@kumion/cli 0.6.2 → 0.6.3

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
@@ -140,7 +140,7 @@ would use.
140
140
  | `kumion documents jobs get <jobId>` | `agents:read` (exits 1 when the job failed or timed out) |
141
141
  | `kumion documents get <documentId>` | `agents:read` |
142
142
  | `kumion documents replace <documentId> --source <sourceDocumentId> --source-revision <rev> --revision <rev> [--dry-run]` | `agents:live` (live: no publish) |
143
- | `kumion test-runs start <agentId> [--no-wait] [--interval <sec>] [--timeout <sec>]` | `tests:run` |
143
+ | `kumion test-runs start <agentId> [--turns <file\|->] [--no-wait] [--interval <sec>] [--timeout <sec>]` | `tests:run` |
144
144
  | `kumion test-runs get <agentId> <runId>` | `tests:run` |
145
145
  | `kumion test-runs list <agentId>` | `tests:run` |
146
146
  | `kumion calls create <agentId> [--to <phone>] [--campaign-contact <id>] [--var <name>=<value> ...]` | `calls:create` |
@@ -364,7 +364,7 @@ A key a node does not store follows the agent's setting (会話の運用) or the
364
364
  | `wait_cover` | start, agent | `tune` | `{ enabled?, on_threshold?, threshold_ms?, on_query_start?, query_grace_ms? }` | Node-level hold phrase. By default it plays only when a lookup tool is still running after `query_grace_ms` (100 to 10000, default 1000); `on_query_start: false` turns that off. `on_threshold: true` also plays it after `threshold_ms` (2000 to 15000, default 2000) of silence on an ordinary turn (default off). `enabled: false` turns it off for this node. The phrase text is set per agent. |
365
365
  | `trigger_path` | trigger | `internal` | `string` | Generated. Shown read-only as the trigger URL. |
366
366
  | `opening_speech` | start | `required` | `string` | The opening line. Supports {{variables}}. |
