cclawd 1.0.1 → 1.0.2
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/{active-listener-Dkhmfuwx.js → active-listener-BLd27Pxd.js} +1 -1
- package/dist/{api-key-rotation-BOfI3cG3.js → api-key-rotation-Dg3JlNDQ.js} +1 -1
- package/dist/{audio-preflight-CtkZ5SAs.js → audio-preflight-eV5m9mMp.js} +6 -6
- package/dist/{audio-transcription-runner-CbPqoiHX.js → audio-transcription-runner-CQU4Eg1M.js} +6 -6
- package/dist/build-info.json +3 -3
- package/dist/bundled/boot-md/handler.js +23 -23
- package/dist/bundled/session-memory/handler.js +23 -23
- package/dist/{channel-activity-DWAER4wd.js → channel-activity-dT3cYb0e.js} +1 -1
- package/dist/{commands-registry-BUyiA7nE.js → commands-registry-CyLMCPuP.js} +1 -1
- package/dist/compact.runtime-DGRl4st4.js +39 -0
- package/dist/{deliver-aHOaRbkt.js → deliver-B6eTtXSk.js} +4 -4
- package/dist/{deliver-runtime-D4bCsr6d.js → deliver-runtime-CLDpY6AW.js} +7 -7
- package/dist/{deps-send-discord.runtime-BziKU-pE.js → deps-send-discord.runtime-CxADlame.js} +7 -7
- package/dist/{deps-send-imessage.runtime-CFRnDTqp.js → deps-send-imessage.runtime-Wi79xm6H.js} +7 -7
- package/dist/{deps-send-signal.runtime-BuOtABJm.js → deps-send-signal.runtime-BDtzvsnR.js} +6 -6
- package/dist/{deps-send-slack.runtime-BOLqvMxW.js → deps-send-slack.runtime-CgX24hgT.js} +5 -5
- package/dist/{deps-send-telegram.runtime-DeEoFLv5.js → deps-send-telegram.runtime-CEWc7ePn.js} +6 -6
- package/dist/deps-send-whatsapp.runtime-B1KJ7YOp.js +43 -0
- package/dist/{diagnostic-BdcXX9iJ.js → diagnostic-BZmAxdu9.js} +1 -1
- package/dist/{fetch-D9NUULbj.js → fetch-CMLoICyN.js} +2 -2
- package/dist/{fetch-guard-B5ZMnGaN.js → fetch-guard-DCj3k042.js} +1 -1
- package/dist/{image-4x07m4Jl.js → image-Bt49ybRv.js} +2 -2
- package/dist/{image-runtime-smkMrIol.js → image-runtime-Cilhq73U.js} +2 -2
- package/dist/{ir-CsgNUpOU.js → ir-CVtBjUiL.js} +2 -2
- package/dist/llm-slug-generator.js +23 -23
- package/dist/{login-p_O59TVQ.js → login-D0fUoX-p.js} +2 -2
- package/dist/{login-qr-BCJpDsAy.js → login-qr-ClBxstxZ.js} +2 -2
- package/dist/{manager-CwYv8O3T.js → manager-DSfEj66R.js} +3 -3
- package/dist/{manager-runtime-D_jEoBr9.js → manager-runtime-BrZlGJsj.js} +4 -4
- package/dist/{model-selection-Cv2Puf5z.js → model-selection-CMEj8bpy.js} +11 -11
- package/dist/{outbound-Chpiwybe.js → outbound-BxIJyMzV.js} +4 -4
- package/dist/{outbound-attachment-BnAVJDLe.js → outbound-attachment-CVJwpypG.js} +2 -2
- package/dist/{pi-embedded-CJVNBk0y.js → pi-embedded-CHNPEUAv.js} +57 -57
- package/dist/{pi-model-discovery-7IzK0Uc3.js → pi-model-discovery-D-r5y7kV.js} +1 -1
- package/dist/{pi-model-discovery-runtime-DABef3qy.js → pi-model-discovery-runtime-DZQXYmdu.js} +2 -2
- package/dist/{pi-tools.before-tool-call.runtime-BP2UvGJb.js → pi-tools.before-tool-call.runtime-DagGpfw0.js} +2 -2
- package/dist/plugin-sdk/compat.js +35 -35
- package/dist/{pw-ai-DwH5GpEO.js → pw-ai-CoIUdns_.js} +1 -1
- package/dist/{runtime-whatsapp-login.runtime-BI3U306v.js → runtime-whatsapp-login.runtime-ChqE9BkX.js} +3 -3
- package/dist/{runtime-whatsapp-outbound.runtime-Bsc2uD09.js → runtime-whatsapp-outbound.runtime-yiy6jzKk.js} +6 -6
- package/dist/{send-DtBvCnPQ.js → send-4rRrSKp9.js} +4 -4
- package/dist/{send-ORtn50qg.js → send-BKO1-P1t.js} +3 -3
- package/dist/{send-C-Q_WPMf.js → send-EDBPXjTT.js} +3 -3
- package/dist/{send-DUibfNQD.js → send-K2mAG7KC.js} +4 -4
- package/dist/{send-BDnOgWIp.js → send-V1MRV7QF.js} +3 -3
- package/dist/{session-B7imi6T5.js → session-CuVCho2m.js} +1 -1
- package/dist/{skill-commands-B9brPuiL.js → skill-commands-B55LOaMB.js} +2 -2
- package/dist/{slash-commands.runtime-Cf6ygfBp.js → slash-commands.runtime-BchS0VkW.js} +2 -2
- package/dist/{slash-dispatch.runtime-CsmvhO5K.js → slash-dispatch.runtime-BIKRY3fr.js} +23 -23
- package/dist/{slash-skill-commands.runtime-CX7stIEP.js → slash-skill-commands.runtime-BP4jBHU9.js} +3 -3
- package/dist/{subagent-registry-runtime-B_S1nf7y.js → subagent-registry-runtime-DjEYzSyM.js} +23 -23
- package/dist/{tables-CjQqTOdD.js → tables-BAGqh2XD.js} +1 -1
- package/dist/{target-errors-BZE1mc-W.js → target-errors-CeBF8Pws.js} +1 -1
- package/dist/{web-Cd8yK1Zq.js → web-BRSmQdtm.js} +27 -27
- package/dist/{whatsapp-actions-CYEzUMBI.js → whatsapp-actions-Dxb2K2Xh.js} +7 -7
- package/extensions/mfa-auth/index.ts +3 -3
- package/extensions/mfa-auth/src/notification-service.ts +2 -2
- package/package.json +458 -458
- package/dist/compact.runtime-DpcZpcTl.js +0 -39
- package/dist/deps-send-whatsapp.runtime-CG1uXYLY.js +0 -43
- package/dist/plugin-sdk/active-listener-CN-tMEvN.js +0 -35
- package/dist/plugin-sdk/api-key-rotation-CimGYMBc.js +0 -176
- package/dist/plugin-sdk/audio-preflight-C-xXBoE2.js +0 -51
- package/dist/plugin-sdk/audio-transcription-runner-CTIHpebA.js +0 -2173
- package/dist/plugin-sdk/audit-membership-runtime-BFatB2LJ.js +0 -58
- package/dist/plugin-sdk/channel-activity-DO0FEzyj.js +0 -95
- package/dist/plugin-sdk/channel-web-Da-__nUF.js +0 -2238
- package/dist/plugin-sdk/commands-registry-6no2NNrY.js +0 -1118
- package/dist/plugin-sdk/compact.runtime-CCoclu5e.js +0 -35
- package/dist/plugin-sdk/config-B9ODwgpz.js +0 -37426
- package/dist/plugin-sdk/deliver-B1fFpKjV.js +0 -1757
- package/dist/plugin-sdk/deliver-runtime-DB-VRMe1.js +0 -15
- package/dist/plugin-sdk/deps-send-discord.runtime-DklqycYG.js +0 -15
- package/dist/plugin-sdk/deps-send-imessage.runtime-Chs8zeon.js +0 -14
- package/dist/plugin-sdk/deps-send-signal.runtime-clW9aSJP.js +0 -13
- package/dist/plugin-sdk/deps-send-slack.runtime-BUx0LYY1.js +0 -13
- package/dist/plugin-sdk/deps-send-telegram.runtime-LECSHgMG.js +0 -16
- package/dist/plugin-sdk/deps-send-whatsapp.runtime-D2d65fw0.js +0 -40
- package/dist/plugin-sdk/diagnostic-CxIvS-C2.js +0 -315
- package/dist/plugin-sdk/dispatch-BqlR4dPx.js +0 -105863
- package/dist/plugin-sdk/env-b9k1PHMI.js +0 -34
- package/dist/plugin-sdk/fetch-PoxzAANT.js +0 -326
- package/dist/plugin-sdk/fetch-guard-4UVSZ0uS.js +0 -164
- package/dist/plugin-sdk/image-Ch6M4tnJ.js +0 -2420
- package/dist/plugin-sdk/image-runtime-CSh2o5wY.js +0 -8
- package/dist/plugin-sdk/ir-CugsqGH8.js +0 -1312
- package/dist/plugin-sdk/local-roots-adnEg9zb.js +0 -217
- package/dist/plugin-sdk/logger-D6zRubj0.js +0 -1164
- package/dist/plugin-sdk/login-CYvkQ0At.js +0 -54
- package/dist/plugin-sdk/login-qr-ll4NtaT5.js +0 -316
- package/dist/plugin-sdk/manager-CHy8IclH.js +0 -3959
- package/dist/plugin-sdk/manager-runtime-C70EkEr7.js +0 -11
- package/dist/plugin-sdk/outbound-Wzs2iN7X.js +0 -216
- package/dist/plugin-sdk/outbound-attachment-khXJwucX.js +0 -17
- package/dist/plugin-sdk/paths-BtVqCdw4.js +0 -3063
- package/dist/plugin-sdk/pi-model-discovery-Dh4ziodY.js +0 -131
- package/dist/plugin-sdk/pi-model-discovery-runtime-b83Xe-HT.js +0 -8
- package/dist/plugin-sdk/pi-tools.before-tool-call.runtime-C1z5CDBF.js +0 -349
- package/dist/plugin-sdk/proxy-fetch-CJEmoBxi.js +0 -54
- package/dist/plugin-sdk/pw-ai-Dj3Cvlzl.js +0 -1990
- package/dist/plugin-sdk/qmd-manager-egHUAseQ.js +0 -1581
- package/dist/plugin-sdk/resolve-outbound-target-BiICvIKs.js +0 -38
- package/dist/plugin-sdk/runtime-whatsapp-login.runtime-DNApufzW.js +0 -9
- package/dist/plugin-sdk/runtime-whatsapp-outbound.runtime-CBmtfIQ8.js +0 -13
- package/dist/plugin-sdk/send-CScblaI4.js +0 -532
- package/dist/plugin-sdk/send-CeHhnld6.js +0 -407
- package/dist/plugin-sdk/send-DP_c8JfR.js +0 -3277
- package/dist/plugin-sdk/send-Dc5fI6e8.js +0 -495
- package/dist/plugin-sdk/send-l-77_s1_.js +0 -2507
- package/dist/plugin-sdk/session-CkOKZaqa.js +0 -166
- package/dist/plugin-sdk/skill-commands-BohYCgkq.js +0 -336
- package/dist/plugin-sdk/slash-commands.runtime-DpLfVTM6.js +0 -8
- package/dist/plugin-sdk/slash-dispatch.runtime-CASMHwpm.js +0 -35
- package/dist/plugin-sdk/slash-skill-commands.runtime-D7rrJEci.js +0 -9
- package/dist/plugin-sdk/sqlite-CJE3X7Mv.js +0 -1005
- package/dist/plugin-sdk/subagent-registry-runtime-B1oo5bih.js +0 -35
- package/dist/plugin-sdk/tables-D5VgpTmm.js +0 -53
- package/dist/plugin-sdk/target-errors-C6zZ_OpA.js +0 -191
- package/dist/plugin-sdk/tokens-DUnJnpMS.js +0 -50
- package/dist/plugin-sdk/web-TfUM1nSi.js +0 -39
- package/dist/plugin-sdk/whatsapp-actions-DuWJ0j1r.js +0 -71
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import "./paths-BtVqCdw4.js";
|
|
2
|
-
import "./config-B9ODwgpz.js";
|
|
3
|
-
import "./paths-eFexkPEh.js";
|
|
4
|
-
import "./github-copilot-token-Cxf8QYZb.js";
|
|
5
|
-
import "./logger-D6zRubj0.js";
|
|
6
|
-
import "./env-b9k1PHMI.js";
|
|
7
|
-
import "./fetch-BSKpf2dM.js";
|
|
8
|
-
import "./fetch-guard-4UVSZ0uS.js";
|
|
9
|
-
import "./local-roots-adnEg9zb.js";
|
|
10
|
-
import "./ir-CugsqGH8.js";
|
|
11
|
-
import { t as deliverOutboundPayloads } from "./deliver-B1fFpKjV.js";
|
|
12
|
-
import "./tokens-DUnJnpMS.js";
|
|
13
|
-
import "./send-CScblaI4.js";
|
|
14
|
-
import "./outbound-attachment-khXJwucX.js";
|
|
15
|
-
export { deliverOutboundPayloads };
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import "./paths-BtVqCdw4.js";
|
|
2
|
-
import "./config-B9ODwgpz.js";
|
|
3
|
-
import "./paths-eFexkPEh.js";
|
|
4
|
-
import "./github-copilot-token-Cxf8QYZb.js";
|
|
5
|
-
import "./logger-D6zRubj0.js";
|
|
6
|
-
import "./env-b9k1PHMI.js";
|
|
7
|
-
import { h as sendMessageDiscord } from "./send-DP_c8JfR.js";
|
|
8
|
-
import "./fetch-BSKpf2dM.js";
|
|
9
|
-
import "./channel-activity-DO0FEzyj.js";
|
|
10
|
-
import "./fetch-guard-4UVSZ0uS.js";
|
|
11
|
-
import "./local-roots-adnEg9zb.js";
|
|
12
|
-
import "./ir-CugsqGH8.js";
|
|
13
|
-
import "./render-CKf6NJ1M.js";
|
|
14
|
-
import "./tables-D5VgpTmm.js";
|
|
15
|
-
export { sendMessageDiscord };
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import "./paths-BtVqCdw4.js";
|
|
2
|
-
import "./config-B9ODwgpz.js";
|
|
3
|
-
import "./paths-eFexkPEh.js";
|
|
4
|
-
import "./github-copilot-token-Cxf8QYZb.js";
|
|
5
|
-
import "./logger-D6zRubj0.js";
|
|
6
|
-
import "./env-b9k1PHMI.js";
|
|
7
|
-
import "./fetch-guard-4UVSZ0uS.js";
|
|
8
|
-
import "./local-roots-adnEg9zb.js";
|
|
9
|
-
import "./ir-CugsqGH8.js";
|
|
10
|
-
import "./render-CKf6NJ1M.js";
|
|
11
|
-
import "./tables-D5VgpTmm.js";
|
|
12
|
-
import "./outbound-attachment-khXJwucX.js";
|
|
13
|
-
import { t as sendMessageIMessage } from "./send-Dc5fI6e8.js";
|
|
14
|
-
export { sendMessageIMessage };
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import "./paths-BtVqCdw4.js";
|
|
2
|
-
import "./config-B9ODwgpz.js";
|
|
3
|
-
import "./paths-eFexkPEh.js";
|
|
4
|
-
import "./github-copilot-token-Cxf8QYZb.js";
|
|
5
|
-
import "./logger-D6zRubj0.js";
|
|
6
|
-
import "./env-b9k1PHMI.js";
|
|
7
|
-
import "./fetch-BSKpf2dM.js";
|
|
8
|
-
import "./fetch-guard-4UVSZ0uS.js";
|
|
9
|
-
import "./local-roots-adnEg9zb.js";
|
|
10
|
-
import "./ir-CugsqGH8.js";
|
|
11
|
-
import { t as sendMessageSignal } from "./send-CScblaI4.js";
|
|
12
|
-
import "./outbound-attachment-khXJwucX.js";
|
|
13
|
-
export { sendMessageSignal };
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import "./paths-BtVqCdw4.js";
|
|
2
|
-
import "./config-B9ODwgpz.js";
|
|
3
|
-
import "./paths-eFexkPEh.js";
|
|
4
|
-
import "./github-copilot-token-Cxf8QYZb.js";
|
|
5
|
-
import "./logger-D6zRubj0.js";
|
|
6
|
-
import "./env-b9k1PHMI.js";
|
|
7
|
-
import "./fetch-guard-4UVSZ0uS.js";
|
|
8
|
-
import "./local-roots-adnEg9zb.js";
|
|
9
|
-
import "./ir-CugsqGH8.js";
|
|
10
|
-
import "./render-CKf6NJ1M.js";
|
|
11
|
-
import { t as sendMessageSlack } from "./send-CeHhnld6.js";
|
|
12
|
-
import "./tokens-DUnJnpMS.js";
|
|
13
|
-
export { sendMessageSlack };
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import "./paths-BtVqCdw4.js";
|
|
2
|
-
import "./config-B9ODwgpz.js";
|
|
3
|
-
import "./paths-eFexkPEh.js";
|
|
4
|
-
import "./github-copilot-token-Cxf8QYZb.js";
|
|
5
|
-
import "./logger-D6zRubj0.js";
|
|
6
|
-
import "./env-b9k1PHMI.js";
|
|
7
|
-
import "./fetch-BSKpf2dM.js";
|
|
8
|
-
import "./channel-activity-DO0FEzyj.js";
|
|
9
|
-
import "./fetch-guard-4UVSZ0uS.js";
|
|
10
|
-
import "./local-roots-adnEg9zb.js";
|
|
11
|
-
import "./ir-CugsqGH8.js";
|
|
12
|
-
import "./render-CKf6NJ1M.js";
|
|
13
|
-
import { s as sendMessageTelegram } from "./send-l-77_s1_.js";
|
|
14
|
-
import "./proxy-fetch-CJEmoBxi.js";
|
|
15
|
-
import "./fetch-PoxzAANT.js";
|
|
16
|
-
export { sendMessageTelegram };
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import "./paths-BtVqCdw4.js";
|
|
2
|
-
import "./config-B9ODwgpz.js";
|
|
3
|
-
import "./dispatch-BqlR4dPx.js";
|
|
4
|
-
import "./paths-eFexkPEh.js";
|
|
5
|
-
import "./github-copilot-token-Cxf8QYZb.js";
|
|
6
|
-
import "./logger-D6zRubj0.js";
|
|
7
|
-
import "./env-b9k1PHMI.js";
|
|
8
|
-
import "./send-DP_c8JfR.js";
|
|
9
|
-
import "./fetch-BSKpf2dM.js";
|
|
10
|
-
import "./channel-activity-DO0FEzyj.js";
|
|
11
|
-
import "./fetch-guard-4UVSZ0uS.js";
|
|
12
|
-
import "./local-roots-adnEg9zb.js";
|
|
13
|
-
import "./ir-CugsqGH8.js";
|
|
14
|
-
import "./render-CKf6NJ1M.js";
|
|
15
|
-
import "./tables-D5VgpTmm.js";
|
|
16
|
-
import "./send-l-77_s1_.js";
|
|
17
|
-
import "./target-errors-C6zZ_OpA.js";
|
|
18
|
-
import "./send-CeHhnld6.js";
|
|
19
|
-
import "./deliver-B1fFpKjV.js";
|
|
20
|
-
import "./diagnostic-CxIvS-C2.js";
|
|
21
|
-
import "./pi-model-discovery-Dh4ziodY.js";
|
|
22
|
-
import "./audio-transcription-runner-CTIHpebA.js";
|
|
23
|
-
import "./image-Ch6M4tnJ.js";
|
|
24
|
-
import "./api-key-rotation-CimGYMBc.js";
|
|
25
|
-
import "./proxy-fetch-CJEmoBxi.js";
|
|
26
|
-
import "./tokens-DUnJnpMS.js";
|
|
27
|
-
import "./commands-registry-6no2NNrY.js";
|
|
28
|
-
import "./skill-commands-BohYCgkq.js";
|
|
29
|
-
import "./send-CScblaI4.js";
|
|
30
|
-
import "./outbound-attachment-khXJwucX.js";
|
|
31
|
-
import "./send-Dc5fI6e8.js";
|
|
32
|
-
import "./sqlite-CJE3X7Mv.js";
|
|
33
|
-
import "./fetch-PoxzAANT.js";
|
|
34
|
-
import "./manager-CHy8IclH.js";
|
|
35
|
-
import "./channel-web-Da-__nUF.js";
|
|
36
|
-
import { t as sendMessageWhatsApp } from "./outbound-Wzs2iN7X.js";
|
|
37
|
-
import "./session-CkOKZaqa.js";
|
|
38
|
-
import "./login-CYvkQ0At.js";
|
|
39
|
-
import "./web-TfUM1nSi.js";
|
|
40
|
-
export { sendMessageWhatsApp };
|
|
@@ -1,315 +0,0 @@
|
|
|
1
|
-
import { r as loadConfig } from "./config-B9ODwgpz.js";
|
|
2
|
-
import { a as createSubsystemLogger } from "./logger-D6zRubj0.js";
|
|
3
|
-
//#region src/infra/diagnostic-events.ts
|
|
4
|
-
function getDiagnosticEventsState() {
|
|
5
|
-
const globalStore = globalThis;
|
|
6
|
-
if (!globalStore.__openclawDiagnosticEventsState) globalStore.__openclawDiagnosticEventsState = {
|
|
7
|
-
seq: 0,
|
|
8
|
-
listeners: /* @__PURE__ */ new Set(),
|
|
9
|
-
dispatchDepth: 0
|
|
10
|
-
};
|
|
11
|
-
return globalStore.__openclawDiagnosticEventsState;
|
|
12
|
-
}
|
|
13
|
-
function isDiagnosticsEnabled(config) {
|
|
14
|
-
return config?.diagnostics?.enabled === true;
|
|
15
|
-
}
|
|
16
|
-
function emitDiagnosticEvent(event) {
|
|
17
|
-
const state = getDiagnosticEventsState();
|
|
18
|
-
if (state.dispatchDepth > 100) {
|
|
19
|
-
console.error(`[diagnostic-events] recursion guard tripped at depth=${state.dispatchDepth}, dropping type=${event.type}`);
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
const enriched = {
|
|
23
|
-
...event,
|
|
24
|
-
seq: state.seq += 1,
|
|
25
|
-
ts: Date.now()
|
|
26
|
-
};
|
|
27
|
-
state.dispatchDepth += 1;
|
|
28
|
-
for (const listener of state.listeners) try {
|
|
29
|
-
listener(enriched);
|
|
30
|
-
} catch (err) {
|
|
31
|
-
const errorMessage = err instanceof Error ? err.stack ?? err.message : typeof err === "string" ? err : String(err);
|
|
32
|
-
console.error(`[diagnostic-events] listener error type=${enriched.type} seq=${enriched.seq}: ${errorMessage}`);
|
|
33
|
-
}
|
|
34
|
-
state.dispatchDepth -= 1;
|
|
35
|
-
}
|
|
36
|
-
function onDiagnosticEvent(listener) {
|
|
37
|
-
const state = getDiagnosticEventsState();
|
|
38
|
-
state.listeners.add(listener);
|
|
39
|
-
return () => {
|
|
40
|
-
state.listeners.delete(listener);
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
//#endregion
|
|
44
|
-
//#region src/logging/diagnostic-session-state.ts
|
|
45
|
-
const diagnosticSessionStates = /* @__PURE__ */ new Map();
|
|
46
|
-
const SESSION_STATE_TTL_MS = 1800 * 1e3;
|
|
47
|
-
const SESSION_STATE_PRUNE_INTERVAL_MS = 60 * 1e3;
|
|
48
|
-
const SESSION_STATE_MAX_ENTRIES = 2e3;
|
|
49
|
-
let lastSessionPruneAt = 0;
|
|
50
|
-
function pruneDiagnosticSessionStates(now = Date.now(), force = false) {
|
|
51
|
-
const shouldPruneForSize = diagnosticSessionStates.size > SESSION_STATE_MAX_ENTRIES;
|
|
52
|
-
if (!force && !shouldPruneForSize && now - lastSessionPruneAt < SESSION_STATE_PRUNE_INTERVAL_MS) return;
|
|
53
|
-
lastSessionPruneAt = now;
|
|
54
|
-
for (const [key, state] of diagnosticSessionStates.entries()) {
|
|
55
|
-
const ageMs = now - state.lastActivity;
|
|
56
|
-
if (state.state === "idle" && state.queueDepth <= 0 && ageMs > SESSION_STATE_TTL_MS) diagnosticSessionStates.delete(key);
|
|
57
|
-
}
|
|
58
|
-
if (diagnosticSessionStates.size <= SESSION_STATE_MAX_ENTRIES) return;
|
|
59
|
-
const excess = diagnosticSessionStates.size - SESSION_STATE_MAX_ENTRIES;
|
|
60
|
-
const ordered = Array.from(diagnosticSessionStates.entries()).toSorted((a, b) => a[1].lastActivity - b[1].lastActivity);
|
|
61
|
-
for (let i = 0; i < excess; i += 1) {
|
|
62
|
-
const key = ordered[i]?.[0];
|
|
63
|
-
if (!key) break;
|
|
64
|
-
diagnosticSessionStates.delete(key);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
function resolveSessionKey({ sessionKey, sessionId }) {
|
|
68
|
-
return sessionKey ?? sessionId ?? "unknown";
|
|
69
|
-
}
|
|
70
|
-
function findStateBySessionId(sessionId) {
|
|
71
|
-
for (const state of diagnosticSessionStates.values()) if (state.sessionId === sessionId) return state;
|
|
72
|
-
}
|
|
73
|
-
function getDiagnosticSessionState(ref) {
|
|
74
|
-
pruneDiagnosticSessionStates();
|
|
75
|
-
const key = resolveSessionKey(ref);
|
|
76
|
-
const existing = diagnosticSessionStates.get(key) ?? (ref.sessionId && findStateBySessionId(ref.sessionId));
|
|
77
|
-
if (existing) {
|
|
78
|
-
if (ref.sessionId) existing.sessionId = ref.sessionId;
|
|
79
|
-
if (ref.sessionKey) existing.sessionKey = ref.sessionKey;
|
|
80
|
-
return existing;
|
|
81
|
-
}
|
|
82
|
-
const created = {
|
|
83
|
-
sessionId: ref.sessionId,
|
|
84
|
-
sessionKey: ref.sessionKey,
|
|
85
|
-
lastActivity: Date.now(),
|
|
86
|
-
state: "idle",
|
|
87
|
-
queueDepth: 0
|
|
88
|
-
};
|
|
89
|
-
diagnosticSessionStates.set(key, created);
|
|
90
|
-
pruneDiagnosticSessionStates(Date.now(), true);
|
|
91
|
-
return created;
|
|
92
|
-
}
|
|
93
|
-
//#endregion
|
|
94
|
-
//#region src/logging/diagnostic.ts
|
|
95
|
-
const diag = createSubsystemLogger("diagnostic");
|
|
96
|
-
const webhookStats = {
|
|
97
|
-
received: 0,
|
|
98
|
-
processed: 0,
|
|
99
|
-
errors: 0,
|
|
100
|
-
lastReceived: 0
|
|
101
|
-
};
|
|
102
|
-
let lastActivityAt = 0;
|
|
103
|
-
const DEFAULT_STUCK_SESSION_WARN_MS = 12e4;
|
|
104
|
-
const MIN_STUCK_SESSION_WARN_MS = 1e3;
|
|
105
|
-
const MAX_STUCK_SESSION_WARN_MS = 1440 * 60 * 1e3;
|
|
106
|
-
let commandPollBackoffRuntimePromise = null;
|
|
107
|
-
function loadCommandPollBackoffRuntime() {
|
|
108
|
-
commandPollBackoffRuntimePromise ??= import("./command-poll-backoff.runtime-DSESnhU1.js");
|
|
109
|
-
return commandPollBackoffRuntimePromise;
|
|
110
|
-
}
|
|
111
|
-
function markActivity() {
|
|
112
|
-
lastActivityAt = Date.now();
|
|
113
|
-
}
|
|
114
|
-
function resolveStuckSessionWarnMs(config) {
|
|
115
|
-
const raw = config?.diagnostics?.stuckSessionWarnMs;
|
|
116
|
-
if (typeof raw !== "number" || !Number.isFinite(raw)) return DEFAULT_STUCK_SESSION_WARN_MS;
|
|
117
|
-
const rounded = Math.floor(raw);
|
|
118
|
-
if (rounded < MIN_STUCK_SESSION_WARN_MS || rounded > MAX_STUCK_SESSION_WARN_MS) return DEFAULT_STUCK_SESSION_WARN_MS;
|
|
119
|
-
return rounded;
|
|
120
|
-
}
|
|
121
|
-
function logWebhookReceived(params) {
|
|
122
|
-
webhookStats.received += 1;
|
|
123
|
-
webhookStats.lastReceived = Date.now();
|
|
124
|
-
if (diag.isEnabled("debug")) diag.debug(`webhook received: channel=${params.channel} type=${params.updateType ?? "unknown"} chatId=${params.chatId ?? "unknown"} total=${webhookStats.received}`);
|
|
125
|
-
emitDiagnosticEvent({
|
|
126
|
-
type: "webhook.received",
|
|
127
|
-
channel: params.channel,
|
|
128
|
-
updateType: params.updateType,
|
|
129
|
-
chatId: params.chatId
|
|
130
|
-
});
|
|
131
|
-
markActivity();
|
|
132
|
-
}
|
|
133
|
-
function logWebhookProcessed(params) {
|
|
134
|
-
webhookStats.processed += 1;
|
|
135
|
-
if (diag.isEnabled("debug")) diag.debug(`webhook processed: channel=${params.channel} type=${params.updateType ?? "unknown"} chatId=${params.chatId ?? "unknown"} duration=${params.durationMs ?? 0}ms processed=${webhookStats.processed}`);
|
|
136
|
-
emitDiagnosticEvent({
|
|
137
|
-
type: "webhook.processed",
|
|
138
|
-
channel: params.channel,
|
|
139
|
-
updateType: params.updateType,
|
|
140
|
-
chatId: params.chatId,
|
|
141
|
-
durationMs: params.durationMs
|
|
142
|
-
});
|
|
143
|
-
markActivity();
|
|
144
|
-
}
|
|
145
|
-
function logWebhookError(params) {
|
|
146
|
-
webhookStats.errors += 1;
|
|
147
|
-
diag.error(`webhook error: channel=${params.channel} type=${params.updateType ?? "unknown"} chatId=${params.chatId ?? "unknown"} error="${params.error}" errors=${webhookStats.errors}`);
|
|
148
|
-
emitDiagnosticEvent({
|
|
149
|
-
type: "webhook.error",
|
|
150
|
-
channel: params.channel,
|
|
151
|
-
updateType: params.updateType,
|
|
152
|
-
chatId: params.chatId,
|
|
153
|
-
error: params.error
|
|
154
|
-
});
|
|
155
|
-
markActivity();
|
|
156
|
-
}
|
|
157
|
-
function logMessageQueued(params) {
|
|
158
|
-
const state = getDiagnosticSessionState(params);
|
|
159
|
-
state.queueDepth += 1;
|
|
160
|
-
state.lastActivity = Date.now();
|
|
161
|
-
if (diag.isEnabled("debug")) diag.debug(`message queued: sessionId=${state.sessionId ?? "unknown"} sessionKey=${state.sessionKey ?? "unknown"} source=${params.source} queueDepth=${state.queueDepth} sessionState=${state.state}`);
|
|
162
|
-
emitDiagnosticEvent({
|
|
163
|
-
type: "message.queued",
|
|
164
|
-
sessionId: state.sessionId,
|
|
165
|
-
sessionKey: state.sessionKey,
|
|
166
|
-
channel: params.channel,
|
|
167
|
-
source: params.source,
|
|
168
|
-
queueDepth: state.queueDepth
|
|
169
|
-
});
|
|
170
|
-
markActivity();
|
|
171
|
-
}
|
|
172
|
-
function logMessageProcessed(params) {
|
|
173
|
-
if (params.outcome === "error" ? diag.isEnabled("error") : diag.isEnabled("debug")) {
|
|
174
|
-
const payload = `message processed: channel=${params.channel} chatId=${params.chatId ?? "unknown"} messageId=${params.messageId ?? "unknown"} sessionId=${params.sessionId ?? "unknown"} sessionKey=${params.sessionKey ?? "unknown"} outcome=${params.outcome} duration=${params.durationMs ?? 0}ms${params.reason ? ` reason=${params.reason}` : ""}${params.error ? ` error="${params.error}"` : ""}`;
|
|
175
|
-
if (params.outcome === "error") diag.error(payload);
|
|
176
|
-
else diag.debug(payload);
|
|
177
|
-
}
|
|
178
|
-
emitDiagnosticEvent({
|
|
179
|
-
type: "message.processed",
|
|
180
|
-
channel: params.channel,
|
|
181
|
-
chatId: params.chatId,
|
|
182
|
-
messageId: params.messageId,
|
|
183
|
-
sessionId: params.sessionId,
|
|
184
|
-
sessionKey: params.sessionKey,
|
|
185
|
-
durationMs: params.durationMs,
|
|
186
|
-
outcome: params.outcome,
|
|
187
|
-
reason: params.reason,
|
|
188
|
-
error: params.error
|
|
189
|
-
});
|
|
190
|
-
markActivity();
|
|
191
|
-
}
|
|
192
|
-
function logSessionStateChange(params) {
|
|
193
|
-
const state = getDiagnosticSessionState(params);
|
|
194
|
-
const isProbeSession = state.sessionId?.startsWith("probe-") ?? false;
|
|
195
|
-
const prevState = state.state;
|
|
196
|
-
state.state = params.state;
|
|
197
|
-
state.lastActivity = Date.now();
|
|
198
|
-
if (params.state === "idle") state.queueDepth = Math.max(0, state.queueDepth - 1);
|
|
199
|
-
if (!isProbeSession && diag.isEnabled("debug")) diag.debug(`session state: sessionId=${state.sessionId ?? "unknown"} sessionKey=${state.sessionKey ?? "unknown"} prev=${prevState} new=${params.state} reason="${params.reason ?? ""}" queueDepth=${state.queueDepth}`);
|
|
200
|
-
emitDiagnosticEvent({
|
|
201
|
-
type: "session.state",
|
|
202
|
-
sessionId: state.sessionId,
|
|
203
|
-
sessionKey: state.sessionKey,
|
|
204
|
-
prevState,
|
|
205
|
-
state: params.state,
|
|
206
|
-
reason: params.reason,
|
|
207
|
-
queueDepth: state.queueDepth
|
|
208
|
-
});
|
|
209
|
-
markActivity();
|
|
210
|
-
}
|
|
211
|
-
function logSessionStuck(params) {
|
|
212
|
-
const state = getDiagnosticSessionState(params);
|
|
213
|
-
diag.warn(`stuck session: sessionId=${state.sessionId ?? "unknown"} sessionKey=${state.sessionKey ?? "unknown"} state=${params.state} age=${Math.round(params.ageMs / 1e3)}s queueDepth=${state.queueDepth}`);
|
|
214
|
-
emitDiagnosticEvent({
|
|
215
|
-
type: "session.stuck",
|
|
216
|
-
sessionId: state.sessionId,
|
|
217
|
-
sessionKey: state.sessionKey,
|
|
218
|
-
state: params.state,
|
|
219
|
-
ageMs: params.ageMs,
|
|
220
|
-
queueDepth: state.queueDepth
|
|
221
|
-
});
|
|
222
|
-
markActivity();
|
|
223
|
-
}
|
|
224
|
-
function logLaneEnqueue(lane, queueSize) {
|
|
225
|
-
diag.debug(`lane enqueue: lane=${lane} queueSize=${queueSize}`);
|
|
226
|
-
emitDiagnosticEvent({
|
|
227
|
-
type: "queue.lane.enqueue",
|
|
228
|
-
lane,
|
|
229
|
-
queueSize
|
|
230
|
-
});
|
|
231
|
-
markActivity();
|
|
232
|
-
}
|
|
233
|
-
function logLaneDequeue(lane, waitMs, queueSize) {
|
|
234
|
-
diag.debug(`lane dequeue: lane=${lane} waitMs=${waitMs} queueSize=${queueSize}`);
|
|
235
|
-
emitDiagnosticEvent({
|
|
236
|
-
type: "queue.lane.dequeue",
|
|
237
|
-
lane,
|
|
238
|
-
queueSize,
|
|
239
|
-
waitMs
|
|
240
|
-
});
|
|
241
|
-
markActivity();
|
|
242
|
-
}
|
|
243
|
-
function logToolLoopAction(params) {
|
|
244
|
-
const payload = `tool loop: sessionId=${params.sessionId ?? "unknown"} sessionKey=${params.sessionKey ?? "unknown"} tool=${params.toolName} level=${params.level} action=${params.action} detector=${params.detector} count=${params.count}${params.pairedToolName ? ` pairedTool=${params.pairedToolName}` : ""} message="${params.message}"`;
|
|
245
|
-
if (params.level === "critical") diag.error(payload);
|
|
246
|
-
else diag.warn(payload);
|
|
247
|
-
emitDiagnosticEvent({
|
|
248
|
-
type: "tool.loop",
|
|
249
|
-
sessionId: params.sessionId,
|
|
250
|
-
sessionKey: params.sessionKey,
|
|
251
|
-
toolName: params.toolName,
|
|
252
|
-
level: params.level,
|
|
253
|
-
action: params.action,
|
|
254
|
-
detector: params.detector,
|
|
255
|
-
count: params.count,
|
|
256
|
-
message: params.message,
|
|
257
|
-
pairedToolName: params.pairedToolName
|
|
258
|
-
});
|
|
259
|
-
markActivity();
|
|
260
|
-
}
|
|
261
|
-
let heartbeatInterval = null;
|
|
262
|
-
function startDiagnosticHeartbeat(config) {
|
|
263
|
-
if (heartbeatInterval) return;
|
|
264
|
-
heartbeatInterval = setInterval(() => {
|
|
265
|
-
let heartbeatConfig = config;
|
|
266
|
-
if (!heartbeatConfig) try {
|
|
267
|
-
heartbeatConfig = loadConfig();
|
|
268
|
-
} catch {
|
|
269
|
-
heartbeatConfig = void 0;
|
|
270
|
-
}
|
|
271
|
-
const stuckSessionWarnMs = resolveStuckSessionWarnMs(heartbeatConfig);
|
|
272
|
-
const now = Date.now();
|
|
273
|
-
pruneDiagnosticSessionStates(now, true);
|
|
274
|
-
const activeCount = Array.from(diagnosticSessionStates.values()).filter((s) => s.state === "processing").length;
|
|
275
|
-
const waitingCount = Array.from(diagnosticSessionStates.values()).filter((s) => s.state === "waiting").length;
|
|
276
|
-
const totalQueued = Array.from(diagnosticSessionStates.values()).reduce((sum, s) => sum + s.queueDepth, 0);
|
|
277
|
-
if (!(lastActivityAt > 0 || webhookStats.received > 0 || activeCount > 0 || waitingCount > 0 || totalQueued > 0)) return;
|
|
278
|
-
if (now - lastActivityAt > 12e4 && activeCount === 0 && waitingCount === 0) return;
|
|
279
|
-
diag.debug(`heartbeat: webhooks=${webhookStats.received}/${webhookStats.processed}/${webhookStats.errors} active=${activeCount} waiting=${waitingCount} queued=${totalQueued}`);
|
|
280
|
-
emitDiagnosticEvent({
|
|
281
|
-
type: "diagnostic.heartbeat",
|
|
282
|
-
webhooks: {
|
|
283
|
-
received: webhookStats.received,
|
|
284
|
-
processed: webhookStats.processed,
|
|
285
|
-
errors: webhookStats.errors
|
|
286
|
-
},
|
|
287
|
-
active: activeCount,
|
|
288
|
-
waiting: waitingCount,
|
|
289
|
-
queued: totalQueued
|
|
290
|
-
});
|
|
291
|
-
loadCommandPollBackoffRuntime().then(({ pruneStaleCommandPolls }) => {
|
|
292
|
-
for (const [, state] of diagnosticSessionStates) pruneStaleCommandPolls(state);
|
|
293
|
-
}).catch((err) => {
|
|
294
|
-
diag.debug(`command-poll-backoff prune failed: ${String(err)}`);
|
|
295
|
-
});
|
|
296
|
-
for (const [, state] of diagnosticSessionStates) {
|
|
297
|
-
const ageMs = now - state.lastActivity;
|
|
298
|
-
if (state.state === "processing" && ageMs > stuckSessionWarnMs) logSessionStuck({
|
|
299
|
-
sessionId: state.sessionId,
|
|
300
|
-
sessionKey: state.sessionKey,
|
|
301
|
-
state: state.state,
|
|
302
|
-
ageMs
|
|
303
|
-
});
|
|
304
|
-
}
|
|
305
|
-
}, 3e4);
|
|
306
|
-
heartbeatInterval.unref?.();
|
|
307
|
-
}
|
|
308
|
-
function stopDiagnosticHeartbeat() {
|
|
309
|
-
if (heartbeatInterval) {
|
|
310
|
-
clearInterval(heartbeatInterval);
|
|
311
|
-
heartbeatInterval = null;
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
//#endregion
|
|
315
|
-
export { logMessageQueued as a, logWebhookError as c, startDiagnosticHeartbeat as d, stopDiagnosticHeartbeat as f, onDiagnosticEvent as g, isDiagnosticsEnabled as h, logMessageProcessed as i, logWebhookProcessed as l, emitDiagnosticEvent as m, logLaneDequeue as n, logSessionStateChange as o, getDiagnosticSessionState as p, logLaneEnqueue as r, logToolLoopAction as s, diag as t, logWebhookReceived as u };
|