@besales/mcp 0.46.0 → 0.47.1
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/README.md +96 -55
- package/dist/auth/connection-store.d.ts +21 -1
- package/dist/auth/connection-store.js +46 -2
- package/dist/auth/connection-store.js.map +1 -1
- package/dist/auth/oauth-client.d.ts +5 -1
- package/dist/auth/oauth-client.js +22 -12
- package/dist/auth/oauth-client.js.map +1 -1
- package/dist/cli.js +14 -5
- package/dist/cli.js.map +1 -1
- package/dist/http/api-client.d.ts +16 -1
- package/dist/http/api-client.js +50 -2
- package/dist/http/api-client.js.map +1 -1
- package/dist/instructions/server-instructions.d.ts +4 -13
- package/dist/instructions/server-instructions.js +76 -274
- package/dist/instructions/server-instructions.js.map +1 -1
- package/dist/prompts/registry.d.ts +15 -0
- package/dist/prompts/registry.js +83 -0
- package/dist/prompts/registry.js.map +1 -0
- package/dist/resources/concepts/feedback-sheets.md +7 -4
- package/dist/resources/concepts/handoff.md +4 -1
- package/dist/resources/concepts/sandbox.md +14 -5
- package/dist/resources/concepts/triggers.md +6 -2
- package/dist/resources/concepts/workbook-classification.md +26 -21
- package/dist/resources/docs/campaigns.md +20 -0
- package/dist/resources/docs/follow-up.md +19 -0
- package/dist/resources/docs/platforms.md +2 -2
- package/dist/resources/docs/routing.md +18 -0
- package/dist/resources/docs/task-state.md +30 -0
- package/dist/resources/docs/trigger-actions.md +28 -0
- package/dist/resources/docs/variables.md +18 -0
- package/dist/resources/registry.js +51 -2
- package/dist/resources/registry.js.map +1 -1
- package/dist/resources/workflows/extract-from-document.md +8 -1
- package/dist/resources/workflows/iterate-with-sandbox.md +5 -2
- package/dist/resources/workflows/platform-setup-from-scratch.md +90 -2
- package/dist/resources/workflows/production-readiness-check.md +22 -18
- package/dist/schemas/mcp-tools.json +1139 -96
- package/dist/server.d.ts +2 -0
- package/dist/server.js +8 -2
- package/dist/server.js.map +1 -1
- package/dist/tasks/task-state-store.d.ts +68 -0
- package/dist/tasks/task-state-store.js +278 -0
- package/dist/tasks/task-state-store.js.map +1 -0
- package/dist/tools/annotations.d.ts +7 -0
- package/dist/tools/annotations.js +16 -0
- package/dist/tools/annotations.js.map +1 -0
- package/dist/tools/contracts.js +7 -1
- package/dist/tools/contracts.js.map +1 -1
- package/dist/tools/definitions/agent-design.d.ts +41 -20
- package/dist/tools/definitions/agent-design.js +189 -19
- package/dist/tools/definitions/agent-design.js.map +1 -1
- package/dist/tools/definitions/analytics.d.ts +40 -0
- package/dist/tools/definitions/analytics.js +233 -0
- package/dist/tools/definitions/analytics.js.map +1 -0
- package/dist/tools/definitions/broadcast-analytics.js +12 -0
- package/dist/tools/definitions/broadcast-analytics.js.map +1 -1
- package/dist/tools/definitions/broadcast-mailing-variants.d.ts +2 -0
- package/dist/tools/definitions/broadcast-mailing-variants.js +10 -0
- package/dist/tools/definitions/broadcast-mailing-variants.js.map +1 -1
- package/dist/tools/definitions/broadcast-scheduler.d.ts +14 -1
- package/dist/tools/definitions/broadcast-scheduler.js +148 -12
- package/dist/tools/definitions/broadcast-scheduler.js.map +1 -1
- package/dist/tools/definitions/contacts.d.ts +15 -0
- package/dist/tools/definitions/contacts.js +84 -0
- package/dist/tools/definitions/contacts.js.map +1 -0
- package/dist/tools/definitions/crm-platform.d.ts +2 -0
- package/dist/tools/definitions/crm-platform.js +75 -5
- package/dist/tools/definitions/crm-platform.js.map +1 -1
- package/dist/tools/definitions/datasource.d.ts +1 -0
- package/dist/tools/definitions/datasource.js +16 -1
- package/dist/tools/definitions/datasource.js.map +1 -1
- package/dist/tools/definitions/dialogue-audit.d.ts +2 -2
- package/dist/tools/definitions/dialogue-audit.js +54 -16
- package/dist/tools/definitions/dialogue-audit.js.map +1 -1
- package/dist/tools/definitions/dialogue-export.d.ts +1 -1
- package/dist/tools/definitions/dialogue-export.js +12 -0
- package/dist/tools/definitions/dialogue-export.js.map +1 -1
- package/dist/tools/definitions/external-api-channels.js +39 -12
- package/dist/tools/definitions/external-api-channels.js.map +1 -1
- package/dist/tools/definitions/follow-up-funnel-test.js +4 -0
- package/dist/tools/definitions/follow-up-funnel-test.js.map +1 -1
- package/dist/tools/definitions/follow-up-setup.js +3 -0
- package/dist/tools/definitions/follow-up-setup.js.map +1 -1
- package/dist/tools/definitions/follow-up.d.ts +2 -1
- package/dist/tools/definitions/follow-up.js +11 -0
- package/dist/tools/definitions/follow-up.js.map +1 -1
- package/dist/tools/definitions/getcourse-anchor-refresh.d.ts +3 -0
- package/dist/tools/definitions/getcourse-anchor-refresh.js +29 -2
- package/dist/tools/definitions/getcourse-anchor-refresh.js.map +1 -1
- package/dist/tools/definitions/getcourse-cold-welcome.d.ts +12 -2
- package/dist/tools/definitions/getcourse-cold-welcome.js +79 -4
- package/dist/tools/definitions/getcourse-cold-welcome.js.map +1 -1
- package/dist/tools/definitions/getcourse-wave.js +14 -0
- package/dist/tools/definitions/getcourse-wave.js.map +1 -1
- package/dist/tools/definitions/help.d.ts +8 -0
- package/dist/tools/definitions/help.js +219 -0
- package/dist/tools/definitions/help.js.map +1 -0
- package/dist/tools/definitions/knowledge.d.ts +27 -5
- package/dist/tools/definitions/knowledge.js +200 -33
- package/dist/tools/definitions/knowledge.js.map +1 -1
- package/dist/tools/definitions/link-tracking.js +9 -0
- package/dist/tools/definitions/link-tracking.js.map +1 -1
- package/dist/tools/definitions/model-comparison.js +6 -0
- package/dist/tools/definitions/model-comparison.js.map +1 -1
- package/dist/tools/definitions/operational-overview.d.ts +3 -0
- package/dist/tools/definitions/operational-overview.js +23 -0
- package/dist/tools/definitions/operational-overview.js.map +1 -0
- package/dist/tools/definitions/operator-workflow.d.ts +20 -0
- package/dist/tools/definitions/operator-workflow.js +114 -0
- package/dist/tools/definitions/operator-workflow.js.map +1 -0
- package/dist/tools/definitions/platform-setup.d.ts +26 -3
- package/dist/tools/definitions/platform-setup.js +209 -7
- package/dist/tools/definitions/platform-setup.js.map +1 -1
- package/dist/tools/definitions/scheduled-tasks.js +2 -0
- package/dist/tools/definitions/scheduled-tasks.js.map +1 -1
- package/dist/tools/definitions/session.js +103 -5
- package/dist/tools/definitions/session.js.map +1 -1
- package/dist/tools/definitions/shared.d.ts +154 -11
- package/dist/tools/definitions/shared.js +67 -9
- package/dist/tools/definitions/shared.js.map +1 -1
- package/dist/tools/definitions/task-state.d.ts +76 -0
- package/dist/tools/definitions/task-state.js +301 -0
- package/dist/tools/definitions/task-state.js.map +1 -0
- package/dist/tools/definitions/trigger-contact-claims.js +2 -0
- package/dist/tools/definitions/trigger-contact-claims.js.map +1 -1
- package/dist/tools/definitions.d.ts +273 -31
- package/dist/tools/definitions.js +12 -0
- package/dist/tools/definitions.js.map +1 -1
- package/dist/tools/description-localization.d.ts +2 -0
- package/dist/tools/description-localization.js +46 -0
- package/dist/tools/description-localization.js.map +1 -0
- package/dist/tools/incomplete-list.d.ts +23 -0
- package/dist/tools/incomplete-list.js +39 -0
- package/dist/tools/incomplete-list.js.map +1 -0
- package/dist/tools/inventory.d.ts +10 -0
- package/dist/tools/inventory.js +49 -0
- package/dist/tools/inventory.js.map +1 -0
- package/dist/tools/registry-mapping-cases-core.js +197 -2
- package/dist/tools/registry-mapping-cases-core.js.map +1 -1
- package/dist/tools/registry-mapping-cases-platform.js +69 -0
- package/dist/tools/registry-mapping-cases-platform.js.map +1 -1
- package/dist/tools/registry.d.ts +2 -0
- package/dist/tools/registry.js +60 -8
- package/dist/tools/registry.js.map +1 -1
- package/dist/tools/result-envelope.d.ts +46 -0
- package/dist/tools/result-envelope.js +184 -0
- package/dist/tools/result-envelope.js.map +1 -0
- package/dist/tools/result.d.ts +41 -3
- package/dist/tools/result.js +229 -27
- package/dist/tools/result.js.map +1 -1
- package/dist/tools/tool-title.d.ts +2 -0
- package/dist/tools/tool-title.js +12 -0
- package/dist/tools/tool-title.js.map +1 -0
- package/dist/tools/toolsets.d.ts +37 -0
- package/dist/tools/toolsets.js +64 -0
- package/dist/tools/toolsets.js.map +1 -0
- package/dist/tools/verify-with.d.ts +5 -0
- package/dist/tools/verify-with.js +36 -0
- package/dist/tools/verify-with.js.map +1 -0
- package/dist/types/api-contract.gen.d.ts +1433 -74
- package/dist/utils/logger.d.ts +11 -0
- package/dist/utils/logger.js +64 -8
- package/dist/utils/logger.js.map +1 -1
- package/docs/agent-usage-guide.full.ru.md +20 -15
- package/docs/agent-usage-guide.ru.md +29 -16
- package/docs/async-operation-lifecycle.md +46 -0
- package/docs/connect.ru.md +120 -0
- package/docs/evals/model-behavior-scorecard.md +80 -0
- package/docs/failure-semantics.md +56 -0
- package/docs/help-navigation.md +48 -0
- package/docs/host-compatibility-matrix.md +153 -0
- package/docs/host-setup.md +22 -6
- package/docs/operation-coverage.md +114 -0
- package/docs/pii-policy.md +46 -0
- package/docs/response-size-budget.md +150 -0
- package/docs/task-state.md +58 -0
- package/docs/tool-effects.md +46 -0
- package/docs/tool-surface.md +91 -0
- package/package.json +6 -2
- package/scripts/model-eval-server.js +213 -0
- package/scripts/probe-mcp-protocol.js +134 -0
- package/scripts/run-model-eval.js +447 -0
package/README.md
CHANGED
|
@@ -21,9 +21,9 @@ npx -y @besales/mcp
|
|
|
21
21
|
```
|
|
22
22
|
|
|
23
23
|
`connect` opens the browser consent flow and stores an MCP API key plus the
|
|
24
|
-
selected workspace in the local keychain.
|
|
25
|
-
|
|
26
|
-
`
|
|
24
|
+
selected workspace in the local keychain. With one connection or an explicit session pin,
|
|
25
|
+
workspace-level tools resolve it automatically. With several unpinned connections they refuse
|
|
26
|
+
the call as ambiguous; inspect `besales_workspace_current` and select one deliberately.
|
|
27
27
|
|
|
28
28
|
For production, do not set `BESALES_API_BASE_URL` or
|
|
29
29
|
`BESALES_OAUTH_AUTHORIZE_URL`. They default to:
|
|
@@ -47,6 +47,9 @@ BESALES_OAUTH_AUTHORIZE_URL=http://localhost:5173/settings/mcp/consent \
|
|
|
47
47
|
|
|
48
48
|
## Configure Your MCP Host
|
|
49
49
|
|
|
50
|
+
Step-by-step guide in Russian (Claude Code, Codex, several workspaces, updating):
|
|
51
|
+
[docs/connect.ru.md](docs/connect.ru.md). Release order for maintainers: [RELEASING.md](RELEASING.md).
|
|
52
|
+
|
|
50
53
|
After `connect`, add the server to your MCP host and restart the host.
|
|
51
54
|
|
|
52
55
|
Claude Desktop config:
|
|
@@ -104,6 +107,13 @@ npx -y @besales/mcp connect # workspace B (re-login in the browser firs
|
|
|
104
107
|
npx -y @besales/mcp connections # list all connections, marks the active one
|
|
105
108
|
```
|
|
106
109
|
|
|
110
|
+
`connect` stores the workspace name and a masked account label such as
|
|
111
|
+
`o***@example.com`; the raw email is never stored in the MCP index. These labels
|
|
112
|
+
are refreshed by a lightweight scoped endpoint (at most once per day) and never
|
|
113
|
+
require a full workspace overview. `besales_workspace_current` reports
|
|
114
|
+
`current`, `cached`, `stale`, or `unknown` plus a safe refresh reason. Reconnect
|
|
115
|
+
also refreshes a renamed workspace; legacy connections migrate on first read.
|
|
116
|
+
|
|
107
117
|
Bind a host session to a specific workspace with `BESALES_WORKSPACE_ID` in that
|
|
108
118
|
server's `env` block — the cleanest "one session = one workspace" setup (one
|
|
109
119
|
project/profile per workspace):
|
|
@@ -146,8 +156,9 @@ one connection nothing changes. `besales_workspace_current` reports
|
|
|
146
156
|
`source: "ambiguous"` and `workspace_id: null` in the same situation, so the
|
|
147
157
|
diagnostic never claims a binding the real call would not use.
|
|
148
158
|
|
|
149
|
-
`BESALES_WORKSPACE_ID` always overrides everything.
|
|
150
|
-
|
|
159
|
+
`BESALES_WORKSPACE_ID` always overrides everything. `besales_workspace_current`
|
|
160
|
+
lists names, safe account labels, UUIDs, the selection source, and label freshness.
|
|
161
|
+
The assistant shows those names to the user and passes the chosen UUID itself.
|
|
151
162
|
|
|
152
163
|
### GUI hosts without per-session env (e.g. Claude Desktop)
|
|
153
164
|
|
|
@@ -193,9 +204,9 @@ business request:
|
|
|
193
204
|
Use besales MCP to create an ICP for SaaS B2B sales automation.
|
|
194
205
|
```
|
|
195
206
|
|
|
196
|
-
The assistant should discover and call the relevant `besales_*` tools itself.
|
|
197
|
-
|
|
198
|
-
`
|
|
207
|
+
The assistant should discover and call the relevant `besales_*` tools itself. The user can ask in
|
|
208
|
+
ordinary business language. If several workspaces are connected without a pin, the assistant must
|
|
209
|
+
show the choices from `besales_workspace_current`; the user does not need to invent an ID.
|
|
199
210
|
|
|
200
211
|
Expected quick checks:
|
|
201
212
|
|
|
@@ -205,14 +216,28 @@ Expected quick checks:
|
|
|
205
216
|
4. External flows use `*_get_instructions`, execute stages locally in the host,
|
|
206
217
|
then call the matching `*_submit` tool.
|
|
207
218
|
|
|
219
|
+
If the host does not expose MCP resources to the model, ask the same request in ordinary words.
|
|
220
|
+
The model can call `besales_help_search` and then `besales_help_get`; both tools read the same
|
|
221
|
+
packaged documents as `besales://...` resources. `besales_help_get` returns a compact heading index
|
|
222
|
+
by default, one section with `section`, or the complete document with `full=true`. See
|
|
223
|
+
[`docs/help-navigation.md`](docs/help-navigation.md).
|
|
224
|
+
|
|
225
|
+
Hosts with MCP prompts may also show five optional task entries: configure an agent, improve an
|
|
226
|
+
agent, audit dialogues, build a campaign report, and diagnose a failure. They expand to the same
|
|
227
|
+
ordinary instructions and tool navigation; a host without prompts loses no operation.
|
|
228
|
+
|
|
208
229
|
To switch workspace, connect each one once (see [Multiple Workspaces](#multiple-workspaces))
|
|
209
230
|
and either set `BESALES_WORKSPACE_ID` per host session or run
|
|
210
231
|
`npx -y @besales/mcp use <workspaceId>`. No browser re-auth is needed once a
|
|
211
232
|
workspace is connected.
|
|
212
233
|
|
|
213
|
-
If
|
|
214
|
-
|
|
215
|
-
`@besales/mcp@latest`
|
|
234
|
+
If a call asks for `workspace_id`, first run `besales_workspace_current`: the cause may be a real
|
|
235
|
+
multi-workspace ambiguity, an env pin conflict, a missing key, or an old schema. Restart the host
|
|
236
|
+
with `@besales/mcp@latest` only when the schema/version is actually stale; reconnect only when the
|
|
237
|
+
credential or granted scopes are the problem.
|
|
238
|
+
|
|
239
|
+
`besales_workspace_current` reports `effective_scopes` from the exact selected credential and
|
|
240
|
+
marks their source. It never unions permissions from other MCP keys in the same workspace.
|
|
216
241
|
|
|
217
242
|
## Development
|
|
218
243
|
|
|
@@ -271,6 +296,21 @@ node bin/besales-mcp.js # start the MCP server
|
|
|
271
296
|
`https://app.besales.ai/settings/mcp/consent` (frontend bridge). For local
|
|
272
297
|
development point them at your local backend and frontend respectively.
|
|
273
298
|
|
|
299
|
+
`BESALES_MCP_RESULT_ENVELOPE=on` turns on the response size ceiling: oversized
|
|
300
|
+
answers are shaped or refused instead of flooding the caller's context. It is
|
|
301
|
+
**off by default** for one release because the package is normally run unpinned,
|
|
302
|
+
so a change in response semantics would land mid-session. See
|
|
303
|
+
[`docs/response-size-budget.md`](docs/response-size-budget.md) for the measured
|
|
304
|
+
numbers and the per-tool classes.
|
|
305
|
+
|
|
306
|
+
`BESALES_MCP_TOOLSETS` limits the session to named toolsets, comma separated —
|
|
307
|
+
`readonly` (every tool that only reads), or a domain group derived from the tool
|
|
308
|
+
name (`knowledge`, `crm`, `agent`, `prompt`, …). Unset or empty means the full
|
|
309
|
+
surface: a setting nobody filled in must never narrow access silently. The filter
|
|
310
|
+
applies to both `tools/list` and `tools/call`, and an unknown name fails loudly
|
|
311
|
+
with the list of valid ones. See [`docs/tool-surface.md`](docs/tool-surface.md)
|
|
312
|
+
for why the surface gets profiles rather than fewer, larger tools.
|
|
313
|
+
|
|
274
314
|
Tool calls require stored credentials. Run `node bin/besales-mcp.js connect`
|
|
275
315
|
against a backend that implements the MCP OAuth endpoints
|
|
276
316
|
(`/api/v2/auth/mcp-connect*` + `/api/v2/auth/mcp-token`), or run
|
|
@@ -290,47 +330,35 @@ connect each once and pin sessions via `BESALES_WORKSPACE_ID` (or switch the
|
|
|
290
330
|
global default with `besales-mcp use <id>`) — see
|
|
291
331
|
[Multiple Workspaces](#multiple-workspaces).
|
|
292
332
|
|
|
293
|
-
## Available tools (
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
`
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
| Category | Tools |
|
|
300
|
-
|
|
301
|
-
|
|
|
302
|
-
|
|
|
303
|
-
|
|
|
304
|
-
|
|
|
305
|
-
|
|
|
306
|
-
|
|
|
307
|
-
|
|
|
308
|
-
|
|
|
309
|
-
|
|
|
310
|
-
|
|
|
311
|
-
|
|
312
|
-
| Workbook ingestion (xlsx / Google Sheets) | 3 | `besales_workbook_*` |
|
|
313
|
-
| Feedback sheets (Google Sheets QA) | 5 | `besales_feedback_sheet_*` |
|
|
314
|
-
| Variables (unified) | 5 | `besales_variable_*` |
|
|
315
|
-
| CRM — pipelines, statuses, platform link | 11 | `besales_crm_pipeline_*`, `besales_platform_pipeline_*` |
|
|
316
|
-
| CRM — connection / field mapping / operators / activate | 7 | `besales_crm_create_*` (AmoCRM/Bitrix24 via browser-secrets), `besales_crm_field_mapping_*`, `besales_crm_operator_*`, `besales_crm_activate` (live token check + activate, deactivates other workspace CRMs) |
|
|
317
|
-
| Platform — provisioning / OAuth | 3 | `besales_platform_create_init`, `besales_platform_create_status`, `besales_platform_create_oauth_init` (Instagram/Avito) |
|
|
318
|
-
| Platform — clone | 3 | `besales_platform_clone_*` |
|
|
319
|
-
| Data sources (1С, категория «БД») | 9 | `besales_datasource_create_*` (Setup URL pattern), `_list` / `_health` / `_catalogs` / `_catalog_roles` / `_role_assign` / `_enable` / `_vectorize`. 1С — товарная БД через OData; чтение/запись — действия триггеров, не tools агента |
|
|
320
|
-
| Files | 3 | `besales_file_upload_request` + status + list |
|
|
321
|
-
| Context / overview / audit | 3 | `besales_workspace_overview`, `besales_platform_context_get`, `besales_audit_revert` |
|
|
322
|
-
| Session / workspace binding | 2 | `besales_workspace_use`, `besales_workspace_current` (in-memory per-session, local — no backend) |
|
|
323
|
-
| Dialogue audit | 2 | `besales_dialogues_query`, `besales_dialogue_transcript` — read-only transcript + trigger-action evidence |
|
|
324
|
-
| Dialogue audit external | 2 | `besales_dialogue_audit_segments_get`, `besales_dialogue_audit_import` — сервер готовит материал ревизора read-only, разбирает клиент, находки возвращаются импортом |
|
|
325
|
-
| Broadcast analytics | 2 | `besales_broadcast_analytics_get`, `besales_broadcast_cohorts_list` — authoritative read-only aggregates, drill-downs, segment/product catalogs, insights and payment-candidate reports from `/broadcast-analytics`, not transcript-derived counts |
|
|
326
|
-
| GetCourse waves | 10 | `besales_getcourse_wave_import`, `besales_getcourse_wave_status`, `besales_getcourse_wave_run_start`, `besales_getcourse_wave_run_status`, `besales_getcourse_wave_run_contacts`, `besales_getcourse_wave_run_cancel`, `besales_getcourse_wave_run_batch_start`, `besales_getcourse_wave_run_batch_status`, `besales_getcourse_wave_run_batch_cancel`, `besales_getcourse_wave_run_batch_resume`; durable confirm использует стабильный `launch_key` + `dry_run_hash`, import/run/batch принимают `segment_description` |
|
|
327
|
-
| Scheduled tasks | 2 | `besales_scheduled_task_list`, `besales_scheduled_task_update` — cron-driven dialogue analysis («суфлёр»): daily summary + hourly status written to the CRM timeline or as a hidden open-line message, never to the client |
|
|
328
|
-
| Link tracking (короткие ссылки) | 6 | `besales_tracked_link_list` / `_create` / `_update` / `_archive` / `_breakdown` / `_clicks` — каталог токенов `{{link:slug}}` для текстов дожимов и рассылок; удаления нет (архивация), правка адреса историю выдач не переписывает |
|
|
329
|
-
| Follow-up (read) | 3 | `besales_followup_sequence_list`, `besales_followup_step_stats`, `besales_followup_reactions` — inspect configs and authoritative delivery/reaction analytics |
|
|
330
|
-
| Follow-up funnel test | 4 | `besales_followup_funnel_test_plan/start/status/cancel` — frozen-plan live-person test; plan spends LLM tokens but sends nothing, start requires explicit confirmation |
|
|
333
|
+
## Available tools (253 tools by category)
|
|
334
|
+
|
|
335
|
+
Итог и категории строятся из активных имён `src/schemas/mcp-tools.json`. Тест сверяет этот блок,
|
|
336
|
+
`summary.tools_by_category` и сумму категорий с `tools.length`.
|
|
337
|
+
|
|
338
|
+
<!-- BEGIN GENERATED TOOL INVENTORY -->
|
|
339
|
+
| Category | Tools | Name prefixes |
|
|
340
|
+
|---|---:|---|
|
|
341
|
+
| Workspace, help, tasks and audit | 18 | `workspace_*`, `help_*`, `task_*`, `audit_*` |
|
|
342
|
+
| Agents, behavior and routing | 14 | `agent_*`, `behavior_*`, `facts_*`, `pipeline_*`, `routing_*`, `router_*` |
|
|
343
|
+
| Prompts, sandbox and evaluation | 33 | `prompt_*`, `qa_*`, `sandbox_*`, `simulation_*`, `test_*`, `model_*` |
|
|
344
|
+
| ICP | 9 | `icp_*` |
|
|
345
|
+
| Knowledge, workbooks, files and variables | 50 | `knowledge_*`, `workbook_*`, `feedback_*`, `variable_*`, `file_*` |
|
|
346
|
+
| CRM and data sources | 27 | `crm_*`, `datasource_*` |
|
|
347
|
+
| Channels and external API credentials | 14 | `platform_*`, `external_*` |
|
|
348
|
+
| Dialogues and contacts | 16 | `dialogue_*`, `dialogues_*`, `dialog_*`, `contact_*` |
|
|
349
|
+
| Triggers | 5 | `trigger_*` |
|
|
350
|
+
| Outbound, follow-up and analytics | 67 | `broadcast_*`, `getcourse_*`, `wazzup_*`, `followup_*`, `scheduled_*`, `tracked_*`, `link_*`, `inbound_*`, `funnel_*`, `ai_*`, `custom_*` |
|
|
351
|
+
<!-- END GENERATED TOOL INVENTORY -->
|
|
331
352
|
|
|
332
353
|
Recent capabilities:
|
|
333
354
|
|
|
355
|
+
- **Intent navigation** — `besales_workspace_navigate` combines the requested task, bot type,
|
|
356
|
+
selected objects and live workspace overview into one next tool call, required user input and a
|
|
357
|
+
result check. It does not perform the recommended mutation.
|
|
358
|
+
- **Complete async lifecycle** — every background start has a read-only status tool; see
|
|
359
|
+
[docs/async-operation-lifecycle.md](docs/async-operation-lifecycle.md). Contact imports and a
|
|
360
|
+
single cold-welcome launch use `besales_getcourse_contact_import_status`; anchor refresh uses
|
|
361
|
+
`besales_getcourse_anchor_refresh_status` and reports a lost worker as `STALLED`.
|
|
334
362
|
- **Funnel test outside the web UI** — `besales_followup_funnel_test_plan` freezes expanded
|
|
335
363
|
texts and dynamic generations under one `runId`; `start` sends exactly that snapshot to the
|
|
336
364
|
live contact and requires both `explicit_confirmation=true` and `confirmation_reason`.
|
|
@@ -352,14 +380,25 @@ Recent capabilities:
|
|
|
352
380
|
- **CRM connection via browser-secrets** — `besales_crm_create_init` provisions
|
|
353
381
|
AmoCRM/Bitrix24 (and GetCourse/Telegram) using the Setup URL pattern, where the
|
|
354
382
|
user pastes credentials in the browser instead of through the chat.
|
|
383
|
+
- **External API credential handoff** — channel create/key rotation/secret rotation
|
|
384
|
+
return `revealUrl` and its expiry. The signed-in user opens that page to receive
|
|
385
|
+
credentials once; keys and webhook secrets never enter MCP content or host logs.
|
|
355
386
|
- **Setup URL pattern** — `*_init` returns a one-time URL; the user completes
|
|
356
387
|
sensitive input in the browser and the host polls `*_status` until ready.
|
|
388
|
+
- **External execution pairs** — schemas returned by `*_get_instructions` use canonical
|
|
389
|
+
camelCase fields. Matching `*_submit` tools accept those fields directly and retain
|
|
390
|
+
legacy snake_case aliases, then send one canonical camelCase body to the API.
|
|
357
391
|
- **File upload** — two-step flow (`besales_file_upload_request` →
|
|
358
392
|
`besales_file_upload_status`) so binaries are uploaded directly, not via MCP.
|
|
359
393
|
- **Platform provisioning & clone** — create channels and clone an existing
|
|
360
394
|
platform configuration (`besales_platform_clone_preview` / `_execute`).
|
|
361
395
|
- **Knowledge ingestion** — full namespace/document/Q&A/website/table CRUD plus
|
|
362
|
-
workbook ingestion from xlsx and Google Sheets.
|
|
396
|
+
workbook ingestion from xlsx and Google Sheets. `besales_workbook_inspect` inventories
|
|
397
|
+
sheets and returns a bounded sample; `besales_workbook_sheet_read` pages through late rows
|
|
398
|
+
and columns with source identity and a page fingerprint. Metadata/classification and
|
|
399
|
+
archival are available through dedicated workbook tools. Namespace/table reindex returns
|
|
400
|
+
a job ID; poll the matching `_reindex_status` tool to a terminal state instead of reading
|
|
401
|
+
worker logs.
|
|
363
402
|
- **GetCourse wave-run batches** — queue 1–10 status-mode segments sequentially
|
|
364
403
|
through `besales_getcourse_wave_run_batch_start`; use one `_batch_status` poll,
|
|
365
404
|
reuse a generated `batch_key` on retry, and resume only after resolving two
|
|
@@ -379,7 +418,7 @@ Recent capabilities:
|
|
|
379
418
|
|
|
380
419
|
## Resources
|
|
381
420
|
|
|
382
|
-
The package exposes
|
|
421
|
+
The package exposes 38 MCP resources. The dialogue-audit workflow is:
|
|
383
422
|
|
|
384
423
|
- `besales://workflows/audit-dialogues`
|
|
385
424
|
|
|
@@ -399,7 +438,7 @@ Inspect them locally:
|
|
|
399
438
|
yarn dlx @modelcontextprotocol/inspector node bin/besales-mcp.js
|
|
400
439
|
```
|
|
401
440
|
|
|
402
|
-
The Inspector should show
|
|
441
|
+
The Inspector should show 253 tools, 38 resources, and 5 optional prompts.
|
|
403
442
|
|
|
404
443
|
## Codex Dialogue Audit Skill
|
|
405
444
|
|
|
@@ -443,7 +482,7 @@ Claude Code, and Codex CLI are documented in
|
|
|
443
482
|
- This package calls Animaly only through `ai-aniomaly` `/api/v2/*`.
|
|
444
483
|
- Direct calls to `prompt-services` are intentionally out of scope.
|
|
445
484
|
|
|
446
|
-
The package exposes
|
|
485
|
+
The package exposes 253 active MCP tools from `src/schemas/mcp-tools.json`.
|
|
447
486
|
|
|
448
487
|
### Token scopes
|
|
449
488
|
|
|
@@ -457,6 +496,8 @@ in `src/auth/oauth-client.ts`:
|
|
|
457
496
|
| `mcp:funnel-test` | frozen follow-up funnel test against a live person |
|
|
458
497
|
| `read:campaigns` | cold-welcome preview, broadcast reads and their message texts |
|
|
459
498
|
| `launch:campaigns` | cold-welcome and broadcast launches |
|
|
499
|
+
| `read:contacts` | contact search, cards, and safe diagnostics |
|
|
500
|
+
| `write:operators` | CAS-protected workspace-operator assignment; no message send or CRM mutation |
|
|
460
501
|
|
|
461
502
|
None of these is implied by another: a plain `mcp:*` key authorizes neither setup
|
|
462
503
|
mutations nor campaigns, and `mcp:platform-setup` does not imply the right to send
|
|
@@ -478,8 +519,8 @@ reconnect once to be granted a newly added scope.
|
|
|
478
519
|
permissions than the one it replaces:
|
|
479
520
|
|
|
480
521
|
```
|
|
481
|
-
Connected to workspace de86534d-… (key: mcp_a1b2
|
|
482
|
-
Scopes: mcp:* mcp:platform-setup mcp:funnel-test read:campaigns launch:campaigns
|
|
522
|
+
Connected to workspace Animaly [de86534d-…] (key: mcp_a1b2…, account: o***@besales.ai).
|
|
523
|
+
Scopes: mcp:* mcp:platform-setup mcp:funnel-test read:campaigns launch:campaigns read:contacts write:operators
|
|
483
524
|
Active workspace: de86534d-….
|
|
484
525
|
|
|
485
526
|
WARNING: this key has FEWER permissions than the one it replaced.
|
|
@@ -8,6 +8,19 @@ export interface ConnectionMeta {
|
|
|
8
8
|
workspaceId: string;
|
|
9
9
|
keyPrefix: string;
|
|
10
10
|
connectedAt: string;
|
|
11
|
+
/** Снимок имени на момент connect; отсутствует у legacy-записей. */
|
|
12
|
+
workspaceName?: string;
|
|
13
|
+
/** Маскированная подпись аккаунта; raw email здесь никогда не хранится. */
|
|
14
|
+
accountLabel?: string | null;
|
|
15
|
+
/** Момент получения подписей от API. Отсутствие означает unknown, а не «свежее». */
|
|
16
|
+
labelUpdatedAt?: string;
|
|
17
|
+
/** Эффективные scopes именно этого ключа; не union подключений workspace. */
|
|
18
|
+
grantedScopes?: readonly string[];
|
|
19
|
+
}
|
|
20
|
+
export interface ConnectionLabels {
|
|
21
|
+
readonly workspaceName?: string;
|
|
22
|
+
readonly accountLabel?: string | null;
|
|
23
|
+
readonly grantedScopes?: readonly string[];
|
|
11
24
|
}
|
|
12
25
|
/**
|
|
13
26
|
* Ошибка резолва воркспейса: не подключён / неоднозначно / env-конфликт / нет ключа.
|
|
@@ -25,6 +38,7 @@ export declare class WorkspaceResolutionError extends Error {
|
|
|
25
38
|
export declare class ConnectionStore {
|
|
26
39
|
private readonly storage;
|
|
27
40
|
private legacyMigrationPromise?;
|
|
41
|
+
private labelUpdatePromise;
|
|
28
42
|
constructor(storage?: CredentialStore);
|
|
29
43
|
/**
|
|
30
44
|
* Одноразовая миграция legacy-пары (`api_key` + `workspace_id`) в новую схему.
|
|
@@ -36,12 +50,18 @@ export declare class ConnectionStore {
|
|
|
36
50
|
getKey(workspaceId: string): Promise<string | null>;
|
|
37
51
|
getActive(): Promise<string | null>;
|
|
38
52
|
setActive(workspaceId: string): Promise<void>;
|
|
53
|
+
/** Обновляет только безопасные подписи, не трогая ключ, active и connectedAt. */
|
|
54
|
+
updateLabels(workspaceId: string, labels: ConnectionLabels & {
|
|
55
|
+
workspaceName: string;
|
|
56
|
+
accountLabel: string | null;
|
|
57
|
+
}): Promise<ConnectionMeta>;
|
|
58
|
+
private applyLabelUpdate;
|
|
39
59
|
/**
|
|
40
60
|
* Добавить/обновить подключение воркспейса. Атомарно: при сбое любой записи
|
|
41
61
|
* восстанавливает прежние key/index/active (refresh того же воркспейса не теряет
|
|
42
62
|
* рабочий ключ). Первое подключение становится `active`.
|
|
43
63
|
*/
|
|
44
|
-
addOrReplace(workspaceId: string, apiKey: string): Promise<void>;
|
|
64
|
+
addOrReplace(workspaceId: string, apiKey: string, labels?: ConnectionLabels): Promise<void>;
|
|
45
65
|
remove(workspaceId: string): Promise<void>;
|
|
46
66
|
/**
|
|
47
67
|
* Полная очистка (best-effort): удаляет ВСЕ `key:*` (включая osиротевшие после
|
|
@@ -27,6 +27,7 @@ export class WorkspaceResolutionError extends Error {
|
|
|
27
27
|
export class ConnectionStore {
|
|
28
28
|
storage;
|
|
29
29
|
legacyMigrationPromise;
|
|
30
|
+
labelUpdatePromise = Promise.resolve();
|
|
30
31
|
constructor(storage = new TokenStorage()) {
|
|
31
32
|
this.storage = storage;
|
|
32
33
|
}
|
|
@@ -60,12 +61,34 @@ export class ConnectionStore {
|
|
|
60
61
|
}
|
|
61
62
|
await this.storage.set(ACTIVE_ACCOUNT, workspaceId);
|
|
62
63
|
}
|
|
64
|
+
/** Обновляет только безопасные подписи, не трогая ключ, active и connectedAt. */
|
|
65
|
+
async updateLabels(workspaceId, labels) {
|
|
66
|
+
const update = this.labelUpdatePromise.then(() => this.applyLabelUpdate(workspaceId, labels));
|
|
67
|
+
this.labelUpdatePromise = update.then(() => undefined, () => undefined);
|
|
68
|
+
return update;
|
|
69
|
+
}
|
|
70
|
+
async applyLabelUpdate(workspaceId, labels) {
|
|
71
|
+
const index = await this.readIndex();
|
|
72
|
+
const current = index.find((connection) => connection.workspaceId === workspaceId);
|
|
73
|
+
if (!current) {
|
|
74
|
+
throw new WorkspaceResolutionError(`Workspace ${workspaceId} is not connected.`);
|
|
75
|
+
}
|
|
76
|
+
const updated = {
|
|
77
|
+
...current,
|
|
78
|
+
workspaceName: labels.workspaceName,
|
|
79
|
+
accountLabel: labels.accountLabel,
|
|
80
|
+
labelUpdatedAt: new Date().toISOString(),
|
|
81
|
+
grantedScopes: labels.grantedScopes ?? current.grantedScopes,
|
|
82
|
+
};
|
|
83
|
+
await this.writeIndex(index.map((connection) => (connection.workspaceId === workspaceId ? updated : connection)));
|
|
84
|
+
return updated;
|
|
85
|
+
}
|
|
63
86
|
/**
|
|
64
87
|
* Добавить/обновить подключение воркспейса. Атомарно: при сбое любой записи
|
|
65
88
|
* восстанавливает прежние key/index/active (refresh того же воркспейса не теряет
|
|
66
89
|
* рабочий ключ). Первое подключение становится `active`.
|
|
67
90
|
*/
|
|
68
|
-
async addOrReplace(workspaceId, apiKey) {
|
|
91
|
+
async addOrReplace(workspaceId, apiKey, labels = {}) {
|
|
69
92
|
const [prevKey, prevIndexRaw, prevActive] = await Promise.all([
|
|
70
93
|
this.storage.get(keyAccount(workspaceId)),
|
|
71
94
|
this.storage.get(INDEX_ACCOUNT),
|
|
@@ -74,10 +97,18 @@ export class ConnectionStore {
|
|
|
74
97
|
try {
|
|
75
98
|
await this.storage.set(keyAccount(workspaceId), apiKey);
|
|
76
99
|
const index = await this.readIndex();
|
|
100
|
+
const previousMeta = index.find((connection) => connection.workspaceId === workspaceId);
|
|
101
|
+
const hasFreshLabels = typeof labels.workspaceName === 'string';
|
|
77
102
|
const meta = {
|
|
78
103
|
workspaceId,
|
|
79
104
|
keyPrefix: maskApiKey(apiKey),
|
|
80
105
|
connectedAt: new Date().toISOString(),
|
|
106
|
+
workspaceName: labels.workspaceName ?? previousMeta?.workspaceName,
|
|
107
|
+
accountLabel: hasFreshLabels ? (labels.accountLabel ?? null) : previousMeta?.accountLabel,
|
|
108
|
+
labelUpdatedAt: hasFreshLabels
|
|
109
|
+
? new Date().toISOString()
|
|
110
|
+
: previousMeta?.labelUpdatedAt,
|
|
111
|
+
grantedScopes: labels.grantedScopes ?? previousMeta?.grantedScopes,
|
|
81
112
|
};
|
|
82
113
|
const next = [
|
|
83
114
|
...index.filter((connection) => connection.workspaceId !== workspaceId),
|
|
@@ -203,6 +234,19 @@ function isConnectionMeta(value) {
|
|
|
203
234
|
const candidate = value;
|
|
204
235
|
return (typeof candidate.workspaceId === 'string' &&
|
|
205
236
|
typeof candidate.keyPrefix === 'string' &&
|
|
206
|
-
typeof candidate.connectedAt === 'string'
|
|
237
|
+
typeof candidate.connectedAt === 'string' &&
|
|
238
|
+
isOptionalString(candidate.workspaceName) &&
|
|
239
|
+
isOptionalNullableString(candidate.accountLabel) &&
|
|
240
|
+
isOptionalString(candidate.labelUpdatedAt) &&
|
|
241
|
+
isOptionalStringArray(candidate.grantedScopes));
|
|
242
|
+
}
|
|
243
|
+
function isOptionalString(value) {
|
|
244
|
+
return value === undefined || typeof value === 'string';
|
|
245
|
+
}
|
|
246
|
+
function isOptionalNullableString(value) {
|
|
247
|
+
return value === undefined || value === null || typeof value === 'string';
|
|
248
|
+
}
|
|
249
|
+
function isOptionalStringArray(value) {
|
|
250
|
+
return value === undefined || (Array.isArray(value) && value.every((item) => typeof item === 'string'));
|
|
207
251
|
}
|
|
208
252
|
//# sourceMappingURL=connection-store.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection-store.js","sourceRoot":"","sources":["../../src/auth/connection-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM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qB,CAAC,SAAS,CAAC,aAAa,CAAC,CAC/C,CAAC;AACJ,CAAC;AAED,SAAS,gBAAgB,CAAC,KAAc;IACtC,OAAO,KAAK,KAAK,SAAS,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAC;AAC1D,CAAC;AAED,SAAS,wBAAwB,CAAC,KAAc;IAC9C,OAAO,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAC;AAC5E,CAAC;AAED,SAAS,qBAAqB,CAAC,KAAc;IAC3C,OAAO,KAAK,KAAK,SAAS,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC;AAC1G,CAAC"}
|
|
@@ -18,7 +18,7 @@ export declare const OAUTH_CALLBACK_PATH = "/oauth-callback";
|
|
|
18
18
|
* Сужение теперь не только запрещено правилом: `connect` сверяет выданный набор с набором
|
|
19
19
|
* заменяемого ключа (`droppedScopes` в ответе `/auth/mcp-token`) и печатает потерю.
|
|
20
20
|
*/
|
|
21
|
-
export declare const MCP_OAUTH_SCOPES: readonly ["mcp:*", "mcp:platform-setup", "mcp:funnel-test", "read:campaigns", "launch:campaigns"];
|
|
21
|
+
export declare const MCP_OAUTH_SCOPES: readonly ["mcp:*", "mcp:platform-setup", "mcp:funnel-test", "read:campaigns", "launch:campaigns", "read:contacts", "write:operators"];
|
|
22
22
|
/**
|
|
23
23
|
* Строка `scope` запроса согласия. Аннотация типом из OpenAPI не косметическая: если клиент
|
|
24
24
|
* начнёт просить комбинацию, которой бэкенд не принимает, падает КОМПИЛЯЦИЯ (`yarn build`),
|
|
@@ -30,6 +30,8 @@ export declare const TOKEN_EXCHANGE_TIMEOUT_MS: number;
|
|
|
30
30
|
export interface OAuthConnectResult {
|
|
31
31
|
readonly apiKey: string;
|
|
32
32
|
readonly workspaceId: string;
|
|
33
|
+
readonly workspaceName?: string;
|
|
34
|
+
readonly accountLabel?: string | null;
|
|
33
35
|
/** Права выданного ключа — то, что реально записано в `api_keys.scopes`. */
|
|
34
36
|
readonly scopes: readonly string[];
|
|
35
37
|
/**
|
|
@@ -91,4 +93,6 @@ export declare class OauthClient {
|
|
|
91
93
|
*/
|
|
92
94
|
private defaultExchange;
|
|
93
95
|
}
|
|
96
|
+
/** Парсит token response с backward compatibility для API без label-полей. */
|
|
97
|
+
export declare function parseTokenExchangeResponse(data: unknown): OAuthConnectResult;
|
|
94
98
|
export {};
|
|
@@ -26,6 +26,8 @@ export const MCP_OAUTH_SCOPES = [
|
|
|
26
26
|
'mcp:funnel-test',
|
|
27
27
|
'read:campaigns',
|
|
28
28
|
'launch:campaigns',
|
|
29
|
+
'read:contacts',
|
|
30
|
+
'write:operators',
|
|
29
31
|
];
|
|
30
32
|
/**
|
|
31
33
|
* Строка `scope` запроса согласия. Аннотация типом из OpenAPI не косметическая: если клиент
|
|
@@ -251,19 +253,27 @@ export class OauthClient {
|
|
|
251
253
|
: String(error);
|
|
252
254
|
throw new Error(`MCP token exchange failed (${detail})`);
|
|
253
255
|
}
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
// повод рушить connect — просто не покажем разбор прав.
|
|
263
|
-
scopes: toStringArray(payload.scopes),
|
|
264
|
-
droppedScopes: toStringArray(payload.dropped_scopes),
|
|
265
|
-
};
|
|
256
|
+
return parseTokenExchangeResponse(data);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
/** Парсит token response с backward compatibility для API без label-полей. */
|
|
260
|
+
export function parseTokenExchangeResponse(data) {
|
|
261
|
+
const payload = data;
|
|
262
|
+
if (typeof payload?.api_key !== 'string' || typeof payload?.workspace_id !== 'string') {
|
|
263
|
+
throw new Error('MCP token exchange returned an invalid response');
|
|
266
264
|
}
|
|
265
|
+
return {
|
|
266
|
+
apiKey: payload.api_key,
|
|
267
|
+
workspaceId: payload.workspace_id,
|
|
268
|
+
workspaceName: typeof payload.workspace_name === 'string' ? payload.workspace_name : undefined,
|
|
269
|
+
accountLabel: typeof payload.account_label === 'string' || payload.account_label === null
|
|
270
|
+
? payload.account_label
|
|
271
|
+
: undefined,
|
|
272
|
+
// Поля добавлены позже самого эндпоинта: бэкенд старше клиента их не пришлёт, и это не
|
|
273
|
+
// повод рушить connect — просто не покажем разбор прав и label будет unknown.
|
|
274
|
+
scopes: toStringArray(payload.scopes),
|
|
275
|
+
droppedScopes: toStringArray(payload.dropped_scopes),
|
|
276
|
+
};
|
|
267
277
|
}
|
|
268
278
|
function toStringArray(value) {
|
|
269
279
|
return Array.isArray(value) ? value.filter((item) => typeof item === 'string') : [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oauth-client.js","sourceRoot":"","sources":["../../src/auth/oauth-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,YAAY,EAAuB,MAAM,WAAW,CAAC;AAG9D,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,IAAI,MAAM,MAAM,CAAC;AAGxB,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAM5C,MAAM,CAAC,MAAM,oBAAoB,GAAG,gCAAgC,CAAC;AACrE,MAAM,CAAC,MAAM,2BAA2B,GAAG,6CAA6C,CAAC;AACzF,MAAM,CAAC,MAAM,mBAAmB,GAAG,WAAW,CAAC;AAC/C,MAAM,CAAC,MAAM,mBAAmB,GAAG,iBAAiB,CAAC;AACrD;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,OAAO;IACP,oBAAoB;IACpB,iBAAiB;IACjB,gBAAgB;IAChB,kBAAkB;
|
|
1
|
+
{"version":3,"file":"oauth-client.js","s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,EAAE,CAAC;QACtF,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;IACrE,CAAC;IAED,OAAO;QACL,MAAM,EAAE,OAAO,CAAC,OAAO;QACvB,WAAW,EAAE,OAAO,CAAC,YAAY;QACjC,aAAa,EACX,OAAO,OAAO,CAAC,cAAc,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,SAAS;QACjF,YAAY,EACV,OAAO,OAAO,CAAC,aAAa,KAAK,QAAQ,IAAI,OAAO,CAAC,aAAa,KAAK,IAAI;YACzE,CAAC,CAAC,OAAO,CAAC,aAAa;YACvB,CAAC,CAAC,SAAS;QACf,uFAAuF;QACvF,8EAA8E;QAC9E,MAAM,EAAE,aAAa,CAAC,OAAO,CAAC,MAAM,CAAC;QACrC,aAAa,EAAE,aAAa,CAAC,OAAO,CAAC,cAAc,CAAC;KACrD,CAAC;AACJ,CAAC;AAED,SAAS,aAAa,CAAC,KAAc;IACnC,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAkB,EAAE,CAAC,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AACtG,CAAC"}
|
package/dist/cli.js
CHANGED
|
@@ -96,10 +96,16 @@ async function installSkillCommand(name, force, io, installer) {
|
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
async function connectCommand(io, oauthClient, store) {
|
|
99
|
-
const { apiKey, workspaceId, scopes, droppedScopes } = await oauthClient.connect();
|
|
100
|
-
await store.addOrReplace(workspaceId, apiKey
|
|
99
|
+
const { apiKey, workspaceId, workspaceName, accountLabel, scopes, droppedScopes } = await oauthClient.connect();
|
|
100
|
+
await store.addOrReplace(workspaceId, apiKey, {
|
|
101
|
+
workspaceName,
|
|
102
|
+
accountLabel,
|
|
103
|
+
grantedScopes: scopes,
|
|
104
|
+
});
|
|
101
105
|
const active = await store.getActive();
|
|
102
|
-
|
|
106
|
+
const readableWorkspace = workspaceName ? `${workspaceName} [${workspaceId}]` : workspaceId;
|
|
107
|
+
const readableAccount = accountLabel ? `, account: ${accountLabel}` : '';
|
|
108
|
+
io.log(`Connected to workspace ${readableWorkspace} (key: ${maskApiKey(apiKey)}${readableAccount}).`);
|
|
103
109
|
if (scopes.length > 0) {
|
|
104
110
|
io.log(`Scopes: ${scopes.join(' ')}`);
|
|
105
111
|
}
|
|
@@ -125,7 +131,9 @@ async function connectionsCommand(io, store) {
|
|
|
125
131
|
const active = await store.getActive();
|
|
126
132
|
for (const connection of connections) {
|
|
127
133
|
const marker = connection.workspaceId === active ? '*' : ' ';
|
|
128
|
-
|
|
134
|
+
const name = connection.workspaceName ?? '(name unknown)';
|
|
135
|
+
const account = connection.accountLabel ? `, account: ${connection.accountLabel}` : '';
|
|
136
|
+
io.log(`${marker} ${name} [${connection.workspaceId}] (key: ${connection.keyPrefix}${account})`);
|
|
129
137
|
}
|
|
130
138
|
return 0;
|
|
131
139
|
}
|
|
@@ -180,7 +188,8 @@ async function statusCommand(io, store) {
|
|
|
180
188
|
const active = await store.getActive();
|
|
181
189
|
const activeConnection = connections.find((connection) => connection.workspaceId === active);
|
|
182
190
|
if (activeConnection) {
|
|
183
|
-
|
|
191
|
+
const name = activeConnection.workspaceName ?? '(name unknown)';
|
|
192
|
+
io.log(`Active workspace: ${name} [${activeConnection.workspaceId}] (key: ${activeConnection.keyPrefix}). ${connections.length} connected.`);
|
|
184
193
|
}
|
|
185
194
|
else {
|
|
186
195
|
io.log(`No active workspace selected. ${connections.length} connected — run \`besales-mcp use <workspaceId>\`.`);
|