@kumion/cli 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/mcp.js CHANGED
@@ -22,18 +22,145 @@ async function attempt(run) {
22
22
  }
23
23
  }
24
24
  const agentId = z.string().min(1).describe("The agent's id, from list_agents.");
25
+ const flowStep = z
26
+ .object({
27
+ key: z.string().min(1).describe("The step's key (an existing one, or a new key with action \"add\")."),
28
+ action: z.enum(["add", "remove"]).optional(),
29
+ afterKey: z.string().optional().describe("add: place it after this step."),
30
+ beforeKey: z.string().optional().describe("add: place it before this step."),
31
+ label: z.string().optional(),
32
+ transitionSpeech: z.string().optional(),
33
+ prompt: z.string().optional().describe("What this step does."),
34
+ requiredBeforeEnd: z.array(z.record(z.string(), z.unknown())).optional(),
35
+ })
36
+ .passthrough();
37
+ const flowLeaf = z
38
+ .object({
39
+ key: z.string().min(1).describe("The 用件's key (an existing one, or a new alphanumeric key with action \"add\")."),
40
+ action: z.enum(["keep", "remove", "merge_into", "add"]).optional(),
41
+ mergeIntoKey: z.string().optional().describe("merge_into: the 用件 this one is folded into."),
42
+ label: z.string().optional(),
43
+ condition: z.string().optional().describe("How a caller's words make this the 用件 the call is taken under."),
44
+ transitionSpeech: z.string().optional(),
45
+ leafPrompt: z.string().optional().describe("What the agent does in this 用件."),
46
+ endSpeech: z.string().optional(),
47
+ transferContactKey: z
48
+ .string()
49
+ .optional()
50
+ .describe("Hand this 用件 to this registered staff member (a `key` from get_call_flow's staffChoices)."),
51
+ removeTransfer: z.boolean().optional().describe("Take the transfer off this 用件 (it goes back to a message)."),
52
+ requiredBeforeEnd: z.array(z.record(z.string(), z.unknown())).optional().describe("The whole list the 用件 must ask."),
53
+ steps: z.array(flowStep).optional(),
54
+ })
55
+ .passthrough();
25
56
  export function createKumionMcpServer(client, options) {
26
57
  const server = new McpServer({ name: "kumion", version: options.version });
27
58
  server.registerTool("list_agents", {
28
59
  description: "List the voice agents of the Kumion tenant this key belongs to. Needs the agents:read scope.",
29
60
  annotations: { readOnlyHint: true },
30
61
  }, () => attempt(async () => ({ tenantId: client.tenantId, agents: await client.listAgents() })));
62
+ server.registerTool("list_agent_templates", {
63
+ description: "List the onboarding templates: the id, what each one is for, and the 用件 and facts it declares. Use an " +
64
+ "id here with create_agent_from_template. Needs agents:read.",
65
+ annotations: { readOnlyHint: true },
66
+ }, () => attempt(async () => ({ templates: await client.listAgentTemplates() })));
67
+ server.registerTool("create_agent_from_template", {
68
+ description: "Create a DRAFT agent from an onboarding template plus the business name, optionally reading a website " +
69
+ "(`url`) or a document already uploaded and extracted on the Portal's 資料 screen (`documentId`; an API key " +
70
+ "cannot upload one). Only facts the source actually states are filled; the rest come back as 「まだない情報」. " +
71
+ "Nothing is published and no fact is confirmed. Needs agents:write.",
72
+ inputSchema: {
73
+ templateId: z.string().min(1).describe("A template id from list_agent_templates."),
74
+ businessName: z.string().min(1).describe("The shop/company name: names the agent and greets the caller."),
75
+ name: z.string().min(1).optional().describe("Agent name; defaults to businessName."),
76
+ url: z.string().url().optional().describe("A site to read (same site, up to 10 pages). Not with documentId."),
77
+ documentId: z.string().min(1).optional().describe("An extracted document id. Not with url."),
78
+ idempotencyKey: z
79
+ .string()
80
+ .min(1)
81
+ .max(200)
82
+ .optional()
83
+ .describe("Safe-retry key: send the same key again to get the agent the first call built instead of a second one."),
84
+ },
85
+ annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false },
86
+ }, (args) => attempt(() => client.createAgentFromTemplate({
87
+ templateId: args.templateId,
88
+ businessName: args.businessName,
89
+ ...(args.name ? { name: args.name } : {}),
90
+ ...(args.url ? { url: args.url } : {}),
91
+ ...(args.documentId ? { documentId: args.documentId } : {}),
92
+ ...(args.idempotencyKey ? { idempotencyKey: args.idempotencyKey } : {}),
93
+ })));
31
94
  server.registerTool("get_agent", {
32
95
  description: "Read one agent: its draft (prompt, flow graph) and its published version. The returned `revision` is " +
33
96
  "what patch_agent needs. Needs agents:read.",
34
97
  inputSchema: { agentId },
35
98
  annotations: { readOnlyHint: true },
36
99
  }, (args) => attempt(() => client.getAgent(args.agentId)));
