@kumion/cli 0.6.8 → 0.6.10

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 CHANGED
@@ -50,9 +50,9 @@ Your Portal session stays in the browser; the CLI only ever holds the key.
50
50
  `kumion auth status` shows the key's kind and expiry. `--scopes agents:read,calls:read`
51
51
  asks for less than every permission the CLI can use.
52
52
 
53
- ### With an API key from 設定 → 開発者
53
+ ### With an API key from 設定 → 開発者API
54
54
 
55
- For a key someone issued on the Portal's **設定 → 開発者** page (a *service* key —
55
+ For a key someone issued on the Portal's **設定 → 開発者API** page (a *service* key —
56
56
  the tenant's, not a person's; choose the scopes you need, see below). You also need
57
57
  the tenant ID: the UUID in the Portal URL (`/tenants/<tenant-id>/…`) and in the curl
58
58
  examples on the same page.
@@ -120,6 +120,13 @@ would use.
120
120
  | `kumion flow get <agentId>` | `agents:read` |
121
121
  | `kumion flow update <agentId> --revision <rev> --patch-file <path> [--dry-run]` | `agents:write` |
122
122
  | `kumion flow edit-steps <agentId> --revision <rev> --ops-file <path> [--dry-run]` | `agents:write` |
123
+ | `kumion chat-agents list` | `agents:read` (the チャットエージェント — text agents; the plan must include them) |
124
+ | `kumion chat-agents get <chatAgentId>` | `agents:read` |
125
+ | `kumion chat-agents draft get <chatAgentId>` | `agents:read` (`--json` prints the whole graph and the `revision` a write needs) |
126
+ | `kumion chat-agents draft update <chatAgentId> --revision <rev> --graph-file <path> [--name <name>] [--dry-run]` | `agents:write` (a draft write: visitors see it after the next publish; a stale revision is a 412) |
127
+ | `kumion chat-agents diagnostics <chatAgentId>` | `agents:read` |
128
+ | `kumion chat-agents publish <chatAgentId> [--revision <rev>]` | `agents:publish` (refused with the findings while an error is left) |
129
+ | `kumion chat-agents versions <chatAgentId>` | `agents:read` |
123
130
  | `kumion templates list` | `agents:read` |
124
131
  | `kumion staff list` | `agents:read` |
125
132
  | `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) |
@@ -136,8 +143,8 @@ would use.
136
143
  | `kumion call-marks clear <callId> <typeId>` | `calls:write` |
137
144
  | `kumion call-marks create-type --name <text>` | `calls:write` |
138
145
  | `kumion callback-lists create --call <value> ... [--name <text>]` | `calls:write` |
139
- | `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` |
140
- | `kumion captures update <captureId> [--status open\|done\|dismissed] [--note <text>]` | `captures:write` |
146
+ | `kumion captures list [--type <text>] [--spec <text>] [--agent <text>] [--field <text>] [--value <text>] [--q <text>] [--status open\|in_progress\|done\|dismissed] [--from <text>] [--to <text>] [--limit <n>] [--offset <n>]` | `captures:read` |
147
+ | `kumion captures update <captureId> [--status open\|in_progress\|done\|dismissed] [--note <text>]` | `captures:write` |
141
148
  | `kumion captures status-log <captureId>` | `captures:read` |
142
149
  | `kumion documents history <documentId>` | `agents:read` |
143
150
  | `kumion documents version-diff <documentId> --from <n> --to <n>` | `agents:read` |
@@ -163,6 +170,7 @@ would use.
163
170
  | `kumion documents upload (--text-file <path> \| --file <path> [--file <path> ...]) --title <title> --idempotency-key <key> [--template <templateId>] [--dry-run]` | `agents:write` (one counted model extraction; see [From a template to public](#from-a-template-to-public)) |
164
171
  | `kumion documents jobs get <jobId>` | `agents:read` (exits 1 when the job failed or timed out) |
165
172
  | `kumion documents get <documentId>` | `agents:read` |
173
+ | `kumion documents delete <documentId>` | `agents:live` (cannot be undone; refused with the list of what uses it, and an archived agent does not count) |
166
174
  | `kumion documents replace <documentId> --source <sourceDocumentId> --source-revision <rev> --revision <rev> [--dry-run]` | `agents:live` (live: no publish) |
167
175
  | `kumion test-runs start <agentId> [--turns <file\|->] [--no-wait] [--interval <sec>] [--timeout <sec>]` | `tests:run` |
168
176
  | `kumion test-runs get <agentId> <runId>` | `tests:run` |
@@ -190,14 +198,14 @@ dial starts; after that it answers 404.
190
198
  them. When the workspace has personal-information masking on, `calls list`, `calls get`,
191
199
  `calls transcript` and the captured items show masked values; only a key that also holds
192
200
  `calls:read_unmasked` sees the stored values (each such read is audited). `kumion auth login`
193
- does not ask for `calls:read_unmasked`; issue a key with it on the Portal's 設定 → 開発者 page. `calls list` returns one page (20 by default, at most 100) and prints the
201
+ does not ask for `calls:read_unmasked`; issue a key with it on the Portal's 設定 → 開発者API page. `calls list` returns one page (20 by default, at most 100) and prints the
194
202
  `--offset` of the next one. Every call in `calls list` and `calls get` carries what it came to: `outcome`
195
203
  (`ai_resolved`, `ai_unresolved_hangup`, `invalid_call`, `handoff`, `system_ended`, or `na` when not judged),
196
204
  `endedAtNode` (the node it ended on), `durationSec`, `transferred`, and `capturedItems` (the names of the
197
205
  items it recorded, never their values). `calls get` also returns `direction` (the raw value stored with
198
206
  the call: `inbound`, `outbound`, `on_net`) and `portalDirection`, which is the 着信/発信 the Portal's call history
199
207
  shows: `inbound`, `outbound`, or `null` when the call is neither (a trigger run, say). An `on_net` web call is
200
- `inbound` there. Count 着信/発信 from `portalDirection`. A transcript's `turns` hold only what the caller and the agent said. A call handed to a person adds `handoffSegment` (`status` `transcribed` / `failed` / `not_sent`, `reason`, `fromSec` / `toSec`, and `turns` of `speaker`, `text`, `offsetSec`, in seconds into the call recording); `not_sent` means the tenant's contract forbids sending the recording out, so it has no text.
208
+ `inbound` there. Count 着信/発信 from `portalDirection`. A transcript's `turns` hold only what the caller and the agent said. A call handed to a person adds `handoffSegment` (`status` `transcribed` / `failed` / `not_sent`, `reason`, `fromSec` / `toSec`, and `turns` of `speaker`, `text`, `offsetSec`, in seconds into the call recording; when each person was transcribed apart a turn also has `role`: `ai` for the platform, `caller` for the other side of the call, `callee` for the person transferred to); `not_sent` means the tenant's contract forbids sending the recording out, so it has no text.
201
209
  Add `--json` to any command for the API's JSON instead of a summary.
202
210
 
203
211
  `hours` is the shop clock the call answers 「何時までですか」 from, and it is one calendar for the
@@ -347,7 +355,7 @@ Three settings are not part of the draft, so a write to them needs no publish:
347
355
  - `agents availability`: 受付時間 (`--operating-hours-file`, JSON `{ "mode": "always" | "staffed" | "custom", "hours": { "mon": [{ "start": "09:00", "end": "18:00" }] } }`) and 時間外の対応 (`--off-hours-file`, JSON `{ "kind": "answer" | "announce_end" | "route_to", ... }`). A file holding `null` clears the setting. `agents get --json` shows both under `live`.
348
356
  - `facts edit` and `facts confirm`: the facts taken from the agent's 資料 (prices, menu). `facts list` shows each fact's `revision`; `facts edit` is refused when that fact changed since.
349
357
 
350
- They need the scope **`agents:live`**, which is not part of `agents:write` (that scope only writes the draft and never publishes) and is not added to keys issued before it existed: issue a new key with it on 設定 → 開発者. `agents opening-name` is an ordinary draft write (`agents:write`): it reaches callers with the next publish.
358
+ They need the scope **`agents:live`**, which is not part of `agents:write` (that scope only writes the draft and never publishes) and is not added to keys issued before it existed: issue a new key with it on 設定 → 開発者API. `agents opening-name` is an ordinary draft write (`agents:write`): it reaches callers with the next publish.
351
359
 
352
360
  `staff update` is the third: a 用件's 転送 looks its スタッフ up by key when the transfer happens and reads 転送先 and whether the row is enabled then, so `staff update --enabled false` takes someone off the 転送 candidates from the next call on, with no publish. `--revision` is the row's own, from `staff list`; a write based on a stale one is refused with a conflict and nothing is written. The transfer key is generated when the row is created and cannot be changed — a published flow stores it.
353
361
 
@@ -393,7 +401,7 @@ A key a node does not store follows the agent's setting (会話の運用) or the
393
401
  | `opening_speech` | start | `required` | `string` | The opening line. Supports {{variables}}. |
394
402
  | `items` | start, agent | `required` | `{key,label?,example?,source?,value_type?,options?,must_ask?,min_digits?,max_digits?,require_day?,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). `require_day`: for a `birthdate` item, tell the model the value needs a year, a month and a day (off = year and month). `tool`: `{tool_key,result_field}` for a tool-sourced item. |
