@adhdev/daemon-core 0.8.71 → 0.8.72
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/chat/chat-signatures.d.ts +34 -0
- package/dist/chat/chat-signatures.js +96 -0
- package/dist/chat/chat-signatures.js.map +1 -0
- package/dist/chat/chat-signatures.mjs +68 -0
- package/dist/chat/chat-signatures.mjs.map +1 -0
- package/dist/chat/subscription-updates.d.ts +50 -0
- package/dist/commands/provider-script-resolver.d.ts +2 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +305 -54
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +297 -54
- package/dist/index.mjs.map +1 -1
- package/dist/providers/provider-session-id.d.ts +2 -0
- package/node_modules/@adhdev/session-host-core/package.json +1 -1
- package/package.json +7 -1
- package/src/chat/chat-signatures.ts +95 -0
- package/src/chat/subscription-updates.ts +218 -0
- package/src/commands/chat-commands.ts +2 -28
- package/src/commands/handler.ts +2 -28
- package/src/commands/provider-script-resolver.ts +40 -0
- package/src/config/state-store.ts +25 -4
- package/src/daemon/dev-server.ts +16 -14
- package/src/index.ts +25 -0
- package/src/providers/cli-provider-instance.ts +9 -6
- package/src/providers/provider-session-id.ts +22 -0
- package/src/session-host/app-name.ts +12 -1
package/dist/index.mjs
CHANGED
|
@@ -3907,6 +3907,27 @@ function getSavedProviderSessions(state, filters) {
|
|
|
3907
3907
|
init_config();
|
|
3908
3908
|
import { existsSync as existsSync3, readFileSync as readFileSync2, writeFileSync as writeFileSync2 } from "fs";
|
|
3909
3909
|
import { join as join3 } from "path";
|
|
3910
|
+
|
|
3911
|
+
// src/providers/provider-session-id.ts
|
|
3912
|
+
var HERMES_SESSION_ID_RE = /^\d{8}_\d{6}_[a-z0-9]+$/i;
|
|
3913
|
+
function normalizeProviderSessionId(providerType, providerSessionId) {
|
|
3914
|
+
const normalizedProviderType = typeof providerType === "string" ? providerType.trim() : "";
|
|
3915
|
+
const normalizedId = typeof providerSessionId === "string" ? providerSessionId.trim() : "";
|
|
3916
|
+
if (!normalizedId) return "";
|
|
3917
|
+
const lowered = normalizedId.toLowerCase();
|
|
3918
|
+
if (lowered === "undefined" || lowered === "null") return "";
|
|
3919
|
+
if (normalizedProviderType === "hermes-cli" && !HERMES_SESSION_ID_RE.test(normalizedId)) {
|
|
3920
|
+
return "";
|
|
3921
|
+
}
|
|
3922
|
+
return normalizedId;
|
|
3923
|
+
}
|
|
3924
|
+
function isLegacyVolatileSessionReadKey(key) {
|
|
3925
|
+
const normalizedKey = typeof key === "string" ? key.trim() : "";
|
|
3926
|
+
if (!normalizedKey) return false;
|
|
3927
|
+
return normalizedKey.startsWith("provider:codex:vscode-webview://");
|
|
3928
|
+
}
|
|
3929
|
+
|
|
3930
|
+
// src/config/state-store.ts
|
|
3910
3931
|
var DEFAULT_STATE = {
|
|
3911
3932
|
recentActivity: [],
|
|
3912
3933
|
savedProviderSessions: [],
|
|
@@ -3921,15 +3942,31 @@ function getStatePath() {
|
|
|
3921
3942
|
}
|
|
3922
3943
|
function normalizeState(raw) {
|
|
3923
3944
|
const parsed = isPlainObject2(raw) ? raw : {};
|
|
3945
|
+
const recentActivity = (Array.isArray(parsed.recentActivity) ? parsed.recentActivity : []).filter((entry) => {
|
|
3946
|
+
if (!isPlainObject2(entry)) return false;
|
|
3947
|
+
const normalizedId = normalizeProviderSessionId(
|
|
3948
|
+
typeof entry.providerType === "string" ? entry.providerType : "",
|
|
3949
|
+
typeof entry.providerSessionId === "string" ? entry.providerSessionId : ""
|
|
3950
|
+
);
|
|
3951
|
+
if (typeof entry.providerSessionId === "string" && !normalizedId) return false;
|
|
3952
|
+
return true;
|
|
3953
|
+
});
|
|
3954
|
+
const savedProviderSessions = (Array.isArray(parsed.savedProviderSessions) ? parsed.savedProviderSessions : []).filter((entry) => {
|
|
3955
|
+
if (!isPlainObject2(entry)) return false;
|
|
3956
|
+
return !!normalizeProviderSessionId(
|
|
3957
|
+
typeof entry.providerType === "string" ? entry.providerType : "",
|
|
3958
|
+
typeof entry.providerSessionId === "string" ? entry.providerSessionId : ""
|
|
3959
|
+
);
|
|
3960
|
+
});
|
|
3924
3961
|
const sessionReads = Object.fromEntries(
|
|
3925
|
-
Object.entries(isPlainObject2(parsed.sessionReads) ? parsed.sessionReads : {}).filter(([, value]) => typeof value === "number" && Number.isFinite(value))
|
|
3962
|
+
Object.entries(isPlainObject2(parsed.sessionReads) ? parsed.sessionReads : {}).filter(([key, value]) => !isLegacyVolatileSessionReadKey(key) && typeof value === "number" && Number.isFinite(value))
|
|
3926
3963
|
);
|
|
3927
3964
|
const sessionReadMarkers = Object.fromEntries(
|
|
3928
|
-
Object.entries(isPlainObject2(parsed.sessionReadMarkers) ? parsed.sessionReadMarkers : {}).filter(([, value]) => typeof value === "string")
|
|
3965
|
+
Object.entries(isPlainObject2(parsed.sessionReadMarkers) ? parsed.sessionReadMarkers : {}).filter(([key, value]) => !isLegacyVolatileSessionReadKey(key) && typeof value === "string")
|
|
3929
3966
|
);
|
|
3930
3967
|
return {
|
|
3931
|
-
recentActivity
|
|
3932
|
-
savedProviderSessions
|
|
3968
|
+
recentActivity,
|
|
3969
|
+
savedProviderSessions,
|
|
3933
3970
|
sessionReads,
|
|
3934
3971
|
sessionReadMarkers
|
|
3935
3972
|
};
|
|
@@ -8283,6 +8320,32 @@ function reconcileIdeRuntimeSessions(instanceManager, sessionRegistry) {
|
|
|
8283
8320
|
// src/commands/handler.ts
|
|
8284
8321
|
init_logger();
|
|
8285
8322
|
|
|
8323
|
+
// src/commands/provider-script-resolver.ts
|
|
8324
|
+
function resolveLegacyProviderScript(fn, scriptName, params) {
|
|
8325
|
+
if (typeof fn !== "function") return null;
|
|
8326
|
+
if (params && typeof params === "object" && !Array.isArray(params) && Object.keys(params).length > 0) {
|
|
8327
|
+
const firstVal = Object.values(params)[0];
|
|
8328
|
+
if (scriptName === "sendMessage" && typeof firstVal === "string") {
|
|
8329
|
+
const legacyScript = fn(firstVal);
|
|
8330
|
+
if (legacyScript) return legacyScript;
|
|
8331
|
+
}
|
|
8332
|
+
const script = fn(params);
|
|
8333
|
+
const likelyLegacyObjectLeak = typeof script === "string" && script.includes("[object Object]") && typeof firstVal === "string";
|
|
8334
|
+
if (!likelyLegacyObjectLeak && script) return script;
|
|
8335
|
+
if (firstVal !== void 0) {
|
|
8336
|
+
const legacyScript = fn(firstVal);
|
|
8337
|
+
if (legacyScript) return legacyScript;
|
|
8338
|
+
}
|
|
8339
|
+
if (script) return script;
|
|
8340
|
+
return null;
|
|
8341
|
+
}
|
|
8342
|
+
if (params !== void 0) {
|
|
8343
|
+
const script = fn(params);
|
|
8344
|
+
if (script) return script;
|
|
8345
|
+
}
|
|
8346
|
+
return fn() || null;
|
|
8347
|
+
}
|
|
8348
|
+
|
|
8286
8349
|
// src/commands/chat-commands.ts
|
|
8287
8350
|
init_contracts();
|
|
8288
8351
|
|
|
@@ -8471,10 +8534,7 @@ function createInteractionId(prefix = "ix") {
|
|
|
8471
8534
|
return `${prefix}_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 8)}`;
|
|
8472
8535
|
}
|
|
8473
8536
|
|
|
8474
|
-
// src/
|
|
8475
|
-
init_chat_message_normalization();
|
|
8476
|
-
var RECENT_SEND_WINDOW_MS = 1200;
|
|
8477
|
-
var recentSendByTarget = /* @__PURE__ */ new Map();
|
|
8537
|
+
// src/chat/chat-signatures.ts
|
|
8478
8538
|
function hashSignatureParts(parts) {
|
|
8479
8539
|
let hash = 2166136261;
|
|
8480
8540
|
for (const part of parts) {
|
|
@@ -8488,6 +8548,58 @@ function hashSignatureParts(parts) {
|
|
|
8488
8548
|
}
|
|
8489
8549
|
return hash.toString(16).padStart(8, "0");
|
|
8490
8550
|
}
|
|
8551
|
+
function stringifySignatureContent(content) {
|
|
8552
|
+
try {
|
|
8553
|
+
return JSON.stringify(content ?? "");
|
|
8554
|
+
} catch {
|
|
8555
|
+
return String(content ?? "");
|
|
8556
|
+
}
|
|
8557
|
+
}
|
|
8558
|
+
function stringifySignatureMessages(messages) {
|
|
8559
|
+
try {
|
|
8560
|
+
return JSON.stringify(messages);
|
|
8561
|
+
} catch {
|
|
8562
|
+
return String(messages.length);
|
|
8563
|
+
}
|
|
8564
|
+
}
|
|
8565
|
+
function buildChatMessageSignature(message) {
|
|
8566
|
+
if (!message) return "";
|
|
8567
|
+
return hashSignatureParts([
|
|
8568
|
+
String(message.id || ""),
|
|
8569
|
+
String(message.index ?? ""),
|
|
8570
|
+
String(message.role || ""),
|
|
8571
|
+
String(message.receivedAt ?? message.timestamp ?? ""),
|
|
8572
|
+
stringifySignatureContent(message.content)
|
|
8573
|
+
]);
|
|
8574
|
+
}
|
|
8575
|
+
function buildChatTailDeliverySignature(payload) {
|
|
8576
|
+
return hashSignatureParts([
|
|
8577
|
+
payload.sessionId,
|
|
8578
|
+
payload.historySessionId || "",
|
|
8579
|
+
payload.status,
|
|
8580
|
+
payload.title || "",
|
|
8581
|
+
payload.syncMode,
|
|
8582
|
+
String(payload.replaceFrom),
|
|
8583
|
+
String(payload.totalMessages),
|
|
8584
|
+
payload.lastMessageSignature,
|
|
8585
|
+
payload.activeModal ? `${payload.activeModal.message}|${payload.activeModal.buttons.join("")}` : "",
|
|
8586
|
+
stringifySignatureMessages(payload.messages)
|
|
8587
|
+
]);
|
|
8588
|
+
}
|
|
8589
|
+
function buildSessionModalDeliverySignature(payload) {
|
|
8590
|
+
return hashSignatureParts([
|
|
8591
|
+
payload.sessionId,
|
|
8592
|
+
payload.status,
|
|
8593
|
+
payload.title || "",
|
|
8594
|
+
payload.modalMessage || "",
|
|
8595
|
+
Array.isArray(payload.modalButtons) ? payload.modalButtons.join("") : ""
|
|
8596
|
+
]);
|
|
8597
|
+
}
|
|
8598
|
+
|
|
8599
|
+
// src/commands/chat-commands.ts
|
|
8600
|
+
init_chat_message_normalization();
|
|
8601
|
+
var RECENT_SEND_WINDOW_MS = 1200;
|
|
8602
|
+
var recentSendByTarget = /* @__PURE__ */ new Map();
|
|
8491
8603
|
function getCurrentProviderType(h, fallback = "") {
|
|
8492
8604
|
return h.currentSession?.providerType || h.currentProviderType || fallback;
|
|
8493
8605
|
}
|
|
@@ -8584,20 +8696,7 @@ function parseMaybeJson(value) {
|
|
|
8584
8696
|
}
|
|
8585
8697
|
}
|
|
8586
8698
|
function getChatMessageSignature(message) {
|
|
8587
|
-
|
|
8588
|
-
let content = "";
|
|
8589
|
-
try {
|
|
8590
|
-
content = JSON.stringify(message.content ?? "");
|
|
8591
|
-
} catch {
|
|
8592
|
-
content = String(message.content ?? "");
|
|
8593
|
-
}
|
|
8594
|
-
return hashSignatureParts([
|
|
8595
|
-
String(message.id || ""),
|
|
8596
|
-
String(message.index ?? ""),
|
|
8597
|
-
String(message.role || ""),
|
|
8598
|
-
String(message.receivedAt ?? message.timestamp ?? ""),
|
|
8599
|
-
content
|
|
8600
|
-
]);
|
|
8699
|
+
return buildChatMessageSignature(message);
|
|
8601
8700
|
}
|
|
8602
8701
|
function normalizeReadChatCursor(args) {
|
|
8603
8702
|
const knownMessageCount = Math.max(0, Number(args?.knownMessageCount || 0));
|
|
@@ -10645,27 +10744,7 @@ var DaemonCommandHandler = class {
|
|
|
10645
10744
|
if (provider?.scripts) {
|
|
10646
10745
|
const fn = provider.scripts[scriptName];
|
|
10647
10746
|
if (typeof fn === "function") {
|
|
10648
|
-
|
|
10649
|
-
if (params && Object.keys(params).length > 0) {
|
|
10650
|
-
const firstVal = Object.values(params)[0];
|
|
10651
|
-
if (scriptName === "sendMessage" && typeof firstVal === "string") {
|
|
10652
|
-
const legacyScript = callScript(firstVal);
|
|
10653
|
-
if (legacyScript) return legacyScript;
|
|
10654
|
-
}
|
|
10655
|
-
const script = callScript(params);
|
|
10656
|
-
if (script) {
|
|
10657
|
-
const likelyLegacyObjectLeak = typeof script === "string" && script.includes("[object Object]") && typeof firstVal === "string";
|
|
10658
|
-
if (!likelyLegacyObjectLeak) return script;
|
|
10659
|
-
}
|
|
10660
|
-
if (firstVal !== void 0) {
|
|
10661
|
-
const legacyScript = callScript(firstVal);
|
|
10662
|
-
if (legacyScript) return legacyScript;
|
|
10663
|
-
}
|
|
10664
|
-
if (script) return script;
|
|
10665
|
-
} else {
|
|
10666
|
-
const script = callScript();
|
|
10667
|
-
if (script) return script;
|
|
10668
|
-
}
|
|
10747
|
+
return resolveLegacyProviderScript(fn, scriptName, params);
|
|
10669
10748
|
}
|
|
10670
10749
|
}
|
|
10671
10750
|
return null;
|
|
@@ -11260,7 +11339,10 @@ var CliProviderInstance = class {
|
|
|
11260
11339
|
const parsedStatus = this.adapter.getScriptParsedStatus?.() || null;
|
|
11261
11340
|
const autoApproveActive = adapterStatus.status === "waiting_approval" && this.shouldAutoApprove();
|
|
11262
11341
|
const visibleStatus = autoApproveActive ? "generating" : adapterStatus.status;
|
|
11263
|
-
const parsedProviderSessionId =
|
|
11342
|
+
const parsedProviderSessionId = normalizeProviderSessionId(
|
|
11343
|
+
this.type,
|
|
11344
|
+
typeof parsedStatus?.providerSessionId === "string" ? parsedStatus.providerSessionId : ""
|
|
11345
|
+
);
|
|
11264
11346
|
if (parsedProviderSessionId) {
|
|
11265
11347
|
this.promoteProviderSessionId(parsedProviderSessionId);
|
|
11266
11348
|
}
|
|
@@ -11524,7 +11606,10 @@ var CliProviderInstance = class {
|
|
|
11524
11606
|
}
|
|
11525
11607
|
applyProviderResponse(data, options) {
|
|
11526
11608
|
if (!data || typeof data !== "object") return;
|
|
11527
|
-
const patchedProviderSessionId =
|
|
11609
|
+
const patchedProviderSessionId = normalizeProviderSessionId(
|
|
11610
|
+
this.type,
|
|
11611
|
+
typeof data.providerSessionId === "string" ? data.providerSessionId : ""
|
|
11612
|
+
);
|
|
11528
11613
|
if (patchedProviderSessionId) {
|
|
11529
11614
|
this.promoteProviderSessionId(patchedProviderSessionId);
|
|
11530
11615
|
}
|
|
@@ -17109,6 +17194,141 @@ init_logger();
|
|
|
17109
17194
|
var DEFAULT_DAEMON_PORT = 19222;
|
|
17110
17195
|
var DAEMON_WS_PATH = "/ipc";
|
|
17111
17196
|
|
|
17197
|
+
// src/chat/subscription-updates.ts
|
|
17198
|
+
function normalizeSyncMode(syncMode) {
|
|
17199
|
+
return syncMode === "append" || syncMode === "replace_tail" || syncMode === "noop" || syncMode === "full" ? syncMode : "full";
|
|
17200
|
+
}
|
|
17201
|
+
function normalizeModalButtons(value) {
|
|
17202
|
+
return Array.isArray(value) ? value.filter((button) => typeof button === "string") : [];
|
|
17203
|
+
}
|
|
17204
|
+
function normalizeModalMessage(value) {
|
|
17205
|
+
return typeof value === "string" ? value : void 0;
|
|
17206
|
+
}
|
|
17207
|
+
function normalizeChatTailActiveModal(activeModal) {
|
|
17208
|
+
if (!activeModal || typeof activeModal !== "object") return null;
|
|
17209
|
+
const message = normalizeModalMessage(activeModal.message);
|
|
17210
|
+
if (!message) return null;
|
|
17211
|
+
const rawButtons = activeModal.buttons;
|
|
17212
|
+
if (!Array.isArray(rawButtons)) return null;
|
|
17213
|
+
return {
|
|
17214
|
+
message,
|
|
17215
|
+
buttons: normalizeModalButtons(rawButtons)
|
|
17216
|
+
};
|
|
17217
|
+
}
|
|
17218
|
+
function normalizeSessionModalFields(activeModal) {
|
|
17219
|
+
if (!activeModal || typeof activeModal !== "object") {
|
|
17220
|
+
return { modalButtons: [] };
|
|
17221
|
+
}
|
|
17222
|
+
return {
|
|
17223
|
+
modalMessage: normalizeModalMessage(activeModal.message),
|
|
17224
|
+
modalButtons: normalizeModalButtons(activeModal.buttons)
|
|
17225
|
+
};
|
|
17226
|
+
}
|
|
17227
|
+
function buildNextChatCursor(cursor, result) {
|
|
17228
|
+
return {
|
|
17229
|
+
knownMessageCount: Math.max(0, Number(result.totalMessages || cursor.knownMessageCount)),
|
|
17230
|
+
lastMessageSignature: typeof result.lastMessageSignature === "string" ? result.lastMessageSignature : cursor.lastMessageSignature,
|
|
17231
|
+
tailLimit: cursor.tailLimit
|
|
17232
|
+
};
|
|
17233
|
+
}
|
|
17234
|
+
function prepareSessionChatTailUpdate(input) {
|
|
17235
|
+
const result = input.result;
|
|
17236
|
+
if (!result?.success || result.syncMode === "noop") {
|
|
17237
|
+
return {
|
|
17238
|
+
cursor: result?.success ? buildNextChatCursor(input.cursor, result) : input.cursor,
|
|
17239
|
+
seq: input.seq,
|
|
17240
|
+
lastDeliveredSignature: input.lastDeliveredSignature,
|
|
17241
|
+
update: null
|
|
17242
|
+
};
|
|
17243
|
+
}
|
|
17244
|
+
const syncMode = normalizeSyncMode(result.syncMode);
|
|
17245
|
+
const cursor = {
|
|
17246
|
+
knownMessageCount: Math.max(0, Number(result.totalMessages || 0)),
|
|
17247
|
+
lastMessageSignature: typeof result.lastMessageSignature === "string" ? result.lastMessageSignature : "",
|
|
17248
|
+
tailLimit: input.cursor.tailLimit
|
|
17249
|
+
};
|
|
17250
|
+
const title = typeof result.title === "string" ? result.title : void 0;
|
|
17251
|
+
const activeModal = normalizeChatTailActiveModal(result.activeModal);
|
|
17252
|
+
const status = typeof result.status === "string" ? result.status : "idle";
|
|
17253
|
+
const deliverySignature = buildChatTailDeliverySignature({
|
|
17254
|
+
sessionId: input.sessionId,
|
|
17255
|
+
...input.historySessionId ? { historySessionId: input.historySessionId } : {},
|
|
17256
|
+
messages: Array.isArray(result.messages) ? result.messages : [],
|
|
17257
|
+
status,
|
|
17258
|
+
...title ? { title } : {},
|
|
17259
|
+
...activeModal ? { activeModal } : {},
|
|
17260
|
+
syncMode,
|
|
17261
|
+
replaceFrom: Number(result.replaceFrom || 0),
|
|
17262
|
+
totalMessages: Number(result.totalMessages || 0),
|
|
17263
|
+
lastMessageSignature: typeof result.lastMessageSignature === "string" ? result.lastMessageSignature : ""
|
|
17264
|
+
});
|
|
17265
|
+
const seq = input.seq + 1;
|
|
17266
|
+
if (deliverySignature === input.lastDeliveredSignature) {
|
|
17267
|
+
return {
|
|
17268
|
+
cursor,
|
|
17269
|
+
seq,
|
|
17270
|
+
lastDeliveredSignature: input.lastDeliveredSignature,
|
|
17271
|
+
update: null
|
|
17272
|
+
};
|
|
17273
|
+
}
|
|
17274
|
+
return {
|
|
17275
|
+
cursor,
|
|
17276
|
+
seq,
|
|
17277
|
+
lastDeliveredSignature: deliverySignature,
|
|
17278
|
+
update: {
|
|
17279
|
+
topic: "session.chat_tail",
|
|
17280
|
+
key: input.key,
|
|
17281
|
+
sessionId: input.sessionId,
|
|
17282
|
+
...input.historySessionId ? { historySessionId: input.historySessionId } : {},
|
|
17283
|
+
...input.interactionId ? { interactionId: input.interactionId } : {},
|
|
17284
|
+
seq,
|
|
17285
|
+
timestamp: input.timestamp,
|
|
17286
|
+
messages: Array.isArray(result.messages) ? result.messages : [],
|
|
17287
|
+
status,
|
|
17288
|
+
...title ? { title } : {},
|
|
17289
|
+
...activeModal ? { activeModal } : {},
|
|
17290
|
+
syncMode,
|
|
17291
|
+
replaceFrom: Number(result.replaceFrom || 0),
|
|
17292
|
+
totalMessages: Number(result.totalMessages || 0),
|
|
17293
|
+
lastMessageSignature: typeof result.lastMessageSignature === "string" ? result.lastMessageSignature : ""
|
|
17294
|
+
}
|
|
17295
|
+
};
|
|
17296
|
+
}
|
|
17297
|
+
function prepareSessionModalUpdate(input) {
|
|
17298
|
+
const { modalMessage, modalButtons } = normalizeSessionModalFields(input.activeModal);
|
|
17299
|
+
const deliverySignature = buildSessionModalDeliverySignature({
|
|
17300
|
+
sessionId: input.sessionId,
|
|
17301
|
+
status: input.status,
|
|
17302
|
+
...input.title ? { title: input.title } : {},
|
|
17303
|
+
...modalMessage ? { modalMessage } : {},
|
|
17304
|
+
...modalButtons.length > 0 ? { modalButtons } : {}
|
|
17305
|
+
});
|
|
17306
|
+
if (deliverySignature === input.lastDeliveredSignature) {
|
|
17307
|
+
return {
|
|
17308
|
+
seq: input.seq,
|
|
17309
|
+
lastDeliveredSignature: input.lastDeliveredSignature,
|
|
17310
|
+
update: null
|
|
17311
|
+
};
|
|
17312
|
+
}
|
|
17313
|
+
const seq = input.seq + 1;
|
|
17314
|
+
return {
|
|
17315
|
+
seq,
|
|
17316
|
+
lastDeliveredSignature: deliverySignature,
|
|
17317
|
+
update: {
|
|
17318
|
+
topic: "session.modal",
|
|
17319
|
+
key: input.key,
|
|
17320
|
+
sessionId: input.sessionId,
|
|
17321
|
+
status: input.status,
|
|
17322
|
+
...input.title ? { title: input.title } : {},
|
|
17323
|
+
...modalMessage ? { modalMessage } : {},
|
|
17324
|
+
...modalButtons.length > 0 ? { modalButtons } : {},
|
|
17325
|
+
...input.interactionId ? { interactionId: input.interactionId } : {},
|
|
17326
|
+
seq,
|
|
17327
|
+
timestamp: input.timestamp
|
|
17328
|
+
}
|
|
17329
|
+
};
|
|
17330
|
+
}
|
|
17331
|
+
|
|
17112
17332
|
// src/agent-stream/provider-adapter.ts
|
|
17113
17333
|
init_read_chat_contract();
|
|
17114
17334
|
init_chat_message_normalization();
|
|
@@ -22303,7 +22523,8 @@ var DevServer = class _DevServer {
|
|
|
22303
22523
|
}
|
|
22304
22524
|
async handleRunScript(type, req, res, parsedBody) {
|
|
22305
22525
|
const body = parsedBody || await this.readBody(req);
|
|
22306
|
-
const { script: scriptName, params, ideType: scriptIdeType } = body;
|
|
22526
|
+
const { script: scriptName, params, args, ideType: scriptIdeType } = body;
|
|
22527
|
+
const rawParams = args !== void 0 ? args : params;
|
|
22307
22528
|
const provider = this.providerLoader.resolve(type);
|
|
22308
22529
|
if (!provider) {
|
|
22309
22530
|
this.json(res, 404, { error: `Provider '${type}' not found` });
|
|
@@ -22320,13 +22541,7 @@ var DevServer = class _DevServer {
|
|
|
22320
22541
|
return;
|
|
22321
22542
|
}
|
|
22322
22543
|
try {
|
|
22323
|
-
|
|
22324
|
-
if (["sendMessage", "webviewSendMessage", "switchSession", "webviewSwitchSession", "setMode", "webviewSetMode", "setModel", "webviewSetModel"].includes(scriptName)) {
|
|
22325
|
-
const firstVal = params && typeof params === "object" && Object.keys(params).length > 0 ? Object.values(params)[0] : params;
|
|
22326
|
-
scriptCode = firstVal !== void 0 ? fn(firstVal) : fn();
|
|
22327
|
-
} else {
|
|
22328
|
-
scriptCode = params !== void 0 ? fn(params) : fn();
|
|
22329
|
-
}
|
|
22544
|
+
const scriptCode = resolveLegacyProviderScript(fn, scriptName, rawParams);
|
|
22330
22545
|
if (!scriptCode) {
|
|
22331
22546
|
this.json(res, 500, { error: "Script function returned null" });
|
|
22332
22547
|
return;
|
|
@@ -22343,6 +22558,17 @@ var DevServer = class _DevServer {
|
|
|
22343
22558
|
break;
|
|
22344
22559
|
}
|
|
22345
22560
|
}
|
|
22561
|
+
if (!sessionId) {
|
|
22562
|
+
try {
|
|
22563
|
+
const discovered = await cdp.discoverAgentWebviews();
|
|
22564
|
+
const target = discovered.find((entry) => entry.agentType === type);
|
|
22565
|
+
if (target) {
|
|
22566
|
+
sessionId = await cdp.attachToAgent(target);
|
|
22567
|
+
}
|
|
22568
|
+
} catch (error) {
|
|
22569
|
+
this.log(`Extension attach fallback failed for ${type}: ${error?.message || String(error)}`);
|
|
22570
|
+
}
|
|
22571
|
+
}
|
|
22346
22572
|
if (sessionId) {
|
|
22347
22573
|
raw = await cdp.evaluateInSessionFrame(sessionId, scriptCode);
|
|
22348
22574
|
} else if (cdp.evaluateInWebviewFrame) {
|
|
@@ -23913,10 +24139,19 @@ var SessionHostPtyTransportFactory = class {
|
|
|
23913
24139
|
// src/session-host/app-name.ts
|
|
23914
24140
|
var DEFAULT_SESSION_HOST_APP_NAME = "adhdev";
|
|
23915
24141
|
var DEFAULT_STANDALONE_SESSION_HOST_APP_NAME = "adhdev-standalone";
|
|
24142
|
+
function validateStandaloneSessionHostAppName(explicit) {
|
|
24143
|
+
if (explicit !== DEFAULT_SESSION_HOST_APP_NAME) return;
|
|
24144
|
+
throw new Error(
|
|
24145
|
+
`Standalone session-host namespace '${DEFAULT_SESSION_HOST_APP_NAME}' is reserved for the global daemon. Use '${DEFAULT_STANDALONE_SESSION_HOST_APP_NAME}' or another non-default namespace.`
|
|
24146
|
+
);
|
|
24147
|
+
}
|
|
23916
24148
|
function resolveSessionHostAppName(options = {}) {
|
|
23917
24149
|
const env = options.env || process.env;
|
|
23918
24150
|
const explicit = typeof env.ADHDEV_SESSION_HOST_NAME === "string" ? env.ADHDEV_SESSION_HOST_NAME.trim() : "";
|
|
23919
|
-
if (explicit)
|
|
24151
|
+
if (explicit) {
|
|
24152
|
+
if (options.standalone) validateStandaloneSessionHostAppName(explicit);
|
|
24153
|
+
return explicit;
|
|
24154
|
+
}
|
|
23920
24155
|
return options.standalone ? DEFAULT_STANDALONE_SESSION_HOST_APP_NAME : DEFAULT_SESSION_HOST_APP_NAME;
|
|
23921
24156
|
}
|
|
23922
24157
|
|
|
@@ -24493,9 +24728,12 @@ export {
|
|
|
24493
24728
|
appendRecentActivity,
|
|
24494
24729
|
buildAssistantChatMessage,
|
|
24495
24730
|
buildChatMessage,
|
|
24731
|
+
buildChatMessageSignature,
|
|
24732
|
+
buildChatTailDeliverySignature,
|
|
24496
24733
|
buildMachineInfo,
|
|
24497
24734
|
buildRuntimeSystemChatMessage,
|
|
24498
24735
|
buildSessionEntries,
|
|
24736
|
+
buildSessionModalDeliverySignature,
|
|
24499
24737
|
buildStatusSnapshot,
|
|
24500
24738
|
buildSystemChatMessage,
|
|
24501
24739
|
buildTerminalChatMessage,
|
|
@@ -24531,6 +24769,7 @@ export {
|
|
|
24531
24769
|
getSessionHostSurfaceKind,
|
|
24532
24770
|
getWorkspaceState,
|
|
24533
24771
|
hasCdpManager,
|
|
24772
|
+
hashSignatureParts,
|
|
24534
24773
|
initDaemonComponents,
|
|
24535
24774
|
installExtensions,
|
|
24536
24775
|
installGlobalInterceptor,
|
|
@@ -24556,12 +24795,16 @@ export {
|
|
|
24556
24795
|
normalizeChatMessage,
|
|
24557
24796
|
normalizeChatMessageKind,
|
|
24558
24797
|
normalizeChatMessages,
|
|
24798
|
+
normalizeChatTailActiveModal,
|
|
24559
24799
|
normalizeInputEnvelope,
|
|
24560
24800
|
normalizeManagedStatus,
|
|
24561
24801
|
normalizeMessageParts,
|
|
24802
|
+
normalizeSessionModalFields,
|
|
24562
24803
|
parseProviderSourceConfigUpdate,
|
|
24563
24804
|
partitionSessionHostDiagnosticsSessions,
|
|
24564
24805
|
partitionSessionHostRecords,
|
|
24806
|
+
prepareSessionChatTailUpdate,
|
|
24807
|
+
prepareSessionModalUpdate,
|
|
24565
24808
|
probeCdpPort,
|
|
24566
24809
|
readChatHistory,
|
|
24567
24810
|
recordDebugTrace,
|