@sellable/mcp 0.1.336 → 0.1.337
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 +34 -19
- package/dist/api.js +5 -3
- package/dist/auth.js +44 -13
- package/dist/server.js +20 -0
- package/dist/tools/campaign-fill-routing.d.ts +39 -0
- package/dist/tools/campaign-fill-routing.js +45 -0
- package/dist/tools/campaign-horizon-fill.d.ts +93 -0
- package/dist/tools/campaign-horizon-fill.js +92 -0
- package/dist/tools/campaign-message-preparation.d.ts +8 -0
- package/dist/tools/campaign-message-preparation.js +13 -6
- package/dist/tools/campaigns.js +1 -1
- package/dist/tools/prompts.js +1 -1
- package/dist/tools/refill-campaign-sends.d.ts +92 -0
- package/dist/tools/refill-campaign-sends.js +91 -0
- package/dist/tools/registry.d.ts +189 -0
- package/dist/tools/registry.js +6 -0
- package/dist/tools/tables.d.ts +4 -0
- package/dist/tools/tables.js +1 -1
- package/package.json +1 -1
- package/skills/create-campaign/SKILL.md +44 -18
- package/skills/create-campaign-v2/core/flow.v2.json +1 -1
- package/skills/create-campaign-v2/references/sample-validation-loop.md +16 -0
- package/skills/create-evergreen-campaigns/SKILL.md +94 -14
- package/skills/fill-send-horizon/SKILL.md +42 -20
- package/skills/refill-sends/SKILL.md +57 -0
- package/skills/research/config.json +9 -0
package/README.md
CHANGED
|
@@ -96,8 +96,17 @@ startup/auth update check and tells the agent to run
|
|
|
96
96
|
`curl -fsSL "https://app.sellable.dev/api/v2/cli/install" | sh` when the
|
|
97
97
|
installed runtime is behind npm.
|
|
98
98
|
|
|
99
|
-
|
|
100
|
-
|
|
99
|
+
First-run login is the normal auth path. Install Sellable, launch a workflow in
|
|
100
|
+
Claude Code or Codex, and let the agent complete the browser magic-link login.
|
|
101
|
+
If the browser login page shows a manual fallback, paste:
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
sellable auth set <token> --workspace-id <workspace_id>
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
For CI/env-only scripted installs, operators can set `SELLABLE_TOKEN` and
|
|
108
|
+
`SELLABLE_WORKSPACE_ID` before running the curl installer. The public path
|
|
109
|
+
remains:
|
|
101
110
|
|
|
102
111
|
```bash
|
|
103
112
|
curl -fsSL "https://app.sellable.dev/api/v2/cli/install" | sh
|
|
@@ -117,11 +126,17 @@ and publishes with a temporary npm config file. Prefer `NPM_TOKEN=<npm token>` i
|
|
|
117
126
|
`prod.env`; `NODE_AUTH_TOKEN`, `SELLABLE_NPM_TOKEN`, and `NPM_PUBLISH_TOKEN` are
|
|
118
127
|
also supported.
|
|
119
128
|
|
|
120
|
-
### 2.
|
|
129
|
+
### 2. First-Run Login
|
|
121
130
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
131
|
+
Launch a Sellable workflow after install. The agent will start first-run login,
|
|
132
|
+
send the magic link, wait for browser confirmation, and write canonical auth to
|
|
133
|
+
`~/.sellable/config.json`.
|
|
134
|
+
|
|
135
|
+
If the browser confirmation page shows a scripted fallback, paste:
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
sellable auth set <token> --workspace-id <workspace_id>
|
|
139
|
+
```
|
|
125
140
|
|
|
126
141
|
### 3. Claude Setup Fallback
|
|
127
142
|
|
|
@@ -135,17 +150,9 @@ Install MCP server manually:
|
|
|
135
150
|
claude mcp add --transport stdio sellable -- npm exec --yes --package @sellable/mcp@latest -- sellable-mcp
|
|
136
151
|
```
|
|
137
152
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
{
|
|
142
|
-
"token": "skt_live_your_token_here",
|
|
143
|
-
"activeWorkspaceId": "your_workspace_id"
|
|
144
|
-
}
|
|
145
|
-
```
|
|
146
|
-
|
|
147
|
-
The token is provided when you generate it. Use `list_workspaces` +
|
|
148
|
-
`set_active_workspace` to choose a workspace if you don't know the ID yet.
|
|
153
|
+
Do not hand-edit auth JSON for normal setup. Use first-run login or the
|
|
154
|
+
`sellable auth set <token> --workspace-id <workspace_id>` fallback so the
|
|
155
|
+
canonical config shape stays consistent.
|
|
149
156
|
|
|
150
157
|
### 4. Codex Setup
|
|
151
158
|
|
|
@@ -524,13 +531,21 @@ generation is not part of these inbox tools.
|
|
|
524
531
|
|
|
525
532
|
### "Sellable not configured" Error
|
|
526
533
|
|
|
527
|
-
|
|
534
|
+
Run a Sellable workflow to start first-run login. If the browser login page
|
|
535
|
+
shows a manual fallback, paste:
|
|
536
|
+
|
|
537
|
+
```bash
|
|
538
|
+
sellable auth set <token> --workspace-id <workspace_id>
|
|
539
|
+
```
|
|
528
540
|
|
|
529
541
|
### Token Not Working
|
|
530
542
|
|
|
531
543
|
1. Make sure token starts with `skt_`
|
|
532
544
|
2. Check token is not revoked
|
|
533
|
-
3.
|
|
545
|
+
3. If the token came from an older Settings flow and returns 403 on campaign or
|
|
546
|
+
enrichment writes, regenerate through first-run login or the scripted
|
|
547
|
+
fallback command above
|
|
548
|
+
4. Verify activeWorkspaceId matches your workspace (or run list_workspaces + set_active_workspace)
|
|
534
549
|
|
|
535
550
|
## Support
|
|
536
551
|
|
package/dist/api.js
CHANGED
|
@@ -19,9 +19,11 @@ export class SellableApi {
|
|
|
19
19
|
const missingWorkspace = status === 400 && errorText.includes("Workspace");
|
|
20
20
|
const guidance = isAuthError
|
|
21
21
|
? "Sellable authentication failed.\n\n" +
|
|
22
|
-
|
|
23
|
-
"
|
|
24
|
-
"
|
|
22
|
+
"Run the first-run Sellable login flow from a Sellable workflow, then retry.\n\n" +
|
|
23
|
+
"If the browser login page shows a manual fallback command, use:\n" +
|
|
24
|
+
"sellable auth set <token> --workspace-id <workspace_id>\n\n" +
|
|
25
|
+
`Current config path: ${getConfigPath()}\n\n` +
|
|
26
|
+
"Older copied Settings tokens can be stale, restricted, or missing write/credit permissions. Sign in again so Sellable mints the current agent token."
|
|
25
27
|
: missingWorkspace
|
|
26
28
|
? "No active workspace selected.\n\n" +
|
|
27
29
|
"Run list_workspaces then set_active_workspace to choose a workspace."
|
package/dist/auth.js
CHANGED
|
@@ -48,6 +48,16 @@ export function getConfigPath() {
|
|
|
48
48
|
}
|
|
49
49
|
return candidates[0];
|
|
50
50
|
}
|
|
51
|
+
function getConfigWritePath() {
|
|
52
|
+
const explicitConfigPath = process.env.SELLABLE_CONFIG_PATH?.trim();
|
|
53
|
+
if (explicitConfigPath) {
|
|
54
|
+
return path.resolve(explicitConfigPath);
|
|
55
|
+
}
|
|
56
|
+
if (configFileName === "sellable.json") {
|
|
57
|
+
return path.join(os.homedir(), ".sellable", "config.json");
|
|
58
|
+
}
|
|
59
|
+
return getConfigPath();
|
|
60
|
+
}
|
|
51
61
|
function normalizeConfig(raw) {
|
|
52
62
|
return {
|
|
53
63
|
...raw,
|
|
@@ -66,14 +76,12 @@ export function getConfig() {
|
|
|
66
76
|
const configPath = getConfigPath();
|
|
67
77
|
if (!fs.existsSync(configPath)) {
|
|
68
78
|
throw new Error("Sellable not configured.\n\n" +
|
|
69
|
-
|
|
70
|
-
"
|
|
71
|
-
|
|
72
|
-
|
|
79
|
+
"Run a Sellable workflow to start first-run login, for example /sellable:create-campaign in Claude Code or $sellable:create-campaign in Codex.\n\n" +
|
|
80
|
+
"If the browser login page shows a manual fallback command, paste it in your terminal:\n" +
|
|
81
|
+
"sellable auth set <token> --workspace-id <workspace_id>\n\n" +
|
|
82
|
+
`Preferred config path: ${getConfigWritePath()}\n\n` +
|
|
73
83
|
"Config path resolution order:\n" +
|
|
74
|
-
`${renderConfigPathOrder(configPathCandidates)}
|
|
75
|
-
"Get your token at: https://app.sellable.dev/settings?tab=integrations\n" +
|
|
76
|
-
"Then run list_workspaces + set_active_workspace to select a workspace.");
|
|
84
|
+
`${renderConfigPathOrder(configPathCandidates)}`);
|
|
77
85
|
}
|
|
78
86
|
try {
|
|
79
87
|
const content = fs.readFileSync(configPath, "utf-8");
|
|
@@ -118,7 +126,8 @@ export function updateActiveWorkspace(params) {
|
|
|
118
126
|
fs.mkdirSync(configDir, { recursive: true });
|
|
119
127
|
}
|
|
120
128
|
if (!fs.existsSync(configPath)) {
|
|
121
|
-
throw new Error(
|
|
129
|
+
throw new Error("Sellable not configured. Run a Sellable workflow to start first-run login, " +
|
|
130
|
+
"or paste the browser fallback command: sellable auth set <token> --workspace-id <workspace_id>.");
|
|
122
131
|
}
|
|
123
132
|
const content = fs.readFileSync(configPath, "utf-8");
|
|
124
133
|
let raw;
|
|
@@ -158,7 +167,8 @@ export function updateActiveWorkspace(params) {
|
|
|
158
167
|
function readRawConfigFile() {
|
|
159
168
|
const configPath = getConfigPath();
|
|
160
169
|
if (!fs.existsSync(configPath)) {
|
|
161
|
-
throw new Error(
|
|
170
|
+
throw new Error("Sellable not configured. Run a Sellable workflow to start first-run login, " +
|
|
171
|
+
"or paste the browser fallback command: sellable auth set <token> --workspace-id <workspace_id>.");
|
|
162
172
|
}
|
|
163
173
|
const content = fs.readFileSync(configPath, "utf-8");
|
|
164
174
|
try {
|
|
@@ -197,15 +207,36 @@ function writeRawConfigFile(configPath, raw) {
|
|
|
197
207
|
* new config without an MCP server restart.
|
|
198
208
|
*/
|
|
199
209
|
export function writeNewConfig(opts) {
|
|
200
|
-
const configPath =
|
|
201
|
-
|
|
210
|
+
const configPath = getConfigWritePath();
|
|
211
|
+
let raw = {};
|
|
212
|
+
if (fs.existsSync(configPath)) {
|
|
213
|
+
const content = fs.readFileSync(configPath, "utf-8");
|
|
214
|
+
try {
|
|
215
|
+
raw = JSON.parse(content);
|
|
216
|
+
}
|
|
217
|
+
catch (error) {
|
|
218
|
+
if (error instanceof SyntaxError) {
|
|
219
|
+
throw new Error(`Invalid JSON in ${configPath}: ${error.message}`);
|
|
220
|
+
}
|
|
221
|
+
throw error;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
const authFields = {
|
|
202
225
|
token: opts.token,
|
|
203
226
|
activeWorkspaceId: opts.activeWorkspaceId,
|
|
204
227
|
apiUrl: opts.apiUrl,
|
|
205
228
|
};
|
|
206
|
-
if (opts.activeWorkspaceName)
|
|
207
|
-
|
|
229
|
+
if (opts.activeWorkspaceName)
|
|
230
|
+
authFields.activeWorkspaceName = opts.activeWorkspaceName;
|
|
231
|
+
const { envConfig, set } = getActiveEnvConfigRef(raw);
|
|
232
|
+
const nextEnvConfig = {
|
|
233
|
+
...envConfig,
|
|
234
|
+
...authFields,
|
|
235
|
+
};
|
|
236
|
+
if (!opts.activeWorkspaceName) {
|
|
237
|
+
delete nextEnvConfig.activeWorkspaceName;
|
|
208
238
|
}
|
|
239
|
+
set(nextEnvConfig);
|
|
209
240
|
writeRawConfigFile(configPath, raw);
|
|
210
241
|
return { configPath };
|
|
211
242
|
}
|
package/dist/server.js
CHANGED
|
@@ -6,7 +6,10 @@ import { getAuthStatus } from "./tools/auth.js";
|
|
|
6
6
|
import { handleAddColumn, handleCommitBlueprint, } from "./tools/blueprint-commit.js";
|
|
7
7
|
import { bootstrapCreateCampaign } from "./tools/bootstrap.js";
|
|
8
8
|
import { prepareCampaignAbTest } from "./tools/campaign-ab-test.js";
|
|
9
|
+
import { resolveCampaignFillRoute } from "./tools/campaign-fill-routing.js";
|
|
10
|
+
import { fillCampaignHorizon } from "./tools/campaign-horizon-fill.js";
|
|
9
11
|
import { cancelPrepareCampaignMessages, getPrepareCampaignMessagesStatus, startPrepareCampaignMessages, } from "./tools/campaign-message-preparation.js";
|
|
12
|
+
import { refillCampaignSends } from "./tools/refill-campaign-sends.js";
|
|
10
13
|
import { getCampaignTableSchema, queueCampaignCells, recordCampaignReviewBatch, reviseMessageTemplateAndRerun, selectCampaignCells, waitForCampaignProcessing, } from "./tools/campaign-processing.js";
|
|
11
14
|
import { createCampaign, duplicateCampaign, getCampaign, getCampaignMessagesPreview, getCampaigns, pauseCampaign, startCampaign, updateCampaign, updateCampaignBrief, } from "./tools/campaigns.js";
|
|
12
15
|
import { queueCells, updateCell } from "./tools/cells.js";
|
|
@@ -178,6 +181,23 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
178
181
|
case "get_campaign_messages_preview":
|
|
179
182
|
result = await getCampaignMessagesPreview(args);
|
|
180
183
|
break;
|
|
184
|
+
case "resolve_campaign_fill_route":
|
|
185
|
+
result = await resolveCampaignFillRoute(args);
|
|
186
|
+
break;
|
|
187
|
+
case "refill_campaign_sends":
|
|
188
|
+
result = await refillCampaignSends(args);
|
|
189
|
+
if (args?.mode === "apply" && Array.isArray(result?.appliedCampaignIds)) {
|
|
190
|
+
for (const campaignId of result.appliedCampaignIds) {
|
|
191
|
+
markCampaignContextDirty(campaignId, "refill_campaign_sends");
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
break;
|
|
195
|
+
case "fill_campaign_horizon":
|
|
196
|
+
result = await fillCampaignHorizon(args);
|
|
197
|
+
if (args?.campaignId) {
|
|
198
|
+
markCampaignContextDirty(args.campaignId, "fill_campaign_horizon");
|
|
199
|
+
}
|
|
200
|
+
break;
|
|
181
201
|
case "start_campaign_message_preparation":
|
|
182
202
|
case "start_prepare_campaign_messages":
|
|
183
203
|
result = await startPrepareCampaignMessages(args);
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
type CampaignFillIntent = "plain" | "evergreen" | "active";
|
|
2
|
+
type ResolveCampaignFillRouteInput = {
|
|
3
|
+
intent: CampaignFillIntent;
|
|
4
|
+
campaignId?: string;
|
|
5
|
+
tableId?: string;
|
|
6
|
+
limit?: number;
|
|
7
|
+
};
|
|
8
|
+
export declare const campaignFillRoutingToolDefinitions: {
|
|
9
|
+
name: string;
|
|
10
|
+
description: string;
|
|
11
|
+
inputSchema: {
|
|
12
|
+
type: string;
|
|
13
|
+
properties: {
|
|
14
|
+
intent: {
|
|
15
|
+
type: string;
|
|
16
|
+
enum: string[];
|
|
17
|
+
description: string;
|
|
18
|
+
};
|
|
19
|
+
campaignId: {
|
|
20
|
+
type: string;
|
|
21
|
+
description: string;
|
|
22
|
+
};
|
|
23
|
+
tableId: {
|
|
24
|
+
type: string;
|
|
25
|
+
description: string;
|
|
26
|
+
};
|
|
27
|
+
limit: {
|
|
28
|
+
type: string;
|
|
29
|
+
minimum: number;
|
|
30
|
+
maximum: number;
|
|
31
|
+
description: string;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
required: string[];
|
|
35
|
+
additionalProperties: boolean;
|
|
36
|
+
};
|
|
37
|
+
}[];
|
|
38
|
+
export declare function resolveCampaignFillRoute(input: ResolveCampaignFillRouteInput): Promise<unknown>;
|
|
39
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { getApi } from "../api.js";
|
|
2
|
+
async function postCampaignFillRoute(body) {
|
|
3
|
+
const api = getApi();
|
|
4
|
+
return api.post("/api/v3/mcp/campaign-fill-routing", body);
|
|
5
|
+
}
|
|
6
|
+
export const campaignFillRoutingToolDefinitions = [
|
|
7
|
+
{
|
|
8
|
+
name: "resolve_campaign_fill_route",
|
|
9
|
+
description: 'Audit-only resolver to call before interpreting plain "fill campaigns", "load everyone up", or similar fill requests. It decides whether the workspace has evergreen/horizon targets, currently active campaign-backed sequence targets, or no targets so the agent must ask what to create. It does not create, append, prepare, approve, schedule, launch, archive, delete, send, or call lower-level fill tools. Only call fill_campaign_horizon when this resolver returns route "evergreen_horizon" or the user explicitly requested evergreen/horizon and the returned target is eligible. Exact target narrowing uses campaignId or tableId only; never fuzzy campaign names.',
|
|
10
|
+
inputSchema: {
|
|
11
|
+
type: "object",
|
|
12
|
+
properties: {
|
|
13
|
+
intent: {
|
|
14
|
+
type: "string",
|
|
15
|
+
enum: ["plain", "evergreen", "active"],
|
|
16
|
+
description: 'Use "plain" for generic fill/load requests, "evergreen" for explicit evergreen/horizon fill, and "active" for explicit active campaign fill.',
|
|
17
|
+
},
|
|
18
|
+
campaignId: {
|
|
19
|
+
type: "string",
|
|
20
|
+
description: "Optional exact CampaignOffer.id to narrow routing. Do not pass campaign names.",
|
|
21
|
+
},
|
|
22
|
+
tableId: {
|
|
23
|
+
type: "string",
|
|
24
|
+
description: "Optional exact WorkflowTable.id to narrow routing. Do not pass table names.",
|
|
25
|
+
},
|
|
26
|
+
limit: {
|
|
27
|
+
type: "number",
|
|
28
|
+
minimum: 1,
|
|
29
|
+
maximum: 100,
|
|
30
|
+
description: "Maximum returned targets/skippedTargets.",
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
required: ["intent"],
|
|
34
|
+
additionalProperties: false,
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
];
|
|
38
|
+
export function resolveCampaignFillRoute(input) {
|
|
39
|
+
return postCampaignFillRoute({
|
|
40
|
+
intent: input.intent,
|
|
41
|
+
campaignId: input.campaignId,
|
|
42
|
+
tableId: input.tableId,
|
|
43
|
+
limit: input.limit,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
type FillCampaignHorizonInput = {
|
|
2
|
+
action: "audit" | "apply";
|
|
3
|
+
campaignId: string;
|
|
4
|
+
tableId?: string;
|
|
5
|
+
stateRevision?: string;
|
|
6
|
+
excludedPostIds?: string[];
|
|
7
|
+
excludedPostUrls?: string[];
|
|
8
|
+
excludedAuthorProfileUrls?: string[];
|
|
9
|
+
excludedAuthorNames?: string[];
|
|
10
|
+
targetPreparedMessages?: number;
|
|
11
|
+
maxRowsToCheck?: number;
|
|
12
|
+
batchSize?: number;
|
|
13
|
+
};
|
|
14
|
+
export declare const campaignHorizonFillToolDefinitions: {
|
|
15
|
+
name: string;
|
|
16
|
+
description: string;
|
|
17
|
+
inputSchema: {
|
|
18
|
+
type: string;
|
|
19
|
+
properties: {
|
|
20
|
+
action: {
|
|
21
|
+
type: string;
|
|
22
|
+
enum: string[];
|
|
23
|
+
description: string;
|
|
24
|
+
};
|
|
25
|
+
campaignId: {
|
|
26
|
+
type: string;
|
|
27
|
+
description: string;
|
|
28
|
+
};
|
|
29
|
+
tableId: {
|
|
30
|
+
type: string;
|
|
31
|
+
description: string;
|
|
32
|
+
};
|
|
33
|
+
stateRevision: {
|
|
34
|
+
type: string;
|
|
35
|
+
description: string;
|
|
36
|
+
};
|
|
37
|
+
excludedPostIds: {
|
|
38
|
+
type: string;
|
|
39
|
+
items: {
|
|
40
|
+
type: string;
|
|
41
|
+
};
|
|
42
|
+
maxItems: number;
|
|
43
|
+
description: string;
|
|
44
|
+
};
|
|
45
|
+
excludedPostUrls: {
|
|
46
|
+
type: string;
|
|
47
|
+
items: {
|
|
48
|
+
type: string;
|
|
49
|
+
};
|
|
50
|
+
maxItems: number;
|
|
51
|
+
description: string;
|
|
52
|
+
};
|
|
53
|
+
excludedAuthorProfileUrls: {
|
|
54
|
+
type: string;
|
|
55
|
+
items: {
|
|
56
|
+
type: string;
|
|
57
|
+
};
|
|
58
|
+
maxItems: number;
|
|
59
|
+
description: string;
|
|
60
|
+
};
|
|
61
|
+
excludedAuthorNames: {
|
|
62
|
+
type: string;
|
|
63
|
+
items: {
|
|
64
|
+
type: string;
|
|
65
|
+
};
|
|
66
|
+
maxItems: number;
|
|
67
|
+
description: string;
|
|
68
|
+
};
|
|
69
|
+
targetPreparedMessages: {
|
|
70
|
+
type: string;
|
|
71
|
+
minimum: number;
|
|
72
|
+
maximum: number;
|
|
73
|
+
description: string;
|
|
74
|
+
};
|
|
75
|
+
maxRowsToCheck: {
|
|
76
|
+
type: string;
|
|
77
|
+
minimum: number;
|
|
78
|
+
maximum: number;
|
|
79
|
+
description: string;
|
|
80
|
+
};
|
|
81
|
+
batchSize: {
|
|
82
|
+
type: string;
|
|
83
|
+
minimum: number;
|
|
84
|
+
maximum: number;
|
|
85
|
+
description: string;
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
required: string[];
|
|
89
|
+
additionalProperties: boolean;
|
|
90
|
+
};
|
|
91
|
+
}[];
|
|
92
|
+
export declare function fillCampaignHorizon(input: FillCampaignHorizonInput): Promise<unknown>;
|
|
93
|
+
export {};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { getApi } from "../api.js";
|
|
2
|
+
async function postHorizonFill(body) {
|
|
3
|
+
const api = getApi();
|
|
4
|
+
return api.post("/api/v3/mcp/campaign-horizon-fill", body);
|
|
5
|
+
}
|
|
6
|
+
export const campaignHorizonFillToolDefinitions = [
|
|
7
|
+
{
|
|
8
|
+
name: "fill_campaign_horizon",
|
|
9
|
+
description: "Evergreen/horizon-only tool: audit or apply a bounded CampaignOffer horizon fill from Signal Discovery/source lead-list rows only when resolve_campaign_fill_route returns route evergreen_horizon or the user explicitly requested evergreen/horizon and the target is managed-waterfall eligible. Use audit first to get stateRevision, then apply with that stateRevision. Apply imports at most 300 eligible non-excluded source rows, starts bounded message preparation in approval mode, skips rows from excluded posts/authors, and does not start or launch the campaign, send messages, or directly assign scheduler-owned send timestamps. Prepared/approved rows are intermediate only; report scheduled completion only after re-reading scheduler-owned scheduled cells with non-null scheduler timestamps.",
|
|
10
|
+
inputSchema: {
|
|
11
|
+
type: "object",
|
|
12
|
+
properties: {
|
|
13
|
+
action: {
|
|
14
|
+
type: "string",
|
|
15
|
+
enum: ["audit", "apply"],
|
|
16
|
+
description: 'Use "audit" to inspect counts/receipt without writes. Use "apply" with the audit stateRevision to import/prep.',
|
|
17
|
+
},
|
|
18
|
+
campaignId: {
|
|
19
|
+
type: "string",
|
|
20
|
+
description: "CampaignOffer.id for the campaign to fill.",
|
|
21
|
+
},
|
|
22
|
+
tableId: {
|
|
23
|
+
type: "string",
|
|
24
|
+
description: "Optional workflow table id. Must match the campaign workflowTableId when provided.",
|
|
25
|
+
},
|
|
26
|
+
stateRevision: {
|
|
27
|
+
type: "string",
|
|
28
|
+
description: "Required for apply. Copy from the immediately preceding audit receipt.",
|
|
29
|
+
},
|
|
30
|
+
excludedPostIds: {
|
|
31
|
+
type: "array",
|
|
32
|
+
items: { type: "string" },
|
|
33
|
+
maxItems: 100,
|
|
34
|
+
description: "Exact SignalSearchPost ids to exclude from import/preparation.",
|
|
35
|
+
},
|
|
36
|
+
excludedPostUrls: {
|
|
37
|
+
type: "array",
|
|
38
|
+
items: { type: "string" },
|
|
39
|
+
maxItems: 100,
|
|
40
|
+
description: "Exact LinkedIn post URLs to exclude from import/preparation.",
|
|
41
|
+
},
|
|
42
|
+
excludedAuthorProfileUrls: {
|
|
43
|
+
type: "array",
|
|
44
|
+
items: { type: "string" },
|
|
45
|
+
maxItems: 100,
|
|
46
|
+
description: "Exact LinkedIn author profile URLs whose source rows should be excluded.",
|
|
47
|
+
},
|
|
48
|
+
excludedAuthorNames: {
|
|
49
|
+
type: "array",
|
|
50
|
+
items: { type: "string" },
|
|
51
|
+
maxItems: 25,
|
|
52
|
+
description: "Exact author names to exclude only when they resolve unambiguously inside campaign Signal Discovery posts.",
|
|
53
|
+
},
|
|
54
|
+
targetPreparedMessages: {
|
|
55
|
+
type: "number",
|
|
56
|
+
minimum: 1,
|
|
57
|
+
maximum: 300,
|
|
58
|
+
description: "Prepared/approved message target for the first pass. Backend caps this at 300.",
|
|
59
|
+
},
|
|
60
|
+
maxRowsToCheck: {
|
|
61
|
+
type: "number",
|
|
62
|
+
minimum: 1,
|
|
63
|
+
maximum: 300,
|
|
64
|
+
description: "Hard first-pass row cap. Backend caps import and prep at 300 rows.",
|
|
65
|
+
},
|
|
66
|
+
batchSize: {
|
|
67
|
+
type: "number",
|
|
68
|
+
minimum: 1,
|
|
69
|
+
maximum: 100,
|
|
70
|
+
description: "Preparation batch size. Backend caps newly checked rows at 100 per batch.",
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
required: ["action", "campaignId"],
|
|
74
|
+
additionalProperties: false,
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
];
|
|
78
|
+
export function fillCampaignHorizon(input) {
|
|
79
|
+
return postHorizonFill({
|
|
80
|
+
action: input.action,
|
|
81
|
+
campaignId: input.campaignId,
|
|
82
|
+
tableId: input.tableId,
|
|
83
|
+
stateRevision: input.stateRevision,
|
|
84
|
+
excludedPostIds: input.excludedPostIds,
|
|
85
|
+
excludedPostUrls: input.excludedPostUrls,
|
|
86
|
+
excludedAuthorProfileUrls: input.excludedAuthorProfileUrls,
|
|
87
|
+
excludedAuthorNames: input.excludedAuthorNames,
|
|
88
|
+
targetPreparedMessages: input.targetPreparedMessages,
|
|
89
|
+
maxRowsToCheck: input.maxRowsToCheck,
|
|
90
|
+
batchSize: input.batchSize,
|
|
91
|
+
});
|
|
92
|
+
}
|
|
@@ -9,6 +9,7 @@ type StartPrepareMessagesInput = PrepareMessagesBaseInput & {
|
|
|
9
9
|
targetPreparedMessages?: number;
|
|
10
10
|
maxRowsToCheck?: number;
|
|
11
11
|
batchSize?: number;
|
|
12
|
+
maxBatchRows?: number;
|
|
12
13
|
approvalMode?: ApprovalMode;
|
|
13
14
|
autoContinue?: boolean;
|
|
14
15
|
disableLowPassRateStop?: boolean;
|
|
@@ -45,6 +46,12 @@ export declare const campaignMessagePreparationToolDefinitions: ({
|
|
|
45
46
|
maximum: number;
|
|
46
47
|
description: string;
|
|
47
48
|
};
|
|
49
|
+
maxBatchRows: {
|
|
50
|
+
type: string;
|
|
51
|
+
minimum: number;
|
|
52
|
+
maximum: number;
|
|
53
|
+
description: string;
|
|
54
|
+
};
|
|
48
55
|
approvalMode: {
|
|
49
56
|
type: string;
|
|
50
57
|
enum: string[];
|
|
@@ -81,6 +88,7 @@ export declare const campaignMessagePreparationToolDefinitions: ({
|
|
|
81
88
|
targetPreparedMessages?: undefined;
|
|
82
89
|
maxRowsToCheck?: undefined;
|
|
83
90
|
batchSize?: undefined;
|
|
91
|
+
maxBatchRows?: undefined;
|
|
84
92
|
approvalMode?: undefined;
|
|
85
93
|
autoContinue?: undefined;
|
|
86
94
|
disableLowPassRateStop?: undefined;
|
|
@@ -6,7 +6,7 @@ async function postPrepareMessages(body) {
|
|
|
6
6
|
export const campaignMessagePreparationToolDefinitions = [
|
|
7
7
|
{
|
|
8
8
|
name: "start_campaign_message_preparation",
|
|
9
|
-
description: 'Start a bounded
|
|
9
|
+
description: 'Start a bounded message-preparation job for a specific existing CampaignOffer campaignId/tableId. This is the active_campaigns existing-row path after resolve_campaign_fill_route, exact target re-read, and active prep-job check; it is not campaign creation and not evergreen horizon fill. It never launches the campaign, sends messages, or directly writes scheduledFor. The job queues pending Enrich Prospect cells first, lets ICP/rubric and Generate Message cascade, then marks ready or approves only the bounded cohort. Prepared/approved/ready rows are intermediate only; scheduled completion requires a later re-read proving scheduler-owned scheduled cells with non-null scheduledFor. Surface active preparation jobs, exhausted source rows, disconnected Sales Nav/deleted sender accounts, missing sequence state, and other sender-health blockers separately from prepared/approved/scheduled counts. Omit maxRowsToCheck and batchSize for the adaptive default: calibrate on at least 100 actually-enriched rows, estimate the row budget from observed rubric/pass yield, cap rows at 300, and process at most 100 newly checked rows at a time. The worker will not pull another row batch while the current checked batch still has queueable or active cells. Do not interpret checkedRows as enriched rows; use progress.enrichedRows, needsEnrichRows, activeCellCount, preparedMessages, approvedMessages, and stopReason.',
|
|
10
10
|
inputSchema: {
|
|
11
11
|
type: "object",
|
|
12
12
|
properties: {
|
|
@@ -19,19 +19,25 @@ export const campaignMessagePreparationToolDefinitions = [
|
|
|
19
19
|
maxRowsToCheck: {
|
|
20
20
|
type: "number",
|
|
21
21
|
minimum: 1,
|
|
22
|
-
maximum:
|
|
23
|
-
description: "Optional override capped by the backend at
|
|
22
|
+
maximum: 300,
|
|
23
|
+
description: "Optional override capped by the backend at 300. Omit this for adaptive sample-based row budgeting.",
|
|
24
24
|
},
|
|
25
25
|
batchSize: {
|
|
26
26
|
type: "number",
|
|
27
27
|
minimum: 1,
|
|
28
|
-
maximum:
|
|
29
|
-
description: "Optional first-batch override capped by the backend at
|
|
28
|
+
maximum: 100,
|
|
29
|
+
description: "Optional first-batch override capped by the backend at 100. Omit this to sample 100 rows.",
|
|
30
|
+
},
|
|
31
|
+
maxBatchRows: {
|
|
32
|
+
type: "number",
|
|
33
|
+
minimum: 1,
|
|
34
|
+
maximum: 100,
|
|
35
|
+
description: "Optional max rows to add in any single preparation batch. Capped by the backend at 100.",
|
|
30
36
|
},
|
|
31
37
|
approvalMode: {
|
|
32
38
|
type: "string",
|
|
33
39
|
enum: ["mark_ready", "approve"],
|
|
34
|
-
description: "Defaults to mark_ready. Use approve only when the user explicitly asks to flip Approved cells.",
|
|
40
|
+
description: "Defaults to mark_ready. Use approve only when the user explicitly asks to flip Approved cells. Approval is not scheduling; it only makes the bounded cohort eligible for downstream scheduler ownership.",
|
|
35
41
|
},
|
|
36
42
|
autoContinue: { type: "boolean" },
|
|
37
43
|
disableLowPassRateStop: {
|
|
@@ -78,6 +84,7 @@ export function startPrepareCampaignMessages(input) {
|
|
|
78
84
|
targetPreparedMessages: input.targetPreparedMessages,
|
|
79
85
|
maxRowsToCheck: input.maxRowsToCheck,
|
|
80
86
|
batchSize: input.batchSize,
|
|
87
|
+
maxBatchRows: input.maxBatchRows,
|
|
81
88
|
approvalMode: input.approvalMode,
|
|
82
89
|
autoContinue: input.autoContinue,
|
|
83
90
|
disableLowPassRateStop: input.disableLowPassRateStop,
|
package/dist/tools/campaigns.js
CHANGED
|
@@ -441,7 +441,7 @@ export const campaignToolDefinitions = [
|
|
|
441
441
|
},
|
|
442
442
|
{
|
|
443
443
|
name: "start_campaign",
|
|
444
|
-
description: "Start a paused campaign, enabling the sweeper to send messages.",
|
|
444
|
+
description: "Start a paused campaign, enabling the sweeper to send messages. This is an explicit human launch/start action and must not be used as part of fill-send-horizon, message preparation, or scheduling-proof flows.",
|
|
445
445
|
inputSchema: {
|
|
446
446
|
type: "object",
|
|
447
447
|
properties: {
|
package/dist/tools/prompts.js
CHANGED
|
@@ -371,7 +371,7 @@ export function getPostFindLeadsScoutRegistry() {
|
|
|
371
371
|
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.',
|
|
372
372
|
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.",
|
|
373
373
|
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.',
|
|
374
|
-
prepareMessagesRule:
|
|
374
|
+
prepareMessagesRule: `Default create-campaign stays on the existing reviewBatchLimit:15 first campaign-table execution slice. For plain post-mint fill/load/refill requests, first call refill_campaign_sends({ mode:"plan", intent:"plain" }). Plain fill is not an alias for fill_campaign_horizon or campaign creation. If no --yolo is present, report the plan and stop. If --yolo is present, call plan first, inspect blockers, then call refill_campaign_sends({ mode:"apply", yolo:true, planRevision, actionIds }) using only selected immutable actionIds from the fresh plan. Use resolve_campaign_fill_route, fill_campaign_horizon, and start_campaign_message_preparation only as fallback/lower-level diagnostics when refill_campaign_sends is unavailable or when the refill command returns an evergreen subplan. fill_campaign_horizon is evergreen-only and is not the generic regular-campaign fill path. Treat "fill up/load sends" as capacity-fill preparation: calculate the bounded target from sender capacity when needed, then let the command plan source, enrichment, ICP/rubric, Generate Message propagation, approval/ready state, scheduler reread, and blockers. 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. For "approve X messages", use approvalMode:approve only when explicitly requested, but still do not launch. For "schedule X sends" or "fill sender sends", approve only when explicitly requested, then re-read campaign/table scheduled counts; if scheduler-owned scheduledFor cells are not present, report prepared/approved/ready - awaiting scheduler instead of success. Do not call start_campaign as part of refill sends. Launch/start is a separate explicit human action after the operator intentionally wants sends to go out, and it must still verify that the bounded cohort is the only approved cohort and must not broad approve-all. campaignId is CampaignOffer.id. If the user asks to stop preparation, the target is wrong, or status shows the wrong campaign/table, use cancel_campaign_message_preparation only for the exact active job. Low-level selectors are diagnostics and recovery only for this lane. start_campaign remains forbidden until explicit launch/start approval outside refill sends.`,
|
|
375
375
|
},
|
|
376
376
|
};
|
|
377
377
|
}
|