conduyt-mcp 4.105.21 → 4.105.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/tool-annotations.js +2 -0
- package/dist/tools/advanced-filter-compilability.js +9 -0
- package/dist/tools/advanced-filter-rules.d.ts +1 -1
- package/dist/tools/advanced-filter-rules.js +4 -2
- package/dist/tools/automations.d.ts +1 -1
- package/dist/tools/automations.js +1 -1
- package/dist/tools/bulk.js +2 -2
- package/dist/tools/companies.js +6 -4
- package/dist/tools/contacts.js +9 -5
- package/dist/tools/custom-fields.js +35 -7
- package/dist/tools/deal-profile.d.ts +1 -0
- package/dist/tools/deal-profile.js +19 -8
- package/dist/tools/deals.js +11 -5
- package/dist/tools/formula-fields.d.ts +62 -0
- package/dist/tools/formula-fields.js +104 -0
- package/dist/tools/lead-pool.js +4 -2
- package/dist/tools/lender-options.d.ts +11 -0
- package/dist/tools/lender-options.js +11 -0
- package/dist/tools/saved-filters.js +4 -2
- package/dist/tools/smart-lists.js +4 -2
- package/dist/tools/user-fields-doc.d.ts +5 -0
- package/dist/tools/user-fields-doc.js +6 -0
- package/package.json +1 -1
- package/scripts/coverage-matrix.json +12 -5
package/dist/tool-annotations.js
CHANGED
|
@@ -16,6 +16,7 @@ export const TOOL_ANNOTATIONS = {
|
|
|
16
16
|
conduyt_mcp_coverage: ro("Get MCP Coverage Matrix"),
|
|
17
17
|
conduyt_list_contacts: ro("List Contacts"),
|
|
18
18
|
conduyt_count_contacts: ro("Count Contacts"),
|
|
19
|
+
conduyt_list_contact_timezones: ro("List Contact Time Zones"),
|
|
19
20
|
conduyt_get_contact: ro("Get Contact"),
|
|
20
21
|
conduyt_create_contact: create("Create Contact"),
|
|
21
22
|
conduyt_update_contact: update("Update Contact"),
|
|
@@ -243,6 +244,7 @@ export const TOOL_ANNOTATIONS = {
|
|
|
243
244
|
conduyt_update_team_chat_settings: update("Update Team Chat Settings"),
|
|
244
245
|
conduyt_list_custom_fields: ro("List Custom Fields"),
|
|
245
246
|
conduyt_create_custom_field: create("Create Custom Field"),
|
|
247
|
+
conduyt_create_mirror_field: create("Create Deal Mirror Field"),
|
|
246
248
|
conduyt_update_custom_field: update("Update Custom Field"),
|
|
247
249
|
conduyt_delete_custom_field: destroy("Delete Custom Field"),
|
|
248
250
|
conduyt_get_contact_table_defaults: ro("Get Contact Table Defaults"),
|
|
@@ -63,6 +63,15 @@ export function advancedRuleCompiles(rule) {
|
|
|
63
63
|
return true;
|
|
64
64
|
return operator === "equals" || operator === "not_equals";
|
|
65
65
|
}
|
|
66
|
+
// (#1312) timezoneRuleToWhere: the two absence operators need no value; every other operator needs at least one value
|
|
67
|
+
if (field === "timezone") {
|
|
68
|
+
if (operator === "is_empty" || operator === "is_not_empty")
|
|
69
|
+
return true;
|
|
70
|
+
const zones = (Array.isArray(value) ? value : String(value ?? "").split(",")).map((v) => String(v).trim()).filter(Boolean);
|
|
71
|
+
if (zones.length === 0)
|
|
72
|
+
return false;
|
|
73
|
+
return rawOp === "is_any_of" || rawOp === "is_none_of" || operator === "equals" || operator === "not_equals";
|
|
74
|
+
}
|
|
66
75
|
if (rawOp === "is_any_of") {
|
|
67
76
|
const values = Array.isArray(value) ? value : String(value ?? "").split(",").map((v) => v.trim()).filter(Boolean);
|
|
68
77
|
return values.length > 0 && LIST_FIELDS.has(field);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* PORTED VERBATIM from conduyt-app lib/smart-view-filters.ts @ slice B r28 (bfba9b0ef + the non-string array element refusal; the app's validator additionally compiles every rule — see validateAdvancedFiltersEffective below) — validateAdvancedFilters, its tables and its
|
|
2
|
+
* PORTED VERBATIM from conduyt-app lib/smart-view-filters.ts @ slice B r28 (+ #1312 the timezone field, parity32) (bfba9b0ef + the non-string array element refusal; the app's validator additionally compiles every rule — see validateAdvancedFiltersEffective below) — validateAdvancedFilters, its tables and its
|
|
3
3
|
* value rules — so a call this surface accepts is never a predictable 400 from the API (Codex mcp r2 m1 / cli r2 m1).
|
|
4
4
|
* Keep in sync with the app: when validateAdvancedFilters, VALID_FIELDS, VALID_OPERATORS, ADVANCED_OPERATORS,
|
|
5
5
|
* CF_OPERATORS, VALUELESS_OPERATORS, DATE_FILTER_FIELDS or isSupportedCallAttemptsFilter change there, re-port here.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* PORTED VERBATIM from conduyt-app lib/smart-view-filters.ts @ slice B r28 (bfba9b0ef + the non-string array element refusal; the app's validator additionally compiles every rule — see validateAdvancedFiltersEffective below) — validateAdvancedFilters, its tables and its
|
|
2
|
+
* PORTED VERBATIM from conduyt-app lib/smart-view-filters.ts @ slice B r28 (+ #1312 the timezone field, parity32) (bfba9b0ef + the non-string array element refusal; the app's validator additionally compiles every rule — see validateAdvancedFiltersEffective below) — validateAdvancedFilters, its tables and its
|
|
3
3
|
* value rules — so a call this surface accepts is never a predictable 400 from the API (Codex mcp r2 m1 / cli r2 m1).
|
|
4
4
|
* Keep in sync with the app: when validateAdvancedFilters, VALID_FIELDS, VALID_OPERATORS, ADVANCED_OPERATORS,
|
|
5
5
|
* CF_OPERATORS, VALUELESS_OPERATORS, DATE_FILTER_FIELDS or isSupportedCallAttemptsFilter change there, re-port here.
|
|
@@ -13,7 +13,7 @@ export const VALID_FIELDS = new Set([
|
|
|
13
13
|
"city", "state", "country", "jobTitle", "optedOutSms", "optedOutEmail",
|
|
14
14
|
"leadScore", "email", "phone", "source", "assignedTo", "tags",
|
|
15
15
|
"pipeline", "pipelineStage", "dealStatus", "company",
|
|
16
|
-
"masterStatus",
|
|
16
|
+
"masterStatus", "timezone",
|
|
17
17
|
]);
|
|
18
18
|
const VALID_OPERATORS = {
|
|
19
19
|
lastContactedAt: new Set(["within", "not_within", "is_empty", "is_not_empty"]),
|
|
@@ -37,6 +37,7 @@ const VALID_OPERATORS = {
|
|
|
37
37
|
pipelineStage: new Set(["equals", "not_equals", "is_empty", "is_not_empty"]),
|
|
38
38
|
dealStatus: new Set(["equals", "not_equals", "is_empty", "is_not_empty"]),
|
|
39
39
|
masterStatus: new Set(["equals", "not_equals", "is_any_of", "is_none_of"]),
|
|
40
|
+
timezone: new Set(["equals", "not_equals", "is_any_of", "is_none_of", "is_empty", "is_not_empty"]),
|
|
40
41
|
city: new Set(["equals", "not_equals", "contains", "is_empty", "is_not_empty"]),
|
|
41
42
|
state: new Set(["equals", "not_equals", "contains", "is_empty", "is_not_empty"]),
|
|
42
43
|
country: new Set(["equals", "not_equals"]),
|
|
@@ -67,6 +68,7 @@ export const ADVANCED_OPERATORS = {
|
|
|
67
68
|
pipelineStage: new Set([...VALID_OPERATORS.pipelineStage, "is", "is_not", "is_empty", "is_not_empty", "is_any_of"]),
|
|
68
69
|
dealStatus: new Set([...VALID_OPERATORS.dealStatus, "is", "is_not", "is_empty", "is_not_empty", "is_any_of"]),
|
|
69
70
|
masterStatus: new Set([...VALID_OPERATORS.masterStatus, "is", "is_not"]),
|
|
71
|
+
timezone: new Set([...VALID_OPERATORS.timezone, "is", "is_not"]),
|
|
70
72
|
city: new Set([...VALID_OPERATORS.city, "is", "is_not", "is_any_of"]),
|
|
71
73
|
state: new Set([...VALID_OPERATORS.state, "is", "is_not", "is_any_of"]),
|
|
72
74
|
country: new Set([...VALID_OPERATORS.country, "is", "is_not", "is_any_of"]),
|
|
@@ -5,7 +5,7 @@ export declare const CARD_OWNERSHIP_ACTIONS_NOTE = " Card ownership per lane: as
|
|
|
5
5
|
/** (deal nodes, app 10-13) find_opportunity v2, link_appointment_to_deal, update_deal_field systemField source; the catalog does not carry action config */
|
|
6
6
|
export declare const DEAL_NODES_ACTIONS_NOTE = " Deal nodes: find_opportunity config {version: 2, pipelineIds (ordered; the first pipeline holding a match wins; empty = every pipeline), status (open default | won | lost | abandoned | any), excludeSources (lead sources never matched, case-insensitive), excludeCreatedByAutomationIds (automations whose create_deal cards are skipped; cards created from 2026-10-13 on), matchField {fieldKey, value} (searches the WHOLE WORKSPACE, any contact, for the card whose deal custom field equals the value, merge fields allowed e.g. {{trigger.oes}}; a card is found when its field holds the searched value (trimmed) as the same text exactly (no case folding); a value written with separators such as dashes or spaces also matches its digits as text; it matches a stored number only when the value (or those digits) is a plain number with no leading zero and at most 15 significant digits that a number holds exactly (007 is text and does not match the number 7; a 16-digit value, 1e-400 or 3e-324 is text only); booleans and differently formatted stored values never match; status, pipelines and exclusions still apply; exactly one match is found, several are ambiguous and take not found; a found card becomes the run's contact when the run has none; the field must exist; an empty rendered value finds nothing), resolution}: searches the run's contact's cards; FOUND makes the card the run's deal and follows nextIfTrue (else next), NOT FOUND is a normal outcome that follows nextIfFalse (else next) and leaves the run's existing deal unchanged (a later deal step on the false branch still acts on the deal the run already had); without version 2 the step keeps the original single-pipeline lookup (a miss fails the step). Prerequisite: a version 2 find needs step cursors on this workspace, and publishing refuses (find_needs_step_cursors) with \"Find opportunity needs step cursors on this workspace; ask support\"; every version 2 find must hold its own live step cursor or it hard-stops the run without selecting or routing. A version 2 find cannot be retried on its own: retrying a failed one alone answers 409, so re-trigger the automation for the contact. An automation definition that touches deals needs the `deals` scope on an API key: without it the write answers 403. link_appointment_to_deal config {stageId, pipelineId (needs stageId), lostReason}: in an appointment-triggered run, links the trigger's appointment to the run's deal (its appointment fields follow it; a newer booking is never displaced; the appointment must be the deal's contact's), then optionally moves the card; it needs an appointment trigger and the run's deal (find_opportunity first, or a booking made with a deal id). update_deal_field config {systemField: \"source\", value, overwriteExisting}: sets the deal's own lead source instead of a custom field (a value only, trimmed, at most 500 characters; overwriteExisting false writes only while the source is the Unknown label).";
|
|
7
7
|
/** (#124, automation unknown keys / types) the refusal codes the write paths answer; surfaced verbatim by the client (details JSON object last), never retried */
|
|
8
|
-
export declare const AUTOMATION_KEY_REFUSALS_NOTE = " Unknown action keys are refused, never ignored: an action config key the action does not read (a typo such as `laneSoruce`) answers code `unknown_action_config_key` with the node, the key and, when one is close, a suggestion (\"Did you mean `laneSource`?\"); an action `type` no registry entry defines answers `unknown_action_type` (with 'Did you mean' when a registered type is close). Create and update answer 400 (an update that does not write `actions` is never refused for a key stored earlier), conduyt_workflow_validate answers 200 with valid false and the `errors` list (nodeId, field, code, message), and publish / a version restore answer 422 (the preflight refusal wraps `data.message`, `data.errors`, `data.warnings`). Read the suggestion, fix the key and send again; a stored workflow is never refused on read.";
|
|
8
|
+
export declare const AUTOMATION_KEY_REFUSALS_NOTE = " Unknown action keys are refused, never ignored: an action config key the action does not read (a typo such as `laneSoruce`) answers code `unknown_action_config_key` with the node, the key and, when one is close, a suggestion (\"Did you mean `laneSource`?\"); an action `type` no registry entry defines answers `unknown_action_type` (with 'Did you mean' when a registered type is close). Create and update answer 400 (an update that does not write `actions` is never refused for a key stored earlier), conduyt_workflow_validate answers 200 with valid false and the `errors` list (nodeId, field, code, message), and publish / a version restore answer 422 (the preflight refusal wraps `data.message`, `data.errors`, `data.warnings`). Read the suggestion, fix the key and send again; a stored workflow is never refused on read. A trigger condition or trigger node naming a deal MIRROR key (deal.customFields.<key>) answers 422 mirror_not_triggerable (#1292): trigger on the source field's own change (Contact Updated / Company Updated).";
|
|
9
9
|
/** GET /automations/:id answers { data: { ...automation, configRevision } } (jsonResponse wraps): the revision lives under `data` */
|
|
10
10
|
export declare function configRevisionOf(raw: unknown): number | undefined;
|
|
11
11
|
export declare function registerAutomationTools(server: McpServer, client: ConduytClient): void;
|
|
@@ -5,7 +5,7 @@ export const CARD_OWNERSHIP_ACTIONS_NOTE = " Card ownership per lane: assign_to_
|
|
|
5
5
|
/** (deal nodes, app 10-13) find_opportunity v2, link_appointment_to_deal, update_deal_field systemField source; the catalog does not carry action config */
|
|
6
6
|
export const DEAL_NODES_ACTIONS_NOTE = " Deal nodes: find_opportunity config {version: 2, pipelineIds (ordered; the first pipeline holding a match wins; empty = every pipeline), status (open default | won | lost | abandoned | any), excludeSources (lead sources never matched, case-insensitive), excludeCreatedByAutomationIds (automations whose create_deal cards are skipped; cards created from 2026-10-13 on), matchField {fieldKey, value} (searches the WHOLE WORKSPACE, any contact, for the card whose deal custom field equals the value, merge fields allowed e.g. {{trigger.oes}}; a card is found when its field holds the searched value (trimmed) as the same text exactly (no case folding); a value written with separators such as dashes or spaces also matches its digits as text; it matches a stored number only when the value (or those digits) is a plain number with no leading zero and at most 15 significant digits that a number holds exactly (007 is text and does not match the number 7; a 16-digit value, 1e-400 or 3e-324 is text only); booleans and differently formatted stored values never match; status, pipelines and exclusions still apply; exactly one match is found, several are ambiguous and take not found; a found card becomes the run's contact when the run has none; the field must exist; an empty rendered value finds nothing), resolution}: searches the run's contact's cards; FOUND makes the card the run's deal and follows nextIfTrue (else next), NOT FOUND is a normal outcome that follows nextIfFalse (else next) and leaves the run's existing deal unchanged (a later deal step on the false branch still acts on the deal the run already had); without version 2 the step keeps the original single-pipeline lookup (a miss fails the step). Prerequisite: a version 2 find needs step cursors on this workspace, and publishing refuses (find_needs_step_cursors) with \"Find opportunity needs step cursors on this workspace; ask support\"; every version 2 find must hold its own live step cursor or it hard-stops the run without selecting or routing. A version 2 find cannot be retried on its own: retrying a failed one alone answers 409, so re-trigger the automation for the contact. An automation definition that touches deals needs the `deals` scope on an API key: without it the write answers 403. link_appointment_to_deal config {stageId, pipelineId (needs stageId), lostReason}: in an appointment-triggered run, links the trigger's appointment to the run's deal (its appointment fields follow it; a newer booking is never displaced; the appointment must be the deal's contact's), then optionally moves the card; it needs an appointment trigger and the run's deal (find_opportunity first, or a booking made with a deal id). update_deal_field config {systemField: \"source\", value, overwriteExisting}: sets the deal's own lead source instead of a custom field (a value only, trimmed, at most 500 characters; overwriteExisting false writes only while the source is the Unknown label).";
|
|
7
7
|
/** (#124, automation unknown keys / types) the refusal codes the write paths answer; surfaced verbatim by the client (details JSON object last), never retried */
|
|
8
|
-
export const AUTOMATION_KEY_REFUSALS_NOTE = " Unknown action keys are refused, never ignored: an action config key the action does not read (a typo such as `laneSoruce`) answers code `unknown_action_config_key` with the node, the key and, when one is close, a suggestion (\"Did you mean `laneSource`?\"); an action `type` no registry entry defines answers `unknown_action_type` (with 'Did you mean' when a registered type is close). Create and update answer 400 (an update that does not write `actions` is never refused for a key stored earlier), conduyt_workflow_validate answers 200 with valid false and the `errors` list (nodeId, field, code, message), and publish / a version restore answer 422 (the preflight refusal wraps `data.message`, `data.errors`, `data.warnings`). Read the suggestion, fix the key and send again; a stored workflow is never refused on read.";
|
|
8
|
+
export const AUTOMATION_KEY_REFUSALS_NOTE = " Unknown action keys are refused, never ignored: an action config key the action does not read (a typo such as `laneSoruce`) answers code `unknown_action_config_key` with the node, the key and, when one is close, a suggestion (\"Did you mean `laneSource`?\"); an action `type` no registry entry defines answers `unknown_action_type` (with 'Did you mean' when a registered type is close). Create and update answer 400 (an update that does not write `actions` is never refused for a key stored earlier), conduyt_workflow_validate answers 200 with valid false and the `errors` list (nodeId, field, code, message), and publish / a version restore answer 422 (the preflight refusal wraps `data.message`, `data.errors`, `data.warnings`). Read the suggestion, fix the key and send again; a stored workflow is never refused on read. A trigger condition or trigger node naming a deal MIRROR key (deal.customFields.<key>) answers 422 mirror_not_triggerable (#1292): trigger on the source field's own change (Contact Updated / Company Updated).";
|
|
9
9
|
/** GET /automations/:id answers { data: { ...automation, configRevision } } (jsonResponse wraps): the revision lives under `data` */
|
|
10
10
|
export function configRevisionOf(raw) {
|
|
11
11
|
const row = raw && typeof raw === "object" && "data" in raw ? raw.data : raw;
|
package/dist/tools/bulk.js
CHANGED
|
@@ -25,7 +25,7 @@ export function registerBulkTools(server, client) {
|
|
|
25
25
|
const result = await client.post("/api/v1/contacts/ai-import", { contacts, options });
|
|
26
26
|
return formatResult(result);
|
|
27
27
|
});
|
|
28
|
-
server.tool("conduyt_export_contacts", "Export contacts as JSON with filtering. Returns all matching contacts with tags and custom fields.", {
|
|
28
|
+
server.tool("conduyt_export_contacts", "Export contacts as JSON with filtering. Returns all matching contacts with tags and custom fields. min_score that is not an integer 0..2147483647 is 400 invalid_min_score { message, param, accepted } (GET /contacts, /contacts/count and /contacts/export).", {
|
|
29
29
|
format: z.enum(["json"]).optional().describe("Export format (use 'json' for MCP)"),
|
|
30
30
|
search: z.string().optional().describe("Search filter"),
|
|
31
31
|
tag: z.string().optional().describe("Filter by tag name"),
|
|
@@ -64,7 +64,7 @@ export function registerBulkTools(server, client) {
|
|
|
64
64
|
});
|
|
65
65
|
return formatResult(result);
|
|
66
66
|
});
|
|
67
|
-
server.tool("conduyt_export_deals", "Export deals as JSON with filtering by status, pipeline, or search term.", {
|
|
67
|
+
server.tool("conduyt_export_deals", "Export deals as JSON with filtering by status, pipeline, or search term. The deal value bounds are judged too: value_min / minValue and value_max / maxValue that are non-numeric or outside the deal value column range (-9999999999.99..9999999999.99) are 400 invalid_value_min / invalid_value_max { message, param, accepted } (absent or empty = no filter; an alias spelling answers the same code with the sent spelling in param).", {
|
|
68
68
|
search: z.string().optional().describe("Search deal titles"),
|
|
69
69
|
status: z.string().optional().describe("Filter by status (open, won, lost)"),
|
|
70
70
|
pipeline: z.string().optional().describe("Filter by pipeline UUID"),
|
package/dist/tools/companies.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
import { USER_FIELD_READ_DOC, USER_FIELD_RECORD_WRITE_DOC } from "./user-fields-doc.js";
|
|
2
3
|
import { formatResult } from "../client.js";
|
|
4
|
+
import { FORMULA_WRITE_NOTE } from "./formula-fields.js";
|
|
3
5
|
export function registerCompanyTools(server, client) {
|
|
4
|
-
server.tool("conduyt_list_companies", "List and search companies. Returns name, domain, industry, contact count, deal count, and total deal value. `count_mode: \"none\"` skips the total count (a picker that only lists names): meta.total is then null and meta.has_more says whether another page exists.", {
|
|
6
|
+
server.tool("conduyt_list_companies", "List and search companies. Returns name, domain, industry, contact count, deal count, and total deal value. `count_mode: \"none\"` skips the total count (a picker that only lists names): meta.total is then null and meta.has_more says whether another page exists. The API judges sort and order (batch32): an unknown sort field, or an order other than asc / desc, is 400 sort_invalid { message, param, accepted } (the sent spelling in param) and is never silently replaced by the default order.", {
|
|
5
7
|
search: z.string().optional().describe("Search by company name, domain, or phone"),
|
|
6
8
|
industry: z.string().optional().describe("Filter by industry"),
|
|
7
9
|
size: z.enum(["1-10", "11-50", "51-200", "201-500", "501-1000", "1001+"]).optional().describe("Filter by company size"),
|
|
@@ -31,7 +33,7 @@ export function registerCompanyTools(server, client) {
|
|
|
31
33
|
const result = await client.get(`/api/v1/companies?${params}`);
|
|
32
34
|
return formatResult(result);
|
|
33
35
|
});
|
|
34
|
-
server.tool("conduyt_get_company", "Get a single company with full details and aggregated deal value. Carries the FIRST page of each related list: contacts (100, total contactCount, contactsNextCursor), deals (50, dealsNextCursor) and child accounts (childCompanies, 25, total childCount, childNextCursor). A non-null next cursor means more rows: read them with conduyt_list_company_related.", {
|
|
36
|
+
server.tool("conduyt_get_company", "Get a single company with full details and aggregated deal value. Carries the FIRST page of each related list: contacts (100, total contactCount, contactsNextCursor), deals (50, dealsNextCursor) and child accounts (childCompanies, 25, total childCount, childNextCursor). A non-null next cursor means more rows: read them with conduyt_list_company_related." + " " + USER_FIELD_READ_DOC, {
|
|
35
37
|
id: z.string().describe("Company UUID"),
|
|
36
38
|
}, async ({ id }) => {
|
|
37
39
|
const result = await client.get(`/api/v1/companies/${id}`);
|
|
@@ -49,7 +51,7 @@ export function registerCompanyTools(server, client) {
|
|
|
49
51
|
const result = await client.get(`/api/v1/companies/${encodeURIComponent(company_id)}/related?${params}`);
|
|
50
52
|
return formatResult(result);
|
|
51
53
|
});
|
|
52
|
-
server.tool("conduyt_create_company", "Create a new company record with business details.", {
|
|
54
|
+
server.tool("conduyt_create_company", "Create a new company record with business details." + " " + FORMULA_WRITE_NOTE + " " + USER_FIELD_RECORD_WRITE_DOC, {
|
|
53
55
|
name: z.string().describe("Company name (required)"),
|
|
54
56
|
domain: z.string().optional().describe("Company domain (e.g. 'acme.com')"),
|
|
55
57
|
industry: z.string().optional().describe("Industry (e.g. 'Technology', 'Healthcare')"),
|
|
@@ -66,7 +68,7 @@ export function registerCompanyTools(server, client) {
|
|
|
66
68
|
const result = await client.post("/api/v1/companies", params);
|
|
67
69
|
return formatResult(result);
|
|
68
70
|
});
|
|
69
|
-
server.tool("conduyt_update_company", "Update a company's details — name, domain, industry, address, or any other field.", {
|
|
71
|
+
server.tool("conduyt_update_company", "Update a company's details — name, domain, industry, address, or any other field." + " " + FORMULA_WRITE_NOTE + " " + USER_FIELD_RECORD_WRITE_DOC, {
|
|
70
72
|
id: z.string().describe("Company UUID"),
|
|
71
73
|
name: z.string().optional().describe("Updated company name"),
|
|
72
74
|
domain: z.string().optional().describe("Updated domain"),
|
package/dist/tools/contacts.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
import { USER_FIELD_READ_DOC, USER_FIELD_RECORD_WRITE_DOC } from "./user-fields-doc.js";
|
|
3
|
+
import { OFF_LIST_NOTE, TIMEZONE_FILTER_NOTE } from "./lender-options.js";
|
|
2
4
|
import { formatResult, formatToolError } from "../client.js";
|
|
5
|
+
import { FORMULA_FILTER_NOTE, FORMULA_WRITE_NOTE } from "./formula-fields.js";
|
|
3
6
|
import { strictInput } from "./strict.js";
|
|
4
7
|
/** The contact save revision pin (catalog bounds: integer 0..2147483647). */
|
|
5
8
|
/** Create-from-call rule: the server derives the lead's source ("Inbound Call") and its owner (the rep who took the call), so a
|
|
@@ -138,7 +141,7 @@ export function registerContactTools(server, client) {
|
|
|
138
141
|
params.set(`cf[${key}]`, value);
|
|
139
142
|
return params;
|
|
140
143
|
};
|
|
141
|
-
server.tool("conduyt_list_contacts", "List and search contacts with filtering. To find the contact(s) holding a known email address, pass `email` (exact match on the primary or any secondary email); `search` is a substring search. To list the contacts carrying a tag (or any of several tags), pass `tagId` (uuid) or `tag` (name). Returns paginated results with name, email, phone, tags, source, and assignee. Each row carries `revision` (integer save revision; pass it back as expectedRevision on conduyt_update_contact or the collaborator tools). " + LIST_TOTAL_NOTE, {
|
|
144
|
+
server.tool("conduyt_list_contacts", "List and search contacts with filtering. To find the contact(s) holding a known email address, pass `email` (exact match on the primary or any secondary email); `search` is a substring search. To list the contacts carrying a tag (or any of several tags), pass `tagId` (uuid) or `tag` (name). Returns paginated results with name, email, phone, tags, source, and assignee. Each row carries `revision` (integer save revision; pass it back as expectedRevision on conduyt_update_contact or the collaborator tools). " + LIST_TOTAL_NOTE + " " + FORMULA_FILTER_NOTE + " " + TIMEZONE_FILTER_NOTE + " The API judges sort and order (batch32): an unknown sort field, or an order other than asc / desc, is 400 sort_invalid { message, param, accepted } (the sent spelling in param) and is never silently replaced by the default order. min_score that is not an integer 0..2147483647 is 400 invalid_min_score { message, param, accepted } (GET /contacts, /contacts/count and /contacts/export).", {
|
|
142
145
|
...contactFilterShape,
|
|
143
146
|
// list-only filters (GET /contacts reads them; GET /contacts/count does not)
|
|
144
147
|
dealContextOwners: z.string().optional().describe("Deal-context filter: comma-separated owner ids (query param `deal_context_owners`; list only, the count route does not read it)"),
|
|
@@ -161,18 +164,19 @@ export function registerContactTools(server, client) {
|
|
|
161
164
|
const result = await client.get(`/api/v1/contacts?${params}`);
|
|
162
165
|
return formatResult(result);
|
|
163
166
|
});
|
|
164
|
-
server.tool("conduyt_count_contacts", "Count the contacts a list filter matches (GET /contacts/count): the exact total when conduyt_list_contacts answers `meta.total: null` with `meta.total_deferred: true`. Takes the SHARED subset of conduyt_list_contacts filters (no page, per_page or sort, and NOT dealContextOwners / dealContextStages / dealContextStatuses, which exist only on the list): with a deal-context filter the exact total is not available here (dropping it counts a broader set), so page the list with has_more instead. Answers `{ total, age_ms?, total_capped?, pending?, timed_out? }`: a cached list (the unfiltered list, or a Smart View alone) answers its cached exact count while under a minute old (`age_ms`), else recounts; `total: null` with `pending: true` = another request is recounting and nothing is cached yet, ask again in a few seconds; `total: null` with `timed_out: true` = the count could not finish within 30 s (narrow the filter); a `search` counts up to 10,000 (`total_capped: true` = more match). Use the total as `expectedTotal` for conduyt_bulk_delete_contacts_matching or conduyt_create_batch_operation.", contactFilterShape, async (filter) => {
|
|
167
|
+
server.tool("conduyt_count_contacts", "Count the contacts a list filter matches (GET /contacts/count): the exact total when conduyt_list_contacts answers `meta.total: null` with `meta.total_deferred: true`. Takes the SHARED subset of conduyt_list_contacts filters (no page, per_page or sort, and NOT dealContextOwners / dealContextStages / dealContextStatuses, which exist only on the list): with a deal-context filter the exact total is not available here (dropping it counts a broader set), so page the list with has_more instead. Answers `{ total, age_ms?, total_capped?, pending?, timed_out? }`: a cached list (the unfiltered list, or a Smart View alone) answers its cached exact count while under a minute old (`age_ms`), else recounts; `total: null` with `pending: true` = another request is recounting and nothing is cached yet, ask again in a few seconds; `total: null` with `timed_out: true` = the count could not finish within 30 s (narrow the filter); a `search` counts up to 10,000 (`total_capped: true` = more match). Use the total as `expectedTotal` for conduyt_bulk_delete_contacts_matching or conduyt_create_batch_operation." + " " + FORMULA_FILTER_NOTE + " " + TIMEZONE_FILTER_NOTE + " min_score that is not an integer 0..2147483647 is 400 invalid_min_score { message, param, accepted } (GET /contacts, /contacts/count and /contacts/export).", contactFilterShape, async (filter) => {
|
|
165
168
|
const params = contactFilterParams(filter);
|
|
166
169
|
const result = await client.get(`/api/v1/contacts/count?${params}`);
|
|
167
170
|
return formatResult(result);
|
|
168
171
|
});
|
|
169
|
-
server.tool("
|
|
172
|
+
server.tool("conduyt_list_contact_timezones", "List the workspace's DISTINCT contact time zones with counts (GET /contacts/timezones, contacts:view): { data: { timezones: [{ timezone, count }], truncated } }. These are the options of the Time zone filter in Advanced Filters (field `timezone`, the contact's IANA string such as America/Chicago; a contact with no zone is never listed). Scoped to the contacts the caller can see (a member limited to their own leads sees only the zones on those), ordered by zone, at most 200 zones (truncated: true says a longer list was cut) and cached for a few minutes per workspace and visibility scope, so a new zone can take a moment to appear. The web builder labels the common US zones (Eastern, Central, Mountain, Pacific, Arizona, Alaska, Hawaii) and shows every other zone as its IANA string; the value to filter on is always the IANA string. " + TIMEZONE_FILTER_NOTE, {}, async () => formatResult(await client.get("/api/v1/contacts/timezones")));
|
|
173
|
+
server.tool("conduyt_get_contact", "Get a single contact with full details — profile, tags, custom fields, timeline, deals, and activity history. Includes `revision` (integer save revision): pass it as expectedRevision on conduyt_update_contact or the collaborator tools so a newer change is never overwritten. Includes `hasOutboundSms` (boolean): true when this workspace has ever PROVABLY texted the contact (a proven send only: not a draft, a queued row or a pre-send failure); use it to pick the `context` for conduyt_check_message (false = 'first', true = 'conversation'). Also includes `hasOutboundEmail` (boolean): the same for email (true when at least one outbound email to the contact was proven sent, so a genuine \"Re:\" reply is a conversation and not flagged); use it to pick the `context` for an email check. Also includes `duplicateProposals` (the open and not-sure possible-duplicate lines on this record, each naming the other record as far as your key may see it) and `heldIdentifiers` (emails or phones held from this record because another record owns them, value-free), each the FIRST page only, with duplicateProposalsTotal, duplicateProposalsNextCursor, duplicateProposalsMembershipRevision, heldIdentifiersTotal, heldIdentifiersNextCursor and heldIdentifiersMembershipRevision (page on with conduyt_list_duplicate_proposals, passing the next cursors as cursor / held_cursor); list or decide them with conduyt_list_duplicate_proposals / conduyt_decide_duplicate_proposal." + " " + USER_FIELD_READ_DOC, {
|
|
170
174
|
id: z.string().describe("Contact UUID"),
|
|
171
175
|
}, async ({ id }) => {
|
|
172
176
|
const result = await client.get(`/api/v1/contacts/${id}`);
|
|
173
177
|
return formatResult(result);
|
|
174
178
|
});
|
|
175
|
-
const createContactTool = server.tool("conduyt_create_contact", "Create a new contact in the CRM. Email or phone is recommended but not strictly required. With callId (a lead made from a contact-less inbound call) you must NOT send source or assignedTo: the server derives both from the call, and the request is refused if either is present." + INVALID_NUMBER_REFUSALS + " " + IDENTITY_CREATE_ANSWERS, {
|
|
179
|
+
const createContactTool = server.tool("conduyt_create_contact", "Create a new contact in the CRM. Email or phone is recommended but not strictly required. With callId (a lead made from a contact-less inbound call) you must NOT send source or assignedTo: the server derives both from the call, and the request is refused if either is present." + INVALID_NUMBER_REFUSALS + " " + IDENTITY_CREATE_ANSWERS + " " + FORMULA_WRITE_NOTE + " " + OFF_LIST_NOTE + " " + USER_FIELD_RECORD_WRITE_DOC, {
|
|
176
180
|
email: z.string().optional().describe("Contact email address"),
|
|
177
181
|
firstName: z.string().optional().describe("First name"),
|
|
178
182
|
lastName: z.string().optional().describe("Last name"),
|
|
@@ -202,7 +206,7 @@ export function registerContactTools(server, client) {
|
|
|
202
206
|
created.inputSchema = Object.assign(base.superRefine((v, ctx) => { if (callDerivedFieldsConflict(v))
|
|
203
207
|
ctx.addIssue({ code: z.ZodIssueCode.custom, message: CALL_DERIVED_REFUSAL, path: ["callId"] }); }), { shape: base.shape });
|
|
204
208
|
}
|
|
205
|
-
strictInput(server.tool("conduyt_update_contact", "Update an existing contact's fields — name, email, phone, company, owner (assignedTo), custom fields. A reassignment releases the previous owner unless keepPreviousOwnerAsCollaborator is true, which keeps them as a collaborator (read-only access to the lead and its cards). customFields merge into existing values (omit a key to leave it unchanged). Pass expectedRevision (the contact's `revision` as you read it) to refuse the save when the contact changed since." + INVALID_NUMBER_REFUSALS + " " + CONTACT_CHANGED + " " + IDENTITY_SAVE_RETRY, {
|
|
209
|
+
strictInput(server.tool("conduyt_update_contact", "Update an existing contact's fields — name, email, phone, company, owner (assignedTo), custom fields. A reassignment releases the previous owner unless keepPreviousOwnerAsCollaborator is true, which keeps them as a collaborator (read-only access to the lead and its cards). customFields merge into existing values (omit a key to leave it unchanged). Pass expectedRevision (the contact's `revision` as you read it) to refuse the save when the contact changed since." + INVALID_NUMBER_REFUSALS + " " + CONTACT_CHANGED + " " + IDENTITY_SAVE_RETRY + " " + FORMULA_WRITE_NOTE + " " + OFF_LIST_NOTE + " " + USER_FIELD_RECORD_WRITE_DOC, {
|
|
206
210
|
id: z.string().describe("Contact UUID"),
|
|
207
211
|
email: z.string().optional().describe("Updated email"),
|
|
208
212
|
firstName: z.string().optional().describe("Updated first name"),
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { ConduytApiError, formatResult } from "../client.js";
|
|
3
|
+
import { USER_NOTE } from "./user-fields-doc.js";
|
|
4
|
+
import { OPTIONS_CAP_NOTE, OPTIONS_MAX, TYPE_CHANGE_NOTE } from "./lender-options.js";
|
|
5
|
+
import { CUSTOM_FIELD_TYPES, DELANCEY_ID_NOTE, fail, formulaCreateProblem, formulaUpdateProblem, FORMULA_DEFINITION_NOTE, SECURE_IDENTIFIER_NOTE } from "./formula-fields.js";
|
|
3
6
|
// (parity1292, batch30 #1292 Ship 1) Secure custom fields: the flag, its reveal set, and the codes. There is NO reveal tool: the reveal
|
|
4
7
|
// routes (POST /{contacts|deals|companies}/{id}/custom-fields/{key}/reveal) refuse an API key (403 reveal_requires_session), and this
|
|
5
8
|
// server always signs in with one.
|
|
@@ -22,26 +25,32 @@ export function registerCustomFieldTools(server, client) {
|
|
|
22
25
|
const result = await client.get(`/api/v1/custom-fields?${params}`);
|
|
23
26
|
return formatResult(result);
|
|
24
27
|
});
|
|
25
|
-
server.tool("conduyt_create_custom_field", "Create a new custom field definition for contacts, deals, or companies. Field types: text, number, date, select, multiselect, boolean. " + SECURE_NOTE, {
|
|
28
|
+
server.tool("conduyt_create_custom_field", "Create a new custom field definition for contacts, deals, or companies. Field types: text, textarea, number, date, datetime, url, select, radio, multiselect, boolean, phone, email, formula, user. " + FORMULA_DEFINITION_NOTE + " " + SECURE_IDENTIFIER_NOTE + " " + SECURE_NOTE + " " + OPTIONS_CAP_NOTE + " " + DELANCEY_ID_NOTE + " " + USER_NOTE, {
|
|
26
29
|
entityType: z.enum(["contact", "deal", "company"]).describe("Entity type this field applies to"),
|
|
27
|
-
fieldKey: z.string().describe("Unique field key (alphanumeric + underscores, e.g. 'lead_score')"),
|
|
30
|
+
fieldKey: z.string().describe("Unique field key (alphanumeric + underscores, e.g. 'lead_score'). On deals, delancey_deal_id is RESERVED (the Delancey Street deal ID the push writes: 422 reserved_field_key, never Secure, never edited or deleted); oes_number and dpp_oes_raw are allowed only as plain optional text fields and are never Secure"),
|
|
28
31
|
label: z.string().describe("Human-readable label (e.g. 'Lead Score')"),
|
|
29
|
-
fieldType: z.enum(
|
|
32
|
+
fieldType: z.enum(CUSTOM_FIELD_TYPES).describe("Field data type; formula is computed at read time from two number fields (options { op, left, right, format })"),
|
|
30
33
|
section: z.string().optional().describe("Section grouping for UI display"),
|
|
31
|
-
options: z.any().optional().describe("Options for select/multiselect fields (array of strings)"),
|
|
34
|
+
options: z.any().optional().describe("Options for select/multiselect fields (array of strings, up to 1000, each 1 to 200 characters); for fieldType formula the object { op: add|sub|mul|div, left: <number field key>, right: <number field key or a number>, format: number|currency|percent }"),
|
|
32
35
|
isRequired: z.boolean().optional().describe("Whether this field is required"),
|
|
33
36
|
sortOrder: z.number().optional().describe("Display order"),
|
|
34
37
|
isSecure: z.boolean().optional().describe("Make this a Secure field (values masked everywhere; 400 secure_fields_not_enabled until enabled)"),
|
|
35
38
|
revealRoles,
|
|
36
39
|
revealGroupIds,
|
|
37
40
|
}, async (params) => {
|
|
41
|
+
const problem = formulaCreateProblem(params);
|
|
42
|
+
if (problem)
|
|
43
|
+
return fail(problem);
|
|
44
|
+
if (Array.isArray(params.options) && params.options.length > OPTIONS_MAX)
|
|
45
|
+
return fail(`options holds at most ${OPTIONS_MAX} choices (got ${params.options.length}).`);
|
|
38
46
|
const result = await client.post("/api/v1/custom-fields", params);
|
|
39
47
|
return formatResult(result);
|
|
40
48
|
});
|
|
41
|
-
server.tool("conduyt_update_custom_field", "Update a custom field's label, options, required status, Secure flag or reveal set. Cannot change the field key or entity type. Turning Secure OFF (isSecure false) makes every stored value visible and needs confirmUnsecure true, else 409 secure_unsecure_unconfirmed. " + SECURE_NOTE, {
|
|
49
|
+
server.tool("conduyt_update_custom_field", "Update a custom field's label, options, required status, Secure flag or reveal set. Cannot change the field key or entity type. A FORMULA field's options (op / left / right / format), Secure flag and required flag are re-judged with its inputs locked: 422 formula_invalid, 422 formula_secure_input; turning Secure on for a number field a non-Secure formula computes from is 409 formula_secure_input naming the formulas. A deal MIRROR (conduyt_create_mirror_field) takes only section and sortOrder; anything else answers 422 invalid_mirror_definition. Turning Secure OFF (isSecure false) makes every stored value visible and needs confirmUnsecure true, else 409 secure_unsecure_unconfirmed. " + SECURE_NOTE + " " + OPTIONS_CAP_NOTE + " " + TYPE_CHANGE_NOTE + " " + DELANCEY_ID_NOTE + " " + USER_NOTE, {
|
|
42
50
|
id: z.string().describe("Custom field UUID"),
|
|
43
51
|
label: z.string().optional().describe("Updated label"),
|
|
44
|
-
|
|
52
|
+
section: z.string().max(120).nullable().optional().describe("Updated section grouping (null clears); the one place besides sortOrder a deal MIRROR can be edited"),
|
|
53
|
+
options: z.any().optional().describe("Updated options for select/multiselect; for a formula field the object { op, left, right, format } (re-judged with its inputs locked)"),
|
|
45
54
|
isRequired: z.boolean().optional().describe("Updated required status"),
|
|
46
55
|
sortOrder: z.number().optional().describe("Updated display order"),
|
|
47
56
|
isSecure: z.boolean().optional().describe("Turn Secure on or off (off needs confirmUnsecure true)"),
|
|
@@ -49,15 +58,34 @@ export function registerCustomFieldTools(server, client) {
|
|
|
49
58
|
revealGroupIds,
|
|
50
59
|
confirmUnsecure: z.boolean().optional().describe("Required true with isSecure false: confirms every stored value becomes visible"),
|
|
51
60
|
}, async ({ id, ...updates }) => {
|
|
61
|
+
const problem = formulaUpdateProblem(updates);
|
|
62
|
+
if (problem)
|
|
63
|
+
return fail(problem);
|
|
64
|
+
if (Array.isArray(updates.options) && updates.options.length > OPTIONS_MAX)
|
|
65
|
+
return fail(`options holds at most ${OPTIONS_MAX} choices (got ${updates.options.length}).`);
|
|
52
66
|
const result = await client.patch(`/api/v1/custom-fields/${id}`, updates);
|
|
53
67
|
return formatResult(result);
|
|
54
68
|
});
|
|
55
|
-
server.tool("conduyt_delete_custom_field", "Delete a custom field definition. Removes the field from all entities. A Secure field cannot be deleted: 409 secure_field_delete_refused (turn Secure off first with conduyt_update_custom_field isSecure false + confirmUnsecure true, then delete).", {
|
|
69
|
+
server.tool("conduyt_delete_custom_field", "Delete a custom field definition. Removes the field from all entities. A field a formula computes from cannot be deleted: 409 deletion_blocked (the formula named in blockers). A contact / company field mirrored on deals cannot be deleted: 409 mirror_source_in_use { mirrors } (delete the deal mirrors first; deleting a mirror deletes only the placement, never the contact's value). A Secure field cannot be deleted: 409 secure_field_delete_refused (turn Secure off first with conduyt_update_custom_field isSecure false + confirmUnsecure true, then delete)." + " " + DELANCEY_ID_NOTE, {
|
|
56
70
|
id: z.string().describe("Custom field UUID"),
|
|
57
71
|
}, async ({ id }) => {
|
|
58
72
|
const result = await client.del(`/api/v1/custom-fields/${id}`);
|
|
59
73
|
return formatResult(result);
|
|
60
74
|
});
|
|
75
|
+
// (mirror1292, batch31 #1292 Ship 3) a DEAL MIRROR: POST /custom-fields with mirrorOf (no type, options, required or Secure flags)
|
|
76
|
+
server.tool("conduyt_create_mirror_field", "Create a DEAL MIRROR field (#1292): a write-through view of a contact or company field shown and edited on every deal as ONE value (nothing is copied). Deal reads (conduyt_get_deal / conduyt_list_deals) answer the deal's linked contact's / company's value under fieldKey with a mirrorFields entry; conduyt_update_deal with the key writes that record. It has no type, options, required or Secure flag of its own: all the source's (a mirror of a Secure source is masked and revealed exactly like it). A re-linked deal shows the new record's value. Not filterable (422 mirror_not_filterable) and never a deal trigger (422 mirror_not_triggerable). Refusals: 422 invalid_mirror_definition (unknown or system-managed source, deals already store values under fieldKey); 409 when fieldKey already exists on deals. POST /api/v1/custom-fields with mirrorOf.", {
|
|
77
|
+
fieldKey: z.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/).describe("The deal field key of the mirror (letters, digits, underscores; not starting with a digit)"),
|
|
78
|
+
mirrorOf: z.object({
|
|
79
|
+
entityType: z.enum(["contact", "company"]).describe("The source record type: the deal's primary contact or its company"),
|
|
80
|
+
fieldKey: z.string().min(1).max(100).regex(/^[A-Za-z_][A-Za-z0-9_]*$/).describe("The source field key on that record type"),
|
|
81
|
+
}).describe("The contact / company field this deal field mirrors"),
|
|
82
|
+
label: z.string().min(1).max(200).optional().describe("Optional; the source's label is answered"),
|
|
83
|
+
section: z.string().max(120).nullable().optional().describe("Section grouping on the deal page"),
|
|
84
|
+
sortOrder: z.number().int().min(0).max(100000).optional().describe("Display order"),
|
|
85
|
+
}, async (params) => {
|
|
86
|
+
const result = await client.post("/api/v1/custom-fields", { entityType: "deal", ...params });
|
|
87
|
+
return formatResult(result);
|
|
88
|
+
});
|
|
61
89
|
// ─── account default columns for the contacts list (admin-managed; applied to every user on their next visit) ───
|
|
62
90
|
server.tool("conduyt_get_contact_table_defaults", "Read the account-level DEFAULT COLUMNS for the Contacts list: the column ids every user gets merged into their own layout on their next visit (each version once; users can rearrange afterwards). null = no account default (users see the built-in layout). Reads /api/v1/settings (settings:view).", {}, async () => {
|
|
63
91
|
const result = (await client.get("/api/v1/settings"));
|
|
@@ -3,4 +3,5 @@ import { ConduytClient } from "../client.js";
|
|
|
3
3
|
/** (parity28, batch28) the Deal profile (the deal page's tabs of the primary contact's bound fields), the partner push and the workspace binding. */
|
|
4
4
|
export declare const PUSH_PARTNERS: readonly ["creditors_relief", "delancey_street"];
|
|
5
5
|
export declare const PUSH_ACTIONS: readonly ["create", "update"];
|
|
6
|
+
export declare const PUSH_EXPECT_MODES: readonly ["test", "live"];
|
|
6
7
|
export declare function registerDealProfileTools(server: McpServer, client: ConduytClient): void;
|
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { formatResult } from "../client.js";
|
|
3
3
|
import { strictInput } from "./strict.js";
|
|
4
|
+
import { fail, secureEgressProblem } from "./formula-fields.js";
|
|
4
5
|
/** (parity28, batch28) the Deal profile (the deal page's tabs of the primary contact's bound fields), the partner push and the workspace binding. */
|
|
5
6
|
export const PUSH_PARTNERS = ["creditors_relief", "delancey_street"];
|
|
6
7
|
export const PUSH_ACTIONS = ["create", "update"];
|
|
8
|
+
export const PUSH_EXPECT_MODES = ["test", "live"];
|
|
7
9
|
const PROFILE_KEYS_MAX = 100;
|
|
8
10
|
const KEY_MAX = 100;
|
|
9
11
|
const PATCH_CODES = "400 profile_key_not_bound (keys lists them), profile_field_invalid (key), deal_profile_not_enabled, invalid_body; 403 deal_not_editable or contacts_permission_required; 404 deal not found; 409 profile_field_changed { key, current } (nothing written), profile_conflict or deal_has_no_contact; 422 stage_automation_only (the card sits in a stage only automation may change; nothing written); 503 profile_busy (the contact stayed locked; nothing written, retry after the Retry-After seconds).";
|
|
10
|
-
|
|
12
|
+
/** (parity32, batch32 delseam1286) a pending Delancey Street submission the CURRENT Secure policy refuses to resend: an ERROR, never a success state */
|
|
13
|
+
const HELD_RESEND_NOTE = "A pending delancey_street submission (status unknown after an ambiguous answer: the next push resends it with the same key) is RE-CHECKED against the CURRENT Secure policy: if its body carries a Secure key the binding's secureEgress no longer lists for delancey_street, nothing is sent and the press answers 422 profile_secure_field with blocked: true { secure[], pushId } (an error: pending.blocked on conduyt_get_deal_partner_pushes is NOT a success state). The push row stays unknown with code secure_blocked and the slot stays held, because the deal may already exist at Delancey Street: list the keys for delancey_street in the Deal profile secureEgress to resend it, or an admin checks Delancey Street by hand.";
|
|
14
|
+
const DELANCEY_PUSH_NOTE = "delancey_street (the ISO Partner API) is enabled per workspace (config.partners.delancey_street.enabled plus a key; else 409 partner_disabled / partner_not_configured) and takes NEW submissions only: action create, one deal record per card (a card that already has its delancey_deal_id or a succeeded submission answers 409 already_submitted). A TEST key runs every check and creates nothing (the answer carries test: true; the card is not stamped). expectMode is the key mode the card showed (test or live): a changed key answers 409 key_mode_changed with nothing sent.";
|
|
15
|
+
const PUSH_CODES = "403 deal_not_editable / push_not_permitted; 404; 409 partner_disabled, partner_not_configured (delancey_street: no API key in the workspace), partner_not_enabled, push_in_flight, needs_link, action_changed (the current state comes back), already_submitted (delancey_street takes a new submission only: the card already has its deal id), key_mode_changed { mode } (delancey_street: the workspace key is now a test or live key other than the expectMode you passed; nothing sent), deal_has_no_contact, contact_busy, reconcile_needs_admin, reconcile_ambiguous; 422 profile_incomplete (missing[] names each gap; nothing written, no partner call), profile_secure_field { secure[], missing[] } (a Secure value the push would send whose key the binding does not list in secureEgress FOR THAT PARTNER; nothing written, no partner call) or stage_automation_only (the card sits in a stage only automation may change); 503 deal_busy or partner_auth.";
|
|
11
16
|
/** fields: 1 to 100 keys; expected: any number of keys (the server caps only fields); both: key length 1 to 100 */
|
|
12
17
|
const keyed = (min, max) => z.record(z.string().min(1).max(KEY_MAX), z.unknown()).refine((o) => Object.keys(o).length >= min && Object.keys(o).length <= max, { message: `must hold ${min} to ${max} keys` });
|
|
13
18
|
export function registerDealProfileTools(server, client) {
|
|
@@ -20,18 +25,24 @@ export function registerDealProfileTools(server, client) {
|
|
|
20
25
|
}, async ({ id, fields, expected }) => formatResult(await client.patch(`/api/v1/deals/${encodeURIComponent(id)}/profile`, { fields, expected }))));
|
|
21
26
|
strictInput(server.tool("conduyt_reveal_deal_profile_field", "Reveal ONE sensitive Deal profile field in full (POST /api/v1/deals/{id}/profile/reveal with body { key }; the answer is never cached and carries the value's token; the old GET answers 405). A bound key whose contact field is Secure is revealed the same way but is refused for an API key (403 reveal_requires_session) and needs that field's own reveal set. Allowed only for a caller in the binding's reveal set (settings.dealProfile revealRoles / revealGroupIds; a super admin always) with contacts:view on a card they can see. Every reveal of a stored value is audited before the answer (deal_profile.reveal for a sensitive-only key; custom_field.revealed with via deal_profile for a Secure key), so each call is recorded; an empty field answers value null and is not audited. 400 invalid_body, invalid_json, profile_key_not_sensitive or deal_profile_not_enabled; 403 reveal_not_allowed or contacts_permission_required; 404.", { id: dealId, key: z.string().min(1).max(100).refine((v) => v.trim() !== "", { message: "key must not be blank" }).describe("The sensitive bound field key (exactly one)") }, async ({ id, key }) => formatResult(await client.post(`/api/v1/deals/${encodeURIComponent(id)}/profile/reveal`, { key }))));
|
|
22
27
|
server.tool("conduyt_get_deal_profile_settings", "Read the workspace's Deal profile binding (GET /api/v1/settings/deal-profile; settings:view): { dealProfile (as stored), valid, danglingKeys (bound keys that name no contact custom field definition) }.", {}, async () => formatResult(await client.get("/api/v1/settings/deal-profile")));
|
|
23
|
-
strictInput(server.tool("conduyt_set_deal_profile_settings", "REPLACE the workspace's Deal profile binding (PUT /api/v1/settings/deal-profile; settings:edit, and only an owner or admin: a delegated holder is refused 403 deal_profile_admin_only; audited as settings_deal_profile_updated): the whole object is replaced, nothing merges, so read the current one with conduyt_get_deal_profile_settings first. dealProfile holds enabled, pipelineIds (null or absent = every pipeline), generalTab { label }, tabs (up to 12: key, label, fields of { key (a CONTACT custom field key), label, control, options, span, sensitive, default, requiredFor, showWhen, note, validate }), repeating slot tables (each may set readinessPerSlot: true), footerNote, actions, revealRoles / revealGroupIds. actions is [{ key, name }] (up to 20, one entry per partner key; a key named twice is refused; name 1 to 60 characters of plain text): the readiness copy on the deal page reads \"Needed for <name>\", and an action without one shows its partner's default name, else its key. A field's note is a hint to the rep shown under the field (plain text, 1 to 240 characters). readinessPerSlot: true on a repeating table makes each readiness column count one item per filled slot (3 creditors listed = 3 items per column in the N of M); absent, the whole table is one item per column. Plain text starts with a visible character and holds no control, line-separator, invisible (zero-width, soft hyphen, BOM) or bidirectional characters. conduyt_get_deal_profile answers the result as partners[key].actionName (the binding's saved name, else \"Send to <name>\" for a known partner, else the key) and fields[].note (null = none, absent on a repeating cell). Every pipeline and member group named must be this workspace's. No custom field definition is created or altered. 422 invalid_deal_profile (shape, a foreign pipeline or member group).", { dealProfile: z.record(z.string(), z.unknown()).describe("The whole binding object (validated by the server: actions [{ key, name }] up to 20, a field note up to 240 plain-text characters, readinessPerSlot true on a repeating table)") }, async ({ dealProfile }) =>
|
|
28
|
+
strictInput(server.tool("conduyt_set_deal_profile_settings", "REPLACE the workspace's Deal profile binding (PUT /api/v1/settings/deal-profile; settings:edit, and only an owner or admin: a delegated holder is refused 403 deal_profile_admin_only; audited as settings_deal_profile_updated): the whole object is replaced, nothing merges, so read the current one with conduyt_get_deal_profile_settings first. dealProfile holds enabled, pipelineIds (null or absent = every pipeline), generalTab { label }, tabs (up to 12: key, label, fields of { key (a CONTACT custom field key), label, control, options, span, sensitive, default, requiredFor, showWhen, note, validate }), repeating slot tables (each may set readinessPerSlot: true), footerNote, actions, secureEgress, revealRoles / revealGroupIds. secureEgress is an OBJECT per partner { creditors_relief: [custom field key], delancey_street: [custom field key] } (each list optional, up to 100 keys, none twice within a list, no other key; the Secure CONTACT or DEAL custom field keys the partner push MAY send TO THAT PARTNER: a key listed for one partner never unblocks the other; each key must name an existing contact or deal custom field, else 422 invalid_deal_profile; a Secure value the push would send to a partner whose list does not name the key refuses the push with 422 profile_secure_field, a listed one is sent masked to the last 4 in the preview, the stored snapshot and the history, and every send is audited); the older FLAT array [custom field key] is still accepted and is read as the Creditors Relief list ONLY (it never unblocks Delancey Street; a stored flat list keeps working). roleStamping { enabled, rules: [{ role: appointment_setter|opener|transfer_rep|closer, groupId (a member group UUID), fieldKey (a DEAL custom field of type user; another type is skipped), mode: first|latest }] } (up to 20 rules; on an owner change the new owner's role field is stamped when their group maps: first = never replaced once set, latest = the newest owner of the group wins; #1303). actions is [{ key, name }] (up to 20, one entry per partner key; a key named twice is refused; name 1 to 60 characters of plain text): the readiness copy on the deal page reads \"Needed for <name>\", and an action without one shows its partner's default name, else its key. A field's note is a hint to the rep shown under the field (plain text, 1 to 240 characters). readinessPerSlot: true on a repeating table makes each readiness column count one item per filled slot (3 creditors listed = 3 items per column in the N of M); absent, the whole table is one item per column. Plain text starts with a visible character and holds no control, line-separator, invisible (zero-width, soft hyphen, BOM) or bidirectional characters. conduyt_get_deal_profile answers the result as partners[key].actionName (the binding's saved name, else \"Send to <name>\" for a known partner, else the key) and fields[].note (null = none, absent on a repeating cell). Every pipeline and member group named must be this workspace's. No custom field definition is created or altered. 422 invalid_deal_profile (shape, a foreign pipeline or member group).", { dealProfile: z.record(z.string(), z.unknown()).describe("The whole binding object (validated by the server: secureEgress { creditors_relief: [field key], delancey_street: [field key] } or the older flat array (= Creditors Relief), each list up to 100 none twice, actions [{ key, name }] up to 20, a field note up to 240 plain-text characters, readinessPerSlot true on a repeating table)") }, async ({ dealProfile }) => {
|
|
29
|
+
const problem = secureEgressProblem(dealProfile);
|
|
30
|
+
if (problem)
|
|
31
|
+
return fail(problem);
|
|
32
|
+
return formatResult(await client.put("/api/v1/settings/deal-profile", { dealProfile }));
|
|
33
|
+
}));
|
|
24
34
|
strictInput(server.tool("conduyt_remove_deal_profile_settings", "REMOVE the workspace's Deal profile binding (PUT /api/v1/settings/deal-profile with dealProfile null; settings:edit, and only an owner or admin: a delegated holder is refused 403 deal_profile_admin_only): the deal page's Details card returns to its plain view and the stored binding (tabs, rules, reveal set) is DISCARDED, so read and keep a copy with conduyt_get_deal_profile_settings first. No custom field definition is touched.", {}, async () => formatResult(await client.put("/api/v1/settings/deal-profile", { dealProfile: null }))));
|
|
25
|
-
server.tool("conduyt_get_deal_partner_pushes", "The deal page's Push to partner card (GET /api/v1/deals/{id}/partner-pushes): { enabled: false } when the workspace has no enabled partner, else the partners (Creditors Relief; Delancey Street
|
|
26
|
-
server.tool("conduyt_preview_deal_partner_push", "Preview what the next partner push would send (GET /api/v1/deals/{id}/partner-pushes/preview): the action (create when the card has no OES #, update when it has one), the partner endpoint, the payload rows (SSN and bank numbers masked to the last 4), the readiness gaps (missing[]; a push answers 422 profile_incomplete while any remain) and the policy warnings. Nothing is written and no partner is called. Same gates as the push: deals:edit, the card's edit scope, closer or above. 403 deal_not_editable / push_not_permitted; 404; 409 partner_disabled (delancey_street
|
|
35
|
+
server.tool("conduyt_get_deal_partner_pushes", "The deal page's Push to partner card (GET /api/v1/deals/{id}/partner-pushes): { enabled: false } when the workspace has no enabled partner, else the partners (Creditors Relief; Delancey Street when the workspace enables it with a key, with its key mode test / live), the card's partner id (the deal field oes_number) and its display (CRL-<id>; Delancey Street: the deal id), a pending create (sending, or unknown after an ambiguous answer: the next push checks the partner first; for delancey_street an unknown one the CURRENT Secure policy refuses to resend carries pending.blocked { reason: secure_policy, keys }, an ERROR state: the next press answers 422 profile_secure_field blocked: true, never a success), the newest four pushes, submitted (delancey_street: the succeeded submission) and canPush (the card's edit scope and closer or above). " + HELD_RESEND_NOTE + " Needs deals:view on the card; 404 when the deal does not exist or the caller cannot see it.", { id: dealId }, async ({ id }) => formatResult(await client.get(`/api/v1/deals/${encodeURIComponent(id)}/partner-pushes`)));
|
|
36
|
+
server.tool("conduyt_preview_deal_partner_push", "Preview what the next partner push would send (GET /api/v1/deals/{id}/partner-pushes/preview): the action (create when the card has no OES #, update when it has one), the partner endpoint, the payload rows (SSN and bank numbers masked to the last 4), the readiness gaps (missing[]; a push answers 422 profile_incomplete while any remain) and the policy warnings. Nothing is written and no partner is called. Same gates as the push: deals:edit, the card's edit scope, closer or above. 403 deal_not_editable / push_not_permitted; 404; 409 partner_disabled / partner_not_configured (delancey_street needs the workspace flag and a key), partner_not_enabled, deal_has_no_contact; 422 profile_secure_field { secure[], missing[] } (a Secure value the push would send whose key the binding does not list in secureEgress for that partner; the preview refuses it too, nothing is sent). " + DELANCEY_PUSH_NOTE, { id: dealId, partner: z.enum(PUSH_PARTNERS).optional().describe("creditors_relief (default) or delancey_street") }, async ({ id, partner }) => {
|
|
27
37
|
if (partner === undefined)
|
|
28
38
|
return formatResult(await client.get(`/api/v1/deals/${encodeURIComponent(id)}/partner-pushes/preview`));
|
|
29
39
|
return formatResult(await client.get(`/api/v1/deals/${encodeURIComponent(id)}/partner-pushes/preview?partner=${partner}`));
|
|
30
40
|
});
|
|
31
|
-
strictInput(server.tool("conduyt_push_deal_to_partner", `Push a deal to a partner (POST /api/v1/deals/{id}/partner-pushes): ONE press of the deal page's Push to partner, which SENDS the card's data to the partner and cannot be recalled. One partner record per card: a card without an OES # creates the record (the contact, one debt per creditor, then the bank account when its details are filled) and stamps the partner's id on the card; a card with an OES # can only update that record's contact. action is what you saw (create or update): the server decides from the locked card and answers 409 action_changed with the current state when they differ (call conduyt_preview_deal_partner_push first). An executed attempt answers 200 with result accepted, found, updated, refused (nothing saved on the deal), unknown (no definite answer: the next push checks the partner before creating), needs_link (the partner created the record but the card could not carry its id; an admin links it by hand) or erased. Needs deals:edit, the card's edit scope and closer or above. idempotencyKey (1-255 printable ASCII) is sent as the Idempotency-Key header: one key per push press, reused ONLY to retry the SAME request (same key + same body replays the first answer; a different body is 422 idempotency_request_conflict). A refusal decided before any partner call (the 403s, partner_disabled, partner_not_enabled, push_in_flight, needs_link, action_changed, deal_has_no_contact, contact_busy, profile_incomplete, deal_busy) releases the key, so the SAME key may be retried at once; an executed attempt (accepted, found, updated, refused, unknown) and reconcile_needs_admin, reconcile_ambiguous or partner_auth spend it: a retry with that key answers 409 idempotency_key_spent, so verify what happened before sending a NEW key. 409 idempotency_in_progress: wait Retry-After and retry with the SAME key. A key starting with forgotten: is reserved (400 idempotency_key_reserved). Rare wrapper outcomes: 409 idempotency_conflict_retry (a concurrent claim could not be resolved, nothing ran: retry with the SAME key); 503 idempotency_claim_held (the release of a failed attempt's claim could not be confirmed: retry with a NEW key); 503 idempotency_outcome_unknown (the success could not be confirmed and the push may have gone through: verify the outcome before any new key). ${PUSH_CODES}`, {
|
|
41
|
+
strictInput(server.tool("conduyt_push_deal_to_partner", `Push a deal to a partner (POST /api/v1/deals/{id}/partner-pushes): ONE press of the deal page's Push to partner, which SENDS the card's data to the partner and cannot be recalled. One partner record per card: a card without an OES # creates the record (the contact, one debt per creditor, then the bank account when its details are filled) and stamps the partner's id on the card; a card with an OES # can only update that record's contact. action is what you saw (create or update): the server decides from the locked card and answers 409 action_changed with the current state when they differ (call conduyt_preview_deal_partner_push first). An executed attempt answers 200 with result accepted, found, updated, refused (nothing saved on the deal), unknown (no definite answer: the next push checks the partner before creating), needs_link (the partner created the record but the card could not carry its id; an admin links it by hand) or erased. Needs deals:edit, the card's edit scope and closer or above. idempotencyKey (1-255 printable ASCII) is sent as the Idempotency-Key header: one key per push press, reused ONLY to retry the SAME request (same key + same body replays the first answer; a different body is 422 idempotency_request_conflict). A refusal decided before any partner call (the 403s, partner_disabled, partner_not_configured, partner_not_enabled, push_in_flight, needs_link, action_changed, already_submitted, key_mode_changed, deal_has_no_contact, contact_busy, profile_incomplete, profile_secure_field, deal_busy) releases the key (a held Delancey resend the current Secure policy refuses, 422 profile_secure_field blocked: true, is one of them), so the SAME key may be retried at once; an executed attempt (accepted, found, updated, refused, unknown) and reconcile_needs_admin, reconcile_ambiguous or partner_auth spend it: a retry with that key answers 409 idempotency_key_spent, so verify what happened before sending a NEW key. 409 idempotency_in_progress: wait Retry-After and retry with the SAME key. A key starting with forgotten: is reserved (400 idempotency_key_reserved). Rare wrapper outcomes: 409 idempotency_conflict_retry (a concurrent claim could not be resolved, nothing ran: retry with the SAME key); 503 idempotency_claim_held (the release of a failed attempt's claim could not be confirmed: retry with a NEW key); 503 idempotency_outcome_unknown (the success could not be confirmed and the push may have gone through: verify the outcome before any new key). ${DELANCEY_PUSH_NOTE} ${HELD_RESEND_NOTE} ${PUSH_CODES}`, {
|
|
32
42
|
id: dealId,
|
|
33
|
-
partner: z.enum(PUSH_PARTNERS).describe("creditors_relief (Forth) or delancey_street (
|
|
34
|
-
action: z.enum(PUSH_ACTIONS).describe("What the card showed: create (no
|
|
43
|
+
partner: z.enum(PUSH_PARTNERS).describe("creditors_relief (Forth) or delancey_street (the ISO Partner API; enabled per workspace)"),
|
|
44
|
+
action: z.enum(PUSH_ACTIONS).describe("What the card showed: create (no partner id yet) or update (a Creditors Relief card with an OES #); delancey_street takes create only"),
|
|
45
|
+
expectMode: z.enum(PUSH_EXPECT_MODES).optional().describe("delancey_street only: the key mode the card showed, test or live (a changed key answers 409 key_mode_changed with nothing sent)"),
|
|
35
46
|
idempotencyKey: z.string().regex(/^[!-~](?:[ -~]{0,253}[!-~])?$/, "idempotencyKey must be 1-255 printable ASCII characters, not blank").optional().describe("Sent as the Idempotency-Key header; reuse it ONLY to retry the SAME request"),
|
|
36
|
-
}, async ({ id, partner, action, idempotencyKey }) => formatResult(await client.post(`/api/v1/deals/${encodeURIComponent(id)}/partner-pushes`, { partner, action }, idempotencyKey !== undefined ? { headers: { "Idempotency-Key": idempotencyKey } } : undefined))));
|
|
47
|
+
}, async ({ id, partner, action, expectMode, idempotencyKey }) => formatResult(await client.post(`/api/v1/deals/${encodeURIComponent(id)}/partner-pushes`, { partner, action, ...(expectMode !== undefined ? { expectMode } : {}) }, idempotencyKey !== undefined ? { headers: { "Idempotency-Key": idempotencyKey } } : undefined))));
|
|
37
48
|
}
|
package/dist/tools/deals.js
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
import { USER_FIELD_READ_DOC, USER_FIELD_RECORD_WRITE_DOC, USER_FIELD_WRITE_DOC } from "./user-fields-doc.js";
|
|
3
|
+
import { OFF_LIST_NOTE } from "./lender-options.js";
|
|
2
4
|
import { formatResult } from "../client.js";
|
|
5
|
+
import { FORMULA_WRITE_NOTE } from "./formula-fields.js";
|
|
3
6
|
import { strictInput } from "./strict.js";
|
|
4
7
|
import { KEEP_PREVIOUS_OWNER_NEEDS_ASSIGNEE } from "./contacts.js";
|
|
8
|
+
// (mirror1292, batch31 #1292 Ship 3) deal MIRROR fields: a write-through view of a contact / company field, named on the deal tools
|
|
9
|
+
const MIRROR_READ_DOC = " Mirror fields (#1292): a deal custom field created as a MIRROR of a contact / company field answers that record's value in customFields, with mirrorFields[key] = { mirrored: true, source: { entityType, fieldKey }, unresolved? } beside it (unresolved: no_linked_contact | no_linked_company | source_field_missing, value null); a mirror of a Secure source answers the mask \u2022\u2022\u2022\u2022 like the source (passed through untouched).";
|
|
10
|
+
const MIRROR_WRITE_DOC = " A customFields key that is a deal MIRROR writes the linked contact / company through its own write path (nothing is stored on the deal): 409 mirror_unresolved (no linked record), 409 mirror_relink_conflict (the same request re-links it), 403 mirror_source_not_editable, 422 mirror_source_rejected, 409 mirror_source_changed, 409 mirror_source_conflict (the source's required state changed under the lock), 422 mirror_conflicting_values (two mirror keys of one source field with different values).";
|
|
5
11
|
/** The six Pipeline health checks (GET /deals health_check, GET /deals/inspection check). */
|
|
6
12
|
export const PIPELINE_HEALTH_CHECKS = ["high_value_idle", "stale", "unassigned", "needs_action", "missing_close_date", "missing_contact"];
|
|
7
13
|
const healthCheckSchema = z.enum(PIPELINE_HEALTH_CHECKS);
|
|
@@ -49,7 +55,7 @@ function boardSnapshotColumns(a, f) {
|
|
|
49
55
|
return a.board_columns.map((c) => (c.limit === undefined ? c.stageId : `${c.stageId}:${c.limit}`)).join(",");
|
|
50
56
|
}
|
|
51
57
|
export function registerDealTools(server, client) {
|
|
52
|
-
strictInput(server.tool("conduyt_list_deals", "List deals with filtering by pipeline, stage, assignee, or status. Returns deal title, value, stage, contact, and dates. Filter by pipeline/stage NAME (the same names you import with) or by UUID — both camelCase (pipelineName) and snake_case (pipeline_name) argument names are accepted. An unknown name returns a clear error, never the whole account. Each deal row carries hasNextStep (boolean: an open task or a booked appointment from a day ago on; the Needs next action rule's own answer) and nextAppointmentAt (ISO string or null; null unless your key can view the calendar, even when hasNextStep is true). PIPELINE HEALTH: pass health_summary=true to get the Pipeline health strip for the same filtered set instead of the deal list: { totalOpenDeals, atRiskValue, checks[] (key, label, severity, color, rule, count, value; the six checks high_value_idle, stale, unassigned, needs_action, missing_close_date, missing_contact, ordered by money at risk), deals }. Add health_check to also get that check's first page of deals (highest value first) as deals: { check, offset, items, hasMore, nextCursor, total }; deals is null without a check. Page with health_cursor (the previous nextCursor, passed back UNCHANGED: an opaque signed token) or health_offset, and health_rows_only=true to get just the page without the summary: the answer is {data:{deals:{check, offset, items, hasMore, nextCursor}}} (the page sits under data.deals). " + HEALTH_ERRORS + " " + BOARD_SNAPSHOT_DOC + " " + BUSY_503_DOC, {
|
|
58
|
+
strictInput(server.tool("conduyt_list_deals", "List deals with filtering by pipeline, stage, assignee, or status. Returns deal title, value, stage, contact, and dates. Filter by pipeline/stage NAME (the same names you import with) or by UUID — both camelCase (pipelineName) and snake_case (pipeline_name) argument names are accepted. An unknown name returns a clear error, never the whole account. Each deal row carries hasNextStep (boolean: an open task or a booked appointment from a day ago on; the Needs next action rule's own answer) and nextAppointmentAt (ISO string or null; null unless your key can view the calendar, even when hasNextStep is true). PIPELINE HEALTH: pass health_summary=true to get the Pipeline health strip for the same filtered set instead of the deal list: { totalOpenDeals, atRiskValue, checks[] (key, label, severity, color, rule, count, value; the six checks high_value_idle, stale, unassigned, needs_action, missing_close_date, missing_contact, ordered by money at risk), deals }. Add health_check to also get that check's first page of deals (highest value first) as deals: { check, offset, items, hasMore, nextCursor, total }; deals is null without a check. Page with health_cursor (the previous nextCursor, passed back UNCHANGED: an opaque signed token) or health_offset, and health_rows_only=true to get just the page without the summary: the answer is {data:{deals:{check, offset, items, hasMore, nextCursor}}} (the page sits under data.deals). " + HEALTH_ERRORS + " " + BOARD_SNAPSHOT_DOC + " " + BUSY_503_DOC + MIRROR_READ_DOC + " A mirror key is not filterable (422 mirror_not_filterable). The API judges the query NAMES (batch32, #1313): a name GET /deals does not read is 400 unknown_query_param { message, unknown[], accepted[] (every name it reads), didYouMean { name: accepted twin } for the camelCase / snake_case twin of an accepted name } and is never silently ignored (it used to answer the unfiltered list); two different values for a single-value name (status, contact_id, search, stale, needsAction, summary, latest_updated, system_occupancy, sort, order, page, per_page, value_min / minValue, value_max / maxValue) are 400 query_param_conflict { message, param }, an exact repeat is accepted. This tool sends only accepted names (pipeline, pipeline_name, stage, stage_name, assigned_to, status, search, page, per_page, board_snapshot, board_columns, health_summary, health_check, health_limit, health_offset, health_cursor, health_rows_only), so these two codes mean an older or newer server than this MCP expects; they reach you as `Conduyt API 400: <message>` with the code. The API judges sort and order (batch32): an unknown sort field, or an order other than asc / desc, is 400 sort_invalid { message, param, accepted } (the sent spelling in param) and is never silently replaced by the default order. The deal value bounds are judged too: value_min / minValue and value_max / maxValue that are non-numeric or outside the deal value column range (-9999999999.99..9999999999.99) are 400 invalid_value_min / invalid_value_max { message, param, accepted } (absent or empty = no filter; an alias spelling answers the same code with the sent spelling in param).", {
|
|
53
59
|
pipeline: z.string().optional().describe("Filter by pipeline UUID (canonical). Aliases: pipelineId, pipeline_id."),
|
|
54
60
|
pipelineId: z.string().optional().describe("Filter by pipeline UUID (alias of pipeline)."),
|
|
55
61
|
pipeline_id: z.string().optional().describe("snake_case alias of pipelineId."),
|
|
@@ -194,13 +200,13 @@ export function registerDealTools(server, client) {
|
|
|
194
200
|
const result = await client.post("/api/v1/tasks", { checkOrigin, dealId, expectedDealUpdatedAt, title, description, dueDate, priority, status, assignedTo, contactId }, idempotencyKey !== undefined ? { headers: { "Idempotency-Key": idempotencyKey } } : undefined);
|
|
195
201
|
return formatResult(result);
|
|
196
202
|
}));
|
|
197
|
-
server.tool("conduyt_get_deal", "Get a single deal with full details — value, currency, probability, stage, contact, expected close date, custom-field values, activities, tasks, and history. Use this to read structured custom-field data back out of a deal (e.g. for a P&L or balance-sheet model). Deal rows also carry hasNextStep and nextAppointmentAt (null unless your key can view the calendar) when the API returns them.", {
|
|
203
|
+
server.tool("conduyt_get_deal", "Get a single deal with full details — value, currency, probability, stage, contact, expected close date, custom-field values, activities, tasks, and history. Use this to read structured custom-field data back out of a deal (e.g. for a P&L or balance-sheet model). Deal rows also carry hasNextStep and nextAppointmentAt (null unless your key can view the calendar) when the API returns them." + MIRROR_READ_DOC + " " + USER_FIELD_READ_DOC, {
|
|
198
204
|
id: z.string().describe("Deal UUID"),
|
|
199
205
|
}, async ({ id }) => {
|
|
200
206
|
const result = await client.get(`/api/v1/deals/${id}`);
|
|
201
207
|
return formatResult(result);
|
|
202
208
|
});
|
|
203
|
-
server.tool("conduyt_create_deal", "Create a new deal in a pipeline with full attributes. Requires a pipeline and stage ID — use conduyt_list_pipelines to discover them. Supports currency (e.g. GBP), probability, priority, expected close date, and structured custom-field values. A stage set to \"Entry by automation only\" refuses every entry here: 422 code stage_automation_only, message \"Only an automation can move a deal into <stage>\" (admins and API keys included; moving out is free).", {
|
|
209
|
+
server.tool("conduyt_create_deal", "Create a new deal in a pipeline with full attributes. Requires a pipeline and stage ID — use conduyt_list_pipelines to discover them. Supports currency (e.g. GBP), probability, priority, expected close date, and structured custom-field values. A stage set to \"Entry by automation only\" refuses every entry here: 422 code stage_automation_only, message \"Only an automation can move a deal into <stage>\" (admins and API keys included; moving out is free)." + " A mirror key cannot be set on a new deal: 422 mirror_not_writable." + " " + FORMULA_WRITE_NOTE + " " + OFF_LIST_NOTE + USER_FIELD_RECORD_WRITE_DOC, {
|
|
204
210
|
title: z.string().describe("Deal title (e.g. 'Acme Corp — Enterprise Plan')"),
|
|
205
211
|
pipelineId: z.string().describe("Pipeline UUID"),
|
|
206
212
|
stageId: z.string().describe("Stage UUID within the pipeline"),
|
|
@@ -219,7 +225,7 @@ export function registerDealTools(server, client) {
|
|
|
219
225
|
const result = await client.post("/api/v1/deals", params);
|
|
220
226
|
return formatResult(result);
|
|
221
227
|
});
|
|
222
|
-
server.tool("conduyt_update_deal", "Update a deal — move stage, change value/currency, set probability or expected close date, reassign (assignedTo: the previous owner is released unless they own another open card of the lead, or keepPreviousOwnerAsCollaborator is true, which keeps them as a read-only collaborator of the contact; the flag is refused 400 without assignedTo and 400 together with a contact change), mark won/lost, or write structured custom-field values. customFields are merged into existing values (omit a key to leave it unchanged). A stage set to \"Entry by automation only\" refuses every entry here: 422 code stage_automation_only, message \"Only an automation can move a deal into <stage>\" (admins and API keys included; moving out is free).", {
|
|
228
|
+
server.tool("conduyt_update_deal", "Update a deal — move stage, change value/currency, set probability or expected close date, reassign (assignedTo: the previous owner is released unless they own another open card of the lead, or keepPreviousOwnerAsCollaborator is true, which keeps them as a read-only collaborator of the contact; the flag is refused 400 without assignedTo and 400 together with a contact change), mark won/lost, or write structured custom-field values. customFields are merged into existing values (omit a key to leave it unchanged). A stage set to \"Entry by automation only\" refuses every entry here: 422 code stage_automation_only, message \"Only an automation can move a deal into <stage>\" (admins and API keys included; moving out is free)." + MIRROR_WRITE_DOC + " " + FORMULA_WRITE_NOTE + " " + OFF_LIST_NOTE + " " + USER_FIELD_WRITE_DOC, {
|
|
223
229
|
id: z.string().describe("Deal UUID"),
|
|
224
230
|
title: z.string().optional().describe("Updated title"),
|
|
225
231
|
stageId: z.string().optional().describe("Move to a new stage UUID"),
|
|
@@ -253,7 +259,7 @@ export function registerDealTools(server, client) {
|
|
|
253
259
|
const result = await client.del(`/api/v1/deals/${encodeURIComponent(id)}`);
|
|
254
260
|
return formatResult(result);
|
|
255
261
|
});
|
|
256
|
-
server.tool("conduyt_import_deals", "Bulk-import deals from a list of rows in one call. Runs on the canonical import engine — pipelines and stages are resolved by NAME (create them first with conduyt_create_pipeline), contacts by email. Deduplicates on title + pipeline + contact, and intentionally does NOT fire deal-created automations/webhooks/SMS/email (bulk imports are side-effect-free by design). Requires an owner/admin API key. Returns the created/skipped/duplicate counts and any per-row errors.", {
|
|
262
|
+
server.tool("conduyt_import_deals", "Bulk-import deals from a list of rows in one call. Runs on the canonical import engine — pipelines and stages are resolved by NAME (create them first with conduyt_create_pipeline), contacts by email. Deduplicates on title + pipeline + contact, and intentionally does NOT fire deal-created automations/webhooks/SMS/email (bulk imports are side-effect-free by design). Requires an owner/admin API key. Returns the created/skipped/duplicate counts and any per-row errors. A CONTACTS import job run (POST /imports/{id}/process or /resume, same refusal; the server documents this refusal for a contacts file only, and this tool imports opportunities, so it is not refused with it here) can be refused 422 import_nothing_ready { readyCount: 0, blockedCount, reasons: [{ code: required_field | missing_identifier | invalid_email, label, rowCount }] (most frequent first) } when the job has NO row that can import (every row misses a required field or fails an identifier rule: no name, email or phone, or an invalid email): refused before the first write, the job is left as it is; fix the rows and import again.", {
|
|
257
263
|
deals: z
|
|
258
264
|
.array(z.object({
|
|
259
265
|
title: z.string().describe("Deal title (required)"),
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* (parity31, batch31 #1292 Ship 4 + Ship 2) Formula custom fields, the Secure identifier rule and the binding's secureEgress list,
|
|
3
|
+
* checked before the request leaves (the server stays the authority; every answer carries its stable code).
|
|
4
|
+
*/
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
export declare const FORMULA_OPS: readonly ["add", "sub", "mul", "div"];
|
|
7
|
+
export declare const FORMULA_FORMATS: readonly ["number", "currency", "percent"];
|
|
8
|
+
/** every fieldType the custom-fields route accepts for a definition (the server's create enum, batch31) */
|
|
9
|
+
export declare const CUSTOM_FIELD_TYPES: readonly ["text", "textarea", "number", "date", "datetime", "url", "select", "radio", "multiselect", "boolean", "phone", "email", "formula", "user"];
|
|
10
|
+
export declare const DEAL_OES_KEYS: readonly ["oes_number", "dpp_oes_raw"];
|
|
11
|
+
/** (parity32, batch32 delseam1286) the Delancey Street deal ID the partner push writes on the card: a partner identifier too (never Secure), and a RESERVED deal key */
|
|
12
|
+
export declare const DELANCEY_ID_KEY = "delancey_deal_id";
|
|
13
|
+
export declare const DELANCEY_ID_NOTE = "delancey_deal_id (the deal field the Delancey Street push writes, the card's link to the partner) is RESERVED: it can never be created through custom-fields (422 reserved_field_key), never made Secure (422 secure_identifier_refused), and a definition that already exists is never renamed, retyped, made required or deleted (422 reserved_field_key; only its section and sortOrder change); while a legacy definition of it is Secure its value is masked to the last 4.";
|
|
14
|
+
/** one description sentence for every record write that could carry a formula key */
|
|
15
|
+
export declare const FORMULA_WRITE_NOTE = "A customFields key that is a FORMULA field (computed at read time, never stored) is refused: 422 formula_read_only.";
|
|
16
|
+
/** one description sentence for every filter that could name a formula key */
|
|
17
|
+
export declare const FORMULA_FILTER_NOTE = "A filter naming a FORMULA custom field is refused: 422 formula_not_filterable (formulas are not filterable in v1).";
|
|
18
|
+
/** the definition-side rules, shared by the create and update tool descriptions */
|
|
19
|
+
export declare const FORMULA_DEFINITION_NOTE = "fieldType formula (#1292) is a COMPUTED field: options { op: add|sub|mul|div, left: <number field key>, right: <number field key or a number>, format: number|currency|percent }; left and right are number fields of the SAME entity (never the formula itself or another formula); the value is computed at read time (never stored), blank when an input is blank and on a division by zero; every record answer carries it in customFields plus computedFields[key] = { computed: true, readOnly: true, format }. A formula is read-only on every write path (422 formula_read_only), not filterable (422 formula_not_filterable), never required, and an input that is Secure needs a Secure formula (422 formula_secure_input; turning Secure on for an input a non-Secure formula computes from is 409 formula_secure_input naming the formulas). A formula needs a FRESH key (409 formula_key_in_use); malformed options, a non-number / formula / self input or a system-owned key is 422 formula_invalid. Deleting a field a formula computes from is 409 deletion_blocked (the formula in blockers).";
|
|
20
|
+
export declare const SECURE_IDENTIFIER_NOTE = "A phone or email field, or a deal partner identifier (the OES # keys oes_number, dpp_oes_raw; the Delancey Street deal ID delancey_deal_id), identifies the record and can never be Secure: isSecure true on one is 422 secure_identifier_refused.";
|
|
21
|
+
/** the server's formula options object, strict */
|
|
22
|
+
export declare const formulaOptionsSchema: z.ZodObject<{
|
|
23
|
+
op: z.ZodEnum<["add", "sub", "mul", "div"]>;
|
|
24
|
+
left: z.ZodString;
|
|
25
|
+
right: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
|
26
|
+
format: z.ZodEnum<["number", "currency", "percent"]>;
|
|
27
|
+
}, "strict", z.ZodTypeAny, {
|
|
28
|
+
op: "add" | "sub" | "mul" | "div";
|
|
29
|
+
left: string;
|
|
30
|
+
right: string | number;
|
|
31
|
+
format: "number" | "currency" | "percent";
|
|
32
|
+
}, {
|
|
33
|
+
op: "add" | "sub" | "mul" | "div";
|
|
34
|
+
left: string;
|
|
35
|
+
right: string | number;
|
|
36
|
+
format: "number" | "currency" | "percent";
|
|
37
|
+
}>;
|
|
38
|
+
/** create: a formula carries its options object (never required); any other type never takes that object. Returns an error text or null */
|
|
39
|
+
export declare function formulaCreateProblem(p: {
|
|
40
|
+
fieldType?: unknown;
|
|
41
|
+
options?: unknown;
|
|
42
|
+
isRequired?: unknown;
|
|
43
|
+
isSecure?: unknown;
|
|
44
|
+
entityType?: unknown;
|
|
45
|
+
fieldKey?: unknown;
|
|
46
|
+
}): string | null;
|
|
47
|
+
/** update: a formula-shaped options object gets the shape check; any other option object (numberFormat, currencyCode, ...) goes to the server untouched */
|
|
48
|
+
export declare function formulaUpdateProblem(p: {
|
|
49
|
+
options?: unknown;
|
|
50
|
+
}): string | null;
|
|
51
|
+
/** the binding's secureEgress, in the two shapes the server accepts (batch32, per partner): an OBJECT { creditors_relief: string[], delancey_street: string[] } (each list optional,
|
|
52
|
+
* no other key) or the older flat ARRAY (= the Creditors Relief list only). Each list: at most 100 field keys, none twice within the list. Returns an error text or null */
|
|
53
|
+
export declare const SECURE_EGRESS_MAX = 100;
|
|
54
|
+
export declare const SECURE_EGRESS_PARTNERS: readonly ["creditors_relief", "delancey_street"];
|
|
55
|
+
export declare function secureEgressProblem(binding: Record<string, unknown>): string | null;
|
|
56
|
+
export declare const fail: (text: string) => {
|
|
57
|
+
content: {
|
|
58
|
+
type: "text";
|
|
59
|
+
text: string;
|
|
60
|
+
}[];
|
|
61
|
+
isError: boolean;
|
|
62
|
+
};
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* (parity31, batch31 #1292 Ship 4 + Ship 2) Formula custom fields, the Secure identifier rule and the binding's secureEgress list,
|
|
3
|
+
* checked before the request leaves (the server stays the authority; every answer carries its stable code).
|
|
4
|
+
*/
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
const KEY_RE = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
7
|
+
export const FORMULA_OPS = ["add", "sub", "mul", "div"];
|
|
8
|
+
export const FORMULA_FORMATS = ["number", "currency", "percent"];
|
|
9
|
+
/** every fieldType the custom-fields route accepts for a definition (the server's create enum, batch31) */
|
|
10
|
+
export const CUSTOM_FIELD_TYPES = ["text", "textarea", "number", "date", "datetime", "url", "select", "radio", "multiselect", "boolean", "phone", "email", "formula", "user"];
|
|
11
|
+
export const DEAL_OES_KEYS = ["oes_number", "dpp_oes_raw"];
|
|
12
|
+
/** (parity32, batch32 delseam1286) the Delancey Street deal ID the partner push writes on the card: a partner identifier too (never Secure), and a RESERVED deal key */
|
|
13
|
+
export const DELANCEY_ID_KEY = "delancey_deal_id";
|
|
14
|
+
export const DELANCEY_ID_NOTE = "delancey_deal_id (the deal field the Delancey Street push writes, the card's link to the partner) is RESERVED: it can never be created through custom-fields (422 reserved_field_key), never made Secure (422 secure_identifier_refused), and a definition that already exists is never renamed, retyped, made required or deleted (422 reserved_field_key; only its section and sortOrder change); while a legacy definition of it is Secure its value is masked to the last 4.";
|
|
15
|
+
/** one description sentence for every record write that could carry a formula key */
|
|
16
|
+
export const FORMULA_WRITE_NOTE = "A customFields key that is a FORMULA field (computed at read time, never stored) is refused: 422 formula_read_only.";
|
|
17
|
+
/** one description sentence for every filter that could name a formula key */
|
|
18
|
+
export const FORMULA_FILTER_NOTE = "A filter naming a FORMULA custom field is refused: 422 formula_not_filterable (formulas are not filterable in v1).";
|
|
19
|
+
/** the definition-side rules, shared by the create and update tool descriptions */
|
|
20
|
+
export const FORMULA_DEFINITION_NOTE = "fieldType formula (#1292) is a COMPUTED field: options { op: add|sub|mul|div, left: <number field key>, right: <number field key or a number>, format: number|currency|percent }; left and right are number fields of the SAME entity (never the formula itself or another formula); the value is computed at read time (never stored), blank when an input is blank and on a division by zero; every record answer carries it in customFields plus computedFields[key] = { computed: true, readOnly: true, format }. A formula is read-only on every write path (422 formula_read_only), not filterable (422 formula_not_filterable), never required, and an input that is Secure needs a Secure formula (422 formula_secure_input; turning Secure on for an input a non-Secure formula computes from is 409 formula_secure_input naming the formulas). A formula needs a FRESH key (409 formula_key_in_use); malformed options, a non-number / formula / self input or a system-owned key is 422 formula_invalid. Deleting a field a formula computes from is 409 deletion_blocked (the formula in blockers).";
|
|
21
|
+
export const SECURE_IDENTIFIER_NOTE = "A phone or email field, or a deal partner identifier (the OES # keys oes_number, dpp_oes_raw; the Delancey Street deal ID delancey_deal_id), identifies the record and can never be Secure: isSecure true on one is 422 secure_identifier_refused.";
|
|
22
|
+
const inputKey = z.string().trim().min(1).max(120).regex(KEY_RE);
|
|
23
|
+
/** the server's formula options object, strict */
|
|
24
|
+
export const formulaOptionsSchema = z.object({
|
|
25
|
+
op: z.enum(FORMULA_OPS),
|
|
26
|
+
left: inputKey,
|
|
27
|
+
right: z.union([inputKey, z.number().finite()]),
|
|
28
|
+
format: z.enum(FORMULA_FORMATS),
|
|
29
|
+
}).strict();
|
|
30
|
+
/** the server's four formula option keys; its other object shapes (choices, options, numberFormat, currencyCode, allowedDomains, blockedDomains, visibility) never use them */
|
|
31
|
+
const FORMULA_KEYS = ["op", "left", "right", "format"];
|
|
32
|
+
const isFormulaShaped = (o) => o !== null && typeof o === "object" && !Array.isArray(o) && Object.keys(o).some((k) => FORMULA_KEYS.includes(k));
|
|
33
|
+
/** create: a formula carries its options object (never required); any other type never takes that object. Returns an error text or null */
|
|
34
|
+
export function formulaCreateProblem(p) {
|
|
35
|
+
const isObj = isFormulaShaped(p.options);
|
|
36
|
+
if (p.fieldType === "formula") {
|
|
37
|
+
const r = formulaOptionsSchema.safeParse(p.options);
|
|
38
|
+
if (!r.success)
|
|
39
|
+
return `A formula needs options { op: ${FORMULA_OPS.join("|")}, left: <field key>, right: <field key or a number>, format: ${FORMULA_FORMATS.join("|")} } and nothing else (422 formula_invalid).`;
|
|
40
|
+
if (p.isRequired === true)
|
|
41
|
+
return "A formula is computed, never required (422 formula_invalid).";
|
|
42
|
+
}
|
|
43
|
+
else if (isObj) {
|
|
44
|
+
return "The formula options object is accepted only with fieldType formula (otherwise 422 formula_invalid); select options are an array.";
|
|
45
|
+
}
|
|
46
|
+
if (p.isSecure === true) {
|
|
47
|
+
const partnerId = p.entityType === "deal" && typeof p.fieldKey === "string" && (DEAL_OES_KEYS.includes(p.fieldKey) || p.fieldKey === DELANCEY_ID_KEY);
|
|
48
|
+
if (p.fieldType === "phone" || p.fieldType === "email" || partnerId)
|
|
49
|
+
return "A phone or email field, or a deal partner identifier (the OES # keys oes_number, dpp_oes_raw; the Delancey Street deal ID delancey_deal_id), identifies the record and can never be Secure (422 secure_identifier_refused).";
|
|
50
|
+
}
|
|
51
|
+
// (parity32) delancey_deal_id on deals is written by the Delancey Street push only: a create naming it is 422 reserved_field_key (the server judges it after the Secure rule above)
|
|
52
|
+
if (p.entityType === "deal" && p.fieldKey === DELANCEY_ID_KEY)
|
|
53
|
+
return `"${DELANCEY_ID_KEY}" is the Delancey Street deal ID the partner push writes: its definition cannot be created here (422 reserved_field_key).`;
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
/** update: a formula-shaped options object gets the shape check; any other option object (numberFormat, currencyCode, ...) goes to the server untouched */
|
|
57
|
+
export function formulaUpdateProblem(p) {
|
|
58
|
+
if (isFormulaShaped(p.options) && !formulaOptionsSchema.safeParse(p.options).success)
|
|
59
|
+
return `A formula's options are { op: ${FORMULA_OPS.join("|")}, left: <field key>, right: <field key or a number>, format: ${FORMULA_FORMATS.join("|")} } and nothing else (422 formula_invalid).`;
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
/** the binding's secureEgress, in the two shapes the server accepts (batch32, per partner): an OBJECT { creditors_relief: string[], delancey_street: string[] } (each list optional,
|
|
63
|
+
* no other key) or the older flat ARRAY (= the Creditors Relief list only). Each list: at most 100 field keys, none twice within the list. Returns an error text or null */
|
|
64
|
+
export const SECURE_EGRESS_MAX = 100;
|
|
65
|
+
export const SECURE_EGRESS_PARTNERS = ["creditors_relief", "delancey_street"];
|
|
66
|
+
const EGRESS_KEY_RE = /^[a-zA-Z_][a-zA-Z0-9_]{0,99}$/;
|
|
67
|
+
function egressListProblem(list, where) {
|
|
68
|
+
if (list.length > SECURE_EGRESS_MAX)
|
|
69
|
+
return `${where} holds at most ${SECURE_EGRESS_MAX} keys.`;
|
|
70
|
+
const seen = new Set();
|
|
71
|
+
for (let i = 0; i < list.length; i++) {
|
|
72
|
+
const k = list[i];
|
|
73
|
+
if (typeof k !== "string" || !EGRESS_KEY_RE.test(k))
|
|
74
|
+
return `${where}[${i}] must be a custom field key (letters, digits, underscores, not starting with a digit; at most 100 characters).`;
|
|
75
|
+
if (seen.has(k))
|
|
76
|
+
return `${where}[${i}] (${k}) is listed twice.`;
|
|
77
|
+
seen.add(k);
|
|
78
|
+
}
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
export function secureEgressProblem(binding) {
|
|
82
|
+
const e = binding.secureEgress;
|
|
83
|
+
if (e === undefined)
|
|
84
|
+
return null;
|
|
85
|
+
if (Array.isArray(e))
|
|
86
|
+
return egressListProblem(e, "secureEgress");
|
|
87
|
+
if (e === null || typeof e !== "object")
|
|
88
|
+
return "secureEgress must be an object per partner { creditors_relief: [keys], delancey_street: [keys] } (or the older flat array of keys, read as Creditors Relief only).";
|
|
89
|
+
for (const k of Object.keys(e))
|
|
90
|
+
if (!SECURE_EGRESS_PARTNERS.includes(k))
|
|
91
|
+
return `secureEgress may only hold ${SECURE_EGRESS_PARTNERS.join(" and ")} (got ${JSON.stringify(k)}).`;
|
|
92
|
+
for (const p of SECURE_EGRESS_PARTNERS) {
|
|
93
|
+
const list = e[p];
|
|
94
|
+
if (list === undefined)
|
|
95
|
+
continue;
|
|
96
|
+
if (!Array.isArray(list))
|
|
97
|
+
return `secureEgress.${p} must be an array of Secure custom field keys.`;
|
|
98
|
+
const problem = egressListProblem(list, `secureEgress.${p}`);
|
|
99
|
+
if (problem)
|
|
100
|
+
return problem;
|
|
101
|
+
}
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
export const fail = (text) => ({ content: [{ type: "text", text }], isError: true });
|
package/dist/tools/lead-pool.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
import { FORMULA_FILTER_NOTE } from "./formula-fields.js";
|
|
3
|
+
import { TIMEZONE_FILTER_NOTE } from "./lender-options.js";
|
|
2
4
|
import { formatResult } from "../client.js";
|
|
3
5
|
import { patchGeneralSettings } from "./lifecycle.js";
|
|
4
6
|
import { validateAdvancedFiltersEffective } from "./advanced-filter-rules.js";
|
|
@@ -117,7 +119,7 @@ export function registerLeadPoolTools(server, client) {
|
|
|
117
119
|
}
|
|
118
120
|
return formatResult({ data: { sets: rows, pageVersion: version } });
|
|
119
121
|
});
|
|
120
|
-
server.tool("conduyt_create_pool_filter_set", "Add a named filter set to a pool page (admin only). A new set is a DRAFT (off) unless isEnabled is true. Enabling a set that would OPEN the whole page (no rule) is refused with 409 pool_opens unless acknowledgeOpensPool is true. Every tag name a rule carries must be a live tag (422 tag_missing); a custom field must exist (422 custom_field_missing). pageVersion is the one your list read answered (409 page_version_stale when the page moved since: re-list and retry).", {
|
|
122
|
+
server.tool("conduyt_create_pool_filter_set", "Add a named filter set to a pool page (admin only). A new set is a DRAFT (off) unless isEnabled is true. Enabling a set that would OPEN the whole page (no rule) is refused with 409 pool_opens unless acknowledgeOpensPool is true. Every tag name a rule carries must be a live tag (422 tag_missing); a custom field must exist (422 custom_field_missing). pageVersion is the one your list read answered (409 page_version_stale when the page moved since: re-list and retry)." + " " + FORMULA_FILTER_NOTE + " " + TIMEZONE_FILTER_NOTE, {
|
|
121
123
|
page: poolPage,
|
|
122
124
|
name: setName,
|
|
123
125
|
filters: filtersSchema,
|
|
@@ -129,7 +131,7 @@ export function registerLeadPoolTools(server, client) {
|
|
|
129
131
|
...(isEnabled !== undefined ? { isEnabled } : {}),
|
|
130
132
|
...(acknowledgeOpensPool !== undefined ? { acknowledgeOpensPool } : {}),
|
|
131
133
|
})));
|
|
132
|
-
server.tool("conduyt_update_pool_filter_set", "Rename, refilter, enable / disable or reorder a pool filter set (admin only). Pass only what changes. Switching a set on or changing its rules reconciles the open offers the page no longer shows; a change that OPENS the whole page needs acknowledgeOpensPool. pageVersion is the one your list read answered for the set's page (409 page_version_stale when the page moved since: re-list and retry).", {
|
|
134
|
+
server.tool("conduyt_update_pool_filter_set", "Rename, refilter, enable / disable or reorder a pool filter set (admin only). Pass only what changes. Switching a set on or changing its rules reconciles the open offers the page no longer shows; a change that OPENS the whole page needs acknowledgeOpensPool. pageVersion is the one your list read answered for the set's page (409 page_version_stale when the page moved since: re-list and retry)." + " " + FORMULA_FILTER_NOTE + " " + TIMEZONE_FILTER_NOTE, {
|
|
133
135
|
id: z.string().uuid().describe("The set's UUID"),
|
|
134
136
|
name: setName.optional(),
|
|
135
137
|
filters: filtersSchema.optional(),
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* (parity32, batch32 lenderv1 #1307 + tz1312 #1312) The select-type option cap, the guarded text -> select type change, the write-path
|
|
3
|
+
* fence for off-list values, and the timezone filter field, named once so every tool description carries the same sentences
|
|
4
|
+
* (the server stays the authority).
|
|
5
|
+
*/
|
|
6
|
+
export declare const OPTIONS_MAX = 1000;
|
|
7
|
+
export declare const OPTION_LABEL_MAX = 200;
|
|
8
|
+
export declare const OPTIONS_CAP_NOTE = "A select / radio / multiselect field holds up to 1000 options (each 1 to 200 characters, trimmed); options is an array, so a name with a comma (\"Dlp Funding, LLC\") is ONE option (only the web editor's box is one option per line).";
|
|
9
|
+
export declare const TYPE_CHANGE_NOTE = "A guarded TYPE CHANGE exists on the API (PATCH /custom-fields/{id} with fieldType select + options, optionally confirmOffListValues): a TEXT field becomes a select with that list (an existing select just takes the new list; nothing else changes beside it, the key never changes, the audit row keeps the before and after definition, there is no way back to text). It is for an owner or admin SIGNED IN, never an API key or an AI teammate, so it answers 403 field_type_change_forbidden here: there is no input for it on this tool. Its other refusals: 422 field_type_change_refused (a system field, a non-text field, an OES # key, an empty or repeating list); 409 field_type_change_off_list_unconfirmed (records hold a value not on the new list: they keep it, but it cannot be saved again; resend with confirmOffListValues true); 422 when fieldType comes with anything but options and confirmOffListValues, or confirmOffListValues without fieldType.";
|
|
10
|
+
export declare const OFF_LIST_NOTE = "A customFields value for a SELECT field (a lender dropdown is one) must be one of the field's options: another value is 422 `Invalid custom field values: <field label>` (no code; the answer's invalidFieldKeys names the key). A stored value that is no longer on the list (a text field became a select) stays readable, a write of OTHER keys never re-judges it, and an unchanged re-send of it is accepted; only a DIFFERENT off-list value is refused.";
|
|
11
|
+
export declare const TIMEZONE_FILTER_NOTE = "Advanced Filters field `timezone` (the contact's IANA zone, e.g. America/Chicago; options from conduyt_list_contact_timezones) takes is / is not / is any of / is none of / is empty / is not empty, an exact case-sensitive match on the stored zone (is not / is none of keep only contacts WITH a zone: ask for the unknown ones with is empty).";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* (parity32, batch32 lenderv1 #1307 + tz1312 #1312) The select-type option cap, the guarded text -> select type change, the write-path
|
|
3
|
+
* fence for off-list values, and the timezone filter field, named once so every tool description carries the same sentences
|
|
4
|
+
* (the server stays the authority).
|
|
5
|
+
*/
|
|
6
|
+
export const OPTIONS_MAX = 1000;
|
|
7
|
+
export const OPTION_LABEL_MAX = 200;
|
|
8
|
+
export const OPTIONS_CAP_NOTE = `A select / radio / multiselect field holds up to ${OPTIONS_MAX} options (each 1 to ${OPTION_LABEL_MAX} characters, trimmed); options is an array, so a name with a comma ("Dlp Funding, LLC") is ONE option (only the web editor's box is one option per line).`;
|
|
9
|
+
export const TYPE_CHANGE_NOTE = "A guarded TYPE CHANGE exists on the API (PATCH /custom-fields/{id} with fieldType select + options, optionally confirmOffListValues): a TEXT field becomes a select with that list (an existing select just takes the new list; nothing else changes beside it, the key never changes, the audit row keeps the before and after definition, there is no way back to text). It is for an owner or admin SIGNED IN, never an API key or an AI teammate, so it answers 403 field_type_change_forbidden here: there is no input for it on this tool. Its other refusals: 422 field_type_change_refused (a system field, a non-text field, an OES # key, an empty or repeating list); 409 field_type_change_off_list_unconfirmed (records hold a value not on the new list: they keep it, but it cannot be saved again; resend with confirmOffListValues true); 422 when fieldType comes with anything but options and confirmOffListValues, or confirmOffListValues without fieldType.";
|
|
10
|
+
export const OFF_LIST_NOTE = "A customFields value for a SELECT field (a lender dropdown is one) must be one of the field's options: another value is 422 `Invalid custom field values: <field label>` (no code; the answer's invalidFieldKeys names the key). A stored value that is no longer on the list (a text field became a select) stays readable, a write of OTHER keys never re-judges it, and an unchanged re-send of it is accepted; only a DIFFERENT off-list value is refused.";
|
|
11
|
+
export const TIMEZONE_FILTER_NOTE = "Advanced Filters field `timezone` (the contact's IANA zone, e.g. America/Chicago; options from conduyt_list_contact_timezones) takes is / is not / is any of / is none of / is empty / is not empty, an exact case-sensitive match on the stored zone (is not / is none of keep only contacts WITH a zone: ask for the unknown ones with is empty).";
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
import { FORMULA_FILTER_NOTE } from "./formula-fields.js";
|
|
3
|
+
import { TIMEZONE_FILTER_NOTE } from "./lender-options.js";
|
|
2
4
|
import { formatResult } from "../client.js";
|
|
3
5
|
/**
|
|
4
6
|
* Personal saved filters for list pages (Velocify-style). Strictly
|
|
@@ -45,7 +47,7 @@ export function registerSavedFilterTools(server, client) {
|
|
|
45
47
|
const result = await client.get(`/api/v1/saved-filters${qs ? `?${qs}` : ""}`);
|
|
46
48
|
return formatResult(result);
|
|
47
49
|
});
|
|
48
|
-
server.tool("conduyt_create_saved_filter", "Save a named contact filter for one-click re-use — e.g. \"save a filter for Heather's Facebook leads\". Since 2026-09-24 a saved filter IS a personal Smart View (the Smart Views tab), private to the key's user for every role (max 50 per user). Requires the 'saved-filters' scope.", {
|
|
50
|
+
server.tool("conduyt_create_saved_filter", "Save a named contact filter for one-click re-use — e.g. \"save a filter for Heather's Facebook leads\". Since 2026-09-24 a saved filter IS a personal Smart View (the Smart Views tab), private to the key's user for every role (max 50 per user). Requires the 'saved-filters' scope." + " " + FORMULA_FILTER_NOTE + " " + TIMEZONE_FILTER_NOTE, {
|
|
49
51
|
name: z.string().min(1).max(60).describe("Display name shown in the Saved dropdown (unique per user, max 60 chars)"),
|
|
50
52
|
filters: filtersSchema,
|
|
51
53
|
sortField: z.string().optional().describe("Sort field applied with the filter (default createdAt)"),
|
|
@@ -59,7 +61,7 @@ export function registerSavedFilterTools(server, client) {
|
|
|
59
61
|
const result = await client.post("/api/v1/smart-views", { name: params.name, filters: params.filters, sortField: params.sortField, sortOrder: params.sortOrder, icon: params.icon, personal: true });
|
|
60
62
|
return formatResult(result);
|
|
61
63
|
});
|
|
62
|
-
server.tool("conduyt_update_saved_filter", "Rename a saved filter (a personal Smart View) or replace its filters/sort. Owner-only — a personal view is its owner's for every role. Use conduyt_list_saved_filters or conduyt_list_smart_views to find the id. Requires the 'saved-filters' scope.", {
|
|
64
|
+
server.tool("conduyt_update_saved_filter", "Rename a saved filter (a personal Smart View) or replace its filters/sort. Owner-only — a personal view is its owner's for every role. Use conduyt_list_saved_filters or conduyt_list_smart_views to find the id. Requires the 'saved-filters' scope." + " " + FORMULA_FILTER_NOTE + " " + TIMEZONE_FILTER_NOTE, {
|
|
63
65
|
id: z.string().uuid().describe("Saved filter UUID (from conduyt_list_saved_filters)"),
|
|
64
66
|
name: z.string().min(1).max(60).optional().describe("New display name (unique per user)"),
|
|
65
67
|
filters: filtersSchema,
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
import { TIMEZONE_FILTER_NOTE } from "./lender-options.js";
|
|
2
3
|
import { formatResult } from "../client.js";
|
|
4
|
+
import { FORMULA_FILTER_NOTE } from "./formula-fields.js";
|
|
3
5
|
export function registerSmartListTools(server, client) {
|
|
4
6
|
server.tool("conduyt_list_smart_lists", "List all smart lists (segments) with contact counts.", {}, async () => {
|
|
5
7
|
const result = await client.get("/api/v1/smart-lists");
|
|
@@ -11,7 +13,7 @@ export function registerSmartListTools(server, client) {
|
|
|
11
13
|
const result = await client.get(`/api/v1/smart-lists/${id}`);
|
|
12
14
|
return formatResult(result);
|
|
13
15
|
});
|
|
14
|
-
server.tool("conduyt_create_smart_list", "Create a new smart list (segment). Static lists have manually added contacts; dynamic lists use filter rules.", {
|
|
16
|
+
server.tool("conduyt_create_smart_list", "Create a new smart list (segment). Static lists have manually added contacts; dynamic lists use filter rules." + " " + FORMULA_FILTER_NOTE + " " + TIMEZONE_FILTER_NOTE, {
|
|
15
17
|
name: z.string().describe("Smart list name"),
|
|
16
18
|
description: z.string().optional().describe("Description"),
|
|
17
19
|
type: z.enum(["static", "dynamic"]).optional().describe("List type — 'static' (manual) or 'dynamic' (filter-based). Default: static"),
|
|
@@ -20,7 +22,7 @@ export function registerSmartListTools(server, client) {
|
|
|
20
22
|
const result = await client.post("/api/v1/smart-lists", params);
|
|
21
23
|
return formatResult(result);
|
|
22
24
|
});
|
|
23
|
-
server.tool("conduyt_update_smart_list", "Update a smart list's name, description, type, or filters.", {
|
|
25
|
+
server.tool("conduyt_update_smart_list", "Update a smart list's name, description, type, or filters." + " " + FORMULA_FILTER_NOTE + " " + TIMEZONE_FILTER_NOTE, {
|
|
24
26
|
id: z.string().describe("Smart list UUID"),
|
|
25
27
|
name: z.string().optional().describe("Updated name"),
|
|
26
28
|
description: z.string().optional().describe("Updated description"),
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const USER_FIELD_READ_DOC = " User fields (#1303): a custom field of fieldType user holds a user id of the workspace; the answer carries customFieldUsers ({ userId (lowercase): \"First Last\" }) naming the people its user fields hold (a value that names no member of the workspace is absent from the map).";
|
|
2
|
+
export declare const USER_FIELD_WRITE_DOC = " A USER custom field (fieldType user) takes a user id of the workspace (null clears); an id outside the workspace is 422 user_not_in_account. An owner change (assignedTo) also stamps the new owner's ROLE field when the workspace's settings.dealProfile.roleStamping maps their group (each rule's mode decides: first = never replaced once set, latest = the newest owner of the group wins; never blanked; a role key set in the same request is kept as sent).";
|
|
3
|
+
export declare const USER_NOTE = " USER fields (fieldType user): the value is a user id of the workspace (record writes refuse an id outside it: 422 user_not_in_account; the inbound webhooks and the import also accept an exact \"First Last\" or the user's e-mail); a user field takes no options (422). Changing a TEXT field into a user field (PATCH fieldType user, a DEAL field only; confirmDependencies true to accept the references that read it as text, else 409 field_type_change_dependencies_unconfirmed; 422 field_type_change_refused) is a signed-in owner / admin action in the app only: an API key is refused 403 field_type_change_forbidden, so there is no input for it on these tools. A user value is a lowercase member id of the workspace (an empty array is refused); the type change is allowed on DEAL fields only (422 on a contact or company field). Automation steps update_contact_field, math_operation, ai_compose_email and update_deal_field refuse a non-member with 422 user_not_in_account. A deal create can answer 422 \"The custom fields changed while saving\" when a field's type changed meanwhile: re-read the definitions and retry.";
|
|
4
|
+
/** contacts and companies: a user field is written by user id too (the role stamp is a deal-owner rule only) */
|
|
5
|
+
export declare const USER_FIELD_RECORD_WRITE_DOC = " A USER custom field (fieldType user) takes a user id of the workspace (null clears); an id outside the workspace is 422 user_not_in_account.";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// (userfield1303, batch32 #1303) USER custom fields and the card role stamp, named once for the record get / update tools and the definition tools
|
|
2
|
+
export const USER_FIELD_READ_DOC = " User fields (#1303): a custom field of fieldType user holds a user id of the workspace; the answer carries customFieldUsers ({ userId (lowercase): \"First Last\" }) naming the people its user fields hold (a value that names no member of the workspace is absent from the map).";
|
|
3
|
+
export const USER_FIELD_WRITE_DOC = " A USER custom field (fieldType user) takes a user id of the workspace (null clears); an id outside the workspace is 422 user_not_in_account. An owner change (assignedTo) also stamps the new owner's ROLE field when the workspace's settings.dealProfile.roleStamping maps their group (each rule's mode decides: first = never replaced once set, latest = the newest owner of the group wins; never blanked; a role key set in the same request is kept as sent).";
|
|
4
|
+
export const USER_NOTE = " USER fields (fieldType user): the value is a user id of the workspace (record writes refuse an id outside it: 422 user_not_in_account; the inbound webhooks and the import also accept an exact \"First Last\" or the user's e-mail); a user field takes no options (422). Changing a TEXT field into a user field (PATCH fieldType user, a DEAL field only; confirmDependencies true to accept the references that read it as text, else 409 field_type_change_dependencies_unconfirmed; 422 field_type_change_refused) is a signed-in owner / admin action in the app only: an API key is refused 403 field_type_change_forbidden, so there is no input for it on these tools. A user value is a lowercase member id of the workspace (an empty array is refused); the type change is allowed on DEAL fields only (422 on a contact or company field). Automation steps update_contact_field, math_operation, ai_compose_email and update_deal_field refuse a non-member with 422 user_not_in_account. A deal create can answer 422 \"The custom fields changed while saving\" when a field's type changed meanwhile: re-read the definitions and retry.";
|
|
5
|
+
/** contacts and companies: a user field is written by user id too (the role stamp is a deal-owner rule only) */
|
|
6
|
+
export const USER_FIELD_RECORD_WRITE_DOC = " A USER custom field (fieldType user) takes a user id of the workspace (null clears); an id outside the workspace is 422 user_not_in_account.";
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
|
-
"generatedAt": "2026-11-
|
|
3
|
-
"toolCount":
|
|
4
|
-
"totalEndpoints":
|
|
2
|
+
"generatedAt": "2026-11-13T12:08:25.855Z",
|
|
3
|
+
"toolCount": 430,
|
|
4
|
+
"totalEndpoints": 1208,
|
|
5
5
|
"counts": {
|
|
6
|
-
"covered":
|
|
6
|
+
"covered": 379,
|
|
7
7
|
"excluded": 372,
|
|
8
8
|
"planned": 457,
|
|
9
9
|
"uncategorized": 0
|
|
@@ -1966,6 +1966,12 @@
|
|
|
1966
1966
|
"status": "planned",
|
|
1967
1967
|
"reason": "contact subroutes beyond the core CRUD/search tools"
|
|
1968
1968
|
},
|
|
1969
|
+
"GET /api/v1/contacts/timezones": {
|
|
1970
|
+
"status": "covered",
|
|
1971
|
+
"tools": [
|
|
1972
|
+
"conduyt_list_contact_timezones"
|
|
1973
|
+
]
|
|
1974
|
+
},
|
|
1969
1975
|
"POST /api/v1/contacts/verify-line-type": {
|
|
1970
1976
|
"status": "covered",
|
|
1971
1977
|
"tools": [
|
|
@@ -2501,7 +2507,8 @@
|
|
|
2501
2507
|
"POST /api/v1/custom-fields": {
|
|
2502
2508
|
"status": "covered",
|
|
2503
2509
|
"tools": [
|
|
2504
|
-
"conduyt_create_custom_field"
|
|
2510
|
+
"conduyt_create_custom_field",
|
|
2511
|
+
"conduyt_create_mirror_field"
|
|
2505
2512
|
]
|
|
2506
2513
|
},
|
|
2507
2514
|
"GET /api/v1/custom-fields/:id": {
|