@sellable/mcp 0.1.555 → 0.1.557

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.
Files changed (63) hide show
  1. package/README.md +13 -2
  2. package/agents/registry.json +2 -2
  3. package/dist/api.js +3 -6
  4. package/dist/auth.d.ts +0 -6
  5. package/dist/auth.js +2 -44
  6. package/dist/refill-run-client.d.ts +0 -5
  7. package/dist/refill-run-client.js +0 -15
  8. package/dist/refill-run-loop.d.ts +1 -12
  9. package/dist/refill-run-loop.js +13 -158
  10. package/dist/server.js +23 -0
  11. package/dist/tools/auth.d.ts +0 -5
  12. package/dist/tools/auth.js +12 -49
  13. package/dist/tools/campaign-message-preparation.d.ts +0 -62
  14. package/dist/tools/campaign-message-preparation.js +0 -41
  15. package/dist/tools/campaigns.js +2 -2
  16. package/dist/tools/csv-dnc.js +2 -2
  17. package/dist/tools/evergreen-refill-plan.d.ts +0 -3
  18. package/dist/tools/evergreen-refill-plan.js +7 -29
  19. package/dist/tools/find-leads-runs.d.ts +151 -0
  20. package/dist/tools/find-leads-runs.js +98 -0
  21. package/dist/tools/leads.d.ts +317 -32
  22. package/dist/tools/leads.js +171 -10
  23. package/dist/tools/model-quality.js +4 -6
  24. package/dist/tools/prompts.d.ts +3 -3
  25. package/dist/tools/prompts.js +7 -15
  26. package/dist/tools/provider-preflight.d.ts +65 -2
  27. package/dist/tools/provider-preflight.js +97 -10
  28. package/dist/tools/readiness.d.ts +89 -5
  29. package/dist/tools/readiness.js +66 -0
  30. package/dist/tools/refill-executors.d.ts +0 -38
  31. package/dist/tools/refill-executors.js +3 -222
  32. package/dist/tools/refill-sends-v2.d.ts +1 -112
  33. package/dist/tools/refill-sends-v2.js +2 -302
  34. package/dist/tools/refill-sends.d.ts +32 -678
  35. package/dist/tools/refill-sends.js +13 -274
  36. package/dist/tools/refill-target-plan.js +14 -486
  37. package/dist/tools/registry.d.ts +330 -115
  38. package/dist/tools/registry.js +7 -1
  39. package/dist/tools/scheduler-fill-capacity.js +1 -1
  40. package/dist/tools/scheduler-run.d.ts +0 -71
  41. package/dist/tools/scheduler-run.js +1 -203
  42. package/dist/tools/setup-evergreen-campaigns.js +1 -1
  43. package/dist/tools/workspace-context.d.ts +1 -1
  44. package/dist/tools/workspace-context.js +3 -8
  45. package/dist/tools/workspace-export.js +2 -2
  46. package/dist/tools/workspaces.d.ts +2 -48
  47. package/dist/tools/workspaces.js +5 -48
  48. package/package.json +1 -1
  49. package/skills/create-campaign/SKILL.md +3 -3
  50. package/skills/create-campaign-v2/SKILL.md +1 -1
  51. package/skills/create-evergreen-campaigns/SKILL.md +16 -16
  52. package/skills/find-leads/SKILL.md +48 -630
  53. package/skills/find-leads-v2/SKILL.md +70 -0
  54. package/skills/find-leads-v2/core/flow.v1.json +31 -0
  55. package/skills/refill-sends/SKILL.md +353 -91
  56. package/skills/refill-sends-v2/SKILL.md +6 -6
  57. package/skills/refill-sends-v2-workflow/SKILL.md +5 -5
  58. package/skills/refill-sends-v2-workflow/core/flow.v1.json +8 -8
  59. package/skills/refill-sends-workflow/SKILL.md +743 -100
  60. package/skills/refill-sends-workflow/core/flow.v1.json +1 -185
  61. package/dist/refill-contract.d.ts +0 -157
  62. package/dist/refill-contract.js +0 -487
  63. package/skills/refill-sends-workflow/core/contract.v2.json +0 -543
@@ -3,7 +3,6 @@ import { startPrepareCampaignMessages } from "./campaign-message-preparation.js"
3
3
  import { startCampaign } from "./campaigns.js";
