@thisispamela/cli 1.0.4 → 1.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.
- package/dist/index.d.ts +0 -1
- package/dist/index.js +100 -127
- package/dist/index.js.map +1 -0
- package/package.json +12 -3
- package/tsup.config.ts +10 -0
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,140 +1,113 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
|
|
3
|
+
// src/index.ts
|
|
4
|
+
import { Command } from "commander";
|
|
5
|
+
import { PamelaClient } from "@thisispamela/sdk";
|
|
6
|
+
var outputJson = (data) => {
|
|
7
|
+
process.stdout.write(`${JSON.stringify(data, null, 2)}
|
|
8
|
+
`);
|
|
8
9
|
};
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
var outputError = (error) => {
|
|
11
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
12
|
+
const name = error instanceof Error ? error.name : "Error";
|
|
13
|
+
process.stderr.write(
|
|
14
|
+
`${JSON.stringify({ error: { name, message } }, null, 2)}
|
|
15
|
+
`
|
|
16
|
+
);
|
|
13
17
|
};
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
var parseNumber = (value, label) => {
|
|
19
|
+
const parsed = Number(value);
|
|
20
|
+
if (!Number.isFinite(parsed)) {
|
|
21
|
+
throw new Error(`${label} must be a valid number`);
|
|
22
|
+
}
|
|
23
|
+
return parsed;
|
|
20
24
|
};
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
var getClient = (options) => {
|
|
26
|
+
const apiKey = options.apiKey || process.env.PAMELA_API_KEY;
|
|
27
|
+
if (!apiKey) {
|
|
28
|
+
throw new Error("Missing API key. Provide --api-key or set PAMELA_API_KEY.");
|
|
29
|
+
}
|
|
30
|
+
return new PamelaClient({
|
|
31
|
+
apiKey,
|
|
32
|
+
baseUrl: options.baseUrl
|
|
33
|
+
});
|
|
30
34
|
};
|
|
31
|
-
|
|
32
|
-
program
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
.
|
|
45
|
-
|
|
46
|
-
.
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const client = getClient(program.opts());
|
|
50
|
-
const payload = {
|
|
51
|
-
to: options.to,
|
|
52
|
-
task: options.task,
|
|
53
|
-
};
|
|
54
|
-
if (options.voice)
|
|
55
|
-
payload.voice = options.voice;
|
|
56
|
-
if (options.agentName)
|
|
57
|
-
payload.agent_name = options.agentName;
|
|
58
|
-
if (options.locale)
|
|
59
|
-
payload.locale = options.locale;
|
|
60
|
-
if (options.maxDurationSeconds !== undefined) {
|
|
61
|
-
payload.max_duration_seconds = options.maxDurationSeconds;
|
|
62
|
-
}
|
|
63
|
-
if (options.callerName)
|
|
64
|
-
payload.caller_name = options.callerName;
|
|
65
|
-
const response = await client.createCall(payload);
|
|
66
|
-
outputJson(response);
|
|
67
|
-
}
|
|
68
|
-
catch (error) {
|
|
69
|
-
outputError(error);
|
|
70
|
-
process.exitCode = 1;
|
|
35
|
+
var program = new Command();
|
|
36
|
+
program.name("thisispamela").description("Pamela Voice API CLI").option("--api-key <key>", "Pamela API key (falls back to PAMELA_API_KEY)").option("--base-url <url>", "Pamela API base URL", "https://api.thisispamela.com");
|
|
37
|
+
program.command("create-call").description("Create a new call").requiredOption("--to <e164>", "Destination phone number (E.164)").requiredOption("--task <text>", "Task for the agent to perform").option("--voice <voice>", "Voice selection (male, female, auto)").option("--agent-name <name>", "Agent display name").option("--locale <locale>", "Locale, e.g. en-US").option(
|
|
38
|
+
"--max-duration-seconds <number>",
|
|
39
|
+
"Maximum call duration in seconds",
|
|
40
|
+
(value) => parseNumber(value, "max-duration-seconds")
|
|
41
|
+
).option("--caller-name <name>", "Caller display name").action(async (options) => {
|
|
42
|
+
try {
|
|
43
|
+
const client = getClient(program.opts());
|
|
44
|
+
const payload = {
|
|
45
|
+
to: options.to,
|
|
46
|
+
task: options.task
|
|
47
|
+
};
|
|
48
|
+
if (options.voice) payload.voice = options.voice;
|
|
49
|
+
if (options.agentName) payload.agent_name = options.agentName;
|
|
50
|
+
if (options.locale) payload.locale = options.locale;
|
|
51
|
+
if (options.maxDurationSeconds !== void 0) {
|
|
52
|
+
payload.max_duration_seconds = options.maxDurationSeconds;
|
|
71
53
|
}
|
|
54
|
+
if (options.callerName) payload.caller_name = options.callerName;
|
|
55
|
+
const response = await client.createCall(payload);
|
|
56
|
+
outputJson(response);
|
|
57
|
+
} catch (error) {
|
|
58
|
+
outputError(error);
|
|
59
|
+
process.exitCode = 1;
|
|
60
|
+
}
|
|
72
61
|
});
|
|
73
|
-
program
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
.
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
83
|
-
catch (error) {
|
|
84
|
-
outputError(error);
|
|
85
|
-
process.exitCode = 1;
|
|
86
|
-
}
|
|
62
|
+
program.command("get-call").description("Get call status and details").argument("<callId>", "Call ID").action(async (callId) => {
|
|
63
|
+
try {
|
|
64
|
+
const client = getClient(program.opts());
|
|
65
|
+
const response = await client.getCall(callId);
|
|
66
|
+
outputJson(response);
|
|
67
|
+
} catch (error) {
|
|
68
|
+
outputError(error);
|
|
69
|
+
process.exitCode = 1;
|
|
70
|
+
}
|
|
87
71
|
});
|
|
88
|
-
program
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
process.exitCode = 1;
|
|
105
|
-
}
|
|
72
|
+
program.command("list-calls").description("List calls").option("--status <status>", "Filter by status").option(
|
|
73
|
+
"--limit <number>",
|
|
74
|
+
"Limit number of results",
|
|
75
|
+
(value) => parseNumber(value, "limit")
|
|
76
|
+
).action(async (options) => {
|
|
77
|
+
try {
|
|
78
|
+
const client = getClient(program.opts());
|
|
79
|
+
const response = await client.listCalls({
|
|
80
|
+
status: options.status,
|
|
81
|
+
limit: options.limit
|
|
82
|
+
});
|
|
83
|
+
outputJson(response);
|
|
84
|
+
} catch (error) {
|
|
85
|
+
outputError(error);
|
|
86
|
+
process.exitCode = 1;
|
|
87
|
+
}
|
|
106
88
|
});
|
|
107
|
-
program
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
.
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
}
|
|
117
|
-
catch (error) {
|
|
118
|
-
outputError(error);
|
|
119
|
-
process.exitCode = 1;
|
|
120
|
-
}
|
|
89
|
+
program.command("cancel-call").description("Cancel an in-progress call").argument("<callId>", "Call ID").action(async (callId) => {
|
|
90
|
+
try {
|
|
91
|
+
const client = getClient(program.opts());
|
|
92
|
+
const response = await client.cancelCall(callId);
|
|
93
|
+
outputJson(response);
|
|
94
|
+
} catch (error) {
|
|
95
|
+
outputError(error);
|
|
96
|
+
process.exitCode = 1;
|
|
97
|
+
}
|
|
121
98
|
});
|
|
122
|
-
program
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
.
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
}
|
|
132
|
-
catch (error) {
|
|
133
|
-
outputError(error);
|
|
134
|
-
process.exitCode = 1;
|
|
135
|
-
}
|
|
99
|
+
program.command("hangup-call").description("Force hangup an in-progress call").argument("<callId>", "Call ID").action(async (callId) => {
|
|
100
|
+
try {
|
|
101
|
+
const client = getClient(program.opts());
|
|
102
|
+
const response = await client.hangupCall(callId);
|
|
103
|
+
outputJson(response);
|
|
104
|
+
} catch (error) {
|
|
105
|
+
outputError(error);
|
|
106
|
+
process.exitCode = 1;
|
|
107
|
+
}
|
|
136
108
|
});
|
|
137
109
|
program.parseAsync(process.argv).catch((error) => {
|
|
138
|
-
|
|
139
|
-
|
|
110
|
+
outputError(error);
|
|
111
|
+
process.exit(1);
|
|
140
112
|
});
|
|
113
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { Command } from 'commander';\nimport { PamelaClient } from '@thisispamela/sdk';\n\ntype GlobalOptions = {\n apiKey?: string;\n baseUrl?: string;\n};\n\nconst outputJson = (data: unknown) => {\n process.stdout.write(`${JSON.stringify(data, null, 2)}\\n`);\n};\n\nconst outputError = (error: unknown) => {\n const message = error instanceof Error ? error.message : String(error);\n const name = error instanceof Error ? error.name : 'Error';\n process.stderr.write(\n `${JSON.stringify({ error: { name, message } }, null, 2)}\\n`\n );\n};\n\nconst parseNumber = (value: string, label: string) => {\n const parsed = Number(value);\n if (!Number.isFinite(parsed)) {\n throw new Error(`${label} must be a valid number`);\n }\n return parsed;\n};\n\nconst getClient = (options: GlobalOptions) => {\n const apiKey = options.apiKey || process.env.PAMELA_API_KEY;\n if (!apiKey) {\n throw new Error('Missing API key. Provide --api-key or set PAMELA_API_KEY.');\n }\n return new PamelaClient({\n apiKey,\n baseUrl: options.baseUrl,\n });\n};\n\nconst program = new Command();\n\nprogram\n .name('thisispamela')\n .description('Pamela Voice API CLI')\n .option('--api-key <key>', 'Pamela API key (falls back to PAMELA_API_KEY)')\n .option('--base-url <url>', 'Pamela API base URL', 'https://api.thisispamela.com');\n\nprogram\n .command('create-call')\n .description('Create a new call')\n .requiredOption('--to <e164>', 'Destination phone number (E.164)')\n .requiredOption('--task <text>', 'Task for the agent to perform')\n .option('--voice <voice>', 'Voice selection (male, female, auto)')\n .option('--agent-name <name>', 'Agent display name')\n .option('--locale <locale>', 'Locale, e.g. en-US')\n .option(\n '--max-duration-seconds <number>',\n 'Maximum call duration in seconds',\n (value) => parseNumber(value, 'max-duration-seconds')\n )\n .option('--caller-name <name>', 'Caller display name')\n .action(async (options) => {\n try {\n const client = getClient(program.opts<GlobalOptions>());\n const payload: Record<string, unknown> = {\n to: options.to,\n task: options.task,\n };\n\n if (options.voice) payload.voice = options.voice;\n if (options.agentName) payload.agent_name = options.agentName;\n if (options.locale) payload.locale = options.locale;\n if (options.maxDurationSeconds !== undefined) {\n payload.max_duration_seconds = options.maxDurationSeconds;\n }\n if (options.callerName) payload.caller_name = options.callerName;\n\n const response = await client.createCall(payload as any);\n outputJson(response);\n } catch (error) {\n outputError(error);\n process.exitCode = 1;\n }\n });\n\nprogram\n .command('get-call')\n .description('Get call status and details')\n .argument('<callId>', 'Call ID')\n .action(async (callId: string) => {\n try {\n const client = getClient(program.opts<GlobalOptions>());\n const response = await client.getCall(callId);\n outputJson(response);\n } catch (error) {\n outputError(error);\n process.exitCode = 1;\n }\n });\n\nprogram\n .command('list-calls')\n .description('List calls')\n .option('--status <status>', 'Filter by status')\n .option('--limit <number>', 'Limit number of results', (value) =>\n parseNumber(value, 'limit')\n )\n .action(async (options) => {\n try {\n const client = getClient(program.opts<GlobalOptions>());\n const response = await client.listCalls({\n status: options.status,\n limit: options.limit,\n });\n outputJson(response);\n } catch (error) {\n outputError(error);\n process.exitCode = 1;\n }\n });\n\nprogram\n .command('cancel-call')\n .description('Cancel an in-progress call')\n .argument('<callId>', 'Call ID')\n .action(async (callId: string) => {\n try {\n const client = getClient(program.opts<GlobalOptions>());\n const response = await client.cancelCall(callId);\n outputJson(response);\n } catch (error) {\n outputError(error);\n process.exitCode = 1;\n }\n });\n\nprogram\n .command('hangup-call')\n .description('Force hangup an in-progress call')\n .argument('<callId>', 'Call ID')\n .action(async (callId: string) => {\n try {\n const client = getClient(program.opts<GlobalOptions>());\n const response = await client.hangupCall(callId);\n outputJson(response);\n } catch (error) {\n outputError(error);\n process.exitCode = 1;\n }\n });\n\nprogram.parseAsync(process.argv).catch((error) => {\n outputError(error);\n process.exit(1);\n});\n"],"mappings":";;;AACA,SAAS,eAAe;AACxB,SAAS,oBAAoB;AAO7B,IAAM,aAAa,CAAC,SAAkB;AACpC,UAAQ,OAAO,MAAM,GAAG,KAAK,UAAU,MAAM,MAAM,CAAC,CAAC;AAAA,CAAI;AAC3D;AAEA,IAAM,cAAc,CAAC,UAAmB;AACtC,QAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AACrE,QAAM,OAAO,iBAAiB,QAAQ,MAAM,OAAO;AACnD,UAAQ,OAAO;AAAA,IACb,GAAG,KAAK,UAAU,EAAE,OAAO,EAAE,MAAM,QAAQ,EAAE,GAAG,MAAM,CAAC,CAAC;AAAA;AAAA,EAC1D;AACF;AAEA,IAAM,cAAc,CAAC,OAAe,UAAkB;AACpD,QAAM,SAAS,OAAO,KAAK;AAC3B,MAAI,CAAC,OAAO,SAAS,MAAM,GAAG;AAC5B,UAAM,IAAI,MAAM,GAAG,KAAK,yBAAyB;AAAA,EACnD;AACA,SAAO;AACT;AAEA,IAAM,YAAY,CAAC,YAA2B;AAC5C,QAAM,SAAS,QAAQ,UAAU,QAAQ,IAAI;AAC7C,MAAI,CAAC,QAAQ;AACX,UAAM,IAAI,MAAM,2DAA2D;AAAA,EAC7E;AACA,SAAO,IAAI,aAAa;AAAA,IACtB;AAAA,IACA,SAAS,QAAQ;AAAA,EACnB,CAAC;AACH;AAEA,IAAM,UAAU,IAAI,QAAQ;AAE5B,QACG,KAAK,cAAc,EACnB,YAAY,sBAAsB,EAClC,OAAO,mBAAmB,+CAA+C,EACzE,OAAO,oBAAoB,uB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",
|
|
4
4
|
"description": "Pamela Enterprise Voice API CLI",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"main": "dist/index.js",
|
|
6
7
|
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"default": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
7
15
|
"bin": {
|
|
8
16
|
"thisispamela": "dist/index.js"
|
|
9
17
|
},
|
|
10
18
|
"scripts": {
|
|
11
|
-
"build": "
|
|
19
|
+
"build": "tsup",
|
|
12
20
|
"prepublishOnly": "npm run build"
|
|
13
21
|
},
|
|
14
22
|
"keywords": [
|
|
@@ -23,11 +31,12 @@
|
|
|
23
31
|
"author": "Pamela",
|
|
24
32
|
"license": "MIT",
|
|
25
33
|
"dependencies": {
|
|
26
|
-
"@thisispamela/sdk": "^1.0
|
|
34
|
+
"@thisispamela/sdk": "^1.1.0",
|
|
27
35
|
"commander": "^14.0.3"
|
|
28
36
|
},
|
|
29
37
|
"devDependencies": {
|
|
30
38
|
"@types/node": "^20.0.0",
|
|
39
|
+
"tsup": "^8.0.0",
|
|
31
40
|
"typescript": "^5.0.0"
|
|
32
41
|
}
|
|
33
42
|
}
|