395
403
  | `allow_interruptions` | start, agent | `tune` | `boolean` | Absent means the caller may interrupt. Only an explicit false is stored. |
396
- | `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`). |
404
+ | `route_judge` | start | `tune` | `boolean` | Absent means on wherever the step can be judged, and off without any diagnostic where it cannot; `false` turns it off. 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 800 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. A step can be judged when the call is Japanese, the call model's endpoint has a calibrated readout, and the step has no items, exactly three AI connections without items and no fixed connections. An explicit `true` on a step that cannot be judged is reported (graph diagnostics `route_judge_not_applicable`). |
397
405
  | `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). |
398
406
  | `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`). |
399
407
  | `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. |
@@ -414,7 +422,7 @@ A key a node does not store follows the agent's setting (会話の運用) or the
414
422
  | `kb_fallback` | start, agent | `advanced` | `{ noResult?, unavailable? }` | Wording when a knowledge search finds nothing or is unavailable. Overrides the tenant operations setting. |
415
423
  | `end_speech` | end | `required` | `string` | Default goodbye line. A connection into this node can override it. |
416
424
  | `caller_leaves` | end | `required` | `boolean` | Marks the end a caller who walks away is sent to from every agent step, connected or not. Required on exactly one end when the flow has two or more end nodes. |
417
- | `ivr` | ivr | `required` | `object` | Announcement, digit table and wait time. input and max_retries are fixed; other values are rejected. |
425
+ | `ivr` | ivr | `required` | `object` | Announcement, digit table, wait time, and the optional speech exit. input and max_retries are fixed; other values are rejected. `voice_enabled: true` also lets a spoken answer leave the menu once it reaches `voice_min_chars` letters and digits (2–30, default 5); the edge it takes has the condition `ivr.<key>.status == "voice"`, and without that edge a spoken answer follows the no-input / failure edge. Omit both keys for the digit-only menu. |
418
426
  | `transfer` | transfer | `required` | `object` | Transfer target and the line spoken before transferring. |
419
427
  | `notify` | notify | `required` | `object` | Recipients, subject and body templates. |
420
428
  | `http_method` | webhook | `required` | `string` | GET, POST, PUT, PATCH or DELETE. |
@@ -443,6 +451,12 @@ and a row in a node's 「動きの調整」), and an IVR node's `ivr.input` and
443
451
  (`{ "mode": "single", "max_digits": 1, "finish_key": null }` and `0`): any other value
444
452
  makes the patch fail.
445
453
 
454
+ An IVR node can also take a spoken answer (「声でも次へ進む」): set `ivr.voice_enabled: true`
455
+ (and optionally `ivr.voice_min_chars`, an integer 2–30, default 5 — the letters and digits an
456
+ utterance needs before it leaves the menu), then add an edge with the condition
457
+ `ivr.<key>.status == "voice"`. Without that edge a spoken answer follows the no-input / failure
458
+ edge. Leave both keys out for the digit-only menu.
459
+
446
460
  ### Testing and publishing
447
461
 
448
462
  ```sh
@@ -666,6 +680,29 @@ Two things are closed here on purpose:
666
680
  - **Booking records** (making, moving or cancelling a customer's booking) and notifications are not
667
681
  Partner API operations. `booking slots` reads openings; nothing here writes a booking.
668
682
 
683
+ ## Chat agents (チャットエージェント)
684
+
685
+ A chat agent is the text counterpart of a voice agent: its own list, its own ids, its own draft canvas and its own
686
+ versions. Use `chat-agents list` for the ids; the voice `agents` commands do not see them. Every command needs the
687
+ tenant's plan to include chat agents (a plan without them answers 403 whatever the key's scopes).
688
+
689
+ ```bash
690
+ kumion chat-agents list
691
+ kumion chat-agents draft get <chatAgentId> --json > draft.json # note "revision"; "graph" is the canvas
692
+ # edit draft.json (the file may stay whole: `--graph-file` takes the output of `draft get --json`)
693
+ kumion chat-agents draft update <chatAgentId> --revision <rev> --graph-file draft.json --dry-run
694
+ kumion chat-agents draft update <chatAgentId> --revision <rev> --graph-file draft.json
695
+ kumion chat-agents diagnostics <chatAgentId> # errors block publishing; warnings do not
696
+ kumion chat-agents publish <chatAgentId> --revision <new rev>
697
+ kumion chat-agents versions <chatAgentId>
698
+ ```
699
+
700
+ `draft update` replaces the whole draft, through the same structural check as the canvas's save (a graph that fails it
701
+ is a 400 and nothing is written). `--dry-run` runs every check and prints the findings the draft would have, without
702
+ saving. A `--revision` that is no longer the draft's is refused with a 412 and nothing is written: read the draft again
703
+ and re-apply the change. `publish` is refused (422) while any finding is an error, and `--revision` makes it refuse
704
+ a draft that moved since you read it.
705
+
669
706
  ## Use it from an AI coding assistant (MCP)
670
707
 
671
708
  `kumion mcp` serves the same operations as MCP tools over stdio, for Claude Code,
package/dist/client.js CHANGED
@@ -268,6 +268,44 @@ export class KumionClient {
268
268
  });
269
269
  return response;
270
270
  }
271
+ chatAgentPath(chatAgentId, rest = "") {
272
+ return this.tenantPath(`/chat-agents/${encodeURIComponent(chatAgentId)}${rest}`);
273
+ }
274
+ async listChatAgents() {
275
+ const { body } = await this.request("GET", this.tenantPath("/chat-agents"), "agents:read");
276
+ return body.agents;
277
+ }
278
+ async getChatAgent(chatAgentId) {
279
+ const { body } = await this.request("GET", this.chatAgentPath(chatAgentId), "agents:read");
280
+ return body.agent;
281
+ }
282
+ async getChatAgentDraft(chatAgentId) {
283
+ const { body } = await this.request("GET", this.chatAgentPath(chatAgentId, "/draft"), "agents:read");
284
+ return body;
285
+ }
286
+ async updateChatAgentDraft(chatAgentId, input, revision, options = {}) {
287
+ const query = options.dryRun ? "?dryRun=1" : "";
288
+ const { body } = await this.request("PATCH", this.chatAgentPath(chatAgentId, `/draft${query}`), "agents:write", {
289
+ body: input,
290
+ ifMatch: revision,
291
+ });
292
+ return body;
293
+ }
294
+ async getChatAgentDiagnostics(chatAgentId) {
295
+ const { body } = await this.request("GET", this.chatAgentPath(chatAgentId, "/diagnostics"), "agents:read");
296
+ return body;
297
+ }
298
+ async publishChatAgent(chatAgentId, revision) {
299
+ const { body } = await this.request("POST", this.chatAgentPath(chatAgentId, "/publish"), "agents:publish", {
300
+ body: {},
301
+ ifMatch: revision,
302
+ });
303
+ return body;
304
+ }
305
+ async listChatAgentVersions(chatAgentId) {
306
+ const { body } = await this.request("GET", this.chatAgentPath(chatAgentId, "/versions"), "agents:read");
307
+ return body.versions;
308
+ }
271
309
  async startTestRun(agentId, turns) {
272
310
  const { body } = await this.request("POST", this.agentPath(agentId, "/test-runs"), "tests:run", {
273
311
  body: turns ? { turns } : {},
@@ -450,6 +488,10 @@ export class KumionClient {
450
488
  const { body } = await this.request("GET", this.tenantPath(`/documents/${encodeURIComponent(documentId)}`), "agents:read");
451
489
  return body;
452
490
  }
491
+ async deleteDocument(documentId) {
492
+ const { body } = await this.request("DELETE", this.tenantPath(`/documents/${encodeURIComponent(documentId)}`), "agents:live");
493
+ return body;
494
+ }
453
495
  async replaceDocument(documentId, input, revision, options = {}) {
454
496
  const query = options.dryRun ? "?dryRun=1" : "";
455
497
  const { body } = await this.request("POST", this.tenantPath(`/documents/${encodeURIComponent(documentId)}/replace${query}`), "agents:live", { body: input, ifMatch: revision });
package/dist/data-ops.js CHANGED
@@ -3,7 +3,7 @@ const page = [
3
3
  { name: "limit", kind: "number", help: "page size (default 20, at most 100)" },
4
4
  { name: "offset", kind: "number", help: "rows to skip" },
5
5
  ];
6
- const STATUS = ["open", "done", "dismissed"];
6
+ const STATUS = ["open", "in_progress", "done", "dismissed"];
7
7
  export const DATA_OPS = [
8
8
  {
9
9
  cli: "contacts list", mcp: "list_contacts", method: "GET", path: "/contacts", scope: "contacts:read",
@@ -98,7 +98,7 @@ export const DATA_OPS = [
98
98
  { name: "field", kind: "string", help: "field key (with --value)" },
99
99
  { name: "value", kind: "string", help: "that field's value (with --field)" },
100
100
  { name: "q", kind: "string", help: "search text" },
101
- { name: "status", kind: "string", values: STATUS, help: "open|done|dismissed" },
101
+ { name: "status", kind: "string", values: STATUS, help: "open|in_progress|done|dismissed" },
102
102
  { name: "from", kind: "string", help: "at or after (ISO 8601)" },
103
103
  { name: "to", kind: "string", help: "at or before (ISO 8601)" },
104
104
  ...page,
@@ -108,7 +108,7 @@ export const DATA_OPS = [
108
108
  {
109
109
  cli: "captures update", mcp: "update_capture", method: "PATCH", path: "/captures/{captureId}", scope: "captures:write",
110
110
  body: [
111
- { name: "status", kind: "string", values: STATUS, help: "open|done|dismissed" },
111
+ { name: "status", kind: "string", values: STATUS, help: "open|in_progress|done|dismissed" },
112
112
  { name: "handledNote", kind: "string", flag: "note", help: "handling note (up to 1000 characters; an empty string clears it)" },
113
113
  ],
114
114
  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.",
package/dist/errors.js CHANGED
@@ -17,7 +17,7 @@ export function describeApiError(err) {
17
17
  const detail = typeof err.body.error === "string" ? err.body.error : "";
18
18
  if (detail.includes(err.scope)) {
19
19
  return (`This API key does not have the \`${err.scope}\` scope, which this command needs (403). ` +