100
+ server.registerTool("get_call_flow", {
101
+ description: "Read the agent's draft call flow the way the canvas assistant reads it: `editLayer` says whether it is edited " +
102
+ "as 用件 (`flow`, with the 用件 subject, what each one says and asks for, and the confirmed caller examples) or " +
103
+ "as steps (`steps`, where `flow` is null); `staffChoices` is who a 用件 may transfer to, `transferRefusal` why " +
104
+ "it may not, and `findings` the same pre-publish findings the assistant sees. `revision` is the value " +
105
+ "patch_agent needs. Needs agents:read.",
106
+ inputSchema: { agentId },
107
+ annotations: { readOnlyHint: true },
108
+ }, (args) => attempt(() => client.getFlow(args.agentId)));
109
+ server.registerTool("update_call_flow", {
110
+ description: "Change the agent's draft call flow the way the canvas assistant does: the 用件 (what each one says and asks " +
111
+ "for, how callers reach it), and whether a 用件 hands the caller to a registered staff member " +
112
+ "(`leaves[].transferContactKey`, or `removeTransfer` to take it away). Only what you pass changes; the same " +
113
+ "arguments and rules as the assistant's update_call_flow tool, so a field it does not take is a 400. Returns " +
114
+ "`changes` (the rows the proposal card lists), `consequences` (tests and steps the change takes along) and " +
115
+ "`warnings` (what could not be applied as asked); `revision` is the draft revision after the write. `dryRun` " +
116
+ "computes the change and stores nothing. A draft write: it reaches callers with the next publish_agent. " +
117
+ "Needs agents:write. Read the flow with get_call_flow first (its `editLayer` must be `flow`).",
118
+ inputSchema: {
119
+ agentId,
120
+ revision: z.string().min(1).describe("The draft revision your change is based on, from get_call_flow."),
121
+ personaPrompt: z.string().optional().describe("The agent's role and tone."),
122
+ openingSpeech: z.string().optional().describe("The first line of the call."),
123
+ noRouteSpeech: z.string().optional().describe("What it says when no 用件 fits."),
124
+ leaves: z.array(flowLeaf).optional().describe("Per-用件 changes; only the fields you pass change."),
125
+ examples: z.record(z.string(), z.string()).optional().describe("用件 key → the line a caller opens with."),
126
+ dryRun: z.boolean().optional().describe("Compute the change and store nothing."),
127
+ },
128
+ annotations: { destructiveHint: false, idempotentHint: false },
129
+ }, (args) => {
130
+ const source = args;
131
+ const patch = {};
132
+ for (const key of ["personaPrompt", "openingSpeech", "noRouteSpeech", "leaves", "examples"]) {
133
+ if (source[key] !== undefined)
134
+ patch[key] = source[key];
135
+ }
136
+ if (Object.keys(patch).length === 0) {
137
+ return failure(new UsageError("Nothing to change: pass personaPrompt, openingSpeech, noRouteSpeech, leaves or examples."));
138
+ }
139
+ return attempt(() => client.updateFlow(args.agentId, patch, args.revision, { dryRun: args.dryRun === true }));
140
+ });
141
+ server.registerTool("edit_call_flow_steps", {
142
+ description: "Change a step-by-step flow (one the canvas draws, `editLayer` = `steps` in get_call_flow) the way the canvas " +
143
+ "assistant does. `ops` is a batch, run in order, at most 20: each element is `{ op, …that operation's " +
144
+ "arguments }`, with `op` one of set_node_field (nodeKey, field, value), set_edge_words (fromKey, toKey, " +
145
+ "condition?, transitionSpeech?), add_step (type `agent`|`transfer`, name, between?, next_condition?, prompt?, " +
146
+ "items?, staff?, before_speech?, key?), remove_step (node), connect_steps (from, to, condition, speech?, " +
147
+ "only_when?), reconnect (from, to, new_to, via_tool?), disconnect (from, to, via_tool?). The batch is atomic: " +
148
+ "one refused operation refuses all of them, and nothing is stored. `add_step.key` (optional, lowercase " +
149
+ "letters/digits/_) names the new step so a later operation of the same batch can point at it; without one the " +
150
+ "server picks the key and returns it in `added`. A 用件 flow (`editLayer` = `flow`) is refused: use " +
151
+ "update_call_flow. Returns `revision` (the draft revision after the write), `changes` (the rows the proposal " +
152
+ "card lists), `consequences`, `warnings` and `added`. A draft write: it reaches callers with the next " +
153
+ "publish_agent. Needs agents:write.",
154
+ inputSchema: {
155
+ agentId,
156
+ revision: z.string().min(1).describe("The draft revision your change is based on, from get_call_flow."),
157
+ ops: z
158
+ .array(z.record(z.string(), z.unknown()))
159
+ .describe("The batch, in order (at most 20): each element is { op, …that operation's arguments }."),
160
+ dryRun: z.boolean().optional().describe("Compute the change and store nothing."),
161
+ },
162
+ annotations: { destructiveHint: false, idempotentHint: false },
163
+ }, (args) => attempt(() => client.editFlowSteps(args.agentId, args.ops, args.revision, { dryRun: args.dryRun === true })));
37
164
  server.registerTool("patch_agent", {
38
165
  description: "Edit an agent's draft (never goes live by itself — publish_agent does that). `revision` must be the one " +
39
166
  "get_agent returned when you read the draft you are changing; if the draft changed since, nothing is " +
@@ -56,6 +183,66 @@ export function createKumionMcpServer(client, options) {
56
183
  }
57
184
  return attempt(() => client.patchAgent(args.agentId, patch, args.revision));
58
185
  });
