@wirecat/amo-cli 0.0.0-stage → 0.1.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 (294) hide show
  1. package/CHANGELOG.md +61 -0
  2. package/LICENSE +204 -0
  3. package/README.md +257 -2
  4. package/contracts/wirecat.json +1356 -0
  5. package/dist/amo/account.d.ts +18 -0
  6. package/dist/amo/account.d.ts.map +1 -0
  7. package/dist/amo/account.js +48 -0
  8. package/dist/amo/account.js.map +1 -0
  9. package/dist/amo/allow-list.d.ts +31 -0
  10. package/dist/amo/allow-list.d.ts.map +1 -0
  11. package/dist/amo/allow-list.js +106 -0
  12. package/dist/amo/allow-list.js.map +1 -0
  13. package/dist/amo/call.d.ts +24 -0
  14. package/dist/amo/call.d.ts.map +1 -0
  15. package/dist/amo/call.js +54 -0
  16. package/dist/amo/call.js.map +1 -0
  17. package/dist/amo/errors.d.ts +12 -0
  18. package/dist/amo/errors.d.ts.map +1 -0
  19. package/dist/amo/errors.js +72 -0
  20. package/dist/amo/errors.js.map +1 -0
  21. package/dist/amo/json.d.ts +3 -0
  22. package/dist/amo/json.d.ts.map +1 -0
  23. package/dist/amo/json.js +3 -0
  24. package/dist/amo/json.js.map +1 -0
  25. package/dist/amo/oauth.d.ts +55 -0
  26. package/dist/amo/oauth.d.ts.map +1 -0
  27. package/dist/amo/oauth.js +189 -0
  28. package/dist/amo/oauth.js.map +1 -0
  29. package/dist/amo/operation.d.ts +45 -0
  30. package/dist/amo/operation.d.ts.map +1 -0
  31. package/dist/amo/operation.js +119 -0
  32. package/dist/amo/operation.js.map +1 -0
  33. package/dist/amo/operations.d.ts +3 -0
  34. package/dist/amo/operations.d.ts.map +1 -0
  35. package/dist/amo/operations.js +1407 -0
  36. package/dist/amo/operations.js.map +1 -0
  37. package/dist/amo/routes.d.ts +67 -0
  38. package/dist/amo/routes.d.ts.map +1 -0
  39. package/dist/amo/routes.js +65 -0
  40. package/dist/amo/routes.js.map +1 -0
  41. package/dist/amo/transport.d.ts +62 -0
  42. package/dist/amo/transport.d.ts.map +1 -0
  43. package/dist/amo/transport.js +282 -0
  44. package/dist/amo/transport.js.map +1 -0
  45. package/dist/api-keys.d.ts +47 -0
  46. package/dist/api-keys.d.ts.map +1 -0
  47. package/dist/api-keys.js +224 -0
  48. package/dist/api-keys.js.map +1 -0
  49. package/dist/bin/amo.d.ts +3 -0
  50. package/dist/bin/amo.d.ts.map +1 -0
  51. package/dist/bin/amo.js +40 -0
  52. package/dist/bin/amo.js.map +1 -0
  53. package/dist/bundle/all-profiles-3KQVWDV4.js +278 -0
  54. package/dist/bundle/amo.js +198 -0
  55. package/dist/bundle/anthropic-N5NOX7K7.js +90 -0
  56. package/dist/bundle/app-server-2MST5EZ5.js +245 -0
  57. package/dist/bundle/bun-4NHWOFX2.js +169 -0
  58. package/dist/bundle/bun-sqlite-DRSXPWPR.js +75 -0
  59. package/dist/bundle/chunk-2I5UVMLW.js +3232 -0
  60. package/dist/bundle/chunk-3IRJDH2U.js +731 -0
  61. package/dist/bundle/chunk-4ZAK773N.js +100 -0
  62. package/dist/bundle/chunk-5D4AEUVA.js +24783 -0
  63. package/dist/bundle/chunk-5D4Z2B5B.js +334 -0
  64. package/dist/bundle/chunk-5E5R65CA.js +54 -0
  65. package/dist/bundle/chunk-5HGGG3QO.js +73 -0
  66. package/dist/bundle/chunk-5RLUHTK6.js +23 -0
  67. package/dist/bundle/chunk-5SBLU7D7.js +63 -0
  68. package/dist/bundle/chunk-5Z5PEEKP.js +206 -0
  69. package/dist/bundle/chunk-63F65DHU.js +29 -0
  70. package/dist/bundle/chunk-6RS7OYTD.js +64 -0
  71. package/dist/bundle/chunk-73CXFE36.js +88 -0
  72. package/dist/bundle/chunk-7GTUZY7M.js +170 -0
  73. package/dist/bundle/chunk-7PKFYX7V.js +189 -0
  74. package/dist/bundle/chunk-7U5HJEPZ.js +1400 -0
  75. package/dist/bundle/chunk-A33TIM5D.js +4172 -0
  76. package/dist/bundle/chunk-ADEWU4P4.js +38 -0
  77. package/dist/bundle/chunk-ADLS6FVG.js +24600 -0
  78. package/dist/bundle/chunk-AHJ4W2IL.js +106 -0
  79. package/dist/bundle/chunk-AUBB72VF.js +2572 -0
  80. package/dist/bundle/chunk-BVMNXI53.js +1266 -0
  81. package/dist/bundle/chunk-CDY2NJFE.js +136 -0
  82. package/dist/bundle/chunk-CHUKWON6.js +244 -0
  83. package/dist/bundle/chunk-CUZRHF34.js +230 -0
  84. package/dist/bundle/chunk-D72URWJE.js +532 -0
  85. package/dist/bundle/chunk-DAY6TSPF.js +786 -0
  86. package/dist/bundle/chunk-DFDN6AUB.js +21 -0
  87. package/dist/bundle/chunk-DJD7TBYG.js +2791 -0
  88. package/dist/bundle/chunk-DOSJONCX.js +1197 -0
  89. package/dist/bundle/chunk-DQV2IKCF.js +72 -0
  90. package/dist/bundle/chunk-DTA5YV5O.js +25 -0
  91. package/dist/bundle/chunk-DXGGCGRP.js +218 -0
  92. package/dist/bundle/chunk-EH6ZEJGT.js +932 -0
  93. package/dist/bundle/chunk-EPOV5UIO.js +185 -0
  94. package/dist/bundle/chunk-EQ7A6NA6.js +53 -0
  95. package/dist/bundle/chunk-EQUKVVHX.js +353 -0
  96. package/dist/bundle/chunk-EROSAUNP.js +133 -0
  97. package/dist/bundle/chunk-ESZSMZKT.js +82 -0
  98. package/dist/bundle/chunk-FKR3M62D.js +407 -0
  99. package/dist/bundle/chunk-GNTJMB6X.js +142 -0
  100. package/dist/bundle/chunk-GQ7VFIYM.js +316 -0
  101. package/dist/bundle/chunk-JH3UOHRE.js +161 -0
  102. package/dist/bundle/chunk-JMDLPBXK.js +1068 -0
  103. package/dist/bundle/chunk-JR6TSMFX.js +9435 -0
  104. package/dist/bundle/chunk-K5UU3IOR.js +27955 -0
  105. package/dist/bundle/chunk-L6AFE73L.js +18 -0
  106. package/dist/bundle/chunk-LDEBZ3IX.js +238 -0
  107. package/dist/bundle/chunk-LGQXGOPJ.js +58 -0
  108. package/dist/bundle/chunk-LJQUYECN.js +6848 -0
  109. package/dist/bundle/chunk-LRBPT7LQ.js +95 -0
  110. package/dist/bundle/chunk-LSND5QYI.js +460 -0
  111. package/dist/bundle/chunk-NHXJYS4R.js +1334 -0
  112. package/dist/bundle/chunk-NJYAL3UW.js +92 -0
  113. package/dist/bundle/chunk-NTLSWCJ5.js +1718 -0
  114. package/dist/bundle/chunk-O2UCU52O.js +4065 -0
  115. package/dist/bundle/chunk-ODNQU7DH.js +1028 -0
  116. package/dist/bundle/chunk-P3WQRTYZ.js +24 -0
  117. package/dist/bundle/chunk-P5LYZRKW.js +63373 -0
  118. package/dist/bundle/chunk-PFO76YFP.js +2003 -0
  119. package/dist/bundle/chunk-PM77PRB6.js +12269 -0
  120. package/dist/bundle/chunk-Q2VNBY4Y.js +38109 -0
  121. package/dist/bundle/chunk-QDMXZZG4.js +604 -0
  122. package/dist/bundle/chunk-QRQYUHCZ.js +761 -0
  123. package/dist/bundle/chunk-RPWAJYI6.js +2336 -0
  124. package/dist/bundle/chunk-SMSTGO2G.js +58 -0
  125. package/dist/bundle/chunk-SZ2V62HB.js +72 -0
  126. package/dist/bundle/chunk-T2UDLX76.js +259 -0
  127. package/dist/bundle/chunk-TGEQNS6G.js +16 -0
  128. package/dist/bundle/chunk-TNUFLULO.js +2333 -0
  129. package/dist/bundle/chunk-U7RLVJ34.js +274 -0
  130. package/dist/bundle/chunk-UBRREVLJ.js +72 -0
  131. package/dist/bundle/chunk-ULXQ5MJM.js +76 -0
  132. package/dist/bundle/chunk-UMVRT7VQ.js +46 -0
  133. package/dist/bundle/chunk-V77XNPXG.js +360 -0
  134. package/dist/bundle/chunk-VVHRQ46X.js +193 -0
  135. package/dist/bundle/chunk-VX37MPTJ.js +7 -0
  136. package/dist/bundle/chunk-WCYCUTSK.js +362 -0
  137. package/dist/bundle/chunk-XEFAMLSD.js +288 -0
  138. package/dist/bundle/chunk-XQL7FEF4.js +721 -0
  139. package/dist/bundle/chunk-XRTD2GCU.js +627 -0
  140. package/dist/bundle/chunk-Y37A3232.js +804 -0
  141. package/dist/bundle/chunk-Y5E2WNWB.js +35 -0
  142. package/dist/bundle/chunk-ZM7I52EP.js +78 -0
  143. package/dist/bundle/chunk-ZVVMGPBJ.js +50 -0
  144. package/dist/bundle/cli-KEGIR67U.js +1193 -0
  145. package/dist/bundle/command-contract-QBUQBXH7.js +39 -0
  146. package/dist/bundle/command-server-entry-5VL5U5EE.js +168 -0
  147. package/dist/bundle/decode-SQ5WGNDX.js +296 -0
  148. package/dist/bundle/dispatch-LA4DFXJD.js +411 -0
  149. package/dist/bundle/dist-XJGFOXYI.js +7577 -0
  150. package/dist/bundle/echarts-25Z3RINX.js +42501 -0
  151. package/dist/bundle/embed-BNOTNXMA.js +37 -0
  152. package/dist/bundle/embedder-BCUT7KKV.js +110 -0
  153. package/dist/bundle/failure-PKAC6XCT.js +24 -0
  154. package/dist/bundle/first-run-EO5K5GME.js +28 -0
  155. package/dist/bundle/first-screen-GMN3T6RW.js +39 -0
  156. package/dist/bundle/instructions-VLM3QAYB.js +11 -0
  157. package/dist/bundle/mcp-7ILNMJH5.js +167 -0
  158. package/dist/bundle/meeting-combined-LAMF7S2B.js +24 -0
  159. package/dist/bundle/meeting-model-GHMMUQ34.js +24 -0
  160. package/dist/bundle/meeting-semantic-BMP6323L.js +21 -0
  161. package/dist/bundle/node-CT3N3TNL.js +176 -0
  162. package/dist/bundle/node-P4E63KXA.js +2340 -0
  163. package/dist/bundle/node-TLZSIHIJ.js +21 -0
  164. package/dist/bundle/node-sqlite-MELD2SBX.js +73 -0
  165. package/dist/bundle/oauth-YBH5OKC2.js +19 -0
  166. package/dist/bundle/open-WNSBWTAG.js +22 -0
  167. package/dist/bundle/openai-XSNMNLW6.js +237 -0
  168. package/dist/bundle/process-I2QKOMM7.js +91 -0
  169. package/dist/bundle/program-VQQTSSAF.js +4940 -0
  170. package/dist/bundle/prompt-SOG4AKPM.js +16 -0
  171. package/dist/bundle/recognize-WMQLWMXH.js +25 -0
  172. package/dist/bundle/remote-4BTFOLFY.js +30 -0
  173. package/dist/bundle/rerank-LJ3TWRNV.js +51 -0
  174. package/dist/bundle/serve-B6UANKXN.js +198 -0
  175. package/dist/bundle/server-S6XD6V6E.js +77 -0
  176. package/dist/bundle/server-YRH6GJ5Z.js +206 -0
  177. package/dist/bundle/source-DGFTA2TN.js +42 -0
  178. package/dist/bundle/sqlite-runtime-R7QFWFE7.js +19 -0
  179. package/dist/bundle/state-DIJ5YUOE.js +35 -0
  180. package/dist/bundle/store-6WFWW7EC.js +294 -0
  181. package/dist/bundle/store-BPNIM4BF.js +32 -0
  182. package/dist/bundle/store-MYTYDV6A.js +177 -0
  183. package/dist/bundle/store-maintenance-command-B5TMKFMG.js +68 -0
  184. package/dist/bundle/writer-GP7VIMAU.js +44 -0
  185. package/dist/commands/account.d.ts +3 -0
  186. package/dist/commands/account.d.ts.map +1 -0
  187. package/dist/commands/account.js +86 -0
  188. package/dist/commands/account.js.map +1 -0
  189. package/dist/commands/api.d.ts +3 -0
  190. package/dist/commands/api.d.ts.map +1 -0
  191. package/dist/commands/api.js +224 -0
  192. package/dist/commands/api.js.map +1 -0
  193. package/dist/commands/comments.d.ts +3 -0
  194. package/dist/commands/comments.d.ts.map +1 -0
  195. package/dist/commands/comments.js +114 -0
  196. package/dist/commands/comments.js.map +1 -0
  197. package/dist/commands/crm-shared.d.ts +8 -0
  198. package/dist/commands/crm-shared.d.ts.map +1 -0
  199. package/dist/commands/crm-shared.js +111 -0
  200. package/dist/commands/crm-shared.js.map +1 -0
  201. package/dist/commands/schedule.d.ts +3 -0
  202. package/dist/commands/schedule.d.ts.map +1 -0
  203. package/dist/commands/schedule.js +9 -0
  204. package/dist/commands/schedule.js.map +1 -0
  205. package/dist/commands/session.d.ts +18 -0
  206. package/dist/commands/session.d.ts.map +1 -0
  207. package/dist/commands/session.js +265 -0
  208. package/dist/commands/session.js.map +1 -0
  209. package/dist/commands/write.d.ts +14 -0
  210. package/dist/commands/write.d.ts.map +1 -0
  211. package/dist/commands/write.js +36 -0
  212. package/dist/commands/write.js.map +1 -0
  213. package/dist/config.d.ts +4 -0
  214. package/dist/config.d.ts.map +1 -0
  215. package/dist/config.js +29 -0
  216. package/dist/config.js.map +1 -0
  217. package/dist/context.d.ts +62 -0
  218. package/dist/context.d.ts.map +1 -0
  219. package/dist/context.js +97 -0
  220. package/dist/context.js.map +1 -0
  221. package/dist/crm/activities.d.ts +32 -0
  222. package/dist/crm/activities.d.ts.map +1 -0
  223. package/dist/crm/activities.js +196 -0
  224. package/dist/crm/activities.js.map +1 -0
  225. package/dist/crm/records.d.ts +20 -0
  226. package/dist/crm/records.d.ts.map +1 -0
  227. package/dist/crm/records.js +175 -0
  228. package/dist/crm/records.js.map +1 -0
  229. package/dist/crm/source.d.ts +41 -0
  230. package/dist/crm/source.d.ts.map +1 -0
  231. package/dist/crm/source.js +673 -0
  232. package/dist/crm/source.js.map +1 -0
  233. package/dist/crm/writer.d.ts +14 -0
  234. package/dist/crm/writer.d.ts.map +1 -0
  235. package/dist/crm/writer.js +247 -0
  236. package/dist/crm/writer.js.map +1 -0
  237. package/dist/identity.d.ts +7 -0
  238. package/dist/identity.d.ts.map +1 -0
  239. package/dist/identity.js +33 -0
  240. package/dist/identity.js.map +1 -0
  241. package/dist/index.d.ts +3 -0
  242. package/dist/index.d.ts.map +1 -0
  243. package/dist/index.js +3 -0
  244. package/dist/index.js.map +1 -0
  245. package/dist/program.d.ts +6 -0
  246. package/dist/program.d.ts.map +1 -0
  247. package/dist/program.js +91 -0
  248. package/dist/program.js.map +1 -0
  249. package/dist/reasons.d.ts +10 -0
  250. package/dist/reasons.d.ts.map +1 -0
  251. package/dist/reasons.js +35 -0
  252. package/dist/reasons.js.map +1 -0
  253. package/dist/sample/comments.d.ts +61 -0
  254. package/dist/sample/comments.d.ts.map +1 -0
  255. package/dist/sample/comments.js +39 -0
  256. package/dist/sample/comments.js.map +1 -0
  257. package/dist/sample/records.d.ts +16 -0
  258. package/dist/sample/records.d.ts.map +1 -0
  259. package/dist/sample/records.js +22 -0
  260. package/dist/sample/records.js.map +1 -0
  261. package/dist/sample/transport.d.ts +42 -0
  262. package/dist/sample/transport.d.ts.map +1 -0
  263. package/dist/sample/transport.js +153 -0
  264. package/dist/sample/transport.js.map +1 -0
  265. package/dist/setup/flow.d.ts +2 -0
  266. package/dist/setup/flow.d.ts.map +1 -0
  267. package/dist/setup/flow.js +127 -0
  268. package/dist/setup/flow.js.map +1 -0
  269. package/dist/setup/texts.en.json +25 -0
  270. package/dist/setup/texts.es.json +25 -0
  271. package/dist/setup/texts.ru.json +25 -0
  272. package/dist/store.d.ts +15 -0
  273. package/dist/store.d.ts.map +1 -0
  274. package/dist/store.js +16 -0
  275. package/dist/store.js.map +1 -0
  276. package/dist/version.d.ts +2 -0
  277. package/dist/version.d.ts.map +1 -0
  278. package/dist/version.js +2 -0
  279. package/dist/version.js.map +1 -0
  280. package/dist/wcat.d.ts +3 -0
  281. package/dist/wcat.d.ts.map +1 -0
  282. package/dist/wcat.js +4 -0
  283. package/dist/wcat.js.map +1 -0
  284. package/dist/whoami.d.ts +24 -0
  285. package/dist/whoami.d.ts.map +1 -0
  286. package/dist/whoami.js +33 -0
  287. package/dist/whoami.js.map +1 -0
  288. package/package.json +85 -4
  289. package/skills/amo-cli/SKILL.md +116 -0
  290. package/skills/amo-cli/references/mcp.md +38 -0
  291. package/skills/amo-cli/references/output.md +42 -0
  292. package/skills/amo-cli/references/reading.md +77 -0
  293. package/skills/amo-cli/references/setup.md +59 -0
  294. package/skills/amo-cli/references/writing.md +85 -0
