@sellable/mcp 0.1.569-phase981.20260711223346 → 0.1.571

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 (34) hide show
  1. package/dist/index-dev.js +0 -0
  2. package/dist/index.js +0 -0
  3. package/dist/refill-date-window.d.ts +34 -0
  4. package/dist/refill-date-window.js +210 -0
  5. package/dist/refill-run-client.d.ts +0 -10
  6. package/dist/refill-run-client.js +0 -22
  7. package/dist/refill-run-loop.d.ts +2 -14
  8. package/dist/refill-run-loop.js +18 -169
  9. package/dist/tools/campaign-message-preparation.d.ts +0 -62
  10. package/dist/tools/campaign-message-preparation.js +0 -41
  11. package/dist/tools/evergreen-refill-plan.d.ts +0 -3
  12. package/dist/tools/evergreen-refill-plan.js +7 -29
  13. package/dist/tools/prompts.d.ts +2 -0
  14. package/dist/tools/prompts.js +2 -10
  15. package/dist/tools/refill-executors.d.ts +11 -0
  16. package/dist/tools/refill-executors.js +71 -4
  17. package/dist/tools/refill-sends-evergreen.d.ts +28 -0
  18. package/dist/tools/refill-sends-evergreen.js +47 -0
  19. package/dist/tools/refill-sends-v2.d.ts +1 -118
  20. package/dist/tools/refill-sends-v2.js +3 -312
  21. package/dist/tools/refill-sends.d.ts +6 -506
  22. package/dist/tools/refill-sends.js +17 -139
  23. package/dist/tools/refill-target-plan.js +129 -331
  24. package/dist/tools/registry.d.ts +41 -54
  25. package/dist/tools/registry.js +3 -1
  26. package/package.json +1 -1
  27. package/skills/refill-sends/SKILL.md +396 -94
  28. package/skills/refill-sends-v2/SKILL.md +6 -6
  29. package/skills/refill-sends-v2-workflow/SKILL.md +5 -5
  30. package/skills/refill-sends-v2-workflow/core/flow.v1.json +8 -8
  31. package/skills/refill-sends-workflow/SKILL.md +785 -100
  32. package/skills/refill-sends-workflow/core/flow.v1.json +0 -122
  33. package/skills/research/config.json +9 -0
  34. package/skills/refill-sends-workflow/core/contract.v2.json +0 -543
