@kumion/cli 0.2.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -106,22 +106,153 @@ would use.
106
106
  | `kumion agents get <agentId> [--json]` | `agents:read` |
107
107
  | `kumion agents patch <agentId> --revision <rev> [--prompt <text> \| --prompt-file <path>] [--graph-file <path>]` | `agents:write` |
108
108
  | `kumion agents publish <agentId> [--revision <rev>]` | `agents:publish` |
109
+ | `kumion agents opening-name <agentId> --revision <rev> (--on \| --off)` | `agents:write` (a draft write: live after the next publish) |
110
+ | `kumion agents availability <agentId> --revision <rev> [--operating-hours-file <path>] [--off-hours-file <path>]` | `agents:live` (live: no publish) |
111
+ | `kumion agents create-from-template --template <id> --business-name <name> [--name <name>] [--url <url> \| --document <documentId>] [--idempotency-key <key>]` | `agents:write` (a `url` makes it read an external site and call the model; the key makes a resend return the first agent) |
112
+ | `kumion agents capture get <agentId>` | `agents:read` |
113
+ | `kumion agents capture set <agentId> --revision <rev> (--spec <specId> ... \| --clear)` | `agents:live` (live: no publish) |
114
+ | `kumion flow get <agentId>` | `agents:read` |
115
+ | `kumion flow update <agentId> --revision <rev> --patch-file <path> [--dry-run]` | `agents:write` |
116
+ | `kumion flow edit-steps <agentId> --revision <rev> --ops-file <path> [--dry-run]` | `agents:write` |
117
+ | `kumion templates list` | `agents:read` |
118
+ | `kumion staff list` | `agents:read` |
119
+ | `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) |
120
+ | `kumion staff update <staffId> --revision <rev> [--name ...] [--transfer-target ...] [--enabled true\|false]` | `agents:live` (live: no publish) |
121
+ | `kumion hours get [--from <date>] [--to <date>] [--json]` | `agents:read` |
122
+ | `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) |
123
+ | `kumion hours exception set <date> --revision <rev> --kind closed\|open\|inherit [--hours-file <path>] [--note <text>] [--dry-run]` | `agents:live` (live: no publish) |
124
+ | `kumion booking get <agentId>` | `agents:read` |
125
+ | `kumion booking calendar update --revision <rev> --patch-file <path> [--dry-run]` | `agents:live` (live: no publish) |
126
+ | `kumion booking services create --revision <rev> --data-file <path> [--dry-run]` | `agents:live` (live: no publish) |
127
+ | `kumion booking services update <serviceId> --revision <rev> --patch-file <path> [--dry-run]` | `agents:live` (live: no publish) |
128
+ | `kumion booking resources create --revision <rev> --data-file <path> [--dry-run]` | `agents:live` (live: no publish) |
129
+ | `kumion booking resources update <resourceId> --revision <rev> --patch-file <path> [--dry-run]` | `agents:live` (live: no publish) |
130
+ | `kumion booking mount <agentId> --mounted true\|false --revision <rev> [--dry-run]` | `agents:live` (live: no publish) |
131
+ | `kumion booking slots <agentId> --resource <resourceId> --date <YYYY-MM-DD> [--service <serviceId>] [--limit <n>]` | `agents:read` |
132
+ | `kumion facts list <agentId>` | `agents:read` |
133
+ | `kumion facts edit <agentId> <factId> --revision <rev> --value <text>` | `agents:live` (live: no publish) |
134
+ | `kumion facts confirm <agentId> [--fact <id> ...]` | `agents:live` (live: no publish) |
135
+ | `kumion capture-specs list` | `agents:read` |
136
+ | `kumion capture-specs create --data-file <path>` | `agents:write` (draft: a new spec is mounted on no agent yet) |
137
+ | `kumion capture-specs update <specId> --revision <rev> --patch-file <path>` | `agents:live` (live: every agent mounted with it records differently) |
138
+ | `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)) |
139
+ | `kumion documents jobs get <jobId>` | `agents:read` (exits 1 when the job failed or timed out) |
140
+ | `kumion documents get <documentId>` | `agents:read` |
141
+ | `kumion documents replace <documentId> --source <sourceDocumentId> --source-revision <rev> --revision <rev> [--dry-run]` | `agents:live` (live: no publish) |
109
142
  | `kumion test-runs start <agentId> [--no-wait] [--interval <sec>] [--timeout <sec>]` | `tests:run` |
110
- | `kumion test-runs get <agentId> <runId>` / `test-runs list <agentId>` | `tests:run` |
111
- | `kumion calls create <agentId> [--campaign-contact <id>]` | `calls:create` |
143
+ | `kumion test-runs get <agentId> <runId>` | `tests:run` |
144
+ | `kumion test-runs list <agentId>` | `tests:run` |
145
+ | `kumion calls create <agentId> [--to <phone>] [--campaign-contact <id>] [--var <name>=<value> ...]` | `calls:create` |
112
146
  | `kumion calls list [--agent <id>] [--channel webcall\|sip_did\|trigger] [--from <iso>] [--to <iso>] [--search <text>] [--limit <n>] [--offset <n>]` | `calls:read` |
113
- | `kumion calls get <callId>` / `calls transcript <callId>` | `calls:read` |
147
+ | `kumion calls get <callId>` | `calls:read` |
148
+ | `kumion calls transcript <callId>` | `calls:read` |
114
149
 
115
150
  A command whose key lacks the scope fails with a message naming the scope it needs.
116
151
  `calls:read` is its own scope: a key that can start calls (`calls:create`) cannot read
117
152
  them. `calls list` returns one page (20 by default, at most 100) and prints the
118
- `--offset` of the next one. A transcript holds only what the caller and the agent said.
153
+ `--offset` of the next one. Every call in `calls list` and `calls get` carries what it came to: `outcome`
154
+ (`ai_resolved`, `ai_unresolved_hangup`, `invalid_call`, `handoff`, `system_ended`, or `na` when not judged),
155
+ `endedAtNode` (the node it ended on), `durationSec`, `transferred`, and `capturedItems` (the names of the
156
+ items it recorded, never their values). A transcript holds only what the caller and the agent said.
119
157
  Add `--json` to any command for the API's JSON instead of a summary.
120
158
 
159
+ `hours` is the shop clock the call answers 「何時までですか」 from, and it is one calendar for the
160
+ whole tenant. `hours update` replaces a field whole (a `--business-hours-file` holding Mon–Fri makes
161
+ Sat and Sun closed), and an omitted field is left alone. `hours exception set` writes one date:
162
+ `closed` is 臨時休業, `open` is 振替出勤 with its own `--hours-file` (or the weekday's hours), and
163
+ `inherit` deletes the date's row so the weekly rule applies again. Both writes carry `--revision`,
164
+ the number `hours get` prints; anything that changes the same calendar in between — the Portal's
165
+ 予約設定, a 担当 or 内容, a published mount — moves it, and a stale write is refused with a conflict
166
+ and nothing saved. `--dry-run` shows what would be saved without moving the revision.
167
+
168
+ `booking` is 予約設定, the same calendar seen from the booking side. `booking get <agentId>` answers
169
+ the slot length, the lead time, the horizon, the **内容** (what can be booked and how long it takes),
170
+ the **担当**, and whether that agent is mounted — plus the `revision` every write below needs. It is
171
+ per agent because the mount is; the settings themselves are the tenant's. `booking calendar update`
172
+ takes a `--patch-file` holding `defaultSlotMinutes` (1–1440), `minLeadMinutes` (0–43200) and/or
173
+ `maxAdvanceDays` (1–730); an omitted field is left alone. `booking services create --data-file` takes
174
+ `name` and `durationMinutes`, and `durationMinutes: null` means 「枠の長さを使う」 — the same null the
175
+ read-back shows. `booking services update` changes a name and/or a duration, `null` going back to the
176
+ slot length. Values must be JSON numbers: `"30"` is refused, not read as 30. All three writes are
177
+ live, and a create carries the revision too, so two callers holding one revision cannot both add a
178
+ 内容 — the second is refused.
179
+
180
+ `booking resources create|update` is a **担当** — who a booking is with. `--data-file` holds `name`,
181
+ `enabled`, `weeklyHours` (`{ "mon": [{ "start": "09:00", "end": "12:00" }] }`) and `serviceIds`
182
+ (`[]` takes every 内容; a list takes only those; omitted keeps the current setting). A 内容 id that is
183
+ not this tenant's refuses the whole write. `enabled: false` takes a 担当 out of service without
184
+ deleting it. `booking mount <agentId> --mounted true|false` is the switch that lets the agent book at
185
+ all: a template's agent starts unmounted, and mounting also retires the 「仮受付」 promise from the
186
+ 受付サマリー in the same write. `booking slots <agentId> --resource <id> --date <date>` reads one
187
+ 担当's openings for one day, computed the way a call computes them (6 by default, at most 20 with
188
+ `--limit`); it reserves nothing and returns no customer's data.
189
+
190
+ `capture-specs` is 記録項目, what the agent records after a call. A spec is the tenant's and the mount
191
+ is the agent's: `capture-specs create --data-file` makes one (mounted on nothing yet),
192
+ `capture-specs update <specId> --rev` changes it for every agent already mounted, and
193
+ `agents capture get|set <agentId>` reads and replaces the set one agent records (`--spec` repeats,
194
+ `--clear` records nothing). `agents capture get` also answers `readiness` — whether THIS agent would
195
+ record anything after a call; a shop whose other agent records is not evidence for this one.
196
+
197
+ `documents` is 資料, the source a template's facts are extracted from: `upload` accepts the text or the
198
+ files and answers a job, `jobs get` follows it, `get` reads the extracted fields, and `replace` gives
199
+ an existing 資料 another document's content while keeping its id. The next section walks the whole
200
+ path; the limits are there too.
201
+
202
+ ### Per-call variables
203
+
204
+ `calls create --var 氏名=山田 --var route=B` starts the call with those values; the agent reads
205
+ them as `{{vars.氏名}}` in a prompt or opening line, and as `vars.route == "B"` in an edge
206
+ condition. The API takes the same values as `variables` in the `POST /api/v1/{tenant}/calls`
207
+ body: an object of strings, at most 50 names, 1000 characters per value, 10000 in total (a
208
+ larger or non-string value is a 400 naming the item). With `--campaign-contact`, the list row's
209
+ columns are the base and `--var` wins. A name that is not passed reads as an empty string.
210
+
211
+ ### Dialing a phone
212
+
213
+ `calls create <agentId> --to 08012345678` places a real call from the phone number assigned to
214
+ the agent instead of opening a web call. The number must be a domestic Japanese landline, 050,
215
+ or 070/080/090 number; international, toll-free (0120/0800), 0570 and short numbers are
216
+ refused. The agent has to be published and have a phone number assigned, otherwise the command
217
+ fails with the reason. It returns at once with the call id; whether the callee answered, was
218
+ busy, did not answer, or the call failed is on `calls get <callLogId>` (`disposition`).
219
+ `--var` and `--campaign-contact` work the same as for a web call. Outbound minutes are metered
220
+ separately from inbound ones. The API takes the same number as `phoneNumber` in the
221
+ `POST /api/v1/{tenant}/calls` body (HTTP 202); without it the call is a web call as before.
222
+
121
223
  ### Editing a draft
122
224
 
123
225
  Edits go to the agent's **draft**. Callers hear nothing new until you publish.
124
226
 
227
+ Start with `flow get`. It shows the flow the way the Portal's canvas assistant sees it,
228
+ and its `editLayer` says which command edits it:
229
+
230
+ - **`flow`** — the flow is in the 用件 form (an agent made from a template is). Change it
231
+ with `flow update`: a JSON object holding only what changes — `personaPrompt`,
232
+ `openingSpeech`, `noRouteSpeech`, `examples`, and `leaves[]`, one entry per 用件 by
233
+ `key` with an `action` (`keep`, `add`, `remove`, `merge_into`). A 用件 hands the caller
234
+ to a staff member with `transferContactKey` (a key from `staff list` / `flow get`'s
235
+ `staffChoices`) and stops with `removeTransfer`.
236
+ - **`steps`** — a step-by-step graph (`flow` is `null`). Change it with `flow edit-steps`:
237
+ a batch of operations, each `{ "op": "<name>", …its arguments }`, from
238
+ `set_node_field`, `set_edge_words`, `add_step`, `remove_step`, `connect_steps`,
239
+ `reconnect`, `disconnect`. They run in order; one refused operation refuses the whole
240
+ batch and nothing is saved. `add_step` may take a `key` so later operations in the
241
+ same batch can name the new step.
242
+
243
+ Both take the same arguments, and are checked by the same rules, as the canvas
244
+ assistant's tools. `--dry-run` prints the change and saves nothing.
245
+
246
+ ```sh
247
+ kumion flow get <agentId> --json > flow.json # note "revision" and "editLayer"
248
+ kumion flow update <agentId> --revision <rev> --patch-file change.json --dry-run
249
+ kumion flow update <agentId> --revision <rev> --patch-file change.json
250
+ kumion flow edit-steps <agentId> --revision <rev> --ops-file ops.json
251
+ ```
252
+
253
+ `agents patch` replaces the prompt or the whole graph. Use it for a prompt-only agent,
254
+ or for a graph change the two commands above do not cover:
255
+
125
256
  ```sh