186
+ server.registerTool("set_agent_opening_name", {
187
+ description: "Switch whether the agent's opening line may call the caller by the name the phone number matched. A draft " +
188
+ "write like patch_agent: it reaches callers with the next publish_agent. `revision` is the one get_agent " +
189
+ "returned. Needs agents:write.",
190
+ inputSchema: {
191
+ agentId,
192
+ revision: z.string().min(1).describe("The draft revision your change is based on, from get_agent."),
193
+ enabled: z.boolean().describe("true: use the caller's name; false: do not."),
194
+ },
195
+ annotations: { destructiveHint: false, idempotentHint: true },
196
+ }, (args) => attempt(() => client.setOpeningName(args.agentId, args.enabled, args.revision)));
197
+ server.registerTool("set_agent_availability", {
198
+ description: "Set when the agent answers the phone (operatingHours: { mode: always | staffed | custom, hours? }) and what " +
199
+ "happens to a call outside that (offHoursPolicy: { kind: answer | announce_end | route_to, text?, agent_id? }). " +
200
+ "Pass either or both; null clears a setting to its default. LIVE: it applies to the next call with no " +
201
+ "publish, so confirm with the person first. `revision` is the one get_agent returned (the settings are in " +
202
+ "its `live` block). Needs agents:live, which a key does not get from agents:write.",
203
+ inputSchema: {
204
+ agentId,
205
+ revision: z.string().min(1).describe("The draft revision your change is based on, from get_agent."),
206
+ operatingHours: z.unknown().optional().describe("New 受付時間, or null to clear."),
207
+ offHoursPolicy: z.unknown().optional().describe("New 時間外の対応, or null to clear."),
208
+ },
209
+ annotations: { destructiveHint: true, idempotentHint: true },
210
+ }, (args) => {
211
+ const patch = {};
212
+ if (args.operatingHours !== undefined)
213
+ patch.operatingHours = args.operatingHours;
214
+ if (args.offHoursPolicy !== undefined)
215
+ patch.offHoursPolicy = args.offHoursPolicy;
216
+ if (!("operatingHours" in patch) && !("offHoursPolicy" in patch)) {
217
+ return failure(new UsageError("Nothing to change: pass `operatingHours` or `offHoursPolicy`."));
218
+ }
219
+ return attempt(() => client.setAvailability(args.agentId, patch, args.revision));
220
+ });
221
+ server.registerTool("list_facts", {
222
+ description: "List the facts taken from the agent's 資料 (prices, menu, opening notes) with their state (pending, " +
223
+ "confirmed, edited) and the `revision` edit_fact needs. Needs agents:read.",
224
+ inputSchema: { agentId },
225
+ annotations: { readOnlyHint: true },
226
+ }, (args) => attempt(async () => ({ facts: await client.listFacts(args.agentId) })));
227
+ server.registerTool("edit_fact", {
228
+ description: "Confirm one fact with a new value. LIVE: callers get it at once, with no publish, so confirm with the person " +
229
+ "first. `revision` is the fact's own, from list_facts; if the fact changed since, nothing is written. Needs " +
230
+ "agents:live.",
231
+ inputSchema: {
232
+ agentId,
233
+ factId: z.string().min(1).describe("The fact's id, from list_facts."),
234
+ revision: z.string().min(1).describe("The fact's revision, from list_facts."),
235
+ value: z.string().describe("The value to confirm."),
236
+ },
237
+ annotations: { destructiveHint: true, idempotentHint: true },
238
+ }, (args) => attempt(async () => ({ fact: await client.editFact(args.agentId, args.factId, args.value, args.revision) })));
239
+ server.registerTool("confirm_facts", {
240
+ description: "Confirm pending facts with the value the extraction found: the listed factIds, or every pending one when " +
241
+ "omitted. A fact whose candidates disagree is not confirmed and comes back in `skipped`. LIVE: callers get " +
242
+ "it at once, with no publish. Needs agents:live.",
243
+ inputSchema: { agentId, factIds: z.array(z.string().min(1)).optional().describe("Only these facts (from list_facts).") },
244
+ annotations: { destructiveHint: true, idempotentHint: true },
245
+ }, (args) => attempt(() => client.confirmFacts(args.agentId, args.factIds)));
59
246
  server.registerTool("publish_agent", {
60
247
  description: "Publish the agent's draft so callers get it. Runs the same pre-publish check as the Portal first and " +
61
248
  "publishes only if it passes; there is no way to skip it. Can take a few minutes. On failure the " +
@@ -104,17 +291,28 @@ export function createKumionMcpServer(client, options) {
104
291
  }, (args) => attempt(async () => ({ testRuns: await client.listTestRuns(args.agentId, args.limit) })));
105
292
  server.registerTool("create_call", {
106
293
  description: "Start a web test call with the agent. Returns the LiveKit room and a participant token to join it. " +
107
- "Needs calls:create.",
294
+ "With phoneNumber (a domestic Japanese number), dials that number instead and returns the call id " +
295
+ "straight away; the outcome is on the call (get_call). Needs calls:create.",
108
296
  inputSchema: {
109
297
  agentId,
110
298
  campaignContactId: z.string().optional().describe("Call as this campaign contact (optional)."),
299
+ phoneNumber: z
300
+ .string()
301
+ .optional()
302
+ .describe("Dial this domestic number (e.g. 08012345678) from the agent's assigned phone number (optional)."),
303
+ variables: z
304
+ .record(z.string(), z.string())
305
+ .optional()
306
+ .describe("Values for {{vars.<name>}} in the agent's prompts, opening line and edge conditions (optional)."),
111
307
  },
112
308
  annotations: { idempotentHint: false },
113
- }, (args) => attempt(() => client.createCall(args.agentId, args.campaignContactId)));
309
+ }, (args) => attempt(() => client.createCall(args.agentId, args.campaignContactId, args.variables, args.phoneNumber)));
114
310
  const callId = z.string().min(1).describe("The call's id, from list_calls.");