20
- `Issue a key that includes it in the Kumion Portal (設定 → 開発者).` +
20
+ `Issue a key that includes it in the Kumion Portal (設定 → 開発者API).` +
21
21
  serverSaid(err));
22
22
  }
23
23
  if (err.code === "plan_publish_required") {
@@ -79,6 +79,14 @@ export function describeApiError(err) {
79
79
  "client. Nothing was written. Run `kumion facts list <agentId>` for its new revision and try again." +
80
80
  serverSaid(err));
81
81
  }
82
+ if (err.code === "document_in_use") {
83
+ const refs = Array.isArray(err.body.references) ? err.body.references : [];
84
+ const lines = refs.map((ref) => ref.kind === "agent"
85
+ ? ` - agent ${String(ref.agentName)} (${String(ref.agentId)}) — the whole agent`
86
+ : ` - flow ${String(ref.workflowName)} / step ${String(ref.nodeName ?? ref.nodeKey)}`);
87
+ return ("The 資料 is still in use (409 document_in_use). Nothing was deleted. Detach it from these first:" +
88
+ `${lines.length > 0 ? `\n${lines.join("\n")}` : ""}${serverSaid(err)}`);
89
+ }
82
90
  if (err.code === "test_run_in_progress") {
83
91
  return ("This agent already has a test run in progress (409). Wait for it with " +
84
92
  "`kumion test-runs list <agentId>` / `kumion test-runs get <agentId> <runId>`, then start another." +
@@ -90,6 +98,11 @@ export function describeApiError(err) {
90
98
  serverSaid(err));
91
99
  }
92
100
  return `Conflict (409).${serverSaid(err)}`;
101
+ case 412:
102
+ return ("The chat agent's draft changed since you read it (412): someone saved it in the Portal or from another " +
103
+ "client. Nothing was written. Run `kumion chat-agents draft get <id>` for the new revision, re-apply your " +
104
+ "change on top of it, and try again." +
105
+ serverSaid(err));
93
106
  case 428:
94
107
  return `The API asked for an If-Match revision the CLI did not send (428). This is a CLI bug.${serverSaid(err)}`;
95
108
  case 422: {
@@ -109,6 +122,11 @@ export function describeApiError(err) {
109
122
  `sends or whom it notifies, and the API cannot add or change them. Edit them on the Portal's canvas:${listed}` +
110
123
  serverSaid(err));
111
124
  }
125
+ if (err.code === "chat_agent_not_publishable") {
126
+ const findings = Array.isArray(err.body.diagnostics) ? err.body.diagnostics : [];
127
+ const lines = findings.filter((d) => d.severity === "error").map((d) => ` - ${String(d.code)}${d.nodeId ? ` (node ${String(d.nodeId)})` : ""}${d.edgeId ? ` (line ${String(d.edgeId)})` : ""}`);
128
+ return `Not published (422). Nothing was stored — the draft still has errors:${lines.length > 0 ? `\n${lines.join("\n")}` : ""}\nFix them with \`kumion chat-agents draft update\`; \`kumion chat-agents diagnostics <id>\` lists them again.`;
129
+ }
112
130
  if (err.code === "flow_edit_refused" && reason) {
113
131
  const which = typeof err.body.opIndex === "number" ? `Operation ${err.body.opIndex + 1} was refused` : "The change was refused";
114
132
  return `${which} (422). Nothing was written.\nServer said: ${reason}`;
package/dist/main.js CHANGED
@@ -6,7 +6,7 @@ import { ApiError, KumionClient, isTextFile, specText, } from "./client.js";
6
6
  import { DEFAULT_BASE_URL, keyPrefix, looksLikeApiKey, normalizeBaseUrl, resolveCredentials, } from "./credentials.js";
7
7
  import { DEFAULT_DEVICE_SCOPES, deviceLogin } from "./device-login.js";
8
8
  import { describeError, ReportedFailure, UsageError } from "./errors.js";
9
- export const VERSION = "0.6.8";
9
+ export const VERSION = "0.6.10";
10
10
  const HELP = `kumion — manage your Kumion voice agents over the Partner API
11
11
 
12
12
  Usage: kumion <command> [options]
@@ -17,7 +17,7 @@ Auth
17
17
  Portal and get a personal key (12 hours at most;
18
18
  tenant administrators only) in the OS keychain
19
19
  auth login --with-api-key [--profile <name>] [--tenant <id>] [--base-url <url>]
20
- Save an API key issued on 設定 → 開発者 instead
20
+ Save an API key issued on 設定 → 開発者API instead
21
21
  auth status Show which tenant and key commands will use
22
22
  auth list List saved profiles
23
23
  auth use <profile> Make a profile the default
@@ -46,7 +46,7 @@ Agents
46
46
  null to clear it. LIVE: callers get it at once, no publish
47
47
  (needs a key with agents:live)
48
48
  webcall get <agentId> Show the Webコール access limits (allowed IPs / embedding sites; empty = no limit)
49
- webcall update <agentId> [--ip <a,b,...>] [--embed <a,b,...>] [--accent <#RRGGBB>] [--title <t>] [--greeting <t>]
49
+ webcall update <agentId> [--ip <a,b,...>] [--embed <a,b,...>] [--signed-only on|off] [--accent <#RRGGBB>] [--title <t>] [--greeting <t>]
50
50
  [--quick-reply <t> (repeat, max 4)] [--launcher-label <t>] [--position right|left]
51
51
  [--entry both|voice|text] [--logo <png|jpg|webp file> | --remove-logo]
52
52
  (an empty value clears an appearance item back to the default)
@@ -85,6 +85,24 @@ Flow
85
85
  is atomic (one refused operation refuses all of them) and moves the
86
86
  revision once. --dry-run prints the change and saves nothing
87
87
 
88
+ Chat agents (チャットエージェント — the text agent, a resource of its own; the plan must include it)
89
+ chat-agents list List the chat agents: id, name, published version, whether the
90
+ draft has changes not yet published
91
+ chat-agents get <id> One chat agent: name, draft revision, published version
92
+ chat-agents draft get <id> Read the draft canvas (nodes and lines) and its revision.
93
+ --json prints the whole graph
94
+ chat-agents draft update <id> --revision <rev> --graph-file <path> [--name <name>] [--dry-run]
95
+ Replace the draft with the graph in the file (a bare graph, or the
96
+ output of \`draft get --json\`), through the checks the canvas's save
97
+ runs. Prints the findings the draft now has. A draft write: nothing
98
+ reaches visitors until publish. --dry-run runs every check and
99
+ saves nothing
100
+ chat-agents diagnostics <id> The draft's findings (errors block publishing; warnings do not)
101
+ chat-agents publish <id> [--revision <rev>]
102
+ Publish the draft as the next version. Refused while an error is
103
+ left; with --revision, also refused if the draft has moved since
104
+ chat-agents versions <id> The published versions, newest first
105
+
88
106
  Templates
89
107
  templates list List the onboarding templates and their ids
90
108
 
@@ -118,10 +136,10 @@ Customers, marks and records (need the contacts:*, calls:write, captures:* or an
118
136
  callback-lists create --call <value> ... [--name <text>]
119
137
  Make a draft callback list from calls (nothing is dialled)
120
138
  captures list [--type <text>] [--spec <text>] [--agent <text>] [--field
121
- <text>] [--value <text>] [--q <text>] [--status open|done|dismissed]
139
+ <text>] [--value <text>] [--q <text>] [--status open|in_progress|done|dismissed]
122
140
  [--from <text>] [--to <text>] [--limit <n>] [--offset <n>]
123
141
  List the recorded summaries, newest first
124
- captures update <captureId> [--status open|done|dismissed] [--note <text>]
142
+ captures update <captureId> [--status open|in_progress|done|dismissed] [--note <text>]
125
143
  Set a summary's handling status and note
126
144
  captures status-log <captureId>
127
145
  Who changed a summary's status, when
@@ -237,6 +255,9 @@ Documents (資料 — the source an agent's facts are extracted from)
237
255
  documents jobs get <jobId> Show an upload job: status, the document it produced, the error.
238
256
  Exits non-zero when the job failed or timed out
239
257
  documents get <documentId> Show a 資料: its fields, review state and revision (not the text)
258
+ documents delete <documentId> Delete a 資料. Refused with the list of what uses it while an agent or a flow
259
+ step still does; an archived agent does not count (its link is cleared).
260
+ Cannot be undone (needs agents:live)
240
261
  documents replace <documentId> --source <sourceDocumentId> --source-revision <rev> --revision <rev>
241
262
  [--dry-run]
242
263
  Give a 資料 another document's content and facts, keeping its id, so the
@@ -409,6 +430,13 @@ export const COMMANDS = {
409
430
  "flow get": flowGet,
410
431
  "flow update": flowUpdate,
411
432
  "flow edit-steps": flowEditSteps,
433
+ "chat-agents list": chatAgentsList,
434
+ "chat-agents get": chatAgentsGet,
435
+ "chat-agents draft get": chatAgentsDraftGet,
436
+ "chat-agents draft update": chatAgentsDraftUpdate,
437
+ "chat-agents diagnostics": chatAgentsDiagnostics,
438
+ "chat-agents publish": chatAgentsPublish,
439
+ "chat-agents versions": chatAgentsVersions,
412
440
  "templates list": templatesList,
413
441
  "staff list": staffList,
414
442
  "staff create": staffCreate,
@@ -435,6 +463,7 @@ export const COMMANDS = {
435
463
  "documents upload": documentsUpload,
436
464
  "documents jobs get": documentsJobsGet,
437
465
  "documents get": documentsGet,
466
+ "documents delete": documentsDelete,
438
467
  "documents replace": documentsReplace,
439
468
  "test-runs start": testRunsStart,
440
469
  "test-runs get": testRunsGet,
@@ -501,7 +530,7 @@ async function authLoginWithApiKey(values, deps) {
501
530
  const name = values.profile ?? "default";
502
531
  const tenantId = (values.tenant ?? (await deps.io.prompt("Tenant ID: "))).trim();
503
532
  if (!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(tenantId)) {
504
- throw new UsageError("The tenant ID must be a UUID — the one in the Portal URL (/tenants/<id>/) and in the curl examples on 設定 → 開発者.");
533
+ throw new UsageError("The tenant ID must be a UUID — the one in the Portal URL (/tenants/<id>/) and in the curl examples on 設定 → 開発者API.");
505
534
  }
506
535
  const apiKey = (await deps.io.prompt("API key (input hidden): ", { hidden: true })).trim();
507
536
  if (!looksLikeApiKey(apiKey))
@@ -791,6 +820,7 @@ function splitList(v) {
791
820
  function webcallLines(w, deps) {
792
821
  deps.io.out(`IP allowlist: ${w.accessIpAllowlist.length ? w.accessIpAllowlist.join(", ") : "(none — no limit)"}`);
793
822
  deps.io.out(`Embed sites: ${w.embedOriginAllowlist.length ? w.embedOriginAllowlist.join(", ") : "(none — deployment default)"}`);
823
+ deps.io.out(`Signed only: ${w.requireSignedVisitor ? "on — a start with no signed visitorToken is refused" : "off"}`);
794
824
  const shown = Object.entries(w.appearance ?? {}).filter(([, v]) => v !== undefined);
795
825
  deps.io.out(`Appearance: ${shown.length ? shown.map(([k, v]) => `${k}=${Array.isArray(v) ? v.join(" | ") : String(v)}`).join("; ") : "(defaults)"}`);
796
826
  deps.io.out(`Logo: ${w.hasLogo ? "set" : "(none)"}`);
@@ -845,6 +875,7 @@ async function webcallUpdate(args, deps) {
845
875
  const { values, positionals } = parse(args, {
846
876
  ip: { type: "string" },
847
877
  embed: { type: "string" },
878
+ "signed-only": { type: "string" },
848
879
  accent: { type: "string" },
849
880
  title: { type: "string" },
850
881
  greeting: { type: "string" },
@@ -861,6 +892,11 @@ async function webcallUpdate(args, deps) {
861
892
  patch.accessIpAllowlist = splitList(values.ip);
862
893
  if (values.embed !== undefined)
863
894
  patch.embedOriginAllowlist = splitList(values.embed);
895
+ if (values["signed-only"] !== undefined) {
896
+ if (values["signed-only"] !== "on" && values["signed-only"] !== "off")
897
+ throw new UsageError("--signed-only takes on or off.");
898
+ patch.requireSignedVisitor = values["signed-only"] === "on";
899
+ }
864
900
  const appearance = {};
865
901
  const orNull = (v) => (v === "" ? null : v);
866
902
  if (values.accent !== undefined)
@@ -891,7 +927,7 @@ async function webcallUpdate(args, deps) {
891
927
  patch.logo = { contentType, dataBase64: Buffer.from(await readFile(values.logo)).toString("base64") };
892
928
  }
893
929
  if (Object.keys(patch).length === 0) {
894
- throw new UsageError("Nothing to change. Pass --ip, --embed or an appearance flag (see `kumion help`).");
930
+ throw new UsageError("Nothing to change. Pass --ip, --embed, --signed-only or an appearance flag (see `kumion help`).");
895
931
  }
896
932
  const w = await (await clientFor(values, deps)).setWebcallAccess(agentId, patch);
897
933
  if (values.json)
@@ -1690,6 +1726,21 @@ async function documentsGet(args, deps) {
1690
1726
  }
1691
1727
  return 0;
1692
1728
  }
1729
+ async function documentsDelete(args, deps) {
1730
+ const { values, positionals } = parse(args, {});
1731
+ const documentId = need(positionals, 0, "documentId");
1732
+ const result = await (await clientFor(values, deps)).deleteDocument(documentId);
1733
+ if (values.json) {
1734
+ printJson(deps, result);
1735
+ return 0;
1736
+ }
1737
+ deps.io.out(`Deleted ${documentId}.`);
1738
+ const archived = Array.isArray(result.archivedAgents) ? result.archivedAgents : [];
1739
+ if (archived.length > 0) {
1740
+ deps.io.out(`Archived agents that lost their link: ${archived.map((agent) => agent.agentName).join(", ")}`);
1741
+ }
1742
+ return 0;
1743
+ }
1693
1744
  async function documentsReplace(args, deps) {
1694
1745
  const { values, positionals } = parse(args, {
1695
1746
  source: { type: "string" },
@@ -1931,6 +1982,130 @@ async function flowUpdate(args, deps) {
1931
1982
  deps.io.out(lines.join("\n"));
1932
1983
  return 0;
1933
1984
  }
1985
+ function chatDiagnosticLines(diagnostics) {
1986
+ if (diagnostics.length === 0)
1987
+ return ["Findings: none."];
1988
+ return [
1989
+ `Findings (${diagnostics.length}):`,
1990
+ ...diagnostics.map((d) => {
1991
+ const where = [d.nodeId && `node ${d.nodeId}`, d.edgeId && `line ${d.edgeId}`, d.detail].filter(Boolean).join(", ");
1992
+ return ` [${d.severity === "error" ? "error" : "warning"}] ${d.code}${where ? ` (${where})` : ""}`;
1993
+ }),
1994
+ ];
1995
+ }
1996
+ const publishedText = (version) => (version === null ? "never published" : `v${version}`);
1997
+ async function chatAgentsList(args, deps) {
1998
+ const { values } = parse(args, {});
1999
+ const agents = await (await clientFor(values, deps)).listChatAgents();
2000
+ if (values.json) {
2001
+ printJson(deps, agents);
2002
+ return 0;
2003
+ }
2004
+ if (agents.length === 0) {
2005
+ deps.io.out("No chat agents.");
2006
+ return 0;
2007
+ }
2008
+ deps.io.out(agents
2009
+ .map((a) => `${a.id} ${a.name} ${publishedText(a.publishedVersion)}${a.unpublishedChanges ? " (draft has unpublished changes)" : ""}`)
2010
+ .join("\n"));
2011
+ return 0;
2012
+ }
2013
+ async function chatAgentsGet(args, deps) {
2014
+ const { values, positionals } = parse(args, {});
2015
+ const agent = await (await clientFor(values, deps)).getChatAgent(need(positionals, 0, "chatAgentId"));
2016
+ if (values.json) {
2017
+ printJson(deps, agent);
2018
+ return 0;
2019
+ }
2020
+ deps.io.out([
2021
+ `${agent.name} (${agent.id})`,
2022
+ `Draft revision: ${agent.revision}`,
2023
+ `Published: ${publishedText(agent.publishedVersion)}${agent.publishedAt ? ` at ${agent.publishedAt}` : ""}`,
2024
+ agent.unpublishedChanges ? "The draft has changes that are not published." : "The draft matches the published version.",
2025
+ ].join("\n"));
2026
+ return 0;
2027
+ }
2028
+ async function chatAgentsDraftGet(args, deps) {
2029
+ const { values, positionals } = parse(args, {});
2030
+ const draft = await (await clientFor(values, deps)).getChatAgentDraft(need(positionals, 0, "chatAgentId"));
2031
+ if (values.json) {
2032
+ printJson(deps, draft);
2033
+ return 0;
2034
+ }
2035
+ const nodes = Array.isArray(draft.graph.nodes) ? draft.graph.nodes : [];
2036
+ const edges = Array.isArray(draft.graph.edges) ? draft.graph.edges.length : 0;
2037
+ deps.io.out([
2038
+ `${draft.name} (${draft.id})`,
2039
+ `Revision: ${draft.revision}`,
2040
+ `Nodes (${nodes.length}): ${nodes.map((n) => `${String(n.id)} [${String(n.type)}]`).join(", ") || "none"}`,
2041
+ `Lines: ${edges}`,
2042
+ "Use --json for the whole graph (what `draft update --graph-file` takes).",
2043
+ ].join("\n"));
2044
+ return 0;
2045
+ }
2046
+ async function chatAgentsDraftUpdate(args, deps) {
2047
+ const { values, positionals } = parse(args, {
2048
+ revision: { type: "string" },
2049
+ "graph-file": { type: "string" },
2050
+ name: { type: "string" },
2051
+ "dry-run": { type: "boolean" },
2052
+ });
2053
+ const chatAgentId = need(positionals, 0, "chatAgentId");
2054
+ const graphFile = values["graph-file"];
2055
+ if (!graphFile) {
2056
+ throw new UsageError("Pass --graph-file <path> — the whole graph as JSON, as `kumion chat-agents draft get --json` prints it.");
2057
+ }
2058
+ const file = await readJsonFile(graphFile);
2059
+ if (!file || typeof file !== "object" || Array.isArray(file))
2060
+ throw new UsageError(`${graphFile} must hold a JSON object.`);
2061
+ const graph = "graph" in file && typeof file.graph === "object" ? file.graph : file;
2062
+ const revision = requireRevision(values.revision, "the revision `kumion chat-agents draft get` showed when you read the draft you are changing.");
2063
+ const result = await (await clientFor(values, deps)).updateChatAgentDraft(chatAgentId, { graph, ...(values.name === undefined ? {} : { name: values.name }) }, revision, { dryRun: values["dry-run"] === true });
2064
+ if (values.json) {
2065
+ printJson(deps, result);
2066
+ return 0;
2067
+ }
2068
+ deps.io.out([
2069
+ values["dry-run"] ? `Dry run — nothing was saved. Revision stays ${result.revision}.` : `Draft saved. New revision: ${result.revision}`,
2070
+ ...chatDiagnosticLines(result.diagnostics),
2071
+ ...(values["dry-run"] ? [] : [`Nothing is live until you run \`kumion chat-agents publish ${chatAgentId}\`.`]),
2072
+ ].join("\n"));
2073
+ return 0;
2074
+ }
2075
+ async function chatAgentsDiagnostics(args, deps) {
2076
+ const { values, positionals } = parse(args, {});
2077
+ const result = await (await clientFor(values, deps)).getChatAgentDiagnostics(need(positionals, 0, "chatAgentId"));
2078
+ if (values.json) {
2079
+ printJson(deps, result);
2080
+ return 0;
2081
+ }
2082
+ deps.io.out([
2083
+ `Revision: ${result.revision}`,
2084
+ result.publishable ? "Publishable: yes" : "Publishable: no — an error-level finding is left.",
2085
+ ...chatDiagnosticLines(result.diagnostics),
2086
+ ].join("\n"));
2087
+ return 0;
2088
+ }
2089
+ async function chatAgentsPublish(args, deps) {
2090
+ const { values, positionals } = parse(args, { revision: { type: "string" } });
2091
+ const result = await (await clientFor(values, deps)).publishChatAgent(need(positionals, 0, "chatAgentId"), values.revision);
2092
+ if (values.json) {
2093
+ printJson(deps, result);
2094
+ return 0;
2095
+ }
2096
+ deps.io.out(`Published as v${result.version} at ${result.publishedAt}.`);
2097
+ return 0;
2098
+ }
2099
+ async function chatAgentsVersions(args, deps) {
2100
+ const { values, positionals } = parse(args, {});
2101
+ const versions = await (await clientFor(values, deps)).listChatAgentVersions(need(positionals, 0, "chatAgentId"));
2102
+ if (values.json) {
2103
+ printJson(deps, versions);
2104
+ return 0;
2105
+ }
2106
+ deps.io.out(versions.length === 0 ? "No published versions." : versions.map((v) => `v${v.version} ${v.publishedAt}`).join("\n"));
2107
+ return 0;
2108
+ }
1934
2109
  function flowStepChangeLine(change) {
1935
2110
  if (change.kind === "add_step")
1936
2111
  return ` + ステップ ${change.node}(${change.key}・${change.stepType ?? "agent"})`;
@@ -2368,7 +2543,10 @@ export function formatTranscript(transcript) {
2368
2543
  else if (segment.status === "failed")
2369
2544
  lines.push(`Transcription failed${segment.reason ? ` (${segment.reason})` : ""}.`);
2370
2545
  for (const t of segment.turns) {
2371
- lines.push(`${t.offsetSec !== null ? `[+${t.offsetSec}s] ` : ""}${t.speaker !== null ? `Person (speaker ${t.speaker})` : "Person"}: ${t.text}`);
2546
+ const who = t.role
2547
+ ? { ai: "Agent", caller: "Caller", callee: "Transferee" }[t.role]
2548
+ : t.speaker !== null ? `Person (speaker ${t.speaker})` : "Person";
2549
+ lines.push(`${t.offsetSec !== null ? `[+${t.offsetSec}s] ` : ""}${who}: ${t.text}`);
2372
2550
  }
2373
2551
  }
2374
2552
  return lines.join("\n");
package/dist/mcp.js CHANGED
@@ -55,6 +55,11 @@ const flowLeaf = z
55
55
  .optional()
56
56
  .describe("Hand this 用件 to this registered staff member (a `key` from get_call_flow's staffChoices)."),
57
57
  removeTransfer: z.boolean().optional().describe("Take the transfer off this 用件 (it goes back to a message)."),
58
+ transferBrowserFirst: z
59
+ .boolean()
60
+ .optional()
61
+ .describe("For a 用件 that transfers to a staff member: ring the browser of the portal account bound to them first when it is on reception (default true)."),
62
+ transferBrowserFirstSeconds: z.number().int().min(10).max(30).optional().describe("How many seconds that browser rings before the phone is dialled (10-30, default 15)."),
58
63
  requiredBeforeEnd: z.array(z.record(z.string(), z.unknown())).optional().describe("The whole list the 用件 must ask."),
59
64
  steps: z.array(flowStep).optional(),
60
65
  })
