@sellable/mcp 0.1.504 → 0.1.506

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 (34) hide show
  1. package/dist/api.d.ts +5 -5
  2. package/dist/api.js +10 -10
  3. package/dist/index-dev.js +0 -0
  4. package/dist/index.js +0 -0
  5. package/dist/server.js +2 -2
  6. package/dist/tools/campaign-fill-routing.d.ts +5 -0
  7. package/dist/tools/campaign-fill-routing.js +13 -3
  8. package/dist/tools/campaign-message-preparation.d.ts +33 -23
  9. package/dist/tools/campaign-message-preparation.js +31 -30
  10. package/dist/tools/campaign-processing.d.ts +19 -0
  11. package/dist/tools/campaign-processing.js +31 -8
  12. package/dist/tools/campaign-refill-state.d.ts +5 -0
  13. package/dist/tools/campaign-refill-state.js +13 -3
  14. package/dist/tools/leads.d.ts +6 -47
  15. package/dist/tools/leads.js +26 -30
  16. package/dist/tools/prompts.js +1 -1
  17. package/dist/tools/readiness.d.ts +6 -0
  18. package/dist/tools/readiness.js +12 -5
  19. package/dist/tools/refill-sends.d.ts +112 -29
  20. package/dist/tools/refill-sends.js +222 -569
  21. package/dist/tools/refill-target-plan.d.ts +5 -0
  22. package/dist/tools/refill-target-plan.js +32 -65
  23. package/dist/tools/registry.d.ts +232 -48
  24. package/dist/tools/scheduler-fill-capacity.d.ts +5 -0
  25. package/dist/tools/scheduler-fill-capacity.js +13 -3
  26. package/dist/tools/sender-routing.d.ts +8 -1
  27. package/dist/tools/sender-routing.js +12 -3
  28. package/dist/tools/senders.d.ts +14 -1
  29. package/dist/tools/senders.js +31 -5
  30. package/dist/tools/workspace-context.d.ts +36 -0
  31. package/dist/tools/workspace-context.js +39 -0
  32. package/package.json +1 -1
  33. package/skills/refill-sends/SKILL.md +53 -29
  34. package/skills/refill-sends-workflow/SKILL.md +19 -12
package/dist/api.d.ts CHANGED
@@ -23,12 +23,12 @@ export declare class SellableApi {
23
23
  private requestResponse;
24
24
  private request;
25
25
  get<T>(path: string, options?: ApiRequestOptions): Promise<T>;
26
- getText(path: string): Promise<string>;
27
- downloadToFile(requestPath: string, destinationPath: string): Promise<DownloadToFileResult>;
26
+ getText(path: string, options?: ApiRequestOptions): Promise<string>;
27
+ downloadToFile(requestPath: string, destinationPath: string, options?: ApiRequestOptions): Promise<DownloadToFileResult>;
28
28
  post<T>(path: string, body?: object, options?: ApiRequestOptions): Promise<T>;
29
- put<T>(path: string, body?: object): Promise<T>;
30
- patch<T>(path: string, body?: object): Promise<T>;
31
- delete<T>(path: string): Promise<T>;
29
+ put<T>(path: string, body?: object, options?: ApiRequestOptions): Promise<T>;
30
+ patch<T>(path: string, body?: object, options?: ApiRequestOptions): Promise<T>;
31
+ delete<T>(path: string, options?: ApiRequestOptions): Promise<T>;
32
32
  }
33
33
  export declare function getApi(): SellableApi;
34
34
  export declare function resetApi(): void;