115
311
  server.registerTool("list_calls", {
116
312
  description: "List the tenant's call history, newest first, one page at a time (default 20, at most 100); `total` " +
117
- "counts every call matching the filters. Draft test calls are not listed. Needs calls:read.",
313
+ "counts every call matching the filters. Draft test calls are not listed. Each call carries its result: " +
314
+ "`outcome` (ai_resolved, ai_unresolved_hangup, invalid_call, handoff, system_ended, na), `endedAtNode`, " +
315
+ "`durationSec`, `transferred` and `capturedItems` (names only). Needs calls:read.",
118
316
  inputSchema: {
119
317
  agentId: z.string().optional().describe("Only this agent's calls."),
120
318
  channel: z.enum(["webcall", "sip_did", "trigger"]).optional().describe("Only calls in on this channel."),
@@ -128,8 +326,8 @@ export function createKumionMcpServer(client, options) {
128
326
  }, (args) => attempt(() => client.listCalls(args)));
129
327
  server.registerTool("get_call", {
130
328
  description: "Read one call: agent, source and direction, numbers, when it started, was answered and ended, how it " +
131
- "ended, and whether a transcript exists (read it with get_call_transcript). The channel is only on " +
132
- "list_calls. Needs calls:read.",
329
+ "ended, its result (`outcome`, `endedAtNode`, `durationSec`, `transferred`, `capturedItems`), and whether " +
330
+ "a transcript exists (read it with get_call_transcript). The channel is only on list_calls. Needs calls:read.",
133
331
  inputSchema: { callId },
134
332
  annotations: { readOnlyHint: true },
135
333
  }, (args) => attempt(async () => ({ call: await client.getCall(args.callId) })));
@@ -140,5 +338,77 @@ export function createKumionMcpServer(client, options) {
140
338
  inputSchema: { callId },
141
339
  annotations: { readOnlyHint: true },
142
340
  }, (args) => attempt(async () => ({ transcript: await client.getTranscript(args.callId) })));
341
+ server.registerTool("list_staff", {
342
+ description: "List the tenant's スタッフ — the people a 用件's 転送 can be sent to — with `id`, the `key` a transfer names, " +
343
+ "`displayName`, `department`, `transferTarget`, `enabled` and `revision` (what update_staff must pass). " +
344
+ "`transferCandidate: true` means a 用件 may transfer there: enabled, keyed and given a 転送先. Needs agents:read.",
345
+ inputSchema: {},
346
+ annotations: { readOnlyHint: true },
347
+ }, () => attempt(async () => ({ staff: await client.listStaff() })));
348
+ const staffText = (what) => z.string().optional().describe(`${what} (an empty string clears it).`);
349
+ server.registerTool("create_staff", {
350
+ description: "Register a スタッフ so a 用件 can transfer a call to them. The transfer `key` is generated and returned — it " +
351
+ "is not a parameter. Nothing reaches callers until a 用件's 転送 names that key and the agent is published, " +
352
+ "and a row with no `transferTarget` is not a transfer candidate yet. Needs agents:write.",
353
+ inputSchema: {
354
+ displayName: z.string().min(1).describe("The person's name, as the operator sees it in the 転送 list."),
355
+ transferTarget: staffText("The number a transfer dials"),
356
+ department: staffText("Their team or department"),
357
+ kana: staffText("The name in kana"),
358
+ email: staffText("Their email address"),
359
+ note: staffText("A note. Never spoken on a call"),
360
+ enabled: z.boolean().optional().describe("false to leave them out of the 転送 candidates (default true)."),
361
+ },
362
+ annotations: { destructiveHint: false, idempotentHint: false },
363
+ }, (args) => attempt(async () => ({
364
+ staff: await client.createStaff({
365
+ displayName: args.displayName,
366
+ ...(args.transferTarget !== undefined ? { transferTarget: args.transferTarget } : {}),
367
+ ...(args.department !== undefined ? { department: args.department } : {}),
368
+ ...(args.kana !== undefined ? { kana: args.kana } : {}),
369
+ ...(args.email !== undefined ? { email: args.email } : {}),
370
+ ...(args.note !== undefined ? { note: args.note } : {}),
371
+ ...(args.enabled !== undefined ? { enabled: args.enabled } : {}),
372
+ }),
373
+ })));
374
+ server.registerTool("update_staff", {
375
+ description: "Change a スタッフ: their name, 転送先, department, kana, email, note, or whether they are a 転送 candidate " +
376
+ "(enabled: false takes them off the list without deleting the row the flow names). The `key` cannot be " +
377
+ "changed. LIVE: the next call already transfers to the new value — no publish — so confirm with the person " +
378
+ "first. `revision` is the row's, from list_staff; if it changed since, nothing is written and you get a " +
379
+ "conflict: read it again and re-apply. Needs agents:live.",
380
+ inputSchema: {
381
+ staffId: z.string().min(1).describe("The スタッフ's id, from list_staff."),
382
+ revision: z.string().min(1).describe("The row's revision, from list_staff."),
383
+ displayName: z.string().min(1).optional().describe("New name."),
384
+ transferTarget: staffText("New 転送先 number"),
385
+ department: staffText("Their team or department"),
386
+ kana: staffText("The name in kana"),
387
+ email: staffText("Their email address"),
388
+ note: staffText("A note. Never spoken on a call"),
389
+ enabled: z.boolean().optional().describe("false to take them out of the 転送 candidates."),
390
+ },
391
+ annotations: { destructiveHint: true, idempotentHint: true },
392
+ }, (args) => {
393
+ const patch = {};
394
+ if (args.displayName !== undefined)
395
+ patch.displayName = args.displayName;
396
+ if (args.transferTarget !== undefined)
397
+ patch.transferTarget = args.transferTarget;
398
+ if (args.department !== undefined)
399
+ patch.department = args.department;
400
+ if (args.kana !== undefined)
401
+ patch.kana = args.kana;
402
+ if (args.email !== undefined)
403
+ patch.email = args.email;
404
+ if (args.note !== undefined)
405
+ patch.note = args.note;
406
+ if (args.enabled !== undefined)
407
+ patch.enabled = args.enabled;
408
+ if (Object.keys(patch).length === 0) {
409
+ return failure(new UsageError("Nothing to change: pass one of displayName, transferTarget, department, kana, email, note or enabled."));
410
+ }
411
+ return attempt(async () => ({ staff: await client.updateStaff(args.staffId, patch, args.revision) }));
412
+ });
143
413
  return server;
144
414
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kumion/cli",
3
- "version": "0.2.0",
3
+ "version": "0.3.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",
@@ -34,10 +34,11 @@
34
34
  "build": "tsc -p tsconfig.build.json",
35
35
  "typecheck": "tsc --noEmit",
36
36
  "test": "vitest run",
37
+ "docs:node-config": "../../node_modules/.bin/tsx scripts/node-config-reference.ts",
37
38
  "prepack": "npm run build"
38
39
  },
