nixflex-mcp 0.5.2 → 0.6.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.
@@ -1,118 +1,128 @@
1
- # Number, calendar and booking examples
2
-
3
- Examples are not an instruction to perform a live write. Use your owned number and explicit environment; no keys or carrier secrets belong in source, terminal arguments or chat. API authentication is NIXFLEX_API_KEY.
4
-
5
- ## Node / TypeScript
6
-
7
- ```ts
8
- import Nixflex, {NixflexDoNotContactError, NixflexInvalidRequestError,
9
- type Booking, type CallCompletedBookingEvent, type SmsBookingEvent} from 'nixflex';
10
- const client = new Nixflex({apiKey:process.env.NIXFLEX_API_KEY!, baseUrl:process.env.NIXFLEX_BASE_URL!});
11
- const number = '+12025550123'; // fictional example; replace with your owned number
12
- const consent = await client.integrations.connectGoogleCalendar(number, 'https://app.example.test/calendar-return');
13
- // Present consent.url privately to the human; never auto-open or log it.
14
- const status = await client.integrations.getGoogleCalendar(number);
15
- if (status.needs_reconnect) { /* Request fresh human consent, not a silent reconnect. */ }
16
- const settings = await client.integrations.updateGoogleCalendarSettings(number, {
17
- timezone:'America/New_York', slot_minutes:30, calendar_id:'primary', send_invites:false,
18
- hours:{monday:['09:00','17:00'],tuesday:['09:00','17:00'],wednesday:['09:00','17:00'],
19
- thursday:['09:00','17:00'],friday:['09:00','17:00'],saturday:null,sunday:null}
20
- });
21
- // Only on a separate, deliberate disconnect request:
22
- await client.integrations.disconnectGoogleCalendar(number);
23
- // Sensitive routing change. Read values from a privately configured process, never log.
24
- const receipt = await client.phoneNumbers.updateCredentials(number, {
25
- twilio_sid:process.env.NIXFLEX_TWILIO_SID!,twilio_token:process.env.NIXFLEX_TWILIO_TOKEN!
26
- });
27
- try {
28
- await client.sms.send({agent_id:'your-agent-id',from_number:number,to:'+12025550124',message:'Requested information'});
29
- } catch (error) {
30
- if (error instanceof NixflexDoNotContactError) { /* Stop; do not resend or remove suppression. */ }
31
- else if (error instanceof NixflexInvalidRequestError) { /* Retain old 400 validation/suppression handling. */ }
32
- else throw error;
33
- }
34
- function bookingPart(event: CallCompletedBookingEvent | SmsBookingEvent): Booking[] {
35
- // Call only AFTER the existing verifier has checked the original raw webhook body.
36
- return event.event === 'call.completed' ? event.bookings : [event.booking];
37
- }
38
- ```
39
-
40
- Telnyx uses the same updateCredentials method with only `{telnyx_api_key:process.env.NIXFLEX_TELNYX_API_KEY!,telnyx_connection_id:process.env.NIXFLEX_TELNYX_CONNECTION_ID!}`. Never mix pairs or send provider in the body. Type assertions are not runtime secret validation; the method rejects missing/invalid pairs without HTTP.
41
-
42
- ## Python sync and async
43
-
44
- ```python
45
- import os
46
- from nixflex import (Nixflex, AsyncNixflex, NixflexDoNotContactError,
47
- NixflexInvalidRequestError, Booking, CallCompletedBookingEvent, SmsBookingEvent)
48
- number = '+12025550123'
49
- config = dict(api_key=os.environ['NIXFLEX_API_KEY'],base_url=os.environ['NIXFLEX_BASE_URL'])
50
- with Nixflex(**config) as client:
51
- consent = client.integrations.connect_google_calendar(number, 'https://app.example.test/calendar-return')
52
- # Present the short-lived link privately to a human; never print it to logs.
53
- status = client.integrations.get_google_calendar(number)
54
- settings = client.integrations.update_google_calendar_settings(number, send_invites=False)
55
- # Separate deliberate disconnect:
56
- client.integrations.disconnect_google_calendar(number)
57
- receipt = client.phone_numbers.update_credentials(number,
58
- telnyx_api_key=os.environ['NIXFLEX_TELNYX_API_KEY'],
59
- telnyx_connection_id=os.environ['NIXFLEX_TELNYX_CONNECTION_ID'])
60
- try:
61
- client.sms.send(agent_id='your-agent-id',from_number=number,to='+12025550124',message='Requested information')
62
- except NixflexDoNotContactError:
63
- pass # Stop; nothing sent. Do not retry or bypass opt-out.
64
- except NixflexInvalidRequestError:
65
- pass # Existing old-server 400 handling; not all validation failures mean opt-out.
66
-
67
- async def read_status():
68
- async with AsyncNixflex(**config) as client:
69
- return await client.integrations.get_google_calendar(number)
70
- # Every other method has the same arguments and is awaited in AsyncNixflex.
71
-
72
- def booking_part(event):
73
- # Only after raw-body signature verification. TypedDict is not authentication.
74
- return event['bookings'] if event['event'] == 'call.completed' else [event['booking']]
75
- ```
76
-
77
- ## CLI (PowerShell-safe argument shapes)
78
-
79
- Privately configure NIXFLEX_API_KEY, NIXFLEX_BASE_URL and the selected carrier pair. These command lines contain no secret values. These are independent actions, not one recommended sequence.
80
-
81
- ```powershell
82
- nixflex integrations connectGoogleCalendar '+12025550123' --return-url 'https://app.example.test/calendar-return' --confirm
83
- nixflex integrations getGoogleCalendar '+12025550123' --json
84
- nixflex integrations updateGoogleCalendarSettings '+12025550123' --body '@calendar-settings.json' --confirm
85
- nixflex integrations disconnectGoogleCalendar '+12025550123' --confirm
86
- nixflex numbers updateCredentials '+12025550123' --provider twilio --confirm --json
87
- # Alternative: a trusted local secret-manager process pipes the exact JSON pair to stdin:
88
- # <private secret-manager command> | nixflex numbers updateCredentials '+12025550123' --provider telnyx --credentials-stdin --confirm
89
- ```
90
-
91
- calendar-settings.json contains settings only, e.g. `{"send_invites":false}`; never carrier credentials. Omit --confirm to preview without a request. Credential commands reject --body, --key and secret flags before the argument parser can echo values. SMS --json errors expose status/type/code: stop on 409 do_not_contact; retain old 400 handling. Webhook types do not add a CLI listener or ingest endpoint.
92
-
93
- ## Calendar and number tools for MCP
94
-
95
- Ask the human to approve the exact number/change before using confirm:true. Credentials are preconfigured privately in the SERVER process environment, never tool arguments or chat. Missing configuration sends nothing.
96
-
97
- | Tool | Arguments example | Result |
98
- | --- | --- | --- |
99
- | connect_google_calendar | `{ "phone_number":"+12025550123", "return_url":"https://app.example.test/calendar-return", "confirm":true }` | Consent url + expires_at; human opens it |
100
- | get_google_calendar | `{ "phone_number":"+12025550123" }` | Six status fields including needs_reconnect and send_invites |
101
- | update_google_calendar_settings | `{ "phone_number":"+12025550123", "send_invites":false, "confirm":true }` | Safe settings, false preserved |
102
- | disconnect_google_calendar | `{ "phone_number":"+12025550123", "confirm":true }` | ok:true, connected:false; no claim of remote revoke |
103
- | update_phone_number_credentials | `{ "phone_number":"+12025550123", "provider":"twilio", "confirm":true }` | Number, provider, updated:true only |
104
-
105
- All new writes without confirmation return confirmation_required:true, sent:false. Google settings accepts the same fields as Node/Python, including the seven-day hours object above. Use provider telnyx for the alternate private environment pair. No bulk deletion, signup, suppression removal, campaign resume/consent or hidden-write Knowledge draft tool is added.
106
-
107
- MCP SMS errors use `error.status=409`, `error.type=conflict`, `error.code=do_not_contact`; report that nothing was sent and stop. Older 400 invalid_request remains generic. The shipped booking schema can validate the booking part of an authenticated webhook locally:
108
-
109
- ```js
110
- import {callCompletedBookingSchema, smsBookingSchema} from 'nixflex-mcp/booking-schemas.js';
111
- // verifiedEvent is supplied only after existing raw-body signature verification.
112
- function parseBookingEvent(verifiedEvent) {
113
- return verifiedEvent.event === 'call.completed'
114
- ? callCompletedBookingSchema.parse(verifiedEvent) : smsBookingSchema.parse(verifiedEvent);
115
- }
116
- ```
117
-
118
- No MCP webhook-receiver tool is registered. Booking required keys: action, booking_uid, start, end, attendee_name, attendee_email, service, timezone. Preserve null; service can be numeric. Never count internal already_exists lookups as mutations.
1
+ # Number, calendar and booking examples
2
+
3
+ Examples are not an instruction to perform a live write. Use your owned number and explicit environment; no keys or carrier secrets belong in source, terminal arguments or chat. API authentication is NIXFLEX_API_KEY.
4
+
5
+ ## Node / TypeScript
6
+
7
+ ```ts
8
+ import Nixflex, {NixflexDoNotContactError, NixflexInvalidRequestError,
9
+ type Booking, type CallCompletedBookingEvent, type SmsBookingEvent} from 'nixflex';
10
+ const client = new Nixflex({apiKey:process.env.NIXFLEX_API_KEY!, baseUrl:process.env.NIXFLEX_BASE_URL!});
11
+ const number = '+12025550123'; // fictional example; replace with your owned number
12
+ const consent = await client.integrations.connectGoogleCalendar(number, 'https://app.example.test/calendar-return');
13
+ // Present consent.url privately to the human; never auto-open or log it.
14
+ const status = await client.integrations.getGoogleCalendar(number);
15
+ if (status.needs_reconnect) { /* Request fresh human consent, not a silent reconnect. */ }
16
+ const settings = await client.integrations.updateGoogleCalendarSettings(number, {
17
+ timezone:'America/New_York', slot_minutes:30, calendar_id:'primary', send_invites:false,
18
+ hours:{monday:['09:00','17:00'],tuesday:['09:00','17:00'],wednesday:['09:00','17:00'],
19
+ thursday:['09:00','17:00'],friday:['09:00','17:00'],saturday:null,sunday:null}
20
+ });
21
+ // Only on a separate, deliberate disconnect request:
22
+ await client.integrations.disconnectGoogleCalendar(number);
23
+ // Sensitive routing change. Read values from a privately configured process, never log.
24
+ const receipt = await client.phoneNumbers.updateCredentials(number, {
25
+ twilio_sid:process.env.NIXFLEX_TWILIO_SID!,twilio_token:process.env.NIXFLEX_TWILIO_TOKEN!
26
+ });
27
+ try {
28
+ await client.sms.send({agent_id:'your-agent-id',from_number:number,to:'+12025550124',message:'Requested information'});
29
+ } catch (error) {
30
+ if (error instanceof NixflexDoNotContactError) { /* Stop; do not resend or remove suppression. */ }
31
+ else if (error instanceof NixflexInvalidRequestError) { /* Retain old 400 validation/suppression handling. */ }
32
+ else throw error;
33
+ }
34
+ function bookingPart(event: CallCompletedBookingEvent | SmsBookingEvent): Booking[] {
35
+ // Call only AFTER the existing verifier has checked the original raw webhook body.
36
+ return event.event === 'call.completed' ? event.bookings : [event.booking];
37
+ }
38
+ ```
39
+
40
+ Telnyx uses the same updateCredentials method with only `{telnyx_api_key:process.env.NIXFLEX_TELNYX_API_KEY!,telnyx_connection_id:process.env.NIXFLEX_TELNYX_CONNECTION_ID!}`. Never mix pairs or send provider in the body. Type assertions are not runtime secret validation; the method rejects missing/invalid pairs without HTTP.
41
+
42
+ ## Python sync and async
43
+
44
+ ```python
45
+ import os
46
+ from nixflex import (Nixflex, AsyncNixflex, NixflexDoNotContactError,
47
+ NixflexInvalidRequestError, Booking, CallCompletedBookingEvent, SmsBookingEvent)
48
+ number = '+12025550123'
49
+ config = dict(api_key=os.environ['NIXFLEX_API_KEY'],base_url=os.environ['NIXFLEX_BASE_URL'])
50
+ with Nixflex(**config) as client:
51
+ consent = client.integrations.connect_google_calendar(number, 'https://app.example.test/calendar-return')
52
+ # Present the short-lived link privately to a human; never print it to logs.
53
+ status = client.integrations.get_google_calendar(number)
54
+ settings = client.integrations.update_google_calendar_settings(number, send_invites=False)
55
+ # Separate deliberate disconnect:
56
+ client.integrations.disconnect_google_calendar(number)
57
+ receipt = client.phone_numbers.update_credentials(number,
58
+ telnyx_api_key=os.environ['NIXFLEX_TELNYX_API_KEY'],
59
+ telnyx_connection_id=os.environ['NIXFLEX_TELNYX_CONNECTION_ID'])
60
+ try:
61
+ client.sms.send(agent_id='your-agent-id',from_number=number,to='+12025550124',message='Requested information')
62
+ except NixflexDoNotContactError:
63
+ pass # Stop; nothing sent. Do not retry or bypass opt-out.
64
+ except NixflexInvalidRequestError:
65
+ pass # Existing old-server 400 handling; not all validation failures mean opt-out.
66
+
67
+ async def read_status():
68
+ async with AsyncNixflex(**config) as client:
69
+ return await client.integrations.get_google_calendar(number)
70
+ # Every other method has the same arguments and is awaited in AsyncNixflex.
71
+
72
+ def booking_part(event):
73
+ # Only after raw-body signature verification. TypedDict is not authentication.
74
+ return event['bookings'] if event['event'] == 'call.completed' else [event['booking']]
75
+ ```
76
+
77
+ ## CLI (PowerShell-safe argument shapes)
78
+
79
+ Privately configure NIXFLEX_API_KEY, NIXFLEX_BASE_URL and the selected carrier pair. These command lines contain no secret values. These are independent actions, not one recommended sequence.
80
+
81
+ ```powershell
82
+ nixflex integrations connectGoogleCalendar '+12025550123' --return-url 'https://app.example.test/calendar-return' --confirm
83
+ nixflex integrations getGoogleCalendar '+12025550123' --json
84
+ nixflex integrations updateGoogleCalendarSettings '+12025550123' --body '@calendar-settings.json' --confirm
85
+ nixflex integrations disconnectGoogleCalendar '+12025550123' --confirm
86
+ nixflex numbers updateCredentials '+12025550123' --provider twilio --confirm --json
87
+ # Alternative: a trusted local secret-manager process pipes the exact JSON pair to stdin:
88
+ # <private secret-manager command> | nixflex numbers updateCredentials '+12025550123' --provider telnyx --credentials-stdin --confirm
89
+ ```
90
+
91
+ calendar-settings.json contains settings only, e.g. `{"send_invites":false}`; never carrier credentials. Omit --confirm to preview without a request. Credential commands reject --body, --key and secret flags before the argument parser can echo values. SMS --json errors expose status/type/code: stop on 409 do_not_contact; retain old 400 handling. Webhook types do not add a CLI listener or ingest endpoint.
92
+
93
+ ## Calendar and number tools for MCP
94
+
95
+ Ask the human to approve the exact number/change before using confirm:true. Credentials are preconfigured privately in the SERVER process environment, never tool arguments or chat. Missing configuration sends nothing.
96
+
97
+ | Tool | Arguments example | Result |
98
+ | --- | --- | --- |
99
+ | connect_google_calendar | `{ "phone_number":"+12025550123", "return_url":"https://app.example.test/calendar-return", "confirm":true }` | Consent url + expires_at; human opens it |
100
+ | get_google_calendar | `{ "phone_number":"+12025550123" }` | Six status fields including needs_reconnect and send_invites |
101
+ | update_google_calendar_settings | `{ "phone_number":"+12025550123", "send_invites":false, "confirm":true }` | Safe settings, false preserved |
102
+ | disconnect_google_calendar | `{ "phone_number":"+12025550123", "confirm":true }` | ok:true, connected:false; no claim of remote revoke |
103
+ | update_phone_number_credentials | `{ "phone_number":"+12025550123", "provider":"twilio", "confirm":true }` | Number, provider, updated:true only |
104
+
105
+ All new writes without confirmation return confirmation_required:true, sent:false. Google settings accepts the same fields as Node/Python, including the seven-day hours object above. Use provider telnyx for the alternate private environment pair. No bulk deletion, signup, suppression removal, campaign resume/consent or hidden-write Knowledge draft tool is added.
106
+
107
+ MCP SMS errors use `error.status=409`, `error.type=conflict`, `error.code=do_not_contact`; report that nothing was sent and stop. Older 400 invalid_request remains generic. The shipped booking schema can validate the booking part of an authenticated webhook locally:
108
+
109
+ ```js
110
+ import {callCompletedBookingSchema, smsBookingSchema} from 'nixflex-mcp/booking-schemas.js';
111
+ // verifiedEvent is supplied only after existing raw-body signature verification.
112
+ function parseBookingEvent(verifiedEvent) {
113
+ return verifiedEvent.event === 'call.completed'
114
+ ? callCompletedBookingSchema.parse(verifiedEvent) : smsBookingSchema.parse(verifiedEvent);
115
+ }
116
+ ```
117
+
118
+ No MCP webhook-receiver tool is registered. Booking required keys: action, booking_uid, start, end, attendee_name, attendee_email, service, timezone. Preserve null; service can be numeric. Never count internal already_exists lookups as mutations.
119
+
120
+ ## Contact blocks by business number
121
+
122
+ A STOP received on one number blocks calls and texts from that number. Do not switch senders to bypass an objection. Existing all-number blocks still apply. Check the relevant channel as well as the separate `all` channel bucket.
123
+
124
+ The field `business_number` tells you which sender is blocked. The field `opted_out_business_number` records where the message arrived. For one owned sender, use `scope=effective` to include all-number blocks. A sender alone filters keyword evidence. Use `business_number=all` to list only global entries. Keep filters unchanged and pass each opaque `next_cursor` back as `after` until null. The same recipient can occur on both sides of a page boundary.
125
+
126
+ Use `list_contact_suppressions` with `{"business_number":"+12025550101","scope":"effective"}`. For `add_contact_suppressions`, review `{"phone_numbers":["+12025550100"],"business_number":"+12025550101"}` with the user. Only add `confirm:true` after explicit confirmation. MCP cannot remove blocks. A person must review eligible owner entries in the dashboard, API, SDK or CLI.
127
+
128
+ Omitting the sender on a write targets all numbers. List filters never change this default. A locked STOP cannot be removed. After an uncertain write, check the list before deciding what to do. Never retry automatically.
package/README.md CHANGED
@@ -9,7 +9,7 @@ Claude Desktop, Claude Code, Codex and Cursor can use the server. The Nixflex CL
9
9
 
