@thisispamela/sdk 1.0.3 → 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/README.md +2 -0
- package/dist/chunk-IKGLZFM6.mjs +38 -0
- package/dist/chunk-IKGLZFM6.mjs.map +1 -0
- package/dist/chunk-NQIPPPEL.mjs +50 -0
- package/dist/chunk-NQIPPPEL.mjs.map +1 -0
- package/dist/chunk-WMXO6YYV.mjs +50 -0
- package/dist/chunk-WMXO6YYV.mjs.map +1 -0
- package/dist/errors.d.mts +47 -0
- package/dist/errors.d.ts +8 -6
- package/dist/errors.js +78 -47
- package/dist/errors.js.map +1 -0
- package/dist/errors.mjs +17 -0
- package/dist/errors.mjs.map +1 -0
- package/dist/index.d.mts +109 -0
- package/dist/index.d.ts +19 -67
- package/dist/index.js +315 -193
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +170 -0
- package/dist/index.mjs.map +1 -0
- package/dist/types.d.mts +99 -0
- package/dist/types.d.ts +99 -0
- package/dist/types.js +74 -0
- package/dist/types.js.map +1 -0
- package/dist/types.mjs +7 -0
- package/dist/types.mjs.map +1 -0
- package/dist/webhooks.d.mts +12 -0
- package/dist/webhooks.d.ts +12 -0
- package/dist/webhooks.js +73 -0
- package/dist/webhooks.js.map +1 -0
- package/dist/webhooks.mjs +9 -0
- package/dist/webhooks.mjs.map +1 -0
- package/package.json +28 -4
- package/src/index.ts +17 -82
- package/src/types.ts +126 -0
- package/src/webhooks.ts +55 -0
- package/tsup.config.ts +10 -0
package/README.md
CHANGED
|
@@ -25,6 +25,7 @@ const call = await client.createCall({
|
|
|
25
25
|
to: '+1234567890',
|
|
26
26
|
task: 'Order a large pizza for delivery',
|
|
27
27
|
locale: 'en-US',
|
|
28
|
+
max_duration_seconds: 299,
|
|
28
29
|
voice: 'female',
|
|
29
30
|
agent_name: 'Pamela',
|
|
30
31
|
caller_name: 'John from Acme',
|
|
@@ -256,6 +257,7 @@ All exceptions have:
|
|
|
256
257
|
- `getCall(callId)` - Get call status and details
|
|
257
258
|
- `listCalls(params?)` - List calls with optional filters
|
|
258
259
|
- `cancelCall(callId)` - Cancel an in-progress call
|
|
260
|
+
- `hangupCall(callId)` - Force hangup an in-progress call
|
|
259
261
|
|
|
260
262
|
### Tools
|
|
261
263
|
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// src/webhooks.ts
|
|
2
|
+
import * as crypto from "crypto";
|
|
3
|
+
var verifyWebhookSignature = (payload, signature, secret) => {
|
|
4
|
+
if (!signature) {
|
|
5
|
+
return false;
|
|
6
|
+
}
|
|
7
|
+
if (!secret) {
|
|
8
|
+
throw new Error("Webhook secret cannot be empty");
|
|
9
|
+
}
|
|
10
|
+
const payloadString = typeof payload === "string" ? payload : JSON.stringify(payload);
|
|
11
|
+
const expectedSignature = crypto.createHmac("sha256", secret).update(payloadString).digest("hex");
|
|
12
|
+
return crypto.timingSafeEqual(
|
|
13
|
+
Buffer.from(signature),
|
|
14
|
+
Buffer.from(expectedSignature)
|
|
15
|
+
);
|
|
16
|
+
};
|
|
17
|
+
var parseToolWebhook = (payload) => {
|
|
18
|
+
const requiredFields = ["tool_name", "arguments", "call_id", "correlation_id"];
|
|
19
|
+
const missing = requiredFields.filter((field) => !(field in payload));
|
|
20
|
+
if (missing.length > 0) {
|
|
21
|
+
throw new Error(`Missing required fields: ${missing.join(", ")}`);
|
|
22
|
+
}
|
|
23
|
+
return {
|
|
24
|
+
tool_name: String(payload.tool_name),
|
|
25
|
+
arguments: typeof payload.arguments === "object" && payload.arguments ? payload.arguments : {},
|
|
26
|
+
call_id: String(payload.call_id),
|
|
27
|
+
correlation_id: String(payload.correlation_id),
|
|
28
|
+
call_session_id: payload.call_session_id,
|
|
29
|
+
partner_id: payload.partner_id,
|
|
30
|
+
project_id: payload.project_id
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export {
|
|
35
|
+
verifyWebhookSignature,
|
|
36
|
+
parseToolWebhook
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=chunk-IKGLZFM6.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/webhooks.ts"],"sourcesContent":["import * as crypto from 'crypto';\n\nexport const verifyWebhookSignature = (\n payload: string | object,\n signature: string | undefined | null,\n secret: string\n): boolean => {\n if (!signature) {\n return false;\n }\n\n if (!secret) {\n throw new Error('Webhook secret cannot be empty');\n }\n\n const payloadString = typeof payload === 'string' ? payload : JSON.stringify(payload);\n const expectedSignature = crypto\n .createHmac('sha256', secret)\n .update(payloadString)\n .digest('hex');\n\n return crypto.timingSafeEqual(\n Buffer.from(signature),\n Buffer.from(expectedSignature)\n );\n};\n\nexport const parseToolWebhook = (payload: Record<string, any>): {\n tool_name: string;\n arguments: Record<string, any>;\n call_id: string;\n correlation_id: string;\n call_session_id?: string;\n partner_id?: string;\n project_id?: string;\n} => {\n const requiredFields = ['tool_name', 'arguments', 'call_id', 'correlation_id'];\n const missing = requiredFields.filter((field) => !(field in payload));\n\n if (missing.length > 0) {\n throw new Error(`Missing required fields: ${missing.join(', ')}`);\n }\n\n return {\n tool_name: String(payload.tool_name),\n arguments: typeof payload.arguments === 'object' && payload.arguments\n ? payload.arguments\n : {},\n call_id: String(payload.call_id),\n correlation_id: String(payload.correlation_id),\n call_session_id: payload.call_session_id,\n partner_id: payload.partner_id,\n project_id: payload.project_id,\n };\n};\n"],"mappings":";AAAA,YAAY,YAAY;AAEjB,IAAM,yBAAyB,CACpC,SACA,WACA,WACY;AACZ,MAAI,CAAC,WAAW;AACd,WAAO;AAAA,EACT;AAEA,MAAI,CAAC,QAAQ;AACX,UAAM,IAAI,MAAM,gCAAgC;AAAA,EAClD;AAEA,QAAM,gBAAgB,OAAO,YAAY,WAAW,UAAU,KAAK,UAAU,OAAO;AACpF,QAAM,oBACH,kBAAW,UAAU,MAAM,EAC3B,OAAO,aAAa,EACpB,OAAO,KAAK;AAEf,SAAc;AAAA,IACZ,OAAO,KAAK,SAAS;AAAA,IACrB,OAAO,KAAK,iBAAiB;AAAA,EAC/B;AACF;AAEO,IAAM,mBAAmB,CAAC,YAQ5B;AACH,QAAM,iBAAiB,CAAC,aAAa,aAAa,WAAW,gBAAgB;AAC7E,QAAM,UAAU,eAAe,OAAO,CAAC,UAAU,EAAE,SAAS,QAAQ;AAEpE,MAAI,QAAQ,SAAS,GAAG;AACtB,UAAM,IAAI,MAAM,4BAA4B,QAAQ,KAAK,IAAI,CAAC,EAAE;AAAA,EAClE;AAEA,SAAO;AAAA,IACL,WAAW,OAAO,QAAQ,SAAS;AAAA,IACnC,WAAW,OAAO,QAAQ,cAAc,YAAY,QAAQ,YACxD,QAAQ,YACR,CAAC;AAAA,IACL,SAAS,OAAO,QAAQ,OAAO;AAAA,IAC/B,gBAAgB,OAAO,QAAQ,cAAc;AAAA,IAC7C,iBAAiB,QAAQ;AAAA,IACzB,YAAY,QAAQ;AAAA,IACpB,YAAY,QAAQ;AAAA,EACtB;AACF;","names":[]}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// src/errors.ts
|
|
2
|
+
var PamelaError = class extends Error {
|
|
3
|
+
constructor(message, options) {
|
|
4
|
+
super(message);
|
|
5
|
+
this.name = "PamelaError";
|
|
6
|
+
this.errorCode = options?.errorCode;
|
|
7
|
+
this.details = options?.details;
|
|
8
|
+
this.statusCode = options?.statusCode;
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
var AuthenticationError = class extends PamelaError {
|
|
12
|
+
constructor(message, options) {
|
|
13
|
+
super(message, options);
|
|
14
|
+
this.name = "AuthenticationError";
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
var SubscriptionError = class extends PamelaError {
|
|
18
|
+
constructor(message, options) {
|
|
19
|
+
super(message, options);
|
|
20
|
+
this.name = "SubscriptionError";
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
var RateLimitError = class extends PamelaError {
|
|
24
|
+
constructor(message, options) {
|
|
25
|
+
super(message, options);
|
|
26
|
+
this.name = "RateLimitError";
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
var ValidationError = class extends PamelaError {
|
|
30
|
+
constructor(message, options) {
|
|
31
|
+
super(message, options);
|
|
32
|
+
this.name = "ValidationError";
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
var CallError = class extends PamelaError {
|
|
36
|
+
constructor(message, options) {
|
|
37
|
+
super(message, options);
|
|
38
|
+
this.name = "CallError";
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export {
|
|
43
|
+
PamelaError,
|
|
44
|
+
AuthenticationError,
|
|
45
|
+
SubscriptionError,
|
|
46
|
+
RateLimitError,
|
|
47
|
+
ValidationError,
|
|
48
|
+
CallError
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=chunk-NQIPPPEL.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/errors.ts"],"sourcesContent":["export class PamelaError extends Error {\n public errorCode?: number;\n public details?: Record<string, any>;\n public statusCode?: number;\n\n constructor(message: string, options?: { errorCode?: number; details?: Record<string, any>; statusCode?: number }) {\n super(message);\n this.name = 'PamelaError';\n this.errorCode = options?.errorCode;\n this.details = options?.details;\n this.statusCode = options?.statusCode;\n }\n}\n\nexport class AuthenticationError extends PamelaError {\n constructor(message: string, options?: { errorCode?: number; details?: Record<string, any>; statusCode?: number }) {\n super(message, options);\n this.name = 'AuthenticationError';\n }\n}\n\nexport class SubscriptionError extends PamelaError {\n constructor(message: string, options?: { errorCode?: number; details?: Record<string, any>; statusCode?: number }) {\n super(message, options);\n this.name = 'SubscriptionError';\n }\n}\n\nexport class RateLimitError extends PamelaError {\n constructor(message: string, options?: { errorCode?: number; details?: Record<string, any>; statusCode?: number }) {\n super(message, options);\n this.name = 'RateLimitError';\n }\n}\n\nexport class ValidationError extends PamelaError {\n constructor(message: string, options?: { errorCode?: number; details?: Record<string, any>; statusCode?: number }) {\n super(message, options);\n this.name = 'ValidationError';\n }\n}\n\nexport class CallError extends PamelaError {\n constructor(message: string, options?: { errorCode?: number; details?: Record<string, any>; statusCode?: number }) {\n super(message, options);\n this.name = 'CallError';\n }\n}\n"],"mappings":";AAAO,IAAM,cAAN,cAA0B,MAAM;AAAA,EAKrC,YAAY,SAAiB,SAAsF;AACjH,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,YAAY,SAAS;AAC1B,SAAK,UAAU,SAAS;AACxB,SAAK,aAAa,SAAS;AAAA,EAC7B;AACF;AAEO,IAAM,sBAAN,cAAkC,YAAY;AAAA,EACnD,YAAY,SAAiB,SAAsF;AACjH,UAAM,SAAS,OAAO;AACtB,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,oBAAN,cAAgC,YAAY;AAAA,EACjD,YAAY,SAAiB,SAAsF;AACjH,UAAM,SAAS,OAAO;AACtB,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,iBAAN,cAA6B,YAAY;AAAA,EAC9C,YAAY,SAAiB,SAAsF;AACjH,UAAM,SAAS,OAAO;AACtB,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,kBAAN,cAA8B,YAAY;AAAA,EAC/C,YAAY,SAAiB,SAAsF;AACjH,UAAM,SAAS,OAAO;AACtB,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,YAAN,cAAwB,YAAY;AAAA,EACzC,YAAY,SAAiB,SAAsF;AACjH,UAAM,SAAS,OAAO;AACtB,SAAK,OAAO;AAAA,EACd;AACF;","names":[]}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// src/types.ts
|
|
2
|
+
var ErrorCodes = {
|
|
3
|
+
// Auth errors (1000-1999)
|
|
4
|
+
AUTH_REQUIRED: 1001,
|
|
5
|
+
AUTH_INVALID: 1002,
|
|
6
|
+
AUTH_EXPIRED: 1003,
|
|
7
|
+
AUTH_INSUFFICIENT_PERMISSIONS: 1004,
|
|
8
|
+
AUTH_FORBIDDEN: 1005,
|
|
9
|
+
// Validation errors (2000-2999)
|
|
10
|
+
VALIDATION_ERROR: 2001,
|
|
11
|
+
INVALID_PHONE: 2002,
|
|
12
|
+
INVALID_EMAIL: 2003,
|
|
13
|
+
INVALID_PASSWORD: 2004,
|
|
14
|
+
MISSING_REQUIRED_FIELD: 2005,
|
|
15
|
+
INVALID_JSON: 2006,
|
|
16
|
+
INVALID_REQUEST_BODY: 2007,
|
|
17
|
+
// Not found errors (3000-3999)
|
|
18
|
+
NOT_FOUND: 3001,
|
|
19
|
+
USER_NOT_FOUND: 3002,
|
|
20
|
+
CONVERSATION_NOT_FOUND: 3003,
|
|
21
|
+
CALL_SESSION_NOT_FOUND: 3004,
|
|
22
|
+
RESOURCE_NOT_FOUND: 3005,
|
|
23
|
+
MESSAGE_NOT_FOUND: 3006,
|
|
24
|
+
// Conflict errors (4000-4999)
|
|
25
|
+
RESOURCE_ALREADY_EXISTS: 4001,
|
|
26
|
+
EMAIL_ALREADY_REGISTERED: 4002,
|
|
27
|
+
ACCOUNT_LINKING_REQUIRED: 4003,
|
|
28
|
+
// Server errors (5000-5999)
|
|
29
|
+
INTERNAL_ERROR: 5001,
|
|
30
|
+
EXTERNAL_SERVICE_ERROR: 5002,
|
|
31
|
+
DATABASE_ERROR: 5003,
|
|
32
|
+
CONFIGURATION_ERROR: 5004,
|
|
33
|
+
// Rate limiting (6000-6999)
|
|
34
|
+
RATE_LIMIT_EXCEEDED: 6001,
|
|
35
|
+
QUOTA_EXCEEDED: 6002,
|
|
36
|
+
// B2B errors (7000-7999)
|
|
37
|
+
B2B_PARTNER_NOT_FOUND: 7001,
|
|
38
|
+
B2B_PROJECT_NOT_FOUND: 7002,
|
|
39
|
+
B2B_CALL_NOT_FOUND: 7003,
|
|
40
|
+
B2B_NO_PHONE_NUMBER: 7004,
|
|
41
|
+
B2B_UNSUPPORTED_COUNTRY: 7005,
|
|
42
|
+
B2B_TOOL_EXECUTION_FAILED: 7006,
|
|
43
|
+
B2B_WEBHOOK_DELIVERY_FAILED: 7007,
|
|
44
|
+
SUBSCRIPTION_EXPIRED: 7008
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export {
|
|
48
|
+
ErrorCodes
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=chunk-WMXO6YYV.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/types.ts"],"sourcesContent":["export interface PamelaClientConfig {\n apiKey: string;\n baseUrl?: string;\n}\n\nexport interface CreateCallRequest {\n to: string;\n country?: string;\n locale?: string;\n task: string;\n instructions?: string;\n max_duration_seconds?: number;\n voice?: 'male' | 'female' | 'auto';\n agent_name?: string;\n caller_name?: string;\n end_user_id?: string;\n metadata?: Record<string, any>;\n tools?: Array<Record<string, any>>;\n webhooks?: {\n webhook_url?: string;\n tool_webhook_url?: string;\n };\n}\n\nexport type CallStatusValue =\n | 'initiating'\n | 'queued'\n | 'ringing'\n | 'in_progress'\n | 'completed'\n | 'failed'\n | 'cancelled'\n | 'timeout_terminated'\n | 'in-progress';\n\nexport interface CallResponse {\n id: string;\n status: CallStatusValue | string;\n call_session_id: string;\n created_at: string;\n}\n\nexport interface CallStatus {\n id: string;\n status: CallStatusValue | string;\n to: string;\n from_: string; // Backend uses from_ (Python keyword)\n country: string;\n created_at: string;\n started_at?: string;\n completed_at?: string;\n duration_seconds?: number;\n max_duration_seconds?: number;\n transcript?: Array<Record<string, any>>;\n summary?: string;\n metadata: Record<string, any>;\n end_user_id?: string; // Marketplace end-user ID for privacy isolation\n}\n\nexport interface ToolDefinition {\n name: string;\n description: string;\n input_schema: Record<string, any>;\n output_schema?: Record<string, any>;\n timeout_ms?: number;\n}\n\nexport interface WebhookPayload {\n event: string;\n call_id: string;\n call_session_id: string;\n timestamp: string;\n data: Record<string, any>;\n}\n\n/** Standard error codes (aligned with backend models/errors.py) */\nexport const ErrorCodes = {\n // Auth errors (1000-1999)\n AUTH_REQUIRED: 1001,\n AUTH_INVALID: 1002,\n AUTH_EXPIRED: 1003,\n AUTH_INSUFFICIENT_PERMISSIONS: 1004,\n AUTH_FORBIDDEN: 1005,\n\n // Validation errors (2000-2999)\n VALIDATION_ERROR: 2001,\n INVALID_PHONE: 2002,\n INVALID_EMAIL: 2003,\n INVALID_PASSWORD: 2004,\n MISSING_REQUIRED_FIELD: 2005,\n INVALID_JSON: 2006,\n INVALID_REQUEST_BODY: 2007,\n\n // Not found errors (3000-3999)\n NOT_FOUND: 3001,\n USER_NOT_FOUND: 3002,\n CONVERSATION_NOT_FOUND: 3003,\n CALL_SESSION_NOT_FOUND: 3004,\n RESOURCE_NOT_FOUND: 3005,\n MESSAGE_NOT_FOUND: 3006,\n\n // Conflict errors (4000-4999)\n RESOURCE_ALREADY_EXISTS: 4001,\n EMAIL_ALREADY_REGISTERED: 4002,\n ACCOUNT_LINKING_REQUIRED: 4003,\n\n // Server errors (5000-5999)\n INTERNAL_ERROR: 5001,\n EXTERNAL_SERVICE_ERROR: 5002,\n DATABASE_ERROR: 5003,\n CONFIGURATION_ERROR: 5004,\n\n // Rate limiting (6000-6999)\n RATE_LIMIT_EXCEEDED: 6001,\n QUOTA_EXCEEDED: 6002,\n\n // B2B errors (7000-7999)\n B2B_PARTNER_NOT_FOUND: 7001,\n B2B_PROJECT_NOT_FOUND: 7002,\n B2B_CALL_NOT_FOUND: 7003,\n B2B_NO_PHONE_NUMBER: 7004,\n B2B_UNSUPPORTED_COUNTRY: 7005,\n B2B_TOOL_EXECUTION_FAILED: 7006,\n B2B_WEBHOOK_DELIVERY_FAILED: 7007,\n SUBSCRIPTION_EXPIRED: 7008,\n} as const;\n"],"mappings":";AA4EO,IAAM,aAAa;AAAA;AAAA,EAExB,eAAe;AAAA,EACf,cAAc;AAAA,EACd,cAAc;AAAA,EACd,+BAA+B;AAAA,EAC/B,gBAAgB;AAAA;AAAA,EAGhB,kBAAkB;AAAA,EAClB,eAAe;AAAA,EACf,eAAe;AAAA,EACf,kBAAkB;AAAA,EAClB,wBAAwB;AAAA,EACxB,cAAc;AAAA,EACd,sBAAsB;AAAA;AAAA,EAGtB,WAAW;AAAA,EACX,gBAAgB;AAAA,EAChB,wBAAwB;AAAA,EACxB,wBAAwB;AAAA,EACxB,oBAAoB;AAAA,EACpB,mBAAmB;AAAA;AAAA,EAGnB,yBAAyB;AAAA,EACzB,0BAA0B;AAAA,EAC1B,0BAA0B;AAAA;AAAA,EAG1B,gBAAgB;AAAA,EAChB,wBAAwB;AAAA,EACxB,gBAAgB;AAAA,EAChB,qBAAqB;AAAA;AAAA,EAGrB,qBAAqB;AAAA,EACrB,gBAAgB;AAAA;AAAA,EAGhB,uBAAuB;AAAA,EACvB,uBAAuB;AAAA,EACvB,oBAAoB;AAAA,EACpB,qBAAqB;AAAA,EACrB,yBAAyB;AAAA,EACzB,2BAA2B;AAAA,EAC3B,6BAA6B;AAAA,EAC7B,sBAAsB;AACxB;","names":[]}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
declare class PamelaError extends Error {
|
|
2
|
+
errorCode?: number;
|
|
3
|
+
details?: Record<string, any>;
|
|
4
|
+
statusCode?: number;
|
|
5
|
+
constructor(message: string, options?: {
|
|
6
|
+
errorCode?: number;
|
|
7
|
+
details?: Record<string, any>;
|
|
8
|
+
statusCode?: number;
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
declare class AuthenticationError extends PamelaError {
|
|
12
|
+
constructor(message: string, options?: {
|
|
13
|
+
errorCode?: number;
|
|
14
|
+
details?: Record<string, any>;
|
|
15
|
+
statusCode?: number;
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
declare class SubscriptionError extends PamelaError {
|
|
19
|
+
constructor(message: string, options?: {
|
|
20
|
+
errorCode?: number;
|
|
21
|
+
details?: Record<string, any>;
|
|
22
|
+
statusCode?: number;
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
declare class RateLimitError extends PamelaError {
|
|
26
|
+
constructor(message: string, options?: {
|
|
27
|
+
errorCode?: number;
|
|
28
|
+
details?: Record<string, any>;
|
|
29
|
+
statusCode?: number;
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
declare class ValidationError extends PamelaError {
|
|
33
|
+
constructor(message: string, options?: {
|
|
34
|
+
errorCode?: number;
|
|
35
|
+
details?: Record<string, any>;
|
|
36
|
+
statusCode?: number;
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
declare class CallError extends PamelaError {
|
|
40
|
+
constructor(message: string, options?: {
|
|
41
|
+
errorCode?: number;
|
|
42
|
+
details?: Record<string, any>;
|
|
43
|
+
statusCode?: number;
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export { AuthenticationError, CallError, PamelaError, RateLimitError, SubscriptionError, ValidationError };
|
package/dist/errors.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
declare class PamelaError extends Error {
|
|
2
2
|
errorCode?: number;
|
|
3
3
|
details?: Record<string, any>;
|
|
4
4
|
statusCode?: number;
|
|
@@ -8,38 +8,40 @@ export declare class PamelaError extends Error {
|
|
|
8
8
|
statusCode?: number;
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
|
-
|
|
11
|
+
declare class AuthenticationError extends PamelaError {
|
|
12
12
|
constructor(message: string, options?: {
|
|
13
13
|
errorCode?: number;
|
|
14
14
|
details?: Record<string, any>;
|
|
15
15
|
statusCode?: number;
|
|
16
16
|
});
|
|
17
17
|
}
|
|
18
|
-
|
|
18
|
+
declare class SubscriptionError extends PamelaError {
|
|
19
19
|
constructor(message: string, options?: {
|
|
20
20
|
errorCode?: number;
|
|
21
21
|
details?: Record<string, any>;
|
|
22
22
|
statusCode?: number;
|
|
23
23
|
});
|
|
24
24
|
}
|
|
25
|
-
|
|
25
|
+
declare class RateLimitError extends PamelaError {
|
|
26
26
|
constructor(message: string, options?: {
|
|
27
27
|
errorCode?: number;
|
|
28
28
|
details?: Record<string, any>;
|
|
29
29
|
statusCode?: number;
|
|
30
30
|
});
|
|
31
31
|
}
|
|
32
|
-
|
|
32
|
+
declare class ValidationError extends PamelaError {
|
|
33
33
|
constructor(message: string, options?: {
|
|
34
34
|
errorCode?: number;
|
|
35
35
|
details?: Record<string, any>;
|
|
36
36
|
statusCode?: number;
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
|
-
|
|
39
|
+
declare class CallError extends PamelaError {
|
|
40
40
|
constructor(message: string, options?: {
|
|
41
41
|
errorCode?: number;
|
|
42
42
|
details?: Record<string, any>;
|
|
43
43
|
statusCode?: number;
|
|
44
44
|
});
|
|
45
45
|
}
|
|
46
|
+
|
|
47
|
+
export { AuthenticationError, CallError, PamelaError, RateLimitError, SubscriptionError, ValidationError };
|
package/dist/errors.js
CHANGED
|
@@ -1,48 +1,79 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/errors.ts
|
|
21
|
+
var errors_exports = {};
|
|
22
|
+
__export(errors_exports, {
|
|
23
|
+
AuthenticationError: () => AuthenticationError,
|
|
24
|
+
CallError: () => CallError,
|
|
25
|
+
PamelaError: () => PamelaError,
|
|
26
|
+
RateLimitError: () => RateLimitError,
|
|
27
|
+
SubscriptionError: () => SubscriptionError,
|
|
28
|
+
ValidationError: () => ValidationError
|
|
29
|
+
});
|
|
30
|
+
module.exports = __toCommonJS(errors_exports);
|
|
31
|
+
var PamelaError = class extends Error {
|
|
32
|
+
constructor(message, options) {
|
|
33
|
+
super(message);
|
|
34
|
+
this.name = "PamelaError";
|
|
35
|
+
this.errorCode = options?.errorCode;
|
|
36
|
+
this.details = options?.details;
|
|
37
|
+
this.statusCode = options?.statusCode;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
var AuthenticationError = class extends PamelaError {
|
|
41
|
+
constructor(message, options) {
|
|
42
|
+
super(message, options);
|
|
43
|
+
this.name = "AuthenticationError";
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
var SubscriptionError = class extends PamelaError {
|
|
47
|
+
constructor(message, options) {
|
|
48
|
+
super(message, options);
|
|
49
|
+
this.name = "SubscriptionError";
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
var RateLimitError = class extends PamelaError {
|
|
53
|
+
constructor(message, options) {
|
|
54
|
+
super(message, options);
|
|
55
|
+
this.name = "RateLimitError";
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
var ValidationError = class extends PamelaError {
|
|
59
|
+
constructor(message, options) {
|
|
60
|
+
super(message, options);
|
|
61
|
+
this.name = "ValidationError";
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
var CallError = class extends PamelaError {
|
|
65
|
+
constructor(message, options) {
|
|
66
|
+
super(message, options);
|
|
67
|
+
this.name = "CallError";
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
71
|
+
0 && (module.exports = {
|
|
72
|
+
AuthenticationError,
|
|
73
|
+
CallError,
|
|
74
|
+
PamelaError,
|
|
75
|
+
RateLimitError,
|
|
76
|
+
SubscriptionError,
|
|
77
|
+
ValidationError
|
|
78
|
+
});
|
|
79
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/errors.ts"],"sourcesContent":["export class PamelaError extends Error {\n public errorCode?: number;\n public details?: Record<string, any>;\n public statusCode?: number;\n\n constructor(message: string, options?: { errorCode?: number; details?: Record<string, any>; statusCode?: number }) {\n super(message);\n this.name = 'PamelaError';\n this.errorCode = options?.errorCode;\n this.details = options?.details;\n this.statusCode = options?.statusCode;\n }\n}\n\nexport class AuthenticationError extends PamelaError {\n constructor(message: string, options?: { errorCode?: number; details?: Record<string, any>; statusCode?: number }) {\n super(message, options);\n this.name = 'AuthenticationError';\n }\n}\n\nexport class SubscriptionError extends PamelaError {\n constructor(message: string, options?: { errorCode?: number; details?: Record<string, any>; statusCode?: number }) {\n super(message, options);\n this.name = 'SubscriptionError';\n }\n}\n\nexport class RateLimitError extends PamelaError {\n constructor(message: string, options?: { errorCode?: number; details?: Record<string, any>; statusCode?: number }) {\n super(message, options);\n this.name = 'RateLimitError';\n }\n}\n\nexport class ValidationError extends PamelaError {\n constructor(message: string, options?: { errorCode?: number; details?: Record<string, any>; statusCode?: number }) {\n super(message, options);\n this.name = 'ValidationError';\n }\n}\n\nexport class CallError extends PamelaError {\n constructor(message: string, options?: { errorCode?: number; details?: Record<string, any>; statusCode?: number }) {\n super(message, options);\n this.name = 'CallError';\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,IAAM,cAAN,cAA0B,MAAM;AAAA,EAKrC,YAAY,SAAiB,SAAsF;AACjH,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,YAAY,SAAS;AAC1B,SAAK,UAAU,SAAS;AACxB,SAAK,aAAa,SAAS;AAAA,EAC7B;AACF;AAEO,IAAM,sBAAN,cAAkC,YAAY;AAAA,EACnD,YAAY,SAAiB,SAAsF;AACjH,UAAM,SAAS,OAAO;AACtB,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,oBAAN,cAAgC,YAAY;AAAA,EACjD,YAAY,SAAiB,SAAsF;AACjH,UAAM,SAAS,OAAO;AACtB,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,iBAAN,cAA6B,YAAY;AAAA,EAC9C,YAAY,SAAiB,SAAsF;AACjH,UAAM,SAAS,OAAO;AACtB,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,kBAAN,cAA8B,YAAY;AAAA,EAC/C,YAAY,SAAiB,SAAsF;AACjH,UAAM,SAAS,OAAO;AACtB,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,YAAN,cAAwB,YAAY;AAAA,EACzC,YAAY,SAAiB,SAAsF;AACjH,UAAM,SAAS,OAAO;AACtB,SAAK,OAAO;AAAA,EACd;AACF;","names":[]}
|
package/dist/errors.mjs
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AuthenticationError,
|
|
3
|
+
CallError,
|
|
4
|
+
PamelaError,
|
|
5
|
+
RateLimitError,
|
|
6
|
+
SubscriptionError,
|
|
7
|
+
ValidationError
|
|
8
|
+
} from "./chunk-NQIPPPEL.mjs";
|
|
9
|
+
export {
|
|
10
|
+
AuthenticationError,
|
|
11
|
+
CallError,
|
|
12
|
+
PamelaError,
|
|
13
|
+
RateLimitError,
|
|
14
|
+
SubscriptionError,
|
|
15
|
+
ValidationError
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=errors.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { AxiosInstance } from 'axios';
|
|
2
|
+
export { AuthenticationError, CallError, PamelaError, RateLimitError, SubscriptionError, ValidationError } from './errors.mjs';
|
|
3
|
+
import { PamelaClientConfig, CreateCallRequest, CallResponse, CallStatus, ToolDefinition } from './types.mjs';
|
|
4
|
+
export { CallStatusValue, ErrorCodes, WebhookPayload } from './types.mjs';
|
|
5
|
+
export { parseToolWebhook, verifyWebhookSignature } from './webhooks.mjs';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Pamela Enterprise Voice API SDK for JavaScript/TypeScript
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
declare class UsageClient {
|
|
12
|
+
private client;
|
|
13
|
+
constructor(client: AxiosInstance);
|
|
14
|
+
/**
|
|
15
|
+
* Get usage statistics for partner/project.
|
|
16
|
+
*/
|
|
17
|
+
get(period?: string): Promise<{
|
|
18
|
+
partner_id: string;
|
|
19
|
+
project_id?: string;
|
|
20
|
+
period: string;
|
|
21
|
+
call_count: number;
|
|
22
|
+
last_updated?: string;
|
|
23
|
+
quota?: {
|
|
24
|
+
partner_limit?: number;
|
|
25
|
+
project_limit?: number;
|
|
26
|
+
};
|
|
27
|
+
}>;
|
|
28
|
+
}
|
|
29
|
+
declare class PamelaClient {
|
|
30
|
+
private client;
|
|
31
|
+
private apiKey;
|
|
32
|
+
usage: UsageClient;
|
|
33
|
+
constructor(config: PamelaClientConfig);
|
|
34
|
+
/**
|
|
35
|
+
* Create a new call.
|
|
36
|
+
*/
|
|
37
|
+
createCall(request: CreateCallRequest): Promise<CallResponse>;
|
|
38
|
+
/**
|
|
39
|
+
* Get call status and details.
|
|
40
|
+
*/
|
|
41
|
+
getCall(callId: string): Promise<CallStatus>;
|
|
42
|
+
/**
|
|
43
|
+
* List calls for the authenticated partner/project.
|
|
44
|
+
*/
|
|
45
|
+
listCalls(params?: {
|
|
46
|
+
status?: string;
|
|
47
|
+
status_filter?: string;
|
|
48
|
+
limit?: number;
|
|
49
|
+
offset?: number;
|
|
50
|
+
start_date?: string;
|
|
51
|
+
end_date?: string;
|
|
52
|
+
}): Promise<{
|
|
53
|
+
items: CallStatus[];
|
|
54
|
+
total: number;
|
|
55
|
+
limit: number;
|
|
56
|
+
offset: number;
|
|
57
|
+
}>;
|
|
58
|
+
/**
|
|
59
|
+
* Cancel an in-progress call.
|
|
60
|
+
*/
|
|
61
|
+
cancelCall(callId: string): Promise<{
|
|
62
|
+
success: boolean;
|
|
63
|
+
call_id: string;
|
|
64
|
+
status: string;
|
|
65
|
+
}>;
|
|
66
|
+
/**
|
|
67
|
+
* Force hangup an in-progress call.
|
|
68
|
+
*/
|
|
69
|
+
hangupCall(callId: string): Promise<{
|
|
70
|
+
success: boolean;
|
|
71
|
+
call_id: string;
|
|
72
|
+
status: string;
|
|
73
|
+
}>;
|
|
74
|
+
/**
|
|
75
|
+
* Register a tool.
|
|
76
|
+
*/
|
|
77
|
+
registerTool(tool: ToolDefinition): Promise<{
|
|
78
|
+
id: string;
|
|
79
|
+
project_id: string;
|
|
80
|
+
name: string;
|
|
81
|
+
description: string;
|
|
82
|
+
input_schema: Record<string, any>;
|
|
83
|
+
output_schema: Record<string, any>;
|
|
84
|
+
timeout_ms: number;
|
|
85
|
+
created_at: string;
|
|
86
|
+
}>;
|
|
87
|
+
/**
|
|
88
|
+
* List all tools for the project.
|
|
89
|
+
*/
|
|
90
|
+
listTools(): Promise<Array<{
|
|
91
|
+
id: string;
|
|
92
|
+
project_id: string;
|
|
93
|
+
name: string;
|
|
94
|
+
description: string;
|
|
95
|
+
input_schema: Record<string, any>;
|
|
96
|
+
output_schema: Record<string, any>;
|
|
97
|
+
timeout_ms: number;
|
|
98
|
+
created_at: string;
|
|
99
|
+
}>>;
|
|
100
|
+
/**
|
|
101
|
+
* Delete a tool.
|
|
102
|
+
*/
|
|
103
|
+
deleteTool(toolId: string): Promise<{
|
|
104
|
+
success: boolean;
|
|
105
|
+
tool_id: string;
|
|
106
|
+
}>;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export { CallResponse, CallStatus, CreateCallRequest, PamelaClient as Pamela, PamelaClient, PamelaClientConfig, ToolDefinition, UsageClient, PamelaClient as default };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,65 +1,14 @@
|
|
|
1
|
+
import { AxiosInstance } from 'axios';
|
|
2
|
+
export { AuthenticationError, CallError, PamelaError, RateLimitError, SubscriptionError, ValidationError } from './errors.js';
|
|
3
|
+
import { PamelaClientConfig, CreateCallRequest, CallResponse, CallStatus, ToolDefinition } from './types.js';
|
|
4
|
+
export { CallStatusValue, ErrorCodes, WebhookPayload } from './types.js';
|
|
5
|
+
export { parseToolWebhook, verifyWebhookSignature } from './webhooks.js';
|
|
6
|
+
|
|
1
7
|
/**
|
|
2
8
|
* Pamela Enterprise Voice API SDK for JavaScript/TypeScript
|
|
3
9
|
*/
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export interface PamelaClientConfig {
|
|
7
|
-
apiKey: string;
|
|
8
|
-
baseUrl?: string;
|
|
9
|
-
}
|
|
10
|
-
export interface CreateCallRequest {
|
|
11
|
-
to: string;
|
|
12
|
-
country?: string;
|
|
13
|
-
locale?: string;
|
|
14
|
-
task: string;
|
|
15
|
-
instructions?: string;
|
|
16
|
-
voice?: 'male' | 'female' | 'auto';
|
|
17
|
-
agent_name?: string;
|
|
18
|
-
caller_name?: string;
|
|
19
|
-
end_user_id?: string;
|
|
20
|
-
metadata?: Record<string, any>;
|
|
21
|
-
tools?: Array<Record<string, any>>;
|
|
22
|
-
webhooks?: {
|
|
23
|
-
webhook_url?: string;
|
|
24
|
-
tool_webhook_url?: string;
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
export interface CallResponse {
|
|
28
|
-
id: string;
|
|
29
|
-
status: string;
|
|
30
|
-
call_session_id: string;
|
|
31
|
-
created_at: string;
|
|
32
|
-
}
|
|
33
|
-
export interface CallStatus {
|
|
34
|
-
id: string;
|
|
35
|
-
status: string;
|
|
36
|
-
to: string;
|
|
37
|
-
from_: string;
|
|
38
|
-
country: string;
|
|
39
|
-
created_at: string;
|
|
40
|
-
started_at?: string;
|
|
41
|
-
completed_at?: string;
|
|
42
|
-
duration_seconds?: number;
|
|
43
|
-
transcript?: Array<Record<string, any>>;
|
|
44
|
-
summary?: string;
|
|
45
|
-
metadata: Record<string, any>;
|
|
46
|
-
end_user_id?: string;
|
|
47
|
-
}
|
|
48
|
-
export interface ToolDefinition {
|
|
49
|
-
name: string;
|
|
50
|
-
description: string;
|
|
51
|
-
input_schema: Record<string, any>;
|
|
52
|
-
output_schema?: Record<string, any>;
|
|
53
|
-
timeout_ms?: number;
|
|
54
|
-
}
|
|
55
|
-
export interface WebhookPayload {
|
|
56
|
-
event: string;
|
|
57
|
-
call_id: string;
|
|
58
|
-
call_session_id: string;
|
|
59
|
-
timestamp: string;
|
|
60
|
-
data: Record<string, any>;
|
|
61
|
-
}
|
|
62
|
-
export declare class UsageClient {
|
|
10
|
+
|
|
11
|
+
declare class UsageClient {
|
|
63
12
|
private client;
|
|
64
13
|
constructor(client: AxiosInstance);
|
|
65
14
|
/**
|
|
@@ -77,7 +26,7 @@ export declare class UsageClient {
|
|
|
77
26
|
};
|
|
78
27
|
}>;
|
|
79
28
|
}
|
|
80
|
-
|
|
29
|
+
declare class PamelaClient {
|
|
81
30
|
private client;
|
|
82
31
|
private apiKey;
|
|
83
32
|
usage: UsageClient;
|
|
@@ -114,6 +63,14 @@ export declare class PamelaClient {
|
|
|
114
63
|
call_id: string;
|
|
115
64
|
status: string;
|
|
116
65
|
}>;
|
|
66
|
+
/**
|
|
67
|
+
* Force hangup an in-progress call.
|
|
68
|
+
*/
|
|
69
|
+
hangupCall(callId: string): Promise<{
|
|
70
|
+
success: boolean;
|
|
71
|
+
call_id: string;
|
|
72
|
+
status: string;
|
|
73
|
+
}>;
|
|
117
74
|
/**
|
|
118
75
|
* Register a tool.
|
|
119
76
|
*/
|
|
@@ -147,11 +104,6 @@ export declare class PamelaClient {
|
|
|
147
104
|
success: boolean;
|
|
148
105
|
tool_id: string;
|
|
149
106
|
}>;
|
|
150
|
-
/**
|
|
151
|
-
* Verify webhook signature.
|
|
152
|
-
*/
|
|
153
|
-
static verifyWebhookSignature(payload: string | object, signature: string, secret: string): boolean;
|
|
154
107
|
}
|
|
155
|
-
|
|
156
|
-
export { PamelaClient as Pamela };
|
|
157
|
-
export { PamelaError, AuthenticationError, SubscriptionError, RateLimitError, ValidationError, CallError, };
|
|
108
|
+
|
|
109
|
+
export { CallResponse, CallStatus, CreateCallRequest, PamelaClient as Pamela, PamelaClient, PamelaClientConfig, ToolDefinition, UsageClient, PamelaClient as default };
|