@adhdev/daemon-core 0.5.37 → 0.5.40
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.d.ts +3 -0
- package/dist/index.js +58 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/agent-stream/provider-adapter.ts +1 -0
- package/src/agent-stream/types.ts +1 -0
- package/src/commands/stream-commands.ts +37 -4
- package/src/daemon/dev-server.ts +20 -6
- package/src/providers/extension-provider-instance.ts +6 -0
- package/src/status/reporter.ts +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1458,6 +1458,7 @@ interface AgentStreamState {
|
|
|
1458
1458
|
messages: AgentChatMessage[];
|
|
1459
1459
|
inputContent: string;
|
|
1460
1460
|
model?: string;
|
|
1461
|
+
mode?: string;
|
|
1461
1462
|
activeModal?: {
|
|
1462
1463
|
message: string;
|
|
1463
1464
|
buttons: string[];
|
|
@@ -1783,6 +1784,8 @@ declare class ExtensionProviderInstance implements ProviderInstance {
|
|
|
1783
1784
|
private agentStreams;
|
|
1784
1785
|
private messages;
|
|
1785
1786
|
private activeModal;
|
|
1787
|
+
private currentModel;
|
|
1788
|
+
private currentMode;
|
|
1786
1789
|
private lastAgentStatus;
|
|
1787
1790
|
private generatingStartedAt;
|
|
1788
1791
|
private monitor;
|
package/dist/index.js
CHANGED
|
@@ -2160,6 +2160,8 @@ var ExtensionProviderInstance = class {
|
|
|
2160
2160
|
agentStreams = [];
|
|
2161
2161
|
messages = [];
|
|
2162
2162
|
activeModal = null;
|
|
2163
|
+
currentModel = "";
|
|
2164
|
+
currentMode = "";
|
|
2163
2165
|
lastAgentStatus = "idle";
|
|
2164
2166
|
generatingStartedAt = 0;
|
|
2165
2167
|
monitor;
|
|
@@ -2199,6 +2201,8 @@ var ExtensionProviderInstance = class {
|
|
|
2199
2201
|
activeModal: this.activeModal,
|
|
2200
2202
|
inputContent: ""
|
|
2201
2203
|
} : null,
|
|
2204
|
+
currentModel: this.currentModel || void 0,
|
|
2205
|
+
currentPlan: this.currentMode || void 0,
|
|
2202
2206
|
agentStreams: this.agentStreams,
|
|
2203
2207
|
instanceId: this.instanceId,
|
|
2204
2208
|
lastUpdated: Date.now(),
|
|
@@ -2211,6 +2215,8 @@ var ExtensionProviderInstance = class {
|
|
|
2211
2215
|
if (data?.streams) this.agentStreams = data.streams;
|
|
2212
2216
|
if (data?.messages) this.messages = data.messages;
|
|
2213
2217
|
if (data?.activeModal !== void 0) this.activeModal = data.activeModal;
|
|
2218
|
+
if (data?.model) this.currentModel = data.model;
|
|
2219
|
+
if (data?.mode) this.currentMode = data.mode;
|
|
2214
2220
|
if (data?.status) {
|
|
2215
2221
|
const newStatus = data.status;
|
|
2216
2222
|
this.detectTransition(newStatus, data);
|
|
@@ -4359,7 +4365,13 @@ async function handleExtensionScript(h, args, scriptName) {
|
|
|
4359
4365
|
return { success: false, error: `Script '${actualScriptName}' not available for ${agentType}` };
|
|
4360
4366
|
}
|
|
4361
4367
|
const scriptFn = provider.scripts[actualScriptName];
|
|
4362
|
-
const
|
|
4368
|
+
const normalizedArgs = { ...args };
|
|
4369
|
+
for (const key of ["mode", "model", "message", "action", "button", "text", "sessionId"]) {
|
|
4370
|
+
if (key in normalizedArgs && !(key.toUpperCase() in normalizedArgs)) {
|
|
4371
|
+
normalizedArgs[key.toUpperCase()] = normalizedArgs[key];
|
|
4372
|
+
}
|
|
4373
|
+
}
|
|
4374
|
+
const scriptCode = scriptFn(normalizedArgs);
|
|
4363
4375
|
if (!scriptCode) return { success: false, error: `Script '${actualScriptName}' returned null` };
|
|
4364
4376
|
const cdpKey = provider.category === "ide" ? h.currentIdeType || agentType : h.currentIdeType || ideType;
|
|
4365
4377
|
LOG.info("Command", `[ExtScript] provider=${provider.type} category=${provider.category} cdpKey=${cdpKey}`);
|
|
@@ -4376,10 +4388,31 @@ async function handleExtensionScript(h, args, scriptName) {
|
|
|
4376
4388
|
break;
|
|
4377
4389
|
}
|
|
4378
4390
|
}
|
|
4379
|
-
|
|
4380
|
-
|
|
4391
|
+
const IDE_LEVEL_SCRIPTS = ["listModes", "setMode", "listModels", "setModel"];
|
|
4392
|
+
if (IDE_LEVEL_SCRIPTS.includes(scriptName)) {
|
|
4393
|
+
if (targetSessionId) {
|
|
4394
|
+
try {
|
|
4395
|
+
result = await cdp.evaluateInSessionFrame(targetSessionId, scriptCode);
|
|
4396
|
+
const parsed = typeof result === "string" ? JSON.parse(result) : result;
|
|
4397
|
+
const notFound = parsed?.error?.includes("not found") || parsed?.error?.includes("no root");
|
|
4398
|
+
if (notFound) {
|
|
4399
|
+
LOG.info("Command", `[ExtScript] ${scriptName} not found in session frame \u2192 trying IDE main page`);
|
|
4400
|
+
result = await cdp.evaluate(scriptCode, 3e4);
|
|
4401
|
+
}
|
|
4402
|
+
} catch {
|
|
4403
|
+
LOG.info("Command", `[ExtScript] ${scriptName} session frame failed \u2192 trying IDE main page`);
|
|
4404
|
+
result = await cdp.evaluate(scriptCode, 3e4);
|
|
4405
|
+
}
|
|
4406
|
+
} else {
|
|
4407
|
+
LOG.info("Command", `[ExtScript] ${scriptName} no session \u2192 trying IDE main page`);
|
|
4408
|
+
result = await cdp.evaluate(scriptCode, 3e4);
|
|
4409
|
+
}
|
|
4410
|
+
} else {
|
|
4411
|
+
if (!targetSessionId) {
|
|
4412
|
+
return { success: false, error: `No active session found for ${agentType}` };
|
|
4413
|
+
}
|
|
4414
|
+
result = await cdp.evaluateInSessionFrame(targetSessionId, scriptCode);
|
|
4381
4415
|
}
|
|
4382
|
-
result = await cdp.evaluateInSessionFrame(targetSessionId, scriptCode);
|
|
4383
4416
|
} else if (hasWebviewScript && cdp.evaluateInWebviewFrame) {
|
|
4384
4417
|
const matchText = provider.webviewMatchText;
|
|
4385
4418
|
const matchFn = matchText ? (body) => body.includes(matchText) : void 0;
|
|
@@ -8900,6 +8933,7 @@ var ProviderStreamAdapter = class {
|
|
|
8900
8933
|
messages: data.messages || [],
|
|
8901
8934
|
inputContent: data.inputContent || "",
|
|
8902
8935
|
model: data.model,
|
|
8936
|
+
mode: data.mode,
|
|
8903
8937
|
activeModal: data.activeModal
|
|
8904
8938
|
};
|
|
8905
8939
|
if (state.messages.length > 0) {
|
|
@@ -10249,14 +10283,29 @@ var DevServer = class _DevServer {
|
|
|
10249
10283
|
return;
|
|
10250
10284
|
}
|
|
10251
10285
|
this.log(`Exec script length: ${scriptCode.length}, first 50 chars: ${scriptCode.slice(0, 50)}...`);
|
|
10252
|
-
const isWebviewScript =
|
|
10286
|
+
const isWebviewScript = scriptName.toLowerCase().includes("webview");
|
|
10253
10287
|
let raw;
|
|
10254
|
-
if (isWebviewScript) {
|
|
10288
|
+
if (provider.category === "extension" && !isWebviewScript) {
|
|
10289
|
+
const sessions = cdp.getAgentSessions();
|
|
10290
|
+
let sessionId = null;
|
|
10291
|
+
for (const [sid, target] of sessions) {
|
|
10292
|
+
if (target.agentType === type) {
|
|
10293
|
+
sessionId = sid;
|
|
10294
|
+
break;
|
|
10295
|
+
}
|
|
10296
|
+
}
|
|
10297
|
+
if (sessionId) {
|
|
10298
|
+
raw = await cdp.evaluateInSessionFrame(sessionId, scriptCode);
|
|
10299
|
+
} else if (cdp.evaluateInWebviewFrame) {
|
|
10300
|
+
const matchText = provider.webviewMatchText;
|
|
10301
|
+
const matchFn = matchText ? (body2) => body2.includes(matchText) : void 0;
|
|
10302
|
+
raw = await cdp.evaluateInWebviewFrame(scriptCode, matchFn);
|
|
10303
|
+
} else {
|
|
10304
|
+
raw = await cdp.evaluate(scriptCode, 3e4);
|
|
10305
|
+
}
|
|
10306
|
+
} else if (isWebviewScript && cdp.evaluateInWebviewFrame) {
|
|
10255
10307
|
const matchText = provider.webviewMatchText;
|
|
10256
10308
|
const matchFn = matchText ? (body2) => body2.includes(matchText) : void 0;
|
|
10257
|
-
if (!cdp.evaluateInWebviewFrame) {
|
|
10258
|
-
throw new Error(`CDP manager does not support evaluateInWebviewFrame`);
|
|
10259
|
-
}
|
|
10260
10309
|
raw = await cdp.evaluateInWebviewFrame(scriptCode, matchFn);
|
|
10261
10310
|
} else {
|
|
10262
10311
|
raw = await cdp.evaluate(scriptCode, 3e4);
|