@sellable/mcp 0.1.555 → 0.1.557

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.
Files changed (63) hide show
  1. package/README.md +13 -2
  2. package/agents/registry.json +2 -2
  3. package/dist/api.js +3 -6
  4. package/dist/auth.d.ts +0 -6
  5. package/dist/auth.js +2 -44
  6. package/dist/refill-run-client.d.ts +0 -5
  7. package/dist/refill-run-client.js +0 -15
  8. package/dist/refill-run-loop.d.ts +1 -12
  9. package/dist/refill-run-loop.js +13 -158
  10. package/dist/server.js +23 -0
  11. package/dist/tools/auth.d.ts +0 -5
  12. package/dist/tools/auth.js +12 -49
  13. package/dist/tools/campaign-message-preparation.d.ts +0 -62
  14. package/dist/tools/campaign-message-preparation.js +0 -41
  15. package/dist/tools/campaigns.js +2 -2
  16. package/dist/tools/csv-dnc.js +2 -2
  17. package/dist/tools/evergreen-refill-plan.d.ts +0 -3
  18. package/dist/tools/evergreen-refill-plan.js +7 -29
  19. package/dist/tools/find-leads-runs.d.ts +151 -0
  20. package/dist/tools/find-leads-runs.js +98 -0
  21. package/dist/tools/leads.d.ts +317 -32
  22. package/dist/tools/leads.js +171 -10
  23. package/dist/tools/model-quality.js +4 -6
  24. package/dist/tools/prompts.d.ts +3 -3
  25. package/dist/tools/prompts.js +7 -15
  26. package/dist/tools/provider-preflight.d.ts +65 -2
  27. package/dist/tools/provider-preflight.js +97 -10
  28. package/dist/tools/readiness.d.ts +89 -5
  29. package/dist/tools/readiness.js +66 -0
  30. package/dist/tools/refill-executors.d.ts +0 -38
  31. package/dist/tools/refill-executors.js +3 -222
  32. package/dist/tools/refill-sends-v2.d.ts +1 -112
  33. package/dist/tools/refill-sends-v2.js +2 -302
  34. package/dist/tools/refill-sends.d.ts +32 -678
  35. package/dist/tools/refill-sends.js +13 -274
  36. package/dist/tools/refill-target-plan.js +14 -486
  37. package/dist/tools/registry.d.ts +330 -115
  38. package/dist/tools/registry.js +7 -1
  39. package/dist/tools/scheduler-fill-capacity.js +1 -1
  40. package/dist/tools/scheduler-run.d.ts +0 -71
  41. package/dist/tools/scheduler-run.js +1 -203
  42. package/dist/tools/setup-evergreen-campaigns.js +1 -1
  43. package/dist/tools/workspace-context.d.ts +1 -1
  44. package/dist/tools/workspace-context.js +3 -8
  45. package/dist/tools/workspace-export.js +2 -2
  46. package/dist/tools/workspaces.d.ts +2 -48
  47. package/dist/tools/workspaces.js +5 -48
  48. package/package.json +1 -1
  49. package/skills/create-campaign/SKILL.md +3 -3
  50. package/skills/create-campaign-v2/SKILL.md +1 -1
  51. package/skills/create-evergreen-campaigns/SKILL.md +16 -16
  52. package/skills/find-leads/SKILL.md +48 -630
  53. package/skills/find-leads-v2/SKILL.md +70 -0
  54. package/skills/find-leads-v2/core/flow.v1.json +31 -0
  55. package/skills/refill-sends/SKILL.md +353 -91
  56. package/skills/refill-sends-v2/SKILL.md +6 -6
  57. package/skills/refill-sends-v2-workflow/SKILL.md +5 -5
  58. package/skills/refill-sends-v2-workflow/core/flow.v1.json +8 -8
  59. package/skills/refill-sends-workflow/SKILL.md +743 -100
  60. package/skills/refill-sends-workflow/core/flow.v1.json +1 -185
  61. package/dist/refill-contract.d.ts +0 -157
  62. package/dist/refill-contract.js +0 -487
  63. package/skills/refill-sends-workflow/core/contract.v2.json +0 -543