126
257
  kumion agents get <agentId> --json > agent.json # note "revision"
127
258
  # edit agent.json's draft.graph, or write a new prompt to prompt.txt
@@ -129,22 +260,135 @@ kumion agents patch <agentId> --graph-file agent.json
129
260
  kumion agents patch <agentId> --revision <rev> --prompt-file prompt.txt
130
261
  ```
131
262
 
132
- `--revision` says which version of the draft your change is based on. If someone saved
133
- the agent in the Portal (or from another client) since you read it, the patch is
134
- refused with a conflict and nothing is written: read it again and re-apply your change.
263
+ `--revision` says which version of the draft your change is based on; `flow get` and
264
+ `agents get` show the same one. If someone saved the agent in the Portal (or from
265
+ another client) since you read it, the write is refused with a conflict and nothing
266
+ is written: read it again and re-apply your change.
135
267
  `--graph-file` accepts either a bare flow graph or the whole `agents get --json`
136
268
  output, in which case the revision inside the file is used.
137
269
 
270
+ **External send settings are closed here.** A setting that decides where a call sends
271
+ something, or which recording it plays before the first word, can be sent back
272
+ unchanged but not added, removed or changed — the same fields the Portal's canvas owns
273
+ and the assistant may not write:
274
+
275
+ - a webhook step's `endpoint_url`, `http_method`, `payload_template`, `custom_headers`
276
+ - the start step's `precall_fetch_url`, `precall_fetch_method`, `precall_fetch_headers`
277
+ - a notification step's `notify` (channel, recipients, subject and body templates)
278
+ - a transfer step's target, unless it is the key of an enabled スタッフ with a 転送先
279
+ (`staff list` shows `transferCandidate`)
280
+ - the start step's `opening_audio_url` and `opening_audio_filename`
281
+ - an IVR menu step's `ivr.prompt.audio_url` (the menu recording — its announcement
282
+ text is ordinary text and stays editable)
283
+
284
+ Adding a webhook or notification step at all is refused for the same reason: its
285
+ defaults would decide where it posts or whom it mails. Deleting a whole step that
286
+ carries one of these settings is allowed — that only takes the capability away, which
287
+ is why a graph with an existing setting round-trips. A refused write answers `422`
288
+ with code `external_field_closed` and the `paths` it objected to; nothing is written
289
+ and the draft revision does not move. Edit those settings in the Portal.
290
+
291
+ ### Settings that reach callers at once
292
+
293
+ Three settings are not part of the draft, so a write to them needs no publish:
294
+
295
+ - `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`.
296
+ - `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.
297
+
298
+ 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.
299
+
300
+ `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.
301
+
138
302
  ### What the CLI does not cover
139
303
 
140
304
  The CLI is a client of the Partner API (the commands above), so it can only do what
141
305
  that API exposes. These Portal features have no Partner API route yet and are not in
142
- the CLI: conversation-edit mode and its monthly count, per-agent operating hours and the
143
- hand-off to another agent outside them, knowledge-base confirm / bulk delete, filtering
144
- bookings by agent, applying 解決策 to pre-publish findings, the opening-line name toggle,
145
- external-tool rate-limit / circuit-breaker status, and the agent language / English
146
- locale. Flow-level settings that live inside the graph (IVR recording, slot sources,
147
- transfer nodes) travel with `agents get --json` / `agents patch --graph-file` unchanged.
306
+ the CLI: conversation-edit mode and its monthly count, knowledge-base bulk delete,
307
+ making / moving / cancelling a customer's booking record and the notifications that go
308
+ with it, filtering bookings by agent, applying 解決策 to pre-publish findings, external-tool rate-limit /
309
+ circuit-breaker status, the agent language / English locale, a tool's display name (表示名),
310
+ the agent's call-outcome categories (通話の結果), and the call model with its TTS voice (`agents get` shows them, `agents patch` cannot
311
+ change them: it writes only `prompt` and `graph`). Flow-level settings that live inside
312
+ the graph (for example an IVR dial table or what a step asks for) travel with
313
+ `agents get --json` / `agents patch --graph-file`; the external send settings listed under
314
+ `agents patch` above must be sent back unchanged.
315
+
316
+ ### Node configuration reference
317
+
318
+ Each node in `draft.graph.nodes[]` keeps its settings in `config`. This table is
319
+ generated from the Portal's field list by `scripts/node-config-reference.ts`; a test
320
+ fails when the two disagree.
321
+
322
+ <!-- BEGIN node-config-reference: generated by scripts/node-config-reference.ts (npm run docs:node-config); do not edit -->
323
+ `layer` says where the Portal's node inspector shows the key:
324
+
325
+ - `required` — always shown
326
+ - `tune` — 「動きの調整」 card: a one-line summary that opens to edit
327
+ - `advanced` — folded under 「詳細」, or a required item's 「細かい設定」
328
+ - `internal` — no editor in the Portal: set by another surface, or API only
329
+
330
+ A key a node does not store follows the agent's setting (会話の運用) or the tenant's
331
+ (運用設定); the inspector shows it as 「既定」 and a stored one as 「変更あり」.
332
+
333
+ | Key | Node types | Layer | Type | Note |
334
+ | --- | --- | --- | --- | --- |
335
+ | `display_name` | start, agent, end, global, trigger, webhook, qa, ivr, transfer, notify | `internal` | `string` | The name shown on the canvas. Edited by renaming the node. |
336
+ | `leaf_label` | start, agent | `internal` | `string` | Set by the manual compiler. The purpose name the diagnostics quote. |
337
+ | `canvas_flow` | start, agent, end, global, trigger, webhook, qa, ivr, transfer, notify | `internal` | `object` | Canvas layout state. Not a setting. |
338
+ | `flow_expectations` | global | `internal` | `object` | Written by the scenario interview. Not a setting. |
339
+ | `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. |
340
+ | `trigger_path` | trigger | `internal` | `string` | Generated. Shown read-only as the trigger URL. |
341
+ | `opening_speech` | start | `required` | `string` | The opening line. Supports {{variables}}. |
342
+ | `items` | start, agent | `required` | `{key,label?,example?,source?,value_type?,options?,must_ask?,tool?,option_writes?}[]` | 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). `tool`: `{tool_key,result_field}` for a tool-sourced item. `option_writes`: option → tool that must succeed before that option lets the call leave (advanced). |
343
+ | `allow_interruptions` | start, agent | `tune` | `boolean` | Absent means the caller may interrupt. Only an explicit false is stored. |
344
+ | `respond_on_enter` | agent | `tune` | `boolean` | Absent means the node answers on arrival. Only an explicit false (wait for the caller) is stored. |
345
+ | `confirm_before_end` | agent | `tune` | `boolean` | Absent means off (agents published before this setting keep their behaviour); a node created on the canvas stores true, and a node compiled from a SOP or document stores true when its connection to an end node requires items (the `end_without_readback` rule). On: the platform reads the recorded items back once before the call ends, and the end opens on a later caller turn with caller_confirmed. |
346
+ | `entry_lookup` | agent | `tune` | `string` | Absent means no lookup on entry. A tool key from this step's tools (`booking_list`): the platform calls it when the call arrives at this step, and the call and its result are in the step's context before the AI speaks. |
347
+ | `quiet_wait` | start, agent | `tune` | `{ seconds, listen?, resume_speech? }` | Node-level wait. { seconds: 0 } turns the agent default off here. |
348
+ | `optional_slots` | start, agent | `tune` | `string[]` | Slots declared elsewhere that this step may record when the caller volunteers them. |
349
+ | `switch_agent_id` | agent | `tune` | `uuid` | A published agent this step hands the call to. |
350
+ | `opening_audio_url` | start | `tune` | `string` | kumion-asset:// upload (or a legacy allow-listed URL) played instead of TTS for the opening line. |
351
+ | `opening_audio_filename` | start | `internal` | `string` | Display name of the uploaded opening audio. |
352
+ | `precall_fetch_url` | start | `advanced` | `string` | URL fetched before the call starts; the response becomes call variables. |
353
+ | `precall_fetch_method` | start | `advanced` | `string` | HTTP method of the pre-call fetch. |
354
+ | `precall_fetch_headers` | start | `advanced` | `{ key, value }[]` | Headers of the pre-call fetch. |
355
+ | `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. |
356
+ | `kb_fallback` | start, agent | `advanced` | `{ noResult?, unavailable? }` | Wording when a knowledge search finds nothing or is unavailable. Overrides the tenant operations setting. |
357
+ | `end_speech` | end | `required` | `string` | Default goodbye line. A connection into this node can override it. |
358
+ | `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. |
359
+ | `ivr` | ivr | `required` | `object` | Announcement, digit table and wait time. input and max_retries are fixed; other values are rejected. |
360
+ | `transfer` | transfer | `required` | `object` | Transfer target and the line spoken before transferring. |
361
+ | `notify` | notify | `required` | `object` | Recipients, subject and body templates. |
362
+ | `http_method` | webhook | `required` | `string` | GET, POST, PUT, PATCH or DELETE. |
363
+ | `endpoint_url` | webhook | `required` | `string` | Destination URL. |
364
+ | `payload_template` | webhook | `required` | `string` | Request body template with {{variables}}. |
365
+ | `custom_headers` | webhook | `advanced` | `{ key, value }[]` | Extra request headers. |
366
+ | `qa_system_prompt` | qa | `required` | `string` | Evaluation prompt. |
367
+ | `qa_sample_rate` | qa | `required` | `number` | Percentage of calls analysed, 1 to 100. |
368
+ | `qa_min_call_duration` | qa | `required` | `number` | Shortest call (seconds) that is analysed. |
369
+ | `qa_model` | qa | `advanced` | `string` | Model override for this analysis. |
370
+ | `qa_voicemail_calls` | qa | `advanced` | `boolean` | Whether voicemail calls are analysed (default true). |
371
+
372
+ A required item's 種類 is stored as a pair on the item: `source` and `value_type`.
373
+ These are the pairs the Portal offers:
374
+
375
+ | 種類 | `source` | `value_type` |
376
+ | --- | --- | --- |
377
+ | お客様の言葉のまま (`verbatim`) | `caller` | `text` |
378
+ | AIがまとめた内容 (`summary`) | `derived` | `text` |
379
+ | 番号 (`code`) | `caller` | `code` |
380
+ | 電話番号 (`phone`) | `caller` | `phone` |
381
+ | 生年月日 (`birthdate`) | `caller` | `birthdate` |
382
+ | 日時 (`datetime`) | `caller` | `datetime` |
383
+ | 選択肢 (`select`) | `derived` | `select` |
384
+ | ツールの結果 (`tool`) | `tool` | `text` |
385
+ <!-- END node-config-reference -->
386
+
387
+ Two settings have no (or only partial) Portal screen: the agent-level `model_config.wait_cover`
388
+ (hold phrase text and repeats are API only; the delay, `on_threshold`, `on_query_start` and `query_grace_ms` have an agent card
389
+ and a row in a node's 「動きの調整」), and an IVR node's `ivr.input` and `ivr.max_retries` are fixed
390
+ (`{ "mode": "single", "max_digits": 1, "finish_key": null }` and `0`): any other value
391
+ makes the patch fail.
148
392
 
149
393
  ### Testing and publishing
150
394
 
@@ -156,15 +400,208 @@ kumion agents publish <agentId> # runs the pre-publish check, then publishe
156
400
  `test-runs start` checks the draft without publishing anything. `agents publish` runs
157
401
  the Portal's pre-publish check and publishes only when it passes; when it does not, the
158
402
  failing cases are printed and nothing goes live. The CLI has no way to skip or override
159
- the check.
403
+ the check. When a check before the test calls refuses (most often the dependency check:
404
+ コンタクト or the booking calendar not connected, a tool not enabled), there are no
405
+ cases to print: the server's message after `Server said:` is the whole reason, one
406
+ problem per line.
407
+
408
+ ## From a template to public
409
+
410
+ One path from an empty tenant to a published agent, with nothing but the CLI (each command is also
411
+ an [MCP tool](#use-it-from-an-ai-coding-assistant-mcp)). The key needs `agents:read`,
412
+ `agents:write`, `agents:live` and, for the last step, `agents:publish`.
413
+
414
+ Every write takes the `revision` the step before it printed. Never carry one over from an earlier
415
+ run: a `409` means something moved in between, and the fix is to read again — not to retry with the
416
+ old number. `--json` is on every command below so a script can read the values back.
417
+
418
+ Names used below: `A` is the agent id, `D` the 資料 the agent was created with, `S` the 資料 you
419
+ uploaded.
420
+
421
+ ### 1. Create the agent from a template
422
+
423
+ ```sh
424
+ kumion templates list
425
+ kumion agents create-from-template --template <templateId> --business-name "山田歯科" \
426
+ --idempotency-key create-1 --json
427
+ ```
428
+
429
+ Keep `A` (`agent.id`), its `workflow.id` and `document.id` (`D`). Nothing is published and no fact
430
+ is confirmed; with no source, every fact is 「まだない情報」. A resend with the same
431
+ `--idempotency-key` answers the first agent instead of creating a second. The draft's `revision` is
432
+ not in this answer — it comes from `agents get` / `flow get` when you first write.
433
+
434
+ ### 2. Upload the real 資料
435
+
436
+ ```sh
437
+ kumion documents upload --text-file ./料金表.txt --template <templateId> \
438
+ --title "料金表" --idempotency-key upload-1 --dry-run --json
439
+ # read the size, the model and the allowance left, then send it for real
440
+ kumion documents upload --text-file ./料金表.txt --template <templateId> \
441
+ --title "料金表" --idempotency-key upload-1 --json
442
+ ```
443
+
444
+ `--text-file` sends the text of one file; `--file` (repeatable) sends `.txt`, `.md`, `.pdf`, `.docx`
445
+ or `.xlsx` — up to 10 files and 20 MiB — and the server parses them; several files become one 資料, in
446
+ the order given. Use one or the other, not both.
447
+
448
+ Uploads are counted, not billed: **10 extractions per key per rolling hour**, and never more than the
449
+ tenant's own `document_writes_per_hour` (20 by default); **one upload in flight per key**, two per
450
+ tenant. Any of those is a `429` with `Retry-After`. `--dry-run` runs the same checks and reports
451
+ `bytes`, `chars`, the model and what is left, **without writing a job, spending an allowance or
452
+ calling a model** — the numbers it shows are a reading at one instant, and the real upload checks them
453
+ again. The accept answers at once (`202`) with a job id; the extraction runs after it, so no command
454
+ waits for the model.
455
+
456
+ ### 3. Wait for the extraction
457
+
458
+ ```sh
459
+ kumion documents jobs get <jobId> --json
460
+ kumion documents get <S> --json
461
+ ```
462
+
463
+ Only `succeeded` gives you a document. `failed` and `timed_out` print `error.code` and exit non-zero,
464
+ so a script branches on the exit code rather than parsing the text. A `timed_out` job is **not retried
465
+ on its own**: the platform replays nothing after the 120-second deadline, and sending the same
466
+ `--idempotency-key` again answers the same job — a new attempt needs a new key. `documents get` then
467
+ answers the fields, their candidates, their review state and the `revision` the next step takes. It
468
+ does not return the text.
469
+
470
+ ### 4. Give the agent the uploaded 資料
471
+
472
+ ```sh
473
+ kumion documents replace <D> --source <S> --source-revision <S revision> \
474
+ --revision <D revision> --dry-run --json
475
+ kumion documents replace <D> --source <S> --source-revision <S revision> \
476
+ --revision <D revision> --json
477
+ ```
478
+
479
+ `D` keeps its id, so everything already pointing at it — the agent, its flow — keeps pointing at it.
480
+ No model is called: the source is already extracted, so this is a move, not an extraction. Every fact
481
+ comes back **pending**, and an item the new 資料 does not mention stays as an empty row. The dry run
482
+ lists what is added, kept empty and removed, and `resetConfirmedCount` says how many confirmations it
483
+ would cancel.
484
+
485
+ ### 5. Review and confirm the facts
486
+
487
+ ```sh
488
+ kumion facts list <A> --json
489
+ kumion facts edit <A> <factId> --revision <fact revision> --value "¥3,300(税込)"
490
+ kumion facts confirm <A> --fact <factId>
491
+ ```
492
+
493
+ An unconfirmed fact is not an answer the agent may read out. `facts confirm` without `--fact`
494
+ confirms every pending fact whose candidates agree and skips the ones that disagree — read those and
495
+ edit them. Reviewing is a step of this path, not a formality: a publish with facts nobody confirmed
496
+ still counts them as unconfirmed.
497
+
498
+ ### 6. Shop hours (営業時間)
499
+
500
+ ```sh
501
+ kumion hours get --json
502
+ kumion hours update --revision <calendar revision> --business-hours-file hours.json --json
503
+ kumion hours exception set <date> --revision <revision> --kind closed --json
504
+ ```
505
+
506
+ `hours.json` is the weekly table itself (`{ "mon": [{ "start": "09:00", "end": "18:00" }], … }`), not
507
+ an object wrapping it in `businessHours`. It replaces the whole week, so a file holding Mon–Fri makes
508
+ Sat and Sun closed. Regular closing days go in their own `--closed-rules-file`; an omitted file is
509
+ left alone. `--kind` is `closed` (臨時休業),
510
+ `open` (振替出勤, with `--hours-file` or the weekday's hours) or `inherit` (delete that day's row and
511
+ go back to the weekly rule). The revision is the one `hours get` printed: 営業時間, 例外日, 内容,
512
+ 担当 and the mount are one calendar with one counter.
513
+
514
+ ### 7. Booking (予約設定)
515
+
516
+ ```sh
517
+ kumion booking get <A> --json
518
+ kumion booking services create --revision <revision> --data-file service.json --json
519
+ kumion booking resources create --revision <revision> --data-file resource.json --json
520
+ kumion booking calendar update --revision <revision> --patch-file calendar.json --json
521
+ kumion booking mount <A> --mounted true --revision <revision> --json
522
+ kumion booking slots <A> --resource <resourceId> --service <serviceId> --date 2026-11-02 --json
523
+ ```
524
+
525
+ `service.json` is `{ "name": "初診", "durationMinutes": 30 }`; `resource.json` is
526
+ `{ "name": "山田", "weeklyHours": { "mon": [{ "start": "09:00", "end": "12:00" }] }, "serviceIds": [] }`
527
+ (`[]` takes every 内容); `calendar.json` holds `defaultSlotMinutes`, `minLeadMinutes` and/or
528
+ `maxAdvanceDays`. A 内容 with no duration uses the slot length.
529
+
530
+ A template's agent starts **not mounted** and with no 担当, so both are needed before it can book
531
+ anything. Mount only after a 担当 exists: read `booking get` back and expect `mounted: true` and
532
+ `bookableResourceCount` above zero. `booking slots` then answers the openings a call would offer —
533
+ computed from the same clock, 内容 lengths and existing bookings — and reserves nothing; an empty list
534
+ on an open day usually means no 担当 is enabled for that 内容.
535
+
536
+ ### 8. 記録項目 (what is recorded after a call)
537
+
538
+ ```sh
539
+ kumion capture-specs list --json
540
+ kumion agents capture get <A> --json
541
+ kumion agents capture set <A> --revision <revision> --spec <specId> --json
542
+ ```
543
+
544
+ A template ships with its 受付サマリー already mounted, so this step is often a read: `agents capture
545
+ get` answers the mounted specs, the agent's `revision` and `readiness`. Expect `readiness.ready: true`;
546
+ `false` means a call on this agent records nothing, whatever the shop's other agents do. To use your
547
+ own, `capture-specs create --data-file spec.json` (mounted on nothing yet, so no call changes) and
548
+ mount it with `agents capture set` — the whole set is replaced, `--spec` repeats, `--clear` records
549
+ nothing.
550
+
551
+ ### 9. Fix the flow (用件 and what each asks)
552
+
553
+ ```sh
554
+ kumion flow get <A> --json
555
+ kumion flow update <A> --revision <revision> --patch-file change.json --dry-run --json
556
+ kumion flow update <A> --revision <revision> --patch-file change.json --json
557
+ ```
558
+
559
+ A new 資料 does not recompile the flow: the 用件 and what each asks for stay as the template built
560
+ them, and a new call_intent the extraction found is not added by itself. `flow get`'s `editLayer` says
561
+ whether `flow update` or `flow edit-steps` is the write. Before publishing, `findings.canvas` must hold
562
+ no entry with `severity: "error"` and `findings.structural` must be empty.
563
+
564
+ ### 10. Publish
565
+
566
+ ```sh
567
+ kumion agents get <A> --json
568
+ kumion agents publish <A> --revision <revision> --json
569
+ kumion agents get <A> --json
570
+ ```
571
+
572
+ Publish runs the Portal's pre-publish check (a few minutes) and answers `publishRunId`,
573
+ `publishedSnapshotId` and `unconfirmedFacts`; read the agent back for `publishState.live: true` and
574
+ `unpublishedChanges: false`. `unconfirmedFacts` counts the facts nobody confirmed — a clean publish
575
+ that still lists them is not a finished agent, so go back to step 5.
576
+
577
+ Two things are closed here on purpose:
578
+
579
+ - **External send settings.** A webhook's endpoint, a pre-call fetch, a notification, a transfer target,
580
+ the opening recording and an IVR menu's recording cannot be added or changed through `agents patch` (or
581
+ `flow`): the write is
582
+ refused with `422` and code `external_field_closed`, `paths` naming what it objected to, and nothing
583
+ is saved. Send them back unchanged and edit them in the Portal. The same list is under
584
+ [Editing a draft](#editing-a-draft).
585
+ - **Booking records** (making, moving or cancelling a customer's booking) and notifications are not
586
+ Partner API operations. `booking slots` reads openings; nothing here writes a booking.
160
587
 
161
588
  ## Use it from an AI coding assistant (MCP)
162
589
 
163
590
  `kumion mcp` serves the same operations as MCP tools over stdio, for Claude Code,
164
- Codex or any other MCP host: `list_agents`, `get_agent`, `patch_agent`,
165
- `publish_agent`, `start_test_run`, `get_test_run`, `list_test_runs`, `create_call`,
166
- `list_calls`, `get_call`, `get_call_transcript`.
167
- Each needs the same scope as its command above.
591
+ Codex or any other MCP host, one tool per command above: `list_agents`, `get_agent`,
592
+ `patch_agent`, `publish_agent`, `get_call_flow`, `update_call_flow`,
593
+ `edit_call_flow_steps`, `set_agent_opening_name`, `set_agent_availability`,
594
+ `create_agent_from_template`, `list_agent_templates`, `list_facts`, `edit_fact`,
595
+ `confirm_facts`, `list_staff`, `create_staff`, `update_staff`, `get_store_hours`,
596
+ `update_store_hours`, `set_store_hours_exception`, `get_booking_settings`,
597
+ `update_booking_calendar`, `create_booking_service`, `update_booking_service`,
598
+ `create_booking_resource`, `update_booking_resource`, `set_agent_booking`,
599
+ `list_booking_slots`, `list_capture_specs`, `create_capture_spec`,
600
+ `update_capture_spec`, `get_agent_capture`, `set_agent_capture`, `upload_document`,
601
+ `get_document_upload_job`, `get_document`, `replace_document`, `start_test_run`,
602
+ `get_test_run`, `list_test_runs`, `create_call`, `list_calls`, `get_call`,
603
+ `get_call_transcript`. Each takes the same input as the API route and needs the same
604
+ scope as its command.
168
605
 
169
606
  The server reads the key the same way every command does — the OS keychain profile,
170
607
  or `KUMION_API_KEY` / `KUMION_TENANT_ID` from its own environment — when it starts.