@sellable/mcp 0.1.504 → 0.1.505

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.
@@ -1,7 +1,11 @@
1
1
  import { getApi } from "../api.js";
2
- async function postSchedulerFillCapacity(body) {
2
+ import { normalizeExplicitWorkspaceId, workspaceRequestOptions, } from "./workspace-context.js";
3
+ async function postSchedulerFillCapacity(body, workspaceId) {
3
4
  const api = getApi();
4
- return api.post("/api/v3/mcp/scheduler-fill-capacity", body);
5
+ const requestOptions = workspaceRequestOptions(workspaceId);
6
+ return requestOptions
7
+ ? api.post("/api/v3/mcp/scheduler-fill-capacity", body, requestOptions)
8
+ : api.post("/api/v3/mcp/scheduler-fill-capacity", body);
5
9
  }
6
10
  export const schedulerFillCapacityToolDefinitions = [
7
11
  {
@@ -55,6 +59,10 @@ export const schedulerFillCapacityToolDefinitions = [
55
59
  enum: ["default_horizon", "target_date"],
56
60
  description: "Optional mode hint. Omit for default_horizon; target_date requires targetDate.",
57
61
  },
62
+ workspaceId: {
63
+ type: "string",
64
+ description: "Explicit request-scoped workspace id for scheduled/yolo refill automation. Pass this instead of switching the shared active workspace.",
65
+ },
58
66
  },
59
67
  required: ["capacityRequests"],
60
68
  additionalProperties: false,
@@ -62,9 +70,11 @@ export const schedulerFillCapacityToolDefinitions = [
62
70
  },
63
71
  ];
64
72
  export function getSchedulerFillCapacity(input) {
73
+ const workspaceId = normalizeExplicitWorkspaceId(input.workspaceId);
65
74
  return postSchedulerFillCapacity({
66
75
  capacityRequests: input.capacityRequests,
67
76
  targetDate: input.targetDate,
68
77
  mode: input.mode,
69
- });
78
+ ...(workspaceId ? { workspaceId } : {}),
79
+ }, workspaceId ?? undefined);
70
80
  }
@@ -14,6 +14,10 @@ export declare const senderRoutingToolDefinitions: ({
14
14
  inputSchema: {
15
15
  type: string;
16
16
  properties: {
17
+ workspaceId: {
18
+ type: string;
19
+ description: string;
20
+ };
17
21
  rulesMarkdown?: undefined;
18
22
  };
19
23
  required: never[];
@@ -29,12 +33,15 @@ export declare const senderRoutingToolDefinitions: ({
29
33
  type: string;
30
34
  description: string;
31
35
  };
36
+ workspaceId?: undefined;
32
37
  };
33
38
  required: never[];
34
39
  additionalProperties: boolean;
35
40
  };
36
41
  })[];
