@sellable/mcp 0.1.292 → 0.1.294

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 CHANGED
@@ -307,13 +307,15 @@ Parallel execution contract:
307
307
  review batch and rows are proven, ask the filter-choice question immediately.
308
308
  Do not load this registry or deep filter/message prompts before that question.
309
309
  Once the user answers, launch Message Drafting from the same campaign/table
310
- basis. If the user chooses filters, keep filter/rubric work in the parent
311
- thread: show Filter Rules, load `references/filter-leads.md`, save rubrics,
312
- then ask for filter approval. After approval, move to Filter Leads and show
310
+ basis. This launch is required whether filters are chosen or skipped. If the
311
+ user chooses filters, keep filter/rubric work in the parent thread: show
312
+ Filter Rules, load `references/filter-leads.md`, save rubrics, then ask for
313
+ filter approval. After approval, move to Filter Leads and show
313
314
  `Filters saved + waiting for message approval` while the message
314
- recommendation is reviewed. If filters are skipped, move to Messages/message
315
- review. Enrichment/filtering and Generate Message cells wait for message
316
- approval.
315
+ recommendation is reviewed. If filters are skipped, start Message Drafting
316
+ first, then move to Messages/message review; `currentStep=messages` is not
317
+ proof of worker kickoff. Enrichment/filtering and Generate Message cells wait
318
+ for message approval.
317
319
  - Source scouts and Prospect Filters are not normal create-campaign background
318
320
  agents. Only Message Drafting may spawn as a background/custom agent on the
319
321
  normal path; if it cannot be launched and the user does not approve inline
@@ -9,6 +9,14 @@ type ReachSignals = {
9
9
  reachAdjustedScore: number;
10
10
  confidence: "high" | "medium" | "low";
11
11
  };
12
+ type EngagementPostMedia = {
13
+ imageUrls: string[];
14
+ videoThumbnailUrl?: string;
15
+ videoUrl?: string;
16
+ articleImageUrl?: string;
17
+ articleUrl?: string;
18
+ mediaTypes: string[];
19
+ };
12
20
  export type EngagementPost = {
13
21
  postId: string;
14
22
  url: string;
@@ -27,6 +35,7 @@ export type EngagementPost = {
27
35
  total: number;
28
36
  };
29
37
  reachSignals?: ReachSignals;
38
+ media?: EngagementPostMedia;
30
39
  contentPreview: string;
31
40
  };
