@sellable/mcp 0.1.552 → 0.1.553

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.
@@ -134,6 +134,36 @@ export declare function sleep(ms: number): Promise<unknown>;
134
134
  export declare function recordValue(value: unknown): Record<string, unknown> | null;
135
135
  export declare function stringValue(value: unknown): string | null;
136
136
  export declare function numberValue(value: unknown): number | null;
137
+ export type SchedulerChangedCount = {
138
+ campaignId: string;
139
+ tableId: string;
140
+ actionType: string;
141
+ count: number;
142
+ };
143
+ export type SchedulerChangedCounts = {
144
+ complete: true;
145
+ truncated: false;
146
+ total: number;
147
+ byCampaignTableActionType: SchedulerChangedCount[];
148
+ };
149
+ export declare function normalizeSchedulerChangedCounts(value: unknown): SchedulerChangedCounts | null;
150
+ export declare function normalizeSchedulerPrimitiveResult(value: unknown): {
151
+ status: "scheduler_receipt_incomplete";
152
+ schedulerStatus: string;
153
+ receipt: {} | null;
154
+ retryAfterMs: number | null;
155
+ changedCounts: null;
156
+ auditComplete: false;
157
+ blocker: "scheduler_receipt_incomplete";
158
+ } | {
159
+ status: string;
160
+ receipt: {} | null;
161
+ retryAfterMs: number | null;
162
+ changedCounts: SchedulerChangedCounts;
163
+ auditComplete: true;
164
+ schedulerStatus?: undefined;
165
+ blocker?: undefined;
166
+ };
137
167
  export declare function stringArray(value: unknown): string[];
138
168
  export declare function prepareRowSelectorValue(value: unknown): PrepareRowSelector | undefined;
139
169
  export declare function uniqueStrings(values: Array<string | null | undefined>): string[];
@@ -3,6 +3,7 @@ import { startPrepareCampaignMessages } from "./campaign-message-preparation.js"
3
3
  import { startCampaign } from "./campaigns.js";
4
4
  import { confirmLeadList, importLeads, searchSignals, selectPromisingPosts, } from "./leads.js";
5
5
  import { markProviderPromptLoaded } from "./provider-preflight.js";
6
+ import { runSchedulerSweep } from "./scheduler-run.js";
6
7
  import { refreshPaidInmailCredits } from "./senders.js";
7
8
  import { workspaceRequestOptions } from "./workspace-context.js";
8
9
  const PAID_INMAIL_REFRESH_MAX_ATTEMPTS = 3;