37
- export declare function getSenderRoutingTool(): Promise<SenderRoutingResponse>;
42
+ export declare function getSenderRoutingTool(input?: {
43
+ workspaceId?: string;
44
+ }): Promise<SenderRoutingResponse>;
38
45
  export declare function setSenderRoutingTool(input?: {
39
46
  rulesMarkdown?: string;
40
47
  }): Promise<{
@@ -1,4 +1,5 @@
1
1
  import { getApi } from "../api.js";
2
+ import { workspaceRequestOptions } from "./workspace-context.js";
2
3
  const MAX_RULES_MARKDOWN_LENGTH = 65536;
3
4
  export const senderRoutingToolDefinitions = [
4
5
  {
@@ -6,7 +7,12 @@ export const senderRoutingToolDefinitions = [
6
7
  description: "Return the workspace's territory routing rules markdown plus the connected sender roster. If configured is false, routing is inactive and all campaign senders are eligible everywhere.",
7
8
  inputSchema: {
8
9
  type: "object",
9
- properties: {},
10
+ properties: {
11
+ workspaceId: {
12
+ type: "string",
13
+ description: "Explicit request-scoped workspace id for scheduled/yolo refill automation. Pass this instead of switching the shared active workspace.",
14
+ },
15
+ },
10
16
  required: [],
11
17
  additionalProperties: false,
12
18
  },
@@ -27,9 +33,12 @@ export const senderRoutingToolDefinitions = [
27
33
  },
28
34
  },
29
35
  ];
30
- export async function getSenderRoutingTool() {
36
+ export async function getSenderRoutingTool(input = {}) {
31
37
  const api = getApi();
32
- return api.get("/api/v3/sender-routing");
38
+ const requestOptions = workspaceRequestOptions(input.workspaceId);
39
+ return requestOptions
40
+ ? api.get("/api/v3/sender-routing", requestOptions)
41
+ : api.get("/api/v3/sender-routing");
33
42
  }
34
43
  export async function setSenderRoutingTool(input = {}) {
35
44
  if (input.rulesMarkdown &&
@@ -22,14 +22,19 @@ export type SenderListItem = {
22
22
  export type ListSendersResponse = {
23
23
  senders: SenderListItem[];
24
24
  };
25
+ export type ListSendersInput = {
26
+ workspaceId?: string;
27
+ };
25
28
  export type GetSenderInput = {
26
29
  senderId: string;
30
+ workspaceId?: string;
27
31
  };
28
32
  export type SenderDetailResponse = {
29
33
  sender: any;
30
34
  };
31
35
  export type RefreshPaidInmailCreditsInput = {
32
36
  senderId: string;
37
+ workspaceId?: string;
33
38
  };
34
39
  export type PaidInmailCreditStatus = {
35
40
  available: number;
@@ -57,6 +62,10 @@ export declare const senderToolDefinitions: ({
57
62
  inputSchema: {
58
63
  type: string;
59
64
  properties: {
65
+ workspaceId: {
66
+ type: string;
67
+ description: string;
68
+ };
60
69
  senderId?: undefined;
61
70
  };
62
71
  required: never[];
@@ -72,12 +81,16 @@ export declare const senderToolDefinitions: ({
72
81
  type: string;
73
82
  description: string;
74
83
  };
84
+ workspaceId: {
85
+ type: string;
86
+ description: string;
87
+ };
75
88
  };
76
89
  required: string[];
77
90
  additionalProperties: boolean;
78
91
  };
79
92
  })[];
80
- export declare function listSenders(): Promise<ListSendersResponse>;
93
+ export declare function listSenders(input?: ListSendersInput): Promise<ListSendersResponse>;
81
94
  export declare function getSender(input: GetSenderInput): Promise<SenderDetailResponse>;
82
95
  export declare function refreshPaidInmailCredits(input: RefreshPaidInmailCreditsInput): Promise<RefreshPaidInmailCreditsResponse>;
83
96
  export {};
@@ -1,5 +1,6 @@
1
1
  import { getApi } from "../api.js";
2
2
  import { isLinkedInProfileInput, normalizeLinkedInProfileInput, } from "./linkedin-url.js";
3
+ import { normalizeExplicitWorkspaceId, workspaceRequestOptions, } from "./workspace-context.js";
3
4
  function pickString(...values) {
4
5
  for (const value of values) {
5
6
  if (typeof value !== "string")
@@ -107,7 +108,12 @@ export const senderToolDefinitions = [
107
108
  description: "List outbound sender identities available in the active workspace, including LinkedIn profile URL and verified identity proof when available. In create-campaign flows, use this at Settings/final launch handoff to verify available connected senders; auto-select only when a sender has an exact identity match to the researched campaign identity. If identity proof is missing, ask the user to confirm the sender.",
108
109
  inputSchema: {
109
110
  type: "object",
110
- properties: {},
111
+ properties: {
112
+ workspaceId: {
113
+ type: "string",
114
+ description: "Explicit request-scoped workspace id for scheduled/yolo refill automation. Pass this instead of switching the shared active workspace.",
115
+ },
116
+ },
111
117
  required: [],
112
118
  additionalProperties: false,
113
119
  },
@@ -119,6 +125,10 @@ export const senderToolDefinitions = [
119
125
  type: "object",
120
126
  properties: {
121
127
  senderId: { type: "string", description: "Outbound sender ID" },
128
+ workspaceId: {
129
+ type: "string",
130
+ description: "Explicit request-scoped workspace id for scheduled/yolo refill automation.",
131
+ },
122
132
  },
123
133
  required: ["senderId"],
124
134
  additionalProperties: false,
@@ -134,15 +144,22 @@ export const senderToolDefinitions = [
134
144
  type: "string",
135
145
  description: "Exact Sender.id to refresh. The API verifies the sender belongs to the active workspace.",
136
146
  },
147
+ workspaceId: {
148
+ type: "string",
149
+ description: "Explicit request-scoped workspace id for scheduled/yolo refill automation. Pass this instead of switching the shared active workspace.",
150
+ },
137
151
  },
138
152
  required: ["senderId"],
139
153
  additionalProperties: false,
140
154
  },
141
155
  },
142
156
  ];
143
- export async function listSenders() {
157
+ export async function listSenders(input = {}) {
144
158
  const api = getApi();
145
- const senders = await api.get("/api/v1/outbound-sender-identities");
159
+ const requestOptions = workspaceRequestOptions(input.workspaceId);
160
+ const senders = requestOptions
161
+ ? await api.get("/api/v1/outbound-sender-identities", requestOptions)
162
+ : await api.get("/api/v1/outbound-sender-identities");
146
163
  return {
147
164
  senders: (senders || []).map((s) => {
148
165
  const linkedinProfileUrl = computeLinkedinProfileUrl(s);
@@ -163,7 +180,11 @@ export async function listSenders() {
163
180
  }
164
181
  export async function getSender(input) {
165
182
  const api = getApi();
166
- const sender = await api.get(`/api/v1/outbound-sender-identities/${encodeURIComponent(input.senderId)}`);
183
+ const requestOptions = workspaceRequestOptions(input.workspaceId);
184
+ const path = `/api/v1/outbound-sender-identities/${encodeURIComponent(input.senderId)}`;
185
+ const sender = requestOptions
186
+ ? await api.get(path, requestOptions)
187
+ : await api.get(path);
167
188
  return { sender };
168
189
  }
169
190
  function normalizeCreditStatus(raw) {
@@ -187,7 +208,12 @@ export async function refreshPaidInmailCredits(input) {
187
208
  throw new Error("senderId is required.");
188
209
  }
189
210
  const api = getApi();
190
- const result = await api.post(`/api/v3/senders/${encodeURIComponent(senderId)}/refresh-inmail-credits`, {});
211
+ const workspaceId = normalizeExplicitWorkspaceId(input.workspaceId);
212
+ const requestOptions = workspaceRequestOptions(workspaceId);
213
+ const body = workspaceId ? { workspaceId } : {};
214
+ const result = requestOptions
215
+ ? await api.post(`/api/v3/senders/${encodeURIComponent(senderId)}/refresh-inmail-credits`, body, requestOptions)
216
+ : await api.post(`/api/v3/senders/${encodeURIComponent(senderId)}/refresh-inmail-credits`, body);
191
217
  return {
192
218
  senderId,
193
219
  refreshed: true,
@@ -0,0 +1,36 @@
1
+ import type { ApiRequestOptions } from "../api.js";
2
+ export type WorkspaceExecutionMode = "manual" | "scheduled" | "yolo";
3
+ export interface CreateWorkspaceContextInput {
4
+ workspaceId?: string | null;
5
+ executionMode: WorkspaceExecutionMode;
6
+ toolName?: string;
7
+ runId?: string;
8
+ }
9
+ export interface WorkspaceContext {
10
+ workspaceId: string;
11
+ requestOptions: Readonly<ApiRequestOptions>;
12
+ executionMode: WorkspaceExecutionMode;
13
+ toolName?: string;
14
+ runId: string;
15
+ workspaceResolution: "explicit";
16
+ }
17
+ export interface WorkspaceRequiredResult {
18
+ ok: false;
19
+ code: "WORKSPACE_REQUIRED";
20
+ message: string;
21
+ executionMode: WorkspaceExecutionMode;
22
+ toolName?: string;
23
+ workspaceResolution: "missing";
24
+ }
25
+ export interface WorkspaceContextResult {
26
+ ok: true;
27
+ context: Readonly<WorkspaceContext>;
28
+ }
29
+ export type CreateWorkspaceContextResult = WorkspaceContextResult | WorkspaceRequiredResult;
30
+ export declare function workspaceRequired(params: {
31
+ executionMode: WorkspaceExecutionMode;
32
+ toolName?: string;
33
+ }): WorkspaceRequiredResult;
34
+ export declare function normalizeExplicitWorkspaceId(value: unknown): string | null;
35
+ export declare function workspaceRequestOptions(workspaceId: unknown): Readonly<ApiRequestOptions> | undefined;
36
+ export declare function createWorkspaceContext(input: CreateWorkspaceContextInput): CreateWorkspaceContextResult;
@@ -0,0 +1,39 @@
1
+ import { randomUUID } from "node:crypto";
2
+ export function workspaceRequired(params) {
3
+ const toolLabel = params.toolName ? ` for ${params.toolName}` : "";
4
+ return {
5
+ ok: false,
6
+ code: "WORKSPACE_REQUIRED",
7
+ message: `Explicit workspaceId is required${toolLabel} in ${params.executionMode} mode. ` +
8
+ "Pass workspaceId on the tool call instead of switching the shared active workspace.",
9
+ executionMode: params.executionMode,
10
+ toolName: params.toolName,
11
+ workspaceResolution: "missing",
12
+ };
13
+ }
14
+ export function normalizeExplicitWorkspaceId(value) {
15
+ return typeof value === "string" && value.trim() ? value.trim() : null;
16
+ }
17
+ export function workspaceRequestOptions(workspaceId) {
18
+ const normalized = normalizeExplicitWorkspaceId(workspaceId);
19
+ return normalized ? Object.freeze({ workspaceId: normalized }) : undefined;
20
+ }
21
+ export function createWorkspaceContext(input) {
22
+ const workspaceId = normalizeExplicitWorkspaceId(input.workspaceId);
23
+ if (!workspaceId) {
24
+ return workspaceRequired({
25
+ executionMode: input.executionMode,
26
+ toolName: input.toolName,
27
+ });
28
+ }
29
+ const requestOptions = Object.freeze({ workspaceId });
30
+ const context = Object.freeze({
31
+ workspaceId,
32
+ requestOptions,
33
+ executionMode: input.executionMode,
34
+ toolName: input.toolName,
35
+ runId: input.runId?.trim() || randomUUID(),
36
+ workspaceResolution: "explicit",
37
+ });
38
+ return { ok: true, context };
39
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sellable/mcp",
3
- "version": "0.1.504",
3
+ "version": "0.1.505",
4
4
  "type": "module",
5
5
  "description": "Sellable MCP server for Claude Code and Codex campaign workflows",
6
6
  "main": "dist/index.js",
@@ -68,6 +68,9 @@ Accepted invocation flags in the same user request:
68
68
 
69
69
  - `--yolo`: auto-accept the rendered bounded refill packet after the required
70
70
  fresh state reread.
71
+ - `workspaceId: <id>`: required for scheduled automation and `--yolo`; pass it
72
+ through on every refill MCP tool call instead of relying on shared config
73
+ state.
71
74
  - `--sender <name-or-id>`: scope to a specific sender; repeat for multiple
72
75
  senders.
73
76
  - `--until <YYYY-MM-DD>`: fill through that sender-local date, inclusive,
@@ -86,7 +89,7 @@ Accepted invocation flags in the same user request:
86
89
  When the host can call typed MCP tools, start with:
87
90
 
88
91
  ```text
89
- refill_sends({ yolo?: boolean, senders?: string[], senderIds?: string[], senderNames?: string[], horizonSendDays?: number, untilDate?: "YYYY-MM-DD", targetDate?: "YYYY-MM-DD" })
92
+ refill_sends({ yolo?: boolean, executionMode?: "manual" | "scheduled" | "yolo", requireWorkspace?: boolean, workspaceId?: string, senders?: string[], senderIds?: string[], senderNames?: string[], horizonSendDays?: number, untilDate?: "YYYY-MM-DD", targetDate?: "YYYY-MM-DD" })
90
93
  ```
91
94
 
92
95
  That command helper normalizes arguments and returns the execution contract. In
@@ -100,9 +103,40 @@ or write scheduler rows. Continue with the workflow below for route selection,
100
103
  state rereads, approval gating, source import, preparation, and bounded
101
104
  approval.
102
105
 
103
- First call `get_auth_status({})`. If auth or active workspace is not OK, follow
104
- the returned login/workspace guidance before route resolution. Do not run refill
105
- research against an implicit or guessed workspace.
106
+ ## Workspace Contract
107
+
108
+ First resolve the target workspace id from the user's request, automation config,
109
+ or install-time workspace mapping. Pass `workspaceId` on every scheduled or
110
+ `--yolo` refill tool call, including setup/read calls such as
111
+ `refill_sends`, `get_refill_target_plan`, `list_senders`,
112
+ `get_sender_routing`, `resolve_campaign_fill_route`,
113
+ `get_campaign_refill_state`, `get_scheduler_fill_capacity`, and any later
114
+ refill mutation covered by the packet. Missing `workspaceId` in scheduled or
115
+ `--yolo` mode is a blocker; stop with `WORKSPACE_REQUIRED` instead of running
116
+ against an implicit or guessed workspace.
117
+
118
+ Do not solve scheduled or `--yolo` workspace uncertainty by changing the shared
119
+ active workspace. Manual interactive workspace switching remains a separate
120
+ diagnostic/setup flow, outside automation.
121
+
122
+ Examples:
123
+
124
+ ```text
125
+ refill_sends({ yolo:true, executionMode:"yolo", requireWorkspace:true, workspaceId:"cmlq1v8ms0000jx04ang4hi7e" })
126
+ get_refill_target_plan({ intent:"plain", approvalMode:"approve", workspaceId:"cmlq1v8ms0000jx04ang4hi7e" })
127
+ list_senders({ workspaceId:"cmlq1v8ms0000jx04ang4hi7e" })
128
+ ```
129
+
130
+ Clover scheduled automation must name the Clover workspace explicitly:
131
+
132
+ ```text
133
+ refill_sends({ yolo:false, executionMode:"scheduled", requireWorkspace:true, workspaceId:"cmlq1v8ms0000jx04ang4hi7e" })
134
+ get_refill_target_plan({ intent:"plain", approvalMode:"mark_ready", workspaceId:"cmlq1v8ms0000jx04ang4hi7e" })
135
+ ```
136
+
137
+ First call `get_auth_status({})`. If auth is not OK, follow the returned login
138
+ guidance before route resolution. Do not run refill research against an implicit
139
+ or guessed workspace.
106
140
 
107
141
  Treat "refill senders", "fill senders", "load everyone up", and "max out
108
142
  senders" as sender-scoped requests. The target set is senders enrolled in active
@@ -165,7 +199,8 @@ Structured planner packet:
165
199
  `Still need`.
166
200
  - `target.globalActionQueue` is the only cross-sender yolo execution queue.
167
201
  Execute exactly one globally ranked primitive from
168
- `target.globalActionQueue[0]`, then rerun `get_refill_target_plan` before
202
+ `target.globalActionQueue[0]`, then rerun `get_refill_target_plan` with the
203
+ same `workspaceId` before
169
204
  choosing another action.
170
205
  - `manualAlternates` are not yolo actions. Threshold lowering and campaign
171
206
  creation are manual continuations only.
@@ -250,7 +285,7 @@ If Christian includes `--yolo` in the same refill request, treat that flag as
250
285
  auto-accept for the rendered bounded refill packet after the required fresh state
251
286
  reread. For sender-scoped language with no named senders, `--yolo` means all
252
287
  eligible healthy senders enrolled in active campaign-backed sequence campaigns in
253
- the active workspace. Without `--yolo`, if Christian did not name senders, ask
288
+ the requested `workspaceId`. Without `--yolo`, if Christian did not name senders, ask
254
289
  which eligible enrolled senders to refill before choosing campaigns or mutating.
255
290
 
256
291
  `--yolo` only covers the exact sender set, per-sender target campaigns, caps,
@@ -61,6 +61,17 @@ senders", and "load everyone up". A sender-scoped request targets senders
61
61
  enrolled in active campaign-backed sequence campaigns, not one arbitrary active
62
62
  campaign.
63
63
 
64
+ Workspace contract: scheduled automation and `--yolo` must carry an explicit
65
+ request-scoped `workspaceId`. Pass that same `workspaceId` on every refill tool
66
+ call in this workflow: `get_refill_target_plan`, `list_senders`,
67
+ `get_sender_routing`, `resolve_campaign_fill_route`,
68
+ `get_campaign_refill_state`, `get_scheduler_fill_capacity`,
69
+ `refresh_paid_inmail_credits`, source import/readiness calls, preparation calls,
70
+ approval calls, and campaign start calls. Missing `workspaceId` in scheduled or
71
+ `--yolo` mode is a blocker; return or report `WORKSPACE_REQUIRED` instead of
72
+ falling back to shared config state. Manual interactive workspace switching is
73
+ diagnostic setup only and is not an automation control path.
74
+
64
75
  Goal-mode continuation: a skill cannot create or invoke `/goal` by itself. When
65
76
  this workflow is already running inside an active Codex goal, keep that goal
66
77
  open until every selected sender lane is horizon-filled by projected coverage
@@ -103,7 +114,8 @@ in-progress wait state, not a reason to mark the goal complete or blocked.
103
114
  `Still need`.
104
115
  - `target.globalActionQueue` is the only cross-sender yolo execution queue.
105
116
  execute exactly one globally ranked primitive from
106
- `target.globalActionQueue[0]`, then rerun `get_refill_target_plan` before
117
+ `target.globalActionQueue[0]`, then rerun `get_refill_target_plan` with
118
+ the same `workspaceId` before
107
119
  choosing another action.
108
120
  - `nextActions[0]` is the current sender's smallest safe primitive.
109
121
  - `manualAlternates` are not yolo actions. Threshold lowering and campaign