32
41
  export type SearchEngagementPostsInput = {
@@ -2,7 +2,7 @@ import { getApi } from "../api.js";
2
2
  export const engageDiscoveryToolDefinitions = [
3
3
  {
4
4
  name: "search_engagement_posts",
5
- description: "Search for high-signal LinkedIn posts by keyword for engagement/comment drafting. Designed for the engage skill (no campaignOfferId required). Filters by recency and engagement, and can exclude already-engaged URLs.",
5
+ description: "Search for high-signal LinkedIn posts by keyword for engagement/comment drafting. Designed for the engage skill (no campaignOfferId required). Filters by recency and engagement, can exclude already-engaged URLs, and returns source media hints when the scraper provides images, video covers, or article images.",
6
6
  inputSchema: {
7
7
  type: "object",
8
8
  properties: {
@@ -74,6 +74,50 @@ function safeNumber(value) {
74
74
  function round3(value) {
75
75
  return Number(value.toFixed(3));
76
76
  }
77
+ function normalizeMedia(raw) {
78
+ if (!raw || typeof raw !== "object")
79
+ return undefined;
80
+ const imageUrls = Array.isArray(raw.imageUrls)
81
+ ? raw.imageUrls
82
+ .map((url) => (typeof url === "string" ? url.trim() : ""))
83
+ .filter(Boolean)
84
+ : [];
85
+ const videoThumbnailUrl = typeof raw.videoThumbnailUrl === "string" && raw.videoThumbnailUrl.trim()
86
+ ? raw.videoThumbnailUrl.trim()
87
+ : undefined;
88
+ const videoUrl = typeof raw.videoUrl === "string" && raw.videoUrl.trim()
89
+ ? raw.videoUrl.trim()
90
+ : undefined;
91
+ const articleImageUrl = typeof raw.articleImageUrl === "string" && raw.articleImageUrl.trim()
92
+ ? raw.articleImageUrl.trim()
93
+ : undefined;
94
+ const articleUrl = typeof raw.articleUrl === "string" && raw.articleUrl.trim()
95
+ ? raw.articleUrl.trim()
96
+ : undefined;
97
+ const mediaTypes = Array.from(new Set([
98
+ ...(Array.isArray(raw.mediaTypes)
99
+ ? raw.mediaTypes.map((type) => typeof type === "string" ? type.trim() : "")
100
+ : []),
101
+ imageUrls.length > 0 ? "image" : "",
102
+ videoThumbnailUrl || videoUrl ? "video" : "",
103
+ articleImageUrl || articleUrl ? "article" : "",
104
+ ].filter(Boolean)));
105
+ if (imageUrls.length === 0 &&
106
+ !videoThumbnailUrl &&
107
+ !videoUrl &&
108
+ !articleImageUrl &&
109
+ !articleUrl) {
110
+ return undefined;
111
+ }
112
+ return {
113
+ imageUrls,
114
+ ...(videoThumbnailUrl ? { videoThumbnailUrl } : {}),
115
+ ...(videoUrl ? { videoUrl } : {}),
116
+ ...(articleImageUrl ? { articleImageUrl } : {}),
117
+ ...(articleUrl ? { articleUrl } : {}),
118
+ mediaTypes,
119
+ };
120
+ }
77
121
  function parseFollowerCount(author) {
78
122
  const direct = safeNumber(author?.followerCount);
79
123
  if (direct > 0)
@@ -218,6 +262,7 @@ export async function searchEngagementPosts(input) {
218
262
  targetFollowerMin,
219
263
  targetFollowerMax,
220
264
  });
265
+ const media = normalizeMedia(p?.media);
221
266
  kept.push({
222
267
  postId: String(p?.id || ""),
223
268
  url,
@@ -233,6 +278,7 @@ export async function searchEngagementPosts(input) {
233
278
  },
234
279
  engagement: { likes, comments, shares, total },
235
280
  ...(reachSignals ? { reachSignals } : {}),
281
+ ...(media ? { media } : {}),
236
282
  contentPreview: previewText(String(p?.content || ""), 220),
237
283
  });
238
284
  }
@@ -5,6 +5,14 @@ type SignalPostForImportSelection = {
5
5
  likes: number;
6
6
  comments: number;
7
7
  };
8
+ type SignalPostMedia = {
9
+ imageUrls: string[];
10
+ videoThumbnailUrl?: string;
11
+ videoUrl?: string;
12
+ articleImageUrl?: string;
13
+ articleUrl?: string;
14
+ mediaTypes: string[];
15
+ };
8
16
  export declare function selectSignalPostsForImport<T extends SignalPostForImportSelection>(posts: T[], options: {
9
17
  targetEngagerCount?: number;
10
18
  maxPostsToScrape?: number;
@@ -4406,6 +4414,7 @@ export declare function searchSignals(input: SignalSearchInput): Promise<{
4406
4414
  selectionTarget: number;
4407
4415
  recommendedPostIds: string[];
4408
4416
  topPosts: {
4417
+ media?: SignalPostMedia | undefined;
4409
4418
  id: string;
4410
4419
  url: string | undefined;
4411
4420
  matchedKeyword: string | null;
@@ -3,8 +3,8 @@ import { dirname, join, resolve } from "path";
3
3
  import { getApi, SellableApiError } from "../api.js";
4
4
  import { resolveSkillsDir } from "../skills.js";
5
5
  import { resolveWorkspaceRoot } from "../utils/workspace-root.js";
6
- import { buildCsvDomainPreview, matchesConfirmationToken, parseConfirmationToken, projectCsvCarryRows, } from "./csv-domains.js";
7
6
  import { listDncEntries, loadCsvDncEntries, } from "./csv-dnc.js";
7
+ import { buildCsvDomainPreview, matchesConfirmationToken, parseConfirmationToken, projectCsvCarryRows, } from "./csv-domains.js";
8
8
  import { buildCsvLinkedinPreview, matchesLinkedinConfirmationToken, parseLinkedinConfirmationToken, uploadCsvLinkedinFile, } from "./csv-linkedin.js";
9
9
  import { assertInteractionApproval } from "./interaction-mode.js";
10
10
  import { assertProviderPromptLoaded, markProviderPromptLoaded, } from "./provider-preflight.js";
@@ -727,6 +727,52 @@ function truncate(text, max = 220) {
727
727
  return clean;
728
728
  return `${clean.slice(0, max - 1)}...`;
729
729
  }
730
+ function normalizeSignalPostMedia(raw) {
731
+ if (!raw || typeof raw !== "object")
732
+ return undefined;
733
+ const media = raw;
734
+ const imageUrls = Array.isArray(media.imageUrls)
735
+ ? media.imageUrls
736
+ .map((url) => (typeof url === "string" ? url.trim() : ""))
737
+ .filter(Boolean)
738
+ : [];
739
+ const videoThumbnailUrl = typeof media.videoThumbnailUrl === "string" &&
740
+ media.videoThumbnailUrl.trim()
741
+ ? media.videoThumbnailUrl.trim()
742
+ : undefined;
743
+ const videoUrl = typeof media.videoUrl === "string" && media.videoUrl.trim()
744
+ ? media.videoUrl.trim()
745
+ : undefined;
746
+ const articleImageUrl = typeof media.articleImageUrl === "string" && media.articleImageUrl.trim()
747
+ ? media.articleImageUrl.trim()
748
+ : undefined;
749
+ const articleUrl = typeof media.articleUrl === "string" && media.articleUrl.trim()
750
+ ? media.articleUrl.trim()
751
+ : undefined;
752
+ const mediaTypes = Array.from(new Set([
753
+ ...(Array.isArray(media.mediaTypes)
754
+ ? media.mediaTypes.map((type) => typeof type === "string" ? type.trim() : "")
755
+ : []),
756
+ imageUrls.length > 0 ? "image" : "",
757
+ videoThumbnailUrl || videoUrl ? "video" : "",
758
+ articleImageUrl || articleUrl ? "article" : "",
759
+ ].filter(Boolean)));
760
+ if (imageUrls.length === 0 &&
761
+ !videoThumbnailUrl &&
762
+ !videoUrl &&
763
+ !articleImageUrl &&
764
+ !articleUrl) {
765
+ return undefined;
766
+ }
767
+ return {
768
+ imageUrls,
769
+ ...(videoThumbnailUrl ? { videoThumbnailUrl } : {}),
770
+ ...(videoUrl ? { videoUrl } : {}),
771
+ ...(articleImageUrl ? { articleImageUrl } : {}),
772
+ ...(articleUrl ? { articleUrl } : {}),
773
+ mediaTypes,
774
+ };
775
+ }
730
776
  function normalizePostUrl(url) {
731
777
  if (!url)
732
778
  return null;
@@ -764,6 +810,7 @@ function summarizeSignalPost(post) {
764
810
  const likes = post.engagement?.likes ?? 0;
765
811
  const comments = post.engagement?.comments ?? 0;
766
812
  const shares = post.engagement?.shares ?? 0;
813
+ const media = normalizeSignalPostMedia(post.media);
767
814
  return {
768
815
  id: post.id,
769
816
  url: post.url,
@@ -784,6 +831,7 @@ function summarizeSignalPost(post) {
784
831
  },
785
832
  score: Number(post._score.toFixed(2)),
786
833
  excerpt: truncate(post.content),
834
+ ...(media ? { media } : {}),
787
835
  };
788
836
  }
789
837
  function summarizeSignalSearchResponse(response) {
@@ -2697,9 +2745,7 @@ function normalizeMcpCompanyIcp(filters) {
2697
2745
  if (!isPlainObject(icp)) {
2698
2746
  return;
2699
2747
  }
2700
- const scope = typeof icp.geographic_scope === "string"
2701
- ? icp.geographic_scope.trim()
2702
- : "";
2748
+ const scope = typeof icp.geographic_scope === "string" ? icp.geographic_scope.trim() : "";
2703
2749
  const scopeMarkets = expandMcpCompanyIcpMarket(scope);
2704
2750
  if (scopeMarkets.length > 0) {
2705
2751
  icp.geographic_scope = "multi_country";
@@ -2708,9 +2754,7 @@ function normalizeMcpCompanyIcp(filters) {
2708
2754
  ...normalizeMcpCompanyIcpMarkets(icp.geographic_markets),
2709
2755
  ]);
2710
2756
  }
2711
- else if (scope &&
2712
- scope !== "single_country" &&
2713
- scope !== "multi_country") {
2757
+ else if (scope && scope !== "single_country" && scope !== "multi_country") {
2714
2758
  delete icp.geographic_scope;
2715
2759
  }
2716
2760
  if (icp.geographic_markets !== undefined) {
@@ -2791,8 +2835,7 @@ function normalizeMcpSeedMatchAll(filters, concreteSeedCount, omittedFilters = [
2791
2835
  if (!isPlainObject(filters.company_lookalike)) {
2792
2836
  return;
2793
2837
  }
2794
- if (filters.company_lookalike.match_all === true &&
2795
- concreteSeedCount < 2) {
2838
+ if (filters.company_lookalike.match_all === true && concreteSeedCount < 2) {
2796
2839
  omittedFilters.push({
2797
2840
  field: "company_lookalike.match_all",
2798
2841
  reason: "Dropped match_all because fewer than two concrete approved lookalike seeds remained after MCP seed normalization.",
@@ -2900,7 +2943,9 @@ function normalizeStringArray(input) {
2900
2943
  .filter((value) => value.length > 0);
2901
2944
  }
2902
2945
  function normalizeMcpSeeds(input, kind) {
2903
- return uniqueStrings(normalizeStringArray(input).filter((seed) => kind === "domain" ? isLikelyConcreteDomain(seed) : isLikelyConcreteSeedCompany(seed)));
2946
+ return uniqueStrings(normalizeStringArray(input).filter((seed) => kind === "domain"
2947
+ ? isLikelyConcreteDomain(seed)
2948
+ : isLikelyConcreteSeedCompany(seed)));
2904
2949
  }
2905
2950
  function isLikelyConcreteDomain(input) {
2906
2951
  return /^[a-z0-9.-]+\.[a-z]{2,}$/i.test(input);
@@ -3111,13 +3156,7 @@ function buildProspeoPeopleSearchFallbackInput(input, error) {
3111
3156
  const fallbackFilters = {
3112
3157
  person_name_or_job_title: keyword,
3113
3158
  person_seniority: {
3114
- include: [
3115
- "C-Suite",
3116
- "Vice President",
3117
- "Head",
3118
- "Director",
3119
- "Manager",
3120
- ],
3159
+ include: ["C-Suite", "Vice President", "Head", "Director", "Manager"],
3121
3160
  },
3122
3161
  max_person_per_company: typeof filters.max_person_per_company === "number"
3123
3162
  ? filters.max_person_per_company
@@ -185,7 +185,15 @@ interface RawLinkedInPost {
185
185
  authorPublicIdentifier?: string;
186
186
  };
187
187
  text?: string;
188
- content?: string;
188
+ content?: string | {
189
+ images?: unknown;
190
+ article?: unknown;
191
+ video?: unknown;
192
+ };
193
+ media?: unknown;
194
+ postImages?: unknown;
195
+ postVideo?: unknown;
196
+ article?: unknown;
189
197
  activityDate?: string;
190
198
  postedAt?: string | {
191
199
  date?: string;
@@ -219,6 +227,15 @@ interface SerializedPost {
219
227
  comments: number;
220
228
  url: string;
221
229
  isRepost: boolean;
230
+ media?: SerializedPostMedia;
231
+ }
232
+ interface SerializedPostMedia {
233
+ imageUrls: string[];
234
+ videoThumbnailUrl?: string;
235
+ videoUrl?: string;
236
+ articleImageUrl?: string;
237
+ articleUrl?: string;
238
+ mediaTypes: string[];
222
239
  }
223
240
  export declare function serializeLinkedInPosts(rawPosts: RawLinkedInPost[] | undefined, context: string): SerializedPost[];
224
241
  export declare function fetchLinkedInPosts(linkedinUrl: string, limit?: number): Promise<{
@@ -157,14 +157,105 @@ function normalizePostUrl(post) {
157
157
  post.header?.linkedinUrl ||
158
158
  "");
159
159
  }
160
+ function collectImageUrls(value, urls = new Set()) {
161
+ if (!value)
162
+ return urls;
163
+ if (typeof value === "string" && /^https?:\/\//i.test(value)) {
164
+ urls.add(value);
165
+ return urls;
166
+ }
167
+ if (Array.isArray(value)) {
168
+ for (const item of value)
169
+ collectImageUrls(item, urls);
170
+ return urls;
171
+ }
172
+ if (typeof value !== "object")
173
+ return urls;
174
+ const objectValue = value;
175
+ for (const key of ["url", "imageUrl", "thumbnailUrl", "thumbnail_url"]) {
176
+ const candidate = objectValue[key];
177
+ if (typeof candidate === "string" && /^https?:\/\//i.test(candidate)) {
178
+ urls.add(candidate);
179
+ }
180
+ }
181
+ if (objectValue.image)
182
+ collectImageUrls(objectValue.image, urls);
183
+ if (objectValue.images)
184
+ collectImageUrls(objectValue.images, urls);
185
+ return urls;
186
+ }
187
+ function pickString(value) {
188
+ return typeof value === "string" && value.trim() ? value.trim() : undefined;
189
+ }
190
+ function serializePostMedia(post) {
191
+ const media = post.media && typeof post.media === "object"
192
+ ? post.media
193
+ : {};
194
+ const content = post.content && typeof post.content === "object" ? post.content : {};
195
+ const article = post.article && typeof post.article === "object"
196
+ ? post.article
197
+ : content.article && typeof content.article === "object"
198
+ ? content.article
199
+ : {};
200
+ const video = post.postVideo && typeof post.postVideo === "object"
201
+ ? post.postVideo
202
+ : content.video && typeof content.video === "object"
203
+ ? content.video
204
+ : {};
205
+ const imageUrls = Array.from(collectImageUrls([
206
+ media.imageUrls,
207
+ post.postImages,
208
+ content.images,
209
+ article.image,
210
+ ]));
211
+ const videoThumbnailUrl = pickString(media.videoThumbnailUrl) ||
212
+ pickString(video.thumbnailUrl) ||
213
+ pickString(video.thumbnail_url) ||
214
+ pickString(video.thumbnail);
215
+ const videoUrl = pickString(media.videoUrl) ||
216
+ pickString(video.videoUrl) ||
217
+ pickString(video.video_url);
218
+ const articleImageUrl = pickString(media.articleImageUrl) ||
219
+ Array.from(collectImageUrls(article.image))[0];
220
+ const articleUrl = pickString(media.articleUrl) ||
221
+ pickString(article.link) ||
222
+ pickString(article.article_url) ||
223
+ pickString(article.articleUrl) ||
224
+ pickString(article.url);
225
+ const mediaTypes = Array.from(new Set([
226
+ ...(Array.isArray(media.mediaTypes)
227
+ ? media.mediaTypes.map((type) => typeof type === "string" ? type.trim() : "")
228
+ : []),
229
+ imageUrls.length > 0 ? "image" : "",
230
+ videoThumbnailUrl || videoUrl ? "video" : "",
231
+ articleImageUrl || articleUrl ? "article" : "",
232
+ ].filter(Boolean)));
233
+ if (imageUrls.length === 0 &&
234
+ !videoThumbnailUrl &&
235
+ !videoUrl &&
236
+ !articleImageUrl &&
237
+ !articleUrl) {
238
+ return undefined;
239
+ }
240
+ return {
241
+ imageUrls,
242
+ ...(videoThumbnailUrl ? { videoThumbnailUrl } : {}),
243
+ ...(videoUrl ? { videoUrl } : {}),
244
+ ...(articleImageUrl ? { articleImageUrl } : {}),
245
+ ...(articleUrl ? { articleUrl } : {}),
246
+ mediaTypes,
247
+ };
248
+ }
160
249
  function serializeLinkedInPost(post) {
250
+ const media = serializePostMedia(post);
161
251
  return {
162
- text: post.text || post.content || "",
252
+ text: post.text || (typeof post.content === "string" ? post.content : "") || "",
163
253
  date: normalizePostDate(post),
164
254
  reactions: post.reactionsCount ?? post.engagement?.likes ?? 0,
165
255
  comments: post.commentsCount ?? post.engagement?.comments ?? 0,
166
256
  url: normalizePostUrl(post),
167
257
  isRepost: Boolean(post.isRepublishedPost || post.repostedBy || post.repostedAt),
258
+ ...(media ? { media } : {}),
168
259
  };
169
260
  }
170
261
  function isUsableSerializedPost(post) {
@@ -363,9 +363,9 @@ export function getPostFindLeadsScoutRegistry() {
363
363
  reusePolicy: "The first completed Message Drafting recommendation remains the default review candidate. Later Lead Fit Builder, Filter Leads, enrichment, or rubric completion may make an enriched rewrite available, but does not automatically retry or replace the initial draft unless campaign/brief/source/list/table/execution-slice identity mismatches or the initial output failed. If filters were chosen but leadScoringRubrics are not yet visible when the branch reads campaign state, Message Drafting must not wait, retry, or return blocked; missing saved rubrics are parent-owned filter setup, and the branch should return status ready with basisStatus usable_initial when campaign/list/table identity and the non-empty execution slice match. User copy feedback before approve-message is an explicit Message Drafting revision and must be routed back through the message branch with the current recommendation and basis.",
364
364
  },
365
365
  usage: {
366
- 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 whenever Codex agent-launch policy is satisfied. 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 or saving rubrics. 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 after Message Drafting is ready. Treat YOLO/autonomous mode as campaign-scoped permission for this single post-import worker; do not ask for another permission click in YOLO. If the user has not enabled YOLO and has not explicitly asked for background agents/subagents/parallel agents/delegation/message bg agent in this campaign, ask once before loading the long message prompt in the parent. If permission is granted and 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. If no background-agent tool is callable, start the same full message branch inline before filter drafting, or return blocked/retry-needed; do not wait until filters are saved and then call the registry.",
366
+ 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 whenever Codex agent-launch policy is satisfied. 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. Treat YOLO/autonomous mode as campaign-scoped permission for this single post-import worker; do not ask for another permission click in YOLO. If the user has not enabled YOLO and has not explicitly asked for background agents/subagents/parallel agents/delegation/message bg agent in this campaign, ask once before loading the long message prompt in the parent. If permission is granted and 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. If no background-agent tool is callable, start the same full message branch inline before filter drafting or before skip-filter message review, or return blocked/retry-needed; do not wait until filters are saved and then call the registry.",
367
367
  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.",
368
- parentThreadRule: 'Named agents are optional acceleration, but message drafting is not optional. The only normal background worker is Message Drafting. YOLO/autonomous mode counts as campaign-scoped permission for this single post-import worker; do not ask for another permission click in YOLO. If a named agent is unavailable after permission, 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, or filter approval. If post-find-leads-message-scout is absent, do not customer-surface install status. Do not silently fall back to parent-thread message drafting; the main thread must execute the same message branch from CampaignOffer state, selected source state, workflowTableId, and initial campaign-table execution slice rows. If no background-agent tool is callable, start that same full message branch inline before filter drafting, or 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 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 the campaign/list/table and 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; only then move to Filter Leads, show `Filters saved + waiting for message approval`, and 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 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.',
368
+ parentThreadRule: 'Named agents are optional acceleration, but message drafting is not optional. The only normal background worker is Message Drafting. YOLO/autonomous mode counts as campaign-scoped permission for this single post-import worker; do not ask for another permission click in YOLO. If a named agent is unavailable after permission, 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 fall back to parent-thread message drafting; the main thread must execute the same message branch from CampaignOffer state, selected source state, workflowTableId, and initial campaign-table execution slice rows. If no background-agent tool is callable, start that same full message branch inline before filter drafting or before skip-filter message review, or 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 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 the campaign/list/table and 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; only then move to Filter Leads, show `Filters saved + waiting for message approval`, and 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.',
369
369
  prepareMessagesRule: 'Default create-campaign stays on the existing reviewBatchLimit:15 first campaign-table execution slice. Only call start_campaign_message_preparation when the user explicitly asks for more prepared messages or a send count. For "prepare/generate X messages", set targetPreparedMessages:X, omit maxRowsToCheck so the backend calibrates on at least 100 rows, estimates the row budget from observed rubric/pass yield, caps maxRowsToCheck at 2500, and use approvalMode:mark_ready. After the calibration sample settles, the backend adapts later batches up to 250 rows while recalculating yield. Poll get_campaign_message_preparation_status and summarize preparation-job status: checked rows, passed/prepared/approved count, target, estimated row budget remaining, and stop reason. For "approve X messages", use approvalMode:approve but still do not launch. For "schedule X sends", use approvalMode:approve to approve exactly the bounded X-message cohort during preparation, then continue through sender, sequence, and final launch greenlight; final launch must verify that bounded 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, call cancel_campaign_message_preparation; otherwise do not cancel a healthy prepare run. cancel_campaign_message_preparation cancels the same pending workflow-table cells as the UI Cancel Pending Cells action. Low-level selectors are diagnostics and recovery only for this lane. start_campaign remains forbidden until final launch greenlight.',
370
370
  },
371
371
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sellable/mcp",
3
- "version": "0.1.292",
3
+ "version": "0.1.294",
4
4
  "type": "module",
5
5
  "description": "Sellable MCP server for Claude Code and Codex campaign workflows",
6
6
  "main": "dist/index.js",
@@ -427,12 +427,15 @@ After confirmed source rows exist in the campaign table, do not load the
427
427
  message registry or any deep filter/message prompt
428
428
  before the filter-choice question. After `confirm_lead_list`, ask add filters
429
429
  vs skip filters immediately. Once the user answers, launch only Message Drafting
430
- from the same campaign/table basis. If the user chooses filters, the parent
430
+ from the same campaign/table basis. This kickoff is required for both answers:
431
+ `Use filters` and `Skip filters`. If the user chooses filters, the parent
431
432
  thread moves to Filter Rules, loads the filter reference, saves rubrics, then
432
433
  asks for filter approval while Message Drafting runs. After approval, move to
433
434
  Filter Leads and show `Filters saved + waiting for message approval` while the
434
- message recommendation is reviewed. If the user skips filters, move to
435
- Messages/message review. Enrichment/filtering and Generate Message cells wait
435
+ message recommendation is reviewed. If the user skips filters, start Message
436
+ Drafting first, then move to Messages/message review after it has started or
437
+ returned a ready recommendation. `update_campaign({ currentStep: "messages" })`
438
+ is not proof of kickoff. Enrichment/filtering and Generate Message cells wait
436
439
  for message approval. AI Generated is an explicit opt-out from the template
437
440
  path.
438
441
 
@@ -915,11 +918,12 @@ updates.
915
918
  3. Follow that prompt and workflow config exactly.
916
919
  4. For filter and message setup, keep the parent thread as a lean orchestrator.
917
920
  The only normal background agent is `post-find-leads-message-scout` for
918
- Message Drafting. When filters are chosen, launch Message Drafting, then keep
919
- filters in the parent thread: load `references/filter-leads.md`, draft
920
- production rubrics, call `save_rubrics`, ask filter approval, and then join
921
- Message Drafting for template review. When filters are skipped, launch only
922
- Message Drafting.
921
+ Message Drafting. Both post-import choices must launch Message Drafting.
922
+ When filters are chosen, launch Message Drafting, then keep filters in the
923
+ parent thread: load `references/filter-leads.md`, draft production rubrics,
924
+ call `save_rubrics`, ask filter approval, and then join Message Drafting for
925
+ template review. When filters are skipped, launch only Message Drafting
926
+ before treating the campaign as in Messages/message review.
923
927
  5. For message generation, keep the parent thread as a lean orchestrator and
924
928
  use the `post-find-leads-message-scout` compatibility agent for Message
925
929
  Drafting whenever the host exposes it
@@ -968,10 +972,12 @@ updates.
968
972
  After rubrics save, keep Filter Rules visible for approval; after approval,
969
973
  move to Filter Leads and show `Filters saved + waiting for message approval`
970
974
  until the template is approved.
971
- If filters are skipped, move to Messages/message review. Queue the bounded
972
- campaign-table execution-slice `enrichCellId` cells only after message approval. Move to
973
- Messages only after at least one review row passes and one generated message
974
- is ready.
975
+ If filters are skipped, launch Message Drafting before moving to
976
+ Messages/message review; updating `currentStep` to `messages` is not proof
977
+ that the background worker started. Queue the bounded campaign-table
978
+ execution-slice `enrichCellId` cells only after message approval. Move to the
979
+ generated-row Messages review only after at least one review row passes and
980
+ one generated message is ready.
975
981
  Do not ask the user to approve the brief before shell creation unless they
976
982
  explicitly requested a no-write draft; the shell itself is the review surface.
977
983
  7. The main thread owns watch navigation. Call
@@ -293,11 +293,11 @@ customer-facing source-choice labels.
293
293
 
294
294
  ## Prospect Setup Workstreams
295
295
 
296
- After `confirm_lead_list` copies a non-empty source into the campaign and records the compact review batch, ask the filter-choice question immediately. Do not call `get_post_find_leads_scout_registry`, load filter/message prompts, or spawn Message Drafting before that question. Customer-facing work before the question: short setup summary plus add filters, skip filters, or revise source; no extra watch link.
296
+ After `confirm_lead_list` copies source rows and records the review batch, ask the filter-choice question immediately. Do not call `get_post_find_leads_scout_registry`, load filter/message prompts, or spawn Message Drafting before that question. Before the question: short setup summary plus add filters, skip filters, or revise source; no extra watch link.
297
297
 
298
- After filter choice, the only normal background worker is Message Drafting (`post-find-leads-message-scout`). The registry lookup is not a launch. Call the registry, then start Message Drafting via `Task`, `spawn_agent`, or host equivalent before loading `references/filter-leads.md` or `save_rubrics`. YOLO already grants permission; do not ask for another permission click. If no background tool is callable, start the same full branch inline before filter drafting or return `blocked` / `retry-needed`. Do not wait until filters are saved and then call the registry.
298
+ After filter choice, the only normal background worker is Message Drafting (`post-find-leads-message-scout`). The registry lookup is not a launch. Both choices must run this kickoff: call the registry, then start Message Drafting via `Task`, `spawn_agent`, or host equivalent before filter refs, `save_rubrics`, or skip review. YOLO already grants permission; do not ask for another permission click. If no background tool is callable, start the same full branch inline before filter drafting or skip review, or return `blocked` / `retry-needed`. `update_campaign({ currentStep: "messages" })` is not proof of kickoff.
299
299
 
300
- The parent thread is the orchestrator and the filter writer. On the filters path, start Message Drafting, then load `references/filter-leads.md`, save rubrics, and ask users to approve saved criteria. Keep `currentStep` on Filter Rules and show `Filters saved + waiting for message approval`; do not queue cells until message approval. Tell the user Message Drafting is preparing the template in the background.
300
+ The parent thread is the orchestrator and the filter writer. On the filters path, start Message Drafting, load `references/filter-leads.md`, save rubrics, and ask users to approve saved criteria. Keep `currentStep` on Filter Rules and show `Filters saved + waiting for message approval`; do not queue cells until message approval. Tell the user Message Drafting is preparing the template in the background.
301
301
 
302
302
  Message Drafting must not wait for `save_rubrics` or require visible
303
303
  `leadScoringRubrics` before returning a reusable template. The parent waits for
@@ -296,10 +296,12 @@ For prospect setup work, call `get_post_find_leads_scout_registry` after
296
296
  the user chooses filters, not before the filter-choice question. After
297
297
  `confirm_lead_list` copies source rows and records the first review/process
298
298
  sample, ask add-filters vs skip-filters immediately. After the answer, launch
299
- only Message Drafting (`post-find-leads-message-scout`). If the user chooses
300
- filters, the parent thread keeps the browser on Filter Rules, loads the filter
301
- reference, drafts/saves rubrics with MCP tools, and asks for filter approval
302
- while Message Drafting runs.
299
+ only Message Drafting (`post-find-leads-message-scout`). This applies to both
300
+ answers: the skip-filters path still routes through the Message Drafting
301
+ kickoff before it enters message review. `update_campaign` to Messages is not a
302
+ worker launch. If the user chooses filters, the parent thread keeps the browser
303
+ on Filter Rules, loads the filter reference, drafts/saves rubrics with MCP
304
+ tools, and asks for filter approval while Message Drafting runs.
303
305
 
304
306
  The parent thread is the orchestrator and the filter writer. On the filters path
305
307
  it must verify `save_rubrics`, keep the browser on Filter Rules, and ask for