@kumion/cli 0.4.0 → 0.6.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
@@ -104,8 +104,9 @@ would use.
104
104
  | --- | --- |
105
105
  | `kumion agents list` | `agents:read` |
106
106
  | `kumion agents get <agentId> [--json]` | `agents:read` |
107
+ | `kumion agents spec <agentId> [--version published\|draft\|<n>] [--format pdf\|docx\|markdown] [--out <path>]` | `agents:read` (the 応対仕様書 as a file: PDF by default, Word and Markdown too; `--out`, or a file in the current directory for PDF/Word) |
107
108
  | `kumion agents patch <agentId> --revision <rev> [--prompt <text> \| --prompt-file <path>] [--graph-file <path>]` | `agents:write` |
108
- | `kumion agents publish <agentId> [--revision <rev>]` | `agents:publish` |
109
+ | `kumion agents publish <agentId> [--revision <rev>] [--accept-intermittent]` | `agents:publish` |
109
110
  | `kumion agents opening-name <agentId> --revision <rev> (--on \| --off)` | `agents:write` (a draft write: live after the next publish) |
110
111
  | `kumion agents availability <agentId> --revision <rev> [--operating-hours-file <path>] [--off-hours-file <path>]` | `agents:live` (live: no publish) |
111
112
  | `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) |
@@ -144,10 +145,23 @@ would use.
144
145
  | `kumion test-runs list <agentId>` | `tests:run` |
145
146
  | `kumion calls create <agentId> [--to <phone>] [--campaign-contact <id>] [--var <name>=<value> ...]` | `calls:create` |
146
147
  | `kumion calls list [--agent <id>] [--channel webcall\|sip_did\|trigger] [--from <iso>] [--to <iso>] [--search <text>] [--limit <n>] [--offset <n>]` | `calls:read` |
148
+ | `kumion scheduled-calls create <agentId> --to <phone> --at <iso8601-with-offset> [--var <name>=<value> ...]` | `calls:create` |
149
+ | `kumion scheduled-calls list` | `calls:read` |
150
+ | `kumion scheduled-calls cancel <id>` | `calls:create` |
147
151
  | `kumion calls get <callId>` | `calls:read` |
148
152
  | `kumion calls transcript <callId>` | `calls:read` |
149
153
 
150
154
  A command whose key lacks the scope fails with a message naming the scope it needs.
155
+
156
+ `scheduled-calls create` takes `--var <name>=<value>` (repeatable; MCP `variables`) like `calls create`; see
157
+ "Per-call variables". The values are stored with the schedule and handed to the call when it is placed.
158
+ It places one dial at the time you give: `--at` must carry a timezone offset
159
+ (`2026-10-31T13:00:00+09:00`; a bare `13:00` is refused), be in the future, and the number a domestic one.
160
+ The dial happens once, with no automatic redial. It is refused with 403 when the tenant's automatic
161
+ outbound dialing is off or the plan is `free`, and with 409 when that number already has a scheduled or
162
+ running dial. `scheduled-calls list` shows the API-scheduled dials, newest first (at most 100), each with a
163
+ `state` (`scheduled`, `dialing`, `done`, ...) and a `reason`. `scheduled-calls cancel` works only before the
164
+ dial starts; after that it answers 404.
151
165
  `calls:read` is its own scope: a key that can start calls (`calls:create`) cannot read
152
166
  them. `calls list` returns one page (20 by default, at most 100) and prints the
153
167
  `--offset` of the next one. Every call in `calls list` and `calls get` carries what it came to: `outcome`
@@ -189,7 +203,7 @@ all: a template's agent starts unmounted, and mounting also retires the 「仮
189
203
 
190
204
  `capture-specs` is 記録項目, what the agent records after a call. A spec is the tenant's and the mount
191
205
  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
206
+ `capture-specs update <specId> --revision` changes it for every agent already mounted, and
193
207
  `agents capture get|set <agentId>` reads and replaces the set one agent records (`--spec` repeats,
194
208
  `--clear` records nothing). `agents capture get` also answers `readiness` — whether THIS agent would
195
209
  record anything after a call; a shop whose other agent records is not evidence for this one.
@@ -208,6 +222,14 @@ body: an object of strings, at most 50 names, 1000 characters per value, 10000 i
208
222
  larger or non-string value is a 400 naming the item). With `--campaign-contact`, the list row's
209
223
  columns are the base and `--var` wins. A name that is not passed reads as an empty string.
210
224
 
225
+ The flag splits at the first `=` (`--var url=https://x.test/?a=b` keeps the second one in the value;
226
+ `--var tag=` is an empty value). `--var foo` and `--var =x` are refused before anything is sent.
227
+ A name takes letters, digits and `_` only. Passing the same name twice keeps the last one. With no `--var`
228
+ the request carries no `variables`. A variable the agent's published version marks 必須 must be given a
229
+ value: otherwise the call is not placed (`calls create`) or not scheduled (`scheduled-calls create`), with
230
+ `400 missing_variables` and the names in `missing`. `scheduled-calls create` takes `--var` the same way and
231
+ checks the same rules at the time you schedule, not when the dial happens.
232
+
211
233
  ### Dialing a phone
212
234
 
213
235
  `calls create <agentId> --to 08012345678` places a real call from the phone number assigned to
@@ -339,10 +361,11 @@ A key a node does not store follows the agent's setting (会話の運用) or the
339
361
  | `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
362
  | `trigger_path` | trigger | `internal` | `string` | Generated. Shown read-only as the trigger URL. |
341
363
  | `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). |
364
+ | `items` | start, agent | `required` | `{key,label?,example?,source?,value_type?,options?,must_ask?,min_digits?,max_digits?,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). `min_digits` / `max_digits`: for a `code` item, the fewest / most digits the value may hold, counted by the platform (the same number twice = exact length). `tool`: `{tool_key,result_field}` for a tool-sourced item. `option_writes`: option → tool that must succeed before that option lets the call leave (advanced). |
343
365
  | `allow_interruptions` | start, agent | `tune` | `boolean` | Absent means the caller may interrupt. Only an explicit false is stored. |
344
366
  | `respond_on_enter` | agent | `tune` | `boolean` | Absent means the node answers on arrival. Only an explicit false (wait for the caller) is stored. |
345
367
  | `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. |
