conduyt-mcp 4.105.26 → 4.105.29
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 +5 -0
- package/dist/tools/advanced-filter-rules.d.ts +1 -1
- package/dist/tools/advanced-filter-rules.js +1 -1
- package/dist/tools/ai-teammate-connect.d.ts +6 -4
- package/dist/tools/ai-teammate-connect.js +26 -20
- package/dist/tools/bulk.js +4 -1
- package/dist/tools/chat.js +5 -5
- package/dist/tools/contact-timezone.d.ts +8 -0
- package/dist/tools/contact-timezone.js +49 -0
- package/dist/tools/contacts.js +1 -1
- package/dist/tools/custom-fields.js +71 -9
- package/dist/tools/deals.js +5 -2
- package/dist/tools/lender-options.d.ts +1 -1
- package/dist/tools/lender-options.js +1 -1
- package/dist/tools/routine-key-redaction.d.ts +1 -1
- package/dist/tools/routine-key-redaction.js +6 -2
- package/dist/tools/store-options.d.ts +72 -0
- package/dist/tools/store-options.js +104 -0
- package/package.json +1 -1
- package/scripts/coverage-matrix.json +37 -5
package/dist/tool-annotations.js
CHANGED
|
@@ -249,6 +249,11 @@ export const TOOL_ANNOTATIONS = {
|
|
|
249
249
|
conduyt_create_mirror_field: create("Create Deal Mirror Field"),
|
|
250
250
|
conduyt_update_custom_field: update("Update Custom Field"),
|
|
251
251
|
conduyt_delete_custom_field: destroy("Delete Custom Field"),
|
|
252
|
+
// (parity35, #1308) the list of a store-backed select: the set REPLACES the active list but never deletes a row (the others are deactivated, a repeat lands on the same state)
|
|
253
|
+
conduyt_search_custom_field_options: ro("Search Custom Field Options"),
|
|
254
|
+
conduyt_set_custom_field_options: update("Set Custom Field Options"),
|
|
255
|
+
conduyt_remove_custom_field_option: destroy("Remove Custom Field Option"),
|
|
256
|
+
conduyt_resolve_custom_field_options: ro("Resolve Custom Field Option Label"),
|
|
252
257
|
conduyt_get_contact_table_defaults: ro("Get Contact Table Defaults"),
|
|
253
258
|
conduyt_set_contact_table_defaults: update("Set Contact Table Defaults"),
|
|
254
259
|
conduyt_list_smart_lists: ro("List Smart Lists"),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
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
|
|
2
|
+
* PORTED VERBATIM from conduyt-app lib/smart-view-filters.ts @ slice B r28 (+ #1312 the timezone field, parity32; parity36: the field's VALUES now also take the group words eastern ... hawaii and unknown, a value the API compiles and this validator never inspects, so no table changed) (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 (+ #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
|
|
2
|
+
* PORTED VERBATIM from conduyt-app lib/smart-view-filters.ts @ slice B r28 (+ #1312 the timezone field, parity32; parity36: the field's VALUES now also take the group words eastern ... hawaii and unknown, a value the API compiles and this validator never inspects, so no table changed) (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.
|
|
@@ -12,16 +12,18 @@ export { hide } from "./routine-key-redaction.js";
|
|
|
12
12
|
* ONE plain sentence: the server's own (the S.3 and input sentences are written for people) or ours where its text is not one (today's
|
|
13
13
|
* production answers these paths with an HTML 404; the switch answers "Not found").
|
|
14
14
|
*/
|
|
15
|
-
export declare const OLDER_SERVER_SENTENCE = "This Conduyt server does not have the Grok Bot connection yet (it predates it); connect the teammate in Settings > AI instead.";
|
|
15
|
+
export declare const OLDER_SERVER_SENTENCE = "This Conduyt server does not have the Grok Bot / OpenClaw connection yet (it predates it); connect the teammate in Settings > AI instead.";
|
|
16
16
|
export declare const AI_OFF_SENTENCE = "AI teammates are switched off for this workspace; an owner or admin turns them on in Settings > AI.";
|
|
17
17
|
export declare const NOT_FOUND_SENTENCE = "There is no AI teammate with that id or handle in this workspace (it may have been revoked); conduyt_list_ai_teammates lists them.";
|
|
18
18
|
/** (#1153) GET /chat/agents on a server from before #1153 refuses every API key with its session-only sentence */
|
|
19
19
|
export declare const OLDER_LIST_SENTENCE = "This Conduyt server does not let an API key read the AI teammate list yet (it predates it); see the teammates in Settings > AI.";
|
|
20
|
-
export declare const TEAMMATE_KEY_SENTENCE = "This is an AI teammate's own key; connect a Grok Bot with a person's API key (an owner or admin).";
|
|
21
|
-
/** the listener-test tool's own wording: the teammate may be any listener (Claude Code, Cowork or another coding-agent listener, or a Grok Bot), so the shared
|
|
20
|
+
export declare const TEAMMATE_KEY_SENTENCE = "This is an AI teammate's own key; connect a Grok Bot or OpenClaw teammate with a person's API key (an owner or admin).";
|
|
21
|
+
/** the listener-test tool's own wording: the teammate may be any listener (Claude Code, Cowork or another coding-agent listener, or a Grok Bot or OpenClaw connector), so the shared connector sentences are not used for it */
|
|
22
22
|
export declare const LISTENER_KEY_SENTENCE = "This is an AI teammate's own key; test a teammate's connection with a person's API key (an owner or admin).";
|
|
23
23
|
export declare const LISTENER_OLDER_SERVER_SENTENCE = "This Conduyt server does not have the AI teammate connection test yet (it predates it); test the teammate in Settings > AI instead.";
|
|
24
|
-
export declare const NO_CREDENTIALS_SENTENCE = "Give the
|
|
24
|
+
export declare const NO_CREDENTIALS_SENTENCE = "Give the connector's address and key: paste (the block Grok Bot shows, or OpenClaw's hooks address and hook token), or address and key.";
|
|
25
|
+
/** (parity36b, #1137) the one sentence for a delivery an OpenClaw gateway accepted without starting a run: neither a failure nor a plain success */
|
|
26
|
+
export declare const NO_RUN_SENTENCE = "Delivered: OpenClaw's gateway accepted it (HTTP 204) and started no run, so no hello will come from this test.";
|
|
25
27
|
/** the one sentence for a refused call, and its code when the API sent one */
|
|
26
28
|
export declare function refusalOf(err: ConduytApiError): {
|
|
27
29
|
status: number | null;
|
|
@@ -14,16 +14,18 @@ export { hide } from "./routine-key-redaction.js";
|
|
|
14
14
|
* ONE plain sentence: the server's own (the S.3 and input sentences are written for people) or ours where its text is not one (today's
|
|
15
15
|
* production answers these paths with an HTML 404; the switch answers "Not found").
|
|
16
16
|
*/
|
|
17
|
-
export const OLDER_SERVER_SENTENCE = "This Conduyt server does not have the Grok Bot connection yet (it predates it); connect the teammate in Settings > AI instead.";
|
|
17
|
+
export const OLDER_SERVER_SENTENCE = "This Conduyt server does not have the Grok Bot / OpenClaw connection yet (it predates it); connect the teammate in Settings > AI instead.";
|
|
18
18
|
export const AI_OFF_SENTENCE = "AI teammates are switched off for this workspace; an owner or admin turns them on in Settings > AI.";
|
|
19
19
|
export const NOT_FOUND_SENTENCE = "There is no AI teammate with that id or handle in this workspace (it may have been revoked); conduyt_list_ai_teammates lists them.";
|
|
20
20
|
/** (#1153) GET /chat/agents on a server from before #1153 refuses every API key with its session-only sentence */
|
|
21
21
|
export const OLDER_LIST_SENTENCE = "This Conduyt server does not let an API key read the AI teammate list yet (it predates it); see the teammates in Settings > AI.";
|
|
22
|
-
export const TEAMMATE_KEY_SENTENCE = "This is an AI teammate's own key; connect a Grok Bot with a person's API key (an owner or admin).";
|
|
23
|
-
/** the listener-test tool's own wording: the teammate may be any listener (Claude Code, Cowork or another coding-agent listener, or a Grok Bot), so the shared
|
|
22
|
+
export const TEAMMATE_KEY_SENTENCE = "This is an AI teammate's own key; connect a Grok Bot or OpenClaw teammate with a person's API key (an owner or admin).";
|
|
23
|
+
/** the listener-test tool's own wording: the teammate may be any listener (Claude Code, Cowork or another coding-agent listener, or a Grok Bot or OpenClaw connector), so the shared connector sentences are not used for it */
|
|
24
24
|
export const LISTENER_KEY_SENTENCE = "This is an AI teammate's own key; test a teammate's connection with a person's API key (an owner or admin).";
|
|
25
25
|
export const LISTENER_OLDER_SERVER_SENTENCE = "This Conduyt server does not have the AI teammate connection test yet (it predates it); test the teammate in Settings > AI instead.";
|
|
26
|
-
export const NO_CREDENTIALS_SENTENCE = "Give the
|
|
26
|
+
export const NO_CREDENTIALS_SENTENCE = "Give the connector's address and key: paste (the block Grok Bot shows, or OpenClaw's hooks address and hook token), or address and key.";
|
|
27
|
+
/** (parity36b, #1137) the one sentence for a delivery an OpenClaw gateway accepted without starting a run: neither a failure nor a plain success */
|
|
28
|
+
export const NO_RUN_SENTENCE = "Delivered: OpenClaw's gateway accepted it (HTTP 204) and started no run, so no hello will come from this test.";
|
|
27
29
|
function errorDetailsOf(message) {
|
|
28
30
|
for (let i = message.indexOf("{"); i !== -1; i = message.indexOf("{", i + 1)) {
|
|
29
31
|
try {
|
|
@@ -88,10 +90,13 @@ const unwrap = (res) => (res && typeof res === "object" && "data" in res ? res.d
|
|
|
88
90
|
function testOutcome(secrets) {
|
|
89
91
|
return (res) => {
|
|
90
92
|
const d = unwrap(res);
|
|
93
|
+
// (parity36b) accepted with no run started: an ok result (not an error) that says so in its own sentence, beside the server's answer
|
|
94
|
+
if (d?.test?.ok === true && d.test.noRun === true)
|
|
95
|
+
return connectResult({ ...d, note: NO_RUN_SENTENCE }, secrets);
|
|
91
96
|
if (d?.test?.ok === true)
|
|
92
97
|
return connectResult(d, secrets);
|
|
93
98
|
const problem = d?.test?.problem;
|
|
94
|
-
return connectError(problem?.message ?? "
|
|
99
|
+
return connectError(problem?.message ?? "The connector did not accept the test.", secrets, { status: 200, ...(problem?.code ? { code: problem.code } : {}), answer: d });
|
|
95
100
|
};
|
|
96
101
|
}
|
|
97
102
|
const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
@@ -100,13 +105,13 @@ const HANDLE_RE = /^@[a-z][a-z0-9_-]{1,31}$/i;
|
|
|
100
105
|
/** (#1153) the teammate: its id (a UUID) or its @handle, lower-cased; the server resolves the handle (lib/agent-webhook-routes.ts
|
|
101
106
|
* parseTeammateRef, the one place for every surface), so nothing here looks it up */
|
|
102
107
|
const TEAMMATE_ID = z.string().trim().refine((v) => UUID_RE.test(v) || HANDLE_RE.test(v), { message: "teammateId must be the teammate's id (a UUID) or its @handle" })
|
|
103
|
-
.describe("The Grok Bot
|
|
108
|
+
.describe("The connector teammate (provider Grok Bot or OpenClaw): its id (a UUID) or its @handle, as conduyt_list_ai_teammates lists them (the agent.id of conduyt_connect_ai_teammate's answer and the senderId of its messages are the id too)");
|
|
104
109
|
/** the path segment of a teammate: trimmed and lower-cased (handles and ids are case-insensitive), an @handle travels as %40handle */
|
|
105
110
|
const seg = (teammateId) => encodeURIComponent(teammateId.trim().toLowerCase());
|
|
106
|
-
const WHO = "Owners and admins, with a person's API key (the chat scope); an AI teammate's own key is refused (403 agent_route_refused). The teammate must have the provider Grok Bot (409 agent_not_webhook_provider otherwise). Answers 404 ai_teammates_off while AI teammates are switched off and 402 plan_required when the workspace is not entitled. Against a server that predates these routes (an HTML 404) the error says so.";
|
|
111
|
+
const WHO = "Owners and admins, with a person's API key (the chat scope); an AI teammate's own key is refused (403 agent_route_refused). The teammate must have the provider Grok Bot or OpenClaw (grok or clawdbot; 409 agent_not_webhook_provider otherwise). Answers 404 ai_teammates_off while AI teammates are switched off and 402 plan_required when the workspace is not entitled. Against a server that predates these routes (an HTML 404) the error says so.";
|
|
107
112
|
export function registerAiTeammateConnectTools(server, client) {
|
|
108
113
|
// (#1153, tri-surface parity) the workspace's AI teammates, so an agent can find the one to connect by id or @handle
|
|
109
|
-
strictInput(server.tool("conduyt_list_ai_teammates", "List the workspace's live AI teammates (GET /api/v1/chat/agents; a removed teammate is not listed), oldest first: [{ id, handle, name, provider (claude_code, codex, grok), state (listening, replying, needs_attention (#1213: listening, nothing running, and a turn in the last 24 hours failed or timed out), away), connected (a
|
|
114
|
+
strictInput(server.tool("conduyt_list_ai_teammates", "List the workspace's live AI teammates (GET /api/v1/chat/agents; a removed teammate is not listed), oldest first: [{ id, handle, name, provider (claude_code, codex, grok, clawdbot), state (listening, replying, needs_attention (#1213: listening, nothing running, and a turn in the last 24 hours failed or timed out), away), connected (a connector teammate, grok or clawdbot: its connection is stored and live; any other: a listener runs now), connection (a connector teammate's not_connected, waiting_for_hello, listening or not_listening; null otherwise), knowledgeFolders (#1209: how many knowledge folders the teammate's RUNNING listeners reported, the sum over the listeners whose heartbeat beats now, 0 = none; a knowledge folder is a folder on the listener's computer the teammate reads on every turn, whoever asked, read-only, secrets-looking files excluded; it is chosen on that computer with \`conduyt agent listen\` (the start directory, --knowledge <folder> or --no-knowledge), never through Conduyt, and its path never leaves the computer), createdAt }]. Nothing secret is listed. Name a teammate to the connector tools (Grok Bot and OpenClaw) by its id or its @handle. The rows an API key reads carry no webhook object (the Settings session rows do: webhook.noRun and webhook.provider are read there, never through this tool). Owners and admins, with a person's API key (the chat scope; reading is enough); a member's key is refused (403) and an AI teammate's own key too (403 agent_route_refused). Adding a teammate stays in Settings > AI. Answers 404 ai_teammates_off while AI teammates are switched off and 402 plan_required when the workspace is not entitled; a workspace with more than 200 live teammates is refused to an API key (413 agent_list_over_ceiling; Settings > AI lists them all).", {}, async () => {
|
|
110
115
|
try {
|
|
111
116
|
const res = await client.get("/api/v1/chat/agents");
|
|
112
117
|
return connectResult(unwrap(res), []);
|
|
@@ -121,23 +126,24 @@ export function registerAiTeammateConnectTools(server, client) {
|
|
|
121
126
|
throw err;
|
|
122
127
|
}
|
|
123
128
|
}));
|
|
124
|
-
strictInput(server.tool("conduyt_connect_ai_teammate", `Step 1 of connecting a Grok Bot as an AI teammate (POST /api/v1/chat/agents/{id}/connect). Mints the teammate's token and returns it ONCE: { token, tokenPrefix, message, toolsUrl, agent }. Give the person the message to paste into Grok Bot and the token to paste into
|
|
125
|
-
strictInput(server.tool("conduyt_set_ai_teammate_webhook", `Step 3 of connecting a Grok Bot (PUT /api/v1/chat/agents/{id}/webhook):
|
|
129
|
+
strictInput(server.tool("conduyt_connect_ai_teammate", `Step 1 of connecting a Grok Bot or OpenClaw as an AI teammate (POST /api/v1/chat/agents/{id}/connect). Mints the teammate's token and returns it ONCE: { token, tokenPrefix, message, toolsUrl, agent }. Give the person the message to paste into Grok Bot (or OpenClaw) and the token to paste into the connector's masked field; NEVER post the token in Team Chat or any message, and never call this again just to read it: every call revokes the teammate's earlier tokens (the card's "Get a new token"). The calling key must hold the write tier and the chat and deals scopes (403 api_key_scope_insufficient otherwise). 409 agent_listener_webhook_conflict while the teammate's listener is running; 409 teammate_not_live when its owner lost access. Step 3 is conduyt_set_ai_teammate_webhook. ${WHO}`, { teammateId: TEAMMATE_ID }, async ({ teammateId }) => attempt([], () => client.post(`/api/v1/chat/agents/${seg(teammateId)}/connect`, {}), (res) => connectResult(unwrap(res), []))));
|
|
130
|
+
strictInput(server.tool("conduyt_set_ai_teammate_webhook", `Step 3 of connecting a Grok Bot or OpenClaw (PUT /api/v1/chat/agents/{id}/webhook): Grok Bot's routine address and key, or OpenClaw's hooks address (https, ending in /hooks/agent) and hook token, as the connector shows them. Send EITHER paste (the whole block the person copied: it must hold one https address and one key; for OpenClaw an "agent:" line may name the hook agent) OR address and key. OpenClaw only, optional: agentId, the agent id inside the OpenClaw gateway that answers (as in its hooks.allowedAgentIds); without it OpenClaw runs its default agent; a Grok Bot teammate takes none. Conduyt checks the address (https, a public host), stores both (the key encrypted), sends the test at once (10 s) and answers { stored, test: { ok, statusCode, runUuid, noRun, problem }, status }. The key (an OpenClaw hook token too) is write-only: it is never returned, and any text this tool returns has it replaced by [hidden]. test.noRun true: an OpenClaw gateway answered 204, so the hello was delivered and accepted but NO RUN was started (neither a failure nor a plain success; this tool answers an ok result with a note saying so, and no hello will come from that test: check the hook agent in OpenClaw, then call conduyt_test_ai_teammate_webhook). A test that was not accepted is an error result { ok: false, error: <its one sentence>, status: 200, code (key_refused, routine_gone, unreachable, not_accepted, rate_limited, session_busy (OpenClaw is still running another turn in the hook's session: wait, test again), body_too_large (the message was over the gateway's hook body limit)), answer: <the whole answer> }; an accepted test that started a run leaves status Waiting for the connector to say hello: poll conduyt_get_ai_teammate_webhook (every few seconds, up to about 3 minutes) until state is listening or a problem is named. Refusals: 400 with the input codes (input_conflict, address_missing, address_invalid, address_ambiguous, key_missing, key_invalid, key_ambiguous, agent_id_not_used, agent_id_invalid, agent_id_ambiguous), 422 address_invalid / unreachable, 409 agent_token_missing (run conduyt_connect_ai_teammate first), agent_listener_webhook_conflict, agent_webhook_contended, teammate_not_live, 429 after 20 tests per teammate in 10 minutes, 503 while a delivery is in flight. ${WHO}`, {
|
|
126
131
|
teammateId: TEAMMATE_ID,
|
|
127
|
-
paste: z.string().min(1).max(12_000).optional().describe("The block Grok Bot shows (address and key together); not with address or key"),
|
|
128
|
-
address: z.string().min(1).max(2_048).optional().describe("The routine's address (https://...)"),
|
|
129
|
-
key: z.string().min(1).max(600).optional().describe("The routine's key (write-only: never returned). The bare key or the \"Authorization: Bearer ...\" header value"),
|
|
130
|
-
|
|
132
|
+
paste: z.string().min(1).max(12_000).optional().describe("The block Grok Bot (or OpenClaw) shows (address and key together); not with address or key"),
|
|
133
|
+
address: z.string().min(1).max(2_048).optional().describe("The routine's address (https://...); OpenClaw: the hooks address, ending in /hooks/agent"),
|
|
134
|
+
key: z.string().min(1).max(600).optional().describe("The routine's key, or OpenClaw's hook token (write-only: never returned). The bare key or the \"Authorization: Bearer ...\" header value"),
|
|
135
|
+
agentId: z.string().min(1).max(64).optional().describe("OpenClaw only, optional: the agent id inside the OpenClaw gateway that answers (hooks.allowedAgentIds; 1 to 64 characters of A-Z a-z 0-9 . _ -); sent as agentId, not a secret. A Grok Bot teammate takes none (400 agent_id_not_used)"),
|
|
136
|
+
}, async ({ teammateId, paste, address, key, agentId }) => {
|
|
131
137
|
// (r2, Codex grokA3-mcp-r1 P1) every form the server could take as the key (routine-key-redaction.ts: the server's rules ported,
|
|
132
138
|
// plus the floor of every token as typed), for each input that can carry it: the key field, the paste, an address box holding both
|
|
133
139
|
const secrets = [...(key !== undefined ? secretsOfKey(key) : []), ...(paste !== undefined ? secretsInPaste(paste) : []), ...(address !== undefined ? secretsInPaste(address) : [])];
|
|
134
140
|
if (paste === undefined && address === undefined)
|
|
135
141
|
return connectError(NO_CREDENTIALS_SENTENCE, secrets, { status: null, code: "address_missing" });
|
|
136
|
-
// the body as ONE literal: the contract gate reads the request fields (paste, address, key) from it
|
|
137
|
-
return attempt(secrets, () => client.put(`/api/v1/chat/agents/${seg(teammateId)}/webhook`, { ...(paste !== undefined ? { paste } : {}), ...(address !== undefined ? { address } : {}), ...(key !== undefined ? { key } : {}) }), testOutcome(secrets));
|
|
142
|
+
// the body as ONE literal: the contract gate reads the request fields (paste, address, key, agentId) from it
|
|
143
|
+
return attempt(secrets, () => client.put(`/api/v1/chat/agents/${seg(teammateId)}/webhook`, { ...(paste !== undefined ? { paste } : {}), ...(address !== undefined ? { address } : {}), ...(key !== undefined ? { key } : {}), ...(agentId !== undefined ? { agentId } : {}) }), testOutcome(secrets));
|
|
138
144
|
}));
|
|
139
|
-
strictInput(server.tool("conduyt_test_ai_teammate_webhook", `The card's Test button (POST /api/v1/chat/agents/{id}/webhook/test): sends the hello again to the stored routine (nothing is pasted); an accepted test turns a stored connection live. Answers { test, status } like conduyt_set_ai_teammate_webhook (a test that was not accepted is an error result with its sentence); then poll conduyt_get_ai_teammate_webhook for the hello. 409 agent_webhook_not_connected when nothing is stored; 429 after 20 tests per teammate in 10 minutes. ${WHO}`, { teammateId: TEAMMATE_ID }, async ({ teammateId }) => attempt([], () => client.post(`/api/v1/chat/agents/${seg(teammateId)}/webhook/test`, {}), testOutcome([]))));
|
|
140
|
-
strictInput(server.tool("conduyt_test_ai_teammate_listener", `The Settings > AI Test for a LISTENER teammate (a teammate whose listener runs the conduyt CLI: Claude Code, Cowork or another coding-agent listener; POST /api/v1/chat/agents/{id}/test, no body): asks the teammate's running listener for the hello. Its next inbox page carries the test and the listener posts "Hello, I'm connected." in AI Team Chat once; read the result with conduyt_list_ai_teammates (helloTest.helloAt). Answers { hello, test: { supported, requestedAt, helloAt, waitingUntil } }. It changes nothing but the request time on the teammate (not destructive; a repeat only asks again). Owners and admins with a person's API key (the chat scope); an AI teammate's own key is refused (403 agent_route_refused). 409 with a code: agent_not_listener_provider (a Grok Bot teammate: use conduyt_test_ai_teammate_webhook), listener_not_listening (no heartbeat in the last 60 seconds), listener_too_old (the listener is older than conduyt CLI 1.91.0; mention the teammate with hello instead), teammate_not_live (its owner lost access); 402 plan_required when the workspace's plan does not include AI teammates; 429 after 20 tests in 10 minutes; 404 ai_teammates_off while the workspace's AI teammates switch is off.`, { teammateId: TEAMMATE_ID.describe("The listener teammate: its id (a UUID) or its @handle, as conduyt_list_ai_teammates lists them (any provider; a Grok Bot is refused with agent_not_listener_provider)") }, async ({ teammateId }) => {
|
|
145
|
+
strictInput(server.tool("conduyt_test_ai_teammate_webhook", `The card's Test button (POST /api/v1/chat/agents/{id}/webhook/test): sends the hello again to the stored routine or hook (nothing is pasted); an accepted test turns a stored connection live. Answers { test, status } like conduyt_set_ai_teammate_webhook (a test that was not accepted is an error result with its sentence, code including session_busy and body_too_large for OpenClaw; test.noRun true = delivered, the gateway accepted it, no run was started: an ok result with a note, and no hello will come); then poll conduyt_get_ai_teammate_webhook for the hello. 409 agent_webhook_not_connected when nothing is stored; 429 after 20 tests per teammate in 10 minutes. ${WHO}`, { teammateId: TEAMMATE_ID }, async ({ teammateId }) => attempt([], () => client.post(`/api/v1/chat/agents/${seg(teammateId)}/webhook/test`, {}), testOutcome([]))));
|
|
146
|
+
strictInput(server.tool("conduyt_test_ai_teammate_listener", `The Settings > AI Test for a LISTENER teammate (a teammate whose listener runs the conduyt CLI: Claude Code, Cowork or another coding-agent listener; POST /api/v1/chat/agents/{id}/test, no body): asks the teammate's running listener for the hello. Its next inbox page carries the test and the listener posts "Hello, I'm connected." in AI Team Chat once; read the result with conduyt_list_ai_teammates (helloTest.helloAt). Answers { hello, test: { supported, requestedAt, helloAt, waitingUntil } }. It changes nothing but the request time on the teammate (not destructive; a repeat only asks again). Owners and admins with a person's API key (the chat scope); an AI teammate's own key is refused (403 agent_route_refused). 409 with a code: agent_not_listener_provider (a Grok Bot or OpenClaw teammate: use conduyt_test_ai_teammate_webhook), listener_not_listening (no heartbeat in the last 60 seconds), listener_too_old (the listener is older than conduyt CLI 1.91.0; mention the teammate with hello instead), teammate_not_live (its owner lost access); 402 plan_required when the workspace's plan does not include AI teammates; 429 after 20 tests in 10 minutes; 404 ai_teammates_off while the workspace's AI teammates switch is off.`, { teammateId: TEAMMATE_ID.describe("The listener teammate: its id (a UUID) or its @handle, as conduyt_list_ai_teammates lists them (any provider; a Grok Bot or OpenClaw teammate is refused with agent_not_listener_provider)") }, async ({ teammateId }) => {
|
|
141
147
|
try {
|
|
142
148
|
return connectResult(unwrap(await client.post(`/api/v1/chat/agents/${seg(teammateId)}/test`, {})), []);
|
|
143
149
|
}
|
|
@@ -150,6 +156,6 @@ export function registerAiTeammateConnectTools(server, client) {
|
|
|
150
156
|
throw err;
|
|
151
157
|
}
|
|
152
158
|
}));
|
|
153
|
-
strictInput(server.tool("conduyt_get_ai_teammate_webhook", `The Grok Bot connection's status (GET /api/v1/chat/agents/{id}/webhook), what the Settings card polls: { state (not_connected | waiting_for_hello | listening | not_listening), label, problem: { code, message } | null (the sentence of what to fix), waitingUntil, connected, address (masked), lastAttempt, tokenUsedAt, lastMessageAt }. Never carries the key. ${WHO}`, { teammateId: TEAMMATE_ID }, async ({ teammateId }) => attempt([], () => client.get(`/api/v1/chat/agents/${seg(teammateId)}/webhook`), (res) => connectResult(unwrap(res), []))));
|
|
154
|
-
strictInput(server.tool("conduyt_disconnect_ai_teammate", `Disconnect a Grok Bot teammate (DELETE /api/v1/chat/agents/{id}/webhook; never blocked by billing): its tokens are revoked, the routine's key is cleared and pending deliveries are cancelled; the teammate and its messages stay. Answers { disconnected, revokedKeys, webhook, cancelledDeliveries }. Safe to repeat. Connect it again with conduyt_connect_ai_teammate then conduyt_set_ai_teammate_webhook. ${WHO.replace(" and 402 plan_required when the workspace is not entitled", "")}`, { teammateId: TEAMMATE_ID }, async ({ teammateId }) => attempt([], () => client.del(`/api/v1/chat/agents/${seg(teammateId)}/webhook`), (res) => connectResult(unwrap(res), []))));
|
|
159
|
+
strictInput(server.tool("conduyt_get_ai_teammate_webhook", `The Grok Bot or OpenClaw connection's status (GET /api/v1/chat/agents/{id}/webhook), what the Settings card polls: { state (not_connected | waiting_for_hello | listening | not_listening), label, problem: { code, message } | null (the sentence of what to fix; session_busy and body_too_large are OpenClaw's codes for a busy hook session and an oversized message), waitingUntil, connected, address (masked), lastAttempt { event, ok, statusCode, at, runUuid, noRun (true: the last delivery was accepted by an OpenClaw gateway without starting a run) }, tokenUsedAt, lastMessageAt }. Never carries the key or the hook token. ${WHO}`, { teammateId: TEAMMATE_ID }, async ({ teammateId }) => attempt([], () => client.get(`/api/v1/chat/agents/${seg(teammateId)}/webhook`), (res) => connectResult(unwrap(res), []))));
|
|
160
|
+
strictInput(server.tool("conduyt_disconnect_ai_teammate", `Disconnect a Grok Bot or OpenClaw teammate (DELETE /api/v1/chat/agents/{id}/webhook; never blocked by billing): its tokens are revoked, the routine's key (an OpenClaw hook token too) is cleared and pending deliveries are cancelled; the teammate and its messages stay. Answers { disconnected, revokedKeys, webhook, cancelledDeliveries }. Safe to repeat. Connect it again with conduyt_connect_ai_teammate then conduyt_set_ai_teammate_webhook. ${WHO.replace(" and 402 plan_required when the workspace is not entitled", "")}`, { teammateId: TEAMMATE_ID }, async ({ teammateId }) => attempt([], () => client.del(`/api/v1/chat/agents/${seg(teammateId)}/webhook`), (res) => connectResult(unwrap(res), []))));
|
|
155
161
|
}
|
package/dist/tools/bulk.js
CHANGED
|
@@ -2,6 +2,7 @@ import { z } from "zod";
|
|
|
2
2
|
import { formatResult } from "../client.js";
|
|
3
3
|
import { INVALID_NUMBER_REFUSALS } from "./contacts.js";
|
|
4
4
|
import { strictInput } from "./strict.js";
|
|
5
|
+
import { CONTACT_TIMEZONE_NOTE, appendContactTimezone, contactTimezoneSchema } from "./contact-timezone.js";
|
|
5
6
|
/** (#136, Codex r1 m2) POST /bulk/contacts/update is NOT atomic and answers per row: an impossible phone is a per-row success:false inside HTTP 200 (no code) while other rows commit; the route takes no country */
|
|
6
7
|
export const BULK_UPDATE_REFUSALS = " Results are PER ROW inside an HTTP 200 (not atomic: some rows can be saved while others fail): read data.summary { total, succeeded, failed } and data.results, each { id, success, error? }. An impossible US/Canada number (area code or exchange starting 0 or 1) fails only that row, success: false with the error text (no phone_invalid code, no top-level 400), and nothing is saved for that row. This route does not take country: a country-only row fails as a row, and a country sent beside another field is ignored while that field is applied (use conduyt_bulk_edit_contacts for a country; it refuses a null or blank country 400 country_invalid).";
|
|
7
8
|
export function registerBulkTools(server, client) {
|
|
@@ -65,10 +66,11 @@ export function registerBulkTools(server, client) {
|
|
|
65
66
|
});
|
|
66
67
|
return formatResult(result);
|
|
67
68
|
});
|
|
68
|
-
server.tool("conduyt_export_deals", "Export deals as JSON with filtering by status, pipeline, or search term. The API judges the query names first (batch33): a name the export does not read is 400 unknown_query_param { message, unknown[], accepted[], didYouMean } (it used to be ignored and the whole book exported) and two different values of format, search, status, pipeline, value_min / minValue, value_max / maxValue, needsAction or stale 400 query_param_conflict { message, param }, both before the numeric codes; this tool sends only accepted names. 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).", {
|
|
69
|
+
server.tool("conduyt_export_deals", "Export deals as JSON with filtering by status, pipeline, or search term. The API judges the query names first (batch33): a name the export does not read is 400 unknown_query_param { message, unknown[], accepted[], didYouMean } (it used to be ignored and the whole book exported) and two different values of format, search, status, pipeline, value_min / minValue, value_max / maxValue, needsAction or stale 400 query_param_conflict { message, param }, both before the numeric codes; this tool sends only accepted names. 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). TIME ZONE (#1312): " + CONTACT_TIMEZONE_NOTE + " The export applies the same rule as conduyt_list_deals.", {
|
|
69
70
|
search: z.string().optional().describe("Search deal titles"),
|
|
70
71
|
status: z.string().optional().describe("Filter by status (open, won, lost)"),
|
|
71
72
|
pipeline: z.string().optional().describe("Filter by pipeline UUID"),
|
|
73
|
+
contact_timezone: contactTimezoneSchema,
|
|
72
74
|
}, async (params) => {
|
|
73
75
|
const qp = new URLSearchParams({ format: "json" });
|
|
74
76
|
if (params.search)
|
|
@@ -77,6 +79,7 @@ export function registerBulkTools(server, client) {
|
|
|
77
79
|
qp.set("status", params.status);
|
|
78
80
|
if (params.pipeline)
|
|
79
81
|
qp.set("pipeline", params.pipeline);
|
|
82
|
+
appendContactTimezone(qp, params.contact_timezone);
|
|
80
83
|
// Same widened-but-bounded budget as the contacts export.
|
|
81
84
|
const result = await client.get(`/api/v1/deals/export?${qp}`, {
|
|
82
85
|
timeoutMs: 120_000,
|
package/dist/tools/chat.js
CHANGED
|
@@ -150,16 +150,16 @@ export function registerChatTools(server, client) {
|
|
|
150
150
|
const result = await client.post(`/api/v1/chat/channels/${channelId}/messages`, { body, ...(idempotencyKey ? { idempotencyKey } : {}) });
|
|
151
151
|
return formatResult(result);
|
|
152
152
|
}));
|
|
153
|
-
strictInput(server.tool("conduyt_reply_chat_message", "Reply in a Team Chat thread as the API key's user (POST /api/v1/chat/channels/{id}/messages with parentId). parentId must name a live top-level message in that channel. The caller must be a member with communications:create. AI-agent keys are subject to the same six-consecutive-agent-turn cap as a top-level send, and to the same 409 agent_human_required / agents_muted_in_channel refusals (nothing written, do not retry; agents_muted_in_channel = an admin turned \"agents respond here\" off for the channel). (#1213) AI teammates may talk to each other in a thread, bounded: with two consecutive AI posts already (the asker and the answerer), a turn answering an AI teammate's message is refused 409 agent_human_required with reason agent_chain_cap (the same one pause line; the thread waits for a person). A 409 parent_deleted means the parent, its thread or the turn's message was deleted: nothing was written and the turn ended; do not retry. (#1213) While an AI teammate is answering a turn (it holds a running claim) every post must be that turn's reply (its reply:<source> key and claim token, in the source's channel and thread): anything else is refused 409 write_outside_turn, nothing posted. A
|
|
153
|
+
strictInput(server.tool("conduyt_reply_chat_message", "Reply in a Team Chat thread as the API key's user (POST /api/v1/chat/channels/{id}/messages with parentId). parentId must name a live top-level message in that channel. The caller must be a member with communications:create. AI-agent keys are subject to the same six-consecutive-agent-turn cap as a top-level send, and to the same 409 agent_human_required / agents_muted_in_channel refusals (nothing written, do not retry; agents_muted_in_channel = an admin turned \"agents respond here\" off for the channel). (#1213) AI teammates may talk to each other in a thread, bounded: with two consecutive AI posts already (the asker and the answerer), a turn answering an AI teammate's message is refused 409 agent_human_required with reason agent_chain_cap (the same one pause line; the thread waits for a person). A 409 parent_deleted means the parent, its thread or the turn's message was deleted: nothing was written and the turn ended; do not retry. (#1213) While an AI teammate is answering a turn (it holds a running claim) every post must be that turn's reply (its reply:<source> key and claim token, in the source's channel and thread): anything else is refused 409 write_outside_turn, nothing posted. A connector turn's answer (Grok Bot or OpenClaw; idempotencyKey turn:<message id>) needs turnToken (409 turn_token_invalid otherwise).", {
|
|
154
154
|
channelId: z.string().uuid().describe("Channel UUID"),
|
|
155
155
|
parentId: z.string().uuid().describe("Top-level message UUID to reply to"),
|
|
156
156
|
body: z.string().trim().min(1).max(10_000).describe("Reply text"),
|
|
157
157
|
idempotencyKey: z.string().regex(/^[A-Za-z0-9:_.-]{1,128}$/).optional().describe("Paired AI agent keys only: a key unique per agent and source turn (the listener uses reply:<source message id>). The same key returns the reply already created (200, idempotentReplay: true) instead of posting a second one; a key used in another channel is a 409 idempotency_key_reused. A person's key gets 400."),
|
|
158
158
|
alsoInChannel: z.boolean().optional().describe("(#684, a person's reply, only while the workspace's thread view is on) true = \"Also send to #channel\": the ONE reply is also shown in the channel (topLevel reads list it with threadReply.reason alsoInChannel); never a second message or notification. Sent only when true. 409 team_chat_threads_off while the thread view is off (nothing posted); an AI teammate never sets it (its first answer already shows in the channel): refused here with claimToken, 400 from the server otherwise"),
|
|
159
159
|
claimToken: z.string().regex(/^[1-9][0-9]{0,8}:[A-Za-z0-9:_.-]{8,128}$/).optional().describe("Paired AI agent keys only; REQUIRED with idempotencyKey reply:<source message id> (refused otherwise, nothing posted): the listener's claim token <generation>:<listener id> from the turn prompt. The reply completes that turn only when posted in the source's channel and thread with the current generation's token; a reply:<source> reply anywhere else, or with a stale token, is refused 409 (reply_wrong_channel / reply_wrong_thread / reply_stale_claim) with nothing posted, so a corrected retry still completes the turn."),
|
|
160
|
-
turnToken: z.string().regex(/^[1-9][0-9]{9,15}\.[0-9a-f]{64}$/).optional().describe("(#1213) an AI teammate answering a Grok Bot
|
|
160
|
+
turnToken: z.string().regex(/^[1-9][0-9]{9,15}\.[0-9a-f]{64}$/).optional().describe("(#1213) an AI teammate answering a connector turn (Grok Bot, OpenClaw): the turn's turnToken from its payload; REQUIRED with idempotencyKey turn:<message id> (refused otherwise, nothing posted)"),
|
|
161
161
|
}, async ({ channelId, parentId, body, idempotencyKey, claimToken, turnToken, alsoInChannel }) => {
|
|
162
|
-
// (#1213) a
|
|
162
|
+
// (#1213) a connector turn's (Grok Bot, OpenClaw) answer always carries the turn's server-minted token
|
|
163
163
|
if (!turnToken && typeof idempotencyKey === "string" && /^turn:[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(idempotencyKey)) {
|
|
164
164
|
throw new Error("turnToken is required with an idempotencyKey turn:<message id> (the turn's turnToken from its payload); nothing was posted");
|
|
165
165
|
}
|
|
@@ -185,13 +185,13 @@ export function registerChatTools(server, client) {
|
|
|
185
185
|
const out = formatResult(result);
|
|
186
186
|
return note ? { ...out, content: [...out.content, { type: "text", text: note }] } : out;
|
|
187
187
|
}));
|
|
188
|
-
strictInput(server.tool("conduyt_react_chat_message", "Add a reaction to a Team Chat message as the API key's user (POST /api/v1/chat/channels/{id}/messages/{messageId}/reactions). The server accepts only its Team Chat reaction set and returns the fully hydrated message. Repeating the same reaction is safe and leaves one reaction from this user. (#802, app #655 c) An AI teammate ENDS its turn with a reaction by passing claimToken (the turn prompt's reply claim token): the reaction then completes that turn (outcome reacted) in the same transaction, so the turn needs no reply. React to the turn's message or one in its thread; when it is another message of the thread, pass the turn's message id as sourceMessageId. Exactly one of a reply, a reaction or conduyt_stay_silent ends a turn: a token that is not the running holder's, or a message outside the turn's thread, is refused 409 reaction_stale_claim, and a turn that already ended (a reply, a silence, another reaction) 409 turn_finished with its outcome; nothing is written on either, do not retry. A person's key sending claimToken gets 400. (#1213 r3) While the teammate is answering a turn its only reaction is that turn's (409 write_outside_turn otherwise); a Grok Bot
|
|
188
|
+
strictInput(server.tool("conduyt_react_chat_message", "Add a reaction to a Team Chat message as the API key's user (POST /api/v1/chat/channels/{id}/messages/{messageId}/reactions). The server accepts only its Team Chat reaction set and returns the fully hydrated message. Repeating the same reaction is safe and leaves one reaction from this user. (#802, app #655 c) An AI teammate ENDS its turn with a reaction by passing claimToken (the turn prompt's reply claim token): the reaction then completes that turn (outcome reacted) in the same transaction, so the turn needs no reply. React to the turn's message or one in its thread; when it is another message of the thread, pass the turn's message id as sourceMessageId. Exactly one of a reply, a reaction or conduyt_stay_silent ends a turn: a token that is not the running holder's, or a message outside the turn's thread, is refused 409 reaction_stale_claim, and a turn that already ended (a reply, a silence, another reaction) 409 turn_finished with its outcome; nothing is written on either, do not retry. A person's key sending claimToken gets 400. (#1213 r3) While the teammate is answering a turn its only reaction is that turn's (409 write_outside_turn otherwise); a connector teammate (Grok Bot or OpenClaw) passes its turn's turnToken (and sourceMessageId for another message of the turn's thread).", {
|
|
189
189
|
channelId: z.string().uuid().describe("Channel UUID"),
|
|
190
190
|
messageId: z.string().uuid().describe("Message UUID"),
|
|
191
191
|
emoji: z.string().min(1).max(16).describe("One allowed Team Chat emoji"),
|
|
192
192
|
claimToken: z.string().regex(/^[1-9][0-9]{0,8}:[A-Za-z0-9:_.-]{8,128}$/).optional().describe("Paired AI agent keys only: the turn prompt's reply claim token <generation>:<listener id>; the reaction then ends that turn"),
|
|
193
193
|
sourceMessageId: z.string().uuid().optional().describe("With claimToken (or turnToken): the turn's message id, when the reaction targets ANOTHER message of its thread (default: the reacted message)"),
|
|
194
|
-
turnToken: z.string().regex(/^[1-9][0-9]{9,15}\.[0-9a-f]{64}$/).optional().describe("(#1213 r3) an AI teammate answering a Grok Bot
|
|
194
|
+
turnToken: z.string().regex(/^[1-9][0-9]{9,15}\.[0-9a-f]{64}$/).optional().describe("(#1213 r3) an AI teammate answering a connector turn (Grok Bot, OpenClaw): the turn's turnToken from its payload; REQUIRED for that teammate's reaction"),
|
|
195
195
|
}, async ({ channelId, messageId, emoji, claimToken, sourceMessageId, turnToken }) => {
|
|
196
196
|
if (sourceMessageId !== undefined && claimToken === undefined && turnToken === undefined)
|
|
197
197
|
throw new Error("sourceMessageId needs claimToken or turnToken (it names the turn the reaction belongs to); nothing was sent");
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/** (parity36, #1312 tzfilter) GET /deals and GET /deals/export accept the repeatable query parameter contact_timezone (the linked contact's time zone). */
|
|
3
|
+
export declare const MAX_CONTACT_TIMEZONE_VALUES = 25;
|
|
4
|
+
export declare const TIMEZONE_GROUP_WORDS: readonly ["eastern", "central", "mountain", "pacific", "alaska", "hawaii"];
|
|
5
|
+
export declare const CONTACT_TIMEZONE_NOTE = "contact_timezone (repeatable: pass an array, each value is sent as its own repeated query parameter, deals matching ANY value) filters by the linked (primary) contact's time zone. A value is one of the group words eastern, central, mountain, pacific, alaska, hawaii (the US zones; each stands for a fixed list of IANA ids: America/Detroit is eastern, America/Boise and America/Phoenix are mountain, America/Adak is hawaii), the word unknown (the deal has no linked contact, its contact is deleted, or its contact has no time zone), or one IANA id (America/Toronto). Group words and unknown are case-insensitive. At most 25 distinct values (more is refused locally before any request, with the API's wording, and is a 400 on the server); a value that is none of the above or not a recognized IANA zone is a 400 from the API, which judges it (this tool does not keep a zone list). A blank value is no filter. Combines with every other filter (AND).";
|
|
6
|
+
export declare const contactTimezoneSchema: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
|
|
7
|
+
/** appends every value as its own contact_timezone parameter (never comma-joined); throws the API's cap wording past 25 distinct values */
|
|
8
|
+
export declare function appendContactTimezone(params: URLSearchParams, value: string | string[] | undefined): void;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/** (parity36, #1312 tzfilter) GET /deals and GET /deals/export accept the repeatable query parameter contact_timezone (the linked contact's time zone). */
|
|
3
|
+
export const MAX_CONTACT_TIMEZONE_VALUES = 25;
|
|
4
|
+
export const TIMEZONE_GROUP_WORDS = ["eastern", "central", "mountain", "pacific", "alaska", "hawaii"];
|
|
5
|
+
export const CONTACT_TIMEZONE_NOTE = "contact_timezone (repeatable: pass an array, each value is sent as its own repeated query parameter, deals matching ANY value) filters by the linked (primary) contact's time zone. A value is one of the group words eastern, central, mountain, pacific, alaska, hawaii (the US zones; each stands for a fixed list of IANA ids: America/Detroit is eastern, America/Boise and America/Phoenix are mountain, America/Adak is hawaii), the word unknown (the deal has no linked contact, its contact is deleted, or its contact has no time zone), or one IANA id (America/Toronto). Group words and unknown are case-insensitive. At most 25 distinct values (more is refused locally before any request, with the API's wording, and is a 400 on the server); a value that is none of the above or not a recognized IANA zone is a 400 from the API, which judges it (this tool does not keep a zone list). A blank value is no filter. Combines with every other filter (AND).";
|
|
6
|
+
export const contactTimezoneSchema = z
|
|
7
|
+
.union([z.string(), z.array(z.string())])
|
|
8
|
+
.optional()
|
|
9
|
+
.describe("Contact time zone filter, repeatable (an array sends one repeated contact_timezone query parameter per value; a single string is one value): eastern | central | mountain | pacific | alaska | hawaii | unknown | an IANA id such as America/Toronto, deals matching ANY value; at most 25 distinct values.");
|
|
10
|
+
/** the server's IANA check (conduyt-app lib/contact-timezone.ts normalizeIanaTimezone, the runtime's own Intl time zone support: no list is kept here): at most 64 characters of the zone-id alphabet that Intl resolves. A POSIX spelling the app maps first (its canonicalTimeZone) that Intl does not know reads as malformed here, which can only UNDER-count, never refuse a request the API accepts */
|
|
11
|
+
function isRecognizedIana(v) {
|
|
12
|
+
if (v.length > 64 || !/^[A-Za-z][A-Za-z0-9_+\-/]*$/.test(v))
|
|
13
|
+
return false;
|
|
14
|
+
try {
|
|
15
|
+
new Intl.DateTimeFormat("en-US", { timeZone: v });
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
/** the distinct values the API COUNTS (lib/deal-filter-params.ts parseContactTimezoneParam): comma lists split and trimmed, blanks dropped, group words and unknown folded to lower case, an IANA id kept as given, repeats collapsed; a value that is none of those and not a recognized IANA id is excluded from the count (the API reports it as its own 400, so it is still forwarded) */
|
|
23
|
+
function distinctContactTimezones(values) {
|
|
24
|
+
const seen = new Set();
|
|
25
|
+
for (const raw of values) {
|
|
26
|
+
for (const part of raw.split(",")) {
|
|
27
|
+
const v = part.trim();
|
|
28
|
+
if (!v)
|
|
29
|
+
continue;
|
|
30
|
+
const lower = v.toLowerCase();
|
|
31
|
+
if (lower === "unknown" || TIMEZONE_GROUP_WORDS.includes(lower))
|
|
32
|
+
seen.add(lower);
|
|
33
|
+
else if (isRecognizedIana(v))
|
|
34
|
+
seen.add(v);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return seen.size;
|
|
38
|
+
}
|
|
39
|
+
/** appends every value as its own contact_timezone parameter (never comma-joined); throws the API's cap wording past 25 distinct values */
|
|
40
|
+
export function appendContactTimezone(params, value) {
|
|
41
|
+
if (value === undefined)
|
|
42
|
+
return;
|
|
43
|
+
const values = Array.isArray(value) ? value : [value];
|
|
44
|
+
const n = distinctContactTimezones(values);
|
|
45
|
+
if (n > MAX_CONTACT_TIMEZONE_VALUES)
|
|
46
|
+
throw new Error(`contact_timezone accepts at most ${MAX_CONTACT_TIMEZONE_VALUES} values; got ${n}.`);
|
|
47
|
+
for (const v of values)
|
|
48
|
+
params.append("contact_timezone", v);
|
|
49
|
+
}
|
package/dist/tools/contacts.js
CHANGED
|
@@ -169,7 +169,7 @@ export function registerContactTools(server, client) {
|
|
|
169
169
|
const result = await client.get(`/api/v1/contacts/count?${params}`);
|
|
170
170
|
return formatResult(result);
|
|
171
171
|
});
|
|
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
|
|
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 an IANA string or, for the US zones, a group word (eastern, central, mountain, pacific, alaska, hawaii) or unknown (#1312; see the note below). " + TIMEZONE_FILTER_NOTE, {}, async () => formatResult(await client.get("/api/v1/contacts/timezones")));
|
|
173
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, {
|
|
174
174
|
id: z.string().describe("Contact UUID"),
|
|
175
175
|
}, async ({ id }) => {
|
|
@@ -2,6 +2,7 @@ import { z } from "zod";
|
|
|
2
2
|
import { ConduytApiError, formatResult } from "../client.js";
|
|
3
3
|
import { USER_NOTE } from "./user-fields-doc.js";
|
|
4
4
|
import { OPTIONS_CAP_NOTE, OPTIONS_MAX, TYPE_CHANGE_NOTE } from "./lender-options.js";
|
|
5
|
+
import { REMOVE_NOTE, RESOLVE_NOTE, SEARCH_NOTE, SET_NOTE, STORE_LIST_NOTE, STORE_UPDATE_NOTE, optionRowSchema, setRowsProblem, storeCreateProblem, storeUpdateProblem, writeFlags, writeQuery } from "./store-options.js";
|
|
5
6
|
import { CUSTOM_FIELD_TYPES, DELANCEY_ID_NOTE, fail, formulaCreateProblem, formulaUpdateProblem, FORMULA_DEFINITION_NOTE, SECURE_IDENTIFIER_NOTE } from "./formula-fields.js";
|
|
6
7
|
// (parity1292, batch30 #1292 Ship 1) Secure custom fields: the flag, its reveal set, and the codes. There is NO reveal tool: the reveal
|
|
7
8
|
// routes (POST /{contacts|deals|companies}/{id}/custom-fields/{key}/reveal) refuse an API key (403 reveal_requires_session), and this
|
|
@@ -10,7 +11,7 @@ const SECURE_NOTE = "Secure fields (isSecure): every read, export and outbound p
|
|
|
10
11
|
const revealRoles = z.array(z.string().min(1).max(40)).max(10).optional().describe("Roles whose members may reveal a Secure value (max 10, 1 to 40 characters each; a super admin always; an API key never)");
|
|
11
12
|
const revealGroupIds = z.array(z.string().uuid()).max(20).optional().describe("Team group UUIDs whose members may reveal a Secure value (max 20)");
|
|
12
13
|
export function registerCustomFieldTools(server, client) {
|
|
13
|
-
server.tool("conduyt_list_custom_fields", "List custom field definitions. Filter by entity type (contact, deal, or company) to see available fields.", {
|
|
14
|
+
server.tool("conduyt_list_custom_fields", "List custom field definitions. Filter by entity type (contact, deal, or company) to see available fields. Every row carries optionCount: the ACTIVE rows of a store-backed select (options.optionList \"store\"; its options read { optionList, allowOther }, the list is read with conduyt_search_custom_field_options), the choices count of an inline select / radio / multiselect, null for every other type; a single-definition answer does not carry it.", {
|
|
14
15
|
entityType: z.enum(["contact", "deal", "company"]).optional().describe("Filter by entity type"),
|
|
15
16
|
page: z.number().optional().describe("Page number (default 1)"),
|
|
16
17
|
per_page: z.number().optional().describe("Results per page"),
|
|
@@ -25,32 +26,41 @@ export function registerCustomFieldTools(server, client) {
|
|
|
25
26
|
const result = await client.get(`/api/v1/custom-fields?${params}`);
|
|
26
27
|
return formatResult(result);
|
|
27
28
|
});
|
|
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, {
|
|
29
|
+
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 + " " + STORE_LIST_NOTE, {
|
|
29
30
|
entityType: z.enum(["contact", "deal", "company"]).describe("Entity type this field applies to"),
|
|
30
31
|
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"),
|
|
31
32
|
label: z.string().describe("Human-readable label (e.g. 'Lead Score')"),
|
|
32
33
|
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 })"),
|
|
33
34
|
section: z.string().optional().describe("Section grouping for UI display"),
|
|
34
35
|
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 }"),
|
|
36
|
+
optionList: z.literal("store").optional().describe("\"store\" = a STORE-BACKED select (typeahead): the list lives in the option store, starts empty, filled with conduyt_set_custom_field_options; needs fieldType select and allowOther; options may carry only { visibility } (no inline choices)"),
|
|
37
|
+
allowOther: z.boolean().optional().describe("Store-backed select, REQUIRED with optionList: true = a typed value that is not on the list is also accepted, false = strict (custom_field_value_not_on_list). Refused 422 custom_field_allow_other_refused on a partner creditor field (contact creditor_1..creditor_7 or a Creditors Relief list)"),
|
|
35
38
|
isRequired: z.boolean().optional().describe("Whether this field is required"),
|
|
36
39
|
sortOrder: z.number().optional().describe("Display order"),
|
|
37
40
|
isSecure: z.boolean().optional().describe("Make this a Secure field (values masked everywhere; 400 secure_fields_not_enabled until enabled)"),
|
|
38
41
|
revealRoles,
|
|
39
42
|
revealGroupIds,
|
|
40
|
-
}, async (
|
|
41
|
-
const problem = formulaCreateProblem(
|
|
43
|
+
}, async (input) => {
|
|
44
|
+
const problem = formulaCreateProblem(input);
|
|
42
45
|
if (problem)
|
|
43
46
|
return fail(problem);
|
|
44
|
-
if (Array.isArray(
|
|
45
|
-
return fail(`options holds at most ${OPTIONS_MAX} choices (got ${
|
|
46
|
-
const
|
|
47
|
+
if (Array.isArray(input.options) && input.options.length > OPTIONS_MAX)
|
|
48
|
+
return fail(`options holds at most ${OPTIONS_MAX} choices (got ${input.options.length}).`);
|
|
49
|
+
const store = storeCreateProblem(input);
|
|
50
|
+
if (typeof store === "string")
|
|
51
|
+
return fail(store);
|
|
52
|
+
// optionList / allowOther are tool inputs folded into options { optionList, allowOther }, never top-level body keys
|
|
53
|
+
const { optionList: _l, allowOther: _a, ...params } = input;
|
|
54
|
+
const result = await client.post("/api/v1/custom-fields", { ...params, ...(store ?? {}) });
|
|
47
55
|
return formatResult(result);
|
|
48
56
|
});
|
|
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, {
|
|
57
|
+
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 + " " + STORE_UPDATE_NOTE, {
|
|
50
58
|
id: z.string().describe("Custom field UUID"),
|
|
51
59
|
label: z.string().optional().describe("Updated label"),
|
|
52
60
|
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
61
|
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)"),
|
|
62
|
+
optionList: z.literal("store").optional().describe("\"store\" = CONVERT a select with inline choices into a STORE-BACKED list (owner / admin signed in only; sent alone with allowOther)"),
|
|
63
|
+
allowOther: z.boolean().optional().describe("Store-backed select: true = accept a typed value that is not on the list, false = strict. Never true on a partner creditor field (422 custom_field_allow_other_refused). Alone it switches allowOther in place"),
|
|
54
64
|
isRequired: z.boolean().optional().describe("Updated required status"),
|
|
55
65
|
sortOrder: z.number().optional().describe("Updated display order"),
|
|
56
66
|
isSecure: z.boolean().optional().describe("Turn Secure on or off (off needs confirmUnsecure true)"),
|
|
@@ -63,7 +73,11 @@ export function registerCustomFieldTools(server, client) {
|
|
|
63
73
|
return fail(problem);
|
|
64
74
|
if (Array.isArray(updates.options) && updates.options.length > OPTIONS_MAX)
|
|
65
75
|
return fail(`options holds at most ${OPTIONS_MAX} choices (got ${updates.options.length}).`);
|
|
66
|
-
const
|
|
76
|
+
const store = storeUpdateProblem(updates);
|
|
77
|
+
if (typeof store === "string")
|
|
78
|
+
return fail(store);
|
|
79
|
+
const { optionList: _l, allowOther: _a, ...rest } = updates;
|
|
80
|
+
const result = await client.patch(`/api/v1/custom-fields/${id}`, { ...rest, ...(store ?? {}) });
|
|
67
81
|
return formatResult(result);
|
|
68
82
|
});
|
|
69
83
|
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). A BDA-sized field can take longer than the server's impact budget to read: DELETE answers 503 custom_field_impact_timeout with Retry-After 5 (nothing was deleted: the transaction rolled back and no lock is held), a RETRYABLE answer: wait the Retry-After seconds and call this tool again (this tool does not replay a delete itself); if it keeps answering 503 after a few tries, stop and report the code. GET /api/v1/custom-fields/{id}/impact (the Settings delete preview) answers the same 503 (\"Impact preview timed out, the delete still works.\"). The same 503 also answers the delete's pre-check (the read that produces the 409 counts) and a dry run; nothing changes either way. The 409 with counts is unchanged." + " " + DELANCEY_ID_NOTE, {
|
|
@@ -72,6 +86,54 @@ export function registerCustomFieldTools(server, client) {
|
|
|
72
86
|
const result = await client.del(`/api/v1/custom-fields/${id}`);
|
|
73
87
|
return formatResult(result);
|
|
74
88
|
});
|
|
89
|
+
// ---- (parity35, #1308 lane A) the list of a STORE-BACKED select ----
|
|
90
|
+
server.tool("conduyt_search_custom_field_options", SEARCH_NOTE, {
|
|
91
|
+
id: z.string().uuid().describe("Custom field UUID (a store-backed select)"),
|
|
92
|
+
q: z.string().optional().describe("Case-insensitive substring, trimmed, at most 200 characters; empty = list from the top"),
|
|
93
|
+
limit: z.number().int().min(1).max(200).optional().describe("Page size 1 to 200 (default 50)"),
|
|
94
|
+
cursor: z.string().min(1).optional().describe("The previous page's nextCursor, passed back UNCHANGED (opaque)"),
|
|
95
|
+
}, async ({ id, q, limit, cursor }) => {
|
|
96
|
+
if (q !== undefined && q.trim().length > 200)
|
|
97
|
+
return fail("q is at most 200 characters.");
|
|
98
|
+
const params = new URLSearchParams();
|
|
99
|
+
if (q !== undefined)
|
|
100
|
+
params.set("q", q);
|
|
101
|
+
if (limit !== undefined)
|
|
102
|
+
params.set("limit", String(limit));
|
|
103
|
+
if (cursor !== undefined)
|
|
104
|
+
params.set("cursor", cursor);
|
|
105
|
+
const qs = params.toString();
|
|
106
|
+
const result = await client.get(`/api/v1/custom-fields/${id}/options` + (qs ? `?${qs}` : ""));
|
|
107
|
+
return formatResult(result);
|
|
108
|
+
});
|
|
109
|
+
server.tool("conduyt_set_custom_field_options", SET_NOTE, {
|
|
110
|
+
id: z.string().uuid().describe("Custom field UUID (a store-backed select)"),
|
|
111
|
+
options: z.array(optionRowSchema).max(1000).describe("The new ACTIVE list, at most 1000 options; every other option is deactivated"),
|
|
112
|
+
...writeFlags,
|
|
113
|
+
}, async ({ id, options, dryRun, sandbox }) => {
|
|
114
|
+
const problem = setRowsProblem(options);
|
|
115
|
+
if (problem)
|
|
116
|
+
return fail(problem);
|
|
117
|
+
const qs = writeQuery({ dryRun, sandbox });
|
|
118
|
+
const result = await client.put(`/api/v1/custom-fields/${id}/options` + qs, { options });
|
|
119
|
+
return formatResult(result);
|
|
120
|
+
});
|
|
121
|
+
server.tool("conduyt_remove_custom_field_option", REMOVE_NOTE, {
|
|
122
|
+
id: z.string().uuid().describe("Custom field UUID (a store-backed select)"),
|
|
123
|
+
optionId: z.string().uuid().describe("The option row id (from conduyt_search_custom_field_options)"),
|
|
124
|
+
...writeFlags,
|
|
125
|
+
}, async ({ id, optionId, dryRun, sandbox }) => {
|
|
126
|
+
const qs = writeQuery({ dryRun, sandbox });
|
|
127
|
+
const result = await client.del(`/api/v1/custom-fields/${id}/options/${optionId}` + qs);
|
|
128
|
+
return formatResult(result);
|
|
129
|
+
});
|
|
130
|
+
server.tool("conduyt_resolve_custom_field_options", RESOLVE_NOTE, {
|
|
131
|
+
id: z.string().uuid().describe("Custom field UUID (a store-backed select)"),
|
|
132
|
+
label: z.string().min(1).max(200).describe("The exact label (1 to 200 characters, case-sensitive, not trimmed)"),
|
|
133
|
+
}, async ({ id, label }) => {
|
|
134
|
+
const result = await client.get(`/api/v1/custom-fields/${id}/options/resolve?${new URLSearchParams({ label })}`);
|
|
135
|
+
return formatResult(result);
|
|
136
|
+
});
|
|
75
137
|
// (mirror1292, batch31 #1292 Ship 3) a DEAL MIRROR: POST /custom-fields with mirrorOf (no type, options, required or Secure flags)
|
|
76
138
|
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
139
|
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)"),
|
package/dist/tools/deals.js
CHANGED
|
@@ -6,6 +6,7 @@ import { formatResult } from "../client.js";
|
|
|
6
6
|
import { FORMULA_WRITE_NOTE } from "./formula-fields.js";
|
|
7
7
|
import { strictInput } from "./strict.js";
|
|
8
8
|
import { KEEP_PREVIOUS_OWNER_NEEDS_ASSIGNEE } from "./contacts.js";
|
|
9
|
+
import { CONTACT_TIMEZONE_NOTE, appendContactTimezone, contactTimezoneSchema } from "./contact-timezone.js";
|
|
9
10
|
// (mirror1292, batch31 #1292 Ship 3) deal MIRROR fields: a write-through view of a contact / company field, named on the deal tools
|
|
10
11
|
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).";
|
|
11
12
|
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).";
|
|
@@ -56,7 +57,7 @@ function boardSnapshotColumns(a, f) {
|
|
|
56
57
|
return a.board_columns.map((c) => (c.limit === undefined ? c.stageId : `${c.stageId}:${c.limit}`)).join(",");
|
|
57
58
|
}
|
|
58
59
|
export function registerDealTools(server, client) {
|
|
59
|
-
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)." + " " + ROLE_COLUMNS_NOTE, {
|
|
60
|
+
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, contact_timezone, 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)." + " " + ROLE_COLUMNS_NOTE + " TIME ZONE (#1312): " + CONTACT_TIMEZONE_NOTE, {
|
|
60
61
|
pipeline: z.string().optional().describe("Filter by pipeline UUID (canonical). Aliases: pipelineId, pipeline_id."),
|
|
61
62
|
pipelineId: z.string().optional().describe("Filter by pipeline UUID (alias of pipeline)."),
|
|
62
63
|
pipeline_id: z.string().optional().describe("snake_case alias of pipelineId."),
|
|
@@ -70,6 +71,7 @@ export function registerDealTools(server, client) {
|
|
|
70
71
|
assignedTo: z.string().optional().describe("Filter by assigned user UUID"),
|
|
71
72
|
status: z.enum(["open", "won", "lost"]).optional().describe("Filter by deal status"),
|
|
72
73
|
search: z.string().optional().describe("Search deal titles"),
|
|
74
|
+
contact_timezone: contactTimezoneSchema,
|
|
73
75
|
page: z.number().optional().describe("Page number (default 1)"),
|
|
74
76
|
per_page: z.number().int().min(1).max(BOARD_SNAPSHOT_MAX_COLUMN_ROWS).optional().describe("Results per page, an integer 1-1000 (server default 50, max 1000; with board_snapshot it is the default rows per column)"),
|
|
75
77
|
health_summary: z.boolean().optional().describe("true: answer the Pipeline health shape (totalOpenDeals, atRiskValue, checks[], deals) for the filtered set instead of the deal list."),
|
|
@@ -125,6 +127,7 @@ export function registerDealTools(server, client) {
|
|
|
125
127
|
params.set("status", status);
|
|
126
128
|
if (search)
|
|
127
129
|
params.set("search", search);
|
|
130
|
+
appendContactTimezone(params, a.contact_timezone);
|
|
128
131
|
if (page)
|
|
129
132
|
params.set("page", String(page));
|
|
130
133
|
if (per_page)
|
|
@@ -318,7 +321,7 @@ export function registerDealTools(server, client) {
|
|
|
318
321
|
const result = await client.post(`/api/v1/deals/${dealId}/tags`, { tagIds });
|
|
319
322
|
return formatResult(result);
|
|
320
323
|
});
|
|
321
|
-
server.tool("conduyt_list_deal_views", "List the account's SAVED DEAL VIEWS (saved deal segments, e.g. 'Open deals over $10k'), each with its id, name, stored filter rules, and current deal count. Read-only — shows how the account segments its deals.", {}, async () => {
|
|
324
|
+
server.tool("conduyt_list_deal_views", "List the account's SAVED DEAL VIEWS (saved deal segments, e.g. 'Open deals over $10k'), each with its id, name, stored filter rules, and current deal count. Read-only — shows how the account segments its deals. A rule's filter field `contactTimezone` (#1312 tzfilter, the linked contact's time zone) takes operators equals / in (the value is a string: one value for equals, a comma-separated list for in) and each value is a group word (eastern, central, mountain, pacific, alaska, hawaii), unknown, or an IANA id (the same values as conduyt_list_deals contact_timezone; the API validates it and refuses a malformed value or more than 25 distinct values with a 400); a view with that rule is created or edited in the web app or through the REST API (POST / PATCH /api/v1/deals/views), this tool set has no saved-view write tool.", {}, async () => {
|
|
322
325
|
const result = await client.get("/api/v1/deals/views");
|
|
323
326
|
return formatResult(result);
|
|
324
327
|
});
|
|
@@ -8,4 +8,4 @@ export declare const OPTION_LABEL_MAX = 200;
|
|
|
8
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
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
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
|
|
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. A value is an IANA id (an exact case-sensitive match on the stored zone) or, since #1312 tzfilter, a GROUP WORD: eastern, central, mountain, pacific, alaska, hawaii (the US zones, each a fixed list of IANA ids: America/Detroit is eastern, America/Boise and America/Phoenix are mountain, America/Adak is hawaii; group words are case-insensitive and mix freely with IANA ids in is any of) or `unknown` (a contact with no zone). Same operators, same shapes: `is eastern` / `is any of [eastern, central, America/Toronto]`. is not / is none of keep only contacts WITH a zone (a group word there excludes that group; `unknown` in them adds nothing: ask for the unknown ones with is empty or is unknown).";
|
|
@@ -8,4 +8,4 @@ export const OPTION_LABEL_MAX = 200;
|
|
|
8
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
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
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
|
|
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. A value is an IANA id (an exact case-sensitive match on the stored zone) or, since #1312 tzfilter, a GROUP WORD: eastern, central, mountain, pacific, alaska, hawaii (the US zones, each a fixed list of IANA ids: America/Detroit is eastern, America/Boise and America/Phoenix are mountain, America/Adak is hawaii; group words are case-insensitive and mix freely with IANA ids in is any of) or `unknown` (a contact with no zone). Same operators, same shapes: `is eastern` / `is any of [eastern, central, America/Toronto]`. is not / is none of keep only contacts WITH a zone (a group word there excludes that group; `unknown` in them adds nothing: ask for the unknown ones with is empty or is unknown).";
|
|
@@ -14,7 +14,7 @@ export declare function serverNormalizeKey(raw: string): string | null;
|
|
|
14
14
|
* Returns EVERY normalized candidate (the server takes exactly one; all of them are hidden). */
|
|
15
15
|
export declare function serverKeyCandidates(text: string): string[];
|
|
16
16
|
/** the FLOOR: every whitespace-separated token of the input as typed (not an address) of 8 characters or more, in each shape a strip
|
|
17
|
-
* of surrounding quotes or brackets, a leading label (key: / key= / Authorization: / Bearer) or trailing punctuation gives it */
|
|
17
|
+
* of surrounding quotes or brackets, a leading label (key: / key= / token: / hook token: / x-openclaw-token: / Authorization: / Bearer) or trailing punctuation gives it */
|
|
18
18
|
export declare function rawKeyTokens(text: string): string[];
|
|
19
19
|
/** what to hide for a pasted block (the server's candidates, then the floor) */
|
|
20
20
|
export declare function secretsInPaste(text: string): string[];
|
|
@@ -51,6 +51,10 @@ export function serverKeyCandidates(text) {
|
|
|
51
51
|
found.push(m[1]);
|
|
52
52
|
for (const m of rest.matchAll(/^[ \t]*(?:the\s+)?key\s*[:=][ \t]*["'`]?([^\s"'`]+)/gim))
|
|
53
53
|
found.push(m[1]);
|
|
54
|
+
// (parity36b, #1137) OpenClaw's step 3 (conduyt-app openclaw1137 873e1abd0 lib/agent-webhook-connect.ts parseOpenClawBlock): the hook token is the
|
|
55
|
+
// token after a line-leading "token:" / "hook token:" / "key:" (the Grok rules above already read key and Bearer); no crsr_ prefix is looked for
|
|
56
|
+
for (const m of rest.matchAll(/^[ \t]*(?:the\s+)?(?:hook\s+token|token)\s*[:=][ \t]*["'`]?([^\s"'`]+)/gim))
|
|
57
|
+
found.push(m[1]);
|
|
54
58
|
const out = [];
|
|
55
59
|
for (const c of found) {
|
|
56
60
|
const k = serverNormalizeKey(c.replace(SERVER_TRAILING_PUNCT_RE, ""));
|
|
@@ -60,7 +64,7 @@ export function serverKeyCandidates(text) {
|
|
|
60
64
|
return out;
|
|
61
65
|
}
|
|
62
66
|
/** the FLOOR: every whitespace-separated token of the input as typed (not an address) of 8 characters or more, in each shape a strip
|
|
63
|
-
* of surrounding quotes or brackets, a leading label (key: / key= / Authorization: / Bearer) or trailing punctuation gives it */
|
|
67
|
+
* of surrounding quotes or brackets, a leading label (key: / key= / token: / hook token: / x-openclaw-token: / Authorization: / Bearer) or trailing punctuation gives it */
|
|
64
68
|
export function rawKeyTokens(text) {
|
|
65
69
|
const out = new Set();
|
|
66
70
|
const add = (t) => { if (t.length >= 8 && !/^https?:\/\//i.test(t))
|
|
@@ -69,7 +73,7 @@ export function rawKeyTokens(text) {
|
|
|
69
73
|
const shapes = [tok];
|
|
70
74
|
for (let i = 0; i < 3; i++) {
|
|
71
75
|
for (const t of [...shapes]) {
|
|
72
|
-
shapes.push(t.replace(/^["'`<(\[{]+|["'`>)\]}]+$/g, ""), t.replace(SERVER_TRAILING_PUNCT_RE, ""), t.replace(/^(?:key\s*[:=]|authorization\s*:|bearer\s*:?)/i, ""));
|
|
76
|
+
shapes.push(t.replace(/^["'`<(\[{]+|["'`>)\]}]+$/g, ""), t.replace(SERVER_TRAILING_PUNCT_RE, ""), t.replace(/^(?:key\s*[:=]|(?:hook\s*token|token)\s*[:=]|x-openclaw-token\s*:|authorization\s*:|bearer\s*:?)/i, ""));
|
|
73
77
|
}
|
|
74
78
|
}
|
|
75
79
|
for (const t of shapes)
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* (parity35, batch35 #1308 lane A) STORE-BACKED typeahead select: a select whose list lives in the server's option store
|
|
3
|
+
* (options { optionList: "store", allowOther }) instead of inline choices, so it can hold a long list (a lender or creditor book).
|
|
4
|
+
* conduyt_search_custom_field_options / conduyt_set_custom_field_options / conduyt_remove_custom_field_option /
|
|
5
|
+
* conduyt_resolve_custom_field_options manage that list; conduyt_create_custom_field / conduyt_update_custom_field take optionList
|
|
6
|
+
* + allowOther. The server is the authority; every check here only refuses before a request leaves and none is stricter than the
|
|
7
|
+
* frozen route contract (typeahead1308a CONTRACT.md).
|
|
8
|
+
*/
|
|
9
|
+
import { z } from "zod";
|
|
10
|
+
export declare const STORE_LIST_MAX_PER_REQUEST = 1000;
|
|
11
|
+
export declare const STORE_LABEL_MAX = 200;
|
|
12
|
+
export declare const ALLOW_OTHER_RULE_NOTE = "HARD RULE: allowOther is NEVER available on a PARTNER CREDITOR field (the contact creditor_1 .. creditor_7 fields, or any store-backed list holding a row whose externalSource is creditors_relief): Creditors Relief refuses an unknown creditor, so allowOther true there is 422 custom_field_allow_other_refused (on create, on update, and when Creditors Relief rows are put into an allowOther list with conduyt_set_custom_field_options).";
|
|
13
|
+
export declare const STORE_LIST_NOTE: string;
|
|
14
|
+
export declare const STORE_UPDATE_NOTE: string;
|
|
15
|
+
export declare const OPTIONS_ACCESS_NOTE = "Reads need settings.view or view on the field's entity module; writes need settings.edit (API keys included; no new scope). Codes: 404 custom_field_not_found (unknown id), 422 custom_field_not_list_backed (the field is not a store-backed select).";
|
|
16
|
+
export declare const SEARCH_NOTE: string;
|
|
17
|
+
export declare const SET_NOTE: string;
|
|
18
|
+
export declare const REMOVE_NOTE: string;
|
|
19
|
+
export declare const RESOLVE_NOTE: string;
|
|
20
|
+
/** one row of the PUT body, strict (the route's additionalProperties false) */
|
|
21
|
+
export declare const optionRowSchema: z.ZodObject<{
|
|
22
|
+
label: z.ZodString;
|
|
23
|
+
externalId: z.ZodOptional<z.ZodUnion<[z.ZodType<string, z.ZodTypeDef, string>, z.ZodNull]>>;
|
|
24
|
+
externalSource: z.ZodOptional<z.ZodUnion<[z.ZodType<string, z.ZodTypeDef, string>, z.ZodNull]>>;
|
|
25
|
+
sortKey: z.ZodOptional<z.ZodNumber>;
|
|
26
|
+
}, "strict", z.ZodTypeAny, {
|
|
27
|
+
label: string;
|
|
28
|
+
externalId?: string | null | undefined;
|
|
29
|
+
externalSource?: string | null | undefined;
|
|
30
|
+
sortKey?: number | undefined;
|
|
31
|
+
}, {
|
|
32
|
+
label: string;
|
|
33
|
+
externalId?: string | null | undefined;
|
|
34
|
+
externalSource?: string | null | undefined;
|
|
35
|
+
sortKey?: number | undefined;
|
|
36
|
+
}>;
|
|
37
|
+
type Body = Record<string, unknown>;
|
|
38
|
+
/** the generated dry_run / sandbox query booleans of the two write routes: sent whenever supplied (false included) */
|
|
39
|
+
export declare function writeQuery(p: {
|
|
40
|
+
dryRun?: boolean;
|
|
41
|
+
sandbox?: boolean;
|
|
42
|
+
}): string;
|
|
43
|
+
export declare const writeFlags: {
|
|
44
|
+
dryRun: z.ZodOptional<z.ZodBoolean>;
|
|
45
|
+
sandbox: z.ZodOptional<z.ZodBoolean>;
|
|
46
|
+
};
|
|
47
|
+
/** create: the store-list options object, or a problem text (undefined options = no store flag was passed) */
|
|
48
|
+
export declare function storeCreateProblem(p: {
|
|
49
|
+
fieldType?: unknown;
|
|
50
|
+
options?: unknown;
|
|
51
|
+
optionList?: unknown;
|
|
52
|
+
allowOther?: unknown;
|
|
53
|
+
}): string | {
|
|
54
|
+
options: {
|
|
55
|
+
optionList: "store";
|
|
56
|
+
allowOther: boolean;
|
|
57
|
+
visibility?: unknown;
|
|
58
|
+
};
|
|
59
|
+
} | undefined;
|
|
60
|
+
/** update: allowOther alone switches in place; optionList store (the convert) goes alone with allowOther */
|
|
61
|
+
export declare function storeUpdateProblem(updates: Body): string | {
|
|
62
|
+
options: {
|
|
63
|
+
optionList: "store";
|
|
64
|
+
allowOther: boolean;
|
|
65
|
+
visibility?: unknown;
|
|
66
|
+
};
|
|
67
|
+
} | undefined;
|
|
68
|
+
/** set: the rows judged before any request (labels unique after trimming; the cap; an empty list needs confirmation) */
|
|
69
|
+
export declare function setRowsProblem(rows: Array<{
|
|
70
|
+
label: string;
|
|
71
|
+
}>): string | undefined;
|
|
72
|
+
export {};
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* (parity35, batch35 #1308 lane A) STORE-BACKED typeahead select: a select whose list lives in the server's option store
|
|
3
|
+
* (options { optionList: "store", allowOther }) instead of inline choices, so it can hold a long list (a lender or creditor book).
|
|
4
|
+
* conduyt_search_custom_field_options / conduyt_set_custom_field_options / conduyt_remove_custom_field_option /
|
|
5
|
+
* conduyt_resolve_custom_field_options manage that list; conduyt_create_custom_field / conduyt_update_custom_field take optionList
|
|
6
|
+
* + allowOther. The server is the authority; every check here only refuses before a request leaves and none is stricter than the
|
|
7
|
+
* frozen route contract (typeahead1308a CONTRACT.md).
|
|
8
|
+
*/
|
|
9
|
+
import { z } from "zod";
|
|
10
|
+
export const STORE_LIST_MAX_PER_REQUEST = 1000;
|
|
11
|
+
export const STORE_LABEL_MAX = 200;
|
|
12
|
+
export const ALLOW_OTHER_RULE_NOTE = "HARD RULE: allowOther is NEVER available on a PARTNER CREDITOR field (the contact creditor_1 .. creditor_7 fields, or any store-backed list holding a row whose externalSource is creditors_relief): Creditors Relief refuses an unknown creditor, so allowOther true there is 422 custom_field_allow_other_refused (on create, on update, and when Creditors Relief rows are put into an allowOther list with conduyt_set_custom_field_options).";
|
|
13
|
+
export const STORE_LIST_NOTE = "STORE-BACKED select (typeahead): fieldType select with optionList \"store\" makes a select whose list lives in the option store (it starts EMPTY: fill it with conduyt_set_custom_field_options), sent as options { optionList: \"store\", allowOther } with NO inline choices (options may carry only { visibility } beside it, merged into the store options; any other key or an array is inline choices and is refused; formula cannot be combined with it). A record stores the plain LABEL text, never an option id. allowOther is REQUIRED with optionList: true = a typed value that is not on the list is also taken (stored as typed: trimmed, 1 to 200 characters), false = strict (an off-list value is refused custom_field_value_not_on_list). " + ALLOW_OTHER_RULE_NOTE + " Codes: 422 custom_field_options_invalid (optionList or allowOther on a non-select, allowOther without optionList, choices beside a list), 422 custom_field_option_list_full (conduyt_set_custom_field_options with more than 1000 options, or a list that would pass 20000 rows counting deactivated ones), 400 / 422 custom_field_value_not_on_list (a record write of an off-list value to a strict list; an unchanged re-send of a stored value is never re-judged, so a deactivated label stays readable and re-sendable). conduyt_list_custom_fields rows carry optionCount (ACTIVE rows of a store-backed list, the choices count of an inline select / radio / multiselect, null for every other type).";
|
|
14
|
+
export const STORE_UPDATE_NOTE = "Update of a store-backed select: allowOther (true or false) switches it in place (sent as options { optionList: \"store\", allowOther }); inline choices (an options array or any options key but visibility), formula or a type change on it are 422 custom_field_option_list_convert_refused; options { visibility } alone may ride with allowOther (there is no way back to inline choices). Turning a select that has inline choices INTO a store-backed list (the convert: every choice becomes a row, the choices are cleared) is optionList \"store\" plus allowOther and NOTHING else (id, optionList and allowOther only, no options at all, visibility included, which the server keeps; anything beside them is refused here and by the server 422 custom_field_option_list_convert_refused); it is an owner / admin SIGNED-IN action only, so with this server's API key it answers 403 field_type_change_forbidden; 409 custom_field_option_list_convert_refused when the field became or stopped being a list between the read and the lock. Codes: 422 custom_field_options_invalid, 422 custom_field_value_not_on_list (a record write), 422 custom_field_option_list_full (the list itself: conduyt_set_custom_field_options). " + ALLOW_OTHER_RULE_NOTE;
|
|
15
|
+
export const OPTIONS_ACCESS_NOTE = "Reads need settings.view or view on the field's entity module; writes need settings.edit (API keys included; no new scope). Codes: 404 custom_field_not_found (unknown id), 422 custom_field_not_list_backed (the field is not a store-backed select).";
|
|
16
|
+
export const SEARCH_NOTE = "Typeahead read of the list of a STORE-BACKED select (GET /custom-fields/{id}/options): ACTIVE options only, prefix hits first then the other substring hits, each tier by sortKey, label, id. q is a case-insensitive substring (trimmed, at most 200 characters; % _ and \\ match themselves; empty = list from the top); limit 1 to 200 (default 50); cursor is the previous page's nextCursor passed back UNCHANGED (opaque; a cursor the route did not issue is 400 invalid_cursor). Answers { data: Option[], hasMore, nextCursor } (nextCursor null on the last page) with Option = { id, label, externalId, externalSource, sortKey, active }; page until hasMore is false. Each parameter is sent at most once (a repeat is 400 invalid_query). " + OPTIONS_ACCESS_NOTE;
|
|
17
|
+
export const SET_NOTE = "REPLACES the active list of a STORE-BACKED select (PUT /custom-fields/{id}/options): the ACTIVE set becomes exactly the options sent, every other option is DEACTIVATED (never deleted; a deactivated label that comes back is reactivated). Each option is { label, externalId?, externalSource?, sortKey? }: label 1 to 200 characters, trimmed, unique after trimming; externalId 1 to 200 or null; externalSource 1 to 64 or null; sortKey 0 to 1000000 (default = the position). An omitted externalId / externalSource keeps the stored value, an explicit null clears it. At most 1000 options per request: more is refused HERE before any request (the server answers 422 custom_field_option_list_full, which is also the answer when the whole list, deactivated rows included, would pass 20000). An EMPTY array is valid and deactivates EVERY option (the active set becomes exactly the request). dryRun / sandbox send the route's dry_run / sandbox query booleans (validate the mutation without persisting it / run it in sandbox mode). Answers { data: { active, added, reactivated, updated, deactivated, unchanged } }; repeating the call with the same options changes nothing (idempotent). 422 custom_field_options_invalid (body shape, a label repeated after trimming, a label over 200), 422 custom_field_allow_other_refused (creditors_relief rows into an allowOther list), 413 body_too_large over 1 MB. " + OPTIONS_ACCESS_NOTE;
|
|
18
|
+
export const REMOVE_NOTE = "Deactivates ONE option of a STORE-BACKED select (DELETE /custom-fields/{id}/options/{optionId}; the row is kept, a record that holds its label keeps the value, it just stops being offered / accepted on a strict list). Idempotent: answers { data: { option, changed } } with changed false when it was already inactive. 404 custom_field_option_not_found (an option id that is not on this field). The optionId is the id of an option row from conduyt_search_custom_field_options. dryRun / sandbox send the route's dry_run / sandbox query booleans. " + OPTIONS_ACCESS_NOTE;
|
|
19
|
+
export const RESOLVE_NOTE = "Is this exact label on the list of a STORE-BACKED select? (GET /custom-fields/{id}/options/resolve?label=...) label is 1 to 200 characters, matched EXACTLY (case-sensitive, not trimmed). Answers { data: { label, onList, option } } where option is the ACTIVE row or null. Read-only: a lookup that writes nothing (the contract has one route, so there is no dry-run / apply pair). " + OPTIONS_ACCESS_NOTE;
|
|
20
|
+
const nullable = (s) => z.union([s, z.null()]);
|
|
21
|
+
/** one row of the PUT body, strict (the route's additionalProperties false) */
|
|
22
|
+
export const optionRowSchema = z
|
|
23
|
+
.object({
|
|
24
|
+
label: z.string().trim().min(1).max(STORE_LABEL_MAX).describe("The option text (1 to 200 characters after trimming; unique in the request after trimming)"),
|
|
25
|
+
externalId: nullable(z.string().trim().min(1).max(200)).optional().describe("Partner id, 1 to 200 characters, or null to clear; omitted keeps the stored value"),
|
|
26
|
+
externalSource: nullable(z.string().trim().min(1).max(64)).optional().describe("Partner name (e.g. creditors_relief), 1 to 64 characters, or null to clear; omitted keeps the stored value"),
|
|
27
|
+
sortKey: z.number().int().min(0).max(1000000).optional().describe("Order key 0 to 1000000 (default = the position in the array)"),
|
|
28
|
+
})
|
|
29
|
+
.strict();
|
|
30
|
+
/** the generated dry_run / sandbox query booleans of the two write routes: sent whenever supplied (false included) */
|
|
31
|
+
export function writeQuery(p) {
|
|
32
|
+
const usp = new URLSearchParams();
|
|
33
|
+
if (p.dryRun !== undefined)
|
|
34
|
+
usp.set("dry_run", String(p.dryRun));
|
|
35
|
+
if (p.sandbox !== undefined)
|
|
36
|
+
usp.set("sandbox", String(p.sandbox));
|
|
37
|
+
const s = usp.toString();
|
|
38
|
+
return s ? `?${s}` : "";
|
|
39
|
+
}
|
|
40
|
+
export const writeFlags = {
|
|
41
|
+
dryRun: z.boolean().optional().describe("Send dry_run: validate the mutation without persisting it"),
|
|
42
|
+
sandbox: z.boolean().optional().describe("Send sandbox: run the mutation in sandbox mode"),
|
|
43
|
+
};
|
|
44
|
+
/** a store-backed list's options object may also carry `visibility` (and nothing else beside optionList / allowOther): the object of the options input, or a problem text for anything else (inline choices) */
|
|
45
|
+
function visibilityOnly(options) {
|
|
46
|
+
if (options === undefined)
|
|
47
|
+
return {};
|
|
48
|
+
const isObj = options !== null && typeof options === "object" && !Array.isArray(options);
|
|
49
|
+
if (!isObj || Object.keys(options).some((k) => k !== "visibility"))
|
|
50
|
+
return "A store-backed select carries no inline choices: drop options, or pass only { visibility } in it (the list is managed with conduyt_set_custom_field_options).";
|
|
51
|
+
return "visibility" in options ? { visibility: options.visibility } : {};
|
|
52
|
+
}
|
|
53
|
+
/** create: the store-list options object, or a problem text (undefined options = no store flag was passed) */
|
|
54
|
+
export function storeCreateProblem(p) {
|
|
55
|
+
if (p.optionList === undefined && p.allowOther === undefined)
|
|
56
|
+
return undefined;
|
|
57
|
+
if (p.optionList !== undefined && p.optionList !== "store")
|
|
58
|
+
return `optionList must be "store" (the only list kind).`;
|
|
59
|
+
const vis = visibilityOnly(p.options);
|
|
60
|
+
if (typeof vis === "string")
|
|
61
|
+
return vis;
|
|
62
|
+
if (p.fieldType !== "select")
|
|
63
|
+
return "optionList store belongs to fieldType select.";
|
|
64
|
+
if (p.allowOther === undefined)
|
|
65
|
+
return "optionList store needs allowOther (true or false): allowOther is required with optionList (the server answers 422 custom_field_options_invalid without it).";
|
|
66
|
+
if (p.optionList === undefined)
|
|
67
|
+
return "allowOther on create belongs to a store-backed select: pass optionList \"store\" (fieldType select).";
|
|
68
|
+
return { options: { optionList: "store", allowOther: p.allowOther, ...vis } };
|
|
69
|
+
}
|
|
70
|
+
/** update: allowOther alone switches in place; optionList store (the convert) goes alone with allowOther */
|
|
71
|
+
export function storeUpdateProblem(updates) {
|
|
72
|
+
const { optionList, allowOther, ...rest } = updates;
|
|
73
|
+
if (optionList === undefined && allowOther === undefined)
|
|
74
|
+
return undefined;
|
|
75
|
+
if (optionList !== undefined && optionList !== "store")
|
|
76
|
+
return `optionList must be "store" (the only list kind).`;
|
|
77
|
+
const vis = visibilityOnly(rest.options);
|
|
78
|
+
if (typeof vis === "string")
|
|
79
|
+
return vis;
|
|
80
|
+
if (allowOther === undefined)
|
|
81
|
+
return "optionList store needs allowOther (true or false): allowOther is required with optionList (the server answers 422 custom_field_options_invalid without it).";
|
|
82
|
+
if (optionList !== undefined) {
|
|
83
|
+
// the convert is optionList + allowOther only (visibility is kept by the server, never sent with it)
|
|
84
|
+
const extra = Object.keys(rest).filter((k) => rest[k] !== undefined);
|
|
85
|
+
if (extra.length > 0)
|
|
86
|
+
return `optionList store (the convert to a store-backed list) must be sent alone with allowOther: drop ${extra.join(", ")}.`;
|
|
87
|
+
}
|
|
88
|
+
return { options: { optionList: "store", allowOther: allowOther, ...vis } };
|
|
89
|
+
}
|
|
90
|
+
/** set: the rows judged before any request (labels unique after trimming; the cap; an empty list needs confirmation) */
|
|
91
|
+
export function setRowsProblem(rows) {
|
|
92
|
+
if (rows.length > STORE_LIST_MAX_PER_REQUEST)
|
|
93
|
+
return `A request holds at most ${STORE_LIST_MAX_PER_REQUEST} options (got ${rows.length}); the server answers 422 custom_field_option_list_full above that. Nothing was sent.`;
|
|
94
|
+
const seen = new Set();
|
|
95
|
+
for (const [i, r] of rows.entries()) {
|
|
96
|
+
const t = r.label.trim();
|
|
97
|
+
if (t.length < 1 || t.length > STORE_LABEL_MAX)
|
|
98
|
+
return `option ${i + 1}: label must be 1 to ${STORE_LABEL_MAX} characters after trimming.`;
|
|
99
|
+
if (seen.has(t))
|
|
100
|
+
return `option ${i + 1}: label ${JSON.stringify(t)} is repeated after trimming (labels are unique; 422 custom_field_options_invalid).`;
|
|
101
|
+
seen.add(t);
|
|
102
|
+
}
|
|
103
|
+
return undefined;
|
|
104
|
+
}
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
|
-
"generatedAt": "2026-11-
|
|
3
|
-
"toolCount":
|
|
4
|
-
"totalEndpoints":
|
|
2
|
+
"generatedAt": "2026-11-14T23:17:44.183Z",
|
|
3
|
+
"toolCount": 437,
|
|
4
|
+
"totalEndpoints": 1214,
|
|
5
5
|
"counts": {
|
|
6
|
-
"covered":
|
|
7
|
-
"excluded":
|
|
6
|
+
"covered": 386,
|
|
7
|
+
"excluded": 374,
|
|
8
8
|
"planned": 454,
|
|
9
9
|
"uncategorized": 0
|
|
10
10
|
},
|
|
@@ -441,6 +441,10 @@
|
|
|
441
441
|
"status": "excluded",
|
|
442
442
|
"reason": "super-admin platform operations (Conduyt staff only)"
|
|
443
443
|
},
|
|
444
|
+
"POST /api/v1/admin/external-deletions/calendar-ops/:id/abandon": {
|
|
445
|
+
"status": "excluded",
|
|
446
|
+
"reason": "super-admin platform operations (Conduyt staff only)"
|
|
447
|
+
},
|
|
444
448
|
"POST /api/v1/admin/external-deletions/calendar-ops/:id/resolve": {
|
|
445
449
|
"status": "excluded",
|
|
446
450
|
"reason": "super-admin platform operations (Conduyt staff only)"
|
|
@@ -2164,6 +2168,10 @@
|
|
|
2164
2168
|
"status": "excluded",
|
|
2165
2169
|
"reason": "CRON_SECRET-gated infrastructure jobs; never key-callable"
|
|
2166
2170
|
},
|
|
2171
|
+
"GET /api/v1/cron/process-calendar-by-key": {
|
|
2172
|
+
"status": "excluded",
|
|
2173
|
+
"reason": "CRON_SECRET-gated infrastructure jobs; never key-callable"
|
|
2174
|
+
},
|
|
2167
2175
|
"GET /api/v1/cron/process-calendar-provider-ops": {
|
|
2168
2176
|
"status": "excluded",
|
|
2169
2177
|
"reason": "CRON_SECRET-gated infrastructure jobs; never key-callable"
|
|
@@ -2537,6 +2545,30 @@
|
|
|
2537
2545
|
"status": "planned",
|
|
2538
2546
|
"reason": "custom field admin beyond read"
|
|
2539
2547
|
},
|
|
2548
|
+
"GET /api/v1/custom-fields/:id/options": {
|
|
2549
|
+
"status": "covered",
|
|
2550
|
+
"tools": [
|
|
2551
|
+
"conduyt_search_custom_field_options"
|
|
2552
|
+
]
|
|
2553
|
+
},
|
|
2554
|
+
"PUT /api/v1/custom-fields/:id/options": {
|
|
2555
|
+
"status": "covered",
|
|
2556
|
+
"tools": [
|
|
2557
|
+
"conduyt_set_custom_field_options"
|
|
2558
|
+
]
|
|
2559
|
+
},
|
|
2560
|
+
"DELETE /api/v1/custom-fields/:id/options/:optionId": {
|
|
2561
|
+
"status": "covered",
|
|
2562
|
+
"tools": [
|
|
2563
|
+
"conduyt_remove_custom_field_option"
|
|
2564
|
+
]
|
|
2565
|
+
},
|
|
2566
|
+
"GET /api/v1/custom-fields/:id/options/resolve": {
|
|
2567
|
+
"status": "covered",
|
|
2568
|
+
"tools": [
|
|
2569
|
+
"conduyt_resolve_custom_field_options"
|
|
2570
|
+
]
|
|
2571
|
+
},
|
|
2540
2572
|
"GET /api/v1/dashboard": {
|
|
2541
2573
|
"status": "covered",
|
|
2542
2574
|
"tools": [
|