@kumion/cli 0.6.2 → 0.6.4
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 +48 -4
- package/dist/cli.js +7 -0
- package/dist/client.js +4 -2
- package/dist/data-ops.js +196 -0
- package/dist/main.js +183 -8
- package/dist/mcp.js +20 -5
- package/package.json +1 -1
- package/skills/kumion/SKILL.md +20 -5
package/README.md
CHANGED
|
@@ -119,6 +119,25 @@ would use.
|
|
|
119
119
|
| `kumion staff list` | `agents:read` |
|
|
120
120
|
| `kumion staff create --name <name> [--transfer-target <number>] [--department <text>] [--kana <text>] [--email <address>] [--note <text>] [--enabled false]` | `agents:write` (draft-side: no call reaches a new row until a 用件's 転送 names its key and the agent is published) |
|
|
121
121
|
| `kumion staff update <staffId> --revision <rev> [--name ...] [--transfer-target ...] [--enabled true\|false]` | `agents:live` (live: no publish) |
|
|
122
|
+
| `kumion contacts list [--q <text>] [--limit <n>] [--offset <n>]` | `contacts:read` |
|
|
123
|
+
| `kumion contacts get <contactId>` | `contacts:read` |
|
|
124
|
+
| `kumion contacts create --name <text> [--phone <text>] [--kana <text>] [--department <text>] [--email <text>] [--note <text>] [--topics <value> ...] [--custom <key>=<value> ...]` | `contacts:write` |
|
|
125
|
+
| `kumion contacts update <contactId> [--name <text>] [--phone <text>] [--kana <text>] [--department <text>] [--email <text>] [--note <text>] [--enabled true\|false] [--topics <value> ...] [--custom <key>=<value> ...]` | `contacts:write` |
|
|
126
|
+
| `kumion contacts calls <contactId> [--limit <n>] [--offset <n>]` | `contacts:read` |
|
|
127
|
+
| `kumion contact-fields list` | `contacts:read` |
|
|
128
|
+
| `kumion calls link-contact <callId> --name <text>` | `calls:write` |
|
|
129
|
+
| `kumion call-marks list <callId>` | `calls:read` |
|
|
130
|
+
| `kumion call-marks set <callId> --type <text> [--citation <text>] [--note <text>]` | `calls:write` |
|
|
131
|
+
| `kumion call-marks clear <callId> <typeId>` | `calls:write` |
|
|
132
|
+
| `kumion call-marks create-type --name <text>` | `calls:write` |
|
|
133
|
+
| `kumion callback-lists create --call <value> ... [--name <text>]` | `calls:write` |
|
|
134
|
+
| `kumion captures list [--type <text>] [--spec <text>] [--agent <text>] [--field <text>] [--value <text>] [--q <text>] [--status open\|done\|dismissed] [--from <text>] [--to <text>] [--limit <n>] [--offset <n>]` | `captures:read` |
|
|
135
|
+
| `kumion captures update <captureId> [--status open\|done\|dismissed] [--note <text>]` | `captures:write` |
|
|
136
|
+
| `kumion captures status-log <captureId>` | `captures:read` |
|
|
137
|
+
| `kumion documents history <documentId>` | `agents:read` |
|
|
138
|
+
| `kumion documents version-diff <documentId> --from <n> --to <n>` | `agents:read` |
|
|
139
|
+
| `kumion documents rollback <documentId> --target-version <n>` | `agents:live` (live: no publish) |
|
|
140
|
+
| `kumion analytics get [--agent <text>] [--channel <text>] [--from <text>] [--to <text>] [--spec <text>] [--field-key <text>]` | `analytics:read` |
|
|
122
141
|
| `kumion hours get [--from <date>] [--to <date>] [--json]` | `agents:read` |
|
|
123
142
|
| `kumion hours update --revision <rev> [--business-hours-file <path>] [--closed-rules-file <path>] [--observe-jp-holidays true\|false] [--dry-run]` | `agents:live` (live: no publish) |
|
|
124
143
|
| `kumion hours exception set <date> --revision <rev> --kind closed\|open\|inherit [--hours-file <path>] [--note <text>] [--dry-run]` | `agents:live` (live: no publish) |
|
|
@@ -140,7 +159,7 @@ would use.
|
|
|
140
159
|
| `kumion documents jobs get <jobId>` | `agents:read` (exits 1 when the job failed or timed out) |
|
|
141
160
|
| `kumion documents get <documentId>` | `agents:read` |
|
|
142
161
|
| `kumion documents replace <documentId> --source <sourceDocumentId> --source-revision <rev> --revision <rev> [--dry-run]` | `agents:live` (live: no publish) |
|
|
143
|
-
| `kumion test-runs start <agentId> [--no-wait] [--interval <sec>] [--timeout <sec>]` | `tests:run` |
|
|
162
|
+
| `kumion test-runs start <agentId> [--turns <file\|->] [--no-wait] [--interval <sec>] [--timeout <sec>]` | `tests:run` |
|
|
144
163
|
| `kumion test-runs get <agentId> <runId>` | `tests:run` |
|
|
145
164
|
| `kumion test-runs list <agentId>` | `tests:run` |
|
|
146
165
|
| `kumion calls create <agentId> [--to <phone>] [--campaign-contact <id>] [--var <name>=<value> ...]` | `calls:create` |
|
|
@@ -364,9 +383,10 @@ A key a node does not store follows the agent's setting (会話の運用) or the
|
|
|
364
383
|
| `wait_cover` | start, agent | `tune` | `{ enabled?, on_threshold?, threshold_ms?, on_query_start?, query_grace_ms? }` | Node-level hold phrase. By default it plays only when a lookup tool is still running after `query_grace_ms` (100 to 10000, default 1000); `on_query_start: false` turns that off. `on_threshold: true` also plays it after `threshold_ms` (2000 to 15000, default 2000) of silence on an ordinary turn (default off). `enabled: false` turns it off for this node. The phrase text is set per agent. |
|
|
365
384
|
| `trigger_path` | trigger | `internal` | `string` | Generated. Shown read-only as the trigger URL. |
|
|
366
385
|
| `opening_speech` | start | `required` | `string` | The opening line. Supports {{variables}}. |
|
|
367
|
-
| `items` | start, agent | `required` | `{key,label?,example?,source?,value_type?,options?,must_ask?,min_digits?,max_digits?,tool
|
|
386
|
+
| `items` | start, agent | `required` | `{key,label?,example?,source?,value_type?,options?,must_ask?,min_digits?,max_digits?,tool?}[]` | What this step collects, one object per item, in the order it asks. `key`: slot key. `label`: display name. `example`: test-call example. `source`: where the value comes from (caller, derived, system, tool). `value_type`: kind (text, select, boolean, ...). `options`: choices of a select item. `must_ask`: ask the caller to confirm on the spot even if already known (advanced). `min_digits` / `max_digits`: for a `code` item, the fewest / most digits the value may hold, counted by the platform (the same number twice = exact length). `tool`: `{tool_key,result_field}` for a tool-sourced item. |
|
|
368
387
|
| `allow_interruptions` | start, agent | `tune` | `boolean` | Absent means the caller may interrupt. Only an explicit false is stored. |
|
|
369
388
|
| `route_judge` | start | `tune` | `boolean` | Absent means off. Only an explicit true is stored. On: while the call stays on this start step, each caller turn is first read by the call model's own probability readout (at most 400 ms, before the AI answers); when it is sure which of the step's three connections fits, the call moves on without a model turn. Offered only for a call model whose endpoint has a calibrated readout; the step needs exactly three AI connections without items and no fixed connections (graph diagnostics `route_judge_not_applicable`). |
|
|
389
|
+
| `ai_disclosure_stated` | start | `tune` | `boolean` | Absent means not declared. Only an explicit true is stored. The author's own statement that the opening tells the caller they are speaking with an AI; the platform does not read the opening for it. Not declared: graph diagnostics `opening_no_ai_disclosure` (a warning, never blocks). |
|
|
370
390
|
| `wait_for_first_word` | start | `tune` | `boolean` | Absent means off. Only an explicit true is stored. On: an outbound call waits for the customer to speak first and says the opening line when they finish or `first_word_wait_seconds` runs out. An inbound call never reads it (graph diagnostics `first_word_wait_outbound_only`). |
|
|
371
391
|
| `first_word_wait_seconds` | start | `tune` | `number` | Seconds `wait_for_first_word` waits (1 to 10, default 3). Absent means the default. Read only when `wait_for_first_word` is true. |
|
|
372
392
|
| `respond_on_enter` | agent | `tune` | `boolean` | Absent means the node answers on arrival. Only an explicit false (wait for the caller) is stored. |
|
|
@@ -380,7 +400,7 @@ A key a node does not store follows the agent's setting (会話の運用) or the
|
|
|
380
400
|
| `opening_audio_filename` | start | `internal` | `string` | Display name of the uploaded opening audio. |
|
|
381
401
|
| `precall_fetch_url` | start | `advanced` | `string` | URL fetched before the call starts; the response becomes call variables. |
|
|
382
402
|
| `precall_fetch_method` | start | `advanced` | `string` | HTTP method of the pre-call fetch. |
|
|
383
|
-
| `precall_fetch_headers` | start | `advanced` | `{ key,
|
|
403
|
+
| `precall_fetch_headers` | start | `advanced` | `{ key, secret }[]` | Headers of the pre-call fetch. A value is never returned: a row you read has `secret` (a reference); to set a value send `{ key, value }` once, and the reply has the reference. Send read rows back unchanged. |
|
|
384
404
|
| `no_response` | start, agent | `advanced` | `{ timeout_s, reprompt_speech?, max_reprompts, then }` | Node-level no-response timer. { timeout_s: 0 } turns the agent default off here. |
|
|
385
405
|
| `kb_fallback` | start, agent | `advanced` | `{ noResult?, unavailable? }` | Wording when a knowledge search finds nothing or is unavailable. Overrides the tenant operations setting. |
|
|
386
406
|
| `end_speech` | end | `required` | `string` | Default goodbye line. A connection into this node can override it. |
|
|
@@ -391,7 +411,7 @@ A key a node does not store follows the agent's setting (会話の運用) or the
|
|
|
391
411
|
| `http_method` | webhook | `required` | `string` | GET, POST, PUT, PATCH or DELETE. |
|
|
392
412
|
| `endpoint_url` | webhook | `required` | `string` | Destination URL. |
|
|
393
413
|
| `payload_template` | webhook | `required` | `string` | Request body template with {{variables}}. |
|
|
394
|
-
| `custom_headers` | webhook | `advanced` | `{ key,
|
|
414
|
+
| `custom_headers` | webhook | `advanced` | `{ key, secret }[]` | Extra request headers. A value is never returned: a row you read has `secret` (a reference); to set a value send `{ key, value }` once, and the reply has the reference. Send read rows back unchanged. |
|
|
395
415
|
| `qa_system_prompt` | qa | `required` | `string` | Evaluation prompt. |
|
|
396
416
|
| `qa_sample_rate` | qa | `required` | `number` | Percentage of calls analysed, 1 to 100. |
|
|
397
417
|
| `qa_min_call_duration` | qa | `required` | `number` | Shortest call (seconds) that is analysed. |
|
|
@@ -438,6 +458,30 @@ each re-run's outcome. When a check before the test calls refuses (most often th
|
|
|
438
458
|
cases to print: the server's message after `Server said:` is the whole reason, one
|
|
439
459
|
problem per line.
|
|
440
460
|
|
|
461
|
+
### Replaying a caller's own lines
|
|
462
|
+
|
|
463
|
+
`test-runs start` builds the caller's side from the examples in the flow. To run the lines of a
|
|
464
|
+
real call that failed, hand them over instead:
|
|
465
|
+
|
|
466
|
+
```sh
|
|
467
|
+
kumion test-runs start <agentId> --turns lines.json # or: ... --turns - < lines.json
|
|
468
|
+
```
|
|
469
|
+
|
|
470
|
+
`lines.json` is `["予約したいです", "山田太郎です"]` or `[{ "caller": "予約したいです" }, ...]`
|
|
471
|
+
(MCP: `start_test_run` with `turns`; HTTP: `POST .../test-runs` with `{ "turns": [{ "caller": "..." }] }`).
|
|
472
|
+
The lines go to the draft one per turn, in order. Nothing is graded and no "please hang up" line is added:
|
|
473
|
+
the result is the conversation, the path the call took, the tool calls and a trace (`event`, `tool`,
|
|
474
|
+
`status`, a short `detail`). `stopReason` says why it stopped: `lines_done` (every line played, the
|
|
475
|
+
call still going), `agent_ended` (the agent ended the call first; the lines never sent are in
|
|
476
|
+
`unsentLines`) or `reply_timeout` (a line got no answer in time). The run ends `completed` and the
|
|
477
|
+
CLI exits 0 in all three; `could_not_run`, `timeout` and `cancelled` exit 1.
|
|
478
|
+
|
|
479
|
+
Limits: at most 30 lines, 500 characters per line and 6,000 characters in all (more is `400
|
|
480
|
+
replay_too_long`). One test run per agent at a time (`409`) and the same hourly limit per key as a
|
|
481
|
+
suite run (`429`). A replay needs the same `tests:run` scope, publishes nothing, makes no call in the
|
|
482
|
+
tenant's call history and counts against no call quota. The lines may hold what a real caller said:
|
|
483
|
+
they are kept in the run's results for as long as any test run is.
|
|
484
|
+
|
|
441
485
|
## From a template to public
|
|
442
486
|
|
|
443
487
|
One path from an empty tenant to a published agent, with nothing but the CLI (each command is also
|
package/dist/cli.js
CHANGED
|
@@ -50,6 +50,12 @@ async function prompt(question, options = {}) {
|
|
|
50
50
|
stdin.on("data", onData);
|
|
51
51
|
});
|
|
52
52
|
}
|
|
53
|
+
async function readStdin() {
|
|
54
|
+
const chunks = [];
|
|
55
|
+
for await (const chunk of process.stdin)
|
|
56
|
+
chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
|
|
57
|
+
return Buffer.concat(chunks).toString("utf8");
|
|
58
|
+
}
|
|
53
59
|
const io = {
|
|
54
60
|
out: (text) => process.stdout.write(text.endsWith("\n") ? text : text + "\n"),
|
|
55
61
|
err: (text) => process.stderr.write(text.endsWith("\n") ? text : text + "\n"),
|
|
@@ -68,6 +74,7 @@ const code = await run(process.argv.slice(2), {
|
|
|
68
74
|
config: ConfigFile.forEnv(process.env),
|
|
69
75
|
io,
|
|
70
76
|
sleep: (ms) => sleep(ms),
|
|
77
|
+
readStdin,
|
|
71
78
|
mcpTransport: stdioTransport,
|
|
72
79
|
});
|
|
73
80
|
process.exitCode = code;
|
package/dist/client.js
CHANGED
|
@@ -243,8 +243,10 @@ export class KumionClient {
|
|
|
243
243
|
});
|
|
244
244
|
return body;
|
|
245
245
|
}
|
|
246
|
-
async startTestRun(agentId) {
|
|
247
|
-
const { body } = await this.request("POST", this.agentPath(agentId, "/test-runs"), "tests:run", {
|
|
246
|
+
async startTestRun(agentId, turns) {
|
|
247
|
+
const { body } = await this.request("POST", this.agentPath(agentId, "/test-runs"), "tests:run", {
|
|
248
|
+
body: turns ? { turns } : {},
|
|
249
|
+
});
|
|
248
250
|
return body.testRun;
|
|
249
251
|
}
|
|
250
252
|
async getTestRun(agentId, runId) {
|
package/dist/data-ops.js
ADDED
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
const page = [
|
|
3
|
+
{ name: "limit", kind: "number", help: "page size (default 20, at most 100)" },
|
|
4
|
+
{ name: "offset", kind: "number", help: "rows to skip" },
|
|
5
|
+
];
|
|
6
|
+
const STATUS = ["open", "done", "dismissed"];
|
|
7
|
+
export const DATA_OPS = [
|
|
8
|
+
{
|
|
9
|
+
cli: "contacts list", mcp: "list_contacts", method: "GET", path: "/contacts", scope: "contacts:read",
|
|
10
|
+
query: [{ name: "q", kind: "string", help: "search text (name, number)" }, ...page],
|
|
11
|
+
description: "List the tenant's お客様 (customer contacts), one page at a time. スタッフ are list_staff. Needs contacts:read.",
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
cli: "contacts get", mcp: "get_contact", method: "GET", path: "/contacts/{contactId}", scope: "contacts:read",
|
|
15
|
+
description: "Read one お客様 with the phone numbers on it. Needs contacts:read.",
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
cli: "contacts create", mcp: "create_contact", method: "POST", path: "/contacts", scope: "contacts:write",
|
|
19
|
+
body: [
|
|
20
|
+
{ name: "displayName", kind: "string", required: true, flag: "name", help: "the name shown in the contact book" },
|
|
21
|
+
{ name: "phone", kind: "string", help: "phone number" },
|
|
22
|
+
{ name: "kana", kind: "string", help: "the name in kana" },
|
|
23
|
+
{ name: "department", kind: "string", help: "team or company" },
|
|
24
|
+
{ name: "email", kind: "string", help: "email address" },
|
|
25
|
+
{ name: "note", kind: "string", help: "a note" },
|
|
26
|
+
{ name: "topics", kind: "list", help: "topics (repeat the flag)" },
|
|
27
|
+
{ name: "custom", kind: "map", help: "custom fields as <fieldId>=<value> (ids from contact-fields list)" },
|
|
28
|
+
],
|
|
29
|
+
description: "Register an お客様. Saved at once; 409 when a customer already has that phone number. Needs contacts:write.",
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
cli: "contacts update", mcp: "update_contact", method: "PATCH", path: "/contacts/{contactId}", scope: "contacts:write",
|
|
33
|
+
body: [
|
|
34
|
+
{ name: "displayName", kind: "string", flag: "name", help: "the name" },
|
|
35
|
+
{ name: "phone", kind: "string", help: "phone number (an empty string clears it)" },
|
|
36
|
+
{ name: "kana", kind: "string", help: "kana (an empty string clears it)" },
|
|
37
|
+
{ name: "department", kind: "string", help: "team or company (an empty string clears it)" },
|
|
38
|
+
{ name: "email", kind: "string", help: "email (an empty string clears it)" },
|
|
39
|
+
{ name: "note", kind: "string", help: "a note (an empty string clears it)" },
|
|
40
|
+
{ name: "enabled", kind: "boolean", help: "true or false" },
|
|
41
|
+
{ name: "topics", kind: "list", help: "topics (repeat the flag; replaces the list)" },
|
|
42
|
+
{ name: "custom", kind: "map", help: "custom fields as <fieldId>=<value>" },
|
|
43
|
+
],
|
|
44
|
+
description: "Change an お客様; only the fields you pass change. Needs contacts:write.",
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
cli: "contacts calls", mcp: "list_contact_calls", method: "GET", path: "/contacts/{contactId}/calls", scope: "contacts:read",
|
|
48
|
+
query: [...page],
|
|
49
|
+
description: "The calls tied to one お客様 (made by them, or transferred to them), newest first. Needs contacts:read.",
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
cli: "contact-fields list", mcp: "list_contact_fields", method: "GET", path: "/contact-fields", scope: "contacts:read",
|
|
53
|
+
description: "The definitions of the お客様 custom fields (the ids `custom` is keyed by). Needs contacts:read.",
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
cli: "calls link-contact", mcp: "link_call_contact", method: "POST", path: "/calls/{callId}/contact", scope: "calls:write",
|
|
57
|
+
body: [{ name: "displayName", kind: "string", required: true, flag: "name", help: "the お客様's name" }],
|
|
58
|
+
description: "Register (or find) the お客様 for a call's caller number and link the call to them, with every other unlinked call from that number. 409 when the call is already linked. Needs calls:write.",
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
cli: "call-marks list", mcp: "list_call_marks", method: "GET", path: "/calls/{callId}/marks", scope: "calls:read",
|
|
62
|
+
description: "The marks on a call, the mark types to choose from, and the knowledge entries a 誤案内 mark may name. Needs calls:read.",
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
cli: "call-marks set", mcp: "set_call_mark", method: "POST", path: "/calls/{callId}/marks", scope: "calls:write",
|
|
66
|
+
body: [
|
|
67
|
+
{ name: "typeId", kind: "string", required: true, flag: "type", help: "mark type id (from call-marks list)" },
|
|
68
|
+
{ name: "citationId", kind: "string", flag: "citation", help: "the entry behind a 誤案内 mark" },
|
|
69
|
+
{ name: "note", kind: "string", help: "a note" },
|
|
70
|
+
],
|
|
71
|
+
description: "Put a mark on a call; marking the same type again replaces its note and entry. Needs calls:write.",
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
cli: "call-marks clear", mcp: "clear_call_mark", method: "DELETE", path: "/calls/{callId}/marks/{typeId}", scope: "calls:write",
|
|
75
|
+
description: "Take one mark off a call. Needs calls:write.",
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
cli: "call-marks create-type", mcp: "create_call_mark_type", method: "POST", path: "/call-mark-types", scope: "calls:write",
|
|
79
|
+
body: [{ name: "name", kind: "string", required: true, help: "the mark's name" }],
|
|
80
|
+
description: "Add a mark type of the tenant's own. Needs calls:write.",
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
cli: "callback-lists create", mcp: "create_callback_list", method: "POST", path: "/callback-lists", scope: "calls:write",
|
|
84
|
+
body: [
|
|
85
|
+
{ name: "callIds", kind: "list", required: true, flag: "call", help: "a call id (repeat the flag)" },
|
|
86
|
+
{ name: "name", kind: "string", help: "the list's name" },
|
|
87
|
+
],
|
|
88
|
+
description: "Make a draft callback list from calls. Nothing is dialled; starting it is done on the callback list screen. Needs calls:write.",
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
cli: "captures list", mcp: "list_captures", method: "GET", path: "/captures", scope: "captures:read",
|
|
92
|
+
query: [
|
|
93
|
+
{ name: "type", kind: "string", help: "summary definition key" },
|
|
94
|
+
{ name: "specId", kind: "string", flag: "spec", help: "summary definition id" },
|
|
95
|
+
{ name: "agentId", kind: "string", flag: "agent", help: "only this agent's" },
|
|
96
|
+
{ name: "field", kind: "string", help: "field key (with --value)" },
|
|
97
|
+
{ name: "value", kind: "string", help: "that field's value (with --field)" },
|
|
98
|
+
{ name: "q", kind: "string", help: "search text" },
|
|
99
|
+
{ name: "status", kind: "string", values: STATUS, help: "open|done|dismissed" },
|
|
100
|
+
{ name: "from", kind: "string", help: "at or after (ISO 8601)" },
|
|
101
|
+
{ name: "to", kind: "string", help: "at or before (ISO 8601)" },
|
|
102
|
+
...page,
|
|
103
|
+
],
|
|
104
|
+
description: "List the summaries recorded during calls, newest first, one page at a time. Needs captures:read.",
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
cli: "captures update", mcp: "update_capture", method: "PATCH", path: "/captures/{captureId}", scope: "captures:write",
|
|
108
|
+
body: [
|
|
109
|
+
{ name: "status", kind: "string", values: STATUS, help: "open|done|dismissed" },
|
|
110
|
+
{ name: "handledNote", kind: "string", flag: "note", help: "handling note (up to 1000 characters; an empty string clears it)" },
|
|
111
|
+
],
|
|
112
|
+
description: "Change a summary's handling status and note. The assignee is set on the screen. A status change is logged under the API key's name. Needs captures:write.",
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
cli: "captures status-log", mcp: "get_capture_status_log", method: "GET", path: "/captures/{captureId}/status-log", scope: "captures:read",
|
|
116
|
+
description: "Who changed a summary's handling status, when, from what to what, newest first. Needs captures:read.",
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
cli: "documents history", mcp: "get_document_history", method: "GET", path: "/documents/{documentId}/history", scope: "agents:read",
|
|
120
|
+
description: "The version history of one document. Needs agents:read.",
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
cli: "documents version-diff", mcp: "get_document_version_diff", method: "GET", path: "/documents/{documentId}/version-diff", scope: "agents:read",
|
|
124
|
+
query: [
|
|
125
|
+
{ name: "from", kind: "number", required: true, help: "the version to compare from" },
|
|
126
|
+
{ name: "to", kind: "number", required: true, help: "the version to compare to" },
|
|
127
|
+
],
|
|
128
|
+
description: "Two versions of one document as the lines a call's model reads. Needs agents:read.",
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
cli: "documents rollback", mcp: "rollback_document", method: "POST", path: "/documents/{documentId}/rollback", scope: "agents:live",
|
|
132
|
+
body: [{ name: "version", kind: "number", required: true, flag: "target-version", help: "the version to restore (from documents history)" }],
|
|
133
|
+
description: "Put an earlier version of a document back as its content; history is kept and the restored content becomes a new version. LIVE: the next call already reads it, no publish — confirm with the person first. Needs agents:live.",
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
cli: "analytics get", mcp: "get_analytics", method: "GET", path: "/analytics", scope: "analytics:read",
|
|
137
|
+
query: [
|
|
138
|
+
{ name: "agentId", kind: "string", flag: "agent", help: "only this agent's calls" },
|
|
139
|
+
{ name: "channel", kind: "string", help: "webcall|sip_did|trigger" },
|
|
140
|
+
{ name: "from", kind: "string", help: "started at or after (ISO 8601)" },
|
|
141
|
+
{ name: "to", kind: "string", help: "started before (ISO 8601)" },
|
|
142
|
+
{ name: "specId", kind: "string", flag: "spec", help: "summary definition id (with --field-key)" },
|
|
143
|
+
{ name: "fieldKey", kind: "string", help: "select field key (with --spec)" },
|
|
144
|
+
],
|
|
145
|
+
description: "The analytics screen's numbers; filters are the call list's. specId + fieldKey add that select field's distribution. Needs analytics:read.",
|
|
146
|
+
},
|
|
147
|
+
];
|
|
148
|
+
export function pathArgs(op) {
|
|
149
|
+
return [...op.path.matchAll(/\{(\w+)\}/g)].map((m) => m[1]);
|
|
150
|
+
}
|
|
151
|
+
export const flagOf = (field) => field.flag ?? field.name.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`);
|
|
152
|
+
export async function runDataOp(client, op, input) {
|
|
153
|
+
const path = op.path.replace(/\{(\w+)\}/g, (_, name) => encodeURIComponent(String(input[name])));
|
|
154
|
+
const query = new URLSearchParams();
|
|
155
|
+
for (const field of op.query ?? []) {
|
|
156
|
+
const value = input[field.name];
|
|
157
|
+
if (value !== undefined && value !== "")
|
|
158
|
+
query.set(field.name, String(value));
|
|
159
|
+
}
|
|
160
|
+
const qs = query.toString();
|
|
161
|
+
const bodyFields = op.body ?? [];
|
|
162
|
+
const body = {};
|
|
163
|
+
for (const field of bodyFields)
|
|
164
|
+
if (input[field.name] !== undefined)
|
|
165
|
+
body[field.name] = input[field.name];
|
|
166
|
+
const { body: answer } = await client.request(op.method, client.tenantPath(`${path}${qs ? `?${qs}` : ""}`), op.scope, {
|
|
167
|
+
...(op.method === "POST" || op.method === "PATCH" ? { body } : {}),
|
|
168
|
+
});
|
|
169
|
+
return answer;
|
|
170
|
+
}
|
|
171
|
+
export function mcpShape(op) {
|
|
172
|
+
const shape = {};
|
|
173
|
+
for (const name of pathArgs(op))
|
|
174
|
+
shape[name] = z.string().min(1).describe(`The ${name}.`);
|
|
175
|
+
for (const field of [...(op.query ?? []), ...(op.body ?? [])]) {
|
|
176
|
+
let type;
|
|
177
|
+
switch (field.kind) {
|
|
178
|
+
case "number":
|
|
179
|
+
type = z.number();
|
|
180
|
+
break;
|
|
181
|
+
case "boolean":
|
|
182
|
+
type = z.boolean();
|
|
183
|
+
break;
|
|
184
|
+
case "list":
|
|
185
|
+
type = z.array(z.string());
|
|
186
|
+
break;
|
|
187
|
+
case "map":
|
|
188
|
+
type = z.record(z.string(), z.string());
|
|
189
|
+
break;
|
|
190
|
+
default:
|
|
191
|
+
type = field.values ? z.enum(field.values) : z.string();
|
|
192
|
+
}
|
|
193
|
+
shape[field.name] = (field.required ? type : type.optional()).describe(field.help);
|
|
194
|
+
}
|
|
195
|
+
return shape;
|
|
196
|
+
}
|
package/dist/main.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { readFile, writeFile } from "node:fs/promises";
|
|
2
2
|
import { basename, join } from "node:path";
|
|
3
3
|
import { parseArgs } from "node:util";
|
|
4
|
+
import { DATA_OPS, flagOf, pathArgs, runDataOp } from "./data-ops.js";
|
|
4
5
|
import { ApiError, KumionClient, isTextFile, specText, } from "./client.js";
|
|
5
6
|
import { DEFAULT_BASE_URL, keyPrefix, looksLikeApiKey, normalizeBaseUrl, resolveCredentials, } from "./credentials.js";
|
|
6
7
|
import { DEFAULT_DEVICE_SCOPES, deviceLogin } from "./device-login.js";
|
|
7
8
|
import { describeError, ReportedFailure, UsageError } from "./errors.js";
|
|
8
|
-
export const VERSION = "0.6.
|
|
9
|
+
export const VERSION = "0.6.4";
|
|
9
10
|
const HELP = `kumion — manage your Kumion voice agents over the Partner API
|
|
10
11
|
|
|
11
12
|
Usage: kumion <command> [options]
|
|
@@ -74,6 +75,53 @@ Flow
|
|
|
74
75
|
Templates
|
|
75
76
|
templates list List the onboarding templates and their ids
|
|
76
77
|
|
|
78
|
+
Customers, marks and records (need the contacts:*, calls:write, captures:* or analytics:read scope; rollback needs agents:live)
|
|
79
|
+
contacts list [--q <text>] [--limit <n>] [--offset <n>]
|
|
80
|
+
List the お客様 (customers); staff are under "staff list"
|
|
81
|
+
contacts get <contactId>
|
|
82
|
+
Show one お客様 with their phone numbers
|
|
83
|
+
contacts create --name <text> [--phone <text>] [--kana <text>] [--department
|
|
84
|
+
<text>] [--email <text>] [--note <text>] [--topics <value> ...]
|
|
85
|
+
[--custom <key>=<value> ...]
|
|
86
|
+
Register an お客様
|
|
87
|
+
contacts update <contactId> [--name <text>] [--phone <text>] [--kana <text>]
|
|
88
|
+
[--department <text>] [--email <text>] [--note <text>] [--enabled
|
|
89
|
+
true|false] [--topics <value> ...] [--custom <key>=<value> ...]
|
|
90
|
+
Change an お客様 ("" clears a text field)
|
|
91
|
+
contacts calls <contactId> [--limit <n>] [--offset <n>]
|
|
92
|
+
The calls tied to one お客様
|
|
93
|
+
contact-fields list
|
|
94
|
+
The custom-field definitions (ids for --custom)
|
|
95
|
+
calls link-contact <callId> --name <text>
|
|
96
|
+
Link a call and its caller number to an お客様 (made if new)
|
|
97
|
+
call-marks list <callId>
|
|
98
|
+
The marks on a call and the mark types to choose from
|
|
99
|
+
call-marks set <callId> --type <text> [--citation <text>] [--note <text>]
|
|
100
|
+
Put a mark on a call
|
|
101
|
+
call-marks clear <callId> <typeId>
|
|
102
|
+
Take a mark off a call
|
|
103
|
+
call-marks create-type --name <text>
|
|
104
|
+
Add a mark type
|
|
105
|
+
callback-lists create --call <value> ... [--name <text>]
|
|
106
|
+
Make a draft callback list from calls (nothing is dialled)
|
|
107
|
+
captures list [--type <text>] [--spec <text>] [--agent <text>] [--field
|
|
108
|
+
<text>] [--value <text>] [--q <text>] [--status open|done|dismissed]
|
|
109
|
+
[--from <text>] [--to <text>] [--limit <n>] [--offset <n>]
|
|
110
|
+
List the recorded summaries, newest first
|
|
111
|
+
captures update <captureId> [--status open|done|dismissed] [--note <text>]
|
|
112
|
+
Set a summary's handling status and note
|
|
113
|
+
captures status-log <captureId>
|
|
114
|
+
Who changed a summary's status, when
|
|
115
|
+
documents history <documentId>
|
|
116
|
+
Version history of one document
|
|
117
|
+
documents version-diff <documentId> --from <n> --to <n>
|
|
118
|
+
Two versions of a document, as the model reads them
|
|
119
|
+
documents rollback <documentId> --target-version <n>
|
|
120
|
+
Restore an earlier version. LIVE: the next call reads it, no publish
|
|
121
|
+
analytics get [--agent <text>] [--channel <text>] [--from <text>] [--to
|
|
122
|
+
<text>] [--spec <text>] [--field-key <text>]
|
|
123
|
+
The analytics screen's numbers
|
|
124
|
+
|
|
77
125
|
Staff (the people a 用件 can transfer a call to)
|
|
78
126
|
staff list List the スタッフ with their transfer key, 転送先 and revision
|
|
79
127
|
staff create --name <name> [--transfer-target <number>] [--department <text>]
|
|
@@ -184,8 +232,16 @@ Documents (資料 — the source an agent's facts are extracted from)
|
|
|
184
232
|
LIVE: the next call reads the new facts. Needs agents:live
|
|
185
233
|
|
|
186
234
|
Test runs
|
|
187
|
-
test-runs start <agentId> [--no-wait] [--interval <sec>] [--timeout <sec>]
|
|
188
|
-
Run the agent's regression tests against its draft
|
|
235
|
+
test-runs start <agentId> [--turns <file|->] [--no-wait] [--interval <sec>] [--timeout <sec>]
|
|
236
|
+
Run the agent's regression tests against its draft.
|
|
237
|
+
With --turns, play the caller's own lines instead of the
|
|
238
|
+
suite's: a JSON file (or - for stdin) holding ["line", ...]
|
|
239
|
+
or [{ "caller": "line" }, ...], at most 30 lines, 500
|
|
240
|
+
characters each and 6,000 in all. The lines go in order,
|
|
241
|
+
nothing is graded, and the result is the conversation, the
|
|
242
|
+
path, the tool calls and the trace. Exit 0 once the lines
|
|
243
|
+
were played or the call ended first. The lines may hold
|
|
244
|
+
what a real caller said; the run keeps them like any run
|
|
189
245
|
test-runs get <agentId> <runId> Show one run and its results
|
|
190
246
|
test-runs list <agentId> [--limit <n>]
|
|
191
247
|
|
|
@@ -194,8 +250,9 @@ Calls
|
|
|
194
250
|
Start a web call with the agent; with --to, dial that
|
|
195
251
|
domestic number instead (--var is read as {{vars.<name>}})
|
|
196
252
|
calls list [--agent <id>] [--channel webcall|sip_did|trigger] [--from <iso>] [--to <iso>]
|
|
197
|
-
[--search <text>] [--limit <n>] [--offset <n>]
|
|
198
|
-
List the tenant's call history, newest first (20 per page)
|
|
253
|
+
[--search <text>] [--content <text>] [--limit <n>] [--offset <n>]
|
|
254
|
+
List the tenant's call history, newest first (20 per page);
|
|
255
|
+
--content searches what was said (needs --from and --to)
|
|
199
256
|
scheduled-calls create <agentId> --to <phone> --at <iso8601-with-offset> [--var <name>=<value> ...]
|
|
200
257
|
Schedule one dial at that time (e.g. 2026-10-31T13:00:00+09:00)
|
|
201
258
|
scheduled-calls list List the dials scheduled through the API, newest first
|
|
@@ -371,6 +428,7 @@ export const COMMANDS = {
|
|
|
371
428
|
"calls list": callsList,
|
|
372
429
|
"calls get": callsGet,
|
|
373
430
|
"calls transcript": callsTranscript,
|
|
431
|
+
...Object.fromEntries(DATA_OPS.map((op) => [op.cli, dataOpHandler(op)])),
|
|
374
432
|
};
|
|
375
433
|
async function authLogin(args, deps) {
|
|
376
434
|
const { values } = parse(args, {
|
|
@@ -1778,8 +1836,64 @@ async function flowEditSteps(args, deps) {
|
|
|
1778
1836
|
deps.io.out(lines.join("\n"));
|
|
1779
1837
|
return 0;
|
|
1780
1838
|
}
|
|
1781
|
-
const TERMINAL = new Set(["passed", "failed", "could_not_run", "timeout", "cancelled"]);
|
|
1839
|
+
const TERMINAL = new Set(["passed", "failed", "could_not_run", "timeout", "cancelled", "completed"]);
|
|
1840
|
+
export function replayTurnsFrom(raw) {
|
|
1841
|
+
if (!Array.isArray(raw) || raw.length === 0) {
|
|
1842
|
+
throw new UsageError('--turns needs a JSON array of lines: ["line", ...] or [{ "caller": "line" }, ...].');
|
|
1843
|
+
}
|
|
1844
|
+
return raw.map((item, index) => {
|
|
1845
|
+
const caller = typeof item === "string" ? item : item && typeof item === "object" ? item.caller : undefined;
|
|
1846
|
+
if (typeof caller !== "string" || caller.trim() === "") {
|
|
1847
|
+
throw new UsageError(`--turns: item ${index} must be a non-empty string or { "caller": "..." }.`);
|
|
1848
|
+
}
|
|
1849
|
+
return { caller };
|
|
1850
|
+
});
|
|
1851
|
+
}
|
|
1852
|
+
async function readTurns(source, deps) {
|
|
1853
|
+
let text;
|
|
1854
|
+
if (source === "-") {
|
|
1855
|
+
if (!deps.readStdin)
|
|
1856
|
+
throw new UsageError("--turns - needs stdin, which this host does not provide.");
|
|
1857
|
+
text = await deps.readStdin();
|
|
1858
|
+
}
|
|
1859
|
+
else {
|
|
1860
|
+
text = await readTextFile(source);
|
|
1861
|
+
}
|
|
1862
|
+
try {
|
|
1863
|
+
return replayTurnsFrom(JSON.parse(text));
|
|
1864
|
+
}
|
|
1865
|
+
catch (err) {
|
|
1866
|
+
if (err instanceof UsageError)
|
|
1867
|
+
throw err;
|
|
1868
|
+
throw new UsageError(`--turns ${source === "-" ? "(stdin)" : source} is not valid JSON: ${err.message}`);
|
|
1869
|
+
}
|
|
1870
|
+
}
|
|
1871
|
+
const STOP_REASON_TEXT = {
|
|
1872
|
+
lines_done: "all lines were played and the call was still going",
|
|
1873
|
+
agent_ended: "the agent ended the call before the lines ran out",
|
|
1874
|
+
reply_timeout: "the agent did not answer a line in time",
|
|
1875
|
+
};
|
|
1876
|
+
export function summarizeReplay(run) {
|
|
1877
|
+
const lines = [`Replay ${run.id}: ${run.status.toUpperCase()}`];
|
|
1878
|
+
const result = (run.results ?? []).find((r) => r.caseId === "replay");
|
|
1879
|
+
if (!result)
|
|
1880
|
+
return lines.join("\n");
|
|
1881
|
+
lines.push(`Stopped: ${result.stopReason ? `${result.stopReason} (${STOP_REASON_TEXT[result.stopReason] ?? result.stopReason})` : "unknown"}`);
|
|
1882
|
+
for (const [i, turn] of (result.turns ?? []).entries()) {
|
|
1883
|
+
lines.push(`#${i + 1} caller: ${turn.user}`, `#${i + 1} agent : ${turn.assistant || "(no reply)"} [${turn.nodeKey}]`);
|
|
1884
|
+
}
|
|
1885
|
+
if (result.unsentLines?.length)
|
|
1886
|
+
lines.push(`Not sent (${result.unsentLines.length}): ${result.unsentLines.join(" / ")}`);
|
|
1887
|
+
if (result.observedPath?.length)
|
|
1888
|
+
lines.push(`Path: ${result.observedPath.join(" → ")}${result.reachedEnd ? " (call ended)" : ""}`);
|
|
1889
|
+
for (const row of result.trace ?? []) {
|
|
1890
|
+
lines.push(`trace #${row.turn} ${row.event} ${row.tool ?? ""} ${row.status ?? ""} ${JSON.stringify(row.detail)}`.replace(/ {2,}/g, " "));
|
|
1891
|
+
}
|
|
1892
|
+
return lines.join("\n");
|
|
1893
|
+
}
|
|
1782
1894
|
export function summarizeTestRun(run) {
|
|
1895
|
+
if (run.kind === "replay")
|
|
1896
|
+
return summarizeReplay(run);
|
|
1783
1897
|
const lines = [
|
|
1784
1898
|
`Test run ${run.id}: ${run.status.toUpperCase()} (${run.casesDone}/${run.casesTotal} cases)`,
|
|
1785
1899
|
];
|
|
@@ -1810,12 +1924,14 @@ async function testRunsStart(args, deps) {
|
|
|
1810
1924
|
"no-wait": { type: "boolean" },
|
|
1811
1925
|
interval: { type: "string" },
|
|
1812
1926
|
timeout: { type: "string" },
|
|
1927
|
+
turns: { type: "string" },
|
|
1813
1928
|
});
|
|
1814
1929
|
const agentId = need(positionals, 0, "agentId");
|
|
1815
1930
|
const intervalMs = positiveNumber(values.interval, "interval", 3) * 1000;
|
|
1816
1931
|
const timeoutMs = positiveNumber(values.timeout, "timeout", 900) * 1000;
|
|
1817
1932
|
const client = await clientFor(values, deps);
|
|
1818
|
-
|
|
1933
|
+
const turns = values.turns === undefined ? undefined : await readTurns(values.turns, deps);
|
|
1934
|
+
let run = await client.startTestRun(agentId, turns);
|
|
1819
1935
|
if (values["no-wait"]) {
|
|
1820
1936
|
if (values.json)
|
|
1821
1937
|
printJson(deps, { testRun: run });
|
|
@@ -1843,7 +1959,7 @@ async function testRunsStart(args, deps) {
|
|
|
1843
1959
|
printJson(deps, { testRun: run });
|
|
1844
1960
|
else
|
|
1845
1961
|
deps.io.out(summarizeTestRun(run));
|
|
1846
|
-
return run.status === "passed" ? 0 : 1;
|
|
1962
|
+
return run.status === "passed" || run.status === "completed" ? 0 : 1;
|
|
1847
1963
|
}
|
|
1848
1964
|
async function testRunsGet(args, deps) {
|
|
1849
1965
|
const { values, positionals } = parse(args, {});
|
|
@@ -1952,6 +2068,63 @@ function wholeNumber(raw, flag) {
|
|
|
1952
2068
|
throw new UsageError(`--${flag} must be a whole number (0 or more).`);
|
|
1953
2069
|
return n;
|
|
1954
2070
|
}
|
|
2071
|
+
function dataOpHandler(op) {
|
|
2072
|
+
return async (args, deps) => {
|
|
2073
|
+
const fields = [...(op.query ?? []), ...(op.body ?? [])];
|
|
2074
|
+
const options = {};
|
|
2075
|
+
for (const f of fields)
|
|
2076
|
+
options[flagOf(f)] = { type: "string", ...(f.kind === "list" || f.kind === "map" ? { multiple: true } : {}) };
|
|
2077
|
+
const { values, positionals } = parse(args, options);
|
|
2078
|
+
const input = {};
|
|
2079
|
+
pathArgs(op).forEach((name, i) => {
|
|
2080
|
+
input[name] = need(positionals, i, name);
|
|
2081
|
+
});
|
|
2082
|
+
const given = values;
|
|
2083
|
+
for (const f of fields) {
|
|
2084
|
+
const raw = given[flagOf(f)];
|
|
2085
|
+
if (raw === undefined)
|
|
2086
|
+
continue;
|
|
2087
|
+
switch (f.kind) {
|
|
2088
|
+
case "number": {
|
|
2089
|
+
const n = Number(raw);
|
|
2090
|
+
if (!Number.isInteger(n) || n < 0)
|
|
2091
|
+
throw new UsageError(`--${flagOf(f)} must be a whole number (0 or more).`);
|
|
2092
|
+
input[f.name] = n;
|
|
2093
|
+
break;
|
|
2094
|
+
}
|
|
2095
|
+
case "boolean":
|
|
2096
|
+
if (raw !== "true" && raw !== "false")
|
|
2097
|
+
throw new UsageError(`--${flagOf(f)} takes true or false.`);
|
|
2098
|
+
input[f.name] = raw === "true";
|
|
2099
|
+
break;
|
|
2100
|
+
case "list":
|
|
2101
|
+
input[f.name] = raw;
|
|
2102
|
+
break;
|
|
2103
|
+
case "map":
|
|
2104
|
+
input[f.name] = Object.fromEntries(raw.map((pair) => {
|
|
2105
|
+
const at = pair.indexOf("=");
|
|
2106
|
+
if (at < 1)
|
|
2107
|
+
throw new UsageError(`--${flagOf(f)} takes <key>=<value>.`);
|
|
2108
|
+
return [pair.slice(0, at), pair.slice(at + 1)];
|
|
2109
|
+
}));
|
|
2110
|
+
break;
|
|
2111
|
+
default:
|
|
2112
|
+
if (f.values && !f.values.includes(raw))
|
|
2113
|
+
throw new UsageError(`--${flagOf(f)} must be one of ${f.values.join(", ")}.`);
|
|
2114
|
+
input[f.name] = raw;
|
|
2115
|
+
}
|
|
2116
|
+
if (f.required && f.kind === "string" && raw === "")
|
|
2117
|
+
throw new UsageError(`--${flagOf(f)} cannot be empty.`);
|
|
2118
|
+
}
|
|
2119
|
+
for (const f of fields) {
|
|
2120
|
+
if (f.required && input[f.name] === undefined)
|
|
2121
|
+
throw new UsageError(`Pass --${flagOf(f)} — ${f.help}.`);
|
|
2122
|
+
}
|
|
2123
|
+
const answer = await runDataOp(await clientFor(values, deps), op, input);
|
|
2124
|
+
printJson(deps, answer);
|
|
2125
|
+
return 0;
|
|
2126
|
+
};
|
|
2127
|
+
}
|
|
1955
2128
|
async function callsList(args, deps) {
|
|
1956
2129
|
const { values } = parse(args, {
|
|
1957
2130
|
agent: { type: "string" },
|
|
@@ -1959,6 +2132,7 @@ async function callsList(args, deps) {
|
|
|
1959
2132
|
from: { type: "string" },
|
|
1960
2133
|
to: { type: "string" },
|
|
1961
2134
|
search: { type: "string" },
|
|
2135
|
+
content: { type: "string" },
|
|
1962
2136
|
limit: { type: "string" },
|
|
1963
2137
|
offset: { type: "string" },
|
|
1964
2138
|
});
|
|
@@ -1968,6 +2142,7 @@ async function callsList(args, deps) {
|
|
|
1968
2142
|
from: values.from,
|
|
1969
2143
|
to: values.to,
|
|
1970
2144
|
q: values.search,
|
|
2145
|
+
content: values.content,
|
|
1971
2146
|
limit: values.limit === undefined ? undefined : positiveNumber(values.limit, "limit", 20),
|
|
1972
2147
|
offset: wholeNumber(values.offset, "offset"),
|
|
1973
2148
|
};
|
package/dist/mcp.js
CHANGED
|
@@ -3,9 +3,10 @@ import { readFile, writeFile } from "node:fs/promises";
|
|
|
3
3
|
import { basename } from "node:path";
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
import { ApiError, isTextFile, specText } from "./client.js";
|
|
6
|
+
import { DATA_OPS, mcpShape, runDataOp } from "./data-ops.js";
|
|
6
7
|
import { describeError, UsageError } from "./errors.js";
|
|
7
8
|
export const MAX_TEST_RUN_WAIT_SECONDS = 120;
|
|
8
|
-
const TERMINAL = new Set(["passed", "failed", "could_not_run", "timeout", "cancelled"]);
|
|
9
|
+
const TERMINAL = new Set(["passed", "failed", "could_not_run", "timeout", "cancelled", "completed"]);
|
|
9
10
|
function json(value) {
|
|
10
11
|
return { content: [{ type: "text", text: JSON.stringify(value, null, 2) }] };
|
|
11
12
|
}
|
|
@@ -196,8 +197,8 @@ export function createKumionMcpServer(client, options) {
|
|
|
196
197
|
"assistant does. `ops` is a batch, run in order, at most 20: each element is `{ op, …that operation's " +
|
|
197
198
|
"arguments }`, with `op` one of set_node_field (nodeKey, field, value), set_edge_words (fromKey, toKey, " +
|
|
198
199
|
"condition?, transitionSpeech?), add_step (type `agent`|`transfer`, name, between?, next_condition?, prompt?, " +
|
|
199
|
-
"items?, staff?, before_speech?, key?), remove_step (node), connect_steps (from, to, condition, speech
|
|
200
|
-
"
|
|
200
|
+
"items?, staff?, before_speech?, key?), remove_step (node), connect_steps (from, to, condition, speech?), " +
|
|
201
|
+
"reconnect (from, to, new_to, via_tool?), disconnect (from, to, via_tool?). The batch is atomic: " +
|
|
201
202
|
"one refused operation refuses all of them, and nothing is stored. `add_step.key` (optional, lowercase " +
|
|
202
203
|
"letters/digits/_) names the new step so a later operation of the same batch can point at it; without one the " +
|
|
203
204
|
"server picks the key and returns it in `added`. A 用件 flow (`editLayer` = `flow`) is refused: use " +
|
|
@@ -322,7 +323,8 @@ export function createKumionMcpServer(client, options) {
|
|
|
322
323
|
server.registerTool("start_test_run", {
|
|
323
324
|
description: "Run the agent's regression tests against its draft (publishes nothing). Returns at once with the run " +
|
|
324
325
|
`unless waitSeconds is set (at most ${MAX_TEST_RUN_WAIT_SECONDS}); follow a running run with ` +
|
|
325
|
-
"get_test_run.
|
|
326
|
+
"get_test_run. With turns, plays those caller lines in order instead of the suite's (nothing is graded; " +
|
|
327
|
+
"the result is the conversation, path, tool calls and trace). Needs tests:run.",
|
|
326
328
|
inputSchema: {
|
|
327
329
|
agentId,
|
|
328
330
|
waitSeconds: z
|
|
@@ -332,9 +334,14 @@ export function createKumionMcpServer(client, options) {
|
|
|
332
334
|
.max(MAX_TEST_RUN_WAIT_SECONDS)
|
|
333
335
|
.optional()
|
|
334
336
|
.describe("Wait up to this many seconds for the run to finish before returning."),
|
|
337
|
+
turns: z
|
|
338
|
+
.array(z.object({ caller: z.string().min(1) }))
|
|
339
|
+
.optional()
|
|
340
|
+
.describe("The caller's own lines, played in order instead of the suite: [{ caller }]. At most 30 lines, 500 characters each, 6000 in all. " +
|
|
341
|
+
"The lines may hold what a real caller said; the run keeps them like any test run."),
|
|
335
342
|
},
|
|
336
343
|
}, (args) => attempt(async () => {
|
|
337
|
-
let run = await client.startTestRun(args.agentId);
|
|
344
|
+
let run = await client.startTestRun(args.agentId, args.turns);
|
|
338
345
|
const deadline = (args.waitSeconds ?? 0) * 1000;
|
|
339
346
|
let waited = 0;
|
|
340
347
|
while (!TERMINAL.has(run.status) && waited < deadline) {
|
|
@@ -408,6 +415,7 @@ export function createKumionMcpServer(client, options) {
|
|
|
408
415
|
from: z.string().optional().describe("Started at or after this instant (ISO 8601)."),
|
|
409
416
|
to: z.string().optional().describe("Started before this instant (ISO 8601)."),
|
|
410
417
|
q: z.string().optional().describe("Caller number, or the start of a call id."),
|
|
418
|
+
content: z.string().optional().describe("Words said on the call (transcript). Needs from and to; the period is capped; a timeout is a 408."),
|
|
411
419
|
limit: z.number().int().min(1).max(100).optional(),
|
|
412
420
|
offset: z.number().int().min(0).optional(),
|
|
413
421
|
},
|
|
@@ -992,5 +1000,12 @@ export function createKumionMcpServer(client, options) {
|
|
|
992
1000
|
},
|
|
993
1001
|
annotations: { destructiveHint: true, idempotentHint: true },
|
|
994
1002
|
}, (args) => attempt(() => client.replaceDocument(args.documentId, { sourceDocumentId: args.sourceDocumentId, sourceRevision: args.sourceRevision }, args.revision, { dryRun: args.dryRun === true })));
|
|
1003
|
+
for (const op of DATA_OPS) {
|
|
1004
|
+
server.registerTool(op.mcp, {
|
|
1005
|
+
description: op.description,
|
|
1006
|
+
inputSchema: mcpShape(op),
|
|
1007
|
+
annotations: op.method === "GET" ? { readOnlyHint: true } : op.method === "DELETE" ? { destructiveHint: true, idempotentHint: true } : { destructiveHint: op.scope === "agents:live" },
|
|
1008
|
+
}, (args) => attempt(() => runDataOp(client, op, args)));
|
|
1009
|
+
}
|
|
995
1010
|
return server;
|
|
996
1011
|
}
|
package/package.json
CHANGED
package/skills/kumion/SKILL.md
CHANGED
|
@@ -83,7 +83,11 @@ A partner with several customers has one profile per customer tenant
|
|
|
83
83
|
(only when the user gave the name and number), then use the key it returns.
|
|
84
84
|
4. **Test** — `start_test_run` (then `get_test_run` until it leaves `running`) /
|
|
85
85
|
`kumion test-runs start <agentId>` (waits; exit 0 only on pass). Fix failures in
|
|
86
|
-
the draft and test again.
|
|
86
|
+
the draft and test again. To re-run the words of a real call that went wrong, pass
|
|
87
|
+
them with `turns` / `--turns <file|->` (at most 30 lines, 500 characters each,
|
|
88
|
+
6,000 in all): they are played in order, nothing is graded, and the run ends
|
|
89
|
+
`completed` with the conversation, path, tool calls and trace. The lines may hold
|
|
90
|
+
what a real caller said; do not paste them anywhere else.
|
|
87
91
|
5. **Publish** — only when the user asked for it. `publish_agent` /
|
|
88
92
|
`kumion agents publish <agentId>`. It runs the same pre-publish check as the Portal
|
|
89
93
|
and can take a few minutes. If the check fails, nothing goes live and the failing
|
|
@@ -266,9 +270,10 @@ A key a node does not store follows the agent's setting (会話の運用) or the
|
|
|
266
270
|
| `wait_cover` | start, agent | `tune` | `{ enabled?, on_threshold?, threshold_ms?, on_query_start?, query_grace_ms? }` | Node-level hold phrase. By default it plays only when a lookup tool is still running after `query_grace_ms` (100 to 10000, default 1000); `on_query_start: false` turns that off. `on_threshold: true` also plays it after `threshold_ms` (2000 to 15000, default 2000) of silence on an ordinary turn (default off). `enabled: false` turns it off for this node. The phrase text is set per agent. |
|
|
267
271
|
| `trigger_path` | trigger | `internal` | `string` | Generated. Shown read-only as the trigger URL. |
|
|
268
272
|
| `opening_speech` | start | `required` | `string` | The opening line. Supports {{variables}}. |
|
|
269
|
-
| `items` | start, agent | `required` | `{key,label?,example?,source?,value_type?,options?,must_ask?,min_digits?,max_digits?,tool
|
|
273
|
+
| `items` | start, agent | `required` | `{key,label?,example?,source?,value_type?,options?,must_ask?,min_digits?,max_digits?,tool?}[]` | What this step collects, one object per item, in the order it asks. `key`: slot key. `label`: display name. `example`: test-call example. `source`: where the value comes from (caller, derived, system, tool). `value_type`: kind (text, select, boolean, ...). `options`: choices of a select item. `must_ask`: ask the caller to confirm on the spot even if already known (advanced). `min_digits` / `max_digits`: for a `code` item, the fewest / most digits the value may hold, counted by the platform (the same number twice = exact length). `tool`: `{tool_key,result_field}` for a tool-sourced item. |
|
|
270
274
|
| `allow_interruptions` | start, agent | `tune` | `boolean` | Absent means the caller may interrupt. Only an explicit false is stored. |
|
|
271
275
|
| `route_judge` | start | `tune` | `boolean` | Absent means off. Only an explicit true is stored. On: while the call stays on this start step, each caller turn is first read by the call model's own probability readout (at most 400 ms, before the AI answers); when it is sure which of the step's three connections fits, the call moves on without a model turn. Offered only for a call model whose endpoint has a calibrated readout; the step needs exactly three AI connections without items and no fixed connections (graph diagnostics `route_judge_not_applicable`). |
|
|
276
|
+
| `ai_disclosure_stated` | start | `tune` | `boolean` | Absent means not declared. Only an explicit true is stored. The author's own statement that the opening tells the caller they are speaking with an AI; the platform does not read the opening for it. Not declared: graph diagnostics `opening_no_ai_disclosure` (a warning, never blocks). |
|
|
272
277
|
| `wait_for_first_word` | start | `tune` | `boolean` | Absent means off. Only an explicit true is stored. On: an outbound call waits for the customer to speak first and says the opening line when they finish or `first_word_wait_seconds` runs out. An inbound call never reads it (graph diagnostics `first_word_wait_outbound_only`). |
|
|
273
278
|
| `first_word_wait_seconds` | start | `tune` | `number` | Seconds `wait_for_first_word` waits (1 to 10, default 3). Absent means the default. Read only when `wait_for_first_word` is true. |
|
|
274
279
|
| `respond_on_enter` | agent | `tune` | `boolean` | Absent means the node answers on arrival. Only an explicit false (wait for the caller) is stored. |
|
|
@@ -282,7 +287,7 @@ A key a node does not store follows the agent's setting (会話の運用) or the
|
|
|
282
287
|
| `opening_audio_filename` | start | `internal` | `string` | Display name of the uploaded opening audio. |
|
|
283
288
|
| `precall_fetch_url` | start | `advanced` | `string` | URL fetched before the call starts; the response becomes call variables. |
|
|
284
289
|
| `precall_fetch_method` | start | `advanced` | `string` | HTTP method of the pre-call fetch. |
|
|
285
|
-
| `precall_fetch_headers` | start | `advanced` | `{ key,
|
|
290
|
+
| `precall_fetch_headers` | start | `advanced` | `{ key, secret }[]` | Headers of the pre-call fetch. A value is never returned: a row you read has `secret` (a reference); to set a value send `{ key, value }` once, and the reply has the reference. Send read rows back unchanged. |
|
|
286
291
|
| `no_response` | start, agent | `advanced` | `{ timeout_s, reprompt_speech?, max_reprompts, then }` | Node-level no-response timer. { timeout_s: 0 } turns the agent default off here. |
|
|
287
292
|
| `kb_fallback` | start, agent | `advanced` | `{ noResult?, unavailable? }` | Wording when a knowledge search finds nothing or is unavailable. Overrides the tenant operations setting. |
|
|
288
293
|
| `end_speech` | end | `required` | `string` | Default goodbye line. A connection into this node can override it. |
|
|
@@ -293,7 +298,7 @@ A key a node does not store follows the agent's setting (会話の運用) or the
|
|
|
293
298
|
| `http_method` | webhook | `required` | `string` | GET, POST, PUT, PATCH or DELETE. |
|
|
294
299
|
| `endpoint_url` | webhook | `required` | `string` | Destination URL. |
|
|
295
300
|
| `payload_template` | webhook | `required` | `string` | Request body template with {{variables}}. |
|
|
296
|
-
| `custom_headers` | webhook | `advanced` | `{ key,
|
|
301
|
+
| `custom_headers` | webhook | `advanced` | `{ key, secret }[]` | Extra request headers. A value is never returned: a row you read has `secret` (a reference); to set a value send `{ key, value }` once, and the reply has the reference. Send read rows back unchanged. |
|
|
297
302
|
| `qa_system_prompt` | qa | `required` | `string` | Evaluation prompt. |
|
|
298
303
|
| `qa_sample_rate` | qa | `required` | `number` | Percentage of calls analysed, 1 to 100. |
|
|
299
304
|
| `qa_min_call_duration` | qa | `required` | `number` | Shortest call (seconds) that is analysed. |
|
|
@@ -334,6 +339,16 @@ field in the item's `tool` as `{ "tool_key": "…", "result_field": "…" }`;
|
|
|
334
339
|
only that tool succeeding at this step records it. Keys in `optional_slots` are
|
|
335
340
|
recorded only when the caller says them first; they are not required at that step.
|
|
336
341
|
|
|
342
|
+
## Customers, marks and records
|
|
343
|
+
|
|
344
|
+
These cover what the Portal's 顧客, 通話 and 分析 screens already do. Each needs its own scope; keys issued before the scope existed do not have it.
|
|
345
|
+
|
|
346
|
+
- `list_contacts`, `get_contact`, `list_contact_calls`, `list_contact_fields` (`contacts:read`); `create_contact`, `update_contact` (`contacts:write`). Customers only; staff are `list_staff`.
|
|
347
|
+
- `link_call_contact`, `set_call_mark`, `clear_call_mark`, `create_call_mark_type`, `create_callback_list` (`calls:write`); `list_call_marks` (`calls:read`). A callback list is a draft: nothing is dialled.
|
|
348
|
+
- `list_captures`, `get_capture_status_log` (`captures:read`); `update_capture` (`captures:write`): status and note only, the assignee is set on the screen.
|
|
349
|
+
- `get_document_history`, `get_document_version_diff` (`agents:read`); `rollback_document` (`agents:live`): LIVE, the next call reads the restored version with no publish, so confirm with the person first.
|
|
350
|
+
- `get_analytics` (`analytics:read`).
|
|
351
|
+
|
|
337
352
|
## When it refuses
|
|
338
353
|
|
|
339
354
|
- **401** — key wrong, revoked, expired, or for another tenant. A personal key from
|
|
@@ -341,7 +356,7 @@ recorded only when the caller says them first; they are not required at that ste
|
|
|
341
356
|
tenant administrator (`kumion auth status` shows its expiry). The user re-runs
|
|
342
357
|
`kumion auth login`.
|
|
343
358
|
- **403 naming a scope** — the key lacks it (`agents:read`, `agents:write`,
|
|
344
|
-
`agents:publish`, `agents:live`, `tests:run`, `calls:create`, `calls:read`). The user issues a key with that scope
|
|
359
|
+
`agents:publish`, `agents:live`, `tests:run`, `calls:create`, `calls:read`, `calls:write`, `contacts:read`, `contacts:write`, `captures:read`, `captures:write`, `analytics:read`). The user issues a key with that scope
|
|
345
360
|
in the Portal (設定 → 開発者) and logs in again. Do not work around it.
|
|
346
361
|
- **403 without a scope name** — the tenant's plan cannot publish, or `create_call` hit
|
|
347
362
|
the call-minute limit. Tell the user; a new key does not help.
|