@roarkanalytics/sdk-mcp 4.44.2 → 4.44.4

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.
Files changed (69) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/client-headers.d.mts +2 -2
  3. package/client-headers.d.ts +2 -2
  4. package/client-headers.js +1 -1
  5. package/client-headers.mjs +1 -1
  6. package/directory-output-schemas.d.mts +139 -0
  7. package/directory-output-schemas.d.mts.map +1 -0
  8. package/directory-output-schemas.d.ts +139 -0
  9. package/directory-output-schemas.d.ts.map +1 -0
  10. package/directory-output-schemas.js +191 -0
  11. package/directory-output-schemas.js.map +1 -0
  12. package/directory-output-schemas.mjs +188 -0
  13. package/directory-output-schemas.mjs.map +1 -0
  14. package/directory-tools.d.mts.map +1 -1
  15. package/directory-tools.d.ts.map +1 -1
  16. package/directory-tools.js +232 -111
  17. package/directory-tools.js.map +1 -1
  18. package/directory-tools.mjs +232 -111
  19. package/directory-tools.mjs.map +1 -1
  20. package/docs-search-tool.d.mts.map +1 -1
  21. package/docs-search-tool.d.ts.map +1 -1
  22. package/docs-search-tool.js +6 -3
  23. package/docs-search-tool.js.map +1 -1
  24. package/docs-search-tool.mjs +6 -3
  25. package/docs-search-tool.mjs.map +1 -1
  26. package/http.d.mts.map +1 -1
  27. package/http.d.ts.map +1 -1
  28. package/http.js +8 -7
  29. package/http.js.map +1 -1
  30. package/http.mjs +9 -8
  31. package/http.mjs.map +1 -1
  32. package/oauth.d.mts +16 -1
  33. package/oauth.d.mts.map +1 -1
  34. package/oauth.d.ts +16 -1
  35. package/oauth.d.ts.map +1 -1
  36. package/oauth.js +24 -1
  37. package/oauth.js.map +1 -1
  38. package/oauth.mjs +22 -0
  39. package/oauth.mjs.map +1 -1
  40. package/options.d.mts +10 -0
  41. package/options.d.mts.map +1 -1
  42. package/options.d.ts +10 -0
  43. package/options.d.ts.map +1 -1
  44. package/options.js +28 -3
  45. package/options.js.map +1 -1
  46. package/options.mjs +26 -3
  47. package/options.mjs.map +1 -1
  48. package/package.json +11 -1
  49. package/server.d.mts.map +1 -1
  50. package/server.d.ts.map +1 -1
  51. package/server.js +8 -1
  52. package/server.js.map +1 -1
  53. package/server.mjs +8 -1
  54. package/server.mjs.map +1 -1
  55. package/src/client-headers.ts +1 -1
  56. package/src/directory-output-schemas.ts +240 -0
  57. package/src/directory-tools.ts +267 -97
  58. package/src/docs-search-tool.ts +9 -3
  59. package/src/http.ts +9 -7
  60. package/src/oauth.ts +28 -1
  61. package/src/options.ts +27 -3
  62. package/src/server.ts +9 -1
  63. package/src/types.ts +1 -0
  64. package/types.d.mts +1 -0
  65. package/types.d.mts.map +1 -1
  66. package/types.d.ts +1 -0
  67. package/types.d.ts.map +1 -1
  68. package/types.js.map +1 -1
  69. package/types.mjs.map +1 -1
@@ -9,6 +9,7 @@
9
9
  // The local code-execution server stays on `execute`. This file is not generated.
10
10
  import { APIError } from '@roarkanalytics/sdk';
11
11
  import { asErrorResult, asTextContentResult, } from "./types.mjs";