package/dist/index-dev.js CHANGED
File without changes
package/dist/index.js CHANGED
File without changes
@@ -0,0 +1,34 @@
1
+ export type RefillDateWindowSource = "default_scheduler_forward" | "horizon_send_days" | "until_date" | "target_date";
2
+ export type NormalizedRefillDateSelector = {
3
+ source: RefillDateWindowSource;
4
+ targetDate: string | null;
5
+ untilDate: string | null;
6
+ horizonSendDays: number | null;
7
+ };
8
+ export type RefillRunDateWindow = NormalizedRefillDateSelector & {
9
+ version: 1;
10
+ selectedDates: string[];
11
+ senderWindows?: Array<{
12
+ senderId: string | null;
13
+ timeZone: string | null;
14
+ selectedDates: string[];
15
+ }>;
16
+ };
17
+ type DateSelectorInput = {
18
+ targetDate?: unknown;
19
+ untilDate?: unknown;
20
+ horizonSendDays?: unknown;
21
+ };
22
+ export declare function normalizeRefillDateSelector(input: DateSelectorInput): NormalizedRefillDateSelector;
23
+ export declare function refillDateSelectorBody(selector: NormalizedRefillDateSelector): {
24
+ targetDate?: string;
25
+ untilDate?: string;
26
+ horizonSendDays?: number;
27
+ };
28
+ export declare function dateWindowFromSelector(selector: NormalizedRefillDateSelector): RefillRunDateWindow;
29
+ export declare function dateWindowFromPlan(plan: Record<string, unknown>, selector: NormalizedRefillDateSelector): RefillRunDateWindow;
30
+ export declare function dateWindowFromRunState(runState: unknown): RefillRunDateWindow | null;
31
+ export declare function selectorFromDateWindow(window: RefillRunDateWindow): NormalizedRefillDateSelector;
32
+ export declare function dateSelectorMatchesWindow(selector: NormalizedRefillDateSelector, window: RefillRunDateWindow): boolean;
33
+ export declare function schedulerSweepTargetDates(window: RefillRunDateWindow): string[];
34
+ export {};
@@ -0,0 +1,210 @@
1
+ function isRecord(value) {
2
+ return Boolean(value) && typeof value === "object" && !Array.isArray(value);
3
+ }
4
+ function stringValue(value) {
5
+ return typeof value === "string" && value.trim() ? value.trim() : null;
6
+ }
7
+ function numberValue(value) {
8
+ return typeof value === "number" && Number.isFinite(value) ? value : null;
9
+ }
10
+ function arrayValue(value) {
11
+ return Array.isArray(value) ? value : [];
12
+ }
13
+ function isValidDateKey(value) {
14
+ if (!/^\d{4}-\d{2}-\d{2}$/.test(value))
15
+ return false;
16
+ const [year, month, day] = value.split("-").map(Number);
17
+ const date = new Date(Date.UTC(year, month - 1, day));
18
+ return (date.getUTCFullYear() === year &&
19
+ date.getUTCMonth() === month - 1 &&
20
+ date.getUTCDate() === day);
21
+ }
22
+ function normalizeDateKey(value, field) {
23
+ if (value === undefined || value === null || value === "")
24
+ return null;
25
+ if (typeof value !== "string") {
26
+ throw new Error(`${field} must be a string in YYYY-MM-DD format.`);
27
+ }
28
+ const trimmed = value.trim();
29
+ if (!isValidDateKey(trimmed)) {
30
+ throw new Error(`${field} must be a valid YYYY-MM-DD calendar date.`);
31
+ }
32
+ return trimmed;
33
+ }
34
+ function normalizeHorizonSendDays(value) {
35
+ if (value === undefined)
36
+ return null;
37
+ if (typeof value !== "number" ||
38
+ !Number.isInteger(value) ||
39
+ value < 1 ||
40
+ value > 7) {
41
+ throw new Error("horizonSendDays must be an integer between 1 and 7.");
42
+ }
43
+ return value;
44
+ }
45
+ export function normalizeRefillDateSelector(input) {
46
+ const targetDate = normalizeDateKey(input.targetDate, "targetDate");
47
+ const untilDate = normalizeDateKey(input.untilDate, "untilDate");
48
+ const horizonSendDays = normalizeHorizonSendDays(input.horizonSendDays);
49
+ if (targetDate) {
50
+ return {
51
+ source: "target_date",
52
+ targetDate,
53
+ untilDate: null,
54
+ horizonSendDays: null,
55
+ };
56
+ }
57
+ if (untilDate) {
58
+ return {
59
+ source: "until_date",
60
+ targetDate: null,
61
+ untilDate,
62
+ horizonSendDays: null,
63
+ };
64
+ }
65
+ if (horizonSendDays !== null) {
66
+ return {
67
+ source: "horizon_send_days",
68
+ targetDate: null,
69
+ untilDate: null,
70
+ horizonSendDays,
71
+ };
72
+ }
73
+ return {
74
+ source: "default_scheduler_forward",
75
+ targetDate: null,
76
+ untilDate: null,
77
+ horizonSendDays: null,
78
+ };
79
+ }
80
+ export function refillDateSelectorBody(selector) {
81
+ if (selector.source === "target_date" && selector.targetDate) {
82
+ return { targetDate: selector.targetDate };
83
+ }
84
+ if (selector.source === "until_date" && selector.untilDate) {
85
+ return { untilDate: selector.untilDate };
86
+ }
87
+ if (selector.source === "horizon_send_days" &&
88
+ selector.horizonSendDays !== null) {
89
+ return { horizonSendDays: selector.horizonSendDays };
90
+ }
91
+ return {};
92
+ }
93
+ export function dateWindowFromSelector(selector) {
94
+ return {
95
+ version: 1,
96
+ ...selector,
97
+ selectedDates: selector.targetDate ? [selector.targetDate] : [],
98
+ };
99
+ }
100
+ function selectedDatesFromPlan(plan) {
101
+ const packet = isRecord(plan.packet) ? plan.packet : {};
102
+ const target = isRecord(packet.target) ? packet.target : {};
103
+ const window = isRecord(target.window) ? target.window : {};
104
+ const senderWindows = arrayValue(window.senderWindows).filter(isRecord);
105
+ const fromWindows = senderWindows.flatMap((senderWindow) => arrayValue(senderWindow.selectedDates)
106
+ .map((entry) => stringValue(entry))
107
+ .filter((entry) => Boolean(entry)));
108
+ if (fromWindows.length > 0)
109
+ return Array.from(new Set(fromWindows)).sort();
110
+ const senderRefillPlans = arrayValue(target.senderRefillPlans).filter(isRecord);
111
+ return Array.from(new Set(senderRefillPlans.flatMap((senderPlan) => {
112
+ const horizon = isRecord(senderPlan.horizon) ? senderPlan.horizon : {};
113
+ return arrayValue(horizon.selectedDays)
114
+ .filter(isRecord)
115
+ .map((day) => stringValue(day.date))
116
+ .filter((entry) => Boolean(entry));
117
+ }))).sort();
118
+ }
119
+ function senderWindowsFromPlan(plan) {
120
+ const packet = isRecord(plan.packet) ? plan.packet : {};
121
+ const target = isRecord(packet.target) ? packet.target : {};
122
+ const window = isRecord(target.window) ? target.window : {};
123
+ return arrayValue(window.senderWindows)
124
+ .filter(isRecord)
125
+ .map((senderWindow) => ({
126
+ senderId: stringValue(senderWindow.senderId),
127
+ timeZone: stringValue(senderWindow.timeZone),
128
+ selectedDates: arrayValue(senderWindow.selectedDates)
129
+ .map((entry) => stringValue(entry))
130
+ .filter((entry) => Boolean(entry)),
131
+ }));
132
+ }
133
+ export function dateWindowFromPlan(plan, selector) {
134
+ const packet = isRecord(plan.packet) ? plan.packet : {};
135
+ const request = isRecord(packet.request) ? packet.request : {};
136
+ const targetDate = stringValue(request.targetDate) ?? selector.targetDate ?? null;
137
+ const untilDate = stringValue(request.untilDate) ?? selector.untilDate ?? null;
138
+ const horizonSendDays = numberValue(request.horizonSendDays) ?? selector.horizonSendDays ?? null;
139
+ const source = targetDate
140
+ ? "target_date"
141
+ : untilDate
142
+ ? "until_date"
143
+ : horizonSendDays !== null
144
+ ? "horizon_send_days"
145
+ : selector.source;
146
+ const selectedDates = selectedDatesFromPlan(plan);
147
+ return {
148
+ version: 1,
149
+ source,
150
+ targetDate: source === "target_date" ? targetDate : null,
151
+ untilDate: source === "until_date" ? untilDate : null,
152
+ horizonSendDays: source === "horizon_send_days" ? horizonSendDays : null,
153
+ selectedDates: selectedDates.length > 0
154
+ ? selectedDates
155
+ : targetDate
156
+ ? [targetDate]
157
+ : [],
158
+ senderWindows: senderWindowsFromPlan(plan),
159
+ };
160
+ }
161
+ export function dateWindowFromRunState(runState) {
162
+ const state = isRecord(runState) ? runState : {};
163
+ const raw = isRecord(state.dateWindow) ? state.dateWindow : null;
164
+ if (!raw || raw.version !== 1)
165
+ return null;
166
+ const source = raw.source === "target_date" ||
167
+ raw.source === "until_date" ||
168
+ raw.source === "horizon_send_days" ||
169
+ raw.source === "default_scheduler_forward"
170
+ ? raw.source
171
+ : null;
172
+ if (!source)
173
+ return null;
174
+ return {
175
+ version: 1,
176
+ source,
177
+ targetDate: source === "target_date" ? stringValue(raw.targetDate) : null,
178
+ untilDate: source === "until_date" ? stringValue(raw.untilDate) : null,
179
+ horizonSendDays: source === "horizon_send_days"
180
+ ? numberValue(raw.horizonSendDays)
181
+ : null,
182
+ selectedDates: arrayValue(raw.selectedDates)
183
+ .map((entry) => stringValue(entry))
184
+ .filter((entry) => Boolean(entry)),
185
+ };
186
+ }
187
+ export function selectorFromDateWindow(window) {
188
+ return {
189
+ source: window.source,
190
+ targetDate: window.targetDate,
191
+ untilDate: window.untilDate,
192
+ horizonSendDays: window.horizonSendDays,
193
+ };
194
+ }
195
+ export function dateSelectorMatchesWindow(selector, window) {
196
+ return (selector.source === window.source &&
197
+ selector.targetDate === window.targetDate &&
198
+ selector.untilDate === window.untilDate &&
199
+ selector.horizonSendDays === window.horizonSendDays);
200
+ }
201
+ export function schedulerSweepTargetDates(window) {
202
+ if (window.source === "target_date" && window.targetDate) {
203
+ return [window.targetDate];
204
+ }
205
+ if (window.source === "until_date" ||
206
+ window.source === "horizon_send_days") {
207
+ return window.selectedDates;
208
+ }
209
+ return [];
210
+ }
@@ -5,11 +5,6 @@ export type RefillRunBlockerResult = {
5
5
  runId: string;
6
6
  gate?: string;
7
7
  gateSeq?: number;
8
- } | {
9
- blocker: "scope_drift" | "approval_expired" | "approval_fingerprint_mismatch";
10
- runId: string;
11
- expectedScopeHash: string | null;
12
- receivedScopeHash: string | null;
13
8
  };