10
10
  ## Tools and permissions
11
11
 
12
- Use `tools/list` to inspect the 97 registered tools, their input fields and their confirmation requirements. They cover agents, calls, numbers, caller context, voices, retention, activity, campaigns, contacts, web agents, inbox, organisations and integrations. The 19 Knowledge tools include reads and confirmed test questions. Questions may use model work. Live edits, uploads, imports, job control and bulk exports require another client. Reading a legacy draft can save changes, so that operation is available through the SDK and CLI only.
12
+ Use `tools/list` to inspect the 98 registered tools, their input fields and their confirmation requirements. They cover agents, calls, numbers, caller context, voices, retention, activity, campaigns, contacts, web agents, inbox, organisations and integrations. The 19 Knowledge tools include reads and confirmed test questions. Questions may use model work. Live edits, uploads, imports, job control and bulk exports require another client. Reading a legacy draft can save changes, so that operation is available through the SDK and CLI only.
13
13
 
14
14
  When a tool offers a preview, inspect it before passing `confirm:true`. For a paid outbound call, prepare and save a UUID before sending. Passing `request_id` to `create_call` requires confirmation. The original call flow without an ID keeps its existing inputs. Writes run once. An uncertain call with a UUID retains its saved ID and `safe_to_retry:false`. Other uncertain writes return `outcome_unknown`. GET has one bounded retry.
