@ph0ny/cli 0.1.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.
Files changed (111) hide show
  1. package/README.md +155 -0
  2. package/bin/phony.js +2 -0
  3. package/dist/commands/agents.d.ts +14 -0
  4. package/dist/commands/agents.d.ts.map +1 -0
  5. package/dist/commands/agents.js +145 -0
  6. package/dist/commands/agents.js.map +1 -0
  7. package/dist/commands/auth.d.ts +11 -0
  8. package/dist/commands/auth.d.ts.map +1 -0
  9. package/dist/commands/auth.js +50 -0
  10. package/dist/commands/auth.js.map +1 -0
  11. package/dist/commands/call.d.ts +17 -0
  12. package/dist/commands/call.d.ts.map +1 -0
  13. package/dist/commands/call.js +165 -0
  14. package/dist/commands/call.js.map +1 -0
  15. package/dist/commands/campaign.d.ts +11 -0
  16. package/dist/commands/campaign.d.ts.map +1 -0
  17. package/dist/commands/campaign.js +26 -0
  18. package/dist/commands/campaign.js.map +1 -0
  19. package/dist/commands/contacts.d.ts +6 -0
  20. package/dist/commands/contacts.d.ts.map +1 -0
  21. package/dist/commands/contacts.js +45 -0
  22. package/dist/commands/contacts.js.map +1 -0
  23. package/dist/commands/conversations.d.ts +6 -0
  24. package/dist/commands/conversations.d.ts.map +1 -0
  25. package/dist/commands/conversations.js +58 -0
  26. package/dist/commands/conversations.js.map +1 -0
  27. package/dist/commands/domains.d.ts +6 -0
  28. package/dist/commands/domains.d.ts.map +1 -0
  29. package/dist/commands/domains.js +70 -0
  30. package/dist/commands/domains.js.map +1 -0
  31. package/dist/commands/keys.d.ts +13 -0
  32. package/dist/commands/keys.d.ts.map +1 -0
  33. package/dist/commands/keys.js +58 -0
  34. package/dist/commands/keys.js.map +1 -0
  35. package/dist/commands/knowledge.d.ts +9 -0
  36. package/dist/commands/knowledge.d.ts.map +1 -0
  37. package/dist/commands/knowledge.js +180 -0
  38. package/dist/commands/knowledge.js.map +1 -0
  39. package/dist/commands/observability.d.ts +6 -0
  40. package/dist/commands/observability.d.ts.map +1 -0
  41. package/dist/commands/observability.js +97 -0
  42. package/dist/commands/observability.js.map +1 -0
  43. package/dist/commands/products.d.ts +6 -0
  44. package/dist/commands/products.d.ts.map +1 -0
  45. package/dist/commands/products.js +70 -0
  46. package/dist/commands/products.js.map +1 -0
  47. package/dist/commands/providers.d.ts +9 -0
  48. package/dist/commands/providers.d.ts.map +1 -0
  49. package/dist/commands/providers.js +70 -0
  50. package/dist/commands/providers.js.map +1 -0
  51. package/dist/commands/raw.d.ts +8 -0
  52. package/dist/commands/raw.d.ts.map +1 -0
  53. package/dist/commands/raw.js +46 -0
  54. package/dist/commands/raw.js.map +1 -0
  55. package/dist/commands/tasks.d.ts +6 -0
  56. package/dist/commands/tasks.d.ts.map +1 -0
  57. package/dist/commands/tasks.js +120 -0
  58. package/dist/commands/tasks.js.map +1 -0
  59. package/dist/commands/tests.d.ts +6 -0
  60. package/dist/commands/tests.d.ts.map +1 -0
  61. package/dist/commands/tests.js +190 -0
  62. package/dist/commands/tests.js.map +1 -0
  63. package/dist/commands/tools.d.ts +6 -0
  64. package/dist/commands/tools.d.ts.map +1 -0
  65. package/dist/commands/tools.js +105 -0
  66. package/dist/commands/tools.js.map +1 -0
  67. package/dist/commands/voices.d.ts +6 -0
  68. package/dist/commands/voices.d.ts.map +1 -0
  69. package/dist/commands/voices.js +114 -0
  70. package/dist/commands/voices.js.map +1 -0
  71. package/dist/index.d.ts +11 -0
  72. package/dist/index.d.ts.map +1 -0
  73. package/dist/index.js +87 -0
  74. package/dist/index.js.map +1 -0
  75. package/dist/lib/agent-payload.d.ts +28 -0
  76. package/dist/lib/agent-payload.d.ts.map +1 -0
  77. package/dist/lib/agent-payload.js +65 -0
  78. package/dist/lib/agent-payload.js.map +1 -0
  79. package/dist/lib/call-payload.d.ts +42 -0
  80. package/dist/lib/call-payload.d.ts.map +1 -0
  81. package/dist/lib/call-payload.js +63 -0
  82. package/dist/lib/call-payload.js.map +1 -0
  83. package/dist/lib/client.d.ts +23 -0
  84. package/dist/lib/client.d.ts.map +1 -0
  85. package/dist/lib/client.js +25 -0
  86. package/dist/lib/client.js.map +1 -0
  87. package/dist/lib/command-utils.d.ts +10 -0
  88. package/dist/lib/command-utils.d.ts.map +1 -0
  89. package/dist/lib/command-utils.js +55 -0
  90. package/dist/lib/command-utils.js.map +1 -0
  91. package/dist/lib/config.d.ts +47 -0
  92. package/dist/lib/config.d.ts.map +1 -0
  93. package/dist/lib/config.js +90 -0
  94. package/dist/lib/config.js.map +1 -0
  95. package/dist/lib/errors.d.ts +25 -0
  96. package/dist/lib/errors.d.ts.map +1 -0
  97. package/dist/lib/errors.js +73 -0
  98. package/dist/lib/errors.js.map +1 -0
  99. package/dist/lib/exit.d.ts +20 -0
  100. package/dist/lib/exit.d.ts.map +1 -0
  101. package/dist/lib/exit.js +24 -0
  102. package/dist/lib/exit.js.map +1 -0
  103. package/dist/lib/json-file.d.ts +7 -0
  104. package/dist/lib/json-file.d.ts.map +1 -0
  105. package/dist/lib/json-file.js +29 -0
  106. package/dist/lib/json-file.js.map +1 -0
  107. package/dist/lib/output.d.ts +18 -0
  108. package/dist/lib/output.d.ts.map +1 -0
  109. package/dist/lib/output.js +60 -0
  110. package/dist/lib/output.js.map +1 -0
  111. package/package.json +55 -0