368
+ | `confirm_before_end_keys` | agent | `internal` | `string[]` | Set by the compiler on a 伝言 step. With `confirm_before_end` on, the end readback reads only these item keys (the call-back number); absent means every item the ending requires. |
346
369
  | `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
370
  | `quiet_wait` | start, agent | `tune` | `{ seconds, listen?, resume_speech? }` | Node-level wait. { seconds: 0 } turns the agent default off here. |
348
371
  | `optional_slots` | start, agent | `tune` | `string[]` | Slots declared elsewhere that this step may record when the caller volunteers them. |
@@ -400,7 +423,11 @@ kumion agents publish <agentId> # runs the pre-publish check, then publishe
400
423
  `test-runs start` checks the draft without publishing anything. `agents publish` runs
401
424
  the Portal's pre-publish check and publishes only when it passes; when it does not, the
402
425
  failing cases are printed and nothing goes live. The CLI has no way to skip or override
403
- the check. When a check before the test calls refuses (most often the dependency check:
426
+ the check, with one exception: a case that failed only in some of its re-runs is marked
427
+ `[intermittent]` (one that failed again is `[reproduced]`), and when nothing else is wrong the refusal
428
+ says so and `agents publish <agentId> --accept-intermittent` (MCP: `acceptIntermittent`) publishes it
429
+ anyway. It never applies to a check that failed every time. `test-runs get` marks the same cases and lists
430
+ each re-run's outcome. When a check before the test calls refuses (most often the dependency check:
404
431
  コンタクト or the booking calendar not connected, a tool not enabled), there are no
405
432
  cases to print: the server's message after `Server said:` is the whole reason, one
406
433
  problem per line.
@@ -570,7 +597,7 @@ kumion agents get <A> --json
570
597
  ```
571
598
 
572
599
  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
600
+ `agent.publishedSnapshotId` and `unconfirmedFacts`; read the agent back for `publishState.live: true` and
574
601
  `unpublishedChanges: false`. `unconfirmedFacts` counts the facts nobody confirmed — a clean publish
575
602
  that still lists them is not a finished agent, so go back to step 5.
576
603
 
@@ -596,10 +623,10 @@ Codex or any other MCP host, one tool per command above: `list_agents`, `get_age
596
623
  `update_store_hours`, `set_store_hours_exception`, `get_booking_settings`,
597
624
  `update_booking_calendar`, `create_booking_service`, `update_booking_service`,
598
625
  `create_booking_resource`, `update_booking_resource`, `set_agent_booking`,
599
- `list_booking_slots`, `list_capture_specs`, `create_capture_spec`,
626
+ `list_booking_slots`, `get_agent_spec`, `list_capture_specs`, `create_capture_spec`,
600
627
  `update_capture_spec`, `get_agent_capture`, `set_agent_capture`, `upload_document`,
601
628
  `get_document_upload_job`, `get_document`, `replace_document`, `start_test_run`,
602
- `get_test_run`, `list_test_runs`, `create_call`, `list_calls`, `get_call`,
629
+ `get_test_run`, `list_test_runs`, `create_scheduled_call`, `list_scheduled_calls`, `cancel_scheduled_call`, `create_call`, `list_calls`, `get_call`,
603
630
  `get_call_transcript`. Each takes the same input as the API route and needs the same
604
631
  scope as its command.
605
632
 
package/dist/client.js CHANGED
@@ -25,6 +25,29 @@ export class NetworkError extends Error {
25
25
  }
26
26
  }
27
27
  const DOCUMENT_UPLOAD_FILES_PART = "files";
28
+ export function specText(file) {
29
+ const type = file.contentType ?? "";
30
+ if (!type.startsWith("text/"))
31
+ throw new Error(`this 仕様書 is a ${type || "binary"} file, not text`);
32
+ return new TextDecoder("utf-8").decode(file.body);
33
+ }
34
+ export function isTextFile(file) {
35
+ return (file.contentType ?? "").startsWith("text/");
36
+ }
37
+ function filenameOf(header) {
38
+ if (!header)
39
+ return null;
40
+ const extended = /filename\*=UTF-8''([^;]+)/i.exec(header);
41
+ if (extended?.[1]) {
42
+ try {
43
+ return decodeURIComponent(extended[1].trim());
44
+ }
45
+ catch {
46
+ }
47
+ }
48
+ const plain = /filename="([^"]*)"/i.exec(header) ?? /filename=([^;]+)/i.exec(header);
49
+ return plain?.[1]?.trim() ?? null;
50
+ }
28
51
  export class KumionClient {
29
52
  creds;
30
53
  fetchImpl;
@@ -91,6 +114,48 @@ export class KumionClient {
91
114
  const { body } = await this.request("GET", this.agentPath(agentId), "agents:read");
92
115
  return body;
93
116
  }
117
+ async getAgentSpec(agentId, options = {}) {
118
+ const query = new URLSearchParams();
119
+ if (options.version !== undefined)
120
+ query.set("version", options.version);
121
+ if (options.format !== undefined)
122
+ query.set("format", options.format);
123
+ const suffix = query.size > 0 ? `?${query.toString()}` : "";
124
+ return this.requestFile(this.agentPath(agentId, `/spec${suffix}`), "agents:read");
125
+ }
126
+ async requestFile(path, scope) {
127
+ const url = this.creds.baseUrl + path;
128
+ let res;
129
+ try {
130
+ res = await this.fetchImpl(url, {
131
+ method: "GET",
132
+ headers: { Authorization: `Bearer ${this.creds.apiKey}`, Accept: "*/*" },
133
+ });
134
+ }
135
+ catch (err) {
136
+ throw new NetworkError(url, err);
137
+ }
138
+ const bytes = new Uint8Array(await res.arrayBuffer());
139
+ if (res.status < 200 || res.status >= 300) {
140
+ let body = {};
141
+ const text = new TextDecoder("utf-8").decode(bytes);
142
+ if (text) {
143
+ try {
144
+ const parsed = JSON.parse(text);
145
+ body = parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : {};
146
+ }
147
+ catch {
148
+ body = { error: `Unexpected non-JSON response: ${text.slice(0, 200)}` };
149
+ }
150
+ }
151
+ throw new ApiError(res.status, body, scope, res.headers.get("retry-after"));
152
+ }
153
+ return {
154
+ body: bytes,
155
+ contentType: res.headers.get("content-type"),
156
+ filename: filenameOf(res.headers.get("content-disposition")),
157
+ };
158
+ }
94
159
  async listAgentTemplates() {
95
160
  const { body } = await this.request("GET", this.tenantPath("/agent-templates"), "agents:read");
96
161
  return body.templates;
@@ -171,9 +236,9 @@ export class KumionClient {
171
236
  });
172
237
  return body;
173
238
  }
174
- async publishAgent(agentId, revision) {
239
+ async publishAgent(agentId, revision, options = {}) {
175
240
  const { body } = await this.request("POST", this.agentPath(agentId, "/publish"), "agents:publish", {
176
- body: {},
241
+ body: options.acceptIntermittent ? { acceptIntermittent: true } : {},
177
242
  ifMatch: revision,
178
243
  });
179
244
  return body;
@@ -212,6 +277,33 @@ export class KumionClient {
212
277
  const { body } = await this.request("GET", this.tenantPath(`/calls${qs ? `?${qs}` : ""}`), "calls:read");
213
278
  return body;
214
279
  }
280
+ async createScheduledCall(agentId, phoneNumber, scheduledAt, variables) {
281
+ try {
282
+ const { body } = await this.request("POST", this.tenantPath("/scheduled-calls"), "calls:create", {
283
+ body: {
284
+ agentId,
285
+ phoneNumber,
286
+ scheduledAt,
287
+ ...(variables && Object.keys(variables).length > 0 ? { variables } : {}),
288
+ },
289
+ });
290
+ return body;
291
+ }
292
+ catch (err) {
293
+ if (err instanceof ApiError && err.status === 403 && !String(err.body.error ?? "").includes(err.scope)) {
294
+ throw new ApiError(403, { ...err.body, code: "scheduled_dialing_unavailable" }, err.scope, err.retryAfter);
295
+ }
296
+ throw err;
297
+ }
298
+ }
299
+ async listScheduledCalls() {
300
+ const { body } = await this.request("GET", this.tenantPath("/scheduled-calls"), "calls:read");
301
+ return body.scheduledCalls;
302
+ }
303
+ async cancelScheduledCall(scheduledCallId) {
304
+ const { body } = await this.request("DELETE", this.tenantPath(`/scheduled-calls/${encodeURIComponent(scheduledCallId)}`), "calls:create");
305
+ return body;
306
+ }
215
307
  async getCall(callId) {
216
308
  const { body } = await this.request("GET", this.tenantPath(`/calls/${encodeURIComponent(callId)}`), "calls:read");
217
309
  return body.call;
package/dist/errors.js CHANGED
@@ -23,6 +23,11 @@ export function describeApiError(err) {
23
23
  if (err.code === "plan_publish_required") {
24
24
  return `This tenant's plan cannot publish agents (403). Upgrade the plan in the Kumion Portal; no key change helps.${serverSaid(err)}`;
