@sellable/mcp 0.1.507 → 0.1.509
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/server.js +4 -1
- package/dist/tools/campaign-message-preparation.d.ts +26 -27
- package/dist/tools/campaign-message-preparation.js +27 -12
- package/dist/tools/campaigns.d.ts +54 -1
- package/dist/tools/campaigns.js +18 -3
- package/dist/tools/leads.d.ts +49 -0
- package/dist/tools/leads.js +138 -41
- package/dist/tools/prompts.js +1 -1
- package/dist/tools/refill-sends.d.ts +54 -79
- package/dist/tools/refill-sends.js +787 -171
- package/dist/tools/refill-target-plan.js +61 -8
- package/dist/tools/registry.d.ts +97 -84
- package/package.json +1 -1
- package/skills/refill-sends/SKILL.md +22 -11
- package/skills/refill-sends-workflow/SKILL.md +11 -6
package/dist/tools/leads.js
CHANGED
|
@@ -1259,7 +1259,7 @@ function serializeInvalidSignalPosts(posts) {
|
|
|
1259
1259
|
reason: post.reason,
|
|
1260
1260
|
}));
|
|
1261
1261
|
}
|
|
1262
|
-
async function validateSelectedSignalPostsForImport(api, posts) {
|
|
1262
|
+
async function validateSelectedSignalPostsForImport(api, posts, requestOptions) {
|
|
1263
1263
|
const results = await Promise.all(posts.map(async (post) => {
|
|
1264
1264
|
if (!post.url.trim()) {
|
|
1265
1265
|
return {
|
|
@@ -1269,10 +1269,15 @@ async function validateSelectedSignalPostsForImport(api, posts) {
|
|
|
1269
1269
|
};
|
|
1270
1270
|
}
|
|
1271
1271
|
try {
|
|
1272
|
-
const response =
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1272
|
+
const response = requestOptions
|
|
1273
|
+
? await api.post("/api/v1/signal-discovery/search-signals", {
|
|
1274
|
+
type: "post",
|
|
1275
|
+
postUrl: post.url,
|
|
1276
|
+
}, requestOptions)
|
|
1277
|
+
: await api.post("/api/v1/signal-discovery/search-signals", {
|
|
1278
|
+
type: "post",
|
|
1279
|
+
postUrl: post.url,
|
|
1280
|
+
});
|
|
1276
1281
|
const valid = response.success !== false &&
|
|
1277
1282
|
Array.isArray(response.posts) &&
|
|
1278
1283
|
response.posts.some(hasUsableSignalValidationPost);
|
|
@@ -2202,6 +2207,15 @@ export const leadToolDefinitions = [
|
|
|
2202
2207
|
type: "number",
|
|
2203
2208
|
description: "Number of campaign rows to use as the initial review/process sample. Defaults to 15.",
|
|
2204
2209
|
},
|
|
2210
|
+
sourceRowIds: {
|
|
2211
|
+
type: "array",
|
|
2212
|
+
items: { type: "string" },
|
|
2213
|
+
description: "Optional exact source WorkflowTableRow ids to copy from the selected source lead list. Use only for bounded refill same-source copy packets.",
|
|
2214
|
+
},
|
|
2215
|
+
sourceRowLimit: {
|
|
2216
|
+
type: "number",
|
|
2217
|
+
description: "Optional cap for copying the first N source rows. Prefer sourceRowIds when a refill packet provides exact ids.",
|
|
2218
|
+
},
|
|
2205
2219
|
allowPartialSourceList: {
|
|
2206
2220
|
type: "boolean",
|
|
2207
2221
|
description: "Explicit override for user-approved early continuation. Default false. When true, confirm_lead_list may copy the currently materialized rows from a still-running source import; use only after the user explicitly asks to keep going with the partial list.",
|
|
@@ -3624,6 +3638,8 @@ export async function searchSignals(input) {
|
|
|
3624
3638
|
campaignOfferId: input?.campaignOfferId,
|
|
3625
3639
|
});
|
|
3626
3640
|
const api = getApi();
|
|
3641
|
+
const workspaceId = normalizeExplicitWorkspaceId(input.workspaceId);
|
|
3642
|
+
const requestOptions = workspaceRequestOptions(workspaceId);
|
|
3627
3643
|
const { campaignOfferId, headlineICPCriteria, rubricGuidelines, currentStepTransition, } = input;
|
|
3628
3644
|
const searchRequest = { ...input };
|
|
3629
3645
|
delete searchRequest.currentStepTransition;
|
|
@@ -3633,37 +3649,62 @@ export async function searchSignals(input) {
|
|
|
3633
3649
|
const effectiveHeadlineICPCriteria = headlineICPCriteria && headlineICPCriteria.length > 0
|
|
3634
3650
|
? headlineICPCriteria
|
|
3635
3651
|
: rubricGuidelines;
|
|
3636
|
-
if (campaignOfferId) {
|
|
3637
|
-
|
|
3652
|
+
if (campaignOfferId && searchCurrentStep) {
|
|
3653
|
+
const body = {
|
|
3638
3654
|
leadSourceType: "new",
|
|
3639
3655
|
leadSourceProvider: "signal-discovery",
|
|
3640
|
-
|
|
3656
|
+
currentStep: searchCurrentStep,
|
|
3641
3657
|
...(currentStepTransition ? { currentStepTransition } : {}),
|
|
3642
3658
|
watchNarration: buildSignalDiscoverySearchWatchNarration(),
|
|
3643
|
-
|
|
3659
|
+
...(workspaceId ? { workspaceId } : {}),
|
|
3660
|
+
};
|
|
3661
|
+
if (requestOptions) {
|
|
3662
|
+
await api.put(`/api/v2/campaign-offers/${campaignOfferId}`, body, requestOptions);
|
|
3663
|
+
}
|
|
3664
|
+
else {
|
|
3665
|
+
await api.put(`/api/v2/campaign-offers/${campaignOfferId}`, body);
|
|
3666
|
+
}
|
|
3644
3667
|
}
|
|
3645
3668
|
// Persist criteria early so user take-over has filters ready.
|
|
3646
3669
|
if (campaignOfferId && effectiveHeadlineICPCriteria?.length) {
|
|
3647
|
-
|
|
3670
|
+
const body = {
|
|
3648
3671
|
selectedIds: [],
|
|
3649
3672
|
unselectedIds: [],
|
|
3650
3673
|
headlineICPCriteria: effectiveHeadlineICPCriteria,
|
|
3651
3674
|
rubricGuidelines: effectiveHeadlineICPCriteria,
|
|
3652
|
-
|
|
3675
|
+
...(workspaceId ? { workspaceId } : {}),
|
|
3676
|
+
};
|
|
3677
|
+
if (requestOptions) {
|
|
3678
|
+
await api.patch(`/api/v3/campaigns/${campaignOfferId}/signal-discovery/posts`, body, requestOptions);
|
|
3679
|
+
}
|
|
3680
|
+
else {
|
|
3681
|
+
await api.patch(`/api/v3/campaigns/${campaignOfferId}/signal-discovery/posts`, body);
|
|
3682
|
+
}
|
|
3653
3683
|
}
|
|
3654
|
-
const response =
|
|
3684
|
+
const response = requestOptions
|
|
3685
|
+
? await api.post(`/api/v1/signal-discovery/search-signals`, searchRequest, requestOptions)
|
|
3686
|
+
: await api.post(`/api/v1/signal-discovery/search-signals`, searchRequest);
|
|
3655
3687
|
const summary = summarizeSignalSearchResponse(response);
|
|
3656
|
-
if (campaignOfferId) {
|
|
3657
|
-
|
|
3658
|
-
|
|
3688
|
+
if (campaignOfferId && searchCurrentStep) {
|
|
3689
|
+
const body = {
|
|
3690
|
+
currentStep: searchCurrentStep,
|
|
3659
3691
|
...(currentStepTransition ? { currentStepTransition } : {}),
|
|
3660
3692
|
watchNarration: buildSignalDiscoveryResultsWatchNarration(summary.postsReturned),
|
|
3661
|
-
|
|
3693
|
+
...(workspaceId ? { workspaceId } : {}),
|
|
3694
|
+
};
|
|
3695
|
+
if (requestOptions) {
|
|
3696
|
+
await api.put(`/api/v2/campaign-offers/${campaignOfferId}`, body, requestOptions);
|
|
3697
|
+
}
|
|
3698
|
+
else {
|
|
3699
|
+
await api.put(`/api/v2/campaign-offers/${campaignOfferId}`, body);
|
|
3700
|
+
}
|
|
3662
3701
|
}
|
|
3663
3702
|
return summary;
|
|
3664
3703
|
}
|
|
3665
3704
|
export async function importLeads(input) {
|
|
3666
3705
|
const api = getApi();
|
|
3706
|
+
const workspaceId = normalizeExplicitWorkspaceId(input.workspaceId);
|
|
3707
|
+
const requestOptions = workspaceRequestOptions(workspaceId);
|
|
3667
3708
|
const { campaignOfferId, currentStep, sourceLeadListId: inputSourceLeadListId, searchId, targetLeadCount, mode, searchName, leadListName, headlineICPCriteria, targetEngagerCount, maxPostsToScrape, allowInvalidSignalPosts, rubricGuidelines, confirmed, } = input;
|
|
3668
3709
|
assertInteractionApproval({
|
|
3669
3710
|
campaignId: campaignOfferId,
|
|
@@ -3678,7 +3719,9 @@ export async function importLeads(input) {
|
|
|
3678
3719
|
let campaignSelectedLeadListId;
|
|
3679
3720
|
if (!provider || currentStep === undefined || mode === undefined) {
|
|
3680
3721
|
// Pull campaign once when we need provider or to determine default step behavior.
|
|
3681
|
-
const campaign =
|
|
3722
|
+
const campaign = requestOptions
|
|
3723
|
+
? await api.get(`/api/v2/campaign-offers/${campaignOfferId}`, requestOptions)
|
|
3724
|
+
: await api.get(`/api/v2/campaign-offers/${campaignOfferId}`);
|
|
3682
3725
|
if (!provider) {
|
|
3683
3726
|
provider = normalizeImportProvider(campaign.leadSourceProvider);
|
|
3684
3727
|
}
|
|
@@ -3800,7 +3843,9 @@ export async function importLeads(input) {
|
|
|
3800
3843
|
const effectiveTargetEngagerCount = normalizePositiveInteger(targetEngagerCount) ?? null;
|
|
3801
3844
|
// Get selected posts from the campaign's signal search tabs
|
|
3802
3845
|
// Note: API returns flat fields (postUrl, postContent, authorName, etc.)
|
|
3803
|
-
const tabsResponse =
|
|
3846
|
+
const tabsResponse = requestOptions
|
|
3847
|
+
? await api.get(`/api/v3/campaigns/${campaignOfferId}/signal-discovery/tabs`, requestOptions)
|
|
3848
|
+
: await api.get(`/api/v3/campaigns/${campaignOfferId}/signal-discovery/tabs`);
|
|
3804
3849
|
// Collect all selected posts, mapping from API format to signal-leads/create format
|
|
3805
3850
|
const selectedPosts = [];
|
|
3806
3851
|
for (const tab of tabsResponse.tabs || []) {
|
|
@@ -3855,7 +3900,7 @@ export async function importLeads(input) {
|
|
|
3855
3900
|
: " Select/promote more right-content posts, run another narrow Signal Discovery search, or switch to Sales Nav recent activity if the lane cannot produce enough source candidates.";
|
|
3856
3901
|
throw new Error(`Signal Discovery selected posts only cover about ${importSelection.estimatedEngagers.toLocaleString("en-US")} people to check, below the approved ${importSelection.targetEngagerCount.toLocaleString("en-US")} source-candidate target. Do not scrape this under-capacity post set.${capClause}`);
|
|
3857
3902
|
}
|
|
3858
|
-
const postValidation = await validateSelectedSignalPostsForImport(api, uniqueSelectedPosts);
|
|
3903
|
+
const postValidation = await validateSelectedSignalPostsForImport(api, uniqueSelectedPosts, requestOptions);
|
|
3859
3904
|
const plannedPostKeys = new Set(postsToScrape.map(signalImportPostKey));
|
|
3860
3905
|
const invalidPlannedPosts = postValidation.invalidPosts.filter((post) => plannedPostKeys.has(signalImportPostKey(post)));
|
|
3861
3906
|
const skippedInvalidPostWarning = postValidation.invalidPosts.length > 0
|
|
@@ -3926,7 +3971,7 @@ export async function importLeads(input) {
|
|
|
3926
3971
|
? headlineICPCriteria
|
|
3927
3972
|
: rubricGuidelines;
|
|
3928
3973
|
// Start the scrape job
|
|
3929
|
-
const
|
|
3974
|
+
const createBody = {
|
|
3930
3975
|
posts: postsToScrape,
|
|
3931
3976
|
targetEngagerCount: importSelection.targetEngagerCount ?? undefined,
|
|
3932
3977
|
...(effectiveHeadlineICPCriteria &&
|
|
@@ -3936,10 +3981,14 @@ export async function importLeads(input) {
|
|
|
3936
3981
|
rubricGuidelines: effectiveHeadlineICPCriteria,
|
|
3937
3982
|
}
|
|
3938
3983
|
: {}),
|
|
3939
|
-
|
|
3984
|
+
...(workspaceId ? { workspaceId } : {}),
|
|
3985
|
+
};
|
|
3986
|
+
const result = requestOptions
|
|
3987
|
+
? await api.post(`/api/v3/campaigns/${campaignOfferId}/signal-leads/create`, createBody, requestOptions)
|
|
3988
|
+
: await api.post(`/api/v3/campaigns/${campaignOfferId}/signal-leads/create`, createBody);
|
|
3940
3989
|
// CRITICAL: Update selectedLeadListId so UI subscribes to correct table
|
|
3941
3990
|
// This enables realtime updates in LeadListCanvas
|
|
3942
|
-
|
|
3991
|
+
const updateBody = {
|
|
3943
3992
|
selectedLeadListId: result.tableId,
|
|
3944
3993
|
...(shouldSetCurrentStep ? { currentStep: postImportCurrentStep } : {}),
|
|
3945
3994
|
...(shouldSetCurrentStep
|
|
@@ -3952,7 +4001,14 @@ export async function importLeads(input) {
|
|
|
3952
4001
|
}),
|
|
3953
4002
|
}
|
|
3954
4003
|
: {}),
|
|
3955
|
-
|
|
4004
|
+
...(workspaceId ? { workspaceId } : {}),
|
|
4005
|
+
};
|
|
4006
|
+
if (requestOptions) {
|
|
4007
|
+
await api.put(`/api/v2/campaign-offers/${campaignOfferId}`, updateBody, requestOptions);
|
|
4008
|
+
}
|
|
4009
|
+
else {
|
|
4010
|
+
await api.put(`/api/v2/campaign-offers/${campaignOfferId}`, updateBody);
|
|
4011
|
+
}
|
|
3956
4012
|
return {
|
|
3957
4013
|
provider: "signal-discovery",
|
|
3958
4014
|
leadListId: result.tableId,
|
|
@@ -3983,10 +4039,14 @@ export async function importLeads(input) {
|
|
|
3983
4039
|
const fallbackName = leadListName ||
|
|
3984
4040
|
(searchName ? `${providerLabel} - ${searchName}` : undefined) ||
|
|
3985
4041
|
`${providerLabel} Import ${new Date().toISOString().slice(0, 10)}`;
|
|
3986
|
-
const
|
|
4042
|
+
const createBody = {
|
|
3987
4043
|
name: fallbackName,
|
|
3988
4044
|
templateType: "lead_list",
|
|
3989
|
-
|
|
4045
|
+
...(workspaceId ? { workspaceId } : {}),
|
|
4046
|
+
};
|
|
4047
|
+
const createResult = requestOptions
|
|
4048
|
+
? await api.post(`/api/v3/lead-lists`, createBody, requestOptions)
|
|
4049
|
+
: await api.post(`/api/v3/lead-lists`, createBody);
|
|
3990
4050
|
leadListId = createResult.leadList?.id;
|
|
3991
4051
|
createdLeadList = createResult.leadList;
|
|
3992
4052
|
}
|
|
@@ -4000,21 +4060,29 @@ export async function importLeads(input) {
|
|
|
4000
4060
|
const startImport = async () => {
|
|
4001
4061
|
if (provider === "sales-nav") {
|
|
4002
4062
|
// Sales Nav export flow
|
|
4003
|
-
|
|
4063
|
+
const body = {
|
|
4004
4064
|
searchId,
|
|
4005
4065
|
workflowTableId: leadListId,
|
|
4006
4066
|
campaignOfferId,
|
|
4007
4067
|
targetLeadCount: cappedTargetLeadCount ?? defaultProviderSourceListTarget,
|
|
4008
4068
|
...(normalizedMode ? { mode: normalizedMode } : {}),
|
|
4009
|
-
|
|
4069
|
+
...(workspaceId ? { workspaceId } : {}),
|
|
4070
|
+
};
|
|
4071
|
+
return requestOptions
|
|
4072
|
+
? api.post(`/api/v3/sales-nav/export`, body, requestOptions)
|
|
4073
|
+
: api.post(`/api/v3/sales-nav/export`, body);
|
|
4010
4074
|
}
|
|
4011
4075
|
if (provider === "prospeo") {
|
|
4012
|
-
|
|
4076
|
+
const body = {
|
|
4013
4077
|
searchId,
|
|
4014
4078
|
campaignOfferId,
|
|
4015
4079
|
targetLeadCount: cappedTargetLeadCount ?? defaultProviderSourceListTarget,
|
|
4016
4080
|
...(normalizedMode ? { mode: normalizedMode } : {}),
|
|
4017
|
-
|
|
4081
|
+
...(workspaceId ? { workspaceId } : {}),
|
|
4082
|
+
};
|
|
4083
|
+
return requestOptions
|
|
4084
|
+
? api.post(`/api/v3/lead-lists/${leadListId}/prospeo-import/start`, body, requestOptions)
|
|
4085
|
+
: api.post(`/api/v3/lead-lists/${leadListId}/prospeo-import/start`, body);
|
|
4018
4086
|
}
|
|
4019
4087
|
throw new Error(`Unsupported import provider ${provider}. Choose sales-nav, prospeo, or signal-discovery.`);
|
|
4020
4088
|
};
|
|
@@ -4062,7 +4130,7 @@ export async function importLeads(input) {
|
|
|
4062
4130
|
}
|
|
4063
4131
|
// Update selectedLeadListId so UI subscribes to the source lead list
|
|
4064
4132
|
// This enables realtime updates while the import job runs.
|
|
4065
|
-
|
|
4133
|
+
const updateBody = {
|
|
4066
4134
|
selectedLeadListId: leadListId,
|
|
4067
4135
|
...(shouldSetCurrentStep ? { currentStep: effectiveCurrentStep } : {}),
|
|
4068
4136
|
...(shouldSetCurrentStep
|
|
@@ -4073,7 +4141,14 @@ export async function importLeads(input) {
|
|
|
4073
4141
|
}),
|
|
4074
4142
|
}
|
|
4075
4143
|
: {}),
|
|
4076
|
-
|
|
4144
|
+
...(workspaceId ? { workspaceId } : {}),
|
|
4145
|
+
};
|
|
4146
|
+
if (requestOptions) {
|
|
4147
|
+
await api.put(`/api/v2/campaign-offers/${campaignOfferId}`, updateBody, requestOptions);
|
|
4148
|
+
}
|
|
4149
|
+
else {
|
|
4150
|
+
await api.put(`/api/v2/campaign-offers/${campaignOfferId}`, updateBody);
|
|
4151
|
+
}
|
|
4077
4152
|
return {
|
|
4078
4153
|
provider,
|
|
4079
4154
|
leadListId,
|
|
@@ -4130,7 +4205,7 @@ export async function confirmLeadList(input) {
|
|
|
4130
4205
|
const api = getApi();
|
|
4131
4206
|
const workspaceId = normalizeExplicitWorkspaceId(input.workspaceId);
|
|
4132
4207
|
const requestOptions = workspaceRequestOptions(workspaceId);
|
|
4133
|
-
const { campaignOfferId, currentStep, confirmed, sourceLeadListId, campaignName, keepInSync, jobId, reviewBatchLimit, includeRawImportResult, allowPartialSourceList, targetLeadCount, } = input;
|
|
4208
|
+
const { campaignOfferId, currentStep, confirmed, sourceLeadListId, campaignName, keepInSync, jobId, reviewBatchLimit, includeRawImportResult, allowPartialSourceList, targetLeadCount, sourceRowIds, sourceRowLimit, } = input;
|
|
4134
4209
|
assertInteractionApproval({
|
|
4135
4210
|
campaignId: campaignOfferId,
|
|
4136
4211
|
action: "confirm-lead-list",
|
|
@@ -4336,6 +4411,8 @@ export async function confirmLeadList(input) {
|
|
|
4336
4411
|
campaignName,
|
|
4337
4412
|
keepInSync,
|
|
4338
4413
|
currentStep: null,
|
|
4414
|
+
sourceRowIds,
|
|
4415
|
+
sourceRowLimit,
|
|
4339
4416
|
...(workspaceId ? { workspaceId } : {}),
|
|
4340
4417
|
};
|
|
4341
4418
|
const importResult = await (requestOptions
|
|
@@ -4571,7 +4648,9 @@ export function getProviderPrompt(input) {
|
|
|
4571
4648
|
}
|
|
4572
4649
|
export async function selectPromisingPosts(input) {
|
|
4573
4650
|
const api = getApi();
|
|
4574
|
-
const
|
|
4651
|
+
const workspaceId = normalizeExplicitWorkspaceId(input.workspaceId);
|
|
4652
|
+
const requestOptions = workspaceRequestOptions(workspaceId);
|
|
4653
|
+
const { campaignOfferId, selections, headlineICPCriteria, currentStep, selectionMode, mode, scrapePlanMode, targetEngagerCount, maxPostsToScrape, } = input;
|
|
4575
4654
|
const effectiveMode = selectionMode ?? mode ?? "replace";
|
|
4576
4655
|
const effectiveScrapePlanMode = scrapePlanMode ??
|
|
4577
4656
|
(targetEngagerCount || maxPostsToScrape
|
|
@@ -4590,19 +4669,25 @@ export async function selectPromisingPosts(input) {
|
|
|
4590
4669
|
const postIds = selections.map((s) => s.postId);
|
|
4591
4670
|
let unselectedIds = [];
|
|
4592
4671
|
if (effectiveMode === "replace") {
|
|
4593
|
-
const existing =
|
|
4672
|
+
const existing = requestOptions
|
|
4673
|
+
? await api.get(`/api/v3/campaigns/${campaignOfferId}/signal-discovery/posts?selected=true`, requestOptions)
|
|
4674
|
+
: await api.get(`/api/v3/campaigns/${campaignOfferId}/signal-discovery/posts?selected=true`);
|
|
4594
4675
|
const existingIds = existing?.posts
|
|
4595
4676
|
?.map((post) => post.id)
|
|
4596
4677
|
.filter((id) => Boolean(id)) ?? [];
|
|
4597
4678
|
const selectedSet = new Set(postIds);
|
|
4598
4679
|
unselectedIds = existingIds.filter((id) => !selectedSet.has(id));
|
|
4599
4680
|
}
|
|
4600
|
-
const
|
|
4681
|
+
const selectionBody = {
|
|
4601
4682
|
selectedIds: postIds,
|
|
4602
4683
|
unselectedIds,
|
|
4603
4684
|
headlineICPCriteria,
|
|
4604
4685
|
rubricGuidelines: headlineICPCriteria,
|
|
4605
|
-
|
|
4686
|
+
...(workspaceId ? { workspaceId } : {}),
|
|
4687
|
+
};
|
|
4688
|
+
const selectionResult = requestOptions
|
|
4689
|
+
? await api.patch(`/api/v3/campaigns/${campaignOfferId}/signal-discovery/posts`, selectionBody, requestOptions)
|
|
4690
|
+
: await api.patch(`/api/v3/campaigns/${campaignOfferId}/signal-discovery/posts`, selectionBody);
|
|
4606
4691
|
if (selectionResult.selectedCount <= 0) {
|
|
4607
4692
|
return {
|
|
4608
4693
|
success: false,
|
|
@@ -4616,7 +4701,9 @@ export async function selectPromisingPosts(input) {
|
|
|
4616
4701
|
let recommendedPostCount = selectionResult.selectedCount;
|
|
4617
4702
|
let recommendationTargetEngagerCount = null;
|
|
4618
4703
|
try {
|
|
4619
|
-
const tabsResponse =
|
|
4704
|
+
const tabsResponse = requestOptions
|
|
4705
|
+
? await api.get(`/api/v3/campaigns/${campaignOfferId}/signal-discovery/tabs`, requestOptions)
|
|
4706
|
+
: await api.get(`/api/v3/campaigns/${campaignOfferId}/signal-discovery/tabs`);
|
|
4620
4707
|
const reasonsByPostId = new Map(selections.map((selection) => [selection.postId, selection.reason]));
|
|
4621
4708
|
const selectedByUrl = new Map();
|
|
4622
4709
|
for (const tab of tabsResponse.tabs ?? []) {
|
|
@@ -4671,10 +4758,20 @@ Approval card should say:
|
|
|
4671
4758
|
|
|
4672
4759
|
**Approve scraping ${selectionResult.selectedCount} recommended LinkedIn post${selectionResult.selectedCount === 1 ? "" : "s"}?**`;
|
|
4673
4760
|
}
|
|
4674
|
-
|
|
4675
|
-
|
|
4676
|
-
|
|
4677
|
-
|
|
4761
|
+
const selectionCurrentStep = currentStep === null ? undefined : (currentStep ?? "signal-discovery");
|
|
4762
|
+
if (selectionCurrentStep) {
|
|
4763
|
+
const body = {
|
|
4764
|
+
currentStep: selectionCurrentStep,
|
|
4765
|
+
watchNarration: buildSelectedPostApprovalWatchNarration(selectionResult.selectedCount, recommendedPostCount, recommendationTargetEngagerCount),
|
|
4766
|
+
...(workspaceId ? { workspaceId } : {}),
|
|
4767
|
+
};
|
|
4768
|
+
if (requestOptions) {
|
|
4769
|
+
await api.put(`/api/v2/campaign-offers/${campaignOfferId}`, body, requestOptions);
|
|
4770
|
+
}
|
|
4771
|
+
else {
|
|
4772
|
+
await api.put(`/api/v2/campaign-offers/${campaignOfferId}`, body);
|
|
4773
|
+
}
|
|
4774
|
+
}
|
|
4678
4775
|
return {
|
|
4679
4776
|
success: true,
|
|
4680
4777
|
selectedCount: selectionResult.selectedCount,
|
package/dist/tools/prompts.js
CHANGED
|
@@ -373,7 +373,7 @@ export function getPostFindLeadsScoutRegistry() {
|
|
|
373
373
|
codex: 'After confirm_lead_list copies source rows and the initial campaign-table execution slice exists, ask the filter-choice question immediately. Do not spawn anything before that question. After the answer, launch only Message Drafting. The filter-choice answer is the post-import user gate for this single worker; do not ask another question about starting it in step-wise or YOLO mode. The registry lookup is not a launch: after get_post_find_leads_scout_registry, immediately invoke Task/spawn_agent or the host background-agent mechanism before loading filter-leads.md, before saving rubrics, and before treating skip-filters as ready for message review. Both choices route through this kickoff; do not let filters_skipped jump straight from filter-choice to message-generation. If filters are chosen, the parent stays on Filter Rules and drafts/saves rubrics with MCP tools while Message Drafting runs in the background. If filters are skipped, move to Messages/message review only after Message Drafting has started or is ready; update_campaign(currentStep=messages) is not proof of launch. If the named Message Drafting custom agent is unavailable, spawn a generic gpt-5.5 xhigh Message Drafting background agent with the same lean campaign/table basis. When the background worker starts, persist workerDetails.messageDraftBuilder with statusSource "branch", status "branch-running", runId, startedAt, updatedAt, basisToken when known, and basis containing campaignId, selectedLeadListId, workflowTableId, filterChoice, and reviewBatchRowHash or reviewBatchRowIds; workerStatuses.messageDraftBuilder may be "running" as a simple badge only. Never put rich proof under workerStatuses and never use workerStatuses.messageDrafting. If no background-agent tool is callable, start the same full message branch inline before filter drafting or before skip-filter message review, record workerDetails.messageDraftBuilder with statusSource "parent-thread-fallback" and status "fallback-active", and require the same live context, prompt, assets, and validation gate before message review; do not wait until filters are saved and then call the registry.',
|
|
374
374
|
claude: "After confirm_lead_list copies source rows and the initial campaign-table execution slice exists, ask the filter-choice question immediately. Do not invoke any Task/Agent before that question. After the answer, invoke only Message Drafting. If filters are chosen, parent drafts/saves rubrics with MCP tools while Message Drafting runs, asks filter approval, then joins Message Drafting. If filters are skipped, invoke only Message Drafting and move to Messages/message review.",
|
|
375
375
|
parentThreadRule: 'Named agents are optional acceleration, but message drafting is not optional. The only normal background worker is Message Drafting. The filter-choice answer is the campaign-scoped go-ahead for this single post-import worker; do not ask another question to start it in step-wise or YOLO mode. If a named agent is unavailable, use a generic gpt-5.5 xhigh Message Drafting background agent. source work and filter work stay in the parent thread with MCP tools. If post-find-leads-message-scout is available, run it as the background Message Draft Builder after the filter-choice answer. The registry lookup is not a launch: get_post_find_leads_scout_registry only identifies the worker, and Message Drafting counts as started only after Task/spawn_agent or the host background-agent tool is invoked, or after the parent begins the same full message branch inline because no background-agent tool is callable. This launch must happen before loading filter-leads.md, save_rubrics, filter approval, or skip-filter message review; currentStep=messages is not proof of launch. If post-find-leads-message-scout is absent, do not customer-surface install status. Do not silently treat message drafting as started; the main thread must either launch the background worker or execute the same message branch from CampaignOffer state, selected source state, workflowTableId, and initial campaign-table execution slice rows. For a spawned worker, record workerDetails.messageDraftBuilder with statusSource branch / status branch-running, runId, startedAt, updatedAt, and basis containing campaignId, selectedLeadListId, workflowTableId, filterChoice, and reviewBatchRowHash or reviewBatchRowIds. workerStatuses.messageDraftBuilder is optional simple badge text only ("running", "ready", "blocked", "idle"); never put runId/statusSource/basis under workerStatuses and never use workerStatuses.messageDrafting. If no background-agent tool is callable, start that same full message branch inline before filter drafting or before skip-filter message review, record workerDetails.messageDraftBuilder with statusSource parent-thread-fallback / status fallback-active then ready, and require the same live context, prompt, assets, and validation gate before message review; do not report that as a background worker failure. If neither branch nor inline fallback can run, return blocked/retry-needed; do not wait until filters are saved and then call the registry. The Message Drafting handoff must be lean. Do not paste copied row counts, brief hashes, review-batch hashes, full reviewBatchRowIds, broad row data, or local debug artifacts into the spawn prompt. Local markdown/json files are not normal-path inputs. The filter-choice question is the first post-import user gate; do not load post-lead registries or filter references before it. Message drafting starts after the filter-choice answer, must load get_subskill_prompt({ subskillName: "generate-messages" }), and must load every required message asset named by generate-messages Mode 0 through get_subskill_asset before drafting. Reference Asset Loading means loading the required pre-draft reference pack before drafting; return blocked/retry-needed if required assets cannot be loaded; load ai-tells.md because it is never optional. The branch or parent-thread fallback loads the full generate-messages prompt and every referenced asset through get_subskill_asset. After generating/revising the candidate and before returning ready, must load get_subskill_prompt({ subskillName: "create-campaign-v2-validation" }) as the final internal validation gate, must read live campaign table state through scoped MCP/product tools, and must reject mismatched selectedLeadListId/workflowTableId/campaign/workspace input. Do not block when filters were chosen but leadScoringRubrics are not yet visible in the branch read; the parent owns save_rubrics and filter approval in parallel, so Message Drafting should return status ready with basisStatus usable_initial when campaign/list/table identity and the non-empty execution slice match. Do not use any alternate, local-artifact, or examples-only message prompt. User copy feedback, message QA, or rewrite requests before approve-message must be routed back to Message Drafting with the current recommendation, lean campaign/table basis, and latest user text; the parent must not rewrite or QA the template from memory and must not call update_campaign_brief before approve-message. The worker validates internally and returns only templateRecommendation, tokenFillRules, renderedGoodSample, status, approveOrReviseRecommendation, validationStatus, outputAt, outputHash, and blocked/retry detail. Do not render renderedFallbackSample, risk notes, or a qaReceipt on the normal happy path. On the filter path, save_rubrics keeps the browser on Filter Rules after save_rubrics so the user can approve the saved criteria; after saved-filter approval, move to Filter Leads with currentStep=apply-icp-rubric whether Message Drafting is ready or still running. Wait there for message approval. Enrichment, filtering, Generate Message cells, sender setup, sequence attach, and launch wait for template approval on the Use Template path. On the skip path, move to Messages/message review after Message Drafting has started or is ready and wait for message approval before enrichment or Settings. Do not render message review from checklist or shortcut instructions; message review requires a messageDraftRecommendation whose basis proves the generate-messages prompt, required message assets, and validation gate ran for the current campaign/table execution slice. Do not automatically rerun Message Drafting after filters/enrichment finish; show the initial draft by default and offer an enriched rewrite only with explicit user opt-in. Handoff and recommendation output are Markdown with labeled fields, not raw JSON.',
|
|
376
|
-
prepareMessagesRule: `Default create-campaign stays on the existing reviewBatchLimit:15 first campaign-table execution slice. For plain post-mint fill/load/refill requests, load get_subskill_prompt({ subskillName: "refill-sends-workflow" }), then call resolve_campaign_fill_route({ intent:"plain" }), list_senders, and get_campaign_refill_state for enough candidate campaigns to identify the campaign that most recently had scheduler-owned sends for the relevant sender set before any mutation. Route outcomes are route:"evergreen_horizon", route:"active_campaigns", and route:"ask_create"; if a plain managed-waterfall route has archived/completed skipped slots or does not cover the named sender set, immediately refetch with resolve_campaign_fill_route({ intent:"active" }) and inspect current dashboard-active ACTIVE/PAUSED campaign-backed sequence campaigns before declaring a sender blocked; stay in the same campaignOfferId/campaignId context after minting. Plain fill is not an alias for fill_campaign_horizon or campaign creation. fill_campaign_horizon is evergreen-only and is not the generic regular-campaign fill path. Campaign creation is allowed only after route:"ask_create" and explicit user selection; it is never the default response to plain fill. Treat "fill up/load sends" as capacity-fill preparation, and treat "refill senders", "fill senders", "max out senders", and "load everyone up" as sender-scoped capacity-fill preparation. For sender-scoped requests with no named senders, --yolo means all eligible healthy senders enrolled in active campaign-backed sequence campaigns in the active workspace; without --yolo, ask which eligible enrolled senders to refill before choosing campaigns or mutating. In non-yolo interactive Codex or Claude Code sessions, post the full sender/campaign/action approval packet in normal chat as Markdown first, then ask request_user_input/AskUserQuestion with exactly Accept and Decline and a compact body that refers back to the posted packet; do not duplicate the campaign table or full operator packet inside the structured question. The chat packet must show workspace, sender scope, a campaign-by-campaign table, exact ids/caps/dates, side effects, forbidden actions, and stop condition before mutation. Default --yolo target is the scheduler-forward 48-hour target window: sender-local send days whose configured sending windows overlap the rolling target window, skipping no-send-hour days. For campaign-scoped fill/refill, select the best recent-send campaign and calculate the bounded gap from healthy sender daily capacity minus projected coverage (actual sent plus future scheduler-owned scheduled sends) and ready-to-schedule rows, then prepare only that gap. For sender-scoped fill/refill, calculate the bounded gap per eligible sender across active enrolled campaigns, counting actual sent coverage, future scheduled rows, and ready-to-schedule rows across those campaigns, then choose the best same-sender campaign to fill each sender gap: prefer recent/future scheduler-owned sends for that sender, then strongest recent result evidence, then source health. Maintain a target-window saturation ledger per selected sender with selected send days, gross capacity, actual sent counts, future scheduler-owned scheduled counts, projected coverage, ready-to-schedule buffer, remaining projected gap, paid-InMail threshold feasibility, and the next MCP primitive. The structured packet lives in target.senderRefillPlans[] with target.eligibleSenderLedger, campaignRanking.options, sourcePlan, nextActions, manualAlternates, and target.globalActionQueue; preserve Need to prepare, Goal, Already sent, Scheduled, Ready and waiting to be scheduled, and Still need labels. In --yolo, execute exactly one globally ranked primitive from the post-refresh target.globalActionQueue[0], then rerun get_refill_target_plan before choosing another action. The refill_sends MCP command maintains a run-local refreshedPaidInmailSenderIds set: if the first target plan contains refresh_paid_inmail_credits for stale/missing paid-InMail facts, refill_sends refreshes each selected paid-InMail sender at most once, reruns get_refill_target_plan to obtain the post-refresh targetPlan, then may apply the first supported yolo-eligible global primitive and return autoPaidInmailRefresh, yoloExecution, and final targetPlan evidence. Do not present paid-credit refresh as the next operator action after refill_sends has returned autoPaidInmailRefresh; inspect yoloExecution and continue from the final targetPlan when it applied an action. Do not stop after filling only one sender when the request was sender-scoped. In --yolo, continue through every safe selected sender/campaign action covered by the rendered packet, reread after each terminal apply/prep/start result, recompute the target-window saturation ledger, and keep going until projected coverage (sent + scheduled) fills the scheduler-forward target window or a concrete non-scheduler blocker is proven. Ready-to-schedule rows are buffer, not completion; if ready covers the projected gap but scheduled cells do not, report loaded, awaiting scheduler and run a persistent read-only scheduler wait/reread loop and keep the run open while awaiting_scheduler_after_ready_buffer is the only remaining state. Paid-InMail threshold changes and connection-campaign creation are explicit continuation options, never --yolo side effects. When no safe in-packet action remains return concrete continuation options with campaign names, exact ids, and which options require a new approval packet; do not return final completion for scheduler wait unless Christian explicitly asks for status or stops the run. Use the refill workflow to decide whether to enrich/prep more rows in that same recent-send/best-result campaign, add/import more rows to that same campaign/source path, use a different existing campaign only when the selected same-sender lane is blocked/exhausted/already loaded while the sender still has a gap, or ask what to create. Do not create warm-post-engager side campaigns. Surface sender-health blockers and paid-InMail threshold blockers separately from prepared/approved/scheduled counts. User-facing refill decisions must be campaign-name-first and sender-name-first, with ids as proof/execution targets only. Trust schedulerGate.sendable and scheduler blockers over raw unipileAccountStatus labels alone. For long-running prep use compact prep status checks, reread target plans after prep or cancel, avoid huge parallel target-plan reads when output is large, and if prepared/ready rows grow but sender-level projected coverage does not move after one bounded settle loop, pivot to compact prep status or a scheduler-proven lane instead of waiting on campaign-level ready counts. For already-running regular campaigns that need Signal Discovery source replenishment, use the guarded currentStep clear with clearCurrentStepIfMatches:"running", campaign-scoped provider prompt/search/select, and import_leads with the existing sourceLeadListId when a newly approved selected-post scrape would otherwise return reusedExistingSourceList. Before prep, inspect get_campaign_refill_state.preparationFrontier. If hasLaterPreparedIsland:true or earliestUnpreparedRow exists before later successful enrichment, use rowSelector:{type:"needsEnrichment"} with columnRole:"enrich" in table-position order or start_campaign_message_preparation adaptive defaults; do not use the UI Jump anchor or needsGeneratedMessage as the refill cursor. After confirm_lead_list copies rows into an existing table, avoid fixed maxRowsToCheck:100; if confirm_lead_list returns USER_ADDED_ROWS_LIMIT_EXCEEDED, create a bounded same-source split from selectedLeadListId with get_rows_minimal/load_csv_linkedin_leads, confirm that smaller source list into the same campaign, and inspect reviewBatch only as diagnostics unless the approved packet explicitly prioritizes the just-copied split and earlier needsEnrichment rows are exhausted, dependency-blocked, or excluded. For approval diagnostics use rowSelector:{type:"needsApproval"} after current generated messages exist; mutating Approved cells still requires approvalMode:approve and exact bounded approval. Do not interpret checkedRows as enriched rows; it is only the table cursor. Prepared, approved, and ready_to_schedule rows are intermediate states; never call them scheduled unless a re-read proves scheduler-owned scheduled cells with non-null scheduledFor contribute to projected coverage, and never call them complete unless a final re-read proves projected coverage fills the scheduler-forward target window. Before source import, prep, approval, or selected paused campaign start, require exact visible approval or --yolo packet auto-accept and a fresh get_campaign_refill_state reread; stop if freshness.stateHash or exact ids changed. For "approve X messages", use approvalMode:approve only when explicitly requested. For "schedule X sends" or "fill sender sends", approve only when explicitly requested, then re-read campaign/table scheduled counts; if projected coverage does not fill the horizon, keep polling when ready buffer covers the gap and report only interim prepared/approved/ready - awaiting scheduler status if Christian asks. Do not call start_campaign as part of fill/schedule horizon. start_campaign is allowed in refill only for exact selected PAUSED, dashboard-active, campaign-backed sequence targets named in the bounded packet, and the packet must state that starting can let the product scheduler schedule/send approved eligible sequence actions. Never start unrelated, archived, completed, draft, direct, or non-selected campaigns, never broad approve-all, and never use direct scheduler writes. campaignId is CampaignOffer.id. If the user asks to stop preparation, the target is wrong, or status shows the wrong campaign/table, use cancel_campaign_message_preparation only for the exact active job. Low-level selectors are diagnostics and recovery only for this lane.`,
|
|
376
|
+
prepareMessagesRule: `Default create-campaign stays on the existing reviewBatchLimit:15 first campaign-table execution slice. For plain post-mint fill/load/refill requests, load get_subskill_prompt({ subskillName: "refill-sends-workflow" }), then call resolve_campaign_fill_route({ intent:"plain" }), list_senders, and get_campaign_refill_state for enough candidate campaigns to identify the campaign that most recently had scheduler-owned sends for the relevant sender set before any mutation. Route outcomes are route:"evergreen_horizon", route:"active_campaigns", and route:"ask_create"; if a plain managed-waterfall route has archived/completed skipped slots or does not cover the named sender set, immediately refetch with resolve_campaign_fill_route({ intent:"active" }) and inspect current dashboard-active ACTIVE/PAUSED campaign-backed sequence campaigns before declaring a sender blocked; stay in the same campaignOfferId/campaignId context after minting. Plain fill is not an alias for fill_campaign_horizon or campaign creation. fill_campaign_horizon is evergreen-only and is not the generic regular-campaign fill path. Campaign creation is allowed only after route:"ask_create" and explicit user selection; it is never the default response to plain fill. Treat "fill up/load sends" as capacity-fill preparation, and treat "refill senders", "fill senders", "max out senders", and "load everyone up" as sender-scoped capacity-fill preparation. For sender-scoped requests with no named senders, --yolo means all eligible healthy senders enrolled in active campaign-backed sequence campaigns in the active workspace; without --yolo, ask which eligible enrolled senders to refill before choosing campaigns or mutating. In non-yolo interactive Codex or Claude Code sessions, post the full sender/campaign/action approval packet in normal chat as Markdown first, then ask request_user_input/AskUserQuestion with exactly Accept and Decline and a compact body that refers back to the posted packet; do not duplicate the campaign table or full operator packet inside the structured question. The chat packet must show workspace, sender scope, a campaign-by-campaign table, exact ids/caps/dates, side effects, forbidden actions, and stop condition before mutation. Default --yolo target is the scheduler-forward 48-hour target window: sender-local send days whose configured sending windows overlap the rolling target window, skipping no-send-hour days. For campaign-scoped fill/refill, select the best recent-send campaign and calculate the bounded gap from healthy sender daily capacity minus projected coverage (actual sent plus future scheduler-owned scheduled sends) and ready-to-schedule rows, then prepare only that gap. For sender-scoped fill/refill, calculate the bounded gap per eligible sender across active enrolled campaigns, counting actual sent coverage, future scheduled rows, and ready-to-schedule rows across those campaigns, then choose the best same-sender campaign to fill each sender gap: prefer recent/future scheduler-owned sends for that sender, then strongest recent result evidence, then source health. Maintain a target-window saturation ledger per selected sender with selected send days, gross capacity, actual sent counts, future scheduler-owned scheduled counts, projected coverage, ready-to-schedule buffer, remaining projected gap, paid-InMail threshold feasibility, and the next MCP primitive. The structured packet lives in target.senderRefillPlans[] with target.eligibleSenderLedger, campaignRanking.options, sourcePlan, nextActions, manualAlternates, and target.globalActionQueue; preserve Need to prepare, Goal, Already sent, Scheduled, Ready and waiting to be scheduled, and Still need labels. In --yolo, execute exactly one globally ranked primitive from the post-refresh target.globalActionQueue[0], then rerun get_refill_target_plan before choosing another action. 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. 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.`,
|
|
377
377
|
},
|
|
378
378
|
};
|
|
379
379
|
}
|
|
@@ -1,29 +1,6 @@
|
|
|
1
1
|
type RefillSendsIntent = "plain" | "active" | "evergreen";
|
|
2
2
|
type RefillSendsApprovalMode = "approve" | "mark_ready";
|
|
3
3
|
type RefillSendsExecutionMode = "manual" | "scheduled" | "yolo";
|
|
4
|
-
type RefillSendsRowSelector = {
|
|
5
|
-
type: "reviewBatch";
|
|
6
|
-
basisHash?: string;
|
|
7
|
-
limit?: number;
|
|
8
|
-
} | {
|
|
9
|
-
type: "rowIds";
|
|
10
|
-
rowIds: string[];
|
|
11
|
-
} | {
|
|
12
|
-
type: "needsEnrichment";
|
|
13
|
-
limit?: number;
|
|
14
|
-
} | {
|
|
15
|
-
type: "needsApproval";
|
|
16
|
-
limit?: number;
|
|
17
|
-
} | {
|
|
18
|
-
type: "passedRows";
|
|
19
|
-
limit?: number;
|
|
20
|
-
} | {
|
|
21
|
-
type: "needsGeneratedMessage";
|
|
22
|
-
limit?: number;
|
|
23
|
-
} | {
|
|
24
|
-
type: "staleGeneratedMessages";
|
|
25
|
-
limit?: number;
|
|
26
|
-
};
|
|
27
4
|
type RefillSendsCommandInput = {
|
|
28
5
|
yolo?: boolean;
|
|
29
6
|
executionMode?: RefillSendsExecutionMode;
|
|
@@ -40,6 +17,34 @@ type RefillSendsCommandInput = {
|
|
|
40
17
|
intent?: RefillSendsIntent;
|
|
41
18
|
approvalMode?: RefillSendsApprovalMode;
|
|
42
19
|
};
|
|
20
|
+
type YoloLoopStatus = "complete" | "no_action" | "read_only_reread" | "executed_and_reread" | "refused" | "max_actions_reached" | "target_shape_drift";
|
|
21
|
+
type YoloLoopStopReason = "target_complete" | "no_global_action" | "primitive_refused" | "max_actions_reached" | "target_shape_drift";
|
|
22
|
+
type YoloPlanSummary = {
|
|
23
|
+
status?: string | null;
|
|
24
|
+
targetShapeRevision?: string | null;
|
|
25
|
+
stateRevision?: string | null;
|
|
26
|
+
grossTarget?: number | null;
|
|
27
|
+
sent?: number | null;
|
|
28
|
+
scheduled?: number | null;
|
|
29
|
+
projected?: number | null;
|
|
30
|
+
readyBuffer?: number | null;
|
|
31
|
+
remainingProjectedGap?: number | null;
|
|
32
|
+
remainingReadyOrProjectedGap?: number | null;
|
|
33
|
+
actionType?: string | null;
|
|
34
|
+
};
|
|
35
|
+
type YoloActionReceipt = {
|
|
36
|
+
attempt: number;
|
|
37
|
+
selectedAction: Record<string, unknown> | null;
|
|
38
|
+
before: YoloPlanSummary;
|
|
39
|
+
primitive: YoloPrimitiveAttempt;
|
|
40
|
+
after: YoloPlanSummary | null;
|
|
41
|
+
postActionFirstAction?: Record<string, unknown> | null;
|
|
42
|
+
};
|
|
43
|
+
type YoloPrimitiveAttempt = {
|
|
44
|
+
status: "no_action" | "read_only_reread" | "executed_and_reread" | "refused";
|
|
45
|
+
result?: unknown;
|
|
46
|
+
refusalReason?: string;
|
|
47
|
+
};
|
|
43
48
|
export declare const refillSendsToolDefinitions: {
|
|
44
49
|
name: string;
|
|
45
50
|
description: string;
|
|
@@ -205,6 +210,12 @@ export declare function executeRefillSendsCommand(input?: RefillSendsCommandInpu
|
|
|
205
210
|
workspaceId?: undefined;
|
|
206
211
|
workspaceResolution?: undefined;
|
|
207
212
|
};
|
|
213
|
+
yoloExecution: {
|
|
214
|
+
enabled: false;
|
|
215
|
+
status: "not_run_without_yolo";
|
|
216
|
+
selectedAction: null;
|
|
217
|
+
targetPlanReread: false;
|
|
218
|
+
};
|
|
208
219
|
command: string;
|
|
209
220
|
tool: string;
|
|
210
221
|
promptName: string;
|
|
@@ -274,19 +285,23 @@ export declare function executeRefillSendsCommand(input?: RefillSendsCommandInpu
|
|
|
274
285
|
};
|
|
275
286
|
} | {
|
|
276
287
|
targetPlan: unknown;
|
|
277
|
-
targetPlanBeforeYoloAction: unknown;
|
|
278
288
|
targetPlanBeforePaidRefresh: unknown;
|
|
289
|
+
targetPlanBeforeYoloPrimitive: unknown;
|
|
279
290
|
autoPaidInmailRefresh: {
|
|
280
291
|
enabled: boolean;
|
|
281
292
|
status: string;
|
|
282
293
|
refreshedPaidInmailSenderIds: string[];
|
|
283
294
|
failedPaidInmailRefreshes: {
|
|
284
295
|
senderId: string;
|
|
296
|
+
attempts?: number;
|
|
285
297
|
error: string;
|
|
298
|
+
errors?: string[];
|
|
286
299
|
}[];
|
|
287
300
|
refreshReceipts: {
|
|
288
301
|
senderId: string;
|
|
289
302
|
actionKey: string | null;
|
|
303
|
+
attempts: number;
|
|
304
|
+
retryErrors: string[];
|
|
290
305
|
receipt: import("./senders.js").RefreshPaidInmailCreditsResponse;
|
|
291
306
|
}[];
|
|
292
307
|
attemptedSenderIds: string[];
|
|
@@ -296,61 +311,21 @@ export declare function executeRefillSendsCommand(input?: RefillSendsCommandInpu
|
|
|
296
311
|
note: string;
|
|
297
312
|
};
|
|
298
313
|
yoloExecution: {
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
status: string;
|
|
315
|
-
applied: boolean;
|
|
316
|
-
action: Record<string, unknown>;
|
|
317
|
-
note: string;
|
|
318
|
-
toolName?: undefined;
|
|
319
|
-
input?: undefined;
|
|
320
|
-
startedAt?: undefined;
|
|
321
|
-
endedAt?: undefined;
|
|
322
|
-
startReceipt?: undefined;
|
|
323
|
-
waitReceipt?: undefined;
|
|
324
|
-
enabled: boolean;
|
|
325
|
-
workspaceId: string | null;
|
|
326
|
-
workspaceResolution: string;
|
|
327
|
-
targetPlanRereadAfterAction: boolean;
|
|
328
|
-
} | {
|
|
329
|
-
status: string;
|
|
330
|
-
applied: boolean;
|
|
331
|
-
action: Record<string, unknown>;
|
|
332
|
-
toolName: string;
|
|
333
|
-
input: {
|
|
334
|
-
workspaceId?: string | undefined;
|
|
335
|
-
rowSelector?: RefillSendsRowSelector | undefined;
|
|
336
|
-
approvalMode?: RefillSendsApprovalMode | undefined;
|
|
337
|
-
targetPreparedMessages?: number | undefined;
|
|
338
|
-
tableId?: string | undefined;
|
|
339
|
-
campaignId: string;
|
|
340
|
-
};
|
|
341
|
-
startedAt: string;
|
|
342
|
-
endedAt: string;
|
|
343
|
-
startReceipt: unknown;
|
|
344
|
-
waitReceipt: {
|
|
345
|
-
waited: boolean;
|
|
346
|
-
timedOut: boolean;
|
|
347
|
-
receipt: unknown;
|
|
348
|
-
};
|
|
349
|
-
note?: undefined;
|
|
350
|
-
enabled: boolean;
|
|
351
|
-
workspaceId: string | null;
|
|
352
|
-
workspaceResolution: string;
|
|
353
|
-
targetPlanRereadAfterAction: boolean;
|
|
314
|
+
enabled: true;
|
|
315
|
+
status: YoloLoopStatus;
|
|
316
|
+
stopReason: YoloLoopStopReason;
|
|
317
|
+
selectedAction: Record<string, unknown> | null;
|
|
318
|
+
actions: YoloActionReceipt[];
|
|
319
|
+
actionCount: number;
|
|
320
|
+
result?: unknown;
|
|
321
|
+
targetPlanReread: boolean;
|
|
322
|
+
targetPlanRereads: number;
|
|
323
|
+
initialTargetShapeRevision?: string | null;
|
|
324
|
+
finalTargetShapeRevision?: string | null;
|
|
325
|
+
finalStateRevision?: string | null;
|
|
326
|
+
maxActions: number;
|
|
327
|
+
refusalReason?: string;
|
|
328
|
+
postActionFirstAction?: unknown;
|
|
354
329
|
};
|
|
355
330
|
command: string;
|
|
356
331
|
tool: string;
|