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 CHANGED
@@ -1,3 +1,7 @@
1
+ # 0.5.1 — 2026-11-28
2
+
3
+ - Docs: README points AI assistants to the Nixflex AI rules; contact email dev@nixflex.com
4
+
1
5
  # K9 — 2026-11-11 (same unpublished candidate versions)
2
6
 
3
7
  - Added voice campaign deletion to Node, Python sync/async, CLI and the confirmed MCP delete_campaign tool (97 tools total).
@@ -1,118 +1,118 @@
1
- # K6 examples — Node 0.11.0 / Python 0.4.0 / MCP 0.5.0
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. The read-only smoke is separate.
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
- ## MCP — K6's five additions (current total: 96 with K7)
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. Existing 89 tools retain their original safeguards.
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/k6-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
+ # K6 examples — Node 0.11.0 / Python 0.4.0 / MCP 0.5.0
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. The read-only smoke is separate.
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
+ ## MCP — K6's five additions (current total: 96 with K7)
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. Existing 89 tools retain their original safeguards.
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/k6-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.
package/LICENSE CHANGED
@@ -1,9 +1,9 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 Nixflex Enterprises LLC
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
-
7
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
-
9
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Nixflex Enterprises LLC
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -1,4 +1,5 @@
1
1
  # Nixflex MCP — 0.5.0 candidate
2
+ > **Building with AI?** Tell your assistant to read https://docs.nixflex.com/ai-rules.md first - the rules for building on Nixflex (safe defaults, costs, what to ask before acting). Full docs: https://docs.nixflex.com
2
3
 
3
4
  B57 deletion and voice campaign delete: see [B57-DELETES.md](B57-DELETES.md). K9 is an unpublished candidate; one DELETE, never an automatic retry.
4
5
 
