@wirecat/bitrix24-cli 0.4.0 → 0.5.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 +78 -0
- package/README.md +84 -9
- package/dist/api-keys.d.ts +18 -13
- package/dist/api-keys.d.ts.map +1 -1
- package/dist/api-keys.js +79 -22
- package/dist/api-keys.js.map +1 -1
- package/dist/bin/b24.js +2 -2
- package/dist/bitrix/errors.js +1 -1
- package/dist/bitrix/errors.js.map +1 -1
- package/dist/bitrix/transport.d.ts +1 -1
- package/dist/bitrix/transport.d.ts.map +1 -1
- package/dist/bitrix/transport.js +20 -6
- package/dist/bitrix/transport.js.map +1 -1
- package/dist/body.d.ts +14 -0
- package/dist/body.d.ts.map +1 -0
- package/dist/body.js +44 -0
- package/dist/body.js.map +1 -0
- package/dist/bundle/{chunk-JAS3OZSP.js → all-profiles-CANIDIDS.js} +12 -7
- package/dist/bundle/{anthropic-QCYLKSJJ.js → anthropic-JUJB4DCF.js} +5 -5
- package/dist/bundle/{app-server-FSLZ2Y6N.js → app-server-3V5Z4PTK.js} +68 -54
- package/dist/bundle/b24.js +18 -12
- package/dist/bundle/{bun-UYRQXF33.js → bun-LKMV5TY7.js} +2 -2
- package/dist/bundle/{bun-sqlite-GXME7EMT.js → bun-sqlite-S56EF74S.js} +3 -3
- package/dist/bundle/{chunk-D2IRPC5I.js → chunk-2I4KWS3H.js} +6 -6
- package/dist/bundle/chunk-36PO5NWY.js +147 -0
- package/dist/bundle/{chunk-COOOXDKZ.js → chunk-42F7Q7V6.js} +3 -3
- package/dist/bundle/{chunk-POUSZWMP.js → chunk-4D3K6GZW.js} +18 -4
- package/dist/bundle/chunk-5D4MJQ6X.js +22 -0
- package/dist/bundle/chunk-5JOPERVF.js +84 -0
- package/dist/bundle/chunk-6A4UPWDC.js +15 -0
- package/dist/bundle/{chunk-O7FVOICH.js → chunk-6MGWIZG4.js} +1 -1
- package/dist/bundle/{chunk-B252WFK7.js → chunk-6YJTNZ7U.js} +13 -13
- package/dist/bundle/{chunk-2D5W4LWL.js → chunk-7FBFJ6B4.js} +4 -2
- package/dist/bundle/chunk-7VCMOTQP.js +55 -0
- package/dist/bundle/{chunk-6BLVBGRK.js → chunk-A5IMMGYU.js} +36 -34
- package/dist/bundle/{chunk-66QLBRIT.js → chunk-ASEHTBNK.js} +1 -1
- package/dist/bundle/{chunk-MY6FAZRA.js → chunk-B6LPJYPQ.js} +2 -2
- package/dist/bundle/{chunk-EQLWU6ZB.js → chunk-BHEE2K6C.js} +7 -7
- package/dist/bundle/chunk-BYZQBE63.js +971 -0
- package/dist/bundle/{chunk-J7OMY6EO.js → chunk-COKGNTDQ.js} +1477 -723
- package/dist/bundle/{chunk-QVZSLBR6.js → chunk-DVFYRQGE.js} +1 -1
- package/dist/bundle/{chunk-Q7Z5IMVY.js → chunk-DVSIBZ3G.js} +1 -1
- package/dist/bundle/chunk-EJEIXC6Y.js +273 -0
- package/dist/bundle/chunk-EYTGCM44.js +130 -0
- package/dist/bundle/{chunk-SBW2Y7AZ.js → chunk-EYYOKT23.js} +26 -26
- package/dist/bundle/{chunk-Y5PPMGCS.js → chunk-FCWPIWSR.js} +2 -2
- package/dist/bundle/{chunk-AOUNT22U.js → chunk-FSWRMQWX.js} +2 -2
- package/dist/bundle/{chunk-ADLS6FVG.js → chunk-FXBHOCJK.js} +1 -1
- package/dist/bundle/chunk-G5MW6RCM.js +723 -0
- package/dist/bundle/{chunk-4OVK5XW2.js → chunk-GLTKRLFT.js} +8 -8
- package/dist/bundle/chunk-GUUZQ7NE.js +581 -0
- package/dist/bundle/{chunk-XOPMSWFC.js → chunk-H6RIPOOI.js} +36 -3
- package/dist/bundle/{chunk-GTMCLOYY.js → chunk-HGFNC4CR.js} +1447 -430
- package/dist/bundle/{chunk-IF27EQN6.js → chunk-IERYD2N2.js} +6 -6
- package/dist/bundle/{chunk-Q4ILKTV4.js → chunk-IGCLMEMB.js} +3 -3
- package/dist/bundle/{chunk-2IZ6GGU2.js → chunk-J7WCSZ2Q.js} +410 -918
- package/dist/bundle/{chunk-CR3TLGM4.js → chunk-JZYHQ4HB.js} +3 -3
- package/dist/bundle/{chunk-XR5SUCAC.js → chunk-K4QM3X5F.js} +4 -4
- package/dist/bundle/{chunk-OWILUBCI.js → chunk-KFSMY7SZ.js} +2 -2
- package/dist/bundle/{chunk-AMVRNYD6.js → chunk-KPEDH5T4.js} +1 -1
- package/dist/bundle/{chunk-NEK7LKC6.js → chunk-KUY7LII2.js} +4 -4
- package/dist/bundle/{chunk-NDSOBIR3.js → chunk-LFXDHLFR.js} +3 -3
- package/dist/bundle/{chunk-ZU4HXKEW.js → chunk-LGLT4JB6.js} +3 -3
- package/dist/bundle/{chunk-EIGPMMGC.js → chunk-LM4OOBAW.js} +3 -3
- package/dist/bundle/chunk-M74BSKMA.js +234 -0
- package/dist/bundle/{chunk-MPI2FDJ4.js → chunk-MMMT6ORT.js} +11 -11
- package/dist/bundle/{chunk-F5NH3UJQ.js → chunk-NGYD6QTE.js} +2 -2
- package/dist/bundle/{chunk-6ERX33NC.js → chunk-NO6QOPVT.js} +10 -19
- package/dist/bundle/chunk-O6XC7DZI.js +804 -0
- package/dist/bundle/chunk-OE3NFB53.js +64 -0
- package/dist/bundle/{chunk-VTIUWHZ3.js → chunk-OUMFNB34.js} +13 -149
- package/dist/bundle/{chunk-VMQL4GNH.js → chunk-P2RQTNVJ.js} +806 -850
- package/dist/bundle/{chunk-XKQZLR2X.js → chunk-PBIBGIZ7.js} +1 -1
- package/dist/bundle/{chunk-YFZXI3NN.js → chunk-Q6VQHTRW.js} +2 -2
- package/dist/bundle/{chunk-OKDC6CLH.js → chunk-QHBCNVUG.js} +5 -5
- package/dist/bundle/{chunk-WJRBX5QB.js → chunk-QNOXAQ6Y.js} +4 -4
- package/dist/bundle/{chunk-GTFRSYYJ.js → chunk-R5F2O5GX.js} +7 -269
- package/dist/bundle/{chunk-OCRCVLZQ.js → chunk-R5PBSKJL.js} +1 -1
- package/dist/bundle/{chunk-JB7OXYAU.js → chunk-RS2BARUU.js} +4 -4
- package/dist/bundle/chunk-TG3DSPT5.js +14 -0
- package/dist/bundle/{chunk-UH56WLDS.js → chunk-U22JMKUO.js} +6 -125
- package/dist/bundle/chunk-U66Q5TVK.js +106 -0
- package/dist/bundle/{chunk-NWKXMMON.js → chunk-UCHMQWON.js} +136 -33
- package/dist/bundle/{chunk-DQIQIZQS.js → chunk-VMJS7FJZ.js} +451 -433
- package/dist/bundle/{chunk-IWEWDVZ6.js → chunk-VMVAQHDC.js} +77 -615
- package/dist/bundle/{chunk-M5XMAUGZ.js → chunk-WWMCJFMT.js} +2 -2
- package/dist/bundle/{chunk-OYLJHX74.js → chunk-XTA5TN3H.js} +1 -1
- package/dist/bundle/{chunk-ELBOQHJA.js → chunk-XUHHBEA7.js} +652 -131
- package/dist/bundle/{chunk-BHZ5VDDY.js → chunk-YDZHO4LT.js} +13 -13
- package/dist/bundle/{chunk-NKLLI4B2.js → chunk-ZKINZFIT.js} +6 -6
- package/dist/bundle/{chunk-GTDOUP6L.js → chunk-ZSQXSIFQ.js} +85 -38
- package/dist/bundle/{chunk-LAYH344Y.js → chunk-ZZEHDIEG.js} +58 -54
- package/dist/bundle/command-contract-OQV6H7SR.js +36 -0
- package/dist/bundle/{decode-IF2F2SFC.js → decode-QSTBX4MG.js} +3 -3
- package/dist/bundle/{echarts-WDDVEJO2.js → echarts-JZELFH2N.js} +2 -2
- package/dist/bundle/{embed-VDUGYEAR.js → embed-4RIW2LVH.js} +4 -4
- package/dist/bundle/{embedder-DUN62H3Z.js → embedder-SW7DTWSL.js} +7 -7
- package/dist/bundle/{first-run-NDGYBQEN.js → first-run-7AISOSOM.js} +8 -8
- package/dist/bundle/first-screen-NMHNFZ2B.js +34 -0
- package/dist/bundle/{instructions-JIIKWS7X.js → instructions-BZE5YUGG.js} +1 -1
- package/dist/bundle/{mcp-33JX6KP4.js → mcp-SDWHDJTY.js} +2 -2
- package/dist/bundle/{node-P4E63KXA.js → node-KM3CUABH.js} +9 -9
- package/dist/bundle/{node-K57WT42O.js → node-LTKZIO4U.js} +2 -2
- package/dist/bundle/{node-sqlite-KS6ORRIG.js → node-sqlite-HQ5PN2RH.js} +4 -4
- package/dist/bundle/{oauth-SLSANN37.js → oauth-UH6FOZQL.js} +5 -5
- package/dist/bundle/{open-WJPHADEX.js → open-TSUP3XGL.js} +3 -3
- package/dist/bundle/{openai-HXB3GTOD.js → openai-GVEE52E3.js} +14 -14
- package/dist/bundle/{process-P73TFAXT.js → process-AGXY76ZE.js} +1 -1
- package/dist/bundle/{program-7BMG5NIN.js → program-BI4A4HFJ.js} +1045 -1048
- package/dist/bundle/{prompt-WDPV37R4.js → prompt-NRSUY7FA.js} +3 -3
- package/dist/bundle/{recognize-CXIFL6IV.js → recognize-NPDPQ6PJ.js} +2 -2
- package/dist/bundle/{remote-Q4VJ4OQW.js → remote-HFASMVLB.js} +5 -5
- package/dist/bundle/{rerank-SUFYK63I.js → rerank-TL6Z6F7K.js} +5 -5
- package/dist/bundle/{chunk-XG6QKS7L.js → serve-VB4DHDZQ.js} +8 -6
- package/dist/bundle/server-T5EDRPJI.js +68 -0
- package/dist/bundle/{chunk-K7XWCZF6.js → server-Z6MW6C37.js} +50 -14
- package/dist/bundle/source-4IGO5J7E.js +237 -0
- package/dist/bundle/sqlite-runtime-YS4POY3W.js +17 -0
- package/dist/bundle/{state-EZCCXQV7.js → state-ISZVVZGR.js} +4 -4
- package/dist/bundle/store-IZJBAKJV.js +58 -0
- package/dist/bundle/{store-MZ7JBYR6.js → store-L76MSQC3.js} +17 -12
- package/dist/bundle/store-PBTIB7BD.js +207 -0
- package/dist/bundle/store-maintenance-command-YFKII7TF.js +58 -0
- package/dist/bundle/writer-3O5EYMFE.js +214 -0
- package/dist/commands/api.d.ts.map +1 -1
- package/dist/commands/api.js +34 -33
- package/dist/commands/api.js.map +1 -1
- package/dist/commands/crm-shared.d.ts +4 -0
- package/dist/commands/crm-shared.d.ts.map +1 -0
- package/dist/commands/crm-shared.js +94 -0
- package/dist/commands/crm-shared.js.map +1 -0
- package/dist/commands/crm-writes.d.ts +0 -1
- package/dist/commands/crm-writes.d.ts.map +1 -1
- package/dist/commands/crm-writes.js +31 -92
- package/dist/commands/crm-writes.js.map +1 -1
- package/dist/commands/crm.d.ts.map +1 -1
- package/dist/commands/crm.js +1 -45
- package/dist/commands/crm.js.map +1 -1
- package/dist/commands/session.d.ts.map +1 -1
- package/dist/commands/session.js +1 -0
- package/dist/commands/session.js.map +1 -1
- package/dist/commands/write.d.ts +1 -6
- package/dist/commands/write.d.ts.map +1 -1
- package/dist/commands/write.js +7 -16
- package/dist/commands/write.js.map +1 -1
- package/dist/config.d.ts +0 -5
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +6 -9
- package/dist/config.js.map +1 -1
- package/dist/crm/capabilities.d.ts +7 -0
- package/dist/crm/capabilities.d.ts.map +1 -0
- package/dist/crm/capabilities.js +7 -0
- package/dist/crm/capabilities.js.map +1 -0
- package/dist/crm/conditions.d.ts +1 -1
- package/dist/crm/conditions.d.ts.map +1 -1
- package/dist/crm/conditions.js +3 -5
- package/dist/crm/conditions.js.map +1 -1
- package/dist/crm/custom-query.d.ts +1 -1
- package/dist/crm/custom-query.d.ts.map +1 -1
- package/dist/crm/custom-query.js +2 -2
- package/dist/crm/custom-query.js.map +1 -1
- package/dist/crm/deal.d.ts +4 -28
- package/dist/crm/deal.d.ts.map +1 -1
- package/dist/crm/deal.js +15 -48
- package/dist/crm/deal.js.map +1 -1
- package/dist/crm/fields.d.ts +2 -26
- package/dist/crm/fields.d.ts.map +1 -1
- package/dist/crm/fields.js +2 -67
- package/dist/crm/fields.js.map +1 -1
- package/dist/crm/items.d.ts.map +1 -1
- package/dist/crm/items.js +6 -5
- package/dist/crm/items.js.map +1 -1
- package/dist/crm/lead.d.ts +5 -37
- package/dist/crm/lead.d.ts.map +1 -1
- package/dist/crm/lead.js +15 -61
- package/dist/crm/lead.js.map +1 -1
- package/dist/crm/pipelines.d.ts +5 -0
- package/dist/crm/pipelines.d.ts.map +1 -0
- package/dist/crm/pipelines.js +54 -0
- package/dist/crm/pipelines.js.map +1 -0
- package/dist/crm/product.d.ts.map +1 -1
- package/dist/crm/product.js +2 -2
- package/dist/crm/product.js.map +1 -1
- package/dist/crm/rest3-fields.d.ts +3 -0
- package/dist/crm/rest3-fields.d.ts.map +1 -0
- package/dist/crm/rest3-fields.js +38 -0
- package/dist/crm/rest3-fields.js.map +1 -0
- package/dist/crm/source.d.ts +15 -0
- package/dist/crm/source.d.ts.map +1 -0
- package/dist/crm/source.js +122 -0
- package/dist/crm/source.js.map +1 -0
- package/dist/crm/user.d.ts.map +1 -1
- package/dist/crm/user.js +2 -2
- package/dist/crm/user.js.map +1 -1
- package/dist/crm/values.d.ts +19 -4
- package/dist/crm/values.d.ts.map +1 -1
- package/dist/crm/values.js +28 -2
- package/dist/crm/values.js.map +1 -1
- package/dist/crm/writer.d.ts +9 -0
- package/dist/crm/writer.d.ts.map +1 -0
- package/dist/crm/writer.js +119 -0
- package/dist/crm/writer.js.map +1 -0
- package/dist/program.d.ts.map +1 -1
- package/dist/program.js +51 -6
- package/dist/program.js.map +1 -1
- package/dist/store.d.ts +15 -0
- package/dist/store.d.ts.map +1 -0
- package/dist/store.js +33 -0
- package/dist/store.js.map +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +4 -6
- package/skills/bitrix24-cli/SKILL.md +16 -15
- package/dist/bundle/all-profiles-MBQZCOVK.js +0 -24
- package/dist/bundle/chunk-UCLWWSQK.js +0 -48
- package/dist/bundle/command-contract-UON4EIC4.js +0 -30
- package/dist/bundle/first-screen-QAVKP5RF.js +0 -28
- package/dist/bundle/mcp-57EQ6QJO.js +0 -171
- package/dist/bundle/mcp-PFJER2DE.js +0 -87
- package/dist/bundle/serve-B7PGFOC2.js +0 -19
- package/dist/bundle/server-4DBNJWW6.js +0 -58
- package/dist/bundle/server-OKE7SXJ2.js +0 -45
- package/dist/bundle/store-maintenance-command-T5QZMENJ.js +0 -47
- package/dist/commands/doctor.d.ts +0 -77
- package/dist/commands/doctor.d.ts.map +0 -1
- package/dist/commands/doctor.js +0 -74
- package/dist/commands/doctor.js.map +0 -1
- package/dist/commands/fields.d.ts +0 -3
- package/dist/commands/fields.d.ts.map +0 -1
- package/dist/commands/fields.js +0 -45
- package/dist/commands/fields.js.map +0 -1
- package/dist/commands/mcp.d.ts +0 -3
- package/dist/commands/mcp.d.ts.map +0 -1
- package/dist/commands/mcp.js +0 -97
- package/dist/commands/mcp.js.map +0 -1
- package/dist/crm/pipeline.d.ts +0 -17
- package/dist/crm/pipeline.d.ts.map +0 -1
- package/dist/crm/pipeline.js +0 -42
- package/dist/crm/pipeline.js.map +0 -1
- package/dist/crm/stage.d.ts +0 -20
- package/dist/crm/stage.d.ts.map +0 -1
- package/dist/crm/stage.js +0 -65
- package/dist/crm/stage.js.map +0 -1
- package/dist/mcp.d.ts +0 -29
- package/dist/mcp.d.ts.map +0 -1
- package/dist/mcp.js +0 -102
- package/dist/mcp.js.map +0 -1
- /package/dist/bundle/{chunk-NDTJE6JQ.js → chunk-ZQ3GWKDQ.js} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,84 @@
|
|
|
2
2
|
|
|
3
3
|
Notable changes to `@wirecat/bitrix24-cli`. One section per version, newest first.
|
|
4
4
|
|
|
5
|
+
## 0.5.0 — 07.11.2026
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- `sync` copies the portal's pipelines, companies, contacts, deals and leads into the local WireCat store: what changed
|
|
10
|
+
since the last sync, or everything with `--rescan`; once a day it also finds what the portal deleted. `store status`
|
|
11
|
+
says how far each kind is. A sync stops before its deadline or `--max-pages`, and the next one goes on from there.
|
|
12
|
+
- `deals close <ref> won|lost` and `leads close`, to the first won or lost stage of the record's pipeline, and
|
|
13
|
+
`deals delete` and `leads delete`, which ask first.
|
|
14
|
+
- `deals create` and `update` take `--pipeline`, `--stage`, `--amount` with `--currency`, `--close-date` and
|
|
15
|
+
`--owner`; leads take the same but `--close-date`. A stage checks the move key, a won or lost one the close key too.
|
|
16
|
+
- `search all` finds stored deals and leads beside the other WireCat tools' messages, notes and events. Under
|
|
17
|
+
`deals.list: deny` it leaves deals out and names them in `missing` and on stderr, and the same for leads; with every
|
|
18
|
+
kind it was asked for denied, it is refused (`search.all-denied`).
|
|
19
|
+
- `b24 --help` and a bare `b24` open with what `b24` is for, what to try first, and where to start.
|
|
20
|
+
|
|
21
|
+
### Changed — may break callers
|
|
22
|
+
|
|
23
|
+
- `deals`, `leads`, `pipelines` and `stages` are cli-core's shared CRM commands, the same in every WireCat CRM tool.
|
|
24
|
+
Their lists and `show` read the local store, so run `sync` first; `--offline` works for them now.
|
|
25
|
+
- A deal or lead is named by its ref, `deal:12` or `lead:7`, as a list prints it, not by its Bitrix24 id or title.
|
|
26
|
+
- A deal or lead answers `ref`, `pipeline` and `pipeline_name`, `stage` (its name), `status` (`open`, `won` or `lost`),
|
|
27
|
+
`close_date`, `amount` as a decimal string in `currency`, both `null` with no amount, `assignee` as
|
|
28
|
+
`<portal>/user/<id>`, and the portal's own fields in `provider_metadata` by code. `stage_id`, `pipeline_id`,
|
|
29
|
+
`outcome`, `closes_on`, `assigned_to` and `person_ids` are gone from them; contacts are in `people`, the company in
|
|
30
|
+
`organization`.
|
|
31
|
+
- Their list query takes `status`, `stage`, `pipeline` and `organization`; the free word, the time windows and the
|
|
32
|
+
portal's own fields are gone from it. `--all` is gone from those lists.
|
|
33
|
+
- `deals move <ref> <stage>` takes the stage as an argument, not `--stage`.
|
|
34
|
+
- Deal and lead writes have no `--body`. `--field <label or code>=<value>` sets a custom field by the definitions the
|
|
35
|
+
last `sync` stored: a list field takes its option's label or id, a multiple field one `--field` per value, and an
|
|
36
|
+
empty value clears it. A code that names a standard field (`stageId`, `categoryId`, `assignedById`, a lead's
|
|
37
|
+
`STATUS_ID`) is refused, and so is a `--field` with no key before its `=`.
|
|
38
|
+
- A custom field's label and a list option's label are matched as cli-core matches names, for every `--field` and
|
|
39
|
+
query: `е` finds `ё`, and a letter typed as two code points finds the same letter typed as one. `people show` and
|
|
40
|
+
`organizations show` compare a name with the portal's matches the same way. A label that matched one field may now
|
|
41
|
+
match two, which is refused with both.
|
|
42
|
+
- `fields list <deals|leads|people|organizations>` is cli-core's: it reads the definitions `sync` stored, so run
|
|
43
|
+
`sync` first, and each field names its `untrusted` parts.
|
|
44
|
+
- `api.crm.deal.update` (and the other deal and lead `api.*` keys) at `ask` now asks on `deals update`, `move` and
|
|
45
|
+
`close` too, not only on `api call`. `--dry-run` of a deal or lead write names every key it may check: the
|
|
46
|
+
`api.*` key, and the move, close and `crm.assign-others` keys with the option that would make each apply.
|
|
47
|
+
- `sync` reads the portal's field definitions of each kind, one more request per kind, so `--max-pages` reaches the
|
|
48
|
+
records later. A webhook without the rights to read them still syncs; any other failure there fails the sync.
|
|
49
|
+
- Leads stand in one pipeline named `Leads`, since Bitrix24's leads have none.
|
|
50
|
+
- `deals.delete` and `leads.delete` default to `ask`; `api call` that sets a stage checks `deals.close` (or
|
|
51
|
+
`leads.close`) as well as `deals.move`.
|
|
52
|
+
- `mcp` and `doctor` are cli-core's shared commands: `mcp` adds `config`, `add` and `check`, and `--profiles` and
|
|
53
|
+
`--permission` on `serve`; `doctor` adds `--online`.
|
|
54
|
+
- A `--body` or `api call` method that could be read in more than one way is refused before anything is sent: a
|
|
55
|
+
body that names one field twice in any spelling, an `entityTypeId` that is not a plain number, a `fields` that is
|
|
56
|
+
not an object, a method with any suffix but one `.json`, and a `crm.item` method without `entityTypeId`. Send each
|
|
57
|
+
field once, under one spelling.
|
|
58
|
+
- `--operation-id` is gone from every write. On a live portal a create repeated with the same id made a second
|
|
59
|
+
record, so a repeat is never safe: after `outcome_unknown`, `sync` and `show` the record and write it again only if
|
|
60
|
+
it is not there. A deal or lead write given `--operation-id` is refused before anything is sent.
|
|
61
|
+
|
|
62
|
+
### Fixed
|
|
63
|
+
|
|
64
|
+
- A `sync` after the first one works. It asked the portal for what changed with a time the portal refuses, so
|
|
65
|
+
every kind failed and nothing new was copied. Times in a filter now go in whole seconds with an offset, which also
|
|
66
|
+
fixes `updated_at:` and `created_at:` in `people list` and `organizations list`.
|
|
67
|
+
- A write answered with a server or gateway failure (500, 502, 504) is `outcome_unknown`, not `provider_unavailable`:
|
|
68
|
+
the portal may have made it. A write a cancel cuts is `outcome_unknown` too, never `cancelled`.
|
|
69
|
+
- Stages are read page by page: a directory past REST 2's first 50 rows lost its later stages.
|
|
70
|
+
- An id or owner that is not a number is refused before anything is sent; it went out empty before.
|
|
71
|
+
- `--body` keeps integers past 2^53 as typed; `api call --body -` reads the body from stdin.
|
|
72
|
+
- A request that gets no answer is cut after 10 seconds, not 30, so a read can be tried again before a one-shot
|
|
73
|
+
command's own 30 s run out.
|
|
74
|
+
- `show` for people and organizations fails when the portal's field labels fail for a reason other than missing
|
|
75
|
+
rights, instead of showing the record without its labels.
|
|
76
|
+
|
|
77
|
+
### Security
|
|
78
|
+
|
|
79
|
+
- Permission checks on `api call` and on `people` and `organizations` writes read a body exactly as it is sent, so
|
|
80
|
+
the key they check is the key the write needs.
|
|
81
|
+
- `api call` reads check the same keys as the commands that read those records, as its writes already did.
|
|
82
|
+
|
|
5
83
|
## 0.4.0 — 06.11.2026
|
|
6
84
|
|
|
7
85
|
### Added
|
package/README.md
CHANGED
|
@@ -1,18 +1,93 @@
|
|
|
1
|
-
# b24
|
|
1
|
+
# b24 — Bitrix24 CRM CLI for AI agents
|
|
2
2
|
|
|
3
3
|
`b24` reads and changes a Bitrix24 portal's sales data from the terminal, from scripts and from AI agents: deals,
|
|
4
4
|
leads, contacts, companies, pipelines and their stages, products and employees. It signs in with one of the portal's
|
|
5
|
-
incoming webhooks and acts with the rights of the employee who made it.
|
|
5
|
+
incoming webhooks and acts with the rights of the employee who made it. Deals and leads are copied into the local
|
|
6
|
+
[WireCat](https://wirecat.dev) store, so lists and search work offline, beside your other WireCat tools' data.
|
|
7
|
+
|
|
8
|
+
## Quick start
|
|
6
9
|
|
|
7
10
|
```sh
|
|
8
11
|
npm install -g @wirecat/bitrix24-cli
|
|
12
|
+
b24 skill install # the agent skill, for Claude Code, Codex, Gemini CLI and OpenClaw
|
|
9
13
|
b24 work session start # paste the webhook address; it is kept in the keyring
|
|
10
|
-
b24 work deals
|
|
11
|
-
b24 work
|
|
12
|
-
|
|
14
|
+
b24 work sync # copies pipelines, companies, contacts, deals and leads into the local store
|
|
15
|
+
b24 work deals list status:open
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
`work` is a profile: a name you choose for one portal. It is the first word of every command that uses an account,
|
|
19
|
+
and none is ever assumed. Make the webhook in Bitrix24 under Developer resources → Other → Incoming webhook, with the
|
|
20
|
+
scopes `crm` and `user`. You need Node.js 22.16 or a later 22.x, or Node.js 24 or later. `b24 doctor` needs no
|
|
21
|
+
network and shows what is set up.
|
|
22
|
+
|
|
23
|
+
More: [installation](docs/installation.md), [usage](docs/usage.md).
|
|
24
|
+
|
|
25
|
+
## What you can do
|
|
26
|
+
|
|
27
|
+
```sh
|
|
28
|
+
b24 work leads list stage:"In progress" --json # from the store, offline too
|
|
29
|
+
b24 work deals move deal:42 "Contract signed" # checks deals.move, and deals.close for a won or lost stage
|
|
30
|
+
b24 work search all kitchen # stored deals and leads beside your other WireCat data
|
|
31
|
+
b24 work people update 4 --body '{"post":"Buyer"}' # a contact, in Bitrix24's own field names
|
|
32
|
+
b24 work api call crm.deal.fields --dry-run # any REST method, with every permission it checks
|
|
13
33
|
```
|
|
14
34
|
|
|
15
|
-
Every
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
35
|
+
Every write answers an `operation_id` and can be previewed with `--dry-run`. More: [usage](docs/usage.md) and the
|
|
36
|
+
[command reference](docs/commands.md).
|
|
37
|
+
|
|
38
|
+
## For AI agents
|
|
39
|
+
|
|
40
|
+
- **An agent with a terminal** (Claude Code, Codex, Gemini CLI, OpenClaw): `b24 skill install` writes the skill, the
|
|
41
|
+
agent's instruction sheet.
|
|
42
|
+
- **An MCP client**: `b24 work mcp serve`, or `b24 work mcp add claude-code`. `mcp serve --permission deals=deny`
|
|
43
|
+
tightens the levels for one server; an agent can never loosen them.
|
|
44
|
+
- **ChatGPT or Claude in a browser**: `b24 work mcp serve --http` behind your own tunnel.
|
|
45
|
+
|
|
46
|
+
Text from the portal is marked `untrusted` in MCP answers: it is data for the agent, never instructions. `api call`
|
|
47
|
+
and `session start`/`end` are never offered over MCP. With `--json`, every command prints one JSON value, and an error
|
|
48
|
+
comes as JSON with a code to branch on.
|
|
49
|
+
|
|
50
|
+
More: [agents](docs/usage.md#agents).
|
|
51
|
+
|
|
52
|
+
## Settings and permissions
|
|
53
|
+
|
|
54
|
+
Each profile has a permission level for every command and every REST method: `allow`, `ask`, `readonly` or `deny`.
|
|
55
|
+
Assigning a record to another employee is denied until you allow it, a delete asks first, and methods that message
|
|
56
|
+
people, publish or start the portal's automation are denied, reads too. A stage change can start the portal's own
|
|
57
|
+
robots, which may write to your clients: set `permissions.deals.move` to `ask` if your portal has such robots.
|
|
58
|
+
`B24_READ_ONLY=1` refuses every write.
|
|
59
|
+
|
|
60
|
+
More: [settings](docs/configuration.md#permissions), [security](docs/security.md).
|
|
61
|
+
|
|
62
|
+
## Limits
|
|
63
|
+
|
|
64
|
+
- The portal allows about 2 requests a second for all its apps together; `b24` keeps to that pace.
|
|
65
|
+
- `people`, `organizations`, `products`, `users` and `fields` still ask the portal on every read and refuse
|
|
66
|
+
`--offline`.
|
|
67
|
+
- Bitrix24 does a repeated write again: on a live portal, a create repeated with the same `Idempotency-Key` made a
|
|
68
|
+
second record. After an `outcome_unknown`, look at the record before you write it again.
|
|
69
|
+
|
|
70
|
+
## Security
|
|
71
|
+
|
|
72
|
+
The webhook address is the password: anyone who has it can do what its employee can. `b24` keeps it in the system
|
|
73
|
+
keyring and never prints it, in output, errors or run records. Report a vulnerability as [SECURITY.md](SECURITY.md)
|
|
74
|
+
says.
|
|
75
|
+
|
|
76
|
+
## When it does not work
|
|
77
|
+
|
|
78
|
+
Start with `b24 doctor`, then [troubleshooting](docs/troubleshooting.md).
|
|
79
|
+
|
|
80
|
+
## Documentation
|
|
81
|
+
|
|
82
|
+
- [Install](docs/installation.md) · [Use it](docs/usage.md) · [Settings](docs/configuration.md) ·
|
|
83
|
+
[Security](docs/security.md) · [Commands](docs/commands.md) · [Troubleshooting](docs/troubleshooting.md)
|
|
84
|
+
- The design: [docs/dev/DESIGN.md](docs/dev/DESIGN.md).
|
|
85
|
+
|
|
86
|
+
## Part of WireCat
|
|
87
|
+
|
|
88
|
+
`b24` is one of the [WireCat](https://wirecat.dev) tools. They share one local store, so `search all` and an agent see
|
|
89
|
+
your CRM beside your messages, mail, notes and meetings.
|
|
90
|
+
|
|
91
|
+
## License
|
|
92
|
+
|
|
93
|
+
[Apache-2.0](LICENSE).
|
package/dist/api-keys.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import type { DealKind } from "@wirecat/cli-core";
|
|
2
|
+
import type { CrmVerb } from "@wirecat/cli-core/crm";
|
|
1
3
|
import type { Level } from "@wirecat/cli-core/sends";
|
|
2
4
|
import { type Effect } from "./bitrix/methods.js";
|
|
5
|
+
import { type Body } from "./body.js";
|
|
3
6
|
export declare const apiKey: (method: string) => string;
|
|
4
7
|
/**
|
|
5
8
|
* Families whose writes reach people, publish, or start the portal's own automation: messages and notifications (im,
|
|
@@ -11,31 +14,33 @@ export declare const apiKey: (method: string) => string;
|
|
|
11
14
|
export declare const DENIED_FAMILIES: string[];
|
|
12
15
|
/** Bitrix24 takes a method in any letter case and with a `.json` suffix; one name keeps the keys from being dodged. */
|
|
13
16
|
export declare const normalMethod: (raw: string) => string;
|
|
14
|
-
/** A field in any letter case, with or without underscores:
|
|
15
|
-
export declare const fieldOf: (record:
|
|
16
|
-
export declare const fieldsOf: (body:
|
|
17
|
+
/** A field in any letter case, with or without underscores: `parseBody` has refused a body that spells one twice. */
|
|
18
|
+
export declare const fieldOf: (record: Body, name: string) => unknown;
|
|
19
|
+
export declare const fieldsOf: (body: Body) => Record<string, unknown>;
|
|
17
20
|
/** The employee a write assigns the record to, by any spelling of `assignedById`. */
|
|
18
|
-
export declare const assigneeOf: (fields:
|
|
21
|
+
export declare const assigneeOf: (fields: Body) => string | undefined;
|
|
19
22
|
/** Whether a write changes a deal's or a lead's stage: `stageId`, or a lead's REST 2 `STATUS_ID`. */
|
|
20
23
|
export declare const setsStage: (type: string, fields: Record<string, unknown>) => boolean;
|
|
24
|
+
/** What `api call` sends, checked once: the body `parseBody` gave, its `fields` an object and its type a number. */
|
|
25
|
+
export declare const checkCall: (method: string, body: Body) => void;
|
|
21
26
|
/**
|
|
22
|
-
* The command keys a raw call does the same as, so `api call` cannot get round `deals
|
|
23
|
-
* `WRITE_METHODS
|
|
27
|
+
* The command keys a raw call does the same as, so `api call` cannot get round `deals: deny` (gcal-cli's
|
|
28
|
+
* `WRITE_METHODS`, WC-PERM-22). A create or update that sets a stage is a move too.
|
|
24
29
|
*/
|
|
25
|
-
export declare const commandKeysOf: (method: string, body?:
|
|
26
|
-
/** The command keys a CRM write command checks beside its own: `.move` when its fields set a stage. */
|
|
27
|
-
export declare const stageKeysOf: (noun: string, fields: Record<string, unknown>) => string[];
|
|
30
|
+
export declare const commandKeysOf: (method: string, body?: Body) => string[];
|
|
28
31
|
/**
|
|
29
32
|
* A method's default, as WC-PERM-22 has it, from an allow list: the reads `b24` makes and the CRM writes the command
|
|
30
33
|
* keys govern are allowed, a delete and anything else asks, and the families that reach people are denied, reads too.
|
|
31
34
|
*/
|
|
32
|
-
export declare const apiDefault: (method: string, effect?: Effect, body?:
|
|
35
|
+
export declare const apiDefault: (method: string, effect?: Effect, body?: Body) => Level;
|
|
33
36
|
/** The built-in levels with this call's own key, which the static table cannot list for every method. */
|
|
34
|
-
export declare const callDefaults: (method: string, effect: Effect, body:
|
|
37
|
+
export declare const callDefaults: (method: string, effect: Effect, body: Body, defaults: Readonly<Record<string, Level>>) => Record<string, Level>;
|
|
35
38
|
/**
|
|
36
|
-
* The
|
|
37
|
-
*
|
|
39
|
+
* The `api.*` key a deal's or lead's write sends its request under, so `api.crm.deal.update: deny` holds on `deals
|
|
40
|
+
* update` too: core's `CrmWrites.alsoChecks` and, through `crmAlsoChecks`, its `--dry-run`.
|
|
38
41
|
*/
|
|
42
|
+
export declare const crmApiKeys: (kind: DealKind, verb: CrmVerb) => string[];
|
|
43
|
+
/** The same for b24's own `people` and `organizations` writes, by command path. */
|
|
39
44
|
export declare const apiKeysOf: (path: readonly string[]) => string[];
|
|
40
45
|
/** The keys `permissions` may name for `api`: the known methods and the denied families. */
|
|
41
46
|
export declare const API_KEYS: string[];
|
package/dist/api-keys.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-keys.d.ts","sourceRoot":"","sources":["../src/api-keys.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"api-keys.d.ts","sourceRoot":"","sources":["../src/api-keys.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAA;AACpD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAA;AACpD,OAAO,EAAE,KAAK,MAAM,EAA2B,MAAM,qBAAqB,CAAA;AAC1E,OAAO,EAAE,KAAK,IAAI,EAAkC,MAAM,WAAW,CAAA;AAErE,eAAO,MAAM,MAAM,WAAY,MAAM,KAAG,MAAyB,CAAA;AAEjE;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,UAoB3B,CAAA;AAQD,uHAAuH;AACvH,eAAO,MAAM,YAAY,QAAS,MAAM,KAAG,MAAkD,CAAA;AAE7F,qHAAqH;AACrH,eAAO,MAAM,OAAO,WAAY,IAAI,QAAQ,MAAM,KAAG,OAIpD,CAAA;AAED,eAAO,MAAM,QAAQ,SAAU,IAAI,KAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAG3D,CAAA;AAED,qFAAqF;AACrF,eAAO,MAAM,UAAU,WAAY,IAAI,KAAG,MAAM,GAAG,SAGlD,CAAA;AAED,qGAAqG;AACrG,eAAO,MAAM,SAAS,SAAU,MAAM,UAAU,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAG,OAEoC,CAAA;AAoB9G,oHAAoH;AACpH,eAAO,MAAM,SAAS,WAAY,MAAM,QAAQ,IAAI,KAAG,IAMtD,CAAA;AAoCD;;;GAGG;AACH,eAAO,MAAM,aAAa,WAAY,MAAM,SAAQ,IAAI,KAAQ,MAAM,EASrE,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,UAAU,WAAY,MAAM,WAAU,MAAM,SAAkC,IAAI,KAAQ,KAKtG,CAAA;AAED,yGAAyG;AACzG,eAAO,MAAM,YAAY,WACf,MAAM,UACN,MAAM,QACR,IAAI,YACA,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,KACxC,MAAM,CAAC,MAAM,EAAE,KAAK,CAA0E,CAAA;AAUjG;;;GAGG;AACH,eAAO,MAAM,UAAU,SAAU,QAAQ,QAAQ,OAAO,KAAG,MAAM,EAA8C,CAAA;AAI/G,mFAAmF;AACnF,eAAO,MAAM,SAAS,SAAU,SAAS,MAAM,EAAE,KAAG,MAAM,EAKzD,CAAA;AAED,4FAA4F;AAC5F,eAAO,MAAM,QAAQ,UAAoF,CAAA;AAEzG,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAQ9C,CAAA"}
|
package/dist/api-keys.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { CliError } from "@wirecat/cli-base";
|
|
1
2
|
import { KNOWN_METHODS, methodOf } from "./bitrix/methods.js";
|
|
3
|
+
import { foldCode, isRecord, jsonNumber } from "./body.js";
|
|
2
4
|
export const apiKey = (method) => `api.${method}`;
|
|
3
5
|
/**
|
|
4
6
|
* Families whose writes reach people, publish, or start the portal's own automation: messages and notifications (im,
|
|
@@ -33,15 +35,15 @@ const READ_FAMILIES = ["crm", "catalog", "user", "profile", "methods", "method",
|
|
|
33
35
|
const inFamily = (families, method) => families.some((family) => method === family || method.startsWith(`${family}.`));
|
|
34
36
|
/** Bitrix24 takes a method in any letter case and with a `.json` suffix; one name keeps the keys from being dodged. */
|
|
35
37
|
export const normalMethod = (raw) => raw.toLowerCase().replace(/\.json$/, "");
|
|
36
|
-
/** A field in any letter case, with or without underscores:
|
|
38
|
+
/** A field in any letter case, with or without underscores: `parseBody` has refused a body that spells one twice. */
|
|
37
39
|
export const fieldOf = (record, name) => {
|
|
38
|
-
const wanted = name
|
|
39
|
-
const found = Object.keys(record).find((one) => one
|
|
40
|
+
const wanted = foldCode(name);
|
|
41
|
+
const found = Object.keys(record).find((one) => foldCode(one) === wanted);
|
|
40
42
|
return found === undefined ? undefined : record[found];
|
|
41
43
|
};
|
|
42
44
|
export const fieldsOf = (body) => {
|
|
43
45
|
const fields = fieldOf(body, "fields");
|
|
44
|
-
return
|
|
46
|
+
return isRecord(fields) ? fields : {};
|
|
45
47
|
};
|
|
46
48
|
/** The employee a write assigns the record to, by any spelling of `assignedById`. */
|
|
47
49
|
export const assigneeOf = (fields) => {
|
|
@@ -55,34 +57,80 @@ const NOUNS = { deal: "deals", lead: "leads", contact: "people", company: "organ
|
|
|
55
57
|
const ACTIONS = { add: "create", update: "update", delete: "delete" };
|
|
56
58
|
/** `crm.item.*`'s `entityTypeId` for the four types the commands cover (apidocs "crm.item.add"). */
|
|
57
59
|
const ENTITY_TYPES = { "1": "lead", "2": "deal", "3": "contact", "4": "company" };
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
60
|
+
const refused = (message) => new CliError("validation_error", message, { param: "--body", reason: "body.invalid", sent: false });
|
|
61
|
+
/** `"02"`, `" 2"` or `"2.0"` would name no type here while the portal may read them as deals: only digits pass. */
|
|
62
|
+
const entityTypeOf = (body) => {
|
|
63
|
+
const given = fieldOf(body, "entityTypeId");
|
|
64
|
+
if (given === undefined)
|
|
65
|
+
return undefined;
|
|
66
|
+
const digits = jsonNumber(given) ?? (typeof given === "string" ? given : typeof given === "number" ? String(given) : "");
|
|
67
|
+
if (!/^(0|[1-9][0-9]*)$/.test(digits))
|
|
68
|
+
throw refused("entityTypeId takes the type's number, such as 2 for deals");
|
|
69
|
+
return digits;
|
|
70
|
+
};
|
|
71
|
+
/** What `api call` sends, checked once: the body `parseBody` gave, its `fields` an object and its type a number. */
|
|
72
|
+
export const checkCall = (method, body) => {
|
|
73
|
+
entityTypeOf(body);
|
|
74
|
+
const fields = fieldOf(body, "fields");
|
|
75
|
+
if (fields !== undefined && !isRecord(fields))
|
|
76
|
+
throw refused("fields takes a JSON object of field names and values");
|
|
77
|
+
if (/^crm\.item\.(add|update|delete|get|list|fields)$/.test(method) && fieldOf(body, "entityTypeId") === undefined)
|
|
78
|
+
throw refused(`${method} needs entityTypeId, the record type's number`);
|
|
79
|
+
};
|
|
80
|
+
const typeOf = (method, body) => {
|
|
81
|
+
const named = /^crm\.(deal|lead|contact|company)\.(.+)$/.exec(method);
|
|
61
82
|
if (named?.[1] && named[2])
|
|
62
83
|
return { type: named[1], action: named[2] };
|
|
63
|
-
const item = /^crm\.item\.(
|
|
64
|
-
const type = ENTITY_TYPES[
|
|
84
|
+
const item = /^crm\.item\.(.+)$/.exec(method);
|
|
85
|
+
const type = ENTITY_TYPES[entityTypeOf(body) ?? ""];
|
|
65
86
|
return item?.[1] && type ? { type, action: item[1] } : undefined;
|
|
66
87
|
};
|
|
88
|
+
/** The CRM type and action a raw write does, whether named `crm.deal.update` or `crm.item.update` with its type id. */
|
|
89
|
+
const crmWriteOf = (method, body) => {
|
|
90
|
+
const found = typeOf(method, body);
|
|
91
|
+
return found && Object.hasOwn(ACTIONS, found.action) ? found : undefined;
|
|
92
|
+
};
|
|
93
|
+
/** The command a raw read reads the same as; any other read of a type, such as its product rows, is its list. */
|
|
94
|
+
const readKeysOf = (method, body) => {
|
|
95
|
+
const crm = typeOf(method, body);
|
|
96
|
+
if (crm) {
|
|
97
|
+
const noun = NOUNS[crm.type];
|
|
98
|
+
if (crm.action === "get")
|
|
99
|
+
return [`${noun}.show`];
|
|
100
|
+
return /^(fields$|field\.|userfield\.)/.test(crm.action) ? ["fields.list"] : [`${noun}.list`];
|
|
101
|
+
}
|
|
102
|
+
// `crm.item.productrow.*` names its record by ownerType in the filter, not entityTypeId (apidocs).
|
|
103
|
+
if (method.startsWith("crm.item.") && fieldOf(body, "entityTypeId") === undefined)
|
|
104
|
+
return Object.values(NOUNS).map((noun) => `${noun}.list`);
|
|
105
|
+
const product = /^(?:crm|catalog)\.product\.(.+)$/.exec(method);
|
|
106
|
+
if (product)
|
|
107
|
+
return [product[1] === "get" ? "products.show" : "products.list"];
|
|
108
|
+
// `users list` and `users show` both read through user.get.
|
|
109
|
+
if (method === "user.get" || method === "user.search")
|
|
110
|
+
return ["users.list", "users.show"];
|
|
111
|
+
if (method.startsWith("crm.category."))
|
|
112
|
+
return ["pipelines.list"];
|
|
113
|
+
if (method.startsWith("crm.status."))
|
|
114
|
+
return ["stages.list"];
|
|
115
|
+
return [];
|
|
116
|
+
};
|
|
67
117
|
/**
|
|
68
|
-
* The command keys a raw call does the same as, so `api call` cannot get round `deals
|
|
69
|
-
* `WRITE_METHODS
|
|
118
|
+
* The command keys a raw call does the same as, so `api call` cannot get round `deals: deny` (gcal-cli's
|
|
119
|
+
* `WRITE_METHODS`, WC-PERM-22). A create or update that sets a stage is a move too.
|
|
70
120
|
*/
|
|
71
121
|
export const commandKeysOf = (method, body = {}) => {
|
|
122
|
+
if (methodOf(method).effect === "read")
|
|
123
|
+
return readKeysOf(method, body);
|
|
72
124
|
const write = crmWriteOf(method, body);
|
|
73
125
|
if (!write)
|
|
74
126
|
return [];
|
|
75
127
|
const noun = NOUNS[write.type];
|
|
76
128
|
const keys = [`${noun}.${ACTIONS[write.action]}`];
|
|
129
|
+
// Without a lookup a stage may be a won or lost one, so both the move and the close key are checked.
|
|
77
130
|
if (write.action !== "delete" && setsStage(write.type, fieldsOf(body)))
|
|
78
|
-
keys.push(`${noun}.move`);
|
|
131
|
+
keys.push(`${noun}.move`, `${noun}.close`);
|
|
79
132
|
return keys;
|
|
80
133
|
};
|
|
81
|
-
/** The command keys a CRM write command checks beside its own: `.move` when its fields set a stage. */
|
|
82
|
-
export const stageKeysOf = (noun, fields) => {
|
|
83
|
-
const type = Object.keys(NOUNS).find((one) => NOUNS[one] === noun) ?? "";
|
|
84
|
-
return setsStage(type, fields) ? [`${noun}.move`] : [];
|
|
85
|
-
};
|
|
86
134
|
/**
|
|
87
135
|
* A method's default, as WC-PERM-22 has it, from an allow list: the reads `b24` makes and the CRM writes the command
|
|
88
136
|
* keys govern are allowed, a delete and anything else asks, and the families that reach people are denied, reads too.
|
|
@@ -98,15 +146,24 @@ export const apiDefault = (method, effect = methodOf(method).effect, body = {})
|
|
|
98
146
|
};
|
|
99
147
|
/** The built-in levels with this call's own key, which the static table cannot list for every method. */
|
|
100
148
|
export const callDefaults = (method, effect, body, defaults) => ({ ...defaults, [apiKey(method)]: apiDefault(method, effect, body) });
|
|
101
|
-
const
|
|
149
|
+
const METHODS = {
|
|
150
|
+
create: "add",
|
|
151
|
+
update: "update",
|
|
152
|
+
move: "update",
|
|
153
|
+
close: "update",
|
|
154
|
+
remove: "delete",
|
|
155
|
+
};
|
|
102
156
|
/**
|
|
103
|
-
* The
|
|
104
|
-
*
|
|
157
|
+
* The `api.*` key a deal's or lead's write sends its request under, so `api.crm.deal.update: deny` holds on `deals
|
|
158
|
+
* update` too: core's `CrmWrites.alsoChecks` and, through `crmAlsoChecks`, its `--dry-run`.
|
|
105
159
|
*/
|
|
160
|
+
export const crmApiKeys = (kind, verb) => [apiKey(`crm.${kind}.${METHODS[verb]}`)];
|
|
161
|
+
const OWN_WRITES = { people: "contact", organizations: "company" };
|
|
162
|
+
/** The same for b24's own `people` and `organizations` writes, by command path. */
|
|
106
163
|
export const apiKeysOf = (path) => {
|
|
107
164
|
const [noun, command, ...rest] = path;
|
|
108
|
-
const type =
|
|
109
|
-
const method =
|
|
165
|
+
const type = OWN_WRITES[noun ?? ""];
|
|
166
|
+
const method = command === "create" ? "add" : command === "update" ? "update" : undefined;
|
|
110
167
|
return type && method && rest.length === 0 ? [apiKey(`crm.${type}.${method}`)] : [];
|
|
111
168
|
};
|
|
112
169
|
/** The keys `permissions` may name for `api`: the known methods and the denied families. */
|
package/dist/api-keys.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-keys.js","sourceRoot":"","sources":["../src/api-keys.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"api-keys.js","sourceRoot":"","sources":["../src/api-keys.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAI5C,OAAO,EAAe,aAAa,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAC1E,OAAO,EAAa,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAErE,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,MAAc,EAAU,EAAE,CAAC,OAAO,MAAM,EAAE,CAAA;AAEjE;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,IAAI;IACJ,aAAa;IACb,OAAO;IACP,aAAa;IACb,cAAc;IACd,gBAAgB;IAChB,aAAa;IACb,WAAW;IACX,YAAY;IACZ,SAAS;IACT,gBAAgB;IAChB,cAAc;IACd,OAAO;IACP,MAAM;IACN,UAAU;IACV,2BAA2B;IAC3B,6BAA6B;IAC7B,YAAY;IACZ,OAAO;CACR,CAAA;AAED,qHAAqH;AACrH,MAAM,aAAa,GAAG,CAAC,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,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,CAAC,MAAM,CAAC;KACjC,CAAC,CACH;IACD,GAAG,MAAM,CAAC,WAAW,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,MAAe,CAAC,CAAC,CAAC;CAC1F,CAAA"}
|
package/dist/bin/b24.js
CHANGED
|
@@ -9,7 +9,7 @@ if (
|
|
|
9
9
|
(words[0] === "--version" || words[0] === "-V") &&
|
|
10
10
|
!Object.keys(process.env).some((key) => key.endsWith("_TEST_ARGV_LOG"))
|
|
11
11
|
) {
|
|
12
|
-
process.stdout.write("0.
|
|
12
|
+
process.stdout.write("0.5.0\n")
|
|
13
13
|
} else {
|
|
14
14
|
// Before the bundle compiles: the bundle's own call comes after its chunks.
|
|
15
15
|
module.enableCompileCache()
|
|
@@ -28,7 +28,7 @@ if (
|
|
|
28
28
|
: next(specifier, context),
|
|
29
29
|
})
|
|
30
30
|
}
|
|
31
|
-
const chunks = ["../bundle/all-profiles-
|
|
31
|
+
const chunks = ["../bundle/all-profiles-CANIDIDS.js","../bundle/anthropic-JUJB4DCF.js","../bundle/app-server-3V5Z4PTK.js","../bundle/bun-LKMV5TY7.js","../bundle/bun-sqlite-S56EF74S.js","../bundle/decode-QSTBX4MG.js","../bundle/dist-6Y64DTOE.js","../bundle/echarts-JZELFH2N.js","../bundle/embed-4RIW2LVH.js","../bundle/embedder-SW7DTWSL.js","../bundle/first-screen-NMHNFZ2B.js","../bundle/instructions-BZE5YUGG.js","../bundle/mcp-SDWHDJTY.js","../bundle/node-KM3CUABH.js","../bundle/node-LTKZIO4U.js","../bundle/node-TLZSIHIJ.js","../bundle/node-sqlite-HQ5PN2RH.js","../bundle/oauth-UH6FOZQL.js","../bundle/open-TSUP3XGL.js","../bundle/openai-GVEE52E3.js","../bundle/process-AGXY76ZE.js","../bundle/program-BI4A4HFJ.js","../bundle/prompt-NRSUY7FA.js","../bundle/recognize-NPDPQ6PJ.js","../bundle/remote-HFASMVLB.js","../bundle/rerank-TL6Z6F7K.js","../bundle/serve-VB4DHDZQ.js","../bundle/server-T5EDRPJI.js","../bundle/server-Z6MW6C37.js","../bundle/source-4IGO5J7E.js","../bundle/sqlite-runtime-YS4POY3W.js","../bundle/state-ISZVVZGR.js","../bundle/store-IZJBAKJV.js","../bundle/store-L76MSQC3.js","../bundle/store-PBTIB7BD.js","../bundle/store-maintenance-command-YFKII7TF.js","../bundle/writer-3O5EYMFE.js"]
|
|
32
32
|
if (((words) => words
|
|
33
33
|
.filter((word) => !word.startsWith("-"))
|
|
34
34
|
.slice(0, 2)
|
package/dist/bitrix/errors.js
CHANGED
|
@@ -65,7 +65,7 @@ export const bitrixError = (method, status, body, { now = Date.now(), waitMs } =
|
|
|
65
65
|
if (code && NOT_FOUND.has(code))
|
|
66
66
|
return as("not_found", `${method}: Bitrix24 has no such record${named}`);
|
|
67
67
|
if (code === "BITRIX_REST_V3_EXCEPTION_IDEMPOTENCYKEYREUSEDEXCEPTION")
|
|
68
|
-
return as("conflict", `${method}: this
|
|
68
|
+
return as("conflict", `${method}: Bitrix24 refused this write's operation id as already used for a different request`, { reason: "operation.reused" });
|
|
69
69
|
const fields = fieldsOf(body);
|
|
70
70
|
if (status === 400 || code?.startsWith("BITRIX_REST_V3_EXCEPTION_"))
|
|
71
71
|
return as("validation_error", `Bitrix24 refused ${method}${named}${fields.length ? `; check ${fields.join(", ")}` : ""}`, fields.length ? { fields } : {});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/bitrix/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAwC,MAAM,mBAAmB,CAAA;AAClF,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AAEtE,4FAA4F;AAC5F,MAAM,mBAAmB,GAAG,KAAK,CAAA;AACjC,sGAAsG;AACtG,MAAM,iBAAiB,GAAG,MAAM,CAAA;AAEhC,M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;IAC7B,IAAI,MAAM,KAAK,GAAG,IAAI,IAAI,EAAE,UAAU,CAAC,2BAA2B,CAAC;QACjE,OAAO,EAAE,CACP,kBAAkB,EAClB,oBAAoB,MAAM,GAAG,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,WAAW,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,EAC1F,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAChC,CAAA;IACH,IAAI,MAAM,IAAI,GAAG;QACf,OAAO,EAAE,CAAC,sBAAsB,EAAE,sBAAsB,MAAM,GAAG,KAAK,EAAE,EAAE,EAAE,SAAS,EAAE,eAAe,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;IACnH,OAAO,EAAE,CAAC,MAAM,IAAI,GAAG,CAAC,CAAC,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,gBAAgB,EAAE,oBAAoB,MAAM,GAAG,KAAK,EAAE,CAAC,CAAA;AAC1G,CAAC,CAAA"}
|
|
@@ -16,7 +16,7 @@ export interface BitrixTransportOptions {
|
|
|
16
16
|
random?: () => number;
|
|
17
17
|
}
|
|
18
18
|
export interface CallOptions {
|
|
19
|
-
/** A write's operation id, sent as REST 3.0's `Idempotency-Key
|
|
19
|
+
/** A write's operation id, sent as REST 3.0's `Idempotency-Key`; a live portal still did a repeat again. */
|
|
20
20
|
idempotencyKey?: string;
|
|
21
21
|
}
|
|
22
22
|
/** REST 2 lists carry `total` and `next` beside `result`; REST 3.0 answers carry neither. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../src/bitrix/transport.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,SAAS,EAEf,MAAM,mBAAmB,CAAA;AAE1B,OAAO,EAA2B,KAAK,SAAS,EAAkC,MAAM,uBA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;IAED,wCAAwC;IACxC,IAAI,MAAM,IAAI,MAAM,CAEnB;IAED;;;;OAIG;IACG,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,EAAE,OAAO,GAAE,WAAgB,GAAG,OAAO,CAAC,YAAY,CAAC,CAqBjH;CAoIF"}
|
package/dist/bitrix/transport.js
CHANGED
|
@@ -4,7 +4,11 @@ import { apiJson, currentAttempt, providerEvent, providerRequest } from "@wireca
|
|
|
4
4
|
import { bitrixError } from "./errors.js";
|
|
5
5
|
import { methodOf } from "./methods.js";
|
|
6
6
|
import { methodUrl } from "./webhook.js";
|
|
7
|
-
|
|
7
|
+
/**
|
|
8
|
+
* A third of a one-shot command's 30 s deadline (cli-core `DEFAULT_COMMAND_MS`), so a read that timed out can still be
|
|
9
|
+
* tried again before the command ends. cli-core does not hand the run's remaining time to a transport.
|
|
10
|
+
*/
|
|
11
|
+
const DEFAULT_TIMEOUT_MS = 10_000;
|
|
8
12
|
const LARGEST_ANSWER = 16 * 1024 * 1024;
|
|
9
13
|
const RETRY = { retries: 3, baseDelayMs: 1_000, maxDelayMs: 10_000, maxRetryAfterMs: 30_000 };
|
|
10
14
|
/** A pace wait longer than this ends the run instead of sitting in it, as cli-core's messenger pacing does. */
|
|
@@ -142,7 +146,7 @@ export class BitrixTransport {
|
|
|
142
146
|
}
|
|
143
147
|
end({ status: response.status, errorCode: "invalid_response" });
|
|
144
148
|
if (!response.ok)
|
|
145
|
-
throw bitrixError(method, response.status, undefined);
|
|
149
|
+
throw this.#refused(method, bitrixError(method, response.status, undefined), run.reads);
|
|
146
150
|
throw new CliError("invalid_response", `Bitrix24 answered ${method} with something that is not JSON`, {
|
|
147
151
|
operation: method,
|
|
148
152
|
status: response.status,
|
|
@@ -159,7 +163,7 @@ export class BitrixTransport {
|
|
|
159
163
|
errorCode: refusal.code,
|
|
160
164
|
providerError: String(refusal.details.provider_error ?? ""),
|
|
161
165
|
});
|
|
162
|
-
throw refusal;
|
|
166
|
+
throw this.#refused(method, refusal, run.reads);
|
|
163
167
|
}
|
|
164
168
|
end({ status: response.status });
|
|
165
169
|
return {
|
|
@@ -172,12 +176,22 @@ export class BitrixTransport {
|
|
|
172
176
|
clearTimeout(timer);
|
|
173
177
|
}
|
|
174
178
|
}
|
|
179
|
+
/** A gateway or server failure may come after a write was made; only a refusal says it was not. */
|
|
180
|
+
#refused(method, refusal, reads) {
|
|
181
|
+
if (reads || refusal.code !== "provider_unavailable")
|
|
182
|
+
return refusal;
|
|
183
|
+
return new CliError("outcome_unknown", `Bitrix24 failed on ${method}; it may or may not have carried it out`, {
|
|
184
|
+
...refusal.details,
|
|
185
|
+
retryable: false,
|
|
186
|
+
});
|
|
187
|
+
}
|
|
175
188
|
#unanswered(method, error, run) {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
// A keyed write's caller names how to repeat it; a REST 2 write has no key to repeat it safely with.
|
|
189
|
+
// A cut write may have reached the portal: never "cancelled", which a caller would repeat (WC-LIFE-9). A keyed
|
|
190
|
+
// write's caller names how to repeat it; a REST 2 write has no key to repeat it safely with.
|
|
179
191
|
if (!run.reads)
|
|
180
192
|
return new CliError("outcome_unknown", `${method} got no answer; Bitrix24 may or may not have carried it out${run.key ? "" : " — check before repeating it"}`, { operation: method, retryable: false });
|
|
193
|
+
if (this.#signal?.aborted && this.#signal.reason?.name !== "TimeoutError")
|
|
194
|
+
return new CliError("cancelled", `${method} was cancelled`, { operation: method });
|
|
181
195
|
const timedOut = error?.name === "TimeoutError";
|
|
182
196
|
return new CliError(timedOut ? "timeout" : "network_error", timedOut ? `${method} got no answer within ${this.#timeoutMs} ms` : `${method} could not reach Bitrix24`, { operation: method, retryable: true });
|
|
183
197
|
}
|