@@ -0,0 +1,61 @@
1
+ import * as v from "valibot";
2
+ import type { Transport } from "./transport.js";
3
+ declare const wireComment: v.ObjectSchema<{
4
+ readonly id: v.StringSchema<undefined>;
5
+ readonly body: v.StringSchema<undefined>;
6
+ readonly authorName: v.StringSchema<undefined>;
7
+ readonly createdAt: v.StringSchema<undefined>;
8
+ }, undefined>;
9
+ /**
10
+ * The answer's own shape, in snake_case (WC-OUT-12). `answerEntity` publishes it, so `--json=id,text` and the MCP
11
+ * schema both come from here (WC-CMD-19). No wire type leaves this file (WC-ARCH-3).
12
+ */
13
+ export declare const commentSchema: v.StrictObjectSchema<{
14
+ readonly id: v.StringSchema<undefined>;
15
+ readonly text: v.StringSchema<undefined>;
16
+ readonly author: v.StringSchema<undefined>;
17
+ readonly created_at: v.StringSchema<undefined>;
18
+ }, undefined>;
19
+ export type Comment = v.InferOutput<typeof commentSchema>;
20
+ export declare const commentOf: (wire: v.InferOutput<typeof wireComment>) => Comment;
21
+ /** Every call the sample makes: a method, a path template and only the fields the service documents. */
22
+ export declare const commentsService: (api: Transport) => {
23
+ me: () => Promise<{
24
+ id: string;
25
+ name: string;
26
+ }>;
27
+ list: ({ limit, offset, author }: {
28
+ limit: number;
29
+ offset: number;
30
+ author?: string | undefined;
31
+ }) => Promise<{
32
+ items: {
33
+ id: string;
34
+ text: string;
35
+ author: string;
36
+ created_at: string;
37
+ }[];
38
+ hasMore: boolean;
39
+ }>;
40
+ show: (id: string) => Promise<{
41
+ id: string;
42
+ text: string;
43
+ author: string;
44
+ created_at: string;
45
+ }>;
46
+ create: (text: string) => Promise<{
47
+ id: string;
48
+ text: string;
49
+ author: string;
50
+ created_at: string;
51
+ }>;
52
+ update: (id: string, text: string) => Promise<{
53
+ id: string;
54
+ text: string;
55
+ author: string;
56
+ created_at: string;
57
+ }>;
58
+ };
59
+ export type CommentsService = ReturnType<typeof commentsService>;
60
+ export {};
61
+ //# sourceMappingURL=comments.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"comments.d.ts","sourceRoot":"","sources":["../../src/sample/comments.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAC5B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAI/C,QAAA,MAAM,WAAW;;;;;aAKf,CAAA;AAIF;;;GAGG;AACH,eAAO,MAAM,aAAa;;;;;aAKxB,CAAA;AACF,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,aAAa,CAAC,CAAA;AAEzD,eAAO,MAAM,SAAS,SAAU,CAAC,CAAC,WAAW,CAAC,OAAO,WAAW,CAAC,KAAG,OAKlE,CAAA;AAEF,wGAAwG;AACxG,eAAO,MAAM,eAAe,QAAS,SAAS;IAC5C,EAAE;;;;IACF,IAAI,8BAAoC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;KAAE;;;;;;;;;IAItG,IAAI,OAAa,MAAM;;;;;;IAEvB,MAAM,SAAe,MAAM;;;;;;IAE3B,MAAM,OAAa,MAAM,QAAQ,MAAM;;;;;;CAIvC,CAAA;AAEF,MAAM,MAAM,eAAe,GAAG,UAAU,CAAC,OAAO,eAAe,CAAC,CAAA"}
@@ -0,0 +1,39 @@
1
+ import * as v from "valibot";
2
+ // SAMPLE: replace these shapes with your service's. Each wire name comes from the service's docs or a captured answer,
3
+ // never from memory; the strict fake in src/testing/fake-comments.ts refuses any other.
4
+ const wireComment = v.object({
5
+ id: v.string(),
6
+ body: v.string(),
7
+ authorName: v.string(),
8
+ createdAt: v.string(),
9
+ });
10
+ const wirePage = v.object({ comments: v.array(wireComment), hasMore: v.boolean() });
11
+ const wireUser = v.object({ id: v.string(), name: v.string() });
12
+ /**
13
+ * The answer's own shape, in snake_case (WC-OUT-12). `answerEntity` publishes it, so `--json=id,text` and the MCP
14
+ * schema both come from here (WC-CMD-19). No wire type leaves this file (WC-ARCH-3).
15
+ */
16
+ export const commentSchema = v.strictObject({
17
+ id: v.string(),
18
+ text: v.string(),
19
+ author: v.string(),
20
+ created_at: v.string(),
21
+ });
22
+ export const commentOf = (wire) => ({
23
+ id: wire.id,
24
+ text: wire.body,
25
+ author: wire.authorName,
26
+ created_at: wire.createdAt,
27
+ });
28
+ /** Every call the sample makes: a method, a path template and only the fields the service documents. */
29
+ export const commentsService = (api) => ({
30
+ me: () => api.send({ method: "GET", path: "me" }, wireUser),
31
+ list: async ({ limit, offset, author }) => {
32
+ const page = await api.send({ method: "GET", path: "comments", query: { limit, offset, by: author } }, wirePage);
33
+ return { items: page.comments.map(commentOf), hasMore: page.hasMore };
34
+ },
35
+ show: async (id) => commentOf(await api.send({ method: "GET", path: "comments/{id}", ids: { id } }, wireComment)),
36
+ create: async (text) => commentOf(await api.send({ method: "POST", path: "comments", body: { body: text } }, wireComment)),
37
+ update: async (id, text) => commentOf(await api.send({ method: "PATCH", path: "comments/{id}", ids: { id }, body: { body: text } }, wireComment)),
38
+ });
39
+ //# sourceMappingURL=comments.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"comments.js","sourceRoot":"","sources":["../../src/sample/comments.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAG5B,uHAAuH;AACvH,wFAAwF;AACxF,MAAM,WAAW,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3B,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE;IACd,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE;IACtB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;CACtB,CAAC,CAAA;AACF,MAAM,QAAQ,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,KAAK,CAAC,WAAW,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAA;AACnF,MAAM,QAAQ,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAA;AAE/D;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC,YAAY,CAAC;IAC1C,EAAE,EAAE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AE,EAAE,EAAE,WAAW,CAAC,CAAC;IAC/F,MAAM,EAAE,KAAK,EAAE,IAAY,EAAE,EAAE,CAC7B,SAAS,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,WAAW,CAAC,CAAC;IACpG,MAAM,EAAE,KAAK,EAAE,EAAU,EAAE,IAAY,EAAE,EAAE,CACzC,SAAS,CACP,MAAM,GAAG,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,eAAe,EAAE,GAAG,EAAE,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,WAAW,CAAC,CAC3G;CACJ,CAAC,CAAA"}
@@ -0,0 +1,16 @@
1
+ import { type IngestReceipt } from "@wirecat/cli-core/services";
2
+ import type { MessageStore } from "@wirecat/cli-core/store";
3
+ import type { Comment } from "./comments.js";
4
+ export interface RecordsSource {
5
+ provider: string;
6
+ account: string;
7
+ batchId: string;
8
+ }
9
+ /** The JSONL a records import reads, ready for a file or stdout: the header line, then one record per line. */
10
+ export declare function commentLines(source: RecordsSource, comments: AsyncIterable<Comment> | Iterable<Comment>): AsyncGenerator<string, void, unknown>;
11
+ /**
12
+ * Takes a JSONL file or stdin into the shared store one line at a time, so memory does not grow with the file. The
13
+ * header's `source.account` must be `account`, or every record is refused.
14
+ */
15
+ export declare const importRecords: (store: Pick<MessageStore, "records">, input: NodeJS.ReadableStream, account: string) => Promise<IngestReceipt>;
16
+ //# sourceMappingURL=records.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"records.d.ts","sourceRoot":"","sources":["../../src/sample/records.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAA2B,MAAM,4BAA4B,CAAA;AACxF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAC3D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAM5C,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;CAChB;AAED,+GAA+G;AAC/G,wBAAuB,YAAY,CAAC,MAAM,EAAE,aAAa,EAAE,QAAQ,EAAE,aAAa,CAAC,OAAO,CAAC,GAAG,QAAQ,CAAC,OAAO,CAAC,yCAa9G;AAED;;;GAGG;AACH,eAAO,MAAM,aAAa,UACjB,IAAI,CAAC,YAAY,EAAE,SAAS,CAAC,SAC7B,MAAM,CAAC,cAAc,WACnB,MAAM,KACd,OAAO,CAAC,aAAa,CAAuD,CAAA"}
@@ -0,0 +1,22 @@
1
+ import { ingestLines, jsonlLines } from "@wirecat/cli-core/services";
2
+ /** The JSONL a records import reads, ready for a file or stdout: the header line, then one record per line. */
3
+ export async function* commentLines(source, comments) {
4
+ yield `${JSON.stringify({
5
+ schema_version: 1,
6
+ source: { provider: source.provider, account: source.account, batch_id: source.batchId },
7
+ })}\n`;
8
+ for await (const comment of comments)
9
+ yield `${JSON.stringify({
10
+ key: comment.id,
11
+ type: "custom:comment",
12
+ external_id: comment.id,
13
+ operation: "upsert",
14
+ fields: { text: comment.text, author: comment.author, created_at: comment.created_at },
15
+ })}\n`;
16
+ }
17
+ /**
18
+ * Takes a JSONL file or stdin into the shared store one line at a time, so memory does not grow with the file. The
19
+ * header's `source.account` must be `account`, or every record is refused.
20
+ */
21
+ export const importRecords = (store, input, account) => ingestLines(store, jsonlLines(input), { account });
22
+ //# sourceMappingURL=records.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"records.js","sourceRoot":"","sources":["../../src/sample/records.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,WAAW,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAA;AAcxF,+GAA+G;AAC/G,MAAM,CAAC,KAAK,SAAS,CAAC,CAAC,YAAY,CAAC,MAAqB,EAAE,QAAoD;IAC7G,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC;QACtB,cAAc,EAAE,CAAC;QACjB,MAAM,EAAE,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,QAAQ,EAAE,MAAM,CAAC,OAAO,EAAE;KACzF,CAAC,IAAI,CAAA;IACN,IAAI,KAAK,EAAE,MAAM,OAAO,IAAI,QAAQ;QAClC,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC;YACtB,GAAG,EAAE,OAAO,CAAC,EAAE;YACf,IAAI,EAAE,gBAAgB;YACtB,WAAW,EAAE,OAAO,CAAC,EAAE;YACvB,SAAS,EAAE,QAAQ;YACnB,MAAM,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,UAAU,EAAE,OAAO,CAAC,UAAU,EAAE;SACvF,CAAC,IAAI,CAAA;AACV,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAC3B,KAAoC,EACpC,KAA4B,EAC5B,OAAe,EACS,EAAE,CAAC,WAAW,CAAC,KAAK,EAAE,UAAU,CAAC,KAAK,CAAC,EAAE,EAAE,OAAO,EAAE,CAAC,CAAA"}
@@ -0,0 +1,42 @@
1
+ import { CliError, type SleepLike } from "@wirecat/cli-base";
2
+ import { type EventSink } from "@wirecat/cli-core/cli";
3
+ import type { Pacer } from "@wirecat/cli-core/sends";
4
+ import * as v from "valibot";
5
+ export declare const SERVICE_URL = "https://comments.example.invalid/v1/";
6
+ export declare const SERVICE = "Example Comments";
7
+ export interface Request {
8
+ method: "GET" | "POST" | "PATCH";
9
+ /** The path as a template, `comments/{id}`: the run record keeps the template, never an id. */
10
+ path: string;
11
+ ids?: Record<string, string>;
12
+ query?: Record<string, string | number | undefined>;
13
+ body?: Record<string, unknown>;
14
+ }
15
+ export interface TransportOptions {
16
+ token: string;
17
+ fetch?: typeof fetch;
18
+ signal?: AbortSignal | undefined;
19
+ /** The run's sink from `baseContext(...).run(events => …)`, so each request lands in the run record (WC-LIFE-15). */
20
+ events?: EventSink;
21
+ /** cli-core's per-profile pace, shared by every process of the profile through a file. */
22
+ pacer?: Pacer;
23
+ sleep?: SleepLike;
24
+ now?: () => number;
25
+ timeoutMs?: number;
26
+ }
27
+ /**
28
+ * A refusal as a CliError with cli-base's code for its status. The service's own message is never repeated: it can
29
+ * quote what was sent (WC-SECR-6). A write that failed on the service's side may have happened, so it is
30
+ * `outcome_unknown` and never retryable (WC-OUT-20, WC-LIFE-9).
31
+ */
32
+ export declare const failureOf: (status: number, writes: boolean, retryAfterMs?: number) => CliError;
33
+ /**
34
+ * The only code that holds the token: it goes in the Authorization header, never in an address, an error or a run
35
+ * record (WC-SECR-7). Nothing here retries. A read the caller may run again; a write is never sent twice, since the
36
+ * first may have landed (WC-OUT-20).
37
+ */
38
+ export declare const transport: (options: TransportOptions) => {
39
+ send: <T>(request: Request, answer: v.GenericSchema<unknown, T>) => Promise<T>;
40
+ };
41
+ export type Transport = ReturnType<typeof transport>;
42
+ //# sourceMappingURL=transport.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../src/sample/transport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAyB,KAAK,SAAS,EAAa,MAAM,mBAAmB,CAAA;AAE9F,OAAO,EAAE,KAAK,SAAS,EAAmB,MAAM,uBAAuB,CAAA;AACvE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAA;AACpD,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAK5B,eAAO,MAAM,WAAW,yCAAyC,CAAA;AACjE,eAAO,MAAM,OAAO,qBAAqB,CAAA;AAOzC,MAAM,WAAW,OAAO;IACtB,MAAM,EAAE,KAAK,GAAG,MAAM,GAAG,OAAO,CAAA;IAChC,+FAA+F;IAC/F,IAAI,EAAE,MAAM,CAAA;IACZ,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC,CAAA;IACnD,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC/B;AAED,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,OAAO,KAAK,CAAA;IACpB,MAAM,CAAC,EAAE,WAAW,GAAG,SAAS,CAAA;IAChC,qHAAqH;IACrH,MAAM,CAAC,EAAE,SAAS,CAAA;IAClB,0FAA0F;IAC1F,KAAK,CAAC,EAAE,KAAK,CAAA;IACb,KAAK,CAAC,EAAE,SAAS,CAAA;IACjB,GAAG,CAAC,EAAE,MAAM,MAAM,CAAA;IAClB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAkBD;;;;GAIG;AACH,eAAO,MAAM,SAAS,WAAY,MAAM,UAAU,OAAO,iBAAiB,MAAM,KAAG,QAqBlF,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,SAAS,YAAa,gBAAgB;WA6B7B,CAAC,WAAW,OAAO,UAAU,CAAC,CAAC,aAAa,CAAC,OAAO,EAAE,CAAC,CAAC,KAAG,OAAO,CAAC,CAAC,CAAC;CAiE1F,CAAA;AAED,MAAM,MAAM,SAAS,GAAG,UAAU,CAAC,OAAO,SAAS,CAAC,CAAA"}
@@ -0,0 +1,153 @@
1
+ import { CliError, isCliError, realSleep, wallClock } from "@wirecat/cli-base";
2
+ import { hostFetch, providerWaitMs, readJsonResponse, statusToCode } from "@wirecat/cli-base/http";
3
+ import { providerRequest } from "@wirecat/cli-core/cli";
4
+ import * as v from "valibot";
5
+ import { DESKTOP } from "../identity.js";
6
+ // SAMPLE: the Example Comments service does not exist; `.invalid` never resolves, so a real run reaches nothing.
7
+ // Replace the address, the paths and the answer shapes with your service's, each from its docs or a captured answer.
8
+ export const SERVICE_URL = "https://comments.example.invalid/v1/";
9
+ export const SERVICE = "Example Comments";
10
+ const TIMEOUT_MS = 30_000;
11
+ const LARGEST_ANSWER = 8 * 1024 * 1024;
12
+ /** A pace wait longer than this ends the run with `rate_limited` instead of sitting in it. */
13
+ const LONGEST_PACE_WAIT_MS = 60_000;
14
+ /** `new URL` folds a `.` or `..` segment into its parent, so such an id would reach another endpoint. */
15
+ const segment = (name, value) => {
16
+ if (value === "" || value === "." || value === "..")
17
+ throw new CliError("validation_error", `${name} must name one item; an empty, "." or ".." id is refused`);
18
+ return encodeURIComponent(value);
19
+ };
20
+ const urlOf = ({ path, ids = {}, query = {} }) => {
21
+ const url = new URL(path.replace(/\{(\w+)\}/g, (_, name) => segment(name, ids[name] ?? "")), SERVICE_URL);
22
+ for (const [key, value] of Object.entries(query))
23
+ if (value !== undefined)
24
+ url.searchParams.set(key, String(value));
25
+ return url;
26
+ };
27
+ /**
28
+ * A refusal as a CliError with cli-base's code for its status. The service's own message is never repeated: it can
29
+ * quote what was sent (WC-SECR-6). A write that failed on the service's side may have happened, so it is
30
+ * `outcome_unknown` and never retryable (WC-OUT-20, WC-LIFE-9).
31
+ */
32
+ export const failureOf = (status, writes, retryAfterMs) => {
33
+ if (status === 401)
34
+ return new CliError("authentication_error", `${SERVICE} refused the token; sign in again with session start`, {
35
+ status,
36
+ });
37
+ if (status === 429)
38
+ return new CliError("rate_limited", `${SERVICE} asked to slow down; retry the command later`, {
39
+ status,
40
+ retryable: true,
41
+ ...(retryAfterMs === undefined ? {} : { retry_after_ms: retryAfterMs }),
42
+ });
43
+ if (status >= 500 && writes)
44
+ return new CliError("outcome_unknown", `${SERVICE} failed during a write; check it before repeating the write`, {
45
+ status,
46
+ retryable: false,
47
+ });
48
+ if (status === 404)
49
+ return new CliError("not_found", `${SERVICE} has no such item, or this token cannot see it`);
50
+ return new CliError(statusToCode(status), `${SERVICE} refused the request (HTTP ${status})`, {
51
+ status,
52
+ retryable: status >= 500,
53
+ });
54
+ };
55
+ /**
56
+ * The only code that holds the token: it goes in the Authorization header, never in an address, an error or a run
57
+ * record (WC-SECR-7). Nothing here retries. A read the caller may run again; a write is never sent twice, since the
58
+ * first may have landed (WC-OUT-20).
59
+ */
60
+ export const transport = (options) => {
61
+ const fetchOf = hostFetch({ hosts: DESKTOP.hosts ?? [], ...(options.fetch ? { fetch: options.fetch } : {}) });
62
+ const sleep = options.sleep ?? realSleep;
63
+ const now = options.now ?? Date.now;
64
+ const turn = async () => {
65
+ if (!options.pacer)
66
+ return;
67
+ const wait = (await options.pacer.reserve()) - now();
68
+ if (wait <= 0)
69
+ return;
70
+ if (wait > LONGEST_PACE_WAIT_MS)
71
+ throw new CliError("rate_limited", `this profile must wait ${Math.ceil(wait / 1000)} s before its next request`, {
72
+ retry_after_ms: wait,
73
+ });
74
+ await sleep(wait, options.signal, "retry");
75
+ };
76
+ const unanswered = (writes, error) => {
77
+ // Before the stop check: a write stopped in flight may still have landed (WC-LIFE-9).
78
+ if (writes)
79
+ return new CliError("outcome_unknown", `${SERVICE} did not answer a write; check it before repeating the write`, {
80
+ retryable: false,
81
+ });
82
+ if (options.signal?.aborted)
83
+ return new CliError("cancelled", `the ${SERVICE} request was stopped`);
84
+ const timedOut = error?.name === "TimeoutError";
85
+ return timedOut
86
+ ? new CliError("timeout", `${SERVICE} did not answer in time`, { retryable: true })
87
+ : new CliError("network_error", `${SERVICE} could not be reached`, { retryable: true });
88
+ };
89
+ const send = async (request, answer) => {
90
+ const writes = request.method !== "GET";
91
+ const url = urlOf(request);
92
+ await turn();
93
+ // Not AbortSignal.timeout: its timer keeps the run's async context alive until it fires.
94
+ const deadline = new AbortController();
95
+ const timer = setTimeout(() => deadline.abort(new DOMException("timed out", "TimeoutError")), options.timeoutMs ?? TIMEOUT_MS);
96
+ timer.unref();
97
+ const signal = options.signal ? AbortSignal.any([options.signal, deadline.signal]) : deadline.signal;
98
+ const end = providerRequest(`${request.method} /${request.path}`, options.events, {
99
+ method: request.method,
100
+ transport: "http",
101
+ });
102
+ try {
103
+ let response;
104
+ try {
105
+ response = await fetchOf(url, {
106
+ method: request.method,
107
+ headers: {
108
+ authorization: `Bearer ${options.token}`,
109
+ accept: "application/json",
110
+ ...(request.body ? { "content-type": "application/json" } : {}),
111
+ },
112
+ ...(request.body ? { body: JSON.stringify(request.body) } : {}),
113
+ // A redirect would carry the Authorization header to an address we did not choose.
114
+ redirect: "error",
115
+ signal,
116
+ });
117
+ }
118
+ catch (error) {
119
+ const failure = unanswered(writes, deadline.signal.reason ?? error);
120
+ end({ errorCode: failure.code });
121
+ throw failure;
122
+ }
123
+ if (!response.ok) {
124
+ const failure = failureOf(response.status, writes, providerWaitMs(response.headers, wallClock));
125
+ end({ status: response.status, errorCode: failure.code });
126
+ throw failure;
127
+ }
128
+ let body;
129
+ try {
130
+ body = await readJsonResponse(response, { maxBytes: LARGEST_ANSWER, signal });
131
+ }
132
+ catch (error) {
133
+ const failure = isCliError(error) && error.code !== "invalid_response"
134
+ ? error
135
+ : new CliError("invalid_response", `${SERVICE} answered with something other than bounded JSON`);
136
+ end({ status: response.status, errorCode: failure.code });
137
+ throw failure;
138
+ }
139
+ const parsed = v.safeParse(answer, body);
140
+ if (!parsed.success) {
141
+ end({ status: response.status, errorCode: "invalid_response" });
142
+ throw new CliError("invalid_response", `${SERVICE}'s answer does not have the documented shape`);
143
+ }
144
+ end({ status: response.status });
145
+ return parsed.output;
146
+ }
147
+ finally {
148
+ clearTimeout(timer);
149
+ }
150
+ };
151
+ return { send };
152
+ };
153
+ //# sourceMappingURL=transport.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transport.js","sourceRoot":"","sources":["../../src/sample/transport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,SAAS,EAAkB,SAAS,EAAE,MAAM,mBAAmB,CAAA;A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EAAE,CAAC,CAAA;YAC/E,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,MAAM,OAAO,GACX,UAAU,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,KAAK,kBAAkB;oBACpD,CAAC,CAAC,KAAK;oBACP,CAAC,CAAC,IAAI,QAAQ,CAAC,kBAAkB,EAAE,GAAG,OAAO,kDAAkD,CAAC,CAAA;gBACpG,GAAG,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC,CAAA;gBACzD,MAAM,OAAO,CAAA;YACf,CAAC;YACD,MAAM,MAAM,GAAG,CAAC,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;YACxC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;gBACpB,GAAG,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,MAAM,EAAE,SAAS,EAAE,kBAAkB,EAAE,CAAC,CAAA;gBAC/D,MAAM,IAAI,QAAQ,CAAC,kBAAkB,EAAE,GAAG,OAAO,8CAA8C,CAAC,CAAA;YAClG,CAAC;YACD,GAAG,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAA;YAChC,OAAO,MAAM,CAAC,MAAM,CAAA;QACtB,CAAC;gBAAS,CAAC;YACT,YAAY,CAAC,KAAK,CAAC,CAAA;QACrB,CAAC;IACH,CAAC,CAAA;IAED,OAAO,EAAE,IAAI,EAAE,CAAA;AACjB,CAAC,CAAA"}
@@ -0,0 +1,2 @@
1
+ export declare const amoSetup: import("@wirecat/cli-core/cli").Setup;
2
+ //# sourceMappingURL=flow.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flow.d.ts","sourceRoot":"","sources":["../../src/setup/flow.ts"],"names":[],"mappings":"AAmDA,eAAO,MAAM,QAAQ,uCAoFnB,CAAA"}
@@ -0,0 +1,127 @@
1
+ import { CliError } from "@wirecat/cli-base";
2
+ import { commandWords, defineSetup, refuseCommandName, refuseOffline, rootOf, } from "@wirecat/cli-core/cli";
3
+ import { accountOrigin } from "../amo/account.js";
4
+ import { appStorage } from "../amo/oauth.js";
5
+ import { checkedToken } from "../commands/session.js";
6
+ import { configuration } from "../config.js";
7
+ import { contextOf, storedSignIn, withAccount } from "../context.js";
8
+ import { IDENTITY } from "../identity.js";
9
+ import { accountUser } from "../whoami.js";
10
+ import en from "./texts.en.json" with { type: "json" };
11
+ import es from "./texts.es.json" with { type: "json" };
12
+ import ru from "./texts.ru.json" with { type: "json" };
13
+ /**
14
+ * The same proof `session start` runs, and the same sign-in it keeps: the address and the token's user beside the
15
+ * token. Editing a profile without a new token keeps the old one only for the same account.
16
+ */
17
+ const check = async ({ command, settings, secrets }) => {
18
+ // The guards `session start` runs before it signs in.
19
+ refuseCommandName(contextOf(command).profile, commandWords(rootOf(command)), IDENTITY.command);
20
+ refuseOffline(command, "the amoCRM account");
21
+ const origin = accountOrigin(String(settings.configured.host ?? ""));
22
+ const typed = secrets.token?.trim();
23
+ if (typed) {
24
+ const { who, signIn, account } = await checkedToken(command, origin, typed);
25
+ const { env, profile, keyring, tokens } = contextOf(command);
26
+ // A request prefers an integration's sign-in to the token, so it would hide the token just proven. The token is
27
+ // saved first, as `session start` does: a save that fails leaves the integration's sign-in in place.
28
+ tokens.write(profile, signIn);
29
+ appStorage(env, profile, keyring).remove();
30
+ return { ...who, keep: { secrets: { token: signIn }, account } };
31
+ }
32
+ const kept = storedSignIn(command);
33
+ if (kept?.origin !== origin)
34
+ throw new CliError("validation_error", `a new account needs its own token: ${new URL(origin).host}`, {
35
+ reason: "account.token-missing",
36
+ param: "token",
37
+ });
38
+ const who = await withAccount(command, accountUser);
39
+ return { ...who, keep: { account: `${who.account}:${who.user.id}` } };
40
+ };
41
+ const OAUTH_COMMAND = "amo <profile> session start --host https://<subdomain>.amocrm.ru --client-id <integration ID>";
42
+ export const amoSetup = defineSetup({
43
+ app: IDENTITY,
44
+ configuration,
45
+ check,
46
+ start: "account",
47
+ steps: {
48
+ account: {
49
+ title: "account.title",
50
+ blocks: [
51
+ { type: "text", text: "account.intro" },
52
+ {
53
+ type: "input",
54
+ id: "host",
55
+ setting: "host",
56
+ input: "text",
57
+ label: "account.host",
58
+ hint: "account.host.hint",
59
+ placeholder: "account.host.placeholder",
60
+ },
61
+ ],
62
+ next: "integration",
63
+ },
64
+ integration: {
65
+ title: "integration.title",
66
+ blocks: [
67
+ { type: "text", text: "integration.amocrm" },
68
+ { type: "note", role: "warning", text: "integration.waiver" },
69
+ {
70
+ type: "group",
71
+ role: "details",
72
+ title: "integration.kommo.title",
73
+ blocks: [{ type: "text", text: "integration.kommo" }],
74
+ },
75
+ ],
76
+ next: "token",
77
+ },
78
+ token: {
79
+ title: "token.title",
80
+ blocks: [
81
+ { type: "text", text: "token.where" },
82
+ { type: "input", id: "token", secret: "token", input: "password", label: "token.label", hint: "token.hint" },
83
+ { type: "note", role: "tip", text: "token.rights" },
84
+ ],
85
+ next: "check",
86
+ },
87
+ check: {
88
+ kind: "run",
89
+ title: "check.title",
90
+ action: "apply",
91
+ blocks: [{ type: "text", text: "check.body" }],
92
+ next: [
93
+ { when: { result: "check", is: "ok" }, to: "done" },
94
+ { when: { result: "check", error: "authentication_error" }, to: "token" },
95
+ { when: { result: "check", error: "validation_error" }, to: "account" },
96
+ { when: { result: "check", error: "conflict" }, to: "account" },
97
+ { to: "failed" },
98
+ ],
99
+ back: false,
100
+ },
101
+ failed: {
102
+ kind: "done",
103
+ title: "failed.title",
104
+ blocks: [{ type: "note", role: "danger", text: "failed.body" }],
105
+ back: true,
106
+ },
107
+ done: {
108
+ kind: "done",
109
+ title: "done.title",
110
+ blocks: [
111
+ { type: "text", text: "done.body" },
112
+ { type: "code", code: "amo <profile> sync\namo <profile> deals list status:open", copy: true },
113
+ {
114
+ type: "group",
115
+ role: "details",
116
+ title: "done.oauth.title",
117
+ blocks: [
118
+ { type: "text", text: "done.oauth" },
119
+ { type: "code", code: OAUTH_COMMAND, copy: true },
120
+ ],
121
+ },
122
+ ],
123
+ },
124
+ },
125
+ texts: { en, ru, es },
126
+ });
127
+ //# sourceMappingURL=flow.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flow.js","sourceRoot":"","sources":["../../src/setup/flow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAC5C,OAAO,EACL,YAAY,EACZ,WAAW,EACX,iBAAiB,EACjB,aAAa,EACb,MAAM,GAEP,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAC5C,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AACpE,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC1C,OAAO,EAAE,MAAM,iBAAiB,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAA;AACtD,OAAO,EAAE,MAAM,iBAAiB,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAA;AACtD,OAAO,EAAE,MAAM,iBAAiB,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAA;AAEtD;;;GAGG;AACH,MAAM,KAAK,GAAe,KAAK,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,EAAE;IACjE,sDAAsD;IACtD,iBAAiB,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,YAAY,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAA;IA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EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,0DAA0D,EAAE,IAAI,EAAE,IAAI,EAAE;gBAC9F;oBACE,IAAI,EAAE,OAAO;oBACb,IAAI,EAAE,SAAS;oBACf,KAAK,EAAE,kBAAkB;oBACzB,MAAM,EAAE;wBACN,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE;wBACpC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,IAAI,EAAE;qBAClD;iBACF;aACF;SACF;KACF;IACD,KAAK,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE;CACtB,CAAC,CAAA"}
@@ -0,0 +1,25 @@
1
+ {
2
+ "account.title": "Which account?",
3
+ "account.intro": "amo reads your deals and their clients from one amoCRM or Kommo account, and changes them only with your permission.",
4
+ "account.host": "Account address",
5
+ "account.host.hint": "The address you open the CRM at: https://<subdomain>.amocrm.ru, or https://<subdomain>.kommo.com for Kommo.",
6
+ "account.host.placeholder": "https://example.amocrm.ru",
7
+ "integration.title": "Create a private integration",
8
+ "integration.amocrm": "An account administrator does this once, in amoCRM:\n\n1. Open **амоМаркет**, click **⋯** at the top left and choose **«Создать интеграцию»**.\n2. Give it a name and a description, such as *WireCat*.\n3. As the Redirect URI, enter `https://wirecat.dev/webhooks/apps/amo-callback`. The token does not use it, but the same integration then also works for a browser sign-in later.\n4. Tick **«Доступ к данным аккаунта»** and save.\n\namoCRM's guide: https://www.amocrm.ru/developers/content/oauth/step-by-step",
9
+ "integration.waiver": "On an account that is not marked technical, amoCRM first asks you to sign a waiver of technical support for a private integration. amoCRM says it cannot be taken back. Read it before you sign: https://www.amocrm.ru/developers/content/integrations/intro",
10
+ "integration.kommo.title": "On Kommo",
11
+ "integration.kommo": "Settings → Integrations → **Create integration**, a private one. Use the same Redirect URI, then open its **Keys and scopes** tab.",
12
+ "token.title": "Make the token",
13
+ "token.where": "In the integration, open the **«Ключи»** tab (Kommo: **Keys and scopes**) and click **«Сгенерировать токен»**. Pick an end date, from one day to five years, and copy the token: it is shown only once.",
14
+ "token.label": "Long-lived token",
15
+ "token.hint": "Kept in your system keyring or, without one, in a file only you can read.",
16
+ "token.rights": "The token acts with the rights of the administrator who made it. amo stops agents' changes with its permissions: `amo <profile> config set permissions …`.",
17
+ "check.title": "Checking the token",
18
+ "check.body": "amo asks the account who the token belongs to. It saves the address and the token only if the account answers.",
19
+ "failed.title": "The check did not pass",
20
+ "failed.body": "The token or the account did not pass amo's check, so nothing was saved. Check the address, the token and your connection, then try again.",
21
+ "done.title": "Connected",
22
+ "done.body": "The profile is ready. Copy your deals and their clients into WireCat, then list the open ones:",
23
+ "done.oauth.title": "Advanced: sign in through the integration instead",
24
+ "done.oauth": "With the integration's ID and secret key, each person signs in in the browser and acts with their own rights. Run this in a terminal; the secret key is asked hidden:"
25
+ }
@@ -0,0 +1,25 @@
1
+ {
2
+ "account.title": "¿Qué cuenta?",
3
+ "account.intro": "amo lee tus negocios y sus clientes de una cuenta de amoCRM o Kommo, y solo los cambia con tu permiso.",
4
+ "account.host": "Dirección de la cuenta",
5
+ "account.host.hint": "La dirección con la que abres el CRM: https://<subdominio>.amocrm.ru, o https://<subdominio>.kommo.com en Kommo.",
6
+ "account.host.placeholder": "https://example.kommo.com",
7
+ "integration.title": "Crea una integración privada",
8
+ "integration.amocrm": "Lo hace una vez un administrador de la cuenta, en amoCRM:\n\n1. Abre **амоМаркет**, pulsa **⋯** arriba a la izquierda y elige **«Создать интеграцию»**.\n2. Ponle un nombre y una descripción, por ejemplo *WireCat*.\n3. Como Redirect URI, escribe `https://wirecat.dev/webhooks/apps/amo-callback`. El token no la usa, pero así la misma integración sirve también para entrar con el navegador.\n4. Marca **«Доступ к данным аккаунта»** y guarda.\n\nGuía de amoCRM: https://www.amocrm.ru/developers/content/oauth/step-by-step",
9
+ "integration.waiver": "En una cuenta no marcada como técnica, amoCRM pide antes firmar una renuncia al soporte técnico para una integración privada. Según amoCRM, no se puede revocar. Léela antes de firmar: https://www.amocrm.ru/developers/content/integrations/intro",
10
+ "integration.kommo.title": "En Kommo",
11
+ "integration.kommo": "Settings → Integrations → **Create integration**, privada (nombres de la interfaz de Kommo en inglés). Usa la misma Redirect URI y abre su pestaña **Keys and scopes**.",
12
+ "token.title": "Crea el token",
13
+ "token.where": "En la integración, abre la pestaña **«Ключи»** (en Kommo: **Keys and scopes**) y pulsa **«Сгенерировать токен»**. Elige una fecha de fin, de un día a cinco años, y copia el token: solo se muestra una vez.",
14
+ "token.label": "Token de larga duración",
15
+ "token.hint": "Se guarda en el llavero del sistema o, si no hay, en un archivo que solo tú puedes leer.",
16
+ "token.rights": "El token actúa con los permisos del administrador que lo creó. amo frena los cambios de los agentes con sus permisos: `amo <perfil> config set permissions …`.",
17
+ "check.title": "Comprobando el token",
18
+ "check.body": "amo pregunta a la cuenta de quién es el token. Guarda la dirección y el token solo si la cuenta responde.",
19
+ "failed.title": "La comprobación no pasó",
20
+ "failed.body": "El token o la cuenta no pasaron la comprobación de amo, así que no se guardó nada. Revisa la dirección, el token y la conexión, y vuelve a intentarlo.",
21
+ "done.title": "Conectado",
22
+ "done.body": "El perfil está listo. Copia tus negocios y sus clientes a WireCat y luego muestra los abiertos:",
23
+ "done.oauth.title": "Avanzado: entrar con la integración",
24
+ "done.oauth": "Con el ID y la clave secreta de la integración, cada persona entra en el navegador y actúa con sus propios permisos. Ejecútalo en una terminal; la clave secreta se pide oculta:"
25
+ }
@@ -0,0 +1,25 @@
1
+ {
2
+ "account.title": "Какой аккаунт?",
3
+ "account.intro": "amo читает ваши сделки и их клиентов из одного аккаунта amoCRM или Kommo и меняет их только с вашего разрешения.",
4
+ "account.host": "Адрес аккаунта",
5
+ "account.host.hint": "Адрес, по которому вы открываете CRM: https://<поддомен>.amocrm.ru, или https://<поддомен>.kommo.com для Kommo.",
6
+ "account.host.placeholder": "https://example.amocrm.ru",
7
+ "integration.title": "Создайте приватную интеграцию",
8
+ "integration.amocrm": "Это один раз делает администратор аккаунта в amoCRM:\n\n1. Откройте **амоМаркет**, нажмите **⋯** слева вверху и выберите **«Создать интеграцию»**.\n2. Укажите название и описание, например *WireCat*.\n3. В поле «Ссылка для перенаправления» впишите `https://wirecat.dev/webhooks/apps/amo-callback`. Токену она не нужна, но тогда та же интеграция подойдёт и для входа через браузер.\n4. Отметьте **«Доступ к данным аккаунта»** и сохраните.\n\nИнструкция amoCRM: https://www.amocrm.ru/developers/content/oauth/step-by-step",
9
+ "integration.waiver": "На аккаунте, не отмеченном как технический, amoCRM сначала просит подписать отказ от технической поддержки для приватной интеграции. По словам amoCRM, отозвать его нельзя. Прочитайте его до подписи: https://www.amocrm.ru/developers/content/integrations/intro",
10
+ "integration.kommo.title": "В Kommo",
11
+ "integration.kommo": "Settings → Integrations → **Create integration**, приватную (названия из английского интерфейса Kommo). Укажите ту же ссылку для перенаправления и откройте вкладку **Keys and scopes**.",
12
+ "token.title": "Получите токен",
13
+ "token.where": "В интеграции откройте вкладку **«Ключи»** (в Kommo: **Keys and scopes**) и нажмите **«Сгенерировать токен»**. Выберите дату окончания, от одного дня до пяти лет, и скопируйте токен: он показывается только один раз.",
14
+ "token.label": "Долгосрочный токен",
15
+ "token.hint": "Хранится в системной связке ключей, а без неё в файле, который можете прочитать только вы.",
16
+ "token.rights": "Токен действует с правами администратора, который его создал. Изменения агентов amo ограничивает разрешениями: `amo <профиль> config set permissions …`.",
17
+ "check.title": "Проверяем токен",
18
+ "check.body": "amo спрашивает у аккаунта, чей это токен. Адрес и токен сохранятся, только если аккаунт ответит.",
19
+ "failed.title": "Проверка не прошла",
20
+ "failed.body": "Токен или аккаунт не прошли проверку amo, поэтому ничего не сохранено. Проверьте адрес, токен и подключение и попробуйте ещё раз.",
21
+ "done.title": "Подключено",
22
+ "done.body": "Профиль готов. Скопируйте свои сделки и их клиентов в WireCat, затем выведите открытые:",
23
+ "done.oauth.title": "Для опытных: вход через интеграцию",
24
+ "done.oauth": "С ID и секретным ключом интеграции каждый входит в браузере и действует со своими правами. Выполните в терминале; секретный ключ спросят скрыто:"
25
+ }
@@ -0,0 +1,15 @@
1
+ import type { MessageStore } from "@wirecat/cli-core/store";
2
+ export declare const PROVIDER: {
3
+ readonly name: "amocrm";
4
+ readonly kind: "crm";
5
+ readonly aliases: readonly ["amo", "kommo"];
6
+ readonly command: string;
7
+ };
8
+ /**
9
+ * The shared store, with amo's provider entry written, so every other CLI's search knows it (WC-ARCH-21). A read-only
10
+ * open writes nothing, the entry included, and fails when the file is missing or needs a migration.
11
+ */
12
+ export declare const openAmoStore: (env: NodeJS.ProcessEnv, { readOnly }?: {
13
+ readOnly?: boolean | undefined;
14
+ }) => Promise<MessageStore>;
15
+ //# sourceMappingURL=store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../src/store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAG3D,eAAO,MAAM,QAAQ;aACnB,IAAI,EAAE,QAAQ;aACd,IAAI,EAAE,KAAK;aACX,OAAO,YAAG,KAAK,EAAE,OAAO;aACxB,OAAO;CACC,CAAA;AAEV;;;GAGG;AACH,eAAO,MAAM,YAAY,QAAe,MAAM,CAAC,UAAU;;MAA8B,OAAO,CAAC,YAAY,CAG1G,CAAA"}