@adhdev/daemon-standalone 0.8.69 → 0.8.71
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 +282 -64
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/public/assets/index-DN14XOgk.js +72 -0
- package/public/index.html +1 -1
- package/public/assets/index-o8G46TAp.js +0 -72
package/dist/index.js
CHANGED
|
@@ -28720,6 +28720,7 @@ var require_dist2 = __commonJS({
|
|
|
28720
28720
|
if (isFiniteNumber(message.index)) normalized.index = message.index;
|
|
28721
28721
|
if (isFiniteNumber(message.timestamp)) normalized.timestamp = message.timestamp;
|
|
28722
28722
|
if (isFiniteNumber(message.receivedAt)) normalized.receivedAt = message.receivedAt;
|
|
28723
|
+
if (typeof message._turnKey === "string") normalized._turnKey = message._turnKey;
|
|
28723
28724
|
if (Array.isArray(message.toolCalls)) normalized.toolCalls = message.toolCalls;
|
|
28724
28725
|
if (isPlainObject3(message.meta)) normalized.meta = message.meta;
|
|
28725
28726
|
if (typeof message.senderName === "string") normalized.senderName = message.senderName;
|
|
@@ -30869,7 +30870,9 @@ ${data.message || ""}`.trim();
|
|
|
30869
30870
|
}
|
|
30870
30871
|
}
|
|
30871
30872
|
if (!this.ready) throw new Error(`${this.cliName} not ready (status: ${this.currentStatus})`);
|
|
30872
|
-
if (this.isWaitingForResponse)
|
|
30873
|
+
if (this.isWaitingForResponse) {
|
|
30874
|
+
throw new Error(`${this.cliName} is still processing the previous prompt`);
|
|
30875
|
+
}
|
|
30873
30876
|
const blockingModal = this.activeModal || this.getStartupConfirmationModal(this.terminalScreen.getText() || "");
|
|
30874
30877
|
if (blockingModal || this.currentStatus === "waiting_approval") {
|
|
30875
30878
|
throw new Error(`${this.cliName} is awaiting confirmation before it can accept a prompt`);
|
|
@@ -31778,27 +31781,37 @@ ${data.message || ""}`.trim();
|
|
|
31778
31781
|
})
|
|
31779
31782
|
})).sort((a, b2) => b2.lastUsedAt - a.lastUsedAt).slice(0, limit);
|
|
31780
31783
|
}
|
|
31781
|
-
function
|
|
31782
|
-
|
|
31784
|
+
function buildSessionReadStateKey(sessionId, providerSessionId) {
|
|
31785
|
+
const normalizedProviderSessionId = typeof providerSessionId === "string" ? providerSessionId.trim() : "";
|
|
31786
|
+
if (normalizedProviderSessionId) return `provider:${normalizedProviderSessionId}`;
|
|
31787
|
+
return sessionId;
|
|
31788
|
+
}
|
|
31789
|
+
function getSessionSeenAt(state, sessionId, providerSessionId) {
|
|
31790
|
+
const providerKey = buildSessionReadStateKey(sessionId, providerSessionId);
|
|
31791
|
+
return state.sessionReads?.[providerKey] || state.sessionReads?.[sessionId] || 0;
|
|
31783
31792
|
}
|
|
31784
|
-
function getSessionSeenMarker(state, sessionId) {
|
|
31785
|
-
|
|
31793
|
+
function getSessionSeenMarker(state, sessionId, providerSessionId) {
|
|
31794
|
+
const providerKey = buildSessionReadStateKey(sessionId, providerSessionId);
|
|
31795
|
+
return state.sessionReadMarkers?.[providerKey] || state.sessionReadMarkers?.[sessionId] || "";
|
|
31786
31796
|
}
|
|
31787
|
-
function markSessionSeen(state, sessionId, seenAt = Date.now(), completionMarker) {
|
|
31797
|
+
function markSessionSeen(state, sessionId, seenAt = Date.now(), completionMarker, providerSessionId) {
|
|
31788
31798
|
const prev = state.sessionReads || {};
|
|
31789
|
-
const nextSeenAt = Math.max(prev[sessionId] || 0, seenAt);
|
|
31790
31799
|
const prevMarkers = state.sessionReadMarkers || {};
|
|
31791
31800
|
const nextMarker = typeof completionMarker === "string" ? completionMarker : "";
|
|
31801
|
+
const readKeys = Array.from(new Set([
|
|
31802
|
+
sessionId,
|
|
31803
|
+
buildSessionReadStateKey(sessionId, providerSessionId)
|
|
31804
|
+
].filter(Boolean)));
|
|
31805
|
+
const nextSessionReads = { ...prev };
|
|
31806
|
+
const nextSessionReadMarkers = { ...prevMarkers };
|
|
31807
|
+
for (const key of readKeys) {
|
|
31808
|
+
nextSessionReads[key] = Math.max(prev[key] || 0, seenAt);
|
|
31809
|
+
if (nextMarker) nextSessionReadMarkers[key] = nextMarker;
|
|
31810
|
+
}
|
|
31792
31811
|
return {
|
|
31793
31812
|
...state,
|
|
31794
|
-
sessionReads:
|
|
31795
|
-
|
|
31796
|
-
[sessionId]: nextSeenAt
|
|
31797
|
-
},
|
|
31798
|
-
sessionReadMarkers: nextMarker ? {
|
|
31799
|
-
...prevMarkers,
|
|
31800
|
-
[sessionId]: nextMarker
|
|
31801
|
-
} : prevMarkers
|
|
31813
|
+
sessionReads: nextSessionReads,
|
|
31814
|
+
sessionReadMarkers: nextMarker ? nextSessionReadMarkers : prevMarkers
|
|
31802
31815
|
};
|
|
31803
31816
|
}
|
|
31804
31817
|
var path32 = __toESM2(require("path"));
|
|
@@ -34368,6 +34381,35 @@ ${cleanBody}`;
|
|
|
34368
34381
|
};
|
|
34369
34382
|
}
|
|
34370
34383
|
init_chat_message_normalization();
|
|
34384
|
+
var IDE_PROVIDER_SESSION_CAPABILITIES_BASE = [
|
|
34385
|
+
"read_chat",
|
|
34386
|
+
"send_message",
|
|
34387
|
+
"new_session",
|
|
34388
|
+
"list_sessions",
|
|
34389
|
+
"switch_session",
|
|
34390
|
+
"resolve_action",
|
|
34391
|
+
"change_model",
|
|
34392
|
+
"set_mode",
|
|
34393
|
+
"set_thought_level"
|
|
34394
|
+
];
|
|
34395
|
+
var EXTENSION_PROVIDER_SESSION_CAPABILITIES_BASE = [
|
|
34396
|
+
"read_chat",
|
|
34397
|
+
"send_message",
|
|
34398
|
+
"new_session",
|
|
34399
|
+
"list_sessions",
|
|
34400
|
+
"switch_session",
|
|
34401
|
+
"resolve_action",
|
|
34402
|
+
"change_model",
|
|
34403
|
+
"set_mode"
|
|
34404
|
+
];
|
|
34405
|
+
function providerHasOpenPanelSupport(provider) {
|
|
34406
|
+
if (typeof provider.scripts?.openPanel === "function") return true;
|
|
34407
|
+
if (provider.category === "ide" && typeof provider.scripts?.webviewOpenPanel === "function") return true;
|
|
34408
|
+
return false;
|
|
34409
|
+
}
|
|
34410
|
+
function getProviderSessionCapabilities(provider, baseCapabilities) {
|
|
34411
|
+
return providerHasOpenPanelSupport(provider) ? [...baseCapabilities, "open_panel"] : [...baseCapabilities];
|
|
34412
|
+
}
|
|
34371
34413
|
var ExtensionProviderInstance = class {
|
|
34372
34414
|
type;
|
|
34373
34415
|
category = "extension";
|
|
@@ -34393,6 +34435,7 @@ ${cleanBody}`;
|
|
|
34393
34435
|
instanceId;
|
|
34394
34436
|
ideType = "";
|
|
34395
34437
|
chatId = null;
|
|
34438
|
+
providerSessionId = null;
|
|
34396
34439
|
chatTitle = null;
|
|
34397
34440
|
agentName = "";
|
|
34398
34441
|
extensionId = "";
|
|
@@ -34426,8 +34469,10 @@ ${cleanBody}`;
|
|
|
34426
34469
|
name: this.provider.name,
|
|
34427
34470
|
category: "extension",
|
|
34428
34471
|
status: this.currentStatus,
|
|
34472
|
+
providerSessionId: this.providerSessionId || this.chatId || void 0,
|
|
34473
|
+
sessionCapabilities: getProviderSessionCapabilities(this.provider, EXTENSION_PROVIDER_SESSION_CAPABILITIES_BASE),
|
|
34429
34474
|
activeChat: this.messages.length > 0 || this.runtimeMessages.length > 0 ? {
|
|
34430
|
-
id: this.chatId || this.instanceId,
|
|
34475
|
+
id: this.providerSessionId || this.chatId || this.instanceId,
|
|
34431
34476
|
title: this.chatTitle || this.agentName || this.provider.name,
|
|
34432
34477
|
status: this.currentStatus,
|
|
34433
34478
|
messages: this.mergeConversationMessages(this.messages),
|
|
@@ -34457,7 +34502,11 @@ ${cleanBody}`;
|
|
|
34457
34502
|
});
|
|
34458
34503
|
this.controlValues = patchedState.controlValues;
|
|
34459
34504
|
this.summaryMetadata = patchedState.summaryMetadata;
|
|
34460
|
-
|
|
34505
|
+
const nextProviderSessionId = typeof data?.providerSessionId === "string" && data.providerSessionId.trim() ? data.providerSessionId.trim() : typeof data?.sessionId === "string" && data.sessionId.trim() ? data.sessionId.trim() : "";
|
|
34506
|
+
if (nextProviderSessionId) {
|
|
34507
|
+
this.providerSessionId = nextProviderSessionId;
|
|
34508
|
+
this.chatId = nextProviderSessionId;
|
|
34509
|
+
}
|
|
34461
34510
|
if (typeof data?.title === "string" && data.title.trim()) this.chatTitle = data.title;
|
|
34462
34511
|
if (typeof data?.agentName === "string" && data.agentName.trim()) this.agentName = data.agentName;
|
|
34463
34512
|
if (typeof data?.extensionId === "string" && data.extensionId.trim()) this.extensionId = data.extensionId;
|
|
@@ -34743,6 +34792,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
34743
34792
|
this.controlValues = {};
|
|
34744
34793
|
this.currentStatus = "idle";
|
|
34745
34794
|
this.chatId = null;
|
|
34795
|
+
this.providerSessionId = null;
|
|
34746
34796
|
this.chatTitle = null;
|
|
34747
34797
|
this.agentName = "";
|
|
34748
34798
|
this.extensionId = "";
|
|
@@ -34891,6 +34941,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
34891
34941
|
workspace: this.workspace || null,
|
|
34892
34942
|
extensions: extensionStates,
|
|
34893
34943
|
cdpConnected: cdp?.isConnected || false,
|
|
34944
|
+
sessionCapabilities: getProviderSessionCapabilities(this.provider, IDE_PROVIDER_SESSION_CAPABILITIES_BASE),
|
|
34894
34945
|
controlValues: surface.controlValues,
|
|
34895
34946
|
providerControls: this.provider.controls,
|
|
34896
34947
|
summaryMetadata: surface.summaryMetadata,
|
|
@@ -35907,27 +35958,8 @@ ${effect.notification.body || ""}`.trim();
|
|
|
35907
35958
|
}
|
|
35908
35959
|
return false;
|
|
35909
35960
|
}
|
|
35910
|
-
var IDE_SESSION_CAPABILITIES = [
|
|
35911
|
-
|
|
35912
|
-
"send_message",
|
|
35913
|
-
"new_session",
|
|
35914
|
-
"list_sessions",
|
|
35915
|
-
"switch_session",
|
|
35916
|
-
"resolve_action",
|
|
35917
|
-
"change_model",
|
|
35918
|
-
"set_mode",
|
|
35919
|
-
"set_thought_level"
|
|
35920
|
-
];
|
|
35921
|
-
var EXTENSION_SESSION_CAPABILITIES = [
|
|
35922
|
-
"read_chat",
|
|
35923
|
-
"send_message",
|
|
35924
|
-
"new_session",
|
|
35925
|
-
"list_sessions",
|
|
35926
|
-
"switch_session",
|
|
35927
|
-
"resolve_action",
|
|
35928
|
-
"change_model",
|
|
35929
|
-
"set_mode"
|
|
35930
|
-
];
|
|
35961
|
+
var IDE_SESSION_CAPABILITIES = [...IDE_PROVIDER_SESSION_CAPABILITIES_BASE];
|
|
35962
|
+
var EXTENSION_SESSION_CAPABILITIES = [...EXTENSION_PROVIDER_SESSION_CAPABILITIES_BASE];
|
|
35931
35963
|
var PTY_SESSION_CAPABILITIES = [
|
|
35932
35964
|
"read_chat",
|
|
35933
35965
|
"send_message",
|
|
@@ -35971,7 +36003,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
35971
36003
|
...includeSessionMetadata && { workspace: state.workspace || null },
|
|
35972
36004
|
activeChat,
|
|
35973
36005
|
...summaryMetadata && { summaryMetadata },
|
|
35974
|
-
...includeSessionMetadata && { capabilities: IDE_SESSION_CAPABILITIES },
|
|
36006
|
+
...includeSessionMetadata && { capabilities: state.sessionCapabilities || IDE_SESSION_CAPABILITIES },
|
|
35975
36007
|
cdpConnected: state.cdpConnected ?? isCdpConnected(cdpManagers, state.type),
|
|
35976
36008
|
...includeSessionControls && {
|
|
35977
36009
|
...controlValues && { controlValues },
|
|
@@ -35994,6 +36026,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
35994
36026
|
parentId: parent.instanceId || parent.type,
|
|
35995
36027
|
providerType: ext.type,
|
|
35996
36028
|
...includeSessionMetadata && { providerName: ext.name },
|
|
36029
|
+
providerSessionId: ext.providerSessionId,
|
|
35997
36030
|
kind: "agent",
|
|
35998
36031
|
transport: "cdp-webview",
|
|
35999
36032
|
status: normalizeManagedStatus(activeChat?.status || ext.status, {
|
|
@@ -36003,7 +36036,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
36003
36036
|
...includeSessionMetadata && { workspace: parent.workspace || null },
|
|
36004
36037
|
activeChat,
|
|
36005
36038
|
...summaryMetadata && { summaryMetadata },
|
|
36006
|
-
...includeSessionMetadata && { capabilities: EXTENSION_SESSION_CAPABILITIES },
|
|
36039
|
+
...includeSessionMetadata && { capabilities: ext.sessionCapabilities || EXTENSION_SESSION_CAPABILITIES },
|
|
36007
36040
|
...includeSessionControls && {
|
|
36008
36041
|
...controlValues && { controlValues },
|
|
36009
36042
|
providerControls: ext.providerControls
|
|
@@ -37895,13 +37928,75 @@ ${effect.notification.body || ""}`.trim();
|
|
|
37895
37928
|
const mode = instance.getPresentationMode?.();
|
|
37896
37929
|
return mode === "chat" || mode === "terminal" ? mode : null;
|
|
37897
37930
|
}
|
|
37898
|
-
|
|
37931
|
+
function normalizeOpenPanelCommandResult(result) {
|
|
37932
|
+
const payload = Object.prototype.hasOwnProperty.call(result, "result") ? result.result : result;
|
|
37933
|
+
if (payload === true) return { opened: true, visible: true, focused: false };
|
|
37934
|
+
if (!payload) return { opened: false, visible: false, focused: false };
|
|
37935
|
+
if (typeof payload === "string") {
|
|
37936
|
+
const normalized = payload.trim().toLowerCase();
|
|
37937
|
+
if (normalized === "visible") return { opened: false, visible: true, focused: false };
|
|
37938
|
+
if (normalized === "focused") return { opened: false, visible: true, focused: true };
|
|
37939
|
+
if (normalized === "opened" || normalized === "open" || normalized === "true" || normalized === "ok" || normalized === "success") {
|
|
37940
|
+
return { opened: true, visible: true, focused: false };
|
|
37941
|
+
}
|
|
37942
|
+
return { opened: false, visible: false, focused: false };
|
|
37943
|
+
}
|
|
37944
|
+
if (typeof payload === "object") {
|
|
37945
|
+
const record2 = payload;
|
|
37946
|
+
return {
|
|
37947
|
+
opened: record2.opened === true,
|
|
37948
|
+
visible: record2.visible === true || record2.opened === true || record2.focused === true,
|
|
37949
|
+
focused: record2.focused === true
|
|
37950
|
+
};
|
|
37951
|
+
}
|
|
37952
|
+
return { opened: false, visible: false, focused: false };
|
|
37953
|
+
}
|
|
37954
|
+
function normalizeFocusEditorCommandResult(result) {
|
|
37955
|
+
const payload = Object.prototype.hasOwnProperty.call(result, "result") ? result.result : result;
|
|
37956
|
+
if (payload === true) return { focused: true };
|
|
37957
|
+
if (!payload) return { focused: false };
|
|
37958
|
+
if (typeof payload === "string") {
|
|
37959
|
+
const normalized = payload.trim().toLowerCase();
|
|
37960
|
+
return { focused: normalized === "focused" || normalized === "visible" || normalized === "true" || normalized === "ok" || normalized === "success" };
|
|
37961
|
+
}
|
|
37962
|
+
if (typeof payload === "object") {
|
|
37963
|
+
const record2 = payload;
|
|
37964
|
+
return { focused: record2.focused === true || record2.visible === true || record2.success === true || record2.ok === true };
|
|
37965
|
+
}
|
|
37966
|
+
return { focused: false };
|
|
37967
|
+
}
|
|
37968
|
+
async function handleSelectSession(h, args) {
|
|
37899
37969
|
if (!h.agentStream || !h.getCdp()) return { success: false, error: "AgentStream or CDP not available" };
|
|
37900
37970
|
const sessionId = args?.targetSessionId || h.currentSession?.sessionId;
|
|
37901
37971
|
if (!sessionId) return { success: false, error: "targetSessionId required" };
|
|
37902
|
-
const ok = await h.agentStream.
|
|
37972
|
+
const ok = await h.agentStream.selectSession(h.getCdp(), sessionId);
|
|
37903
37973
|
return { success: ok };
|
|
37904
37974
|
}
|
|
37975
|
+
async function handleOpenPanel(h, args) {
|
|
37976
|
+
const cdp = h.getCdp();
|
|
37977
|
+
if (!cdp) return { success: false, error: "AgentStream or CDP not available" };
|
|
37978
|
+
const sessionId = args?.targetSessionId || h.currentSession?.sessionId;
|
|
37979
|
+
if (!sessionId) return { success: false, error: "targetSessionId required" };
|
|
37980
|
+
const currentTransport = h.currentSession?.transport;
|
|
37981
|
+
const shouldUseAgentStream = !!h.agentStream && currentTransport !== "cdp-page" && currentTransport !== "pty" && currentTransport !== "acp";
|
|
37982
|
+
if (shouldUseAgentStream) {
|
|
37983
|
+
const ok = await h.agentStream.openSessionPanel(cdp, sessionId);
|
|
37984
|
+
return { success: ok };
|
|
37985
|
+
}
|
|
37986
|
+
const openResult = await executeProviderScript(h, args, "openPanel");
|
|
37987
|
+
if (!openResult.success) return openResult;
|
|
37988
|
+
const revealState = normalizeOpenPanelCommandResult(openResult);
|
|
37989
|
+
let focusState = { focused: false };
|
|
37990
|
+
const focusResult = await executeProviderScript(h, args, "focusEditor");
|
|
37991
|
+
if (focusResult.success) {
|
|
37992
|
+
focusState = normalizeFocusEditorCommandResult(focusResult);
|
|
37993
|
+
}
|
|
37994
|
+
return {
|
|
37995
|
+
...openResult,
|
|
37996
|
+
...focusState.focused ? { focused: true } : {},
|
|
37997
|
+
success: revealState.visible || focusState.focused
|
|
37998
|
+
};
|
|
37999
|
+
}
|
|
37905
38000
|
function handlePtyInput(h, args) {
|
|
37906
38001
|
const { cliType, data, targetSessionId } = args || {};
|
|
37907
38002
|
if (!data) return { success: false, error: "data required" };
|
|
@@ -38587,7 +38682,8 @@ ${effect.notification.body || ""}`.trim();
|
|
|
38587
38682
|
"change_model",
|
|
38588
38683
|
"set_thought_level",
|
|
38589
38684
|
"resolve_action",
|
|
38590
|
-
"
|
|
38685
|
+
"select_session",
|
|
38686
|
+
"open_panel",
|
|
38591
38687
|
"pty_input",
|
|
38592
38688
|
"pty_resize",
|
|
38593
38689
|
"invoke_provider_script"
|
|
@@ -38685,8 +38781,10 @@ ${effect.notification.body || ""}`.trim();
|
|
|
38685
38781
|
case "refresh_scripts":
|
|
38686
38782
|
return this.handleRefreshScripts(args);
|
|
38687
38783
|
// ─── Stream commands (stream-commands.ts) ───────────
|
|
38688
|
-
case "
|
|
38689
|
-
return
|
|
38784
|
+
case "select_session":
|
|
38785
|
+
return handleSelectSession(this, args);
|
|
38786
|
+
case "open_panel":
|
|
38787
|
+
return handleOpenPanel(this, args);
|
|
38690
38788
|
// ─── PTY Raw I/O (stream-commands.ts) ─────────
|
|
38691
38789
|
case "pty_input":
|
|
38692
38790
|
return handlePtyInput(this, args);
|
|
@@ -41371,6 +41469,16 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
41371
41469
|
if (!cliType) throw new Error("cliType required");
|
|
41372
41470
|
const found = this.findAdapter(cliType, { instanceKey: args?.targetSessionId, dir });
|
|
41373
41471
|
if (found) {
|
|
41472
|
+
if (!args?.targetSessionId && !dir) {
|
|
41473
|
+
const matchCount = [...this.adapters.values()].filter((a) => a.cliType === cliType).length;
|
|
41474
|
+
if (matchCount > 1) {
|
|
41475
|
+
return {
|
|
41476
|
+
success: false,
|
|
41477
|
+
error: `Multiple ${cliType} sessions running \u2014 provide targetSessionId to stop a specific session`,
|
|
41478
|
+
code: "AMBIGUOUS_SESSION"
|
|
41479
|
+
};
|
|
41480
|
+
}
|
|
41481
|
+
}
|
|
41374
41482
|
await this.stopSessionWithMode(found.key, mode);
|
|
41375
41483
|
} else {
|
|
41376
41484
|
console.log(colorize("yellow", ` \u26A0 No adapter found for ${cliType}`));
|
|
@@ -41546,6 +41654,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
41546
41654
|
warnings.push("disableUpstream is deprecated in provider definitions; use machine-level provider source policy instead");
|
|
41547
41655
|
}
|
|
41548
41656
|
const category = provider.category;
|
|
41657
|
+
const typedProvider = provider;
|
|
41549
41658
|
const controls = Array.isArray(provider.controls) ? provider.controls : [];
|
|
41550
41659
|
if (category === "cli" || category === "acp") {
|
|
41551
41660
|
const spawn4 = provider.spawn;
|
|
@@ -41568,6 +41677,9 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
41568
41677
|
for (const control of controls) {
|
|
41569
41678
|
validateControl(control, errors);
|
|
41570
41679
|
}
|
|
41680
|
+
if ((category === "ide" || category === "extension") && typeof typedProvider.scripts?.focusEditor === "function" && !providerHasOpenPanelSupport(typedProvider)) {
|
|
41681
|
+
warnings.push("scripts.focusEditor is present without scripts.openPanel/webviewOpenPanel; open_panel capability will remain disabled");
|
|
41682
|
+
}
|
|
41571
41683
|
return { errors, warnings };
|
|
41572
41684
|
}
|
|
41573
41685
|
function validateCapabilities(provider, controls, errors) {
|
|
@@ -43629,8 +43741,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
43629
43741
|
for (const sourceSession of unreadSourceSessions) {
|
|
43630
43742
|
const session = sessionsById.get(sourceSession.id);
|
|
43631
43743
|
if (!session) continue;
|
|
43632
|
-
const lastSeenAt = getSessionSeenAt(state, sourceSession.id);
|
|
43633
|
-
const seenCompletionMarker = getSessionSeenMarker(state, sourceSession.id);
|
|
43744
|
+
const lastSeenAt = getSessionSeenAt(state, sourceSession.id, sourceSession.providerSessionId);
|
|
43745
|
+
const seenCompletionMarker = getSessionSeenMarker(state, sourceSession.id, sourceSession.providerSessionId);
|
|
43634
43746
|
const lastUsedAt = getSessionLastUsedAt(sourceSession);
|
|
43635
43747
|
const completionMarker = getSessionCompletionMarker(sourceSession);
|
|
43636
43748
|
const { unread, inboxBucket } = sourceSession.surfaceHidden ? { unread: false, inboxBucket: "idle" } : getUnreadState(
|
|
@@ -44442,7 +44554,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
44442
44554
|
currentState,
|
|
44443
44555
|
sessionId,
|
|
44444
44556
|
typeof args?.seenAt === "number" ? args.seenAt : Date.now(),
|
|
44445
|
-
completionMarker
|
|
44557
|
+
completionMarker,
|
|
44558
|
+
targetSession?.providerSessionId
|
|
44446
44559
|
);
|
|
44447
44560
|
if (READ_DEBUG_ENABLED2) {
|
|
44448
44561
|
LOG2.info("RecentRead", `mark_session_seen sessionId=${sessionId} seenAt=${String(args?.seenAt || "")} prevSeenAt=${String(prevSeenAt)} nextSeenAt=${String(next.sessionReads?.[sessionId] || 0)} marker=${completionMarker || "-"}`);
|
|
@@ -44867,6 +44980,77 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
44867
44980
|
return raw;
|
|
44868
44981
|
}
|
|
44869
44982
|
}
|
|
44983
|
+
getOptionalError(raw) {
|
|
44984
|
+
return typeof raw === "string" && raw.trim() ? raw.trim() : void 0;
|
|
44985
|
+
}
|
|
44986
|
+
normalizeFocusEditorResult(raw) {
|
|
44987
|
+
const data = this.parseMaybeJson(raw);
|
|
44988
|
+
if (data === true) return { focused: true };
|
|
44989
|
+
if (data === false || data == null) return { focused: false };
|
|
44990
|
+
if (typeof data === "string") {
|
|
44991
|
+
const trimmed = data.trim();
|
|
44992
|
+
const normalized = trimmed.toLowerCase();
|
|
44993
|
+
if (normalized === "true" || normalized === "ok" || normalized === "success" || normalized === "focused" || normalized === "visible") {
|
|
44994
|
+
return { focused: true };
|
|
44995
|
+
}
|
|
44996
|
+
if (normalized === "false" || normalized === "not_found" || normalized === "not found" || normalized === "missing" || normalized === "panel_hidden" || normalized === "hidden") {
|
|
44997
|
+
return { focused: false };
|
|
44998
|
+
}
|
|
44999
|
+
return { focused: false, ...trimmed ? { error: trimmed } : {} };
|
|
45000
|
+
}
|
|
45001
|
+
if (data && typeof data === "object") {
|
|
45002
|
+
const error48 = this.getOptionalError(data.error);
|
|
45003
|
+
if (data.focused === true || data.success === true || data.ok === true || data.visible === true) {
|
|
45004
|
+
return { focused: true };
|
|
45005
|
+
}
|
|
45006
|
+
if (data.focused === false || data.success === false || data.ok === false || error48) {
|
|
45007
|
+
return { focused: false, ...error48 ? { error: error48 } : {} };
|
|
45008
|
+
}
|
|
45009
|
+
}
|
|
45010
|
+
return { focused: false };
|
|
45011
|
+
}
|
|
45012
|
+
normalizeOpenPanelResult(raw) {
|
|
45013
|
+
const data = this.parseMaybeJson(raw);
|
|
45014
|
+
if (data === true) return { opened: true, visible: true };
|
|
45015
|
+
if (data === false || data == null) return { opened: false, visible: false };
|
|
45016
|
+
if (typeof data === "string") {
|
|
45017
|
+
const trimmed = data.trim();
|
|
45018
|
+
const normalized = trimmed.toLowerCase();
|
|
45019
|
+
if (normalized === "true" || normalized === "ok" || normalized === "opened" || normalized === "open" || normalized === "success") {
|
|
45020
|
+
return { opened: true, visible: true };
|
|
45021
|
+
}
|
|
45022
|
+
if (normalized === "visible") {
|
|
45023
|
+
return { opened: false, visible: true };
|
|
45024
|
+
}
|
|
45025
|
+
if (normalized === "focused") {
|
|
45026
|
+
return { opened: false, visible: true, focused: true };
|
|
45027
|
+
}
|
|
45028
|
+
if (normalized === "false" || normalized === "panel_hidden" || normalized === "hidden" || normalized === "not_found" || normalized === "not found" || normalized === "missing") {
|
|
45029
|
+
return { opened: false, visible: false };
|
|
45030
|
+
}
|
|
45031
|
+
return { opened: false, visible: false, ...trimmed ? { error: trimmed } : {} };
|
|
45032
|
+
}
|
|
45033
|
+
if (data && typeof data === "object") {
|
|
45034
|
+
const error48 = this.getOptionalError(data.error);
|
|
45035
|
+
const focused = data.focused === true;
|
|
45036
|
+
const visible = data.visible === true || data.opened === true || focused || data.success === true || data.ok === true;
|
|
45037
|
+
if (visible) {
|
|
45038
|
+
return {
|
|
45039
|
+
opened: data.opened === true,
|
|
45040
|
+
visible: true,
|
|
45041
|
+
...focused ? { focused: true } : {}
|
|
45042
|
+
};
|
|
45043
|
+
}
|
|
45044
|
+
if (data.opened === false || data.visible === false || data.success === false || data.ok === false || error48) {
|
|
45045
|
+
return {
|
|
45046
|
+
opened: false,
|
|
45047
|
+
visible: false,
|
|
45048
|
+
...error48 ? { error: error48 } : {}
|
|
45049
|
+
};
|
|
45050
|
+
}
|
|
45051
|
+
}
|
|
45052
|
+
return { opened: false, visible: false };
|
|
45053
|
+
}
|
|
44870
45054
|
summarizeRaw(raw) {
|
|
44871
45055
|
try {
|
|
44872
45056
|
if (typeof raw === "string") return raw.replace(/\s+/g, " ").trim().slice(0, 240);
|
|
@@ -44953,6 +45137,11 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
44953
45137
|
if (typeof validated.title === "string" && validated.title.trim()) {
|
|
44954
45138
|
state.title = validated.title.trim();
|
|
44955
45139
|
}
|
|
45140
|
+
const providerSessionId = typeof validated.providerSessionId === "string" && validated.providerSessionId.trim() ? validated.providerSessionId.trim() : "";
|
|
45141
|
+
if (providerSessionId) {
|
|
45142
|
+
state.sessionId = providerSessionId;
|
|
45143
|
+
state.providerSessionId = providerSessionId;
|
|
45144
|
+
}
|
|
44956
45145
|
const controlValues = extractProviderControlValues(this.provider.controls, validated);
|
|
44957
45146
|
const surface = resolveProviderStateSurface({
|
|
44958
45147
|
controlValues,
|
|
@@ -45075,8 +45264,15 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
45075
45264
|
}
|
|
45076
45265
|
async focusEditor(evaluate) {
|
|
45077
45266
|
const script = this.callScript("focusEditor");
|
|
45078
|
-
if (!script) return;
|
|
45079
|
-
await evaluate(script);
|
|
45267
|
+
if (!script) return { focused: false };
|
|
45268
|
+
const raw = await evaluate(script);
|
|
45269
|
+
return this.normalizeFocusEditorResult(raw);
|
|
45270
|
+
}
|
|
45271
|
+
async openPanel(evaluate) {
|
|
45272
|
+
const script = this.callScript("openPanel");
|
|
45273
|
+
if (!script) return { opened: false, visible: false };
|
|
45274
|
+
const raw = await evaluate(script);
|
|
45275
|
+
return this.normalizeOpenPanelResult(raw);
|
|
45080
45276
|
}
|
|
45081
45277
|
errorState(message) {
|
|
45082
45278
|
return {
|
|
@@ -45344,19 +45540,33 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
45344
45540
|
return false;
|
|
45345
45541
|
}
|
|
45346
45542
|
}
|
|
45347
|
-
async
|
|
45543
|
+
async selectSession(cdp, sessionId) {
|
|
45348
45544
|
const target = this.getSessionTarget(sessionId);
|
|
45349
45545
|
if (!target?.parentSessionId) return false;
|
|
45350
45546
|
await this.setActiveSession(cdp, target.parentSessionId, sessionId);
|
|
45351
45547
|
await this.syncActiveSession(cdp, target.parentSessionId);
|
|
45548
|
+
return this.managedBySessionId.has(sessionId);
|
|
45549
|
+
}
|
|
45550
|
+
async openSessionPanel(cdp, sessionId) {
|
|
45551
|
+
const selected = await this.selectSession(cdp, sessionId);
|
|
45552
|
+
if (!selected) return false;
|
|
45352
45553
|
const agent = this.managedBySessionId.get(sessionId);
|
|
45353
|
-
if (!agent
|
|
45554
|
+
if (!agent) return false;
|
|
45555
|
+
let panelVisible = false;
|
|
45556
|
+
let editorFocused = false;
|
|
45354
45557
|
try {
|
|
45355
45558
|
const evaluate = (expr, timeout) => cdp.evaluateInSessionFrame(agent.cdpSessionId, expr, timeout);
|
|
45356
|
-
|
|
45357
|
-
|
|
45559
|
+
if (typeof agent.adapter.openPanel === "function") {
|
|
45560
|
+
const result = await agent.adapter.openPanel(evaluate);
|
|
45561
|
+
panelVisible = result.visible;
|
|
45562
|
+
}
|
|
45563
|
+
if (typeof agent.adapter.focusEditor === "function") {
|
|
45564
|
+
const result = await agent.adapter.focusEditor(evaluate);
|
|
45565
|
+
editorFocused = result.focused;
|
|
45566
|
+
}
|
|
45567
|
+
return panelVisible || editorFocused;
|
|
45358
45568
|
} catch (e) {
|
|
45359
|
-
this.logFn(`[AgentStream]
|
|
45569
|
+
this.logFn(`[AgentStream] openPanel(${sessionId}) error: ${e.message}`);
|
|
45360
45570
|
return false;
|
|
45361
45571
|
}
|
|
45362
45572
|
}
|
|
@@ -45578,6 +45788,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
45578
45788
|
summaryMetadata: stream.summaryMetadata || void 0,
|
|
45579
45789
|
effects: stream.effects || void 0,
|
|
45580
45790
|
sessionId: stream.sessionId || stream.instanceId || void 0,
|
|
45791
|
+
providerSessionId: stream.providerSessionId || stream.sessionId || void 0,
|
|
45581
45792
|
title: stream.title || stream.agentName || void 0,
|
|
45582
45793
|
agentType: stream.agentType || void 0,
|
|
45583
45794
|
agentName: stream.agentName || void 0,
|
|
@@ -46220,9 +46431,14 @@ module.exports.setMode = (params) => {
|
|
|
46220
46431
|
(() => {
|
|
46221
46432
|
try {
|
|
46222
46433
|
const input = document.querySelector('${meta3.inputSelector || '[contenteditable="true"]'}');
|
|
46223
|
-
if (input) {
|
|
46224
|
-
|
|
46225
|
-
|
|
46434
|
+
if (input) {
|
|
46435
|
+
input.focus();
|
|
46436
|
+
return JSON.stringify({ focused: true });
|
|
46437
|
+
}
|
|
46438
|
+
return JSON.stringify({ focused: false, error: 'not_found' });
|
|
46439
|
+
} catch(e) {
|
|
46440
|
+
return JSON.stringify({ focused: false, error: e.message });
|
|
46441
|
+
}
|
|
46226
46442
|
})()
|
|
46227
46443
|
`;
|
|
46228
46444
|
files[`${scriptDir}/open_panel.js`] = `/**
|
|
@@ -46233,8 +46449,10 @@ module.exports.setMode = (params) => {
|
|
|
46233
46449
|
(() => {
|
|
46234
46450
|
try {
|
|
46235
46451
|
// TODO: Check if panel visible, if not find toggle button
|
|
46236
|
-
return 'not_found';
|
|
46237
|
-
} catch(e) {
|
|
46452
|
+
return JSON.stringify({ opened: false, visible: false, error: 'not_found' });
|
|
46453
|
+
} catch(e) {
|
|
46454
|
+
return JSON.stringify({ opened: false, visible: false, error: e.message });
|
|
46455
|
+
}
|
|
46238
46456
|
})()
|
|
46239
46457
|
`;
|
|
46240
46458
|
files[`${scriptDir}/resolve_action.js`] = `/**
|
|
@@ -49038,8 +49256,8 @@ async (params) => {
|
|
|
49038
49256
|
lines.push("| setModel | `{ success: true/false }` |");
|
|
49039
49257
|
lines.push("| listModes | `{ modes: [{ name, id }], current }` |");
|
|
49040
49258
|
lines.push("| setMode | `{ success: true/false }` |");
|
|
49041
|
-
lines.push("| focusEditor | `{ focused: true/false }` |");
|
|
49042
|
-
lines.push("| openPanel | `{ opened: true/false }` |");
|
|
49259
|
+
lines.push("| focusEditor | `{ focused: true/false, error? }` |");
|
|
49260
|
+
lines.push("| openPanel | `{ opened: true/false, visible: true/false, focused?: true, error? }` |");
|
|
49043
49261
|
lines.push("");
|
|
49044
49262
|
lines.push("## \u{1F534} CRITICAL: readChat `status` Lifecycle");
|
|
49045
49263
|
lines.push("The `status` field in readChat controls how the dashboard and daemon auto-approve-loop behave.");
|
|
@@ -50671,8 +50889,8 @@ data: ${JSON.stringify(msg.data)}
|
|
|
50671
50889
|
lines.push("| setModel | `{ success: true/false }` |");
|
|
50672
50890
|
lines.push("| listModes | `{ modes: [{ name, id }], current }` |");
|
|
50673
50891
|
lines.push("| setMode | `{ success: true/false }` |");
|
|
50674
|
-
lines.push("| focusEditor | `{ focused: true/false }` |");
|
|
50675
|
-
lines.push("| openPanel | `{ opened: true/false }` |");
|
|
50892
|
+
lines.push("| focusEditor | `{ focused: true/false, error? }` |");
|
|
50893
|
+
lines.push("| openPanel | `{ opened: true/false, visible: true/false, focused?: true, error? }` |");
|
|
50676
50894
|
lines.push("");
|
|
50677
50895
|
lines.push("## \u{1F534} CRITICAL: readChat `status` Lifecycle");
|
|
50678
50896
|
lines.push("The `status` field in readChat controls how the dashboard and daemon auto-approve-loop behave.");
|