@sellable/mcp 0.1.535 → 0.1.536
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/README.md +5 -2
- package/dist/index-dev.js +0 -0
- package/dist/index.js +0 -0
- package/dist/refill-date-window.d.ts +34 -0
- package/dist/refill-date-window.js +210 -0
- package/dist/refill-run-loop.d.ts +9 -1
- package/dist/refill-run-loop.js +435 -85
- package/dist/server.js +4 -0
- package/dist/tools/evergreen-refill-plan.d.ts +19 -0
- package/dist/tools/evergreen-refill-plan.js +19 -0
- package/dist/tools/prompts.d.ts +2 -0
- package/dist/tools/prompts.js +1 -0
- package/dist/tools/refill-executors.d.ts +0 -7
- package/dist/tools/refill-executors.js +0 -22
- package/dist/tools/refill-sends-evergreen.d.ts +28 -0
- package/dist/tools/refill-sends-evergreen.js +47 -0
- package/dist/tools/refill-sends-v2.d.ts +19 -0
- package/dist/tools/refill-sends-v2.js +32 -1
- package/dist/tools/refill-sends.d.ts +0 -12
- package/dist/tools/refill-sends.js +37 -58
- package/dist/tools/refill-target-plan.js +19 -6
- package/dist/tools/registry.d.ts +55 -0
- package/dist/tools/registry.js +2 -0
- package/dist/tools/scheduler-fill-capacity.js +1 -1
- package/dist/tools/scheduler-run.d.ts +32 -0
- package/dist/tools/scheduler-run.js +68 -0
- package/dist/tools/senders.d.ts +8 -14
- package/dist/tools/senders.js +10 -21
- package/package.json +1 -1
- package/skills/refill-sends/SKILL.md +31 -4
- package/skills/refill-sends-v2/SKILL.md +29 -5
- package/skills/refill-sends-v2-workflow/SKILL.md +27 -2
- package/skills/refill-sends-v2-workflow/core/flow.v1.json +19 -3
- package/skills/refill-sends-workflow/SKILL.md +27 -5
- package/skills/refill-sends-workflow/core/flow.v1.json +6 -1
|
@@ -3,6 +3,9 @@ type GetRefillPlanV2Input = {
|
|
|
3
3
|
intent?: "auto" | "evergreen" | "plain" | "active";
|
|
4
4
|
senderIds?: string[];
|
|
5
5
|
runState?: Record<string, unknown>;
|
|
6
|
+
targetDate?: string | null;
|
|
7
|
+
untilDate?: string | null;
|
|
8
|
+
horizonSendDays?: number | null;
|
|
6
9
|
journal?: boolean;
|
|
7
10
|
journalNote?: string;
|
|
8
11
|
};
|
|
@@ -38,6 +41,22 @@ export declare const refillPlanV2ToolDefinitions: {
|
|
|
38
41
|
enum: string[];
|
|
39
42
|
description: string;
|
|
40
43
|
};
|
|
44
|
+
targetDate: {
|
|
45
|
+
type: string;
|
|
46
|
+
pattern: string;
|
|
47
|
+
description: string;
|
|
48
|
+
};
|
|
49
|
+
untilDate: {
|
|
50
|
+
type: string;
|
|
51
|
+
pattern: string;
|
|
52
|
+
description: string;
|
|
53
|
+
};
|
|
54
|
+
horizonSendDays: {
|
|
55
|
+
type: string;
|
|
56
|
+
minimum: number;
|
|
57
|
+
maximum: number;
|
|
58
|
+
description: string;
|
|
59
|
+
};
|
|
41
60
|
journal: {
|
|
42
61
|
type: string;
|
|
43
62
|
description: string;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as path from "node:path";
|
|
2
2
|
import { getApi, SellableApiError } from "../api.js";
|
|
3
|
+
import { normalizeRefillDateSelector, refillDateSelectorBody, } from "../refill-date-window.js";
|
|
3
4
|
import { appendIndexLine, appendJournalEvent, createRunJournal, renderBootstrapSection, renderPlanSection, renderTerminalSection, } from "../refill-journal.js";
|
|
4
5
|
import { readRefillWorkspaceState } from "../refill-local-state.js";
|
|
5
6
|
import { normalizeExplicitWorkspaceId, workspaceRequestOptions, } from "./workspace-context.js";
|
|
@@ -175,6 +176,22 @@ export const refillPlanV2ToolDefinitions = [
|
|
|
175
176
|
enum: ["auto", "evergreen", "plain", "active"],
|
|
176
177
|
description: 'Planner intent. Defaults to "auto" for refill-sends-v2.',
|
|
177
178
|
},
|
|
179
|
+
targetDate: {
|
|
180
|
+
type: "string",
|
|
181
|
+
pattern: "^\\d{4}-\\d{2}-\\d{2}$",
|
|
182
|
+
description: "Optional one exact sender-local date (YYYY-MM-DD) to plan. Takes precedence over untilDate and horizonSendDays.",
|
|
183
|
+
},
|
|
184
|
+
untilDate: {
|
|
185
|
+
type: "string",
|
|
186
|
+
pattern: "^\\d{4}-\\d{2}-\\d{2}$",
|
|
187
|
+
description: "Optional inclusive sender-local through-date (YYYY-MM-DD) to plan.",
|
|
188
|
+
},
|
|
189
|
+
horizonSendDays: {
|
|
190
|
+
type: "number",
|
|
191
|
+
minimum: 1,
|
|
192
|
+
maximum: 7,
|
|
193
|
+
description: "Optional explicit next N sender-local send days to plan.",
|
|
194
|
+
},
|
|
178
195
|
journal: {
|
|
179
196
|
type: "boolean",
|
|
180
197
|
description: "Set false to skip the local dry-run journal write.",
|
|
@@ -197,6 +214,7 @@ export async function getRefillPlanV2(input) {
|
|
|
197
214
|
const runState = input.runState !== undefined
|
|
198
215
|
? input.runState
|
|
199
216
|
: buildRunStateFromLocalHints(workspaceId);
|
|
217
|
+
const dateSelector = normalizeRefillDateSelector(input);
|
|
200
218
|
let raw;
|
|
201
219
|
try {
|
|
202
220
|
raw = await postRefillPlanV2({
|
|
@@ -204,6 +222,7 @@ export async function getRefillPlanV2(input) {
|
|
|
204
222
|
intent: input.intent ?? "auto",
|
|
205
223
|
senderIds: input.senderIds,
|
|
206
224
|
runState,
|
|
225
|
+
...refillDateSelectorBody(dateSelector),
|
|
207
226
|
}, workspaceId);
|
|
208
227
|
}
|
|
209
228
|
catch (error) {
|
package/dist/tools/prompts.d.ts
CHANGED
|
@@ -82,6 +82,7 @@ export interface SourceScoutRegistryResponse {
|
|
|
82
82
|
codex: string;
|
|
83
83
|
claude: string;
|
|
84
84
|
parentThreadRule: string;
|
|
85
|
+
schedulerRunReceiptRule?: string;
|
|
85
86
|
prepareMessagesRule?: string;
|
|
86
87
|
};
|
|
87
88
|
}
|
|
@@ -132,6 +133,7 @@ export interface PostFindLeadsScoutRegistryResponse {
|
|
|
132
133
|
codex: string;
|
|
133
134
|
claude: string;
|
|
134
135
|
parentThreadRule: string;
|
|
136
|
+
schedulerRunReceiptRule?: string;
|
|
135
137
|
prepareMessagesRule?: string;
|
|
136
138
|
};
|
|
137
139
|
}
|
package/dist/tools/prompts.js
CHANGED
|
@@ -379,6 +379,7 @@ export function getPostFindLeadsScoutRegistry() {
|
|
|
379
379
|
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.',
|
|
380
380
|
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.",
|
|
381
381
|
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.',
|
|
382
|
+
schedulerRunReceiptRule: "For refill prompt handoffs, scheduler-run receipt interpretation is mandatory: cellsConsidered is allocation-attempt count, not total ready supply, while readyCellsFound is ready inventory found before prefilters. Inspect campaignScopeSummary before assuming the selected refill campaign/table was included. Interpret prefiltered, skipped, and deferred separately. For ready closed-InMail cells with stale paid-credit prefilter/defer reasons, route to refresh_paid_inmail_credits_then_rerun once, then rerun/status. wait_for_capacity_or_window means report loaded/capped/waiting and do not source or prep more rows. no_ready_cells_continue_refill_prep means return to the refill/prep ladder. Do not treat cellsScheduled:0 alone as failure.",
|
|
382
383
|
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" }) and get_subskill_asset({ subskillName: "refill-sends-workflow", assetPath: "core/flow.v1.json" }) to hasMore:false before operational steps, 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. Refill action ladder: approve generated rows only when an explicit bounded approval gate exists, process all existing same-campaign unenriched/unprepared rows in bounded batches before any source work, then copy bounded net-new rows from the selected source (selectedLeadListId, provider, and source fingerprint preserved), then use provider-aligned source-more. A new source or provider switch changes the reply-rate baseline and is a manual alternate, not a --yolo side effect. 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/source-copy/bounded-approval/read-only wait. Freshness gate precedes scheduler wait: if any selected target.senderRefillPlans[].paidInmail.status is missing_credit_facts or stale_credit_facts, or the target plan contains refresh_paid_inmail_credits, do not enter wait_for_scheduler even when remainingReadyOrProjectedGap is 0; refresh exact sender credit facts once, reread get_refill_target_plan, then choose scheduler wait only if freshness is clean. 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/source-copy/bounded-approval/read-only wait 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.`,
|
|
383
384
|
},
|
|
384
385
|
};
|
|
@@ -14,12 +14,6 @@ export type PaidInmailCreditRefreshOptions = {
|
|
|
14
14
|
maxStalenessSeconds?: number | null;
|
|
15
15
|
paidInmailCreditsMaxStalenessSeconds?: number | null;
|
|
16
16
|
};
|
|
17
|
-
export type PaidInmailRefreshReceiptClassification = {
|
|
18
|
-
usableCurrentFacts: boolean;
|
|
19
|
-
status: string;
|
|
20
|
-
error: string | null;
|
|
21
|
-
refreshed: boolean;
|
|
22
|
-
};
|
|
23
17
|
export type YoloPrimitiveExecution = {
|
|
24
18
|
enabled: true;
|
|
25
19
|
status: "no_action" | "read_only_reread" | "executed_and_reread" | "refused" | "skipped_after_paid_refresh";
|
|
@@ -141,7 +135,6 @@ export declare function userAddedRowsLimitPayloadFromError(error: unknown): User
|
|
|
141
135
|
export declare function sourceImportInProgressPayloadFromError(error: unknown): SourceImportInProgressPayload | null;
|
|
142
136
|
export declare function paidRefreshActionFrom(value: unknown): PaidInmailRefreshAction | null;
|
|
143
137
|
export declare function collectPaidInmailRefreshActions(plan: unknown): PaidInmailRefreshAction[];
|
|
144
|
-
export declare function classifyPaidInmailRefreshReceipt(value: unknown): PaidInmailRefreshReceiptClassification;
|
|
145
138
|
export declare function firstGlobalAction(plan: unknown): Record<string, unknown> | null;
|
|
146
139
|
export declare function actionIds(action: Record<string, unknown>): Record<string, unknown>;
|
|
147
140
|
export declare function actionToolInput(action: Record<string, unknown>): Record<string, unknown>;
|
|
@@ -10,11 +10,6 @@ const PAID_INMAIL_REFRESH_RETRY_DELAY_MS = Number(process.env.SELLABLE_MCP_PAID_
|
|
|
10
10
|
const SIGNAL_DISCOVERY_MIN_REFILL_POSTS = 3;
|
|
11
11
|
const SIGNAL_DISCOVERY_MAX_REFILL_POSTS = 10;
|
|
12
12
|
const SIGNAL_DISCOVERY_TARGET_ROWS_PER_POST = 150;
|
|
13
|
-
const USABLE_PAID_INMAIL_REFRESH_RECEIPT_STATUSES = new Set([
|
|
14
|
-
"fresh",
|
|
15
|
-
"refreshed",
|
|
16
|
-
"below_threshold",
|
|
17
|
-
]);
|
|
18
13
|
export function normalizeStrings(values) {
|
|
19
14
|
if (!Array.isArray(values))
|
|
20
15
|
return [];
|
|
@@ -211,23 +206,6 @@ export function collectPaidInmailRefreshActions(plan) {
|
|
|
211
206
|
add(action);
|
|
212
207
|
return [...bySender.values()];
|
|
213
208
|
}
|
|
214
|
-
export function classifyPaidInmailRefreshReceipt(value) {
|
|
215
|
-
const response = recordValue(value);
|
|
216
|
-
const nestedReceipt = recordValue(response?.receipt);
|
|
217
|
-
const status = stringValue(nestedReceipt?.status) ??
|
|
218
|
-
stringValue(response?.status) ??
|
|
219
|
-
(response?.refreshed === true ? "refreshed" : "not_refreshed");
|
|
220
|
-
const refreshed = response?.refreshed === true || nestedReceipt?.refreshed === true;
|
|
221
|
-
const usableCurrentFacts = refreshed || USABLE_PAID_INMAIL_REFRESH_RECEIPT_STATUSES.has(status);
|
|
222
|
-
return {
|
|
223
|
-
usableCurrentFacts,
|
|
224
|
-
status,
|
|
225
|
-
refreshed,
|
|
226
|
-
error: stringValue(response?.error) ??
|
|
227
|
-
stringValue(nestedReceipt?.error) ??
|
|
228
|
-
(usableCurrentFacts ? null : "paid InMail credit refresh did not return usable current facts"),
|
|
229
|
-
};
|
|
230
|
-
}
|
|
231
209
|
export function firstGlobalAction(plan) {
|
|
232
210
|
const root = recordValue(plan);
|
|
233
211
|
const target = recordValue(root?.target);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
type RefillSendsEvergreenInput = {
|
|
2
|
+
workspaceId?: string;
|
|
3
|
+
};
|
|
4
|
+
export declare const refillSendsEvergreenToolDefinitions: {
|
|
5
|
+
name: string;
|
|
6
|
+
description: string;
|
|
7
|
+
inputSchema: {
|
|
8
|
+
type: string;
|
|
9
|
+
properties: {
|
|
10
|
+
workspaceId: {
|
|
11
|
+
type: string;
|
|
12
|
+
description: string;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
required: string[];
|
|
16
|
+
additionalProperties: boolean;
|
|
17
|
+
};
|
|
18
|
+
}[];
|
|
19
|
+
export declare function refillSendsEvergreenCommand(input: RefillSendsEvergreenInput): {
|
|
20
|
+
readOnly: boolean;
|
|
21
|
+
workspaceId: string | null;
|
|
22
|
+
firstOperationalSteps: string[];
|
|
23
|
+
approvalContract: string;
|
|
24
|
+
forbiddenActions: string[];
|
|
25
|
+
fillWindow: string;
|
|
26
|
+
hostExamples: string[];
|
|
27
|
+
};
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export const refillSendsEvergreenToolDefinitions = [
|
|
2
|
+
{
|
|
3
|
+
name: "refill_sends_evergreen",
|
|
4
|
+
description: "Read-only Phase 85 evergreen refill command contract. It performs no mutations and only tells the operator to call get_evergreen_refill_plan for a dry-run packet and journal.",
|
|
5
|
+
inputSchema: {
|
|
6
|
+
type: "object",
|
|
7
|
+
properties: {
|
|
8
|
+
workspaceId: {
|
|
9
|
+
type: "string",
|
|
10
|
+
description: "Explicit request-scoped workspace id.",
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
required: ["workspaceId"],
|
|
14
|
+
additionalProperties: false,
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
];
|
|
18
|
+
export function refillSendsEvergreenCommand(input) {
|
|
19
|
+
return {
|
|
20
|
+
readOnly: true,
|
|
21
|
+
workspaceId: input.workspaceId ?? null,
|
|
22
|
+
firstOperationalSteps: [
|
|
23
|
+
"Call get_evergreen_refill_plan with the explicit workspaceId.",
|
|
24
|
+
"Read the returned packet, globalActionQueue, per-sender plans, and itinerary before taking any action.",
|
|
25
|
+
"Review the dry-run journal file path returned by get_evergreen_refill_plan.",
|
|
26
|
+
"Phase 85 is PLAN-ONLY; execution arrives in Phase 86.",
|
|
27
|
+
],
|
|
28
|
+
approvalContract: "Nothing is approved or executable in Phase 85. The evergreen command is read-only; Phase 86 introduces execution approval.",
|
|
29
|
+
forbiddenActions: [
|
|
30
|
+
"Do not schedule sends.",
|
|
31
|
+
"Do not send messages.",
|
|
32
|
+
"Do not approve messages.",
|
|
33
|
+
"Do not prepare messages.",
|
|
34
|
+
"Do not start or launch campaigns.",
|
|
35
|
+
"Do not create campaigns.",
|
|
36
|
+
"Do not switch providers or source families.",
|
|
37
|
+
"Do not lower paid InMail thresholds.",
|
|
38
|
+
"Do not refresh paid InMail credits.",
|
|
39
|
+
"Do not write scheduler fields.",
|
|
40
|
+
],
|
|
41
|
+
fillWindow: "Use only the target window and caps returned by get_evergreen_refill_plan.",
|
|
42
|
+
hostExamples: [
|
|
43
|
+
"refill_sends_evergreen({ workspaceId })",
|
|
44
|
+
"get_evergreen_refill_plan({ workspaceId })",
|
|
45
|
+
],
|
|
46
|
+
};
|
|
47
|
+
}
|
|
@@ -6,6 +6,9 @@ type RefillSendsV2Input = {
|
|
|
6
6
|
approvalMode?: "approve" | "mark_ready";
|
|
7
7
|
senderIds?: string[];
|
|
8
8
|
intent?: "auto" | "evergreen" | "plain" | "active";
|
|
9
|
+
targetDate?: string | null;
|
|
10
|
+
untilDate?: string | null;
|
|
11
|
+
horizonSendDays?: number | null;
|
|
9
12
|
};
|
|
10
13
|
export declare const refillSendsV2ToolDefinitions: {
|
|
11
14
|
name: string;
|
|
@@ -44,6 +47,22 @@ export declare const refillSendsV2ToolDefinitions: {
|
|
|
44
47
|
type: string;
|
|
45
48
|
enum: string[];
|
|
46
49
|
};
|
|
50
|
+
targetDate: {
|
|
51
|
+
type: string;
|
|
52
|
+
pattern: string;
|
|
53
|
+
description: string;
|
|
54
|
+
};
|
|
55
|
+
untilDate: {
|
|
56
|
+
type: string;
|
|
57
|
+
pattern: string;
|
|
58
|
+
description: string;
|
|
59
|
+
};
|
|
60
|
+
horizonSendDays: {
|
|
61
|
+
type: string;
|
|
62
|
+
minimum: number;
|
|
63
|
+
maximum: number;
|
|
64
|
+
description: string;
|
|
65
|
+
};
|
|
47
66
|
};
|
|
48
67
|
required: string[];
|
|
49
68
|
additionalProperties: boolean;
|
|
@@ -5,6 +5,7 @@ import { runRefillV2Loop } from "../refill-run-loop.js";
|
|
|
5
5
|
import { getPrepareCampaignMessagesStatus } from "./campaign-message-preparation.js";
|
|
6
6
|
import { getRefillPlanV2 } from "./evergreen-refill-plan.js";
|
|
7
7
|
import { executeOneYoloPrimitive, executeStartCampaignPrimitive, prepareRowSelectorValue, refillPrepareRequestHash, refreshPaidInmailCreditsWithRetry, } from "./refill-executors.js";
|
|
8
|
+
import { runSchedulerSweep } from "./scheduler-run.js";
|
|
8
9
|
const FORBIDDEN_ACTIONS = [
|
|
9
10
|
"Do not schedule sends.",
|
|
10
11
|
"Do not send messages.",
|
|
@@ -17,7 +18,7 @@ const BOUNDED_AUTHORITY = "Within the refill run, bounded approvals, preparation
|
|
|
17
18
|
export const refillSendsV2ToolDefinitions = [
|
|
18
19
|
{
|
|
19
20
|
name: "refill_sends_v2",
|
|
20
|
-
description: "Execute the refill sends v2 loop with run-record fencing, packet re-planning, shared refill executors, and resumable dry-run/real-run modes.",
|
|
21
|
+
description: "Execute the refill sends v2 loop with run-record fencing, packet re-planning, shared refill executors, and resumable dry-run/real-run modes. Date selectors match refill_sends: targetDate is one exact sender-local date, untilDate is inclusive, horizonSendDays is the next N sender-local send days, with precedence targetDate > untilDate > horizonSendDays > default scheduler-forward planning.",
|
|
21
22
|
inputSchema: {
|
|
22
23
|
type: "object",
|
|
23
24
|
properties: {
|
|
@@ -50,6 +51,22 @@ export const refillSendsV2ToolDefinitions = [
|
|
|
50
51
|
type: "string",
|
|
51
52
|
enum: ["auto", "evergreen", "plain", "active"],
|
|
52
53
|
},
|
|
54
|
+
targetDate: {
|
|
55
|
+
type: "string",
|
|
56
|
+
pattern: "^\\d{4}-\\d{2}-\\d{2}$",
|
|
57
|
+
description: "Optional one exact sender-local date (YYYY-MM-DD) to refill.",
|
|
58
|
+
},
|
|
59
|
+
untilDate: {
|
|
60
|
+
type: "string",
|
|
61
|
+
pattern: "^\\d{4}-\\d{2}-\\d{2}$",
|
|
62
|
+
description: "Optional inclusive sender-local through-date (YYYY-MM-DD) to refill.",
|
|
63
|
+
},
|
|
64
|
+
horizonSendDays: {
|
|
65
|
+
type: "number",
|
|
66
|
+
minimum: 1,
|
|
67
|
+
maximum: 7,
|
|
68
|
+
description: "Optional explicit next N sender-local send days to refill.",
|
|
69
|
+
},
|
|
53
70
|
},
|
|
54
71
|
required: ["workspaceId"],
|
|
55
72
|
additionalProperties: false,
|
|
@@ -98,6 +115,9 @@ export async function refillSendsV2Command(input) {
|
|
|
98
115
|
workspaceId,
|
|
99
116
|
intent: input.intent,
|
|
100
117
|
senderIds: input.senderIds,
|
|
118
|
+
targetDate: input.targetDate,
|
|
119
|
+
untilDate: input.untilDate,
|
|
120
|
+
horizonSendDays: input.horizonSendDays,
|
|
101
121
|
journal: true,
|
|
102
122
|
});
|
|
103
123
|
return {
|
|
@@ -112,6 +132,9 @@ export async function refillSendsV2Command(input) {
|
|
|
112
132
|
workspaceId,
|
|
113
133
|
intent: input.intent,
|
|
114
134
|
senderIds: input.senderIds,
|
|
135
|
+
targetDate: input.targetDate,
|
|
136
|
+
untilDate: input.untilDate,
|
|
137
|
+
horizonSendDays: input.horizonSendDays,
|
|
115
138
|
approvalMode: input.approvalMode ?? "approve",
|
|
116
139
|
resume: resumeHandle(input),
|
|
117
140
|
}, {
|
|
@@ -128,6 +151,9 @@ export async function refillSendsV2Command(input) {
|
|
|
128
151
|
workspaceId: planInput.workspaceId,
|
|
129
152
|
intent: planInput.intent,
|
|
130
153
|
senderIds: planInput.senderIds,
|
|
154
|
+
targetDate: planInput.targetDate,
|
|
155
|
+
untilDate: planInput.untilDate,
|
|
156
|
+
horizonSendDays: planInput.horizonSendDays,
|
|
131
157
|
runState: planInput.runState,
|
|
132
158
|
journal: planInput.journal,
|
|
133
159
|
}),
|
|
@@ -152,6 +178,11 @@ export async function refillSendsV2Command(input) {
|
|
|
152
178
|
localState: {
|
|
153
179
|
writeRefillWorkspaceState,
|
|
154
180
|
},
|
|
181
|
+
requestSchedulerRun: (workspaceId, options) => runSchedulerSweep({
|
|
182
|
+
workspaceId,
|
|
183
|
+
action: "run",
|
|
184
|
+
targetDate: options?.targetDate,
|
|
185
|
+
}),
|
|
155
186
|
});
|
|
156
187
|
return {
|
|
157
188
|
...(await maybeAddLostFenceGuidance(result, { ...input, workspaceId })),
|
|
@@ -292,8 +292,6 @@ export declare function executeRefillSendsCommand(input?: RefillSendsCommandInpu
|
|
|
292
292
|
attempts?: number;
|
|
293
293
|
error: string;
|
|
294
294
|
errors?: string[];
|
|
295
|
-
receiptStatus?: string;
|
|
296
|
-
receipt?: unknown;
|
|
297
295
|
}[];
|
|
298
296
|
refreshReceipts: {
|
|
299
297
|
senderId: string;
|
|
@@ -303,8 +301,6 @@ export declare function executeRefillSendsCommand(input?: RefillSendsCommandInpu
|
|
|
303
301
|
approvalSource: string;
|
|
304
302
|
approvalPacket: PaidInmailRefreshApprovalPacket;
|
|
305
303
|
receipt: import("./senders.js").RefreshPaidInmailCreditsResponse;
|
|
306
|
-
receiptStatus: string;
|
|
307
|
-
usableCurrentFacts: boolean;
|
|
308
304
|
}[];
|
|
309
305
|
attemptedSenderIds: string[];
|
|
310
306
|
targetPlanReread: boolean;
|
|
@@ -313,14 +309,6 @@ export declare function executeRefillSendsCommand(input?: RefillSendsCommandInpu
|
|
|
313
309
|
note: string;
|
|
314
310
|
};
|
|
315
311
|
yoloExecution: {
|
|
316
|
-
enabled: false;
|
|
317
|
-
status: "not_run_without_yolo";
|
|
318
|
-
selectedAction: null;
|
|
319
|
-
targetPlanReread: false;
|
|
320
|
-
result?: undefined;
|
|
321
|
-
refusalReason?: undefined;
|
|
322
|
-
postActionFirstAction?: undefined;
|
|
323
|
-
} | {
|
|
324
312
|
enabled: true;
|
|
325
313
|
status: "skipped_after_paid_refresh";
|
|
326
314
|
selectedAction: null;
|
|
@@ -1,14 +1,18 @@
|
|
|
1
|
-
import { actionIds,
|
|
1
|
+
import { actionIds, collectPaidInmailRefreshActions, executeOneYoloPrimitive, firstGlobalAction, normalizeStrings, numberValue, recordValue, refreshPaidInmailCreditsWithRetry, stringValue, } from "./refill-executors.js";
|
|
2
2
|
import { getRefillTargetPlan } from "./refill-target-plan.js";
|
|
3
3
|
import { createWorkspaceContext, normalizeExplicitWorkspaceId, } from "./workspace-context.js";
|
|
4
4
|
const DEFAULT_SCHEDULER_FORWARD_HOURS = 48;
|
|
5
5
|
const MCP_PAID_INMAIL_CREDITS_MAX_STALENESS_SECONDS = 4 * 60 * 60;
|
|
6
6
|
function normalizeHorizonSendDays(value) {
|
|
7
|
-
if (value === undefined
|
|
7
|
+
if (value === undefined)
|
|
8
8
|
return null;
|
|
9
|
-
if (typeof value !== "number" ||
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
if (typeof value !== "number" ||
|
|
10
|
+
!Number.isInteger(value) ||
|
|
11
|
+
value < 1 ||
|
|
12
|
+
value > 7) {
|
|
13
|
+
throw new Error("horizonSendDays must be an integer between 1 and 7.");
|
|
14
|
+
}
|
|
15
|
+
return value;
|
|
12
16
|
}
|
|
13
17
|
function normalizeUntilDate(value) {
|
|
14
18
|
if (value === undefined || value === null || value === "")
|
|
@@ -91,7 +95,7 @@ export const refillSendsToolDefinitions = [
|
|
|
91
95
|
type: "number",
|
|
92
96
|
minimum: 1,
|
|
93
97
|
maximum: 7,
|
|
94
|
-
description: "Compatibility override for
|
|
98
|
+
description: "Compatibility override for explicit next N sender-local send days. Omit for the default scheduler-forward 48-hour target window.",
|
|
95
99
|
},
|
|
96
100
|
untilDate: {
|
|
97
101
|
type: "string",
|
|
@@ -184,7 +188,7 @@ export function refillSendsCommand(input = {}) {
|
|
|
184
188
|
horizonHours: horizonSendDays === null ? DEFAULT_SCHEDULER_FORWARD_HOURS : null,
|
|
185
189
|
description: horizonSendDays === null
|
|
186
190
|
? "Fill the default scheduler-forward 48-hour target window."
|
|
187
|
-
:
|
|
191
|
+
: `Fill the next ${horizonSendDays} sender-local send days.`,
|
|
188
192
|
},
|
|
189
193
|
approvalMode,
|
|
190
194
|
campaignId: input.campaignId ?? null,
|
|
@@ -231,8 +235,9 @@ export function refillSendsCommand(input = {}) {
|
|
|
231
235
|
"Fresh reread get_campaign_refill_state immediately before any import, prep, approval, or horizon-fill mutation.",
|
|
232
236
|
"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.",
|
|
233
237
|
"Source/fallback primitives require receipt-proven exhaustion: existingRowFrontier.hasMoreFrontierRows:false, approvalCandidates:0, no fresh active prep, no stuckActiveCells, and no non-terminal approvedNotDispatched rows. Treat anomalies, stuckActiveCells, and non-terminal approvedNotDispatched as diagnose-and-report gates, not exhaustion. Terminal approvedNotDispatched blockers may be reported and then the ladder can proceed.",
|
|
234
|
-
"In
|
|
238
|
+
"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/source-copy/bounded-approval/read-only wait action is chosen.",
|
|
235
239
|
"Freshness gate precedes scheduler wait: if any selected target.senderRefillPlans[].paidInmail.status is missing_credit_facts or stale_credit_facts, or the target plan contains refresh_paid_inmail_credits, do not enter wait_for_scheduler even when remainingReadyOrProjectedGap is 0; refresh exact sender credit facts once, reread get_refill_target_plan, then choose scheduler wait only if freshness is clean.",
|
|
240
|
+
"Scheduler-run receipt interpretation: cellsConsidered is allocation-attempt count, readyCellsFound is ready inventory before prefilters, and campaignScopeSummary must include the selected campaign/table before inferring it was ready-but-blocked. Read prefiltered, skipped, and deferred separately. For ready closed-InMail cells with stale paid-credit facts, route to refresh_paid_inmail_credits_then_rerun once, then rerun/status. wait_for_capacity_or_window means report loaded/capped/waiting and do not source or prep more rows. no_ready_cells_continue_refill_prep means return to the refill/prep ladder.",
|
|
236
241
|
"For wait_for_active_work and wait_for_scheduler, honor the receipt's absolute wait.deadlineAt when present. If the deadline is expired on this call, escalate to diagnostics with the receipt evidence instead of issuing another blind wait.",
|
|
237
242
|
"Do not present paid-credit refresh as the next operator action after refill_sends returns autoPaidInmailRefresh and the post-refresh targetPlan.",
|
|
238
243
|
"If paid InMail feasibility remains below threshold after that automatic refresh, report the exact sender/campaign/table/column threshold action or same-campaign connection fallback; --yolo must not lower paid InMail thresholds or create campaigns.",
|
|
@@ -374,11 +379,7 @@ export async function executeRefillSendsCommand(input = {}) {
|
|
|
374
379
|
? { ...input, workspaceId: workspaceContext.context.workspaceId }
|
|
375
380
|
: input;
|
|
376
381
|
const command = refillSendsCommand(scopedInput);
|
|
377
|
-
|
|
378
|
-
? workspaceContext.context.workspaceId
|
|
379
|
-
: normalizeExplicitWorkspaceId(scopedInput.workspaceId);
|
|
380
|
-
const canRefreshPaidInmailFacts = yolo || executionMode === "scheduled" || Boolean(workspaceId);
|
|
381
|
-
if (!canRefreshPaidInmailFacts) {
|
|
382
|
+
if (!yolo) {
|
|
382
383
|
return {
|
|
383
384
|
...command,
|
|
384
385
|
autoPaidInmailRefresh: {
|
|
@@ -386,7 +387,7 @@ export async function executeRefillSendsCommand(input = {}) {
|
|
|
386
387
|
status: "not_run_without_yolo",
|
|
387
388
|
refreshedPaidInmailSenderIds: [],
|
|
388
389
|
failedPaidInmailRefreshes: [],
|
|
389
|
-
note: "Automatic paid InMail credit refresh
|
|
390
|
+
note: "Automatic paid InMail credit refresh only runs for --yolo refill_sends calls.",
|
|
390
391
|
},
|
|
391
392
|
yoloExecution: {
|
|
392
393
|
enabled: false,
|
|
@@ -396,6 +397,9 @@ export async function executeRefillSendsCommand(input = {}) {
|
|
|
396
397
|
},
|
|
397
398
|
};
|
|
398
399
|
}
|
|
400
|
+
const workspaceId = workspaceContext && workspaceContext.ok
|
|
401
|
+
? workspaceContext.context.workspaceId
|
|
402
|
+
: normalizeExplicitWorkspaceId(scopedInput.workspaceId);
|
|
399
403
|
const targetPlanInput = targetPlanInputFor(scopedInput);
|
|
400
404
|
const targetPlanBeforePaidRefresh = await getRefillTargetPlan(targetPlanInput);
|
|
401
405
|
const refreshActions = collectPaidInmailRefreshActions(targetPlanBeforePaidRefresh);
|
|
@@ -421,7 +425,7 @@ export async function executeRefillSendsCommand(input = {}) {
|
|
|
421
425
|
}
|
|
422
426
|
const refreshResult = await refreshPaidInmailCreditsWithRetry(action.senderId, workspaceId, paidRefreshOptionsFromApprovalPacket(approvalPacket));
|
|
423
427
|
if (refreshResult.receipt) {
|
|
424
|
-
|
|
428
|
+
refreshedPaidInmailSenderIds.push(action.senderId);
|
|
425
429
|
refreshReceipts.push({
|
|
426
430
|
senderId: action.senderId,
|
|
427
431
|
actionKey: action.actionKey ?? null,
|
|
@@ -430,23 +434,7 @@ export async function executeRefillSendsCommand(input = {}) {
|
|
|
430
434
|
approvalSource: "explicit_yolo_flag",
|
|
431
435
|
approvalPacket,
|
|
432
436
|
receipt: refreshResult.receipt,
|
|
433
|
-
receiptStatus: classification.status,
|
|
434
|
-
usableCurrentFacts: classification.usableCurrentFacts,
|
|
435
437
|
});
|
|
436
|
-
if (classification.usableCurrentFacts) {
|
|
437
|
-
refreshedPaidInmailSenderIds.push(action.senderId);
|
|
438
|
-
}
|
|
439
|
-
else {
|
|
440
|
-
failedPaidInmailRefreshes.push({
|
|
441
|
-
senderId: action.senderId,
|
|
442
|
-
attempts: refreshResult.attempts,
|
|
443
|
-
error: classification.error ??
|
|
444
|
-
"paid InMail credit refresh did not return usable current facts",
|
|
445
|
-
errors: refreshResult.errors,
|
|
446
|
-
receiptStatus: classification.status,
|
|
447
|
-
receipt: refreshResult.receipt,
|
|
448
|
-
});
|
|
449
|
-
}
|
|
450
438
|
}
|
|
451
439
|
else {
|
|
452
440
|
failedPaidInmailRefreshes.push({
|
|
@@ -461,8 +449,8 @@ export async function executeRefillSendsCommand(input = {}) {
|
|
|
461
449
|
const targetPlan = refreshActions.length > 0
|
|
462
450
|
? await getRefillTargetPlan(targetPlanInput)
|
|
463
451
|
: targetPlanBeforePaidRefresh;
|
|
464
|
-
const selectedAction =
|
|
465
|
-
const primitiveAttempt =
|
|
452
|
+
const selectedAction = refreshActions.length > 0 ? null : firstGlobalAction(targetPlan);
|
|
453
|
+
const primitiveAttempt = refreshActions.length > 0
|
|
466
454
|
? null
|
|
467
455
|
: await executeOneYoloPrimitive(selectedAction, workspaceId ?? undefined);
|
|
468
456
|
const shouldRereadAfterPrimitive = primitiveAttempt?.status === "executed_and_reread" ||
|
|
@@ -475,9 +463,7 @@ export async function executeRefillSendsCommand(input = {}) {
|
|
|
475
463
|
...command,
|
|
476
464
|
targetPlan: finalTargetPlan,
|
|
477
465
|
targetPlanBeforePaidRefresh: refreshActions.length > 0 ? targetPlanBeforePaidRefresh : null,
|
|
478
|
-
targetPlanBeforeYoloPrimitive:
|
|
479
|
-
? targetPlan
|
|
480
|
-
: null,
|
|
466
|
+
targetPlanBeforeYoloPrimitive: refreshActions.length === 0 && postActionTargetPlan ? targetPlan : null,
|
|
481
467
|
autoPaidInmailRefresh: {
|
|
482
468
|
enabled: true,
|
|
483
469
|
status: refreshActions.length === 0
|
|
@@ -496,30 +482,23 @@ export async function executeRefillSendsCommand(input = {}) {
|
|
|
496
482
|
? "refill_sends refreshed stale paid InMail credit facts internally with bounded retries, once per sender, then returned the post-refresh targetPlan."
|
|
497
483
|
: "No stale or missing paid InMail credit refresh candidates were present in the initial target plan.",
|
|
498
484
|
},
|
|
499
|
-
yoloExecution:
|
|
485
|
+
yoloExecution: refreshActions.length > 0
|
|
500
486
|
? {
|
|
501
|
-
enabled:
|
|
502
|
-
status: "
|
|
487
|
+
enabled: true,
|
|
488
|
+
status: "skipped_after_paid_refresh",
|
|
503
489
|
selectedAction: null,
|
|
504
|
-
targetPlanReread:
|
|
490
|
+
targetPlanReread: true,
|
|
505
491
|
}
|
|
506
|
-
:
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
:
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
result: primitiveAttempt?.result,
|
|
518
|
-
targetPlanReread: shouldRereadAfterPrimitive,
|
|
519
|
-
refusalReason: primitiveAttempt?.refusalReason,
|
|
520
|
-
postActionFirstAction: postActionTargetPlan
|
|
521
|
-
? firstGlobalAction(postActionTargetPlan)
|
|
522
|
-
: null,
|
|
523
|
-
},
|
|
492
|
+
: {
|
|
493
|
+
enabled: true,
|
|
494
|
+
status: primitiveAttempt?.status ?? "no_action",
|
|
495
|
+
selectedAction,
|
|
496
|
+
result: primitiveAttempt?.result,
|
|
497
|
+
targetPlanReread: shouldRereadAfterPrimitive,
|
|
498
|
+
refusalReason: primitiveAttempt?.refusalReason,
|
|
499
|
+
postActionFirstAction: postActionTargetPlan
|
|
500
|
+
? firstGlobalAction(postActionTargetPlan)
|
|
501
|
+
: null,
|
|
502
|
+
},
|
|
524
503
|
};
|
|
525
504
|
}
|