@adhdev/daemon-standalone 0.7.14 → 0.7.16

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
@@ -19590,31 +19590,14 @@ var init_provider_cli_adapter = __esm2({
19590
19590
  this.accumulatedRawBuffer = (this.accumulatedRawBuffer + rawData).slice(-_ProviderCliAdapter.MAX_ACCUMULATED_BUFFER);
19591
19591
  if (this.startupParseGate) {
19592
19592
  this.startupBuffer += cleanData;
19593
- const dialogPatterns = [
19594
- /Do you want to connect/i,
19595
- /Do you trust the files/i,
19596
- /Quick safety check/i,
19597
- /Is this a project/i,
19598
- /Enter to confirm/i,
19599
- /be able to read, edit, and execute/i,
19600
- /Security guide/i
19601
- ];
19602
- if (dialogPatterns.some((p) => p.test(this.startupBuffer))) {
19603
- setTimeout(() => this.ptyProcess?.write("\r"), this.timeouts.dialogAccept);
19604
- this.startupBuffer = "";
19605
- return;
19606
- }
19607
19593
  const elapsed = Date.now() - this.spawnAt;
19608
- const bufCap = this.startupBuffer.length > 12e3;
19609
19594
  const scriptStatus = this.runDetectStatus(this.startupBuffer);
19610
- const isReady = scriptStatus === "idle" || elapsed > 8e3 || bufCap;
19595
+ const isReady = scriptStatus === "idle" || scriptStatus === "waiting_approval" || elapsed > 8e3 || this.startupBuffer.length > 12e3;
19611
19596
  if (isReady) {
19612
19597
  this.startupParseGate = false;
19613
19598
  this.ready = true;
19614
- LOG.info("CLI", `[${this.cliType}] Startup gate end (${elapsed}ms, scriptStatus=${scriptStatus})`);
19599
+ LOG.info("CLI", `[${this.cliType}] Startup ready (${elapsed}ms, scriptStatus=${scriptStatus})`);
19615
19600
  this.onStatusChange?.();
19616
- } else {
19617
- return;
19618
19601
  }
19619
19602
  }
19620
19603
  this.scheduleSettle();
@@ -19822,51 +19805,6 @@ var init_provider_cli_adapter = __esm2({
19822
19805
  this.onStatusChange?.();
19823
19806
  }
19824
19807
  commitCurrentTranscript() {
19825
- const baseMessages = [...this.committedMessages];
19826
- const parsed = this.parseCurrentTranscript(baseMessages, "", this.currentTurnScope);
19827
- if (parsed && Array.isArray(parsed.messages) && parsed.messages.length > 0) {
19828
- const parsedMessages = parsed.messages.filter((m) => m && (m.role === "user" || m.role === "assistant")).map((m) => ({
19829
- role: m.role,
19830
- content: typeof m.content === "string" ? m.content : String(m.content || ""),
19831
- timestamp: m.timestamp
19832
- }));
19833
- const latestAssistant = [...parsedMessages].reverse().find((m) => m.role === "assistant" && m.content.trim());
19834
- if (latestAssistant) {
19835
- LOG.info("CLI", `[${this.cliType}] commitCurrentTranscript parsed assistant len=${latestAssistant.content.length} scopePrompt=${JSON.stringify(this.currentTurnScope?.prompt || "").slice(0, 120)}`);
19836
- const nextMessages = [...baseMessages];
19837
- const last2 = nextMessages[nextMessages.length - 1];
19838
- if (last2?.role === "assistant") {
19839
- last2.content = latestAssistant.content;
19840
- last2.timestamp = latestAssistant.timestamp || last2.timestamp;
19841
- } else if (last2?.role === "user") {
19842
- nextMessages.push({
19843
- role: "assistant",
19844
- content: latestAssistant.content,
19845
- timestamp: latestAssistant.timestamp || Date.now()
19846
- });
19847
- } else {
19848
- nextMessages.push({
19849
- role: "assistant",
19850
- content: latestAssistant.content,
19851
- timestamp: latestAssistant.timestamp || Date.now()
19852
- });
19853
- }
19854
- this.committedMessages = nextMessages;
19855
- this.syncMessageViews();
19856
- return;
19857
- }
19858
- }
19859
- const fallback = String(this.responseBuffer || "").trim();
19860
- LOG.info("CLI", `[${this.cliType}] commitCurrentTranscript fallback len=${fallback.length} scopePrompt=${JSON.stringify(this.currentTurnScope?.prompt || "").slice(0, 120)}`);
19861
- if (!fallback) return;
19862
- const last = baseMessages[baseMessages.length - 1];
19863
- if (last?.role === "assistant") {
19864
- last.content = fallback;
19865
- } else {
19866
- baseMessages.push({ role: "assistant", content: fallback, timestamp: Date.now() });
19867
- }
19868
- this.committedMessages = baseMessages;
19869
- this.syncMessageViews();
19870
19808
  }
19871
19809
  // ─── Script Execution ──────────────────────────
19872
19810
  runDetectStatus(text) {
@@ -27824,6 +27762,11 @@ var AcpProviderInstance = class {
27824
27762
  }
27825
27763
  };
27826
27764
  init_logger();
27765
+ var chalkApi = import_chalk.default?.yellow ? import_chalk.default : import_chalk.default?.default || null;
27766
+ function colorize(color, text) {
27767
+ const fn = chalkApi?.[color];
27768
+ return typeof fn === "function" ? fn(text) : text;
27769
+ }
27827
27770
  var DaemonCliManager = class {
27828
27771
  adapters = /* @__PURE__ */ new Map();
27829
27772
  deps;
@@ -27843,16 +27786,16 @@ var DaemonCliManager = class {
27843
27786
  const provider = this.providerLoader.getByAlias(cliType);
27844
27787
  const actKind = provider?.category === "acp" ? "acp" : "cli";
27845
27788
  let next = loadConfig();
27846
- console.log(import_chalk.default.cyan(` \u{1F4C2} Saving recent workspace: ${dir}`));
27789
+ console.log(colorize("cyan", ` \u{1F4C2} Saving recent workspace: ${dir}`));
27847
27790
  const recent = next.recentCliWorkspaces || [];
27848
27791
  if (!recent.includes(dir)) {
27849
27792
  next = { ...next, recentCliWorkspaces: [dir, ...recent].slice(0, 10) };
27850
27793
  }
27851
27794
  next = appendWorkspaceActivity(next, dir, { kind: actKind, agentType: normalizedType });
27852
27795
  saveConfig(next);
27853
- console.log(import_chalk.default.green(` \u2713 Recent workspace saved: ${dir}`));
27796
+ console.log(colorize("green", ` \u2713 Recent workspace saved: ${dir}`));
27854
27797
  } catch (e) {
27855
- console.error(import_chalk.default.red(` \u2717 Failed to save recent workspace: ${e}`));
27798
+ console.error(colorize("red", ` \u2717 Failed to save recent workspace: ${e}`));
27856
27799
  }
27857
27800
  }
27858
27801
  getTransportFactory(runtimeId, providerType, workspace, cliArgs, attachExisting = false) {
@@ -27868,7 +27811,7 @@ var DaemonCliManager = class {
27868
27811
  const normalizedType = this.providerLoader.resolveAlias(cliType);
27869
27812
  const provider = this.providerLoader.getMeta(normalizedType);
27870
27813
  if (provider && provider.category === "cli" && provider.patterns && provider.spawn) {
27871
- console.log(import_chalk.default.cyan(` \u{1F4E6} Using provider: ${provider.name} (${provider.type})`));
27814
+ console.log(colorize("cyan", ` \u{1F4E6} Using provider: ${provider.name} (${provider.type})`));
27872
27815
  const resolvedProvider = this.providerLoader.resolve(normalizedType) || provider;
27873
27816
  const transportFactory = this.getTransportFactory(runtimeId, normalizedType, workingDir, cliArgs, attachExisting);
27874
27817
  return new ProviderCliAdapter(resolvedProvider, workingDir, cliArgs, transportFactory);
@@ -27961,7 +27904,7 @@ ${installInfo}`
27961
27904
  );
27962
27905
  }
27963
27906
  }
27964
- console.log(import_chalk.default.cyan(` \u{1F50C} Starting ACP agent: ${provider.name} (${provider.type}) in ${resolvedDir}`));
27907
+ console.log(colorize("cyan", ` \u{1F50C} Starting ACP agent: ${provider.name} (${provider.type}) in ${resolvedDir}`));
27965
27908
  const acpInstance = new AcpProviderInstance(provider, resolvedDir, cliArgs);
27966
27909
  await instanceManager2.addInstance(key, acpInstance, {
27967
27910
  settings: this.providerLoader.getSettings(normalizedType)
@@ -28001,11 +27944,11 @@ ${installInfo}`
28001
27944
  setOnPtyData: () => {
28002
27945
  }
28003
27946
  });
28004
- console.log(import_chalk.default.green(` \u2713 ACP agent started: ${provider.name} in ${resolvedDir}`));
27947
+ console.log(colorize("green", ` \u2713 ACP agent started: ${provider.name} in ${resolvedDir}`));
28005
27948
  if (initialModel) {
28006
27949
  try {
28007
27950
  await acpInstance.setConfigOption("model", initialModel);
28008
- console.log(import_chalk.default.green(` \u{1F916} Initial model set: ${initialModel}`));
27951
+ console.log(colorize("green", ` \u{1F916} Initial model set: ${initialModel}`));
28009
27952
  } catch (e) {
28010
27953
  LOG.warn("CLI", `[ACP] Initial model set failed: ${e?.message}`);
28011
27954
  }
@@ -28020,9 +27963,9 @@ ${installInfo}`
28020
27963
  }
28021
27964
  const cliInfo = await detectCLI(cliType, this.providerLoader);
28022
27965
  if (!cliInfo) throw new Error(`${cliType} not found`);
28023
- console.log(import_chalk.default.yellow(` \u26A1 Starting CLI ${cliType} in ${resolvedDir}...`));
27966
+ console.log(colorize("yellow", ` \u26A1 Starting CLI ${cliType} in ${resolvedDir}...`));
28024
27967
  if (provider) {
28025
- console.log(import_chalk.default.cyan(` \u{1F4E6} Using provider: ${provider.name} (${provider.type})`));
27968
+ console.log(colorize("cyan", ` \u{1F4E6} Using provider: ${provider.name} (${provider.type})`));
28026
27969
  }
28027
27970
  const instanceManager = this.deps.getInstanceManager();
28028
27971
  if (provider && instanceManager) {
@@ -28037,7 +27980,7 @@ ${installInfo}`
28037
27980
  {},
28038
27981
  false
28039
27982
  );
28040
- console.log(import_chalk.default.green(` \u2713 CLI started: ${cliInfo.displayName} v${cliInfo.version || "unknown"} in ${resolvedDir}`));
27983
+ console.log(colorize("green", ` \u2713 CLI started: ${cliInfo.displayName} v${cliInfo.version || "unknown"} in ${resolvedDir}`));
28041
27984
  } else {
28042
27985
  const adapter = this.createAdapter(cliType, resolvedDir, cliArgs, key, false);
28043
27986
  try {
@@ -28070,7 +28013,7 @@ ${installInfo}`
28070
28013
  });
28071
28014
  }
28072
28015
  this.adapters.set(key, adapter);
28073
- console.log(import_chalk.default.green(` \u2713 CLI started: ${cliInfo.displayName} v${cliInfo.version || "unknown"} in ${resolvedDir}`));
28016
+ console.log(colorize("green", ` \u2713 CLI started: ${cliInfo.displayName} v${cliInfo.version || "unknown"} in ${resolvedDir}`));
28074
28017
  }
28075
28018
  try {
28076
28019
  addCliHistory({ category: "cli", cliType, dir: resolvedDir, workspace: resolvedDir, cliArgs, model: initialModel });
@@ -28232,7 +28175,7 @@ ${installInfo}`
28232
28175
  if (found) {
28233
28176
  await this.stopSessionWithMode(found.key, mode);
28234
28177
  } else {
28235
- console.log(import_chalk.default.yellow(` \u26A0 No adapter found for ${cliType}`));
28178
+ console.log(colorize("yellow", ` \u26A0 No adapter found for ${cliType}`));
28236
28179
  }
28237
28180
  return { success: true, cliType, dir, stopped: true, mode };
28238
28181
  }