@wirecat/slack-cli 0.0.0-stage → 0.2.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.
Files changed (275) hide show
  1. package/CHANGELOG.md +121 -0
  2. package/LICENSE +204 -0
  3. package/README.md +131 -2
  4. package/contracts/wirecat.json +5526 -0
  5. package/dist/bin/slack.d.ts +3 -0
  6. package/dist/bin/slack.d.ts.map +1 -0
  7. package/dist/bin/slack.js +40 -0
  8. package/dist/bin/slack.js.map +1 -0
  9. package/dist/bundle/agent-GOFXFUQP.js +37 -0
  10. package/dist/bundle/all-profiles-4C7VOT2D.js +320 -0
  11. package/dist/bundle/anthropic-ZD66TC5S.js +91 -0
  12. package/dist/bundle/app-server-QNCVEDMY.js +249 -0
  13. package/dist/bundle/bun-2FULBYXS.js +169 -0
  14. package/dist/bundle/bun-sqlite-PMS26ZUT.js +76 -0
  15. package/dist/bundle/chunk-2LB5BWC4.js +362 -0
  16. package/dist/bundle/chunk-2ZEYRHZV.js +18 -0
  17. package/dist/bundle/chunk-3IJ3THPV.js +7 -0
  18. package/dist/bundle/chunk-3IZF5ENR.js +61 -0
  19. package/dist/bundle/chunk-4HSVEQ3R.js +29 -0
  20. package/dist/bundle/chunk-4QPMHVM5.js +1007 -0
  21. package/dist/bundle/chunk-53LIHHXC.js +16 -0
  22. package/dist/bundle/chunk-5F36CXDM.js +794 -0
  23. package/dist/bundle/chunk-5LPREGD3.js +12636 -0
  24. package/dist/bundle/chunk-5R5YRYIP.js +1148 -0
  25. package/dist/bundle/chunk-5RSQTG7L.js +388 -0
  26. package/dist/bundle/chunk-5SXZETJF.js +170 -0
  27. package/dist/bundle/chunk-6PDQP5RM.js +50 -0
  28. package/dist/bundle/chunk-75BLNPN3.js +1197 -0
  29. package/dist/bundle/chunk-7BEO72EN.js +131 -0
  30. package/dist/bundle/chunk-7F6RNAIM.js +230 -0
  31. package/dist/bundle/chunk-AG7FP64Z.js +77 -0
  32. package/dist/bundle/chunk-BRXTN5LJ.js +338 -0
  33. package/dist/bundle/chunk-CABZAU37.js +319 -0
  34. package/dist/bundle/chunk-CCOSG3F2.js +24616 -0
  35. package/dist/bundle/chunk-CDTZSFTN.js +58 -0
  36. package/dist/bundle/chunk-CMZBCWND.js +1246 -0
  37. package/dist/bundle/chunk-CRQEEJNF.js +185 -0
  38. package/dist/bundle/chunk-CWYU4R65.js +358 -0
  39. package/dist/bundle/chunk-CZFR6JQX.js +52 -0
  40. package/dist/bundle/chunk-D72URWJE.js +532 -0
  41. package/dist/bundle/chunk-DFDN6AUB.js +21 -0
  42. package/dist/bundle/chunk-DVHX7R54.js +4072 -0
  43. package/dist/bundle/chunk-DYKOG7QR.js +9596 -0
  44. package/dist/bundle/chunk-ECDI42G6.js +100 -0
  45. package/dist/bundle/chunk-EH6ZEJGT.js +932 -0
  46. package/dist/bundle/chunk-ELY2TLCY.js +259 -0
  47. package/dist/bundle/chunk-ERRVUVKR.js +156 -0
  48. package/dist/bundle/chunk-FBWR4E5D.js +353 -0
  49. package/dist/bundle/chunk-GKS6KL57.js +6848 -0
  50. package/dist/bundle/chunk-H2COZZ55.js +2787 -0
  51. package/dist/bundle/chunk-HGXTEK7R.js +82 -0
  52. package/dist/bundle/chunk-HXLXM7HV.js +726 -0
  53. package/dist/bundle/chunk-IPP4N6HD.js +24 -0
  54. package/dist/bundle/chunk-IWTVR7S7.js +53 -0
  55. package/dist/bundle/chunk-IYJH75D4.js +63 -0
  56. package/dist/bundle/chunk-JCZLRT4Z.js +39 -0
  57. package/dist/bundle/chunk-JGRWMR5H.js +123 -0
  58. package/dist/bundle/chunk-JYRYQJBN.js +633 -0
  59. package/dist/bundle/chunk-KIKLDI74.js +161 -0
  60. package/dist/bundle/chunk-L4WO3XH6.js +2020 -0
  61. package/dist/bundle/chunk-LQDNUAK3.js +274 -0
  62. package/dist/bundle/chunk-LV5ONLQH.js +38 -0
  63. package/dist/bundle/chunk-M27Z23OZ.js +23 -0
  64. package/dist/bundle/chunk-M5XTZHXM.js +142 -0
  65. package/dist/bundle/chunk-MJBEGUIZ.js +76 -0
  66. package/dist/bundle/chunk-N4WOLGIV.js +2333 -0
  67. package/dist/bundle/chunk-N5K4OHPT.js +206 -0
  68. package/dist/bundle/chunk-NYAPUET7.js +108 -0
  69. package/dist/bundle/chunk-P4IFLOIK.js +218 -0
  70. package/dist/bundle/chunk-P6G2QTCD.js +288 -0
  71. package/dist/bundle/chunk-PL5P7UKW.js +25216 -0
  72. package/dist/bundle/chunk-PU7R6XNV.js +80 -0
  73. package/dist/bundle/chunk-QLLBACDR.js +72 -0
  74. package/dist/bundle/chunk-QP7XN5KX.js +407 -0
  75. package/dist/bundle/chunk-QY2F6A3D.js +557 -0
  76. package/dist/bundle/chunk-RLIT7VAZ.js +66 -0
  77. package/dist/bundle/chunk-S4UUN6LD.js +1410 -0
  78. package/dist/bundle/chunk-SKGAKI62.js +86 -0
  79. package/dist/bundle/chunk-SQMZP5MA.js +66653 -0
  80. package/dist/bundle/chunk-UB6NTICY.js +95 -0
  81. package/dist/bundle/chunk-UBHQO5HV.js +778 -0
  82. package/dist/bundle/chunk-UM4RKO24.js +106 -0
  83. package/dist/bundle/chunk-VAHFY732.js +1068 -0
  84. package/dist/bundle/chunk-VGDM4C3F.js +188 -0
  85. package/dist/bundle/chunk-VOUAKCPM.js +41181 -0
  86. package/dist/bundle/chunk-WCCFJ4Q6.js +3736 -0
  87. package/dist/bundle/chunk-WV6EXRDV.js +46 -0
  88. package/dist/bundle/chunk-WVAT5TGY.js +334 -0
  89. package/dist/bundle/chunk-WW76JMKE.js +1243 -0
  90. package/dist/bundle/chunk-XXOMUKC6.js +54 -0
  91. package/dist/bundle/chunk-Y5E2WNWB.js +35 -0
  92. package/dist/bundle/chunk-YDO6RJ2P.js +1337 -0
  93. package/dist/bundle/chunk-ZBCFZCJW.js +388 -0
  94. package/dist/bundle/chunk-ZVVMGPBJ.js +50 -0
  95. package/dist/bundle/command-contract-BWGRUY6L.js +37 -0
  96. package/dist/bundle/command-server-entry-BATOWE3Y.js +166 -0
  97. package/dist/bundle/decode-MZQGYXJH.js +297 -0
  98. package/dist/bundle/definitions-3EONB23J.js +8600 -0
  99. package/dist/bundle/dispatch-NYC4ARWX.js +411 -0
  100. package/dist/bundle/dist-AMLBQVKM.js +7577 -0
  101. package/dist/bundle/dist-PAKDDIBT.js +191 -0
  102. package/dist/bundle/echarts-7OYGL2GW.js +42501 -0
  103. package/dist/bundle/embed-4I25DVKZ.js +38 -0
  104. package/dist/bundle/embedder-YXKQHAZO.js +111 -0
  105. package/dist/bundle/emoji-4LYX3GOS.js +4271 -0
  106. package/dist/bundle/failure-3YOVYZTX.js +25 -0
  107. package/dist/bundle/first-run-2VL2BOV7.js +29 -0
  108. package/dist/bundle/first-screen-C7FIWZL2.js +37 -0
  109. package/dist/bundle/instructions-UMNDHXG2.js +11 -0
  110. package/dist/bundle/mcp-V27RHILF.js +167 -0
  111. package/dist/bundle/meeting-combined-LS6XO4JH.js +24 -0
  112. package/dist/bundle/meeting-model-VIR465CY.js +25 -0
  113. package/dist/bundle/meeting-semantic-H5J3OOF2.js +22 -0
  114. package/dist/bundle/node-JJ3WDCNJ.js +2340 -0
  115. package/dist/bundle/node-PYFPGL4E.js +176 -0
  116. package/dist/bundle/node-TLZSIHIJ.js +21 -0
  117. package/dist/bundle/node-sqlite-LFWPGDVP.js +74 -0
  118. package/dist/bundle/oauth-42VCSIVL.js +20 -0
  119. package/dist/bundle/open-XJ5R5LHC.js +23 -0
  120. package/dist/bundle/openai-RZBLV4HG.js +238 -0
  121. package/dist/bundle/process-DD6H3K7L.js +91 -0
  122. package/dist/bundle/program-OIYIBNSA.js +35443 -0
  123. package/dist/bundle/prompt-NQRDM5LY.js +17 -0
  124. package/dist/bundle/recognize-EM7H2IZS.js +26 -0
  125. package/dist/bundle/remote-Z6NU6QQA.js +31 -0
  126. package/dist/bundle/rerank-PNPCSPNF.js +52 -0
  127. package/dist/bundle/schemas-JMKNP4U3.js +2765 -0
  128. package/dist/bundle/serve-SQVGX76J.js +199 -0
  129. package/dist/bundle/server-NPJH45FZ.js +212 -0
  130. package/dist/bundle/server-Z4ZMGRAH.js +79 -0
  131. package/dist/bundle/slack.js +184 -0
  132. package/dist/bundle/sqlite-runtime-F3AJGAPN.js +20 -0
  133. package/dist/bundle/state-JT7ZFSXN.js +36 -0
  134. package/dist/bundle/store-FXGMHRF3.js +181 -0
  135. package/dist/bundle/store-J5ZL2USR.js +295 -0
  136. package/dist/bundle/store-maintenance-command-TIHOIKLZ.js +66 -0
  137. package/dist/bundle/surface-NW6T5OR6.js +65 -0
  138. package/dist/commands/api.d.ts +7 -0
  139. package/dist/commands/api.d.ts.map +1 -0
  140. package/dist/commands/api.js +49 -0
  141. package/dist/commands/api.js.map +1 -0
  142. package/dist/commands/session.d.ts +7 -0
  143. package/dist/commands/session.d.ts.map +1 -0
  144. package/dist/commands/session.js +26 -0
  145. package/dist/commands/session.js.map +1 -0
  146. package/dist/config.d.ts +24 -0
  147. package/dist/config.d.ts.map +1 -0
  148. package/dist/config.js +75 -0
  149. package/dist/config.js.map +1 -0
  150. package/dist/context.d.ts +59 -0
  151. package/dist/context.d.ts.map +1 -0
  152. package/dist/context.js +75 -0
  153. package/dist/context.js.map +1 -0
  154. package/dist/generated/definitions.d.ts +3 -0
  155. package/dist/generated/definitions.d.ts.map +1 -0
  156. package/dist/generated/definitions.js +8596 -0
  157. package/dist/generated/definitions.js.map +1 -0
  158. package/dist/generated/emoji.d.ts +2 -0
  159. package/dist/generated/emoji.d.ts.map +1 -0
  160. package/dist/generated/emoji.js +4265 -0
  161. package/dist/generated/emoji.js.map +1 -0
  162. package/dist/generated/manifest.d.ts +6 -0
  163. package/dist/generated/manifest.d.ts.map +1 -0
  164. package/dist/generated/manifest.js +6139 -0
  165. package/dist/generated/manifest.js.map +1 -0
  166. package/dist/generated/schemas.d.ts +631 -0
  167. package/dist/generated/schemas.d.ts.map +1 -0
  168. package/dist/generated/schemas.js +2426 -0
  169. package/dist/generated/schemas.js.map +1 -0
  170. package/dist/generated/types.d.ts +3220 -0
  171. package/dist/generated/types.d.ts.map +1 -0
  172. package/dist/generated/types.js +5 -0
  173. package/dist/generated/types.js.map +1 -0
  174. package/dist/identity.d.ts +29 -0
  175. package/dist/identity.d.ts.map +1 -0
  176. package/dist/identity.js +32 -0
  177. package/dist/identity.js.map +1 -0
  178. package/dist/index.d.ts +3 -0
  179. package/dist/index.d.ts.map +1 -0
  180. package/dist/index.js +3 -0
  181. package/dist/index.js.map +1 -0
  182. package/dist/messenger.d.ts +12 -0
  183. package/dist/messenger.d.ts.map +1 -0
  184. package/dist/messenger.js +184 -0
  185. package/dist/messenger.js.map +1 -0
  186. package/dist/program.d.ts +6 -0
  187. package/dist/program.d.ts.map +1 -0
  188. package/dist/program.js +116 -0
  189. package/dist/program.js.map +1 -0
  190. package/dist/reasons.d.ts +7 -0
  191. package/dist/reasons.d.ts.map +1 -0
  192. package/dist/reasons.js +20 -0
  193. package/dist/reasons.js.map +1 -0
  194. package/dist/setup/flow.d.ts +2 -0
  195. package/dist/setup/flow.d.ts.map +1 -0
  196. package/dist/setup/flow.js +83 -0
  197. package/dist/setup/flow.js.map +1 -0
  198. package/dist/setup/guide.d.ts +6 -0
  199. package/dist/setup/guide.d.ts.map +1 -0
  200. package/dist/setup/guide.js +13 -0
  201. package/dist/setup/guide.js.map +1 -0
  202. package/dist/setup/texts.d.ts +24 -0
  203. package/dist/setup/texts.d.ts.map +1 -0
  204. package/dist/setup/texts.js +24 -0
  205. package/dist/setup/texts.js.map +1 -0
  206. package/dist/slack/adapter.d.ts +36 -0
  207. package/dist/slack/adapter.d.ts.map +1 -0
  208. package/dist/slack/adapter.js +574 -0
  209. package/dist/slack/adapter.js.map +1 -0
  210. package/dist/slack/app-manifest.d.ts +25 -0
  211. package/dist/slack/app-manifest.d.ts.map +1 -0
  212. package/dist/slack/app-manifest.js +51 -0
  213. package/dist/slack/app-manifest.js.map +1 -0
  214. package/dist/slack/client.d.ts +45 -0
  215. package/dist/slack/client.d.ts.map +1 -0
  216. package/dist/slack/client.js +236 -0
  217. package/dist/slack/client.js.map +1 -0
  218. package/dist/slack/map.d.ts +437 -0
  219. package/dist/slack/map.d.ts.map +1 -0
  220. package/dist/slack/map.js +411 -0
  221. package/dist/slack/map.js.map +1 -0
  222. package/dist/slack/mrkdwn.d.ts +9 -0
  223. package/dist/slack/mrkdwn.d.ts.map +1 -0
  224. package/dist/slack/mrkdwn.js +56 -0
  225. package/dist/slack/mrkdwn.js.map +1 -0
  226. package/dist/slack/search.d.ts +24 -0
  227. package/dist/slack/search.d.ts.map +1 -0
  228. package/dist/slack/search.js +99 -0
  229. package/dist/slack/search.js.map +1 -0
  230. package/dist/slack/threads.d.ts +28 -0
  231. package/dist/slack/threads.d.ts.map +1 -0
  232. package/dist/slack/threads.js +56 -0
  233. package/dist/slack/threads.js.map +1 -0
  234. package/dist/slack/tokens.d.ts +17 -0
  235. package/dist/slack/tokens.d.ts.map +1 -0
  236. package/dist/slack/tokens.js +27 -0
  237. package/dist/slack/tokens.js.map +1 -0
  238. package/dist/slack/writes.d.ts +43 -0
  239. package/dist/slack/writes.d.ts.map +1 -0
  240. package/dist/slack/writes.js +277 -0
  241. package/dist/slack/writes.js.map +1 -0
  242. package/dist/version.d.ts +2 -0
  243. package/dist/version.d.ts.map +1 -0
  244. package/dist/version.js +2 -0
  245. package/dist/version.js.map +1 -0
  246. package/dist/wcat.d.ts +3 -0
  247. package/dist/wcat.d.ts.map +1 -0
  248. package/dist/wcat.js +4 -0
  249. package/dist/wcat.js.map +1 -0
  250. package/package.json +89 -4
  251. package/skills/slack-cli/SKILL.md +117 -0
  252. package/skills/slack-cli/references/api/api-admin.md +541 -0
  253. package/skills/slack-cli/references/api/api-api.md +13 -0
  254. package/skills/slack-cli/references/api/api-apps.md +78 -0
  255. package/skills/slack-cli/references/api/api-auth.md +18 -0
  256. package/skills/slack-cli/references/api/api-bots.md +12 -0
  257. package/skills/slack-cli/references/api/api-calls.md +68 -0
  258. package/skills/slack-cli/references/api/api-chat.md +123 -0
  259. package/skills/slack-cli/references/api/api-conversations.md +230 -0
  260. package/skills/slack-cli/references/api/api-dialog.md +13 -0
  261. package/skills/slack-cli/references/api/api-dnd.md +31 -0
  262. package/skills/slack-cli/references/api/api-emoji.md +8 -0
  263. package/skills/slack-cli/references/api/api-files.md +120 -0
  264. package/skills/slack-cli/references/api/api-migration.md +14 -0
  265. package/skills/slack-cli/references/api/api-pins.md +37 -0
  266. package/skills/slack-cli/references/api/api-reactions.md +58 -0
  267. package/skills/slack-cli/references/api/api-reminders.md +51 -0
  268. package/skills/slack-cli/references/api/api-search.md +18 -0
  269. package/skills/slack-cli/references/api/api-stars.md +42 -0
  270. package/skills/slack-cli/references/api/api-team.md +55 -0
  271. package/skills/slack-cli/references/api/api-usergroups.md +80 -0
  272. package/skills/slack-cli/references/api/api-users.md +101 -0
  273. package/skills/slack-cli/references/api/api-views.md +46 -0
  274. package/skills/slack-cli/references/api/api-workflows.md +36 -0
  275. package/skills/slack-cli/references/api.md +35 -0
