nixflex-mcp 0.5.0 → 0.5.1
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/CHANGELOG.md +4 -0
- package/KIT-EXAMPLES-K6.md +118 -118
- package/LICENSE +9 -9
- package/README.md +1 -0
- package/agent-reads.js +26 -26
- package/agent-schema.js +24 -24
- package/c6-output.js +32 -32
- package/c6-tools.js +35 -35
- package/call-reads.js +43 -43
- package/call-tools.js +22 -22
- package/campaign-schema.js +38 -38
- package/core-tools.js +36 -36
- package/foundation/connection.mjs +48 -48
- package/foundation/launch.mjs +39 -39
- package/foundation/origin-fence.mjs +21 -21
- package/foundation/origins.mjs +15 -15
- package/index.js +165 -165
- package/k6-private.js +36 -36
- package/k6-schemas.js +27 -27
- package/k6-tools.js +42 -42
- package/k7-call.js +34 -34
- package/k7-errors.js +16 -16
- package/k7-schemas.js +34 -34
- package/k7-tools.js +20 -20
- package/k9-deletes.js +90 -90
- package/kit-request.js +24 -24
- package/knowledge-request.js +24 -24
- package/number-reads.js +23 -23
- package/number-schema.js +26 -26
- package/number-usage.js +13 -13
- package/organisation-tools.js +26 -26
- package/package.json +2 -1
- package/safe-tools.js +36 -36
package/k7-call.js
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
import * as z from 'zod/v4';
|
|
2
|
-
import {randomUUID} from 'node:crypto';
|
|
3
|
-
import {createCallBody} from './call-tools.js';
|
|
4
|
-
import {executeTool,errorBody} from './safe-tools.js';
|
|
5
|
-
import {requestId,acceptanceOutput} from './k7-schemas.js';
|
|
6
|
-
import {callRequestError} from './k7-errors.js';
|
|
7
|
-
const text=v=>({content:[{type:'text',text:JSON.stringify(v,null,2)}]});
|
|
8
|
-
const description='Place an outbound phone call now. SPENDS credit. prompt is the purpose of this call in full; variables fill {{placeholders}}.';
|
|
9
|
-
export function registerK7CreateCall(server,{client,request,metadata,E164,contactLocation}){
|
|
10
|
-
const schema=z.object({agent_id:z.string(),to_number:E164,prompt:z.string(),
|
|
11
|
-
from_number:E164.optional().describe('One of your numbers; defaults to an eligible outbound number'),
|
|
12
|
-
variables:z.record(z.string(),z.string()).optional(),...contactLocation,
|
|
13
|
-
request_id:requestId.optional().describe('Saved UUID for exactly this call intent. Never replace it to retry an uncertain call.'),
|
|
14
|
-
safe_retry:z.boolean().optional().describe('Without request_id: prepare a UUID, place no call. Then reuse the returned UUID and identical inputs with confirm:true.'),
|
|
15
|
-
confirm:z.boolean().optional().describe('Required true for the new request_id path. Does not replace the saved UUID or bypass server admission.')});
|
|
16
|
-
server.registerTool('create_call',{...metadata('create_call',description+' Optional safe_retry prepares a UUID locally without dialling. request_id requires confirm:true; reuse unchanged inputs. The legacy path without either option is unchanged.'),inputSchema:schema},
|
|
17
|
-
createCallHandler(client,request));
|
|
18
|
-
}
|
|
19
|
-
export function createCallHandler(client,request){
|
|
20
|
-
return async args=>{
|
|
21
|
-
const {safe_retry,confirm,...input}=args;
|
|
22
|
-
if(safe_retry===true&&input.request_id===undefined)return text({confirmation_required:true,sent:false,
|
|
23
|
-
request_id:randomUUID(),hint:'Save this UUID and the exact call inputs before sending. Call again with that request_id and confirm:true. Never prepare another ID as a retry.'});
|
|
24
|
-
const durable=input.request_id!==undefined;
|
|
25
|
-
if(durable&&confirm!==true)return text({confirmation_required:true,sent:false,request_id:input.request_id,
|
|
26
|
-
hint:'Review this paid call with the human; use the same UUID and unchanged inputs with confirm:true.'});
|
|
27
|
-
try{
|
|
28
|
-
if(!durable)return text(await executeTool('create_call',()=>client.calls.create(createCallBody(input)),{}));
|
|
29
|
-
const body=createCallBody(input);
|
|
30
|
-
requestId.parse(input.request_id);
|
|
31
|
-
return text(acceptanceOutput(await request('POST','/calls/outbound',body),input.request_id));
|
|
32
|
-
}catch(error){return {...text(durable?callRequestError(error,input.request_id,true):errorBody(error)),isError:true};}
|
|
33
|
-
};
|
|
34
|
-
}
|
|
1
|
+
import * as z from 'zod/v4';
|
|
2
|
+
import {randomUUID} from 'node:crypto';
|
|
3
|
+
import {createCallBody} from './call-tools.js';
|
|
4
|
+
import {executeTool,errorBody} from './safe-tools.js';
|
|
5
|
+
import {requestId,acceptanceOutput} from './k7-schemas.js';
|
|
6
|
+
import {callRequestError} from './k7-errors.js';
|
|
7
|
+
const text=v=>({content:[{type:'text',text:JSON.stringify(v,null,2)}]});
|
|
8
|
+
const description='Place an outbound phone call now. SPENDS credit. prompt is the purpose of this call in full; variables fill {{placeholders}}.';
|
|
9
|
+
export function registerK7CreateCall(server,{client,request,metadata,E164,contactLocation}){
|
|
10
|
+
const schema=z.object({agent_id:z.string(),to_number:E164,prompt:z.string(),
|
|
11
|
+
from_number:E164.optional().describe('One of your numbers; defaults to an eligible outbound number'),
|
|
12
|
+
variables:z.record(z.string(),z.string()).optional(),...contactLocation,
|
|
13
|
+
request_id:requestId.optional().describe('Saved UUID for exactly this call intent. Never replace it to retry an uncertain call.'),
|
|
14
|
+
safe_retry:z.boolean().optional().describe('Without request_id: prepare a UUID, place no call. Then reuse the returned UUID and identical inputs with confirm:true.'),
|
|
15
|
+
confirm:z.boolean().optional().describe('Required true for the new request_id path. Does not replace the saved UUID or bypass server admission.')});
|
|
16
|
+
server.registerTool('create_call',{...metadata('create_call',description+' Optional safe_retry prepares a UUID locally without dialling. request_id requires confirm:true; reuse unchanged inputs. The legacy path without either option is unchanged.'),inputSchema:schema},
|
|
17
|
+
createCallHandler(client,request));
|
|
18
|
+
}
|
|
19
|
+
export function createCallHandler(client,request){
|
|
20
|
+
return async args=>{
|
|
21
|
+
const {safe_retry,confirm,...input}=args;
|
|
22
|
+
if(safe_retry===true&&input.request_id===undefined)return text({confirmation_required:true,sent:false,
|
|
23
|
+
request_id:randomUUID(),hint:'Save this UUID and the exact call inputs before sending. Call again with that request_id and confirm:true. Never prepare another ID as a retry.'});
|
|
24
|
+
const durable=input.request_id!==undefined;
|
|
25
|
+
if(durable&&confirm!==true)return text({confirmation_required:true,sent:false,request_id:input.request_id,
|
|
26
|
+
hint:'Review this paid call with the human; use the same UUID and unchanged inputs with confirm:true.'});
|
|
27
|
+
try{
|
|
28
|
+
if(!durable)return text(await executeTool('create_call',()=>client.calls.create(createCallBody(input)),{}));
|
|
29
|
+
const body=createCallBody(input);
|
|
30
|
+
requestId.parse(input.request_id);
|
|
31
|
+
return text(acceptanceOutput(await request('POST','/calls/outbound',body),input.request_id));
|
|
32
|
+
}catch(error){return {...text(durable?callRequestError(error,input.request_id,true):errorBody(error)),isError:true};}
|
|
33
|
+
};
|
|
34
|
+
}
|
package/k7-errors.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
// Protocol errors contain bounded codes/status and the non-secret request UUID.
|
|
2
|
-
// Never echo raw server messages, headers, URLs, request bodies or booking content.
|
|
3
|
-
export function callRequestError(value,id,mutation){
|
|
4
|
-
const e=value||{},raw=e.details||{},status=Number.isInteger(e.status)&&e.status>=0&&e.status<=599?e.status:0;
|
|
5
|
-
const original=e.code==='outcome_unknown'?raw.original_code:e.code;
|
|
6
|
-
const code=typeof original==='string'&&/^[a-z][a-z0-9_]{0,79}$/.test(original)&&!['unknown_error','invalid_response'].includes(original)
|
|
7
|
-
? original : mutation?'outbound_request_unknown':'invalid_response';
|
|
8
|
-
const details=id?{request_id:id}:{};
|
|
9
|
-
if(['pending','accepted','rejected','unknown'].includes(raw.state))details.state=raw.state;
|
|
10
|
-
if(mutation){details.safe_to_retry=false;if(!details.state&&(status===0||code==='outbound_request_unknown'))details.state='unknown';}
|
|
11
|
-
const type=({400:'invalid_request',422:'invalid_request',401:'authentication_error',402:'payment_required',403:'permission_denied',
|
|
12
|
-
404:'not_found',409:'conflict',429:'rate_limit'})[status]||(status>=500?'server_error':status===0&&mutation?'outcome_unknown':'error');
|
|
13
|
-
return {error:{type,code,status,request_id:id||null,details,
|
|
14
|
-
message:mutation?'Call request not confirmed. Keep this request_id; check its status and Call History before any manual retry. No automatic repeat.'
|
|
15
|
-
:'Call result could not be read. No booking or call outcome was inferred.'}};
|
|
16
|
-
}
|
|
1
|
+
// Protocol errors contain bounded codes/status and the non-secret request UUID.
|
|
2
|
+
// Never echo raw server messages, headers, URLs, request bodies or booking content.
|
|
3
|
+
export function callRequestError(value,id,mutation){
|
|
4
|
+
const e=value||{},raw=e.details||{},status=Number.isInteger(e.status)&&e.status>=0&&e.status<=599?e.status:0;
|
|
5
|
+
const original=e.code==='outcome_unknown'?raw.original_code:e.code;
|
|
6
|
+
const code=typeof original==='string'&&/^[a-z][a-z0-9_]{0,79}$/.test(original)&&!['unknown_error','invalid_response'].includes(original)
|
|
7
|
+
? original : mutation?'outbound_request_unknown':'invalid_response';
|
|
8
|
+
const details=id?{request_id:id}:{};
|
|
9
|
+
if(['pending','accepted','rejected','unknown'].includes(raw.state))details.state=raw.state;
|
|
10
|
+
if(mutation){details.safe_to_retry=false;if(!details.state&&(status===0||code==='outbound_request_unknown'))details.state='unknown';}
|
|
11
|
+
const type=({400:'invalid_request',422:'invalid_request',401:'authentication_error',402:'payment_required',403:'permission_denied',
|
|
12
|
+
404:'not_found',409:'conflict',429:'rate_limit'})[status]||(status>=500?'server_error':status===0&&mutation?'outcome_unknown':'error');
|
|
13
|
+
return {error:{type,code,status,request_id:id||null,details,
|
|
14
|
+
message:mutation?'Call request not confirmed. Keep this request_id; check its status and Call History before any manual retry. No automatic repeat.'
|
|
15
|
+
:'Call result could not be read. No booking or call outcome was inferred.'}};
|
|
16
|
+
}
|
package/k7-schemas.js
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
import * as z from 'zod/v4';
|
|
2
|
-
export const requestId = z.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i);
|
|
3
|
-
export const callId = z.string().min(1).max(200).regex(/^(?!\.{1,2}$)[^\u0000-\u001f]+$/);
|
|
4
|
-
const nullable = z.string().nullable();
|
|
5
|
-
const appointment = {booking_uid:z.string().min(1),start:nullable,end:nullable,
|
|
6
|
-
attendee_name:nullable,attendee_email:nullable,service:z.union([z.string(),z.number(),z.null()]),timezone:nullable};
|
|
7
|
-
export const callBookingResult = z.object({event:z.literal('call.bookings'),call_id:callId,agent_id:nullable,
|
|
8
|
-
from:nullable,to:nullable,number:nullable,ended_at:nullable,
|
|
9
|
-
timeline:z.array(z.object({action:z.enum(['created','rescheduled','cancelled']),...appointment,at:z.string()})).min(1),
|
|
10
|
-
final:z.array(z.object({...appointment,status:z.enum(['active','cancelled'])})).min(1)});
|
|
11
|
-
export const callBookings = z.discriminatedUnion('state',[
|
|
12
|
-
z.object({call_id:callId,state:z.literal('ready'),result:callBookingResult}),
|
|
13
|
-
...['none','processing','deleted','unavailable'].map(state=>z.object({call_id:callId,state:z.literal(state),result:z.null()}))
|
|
14
|
-
]);
|
|
15
|
-
export const outboundRequest = z.object({request_id:requestId,state:z.enum(['pending','accepted','rejected','unknown']),
|
|
16
|
-
call_id:nullable,reason:nullable});
|
|
17
|
-
export const acceptance = z.object({call_id:callId.regex(/^[^\u0000-\u0020]+$/),request_id:requestId,
|
|
18
|
-
status:z.literal('initiated'),replayed:z.literal(true).optional(),request_status:z.literal('unconfirmed').optional(),
|
|
19
|
-
safe_to_retry:z.literal(false).optional()}).passthrough();
|
|
20
|
-
export function bookingOutput(value,id){
|
|
21
|
-
const result=callBookings.parse(value);
|
|
22
|
-
if(result.call_id!==id||result.state==='ready'&&result.result.call_id!==id)throw Error('Invalid call result identity.');
|
|
23
|
-
return result;
|
|
24
|
-
}
|
|
25
|
-
export function requestOutput(value,id){
|
|
26
|
-
const result=outboundRequest.parse(value);
|
|
27
|
-
if(result.request_id.toLowerCase()!==id.toLowerCase()||result.state==='accepted'&&!result.call_id)throw Error('Invalid call request identity.');
|
|
28
|
-
return result;
|
|
29
|
-
}
|
|
30
|
-
export function acceptanceOutput(value,id){
|
|
31
|
-
const result=acceptance.parse(value);
|
|
32
|
-
if(result.request_id.toLowerCase()!==id.toLowerCase()||result.request_status==='unconfirmed'&&result.safe_to_retry!==false)throw Error('Invalid acceptance receipt.');
|
|
33
|
-
return result;
|
|
34
|
-
}
|
|
1
|
+
import * as z from 'zod/v4';
|
|
2
|
+
export const requestId = z.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i);
|
|
3
|
+
export const callId = z.string().min(1).max(200).regex(/^(?!\.{1,2}$)[^\u0000-\u001f]+$/);
|
|
4
|
+
const nullable = z.string().nullable();
|
|
5
|
+
const appointment = {booking_uid:z.string().min(1),start:nullable,end:nullable,
|
|
6
|
+
attendee_name:nullable,attendee_email:nullable,service:z.union([z.string(),z.number(),z.null()]),timezone:nullable};
|
|
7
|
+
export const callBookingResult = z.object({event:z.literal('call.bookings'),call_id:callId,agent_id:nullable,
|
|
8
|
+
from:nullable,to:nullable,number:nullable,ended_at:nullable,
|
|
9
|
+
timeline:z.array(z.object({action:z.enum(['created','rescheduled','cancelled']),...appointment,at:z.string()})).min(1),
|
|
10
|
+
final:z.array(z.object({...appointment,status:z.enum(['active','cancelled'])})).min(1)});
|
|
11
|
+
export const callBookings = z.discriminatedUnion('state',[
|
|
12
|
+
z.object({call_id:callId,state:z.literal('ready'),result:callBookingResult}),
|
|
13
|
+
...['none','processing','deleted','unavailable'].map(state=>z.object({call_id:callId,state:z.literal(state),result:z.null()}))
|
|
14
|
+
]);
|
|
15
|
+
export const outboundRequest = z.object({request_id:requestId,state:z.enum(['pending','accepted','rejected','unknown']),
|
|
16
|
+
call_id:nullable,reason:nullable});
|
|
17
|
+
export const acceptance = z.object({call_id:callId.regex(/^[^\u0000-\u0020]+$/),request_id:requestId,
|
|
18
|
+
status:z.literal('initiated'),replayed:z.literal(true).optional(),request_status:z.literal('unconfirmed').optional(),
|
|
19
|
+
safe_to_retry:z.literal(false).optional()}).passthrough();
|
|
20
|
+
export function bookingOutput(value,id){
|
|
21
|
+
const result=callBookings.parse(value);
|
|
22
|
+
if(result.call_id!==id||result.state==='ready'&&result.result.call_id!==id)throw Error('Invalid call result identity.');
|
|
23
|
+
return result;
|
|
24
|
+
}
|
|
25
|
+
export function requestOutput(value,id){
|
|
26
|
+
const result=outboundRequest.parse(value);
|
|
27
|
+
if(result.request_id.toLowerCase()!==id.toLowerCase()||result.state==='accepted'&&!result.call_id)throw Error('Invalid call request identity.');
|
|
28
|
+
return result;
|
|
29
|
+
}
|
|
30
|
+
export function acceptanceOutput(value,id){
|
|
31
|
+
const result=acceptance.parse(value);
|
|
32
|
+
if(result.request_id.toLowerCase()!==id.toLowerCase()||result.request_status==='unconfirmed'&&result.safe_to_retry!==false)throw Error('Invalid acceptance receipt.');
|
|
33
|
+
return result;
|
|
34
|
+
}
|
package/k7-tools.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import * as z from 'zod/v4';
|
|
2
|
-
import {executeTool} from './safe-tools.js';
|
|
3
|
-
import {requestId,callId,bookingOutput,requestOutput} from './k7-schemas.js';
|
|
4
|
-
import {callRequestError} from './k7-errors.js';
|
|
5
|
-
const text=v=>({content:[{type:'text',text:JSON.stringify(v,null,2)}]});
|
|
6
|
-
export function registerK7Tools(server,request){
|
|
7
|
-
function add(name,title,description,shape,run){
|
|
8
|
-
server.registerTool(name,{title,description:description+' Read only. Use only when the user requests this account information.',
|
|
9
|
-
annotations:{title,readOnlyHint:true,destructiveHint:false,idempotentHint:true,openWorldHint:true},inputSchema:z.object(shape).strict()},async args=>{
|
|
10
|
-
try{return text(await executeTool(name,run,args));}
|
|
11
|
-
catch(error){return {...text(callRequestError(error,args.request_id,false)),isError:true};}
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
add('get_call_bookings','Read a call’s booking result',
|
|
15
|
-
'Read retained result: ready, none, processing, deleted or unavailable. Only ready has content. This is this call’s result, not current calendar inventory. Unavailable/deleted is never no bookings.',
|
|
16
|
-
{call_id:callId},async a=>bookingOutput(await request('GET','/calls/'+encodeURIComponent(a.call_id)+'/bookings'),a.call_id));
|
|
17
|
-
add('get_outbound_call_request','Read an outbound call request',
|
|
18
|
-
'Read pending, accepted, rejected or unknown for the saved UUID. No call is placed. Unknown is not failure or permission to allocate a new UUID. Accepted does not mean connected or completed.',
|
|
19
|
-
{request_id:requestId},async a=>requestOutput(await request('GET','/calls/outbound/requests/'+encodeURIComponent(a.request_id)),a.request_id));
|
|
20
|
-
}
|
|
1
|
+
import * as z from 'zod/v4';
|
|
2
|
+
import {executeTool} from './safe-tools.js';
|
|
3
|
+
import {requestId,callId,bookingOutput,requestOutput} from './k7-schemas.js';
|
|
4
|
+
import {callRequestError} from './k7-errors.js';
|
|
5
|
+
const text=v=>({content:[{type:'text',text:JSON.stringify(v,null,2)}]});
|
|
6
|
+
export function registerK7Tools(server,request){
|
|
7
|
+
function add(name,title,description,shape,run){
|
|
8
|
+
server.registerTool(name,{title,description:description+' Read only. Use only when the user requests this account information.',
|
|
9
|
+
annotations:{title,readOnlyHint:true,destructiveHint:false,idempotentHint:true,openWorldHint:true},inputSchema:z.object(shape).strict()},async args=>{
|
|
10
|
+
try{return text(await executeTool(name,run,args));}
|
|
11
|
+
catch(error){return {...text(callRequestError(error,args.request_id,false)),isError:true};}
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
add('get_call_bookings','Read a call’s booking result',
|
|
15
|
+
'Read retained result: ready, none, processing, deleted or unavailable. Only ready has content. This is this call’s result, not current calendar inventory. Unavailable/deleted is never no bookings.',
|
|
16
|
+
{call_id:callId},async a=>bookingOutput(await request('GET','/calls/'+encodeURIComponent(a.call_id)+'/bookings'),a.call_id));
|
|
17
|
+
add('get_outbound_call_request','Read an outbound call request',
|
|
18
|
+
'Read pending, accepted, rejected or unknown for the saved UUID. No call is placed. Unknown is not failure or permission to allocate a new UUID. Accepted does not mean connected or completed.',
|
|
19
|
+
{request_id:requestId},async a=>requestOutput(await request('GET','/calls/outbound/requests/'+encodeURIComponent(a.request_id)),a.request_id));
|
|
20
|
+
}
|
package/k9-deletes.js
CHANGED
|
@@ -1,90 +1,90 @@
|
|
|
1
|
-
// B57 adapters use the existing one-attempt transport and origin fence, not a future SDK.
|
|
2
|
-
import * as z from 'zod/v4';
|
|
3
|
-
import { NixflexError } from 'nixflex';
|
|
4
|
-
import { errorBody } from './safe-tools.js';
|
|
5
|
-
import { kitRequest } from './kit-request.js';
|
|
6
|
-
|
|
7
|
-
/** Keep the shared transport untouched; only B57 deletes require a full receipt. */
|
|
8
|
-
export function contentDeleteRequest(key, baseUrl, fetcher = fetch) {
|
|
9
|
-
return async (method, path) => {
|
|
10
|
-
let status = 0, requestId;
|
|
11
|
-
const request = kitRequest(key, baseUrl, async (...args) => {
|
|
12
|
-
const response = await fetcher(...args);
|
|
13
|
-
status = response.status;
|
|
14
|
-
requestId = response.headers.get('x-request-id') || response.headers.get('x-railway-request-id') || undefined;
|
|
15
|
-
return response;
|
|
16
|
-
});
|
|
17
|
-
const invalid = () => new NixflexError(status, {error:{type:'connection_error',
|
|
18
|
-
code:'invalid_response',message:'Deletion receipt could not be confirmed.'}}, requestId);
|
|
19
|
-
let receipt;
|
|
20
|
-
try { receipt = await request(method, path); }
|
|
21
|
-
catch (error) {
|
|
22
|
-
if (error instanceof NixflexError && error.code === 'invalid_response') throw invalid();
|
|
23
|
-
throw error;
|
|
24
|
-
}
|
|
25
|
-
const call = path.startsWith('/calls/') && !path.startsWith('/calls/batch/');
|
|
26
|
-
const id = decodeURIComponent(path.slice(path.lastIndexOf('/') + 1));
|
|
27
|
-
const valid = receipt?.deleted === true && (call
|
|
28
|
-
? receipt.call_id === id && typeof receipt.recording_deleted === 'boolean' &&
|
|
29
|
-
['carrier_best_effort','queued'].includes(receipt.recording_cleanup)
|
|
30
|
-
: receipt.campaign_id === id && typeof receipt.message === 'string');
|
|
31
|
-
if (!valid) throw invalid();
|
|
32
|
-
return receipt;
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const confirm = z.boolean().optional().describe('Required true to actually do it. Without it the tool returns a preview and changes nothing.');
|
|
37
|
-
export const contentDeletes = [
|
|
38
|
-
{ name:'delete_call', id:'call_id', prefix:'/calls/', noun:'call',
|
|
39
|
-
description:'End a running call and delete its content. recording_cleanup is carrier_best_effort or queued, not proof every copy is erased. 503 hangup_pending with retry_pending:true means queued, not deleted. Requires confirm: true; preview makes zero requests. Never automatically retries.' },
|
|
40
|
-
{ name:'delete_sms_campaign', id:'campaign_id', prefix:'/sms/campaigns/', noun:'SMS campaign',
|
|
41
|
-
description:'Cancel waiting work and hide an SMS campaign. History and used charges remain; no refund or recall of sent messages. Owner/Admin only; missing/foreign is 404. 503 hangup_pending with retry_pending:true means queued, not deleted. Requires confirm: true; preview makes zero requests. Never automatically retries.' },
|
|
42
|
-
{ name:'delete_campaign', id:'campaign_id', prefix:'/calls/batch/', noun:'voice campaign',
|
|
43
|
-
description:'Cancel waiting work, end running calls and hide a voice campaign. History and used charges remain; no refund. Owner/Admin only; missing/foreign is 404. 503 hangup_pending with retry_pending:true means queued, not deleted. Requires confirm: true; preview makes zero requests. Never automatically retries.' },
|
|
44
|
-
];
|
|
45
|
-
|
|
46
|
-
function deletionError(error) {
|
|
47
|
-
const proof = error?.details;
|
|
48
|
-
const queued = error instanceof NixflexError && error.status === 503 &&
|
|
49
|
-
error.code === 'hangup_pending' && error.type === 'server_error' && typeof error.message === 'string' &&
|
|
50
|
-
proof?.deleted === false && proof.retry_pending === true;
|
|
51
|
-
const notSent = proof?.outcome === 'not_sent' && proof.sent === false &&
|
|
52
|
-
proof.charged === false && proof.safe_to_retry === true;
|
|
53
|
-
if (queued || notSent) return error;
|
|
54
|
-
if (error instanceof NixflexError && error.status >= 400 && error.status < 500) return error;
|
|
55
|
-
const unknown = new NixflexError(error?.status || 0, {error:{
|
|
56
|
-
type:'outcome_unknown', code:'outcome_unknown',
|
|
57
|
-
message:'Outcome unknown - check before retrying. The change may already have happened; it was not automatically repeated.',
|
|
58
|
-
doc_url:error?.docUrl,
|
|
59
|
-
details:{...proof,original_code:error?.code,outcome:'unknown',safe_to_retry:false},
|
|
60
|
-
}},error?.requestId);
|
|
61
|
-
unknown.outcome='unknown';unknown.safe_to_retry=false;
|
|
62
|
-
return unknown;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export function registerK9Deletes(server, request) {
|
|
66
|
-
for (const row of contentDeletes) {
|
|
67
|
-
const title = row.name === 'delete_call' ? 'Delete one call and recording' :
|
|
68
|
-
row.name === 'delete_sms_campaign' ? 'Delete an SMS campaign' : 'Delete a voice campaign';
|
|
69
|
-
server.registerTool(row.name, {
|
|
70
|
-
title, description:row.description+' Use only for the user\'s explicitly requested change. Check uncertain outcomes before retrying.',
|
|
71
|
-
annotations:{title,readOnlyHint:false,destructiveHint:true,idempotentHint:false,openWorldHint:true},
|
|
72
|
-
inputSchema:z.object({[row.id]:z.string(),confirm}),
|
|
73
|
-
}, async args => {
|
|
74
|
-
const reply = data => ({content:[{type:'text',text:JSON.stringify(data,null,2)}]});
|
|
75
|
-
if (args.confirm !== true) return reply({
|
|
76
|
-
would_delete:row.noun+' '+args[row.id],
|
|
77
|
-
warning:row.noun==='call' ? 'The running call will be ended; recording cleanup may remain queued.' :
|
|
78
|
-
'Waiting work will be cancelled and running calls ended. History and used charges remain; no refund.',
|
|
79
|
-
hint:'Call again with confirm: true. This preview made no requests.',
|
|
80
|
-
});
|
|
81
|
-
try {
|
|
82
|
-
const id=args[row.id];
|
|
83
|
-
if(typeof id!=='string'||!id.length||id.length>200||id==='.'||id==='..'||/[\x00-\x1f\x7f]/.test(id))
|
|
84
|
-
throw new NixflexError(400,{error:{type:'invalid_request',code:'invalid_delete',message:'Choose a valid call or campaign identifier. Nothing was sent.',details:{}}});
|
|
85
|
-
return reply(await request('DELETE',row.prefix+encodeURIComponent(id)));
|
|
86
|
-
}
|
|
87
|
-
catch (error) { return {...reply(errorBody(deletionError(error))),isError:true}; }
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
}
|
|
1
|
+
// B57 adapters use the existing one-attempt transport and origin fence, not a future SDK.
|
|
2
|
+
import * as z from 'zod/v4';
|
|
3
|
+
import { NixflexError } from 'nixflex';
|
|
4
|
+
import { errorBody } from './safe-tools.js';
|
|
5
|
+
import { kitRequest } from './kit-request.js';
|
|
6
|
+
|
|
7
|
+
/** Keep the shared transport untouched; only B57 deletes require a full receipt. */
|
|
8
|
+
export function contentDeleteRequest(key, baseUrl, fetcher = fetch) {
|
|
9
|
+
return async (method, path) => {
|
|
10
|
+
let status = 0, requestId;
|
|
11
|
+
const request = kitRequest(key, baseUrl, async (...args) => {
|
|
12
|
+
const response = await fetcher(...args);
|
|
13
|
+
status = response.status;
|
|
14
|
+
requestId = response.headers.get('x-request-id') || response.headers.get('x-railway-request-id') || undefined;
|
|
15
|
+
return response;
|
|
16
|
+
});
|
|
17
|
+
const invalid = () => new NixflexError(status, {error:{type:'connection_error',
|
|
18
|
+
code:'invalid_response',message:'Deletion receipt could not be confirmed.'}}, requestId);
|
|
19
|
+
let receipt;
|
|
20
|
+
try { receipt = await request(method, path); }
|
|
21
|
+
catch (error) {
|
|
22
|
+
if (error instanceof NixflexError && error.code === 'invalid_response') throw invalid();
|
|
23
|
+
throw error;
|
|
24
|
+
}
|
|
25
|
+
const call = path.startsWith('/calls/') && !path.startsWith('/calls/batch/');
|
|
26
|
+
const id = decodeURIComponent(path.slice(path.lastIndexOf('/') + 1));
|
|
27
|
+
const valid = receipt?.deleted === true && (call
|
|
28
|
+
? receipt.call_id === id && typeof receipt.recording_deleted === 'boolean' &&
|
|
29
|
+
['carrier_best_effort','queued'].includes(receipt.recording_cleanup)
|
|
30
|
+
: receipt.campaign_id === id && typeof receipt.message === 'string');
|
|
31
|
+
if (!valid) throw invalid();
|
|
32
|
+
return receipt;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const confirm = z.boolean().optional().describe('Required true to actually do it. Without it the tool returns a preview and changes nothing.');
|
|
37
|
+
export const contentDeletes = [
|
|
38
|
+
{ name:'delete_call', id:'call_id', prefix:'/calls/', noun:'call',
|
|
39
|
+
description:'End a running call and delete its content. recording_cleanup is carrier_best_effort or queued, not proof every copy is erased. 503 hangup_pending with retry_pending:true means queued, not deleted. Requires confirm: true; preview makes zero requests. Never automatically retries.' },
|
|
40
|
+
{ name:'delete_sms_campaign', id:'campaign_id', prefix:'/sms/campaigns/', noun:'SMS campaign',
|
|
41
|
+
description:'Cancel waiting work and hide an SMS campaign. History and used charges remain; no refund or recall of sent messages. Owner/Admin only; missing/foreign is 404. 503 hangup_pending with retry_pending:true means queued, not deleted. Requires confirm: true; preview makes zero requests. Never automatically retries.' },
|
|
42
|
+
{ name:'delete_campaign', id:'campaign_id', prefix:'/calls/batch/', noun:'voice campaign',
|
|
43
|
+
description:'Cancel waiting work, end running calls and hide a voice campaign. History and used charges remain; no refund. Owner/Admin only; missing/foreign is 404. 503 hangup_pending with retry_pending:true means queued, not deleted. Requires confirm: true; preview makes zero requests. Never automatically retries.' },
|
|
44
|
+
];
|
|
45
|
+
|
|
46
|
+
function deletionError(error) {
|
|
47
|
+
const proof = error?.details;
|
|
48
|
+
const queued = error instanceof NixflexError && error.status === 503 &&
|
|
49
|
+
error.code === 'hangup_pending' && error.type === 'server_error' && typeof error.message === 'string' &&
|
|
50
|
+
proof?.deleted === false && proof.retry_pending === true;
|
|
51
|
+
const notSent = proof?.outcome === 'not_sent' && proof.sent === false &&
|
|
52
|
+
proof.charged === false && proof.safe_to_retry === true;
|
|
53
|
+
if (queued || notSent) return error;
|
|
54
|
+
if (error instanceof NixflexError && error.status >= 400 && error.status < 500) return error;
|
|
55
|
+
const unknown = new NixflexError(error?.status || 0, {error:{
|
|
56
|
+
type:'outcome_unknown', code:'outcome_unknown',
|
|
57
|
+
message:'Outcome unknown - check before retrying. The change may already have happened; it was not automatically repeated.',
|
|
58
|
+
doc_url:error?.docUrl,
|
|
59
|
+
details:{...proof,original_code:error?.code,outcome:'unknown',safe_to_retry:false},
|
|
60
|
+
}},error?.requestId);
|
|
61
|
+
unknown.outcome='unknown';unknown.safe_to_retry=false;
|
|
62
|
+
return unknown;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export function registerK9Deletes(server, request) {
|
|
66
|
+
for (const row of contentDeletes) {
|
|
67
|
+
const title = row.name === 'delete_call' ? 'Delete one call and recording' :
|
|
68
|
+
row.name === 'delete_sms_campaign' ? 'Delete an SMS campaign' : 'Delete a voice campaign';
|
|
69
|
+
server.registerTool(row.name, {
|
|
70
|
+
title, description:row.description+' Use only for the user\'s explicitly requested change. Check uncertain outcomes before retrying.',
|
|
71
|
+
annotations:{title,readOnlyHint:false,destructiveHint:true,idempotentHint:false,openWorldHint:true},
|
|
72
|
+
inputSchema:z.object({[row.id]:z.string(),confirm}),
|
|
73
|
+
}, async args => {
|
|
74
|
+
const reply = data => ({content:[{type:'text',text:JSON.stringify(data,null,2)}]});
|
|
75
|
+
if (args.confirm !== true) return reply({
|
|
76
|
+
would_delete:row.noun+' '+args[row.id],
|
|
77
|
+
warning:row.noun==='call' ? 'The running call will be ended; recording cleanup may remain queued.' :
|
|
78
|
+
'Waiting work will be cancelled and running calls ended. History and used charges remain; no refund.',
|
|
79
|
+
hint:'Call again with confirm: true. This preview made no requests.',
|
|
80
|
+
});
|
|
81
|
+
try {
|
|
82
|
+
const id=args[row.id];
|
|
83
|
+
if(typeof id!=='string'||!id.length||id.length>200||id==='.'||id==='..'||/[\x00-\x1f\x7f]/.test(id))
|
|
84
|
+
throw new NixflexError(400,{error:{type:'invalid_request',code:'invalid_delete',message:'Choose a valid call or campaign identifier. Nothing was sent.',details:{}}});
|
|
85
|
+
return reply(await request('DELETE',row.prefix+encodeURIComponent(id)));
|
|
86
|
+
}
|
|
87
|
+
catch (error) { return {...reply(errorBody(deletionError(error))),isError:true}; }
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
}
|
package/kit-request.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import { NixflexError, NixflexConnectionError, errorFromResponse } from 'nixflex';
|
|
2
|
-
import { readFileSync } from 'node:fs';
|
|
3
|
-
export const KIT_VERSION = JSON.parse(readFileSync(new URL('./package.json', import.meta.url), 'utf8')).version;
|
|
4
|
-
/** One attempt. executeTool owns the one GET-only retry, including organisation reads. */
|
|
5
|
-
export function kitRequest(key, baseUrl, fetcher = fetch) {
|
|
6
|
-
return async (method, path, body, query) => {
|
|
7
|
-
if (!path.startsWith('/') || path.startsWith('//') || /[?#\\]/.test(path)) throw Error('Invalid API path.');
|
|
8
|
-
const url = new URL(baseUrl.replace(/\/+$/, '') + '/v1' + path);
|
|
9
|
-
for (const [k,v] of Object.entries(query || {})) if (v !== undefined && v !== null) url.searchParams.set(k, String(v));
|
|
10
|
-
let response;
|
|
11
|
-
try {
|
|
12
|
-
response = await fetcher(url, { method, redirect: 'error', signal: AbortSignal.timeout(30000),
|
|
13
|
-
headers: { Authorization: 'Bearer ' + key, 'Content-Type': 'application/json', 'User-Agent': 'nixflex-mcp/' + KIT_VERSION },
|
|
14
|
-
body: body === undefined ? undefined : JSON.stringify(body) });
|
|
15
|
-
} catch { throw new NixflexConnectionError('API request could not be confirmed.'); }
|
|
16
|
-
const requestId = response.headers.get('x-request-id') || response.headers.get('x-railway-request-id') || undefined;
|
|
17
|
-
if (response.status === 204) return undefined;
|
|
18
|
-
let data;
|
|
19
|
-
try { data = await response.json(); }
|
|
20
|
-
catch { throw new NixflexError(0, {error:{type:'connection_error',code:'invalid_response',message:'API response could not be confirmed.'}}, requestId); }
|
|
21
|
-
if (!response.ok) throw errorFromResponse(response.status, data, requestId, Number(response.headers.get('retry-after')) || 0);
|
|
22
|
-
return data;
|
|
23
|
-
};
|
|
24
|
-
}
|
|
1
|
+
import { NixflexError, NixflexConnectionError, errorFromResponse } from 'nixflex';
|
|
2
|
+
import { readFileSync } from 'node:fs';
|
|
3
|
+
export const KIT_VERSION = JSON.parse(readFileSync(new URL('./package.json', import.meta.url), 'utf8')).version;
|
|
4
|
+
/** One attempt. executeTool owns the one GET-only retry, including organisation reads. */
|
|
5
|
+
export function kitRequest(key, baseUrl, fetcher = fetch) {
|
|
6
|
+
return async (method, path, body, query) => {
|
|
7
|
+
if (!path.startsWith('/') || path.startsWith('//') || /[?#\\]/.test(path)) throw Error('Invalid API path.');
|
|
8
|
+
const url = new URL(baseUrl.replace(/\/+$/, '') + '/v1' + path);
|
|
9
|
+
for (const [k,v] of Object.entries(query || {})) if (v !== undefined && v !== null) url.searchParams.set(k, String(v));
|
|
10
|
+
let response;
|
|
11
|
+
try {
|
|
12
|
+
response = await fetcher(url, { method, redirect: 'error', signal: AbortSignal.timeout(30000),
|
|
13
|
+
headers: { Authorization: 'Bearer ' + key, 'Content-Type': 'application/json', 'User-Agent': 'nixflex-mcp/' + KIT_VERSION },
|
|
14
|
+
body: body === undefined ? undefined : JSON.stringify(body) });
|
|
15
|
+
} catch { throw new NixflexConnectionError('API request could not be confirmed.'); }
|
|
16
|
+
const requestId = response.headers.get('x-request-id') || response.headers.get('x-railway-request-id') || undefined;
|
|
17
|
+
if (response.status === 204) return undefined;
|
|
18
|
+
let data;
|
|
19
|
+
try { data = await response.json(); }
|
|
20
|
+
catch { throw new NixflexError(0, {error:{type:'connection_error',code:'invalid_response',message:'API response could not be confirmed.'}}, requestId); }
|
|
21
|
+
if (!response.ok) throw errorFromResponse(response.status, data, requestId, Number(response.headers.get('retry-after')) || 0);
|
|
22
|
+
return data;
|
|
23
|
+
};
|
|
24
|
+
}
|
package/knowledge-request.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import { NixflexError, NixflexConnectionError, errorFromResponse } from 'nixflex';
|
|
2
|
-
import { KIT_VERSION } from './kit-request.js';
|
|
3
|
-
/** One request. Existing executeTool supplies only GET retries. Content is never logged. */
|
|
4
|
-
export function knowledgeRequest(key, baseUrl, fetcher = fetch) {
|
|
5
|
-
return async (method, path, body, query, operationKey) => {
|
|
6
|
-
if (!path.startsWith('/') || path.startsWith('//') || /[?#\\]/.test(path)) throw new TypeError('Invalid API path.');
|
|
7
|
-
if (operationKey !== undefined && (!/^[A-Za-z0-9_.:-]{8,128}$/.test(operationKey) || operationKey.startsWith('prompt:')))
|
|
8
|
-
throw new TypeError('Invalid operation key.');
|
|
9
|
-
const url = new URL(baseUrl.replace(/\/+$/, '') + '/v1' + path);
|
|
10
|
-
for (const [name, value] of Object.entries(query || {})) if (value !== undefined) url.searchParams.set(name, String(value));
|
|
11
|
-
let res;
|
|
12
|
-
try {
|
|
13
|
-
res = await fetcher(url, { method, redirect: 'error', signal: AbortSignal.timeout(30000),
|
|
14
|
-
headers: { Authorization: 'Bearer ' + key, 'Content-Type': 'application/json', 'User-Agent': 'nixflex-mcp/' + KIT_VERSION,
|
|
15
|
-
...(operationKey === undefined ? {} : { 'Idempotency-Key': operationKey }) },
|
|
16
|
-
body: body === undefined ? undefined : JSON.stringify(body) });
|
|
17
|
-
} catch { throw new NixflexConnectionError('Knowledge request could not be confirmed.'); }
|
|
18
|
-
let data;
|
|
19
|
-
try { data = await res.json(); }
|
|
20
|
-
catch { throw new NixflexError(0, { error: { code: 'invalid_response', type: 'connection_error', message: 'Knowledge response could not be confirmed.' } }); }
|
|
21
|
-
if (!res.ok) throw errorFromResponse(res.status, data, undefined, Number(res.headers.get('retry-after')) || 0);
|
|
22
|
-
return data;
|
|
23
|
-
};
|
|
24
|
-
}
|
|
1
|
+
import { NixflexError, NixflexConnectionError, errorFromResponse } from 'nixflex';
|
|
2
|
+
import { KIT_VERSION } from './kit-request.js';
|
|
3
|
+
/** One request. Existing executeTool supplies only GET retries. Content is never logged. */
|
|
4
|
+
export function knowledgeRequest(key, baseUrl, fetcher = fetch) {
|
|
5
|
+
return async (method, path, body, query, operationKey) => {
|
|
6
|
+
if (!path.startsWith('/') || path.startsWith('//') || /[?#\\]/.test(path)) throw new TypeError('Invalid API path.');
|
|
7
|
+
if (operationKey !== undefined && (!/^[A-Za-z0-9_.:-]{8,128}$/.test(operationKey) || operationKey.startsWith('prompt:')))
|
|
8
|
+
throw new TypeError('Invalid operation key.');
|
|
9
|
+
const url = new URL(baseUrl.replace(/\/+$/, '') + '/v1' + path);
|
|
10
|
+
for (const [name, value] of Object.entries(query || {})) if (value !== undefined) url.searchParams.set(name, String(value));
|
|
11
|
+
let res;
|
|
12
|
+
try {
|
|
13
|
+
res = await fetcher(url, { method, redirect: 'error', signal: AbortSignal.timeout(30000),
|
|
14
|
+
headers: { Authorization: 'Bearer ' + key, 'Content-Type': 'application/json', 'User-Agent': 'nixflex-mcp/' + KIT_VERSION,
|
|
15
|
+
...(operationKey === undefined ? {} : { 'Idempotency-Key': operationKey }) },
|
|
16
|
+
body: body === undefined ? undefined : JSON.stringify(body) });
|
|
17
|
+
} catch { throw new NixflexConnectionError('Knowledge request could not be confirmed.'); }
|
|
18
|
+
let data;
|
|
19
|
+
try { data = await res.json(); }
|
|
20
|
+
catch { throw new NixflexError(0, { error: { code: 'invalid_response', type: 'connection_error', message: 'Knowledge response could not be confirmed.' } }); }
|
|
21
|
+
if (!res.ok) throw errorFromResponse(res.status, data, undefined, Number(res.headers.get('retry-after')) || 0);
|
|
22
|
+
return data;
|
|
23
|
+
};
|
|
24
|
+
}
|
package/number-reads.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
// Read-only compatibility adapter until the updated SDK is published. Installed
|
|
2
|
-
// SDK 0.8.0 has no number get and discards new list filters. No mutation uses this.
|
|
3
|
-
import { NixflexConnectionError, errorFromResponse } from 'nixflex';
|
|
4
|
-
import { numberUsage } from './number-usage.js';
|
|
5
|
-
export function numberReads(apiKey, baseUrl = 'https://api.nixflex.com', fetcher = fetch) {
|
|
6
|
-
return async function read({ phone_number, agent_id, provider, limit, cursor, usage, period, time_zone } = {}) {
|
|
7
|
-
if (usage === true) return numberUsage(apiKey, baseUrl, {phone_number,period,time_zone}, fetcher);
|
|
8
|
-
const suffix = phone_number ? '/' + encodeURIComponent(phone_number) : '';
|
|
9
|
-
const url = new URL(baseUrl.replace(/\/+$/, '') + '/v1/phone-numbers' + suffix);
|
|
10
|
-
if (!phone_number) for (const [k,v] of Object.entries({agent_id,provider,limit,cursor})) if(v !== undefined) url.searchParams.set(k,String(v));
|
|
11
|
-
let response;
|
|
12
|
-
try {
|
|
13
|
-
response = await fetcher(url.toString(), {method:'GET',redirect:'error',signal:AbortSignal.timeout(30000),
|
|
14
|
-
headers:{Authorization:'Bearer '+apiKey,Accept:'application/json'}});
|
|
15
|
-
} catch { throw new NixflexConnectionError('Could not read phone numbers.'); }
|
|
16
|
-
let body;
|
|
17
|
-
try { body = await response.json(); }
|
|
18
|
-
catch { throw new NixflexConnectionError('Invalid phone number read response.'); }
|
|
19
|
-
if (!response.ok) throw errorFromResponse(response.status,body,response.headers.get('x-railway-request-id') || undefined,
|
|
20
|
-
Number(response.headers.get('retry-after')) || undefined);
|
|
21
|
-
return body;
|
|
22
|
-
};
|
|
23
|
-
}
|
|
1
|
+
// Read-only compatibility adapter until the updated SDK is published. Installed
|
|
2
|
+
// SDK 0.8.0 has no number get and discards new list filters. No mutation uses this.
|
|
3
|
+
import { NixflexConnectionError, errorFromResponse } from 'nixflex';
|
|
4
|
+
import { numberUsage } from './number-usage.js';
|
|
5
|
+
export function numberReads(apiKey, baseUrl = 'https://api.nixflex.com', fetcher = fetch) {
|
|
6
|
+
return async function read({ phone_number, agent_id, provider, limit, cursor, usage, period, time_zone } = {}) {
|
|
7
|
+
if (usage === true) return numberUsage(apiKey, baseUrl, {phone_number,period,time_zone}, fetcher);
|
|
8
|
+
const suffix = phone_number ? '/' + encodeURIComponent(phone_number) : '';
|
|
9
|
+
const url = new URL(baseUrl.replace(/\/+$/, '') + '/v1/phone-numbers' + suffix);
|
|
10
|
+
if (!phone_number) for (const [k,v] of Object.entries({agent_id,provider,limit,cursor})) if(v !== undefined) url.searchParams.set(k,String(v));
|
|
11
|
+
let response;
|
|
12
|
+
try {
|
|
13
|
+
response = await fetcher(url.toString(), {method:'GET',redirect:'error',signal:AbortSignal.timeout(30000),
|
|
14
|
+
headers:{Authorization:'Bearer '+apiKey,Accept:'application/json'}});
|
|
15
|
+
} catch { throw new NixflexConnectionError('Could not read phone numbers.'); }
|
|
16
|
+
let body;
|
|
17
|
+
try { body = await response.json(); }
|
|
18
|
+
catch { throw new NixflexConnectionError('Invalid phone number read response.'); }
|
|
19
|
+
if (!response.ok) throw errorFromResponse(response.status,body,response.headers.get('x-railway-request-id') || undefined,
|
|
20
|
+
Number(response.headers.get('retry-after')) || undefined);
|
|
21
|
+
return body;
|
|
22
|
+
};
|
|
23
|
+
}
|