367
- | `items` | start, agent | `required` | `{key,label?,example?,source?,value_type?,options?,must_ask?,min_digits?,max_digits?,tool?,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). |
367
+ | `items` | start, agent | `required` | `{key,label?,example?,source?,value_type?,options?,must_ask?,min_digits?,max_digits?,tool?}[]` | What this step collects, one object per item, in the order it asks. `key`: slot key. `label`: display name. `example`: test-call example. `source`: where the value comes from (caller, derived, system, tool). `value_type`: kind (text, select, boolean, ...). `options`: choices of a select item. `must_ask`: ask the caller to confirm on the spot even if already known (advanced). `min_digits` / `max_digits`: for a `code` item, the fewest / most digits the value may hold, counted by the platform (the same number twice = exact length). `tool`: `{tool_key,result_field}` for a tool-sourced item. |
368
368
  | `allow_interruptions` | start, agent | `tune` | `boolean` | Absent means the caller may interrupt. Only an explicit false is stored. |
369
369
  | `route_judge` | start | `tune` | `boolean` | Absent means off. Only an explicit true is stored. On: while the call stays on this start step, each caller turn is first read by the call model's own probability readout (at most 400 ms, before the AI answers); when it is sure which of the step's three connections fits, the call moves on without a model turn. Offered only for a call model whose endpoint has a calibrated readout; the step needs exactly three AI connections without items and no fixed connections (graph diagnostics `route_judge_not_applicable`). |
370
370
  | `wait_for_first_word` | start | `tune` | `boolean` | Absent means off. Only an explicit true is stored. On: an outbound call waits for the customer to speak first and says the opening line when they finish or `first_word_wait_seconds` runs out. An inbound call never reads it (graph diagnostics `first_word_wait_outbound_only`). |
@@ -438,6 +438,30 @@ each re-run's outcome. When a check before the test calls refuses (most often th
438
438
  cases to print: the server's message after `Server said:` is the whole reason, one
439
439
  problem per line.
440
440
 
441
+ ### Replaying a caller's own lines
442
+
443
+ `test-runs start` builds the caller's side from the examples in the flow. To run the lines of a
444
+ real call that failed, hand them over instead:
445
+
446
+ ```sh
447
+ kumion test-runs start <agentId> --turns lines.json # or: ... --turns - < lines.json
448
+ ```
449
+
450
+ `lines.json` is `["予約したいです", "山田太郎です"]` or `[{ "caller": "予約したいです" }, ...]`
451
+ (MCP: `start_test_run` with `turns`; HTTP: `POST .../test-runs` with `{ "turns": [{ "caller": "..." }] }`).
452
+ The lines go to the draft one per turn, in order. Nothing is graded and no "please hang up" line is added:
453
+ the result is the conversation, the path the call took, the tool calls and a trace (`event`, `tool`,
454
+ `status`, a short `detail`). `stopReason` says why it stopped: `lines_done` (every line played, the
455
+ call still going), `agent_ended` (the agent ended the call first; the lines never sent are in
456
+ `unsentLines`) or `reply_timeout` (a line got no answer in time). The run ends `completed` and the
457
+ CLI exits 0 in all three; `could_not_run`, `timeout` and `cancelled` exit 1.
458
+
459
+ Limits: at most 30 lines, 500 characters per line and 6,000 characters in all (more is `400
460
+ replay_too_long`). One test run per agent at a time (`409`) and the same hourly limit per key as a
461
+ suite run (`429`). A replay needs the same `tests:run` scope, publishes nothing, makes no call in the
462
+ tenant's call history and counts against no call quota. The lines may hold what a real caller said:
463
+ they are kept in the run's results for as long as any test run is.
464
+
441
465
  ## From a template to public
442
466
 
443
467
  One path from an empty tenant to a published agent, with nothing but the CLI (each command is also
package/dist/cli.js CHANGED
@@ -50,6 +50,12 @@ async function prompt(question, options = {}) {
50
50
  stdin.on("data", onData);
51
51
  });
52
52
  }
53
+ async function readStdin() {
54
+ const chunks = [];
55
+ for await (const chunk of process.stdin)
56
+ chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
57
+ return Buffer.concat(chunks).toString("utf8");
58
+ }
53
59
  const io = {
54
60
  out: (text) => process.stdout.write(text.endsWith("\n") ? text : text + "\n"),
55
61
  err: (text) => process.stderr.write(text.endsWith("\n") ? text : text + "\n"),
@@ -68,6 +74,7 @@ const code = await run(process.argv.slice(2), {
68
74
  config: ConfigFile.forEnv(process.env),
69
75
  io,
70
76
  sleep: (ms) => sleep(ms),
77
+ readStdin,
71
78
  mcpTransport: stdioTransport,
72
79
  });
73
80
  process.exitCode = code;
package/dist/client.js CHANGED
@@ -243,8 +243,10 @@ export class KumionClient {
243
243
  });
244
244
  return body;
245
245
  }
246
- async startTestRun(agentId) {
247
- const { body } = await this.request("POST", this.agentPath(agentId, "/test-runs"), "tests:run", { body: {} });
246
+ async startTestRun(agentId, turns) {
247
+ const { body } = await this.request("POST", this.agentPath(agentId, "/test-runs"), "tests:run", {
248
+ body: turns ? { turns } : {},
249
+ });
248
250
  return body.testRun;
249
251
  }
250
252
  async getTestRun(agentId, runId) {
package/dist/main.js CHANGED
@@ -5,7 +5,7 @@ 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.6.2";
8
+ export const VERSION = "0.6.3";
9
9
  const HELP = `kumion — manage your Kumion voice agents over the Partner API
10
10
 
11
11
  Usage: kumion <command> [options]