@@ -0,0 +1,49 @@
1
+ import { CliError } from "@wirecat/cli-base";
2
+ import { apiCommandPath } from "@wirecat/cli-base/codegen";
3
+ import { retrying } from "@wirecat/cli-base/http";
4
+ import { environmentOf, hostsFetch, serviceApiCommand } from "@wirecat/cli-core/cli";
5
+ import { API, configuration } from "../config.js";
6
+ import { contextOf, pacerFor, tokenOf } from "../context.js";
7
+ import { DESKTOP, IDENTITY } from "../identity.js";
8
+ import { refusalOf } from "../slack/client.js";
9
+ // Slack is RPC: a GET can send or publish (`views.publish`), so only an operation the manifest calls a read may be sent
10
+ // again after a 5xx or a lost answer; a write is sent once (WC-OUT-20).
11
+ const READS = new Set(API.manifest.operations.flatMap(({ effect, binding }) => effect === "read" && binding.kind === "http" ? [`${binding.method} ${binding.path}`] : []));
12
+ export const isRead = (method, url) => READS.has(`${method} ${url.pathname.slice(url.pathname.lastIndexOf("/"))}`);
13
+ /** The service's hosts and nothing else (WC-CMD-32), over the test's fake when it gives one. */
14
+ export const serviceFetch = (environment) => hostsFetch(DESKTOP.hosts, environment.fetch);
15
+ /**
16
+ * The service's raw API from its spec, `api list`, `api show` and one command per operation, through cli-core's shared
17
+ * group. The manifest gives the server, the sign-in header, the paging of `--all` and the keys: each write asks or
18
+ * refuses by `api.<operation>`, a delete or a share also by its key. The requests keep the profile's pace.
19
+ * The token is the profile's own, read by `tokenOf` like every other command's.
20
+ */
21
+ const DESTRUCTIVE = new Set(API.manifest.operations.flatMap((operation) => operation.effect === "destructive" ? [apiCommandPath(operation).join(" ")] : []));
22
+ const pathUnder = (group, action) => {
23
+ const words = [];
24
+ for (let at = action; at && at !== group; at = at.parent)
25
+ words.unshift(at.name());
26
+ return words.join(" ");
27
+ };
28
+ /**
29
+ * An agent never runs a raw delete: `chat delete` removes a message for everyone, and the rest cannot be undone
30
+ * either (WC-PERM-11). The owner still can, on the command line.
31
+ */
32
+ const ownerDeletesOnly = (group) => group.hook("preAction", (_, action) => {
33
+ const path = pathUnder(group, action);
34
+ if (environmentOf(action).agent && DESTRUCTIVE.has(path))
35
+ throw new CliError("permission_error", `an agent never runs \`api ${path}\`; the owner can, on the command line`, {
36
+ sent: false,
37
+ });
38
+ });
39
+ export const apiCommand = () => ownerDeletesOnly(serviceApiCommand({
40
+ ...API,
41
+ app: IDENTITY,
42
+ configuration,
43
+ fetch: (command) => retrying(serviceFetch(contextOf(command).environment), { reads: isRead, pacer: pacerFor(command) }),
44
+ token: tokenOf,
45
+ failedAnswer: (answer, operation) => refusalOf(answer, operation.effect !== "read"),
46
+ schemas: () => import("../generated/schemas.js").then((module) => module.schemas),
47
+ definitions: () => import("../generated/definitions.js").then((module) => module.definitions),
48
+ }));
49
+ //# sourceMappingURL=api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/commands/api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;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AAO,CAAC,CAAC,WAAW,CAAC,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;IACrG,KAAK,EAAE,OAAO;IACd,YAAY,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,MAAM,EAAE,SAAS,CAAC,MAAM,KAAK,MAAM,CAAC;IACnF,OAAO,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,yBAAyB,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC;IACjF,WAAW,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,6BAA6B,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC;CAC9F,CAAC,CACH,CAAA"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * `session start | status | end | list` (WC-ACCT-12) through cli-core's token session: the token is read hidden or
3
+ * from stdin, never as an argument, checked with `auth.test`, and only then kept in the keyring through
4
+ * `ProfileTokenStore`.
5
+ */
6
+ export declare const sessionCommand: () => import("commander").Command;
7
+ //# sourceMappingURL=session.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/commands/session.ts"],"names":[],"mappings":"AAOA;;;;GAIG;AACH,eAAO,MAAM,cAAc,mCAevB,CAAA"}
@@ -0,0 +1,26 @@
1
+ import { tokenSessionCommand } from "@wirecat/cli-core/cli";
2
+ import { configuration } from "../config.js";
3
+ import { slackFor } from "../context.js";
4
+ import { IDENTITY, SERVICE } from "../identity.js";
5
+ import { TOKEN_GUIDE } from "../setup/guide.js";
6
+ import { refuseOtherTokens, whoAmI } from "../slack/tokens.js";
7
+ /**
8
+ * `session start | status | end | list` (WC-ACCT-12) through cli-core's token session: the token is read hidden or
9
+ * from stdin, never as an argument, checked with `auth.test`, and only then kept in the keyring through
10
+ * `ProfileTokenStore`.
11
+ */
12
+ export const sessionCommand = () => tokenSessionCommand({
13
+ app: IDENTITY,
14
+ service: SERVICE,
15
+ resolveSettings: configuration.resolveSettings,
16
+ token: "User OAuth Token (xoxp-…)",
17
+ about: "Paste the User OAuth Token (xoxp-…) of your own Slack app, made from docs/slack-app-manifest.json; " +
18
+ "a bot token is refused",
19
+ guide: TOKEN_GUIDE,
20
+ endNote: "The app stays installed in the workspace; remove it there to revoke the token",
21
+ verify: async (command, token, events) => {
22
+ refuseOtherTokens(token);
23
+ return whoAmI(slackFor(command, token, events));
24
+ },
25
+ });
26
+ //# sourceMappingURL=session.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session.js","sourceRoot":"","sources":["../../src/commands/session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAE9D;;;;GAIG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,EAAE,CACjC,mBAAmB,CAAC;IAClB,GAAG,EAAE,QAAQ;IACb,OAAO,EAAE,OAAO;IAChB,eAAe,EAAE,aAAa,CAAC,eAAe;IAC9C,KAAK,EAAE,2BAA2B;IAClC,KAAK,EACH,qGAAqG;QACrG,wBAAwB;IAC1B,KAAK,EAAE,WAAW;IAClB,OAAO,EAAE,+EAA+E;IACxF,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE;QACvC,iBAAiB,CAAC,KAAK,CAAC,CAAA;QACxB,OAAO,MAAM,CAAC,QAAQ,CAAC,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,CAAA;IACjD,CAAC;CACF,CAAC,CAAA"}
@@ -0,0 +1,24 @@
1
+ import { type Configuration } from "@wirecat/cli-core/cli";
2
+ export declare const API: {
3
+ manifest: {
4
+ servers: readonly import("@wirecat/cli-base/codegen").ApiServer[];
5
+ securitySchemes: Readonly<Record<string, import("@wirecat/cli-base/codegen").SecurityScheme>>;
6
+ security: readonly import("@wirecat/cli-base/codegen").SecurityRequirement[];
7
+ operations: readonly import("@wirecat/cli-base/codegen").ManifestOperation[];
8
+ };
9
+ service: string;
10
+ excluded: readonly {
11
+ id: string;
12
+ reason: string;
13
+ }[];
14
+ };
15
+ export declare const permissions: import("@wirecat/cli-core/cli").CommandPermissions;
16
+ /** How many days back `messages sync` looks for threads with new replies (plan.md, "Sync and threads"). */
17
+ export declare const THREAD_WINDOW_DAYS = 14;
18
+ export interface SlackSettings {
19
+ threadWindowDays: number;
20
+ inboxChannels: string[];
21
+ inboxAllChannels: boolean;
22
+ }
23
+ export declare const configuration: Configuration;
24
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAKnB,MAAM,uBAAuB,CAAA;AAW9B,eAAO,MAAM,GAAG;;;;;;;;;;;;CAIf,CAAA;AAMD,eAAO,MAAM,WAAW,oDAGtB,CAAA;AAEF,2GAA2G;AAC3G,eAAO,MAAM,kBAAkB,KAAK,CAAA;AAEpC,MAAM,WAAW,aAAa;IAC5B,gBAAgB,EAAE,MAAM,CAAA;IACxB,aAAa,EAAE,MAAM,EAAE,CAAA;IACvB,gBAAgB,EAAE,OAAO,CAAA;CAC1B;AASD,eAAO,MAAM,aAAa,EAAE,aAgD1B,CAAA"}
package/dist/config.js ADDED
@@ -0,0 +1,75 @@
1
+ import { commandPermissions, serviceApiOperations, serviceApiPermissions, settingsFor, } from "@wirecat/cli-core/cli";
2
+ import { levelFor } from "@wirecat/cli-core/sends";
3
+ import * as v from "valibot";
4
+ import * as manifest from "./generated/manifest.js";
5
+ import { IDENTITY, SERVICE } from "./identity.js";
6
+ /** Each command is checked against its own path (`notes.list`); add the keys a command checks inside itself. */
7
+ // The keys a delete or a share checks come from `permissions` in scripts/generate.ts. Left out: an operation that
8
+ // answers with a credential (the CLI signs in through `session`) and a body cli-core cannot send (a form).
9
+ const { offered, left } = serviceApiOperations(manifest);
10
+ export const API = {
11
+ manifest: { ...manifest, operations: offered },
12
+ service: SERVICE,
13
+ excluded: left,
14
+ };
15
+ const apiPermissions = serviceApiPermissions(API);
16
+ // cli-core asks for every key an api operation names; a read of what people wrote is checked as `messages.list` and is
17
+ // no stricter than `messages list` (WC-PERM-4). A write keeps the ask: the api group has no recipient list or pace.
18
+ export const permissions = commandPermissions({
19
+ ...apiPermissions,
20
+ defaults: { ...apiPermissions.defaults, "messages.list": levelFor({}, "messages.list").level },
21
+ });
22
+ /** How many days back `messages sync` looks for threads with new replies (plan.md, "Sync and threads"). */
23
+ export const THREAD_WINDOW_DAYS = 14;
24
+ const threadWindowDays = v.optional(v.pipe(v.number("has to be a number of days"), v.integer(), v.minValue(1), v.maxValue(365)));
25
+ const inboxChannels = v.optional(v.string("has to be channel names or ids, comma-separated: #general, #dev"));
26
+ const inboxAllChannels = v.optional(v.boolean("has to be true or false"));
27
+ export const configuration = settingsFor(IDENTITY, {
28
+ permissions,
29
+ personal: {
30
+ thread_window_days: threadWindowDays,
31
+ inbox_channels: inboxChannels,
32
+ inbox_all_channels: inboxAllChannels,
33
+ },
34
+ // The channels are a workspace's, so they are set per profile only.
35
+ defaults: { thread_window_days: threadWindowDays },
36
+ settings: [
37
+ {
38
+ key: "thread_window_days",
39
+ default: THREAD_WINDOW_DAYS,
40
+ description: "how many days back messages sync looks for threads with new replies",
41
+ },
42
+ {
43
+ key: "inbox_channels",
44
+ default: "",
45
+ description: "the channels inbox counts every unread message of, comma-separated names or ids (#general, #dev); DMs are " +
46
+ "always counted",
47
+ },
48
+ {
49
+ key: "inbox_all_channels",
50
+ default: false,
51
+ description: "inbox counts every channel you are in, two calls each, so it may stop before the last ones",
52
+ },
53
+ ],
54
+ resolve: ({ fromLayers }) => {
55
+ const days = fromLayers("thread_window_days", THREAD_WINDOW_DAYS);
56
+ const channels = fromLayers("inbox_channels", "");
57
+ const allChannels = fromLayers("inbox_all_channels", false);
58
+ return {
59
+ values: {
60
+ threadWindowDays: days.value,
61
+ inboxChannels: channels.value
62
+ .split(",")
63
+ .map((one) => one.trim())
64
+ .filter(Boolean),
65
+ inboxAllChannels: allChannels.value,
66
+ },
67
+ sources: {
68
+ thread_window_days: days.from,
69
+ inbox_channels: channels.from,
70
+ inbox_all_channels: allChannels.from,
71
+ },
72
+ };
73
+ },
74
+ });
75
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,kBAAkB,EAClB,oBAAoB,EACpB,qBAAqB,EACrB,WAAW,GACZ,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAClD,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAC5B,OAAO,KAAK,QAAQ,MAAM,yBAAyB,CAAA;AACnD,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAEjD,gHAAgH;AAChH,kHAAkH;AAClH,2GAA2G;AAC3G,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,oBAAoB,CAAC,QAAQ,CAAC,CAAA;AAExD,MAAM,CAAC,MAAM,GAAG,GAAG;IACjB,QAAQ,EAAE,EAAE,GAAG,QAAQ,EAAE,UAAU,EAAE,OAAO,EAAE;IAC9C,OAAO,EAAE,OAAO;IAChB,QAAQ,EAAE,IAAI;CACf,CA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AAE;YACX,WAAW,EACT,4GAA4G;gBAC5G,gBAAgB;SACnB;QACD;YACE,GAAG,EAAE,oBAAoB;YACzB,OAAO,EAAE,KAAK;YACd,WAAW,EAAE,4FAA4F;SAC1G;KACF;IACD,OAAO,EAAE,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE;QAC1B,MAAM,IAAI,GAAG,UAAU,CAAC,oBAAoB,EAAE,kBAAkB,CAAC,CAAA;QACjE,MAAM,QAAQ,GAAG,UAAU,CAAC,gBAAgB,EAAE,EAAE,CAAC,CAAA;QACjD,MAAM,WAAW,GAAG,UAAU,CAAC,oBAAoB,EAAE,KAAK,CAAC,CAAA;QAC3D,OAAO;YACL,MAAM,EAAE;gBACN,gBAAgB,EAAE,IAAI,CAAC,KAAK;gBAC5B,aAAa,EAAE,QAAQ,CAAC,KAAK;qBAC1B,KAAK,CAAC,GAAG,CAAC;qBACV,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;qBACxB,MAAM,CAAC,OAAO,CAAC;gBAClB,gBAAgB,EAAE,WAAW,CAAC,KAAK;aACpC;YACD,OAAO,EAAE;gBACP,kBAAkB,EAAE,IAAI,CAAC,IAAI;gBAC7B,cAAc,EAAE,QAAQ,CAAC,IAAI;gBAC7B,kBAAkB,EAAE,WAAW,CAAC,IAAI;aACrC;SACF,CAAA;IACH,CAAC;CACF,CAAC,CAAA"}
@@ -0,0 +1,59 @@
1
+ import { type BaseEnvironment, type EventSink, type GlobalFlags, ProfileTokenStore } from "@wirecat/cli-core/cli";
2
+ import { Pacer } from "@wirecat/cli-core/sends";
3
+ import type { Command } from "commander";
4
+ /** What a test hands `run()` beside cli-core's own: the fake service in place of the network (WC-ARCH-10). */
5
+ export interface ServiceEnvironment extends BaseEnvironment {
6
+ fetch?: typeof fetch;
7
+ }
8
+ export declare const PACE: {
9
+ perMinute: number;
10
+ burst: number;
11
+ };
12
+ export declare const TIER_3_PACE: {
13
+ perMinute: number;
14
+ burst: number;
15
+ };
16
+ /**
17
+ * Settings, keyring and the run come from cli-core's `baseContext` and nowhere else: a command that resolves settings
18
+ * on its own skips `--timeout`, the run record and the profile's permissions (WC-LIFE-5, WC-LIFE-15).
19
+ */
20
+ export declare const contextOf: (command: Command) => {
21
+ settings: import("@wirecat/cli-core/cli").Settings;
22
+ renderer: import("@wirecat/cli-base").Renderer;
23
+ format: import("@wirecat/cli-base").RenderFormat;
24
+ color: boolean;
25
+ streams: import("@wirecat/cli-base").Streams;
26
+ compact?: boolean;
27
+ full?: boolean;
28
+ env: NodeJS.ProcessEnv;
29
+ keyring?: import("@wirecat/cli-base").KeyringStore;
30
+ run: <T>(body: (events: EventSink) => Promise<T>, options?: {
31
+ unbounded?: boolean;
32
+ name?: string;
33
+ }) => Promise<T>;
34
+ track: (closeable: import("@wirecat/cli-core/cli").Closeable) => void;
35
+ environment: ServiceEnvironment;
36
+ flags: GlobalFlags;
37
+ profile: string;
38
+ tokens: ProfileTokenStore;
39
+ };
40
+ /** The profile's pace: Slack's Tier 2, or `requests_per_minute` when set; 0 turns it off for tests. */
41
+ export declare const pacerFor: (command: Command, rate?: {
42
+ perMinute: number;
43
+ burst: number;
44
+ }, suffix?: string) => Pacer;
45
+ /** Slack for one run, with the token it was given and the profile's pace; each call lands in the run's `events`. */
46
+ export declare const slackFor: (command: Command, token: string, events?: EventSink) => (<T>(method: string, args: import("./slack/client.js").SlackArgs, answer: import("valibot").GenericSchema<unknown, T>, { writes, signal: stop }?: {
47
+ writes?: boolean;
48
+ signal?: AbortSignal | undefined;
49
+ }) => Promise<T>) & {
50
+ upload: (address: string, bytes: Uint8Array) => Promise<void>;
51
+ };
52
+ /** Whether the profile's token comes from SLACK_TOKEN, which never went through `session start`. */
53
+ export declare const tokenFromEnvironment: (command: Command) => boolean;
54
+ /**
55
+ * The profile's saved token, or an authentication error that says how to sign in. Read before any request; one from
56
+ * `SLACK_TOKEN` skips `session start`, so it is refused here as there.
57
+ */
58
+ export declare const tokenOf: (command: Command) => string;
59
+ //# sourceMappingURL=context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,eAAe,EAEpB,KAAK,SAAS,EAEd,KAAK,WAAW,EAChB,iBAAiB,EAGlB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,KAAK,EAAe,MAAM,yBAAyB,CAAA;AAC5D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAMxC,8GAA8G;AAC9G,MAAM,WAAW,kBAAmB,SAAQ,eAAe;IACzD,KAAK,CAAC,EAAE,OAAO,KAAK,CAAA;CACrB;AAMD,eAAO,MAAM,IAAI;IAAK,SAAS;IAAM,KAAK;CAAM,CAAA;AAChD,eAAO,MAAM,WAAW;IAAK,SAAS;IAAM,KAAK;CAAM,CAAA;AAEvD;;;GAGG;AACH,eAAO,MAAM,SAAS,YAAa,OAAO;;;;;;;;;;;;;;;;;;;CAczC,CAAA;AAED,uGAAuG;AACvG,eAAO,MAAM,QAAQ,YAAa,OAAO;;;4BAOxC,CAAA;AAED,oHAAoH;AACpH,eAAO,MAAM,QAAQ,YAAa,OAAO,SAAS,MAAM,WAAW,SAAS;;;;;CAU3E,CAAA;AAED,oGAAoG;AACpG,eAAO,MAAM,oBAAoB,YAAa,OAAO,YAGpD,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,OAAO,YAAa,OAAO,KAAG,MAiB1C,CAAA"}
@@ -0,0 +1,75 @@
1
+ import { CliError, isCliError } from "@wirecat/cli-base";
2
+ import { baseContext, environmentOf, ProfileTokenStore, recalledAccount, refuseOffline, } from "@wirecat/cli-core/cli";
3
+ import { Pacer, pacePathFor } from "@wirecat/cli-core/sends";
4
+ import { configuration } from "./config.js";
5
+ import { IDENTITY, PROVIDER, SERVICE } from "./identity.js";
6
+ import { slackClient } from "./slack/client.js";
7
+ import { refuseOtherTokens } from "./slack/tokens.js";
8
+ // Slack limits each method per workspace by tier (https://docs.slack.dev/apis/web-api/rate-limits/). The paging reads
9
+ // mix Tier 2 (users.list, reactions.list, search.messages: 20 a minute) and Tier 3 (conversations.history, .info,
10
+ // .replies, users.conversations: 50). cli-core's Pacer keeps one pace per file, so the profile has two: Tier 2 for
11
+ // every method, and Tier 3 for those in TIER_3. A 429 holds every process of the profile on that pace.
12
+ export const PACE = { perMinute: 20, burst: 10 };
13
+ export const TIER_3_PACE = { perMinute: 50, burst: 10 };
14
+ /**
15
+ * Settings, keyring and the run come from cli-core's `baseContext` and nowhere else: a command that resolves settings
16
+ * on its own skips `--timeout`, the run record and the profile's permissions (WC-LIFE-5, WC-LIFE-15).
17
+ */
18
+ export const contextOf = (command) => {
19
+ const base = baseContext(command, configuration.resolveSettings);
20
+ return {
21
+ ...base,
22
+ environment: environmentOf(command),
23
+ flags: command.optsWithGlobals(),
24
+ profile: base.settings.profile,
25
+ tokens: new ProfileTokenStore({
26
+ app: IDENTITY,
27
+ env: base.env,
28
+ keyring: base.keyring,
29
+ warn: base.renderer.warn,
30
+ }),
31
+ };
32
+ };
33
+ /** The profile's pace: Slack's Tier 2, or `requests_per_minute` when set; 0 turns it off for tests. */
34
+ export const pacerFor = (command, rate = PACE, suffix = "") => {
35
+ const { env, profile, settings } = contextOf(command);
36
+ const { requestsPerMinute } = settings;
37
+ return new Pacer(`${pacePathFor(IDENTITY, profile, env)}${suffix}`, requestsPerMinute === undefined ? rate : { ...rate, perMinute: requestsPerMinute });
38
+ };
39
+ /** Slack for one run, with the token it was given and the profile's pace; each call lands in the run's `events`. */
40
+ export const slackFor = (command, token, events) => {
41
+ const { environment } = contextOf(command);
42
+ return slackClient({
43
+ token,
44
+ events,
45
+ signal: environment.signal,
46
+ fetch: environment.fetch,
47
+ pacer: pacerFor(command),
48
+ tier3Pacer: pacerFor(command, TIER_3_PACE, ".tier3"),
49
+ });
50
+ };
51
+ /** Whether the profile's token comes from SLACK_TOKEN, which never went through `session start`. */
52
+ export const tokenFromEnvironment = (command) => {
53
+ const { profile, tokens } = contextOf(command);
54
+ return tokens.read(profile)?.source === "environment";
55
+ };
56
+ /**
57
+ * The profile's saved token, or an authentication error that says how to sign in. Read before any request; one from
58
+ * `SLACK_TOKEN` skips `session start`, so it is refused here as there.
59
+ */
60
+ export const tokenOf = (command) => {
61
+ const { profile, tokens, env, settings } = contextOf(command);
62
+ refuseOffline(command, SERVICE);
63
+ try {
64
+ return refuseOtherTokens(tokens.need(profile));
65
+ }
66
+ catch (error) {
67
+ // A keyring that cannot be read hides whether a profile this computer has never seen is a typo; as not signed in,
68
+ // cli-core names the profiles here (WC-ACCT-3). A known profile keeps the keyring's own error.
69
+ const unseen = !settings.profilesHere.includes(profile) && !recalledAccount(IDENTITY, PROVIDER, profile, env);
70
+ if (isCliError(error) && error.code === "configuration_error" && unseen)
71
+ throw new CliError("authentication_error", `profile ${profile} is not signed in — run \`${IDENTITY.command} ${profile} session start\``, { reason: "session.missing" });
72
+ throw error;
73
+ }
74
+ };
75
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AACxD,OAAO,EAEL,WAAW,EAEX,aAAa,EAEb,iBAAiB,EACjB,eAAe,EACf,aAAa,GACd,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAE5D,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AAOrD,sHAAsH;AACtH,kHAAkH;AAClH,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Q,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,CAAC,CAAA;QAC7G,IAAI,UAAU,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,KAAK,qBAAqB,IAAI,MAAM;YACrE,MAAM,IAAI,QAAQ,CAChB,sBAAsB,EACtB,WAAW,OAAO,6BAA6B,QAAQ,CAAC,OAAO,IAAI,OAAO,kBAAkB,EAC5F,EAAE,MAAM,EAAE,iBAAiB,EAAE,CAC9B,CAAA;QACH,MAAM,KAAK,CAAA;IACb,CAAC;AACH,CAAC,CAAA"}
@@ -0,0 +1,3 @@
1
+ import type { SchemaNode } from "@wirecat/cli-base/codegen";
2
+ export declare const definitions: Readonly<Record<string, SchemaNode>>;
3
+ //# sourceMappingURL=definitions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"definitions.d.ts","sourceRoot":"","sources":["../../src/generated/definitions.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAA;AAE3D,eAAO,MAAM,WAAW,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CA+hR5D,CAAA"}