@adhdev/daemon-standalone 0.9.76-rc.60 → 0.9.76-rc.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.
package/dist/index.js CHANGED
@@ -31624,10 +31624,10 @@ var require_dist2 = __commonJS({
31624
31624
  return (0, import_path22.join)(getConfigDir(), "meshes.json");
31625
31625
  }
31626
31626
  function loadMeshConfig() {
31627
- const path27 = getMeshConfigPath();
31628
- if (!(0, import_fs2.existsSync)(path27)) return { meshes: [] };
31627
+ const path28 = getMeshConfigPath();
31628
+ if (!(0, import_fs2.existsSync)(path28)) return { meshes: [] };
31629
31629
  try {
31630
- const raw = JSON.parse((0, import_fs2.readFileSync)(path27, "utf-8"));
31630
+ const raw = JSON.parse((0, import_fs2.readFileSync)(path28, "utf-8"));
31631
31631
  if (!raw || !Array.isArray(raw.meshes)) return { meshes: [] };
31632
31632
  return raw;
31633
31633
  } catch {
@@ -31635,16 +31635,16 @@ var require_dist2 = __commonJS({
31635
31635
  }
31636
31636
  }
31637
31637
  function saveMeshConfig(config2) {
31638
- const path27 = getMeshConfigPath();
31639
- (0, import_fs2.writeFileSync)(path27, JSON.stringify(config2, null, 2), { encoding: "utf-8", mode: 384 });
31638
+ const path28 = getMeshConfigPath();
31639
+ (0, import_fs2.writeFileSync)(path28, JSON.stringify(config2, null, 2), { encoding: "utf-8", mode: 384 });
31640
31640
  }
31641
31641
  function normalizeRepoIdentity(remoteUrl) {
31642
31642
  let identity = remoteUrl.trim();
31643
31643
  if (identity.startsWith("http://") || identity.startsWith("https://")) {
31644
31644
  try {
31645
31645
  const url2 = new URL(identity);
31646
- const path27 = url2.pathname.replace(/^\//, "").replace(/\.git$/, "");
31647
- return `${url2.hostname}/${path27}`;
31646
+ const path28 = url2.pathname.replace(/^\//, "").replace(/\.git$/, "");
31647
+ return `${url2.hostname}/${path28}`;
31648
31648
  } catch {
31649
31649
  }
31650
31650
  }
@@ -31802,6 +31802,7 @@ Default branch: \`${mesh.defaultBranch}\`` : ""}`);
31802
31802
  }
31803
31803
  sections.push(buildPolicySection({ ...DEFAULT_MESH_POLICY, ...mesh.policy || {} }));
31804
31804
  sections.push(TOOLS_SECTION);
31805
+ sections.push(TOOL_EXPOSURE_PREFLIGHT_SECTION);
31805
31806
  sections.push(WORKFLOW_SECTION);
31806
31807
  sections.push(buildRulesSection(coordinatorCliType));
31807
31808
  if (userInstruction) {
@@ -31872,6 +31873,7 @@ ${rules.join("\n")}`;
31872
31873
  - **Name worktree branches meaningfully.** Use descriptive names like \`feat/auth-refactor\` or \`fix/build-123\`.${coordinatorNote}`;
31873
31874
  }
31874
31875
  var TOOLS_SECTION;
31876
+ var TOOL_EXPOSURE_PREFLIGHT_SECTION;
31875
31877
  var WORKFLOW_SECTION;
31876
31878
  var init_coordinator_prompt = __esm2({
31877
31879
  "src/mesh/coordinator-prompt.ts"() {
@@ -31891,6 +31893,9 @@ ${rules.join("\n")}`;
31891
31893
  | \`mesh_approve\` | Approve/reject a pending agent action |
31892
31894
  | \`mesh_clone_node\` | Create a worktree node for isolated parallel branch work |
31893
31895
  | \`mesh_remove_node\` | Remove a node (cleans up worktree if applicable) |`;
31896
+ TOOL_EXPOSURE_PREFLIGHT_SECTION = `## Tool Exposure Preflight
31897
+
31898
+ Before doing any coordinator work, confirm that the actual callable tool list includes \`mesh_status\` and the other \`mesh_*\` tools from the table above. If this Repo Mesh coordinator prompt is present but the callable \`mesh_*\` tools are missing, the MCP server/tool manifest is stale or not injected yet. Do not substitute terminal/file/git tools, do not inspect or edit the repository directly, and do not continue as a non-mesh local coding agent. Stop immediately and tell the user to run \`/reload-mcp\` or start a fresh coordinator session so ADHDev can reconnect \`adhdev-mesh\`.`;
31894
31899
  WORKFLOW_SECTION = `## Orchestration Workflow
31895
31900
 
31896
31901
  1. **Assess** \u2014 Call \`mesh_status\` to see which nodes are healthy and available.
@@ -35023,6 +35028,12 @@ ${lastSnapshot}`;
35023
35028
  AcpProviderInstance: () => AcpProviderInstance,
35024
35029
  AgentStreamPoller: () => AgentStreamPoller,
35025
35030
  BUILTIN_CHAT_MESSAGE_KINDS: () => BUILTIN_CHAT_MESSAGE_KINDS,
35031
+ CHAT_MESSAGE_ACTIVITY_SOURCES: () => CHAT_MESSAGE_ACTIVITY_SOURCES,
35032
+ CHAT_MESSAGE_AUDIENCES: () => CHAT_MESSAGE_AUDIENCES,
35033
+ CHAT_MESSAGE_INTERNAL_SOURCES: () => CHAT_MESSAGE_INTERNAL_SOURCES,
35034
+ CHAT_MESSAGE_SOURCES: () => CHAT_MESSAGE_SOURCES,
35035
+ CHAT_MESSAGE_TRANSCRIPT_VISIBILITIES: () => CHAT_MESSAGE_TRANSCRIPT_VISIBILITIES,
35036
+ CHAT_MESSAGE_VISIBILITIES: () => CHAT_MESSAGE_VISIBILITIES,
35026
35037
  CdpDomHandlers: () => CdpDomHandlers,
35027
35038
  CliProviderInstance: () => CliProviderInstance,
35028
35039
  DAEMON_WS_PATH: () => DAEMON_WS_PATH,
@@ -35085,6 +35096,7 @@ ${lastSnapshot}`;
35085
35096
  buildThoughtChatMessage: () => buildThoughtChatMessage,
35086
35097
  buildToolChatMessage: () => buildToolChatMessage,
35087
35098
  buildUserChatMessage: () => buildUserChatMessage,
35099
+ classifyChatMessageVisibility: () => classifyChatMessageVisibility,
35088
35100
  classifyHotChatSessionsForSubscriptionFlush: () => classifyHotChatSessionsForSubscriptionFlush2,
35089
35101
  clearDebugTrace: () => clearDebugTrace,
35090
35102
  compareGitSnapshots: () => compareGitSnapshots,
@@ -35104,6 +35116,9 @@ ${lastSnapshot}`;
35104
35116
  detectIDEs: () => detectIDEs,
35105
35117
  ensureSessionHostReady: () => ensureSessionHostReady2,
35106
35118
  execNpmCommandSync: () => execNpmCommandSync,
35119
+ filterActivityChatMessages: () => filterActivityChatMessages,
35120
+ filterChatMessagesByVisibility: () => filterChatMessagesByVisibility,
35121
+ filterInternalChatMessages: () => filterInternalChatMessages,
35107
35122
  filterUserFacingChatMessages: () => filterUserFacingChatMessages,
35108
35123
  findCdpManager: () => findCdpManager,
35109
35124
  flattenMessageParts: () => flattenMessageParts,
@@ -35135,11 +35150,13 @@ ${lastSnapshot}`;
35135
35150
  initDaemonComponents: () => initDaemonComponents2,
35136
35151
  installExtensions: () => installExtensions,
35137
35152
  installGlobalInterceptor: () => installGlobalInterceptor,
35153
+ isActivityChatMessage: () => isActivityChatMessage,
35138
35154
  isBuiltinChatMessageKind: () => isBuiltinChatMessageKind,
35139
35155
  isCdpConnected: () => isCdpConnected,
35140
35156
  isExtensionInstalled: () => isExtensionInstalled,
35141
35157
  isGitCommandName: () => isGitCommandName,
35142
35158
  isIdeRunning: () => isIdeRunning,
35159
+ isInternalChatMessage: () => isInternalChatMessage,
35143
35160
  isManagedStatusWaiting: () => isManagedStatusWaiting,
35144
35161
  isManagedStatusWorking: () => isManagedStatusWorking,
35145
35162
  isPathInside: () => isPathInside,
@@ -38870,6 +38887,10 @@ ${lastSnapshot}`;
38870
38887
  return parts.map((part) => {
38871
38888
  if (part.type === "text") return part.text;
38872
38889
  if (part.type === "resource") return part.resource.text || "";
38890
+ if (part.type === "image") return part.alt || (part.data ? `[image: ${part.mimeType}]` : "");
38891
+ if (part.type === "audio") return part.transcript || (part.data ? `[audio: ${part.mimeType}]` : "");
38892
+ if (part.type === "video") return part.transcript || (part.data ? `[video: ${part.mimeType}]` : "");
38893
+ if (part.type === "resource_link") return [part.name, part.description].filter(Boolean).join("\n");
38873
38894
  return "";
38874
38895
  }).filter((value) => value.length > 0).join("\n");
38875
38896
  }
@@ -38956,6 +38977,7 @@ ${lastSnapshot}`;
38956
38977
  mimeType: raw.mimeType,
38957
38978
  ...typeof raw.uri === "string" ? { uri: raw.uri } : {},
38958
38979
  ...typeof raw.data === "string" ? { data: raw.data } : {},
38980
+ ...typeof raw.transcript === "string" ? { transcript: raw.transcript } : {},
38959
38981
  ...typeof raw.posterUri === "string" ? { posterUri: raw.posterUri } : {}
38960
38982
  };
38961
38983
  }
@@ -38971,10 +38993,14 @@ ${lastSnapshot}`;
38971
38993
  }
38972
38994
  if (type === "resource_link" && typeof raw.uri === "string") {
38973
38995
  return {
38974
- type: "resource",
38996
+ type,
38975
38997
  uri: raw.uri,
38998
+ name: typeof raw.name === "string" ? raw.name : getUriDisplayName(raw.uri, "resource"),
38999
+ ...typeof raw.title === "string" ? { title: raw.title } : {},
39000
+ ...typeof raw.description === "string" ? { description: raw.description } : {},
38976
39001
  ...typeof raw.mimeType === "string" ? { mimeType: raw.mimeType } : {},
38977
- ...typeof raw.name === "string" ? { name: raw.name } : {}
39002
+ ...typeof raw.size === "number" && Number.isFinite(raw.size) ? { size: raw.size } : {},
39003
+ ...normalizeAnnotationsProperty(raw.annotations)
38978
39004
  };
38979
39005
  }
38980
39006
  return null;
@@ -38989,7 +39015,8 @@ ${lastSnapshot}`;
38989
39015
  type,
38990
39016
  mimeType: raw.mimeType,
38991
39017
  ...typeof raw.uri === "string" ? { uri: raw.uri } : {},
38992
- ...typeof raw.data === "string" ? { data: raw.data } : {}
39018
+ ...typeof raw.data === "string" ? { data: raw.data } : {},
39019
+ ...typeof raw.alt === "string" ? { alt: raw.alt } : {}
38993
39020
  };
38994
39021
  }
38995
39022
  if (type === "audio" && typeof raw.mimeType === "string") {
@@ -39007,6 +39034,7 @@ ${lastSnapshot}`;
39007
39034
  mimeType: raw.mimeType,
39008
39035
  ...typeof raw.uri === "string" ? { uri: raw.uri } : {},
39009
39036
  ...typeof raw.data === "string" ? { data: raw.data } : {},
39037
+ ...typeof raw.transcript === "string" ? { transcript: raw.transcript } : {},
39010
39038
  ...typeof raw.posterUri === "string" ? { posterUri: raw.posterUri } : {}
39011
39039
  };
39012
39040
  }
@@ -39015,8 +39043,11 @@ ${lastSnapshot}`;
39015
39043
  type,
39016
39044
  uri: raw.uri,
39017
39045
  name: raw.name,
39046
+ ...typeof raw.title === "string" ? { title: raw.title } : {},
39047
+ ...typeof raw.description === "string" ? { description: raw.description } : {},
39018
39048
  ...typeof raw.mimeType === "string" ? { mimeType: raw.mimeType } : {},
39019
- ...typeof raw.size === "number" ? { size: raw.size } : {}
39049
+ ...typeof raw.size === "number" && Number.isFinite(raw.size) ? { size: raw.size } : {},
39050
+ ...normalizeAnnotationsProperty(raw.annotations)
39020
39051
  };
39021
39052
  }
39022
39053
  if (type === "resource" && raw.resource && typeof raw.resource === "object") {
@@ -39037,11 +39068,35 @@ ${lastSnapshot}`;
39037
39068
  function flattenInputParts(parts) {
39038
39069
  return parts.map((part) => {
39039
39070
  if (part.type === "text") return part.text;
39040
- if (part.type === "audio") return part.transcript || "";
39041
- if (part.type === "resource") return part.text || "";
39071
+ if (part.type === "image") return part.alt || (part.data ? `[image: ${part.mimeType}]` : "");
39072
+ if (part.type === "audio") return part.transcript || (part.data ? `[audio: ${part.mimeType}]` : "");
39073
+ if (part.type === "video") return part.transcript || (part.data ? `[video: ${part.mimeType}]` : "");
39074
+ if (part.type === "resource_link") return [part.title, part.name, part.description, part.uri].filter(Boolean).join("\n");
39075
+ if (part.type === "resource") return part.text || part.name || part.uri;
39042
39076
  return "";
39043
39077
  }).filter((value) => value.length > 0).join("\n");
39044
39078
  }
39079
+ function getUriDisplayName(uri, fallback) {
39080
+ try {
39081
+ const pathname = uri.startsWith("file://") ? new URL(uri).pathname : uri;
39082
+ return pathname.split(/[\\/]/).filter(Boolean).pop() || fallback;
39083
+ } catch {
39084
+ return uri.split(/[\\/]/).filter(Boolean).pop() || fallback;
39085
+ }
39086
+ }
39087
+ function normalizeAnnotationsProperty(value) {
39088
+ if (!value || typeof value !== "object") return {};
39089
+ const record2 = value;
39090
+ const annotations = {};
39091
+ if (Array.isArray(record2.audience)) {
39092
+ const audience = record2.audience.filter((item) => item === "user" || item === "assistant");
39093
+ if (audience.length > 0) annotations.audience = audience;
39094
+ }
39095
+ if (typeof record2.priority === "number" && Number.isFinite(record2.priority)) {
39096
+ annotations.priority = record2.priority;
39097
+ }
39098
+ return Object.keys(annotations).length > 0 ? { annotations } : {};
39099
+ }
39045
39100
  function flattenContent(content) {
39046
39101
  if (typeof content === "string") return content;
39047
39102
  return flattenMessageParts(normalizeMessageParts(content));
@@ -39157,6 +39212,20 @@ ${lastSnapshot}`;
39157
39212
  }
39158
39213
  };
39159
39214
  var BUILTIN_CHAT_MESSAGE_KINDS = ["standard", "thought", "tool", "terminal", "system"];
39215
+ var CHAT_MESSAGE_VISIBILITIES = ["user", "debug", "internal", "hidden"];
39216
+ var CHAT_MESSAGE_TRANSCRIPT_VISIBILITIES = ["visible", "chat", "user", "debug", "internal", "hidden"];
39217
+ var CHAT_MESSAGE_AUDIENCES = ["chat", "debug", "trace", "internal"];
39218
+ var CHAT_MESSAGE_SOURCES = [
39219
+ "assistant_text",
39220
+ "tool_call",
39221
+ "terminal_command",
39222
+ "runtime_activity",
39223
+ "runtime_status",
39224
+ "provider_chrome",
39225
+ "control"
39226
+ ];
39227
+ var CHAT_MESSAGE_ACTIVITY_SOURCES = ["tool_call", "terminal_command", "runtime_activity"];
39228
+ var CHAT_MESSAGE_INTERNAL_SOURCES = ["runtime_status", "provider_chrome", "control"];
39160
39229
  var KNOWN_CHAT_MESSAGE_KINDS = new Set(BUILTIN_CHAT_MESSAGE_KINDS);
39161
39230
  var CHAT_MESSAGE_KIND_ALIASES = {
39162
39231
  text: "standard",
@@ -39305,37 +39374,162 @@ ${lastSnapshot}`;
39305
39374
  function readStringField(value) {
39306
39375
  return typeof value === "string" ? value.trim().toLowerCase() : "";
39307
39376
  }
39308
- function readVisibilityField(message, meta3) {
39377
+ function readRecordField(message, meta3, key) {
39309
39378
  const record2 = message;
39310
- return readStringField(record2.visibility ?? record2.transcriptVisibility ?? meta3?.visibility ?? meta3?.transcriptVisibility);
39379
+ return record2[key] ?? meta3?.[key];
39311
39380
  }
39312
- function isExplicitlyHiddenFromTranscript(message, meta3) {
39313
- const record2 = message;
39314
- const visibility = readVisibilityField(message, meta3);
39315
- const audience = readStringField(record2.audience ?? meta3?.audience);
39316
- const source = readStringField(record2.source ?? meta3?.source);
39317
- return visibility === "hidden" || visibility === "debug" || visibility === "internal" || audience === "debug" || audience === "trace" || audience === "internal" || source === "runtime_status" || source === "runtime_activity" || source === "provider_chrome" || source === "control" || record2.internal === true || record2.isInternal === true || record2.debug === true || meta3?.internal === true || meta3?.isInternal === true || meta3?.debug === true || meta3?.statusOnly === true || meta3?.controlOnly === true;
39381
+ function readVisibilityField(message, meta3) {
39382
+ return readStringField(readRecordField(message, meta3, "visibility"));
39318
39383
  }
39319
- function isExplicitlyVisibleInTranscript(message, meta3) {
39384
+ function readTranscriptVisibilityField(message, meta3) {
39320
39385
  const record2 = message;
39321
- const visibility = readVisibilityField(message, meta3);
39322
- const audience = readStringField(record2.audience ?? meta3?.audience);
39323
- return visibility === "visible" || visibility === "user" || visibility === "chat" || audience === "chat" || record2.userFacing === true || meta3?.userFacing === true;
39386
+ return readStringField(record2.transcriptVisibility ?? meta3?.transcriptVisibility ?? record2.visibility ?? meta3?.visibility);
39387
+ }
39388
+ var EXPLICIT_HIDDEN_VISIBILITIES = /* @__PURE__ */ new Set(["hidden", "debug", "internal"]);
39389
+ var EXPLICIT_VISIBLE_VISIBILITIES = /* @__PURE__ */ new Set(["visible", "user", "chat"]);
39390
+ var HIDDEN_AUDIENCES = /* @__PURE__ */ new Set(["debug", "trace", "internal"]);
39391
+ var ACTIVITY_SOURCE_SET = new Set(CHAT_MESSAGE_ACTIVITY_SOURCES);
39392
+ var INTERNAL_SOURCE_SET = new Set(CHAT_MESSAGE_INTERNAL_SOURCES);
39393
+ function hasBooleanMarker(message, meta3, keys) {
39394
+ const record2 = message;
39395
+ return keys.some((key) => record2[key] === true || meta3?.[key] === true);
39324
39396
  }
39325
- function isUserFacingChatMessage(message) {
39326
- if (!message) return false;
39327
- const meta3 = readMessageMeta(message);
39328
- if (isExplicitlyHiddenFromTranscript(message, meta3)) return false;
39329
- if (isExplicitlyVisibleInTranscript(message, meta3)) return true;
39330
- const role = typeof message.role === "string" ? message.role.trim().toLowerCase() : "";
39331
- const kind = resolveChatMessageKind(message);
39397
+ function isActivityKind(kind) {
39398
+ return kind === "thought" || kind === "tool" || kind === "terminal";
39399
+ }
39400
+ function isOrdinaryVisibleTurn(message, role, kind) {
39332
39401
  if (role === "user" || role === "human") return kind === "standard" || kind === "";
39333
39402
  if (role === "assistant") return kind === "standard" || kind === "";
39334
39403
  return false;
39335
39404
  }
39405
+ function classifyChatMessageVisibility(message) {
39406
+ if (!message) {
39407
+ return {
39408
+ surface: "internal",
39409
+ isUserFacing: false,
39410
+ isActivityFacing: false,
39411
+ isInternal: true,
39412
+ explicitUserFacing: false,
39413
+ explicitHidden: true,
39414
+ role: "",
39415
+ kind: "standard",
39416
+ visibility: "",
39417
+ transcriptVisibility: "",
39418
+ audience: "",
39419
+ source: ""
39420
+ };
39421
+ }
39422
+ const meta3 = readMessageMeta(message);
39423
+ const role = typeof message.role === "string" ? message.role.trim().toLowerCase() : "";
39424
+ const kind = resolveChatMessageKind(message);
39425
+ const visibility = readVisibilityField(message, meta3);
39426
+ const transcriptVisibility = readTranscriptVisibilityField(message, meta3);
39427
+ const audience = readStringField(readRecordField(message, meta3, "audience"));
39428
+ const source = readStringField(readRecordField(message, meta3, "source"));
39429
+ const explicitHidden = EXPLICIT_HIDDEN_VISIBILITIES.has(visibility) || EXPLICIT_HIDDEN_VISIBILITIES.has(transcriptVisibility) || HIDDEN_AUDIENCES.has(audience) || hasBooleanMarker(message, meta3, ["internal", "isInternal", "debug", "statusOnly", "controlOnly"]);
39430
+ const explicitUserFacing = EXPLICIT_VISIBLE_VISIBILITIES.has(visibility) || EXPLICIT_VISIBLE_VISIBILITIES.has(transcriptVisibility) || audience === "chat" || hasBooleanMarker(message, meta3, ["userFacing"]);
39431
+ if (explicitHidden) {
39432
+ const activityLike = isActivityKind(kind) || ACTIVITY_SOURCE_SET.has(source);
39433
+ return {
39434
+ surface: activityLike ? "activity" : "internal",
39435
+ isUserFacing: false,
39436
+ isActivityFacing: activityLike,
39437
+ isInternal: !activityLike,
39438
+ explicitUserFacing,
39439
+ explicitHidden,
39440
+ role,
39441
+ kind,
39442
+ visibility,
39443
+ transcriptVisibility,
39444
+ audience,
39445
+ source
39446
+ };
39447
+ }
39448
+ if (explicitUserFacing) {
39449
+ return {
39450
+ surface: "chat",
39451
+ isUserFacing: true,
39452
+ isActivityFacing: false,
39453
+ isInternal: false,
39454
+ explicitUserFacing,
39455
+ explicitHidden,
39456
+ role,
39457
+ kind,
39458
+ visibility,
39459
+ transcriptVisibility,
39460
+ audience,
39461
+ source
39462
+ };
39463
+ }
39464
+ if (INTERNAL_SOURCE_SET.has(source) || role === "system" || kind === "system") {
39465
+ return {
39466
+ surface: "internal",
39467
+ isUserFacing: false,
39468
+ isActivityFacing: false,
39469
+ isInternal: true,
39470
+ explicitUserFacing,
39471
+ explicitHidden,
39472
+ role,
39473
+ kind,
39474
+ visibility,
39475
+ transcriptVisibility,
39476
+ audience,
39477
+ source
39478
+ };
39479
+ }
39480
+ if (ACTIVITY_SOURCE_SET.has(source) || isActivityKind(kind)) {
39481
+ return {
39482
+ surface: "activity",
39483
+ isUserFacing: false,
39484
+ isActivityFacing: true,
39485
+ isInternal: false,
39486
+ explicitUserFacing,
39487
+ explicitHidden,
39488
+ role,
39489
+ kind,
39490
+ visibility,
39491
+ transcriptVisibility,
39492
+ audience,
39493
+ source
39494
+ };
39495
+ }
39496
+ const isUserFacing = isOrdinaryVisibleTurn(message, role, kind);
39497
+ return {
39498
+ surface: isUserFacing ? "chat" : "internal",
39499
+ isUserFacing,
39500
+ isActivityFacing: false,
39501
+ isInternal: !isUserFacing,
39502
+ explicitUserFacing,
39503
+ explicitHidden,
39504
+ role,
39505
+ kind,
39506
+ visibility,
39507
+ transcriptVisibility,
39508
+ audience,
39509
+ source
39510
+ };
39511
+ }
39512
+ function isUserFacingChatMessage(message) {
39513
+ return classifyChatMessageVisibility(message).isUserFacing;
39514
+ }
39515
+ function isActivityChatMessage(message) {
39516
+ return classifyChatMessageVisibility(message).isActivityFacing;
39517
+ }
39518
+ function isInternalChatMessage(message) {
39519
+ return classifyChatMessageVisibility(message).isInternal;
39520
+ }
39336
39521
  function filterUserFacingChatMessages(messages) {
39337
39522
  return (Array.isArray(messages) ? messages : []).filter((message) => isUserFacingChatMessage(message));
39338
39523
  }
39524
+ function filterActivityChatMessages(messages) {
39525
+ return (Array.isArray(messages) ? messages : []).filter((message) => isActivityChatMessage(message));
39526
+ }
39527
+ function filterInternalChatMessages(messages) {
39528
+ return (Array.isArray(messages) ? messages : []).filter((message) => isInternalChatMessage(message));
39529
+ }
39530
+ function filterChatMessagesByVisibility(messages, surface) {
39531
+ return (Array.isArray(messages) ? messages : []).filter((message) => classifyChatMessageVisibility(message).surface === surface);
39532
+ }
39339
39533
  function extractProviderControlValues(controls, data) {
39340
39534
  if (!data || typeof data !== "object") return void 0;
39341
39535
  const values = {};
@@ -42525,6 +42719,145 @@ ${effect.notification.body || ""}`.trim();
42525
42719
  }
42526
42720
  return normalized;
42527
42721
  }
42722
+ var VALID_INPUT_MEDIA_TYPES = /* @__PURE__ */ new Set(["text", "image", "audio", "video", "resource"]);
42723
+ var VALID_INPUT_STRATEGIES = /* @__PURE__ */ new Set(["native", "native_acp", "resource_link", "text_fallback", "paste", "upload"]);
42724
+ var TEXT_ONLY_MESSAGE_INPUT_SUPPORT = Object.freeze({
42725
+ text: true,
42726
+ multipart: false,
42727
+ mediaTypes: ["text"],
42728
+ strategies: []
42729
+ });
42730
+ function getProviderLabel(provider) {
42731
+ return provider?.name || provider?.type || "This provider";
42732
+ }
42733
+ function hasNonEmptyFallbackText(input) {
42734
+ return typeof input.textFallback === "string" && input.textFallback.trim().length > 0;
42735
+ }
42736
+ function getRequestedInputMediaTypes(input) {
42737
+ const types = /* @__PURE__ */ new Set();
42738
+ if (hasNonEmptyFallbackText(input) && !input.parts.some((part) => part.type === "text")) {
42739
+ types.add("text");
42740
+ }
42741
+ for (const part of input.parts) {
42742
+ if (VALID_INPUT_MEDIA_TYPES.has(part.type)) {
42743
+ types.add(part.type);
42744
+ }
42745
+ }
42746
+ return Array.from(types);
42747
+ }
42748
+ function getEffectiveSemanticPartCount(input) {
42749
+ let count = input.parts.length;
42750
+ if (hasNonEmptyFallbackText(input) && !input.parts.some((part) => part.type === "text")) {
42751
+ count += 1;
42752
+ }
42753
+ return count;
42754
+ }
42755
+ function assertTextOnlyInput(provider, input) {
42756
+ const unsupported = getRequestedInputMediaTypes(input).filter((type) => type !== "text");
42757
+ if (unsupported.length === 0) return;
42758
+ const label = getProviderLabel(provider);
42759
+ const suffix = unsupported.length === 1 ? "" : "s";
42760
+ throw new Error(`${label} only supports text input; unsupported input type${suffix}: ${unsupported.join(", ")}`);
42761
+ }
42762
+ function getDeclaredProviderInputSupport(provider) {
42763
+ const rawMediaTypes = Array.isArray(provider?.capabilities?.input?.mediaTypes) ? provider?.capabilities?.input?.mediaTypes.filter((type) => VALID_INPUT_MEDIA_TYPES.has(type)) : [];
42764
+ const strategies = normalizeInputStrategyDescriptors(provider?.capabilities?.input?.strategies);
42765
+ return {
42766
+ multipart: provider?.capabilities?.input?.multipart === true,
42767
+ mediaTypes: new Set(rawMediaTypes.length > 0 ? rawMediaTypes : ["text"]),
42768
+ strategies
42769
+ };
42770
+ }
42771
+ function normalizeInputStrategyDescriptors(raw) {
42772
+ if (!Array.isArray(raw)) return [];
42773
+ const result = [];
42774
+ for (const entry of raw) {
42775
+ if (!entry || typeof entry !== "object") continue;
42776
+ const record2 = entry;
42777
+ const mediaType = record2.mediaType;
42778
+ if (typeof mediaType !== "string" || !VALID_INPUT_MEDIA_TYPES.has(mediaType)) continue;
42779
+ const strategies = Array.isArray(record2.strategies) ? record2.strategies.filter((value) => typeof value === "string" && VALID_INPUT_STRATEGIES.has(value)) : [];
42780
+ const degradation = Array.isArray(record2.degradation) ? record2.degradation.filter((value) => typeof value === "string" && VALID_INPUT_STRATEGIES.has(value)) : [];
42781
+ if (strategies.length === 0 && degradation.length === 0) continue;
42782
+ result.push({
42783
+ mediaType,
42784
+ strategies,
42785
+ ...typeof record2.native === "boolean" ? { native: record2.native } : {},
42786
+ ...degradation.length > 0 ? { degradation } : {}
42787
+ });
42788
+ }
42789
+ return result;
42790
+ }
42791
+ function promptCapabilityFlags(runtimeCapabilities) {
42792
+ const prompt = runtimeCapabilities?.promptCapabilities || {};
42793
+ return {
42794
+ image: prompt.image === true,
42795
+ audio: prompt.audio === true,
42796
+ embeddedContext: prompt.embeddedContext === true
42797
+ };
42798
+ }
42799
+ function supportFromDeclared(provider) {
42800
+ const declared = getDeclaredProviderInputSupport(provider);
42801
+ return {
42802
+ text: true,
42803
+ multipart: declared.multipart,
42804
+ mediaTypes: Array.from(declared.mediaTypes),
42805
+ strategies: declared.strategies
42806
+ };
42807
+ }
42808
+ function getEffectiveMessageInputSupport(provider, runtimeCapabilities) {
42809
+ if (provider?.category !== "acp") {
42810
+ const declared2 = supportFromDeclared(provider);
42811
+ return {
42812
+ ...declared2,
42813
+ mediaTypes: [...declared2.mediaTypes],
42814
+ strategies: declared2.strategies.map((strategy) => ({
42815
+ ...strategy,
42816
+ strategies: [...strategy.strategies],
42817
+ ...strategy.degradation ? { degradation: [...strategy.degradation] } : {}
42818
+ }))
42819
+ };
42820
+ }
42821
+ const declared = supportFromDeclared(provider);
42822
+ const caps = promptCapabilityFlags(runtimeCapabilities);
42823
+ const mediaTypes = /* @__PURE__ */ new Set(["text"]);
42824
+ const strategies = [];
42825
+ if (declared.mediaTypes.includes("resource")) {
42826
+ mediaTypes.add("resource");
42827
+ strategies.push({ mediaType: "resource", strategies: caps.embeddedContext ? ["native_acp", "resource_link", "text_fallback"] : ["resource_link", "text_fallback"], native: caps.embeddedContext, degradation: ["resource_link", "text_fallback"] });
42828
+ }
42829
+ if (declared.mediaTypes.includes("video")) {
42830
+ mediaTypes.add("video");
42831
+ strategies.push({ mediaType: "video", strategies: ["resource_link", "text_fallback"], native: false, degradation: ["resource_link", "text_fallback"] });
42832
+ }
42833
+ if (declared.mediaTypes.includes("image")) {
42834
+ mediaTypes.add("image");
42835
+ strategies.push({ mediaType: "image", strategies: caps.image ? ["native_acp", "resource_link", "text_fallback"] : ["resource_link", "text_fallback"], native: caps.image, degradation: ["resource_link", "text_fallback"] });
42836
+ }
42837
+ if (declared.mediaTypes.includes("audio")) {
42838
+ mediaTypes.add("audio");
42839
+ strategies.push({ mediaType: "audio", strategies: caps.audio ? ["native_acp", "resource_link", "text_fallback"] : ["resource_link", "text_fallback"], native: caps.audio, degradation: ["resource_link", "text_fallback"] });
42840
+ }
42841
+ return {
42842
+ text: true,
42843
+ multipart: declared.multipart && mediaTypes.size > 1,
42844
+ mediaTypes: Array.from(mediaTypes),
42845
+ strategies
42846
+ };
42847
+ }
42848
+ function assertProviderSupportsDeclaredInput(provider, input) {
42849
+ const label = getProviderLabel(provider);
42850
+ const support = getDeclaredProviderInputSupport(provider);
42851
+ const requestedTypes = getRequestedInputMediaTypes(input);
42852
+ const unsupported = requestedTypes.filter((type) => !support.mediaTypes.has(type));
42853
+ if (unsupported.length > 0) {
42854
+ const suffix = unsupported.length === 1 ? "" : "s";
42855
+ throw new Error(`${label} does not support input type${suffix}: ${unsupported.join(", ")}`);
42856
+ }
42857
+ if (getEffectiveSemanticPartCount(input) > 1 && !support.multipart) {
42858
+ throw new Error(`${label} does not support multipart input`);
42859
+ }
42860
+ }
42528
42861
  function getActiveChatOptions(profile) {
42529
42862
  if (profile === "full") return {};
42530
42863
  return LIVE_STATUS_ACTIVE_CHAT_OPTIONS;
@@ -42621,7 +42954,7 @@ ${effect.notification.body || ""}`.trim();
42621
42954
  ...git && { git },
42622
42955
  activeChat,
42623
42956
  ...summaryMetadata && { summaryMetadata },
42624
- ...includeSessionMetadata && { capabilities: state.sessionCapabilities || IDE_SESSION_CAPABILITIES },
42957
+ ...includeSessionMetadata && { capabilities: state.sessionCapabilities || IDE_SESSION_CAPABILITIES, messageInput: state.messageInput || TEXT_ONLY_MESSAGE_INPUT_SUPPORT },
42625
42958
  cdpConnected: state.cdpConnected ?? isCdpConnected(cdpManagers, state.type),
42626
42959
  ...includeSessionControls && {
42627
42960
  ...controlValues && { controlValues },
@@ -42656,7 +42989,7 @@ ${effect.notification.body || ""}`.trim();
42656
42989
  ...git && { git },
42657
42990
  activeChat,
42658
42991
  ...summaryMetadata && { summaryMetadata },
42659
- ...includeSessionMetadata && { capabilities: ext.sessionCapabilities || EXTENSION_SESSION_CAPABILITIES },
42992
+ ...includeSessionMetadata && { capabilities: ext.sessionCapabilities || EXTENSION_SESSION_CAPABILITIES, messageInput: ext.messageInput || TEXT_ONLY_MESSAGE_INPUT_SUPPORT },
42660
42993
  ...includeSessionControls && {
42661
42994
  ...controlValues && { controlValues },
42662
42995
  providerControls: ext.providerControls
@@ -42720,7 +43053,8 @@ ${effect.notification.body || ""}`.trim();
42720
43053
  activeChat,
42721
43054
  ...summaryMetadata && { summaryMetadata },
42722
43055
  ...includeSessionMetadata && {
42723
- capabilities: state.mode === "terminal" ? PTY_SESSION_CAPABILITIES : CLI_CHAT_SESSION_CAPABILITIES
43056
+ capabilities: state.mode === "terminal" ? PTY_SESSION_CAPABILITIES : CLI_CHAT_SESSION_CAPABILITIES,
43057
+ messageInput: state.messageInput || TEXT_ONLY_MESSAGE_INPUT_SUPPORT
42724
43058
  },
42725
43059
  ...includeSessionControls && {
42726
43060
  ...controlValues && { controlValues },
@@ -42754,7 +43088,7 @@ ${effect.notification.body || ""}`.trim();
42754
43088
  ...git && { git },
42755
43089
  activeChat,
42756
43090
  ...summaryMetadata && { summaryMetadata },
42757
- ...includeSessionMetadata && { capabilities: ACP_SESSION_CAPABILITIES },
43091
+ ...includeSessionMetadata && { capabilities: ACP_SESSION_CAPABILITIES, messageInput: state.messageInput || TEXT_ONLY_MESSAGE_INPUT_SUPPORT },
42758
43092
  ...includeSessionControls && {
42759
43093
  ...controlValues && { controlValues },
42760
43094
  providerControls: state.providerControls
@@ -42865,59 +43199,6 @@ ${effect.notification.body || ""}`.trim();
42865
43199
  var os62 = __toESM2(require("os"));
42866
43200
  var path12 = __toESM2(require("path"));
42867
43201
  var import_node_crypto = require("crypto");
42868
- var VALID_INPUT_MEDIA_TYPES = /* @__PURE__ */ new Set(["text", "image", "audio", "video", "resource"]);
42869
- function getProviderLabel(provider) {
42870
- return provider?.name || provider?.type || "This provider";
42871
- }
42872
- function hasNonEmptyFallbackText(input) {
42873
- return typeof input.textFallback === "string" && input.textFallback.trim().length > 0;
42874
- }
42875
- function getRequestedInputMediaTypes(input) {
42876
- const types = /* @__PURE__ */ new Set();
42877
- if (hasNonEmptyFallbackText(input) && !input.parts.some((part) => part.type === "text")) {
42878
- types.add("text");
42879
- }
42880
- for (const part of input.parts) {
42881
- if (VALID_INPUT_MEDIA_TYPES.has(part.type)) {
42882
- types.add(part.type);
42883
- }
42884
- }
42885
- return Array.from(types);
42886
- }
42887
- function getEffectiveSemanticPartCount(input) {
42888
- let count = input.parts.length;
42889
- if (hasNonEmptyFallbackText(input) && !input.parts.some((part) => part.type === "text")) {
42890
- count += 1;
42891
- }
42892
- return count;
42893
- }
42894
- function assertTextOnlyInput(provider, input) {
42895
- const unsupported = getRequestedInputMediaTypes(input).filter((type) => type !== "text");
42896
- if (unsupported.length === 0) return;
42897
- const label = getProviderLabel(provider);
42898
- const suffix = unsupported.length === 1 ? "" : "s";
42899
- throw new Error(`${label} only supports text input; unsupported input type${suffix}: ${unsupported.join(", ")}`);
42900
- }
42901
- function getDeclaredProviderInputSupport(provider) {
42902
- const rawMediaTypes = Array.isArray(provider?.capabilities?.input?.mediaTypes) ? provider?.capabilities?.input?.mediaTypes.filter((type) => VALID_INPUT_MEDIA_TYPES.has(type)) : [];
42903
- return {
42904
- multipart: provider?.capabilities?.input?.multipart === true,
42905
- mediaTypes: new Set(rawMediaTypes.length > 0 ? rawMediaTypes : ["text"])
42906
- };
42907
- }
42908
- function assertProviderSupportsDeclaredInput(provider, input) {
42909
- const label = getProviderLabel(provider);
42910
- const support = getDeclaredProviderInputSupport(provider);
42911
- const requestedTypes = getRequestedInputMediaTypes(input);
42912
- const unsupported = requestedTypes.filter((type) => !support.mediaTypes.has(type));
42913
- if (unsupported.length > 0) {
42914
- const suffix = unsupported.length === 1 ? "" : "s";
42915
- throw new Error(`${label} does not support input type${suffix}: ${unsupported.join(", ")}`);
42916
- }
42917
- if (getEffectiveSemanticPartCount(input) > 1 && !support.multipart) {
42918
- throw new Error(`${label} does not support multipart input`);
42919
- }
42920
- }
42921
43202
  init_logger();
42922
43203
  init_debug_config();
42923
43204
  function summarizeString(value) {
@@ -43101,10 +43382,25 @@ ${effect.notification.body || ""}`.trim();
43101
43382
  const target = args?.targetSessionId || args?.agentType || h.currentSession?.providerType || h.currentProviderType || h.currentManagerKey || "unknown";
43102
43383
  return `${transport}:${target}:${signature.trim()}`;
43103
43384
  }
43385
+ function summarizeSendInputPart(part) {
43386
+ if (!part || typeof part !== "object") return String(part ?? "");
43387
+ if (part.type === "text") return `text:${String(part.text || "").trim()}`;
43388
+ const fields = [
43389
+ `type=${String(part.type || "")}`,
43390
+ `mime=${String(part.mimeType || "")}`,
43391
+ `uri=${String(part.uri || "")}`,
43392
+ `name=${String(part.name || "")}`
43393
+ ];
43394
+ const data = typeof part.data === "string" ? part.data : typeof part.resource?.blob === "string" ? part.resource.blob : "";
43395
+ if (data) fields.push(`dataLen=${data.length}`, `dataHash=${hashSignatureParts([data]).slice(0, 12)}`);
43396
+ const textish = [part.alt, part.transcript, part.description, part.title, part.resource?.uri].filter((value) => typeof value === "string" && value.trim()).join("");
43397
+ if (textish) fields.push(`meta=${hashSignatureParts([textish]).slice(0, 12)}`);
43398
+ return fields.join(";");
43399
+ }
43104
43400
  function buildSendInputSignature(input) {
43105
43401
  const text = typeof input.textFallback === "string" ? input.textFallback.trim() : "";
43106
- if (text) return text;
43107
- return JSON.stringify(input.parts || []);
43402
+ const partSummaries = (input.parts || []).map(summarizeSendInputPart);
43403
+ return hashSignatureParts([text, ...partSummaries]);
43108
43404
  }
43109
43405
  function getSendChatInputEnvelope(args) {
43110
43406
  return normalizeInputEnvelope(args?.input ? { input: args.input } : args);
@@ -43985,6 +44281,17 @@ ${effect.notification.body || ""}`.trim();
43985
44281
  if (adapter) {
43986
44282
  _log(`${transport} adapter: ${adapter.cliType}`);
43987
44283
  try {
44284
+ const hasStructuredParts = input.parts.some((part) => part.type !== "text");
44285
+ if (hasStructuredParts) {
44286
+ const target = getTargetInstance(h, args);
44287
+ if (!target || target.category !== "cli") {
44288
+ return { success: false, error: `CLI instance not found for ${provider?.type || args?.agentType || "unknown"}` };
44289
+ }
44290
+ assertProviderSupportsDeclaredInput(provider, input);
44291
+ await waitOnceForFreshHermesCliStart(adapter, _log);
44292
+ target.onEvent("send_message", { input });
44293
+ return _logSendSuccess(`${transport}-instance`, target.type);
44294
+ }
43988
44295
  assertTextOnlyInput(provider, input);
43989
44296
  if (!text) return { success: false, error: "text required for PTY send" };
43990
44297
  await waitOnceForFreshHermesCliStart(adapter, _log);
@@ -46058,7 +46365,7 @@ ${effect.notification.body || ""}`.trim();
46058
46365
  }
46059
46366
  };
46060
46367
  var os13 = __toESM2(require("os"));
46061
- var path17 = __toESM2(require("path"));
46368
+ var path18 = __toESM2(require("path"));
46062
46369
  var crypto4 = __toESM2(require("crypto"));
46063
46370
  var import_fs6 = require("fs");
46064
46371
  var import_child_process6 = require("child_process");
@@ -46087,6 +46394,79 @@ ${effect.notification.body || ""}`.trim();
46087
46394
  }
46088
46395
  return normalizedId;
46089
46396
  }
46397
+ var IMAGE_MIME_EXTENSIONS = {
46398
+ "image/png": ".png",
46399
+ "image/jpeg": ".jpg",
46400
+ "image/jpg": ".jpg",
46401
+ "image/gif": ".gif",
46402
+ "image/webp": ".webp",
46403
+ "image/bmp": ".bmp",
46404
+ "image/tiff": ".tiff",
46405
+ "image/svg+xml": ".svg"
46406
+ };
46407
+ function filePathFromUri(uri) {
46408
+ if (!uri) return null;
46409
+ if (uri.startsWith("file://")) {
46410
+ try {
46411
+ return decodeURIComponent(new URL(uri).pathname);
46412
+ } catch {
46413
+ return uri.slice("file://".length);
46414
+ }
46415
+ }
46416
+ if (path16.isAbsolute(uri)) return uri;
46417
+ return null;
46418
+ }
46419
+ function extensionForImageMime(mimeType) {
46420
+ return IMAGE_MIME_EXTENSIONS[mimeType.toLowerCase()] || ".img";
46421
+ }
46422
+ function safeInputImageBasename(index, mimeType) {
46423
+ const extension = extensionForImageMime(mimeType);
46424
+ const suffix = crypto3.randomBytes(6).toString("hex");
46425
+ return `adhdev-input-image-${Date.now()}-${index}-${suffix}${extension}`;
46426
+ }
46427
+ function materializeImageDataPart(part, index, dir) {
46428
+ if (!part.data) return null;
46429
+ const rawData = part.data.includes(",") ? part.data.split(",").pop() || "" : part.data;
46430
+ if (!rawData) return null;
46431
+ fs6.mkdirSync(dir, { recursive: true });
46432
+ const filePath = path16.join(dir, safeInputImageBasename(index, part.mimeType));
46433
+ fs6.writeFileSync(filePath, Buffer.from(rawData, "base64"));
46434
+ return filePath;
46435
+ }
46436
+ function buildCliStructuredInputPrompt(input, options = {}) {
46437
+ const promptParts = [];
46438
+ const imageRefs = [];
46439
+ const resourceRefs = [];
46440
+ const materializeDir = options.materializeDir || path16.join(os12.tmpdir(), "adhdev-input-media");
46441
+ input.parts.forEach((part, index) => {
46442
+ if (part.type === "text" && part.text.trim()) {
46443
+ promptParts.push(part.text.trim());
46444
+ return;
46445
+ }
46446
+ if (part.type === "image") {
46447
+ const localPath = typeof part.uri === "string" ? filePathFromUri(part.uri) : null;
46448
+ const materializedPath = !localPath && part.data ? materializeImageDataPart(part, index, materializeDir) : null;
46449
+ const ref = localPath || materializedPath || part.uri || "";
46450
+ if (ref) imageRefs.push(ref);
46451
+ if (part.alt?.trim()) promptParts.push(part.alt.trim());
46452
+ return;
46453
+ }
46454
+ if (part.type === "resource_link") {
46455
+ resourceRefs.push([part.title, part.name, part.description, part.uri].filter(Boolean).join("\n"));
46456
+ return;
46457
+ }
46458
+ if (part.type === "resource") {
46459
+ resourceRefs.push([part.name, part.text, part.uri].filter(Boolean).join("\n"));
46460
+ }
46461
+ });
46462
+ if (input.textFallback.trim()) promptParts.push(input.textFallback.trim());
46463
+ const ordered = [
46464
+ ...imageRefs,
46465
+ ...promptParts,
46466
+ ...resourceRefs
46467
+ ].filter((value, index, values) => value.trim().length > 0 && values.indexOf(value) === index);
46468
+ return ordered.join("\n");
46469
+ }
46090
46470
  function normalizePersistableCliHistoryContent(content) {
46091
46471
  return flattenContent(content).replace(/\s+/g, " ").trim();
46092
46472
  }
@@ -46406,6 +46786,7 @@ ${effect.notification.body || ""}`.trim();
46406
46786
  resume: this.provider.resume,
46407
46787
  controlValues: surface.controlValues,
46408
46788
  providerControls: this.provider.controls,
46789
+ messageInput: getEffectiveMessageInputSupport(this.provider),
46409
46790
  summaryMetadata: surface.summaryMetadata,
46410
46791
  errorMessage: this.errorMessage,
46411
46792
  errorReason: this.errorReason
@@ -46456,9 +46837,10 @@ ${effect.notification.body || ""}`.trim();
46456
46837
  onEvent(event, data) {
46457
46838
  if (event === "send_message") {
46458
46839
  const input = normalizeInputEnvelope(data);
46459
- assertTextOnlyInput(this.provider, input);
46460
- if (input.textFallback) {
46461
- void this.adapter.sendMessage(input.textFallback).catch((e) => {
46840
+ assertProviderSupportsDeclaredInput(this.provider, input);
46841
+ const promptText = buildCliStructuredInputPrompt(input);
46842
+ if (promptText) {
46843
+ void this.adapter.sendMessage(promptText).catch((e) => {
46462
46844
  LOG2.warn("CLI", `[${this.type}] send_message failed: ${e?.message || e}`);
46463
46845
  });
46464
46846
  }
@@ -47085,6 +47467,7 @@ ${effect.notification.body || ""}`.trim();
47085
47467
  }
47086
47468
  }
47087
47469
  };
47470
+ var path17 = __toESM2(require("path"));
47088
47471
  var import_stream = require("stream");
47089
47472
  var import_child_process5 = require("child_process");
47090
47473
  var import_sdk = (init_acp(), __toCommonJS(acp_exports));
@@ -47104,6 +47487,31 @@ ${effect.notification.body || ""}`.trim();
47104
47487
  if (last?.type === "text" && last.text === normalized) return;
47105
47488
  promptParts.push({ type: "text", text: normalized });
47106
47489
  }
47490
+ function getUriDisplayName2(uri, fallback) {
47491
+ if (!uri) return fallback;
47492
+ try {
47493
+ const pathname = uri.startsWith("file://") ? new URL(uri).pathname : uri;
47494
+ return pathname.split(/[\\/]/).filter(Boolean).pop() || fallback;
47495
+ } catch {
47496
+ return uri.split(/[\\/]/).filter(Boolean).pop() || fallback;
47497
+ }
47498
+ }
47499
+ function appendResourceLink(promptParts, uri, fallbackName, mimeType, description, metadata) {
47500
+ promptParts.push({
47501
+ type: "resource_link",
47502
+ uri,
47503
+ name: metadata?.name || getUriDisplayName2(uri, fallbackName),
47504
+ ...metadata?.title ? { title: metadata.title } : {},
47505
+ ...mimeType ? { mimeType } : {},
47506
+ ...description ? { description } : {},
47507
+ ...typeof metadata?.size === "number" ? { size: metadata.size } : {},
47508
+ ...metadata?.annotations ? { annotations: metadata.annotations } : {}
47509
+ });
47510
+ }
47511
+ function appendMediaFallbackText(promptParts, label, details) {
47512
+ const normalizedDetails = details.map((value) => typeof value === "string" ? value.trim() : "").filter(Boolean);
47513
+ appendPromptText(promptParts, `[${[label, ...normalizedDetails].join(": ")}]`);
47514
+ }
47107
47515
  function buildAcpPromptParts(input, agentCapabilities) {
47108
47516
  const caps = getPromptCapabilityFlags(agentCapabilities);
47109
47517
  const promptParts = [];
@@ -47113,56 +47521,76 @@ ${effect.notification.body || ""}`.trim();
47113
47521
  continue;
47114
47522
  }
47115
47523
  if (part.type === "image") {
47116
- if (!caps.image) {
47117
- throw new Error("ACP agent does not support input type: image");
47118
- }
47119
- if (!part.data) {
47120
- throw new Error("ACP image input requires inline image data");
47524
+ if (caps.image && part.data) {
47525
+ promptParts.push({
47526
+ type: "image",
47527
+ data: part.data,
47528
+ mimeType: part.mimeType,
47529
+ ...part.uri ? { uri: part.uri } : {},
47530
+ ...part.alt ? { alt: part.alt } : {}
47531
+ });
47532
+ if (part.alt) appendPromptText(promptParts, part.alt);
47533
+ } else if (part.uri) {
47534
+ appendResourceLink(promptParts, part.uri, "image", part.mimeType, part.alt);
47535
+ if (part.alt) appendPromptText(promptParts, part.alt);
47536
+ } else {
47537
+ appendMediaFallbackText(promptParts, "Image attachment", [part.alt, part.mimeType]);
47121
47538
  }
47122
- promptParts.push({
47123
- type: "image",
47124
- data: part.data,
47125
- mimeType: part.mimeType,
47126
- ...part.uri ? { uri: part.uri } : {}
47127
- });
47128
47539
  continue;
47129
47540
  }
47130
47541
  if (part.type === "audio") {
47131
- if (!caps.audio) {
47132
- throw new Error("ACP agent does not support input type: audio");
47133
- }
47134
- if (!part.data) {
47135
- throw new Error("ACP audio input requires inline audio data");
47542
+ if (caps.audio && part.data) {
47543
+ promptParts.push({
47544
+ type: "audio",
47545
+ data: part.data,
47546
+ mimeType: part.mimeType,
47547
+ ...part.uri ? { uri: part.uri } : {},
47548
+ ...part.transcript ? { transcript: part.transcript } : {}
47549
+ });
47550
+ if (part.transcript) appendPromptText(promptParts, part.transcript);
47551
+ } else if (part.uri) {
47552
+ appendResourceLink(promptParts, part.uri, "audio", part.mimeType, part.transcript);
47553
+ if (part.transcript) appendPromptText(promptParts, part.transcript);
47554
+ } else {
47555
+ appendMediaFallbackText(promptParts, "Audio attachment", [part.transcript, part.mimeType]);
47136
47556
  }
47137
- promptParts.push({
47138
- type: "audio",
47139
- data: part.data,
47140
- mimeType: part.mimeType
47141
- });
47142
47557
  continue;
47143
47558
  }
47144
47559
  if (part.type === "resource") {
47145
- if (!caps.embeddedContext) {
47146
- throw new Error("ACP agent does not support input type: resource");
47147
- }
47148
- if (part.text) {
47560
+ if (caps.embeddedContext && part.text) {
47149
47561
  promptParts.push({
47150
47562
  type: "resource",
47151
47563
  resource: { uri: part.uri, text: part.text, mimeType: part.mimeType ?? null }
47152
47564
  });
47153
47565
  continue;
47154
47566
  }
47155
- if (part.data) {
47567
+ if (caps.embeddedContext && part.data) {
47156
47568
  promptParts.push({
47157
47569
  type: "resource",
47158
47570
  resource: { uri: part.uri, blob: part.data, mimeType: part.mimeType ?? null }
47159
47571
  });
47160
47572
  continue;
47161
47573
  }
47162
- throw new Error("ACP resource input requires embedded text or binary data");
47574
+ appendResourceLink(promptParts, part.uri, part.name || "resource", part.mimeType, part.text);
47575
+ if (part.text) appendPromptText(promptParts, part.text);
47576
+ continue;
47577
+ }
47578
+ if (part.type === "resource_link") {
47579
+ appendResourceLink(promptParts, part.uri, part.name, part.mimeType, part.description, {
47580
+ name: part.name,
47581
+ ...part.title ? { title: part.title } : {},
47582
+ ...typeof part.size === "number" ? { size: part.size } : {},
47583
+ ...part.annotations ? { annotations: part.annotations } : {}
47584
+ });
47585
+ continue;
47163
47586
  }
47164
47587
  if (part.type === "video") {
47165
- throw new Error("ACP agent does not support input type: video");
47588
+ if (part.uri) {
47589
+ appendResourceLink(promptParts, part.uri, "video", part.mimeType, part.transcript);
47590
+ if (part.transcript) appendPromptText(promptParts, part.transcript);
47591
+ } else {
47592
+ appendMediaFallbackText(promptParts, "Video attachment", [part.transcript, part.mimeType]);
47593
+ }
47166
47594
  }
47167
47595
  }
47168
47596
  if (!promptParts.some((part) => part.type === "text") && input.textFallback) {
@@ -47295,6 +47723,7 @@ ${effect.notification.body || ""}`.trim();
47295
47723
  lastUpdated: Date.now(),
47296
47724
  settings: this.settings,
47297
47725
  pendingEvents: this.flushEvents(),
47726
+ messageInput: getEffectiveMessageInputSupport(this.provider, this.agentCapabilities),
47298
47727
  // ACP-specific: expose available models/modes for dashboard
47299
47728
  acpConfigOptions: this.configOptions,
47300
47729
  acpModes: this.availableModes,
@@ -47796,22 +48225,38 @@ ${effect.notification.body || ""}`.trim();
47796
48225
  type: "image",
47797
48226
  data: b2.data,
47798
48227
  mimeType: b2.mimeType,
47799
- ...b2.uri ? { uri: b2.uri } : {}
48228
+ ...b2.uri ? { uri: b2.uri } : {},
48229
+ ...b2.alt ? { alt: b2.alt } : {}
47800
48230
  };
47801
48231
  }
47802
48232
  if (b2.type === "audio") {
47803
48233
  return {
47804
48234
  type: "audio",
47805
48235
  data: b2.data,
47806
- mimeType: b2.mimeType
48236
+ mimeType: b2.mimeType,
48237
+ ...b2.uri ? { uri: b2.uri } : {},
48238
+ ...b2.transcript ? { transcript: b2.transcript } : {}
47807
48239
  };
47808
48240
  }
48241
+ if (b2.type === "video") {
48242
+ return b2.uri ? {
48243
+ type: "resource_link",
48244
+ uri: b2.uri,
48245
+ name: path17.basename(b2.uri),
48246
+ mimeType: b2.mimeType,
48247
+ ...b2.transcript ? { description: b2.transcript } : {}
48248
+ } : { type: "text", text: b2.transcript || `[Video attachment: ${b2.mimeType}]` };
48249
+ }
47809
48250
  if (b2.type === "resource_link") {
47810
48251
  return {
47811
48252
  type: "resource_link",
47812
48253
  uri: b2.uri,
47813
48254
  name: b2.name,
47814
- ...b2.mimeType ? { mimeType: b2.mimeType } : {}
48255
+ ...b2.title ? { title: b2.title } : {},
48256
+ ...b2.description ? { description: b2.description } : {},
48257
+ ...b2.mimeType ? { mimeType: b2.mimeType } : {},
48258
+ ...typeof b2.size === "number" ? { size: b2.size } : {},
48259
+ ...b2.annotations ? { annotations: b2.annotations } : {}
47815
48260
  };
47816
48261
  }
47817
48262
  if (b2.type === "resource") return { type: "resource", resource: b2.resource };
@@ -47887,7 +48332,18 @@ ${effect.notification.body || ""}`.trim();
47887
48332
  this.partialBlocks.push({
47888
48333
  type: "audio",
47889
48334
  data: content.data,
47890
- mimeType: content.mimeType
48335
+ mimeType: content.mimeType,
48336
+ ...content.uri ? { uri: content.uri } : {},
48337
+ ...content.transcript ? { transcript: content.transcript } : {}
48338
+ });
48339
+ } else if (content.type === "video") {
48340
+ this.partialBlocks.push({
48341
+ type: "video",
48342
+ data: content.data,
48343
+ mimeType: content.mimeType,
48344
+ ...content.uri ? { uri: content.uri } : {},
48345
+ ...content.transcript ? { transcript: content.transcript } : {},
48346
+ ...content.posterUri ? { posterUri: content.posterUri } : {}
47891
48347
  });
47892
48348
  } else if (content.type === "resource_link") {
47893
48349
  this.partialBlocks.push({
@@ -48238,11 +48694,11 @@ ${rawInput}` : rawInput;
48238
48694
  }
48239
48695
  function isExplicitCommand(command) {
48240
48696
  const trimmed = command.trim();
48241
- return path17.isAbsolute(trimmed) || trimmed.includes("/") || trimmed.includes("\\") || trimmed.startsWith("~");
48697
+ return path18.isAbsolute(trimmed) || trimmed.includes("/") || trimmed.includes("\\") || trimmed.startsWith("~");
48242
48698
  }
48243
48699
  function expandExecutable(command) {
48244
48700
  const trimmed = command.trim();
48245
- return trimmed.startsWith("~") ? path17.join(os13.homedir(), trimmed.slice(1)) : trimmed;
48701
+ return trimmed.startsWith("~") ? path18.join(os13.homedir(), trimmed.slice(1)) : trimmed;
48246
48702
  }
48247
48703
  function commandExists(command) {
48248
48704
  const trimmed = command.trim();
@@ -48276,10 +48732,10 @@ ${rawInput}` : rawInput;
48276
48732
  return args.some((arg) => arg === flag || arg.startsWith(`${flag}=`));
48277
48733
  }
48278
48734
  function ensureEmptyDelegatedMcpConfig(workspace) {
48279
- const baseDir = path17.join(os13.tmpdir(), "adhdev-delegated-agent-empty-mcp");
48735
+ const baseDir = path18.join(os13.tmpdir(), "adhdev-delegated-agent-empty-mcp");
48280
48736
  (0, import_fs6.mkdirSync)(baseDir, { recursive: true });
48281
- const workspaceHash = crypto4.createHash("sha256").update(path17.resolve(workspace || os13.tmpdir())).digest("hex").slice(0, 16);
48282
- const filePath = path17.join(baseDir, `${workspaceHash}.json`);
48737
+ const workspaceHash = crypto4.createHash("sha256").update(path18.resolve(workspace || os13.tmpdir())).digest("hex").slice(0, 16);
48738
+ const filePath = path18.join(baseDir, `${workspaceHash}.json`);
48283
48739
  (0, import_fs6.writeFileSync)(filePath, JSON.stringify({ mcpServers: {} }, null, 2), "utf-8");
48284
48740
  return filePath;
48285
48741
  }
@@ -48552,7 +49008,7 @@ ${rawInput}` : rawInput;
48552
49008
  async startSession(cliType, workingDir, cliArgs, initialModel, options) {
48553
49009
  const trimmed = (workingDir || "").trim();
48554
49010
  if (!trimmed) throw new Error("working directory required");
48555
- const resolvedDir = trimmed.startsWith("~") ? trimmed.replace(/^~/, os13.homedir()) : path17.resolve(trimmed);
49011
+ const resolvedDir = trimmed.startsWith("~") ? trimmed.replace(/^~/, os13.homedir()) : path18.resolve(trimmed);
48556
49012
  const normalizedType = this.providerLoader.resolveAlias(cliType);
48557
49013
  const rawProvider = this.providerLoader.getByAlias(cliType);
48558
49014
  const provider = rawProvider ? this.providerLoader.resolve(normalizedType) || rawProvider : void 0;
@@ -49064,13 +49520,14 @@ Run 'adhdev doctor' for detailed diagnostics.`
49064
49520
  var import_child_process7 = require("child_process");
49065
49521
  var net3 = __toESM2(require("net"));
49066
49522
  var os15 = __toESM2(require("os"));
49067
- var path19 = __toESM2(require("path"));
49523
+ var path20 = __toESM2(require("path"));
49068
49524
  var fs7 = __toESM2(require("fs"));
49069
- var path18 = __toESM2(require("path"));
49525
+ var path19 = __toESM2(require("path"));
49070
49526
  var os14 = __toESM2(require("os"));
49071
49527
  var chokidar = __toESM2(require_chokidar());
49072
49528
  init_logger();
49073
49529
  var VALID_CAPABILITY_MEDIA_TYPES = /* @__PURE__ */ new Set(["text", "image", "audio", "video", "resource"]);
49530
+ var VALID_INPUT_STRATEGIES2 = /* @__PURE__ */ new Set(["native", "native_acp", "resource_link", "text_fallback", "paste", "upload"]);
49074
49531
  var KNOWN_PROVIDER_FIELDS = /* @__PURE__ */ new Set([
49075
49532
  "type",
49076
49533
  "name",
@@ -49200,16 +49657,45 @@ Run 'adhdev doctor' for detailed diagnostics.`
49200
49657
  return;
49201
49658
  }
49202
49659
  const input = capabilities.input;
49203
- if (!input || typeof input !== "object") {
49204
- errors.push("capabilities.input is required");
49205
- } else {
49206
- if (typeof input.multipart !== "boolean") {
49660
+ if (input !== void 0) {
49661
+ if (!input || typeof input !== "object") {
49662
+ errors.push("capabilities.input must be an object when provided");
49663
+ } else if (typeof input.multipart !== "boolean") {
49207
49664
  errors.push("capabilities.input.multipart must be boolean");
49208
49665
  }
49209
- if (!Array.isArray(input.mediaTypes) || input.mediaTypes.length === 0) {
49210
- errors.push("capabilities.input.mediaTypes must be a non-empty array");
49211
- } else if (input.mediaTypes.some((type) => typeof type !== "string" || !VALID_CAPABILITY_MEDIA_TYPES.has(type))) {
49212
- errors.push(`capabilities.input.mediaTypes must only include: ${Array.from(VALID_CAPABILITY_MEDIA_TYPES).join(", ")}`);
49666
+ if (input && typeof input === "object") {
49667
+ const mediaTypes = Array.isArray(input.mediaTypes) ? input.mediaTypes : void 0;
49668
+ if (!mediaTypes || mediaTypes.length === 0) {
49669
+ errors.push("capabilities.input.mediaTypes must be a non-empty array");
49670
+ } else if (mediaTypes.some((type) => typeof type !== "string" || !VALID_CAPABILITY_MEDIA_TYPES.has(type))) {
49671
+ errors.push(`capabilities.input.mediaTypes must only include: ${Array.from(VALID_CAPABILITY_MEDIA_TYPES).join(", ")}`);
49672
+ }
49673
+ }
49674
+ if (input && typeof input === "object" && input.strategies !== void 0) {
49675
+ if (!Array.isArray(input.strategies)) {
49676
+ errors.push("capabilities.input.strategies must be an array when provided");
49677
+ } else {
49678
+ for (const strategy of input.strategies) {
49679
+ if (!strategy || typeof strategy !== "object" || Array.isArray(strategy)) {
49680
+ errors.push("capabilities.input.strategies entries must be objects");
49681
+ continue;
49682
+ }
49683
+ const entry = strategy;
49684
+ if (typeof entry.mediaType !== "string" || !VALID_CAPABILITY_MEDIA_TYPES.has(entry.mediaType)) {
49685
+ errors.push(`capabilities.input.strategies.mediaType must only include: ${Array.from(VALID_CAPABILITY_MEDIA_TYPES).join(", ")}`);
49686
+ }
49687
+ for (const field of ["strategies", "degradation"]) {
49688
+ const values = entry[field];
49689
+ if (values === void 0) continue;
49690
+ if (!Array.isArray(values) || values.some((value) => typeof value !== "string" || !VALID_INPUT_STRATEGIES2.has(value))) {
49691
+ errors.push(`capabilities.input.strategies.${field} must only include: ${Array.from(VALID_INPUT_STRATEGIES2).join(", ")}`);
49692
+ }
49693
+ }
49694
+ if (entry.native !== void 0 && typeof entry.native !== "boolean") {
49695
+ errors.push("capabilities.input.strategies.native must be boolean when provided");
49696
+ }
49697
+ }
49698
+ }
49213
49699
  }
49214
49700
  }
49215
49701
  const output = capabilities.output;
@@ -49386,7 +49872,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
49386
49872
  try {
49387
49873
  if (!fs7.existsSync(candidate) || !fs7.statSync(candidate).isDirectory()) return false;
49388
49874
  return ["ide", "extension", "cli", "acp"].some(
49389
- (category) => fs7.existsSync(path18.join(candidate, category))
49875
+ (category) => fs7.existsSync(path19.join(candidate, category))
49390
49876
  );
49391
49877
  } catch {
49392
49878
  return false;
@@ -49394,20 +49880,20 @@ Run 'adhdev doctor' for detailed diagnostics.`
49394
49880
  }
49395
49881
  static hasProviderRootMarker(candidate) {
49396
49882
  try {
49397
- return fs7.existsSync(path18.join(candidate, _ProviderLoader.SIBLING_MARKER_FILE));
49883
+ return fs7.existsSync(path19.join(candidate, _ProviderLoader.SIBLING_MARKER_FILE));
49398
49884
  } catch {
49399
49885
  return false;
49400
49886
  }
49401
49887
  }
49402
49888
  detectDefaultUserDir() {
49403
- const fallback = path18.join(os14.homedir(), ".adhdev", "providers");
49889
+ const fallback = path19.join(os14.homedir(), ".adhdev", "providers");
49404
49890
  const envOptIn = process.env[_ProviderLoader.SIBLING_ENV_VAR] === "1";
49405
49891
  const visited = /* @__PURE__ */ new Set();
49406
49892
  for (const start of this.probeStarts) {
49407
- let current = path18.resolve(start);
49893
+ let current = path19.resolve(start);
49408
49894
  while (!visited.has(current)) {
49409
49895
  visited.add(current);
49410
- const siblingCandidate = path18.join(path18.dirname(current), _ProviderLoader.REPO_PROVIDER_DIRNAME);
49896
+ const siblingCandidate = path19.join(path19.dirname(current), _ProviderLoader.REPO_PROVIDER_DIRNAME);
49411
49897
  if (_ProviderLoader.looksLikeProviderRoot(siblingCandidate)) {
49412
49898
  const hasMarker = _ProviderLoader.hasProviderRootMarker(siblingCandidate);
49413
49899
  if (envOptIn || hasMarker) {
@@ -49429,7 +49915,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
49429
49915
  return { path: siblingCandidate, source };
49430
49916
  }
49431
49917
  }
49432
- const parent = path18.dirname(current);
49918
+ const parent = path19.dirname(current);
49433
49919
  if (parent === current) break;
49434
49920
  current = parent;
49435
49921
  }
@@ -49439,11 +49925,11 @@ Run 'adhdev doctor' for detailed diagnostics.`
49439
49925
  constructor(options) {
49440
49926
  this.logFn = options?.logFn || LOG2.forComponent("Provider").asLogFn();
49441
49927
  this.probeStarts = options?.probeStarts ?? [process.cwd(), __dirname];
49442
- this.defaultProvidersDir = path18.join(os14.homedir(), ".adhdev", "providers");
49928
+ this.defaultProvidersDir = path19.join(os14.homedir(), ".adhdev", "providers");
49443
49929
  const detected = this.detectDefaultUserDir();
49444
49930
  this.userDir = detected.path;
49445
49931
  this.userDirSource = detected.source;
49446
- this.upstreamDir = path18.join(this.defaultProvidersDir, ".upstream");
49932
+ this.upstreamDir = path19.join(this.defaultProvidersDir, ".upstream");
49447
49933
  this.disableUpstream = false;
49448
49934
  this.applySourceConfig({
49449
49935
  userDir: options?.userDir,
@@ -49502,7 +49988,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
49502
49988
  this.userDir = detected.path;
49503
49989
  this.userDirSource = detected.source;
49504
49990
  }
49505
- this.upstreamDir = path18.join(this.defaultProvidersDir, ".upstream");
49991
+ this.upstreamDir = path19.join(this.defaultProvidersDir, ".upstream");
49506
49992
  this.disableUpstream = this.sourceMode === "no-upstream";
49507
49993
  if (this.explicitProviderDir) {
49508
49994
  this.log(`Config 'providerDir' applied: ${this.userDir}`);
@@ -49516,7 +50002,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
49516
50002
  * Canonical provider directory shape for a given root.
49517
50003
  */
49518
50004
  getProviderDir(root, category, type) {
49519
- return path18.join(root, category, type);
50005
+ return path19.join(root, category, type);
49520
50006
  }
49521
50007
  /**
49522
50008
  * Canonical user override directory for a provider.
@@ -49543,7 +50029,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
49543
50029
  resolveProviderFile(type, ...segments) {
49544
50030
  const dir = this.findProviderDirInternal(type);
49545
50031
  if (!dir) return null;
49546
- return path18.join(dir, ...segments);
50032
+ return path19.join(dir, ...segments);
49547
50033
  }
49548
50034
  /**
49549
50035
  * Load all providers (3-tier priority)
@@ -49582,7 +50068,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
49582
50068
  if (!fs7.existsSync(this.upstreamDir)) return false;
49583
50069
  try {
49584
50070
  return fs7.readdirSync(this.upstreamDir).some(
49585
- (d) => fs7.statSync(path18.join(this.upstreamDir, d)).isDirectory()
50071
+ (d) => fs7.statSync(path19.join(this.upstreamDir, d)).isDirectory()
49586
50072
  );
49587
50073
  } catch {
49588
50074
  return false;
@@ -50079,8 +50565,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
50079
50565
  resolved._resolvedScriptDir = entry.scriptDir;
50080
50566
  resolved._resolvedScriptsSource = `compatibility:${entry.ideVersion}`;
50081
50567
  if (providerDir) {
50082
- const fullDir = path18.join(providerDir, entry.scriptDir);
50083
- resolved._resolvedScriptsPath = fs7.existsSync(path18.join(fullDir, "scripts.js")) ? path18.join(fullDir, "scripts.js") : fullDir;
50568
+ const fullDir = path19.join(providerDir, entry.scriptDir);
50569
+ resolved._resolvedScriptsPath = fs7.existsSync(path19.join(fullDir, "scripts.js")) ? path19.join(fullDir, "scripts.js") : fullDir;
50084
50570
  }
50085
50571
  matched = true;
50086
50572
  }
@@ -50095,8 +50581,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
50095
50581
  resolved._resolvedScriptDir = base.defaultScriptDir;
50096
50582
  resolved._resolvedScriptsSource = "defaultScriptDir:version_miss";
50097
50583
  if (providerDir) {
50098
- const fullDir = path18.join(providerDir, base.defaultScriptDir);
50099
- resolved._resolvedScriptsPath = fs7.existsSync(path18.join(fullDir, "scripts.js")) ? path18.join(fullDir, "scripts.js") : fullDir;
50584
+ const fullDir = path19.join(providerDir, base.defaultScriptDir);
50585
+ resolved._resolvedScriptsPath = fs7.existsSync(path19.join(fullDir, "scripts.js")) ? path19.join(fullDir, "scripts.js") : fullDir;
50100
50586
  }
50101
50587
  }
50102
50588
  resolved._versionWarning = `Version ${currentVersion} not in compatibility matrix. Using default scripts.`;
@@ -50113,8 +50599,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
50113
50599
  resolved._resolvedScriptDir = dirOverride;
50114
50600
  resolved._resolvedScriptsSource = `versions:${range}`;
50115
50601
  if (providerDir) {
50116
- const fullDir = path18.join(providerDir, dirOverride);
50117
- resolved._resolvedScriptsPath = fs7.existsSync(path18.join(fullDir, "scripts.js")) ? path18.join(fullDir, "scripts.js") : fullDir;
50602
+ const fullDir = path19.join(providerDir, dirOverride);
50603
+ resolved._resolvedScriptsPath = fs7.existsSync(path19.join(fullDir, "scripts.js")) ? path19.join(fullDir, "scripts.js") : fullDir;
50118
50604
  }
50119
50605
  }
50120
50606
  } else if (override.scripts) {
@@ -50130,8 +50616,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
50130
50616
  resolved._resolvedScriptDir = base.defaultScriptDir;
50131
50617
  resolved._resolvedScriptsSource = "defaultScriptDir:no_version";
50132
50618
  if (providerDir) {
50133
- const fullDir = path18.join(providerDir, base.defaultScriptDir);
50134
- resolved._resolvedScriptsPath = fs7.existsSync(path18.join(fullDir, "scripts.js")) ? path18.join(fullDir, "scripts.js") : fullDir;
50619
+ const fullDir = path19.join(providerDir, base.defaultScriptDir);
50620
+ resolved._resolvedScriptsPath = fs7.existsSync(path19.join(fullDir, "scripts.js")) ? path19.join(fullDir, "scripts.js") : fullDir;
50135
50621
  }
50136
50622
  }
50137
50623
  }
@@ -50163,14 +50649,14 @@ Run 'adhdev doctor' for detailed diagnostics.`
50163
50649
  this.log(` [loadScriptsFromDir] ${type}: providerDir not found`);
50164
50650
  return null;
50165
50651
  }
50166
- const dir = path18.join(providerDir, scriptDir);
50652
+ const dir = path19.join(providerDir, scriptDir);
50167
50653
  if (!fs7.existsSync(dir)) {
50168
50654
  this.log(` [loadScriptsFromDir] ${type}: dir not found: ${dir}`);
50169
50655
  return null;
50170
50656
  }
50171
50657
  const cached2 = this.scriptsCache.get(dir);
50172
50658
  if (cached2) return cached2;
50173
- const scriptsJs = path18.join(dir, "scripts.js");
50659
+ const scriptsJs = path19.join(dir, "scripts.js");
50174
50660
  if (fs7.existsSync(scriptsJs)) {
50175
50661
  try {
50176
50662
  delete require.cache[require.resolve(scriptsJs)];
@@ -50212,7 +50698,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
50212
50698
  return;
50213
50699
  }
50214
50700
  if (filePath.endsWith(".js") || filePath.endsWith(".json")) {
50215
- this.log(`File changed: ${path18.basename(filePath)}, reloading...`);
50701
+ this.log(`File changed: ${path19.basename(filePath)}, reloading...`);
50216
50702
  this.reload();
50217
50703
  }
50218
50704
  };
@@ -50267,7 +50753,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
50267
50753
  }
50268
50754
  const https = require("https");
50269
50755
  const { execSync: execSync7 } = require("child_process");
50270
- const metaPath = path18.join(this.upstreamDir, _ProviderLoader.META_FILE);
50756
+ const metaPath = path19.join(this.upstreamDir, _ProviderLoader.META_FILE);
50271
50757
  let prevEtag = "";
50272
50758
  let prevTimestamp = 0;
50273
50759
  try {
@@ -50327,17 +50813,17 @@ Run 'adhdev doctor' for detailed diagnostics.`
50327
50813
  return { updated: false };
50328
50814
  }
50329
50815
  this.log("Downloading latest providers from GitHub...");
50330
- const tmpTar = path18.join(os14.tmpdir(), `adhdev-providers-${Date.now()}.tar.gz`);
50331
- const tmpExtract = path18.join(os14.tmpdir(), `adhdev-providers-extract-${Date.now()}`);
50816
+ const tmpTar = path19.join(os14.tmpdir(), `adhdev-providers-${Date.now()}.tar.gz`);
50817
+ const tmpExtract = path19.join(os14.tmpdir(), `adhdev-providers-extract-${Date.now()}`);
50332
50818
  await this.downloadFile(_ProviderLoader.GITHUB_TARBALL_URL, tmpTar);
50333
50819
  fs7.mkdirSync(tmpExtract, { recursive: true });
50334
50820
  execSync7(`tar -xzf "${tmpTar}" -C "${tmpExtract}"`, { timeout: 3e4 });
50335
50821
  const extracted = fs7.readdirSync(tmpExtract);
50336
50822
  const rootDir = extracted.find(
50337
- (d) => fs7.statSync(path18.join(tmpExtract, d)).isDirectory() && d.startsWith("adhdev-providers")
50823
+ (d) => fs7.statSync(path19.join(tmpExtract, d)).isDirectory() && d.startsWith("adhdev-providers")
50338
50824
  );
50339
50825
  if (!rootDir) throw new Error("Unexpected tarball structure");
50340
- const sourceDir = path18.join(tmpExtract, rootDir);
50826
+ const sourceDir = path19.join(tmpExtract, rootDir);
50341
50827
  const backupDir = this.upstreamDir + ".bak";
50342
50828
  if (fs7.existsSync(this.upstreamDir)) {
50343
50829
  if (fs7.existsSync(backupDir)) fs7.rmSync(backupDir, { recursive: true, force: true });
@@ -50412,8 +50898,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
50412
50898
  copyDirRecursive(src, dest) {
50413
50899
  fs7.mkdirSync(dest, { recursive: true });
50414
50900
  for (const entry of fs7.readdirSync(src, { withFileTypes: true })) {
50415
- const srcPath = path18.join(src, entry.name);
50416
- const destPath = path18.join(dest, entry.name);
50901
+ const srcPath = path19.join(src, entry.name);
50902
+ const destPath = path19.join(dest, entry.name);
50417
50903
  if (entry.isDirectory()) {
50418
50904
  this.copyDirRecursive(srcPath, destPath);
50419
50905
  } else {
@@ -50424,7 +50910,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
50424
50910
  /** .meta.json save */
50425
50911
  writeMeta(metaPath, etag, timestamp) {
50426
50912
  try {
50427
- fs7.mkdirSync(path18.dirname(metaPath), { recursive: true });
50913
+ fs7.mkdirSync(path19.dirname(metaPath), { recursive: true });
50428
50914
  fs7.writeFileSync(metaPath, JSON.stringify({
50429
50915
  etag,
50430
50916
  timestamp,
@@ -50441,7 +50927,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
50441
50927
  const scan = (d) => {
50442
50928
  try {
50443
50929
  for (const entry of fs7.readdirSync(d, { withFileTypes: true })) {
50444
- if (entry.isDirectory()) scan(path18.join(d, entry.name));
50930
+ if (entry.isDirectory()) scan(path19.join(d, entry.name));
50445
50931
  else if (entry.name === "provider.json") count++;
50446
50932
  }
50447
50933
  } catch {
@@ -50669,17 +51155,17 @@ Run 'adhdev doctor' for detailed diagnostics.`
50669
51155
  for (const root of searchRoots) {
50670
51156
  if (!fs7.existsSync(root)) continue;
50671
51157
  const candidate = this.getProviderDir(root, cat, type);
50672
- if (fs7.existsSync(path18.join(candidate, "provider.json"))) return candidate;
50673
- const catDir = path18.join(root, cat);
51158
+ if (fs7.existsSync(path19.join(candidate, "provider.json"))) return candidate;
51159
+ const catDir = path19.join(root, cat);
50674
51160
  if (fs7.existsSync(catDir)) {
50675
51161
  try {
50676
51162
  for (const entry of fs7.readdirSync(catDir, { withFileTypes: true })) {
50677
51163
  if (!entry.isDirectory()) continue;
50678
- const jsonPath = path18.join(catDir, entry.name, "provider.json");
51164
+ const jsonPath = path19.join(catDir, entry.name, "provider.json");
50679
51165
  if (fs7.existsSync(jsonPath)) {
50680
51166
  try {
50681
51167
  const data = JSON.parse(fs7.readFileSync(jsonPath, "utf-8"));
50682
- if (data.type === type) return path18.join(catDir, entry.name);
51168
+ if (data.type === type) return path19.join(catDir, entry.name);
50683
51169
  } catch {
50684
51170
  }
50685
51171
  }
@@ -50696,7 +51182,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
50696
51182
  * (template substitution is NOT applied here — scripts.js handles that)
50697
51183
  */
50698
51184
  buildScriptWrappersFromDir(dir) {
50699
- const scriptsJs = path18.join(dir, "scripts.js");
51185
+ const scriptsJs = path19.join(dir, "scripts.js");
50700
51186
  if (fs7.existsSync(scriptsJs)) {
50701
51187
  try {
50702
51188
  delete require.cache[require.resolve(scriptsJs)];
@@ -50710,7 +51196,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
50710
51196
  for (const file2 of fs7.readdirSync(dir)) {
50711
51197
  if (!file2.endsWith(".js")) continue;
50712
51198
  const scriptName = toCamel(file2.replace(".js", ""));
50713
- const filePath = path18.join(dir, file2);
51199
+ const filePath = path19.join(dir, file2);
50714
51200
  result[scriptName] = (...args) => {
50715
51201
  try {
50716
51202
  let content = fs7.readFileSync(filePath, "utf-8");
@@ -50770,7 +51256,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
50770
51256
  }
50771
51257
  const hasJson = entries.some((e) => e.name === "provider.json");
50772
51258
  if (hasJson) {
50773
- const jsonPath = path18.join(d, "provider.json");
51259
+ const jsonPath = path19.join(d, "provider.json");
50774
51260
  try {
50775
51261
  const raw = fs7.readFileSync(jsonPath, "utf-8");
50776
51262
  const mod = JSON.parse(raw);
@@ -50791,7 +51277,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
50791
51277
  this.log(`\u26A0 Invalid provider at ${jsonPath}: ${validation.errors.join("; ")}`);
50792
51278
  } else {
50793
51279
  const hasCompatibility = Array.isArray(normalizedProvider.compatibility);
50794
- const scriptsPath = path18.join(d, "scripts.js");
51280
+ const scriptsPath = path19.join(d, "scripts.js");
50795
51281
  if (!hasCompatibility && fs7.existsSync(scriptsPath)) {
50796
51282
  try {
50797
51283
  delete require.cache[require.resolve(scriptsPath)];
@@ -50817,7 +51303,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
50817
51303
  if (!entry.isDirectory()) continue;
50818
51304
  if (entry.name.startsWith("_") || entry.name.startsWith(".")) continue;
50819
51305
  if (excludeDirs && d === dir && excludeDirs.includes(entry.name)) continue;
50820
- scan(path18.join(d, entry.name));
51306
+ scan(path19.join(d, entry.name));
50821
51307
  }
50822
51308
  }
50823
51309
  };
@@ -51138,8 +51624,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
51138
51624
  const appNameMap = getMacAppIdentifiers();
51139
51625
  const appName = appNameMap[ideId];
51140
51626
  if (appName) {
51141
- const storagePath = path19.join(
51142
- process.env.APPDATA || path19.join(os15.homedir(), "AppData", "Roaming"),
51627
+ const storagePath = path20.join(
51628
+ process.env.APPDATA || path20.join(os15.homedir(), "AppData", "Roaming"),
51143
51629
  appName,
51144
51630
  "storage.json"
51145
51631
  );
@@ -51324,9 +51810,9 @@ Run 'adhdev doctor' for detailed diagnostics.`
51324
51810
  init_config();
51325
51811
  init_logger();
51326
51812
  var fs8 = __toESM2(require("fs"));
51327
- var path20 = __toESM2(require("path"));
51813
+ var path21 = __toESM2(require("path"));
51328
51814
  var os16 = __toESM2(require("os"));
51329
- var LOG_DIR2 = process.platform === "win32" ? path20.join(process.env.LOCALAPPDATA || process.env.APPDATA || path20.join(os16.homedir(), "AppData", "Local"), "adhdev", "logs") : process.platform === "darwin" ? path20.join(os16.homedir(), "Library", "Logs", "adhdev") : path20.join(os16.homedir(), ".local", "share", "adhdev", "logs");
51815
+ var LOG_DIR2 = process.platform === "win32" ? path21.join(process.env.LOCALAPPDATA || process.env.APPDATA || path21.join(os16.homedir(), "AppData", "Local"), "adhdev", "logs") : process.platform === "darwin" ? path21.join(os16.homedir(), "Library", "Logs", "adhdev") : path21.join(os16.homedir(), ".local", "share", "adhdev", "logs");
51330
51816
  var MAX_FILE_SIZE = 5 * 1024 * 1024;
51331
51817
  var MAX_DAYS = 7;
51332
51818
  try {
@@ -51364,13 +51850,13 @@ Run 'adhdev doctor' for detailed diagnostics.`
51364
51850
  return (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
51365
51851
  }
51366
51852
  var currentDate2 = getDateStr2();
51367
- var currentFile = path20.join(LOG_DIR2, `commands-${currentDate2}.jsonl`);
51853
+ var currentFile = path21.join(LOG_DIR2, `commands-${currentDate2}.jsonl`);
51368
51854
  var writeCount2 = 0;
51369
51855
  function checkRotation() {
51370
51856
  const today = getDateStr2();
51371
51857
  if (today !== currentDate2) {
51372
51858
  currentDate2 = today;
51373
- currentFile = path20.join(LOG_DIR2, `commands-${currentDate2}.jsonl`);
51859
+ currentFile = path21.join(LOG_DIR2, `commands-${currentDate2}.jsonl`);
51374
51860
  cleanOldFiles();
51375
51861
  }
51376
51862
  }
@@ -51384,7 +51870,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
51384
51870
  const dateMatch = file2.match(/commands-(\d{4}-\d{2}-\d{2})/);
51385
51871
  if (dateMatch && dateMatch[1] < cutoffStr) {
51386
51872
  try {
51387
- fs8.unlinkSync(path20.join(LOG_DIR2, file2));
51873
+ fs8.unlinkSync(path21.join(LOG_DIR2, file2));
51388
51874
  } catch {
51389
51875
  }
51390
51876
  }
@@ -51468,6 +51954,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
51468
51954
  var yaml = __toESM2(require_js_yaml());
51469
51955
  init_logger();
51470
51956
  var import_node_child_process3 = require("child_process");
51957
+ var import_node_crypto2 = require("crypto");
51471
51958
  var import_node_fs3 = require("fs");
51472
51959
  var import_node_module2 = require("module");
51473
51960
  var os17 = __toESM2(require("os"));
@@ -51492,7 +51979,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
51492
51979
  reason: "Could not resolve the ADHDev MCP server entrypoint and a Node runtime with WebSocket support for daemon IPC mode"
51493
51980
  };
51494
51981
  }
51495
- const configPath = resolveMcpConfigPath(HERMES_MCP_CONFIG_PATH, options.workspace);
51982
+ const configPath = (0, import_node_path.join)(resolveHermesCoordinatorHome(options.meshId, options.workspace), "config.yaml");
51496
51983
  if (!configPath.trim()) {
51497
51984
  return createHermesManualMeshCoordinatorSetup(options.meshId, options.workspace);
51498
51985
  }
@@ -51544,8 +52031,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
51544
52031
  }
51545
52032
  const serverName = mcpConfig.serverName?.trim() || DEFAULT_SERVER_NAME;
51546
52033
  if (mcpConfig.mode === "auto_import") {
51547
- const path27 = mcpConfig.path?.trim();
51548
- if (!path27) {
52034
+ const path28 = mcpConfig.path?.trim();
52035
+ if (!path28) {
51549
52036
  return { kind: "unsupported", reason: "Provider auto-import MCP config is missing a config path" };
51550
52037
  }
51551
52038
  const mcpServer = resolveAdhdevMcpServerLaunch({
@@ -51562,7 +52049,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
51562
52049
  return {
51563
52050
  kind: "auto_import",
51564
52051
  serverName,
51565
- configPath: resolveMcpConfigPath(path27, workspace),
52052
+ configPath: resolveMcpConfigPath(path28, workspace),
51566
52053
  configFormat: mcpConfig.format,
51567
52054
  mcpServer
51568
52055
  };
@@ -51596,6 +52083,12 @@ Run 'adhdev doctor' for detailed diagnostics.`
51596
52083
  function renderMeshCoordinatorTemplate(template, values) {
51597
52084
  return template.replace(/\{\{\s*(meshId|workspace|serverName|adhdevMcpCommand)\s*\}\}/g, (_, key) => values[key] || "");
51598
52085
  }
52086
+ function resolveHermesCoordinatorHome(meshId, workspace) {
52087
+ const key = `${meshId || "mesh"}
52088
+ ${(0, import_node_path.resolve)(workspace || os17.tmpdir())}`;
52089
+ const hash2 = (0, import_node_crypto2.createHash)("sha256").update(key).digest("hex").slice(0, 16);
52090
+ return (0, import_node_path.join)(os17.tmpdir(), `adhdev-hermes-mesh-coordinator-${hash2}`);
52091
+ }
51599
52092
  function resolveMcpConfigPath(configPath, workspace) {
51600
52093
  const trimmed = configPath.trim();
51601
52094
  if (trimmed === "~") return os17.homedir();
@@ -52123,13 +52616,13 @@ Run 'adhdev doctor' for detailed diagnostics.`
52123
52616
  var import_child_process9 = require("child_process");
52124
52617
  var fs9 = __toESM2(require("fs"));
52125
52618
  var os19 = __toESM2(require("os"));
52126
- var path21 = __toESM2(require("path"));
52619
+ var path222 = __toESM2(require("path"));
52127
52620
  var UPGRADE_HELPER_ENV = "ADHDEV_DAEMON_UPGRADE_HELPER";
52128
52621
  function getUpgradeLogPath() {
52129
52622
  const home = os19.homedir();
52130
- const dir = path21.join(home, ".adhdev");
52623
+ const dir = path222.join(home, ".adhdev");
52131
52624
  fs9.mkdirSync(dir, { recursive: true });
52132
- return path21.join(dir, "daemon-upgrade.log");
52625
+ return path222.join(dir, "daemon-upgrade.log");
52133
52626
  }
52134
52627
  function appendUpgradeLog(message) {
52135
52628
  const line = `[${(/* @__PURE__ */ new Date()).toISOString()}] ${message}
@@ -52140,14 +52633,14 @@ Run 'adhdev doctor' for detailed diagnostics.`
52140
52633
  }
52141
52634
  }
52142
52635
  function resolveSiblingNpmInvocation(nodeExecutable, platform10 = process.platform) {
52143
- const binDir = path21.dirname(nodeExecutable);
52636
+ const binDir = path222.dirname(nodeExecutable);
52144
52637
  if (platform10 === "win32") {
52145
- const npmCliPath = path21.join(binDir, "node_modules", "npm", "bin", "npm-cli.js");
52638
+ const npmCliPath = path222.join(binDir, "node_modules", "npm", "bin", "npm-cli.js");
52146
52639
  if (fs9.existsSync(npmCliPath)) {
52147
52640
  return { executable: nodeExecutable, argsPrefix: [npmCliPath], execOptions: getNpmExecOptions(platform10) };
52148
52641
  }
52149
52642
  for (const candidate of ["npm.exe", "npm"]) {
52150
- const candidatePath = path21.join(binDir, candidate);
52643
+ const candidatePath = path222.join(binDir, candidate);
52151
52644
  if (fs9.existsSync(candidatePath)) {
52152
52645
  return { executable: candidatePath, argsPrefix: [], execOptions: getNpmExecOptions(platform10) };
52153
52646
  }
@@ -52155,7 +52648,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
52155
52648
  return { executable: nodeExecutable, argsPrefix: [npmCliPath], execOptions: getNpmExecOptions(platform10) };
52156
52649
  }
52157
52650
  for (const candidate of ["npm"]) {
52158
- const candidatePath = path21.join(binDir, candidate);
52651
+ const candidatePath = path222.join(binDir, candidate);
52159
52652
  if (fs9.existsSync(candidatePath)) {
52160
52653
  return { executable: candidatePath, argsPrefix: [], execOptions: getNpmExecOptions(platform10) };
52161
52654
  }
@@ -52172,13 +52665,13 @@ Run 'adhdev doctor' for detailed diagnostics.`
52172
52665
  let currentDir = resolvedPath;
52173
52666
  try {
52174
52667
  if (fs9.statSync(resolvedPath).isFile()) {
52175
- currentDir = path21.dirname(resolvedPath);
52668
+ currentDir = path222.dirname(resolvedPath);
52176
52669
  }
52177
52670
  } catch {
52178
- currentDir = path21.dirname(resolvedPath);
52671
+ currentDir = path222.dirname(resolvedPath);
52179
52672
  }
52180
52673
  while (true) {
52181
- const packageJsonPath = path21.join(currentDir, "package.json");
52674
+ const packageJsonPath = path222.join(currentDir, "package.json");
52182
52675
  try {
52183
52676
  if (fs9.existsSync(packageJsonPath)) {
52184
52677
  const parsed = JSON.parse(fs9.readFileSync(packageJsonPath, "utf8"));
@@ -52189,7 +52682,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
52189
52682
  }
52190
52683
  } catch {
52191
52684
  }
52192
- const parentDir = path21.dirname(currentDir);
52685
+ const parentDir = path222.dirname(currentDir);
52193
52686
  if (parentDir === currentDir) {
52194
52687
  return null;
52195
52688
  }
@@ -52197,13 +52690,13 @@ Run 'adhdev doctor' for detailed diagnostics.`
52197
52690
  }
52198
52691
  }
52199
52692
  function resolveInstallPrefixFromPackageRoot(packageRoot, packageName) {
52200
- const nodeModulesDir = packageName.startsWith("@") ? path21.dirname(path21.dirname(packageRoot)) : path21.dirname(packageRoot);
52201
- if (path21.basename(nodeModulesDir) !== "node_modules") {
52693
+ const nodeModulesDir = packageName.startsWith("@") ? path222.dirname(path222.dirname(packageRoot)) : path222.dirname(packageRoot);
52694
+ if (path222.basename(nodeModulesDir) !== "node_modules") {
52202
52695
  return null;
52203
52696
  }
52204
- const maybeLibDir = path21.dirname(nodeModulesDir);
52205
- if (path21.basename(maybeLibDir) === "lib") {
52206
- return path21.dirname(maybeLibDir);
52697
+ const maybeLibDir = path222.dirname(nodeModulesDir);
52698
+ if (path222.basename(maybeLibDir) === "lib") {
52699
+ return path222.dirname(maybeLibDir);
52207
52700
  }
52208
52701
  return maybeLibDir;
52209
52702
  }
@@ -52318,7 +52811,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
52318
52811
  }
52319
52812
  }
52320
52813
  function stopSessionHostProcesses(appName) {
52321
- const pidFile = path21.join(os19.homedir(), ".adhdev", `${appName}-session-host.pid`);
52814
+ const pidFile = path222.join(os19.homedir(), ".adhdev", `${appName}-session-host.pid`);
52322
52815
  try {
52323
52816
  if (fs9.existsSync(pidFile)) {
52324
52817
  const pid = Number.parseInt(fs9.readFileSync(pidFile, "utf8").trim(), 10);
@@ -52335,7 +52828,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
52335
52828
  }
52336
52829
  }
52337
52830
  function removeDaemonPidFile() {
52338
- const pidFile = path21.join(os19.homedir(), ".adhdev", "daemon.pid");
52831
+ const pidFile = path222.join(os19.homedir(), ".adhdev", "daemon.pid");
52339
52832
  try {
52340
52833
  fs9.unlinkSync(pidFile);
52341
52834
  } catch {
@@ -52346,7 +52839,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
52346
52839
  const npmRoot = String(execNpmCommandSync(["root", "-g", ...prefixArgs], { encoding: "utf8" }, surface)).trim();
52347
52840
  if (!npmRoot) return;
52348
52841
  const npmPrefix = surface.installPrefix || String(execNpmCommandSync(["prefix", "-g", ...prefixArgs], { encoding: "utf8" }, surface)).trim();
52349
- const binDir = process.platform === "win32" ? npmPrefix : path21.join(npmPrefix, "bin");
52842
+ const binDir = process.platform === "win32" ? npmPrefix : path222.join(npmPrefix, "bin");
52350
52843
  const packageBaseName = pkgName.startsWith("@") ? pkgName.split("/")[1] : pkgName;
52351
52844
  const binNames = /* @__PURE__ */ new Set([packageBaseName]);
52352
52845
  if (pkgName === "@adhdev/daemon-standalone") {
@@ -52354,25 +52847,25 @@ Run 'adhdev doctor' for detailed diagnostics.`
52354
52847
  }
52355
52848
  if (pkgName.startsWith("@")) {
52356
52849
  const [scope, name] = pkgName.split("/");
52357
- const scopeDir = path21.join(npmRoot, scope);
52850
+ const scopeDir = path222.join(npmRoot, scope);
52358
52851
  if (!fs9.existsSync(scopeDir)) return;
52359
52852
  for (const entry of fs9.readdirSync(scopeDir)) {
52360
52853
  if (!entry.startsWith(`.${name}-`)) continue;
52361
- fs9.rmSync(path21.join(scopeDir, entry), { recursive: true, force: true });
52362
- appendUpgradeLog(`Removed stale scoped staging dir: ${path21.join(scopeDir, entry)}`);
52854
+ fs9.rmSync(path222.join(scopeDir, entry), { recursive: true, force: true });
52855
+ appendUpgradeLog(`Removed stale scoped staging dir: ${path222.join(scopeDir, entry)}`);
52363
52856
  }
52364
52857
  } else {
52365
52858
  for (const entry of fs9.readdirSync(npmRoot)) {
52366
52859
  if (!entry.startsWith(`.${pkgName}-`)) continue;
52367
- fs9.rmSync(path21.join(npmRoot, entry), { recursive: true, force: true });
52368
- appendUpgradeLog(`Removed stale staging dir: ${path21.join(npmRoot, entry)}`);
52860
+ fs9.rmSync(path222.join(npmRoot, entry), { recursive: true, force: true });
52861
+ appendUpgradeLog(`Removed stale staging dir: ${path222.join(npmRoot, entry)}`);
52369
52862
  }
52370
52863
  }
52371
52864
  if (fs9.existsSync(binDir)) {
52372
52865
  for (const entry of fs9.readdirSync(binDir)) {
52373
52866
  if (!Array.from(binNames).some((name) => entry.startsWith(`.${name}-`))) continue;
52374
- fs9.rmSync(path21.join(binDir, entry), { recursive: true, force: true });
52375
- appendUpgradeLog(`Removed stale bin staging entry: ${path21.join(binDir, entry)}`);
52867
+ fs9.rmSync(path222.join(binDir, entry), { recursive: true, force: true });
52868
+ appendUpgradeLog(`Removed stale bin staging entry: ${path222.join(binDir, entry)}`);
52376
52869
  }
52377
52870
  }
52378
52871
  }
@@ -53742,7 +54235,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
53742
54235
  workspace
53743
54236
  };
53744
54237
  }
53745
- const { existsSync: existsSync23, readFileSync: readFileSync15, writeFileSync: writeFileSync13, copyFileSync: copyFileSync3, mkdirSync: mkdirSync15 } = await import("fs");
54238
+ const { existsSync: existsSync23, readFileSync: readFileSync15, writeFileSync: writeFileSync14, copyFileSync: copyFileSync3, mkdirSync: mkdirSync16 } = await import("fs");
53746
54239
  const { dirname: dirname9 } = await import("path");
53747
54240
  const mcpConfigPath = coordinatorSetup.configPath;
53748
54241
  const hermesManualFallback = cliType === "hermes-cli" && configFormat === "hermes_config_yaml" ? createHermesManualMeshCoordinatorSetup(meshId, workspace) : null;
@@ -53766,7 +54259,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
53766
54259
  };
53767
54260
  }
53768
54261
  try {
53769
- mkdirSync15(dirname9(mcpConfigPath), { recursive: true });
54262
+ mkdirSync16(dirname9(mcpConfigPath), { recursive: true });
53770
54263
  } catch (error48) {
53771
54264
  const message = `Could not prepare MCP config path for automatic setup: ${error48?.message || error48}`;
53772
54265
  LOG2.error("MeshCoordinator", message);
@@ -53798,7 +54291,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
53798
54291
  }
53799
54292
  };
53800
54293
  try {
53801
- writeFileSync13(mcpConfigPath, serializeMeshCoordinatorMcpConfig(mcpConfig, configFormat), "utf-8");
54294
+ writeFileSync14(mcpConfigPath, serializeMeshCoordinatorMcpConfig(mcpConfig, configFormat), "utf-8");
53802
54295
  } catch (error48) {
53803
54296
  const message = `Could not write MCP config for automatic setup: ${error48?.message || error48}`;
53804
54297
  LOG2.error("MeshCoordinator", message);
@@ -53808,6 +54301,10 @@ Run 'adhdev doctor' for detailed diagnostics.`
53808
54301
  LOG2.info("MeshCoordinator", `Wrote ${mcpConfigPath} with ${coordinatorSetup.serverName} server`);
53809
54302
  const cliArgs = [];
53810
54303
  const launchEnv = {};
54304
+ if (configFormat === "hermes_config_yaml") {
54305
+ launchEnv.HERMES_HOME = dirname9(mcpConfigPath);
54306
+ launchEnv.HERMES_IGNORE_USER_CONFIG = "";
54307
+ }
53811
54308
  if (systemPrompt) {
53812
54309
  if (configFormat === "hermes_config_yaml") {
53813
54310
  launchEnv.HERMES_EPHEMERAL_SYSTEM_PROMPT = systemPrompt;
@@ -54221,7 +54718,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
54221
54718
  update: null
54222
54719
  };
54223
54720
  }
54224
- const messages = Array.isArray(result.messages) ? result.messages : [];
54721
+ const fullMessages = normalizeChatMessages(Array.isArray(result.messages) ? result.messages : []);
54722
+ const messages = filterUserFacingChatMessages(fullMessages);
54225
54723
  const title = typeof result.title === "string" ? result.title : void 0;
54226
54724
  const activeModal = normalizeChatTailActiveModal(result.activeModal);
54227
54725
  const status = typeof result.status === "string" ? result.status : "idle";
@@ -55481,11 +55979,11 @@ Run 'adhdev doctor' for detailed diagnostics.`
55481
55979
  }
55482
55980
  };
55483
55981
  var fs11 = __toESM2(require("fs"));
55484
- var path222 = __toESM2(require("path"));
55982
+ var path232 = __toESM2(require("path"));
55485
55983
  var os20 = __toESM2(require("os"));
55486
55984
  var import_child_process10 = require("child_process");
55487
55985
  var import_os3 = require("os");
55488
- var ARCHIVE_PATH = path222.join(os20.homedir(), ".adhdev", "version-history.json");
55986
+ var ARCHIVE_PATH = path232.join(os20.homedir(), ".adhdev", "version-history.json");
55489
55987
  var MAX_ENTRIES_PER_PROVIDER = 20;
55490
55988
  var VersionArchive = class {
55491
55989
  history = {};
@@ -55532,7 +56030,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
55532
56030
  }
55533
56031
  save() {
55534
56032
  try {
55535
- fs11.mkdirSync(path222.dirname(ARCHIVE_PATH), { recursive: true });
56033
+ fs11.mkdirSync(path232.dirname(ARCHIVE_PATH), { recursive: true });
55536
56034
  fs11.writeFileSync(ARCHIVE_PATH, JSON.stringify(this.history, null, 2));
55537
56035
  } catch {
55538
56036
  }
@@ -55589,7 +56087,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
55589
56087
  for (const p of paths) {
55590
56088
  if (p.includes("*")) {
55591
56089
  const home = os20.homedir();
55592
- const resolved = p.replace(/\*/g, home.split(path222.sep).pop() || "");
56090
+ const resolved = p.replace(/\*/g, home.split(path232.sep).pop() || "");
55593
56091
  if (fs11.existsSync(resolved)) return resolved;
55594
56092
  } else {
55595
56093
  if (fs11.existsSync(p)) return p;
@@ -55599,7 +56097,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
55599
56097
  }
55600
56098
  function getMacAppVersion(appPath) {
55601
56099
  if ((0, import_os3.platform)() !== "darwin" || !appPath.endsWith(".app")) return null;
55602
- const plistPath = path222.join(appPath, "Contents", "Info.plist");
56100
+ const plistPath = path232.join(appPath, "Contents", "Info.plist");
55603
56101
  if (!fs11.existsSync(plistPath)) return null;
55604
56102
  const raw = runCommand(`/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${plistPath}"`);
55605
56103
  return raw || null;
@@ -55625,7 +56123,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
55625
56123
  const cliBin = provider.cli ? findBinary2(provider.cli) : null;
55626
56124
  let resolvedBin = cliBin;
55627
56125
  if (!resolvedBin && appPath && currentOs === "darwin") {
55628
- const bundled = path222.join(appPath, "Contents", "Resources", "app", "bin", provider.cli || "");
56126
+ const bundled = path232.join(appPath, "Contents", "Resources", "app", "bin", provider.cli || "");
55629
56127
  if (provider.cli && fs11.existsSync(bundled)) resolvedBin = bundled;
55630
56128
  }
55631
56129
  info.installed = !!(appPath || resolvedBin);
@@ -55664,7 +56162,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
55664
56162
  }
55665
56163
  var http2 = __toESM2(require("http"));
55666
56164
  var fs15 = __toESM2(require("fs"));
55667
- var path26 = __toESM2(require("path"));
56165
+ var path27 = __toESM2(require("path"));
55668
56166
  init_config();
55669
56167
  function generateFiles(type, name, category, opts = {}) {
55670
56168
  const { cdpPorts, cli, processName, installPath, binary, extensionId, version: version2 = "0.1" } = opts;
@@ -56009,7 +56507,7 @@ async (params) => {
56009
56507
  }
56010
56508
  init_logger();
56011
56509
  var fs12 = __toESM2(require("fs"));
56012
- var path232 = __toESM2(require("path"));
56510
+ var path24 = __toESM2(require("path"));
56013
56511
  init_logger();
56014
56512
  async function handleCdpEvaluate(ctx, req, res) {
56015
56513
  const body = await ctx.readBody(req);
@@ -56188,17 +56686,17 @@ async (params) => {
56188
56686
  return;
56189
56687
  }
56190
56688
  let scriptsPath = "";
56191
- const directScripts = path232.join(dir, "scripts.js");
56689
+ const directScripts = path24.join(dir, "scripts.js");
56192
56690
  if (fs12.existsSync(directScripts)) {
56193
56691
  scriptsPath = directScripts;
56194
56692
  } else {
56195
- const scriptsDir = path232.join(dir, "scripts");
56693
+ const scriptsDir = path24.join(dir, "scripts");
56196
56694
  if (fs12.existsSync(scriptsDir)) {
56197
56695
  const versions = fs12.readdirSync(scriptsDir).filter((d) => {
56198
- return fs12.statSync(path232.join(scriptsDir, d)).isDirectory();
56696
+ return fs12.statSync(path24.join(scriptsDir, d)).isDirectory();
56199
56697
  }).sort().reverse();
56200
56698
  for (const ver of versions) {
56201
- const p = path232.join(scriptsDir, ver, "scripts.js");
56699
+ const p = path24.join(scriptsDir, ver, "scripts.js");
56202
56700
  if (fs12.existsSync(p)) {
56203
56701
  scriptsPath = p;
56204
56702
  break;
@@ -57025,7 +57523,7 @@ async (params) => {
57025
57523
  }
57026
57524
  }
57027
57525
  var fs13 = __toESM2(require("fs"));
57028
- var path24 = __toESM2(require("path"));
57526
+ var path25 = __toESM2(require("path"));
57029
57527
  function slugifyFixtureName(value) {
57030
57528
  const normalized = String(value || "").trim().toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^-+|-+$/g, "");
57031
57529
  return normalized || `fixture-${Date.now()}`;
@@ -57035,11 +57533,11 @@ async (params) => {
57035
57533
  if (!providerDir) {
57036
57534
  throw new Error(`Provider directory not found for '${type}'`);
57037
57535
  }
57038
- return path24.join(providerDir, "fixtures");
57536
+ return path25.join(providerDir, "fixtures");
57039
57537
  }
57040
57538
  function readCliFixture(ctx, type, name) {
57041
57539
  const fixtureDir = getCliFixtureDir(ctx, type);
57042
- const filePath = path24.join(fixtureDir, `${name}.json`);
57540
+ const filePath = path25.join(fixtureDir, `${name}.json`);
57043
57541
  if (!fs13.existsSync(filePath)) {
57044
57542
  throw new Error(`Fixture not found: ${filePath}`);
57045
57543
  }
@@ -57806,7 +58304,7 @@ async (params) => {
57806
58304
  },
57807
58305
  notes: typeof body?.notes === "string" ? body.notes : void 0
57808
58306
  };
57809
- const filePath = path24.join(fixtureDir, `${name}.json`);
58307
+ const filePath = path25.join(fixtureDir, `${name}.json`);
57810
58308
  fs13.writeFileSync(filePath, JSON.stringify(fixture, null, 2));
57811
58309
  ctx.json(res, 200, {
57812
58310
  saved: true,
@@ -57830,7 +58328,7 @@ async (params) => {
57830
58328
  return;
57831
58329
  }
57832
58330
  const fixtures = fs13.readdirSync(fixtureDir).filter((file2) => file2.endsWith(".json")).sort((a, b2) => b2.localeCompare(a, void 0, { numeric: true, sensitivity: "base" })).map((file2) => {
57833
- const fullPath = path24.join(fixtureDir, file2);
58331
+ const fullPath = path25.join(fixtureDir, file2);
57834
58332
  try {
57835
58333
  const raw = JSON.parse(fs13.readFileSync(fullPath, "utf-8"));
57836
58334
  return {
@@ -57964,7 +58462,7 @@ async (params) => {
57964
58462
  }
57965
58463
  }
57966
58464
  var fs14 = __toESM2(require("fs"));
57967
- var path25 = __toESM2(require("path"));
58465
+ var path26 = __toESM2(require("path"));
57968
58466
  var os21 = __toESM2(require("os"));
57969
58467
  function getAutoImplPid(ctx) {
57970
58468
  const pid = ctx.autoImplProcess?.pid;
@@ -58014,22 +58512,22 @@ async (params) => {
58014
58512
  if (!fs14.existsSync(scriptsDir)) return null;
58015
58513
  const versions = fs14.readdirSync(scriptsDir).filter((d) => {
58016
58514
  try {
58017
- return fs14.statSync(path25.join(scriptsDir, d)).isDirectory();
58515
+ return fs14.statSync(path26.join(scriptsDir, d)).isDirectory();
58018
58516
  } catch {
58019
58517
  return false;
58020
58518
  }
58021
58519
  }).sort((a, b2) => b2.localeCompare(a, void 0, { numeric: true, sensitivity: "base" }));
58022
58520
  if (versions.length === 0) return null;
58023
- return path25.join(scriptsDir, versions[0]);
58521
+ return path26.join(scriptsDir, versions[0]);
58024
58522
  }
58025
58523
  function resolveAutoImplWritableProviderDir(ctx, category, type, requestedDir) {
58026
- const canonicalUserDir = path25.resolve(ctx.providerLoader.getUserProviderDir(category, type));
58027
- const desiredDir = requestedDir ? path25.resolve(requestedDir) : canonicalUserDir;
58028
- const upstreamRoot = path25.resolve(ctx.providerLoader.getUpstreamDir());
58029
- if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${path25.sep}`)) {
58524
+ const canonicalUserDir = path26.resolve(ctx.providerLoader.getUserProviderDir(category, type));
58525
+ const desiredDir = requestedDir ? path26.resolve(requestedDir) : canonicalUserDir;
58526
+ const upstreamRoot = path26.resolve(ctx.providerLoader.getUpstreamDir());
58527
+ if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${path26.sep}`)) {
58030
58528
  return { dir: null, reason: `Refusing to write into upstream provider directory: ${desiredDir}` };
58031
58529
  }
58032
- if (path25.basename(desiredDir) !== type) {
58530
+ if (path26.basename(desiredDir) !== type) {
58033
58531
  return { dir: null, reason: `Requested writable provider directory must end with '${type}': ${desiredDir}` };
58034
58532
  }
58035
58533
  const sourceDir = ctx.findProviderDir(type);
@@ -58037,11 +58535,11 @@ async (params) => {
58037
58535
  return { dir: null, reason: `Provider source directory not found for '${type}'` };
58038
58536
  }
58039
58537
  if (!fs14.existsSync(desiredDir)) {
58040
- fs14.mkdirSync(path25.dirname(desiredDir), { recursive: true });
58538
+ fs14.mkdirSync(path26.dirname(desiredDir), { recursive: true });
58041
58539
  fs14.cpSync(sourceDir, desiredDir, { recursive: true });
58042
58540
  ctx.log(`Auto-implement writable copy created: ${desiredDir}`);
58043
58541
  }
58044
- const providerJson = path25.join(desiredDir, "provider.json");
58542
+ const providerJson = path26.join(desiredDir, "provider.json");
58045
58543
  if (!fs14.existsSync(providerJson)) {
58046
58544
  return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
58047
58545
  }
@@ -58052,13 +58550,13 @@ async (params) => {
58052
58550
  const refDir = ctx.findProviderDir(referenceType);
58053
58551
  if (!refDir || !fs14.existsSync(refDir)) return {};
58054
58552
  const referenceScripts = {};
58055
- const scriptsDir = path25.join(refDir, "scripts");
58553
+ const scriptsDir = path26.join(refDir, "scripts");
58056
58554
  const latestDir = getLatestScriptVersionDir(scriptsDir);
58057
58555
  if (!latestDir) return referenceScripts;
58058
58556
  for (const file2 of fs14.readdirSync(latestDir)) {
58059
58557
  if (!file2.endsWith(".js")) continue;
58060
58558
  try {
58061
- referenceScripts[file2] = fs14.readFileSync(path25.join(latestDir, file2), "utf-8");
58559
+ referenceScripts[file2] = fs14.readFileSync(path26.join(latestDir, file2), "utf-8");
58062
58560
  } catch {
58063
58561
  }
58064
58562
  }
@@ -58166,9 +58664,9 @@ async (params) => {
58166
58664
  });
58167
58665
  const referenceScripts = loadAutoImplReferenceScripts(ctx, resolvedReference);
58168
58666
  const prompt = buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domContext, referenceScripts, comment, resolvedReference, verification);
58169
- const tmpDir = path25.join(os21.tmpdir(), "adhdev-autoimpl");
58667
+ const tmpDir = path26.join(os21.tmpdir(), "adhdev-autoimpl");
58170
58668
  if (!fs14.existsSync(tmpDir)) fs14.mkdirSync(tmpDir, { recursive: true });
58171
- const promptFile = path25.join(tmpDir, `prompt-${type}-${Date.now()}.md`);
58669
+ const promptFile = path26.join(tmpDir, `prompt-${type}-${Date.now()}.md`);
58172
58670
  fs14.writeFileSync(promptFile, prompt, "utf-8");
58173
58671
  ctx.log(`Auto-implement prompt written to ${promptFile} (${prompt.length} chars)`);
58174
58672
  const agentProvider = ctx.providerLoader.resolve(agent) || ctx.providerLoader.getMeta(agent);
@@ -58600,7 +59098,7 @@ async (params) => {
58600
59098
  setMode: "set_mode.js"
58601
59099
  };
58602
59100
  const targetFileNames = new Set(functions.map((fn2) => funcToFile[fn2]).filter(Boolean));
58603
- const scriptsDir = path25.join(providerDir, "scripts");
59101
+ const scriptsDir = path26.join(providerDir, "scripts");
58604
59102
  const latestScriptsDir = getLatestScriptVersionDir(scriptsDir);
58605
59103
  if (latestScriptsDir) {
58606
59104
  lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
@@ -58611,7 +59109,7 @@ async (params) => {
58611
59109
  for (const file2 of fs14.readdirSync(latestScriptsDir)) {
58612
59110
  if (file2.endsWith(".js") && targetFileNames.has(file2)) {
58613
59111
  try {
58614
- const content = fs14.readFileSync(path25.join(latestScriptsDir, file2), "utf-8");
59112
+ const content = fs14.readFileSync(path26.join(latestScriptsDir, file2), "utf-8");
58615
59113
  lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
58616
59114
  lines.push("```javascript");
58617
59115
  lines.push(content);
@@ -58628,7 +59126,7 @@ async (params) => {
58628
59126
  lines.push("");
58629
59127
  for (const file2 of refFiles) {
58630
59128
  try {
58631
- const content = fs14.readFileSync(path25.join(latestScriptsDir, file2), "utf-8");
59129
+ const content = fs14.readFileSync(path26.join(latestScriptsDir, file2), "utf-8");
58632
59130
  lines.push(`### \`${file2}\` \u{1F512}`);
58633
59131
  lines.push("```javascript");
58634
59132
  lines.push(content);
@@ -58669,10 +59167,10 @@ async (params) => {
58669
59167
  lines.push("");
58670
59168
  }
58671
59169
  }
58672
- const docsDir = path25.join(providerDir, "../../docs");
59170
+ const docsDir = path26.join(providerDir, "../../docs");
58673
59171
  const loadGuide = (name) => {
58674
59172
  try {
58675
- const p = path25.join(docsDir, name);
59173
+ const p = path26.join(docsDir, name);
58676
59174
  if (fs14.existsSync(p)) return fs14.readFileSync(p, "utf-8");
58677
59175
  } catch {
58678
59176
  }
@@ -58909,7 +59407,7 @@ async (params) => {
58909
59407
  parseApproval: "parse_approval.js"
58910
59408
  };
58911
59409
  const targetFileNames = new Set(functions.map((fn2) => funcToFile[fn2]).filter(Boolean));
58912
- const scriptsDir = path25.join(providerDir, "scripts");
59410
+ const scriptsDir = path26.join(providerDir, "scripts");
58913
59411
  const latestScriptsDir = getLatestScriptVersionDir(scriptsDir);
58914
59412
  if (latestScriptsDir) {
58915
59413
  lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
@@ -58921,7 +59419,7 @@ async (params) => {
58921
59419
  if (!file2.endsWith(".js")) continue;
58922
59420
  if (!targetFileNames.has(file2)) continue;
58923
59421
  try {
58924
- const content = fs14.readFileSync(path25.join(latestScriptsDir, file2), "utf-8");
59422
+ const content = fs14.readFileSync(path26.join(latestScriptsDir, file2), "utf-8");
58925
59423
  lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
58926
59424
  lines.push("```javascript");
58927
59425
  lines.push(content);
@@ -58937,7 +59435,7 @@ async (params) => {
58937
59435
  lines.push("");
58938
59436
  for (const file2 of refFiles) {
58939
59437
  try {
58940
- const content = fs14.readFileSync(path25.join(latestScriptsDir, file2), "utf-8");
59438
+ const content = fs14.readFileSync(path26.join(latestScriptsDir, file2), "utf-8");
58941
59439
  lines.push(`### \`${file2}\` \u{1F512}`);
58942
59440
  lines.push("```javascript");
58943
59441
  lines.push(content);
@@ -58970,10 +59468,10 @@ async (params) => {
58970
59468
  lines.push("");
58971
59469
  }
58972
59470
  }
58973
- const docsDir = path25.join(providerDir, "../../docs");
59471
+ const docsDir = path26.join(providerDir, "../../docs");
58974
59472
  const loadGuide = (name) => {
58975
59473
  try {
58976
- const p = path25.join(docsDir, name);
59474
+ const p = path26.join(docsDir, name);
58977
59475
  if (fs14.existsSync(p)) return fs14.readFileSync(p, "utf-8");
58978
59476
  } catch {
58979
59477
  }
@@ -59418,8 +59916,8 @@ data: ${JSON.stringify(msg.data)}
59418
59916
  }
59419
59917
  getEndpointList() {
59420
59918
  return this.routes.map((r) => {
59421
- const path27 = typeof r.pattern === "string" ? r.pattern : r.pattern.source.replace(/\\\//g, "/").replace(/\(\[.*?\]\+\)/g, ":type").replace(/[\^$]/g, "");
59422
- return `${r.method.padEnd(5)} ${path27}`;
59919
+ const path28 = typeof r.pattern === "string" ? r.pattern : r.pattern.source.replace(/\\\//g, "/").replace(/\(\[.*?\]\+\)/g, ":type").replace(/[\^$]/g, "");
59920
+ return `${r.method.padEnd(5)} ${path28}`;
59423
59921
  });
59424
59922
  }
59425
59923
  async start(port = DEV_SERVER_PORT) {
@@ -59707,12 +60205,12 @@ data: ${JSON.stringify(msg.data)}
59707
60205
  // ─── DevConsole SPA ───
59708
60206
  getConsoleDistDir() {
59709
60207
  const candidates = [
59710
- path26.resolve(__dirname, "../../web-devconsole/dist"),
59711
- path26.resolve(__dirname, "../../../web-devconsole/dist"),
59712
- path26.join(process.cwd(), "packages/web-devconsole/dist")
60208
+ path27.resolve(__dirname, "../../web-devconsole/dist"),
60209
+ path27.resolve(__dirname, "../../../web-devconsole/dist"),
60210
+ path27.join(process.cwd(), "packages/web-devconsole/dist")
59713
60211
  ];
59714
60212
  for (const dir of candidates) {
59715
- if (fs15.existsSync(path26.join(dir, "index.html"))) return dir;
60213
+ if (fs15.existsSync(path27.join(dir, "index.html"))) return dir;
59716
60214
  }
59717
60215
  return null;
59718
60216
  }
@@ -59722,7 +60220,7 @@ data: ${JSON.stringify(msg.data)}
59722
60220
  this.json(res, 500, { error: "DevConsole not found. Run: npm run build -w packages/web-devconsole" });
59723
60221
  return;
59724
60222
  }
59725
- const htmlPath = path26.join(distDir, "index.html");
60223
+ const htmlPath = path27.join(distDir, "index.html");
59726
60224
  try {
59727
60225
  const html = fs15.readFileSync(htmlPath, "utf-8");
59728
60226
  res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
@@ -59747,15 +60245,15 @@ data: ${JSON.stringify(msg.data)}
59747
60245
  this.json(res, 404, { error: "Not found" });
59748
60246
  return;
59749
60247
  }
59750
- const safePath = path26.normalize(pathname).replace(/^\.\.\//, "");
59751
- const filePath = path26.join(distDir, safePath);
60248
+ const safePath = path27.normalize(pathname).replace(/^\.\.\//, "");
60249
+ const filePath = path27.join(distDir, safePath);
59752
60250
  if (!filePath.startsWith(distDir)) {
59753
60251
  this.json(res, 403, { error: "Forbidden" });
59754
60252
  return;
59755
60253
  }
59756
60254
  try {
59757
60255
  const content = fs15.readFileSync(filePath);
59758
- const ext = path26.extname(filePath);
60256
+ const ext = path27.extname(filePath);
59759
60257
  const contentType = _DevServer.MIME_MAP[ext] || "application/octet-stream";
59760
60258
  res.writeHead(200, { "Content-Type": contentType, "Cache-Control": "public, max-age=31536000, immutable" });
59761
60259
  res.end(content);
@@ -59868,9 +60366,9 @@ data: ${JSON.stringify(msg.data)}
59868
60366
  const rel = prefix ? `${prefix}/${entry.name}` : entry.name;
59869
60367
  if (entry.isDirectory()) {
59870
60368
  files.push({ path: rel, size: 0, type: "dir" });
59871
- scan(path26.join(d, entry.name), rel);
60369
+ scan(path27.join(d, entry.name), rel);
59872
60370
  } else {
59873
- const stat2 = fs15.statSync(path26.join(d, entry.name));
60371
+ const stat2 = fs15.statSync(path27.join(d, entry.name));
59874
60372
  files.push({ path: rel, size: stat2.size, type: "file" });
59875
60373
  }
59876
60374
  }
@@ -59893,7 +60391,7 @@ data: ${JSON.stringify(msg.data)}
59893
60391
  this.json(res, 404, { error: `Provider directory not found: ${type}` });
59894
60392
  return;
59895
60393
  }
59896
- const fullPath = path26.resolve(dir, path26.normalize(filePath));
60394
+ const fullPath = path27.resolve(dir, path27.normalize(filePath));
59897
60395
  if (!fullPath.startsWith(dir)) {
59898
60396
  this.json(res, 403, { error: "Forbidden" });
59899
60397
  return;
@@ -59918,14 +60416,14 @@ data: ${JSON.stringify(msg.data)}
59918
60416
  this.json(res, 404, { error: `Provider directory not found: ${type}` });
59919
60417
  return;
59920
60418
  }
59921
- const fullPath = path26.resolve(dir, path26.normalize(filePath));
60419
+ const fullPath = path27.resolve(dir, path27.normalize(filePath));
59922
60420
  if (!fullPath.startsWith(dir)) {
59923
60421
  this.json(res, 403, { error: "Forbidden" });
59924
60422
  return;
59925
60423
  }
59926
60424
  try {
59927
60425
  if (fs15.existsSync(fullPath)) fs15.copyFileSync(fullPath, fullPath + ".bak");
59928
- fs15.mkdirSync(path26.dirname(fullPath), { recursive: true });
60426
+ fs15.mkdirSync(path27.dirname(fullPath), { recursive: true });
59929
60427
  fs15.writeFileSync(fullPath, content, "utf-8");
59930
60428
  this.log(`File saved: ${fullPath} (${content.length} chars)`);
59931
60429
  this.providerLoader.reload();
@@ -59942,7 +60440,7 @@ data: ${JSON.stringify(msg.data)}
59942
60440
  return;
59943
60441
  }
59944
60442
  for (const name of ["scripts.js", "provider.json"]) {
59945
- const p = path26.join(dir, name);
60443
+ const p = path27.join(dir, name);
59946
60444
  if (fs15.existsSync(p)) {
59947
60445
  const source = fs15.readFileSync(p, "utf-8");
59948
60446
  this.json(res, 200, { type, path: p, source, lines: source.split("\n").length });
@@ -59963,8 +60461,8 @@ data: ${JSON.stringify(msg.data)}
59963
60461
  this.json(res, 404, { error: `Provider not found: ${type}` });
59964
60462
  return;
59965
60463
  }
59966
- const target = fs15.existsSync(path26.join(dir, "scripts.js")) ? "scripts.js" : "provider.json";
59967
- const targetPath = path26.join(dir, target);
60464
+ const target = fs15.existsSync(path27.join(dir, "scripts.js")) ? "scripts.js" : "provider.json";
60465
+ const targetPath = path27.join(dir, target);
59968
60466
  try {
59969
60467
  if (fs15.existsSync(targetPath)) fs15.copyFileSync(targetPath, targetPath + ".bak");
59970
60468
  fs15.writeFileSync(targetPath, source, "utf-8");
@@ -60111,7 +60609,7 @@ data: ${JSON.stringify(msg.data)}
60111
60609
  }
60112
60610
  let targetDir;
60113
60611
  targetDir = this.providerLoader.getUserProviderDir(category, type);
60114
- const jsonPath = path26.join(targetDir, "provider.json");
60612
+ const jsonPath = path27.join(targetDir, "provider.json");
60115
60613
  if (fs15.existsSync(jsonPath)) {
60116
60614
  this.json(res, 409, { error: `Provider already exists at ${targetDir}`, path: targetDir });
60117
60615
  return;
@@ -60123,8 +60621,8 @@ data: ${JSON.stringify(msg.data)}
60123
60621
  const createdFiles = ["provider.json"];
60124
60622
  if (result.files) {
60125
60623
  for (const [relPath, content] of Object.entries(result.files)) {
60126
- const fullPath = path26.join(targetDir, relPath);
60127
- fs15.mkdirSync(path26.dirname(fullPath), { recursive: true });
60624
+ const fullPath = path27.join(targetDir, relPath);
60625
+ fs15.mkdirSync(path27.dirname(fullPath), { recursive: true });
60128
60626
  fs15.writeFileSync(fullPath, content, "utf-8");
60129
60627
  createdFiles.push(relPath);
60130
60628
  }
@@ -60177,22 +60675,22 @@ data: ${JSON.stringify(msg.data)}
60177
60675
  if (!fs15.existsSync(scriptsDir)) return null;
60178
60676
  const versions = fs15.readdirSync(scriptsDir).filter((d) => {
60179
60677
  try {
60180
- return fs15.statSync(path26.join(scriptsDir, d)).isDirectory();
60678
+ return fs15.statSync(path27.join(scriptsDir, d)).isDirectory();
60181
60679
  } catch {
60182
60680
  return false;
60183
60681
  }
60184
60682
  }).sort((a, b2) => b2.localeCompare(a, void 0, { numeric: true, sensitivity: "base" }));
60185
60683
  if (versions.length === 0) return null;
60186
- return path26.join(scriptsDir, versions[0]);
60684
+ return path27.join(scriptsDir, versions[0]);
60187
60685
  }
60188
60686
  resolveAutoImplWritableProviderDir(category, type, requestedDir) {
60189
- const canonicalUserDir = path26.resolve(this.providerLoader.getUserProviderDir(category, type));
60190
- const desiredDir = requestedDir ? path26.resolve(requestedDir) : canonicalUserDir;
60191
- const upstreamRoot = path26.resolve(this.providerLoader.getUpstreamDir());
60192
- if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${path26.sep}`)) {
60687
+ const canonicalUserDir = path27.resolve(this.providerLoader.getUserProviderDir(category, type));
60688
+ const desiredDir = requestedDir ? path27.resolve(requestedDir) : canonicalUserDir;
60689
+ const upstreamRoot = path27.resolve(this.providerLoader.getUpstreamDir());
60690
+ if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${path27.sep}`)) {
60193
60691
  return { dir: null, reason: `Refusing to write into upstream provider directory: ${desiredDir}` };
60194
60692
  }
60195
- if (path26.basename(desiredDir) !== type) {
60693
+ if (path27.basename(desiredDir) !== type) {
60196
60694
  return { dir: null, reason: `Requested writable provider directory must end with '${type}': ${desiredDir}` };
60197
60695
  }
60198
60696
  const sourceDir = this.findProviderDir(type);
@@ -60200,11 +60698,11 @@ data: ${JSON.stringify(msg.data)}
60200
60698
  return { dir: null, reason: `Provider source directory not found for '${type}'` };
60201
60699
  }
60202
60700
  if (!fs15.existsSync(desiredDir)) {
60203
- fs15.mkdirSync(path26.dirname(desiredDir), { recursive: true });
60701
+ fs15.mkdirSync(path27.dirname(desiredDir), { recursive: true });
60204
60702
  fs15.cpSync(sourceDir, desiredDir, { recursive: true });
60205
60703
  this.log(`Auto-implement writable copy created: ${desiredDir}`);
60206
60704
  }
60207
- const providerJson = path26.join(desiredDir, "provider.json");
60705
+ const providerJson = path27.join(desiredDir, "provider.json");
60208
60706
  if (!fs15.existsSync(providerJson)) {
60209
60707
  return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
60210
60708
  }
@@ -60240,7 +60738,7 @@ data: ${JSON.stringify(msg.data)}
60240
60738
  setMode: "set_mode.js"
60241
60739
  };
60242
60740
  const targetFileNames = new Set(functions.map((fn2) => funcToFile[fn2]).filter(Boolean));
60243
- const scriptsDir = path26.join(providerDir, "scripts");
60741
+ const scriptsDir = path27.join(providerDir, "scripts");
60244
60742
  const latestScriptsDir = this.getLatestScriptVersionDir(scriptsDir);
60245
60743
  if (latestScriptsDir) {
60246
60744
  lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
@@ -60251,7 +60749,7 @@ data: ${JSON.stringify(msg.data)}
60251
60749
  for (const file2 of fs15.readdirSync(latestScriptsDir)) {
60252
60750
  if (file2.endsWith(".js") && targetFileNames.has(file2)) {
60253
60751
  try {
60254
- const content = fs15.readFileSync(path26.join(latestScriptsDir, file2), "utf-8");
60752
+ const content = fs15.readFileSync(path27.join(latestScriptsDir, file2), "utf-8");
60255
60753
  lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
60256
60754
  lines.push("```javascript");
60257
60755
  lines.push(content);
@@ -60268,7 +60766,7 @@ data: ${JSON.stringify(msg.data)}
60268
60766
  lines.push("");
60269
60767
  for (const file2 of refFiles) {
60270
60768
  try {
60271
- const content = fs15.readFileSync(path26.join(latestScriptsDir, file2), "utf-8");
60769
+ const content = fs15.readFileSync(path27.join(latestScriptsDir, file2), "utf-8");
60272
60770
  lines.push(`### \`${file2}\` \u{1F512}`);
60273
60771
  lines.push("```javascript");
60274
60772
  lines.push(content);
@@ -60309,10 +60807,10 @@ data: ${JSON.stringify(msg.data)}
60309
60807
  lines.push("");
60310
60808
  }
60311
60809
  }
60312
- const docsDir = path26.join(providerDir, "../../docs");
60810
+ const docsDir = path27.join(providerDir, "../../docs");
60313
60811
  const loadGuide = (name) => {
60314
60812
  try {
60315
- const p = path26.join(docsDir, name);
60813
+ const p = path27.join(docsDir, name);
60316
60814
  if (fs15.existsSync(p)) return fs15.readFileSync(p, "utf-8");
60317
60815
  } catch {
60318
60816
  }
@@ -60486,7 +60984,7 @@ data: ${JSON.stringify(msg.data)}
60486
60984
  parseApproval: "parse_approval.js"
60487
60985
  };
60488
60986
  const targetFileNames = new Set(functions.map((fn2) => funcToFile[fn2]).filter(Boolean));
60489
- const scriptsDir = path26.join(providerDir, "scripts");
60987
+ const scriptsDir = path27.join(providerDir, "scripts");
60490
60988
  const latestScriptsDir = this.getLatestScriptVersionDir(scriptsDir);
60491
60989
  if (latestScriptsDir) {
60492
60990
  lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
@@ -60498,7 +60996,7 @@ data: ${JSON.stringify(msg.data)}
60498
60996
  if (!file2.endsWith(".js")) continue;
60499
60997
  if (!targetFileNames.has(file2)) continue;
60500
60998
  try {
60501
- const content = fs15.readFileSync(path26.join(latestScriptsDir, file2), "utf-8");
60999
+ const content = fs15.readFileSync(path27.join(latestScriptsDir, file2), "utf-8");
60502
61000
  lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
60503
61001
  lines.push("```javascript");
60504
61002
  lines.push(content);
@@ -60514,7 +61012,7 @@ data: ${JSON.stringify(msg.data)}
60514
61012
  lines.push("");
60515
61013
  for (const file2 of refFiles) {
60516
61014
  try {
60517
- const content = fs15.readFileSync(path26.join(latestScriptsDir, file2), "utf-8");
61015
+ const content = fs15.readFileSync(path27.join(latestScriptsDir, file2), "utf-8");
60518
61016
  lines.push(`### \`${file2}\` \u{1F512}`);
60519
61017
  lines.push("```javascript");
60520
61018
  lines.push(content);
@@ -60547,10 +61045,10 @@ data: ${JSON.stringify(msg.data)}
60547
61045
  lines.push("");
60548
61046
  }
60549
61047
  }
60550
- const docsDir = path26.join(providerDir, "../../docs");
61048
+ const docsDir = path27.join(providerDir, "../../docs");
60551
61049
  const loadGuide = (name) => {
60552
61050
  try {
60553
- const p = path26.join(docsDir, name);
61051
+ const p = path27.join(docsDir, name);
60554
61052
  if (fs15.existsSync(p)) return fs15.readFileSync(p, "utf-8");
60555
61053
  } catch {
60556
61054
  }