@wirecat/mail-cli 0.38.0 → 0.39.0
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 +27 -0
- package/README.md +9 -7
- package/contracts/wirecat.json +63 -2
- package/dist/bin/mail.js +11 -11
- package/dist/bundle/{chunk-HIKPVWCL.js → chunk-BXH2YUBR.js} +32 -5
- package/dist/bundle/mail.js +4 -166
- package/dist/bundle/program-ZSF2VJI6.js +17329 -0
- package/dist/commands/account-remove.js +1 -2
- package/dist/commands/account.js +1 -1
- package/dist/commands/attachments.js +1 -2
- package/dist/commands/context.js +1 -1
- package/dist/commands/doctor.js +1 -1
- package/dist/commands/drafts-send.js +1 -2
- package/dist/commands/drafts.js +1 -2
- package/dist/commands/export.js +1 -2
- package/dist/commands/folders.js +1 -2
- package/dist/commands/import.js +1 -1
- package/dist/commands/messages.js +1 -1
- package/dist/commands/organising.js +1 -2
- package/dist/commands/read.js +2 -4
- package/dist/commands/restore.js +1 -1
- package/dist/commands/rules.js +1 -2
- package/dist/commands/send.js +1 -2
- package/dist/commands/session-start.js +1 -1
- package/dist/commands/session.js +1 -1
- package/dist/commands/stats.js +1 -1
- package/dist/commands/status.js +3 -5
- package/dist/commands/sync.js +1 -1
- package/dist/commands/tags.js +1 -2
- package/dist/config.js +1 -1
- package/dist/identity.js +26 -0
- package/dist/mail/changes.js +3 -2
- package/dist/mail/cleanup.js +3 -2
- package/dist/mail/domain-age.js +1 -1
- package/dist/mail/memo-trash.js +47 -0
- package/dist/mail/organise.js +1 -1
- package/dist/mail/save.js +1 -1
- package/dist/mail/send.js +1 -1
- package/dist/oauth.js +1 -3
- package/dist/profile.js +1 -1
- package/dist/program.js +1 -2
- package/dist/providers.js +4 -4
- package/dist/store.js +1 -1
- package/dist/version.js +1 -1
- package/package.json +5 -5
- package/dist/bin/mail.d.ts +0 -3
- package/dist/bin/mail.d.ts.map +0 -1
- package/dist/bin/mail.js.map +0 -1
- package/dist/bundle/agent-U43CYLAP.js +0 -41
- package/dist/bundle/all-profiles-OCUZMXMI.js +0 -320
- package/dist/bundle/anthropic-CABWJABQ.js +0 -90
- package/dist/bundle/app-server-TTWPIGWG.js +0 -257
- package/dist/bundle/bun-F4M4KCNA.js +0 -169
- package/dist/bundle/bun-sqlite-YKYG25CR.js +0 -75
- package/dist/bundle/chunk-24UGTK32.js +0 -185
- package/dist/bundle/chunk-2HDXD6LM.js +0 -615
- package/dist/bundle/chunk-2SQLHBDP.js +0 -54
- package/dist/bundle/chunk-2YO3PLOE.js +0 -2843
- package/dist/bundle/chunk-3TYER5IK.js +0 -80
- package/dist/bundle/chunk-4FXDUXZP.js +0 -192
- package/dist/bundle/chunk-5ICUC66S.js +0 -76
- package/dist/bundle/chunk-725OPCHI.js +0 -4070
- package/dist/bundle/chunk-77YTUOKN.js +0 -1255
- package/dist/bundle/chunk-7ECP5ZQR.js +0 -2
- package/dist/bundle/chunk-7EJWHADX.js +0 -323
- package/dist/bundle/chunk-7KO5FSAW.js +0 -64
- package/dist/bundle/chunk-A3KNH3Q4.js +0 -353
- package/dist/bundle/chunk-AGO3OVKW.js +0 -40856
- package/dist/bundle/chunk-AQ5RIOUE.js +0 -633
- package/dist/bundle/chunk-BA5B5ZF4.js +0 -12177
- package/dist/bundle/chunk-C4PUDTGD.js +0 -106
- package/dist/bundle/chunk-C7JPYWYQ.js +0 -77
- package/dist/bundle/chunk-CJJFOT7W.js +0 -52
- package/dist/bundle/chunk-CLTFTGBP.js +0 -560
- package/dist/bundle/chunk-D72URWJE.js +0 -532
- package/dist/bundle/chunk-DFDN6AUB.js +0 -21
- package/dist/bundle/chunk-DKGKPJA3.js +0 -3752
- package/dist/bundle/chunk-DNCLQPOM.js +0 -7
- package/dist/bundle/chunk-DPV53EZC.js +0 -206
- package/dist/bundle/chunk-DYCE72XB.js +0 -794
- package/dist/bundle/chunk-EDWY73H7.js +0 -133
- package/dist/bundle/chunk-EJQAP6A6.js +0 -1007
- package/dist/bundle/chunk-ESNZL7SB.js +0 -330
- package/dist/bundle/chunk-FFER7KJI.js +0 -407
- package/dist/bundle/chunk-FTH6WGYO.js +0 -24
- package/dist/bundle/chunk-FWGNDKJK.js +0 -195
- package/dist/bundle/chunk-G46PNDWL.js +0 -58
- package/dist/bundle/chunk-G5HG7ZWQ.js +0 -1169
- package/dist/bundle/chunk-G6NY7LFB.js +0 -230
- package/dist/bundle/chunk-GMWKNWWY.js +0 -388
- package/dist/bundle/chunk-GZ7WBU5Y.js +0 -18
- package/dist/bundle/chunk-HFDDVGDH.js +0 -9512
- package/dist/bundle/chunk-HFRH5YJ6.js +0 -86
- package/dist/bundle/chunk-HI6MTNID.js +0 -338
- package/dist/bundle/chunk-HO4JGD4Q.js +0 -16
- package/dist/bundle/chunk-HTQTIKWP.js +0 -928
- package/dist/bundle/chunk-HUAHLO6N.js +0 -29
- package/dist/bundle/chunk-HYUUAH2N.js +0 -188
- package/dist/bundle/chunk-I4AWLFYH.js +0 -377
- package/dist/bundle/chunk-I4PZOWYG.js +0 -334
- package/dist/bundle/chunk-IDCZ4LWS.js +0 -150
- package/dist/bundle/chunk-ISQ23VKV.js +0 -123
- package/dist/bundle/chunk-KLRCTMES.js +0 -100
- package/dist/bundle/chunk-KP5JDYY6.js +0 -2669
- package/dist/bundle/chunk-KYRYD4CR.js +0 -38
- package/dist/bundle/chunk-LB2CF3GG.js +0 -730
- package/dist/bundle/chunk-LC7ZD2RW.js +0 -92
- package/dist/bundle/chunk-M65NILSA.js +0 -259
- package/dist/bundle/chunk-NQFG7AES.js +0 -364
- package/dist/bundle/chunk-OAO3JKQD.js +0 -463
- package/dist/bundle/chunk-OEEWVKJX.js +0 -53
- package/dist/bundle/chunk-OVHC7OV4.js +0 -218
- package/dist/bundle/chunk-PL5P7UKW.js +0 -25216
- package/dist/bundle/chunk-PT4VLN3K.js +0 -161
- package/dist/bundle/chunk-QETNCUWB.js +0 -1703
- package/dist/bundle/chunk-QK3Z7BCC.js +0 -95
- package/dist/bundle/chunk-QWF3TFW4.js +0 -1342
- package/dist/bundle/chunk-RHEDE7D4.js +0 -80
- package/dist/bundle/chunk-RI5YZ23Y.js +0 -1068
- package/dist/bundle/chunk-ROUZN6UQ.js +0 -1997
- package/dist/bundle/chunk-RQD7CAGF.js +0 -288
- package/dist/bundle/chunk-S6JG4YUH.js +0 -72
- package/dist/bundle/chunk-SBLHQAH3.js +0 -360
- package/dist/bundle/chunk-SXLIADMY.js +0 -52
- package/dist/bundle/chunk-SYCM6SQ5.js +0 -2470
- package/dist/bundle/chunk-T3W4V4A6.js +0 -63
- package/dist/bundle/chunk-TCT5D2X2.js +0 -6848
- package/dist/bundle/chunk-TES7MB6I.js +0 -82
- package/dist/bundle/chunk-TQDSBLQB.js +0 -2
- package/dist/bundle/chunk-TXDR6YSF.js +0 -23
- package/dist/bundle/chunk-TY7NDMFY.js +0 -46
- package/dist/bundle/chunk-UGFMQWAZ.js +0 -1044
- package/dist/bundle/chunk-VA6PHTMV.js +0 -690
- package/dist/bundle/chunk-VK24UQSD.js +0 -142
- package/dist/bundle/chunk-VUHH4MQW.js +0 -73464
- package/dist/bundle/chunk-W3BOR6AT.js +0 -2333
- package/dist/bundle/chunk-WA53OJ7V.js +0 -160
- package/dist/bundle/chunk-XGVMQMTS.js +0 -1197
- package/dist/bundle/chunk-XQUUANA2.js +0 -24600
- package/dist/bundle/chunk-Y5E2WNWB.js +0 -35
- package/dist/bundle/chunk-YP4FYLFI.js +0 -170
- package/dist/bundle/chunk-ZDBWBCEO.js +0 -108
- package/dist/bundle/chunk-ZKVUAH5N.js +0 -274
- package/dist/bundle/chunk-ZVVMGPBJ.js +0 -50
- package/dist/bundle/command-contract-V2WIL6RL.js +0 -40
- package/dist/bundle/command-server-entry-ZC5YF4EC.js +0 -169
- package/dist/bundle/decode-NXAGEUAD.js +0 -296
- package/dist/bundle/dispatch-USKS7J74.js +0 -411
- package/dist/bundle/dist-HFUVURJG.js +0 -7577
- package/dist/bundle/dist-PAKDDIBT.js +0 -191
- package/dist/bundle/dist-XN2CRP3U.js +0 -318
- package/dist/bundle/echarts-QMAA7HH5.js +0 -42501
- package/dist/bundle/embed-3P3LSM2O.js +0 -37
- package/dist/bundle/embedder-2SANUF2X.js +0 -110
- package/dist/bundle/failure-D4FGOIWF.js +0 -24
- package/dist/bundle/first-run-HEZKQLJL.js +0 -28
- package/dist/bundle/first-screen-7TQZ4I6X.js +0 -41
- package/dist/bundle/instructions-4H7UREH2.js +0 -11
- package/dist/bundle/mcp-5HFPWC3W.js +0 -167
- package/dist/bundle/meeting-combined-HF2NL4PU.js +0 -26
- package/dist/bundle/meeting-model-B7RVFB7L.js +0 -24
- package/dist/bundle/meeting-semantic-YQTL7YVQ.js +0 -21
- package/dist/bundle/node-KM3CUABH.js +0 -2340
- package/dist/bundle/node-P3PUHKYH.js +0 -176
- package/dist/bundle/node-TLZSIHIJ.js +0 -21
- package/dist/bundle/node-sqlite-OFHTCHJH.js +0 -73
- package/dist/bundle/oauth-IVB5RP7T.js +0 -19
- package/dist/bundle/open-KDGDLCWV.js +0 -22
- package/dist/bundle/openai-NVUBKA7Z.js +0 -237
- package/dist/bundle/process-AFIXYXWL.js +0 -91
- package/dist/bundle/program-JQ7EFODJ.js +0 -47008
- package/dist/bundle/prompt-QG7FC2SA.js +0 -16
- package/dist/bundle/public-FBD7MQUM.js +0 -204
- package/dist/bundle/recognize-ZBR5KNID.js +0 -25
- package/dist/bundle/remote-QOTHNO2M.js +0 -30
- package/dist/bundle/rerank-JD2NIUW6.js +0 -51
- package/dist/bundle/serve-QZT3FKK7.js +0 -198
- package/dist/bundle/server-M6JJ7IKS.js +0 -219
- package/dist/bundle/server-TAMXMWK6.js +0 -87
- package/dist/bundle/sqlite-runtime-N2PY7C7J.js +0 -19
- package/dist/bundle/state-OGRUMU7P.js +0 -35
- package/dist/bundle/store-7UE63OQR.js +0 -313
- package/dist/bundle/store-DGJKE4ZJ.js +0 -186
- package/dist/bundle/store-maintenance-command-WIDKMZLK.js +0 -74
- package/dist/bundle/surface-LTEEEZU4.js +0 -73
- package/dist/commands/account-remove.d.ts +0 -3
- package/dist/commands/account-remove.d.ts.map +0 -1
- package/dist/commands/account-remove.js.map +0 -1
- package/dist/commands/account.d.ts +0 -3
- package/dist/commands/account.d.ts.map +0 -1
- package/dist/commands/account.js.map +0 -1
- package/dist/commands/attachments.d.ts +0 -3
- package/dist/commands/attachments.d.ts.map +0 -1
- package/dist/commands/attachments.js.map +0 -1
- package/dist/commands/context.d.ts +0 -79
- package/dist/commands/context.d.ts.map +0 -1
- package/dist/commands/context.js.map +0 -1
- package/dist/commands/doctor.d.ts +0 -68
- package/dist/commands/doctor.d.ts.map +0 -1
- package/dist/commands/doctor.js.map +0 -1
- package/dist/commands/drafts-send.d.ts +0 -7
- package/dist/commands/drafts-send.d.ts.map +0 -1
- package/dist/commands/drafts-send.js.map +0 -1
- package/dist/commands/drafts.d.ts +0 -3
- package/dist/commands/drafts.d.ts.map +0 -1
- package/dist/commands/drafts.js.map +0 -1
- package/dist/commands/export.d.ts +0 -3
- package/dist/commands/export.d.ts.map +0 -1
- package/dist/commands/export.js.map +0 -1
- package/dist/commands/folders.d.ts +0 -3
- package/dist/commands/folders.d.ts.map +0 -1
- package/dist/commands/folders.js.map +0 -1
- package/dist/commands/import.d.ts +0 -3
- package/dist/commands/import.d.ts.map +0 -1
- package/dist/commands/import.js.map +0 -1
- package/dist/commands/login.d.ts +0 -5
- package/dist/commands/login.d.ts.map +0 -1
- package/dist/commands/login.js.map +0 -1
- package/dist/commands/mailbox.d.ts +0 -17
- package/dist/commands/mailbox.d.ts.map +0 -1
- package/dist/commands/mailbox.js.map +0 -1
- package/dist/commands/messages.d.ts +0 -4
- package/dist/commands/messages.d.ts.map +0 -1
- package/dist/commands/messages.js.map +0 -1
- package/dist/commands/organising.d.ts +0 -98
- package/dist/commands/organising.d.ts.map +0 -1
- package/dist/commands/organising.js.map +0 -1
- package/dist/commands/read.d.ts +0 -6
- package/dist/commands/read.d.ts.map +0 -1
- package/dist/commands/read.js.map +0 -1
- package/dist/commands/restore.d.ts +0 -3
- package/dist/commands/restore.d.ts.map +0 -1
- package/dist/commands/restore.js.map +0 -1
- package/dist/commands/rules.d.ts +0 -3
- package/dist/commands/rules.d.ts.map +0 -1
- package/dist/commands/rules.js.map +0 -1
- package/dist/commands/send.d.ts +0 -51
- package/dist/commands/send.d.ts.map +0 -1
- package/dist/commands/send.js.map +0 -1
- package/dist/commands/server-search.d.ts +0 -8
- package/dist/commands/server-search.d.ts.map +0 -1
- package/dist/commands/server-search.js.map +0 -1
- package/dist/commands/session-start.d.ts +0 -3
- package/dist/commands/session-start.d.ts.map +0 -1
- package/dist/commands/session-start.js.map +0 -1
- package/dist/commands/session.d.ts +0 -3
- package/dist/commands/session.d.ts.map +0 -1
- package/dist/commands/session.js.map +0 -1
- package/dist/commands/stats.d.ts +0 -3
- package/dist/commands/stats.d.ts.map +0 -1
- package/dist/commands/stats.js.map +0 -1
- package/dist/commands/status.d.ts +0 -3
- package/dist/commands/status.d.ts.map +0 -1
- package/dist/commands/status.js.map +0 -1
- package/dist/commands/sync.d.ts +0 -11
- package/dist/commands/sync.d.ts.map +0 -1
- package/dist/commands/sync.js.map +0 -1
- package/dist/commands/tags.d.ts +0 -3
- package/dist/commands/tags.d.ts.map +0 -1
- package/dist/commands/tags.js.map +0 -1
- package/dist/commands/words.d.ts +0 -8
- package/dist/commands/words.d.ts.map +0 -1
- package/dist/commands/words.js.map +0 -1
- package/dist/config.d.ts +0 -239
- package/dist/config.d.ts.map +0 -1
- package/dist/config.js.map +0 -1
- package/dist/discovery.d.ts +0 -31
- package/dist/discovery.d.ts.map +0 -1
- package/dist/discovery.js.map +0 -1
- package/dist/export/format.d.ts +0 -19
- package/dist/export/format.d.ts.map +0 -1
- package/dist/export/format.js.map +0 -1
- package/dist/export/journal.d.ts +0 -34
- package/dist/export/journal.d.ts.map +0 -1
- package/dist/export/journal.js.map +0 -1
- package/dist/export/write.d.ts +0 -14
- package/dist/export/write.d.ts.map +0 -1
- package/dist/export/write.js.map +0 -1
- package/dist/identity.d.ts +0 -7
- package/dist/identity.d.ts.map +0 -1
- package/dist/identity.js.map +0 -1
- package/dist/mail/backend.d.ts +0 -138
- package/dist/mail/backend.d.ts.map +0 -1
- package/dist/mail/backend.js.map +0 -1
- package/dist/mail/changes.d.ts +0 -99
- package/dist/mail/changes.d.ts.map +0 -1
- package/dist/mail/changes.js.map +0 -1
- package/dist/mail/cleanup.d.ts +0 -41
- package/dist/mail/cleanup.d.ts.map +0 -1
- package/dist/mail/cleanup.js.map +0 -1
- package/dist/mail/compose.d.ts +0 -75
- package/dist/mail/compose.d.ts.map +0 -1
- package/dist/mail/compose.js.map +0 -1
- package/dist/mail/domain-age.d.ts +0 -29
- package/dist/mail/domain-age.d.ts.map +0 -1
- package/dist/mail/domain-age.js.map +0 -1
- package/dist/mail/drafts.d.ts +0 -54
- package/dist/mail/drafts.d.ts.map +0 -1
- package/dist/mail/drafts.js.map +0 -1
- package/dist/mail/imap/account.d.ts +0 -5
- package/dist/mail/imap/account.d.ts.map +0 -1
- package/dist/mail/imap/account.js.map +0 -1
- package/dist/mail/imap/connection.d.ts +0 -72
- package/dist/mail/imap/connection.d.ts.map +0 -1
- package/dist/mail/imap/connection.js.map +0 -1
- package/dist/mail/imap/errors.d.ts +0 -11
- package/dist/mail/imap/errors.d.ts.map +0 -1
- package/dist/mail/imap/errors.js.map +0 -1
- package/dist/mail/imap/index.d.ts +0 -7
- package/dist/mail/imap/index.d.ts.map +0 -1
- package/dist/mail/imap/index.js.map +0 -1
- package/dist/mail/imap/messages.d.ts +0 -17
- package/dist/mail/imap/messages.d.ts.map +0 -1
- package/dist/mail/imap/messages.js.map +0 -1
- package/dist/mail/imap/read.d.ts +0 -7
- package/dist/mail/imap/read.d.ts.map +0 -1
- package/dist/mail/imap/read.js.map +0 -1
- package/dist/mail/imap/search.d.ts +0 -19
- package/dist/mail/imap/search.d.ts.map +0 -1
- package/dist/mail/imap/search.js.map +0 -1
- package/dist/mail/imap/write.d.ts +0 -5
- package/dist/mail/imap/write.d.ts.map +0 -1
- package/dist/mail/imap/write.js.map +0 -1
- package/dist/mail/locate.d.ts +0 -32
- package/dist/mail/locate.d.ts.map +0 -1
- package/dist/mail/locate.js.map +0 -1
- package/dist/mail/mbox.d.ts +0 -9
- package/dist/mail/mbox.d.ts.map +0 -1
- package/dist/mail/mbox.js.map +0 -1
- package/dist/mail/organise.d.ts +0 -101
- package/dist/mail/organise.d.ts.map +0 -1
- package/dist/mail/organise.js.map +0 -1
- package/dist/mail/restore.d.ts +0 -22
- package/dist/mail/restore.d.ts.map +0 -1
- package/dist/mail/restore.js.map +0 -1
- package/dist/mail/rethread.d.ts +0 -14
- package/dist/mail/rethread.d.ts.map +0 -1
- package/dist/mail/rethread.js.map +0 -1
- package/dist/mail/rules/apply.d.ts +0 -48
- package/dist/mail/rules/apply.d.ts.map +0 -1
- package/dist/mail/rules/apply.js.map +0 -1
- package/dist/mail/rules/file.d.ts +0 -9
- package/dist/mail/rules/file.d.ts.map +0 -1
- package/dist/mail/rules/file.js.map +0 -1
- package/dist/mail/rules/filters.d.ts +0 -11
- package/dist/mail/rules/filters.d.ts.map +0 -1
- package/dist/mail/rules/filters.js.map +0 -1
- package/dist/mail/rules/folders.d.ts +0 -11
- package/dist/mail/rules/folders.d.ts.map +0 -1
- package/dist/mail/rules/folders.js.map +0 -1
- package/dist/mail/rules/query.d.ts +0 -16
- package/dist/mail/rules/query.d.ts.map +0 -1
- package/dist/mail/rules/query.js.map +0 -1
- package/dist/mail/rules/store.d.ts +0 -9
- package/dist/mail/rules/store.d.ts.map +0 -1
- package/dist/mail/rules/store.js.map +0 -1
- package/dist/mail/save.d.ts +0 -9
- package/dist/mail/save.d.ts.map +0 -1
- package/dist/mail/save.js.map +0 -1
- package/dist/mail/send-as.d.ts +0 -21
- package/dist/mail/send-as.d.ts.map +0 -1
- package/dist/mail/send-as.js.map +0 -1
- package/dist/mail/send.d.ts +0 -76
- package/dist/mail/send.d.ts.map +0 -1
- package/dist/mail/send.js.map +0 -1
- package/dist/mail/smtp.d.ts +0 -4
- package/dist/mail/smtp.d.ts.map +0 -1
- package/dist/mail/smtp.js.map +0 -1
- package/dist/oauth.d.ts +0 -75
- package/dist/oauth.d.ts.map +0 -1
- package/dist/oauth.js.map +0 -1
- package/dist/profile.d.ts +0 -20
- package/dist/profile.d.ts.map +0 -1
- package/dist/profile.js.map +0 -1
- package/dist/program.d.ts +0 -6
- package/dist/program.d.ts.map +0 -1
- package/dist/program.js.map +0 -1
- package/dist/providers.d.ts +0 -255
- package/dist/providers.d.ts.map +0 -1
- package/dist/providers.js.map +0 -1
- package/dist/reasons.d.ts +0 -9
- package/dist/reasons.d.ts.map +0 -1
- package/dist/reasons.js.map +0 -1
- package/dist/secret.d.ts +0 -31
- package/dist/secret.d.ts.map +0 -1
- package/dist/secret.js.map +0 -1
- package/dist/store.d.ts +0 -12
- package/dist/store.d.ts.map +0 -1
- package/dist/store.js.map +0 -1
- package/dist/version.d.ts +0 -2
- package/dist/version.d.ts.map +0 -1
- package/dist/version.js.map +0 -1
- package/dist/wcat.d.ts +0 -3
- package/dist/wcat.d.ts.map +0 -1
- package/dist/wcat.js.map +0 -1
|
@@ -1,560 +0,0 @@
|
|
|
1
|
-
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
-
const require = __bundleRequire(import.meta.url);
|
|
3
|
-
import {
|
|
4
|
-
UNTRUSTED,
|
|
5
|
-
UNTRUSTED_NEUTRAL,
|
|
6
|
-
agentArguments,
|
|
7
|
-
agentJson
|
|
8
|
-
} from "./chunk-4FXDUXZP.js";
|
|
9
|
-
import {
|
|
10
|
-
failureContext
|
|
11
|
-
} from "./chunk-UGFMQWAZ.js";
|
|
12
|
-
import {
|
|
13
|
-
onlineDeps,
|
|
14
|
-
refuseLacking,
|
|
15
|
-
servicesFor,
|
|
16
|
-
storeModeDeps
|
|
17
|
-
} from "./chunk-AGO3OVKW.js";
|
|
18
|
-
import {
|
|
19
|
-
callerOf
|
|
20
|
-
} from "./chunk-ZDBWBCEO.js";
|
|
21
|
-
import {
|
|
22
|
-
DEFAULT_OUTPUT_BYTES,
|
|
23
|
-
ENTITIES,
|
|
24
|
-
LOCAL_WRITE,
|
|
25
|
-
REMOTE_WRITE,
|
|
26
|
-
answerSchema,
|
|
27
|
-
judgedAnswer,
|
|
28
|
-
judgedEffects,
|
|
29
|
-
listOf,
|
|
30
|
-
refuseStoreChange,
|
|
31
|
-
sealed,
|
|
32
|
-
startRecording
|
|
33
|
-
} from "./chunk-BA5B5ZF4.js";
|
|
34
|
-
import {
|
|
35
|
-
fetchesAt,
|
|
36
|
-
keyForCommand,
|
|
37
|
-
levelFor,
|
|
38
|
-
readKeysForCommand
|
|
39
|
-
} from "./chunk-2HDXD6LM.js";
|
|
40
|
-
import {
|
|
41
|
-
currentCaller,
|
|
42
|
-
keepsSuccess,
|
|
43
|
-
runContextOf,
|
|
44
|
-
withCaller
|
|
45
|
-
} from "./chunk-NQFG7AES.js";
|
|
46
|
-
import {
|
|
47
|
-
MAX_BUFFERED_INPUT
|
|
48
|
-
} from "./chunk-TES7MB6I.js";
|
|
49
|
-
import {
|
|
50
|
-
inRun,
|
|
51
|
-
newRunId
|
|
52
|
-
} from "./chunk-G5HG7ZWQ.js";
|
|
53
|
-
import {
|
|
54
|
-
storeBusy,
|
|
55
|
-
storeDamaged
|
|
56
|
-
} from "./chunk-3TYER5IK.js";
|
|
57
|
-
import {
|
|
58
|
-
traceIdOf
|
|
59
|
-
} from "./chunk-2YO3PLOE.js";
|
|
60
|
-
import {
|
|
61
|
-
array,
|
|
62
|
-
boolean,
|
|
63
|
-
description,
|
|
64
|
-
errorObjectOf,
|
|
65
|
-
integer,
|
|
66
|
-
itemEnvelopeSchema,
|
|
67
|
-
listEnvelopeSchema,
|
|
68
|
-
looseObject,
|
|
69
|
-
maxLength,
|
|
70
|
-
maxValue,
|
|
71
|
-
mcpErrorResult,
|
|
72
|
-
minLength,
|
|
73
|
-
minValue,
|
|
74
|
-
number,
|
|
75
|
-
optional,
|
|
76
|
-
pipe,
|
|
77
|
-
record,
|
|
78
|
-
regex,
|
|
79
|
-
safeParse,
|
|
80
|
-
strictObject,
|
|
81
|
-
string,
|
|
82
|
-
summarize,
|
|
83
|
-
toJsonSchema,
|
|
84
|
-
toStandardJsonSchema,
|
|
85
|
-
unknown
|
|
86
|
-
} from "./chunk-KP5JDYY6.js";
|
|
87
|
-
import {
|
|
88
|
-
CliError,
|
|
89
|
-
errorCodes
|
|
90
|
-
} from "./chunk-S6JG4YUH.js";
|
|
91
|
-
import {
|
|
92
|
-
__name
|
|
93
|
-
} from "./chunk-ZVVMGPBJ.js";
|
|
94
|
-
|
|
95
|
-
// node_modules/.pnpm/@wirecat+cli-core@2.0.0_@wirecat+cli-base@1.0.0_commander@15.0.0_esbuild@0.28.2_typescr_a82f624c57005d53c3f072e45c3a3a86/node_modules/@wirecat/cli-core/dist/mcp/surface.js
|
|
96
|
-
import { randomUUID } from "node:crypto";
|
|
97
|
-
|
|
98
|
-
// node_modules/.pnpm/@wirecat+cli-core@2.0.0_@wirecat+cli-base@1.0.0_commander@15.0.0_esbuild@0.28.2_typescr_a82f624c57005d53c3f072e45c3a3a86/node_modules/@wirecat/cli-core/dist/mcp/tool.js
|
|
99
|
-
var limit = optional(pipe(number(), integer(), minValue(1), maxValue(100), description("how many")));
|
|
100
|
-
var page = optional(pipe(number(), integer(), minValue(1), description("which page, from 1")));
|
|
101
|
-
var message = pipe(
|
|
102
|
-
string(),
|
|
103
|
-
maxLength(256),
|
|
104
|
-
// biome-ignore lint/suspicious/noControlCharactersInRegex: refusing them is the point
|
|
105
|
-
regex(/^[^\s\x00-\x1F\x7F-\x9F]+$/, "a message id has no spaces or control characters"),
|
|
106
|
-
description("message id")
|
|
107
|
-
);
|
|
108
|
-
var READ = { readOnlyHint: true, destructiveHint: false, openWorldHint: true };
|
|
109
|
-
var WRITE = {
|
|
110
|
-
readOnlyHint: false,
|
|
111
|
-
destructiveHint: true,
|
|
112
|
-
idempotentHint: false,
|
|
113
|
-
openWorldHint: true
|
|
114
|
-
};
|
|
115
|
-
var tool = /* @__PURE__ */ __name((definition) => definition, "tool");
|
|
116
|
-
var chatOf = /* @__PURE__ */ __name((messenger) => pipe(string(), minLength(1), description(messenger.chatArgument)), "chatOf");
|
|
117
|
-
var tierOf = /* @__PURE__ */ __name((key, definition, messenger) => {
|
|
118
|
-
if (definition.annotations.readOnlyHint === true)
|
|
119
|
-
return "read";
|
|
120
|
-
if (/^admin|_admin/.test(key))
|
|
121
|
-
return "admin";
|
|
122
|
-
if (/delete|ban|kick|remove|purge|block/.test(key))
|
|
123
|
-
return "destructive";
|
|
124
|
-
if (/draft/.test(key))
|
|
125
|
-
return "draft";
|
|
126
|
-
if (key === "messages_pin" && messenger?.quietPins === false)
|
|
127
|
-
return "write-public";
|
|
128
|
-
if (/mark_read|mark_unread|read_mark|archive|mute|pin|tag|note|label|folder|alias|save|_(un)?star$/.test(key))
|
|
129
|
-
return "write-private";
|
|
130
|
-
return "write-public";
|
|
131
|
-
}, "tierOf");
|
|
132
|
-
var effectsOf = /* @__PURE__ */ __name((definition) => {
|
|
133
|
-
if (definition.effects)
|
|
134
|
-
return definition.effects;
|
|
135
|
-
const { readOnlyHint, openWorldHint } = definition.annotations;
|
|
136
|
-
if (readOnlyHint === true)
|
|
137
|
-
return { remote: openWorldHint === false ? "none" : "read", local: "read" };
|
|
138
|
-
return openWorldHint === false ? LOCAL_WRITE : REMOTE_WRITE;
|
|
139
|
-
}, "effectsOf");
|
|
140
|
-
var outcomeOf = /* @__PURE__ */ __name((result) => {
|
|
141
|
-
if (!result.isError)
|
|
142
|
-
return { status: "ok" };
|
|
143
|
-
const code = result.structuredContent?.error?.code;
|
|
144
|
-
const error = typeof code === "string" ? code : "generic_failure";
|
|
145
|
-
return { status: error === "permission_error" ? "refused" : "failed", error };
|
|
146
|
-
}, "outcomeOf");
|
|
147
|
-
var commandOf = /* @__PURE__ */ __name((name, definition) => definition.command ?? name.replaceAll("_", " "), "commandOf");
|
|
148
|
-
var toolKey = /* @__PURE__ */ __name((name, definition) => definition.key !== void 0 ? definition.key : keyForCommand(commandOf(name, definition).split(" ")), "toolKey");
|
|
149
|
-
var inputOf = /* @__PURE__ */ __name((definition, syncAllowed) => strictObject(syncAllowed || !("sync_first" in definition.input.entries) ? definition.input.entries : Object.fromEntries(Object.entries(definition.input.entries).filter(([name]) => !["sync_first", "sync_time", "max_chats", "max_messages"].includes(name)))), "inputOf");
|
|
150
|
-
var syncAllowedFor = /* @__PURE__ */ __name((key, defaults) => {
|
|
151
|
-
const permissions = defaults.settings.permissions ?? {};
|
|
152
|
-
const shared = defaults.syncAllowed ?? fetchesAt(levelFor(permissions, "messages.sync-first").level);
|
|
153
|
-
return shared && (!key.startsWith("stats_") || fetchesAt(levelFor(permissions, `${key.replaceAll("_", ".")}.sync-first`).level));
|
|
154
|
-
}, "syncAllowedFor");
|
|
155
|
-
var entryRunner = /* @__PURE__ */ __name((registration) => {
|
|
156
|
-
const run = callRunner(registration);
|
|
157
|
-
const { log } = registration;
|
|
158
|
-
return async (key, definition, args, ctx) => {
|
|
159
|
-
const startedAt = Date.now();
|
|
160
|
-
const command = `mcp ${commandOf(key, definition)}`;
|
|
161
|
-
const traceId = traceIdOf(ctx?.mcpReq?._meta?.traceparent);
|
|
162
|
-
const app = registration.messenger?.app;
|
|
163
|
-
const caller = registration.callers ? callerOf(ctx, key, registration.callers) : currentCaller();
|
|
164
|
-
const env = registration.defaults.env ?? process.env;
|
|
165
|
-
const settings = registration.defaults.settings;
|
|
166
|
-
const recording = key !== "runs_search" && settings.keepFailedRuns !== false && app?.appName ? startRecording({
|
|
167
|
-
app,
|
|
168
|
-
command,
|
|
169
|
-
...settings.profile === void 0 ? {} : { profile: settings.profile },
|
|
170
|
-
env,
|
|
171
|
-
record: keepsSuccess({ record: settings.record ?? true, fromFlag: false, env, caller }),
|
|
172
|
-
keepFailed: true,
|
|
173
|
-
trace: false,
|
|
174
|
-
format: "json",
|
|
175
|
-
context: runContextOf({ bin: app.command, command, env, caller }),
|
|
176
|
-
...settings.keepRunsForDays === void 0 ? {} : { keepDays: settings.keepRunsForDays },
|
|
177
|
-
...settings.keepSuccessfulRunsForDays === void 0 ? {} : { keepSuccessDays: settings.keepSuccessfulRunsForDays },
|
|
178
|
-
...settings.runsSizeLimitMb === void 0 ? {} : { maxBytes: settings.runsSizeLimitMb * 1024 * 1024 },
|
|
179
|
-
...traceId === void 0 ? {} : { traceId }
|
|
180
|
-
}) : void 0;
|
|
181
|
-
const profile = registration.defaults.settings.profile;
|
|
182
|
-
const scope = {
|
|
183
|
-
runId: recording?.runId ?? newRunId(new Date(startedAt), command),
|
|
184
|
-
command,
|
|
185
|
-
startedAt,
|
|
186
|
-
...profile === void 0 ? {} : { profile },
|
|
187
|
-
...traceId === void 0 ? {} : { traceId },
|
|
188
|
-
...recording ? { events: recording.events } : {}
|
|
189
|
-
};
|
|
190
|
-
const work = /* @__PURE__ */ __name(() => inRun(scope, () => {
|
|
191
|
-
const input = inputOf(definition, syncAllowedFor(key, registration.defaults));
|
|
192
|
-
const parsed = safeParse(input, args);
|
|
193
|
-
return parsed.success ? run(key, definition, parsed.output, ctx) : failed(new CliError("validation_error", `${commandOf(key, definition)}: ${summarize(parsed.issues)}`, {
|
|
194
|
-
arguments: toJsonSchema(input)
|
|
195
|
-
}), app?.errors);
|
|
196
|
-
}), "work");
|
|
197
|
-
const result = await (caller ? withCaller(caller, work) : work());
|
|
198
|
-
if (recording) {
|
|
199
|
-
if (result.isError) {
|
|
200
|
-
const error = result.structuredContent?.error;
|
|
201
|
-
const code = error?.code && errorCodes.includes(error.code) ? error.code : void 0;
|
|
202
|
-
await recording.fail(code ? new CliError(code, "MCP operation failed") : new Error("MCP operation failed")).catch(() => void 0);
|
|
203
|
-
} else
|
|
204
|
-
await recording.succeed(result.structuredContent).catch(() => void 0);
|
|
205
|
-
}
|
|
206
|
-
await log?.({
|
|
207
|
-
tool: key,
|
|
208
|
-
tier: tierOf(key, definition, registration.messenger),
|
|
209
|
-
...outcomeOf(result),
|
|
210
|
-
startedAt,
|
|
211
|
-
finishedAt: Date.now()
|
|
212
|
-
}, caller)?.catch(() => void 0);
|
|
213
|
-
return result;
|
|
214
|
-
};
|
|
215
|
-
}, "entryRunner");
|
|
216
|
-
var callRunner = /* @__PURE__ */ __name(({ messenger, session, withStore, withServices, defaults, around, targets }) => {
|
|
217
|
-
const where = {
|
|
218
|
-
profile: defaults.settings.profile,
|
|
219
|
-
env: defaults.env,
|
|
220
|
-
pictures: defaults.settings.pictureSearch,
|
|
221
|
-
reranker: defaults.settings.searchReranker
|
|
222
|
-
};
|
|
223
|
-
return async (key, definition, args, ctx) => {
|
|
224
|
-
const path = commandOf(key, definition).split(" ");
|
|
225
|
-
const run = `mcp ${path.join(" ")}`;
|
|
226
|
-
try {
|
|
227
|
-
const execute = /* @__PURE__ */ __name(async () => {
|
|
228
|
-
const syncAllowed = syncAllowedFor(key, defaults);
|
|
229
|
-
if (Buffer.byteLength(JSON.stringify(args)) > MAX_BUFFERED_INPUT)
|
|
230
|
-
throw new CliError("validation_error", "tool arguments exceed the buffered input limit", {
|
|
231
|
-
reason: "input.too-large",
|
|
232
|
-
max_bytes: MAX_BUFFERED_INPUT,
|
|
233
|
-
retryable: false
|
|
234
|
-
});
|
|
235
|
-
definition.check?.(args);
|
|
236
|
-
if (definition.changesStore)
|
|
237
|
-
refuseStoreChange(messenger.app, defaults.env);
|
|
238
|
-
refuseLacking(messenger, path);
|
|
239
|
-
for (const permission of readKeysForCommand(path)) {
|
|
240
|
-
if (levelFor(defaults.settings.permissions ?? {}, permission).level === "deny")
|
|
241
|
-
throw new CliError("permission_error", `profile denies ${permission}`, { permission });
|
|
242
|
-
}
|
|
243
|
-
if (args.sync_first && !syncAllowed)
|
|
244
|
-
throw new CliError("permission_error", "messages.sync-first is not allowed by this profile");
|
|
245
|
-
if (definition.custom) {
|
|
246
|
-
const result2 = await definition.custom(args, { ...defaults, signal: ctx.mcpReq.signal }, ctx);
|
|
247
|
-
return answered(result2, definition.outputLimit?.(args, defaults), targets);
|
|
248
|
-
}
|
|
249
|
-
if (definition.local)
|
|
250
|
-
return answered(await definition.local(args, defaults), definition.outputLimit?.(args, defaults), targets);
|
|
251
|
-
const { online, stored: local, served } = definition;
|
|
252
|
-
const stored = local && (!definition.storedWhen || definition.storedWhen(args)) ? local : void 0;
|
|
253
|
-
const result = stored ? await withStore((store, account) => stored(store, account, args, { ...defaults, signal: ctx.mcpReq.signal }, (work) => session.use(run, work)), {
|
|
254
|
-
name: run
|
|
255
|
-
}) : served && withServices ? await withServices((services, connect) => served(services, args, defaults, connect), { name: run }) : served && messenger.history === "store" ? await withStore((store, account) => served(servicesFor({
|
|
256
|
-
...storeModeDeps(messenger, store, account, defaults.guard),
|
|
257
|
-
...where,
|
|
258
|
-
embedders: defaults.embedders
|
|
259
|
-
}), args, defaults, (work) => session.use(run, async (adapter, release) => {
|
|
260
|
-
try {
|
|
261
|
-
return await work(adapter);
|
|
262
|
-
} finally {
|
|
263
|
-
await release();
|
|
264
|
-
}
|
|
265
|
-
})), { name: run }) : served ? await session.use(run, (adapter, release) => served(servicesFor(onlineDeps(messenger, adapter, defaults.guard, where)), args, defaults, (work) => (async () => {
|
|
266
|
-
try {
|
|
267
|
-
return await work(adapter);
|
|
268
|
-
} finally {
|
|
269
|
-
await release();
|
|
270
|
-
}
|
|
271
|
-
})())) : await session.use(run, (adapter, release) => online(adapter, args, { ...defaults, release }));
|
|
272
|
-
return answered(result, definition.outputLimit?.(args, defaults), targets);
|
|
273
|
-
}, "execute");
|
|
274
|
-
return around ? await around(key, definition, execute) : await execute();
|
|
275
|
-
} catch (error) {
|
|
276
|
-
return failed(error, messenger?.app?.errors, effectsOf(definition));
|
|
277
|
-
}
|
|
278
|
-
};
|
|
279
|
-
}, "callRunner");
|
|
280
|
-
var outputSchemaOf = /* @__PURE__ */ __name((definition) => {
|
|
281
|
-
if (!definition.output)
|
|
282
|
-
return looseObject({});
|
|
283
|
-
const entity = ENTITIES[definition.output.entity];
|
|
284
|
-
return definition.output.list ? listEnvelopeSchema(entity) : itemEnvelopeSchema(entity);
|
|
285
|
-
}, "outputSchemaOf");
|
|
286
|
-
var Picture = class {
|
|
287
|
-
static {
|
|
288
|
-
__name(this, "Picture");
|
|
289
|
-
}
|
|
290
|
-
bytes;
|
|
291
|
-
mimeType;
|
|
292
|
-
about;
|
|
293
|
-
constructor(bytes, mimeType, about) {
|
|
294
|
-
this.bytes = bytes;
|
|
295
|
-
this.mimeType = mimeType;
|
|
296
|
-
this.about = about;
|
|
297
|
-
}
|
|
298
|
-
};
|
|
299
|
-
var BinaryResource = class {
|
|
300
|
-
static {
|
|
301
|
-
__name(this, "BinaryResource");
|
|
302
|
-
}
|
|
303
|
-
base64;
|
|
304
|
-
mimeType;
|
|
305
|
-
uri;
|
|
306
|
-
about;
|
|
307
|
-
constructor(base64, mimeType, uri, about) {
|
|
308
|
-
this.base64 = base64;
|
|
309
|
-
this.mimeType = mimeType;
|
|
310
|
-
this.uri = uri;
|
|
311
|
-
this.about = about;
|
|
312
|
-
}
|
|
313
|
-
};
|
|
314
|
-
var answered = /* @__PURE__ */ __name((answer, maxBytes = DEFAULT_OUTPUT_BYTES, targets) => {
|
|
315
|
-
const bounded = /* @__PURE__ */ __name((result) => {
|
|
316
|
-
if (maxBytes !== 0 && Buffer.byteLength(JSON.stringify(result.content)) > maxBytes)
|
|
317
|
-
throw new CliError("invalid_response", "tool output exceeds its byte limit \u2014 reduce limit or use a narrower request", { reason: "output.too-large", max_bytes: maxBytes, retryable: false });
|
|
318
|
-
return result;
|
|
319
|
-
}, "bounded");
|
|
320
|
-
if (answer === null || Array.isArray(answer) || typeof answer !== "object")
|
|
321
|
-
throw new CliError("invalid_response", "tool result must be an object", { retryable: false });
|
|
322
|
-
const objectBody = /* @__PURE__ */ __name((value) => {
|
|
323
|
-
const serialized = JSON.parse(agentJson(value));
|
|
324
|
-
if (serialized === null || Array.isArray(serialized) || typeof serialized !== "object")
|
|
325
|
-
throw new CliError("invalid_response", "serialized tool result must be an object", { retryable: false });
|
|
326
|
-
return serialized;
|
|
327
|
-
}, "objectBody");
|
|
328
|
-
if (answer instanceof BinaryResource) {
|
|
329
|
-
const about = sealed(answer.about);
|
|
330
|
-
return bounded({
|
|
331
|
-
structuredContent: objectBody(about),
|
|
332
|
-
content: [
|
|
333
|
-
{ type: "resource", resource: { uri: answer.uri, mimeType: answer.mimeType, blob: answer.base64 } },
|
|
334
|
-
{ type: "text", text: agentJson(about) }
|
|
335
|
-
]
|
|
336
|
-
});
|
|
337
|
-
}
|
|
338
|
-
if (answer instanceof Picture) {
|
|
339
|
-
const about = sealed(answer.about);
|
|
340
|
-
return bounded({
|
|
341
|
-
structuredContent: objectBody(about),
|
|
342
|
-
content: [
|
|
343
|
-
{ type: "image", data: Buffer.from(answer.bytes).toString("base64"), mimeType: answer.mimeType },
|
|
344
|
-
{ type: "text", text: agentJson(about) }
|
|
345
|
-
]
|
|
346
|
-
});
|
|
347
|
-
}
|
|
348
|
-
const body = objectBody(sealed(targets ? judgedAnswer(answer, targets) : answer));
|
|
349
|
-
return bounded({ content: [{ type: "text", text: JSON.stringify(body) }], structuredContent: body });
|
|
350
|
-
}, "answered");
|
|
351
|
-
var failed = /* @__PURE__ */ __name((error, errors, effects) => {
|
|
352
|
-
const judged = judgedEffects(effects);
|
|
353
|
-
const context = { ...failureContext(errors), ...judged ? { effects: judged } : {} };
|
|
354
|
-
return mcpErrorResult(JSON.parse(agentJson(errorObjectOf(storeBusy(storeDamaged(error)), context))));
|
|
355
|
-
}, "failed");
|
|
356
|
-
|
|
357
|
-
// node_modules/.pnpm/@wirecat+cli-core@2.0.0_@wirecat+cli-base@1.0.0_commander@15.0.0_esbuild@0.28.2_typescr_a82f624c57005d53c3f072e45c3a3a86/node_modules/@wirecat/cli-core/dist/mcp/surface.js
|
|
358
|
-
var MATCHES = 8;
|
|
359
|
-
var ANSWER = answerSchema();
|
|
360
|
-
var agentAnswer = /* @__PURE__ */ __name((prefix, writes) => {
|
|
361
|
-
const meta = pipe(looseObject({}), description(`run facts; ${prefix}_tools_search shows the full answer`));
|
|
362
|
-
const next = optional(pipe(array(looseObject({})), description("steps to run next: command and args")));
|
|
363
|
-
return looseObject(writes ? { item: optional(unknown()), next, meta } : {
|
|
364
|
-
items: optional(array(unknown())),
|
|
365
|
-
item: optional(unknown()),
|
|
366
|
-
page: optional(looseObject({ has_more: boolean() })),
|
|
367
|
-
next,
|
|
368
|
-
missing: optional(array(looseObject({ field: string(), why: string() }))),
|
|
369
|
-
meta
|
|
370
|
-
});
|
|
371
|
-
}, "agentAnswer");
|
|
372
|
-
var listedAs = /* @__PURE__ */ __name((prefix, writes) => {
|
|
373
|
-
const checked = toStandardJsonSchema(ANSWER);
|
|
374
|
-
const shown = toStandardJsonSchema(agentAnswer(prefix, writes))["~standard"].jsonSchema;
|
|
375
|
-
return { "~standard": { ...checked["~standard"], jsonSchema: shown } };
|
|
376
|
-
}, "listedAs");
|
|
377
|
-
var normal = /* @__PURE__ */ __name((command) => command.trim().toLowerCase().split(/[\s_-]+/).join(" "), "normal");
|
|
378
|
-
var STOP_WORDS = new Set("a an the to of in on at by for from with into out about and or but is are be been was were it its this that these those which who whom whose what when where how do does did can could should would will my our your their his her them they we you i one some any all each every another other".split(" "));
|
|
379
|
-
var wordsOf = /* @__PURE__ */ __name((text) => text.toLowerCase().split(/[^\p{L}\p{N}]+/u).filter(Boolean), "wordsOf");
|
|
380
|
-
var stem = /* @__PURE__ */ __name((word) => {
|
|
381
|
-
const bare = word.replace(/'s$/u, "");
|
|
382
|
-
if (bare.length > 4 && bare.endsWith("ies"))
|
|
383
|
-
return `${bare.slice(0, -3)}y`;
|
|
384
|
-
for (const ending of ["ing", "ed", "es", "s"])
|
|
385
|
-
if (bare.length - ending.length >= 3 && bare.endsWith(ending))
|
|
386
|
-
return bare.slice(0, -ending.length);
|
|
387
|
-
return bare;
|
|
388
|
-
}, "stem");
|
|
389
|
-
var sameWord = /* @__PURE__ */ __name((asked, known) => {
|
|
390
|
-
if (asked === known)
|
|
391
|
-
return true;
|
|
392
|
-
const [short, long] = asked.length <= known.length ? [asked, known] : [known, asked];
|
|
393
|
-
return short.length >= 3 && long.startsWith(short);
|
|
394
|
-
}, "sameWord");
|
|
395
|
-
var fieldsOf = /* @__PURE__ */ __name((command, one) => [
|
|
396
|
-
[4, [...wordsOf(command), ...(one.aliases ?? []).flatMap(wordsOf)]],
|
|
397
|
-
[2, wordsOf(one.title)],
|
|
398
|
-
[1, [...wordsOf(one.description), ...(one.keywords ?? []).flatMap(wordsOf), ...Object.keys(one.input.entries)]]
|
|
399
|
-
].map(([weight, words]) => [weight, [...new Set(words.map(stem))]]), "fieldsOf");
|
|
400
|
-
var search = /* @__PURE__ */ __name((commands, query) => {
|
|
401
|
-
const named = normal(query);
|
|
402
|
-
const all = Object.entries(commands);
|
|
403
|
-
if (!named)
|
|
404
|
-
return all.map((entry) => entry).sort((a, b) => a[0].localeCompare(b[0]));
|
|
405
|
-
const words = [
|
|
406
|
-
...new Set(wordsOf(query).filter((word) => word.length > 1 && !STOP_WORDS.has(word)).map(stem))
|
|
407
|
-
];
|
|
408
|
-
return all.map((entry) => {
|
|
409
|
-
const fields = fieldsOf(entry[0], entry[1]);
|
|
410
|
-
const weights = words.map((word) => fields.reduce((best, [weight, known]) => known.some((one) => sameWord(word, one)) ? Math.max(best, weight) : best, 0));
|
|
411
|
-
const matched = weights.filter((weight) => weight > 0).length;
|
|
412
|
-
const exact = normal(entry[0]) === named || (entry[1].aliases ?? []).some((alias) => normal(alias) === named);
|
|
413
|
-
return { entry, matched, rank: (exact ? 1e3 : 0) + matched * 10 + weights.reduce((a, b) => a + b, 0) };
|
|
414
|
-
}).filter(({ matched, rank }) => matched > 0 || rank >= 1e3).sort((a, b) => b.rank - a.rank || wordsOf(a.entry[0]).length - wordsOf(b.entry[0]).length || a.entry[0].localeCompare(b.entry[0])).map(({ entry }) => entry);
|
|
415
|
-
}, "search");
|
|
416
|
-
var nearest = /* @__PURE__ */ __name((commands, asked) => {
|
|
417
|
-
const words = normal(asked).split(" ");
|
|
418
|
-
return Object.keys(commands).map((one) => ({ one, shared: words.filter((word) => normal(one).split(" ").includes(word)).length })).filter(({ shared }) => shared > 0).sort((a, b) => b.shared - a.shared).slice(0, 3).map(({ one }) => one);
|
|
419
|
-
}, "nearest");
|
|
420
|
-
var runnableOnly = /* @__PURE__ */ __name((result, offered) => {
|
|
421
|
-
const body = result.structuredContent;
|
|
422
|
-
if (result.isError || !Array.isArray(body?.next))
|
|
423
|
-
return result;
|
|
424
|
-
const next = body.next.filter((step) => step.command === void 0 || offered(step.command));
|
|
425
|
-
const { next: _, ...rest } = body;
|
|
426
|
-
const kept = next.length > 0 ? { ...rest, next } : rest;
|
|
427
|
-
return {
|
|
428
|
-
...result,
|
|
429
|
-
structuredContent: kept,
|
|
430
|
-
content: result.content.map((part) => part.type === "text" ? { ...part, text: JSON.stringify(kept) } : part)
|
|
431
|
-
};
|
|
432
|
-
}, "runnableOnly");
|
|
433
|
-
var takesNothing = /* @__PURE__ */ __name((one) => Object.values(one.input.entries).every((entry) => entry.type === "optional"), "takesNothing");
|
|
434
|
-
var sampleOf = /* @__PURE__ */ __name((commands) => {
|
|
435
|
-
const reading = Object.entries(commands).filter(([, one]) => !one.writes);
|
|
436
|
-
const bare = reading.filter(([, one]) => takesNothing(one));
|
|
437
|
-
return bare.find(([command]) => command.endsWith(" list"))?.[0] ?? bare[0]?.[0] ?? reading[0]?.[0] ?? Object.keys(commands)[0] ?? "";
|
|
438
|
-
}, "sampleOf");
|
|
439
|
-
var registerCommands = /* @__PURE__ */ __name((server, prefix, commands, errors, withheld, isMessenger) => {
|
|
440
|
-
const byNormal = new Map(Object.keys(commands).map((command) => [normal(command), command]));
|
|
441
|
-
const messenger = isMessenger ?? Object.keys(commands).some((command) => command.split(" ")[0] === "messages");
|
|
442
|
-
const tasks = messenger ? '"unread", "send message", "chat members"' : '"list", "show", "change a setting"';
|
|
443
|
-
const sample = messenger ? "messages list" : sampleOf(commands);
|
|
444
|
-
const untrusted = messenger ? UNTRUSTED : UNTRUSTED_NEUTRAL;
|
|
445
|
-
server.registerTool(`${prefix}_tools_search`, {
|
|
446
|
-
outputSchema: toStandardJsonSchema(looseObject({})),
|
|
447
|
-
title: "Find a command",
|
|
448
|
-
description: `Find the command for a task \u2014 ${tasks} \u2014 before calling ${prefix}_read or ${prefix}_write with it. Each match gives its command, whether it writes, its arguments and the shape of its answer. With no words, lists every command and title, without arguments.`,
|
|
449
|
-
inputSchema: toStandardJsonSchema(strictObject({ query: optional(pipe(string(), description("words that describe the task"))) })),
|
|
450
|
-
annotations: { ...READ, openWorldHint: false, idempotentHint: true }
|
|
451
|
-
}, async ({ query }) => {
|
|
452
|
-
const found = search(commands, query ?? "");
|
|
453
|
-
const items = query?.trim() ? found.slice(0, MATCHES).map(([command, one]) => ({
|
|
454
|
-
command,
|
|
455
|
-
title: one.title,
|
|
456
|
-
description: one.description,
|
|
457
|
-
writes: one.writes,
|
|
458
|
-
availability: one.availability?.() ?? { available: true },
|
|
459
|
-
arguments: toJsonSchema(one.input),
|
|
460
|
-
output: toJsonSchema(one.output ?? ANSWER)
|
|
461
|
-
})) : found.map(([command, one]) => ({
|
|
462
|
-
command,
|
|
463
|
-
title: one.title,
|
|
464
|
-
writes: one.writes,
|
|
465
|
-
availability: one.availability?.() ?? { available: true }
|
|
466
|
-
}));
|
|
467
|
-
const { next: _paging, ...list } = listOf(`${prefix}_tools_search`, {
|
|
468
|
-
items,
|
|
469
|
-
limit: Math.max(items.length, query?.trim() ? MATCHES : 1),
|
|
470
|
-
has_more: found.length > items.length
|
|
471
|
-
});
|
|
472
|
-
return answered(list);
|
|
473
|
-
});
|
|
474
|
-
const callers = {
|
|
475
|
-
env: process.env,
|
|
476
|
-
client: /* @__PURE__ */ __name(() => server.server.getClientVersion(), "client"),
|
|
477
|
-
connectionId: randomUUID()
|
|
478
|
-
};
|
|
479
|
-
const runner = /* @__PURE__ */ __name((writing) => async ({ command: asked, arguments: given }, ctx) => {
|
|
480
|
-
try {
|
|
481
|
-
const command = byNormal.get(normal(asked));
|
|
482
|
-
const one = command === void 0 ? void 0 : commands[command];
|
|
483
|
-
if (command === void 0 || !one) {
|
|
484
|
-
withheld?.(normal(asked));
|
|
485
|
-
const near = nearest(commands, asked);
|
|
486
|
-
throw new CliError("validation_error", `no command "${asked}" here${near.length ? ` \u2014 did you mean ${near.map((name) => `"${name}"`).join(", ")}?` : ""}; ${prefix}_tools_search finds one`);
|
|
487
|
-
}
|
|
488
|
-
if (one.writes !== writing)
|
|
489
|
-
throw new CliError("validation_error", `"${command}" ${writing ? "only reads" : "writes"}: call it with ${prefix}_${writing ? "read" : "write"}`);
|
|
490
|
-
const args = writing ? agentArguments(given ?? {}) : given ?? {};
|
|
491
|
-
const caller = currentCaller() ?? callerOf(ctx, command.replace(/[ -]/g, "_"), callers);
|
|
492
|
-
if (one.checked)
|
|
493
|
-
return runnableOnly(await withCaller(caller, () => one.run(args, ctx)), (named) => byNormal.has(normal(named)));
|
|
494
|
-
const parsed = safeParse(strictObject(one.input.entries), args);
|
|
495
|
-
if (!parsed.success)
|
|
496
|
-
throw new CliError("validation_error", `${command}: ${summarize(parsed.issues)}`, {
|
|
497
|
-
arguments: toJsonSchema(one.input)
|
|
498
|
-
});
|
|
499
|
-
return runnableOnly(await withCaller(caller, () => one.run(parsed.output, ctx)), (named) => byNormal.has(normal(named)));
|
|
500
|
-
} catch (error) {
|
|
501
|
-
return failed(error, errors);
|
|
502
|
-
}
|
|
503
|
-
}, "runner");
|
|
504
|
-
const call = strictObject({
|
|
505
|
-
command: pipe(string(), minLength(1), description(`a command ${prefix}_tools_search returned: "${sample}"`)),
|
|
506
|
-
arguments: optional(pipe(record(string(), unknown()), description("that command's arguments")))
|
|
507
|
-
});
|
|
508
|
-
server.registerTool(`${prefix}_read`, {
|
|
509
|
-
outputSchema: listedAs(prefix, false),
|
|
510
|
-
title: "Run a reading command",
|
|
511
|
-
description: `Run one command that only reads, with the arguments ${prefix}_tools_search showed. ${untrusted}`,
|
|
512
|
-
inputSchema: toStandardJsonSchema(call),
|
|
513
|
-
annotations: READ
|
|
514
|
-
}, runner(false));
|
|
515
|
-
if (Object.values(commands).some((one) => one.writes))
|
|
516
|
-
server.registerTool(`${prefix}_write`, {
|
|
517
|
-
outputSchema: listedAs(prefix, true),
|
|
518
|
-
title: "Run a writing command",
|
|
519
|
-
description: `Run one command that changes something \u2014 ${messenger ? "sends, edits, deletes, joins" : "creates, edits, deletes"} \u2014 with the arguments ${prefix}_tools_search showed. ${untrusted}`,
|
|
520
|
-
inputSchema: toStandardJsonSchema(call),
|
|
521
|
-
annotations: WRITE
|
|
522
|
-
}, runner(true));
|
|
523
|
-
}, "registerCommands");
|
|
524
|
-
var surfaceCommands = /* @__PURE__ */ __name((tools, registration) => {
|
|
525
|
-
const run = entryRunner(registration);
|
|
526
|
-
return Object.fromEntries(Object.entries(tools).map(([key, definition]) => [
|
|
527
|
-
commandOf(key, definition),
|
|
528
|
-
{
|
|
529
|
-
title: definition.title,
|
|
530
|
-
description: definition.description,
|
|
531
|
-
writes: definition.annotations.readOnlyHint !== true,
|
|
532
|
-
input: inputOf(definition, syncAllowedFor(key, registration.defaults)),
|
|
533
|
-
...definition.output ? { output: outputSchemaOf(definition) } : {},
|
|
534
|
-
checked: true,
|
|
535
|
-
run: /* @__PURE__ */ __name((args, ctx) => run(key, definition, args, ctx), "run")
|
|
536
|
-
}
|
|
537
|
-
]));
|
|
538
|
-
}, "surfaceCommands");
|
|
539
|
-
var outputOf = /* @__PURE__ */ __name(({ entity, view }) => answerSchema(ENTITIES[view ? `${entity}.${view}` : entity] ?? unknown()), "outputOf");
|
|
540
|
-
|
|
541
|
-
export {
|
|
542
|
-
message,
|
|
543
|
-
READ,
|
|
544
|
-
WRITE,
|
|
545
|
-
tool,
|
|
546
|
-
chatOf,
|
|
547
|
-
tierOf,
|
|
548
|
-
outcomeOf,
|
|
549
|
-
commandOf,
|
|
550
|
-
toolKey,
|
|
551
|
-
Picture,
|
|
552
|
-
BinaryResource,
|
|
553
|
-
answered,
|
|
554
|
-
failed,
|
|
555
|
-
normal,
|
|
556
|
-
search,
|
|
557
|
-
registerCommands,
|
|
558
|
-
surfaceCommands,
|
|
559
|
-
outputOf
|
|
560
|
-
};
|