39
40
  "dependencies": {
40
- "@modelcontextprotocol/sdk": "^1.30.1",
41
+ "@modelcontextprotocol/sdk": "^1.32.1",
41
42
  "@napi-rs/keyring": "^2.1.0",
42
43
  "undici": "^7.29.1",
43
44
  "zod": "^3.25.76"
@@ -45,6 +46,6 @@
45
46
  "devDependencies": {
46
47
  "@types/node": "^22.10.2",
47
48
  "typescript": "^5.7.2",
48
- "vitest": "^2.1.8"
49
+ "vitest": "^4.1.11"
49
50
  }
50
51
  }
@@ -11,10 +11,12 @@ repository to clone and no local agent file to keep in sync — do not create on
11
11
 
12
12
  Two ways in, same operations and same permissions:
13
13
 
14
- - **MCP tools** (`list_agents`, `get_agent`, `patch_agent`, `publish_agent`,
15
- `start_test_run`, `get_test_run`, `list_test_runs`, `create_call`, `list_calls`,
16
- `get_call`, `get_call_transcript`) when the host
17
- has the `kumion` MCP server registered.
14
+ - **MCP tools** when the host has the `kumion` MCP server registered. Each CLI
15
+ command has one: `list_agents`, `get_agent`, `get_call_flow`, `update_call_flow`,
16
+ `edit_call_flow_steps`, `patch_agent`, `publish_agent`, `start_test_run`,
17
+ `get_test_run`, `list_staff`, `create_staff`, `update_staff`, `create_call`,
18
+ `list_calls`, `get_call`, `get_call_transcript`, and the rest in
19
+ `kumion --help`.
18
20
  - **The `kumion` CLI** otherwise (`kumion --help`). Add `--json` for machine-readable