@@ -1,487 +0,0 @@
1
- import { createHash } from "node:crypto";
2
- export const REFILL_CONTRACT_VERSION = "2.0.0";
3
- export const REFILL_CONTRACT_CACHE_VERSION = "refill-contract-v1";
4
- export const REFILL_CONTRACT_SUPPORTED_MAJOR = 2;
5
- export const REFILL_CONTRACT_ERROR_CODES = [
6
- "refill_contract_not_implemented",
7
- "unsupported_refill_contract_major",
8
- "refill_contract_hash_mismatch",
9
- "refill_contract_semantic_mismatch",
10
- ];
11
- export class RefillContractError extends Error {
12
- code;
13
- constructor(code, message) {
14
- super(message);
15
- this.code = code;
16
- this.name = "RefillContractError";
17
- }
18
- }
19
- export const REFILL_SCOPE_IDS = [
20
- "workspace_id",
21
- "target_date",
22
- "sender_selectors",
23
- "campaign_selectors",
24
- "approval_mode",
25
- "contract_identity",
26
- "installed_identity",
27
- ];
28
- export const REFILL_GATE_IDS = [
29
- "workspace_access",
30
- "approval_packet",
31
- "source_family",
32
- "threshold",
33
- "scheduler",
34
- "campaign_lifecycle",
35
- "send_time",
36
- "no_direct_send",
37
- "one_primitive",
38
- "fresh_reread",
39
- "normalized_accounting",
40
- "prep_circuit",
41
- "terminal_truth",
42
- ];
43
- export const REFILL_STATE_IDS = [
44
- "planning",
45
- "awaiting_approval",
46
- "executing",
47
- "settling",
48
- "replanning",
49
- "terminal",
50
- ];
51
- export const REFILL_ACTION_IDS = [
52
- "prepare_messages",
53
- "approve_messages",
54
- "rerun_errored_cells",
55
- "start_paused_campaign",
56
- "run_scheduler_sweep",
57
- "scheduler_first_settle",
58
- "wait_for_scheduler",
59
- "wait_for_active_work",
60
- "wait_for_source_import",
61
- "copy_selected_source_rows",
62
- "continue_signal_discovery_source",
63
- "continue_sales_nav_source",
64
- "continue_prospeo_source",
65
- "manual_source_replenishment",
66
- "refresh_paid_inmail_credits",
67
- "lower_paid_inmail_threshold",
68
- "switch_to_connection_lane",
69
- "create_connection_campaign",
70
- "next_campaign",
71
- "done",
72
- ];
73
- export const REFILL_RECEIPT_IDS = [
74
- "target_plan_receipt",
75
- "preparation_receipt",
76
- "scheduler_receipt",
77
- "run_receipt",
78
- ];
79
- export const REFILL_SIDE_EFFECT_CLASS_IDS = [
80
- "read_only",
81
- "message_preparation",
82
- "message_approval",
83
- "source_replenishment",
84
- "credit_refresh",
85
- "campaign_start",
86
- "scheduler_placement",
87
- ];
88
- export const REFILL_FORBIDDEN_ACTION_IDS = [
89
- "direct_send",
90
- "raw_scheduler_write",
91
- "campaign_create",
92
- "campaign_archive_delete",
93
- "threshold_lowering",
94
- "unselected_source_mutation",
95
- "unapproved_campaign_start",
96
- "sender_config_write",
97
- ];
98
- export const REFILL_TERMINAL_REASON_IDS = [
99
- "projected_full",
100
- "concrete_blocker",
101
- "deadline_reached",
102
- "iteration_limit",
103
- "operator_stopped",
104
- "capped_by_scheduler",
105
- "loaded_awaiting_scheduler",
106
- "lanes_exhausted",
107
- "not_an_evergreen_workspace",
108
- "no_refillable_campaigns",
109
- ];
110
- const plannerActions = [...REFILL_ACTION_IDS];
111
- const plannerReceiptFields = [
112
- "refillLaneKey",
113
- "branchMetrics",
114
- "ledger",
115
- "targetDate",
116
- "actionKey",
117
- "targetShapeRevision",
118
- "stateRevision",
119
- ];
120
- const preparationDependencyClasses = [
121
- "active",
122
- "transient",
123
- "permanent",
124
- "changed",
125
- "exhausted",
126
- ];
127
- const preparationDependencyReasons = [
128
- "active_cells",
129
- "dependency_timeout",
130
- "rate_limited",
131
- "provider_unavailable",
132
- "authentication_failed",
133
- "validation_failed",
134
- "schema_invalid",
135
- "config_epoch_changed",
136
- "source_epoch_changed",
137
- "frontier_exhausted",
138
- "unknown_dependency",
139
- ];
140
- const preparationCircuitStates = [
141
- "closed",
142
- "open",
143
- "half_open",
144
- "reset",
145
- ];
146
- const preparationCooperativeStopReasons = [
147
- "target_satisfied_during_prep",
148
- ];
149
- const preparationReceiptFields = [
150
- "dependency",
151
- "circuit",
152
- "batchCalibration",
153
- "cooperativeStop",
154
- ];
155
- const schedulerTargetOutcomes = ["included", "omitted"];
156
- const schedulerOmissionReasons = [
157
- "no_ready_cells",
158
- "not_scheduler_eligible",
159
- "sender_mismatch",
160
- "capacity_prefiltered",
161
- "outside_target_date",
162
- "receipt_error",
163
- ];
164
- const schedulerRunStatuses = [
165
- "ran",
166
- "window_closed_noop",
167
- "failed",
168
- ];
169
- const schedulerNextActions = [
170
- "refresh_paid_inmail_credits_then_rerun",
171
- "wait_for_capacity_or_window",
172
- "inspect_sender_mismatch",
173
- "no_ready_cells_continue_refill_prep",
174
- "scheduled_cells",
175
- "investigate_deferred_reasons",
176
- "investigate_scheduler_failure",
177
- ];
178
- const schedulerReceiptFields = [
179
- "receiptVersion",
180
- "diagnosticsVersion",
181
- "status",
182
- "trigger",
183
- "workspaceId",
184
- "runId",
185
- "leaseFence",
186
- "expectedTargetsHash",
187
- "maxPlacements",
188
- "readyCellsFound",
189
- "cellsConsidered",
190
- "cellsScheduled",
191
- "cellsSkipped",
192
- "cellsDeferred",
193
- "campaignScopeSummary",
194
- "expectedTargetSummary",
195
- "changedCounts",
196
- "summary",
197
- "nextAction",
198
- "errorCount",
199
- "error",
200
- ];
201
- const runGates = [
202
- "g0_bootstrap",
203
- "g1_plan",
204
- "g2_execute",
205
- "g3_verify",
206
- "g4_terminal",
207
- ];
208
- const runResultKinds = [
209
- "started",
210
- "awaiting_approval",
211
- "active_run_in_progress",
212
- "resumed",
213
- "lease_lost",
214
- "scope_drift",
215
- "approval_expired",
216
- "approval_fingerprint_mismatch",
217
- ];
218
- const runTerminalReasons = [
219
- "complete",
220
- "capped_by_scheduler",
221
- "loaded_awaiting_scheduler",
222
- "lanes_exhausted",
223
- "blocked",
224
- "not_an_evergreen_workspace",
225
- "no_refillable_campaigns",
226
- ];
227
- const runRefusals = [
228
- "scope_drift",
229
- "approval_expired",
230
- "approval_fingerprint_mismatch",
231
- "legacy_read_only",
232
- "expected_target_overflow",
233
- "scheduler_receipt_incomplete",
234
- ];
235
- const runScopeFields = [
236
- "workspaceId",
237
- "intent",
238
- "senderIds",
239
- "campaignIds",
240
- "tableIds",
241
- "actionIds",
242
- "approvalMode",
243
- "dateSelector",
244
- "senderTimezones",
245
- "expectedTargetsHash",
246
- "maxPlacements",
247
- "contract",
248
- "installed",
249
- ];
250
- const runApprovalFields = [
251
- "scopeHash",
252
- "targetShapeRevision",
253
- "actionFingerprint",
254
- "expectedTargetsHash",
255
- "sideEffectEnvelope",
256
- "maxPlacements",
257
- "approvalExpiresAt",
258
- "approvalFingerprint",
259
- ];
260
- const actionSideEffects = {
261
- prepare_messages: "message_preparation",
262
- approve_messages: "message_approval",
263
- rerun_errored_cells: "message_preparation",
264
- start_paused_campaign: "campaign_start",
265
- run_scheduler_sweep: "scheduler_placement",
266
- scheduler_first_settle: "read_only",
267
- wait_for_scheduler: "read_only",
268
- wait_for_active_work: "read_only",
269
- wait_for_source_import: "read_only",
270
- copy_selected_source_rows: "source_replenishment",
271
- continue_signal_discovery_source: "source_replenishment",
272
- continue_sales_nav_source: "source_replenishment",
273
- continue_prospeo_source: "source_replenishment",
274
- manual_source_replenishment: "source_replenishment",
275
- refresh_paid_inmail_credits: "credit_refresh",
276
- lower_paid_inmail_threshold: "read_only",
277
- switch_to_connection_lane: "read_only",
278
- create_connection_campaign: "read_only",
279
- next_campaign: "read_only",
280
- done: "read_only",
281
- };
282
- const semanticContract = {
283
- scope: REFILL_SCOPE_IDS.map((id) => ({ id })),
284
- gates: REFILL_GATE_IDS.map((id) => ({ id })),
285
- states: REFILL_STATE_IDS.map((id) => ({ id })),
286
- actions: REFILL_ACTION_IDS.map((id) => ({
287
- id,
288
- sideEffectClass: actionSideEffects[id],
289
- })),
290
- receipts: [
291
- { id: "target_plan_receipt", requiredFields: plannerReceiptFields },
292
- { id: "preparation_receipt", requiredFields: preparationReceiptFields },
293
- { id: "scheduler_receipt", requiredFields: schedulerReceiptFields },
294
- {
295
- id: "run_receipt",
296
- requiredFields: [
297
- "runId",
298
- "fence",
299
- "gate",
300
- "gateSeq",
301
- "events",
302
- "doneReason",
303
- ],
304
- },
305
- ],
306
- sideEffectClasses: REFILL_SIDE_EFFECT_CLASS_IDS.map((id) => ({ id })),
307
- forbiddenActions: REFILL_FORBIDDEN_ACTION_IDS.map((id) => ({ id })),
308
- terminalReasons: REFILL_TERMINAL_REASON_IDS.map((id) => ({
309
- id,
310
- terminalKind: id === "projected_full" ? "complete" : "stopped",
311
- })),
312
- transitions: [
313
- { from: "planning", to: "awaiting_approval" },
314
- { from: "awaiting_approval", to: "executing" },
315
- { from: "executing", to: "settling" },
316
- { from: "settling", to: "replanning" },
317
- { from: "replanning", to: "executing" },
318
- { from: "replanning", to: "terminal" },
319
- ],
320
- };
321
- const backendBindings = {
322
- planner: {
323
- actions: plannerActions,
324
- receiptFields: plannerReceiptFields,
325
- },
326
- preparation: {
327
- dependencyClasses: preparationDependencyClasses,
328
- dependencyReasons: preparationDependencyReasons,
329
- circuitStates: preparationCircuitStates,
330
- cooperativeStopReasons: preparationCooperativeStopReasons,
331
- receiptFields: preparationReceiptFields,
332
- },
333
- scheduler: {
334
- targetOutcomes: schedulerTargetOutcomes,
335
- omissionReasons: schedulerOmissionReasons,
336
- runStatuses: schedulerRunStatuses,
337
- nextActions: schedulerNextActions,
338
- receiptFields: schedulerReceiptFields,
339
- },
340
- run: {
341
- gates: runGates,
342
- states: REFILL_STATE_IDS,
343
- resultKinds: runResultKinds,
344
- terminalReasons: runTerminalReasons,
345
- refusals: runRefusals,
346
- scopeFields: runScopeFields,
347
- approvalFields: runApprovalFields,
348
- },
349
- };
350
- const contractWithoutHash = {
351
- contractVersion: REFILL_CONTRACT_VERSION,
352
- cacheVersion: REFILL_CONTRACT_CACHE_VERSION,
353
- supportedMajor: REFILL_CONTRACT_SUPPORTED_MAJOR,
354
- semantics: semanticContract,
355
- backendBindings,
356
- };
357
- function canonicalValue(value) {
358
- if (Array.isArray(value))
359
- return value.map(canonicalValue);
360
- if (value && typeof value === "object") {
361
- return Object.fromEntries(Object.entries(value)
362
- .filter(([key, entry]) => key !== "contractHash" &&
363
- key !== "releaseIdentities" &&
364
- entry !== undefined)
365
- .sort(([left], [right]) => left.localeCompare(right))
366
- .map(([key, entry]) => [key, canonicalValue(entry)]));
367
- }
368
- return value;
369
- }
370
- export function canonicalizeRefillContract(value) {
371
- return JSON.stringify(canonicalValue(value));
372
- }
373
- export function computeRefillContractHash(value) {
374
- return createHash("sha256")
375
- .update(canonicalizeRefillContract(value))
376
- .digest("hex");
377
- }
378
- export const REFILL_CONTRACT_HASH = computeRefillContractHash(contractWithoutHash);
379
- export const refillContract = {
380
- ...contractWithoutHash,
381
- contractHash: REFILL_CONTRACT_HASH,
382
- };
383
- function objectRecord(value, path) {
384
- if (!value || typeof value !== "object" || Array.isArray(value)) {
385
- throw new RefillContractError("refill_contract_semantic_mismatch", `${path} must be an object`);
386
- }
387
- return value;
388
- }
389
- function semanticDifference(path, actual, expected) {
390
- if (canonicalizeRefillContract(actual) === canonicalizeRefillContract(expected)) {
391
- return;
392
- }
393
- const actualIds = Array.isArray(actual)
394
- ? actual.map((entry) => typeof entry === "string"
395
- ? entry
396
- : String(entry?.id ?? ""))
397
- : [];
398
- const expectedIds = Array.isArray(expected)
399
- ? expected.map((entry) => typeof entry === "string"
400
- ? entry
401
- : String(entry?.id ?? ""))
402
- : [];
403
- const missing = expectedIds.filter((id) => !actualIds.includes(id));
404
- const extra = actualIds.filter((id) => !expectedIds.includes(id));
405
- const detail = [
406
- missing.length ? `missing=${missing.join(",")}` : "",
407
- extra.length ? `extra=${extra.join(",")}` : "",
408
- ]
409
- .filter(Boolean)
410
- .join(" ");
411
- throw new RefillContractError("refill_contract_semantic_mismatch", `${path} differs from the canonical refill contract${detail ? `: ${detail}` : ""}`);
412
- }
413
- export function assertSupportedRefillContractMajor(version) {
414
- const major = Number.parseInt(version.split(".")[0] ?? "", 10);
415
- if (major !== REFILL_CONTRACT_SUPPORTED_MAJOR) {
416
- throw new RefillContractError("unsupported_refill_contract_major", `unsupported_refill_contract_major: expected ${REFILL_CONTRACT_SUPPORTED_MAJOR}, received ${version}`);
417
- }
418
- }
419
- export function validateRefillContractAsset(value) {
420
- const record = objectRecord(value, "contract");
421
- const version = String(record.contractVersion ?? "");
422
- assertSupportedRefillContractMajor(version);
423
- if (version !== REFILL_CONTRACT_VERSION) {
424
- throw new RefillContractError("refill_contract_semantic_mismatch", `contractVersion differs: expected ${REFILL_CONTRACT_VERSION}, received ${version}`);
425
- }
426
- if (record.cacheVersion !== REFILL_CONTRACT_CACHE_VERSION) {
427
- throw new RefillContractError("refill_contract_semantic_mismatch", `cacheVersion differs: expected ${REFILL_CONTRACT_CACHE_VERSION}, received ${String(record.cacheVersion)}`);
428
- }
429
- const semantics = objectRecord(record.semantics, "semantics");
430
- for (const [family, expected] of Object.entries(refillContract.semantics)) {
431
- semanticDifference(`semantics.${family}`, semantics[family], expected);
432
- }
433
- semanticDifference("backendBindings", record.backendBindings, refillContract.backendBindings);
434
- const computedHash = computeRefillContractHash(record);
435
- if (record.contractHash !== computedHash) {
436
- throw new RefillContractError("refill_contract_hash_mismatch", `refill_contract_hash_mismatch: expected ${computedHash}, received ${String(record.contractHash)}`);
437
- }
438
- return value;
439
- }
440
- export function refillContractSemanticProjection() {
441
- return {
442
- contractVersion: REFILL_CONTRACT_VERSION,
443
- cacheVersion: REFILL_CONTRACT_CACHE_VERSION,
444
- contractHash: REFILL_CONTRACT_HASH,
445
- semanticIds: Object.fromEntries(Object.entries(refillContract.semantics)
446
- .filter(([, entries]) => Array.isArray(entries))
447
- .map(([family, entries]) => [
448
- family,
449
- entries.map((entry) => typeof entry === "string"
450
- ? entry
451
- : String(entry.id ?? "")),
452
- ])),
453
- };
454
- }
455
- export function validateRefillFlowProjection(value) {
456
- const flow = objectRecord(value, "flow");
457
- const projection = objectRecord(flow.refillContract, "flow.refillContract");
458
- semanticDifference("flow.refillContract", projection, refillContractSemanticProjection());
459
- }
460
- function renderIds(label, ids) {
461
- return `${label}: ${ids.join(", ")}`;
462
- }
463
- export function renderRefillBootstrapGuidance() {
464
- return [
465
- renderIds("scope", REFILL_SCOPE_IDS),
466
- renderIds("gates", [
467
- "approval_packet",
468
- "one_primitive",
469
- "fresh_reread",
470
- "normalized_accounting",
471
- "prep_circuit",
472
- ]),
473
- "release identities (independent of semantic hash): mcpPackageVersion, installPackageVersion, codexPluginVersion",
474
- ].join("\n");
475
- }
476
- export function renderRefillSafetyGuidance() {
477
- return renderIds("forbidden", REFILL_FORBIDDEN_ACTION_IDS);
478
- }
479
- export function renderRefillTerminalGuidance() {
480
- return [
481
- renderIds("terminal", REFILL_TERMINAL_REASON_IDS),
482
- "ready_buffer_exists_is_not_complete",
483
- ].join("\n");
484
- }
485
- export function assertNeverRefillVariant(value) {
486
- throw new RefillContractError("refill_contract_semantic_mismatch", `Unhandled refill contract variant: ${String(value)}`);
487
- }