@creatoria/miniapp-mcp 0.1.3 → 0.2.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/README.md +131 -66
- package/dist/app/cli/index.d.ts +6 -0
- package/dist/app/cli/index.d.ts.map +1 -0
- package/dist/app/cli/index.js +6 -0
- package/dist/app/cli/index.js.map +1 -0
- package/dist/app/index.d.ts +6 -0
- package/dist/app/index.d.ts.map +1 -0
- package/dist/app/index.js +6 -0
- package/dist/app/index.js.map +1 -0
- package/dist/app/server/index.d.ts +7 -0
- package/dist/app/server/index.d.ts.map +1 -0
- package/dist/app/server/index.js +6 -0
- package/dist/app/server/index.js.map +1 -0
- package/dist/capabilities/assert/handlers/assert-handlers.d.ts +98 -0
- package/dist/capabilities/assert/handlers/assert-handlers.d.ts.map +1 -0
- package/dist/capabilities/assert/handlers/assert-handlers.js +179 -0
- package/dist/capabilities/assert/handlers/assert-handlers.js.map +1 -0
- package/dist/capabilities/assert/handlers/index.d.ts +7 -0
- package/dist/capabilities/assert/handlers/index.d.ts.map +1 -0
- package/dist/capabilities/assert/handlers/index.js +7 -0
- package/dist/capabilities/assert/handlers/index.js.map +1 -0
- package/dist/capabilities/assert/index.d.ts +15 -0
- package/dist/capabilities/assert/index.d.ts.map +1 -0
- package/dist/capabilities/assert/index.js +90 -0
- package/dist/capabilities/assert/index.js.map +1 -0
- package/dist/capabilities/assert/schemas/index.d.ts +101 -0
- package/dist/capabilities/assert/schemas/index.d.ts.map +1 -0
- package/dist/capabilities/assert/schemas/index.js +62 -0
- package/dist/capabilities/assert/schemas/index.js.map +1 -0
- package/dist/capabilities/automator/handlers/close.d.ts +18 -0
- package/dist/capabilities/automator/handlers/close.d.ts.map +1 -0
- package/dist/capabilities/automator/handlers/close.js +45 -0
- package/dist/capabilities/automator/handlers/close.js.map +1 -0
- package/dist/capabilities/automator/handlers/connect.d.ts +24 -0
- package/dist/capabilities/automator/handlers/connect.d.ts.map +1 -0
- package/dist/capabilities/automator/handlers/connect.js +51 -0
- package/dist/capabilities/automator/handlers/connect.js.map +1 -0
- package/dist/capabilities/automator/handlers/disconnect.d.ts +16 -0
- package/dist/capabilities/automator/handlers/disconnect.d.ts.map +1 -0
- package/dist/capabilities/automator/handlers/disconnect.js +44 -0
- package/dist/capabilities/automator/handlers/disconnect.js.map +1 -0
- package/dist/capabilities/automator/handlers/index.d.ts +8 -0
- package/dist/capabilities/automator/handlers/index.d.ts.map +1 -0
- package/dist/capabilities/automator/handlers/index.js +8 -0
- package/dist/capabilities/automator/handlers/index.js.map +1 -0
- package/dist/capabilities/automator/handlers/launch.d.ts +25 -0
- package/dist/capabilities/automator/handlers/launch.d.ts.map +1 -0
- package/dist/capabilities/automator/handlers/launch.js +61 -0
- package/dist/capabilities/automator/handlers/launch.js.map +1 -0
- package/dist/capabilities/automator/index.d.ts +15 -0
- package/dist/capabilities/automator/index.d.ts.map +1 -0
- package/dist/capabilities/automator/index.js +55 -0
- package/dist/capabilities/automator/index.js.map +1 -0
- package/dist/capabilities/automator/schemas/close.d.ts +5 -0
- package/dist/capabilities/automator/schemas/close.d.ts.map +1 -0
- package/dist/capabilities/automator/schemas/close.js +11 -0
- package/dist/capabilities/automator/schemas/close.js.map +1 -0
- package/dist/capabilities/automator/schemas/connect.d.ts +11 -0
- package/dist/capabilities/automator/schemas/connect.d.ts.map +1 -0
- package/dist/capabilities/automator/schemas/connect.js +19 -0
- package/dist/capabilities/automator/schemas/connect.js.map +1 -0
- package/dist/capabilities/automator/schemas/disconnect.d.ts +5 -0
- package/dist/capabilities/automator/schemas/disconnect.d.ts.map +1 -0
- package/dist/capabilities/automator/schemas/disconnect.js +11 -0
- package/dist/capabilities/automator/schemas/disconnect.js.map +1 -0
- package/dist/capabilities/automator/schemas/index.d.ts +9 -0
- package/dist/capabilities/automator/schemas/index.d.ts.map +1 -0
- package/dist/capabilities/automator/schemas/index.js +14 -0
- package/dist/capabilities/automator/schemas/index.js.map +1 -0
- package/dist/capabilities/automator/schemas/launch.d.ts +17 -0
- package/dist/capabilities/automator/schemas/launch.d.ts.map +1 -0
- package/dist/capabilities/automator/schemas/launch.js +26 -0
- package/dist/capabilities/automator/schemas/launch.js.map +1 -0
- package/dist/capabilities/element/handlers/element-handlers.d.ts +212 -0
- package/dist/capabilities/element/handlers/element-handlers.d.ts.map +1 -0
- package/dist/capabilities/element/handlers/element-handlers.js +383 -0
- package/dist/capabilities/element/handlers/element-handlers.js.map +1 -0
- package/dist/capabilities/element/handlers/index.d.ts +7 -0
- package/dist/capabilities/element/handlers/index.d.ts.map +1 -0
- package/dist/capabilities/element/handlers/index.js +27 -0
- package/dist/capabilities/element/handlers/index.js.map +1 -0
- package/dist/capabilities/element/index.d.ts +20 -0
- package/dist/capabilities/element/index.d.ts.map +1 -0
- package/dist/capabilities/element/index.js +199 -0
- package/dist/capabilities/element/index.js.map +1 -0
- package/dist/capabilities/element/schemas/index.d.ts +325 -0
- package/dist/capabilities/element/schemas/index.d.ts.map +1 -0
- package/dist/capabilities/element/schemas/index.js +168 -0
- package/dist/capabilities/element/schemas/index.js.map +1 -0
- package/dist/capabilities/index.d.ts +34 -0
- package/dist/capabilities/index.d.ts.map +1 -0
- package/dist/capabilities/index.js +40 -0
- package/dist/capabilities/index.js.map +1 -0
- package/dist/capabilities/loader.d.ts +61 -0
- package/dist/capabilities/loader.d.ts.map +1 -0
- package/dist/capabilities/loader.js +164 -0
- package/dist/capabilities/loader.js.map +1 -0
- package/dist/capabilities/miniprogram/handlers/call-wx.d.ts +24 -0
- package/dist/capabilities/miniprogram/handlers/call-wx.d.ts.map +1 -0
- package/dist/capabilities/miniprogram/handlers/call-wx.js +37 -0
- package/dist/capabilities/miniprogram/handlers/call-wx.js.map +1 -0
- package/dist/capabilities/miniprogram/handlers/evaluate.d.ts +32 -0
- package/dist/capabilities/miniprogram/handlers/evaluate.d.ts.map +1 -0
- package/dist/capabilities/miniprogram/handlers/evaluate.js +51 -0
- package/dist/capabilities/miniprogram/handlers/evaluate.js.map +1 -0
- package/dist/capabilities/miniprogram/handlers/index.d.ts +12 -0
- package/dist/capabilities/miniprogram/handlers/index.d.ts.map +1 -0
- package/dist/capabilities/miniprogram/handlers/index.js +12 -0
- package/dist/capabilities/miniprogram/handlers/index.js.map +1 -0
- package/dist/capabilities/miniprogram/handlers/navigate.d.ts +26 -0
- package/dist/capabilities/miniprogram/handlers/navigate.d.ts.map +1 -0
- package/dist/capabilities/miniprogram/handlers/navigate.js +56 -0
- package/dist/capabilities/miniprogram/handlers/navigate.js.map +1 -0
- package/dist/capabilities/miniprogram/handlers/page-stack.d.ts +20 -0
- package/dist/capabilities/miniprogram/handlers/page-stack.d.ts.map +1 -0
- package/dist/capabilities/miniprogram/handlers/page-stack.js +37 -0
- package/dist/capabilities/miniprogram/handlers/page-stack.js.map +1 -0
- package/dist/capabilities/miniprogram/handlers/screenshot.d.ts +33 -0
- package/dist/capabilities/miniprogram/handlers/screenshot.d.ts.map +1 -0
- package/dist/capabilities/miniprogram/handlers/screenshot.js +132 -0
- package/dist/capabilities/miniprogram/handlers/screenshot.js.map +1 -0
- package/dist/capabilities/miniprogram/handlers/system-info.d.ts +17 -0
- package/dist/capabilities/miniprogram/handlers/system-info.d.ts.map +1 -0
- package/dist/capabilities/miniprogram/handlers/system-info.js +31 -0
- package/dist/capabilities/miniprogram/handlers/system-info.js.map +1 -0
- package/dist/capabilities/miniprogram/index.d.ts +15 -0
- package/dist/capabilities/miniprogram/index.d.ts.map +1 -0
- package/dist/capabilities/miniprogram/index.js +69 -0
- package/dist/capabilities/miniprogram/index.js.map +1 -0
- package/dist/capabilities/miniprogram/schemas/call-wx.d.ts +15 -0
- package/dist/capabilities/miniprogram/schemas/call-wx.d.ts.map +1 -0
- package/dist/capabilities/miniprogram/schemas/call-wx.js +11 -0
- package/dist/capabilities/miniprogram/schemas/call-wx.js.map +1 -0
- package/dist/capabilities/miniprogram/schemas/evaluate.d.ts +15 -0
- package/dist/capabilities/miniprogram/schemas/evaluate.d.ts.map +1 -0
- package/dist/capabilities/miniprogram/schemas/evaluate.js +11 -0
- package/dist/capabilities/miniprogram/schemas/evaluate.js.map +1 -0
- package/dist/capabilities/miniprogram/schemas/index.d.ts +10 -0
- package/dist/capabilities/miniprogram/schemas/index.d.ts.map +1 -0
- package/dist/capabilities/miniprogram/schemas/index.js +10 -0
- package/dist/capabilities/miniprogram/schemas/index.js.map +1 -0
- package/dist/capabilities/miniprogram/schemas/navigate.d.ts +18 -0
- package/dist/capabilities/miniprogram/schemas/navigate.d.ts.map +1 -0
- package/dist/capabilities/miniprogram/schemas/navigate.js +22 -0
- package/dist/capabilities/miniprogram/schemas/navigate.js.map +1 -0
- package/dist/capabilities/miniprogram/schemas/page-stack.d.ts +6 -0
- package/dist/capabilities/miniprogram/schemas/page-stack.d.ts.map +1 -0
- package/dist/capabilities/miniprogram/schemas/page-stack.js +6 -0
- package/dist/capabilities/miniprogram/schemas/page-stack.js.map +1 -0
- package/dist/capabilities/miniprogram/schemas/screenshot.d.ts +18 -0
- package/dist/capabilities/miniprogram/schemas/screenshot.d.ts.map +1 -0
- package/dist/capabilities/miniprogram/schemas/screenshot.js +21 -0
- package/dist/capabilities/miniprogram/schemas/screenshot.js.map +1 -0
- package/dist/capabilities/miniprogram/schemas/system-info.d.ts +6 -0
- package/dist/capabilities/miniprogram/schemas/system-info.d.ts.map +1 -0
- package/dist/capabilities/miniprogram/schemas/system-info.js +6 -0
- package/dist/capabilities/miniprogram/schemas/system-info.js.map +1 -0
- package/dist/capabilities/network/handlers/index.d.ts +7 -0
- package/dist/capabilities/network/handlers/index.d.ts.map +1 -0
- package/dist/capabilities/network/handlers/index.js +7 -0
- package/dist/capabilities/network/handlers/index.js.map +1 -0
- package/dist/capabilities/network/handlers/network-handlers.d.ts +53 -0
- package/dist/capabilities/network/handlers/network-handlers.d.ts.map +1 -0
- package/dist/capabilities/network/handlers/network-handlers.js +127 -0
- package/dist/capabilities/network/handlers/network-handlers.js.map +1 -0
- package/dist/capabilities/network/index.d.ts +15 -0
- package/dist/capabilities/network/index.d.ts.map +1 -0
- package/dist/capabilities/network/index.js +69 -0
- package/dist/capabilities/network/index.js.map +1 -0
- package/dist/capabilities/network/schemas/index.d.ts +53 -0
- package/dist/capabilities/network/schemas/index.d.ts.map +1 -0
- package/dist/capabilities/network/schemas/index.js +33 -0
- package/dist/capabilities/network/schemas/index.js.map +1 -0
- package/dist/capabilities/page/handlers/index.d.ts +7 -0
- package/dist/capabilities/page/handlers/index.d.ts.map +1 -0
- package/dist/capabilities/page/handlers/index.js +7 -0
- package/dist/capabilities/page/handlers/index.js.map +1 -0
- package/dist/capabilities/page/handlers/page-handlers.d.ts +165 -0
- package/dist/capabilities/page/handlers/page-handlers.d.ts.map +1 -0
- package/dist/capabilities/page/handlers/page-handlers.js +258 -0
- package/dist/capabilities/page/handlers/page-handlers.js.map +1 -0
- package/dist/capabilities/page/index.d.ts +15 -0
- package/dist/capabilities/page/index.d.ts.map +1 -0
- package/dist/capabilities/page/index.js +83 -0
- package/dist/capabilities/page/index.js.map +1 -0
- package/dist/capabilities/page/schemas/index.d.ts +91 -0
- package/dist/capabilities/page/schemas/index.d.ts.map +1 -0
- package/dist/capabilities/page/schemas/index.js +55 -0
- package/dist/capabilities/page/schemas/index.js.map +1 -0
- package/dist/capabilities/record/handlers/index.d.ts +7 -0
- package/dist/capabilities/record/handlers/index.d.ts.map +1 -0
- package/dist/capabilities/record/handlers/index.js +7 -0
- package/dist/capabilities/record/handlers/index.js.map +1 -0
- package/dist/capabilities/record/handlers/record-handlers.d.ts +76 -0
- package/dist/capabilities/record/handlers/record-handlers.d.ts.map +1 -0
- package/dist/capabilities/record/handlers/record-handlers.js +255 -0
- package/dist/capabilities/record/handlers/record-handlers.js.map +1 -0
- package/dist/capabilities/record/index.d.ts +15 -0
- package/dist/capabilities/record/index.d.ts.map +1 -0
- package/dist/capabilities/record/index.js +69 -0
- package/dist/capabilities/record/index.js.map +1 -0
- package/dist/capabilities/record/schemas/index.d.ts +47 -0
- package/dist/capabilities/record/schemas/index.d.ts.map +1 -0
- package/dist/capabilities/record/schemas/index.js +33 -0
- package/dist/capabilities/record/schemas/index.js.map +1 -0
- package/dist/capabilities/registry.d.ts +138 -0
- package/dist/capabilities/registry.d.ts.map +1 -0
- package/dist/capabilities/registry.js +261 -0
- package/dist/capabilities/registry.js.map +1 -0
- package/dist/capabilities/schema-registry.d.ts +4 -0
- package/dist/capabilities/schema-registry.d.ts.map +1 -0
- package/dist/capabilities/schema-registry.js +18 -0
- package/dist/capabilities/schema-registry.js.map +1 -0
- package/dist/capabilities/schema-types.d.ts +22 -0
- package/dist/capabilities/schema-types.d.ts.map +1 -0
- package/dist/capabilities/schema-types.js +2 -0
- package/dist/capabilities/schema-types.js.map +1 -0
- package/dist/capabilities/snapshot/handlers/index.d.ts +7 -0
- package/dist/capabilities/snapshot/handlers/index.d.ts.map +1 -0
- package/dist/capabilities/snapshot/handlers/index.js +7 -0
- package/dist/capabilities/snapshot/handlers/index.js.map +1 -0
- package/dist/capabilities/snapshot/handlers/snapshot-handlers.d.ts +75 -0
- package/dist/capabilities/snapshot/handlers/snapshot-handlers.d.ts.map +1 -0
- package/dist/capabilities/snapshot/handlers/snapshot-handlers.js +201 -0
- package/dist/capabilities/snapshot/handlers/snapshot-handlers.js.map +1 -0
- package/dist/capabilities/snapshot/index.d.ts +15 -0
- package/dist/capabilities/snapshot/index.d.ts.map +1 -0
- package/dist/capabilities/snapshot/index.js +48 -0
- package/dist/capabilities/snapshot/index.js.map +1 -0
- package/dist/capabilities/snapshot/schemas/index.d.ts +47 -0
- package/dist/capabilities/snapshot/schemas/index.d.ts.map +1 -0
- package/dist/capabilities/snapshot/schemas/index.js +28 -0
- package/dist/capabilities/snapshot/schemas/index.js.map +1 -0
- package/dist/config/loader.js +1 -1
- package/dist/config/loader.js.map +1 -1
- package/dist/core/element-ref.d.ts +1 -43
- package/dist/core/element-ref.d.ts.map +1 -1
- package/dist/core/element-ref.js +1 -212
- package/dist/core/element-ref.js.map +1 -1
- package/dist/core/logger.d.ts +1 -54
- package/dist/core/logger.d.ts.map +1 -1
- package/dist/core/logger.js +1 -377
- package/dist/core/logger.js.map +1 -1
- package/dist/core/output.d.ts +1 -20
- package/dist/core/output.d.ts.map +1 -1
- package/dist/core/output.js +1 -55
- package/dist/core/output.js.map +1 -1
- package/dist/core/report-generator.d.ts +1 -23
- package/dist/core/report-generator.d.ts.map +1 -1
- package/dist/core/report-generator.js +1 -211
- package/dist/core/report-generator.js.map +1 -1
- package/dist/core/session.d.ts +2 -82
- package/dist/core/session.d.ts.map +1 -1
- package/dist/core/session.js +2 -305
- package/dist/core/session.js.map +1 -1
- package/dist/core/timeout.d.ts +1 -48
- package/dist/core/timeout.d.ts.map +1 -1
- package/dist/core/timeout.js +1 -66
- package/dist/core/timeout.js.map +1 -1
- package/dist/core/tool-logger.d.ts +1 -82
- package/dist/core/tool-logger.d.ts.map +1 -1
- package/dist/core/tool-logger.js +1 -452
- package/dist/core/tool-logger.js.map +1 -1
- package/dist/core/validation.d.ts +1 -38
- package/dist/core/validation.d.ts.map +1 -1
- package/dist/core/validation.js +1 -92
- package/dist/core/validation.js.map +1 -1
- package/dist/runtime/element/element-ref.d.ts +44 -0
- package/dist/runtime/element/element-ref.d.ts.map +1 -0
- package/dist/runtime/element/element-ref.js +214 -0
- package/dist/runtime/element/element-ref.js.map +1 -0
- package/dist/runtime/element/index.d.ts +2 -0
- package/dist/runtime/element/index.d.ts.map +1 -0
- package/dist/runtime/element/index.js +2 -0
- package/dist/runtime/element/index.js.map +1 -0
- package/dist/runtime/index.d.ts +11 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/index.js +11 -0
- package/dist/runtime/index.js.map +1 -0
- package/dist/runtime/logging/index.d.ts +3 -0
- package/dist/runtime/logging/index.d.ts.map +1 -0
- package/dist/runtime/logging/index.js +3 -0
- package/dist/runtime/logging/index.js.map +1 -0
- package/dist/runtime/logging/logger.d.ts +55 -0
- package/dist/runtime/logging/logger.d.ts.map +1 -0
- package/dist/runtime/logging/logger.js +379 -0
- package/dist/runtime/logging/logger.js.map +1 -0
- package/dist/runtime/logging/tool-logger.d.ts +83 -0
- package/dist/runtime/logging/tool-logger.d.ts.map +1 -0
- package/dist/runtime/logging/tool-logger.js +454 -0
- package/dist/runtime/logging/tool-logger.js.map +1 -0
- package/dist/runtime/outputs/index.d.ts +3 -0
- package/dist/runtime/outputs/index.d.ts.map +1 -0
- package/dist/runtime/outputs/index.js +3 -0
- package/dist/runtime/outputs/index.js.map +1 -0
- package/dist/runtime/outputs/output-manager.d.ts +12 -0
- package/dist/runtime/outputs/output-manager.d.ts.map +1 -0
- package/dist/runtime/outputs/output-manager.js +39 -0
- package/dist/runtime/outputs/output-manager.js.map +1 -0
- package/dist/runtime/outputs/report-generator.d.ts +5 -0
- package/dist/runtime/outputs/report-generator.d.ts.map +1 -0
- package/dist/runtime/outputs/report-generator.js +175 -0
- package/dist/runtime/outputs/report-generator.js.map +1 -0
- package/dist/runtime/retry/index.d.ts +5 -0
- package/dist/runtime/retry/index.d.ts.map +1 -0
- package/dist/runtime/retry/index.js +5 -0
- package/dist/runtime/retry/index.js.map +1 -0
- package/dist/runtime/retry/retry.d.ts +61 -0
- package/dist/runtime/retry/retry.d.ts.map +1 -0
- package/dist/runtime/retry/retry.js +90 -0
- package/dist/runtime/retry/retry.js.map +1 -0
- package/dist/runtime/session/index.d.ts +3 -0
- package/dist/runtime/session/index.d.ts.map +1 -0
- package/dist/runtime/session/index.js +3 -0
- package/dist/runtime/session/index.js.map +1 -0
- package/dist/runtime/session/store.d.ts +28 -0
- package/dist/runtime/session/store.d.ts.map +1 -0
- package/dist/runtime/session/store.js +154 -0
- package/dist/runtime/session/store.js.map +1 -0
- package/dist/runtime/session/utils/cleanup.d.ts +3 -0
- package/dist/runtime/session/utils/cleanup.d.ts.map +1 -0
- package/dist/runtime/session/utils/cleanup.js +78 -0
- package/dist/runtime/session/utils/cleanup.js.map +1 -0
- package/dist/runtime/timeout/index.d.ts +2 -0
- package/dist/runtime/timeout/index.d.ts.map +1 -0
- package/dist/runtime/timeout/index.js +2 -0
- package/dist/runtime/timeout/index.js.map +1 -0
- package/dist/runtime/timeout/timeout.d.ts +59 -0
- package/dist/runtime/timeout/timeout.d.ts.map +1 -0
- package/dist/runtime/timeout/timeout.js +77 -0
- package/dist/runtime/timeout/timeout.js.map +1 -0
- package/dist/runtime/validation/index.d.ts +2 -0
- package/dist/runtime/validation/index.d.ts.map +1 -0
- package/dist/runtime/validation/index.js +2 -0
- package/dist/runtime/validation/index.js.map +1 -0
- package/dist/runtime/validation/validation.d.ts +39 -0
- package/dist/runtime/validation/validation.d.ts.map +1 -0
- package/dist/runtime/validation/validation.js +93 -0
- package/dist/runtime/validation/validation.js.map +1 -0
- package/dist/schemas/automator/miniprogram_close.json +12 -0
- package/dist/schemas/automator/miniprogram_connect.json +19 -0
- package/dist/schemas/automator/miniprogram_disconnect.json +12 -0
- package/dist/schemas/automator/miniprogram_launch.json +30 -0
- package/dist/server.js +5 -5
- package/dist/server.js.map +1 -1
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +8 -4
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/miniprogram.d.ts +11 -2
- package/dist/tools/miniprogram.d.ts.map +1 -1
- package/dist/tools/miniprogram.js +111 -41
- package/dist/tools/miniprogram.js.map +1 -1
- package/dist/tools/page.js +2 -2
- package/dist/tools/page.js.map +1 -1
- package/docs/current/01-architecture-migration.md +337 -0
- package/docs/current/02-screenshot-timeout-fix.md +589 -0
- package/docs/current/README.md +226 -0
- package/docs/directory-structure-and-code-style-best-practices.md +91 -0
- package/docs/migration/README.md +34 -0
- package/docs/migration/TC-ALIGN-01-notes.md +35 -0
- package/docs/migration/runtime-skeleton.md +50 -0
- package/docs/migration/tool-schema-strategy.md +75 -0
- package/docs//345/256/214/346/225/264/345/256/236/347/216/260/346/226/271/346/241/210.md +14 -14
- package/docs//347/254/254/344/270/200/347/211/210/346/234/254/346/226/271/346/241/210.md +7 -7
- package/package.json +4 -2
- package/docs/SIMPLE_USAGE.md +0 -210
- package/docs/architecture.E-Docs.md +0 -1359
- package/docs/architecture.F1.md +0 -720
- package/docs/architecture.F2.md +0 -871
- package/docs/architecture.F3.md +0 -905
- package/docs/architecture.md +0 -90
- package/docs/charter.A1.align.yaml +0 -170
- package/docs/charter.A2.align.yaml +0 -199
- package/docs/charter.A3.align.yaml +0 -242
- package/docs/charter.A4.align.yaml +0 -227
- package/docs/charter.B1.align.yaml +0 -179
- package/docs/charter.B2.align.yaml +0 -200
- package/docs/charter.B3.align.yaml +0 -200
- package/docs/charter.B4.align.yaml +0 -188
- package/docs/charter.C1.align.yaml +0 -190
- package/docs/charter.C2.align.yaml +0 -202
- package/docs/charter.C3.align.yaml +0 -211
- package/docs/charter.C4.align.yaml +0 -263
- package/docs/charter.C5.align.yaml +0 -220
- package/docs/charter.D1.align.yaml +0 -190
- package/docs/charter.D2.align.yaml +0 -234
- package/docs/charter.D3.align.yaml +0 -206
- package/docs/charter.E-Docs.align.yaml +0 -294
- package/docs/charter.F1.align.yaml +0 -193
- package/docs/charter.F2.align.yaml +0 -248
- package/docs/charter.F3.align.yaml +0 -287
- package/docs/charter.G.align.yaml +0 -174
- package/docs/charter.align.yaml +0 -111
- package/docs/maintenance.md +0 -682
- package/docs/playwright-mcp/350/260/203/347/240/224.md +0 -53
- package/docs/setup-guide.md +0 -775
- package/docs/tasks.A1.atomize.md +0 -296
- package/docs/tasks.A2.atomize.md +0 -408
- package/docs/tasks.A3.atomize.md +0 -564
- package/docs/tasks.A4.atomize.md +0 -496
- package/docs/tasks.B1.atomize.md +0 -352
- package/docs/tasks.B2.atomize.md +0 -561
- package/docs/tasks.B3.atomize.md +0 -508
- package/docs/tasks.B4.atomize.md +0 -504
- package/docs/tasks.C1.atomize.md +0 -540
- package/docs/tasks.C2.atomize.md +0 -665
- package/docs/tasks.C3.atomize.md +0 -745
- package/docs/tasks.C4.atomize.md +0 -908
- package/docs/tasks.C5.atomize.md +0 -755
- package/docs/tasks.D1.atomize.md +0 -547
- package/docs/tasks.D2.atomize.md +0 -619
- package/docs/tasks.D3.atomize.md +0 -790
- package/docs/tasks.E-Docs.atomize.md +0 -1204
- package/docs/tasks.atomize.md +0 -189
package/docs/architecture.F1.md
DELETED
|
@@ -1,720 +0,0 @@
|
|
|
1
|
-
# F1 Architecture: Structured Logging Enhancement
|
|
2
|
-
|
|
3
|
-
**Task**: F1 - Structured Logging Enhancement
|
|
4
|
-
**Date**: 2025-10-03
|
|
5
|
-
**Status**: Architect
|
|
6
|
-
**Author**: ClaudeCode
|
|
7
|
-
|
|
8
|
-
---
|
|
9
|
-
|
|
10
|
-
## 1. Architecture Overview
|
|
11
|
-
|
|
12
|
-
### 1.1 System Context
|
|
13
|
-
|
|
14
|
-
```
|
|
15
|
-
┌─────────────────────────────────────────────────────────────┐
|
|
16
|
-
│ MCP Server │
|
|
17
|
-
│ │
|
|
18
|
-
│ ┌──────────────┐ ┌──────────────┐ │
|
|
19
|
-
│ │ Tool Handler │─────▶│ ToolLogger │ (NEW) │
|
|
20
|
-
│ │ (65 tools) │ │ Wrapper │ │
|
|
21
|
-
│ └──────────────┘ └──────┬───────┘ │
|
|
22
|
-
│ │ │
|
|
23
|
-
│ ▼ │
|
|
24
|
-
│ ┌──────────────────┐ │
|
|
25
|
-
│ │ Enhanced Logger │ │
|
|
26
|
-
│ │ (ConsoleLogger) │ │
|
|
27
|
-
│ └────────┬─────────┘ │
|
|
28
|
-
│ │ │
|
|
29
|
-
│ ┌──────────────┼──────────────┐ │
|
|
30
|
-
│ ▼ ▼ ▼ │
|
|
31
|
-
│ ┌─────────┐ ┌─────────┐ ┌──────────┐ │
|
|
32
|
-
│ │ Console │ │ File │ │ Buffer │ │
|
|
33
|
-
│ │ (stderr)│ │ Writer │ │ (async) │ │
|
|
34
|
-
│ └─────────┘ └─────────┘ └──────────┘ │
|
|
35
|
-
│ │ │
|
|
36
|
-
│ ▼ │
|
|
37
|
-
│ outputDir/logs/session-{id}.log │
|
|
38
|
-
└─────────────────────────────────────────────────────────────┘
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
### 1.2 Component Responsibilities
|
|
42
|
-
|
|
43
|
-
| Component | Responsibility | Location |
|
|
44
|
-
|-----------|---------------|----------|
|
|
45
|
-
| **ToolLogger** | 自动记录工具调用 START/END/ERROR | `src/core/tool-logger.ts` |
|
|
46
|
-
| **Enhanced ConsoleLogger** | 文件写入、批量缓冲、格式化 | `src/core/logger.ts` |
|
|
47
|
-
| **FileWriter** | 异步文件写入管理 | `src/core/logger.ts` (内部类) |
|
|
48
|
-
| **Tool Registration** | 集成 ToolLogger 到所有工具 | `src/tools/index.ts` |
|
|
49
|
-
|
|
50
|
-
---
|
|
51
|
-
|
|
52
|
-
## 2. Data Flow
|
|
53
|
-
|
|
54
|
-
### 2.1 Tool Call Flow (Enhanced)
|
|
55
|
-
|
|
56
|
-
```
|
|
57
|
-
1. User/LLM calls tool
|
|
58
|
-
│
|
|
59
|
-
├─▶ Tool Handler registered with ToolLogger wrapper
|
|
60
|
-
│
|
|
61
|
-
2. ToolLogger.wrap() intercepts call
|
|
62
|
-
│
|
|
63
|
-
├─▶ Log START (tool name, args, sessionId)
|
|
64
|
-
│ │
|
|
65
|
-
│ └─▶ ConsoleLogger.info() + file write (if enabled)
|
|
66
|
-
│
|
|
67
|
-
3. Execute actual tool handler
|
|
68
|
-
│
|
|
69
|
-
├─▶ [SUCCESS] Log END (tool name, result, duration)
|
|
70
|
-
│ │
|
|
71
|
-
│ └─▶ ConsoleLogger.info() + file write
|
|
72
|
-
│
|
|
73
|
-
└─▶ [FAILURE] Log ERROR (tool name, error, duration)
|
|
74
|
-
│
|
|
75
|
-
└─▶ ConsoleLogger.error() + file write
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
### 2.2 File Writing Flow
|
|
79
|
-
|
|
80
|
-
```
|
|
81
|
-
Logger.info/warn/error()
|
|
82
|
-
│
|
|
83
|
-
├─▶ Create LogEntry { timestamp, level, sessionId, toolName, message, context }
|
|
84
|
-
│
|
|
85
|
-
├─▶ Format for console → stderr output
|
|
86
|
-
│
|
|
87
|
-
└─▶ If fileLogging enabled:
|
|
88
|
-
│
|
|
89
|
-
├─▶ Add to write buffer (JSON Lines format)
|
|
90
|
-
│
|
|
91
|
-
└─▶ Flush when:
|
|
92
|
-
├─▶ Buffer size >= 100 entries
|
|
93
|
-
├─▶ 5 seconds elapsed since last flush
|
|
94
|
-
└─▶ Logger dispose/cleanup
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
---
|
|
98
|
-
|
|
99
|
-
## 3. Interface Design
|
|
100
|
-
|
|
101
|
-
### 3.1 Enhanced Types
|
|
102
|
-
|
|
103
|
-
```typescript
|
|
104
|
-
// src/types.ts - New types
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Tool execution log entry with timing
|
|
108
|
-
*/
|
|
109
|
-
export interface ToolLogEntry extends LogEntry {
|
|
110
|
-
toolName: string // Tool name (e.g., "page_query")
|
|
111
|
-
phase: 'START' | 'END' | 'ERROR'
|
|
112
|
-
args?: any // Tool input arguments (START phase)
|
|
113
|
-
result?: any // Tool output result (END phase)
|
|
114
|
-
error?: string // Error message (ERROR phase)
|
|
115
|
-
duration?: number // Execution time in ms (END/ERROR phase)
|
|
116
|
-
stackTrace?: string // Error stack trace (ERROR phase)
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Logger configuration
|
|
121
|
-
*/
|
|
122
|
-
export interface LoggerConfig {
|
|
123
|
-
level?: LogLevel // Minimum log level (default: 'info')
|
|
124
|
-
enableFileLog?: boolean // Enable file logging (default: false)
|
|
125
|
-
outputDir?: string // Output directory for logs
|
|
126
|
-
bufferSize?: number // Buffer size for file writes (default: 100)
|
|
127
|
-
flushInterval?: number // Flush interval in ms (default: 5000)
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* Extended Logger interface with file support
|
|
132
|
-
*/
|
|
133
|
-
export interface Logger {
|
|
134
|
-
info(message: string, context?: Record<string, any>): void
|
|
135
|
-
warn(message: string, context?: Record<string, any>): void
|
|
136
|
-
error(message: string, context?: Record<string, any>): void
|
|
137
|
-
debug(message: string, context?: Record<string, any>): void
|
|
138
|
-
child(toolName: string): Logger
|
|
139
|
-
|
|
140
|
-
// New methods for F1
|
|
141
|
-
dispose?(): Promise<void> // Flush buffer and close file handles
|
|
142
|
-
flush?(): Promise<void> // Force flush buffer to disk
|
|
143
|
-
}
|
|
144
|
-
```
|
|
145
|
-
|
|
146
|
-
### 3.2 ToolLogger API
|
|
147
|
-
|
|
148
|
-
```typescript
|
|
149
|
-
// src/core/tool-logger.ts
|
|
150
|
-
|
|
151
|
-
export class ToolLogger {
|
|
152
|
-
constructor(private logger: Logger) {}
|
|
153
|
-
|
|
154
|
-
/**
|
|
155
|
-
* Wrap a tool handler with automatic logging
|
|
156
|
-
*
|
|
157
|
-
* @param toolName - Name of the tool (e.g., "page_query")
|
|
158
|
-
* @param handler - Original tool handler function
|
|
159
|
-
* @returns Wrapped handler with automatic logging
|
|
160
|
-
*/
|
|
161
|
-
wrap<TArgs, TResult>(
|
|
162
|
-
toolName: string,
|
|
163
|
-
handler: (session: SessionState, args: TArgs) => Promise<TResult>
|
|
164
|
-
): (session: SessionState, args: TArgs) => Promise<TResult> {
|
|
165
|
-
return async (session: SessionState, args: TArgs): Promise<TResult> => {
|
|
166
|
-
const startTime = Date.now()
|
|
167
|
-
const childLogger = this.logger.child(toolName)
|
|
168
|
-
|
|
169
|
-
// Log START
|
|
170
|
-
childLogger.info(`Tool call started`, {
|
|
171
|
-
phase: 'START',
|
|
172
|
-
args: this.sanitizeArgs(args),
|
|
173
|
-
})
|
|
174
|
-
|
|
175
|
-
try {
|
|
176
|
-
// Execute tool
|
|
177
|
-
const result = await handler(session, args)
|
|
178
|
-
const duration = Date.now() - startTime
|
|
179
|
-
|
|
180
|
-
// Log END
|
|
181
|
-
childLogger.info(`Tool call completed`, {
|
|
182
|
-
phase: 'END',
|
|
183
|
-
duration,
|
|
184
|
-
result: this.sanitizeResult(result),
|
|
185
|
-
})
|
|
186
|
-
|
|
187
|
-
return result
|
|
188
|
-
} catch (error) {
|
|
189
|
-
const duration = Date.now() - startTime
|
|
190
|
-
|
|
191
|
-
// Log ERROR
|
|
192
|
-
childLogger.error(`Tool call failed`, {
|
|
193
|
-
phase: 'ERROR',
|
|
194
|
-
duration,
|
|
195
|
-
error: error instanceof Error ? error.message : String(error),
|
|
196
|
-
stackTrace: error instanceof Error ? error.stack : undefined,
|
|
197
|
-
})
|
|
198
|
-
|
|
199
|
-
throw error // Re-throw to preserve error handling
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
/**
|
|
205
|
-
* Sanitize arguments for logging (remove sensitive data, limit size)
|
|
206
|
-
*/
|
|
207
|
-
private sanitizeArgs(args: any): any {
|
|
208
|
-
// Implementation details...
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
/**
|
|
212
|
-
* Sanitize result for logging (limit size, remove large objects)
|
|
213
|
-
*/
|
|
214
|
-
private sanitizeResult(result: any): any {
|
|
215
|
-
// Implementation details...
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
```
|
|
219
|
-
|
|
220
|
-
### 3.3 Enhanced ConsoleLogger
|
|
221
|
-
|
|
222
|
-
```typescript
|
|
223
|
-
// src/core/logger.ts - Enhanced implementation
|
|
224
|
-
|
|
225
|
-
export class ConsoleLogger implements Logger {
|
|
226
|
-
private sessionId?: string
|
|
227
|
-
private toolName?: string
|
|
228
|
-
private config: Required<LoggerConfig>
|
|
229
|
-
private fileWriter?: FileWriter // Internal file writer
|
|
230
|
-
|
|
231
|
-
constructor(
|
|
232
|
-
sessionId?: string,
|
|
233
|
-
toolName?: string,
|
|
234
|
-
config?: LoggerConfig
|
|
235
|
-
) {
|
|
236
|
-
this.sessionId = sessionId
|
|
237
|
-
this.toolName = toolName
|
|
238
|
-
this.config = this.mergeConfig(config)
|
|
239
|
-
|
|
240
|
-
// Initialize file writer if enabled
|
|
241
|
-
if (this.config.enableFileLog && sessionId) {
|
|
242
|
-
this.fileWriter = new FileWriter(
|
|
243
|
-
sessionId,
|
|
244
|
-
this.config.outputDir,
|
|
245
|
-
this.config.bufferSize,
|
|
246
|
-
this.config.flushInterval
|
|
247
|
-
)
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
info(message: string, context?: Record<string, any>): void {
|
|
252
|
-
const entry = this.createEntry('info', message, context)
|
|
253
|
-
this.log(entry)
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
// ... other methods ...
|
|
257
|
-
|
|
258
|
-
private log(entry: LogEntry): void {
|
|
259
|
-
// Console output (always)
|
|
260
|
-
console.error(this.format(entry))
|
|
261
|
-
|
|
262
|
-
// File output (if enabled)
|
|
263
|
-
this.fileWriter?.write(entry)
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
async dispose(): Promise<void> {
|
|
267
|
-
await this.fileWriter?.dispose()
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
async flush(): Promise<void> {
|
|
271
|
-
await this.fileWriter?.flush()
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
/**
|
|
276
|
-
* Internal file writer with buffering
|
|
277
|
-
*/
|
|
278
|
-
class FileWriter {
|
|
279
|
-
private buffer: LogEntry[] = []
|
|
280
|
-
private flushTimer?: NodeJS.Timeout
|
|
281
|
-
private fileHandle?: FileHandle
|
|
282
|
-
private disposed = false
|
|
283
|
-
|
|
284
|
-
constructor(
|
|
285
|
-
private sessionId: string,
|
|
286
|
-
private outputDir: string,
|
|
287
|
-
private bufferSize: number,
|
|
288
|
-
private flushInterval: number
|
|
289
|
-
) {
|
|
290
|
-
this.startFlushTimer()
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
write(entry: LogEntry): void {
|
|
294
|
-
if (this.disposed) return
|
|
295
|
-
|
|
296
|
-
this.buffer.push(entry)
|
|
297
|
-
|
|
298
|
-
if (this.buffer.length >= this.bufferSize) {
|
|
299
|
-
// Fire-and-forget flush (non-blocking)
|
|
300
|
-
void this.flush().catch(err => {
|
|
301
|
-
console.error('Failed to flush log buffer:', err)
|
|
302
|
-
})
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
async flush(): Promise<void> {
|
|
307
|
-
if (this.buffer.length === 0 || this.disposed) return
|
|
308
|
-
|
|
309
|
-
const entries = this.buffer.splice(0, this.buffer.length)
|
|
310
|
-
const lines = entries.map(e => JSON.stringify(e)).join('\n') + '\n'
|
|
311
|
-
|
|
312
|
-
try {
|
|
313
|
-
// Ensure file handle is open
|
|
314
|
-
if (!this.fileHandle) {
|
|
315
|
-
await this.ensureLogDirectory()
|
|
316
|
-
const logPath = join(this.outputDir, 'logs', `session-${this.sessionId}.log`)
|
|
317
|
-
this.fileHandle = await open(logPath, 'a')
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
// Write to file
|
|
321
|
-
await this.fileHandle.write(lines)
|
|
322
|
-
} catch (error) {
|
|
323
|
-
console.error('Failed to write logs to file:', error)
|
|
324
|
-
// Re-add entries to buffer for retry
|
|
325
|
-
this.buffer.unshift(...entries)
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
async dispose(): Promise<void> {
|
|
330
|
-
this.disposed = true
|
|
331
|
-
clearInterval(this.flushTimer)
|
|
332
|
-
await this.flush()
|
|
333
|
-
await this.fileHandle?.close()
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
private startFlushTimer(): void {
|
|
337
|
-
this.flushTimer = setInterval(() => {
|
|
338
|
-
void this.flush().catch(err => {
|
|
339
|
-
console.error('Scheduled flush failed:', err)
|
|
340
|
-
})
|
|
341
|
-
}, this.flushInterval)
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
private async ensureLogDirectory(): Promise<void> {
|
|
345
|
-
const logDir = join(this.outputDir, 'logs')
|
|
346
|
-
await mkdir(logDir, { recursive: true })
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
```
|
|
350
|
-
|
|
351
|
-
---
|
|
352
|
-
|
|
353
|
-
## 4. Integration Points
|
|
354
|
-
|
|
355
|
-
### 4.1 Tool Registration Integration
|
|
356
|
-
|
|
357
|
-
```typescript
|
|
358
|
-
// src/tools/index.ts - Modified registerTools()
|
|
359
|
-
|
|
360
|
-
export function registerTools(
|
|
361
|
-
server: Server,
|
|
362
|
-
options: ToolRegistrationOptions
|
|
363
|
-
): Tool[] {
|
|
364
|
-
const { getSession, deleteSession, capabilities, sessionStore } = options
|
|
365
|
-
|
|
366
|
-
// ... existing code ...
|
|
367
|
-
|
|
368
|
-
// Create ToolLogger for session
|
|
369
|
-
const createToolLogger = (sessionId: string): ToolLogger => {
|
|
370
|
-
const session = sessionStore.get(sessionId)
|
|
371
|
-
if (!session?.logger) {
|
|
372
|
-
throw new Error('Session logger not initialized')
|
|
373
|
-
}
|
|
374
|
-
return new ToolLogger(session.logger)
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
// Register CallToolRequest handler with logging
|
|
378
|
-
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
379
|
-
const toolName = request.params.name
|
|
380
|
-
const args = request.params.arguments || {}
|
|
381
|
-
const sessionId = request.meta?.sessionId || 'default'
|
|
382
|
-
|
|
383
|
-
// Get or create session
|
|
384
|
-
const session = await getSession(sessionId)
|
|
385
|
-
|
|
386
|
-
// Create tool logger
|
|
387
|
-
const toolLogger = createToolLogger(sessionId)
|
|
388
|
-
|
|
389
|
-
// Get handler
|
|
390
|
-
const handler = handlers[toolName]
|
|
391
|
-
if (!handler) {
|
|
392
|
-
throw new Error(`Unknown tool: ${toolName}`)
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
// Wrap handler with logging
|
|
396
|
-
const wrappedHandler = toolLogger.wrap(toolName, handler)
|
|
397
|
-
|
|
398
|
-
// Execute wrapped handler
|
|
399
|
-
const result = await wrappedHandler(session, args)
|
|
400
|
-
|
|
401
|
-
return {
|
|
402
|
-
content: [
|
|
403
|
-
{
|
|
404
|
-
type: 'text',
|
|
405
|
-
text: typeof result === 'string' ? result : JSON.stringify(result, null, 2),
|
|
406
|
-
},
|
|
407
|
-
],
|
|
408
|
-
}
|
|
409
|
-
})
|
|
410
|
-
|
|
411
|
-
return tools
|
|
412
|
-
}
|
|
413
|
-
```
|
|
414
|
-
|
|
415
|
-
### 4.2 Session Initialization
|
|
416
|
-
|
|
417
|
-
```typescript
|
|
418
|
-
// src/core/session.ts - Modified SessionStore.getOrCreate()
|
|
419
|
-
|
|
420
|
-
getOrCreate(sessionId: string, config?: SessionConfig): SessionState {
|
|
421
|
-
let session = this.get(sessionId)
|
|
422
|
-
|
|
423
|
-
if (!session) {
|
|
424
|
-
// Create logger with config
|
|
425
|
-
const loggerConfig: LoggerConfig = {
|
|
426
|
-
level: 'info',
|
|
427
|
-
enableFileLog: config?.enableFileLog || false,
|
|
428
|
-
outputDir: config?.outputDir || this.outputDir,
|
|
429
|
-
bufferSize: 100,
|
|
430
|
-
flushInterval: 5000,
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
const logger = new ConsoleLogger(sessionId, undefined, loggerConfig)
|
|
434
|
-
const outputManager = new OutputManager(sessionId, this.outputDir)
|
|
435
|
-
|
|
436
|
-
session = {
|
|
437
|
-
sessionId,
|
|
438
|
-
pages: [],
|
|
439
|
-
elements: new Map(),
|
|
440
|
-
outputDir: this.outputDir,
|
|
441
|
-
createdAt: new Date(),
|
|
442
|
-
lastActivity: new Date(),
|
|
443
|
-
config,
|
|
444
|
-
logger,
|
|
445
|
-
outputManager,
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
this.set(sessionId, session)
|
|
449
|
-
logger.info('Session created', { sessionId })
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
return session
|
|
453
|
-
}
|
|
454
|
-
```
|
|
455
|
-
|
|
456
|
-
### 4.3 Configuration Extension
|
|
457
|
-
|
|
458
|
-
```typescript
|
|
459
|
-
// src/config/defaults.ts - Add logging defaults
|
|
460
|
-
|
|
461
|
-
export const DEFAULT_LOG_LEVEL: LogLevel = 'info'
|
|
462
|
-
export const DEFAULT_ENABLE_FILE_LOG = false
|
|
463
|
-
export const DEFAULT_LOG_BUFFER_SIZE = 100
|
|
464
|
-
export const DEFAULT_LOG_FLUSH_INTERVAL = 5000
|
|
465
|
-
|
|
466
|
-
export const DEFAULT_SERVER_CONFIG: Required<ServerConfig> = {
|
|
467
|
-
// ... existing ...
|
|
468
|
-
logLevel: DEFAULT_LOG_LEVEL,
|
|
469
|
-
enableFileLog: DEFAULT_ENABLE_FILE_LOG,
|
|
470
|
-
logBufferSize: DEFAULT_LOG_BUFFER_SIZE,
|
|
471
|
-
logFlushInterval: DEFAULT_LOG_FLUSH_INTERVAL,
|
|
472
|
-
}
|
|
473
|
-
```
|
|
474
|
-
|
|
475
|
-
---
|
|
476
|
-
|
|
477
|
-
## 5. Data Structures
|
|
478
|
-
|
|
479
|
-
### 5.1 Log Entry Format
|
|
480
|
-
|
|
481
|
-
**Console Output** (Human-readable):
|
|
482
|
-
```
|
|
483
|
-
2025-10-03T10:30:45.123Z INFO [session-abc] [page_query]: Tool call started {"phase":"START","args":{"selector":".btn"}}
|
|
484
|
-
2025-10-03T10:30:45.234Z INFO [session-abc] [page_query]: Tool call completed {"phase":"END","duration":111,"result":{"refId":"elem-123"}}
|
|
485
|
-
```
|
|
486
|
-
|
|
487
|
-
**File Output** (JSON Lines):
|
|
488
|
-
```json
|
|
489
|
-
{"timestamp":"2025-10-03T10:30:45.123Z","level":"info","sessionId":"session-abc","toolName":"page_query","message":"Tool call started","context":{"phase":"START","args":{"selector":".btn"}}}
|
|
490
|
-
{"timestamp":"2025-10-03T10:30:45.234Z","level":"info","sessionId":"session-abc","toolName":"page_query","message":"Tool call completed","context":{"phase":"END","duration":111,"result":{"refId":"elem-123"}}}
|
|
491
|
-
```
|
|
492
|
-
|
|
493
|
-
### 5.2 Log File Structure
|
|
494
|
-
|
|
495
|
-
```
|
|
496
|
-
outputDir/
|
|
497
|
-
└── logs/
|
|
498
|
-
├── session-abc.log (JSON Lines format)
|
|
499
|
-
├── session-def.log
|
|
500
|
-
└── session-xyz.log
|
|
501
|
-
```
|
|
502
|
-
|
|
503
|
-
---
|
|
504
|
-
|
|
505
|
-
## 6. Performance Considerations
|
|
506
|
-
|
|
507
|
-
### 6.1 Optimization Strategies
|
|
508
|
-
|
|
509
|
-
| Strategy | Implementation | Impact |
|
|
510
|
-
|----------|---------------|--------|
|
|
511
|
-
| **Async File I/O** | Non-blocking writes, buffered | Minimal tool latency |
|
|
512
|
-
| **Batch Writes** | Buffer 100 entries or 5s | Reduce syscall overhead |
|
|
513
|
-
| **Argument Sanitization** | Limit size to 1KB per arg | Prevent memory bloat |
|
|
514
|
-
| **Result Sanitization** | Truncate large results | Control log file size |
|
|
515
|
-
|
|
516
|
-
### 6.2 Expected Overhead
|
|
517
|
-
|
|
518
|
-
| Scenario | Overhead | Justification |
|
|
519
|
-
|----------|----------|---------------|
|
|
520
|
-
| Console logging only | <1% | Minimal string formatting |
|
|
521
|
-
| File logging enabled | 2-5% | Buffered async writes |
|
|
522
|
-
| High-frequency calls (>100/s) | <5% | Buffering prevents bottleneck |
|
|
523
|
-
|
|
524
|
-
---
|
|
525
|
-
|
|
526
|
-
## 7. Error Handling
|
|
527
|
-
|
|
528
|
-
### 7.1 Failure Modes
|
|
529
|
-
|
|
530
|
-
| Failure | Behavior | Recovery |
|
|
531
|
-
|---------|----------|----------|
|
|
532
|
-
| **File write fails** | Log error to stderr, continue execution | Retry on next flush |
|
|
533
|
-
| **Disk full** | Log warning, disable file logging | Continue with console only |
|
|
534
|
-
| **Buffer overflow** | Force flush, log warning | Temporary backpressure |
|
|
535
|
-
| **Dispose timeout** | Wait up to 5s, then warn | Logs may be incomplete |
|
|
536
|
-
|
|
537
|
-
### 7.2 Graceful Degradation
|
|
538
|
-
|
|
539
|
-
```typescript
|
|
540
|
-
// Example: File write failure handling
|
|
541
|
-
try {
|
|
542
|
-
await this.fileHandle.write(lines)
|
|
543
|
-
} catch (error) {
|
|
544
|
-
if (error.code === 'ENOSPC') {
|
|
545
|
-
console.error('Disk full, disabling file logging')
|
|
546
|
-
this.disposed = true
|
|
547
|
-
} else {
|
|
548
|
-
console.error('Failed to write logs:', error)
|
|
549
|
-
// Re-buffer for retry
|
|
550
|
-
this.buffer.unshift(...entries)
|
|
551
|
-
}
|
|
552
|
-
}
|
|
553
|
-
```
|
|
554
|
-
|
|
555
|
-
---
|
|
556
|
-
|
|
557
|
-
## 8. Security Considerations
|
|
558
|
-
|
|
559
|
-
### 8.1 Sensitive Data Handling
|
|
560
|
-
|
|
561
|
-
**Sanitization Rules**:
|
|
562
|
-
- Passwords/tokens: Replace with `[REDACTED]`
|
|
563
|
-
- Large objects (>1KB): Truncate with `... (${bytes} bytes total)`
|
|
564
|
-
- Binary data: Convert to `<Buffer ${length} bytes>`
|
|
565
|
-
|
|
566
|
-
**Example**:
|
|
567
|
-
```typescript
|
|
568
|
-
private sanitizeArgs(args: any): any {
|
|
569
|
-
const SENSITIVE_KEYS = ['password', 'token', 'secret', 'apiKey']
|
|
570
|
-
const MAX_SIZE = 1024 // 1KB
|
|
571
|
-
|
|
572
|
-
const sanitized = JSON.parse(JSON.stringify(args, (key, value) => {
|
|
573
|
-
// Redact sensitive keys
|
|
574
|
-
if (SENSITIVE_KEYS.includes(key.toLowerCase())) {
|
|
575
|
-
return '[REDACTED]'
|
|
576
|
-
}
|
|
577
|
-
// Truncate large strings
|
|
578
|
-
if (typeof value === 'string' && value.length > MAX_SIZE) {
|
|
579
|
-
return value.substring(0, MAX_SIZE) + `... (${value.length} bytes total)`
|
|
580
|
-
}
|
|
581
|
-
return value
|
|
582
|
-
}))
|
|
583
|
-
|
|
584
|
-
return sanitized
|
|
585
|
-
}
|
|
586
|
-
```
|
|
587
|
-
|
|
588
|
-
---
|
|
589
|
-
|
|
590
|
-
## 9. Testing Strategy
|
|
591
|
-
|
|
592
|
-
### 9.1 Unit Tests
|
|
593
|
-
|
|
594
|
-
| Test Suite | Tests | Coverage |
|
|
595
|
-
|------------|-------|----------|
|
|
596
|
-
| `logger-enhanced.test.ts` | 15 | File writing, buffering, flush timing |
|
|
597
|
-
| `tool-logger.test.ts` | 10 | Wrapper behavior, START/END/ERROR logs |
|
|
598
|
-
| Integration (tools/index) | 5 | End-to-end tool call logging |
|
|
599
|
-
|
|
600
|
-
### 9.2 Test Scenarios
|
|
601
|
-
|
|
602
|
-
1. **File Logging**:
|
|
603
|
-
- Enable/disable via config
|
|
604
|
-
- Buffer flush on size limit
|
|
605
|
-
- Buffer flush on time interval
|
|
606
|
-
- Dispose triggers final flush
|
|
607
|
-
|
|
608
|
-
2. **Tool Wrapper**:
|
|
609
|
-
- START log before execution
|
|
610
|
-
- END log with duration on success
|
|
611
|
-
- ERROR log with stack trace on failure
|
|
612
|
-
- Re-throw original error
|
|
613
|
-
|
|
614
|
-
3. **Error Handling**:
|
|
615
|
-
- File write failure doesn't break tool
|
|
616
|
-
- Disk full disables file logging
|
|
617
|
-
- Missing output directory created automatically
|
|
618
|
-
|
|
619
|
-
---
|
|
620
|
-
|
|
621
|
-
## 10. Migration Path
|
|
622
|
-
|
|
623
|
-
### 10.1 Backward Compatibility
|
|
624
|
-
|
|
625
|
-
- ✅ Existing `Logger` interface unchanged
|
|
626
|
-
- ✅ `ConsoleLogger` constructor backward compatible (new params optional)
|
|
627
|
-
- ✅ File logging disabled by default
|
|
628
|
-
- ✅ No breaking changes to tool handlers
|
|
629
|
-
|
|
630
|
-
### 10.2 Opt-in Enhancement
|
|
631
|
-
|
|
632
|
-
```json
|
|
633
|
-
// .mcp.json - Enable file logging
|
|
634
|
-
{
|
|
635
|
-
"projectPath": "/path/to/project",
|
|
636
|
-
"logLevel": "info",
|
|
637
|
-
"enableFileLog": true,
|
|
638
|
-
"outputDir": ".mcp-artifacts"
|
|
639
|
-
}
|
|
640
|
-
```
|
|
641
|
-
|
|
642
|
-
---
|
|
643
|
-
|
|
644
|
-
## 11. ADRs (Architecture Decision Records)
|
|
645
|
-
|
|
646
|
-
### ADR-F1-001: JSON Lines for File Format
|
|
647
|
-
|
|
648
|
-
**Decision**: Use JSON Lines (newline-delimited JSON) instead of single JSON array
|
|
649
|
-
|
|
650
|
-
**Rationale**:
|
|
651
|
-
- Streaming-friendly (can read line-by-line)
|
|
652
|
-
- Append-only (no need to rewrite entire file)
|
|
653
|
-
- Standard format (supported by jq, grep, etc.)
|
|
654
|
-
|
|
655
|
-
**Alternatives Considered**:
|
|
656
|
-
- Single JSON array: Requires rewriting entire file on each append
|
|
657
|
-
- CSV: Less structured, harder to parse complex objects
|
|
658
|
-
|
|
659
|
-
---
|
|
660
|
-
|
|
661
|
-
### ADR-F1-002: Async File I/O with Buffering
|
|
662
|
-
|
|
663
|
-
**Decision**: Use buffered async file writes (100 entries or 5s)
|
|
664
|
-
|
|
665
|
-
**Rationale**:
|
|
666
|
-
- Non-blocking: Tool execution not delayed by I/O
|
|
667
|
-
- Efficient: Batch writes reduce syscall overhead
|
|
668
|
-
- Acceptable latency: 5s max delay for log availability
|
|
669
|
-
|
|
670
|
-
**Alternatives Considered**:
|
|
671
|
-
- Sync writes: Would block tool execution
|
|
672
|
-
- Immediate async writes: High syscall overhead
|
|
673
|
-
|
|
674
|
-
---
|
|
675
|
-
|
|
676
|
-
### ADR-F1-003: Automatic Tool Wrapping
|
|
677
|
-
|
|
678
|
-
**Decision**: Wrap all tool handlers with ToolLogger automatically in `registerTools()`
|
|
679
|
-
|
|
680
|
-
**Rationale**:
|
|
681
|
-
- Zero boilerplate: Developers don't need to add logging manually
|
|
682
|
-
- Consistent: All tools logged uniformly
|
|
683
|
-
- Centralized: Easy to modify logging behavior globally
|
|
684
|
-
|
|
685
|
-
**Alternatives Considered**:
|
|
686
|
-
- Manual logging in each tool: High maintenance burden, inconsistent
|
|
687
|
-
- AOP/Decorators: Not well-supported in ESM, complex setup
|
|
688
|
-
|
|
689
|
-
---
|
|
690
|
-
|
|
691
|
-
## 12. Open Questions (Resolved)
|
|
692
|
-
|
|
693
|
-
| Question | Answer | Rationale |
|
|
694
|
-
|----------|--------|-----------|
|
|
695
|
-
| Buffer size? | 100 entries | Balance memory vs flush frequency |
|
|
696
|
-
| Flush interval? | 5 seconds | Acceptable latency for debugging |
|
|
697
|
-
| Max log file size? | No limit (warn at 10MB) | User-managed cleanup |
|
|
698
|
-
| Sensitive data handling? | Sanitize via allowlist | Prevent accidental logging |
|
|
699
|
-
|
|
700
|
-
---
|
|
701
|
-
|
|
702
|
-
## 13. Implementation Checklist
|
|
703
|
-
|
|
704
|
-
- [ ] Define new types in `src/types.ts`
|
|
705
|
-
- [ ] Implement `FileWriter` class in `src/core/logger.ts`
|
|
706
|
-
- [ ] Enhance `ConsoleLogger` with file support
|
|
707
|
-
- [ ] Create `ToolLogger` wrapper in `src/core/tool-logger.ts`
|
|
708
|
-
- [ ] Integrate into `src/tools/index.ts`
|
|
709
|
-
- [ ] Update `SessionStore` to use enhanced logger
|
|
710
|
-
- [ ] Extend configuration defaults
|
|
711
|
-
- [ ] Write unit tests (25 tests)
|
|
712
|
-
- [ ] Update documentation
|
|
713
|
-
|
|
714
|
-
---
|
|
715
|
-
|
|
716
|
-
**Architecture Sign-off**: Ready for Atomize phase
|
|
717
|
-
|
|
718
|
-
**Created**: 2025-10-03
|
|
719
|
-
**Author**: ClaudeCode
|
|
720
|
-
**Status**: Complete
|