@@ -184,8 +184,16 @@ Documents (資料 — the source an agent's facts are extracted from)
184
184
  LIVE: the next call reads the new facts. Needs agents:live
185
185
 
186
186
  Test runs
187
- test-runs start <agentId> [--no-wait] [--interval <sec>] [--timeout <sec>]
188
- Run the agent's regression tests against its draft
187
+ test-runs start <agentId> [--turns <file|->] [--no-wait] [--interval <sec>] [--timeout <sec>]
188
+ Run the agent's regression tests against its draft.
189
+ With --turns, play the caller's own lines instead of the
190
+ suite's: a JSON file (or - for stdin) holding ["line", ...]
191
+ or [{ "caller": "line" }, ...], at most 30 lines, 500
192
+ characters each and 6,000 in all. The lines go in order,
193
+ nothing is graded, and the result is the conversation, the
194
+ path, the tool calls and the trace. Exit 0 once the lines
195
+ were played or the call ended first. The lines may hold
196
+ what a real caller said; the run keeps them like any run
189
197
  test-runs get <agentId> <runId> Show one run and its results
190
198
  test-runs list <agentId> [--limit <n>]
191
199
 
@@ -1778,8 +1786,64 @@ async function flowEditSteps(args, deps) {
1778
1786
  deps.io.out(lines.join("\n"));
1779
1787
  return 0;
1780
1788
  }
1781
- const TERMINAL = new Set(["passed", "failed", "could_not_run", "timeout", "cancelled"]);
1789
+ const TERMINAL = new Set(["passed", "failed", "could_not_run", "timeout", "cancelled", "completed"]);
1790
+ export function replayTurnsFrom(raw) {
1791
+ if (!Array.isArray(raw) || raw.length === 0) {
1792
+ throw new UsageError('--turns needs a JSON array of lines: ["line", ...] or [{ "caller": "line" }, ...].');
1793
+ }
1794
+ return raw.map((item, index) => {
1795
+ const caller = typeof item === "string" ? item : item && typeof item === "object" ? item.caller : undefined;
1796
+ if (typeof caller !== "string" || caller.trim() === "") {
1797
+ throw new UsageError(`--turns: item ${index} must be a non-empty string or { "caller": "..." }.`);
1798
+ }
1799
+ return { caller };
1800
+ });
1801
+ }
1802
+ async function readTurns(source, deps) {
1803
+ let text;
1804
+ if (source === "-") {
1805
+ if (!deps.readStdin)
1806
+ throw new UsageError("--turns - needs stdin, which this host does not provide.");
1807
+ text = await deps.readStdin();
1808
+ }
1809
+ else {
1810
+ text = await readTextFile(source);
1811
+ }
1812
+ try {
1813
+ return replayTurnsFrom(JSON.parse(text));
1814
+ }
1815
+ catch (err) {
1816
+ if (err instanceof UsageError)
1817
+ throw err;
1818
+ throw new UsageError(`--turns ${source === "-" ? "(stdin)" : source} is not valid JSON: ${err.message}`);
1819
+ }
1820
+ }
1821
+ const STOP_REASON_TEXT = {
1822
+ lines_done: "all lines were played and the call was still going",
1823
+ agent_ended: "the agent ended the call before the lines ran out",
1824
+ reply_timeout: "the agent did not answer a line in time",
1825
+ };
1826
+ export function summarizeReplay(run) {
1827
+ const lines = [`Replay ${run.id}: ${run.status.toUpperCase()}`];
1828
+ const result = (run.results ?? []).find((r) => r.caseId === "replay");
1829
+ if (!result)
1830
+ return lines.join("\n");
1831
+ lines.push(`Stopped: ${result.stopReason ? `${result.stopReason} (${STOP_REASON_TEXT[result.stopReason] ?? result.stopReason})` : "unknown"}`);
1832
+ for (const [i, turn] of (result.turns ?? []).entries()) {
1833
+ lines.push(`#${i + 1} caller: ${turn.user}`, `#${i + 1} agent : ${turn.assistant || "(no reply)"} [${turn.nodeKey}]`);
1834
+ }
1835
+ if (result.unsentLines?.length)
1836
+ lines.push(`Not sent (${result.unsentLines.length}): ${result.unsentLines.join(" / ")}`);
1837
+ if (result.observedPath?.length)
1838
+ lines.push(`Path: ${result.observedPath.join(" → ")}${result.reachedEnd ? " (call ended)" : ""}`);
1839
+ for (const row of result.trace ?? []) {
1840
+ lines.push(`trace #${row.turn} ${row.event} ${row.tool ?? ""} ${row.status ?? ""} ${JSON.stringify(row.detail)}`.replace(/ {2,}/g, " "));
1841
+ }
1842
+ return lines.join("\n");
1843
+ }
1782
1844
  export function summarizeTestRun(run) {
1845
+ if (run.kind === "replay")
1846
+ return summarizeReplay(run);
1783
1847
  const lines = [
1784
1848
  `Test run ${run.id}: ${run.status.toUpperCase()} (${run.casesDone}/${run.casesTotal} cases)`,
1785
1849
  ];
@@ -1810,12 +1874,14 @@ async function testRunsStart(args, deps) {
1810
1874
  "no-wait": { type: "boolean" },
1811
1875
  interval: { type: "string" },
1812
1876
  timeout: { type: "string" },
1877
+ turns: { type: "string" },
1813
1878
  });
1814
1879
  const agentId = need(positionals, 0, "agentId");
1815
1880
  const intervalMs = positiveNumber(values.interval, "interval", 3) * 1000;
1816
1881
  const timeoutMs = positiveNumber(values.timeout, "timeout", 900) * 1000;
1817
1882
  const client = await clientFor(values, deps);
1818
- let run = await client.startTestRun(agentId);
1883
+ const turns = values.turns === undefined ? undefined : await readTurns(values.turns, deps);
1884
+ let run = await client.startTestRun(agentId, turns);
1819
1885
  if (values["no-wait"]) {
1820
1886
  if (values.json)
1821
1887
  printJson(deps, { testRun: run });
@@ -1843,7 +1909,7 @@ async function testRunsStart(args, deps) {
1843
1909
  printJson(deps, { testRun: run });
1844
1910
  else
1845
1911
  deps.io.out(summarizeTestRun(run));
1846
- return run.status === "passed" ? 0 : 1;
1912
+ return run.status === "passed" || run.status === "completed" ? 0 : 1;
1847
1913
  }
1848
1914
  async function testRunsGet(args, deps) {
1849
1915
  const { values, positionals } = parse(args, {});
package/dist/mcp.js CHANGED
@@ -5,7 +5,7 @@ import { z } from "zod";
5
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
- const TERMINAL = new Set(["passed", "failed", "could_not_run", "timeout", "cancelled"]);
8
+ const TERMINAL = new Set(["passed", "failed", "could_not_run", "timeout", "cancelled", "completed"]);
9
9
  function json(value) {
10
10
  return { content: [{ type: "text", text: JSON.stringify(value, null, 2) }] };
11
11
  }
@@ -196,8 +196,8 @@ export function createKumionMcpServer(client, options) {
196
196
  "assistant does. `ops` is a batch, run in order, at most 20: each element is `{ op, …that operation's " +
197
197
  "arguments }`, with `op` one of set_node_field (nodeKey, field, value), set_edge_words (fromKey, toKey, " +
198
198
  "condition?, transitionSpeech?), add_step (type `agent`|`transfer`, name, between?, next_condition?, prompt?, " +
199
- "items?, staff?, before_speech?, key?), remove_step (node), connect_steps (from, to, condition, speech?, " +
200
- "only_when?), reconnect (from, to, new_to, via_tool?), disconnect (from, to, via_tool?). The batch is atomic: " +
199
+ "items?, staff?, before_speech?, key?), remove_step (node), connect_steps (from, to, condition, speech?), " +
200
+ "reconnect (from, to, new_to, via_tool?), disconnect (from, to, via_tool?). The batch is atomic: " +
201
201
  "one refused operation refuses all of them, and nothing is stored. `add_step.key` (optional, lowercase " +
202
202
  "letters/digits/_) names the new step so a later operation of the same batch can point at it; without one the " +
203
203
  "server picks the key and returns it in `added`. A 用件 flow (`editLayer` = `flow`) is refused: use " +
@@ -322,7 +322,8 @@ export function createKumionMcpServer(client, options) {
322
322
  server.registerTool("start_test_run", {
323
323
  description: "Run the agent's regression tests against its draft (publishes nothing). Returns at once with the run " +
324
324
  `unless waitSeconds is set (at most ${MAX_TEST_RUN_WAIT_SECONDS}); follow a running run with ` +
325
- "get_test_run. Needs tests:run.",
325
+ "get_test_run. With turns, plays those caller lines in order instead of the suite's (nothing is graded; " +
326
+ "the result is the conversation, path, tool calls and trace). Needs tests:run.",
326
327
  inputSchema: {
327
328
  agentId,
328
329
  waitSeconds: z
@@ -332,9 +333,14 @@ export function createKumionMcpServer(client, options) {
332
333
  .max(MAX_TEST_RUN_WAIT_SECONDS)
333
334
  .optional()
334
335
  .describe("Wait up to this many seconds for the run to finish before returning."),
336
+ turns: z
337
+ .array(z.object({ caller: z.string().min(1) }))
338
+ .optional()
339
+ .describe("The caller's own lines, played in order instead of the suite: [{ caller }]. At most 30 lines, 500 characters each, 6000 in all. " +
340
+ "The lines may hold what a real caller said; the run keeps them like any test run."),
335
341
  },
336
342
  }, (args) => attempt(async () => {
337
- let run = await client.startTestRun(args.agentId);
343
+ let run = await client.startTestRun(args.agentId, args.turns);
338
344
  const deadline = (args.waitSeconds ?? 0) * 1000;
339
345
  let waited = 0;
340
346
  while (!TERMINAL.has(run.status) && waited < deadline) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kumion/cli",
3
- "version": "0.6.2",
3
+ "version": "0.6.3",
4
4
  "description": "Manage your Kumion voice agents from the terminal over the Kumion Partner API",
5
5
  "author": "KAOPA株式会社",
6
6
  "license": "MIT",
@@ -83,7 +83,11 @@ A partner with several customers has one profile per customer tenant
83
83
  (only when the user gave the name and number), then use the key it returns.
84
84
  4. **Test** — `start_test_run` (then `get_test_run` until it leaves `running`) /
85
85
  `kumion test-runs start <agentId>` (waits; exit 0 only on pass). Fix failures in
86
- the draft and test again.
86
+ the draft and test again. To re-run the words of a real call that went wrong, pass
87
+ them with `turns` / `--turns <file|->` (at most 30 lines, 500 characters each,
88
+ 6,000 in all): they are played in order, nothing is graded, and the run ends
89
+ `completed` with the conversation, path, tool calls and trace. The lines may hold
90
+ what a real caller said; do not paste them anywhere else.
87
91
  5. **Publish** — only when the user asked for it. `publish_agent` /
88
92
  `kumion agents publish <agentId>`. It runs the same pre-publish check as the Portal
89
93
  and can take a few minutes. If the check fails, nothing goes live and the failing
@@ -266,7 +270,7 @@ A key a node does not store follows the agent's setting (会話の運用) or the
266
270
  | `wait_cover` | start, agent | `tune` | `{ enabled?, on_threshold?, threshold_ms?, on_query_start?, query_grace_ms? }` | Node-level hold phrase. By default it plays only when a lookup tool is still running after `query_grace_ms` (100 to 10000, default 1000); `on_query_start: false` turns that off. `on_threshold: true` also plays it after `threshold_ms` (2000 to 15000, default 2000) of silence on an ordinary turn (default off). `enabled: false` turns it off for this node. The phrase text is set per agent. |
267
271
  | `trigger_path` | trigger | `internal` | `string` | Generated. Shown read-only as the trigger URL. |
268
272
  | `opening_speech` | start | `required` | `string` | The opening line. Supports {{variables}}. |
269
- | `items` | start, agent | `required` | `{key,label?,example?,source?,value_type?,options?,must_ask?,min_digits?,max_digits?,tool?,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). |
273
+ | `items` | start, agent | `required` | `{key,label?,example?,source?,value_type?,options?,must_ask?,min_digits?,max_digits?,tool?}[]` | What this step collects, one object per item, in the order it asks. `key`: slot key. `label`: display name. `example`: test-call example. `source`: where the value comes from (caller, derived, system, tool). `value_type`: kind (text, select, boolean, ...). `options`: choices of a select item. `must_ask`: ask the caller to confirm on the spot even if already known (advanced). `min_digits` / `max_digits`: for a `code` item, the fewest / most digits the value may hold, counted by the platform (the same number twice = exact length). `tool`: `{tool_key,result_field}` for a tool-sourced item. |
270
274
  | `allow_interruptions` | start, agent | `tune` | `boolean` | Absent means the caller may interrupt. Only an explicit false is stored. |
271
275
  | `route_judge` | start | `tune` | `boolean` | Absent means off. Only an explicit true is stored. On: while the call stays on this start step, each caller turn is first read by the call model's own probability readout (at most 400 ms, before the AI answers); when it is sure which of the step's three connections fits, the call moves on without a model turn. Offered only for a call model whose endpoint has a calibrated readout; the step needs exactly three AI connections without items and no fixed connections (graph diagnostics `route_judge_not_applicable`). |
272
276
  | `wait_for_first_word` | start | `tune` | `boolean` | Absent means off. Only an explicit true is stored. On: an outbound call waits for the customer to speak first and says the opening line when they finish or `first_word_wait_seconds` runs out. An inbound call never reads it (graph diagnostics `first_word_wait_outbound_only`). |