@sellable/mcp 0.1.340 → 0.1.342

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.
@@ -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" }) and get_campaign_refill_state before any mutation. Route outcomes are route:"evergreen_horizon", route:"active_campaigns", and route:"ask_create"; 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: calculate the bounded target from sender capacity when needed, then use the refill workflow to decide same-campaign source replenishment, enrichment/prep, approval/ready state, scheduler reread, and sender-health blockers. Do not create warm-post-engager side campaigns. 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. Before source import, prep, or approval, require exact visible approval 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, but still do not launch. For "schedule X sends" or "fill sender sends", approve only when explicitly requested, then re-read campaign/table scheduled counts; if scheduler-owned scheduledFor cells are not present, report prepared/approved/ready - awaiting scheduler instead of success. Do not call start_campaign as part of fill/schedule horizon. Do not call start_campaign as part of refill sends. Launch/start is a separate explicit human action after the operator intentionally wants sends to go out, and it must still verify that the bounded cohort is the only approved cohort and must not broad approve-all. 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. start_campaign remains forbidden until explicit launch/start approval outside refill sends.`,
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" }) and get_campaign_refill_state before any mutation. Route outcomes are route:"evergreen_horizon", route:"active_campaigns", and route:"ask_create"; 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: calculate the bounded target from sender capacity when needed, then use the refill workflow to decide same-campaign source replenishment, enrichment/prep, approval/ready state, scheduler reread, and sender-health blockers. Do not create warm-post-engager side campaigns. 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. After confirm_lead_list copies rows into an existing table, avoid fixed maxRowsToCheck:100; inspect reviewBatch/table selectors or use adaptive/wider bounded prep so appended rows are included. 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. Before source import, prep, or approval, require exact visible approval 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, but still do not launch. For "schedule X sends" or "fill sender sends", approve only when explicitly requested, then re-read campaign/table scheduled counts; if scheduler-owned scheduledFor cells are not present, report prepared/approved/ready - awaiting scheduler instead of success. Do not call start_campaign as part of fill/schedule horizon. Do not call start_campaign as part of refill sends. Launch/start is a separate explicit human action after the operator intentionally wants sends to go out, and it must still verify that the bounded cohort is the only approved cohort and must not broad approve-all. 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. start_campaign remains forbidden until explicit launch/start approval outside refill sends.`,
377
377
  },
378
378
  };
379
379
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sellable/mcp",
3
- "version": "0.1.340",
3
+ "version": "0.1.342",
4
4
  "type": "module",
5
5
  "description": "Sellable MCP server for Claude Code and Codex campaign workflows",
6
6
  "main": "dist/index.js",
@@ -142,6 +142,14 @@ Treat active fills as capacity-fill preparation: calculate the bounded target
142
142
  from sender capacity when needed, then use the refill workflow to decide source
143
143
  replenishment, enrichment/prep, approval policy, and scheduler proof. Mutation
144
144
  requires exact visible approval and a fresh `get_campaign_refill_state` reread.
145
+ For already-running regular campaigns that need Signal Discovery source
146
+ replenishment, the refill workflow owns the guarded recovery: clear
147
+ `currentStep` only with `clearCurrentStepIfMatches:"running"`, load the
148
+ campaign-scoped provider prompt, run campaign-scoped `search_signals`, select
149
+ posts with a capacity-target scrape plan, import into the same source path, and
150
+ restore Running through `confirm_lead_list`. If the copied rows append beyond
151
+ the first table page, inspect `reviewBatch` with table-schema/selector tools and
152
+ use adaptive or wider bounded message prep; do not rely on a fixed `maxRowsToCheck:100` pass after source copy.
145
153
  If the user says "prepare/generate X messages", use message-prep primitives with
146
154
  `targetPreparedMessages:X` and default `approvalMode:"mark_ready"`. If the user
147
155
  says "approve X messages", use `approvalMode:"approve"` only for the bounded
