pi-kot 0.1.19 → 0.1.21
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/README.md +253 -17
- package/package.json +8 -60
- package/bin/pi-kot.mjs +0 -148
- package/dist/client/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
- package/dist/client/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
- package/dist/client/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
- package/dist/client/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
- package/dist/client/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
- package/dist/client/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
- package/dist/client/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
- package/dist/client/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
- package/dist/client/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
- package/dist/client/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
- package/dist/client/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
- package/dist/client/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
- package/dist/client/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
- package/dist/client/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
- package/dist/client/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
- package/dist/client/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
- package/dist/client/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
- package/dist/client/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
- package/dist/client/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
- package/dist/client/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
- package/dist/client/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
- package/dist/client/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
- package/dist/client/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
- package/dist/client/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
- package/dist/client/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
- package/dist/client/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
- package/dist/client/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
- package/dist/client/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
- package/dist/client/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
- package/dist/client/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
- package/dist/client/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
- package/dist/client/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
- package/dist/client/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
- package/dist/client/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
- package/dist/client/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
- package/dist/client/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
- package/dist/client/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
- package/dist/client/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
- package/dist/client/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
- package/dist/client/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
- package/dist/client/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
- package/dist/client/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
- package/dist/client/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
- package/dist/client/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
- package/dist/client/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
- package/dist/client/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
- package/dist/client/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
- package/dist/client/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
- package/dist/client/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
- package/dist/client/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
- package/dist/client/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
- package/dist/client/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
- package/dist/client/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
- package/dist/client/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
- package/dist/client/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
- package/dist/client/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
- package/dist/client/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
- package/dist/client/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
- package/dist/client/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
- package/dist/client/assets/index-B6Hxrz4s.js +0 -448
- package/dist/client/assets/index-B6Hxrz4s.js.map +0 -1
- package/dist/client/assets/index-BPImbgFg.css +0 -1
- package/dist/client/index.html +0 -14
- package/dist/server/ask-user-question/envelope.d.ts +0 -11
- package/dist/server/ask-user-question/envelope.d.ts.map +0 -1
- package/dist/server/ask-user-question/envelope.js +0 -41
- package/dist/server/ask-user-question/envelope.js.map +0 -1
- package/dist/server/ask-user-question/plan-mode-question-tool.d.ts +0 -26
- package/dist/server/ask-user-question/plan-mode-question-tool.d.ts.map +0 -1
- package/dist/server/ask-user-question/plan-mode-question-tool.js +0 -273
- package/dist/server/ask-user-question/plan-mode-question-tool.js.map +0 -1
- package/dist/server/ask-user-question/prompt-strings.d.ts +0 -4
- package/dist/server/ask-user-question/prompt-strings.d.ts.map +0 -1
- package/dist/server/ask-user-question/prompt-strings.js +0 -18
- package/dist/server/ask-user-question/prompt-strings.js.map +0 -1
- package/dist/server/ask-user-question/registry.d.ts +0 -39
- package/dist/server/ask-user-question/registry.d.ts.map +0 -1
- package/dist/server/ask-user-question/registry.js +0 -124
- package/dist/server/ask-user-question/registry.js.map +0 -1
- package/dist/server/ask-user-question/tool.d.ts +0 -4
- package/dist/server/ask-user-question/tool.d.ts.map +0 -1
- package/dist/server/ask-user-question/tool.js +0 -68
- package/dist/server/ask-user-question/tool.js.map +0 -1
- package/dist/server/ask-user-question/types.d.ts +0 -50
- package/dist/server/ask-user-question/types.d.ts.map +0 -1
- package/dist/server/ask-user-question/types.js +0 -7
- package/dist/server/ask-user-question/types.js.map +0 -1
- package/dist/server/ask-user-question/validate.d.ts +0 -3
- package/dist/server/ask-user-question/validate.d.ts.map +0 -1
- package/dist/server/ask-user-question/validate.js +0 -67
- package/dist/server/ask-user-question/validate.js.map +0 -1
- package/dist/server/compaction-continuation.d.ts +0 -113
- package/dist/server/compaction-continuation.d.ts.map +0 -1
- package/dist/server/compaction-continuation.js +0 -65
- package/dist/server/compaction-continuation.js.map +0 -1
- package/dist/server/compaction-history.d.ts +0 -62
- package/dist/server/compaction-history.d.ts.map +0 -1
- package/dist/server/compaction-history.js +0 -180
- package/dist/server/compaction-history.js.map +0 -1
- package/dist/server/config-manager.d.ts +0 -97
- package/dist/server/config-manager.d.ts.map +0 -1
- package/dist/server/config-manager.js +0 -352
- package/dist/server/config-manager.js.map +0 -1
- package/dist/server/config.d.ts +0 -24
- package/dist/server/config.d.ts.map +0 -1
- package/dist/server/config.js +0 -67
- package/dist/server/config.js.map +0 -1
- package/dist/server/extension-manager.d.ts +0 -116
- package/dist/server/extension-manager.d.ts.map +0 -1
- package/dist/server/extension-manager.js +0 -586
- package/dist/server/extension-manager.js.map +0 -1
- package/dist/server/extension-ui-bridge.d.ts +0 -35
- package/dist/server/extension-ui-bridge.d.ts.map +0 -1
- package/dist/server/extension-ui-bridge.js +0 -228
- package/dist/server/extension-ui-bridge.js.map +0 -1
- package/dist/server/extensions-discovery.d.ts +0 -26
- package/dist/server/extensions-discovery.d.ts.map +0 -1
- package/dist/server/extensions-discovery.js +0 -107
- package/dist/server/extensions-discovery.js.map +0 -1
- package/dist/server/file-manager.d.ts +0 -79
- package/dist/server/file-manager.d.ts.map +0 -1
- package/dist/server/file-manager.js +0 -535
- package/dist/server/file-manager.js.map +0 -1
- package/dist/server/file-references.d.ts +0 -5
- package/dist/server/file-references.d.ts.map +0 -1
- package/dist/server/file-references.js +0 -249
- package/dist/server/file-references.js.map +0 -1
- package/dist/server/file-searcher.d.ts +0 -29
- package/dist/server/file-searcher.d.ts.map +0 -1
- package/dist/server/file-searcher.js +0 -318
- package/dist/server/file-searcher.js.map +0 -1
- package/dist/server/git-clone.d.ts +0 -56
- package/dist/server/git-clone.d.ts.map +0 -1
- package/dist/server/git-clone.js +0 -173
- package/dist/server/git-clone.js.map +0 -1
- package/dist/server/git-hunk-stager.d.ts +0 -56
- package/dist/server/git-hunk-stager.d.ts.map +0 -1
- package/dist/server/git-hunk-stager.js +0 -137
- package/dist/server/git-hunk-stager.js.map +0 -1
- package/dist/server/git-runner.d.ts +0 -346
- package/dist/server/git-runner.d.ts.map +0 -1
- package/dist/server/git-runner.js +0 -884
- package/dist/server/git-runner.js.map +0 -1
- package/dist/server/index.d.ts +0 -22
- package/dist/server/index.d.ts.map +0 -1
- package/dist/server/index.js +0 -262
- package/dist/server/index.js.map +0 -1
- package/dist/server/lifecycle-notifications.d.ts +0 -28
- package/dist/server/lifecycle-notifications.d.ts.map +0 -1
- package/dist/server/lifecycle-notifications.js +0 -38
- package/dist/server/lifecycle-notifications.js.map +0 -1
- package/dist/server/mcp/config.d.ts +0 -23
- package/dist/server/mcp/config.d.ts.map +0 -1
- package/dist/server/mcp/config.js +0 -139
- package/dist/server/mcp/config.js.map +0 -1
- package/dist/server/mcp/manager.d.ts +0 -40
- package/dist/server/mcp/manager.d.ts.map +0 -1
- package/dist/server/mcp/manager.js +0 -435
- package/dist/server/mcp/manager.js.map +0 -1
- package/dist/server/mcp/stdio-trust.d.ts +0 -5
- package/dist/server/mcp/stdio-trust.d.ts.map +0 -1
- package/dist/server/mcp/stdio-trust.js +0 -78
- package/dist/server/mcp/stdio-trust.js.map +0 -1
- package/dist/server/mcp/tool-bridge.d.ts +0 -33
- package/dist/server/mcp/tool-bridge.d.ts.map +0 -1
- package/dist/server/mcp/tool-bridge.js +0 -138
- package/dist/server/mcp/tool-bridge.js.map +0 -1
- package/dist/server/orchestration/config.d.ts +0 -5
- package/dist/server/orchestration/config.d.ts.map +0 -1
- package/dist/server/orchestration/config.js +0 -35
- package/dist/server/orchestration/config.js.map +0 -1
- package/dist/server/orchestration/event-bridge.d.ts +0 -32
- package/dist/server/orchestration/event-bridge.d.ts.map +0 -1
- package/dist/server/orchestration/event-bridge.js +0 -110
- package/dist/server/orchestration/event-bridge.js.map +0 -1
- package/dist/server/orchestration/inbox.d.ts +0 -9
- package/dist/server/orchestration/inbox.d.ts.map +0 -1
- package/dist/server/orchestration/inbox.js +0 -186
- package/dist/server/orchestration/inbox.js.map +0 -1
- package/dist/server/orchestration/init.d.ts +0 -2
- package/dist/server/orchestration/init.d.ts.map +0 -1
- package/dist/server/orchestration/init.js +0 -22
- package/dist/server/orchestration/init.js.map +0 -1
- package/dist/server/orchestration/store.d.ts +0 -33
- package/dist/server/orchestration/store.d.ts.map +0 -1
- package/dist/server/orchestration/store.js +0 -331
- package/dist/server/orchestration/store.js.map +0 -1
- package/dist/server/orchestration/tools.d.ts +0 -15
- package/dist/server/orchestration/tools.d.ts.map +0 -1
- package/dist/server/orchestration/tools.js +0 -621
- package/dist/server/orchestration/tools.js.map +0 -1
- package/dist/server/orchestration/types.d.ts +0 -68
- package/dist/server/orchestration/types.d.ts.map +0 -1
- package/dist/server/orchestration/types.js +0 -43
- package/dist/server/orchestration/types.js.map +0 -1
- package/dist/server/orchestration/worker-lifecycle.d.ts +0 -15
- package/dist/server/orchestration/worker-lifecycle.d.ts.map +0 -1
- package/dist/server/orchestration/worker-lifecycle.js +0 -45
- package/dist/server/orchestration/worker-lifecycle.js.map +0 -1
- package/dist/server/project-manager.d.ts +0 -25
- package/dist/server/project-manager.d.ts.map +0 -1
- package/dist/server/project-manager.js +0 -157
- package/dist/server/project-manager.js.map +0 -1
- package/dist/server/pty-manager.d.ts +0 -54
- package/dist/server/pty-manager.d.ts.map +0 -1
- package/dist/server/pty-manager.js +0 -220
- package/dist/server/pty-manager.js.map +0 -1
- package/dist/server/routes/_schemas.d.ts +0 -16
- package/dist/server/routes/_schemas.d.ts.map +0 -1
- package/dist/server/routes/_schemas.js +0 -12
- package/dist/server/routes/_schemas.js.map +0 -1
- package/dist/server/routes/ask-user-question.d.ts +0 -3
- package/dist/server/routes/ask-user-question.d.ts.map +0 -1
- package/dist/server/routes/ask-user-question.js +0 -105
- package/dist/server/routes/ask-user-question.js.map +0 -1
- package/dist/server/routes/auth.d.ts +0 -8
- package/dist/server/routes/auth.d.ts.map +0 -1
- package/dist/server/routes/auth.js +0 -225
- package/dist/server/routes/auth.js.map +0 -1
- package/dist/server/routes/config.d.ts +0 -3
- package/dist/server/routes/config.d.ts.map +0 -1
- package/dist/server/routes/config.js +0 -568
- package/dist/server/routes/config.js.map +0 -1
- package/dist/server/routes/control.d.ts +0 -3
- package/dist/server/routes/control.d.ts.map +0 -1
- package/dist/server/routes/control.js +0 -365
- package/dist/server/routes/control.js.map +0 -1
- package/dist/server/routes/exec.d.ts +0 -3
- package/dist/server/routes/exec.d.ts.map +0 -1
- package/dist/server/routes/exec.js +0 -426
- package/dist/server/routes/exec.js.map +0 -1
- package/dist/server/routes/extension-commands.d.ts +0 -22
- package/dist/server/routes/extension-commands.d.ts.map +0 -1
- package/dist/server/routes/extension-commands.js +0 -178
- package/dist/server/routes/extension-commands.js.map +0 -1
- package/dist/server/routes/extensions.d.ts +0 -8
- package/dist/server/routes/extensions.d.ts.map +0 -1
- package/dist/server/routes/extensions.js +0 -414
- package/dist/server/routes/extensions.js.map +0 -1
- package/dist/server/routes/files.d.ts +0 -3
- package/dist/server/routes/files.d.ts.map +0 -1
- package/dist/server/routes/files.js +0 -835
- package/dist/server/routes/files.js.map +0 -1
- package/dist/server/routes/git.d.ts +0 -3
- package/dist/server/routes/git.d.ts.map +0 -1
- package/dist/server/routes/git.js +0 -1058
- package/dist/server/routes/git.js.map +0 -1
- package/dist/server/routes/mcp.d.ts +0 -3
- package/dist/server/routes/mcp.d.ts.map +0 -1
- package/dist/server/routes/mcp.js +0 -403
- package/dist/server/routes/mcp.js.map +0 -1
- package/dist/server/routes/orchestration.d.ts +0 -3
- package/dist/server/routes/orchestration.d.ts.map +0 -1
- package/dist/server/routes/orchestration.js +0 -251
- package/dist/server/routes/orchestration.js.map +0 -1
- package/dist/server/routes/projects.d.ts +0 -3
- package/dist/server/routes/projects.d.ts.map +0 -1
- package/dist/server/routes/projects.js +0 -421
- package/dist/server/routes/projects.js.map +0 -1
- package/dist/server/routes/prompt.d.ts +0 -3
- package/dist/server/routes/prompt.d.ts.map +0 -1
- package/dist/server/routes/prompt.js +0 -311
- package/dist/server/routes/prompt.js.map +0 -1
- package/dist/server/routes/session-extensions.d.ts +0 -11
- package/dist/server/routes/session-extensions.d.ts.map +0 -1
- package/dist/server/routes/session-extensions.js +0 -171
- package/dist/server/routes/session-extensions.js.map +0 -1
- package/dist/server/routes/sessions.d.ts +0 -3
- package/dist/server/routes/sessions.d.ts.map +0 -1
- package/dist/server/routes/sessions.js +0 -706
- package/dist/server/routes/sessions.js.map +0 -1
- package/dist/server/routes/skills.d.ts +0 -14
- package/dist/server/routes/skills.d.ts.map +0 -1
- package/dist/server/routes/skills.js +0 -448
- package/dist/server/routes/skills.js.map +0 -1
- package/dist/server/routes/stream.d.ts +0 -3
- package/dist/server/routes/stream.d.ts.map +0 -1
- package/dist/server/routes/stream.js +0 -112
- package/dist/server/routes/stream.js.map +0 -1
- package/dist/server/routes/terminal.d.ts +0 -28
- package/dist/server/routes/terminal.d.ts.map +0 -1
- package/dist/server/routes/terminal.js +0 -211
- package/dist/server/routes/terminal.js.map +0 -1
- package/dist/server/routes/tunnel.d.ts +0 -13
- package/dist/server/routes/tunnel.d.ts.map +0 -1
- package/dist/server/routes/tunnel.js +0 -231
- package/dist/server/routes/tunnel.js.map +0 -1
- package/dist/server/session-registry.d.ts +0 -164
- package/dist/server/session-registry.d.ts.map +0 -1
- package/dist/server/session-registry.js +0 -754
- package/dist/server/session-registry.js.map +0 -1
- package/dist/server/skill-overrides.d.ts +0 -47
- package/dist/server/skill-overrides.d.ts.map +0 -1
- package/dist/server/skill-overrides.js +0 -178
- package/dist/server/skill-overrides.js.map +0 -1
- package/dist/server/sse-bridge.d.ts +0 -31
- package/dist/server/sse-bridge.d.ts.map +0 -1
- package/dist/server/sse-bridge.js +0 -158
- package/dist/server/sse-bridge.js.map +0 -1
- package/dist/server/tool-overrides.d.ts +0 -39
- package/dist/server/tool-overrides.d.ts.map +0 -1
- package/dist/server/tool-overrides.js +0 -121
- package/dist/server/tool-overrides.js.map +0 -1
- package/dist/server/tunnel/executable-search.d.ts +0 -45
- package/dist/server/tunnel/executable-search.d.ts.map +0 -1
- package/dist/server/tunnel/executable-search.js +0 -150
- package/dist/server/tunnel/executable-search.js.map +0 -1
- package/dist/server/tunnel/install-help.d.ts +0 -19
- package/dist/server/tunnel/install-help.d.ts.map +0 -1
- package/dist/server/tunnel/install-help.js +0 -47
- package/dist/server/tunnel/install-help.js.map +0 -1
- package/dist/server/tunnel/providers/ngrok.d.ts +0 -34
- package/dist/server/tunnel/providers/ngrok.d.ts.map +0 -1
- package/dist/server/tunnel/providers/ngrok.js +0 -464
- package/dist/server/tunnel/providers/ngrok.js.map +0 -1
- package/dist/server/tunnel/registry.d.ts +0 -15
- package/dist/server/tunnel/registry.d.ts.map +0 -1
- package/dist/server/tunnel/registry.js +0 -58
- package/dist/server/tunnel/registry.js.map +0 -1
- package/dist/server/tunnel/service.d.ts +0 -15
- package/dist/server/tunnel/service.d.ts.map +0 -1
- package/dist/server/tunnel/service.js +0 -158
- package/dist/server/tunnel/service.js.map +0 -1
- package/dist/server/tunnel/types.d.ts +0 -166
- package/dist/server/tunnel/types.d.ts.map +0 -1
- package/dist/server/tunnel/types.js +0 -217
- package/dist/server/tunnel/types.js.map +0 -1
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { RESERVED_LABELS, MAX_HEADER_LENGTH, MAX_LABEL_LENGTH, MAX_OPTIONS, MAX_QUESTIONS, MIN_OPTIONS, } from "./types.js";
|
|
2
|
-
export function validateQuestionnaire(raw) {
|
|
3
|
-
if (typeof raw !== "object" || raw === null) {
|
|
4
|
-
return { ok: false, error: "invalid_input", message: "Expected an object" };
|
|
5
|
-
}
|
|
6
|
-
const input = raw;
|
|
7
|
-
const questions = input.questions;
|
|
8
|
-
if (!Array.isArray(questions)) {
|
|
9
|
-
return { ok: false, error: "no_questions", message: "Missing questions array" };
|
|
10
|
-
}
|
|
11
|
-
if (questions.length < 1) {
|
|
12
|
-
return { ok: false, error: "no_questions", message: "At least one question required" };
|
|
13
|
-
}
|
|
14
|
-
if (questions.length > MAX_QUESTIONS) {
|
|
15
|
-
return { ok: false, error: "too_many_questions", message: `Max ${MAX_QUESTIONS} questions` };
|
|
16
|
-
}
|
|
17
|
-
for (const q of questions) {
|
|
18
|
-
if (typeof q !== "object" || q === null) {
|
|
19
|
-
return { ok: false, error: "invalid_question", message: "Question must be an object" };
|
|
20
|
-
}
|
|
21
|
-
const qq = q;
|
|
22
|
-
if (typeof qq.question !== "string" || qq.question.length === 0) {
|
|
23
|
-
return { ok: false, error: "missing_question_text", message: "Question text required" };
|
|
24
|
-
}
|
|
25
|
-
if (typeof qq.header !== "string" || qq.header.length === 0) {
|
|
26
|
-
return { ok: false, error: "missing_header", message: "Header required" };
|
|
27
|
-
}
|
|
28
|
-
if (qq.header.length > MAX_HEADER_LENGTH) {
|
|
29
|
-
return { ok: false, error: "header_too_long", message: `Header max ${MAX_HEADER_LENGTH} chars` };
|
|
30
|
-
}
|
|
31
|
-
const options = qq.options;
|
|
32
|
-
if (!Array.isArray(options)) {
|
|
33
|
-
return { ok: false, error: "too_few_options", message: "Options array required" };
|
|
34
|
-
}
|
|
35
|
-
if (options.length < MIN_OPTIONS) {
|
|
36
|
-
return { ok: false, error: "too_few_options", message: `Min ${MIN_OPTIONS} options` };
|
|
37
|
-
}
|
|
38
|
-
if (options.length > MAX_OPTIONS) {
|
|
39
|
-
return { ok: false, error: "too_many_options", message: `Max ${MAX_OPTIONS} options` };
|
|
40
|
-
}
|
|
41
|
-
const seenLabels = new Set();
|
|
42
|
-
for (const opt of options) {
|
|
43
|
-
if (typeof opt !== "object" || opt === null) {
|
|
44
|
-
return { ok: false, error: "invalid_option", message: "Option must be an object" };
|
|
45
|
-
}
|
|
46
|
-
const oo = opt;
|
|
47
|
-
if (typeof oo.label !== "string" || oo.label.length === 0) {
|
|
48
|
-
return { ok: false, error: "missing_label", message: "Option label required" };
|
|
49
|
-
}
|
|
50
|
-
if (oo.label.length > MAX_LABEL_LENGTH) {
|
|
51
|
-
return { ok: false, error: "label_too_long", message: `Label max ${MAX_LABEL_LENGTH} chars` };
|
|
52
|
-
}
|
|
53
|
-
if (typeof oo.description !== "string" || oo.description.length === 0) {
|
|
54
|
-
return { ok: false, error: "missing_description", message: "Option description required" };
|
|
55
|
-
}
|
|
56
|
-
if (RESERVED_LABELS.includes(oo.label)) {
|
|
57
|
-
return { ok: false, error: "reserved_label", message: `Label "${oo.label}" is reserved` };
|
|
58
|
-
}
|
|
59
|
-
if (seenLabels.has(oo.label)) {
|
|
60
|
-
return { ok: false, error: "duplicate_label", message: `Duplicate label "${oo.label}"` };
|
|
61
|
-
}
|
|
62
|
-
seenLabels.add(oo.label);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
return { ok: true, params: input };
|
|
66
|
-
}
|
|
67
|
-
//# sourceMappingURL=validate.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../src/ask-user-question/validate.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,WAAW,EACX,aAAa,EACb,WAAW,GAGZ,MAAM,YAAY,CAAC;AAEpB,MAAM,UAAU,qBAAqB,CAAC,GAAY;IAChD,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;QAC5C,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,eAAe,EAAE,OAAO,EAAE,oBAAoB,EAAE,CAAC;IAC9E,CAAC;IACD,MAAM,KAAK,GAAG,GAA8B,CAAC;IAC7C,MAAM,SAAS,GAAG,KAAK,CAAC,SAAS,CAAC;IAClC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC;QAC9B,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,yBAAyB,EAAE,CAAC;IAClF,CAAC;IACD,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACzB,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,gCAAgC,EAAE,CAAC;IACzF,CAAC;IACD,IAAI,SAAS,CAAC,MAAM,GAAG,aAAa,EAAE,CAAC;QACrC,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,oBAAoB,EAAE,OAAO,EAAE,OAAO,aAAa,YAAY,EAAE,CAAC;IAC/F,CAAC;IAED,KAAK,MAAM,CAAC,IAAI,SAAS,EAAE,CAAC;QAC1B,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC;YACxC,OAA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EAAE,OAAO,EAAE,UAAU,EAAE,CAAC,KAAK,eAAe,EAAE,CAAC;YAC5F,CAAC;YACD,IAAI,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC7B,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,iBAAiB,EAAE,OAAO,EAAE,oBAAoB,EAAE,CAAC,KAAK,GAAG,EAAE,CAAC;YAC3F,CAAC;YACD,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;QAC3B,CAAC;IACH,CAAC;IAED,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,KAAyC,EAAE,CAAC;AACzE,CAAC"}
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* In-process pi extension that nudges the model to KEEP WORKING on
|
|
3
|
-
* the in-progress task after an overflow-driven auto-compaction,
|
|
4
|
-
* instead of producing a prose status report that paraphrases the
|
|
5
|
-
* compaction summary's "Next Steps" section.
|
|
6
|
-
*
|
|
7
|
-
* ## The problem this solves
|
|
8
|
-
*
|
|
9
|
-
* When the LLM rejects a request with a context-overflow error, the
|
|
10
|
-
* pi SDK auto-compacts and calls `agent.continue()` to resume the
|
|
11
|
-
* loop. The model then sees:
|
|
12
|
-
*
|
|
13
|
-
* - system prompt + tool defs
|
|
14
|
-
* - <kept-recent messages — whatever fit under keepRecentTokens>
|
|
15
|
-
* - <compactionSummary> — a structured doc with sections "## Goal",
|
|
16
|
-
* "## Progress (Done / In Progress / Blocked)", "## Next Steps",
|
|
17
|
-
* "## Critical Context"
|
|
18
|
-
*
|
|
19
|
-
* The failed assistant message was stripped by the SDK (per the
|
|
20
|
-
* overflow path in `agent-session.js:_checkCompaction`), so the
|
|
21
|
-
* `compactionSummary` is the LAST message and the next model output
|
|
22
|
-
* starts a fresh turn. Strong models (Claude, GPT-4) usually infer
|
|
23
|
-
* "I'm mid-task — pick up where I left off." Weaker / smaller local
|
|
24
|
-
* models (Gemma-class on vLLM in particular) read the structured
|
|
25
|
-
* summary as a status report addressed TO them and respond with
|
|
26
|
-
* prose paraphrasing the "Next Steps" section instead of actually
|
|
27
|
-
* doing the work. End-effect: the agent stops making progress right
|
|
28
|
-
* when the user needs it to keep going.
|
|
29
|
-
*
|
|
30
|
-
* The next action might be a tool call, a final answer, a follow-up
|
|
31
|
-
* question, or anything else the task requires — we don't prescribe
|
|
32
|
-
* the shape, we just say "keep going."
|
|
33
|
-
*
|
|
34
|
-
* ## How this extension fixes it
|
|
35
|
-
*
|
|
36
|
-
* Registers a `context` event handler. The `context` event fires
|
|
37
|
-
* BEFORE every LLM request, with the messages array that's about to
|
|
38
|
-
* be sent. We never mutate the session itself — we append a
|
|
39
|
-
* synthetic user message to the OUTBOUND copy only. The handler:
|
|
40
|
-
*
|
|
41
|
-
* 1. Looks at the messages array.
|
|
42
|
-
* 2. If the LAST message is a `compactionSummary`, the model is
|
|
43
|
-
* about to receive a fresh post-compaction context with no
|
|
44
|
-
* forward prompt. Append `NUDGE_MESSAGE` — a one-line
|
|
45
|
-
* imperative telling the model to resume by calling tools.
|
|
46
|
-
* 3. Otherwise (last message is a user prompt, assistant turn, or
|
|
47
|
-
* tool result), do nothing. Threshold compactions don't auto-
|
|
48
|
-
* continue so the user types the next prompt themselves — which
|
|
49
|
-
* becomes the last message — and provides the imperative
|
|
50
|
-
* naturally.
|
|
51
|
-
*
|
|
52
|
-
* The nudge is sent to the LLM but NOT persisted to the session
|
|
53
|
-
* JSONL, so it doesn't leak into compaction summaries, tree views,
|
|
54
|
-
* or session exports.
|
|
55
|
-
*
|
|
56
|
-
* ## Why the `context` hook and not `session_before_compact`
|
|
57
|
-
*
|
|
58
|
-
* `session_before_compact` would let us replace the entire
|
|
59
|
-
* compaction (cancel it, or provide our own). To append text to the
|
|
60
|
-
* SDK-generated summary we'd have to re-implement summarization
|
|
61
|
-
* (call the SDK's exported `compact()` helper, mutate the result,
|
|
62
|
-
* return it). That works but is heavier and couples us to internal
|
|
63
|
-
* SDK shapes. The `context` hook is lighter: SDK does its own
|
|
64
|
-
* summarization, we just inject the imperative at LLM-call time.
|
|
65
|
-
*
|
|
66
|
-
* ## Why a user message and not a system / custom message
|
|
67
|
-
*
|
|
68
|
-
* The `context` hook returns an `AgentMessage[]` that the SDK passes
|
|
69
|
-
* to the provider. Providers expect a system prompt + a user/assistant
|
|
70
|
-
* dialogue; injecting a synthetic `system` mid-stream is non-standard
|
|
71
|
-
* and reorders cache. A trailing user message is the cheapest signal
|
|
72
|
-
* the model interprets as "respond to this now."
|
|
73
|
-
*
|
|
74
|
-
* Ported from a reference
|
|
75
|
-
* packages/server/src/agent-extensions/compaction-continuation.ts.
|
|
76
|
-
*/
|
|
77
|
-
import type { ExtensionFactory } from "@earendil-works/pi-coding-agent";
|
|
78
|
-
import type { AgentMessage } from "@earendil-works/pi-agent-core";
|
|
79
|
-
/**
|
|
80
|
-
* The text the LLM sees as a synthetic user message after an
|
|
81
|
-
* overflow-driven auto-compaction. Tuned to be imperative and brief:
|
|
82
|
-
*
|
|
83
|
-
* - "Continue the task in progress" — open-ended about what the
|
|
84
|
-
* next step is. The agent may need to call a tool, write a
|
|
85
|
-
* final answer, ask a follow-up question, or anything else the
|
|
86
|
-
* task requires. We don't prescribe the shape; we just say
|
|
87
|
-
* keep going.
|
|
88
|
-
* - "Do not write a summary of what you were doing" — names the
|
|
89
|
-
* observed failure mode (model paraphrases the summary's
|
|
90
|
-
* "Next Steps" instead of acting).
|
|
91
|
-
* - "Pick up from where you left off" — frames the summary as
|
|
92
|
-
* reference material, not as a fresh prompt addressed to the
|
|
93
|
-
* model.
|
|
94
|
-
*
|
|
95
|
-
* Kept under 250 characters so the addition to LLM input is
|
|
96
|
-
* negligible (~50 tokens).
|
|
97
|
-
*/
|
|
98
|
-
export declare const NUDGE_MESSAGE: string;
|
|
99
|
-
/**
|
|
100
|
-
* Inspect a messages array and decide whether the post-compaction
|
|
101
|
-
* nudge should be appended. Exported separately so the unit test can
|
|
102
|
-
* exercise the boundary cases (empty, only summary, summary then user
|
|
103
|
-
* prompt, summary then assistant turn) without booting a full SDK
|
|
104
|
-
* session.
|
|
105
|
-
*/
|
|
106
|
-
export declare function shouldNudgeAfterCompaction(messages: readonly AgentMessage[]): boolean;
|
|
107
|
-
/**
|
|
108
|
-
* Pi extension factory. Registered via `DefaultResourceLoader`'s
|
|
109
|
-
* `extensionFactories` option in `session-registry.ts`. No I/O,
|
|
110
|
-
* no async setup — just registers the handler and returns.
|
|
111
|
-
*/
|
|
112
|
-
export declare const compactionContinuationExtension: ExtensionFactory;
|
|
113
|
-
//# sourceMappingURL=compaction-continuation.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"compaction-continuation.d.ts","sourceRoot":"","sources":["../src/compaction-continuation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2EG;AACH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAElE;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,aAAa,QAG0C,CAAC;AAErE;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CAAC,QAAQ,EAAE,SAAS,YAAY,EAAE,GAAG,OAAO,CAIrF;AAiBD;;;;GAIG;AACH,eAAO,MAAM,+BAA+B,EAAE,gBAS7C,CAAC"}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The text the LLM sees as a synthetic user message after an
|
|
3
|
-
* overflow-driven auto-compaction. Tuned to be imperative and brief:
|
|
4
|
-
*
|
|
5
|
-
* - "Continue the task in progress" — open-ended about what the
|
|
6
|
-
* next step is. The agent may need to call a tool, write a
|
|
7
|
-
* final answer, ask a follow-up question, or anything else the
|
|
8
|
-
* task requires. We don't prescribe the shape; we just say
|
|
9
|
-
* keep going.
|
|
10
|
-
* - "Do not write a summary of what you were doing" — names the
|
|
11
|
-
* observed failure mode (model paraphrases the summary's
|
|
12
|
-
* "Next Steps" instead of acting).
|
|
13
|
-
* - "Pick up from where you left off" — frames the summary as
|
|
14
|
-
* reference material, not as a fresh prompt addressed to the
|
|
15
|
-
* model.
|
|
16
|
-
*
|
|
17
|
-
* Kept under 250 characters so the addition to LLM input is
|
|
18
|
-
* negligible (~50 tokens).
|
|
19
|
-
*/
|
|
20
|
-
export const NUDGE_MESSAGE = "[continuation] Continue the task in progress — pick up from where you left off " +
|
|
21
|
-
"based on the summary above. Do not write a status update or summary of what you " +
|
|
22
|
-
"were doing; just proceed with the next action the task requires.";
|
|
23
|
-
/**
|
|
24
|
-
* Inspect a messages array and decide whether the post-compaction
|
|
25
|
-
* nudge should be appended. Exported separately so the unit test can
|
|
26
|
-
* exercise the boundary cases (empty, only summary, summary then user
|
|
27
|
-
* prompt, summary then assistant turn) without booting a full SDK
|
|
28
|
-
* session.
|
|
29
|
-
*/
|
|
30
|
-
export function shouldNudgeAfterCompaction(messages) {
|
|
31
|
-
const last = messages[messages.length - 1];
|
|
32
|
-
if (last === undefined)
|
|
33
|
-
return false;
|
|
34
|
-
return last.role === "compactionSummary";
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Build the synthetic user message used as the nudge. Timestamp is
|
|
38
|
-
* `Date.now()` so the message sorts after any prior content if a
|
|
39
|
-
* downstream consumer ever inspects timestamps; in practice the SDK
|
|
40
|
-
* doesn't reorder by timestamp at LLM-call time, but it costs nothing
|
|
41
|
-
* to keep monotonic ordering.
|
|
42
|
-
*/
|
|
43
|
-
function buildNudgeMessage() {
|
|
44
|
-
return {
|
|
45
|
-
role: "user",
|
|
46
|
-
content: [{ type: "text", text: NUDGE_MESSAGE }],
|
|
47
|
-
timestamp: Date.now(),
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Pi extension factory. Registered via `DefaultResourceLoader`'s
|
|
52
|
-
* `extensionFactories` option in `session-registry.ts`. No I/O,
|
|
53
|
-
* no async setup — just registers the handler and returns.
|
|
54
|
-
*/
|
|
55
|
-
export const compactionContinuationExtension = (pi) => {
|
|
56
|
-
pi.on("context", (event) => {
|
|
57
|
-
if (!shouldNudgeAfterCompaction(event.messages)) {
|
|
58
|
-
return undefined;
|
|
59
|
-
}
|
|
60
|
-
return {
|
|
61
|
-
messages: [...event.messages, buildNudgeMessage()],
|
|
62
|
-
};
|
|
63
|
-
});
|
|
64
|
-
};
|
|
65
|
-
//# sourceMappingURL=compaction-continuation.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"compaction-continuation.js","sourceRoot":"","sources":["../src/compaction-continuation.ts"],"names":[],"mappings":"AA+EA;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,aAAa,GACxB,iFAAiF;IACjF,kFAAkF;IAClF,kEAAkE,CAAC;AAErE;;;;;;GAMG;AACH,MAAM,UAAU,0BAA0B,CAAC,QAAiC;IAC1E,MAAM,IAAI,GAAG,QAAQ,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAC3C,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC;IACrC,OAAO,IAAI,CAAC,IAAI,KAAK,mBAAmB,CAAC;AAC3C,CAAC;AAED;;;;;;GAMG;AACH,SAAS,iBAAiB;IACxB,OAAO;QACL,IAAI,EAAE,MAAM;QACZ,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC;QAChD,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;KACtB,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,+BAA+B,GAAqB,CAAC,EAAE,EAAE,EAAE;IACtE,EAAE,CAAC,EAAE,CAAC,SAAS,EAAE,CAAC,KAAK,EAAE,EAAE;QACzB,IAAI,CAAC,0BAA0B,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC;YAChD,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,OAAO;YACL,QAAQ,EAAE,CAAC,GAAG,KAAK,CAAC,QAAQ,EAAE,iBAAiB,EAAE,CAAC;SACnD,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC"}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Per-compaction archive derivation.
|
|
3
|
-
*
|
|
4
|
-
* Pi's SessionManager persists every entry to JSONL — including
|
|
5
|
-
* `CompactionEntry` records that mark where the SDK summarised and
|
|
6
|
-
* dropped older messages from the in-memory context. The chat UI
|
|
7
|
-
* reads `session.messages` (the post-compaction view); without
|
|
8
|
-
* something like this module the user's pre-compaction history
|
|
9
|
-
* appears to vanish.
|
|
10
|
-
*
|
|
11
|
-
* This module reads the full entries array, walks each compaction,
|
|
12
|
-
* and produces a `CompactionEvent[]` shape the client renders as
|
|
13
|
-
* inline "Compacted N messages → Y tokens" cards with the archived
|
|
14
|
-
* messages one click away.
|
|
15
|
-
*
|
|
16
|
-
* Shape contract:
|
|
17
|
-
* - `id` — the CompactionEntry's id (stable across reloads)
|
|
18
|
-
* - `timestamp` — when the compaction happened (ISO 8601)
|
|
19
|
-
* - `summary` — the SDK-generated prose summary
|
|
20
|
-
* - `tokensBefore` — context size at the moment of compaction
|
|
21
|
-
* - `insertBeforeIndex` — index in the post-compaction `session.messages`
|
|
22
|
-
* array where the card should render. The card
|
|
23
|
-
* appears IMMEDIATELY ABOVE the message at
|
|
24
|
-
* this index — i.e. between messages[i-1] and
|
|
25
|
-
* messages[i]. When 0, the card renders at the
|
|
26
|
-
* very top of the chat (the entire pre-
|
|
27
|
-
* compaction history was archived).
|
|
28
|
-
* - `archivedMessages` — the AgentMessage[] that the SDK removed from
|
|
29
|
-
* the context. Rendered through the existing
|
|
30
|
-
* Message component when the user expands the
|
|
31
|
-
* card. Slice is from "the compaction immediately
|
|
32
|
-
* before this one (or session start)" up to but
|
|
33
|
-
* not including the new compaction.
|
|
34
|
-
*
|
|
35
|
-
* Ported from a reference compaction history module.
|
|
36
|
-
*/
|
|
37
|
-
import type { AgentSession } from "@earendil-works/pi-coding-agent";
|
|
38
|
-
import type { AgentMessage } from "@earendil-works/pi-agent-core";
|
|
39
|
-
export interface CompactionEvent {
|
|
40
|
-
id: string;
|
|
41
|
-
timestamp: string;
|
|
42
|
-
summary: string;
|
|
43
|
-
tokensBefore: number;
|
|
44
|
-
/** Estimated token count of the kept context AFTER compaction (SDK 0.79.8+).
|
|
45
|
-
* Derived by walking kept message entries from firstKeptEntryId using a
|
|
46
|
-
* char/4 heuristic — same approach the SDK uses at compaction time. */
|
|
47
|
-
estimatedTokensAfter?: number;
|
|
48
|
-
insertBeforeIndex: number;
|
|
49
|
-
archivedMessages: AgentMessage[];
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Walk `session.sessionManager.getEntries()` once and produce one
|
|
53
|
-
* CompactionEvent per CompactionEntry. The mapping back to a position
|
|
54
|
-
* in `session.messages` is the tricky part: the post-compaction
|
|
55
|
-
* messages array is rebuilt from the entries that come AT or AFTER
|
|
56
|
-
* the latest compaction's `firstKeptEntryId`, with the compaction
|
|
57
|
-
* summary itself synthesised in. We compute `insertBeforeIndex` by
|
|
58
|
-
* counting how many "kept" message entries appear in `messages`
|
|
59
|
-
* before the position where this compaction's first-kept entry lands.
|
|
60
|
-
*/
|
|
61
|
-
export declare function buildCompactionHistory(session: AgentSession): CompactionEvent[];
|
|
62
|
-
//# sourceMappingURL=compaction-history.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"compaction-history.d.ts","sourceRoot":"","sources":["../src/compaction-history.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,OAAO,KAAK,EAAE,YAAY,EAAgB,MAAM,iCAAiC,CAAC;AAClF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAElE,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB;;4EAEwE;IACxE,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,gBAAgB,EAAE,YAAY,EAAE,CAAC;CAClC;AA0BD;;;;;;;;;GASG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,YAAY,GAAG,eAAe,EAAE,CA0E/E"}
|
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
function isCompactionEntry(e) {
|
|
2
|
-
return e.type === "compaction";
|
|
3
|
-
}
|
|
4
|
-
function isMessageEntry(e) {
|
|
5
|
-
return e.type === "message";
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* Walk `session.sessionManager.getEntries()` once and produce one
|
|
9
|
-
* CompactionEvent per CompactionEntry. The mapping back to a position
|
|
10
|
-
* in `session.messages` is the tricky part: the post-compaction
|
|
11
|
-
* messages array is rebuilt from the entries that come AT or AFTER
|
|
12
|
-
* the latest compaction's `firstKeptEntryId`, with the compaction
|
|
13
|
-
* summary itself synthesised in. We compute `insertBeforeIndex` by
|
|
14
|
-
* counting how many "kept" message entries appear in `messages`
|
|
15
|
-
* before the position where this compaction's first-kept entry lands.
|
|
16
|
-
*/
|
|
17
|
-
export function buildCompactionHistory(session) {
|
|
18
|
-
const entries = session.sessionManager.getEntries();
|
|
19
|
-
const compactions = [];
|
|
20
|
-
for (const e of entries)
|
|
21
|
-
if (isCompactionEntry(e))
|
|
22
|
-
compactions.push(e);
|
|
23
|
-
if (compactions.length === 0)
|
|
24
|
-
return [];
|
|
25
|
-
// Walk entries in order; for each compaction event, capture the
|
|
26
|
-
// message entries between the previous compaction (or session start)
|
|
27
|
-
// and this one. Those are the "archived" messages — the ones that
|
|
28
|
-
// were summarised and dropped.
|
|
29
|
-
const events = [];
|
|
30
|
-
let archiveBuffer = [];
|
|
31
|
-
for (const entry of entries) {
|
|
32
|
-
if (isMessageEntry(entry)) {
|
|
33
|
-
archiveBuffer.push(entry.message);
|
|
34
|
-
continue;
|
|
35
|
-
}
|
|
36
|
-
if (isCompactionEntry(entry)) {
|
|
37
|
-
// Estimate what the kept context size was AFTER this compaction
|
|
38
|
-
// by counting tokens for all message entries from firstKeptEntryId
|
|
39
|
-
// to the end of the entries array.
|
|
40
|
-
const estimatedTokensAfter = estimateKeptTokens(entries, entry.firstKeptEntryId);
|
|
41
|
-
events.push({
|
|
42
|
-
id: entry.id,
|
|
43
|
-
timestamp: entry.timestamp,
|
|
44
|
-
summary: entry.summary,
|
|
45
|
-
tokensBefore: entry.tokensBefore,
|
|
46
|
-
estimatedTokensAfter: estimatedTokensAfter > 0 ? estimatedTokensAfter : undefined,
|
|
47
|
-
// Filled in below — depends on the index of `firstKeptEntryId`
|
|
48
|
-
// within the *kept* portion of the messages stream.
|
|
49
|
-
insertBeforeIndex: 0,
|
|
50
|
-
archivedMessages: archiveBuffer,
|
|
51
|
-
});
|
|
52
|
-
// Reset for the next archive window. Anything between this
|
|
53
|
-
// compaction and the next one (or end of session) belongs to
|
|
54
|
-
// the next event's archive — but only if there IS a next
|
|
55
|
-
// compaction. If not, those messages live in `session.messages`
|
|
56
|
-
// and don't need archiving.
|
|
57
|
-
archiveBuffer = [];
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
// Compute insertBeforeIndex for each event. Given a compaction whose
|
|
61
|
-
// firstKeptEntryId points at message-entry M, the number of message
|
|
62
|
-
// entries BEFORE M (within the post-this-compaction kept portion of
|
|
63
|
-
// the entries array) tells us where to splice the card.
|
|
64
|
-
//
|
|
65
|
-
// For the LAST compaction, the kept portion lines up with what
|
|
66
|
-
// session.messages actually contains, so we can count message
|
|
67
|
-
// entries from `firstKeptEntryId` forward up to the compaction's
|
|
68
|
-
// own position. Earlier compactions' kept portions were re-archived
|
|
69
|
-
// by later compactions — those events sit at the TOP of the
|
|
70
|
-
// (current) display, so insertBeforeIndex = 0 for all but the last.
|
|
71
|
-
// (Once a compaction's kept window has itself been archived, no
|
|
72
|
-
// post-compaction message in `session.messages` corresponds to it,
|
|
73
|
-
// so the only sensible position is "before everything else".)
|
|
74
|
-
for (let i = 0; i < events.length - 1; i++) {
|
|
75
|
-
const ev = events[i];
|
|
76
|
-
if (ev !== undefined)
|
|
77
|
-
ev.insertBeforeIndex = 0;
|
|
78
|
-
}
|
|
79
|
-
const last = events[events.length - 1];
|
|
80
|
-
if (last !== undefined) {
|
|
81
|
-
const lastCompaction = compactions[compactions.length - 1];
|
|
82
|
-
if (lastCompaction !== undefined) {
|
|
83
|
-
last.insertBeforeIndex = countMessagesBetween(entries, lastCompaction.firstKeptEntryId, lastCompaction.id);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
return events;
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Estimate token count for a single message using char/4 heuristic.
|
|
90
|
-
* Mirrors the SDK's `estimateTokens()` in `core/compaction/compaction.ts`.
|
|
91
|
-
*/
|
|
92
|
-
function estimateMessageTokens(msg) {
|
|
93
|
-
const m = msg;
|
|
94
|
-
let chars = 0;
|
|
95
|
-
// Roles with a `content` field: user, assistant, toolResult, custom
|
|
96
|
-
const content = m.content;
|
|
97
|
-
if (typeof content === "string") {
|
|
98
|
-
chars += content.length;
|
|
99
|
-
}
|
|
100
|
-
else if (Array.isArray(content)) {
|
|
101
|
-
for (const block of content) {
|
|
102
|
-
const b = block;
|
|
103
|
-
if (b.type === "text" && typeof b.text === "string") {
|
|
104
|
-
chars += b.text.length;
|
|
105
|
-
}
|
|
106
|
-
else if (b.type === "thinking" && typeof b.thinking === "string") {
|
|
107
|
-
chars += b.thinking.length;
|
|
108
|
-
}
|
|
109
|
-
else if (b.type === "toolCall") {
|
|
110
|
-
chars += typeof b.name === "string" ? b.name.length : 0;
|
|
111
|
-
try {
|
|
112
|
-
chars += typeof b.arguments === "string"
|
|
113
|
-
? b.arguments.length
|
|
114
|
-
: JSON.stringify(b.arguments).length;
|
|
115
|
-
}
|
|
116
|
-
catch { /* skip unstringifiable */ }
|
|
117
|
-
}
|
|
118
|
-
else if (b.type === "image") {
|
|
119
|
-
chars += 4800; // ESTIMATED_IMAGE_CHARS — same value as the SDK
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
// compactionSummary / branchSummary roles: carry `summary` instead of `content`
|
|
124
|
-
if (typeof m.summary === "string") {
|
|
125
|
-
chars = m.summary.length;
|
|
126
|
-
}
|
|
127
|
-
// bashExecution: carries `command` + `output`
|
|
128
|
-
if (typeof m.command === "string") {
|
|
129
|
-
chars += m.command.length;
|
|
130
|
-
}
|
|
131
|
-
if (typeof m.output === "string") {
|
|
132
|
-
chars += m.output.length;
|
|
133
|
-
}
|
|
134
|
-
return Math.ceil(chars / 4);
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
* Walk message entries from `firstKeptEntryId` to the end of the entries
|
|
138
|
-
* array and estimate their total tokens. This gives us the
|
|
139
|
-
* `estimatedTokensAfter` — the approximate size of the kept context
|
|
140
|
-
* right after compaction.
|
|
141
|
-
*/
|
|
142
|
-
function estimateKeptTokens(entries, firstKeptEntryId) {
|
|
143
|
-
const startIdx = entries.findIndex((e) => e.id === firstKeptEntryId);
|
|
144
|
-
if (startIdx === -1)
|
|
145
|
-
return 0;
|
|
146
|
-
let total = 0;
|
|
147
|
-
for (let i = startIdx; i < entries.length; i++) {
|
|
148
|
-
const e = entries[i];
|
|
149
|
-
if (e === undefined)
|
|
150
|
-
break;
|
|
151
|
-
if (isMessageEntry(e)) {
|
|
152
|
-
total += estimateMessageTokens(e.message);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
return total;
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* Count message-typed entries between two entry ids (exclusive of the
|
|
159
|
-
* end id). Returns the position where the compaction card should
|
|
160
|
-
* splice into `session.messages`. When `firstKeptEntryId` doesn't
|
|
161
|
-
* resolve (legacy session, manual JSONL edit), returns 0 — the card
|
|
162
|
-
* lands at the top of the chat, which is the safe fallback.
|
|
163
|
-
*/
|
|
164
|
-
function countMessagesBetween(entries, firstKeptEntryId, endEntryId) {
|
|
165
|
-
const startIdx = entries.findIndex((e) => e.id === firstKeptEntryId);
|
|
166
|
-
if (startIdx === -1)
|
|
167
|
-
return 0;
|
|
168
|
-
let count = 0;
|
|
169
|
-
for (let i = startIdx; i < entries.length; i++) {
|
|
170
|
-
const e = entries[i];
|
|
171
|
-
if (e === undefined)
|
|
172
|
-
break;
|
|
173
|
-
if (e.id === endEntryId)
|
|
174
|
-
break;
|
|
175
|
-
if (isMessageEntry(e))
|
|
176
|
-
count++;
|
|
177
|
-
}
|
|
178
|
-
return count;
|
|
179
|
-
}
|
|
180
|
-
//# sourceMappingURL=compaction-history.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"compaction-history.js","sourceRoot":"","sources":["../src/compaction-history.ts"],"names":[],"mappings":"AAoEA,SAAS,iBAAiB,CAAC,CAAe;IACxC,OAAO,CAAC,CAAC,IAAI,KAAK,YAAY,CAAC;AACjC,CAAC;AAED,SAAS,cAAc,CAAC,CAAe;IACrC,OAAO,CAAC,CAAC,IAAI,KAAK,SAAS,CAAC;AAC9B,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,sBAAsB,CAAC,OAAqB;IAC1D,MAAM,OAAO,GAAG,OAAO,CAAC,cAAc,CAAC,UAAU,EAAE,CAAC;IACpD,MAAM,WAAW,GAA4C,EAAE,CAAC;IAChE,KAAK,MAAM,CAAC,IAAI,OAAO;QAAE,IAAI,iBAAiB,CAAC,CAAC,CAAC;YAAE,WAAW,CAAC,IAAI,CAAC,CA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AAC,CAAC;QACrB,IAAI,CAAC,KAAK,SAAS;YAAE,MAAM;QAC3B,IAAI,CAAC,CAAC,EAAE,KAAK,UAAU;YAAE,MAAM;QAC/B,IAAI,cAAc,CAAC,CAAC,CAAC;YAAE,KAAK,EAAE,CAAC;IACjC,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
interface ProbeRequest {
|
|
2
|
-
baseUrl: string;
|
|
3
|
-
apiKey?: string;
|
|
4
|
-
apiType?: string;
|
|
5
|
-
headers?: Record<string, string>;
|
|
6
|
-
}
|
|
7
|
-
interface ProbeResult {
|
|
8
|
-
reachable: boolean;
|
|
9
|
-
error?: string;
|
|
10
|
-
detectedApiType?: string;
|
|
11
|
-
models?: Array<{
|
|
12
|
-
id: string;
|
|
13
|
-
name?: string;
|
|
14
|
-
}>;
|
|
15
|
-
suggestedName?: string;
|
|
16
|
-
/** Full response from the models endpoint for debugging */
|
|
17
|
-
rawResponse?: unknown;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Probe a provider endpoint to test connectivity, detect API type,
|
|
21
|
-
* and fetch available models.
|
|
22
|
-
*/
|
|
23
|
-
export declare function probeProvider(req: ProbeRequest): Promise<ProbeResult>;
|
|
24
|
-
/**
|
|
25
|
-
* Add or update a custom provider in models.json.
|
|
26
|
-
*/
|
|
27
|
-
export declare function addCustomProvider(providerName: string, config: Record<string, unknown>): Promise<{
|
|
28
|
-
providers: Record<string, unknown>;
|
|
29
|
-
}>;
|
|
30
|
-
/**
|
|
31
|
-
* Remove a custom provider from models.json.
|
|
32
|
-
*/
|
|
33
|
-
export declare function removeCustomProvider(providerName: string): Promise<{
|
|
34
|
-
providers: Record<string, unknown>;
|
|
35
|
-
}>;
|
|
36
|
-
export declare class AuthProviderNotFoundError extends Error {
|
|
37
|
-
constructor(provider: string);
|
|
38
|
-
}
|
|
39
|
-
export interface AuthPresence {
|
|
40
|
-
configured: boolean;
|
|
41
|
-
source?: string;
|
|
42
|
-
label?: string;
|
|
43
|
-
}
|
|
44
|
-
export interface AuthSummary {
|
|
45
|
-
providers: Record<string, AuthPresence>;
|
|
46
|
-
}
|
|
47
|
-
export declare function readAuthSummary(): AuthSummary;
|
|
48
|
-
export declare function writeApiKey(provider: string, apiKey: string): void;
|
|
49
|
-
export declare function removeApiKey(provider: string): void;
|
|
50
|
-
export declare function readSettings(): Record<string, unknown>;
|
|
51
|
-
export declare function updateSettings(patch: Record<string, unknown>): Record<string, unknown>;
|
|
52
|
-
export interface ModelsJson {
|
|
53
|
-
providers: Record<string, unknown>;
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Read models.json, redacting secret fields (apiKey, apiKeyCommand).
|
|
57
|
-
*/
|
|
58
|
-
export declare function readModelsJsonRedacted(): Promise<ModelsJson>;
|
|
59
|
-
export declare function writeModelsJson(data: ModelsJson): Promise<void>;
|
|
60
|
-
/**
|
|
61
|
-
* Write settings.json atomically. Used by the per-session setModel route
|
|
62
|
-
* to restore the global default after the SDK mutates it as a side effect
|
|
63
|
-
* of session.setModel().
|
|
64
|
-
* Pattern from reference writeSettings().
|
|
65
|
-
*/
|
|
66
|
-
export declare function writeSettings(settings: Record<string, unknown>): Promise<void>;
|
|
67
|
-
/**
|
|
68
|
-
* Read the enabledModels array from settings via the SDK SettingsManager.
|
|
69
|
-
* Returns undefined when no scoping is active (all models visible).
|
|
70
|
-
*/
|
|
71
|
-
export declare function readEnabledModels(): string[] | undefined;
|
|
72
|
-
/**
|
|
73
|
-
* Persist the enabledModels array to settings. Pass undefined or null
|
|
74
|
-
* to disable scoping (all models visible).
|
|
75
|
-
*/
|
|
76
|
-
export declare function writeEnabledModels(patterns: string[] | null | undefined): void;
|
|
77
|
-
export interface ProvidersListingOptions {
|
|
78
|
-
/** When true, only return models listed in enabledModels. */
|
|
79
|
-
scoped?: boolean;
|
|
80
|
-
}
|
|
81
|
-
export declare function liveProvidersListing(opts?: ProvidersListingOptions): {
|
|
82
|
-
providers: Array<{
|
|
83
|
-
provider: string;
|
|
84
|
-
models: Array<{
|
|
85
|
-
id: string;
|
|
86
|
-
name: string;
|
|
87
|
-
contextWindow: number;
|
|
88
|
-
maxTokens: number;
|
|
89
|
-
reasoning: boolean;
|
|
90
|
-
input: string[];
|
|
91
|
-
hasAuth: boolean;
|
|
92
|
-
supportedThinkingLevels: string[];
|
|
93
|
-
}>;
|
|
94
|
-
}>;
|
|
95
|
-
};
|
|
96
|
-
export {};
|
|
97
|
-
//# sourceMappingURL=config-manager.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config-manager.d.ts","sourceRoot":"","sources":["../src/config-manager.ts"],"names":[],"mappings":"AAmBA,UAAU,YAAY;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC;AAED,UAAU,WAAW;IACnB,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,MAAM,CAAC,EAAE,KAAK,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC9C,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,2DAA2D;IAC3D,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED;;;GAGG;AACH,wBAAsB,aAAa,CAAC,GAAG,EAAE,YAAY,GAAG,OAAO,CAAC,WAAW,CAAC,CA+G3E;AAED;;GAEG;AACH,wBAAsB,iBAAiB,CACrC,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC9B,OAAO,CAAC;IAAE,SAAS,EAAE,MAAM,CAA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