@wirecat/cli-core 3.1.0-dev → 3.2.0-dev
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/CHANGELOG.md +102 -0
- package/dist/background/daily-archive-timer.d.ts +1 -1
- package/dist/bundle/{agent-RMLBQXJF-CuqJBQqf.js → agent-J75WGZEV-K_l-bQ-h.js} +5 -5
- package/dist/bundle/{all-profiles-3GEKS7PR-Bi_zb5_-.js → all-profiles-3GEKS7PR-BohqgNvP.js} +6 -6
- package/dist/bundle/{anthropic-EVM6I7MZ-BWI01JgC.js → anthropic-EVM6I7MZ-CqB3j7dB.js} +2 -2
- package/dist/bundle/{app-server-76XGUZHU-__6SrMhc.js → app-server-5BL62GAL-Osw_tMej.js} +20 -15
- package/dist/bundle/{bun-AWMVU72K-COHrAYHA.js → bun-AWMVU72K-Bk0oN5Sm.js} +2 -2
- package/dist/bundle/{bun-sqlite-CYFVVXXR-r_kJOwku.js → bun-sqlite-CYFVVXXR-4iGlaI9X.js} +3 -3
- package/dist/bundle/{chunk-4ZM6SE7G-DNDxhi8l.js → chunk-4HGRFFTO-fNvELOjI.js} +330 -56
- package/dist/bundle/{chunk-6G6TIMKP-CoVYG_I3.js → chunk-6G6TIMKP-Byea1UGV.js} +4 -4
- package/dist/bundle/{chunk-M5CHOMME-BIcASmVb.js → chunk-6OLVBOBX-Ch2rblZk.js} +17 -11
- package/dist/bundle/{chunk-CCFBHR4O-DAuKd8rI.js → chunk-CCFBHR4O-Bhxq5eaI.js} +1 -1
- package/dist/bundle/{chunk-DDXCCEI4-CHLrblc1.js → chunk-DDXCCEI4-CBg_l4Ro.js} +2 -2
- package/dist/bundle/{chunk-DZPIGAKP-nrRAPNTz.js → chunk-DZPIGAKP-BZy6DShN.js} +1 -1
- package/dist/bundle/{chunk-ERNCGLKE-4JdU74o6.js → chunk-ERNCGLKE-D3HStkJC.js} +1 -1
- package/dist/bundle/{chunk-GBNNGOIB-DVUFOYzA.js → chunk-GBNNGOIB-DS3rusdH.js} +5 -5
- package/dist/bundle/{chunk-GJTANPFI-5L6Owk-H.js → chunk-GJTANPFI-DlUMnFUQ.js} +3 -3
- package/dist/bundle/{chunk-6ZUQA7OL-ofpF0AvH.js → chunk-GRGGW52W-Fkw6omOx.js} +5 -5
- package/dist/bundle/{chunk-KSUALCA7-DB6cYuSU.js → chunk-KSUALCA7-SMNQ85c6.js} +1 -1
- package/dist/bundle/{chunk-LBVI4Z2X-COUoJmWU.js → chunk-LBVI4Z2X-D9_8iC1S.js} +1 -1
- package/dist/bundle/{chunk-M23BPYSL-ChiHsEsy.js → chunk-M23BPYSL-ByTcRixP.js} +3 -3
- package/dist/bundle/{chunk-Z3ZVBBWR-whNBW-iH.js → chunk-M4KMNZN6-CBeUwDlF.js} +2 -2
- package/dist/bundle/{chunk-NG7F5L7N-BKCEXGxy.js → chunk-NG7F5L7N-Ch_ERSNz.js} +1 -1
- package/dist/bundle/{chunk-NX2VS2ER-DS6Urg3e.js → chunk-NX2VS2ER-CWN0zXqZ.js} +1 -1
- package/dist/bundle/{chunk-O2HOOK7X-Dboq6vxP.js → chunk-O2HOOK7X-Dyw_Dcql.js} +4 -4
- package/dist/bundle/{chunk-PSD6373C-wlicX185.js → chunk-PSD6373C-DgL0rhKe.js} +1 -1
- package/dist/bundle/{chunk-RTCT4N7Y-Dn-lP1zF.js → chunk-RTCT4N7Y-BEZ3cJ5d.js} +1 -1
- package/dist/bundle/{chunk-S34BE7ZC-p6NeYmqQ.js → chunk-S34BE7ZC-BO0yaVoX.js} +1 -1
- package/dist/bundle/{chunk-E6KETVFF-wOOXf4op.js → chunk-SRAGL5LI-CKhhwRrx.js} +5 -5
- package/dist/bundle/{chunk-T6V6LFHT-Dwv7XUuC.js → chunk-T6V6LFHT-BazTZ25Y.js} +1 -1
- package/dist/bundle/{chunk-ACWFPMZF-DkR70AOW.js → chunk-TFRAD7RO-BVAK9frq.js} +50 -4
- package/dist/bundle/{chunk-UH2H3OLE-R_6H5D7o.js → chunk-UH2H3OLE-QNxQo07O.js} +1 -1
- package/dist/bundle/{chunk-UQJGYQ56-CANeLx5l.js → chunk-UQJGYQ56-PoYTv6WX.js} +1 -1
- package/dist/bundle/{chunk-VKZDPPVI-d7RS_QOW.js → chunk-VKZDPPVI-BOmnhxVJ.js} +2 -2
- package/dist/bundle/{chunk-UNGNJ255-CtLEiDap.js → chunk-W3AAOYWE-Cyx1kZsd.js} +7 -7
- package/dist/bundle/{chunk-WXEJSLMO-DbSxVCq9.js → chunk-WXEJSLMO-DCjDRcYe.js} +8 -8
- package/dist/bundle/{chunk-XW3IHFDH-CjmXc8aI.js → chunk-XW3IHFDH-CA9Bby7o.js} +1 -1
- package/dist/bundle/{chunk-YHBBPJW6-jAof9asy.js → chunk-YHBBPJW6-DKIU2gC4.js} +2 -2
- package/dist/bundle/{chunk-YITG2CE5-Bg4SA8X1.js → chunk-YITG2CE5-o18mzaka.js} +1 -1
- package/dist/bundle/{chunk-ZMRSCVFX-Dwxb-Yg1.js → chunk-ZMRSCVFX-uhwzmZUP.js} +1 -1
- package/dist/bundle/chunks.json +83 -83
- package/dist/bundle/{command-contract-4X4JDKH7-BsU8tW9N.js → command-contract-DHFUF6RM-Bnc6nJSk.js} +2 -2
- package/dist/bundle/{command-server-entry-3JEJBUK5-CF-VyCRd.js → command-server-entry-UQSMAHYK-DzjTaTCZ.js} +2 -2
- package/dist/bundle/{decode-KVUA3TLF-Ds0C1R9U.js → decode-KVUA3TLF-BoJfgCpS.js} +2 -2
- package/dist/bundle/{dist-TPSNLFVO-D1tJd0aB.js → dist-TPSNLFVO-55jBf4N-.js} +2 -2
- package/dist/bundle/documents.js +5 -5
- package/dist/bundle/{echarts-6Q4CQ2DC-BvZMDYNl.js → echarts-6Q4CQ2DC-w9WhKUJu.js} +1 -1
- package/dist/bundle/{embed-JGGK2WKR-h5ppwooq.js → embed-JGGK2WKR-Cl3meWl4.js} +2 -2
- package/dist/bundle/{embedder-5SIVKVWO-D4yt4YCy.js → embedder-5SIVKVWO-DJEa9hBn.js} +2 -2
- package/dist/bundle/{first-run-FFHXPGFC-CyHZ4KM3.js → first-run-BT3X33BP-JikrW5_w.js} +2 -2
- package/dist/bundle/{first-screen-2NGQNWIN-BkvwnUdE.js → first-screen-KGQQK446-D2MchUuo.js} +2 -2
- package/dist/bundle/{hast-util-from-html-WLAUHN53-BfAYjYKc.js → hast-util-from-html-WLAUHN53-BOWgHBLv.js} +4 -4
- package/dist/bundle/{hast-util-to-html-PJC36XDP-C8DGIyzU.js → hast-util-to-html-PJC36XDP-QwbM5c4F.js} +5 -5
- package/dist/bundle/{hast-util-to-mdast-ZQ5OFYUM-9p6MJEBi.js → hast-util-to-mdast-ZQ5OFYUM-BidjUANu.js} +6 -6
- package/dist/bundle/{index-BOgkxLir.js → index-CTvUjqLX.js} +331 -345
- package/dist/bundle/index.js +66 -66
- package/dist/bundle/install-IPXFNLYZ-BGKW94IA.js +5 -0
- package/dist/bundle/{instructions-NHSD6EUE-BfefgySD.js → instructions-34FSWDC6-BR7mbjJH.js} +2 -2
- package/dist/bundle/mail.js +3 -3
- package/dist/bundle/{mcp-server-5FM4GA2C-CNWjKPAi.js → mcp-server-5FM4GA2C-B4Sqou0Z.js} +2 -2
- package/dist/bundle/mcp.js +12 -12
- package/dist/bundle/{mdast-util-from-markdown-Y7N3XA5A-ZkhTz5VO.js → mdast-util-from-markdown-Y7N3XA5A-CBCtetYX.js} +8 -8
- package/dist/bundle/{mdast-util-gfm-52PMOHWQ-gfhFQVZ5.js → mdast-util-gfm-52PMOHWQ-Bv-Hkixb.js} +12 -12
- package/dist/bundle/{mdast-util-to-hast-4MTEM3TB-Bomsq1EU.js → mdast-util-to-hast-4MTEM3TB-40gSN0gV.js} +6 -6
- package/dist/bundle/mdast-util-to-markdown-UGCOLDXA-DnYraMQX.js +12 -0
- package/dist/bundle/{meeting-combined-G3OVTNM6-CFHWFlT-.js → meeting-combined-G3OVTNM6-C4Jdctiy.js} +2 -2
- package/dist/bundle/{meeting-model-RINL42I5-Bab4crMQ.js → meeting-model-RINL42I5-BLAAT6mv.js} +2 -2
- package/dist/bundle/meeting-semantic-I7AZQTEI-DQ19wjn5.js +5 -0
- package/dist/bundle/{micromark-extension-gfm-FRHRNOIW-81l4O6kr.js → micromark-extension-gfm-FRHRNOIW-BvJCT_wq.js} +6 -6
- package/dist/bundle/{node-ZIYT5JOL-WfCpdwZ2.js → node-ZIYT5JOL-DoWqiI0I.js} +2 -2
- package/dist/bundle/{node-sqlite-VFGFD4MA-CrKdzJgw.js → node-sqlite-VFGFD4MA-QH9swjUN.js} +3 -3
- package/dist/bundle/notes-search-2Q3C65PA-D2HqYyaY.js +5 -0
- package/dist/bundle/oauth-TVUNW3GM-uN6u_RWy.js +7 -0
- package/dist/bundle/{open-36SZHLGF-kGan0BjP.js → open-36SZHLGF-CPBs6fdy.js} +1 -1
- package/dist/bundle/{openai-Z2WIZ6AC-D-aH-As-.js → openai-Z2WIZ6AC-CcEngcFj.js} +2 -2
- package/dist/bundle/preload.js +1 -1
- package/dist/bundle/{process-KJQOPRSP-C6W_P1_I.js → process-KJQOPRSP-BNqvUqBZ.js} +2 -2
- package/dist/bundle/{prompt-S2W33X57-BEDbCA8B.js → prompt-S2W33X57-BiF1939t.js} +2 -2
- package/dist/bundle/{recognize-NBWDLXLD-B2LTlDUy.js → recognize-NBWDLXLD-BCqQ8iG1.js} +2 -2
- package/dist/bundle/{remote-O54ANXYL-DOEubnhV.js → remote-O54ANXYL-BixLG9XM.js} +2 -2
- package/dist/bundle/{rerank-HTCSXPM6-CVIU4cUa.js → rerank-HTCSXPM6-FGYUs2VW.js} +2 -2
- package/dist/bundle/serve-7KRXCBBZ-EVSG16Mc.js +8 -0
- package/dist/bundle/server-BFD6QUV7-OmgCCeuX.js +11 -0
- package/dist/bundle/server-G7VWUBA2-C3Gq_HlM.js +12 -0
- package/dist/bundle/{sqlite-runtime-KC3NKKRB-DYslMC-g.js → sqlite-runtime-KC3NKKRB-y_O8PNsQ.js} +1 -1
- package/dist/bundle/{start-Dtq56YXe.js → start-CqQGB7xI.js} +5 -5
- package/dist/bundle/start.js +1 -1
- package/dist/bundle/state-3CFS2SAC-CYYQ103I.js +5 -0
- package/dist/bundle/store-BSVRVKTV-Uot4OGm0.js +5 -0
- package/dist/bundle/{store-6CM2A3HP-CtnMVUVK.js → store-LGAEGNFF-BzNIKnoK.js} +2 -2
- package/dist/bundle/{store-maintenance-command-WYO5PN4V-B0wefBHZ.js → store-maintenance-command-Z27R7URJ-CoJCYGVq.js} +2 -2
- package/dist/bundle/surface-ZEEHYD5Q-DRIV3XG3.js +8 -0
- package/dist/bundle/testing.js +8 -8
- package/dist/cli/app-doctor-command.d.ts +187 -1
- package/dist/cli/app-doctor-command.d.ts.map +1 -1
- package/dist/cli/app-doctor-command.js +3 -2
- package/dist/cli/app-doctor-command.js.map +1 -1
- package/dist/cli/app-mcp-command.d.ts +187 -2
- package/dist/cli/app-mcp-command.d.ts.map +1 -1
- package/dist/cli/app-mcp-command.js +3 -2
- package/dist/cli/app-mcp-command.js.map +1 -1
- package/dist/cli/built-commands.d.ts +10 -0
- package/dist/cli/built-commands.d.ts.map +1 -0
- package/dist/cli/built-commands.js +33 -0
- package/dist/cli/built-commands.js.map +1 -0
- package/dist/cli/commands-command.d.ts.map +1 -1
- package/dist/cli/commands-command.js +3 -2
- package/dist/cli/commands-command.js.map +1 -1
- package/dist/cli/complete-command.d.ts +187 -2
- package/dist/cli/complete-command.d.ts.map +1 -1
- package/dist/cli/complete-command.js +3 -2
- package/dist/cli/complete-command.js.map +1 -1
- package/dist/cli/config-command.d.ts +189 -3
- package/dist/cli/config-command.d.ts.map +1 -1
- package/dist/cli/config-command.js +3 -2
- package/dist/cli/config-command.js.map +1 -1
- package/dist/cli/context.d.ts +8 -0
- package/dist/cli/context.d.ts.map +1 -1
- package/dist/cli/context.js +39 -2
- package/dist/cli/context.js.map +1 -1
- package/dist/cli/documents/words.d.ts +1 -1
- package/dist/cli/dry-run-guard.d.ts.map +1 -1
- package/dist/cli/dry-run-guard.js +6 -28
- package/dist/cli/dry-run-guard.js.map +1 -1
- package/dist/cli/first-run.js +1 -1
- package/dist/cli/first-run.js.map +1 -1
- package/dist/cli/guide.d.ts.map +1 -1
- package/dist/cli/guide.js +3 -2
- package/dist/cli/guide.js.map +1 -1
- package/dist/cli/messenger/archive-commands.d.ts.map +1 -1
- package/dist/cli/messenger/archive-commands.js +3 -2
- package/dist/cli/messenger/archive-commands.js.map +1 -1
- package/dist/cli/messenger/complete-command.d.ts +187 -2
- package/dist/cli/messenger/complete-command.d.ts.map +1 -1
- package/dist/cli/messenger/complete-command.js +3 -2
- package/dist/cli/messenger/complete-command.js.map +1 -1
- package/dist/cli/messenger/doctor-command.d.ts.map +1 -1
- package/dist/cli/messenger/doctor-command.js +3 -2
- package/dist/cli/messenger/doctor-command.js.map +1 -1
- package/dist/cli/messenger/flood-command.d.ts.map +1 -1
- package/dist/cli/messenger/flood-command.js +3 -2
- package/dist/cli/messenger/flood-command.js.map +1 -1
- package/dist/cli/messenger/mcp-command.d.ts.map +1 -1
- package/dist/cli/messenger/mcp-command.js +3 -2
- package/dist/cli/messenger/mcp-command.js.map +1 -1
- package/dist/cli/messenger/metadata-command.d.ts.map +1 -1
- package/dist/cli/messenger/metadata-command.js +3 -2
- package/dist/cli/messenger/metadata-command.js.map +1 -1
- package/dist/cli/messenger/models-command.d.ts.map +1 -1
- package/dist/cli/messenger/models-command.js +3 -2
- package/dist/cli/messenger/models-command.js.map +1 -1
- package/dist/cli/messenger/server-command.d.ts +1 -1
- package/dist/cli/messenger/server-command.d.ts.map +1 -1
- package/dist/cli/messenger/server-command.js +3 -2
- package/dist/cli/messenger/server-command.js.map +1 -1
- package/dist/cli/messenger/session-commands.d.ts.map +1 -1
- package/dist/cli/messenger/session-commands.js +3 -2
- package/dist/cli/messenger/session-commands.js.map +1 -1
- package/dist/cli/messenger/store-maintenance-command.d.ts.map +1 -1
- package/dist/cli/messenger/store-maintenance-command.js +11 -5
- package/dist/cli/messenger/store-maintenance-command.js.map +1 -1
- package/dist/cli/model-catalogue-command.d.ts.map +1 -1
- package/dist/cli/model-catalogue-command.js +3 -2
- package/dist/cli/model-catalogue-command.js.map +1 -1
- package/dist/cli/oauth-session.d.ts.map +1 -1
- package/dist/cli/oauth-session.js +3 -2
- package/dist/cli/oauth-session.js.map +1 -1
- package/dist/cli/runs/command.d.ts.map +1 -1
- package/dist/cli/runs/command.js +3 -2
- package/dist/cli/runs/command.js.map +1 -1
- package/dist/cli/schedule/schedule-command.d.ts +1 -1
- package/dist/cli/schedule/schedule-command.d.ts.map +1 -1
- package/dist/cli/schedule/schedule-command.js +5 -3
- package/dist/cli/schedule/schedule-command.js.map +1 -1
- package/dist/cli/setup-command.d.ts.map +1 -1
- package/dist/cli/setup-command.js +3 -2
- package/dist/cli/setup-command.js.map +1 -1
- package/dist/cli/skill-command.d.ts.map +1 -1
- package/dist/cli/skill-command.js +3 -2
- package/dist/cli/skill-command.js.map +1 -1
- package/dist/cli/store-info.d.ts.map +1 -1
- package/dist/cli/store-info.js +5 -4
- package/dist/cli/store-info.js.map +1 -1
- package/dist/cli/token-session.d.ts.map +1 -1
- package/dist/cli/token-session.js +2 -1
- package/dist/cli/token-session.js.map +1 -1
- package/dist/cli/upgrade-command.d.ts.map +1 -1
- package/dist/cli/upgrade-command.js +4 -5
- package/dist/cli/upgrade-command.js.map +1 -1
- package/dist/cli/upkeep.d.ts +8 -0
- package/dist/cli/upkeep.d.ts.map +1 -0
- package/dist/cli/upkeep.js +11 -0
- package/dist/cli/upkeep.js.map +1 -0
- package/dist/entities/attachment.d.ts +0 -8
- package/dist/entities/attachment.d.ts.map +1 -1
- package/dist/entities/attachment.js +22 -20
- package/dist/entities/attachment.js.map +1 -1
- package/dist/entities/chat.d.ts +0 -4
- package/dist/entities/chat.d.ts.map +1 -1
- package/dist/entities/chat.js +6 -10
- package/dist/entities/chat.js.map +1 -1
- package/dist/entities/contact.d.ts +0 -7
- package/dist/entities/contact.d.ts.map +1 -1
- package/dist/entities/contact.js +9 -16
- package/dist/entities/contact.js.map +1 -1
- package/dist/entities/deal.d.ts +0 -36
- package/dist/entities/deal.d.ts.map +1 -1
- package/dist/entities/deal.js +22 -48
- package/dist/entities/deal.js.map +1 -1
- package/dist/entities/document.d.ts +0 -2
- package/dist/entities/document.d.ts.map +1 -1
- package/dist/entities/document.js +3 -5
- package/dist/entities/document.js.map +1 -1
- package/dist/entities/fields.d.ts +5 -1
- package/dist/entities/fields.d.ts.map +1 -1
- package/dist/entities/fields.js +6 -2
- package/dist/entities/fields.js.map +1 -1
- package/dist/entities/hit.d.ts +0 -18
- package/dist/entities/hit.d.ts.map +1 -1
- package/dist/entities/hit.js +19 -37
- package/dist/entities/hit.js.map +1 -1
- package/dist/entities/index.d.ts +0 -1
- package/dist/entities/index.d.ts.map +1 -1
- package/dist/entities/index.js +2 -3
- package/dist/entities/index.js.map +1 -1
- package/dist/entities/message.d.ts +2 -34
- package/dist/entities/message.d.ts.map +1 -1
- package/dist/entities/message.js +35 -67
- package/dist/entities/message.js.map +1 -1
- package/dist/entities/task.d.ts +0 -19
- package/dist/entities/task.d.ts.map +1 -1
- package/dist/entities/task.js +18 -35
- package/dist/entities/task.js.map +1 -1
- package/dist/mcp/agent.d.ts +3 -0
- package/dist/mcp/agent.d.ts.map +1 -1
- package/dist/mcp/agent.js +48 -1
- package/dist/mcp/agent.js.map +1 -1
- package/dist/mcp/app-server.d.ts.map +1 -1
- package/dist/mcp/app-server.js +8 -5
- package/dist/mcp/app-server.js.map +1 -1
- package/dist/mcp/bot/instructions.js +1 -1
- package/dist/mcp/bot/instructions.js.map +1 -1
- package/dist/mcp/index.d.ts +4 -0
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js +4 -0
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/instructions.js +4 -4
- package/dist/mcp/instructions.js.map +1 -1
- package/dist/mcp/lean.d.ts +9 -0
- package/dist/mcp/lean.d.ts.map +1 -0
- package/dist/mcp/lean.js +7 -0
- package/dist/mcp/lean.js.map +1 -0
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +6 -2
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp/surface.d.ts +51 -2
- package/dist/mcp/surface.d.ts.map +1 -1
- package/dist/mcp/surface.js +379 -52
- package/dist/mcp/surface.js.map +1 -1
- package/dist/mcp/tool.d.ts +9 -1
- package/dist/mcp/tool.d.ts.map +1 -1
- package/dist/mcp/tool.js +20 -6
- package/dist/mcp/tool.js.map +1 -1
- package/dist/output-detail.d.ts +8 -0
- package/dist/output-detail.d.ts.map +1 -1
- package/dist/output-detail.js +55 -0
- package/dist/output-detail.js.map +1 -1
- package/dist/services/package-upgrade.d.ts.map +1 -1
- package/dist/services/package-upgrade.js +3 -1
- package/dist/services/package-upgrade.js.map +1 -1
- package/dist/store/compatibility.d.ts +2 -0
- package/dist/store/compatibility.d.ts.map +1 -1
- package/dist/store/compatibility.js +12 -0
- package/dist/store/compatibility.js.map +1 -1
- package/dist/store/migrations.d.ts +3 -3
- package/dist/store/migrations.js +3 -3
- package/dist/store/sqlite/clients.d.ts +6 -0
- package/dist/store/sqlite/clients.d.ts.map +1 -1
- package/dist/store/sqlite/clients.js +6 -4
- package/dist/store/sqlite/clients.js.map +1 -1
- package/dist/store/sqlite/manifest.d.ts +4 -0
- package/dist/store/sqlite/manifest.d.ts.map +1 -1
- package/dist/store/sqlite/manifest.js.map +1 -1
- package/package.json +1 -1
- package/skills/link-conversations/SKILL.md +1 -1
- package/src/cli/app-doctor-command.ts +41 -42
- package/src/cli/app-mcp-command.ts +55 -52
- package/src/cli/built-commands.ts +32 -0
- package/src/cli/commands-command.ts +3 -2
- package/src/cli/complete-command.ts +53 -48
- package/src/cli/config-command.ts +180 -177
- package/src/cli/context.ts +44 -2
- package/src/cli/dry-run-guard.ts +11 -23
- package/src/cli/first-run.ts +1 -1
- package/src/cli/guide.ts +3 -2
- package/src/cli/messenger/archive-commands.ts +3 -2
- package/src/cli/messenger/complete-command.ts +30 -30
- package/src/cli/messenger/doctor-command.ts +3 -2
- package/src/cli/messenger/flood-command.ts +3 -2
- package/src/cli/messenger/mcp-command.ts +3 -2
- package/src/cli/messenger/metadata-command.ts +3 -2
- package/src/cli/messenger/models-command.ts +3 -2
- package/src/cli/messenger/server-command.ts +3 -2
- package/src/cli/messenger/session-commands.ts +3 -2
- package/src/cli/messenger/store-maintenance-command.ts +18 -12
- package/src/cli/model-catalogue-command.ts +3 -2
- package/src/cli/oauth-session.ts +3 -2
- package/src/cli/runs/command.ts +3 -2
- package/src/cli/schedule/schedule-command.ts +412 -410
- package/src/cli/setup-command.ts +3 -2
- package/src/cli/skill-command.ts +3 -2
- package/src/cli/store-info.ts +21 -16
- package/src/cli/token-session.ts +3 -2
- package/src/cli/upgrade-command.ts +59 -62
- package/src/cli/upkeep.ts +15 -0
- package/src/entities/attachment.ts +44 -30
- package/src/entities/chat.ts +9 -10
- package/src/entities/contact.ts +20 -21
- package/src/entities/deal.ts +66 -53
- package/src/entities/document.ts +3 -5
- package/src/entities/fields.ts +11 -2
- package/src/entities/hit.ts +52 -37
- package/src/entities/index.ts +2 -3
- package/src/entities/message.ts +101 -80
- package/src/entities/task.ts +37 -38
- package/src/mcp/agent.ts +51 -1
- package/src/mcp/app-server.ts +8 -5
- package/src/mcp/bot/instructions.ts +1 -1
- package/src/mcp/index.ts +4 -0
- package/src/mcp/instructions.ts +4 -4
- package/src/mcp/lean.ts +8 -0
- package/src/mcp/server.ts +6 -2
- package/src/mcp/surface.ts +436 -64
- package/src/mcp/tool.ts +27 -4
- package/src/output-detail.ts +61 -0
- package/src/services/package-upgrade.ts +3 -1
- package/src/store/compatibility.ts +12 -0
- package/src/store/migrations.ts +3 -3
- package/src/store/sqlite/clients.ts +17 -6
- package/src/store/sqlite/manifest.ts +4 -0
- package/dist/bundle/install-IPXFNLYZ-BSWiztYR.js +0 -5
- package/dist/bundle/mdast-util-to-markdown-UGCOLDXA-7D6EJn9r.js +0 -12
- package/dist/bundle/meeting-semantic-I7AZQTEI-BgZ3ZzQB.js +0 -5
- package/dist/bundle/notes-search-2Q3C65PA-CWKHboCy.js +0 -5
- package/dist/bundle/oauth-TVUNW3GM-BqlyhUfp.js +0 -7
- package/dist/bundle/serve-7KRXCBBZ-BO9BKhWL.js +0 -8
- package/dist/bundle/server-PIT6UZRZ-C6I-VrDd.js +0 -11
- package/dist/bundle/server-ZL4FMEHH-DP1oYgCn.js +0 -12
- package/dist/bundle/state-3CFS2SAC-xptBCfut.js +0 -5
- package/dist/bundle/store-ASWYHJ4Q-C7EFfvzB.js +0 -5
- package/dist/bundle/surface-DDH4HGT3-CBZnEqH_.js +0 -8
package/src/mcp/surface.ts
CHANGED
|
@@ -3,12 +3,15 @@ import type { CallToolResult, McpServer, ServerContext } from "@modelcontextprot
|
|
|
3
3
|
import { toJsonSchema, toStandardJsonSchema } from "@valibot/to-json-schema"
|
|
4
4
|
import { CliError } from "@wirecat/cli-base"
|
|
5
5
|
import type { CommandOutput } from "@wirecat/cli-base/commands"
|
|
6
|
+
import { MAX_NEXT_STEPS, type Meta, type NextStep } from "@wirecat/cli-base/standards"
|
|
6
7
|
import * as v from "valibot"
|
|
7
8
|
import { answerSchema, listOf } from "../cli/envelope.js"
|
|
9
|
+
import { nextStep } from "../cli/steps.js"
|
|
8
10
|
import { ENTITIES, type EntityName } from "../entities/index.js"
|
|
9
11
|
import type { AppErrors } from "../errors/reasons.js"
|
|
10
12
|
import type { CommandAvailability } from "./agent.js"
|
|
11
13
|
import { type CallerSource, callerOf, currentCaller, withCaller } from "./caller.js"
|
|
14
|
+
import { leansRead } from "./lean.js"
|
|
12
15
|
import { agentArguments } from "./text.js"
|
|
13
16
|
import {
|
|
14
17
|
type AnyTool,
|
|
@@ -26,13 +29,23 @@ import {
|
|
|
26
29
|
WRITE,
|
|
27
30
|
} from "./tool.js"
|
|
28
31
|
|
|
29
|
-
|
|
32
|
+
// Claude Code saves an answer over 25,000 tokens to a file the agent never reads: one match with 14 arguments is
|
|
33
|
+
// 1,700 characters, a match's answer schema was up to 60,000.
|
|
34
|
+
const MATCHES = 5
|
|
35
|
+
const FULL_MATCHES = 2
|
|
36
|
+
/** A match scoring under 45% of the best one answers another task: `polls create` for "messages send". */
|
|
37
|
+
const NEAR = 0.45
|
|
38
|
+
/** About 10,000 tokens, where Claude Code starts to warn; an answer past it is cut where a page can carry the rest. */
|
|
39
|
+
export const AGENT_ANSWER_CHARS = 40_000
|
|
30
40
|
const ANSWER = answerSchema()
|
|
31
41
|
|
|
32
42
|
// The listing shows an agent only what it acts on; the server still checks every answer against the full envelope,
|
|
33
|
-
// and tools_search gives
|
|
43
|
+
// and tools_search with `schema` gives one command's. meta.ranking alone took 2,800 characters of every connect.
|
|
34
44
|
const agentAnswer = (prefix: string, writes: boolean) => {
|
|
35
|
-
const meta = v.pipe(
|
|
45
|
+
const meta = v.pipe(
|
|
46
|
+
v.looseObject({}),
|
|
47
|
+
v.description(`run facts; ${prefix}_tools_search with schema: true shows the full answer`),
|
|
48
|
+
)
|
|
36
49
|
const next = v.optional(v.pipe(v.array(v.looseObject({})), v.description("steps to run next: command and args")))
|
|
37
50
|
return v.looseObject(
|
|
38
51
|
writes
|
|
@@ -67,8 +80,12 @@ export interface McpCommand {
|
|
|
67
80
|
keywords?: readonly string[]
|
|
68
81
|
writes: boolean
|
|
69
82
|
input: Input
|
|
70
|
-
/** The envelope it answers with
|
|
83
|
+
/** The envelope it answers with; else the one of `answers`; any envelope otherwise. */
|
|
71
84
|
output?: v.GenericSchema
|
|
85
|
+
/** The name of the entity it answers with, `message_write`, when it declares one. */
|
|
86
|
+
answers?: string
|
|
87
|
+
/** One of cli-core's commands that run the CLI itself (config, sign-in, the store): one name in the listing. */
|
|
88
|
+
upkeep?: boolean
|
|
72
89
|
/** `run` checks the arguments itself, and records a refusal. */
|
|
73
90
|
checked?: boolean
|
|
74
91
|
run: (args: Record<string, unknown>, ctx: ServerContext) => Promise<CallToolResult>
|
|
@@ -100,15 +117,18 @@ const wordsOf = (text: string): string[] =>
|
|
|
100
117
|
const stem = (word: string): string => {
|
|
101
118
|
const bare = word.replace(/'s$/u, "")
|
|
102
119
|
if (bare.length > 4 && bare.endsWith("ies")) return `${bare.slice(0, -3)}y`
|
|
103
|
-
|
|
120
|
+
// `es` only after a hiss, so `notes` is `note` as the task's "note" is: `matches` is `match`.
|
|
121
|
+
if (bare.length > 5 && /(?:[sxz]|ch|sh)es$/u.test(bare)) return bare.slice(0, -2)
|
|
122
|
+
for (const ending of ["ing", "ed", "s"])
|
|
104
123
|
if (bare.length - ending.length >= 3 && bare.endsWith(ending)) return bare.slice(0, -ending.length)
|
|
105
124
|
return bare
|
|
106
125
|
}
|
|
107
126
|
|
|
108
|
-
|
|
109
|
-
|
|
127
|
+
/** 1 for the same word, ½ for one that starts the other (`time` in `timer`), 0 for another word. */
|
|
128
|
+
const likeness = (asked: string, known: string): number => {
|
|
129
|
+
if (asked === known) return 1
|
|
110
130
|
const [short, long] = asked.length <= known.length ? [asked, known] : [known, asked]
|
|
111
|
-
return short.length >= 3 && long.startsWith(short)
|
|
131
|
+
return short.length >= 3 && long.startsWith(short) ? 0.5 : 0
|
|
112
132
|
}
|
|
113
133
|
|
|
114
134
|
/** Where a word of the task is found, by how much it says about the command: its own name says the most. */
|
|
@@ -119,48 +139,325 @@ const fieldsOf = (command: string, one: McpCommand): [number, string[]][] =>
|
|
|
119
139
|
[1, [...wordsOf(one.description), ...(one.keywords ?? []).flatMap(wordsOf), ...Object.keys(one.input.entries)]],
|
|
120
140
|
].map(([weight, words]) => [weight as number, [...new Set((words as string[]).map(stem))]])
|
|
121
141
|
|
|
142
|
+
/** Each two words in a row, stemmed, that hold a telling word: `reports to`, `a person`, not `to a`. */
|
|
143
|
+
const pairsOf = (text: string): string[] => {
|
|
144
|
+
const words = wordsOf(text)
|
|
145
|
+
return words.slice(1).flatMap((word, at) => {
|
|
146
|
+
const before = words[at] ?? ""
|
|
147
|
+
return STOP_WORDS.has(before) && STOP_WORDS.has(word) ? [] : [`${stem(before)} ${stem(word)}`]
|
|
148
|
+
})
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/** A task often says what the help says: "who reports to whom" is a phrase of `relationships list`'s help. */
|
|
152
|
+
const PAIR = 3
|
|
153
|
+
|
|
122
154
|
/**
|
|
123
155
|
* Ranks by how many words of the task a command matches, then by where they matched: its name, then its title, then
|
|
124
156
|
* its help, examples and arguments. A task is typed in its own words, so no single word is required. The command
|
|
125
157
|
* named exactly ranks first. No word lists everything.
|
|
126
158
|
*/
|
|
127
159
|
export const search = (commands: Record<string, McpCommand>, query: string): [string, McpCommand][] => {
|
|
160
|
+
if (!normal(query)) return Object.entries(commands).sort((a, b) => a[0].localeCompare(b[0]))
|
|
161
|
+
return scored(commands, query).map(({ entry }) => entry)
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
interface Scored {
|
|
165
|
+
entry: [string, McpCommand]
|
|
166
|
+
exact: boolean
|
|
167
|
+
/** Every telling word of the task matched. */
|
|
168
|
+
whole: boolean
|
|
169
|
+
score: number
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
const scored = (commands: Record<string, McpCommand>, query: string): Scored[] => {
|
|
128
173
|
const named = normal(query)
|
|
129
174
|
const all = Object.entries(commands)
|
|
130
|
-
|
|
131
|
-
const words = [
|
|
175
|
+
const asked = [
|
|
132
176
|
...new Set(
|
|
133
177
|
wordsOf(query)
|
|
134
178
|
.filter((word) => word.length > 1 && !STOP_WORDS.has(word))
|
|
135
179
|
.map(stem),
|
|
136
180
|
),
|
|
137
181
|
]
|
|
182
|
+
const pairs = [...new Set(pairsOf(query))]
|
|
183
|
+
const phrased = all.map(([command, one]) => {
|
|
184
|
+
// A name's words come in either order, "list events" for `events list`; examples' words are no phrase.
|
|
185
|
+
const names = [command, ...(one.aliases ?? [])].flatMap((name) => [name, wordsOf(name).reverse().join(" ")])
|
|
186
|
+
const known = new Set([...names, one.title, one.description].flatMap(pairsOf))
|
|
187
|
+
return pairs.filter((pair) => known.has(pair)).length
|
|
188
|
+
})
|
|
189
|
+
// Per word: the best field's weight, and how many fields hold the word itself, which breaks a tie.
|
|
190
|
+
const weighed = all.map((entry) => {
|
|
191
|
+
const fields = fieldsOf(entry[0], entry[1])
|
|
192
|
+
return asked.map((word) => {
|
|
193
|
+
const likes = fields.map(([weight, known]) => ({
|
|
194
|
+
weight: weight * known.reduce((most, one) => Math.max(most, likeness(word, one)), 0),
|
|
195
|
+
same: known.includes(word),
|
|
196
|
+
}))
|
|
197
|
+
return {
|
|
198
|
+
weight: likes.reduce((best, one) => Math.max(best, one.weight), 0),
|
|
199
|
+
fields: likes.filter(({ same }) => same).length,
|
|
200
|
+
}
|
|
201
|
+
})
|
|
202
|
+
})
|
|
138
203
|
return (
|
|
139
204
|
all
|
|
140
|
-
.map((entry) => {
|
|
141
|
-
const
|
|
142
|
-
const
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
205
|
+
.map((entry, index) => {
|
|
206
|
+
const found = weighed[index] ?? []
|
|
207
|
+
const matched = found.filter(({ weight }) => weight > 0).length
|
|
208
|
+
const exact = isNamed(entry, named)
|
|
209
|
+
return {
|
|
210
|
+
entry,
|
|
211
|
+
exact,
|
|
212
|
+
whole: matched === found.length,
|
|
213
|
+
score:
|
|
214
|
+
matched * 10 +
|
|
215
|
+
found.reduce((sum, { weight }) => sum + weight, 0) +
|
|
216
|
+
(matched ? PAIR * (phrased[index] ?? 0) : 0),
|
|
217
|
+
evidence: found.reduce((sum, { fields }) => sum + fields, 0),
|
|
218
|
+
}
|
|
151
219
|
})
|
|
152
|
-
.filter(({
|
|
153
|
-
// A tie goes to the
|
|
220
|
+
.filter(({ score, exact }) => score > 0 || exact)
|
|
221
|
+
// A tie goes to the command that holds the words in more places, then to the shorter name, which holds less the
|
|
222
|
+
// task did not ask for: `messages send` first.
|
|
154
223
|
.sort(
|
|
155
224
|
(a, b) =>
|
|
156
|
-
b.
|
|
225
|
+
Number(b.exact) - Number(a.exact) ||
|
|
226
|
+
b.score - a.score ||
|
|
227
|
+
b.evidence - a.evidence ||
|
|
157
228
|
wordsOf(a.entry[0]).length - wordsOf(b.entry[0]).length ||
|
|
158
229
|
a.entry[0].localeCompare(b.entry[0]),
|
|
159
230
|
)
|
|
160
|
-
.map(({ entry }) => entry)
|
|
161
231
|
)
|
|
162
232
|
}
|
|
163
233
|
|
|
234
|
+
const isApi = (command: string): boolean => command.split(" ")[0] === "api"
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* The commands a task most likely means, best first. Generated `api *` commands rank below the hand-written ones and
|
|
238
|
+
* come in only when the task names `api` or no hand-written command scores near them: in hubspot "find contact" gave
|
|
239
|
+
* eight `api contacts-*` and no `people` command. When no hand-written command matched every word, the best `api *`
|
|
240
|
+
* one still takes the last place: gcal's "free time" is `calendars busy` or `api calendar-freebusy-query`.
|
|
241
|
+
*/
|
|
242
|
+
export const matchesOf = (commands: Record<string, McpCommand>, query: string): [string, McpCommand][] => {
|
|
243
|
+
const ranked = scored(commands, query)
|
|
244
|
+
const groups = new Set(wordsOf(query).map(stem))
|
|
245
|
+
if (normal(query).split(" ")[0] === "api") return near(ranked, groups)
|
|
246
|
+
const own = ranked.filter(({ entry, exact }) => exact || !isApi(entry[0]))
|
|
247
|
+
const api = ranked.filter(({ entry, exact }) => !exact && isApi(entry[0]))
|
|
248
|
+
const best = bestOf(own)
|
|
249
|
+
if (best < NEAR * (api[0]?.score ?? 0)) return near([...own, ...api], groups)
|
|
250
|
+
const shown = near(own, groups)
|
|
251
|
+
const fallback = api[0]
|
|
252
|
+
if (!fallback || own.some(({ whole }) => whole) || fallback.score < NEAR * best) return shown
|
|
253
|
+
return [...shown.slice(0, MATCHES - 1), fallback.entry, ...shown.slice(MATCHES - 1)]
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
const bestOf = (ranked: Scored[]): number => ranked.reduce((best, { score }) => Math.max(best, score), 0)
|
|
257
|
+
|
|
258
|
+
/** At most 2 of one group the task does not name: five `schedule *` siblings hid `calendars busy`. */
|
|
259
|
+
const SIBLINGS = 2
|
|
260
|
+
|
|
261
|
+
const near = (ranked: Scored[], groups: Set<string>): [string, McpCommand][] => {
|
|
262
|
+
const best = bestOf(ranked)
|
|
263
|
+
const taken = new Map<string, number>()
|
|
264
|
+
return ranked
|
|
265
|
+
.filter(({ exact, score }) => exact || score >= NEAR * best)
|
|
266
|
+
.filter(({ entry, exact }) => {
|
|
267
|
+
const group = stem(entry[0].split(" ")[0] ?? "")
|
|
268
|
+
const count = (taken.get(group) ?? 0) + 1
|
|
269
|
+
taken.set(group, count)
|
|
270
|
+
return exact || groups.has(group) || count <= SIBLINGS
|
|
271
|
+
})
|
|
272
|
+
.map(({ entry }) => entry)
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
// Keywords that check a value, not what it means; the CLI checks them again. Data keys keep everything under them.
|
|
276
|
+
const CHECKS = new Set(["$schema", "pattern", "minLength", "minItems"])
|
|
277
|
+
const DATA = new Set(["default", "enum", "const", "examples"])
|
|
278
|
+
|
|
279
|
+
/** A command's arguments as an agent needs them to call it: type, description, enum, default, required. */
|
|
280
|
+
export const argumentsOf = (one: McpCommand): unknown => {
|
|
281
|
+
const bare = (node: unknown): unknown => {
|
|
282
|
+
if (Array.isArray(node)) return node.map(bare)
|
|
283
|
+
if (node === null || typeof node !== "object") return node
|
|
284
|
+
return Object.fromEntries(
|
|
285
|
+
Object.entries(node)
|
|
286
|
+
.filter(
|
|
287
|
+
([key, value]) =>
|
|
288
|
+
!CHECKS.has(key) &&
|
|
289
|
+
!(key === "additionalProperties" && value === false) &&
|
|
290
|
+
!(key === "required" && Array.isArray(value) && value.length === 0),
|
|
291
|
+
)
|
|
292
|
+
.map(([key, value]) => [
|
|
293
|
+
key,
|
|
294
|
+
DATA.has(key)
|
|
295
|
+
? value
|
|
296
|
+
: key === "properties" && value !== null && typeof value === "object"
|
|
297
|
+
? Object.fromEntries(Object.entries(value).map(([name, inner]) => [name, bare(inner)]))
|
|
298
|
+
: bare(value),
|
|
299
|
+
]),
|
|
300
|
+
)
|
|
301
|
+
}
|
|
302
|
+
return bare(toJsonSchema(one.input))
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
/** Shown only when it changes what the agent does: a command that is refused, or that asks the owner first. */
|
|
306
|
+
const availabilityOf = (one: McpCommand) => {
|
|
307
|
+
const availability = one.availability?.()
|
|
308
|
+
return availability && (!availability.available || (availability.level ?? "allow") !== "allow")
|
|
309
|
+
? { availability }
|
|
310
|
+
: {}
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
const shortMatch = (command: string, one: McpCommand) => ({
|
|
314
|
+
command,
|
|
315
|
+
does: one.description,
|
|
316
|
+
writes: one.writes,
|
|
317
|
+
...availabilityOf(one),
|
|
318
|
+
})
|
|
319
|
+
|
|
320
|
+
const fullMatch = (command: string, one: McpCommand) => ({
|
|
321
|
+
command,
|
|
322
|
+
...(one.title !== one.description ? { title: one.title } : {}),
|
|
323
|
+
does: one.description,
|
|
324
|
+
writes: one.writes,
|
|
325
|
+
...(one.answers ? { answers: one.answers } : {}),
|
|
326
|
+
...availabilityOf(one),
|
|
327
|
+
arguments: argumentsOf(one),
|
|
328
|
+
})
|
|
329
|
+
|
|
330
|
+
const API_ROOM = 2_000
|
|
331
|
+
|
|
332
|
+
/**
|
|
333
|
+
* The generated `api *` commands as names, each reachable by its own name; past `room` characters, the names that fit
|
|
334
|
+
* and how to find the rest.
|
|
335
|
+
*/
|
|
336
|
+
const apiGroup = (api: [string, McpCommand][], prefix: string, room: number) => {
|
|
337
|
+
const find = `${prefix}_tools_search with "api" and words of the task, for example "${api[0]?.[0]}"`
|
|
338
|
+
const commands: string[] = []
|
|
339
|
+
let size = find.length + API_ROOM
|
|
340
|
+
for (const [command] of api) {
|
|
341
|
+
size += command.length + 3
|
|
342
|
+
if (size > room) break
|
|
343
|
+
commands.push(command)
|
|
344
|
+
}
|
|
345
|
+
return {
|
|
346
|
+
group: "api",
|
|
347
|
+
count: api.length,
|
|
348
|
+
commands,
|
|
349
|
+
...(commands.length < api.length ? { find } : {}),
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
const isNamed = ([command, one]: [string, McpCommand], named: string) =>
|
|
354
|
+
normal(command) === named || (one.aliases ?? []).some((alias) => normal(alias) === named)
|
|
355
|
+
|
|
356
|
+
/** An agent's read leaves out empty fields (`agentView`), so no field of a record is sure to be there. */
|
|
357
|
+
const asAgentSees = (schema: unknown, inRecord = false): unknown => {
|
|
358
|
+
if (Array.isArray(schema)) return schema.map((one) => asAgentSees(one, inRecord))
|
|
359
|
+
if (schema === null || typeof schema !== "object") return schema
|
|
360
|
+
return Object.fromEntries(
|
|
361
|
+
Object.entries(schema)
|
|
362
|
+
.filter(([key]) => !(inRecord && key === "required"))
|
|
363
|
+
.map(([key, value]) => [
|
|
364
|
+
key,
|
|
365
|
+
key === "properties" && value !== null && typeof value === "object"
|
|
366
|
+
? Object.fromEntries(
|
|
367
|
+
Object.entries(value).map(([name, inner]) => [
|
|
368
|
+
name,
|
|
369
|
+
asAgentSees(inner, inRecord || name === "item" || name === "items"),
|
|
370
|
+
]),
|
|
371
|
+
)
|
|
372
|
+
: asAgentSees(value, inRecord),
|
|
373
|
+
]),
|
|
374
|
+
)
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
/** Only a read of records goes out lean (`leansRead`); a write's receipt or a report keeps every field. */
|
|
378
|
+
const leanSchema = (one: McpCommand, schema: unknown) =>
|
|
379
|
+
leansRead({ writes: one.writes, ...(one.answers ? { entity: one.answers } : {}) }) ? asAgentSees(schema) : schema
|
|
380
|
+
|
|
381
|
+
/** Every command a line, grouped by the first word; the CLI's own upkeep in one line, `api *` as a count. */
|
|
382
|
+
const listingOf = (commands: Record<string, McpCommand>, prefix: string) => {
|
|
383
|
+
const all = search(commands, "")
|
|
384
|
+
const api = all.filter(([command]) => isApi(command))
|
|
385
|
+
// An upkeep command that is refused or asks first keeps its own line, so the listing still says so.
|
|
386
|
+
const service = all.filter(
|
|
387
|
+
([command, one]) => !isApi(command) && one.upkeep === true && !("availability" in availabilityOf(one)),
|
|
388
|
+
)
|
|
389
|
+
const own = all.filter(([command]) => !isApi(command) && !service.some(([named]) => named === command))
|
|
390
|
+
const rows = [
|
|
391
|
+
...own.map(([command, one]) => ({
|
|
392
|
+
command,
|
|
393
|
+
// A listing is a line a command: the shorter text, since memo's descriptions alone took 55,000 characters.
|
|
394
|
+
does: one.title.length < one.description.length ? one.title : one.description,
|
|
395
|
+
...(one.writes ? { writes: true } : {}),
|
|
396
|
+
...availabilityOf(one),
|
|
397
|
+
})),
|
|
398
|
+
...(service.length ? [{ group: "service", commands: service.map(([command]) => command) }] : []),
|
|
399
|
+
]
|
|
400
|
+
const listed = [
|
|
401
|
+
...rows,
|
|
402
|
+
...(api.length ? [apiGroup(api, prefix, AGENT_ANSWER_CHARS - JSON.stringify(rows).length)] : []),
|
|
403
|
+
]
|
|
404
|
+
return listed
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
/**
|
|
408
|
+
* The answer of `<prefix>_tools_search`: the first matches with their arguments, the rest a line each; with no
|
|
409
|
+
* words, the listing; with `schema` and a command's exact name, that command's answer schema too.
|
|
410
|
+
* @experimental
|
|
411
|
+
*/
|
|
412
|
+
export const searchAnswer = (
|
|
413
|
+
commands: Record<string, McpCommand>,
|
|
414
|
+
prefix: string,
|
|
415
|
+
{ query = "", schema = false }: { query?: string; schema?: boolean } = {},
|
|
416
|
+
) => {
|
|
417
|
+
if (schema) {
|
|
418
|
+
const [command, one] = Object.entries(commands).find((entry) => isNamed(entry, normal(query))) ?? []
|
|
419
|
+
if (command === undefined || !one)
|
|
420
|
+
throw new CliError("validation_error", `schema needs a command's exact name; "${query}" is none`)
|
|
421
|
+
const { next: _none, ...list } = listOf(`${prefix}_tools_search`, {
|
|
422
|
+
items: [
|
|
423
|
+
{
|
|
424
|
+
...fullMatch(command, one),
|
|
425
|
+
output: leanSchema(one, toJsonSchema(one.output ?? (one.answers ? entityAnswer(one.answers) : ANSWER))),
|
|
426
|
+
},
|
|
427
|
+
],
|
|
428
|
+
limit: 1,
|
|
429
|
+
has_more: false,
|
|
430
|
+
})
|
|
431
|
+
return list
|
|
432
|
+
}
|
|
433
|
+
if (normal(query) === "api") {
|
|
434
|
+
const api = search(commands, "").filter(([command]) => isApi(command))
|
|
435
|
+
if (api.length) return unpaged(prefix, [apiGroup(api, prefix, AGENT_ANSWER_CHARS)], false)
|
|
436
|
+
}
|
|
437
|
+
const found = query.trim() ? matchesOf(commands, query) : []
|
|
438
|
+
const items = query.trim()
|
|
439
|
+
? found
|
|
440
|
+
.slice(0, MATCHES)
|
|
441
|
+
.map(([command, one], index) => (index < FULL_MATCHES ? fullMatch(command, one) : shortMatch(command, one)))
|
|
442
|
+
: listingOf(commands, prefix)
|
|
443
|
+
return unpaged(prefix, items, found.length > items.length)
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
// The tool takes no page: more matches mean narrower words, so the list carries no page to read on.
|
|
447
|
+
const unpaged = (prefix: string, items: unknown[], more: boolean) => {
|
|
448
|
+
const {
|
|
449
|
+
next: _paging,
|
|
450
|
+
page,
|
|
451
|
+
...list
|
|
452
|
+
} = listOf(`${prefix}_tools_search`, {
|
|
453
|
+
items,
|
|
454
|
+
limit: Math.max(items.length, 1),
|
|
455
|
+
has_more: more,
|
|
456
|
+
})
|
|
457
|
+
const { next_page: _none, ...shown } = page as typeof page & { next_page?: number }
|
|
458
|
+
return { ...list, page: shown }
|
|
459
|
+
}
|
|
460
|
+
|
|
164
461
|
const nearest = (commands: Record<string, McpCommand>, asked: string): string[] => {
|
|
165
462
|
const words = normal(asked).split(" ")
|
|
166
463
|
return Object.keys(commands)
|
|
@@ -185,6 +482,91 @@ const runnableOnly = (result: CallToolResult, offered: (command: string) => bool
|
|
|
185
482
|
}
|
|
186
483
|
}
|
|
187
484
|
|
|
485
|
+
type Body = Record<string, unknown> & { items?: unknown[]; next?: NextStep[]; meta?: Meta }
|
|
486
|
+
|
|
487
|
+
const rewritten = (result: CallToolResult, body: Body): CallToolResult => ({
|
|
488
|
+
...result,
|
|
489
|
+
structuredContent: body,
|
|
490
|
+
content: result.content.map((part) => (part.type === "text" ? { ...part, text: JSON.stringify(body) } : part)),
|
|
491
|
+
})
|
|
492
|
+
|
|
493
|
+
/**
|
|
494
|
+
* A page cut short at the size an agent reads whole, with a `page.next` that starts at the first row left out. Pages
|
|
495
|
+
* are offsets of `(page - 1) * limit`, so the shorter limit must divide the rows before this page. A cursor marks the
|
|
496
|
+
* end of the provider's page, never a row inside it, so a cursor list is not cut.
|
|
497
|
+
*/
|
|
498
|
+
const cutPage = (body: Body, command: string, one: McpCommand, args: Record<string, unknown>): Body | undefined => {
|
|
499
|
+
const { items, page } = body as { items?: unknown[]; page?: { mode?: string; limit?: number } }
|
|
500
|
+
if (one.writes || !Array.isArray(items) || page?.mode !== "page" || typeof page.limit !== "number") return undefined
|
|
501
|
+
if (!("page" in one.input.entries && "limit" in one.input.entries)) return undefined
|
|
502
|
+
const before = (Number(args.page ?? 1) - 1) * page.limit
|
|
503
|
+
if (!Number.isSafeInteger(before) || before < 0) return undefined
|
|
504
|
+
const paged = body.next?.find((step) => step.kind === "command" && step.step === "page.next")
|
|
505
|
+
// `all` read every row from the start; the step reads on from one page, and `--all` with `--page` is refused.
|
|
506
|
+
const { all: _all, ...rest } = paged?.kind === "command" ? paged.args : args
|
|
507
|
+
// Sizes once: a 3,000-row page cut a row at a time stringified the whole page 3,000 times.
|
|
508
|
+
const ends: number[] = []
|
|
509
|
+
items.forEach((item, index) => {
|
|
510
|
+
ends.push((ends[index - 1] ?? 0) + JSON.stringify(item).length + (index > 0 ? 1 : 0))
|
|
511
|
+
})
|
|
512
|
+
for (let shown = items.length - 1; shown >= 1; shown--) {
|
|
513
|
+
if (before % shown !== 0) continue
|
|
514
|
+
const values = { page: before / shown + 2, limit: shown }
|
|
515
|
+
const stepArgs = { ...rest, ...values }
|
|
516
|
+
const fresh = nextStep("page.next", { command, args: stepArgs, values: { shown } })
|
|
517
|
+
const step = paged?.kind === "command" ? { ...paged, args: stepArgs, why: fresh.why } : fresh
|
|
518
|
+
const shell = {
|
|
519
|
+
...body,
|
|
520
|
+
items: [],
|
|
521
|
+
page: { ...page, limit: shown, has_more: true, next_page: values.page },
|
|
522
|
+
next: [step, ...(body.next ?? []).filter((other) => other !== paged)].slice(0, MAX_NEXT_STEPS),
|
|
523
|
+
}
|
|
524
|
+
if (JSON.stringify(shell).length + (ends[shown - 1] ?? 0) <= AGENT_ANSWER_CHARS)
|
|
525
|
+
return { ...shell, items: items.slice(0, shown) }
|
|
526
|
+
}
|
|
527
|
+
return undefined
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
/** Too large and no page to carry the rest: whole, since the data is complete, with a limit that fits for a list. */
|
|
531
|
+
const flagged = (body: Body, size: number, command: string, one: McpCommand, args: Record<string, unknown>): Body => {
|
|
532
|
+
const items = Array.isArray(body.items) ? body.items.length : 0
|
|
533
|
+
const fits = Math.floor(((items * AGENT_ANSWER_CHARS) / size) * 0.9)
|
|
534
|
+
if (!("limit" in one.input.entries) || fits < 1 || fits >= items) return body
|
|
535
|
+
const { all: _all, page: _page, ...rest } = args
|
|
536
|
+
const step: NextStep = {
|
|
537
|
+
kind: "command",
|
|
538
|
+
step: "output.limit",
|
|
539
|
+
command,
|
|
540
|
+
args: { ...rest, limit: fits },
|
|
541
|
+
why: `this answer is ${size} characters, more than an agent reads whole; limit ${fits} gives a smaller one`,
|
|
542
|
+
safe_to_auto_execute: false,
|
|
543
|
+
}
|
|
544
|
+
return { ...body, next: [...(body.next ?? []), step].slice(0, MAX_NEXT_STEPS) }
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
/** An answer past what an agent reads whole: cut where a page carries the rest, else whole with a smaller limit. */
|
|
548
|
+
const fitted = (
|
|
549
|
+
result: CallToolResult,
|
|
550
|
+
command: string,
|
|
551
|
+
one: McpCommand,
|
|
552
|
+
args: Record<string, unknown>,
|
|
553
|
+
): CallToolResult => {
|
|
554
|
+
const body = result.structuredContent as Body | undefined
|
|
555
|
+
// A write's answer says what was changed: never cut, and the step to rerun it with a smaller limit would write again.
|
|
556
|
+
if (one.writes || result.isError || !body) return result
|
|
557
|
+
const size = JSON.stringify(body).length
|
|
558
|
+
if (size <= AGENT_ANSWER_CHARS) return result
|
|
559
|
+
const cut = (() => {
|
|
560
|
+
try {
|
|
561
|
+
return cutPage(body, command, one, args)
|
|
562
|
+
} catch {
|
|
563
|
+
// A step template refuses args it cannot print (an object, a newline): the answer goes out whole instead.
|
|
564
|
+
return undefined
|
|
565
|
+
}
|
|
566
|
+
})()
|
|
567
|
+
return rewritten(result, cut ?? flagged(body, size, command, one, args))
|
|
568
|
+
}
|
|
569
|
+
|
|
188
570
|
const takesNothing = (one: McpCommand): boolean =>
|
|
189
571
|
Object.values(one.input.entries).every((entry) => entry.type === "optional")
|
|
190
572
|
|
|
@@ -230,38 +612,28 @@ export const registerCommands = (
|
|
|
230
612
|
title: "Find a command",
|
|
231
613
|
description:
|
|
232
614
|
`Find the command for a task — ${tasks} — before calling ` +
|
|
233
|
-
`${prefix}_read or ${prefix}_write with it.
|
|
234
|
-
|
|
615
|
+
`${prefix}_read or ${prefix}_write with it. Up to ${MATCHES} matches, best first: each gives its command, ` +
|
|
616
|
+
`what it does and whether it writes; the first ${FULL_MATCHES} also give their arguments. A command's exact ` +
|
|
617
|
+
'name ranks it first. With no words, lists every command a line, by group; "api" lists the api commands.',
|
|
235
618
|
inputSchema: toStandardJsonSchema(
|
|
236
|
-
v.strictObject({
|
|
619
|
+
v.strictObject({
|
|
620
|
+
query: v.optional(v.pipe(v.string(), v.description("words that describe the task"))),
|
|
621
|
+
schema: v.optional(
|
|
622
|
+
v.pipe(
|
|
623
|
+
v.boolean(),
|
|
624
|
+
v.description("with a command's exact name as query: also its answer's schema, as an agent reads it"),
|
|
625
|
+
),
|
|
626
|
+
),
|
|
627
|
+
}),
|
|
237
628
|
),
|
|
238
629
|
annotations: { ...READ, openWorldHint: false, idempotentHint: true },
|
|
239
630
|
},
|
|
240
|
-
async ({ query }: { query?: string }) => {
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
description: one.description,
|
|
247
|
-
writes: one.writes,
|
|
248
|
-
availability: one.availability?.() ?? { available: true },
|
|
249
|
-
arguments: toJsonSchema(one.input),
|
|
250
|
-
output: toJsonSchema(one.output ?? ANSWER),
|
|
251
|
-
}))
|
|
252
|
-
: found.map(([command, one]) => ({
|
|
253
|
-
command,
|
|
254
|
-
title: one.title,
|
|
255
|
-
writes: one.writes,
|
|
256
|
-
availability: one.availability?.() ?? { available: true },
|
|
257
|
-
}))
|
|
258
|
-
// The tool takes no page: more matches mean narrower words, so the list carries no page.next to rerun.
|
|
259
|
-
const { next: _paging, ...list } = listOf(`${prefix}_tools_search`, {
|
|
260
|
-
items,
|
|
261
|
-
limit: Math.max(items.length, query?.trim() ? MATCHES : 1),
|
|
262
|
-
has_more: found.length > items.length,
|
|
263
|
-
})
|
|
264
|
-
return answered(list)
|
|
631
|
+
async ({ query, schema }: { query?: string; schema?: boolean }) => {
|
|
632
|
+
try {
|
|
633
|
+
return answered(searchAnswer(commands, prefix, { query: query ?? "", schema: schema === true }))
|
|
634
|
+
} catch (error) {
|
|
635
|
+
return failed(error, errors)
|
|
636
|
+
}
|
|
265
637
|
},
|
|
266
638
|
)
|
|
267
639
|
|
|
@@ -295,19 +667,16 @@ export const registerCommands = (
|
|
|
295
667
|
)
|
|
296
668
|
const args = writing ? agentArguments(given ?? {}) : (given ?? {})
|
|
297
669
|
const caller = currentCaller() ?? callerOf(ctx, command.replace(/[ -]/g, "_"), callers)
|
|
670
|
+
const offered = (named: string) => byNormal.has(normal(named))
|
|
298
671
|
if (one.checked)
|
|
299
|
-
return runnableOnly(await withCaller(caller, () => one.run(args, ctx)),
|
|
300
|
-
byNormal.has(normal(named)),
|
|
301
|
-
)
|
|
672
|
+
return fitted(runnableOnly(await withCaller(caller, () => one.run(args, ctx)), offered), command, one, args)
|
|
302
673
|
const parsed = v.safeParse(v.strictObject(one.input.entries), args)
|
|
303
674
|
if (!parsed.success)
|
|
304
675
|
throw new CliError("validation_error", `${command}: ${v.summarize(parsed.issues)}`, {
|
|
305
676
|
arguments: toJsonSchema(one.input),
|
|
306
677
|
})
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
(named) => byNormal.has(normal(named)),
|
|
310
|
-
)
|
|
678
|
+
const input = parsed.output as Record<string, unknown>
|
|
679
|
+
return fitted(runnableOnly(await withCaller(caller, () => one.run(input, ctx)), offered), command, one, input)
|
|
311
680
|
} catch (error) {
|
|
312
681
|
return failed(error, errors)
|
|
313
682
|
}
|
|
@@ -368,8 +737,11 @@ export const surfaceCommands = (
|
|
|
368
737
|
)
|
|
369
738
|
}
|
|
370
739
|
|
|
740
|
+
/** The name of the entity a command declares: `message`, `message.hit`. */
|
|
741
|
+
export const answersOf = ({ entity, view }: CommandOutput): string => (view ? `${entity}.${view}` : entity)
|
|
742
|
+
|
|
371
743
|
/** The envelope a command answers with, from the entity it declares (`annotate(…, { output })`). */
|
|
372
|
-
export const outputOf = (
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
)
|
|
744
|
+
export const outputOf = (output: CommandOutput): v.GenericSchema => entityAnswer(answersOf(output))
|
|
745
|
+
|
|
746
|
+
const entityAnswer = (name: string): v.GenericSchema =>
|
|
747
|
+
answerSchema((ENTITIES[name as EntityName] as v.GenericSchema | undefined) ?? v.unknown())
|