19
21
  output.
20
22
 
@@ -40,12 +42,32 @@ A partner with several customers has one profile per customer tenant
40
42
  2. **Read it** — `get_agent` / `kumion agents get <agentId> --json`. Note `revision`.
41
43
  A flow agent's behaviour is in `draft.graph`; a prompt-only agent's in
42
44
  `draft.prompt`.
43
- 3. **Edit the draft** — `patch_agent` with the `revision` you read /
44
- `kumion agents patch <agentId> --revision <rev> --prompt-file … | --graph-file …`.
45
- Send the whole edited graph, not a fragment. The draft is not live.
45
+ 3. **Edit the draft** — read the flow first: `get_call_flow` /
46
+ `kumion flow get <agentId> --json`. It is the view the Portal's canvas assistant
47
+ works on, with the `revision`, the pre-publish `findings`, and `staffChoices`
48
+ (who a 用件 can transfer to). Its `editLayer` picks the tool:
49
+ - `"flow"` (用件 form): `update_call_flow` / `kumion flow update <agentId>
50
+ --revision <rev> --patch-file <path>`. Send only what changes: `leaves[]` by
51
+ `key` with an `action` (`keep`, `add`, `remove`, `merge_into`), plus
52
+ `personaPrompt`, `openingSpeech`, `noRouteSpeech`, `examples` when they change.
53
+ To transfer a 用件 to someone, set its `transferContactKey` to a key from
54
+ `staffChoices`; `removeTransfer` turns it back into a message.
55
+ - `"steps"` (step-by-step graph, `flow` is null): `edit_call_flow_steps` /
56
+ `kumion flow edit-steps <agentId> --revision <rev> --ops-file <path>`. A batch of
57
+ `{ "op": …, …arguments }` from `set_node_field`, `set_edge_words`, `add_step`,
58
+ `remove_step`, `connect_steps`, `reconnect`, `disconnect`. It is all or nothing.
59
+ - Both accept `dryRun` / `--dry-run`: try it first and read the changes back.
60
+ - `patch_agent` / `kumion agents patch` replaces the prompt or the whole graph. Use
61
+ it only for a prompt-only agent or a change the two above cannot express, and
62
+ send the whole edited graph, not a fragment.
63
+
64
+ The draft is not live.
46
65
  - **Conflict (409)**: someone saved the agent since you read it. Nothing was
47
- written. Read it again, re-apply your change to the new draft, patch with the
66
+ written. Read it again, re-apply your change to the new draft, write with the
48
67
  new revision. Never retry with a revision you did not just read.
68
+ - **No one to transfer to**: `staffChoices` is empty or lacks the person. Register
69
+ them with `create_staff` / `kumion staff create --name … --transfer-target …`
70
+ (only when the user gave the name and number), then use the key it returns.
49
71
  4. **Test** — `start_test_run` (then `get_test_run` until it leaves `running`) /
50
72
  `kumion test-runs start <agentId>` (waits; exit 0 only on pass). Fix failures in
51
73
  the draft and test again.
@@ -55,21 +77,117 @@ A partner with several customers has one profile per customer tenant
55
77
  cases come back: fix, test, publish again. There is no skip or override; do not
56
78
  look for one.
57
79
  6. **Try it** (optional) — `create_call` / `kumion calls create <agentId>` starts a web
58
- test call and returns a LiveKit room and token.
80
+ test call and returns a LiveKit room and token. With `phoneNumber` / `--to <phone>` it
81
+ places a real outbound call instead (a domestic number; the agent must be published
82
+ and have a phone number assigned) — only when the user asked to dial a real person.
83
+ The outcome is on `get_call` / `kumion calls get`.
59
84
 
60
85
  ## Reading real calls
61
86
 
62
87
  `list_calls` / `kumion calls list` pages through the call history (filter by agent,
63
- channel, time range, or caller number); `get_call_transcript` /
88
+ channel, time range, or caller number). Each call already carries its result (`outcome`,
89
+ `endedAtNode`, `durationSec`, `transferred`, `capturedItems`): start from that, and read a
90
+ transcript only for the call you need. `get_call_transcript` /
64
91
  `kumion calls transcript <callId>` returns what the caller (`user`) and the agent
65
92
  (`assistant`) said. `available: false` means no transcript has been written yet, not a
66
93
  silent call. Use a transcript to find where the agent went wrong before editing its
67
94
  draft. Transcripts are the tenant's customers' conversations: quote only what the task
