callkaro-cli-unofficial 0.2.0 → 0.3.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/README.md +260 -260
- package/dist/commands/accounts.js +6 -0
- package/dist/commands/agents.js +6 -1
- package/dist/commands/monitor.js +72 -0
- package/dist/index.js +24 -0
- package/dist/lib/agentUpdate.js +30 -0
- package/dist/lib/api.js +11 -4
- package/dist/lib/config.js +16 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,260 +1,260 @@
|
|
|
1
|
-
# cku
|
|
2
|
-
|
|
3
|
-
An unofficial fork of the [CallKaro CLI](https://www.npmjs.com/package/@callkaro-official/cli). It installs as `cku`, so it sits alongside the official `ck` without either one overwriting the other.
|
|
4
|
-
|
|
5
|
-
Manage voice agents, calls, phone numbers, batch campaigns, simulations and analytics from the terminal — plus the dashboard side, which the official CLI doesn't reach at all.
|
|
6
|
-
|
|
7
|
-
```
|
|
8
|
-
cku agents list
|
|
9
|
-
cku calls make --agent <id> --to <number> --test
|
|
10
|
-
cku kpi tasks --severity "Very High" --column action_items
|
|
11
|
-
cku accounts use tejas@acme.com
|
|
12
|
-
```
|
|
13
|
-
|
|
14
|
-
---
|
|
15
|
-
|
|
16
|
-
## Why this exists
|
|
17
|
-
|
|
18
|
-
**It doesn't fight the official CLI for a name.** Both packages write to the same global `node_modules/.bin`. If both were called `ck`, whichever npm install ran last would silently take over. You'd type `ck`, get official behaviour, and get no signal anything had changed. `cku` cannot collide.
|
|
19
|
-
|
|
20
|
-
**It holds several accounts at once.** The official CLI keeps one session. This one keeps a file per account, and can pin an account to a folder, so two agents working in two directories can't switch each other out from under themselves.
|
|
21
|
-
|
|
22
|
-
**It reaches the dashboard API.** The official CLI only talks to `/cli/*`. That leaves the KPI board, the call analyzers, and the server's own model catalogue unreachable from a terminal — [`cku kpi`](#only-in-cku) is the whole of that surface.
|
|
23
|
-
|
|
24
|
-
**It fixes three upstream bugs.** Details and evidence in [`docs/BUG-REPORT.md`](docs/BUG-REPORT.md).
|
|
25
|
-
|
|
26
|
-
---
|
|
27
|
-
|
|
28
|
-
## Install
|
|
29
|
-
|
|
30
|
-
```bash
|
|
31
|
-
npm install --global callkaro-cli-unofficial
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
Or, to work on it directly:
|
|
35
|
-
|
|
36
|
-
```bash
|
|
37
|
-
git clone https://github.com/TejasLamba2006/callkaro-cli-unofficial
|
|
38
|
-
cd callkaro-cli-unofficial
|
|
39
|
-
npm install && npm run build && npm link
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
Node 18 or newer.
|
|
43
|
-
|
|
44
|
-
---
|
|
45
|
-
|
|
46
|
-
## How it fits together
|
|
47
|
-
|
|
48
|
-

|
|
49
|
-
|
|
50
|
-
Every arrow above is a real import or a real call, checked against the source. `api.ts` is the only thing that touches the network. `config.ts` is the only thing that reads a token, which is why every route to the backend goes through it. The ASCII version below says the same thing for the terminal:
|
|
51
|
-
|
|
52
|
-
```
|
|
53
|
-
┌─ cku ─────────────────────────────────────────────┐
|
|
54
|
-
│ index.ts commander wiring, 44 subcommands │
|
|
55
|
-
│ ↓ │
|
|
56
|
-
│ commands/ agents, calls, numbers, batches, │
|
|
57
|
-
│ sim, analytics, audits, skills │
|
|
58
|
-
│ ↓ │
|
|
59
|
-
│ lib/ api.ts, config.ts, agentUpdate.ts, │
|
|
60
|
-
│ looseJson.ts, ui.ts, catalog.ts │
|
|
61
|
-
└──────┬────────────────────────────────────────────┘
|
|
62
|
-
↓
|
|
63
|
-
account resolution, highest precedence first
|
|
64
|
-
│
|
|
65
|
-
CK_TOKEN → CK_ACCOUNT → ./.cku.json → global → none
|
|
66
|
-
│
|
|
67
|
-
↓
|
|
68
|
-
backend.callkaro.ai
|
|
69
|
-
/cli/* · 61 endpoints · Bearer ck_5b02…
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
One thing worth knowing up front: the official CLI ships **compiled output only**. Its npm package has `dist/` and nothing else: no TypeScript, no tests, no build config, and it isn't in any public repo. So this is a reconstruction. The `/cli/*` contract was rebuilt from the published bundle, and the command surface matches
|
|
73
|
-
|
|
74
|
-
The public API at `api.callkaro.ai` is a different thing entirely, with an `X-API-KEY` header and three documented endpoints. This CLI doesn't use it. [`docs/architecture.md`](docs/architecture.md) covers the boundaries, and [`docs/api.md`](docs/api.md) has the full endpoint inventory.
|
|
75
|
-
|
|
76
|
-
---
|
|
77
|
-
|
|
78
|
-
## Several accounts
|
|
79
|
-
|
|
80
|
-
```bash
|
|
81
|
-
cku login # add an account
|
|
82
|
-
cku accounts # list them, * marks the active one
|
|
83
|
-
cku accounts use <email> # change the global default
|
|
84
|
-
cku accounts remove <email> # forget one
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
### Pin an account to a folder
|
|
88
|
-
|
|
89
|
-
If you're running more than one agent at a time, this is the part that matters.
|
|
90
|
-
|
|
91
|
-
```bash
|
|
92
|
-
cd ~/work/bot-alpha && cku accounts bind alpha@acme.com
|
|
93
|
-
cd ~/work/bot-beta && cku accounts bind beta@other.com
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
`bind` writes a `.cku.json` into that directory containing just the account slug and no token, so it's safe to commit. Every `cku` command in that folder (and anything nested under it) uses that account, regardless of what the global default says.
|
|
97
|
-
|
|
98
|
-
Why this matters: `cku accounts use` changes **shared** state. Two agents in two folders both calling it would overwrite each other, and whichever wrote last would silently redirect the other bot's commands to the wrong CallKaro account. No error, just wrong data. A bound folder never reads shared state at all, so that can't happen.
|
|
99
|
-
|
|
100
|
-
```
|
|
101
|
-
cku accounts status
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
tells you which account is in effect *and where the choice came from*: env var, this folder, or the global default. Worth running first when something looks off, since acting on the wrong account is the most damaging mistake available here.
|
|
105
|
-
|
|
106
|
-
Override for a single command with `CK_ACCOUNT=<email> cku whoami`.
|
|
107
|
-
|
|
108
|
-
---
|
|
109
|
-
|
|
110
|
-
## Fixes over the official CLI
|
|
111
|
-
|
|
112
|
-
Full write-ups, with line numbers and reproduction steps, in [`docs/BUG-REPORT.md`](docs/BUG-REPORT.md).
|
|
113
|
-
|
|
114
|
-
**`agents update --set` silently deleted agent configuration.** Send a partial `voice_configuration` and the backend replaces the whole object, so nine keys, including the voice itself, were dropped, and the command reported success. The agent kept working; it just couldn't make calls. The fix already exists upstream as `deepMerge`, with a comment describing exactly this problem. Nothing ever called it.
|
|
115
|
-
|
|
116
|
-
**`skills install` failed on every run on Windows.** `tar` was handed an absolute path, and `C:/Users/...` gets read as a `<host>:<path>` remote spec, so tar tried to connect to a machine named "C". Since the temp path always sits under a drive root, this never worked there. It's also the only way to install the skill pack, so an agent couldn't bootstrap itself on Windows. Linux and macOS were never affected; no drive letters, no colon in a path.
|
|
117
|
-
|
|
118
|
-
**`agents export` can't always be re-imported.** For some agents the export response omits a field the CLI's own validator requires, so the round trip fails. That part needs a backend fix; a workaround is in the `callkaro-cli` skill.
|
|
119
|
-
|
|
120
|
-
My own first port of this fix had a worse version of the same bug: I merged against the agent's default version, so updating any other version could swap its voice for the default's. That's fixed and covered by a test, and the details are in [`docs/official-fixes.md`](docs/official-fixes.md).
|
|
121
|
-
|
|
122
|
-
---
|
|
123
|
-
|
|
124
|
-
## Only in `cku`
|
|
125
|
-
|
|
126
|
-
Commands and capabilities the official CLI does not have at all. Not bug fixes — surface area.
|
|
127
|
-
|
|
128
|
-
### The KPI manager and the pending-task board
|
|
129
|
-
|
|
130
|
-
The official `ck` has **no KPI commands whatsoever**. This is the only way to reach the board from a terminal.
|
|
131
|
-
|
|
132
|
-
```bash
|
|
133
|
-
cku kpi tasks --severity "Very High" --column action_items --since 7d
|
|
134
|
-
cku kpi show "<taskId>" # cause, recommended fix, metric impact
|
|
135
|
-
cku kpi create --cause "…" --fix "…" --severity High
|
|
136
|
-
cku kpi move "<taskId>" in_progress
|
|
137
|
-
cku kpi comment "<taskId>" "Fixed in v3"
|
|
138
|
-
cku kpi assign "<taskId>" --to "Name" # or --to ai_fde
|
|
139
|
-
cku kpi target --agent <id> --value 25
|
|
140
|
-
cku kpi rca --agent <id> --since 2026-09-01 --until 2026-09-30
|
|
141
|
-
```
|
|
142
|
-
|
|
143
|
-
There is **no delete** for a card — the board retires one by moving it to `rejected`, which is reversible. Only `description` is editable after creation; `cause`, fix and severity are fixed at create, so correcting one means creating a replacement.
|
|
144
|
-
|
|
145
|
-
`GET /pending-tasks` returns every column including `done` and `rejected`, so a closed card is not a gone card. The list prints a **COLUMN** column for exactly that reason, and `--column` filters on it.
|
|
146
|
-
|
|
147
|
-
### The dashboard credential
|
|
148
|
-
|
|
149
|
-
```bash
|
|
150
|
-
cku dashboard login # separate from `cku login`; the token lasts 24h, renewed silently
|
|
151
|
-
cku dashboard whoami
|
|
152
|
-
cku dashboard probe # which dashboard routes this token reaches
|
|
153
|
-
```
|
|
154
|
-
|
|
155
|
-
The dashboard API needs a *different* token from `/cli/*` — they're not interchangeable, and each rejects the other with an opaque 401. This also unlocks `cku analyzers` and `cku models`. The dashboard token expires every 24h with no refresh endpoint, so `cku dashboard login` saves your password (plain text, mode 0600, alongside the tokens) and re-logs in for you when it lapses. Pass `--no-save-password` to keep it off disk and re-enter it daily; `cku dashboard logout` deletes it.
|
|
156
|
-
|
|
157
|
-
### Knowing which models are actually valid
|
|
158
|
-
|
|
159
|
-
```bash
|
|
160
|
-
cku models # per slot, and which field each governs
|
|
161
|
-
cku models --slot agent
|
|
162
|
-
```
|
|
163
|
-
|
|
164
|
-
Models are scoped per slot and **the slots disagree**: `agent` has 44, `post-call` has 9 and excludes `gpt-4o` and `o4-mini`. So the same value is valid in `model` and refused in `postcallmodel`. Works with or without a dashboard session, and says which source it read.
|
|
165
|
-
|
|
166
|
-
### A catalogue that can't silently rot
|
|
167
|
-
|
|
168
|
-
The provider tables, and now the model lists, are regenerated from the server rather than hand-copied:
|
|
169
|
-
|
|
170
|
-
```bash
|
|
171
|
-
npm run catalog:sync # refresh from the bundle + the live server
|
|
172
|
-
npm run catalog:check # fail if catalog.json disagrees with the snapshot
|
|
173
|
-
```
|
|
174
|
-
|
|
175
|
-
`catalog:check` runs offline against a committed snapshot, so it works in CI with no credentials. On 1 October 2026 it caught shipped tables that listed withdrawn models *and* missed live ones in both directions. A wrong voice model otherwise persists silently and only surfaces as a broken call.
|
|
176
|
-
|
|
177
|
-
### Smaller things
|
|
178
|
-
|
|
179
|
-
- `cku calls logs` — grep/awk/sed over the raw call log, in-process, no subprocess and no shell
|
|
180
|
-
- `cku accounts status` — reports which account is in effect **and where that choice came from**
|
|
181
|
-
- Per-project binding, so parallel agents can't redirect each other
|
|
182
|
-
- `secrets set` without the value on the command line
|
|
183
|
-
- `--json` that stays unpaged for scripting, with human tables paged
|
|
184
|
-
|
|
185
|
-
---
|
|
186
|
-
|
|
187
|
-
## Staying current
|
|
188
|
-
|
|
189
|
-
A daily workflow checks npm for a newer `@callkaro-official/cli` and, when it finds one, regenerates the provider catalogue and opens a PR onto the `official` branch. It never merges anything itself.
|
|
190
|
-
|
|
191
|
-
| Branch | What's on it |
|
|
192
|
-
|---|---|
|
|
193
|
-
| `official` | Clean base. Changes only arrive through sync PRs. |
|
|
194
|
-
| `main` | `official` plus your customizations. Your working branch. |
|
|
195
|
-
|
|
196
|
-
To take an update: review the PR, merge into `official`, then merge `official` into `main`.
|
|
197
|
-
|
|
198
|
-
Worth knowing what the sync does and doesn't do. It regenerates `src/data/catalog.json` — the provider tables and the per-slot LLM model lists — because those change when the dashboard changes. It does **not** port command code, because the official source isn't available, so that's maintained by hand. The PR lists which commands were added or removed so you know what to look at.
|
|
199
|
-
|
|
200
|
-
Keep your customizations in as few files as you can. That diff is the one you have to resolve on every update.
|
|
201
|
-
|
|
202
|
-
---
|
|
203
|
-
|
|
204
|
-
## Development
|
|
205
|
-
|
|
206
|
-
```bash
|
|
207
|
-
npm run build # tsc -> dist/, copy endpoints.json, chmod +x
|
|
208
|
-
npm test # build, then node --test
|
|
209
|
-
npm run test:only # tests without rebuilding
|
|
210
|
-
npm run dev # build and run
|
|
211
|
-
npm run catalog:sync # regenerate the catalogue: provider tables + per-slot LLM lists, from the server
|
|
212
|
-
npm run catalog:check # fail if catalog.json disagrees with the server snapshot (offline)
|
|
213
|
-
npm run catalog:check:live # same, against the live server (needs `cku dashboard login`)
|
|
214
|
-
```
|
|
215
|
-
|
|
216
|
-
Single test file:
|
|
217
|
-
|
|
218
|
-
```bash
|
|
219
|
-
node --test tests/agentUpdate.test.js
|
|
220
|
-
```
|
|
221
|
-
|
|
222
|
-
210 tests. No linter or formatter is configured.
|
|
223
|
-
|
|
224
|
-
### Layout
|
|
225
|
-
|
|
226
|
-
`src/index.ts` is commander wiring and almost nothing else. Every command, flag and description is declared there. `src/commands/` holds one module per command group. `src/lib/` holds the shared layer, and that's where the rules worth knowing live:
|
|
227
|
-
|
|
228
|
-
- **`api.ts`** is the only place that talks to the backend. Adding an endpoint means adding a method here, not a raw `fetch` in a command.
|
|
229
|
-
- **`looseJson.ts`** has two parsers, chosen by where the text came from. Values from argv get a repair pass, because PowerShell strips quotes out of single-quoted arguments and `--set '{"name":"x"}'` arrives as `{name:x}`. Values from files or stdin are parsed strictly, since the shell never touched them and a real typo should be reported rather than guessed at.
|
|
230
|
-
- **`agentUpdate.ts`** merges updates into objects the backend replaces wholesale, so a partial update doesn't drop its siblings.
|
|
231
|
-
- **`ui.ts`** sets `process.exitCode` rather than calling `process.exit()`. On Windows, exiting while a fetch socket is still closing trips a libuv assertion that aborts with code 127 and a pile of C-level noise.
|
|
232
|
-
|
|
233
|
-
### Regenerating docs
|
|
234
|
-
|
|
235
|
-
Both of these read from the code, so they can't drift:
|
|
236
|
-
|
|
237
|
-
```bash
|
|
238
|
-
node scripts/gen-api-inventory.js # endpoint tables in docs/api.md
|
|
239
|
-
node scripts/gen-cli-reference.js ../callkaro-skills/skills/callkaro-cli/REFERENCE.md
|
|
240
|
-
```
|
|
241
|
-
|
|
242
|
-
---
|
|
243
|
-
|
|
244
|
-
## Skills
|
|
245
|
-
|
|
246
|
-
The CLI installs a skill pack for Claude Code and other coding agents, so an agent can drive `cku` without being told how.
|
|
247
|
-
|
|
248
|
-
```bash
|
|
249
|
-
cku skills install --claude # this fork's pack
|
|
250
|
-
cku skills install --claude --official # the upstream pack
|
|
251
|
-
cku skills update # refresh every install
|
|
252
|
-
```
|
|
253
|
-
|
|
254
|
-
Targets include `--cursor --copilot --gemini --windsurf --roo --opencode --cline --codex --all`, plus `--project` to install into a repo rather than your user account. Skills ship from GitHub, so a new one reaches users without a CLI release.
|
|
255
|
-
|
|
256
|
-
---
|
|
257
|
-
|
|
258
|
-
## License
|
|
259
|
-
|
|
260
|
-
Apache-2.0, matching the upstream CLI.
|
|
1
|
+
# cku
|
|
2
|
+
|
|
3
|
+
An unofficial fork of the [CallKaro CLI](https://www.npmjs.com/package/@callkaro-official/cli). It installs as `cku`, so it sits alongside the official `ck` without either one overwriting the other.
|
|
4
|
+
|
|
5
|
+
Manage voice agents, calls, phone numbers, batch campaigns, simulations and analytics from the terminal — plus the dashboard side, which the official CLI doesn't reach at all.
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
cku agents list
|
|
9
|
+
cku calls make --agent <id> --to <number> --test
|
|
10
|
+
cku kpi tasks --severity "Very High" --column action_items
|
|
11
|
+
cku accounts use tejas@acme.com
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## Why this exists
|
|
17
|
+
|
|
18
|
+
**It doesn't fight the official CLI for a name.** Both packages write to the same global `node_modules/.bin`. If both were called `ck`, whichever npm install ran last would silently take over. You'd type `ck`, get official behaviour, and get no signal anything had changed. `cku` cannot collide.
|
|
19
|
+
|
|
20
|
+
**It holds several accounts at once.** The official CLI keeps one session. This one keeps a file per account, and can pin an account to a folder, so two agents working in two directories can't switch each other out from under themselves.
|
|
21
|
+
|
|
22
|
+
**It reaches the dashboard API.** The official CLI only talks to `/cli/*`. That leaves the KPI board, the call analyzers, and the server's own model catalogue unreachable from a terminal — [`cku kpi`](#only-in-cku) is the whole of that surface.
|
|
23
|
+
|
|
24
|
+
**It fixes three upstream bugs.** Details and evidence in [`docs/BUG-REPORT.md`](docs/BUG-REPORT.md).
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## Install
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
npm install --global callkaro-cli-unofficial
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Or, to work on it directly:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
git clone https://github.com/TejasLamba2006/callkaro-cli-unofficial
|
|
38
|
+
cd callkaro-cli-unofficial
|
|
39
|
+
npm install && npm run build && npm link
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Node 18 or newer.
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## How it fits together
|
|
47
|
+
|
|
48
|
+

|
|
49
|
+
|
|
50
|
+
Every arrow above is a real import or a real call, checked against the source. `api.ts` is the only thing that touches the network. `config.ts` is the only thing that reads a token, which is why every route to the backend goes through it. The ASCII version below says the same thing for the terminal:
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
┌─ cku ─────────────────────────────────────────────┐
|
|
54
|
+
│ index.ts commander wiring, 44 subcommands │
|
|
55
|
+
│ ↓ │
|
|
56
|
+
│ commands/ agents, calls, numbers, batches, │
|
|
57
|
+
│ sim, analytics, audits, skills │
|
|
58
|
+
│ ↓ │
|
|
59
|
+
│ lib/ api.ts, config.ts, agentUpdate.ts, │
|
|
60
|
+
│ looseJson.ts, ui.ts, catalog.ts │
|
|
61
|
+
└──────┬────────────────────────────────────────────┘
|
|
62
|
+
↓
|
|
63
|
+
account resolution, highest precedence first
|
|
64
|
+
│
|
|
65
|
+
CK_TOKEN → CK_ACCOUNT → ./.cku.json → global → none
|
|
66
|
+
│
|
|
67
|
+
↓
|
|
68
|
+
backend.callkaro.ai
|
|
69
|
+
/cli/* · 61 endpoints · Bearer ck_5b02…
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
One thing worth knowing up front: the official CLI ships **compiled output only**. Its npm package has `dist/` and nothing else: no TypeScript, no tests, no build config, and it isn't in any public repo. So this is a reconstruction. The `/cli/*` contract was rebuilt from the published bundle, and the command surface matches v5.0.0 (the official CLI's commands, its `accounts` group renamed `monitor`, plus the `accounts` group and the dashboard-side `dashboard`, `kpi`, `analyzers` and `models` groups).
|
|
73
|
+
|
|
74
|
+
The public API at `api.callkaro.ai` is a different thing entirely, with an `X-API-KEY` header and three documented endpoints. This CLI doesn't use it. [`docs/architecture.md`](docs/architecture.md) covers the boundaries, and [`docs/api.md`](docs/api.md) has the full endpoint inventory.
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
## Several accounts
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
cku login # add an account
|
|
82
|
+
cku accounts # list them, * marks the active one
|
|
83
|
+
cku accounts use <email> # change the global default
|
|
84
|
+
cku accounts remove <email> # forget one
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Pin an account to a folder
|
|
88
|
+
|
|
89
|
+
If you're running more than one agent at a time, this is the part that matters.
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
cd ~/work/bot-alpha && cku accounts bind alpha@acme.com
|
|
93
|
+
cd ~/work/bot-beta && cku accounts bind beta@other.com
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
`bind` writes a `.cku.json` into that directory containing just the account slug and no token, so it's safe to commit. Every `cku` command in that folder (and anything nested under it) uses that account, regardless of what the global default says.
|
|
97
|
+
|
|
98
|
+
Why this matters: `cku accounts use` changes **shared** state. Two agents in two folders both calling it would overwrite each other, and whichever wrote last would silently redirect the other bot's commands to the wrong CallKaro account. No error, just wrong data. A bound folder never reads shared state at all, so that can't happen.
|
|
99
|
+
|
|
100
|
+
```
|
|
101
|
+
cku accounts status
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
tells you which account is in effect *and where the choice came from*: env var, this folder, or the global default. Worth running first when something looks off, since acting on the wrong account is the most damaging mistake available here.
|
|
105
|
+
|
|
106
|
+
Override for a single command with `CK_ACCOUNT=<email> cku whoami`.
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
## Fixes over the official CLI
|
|
111
|
+
|
|
112
|
+
Full write-ups, with line numbers and reproduction steps, in [`docs/BUG-REPORT.md`](docs/BUG-REPORT.md).
|
|
113
|
+
|
|
114
|
+
**`agents update --set` silently deleted agent configuration.** Send a partial `voice_configuration` and the backend replaces the whole object, so nine keys, including the voice itself, were dropped, and the command reported success. The agent kept working; it just couldn't make calls. The fix already exists upstream as `deepMerge`, with a comment describing exactly this problem. Nothing ever called it.
|
|
115
|
+
|
|
116
|
+
**`skills install` failed on every run on Windows.** `tar` was handed an absolute path, and `C:/Users/...` gets read as a `<host>:<path>` remote spec, so tar tried to connect to a machine named "C". Since the temp path always sits under a drive root, this never worked there. It's also the only way to install the skill pack, so an agent couldn't bootstrap itself on Windows. Linux and macOS were never affected; no drive letters, no colon in a path.
|
|
117
|
+
|
|
118
|
+
**`agents export` can't always be re-imported.** For some agents the export response omits a field the CLI's own validator requires, so the round trip fails. That part needs a backend fix; a workaround is in the `callkaro-cli` skill.
|
|
119
|
+
|
|
120
|
+
My own first port of this fix had a worse version of the same bug: I merged against the agent's default version, so updating any other version could swap its voice for the default's. That's fixed and covered by a test, and the details are in [`docs/official-fixes.md`](docs/official-fixes.md).
|
|
121
|
+
|
|
122
|
+
---
|
|
123
|
+
|
|
124
|
+
## Only in `cku`
|
|
125
|
+
|
|
126
|
+
Commands and capabilities the official CLI does not have at all. Not bug fixes — surface area.
|
|
127
|
+
|
|
128
|
+
### The KPI manager and the pending-task board
|
|
129
|
+
|
|
130
|
+
The official `ck` has **no KPI commands whatsoever**. This is the only way to reach the board from a terminal.
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
cku kpi tasks --severity "Very High" --column action_items --since 7d
|
|
134
|
+
cku kpi show "<taskId>" # cause, recommended fix, metric impact
|
|
135
|
+
cku kpi create --cause "…" --fix "…" --severity High
|
|
136
|
+
cku kpi move "<taskId>" in_progress
|
|
137
|
+
cku kpi comment "<taskId>" "Fixed in v3"
|
|
138
|
+
cku kpi assign "<taskId>" --to "Name" # or --to ai_fde
|
|
139
|
+
cku kpi target --agent <id> --value 25
|
|
140
|
+
cku kpi rca --agent <id> --since 2026-09-01 --until 2026-09-30
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
There is **no delete** for a card — the board retires one by moving it to `rejected`, which is reversible. Only `description` is editable after creation; `cause`, fix and severity are fixed at create, so correcting one means creating a replacement.
|
|
144
|
+
|
|
145
|
+
`GET /pending-tasks` returns every column including `done` and `rejected`, so a closed card is not a gone card. The list prints a **COLUMN** column for exactly that reason, and `--column` filters on it.
|
|
146
|
+
|
|
147
|
+
### The dashboard credential
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
cku dashboard login # separate from `cku login`; the token lasts 24h, renewed silently
|
|
151
|
+
cku dashboard whoami
|
|
152
|
+
cku dashboard probe # which dashboard routes this token reaches
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
The dashboard API needs a *different* token from `/cli/*` — they're not interchangeable, and each rejects the other with an opaque 401. This also unlocks `cku analyzers` and `cku models`. The dashboard token expires every 24h with no refresh endpoint, so `cku dashboard login` saves your password (plain text, mode 0600, alongside the tokens) and re-logs in for you when it lapses. Pass `--no-save-password` to keep it off disk and re-enter it daily; `cku dashboard logout` deletes it.
|
|
156
|
+
|
|
157
|
+
### Knowing which models are actually valid
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
cku models # per slot, and which field each governs
|
|
161
|
+
cku models --slot agent
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
Models are scoped per slot and **the slots disagree**: `agent` has 44, `post-call` has 9 and excludes `gpt-4o` and `o4-mini`. So the same value is valid in `model` and refused in `postcallmodel`. Works with or without a dashboard session, and says which source it read.
|
|
165
|
+
|
|
166
|
+
### A catalogue that can't silently rot
|
|
167
|
+
|
|
168
|
+
The provider tables, and now the model lists, are regenerated from the server rather than hand-copied:
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
npm run catalog:sync # refresh from the bundle + the live server
|
|
172
|
+
npm run catalog:check # fail if catalog.json disagrees with the snapshot
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
`catalog:check` runs offline against a committed snapshot, so it works in CI with no credentials. On 1 October 2026 it caught shipped tables that listed withdrawn models *and* missed live ones in both directions. A wrong voice model otherwise persists silently and only surfaces as a broken call.
|
|
176
|
+
|
|
177
|
+
### Smaller things
|
|
178
|
+
|
|
179
|
+
- `cku calls logs` — grep/awk/sed over the raw call log, in-process, no subprocess and no shell
|
|
180
|
+
- `cku accounts status` — reports which account is in effect **and where that choice came from**
|
|
181
|
+
- Per-project binding, so parallel agents can't redirect each other
|
|
182
|
+
- `secrets set` without the value on the command line
|
|
183
|
+
- `--json` that stays unpaged for scripting, with human tables paged
|
|
184
|
+
|
|
185
|
+
---
|
|
186
|
+
|
|
187
|
+
## Staying current
|
|
188
|
+
|
|
189
|
+
A daily workflow checks npm for a newer `@callkaro-official/cli` and, when it finds one, regenerates the provider catalogue and opens a PR onto the `official` branch. It never merges anything itself.
|
|
190
|
+
|
|
191
|
+
| Branch | What's on it |
|
|
192
|
+
|---|---|
|
|
193
|
+
| `official` | Clean base. Changes only arrive through sync PRs. |
|
|
194
|
+
| `main` | `official` plus your customizations. Your working branch. |
|
|
195
|
+
|
|
196
|
+
To take an update: review the PR, merge into `official`, then merge `official` into `main`.
|
|
197
|
+
|
|
198
|
+
Worth knowing what the sync does and doesn't do. It regenerates `src/data/catalog.json` — the provider tables and the per-slot LLM model lists — because those change when the dashboard changes. It does **not** port command code, because the official source isn't available, so that's maintained by hand. The PR lists which commands were added or removed so you know what to look at.
|
|
199
|
+
|
|
200
|
+
Keep your customizations in as few files as you can. That diff is the one you have to resolve on every update.
|
|
201
|
+
|
|
202
|
+
---
|
|
203
|
+
|
|
204
|
+
## Development
|
|
205
|
+
|
|
206
|
+
```bash
|
|
207
|
+
npm run build # tsc -> dist/, copy endpoints.json, chmod +x
|
|
208
|
+
npm test # build, then node --test
|
|
209
|
+
npm run test:only # tests without rebuilding
|
|
210
|
+
npm run dev # build and run
|
|
211
|
+
npm run catalog:sync # regenerate the catalogue: provider tables + per-slot LLM lists, from the server
|
|
212
|
+
npm run catalog:check # fail if catalog.json disagrees with the server snapshot (offline)
|
|
213
|
+
npm run catalog:check:live # same, against the live server (needs `cku dashboard login`)
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
Single test file:
|
|
217
|
+
|
|
218
|
+
```bash
|
|
219
|
+
node --test tests/agentUpdate.test.js
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
210 tests. No linter or formatter is configured.
|
|
223
|
+
|
|
224
|
+
### Layout
|
|
225
|
+
|
|
226
|
+
`src/index.ts` is commander wiring and almost nothing else. Every command, flag and description is declared there. `src/commands/` holds one module per command group. `src/lib/` holds the shared layer, and that's where the rules worth knowing live:
|
|
227
|
+
|
|
228
|
+
- **`api.ts`** is the only place that talks to the backend. Adding an endpoint means adding a method here, not a raw `fetch` in a command.
|
|
229
|
+
- **`looseJson.ts`** has two parsers, chosen by where the text came from. Values from argv get a repair pass, because PowerShell strips quotes out of single-quoted arguments and `--set '{"name":"x"}'` arrives as `{name:x}`. Values from files or stdin are parsed strictly, since the shell never touched them and a real typo should be reported rather than guessed at.
|
|
230
|
+
- **`agentUpdate.ts`** merges updates into objects the backend replaces wholesale, so a partial update doesn't drop its siblings.
|
|
231
|
+
- **`ui.ts`** sets `process.exitCode` rather than calling `process.exit()`. On Windows, exiting while a fetch socket is still closing trips a libuv assertion that aborts with code 127 and a pile of C-level noise.
|
|
232
|
+
|
|
233
|
+
### Regenerating docs
|
|
234
|
+
|
|
235
|
+
Both of these read from the code, so they can't drift:
|
|
236
|
+
|
|
237
|
+
```bash
|
|
238
|
+
node scripts/gen-api-inventory.js # endpoint tables in docs/api.md
|
|
239
|
+
node scripts/gen-cli-reference.js ../callkaro-skills/skills/callkaro-cli/REFERENCE.md
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
---
|
|
243
|
+
|
|
244
|
+
## Skills
|
|
245
|
+
|
|
246
|
+
The CLI installs a skill pack for Claude Code and other coding agents, so an agent can drive `cku` without being told how.
|
|
247
|
+
|
|
248
|
+
```bash
|
|
249
|
+
cku skills install --claude # this fork's pack
|
|
250
|
+
cku skills install --claude --official # the upstream pack
|
|
251
|
+
cku skills update # refresh every install
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
Targets include `--cursor --copilot --gemini --windsurf --roo --opencode --cline --codex --all`, plus `--project` to install into a repo rather than your user account. Skills ship from GitHub, so a new one reaches users without a CLI release.
|
|
255
|
+
|
|
256
|
+
---
|
|
257
|
+
|
|
258
|
+
## License
|
|
259
|
+
|
|
260
|
+
Apache-2.0, matching the upstream CLI.
|
|
@@ -116,12 +116,15 @@ async function whoamiCommand(opts) {
|
|
|
116
116
|
if (opts.json)
|
|
117
117
|
return void console.log(JSON.stringify(res, null, 2));
|
|
118
118
|
const user = res.user || res;
|
|
119
|
+
const monitoring = res.monitoring?.active ? res.monitoring.account : undefined;
|
|
119
120
|
if (!user?.email) {
|
|
120
121
|
(0, ui_1.fail)('Could not read your account details. Run `cku login`.');
|
|
121
122
|
process.exitCode = 1;
|
|
122
123
|
return;
|
|
123
124
|
}
|
|
124
125
|
(0, ui_1.success)(`Logged in as ${user.email}`);
|
|
126
|
+
if (monitoring)
|
|
127
|
+
(0, ui_1.info)(` MONITORING ${monitoring.name || monitoring.email} (${monitoring.id})`);
|
|
125
128
|
}
|
|
126
129
|
catch (err) {
|
|
127
130
|
(0, ui_1.handleError)(err);
|
|
@@ -148,6 +151,9 @@ async function configCommand() {
|
|
|
148
151
|
else {
|
|
149
152
|
(0, ui_1.info)(' session not signed in — run `cku login`');
|
|
150
153
|
}
|
|
154
|
+
const monitored = process.env.CK_ACCOUNT_ID || cfg.monitoring?.id;
|
|
155
|
+
if (monitored)
|
|
156
|
+
(0, ui_1.info)(` monitoring ${monitored} (acting on a client account — \`cku monitor clear\` to leave)`);
|
|
151
157
|
(0, ui_1.info)(` accounts ${accounts.length} saved${accounts.length ? ` — \`cku accounts list\`` : ''}`);
|
|
152
158
|
}
|
|
153
159
|
/** `cku accounts` — list / switch / add / remove stored logins. */
|
package/dist/commands/agents.js
CHANGED
|
@@ -427,9 +427,14 @@ async function agentsUpdateCommand(agentId, opts) {
|
|
|
427
427
|
// *target* version: without one, getAgent returns the default version, and
|
|
428
428
|
// its siblings (provider, voice id, …) would be written onto a different
|
|
429
429
|
// version. Wholesale keys are version-level, so --versions is set here.
|
|
430
|
-
|
|
430
|
+
// `functions` is a whole array on the backend: merge by name unless the
|
|
431
|
+
// caller asked to replace the list.
|
|
432
|
+
const mergeFns = Array.isArray(patch.functions) && !opts.replaceFunctions;
|
|
433
|
+
if (wholesaleKeys.length || mergeFns) {
|
|
431
434
|
const { agent } = await api.getAgent(agentId, (0, versions_1.firstVersion)(opts.versions));
|
|
432
435
|
patch = (0, agentUpdate_1.mergeWholesaleKeys)(patch, agent);
|
|
436
|
+
if (mergeFns)
|
|
437
|
+
patch.functions = (0, agentUpdate_1.mergeFunctions)(patch.functions, agent.functions);
|
|
433
438
|
}
|
|
434
439
|
// A commit message is recorded against a version. Version-level updates
|
|
435
440
|
// already name one; for an agent-level-only update with --commit, attach it
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.monitorListCommand = monitorListCommand;
|
|
4
|
+
exports.monitorUseCommand = monitorUseCommand;
|
|
5
|
+
exports.monitorCurrentCommand = monitorCurrentCommand;
|
|
6
|
+
exports.monitorClearCommand = monitorClearCommand;
|
|
7
|
+
const config_1 = require("../lib/config");
|
|
8
|
+
const session_1 = require("../lib/session");
|
|
9
|
+
const ui_1 = require("../lib/ui");
|
|
10
|
+
// Official v5 `accounts` group, renamed: `cku accounts` already means local saved logins.
|
|
11
|
+
async function monitorListCommand(opts) {
|
|
12
|
+
try {
|
|
13
|
+
const api = (0, session_1.requireApi)();
|
|
14
|
+
const { accounts } = await api.listClientAccounts();
|
|
15
|
+
if (opts.json)
|
|
16
|
+
return void console.log(JSON.stringify(accounts, null, 2));
|
|
17
|
+
if (!accounts?.length)
|
|
18
|
+
return void (0, ui_1.info)('No client accounts are assigned to you.');
|
|
19
|
+
const current = (0, config_1.monitoringAccountId)();
|
|
20
|
+
(0, ui_1.table)(['Active', 'Name', 'Email', 'Account ID'], accounts.map((a) => [current === a.id ? '*' : '', a.name || '', a.email || '', a.id]));
|
|
21
|
+
}
|
|
22
|
+
catch (err) {
|
|
23
|
+
(0, ui_1.handleError)(err);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
async function monitorUseCommand(accountId) {
|
|
27
|
+
try {
|
|
28
|
+
const api = (0, session_1.requireApi)();
|
|
29
|
+
const { accounts } = await api.listClientAccounts();
|
|
30
|
+
const account = (accounts || []).find((a) => a.id === accountId);
|
|
31
|
+
if (!account) {
|
|
32
|
+
(0, ui_1.fail)('That client account is not assigned to you. Run `cku monitor list`.');
|
|
33
|
+
process.exitCode = 1;
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
if (!(0, config_1.setMonitoring)({ id: account.id, name: account.name, email: account.email })) {
|
|
37
|
+
(0, ui_1.fail)('No stored account to save this on (CK_TOKEN only?). Set CK_ACCOUNT_ID for this shell instead.');
|
|
38
|
+
process.exitCode = 1;
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
(0, ui_1.success)(`Monitoring ${account.name || account.email || account.id}. Every command now acts on that account.`);
|
|
42
|
+
if (process.env.CK_ACCOUNT_ID)
|
|
43
|
+
(0, ui_1.info)(' CK_ACCOUNT_ID is set and overrides this; unset it to use the stored choice.');
|
|
44
|
+
}
|
|
45
|
+
catch (err) {
|
|
46
|
+
(0, ui_1.handleError)(err);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function monitorCurrentCommand(opts) {
|
|
50
|
+
const envId = process.env.CK_ACCOUNT_ID;
|
|
51
|
+
const stored = (0, config_1.loadConfig)().monitoring;
|
|
52
|
+
if (!envId && !stored)
|
|
53
|
+
return void (0, ui_1.info)('Monitoring mode is off.');
|
|
54
|
+
const current = envId ? { id: envId, source: 'CK_ACCOUNT_ID' } : { ...stored, source: 'config' };
|
|
55
|
+
if (opts.json)
|
|
56
|
+
return void console.log(JSON.stringify(current, null, 2));
|
|
57
|
+
(0, ui_1.keyValue)({
|
|
58
|
+
mode: 'MONITORING',
|
|
59
|
+
account: envId || stored?.name || stored?.email || stored?.id,
|
|
60
|
+
accountId: current.id,
|
|
61
|
+
source: current.source,
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
function monitorClearCommand() {
|
|
65
|
+
if (process.env.CK_ACCOUNT_ID) {
|
|
66
|
+
(0, ui_1.fail)('CK_ACCOUNT_ID is set for this process. Unset it to leave monitoring mode.');
|
|
67
|
+
process.exitCode = 1;
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
(0, config_1.setMonitoring)(undefined);
|
|
71
|
+
(0, ui_1.success)('Monitoring mode is off.');
|
|
72
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -8,6 +8,7 @@ const commander_1 = require("commander");
|
|
|
8
8
|
const chalk_1 = __importDefault(require("chalk"));
|
|
9
9
|
const ui_1 = require("./lib/ui");
|
|
10
10
|
const accounts_1 = require("./commands/accounts");
|
|
11
|
+
const monitor_1 = require("./commands/monitor");
|
|
11
12
|
const dashboardAuth_1 = require("./lib/dashboardAuth");
|
|
12
13
|
const kpi_1 = require("./commands/kpi");
|
|
13
14
|
/** Board columns, for `--help`. Ids are what the server keys on, not labels. */
|
|
@@ -281,6 +282,28 @@ accounts
|
|
|
281
282
|
.description('forget a saved login')
|
|
282
283
|
.option('--yes', 'skip confirmation')
|
|
283
284
|
.action(accounts_1.accountsRemoveCommand);
|
|
285
|
+
// --- monitoring mode (official 5.0: client accounts assigned to you) -------
|
|
286
|
+
const monitor = program
|
|
287
|
+
.command('monitor')
|
|
288
|
+
.description('act on a client account assigned to you (official 5.0 `accounts`, renamed)');
|
|
289
|
+
monitor
|
|
290
|
+
.command('list', { isDefault: true })
|
|
291
|
+
.description('list client accounts assigned to you (* = monitored)')
|
|
292
|
+
.option('--json', 'output raw JSON')
|
|
293
|
+
.action(monitor_1.monitorListCommand);
|
|
294
|
+
monitor
|
|
295
|
+
.command('use <accountId>')
|
|
296
|
+
.description('enter monitoring mode: every command acts on that client account')
|
|
297
|
+
.action(monitor_1.monitorUseCommand);
|
|
298
|
+
monitor
|
|
299
|
+
.command('current')
|
|
300
|
+
.description('show the monitored account, if any')
|
|
301
|
+
.option('--json', 'output raw JSON')
|
|
302
|
+
.action(monitor_1.monitorCurrentCommand);
|
|
303
|
+
monitor
|
|
304
|
+
.command('clear')
|
|
305
|
+
.description('leave monitoring mode')
|
|
306
|
+
.action(monitor_1.monitorClearCommand);
|
|
284
307
|
program
|
|
285
308
|
.command('update')
|
|
286
309
|
.description('upgrade the CLI to the latest release, then refresh the skill pack')
|
|
@@ -325,6 +348,7 @@ agents.command('update <agentId>').description('update fields via --set \'{json}
|
|
|
325
348
|
.option('--set <json>', "JSON object of fields (or @file.json), e.g. '{\"name\":\"x\",\"temperature\":5}'")
|
|
326
349
|
.option('--versions <id>', 'target a specific version (needed for version-level fields)')
|
|
327
350
|
.option('--commit <msg>', 'commit message for the version change')
|
|
351
|
+
.option('--replace-functions', 'replace the whole functions list instead of merging by name (default merges; omitted functions are kept)')
|
|
328
352
|
.option('--json', 'output the raw updated-agent response')
|
|
329
353
|
.action(agents_1.agentsUpdateCommand);
|
|
330
354
|
// Phone assignment (agent-centric). The one-inbound-agent rule is enforced server-side.
|
package/dist/lib/agentUpdate.js
CHANGED
|
@@ -9,6 +9,7 @@ exports.preparePatch = preparePatch;
|
|
|
9
9
|
exports.coerce = coerce;
|
|
10
10
|
exports.deepMerge = deepMerge;
|
|
11
11
|
exports.mergeWholesaleKeys = mergeWholesaleKeys;
|
|
12
|
+
exports.mergeFunctions = mergeFunctions;
|
|
12
13
|
exports.isAgentLevelKey = isAgentLevelKey;
|
|
13
14
|
exports.normalizeStringArray = normalizeStringArray;
|
|
14
15
|
const agentImport_1 = require("./agentImport");
|
|
@@ -251,6 +252,35 @@ function mergeWholesaleKeys(patch, current) {
|
|
|
251
252
|
}
|
|
252
253
|
return out;
|
|
253
254
|
}
|
|
255
|
+
/**
|
|
256
|
+
* Merge a partial `functions` array into the version's current one, by `name`:
|
|
257
|
+
* a matching name is replaced, a new name is appended, the rest are kept.
|
|
258
|
+
*
|
|
259
|
+
* The backend replaces the whole array, so sending one function would delete
|
|
260
|
+
* every other function on the version while reporting success.
|
|
261
|
+
*/
|
|
262
|
+
function mergeFunctions(incoming, current) {
|
|
263
|
+
if (!Array.isArray(incoming))
|
|
264
|
+
throw new Error('"functions" must be an array of function objects.');
|
|
265
|
+
const out = Array.isArray(current) ? [...current] : [];
|
|
266
|
+
const seen = new Set();
|
|
267
|
+
incoming.forEach((fn, i) => {
|
|
268
|
+
const name = fn && typeof fn === 'object' ? fn.name : undefined;
|
|
269
|
+
if (typeof name !== 'string' || !name.trim()) {
|
|
270
|
+
throw new Error(`functions[${i}] has no "name". Functions are merged by name, so each needs one.\n` +
|
|
271
|
+
' To replace the whole list on purpose, pass --replace-functions.');
|
|
272
|
+
}
|
|
273
|
+
if (seen.has(name))
|
|
274
|
+
throw new Error(`functions lists "${name}" twice.`);
|
|
275
|
+
seen.add(name);
|
|
276
|
+
const at = out.findIndex((c) => c && c.name === name);
|
|
277
|
+
if (at >= 0)
|
|
278
|
+
out[at] = fn;
|
|
279
|
+
else
|
|
280
|
+
out.push(fn);
|
|
281
|
+
});
|
|
282
|
+
return out;
|
|
283
|
+
}
|
|
254
284
|
function isAgentLevelKey(key) {
|
|
255
285
|
return agentImport_1.AGENT_LEVEL_KEYS.has(key);
|
|
256
286
|
}
|
package/dist/lib/api.js
CHANGED
|
@@ -13,21 +13,26 @@ const types_1 = require("./types");
|
|
|
13
13
|
*/
|
|
14
14
|
class Api {
|
|
15
15
|
token;
|
|
16
|
+
monitoringAccountId;
|
|
16
17
|
baseUrl;
|
|
17
18
|
callBaseUrl;
|
|
18
|
-
constructor(baseUrl, callBaseUrl, token) {
|
|
19
|
+
constructor(baseUrl, callBaseUrl, token, monitoringAccountId) {
|
|
19
20
|
this.token = token;
|
|
21
|
+
this.monitoringAccountId = monitoringAccountId;
|
|
20
22
|
this.baseUrl = baseUrl.replace(/\/+$/, '');
|
|
21
23
|
this.callBaseUrl = (callBaseUrl || baseUrl).replace(/\/+$/, '');
|
|
22
24
|
}
|
|
23
|
-
request(method, path, body) {
|
|
24
|
-
return this.requestTo(this.baseUrl, method, path, body);
|
|
25
|
+
request(method, path, body, includeAccount = true) {
|
|
26
|
+
return this.requestTo(this.baseUrl, method, path, body, includeAccount);
|
|
25
27
|
}
|
|
26
28
|
/** Same as request(), but against a specific base URL (e.g. the call cloud). */
|
|
27
|
-
async requestTo(base, method, path, body) {
|
|
29
|
+
async requestTo(base, method, path, body, includeAccount = true) {
|
|
28
30
|
const headers = { 'Content-Type': 'application/json' };
|
|
29
31
|
if (this.token)
|
|
30
32
|
headers.Authorization = `Bearer ${this.token}`;
|
|
33
|
+
// Monitoring mode: every request, writes included, acts on the client account.
|
|
34
|
+
if (includeAccount && this.monitoringAccountId)
|
|
35
|
+
headers['X-CallKaro-Account-Id'] = this.monitoringAccountId;
|
|
31
36
|
let res;
|
|
32
37
|
try {
|
|
33
38
|
res = await fetch(`${base}${path}`, {
|
|
@@ -59,6 +64,8 @@ class Api {
|
|
|
59
64
|
return this.request('GET', `/cli/auth/browser/poll?code=${encodeURIComponent(code)}&secret=${encodeURIComponent(secret)}`);
|
|
60
65
|
}
|
|
61
66
|
me() { return this.request('GET', '/cli/auth/me'); }
|
|
67
|
+
/** Client accounts assigned to this user. Sent without the monitoring header: it lists, not acts. */
|
|
68
|
+
listClientAccounts() { return this.request('GET', '/cli/auth/accounts', undefined, false); }
|
|
62
69
|
// --- secrets --------------------------------------------------------------
|
|
63
70
|
listSecrets() { return this.request('GET', '/cli/secrets'); }
|
|
64
71
|
saveSecrets(secrets) { return this.request('PUT', '/cli/secrets', { secrets }); }
|
package/dist/lib/config.js
CHANGED
|
@@ -27,6 +27,8 @@ exports.removeAccount = removeAccount;
|
|
|
27
27
|
exports.loadConfig = loadConfig;
|
|
28
28
|
exports.clearSession = clearSession;
|
|
29
29
|
exports.saveLogin = saveLogin;
|
|
30
|
+
exports.monitoringAccountId = monitoringAccountId;
|
|
31
|
+
exports.setMonitoring = setMonitoring;
|
|
30
32
|
exports.getClient = getClient;
|
|
31
33
|
const fs_1 = require("fs");
|
|
32
34
|
const os_1 = require("os");
|
|
@@ -347,8 +349,21 @@ function saveLogin(email, session) {
|
|
|
347
349
|
? saved + ` This shell still uses ${current} via CK_ACCOUNT. Unset it, or set CK_ACCOUNT=${email}, to switch.`
|
|
348
350
|
: saved + ` This folder still uses ${current} via .cku.json. Run \`cku accounts bind ${email}\` to switch.`;
|
|
349
351
|
}
|
|
352
|
+
/** The client account in effect, if any: CK_ACCOUNT_ID wins over the stored choice. */
|
|
353
|
+
function monitoringAccountId(cfg = loadConfig()) {
|
|
354
|
+
return process.env.CK_ACCOUNT_ID || cfg.monitoring?.id || undefined;
|
|
355
|
+
}
|
|
356
|
+
/** Set or clear (undefined) the monitored account on the effective stored account. */
|
|
357
|
+
function setMonitoring(monitoring) {
|
|
358
|
+
const slug = activeAccount();
|
|
359
|
+
if (!slug || !(0, fs_1.existsSync)(accountPath(slug)))
|
|
360
|
+
return false;
|
|
361
|
+
const { monitoring: _old, ...rest } = loadAccount(slug);
|
|
362
|
+
writeJson(accountPath(slug), monitoring ? { ...rest, monitoring } : rest);
|
|
363
|
+
return true;
|
|
364
|
+
}
|
|
350
365
|
/** Build the API client from the endpoint URLs + resolved token. */
|
|
351
366
|
function getClient() {
|
|
352
367
|
const cfg = loadConfig();
|
|
353
|
-
return { api: new api_1.Api(backendUrl(), callUrl(), cfg.token), cfg };
|
|
368
|
+
return { api: new api_1.Api(backendUrl(), callUrl(), cfg.token, monitoringAccountId(cfg)), cfg };
|
|
354
369
|
}
|