package/dist/api.js CHANGED
@@ -64,12 +64,12 @@ export class SellableApi {
64
64
  async get(path, options) {
65
65
  return this.request("GET", path, undefined, options);
66
66
  }
67
- async getText(path) {
68
- const response = await this.requestResponse("GET", path);
67
+ async getText(path, options) {
68
+ const response = await this.requestResponse("GET", path, undefined, options);
69
69
  return response.text();
70
70
  }
71
- async downloadToFile(requestPath, destinationPath) {
72
- const response = await this.requestResponse("GET", requestPath);
71
+ async downloadToFile(requestPath, destinationPath, options) {
72
+ const response = await this.requestResponse("GET", requestPath, undefined, options);
73
73
  if (!response.body) {
74
74
  throw new SellableApiError(response.status, "Response body was empty for file download");
75
75
  }
@@ -98,14 +98,14 @@ export class SellableApi {
98
98
  async post(path, body, options) {
99
99
  return this.request("POST", path, body, options);
100
100
  }
101
- async put(path, body) {
102
- return this.request("PUT", path, body);
101
+ async put(path, body, options) {
102
+ return this.request("PUT", path, body, options);
103
103
  }
104
- async patch(path, body) {
105
- return this.request("PATCH", path, body);
104
+ async patch(path, body, options) {
105
+ return this.request("PATCH", path, body, options);
106
106
  }
107
- async delete(path) {
108
- return this.request("DELETE", path);
107
+ async delete(path, options) {
108
+ return this.request("DELETE", path, undefined, options);
109
109
  }
110
110
  }
111
111
  let apiInstance = null;
package/dist/index-dev.js CHANGED
File without changes
package/dist/index.js CHANGED
File without changes
package/dist/server.js CHANGED
@@ -511,7 +511,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
511
511
  result = await getEngagedPosts(args);
512
512
  break;
513
513
  case "get_sender_routing":
514
- result = await getSenderRoutingTool();
514
+ result = await getSenderRoutingTool(args);
515
515
  break;
516
516
  case "set_sender_routing":
517
517
  result = await setSenderRoutingTool(args);
@@ -523,7 +523,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
523
523
  result = await setCompanyInfoTool(args);
524
524
  break;
525
525
  case "list_senders":
526
- result = await listSenders();
526
+ result = await listSenders(args);
527
527
  break;
528
528
  case "get_sender":
529
529
  result = await getSender(args);
@@ -4,6 +4,7 @@ type ResolveCampaignFillRouteInput = {
4
4
  campaignId?: string;
5
5
  tableId?: string;
6
6
  limit?: number;
7
+ workspaceId?: string;
7
8
  };
8
9
  export declare const campaignFillRoutingToolDefinitions: {
9
10
  name: string;
@@ -30,6 +31,10 @@ export declare const campaignFillRoutingToolDefinitions: {
30
31
  maximum: number;
31
32
  description: string;
32
33
  };
34
+ workspaceId: {
35
+ type: string;
36
+ description: string;
37
+ };
33
38
  };
34
39
  required: string[];
35
40
  additionalProperties: boolean;
@@ -1,7 +1,11 @@
1
1
  import { getApi } from "../api.js";
2
- async function postCampaignFillRoute(body) {
2
+ import { normalizeExplicitWorkspaceId, workspaceRequestOptions, } from "./workspace-context.js";
3
+ async function postCampaignFillRoute(body, workspaceId) {
3
4
  const api = getApi();
4
- return api.post("/api/v3/mcp/campaign-fill-routing", body);
5
+ const requestOptions = workspaceRequestOptions(workspaceId);
6
+ return requestOptions
7
+ ? api.post("/api/v3/mcp/campaign-fill-routing", body, requestOptions)
8
+ : api.post("/api/v3/mcp/campaign-fill-routing", body);
5
9
  }
6
10
  export const campaignFillRoutingToolDefinitions = [
7
11
  {
@@ -29,6 +33,10 @@ export const campaignFillRoutingToolDefinitions = [
29
33
  maximum: 100,
30
34
  description: "Maximum returned targets/skippedTargets.",
31
35
  },
36
+ workspaceId: {
37
+ type: "string",
38
+ description: "Explicit request-scoped workspace id for scheduled/yolo refill automation. Pass this instead of switching the shared active workspace.",
39
+ },
32
40
  },
33
41
  required: ["intent"],
34
42
  additionalProperties: false,
@@ -36,10 +44,12 @@ export const campaignFillRoutingToolDefinitions = [
36
44
  },
37
45
  ];
38
46
  export function resolveCampaignFillRoute(input) {
47
+ const workspaceId = normalizeExplicitWorkspaceId(input.workspaceId);
39
48
  return postCampaignFillRoute({
40
49
  intent: input.intent,
41
50
  campaignId: input.campaignId,
42
51
  tableId: input.tableId,
43
52
  limit: input.limit,
44
- });
53
+ ...(workspaceId ? { workspaceId } : {}),
54
+ }, workspaceId ?? undefined);
45
55
  }
@@ -1,15 +1,22 @@
1
1
  type ApprovalMode = "mark_ready" | "approve";
2
2
  type RowSelector = {
3
+ type: "reviewBatch";
4
+ basisHash?: string;
5
+ limit?: number;
6
+ } | {
7
+ type: "rowIds";
8
+ rowIds: string[];
9
+ } | {
3
10
  type: "needsEnrichment";
4
11
  limit?: number;
5
12
  } | {
6
13
  type: "needsApproval";
7
14
  limit?: number;
8
15
  } | {
9
- type: "needsGeneratedMessage";
16
+ type: "passedRows";
10
17
  limit?: number;
11
18
  } | {
12
- type: "reviewBatch";
19
+ type: "needsGeneratedMessage";
13
20
  limit?: number;
14
21
  } | {
15
22
  type: "staleGeneratedMessages";
@@ -19,6 +26,7 @@ type PrepareMessagesBaseInput = {
19
26
  campaignId?: string;
20
27
  tableId?: string;
21
28
  jobId?: string;
29
+ workspaceId?: string;
22
30
  };
23
31
  type StartPrepareMessagesInput = PrepareMessagesBaseInput & {
24
32
  campaignId: string;
@@ -27,13 +35,9 @@ type StartPrepareMessagesInput = PrepareMessagesBaseInput & {
27
35
  batchSize?: number;
28
36
  maxBatchRows?: number;
29
37
  approvalMode?: ApprovalMode;
30
- rowSelector?: RowSelector;
31
38
  autoContinue?: boolean;
32
39
  disableLowPassRateStop?: boolean;
33
- requestHash?: string;
34
- requestSource?: string;
35
- senderId?: string;
36
- actionType?: string;
40
+ rowSelector?: RowSelector;
37
41
  };
38
42
  type StatusPrepareMessagesInput = PrepareMessagesBaseInput;
39
43
  type CancelPrepareMessagesInput = PrepareMessagesBaseInput;
@@ -78,6 +82,13 @@ export declare const campaignMessagePreparationToolDefinitions: ({
78
82
  enum: string[];
79
83
  description: string;
80
84
  };
85
+ autoContinue: {
86
+ type: string;
87
+ };
88
+ disableLowPassRateStop: {
89
+ type: string;
90
+ description: string;
91
+ };
81
92
  rowSelector: {
82
93
  type: string;
83
94
  description: string;
@@ -86,6 +97,15 @@ export declare const campaignMessagePreparationToolDefinitions: ({
86
97
  type: string;
87
98
  enum: string[];
88
99
  };
100
+ basisHash: {
101
+ type: string;
102
+ };
103
+ rowIds: {
104
+ type: string;
105
+ items: {
106
+ type: string;
107
+ };
108
+ };
89
109
  limit: {
90
110
  type: string;
91
111
  minimum: number;
@@ -95,19 +115,7 @@ export declare const campaignMessagePreparationToolDefinitions: ({
95
115
  required: string[];
96
116
  additionalProperties: boolean;
97
117
  };
98
- autoContinue: {
99
- type: string;
100
- };
101
- senderId: {
102
- type: string;
103
- description: string;
104
- };
105
- actionType: {
106
- type: string;
107
- enum: string[];
108
- description: string;
109
- };
110
- disableLowPassRateStop: {
118
+ workspaceId: {
111
119
  type: string;
112
120
  description: string;
113
121
  };
@@ -132,16 +140,18 @@ export declare const campaignMessagePreparationToolDefinitions: ({
132
140
  tableId: {
133
141
  type: string;
134
142
  };
143
+ workspaceId: {
144
+ type: string;
145
+ description?: undefined;
146
+ };
135
147
  targetPreparedMessages?: undefined;
136
148
  maxRowsToCheck?: undefined;
137
149
  batchSize?: undefined;
138
150
  maxBatchRows?: undefined;
139
151
  approvalMode?: undefined;
140
- rowSelector?: undefined;
141
152
  autoContinue?: undefined;
142
- senderId?: undefined;
143
- actionType?: undefined;
144
153
  disableLowPassRateStop?: undefined;
154
+ rowSelector?: undefined;
145
155
  };
146
156
  additionalProperties: boolean;
147
157
  required?: undefined;
@@ -1,7 +1,11 @@
1
1
  import { getApi } from "../api.js";
2
- async function postPrepareMessages(body) {
2
+ import { normalizeExplicitWorkspaceId, workspaceRequestOptions, } from "./workspace-context.js";
3
+ async function postPrepareMessages(body, workspaceId) {
3
4
  const api = getApi();
4
- return api.post("/api/v3/mcp/campaign-message-preparation", body);
5
+ const requestOptions = workspaceRequestOptions(workspaceId);
6
+ return requestOptions
7
+ ? api.post("/api/v3/mcp/campaign-message-preparation", body, requestOptions)
8
+ : api.post("/api/v3/mcp/campaign-message-preparation", body);
5
9
  }
6
10
  export const campaignMessagePreparationToolDefinitions = [
7
11
  {
@@ -39,44 +43,37 @@ export const campaignMessagePreparationToolDefinitions = [
39
43
  enum: ["mark_ready", "approve"],
40
44
  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.",
41
45
  },
46
+ autoContinue: { type: "boolean" },
47
+ disableLowPassRateStop: {
48
+ type: "boolean",
49
+ description: "Operator override for explicit fill/exhaust requests. When true, keep processing eligible rows even if the enriched sample pass rate is low. Still bounded by targetPreparedMessages and maxRowsToCheck.",
50
+ },
42
51
  rowSelector: {
43
52
  type: "object",
44
- description: 'Optional semantic row selector for refill frontiers. For regular refill preparation, use {type:"needsEnrichment"} so the backend starts at the actual unenriched table frontier instead of a generic prefix scan.',
53
+ description: 'Optional row selector for scoped refill frontiers. Use {"type":"needsEnrichment","limit":N} to prepare the next unenriched/refill rows selected by get_refill_target_plan.',
45
54
  properties: {
46
55
  type: {
47
56
  type: "string",
48
57
  enum: [
58
+ "reviewBatch",
59
+ "rowIds",
49
60
  "needsEnrichment",
50
61
  "needsApproval",
62
+ "passedRows",
51
63
  "needsGeneratedMessage",
52
- "reviewBatch",
53
64
  "staleGeneratedMessages",
54
65
  ],
55
66
  },
67
+ basisHash: { type: "string" },
68
+ rowIds: { type: "array", items: { type: "string" } },
56
69
  limit: { type: "number", minimum: 1, maximum: 500 },
57
70
  },
58
71
  required: ["type"],
59
72
  additionalProperties: false,
60
73
  },
61
- autoContinue: { type: "boolean" },
62
- senderId: {
63
- type: "string",
64
- description: "Optional refill-scope sender id. Used with actionType by refill_sends so preparation skips rows already attempted by other send actions.",
65
- },
66
- actionType: {
74
+ workspaceId: {
67
75
  type: "string",
68
- enum: [
69
- "send_invite",
70
- "send_dm",
71
- "send_inmail_open",
72
- "send_inmail_closed",
73
- "react_and_comment",
74
- ],
75
- description: "Optional refill-scope send action. InMail scopes treat open and paid InMail as one contact-reuse family.",
76
- },
77
- disableLowPassRateStop: {
78
- type: "boolean",
79
- description: "Operator override for explicit fill/exhaust requests. When true, keep processing eligible rows even if the enriched sample pass rate is low. Still bounded by targetPreparedMessages and maxRowsToCheck.",
76
+ description: "Explicit request-scoped workspace id for scheduled/yolo refill automation.",
80
77
  },
81
78
  },
82
79
  required: ["campaignId"],
@@ -92,6 +89,7 @@ export const campaignMessagePreparationToolDefinitions = [
92
89
  jobId: { type: "string" },
93
90
  campaignId: { type: "string" },
94
91
  tableId: { type: "string" },
92
+ workspaceId: { type: "string" },
95
93
  },
96
94
  additionalProperties: false,
97
95
  },
@@ -105,12 +103,14 @@ export const campaignMessagePreparationToolDefinitions = [
105
103
  jobId: { type: "string" },
106
104
  campaignId: { type: "string" },
107
105
  tableId: { type: "string" },
106
+ workspaceId: { type: "string" },
108
107
  },
109
108
  additionalProperties: false,
110
109
  },
111
110
  },
112
111
  ];
113
112
  export function startPrepareCampaignMessages(input) {
113
+ const workspaceId = normalizeExplicitWorkspaceId(input.workspaceId);
114
114
  return postPrepareMessages({
115
115
  action: "start",
116
116
  campaignId: input.campaignId,
@@ -120,28 +120,29 @@ export function startPrepareCampaignMessages(input) {
120
120
  batchSize: input.batchSize,
121
121
  maxBatchRows: input.maxBatchRows,
122
122
  approvalMode: input.approvalMode,
123
- rowSelector: input.rowSelector,
124
123
  autoContinue: input.autoContinue,
125
124
  disableLowPassRateStop: input.disableLowPassRateStop,
126
- requestHash: input.requestHash,
127
- requestSource: input.requestSource,
128
- senderId: input.senderId,
129
- actionType: input.actionType,
130
- });
125
+ rowSelector: input.rowSelector,
126
+ ...(workspaceId ? { workspaceId } : {}),
127
+ }, workspaceId ?? undefined);
131
128
  }
132
129
  export function getPrepareCampaignMessagesStatus(input) {
130
+ const workspaceId = normalizeExplicitWorkspaceId(input.workspaceId);
133
131
  return postPrepareMessages({
134
132
  action: "status",
135
133
  jobId: input.jobId,
136
134
  campaignId: input.campaignId,
137
135
  tableId: input.tableId,
138
- });
136
+ ...(workspaceId ? { workspaceId } : {}),
137
+ }, workspaceId ?? undefined);
139
138
  }
140
139
  export function cancelPrepareCampaignMessages(input) {
140
+ const workspaceId = normalizeExplicitWorkspaceId(input.workspaceId);
141
141
  return postPrepareMessages({
142
142
  action: "cancel",
143
143
  jobId: input.jobId,
144
144
  campaignId: input.campaignId,
145
145
  tableId: input.tableId,
146
- });
146
+ ...(workspaceId ? { workspaceId } : {}),
147
+ }, workspaceId ?? undefined);
147
148
  }
@@ -24,6 +24,7 @@ type RowSelector = {
24
24
  type SchemaInput = {
25
25
  campaignId?: string;
26
26
  tableId?: string;
27
+ workspaceId?: string;
27
28
  };
28
29
  type SelectInput = SchemaInput & {
29
30
  columnRole: ColumnRole;
@@ -100,6 +101,9 @@ export declare const campaignProcessingToolDefinitions: ({
100
101
  tableId: {
101
102
  type: string;
102
103
  };
104
+ workspaceId: {
105
+ type: string;
106
+ };
103
107
  columnRole?: undefined;
104
108
  rowSelector?: undefined;
105
109
  limit?: undefined;
@@ -130,6 +134,9 @@ export declare const campaignProcessingToolDefinitions: ({
130
134
  tableId: {
131
135
  type: string;
132
136
  };
137
+ workspaceId: {
138
+ type: string;
139
+ };
133
140
  columnRole: {
134
141
  type: string;
135
142
  enum: string[];
@@ -187,6 +194,9 @@ export declare const campaignProcessingToolDefinitions: ({
187
194
  tableId: {
188
195
  type: string;
189
196
  };
197
+ workspaceId: {
198
+ type: string;
199
+ };
190
200
  columnRole: {
191
201
  type: string;
192
202
  enum: string[];
@@ -248,6 +258,9 @@ export declare const campaignProcessingToolDefinitions: ({
248
258
  tableId: {
249
259
  type: string;
250
260
  };
261
+ workspaceId: {
262
+ type: string;
263
+ };
251
264
  minPassedCount: {
252
265
  type: string;
253
266
  };
@@ -286,6 +299,9 @@ export declare const campaignProcessingToolDefinitions: ({
286
299
  tableId: {
287
300
  type: string;
288
301
  };
302
+ workspaceId: {
303
+ type: string;
304
+ };
289
305
  rowIds: {
290
306
  type: string;
291
307
  items: {
@@ -327,6 +343,9 @@ export declare const campaignProcessingToolDefinitions: ({
327
343
  tableId: {
328
344
  type: string;
329
345
  };
346
+ workspaceId: {
347
+ type: string;
348
+ };
330
349
  templateMarkdown: {
331
350
  type: string;
332
351
  };
@@ -1,5 +1,6 @@
1
1
  import { getApi } from "../api.js";
2
2
  import { resolveWaitTimeout } from "./readiness.js";
3
+ import { normalizeExplicitWorkspaceId, workspaceRequestOptions, } from "./workspace-context.js";
3
4
  const DEFAULT_TIMEOUT_MS = 90000;
4
5
  const DEFAULT_INTERVAL_MS = 2000;
5
6
  function sleep(ms) {
@@ -14,16 +15,21 @@ function stableHash(value) {
14
15
  }
15
16
  return (hash >>> 0).toString(16).padStart(8, "0");
16
17
  }
17
- async function postCampaignProcessing(body) {
18
+ async function postCampaignProcessing(body, workspaceId) {
18
19
  const api = getApi();
19
- return api.post("/api/v3/mcp/campaign-processing", body);
20
+ const requestOptions = workspaceRequestOptions(workspaceId);
21
+ return requestOptions
22
+ ? api.post("/api/v3/mcp/campaign-processing", body, requestOptions)
23
+ : api.post("/api/v3/mcp/campaign-processing", body);
20
24
  }
21
25
  async function resolveSchema(input) {
26
+ const workspaceId = normalizeExplicitWorkspaceId(input.workspaceId);
22
27
  return postCampaignProcessing({
23
28
  action: "schema",
24
29
  campaignId: input.campaignId,
25
30
  tableId: input.tableId,
26
- });
31
+ ...(workspaceId ? { workspaceId } : {}),
32
+ }, workspaceId ?? undefined);
27
33
  }
28
34
  export const campaignProcessingToolDefinitions = [
29
35
  {
@@ -34,6 +40,7 @@ export const campaignProcessingToolDefinitions = [
34
40
  properties: {
35
41
  campaignId: { type: "string" },
36
42
  tableId: { type: "string" },
43
+ workspaceId: { type: "string" },
37
44
  },
38
45
  additionalProperties: false,
39
46
  },
@@ -46,6 +53,7 @@ export const campaignProcessingToolDefinitions = [
46
53
  properties: {
47
54
  campaignId: { type: "string" },
48
55
  tableId: { type: "string" },
56
+ workspaceId: { type: "string" },
49
57
  columnRole: {
50
58
  type: "string",
51
59
  enum: [
@@ -92,6 +100,7 @@ export const campaignProcessingToolDefinitions = [
92
100
  properties: {
93
101
  campaignId: { type: "string" },
94
102
  tableId: { type: "string" },
103
+ workspaceId: { type: "string" },
95
104
  columnRole: {
96
105
  type: "string",
97
106
  enum: ["enrich", "generateMessage", "approved"],
@@ -134,6 +143,7 @@ export const campaignProcessingToolDefinitions = [
134
143
  properties: {
135
144
  campaignId: { type: "string" },
136
145
  tableId: { type: "string" },
146
+ workspaceId: { type: "string" },
137
147
  minPassedCount: { type: "number" },
138
148
  minGeneratedMessages: { type: "number" },
139
149
  templateRevision: {
@@ -153,6 +163,7 @@ export const campaignProcessingToolDefinitions = [
153
163
  type: "object",
154
164
  properties: {
155
165
  tableId: { type: "string" },
166
+ workspaceId: { type: "string" },
156
167
  rowIds: { type: "array", items: { type: "string" } },
157
168
  enrichCellIds: { type: "array", items: { type: "string" } },
158
169
  },
@@ -168,6 +179,7 @@ export const campaignProcessingToolDefinitions = [
168
179
  properties: {
169
180
  campaignId: { type: "string" },
170
181
  tableId: { type: "string" },
182
+ workspaceId: { type: "string" },
171
183
  templateMarkdown: { type: "string" },
172
184
  approvedMessageTemplate: { type: "string" },
173
185
  rowSelector: {
@@ -199,28 +211,36 @@ export async function getCampaignTableSchema(input) {
199
211
  return resolveSchema(input);
200
212
  }
201
213
  export async function selectCampaignCells(input) {
214
+ const workspaceId = normalizeExplicitWorkspaceId(input.workspaceId);
202
215
  return postCampaignProcessing({
203
216
  action: "select",
204
217
  ...input,
205
- });
218
+ ...(workspaceId ? { workspaceId } : {}),
219
+ }, workspaceId ?? undefined);
206
220
  }
207
221
  export async function queueCampaignCells(input) {
222
+ const workspaceId = normalizeExplicitWorkspaceId(input.workspaceId);
208
223
  return postCampaignProcessing({
209
224
  action: "queue",
210
225
  ...input,
211
- });
226
+ ...(workspaceId ? { workspaceId } : {}),
227
+ }, workspaceId ?? undefined);
212
228
  }
213
229
  export async function recordCampaignReviewBatch(input) {
230
+ const workspaceId = normalizeExplicitWorkspaceId(input.workspaceId);
214
231
  return postCampaignProcessing({
215
232
  action: "recordReviewBatch",
216
233
  ...input,
217
- });
234
+ ...(workspaceId ? { workspaceId } : {}),
235
+ }, workspaceId ?? undefined);
218
236
  }
219
237
  export async function reviseMessageTemplateAndRerun(input) {
238
+ const workspaceId = normalizeExplicitWorkspaceId(input.workspaceId);
220
239
  const result = await postCampaignProcessing({
221
240
  action: "reviseTemplateAndRerun",
222
241
  ...input,
223
- });
242
+ ...(workspaceId ? { workspaceId } : {}),
243
+ }, workspaceId ?? undefined);
224
244
  const approvalsReset = typeof result.approvalsReset === "number" ? result.approvalsReset : 0;
225
245
  if (approvalsReset <= 0)
226
246
  return result;
@@ -328,6 +348,7 @@ function buildProcessingTimeoutRecovery({ input, schema, stats, minPassedCount,
328
348
  }
329
349
  export async function waitForCampaignProcessing(input) {
330
350
  const api = getApi();
351
+ const requestOptions = workspaceRequestOptions(input.workspaceId);
331
352
  const schema = await resolveSchema(input);
332
353
  const { effectiveTimeoutMs, guardApplied, requestedTimeoutMs } = resolveWaitTimeout(input.timeoutMs ?? DEFAULT_TIMEOUT_MS);
333
354
  const intervalMs = Math.max(500, input.intervalMs ?? DEFAULT_INTERVAL_MS);
@@ -352,7 +373,9 @@ export async function waitForCampaignProcessing(input) {
352
373
  let lastStats = null;
353
374
  while (Date.now() - start <= effectiveTimeoutMs) {
354
375
  attempts += 1;
355
- const stats = await api.get(`/api/v3/workflow-tables/${schema.tableId}/stats`);
376
+ const stats = requestOptions
377
+ ? await api.get(`/api/v3/workflow-tables/${schema.tableId}/stats`, requestOptions)
378
+ : await api.get(`/api/v3/workflow-tables/${schema.tableId}/stats`);
356
379
  lastStats = stats;
357
380
  const currentRevisionHash = stats.currentTemplateRevisionHash ?? null;
358
381
  if (templateRevision &&
@@ -1,6 +1,7 @@
1
1
  type GetCampaignRefillStateInput = {
2
2
  campaignId?: string;
3
3
  tableId?: string;
4
+ workspaceId?: string;
4
5
  };
5
6
  export declare const campaignRefillStateToolDefinitions: {
6
7
  name: string;
@@ -16,6 +17,10 @@ export declare const campaignRefillStateToolDefinitions: {
16
17
  type: string;
17
18
  description: string;
18
19
  };
20
+ workspaceId: {
21
+ type: string;
22
+ description: string;
23
+ };
19
24
  };
20
25
  required: never[];
21
26
  additionalProperties: boolean;
@@ -1,7 +1,11 @@
1
1
  import { getApi } from "../api.js";
2
- async function postCampaignRefillState(body) {
2
+ import { normalizeExplicitWorkspaceId, workspaceRequestOptions, } from "./workspace-context.js";
3
+ async function postCampaignRefillState(body, workspaceId) {
3
4
  const api = getApi();
4
- return api.post("/api/v3/mcp/campaign-refill-state", body);
5
+ const requestOptions = workspaceRequestOptions(workspaceId);
6
+ return requestOptions
7
+ ? api.post("/api/v3/mcp/campaign-refill-state", body, requestOptions)
8
+ : api.post("/api/v3/mcp/campaign-refill-state", body);
5
9
  }
6
10
  export const campaignRefillStateToolDefinitions = [
7
11
  {
@@ -18,6 +22,10 @@ export const campaignRefillStateToolDefinitions = [
18
22
  type: "string",
19
23
  description: "Optional exact WorkflowTable.id from resolve_campaign_fill_route. Do not pass table names.",
20
24
  },
25
+ workspaceId: {
26
+ type: "string",
27
+ description: "Explicit request-scoped workspace id for scheduled/yolo refill automation. Pass this instead of switching the shared active workspace.",
28
+ },
21
29
  },
22
30
  required: [],
23
31
  additionalProperties: false,
@@ -25,8 +33,10 @@ export const campaignRefillStateToolDefinitions = [
25
33
  },
26
34
  ];
27
35
  export function getCampaignRefillState(input) {
36
+ const workspaceId = normalizeExplicitWorkspaceId(input.workspaceId);
28
37
  return postCampaignRefillState({
29
38
  campaignId: input.campaignId,
30
39
  tableId: input.tableId,
31
- });
40
+ ...(workspaceId ? { workspaceId } : {}),
41
+ }, workspaceId ?? undefined);
32
42
  }