@@ -9,6 +9,9 @@ allowed-tools:
9
9
  - mcp__sellable__get_campaign_refill_state
10
10
  - mcp__sellable__fill_campaign_horizon
11
11
  - mcp__sellable__get_campaign
12
+ - mcp__sellable__get_campaign_context
13
+ - mcp__sellable__update_campaign
14
+ - mcp__sellable__get_provider_prompt
12
15
  - mcp__sellable__get_campaign_message_preparation_status
13
16
  - mcp__sellable__start_campaign_message_preparation
14
17
  - mcp__sellable__cancel_campaign_message_preparation
@@ -16,6 +19,7 @@ allowed-tools:
16
19
  - mcp__sellable__wait_for_lead_list_ready
17
20
  - mcp__sellable__confirm_lead_list
18
21
  - mcp__sellable__search_signals
22
+ - mcp__sellable__select_promising_posts
19
23
  - mcp__sellable__fetch_post_engagers
20
24
  - mcp__sellable__search_sales_nav
21
25
  - mcp__sellable__lookup_sales_nav_filter
@@ -29,6 +33,10 @@ allowed-tools:
29
33
  - mcp__sellable__get_rows
30
34
  - mcp__sellable__get_rows_minimal
31
35
  - mcp__sellable__get_table_rows
36
+ - mcp__sellable__get_campaign_table_schema
37
+ - mcp__sellable__select_campaign_cells
38
+ - mcp__sellable__wait_for_campaign_processing
39
+ - mcp__sellable__get_sender
32
40
  ---
33
41
 
34
42
  # Refill Sends
@@ -7,6 +7,9 @@ allowed-tools:
7
7
  - mcp__sellable__get_campaign_refill_state
8
8
  - mcp__sellable__fill_campaign_horizon
9
9
  - mcp__sellable__get_campaign
10
+ - mcp__sellable__get_campaign_context
11
+ - mcp__sellable__update_campaign
12
+ - mcp__sellable__get_provider_prompt
10
13
  - mcp__sellable__get_campaign_message_preparation_status
11
14
  - mcp__sellable__start_campaign_message_preparation
12
15
  - mcp__sellable__cancel_campaign_message_preparation
@@ -14,6 +17,7 @@ allowed-tools:
14
17
  - mcp__sellable__wait_for_lead_list_ready
15
18
  - mcp__sellable__confirm_lead_list
16
19
  - mcp__sellable__search_signals
20
+ - mcp__sellable__select_promising_posts
17
21
  - mcp__sellable__fetch_post_engagers
18
22
  - mcp__sellable__search_sales_nav
19
23
  - mcp__sellable__lookup_sales_nav_filter
@@ -27,6 +31,10 @@ allowed-tools:
27
31
  - mcp__sellable__get_rows
28
32
  - mcp__sellable__get_rows_minimal
29
33
  - mcp__sellable__get_table_rows
34
+ - mcp__sellable__get_campaign_table_schema
35
+ - mcp__sellable__select_campaign_cells
36
+ - mcp__sellable__wait_for_campaign_processing
37
+ - mcp__sellable__get_sender
30
38
  ---
31
39
 
32
40
  # Refill Sends Workflow
@@ -101,6 +109,42 @@ Source replenishment choices:
101
109
  source prospects into the same campaign/source-list path, then confirm
102
110
  readiness.
103
111
 