12
+ import { directoryOutputSchemas } from "./directory-output-schemas.mjs";
12
13
  /**
13
14
  * Server instructions for the directory surface.
14
15
  *
@@ -103,30 +104,39 @@ class ToolInputError extends Error {
103
104
  this.name = 'ToolInputError';
104
105
  }
105
106
  }
107
+ // Every tool talks only to the Roark API, so openWorldHint is false, except
108
+ // run_simulation, which places phone calls to the agent under test.
106
109
  const readAnnotations = (title) => ({
107
110
  title,
108
111
  readOnlyHint: true,
109
112
  destructiveHint: false,
113
+ idempotentHint: true,
114
+ openWorldHint: false,
110
115
  });
111
- const writeAnnotations = (title) => ({
116
+ // Each write creates a new record, so repeating a call is not idempotent.
117
+ const writeAnnotations = (title, { openWorld = false } = {}) => ({
112
118
  title,
113
119
  readOnlyHint: false,
114
120
  destructiveHint: true,
121
+ idempotentHint: false,
122
+ openWorldHint: openWorld,
115
123
  });
116
124
  const projectProperty = {
117
125
  type: 'string',
118
126
  description: 'Roark project id. Required when this connection is not already pinned to one project. list_projects returns the ids this credential can use.',
119
127
  };
120
- const pagingProperties = {
128
+ /** `after` and `limit`, with the page size the endpoint uses when `limit` is omitted. */
129
+ const paging = (defaultLimit) => ({
121
130
  after: {
122
131
  type: 'string',
123
- description: 'Cursor from a previous response. Omit for the first page.',
132
+ description: 'Paging cursor: pass pagination.nextCursor from the previous response to get the next page. Omit for the first page.',
124
133
  },
125
134
  limit: {
126
135
  type: 'number',
127
- description: 'Maximum number of rows to return.',
136
+ description: `Page size: the most rows one response returns. When omitted, the API returns up to ${defaultLimit}.`,
128
137
  },
129
- };
138
+ });
139
+ const pagingProperties = paging(20);
130
140
  const objectSchema = (properties, required) => ({
131
141
  type: 'object',
132
142
  properties,
@@ -331,9 +341,17 @@ const callListQuery = (args) => omitUndefined({
331
341
  after: optionalString(args, 'after'),
332
342
  limit: optionalLimit(args),
333
343
  });
344
+ // Every tool declares an outputSchema, so the response body is also returned as
345
+ // structuredContent. The JSON text stays for clients that read only content.
334
346
  const callApi = async (fn) => {
335
347
  try {
336
- return asTextContentResult(await fn());
348
+ const result = await fn();
349
+ // A tool with an outputSchema must return structuredContent, which is an object. The API
350
+ // always answers with { data, ... }; anything else is reported rather than sent unstructured.
351
+ if (!isRecord(result)) {
352
+ return asErrorResult(`Unexpected response from the Roark API: ${JSON.stringify(result) ?? 'empty'}`);
353
+ }
354
+ return { ...asTextContentResult(result), structuredContent: result };
337
355
  }
338
356
  catch (error) {
339
357
  if (error instanceof ToolInputError || error instanceof APIError || error instanceof Error) {
@@ -343,22 +361,26 @@ const callApi = async (fn) => {
343
361
  }
344
362
  };
345
363
  const handler = (fn) => async ({ reqContext, args, }) => callApi(() => fn(reqContext, args ?? {}));
346
- const defineTool = (name, title, description, inputSchema, annotations, metadata, fn) => ({
364
+ const defineTool = (name, title, description, inputSchema, outputSchema, annotations, metadata, fn) => ({
347
365
  metadata,
348
366
  tool: {
349
367
  name,
350
368
  title,
351
369
  description,
352
370
  inputSchema,
371
+ outputSchema,
353
372
  annotations,
354
373
  },
355
374
  handler: handler(fn),
356
375
  });
357
376
  const endpointSchema = {
358
377
  type: 'object',
359
- description: 'An agent endpoint Roark dials or connects to.',
378
+ description: 'An agent endpoint the run tests.',
360
379
  properties: {
361
- id: { type: 'string', description: 'Agent endpoint id from list_agent_endpoints.' },
380
+ id: {
381
+ type: 'string',
382
+ description: 'Agent endpoint id, from list_agent_endpoints or create_agent_endpoint.',
383
+ },
362
384
  },
363
385
  required: ['id'],
364
386
  };
@@ -366,8 +388,11 @@ const metricRefSchema = {
366
388
  type: 'object',
367
389
  description: 'A metric to score, by id or by slug.',
368
390
  properties: {
369
- id: { type: 'string', description: 'Metric definition id.' },
370
- slug: { type: 'string', description: 'Metric slug, such as call_outcome.' },
391
+ id: { type: 'string', description: 'Metric definition id, from list_metric_definitions.' },
392
+ slug: {
393
+ type: 'string',
394
+ description: 'Metric slug, from list_metric_definitions. Use instead of id.',
395
+ },
371
396
  },
372
397
  };
373
398
  // A {{variable}} name to value map. The API takes string values only.
@@ -378,30 +403,47 @@ const stringMapSchema = (description) => ({
378
403
  });
379
404
  const flowAttachmentSchema = {
380
405
  type: 'object',
381
- description: 'A customer flow to include. Set happyPath, edgeCases, or both. id comes from list_customer_flows.',
406
+ description: 'A customer flow to include. Name it by id or slug, and set happyPath, edgeCases, or both.',
382
407
  properties: {
383
- id: { type: 'string', description: 'Customer flow id.' },
384
- slug: { type: 'string', description: 'Roark-curated flow slug, used instead of id.' },
385
- happyPath: { type: 'boolean', description: 'Whether to run the flow happy path.' },
408
+ id: {
409
+ type: 'string',
410
+ description: 'Customer flow id, from list_customer_flows or create_customer_flow.',
411
+ },
412
+ slug: {
413
+ type: 'string',
414
+ description: 'Stable slug of a flow Roark provides, used instead of id. GET /v1/simulation/template lists them. Flows made in the project have no slug.',
415
+ },
416
+ happyPath: { type: 'boolean', description: 'true runs the flow happy path.' },
386
417
  edgeCases: {
387
418
  type: ['string', 'array'],
388
- description: 'The string ALL runs every edge case. An array runs only the listed edge cases, each named by id or slug.',
419
+ description: 'The string ALL runs every edge case the flow has when the run starts. An array runs only the listed edge cases, each named by id or slug.',
389
420
  items: {
390
421
  type: 'object',
391
422
  properties: {
392
- id: { type: 'string', description: 'Edge case id from list_customer_flows.' },
393
- slug: { type: 'string', description: 'Edge case slug, used instead of id.' },
423
+ id: {
424
+ type: 'string',
425
+ description: "Edge case id, from the flow's edgeCases in list_customer_flows.",
426
+ },
427
+ slug: {
428
+ type: 'string',
429
+ description: 'Stable slug of an edge case Roark provides, matched within this flow. Used instead of id.',
430
+ },
394
431
  personaOverrideId: {
395
432
  type: 'string',
396
- description: 'Persona id to use for this edge case.',
433
+ description: 'Persona id, from list_personas, to run this edge case as instead of its own persona.',
397
434
  },
398
- variables: stringMapSchema('Values for this edge case only.'),
435
+ variables: stringMapSchema('Values for the {{variables}} in this edge case only, as variable name to string value.'),
399
436
  },
400
437
  },
401
438
  },
402
- personaOverrideId: { type: 'string', description: 'Persona id to use for this attachment.' },
439
+ personaOverrideId: {
440
+ type: 'string',
441
+ description: 'Persona id, from list_personas, to run everything in this flow as instead of its own persona.',
442
+ },
403
443
  },
404
444
  };
445
+ const callIdDescription = 'Roark call id, from list_calls.';
446
+ const directionDescription = 'INBOUND: the simulated caller phones the agent. OUTBOUND: the agent places the call to the simulated caller.';
405
447
  const buildRunBody = (args) => {
406
448
  const hasPlanId = args['planId'] !== undefined;
407
449
  const hasPlan = args['plan'] !== undefined;
@@ -555,50 +597,63 @@ const buildEndpointBody = (args) => {
555
597
  */
556
598
  export function directoryTools() {
557
599
  return [
558
- defineTool('list_projects', 'List projects', 'Lists the Roark projects this credential can use, with the permissions it holds in each. Returns each project id, name, slug, and organization.', objectSchema({}), readAnnotations('List projects'), readMeta('project', '/v1/projects'), async (reqContext) => reqContext.client.project.list()),
559
- defineTool('list_agents', 'List agents', 'Lists voice and chat agents in a Roark project. Returns each agent id, name, custom id, and description.', objectSchema({
600
+ defineTool('list_projects', 'List projects', 'Lists the Roark projects this credential can use, with the permissions it holds in each. Returns each project id, name, slug, and organization.', objectSchema({}), directoryOutputSchemas.listProjects, readAnnotations('List projects'), readMeta('project', '/v1/projects'), async (reqContext) => reqContext.client.project.list()),
601
+ defineTool('list_agents', 'List agents', 'Lists voice and chat agents in a Roark project, every agent unless searchText narrows it. Returns each agent id, name, custom id, and description, one page at a time.', objectSchema({
560
602
  project: projectProperty,
561
- searchText: { type: 'string', description: 'Match against agent name or description.' },
603
+ searchText: {
604
+ type: 'string',
605
+ description: 'Text to match against agent names and descriptions. When omitted, every agent is listed.',
606
+ },
562
607
  ...pagingProperties,
563
- }), readAnnotations('List agents'), readMeta('agent', '/v1/agent'), async (reqContext, args) => scopedClient(reqContext, args).agent.list(omitUndefined({
608
+ }), directoryOutputSchemas.listAgents, readAnnotations('List agents'), readMeta('agent', '/v1/agent'), async (reqContext, args) => scopedClient(reqContext, args).agent.list(omitUndefined({
564
609
  searchText: optionalString(args, 'searchText'),
565
610
  after: optionalString(args, 'after'),
566
611
  limit: optionalLimit(args),
567
612
  }))),
568
- defineTool('list_agent_endpoints', 'List agent endpoints', 'Lists the endpoints Roark uses to reach agents in a project. Returns each endpoint id, agent id, direction, type, and address. A simulation runs against an endpoint id.', objectSchema({
613
+ defineTool('list_agent_endpoints', 'List agent endpoints', 'Lists the endpoints Roark uses to reach agents in a project: phone numbers and other transports. Returns each endpoint id, agent id, direction, type, and address. A simulation runs against an endpoint id.', objectSchema({
569
614
  project: projectProperty,
570
- agentId: { type: 'string', description: 'Return endpoints for this agent only.' },
571
- searchText: { type: 'string', description: 'Match against endpoint address or environment name.' },
615
+ agentId: {
616
+ type: 'string',
617
+ description: "Agent id, from list_agents, to list only that agent's endpoints. When omitted, endpoints for every agent are listed.",
618
+ },
619
+ searchText: {
620
+ type: 'string',
621
+ description: 'Text to match against the endpoint address, such as a phone number, or its environment name.',
622
+ },
572
623
  ...pagingProperties,
573
- }), readAnnotations('List agent endpoints'), readMeta('agentEndpoint', '/v1/agent/endpoint'), async (reqContext, args) => scopedClient(reqContext, args).agentEndpoint.list(omitUndefined({
624
+ }), directoryOutputSchemas.listAgentEndpoints, readAnnotations('List agent endpoints'), readMeta('agentEndpoint', '/v1/agent/endpoint'), async (reqContext, args) => scopedClient(reqContext, args).agentEndpoint.list(omitUndefined({
574
625
  agentId: optionalString(args, 'agentId'),
575
626
  searchText: optionalString(args, 'searchText'),
576
627
  after: optionalString(args, 'after'),
577
628
  limit: optionalLimit(args),
578
629
  }))),
579
- defineTool('list_calls', 'List calls', 'Lists calls in a Roark project, including simulated and live calls. Returns call ids, status, direction, and timestamps. Does not include transcripts. ' +
580
- 'agentId is one agent UUID, or up to 100 comma-separated UUIDs with no spaces. ' +
581
- 'properties filters with one operator per name: eq is a case-insensitive exact match, and exists checks whether the property is set. ' +
582
- "Built-in agent_name, also accepted as agentName, matches any participating agent's current name. Built-in agent_id matches one agent UUID. Any other name is a custom property. " +
583
- 'sortBy is createdAt (the default), startedAt, endedAt, duration, title, or status, and sortDirection is desc (the default) or asc. The filters and the sort apply together.', objectSchema({
630
+ defineTool('list_calls', 'List calls', 'Lists calls in a Roark project, simulated and live. Returns call ids, status, direction, and timestamps, without transcripts. Every filter and the sort apply together. ' +
631
+ "properties filters on call properties: eq matches a value, ignoring case, and exists checks whether the property is set. The built-in agent_name, also accepted as agentName, matches any participating agent's current name, and agent_id matches one agent id. Any other name is a custom property.", objectSchema({
584
632
  project: projectProperty,
585
- searchText: { type: 'string', description: 'Match against call title, summary, or transcript text.' },
586
- status: { type: 'string', enum: [...CALL_STATUSES], description: 'Call status filter.' },
633
+ searchText: {
634
+ type: 'string',
635
+ description: 'Text to match against call titles, summaries, and transcripts.',
636
+ },
637
+ status: {
638
+ type: 'string',
639
+ enum: [...CALL_STATUSES],
640
+ description: 'Lifecycle state to list. When omitted, calls in every state are listed.',
641
+ },
587
642
  agentId: {
588
643
  type: 'string',
589
- description: 'One agent UUID, or up to 100 comma-separated UUIDs with no spaces. Returns calls that include any of these agents.',
644
+ description: 'Agent ids, from list_agents, to list only calls those agents took part in. Several ids go comma-separated with no spaces, at most 100.',
590
645
  },
591
646
  properties: {
592
647
  type: 'object',
593
- description: "One entry per property name, at most 20. Each entry sets eq (case-insensitive exact match, sent as properties[<name>][eq]=<value>) or exists (properties[<name>][exists]=true or false), and not both. agent_name (alias agentName) matches any participating agent's current name. agent_id takes one UUID. Any other name is a custom property.",
648
+ description: 'Call property filters, keyed by property name, at most 20. Each entry sets eq or exists, not both. agent_name (alias agentName) and agent_id are built in; any other name is a custom property set on the call.',
594
649
  additionalProperties: {
595
650
  type: 'object',
596
- description: 'Exactly one of eq or exists.',
651
+ description: 'One filter: eq or exists.',
597
652
  properties: {
598
- eq: { type: 'string', description: 'Case-insensitive exact match.' },
653
+ eq: { type: 'string', description: 'Value the property must equal, ignoring case.' },
599
654
  exists: {
600
655
  type: 'boolean',
601
- description: 'true: the property is set. false: the property is missing.',
656
+ description: 'true lists calls that have the property set. false lists calls that do not.',
602
657
  },
603
658
  },
604
659
  },
@@ -606,35 +661,35 @@ export function directoryTools() {
606
661
  sortBy: {
607
662
  type: 'string',
608
663
  enum: [...CALL_SORT_FIELDS],
609
- description: 'Field to sort by. createdAt is the default. Combines with the filters and with sortDirection.',
664
+ description: 'Call field the results are ordered by. When omitted, createdAt.',
610
665
  },
611
666
  sortDirection: {
612
667
  type: 'string',
613
668
  enum: [...SORT_DIRECTIONS],
614
- description: 'asc or desc. desc is the default. Combines with sortBy and the filters.',
669
+ description: 'asc puts the earliest or smallest first, desc the latest or largest. When omitted, desc.',
615
670
  },
616
671
  simulationRunPlanJobId: {
617
672
  type: 'string',
618
- description: 'Return calls from this simulation run only.',
673
+ description: 'Simulation run id, the simulationRunPlanJobId that run_simulation returns, to list only the calls that run placed.',
619
674
  },
620
675
  ...pagingProperties,
621
- }), readAnnotations('List calls'), readMeta('call', '/v1/call'), async (reqContext, args) => scopedClient(reqContext, args).call.list(callListQuery(args))),
676
+ }), directoryOutputSchemas.listCalls, readAnnotations('List calls'), readMeta('call', '/v1/call'), async (reqContext, args) => scopedClient(reqContext, args).call.list(callListQuery(args))),
622
677
  defineTool('get_call', 'Get call', 'Returns one call in a Roark project by its id, including status, direction, timestamps, and summary. Does not include the transcript.', objectSchema({
623
678
  project: projectProperty,
624
- callId: { type: 'string', description: 'Call id.' },
625
- }, ['callId']), readAnnotations('Get call'), readMeta('call', '/v1/call/{callId}'), async (reqContext, args) => scopedClient(reqContext, args).call.getByID(requireString(args, 'callId'))),
626
- defineTool('get_call_transcript', 'Get call transcript', 'Returns the transcript of one call in a Roark project: participants and the text of each turn, with timing.', objectSchema({
679
+ callId: { type: 'string', description: callIdDescription },
680
+ }, ['callId']), directoryOutputSchemas.getCall, readAnnotations('Get call'), readMeta('call', '/v1/call/{callId}'), async (reqContext, args) => scopedClient(reqContext, args).call.getByID(requireString(args, 'callId'))),
681
+ defineTool('get_call_transcript', 'Get call transcript', 'Returns the transcript of one call in a Roark project: who took part, and the text of each turn with its timing.', objectSchema({
627
682
  project: projectProperty,
628
- callId: { type: 'string', description: 'Call id.' },
683
+ callId: { type: 'string', description: callIdDescription },
629
684
  source: {
630
685
  type: 'string',
631
686
  enum: [...TRANSCRIPT_SOURCES],
632
- description: 'Transcription source. When omitted, the API uses the best source it has for the call.',
687
+ description: 'Which transcription to return: Roark post-call transcription, or the one the simulated caller or your agent captured live. When omitted, the first available of CUSTOMER_AGENT_REALTIME, SIMULATION_AGENT_REALTIME, then ROARK_POST_CALL.',
633
688
  },
634
- }, ['callId']), readAnnotations('Get call transcript'), readMeta('call', '/v1/call/{callId}/transcript'), async (reqContext, args) => scopedClient(reqContext, args).call.getTranscript(requireString(args, 'callId'), omitUndefined({ source: optionalEnum(args, 'source', TRANSCRIPT_SOURCES) }))),
635
- defineTool('list_call_metrics', 'List call metrics', 'Returns the metric scores recorded for one call in a Roark project. status success returns computed scores only. status all also returns rows that have no value. flatten true returns one row per score; when omitted, scores are grouped by metric.', objectSchema({
689
+ }, ['callId']), directoryOutputSchemas.getCallTranscript, readAnnotations('Get call transcript'), readMeta('call', '/v1/call/{callId}/transcript'), async (reqContext, args) => scopedClient(reqContext, args).call.getTranscript(requireString(args, 'callId'), omitUndefined({ source: optionalEnum(args, 'source', TRANSCRIPT_SOURCES) }))),
690
+ defineTool('list_call_metrics', 'List call metrics', 'Returns the metric scores recorded for one call in a Roark project, grouped by metric unless flatten is true.', objectSchema({
636
691
  project: projectProperty,
637
- callId: { type: 'string', description: 'Call id.' },
692
+ callId: { type: 'string', description: callIdDescription },
638
693
  flatten: {
639
694
  type: 'string',
640
695
  description: 'true returns one row per score. Any other value, or omitting it, groups scores by metric.',
@@ -642,13 +697,13 @@ export function directoryTools() {
642
697
  status: {
643
698
  type: 'string',
644
699
  enum: ['success', 'all'],
645
- description: 'success returns computed scores. all also returns rows with no value.',
700
+ description: 'success returns computed scores only. all also returns metrics with no value (not applicable, missing data, or an error), so a caller can tell a finished metric from one still computing. When omitted, success.',
646
701
  },
647
- }, ['callId']), readAnnotations('List call metrics'), readMeta('call', '/v1/call/{callId}/metrics'), async (reqContext, args) => scopedClient(reqContext, args).call.listMetrics(requireString(args, 'callId'), omitUndefined({
702
+ }, ['callId']), directoryOutputSchemas.listCallMetrics, readAnnotations('List call metrics'), readMeta('call', '/v1/call/{callId}/metrics'), async (reqContext, args) => scopedClient(reqContext, args).call.listMetrics(requireString(args, 'callId'), omitUndefined({
648
703
  flatten: optionalString(args, 'flatten'),
649
704
  status: optionalEnum(args, 'status', ['success', 'all']),
650
705
  }))),
651
- defineTool('list_metric_definitions', 'List metric definitions', 'Lists the metrics a Roark project can score, including built-in and custom metrics. Returns each metric id, slug, name, and type.', objectSchema({ project: projectProperty, ...pagingProperties }), readAnnotations('List metric definitions'), readMeta('metric', '/v1/metric/definitions'), async (reqContext, args) => scopedClient(reqContext, args).metric.listDefinitions(omitUndefined({ after: optionalString(args, 'after'), limit: optionalLimit(args) }))),
706
+ defineTool('list_metric_definitions', 'List metric definitions', 'Lists the metrics a Roark project can score, including built-in and custom metrics. Returns each metric id, slug, name, and type.', objectSchema({ project: projectProperty, ...paging(500) }), directoryOutputSchemas.listMetricDefinitions, readAnnotations('List metric definitions'), readMeta('metric', '/v1/metric/definitions'), async (reqContext, args) => scopedClient(reqContext, args).metric.listDefinitions(omitUndefined({ after: optionalString(args, 'after'), limit: optionalLimit(args) }))),
652
707
  defineTool('get_simulation_results', 'Get simulation results', 'Returns the results of one simulation run in a Roark project: run status, score, pass or fail verdict, per-metric aggregates, and the checks on each simulated call. Counts include calls that have finished so far. The verdict is absent until the run ends.', objectSchema({
653
708
  project: projectProperty,
654
709
  jobId: {
@@ -659,102 +714,134 @@ export function directoryTools() {
659
714
  type: 'string',
660
715
  description: 'Another simulation run id to compare against. When omitted, the API compares with the previous settled run of the same plan.',
661
716
  },
662
- }, ['jobId']), readAnnotations('Get simulation results'), readMeta('simulationRunPlanJob', '/v1/simulation/plan/job/{jobId}/results'), async (reqContext, args) => scopedClient(reqContext, args).simulationRunPlanJob.getResults(requireString(args, 'jobId'), omitUndefined({ compareToJobId: optionalString(args, 'compareToJobId') }))),
663
- defineTool('list_personas', 'List personas', 'Lists simulated caller personas in a Roark project. Returns each persona id, name, language, accent, and gender.', objectSchema({
717
+ }, ['jobId']), directoryOutputSchemas.getSimulationResults, readAnnotations('Get simulation results'), readMeta('simulationRunPlanJob', '/v1/simulation/plan/job/{jobId}/results'), async (reqContext, args) => scopedClient(reqContext, args).simulationRunPlanJob.getResults(requireString(args, 'jobId'), omitUndefined({ compareToJobId: optionalString(args, 'compareToJobId') }))),
718
+ defineTool('list_personas', 'List personas', 'Lists simulated caller personas in a Roark project, every persona unless searchText narrows it. Returns each persona id, name, language, accent, and gender, one page at a time.', objectSchema({
664
719
  project: projectProperty,
665
- searchText: { type: 'string', description: 'Match against persona name or description.' },
720
+ searchText: {
721
+ type: 'string',
722
+ description: 'Text to match against persona names and descriptions. When omitted, every persona is listed.',
723
+ },
666
724
  ...pagingProperties,
667
- }), readAnnotations('List personas'), readMeta('simulationPersona', '/v1/persona'), async (reqContext, args) => scopedClient(reqContext, args).simulationPersona.list(omitUndefined({
725
+ }), directoryOutputSchemas.listPersonas, readAnnotations('List personas'), readMeta('simulationPersona', '/v1/persona'), async (reqContext, args) => scopedClient(reqContext, args).simulationPersona.list(omitUndefined({
668
726
  searchText: optionalString(args, 'searchText'),
669
727
  after: optionalString(args, 'after'),
670
728
  limit: optionalLimit(args),
671
729
  }))),
672
- defineTool('list_customer_flows', 'List customer flows', 'Lists customer flows in a Roark project. A customer flow is the conversation scenario a simulated caller follows. Returns each flow id, title, and type. The step graph of a scripted flow is not included.', objectSchema({
730
+ defineTool('list_customer_flows', 'List customer flows', 'Lists customer flows in a Roark project. A customer flow is the conversation scenario a simulated caller follows. Returns each flow id, title, type, happy path, and edge cases. The step graph of a scripted flow is not included.', objectSchema({
673
731
  project: projectProperty,
674
- searchText: { type: 'string', description: 'Match against flow title.' },
675
- type: { type: 'string', enum: [...FLOW_TYPES], description: 'Flow type filter.' },
732
+ searchText: {
733
+ type: 'string',
734
+ description: 'Text to match against flow titles. When omitted, flows are not filtered by title.',
735
+ },
736
+ type: {
737
+ type: 'string',
738
+ enum: [...FLOW_TYPES],
739
+ description: 'Kind of flow to list. When omitted, flows of every kind are listed.',
740
+ },
676
741
  includeSystem: {
677
742
  type: 'string',
678
743
  enum: ['true', 'false'],
679
- description: 'true includes flows Roark provides. false returns only flows in the project.',
744
+ description: 'true also lists flows Roark provides. false, or omitting it, lists only flows made in the project.',
680
745
  },
681
746
  ...pagingProperties,
682
- }), readAnnotations('List customer flows'), readMeta('customerFlow', '/v1/customer-flow'), async (reqContext, args) => scopedClient(reqContext, args).customerFlow.list(omitUndefined({
747
+ }), directoryOutputSchemas.listCustomerFlows, readAnnotations('List customer flows'), readMeta('customerFlow', '/v1/customer-flow'), async (reqContext, args) => scopedClient(reqContext, args).customerFlow.list(omitUndefined({
683
748
  searchText: optionalString(args, 'searchText'),
684
749
  type: optionalEnum(args, 'type', FLOW_TYPES),
685
750
  includeSystem: optionalEnum(args, 'includeSystem', ['true', 'false']),
686
751
  after: optionalString(args, 'after'),
687
752
  limit: optionalLimit(args),
688
753
  }))),
689
- defineTool('list_simulation_environments', 'List simulation environments', 'Lists call environments in a Roark project, including environments Roark provides. Returns each environment id, name, and background noise. Creating a customer flow requires an environment id.', objectSchema({ project: projectProperty, ...pagingProperties }), readAnnotations('List simulation environments'), readMeta('simulationEnvironment', '/v1/simulation/environment'), async (reqContext, args) => scopedClient(reqContext, args).simulationEnvironment.list(omitUndefined({ after: optionalString(args, 'after'), limit: optionalLimit(args) }))),
690
- defineTool('create_agent', 'Create agent', 'Creates an agent in a Roark project. Requires a name. Returns the created agent, including its id. Does not create an endpoint.', objectSchema({
754
+ defineTool('list_simulation_environments', 'List simulation environments', 'Lists call environments in a Roark project, including environments Roark provides. Returns each environment id, name, and background noise. Creating a customer flow requires an environment id.', objectSchema({ project: projectProperty, ...pagingProperties }), directoryOutputSchemas.listSimulationEnvironments, readAnnotations('List simulation environments'), readMeta('simulationEnvironment', '/v1/simulation/environment'), async (reqContext, args) => scopedClient(reqContext, args).simulationEnvironment.list(omitUndefined({ after: optionalString(args, 'after'), limit: optionalLimit(args) }))),
755
+ defineTool('create_agent', 'Create agent', 'Creates an agent in a Roark project. Each call adds a new agent. Requires a name. Returns the created agent, including its id. Does not create an endpoint; create_agent_endpoint does.', objectSchema({
691
756
  project: projectProperty,
692
- name: { type: 'string', description: 'Agent name.' },
757
+ name: {
758
+ type: 'string',
759
+ description: 'Display name for the agent, shown in Roark and returned by list_agents.',
760
+ },
693
761
  description: { type: 'string', description: 'What the agent does.' },
694
- customId: { type: 'string', description: 'Caller-chosen id, unique in the project.' },
695
- }, ['name']), writeAnnotations('Create agent'), writeMeta('agent', '/v1/agent'), async (reqContext, args) => scopedClient(reqContext, args).agent.create({
762
+ customId: {
763
+ type: 'string',
764
+ description: 'Your own identifier for the agent, such as its id in your platform. Unique in the project.',
765
+ },
766
+ }, ['name']), directoryOutputSchemas.createAgent, writeAnnotations('Create agent'), writeMeta('agent', '/v1/agent'), async (reqContext, args) => scopedClient(reqContext, args).agent.create({
696
767
  name: requireString(args, 'name'),
697
768
  ...omitUndefined({
698
769
  description: optionalString(args, 'description'),
699
770
  customId: optionalString(args, 'customId'),
700
771
  }),
701
772
  })),
702
- defineTool('create_agent_endpoint', 'Create agent endpoint', 'Creates a phone endpoint for an agent in a Roark project. Roark places simulated calls to this number. Requires an agent id, an E.164 phone number, and a direction of INCOMING, OUTGOING, or INCOMING_AND_OUTGOING. Phone is the only endpoint type this tool creates.', objectSchema({
773
+ defineTool('create_agent_endpoint', 'Create agent endpoint', 'Creates a phone endpoint for an agent in a Roark project. Each call adds a new endpoint; it places no calls itself. Simulations then call the agent on this number, or receive its calls. Phone is the only endpoint type this tool creates.', objectSchema({
703
774
  project: projectProperty,
704
775
  agentId: { type: 'string', description: 'Agent id from list_agents or create_agent.' },
705
- value: { type: 'string', description: 'Phone number in E.164 format, starting with +.' },
776
+ value: {
777
+ type: 'string',
778
+ description: "The agent's phone number in E.164 form, such as +14155550123.",
779
+ },
706
780
  direction: {
707
781
  type: 'string',
708
782
  enum: [...ENDPOINT_DIRECTIONS],
709
- description: 'Which way calls can travel on this number.',
783
+ description: 'Which way calls travel on this number: INCOMING when callers reach the agent here, OUTGOING when the agent calls out from it, or both.',
784
+ },
785
+ environment: {
786
+ type: 'string',
787
+ description: 'Environment label for the endpoint, such as production or staging. When omitted, production.',
710
788
  },
711
- environment: { type: 'string', description: 'Environment name. The API default is production.' },
712
789
  outboundDialType: {
713
790
  type: 'string',
714
791
  enum: ['NONE', 'HTTP_REQUEST'],
715
- description: 'How Roark places an outbound call. The API default is NONE.',
792
+ description: 'How Roark starts an outbound simulation: HTTP_REQUEST sends an HTTP request to your platform to make the agent dial, NONE sends nothing. When omitted, NONE.',
716
793
  },
717
794
  outboundDialHttpRequestDefinitionId: {
718
795
  type: 'string',
719
- description: 'HTTP request definition id. Required when outboundDialType is HTTP_REQUEST.',
796
+ description: 'Id of the HTTP request definition Roark sends to make the agent dial, from GET /v1/http-request-definition. Required when outboundDialType is HTTP_REQUEST.',
720
797
  },
721
- }, ['agentId', 'value', 'direction']), writeAnnotations('Create agent endpoint'), writeMeta('agentEndpoint', '/v1/agent/endpoint'), async (reqContext, args) => scopedClient(reqContext, args).agentEndpoint.create(buildEndpointBody(args))),
722
- defineTool('create_persona', 'Create persona', 'Creates a simulated caller persona in a Roark project. Requires a name, language, accent, and gender. Returns the created persona, including its id.', objectSchema({
798
+ }, ['agentId', 'value', 'direction']), directoryOutputSchemas.createAgentEndpoint, writeAnnotations('Create agent endpoint'), writeMeta('agentEndpoint', '/v1/agent/endpoint'), async (reqContext, args) => scopedClient(reqContext, args).agentEndpoint.create(buildEndpointBody(args))),
799
+ defineTool('create_persona', 'Create persona', 'Creates a simulated caller persona in a Roark project. Each call adds a new persona, so repeating it creates a duplicate. It changes nothing else and places no calls. Requires a name, language, accent, and gender. Returns the created persona; pass its id as personaOverrideId to create_customer_flow to use it.', objectSchema({
723
800
  project: projectProperty,
724
801
  name: { type: 'string', description: 'Name the caller uses in conversation.' },
725
802
  language: { type: 'string', enum: [...LANGUAGES], description: 'Primary spoken language.' },
726
- accent: { type: 'string', enum: [...ACCENTS], description: 'Accent the persona is voiced with.' },
803
+ accent: { type: 'string', enum: [...ACCENTS], description: 'Accent the caller speaks with.' },
727
804
  gender: { type: 'string', enum: [...GENDERS], description: 'Gender the persona is voiced with.' },
728
805
  age: {
729
806
  type: 'string',
730
807
  enum: [...AGES],
731
- description: 'How old the caller sounds. The API default is ADULT.',
808
+ description: 'How old the caller sounds. When omitted, ADULT.',
732
809
  },
733
810
  baseEmotion: {
734
811
  type: 'string',
735
812
  enum: [...EMOTIONS],
736
- description: 'Emotional baseline. The API default is NEUTRAL.',
813
+ description: 'Mood the caller starts the conversation in. When omitted, NEUTRAL.',
737
814
  },
738
815
  backstoryPrompt: {
739
816
  type: 'string',
740
817
  description: 'Background and behavior the simulated caller plays.',
741
818
  },
742
- description: { type: 'string', description: 'Short label for the persona.' },
743
- }, ['name', 'language', 'accent', 'gender']), writeAnnotations('Create persona'), writeMeta('simulationPersona', '/v1/persona'), async (reqContext, args) => scopedClient(reqContext, args).simulationPersona.create(buildPersonaBody(args))),
744
- defineTool('create_customer_flow', 'Create customer flow', 'Creates an improv customer flow in a Roark project. A customer flow is the conversation scenario a simulated caller follows. Requires a title, at least one agent id, and a happy path with a title, a persona id, and an environment id. Returns the created flow, including its id. Scripted step graphs are not created by this tool.', objectSchema({
819
+ description: {
820
+ type: 'string',
821
+ description: 'Short summary of the persona, to tell it apart from others in the project.',
822
+ },
823
+ }, ['name', 'language', 'accent', 'gender']), directoryOutputSchemas.createPersona, writeAnnotations('Create persona'), writeMeta('simulationPersona', '/v1/persona'), async (reqContext, args) => scopedClient(reqContext, args).simulationPersona.create(buildPersonaBody(args))),
824
+ defineTool('create_customer_flow', 'Create customer flow', 'Creates an improv customer flow in a Roark project. A customer flow is the conversation scenario a simulated caller follows. Each call adds a new flow. Requires a title, at least one agent id, and a happy path with a title, a persona id, and an environment id. Returns the created flow, including its id. Scripted step graphs are not created by this tool.', objectSchema({
745
825
  project: projectProperty,
746
- title: { type: 'string', description: 'Flow title.' },
826
+ title: {
827
+ type: 'string',
828
+ description: 'Name for the flow, shown in Roark and returned by list_customer_flows.',
829
+ },
747
830
  description: { type: 'string', description: 'What the conversation covers.' },
748
831
  agentIds: {
749
832
  type: 'array',
750
833
  items: { type: 'string' },
751
- description: 'Agents this flow exercises. At least one.',
834
+ minItems: 1,
835
+ description: 'Ids of the agents this flow tests, from list_agents or create_agent.',
752
836
  },
753
837
  happyPath: {
754
838
  type: 'object',
755
839
  description: 'The way the conversation is meant to go.',
756
840
  properties: {
757
- title: { type: 'string', description: 'Happy path title.' },
841
+ title: {
842
+ type: 'string',
843
+ description: 'Name for the happy path, the run where the conversation goes as intended.',
844
+ },
758
845
  prompt: { type: 'string', description: 'What the simulated caller is trying to do.' },
759
846
  personaOverrideId: {
760
847
  type: 'string',
@@ -773,72 +860,106 @@ export function directoryTools() {
773
860
  items: {
774
861
  type: 'object',
775
862
  properties: {
776
- title: { type: 'string' },
777
- prompt: { type: 'string' },
778
- personaOverrideId: { type: 'string' },
779
- environmentId: { type: 'string' },
863
+ title: { type: 'string', description: 'Name for this edge case.' },
864
+ prompt: {
865
+ type: 'string',
866
+ description: 'What the simulated caller is trying to do in this edge case.',
867
+ },
868
+ personaOverrideId: {
869
+ type: 'string',
870
+ description: 'Persona id from list_personas or create_persona. When omitted, the happy path persona.',
871
+ },
872
+ environmentId: {
873
+ type: 'string',
874
+ description: 'Environment id from list_simulation_environments. When omitted, the happy path environment.',
875
+ },
780
876
  },
781
877
  required: ['title'],
782
878
  },
783
879
  },
784
- }, ['title', 'agentIds', 'happyPath']), writeAnnotations('Create customer flow'), writeMeta('customerFlow', '/v1/customer-flow'), async (reqContext, args) => scopedClient(reqContext, args).customerFlow.create(buildFlowBody(args))),
785
- defineTool('run_simulation', 'Run simulation', 'Starts a simulation run in a Roark project and places simulated calls. Pass exactly one of planId (an existing plan), plan (an inline plan), or template (a built-in template name, with agentEndpoints and direction). Returns the run id and how many calls the run places. This spends simulation usage on the account.', objectSchema({
880
+ }, ['title', 'agentIds', 'happyPath']), directoryOutputSchemas.createCustomerFlow, writeAnnotations('Create customer flow'), writeMeta('customerFlow', '/v1/customer-flow'), async (reqContext, args) => scopedClient(reqContext, args).customerFlow.create(buildFlowBody(args))),
881
+ defineTool('run_simulation', 'Run simulation', 'Starts a simulation run in a Roark project and places simulated calls to the agent. Pass exactly one of planId (an existing plan), plan (an inline plan), or template (a built-in template name, with agentEndpoints and direction). Returns the run id and how many calls the run places. This spends simulation usage on the account.', objectSchema({
786
882
  project: projectProperty,
787
883
  planId: { type: 'string', description: 'Id of a saved simulation plan to run.' },
788
884
  plan: {
789
885
  type: 'object',
790
886
  description: 'Inline plan to run once. Requires agentEndpoints, direction, and maxSimulationDurationSeconds.',
791
887
  properties: {
792
- name: { type: 'string', description: 'Plan name. Required when saveAsPlan is true.' },
793
- description: { type: 'string' },
794
- direction: { type: 'string', enum: [...DIRECTIONS] },
795
- agentEndpoints: { type: 'array', items: endpointSchema },
888
+ name: {
889
+ type: 'string',
890
+ description: 'Name for the plan. When omitted, one is generated from the date. Needed for saveAsPlan.',
891
+ },
892
+ description: { type: 'string', description: 'Note on what the plan tests.' },
893
+ direction: { type: 'string', enum: [...DIRECTIONS], description: directionDescription },
894
+ agentEndpoints: {
895
+ type: 'array',
896
+ items: endpointSchema,
897
+ description: 'The agent endpoints the run tests.',
898
+ },
796
899
  metrics: {
797
900
  type: 'array',
798
901
  items: metricRefSchema,
799
902
  description: 'Metrics to score, by id or slug.',
800
903
  },
801
- flows: { type: 'array', items: flowAttachmentSchema },
802
- maxSimulationDurationSeconds: { type: 'number', description: 'Per-call cap, in seconds.' },
904
+ flows: {
905
+ type: 'array',
906
+ items: flowAttachmentSchema,
907
+ description: 'Customer flows to run, and which of their happy paths and edge cases.',
908
+ },
909
+ maxSimulationDurationSeconds: {
910
+ type: 'number',
911
+ description: 'Longest one simulated call may last, in seconds.',
912
+ },
803
913
  iterationCount: {
804
914
  type: 'number',
805
- description: 'Repeats of each test case. The API default is 1.',
915
+ description: 'Times each test case runs. When omitted, 1.',
806
916
  },
807
917
  maxConcurrentJobs: {
808
918
  type: 'number',
809
- description: 'How many calls run at once. The API default is 5.',
919
+ description: 'How many calls run at once. When omitted, 5.',
810
920
  },
811
921
  executionMode: {
812
922
  type: 'string',
813
923
  enum: ['PARALLEL', 'SEQUENTIAL_SAME_RUN_PLAN', 'SEQUENTIAL_PROJECT'],
924
+ description: 'When the run starts relative to other runs. PARALLEL starts it at once. SEQUENTIAL_SAME_RUN_PLAN queues it while another run of the same plan is active. SEQUENTIAL_PROJECT queues it while any run in the project is active. When omitted, PARALLEL.',
814
925
  },
815
926
  },
816
927
  required: ['agentEndpoints', 'direction', 'maxSimulationDurationSeconds'],
817
928
  },
818
929
  template: {
819
930
  type: 'string',
820
- description: 'Built-in template name, as listed by the simulation template API.',
931
+ description: 'Name of a built-in Roark template, such as health-check. GET /v1/simulation/template lists them.',
821
932
  },
822
933
  agentEndpoints: {
823
934
  type: 'array',
824
935
  items: endpointSchema,
825
- description: 'Required with template. The endpoints the template calls.',
936
+ description: 'For a template run: the agent endpoints it tests. A template run fails without it.',
937
+ },
938
+ direction: {
939
+ type: 'string',
940
+ enum: [...DIRECTIONS],
941
+ description: `For a template run, where it is required. ${directionDescription}`,
826
942
  },
827
- direction: { type: 'string', enum: [...DIRECTIONS], description: 'Required with template.' },
828
943
  flows: {
829
944
  type: 'array',
830
945
  items: flowAttachmentSchema,
831
- description: 'Flows for a template that does not supply its own.',
946
+ description: 'For a template run: the flows to run. Needed when the template has no flows of its own; otherwise they replace its flows.',
947
+ },
948
+ iterationCount: {
949
+ type: 'number',
950
+ description: "For a template run: times each test case runs. When omitted, 1, or the template's own count for a template that sweeps a property.",
951
+ },
952
+ maxSimulationDurationSeconds: {
953
+ type: 'number',
954
+ description: "For a template run: longest one simulated call may last, in seconds. When omitted, the template's default.",
832
955
  },
833
- iterationCount: { type: 'number' },
834
- maxSimulationDurationSeconds: { type: 'number' },
835
956
  saveAsPlan: {
836
957
  type: 'boolean',
837
958
  description: 'When plan is set, true keeps the plan so it can be run again by planId. Requires plan.name.',
838
959
  },
839
960
  variables: {
840
961
  type: ['object', 'array'],
841
- description: 'Placeholder values for the run. An object of name to string value applies to the whole run. An array applies values per flow (flowId, optionally narrowed by edgeCaseId or happyPath) or per scenario (scenarioId).',
962
+ description: 'Values for the {{variables}} the run resolves. An object of name to string value applies to the whole run. An array applies values per flow (flowId, optionally narrowed by edgeCaseId or happyPath).',
842
963
  additionalProperties: { type: 'string' },
843
964
  items: {
844
965
  type: 'object',
@@ -848,14 +969,14 @@ export function directoryTools() {
848
969
  happyPath: { type: 'boolean', description: "Narrow to the flow's happy path." },
849
970
  scenarioId: {
850
971
  type: 'string',
851
- description: 'Scenario id the values apply to, instead of flowId.',
972
+ description: 'Deprecated. Scenario id the values apply to, for a saved plan built from scenarios rather than flows. Use flowId otherwise. Template runs refuse it.',
852
973
  },
853
- variables: stringMapSchema('The values to apply.'),
974
+ variables: stringMapSchema('The values to apply, as variable name to string value.'),
854
975
  },
855
976
  required: ['variables'],
856
977
  },
857
978
  },
858
- }), writeAnnotations('Run simulation'), writeMeta('simulation', '/v1/simulation/run'), async (reqContext, args) => scopedClient(reqContext, args).simulation.run(buildRunBody(args))),
979
+ }), directoryOutputSchemas.runSimulation, writeAnnotations('Run simulation', { openWorld: true }), writeMeta('simulation', '/v1/simulation/run'), async (reqContext, args) => scopedClient(reqContext, args).simulation.run(buildRunBody(args))),
859
980
  ];
860
981
  }
861
982
  //# sourceMappingURL=directory-tools.mjs.map