@adhdev/daemon-core 0.7.15 → 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
@@ -1351,31 +1351,14 @@ var init_provider_cli_adapter = __esm({
1351
1351
  this.accumulatedRawBuffer = (this.accumulatedRawBuffer + rawData).slice(-_ProviderCliAdapter.MAX_ACCUMULATED_BUFFER);
1352
1352
  if (this.startupParseGate) {
1353
1353
  this.startupBuffer += cleanData;
1354
- const dialogPatterns = [
1355
- /Do you want to connect/i,
1356
- /Do you trust the files/i,
1357
- /Quick safety check/i,
1358
- /Is this a project/i,
1359
- /Enter to confirm/i,
1360
- /be able to read, edit, and execute/i,
1361
- /Security guide/i
1362
- ];
1363
- if (dialogPatterns.some((p) => p.test(this.startupBuffer))) {
1364
- setTimeout(() => this.ptyProcess?.write("\r"), this.timeouts.dialogAccept);
1365
- this.startupBuffer = "";
1366
- return;
1367
- }
1368
1354
  const elapsed = Date.now() - this.spawnAt;
1369
- const bufCap = this.startupBuffer.length > 12e3;
1370
1355
  const scriptStatus = this.runDetectStatus(this.startupBuffer);
1371
- const isReady = scriptStatus === "idle" || elapsed > 8e3 || bufCap;
1356
+ const isReady = scriptStatus === "idle" || scriptStatus === "waiting_approval" || elapsed > 8e3 || this.startupBuffer.length > 12e3;
1372
1357
  if (isReady) {
1373
1358
  this.startupParseGate = false;
1374
1359
  this.ready = true;
1375
- LOG.info("CLI", `[${this.cliType}] Startup gate end (${elapsed}ms, scriptStatus=${scriptStatus})`);
1360
+ LOG.info("CLI", `[${this.cliType}] Startup ready (${elapsed}ms, scriptStatus=${scriptStatus})`);
1376
1361
  this.onStatusChange?.();
1377
- } else {
1378
- return;
1379
1362
  }
1380
1363
  }
1381
1364
  this.scheduleSettle();
@@ -1583,51 +1566,6 @@ var init_provider_cli_adapter = __esm({
1583
1566
  this.onStatusChange?.();
1584
1567
  }
1585
1568
  commitCurrentTranscript() {
1586
- const baseMessages = [...this.committedMessages];
1587
- const parsed = this.parseCurrentTranscript(baseMessages, "", this.currentTurnScope);
1588
- if (parsed && Array.isArray(parsed.messages) && parsed.messages.length > 0) {
1589
- const parsedMessages = parsed.messages.filter((m) => m && (m.role === "user" || m.role === "assistant")).map((m) => ({
1590
- role: m.role,
1591
- content: typeof m.content === "string" ? m.content : String(m.content || ""),
1592
- timestamp: m.timestamp
1593
- }));
1594
- const latestAssistant = [...parsedMessages].reverse().find((m) => m.role === "assistant" && m.content.trim());
1595
- if (latestAssistant) {
1596
- LOG.info("CLI", `[${this.cliType}] commitCurrentTranscript parsed assistant len=${latestAssistant.content.length} scopePrompt=${JSON.stringify(this.currentTurnScope?.prompt || "").slice(0, 120)}`);
1597
- const nextMessages = [...baseMessages];
1598
- const last2 = nextMessages[nextMessages.length - 1];
1599
- if (last2?.role === "assistant") {
1600
- last2.content = latestAssistant.content;
1601
- last2.timestamp = latestAssistant.timestamp || last2.timestamp;
1602
- } else if (last2?.role === "user") {
1603
- nextMessages.push({
1604
- role: "assistant",
1605
- content: latestAssistant.content,
1606
- timestamp: latestAssistant.timestamp || Date.now()
1607
- });
1608
- } else {
1609
- nextMessages.push({
1610
- role: "assistant",
1611
- content: latestAssistant.content,
1612
- timestamp: latestAssistant.timestamp || Date.now()
1613
- });
1614
- }
1615
- this.committedMessages = nextMessages;
1616
- this.syncMessageViews();
1617
- return;
1618
- }
1619
- }
1620
- const fallback = String(this.responseBuffer || "").trim();
1621
- LOG.info("CLI", `[${this.cliType}] commitCurrentTranscript fallback len=${fallback.length} scopePrompt=${JSON.stringify(this.currentTurnScope?.prompt || "").slice(0, 120)}`);
1622
- if (!fallback) return;
1623
- const last = baseMessages[baseMessages.length - 1];
1624
- if (last?.role === "assistant") {
1625
- last.content = fallback;
1626
- } else {
1627
- baseMessages.push({ role: "assistant", content: fallback, timestamp: Date.now() });
1628
- }
1629
- this.committedMessages = baseMessages;
1630
- this.syncMessageViews();
1631
1569
  }
1632
1570
  // ─── Script Execution ──────────────────────────
1633
1571
  runDetectStatus(text) {
@@ -10145,6 +10083,11 @@ var AcpProviderInstance = class {
10145
10083
 
10146
10084
  // src/commands/cli-manager.ts
10147
10085
  init_logger();
10086
+ var chalkApi = import_chalk.default?.yellow ? import_chalk.default : import_chalk.default?.default || null;
10087
+ function colorize(color, text) {
10088
+ const fn = chalkApi?.[color];
10089
+ return typeof fn === "function" ? fn(text) : text;
10090
+ }
10148
10091
  var DaemonCliManager = class {
10149
10092
  adapters = /* @__PURE__ */ new Map();
10150
10093
  deps;
@@ -10164,16 +10107,16 @@ var DaemonCliManager = class {
10164
10107
  const provider = this.providerLoader.getByAlias(cliType);
10165
10108
  const actKind = provider?.category === "acp" ? "acp" : "cli";
10166
10109
  let next = loadConfig();
10167
- console.log(import_chalk.default.cyan(` \u{1F4C2} Saving recent workspace: ${dir}`));
10110
+ console.log(colorize("cyan", ` \u{1F4C2} Saving recent workspace: ${dir}`));
10168
10111
  const recent = next.recentCliWorkspaces || [];
10169
10112
  if (!recent.includes(dir)) {
10170
10113
  next = { ...next, recentCliWorkspaces: [dir, ...recent].slice(0, 10) };
10171
10114
  }
10172
10115
  next = appendWorkspaceActivity(next, dir, { kind: actKind, agentType: normalizedType });
10173
10116
  saveConfig(next);
10174
- console.log(import_chalk.default.green(` \u2713 Recent workspace saved: ${dir}`));
10117
+ console.log(colorize("green", ` \u2713 Recent workspace saved: ${dir}`));
10175
10118
  } catch (e) {
10176
- console.error(import_chalk.default.red(` \u2717 Failed to save recent workspace: ${e}`));
10119
+ console.error(colorize("red", ` \u2717 Failed to save recent workspace: ${e}`));
10177
10120
  }
10178
10121
  }
10179
10122
  getTransportFactory(runtimeId, providerType, workspace, cliArgs, attachExisting = false) {
@@ -10189,7 +10132,7 @@ var DaemonCliManager = class {
10189
10132
  const normalizedType = this.providerLoader.resolveAlias(cliType);
10190
10133
  const provider = this.providerLoader.getMeta(normalizedType);
10191
10134
  if (provider && provider.category === "cli" && provider.patterns && provider.spawn) {
10192
- console.log(import_chalk.default.cyan(` \u{1F4E6} Using provider: ${provider.name} (${provider.type})`));
10135
+ console.log(colorize("cyan", ` \u{1F4E6} Using provider: ${provider.name} (${provider.type})`));
10193
10136
  const resolvedProvider = this.providerLoader.resolve(normalizedType) || provider;
10194
10137
  const transportFactory = this.getTransportFactory(runtimeId, normalizedType, workingDir, cliArgs, attachExisting);
10195
10138
  return new ProviderCliAdapter(resolvedProvider, workingDir, cliArgs, transportFactory);
@@ -10282,7 +10225,7 @@ ${installInfo}`
10282
10225
  );
10283
10226
  }
10284
10227
  }
10285
- console.log(import_chalk.default.cyan(` \u{1F50C} Starting ACP agent: ${provider.name} (${provider.type}) in ${resolvedDir}`));
10228
+ console.log(colorize("cyan", ` \u{1F50C} Starting ACP agent: ${provider.name} (${provider.type}) in ${resolvedDir}`));
10286
10229
  const acpInstance = new AcpProviderInstance(provider, resolvedDir, cliArgs);
10287
10230
  await instanceManager2.addInstance(key, acpInstance, {
10288
10231
  settings: this.providerLoader.getSettings(normalizedType)
@@ -10322,11 +10265,11 @@ ${installInfo}`
10322
10265
  setOnPtyData: () => {
10323
10266
  }
10324
10267
  });
10325
- console.log(import_chalk.default.green(` \u2713 ACP agent started: ${provider.name} in ${resolvedDir}`));
10268
+ console.log(colorize("green", ` \u2713 ACP agent started: ${provider.name} in ${resolvedDir}`));
10326
10269
  if (initialModel) {
10327
10270
  try {
10328
10271
  await acpInstance.setConfigOption("model", initialModel);
10329
- console.log(import_chalk.default.green(` \u{1F916} Initial model set: ${initialModel}`));
10272
+ console.log(colorize("green", ` \u{1F916} Initial model set: ${initialModel}`));
10330
10273
  } catch (e) {
10331
10274
  LOG.warn("CLI", `[ACP] Initial model set failed: ${e?.message}`);
10332
10275
  }
@@ -10341,9 +10284,9 @@ ${installInfo}`
10341
10284
  }
10342
10285
  const cliInfo = await detectCLI(cliType, this.providerLoader);
10343
10286
  if (!cliInfo) throw new Error(`${cliType} not found`);
10344
- console.log(import_chalk.default.yellow(` \u26A1 Starting CLI ${cliType} in ${resolvedDir}...`));
10287
+ console.log(colorize("yellow", ` \u26A1 Starting CLI ${cliType} in ${resolvedDir}...`));
10345
10288
  if (provider) {
10346
- console.log(import_chalk.default.cyan(` \u{1F4E6} Using provider: ${provider.name} (${provider.type})`));
10289
+ console.log(colorize("cyan", ` \u{1F4E6} Using provider: ${provider.name} (${provider.type})`));
10347
10290
  }
10348
10291
  const instanceManager = this.deps.getInstanceManager();
10349
10292
  if (provider && instanceManager) {
@@ -10358,7 +10301,7 @@ ${installInfo}`
10358
10301
  {},
10359
10302
  false
10360
10303
  );
10361
- console.log(import_chalk.default.green(` \u2713 CLI started: ${cliInfo.displayName} v${cliInfo.version || "unknown"} in ${resolvedDir}`));
10304
+ console.log(colorize("green", ` \u2713 CLI started: ${cliInfo.displayName} v${cliInfo.version || "unknown"} in ${resolvedDir}`));
10362
10305
  } else {
10363
10306
  const adapter = this.createAdapter(cliType, resolvedDir, cliArgs, key, false);
10364
10307
  try {
@@ -10391,7 +10334,7 @@ ${installInfo}`
10391
10334
  });
10392
10335
  }
10393
10336
  this.adapters.set(key, adapter);
10394
- console.log(import_chalk.default.green(` \u2713 CLI started: ${cliInfo.displayName} v${cliInfo.version || "unknown"} in ${resolvedDir}`));
10337
+ console.log(colorize("green", ` \u2713 CLI started: ${cliInfo.displayName} v${cliInfo.version || "unknown"} in ${resolvedDir}`));
10395
10338
  }
10396
10339
  try {
10397
10340
  addCliHistory({ category: "cli", cliType, dir: resolvedDir, workspace: resolvedDir, cliArgs, model: initialModel });
@@ -10553,7 +10496,7 @@ ${installInfo}`
10553
10496
  if (found) {
10554
10497
  await this.stopSessionWithMode(found.key, mode);
10555
10498
  } else {
10556
- console.log(import_chalk.default.yellow(` \u26A0 No adapter found for ${cliType}`));
10499
+ console.log(colorize("yellow", ` \u26A0 No adapter found for ${cliType}`));
10557
10500
  }
10558
10501
  return { success: true, cliType, dir, stopped: true, mode };
10559
10502
  }