@sellable/mcp 0.1.473 → 0.1.475
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/server.js +2 -2
- package/dist/tools/prompts.js +1 -1
- package/dist/tools/refill-sends.d.ts +158 -0
- package/dist/tools/refill-sends.js +152 -3
- package/dist/tools/senders.js +1 -1
- package/package.json +1 -1
- package/skills/refill-sends/SKILL.md +18 -13
- package/skills/refill-sends-workflow/SKILL.md +17 -12
package/dist/server.js
CHANGED
|
@@ -39,7 +39,7 @@ import { addOnDemandLeads, createOnDemandCampaign, createOnDemandTable, initOnDe
|
|
|
39
39
|
import { upsertRubric } from "./tools/processing.js";
|
|
40
40
|
import { completeSenderResearch, getPostFindLeadsScoutRegistry, getSourceScoutRegistry, getSubskillAsset, getSubskillPrompt, listSubskillPrompts, searchSubskillPrompts, } from "./tools/prompts.js";
|
|
41
41
|
import { waitForCampaignTableReady, waitForLeadListReady, } from "./tools/readiness.js";
|
|
42
|
-
import {
|
|
42
|
+
import { executeRefillSendsCommand } from "./tools/refill-sends.js";
|
|
43
43
|
import { allTools } from "./tools/registry.js";
|
|
44
44
|
import { getRows, getTableRows, getTableRowsMinimal } from "./tools/rows.js";
|
|
45
45
|
import { addRubricItem, checkRubric, deleteRubricItem, draftRubrics, saveRubrics, selectNecessaryRubrics, updateRubricItem, waitForRubricResults, } from "./tools/rubrics.js";
|
|
@@ -230,7 +230,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
230
230
|
result = await getSchedulerFillCapacity(args);
|
|
231
231
|
break;
|
|
232
232
|
case "refill_sends":
|
|
233
|
-
result =
|
|
233
|
+
result = await executeRefillSendsCommand(args);
|
|
234
234
|
break;
|
|
235
235
|
case "setup_evergreen_campaigns":
|
|
236
236
|
result = await setupEvergreenCampaigns(args);
|
package/dist/tools/prompts.js
CHANGED
|
@@ -373,7 +373,7 @@ export function getPostFindLeadsScoutRegistry() {
|
|
|
373
373
|
codex: 'After confirm_lead_list copies source rows and the initial campaign-table execution slice exists, ask the filter-choice question immediately. Do not spawn anything before that question. After the answer, launch only Message Drafting. The filter-choice answer is the post-import user gate for this single worker; do not ask another question about starting it in step-wise or YOLO mode. The registry lookup is not a launch: after get_post_find_leads_scout_registry, immediately invoke Task/spawn_agent or the host background-agent mechanism before loading filter-leads.md, before saving rubrics, and before treating skip-filters as ready for message review. Both choices route through this kickoff; do not let filters_skipped jump straight from filter-choice to message-generation. If filters are chosen, the parent stays on Filter Rules and drafts/saves rubrics with MCP tools while Message Drafting runs in the background. If filters are skipped, move to Messages/message review only after Message Drafting has started or is ready; update_campaign(currentStep=messages) is not proof of launch. If the named Message Drafting custom agent is unavailable, spawn a generic gpt-5.5 xhigh Message Drafting background agent with the same lean campaign/table basis. When the background worker starts, persist workerDetails.messageDraftBuilder with statusSource "branch", status "branch-running", runId, startedAt, updatedAt, basisToken when known, and basis containing campaignId, selectedLeadListId, workflowTableId, filterChoice, and reviewBatchRowHash or reviewBatchRowIds; workerStatuses.messageDraftBuilder may be "running" as a simple badge only. Never put rich proof under workerStatuses and never use workerStatuses.messageDrafting. If no background-agent tool is callable, start the same full message branch inline before filter drafting or before skip-filter message review, record workerDetails.messageDraftBuilder with statusSource "parent-thread-fallback" and status "fallback-active", and require the same live context, prompt, assets, and validation gate before message review; do not wait until filters are saved and then call the registry.',
|
|
374
374
|
claude: "After confirm_lead_list copies source rows and the initial campaign-table execution slice exists, ask the filter-choice question immediately. Do not invoke any Task/Agent before that question. After the answer, invoke only Message Drafting. If filters are chosen, parent drafts/saves rubrics with MCP tools while Message Drafting runs, asks filter approval, then joins Message Drafting. If filters are skipped, invoke only Message Drafting and move to Messages/message review.",
|
|
375
375
|
parentThreadRule: 'Named agents are optional acceleration, but message drafting is not optional. The only normal background worker is Message Drafting. The filter-choice answer is the campaign-scoped go-ahead for this single post-import worker; do not ask another question to start it in step-wise or YOLO mode. If a named agent is unavailable, use a generic gpt-5.5 xhigh Message Drafting background agent. source work and filter work stay in the parent thread with MCP tools. If post-find-leads-message-scout is available, run it as the background Message Draft Builder after the filter-choice answer. The registry lookup is not a launch: get_post_find_leads_scout_registry only identifies the worker, and Message Drafting counts as started only after Task/spawn_agent or the host background-agent tool is invoked, or after the parent begins the same full message branch inline because no background-agent tool is callable. This launch must happen before loading filter-leads.md, save_rubrics, filter approval, or skip-filter message review; currentStep=messages is not proof of launch. If post-find-leads-message-scout is absent, do not customer-surface install status. Do not silently treat message drafting as started; the main thread must either launch the background worker or execute the same message branch from CampaignOffer state, selected source state, workflowTableId, and initial campaign-table execution slice rows. For a spawned worker, record workerDetails.messageDraftBuilder with statusSource branch / status branch-running, runId, startedAt, updatedAt, and basis containing campaignId, selectedLeadListId, workflowTableId, filterChoice, and reviewBatchRowHash or reviewBatchRowIds. workerStatuses.messageDraftBuilder is optional simple badge text only ("running", "ready", "blocked", "idle"); never put runId/statusSource/basis under workerStatuses and never use workerStatuses.messageDrafting. If no background-agent tool is callable, start that same full message branch inline before filter drafting or before skip-filter message review, record workerDetails.messageDraftBuilder with statusSource parent-thread-fallback / status fallback-active then ready, and require the same live context, prompt, assets, and validation gate before message review; do not report that as a background worker failure. If neither branch nor inline fallback can run, return blocked/retry-needed; do not wait until filters are saved and then call the registry. The Message Drafting handoff must be lean. Do not paste copied row counts, brief hashes, review-batch hashes, full reviewBatchRowIds, broad row data, or local debug artifacts into the spawn prompt. Local markdown/json files are not normal-path inputs. The filter-choice question is the first post-import user gate; do not load post-lead registries or filter references before it. Message drafting starts after the filter-choice answer, must load get_subskill_prompt({ subskillName: "generate-messages" }), and must load every required message asset named by generate-messages Mode 0 through get_subskill_asset before drafting. Reference Asset Loading means loading the required pre-draft reference pack before drafting; return blocked/retry-needed if required assets cannot be loaded; load ai-tells.md because it is never optional. The branch or parent-thread fallback loads the full generate-messages prompt and every referenced asset through get_subskill_asset. After generating/revising the candidate and before returning ready, must load get_subskill_prompt({ subskillName: "create-campaign-v2-validation" }) as the final internal validation gate, must read live campaign table state through scoped MCP/product tools, and must reject mismatched selectedLeadListId/workflowTableId/campaign/workspace input. Do not block when filters were chosen but leadScoringRubrics are not yet visible in the branch read; the parent owns save_rubrics and filter approval in parallel, so Message Drafting should return status ready with basisStatus usable_initial when campaign/list/table identity and the non-empty execution slice match. Do not use any alternate, local-artifact, or examples-only message prompt. User copy feedback, message QA, or rewrite requests before approve-message must be routed back to Message Drafting with the current recommendation, lean campaign/table basis, and latest user text; the parent must not rewrite or QA the template from memory and must not call update_campaign_brief before approve-message. The worker validates internally and returns only templateRecommendation, tokenFillRules, renderedGoodSample, status, approveOrReviseRecommendation, validationStatus, outputAt, outputHash, and blocked/retry detail. Do not render renderedFallbackSample, risk notes, or a qaReceipt on the normal happy path. On the filter path, save_rubrics keeps the browser on Filter Rules after save_rubrics so the user can approve the saved criteria; after saved-filter approval, move to Filter Leads with currentStep=apply-icp-rubric whether Message Drafting is ready or still running. Wait there for message approval. Enrichment, filtering, Generate Message cells, sender setup, sequence attach, and launch wait for template approval on the Use Template path. On the skip path, move to Messages/message review after Message Drafting has started or is ready and wait for message approval before enrichment or Settings. Do not render message review from checklist or shortcut instructions; message review requires a messageDraftRecommendation whose basis proves the generate-messages prompt, required message assets, and validation gate ran for the current campaign/table execution slice. Do not automatically rerun Message Drafting after filters/enrichment finish; show the initial draft by default and offer an enriched rewrite only with explicit user opt-in. Handoff and recommendation output are Markdown with labeled fields, not raw JSON.',
|
|
376
|
-
prepareMessagesRule: `Default create-campaign stays on the existing reviewBatchLimit:15 first campaign-table execution slice. For plain post-mint fill/load/refill requests, load get_subskill_prompt({ subskillName: "refill-sends-workflow" }), then call resolve_campaign_fill_route({ intent:"plain" }), list_senders, and get_campaign_refill_state for enough candidate campaigns to identify the campaign that most recently had scheduler-owned sends for the relevant sender set before any mutation. Route outcomes are route:"evergreen_horizon", route:"active_campaigns", and route:"ask_create"; if a plain managed-waterfall route has archived/completed skipped slots or does not cover the named sender set, immediately refetch with resolve_campaign_fill_route({ intent:"active" }) and inspect current dashboard-active ACTIVE/PAUSED campaign-backed sequence campaigns before declaring a sender blocked; stay in the same campaignOfferId/campaignId context after minting. Plain fill is not an alias for fill_campaign_horizon or campaign creation. fill_campaign_horizon is evergreen-only and is not the generic regular-campaign fill path. Campaign creation is allowed only after route:"ask_create" and explicit user selection; it is never the default response to plain fill. Treat "fill up/load sends" as capacity-fill preparation, and treat "refill senders", "fill senders", "max out senders", and "load everyone up" as sender-scoped capacity-fill preparation. For sender-scoped requests with no named senders, --yolo means all eligible healthy senders enrolled in active campaign-backed sequence campaigns in the active workspace; without --yolo, ask which eligible enrolled senders to refill before choosing campaigns or mutating. In non-yolo interactive Codex or Claude Code sessions, post the full sender/campaign/action approval packet in normal chat as Markdown first, then ask request_user_input/AskUserQuestion with exactly Accept and Decline and a compact body that refers back to the posted packet; do not duplicate the campaign table or full operator packet inside the structured question. The chat packet must show workspace, sender scope, a campaign-by-campaign table, exact ids/caps/dates, side effects, forbidden actions, and stop condition before mutation. Default --yolo target is the scheduler-forward 48-hour target window: sender-local send days whose configured sending windows overlap the rolling target window, skipping no-send-hour days. For campaign-scoped fill/refill, select the best recent-send campaign and calculate the bounded gap from healthy sender daily capacity minus projected coverage (actual sent plus future scheduler-owned scheduled sends) and ready-to-schedule rows, then prepare only that gap. For sender-scoped fill/refill, calculate the bounded gap per eligible sender across active enrolled campaigns, counting actual sent coverage, future scheduled rows, and ready-to-schedule rows across those campaigns, then choose the best same-sender campaign to fill each sender gap: prefer recent/future scheduler-owned sends for that sender, then strongest recent result evidence, then source health. Maintain a target-window saturation ledger per selected sender with selected send days, gross capacity, actual sent counts, future scheduler-owned scheduled counts, projected coverage, ready-to-schedule buffer, remaining projected gap, paid-InMail threshold feasibility, and the next MCP primitive. The structured packet lives in target.senderRefillPlans[] with target.eligibleSenderLedger, campaignRanking.options, sourcePlan, nextActions, manualAlternates, and target.globalActionQueue; preserve Need to prepare, Goal, Already sent, Scheduled, Ready and waiting to be scheduled, and Still need labels. In --yolo, execute exactly one globally ranked primitive from target.globalActionQueue[0], then rerun get_refill_target_plan before choosing another action.
|
|
376
|
+
prepareMessagesRule: `Default create-campaign stays on the existing reviewBatchLimit:15 first campaign-table execution slice. For plain post-mint fill/load/refill requests, load get_subskill_prompt({ subskillName: "refill-sends-workflow" }), then call resolve_campaign_fill_route({ intent:"plain" }), list_senders, and get_campaign_refill_state for enough candidate campaigns to identify the campaign that most recently had scheduler-owned sends for the relevant sender set before any mutation. Route outcomes are route:"evergreen_horizon", route:"active_campaigns", and route:"ask_create"; if a plain managed-waterfall route has archived/completed skipped slots or does not cover the named sender set, immediately refetch with resolve_campaign_fill_route({ intent:"active" }) and inspect current dashboard-active ACTIVE/PAUSED campaign-backed sequence campaigns before declaring a sender blocked; stay in the same campaignOfferId/campaignId context after minting. Plain fill is not an alias for fill_campaign_horizon or campaign creation. fill_campaign_horizon is evergreen-only and is not the generic regular-campaign fill path. Campaign creation is allowed only after route:"ask_create" and explicit user selection; it is never the default response to plain fill. Treat "fill up/load sends" as capacity-fill preparation, and treat "refill senders", "fill senders", "max out senders", and "load everyone up" as sender-scoped capacity-fill preparation. For sender-scoped requests with no named senders, --yolo means all eligible healthy senders enrolled in active campaign-backed sequence campaigns in the active workspace; without --yolo, ask which eligible enrolled senders to refill before choosing campaigns or mutating. In non-yolo interactive Codex or Claude Code sessions, post the full sender/campaign/action approval packet in normal chat as Markdown first, then ask request_user_input/AskUserQuestion with exactly Accept and Decline and a compact body that refers back to the posted packet; do not duplicate the campaign table or full operator packet inside the structured question. The chat packet must show workspace, sender scope, a campaign-by-campaign table, exact ids/caps/dates, side effects, forbidden actions, and stop condition before mutation. Default --yolo target is the scheduler-forward 48-hour target window: sender-local send days whose configured sending windows overlap the rolling target window, skipping no-send-hour days. For campaign-scoped fill/refill, select the best recent-send campaign and calculate the bounded gap from healthy sender daily capacity minus projected coverage (actual sent plus future scheduler-owned scheduled sends) and ready-to-schedule rows, then prepare only that gap. For sender-scoped fill/refill, calculate the bounded gap per eligible sender across active enrolled campaigns, counting actual sent coverage, future scheduled rows, and ready-to-schedule rows across those campaigns, then choose the best same-sender campaign to fill each sender gap: prefer recent/future scheduler-owned sends for that sender, then strongest recent result evidence, then source health. Maintain a target-window saturation ledger per selected sender with selected send days, gross capacity, actual sent counts, future scheduler-owned scheduled counts, projected coverage, ready-to-schedule buffer, remaining projected gap, paid-InMail threshold feasibility, and the next MCP primitive. The structured packet lives in target.senderRefillPlans[] with target.eligibleSenderLedger, campaignRanking.options, sourcePlan, nextActions, manualAlternates, and target.globalActionQueue; preserve Need to prepare, Goal, Already sent, Scheduled, Ready and waiting to be scheduled, and Still need labels. In --yolo, execute exactly one globally ranked primitive from the post-refresh target.globalActionQueue[0], then rerun get_refill_target_plan before choosing another action. The refill_sends MCP command maintains a run-local refreshedPaidInmailSenderIds set: if the first target plan contains refresh_paid_inmail_credits for stale/missing paid-InMail facts, refill_sends refreshes each selected paid-InMail sender at most once, reruns get_refill_target_plan, and returns autoPaidInmailRefresh plus the post-refresh targetPlan before the operator chooses prep, approval, start, or fallback. Do not present paid-credit refresh as the next operator action after refill_sends has returned a post-refresh targetPlan. Do not stop after filling only one sender when the request was sender-scoped. In --yolo, continue through every safe selected sender/campaign action covered by the rendered packet, reread after each terminal apply/prep/start result, recompute the target-window saturation ledger, and keep going until projected coverage (sent + scheduled) fills the scheduler-forward target window or a concrete non-scheduler blocker is proven. Ready-to-schedule rows are buffer, not completion; if ready covers the projected gap but scheduled cells do not, report loaded, awaiting scheduler and run a persistent read-only scheduler wait/reread loop and keep the run open while awaiting_scheduler_after_ready_buffer is the only remaining state. Paid-InMail threshold changes and connection-campaign creation are explicit continuation options, never --yolo side effects. When no safe in-packet action remains return concrete continuation options with campaign names, exact ids, and which options require a new approval packet; do not return final completion for scheduler wait unless Christian explicitly asks for status or stops the run. Use the refill workflow to decide whether to enrich/prep more rows in that same recent-send/best-result campaign, add/import more rows to that same campaign/source path, use a different existing campaign only when the selected same-sender lane is blocked/exhausted/already loaded while the sender still has a gap, or ask what to create. Do not create warm-post-engager side campaigns. Surface sender-health blockers and paid-InMail threshold blockers separately from prepared/approved/scheduled counts. User-facing refill decisions must be campaign-name-first and sender-name-first, with ids as proof/execution targets only. Trust schedulerGate.sendable and scheduler blockers over raw unipileAccountStatus labels alone. For long-running prep use compact prep status checks, reread target plans after prep or cancel, avoid huge parallel target-plan reads when output is large, and if prepared/ready rows grow but sender-level projected coverage does not move after one bounded settle loop, pivot to compact prep status or a scheduler-proven lane instead of waiting on campaign-level ready counts. For already-running regular campaigns that need Signal Discovery source replenishment, use the guarded currentStep clear with clearCurrentStepIfMatches:"running", campaign-scoped provider prompt/search/select, and import_leads with the existing sourceLeadListId when a newly approved selected-post scrape would otherwise return reusedExistingSourceList. Before prep, inspect get_campaign_refill_state.preparationFrontier. If hasLaterPreparedIsland:true or earliestUnpreparedRow exists before later successful enrichment, use rowSelector:{type:"needsEnrichment"} with columnRole:"enrich" in table-position order or start_campaign_message_preparation adaptive defaults; do not use the UI Jump anchor or needsGeneratedMessage as the refill cursor. After confirm_lead_list copies rows into an existing table, avoid fixed maxRowsToCheck:100; if confirm_lead_list returns USER_ADDED_ROWS_LIMIT_EXCEEDED, create a bounded same-source split from selectedLeadListId with get_rows_minimal/load_csv_linkedin_leads, confirm that smaller source list into the same campaign, and inspect reviewBatch only as diagnostics unless the approved packet explicitly prioritizes the just-copied split and earlier needsEnrichment rows are exhausted, dependency-blocked, or excluded. For approval diagnostics use rowSelector:{type:"needsApproval"} after current generated messages exist; mutating Approved cells still requires approvalMode:approve and exact bounded approval. Do not interpret checkedRows as enriched rows; it is only the table cursor. Prepared, approved, and ready_to_schedule rows are intermediate states; never call them scheduled unless a re-read proves scheduler-owned scheduled cells with non-null scheduledFor contribute to projected coverage, and never call them complete unless a final re-read proves projected coverage fills the scheduler-forward target window. Before source import, prep, approval, or selected paused campaign start, require exact visible approval or --yolo packet auto-accept and a fresh get_campaign_refill_state reread; stop if freshness.stateHash or exact ids changed. For "approve X messages", use approvalMode:approve only when explicitly requested. For "schedule X sends" or "fill sender sends", approve only when explicitly requested, then re-read campaign/table scheduled counts; if projected coverage does not fill the horizon, keep polling when ready buffer covers the gap and report only interim prepared/approved/ready - awaiting scheduler status if Christian asks. Do not call start_campaign as part of fill/schedule horizon. start_campaign is allowed in refill only for exact selected PAUSED, dashboard-active, campaign-backed sequence targets named in the bounded packet, and the packet must state that starting can let the product scheduler schedule/send approved eligible sequence actions. Never start unrelated, archived, completed, draft, direct, or non-selected campaigns, never broad approve-all, and never use direct scheduler writes. campaignId is CampaignOffer.id. If the user asks to stop preparation, the target is wrong, or status shows the wrong campaign/table, use cancel_campaign_message_preparation only for the exact active job. Low-level selectors are diagnostics and recovery only for this lane.`,
|
|
377
377
|
},
|
|
378
378
|
};
|
|
379
379
|
}
|
|
@@ -148,4 +148,162 @@ export declare function refillSendsCommand(input?: RefillSendsCommandInput): {
|
|
|
148
148
|
};
|
|
149
149
|
};
|
|
150
150
|
};
|
|
151
|
+
export declare function executeRefillSendsCommand(input?: RefillSendsCommandInput): Promise<{
|
|
152
|
+
autoPaidInmailRefresh: {
|
|
153
|
+
enabled: boolean;
|
|
154
|
+
status: string;
|
|
155
|
+
refreshedPaidInmailSenderIds: never[];
|
|
156
|
+
failedPaidInmailRefreshes: never[];
|
|
157
|
+
note: string;
|
|
158
|
+
refreshReceipts?: undefined;
|
|
159
|
+
attemptedSenderIds?: undefined;
|
|
160
|
+
targetPlanReread?: undefined;
|
|
161
|
+
};
|
|
162
|
+
command: string;
|
|
163
|
+
tool: string;
|
|
164
|
+
promptName: string;
|
|
165
|
+
workflowPromptName: string;
|
|
166
|
+
yolo: boolean;
|
|
167
|
+
intent: RefillSendsIntent;
|
|
168
|
+
targetDate: string | null;
|
|
169
|
+
untilDate: string | null;
|
|
170
|
+
horizonSendDays: number | null;
|
|
171
|
+
fillWindow: {
|
|
172
|
+
mode: string;
|
|
173
|
+
targetDate: string;
|
|
174
|
+
description: string;
|
|
175
|
+
untilDate?: undefined;
|
|
176
|
+
horizonSendDays?: undefined;
|
|
177
|
+
horizonHours?: undefined;
|
|
178
|
+
} | {
|
|
179
|
+
mode: string;
|
|
180
|
+
untilDate: string;
|
|
181
|
+
description: string;
|
|
182
|
+
targetDate?: undefined;
|
|
183
|
+
horizonSendDays?: undefined;
|
|
184
|
+
horizonHours?: undefined;
|
|
185
|
+
} | {
|
|
186
|
+
mode: string;
|
|
187
|
+
horizonSendDays: number | null;
|
|
188
|
+
horizonHours: number | null;
|
|
189
|
+
description: string;
|
|
190
|
+
targetDate?: undefined;
|
|
191
|
+
untilDate?: undefined;
|
|
192
|
+
};
|
|
193
|
+
approvalMode: RefillSendsApprovalMode;
|
|
194
|
+
campaignId: string | null;
|
|
195
|
+
tableId: string | null;
|
|
196
|
+
senderScope: string;
|
|
197
|
+
senderSelectors: {
|
|
198
|
+
senders: string[];
|
|
199
|
+
senderIds: string[];
|
|
200
|
+
senderNames: string[];
|
|
201
|
+
};
|
|
202
|
+
firstOperationalSteps: string[];
|
|
203
|
+
approvalContract: string;
|
|
204
|
+
forbiddenActions: string[];
|
|
205
|
+
hostExamples: {
|
|
206
|
+
claude: string[];
|
|
207
|
+
codex: string[];
|
|
208
|
+
mcpTool: {
|
|
209
|
+
name: string;
|
|
210
|
+
arguments: {
|
|
211
|
+
yolo: boolean;
|
|
212
|
+
senders: string[];
|
|
213
|
+
senderIds: string[];
|
|
214
|
+
senderNames: string[];
|
|
215
|
+
targetDate: string | null;
|
|
216
|
+
untilDate: string | null;
|
|
217
|
+
horizonSendDays: number | null;
|
|
218
|
+
campaignId: string | undefined;
|
|
219
|
+
tableId: string | undefined;
|
|
220
|
+
intent: RefillSendsIntent;
|
|
221
|
+
approvalMode: RefillSendsApprovalMode;
|
|
222
|
+
};
|
|
223
|
+
};
|
|
224
|
+
};
|
|
225
|
+
} | {
|
|
226
|
+
targetPlan: unknown;
|
|
227
|
+
targetPlanBeforePaidRefresh: unknown;
|
|
228
|
+
autoPaidInmailRefresh: {
|
|
229
|
+
enabled: boolean;
|
|
230
|
+
status: string;
|
|
231
|
+
refreshedPaidInmailSenderIds: string[];
|
|
232
|
+
failedPaidInmailRefreshes: {
|
|
233
|
+
senderId: string;
|
|
234
|
+
error: string;
|
|
235
|
+
}[];
|
|
236
|
+
refreshReceipts: {
|
|
237
|
+
senderId: string;
|
|
238
|
+
actionKey: string | null;
|
|
239
|
+
receipt: import("./senders.js").RefreshPaidInmailCreditsResponse;
|
|
240
|
+
}[];
|
|
241
|
+
attemptedSenderIds: string[];
|
|
242
|
+
targetPlanReread: boolean;
|
|
243
|
+
note: string;
|
|
244
|
+
};
|
|
245
|
+
command: string;
|
|
246
|
+
tool: string;
|
|
247
|
+
promptName: string;
|
|
248
|
+
workflowPromptName: string;
|
|
249
|
+
yolo: boolean;
|
|
250
|
+
intent: RefillSendsIntent;
|
|
251
|
+
targetDate: string | null;
|
|
252
|
+
untilDate: string | null;
|
|
253
|
+
horizonSendDays: number | null;
|
|
254
|
+
fillWindow: {
|
|
255
|
+
mode: string;
|
|
256
|
+
targetDate: string;
|
|
257
|
+
description: string;
|
|
258
|
+
untilDate?: undefined;
|
|
259
|
+
horizonSendDays?: undefined;
|
|
260
|
+
horizonHours?: undefined;
|
|
261
|
+
} | {
|
|
262
|
+
mode: string;
|
|
263
|
+
untilDate: string;
|
|
264
|
+
description: string;
|
|
265
|
+
targetDate?: undefined;
|
|
266
|
+
horizonSendDays?: undefined;
|
|
267
|
+
horizonHours?: undefined;
|
|
268
|
+
} | {
|
|
269
|
+
mode: string;
|
|
270
|
+
horizonSendDays: number | null;
|
|
271
|
+
horizonHours: number | null;
|
|
272
|
+
description: string;
|
|
273
|
+
targetDate?: undefined;
|
|
274
|
+
untilDate?: undefined;
|
|
275
|
+
};
|
|
276
|
+
approvalMode: RefillSendsApprovalMode;
|
|
277
|
+
campaignId: string | null;
|
|
278
|
+
tableId: string | null;
|
|
279
|
+
senderScope: string;
|
|
280
|
+
senderSelectors: {
|
|
281
|
+
senders: string[];
|
|
282
|
+
senderIds: string[];
|
|
283
|
+
senderNames: string[];
|
|
284
|
+
};
|
|
285
|
+
firstOperationalSteps: string[];
|
|
286
|
+
approvalContract: string;
|
|
287
|
+
forbiddenActions: string[];
|
|
288
|
+
hostExamples: {
|
|
289
|
+
claude: string[];
|
|
290
|
+
codex: string[];
|
|
291
|
+
mcpTool: {
|
|
292
|
+
name: string;
|
|
293
|
+
arguments: {
|
|
294
|
+
yolo: boolean;
|
|
295
|
+
senders: string[];
|
|
296
|
+
senderIds: string[];
|
|
297
|
+
senderNames: string[];
|
|
298
|
+
targetDate: string | null;
|
|
299
|
+
untilDate: string | null;
|
|
300
|
+
horizonSendDays: number | null;
|
|
301
|
+
campaignId: string | undefined;
|
|
302
|
+
tableId: string | undefined;
|
|
303
|
+
intent: RefillSendsIntent;
|
|
304
|
+
approvalMode: RefillSendsApprovalMode;
|
|
305
|
+
};
|
|
306
|
+
};
|
|
307
|
+
};
|
|
308
|
+
}>;
|
|
151
309
|
export {};
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { getRefillTargetPlan } from "./refill-target-plan.js";
|
|
2
|
+
import { refreshPaidInmailCredits } from "./senders.js";
|
|
1
3
|
const DEFAULT_SCHEDULER_FORWARD_HOURS = 48;
|
|
2
4
|
function normalizeStrings(values) {
|
|
3
5
|
if (!Array.isArray(values))
|
|
@@ -56,7 +58,7 @@ function normalizeTargetDate(value) {
|
|
|
56
58
|
export const refillSendsToolDefinitions = [
|
|
57
59
|
{
|
|
58
60
|
name: "refill_sends",
|
|
59
|
-
description: "Typed command entrypoint for Sellable refill sends. Accepts --yolo semantics and optional sender selectors, then returns the bounded execution contract for the skill-led refill workflow. This tool does not mutate campaigns, import leads, approve messages, schedule sends, launch, archive, delete, or write scheduler rows.",
|
|
61
|
+
description: "Typed command entrypoint for Sellable refill sends. Accepts --yolo semantics and optional sender selectors, then returns the bounded execution contract for the skill-led refill workflow. In --yolo, it may refresh stale paid InMail credit cache facts for exact selected senders once, then rerun and return the post-refresh target plan. This tool does not mutate campaigns, import leads, approve messages, schedule sends, launch, archive, delete, or write scheduler rows.",
|
|
60
62
|
inputSchema: {
|
|
61
63
|
type: "object",
|
|
62
64
|
properties: {
|
|
@@ -211,8 +213,9 @@ export function refillSendsCommand(input = {}) {
|
|
|
211
213
|
"Treat current dashboard-active PAUSED campaign-backed sequence campaigns as start-eligible candidates: read refill state before deciding whether to prep, approve, start, or skip.",
|
|
212
214
|
"Fresh reread get_campaign_refill_state immediately before any import, prep, approval, or horizon-fill mutation.",
|
|
213
215
|
"Maintain a target-window saturation ledger per selected sender from get_refill_target_plan: selected days, gross capacity, actual sent counts, future scheduler-owned scheduled counts, projected counts, ready-to-schedule buffer, remaining projected gap, paid InMail threshold feasibility, targetShapeRevision, stateRevision, and next MCP primitive.",
|
|
214
|
-
"
|
|
215
|
-
"
|
|
216
|
+
"In --yolo, this tool automatically maintains a run-local refreshedPaidInmailSenderIds set: when the first target plan returns refresh_paid_inmail_credits candidates for selected paid-InMail lanes, it refreshes each exact sender at most once, reruns get_refill_target_plan, and returns the post-refresh targetPlan before any prep/import/approval/start action is chosen.",
|
|
217
|
+
"Do not present paid-credit refresh as the next operator action after refill_sends returns autoPaidInmailRefresh and the post-refresh targetPlan.",
|
|
218
|
+
"If paid InMail feasibility remains below threshold after that automatic refresh, report the exact sender/campaign/table/column threshold action or connection fallback; --yolo must not lower paid InMail thresholds or create campaigns.",
|
|
216
219
|
"In --yolo or after one Accept, continue through every safe selected sender/campaign action covered by the rendered target packet; sent/scheduled-count progress changes stateRevision and should continue while targetShapeRevision is stable.",
|
|
217
220
|
"Do not complete a fill/schedule request until a final get_refill_target_plan or refill-state reread proves projected coverage (sent + scheduled) fills the scheduler-forward target window. Treat awaiting_scheduler_after_ready_buffer as loaded, awaiting scheduler when ready buffer covers the gap; do not import/prep more rows in that state, and keep polling unless Christian stops/statuses the run or a concrete non-scheduler blocker such as paid_inmail_below_threshold appears.",
|
|
218
221
|
],
|
|
@@ -264,3 +267,149 @@ export function refillSendsCommand(input = {}) {
|
|
|
264
267
|
},
|
|
265
268
|
};
|
|
266
269
|
}
|
|
270
|
+
function targetPlanInputFor(input = {}) {
|
|
271
|
+
const senders = normalizeStrings(input.senders);
|
|
272
|
+
const senderIds = normalizeStrings(input.senderIds);
|
|
273
|
+
const senderNames = normalizeStrings(input.senderNames);
|
|
274
|
+
const targetDate = normalizeTargetDate(input.targetDate);
|
|
275
|
+
const untilDate = targetDate ? null : normalizeUntilDate(input.untilDate);
|
|
276
|
+
const horizonSendDays = targetDate || untilDate
|
|
277
|
+
? null
|
|
278
|
+
: normalizeHorizonSendDays(input.horizonSendDays);
|
|
279
|
+
const approvalMode = input.approvalMode ?? (input.yolo === true ? "approve" : "mark_ready");
|
|
280
|
+
return {
|
|
281
|
+
intent: input.intent ?? "plain",
|
|
282
|
+
...(input.campaignId ? { campaignId: input.campaignId } : {}),
|
|
283
|
+
...(input.tableId ? { tableId: input.tableId } : {}),
|
|
284
|
+
...(senderIds.length > 0 ? { senderIds } : {}),
|
|
285
|
+
...(senderNames.length > 0 ? { senderNames } : {}),
|
|
286
|
+
...(senders.length > 0 ? { senders } : {}),
|
|
287
|
+
...(targetDate
|
|
288
|
+
? { targetDate }
|
|
289
|
+
: untilDate
|
|
290
|
+
? { untilDate }
|
|
291
|
+
: horizonSendDays === null
|
|
292
|
+
? {}
|
|
293
|
+
: { horizonSendDays }),
|
|
294
|
+
approvalMode,
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
function recordValue(value) {
|
|
298
|
+
return value && typeof value === "object" && !Array.isArray(value)
|
|
299
|
+
? value
|
|
300
|
+
: null;
|
|
301
|
+
}
|
|
302
|
+
function stringValue(value) {
|
|
303
|
+
return typeof value === "string" && value.trim() ? value.trim() : null;
|
|
304
|
+
}
|
|
305
|
+
function paidRefreshActionFrom(value) {
|
|
306
|
+
const action = recordValue(value);
|
|
307
|
+
if (!action || action.type !== "refresh_paid_inmail_credits")
|
|
308
|
+
return null;
|
|
309
|
+
const ids = recordValue(action.ids);
|
|
310
|
+
const senderId = stringValue(ids?.senderId) ?? stringValue(action.senderId);
|
|
311
|
+
if (!senderId)
|
|
312
|
+
return null;
|
|
313
|
+
return {
|
|
314
|
+
senderId,
|
|
315
|
+
actionKey: stringValue(action.actionKey),
|
|
316
|
+
action,
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
function collectPaidInmailRefreshActions(plan) {
|
|
320
|
+
const root = recordValue(plan);
|
|
321
|
+
const target = recordValue(root?.target);
|
|
322
|
+
const bySender = new Map();
|
|
323
|
+
const add = (candidate) => {
|
|
324
|
+
const action = paidRefreshActionFrom(candidate);
|
|
325
|
+
if (action && !bySender.has(action.senderId)) {
|
|
326
|
+
bySender.set(action.senderId, action);
|
|
327
|
+
}
|
|
328
|
+
};
|
|
329
|
+
const senderPlans = Array.isArray(target?.senderRefillPlans)
|
|
330
|
+
? target.senderRefillPlans
|
|
331
|
+
: [];
|
|
332
|
+
for (const senderPlan of senderPlans) {
|
|
333
|
+
const planRecord = recordValue(senderPlan);
|
|
334
|
+
const nextActions = Array.isArray(planRecord?.nextActions)
|
|
335
|
+
? planRecord.nextActions
|
|
336
|
+
: [];
|
|
337
|
+
for (const action of nextActions)
|
|
338
|
+
add(action);
|
|
339
|
+
}
|
|
340
|
+
const globalActionQueue = Array.isArray(target?.globalActionQueue)
|
|
341
|
+
? target.globalActionQueue
|
|
342
|
+
: [];
|
|
343
|
+
for (const action of globalActionQueue)
|
|
344
|
+
add(action);
|
|
345
|
+
const actionCandidates = Array.isArray(root?.actionCandidates)
|
|
346
|
+
? root.actionCandidates
|
|
347
|
+
: [];
|
|
348
|
+
for (const action of actionCandidates)
|
|
349
|
+
add(action);
|
|
350
|
+
return [...bySender.values()];
|
|
351
|
+
}
|
|
352
|
+
export async function executeRefillSendsCommand(input = {}) {
|
|
353
|
+
const command = refillSendsCommand(input);
|
|
354
|
+
if (input.yolo !== true) {
|
|
355
|
+
return {
|
|
356
|
+
...command,
|
|
357
|
+
autoPaidInmailRefresh: {
|
|
358
|
+
enabled: false,
|
|
359
|
+
status: "not_run_without_yolo",
|
|
360
|
+
refreshedPaidInmailSenderIds: [],
|
|
361
|
+
failedPaidInmailRefreshes: [],
|
|
362
|
+
note: "Automatic paid InMail credit refresh only runs for --yolo refill_sends calls.",
|
|
363
|
+
},
|
|
364
|
+
};
|
|
365
|
+
}
|
|
366
|
+
const targetPlanInput = targetPlanInputFor(input);
|
|
367
|
+
const targetPlanBeforePaidRefresh = await getRefillTargetPlan(targetPlanInput);
|
|
368
|
+
const refreshActions = collectPaidInmailRefreshActions(targetPlanBeforePaidRefresh);
|
|
369
|
+
const refreshedPaidInmailSenderIds = [];
|
|
370
|
+
const failedPaidInmailRefreshes = [];
|
|
371
|
+
const refreshReceipts = [];
|
|
372
|
+
for (const action of refreshActions) {
|
|
373
|
+
try {
|
|
374
|
+
const receipt = await refreshPaidInmailCredits({
|
|
375
|
+
senderId: action.senderId,
|
|
376
|
+
});
|
|
377
|
+
refreshedPaidInmailSenderIds.push(action.senderId);
|
|
378
|
+
refreshReceipts.push({
|
|
379
|
+
senderId: action.senderId,
|
|
380
|
+
actionKey: action.actionKey ?? null,
|
|
381
|
+
receipt,
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
catch (error) {
|
|
385
|
+
failedPaidInmailRefreshes.push({
|
|
386
|
+
senderId: action.senderId,
|
|
387
|
+
error: error instanceof Error ? error.message : String(error),
|
|
388
|
+
});
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
const targetPlan = refreshActions.length > 0
|
|
392
|
+
? await getRefillTargetPlan(targetPlanInput)
|
|
393
|
+
: targetPlanBeforePaidRefresh;
|
|
394
|
+
return {
|
|
395
|
+
...command,
|
|
396
|
+
targetPlan,
|
|
397
|
+
targetPlanBeforePaidRefresh: refreshActions.length > 0 ? targetPlanBeforePaidRefresh : null,
|
|
398
|
+
autoPaidInmailRefresh: {
|
|
399
|
+
enabled: true,
|
|
400
|
+
status: refreshActions.length === 0
|
|
401
|
+
? "no_refresh_needed"
|
|
402
|
+
: failedPaidInmailRefreshes.length > 0
|
|
403
|
+
? "partial_failed_reread"
|
|
404
|
+
: "refreshed_and_reread",
|
|
405
|
+
refreshedPaidInmailSenderIds,
|
|
406
|
+
failedPaidInmailRefreshes,
|
|
407
|
+
refreshReceipts,
|
|
408
|
+
attemptedSenderIds: refreshActions.map((action) => action.senderId),
|
|
409
|
+
targetPlanReread: refreshActions.length > 0,
|
|
410
|
+
note: refreshActions.length > 0
|
|
411
|
+
? "refill_sends refreshed stale paid InMail credit facts internally, once per sender, then returned the post-refresh targetPlan."
|
|
412
|
+
: "No stale or missing paid InMail credit refresh candidates were present in the initial target plan.",
|
|
413
|
+
},
|
|
414
|
+
};
|
|
415
|
+
}
|
package/dist/tools/senders.js
CHANGED
|
@@ -126,7 +126,7 @@ export const senderToolDefinitions = [
|
|
|
126
126
|
},
|
|
127
127
|
{
|
|
128
128
|
name: "refresh_paid_inmail_credits",
|
|
129
|
-
description: "Refresh the cached paid InMail credit facts for one exact sender in the active workspace by calling Sellable's product credit refresh path. This updates only the sender credit cache (balance, sentSince, checkedAt) and returns the fresh status. It does not mutate campaigns, lower thresholds, approve messages, schedule sends, start campaigns, send messages, spend InMail credits, or write scheduler fields.
|
|
129
|
+
description: "Refresh the cached paid InMail credit facts for one exact sender in the active workspace by calling Sellable's product credit refresh path. This updates only the sender credit cache (balance, sentSince, checkedAt) and returns the fresh status. It does not mutate campaigns, lower thresholds, approve messages, schedule sends, start campaigns, send messages, spend InMail credits, or write scheduler fields. refill_sends --yolo normally handles get_refill_target_plan refresh_paid_inmail_credits candidates internally; use this standalone tool for manual diagnostics or explicit one-off refreshes, then rerun get_refill_target_plan before any refill mutation.",
|
|
130
130
|
inputSchema: {
|
|
131
131
|
type: "object",
|
|
132
132
|
properties: {
|
package/package.json
CHANGED
|
@@ -161,11 +161,14 @@ Structured planner packet:
|
|
|
161
161
|
- `manualAlternates` are not yolo actions. Threshold lowering and campaign
|
|
162
162
|
creation are manual continuations only.
|
|
163
163
|
|
|
164
|
-
Run-local paid-credit guard:
|
|
165
|
-
|
|
166
|
-
command call
|
|
167
|
-
|
|
168
|
-
|
|
164
|
+
Run-local paid-credit guard: in `--yolo`, the `refill_sends` MCP command
|
|
165
|
+
automatically maintains a `refreshedPaidInmailSenderIds` set for the current
|
|
166
|
+
command call. If its first target plan has stale/missing paid-InMail credit
|
|
167
|
+
facts, it refreshes each selected sender at most once, reruns
|
|
168
|
+
`get_refill_target_plan`, and returns the post-refresh `targetPlan` before
|
|
169
|
+
choosing the next prep/approval/start action. If fresh facts are still below
|
|
170
|
+
threshold, below-threshold paid-InMail facts fall back to an existing connection
|
|
171
|
+
lane or a manual continuation.
|
|
169
172
|
|
|
170
173
|
Compact refill lessons: sender-level target plan is final truth; trust
|
|
171
174
|
`schedulerGate.sendable` and scheduler gate blockers, not raw
|
|
@@ -190,14 +193,16 @@ interval, until projected coverage fills the target, a concrete non-scheduler
|
|
|
190
193
|
blocker appears, or Christian explicitly asks to stop or only receive a status
|
|
191
194
|
report. Treat `awaiting_scheduler_after_ready_buffer` as an in-progress wait
|
|
192
195
|
state, not a close-out condition.
|
|
193
|
-
If paid InMail credit facts are stale or missing and the target plan
|
|
194
|
-
`refresh_paid_inmail_credits
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
196
|
+
If paid InMail credit facts are stale or missing and the first target plan
|
|
197
|
+
contains `refresh_paid_inmail_credits`, do not present that as the operator's
|
|
198
|
+
next action in `--yolo`. Do not present paid-credit refresh as the next operator
|
|
199
|
+
action after `refill_sends` returns `autoPaidInmailRefresh` and the
|
|
200
|
+
post-refresh `targetPlan`. Trust `refill_sends.autoPaidInmailRefresh`: it should
|
|
201
|
+
show the exact sender ids refreshed once, sender-credit-cache write receipts,
|
|
202
|
+
and a returned post-refresh `targetPlan`. Continue from that post-refresh packet.
|
|
203
|
+
If paid InMail is below threshold after the fresh credit read, report the exact
|
|
204
|
+
campaign/table/column threshold action or connection fallback; `--yolo` does not
|
|
205
|
+
lower paid-InMail thresholds or create campaigns.
|
|
201
206
|
|
|
202
207
|
If the plain route's managed waterfall targets are stale, for example skipped
|
|
203
208
|
targets show archived/completed shared slots or the returned targets do not cover
|
|
@@ -105,11 +105,14 @@ in-progress wait state, not a reason to mark the goal complete or blocked.
|
|
|
105
105
|
- `nextActions[0]` is the current sender's smallest safe primitive.
|
|
106
106
|
- `manualAlternates` are not yolo actions. Threshold lowering and campaign
|
|
107
107
|
creation are manual continuations only.
|
|
108
|
-
Run-local paid-credit guard:
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
108
|
+
Run-local paid-credit guard: in `--yolo`, the `refill_sends` MCP command
|
|
109
|
+
automatically maintains a `refreshedPaidInmailSenderIds` set for the current
|
|
110
|
+
command call. If its first target plan has stale/missing paid-InMail credit
|
|
111
|
+
facts, it refreshes each selected sender at most once, reruns
|
|
112
|
+
`get_refill_target_plan`, and returns the post-refresh `targetPlan` before
|
|
113
|
+
choosing the next prep/approval/start action. If fresh facts are still below
|
|
114
|
+
threshold, below-threshold paid-InMail facts fall back to an existing
|
|
115
|
+
connection lane or a manual continuation.
|
|
113
116
|
Compact refill lessons: sender-level target plan is final truth; trust
|
|
114
117
|
`schedulerGate.sendable` and scheduler gate blockers, not raw
|
|
115
118
|
`unipileAccountStatus` labels alone; use compact prep status checks for
|
|
@@ -136,13 +139,15 @@ in-progress wait state, not a reason to mark the goal complete or blocked.
|
|
|
136
139
|
stop or only receive a status report. Treat
|
|
137
140
|
`awaiting_scheduler_after_ready_buffer` as an in-progress wait state, not a
|
|
138
141
|
close-out condition.
|
|
139
|
-
If paid InMail credit facts are stale or missing and the target plan
|
|
140
|
-
`refresh_paid_inmail_credits
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
142
|
+
If paid InMail credit facts are stale or missing and the first target plan
|
|
143
|
+
contains `refresh_paid_inmail_credits`, do not present that as the operator's
|
|
144
|
+
next action in `--yolo`. Do not present paid-credit refresh as the next
|
|
145
|
+
operator action after `refill_sends` returns `autoPaidInmailRefresh` and the
|
|
146
|
+
post-refresh `targetPlan`. Trust `refill_sends.autoPaidInmailRefresh`: it
|
|
147
|
+
should show the exact sender ids refreshed once, sender-credit-cache write
|
|
148
|
+
receipts, and a returned post-refresh `targetPlan`. Continue from that
|
|
149
|
+
post-refresh packet. If paid InMail is below threshold after the fresh credit read, report
|
|
150
|
+
the exact campaign/table/column threshold action or
|
|
146
151
|
connection fallback; `--yolo` does not lower paid-InMail thresholds or create campaigns.
|
|
147
152
|
2. Call `resolve_campaign_fill_route`. Use `intent:"plain"` for generic
|
|
148
153
|
fill/load language, `intent:"active"` only when the user explicitly narrowed
|