4
4
  import { confirmLeadList, importLeads, searchSignals, selectPromisingPosts, } from "./leads.js";
5
5
  import { markProviderPromptLoaded } from "./provider-preflight.js";
6
- import { runSchedulerSweep, } from "./scheduler-run.js";
7
6
  import { refreshPaidInmailCredits } from "./senders.js";
8
7
  import { workspaceRequestOptions } from "./workspace-context.js";
9
8
  const PAID_INMAIL_REFRESH_MAX_ATTEMPTS = 3;
@@ -41,160 +40,6 @@ export function stringValue(value) {
41
40
  export function numberValue(value) {
42
41
  return typeof value === "number" && Number.isFinite(value) ? value : null;
43
42
  }
44
- export function normalizeSchedulerChangedCounts(value) {
45
- const changedCounts = recordValue(value);
46
- if (!changedCounts ||
47
- changedCounts.complete !== true ||
48
- changedCounts.truncated !== false) {
49
- return null;
50
- }
51
- const total = numberValue(changedCounts.total);
52
- if (total === null || total < 0 || !Number.isInteger(total))
53
- return null;
54
- if (!Array.isArray(changedCounts.byCampaignTableActionType))
55
- return null;
56
- const groups = [];
57
- const seen = new Set();
58
- for (const rawGroup of changedCounts.byCampaignTableActionType) {
59
- const group = recordValue(rawGroup);
60
- const campaignId = stringValue(group?.campaignId);
61
- const tableId = stringValue(group?.tableId);
62
- const actionType = stringValue(group?.actionType);
63
- const count = numberValue(group?.count);
64
- if (!campaignId ||
65
- !tableId ||
66
- !actionType ||
67
- count === null ||
68
- count <= 0 ||
69
- !Number.isInteger(count)) {
70
- return null;
71
- }
72
- const key = `${campaignId}:${tableId}:${actionType}`;
73
- if (seen.has(key))
74
- return null;
75
- seen.add(key);
76
- groups.push({ campaignId, tableId, actionType, count });
77
- }
78
- groups.sort((a, b) => {
79
- if (a.campaignId !== b.campaignId) {
80
- return a.campaignId.localeCompare(b.campaignId);
81
- }
82
- if (a.tableId !== b.tableId)
83
- return a.tableId.localeCompare(b.tableId);
84
- return a.actionType.localeCompare(b.actionType);
85
- });
86
- if (groups.reduce((sum, group) => sum + group.count, 0) !== total) {
87
- return null;
88
- }
89
- if (!Array.isArray(changedCounts.byCampaignTableActionTypeSender)) {
90
- return null;
91
- }
92
- const senderGroups = [];
93
- const senderSeen = new Set();
94
- for (const rawGroup of changedCounts.byCampaignTableActionTypeSender) {
95
- const group = recordValue(rawGroup);
96
- const campaignId = stringValue(group?.campaignId);
97
- const tableId = stringValue(group?.tableId);
98
- const actionType = stringValue(group?.actionType);
99
- const senderId = stringValue(group?.senderId);
100
- const count = numberValue(group?.count);
101
- if (!campaignId ||
102
- !tableId ||
103
- !actionType ||
104
- !senderId ||
105
- count === null ||
106
- count <= 0 ||
107
- !Number.isInteger(count)) {
108
- return null;
109
- }
110
- const key = `${campaignId}:${tableId}:${actionType}:${senderId}`;
111
- if (senderSeen.has(key))
112
- return null;
113
- senderSeen.add(key);
114
- senderGroups.push({ campaignId, tableId, actionType, senderId, count });
115
- }
116
- if (senderGroups.reduce((sum, group) => sum + group.count, 0) !== total) {
117
- return null;
118
- }
119
- return {
120
- complete: true,
121
- truncated: false,
122
- total,
123
- byCampaignTableActionType: groups,
124
- byCampaignTableActionTypeSender: senderGroups,
125
- };
126
- }
127
- function completeExpectedTargetSummary(value, expectedTargets, maxPlacements) {
128
- const summary = recordValue(value);
129
- const items = Array.isArray(summary?.items) ? summary.items : [];
130
- if (summary?.complete !== true ||
131
- summary.truncated !== false ||
132
- numberValue(summary.requested) !== expectedTargets.length ||
133
- numberValue(summary.included) == null ||
134
- numberValue(summary.omitted) == null ||
135
- numberValue(summary.included) + numberValue(summary.omitted) !==
136
- expectedTargets.length ||
137
- numberValue(summary.maxPlacements) !== maxPlacements ||
138
- items.length !== expectedTargets.length) {
139
- return false;
140
- }
141
- return items.every((rawItem, index) => {
142
- const item = recordValue(rawItem);
143
- const target = expectedTargets[index];
144
- const senderIds = stringArray(item?.senderIds).sort();
145
- const bySender = Array.isArray(item?.bySender) ? item.bySender : [];
146
- const accounted = bySender
147
- .map((entry) => stringValue(recordValue(entry)?.senderId))
148
- .filter((senderId) => Boolean(senderId))
149
- .sort();
150
- return (Boolean(target) &&
151
- item?.campaignId === target?.campaignId &&
152
- item?.tableId === target?.tableId &&
153
- item?.refillLaneKey === target?.refillLaneKey &&
154
- (item?.outcome === "included" || item?.outcome === "omitted") &&
155
- JSON.stringify(senderIds) === JSON.stringify(target?.senderIds) &&
156
- JSON.stringify(accounted) === JSON.stringify(target?.senderIds));
157
- });
158
- }
159
- export function normalizeSchedulerPrimitiveResult(value, expected) {
160
- const response = recordValue(value);
161
- const receipt = recordValue(response?.receipt);
162
- const changedCounts = normalizeSchedulerChangedCounts(receipt?.changedCounts ?? response?.changedCounts);
163
- const targetAuditComplete = !expected ||
164
- (receipt?.receiptVersion === 3 &&
165
- receipt.expectedTargetsHash === expected.expectedTargetsHash &&
166
- receipt.maxPlacements === expected.maxPlacements &&
167
- completeExpectedTargetSummary(receipt.expectedTargetSummary, expected.expectedTargets, expected.maxPlacements));
168
- const schedulerStatus = stringValue(response?.status) ?? stringValue(receipt?.status) ?? "unknown";
169
- if (!changedCounts || !targetAuditComplete) {
170
- return {
171
- status: "scheduler_receipt_incomplete",
172
- schedulerStatus,
173
- receipt: response?.receipt ?? null,
174
- retryAfterMs: numberValue(response?.retryAfterMs),
175
- changedCounts: null,
176
- auditComplete: false,
177
- blocker: "scheduler_receipt_incomplete",
178
- };
179
- }
180
- return {
181
- status: schedulerStatus,
182
- receipt: response?.receipt ?? null,
183
- retryAfterMs: numberValue(response?.retryAfterMs),
184
- changedCounts,
185
- auditComplete: true,
186
- };
187
- }
188
- function exactDateValue(value) {
189
- const targetDate = stringValue(value);
190
- if (!targetDate || !/^\d{4}-\d{2}-\d{2}$/.test(targetDate))
191
- return null;
192
- const parsed = new Date(`${targetDate}T00:00:00.000Z`);
193
- return !Number.isNaN(parsed.getTime()) &&
194
- parsed.toISOString().slice(0, 10) === targetDate
195
- ? targetDate
196
- : null;
197
- }
198
43
  export function stringArray(value) {
199
44
  if (!Array.isArray(value))
200
45
  return [];
@@ -380,9 +225,7 @@ export function classifyPaidInmailRefreshReceipt(value) {
380
225
  refreshed,
381
226
  error: stringValue(response?.error) ??
382
227
  stringValue(nestedReceipt?.error) ??
383
- (usableCurrentFacts
384
- ? null
385
- : "paid InMail credit refresh did not return usable current facts"),
228
+ (usableCurrentFacts ? null : "paid InMail credit refresh did not return usable current facts"),
386
229
  };
387
230
  }
388
231
  export function firstGlobalAction(plan) {
@@ -926,67 +769,7 @@ export async function executeOneYoloPrimitive(action, workspaceId) {
926
769
  case "wait_for_scheduler":
927
770
  case "wait_for_active_work":
928
771
  case "wait_for_source_import":
929
- return {
930
- status: "read_only_reread",
931
- result: waitResultForAction(action),
932
- };
933
- case "run_scheduler_sweep": {
934
- const toolInput = actionToolInput(action);
935
- const actionWorkspaceId = stringValue(toolInput.workspaceId);
936
- const targetDate = exactDateValue(toolInput.targetDate);
937
- const targetDateKey = exactDateValue(toolInput.targetDateKey);
938
- const actionKey = stringValue(action.actionKey);
939
- const requestKey = stringValue(toolInput.requestKey);
940
- const targetShapeRevision = stringValue(toolInput.targetShapeRevision);
941
- const receiptRequirements = recordValue(action.receiptRequirements);
942
- const receiptGroups = stringArray(receiptRequirements?.groupBy);
943
- const expectedTargets = Array.isArray(toolInput.expectedTargets)
944
- ? toolInput.expectedTargets
945
- : [];
946
- const expectedTargetsHash = stringValue(toolInput.expectedTargetsHash);
947
- const maxPlacements = numberValue(toolInput.maxPlacements);
948
- if (!workspaceId ||
949
- !actionWorkspaceId ||
950
- actionWorkspaceId !== workspaceId ||
951
- toolInput.action !== "run" ||
952
- !targetDate ||
953
- targetDateKey !== targetDate ||
954
- !actionKey ||
955
- requestKey !== actionKey ||
956
- !targetShapeRevision ||
957
- action.workspaceWide !== true ||
958
- receiptRequirements?.nonTruncated !== true ||
959
- receiptGroups.join(":") !== "campaignId:tableId:actionType:senderId" ||
960
- receiptRequirements?.expectedTargetSummary !== true ||
961
- expectedTargets.length === 0 ||
962
- !expectedTargetsHash ||
963
- maxPlacements === null ||
964
- !Number.isInteger(maxPlacements) ||
965
- maxPlacements <= 0) {
966
- return {
967
- status: "refused",
968
- refusalReason: "run_scheduler_sweep action is missing exact workspace/date/revision scope or complete receipt requirements",
969
- };
970
- }
971
- const result = await runSchedulerSweep({
972
- workspaceId,
973
- action: "run",
974
- targetDate,
975
- requestKey,
976
- targetShapeRevision,
977
- expectedTargets,
978
- expectedTargetsHash,
979
- maxPlacements,
980
- });
981
- return {
982
- status: "executed_and_reread",
983
- result: normalizeSchedulerPrimitiveResult(result, {
984
- expectedTargets,
985
- expectedTargetsHash,
986
- maxPlacements,
987
- }),
988
- };
989
- }
772
+ return { status: "read_only_reread", result: waitResultForAction(action) };
990
773
  case "prepare_messages": {
991
774
  const campaignId = actionCampaignId(action);
992
775
  const tableId = actionTableId(action) ?? undefined;
@@ -1008,9 +791,7 @@ export async function executeOneYoloPrimitive(action, workspaceId) {
1008
791
  tableId,
1009
792
  ...(workspaceId ? { workspaceId } : {}),
1010
793
  targetPreparedMessages,
1011
- ...(numberValue(toolInput.maxRowsToCheck) != null
1012
- ? { maxRowsToCheck: numberValue(toolInput.maxRowsToCheck) }
1013
- : {}),
794
+ maxRowsToCheck: numberValue(toolInput.maxRowsToCheck) ?? 300,
1014
795
  approvalMode,
1015
796
  rowSelector,
1016
797
  ...(excludeRowIds.length > 0 ? { excludeRowIds } : {}),
@@ -1,4 +1,4 @@
1
- export type RefillSendsV2Input = {
1
+ type RefillSendsV2Input = {
2
2
  workspaceId?: string;
3
3
  runId?: string;
4
4
  fence?: number;
@@ -6,39 +6,6 @@ export type RefillSendsV2Input = {
6
6
  approvalMode?: "approve" | "mark_ready";
7
7
  senderIds?: string[];
8
8
  intent?: "auto" | "evergreen" | "plain" | "active";
9
- targetDate?: string;
10
- untilDate?: string;
11
- horizonSendDays?: number;
12
- scope?: Record<string, unknown>;
13
- scopeHash?: string;
14
- approval?: Record<string, unknown>;
15
- targetPlan?: Record<string, unknown>;
16
- approvalEcho?: {
17
- scopeHash: string;
18
- targetShapeRevision: string;
19
- actionFingerprint: string;
20
- expectedTargetsHash: string;
21
- approvalExpiresAt: string;
22
- approvalFingerprint: string;
23
- };
24
- };
25
- type RefillV2ApprovalPreparationInput = Pick<RefillSendsV2Input, "workspaceId" | "intent" | "senderIds" | "approvalMode" | "targetDate" | "untilDate" | "horizonSendDays"> & {
26
- targetPlan: Record<string, unknown>;
27
- now?: Date;
28
- approvalExpiresAt?: string;
29
- };
30
- export declare const REFILL_V2_RUNTIME_IDENTITY: {
31
- readonly contract: {
32
- readonly version: "2.0.0";
33
- readonly hash: string;
34
- readonly cacheKey: "refill-contract-v1";
35
- };
36
- readonly installed: {
37
- readonly mcpVersion: "phase98-local";
38
- readonly installVersion: "phase98-local";
39
- readonly pluginVersion: "phase98-local";
40
- readonly cacheIdentity: "phase98-local-plugin-cache";
41
- };
42
9
  };
43
10
  export declare const refillSendsV2ToolDefinitions: {
44
11
  name: string;
@@ -77,89 +44,11 @@ export declare const refillSendsV2ToolDefinitions: {
77
44
  type: string;
78
45
  enum: string[];
79
46
  };
80
- targetDate: {
81
- type: string;
82
- description: string;
83
- };
84
- untilDate: {
85
- type: string;
86
- description: string;
87
- };
88
- horizonSendDays: {
89
- type: string;
90
- description: string;
91
- };
92
47
  };
93
48
  required: string[];
94
49
  additionalProperties: boolean;
95
50
  };
96
51
  }[];
97
- export declare function prepareRefillSendsV2Approval(input: RefillV2ApprovalPreparationInput): Promise<{
98
- status: "blocked";
99
- blocker: string;
100
- response: unknown;
101
- } | {
102
- status: "awaiting_approval";
103
- runId: string;
104
- fence: number;
105
- scope: Record<string, unknown> | {
106
- version: 2;
107
- workspaceId: string;
108
- intent: "active" | "plain" | "evergreen" | "auto";
109
- senderIds: string[];
110
- campaignIds: string[];
111
- tableIds: string[];
112
- actionIds: string[];
113
- approvalMode: "mark_ready" | "approve";
114
- dateSelector: {
115
- kind: "target_date";
116
- targetDate: string;
117
- untilDate?: undefined;
118
- horizonSendDays?: undefined;
119
- } | {
120
- kind: "until_date";
121
- untilDate: string;
122
- targetDate?: undefined;
123
- horizonSendDays?: undefined;
124
- } | {
125
- kind: "horizon_send_days";
126
- horizonSendDays: number;
127
- targetDate?: undefined;
128
- untilDate?: undefined;
129
- } | {
130
- kind: "scheduler_default";
131
- targetDate?: undefined;
132
- untilDate?: undefined;
133
- horizonSendDays?: undefined;
134
- };
135
- senderTimezones: {
136
- [k: string]: string;
137
- };
138
- expectedTargetsHash: string;
139
- maxPlacements: number;
140
- contract: {
141
- version: "2.0.0";
142
- hash: string;
143
- cacheKey: "refill-contract-v1";
144
- };
145
- installed: {
146
- mcpVersion: "phase98-local";
147
- installVersion: "phase98-local";
148
- pluginVersion: "phase98-local";
149
- cacheIdentity: "phase98-local-plugin-cache";
150
- };
151
- };
152
- approvalFingerprint: string;
153
- scopeHash: string;
154
- targetShapeRevision: string;
155
- actionFingerprint: string;
156
- expectedTargetsHash: string;
157
- sideEffectEnvelope: string[];
158
- maxPlacements: number;
159
- approvalExpiresAt: string;
160
- blocker?: undefined;
161
- response?: undefined;
162
- }>;
163
52
  export declare function refillSendsV2Command(input: RefillSendsV2Input): Promise<{
164
53
  readOnly: boolean;
165
54
  mode: string;