15
15
 
@@ -22,4 +22,24 @@ Account signup returns a secret and bulk deletion can remove many records. Use t
22
22
  - [Calendar settings](https://docs.nixflex.com/ai-tools/calendar-settings) and [number credentials](https://docs.nixflex.com/ai-tools/number-credentials).
23
23
  - [Organisations](https://docs.nixflex.com/guides/developer/organisations) and [Knowledge](https://docs.nixflex.com/guides/developer/knowledge).
24
24
 
25
+ ## Monitor live calls and save agent settings
26
+
27
+ Use `list_live_calls` for a summary of calls on monitor-enabled numbers. A partial list has unknown counts. Pass creation belongs in the server SDK or a private terminal because the returned socket URL grants access to a live call and an assistant cannot play or publish audio.
28
+
29
+ Each call supports up to **10 audio listeners** and **100 listeners in total** across audio and text. A pass is single-use and gives the listener 60 seconds to join. Once connected, the session continues past that deadline while its lease and permission remain valid. A pass does not reserve a seat. When all 10 audio seats are taken, an audio pass request through a server SDK or the CLI returns HTTP 409 `audio_seats_full`. This is a definite refusal after one attempt and no pass was issued. Request a fresh pass in text mode to follow the transcript. `list_live_calls` is unchanged.
30
+
31
+ The default API key limit is 300 requests per minute. If pass creation through a server SDK receives HTTP 503 `monitor_unavailable`, the SDK reports `outcome_unknown`, preserves status 503 and the cause in `details.original_code`, and makes one attempt. The CLI reports `503 outcome_unknown`. Check the call before requesting another pass.
32
+
33
+ For `update_agent`, pass the agent ID and the following `fields` object, substituting the revision returned by `get_agent`.
34
+
35
+ ```json
36
+ {"if_revision":"0123456789abcdef01234567","changes":{"welcome_message":"How can I help?"}}
37
+ ```
38
+
39
+ Use the `settings_revision` from the latest agent read as `if_revision`. Supply `if_voice` to compare the voice fields you read, including an explicit null. Send edits beside the guards or inside `changes`. The envelope requires `if_revision` and places all edits inside `changes`. With agent settings enabled, a guarded save applies every change together. Use the envelope when engine support is uncertain. Engines that cannot apply it refuse the whole save. After a 409 `settings_revision_conflict` or `agent_voice_conflict`, read the agent again and review the edits. A 400 `empty_agent_update` or `invalid_agent_field` asks you to correct the request. Keep the guard on every retry.
40
+
41
+ For `call_flag_rules`, `paused_by_card: true` requires `paused: true`. Resuming the card lifts only its own pauses. An individually paused flag stays paused.
42
+
43
+ The signed `call.listening_started` webhook follows the first confirmed audio playback. `call.taken_over` follows the first committed takeover. Each fires once per call per destination URL. The socket signals `call_ended` immediately and the existing `call.completed` webhook follows.
44
+
25
45
  [Package guide](https://docs.nixflex.com/sdks/mcp) · Developer contact: dev@nixflex.com
@@ -0,0 +1,34 @@
1
+ import * as z from 'zod/v4';
2
+ import { agentUpdateFields } from './agent-schema.js';
3
+
4
+ const flag = z.strictObject({
5
+ id: z.string(), label: z.string(), watch_for: z.string(), enabled: z.boolean(),
6
+ paused: z.boolean().optional(), paused_by_card: z.boolean().optional(),
7
+ });
8
+ const voiceValue = z.union([z.string().max(200), z.number().int(), z.null()]).optional();
9
+ const voice = z.strictObject({
10
+ voice_id: voiceValue, voice_key: voiceValue, language: voiceValue, voice_route_key: voiceValue,
11
+ backup_voice_key: voiceValue, backup_voice_route_key: voiceValue, voice_pair_version: voiceValue,
12
+ });
13
+ const changes = agentUpdateFields.extend({ call_flag_rules: z.array(flag).max(10).nullable().optional() });
14
+ export const settingsFields = changes.extend({
15
+ if_revision: z.string().regex(/^[a-f0-9]{24}$/).optional(),
16
+ if_voice: voice.optional(), changes: changes.optional(),
17
+ });
18
+
19
+ const messages = new Map(Object.entries({
20
+ "settings_revision_conflict": "Agent settings changed. Read the latest settings and review your edits before saving.",
21
+ "agent_voice_conflict": "The saved voice changed. Read the latest voice settings before saving.",
22
+ "empty_agent_update": "Supply at least one changed agent setting.",
23
+ "invalid_agent_field": "Check the rejected agent fields and their values."
24
+ }));
25
+ export async function updateSettings(client, id, fields) {
26
+ try {
27
+ return await client.agents.update(id, fields);
28
+ } catch (error) {
29
+ if ([400, 409].includes(error?.status) && messages.has(error.code)) {
30
+ error.message = [error.message, messages.get(error.code)].filter(Boolean).join(' ');
31
+ }
32
+ throw error;
33
+ }
34
+ }
package/c5-schemas.js CHANGED
@@ -1,17 +1,31 @@
1
- import * as z from 'zod/v4';
2
- // Additive C5 schemas. Omission is preserved; no consent or server defaults are invented.
3
- export const s97 = z.object({"status": z.string().optional(), "limit": z.number().int().min(1).max(200).optional()}).strict();
4
- export const s91 = z.object({"id": z.string().min(1).max(100).regex(new RegExp("^[A-Za-z0-9_-]+$")), "confirm": z.boolean().optional()}).strict();
5
- export const s179 = z.object({"id": z.string(), "body": z.object({"is_active": z.boolean().optional(), "reply_context_prompt": z.union([z.string(), z.null()]).optional(), "reply_window_hours": z.number().int().min(1).optional()}).strict().refine(v => Object.keys(v).length >= 1, "Supply at least one setting"), "confirm": z.boolean().optional()}).strict();
6
- export const s180 = z.object({"id": z.string().min(1).max(100).regex(new RegExp("^[A-Za-z0-9_-]+$")), "confirm": z.boolean().optional()}).strict();
7
- export const s98 = z.object({"agent_id": z.string().regex(new RegExp("^[A-Za-z0-9_-]{1,64}$")), "recipients": z.array(z.object({"phone": z.string().max(32), "country": z.string().max(2).optional(), "timezone": z.string().max(80).optional()}).strict()).min(1).max(20), "campaign": z.object({"allow_wider_hours": z.boolean().optional(), "start": z.string().regex(new RegExp("^(?:[01][0-9]|2[0-3]):[0-5][0-9]$")).optional(), "end": z.string().regex(new RegExp("^(?:[01][0-9]|2[0-3]):[0-5][0-9]$")).optional(), "days": z.array(z.enum(["sun", "mon", "tue", "wed", "thu", "fri", "sat"])).min(1).max(7).optional(), "scheduled_date": z.string().optional()}).passthrough().optional()}).strict();
8
- export const s100 = z.object({"channel": z.enum(["all", "voice", "sms"]).optional(), "after": z.string().regex(new RegExp("^\\+[1-9][0-9]{6,14}$")).optional()}).strict();
9
- export const s101 = z.object({"phone_numbers": z.array(z.string().regex(new RegExp("^\\+[1-9][0-9]{6,14}$"))).min(1).max(1000), "channel": z.enum(["all", "voice", "sms"]).optional(), "confirm": z.boolean().optional()}).strict();
10
- export const s58 = z.object({"number": z.string().regex(new RegExp("^\\+[1-9][0-9]{6,14}$"))}).strict();
11
- export const s59 = z.object({"number": z.string().regex(new RegExp("^\\+[1-9][0-9]{6,14}$")), "body": z.object({"revision": z.string().regex(new RegExp("^[0-9]{1,18}$")), "settings": z.object({"web_prompt": z.string().max(16000).refine(v => v.length <= 16000, "Maximum 16000 UTF-16 code units").optional(), "web_design": z.number().int().min(1).max(10).optional(), "web_color": z.string().regex(new RegExp("^#[0-9a-fA-F]{6}$")).optional(), "web_name": z.string().max(80).optional(), "web_chips": z.string().max(323).optional(), "web_calls_enabled": z.boolean().optional(), "web_appearance": z.object({"version": z.literal(1), "launcher": z.string().regex(new RegExp("^[a-z][a-z0-9-]{0,31}$")), "window": z.enum(["compact", "side", "centre", "full"]), "visit": z.enum(["nothing", "greeting", "open"]), "theme": z.enum(["dark", "light"]), "colourMode": z.enum(["solid", "gradient"]), "colour": z.string().regex(new RegExp("^#[0-9a-fA-F]{6}$")), "colour2": z.string().regex(new RegExp("^#[0-9a-fA-F]{6}$")), "text": z.object({"greeting": z.string().max(500).optional(), "button": z.string().max(500).optional(), "title": z.string().max(500).optional(), "subtitle": z.string().max(500).optional(), "call": z.string().max(500).optional(), "chat": z.string().max(500).optional(), "welcome": z.string().max(500).optional(), "placeholder": z.string().max(500).optional(), "status": z.string().max(500).optional(), "send": z.string().max(500).optional(), "close": z.string().max(500).optional(), "footer": z.string().max(500).optional(), "typing": z.string().max(500).optional(), "error": z.string().max(500).optional(), "contact": z.string().max(500).optional(), "contactNote": z.string().max(500).optional(), "contactName": z.string().max(500).optional(), "contactPhone": z.string().max(500).optional(), "avatar": z.string().max(500).optional(), "voiceConnecting": z.string().max(500).optional(), "voicePrivacy": z.string().max(500).optional(), "voiceMute": z.string().max(500).optional(), "voiceUnmute": z.string().max(500).optional(), "voiceEnd": z.string().max(500).optional(), "voiceAllow": z.string().max(500).optional(), "voiceCancel": z.string().max(500).optional(), "voiceEnded": z.string().max(500).optional(), "voiceYouEnded": z.string().max(500).optional(), "voiceUnavailable": z.string().max(500).optional(), "voiceUnavailableNote": z.string().max(500).optional(), "voiceDisabled": z.string().max(500).optional(), "voiceInsecure": z.string().max(500).optional(), "voiceInsecureNote": z.string().max(500).optional(), "voicePermission": z.string().max(500).optional(), "voicePermissionNote": z.string().max(500).optional(), "voiceChecking": z.string().max(500).optional(), "voiceNeeded": z.string().max(500).optional(), "voiceBlocked": z.string().max(500).optional(), "voiceMissing": z.string().max(500).optional(), "voiceInUse": z.string().max(500).optional(), "voiceMicError": z.string().max(500).optional(), "voiceBusy": z.string().max(500).optional(), "voiceBusyNote": z.string().max(500).optional(), "voiceRinging": z.string().max(500).optional(), "voiceLive": z.string().max(500).optional(), "voiceError": z.string().max(500).optional(), "contactSave": z.string().max(500).optional(), "contactSavedEdit": z.string().max(500).optional(), "contactRequired": z.string().max(500).optional(), "beforeCallStart": z.string().max(500).optional(), "beforeCallCancel": z.string().max(500).optional()}).strict(), "contactFields": z.array(z.object({"id": z.string().regex(new RegExp("^(name|phone|email|order|custom_[1-5])$")), "label": z.string().min(1).max(60), "enabled": z.boolean(), "required": z.boolean(), "askInChat": z.boolean().optional()}).strict()).max(9).optional(), "beforeCall": z.object({"enabled": z.boolean(), "message": z.string().max(500), "fields": z.array(z.object({"id": z.string().regex(new RegExp("^(name|phone|email|order|custom_[1-5])$")), "required": z.boolean()}).strict()).max(9)}).strict().optional()}).strict().optional()}).strict().refine(v => Object.keys(v).length >= 1, "Supply at least one setting")}).strict(), "confirm": z.boolean().optional()}).strict();
12
- export const s52 = z.object({"channel": z.enum(["sms", "web"]), "number": z.string().regex(new RegExp("^\\+[1-9][0-9]{6,14}$")), "archived": z.boolean().optional(), "unread": z.boolean().optional(), "search": z.string().max(160).optional(), "since": z.string().optional(), "period": z.enum(["all", "today", "7", "30", "90"]).optional(), "limit": z.number().int().min(1).max(100).optional(), "offset": z.number().int().min(0).max(10000).optional()}).strict();
13
- export const s53 = z.object({"channel": z.enum(["sms", "web"]), "number": z.string().regex(new RegExp("^\\+[1-9][0-9]{6,14}$")), "thread": z.string().min(1).max(160), "limit": z.number().int().min(1).max(200).optional(), "before": z.string().optional(), "before_id": z.string().max(80).optional()}).strict();
14
- export const s54 = z.object({"channel": z.enum(["sms", "web"]), "number": z.string().regex(new RegExp("^\\+[1-9][0-9]{6,14}$")), "thread": z.string().min(1).max(160), "body": z.object({"archived": z.boolean().optional(), "read_version": z.string().regex(new RegExp("^[0-9]{1,18}$")).optional()}).strict().refine(v => Object.keys(v).length >= 1, "Supply at least one setting"), "confirm": z.boolean().optional()}).strict();
15
- export const s55 = z.object({}).strict();
16
- export const s56 = z.object({"offset": z.number().int().min(0).max(10000).optional()}).strict();
17
- export const s57 = z.object({"number": z.string().regex(new RegExp("^\\+[1-9][0-9]{6,14}$")).optional()}).strict();
1
+ import * as z from 'zod/v4';
2
+ // Additive C5 schemas. Omission is preserved; no consent or server defaults are invented.
3
+ export const s97 = z.object({"status": z.string().optional(), "limit": z.number().int().min(1).max(200).optional()}).strict();
4
+ export const s91 = z.object({"id": z.string().min(1).max(100).regex(new RegExp("^[A-Za-z0-9_-]+$")), "confirm": z.boolean().optional()}).strict();
5
+ export const s179 = z.object({"id": z.string(), "body": z.object({"is_active": z.boolean().optional(), "reply_context_prompt": z.union([z.string(), z.null()]).optional(), "reply_window_hours": z.number().int().min(1).optional()}).strict().refine(v => Object.keys(v).length >= 1, "Supply at least one setting"), "confirm": z.boolean().optional()}).strict();
6
+ export const s180 = z.object({"id": z.string().min(1).max(100).regex(new RegExp("^[A-Za-z0-9_-]+$")), "confirm": z.boolean().optional()}).strict();
7
+ export const s98 = z.object({"agent_id": z.string().regex(new RegExp("^[A-Za-z0-9_-]{1,64}$")), "recipients": z.array(z.object({"phone": z.string().max(32), "country": z.string().max(2).optional(), "timezone": z.string().max(80).optional()}).strict()).min(1).max(20), "campaign": z.object({"allow_wider_hours": z.boolean().optional(), "start": z.string().regex(new RegExp("^(?:[01][0-9]|2[0-3]):[0-5][0-9]$")).optional(), "end": z.string().regex(new RegExp("^(?:[01][0-9]|2[0-3]):[0-5][0-9]$")).optional(), "days": z.array(z.enum(["sun", "mon", "tue", "wed", "thu", "fri", "sat"])).min(1).max(7).optional(), "scheduled_date": z.string().optional()}).passthrough().optional()}).strict();
8
+ const phone = z.string().regex(/^\+[1-9][0-9]{6,14}$/);
9
+ const businessNumber = z.union([z.literal('all'), phone]);
10
+ const contactChannel = z.enum(['all', 'voice', 'sms']);
11
+ export const s100 = z.object({
12
+ channel: contactChannel.optional(),
13
+ after: z.string().min(1).optional(),
14
+ business_number: businessNumber.optional(),
15
+ scope: z.literal('effective').optional(),
16
+ source: z.enum(['owner', 'registry', 'support', 'sms_optout', 'ai_optout', 'attributed']).optional(),
17
+ }).strict();
18
+ export const s101 = z.object({
19
+ phone_numbers: z.array(phone).min(1).max(1000),
20
+ channel: contactChannel.optional(),
21
+ business_number: businessNumber.optional(),
22
+ confirm: z.boolean().optional(),
23
+ }).strict();
24
+ export const s58 = z.object({"number": z.string().regex(new RegExp("^\\+[1-9][0-9]{6,14}$"))}).strict();
25
+ export const s59 = z.object({"number": z.string().regex(new RegExp("^\\+[1-9][0-9]{6,14}$")), "body": z.object({"revision": z.string().regex(new RegExp("^[0-9]{1,18}$")), "settings": z.object({"web_prompt": z.string().max(16000).refine(v => v.length <= 16000, "Maximum 16000 UTF-16 code units").optional(), "web_design": z.number().int().min(1).max(10).optional(), "web_color": z.string().regex(new RegExp("^#[0-9a-fA-F]{6}$")).optional(), "web_name": z.string().max(80).optional(), "web_chips": z.string().max(323).optional(), "web_calls_enabled": z.boolean().optional(), "web_appearance": z.object({"version": z.literal(1), "launcher": z.string().regex(new RegExp("^[a-z][a-z0-9-]{0,31}$")), "window": z.enum(["compact", "side", "centre", "full"]), "visit": z.enum(["nothing", "greeting", "open"]), "theme": z.enum(["dark", "light"]), "colourMode": z.enum(["solid", "gradient"]), "colour": z.string().regex(new RegExp("^#[0-9a-fA-F]{6}$")), "colour2": z.string().regex(new RegExp("^#[0-9a-fA-F]{6}$")), "text": z.object({"greeting": z.string().max(500).optional(), "button": z.string().max(500).optional(), "title": z.string().max(500).optional(), "subtitle": z.string().max(500).optional(), "call": z.string().max(500).optional(), "chat": z.string().max(500).optional(), "welcome": z.string().max(500).optional(), "placeholder": z.string().max(500).optional(), "status": z.string().max(500).optional(), "send": z.string().max(500).optional(), "close": z.string().max(500).optional(), "footer": z.string().max(500).optional(), "typing": z.string().max(500).optional(), "error": z.string().max(500).optional(), "contact": z.string().max(500).optional(), "contactNote": z.string().max(500).optional(), "contactName": z.string().max(500).optional(), "contactPhone": z.string().max(500).optional(), "avatar": z.string().max(500).optional(), "voiceConnecting": z.string().max(500).optional(), "voicePrivacy": z.string().max(500).optional(), "voiceMute": z.string().max(500).optional(), "voiceUnmute": z.string().max(500).optional(), "voiceEnd": z.string().max(500).optional(), "voiceAllow": z.string().max(500).optional(), "voiceCancel": z.string().max(500).optional(), "voiceEnded": z.string().max(500).optional(), "voiceYouEnded": z.string().max(500).optional(), "voiceUnavailable": z.string().max(500).optional(), "voiceUnavailableNote": z.string().max(500).optional(), "voiceDisabled": z.string().max(500).optional(), "voiceInsecure": z.string().max(500).optional(), "voiceInsecureNote": z.string().max(500).optional(), "voicePermission": z.string().max(500).optional(), "voicePermissionNote": z.string().max(500).optional(), "voiceChecking": z.string().max(500).optional(), "voiceNeeded": z.string().max(500).optional(), "voiceBlocked": z.string().max(500).optional(), "voiceMissing": z.string().max(500).optional(), "voiceInUse": z.string().max(500).optional(), "voiceMicError": z.string().max(500).optional(), "voiceBusy": z.string().max(500).optional(), "voiceBusyNote": z.string().max(500).optional(), "voiceRinging": z.string().max(500).optional(), "voiceLive": z.string().max(500).optional(), "voiceError": z.string().max(500).optional(), "contactSave": z.string().max(500).optional(), "contactSavedEdit": z.string().max(500).optional(), "contactRequired": z.string().max(500).optional(), "beforeCallStart": z.string().max(500).optional(), "beforeCallCancel": z.string().max(500).optional()}).strict(), "contactFields": z.array(z.object({"id": z.string().regex(new RegExp("^(name|phone|email|order|custom_[1-5])$")), "label": z.string().min(1).max(60), "enabled": z.boolean(), "required": z.boolean(), "askInChat": z.boolean().optional()}).strict()).max(9).optional(), "beforeCall": z.object({"enabled": z.boolean(), "message": z.string().max(500), "fields": z.array(z.object({"id": z.string().regex(new RegExp("^(name|phone|email|order|custom_[1-5])$")), "required": z.boolean()}).strict()).max(9)}).strict().optional()}).strict().optional()}).strict().refine(v => Object.keys(v).length >= 1, "Supply at least one setting")}).strict(), "confirm": z.boolean().optional()}).strict();
26
+ export const s52 = z.object({"channel": z.enum(["sms", "web"]), "number": z.string().regex(new RegExp("^\\+[1-9][0-9]{6,14}$")), "archived": z.boolean().optional(), "unread": z.boolean().optional(), "search": z.string().max(160).optional(), "since": z.string().optional(), "period": z.enum(["all", "today", "7", "30", "90"]).optional(), "limit": z.number().int().min(1).max(100).optional(), "offset": z.number().int().min(0).max(10000).optional()}).strict();
27
+ export const s53 = z.object({"channel": z.enum(["sms", "web"]), "number": z.string().regex(new RegExp("^\\+[1-9][0-9]{6,14}$")), "thread": z.string().min(1).max(160), "limit": z.number().int().min(1).max(200).optional(), "before": z.string().optional(), "before_id": z.string().max(80).optional()}).strict();
28
+ export const s54 = z.object({"channel": z.enum(["sms", "web"]), "number": z.string().regex(new RegExp("^\\+[1-9][0-9]{6,14}$")), "thread": z.string().min(1).max(160), "body": z.object({"archived": z.boolean().optional(), "read_version": z.string().regex(new RegExp("^[0-9]{1,18}$")).optional()}).strict().refine(v => Object.keys(v).length >= 1, "Supply at least one setting"), "confirm": z.boolean().optional()}).strict();
29
+ export const s55 = z.object({}).strict();
30
+ export const s56 = z.object({"offset": z.number().int().min(0).max(10000).optional()}).strict();
31
+ export const s57 = z.object({"number": z.string().regex(new RegExp("^\\+[1-9][0-9]{6,14}$")).optional()}).strict();
package/c5-tools.js CHANGED
@@ -1,31 +1,35 @@
1
- import * as schemas from './c5-schemas.js';
2
- import { executeTool, errorBody } from './safe-tools.js';
3
-
4
- export function registerC5Tools(server, request) {
5
- const enc = encodeURIComponent;
6
- const add = (name, schema, description, read, fn) => server.registerTool(name, {
7
- title: name.replaceAll('_', ' '), description: description + (read ? ' Use only when the user requests this information or advisory preview.' : ' Use only for the user\'s explicitly requested change. Requires confirm:true. Without confirmation sends zero requests. Never automatically repeat an uncertain write.'),
8
- inputSchema: schema, annotations: { title: name.replaceAll('_', ' '), readOnlyHint: read, destructiveHint: !read, idempotentHint: read, openWorldHint: true },
9
- }, async args => {
10
- try {
11
- const { confirm, ...input } = args;
12
- const data = !read && confirm !== true ? { confirmation_required: true, sent: false, message: 'No request sent. Confirm only this intentional change.' } : await executeTool(name, fn, input);
13
- return { content: [{ type: 'text', text: JSON.stringify(data) }] };
14
- } catch (error) { return { isError: true, content: [{ type: 'text', text: JSON.stringify(errorBody(error)) }] }; }
15
- });
16
- add('list_campaigns', schemas.s97, "Default 50, cap 200; no cursor.", true, (query) => request('GET', `/campaigns`, undefined, query));
17
- add('cancel_campaign', schemas.s91, "Stops future work; in-progress calls may finish.", false, ({ id, ...query }) => request('POST', `/calls/batch/${enc(id)}/cancel`, undefined, undefined));
18
- add('update_sms_campaign', schemas.s179, "Changes reply settings only; does not cancel dispatch.", false, ({ id, ...query }) => request('PATCH', `/sms/campaigns/${enc(id)}`, query.body, undefined));
19
- add('cancel_sms_campaign', schemas.s180, "Stops future work; in-progress sends may finish.", false, ({ id, ...query }) => request('POST', `/sms/campaigns/${enc(id)}/cancel`, undefined, undefined));
20
- add('preview_contact_hours', schemas.s98, "Advisory only, expires after one minute. Never a permission token; POST is never automatically retried.", true, (query) => request('POST', `/contact-hours/preview`, query, undefined));
21
- add('list_contact_suppressions', schemas.s100, "Fixed 200 rows; all is a separate bucket, not a union. Continue after next_cursor until null.", true, (query) => request('GET', `/contact-suppressions`, undefined, query));
22
- add('add_contact_suppressions', schemas.s101, "Blocks contact for the explicit 1\u20131000 numbers; preserves locked opt-out evidence.", false, (query) => request('POST', `/contact-suppressions`, query, undefined));
23
- add('get_web_agent', schemas.s58, "Read current revision before changing settings.", true, ({ number, ...query }) => request('GET', `/agent-web/${enc(number)}`, undefined, query));
24
- add('update_web_agent', schemas.s59, "Revision is a string. Appearance is a COMPLETE replacement, not a merge. On conflict reload and compare; never retry the stale update.", false, ({ number, ...query }) => request('PATCH', `/agent-web/${enc(number)}`, query.body, undefined));
25
- add('list_inbox_conversations', schemas.s52, "Reads do not mark messages read; unread_total counts conversations, not messages. since and period cannot be combined.", true, ({ channel, number, ...query }) => request('GET', `/agent-inbox/${enc(channel)}/${enc(number)}`, undefined, query));
26
- add('get_inbox_thread', schemas.s53, "Before and before_id are paired; read_version covers the whole thread. Reading never acknowledges messages.", true, ({ channel, number, thread, ...query }) => request('GET', `/agent-inbox/${enc(channel)}/${enc(number)}/thread/${enc(thread)}`, undefined, query));
27
- add('update_inbox_thread', schemas.s54, "Use the whole-thread string read_version; archive is not erasure.", false, ({ channel, number, thread, ...query }) => request('PATCH', `/agent-inbox/${enc(channel)}/${enc(number)}/thread/${enc(thread)}`, query.body, undefined));
28
- add('get_inbox_features', schemas.s55, "Feature availability, not proof of database readiness.", true, (query) => request('GET', `/agent-inbox/features`, undefined, query));
29
- add('list_inbox_numbers', schemas.s56, "Fixed 100 rows; agents capped at 1,000. No automatic pagination.", true, (query) => request('GET', `/agent-inbox/numbers`, undefined, query));
30
- add('get_inbox_retention', schemas.s57, "Zero days means the next cleanup after reply. Archive does not change retention.", true, (query) => request('GET', `/agent-inbox/retention`, undefined, query));
31
- }
1
+ import * as schemas from './c5-schemas.js';
2
+ import { executeTool, errorBody } from './safe-tools.js';
3
+
4
+ export function registerC5Tools(server, request) {
5
+ const enc = encodeURIComponent;
6
+ const add = (name, schema, description, read, fn) => server.registerTool(name, {
7
+ title: name.replaceAll('_', ' '), description: description + (read ? ' Use only when the user requests this information or advisory preview.' : ' Use only for the user\'s explicitly requested change. Requires confirm:true. Without confirmation sends zero requests. Never automatically repeat an uncertain write.'),
8
+ inputSchema: schema, annotations: { title: name.replaceAll('_', ' '), readOnlyHint: read, destructiveHint: !read, idempotentHint: read, openWorldHint: true },
9
+ }, async args => {
10
+ try {
11
+ const { confirm, ...input } = args;
12
+ const data = !read && confirm !== true ? { confirmation_required: true, sent: false, message: 'No request sent. Confirm only this intentional change.' } : await executeTool(name, fn, input);
13
+ return { content: [{ type: 'text', text: JSON.stringify(data) }] };
14
+ } catch (error) { return { isError: true, content: [{ type: 'text', text: JSON.stringify(errorBody(error)) }] }; }
15
+ });
16
+ add('list_campaigns', schemas.s97, "Default 50, cap 200; no cursor.", true, (query) => request('GET', `/campaigns`, undefined, query));
17
+ add('cancel_campaign', schemas.s91, "Stops future work; in-progress calls may finish.", false, ({ id, ...query }) => request('POST', `/calls/batch/${enc(id)}/cancel`, undefined, undefined));
18
+ add('update_sms_campaign', schemas.s179, "Changes reply settings only; does not cancel dispatch.", false, ({ id, ...query }) => request('PATCH', `/sms/campaigns/${enc(id)}`, query.body, undefined));
19
+ add('cancel_sms_campaign', schemas.s180, "Stops future work; in-progress sends may finish.", false, ({ id, ...query }) => request('POST', `/sms/campaigns/${enc(id)}/cancel`, undefined, undefined));
20
+ add('preview_contact_hours', schemas.s98, "Advisory only, expires after one minute. Never a permission token; POST is never automatically retried.", true, (query) => request('POST', `/contact-hours/preview`, query, undefined));
21
+ add('list_contact_suppressions', schemas.s100,
22
+ 'List up to 200 blocks. With business_number set to an owned E.164 sender, use scope=effective for that sender plus all-number blocks. A sender alone filters keyword evidence. Use source=attributed for keyword and AI evidence, or source=owner for owner entries. Set business_number=all for global rows only. Each row’s business_number is its scope. opted_out_business_number is where the message arrived. Channel all is a separate bucket. Pass next_cursor unchanged as after until null. Never switch senders to bypass STOP.',
23
+ true, query => request('GET', '/contact-suppressions', undefined, query));
24
+ add('add_contact_suppressions', schemas.s101,
25
+ 'Block 1–1000 recipients on one owned E.164 business_number or all my numbers (all, the default). Confirm the recipients, channel and exact sender scope with the user. A previous list filter does not set the write scope. Preserve locked opt-outs. Only a person can remove an eligible owner entry in the dashboard, API, SDK or CLI.',
26
+ false, query => request('POST', '/contact-suppressions', query, undefined));
27
+ add('get_web_agent', schemas.s58, "Read current revision before changing settings.", true, ({ number, ...query }) => request('GET', `/agent-web/${enc(number)}`, undefined, query));
28
+ add('update_web_agent', schemas.s59, "Revision is a string. Appearance is a COMPLETE replacement, not a merge. On conflict reload and compare; never retry the stale update.", false, ({ number, ...query }) => request('PATCH', `/agent-web/${enc(number)}`, query.body, undefined));
29
+ add('list_inbox_conversations', schemas.s52, "Reads do not mark messages read; unread_total counts conversations, not messages. since and period cannot be combined.", true, ({ channel, number, ...query }) => request('GET', `/agent-inbox/${enc(channel)}/${enc(number)}`, undefined, query));
30
+ add('get_inbox_thread', schemas.s53, "Before and before_id are paired; read_version covers the whole thread. Reading never acknowledges messages.", true, ({ channel, number, thread, ...query }) => request('GET', `/agent-inbox/${enc(channel)}/${enc(number)}/thread/${enc(thread)}`, undefined, query));
31
+ add('update_inbox_thread', schemas.s54, "Use the whole-thread string read_version; archive is not erasure.", false, ({ channel, number, thread, ...query }) => request('PATCH', `/agent-inbox/${enc(channel)}/${enc(number)}/thread/${enc(thread)}`, query.body, undefined));
32
+ add('get_inbox_features', schemas.s55, "Feature availability, not proof of database readiness.", true, (query) => request('GET', `/agent-inbox/features`, undefined, query));
33
+ add('list_inbox_numbers', schemas.s56, "Fixed 100 rows; agents capped at 1,000. No automatic pagination.", true, (query) => request('GET', `/agent-inbox/numbers`, undefined, query));
34
+ add('get_inbox_retention', schemas.s57, "Zero days means the next cleanup after reply. Archive does not change retention.", true, (query) => request('GET', `/agent-inbox/retention`, undefined, query));
35
+ }
@@ -2,6 +2,7 @@
2
2
  const TITLES = Object.freeze({
3
3
  get_usage: 'Read account usage and balance',
4
4
  rotate_api_key: 'Replace the API secret',
5
+ list_live_calls: 'List live calls',
5
6
  list_agents: 'List agents', get_agent: 'Read one agent',
6
7
  create_agent: 'Create an agent', update_agent: 'Update an agent', delete_agent: 'Disable an agent',
7
8
  create_call: 'Place a paid phone call', list_calls: 'List call summaries',
@@ -19,7 +20,7 @@ const TITLES = Object.freeze({
19
20
  delete_webhook: 'Remove a webhook', get_byo_config: 'Read own-provider settings',
20
21
  set_byo_config: 'Connect own storage or AI provider', delete_byo_config: 'Disconnect own storage or AI provider',
21
22
  });
22
- const READS = new Set(['get_usage', 'list_agents', 'get_agent', 'list_calls', 'get_call',
23
+ const READS = new Set(['get_usage', 'list_live_calls', 'list_agents', 'get_agent', 'list_calls', 'get_call',
23
24
  'list_phone_numbers', 'get_caller_context', 'list_sms_campaigns', 'get_sms_campaign', 'get_webhook', 'get_byo_config']);
24
25
  const DETAILS = Object.freeze({
25
26
  rotate_api_key: 'Replace the API secret. The current secret stops working immediately; every integration must be updated. The response can contain the replacement secret, visible to the chat client. Prefer the dashboard for rotation. Requires confirm: true; otherwise returns a preview.',
package/index.js CHANGED
@@ -39,7 +39,9 @@ import { contactLocation, voiceCampaignSchema, smsCampaignSchema, campaignBody,
39
39
  import { executeTool, errorBody } from './safe-tools.js';
40
40
  import { numberReads } from './number-reads.js';
41
41
  import { numberReadSchema, numberFields } from './number-schema.js';
42
- import { agentCreateFields, agentUpdateFields } from './agent-schema.js';
42
+ import { agentCreateFields } from './agent-schema.js';
43
+ import { settingsFields, updateSettings } from './agent-settings.js';
44
+ import { listLiveCalls } from './monitor-tools.js';
43
45
  import { agentReads, agentListSchema } from './agent-reads.js';
44
46
  import { createCallBody, summariseCall as callSummary } from './call-tools.js';
45
47
  import { callReads, callListSchema, callGetSchema } from './call-reads.js';
@@ -93,12 +95,14 @@ T('list_agents', 'List the agents on this account. Phone numbers, webhooks and i
93
95
  T('get_agent', 'One agent with its prompt and settings.', z.object({ agent_id: z.string() }), ({ agent_id }) => client.agents.get(agent_id));
94
96
  T('create_agent', 'Create an agent. All fields are optional. New defaults: maximum call 300 seconds, silence hang-up 10 seconds, dynamic greeting on; any other agent field (voice_id, language, incall_sms_enabled, silence_hangup_seconds, record_call, recording_source = provider or nixflex, ...) goes in fields.',
95
97
  z.object({ name: z.string().optional(), system_prompt: z.string().optional(), fields: agentCreateFields.optional() }), ({ name, system_prompt, fields: f }) => client.agents.create({ name, system_prompt, ...(f || {}) }));
96
- T('update_agent', 'Update an agent. Empty/unknown-only updates fail; mixed unknown keys return warnings. Only passed fields change. Pass null only to clear nullable fields.',
97
- z.object({ agent_id: z.string(), fields: agentUpdateFields }), ({ agent_id, fields: f }) => client.agents.update(agent_id, f));
98
+ T('update_agent', 'Update only the supplied agent settings. Pass if_revision and optional if_voice with edits, or put edits in changes with if_revision. Guarded edits are atomic. Refresh after a conflict.',
99
+ z.object({ agent_id: z.string(), fields: settingsFields }), ({ agent_id, fields: f }) => updateSettings(client, agent_id, f));
98
100
  T('delete_agent', 'Soft disable an agent, not permanent deletion. Does not detach numbers or erase history. Requires confirm: true; otherwise returns a preview.',
99
101
  z.object({ agent_id: z.string(), confirm: confirmArg }), async ({ agent_id, confirm }) => confirm ? client.agents.delete(agent_id) : preview('agent ' + agent_id, () => client.agents.get(agent_id)));
100
102
 
101
103
  // ============ calls ============
104
+ T('list_live_calls', 'List live calls on monitor-enabled numbers. Partial results have unknown counts. Returns call summaries only.',
105
+ z.object({}), () => listLiveCalls(request));
102
106
  registerK7CreateCall(server, {client, request, metadata:toolMetadata, E164, contactLocation});
103
107
  T('list_calls', 'Call summaries without transcript. history:true adds dashboard filters, totals and next_cursor; continue with cursor + limit only. period defaults month; today uses UTC, or pass exact since/until from dashboard.',
104
108
  callListSchema, args => readCalls.list(args, summariseCall));
@@ -0,0 +1,17 @@
1
+ import * as z from 'zod/v4';
2
+
3
+ const count = z.number().int().nonnegative();
4
+ const call = z.object({
5
+ call_id: z.string(), number: z.string(), caller: z.string().nullable(), direction: z.string(),
6
+ state: z.string(), started_at: z.number().nullable(), agent_id: z.string().nullable(),
7
+ agent_name: z.string().nullable(), listeners: count, taken_over: z.boolean(), takeover_name: z.string().nullable(),
8
+ });
9
+ const listing = z.object({
10
+ calls: z.array(call), live_count: count.nullable(), listening_count: count.nullable(),
11
+ taken_over_count: count.nullable(), status: z.enum(['available', 'partial']), complete: z.boolean(), server_now: z.number(),
12
+ });
13
+
14
+ export async function listLiveCalls(request) {
15
+ // Project both levels so future socket credentials or transcripts cannot enter a tool response.
16
+ return listing.parse(await request('GET', '/monitor/calls'));
17
+ }