package/agent-reads.js CHANGED
@@ -1,26 +1,26 @@
1
- // GET-only adapter: the installed SDK drops status/search. Mutations stay on the SDK.
2
- import * as z from 'zod/v4';
3
- import { NixflexConnectionError, errorFromResponse } from 'nixflex';
4
- export const agentListSchema = z.object({
5
- limit: z.number().int().min(1).max(200).optional(),
6
- offset: z.number().int().min(0).max(1000000).optional(),
7
- status: z.enum(['active','disabled','all']).optional().describe('Default active; all includes disabled.'),
8
- search: z.string().max(200).regex(/^[^\u0000-\u001f\u007f]*$/).optional().describe('Literal case-insensitive name or ID substring.')
9
- });
10
- export function agentReads(apiKey, baseUrl = 'https://api.nixflex.com', fetcher = fetch) {
11
- return async function read(args = {}) {
12
- const values = agentListSchema.parse(args);
13
- const url = new URL(baseUrl.replace(/\/+$/, '') + '/v1/agents');
14
- for (const [key, value] of Object.entries(values)) if (value !== undefined) url.searchParams.set(key, String(value));
15
- let response, body;
16
- try {
17
- response = await fetcher(url.toString(), { method: 'GET', redirect: 'error', signal: AbortSignal.timeout(30000),
18
- headers: { Authorization: 'Bearer ' + apiKey, Accept: 'application/json' } });
19
- } catch { throw new NixflexConnectionError('Could not read agents.'); }
20
- try { body = await response.json(); } catch { throw new NixflexConnectionError('Invalid agent list response.'); }
21
- if (!response.ok) throw errorFromResponse(response.status, body, response.headers.get('x-railway-request-id') || undefined,
22
- Number(response.headers.get('retry-after')) || undefined);
23
- if (!Array.isArray(body)) throw new NixflexConnectionError('Invalid agent list response.');
24
- return body;
25
- };
26
- }
1
+ // GET-only adapter: the installed SDK drops status/search. Mutations stay on the SDK.
2
+ import * as z from 'zod/v4';
3
+ import { NixflexConnectionError, errorFromResponse } from 'nixflex';
4
+ export const agentListSchema = z.object({
5
+ limit: z.number().int().min(1).max(200).optional(),
6
+ offset: z.number().int().min(0).max(1000000).optional(),
7
+ status: z.enum(['active','disabled','all']).optional().describe('Default active; all includes disabled.'),
8
+ search: z.string().max(200).regex(/^[^\u0000-\u001f\u007f]*$/).optional().describe('Literal case-insensitive name or ID substring.')
9
+ });
10
+ export function agentReads(apiKey, baseUrl = 'https://api.nixflex.com', fetcher = fetch) {
11
+ return async function read(args = {}) {
12
+ const values = agentListSchema.parse(args);
13
+ const url = new URL(baseUrl.replace(/\/+$/, '') + '/v1/agents');
14
+ for (const [key, value] of Object.entries(values)) if (value !== undefined) url.searchParams.set(key, String(value));
15
+ let response, body;
16
+ try {
17
+ response = await fetcher(url.toString(), { method: 'GET', redirect: 'error', signal: AbortSignal.timeout(30000),
18
+ headers: { Authorization: 'Bearer ' + apiKey, Accept: 'application/json' } });
19
+ } catch { throw new NixflexConnectionError('Could not read agents.'); }
20
+ try { body = await response.json(); } catch { throw new NixflexConnectionError('Invalid agent list response.'); }
21
+ if (!response.ok) throw errorFromResponse(response.status, body, response.headers.get('x-railway-request-id') || undefined,
22
+ Number(response.headers.get('retry-after')) || undefined);
23
+ if (!Array.isArray(body)) throw new NixflexConnectionError('Invalid agent list response.');
24
+ return body;
25
+ };
26
+ }
package/agent-schema.js CHANGED
@@ -1,24 +1,24 @@
1
- import * as z from 'zod/v4';
2
- // Do not strip unknown keys: the engine must return its mixed-key warnings.
3
- const shape = {};
4
- for (const key of 'name system_prompt welcome_message language timezone llm_model fallback_message post_call_sms_template'.split(' ')) shape[key] = z.string().optional();
5
- for (const key of 'voice_id voice_key webhook_url phone_number transfer_number transfer_whisper boosted_keywords voicemail_message'.split(' ')) shape[key] = z.string().nullable().optional();
6
- for (const key of 'is_active ai_speaks_first dynamic_greeting func_end_call func_cold_transfer func_send_sms record_call post_call_sms_enabled incall_sms_enabled amd_enabled greet_by_name remember_callers require_booking_confirmation voicemail_leave_enabled'.split(' ')) shape[key] = z.boolean().optional();
7
- shape.temperature = z.number().min(0).max(0.7).optional();
8
- shape.response_eagerness = z.number().int().min(0).max(1000).optional();
9
- shape.stt_confidence = z.number().min(0).max(1).optional();
10
- shape.stt_max_silence_ms = z.number().int().min(0).max(2147483647).optional();
11
- shape.interruption_sensitivity = z.number().int().min(0).max(100).optional();
12
- for (const key of ['max_call_duration_seconds', 'silence_hangup_seconds']) shape[key] = z.number().int().min(1).max(2147483).nullable().optional();
13
- shape.wait_tag_seconds = z.number().int().min(30).max(120).nullable().optional();
14
- shape.ivr_timeout_seconds = z.number().int().min(1).max(1800).optional();
15
- shape.speaking_rate = z.union([z.number(), z.null(), z.literal('')]).optional();
16
- shape.voice_speed = z.number().min(0.01).max(100).optional();
17
- shape.pickup_delay = z.unknown().optional().describe('Legacy setting, unchanged in this release.');
18
- shape.dtmf_enabled = z.boolean().nullable().optional();
19
- shape.recording_source = z.string().nullable().optional().describe('provider/nixflex, case-normalized by the existing engine parser; null/empty clears to provider.');
20
- shape.response_length = z.enum(['short', 'medium', 'long']).optional();
21
- shape.transfer_type = z.enum(['cold', 'warm']).optional();
22
- shape.data_extraction_fields = z.array(z.object({ name: z.string(), type: z.enum(['text', 'selector', 'boolean', 'number']), description: z.string().optional(), optional: z.boolean().optional(), format_example: z.string().optional(), choices: z.array(z.string()).optional() }).passthrough()).max(50).optional();
23
- export const agentCreateFields = z.object(shape).passthrough().describe('Agent settings: temperature 0..0.7, SMS, voicemail, STT and extraction. Retention inherits the account default. The engine validates all values.');
24
- export const agentUpdateFields = agentCreateFields.extend({ call_retention_days: z.union([z.literal(90), z.literal(30), z.literal(7), z.literal(1), z.literal(0)]).optional() });
1
+ import * as z from 'zod/v4';
2
+ // Do not strip unknown keys: the engine must return its mixed-key warnings.
3
+ const shape = {};
4
+ for (const key of 'name system_prompt welcome_message language timezone llm_model fallback_message post_call_sms_template'.split(' ')) shape[key] = z.string().optional();
5
+ for (const key of 'voice_id voice_key webhook_url phone_number transfer_number transfer_whisper boosted_keywords voicemail_message'.split(' ')) shape[key] = z.string().nullable().optional();
6
+ for (const key of 'is_active ai_speaks_first dynamic_greeting func_end_call func_cold_transfer func_send_sms record_call post_call_sms_enabled incall_sms_enabled amd_enabled greet_by_name remember_callers require_booking_confirmation voicemail_leave_enabled'.split(' ')) shape[key] = z.boolean().optional();
7
+ shape.temperature = z.number().min(0).max(0.7).optional();
8
+ shape.response_eagerness = z.number().int().min(0).max(1000).optional();
9
+ shape.stt_confidence = z.number().min(0).max(1).optional();
10
+ shape.stt_max_silence_ms = z.number().int().min(0).max(2147483647).optional();
11
+ shape.interruption_sensitivity = z.number().int().min(0).max(100).optional();
12
+ for (const key of ['max_call_duration_seconds', 'silence_hangup_seconds']) shape[key] = z.number().int().min(1).max(2147483).nullable().optional();
13
+ shape.wait_tag_seconds = z.number().int().min(30).max(120).nullable().optional();
14
+ shape.ivr_timeout_seconds = z.number().int().min(1).max(1800).optional();
15
+ shape.speaking_rate = z.union([z.number(), z.null(), z.literal('')]).optional();
16
+ shape.voice_speed = z.number().min(0.01).max(100).optional();
17
+ shape.pickup_delay = z.unknown().optional().describe('Legacy setting, unchanged in this release.');
18
+ shape.dtmf_enabled = z.boolean().nullable().optional();
19
+ shape.recording_source = z.string().nullable().optional().describe('provider/nixflex, case-normalized by the existing engine parser; null/empty clears to provider.');
20
+ shape.response_length = z.enum(['short', 'medium', 'long']).optional();
21
+ shape.transfer_type = z.enum(['cold', 'warm']).optional();
22
+ shape.data_extraction_fields = z.array(z.object({ name: z.string(), type: z.enum(['text', 'selector', 'boolean', 'number']), description: z.string().optional(), optional: z.boolean().optional(), format_example: z.string().optional(), choices: z.array(z.string()).optional() }).passthrough()).max(50).optional();
23
+ export const agentCreateFields = z.object(shape).passthrough().describe('Agent settings: temperature 0..0.7, SMS, voicemail, STT and extraction. Retention inherits the account default. The engine validates all values.');
24
+ export const agentUpdateFields = agentCreateFields.extend({ call_retention_days: z.union([z.literal(90), z.literal(30), z.literal(7), z.literal(1), z.literal(0)]).optional() });
package/c6-output.js CHANGED
@@ -1,32 +1,32 @@
1
- const allowed = new Set(['ok','phone_number','agent_id','provider','is_active','deleted','web_calls_enabled',
2
- 'id','name','functions','method','timeout_ms','has_headers','is_set','api_key_set','webhook_url_set',
3
- 'post_call_url_set','in_call_url_set','pit_set','username','event_slug','default_timezone','location_id','tags','tool_name']);
4
- export function integrationOutput(value) {
5
- if (Array.isArray(value)) return value.map(integrationOutput);
6
- if (!value || typeof value !== 'object') return value;
7
- const result = { private_fields_omitted: true };
8
- for (const [key, item] of Object.entries(value)) {
9
- if (/(?:^|_)url(?:_2)?$/.test(key)) result[key] = item == null ? null : '[omitted: private URL]';
10
- else if (allowed.has(key)) result[key] = integrationOutput(item);
11
- }
12
- return result;
13
- }
14
- const codes = new Set(['invalid_filter','not_found','server_error','organisation_disabled','organisation_unavailable',
15
- 'unauthorized','invalid_api_key','forbidden','rate_limit_exceeded','owner_required','outcome_unknown','invalid_business_name']);
16
- export function privateError(error) {
17
- const unknown = error?.code === 'outcome_unknown';
18
- return { error: { code: codes.has(error?.code) ? error.code : 'request_failed',
19
- status: Number.isInteger(error?.status) && error.status >= 0 && error.status <= 599 ? error.status : 0,
20
- message: unknown ? 'Outcome unknown. Check current state before retrying.' : 'Request failed. Private error details omitted.',
21
- ...(unknown ? { outcome: 'unknown', safe_to_retry: false } : {}) } };
22
- }
23
- /** Approved success-output change only. Preserve errors, retries and all other fields. */
24
- export async function privateWebhookRead(action) {
25
- const value = await action();
26
- if (!value || typeof value !== 'object' || Array.isArray(value)) return value;
27
- const result = { ...value };
28
- for (const field of ['webhook_url', 'webhook_url_2']) {
29
- if (Object.hasOwn(result, field) && result[field] !== null) result[field] = '[omitted: private URL]';
30
- }
31
- return result;
32
- }
1
+ const allowed = new Set(['ok','phone_number','agent_id','provider','is_active','deleted','web_calls_enabled',
2
+ 'id','name','functions','method','timeout_ms','has_headers','is_set','api_key_set','webhook_url_set',
3
+ 'post_call_url_set','in_call_url_set','pit_set','username','event_slug','default_timezone','location_id','tags','tool_name']);
4
+ export function integrationOutput(value) {
5
+ if (Array.isArray(value)) return value.map(integrationOutput);
6
+ if (!value || typeof value !== 'object') return value;
7
+ const result = { private_fields_omitted: true };
8
+ for (const [key, item] of Object.entries(value)) {
9
+ if (/(?:^|_)url(?:_2)?$/.test(key)) result[key] = item == null ? null : '[omitted: private URL]';
10
+ else if (allowed.has(key)) result[key] = integrationOutput(item);
11
+ }
12
+ return result;
13
+ }
14
+ const codes = new Set(['invalid_filter','not_found','server_error','organisation_disabled','organisation_unavailable',
15
+ 'unauthorized','invalid_api_key','forbidden','rate_limit_exceeded','owner_required','outcome_unknown','invalid_business_name']);
16
+ export function privateError(error) {
17
+ const unknown = error?.code === 'outcome_unknown';
18
+ return { error: { code: codes.has(error?.code) ? error.code : 'request_failed',
19
+ status: Number.isInteger(error?.status) && error.status >= 0 && error.status <= 599 ? error.status : 0,
20
+ message: unknown ? 'Outcome unknown. Check current state before retrying.' : 'Request failed. Private error details omitted.',
21
+ ...(unknown ? { outcome: 'unknown', safe_to_retry: false } : {}) } };
22
+ }
23
+ /** Approved success-output change only. Preserve errors, retries and all other fields. */
24
+ export async function privateWebhookRead(action) {
25
+ const value = await action();
26
+ if (!value || typeof value !== 'object' || Array.isArray(value)) return value;
27
+ const result = { ...value };
28
+ for (const field of ['webhook_url', 'webhook_url_2']) {
29
+ if (Object.hasOwn(result, field) && result[field] !== null) result[field] = '[omitted: private URL]';
30
+ }
31
+ return result;
32
+ }
package/c6-tools.js CHANGED
@@ -1,35 +1,35 @@
1
- import * as z from 'zod/v4';
2
- import { executeTool } from './safe-tools.js';
3
- import { integrationOutput, privateError } from './c6-output.js';
4
-
5
- /** K4 scope approved by Fahim, 2 November 2026. */
6
- export function registerC6Tools(server, request) {
7
- const number = z.string().regex(/^\+[1-9]\d{6,14}$/);
8
- const identity = z.object({ phone_number: number });
9
- const agent = z.object({ agent_id: z.string().min(1).max(200) });
10
- const enc = encodeURIComponent;
11
- const add = (name, schema, description, read, fn, project = value => value) => server.registerTool(name, {
12
- title: name.replaceAll('_', ' '), description: description + (read ? ' Use only for information the user requests.' : " Use only for the user's explicitly requested change. Requires confirm:true before any request; never automatically repeat an uncertain change."),
13
- inputSchema: schema, annotations: { title: name.replaceAll('_', ' '), readOnlyHint: read, destructiveHint: !read, idempotentHint: read, openWorldHint: true },
14
- }, async args => {
15
- try {
16
- const { confirm, ...input } = args;
17
- const data = !read && confirm !== true ? { confirmation_required: true, sent: false, message: 'No request sent. Confirm only this intentional change.' } : project(await executeTool(name, fn, input));
18
- return { content: [{ type: 'text', text: JSON.stringify(data) }] };
19
- } catch (error) { return { isError: true, content: [{ type: 'text', text: JSON.stringify(privateError(error)) }] }; }
20
- });
21
- for (const [provider, name] of [['calcom','get_calcom'],['slack','get_slack'],['zapier','get_zapier'],['make','get_make'],['gohighlevel','get_gohighlevel'],['web-calls','get_number_web_calls'],['precall','get_number_precall']]) {
22
- add(name, identity, 'Read saved '+provider+' settings on an owned number. Credentials, private URLs and free-form configuration are omitted. Saved flags do not prove effective availability; a missing config may return 404.', true,
23
- ({ phone_number }) => request('GET', `/integrations/${provider}/number/${enc(phone_number)}`), integrationOutput);
24
- }
25
- add('get_agent_precall', agent, 'Read the saved agent pre-call default. Private URL omitted. A number override takes precedence.', true,
26
- ({ agent_id }) => request('GET', `/integrations/precall/agent/${enc(agent_id)}`), integrationOutput);
27
- add('list_custom_functions', identity, 'List at most 15 saved functions. No paging. Empty does not prove number ownership. URLs, private headers, schemas and free-form text are omitted.', true,
28
- ({ phone_number }) => request('GET', `/integrations/custom-functions/number/${enc(phone_number)}`), integrationOutput);
29
- add('list_organisation_activity_filtered', z.object({ before: z.string().regex(/^\d{1,18}$/).optional(), actor: z.uuid().optional(), from: z.iso.date().optional(), to: z.iso.date().optional() }),
30
- 'Read up to 50 activity events using inclusive UTC dates within retained history. Keep IDs and next_cursor as strings; pass next_cursor as before. API key has Owner authority. Full CSV export is SDK/CLI only.', true,
31
- query => request('GET', '/organisation/activity', undefined, query));
32
- add('rename_organisation', z.object({ name: z.string().min(2).max(100).regex(/^[^\u0000-\u001f\u007f]+$/), confirm: z.boolean().optional() }),
33
- 'Change only the business name. API key has Owner authority; no membership or ownership transfer.', false,
34
- body => request('PATCH', '/organisation/name', body));
35
- }
1
+ import * as z from 'zod/v4';
2
+ import { executeTool } from './safe-tools.js';
3
+ import { integrationOutput, privateError } from './c6-output.js';
4
+
5
+ /** K4 scope approved by Fahim, 2 November 2026. */
6
+ export function registerC6Tools(server, request) {
7
+ const number = z.string().regex(/^\+[1-9]\d{6,14}$/);
8
+ const identity = z.object({ phone_number: number });
9
+ const agent = z.object({ agent_id: z.string().min(1).max(200) });
10
+ const enc = encodeURIComponent;
11
+ const add = (name, schema, description, read, fn, project = value => value) => server.registerTool(name, {
12
+ title: name.replaceAll('_', ' '), description: description + (read ? ' Use only for information the user requests.' : " Use only for the user's explicitly requested change. Requires confirm:true before any request; never automatically repeat an uncertain change."),
13
+ inputSchema: schema, annotations: { title: name.replaceAll('_', ' '), readOnlyHint: read, destructiveHint: !read, idempotentHint: read, openWorldHint: true },
14
+ }, async args => {
15
+ try {
16
+ const { confirm, ...input } = args;
17
+ const data = !read && confirm !== true ? { confirmation_required: true, sent: false, message: 'No request sent. Confirm only this intentional change.' } : project(await executeTool(name, fn, input));
18
+ return { content: [{ type: 'text', text: JSON.stringify(data) }] };
19
+ } catch (error) { return { isError: true, content: [{ type: 'text', text: JSON.stringify(privateError(error)) }] }; }
20
+ });
21
+ for (const [provider, name] of [['calcom','get_calcom'],['slack','get_slack'],['zapier','get_zapier'],['make','get_make'],['gohighlevel','get_gohighlevel'],['web-calls','get_number_web_calls'],['precall','get_number_precall']]) {
22
+ add(name, identity, 'Read saved '+provider+' settings on an owned number. Credentials, private URLs and free-form configuration are omitted. Saved flags do not prove effective availability; a missing config may return 404.', true,
23
+ ({ phone_number }) => request('GET', `/integrations/${provider}/number/${enc(phone_number)}`), integrationOutput);
24
+ }
25
+ add('get_agent_precall', agent, 'Read the saved agent pre-call default. Private URL omitted. A number override takes precedence.', true,
26
+ ({ agent_id }) => request('GET', `/integrations/precall/agent/${enc(agent_id)}`), integrationOutput);
27
+ add('list_custom_functions', identity, 'List at most 15 saved functions. No paging. Empty does not prove number ownership. URLs, private headers, schemas and free-form text are omitted.', true,
28
+ ({ phone_number }) => request('GET', `/integrations/custom-functions/number/${enc(phone_number)}`), integrationOutput);
29
+ add('list_organisation_activity_filtered', z.object({ before: z.string().regex(/^\d{1,18}$/).optional(), actor: z.uuid().optional(), from: z.iso.date().optional(), to: z.iso.date().optional() }),
30
+ 'Read up to 50 activity events using inclusive UTC dates within retained history. Keep IDs and next_cursor as strings; pass next_cursor as before. API key has Owner authority. Full CSV export is SDK/CLI only.', true,
31
+ query => request('GET', '/organisation/activity', undefined, query));
32
+ add('rename_organisation', z.object({ name: z.string().min(2).max(100).regex(/^[^\u0000-\u001f\u007f]+$/), confirm: z.boolean().optional() }),
33
+ 'Change only the business name. API key has Owner authority; no membership or ownership transfer.', false,
34
+ body => request('PATCH', '/organisation/name', body));
35
+ }