@workover/mcp 0.21.0 → 0.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib.mjs CHANGED
@@ -29,6 +29,89 @@ import {
29
29
  unpublishSite,
30
30
  renderUnpublish,
31
31
  } from './site-setup.mjs';
32
+ import {
33
+ detectFramework,
34
+ FRAMEWORKS,
35
+ renderInstall,
36
+ renderSupportHome,
37
+ renderSupportSetup,
38
+ renderSupportNotifications,
39
+ renderSupportStatus,
40
+ renderSupportTest,
41
+ NOTIFY_CHANNELS,
42
+ NOTIFY_EVENTS,
43
+ renderSupportThread,
44
+ reportStep,
45
+ sendTest,
46
+ supportNotifications,
47
+ HOME_FIELDS,
48
+ supportHome,
49
+ supportScopeHelp,
50
+ supportSetup,
51
+ supportStatus,
52
+ supportThread,
53
+ writeIdentitySecret,
54
+ } from './support-setup.mjs';
55
+ import {
56
+ MAX_PDF_JSON_BYTES,
57
+ addPdf,
58
+ addSource,
59
+ listSources,
60
+ removeSource,
61
+ renderSourceAdded,
62
+ renderSourceLine,
63
+ renderSourceRemoved,
64
+ renderSources,
65
+ syncSource,
66
+ updateSource,
67
+ } from './support-sources.mjs';
68
+ import { AGENT_TEST_TOOLS, runAgentTestTool } from './support-agent-tests.mjs';
69
+ import { CONFIG_TOOLS, configTool } from './support-config.mjs';
70
+ import { WALTER_TOOLS, walterTool } from './support-walter.mjs';
71
+ import { LABEL_TOOLS, runLabelTool } from './support-labels.mjs';
72
+ import { FEEDBACK_BOARD_TOOLS, runFeedbackBoardTool } from './feedback-board.mjs';
73
+ import { CONTACTS_TOOLS, contactsScopeHelp, runContactsTool } from './contacts.mjs';
74
+ import { DOMAINS_TOOLS, runDomainsTool } from './domains.mjs';
75
+ import { JOURNEYS_TOOLS, runJourneysTool } from './journeys.mjs';
76
+ import { EMAIL_STUDIO_TOOLS, runEmailStudioTool } from './email-studio.mjs';
77
+ import { FIELD_TOOLS, runFieldTool } from './support-fields.mjs';
78
+ import { SIGNATURE_TOOLS, runSignatureTool } from './support-signatures.mjs';
79
+ import { EMAIL_TOOLS, runEmailTool } from './support-email.mjs';
80
+ import { INBOX_TOOLS, inboxToolLines } from './support-inbox.mjs';
81
+ import {
82
+ listLabelRules,
83
+ removeLabelRule,
84
+ renderLabelRuleRemoved,
85
+ renderLabelRules,
86
+ renderLabelRuleSet,
87
+ setLabelRule,
88
+ } from './support-label-rules.mjs';
89
+ import {
90
+ checkOutsideBot,
91
+ getOutsideBot,
92
+ renderOutsideBot,
93
+ renderOutsideBotCheck,
94
+ setOutsideBot,
95
+ } from './support-outside-bot.mjs';
96
+ import {
97
+ clearOutcome,
98
+ getOutcomeUsage,
99
+ listOutcomes,
100
+ markOutcome,
101
+ outcomesCsv,
102
+ renderOutcomeMark,
103
+ renderOutcomes,
104
+ renderOutcomeUsage,
105
+ } from './support-outcomes.mjs';
106
+ import {
107
+ checkFreshdesk,
108
+ getFreshdesk,
109
+ removeFreshdesk,
110
+ renderFreshdesk,
111
+ renderFreshdeskCheck,
112
+ renderFreshdeskRemoved,
113
+ setFreshdesk,
114
+ } from './support-freshdesk.mjs';
32
115
  import {
33
116
  addApiReference,
34
117
  addRedirects,
@@ -295,6 +378,60 @@ export const SITE_TOOLS = new Set([
295
378
  'workover_unpublish_site',
296
379
  ]);
297
380
 
381
+ /** The Support setup tools (support-setup.mjs), all behind the `support` scope (WO-1752, S43; thread S35b). */
382
+ export const SUPPORT_TOOLS = new Set([
383
+ 'workover_support_status',
384
+ 'workover_support_setup',
385
+ 'workover_support_report_step',
386
+ 'workover_support_install',
387
+ 'workover_support_identity_secret',
388
+ 'workover_support_test',
389
+ 'workover_support_notifications',
390
+ 'workover_support_home',
391
+ 'workover_support_thread',
392
+ ]);
393
+
394
+ /** Walter AI's source tools (support-sources.mjs), behind the same `support` scope (WO-1752, S06b). */
395
+ export const SOURCE_TOOLS = new Set([
396
+ 'workover_support_sources',
397
+ 'workover_support_add_source',
398
+ 'workover_support_update_source',
399
+ 'workover_support_sync_source',
400
+ 'workover_support_remove_source',
401
+ ]);
402
+
403
+ /** Walter AI's batch test and release tools, behind the same `support` scope (WO-1752, S06c). */
404
+ export { AGENT_TEST_TOOLS };
405
+
406
+ /** When the AI adds each label (support-label-rules.mjs), behind the same `support` scope (WO-1752, S09). */
407
+ export const LABEL_RULE_TOOLS = new Set([
408
+ 'workover_support_label_rules',
409
+ 'workover_support_set_label_rule',
410
+ 'workover_support_remove_label_rule',
411
+ ]);
412
+
413
+ /** Support's outside bot (support-outside-bot.mjs), behind the same `support` scope (WO-1752, S14). */
414
+ export const OUTSIDE_BOT_TOOLS = new Set([
415
+ 'workover_support_outside_bot',
416
+ 'workover_support_set_outside_bot',
417
+ 'workover_support_check_outside_bot',
418
+ ]);
419
+
420
+ /** Walter AI's outcome ledger (support-outcomes.mjs), behind the same `support` scope (WO-1752, S65). */
421
+ export const OUTCOME_TOOLS = new Set([
422
+ 'workover_support_outcomes',
423
+ 'workover_support_outcome_mark',
424
+ 'workover_support_outcome_usage',
425
+ ]);
426
+
427
+ /** Freshdesk escalation setup (support-freshdesk.mjs), behind the same `support` scope (WO-1752, S18). */
428
+ export const FRESHDESK_TOOLS = new Set([
429
+ 'workover_support_freshdesk',
430
+ 'workover_support_set_freshdesk',
431
+ 'workover_support_check_freshdesk',
432
+ 'workover_support_remove_freshdesk',
433
+ ]);
434
+
298
435
  /**
299
436
  * A sentence when a document link is for a different Workover than the one signed in to, else null.
300
437
  *
@@ -579,14 +716,50 @@ export const vetImagePath = (p, { realpath = realpathSync, stat = statSync } = {
579
716
  return { path: real, ext };
580
717
  };
581
718
 
719
+ /**
720
+ * Decide whether `workover_support_add_source` may read a local path as a PDF for Walter AI. The
721
+ * same reasoning as `vetImagePath`, with more at stake: the PDF becomes something the agent answers
722
+ * ANONYMOUS visitors from, so a model talked into "adding" a statement kept in a dot directory would
723
+ * publish it, in effect. So: symlinks resolved first, nothing hidden, a `.pdf` name, a plain file,
724
+ * and the size checked against what the JSON route takes before a byte is read. Returns
725
+ * `{ path }` (the real path) or `{ error }`.
726
+ */
727
+ export const vetPdfPath = (p, { realpath = realpathSync, stat = statSync } = {}) => {
728
+ let real;
729
+ try {
730
+ real = realpath(p);
731
+ } catch {
732
+ return { error: `Couldn't read a PDF at ${p}. Nothing was added.` };
733
+ }
734
+ if (real.split(/[\\/]/).some((part) => part.startsWith('.') && part !== '.' && part !== '..'))
735
+ return {
736
+ error: `Refusing to upload ${p}: it is a hidden file or inside a hidden directory. Save the PDF somewhere ordinary and pass that path. Nothing was added.`,
737
+ };
738
+ if (!/\.pdf$/i.test(basename(real)))
739
+ return { error: `Refusing to upload ${p}: only a .pdf file can be a source. Nothing was added.` };
740
+ let info;
741
+ try {
742
+ info = stat(real);
743
+ } catch {
744
+ return { error: `Couldn't read a PDF at ${p}. Nothing was added.` };
745
+ }
746
+ if (!info.isFile()) return { error: `${p} is not a file. Nothing was added.` };
747
+ if (info.size > MAX_PDF_JSON_BYTES)
748
+ return {
749
+ error: `${p} is ${Math.round(info.size / 1e5) / 10} MB. Files up to 3.5 MB upload from here; larger ones (up to 20 MB) upload in the app, under Support, AI answers, Sources. Nothing was added.`,
750
+ };
751
+ return { path: real };
752
+ };
753
+
582
754
  /**
583
755
  * Build the authenticated JSON API caller. `fetchImpl` is injectable for tests. The status→message
584
756
  * mapping is the contract the tools rely on (401/403 are friendly, other non-2xx is generic).
585
757
  */
586
758
  export function makeApi({ auth, fetchImpl = fetch }) {
587
759
  async function api(path, init) {
760
+ const { raw, ...rest } = init ?? {};
588
761
  const res = await fetchImpl(`${auth.api}${path}`, {
589
- ...init,
762
+ ...rest,
590
763
  headers: { authorization: `Bearer ${auth.token}`, ...(init?.headers || {}) },
591
764
  });
592
765
  if (res.status === 401)
@@ -613,7 +786,8 @@ export function makeApi({ auth, fetchImpl = fetch }) {
613
786
  : '';
614
787
  throw new Error(`Workover API error (${res.status})${detail ? `: ${detail}` : '.'}`);
615
788
  }
616
- return res.json();
789
+ // A CSV export comes back as text (`raw: true`; not passed on to fetch).
790
+ return raw ? res.text() : res.json();
617
791
  }
618
792
  const apiPost = (path, body) =>
619
793
  api(path, {
@@ -629,11 +803,12 @@ export function makeApi({ auth, fetchImpl = fetch }) {
629
803
  * short-circuits before any request; unknown tools and thrown errors become `err(...)`. `readFile`
630
804
  * and `fetchImpl` are injected so the upload path is testable without touching the disk/network.
631
805
  */
632
- export function makeDispatch({ auth, api, apiPost, fetchImpl = fetch, readFile, fsOps, siteWait, clientInfo }) {
806
+ export function makeDispatch({ auth, api, apiPost, fetchImpl = fetch, readFile, fsOps, siteWait, supportFiles, supportWait, clientInfo }) {
633
807
  // The site tools' caller (site-setup.mjs): the same authenticated `api`, with a body as JSON.
634
- const call = (path, { method, body } = {}) =>
808
+ const call = (path, { method, body, raw } = {}) =>
635
809
  api(path, {
636
810
  method: method || 'GET',
811
+ ...(raw ? { raw: true } : {}),
637
812
  ...(body ? { headers: { 'content-type': 'application/json' }, body: JSON.stringify(body) } : {}),
638
813
  });
639
814
  // An MCP call should not hold the client for minutes: an import or publish still running after
@@ -804,6 +979,304 @@ export function makeDispatch({ auth, api, apiPost, fetchImpl = fetch, readFile,
804
979
  return err(`Unknown tool: ${name}`);
805
980
  }
806
981
 
982
+ /**
983
+ * The Support setup tools. Every one needs a token from `workover login --support`. `supportFiles`
984
+ * is `{ exists, read, write }`: the app's files for finding its framework, and the env file the
985
+ * identity secret is written into (it never comes back to the model).
986
+ */
987
+ async function supportTool(name, args) {
988
+ const workspace = args.workspace === undefined || args.workspace === null ? undefined : String(args.workspace);
989
+ try {
990
+ if (name === 'workover_support_status') {
991
+ const res = await supportStatus(call, { workspace });
992
+ return lines(renderSupportStatus(res, { web }));
993
+ }
994
+ if (name === 'workover_support_setup') {
995
+ const pick = {};
996
+ for (const k of ['name', 'color', 'greeting', 'origins', 'topics', 'projectIds', 'hours', 'agentEnabled', 'enabled'])
997
+ if (args[k] !== undefined) pick[k] = args[k];
998
+ const res = await supportSetup(call, { workspace, ...pick });
999
+ return lines(renderSupportSetup(res, { web }));
1000
+ }
1001
+ if (name === 'workover_support_report_step') {
1002
+ const res = await reportStep(call, {
1003
+ workspace,
1004
+ step: args.step,
1005
+ state: args.failed === true ? 'failed' : 'done',
1006
+ detail: typeof args.detail === 'string' ? args.detail : undefined,
1007
+ });
1008
+ return lines(renderSupportStatus(res, { web }));
1009
+ }
1010
+ if (name === 'workover_support_install') {
1011
+ const framework = typeof args.framework === 'string' ? args.framework.toLowerCase() : null;
1012
+ if (framework && !FRAMEWORKS.includes(framework))
1013
+ return err(`No snippet for "${framework}". One of: ${FRAMEWORKS.join(', ')}.`);
1014
+ const status = await supportStatus(call, { workspace });
1015
+ const detected =
1016
+ !framework && typeof args.dir === 'string' && supportFiles ? detectFramework(supportFiles, args.dir) : null;
1017
+ return lines(renderInstall({ status, detected, framework }));
1018
+ }
1019
+ if (name === 'workover_support_identity_secret') {
1020
+ if (!supportFiles) return err('This server cannot write files here. Use `workover support secret --env-file <file>` in a terminal.');
1021
+ // The server's working directory is not necessarily the app's, so a relative path could put
1022
+ // the secret in some other folder's env file.
1023
+ if (typeof args.envFile === 'string' && !/^(\/|[A-Za-z]:[\\/])/.test(args.envFile))
1024
+ return err(`Give envFile as an absolute path, such as /path/to/app/.env.local ("${args.envFile}" is relative). Nothing was created.`);
1025
+ const res = await writeIdentitySecret(call, supportFiles, {
1026
+ workspace,
1027
+ envFile: args.envFile,
1028
+ varName: typeof args.varName === 'string' ? args.varName : undefined,
1029
+ rotate: args.rotate === true,
1030
+ });
1031
+ return text(
1032
+ `${res.rotated ? 'Rotated' : 'Created'} the identity secret and wrote it to ${res.envFile} as ${res.varName}. It is not shown here. Keep that file out of version control and out of the browser bundle.`,
1033
+ );
1034
+ }
1035
+ if (name === 'workover_support_notifications') {
1036
+ // Only the known switches, and only booleans: anything else is named back, nothing sent.
1037
+ const set = {};
1038
+ for (const [k, v] of Object.entries(args || {})) {
1039
+ if (k === 'workspace') continue;
1040
+ if (![...NOTIFY_CHANNELS, ...NOTIFY_EVENTS].includes(k))
1041
+ return err(`"${k}" is not a Support notification switch. One of: ${[...NOTIFY_CHANNELS, ...NOTIFY_EVENTS].join(', ')}. Nothing was changed.`);
1042
+ if (typeof v !== 'boolean') return err(`${k} is true or false. Nothing was changed.`);
1043
+ set[k] = v;
1044
+ }
1045
+ const res = await supportNotifications(call, { set });
1046
+ return lines(renderSupportNotifications(res));
1047
+ }
1048
+ if (name === 'workover_support_home') {
1049
+ const pick = {};
1050
+ for (const k of HOME_FIELDS) if (args[k] !== undefined) pick[k] = args[k];
1051
+ const res = await supportHome(call, { workspace, ...pick });
1052
+ return lines(renderSupportHome(res));
1053
+ }
1054
+ if (name === 'workover_support_test') {
1055
+ const res = await sendTest(call, { workspace, ...(supportWait || {}) });
1056
+ const out = lines(renderSupportTest(res, { web }));
1057
+ return res.confirmed ? out : err(out.content[0].text);
1058
+ }
1059
+ if (name === 'workover_support_thread') {
1060
+ if (args.closedStaysClosed !== undefined && typeof args.closedStaysClosed !== 'boolean')
1061
+ return err('closedStaysClosed is true or false. Nothing was changed.');
1062
+ const res = await supportThread(call, { workspace, closedStaysClosed: args.closedStaysClosed });
1063
+ return lines(renderSupportThread(res));
1064
+ }
1065
+ } catch (e) {
1066
+ const help = supportScopeHelp(e?.message);
1067
+ return err(`${e?.message || 'Something went wrong.'}${help ? `\n\n${help}` : ''}`);
1068
+ }
1069
+ return err(`Unknown tool: ${name}`);
1070
+ }
1071
+
1072
+ /** Support's email follow-ups (support-email.mjs, real widths M3), behind the same `support` scope. */
1073
+ async function emailTool(name, args) {
1074
+ try {
1075
+ return lines(await runEmailTool(call, name, args ?? {}));
1076
+ } catch (e) {
1077
+ const help = supportScopeHelp(e?.message);
1078
+ return err(`${e?.message || 'Something went wrong.'}${help ? `\n\n${help}` : ''}`);
1079
+ }
1080
+ }
1081
+
1082
+ /** Support's email signatures (support-signatures.mjs, S10b), behind the same `support` scope. */
1083
+ async function signatureTool(name, args) {
1084
+ try {
1085
+ return lines(await runSignatureTool(call, name, args ?? {}));
1086
+ } catch (e) {
1087
+ const help = supportScopeHelp(e?.message);
1088
+ return err(`${e?.message || 'Something went wrong.'}${help ? `\n\n${help}` : ''}`);
1089
+ }
1090
+ }
1091
+
1092
+ /** Support's conversation fields (support-fields.mjs, S38), behind the same `support` scope. */
1093
+ async function fieldTool(name, args) {
1094
+ try {
1095
+ return lines(await runFieldTool(call, name, args ?? {}));
1096
+ } catch (e) {
1097
+ const help = supportScopeHelp(e?.message);
1098
+ return err(`${e?.message || 'Something went wrong.'}${help ? `\n\n${help}` : ''}`);
1099
+ }
1100
+ }
1101
+
1102
+ /** Support's labels (support-labels.mjs, S63), behind the same `support` scope. */
1103
+ async function labelTool(name, args) {
1104
+ try {
1105
+ return lines(await runLabelTool(call, name, args ?? {}));
1106
+ } catch (e) {
1107
+ const help = supportScopeHelp(e?.message);
1108
+ return err(`${e?.message || 'Something went wrong.'}${help ? `\n\n${help}` : ''}`);
1109
+ }
1110
+ }
1111
+
1112
+ /**
1113
+ * Walter AI's sources (support-sources.mjs). `readFile` reads the PDF a path names; only an
1114
+ * absolute path is taken, since the server's working directory is not the person's.
1115
+ */
1116
+ async function sourceTool(name, args) {
1117
+ const workspace = args.workspace === undefined || args.workspace === null ? undefined : String(args.workspace);
1118
+ try {
1119
+ if (name === 'workover_support_sources') return lines(renderSources(await listSources(call, { workspace })));
1120
+ if (name === 'workover_support_add_source') {
1121
+ if (String(args.kind ?? '').toLowerCase() === 'pdf') {
1122
+ if (typeof args.file !== 'string' || !/^(\/|[A-Za-z]:[\\/])/.test(args.file))
1123
+ return err('Give file as the absolute path of the PDF, such as /path/to/refunds.pdf. Nothing was added.');
1124
+ if (!readFile) return err('This server cannot read files here. Use `workover support sources pdf <file>` in a terminal.');
1125
+ const vetted = vetPdfPath(args.file, fsOps);
1126
+ if (vetted.error) return err(vetted.error);
1127
+ let bytes;
1128
+ try {
1129
+ bytes = readFile(vetted.path);
1130
+ } catch {
1131
+ return err(`Could not read ${args.file}. Nothing was added.`);
1132
+ }
1133
+ if (!bytes?.length || Buffer.from(bytes.subarray(0, 5)).toString('latin1') !== '%PDF-')
1134
+ return err(`${args.file} is not a PDF. Nothing was added.`);
1135
+ const fileName = basename(vetted.path);
1136
+ return lines(renderSourceAdded(await addPdf(call, { workspace, name: fileName, bytes })));
1137
+ }
1138
+ const res = await addSource(call, {
1139
+ workspace,
1140
+ kind: args.kind,
1141
+ url: args.url,
1142
+ projectId: args.projectId,
1143
+ resyncHours: args.resyncHours,
1144
+ });
1145
+ return lines(renderSourceAdded(res));
1146
+ }
1147
+ if (name === 'workover_support_update_source') {
1148
+ const res = await updateSource(call, {
1149
+ workspace,
1150
+ sourceId: args.sourceId,
1151
+ enabled: typeof args.enabled === 'boolean' ? args.enabled : undefined,
1152
+ resyncHours: args.resyncHours,
1153
+ });
1154
+ return lines(['Saved.', ...renderSourceLine(res.source)]);
1155
+ }
1156
+ if (name === 'workover_support_sync_source') {
1157
+ const res = await syncSource(call, { workspace, sourceId: args.sourceId });
1158
+ return lines(['Reading it again now. Call workover_support_sources for ready or failed.', ...renderSourceLine(res.source)]);
1159
+ }
1160
+ if (name === 'workover_support_remove_source')
1161
+ return lines(renderSourceRemoved(await removeSource(call, { workspace, sourceId: args.sourceId })));
1162
+ } catch (e) {
1163
+ const help = supportScopeHelp(e?.message);
1164
+ return err(`${e?.message || 'Something went wrong.'}${help ? `\n\n${help}` : ''}`);
1165
+ }
1166
+ return err(`Unknown tool: ${name}`);
1167
+ }
1168
+
1169
+ /** Walter AI's batch test and releases (support-agent-tests.mjs, S06c). */
1170
+ async function agentTestTool(name, args) {
1171
+ try {
1172
+ return lines(await runAgentTestTool(call, name, args ?? {}, supportWait || {}));
1173
+ } catch (e) {
1174
+ const help = supportScopeHelp(e?.message);
1175
+ return err(`${e?.message || 'Something went wrong.'}${help ? `\n\n${help}` : ''}`);
1176
+ }
1177
+ }
1178
+
1179
+ /** When the AI adds each label (support-label-rules.mjs). */
1180
+ async function labelRuleTool(name, args) {
1181
+ const workspace = args.workspace === undefined || args.workspace === null ? undefined : String(args.workspace);
1182
+ try {
1183
+ if (name === 'workover_support_label_rules') return lines(renderLabelRules(await listLabelRules(call, { workspace })));
1184
+ if (name === 'workover_support_set_label_rule')
1185
+ return lines(
1186
+ renderLabelRuleSet(
1187
+ await setLabelRule(call, {
1188
+ workspace,
1189
+ label: args.label,
1190
+ instruction: args.instruction,
1191
+ enabled: typeof args.enabled === 'boolean' ? args.enabled : undefined,
1192
+ }),
1193
+ ),
1194
+ );
1195
+ if (name === 'workover_support_remove_label_rule')
1196
+ return lines(renderLabelRuleRemoved(await removeLabelRule(call, { workspace, label: args.label })));
1197
+ } catch (e) {
1198
+ const help = supportScopeHelp(e?.message);
1199
+ return err(`${e?.message || 'Something went wrong.'}${help ? `\n\n${help}` : ''}`);
1200
+ }
1201
+ return err(`Unknown tool: ${name}`);
1202
+ }
1203
+
1204
+ /** Support's outside bot (support-outside-bot.mjs). */
1205
+ async function outsideBotTool(name, args) {
1206
+ const workspace = args.workspace === undefined || args.workspace === null ? undefined : String(args.workspace);
1207
+ try {
1208
+ if (name === 'workover_support_outside_bot') return lines(renderOutsideBot(await getOutsideBot(call, { workspace })));
1209
+ if (name === 'workover_support_set_outside_bot') {
1210
+ const { workspace: _w, ...patch } = args;
1211
+ return lines(renderOutsideBot(await setOutsideBot(call, { workspace, ...patch })));
1212
+ }
1213
+ if (name === 'workover_support_check_outside_bot')
1214
+ return lines(renderOutsideBotCheck(await checkOutsideBot(call, { workspace })));
1215
+ } catch (e) {
1216
+ const help = supportScopeHelp(e?.message);
1217
+ return err(`${e?.message || 'Something went wrong.'}${help ? `\n\n${help}` : ''}`);
1218
+ }
1219
+ return err(`Unknown tool: ${name}`);
1220
+ }
1221
+
1222
+ /** Walter AI's outcome ledger (support-outcomes.mjs). */
1223
+ async function outcomeTool(name, args) {
1224
+ const workspace = args.workspace === undefined || args.workspace === null ? undefined : String(args.workspace);
1225
+ try {
1226
+ if (name === 'workover_support_outcomes') {
1227
+ const filters = { workspace, outcome: args.outcome, from: args.from, to: args.to };
1228
+ if (args.csv === true) {
1229
+ const res = await listOutcomes(call, { ...filters, all: true });
1230
+ return text(outcomesCsv(res.rows).replace(/^\uFEFF/, '') + (res.truncated ? '\n(only the first 10,000 rows)' : ''));
1231
+ }
1232
+ return lines(renderOutcomes(await listOutcomes(call, { ...filters, cursor: args.cursor })));
1233
+ }
1234
+ if (name === 'workover_support_outcome_mark') {
1235
+ const res =
1236
+ args.clear === true
1237
+ ? await clearOutcome(call, { workspace, conversation: args.conversation })
1238
+ : await markOutcome(call, { workspace, conversation: args.conversation, reason: args.reason });
1239
+ return lines(renderOutcomeMark(res));
1240
+ }
1241
+ if (name === 'workover_support_outcome_usage') return lines(renderOutcomeUsage(await getOutcomeUsage(call, { workspace })));
1242
+ } catch (e) {
1243
+ const help = supportScopeHelp(e?.message);
1244
+ return err(`${e?.message || 'Something went wrong.'}${help ? `\n\n${help}` : ''}`);
1245
+ }
1246
+ return err(`Unknown tool: ${name}`);
1247
+ }
1248
+
1249
+ /** Freshdesk escalation setup (support-freshdesk.mjs). */
1250
+ async function freshdeskTool(name, args) {
1251
+ const workspace = args.workspace === undefined || args.workspace === null ? undefined : String(args.workspace);
1252
+ try {
1253
+ if (name === 'workover_support_freshdesk') return lines(renderFreshdesk(await getFreshdesk(call, { workspace })));
1254
+ if (name === 'workover_support_set_freshdesk')
1255
+ return lines(
1256
+ renderFreshdesk(
1257
+ await setFreshdesk(call, {
1258
+ workspace,
1259
+ domain: args.domain,
1260
+ apiKey: args.apiKey,
1261
+ mode: args.mode,
1262
+ priority: args.priority,
1263
+ groupId: args.groupId,
1264
+ tags: args.tags,
1265
+ closeAfter: typeof args.closeAfter === 'boolean' ? args.closeAfter : undefined,
1266
+ }),
1267
+ ),
1268
+ );
1269
+ if (name === 'workover_support_check_freshdesk')
1270
+ return lines(renderFreshdeskCheck(await checkFreshdesk(call, { workspace })));
1271
+ if (name === 'workover_support_remove_freshdesk')
1272
+ return lines(renderFreshdeskRemoved(await removeFreshdesk(call, { workspace })));
1273
+ } catch (e) {
1274
+ const help = supportScopeHelp(e?.message);
1275
+ return err(`${e?.message || 'Something went wrong.'}${help ? `\n\n${help}` : ''}`);
1276
+ }
1277
+ return err(`Unknown tool: ${name}`);
1278
+ }
1279
+
807
1280
  return async function dispatch(name, args = {}) {
808
1281
  if (!auth)
809
1282
  return err(
@@ -1285,6 +1758,88 @@ export function makeDispatch({ auth, api, apiPost, fetchImpl = fetch, readFile,
1285
1758
  }
1286
1759
  }
1287
1760
  if (SITE_TOOLS.has(name)) return await siteTool(name, args);
1761
+ if (SUPPORT_TOOLS.has(name)) return await supportTool(name, args);
1762
+ if (SOURCE_TOOLS.has(name)) return await sourceTool(name, args);
1763
+ if (AGENT_TEST_TOOLS.has(name)) return await agentTestTool(name, args);
1764
+ // The Messenger's settings through the editor's draft (support-config.mjs, WO-1752, S46).
1765
+ if (CONFIG_TOOLS.has(name)) {
1766
+ try {
1767
+ return lines(await configTool(call, name, args));
1768
+ } catch (e) {
1769
+ const help = supportScopeHelp(e?.message);
1770
+ return err(`${e?.message || 'Something went wrong.'}${help ? `\n\n${help}` : ''}`);
1771
+ }
1772
+ }
1773
+ // Walter AI's Basics, draft, preview and Deploy checklist (support-walter.mjs, WO-1752, S57).
1774
+ if (WALTER_TOOLS.has(name)) {
1775
+ try {
1776
+ return lines(await walterTool(call, name, args));
1777
+ } catch (e) {
1778
+ const help = supportScopeHelp(e?.message);
1779
+ return err(`${e?.message || 'Something went wrong.'}${help ? `\n\n${help}` : ''}`);
1780
+ }
1781
+ }
1782
+ // Reply targets, auto-assignment and availability (support-inbox.mjs, WO-1752, S08).
1783
+ if (INBOX_TOOLS.has(name)) {
1784
+ try {
1785
+ return lines(await inboxToolLines(call, name, args));
1786
+ } catch (e) {
1787
+ const help = supportScopeHelp(e?.message);
1788
+ return err(`${e?.message || 'Something went wrong.'}${help ? `\n\n${help}` : ''}`);
1789
+ }
1790
+ }
1791
+ if (LABEL_TOOLS.has(name)) return await labelTool(name, args);
1792
+ // Feedback's posts (feedback-board.mjs, WO-1752 round 3): any `workover login` token.
1793
+ if (FEEDBACK_BOARD_TOOLS.has(name)) {
1794
+ try {
1795
+ return lines(await runFeedbackBoardTool(call, name, args ?? {}));
1796
+ } catch (e) {
1797
+ return err(e?.message || 'Something went wrong.');
1798
+ }
1799
+ }
1800
+ // Contacts (contacts.mjs, Contacts CRM step 1): the `contacts` token scope.
1801
+ if (CONTACTS_TOOLS.has(name)) {
1802
+ try {
1803
+ return lines(await runContactsTool(call, name, args ?? {}));
1804
+ } catch (e) {
1805
+ const help = contactsScopeHelp(e?.message);
1806
+ return err(`${e?.message || 'Something went wrong.'}${help ? `\n\n${help}` : ''}`);
1807
+ }
1808
+ }
1809
+ // Sending domains (domains.mjs, WO-1752): the `contacts` token scope too.
1810
+ if (DOMAINS_TOOLS.has(name)) {
1811
+ try {
1812
+ return lines(await runDomainsTool(call, name, args ?? {}));
1813
+ } catch (e) {
1814
+ const help = contactsScopeHelp(e?.message);
1815
+ return err(`${e?.message || 'Something went wrong.'}${help ? `\n\n${help}` : ''}`);
1816
+ }
1817
+ }
1818
+ // Emails designed in blocks (email-studio.mjs, WO-1752): the `contacts` token scope too.
1819
+ if (EMAIL_STUDIO_TOOLS.has(name)) {
1820
+ try {
1821
+ return lines(await runEmailStudioTool(call, name, args ?? {}));
1822
+ } catch (e) {
1823
+ const help = contactsScopeHelp(e?.message);
1824
+ return err(`${e?.message || 'Something went wrong.'}${help ? `\n\n${help}` : ''}`);
1825
+ }
1826
+ }
1827
+ // Contacts journeys (journeys.mjs, WO-1752): the `contacts` token scope too.
1828
+ if (JOURNEYS_TOOLS.has(name)) {
1829
+ try {
1830
+ return lines(await runJourneysTool(call, name, args ?? {}));
1831
+ } catch (e) {
1832
+ const help = contactsScopeHelp(e?.message);
1833
+ return err(`${e?.message || 'Something went wrong.'}${help ? `\n\n${help}` : ''}`);
1834
+ }
1835
+ }
1836
+ if (FIELD_TOOLS.has(name)) return await fieldTool(name, args);
1837
+ if (LABEL_RULE_TOOLS.has(name)) return await labelRuleTool(name, args);
1838
+ if (SIGNATURE_TOOLS.has(name)) return await signatureTool(name, args);
1839
+ if (EMAIL_TOOLS.has(name)) return await emailTool(name, args);
1840
+ if (OUTSIDE_BOT_TOOLS.has(name)) return await outsideBotTool(name, args);
1841
+ if (OUTCOME_TOOLS.has(name)) return await outcomeTool(name, args);
1842
+ if (FRESHDESK_TOOLS.has(name)) return await freshdeskTool(name, args);
1288
1843
  return err(`Unknown tool: ${name}`);
1289
1844
  } catch (e) {
1290
1845
  return err(e?.message || 'Something went wrong.');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workover/mcp",
3
- "version": "0.21.0",
3
+ "version": "0.23.0",
4
4
  "description": "Workover MCP server — let Claude Code and other MCP clients read and cowork on your Workover documents.",
5
5
  "license": "UNLICENSED",
6
6
  "author": "ScaleMath",
@@ -24,6 +24,25 @@
24
24
  "lib.mjs",
25
25
  "site-setup.mjs",
26
26
  "site-folder.mjs",
27
+ "support-inbox.mjs",
28
+ "support-setup.mjs",
29
+ "support-sources.mjs",
30
+ "support-agent-tests.mjs",
31
+ "support-config.mjs",
32
+ "support-walter.mjs",
33
+ "support-labels.mjs",
34
+ "feedback-board.mjs",
35
+ "contacts.mjs",
36
+ "domains.mjs",
37
+ "journeys.mjs",
38
+ "email-studio.mjs",
39
+ "support-fields.mjs",
40
+ "support-label-rules.mjs",
41
+ "support-signatures.mjs",
42
+ "support-email.mjs",
43
+ "support-outside-bot.mjs",
44
+ "support-outcomes.mjs",
45
+ "support-freshdesk.mjs",
27
46
  "telemetry.mjs",
28
47
  "feedback.mjs",
29
48
  "README.md"