68
95
  needs.
69
96
 
70
- Not available over the Partner API (do not look for a command): operating hours,
71
- conversation-edit mode, the knowledge base, bookings, external-tool limits and the
72
- agent language setting. Those are Portal-only.
97
+ Not available over the Partner API (do not look for a command): conversation-edit mode, the knowledge base, bookings, external-tool limits, the agent
98
+ language setting, a tool's display name (表示名), the agent's call-outcome categories
99
+ (通話の結果), and the call model with its TTS voice. Those are Portal-only. A patch
100
+ writes only `prompt` and `graph`; `agents get` shows the model and voice read-only.
101
+
102
+ ## Node configuration reference
103
+
104
+ A flow agent's steps are `draft.graph.nodes[]`; each node's settings are its `config`.
105
+ The table below is generated from the Portal's own field list. The Portal's node
106
+ inspector shows the keys in three layers: 必須 (always shown), 動きの調整 and 詳細.
107
+
108
+ <!-- BEGIN node-config-reference: generated by scripts/node-config-reference.ts (npm run docs:node-config); do not edit -->
109
+ `layer` says where the Portal's node inspector shows the key:
110
+
111
+ - `required` — always shown
112
+ - `tune` — 「動きの調整」 card: a one-line summary that opens to edit
113
+ - `advanced` — folded under 「詳細」, or a required item's 「細かい設定」
114
+ - `internal` — no editor in the Portal: set by another surface, or API only
115
+
116
+ A key a node does not store follows the agent's setting (会話の運用) or the tenant's
117
+ (運用設定); the inspector shows it as 「既定」 and a stored one as 「変更あり」.
118
+
119
+ | Key | Node types | Layer | Type | Note |
120
+ | --- | --- | --- | --- | --- |
121
+ | `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. |
122
+ | `leaf_label` | start, agent | `internal` | `string` | Set by the manual compiler. The purpose name the diagnostics quote. |
123
+ | `canvas_flow` | start, agent, end, global, trigger, webhook, qa, ivr, transfer, notify | `internal` | `object` | Canvas layout state. Not a setting. |
124
+ | `flow_expectations` | global | `internal` | `object` | Written by the scenario interview. Not a setting. |
125
+ | `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. |
126
+ | `trigger_path` | trigger | `internal` | `string` | Generated. Shown read-only as the trigger URL. |
127
+ | `opening_speech` | start | `required` | `string` | The opening line. Supports {{variables}}. |
128
+ | `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). |
129
+ | `allow_interruptions` | start, agent | `tune` | `boolean` | Absent means the caller may interrupt. Only an explicit false is stored. |
130
+ | `respond_on_enter` | agent | `tune` | `boolean` | Absent means the node answers on arrival. Only an explicit false (wait for the caller) is stored. |
131
+ | `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. |
132
+ | `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. |
133
+ | `quiet_wait` | start, agent | `tune` | `{ seconds, listen?, resume_speech? }` | Node-level wait. { seconds: 0 } turns the agent default off here. |
134
+ | `optional_slots` | start, agent | `tune` | `string[]` | Slots declared elsewhere that this step may record when the caller volunteers them. |
135
+ | `switch_agent_id` | agent | `tune` | `uuid` | A published agent this step hands the call to. |
136
+ | `opening_audio_url` | start | `tune` | `string` | kumion-asset:// upload (or a legacy allow-listed URL) played instead of TTS for the opening line. |
137
+ | `opening_audio_filename` | start | `internal` | `string` | Display name of the uploaded opening audio. |
138
+ | `precall_fetch_url` | start | `advanced` | `string` | URL fetched before the call starts; the response becomes call variables. |
139
+ | `precall_fetch_method` | start | `advanced` | `string` | HTTP method of the pre-call fetch. |
140
+ | `precall_fetch_headers` | start | `advanced` | `{ key, value }[]` | Headers of the pre-call fetch. |
141
+ | `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. |
142
+ | `kb_fallback` | start, agent | `advanced` | `{ noResult?, unavailable? }` | Wording when a knowledge search finds nothing or is unavailable. Overrides the tenant operations setting. |
143
+ | `end_speech` | end | `required` | `string` | Default goodbye line. A connection into this node can override it. |
144
+ | `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. |
145
+ | `ivr` | ivr | `required` | `object` | Announcement, digit table and wait time. input and max_retries are fixed; other values are rejected. |
146
+ | `transfer` | transfer | `required` | `object` | Transfer target and the line spoken before transferring. |
147
+ | `notify` | notify | `required` | `object` | Recipients, subject and body templates. |
148
+ | `http_method` | webhook | `required` | `string` | GET, POST, PUT, PATCH or DELETE. |
149
+ | `endpoint_url` | webhook | `required` | `string` | Destination URL. |
150
+ | `payload_template` | webhook | `required` | `string` | Request body template with {{variables}}. |
151
+ | `custom_headers` | webhook | `advanced` | `{ key, value }[]` | Extra request headers. |
152
+ | `qa_system_prompt` | qa | `required` | `string` | Evaluation prompt. |
153
+ | `qa_sample_rate` | qa | `required` | `number` | Percentage of calls analysed, 1 to 100. |
154
+ | `qa_min_call_duration` | qa | `required` | `number` | Shortest call (seconds) that is analysed. |
155
+ | `qa_model` | qa | `advanced` | `string` | Model override for this analysis. |
156
+ | `qa_voicemail_calls` | qa | `advanced` | `boolean` | Whether voicemail calls are analysed (default true). |
157
+
158
+ A required item's 種類 is stored as a pair on the item: `source` and `value_type`.
159
+ These are the pairs the Portal offers:
160
+
161
+ | 種類 | `source` | `value_type` |
162
+ | --- | --- | --- |
163
+ | お客様の言葉のまま (`verbatim`) | `caller` | `text` |
164
+ | AIがまとめた内容 (`summary`) | `derived` | `text` |
165
+ | 番号 (`code`) | `caller` | `code` |
166
+ | 電話番号 (`phone`) | `caller` | `phone` |
167
+ | 生年月日 (`birthdate`) | `caller` | `birthdate` |
168
+ | 日時 (`datetime`) | `caller` | `datetime` |
169
+ | 選択肢 (`select`) | `derived` | `select` |
170
+ | ツールの結果 (`tool`) | `tool` | `text` |
171
+ <!-- END node-config-reference -->
172
+
173
+ The `internal` keys that are settings, not bookkeeping, have no Portal screen:
174
+
175
+ - `wait_cover` at the agent level (`model_config.wait_cover`): `threshold_ms`,
176
+ `on_threshold`, `on_query_start` and `query_grace_ms` have a card in the agent's 会話の運用 / edit screen (cascaded agents);
177
+ `text` and the repeat settings are API only. The node has a row in 「動きの調整」
178
+ for the first two; a node value overrides the agent's.
179
+ - `ivr.input` and `ivr.max_retries` (IVR nodes) — fixed. `input` must be one digit
180
+ with no finish key (`{ "mode": "single", "max_digits": 1, "finish_key": null }`)
181
+ and `max_retries` must be `0`; any other value makes the patch fail. Only
182
+ `ivr.timeout_ms` (3000–30000, default 8000) can change.
183
+
184
+ A required item whose 種類 is 選択肢 (`derived` / `select`) needs its options in
185
+ the item's `options`: the AI picks one of them and the write is checked
186
+ against the list. Give it at least two. There is no yes/no 種類; for yes/no, use 選択肢
187
+ with two options. A ツールの結果 (`tool` / `text`) item names its tool and result
188
+ field in the item's `tool` as `{ "tool_key": "…", "result_field": "…" }`;
189
+ only that tool succeeding at this step records it. Keys in `optional_slots` are
190
+ recorded only when the caller says them first; they are not required at that step.
73
191
 
74
192
  ## When it refuses
75
193
 
@@ -78,10 +196,24 @@ agent language setting. Those are Portal-only.
78
196
  tenant administrator (`kumion auth status` shows its expiry). The user re-runs
79
197
  `kumion auth login`.
80
198
  - **403 naming a scope** — the key lacks it (`agents:read`, `agents:write`,
81
- `agents:publish`, `tests:run`, `calls:create`, `calls:read`). The user issues a key with that scope
199
+ `agents:publish`, `agents:live`, `tests:run`, `calls:create`, `calls:read`). The user issues a key with that scope
82
200
  in the Portal (設定 → 開発者) and logs in again. Do not work around it.
83
201
  - **403 without a scope name** — the tenant's plan cannot publish, or `create_call` hit
84
202
  the call-minute limit. Tell the user; a new key does not help.
203
+ - **422 on publish with only a message** — a check before the test calls refused,
204
+ so no test ran. The body is `{ "error": "…" }`: no code, no test cases, no publish
205
+ run, and the CLI prints that message after `Server said:`. Most often it is the
206
+ dependency check. Its message is one Japanese sentence per problem, one per line,
207
+ each naming what is missing: コンタクト not connected, a コンタクト照合 item not set
208
+ or too few, the 予約カレンダー not connected, a tool the graph names that the
209
+ tenant does not have enabled, a 先に受け取れる項目 (`optional_slots` key) that no
210
+ step requires, or a connection whose condition reads a value nothing produces. The
211
+ other checks that answer the same way are an IVR node's settings, a transfer
212
+ target, a 会話の運用 move-to node, and a language that is no longer offered. Read
213
+ each line and fix what it names: a graph problem in the draft; a connection,
214
+ calendar or tool in the Portal, which you cannot change, so tell the user. Then
215
+ publish again. The CLI has no other way to list these reasons; in the Portal the
216
+ canvas's 「フローの問題」 list shows the dependency findings.
85
217
  - **429** — rate limited; wait the stated seconds.
86
218
 
87
219
  Callers hear what is published. Say clearly to the user what you changed in the draft,