adhdev 0.9.8 → 0.9.10
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/cli/index.js +60 -14
- package/dist/cli/index.js.map +1 -1
- package/dist/index.js +60 -14
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -5813,6 +5813,18 @@ function validateRole(role, source, index) {
|
|
|
5813
5813
|
}
|
|
5814
5814
|
return role;
|
|
5815
5815
|
}
|
|
5816
|
+
function validateBubbleState(state, source, index) {
|
|
5817
|
+
if (typeof state !== "string" || !VALID_BUBBLE_STATES.includes(state)) {
|
|
5818
|
+
throw new Error(`${source}: messages[${index}].bubbleState must be one of ${VALID_BUBBLE_STATES.join(", ")}`);
|
|
5819
|
+
}
|
|
5820
|
+
return state;
|
|
5821
|
+
}
|
|
5822
|
+
function validateTurnStatus(turnStatus, source) {
|
|
5823
|
+
if (typeof turnStatus !== "string" || !VALID_TURN_STATUSES.includes(turnStatus)) {
|
|
5824
|
+
throw new Error(`${source}: turnStatus must be one of ${VALID_TURN_STATUSES.join(", ")}`);
|
|
5825
|
+
}
|
|
5826
|
+
return turnStatus;
|
|
5827
|
+
}
|
|
5816
5828
|
function validateMessageContent(content, source, index) {
|
|
5817
5829
|
if (typeof content === "string") return content;
|
|
5818
5830
|
if (Array.isArray(content)) return normalizeMessageParts(content);
|
|
@@ -5828,6 +5840,9 @@ function validateMessage(message, source, index) {
|
|
|
5828
5840
|
};
|
|
5829
5841
|
if (typeof message.kind === "string") normalized.kind = message.kind;
|
|
5830
5842
|
if (typeof message.id === "string") normalized.id = message.id;
|
|
5843
|
+
if (typeof message.bubbleId === "string") normalized.bubbleId = message.bubbleId;
|
|
5844
|
+
if (typeof message.providerUnitKey === "string") normalized.providerUnitKey = message.providerUnitKey;
|
|
5845
|
+
if (message.bubbleState !== void 0) normalized.bubbleState = validateBubbleState(message.bubbleState, source, index);
|
|
5831
5846
|
if (isFiniteNumber(message.index)) normalized.index = message.index;
|
|
5832
5847
|
if (isFiniteNumber(message.timestamp)) normalized.timestamp = message.timestamp;
|
|
5833
5848
|
if (isFiniteNumber(message.receivedAt)) normalized.receivedAt = message.receivedAt;
|
|
@@ -5895,6 +5910,8 @@ function validateReadChatResultPayload(raw, source = "read_chat") {
|
|
|
5895
5910
|
if (activeModal !== void 0) normalized.activeModal = activeModal;
|
|
5896
5911
|
if (typeof raw.id === "string") normalized.id = raw.id;
|
|
5897
5912
|
if (typeof raw.title === "string") normalized.title = raw.title;
|
|
5913
|
+
if (typeof raw.currentTurnId === "string") normalized.currentTurnId = raw.currentTurnId;
|
|
5914
|
+
if (raw.turnStatus !== void 0) normalized.turnStatus = validateTurnStatus(raw.turnStatus, source);
|
|
5898
5915
|
if (typeof raw.agentType === "string") normalized.agentType = raw.agentType;
|
|
5899
5916
|
if (typeof raw.agentName === "string") normalized.agentName = raw.agentName;
|
|
5900
5917
|
if (typeof raw.extensionId === "string") normalized.extensionId = raw.extensionId;
|
|
@@ -5907,13 +5924,15 @@ function validateReadChatResultPayload(raw, source = "read_chat") {
|
|
|
5907
5924
|
if (typeof raw.providerSessionId === "string") normalized.providerSessionId = raw.providerSessionId;
|
|
5908
5925
|
return normalized;
|
|
5909
5926
|
}
|
|
5910
|
-
var VALID_STATUSES, VALID_ROLES;
|
|
5927
|
+
var VALID_STATUSES, VALID_ROLES, VALID_BUBBLE_STATES, VALID_TURN_STATUSES;
|
|
5911
5928
|
var init_read_chat_contract = __esm({
|
|
5912
5929
|
"../../oss/packages/daemon-core/src/providers/read-chat-contract.ts"() {
|
|
5913
5930
|
"use strict";
|
|
5914
5931
|
init_contracts();
|
|
5915
5932
|
VALID_STATUSES = ["idle", "generating", "waiting_approval", "error", "panel_hidden", "streaming", "long_generating"];
|
|
5916
5933
|
VALID_ROLES = ["user", "assistant", "system", "human"];
|
|
5934
|
+
VALID_BUBBLE_STATES = ["draft", "streaming", "final", "removed"];
|
|
5935
|
+
VALID_TURN_STATUSES = ["open", "waiting_approval", "complete", "error"];
|
|
5917
5936
|
}
|
|
5918
5937
|
});
|
|
5919
5938
|
|
|
@@ -8026,7 +8045,7 @@ function didProviderConfirmSend(result) {
|
|
|
8026
8045
|
}
|
|
8027
8046
|
async function readExtensionChatState(h) {
|
|
8028
8047
|
try {
|
|
8029
|
-
const evalResult = await h.evaluateProviderScript("readChat", void 0,
|
|
8048
|
+
const evalResult = await h.evaluateProviderScript("readChat", void 0, READ_CHAT_PROVIDER_EVAL_TIMEOUT_MS);
|
|
8030
8049
|
if (!evalResult?.result) return null;
|
|
8031
8050
|
const parsed = parseMaybeJson(evalResult.result);
|
|
8032
8051
|
return parsed && typeof parsed === "object" ? parsed : null;
|
|
@@ -8114,7 +8133,7 @@ async function handleReadChat(h, args) {
|
|
|
8114
8133
|
const title = typeof parsedRecord?.title === "string" ? parsedRecord.title : void 0;
|
|
8115
8134
|
const providerSessionId = typeof parsedRecord?.providerSessionId === "string" ? parsedRecord.providerSessionId : void 0;
|
|
8116
8135
|
if (status) {
|
|
8117
|
-
LOG.
|
|
8136
|
+
LOG.debug("Command", `[read_chat] cli-like resolved provider=${adapter.cliType} target=${String(args?.targetSessionId || "")} adapterStatus=${String(adapterStatus.status || "")} parsedStatus=${String(parsedRecord?.status || "")} shouldPreferAdapterMessages=${String(shouldPreferAdapterMessages)} adapterMsgCount=${Array.isArray(adapterStatus.messages) ? adapterStatus.messages.length : 0} parsedMsgCount=${Array.isArray(parsedRecord?.messages) ? parsedRecord.messages.length : 0} returnedMsgCount=${Array.isArray(status.messages) ? status.messages.length : 0}`);
|
|
8118
8137
|
return buildReadChatCommandResult({
|
|
8119
8138
|
messages: status.messages || [],
|
|
8120
8139
|
status: status.status,
|
|
@@ -8139,7 +8158,7 @@ async function handleReadChat(h, args) {
|
|
|
8139
8158
|
}
|
|
8140
8159
|
if (isExtensionTransport(transport)) {
|
|
8141
8160
|
try {
|
|
8142
|
-
const evalResult = await h.evaluateProviderScript("readChat", void 0,
|
|
8161
|
+
const evalResult = await h.evaluateProviderScript("readChat", void 0, READ_CHAT_PROVIDER_EVAL_TIMEOUT_MS);
|
|
8143
8162
|
if (evalResult?.result) {
|
|
8144
8163
|
let parsed = evalResult.result;
|
|
8145
8164
|
if (typeof parsed === "string") {
|
|
@@ -8243,7 +8262,7 @@ async function handleReadChat(h, args) {
|
|
|
8243
8262
|
const script = h.getProviderScript("readChat") || h.getProviderScript("read_chat");
|
|
8244
8263
|
if (script) {
|
|
8245
8264
|
try {
|
|
8246
|
-
const evalResult = await h.evaluateProviderScript("readChat", void 0,
|
|
8265
|
+
const evalResult = await h.evaluateProviderScript("readChat", void 0, READ_CHAT_PROVIDER_EVAL_TIMEOUT_MS);
|
|
8247
8266
|
if (evalResult?.result) {
|
|
8248
8267
|
let parsed = evalResult.result;
|
|
8249
8268
|
if (typeof parsed === "string") {
|
|
@@ -8947,7 +8966,7 @@ async function handleResolveAction(h, args) {
|
|
|
8947
8966
|
}
|
|
8948
8967
|
return { success: false, error: "resolveAction script not available for this provider" };
|
|
8949
8968
|
}
|
|
8950
|
-
var RECENT_SEND_WINDOW_MS, recentSendByTarget;
|
|
8969
|
+
var RECENT_SEND_WINDOW_MS, READ_CHAT_PROVIDER_EVAL_TIMEOUT_MS, recentSendByTarget;
|
|
8951
8970
|
var init_chat_commands = __esm({
|
|
8952
8971
|
"../../oss/packages/daemon-core/src/commands/chat-commands.ts"() {
|
|
8953
8972
|
"use strict";
|
|
@@ -8960,6 +8979,7 @@ var init_chat_commands = __esm({
|
|
|
8960
8979
|
init_chat_signatures();
|
|
8961
8980
|
init_chat_message_normalization();
|
|
8962
8981
|
RECENT_SEND_WINDOW_MS = 1200;
|
|
8982
|
+
READ_CHAT_PROVIDER_EVAL_TIMEOUT_MS = 25e3;
|
|
8963
8983
|
recentSendByTarget = /* @__PURE__ */ new Map();
|
|
8964
8984
|
}
|
|
8965
8985
|
});
|
|
@@ -12764,7 +12784,7 @@ var init_provider_cli_adapter = __esm({
|
|
|
12764
12784
|
sendDelayMs;
|
|
12765
12785
|
sendKey;
|
|
12766
12786
|
submitStrategy;
|
|
12767
|
-
static SCRIPT_STATUS_DEBOUNCE_MS =
|
|
12787
|
+
static SCRIPT_STATUS_DEBOUNCE_MS = 3e3;
|
|
12768
12788
|
/** Inject CLI scripts after construction (e.g. when resolved by ProviderLoader) */
|
|
12769
12789
|
setCliScripts(scripts) {
|
|
12770
12790
|
this.cliScripts = scripts;
|
|
@@ -14928,7 +14948,7 @@ var init_cli_provider_instance = __esm({
|
|
|
14928
14948
|
this.generatingDebouncePending = null;
|
|
14929
14949
|
}
|
|
14930
14950
|
this.generatingDebounceTimer = null;
|
|
14931
|
-
},
|
|
14951
|
+
}, 3e3);
|
|
14932
14952
|
} else if (newStatus === "waiting_approval") {
|
|
14933
14953
|
this.suppressIdleHistoryReplay = false;
|
|
14934
14954
|
if (this.generatingDebouncePending) {
|
|
@@ -14984,7 +15004,7 @@ var init_cli_provider_instance = __esm({
|
|
|
14984
15004
|
this.generatingStartedAt = 0;
|
|
14985
15005
|
}
|
|
14986
15006
|
this.completedDebounceTimer = null;
|
|
14987
|
-
},
|
|
15007
|
+
}, 3e3);
|
|
14988
15008
|
}
|
|
14989
15009
|
} else if (newStatus === "stopped") {
|
|
14990
15010
|
if (this.generatingDebounceTimer) {
|
|
@@ -87073,7 +87093,7 @@ var init_adhdev_daemon = __esm({
|
|
|
87073
87093
|
init_version();
|
|
87074
87094
|
init_src();
|
|
87075
87095
|
init_runtime_defaults();
|
|
87076
|
-
pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.
|
|
87096
|
+
pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.10" });
|
|
87077
87097
|
AdhdevDaemon = class _AdhdevDaemon {
|
|
87078
87098
|
localHttpServer = null;
|
|
87079
87099
|
localWss = null;
|
|
@@ -87097,6 +87117,7 @@ var init_adhdev_daemon = __esm({
|
|
|
87097
87117
|
mandatoryUpgradeInFlight = false;
|
|
87098
87118
|
debugConfig = resolveDebugRuntimeConfig();
|
|
87099
87119
|
recentInteractionIdsBySession = /* @__PURE__ */ new Map();
|
|
87120
|
+
ptyInputDropLogLastAt = /* @__PURE__ */ new Map();
|
|
87100
87121
|
static MANDATORY_UPDATE_BLOCKED_COMMANDS = /* @__PURE__ */ new Set([
|
|
87101
87122
|
"launch_ide",
|
|
87102
87123
|
"launch_cli",
|
|
@@ -87148,6 +87169,14 @@ var init_adhdev_daemon = __esm({
|
|
|
87148
87169
|
const mode = this.getCliPresentationMode(sessionId);
|
|
87149
87170
|
return mode === "chat" || mode === "terminal";
|
|
87150
87171
|
}
|
|
87172
|
+
logPtyInputDrop(sessionId, reason) {
|
|
87173
|
+
const key = `${sessionId || "(missing)"}:${reason}`;
|
|
87174
|
+
const now = Date.now();
|
|
87175
|
+
const last = this.ptyInputDropLogLastAt.get(key) || 0;
|
|
87176
|
+
if (now - last < 3e4) return;
|
|
87177
|
+
this.ptyInputDropLogLastAt.set(key, now);
|
|
87178
|
+
LOG.warn("P2P", `PTY input dropped: session=${sessionId || "(missing)"} reason=${reason}`);
|
|
87179
|
+
}
|
|
87151
87180
|
getUpgradePackageName() {
|
|
87152
87181
|
return process.argv[1]?.includes("daemon-standalone") ? "@adhdev/daemon-standalone" : "adhdev";
|
|
87153
87182
|
}
|
|
@@ -87260,9 +87289,13 @@ var init_adhdev_daemon = __esm({
|
|
|
87260
87289
|
});
|
|
87261
87290
|
}
|
|
87262
87291
|
getHotChatSessionIdsForP2PFlush() {
|
|
87263
|
-
const
|
|
87292
|
+
const sessions = buildSessionEntries(
|
|
87293
|
+
this.components.instanceManager.collectAllStates(),
|
|
87294
|
+
this.components.cdpManagers,
|
|
87295
|
+
{ profile: "live" }
|
|
87296
|
+
);
|
|
87264
87297
|
const hotSessions = classifyHotChatSessionsForSubscriptionFlush(
|
|
87265
|
-
|
|
87298
|
+
sessions,
|
|
87266
87299
|
this.hotP2PChatSessionIds
|
|
87267
87300
|
);
|
|
87268
87301
|
this.hotP2PChatSessionIds = hotSessions.active;
|
|
@@ -87587,10 +87620,23 @@ ${err?.stack || ""}`);
|
|
|
87587
87620
|
}
|
|
87588
87621
|
});
|
|
87589
87622
|
this.p2p.onPtyInput((sessionId, data) => {
|
|
87590
|
-
if (!this.isCliSession(sessionId))
|
|
87623
|
+
if (!this.isCliSession(sessionId)) {
|
|
87624
|
+
this.logPtyInputDrop(sessionId, "not_cli_session");
|
|
87625
|
+
return;
|
|
87626
|
+
}
|
|
87591
87627
|
const found = this.components.cliManager.findAdapter(sessionId, { instanceKey: sessionId });
|
|
87592
|
-
if (found
|
|
87628
|
+
if (!found) {
|
|
87629
|
+
this.logPtyInputDrop(sessionId, "adapter_not_found");
|
|
87630
|
+
return;
|
|
87631
|
+
}
|
|
87632
|
+
if (typeof found.adapter.writeRaw !== "function") {
|
|
87633
|
+
this.logPtyInputDrop(sessionId, "writeRaw_missing");
|
|
87634
|
+
return;
|
|
87635
|
+
}
|
|
87636
|
+
try {
|
|
87593
87637
|
found.adapter.writeRaw(data);
|
|
87638
|
+
} catch {
|
|
87639
|
+
this.logPtyInputDrop(sessionId, "write_failed");
|
|
87594
87640
|
}
|
|
87595
87641
|
});
|
|
87596
87642
|
this.p2p.onPtyResize((sessionId, cols, rows) => {
|