14
9
  export declare function startRefillRunRemote(input: {
15
10
  workspaceId?: string;
@@ -29,11 +24,6 @@ export declare function heartbeatRefillRun(input: {
29
24
  runId: string;
30
25
  fence: number;
31
26
  }): Promise<unknown>;
32
- export declare function yieldRefillRun(input: {
33
- workspaceId?: string;
34
- runId: string;
35
- fence: number;
36
- }): Promise<unknown>;
37
27
  export declare function advanceRefillRunGateRemote(input: {
38
28
  workspaceId?: string;
39
29
  runId: string;
@@ -15,21 +15,6 @@ function parseBlockerBody(body) {
15
15
  gateSeq: typeof parsed.gateSeq === "number" ? parsed.gateSeq : undefined,
16
16
  };
17
17
  }
18
- if ((parsed.blocker === "scope_drift" ||
19
- parsed.blocker === "approval_expired" ||
20
- parsed.blocker === "approval_fingerprint_mismatch") &&
21
- typeof parsed.runId === "string") {
22
- return {
23
- blocker: parsed.blocker,
24
- runId: parsed.runId,
25
- expectedScopeHash: typeof parsed.expectedScopeHash === "string"
26
- ? parsed.expectedScopeHash
27
- : null,
28
- receivedScopeHash: typeof parsed.receivedScopeHash === "string"
29
- ? parsed.receivedScopeHash
30
- : null,
31
- };
32
- }
33
18
  }
34
19
  catch {
35
20
  return null;
@@ -70,13 +55,6 @@ export function heartbeatRefillRun(input) {
70
55
  fence: input.fence,
71
56
  });
72
57
  }
73
- export function yieldRefillRun(input) {
74
- return postRefillRuns(input.workspaceId, {
75
- action: "yield",
76
- runId: input.runId,
77
- fence: input.fence,
78
- });
79
- }
80
58
  export function advanceRefillRunGateRemote(input) {
81
59
  return postRefillRuns(input.workspaceId, {
82
60
  action: "advance-gate",
@@ -1,6 +1,6 @@
1
1
  import type { appendIndexLine, appendJournalEvent, createRunJournal, renderBootstrapSection, renderCrashedAbandonedSection, renderExecutionEventSection, renderPlanSection, renderTerminalSection } from "./refill-journal.js";
2
- import type { advanceRefillRunGateRemote, completeRefillRun, heartbeatRefillRun, recordRunOutcome, recordRunPlanned, refillRunStatus, startRefillRunRemote, yieldRefillRun } from "./refill-run-client.js";
3
- import type { getPrepareCampaignMessagesStatus, stopSatisfiedPrepareCampaignMessages } from "./tools/campaign-message-preparation.js";
2
+ import type { advanceRefillRunGateRemote, completeRefillRun, heartbeatRefillRun, recordRunOutcome, recordRunPlanned, refillRunStatus, startRefillRunRemote } from "./refill-run-client.js";
3
+ import type { getPrepareCampaignMessagesStatus } from "./tools/campaign-message-preparation.js";
4
4
  import type { executeOneYoloPrimitive, executeStartCampaignPrimitive, prepareRowSelectorValue, refillPrepareRequestHash, refreshPaidInmailCreditsWithRetry } from "./tools/refill-executors.js";
5
5
  export type RefillLoopGate = "g0_bootstrap" | "g1_plan" | "g2_execute" | "g3_verify" | "g4_terminal";
6
6
  export interface RefillV2LoopInput {
@@ -13,12 +13,6 @@ export interface RefillV2LoopInput {
13
13
  };
14
14
  approvalMode?: "approve" | "mark_ready";
15
15
  dryRun?: boolean;
16
- targetDate?: string;
17
- untilDate?: string;
18
- horizonSendDays?: number;
19
- scope?: Record<string, unknown>;
20
- scopeHash?: string;
21
- approval?: Record<string, unknown>;
22
16
  }
23
17
  export interface RefillV2LoopBudgets {
24
18
  maxGateCyclesPerInvocation: number;
@@ -32,7 +26,6 @@ export interface RefillV2RunClient {
32
26
  startRefillRunRemote: typeof startRefillRunRemote;
33
27
  refillRunStatus: typeof refillRunStatus;
34
28
  heartbeatRefillRun: typeof heartbeatRefillRun;
35
- yieldRefillRun: typeof yieldRefillRun;
36
29
  advanceRefillRunGateRemote: typeof advanceRefillRunGateRemote;
37
30
  recordRunPlanned: typeof recordRunPlanned;
38
31
  recordRunOutcome: typeof recordRunOutcome;
@@ -43,7 +36,6 @@ export interface RefillV2Executors {
43
36
  executeStartCampaignPrimitive: typeof executeStartCampaignPrimitive;
44
37
  refreshPaidInmailCreditsWithRetry: typeof refreshPaidInmailCreditsWithRetry;
45
38
  getPrepareCampaignMessagesStatus?: typeof getPrepareCampaignMessagesStatus;
46
- stopSatisfiedPrepareCampaignMessages?: typeof stopSatisfiedPrepareCampaignMessages;
47
39
  refillPrepareRequestHash?: typeof refillPrepareRequestHash;
48
40
  prepareRowSelectorValue?: typeof prepareRowSelectorValue;
49
41
  }
@@ -69,10 +61,6 @@ export interface RefillV2LoopDeps {
69
61
  senderIds?: string[];
70
62
  runState?: Record<string, unknown>;
71
63
  journal?: boolean;
72
- targetDate?: string;
73
- untilDate?: string;
74
- horizonSendDays?: number;
75
- scopeHash?: string;
76
64
  }) => Promise<Record<string, unknown>>;
77
65
  executors: RefillV2Executors;
78
66
  journal: RefillV2JournalDeps;