112
+ ### Running Campaign Signal Discovery Recovery
113
+
114
+ For an already-running regular campaign that needs same-campaign Signal
115
+ Discovery replenishment, treat the watch/current-step transition as a guarded
116
+ repair, not as normal create-campaign navigation.
117
+
118
+ Do not call `search_signals` with `currentStep:"signal-discovery"` directly from `currentStep:"running"`. The campaign step guard intentionally rejects that
119
+ backwards transition. After exact approval and a fresh refill-state reread, clear `currentStep` only if it still exactly matches `running`:
120
+
121
+ ```text
122
+ update_campaign({ campaignId, currentStep:null, clearCurrentStepIfMatches:"running" })
123
+ ```
124
+
125
+ Then register provider preflight and run a campaign-scoped `search_signals` so
126
+ post rows exist in the campaign's Signal Discovery state:
127
+
128
+ ```text
129
+ get_provider_prompt({ provider:"signal-discovery", campaignOfferId, confirmed:true })
130
+ search_signals({ campaignOfferId, currentStep:"signal-discovery", confirmed:true, ... })
131
+ ```
132
+
133
+ Use `select_promising_posts` before importing. For a fresh source refill, prefer
134
+ `selectionMode:"replace"` and `scrapePlanMode:"capacity-target"` with the
135
+ approved `targetEngagerCount` and `maxPostsToScrape`. If the approved post set cannot cover the target, do not knowingly run an under-capacity scrape; ask for approval to expand the selected post set or switch source.
136
+
137
+ If `import_leads` returns `reusedExistingSourceList` but the user explicitly
138
+ approved a different selected-post scrape, retry `import_leads` with the existing `sourceLeadListId` from that response or from refill state. For Signal
139
+ Discovery this bypasses the stale reuse guard and materializes the newly
140
+ selected campaign-scoped posts into a fresh source list.
141
+
142
+ After `wait_for_lead_list_ready`, call `confirm_lead_list` with the new
143
+ source-list id and same campaign id. Pass `currentStep:"running"` to `confirm_lead_list` for an ACTIVE already-running campaign so the watched state
144
+ returns to Running after same-campaign source rows are copied. Do not call
145
+ `update_campaign` to fake this after the copy; `confirm_lead_list` owns the
146
+ post-copy state transition.
147
+
104
148
  Before any source mutation, show exact approval evidence: workspace id,
105
149
  campaign id, workflow table id, source/provider id, source-list id when known,
106
150
  import caps, target dates/caps, dedupe/DNC/provider exclusion expectations, and
@@ -135,11 +179,28 @@ Before prep or approval mutation, reread `get_campaign_refill_state` and compare
135
179
  If they changed, stop. A second concurrent refill run must see the first run's
136
180
  import/prep state on reread and avoid duplicate work.
137
181
 
182
+ After same-campaign source copy, inspect the actual campaign-table position of
183
+ the copied rows before starting prep. Newly copied rows often land after the first 100 table rows. Use `get_campaign_table_schema` to read the `reviewBatch`,
184
+ then use `select_campaign_cells` diagnostics against
185
+ `rowSelector:{ type:"reviewBatch" }` for `enrich`, `generateMessage`, and
186
+ `approved` roles when needed.
187
+
188
+ If review-batch enrich cells are pending or Generate Message cells are
189
+ dependency-blocked, omit `maxRowsToCheck` so the adaptive prep job can cover the
190
+ bounded table scan, or set a bounded cap high enough to include appended rows
191
+ when row count evidence requires it. Do not run a fixed `maxRowsToCheck:100` prep pass after appending rows to a larger existing campaign table; it can spend
192
+ the whole budget on older rows and miss the refill batch.
193
+
138
194
  Scheduled success requires a post-action reread proving scheduler-owned cells
139
195
  with non-null `scheduledFor`. Prepared, approved, and ready-to-schedule rows are
140
196
  intermediate states; report them as awaiting scheduler unless scheduled cells
141
197
  are present.
142
198
 
199
+ preparedMessages can remain 0 while scheduler-ready state changes downstream.
200
+ After a prep job reaches a terminal state, run `wait_for_campaign_processing`
201
+ when generated/pass counts are still settling, then poll `get_campaign_refill_state` until `readyToSchedule` drops, scheduled counts increase, or the state clearly
202
+ remains awaiting scheduler. Do not force scheduler fields directly.
203
+
143
204
  ## Evergreen Campaign Discipline
144
205
 
145
206
  `fill_campaign_horizon` is a legacy evergreen-only lower-level primitive. Call it