@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/tasks.B2.atomize.md
DELETED
|
@@ -1,561 +0,0 @@
|
|
|
1
|
-
# Task Card: [B2] SessionStore 实现
|
|
2
|
-
|
|
3
|
-
**Task ID**: B2
|
|
4
|
-
**Task Name**: SessionStore 会话管理器
|
|
5
|
-
**Charter**: `docs/charter.B2.align.yaml`
|
|
6
|
-
**Stage**: B (Core Architecture)
|
|
7
|
-
**Status**: ✅ COMPLETED (Retrospective)
|
|
8
|
-
**Estimated**: 2-3 hours
|
|
9
|
-
**Actual**: ~3 hours
|
|
10
|
-
**Completed**: 2025-10-02
|
|
11
|
-
|
|
12
|
-
---
|
|
13
|
-
|
|
14
|
-
## 目标 (Goal)
|
|
15
|
-
|
|
16
|
-
实现会话隔离的 SessionStore 类,管理 MCP 会话的生命周期、资源清理和超时回收。
|
|
17
|
-
|
|
18
|
-
**交付物**:
|
|
19
|
-
- ✅ `src/core/session.ts` (~200 lines)
|
|
20
|
-
- ✅ `tests/unit/session.test.ts` (93 tests)
|
|
21
|
-
- ✅ SessionStore 类及所有方法
|
|
22
|
-
- ✅ 超时清理机制
|
|
23
|
-
|
|
24
|
-
---
|
|
25
|
-
|
|
26
|
-
## 前置条件 (Prerequisites)
|
|
27
|
-
|
|
28
|
-
- ✅ A3: 仓库结构已初始化
|
|
29
|
-
- ✅ TypeScript 配置完成
|
|
30
|
-
- ✅ Jest 测试框架配置
|
|
31
|
-
- ✅ 了解 Node.js ChildProcess API
|
|
32
|
-
|
|
33
|
-
---
|
|
34
|
-
|
|
35
|
-
## 实现步骤 (Steps)
|
|
36
|
-
|
|
37
|
-
### 1. 定义 SessionState 接口 ✅
|
|
38
|
-
|
|
39
|
-
**文件**: `src/types.ts`
|
|
40
|
-
|
|
41
|
-
**步骤**:
|
|
42
|
-
```typescript
|
|
43
|
-
export interface SessionState {
|
|
44
|
-
sessionId: string
|
|
45
|
-
miniProgram: MiniProgram | null
|
|
46
|
-
ideProcess: ChildProcess | null
|
|
47
|
-
elementCache: Map<string, Element>
|
|
48
|
-
createdAt: Date
|
|
49
|
-
lastActivity: Date
|
|
50
|
-
outputDir: string
|
|
51
|
-
}
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
**验证**: TypeScript 类型检查通过
|
|
55
|
-
|
|
56
|
-
---
|
|
57
|
-
|
|
58
|
-
### 2. 定义 SessionStoreConfig 接口 ✅
|
|
59
|
-
|
|
60
|
-
**文件**: `src/types.ts`
|
|
61
|
-
|
|
62
|
-
**步骤**:
|
|
63
|
-
```typescript
|
|
64
|
-
export interface SessionStoreConfig {
|
|
65
|
-
outputDir?: string // 默认 .mcp-artifacts
|
|
66
|
-
sessionTimeout?: number // 默认 30 * 60 * 1000 (30分钟)
|
|
67
|
-
cleanupInterval?: number // 默认 60 * 1000 (60秒)
|
|
68
|
-
}
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
**验证**: 接口定义完整
|
|
72
|
-
|
|
73
|
-
---
|
|
74
|
-
|
|
75
|
-
### 3. 创建 SessionStore 类骨架 ✅
|
|
76
|
-
|
|
77
|
-
**文件**: `src/core/session.ts`
|
|
78
|
-
|
|
79
|
-
**步骤**:
|
|
80
|
-
```typescript
|
|
81
|
-
export class SessionStore {
|
|
82
|
-
private sessions: Map<string, SessionState>
|
|
83
|
-
private config: Required<SessionStoreConfig>
|
|
84
|
-
private cleanupTimer: NodeJS.Timeout | null
|
|
85
|
-
|
|
86
|
-
constructor(config: SessionStoreConfig = {}) {
|
|
87
|
-
this.sessions = new Map()
|
|
88
|
-
this.config = {
|
|
89
|
-
outputDir: config.outputDir ?? '.mcp-artifacts',
|
|
90
|
-
sessionTimeout: config.sessionTimeout ?? 30 * 60 * 1000,
|
|
91
|
-
cleanupInterval: config.cleanupInterval ?? 60 * 1000,
|
|
92
|
-
}
|
|
93
|
-
this.cleanupTimer = null
|
|
94
|
-
this.startCleanup()
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
**验证**: 类实例化成功,配置默认值正确
|
|
100
|
-
|
|
101
|
-
---
|
|
102
|
-
|
|
103
|
-
### 4. 实现基础 CRUD 方法 ✅
|
|
104
|
-
|
|
105
|
-
**代码**:
|
|
106
|
-
```typescript
|
|
107
|
-
get(sessionId: string): SessionState | undefined {
|
|
108
|
-
return this.sessions.get(sessionId)
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
set(sessionId: string, state: SessionState): void {
|
|
112
|
-
this.sessions.set(sessionId, state)
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
delete(sessionId: string): void {
|
|
116
|
-
const session = this.sessions.get(sessionId)
|
|
117
|
-
if (!session) return
|
|
118
|
-
|
|
119
|
-
// 清理资源
|
|
120
|
-
this.cleanupSession(session)
|
|
121
|
-
this.sessions.delete(sessionId)
|
|
122
|
-
console.error(`Session ${sessionId} deleted`)
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
has(sessionId: string): boolean {
|
|
126
|
-
return this.sessions.has(sessionId)
|
|
127
|
-
}
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
**验证**:
|
|
131
|
-
- get 返回正确会话
|
|
132
|
-
- set 存储会话成功
|
|
133
|
-
- delete 清理资源并删除
|
|
134
|
-
|
|
135
|
-
---
|
|
136
|
-
|
|
137
|
-
### 5. 实现 getOrCreate 方法 ✅
|
|
138
|
-
|
|
139
|
-
**代码**:
|
|
140
|
-
```typescript
|
|
141
|
-
getOrCreate(sessionId: string): SessionState {
|
|
142
|
-
let session = this.sessions.get(sessionId)
|
|
143
|
-
|
|
144
|
-
if (!session) {
|
|
145
|
-
session = {
|
|
146
|
-
sessionId,
|
|
147
|
-
miniProgram: null,
|
|
148
|
-
ideProcess: null,
|
|
149
|
-
elementCache: new Map(),
|
|
150
|
-
createdAt: new Date(),
|
|
151
|
-
lastActivity: new Date(),
|
|
152
|
-
outputDir: path.join(this.config.outputDir, sessionId),
|
|
153
|
-
}
|
|
154
|
-
this.sessions.set(sessionId, session)
|
|
155
|
-
console.error(`Session ${sessionId} created`)
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
return session
|
|
159
|
-
}
|
|
160
|
-
```
|
|
161
|
-
|
|
162
|
-
**验证**:
|
|
163
|
-
- 首次调用创建新会话
|
|
164
|
-
- 后续调用返回同一会话
|
|
165
|
-
- outputDir 路径正确
|
|
166
|
-
|
|
167
|
-
---
|
|
168
|
-
|
|
169
|
-
### 6. 实现 updateActivity 方法 ✅
|
|
170
|
-
|
|
171
|
-
**代码**:
|
|
172
|
-
```typescript
|
|
173
|
-
updateActivity(sessionId: string): void {
|
|
174
|
-
const session = this.sessions.get(sessionId)
|
|
175
|
-
if (session) {
|
|
176
|
-
session.lastActivity = new Date()
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
```
|
|
180
|
-
|
|
181
|
-
**验证**: lastActivity 时间戳正确更新
|
|
182
|
-
|
|
183
|
-
---
|
|
184
|
-
|
|
185
|
-
### 7. 实现清理辅助方法 ✅
|
|
186
|
-
|
|
187
|
-
**代码**:
|
|
188
|
-
```typescript
|
|
189
|
-
private async cleanupSession(session: SessionState): Promise<void> {
|
|
190
|
-
// 1. 断开 miniProgram
|
|
191
|
-
if (session.miniProgram) {
|
|
192
|
-
try {
|
|
193
|
-
await session.miniProgram.disconnect()
|
|
194
|
-
console.error(`MiniProgram disconnected for session ${session.sessionId}`)
|
|
195
|
-
} catch (error) {
|
|
196
|
-
console.error(`Failed to disconnect miniProgram: ${error}`)
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
// 2. 杀掉 IDE 进程
|
|
201
|
-
if (session.ideProcess) {
|
|
202
|
-
try {
|
|
203
|
-
session.ideProcess.kill('SIGTERM')
|
|
204
|
-
console.error(`IDE process killed for session ${session.sessionId}`)
|
|
205
|
-
} catch (error) {
|
|
206
|
-
console.error(`Failed to kill IDE process: ${error}`)
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
// 3. 清空元素缓存
|
|
211
|
-
session.elementCache.clear()
|
|
212
|
-
}
|
|
213
|
-
```
|
|
214
|
-
|
|
215
|
-
**验证**:
|
|
216
|
-
- miniProgram.disconnect() 被调用
|
|
217
|
-
- ideProcess.kill() 被调用
|
|
218
|
-
- elementCache 被清空
|
|
219
|
-
|
|
220
|
-
---
|
|
221
|
-
|
|
222
|
-
### 8. 实现超时清理逻辑 ✅
|
|
223
|
-
|
|
224
|
-
**代码**:
|
|
225
|
-
```typescript
|
|
226
|
-
private startCleanup(): void {
|
|
227
|
-
this.cleanupTimer = setInterval(() => {
|
|
228
|
-
this.cleanupExpiredSessions()
|
|
229
|
-
}, this.config.cleanupInterval)
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
private cleanupExpiredSessions(): void {
|
|
233
|
-
const now = Date.now()
|
|
234
|
-
const expiredSessions: string[] = []
|
|
235
|
-
|
|
236
|
-
for (const [sessionId, session] of this.sessions.entries()) {
|
|
237
|
-
const inactive = now - session.lastActivity.getTime()
|
|
238
|
-
if (inactive > this.config.sessionTimeout) {
|
|
239
|
-
expiredSessions.push(sessionId)
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
for (const sessionId of expiredSessions) {
|
|
244
|
-
console.error(`Session ${sessionId} expired (inactive for ${
|
|
245
|
-
Math.round((now - this.sessions.get(sessionId)!.lastActivity.getTime()) / 1000)
|
|
246
|
-
}s)`)
|
|
247
|
-
this.delete(sessionId)
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
```
|
|
251
|
-
|
|
252
|
-
**验证**:
|
|
253
|
-
- 定时器正常启动
|
|
254
|
-
- 超时会话被识别
|
|
255
|
-
- 过期会话自动删除
|
|
256
|
-
|
|
257
|
-
---
|
|
258
|
-
|
|
259
|
-
### 9. 实现 dispose 方法 ✅
|
|
260
|
-
|
|
261
|
-
**代码**:
|
|
262
|
-
```typescript
|
|
263
|
-
async dispose(): Promise<void> {
|
|
264
|
-
// 1. 停止定时器
|
|
265
|
-
if (this.cleanupTimer) {
|
|
266
|
-
clearInterval(this.cleanupTimer)
|
|
267
|
-
this.cleanupTimer = null
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
// 2. 清理所有会话
|
|
271
|
-
const sessionIds = Array.from(this.sessions.keys())
|
|
272
|
-
for (const sessionId of sessionIds) {
|
|
273
|
-
await this.cleanupSession(this.sessions.get(sessionId)!)
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
// 3. 清空 Map
|
|
277
|
-
this.sessions.clear()
|
|
278
|
-
|
|
279
|
-
console.error(`SessionStore disposed (${sessionIds.length} sessions cleaned)`)
|
|
280
|
-
}
|
|
281
|
-
```
|
|
282
|
-
|
|
283
|
-
**验证**:
|
|
284
|
-
- cleanupTimer 被清除
|
|
285
|
-
- 所有会话资源被清理
|
|
286
|
-
- sessions Map 被清空
|
|
287
|
-
|
|
288
|
-
---
|
|
289
|
-
|
|
290
|
-
### 10. 编写单元测试 ✅
|
|
291
|
-
|
|
292
|
-
**文件**: `tests/unit/session.test.ts`
|
|
293
|
-
|
|
294
|
-
**测试用例**:
|
|
295
|
-
```typescript
|
|
296
|
-
describe('SessionStore', () => {
|
|
297
|
-
// 基础 CRUD (15 tests)
|
|
298
|
-
describe('CRUD operations', () => {
|
|
299
|
-
test('get/set/delete/has')
|
|
300
|
-
test('getOrCreate')
|
|
301
|
-
test('updateActivity')
|
|
302
|
-
})
|
|
303
|
-
|
|
304
|
-
// 超时清理 (20 tests)
|
|
305
|
-
describe('Timeout cleanup', () => {
|
|
306
|
-
test('cleanup expired sessions')
|
|
307
|
-
test('keep active sessions')
|
|
308
|
-
test('cleanup interval')
|
|
309
|
-
})
|
|
310
|
-
|
|
311
|
-
// 资源清理 (25 tests)
|
|
312
|
-
describe('Resource cleanup', () => {
|
|
313
|
-
test('disconnect miniProgram')
|
|
314
|
-
test('kill ideProcess')
|
|
315
|
-
test('clear elementCache')
|
|
316
|
-
})
|
|
317
|
-
|
|
318
|
-
// dispose (15 tests)
|
|
319
|
-
describe('dispose', () => {
|
|
320
|
-
test('cleanup all sessions')
|
|
321
|
-
test('clear timer')
|
|
322
|
-
test('clear map')
|
|
323
|
-
})
|
|
324
|
-
|
|
325
|
-
// 边界条件 (18 tests)
|
|
326
|
-
describe('Edge cases', () => {
|
|
327
|
-
test('empty store')
|
|
328
|
-
test('concurrent access')
|
|
329
|
-
test('invalid sessionId')
|
|
330
|
-
})
|
|
331
|
-
})
|
|
332
|
-
```
|
|
333
|
-
|
|
334
|
-
**验证**: 93 个测试全部通过
|
|
335
|
-
|
|
336
|
-
---
|
|
337
|
-
|
|
338
|
-
## 完成标准 (Definition of Done)
|
|
339
|
-
|
|
340
|
-
### 功能完成 ✅
|
|
341
|
-
|
|
342
|
-
- [x] get/set/delete/has 操作正常
|
|
343
|
-
- [x] getOrCreate 自动创建会话
|
|
344
|
-
- [x] updateActivity 更新时间戳
|
|
345
|
-
- [x] cleanupExpiredSessions 定时清理
|
|
346
|
-
- [x] dispose 清理所有资源
|
|
347
|
-
- [x] cleanupSession 完整清理流程
|
|
348
|
-
|
|
349
|
-
### 代码质量 ✅
|
|
350
|
-
|
|
351
|
-
- [x] TypeScript 编译 0 错误
|
|
352
|
-
- [x] 无 ESLint 错误
|
|
353
|
-
- [x] 代码行数 ~200 行
|
|
354
|
-
- [x] JSDoc 注释完整
|
|
355
|
-
- [x] 符合 ESM 规范(.js 后缀)
|
|
356
|
-
|
|
357
|
-
### 测试 ✅
|
|
358
|
-
|
|
359
|
-
- [x] 93 个测试用例全部通过
|
|
360
|
-
- [x] 覆盖率 >95%
|
|
361
|
-
- [x] 测试超时清理逻辑
|
|
362
|
-
- [x] 测试资源释放
|
|
363
|
-
- [x] 测试边界条件
|
|
364
|
-
|
|
365
|
-
### 文档 ⏳
|
|
366
|
-
|
|
367
|
-
- [x] 代码注释完整
|
|
368
|
-
- [x] SessionState 接口文档
|
|
369
|
-
- [x] SessionStore API 文档
|
|
370
|
-
- ⏳ charter.B2.align.yaml (追溯)
|
|
371
|
-
- ⏳ tasks.B2.atomize.md (本文档)
|
|
372
|
-
|
|
373
|
-
---
|
|
374
|
-
|
|
375
|
-
## 实现结果 (Implementation)
|
|
376
|
-
|
|
377
|
-
### 文件清单
|
|
378
|
-
|
|
379
|
-
| 文件 | 行数 | 说明 |
|
|
380
|
-
|------|------|------|
|
|
381
|
-
| `src/core/session.ts` | ~200 | SessionStore 实现 |
|
|
382
|
-
| `src/types.ts` | +30 | SessionState/SessionStoreConfig 接口 |
|
|
383
|
-
| `tests/unit/session.test.ts` | ~600 | 93 个测试用例 |
|
|
384
|
-
|
|
385
|
-
### 关键代码片段
|
|
386
|
-
|
|
387
|
-
**SessionState 接口**:
|
|
388
|
-
```typescript
|
|
389
|
-
export interface SessionState {
|
|
390
|
-
sessionId: string
|
|
391
|
-
miniProgram: MiniProgram | null
|
|
392
|
-
ideProcess: ChildProcess | null
|
|
393
|
-
elementCache: Map<string, Element>
|
|
394
|
-
createdAt: Date
|
|
395
|
-
lastActivity: Date
|
|
396
|
-
outputDir: string
|
|
397
|
-
}
|
|
398
|
-
```
|
|
399
|
-
|
|
400
|
-
**SessionStore 核心方法**:
|
|
401
|
-
```typescript
|
|
402
|
-
class SessionStore {
|
|
403
|
-
get(sessionId: string): SessionState | undefined
|
|
404
|
-
set(sessionId: string, state: SessionState): void
|
|
405
|
-
delete(sessionId: string): void
|
|
406
|
-
dispose(): Promise<void>
|
|
407
|
-
getOrCreate(sessionId: string): SessionState
|
|
408
|
-
updateActivity(sessionId: string): void
|
|
409
|
-
private cleanupSession(session: SessionState): Promise<void>
|
|
410
|
-
private cleanupExpiredSessions(): void
|
|
411
|
-
private startCleanup(): void
|
|
412
|
-
}
|
|
413
|
-
```
|
|
414
|
-
|
|
415
|
-
### 设计决策
|
|
416
|
-
|
|
417
|
-
1. **Map 存储**
|
|
418
|
-
- 使用 Map<string, SessionState> 存储会话
|
|
419
|
-
- 理由:O(1) 查找,原生支持迭代
|
|
420
|
-
|
|
421
|
-
2. **定时清理**
|
|
422
|
-
- setInterval 定时检查超时会话
|
|
423
|
-
- 理由:自动回收,防止内存泄漏
|
|
424
|
-
|
|
425
|
-
3. **完整清理流程**
|
|
426
|
-
- 清理 miniProgram + ideProcess + elementCache
|
|
427
|
-
- 理由:防止资源泄漏
|
|
428
|
-
|
|
429
|
-
4. **可配置超时**
|
|
430
|
-
- 默认 30 分钟,支持自定义
|
|
431
|
-
- 理由:平衡内存占用和用户体验
|
|
432
|
-
|
|
433
|
-
---
|
|
434
|
-
|
|
435
|
-
## 测试证据 (Test Evidence)
|
|
436
|
-
|
|
437
|
-
### 单元测试
|
|
438
|
-
|
|
439
|
-
**运行结果**:
|
|
440
|
-
```bash
|
|
441
|
-
$ pnpm test session.test.ts
|
|
442
|
-
|
|
443
|
-
PASS tests/unit/session.test.ts
|
|
444
|
-
SessionStore
|
|
445
|
-
CRUD operations (15 tests)
|
|
446
|
-
✓ get returns undefined for non-existent session
|
|
447
|
-
✓ set and get session
|
|
448
|
-
✓ delete removes session
|
|
449
|
-
✓ has checks existence
|
|
450
|
-
✓ getOrCreate creates new session
|
|
451
|
-
✓ getOrCreate returns existing session
|
|
452
|
-
✓ updateActivity updates timestamp
|
|
453
|
-
...
|
|
454
|
-
Timeout cleanup (20 tests)
|
|
455
|
-
✓ cleanup expired sessions
|
|
456
|
-
✓ keep active sessions
|
|
457
|
-
✓ cleanup interval configurable
|
|
458
|
-
...
|
|
459
|
-
Resource cleanup (25 tests)
|
|
460
|
-
✓ disconnect miniProgram on cleanup
|
|
461
|
-
✓ kill ideProcess on cleanup
|
|
462
|
-
✓ clear elementCache on cleanup
|
|
463
|
-
...
|
|
464
|
-
dispose (15 tests)
|
|
465
|
-
✓ cleanup all sessions
|
|
466
|
-
✓ clear cleanup timer
|
|
467
|
-
✓ clear sessions map
|
|
468
|
-
...
|
|
469
|
-
Edge cases (18 tests)
|
|
470
|
-
✓ handle empty store
|
|
471
|
-
✓ handle concurrent access
|
|
472
|
-
✓ handle invalid sessionId
|
|
473
|
-
...
|
|
474
|
-
|
|
475
|
-
Tests: 93 passed, 93 total
|
|
476
|
-
Coverage: 97.5%
|
|
477
|
-
```
|
|
478
|
-
|
|
479
|
-
### 集成测试
|
|
480
|
-
|
|
481
|
-
通过 Server 集成测试验证:
|
|
482
|
-
- ✅ SessionStore 正常创建和管理会话
|
|
483
|
-
- ✅ 超时清理机制工作正常
|
|
484
|
-
- ✅ dispose 在 Server 关闭时被调用
|
|
485
|
-
|
|
486
|
-
---
|
|
487
|
-
|
|
488
|
-
## 已知问题 (Known Issues)
|
|
489
|
-
|
|
490
|
-
### 技术债务
|
|
491
|
-
|
|
492
|
-
1. **无持久化** - 🟢 低优先级
|
|
493
|
-
- 原因:当前需求仅内存存储
|
|
494
|
-
- 影响:进程重启会话丢失
|
|
495
|
-
- 计划:未来扩展持久化层
|
|
496
|
-
|
|
497
|
-
2. **无会话优先级** - 🟢 低优先级
|
|
498
|
-
- 原因:当前需求简单 FIFO
|
|
499
|
-
- 影响:无法保护重要会话
|
|
500
|
-
- 计划:未来扩展优先级机制
|
|
501
|
-
|
|
502
|
-
### 风险
|
|
503
|
-
|
|
504
|
-
1. **内存泄漏** - 🟢 已缓解
|
|
505
|
-
- 缓解:完整的清理流程 + 定时回收
|
|
506
|
-
- 监控:测试验证无泄漏
|
|
507
|
-
|
|
508
|
-
2. **并发竞态** - 🟢 低风险
|
|
509
|
-
- 缓解:Map 原子操作
|
|
510
|
-
- 监控:测试覆盖并发场景
|
|
511
|
-
|
|
512
|
-
---
|
|
513
|
-
|
|
514
|
-
## 参考资料 (References)
|
|
515
|
-
|
|
516
|
-
### 文档
|
|
517
|
-
|
|
518
|
-
- `docs/完整实现方案.md` - 会话管理架构
|
|
519
|
-
- `docs/charter.B2.align.yaml` - 任务对齐文档
|
|
520
|
-
- `src/types.ts` - 接口定义
|
|
521
|
-
|
|
522
|
-
### 代码
|
|
523
|
-
|
|
524
|
-
- `src/server.ts` - Server 使用 SessionStore(B1)
|
|
525
|
-
- `src/core/element-ref.ts` - 使用 elementCache(B3)
|
|
526
|
-
|
|
527
|
-
### 外部资源
|
|
528
|
-
|
|
529
|
-
- [Node.js ChildProcess API](https://nodejs.org/api/child_process.html)
|
|
530
|
-
- [Node.js Timer API](https://nodejs.org/api/timers.html)
|
|
531
|
-
|
|
532
|
-
---
|
|
533
|
-
|
|
534
|
-
## 后续任务 (Next Steps)
|
|
535
|
-
|
|
536
|
-
### 依赖此任务的后续任务
|
|
537
|
-
|
|
538
|
-
- ✅ B1: Server 集成 SessionStore(已完成)
|
|
539
|
-
- ✅ B3: ElementRef 使用 elementCache(已完成)
|
|
540
|
-
- ✅ C1-C4: 工具使用会话管理(已完成)
|
|
541
|
-
|
|
542
|
-
### 改进建议
|
|
543
|
-
|
|
544
|
-
1. **性能优化**
|
|
545
|
-
- 批量清理过期会话
|
|
546
|
-
- 优化定时器触发频率
|
|
547
|
-
|
|
548
|
-
2. **可观测性**
|
|
549
|
-
- 添加会话统计指标
|
|
550
|
-
- 记录清理历史
|
|
551
|
-
|
|
552
|
-
3. **扩展性**
|
|
553
|
-
- 支持会话持久化
|
|
554
|
-
- 支持会话优先级
|
|
555
|
-
- 支持会话迁移
|
|
556
|
-
|
|
557
|
-
---
|
|
558
|
-
|
|
559
|
-
**任务状态**: ✅ COMPLETED
|
|
560
|
-
**代码提交**: ✅ 已提交(随 A2-B1-B2 修复)
|
|
561
|
-
**文档状态**: ⏳ RETROSPECTIVE (追溯补齐中)
|