@adhdev/daemon-core 0.7.15 → 0.7.17
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 +19 -76
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +19 -76
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/cli-adapters/provider-cli-adapter.ts +9 -74
- package/src/commands/cli-manager.ts +21 -12
package/dist/index.mjs
CHANGED
|
@@ -1346,31 +1346,14 @@ var init_provider_cli_adapter = __esm({
|
|
|
1346
1346
|
this.accumulatedRawBuffer = (this.accumulatedRawBuffer + rawData).slice(-_ProviderCliAdapter.MAX_ACCUMULATED_BUFFER);
|
|
1347
1347
|
if (this.startupParseGate) {
|
|
1348
1348
|
this.startupBuffer += cleanData;
|
|
1349
|
-
const dialogPatterns = [
|
|
1350
|
-
/Do you want to connect/i,
|
|
1351
|
-
/Do you trust the files/i,
|
|
1352
|
-
/Quick safety check/i,
|
|
1353
|
-
/Is this a project/i,
|
|
1354
|
-
/Enter to confirm/i,
|
|
1355
|
-
/be able to read, edit, and execute/i,
|
|
1356
|
-
/Security guide/i
|
|
1357
|
-
];
|
|
1358
|
-
if (dialogPatterns.some((p) => p.test(this.startupBuffer))) {
|
|
1359
|
-
setTimeout(() => this.ptyProcess?.write("\r"), this.timeouts.dialogAccept);
|
|
1360
|
-
this.startupBuffer = "";
|
|
1361
|
-
return;
|
|
1362
|
-
}
|
|
1363
1349
|
const elapsed = Date.now() - this.spawnAt;
|
|
1364
|
-
const bufCap = this.startupBuffer.length > 12e3;
|
|
1365
1350
|
const scriptStatus = this.runDetectStatus(this.startupBuffer);
|
|
1366
|
-
const isReady = scriptStatus === "idle" || elapsed > 8e3 ||
|
|
1351
|
+
const isReady = scriptStatus === "idle" || scriptStatus === "waiting_approval" || elapsed > 8e3 || this.startupBuffer.length > 12e3;
|
|
1367
1352
|
if (isReady) {
|
|
1368
1353
|
this.startupParseGate = false;
|
|
1369
1354
|
this.ready = true;
|
|
1370
|
-
LOG.info("CLI", `[${this.cliType}] Startup
|
|
1355
|
+
LOG.info("CLI", `[${this.cliType}] Startup ready (${elapsed}ms, scriptStatus=${scriptStatus})`);
|
|
1371
1356
|
this.onStatusChange?.();
|
|
1372
|
-
} else {
|
|
1373
|
-
return;
|
|
1374
1357
|
}
|
|
1375
1358
|
}
|
|
1376
1359
|
this.scheduleSettle();
|
|
@@ -1578,51 +1561,6 @@ var init_provider_cli_adapter = __esm({
|
|
|
1578
1561
|
this.onStatusChange?.();
|
|
1579
1562
|
}
|
|
1580
1563
|
commitCurrentTranscript() {
|
|
1581
|
-
const baseMessages = [...this.committedMessages];
|
|
1582
|
-
const parsed = this.parseCurrentTranscript(baseMessages, "", this.currentTurnScope);
|
|
1583
|
-
if (parsed && Array.isArray(parsed.messages) && parsed.messages.length > 0) {
|
|
1584
|
-
const parsedMessages = parsed.messages.filter((m) => m && (m.role === "user" || m.role === "assistant")).map((m) => ({
|
|
1585
|
-
role: m.role,
|
|
1586
|
-
content: typeof m.content === "string" ? m.content : String(m.content || ""),
|
|
1587
|
-
timestamp: m.timestamp
|
|
1588
|
-
}));
|
|
1589
|
-
const latestAssistant = [...parsedMessages].reverse().find((m) => m.role === "assistant" && m.content.trim());
|
|
1590
|
-
if (latestAssistant) {
|
|
1591
|
-
LOG.info("CLI", `[${this.cliType}] commitCurrentTranscript parsed assistant len=${latestAssistant.content.length} scopePrompt=${JSON.stringify(this.currentTurnScope?.prompt || "").slice(0, 120)}`);
|
|
1592
|
-
const nextMessages = [...baseMessages];
|
|
1593
|
-
const last2 = nextMessages[nextMessages.length - 1];
|
|
1594
|
-
if (last2?.role === "assistant") {
|
|
1595
|
-
last2.content = latestAssistant.content;
|
|
1596
|
-
last2.timestamp = latestAssistant.timestamp || last2.timestamp;
|
|
1597
|
-
} else if (last2?.role === "user") {
|
|
1598
|
-
nextMessages.push({
|
|
1599
|
-
role: "assistant",
|
|
1600
|
-
content: latestAssistant.content,
|
|
1601
|
-
timestamp: latestAssistant.timestamp || Date.now()
|
|
1602
|
-
});
|
|
1603
|
-
} else {
|
|
1604
|
-
nextMessages.push({
|
|
1605
|
-
role: "assistant",
|
|
1606
|
-
content: latestAssistant.content,
|
|
1607
|
-
timestamp: latestAssistant.timestamp || Date.now()
|
|
1608
|
-
});
|
|
1609
|
-
}
|
|
1610
|
-
this.committedMessages = nextMessages;
|
|
1611
|
-
this.syncMessageViews();
|
|
1612
|
-
return;
|
|
1613
|
-
}
|
|
1614
|
-
}
|
|
1615
|
-
const fallback = String(this.responseBuffer || "").trim();
|
|
1616
|
-
LOG.info("CLI", `[${this.cliType}] commitCurrentTranscript fallback len=${fallback.length} scopePrompt=${JSON.stringify(this.currentTurnScope?.prompt || "").slice(0, 120)}`);
|
|
1617
|
-
if (!fallback) return;
|
|
1618
|
-
const last = baseMessages[baseMessages.length - 1];
|
|
1619
|
-
if (last?.role === "assistant") {
|
|
1620
|
-
last.content = fallback;
|
|
1621
|
-
} else {
|
|
1622
|
-
baseMessages.push({ role: "assistant", content: fallback, timestamp: Date.now() });
|
|
1623
|
-
}
|
|
1624
|
-
this.committedMessages = baseMessages;
|
|
1625
|
-
this.syncMessageViews();
|
|
1626
1564
|
}
|
|
1627
1565
|
// ─── Script Execution ──────────────────────────
|
|
1628
1566
|
runDetectStatus(text) {
|
|
@@ -10073,6 +10011,11 @@ var AcpProviderInstance = class {
|
|
|
10073
10011
|
|
|
10074
10012
|
// src/commands/cli-manager.ts
|
|
10075
10013
|
init_logger();
|
|
10014
|
+
var chalkApi = chalk?.yellow ? chalk : chalk?.default || null;
|
|
10015
|
+
function colorize(color, text) {
|
|
10016
|
+
const fn = chalkApi?.[color];
|
|
10017
|
+
return typeof fn === "function" ? fn(text) : text;
|
|
10018
|
+
}
|
|
10076
10019
|
var DaemonCliManager = class {
|
|
10077
10020
|
adapters = /* @__PURE__ */ new Map();
|
|
10078
10021
|
deps;
|
|
@@ -10092,16 +10035,16 @@ var DaemonCliManager = class {
|
|
|
10092
10035
|
const provider = this.providerLoader.getByAlias(cliType);
|
|
10093
10036
|
const actKind = provider?.category === "acp" ? "acp" : "cli";
|
|
10094
10037
|
let next = loadConfig();
|
|
10095
|
-
console.log(
|
|
10038
|
+
console.log(colorize("cyan", ` \u{1F4C2} Saving recent workspace: ${dir}`));
|
|
10096
10039
|
const recent = next.recentCliWorkspaces || [];
|
|
10097
10040
|
if (!recent.includes(dir)) {
|
|
10098
10041
|
next = { ...next, recentCliWorkspaces: [dir, ...recent].slice(0, 10) };
|
|
10099
10042
|
}
|
|
10100
10043
|
next = appendWorkspaceActivity(next, dir, { kind: actKind, agentType: normalizedType });
|
|
10101
10044
|
saveConfig(next);
|
|
10102
|
-
console.log(
|
|
10045
|
+
console.log(colorize("green", ` \u2713 Recent workspace saved: ${dir}`));
|
|
10103
10046
|
} catch (e) {
|
|
10104
|
-
console.error(
|
|
10047
|
+
console.error(colorize("red", ` \u2717 Failed to save recent workspace: ${e}`));
|
|
10105
10048
|
}
|
|
10106
10049
|
}
|
|
10107
10050
|
getTransportFactory(runtimeId, providerType, workspace, cliArgs, attachExisting = false) {
|
|
@@ -10117,7 +10060,7 @@ var DaemonCliManager = class {
|
|
|
10117
10060
|
const normalizedType = this.providerLoader.resolveAlias(cliType);
|
|
10118
10061
|
const provider = this.providerLoader.getMeta(normalizedType);
|
|
10119
10062
|
if (provider && provider.category === "cli" && provider.patterns && provider.spawn) {
|
|
10120
|
-
console.log(
|
|
10063
|
+
console.log(colorize("cyan", ` \u{1F4E6} Using provider: ${provider.name} (${provider.type})`));
|
|
10121
10064
|
const resolvedProvider = this.providerLoader.resolve(normalizedType) || provider;
|
|
10122
10065
|
const transportFactory = this.getTransportFactory(runtimeId, normalizedType, workingDir, cliArgs, attachExisting);
|
|
10123
10066
|
return new ProviderCliAdapter(resolvedProvider, workingDir, cliArgs, transportFactory);
|
|
@@ -10210,7 +10153,7 @@ ${installInfo}`
|
|
|
10210
10153
|
);
|
|
10211
10154
|
}
|
|
10212
10155
|
}
|
|
10213
|
-
console.log(
|
|
10156
|
+
console.log(colorize("cyan", ` \u{1F50C} Starting ACP agent: ${provider.name} (${provider.type}) in ${resolvedDir}`));
|
|
10214
10157
|
const acpInstance = new AcpProviderInstance(provider, resolvedDir, cliArgs);
|
|
10215
10158
|
await instanceManager2.addInstance(key, acpInstance, {
|
|
10216
10159
|
settings: this.providerLoader.getSettings(normalizedType)
|
|
@@ -10250,11 +10193,11 @@ ${installInfo}`
|
|
|
10250
10193
|
setOnPtyData: () => {
|
|
10251
10194
|
}
|
|
10252
10195
|
});
|
|
10253
|
-
console.log(
|
|
10196
|
+
console.log(colorize("green", ` \u2713 ACP agent started: ${provider.name} in ${resolvedDir}`));
|
|
10254
10197
|
if (initialModel) {
|
|
10255
10198
|
try {
|
|
10256
10199
|
await acpInstance.setConfigOption("model", initialModel);
|
|
10257
|
-
console.log(
|
|
10200
|
+
console.log(colorize("green", ` \u{1F916} Initial model set: ${initialModel}`));
|
|
10258
10201
|
} catch (e) {
|
|
10259
10202
|
LOG.warn("CLI", `[ACP] Initial model set failed: ${e?.message}`);
|
|
10260
10203
|
}
|
|
@@ -10269,9 +10212,9 @@ ${installInfo}`
|
|
|
10269
10212
|
}
|
|
10270
10213
|
const cliInfo = await detectCLI(cliType, this.providerLoader);
|
|
10271
10214
|
if (!cliInfo) throw new Error(`${cliType} not found`);
|
|
10272
|
-
console.log(
|
|
10215
|
+
console.log(colorize("yellow", ` \u26A1 Starting CLI ${cliType} in ${resolvedDir}...`));
|
|
10273
10216
|
if (provider) {
|
|
10274
|
-
console.log(
|
|
10217
|
+
console.log(colorize("cyan", ` \u{1F4E6} Using provider: ${provider.name} (${provider.type})`));
|
|
10275
10218
|
}
|
|
10276
10219
|
const instanceManager = this.deps.getInstanceManager();
|
|
10277
10220
|
if (provider && instanceManager) {
|
|
@@ -10286,7 +10229,7 @@ ${installInfo}`
|
|
|
10286
10229
|
{},
|
|
10287
10230
|
false
|
|
10288
10231
|
);
|
|
10289
|
-
console.log(
|
|
10232
|
+
console.log(colorize("green", ` \u2713 CLI started: ${cliInfo.displayName} v${cliInfo.version || "unknown"} in ${resolvedDir}`));
|
|
10290
10233
|
} else {
|
|
10291
10234
|
const adapter = this.createAdapter(cliType, resolvedDir, cliArgs, key, false);
|
|
10292
10235
|
try {
|
|
@@ -10319,7 +10262,7 @@ ${installInfo}`
|
|
|
10319
10262
|
});
|
|
10320
10263
|
}
|
|
10321
10264
|
this.adapters.set(key, adapter);
|
|
10322
|
-
console.log(
|
|
10265
|
+
console.log(colorize("green", ` \u2713 CLI started: ${cliInfo.displayName} v${cliInfo.version || "unknown"} in ${resolvedDir}`));
|
|
10323
10266
|
}
|
|
10324
10267
|
try {
|
|
10325
10268
|
addCliHistory({ category: "cli", cliType, dir: resolvedDir, workspace: resolvedDir, cliArgs, model: initialModel });
|
|
@@ -10481,7 +10424,7 @@ ${installInfo}`
|
|
|
10481
10424
|
if (found) {
|
|
10482
10425
|
await this.stopSessionWithMode(found.key, mode);
|
|
10483
10426
|
} else {
|
|
10484
|
-
console.log(
|
|
10427
|
+
console.log(colorize("yellow", ` \u26A0 No adapter found for ${cliType}`));
|
|
10485
10428
|
}
|
|
10486
10429
|
return { success: true, cliType, dir, stopped: true, mode };
|
|
10487
10430
|
}
|