@@ -40,6 +41,92 @@ export function stringValue(value) {
40
41
  export function numberValue(value) {
41
42
  return typeof value === "number" && Number.isFinite(value) ? value : null;
42
43
  }
44
+ export function normalizeSchedulerChangedCounts(value) {
45
+ const changedCounts = recordValue(value);
46
+ if (!changedCounts ||
47
+ changedCounts.complete !== true ||
48
+ changedCounts.truncated !== false) {
49
+ return null;
50
+ }
51
+ const total = numberValue(changedCounts.total);
52
+ if (total === null || total < 0 || !Number.isInteger(total))
53
+ return null;
54
+ if (!Array.isArray(changedCounts.byCampaignTableActionType))
55
+ return null;
56
+ const groups = [];
57
+ const seen = new Set();
58
+ for (const rawGroup of changedCounts.byCampaignTableActionType) {
59
+ const group = recordValue(rawGroup);
60
+ const campaignId = stringValue(group?.campaignId);
61
+ const tableId = stringValue(group?.tableId);
62
+ const actionType = stringValue(group?.actionType);
63
+ const count = numberValue(group?.count);
64
+ if (!campaignId ||
65
+ !tableId ||
66
+ !actionType ||
67
+ count === null ||
68
+ count <= 0 ||
69
+ !Number.isInteger(count)) {
70
+ return null;
71
+ }
72
+ const key = `${campaignId}:${tableId}:${actionType}`;
73
+ if (seen.has(key))
74
+ return null;
75
+ seen.add(key);
76
+ groups.push({ campaignId, tableId, actionType, count });
77
+ }
78
+ groups.sort((a, b) => {
79
+ if (a.campaignId !== b.campaignId) {
80
+ return a.campaignId.localeCompare(b.campaignId);
81
+ }
82
+ if (a.tableId !== b.tableId)
83
+ return a.tableId.localeCompare(b.tableId);
84
+ return a.actionType.localeCompare(b.actionType);
85
+ });
86
+ if (groups.reduce((sum, group) => sum + group.count, 0) !== total) {
87
+ return null;
88
+ }
89
+ return {
90
+ complete: true,
91
+ truncated: false,
92
+ total,
93
+ byCampaignTableActionType: groups,
94
+ };
95
+ }
96
+ export function normalizeSchedulerPrimitiveResult(value) {
97
+ const response = recordValue(value);
98
+ const receipt = recordValue(response?.receipt);
99
+ const changedCounts = normalizeSchedulerChangedCounts(receipt?.changedCounts ?? response?.changedCounts);
100
+ const schedulerStatus = stringValue(response?.status) ?? stringValue(receipt?.status) ?? "unknown";
101
+ if (!changedCounts) {
102
+ return {
103
+ status: "scheduler_receipt_incomplete",
104
+ schedulerStatus,
105
+ receipt: response?.receipt ?? null,
106
+ retryAfterMs: numberValue(response?.retryAfterMs),
107
+ changedCounts: null,
108
+ auditComplete: false,
109
+ blocker: "scheduler_receipt_incomplete",
110
+ };
111
+ }
112
+ return {
113
+ status: schedulerStatus,
114
+ receipt: response?.receipt ?? null,
115
+ retryAfterMs: numberValue(response?.retryAfterMs),
116
+ changedCounts,
117
+ auditComplete: true,
118
+ };
119
+ }
120
+ function exactDateValue(value) {
121
+ const targetDate = stringValue(value);
122
+ if (!targetDate || !/^\d{4}-\d{2}-\d{2}$/.test(targetDate))
123
+ return null;
124
+ const parsed = new Date(`${targetDate}T00:00:00.000Z`);
125
+ return !Number.isNaN(parsed.getTime()) &&
126
+ parsed.toISOString().slice(0, 10) === targetDate
127
+ ? targetDate
128
+ : null;
129
+ }
43
130
  export function stringArray(value) {
44
131
  if (!Array.isArray(value))
45
132
  return [];
@@ -770,6 +857,45 @@ export async function executeOneYoloPrimitive(action, workspaceId) {
770
857
  case "wait_for_active_work":
771
858
  case "wait_for_source_import":
772
859
  return { status: "read_only_reread", result: waitResultForAction(action) };
860
+ case "run_scheduler_sweep": {
861
+ const toolInput = actionToolInput(action);
862
+ const actionWorkspaceId = stringValue(toolInput.workspaceId);
863
+ const targetDate = exactDateValue(toolInput.targetDate);
864
+ const targetDateKey = exactDateValue(toolInput.targetDateKey);
865
+ const actionKey = stringValue(action.actionKey);
866
+ const requestKey = stringValue(toolInput.requestKey);
867
+ const targetShapeRevision = stringValue(toolInput.targetShapeRevision);
868
+ const receiptRequirements = recordValue(action.receiptRequirements);
869
+ const receiptGroups = stringArray(receiptRequirements?.groupBy);
870
+ if (!workspaceId ||
871
+ !actionWorkspaceId ||
872
+ actionWorkspaceId !== workspaceId ||
873
+ toolInput.action !== "run" ||
874
+ !targetDate ||
875
+ targetDateKey !== targetDate ||
876
+ !actionKey ||
877
+ requestKey !== actionKey ||
878
+ !targetShapeRevision ||
879
+ action.workspaceWide !== true ||
880
+ receiptRequirements?.nonTruncated !== true ||
881
+ receiptGroups.join(":") !== "campaignId:tableId:actionType") {
882
+ return {
883
+ status: "refused",
884
+ refusalReason: "run_scheduler_sweep action is missing exact workspace/date/revision scope or complete receipt requirements",
885
+ };
886
+ }
887
+ const result = await runSchedulerSweep({
888
+ workspaceId,
889
+ action: "run",
890
+ targetDate,
891
+ requestKey,
892
+ targetShapeRevision,
893
+ });
894
+ return {
895
+ status: "executed_and_reread",
896
+ result: normalizeSchedulerPrimitiveResult(result),
897
+ };
898
+ }
773
899
  case "prepare_messages": {
774
900
  const campaignId = actionCampaignId(action);
775
901
  const tableId = actionTableId(action) ?? undefined;
@@ -1,6 +1,8 @@
1
1
  type RefillSendsIntent = "plain" | "active" | "evergreen";
2
2
  type RefillSendsApprovalMode = "approve" | "mark_ready";
3
3
  type RefillSendsExecutionMode = "manual" | "scheduled" | "yolo";
4
+ declare const REFILL_SEND_ACTION_TYPES: readonly ["send_invite", "send_inmail_closed"];
5
+ type RefillSendsActionType = (typeof REFILL_SEND_ACTION_TYPES)[number];
4
6
  type RefillSendsCommandInput = {
5
7
  yolo?: boolean;
6
8
  executionMode?: RefillSendsExecutionMode;
@@ -16,6 +18,9 @@ type RefillSendsCommandInput = {
16
18
  tableId?: string;
17
19
  intent?: RefillSendsIntent;
18
20
  approvalMode?: RefillSendsApprovalMode;
21
+ actionTypes?: RefillSendsActionType[];
22
+ expectedTargetShapeRevision?: string;
23
+ expectedActionKey?: string;
19
24
  };
20
25
  type PaidInmailRefreshApprovalPacket = {
21
26
  approvalSource: "explicit_yolo_flag";
@@ -74,6 +79,14 @@ export declare const refillSendsToolDefinitions: {
74
79
  };
75
80
  description: string;
76
81
  };
82
+ actionTypes: {
83
+ type: string;
84
+ items: {
85
+ type: string;
86
+ enum: string[];
87
+ };
88
+ description: string;
89
+ };
77
90
  horizonSendDays: {
78
91
  type: string;
79
92
  minimum: number;
@@ -108,25 +121,20 @@ export declare const refillSendsToolDefinitions: {
108
121
  enum: string[];
109
122
  description: string;
110
123
  };
124
+ expectedTargetShapeRevision: {
125
+ type: string;
126
+ description: string;
127
+ };
128
+ expectedActionKey: {
129
+ type: string;
130
+ description: string;
131
+ };
111
132
  };
112
133
  required: never[];
113
134
  additionalProperties: boolean;
114
135
  };
115
136
  }[];
116
137
  export declare function refillSendsCommand(input?: RefillSendsCommandInput): {
117
- command: string;
118
- tool: string;
119
- promptName: string;
120
- workflowPromptName: string;
121
- workflowAsset: {
122
- subskillName: string;
123
- assetPath: string;
124
- };
125
- yolo: boolean;
126
- executionMode: RefillSendsExecutionMode;
127
- workspaceId: string | null;
128
- workspaceResolution: string;
129
- intent: RefillSendsIntent;
130
138
  targetDate: string | null;
131
139
  untilDate: string | null;
132
140
  horizonSendDays: number | null;
@@ -170,10 +178,8 @@ export declare function refillSendsCommand(input?: RefillSendsCommandInput): {
170
178
  mcpTool: {
171
179
  name: string;
172
180
  arguments: {
173
- yolo: boolean;
174
- senders: string[];
175
- senderIds: string[];
176
- senderNames: string[];
181
+ expectedActionKey?: string | undefined;
182
+ expectedTargetShapeRevision?: string | undefined;
177
183
  targetDate: string | null;
178
184
  untilDate: string | null;
179
185
  horizonSendDays: number | null;
@@ -182,9 +188,28 @@ export declare function refillSendsCommand(input?: RefillSendsCommandInput): {
182
188
  intent: RefillSendsIntent;
183
189
  approvalMode: RefillSendsApprovalMode;
184
190
  workspaceId: string | null;
191
+ actionTypes?: ("send_invite" | "send_inmail_closed")[] | undefined;
192
+ yolo: boolean;
193
+ senders: string[];
194
+ senderIds: string[];
195
+ senderNames: string[];
185
196
  };
186
197
  };
187
198
  };
199
+ actionTypes?: ("send_invite" | "send_inmail_closed")[] | undefined;
200
+ command: string;
201
+ tool: string;
202
+ promptName: string;
203
+ workflowPromptName: string;
204
+ workflowAsset: {
205
+ subskillName: string;
206
+ assetPath: string;
207
+ };
208
+ yolo: boolean;
209
+ executionMode: RefillSendsExecutionMode;
210
+ workspaceId: string | null;
211
+ workspaceResolution: string;
212
+ intent: RefillSendsIntent;
188
213
  };
189
214
  export declare function executeRefillSendsCommand(input?: RefillSendsCommandInput): Promise<import("./workspace-context.js").WorkspaceRequiredResult | {
190
215
  autoPaidInmailRefresh: {
@@ -193,11 +218,11 @@ export declare function executeRefillSendsCommand(input?: RefillSendsCommandInpu
193
218
  refreshedPaidInmailSenderIds: never[];
194
219
  failedPaidInmailRefreshes: never[];
195
220
  note: string;
196
- refreshReceipts?: undefined;
197
221
  attemptedSenderIds?: undefined;
198
222
  targetPlanReread?: undefined;
199
223
  workspaceId?: undefined;
200
224
  workspaceResolution?: undefined;
225
+ refreshReceipts?: undefined;
201
226
  };
202
227
  yoloExecution: {
203
228
  enabled: false;
@@ -208,6 +233,68 @@ export declare function executeRefillSendsCommand(input?: RefillSendsCommandInpu
208
233
  refusalReason?: undefined;
209
234
  postActionFirstAction?: undefined;
210
235
  };
236
+ targetDate: string | null;
237
+ untilDate: string | null;
238
+ horizonSendDays: number | null;
239
+ fillWindow: {
240
+ mode: string;
241
+ targetDate: string;
242
+ description: string;
243
+ untilDate?: undefined;
244
+ horizonSendDays?: undefined;
245
+ horizonHours?: undefined;
246
+ } | {
247
+ mode: string;
248
+ untilDate: string;
249
+ description: string;
250
+ targetDate?: undefined;
251
+ horizonSendDays?: undefined;
252
+ horizonHours?: undefined;
253
+ } | {
254
+ mode: string;
255
+ horizonSendDays: number | null;
256
+ horizonHours: number | null;
257
+ description: string;
258
+ targetDate?: undefined;
259
+ untilDate?: undefined;
260
+ };
261
+ approvalMode: RefillSendsApprovalMode;
262
+ campaignId: string | null;
263
+ tableId: string | null;
264
+ senderScope: string;
265
+ senderSelectors: {
266
+ senders: string[];
267
+ senderIds: string[];
268
+ senderNames: string[];
269
+ };
270
+ firstOperationalSteps: string[];
271
+ approvalContract: string;
272
+ forbiddenActions: string[];
273
+ hostExamples: {
274
+ claude: string[];
275
+ codex: string[];
276
+ mcpTool: {
277
+ name: string;
278
+ arguments: {
279
+ expectedActionKey?: string | undefined;
280
+ expectedTargetShapeRevision?: string | undefined;
281
+ targetDate: string | null;
282
+ untilDate: string | null;
283
+ horizonSendDays: number | null;
284
+ campaignId: string | undefined;
285
+ tableId: string | undefined;
286
+ intent: RefillSendsIntent;
287
+ approvalMode: RefillSendsApprovalMode;
288
+ workspaceId: string | null;
289
+ actionTypes?: ("send_invite" | "send_inmail_closed")[] | undefined;
290
+ yolo: boolean;
291
+ senders: string[];
292
+ senderIds: string[];
293
+ senderNames: string[];
294
+ };
295
+ };
296
+ };
297
+ actionTypes?: ("send_invite" | "send_inmail_closed")[] | undefined;
211
298
  command: string;
212
299
  tool: string;
213
300
  promptName: string;
@@ -221,6 +308,40 @@ export declare function executeRefillSendsCommand(input?: RefillSendsCommandInpu
221
308
  workspaceId: string | null;
222
309
  workspaceResolution: string;
223
310
  intent: RefillSendsIntent;
311
+ } | {
312
+ autoPaidInmailRefresh: {
313
+ enabled: boolean;
314
+ status: string;
315
+ refreshedPaidInmailSenderIds: never[];
316
+ failedPaidInmailRefreshes: never[];
317
+ attemptedSenderIds: never[];
318
+ targetPlanReread: boolean;
319
+ workspaceId: string | null;
320
+ workspaceResolution: string;
321
+ note: string;
322
+ refreshReceipts?: undefined;
323
+ };
324
+ yoloExecution: {
325
+ enabled: boolean;
326
+ status: string;
327
+ selectedAction: Record<string, unknown> | null;
328
+ targetPlanReread: boolean;
329
+ result?: undefined;
330
+ refusalReason?: undefined;
331
+ postActionFirstAction?: undefined;
332
+ };
333
+ changed: boolean;
334
+ expectedTargetShapeRevision: string | null;
335
+ actualTargetShapeRevision: string | null;
336
+ expectedActionKey: string | null;
337
+ actualActionKey: string | null;
338
+ shapeChanged: boolean;
339
+ actionChanged: boolean;
340
+ ok: boolean;
341
+ code: string;
342
+ targetPlan: unknown;
343
+ targetPlanBeforePaidRefresh: null;
344
+ targetPlanBeforeYoloPrimitive: null;
224
345
  targetDate: string | null;
225
346
  untilDate: string | null;
226
347
  horizonSendDays: number | null;
@@ -264,10 +385,8 @@ export declare function executeRefillSendsCommand(input?: RefillSendsCommandInpu
264
385
  mcpTool: {
265
386
  name: string;
266
387
  arguments: {
267
- yolo: boolean;
268
- senders: string[];
269
- senderIds: string[];
270
- senderNames: string[];
388
+ expectedActionKey?: string | undefined;
389
+ expectedTargetShapeRevision?: string | undefined;
271
390
  targetDate: string | null;
272
391
  untilDate: string | null;
273
392
  horizonSendDays: number | null;
@@ -276,9 +395,28 @@ export declare function executeRefillSendsCommand(input?: RefillSendsCommandInpu
276
395
  intent: RefillSendsIntent;
277
396
  approvalMode: RefillSendsApprovalMode;
278
397
  workspaceId: string | null;
398
+ actionTypes?: ("send_invite" | "send_inmail_closed")[] | undefined;
399
+ yolo: boolean;
400
+ senders: string[];
401
+ senderIds: string[];
402
+ senderNames: string[];
279
403
  };
280
404
  };
281
405
  };
406
+ actionTypes?: ("send_invite" | "send_inmail_closed")[] | undefined;
407
+ command: string;
408
+ tool: string;
409
+ promptName: string;
410
+ workflowPromptName: string;
411
+ workflowAsset: {
412
+ subskillName: string;
413
+ assetPath: string;
414
+ };
415
+ yolo: boolean;
416
+ executionMode: RefillSendsExecutionMode;
417
+ workspaceId: string | null;
418
+ workspaceResolution: string;
419
+ intent: RefillSendsIntent;
282
420
  } | {
283
421
  targetPlan: unknown;
284
422
  targetPlanBeforePaidRefresh: unknown;
@@ -337,19 +475,6 @@ export declare function executeRefillSendsCommand(input?: RefillSendsCommandInpu
337
475
  refusalReason: string | undefined;
338
476
  postActionFirstAction: Record<string, unknown> | null;
339
477
  };
340
- command: string;
341
- tool: string;
342
- promptName: string;
343
- workflowPromptName: string;
344
- workflowAsset: {
345
- subskillName: string;
346
- assetPath: string;
347
- };
348
- yolo: boolean;
349
- executionMode: RefillSendsExecutionMode;
350
- workspaceId: string | null;
351
- workspaceResolution: string;
352
- intent: RefillSendsIntent;
353
478
  targetDate: string | null;
354
479
  untilDate: string | null;
355
480
  horizonSendDays: number | null;
@@ -393,10 +518,8 @@ export declare function executeRefillSendsCommand(input?: RefillSendsCommandInpu
393
518
  mcpTool: {
394
519
  name: string;
395
520
  arguments: {
396
- yolo: boolean;
397
- senders: string[];
398
- senderIds: string[];
399
- senderNames: string[];
521
+ expectedActionKey?: string | undefined;
522
+ expectedTargetShapeRevision?: string | undefined;
400
523
  targetDate: string | null;
401
524
  untilDate: string | null;
402
525
  horizonSendDays: number | null;
@@ -405,8 +528,27 @@ export declare function executeRefillSendsCommand(input?: RefillSendsCommandInpu
405
528
  intent: RefillSendsIntent;
406
529
  approvalMode: RefillSendsApprovalMode;
407
530
  workspaceId: string | null;
531
+ actionTypes?: ("send_invite" | "send_inmail_closed")[] | undefined;
532
+ yolo: boolean;
533
+ senders: string[];
534
+ senderIds: string[];
535
+ senderNames: string[];
408
536
  };
409
537
  };
410
538
  };
539
+ actionTypes?: ("send_invite" | "send_inmail_closed")[] | undefined;
540
+ command: string;
541
+ tool: string;
542
+ promptName: string;
543
+ workflowPromptName: string;
544
+ workflowAsset: {
545
+ subskillName: string;
546
+ assetPath: string;
547
+ };
548
+ yolo: boolean;
549
+ executionMode: RefillSendsExecutionMode;
550
+ workspaceId: string | null;
551
+ workspaceResolution: string;
552
+ intent: RefillSendsIntent;
411
553
  }>;
412
554
  export {};