@@ -307,7 +312,8 @@ export function createKumionMcpServer(client, options) {
307
312
  }, (args) => attempt(() => client.getWebcallAccess(args.agentId)));
308
313
  server.registerTool("set_webcall_access", {
309
314
  description: "Set the Webコール access limits. accessIpAllowlist: IPs or CIDRs (empty list = no limit); embedOriginAllowlist: " +
310
- "origins like https://example.com or https://*.example.com. appearance: the widget look (accent #RRGGBB, title <=40, " +
315
+ "origins like https://example.com or https://*.example.com. requireSignedVisitor: true refuses a start without a visitorToken signed " +
316
+ "by the tenant's own server (default false; the /call share link cannot carry a token, so it stops working). appearance: the widget look (accent #RRGGBB, title <=40, " +
311
317
  "greeting <=200, quickReplies <=4 x <=30, launcherLabel <=20, launcherPosition, entry); null clears an item. logo: " +
312
318
  "{contentType, dataBase64} PNG/JPEG/WebP <=512KB, or null to remove. LIVE: applies at once, no publish, so confirm with the " +
313
319
  "person first (a wrong IP list locks them out). Needs agents:live.",
@@ -315,6 +321,7 @@ export function createKumionMcpServer(client, options) {
315
321
  agentId,
316
322
  accessIpAllowlist: z.array(z.string()).optional().describe("Allowed IPs/CIDRs; [] clears."),
317
323
  embedOriginAllowlist: z.array(z.string()).optional().describe("Allowed embedding origins; [] clears."),
324
+ requireSignedVisitor: z.boolean().optional().describe("true: only visitors with a signed visitorToken may start a call; false: anonymous starts allowed."),
318
325
  appearance: z
319
326
  .object({
320
327
  accent: z.string().nullable().optional(),
@@ -340,12 +347,14 @@ export function createKumionMcpServer(client, options) {
340
347
  patch.accessIpAllowlist = args.accessIpAllowlist;
341
348
  if (args.embedOriginAllowlist)
342
349
  patch.embedOriginAllowlist = args.embedOriginAllowlist;
350
+ if (args.requireSignedVisitor !== undefined)
351
+ patch.requireSignedVisitor = args.requireSignedVisitor;
343
352
  if (args.appearance)
344
353
  patch.appearance = args.appearance;
345
354
  if (args.logo !== undefined)
346
355
  patch.logo = args.logo;
347
356
  if (Object.keys(patch).length === 0) {
348
- return failure(new UsageError("Nothing to change: pass `accessIpAllowlist`, `embedOriginAllowlist`, `appearance` or `logo`."));
357
+ return failure(new UsageError("Nothing to change: pass `accessIpAllowlist`, `embedOriginAllowlist`, `requireSignedVisitor`, `appearance` or `logo`."));
349
358
  }
350
359
  return attempt(() => client.setWebcallAccess(args.agentId, patch));
351
360
  });
@@ -514,9 +523,10 @@ export function createKumionMcpServer(client, options) {
514
523
  description: "Read what the caller (`user`) and the agent (`assistant`) said on one call, in order. Tool calls and " +
515
524
  "the agent's instructions are not included. `available: false` means no transcript has been written " +
516
525
  "yet (the call is still up, or never connected) — not that the call was silent. A call handed to a " +
517
- "person also carries `handoffSegment`: what the person said after the pickup (`status` transcribed / " +
526
+ "person also carries `handoffSegment`: the conversation after the pickup (`status` transcribed / " +
518
527
  "failed / not_sent; not_sent means the tenant's contract forbids sending the recording out, so there is " +
519
- "no text). Needs calls:read.",
528
+ "no text). When each person was transcribed apart its turns have `role`: `ai` (the platform), `caller` " +
529
+ "(the other side of the call), `callee` (the person transferred to). Needs calls:read.",
520
530
  inputSchema: { callId },
521
531
  annotations: { readOnlyHint: true },
522
532
  }, (args) => attempt(async () => ({ transcript: await client.getTranscript(args.callId) })));
@@ -1056,6 +1066,13 @@ export function createKumionMcpServer(client, options) {
1056
1066
  },
1057
1067
  annotations: { readOnlyHint: true },
1058
1068
  }, (args) => attempt(() => client.getDocument(args.documentId)));
1069
+ server.registerTool("delete_document", {
1070
+ description: "Delete a 資料. Refused with the list of what uses it (`references`) while an agent or a flow step still " +
1071
+ "does; nothing is written then. An archived agent is not a user: deleting clears its link and the " +
1072
+ "answer names it in `archivedAgents`. Cannot be undone, so confirm with the person first. Needs agents:live.",
1073
+ inputSchema: { documentId: z.string().min(1).describe("The 資料 to delete, from get_document.") },
1074
+ annotations: { destructiveHint: true, idempotentHint: true },
1075
+ }, (args) => attempt(() => client.deleteDocument(args.documentId)));
1059
1076
  server.registerTool("replace_document", {
1060
1077
  description: "Replace a 資料's content and facts with another 資料's, keeping its id — so every agent already " +
1061
1078
  "reading it switches over, with no re-creation and no publish (LIVE: the next call reads the new " +
@@ -1087,6 +1104,62 @@ export function createKumionMcpServer(client, options) {
1087
1104
  },
1088
1105
  annotations: { destructiveHint: true, idempotentHint: true },
1089
1106
  }, (args) => attempt(() => client.replaceDocument(args.documentId, { sourceDocumentId: args.sourceDocumentId, sourceRevision: args.sourceRevision }, args.revision, { dryRun: args.dryRun === true })));
1107
+ const chatAgentId = z.string().min(1).describe("The chat agent's id, from list_chat_agents.");
1108
+ server.registerTool("list_chat_agents", {
1109
+ description: "List the tenant's チャットエージェント (text agents): id, name, published version and whether the draft has " +
1110
+ "changes that are not published. Needs agents:read and a plan that includes chat agents.",
1111
+ inputSchema: {},
1112
+ annotations: { readOnlyHint: true },
1113
+ }, () => attempt(() => client.listChatAgents()));
1114
+ server.registerTool("get_chat_agent", {
1115
+ description: "One チャットエージェント: name, draft revision, published version and whether the draft has unpublished " +
1116
+ "changes. The canvas itself is get_chat_agent_draft. Needs agents:read.",
1117
+ inputSchema: { chatAgentId },
1118
+ annotations: { readOnlyHint: true },
1119
+ }, (args) => attempt(() => client.getChatAgent(args.chatAgentId)));
1120
+ server.registerTool("get_chat_agent_draft", {
1121
+ description: "Read a チャットエージェント's draft canvas: `graph` (nodes, lines and settings, the shape " +
1122
+ "update_chat_agent_draft takes) and `revision`, which update_chat_agent_draft needs. Needs agents:read.",
1123
+ inputSchema: { chatAgentId },
1124
+ annotations: { readOnlyHint: true },
1125
+ }, (args) => attempt(() => client.getChatAgentDraft(args.chatAgentId)));
1126
+ server.registerTool("update_chat_agent_draft", {
1127
+ description: "Replace a チャットエージェント's draft with `graph` (the whole canvas, as get_chat_agent_draft returns it), " +
1128
+ "through the same structural check the canvas's save runs: a graph that fails it is a 400 and nothing is " +
1129
+ "written. Returns the new `revision` and the `diagnostics` the draft now has. A stale `revision` is a 412 " +
1130
+ "and nothing is written. `dryRun` runs every check and returns the diagnostics without saving, so you can " +
1131
+ "try a change first. A draft write: visitors see it only after publish_chat_agent. Needs agents:write.",
1132
+ inputSchema: {
1133
+ chatAgentId,
1134
+ revision: z.string().min(1).describe("The draft revision your change is based on, from get_chat_agent_draft."),
1135
+ graph: z.record(z.string(), z.unknown()).describe("The whole new graph."),
1136
+ name: z.string().optional().describe("A new name; left as it is when omitted."),
1137
+ dryRun: z.boolean().optional().describe("Run the checks and return the diagnostics; store nothing."),
1138
+ },
1139
+ annotations: { destructiveHint: false, idempotentHint: false },
1140
+ }, (args) => attempt(() => client.updateChatAgentDraft(args.chatAgentId, { graph: args.graph, ...(args.name === undefined ? {} : { name: args.name }) }, args.revision, { dryRun: args.dryRun === true })));
1141
+ server.registerTool("get_chat_agent_diagnostics", {
1142
+ description: "The findings on a チャットエージェント's draft: each has a `code`, a `severity` (error or warning) and the " +
1143
+ "node or line it is about. `publishable` is false while an error is left. Needs agents:read.",
1144
+ inputSchema: { chatAgentId },
1145
+ annotations: { readOnlyHint: true },
1146
+ }, (args) => attempt(() => client.getChatAgentDiagnostics(args.chatAgentId)));
1147
+ server.registerTool("publish_chat_agent", {
1148
+ description: "Publish a チャットエージェント's draft as its next version. Refused (422, with the diagnostics) while an " +
1149
+ "error-level finding is left, and nothing is stored. Pass `revision` to publish only if the draft is still " +
1150
+ "the one you read (412 otherwise). This puts the agent in front of its visitors, so confirm with the " +
1151
+ "person first. Needs agents:publish.",
1152
+ inputSchema: {
1153
+ chatAgentId,
1154
+ revision: z.string().min(1).optional().describe("The draft revision you mean to publish, from get_chat_agent_draft."),
1155
+ },
1156
+ annotations: { destructiveHint: false, idempotentHint: false },
1157
+ }, (args) => attempt(() => client.publishChatAgent(args.chatAgentId, args.revision)));
1158
+ server.registerTool("list_chat_agent_versions", {
1159
+ description: "The published versions of a チャットエージェント, newest first. Needs agents:read.",
1160
+ inputSchema: { chatAgentId },
1161
+ annotations: { readOnlyHint: true },
1162
+ }, (args) => attempt(() => client.listChatAgentVersions(args.chatAgentId)));
1090
1163
  for (const op of DATA_OPS) {
1091
1164
  server.registerTool(op.mcp, {
1092
1165
  description: op.description,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kumion/cli",
3
- "version": "0.6.8",
3
+ "version": "0.6.10",
4
4
  "description": "Manage your Kumion voice agents from the terminal over the Kumion Partner API",
5
5
  "author": "KAOPA株式会社",
6
6
  "license": "MIT",
@@ -13,8 +13,8 @@ Two ways in, same operations and same permissions:
13
13
 
14
14
  - **MCP tools** when the host has the `kumion` MCP server registered. Each CLI
15
15
  command has one: `list_agents`, `get_agent`, `get_agent_spec`, `patch_agent`,
16
- `publish_agent`, `get_call_flow`, `update_call_flow`, `edit_call_flow_steps`,
17
- `set_agent_opening_name`, `set_agent_availability`, `get_webcall_access`, `set_webcall_access`, `list_widget_signing_keys`, `create_widget_signing_key`, `revoke_widget_signing_key`, `create_agent_from_template`,
16
+ `publish_agent`, `list_chat_agents`, `get_chat_agent`, `get_chat_agent_draft`, `update_chat_agent_draft`, `get_chat_agent_diagnostics`, `publish_chat_agent`, `list_chat_agent_versions`, `get_call_flow`, `update_call_flow`, `edit_call_flow_steps`,
17
+ `set_agent_opening_name`, `set_agent_availability`, `get_webcall_access`, `set_webcall_access`, `list_widget_signing_keys`, `create_widget_signing_key`, `revoke_widget_signing_key`, `delete_document`, `create_agent_from_template`,
18
18
  `list_agent_templates`, `list_facts`, `edit_fact`, `confirm_facts`,
19
19
  `list_staff`, `create_staff`, `update_staff`, `get_store_hours`,
20
20
  `update_store_hours`, `set_store_hours_exception`, `get_booking_settings`,
@@ -34,7 +34,7 @@ Two ways in, same operations and same permissions:
34
34
  Run `kumion auth status`. If it says "Not logged in", **stop and ask the user** to run
35
35
  `kumion auth login` themselves: it prints a link and a code, and the user approves
36
36
  it in the Portal in their browser (a tenant administrator gets a personal key good for
37
- 12 hours). With a key from 設定 → 開発者 it is `kumion auth login --with-api-key`,
37
+ 12 hours). With a key from 設定 → 開発者API it is `kumion auth login --with-api-key`,
38
38
  which prompts for the tenant ID and the key with hidden input. Do not run the login
39
39
  yourself and do not approve anything on the user's behalf. Never ask the user to paste
40
40
  an API key into the chat, never put a key in a command line, a file, `.mcp.json` or an
@@ -148,6 +148,24 @@ number. `--json` everywhere; the names below are the CLI's, the MCP tool is in t
148
148
  `publishState.live: true`, `unpublishedChanges: false`, and the publish answer's
149
149
  `agent.publishedSnapshotId`. `unconfirmedFacts` above zero means the agent is not finished.
150
150
 
151
+ ## Chat agents (チャットエージェント)
152
+
153
+ A chat agent is the text agent: its own ids (`list_chat_agents` / `kumion chat-agents list`, never `list_agents`), its
154
+ own draft canvas and its own versions. The tenant's plan has to include it; a 403 with no scope name on these tools
155
+ means it does not, and a new key does not help.
156
+
157
+ 1. `get_chat_agent_draft` / `kumion chat-agents draft get <id> --json` — the `graph` (the canvas) and its `revision`.
158
+ 2. Change the graph and try it first: `update_chat_agent_draft` with `dryRun: true` /
159
+ `kumion chat-agents draft update <id> --revision <rev> --graph-file <path> --dry-run`. It runs the canvas's own
160
+ structural check (a failing graph is a 400, nothing written) and returns the `diagnostics` the draft would have.
161
+ 3. Save it without `dryRun`; the answer carries the new `revision`. A 412 means someone saved first: read the draft again
162
+ and re-apply your change, do not retry with the old revision.
163
+ 4. `get_chat_agent_diagnostics` / `kumion chat-agents diagnostics <id>` — `publishable` is false while any finding has
164
+ `severity: "error"`. Fix those before publishing.
165
+ 5. `publish_chat_agent` / `kumion chat-agents publish <id> --revision <rev>` puts it in front of visitors, so confirm
166
+ with the person first. A 422 carries the `diagnostics` that refused it. `list_chat_agent_versions` /
167
+ `kumion chat-agents versions <id>` shows the new version; `get_chat_agent` shows `unpublishedChanges`.
168
+
151
169
  ## Reading real calls
152
170
 
153
171
  `list_calls` / `kumion calls list` pages through the call history (filter by agent,
@@ -156,8 +174,9 @@ channel, time range, or caller number). Each call already carries its result (`o
156
174
  transcript only for the call you need. `get_call_transcript` /
157
175
  `kumion calls transcript <callId>` returns what the caller (`user`) and the agent
158
176
  (`assistant`) said. `available: false` means no transcript has been written yet, not a
159
- silent call. A call handed to a person also has `handoffSegment`: what the person said after
160
- the pickup (`status` is `transcribed`, `failed` or `not_sent`; `not_sent` means the tenant's
177
+ silent call. A call handed to a person also has `handoffSegment`: the conversation after
178
+ the pickup; when each person was transcribed apart its turns have `role` (`ai`, `caller`,
179
+ `callee` = the person transferred to) (`status` is `transcribed`, `failed` or `not_sent`; `not_sent` means the tenant's
161
180
  contract forbids sending the recording out, so there is no text). `turns` stays the AI part. `get_call` carries `direction` (the raw stored value) and `portalDirection` (`inbound` /
162
181
  `outbound` / null: the 着信/発信 the Portal call history shows); count from `portalDirection`.
163
182
  Use a transcript to find where the agent went wrong before editing its
@@ -272,7 +291,7 @@ A key a node does not store follows the agent's setting (会話の運用) or the
272
291
  | `opening_speech` | start | `required` | `string` | The opening line. Supports {{variables}}. |
273
292
  | `items` | start, agent | `required` | `{key,label?,example?,source?,value_type?,options?,must_ask?,min_digits?,max_digits?,require_day?,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). `require_day`: for a `birthdate` item, tell the model the value needs a year, a month and a day (off = year and month). `tool`: `{tool_key,result_field}` for a tool-sourced item. |
274
293
  | `allow_interruptions` | start, agent | `tune` | `boolean` | Absent means the caller may interrupt. Only an explicit false is stored. |
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`). |
294
+ | `route_judge` | start | `tune` | `boolean` | Absent means on wherever the step can be judged, and off without any diagnostic where it cannot; `false` turns it off. 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 800 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. A step can be judged when the call is Japanese, the call model's endpoint has a calibrated readout, and the step has no items, exactly three AI connections without items and no fixed connections. An explicit `true` on a step that cannot be judged is reported (graph diagnostics `route_judge_not_applicable`). |
276
295
  | `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). |
277
296
  | `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`). |
278
297
  | `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. |
@@ -293,7 +312,7 @@ A key a node does not store follows the agent's setting (会話の運用) or the
293
312
  | `kb_fallback` | start, agent | `advanced` | `{ noResult?, unavailable? }` | Wording when a knowledge search finds nothing or is unavailable. Overrides the tenant operations setting. |
294
313
  | `end_speech` | end | `required` | `string` | Default goodbye line. A connection into this node can override it. |
295
314
  | `caller_leaves` | end | `required` | `boolean` | Marks the end a caller who walks away is sent to from every agent step, connected or not. Required on exactly one end when the flow has two or more end nodes. |
296
- | `ivr` | ivr | `required` | `object` | Announcement, digit table and wait time. input and max_retries are fixed; other values are rejected. |
315
+ | `ivr` | ivr | `required` | `object` | Announcement, digit table, wait time, and the optional speech exit. input and max_retries are fixed; other values are rejected. `voice_enabled: true` also lets a spoken answer leave the menu once it reaches `voice_min_chars` letters and digits (2–30, default 5); the edge it takes has the condition `ivr.<key>.status == "voice"`, and without that edge a spoken answer follows the no-input / failure edge. Omit both keys for the digit-only menu. |
297
316
  | `transfer` | transfer | `required` | `object` | Transfer target and the line spoken before transferring. |
298
317
  | `notify` | notify | `required` | `object` | Recipients, subject and body templates. |
299
318
  | `http_method` | webhook | `required` | `string` | GET, POST, PUT, PATCH or DELETE. |
@@ -326,6 +345,13 @@ The `internal` keys that are settings, not bookkeeping, have no Portal screen:
326
345
  with no finish key (`{ "mode": "single", "max_digits": 1, "finish_key": null }`)
327
346
  and `max_retries` must be `0`; any other value makes the patch fail. Only
328
347
  `ivr.timeout_ms` (3000–30000, default 8000) can change.
348
+ - `ivr.voice_enabled` and `ivr.voice_min_chars` (IVR nodes) — optional speech exit
349
+ (the Portal's 「声でも次へ進む」). Set `voice_enabled: true` to let a spoken answer leave
350
+ the menu; `voice_min_chars` (integer 2–30, default 5) is how many letters and digits
351
+ the utterance needs, so a back-channel does not end the menu. Draw the exit as an edge
352
+ with the condition `ivr.<key>.status == "voice"`; without it a spoken answer follows the
353
+ no-input / failure edge, and a voice edge on a node with the option off is flagged.
354
+ Leave both keys out for the digit-only menu.
329
355
 
330
356
  A required item whose 種類 is 選択肢 (`derived` / `select`) needs its options in
331
357
  the item's `options`: the AI picks one of them and the write is checked
@@ -353,7 +379,7 @@ These cover what the Portal's 顧客, 通話 and 分析 screens already do. Each
353
379
  `kumion auth login`.
354
380
  - **403 naming a scope** — the key lacks it (`agents:read`, `agents:write`,
355
381
  `agents:publish`, `agents:live`, `tests:run`, `calls:create`, `calls:read`, `calls:read_unmasked`, `calls:write`, `contacts:read`, `contacts:write`, `captures:read`, `captures:write`, `analytics:read`). The user issues a key with that scope
356
- in the Portal (設定 → 開発者) and logs in again. Do not work around it.
382
+ in the Portal (設定 → 開発者API) and logs in again. Do not work around it.
357
383
  - **403 without a scope name** — the tenant's plan cannot publish, or `create_call` hit
358
384
  the call-minute limit. Tell the user; a new key does not help.
359
385
  - **422 on publish with only a message** — a check before the test calls refused,