@@ -0,0 +1,105 @@
1
+ /**
2
+ * `phony tools …` — agent tool management, including MCP discovery.
3
+ */
4
+ import { Command } from 'commander';
5
+ import { createCliClient } from '../lib/client.js';
6
+ import { run } from '../lib/errors.js';
7
+ import { printJson, printKeyValue, printTable, success } from '../lib/output.js';
8
+ import { readJsonFileIfSet, readSecretFromEnv, requireJsonFile } from '../lib/command-utils.js';
9
+ export function createToolsCommand() {
10
+ const cmd = new Command('tools').description('Manage tools on an agent');
11
+ cmd
12
+ .command('list')
13
+ .description('List tools for an agent')
14
+ .requiredOption('--agent <id>', 'Agent ID')
15
+ .option('--json', 'Output as JSON')
16
+ .action(run(async (options) => {
17
+ const client = createCliClient();
18
+ const tools = await client.voice.agents.listTools(options.agent);
19
+ if (options.json)
20
+ return printJson({ data: tools });
21
+ printTable(['ID', 'Name', 'Type', 'Enabled'], tools.map(tool => [
22
+ tool.id,
23
+ tool.name,
24
+ tool.type,
25
+ tool.enabled,
26
+ ]));
27
+ }));
28
+ cmd
29
+ .command('create')
30
+ .description('Create a tool from JSON')
31
+ .requiredOption('--agent <id>', 'Agent ID')
32
+ .requiredOption('--file <json>', 'CreateAgentTool body JSON')
33
+ .option('--json', 'Output as JSON')
34
+ .action(run(async (options) => {
35
+ const client = createCliClient();
36
+ const tool = await client.voice.agents.addTool(options.agent, requireJsonFile(options.file, '--file'));
37
+ if (options.json)
38
+ return printJson(tool);
39
+ success(`Created tool ${tool.id} (${tool.name})`);
40
+ }));
41
+ cmd
42
+ .command('update')
43
+ .description('Update a tool from JSON')
44
+ .requiredOption('--agent <id>', 'Agent ID')
45
+ .argument('<toolId>', 'Tool ID')
46
+ .requiredOption('--file <json>', 'UpdateAgentTool body JSON')
47
+ .option('--json', 'Output as JSON')
48
+ .action(run(async (toolId, options) => {
49
+ const client = createCliClient();
50
+ const tool = await client.voice.agents.updateTool(options.agent, toolId, requireJsonFile(options.file, '--file'));
51
+ if (options.json)
52
+ return printJson(tool);
53
+ success(`Updated tool ${tool.id} (${tool.name})`);
54
+ }));
55
+ cmd
56
+ .command('delete')
57
+ .description('Delete a tool')
58
+ .requiredOption('--agent <id>', 'Agent ID')
59
+ .argument('<toolId>', 'Tool ID')
60
+ .option('--json', 'Output as JSON')
61
+ .action(run(async (toolId, options) => {
62
+ const client = createCliClient();
63
+ await client.voice.agents.deleteTool(options.agent, toolId);
64
+ if (options.json)
65
+ return printJson({ agentId: options.agent, toolId, deleted: true });
66
+ success(`Deleted tool ${toolId}`);
67
+ }));
68
+ cmd
69
+ .command('test')
70
+ .description('Test a webhook tool')
71
+ .requiredOption('--agent <id>', 'Agent ID')
72
+ .argument('<toolId>', 'Tool ID')
73
+ .option('--payload-file <json>', 'Payload JSON object')
74
+ .option('--json', 'Output as JSON')
75
+ .action(run(async (toolId, options) => {
76
+ const client = createCliClient();
77
+ const result = await client.voice.agents.testTool(options.agent, toolId, readJsonFileIfSet(options.payloadFile, '--payload-file'));
78
+ if (options.json)
79
+ return printJson(result);
80
+ printKeyValue({ OK: result.ok, Status: result.status, Latency: result.latencyMs });
81
+ }));
82
+ cmd
83
+ .command('discover-mcp')
84
+ .description('Discover tools from an MCP server')
85
+ .requiredOption('--agent <id>', 'Agent ID')
86
+ .requiredOption('--url <url>', 'MCP server URL')
87
+ .option('--name <name>', 'Connection name')
88
+ .option('--transport <transport>', 'streamable-http or sse')
89
+ .option('--auth-token-env <name>', 'Environment variable containing bearer token')
90
+ .option('--json', 'Output as JSON')
91
+ .action(run(async (options) => {
92
+ const client = createCliClient();
93
+ const tools = await client.voice.agents.discoverMcpTools(options.agent, {
94
+ url: options.url,
95
+ name: options.name,
96
+ transport: options.transport,
97
+ authToken: options.authTokenEnv ? readSecretFromEnv(options.authTokenEnv, '--auth-token-env') : undefined,
98
+ });
99
+ if (options.json)
100
+ return printJson({ data: tools });
101
+ printTable(['Name', 'Description'], tools.map(tool => [tool.name, tool.description ?? '—']));
102
+ }));
103
+ return cmd;
104
+ }
105
+ //# sourceMappingURL=tools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.js","sourceRoot":"","sources":["../../src/commands/tools.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AACtC,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAChF,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAE/F,MAAM,UAAU,kBAAkB;IAChC,MAAM,GAA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function createVoicesCommand(): Command;
6
+ //# sourceMappingURL=voices.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"voices.d.ts","sourceRoot":"","sources":["../../src/commands/voices.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAMnC,wBAAgB,mBAAmB,IAAI,OAAO,CA+G7C"}
@@ -0,0 +1,114 @@
1
+ /**
2
+ * `phony voices …` — public TTS voice management.
3
+ */
4
+ import * as fs from 'node:fs';
5
+ import { Command } from 'commander';
6
+ import { createCliClient } from '../lib/client.js';
7
+ import { run } from '../lib/errors.js';
8
+ import { printJson, printKeyValue, printTable, success } from '../lib/output.js';
9
+ import { parseOptionalFloat, parsePositiveInt } from '../lib/command-utils.js';
10
+ export function createVoicesCommand() {
11
+ const cmd = new Command('voices').description('Manage voices and synthesize speech');
12
+ cmd
13
+ .command('list')
14
+ .description('List voices')
15
+ .option('--include-custom', 'Include custom voices')
16
+ .option('--limit <n>', 'Max voices to return')
17
+ .option('--cursor <cursor>', 'Pagination cursor')
18
+ .option('--json', 'Output as JSON')
19
+ .action(run(async (options) => {
20
+ const client = createCliClient();
21
+ const page = await client.voice.tts.listVoices({
22
+ includeCustom: Boolean(options.includeCustom),
23
+ limit: parsePositiveInt(options.limit, '--limit'),
24
+ cursor: options.cursor,
25
+ });
26
+ if (options.json)
27
+ return printJson(page);
28
+ printTable(['ID', 'Name', 'Custom', 'Preview'], page.data.map(voice => [
29
+ voice.id,
30
+ voice.name,
31
+ voice.isCustom,
32
+ voice.previewUrl ?? '—',
33
+ ]));
34
+ }));
35
+ cmd
36
+ .command('get')
37
+ .description('Get a voice')
38
+ .argument('<id>', 'Voice ID')
39
+ .option('--json', 'Output as JSON')
40
+ .action(run(async (id, options) => {
41
+ const client = createCliClient();
42
+ const voice = await client.voice.tts.getVoice(id);
43
+ if (options.json)
44
+ return printJson(voice);
45
+ printKeyValue({
46
+ ID: voice.id,
47
+ Name: voice.name,
48
+ Description: voice.description,
49
+ Custom: voice.isCustom,
50
+ Preview: voice.previewUrl,
51
+ });
52
+ }));
53
+ cmd
54
+ .command('clone')
55
+ .description('Clone a voice from one or more audio sample files')
56
+ .requiredOption('--name <name>', 'Voice name')
57
+ .requiredOption('--audio-file <path...>', 'Audio sample file(s)')
58
+ .option('--description <text>', 'Voice description')
59
+ .option('--json', 'Output as JSON')
60
+ .action(run(async (options) => {
61
+ const client = createCliClient();
62
+ const samples = options.audioFile.map(file => fs.readFileSync(file));
63
+ const result = await client.voice.tts.cloneVoice(samples, {
64
+ name: options.name,
65
+ description: options.description,
66
+ });
67
+ if (options.json)
68
+ return printJson(result);
69
+ success(`Cloned voice ${result.voice.id} (${result.voice.name}) quality=${result.quality}`);
70
+ }));
71
+ cmd
72
+ .command('synthesize')
73
+ .description('Synthesize text with a voice')
74
+ .argument('<voiceId>', 'Voice ID')
75
+ .requiredOption('--text <text>', 'Text to synthesize')
76
+ .option('--format <format>', 'Audio format, e.g. mp3 or wav')
77
+ .option('--provider <provider>', 'TTS provider override')
78
+ .option('--speed <n>', 'Speech speed')
79
+ .option('--pitch <n>', 'Speech pitch')
80
+ .option('--json', 'Output as JSON')
81
+ .action(run(async (voiceId, options) => {
82
+ const client = createCliClient();
83
+ const result = await client.voice.tts.synthesize(options.text, {
84
+ voiceId,
85
+ format: (options.format ?? 'mp3'),
86
+ provider: options.provider,
87
+ speed: parseOptionalFloat(options.speed, '--speed') ?? 1,
88
+ pitch: parseOptionalFloat(options.pitch, '--pitch') ?? 1,
89
+ });
90
+ if (options.json)
91
+ return printJson(result);
92
+ printKeyValue({
93
+ Provider: result.provider,
94
+ Duration: result.duration,
95
+ Characters: result.charactersUsed,
96
+ Audio: result.audioUrl ?? (result.audio ? '<inline base64>' : undefined),
97
+ Format: result.audioFormat,
98
+ });
99
+ }));
100
+ cmd
101
+ .command('delete')
102
+ .description('Delete a custom voice')
103
+ .argument('<id>', 'Voice ID')
104
+ .option('--json', 'Output as JSON')
105
+ .action(run(async (id, options) => {
106
+ const client = createCliClient();
107
+ await client.voice.tts.deleteVoice(id);
108
+ if (options.json)
109
+ return printJson({ id, deleted: true });
110
+ success(`Deleted voice ${id}`);
111
+ }));
112
+ return cmd;
113
+ }
114
+ //# sourceMappingURL=voices.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"voices.js","sourceRoot":"","sources":["../../src/commands/voices.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAA;AAC7B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AACtC,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAChF,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAE9E,MAAM,UAAU,mBAAmB;IACjC,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,QAAQ,CAAC,CAAC,WAAW,CAAC,qCAAqC,CAAC,CAAA;IAEpF,GAAG;SACA,OAAO,CAAC,MAAM,CAAC;SACf,WAAW,CAAC,aAAa,CAAC;SAC1B,MAAM,CAAC,kBAAkB,EAAE,uBAAuB,CAAC;SACnD,MAAM,CAAC,aAAa,EAAE,sBAAsB,CAAC;SAC7C,MAAM,CAAC,mBAAmB,EAAE,mBAAmB,CAAC;SAChD,MAAM,CAAC,QAAQ,EAAE,gBAAgB,CAAC;SAClC,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,OAAqF,EAAE,EAAE;QAC1G,MAAM,MAAM,GAAG,eAAe,EAAE,CAAA;QAChC,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC;YAC7C,aAAa,EAAE,OAAO,CAAC,OAAO,CAAC,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E,CAAA;QAChC,MAAM,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC,CAAA;QACtC,IAAI,OAAO,CAAC,IAAI;YAAE,OAAO,SAAS,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAA;QACzD,OAAO,CAAC,iBAAiB,EAAE,EAAE,CAAC,CAAA;IAChC,CAAC,CAAC,CAAC,CAAA;IAEL,OAAO,GAAG,CAAA;AACZ,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Phony CLI — agents, keys, and outbound calls over the Phony Voice API.
3
+ *
4
+ * Designed to be driven by autonomous LLM agents:
5
+ * - every read/list command supports --json (2-space, no colors)
6
+ * - no interactive prompts
7
+ * - no secret values via argv (PHONY_API_KEY / ~/.phony/config.json only)
8
+ * - exit codes: 0 success, 1 runtime failure, 2 usage/compliance error
9
+ */
10
+ import 'dotenv/config';
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,eAAe,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,87 @@
1
+ /**
2
+ * Phony CLI — agents, keys, and outbound calls over the Phony Voice API.
3
+ *
4
+ * Designed to be driven by autonomous LLM agents:
5
+ * - every read/list command supports --json (2-space, no colors)
6
+ * - no interactive prompts
7
+ * - no secret values via argv (PHONY_API_KEY / ~/.phony/config.json only)
8
+ * - exit codes: 0 success, 1 runtime failure, 2 usage/compliance error
9
+ */
10
+ import 'dotenv/config';
11
+ import { createRequire } from 'node:module';
12
+ import { Command } from 'commander';
13
+ import { createAuthCommand } from './commands/auth.js';
14
+ import { createKeysCommand } from './commands/keys.js';
15
+ import { createAgentsCommand } from './commands/agents.js';
16
+ import { createCallCommand } from './commands/call.js';
17
+ import { createCampaignCommand } from './commands/campaign.js';
18
+ import { createKnowledgeCommand } from './commands/knowledge.js';
19
+ import { createVoicesCommand } from './commands/voices.js';
20
+ import { createProvidersCommand } from './commands/providers.js';
21
+ import { createToolsCommand } from './commands/tools.js';
22
+ import { createTestsCommand } from './commands/tests.js';
23
+ import { createObservabilityCommand } from './commands/observability.js';
24
+ import { createTasksCommand } from './commands/tasks.js';
25
+ import { createContactsCommand } from './commands/contacts.js';
26
+ import { createProductsCommand } from './commands/products.js';
27
+ import { createDomainsCommand } from './commands/domains.js';
28
+ import { createConversationsCommand } from './commands/conversations.js';
29
+ import { createRawCommand } from './commands/raw.js';
30
+ import { EXIT_OK, EXIT_USAGE } from './lib/exit.js';
31
+ const require = createRequire(import.meta.url);
32
+ const packageJson = require('../package.json');
33
+ const program = new Command();
34
+ program
35
+ .name('phony')
36
+ .description('CLI for the Phony Voice API')
37
+ .version(packageJson.version ?? '0.0.0');
38
+ program.addCommand(createAuthCommand());
39
+ program.addCommand(createKeysCommand());
40
+ program.addCommand(createAgentsCommand());
41
+ program.addCommand(createKnowledgeCommand());
42
+ program.addCommand(createVoicesCommand());
43
+ program.addCommand(createProvidersCommand());
44
+ program.addCommand(createToolsCommand());
45
+ program.addCommand(createTestsCommand());
46
+ program.addCommand(createCallCommand());
47
+ program.addCommand(createTasksCommand());
48
+ program.addCommand(createConversationsCommand());
49
+ program.addCommand(createContactsCommand());
50
+ program.addCommand(createProductsCommand());
51
+ program.addCommand(createDomainsCommand());
52
+ program.addCommand(createObservabilityCommand());
53
+ program.addCommand(createCampaignCommand());
54
+ program.addCommand(createRawCommand());
55
+ // Map commander's own parse errors onto our exit-code contract: help/version
56
+ // exit 0, every malformed-invocation error exits 2 (usage). Commander prints
57
+ // the message itself, so we only translate the code. Applied to every command
58
+ // in the tree so missing-required-option on a leaf subcommand also exits 2.
59
+ applyExitOverride(program);
60
+ function applyExitOverride(command) {
61
+ command.exitOverride();
62
+ for (const child of command.commands) {
63
+ applyExitOverride(child);
64
+ }
65
+ }
66
+ async function main() {
67
+ try {
68
+ await program.parseAsync(process.argv);
69
+ }
70
+ catch (err) {
71
+ if (isCommanderError(err)) {
72
+ if (err.code === 'commander.helpDisplayed' || err.code === 'commander.version' || err.code === 'commander.help') {
73
+ process.exit(EXIT_OK);
74
+ }
75
+ process.exit(EXIT_USAGE);
76
+ }
77
+ throw err;
78
+ }
79
+ }
80
+ function isCommanderError(err) {
81
+ return err instanceof Error && typeof err.code === 'string';
82
+ }
83
+ main().catch((err) => {
84
+ process.stderr.write(`Fatal: ${err instanceof Error ? err.message : String(err)}\n`);
85
+ process.exit(1);
86
+ });
87
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,eAAe,CAAA;AACtB,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAA;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AACtD,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAA;AAC9D,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAA;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAA;AAC1D,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAA;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AACxD,OAAO,EAAE,0BAA0B,EAAE,MAAM,6BAA6B,CAAA;AACxE,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAA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AAG,YAAY,KAAK,IAAI,OAAQ,GAA0B,CAAC,IAAI,KAAK,QAAQ,CAAA;AACrF,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACnB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;IACpF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACjB,CAAC,CAAC,CAAA"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Pure builders for `phony agents create|update`.
3
+ *
4
+ * An agent body comes from EITHER --file <json> (full body) OR discrete flags
5
+ * (--name/--system-prompt/--voice/--llm). The two are mutually exclusive to
6
+ * avoid silent precedence surprises. Field names mirror the agents route schema
7
+ * (name, systemPrompt, voiceId, llmProvider).
8
+ */
9
+ import { type LLMProviderType } from '@ph0ny/sdk';
10
+ export interface AgentFlagInput {
11
+ file?: Record<string, unknown>;
12
+ name?: string;
13
+ systemPrompt?: string;
14
+ voice?: string;
15
+ llm?: string;
16
+ }
17
+ export interface AgentBody {
18
+ name?: string;
19
+ systemPrompt?: string;
20
+ voiceId?: string;
21
+ llmProvider?: LLMProviderType;
22
+ [key: string]: unknown;
23
+ }
24
+ /** Build the create body. `name` is required (from --file or --name). */
25
+ export declare function buildCreateAgentBody(input: AgentFlagInput): AgentBody;
26
+ /** Build the update body. At least one mutable field is required. */
27
+ export declare function buildUpdateAgentBody(input: AgentFlagInput): AgentBody;
28
+ //# sourceMappingURL=agent-payload.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-payload.d.ts","sourceRoot":"","sources":["../../src/lib/agent-payload.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAiB,KAAK,eAAe,EAAE,MAAM,YAAY,CAAA;AAGhE,MAAM,WAAW,cAAc;IAC7B,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC9B,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,GAAG,CAAC,EAAE,MAAM,CAAA;CACb;AAED,MAAM,WAAW,SAAS;IACxB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,WAAW,CAAC,EAAE,eAAe,CAAA;IAC7B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CACvB;AAkBD,yEAAyE;AACzE,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,cAAc,GAAG,SAAS,CAerE;AAED,qEAAqE;AACrE,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,cAAc,GAAG,SAAS,CAUrE"}
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Pure builders for `phony agents create|update`.
3
+ *
4
+ * An agent body comes from EITHER --file <json> (full body) OR discrete flags
5
+ * (--name/--system-prompt/--voice/--llm). The two are mutually exclusive to
6
+ * avoid silent precedence surprises. Field names mirror the agents route schema
7
+ * (name, systemPrompt, voiceId, llmProvider).
8
+ */
9
+ import { LLM_PROVIDERS } from '@ph0ny/sdk';
10
+ import { UsageError } from './exit.js';
11
+ function assertLlmProvider(value) {
12
+ if (!LLM_PROVIDERS.includes(value)) {
13
+ throw new UsageError(`--llm must be one of: ${LLM_PROVIDERS.join(', ')} (got "${value}").`, 'INVALID_LLM');
14
+ }
15
+ return value;
16
+ }
17
+ function bodyFromFlags(input) {
18
+ const body = {};
19
+ if (input.name !== undefined)
20
+ body.name = input.name;
21
+ if (input.systemPrompt !== undefined)
22
+ body.systemPrompt = input.systemPrompt;
23
+ if (input.voice !== undefined)
24
+ body.voiceId = input.voice;
25
+ if (input.llm !== undefined)
26
+ body.llmProvider = assertLlmProvider(input.llm);
27
+ return body;
28
+ }
29
+ /** Build the create body. `name` is required (from --file or --name). */
30
+ export function buildCreateAgentBody(input) {
31
+ if (input.file && hasAnyFlag(input)) {
32
+ throw new UsageError('Use either --file or discrete flags (--name/--system-prompt/--voice/--llm), not both.', 'CONFLICTING_ARGS');
33
+ }
34
+ if (input.file) {
35
+ if (typeof input.file.name !== 'string' || input.file.name.length === 0) {
36
+ throw new UsageError('--file body must include a non-empty "name".', 'MISSING_ARG');
37
+ }
38
+ return input.file;
39
+ }
40
+ const body = bodyFromFlags(input);
41
+ if (!body.name) {
42
+ throw new UsageError('Missing --name (or provide a --file with a "name").', 'MISSING_ARG');
43
+ }
44
+ return body;
45
+ }
46
+ /** Build the update body. At least one mutable field is required. */
47
+ export function buildUpdateAgentBody(input) {
48
+ if (input.file && hasAnyFlag(input)) {
49
+ throw new UsageError('Use either --file or discrete flags (--name/--system-prompt/--voice/--llm), not both.', 'CONFLICTING_ARGS');
50
+ }
51
+ if (input.file)
52
+ return input.file;
53
+ const body = bodyFromFlags(input);
54
+ if (Object.keys(body).length === 0) {
55
+ throw new UsageError('Nothing to update. Provide --file or at least one of --name/--system-prompt/--voice/--llm.', 'MISSING_ARG');
56
+ }
57
+ return body;
58
+ }
59
+ function hasAnyFlag(input) {
60
+ return (input.name !== undefined ||
61
+ input.systemPrompt !== undefined ||
62
+ input.voice !== undefined ||
63
+ input.llm !== undefined);
64
+ }
65
+ //# sourceMappingURL=agent-payload.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-payload.js","sourceRoot":"","sources":["../../src/lib/agent-payload.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,aAAa,EAAwB,MAAM,YAAY,CAAA;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAkBtC,SAAS,iBAAiB,CAAC,KAAa;IACtC,IAAI,CAAE,aAAmC,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;Q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C,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;QACf,MAAM,IAAI,UAAU,CAAC,qDAAqD,EAAE,aAAa,CAAC,CAAA;IAC5F,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC;AAED,qEAAqE;AACrE,MAAM,UAAU,oBAAoB,CAAC,KAAqB;IACxD,IAAI,KAAK,CAAC,IAAI,IAAI,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;QACpC,MAAM,IAAI,UAAU,CAAC,uFAAuF,EAAE,kBAAkB,CAAC,CAAA;IACnI,CAAC;IACD,IAAI,KAAK,CAAC,IAAI;QAAE,OAAO,KAAK,CAAC,IAAiB,CAAA;IAC9C,MAAM,IAAI,GAAG,aAAa,CAAC,KAAK,CAAC,CAAA;IACjC,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACnC,MAAM,IAAI,UAAU,CAAC,4FAA4F,EAAE,aAAa,CAAC,CAAA;IACnI,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC;AAED,SAAS,UAAU,CAAC,KAAqB;IACvC,OAAO,CACL,KAAK,CAAC,IAAI,KAAK,SAAS;QACxB,KAAK,CAAC,YAAY,KAAK,SAAS;QAChC,KAAK,CAAC,KAAK,KAAK,SAAS;QACzB,KAAK,CAAC,GAAG,KAAK,SAAS,CACxB,CAAA;AACH,CAAC"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Pure builders + validators for `phony call start`.
3
+ *
4
+ * Kept free of I/O and commander so they can be unit-tested directly. The shape
5
+ * mirrors POST /v1/outbound/start exactly (see infra/voice-api outbound route):
6
+ * { agentId, toNumber, fromNumber, mission: { goal, successSchema?, ivrHints? },
7
+ * userConsentRecorded, dryRun? }
8
+ */
9
+ export interface CallStartInput {
10
+ agent?: string;
11
+ to?: string;
12
+ from?: string;
13
+ goal?: string;
14
+ ivrHints?: string;
15
+ successSchema?: Record<string, unknown>;
16
+ dryRun?: boolean;
17
+ consentRecorded?: boolean;
18
+ }
19
+ export interface OutboundStartPayload {
20
+ agentId: string;
21
+ toNumber: string;
22
+ fromNumber: string;
23
+ mission: {
24
+ goal: string;
25
+ successSchema?: Record<string, unknown>;
26
+ ivrHints?: string[];
27
+ };
28
+ userConsentRecorded: true;
29
+ dryRun?: boolean;
30
+ }
31
+ export declare function assertE164(value: string, field: string): void;
32
+ /** Split a comma-separated --ivr-hints string into trimmed, non-empty hints. */
33
+ export declare function parseIvrHints(raw: string | undefined): string[] | undefined;
34
+ /**
35
+ * Build the outbound start payload, enforcing every client-side gate.
36
+ *
37
+ * The consent gate is a compliance requirement, not a convenience check: the
38
+ * server rejects userConsentRecorded:false, and we refuse to even construct a
39
+ * call request without an explicit --consent-recorded flag.
40
+ */
41
+ export declare function buildOutboundStartPayload(input: CallStartInput): OutboundStartPayload;
42
+ //# sourceMappingURL=call-payload.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"call-payload.d.ts","sourceRoot":"","sources":["../../src/lib/call-payload.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAOH,MAAM,WAAW,cAAc;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACvC,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,eAAe,CAAC,EAAE,OAAO,CAAA;CAC1B;AAED,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,MAAM,CAAA;IAChB,UAAU,EAAE,MAAM,CAAA;IAClB,OAAO,EAAE;QACP,IAAI,EAAE,MAAM,CAAA;QACZ,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;QACvC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;KACpB,CAAA;IACD,mBAAmB,EAAE,IAAI,CAAA;IACzB,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAI7D;AAED,gFAAgF;AAChF,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,EAAE,GAAG,SAAS,CAI3E;AAED;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,cAAc,GAAG,oBAAoB,CA+BrF"}
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Pure builders + validators for `phony call start`.
3
+ *
4
+ * Kept free of I/O and commander so they can be unit-tested directly. The shape
5
+ * mirrors POST /v1/outbound/start exactly (see infra/voice-api outbound route):
6
+ * { agentId, toNumber, fromNumber, mission: { goal, successSchema?, ivrHints? },
7
+ * userConsentRecorded, dryRun? }
8
+ */
9
+ import { UsageError } from './exit.js';
10
+ /** Matches the server's E164 regex in the outbound route. */
11
+ const E164 = /^\+[1-9]\d{7,14}$/;
12
+ export function assertE164(value, field) {
13
+ if (!E164.test(value)) {
14
+ throw new UsageError(`${field} must be E.164 format (e.g. +14155550123), got "${value}".`, 'INVALID_E164');
15
+ }
16
+ }
17
+ /** Split a comma-separated --ivr-hints string into trimmed, non-empty hints. */
18
+ export function parseIvrHints(raw) {
19
+ if (!raw)
20
+ return undefined;
21
+ const hints = raw.split(',').map((h) => h.trim()).filter(Boolean);
22
+ return hints.length > 0 ? hints : undefined;
23
+ }
24
+ /**
25
+ * Build the outbound start payload, enforcing every client-side gate.
26
+ *
27
+ * The consent gate is a compliance requirement, not a convenience check: the
28
+ * server rejects userConsentRecorded:false, and we refuse to even construct a
29
+ * call request without an explicit --consent-recorded flag.
30
+ */
31
+ export function buildOutboundStartPayload(input) {
32
+ if (input.consentRecorded !== true) {
33
+ throw new UsageError('Refusing to place a call without recorded consent. Pass --consent-recorded only after the user has explicitly authorized this call (TCPA/recording compliance).', 'CONSENT_REQUIRED');
34
+ }
35
+ if (!input.agent)
36
+ throw new UsageError('Missing --agent <id>.', 'MISSING_ARG');
37
+ if (!input.to)
38
+ throw new UsageError('Missing --to <e164>.', 'MISSING_ARG');
39
+ if (!input.from)
40
+ throw new UsageError('Missing --from <e164>.', 'MISSING_ARG');
41
+ if (!input.goal || input.goal.trim().length < 8) {
42
+ throw new UsageError('Missing or too-short --goal (the mission goal must be at least 8 characters).', 'MISSING_ARG');
43
+ }
44
+ assertE164(input.to, '--to');
45
+ assertE164(input.from, '--from');
46
+ const mission = { goal: input.goal };
47
+ if (input.successSchema)
48
+ mission.successSchema = input.successSchema;
49
+ const ivrHints = parseIvrHints(input.ivrHints);
50
+ if (ivrHints)
51
+ mission.ivrHints = ivrHints;
52
+ const payload = {
53
+ agentId: input.agent,
54
+ toNumber: input.to,
55
+ fromNumber: input.from,
56
+ mission,
57
+ userConsentRecorded: true,
58
+ };
59
+ if (input.dryRun === true)
60
+ payload.dryRun = true;
61
+ return payload;
62
+ }
63
+ //# sourceMappingURL=call-payload.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"call-payload.js","sourceRoot":"","sources":["../../src/lib/call-payload.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAEtC,6DAA6D;AAC7D,MAAM,IAAI,GAAG,mBAAmB,CAAA;AA0BhC,MAAM,UAAU,UAAU,CAAC,KAAa,EAAE,KAAa;IACrD,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QACtB,MAAM,IAAI,UAAU,CAAC,GAAG,KAAK,mDAAmD,KAAK,IAAI,EAAE,cAAc,CAAC,CAAA;IAC5G,CAAC;AACH,CAAC;AAED,gFAAgF;AAChF,MAAM,UAAU,aAAa,CAAC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AC,aAAa;QAAE,OAAO,CAAC,aAAa,GAAG,KAAK,CAAC,aAAa,CAAA;IACpE,MAAM,QAAQ,GAAG,aAAa,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAA;IAC9C,IAAI,QAAQ;QAAE,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAA;IAEzC,MAAM,OAAO,GAAyB;QACpC,OAAO,EAAE,KAAK,CAAC,KAAK;QACpB,QAAQ,EAAE,KAAK,CAAC,EAAE;QAClB,UAAU,EAAE,KAAK,CAAC,IAAI;QACtB,OAAO;QACP,mBAAmB,EAAE,IAAI;KAC1B,CAAA;IACD,IAAI,KAAK,CAAC,MAAM,KAAK,IAAI;QAAE,OAAO,CAAC,MAAM,GAAG,IAAI,CAAA;IAChD,OAAO,OAAO,CAAA;AAChB,CAAC"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Client construction.
3
+ *
4
+ * One `VoiceClient` (from @ph0ny/sdk) is built per command from the resolved
5
+ * context. Endpoints the SDK already wraps (agents CRUD/chat/speak, self-play)
6
+ * go through its typed methods. Endpoints the SDK does NOT model (key
7
+ * management, outbound calls) go through the client's public `request<T>`
8
+ * helper, which reuses the same auth header, base URL, and VoiceApiException
9
+ * error mapping — so there is no second, divergent fetch path.
10
+ */
11
+ import { VoiceClient } from '@ph0ny/sdk';
12
+ import { type ResolvedContext } from './config.js';
13
+ export interface CliClient {
14
+ voice: VoiceClient;
15
+ context: ResolvedContext;
16
+ /** Raw typed request against /v1 for routes the SDK does not wrap. */
17
+ request<T>(method: string, path: string, options?: {
18
+ body?: unknown;
19
+ query?: Record<string, string | number | boolean | undefined>;
20
+ }): Promise<T>;
21
+ }
22
+ export declare function createCliClient(): CliClient;
23
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/lib/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AACxC,OAAO,EAA6B,KAAK,eAAe,EAAE,MAAM,aAAa,CAAA;AAE7E,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,WAAW,CAAA;IAClB,OAAO,EAAE,eAAe,CAAA;IACxB,sEAAsE;IACtE,OAAO,CAAC,CAAC,EACP,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,OAAO,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC,CAAA;KAAE,GAC1F,OAAO,CAAC,CAAC,CAAC,CAAA;CACd;AAED,wBAAgB,eAAe,IAAI,SAAS,CAW3C"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Client construction.
3
+ *
4
+ * One `VoiceClient` (from @ph0ny/sdk) is built per command from the resolved
5
+ * context. Endpoints the SDK already wraps (agents CRUD/chat/speak, self-play)
6
+ * go through its typed methods. Endpoints the SDK does NOT model (key
7
+ * management, outbound calls) go through the client's public `request<T>`
8
+ * helper, which reuses the same auth header, base URL, and VoiceApiException
9
+ * error mapping — so there is no second, divergent fetch path.
10
+ */
11
+ import { VoiceClient } from '@ph0ny/sdk';
12
+ import { resolveContext, v1BaseUrl } from './config.js';
13
+ export function createCliClient() {
14
+ const context = resolveContext();
15
+ const voice = new VoiceClient({
16
+ apiKey: context.apiKey,
17
+ baseUrl: v1BaseUrl(context.baseUrl),
18
+ });
19
+ return {
20
+ voice,
21
+ context,
22
+ request: (method, path, options) => voice.request(method, path, options),
23
+ };
24
+ }
25
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/lib/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AACxC,OAAO,EAAE,cAAc,EAAE,SAAS,EAAwB,MAAM,aAAa,CAAA;AAa7E,MAAM,UAAU,eAAe;IAC7B,MAAM,OAAO,GAAG,cAAc,EAAE,CAAA;IAChC,MAAM,KAAK,GAAG,IAAI,WAAW,CAAC;QAC5B,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,OAAO,EAAE,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC;KACpC,CAAC,CAAA;IACF,OAAO;QACL,KAAK;QACL,OAAO;QACP,OAAO,EAAE,CAAC,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC;KACzE,CAAA;AACH,CAAC"}