@adhdev/daemon-core 0.8.71 → 0.8.73
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 +53 -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 +222 -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.js
CHANGED
|
@@ -3576,9 +3576,12 @@ __export(index_exports, {
|
|
|
3576
3576
|
appendRecentActivity: () => appendRecentActivity,
|
|
3577
3577
|
buildAssistantChatMessage: () => buildAssistantChatMessage,
|
|
3578
3578
|
buildChatMessage: () => buildChatMessage,
|
|
3579
|
+
buildChatMessageSignature: () => buildChatMessageSignature,
|
|
3580
|
+
buildChatTailDeliverySignature: () => buildChatTailDeliverySignature,
|
|
3579
3581
|
buildMachineInfo: () => buildMachineInfo,
|
|
3580
3582
|
buildRuntimeSystemChatMessage: () => buildRuntimeSystemChatMessage,
|
|
3581
3583
|
buildSessionEntries: () => buildSessionEntries,
|
|
3584
|
+
buildSessionModalDeliverySignature: () => buildSessionModalDeliverySignature,
|
|
3582
3585
|
buildStatusSnapshot: () => buildStatusSnapshot,
|
|
3583
3586
|
buildSystemChatMessage: () => buildSystemChatMessage,
|
|
3584
3587
|
buildTerminalChatMessage: () => buildTerminalChatMessage,
|
|
@@ -3614,6 +3617,7 @@ __export(index_exports, {
|
|
|
3614
3617
|
getSessionHostSurfaceKind: () => getSessionHostSurfaceKind,
|
|
3615
3618
|
getWorkspaceState: () => getWorkspaceState,
|
|
3616
3619
|
hasCdpManager: () => hasCdpManager,
|
|
3620
|
+
hashSignatureParts: () => hashSignatureParts,
|
|
3617
3621
|
initDaemonComponents: () => initDaemonComponents,
|
|
3618
3622
|
installExtensions: () => installExtensions,
|
|
3619
3623
|
installGlobalInterceptor: () => installGlobalInterceptor,
|
|
@@ -3639,12 +3643,16 @@ __export(index_exports, {
|
|
|
3639
3643
|
normalizeChatMessage: () => normalizeChatMessage,
|
|
3640
3644
|
normalizeChatMessageKind: () => normalizeChatMessageKind,
|
|
3641
3645
|
normalizeChatMessages: () => normalizeChatMessages,
|
|
3646
|
+
normalizeChatTailActiveModal: () => normalizeChatTailActiveModal,
|
|
3642
3647
|
normalizeInputEnvelope: () => normalizeInputEnvelope,
|
|
3643
3648
|
normalizeManagedStatus: () => normalizeManagedStatus,
|
|
3644
3649
|
normalizeMessageParts: () => normalizeMessageParts,
|
|
3650
|
+
normalizeSessionModalFields: () => normalizeSessionModalFields,
|
|
3645
3651
|
parseProviderSourceConfigUpdate: () => parseProviderSourceConfigUpdate,
|
|
3646
3652
|
partitionSessionHostDiagnosticsSessions: () => partitionSessionHostDiagnosticsSessions,
|
|
3647
3653
|
partitionSessionHostRecords: () => partitionSessionHostRecords,
|
|
3654
|
+
prepareSessionChatTailUpdate: () => prepareSessionChatTailUpdate,
|
|
3655
|
+
prepareSessionModalUpdate: () => prepareSessionModalUpdate,
|
|
3648
3656
|
probeCdpPort: () => probeCdpPort,
|
|
3649
3657
|
readChatHistory: () => readChatHistory,
|
|
3650
3658
|
recordDebugTrace: () => recordDebugTrace,
|
|
@@ -4036,6 +4044,27 @@ function getSavedProviderSessions(state, filters) {
|
|
|
4036
4044
|
var import_fs2 = require("fs");
|
|
4037
4045
|
var import_path2 = require("path");
|
|
4038
4046
|
init_config();
|
|
4047
|
+
|
|
4048
|
+
// src/providers/provider-session-id.ts
|
|
4049
|
+
var HERMES_SESSION_ID_RE = /^\d{8}_\d{6}_[a-z0-9]+$/i;
|
|
4050
|
+
function normalizeProviderSessionId(providerType, providerSessionId) {
|
|
4051
|
+
const normalizedProviderType = typeof providerType === "string" ? providerType.trim() : "";
|
|
4052
|
+
const normalizedId = typeof providerSessionId === "string" ? providerSessionId.trim() : "";
|
|
4053
|
+
if (!normalizedId) return "";
|
|
4054
|
+
const lowered = normalizedId.toLowerCase();
|
|
4055
|
+
if (lowered === "undefined" || lowered === "null") return "";
|
|
4056
|
+
if (normalizedProviderType === "hermes-cli" && !HERMES_SESSION_ID_RE.test(normalizedId)) {
|
|
4057
|
+
return "";
|
|
4058
|
+
}
|
|
4059
|
+
return normalizedId;
|
|
4060
|
+
}
|
|
4061
|
+
function isLegacyVolatileSessionReadKey(key) {
|
|
4062
|
+
const normalizedKey = typeof key === "string" ? key.trim() : "";
|
|
4063
|
+
if (!normalizedKey) return false;
|
|
4064
|
+
return normalizedKey.startsWith("provider:codex:vscode-webview://");
|
|
4065
|
+
}
|
|
4066
|
+
|
|
4067
|
+
// src/config/state-store.ts
|
|
4039
4068
|
var DEFAULT_STATE = {
|
|
4040
4069
|
recentActivity: [],
|
|
4041
4070
|
savedProviderSessions: [],
|
|
@@ -4050,15 +4079,31 @@ function getStatePath() {
|
|
|
4050
4079
|
}
|
|
4051
4080
|
function normalizeState(raw) {
|
|
4052
4081
|
const parsed = isPlainObject2(raw) ? raw : {};
|
|
4082
|
+
const recentActivity = (Array.isArray(parsed.recentActivity) ? parsed.recentActivity : []).filter((entry) => {
|
|
4083
|
+
if (!isPlainObject2(entry)) return false;
|
|
4084
|
+
const normalizedId = normalizeProviderSessionId(
|
|
4085
|
+
typeof entry.providerType === "string" ? entry.providerType : "",
|
|
4086
|
+
typeof entry.providerSessionId === "string" ? entry.providerSessionId : ""
|
|
4087
|
+
);
|
|
4088
|
+
if (typeof entry.providerSessionId === "string" && !normalizedId) return false;
|
|
4089
|
+
return true;
|
|
4090
|
+
});
|
|
4091
|
+
const savedProviderSessions = (Array.isArray(parsed.savedProviderSessions) ? parsed.savedProviderSessions : []).filter((entry) => {
|
|
4092
|
+
if (!isPlainObject2(entry)) return false;
|
|
4093
|
+
return !!normalizeProviderSessionId(
|
|
4094
|
+
typeof entry.providerType === "string" ? entry.providerType : "",
|
|
4095
|
+
typeof entry.providerSessionId === "string" ? entry.providerSessionId : ""
|
|
4096
|
+
);
|
|
4097
|
+
});
|
|
4053
4098
|
const sessionReads = Object.fromEntries(
|
|
4054
|
-
Object.entries(isPlainObject2(parsed.sessionReads) ? parsed.sessionReads : {}).filter(([, value]) => typeof value === "number" && Number.isFinite(value))
|
|
4099
|
+
Object.entries(isPlainObject2(parsed.sessionReads) ? parsed.sessionReads : {}).filter(([key, value]) => !isLegacyVolatileSessionReadKey(key) && typeof value === "number" && Number.isFinite(value))
|
|
4055
4100
|
);
|
|
4056
4101
|
const sessionReadMarkers = Object.fromEntries(
|
|
4057
|
-
Object.entries(isPlainObject2(parsed.sessionReadMarkers) ? parsed.sessionReadMarkers : {}).filter(([, value]) => typeof value === "string")
|
|
4102
|
+
Object.entries(isPlainObject2(parsed.sessionReadMarkers) ? parsed.sessionReadMarkers : {}).filter(([key, value]) => !isLegacyVolatileSessionReadKey(key) && typeof value === "string")
|
|
4058
4103
|
);
|
|
4059
4104
|
return {
|
|
4060
|
-
recentActivity
|
|
4061
|
-
savedProviderSessions
|
|
4105
|
+
recentActivity,
|
|
4106
|
+
savedProviderSessions,
|
|
4062
4107
|
sessionReads,
|
|
4063
4108
|
sessionReadMarkers
|
|
4064
4109
|
};
|
|
@@ -8412,6 +8457,32 @@ function reconcileIdeRuntimeSessions(instanceManager, sessionRegistry) {
|
|
|
8412
8457
|
// src/commands/handler.ts
|
|
8413
8458
|
init_logger();
|
|
8414
8459
|
|
|
8460
|
+
// src/commands/provider-script-resolver.ts
|
|
8461
|
+
function resolveLegacyProviderScript(fn, scriptName, params) {
|
|
8462
|
+
if (typeof fn !== "function") return null;
|
|
8463
|
+
if (params && typeof params === "object" && !Array.isArray(params) && Object.keys(params).length > 0) {
|
|
8464
|
+
const firstVal = Object.values(params)[0];
|
|
8465
|
+
if (scriptName === "sendMessage" && typeof firstVal === "string") {
|
|
8466
|
+
const legacyScript = fn(firstVal);
|
|
8467
|
+
if (legacyScript) return legacyScript;
|
|
8468
|
+
}
|
|
8469
|
+
const script = fn(params);
|
|
8470
|
+
const likelyLegacyObjectLeak = typeof script === "string" && script.includes("[object Object]") && typeof firstVal === "string";
|
|
8471
|
+
if (!likelyLegacyObjectLeak && script) return script;
|
|
8472
|
+
if (firstVal !== void 0) {
|
|
8473
|
+
const legacyScript = fn(firstVal);
|
|
8474
|
+
if (legacyScript) return legacyScript;
|
|
8475
|
+
}
|
|
8476
|
+
if (script) return script;
|
|
8477
|
+
return null;
|
|
8478
|
+
}
|
|
8479
|
+
if (params !== void 0) {
|
|
8480
|
+
const script = fn(params);
|
|
8481
|
+
if (script) return script;
|
|
8482
|
+
}
|
|
8483
|
+
return fn() || null;
|
|
8484
|
+
}
|
|
8485
|
+
|
|
8415
8486
|
// src/commands/chat-commands.ts
|
|
8416
8487
|
init_contracts();
|
|
8417
8488
|
|
|
@@ -8600,10 +8671,7 @@ function createInteractionId(prefix = "ix") {
|
|
|
8600
8671
|
return `${prefix}_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 8)}`;
|
|
8601
8672
|
}
|
|
8602
8673
|
|
|
8603
|
-
// src/
|
|
8604
|
-
init_chat_message_normalization();
|
|
8605
|
-
var RECENT_SEND_WINDOW_MS = 1200;
|
|
8606
|
-
var recentSendByTarget = /* @__PURE__ */ new Map();
|
|
8674
|
+
// src/chat/chat-signatures.ts
|
|
8607
8675
|
function hashSignatureParts(parts) {
|
|
8608
8676
|
let hash = 2166136261;
|
|
8609
8677
|
for (const part of parts) {
|
|
@@ -8617,6 +8685,58 @@ function hashSignatureParts(parts) {
|
|
|
8617
8685
|
}
|
|
8618
8686
|
return hash.toString(16).padStart(8, "0");
|
|
8619
8687
|
}
|
|
8688
|
+
function stringifySignatureContent(content) {
|
|
8689
|
+
try {
|
|
8690
|
+
return JSON.stringify(content ?? "");
|
|
8691
|
+
} catch {
|
|
8692
|
+
return String(content ?? "");
|
|
8693
|
+
}
|
|
8694
|
+
}
|
|
8695
|
+
function stringifySignatureMessages(messages) {
|
|
8696
|
+
try {
|
|
8697
|
+
return JSON.stringify(messages);
|
|
8698
|
+
} catch {
|
|
8699
|
+
return String(messages.length);
|
|
8700
|
+
}
|
|
8701
|
+
}
|
|
8702
|
+
function buildChatMessageSignature(message) {
|
|
8703
|
+
if (!message) return "";
|
|
8704
|
+
return hashSignatureParts([
|
|
8705
|
+
String(message.id || ""),
|
|
8706
|
+
String(message.index ?? ""),
|
|
8707
|
+
String(message.role || ""),
|
|
8708
|
+
String(message.receivedAt ?? message.timestamp ?? ""),
|
|
8709
|
+
stringifySignatureContent(message.content)
|
|
8710
|
+
]);
|
|
8711
|
+
}
|
|
8712
|
+
function buildChatTailDeliverySignature(payload) {
|
|
8713
|
+
return hashSignatureParts([
|
|
8714
|
+
payload.sessionId,
|
|
8715
|
+
payload.historySessionId || "",
|
|
8716
|
+
payload.status,
|
|
8717
|
+
payload.title || "",
|
|
8718
|
+
payload.syncMode,
|
|
8719
|
+
String(payload.replaceFrom),
|
|
8720
|
+
String(payload.totalMessages),
|
|
8721
|
+
payload.lastMessageSignature,
|
|
8722
|
+
payload.activeModal ? `${payload.activeModal.message}|${payload.activeModal.buttons.join("")}` : "",
|
|
8723
|
+
stringifySignatureMessages(payload.messages)
|
|
8724
|
+
]);
|
|
8725
|
+
}
|
|
8726
|
+
function buildSessionModalDeliverySignature(payload) {
|
|
8727
|
+
return hashSignatureParts([
|
|
8728
|
+
payload.sessionId,
|
|
8729
|
+
payload.status,
|
|
8730
|
+
payload.title || "",
|
|
8731
|
+
payload.modalMessage || "",
|
|
8732
|
+
Array.isArray(payload.modalButtons) ? payload.modalButtons.join("") : ""
|
|
8733
|
+
]);
|
|
8734
|
+
}
|
|
8735
|
+
|
|
8736
|
+
// src/commands/chat-commands.ts
|
|
8737
|
+
init_chat_message_normalization();
|
|
8738
|
+
var RECENT_SEND_WINDOW_MS = 1200;
|
|
8739
|
+
var recentSendByTarget = /* @__PURE__ */ new Map();
|
|
8620
8740
|
function getCurrentProviderType(h, fallback = "") {
|
|
8621
8741
|
return h.currentSession?.providerType || h.currentProviderType || fallback;
|
|
8622
8742
|
}
|
|
@@ -8713,20 +8833,7 @@ function parseMaybeJson(value) {
|
|
|
8713
8833
|
}
|
|
8714
8834
|
}
|
|
8715
8835
|
function getChatMessageSignature(message) {
|
|
8716
|
-
|
|
8717
|
-
let content = "";
|
|
8718
|
-
try {
|
|
8719
|
-
content = JSON.stringify(message.content ?? "");
|
|
8720
|
-
} catch {
|
|
8721
|
-
content = String(message.content ?? "");
|
|
8722
|
-
}
|
|
8723
|
-
return hashSignatureParts([
|
|
8724
|
-
String(message.id || ""),
|
|
8725
|
-
String(message.index ?? ""),
|
|
8726
|
-
String(message.role || ""),
|
|
8727
|
-
String(message.receivedAt ?? message.timestamp ?? ""),
|
|
8728
|
-
content
|
|
8729
|
-
]);
|
|
8836
|
+
return buildChatMessageSignature(message);
|
|
8730
8837
|
}
|
|
8731
8838
|
function normalizeReadChatCursor(args) {
|
|
8732
8839
|
const knownMessageCount = Math.max(0, Number(args?.knownMessageCount || 0));
|
|
@@ -10774,27 +10881,7 @@ var DaemonCommandHandler = class {
|
|
|
10774
10881
|
if (provider?.scripts) {
|
|
10775
10882
|
const fn = provider.scripts[scriptName];
|
|
10776
10883
|
if (typeof fn === "function") {
|
|
10777
|
-
|
|
10778
|
-
if (params && Object.keys(params).length > 0) {
|
|
10779
|
-
const firstVal = Object.values(params)[0];
|
|
10780
|
-
if (scriptName === "sendMessage" && typeof firstVal === "string") {
|
|
10781
|
-
const legacyScript = callScript(firstVal);
|
|
10782
|
-
if (legacyScript) return legacyScript;
|
|
10783
|
-
}
|
|
10784
|
-
const script = callScript(params);
|
|
10785
|
-
if (script) {
|
|
10786
|
-
const likelyLegacyObjectLeak = typeof script === "string" && script.includes("[object Object]") && typeof firstVal === "string";
|
|
10787
|
-
if (!likelyLegacyObjectLeak) return script;
|
|
10788
|
-
}
|
|
10789
|
-
if (firstVal !== void 0) {
|
|
10790
|
-
const legacyScript = callScript(firstVal);
|
|
10791
|
-
if (legacyScript) return legacyScript;
|
|
10792
|
-
}
|
|
10793
|
-
if (script) return script;
|
|
10794
|
-
} else {
|
|
10795
|
-
const script = callScript();
|
|
10796
|
-
if (script) return script;
|
|
10797
|
-
}
|
|
10884
|
+
return resolveLegacyProviderScript(fn, scriptName, params);
|
|
10798
10885
|
}
|
|
10799
10886
|
}
|
|
10800
10887
|
return null;
|
|
@@ -11389,7 +11476,10 @@ var CliProviderInstance = class {
|
|
|
11389
11476
|
const parsedStatus = this.adapter.getScriptParsedStatus?.() || null;
|
|
11390
11477
|
const autoApproveActive = adapterStatus.status === "waiting_approval" && this.shouldAutoApprove();
|
|
11391
11478
|
const visibleStatus = autoApproveActive ? "generating" : adapterStatus.status;
|
|
11392
|
-
const parsedProviderSessionId =
|
|
11479
|
+
const parsedProviderSessionId = normalizeProviderSessionId(
|
|
11480
|
+
this.type,
|
|
11481
|
+
typeof parsedStatus?.providerSessionId === "string" ? parsedStatus.providerSessionId : ""
|
|
11482
|
+
);
|
|
11393
11483
|
if (parsedProviderSessionId) {
|
|
11394
11484
|
this.promoteProviderSessionId(parsedProviderSessionId);
|
|
11395
11485
|
}
|
|
@@ -11653,7 +11743,10 @@ var CliProviderInstance = class {
|
|
|
11653
11743
|
}
|
|
11654
11744
|
applyProviderResponse(data, options) {
|
|
11655
11745
|
if (!data || typeof data !== "object") return;
|
|
11656
|
-
const patchedProviderSessionId =
|
|
11746
|
+
const patchedProviderSessionId = normalizeProviderSessionId(
|
|
11747
|
+
this.type,
|
|
11748
|
+
typeof data.providerSessionId === "string" ? data.providerSessionId : ""
|
|
11749
|
+
);
|
|
11657
11750
|
if (patchedProviderSessionId) {
|
|
11658
11751
|
this.promoteProviderSessionId(patchedProviderSessionId);
|
|
11659
11752
|
}
|
|
@@ -17233,6 +17326,141 @@ init_logger();
|
|
|
17233
17326
|
var DEFAULT_DAEMON_PORT = 19222;
|
|
17234
17327
|
var DAEMON_WS_PATH = "/ipc";
|
|
17235
17328
|
|
|
17329
|
+
// src/chat/subscription-updates.ts
|
|
17330
|
+
function normalizeSyncMode(syncMode) {
|
|
17331
|
+
return syncMode === "append" || syncMode === "replace_tail" || syncMode === "noop" || syncMode === "full" ? syncMode : "full";
|
|
17332
|
+
}
|
|
17333
|
+
function normalizeModalButtons(value) {
|
|
17334
|
+
return Array.isArray(value) ? value.filter((button) => typeof button === "string") : [];
|
|
17335
|
+
}
|
|
17336
|
+
function normalizeModalMessage(value) {
|
|
17337
|
+
return typeof value === "string" ? value : void 0;
|
|
17338
|
+
}
|
|
17339
|
+
function normalizeChatTailActiveModal(activeModal) {
|
|
17340
|
+
if (!activeModal || typeof activeModal !== "object") return null;
|
|
17341
|
+
const message = normalizeModalMessage(activeModal.message);
|
|
17342
|
+
if (!message) return null;
|
|
17343
|
+
const rawButtons = activeModal.buttons;
|
|
17344
|
+
if (!Array.isArray(rawButtons)) return null;
|
|
17345
|
+
return {
|
|
17346
|
+
message,
|
|
17347
|
+
buttons: normalizeModalButtons(rawButtons)
|
|
17348
|
+
};
|
|
17349
|
+
}
|
|
17350
|
+
function normalizeSessionModalFields(activeModal) {
|
|
17351
|
+
if (!activeModal || typeof activeModal !== "object") {
|
|
17352
|
+
return { modalButtons: [] };
|
|
17353
|
+
}
|
|
17354
|
+
return {
|
|
17355
|
+
modalMessage: normalizeModalMessage(activeModal.message),
|
|
17356
|
+
modalButtons: normalizeModalButtons(activeModal.buttons)
|
|
17357
|
+
};
|
|
17358
|
+
}
|
|
17359
|
+
function buildNextChatCursor(cursor, result) {
|
|
17360
|
+
return {
|
|
17361
|
+
knownMessageCount: Math.max(0, Number(result.totalMessages || cursor.knownMessageCount)),
|
|
17362
|
+
lastMessageSignature: typeof result.lastMessageSignature === "string" ? result.lastMessageSignature : cursor.lastMessageSignature,
|
|
17363
|
+
tailLimit: cursor.tailLimit
|
|
17364
|
+
};
|
|
17365
|
+
}
|
|
17366
|
+
function prepareSessionChatTailUpdate(input) {
|
|
17367
|
+
const result = input.result;
|
|
17368
|
+
if (!result?.success || result.syncMode === "noop") {
|
|
17369
|
+
return {
|
|
17370
|
+
cursor: result?.success ? buildNextChatCursor(input.cursor, result) : input.cursor,
|
|
17371
|
+
seq: input.seq,
|
|
17372
|
+
lastDeliveredSignature: input.lastDeliveredSignature,
|
|
17373
|
+
update: null
|
|
17374
|
+
};
|
|
17375
|
+
}
|
|
17376
|
+
const syncMode = normalizeSyncMode(result.syncMode);
|
|
17377
|
+
const cursor = {
|
|
17378
|
+
knownMessageCount: Math.max(0, Number(result.totalMessages || 0)),
|
|
17379
|
+
lastMessageSignature: typeof result.lastMessageSignature === "string" ? result.lastMessageSignature : "",
|
|
17380
|
+
tailLimit: input.cursor.tailLimit
|
|
17381
|
+
};
|
|
17382
|
+
const title = typeof result.title === "string" ? result.title : void 0;
|
|
17383
|
+
const activeModal = normalizeChatTailActiveModal(result.activeModal);
|
|
17384
|
+
const status = typeof result.status === "string" ? result.status : "idle";
|
|
17385
|
+
const deliverySignature = buildChatTailDeliverySignature({
|
|
17386
|
+
sessionId: input.sessionId,
|
|
17387
|
+
...input.historySessionId ? { historySessionId: input.historySessionId } : {},
|
|
17388
|
+
messages: Array.isArray(result.messages) ? result.messages : [],
|
|
17389
|
+
status,
|
|
17390
|
+
...title ? { title } : {},
|
|
17391
|
+
...activeModal ? { activeModal } : {},
|
|
17392
|
+
syncMode,
|
|
17393
|
+
replaceFrom: Number(result.replaceFrom || 0),
|
|
17394
|
+
totalMessages: Number(result.totalMessages || 0),
|
|
17395
|
+
lastMessageSignature: typeof result.lastMessageSignature === "string" ? result.lastMessageSignature : ""
|
|
17396
|
+
});
|
|
17397
|
+
const seq = input.seq + 1;
|
|
17398
|
+
if (deliverySignature === input.lastDeliveredSignature) {
|
|
17399
|
+
return {
|
|
17400
|
+
cursor,
|
|
17401
|
+
seq,
|
|
17402
|
+
lastDeliveredSignature: input.lastDeliveredSignature,
|
|
17403
|
+
update: null
|
|
17404
|
+
};
|
|
17405
|
+
}
|
|
17406
|
+
return {
|
|
17407
|
+
cursor,
|
|
17408
|
+
seq,
|
|
17409
|
+
lastDeliveredSignature: deliverySignature,
|
|
17410
|
+
update: {
|
|
17411
|
+
topic: "session.chat_tail",
|
|
17412
|
+
key: input.key,
|
|
17413
|
+
sessionId: input.sessionId,
|
|
17414
|
+
...input.historySessionId ? { historySessionId: input.historySessionId } : {},
|
|
17415
|
+
...input.interactionId ? { interactionId: input.interactionId } : {},
|
|
17416
|
+
seq,
|
|
17417
|
+
timestamp: input.timestamp,
|
|
17418
|
+
messages: Array.isArray(result.messages) ? result.messages : [],
|
|
17419
|
+
status,
|
|
17420
|
+
...title ? { title } : {},
|
|
17421
|
+
...activeModal ? { activeModal } : {},
|
|
17422
|
+
syncMode,
|
|
17423
|
+
replaceFrom: Number(result.replaceFrom || 0),
|
|
17424
|
+
totalMessages: Number(result.totalMessages || 0),
|
|
17425
|
+
lastMessageSignature: typeof result.lastMessageSignature === "string" ? result.lastMessageSignature : ""
|
|
17426
|
+
}
|
|
17427
|
+
};
|
|
17428
|
+
}
|
|
17429
|
+
function prepareSessionModalUpdate(input) {
|
|
17430
|
+
const { modalMessage, modalButtons } = normalizeSessionModalFields(input.activeModal);
|
|
17431
|
+
const deliverySignature = buildSessionModalDeliverySignature({
|
|
17432
|
+
sessionId: input.sessionId,
|
|
17433
|
+
status: input.status,
|
|
17434
|
+
...input.title ? { title: input.title } : {},
|
|
17435
|
+
...modalMessage ? { modalMessage } : {},
|
|
17436
|
+
...modalButtons.length > 0 ? { modalButtons } : {}
|
|
17437
|
+
});
|
|
17438
|
+
if (deliverySignature === input.lastDeliveredSignature) {
|
|
17439
|
+
return {
|
|
17440
|
+
seq: input.seq,
|
|
17441
|
+
lastDeliveredSignature: input.lastDeliveredSignature,
|
|
17442
|
+
update: null
|
|
17443
|
+
};
|
|
17444
|
+
}
|
|
17445
|
+
const seq = input.seq + 1;
|
|
17446
|
+
return {
|
|
17447
|
+
seq,
|
|
17448
|
+
lastDeliveredSignature: deliverySignature,
|
|
17449
|
+
update: {
|
|
17450
|
+
topic: "session.modal",
|
|
17451
|
+
key: input.key,
|
|
17452
|
+
sessionId: input.sessionId,
|
|
17453
|
+
status: input.status,
|
|
17454
|
+
...input.title ? { title: input.title } : {},
|
|
17455
|
+
...modalMessage ? { modalMessage } : {},
|
|
17456
|
+
...modalButtons.length > 0 ? { modalButtons } : {},
|
|
17457
|
+
...input.interactionId ? { interactionId: input.interactionId } : {},
|
|
17458
|
+
seq,
|
|
17459
|
+
timestamp: input.timestamp
|
|
17460
|
+
}
|
|
17461
|
+
};
|
|
17462
|
+
}
|
|
17463
|
+
|
|
17236
17464
|
// src/agent-stream/provider-adapter.ts
|
|
17237
17465
|
init_read_chat_contract();
|
|
17238
17466
|
init_chat_message_normalization();
|
|
@@ -22427,7 +22655,8 @@ var DevServer = class _DevServer {
|
|
|
22427
22655
|
}
|
|
22428
22656
|
async handleRunScript(type, req, res, parsedBody) {
|
|
22429
22657
|
const body = parsedBody || await this.readBody(req);
|
|
22430
|
-
const { script: scriptName, params, ideType: scriptIdeType } = body;
|
|
22658
|
+
const { script: scriptName, params, args, ideType: scriptIdeType } = body;
|
|
22659
|
+
const rawParams = args !== void 0 ? args : params;
|
|
22431
22660
|
const provider = this.providerLoader.resolve(type);
|
|
22432
22661
|
if (!provider) {
|
|
22433
22662
|
this.json(res, 404, { error: `Provider '${type}' not found` });
|
|
@@ -22444,13 +22673,7 @@ var DevServer = class _DevServer {
|
|
|
22444
22673
|
return;
|
|
22445
22674
|
}
|
|
22446
22675
|
try {
|
|
22447
|
-
|
|
22448
|
-
if (["sendMessage", "webviewSendMessage", "switchSession", "webviewSwitchSession", "setMode", "webviewSetMode", "setModel", "webviewSetModel"].includes(scriptName)) {
|
|
22449
|
-
const firstVal = params && typeof params === "object" && Object.keys(params).length > 0 ? Object.values(params)[0] : params;
|
|
22450
|
-
scriptCode = firstVal !== void 0 ? fn(firstVal) : fn();
|
|
22451
|
-
} else {
|
|
22452
|
-
scriptCode = params !== void 0 ? fn(params) : fn();
|
|
22453
|
-
}
|
|
22676
|
+
const scriptCode = resolveLegacyProviderScript(fn, scriptName, rawParams);
|
|
22454
22677
|
if (!scriptCode) {
|
|
22455
22678
|
this.json(res, 500, { error: "Script function returned null" });
|
|
22456
22679
|
return;
|
|
@@ -22467,6 +22690,17 @@ var DevServer = class _DevServer {
|
|
|
22467
22690
|
break;
|
|
22468
22691
|
}
|
|
22469
22692
|
}
|
|
22693
|
+
if (!sessionId) {
|
|
22694
|
+
try {
|
|
22695
|
+
const discovered = await cdp.discoverAgentWebviews();
|
|
22696
|
+
const target = discovered.find((entry) => entry.agentType === type);
|
|
22697
|
+
if (target) {
|
|
22698
|
+
sessionId = await cdp.attachToAgent(target);
|
|
22699
|
+
}
|
|
22700
|
+
} catch (error) {
|
|
22701
|
+
this.log(`Extension attach fallback failed for ${type}: ${error?.message || String(error)}`);
|
|
22702
|
+
}
|
|
22703
|
+
}
|
|
22470
22704
|
if (sessionId) {
|
|
22471
22705
|
raw = await cdp.evaluateInSessionFrame(sessionId, scriptCode);
|
|
22472
22706
|
} else if (cdp.evaluateInWebviewFrame) {
|
|
@@ -24035,10 +24269,19 @@ var SessionHostPtyTransportFactory = class {
|
|
|
24035
24269
|
// src/session-host/app-name.ts
|
|
24036
24270
|
var DEFAULT_SESSION_HOST_APP_NAME = "adhdev";
|
|
24037
24271
|
var DEFAULT_STANDALONE_SESSION_HOST_APP_NAME = "adhdev-standalone";
|
|
24272
|
+
function validateStandaloneSessionHostAppName(explicit) {
|
|
24273
|
+
if (explicit !== DEFAULT_SESSION_HOST_APP_NAME) return;
|
|
24274
|
+
throw new Error(
|
|
24275
|
+
`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.`
|
|
24276
|
+
);
|
|
24277
|
+
}
|
|
24038
24278
|
function resolveSessionHostAppName(options = {}) {
|
|
24039
24279
|
const env = options.env || process.env;
|
|
24040
24280
|
const explicit = typeof env.ADHDEV_SESSION_HOST_NAME === "string" ? env.ADHDEV_SESSION_HOST_NAME.trim() : "";
|
|
24041
|
-
if (explicit)
|
|
24281
|
+
if (explicit) {
|
|
24282
|
+
if (options.standalone) validateStandaloneSessionHostAppName(explicit);
|
|
24283
|
+
return explicit;
|
|
24284
|
+
}
|
|
24042
24285
|
return options.standalone ? DEFAULT_STANDALONE_SESSION_HOST_APP_NAME : DEFAULT_SESSION_HOST_APP_NAME;
|
|
24043
24286
|
}
|
|
24044
24287
|
|
|
@@ -24613,9 +24856,12 @@ async function shutdownDaemonComponents(components) {
|
|
|
24613
24856
|
appendRecentActivity,
|
|
24614
24857
|
buildAssistantChatMessage,
|
|
24615
24858
|
buildChatMessage,
|
|
24859
|
+
buildChatMessageSignature,
|
|
24860
|
+
buildChatTailDeliverySignature,
|
|
24616
24861
|
buildMachineInfo,
|
|
24617
24862
|
buildRuntimeSystemChatMessage,
|
|
24618
24863
|
buildSessionEntries,
|
|
24864
|
+
buildSessionModalDeliverySignature,
|
|
24619
24865
|
buildStatusSnapshot,
|
|
24620
24866
|
buildSystemChatMessage,
|
|
24621
24867
|
buildTerminalChatMessage,
|
|
@@ -24651,6 +24897,7 @@ async function shutdownDaemonComponents(components) {
|
|
|
24651
24897
|
getSessionHostSurfaceKind,
|
|
24652
24898
|
getWorkspaceState,
|
|
24653
24899
|
hasCdpManager,
|
|
24900
|
+
hashSignatureParts,
|
|
24654
24901
|
initDaemonComponents,
|
|
24655
24902
|
installExtensions,
|
|
24656
24903
|
installGlobalInterceptor,
|
|
@@ -24676,12 +24923,16 @@ async function shutdownDaemonComponents(components) {
|
|
|
24676
24923
|
normalizeChatMessage,
|
|
24677
24924
|
normalizeChatMessageKind,
|
|
24678
24925
|
normalizeChatMessages,
|
|
24926
|
+
normalizeChatTailActiveModal,
|
|
24679
24927
|
normalizeInputEnvelope,
|
|
24680
24928
|
normalizeManagedStatus,
|
|
24681
24929
|
normalizeMessageParts,
|
|
24930
|
+
normalizeSessionModalFields,
|
|
24682
24931
|
parseProviderSourceConfigUpdate,
|
|
24683
24932
|
partitionSessionHostDiagnosticsSessions,
|
|
24684
24933
|
partitionSessionHostRecords,
|
|
24934
|
+
prepareSessionChatTailUpdate,
|
|
24935
|
+
prepareSessionModalUpdate,
|
|
24685
24936
|
probeCdpPort,
|
|
24686
24937
|
readChatHistory,
|
|
24687
24938
|
recordDebugTrace,
|