@sellable/mcp 0.1.512 → 0.1.514

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.
@@ -0,0 +1,115 @@
1
+ type RefillSendsV2Input = {
2
+ workspaceId?: string;
3
+ runId?: string;
4
+ fence?: number;
5
+ dryRun?: boolean;
6
+ approvalMode?: "approve" | "mark_ready";
7
+ senderIds?: string[];
8
+ intent?: "auto" | "evergreen" | "plain" | "active";
9
+ };
10
+ export declare const refillSendsV2ToolDefinitions: {
11
+ name: string;
12
+ description: string;
13
+ inputSchema: {
14
+ type: string;
15
+ properties: {
16
+ workspaceId: {
17
+ type: string;
18
+ description: string;
19
+ };
20
+ runId: {
21
+ type: string;
22
+ description: string;
23
+ };
24
+ fence: {
25
+ type: string;
26
+ description: string;
27
+ };
28
+ dryRun: {
29
+ type: string;
30
+ description: string;
31
+ };
32
+ approvalMode: {
33
+ type: string;
34
+ enum: string[];
35
+ description: string;
36
+ };
37
+ senderIds: {
38
+ type: string;
39
+ items: {
40
+ type: string;
41
+ };
42
+ };
43
+ intent: {
44
+ type: string;
45
+ enum: string[];
46
+ };
47
+ };
48
+ required: string[];
49
+ additionalProperties: boolean;
50
+ };
51
+ }[];
52
+ export declare function refillSendsV2Command(input: RefillSendsV2Input): Promise<{
53
+ readOnly: boolean;
54
+ mode: string;
55
+ forbiddenActions: string[];
56
+ boundedAuthority: string;
57
+ blocker: string;
58
+ workspaceId: string;
59
+ guidance: string;
60
+ warnings: string[];
61
+ journalPath: string | null;
62
+ text: string;
63
+ workspaceResolution: string;
64
+ } | {
65
+ readOnly: boolean;
66
+ mode: string;
67
+ forbiddenActions: string[];
68
+ boundedAuthority: string;
69
+ warnings: any[];
70
+ journalPath: string | null;
71
+ text: string;
72
+ workspaceId: string;
73
+ workspaceResolution: string;
74
+ blocker?: undefined;
75
+ guidance?: undefined;
76
+ } | {
77
+ readOnly: boolean;
78
+ forbiddenActions: string[];
79
+ boundedAuthority: string;
80
+ status: "dry_run";
81
+ plan: Record<string, unknown>;
82
+ } | {
83
+ readOnly: boolean;
84
+ forbiddenActions: string[];
85
+ boundedAuthority: string;
86
+ status: "in_progress";
87
+ runId: string;
88
+ fence: number;
89
+ gate: import("../refill-run-loop.js").RefillLoopGate;
90
+ guidance: string;
91
+ journalPath?: string | null;
92
+ } | {
93
+ readOnly: boolean;
94
+ forbiddenActions: string[];
95
+ boundedAuthority: string;
96
+ status: "blocked";
97
+ blocker: string;
98
+ runId?: string;
99
+ fence?: number;
100
+ gate?: import("../refill-run-loop.js").RefillLoopGate;
101
+ guidance: string;
102
+ holderRunId?: string;
103
+ report?: Record<string, unknown>;
104
+ journalPath?: string | null;
105
+ } | {
106
+ readOnly: boolean;
107
+ forbiddenActions: string[];
108
+ boundedAuthority: string;
109
+ status: "terminal";
110
+ doneReason: string;
111
+ report: Record<string, unknown>;
112
+ runId: string;
113
+ journalPath?: string | null;
114
+ }>;
115
+ export {};
@@ -0,0 +1,162 @@
1
+ import { appendIndexLine, appendJournalEvent, createRunJournal, renderBootstrapSection, renderCrashedAbandonedSection, renderExecutionEventSection, renderPlanSection, renderTerminalSection, } from "../refill-journal.js";
2
+ import { writeRefillWorkspaceState } from "../refill-local-state.js";
3
+ import { advanceRefillRunGateRemote, completeRefillRun, heartbeatRefillRun, recordRunOutcome, recordRunPlanned, refillRunStatus, startRefillRunRemote, } from "../refill-run-client.js";
4
+ import { runRefillV2Loop } from "../refill-run-loop.js";
5
+ import { getPrepareCampaignMessagesStatus } from "./campaign-message-preparation.js";
6
+ import { getRefillPlanV2 } from "./evergreen-refill-plan.js";
7
+ import { executeOneYoloPrimitive, executeStartCampaignPrimitive, prepareRowSelectorValue, refillPrepareRequestHash, refreshPaidInmailCreditsWithRetry, } from "./refill-executors.js";
8
+ const FORBIDDEN_ACTIONS = [
9
+ "Do not schedule sends.",
10
+ "Do not send messages.",
11
+ "Do not create campaigns.",
12
+ "Do not switch providers or source families.",
13
+ "Do not lower paid InMail thresholds.",
14
+ "Do not write scheduler fields.",
15
+ ];
16
+ const BOUNDED_AUTHORITY = "Within the refill run, bounded approvals, preparation jobs, source copies, saved signal continuations, pinned-lane campaign starts, and paid-credit refreshes may execute only when named by the current packet and logged planned -> did -> outcome.";
17
+ export const refillSendsV2ToolDefinitions = [
18
+ {
19
+ name: "refill_sends_v2",
20
+ description: "Execute the refill sends v2 loop with run-record fencing, packet re-planning, shared refill executors, and resumable dry-run/real-run modes.",
21
+ inputSchema: {
22
+ type: "object",
23
+ properties: {
24
+ workspaceId: {
25
+ type: "string",
26
+ description: "Explicit request-scoped workspace id.",
27
+ },
28
+ runId: {
29
+ type: "string",
30
+ description: "Optional refill run id to resume.",
31
+ },
32
+ fence: {
33
+ type: "number",
34
+ description: "Optional refill run fence to resume.",
35
+ },
36
+ dryRun: {
37
+ type: "boolean",
38
+ description: "When true, read the v2 packet and write only a dry-run journal.",
39
+ },
40
+ approvalMode: {
41
+ type: "string",
42
+ enum: ["approve", "mark_ready"],
43
+ description: 'Message approval behavior for packet-named prep/approval actions. Defaults to "approve".',
44
+ },
45
+ senderIds: {
46
+ type: "array",
47
+ items: { type: "string" },
48
+ },
49
+ intent: {
50
+ type: "string",
51
+ enum: ["auto", "evergreen", "plain", "active"],
52
+ },
53
+ },
54
+ required: ["workspaceId"],
55
+ additionalProperties: false,
56
+ },
57
+ },
58
+ ];
59
+ function normalizeWorkspaceId(workspaceId) {
60
+ if (!workspaceId?.trim()) {
61
+ throw new Error("workspaceId is required for refill_sends_v2.");
62
+ }
63
+ return workspaceId.trim();
64
+ }
65
+ function resumeHandle(input) {
66
+ return input.runId && typeof input.fence === "number"
67
+ ? { runId: input.runId, fence: input.fence }
68
+ : undefined;
69
+ }
70
+ async function maybeAddLostFenceGuidance(result, input) {
71
+ if (result.status !== "blocked" ||
72
+ result.blocker !== "lease_lost" ||
73
+ !input.runId) {
74
+ return result;
75
+ }
76
+ try {
77
+ const status = await refillRunStatus({
78
+ workspaceId: input.workspaceId,
79
+ runId: input.runId,
80
+ });
81
+ return {
82
+ ...result,
83
+ guidance: [
84
+ result.guidance,
85
+ "Lease lockout window is approximately 10 minutes.",
86
+ `Holder status: ${JSON.stringify(status)}`,
87
+ ].join(" "),
88
+ };
89
+ }
90
+ catch {
91
+ return result;
92
+ }
93
+ }
94
+ export async function refillSendsV2Command(input) {
95
+ const workspaceId = normalizeWorkspaceId(input.workspaceId);
96
+ if (input.dryRun) {
97
+ const plan = await getRefillPlanV2({
98
+ workspaceId,
99
+ intent: input.intent,
100
+ senderIds: input.senderIds,
101
+ journal: true,
102
+ });
103
+ return {
104
+ ...plan,
105
+ readOnly: true,
106
+ mode: "dry_run",
107
+ forbiddenActions: FORBIDDEN_ACTIONS,
108
+ boundedAuthority: BOUNDED_AUTHORITY,
109
+ };
110
+ }
111
+ const result = await runRefillV2Loop({
112
+ workspaceId,
113
+ intent: input.intent,
114
+ senderIds: input.senderIds,
115
+ approvalMode: input.approvalMode ?? "approve",
116
+ resume: resumeHandle(input),
117
+ }, {
118
+ runClient: {
119
+ startRefillRunRemote,
120
+ refillRunStatus,
121
+ heartbeatRefillRun,
122
+ advanceRefillRunGateRemote,
123
+ recordRunPlanned,
124
+ recordRunOutcome,
125
+ completeRefillRun,
126
+ },
127
+ readPlan: async (planInput) => getRefillPlanV2({
128
+ workspaceId: planInput.workspaceId,
129
+ intent: planInput.intent,
130
+ senderIds: planInput.senderIds,
131
+ runState: planInput.runState,
132
+ journal: planInput.journal,
133
+ }),
134
+ executors: {
135
+ executeOneYoloPrimitive,
136
+ executeStartCampaignPrimitive,
137
+ refreshPaidInmailCreditsWithRetry,
138
+ getPrepareCampaignMessagesStatus,
139
+ refillPrepareRequestHash,
140
+ prepareRowSelectorValue,
141
+ },
142
+ journal: {
143
+ createRunJournal,
144
+ appendJournalEvent,
145
+ renderBootstrapSection,
146
+ renderPlanSection,
147
+ renderExecutionEventSection,
148
+ renderCrashedAbandonedSection,
149
+ renderTerminalSection,
150
+ appendIndexLine,
151
+ },
152
+ localState: {
153
+ writeRefillWorkspaceState,
154
+ },
155
+ });
156
+ return {
157
+ ...(await maybeAddLostFenceGuidance(result, { ...input, workspaceId })),
158
+ readOnly: false,
159
+ forbiddenActions: FORBIDDEN_ACTIONS,
160
+ boundedAuthority: BOUNDED_AUTHORITY,
161
+ };
162
+ }