25
25
  }
26
+ if (err.code === "scheduled_dialing_unavailable") {
27
+ return ("This tenant cannot schedule calls (403): automatic outbound dialing is off for it, or its plan is free. " +
28
+ "Nothing was scheduled. Turn automatic dialing on in the Kumion Portal (設定), or dial now with `kumion calls create`." +
29
+ serverSaid(err));
30
+ }
26
31
  if (err.scope === "calls:create") {
27
32
  return ("The call was refused (403): the tenant has reached its call-minute limit (the trial minutes cap for an " +
28
33
  "unsigned tenant, or the monthly cap), or its plan cannot start calls. Check 設定 in the Kumion Portal." +
@@ -30,7 +35,32 @@ export function describeApiError(err) {
30
35
  }
31
36
  return `Access refused (403).${serverSaid(err)}`;
32
37
  }
38
+ case 400:
39
+ if (err.code === "no_versions") {
40
+ return ("This agent has no versions (400 no_versions): it answers from a prompt alone, with no canvas to publish, so " +
41
+ `there is no version number to name. Leave --version out.${serverSaid(err)}`);
42
+ }
43
+ if (err.code === "unsupported_format") {
44
+ return `That --format is not one this server produces (400 unsupported_format).${serverSaid(err)}`;
45
+ }
46
+ if (err.code === "invalid_version") {
47
+ return `--version takes published, draft, or a version number (400 invalid_version).${serverSaid(err)}`;
48
+ }
49
+ if (err.code === "missing_variables") {
50
+ const missing = Array.isArray(err.body.missing) ? err.body.missing.map(String).join(", ") : "";
51
+ return (`The call was not placed (400 missing_variables): the agent's published version has 必須 call variables that were ` +
52
+ `left empty${missing ? ` (${missing})` : ""}. Nothing was dialed or scheduled. Pass each one as ` +
53
+ `\`--var <name>=<value>\`.${serverSaid(err)}`);
54
+ }
55
+ return `Request failed (400).${serverSaid(err)}`;
33
56
  case 404:
57
+ if (err.code === "not_published") {
58
+ return ("This agent has never been published (404 not_published), so there is no 公開中 version to export. Pass " +
59
+ `--version draft to export the draft instead.${serverSaid(err)}`);
60
+ }
61
+ if (err.code === "version_not_found") {
62
+ return `There is no such version of this agent (404 version_not_found). See the versions in \`kumion agents get <agentId>\`.${serverSaid(err)}`;
63
+ }
34
64
  return `Not found (404) — check the id, and that it belongs to this tenant.${serverSaid(err)}`;
35
65
  case 409:
36
66
  if (err.code === "draft_revision_conflict") {
@@ -39,6 +69,11 @@ export function describeApiError(err) {
39
69
  "change on top of it, and try again." +
40
70
  serverSaid(err));
41
71
  }
72
+ if (err.code === "agent_name_taken") {
73
+ return ("Another agent in this tenant already has that name (409 agent_name_taken). Nothing was created or renamed. " +
74
+ "Pick a different name and try again." +
75
+ serverSaid(err));
76
+ }
42
77
  if (err.code === "fact_revision_conflict") {
43
78
  return ("That fact changed since you read it (409): someone confirmed or edited it in the Portal or from another " +
44
79
  "client. Nothing was written. Run `kumion facts list <agentId>` for its new revision and try again." +
package/dist/main.js CHANGED
@@ -1,11 +1,11 @@
1
- import { readFile } from "node:fs/promises";
2
- import { basename } from "node:path";
1
+ import { readFile, writeFile } from "node:fs/promises";
2
+ import { basename, join } from "node:path";
3
3
  import { parseArgs } from "node:util";
4
- import { ApiError, KumionClient, } from "./client.js";
4
+ import { ApiError, KumionClient, isTextFile, specText, } from "./client.js";
5
5
  import { DEFAULT_BASE_URL, keyPrefix, looksLikeApiKey, normalizeBaseUrl, resolveCredentials, } from "./credentials.js";
6
6
  import { DEFAULT_DEVICE_SCOPES, deviceLogin } from "./device-login.js";
7
7
  import { describeError, ReportedFailure, UsageError } from "./errors.js";
8
- export const VERSION = "0.4.0";
8
+ export const VERSION = "0.6.0";
9
9
  const HELP = `kumion — manage your Kumion voice agents over the Partner API
10
10
 
11
11
  Usage: kumion <command> [options]
@@ -25,9 +25,16 @@ Auth
25
25
  Agents
26
26
  agents list List the tenant's agents
27
27
  agents get <agentId> Show an agent's draft and published version
28
+ agents spec <agentId> [--version published|draft|<n>] [--format pdf|docx|markdown] [--out <path>]
29
+ Download the 応対仕様書 (the agent's settings as a document) for
30
+ a version: 公開中 by default, or the draft / a version number.
31
+ PDF by default; Word (docx) and Markdown too. Writes to --out;
32
+ Markdown without --out goes to stdout, and PDF/Word without --out
33
+ to the file the server names, in the current directory. The
34
+ 出力日時 on the cover is the moment of the export
28
35
  agents patch <agentId> --revision <rev> [--prompt <text> | --prompt-file <path>] [--graph-file <path>]
29
36
  Edit the draft (never goes live by itself)
30
- agents publish <agentId> [--revision <rev>]
37
+ agents publish <agentId> [--revision <rev>] [--accept-intermittent]
31
38
  Publish the draft through the pre-publish check
32
39
  agents opening-name <agentId> --revision <rev> (--on | --off)
33
40
  Whether the opening line uses the caller's name (a draft write:
@@ -128,7 +135,8 @@ Booking (予約設定 — one calendar for the tenant, read per agent)
128
135
  computes them (6 by default, at most 20). Reads only —
129
136
  nothing is reserved (needs agents:read)
130
137
 
131
- Facts (the agent's 資料) facts list <agentId> List the facts with their state and revision
138
+ Facts (the agent's 資料)
139
+ facts list <agentId> List the facts with their state and revision
132
140
  facts edit <agentId> <factId> --revision <rev> --value <text>
133
141
  Confirm one fact with a new value. LIVE (needs agents:live)
134
142
  facts confirm <agentId> [--fact <factId> ...]
@@ -188,6 +196,10 @@ Calls
188
196
  calls list [--agent <id>] [--channel webcall|sip_did|trigger] [--from <iso>] [--to <iso>]
189
197
  [--search <text>] [--limit <n>] [--offset <n>]
190
198
  List the tenant's call history, newest first (20 per page)
199
+ scheduled-calls create <agentId> --to <phone> --at <iso8601-with-offset> [--var <name>=<value> ...]
200
+ Schedule one dial at that time (e.g. 2026-10-31T13:00:00+09:00)
201
+ scheduled-calls list List the dials scheduled through the API, newest first
202
+ scheduled-calls cancel <id> Cancel a scheduled dial that has not started
191
203
  calls get <callId> Show one call: source, numbers, times, how it ended
192
204
  calls transcript <callId> Print what the caller and the agent said
193
205
  (list/get/transcript need a key with calls:read)
@@ -313,6 +325,7 @@ export const COMMANDS = {
313
325
  "auth logout": authLogout,
314
326
  "agents list": agentsList,
315
327
  "agents get": agentsGet,
328
+ "agents spec": agentsSpec,
316
329
  "agents patch": agentsPatch,
317
330
  "agents publish": agentsPublish,
318
331
  "agents opening-name": agentsOpeningName,
@@ -351,6 +364,9 @@ export const COMMANDS = {
351
364
  "test-runs start": testRunsStart,
352
365
  "test-runs get": testRunsGet,
353
366
  "test-runs list": testRunsList,
367
+ "scheduled-calls create": scheduledCallsCreate,
368
+ "scheduled-calls list": scheduledCallsList,
369
+ "scheduled-calls cancel": scheduledCallsCancel,
354
370
  "calls create": callsCreate,
355
371
  "calls list": callsList,
356
372
  "calls get": callsGet,
@@ -556,6 +572,50 @@ async function agentsGet(args, deps) {
556
572
  ].join("\n"));
557
573
  return 0;
558
574
  }
575
+ async function agentsSpec(args, deps) {
576
+ const { values, positionals } = parse(args, {
577
+ version: { type: "string" },
578
+ format: { type: "string" },
579
+ out: { type: "string" },
580
+ });
581
+ const agentId = need(positionals, 0, "agentId");
582
+ const version = values.version;
583
+ if (version !== undefined && version !== "published" && version !== "draft" && !/^[1-9]\d*$/.test(version)) {
584
+ throw new UsageError("--version takes published (公開中), draft (下書き), or a version number (1, 2, …).");
585
+ }
586
+ const file = await (await clientFor(values, deps)).getAgentSpec(agentId, {
587
+ ...(version === undefined ? {} : { version }),
588
+ ...(values.format === undefined ? {} : { format: values.format }),
589
+ });
590
+ const text = isTextFile(file);
591
+ const bytes = file.body.byteLength;
592
+ const target = values.out ?? (text ? null : file.filename ?? defaultSpecName(agentId, file.contentType));
593
+ if (target === null) {
594
+ if (values.json) {
595
+ printJson(deps, { filename: file.filename, contentType: file.contentType, markdown: specText(file) });
596
+ return 0;
597
+ }
598
+ deps.io.out(specText(file).replace(/\n$/, ""));
599
+ return 0;
600
+ }
601
+ const path = values.out ? values.out : join((deps.cwd ?? process.cwd)(), target);
602
+ try {
603
+ await writeFile(path, file.body);
604
+ }
605
+ catch (err) {
606
+ throw new UsageError(`Cannot write ${path}: ${err.message}`);
607
+ }
608
+ if (values.json) {
609
+ printJson(deps, { path, filename: file.filename, contentType: file.contentType, bytes });
610
+ return 0;
611
+ }
612
+ deps.io.out(`Wrote ${path} (${file.filename ?? "仕様書"}, ${bytes} bytes)`);
613
+ return 0;
614
+ }
615
+ function defaultSpecName(agentId, contentType) {
616
+ const extension = contentType === "application/pdf" ? "pdf" : contentType?.includes("wordprocessingml") ? "docx" : "bin";
617
+ return `仕様書_${agentId}.${extension}`;
618
+ }
559
619
  async function agentsPatch(args, deps) {
560
620
  const { values, positionals } = parse(args, {
561
621
  revision: { type: "string" },
@@ -1502,16 +1562,19 @@ async function factsConfirm(args, deps) {
1502
1562
  }
1503
1563
  return 0;
1504
1564
  }
1565
+ function gateTag(gate) {
1566
+ return gate ? ` [${gate}]` : "";
1567
+ }
1505
1568
  function formatFindings(findings, indent) {
1506
1569
  return (findings ?? []).map((f) => `${indent}- ${f.kind}${f.nodeKey ? ` @${f.nodeKey}` : ""}: ${f.detail}`);
1507
1570
  }
1508
1571
  async function agentsPublish(args, deps) {
1509
- const { values, positionals } = parse(args, { revision: { type: "string" } });
1572
+ const { values, positionals } = parse(args, { revision: { type: "string" }, "accept-intermittent": { type: "boolean" } });
1510
1573
  const agentId = need(positionals, 0, "agentId");
1511
1574
  const client = await clientFor(values, deps);
1512
1575
  deps.io.err("Publishing — the pre-publish check runs first and can take a few minutes…");
1513
1576
  try {
1514
- const result = await client.publishAgent(agentId, values.revision);
1577
+ const result = await client.publishAgent(agentId, values.revision, { acceptIntermittent: values["accept-intermittent"] === true });
1515
1578
  if (values.json)
1516
1579
  printJson(deps, result);
1517
1580
  else {
@@ -1543,13 +1606,19 @@ async function agentsPublish(args, deps) {
1543
1606
  for (const c of verdict.cases) {
1544
1607
  if (!c.failures?.length)
1545
1608
  continue;
1546
- lines.push(` case ${c.caseId ?? "?"}${c.expectedLeafKey ? ` (→ ${c.expectedLeafKey})` : ""}:`);
1609
+ lines.push(` case ${c.caseId ?? "?"}${c.expectedLeafKey ? ` (→ ${c.expectedLeafKey})` : ""}${gateTag(c.gate)}:`);
1547
1610
  lines.push(...formatFindings(c.failures, " "));
1548
1611
  }
1549
1612
  }
1550
1613
  if (body.publishRunId)
1551
1614
  lines.push(`Publish run: ${String(body.publishRunId)} (details in the Portal).`);
1552
- lines.push("There is no override from the CLI: fix the draft, run `kumion test-runs start`, and publish again.");
1615
+ if (body.code === "intermittent") {
1616
+ lines.push("The check failed only in some of its runs (intermittent), nothing else is wrong. Fix the draft and publish again, " +
1617
+ "or accept the risk with `kumion agents publish " + agentId + " --accept-intermittent`.");
1618
+ }
1619
+ else {
1620
+ lines.push("There is no override from the CLI: fix the draft, run `kumion test-runs start`, and publish again.");
1621
+ }
1553
1622
  throw new ReportedFailure(lines.join("\n"));
1554
1623
  }
1555
1624
  }
@@ -1710,7 +1779,9 @@ export function summarizeTestRun(run) {
1710
1779
  for (const r of run.results ?? []) {
1711
1780
  if (!r.failures?.length)
1712
1781
  continue;
1713
- lines.push(`Case ${r.caseId}${r.expectedLeafKey ? ` (→ ${r.expectedLeafKey})` : ""}:`);
1782
+ lines.push(`Case ${r.caseId}${r.expectedLeafKey ? ` (→ ${r.expectedLeafKey})` : ""}${gateTag(r.gate)}:`);
1783
+ if (r.attempts?.length)
1784
+ lines.push(` runs: ${r.attempts.map((a) => `#${a.attempt} ${a.outcome}`).join(", ")}`);
1714
1785
  lines.push(...formatFindings(r.failures, " "));
1715
1786
  }
1716
1787
  }
@@ -1781,6 +1852,53 @@ async function testRunsList(args, deps) {
1781
1852
  deps.io.out(`${r.id} ${r.status.padEnd(13)} ${r.casesDone}/${r.casesTotal} ${r.startedAt}`);
1782
1853
  return 0;
1783
1854
  }
1855
+ function parseVarFlags(pairs) {
1856
+ const variables = {};
1857
+ for (const pair of pairs ?? []) {
1858
+ const at = pair.indexOf("=");
1859
+ if (at < 1)
1860
+ throw new UsageError(`--var must be <name>=<value> (got "${pair}").`);
1861
+ variables[pair.slice(0, at)] = pair.slice(at + 1);
1862
+ }
1863
+ return variables;
1864
+ }
1865
+ async function scheduledCallsCreate(args, deps) {
1866
+ const { values, positionals } = parse(args, { to: { type: "string" }, at: { type: "string" }, var: { type: "string", multiple: true } });
1867
+ const agentId = need(positionals, 0, "agentId");
1868
+ const variables = parseVarFlags(values.var);
1869
+ if (!values.to)
1870
+ throw new UsageError("--to <phone> is required.");
1871
+ if (!values.at)
1872
+ throw new UsageError("--at <iso8601 with offset> is required.");
1873
+ const result = await (await clientFor(values, deps)).createScheduledCall(agentId, values.to, values.at, variables);
1874
+ if (values.json)
1875
+ printJson(deps, result);
1876
+ else
1877
+ deps.io.out(`Scheduled ${String(result.phoneNumber)} for ${String(result.scheduledAt)}.\nId: ${String(result.id)}`);
1878
+ return 0;
1879
+ }
1880
+ async function scheduledCallsList(args, deps) {
1881
+ const { values } = parse(args, {});
1882
+ const rows = await (await clientFor(values, deps)).listScheduledCalls();
1883
+ if (values.json)
1884
+ printJson(deps, { scheduledCalls: rows });
1885
+ else if (rows.length === 0)
1886
+ deps.io.out("No scheduled calls.");
1887
+ else
1888
+ for (const r of rows)
1889
+ deps.io.out(`${String(r.id)} ${String(r.state).padEnd(9)} ${String(r.scheduledAt)} ${String(r.phoneNumber)}${r.reason ? ` (${String(r.reason)})` : ""}`);
1890
+ return 0;
1891
+ }
1892
+ async function scheduledCallsCancel(args, deps) {
1893
+ const { values, positionals } = parse(args, {});
1894
+ const id = need(positionals, 0, "id");
1895
+ const result = await (await clientFor(values, deps)).cancelScheduledCall(id);
1896
+ if (values.json)
1897
+ printJson(deps, result);
1898
+ else
1899
+ deps.io.out(`Canceled ${String(result.id)}.`);
1900
+ return 0;
1901
+ }
1784
1902
  async function callsCreate(args, deps) {
1785
1903
  const { values, positionals } = parse(args, {
1786
1904
  "campaign-contact": { type: "string" },
@@ -1788,13 +1906,7 @@ async function callsCreate(args, deps) {
1788
1906
  var: { type: "string", multiple: true },
1789
1907
  });
1790
1908
  const agentId = need(positionals, 0, "agentId");
1791
- const variables = {};
1792
- for (const pair of values.var ?? []) {
1793
- const at = pair.indexOf("=");
1794
- if (at < 1)
1795
- throw new UsageError(`--var must be <name>=<value> (got "${pair}").`);
1796
- variables[pair.slice(0, at)] = pair.slice(at + 1);
1797
- }
1909
+ const variables = parseVarFlags(values.var);
1798
1910
  const result = await (await clientFor(values, deps)).createCall(agentId, values["campaign-contact"], variables, values.to);
1799
1911
  if (values.json)
1800
1912
  printJson(deps, result);
package/dist/mcp.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
- import { readFile } from "node:fs/promises";
2
+ import { readFile, writeFile } from "node:fs/promises";
3
3
  import { basename } from "node:path";
4
4
  import { z } from "zod";
5
- import { ApiError } from "./client.js";
5
+ import { ApiError, isTextFile, specText } from "./client.js";
6
6
  import { describeError, UsageError } from "./errors.js";
7
7
  export const MAX_TEST_RUN_WAIT_SECONDS = 120;
8
8
  const TERMINAL = new Set(["passed", "failed", "could_not_run", "timeout", "cancelled"]);
@@ -71,8 +71,9 @@ export function createKumionMcpServer(client, options) {
71
71
  }, () => attempt(async () => ({ templates: await client.listAgentTemplates() })));
72
72
  server.registerTool("create_agent_from_template", {
73
73
  description: "Create a DRAFT agent from an onboarding template plus the business name, optionally reading a website " +
74
- "(`url`) or a document already uploaded and extracted on the Portal's 資料 screen (`documentId`; an API key " +
75
- "cannot upload one). Only facts the source actually states are filled; the rest come back as 「まだない情報」. " +
74
+ "(`url`) or a document already uploaded and extracted on the Portal's 資料 screen (`documentId`; upload it " +
75
+ "with `upload_document` first). Only facts the source actually states are filled; the rest come back as " +
76
+ "「まだない情報」. " +
76
77
  "Nothing is published and no fact is confirmed. Needs agents:write.",
77
78
  inputSchema: {
78
79
  templateId: z.string().min(1).describe("A template id from list_agent_templates."),
@@ -102,6 +103,53 @@ export function createKumionMcpServer(client, options) {
102
103
  inputSchema: { agentId },
103
104
  annotations: { readOnlyHint: true },
104
105
  }, (args) => attempt(() => client.getAgent(args.agentId)));
106
+ server.registerTool("get_agent_spec", {
107
+ description: "Download the agent's 応対仕様書 — the document that says, in Japanese, how the agent answers: the opening, " +
108
+ "the flow of a call, transfers, booking, the facts it may read out, what it records, who it notifies, and the " +
109
+ "AI instructions verbatim. `version` is published (the default), draft, or a version number. `format` is pdf " +
110
+ "(the default), docx (Word) or markdown; markdown comes back as the document itself, and pdf/docx are written " +
111
+ "to `outputPath`, which those two formats require. Chapters marked 〔出力時点〕 read settings that no version " +
112
+ "froze (hours, booking, 記録項目, 資料, 転送先, notifications) and are as they stand now. Needs agents:read.",
113
+ inputSchema: {
114
+ agentId,
115
+ version: z.string().min(1).optional().describe("published (default), draft, or a version number such as 3."),
116
+ format: z
117
+ .enum(["pdf", "docx", "markdown"])
118
+ .optional()
119
+ .describe("The output format: pdf (default), docx, or markdown. The first two answer with a file."),
120
+ outputPath: z
121
+ .string()
122
+ .min(1)
123
+ .optional()
124
+ .describe("Local file to write the document to. Required for pdf and docx — a binary file cannot travel as tool text. " +
125
+ "Ignored for markdown, which is returned as text."),
126
+ },
127
+ annotations: { readOnlyHint: true },
128
+ }, async (args) => {
129
+ try {
130
+ const file = await client.getAgentSpec(args.agentId, {
131
+ ...(args.version === undefined ? {} : { version: args.version }),
132
+ ...(args.format === undefined ? {} : { format: args.format }),
133
+ });
134
+ if (isTextFile(file)) {
135
+ return { content: [{ type: "text", text: specText(file) }] };
136
+ }
137
+ if (args.outputPath === undefined) {
138
+ throw new UsageError(`format=${args.format ?? "pdf"} answers with a file, not text: pass outputPath (a local path to write it to). ` +
139
+ "Use format=markdown for the document as text.");
140
+ }
141
+ await writeFile(args.outputPath, file.body);
142
+ return json({
143
+ path: args.outputPath,
144
+ bytes: file.body.byteLength,
145
+ filename: file.filename,
146
+ contentType: file.contentType,
147
+ });
148
+ }
149
+ catch (err) {
150
+ return failure(err);
151
+ }
152
+ });
105
153
  server.registerTool("get_call_flow", {
106
154
  description: "Read the agent's draft call flow the way the canvas assistant reads it: `editLayer` says whether it is edited " +
107
155
  "as 用件 (`flow`, with the 用件 subject, what each one says and asks for, and the confirmed caller examples) or " +
@@ -254,16 +302,22 @@ export function createKumionMcpServer(client, options) {
254
302
  }, (args) => attempt(() => client.confirmFacts(args.agentId, args.factIds)));
255
303
  server.registerTool("publish_agent", {
256
304
  description: "Publish the agent's draft so callers get it. Runs the same pre-publish check as the Portal first and " +
257
- "publishes only if it passes; there is no way to skip it. Can take a few minutes. On failure the " +
305
+ "publishes only if it passes; a failing check cannot be skipped. The one exception: a check that failed " +
306
+ "only in some of its runs comes back with code `intermittent` and the cases (`gate: intermittent`), and " +
307
+ "`acceptIntermittent` publishes it anyway. Can take a few minutes. On failure the " +
258
308
  "failing cases are returned. A success carries `unconfirmedFacts`: how many of the agent's 資料 facts " +
259
309
  "nobody has confirmed yet — for each of them the agent says it will check and call back instead of " +
260
310
  "stating it (confirm_facts confirms them). Needs agents:publish.",
261
311
  inputSchema: {
262
312
  agentId,
263
313
  revision: z.string().optional().describe("Refuse to publish if the draft is no longer at this revision."),
314
+ acceptIntermittent: z
315
+ .boolean()
316
+ .optional()
317
+ .describe("Publish although the check failed only in some of its runs (code `intermittent`). Has no effect on a check that failed every time."),
264
318
  },
265
319
  annotations: { destructiveHint: true, idempotentHint: false },
266
- }, (args) => attempt(() => client.publishAgent(args.agentId, args.revision)));
320
+ }, (args) => attempt(() => client.publishAgent(args.agentId, args.revision, { acceptIntermittent: args.acceptIntermittent === true })));
267
321
  server.registerTool("start_test_run", {
268
322
  description: "Run the agent's regression tests against its draft (publishes nothing). Returns at once with the run " +
269
323
  `unless waitSeconds is set (at most ${MAX_TEST_RUN_WAIT_SECONDS}); follow a running run with ` +
@@ -318,6 +372,29 @@ export function createKumionMcpServer(client, options) {
318
372
  },
319
373
  annotations: { idempotentHint: false },
320
374
  }, (args) => attempt(() => client.createCall(args.agentId, args.campaignContactId, args.variables, args.phoneNumber)));
375
+ server.registerTool("create_scheduled_call", {
376
+ description: "Schedule one outbound call at a stated time; the dialer places it once, with no automatic redial. " +
377
+ "scheduledAt must carry a timezone offset (2026-10-31T13:00:00+09:00). Needs calls:create.",
378
+ inputSchema: {
379
+ agentId,
380
+ phoneNumber: z.string().describe("Domestic Japanese number to dial."),
381
+ scheduledAt: z.string().describe("When to dial, ISO 8601 with a timezone offset."),
382
+ variables: z
383
+ .record(z.string(), z.string())
384
+ .optional()
385
+ .describe("Values for {{vars.<name>}} in the agent's prompts, opening line and edge conditions (optional)."),
386
+ },
387
+ annotations: { idempotentHint: false },
388
+ }, (args) => attempt(() => client.createScheduledCall(args.agentId, args.phoneNumber, args.scheduledAt, args.variables)));
389
+ server.registerTool("list_scheduled_calls", {
390
+ description: "List the calls scheduled through the API, newest first (at most 100), with state and reason. Needs calls:read.",
391
+ inputSchema: {},
392
+ annotations: { readOnlyHint: true },
393
+ }, () => attempt(async () => ({ scheduledCalls: await client.listScheduledCalls() })));
394
+ server.registerTool("cancel_scheduled_call", {
395
+ description: "Cancel a scheduled call that has not started. Needs calls:create.",
396
+ inputSchema: { scheduledCallId: z.string().min(1).describe("The id from create_scheduled_call or list_scheduled_calls.") },
397
+ }, (args) => attempt(() => client.cancelScheduledCall(args.scheduledCallId)));
321
398
  const callId = z.string().min(1).describe("The call's id, from list_calls.");
322
399
  server.registerTool("list_calls", {
323
400
  description: "List the tenant's call history, newest first, one page at a time (default 20, at most 100); `total` " +
@@ -715,7 +792,7 @@ export function createKumionMcpServer(client, options) {
715
792
  description: "Add one 記録項目. It is mounted on NO agent yet, so no call changes until something mounts it. Omit " +
716
793
  "`instruction` and the API writes one from the label, 場面 and fields — no model is called. `key` is " +
717
794
  "generated when omitted (print it back to the operator) and cannot be changed afterwards. Walls: at most " +
718
- "10 fields, at most 3 of them `summary`, and at most 5 enabled specs per tenant. Needs agents:write.",
795
+ "10 fields, at most 3 of them `summary`, and at most 20 enabled specs per tenant. Needs agents:write.",
719
796
  inputSchema: {
720
797
  label: z.string().min(1).describe("The name the operator sees (例: 予約内容)."),
721
798
  fields: z.array(captureSpecField).describe("The items to record, in the order they should be asked."),
@@ -741,7 +818,7 @@ export function createKumionMcpServer(client, options) {
741
818
  server.registerTool("update_capture_spec", {
742
819
  description: "Change one 記録項目. An omitted field is left alone; `key` cannot be changed. A hand-written `instruction` " +
743
820
  "is never rewritten by a field edit — only a generated one follows the fields. `scenario` and " +
744
- "`confirmationMessage` take null to clear. LIVE: every agent mounted with this spec records differently " +
821
+ "`confirmationMessage` take an empty string to clear. LIVE: every agent mounted with this spec records differently " +
745
822
  "from its next call, with no publish. `revision` is the spec's, from list_capture_specs; a stale one writes " +
746
823
  "nothing and answers a conflict. Needs agents:live.",
747
824
  inputSchema: {
@@ -873,7 +950,7 @@ export function createKumionMcpServer(client, options) {
873
950
  server.registerTool("get_document", {
874
951
  description: "Read one 資料: its summary (title, status, mode, character count), what it is wired into (the agents " +
875
952
  "and graph nodes in `references`), the extracted `fields` (each with its candidates, sources and review " +
876
- "state) and the `revision`. The raw text is never returned. This id is what create_from_template's " +
953
+ "state) and the `revision`. The raw text is never returned. This id is what create_agent_from_template's " +
877
954
  "`documentId` takes. Needs agents:read.",
878
955
  inputSchema: {
879
956
  documentId: z.string().min(1).describe("The document id, from get_document_upload_job."),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kumion/cli",
3
- "version": "0.4.0",
3
+ "version": "0.6.0",
4
4
  "description": "Manage your Kumion voice agents from the terminal over the Kumion Partner API",
5
5
  "author": "KAOPA株式会社",
6
6
  "license": "MIT",
@@ -12,8 +12,8 @@ repository to clone and no local agent file to keep in sync — do not create on
12
12
  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
- command has one: `list_agents`, `get_agent`, `patch_agent`, `publish_agent`,
16
- `get_call_flow`, `update_call_flow`, `edit_call_flow_steps`,
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
17
  `set_agent_opening_name`, `set_agent_availability`, `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`,
@@ -87,12 +87,21 @@ A partner with several customers has one profile per customer tenant
87
87
  `kumion agents publish <agentId>`. It runs the same pre-publish check as the Portal
88
88
  and can take a few minutes. If the check fails, nothing goes live and the failing
89
89
  cases come back: fix, test, publish again. There is no skip or override; do not
90
- look for one.
90
+ look for one. One case is the exception: when the refusal says the check failed only
91
+ intermittently (`[intermittent]`, code `intermittent`), `--accept-intermittent` /
92
+ `acceptIntermittent` publishes it. Use it only when the user said to accept that risk.
91
93
  6. **Try it** (optional) — `create_call` / `kumion calls create <agentId>` starts a web
92
94
  test call and returns a LiveKit room and token. With `phoneNumber` / `--to <phone>` it
93
95
  places a real outbound call instead (a domestic number; the agent must be published
94
96
  and have a phone number assigned) — only when the user asked to dial a real person.
95
97
  The outcome is on `get_call` / `kumion calls get`.
98
+ To dial at a stated time instead, `create_scheduled_call` / `kumion scheduled-calls create <agentId> --to <phone> --at <iso8601-with-offset>`
99
+ (the offset is required, the time must be in the future, one dial with no redial; 403 when the tenant's
100
+ automatic outbound dialing is off or the plan is free, 409 when the number already has a pending dial).
101
+ Both take per-call values, `--var <name>=<value>` (repeatable) / `variables`, read as `{{vars.<name>}}` in
102
+ the agent's prompts and opening line. The flag splits at the first `=`; a name left out reads as empty; a
103
+ 変数 marked 必須 must be given or the call is refused (400 `missing_variables`).
104
+ `list_scheduled_calls` shows the state; `cancel_scheduled_call` works only before the dial starts.
96
105
 
97
106
  ## From a template to a published agent
98
107
 
@@ -132,7 +141,7 @@ number. `--json` everywhere; the names below are the CLI's, the MCP tool is in t
132
141
  `severity: "error"` entry in `findings.canvas` and `findings.structural` must be empty.
133
142
  10. **Publish** — `kumion agents publish <A> --revision <rev> --json`, then `kumion agents get <A>`:
134
143
  `publishState.live: true`, `unpublishedChanges: false`, and the publish answer's
135
- `publishedSnapshotId`. `unconfirmedFacts` above zero means the agent is not finished.
144
+ `agent.publishedSnapshotId`. `unconfirmedFacts` above zero means the agent is not finished.
136
145
 
137
146
  ## Reading real calls
138
147
 
@@ -146,6 +155,34 @@ silent call. Use a transcript to find where the agent went wrong before editing
146
155
  draft. Transcripts are the tenant's customers' conversations: quote only what the task
147
156
  needs.
148
157
 
158
+ ## The 応対仕様書 (the agent's settings as one document)
159
+
160
+ `get_agent_spec` / `kumion agents spec <agentId>` writes the 応対仕様書: the Japanese
161
+ document that states how this agent answers — the opening, the flow of a call, transfers,
162
+ booking, the facts it may read out, what it records, who it notifies, and the AI
163
+ instructions verbatim. It is built from the stored settings; no model writes or rewords
164
+ any of it. It is what a customer files, or hands to someone reviewing what the agent says.
165
+ Needs `agents:read`.
166
+
167
+ - **`version`** — `published` (the default; the version answering calls today), `draft`,
168
+ or a version number such as `3`. An agent with no canvas has no versions at all, and
169
+ `published` answers its 現在の設定; an agent that was never published answers with its
170
+ draft, labelled 未公開.
171
+ - **`format`** — `pdf` (the default), `docx`, or `markdown`. Markdown is text and comes
172
+ back as the answer itself (MCP tool content, CLI stdout). PDF and Word are binary: MCP
173
+ writes them to `outputPath`, which those two require, and the CLI writes them to `--out`
174
+ — or, with no `--out`, to the server's own filename in the current directory.
175
+ - **Two kinds of chapter.** 〔この版〕 chapters were frozen when the chosen version was
176
+ published. 〔出力時点〕 chapters read settings no version froze — 店舗, 予約, 記録項目,
177
+ 資料, 転送先, 通知 — and state them as they stand at export. Exporting an older version
178
+ therefore mixes that version's content with today's settings on purpose; say so when
179
+ handing one over. A draft carries 「下書き」 on every page.
180
+ - **Exporting changes nothing.** It is a read: 公開中 stays the version it was, and the
181
+ next call answers from it. The export date on the cover is the moment of the export.
182
+
183
+ Do not retype or summarise the document into the conversation: save it and give the user
184
+ the path (or hand it to them where the host can attach files).
185
+
149
186
  ## The shop clock (営業時間)
150
187
 
151
188
  When the call answers 「何時までですか」, it reads the tenant's one booking calendar.
@@ -224,10 +261,11 @@ A key a node does not store follows the agent's setting (会話の運用) or the
224
261
  | `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. |
225
262
  | `trigger_path` | trigger | `internal` | `string` | Generated. Shown read-only as the trigger URL. |
226
263
  | `opening_speech` | start | `required` | `string` | The opening line. Supports {{variables}}. |
227
- | `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). |
264
+ | `items` | start, agent | `required` | `{key,label?,example?,source?,value_type?,options?,must_ask?,min_digits?,max_digits?,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). `min_digits` / `max_digits`: for a `code` item, the fewest / most digits the value may hold, counted by the platform (the same number twice = exact length). `tool`: `{tool_key,result_field}` for a tool-sourced item. `option_writes`: option → tool that must succeed before that option lets the call leave (advanced). |
228
265
  | `allow_interruptions` | start, agent | `tune` | `boolean` | Absent means the caller may interrupt. Only an explicit false is stored. |
229
266
  | `respond_on_enter` | agent | `tune` | `boolean` | Absent means the node answers on arrival. Only an explicit false (wait for the caller) is stored. |
230
267
  | `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. |
268
+ | `confirm_before_end_keys` | agent | `internal` | `string[]` | Set by the compiler on a 伝言 step. With `confirm_before_end` on, the end readback reads only these item keys (the call-back number); absent means every item the ending requires. |
231
269
  | `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. |
232
270
  | `quiet_wait` | start, agent | `tune` | `{ seconds, listen?, resume_speech? }` | Node-level wait. { seconds: 0 } turns the agent default off here. |
233
271
  | `optional_slots` | start, agent | `tune` | `string[]` | Slots declared elsewhere that this step may record when the caller volunteers them. |