scrapeloop-mcp 0.6.0 → 0.7.1

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,206 @@
1
+ /**
2
+ * Retry contracts for every MCP operation that does not use HTTP GET.
3
+ *
4
+ * A POST may still be read-only, such as an estimate with a JSON filter body.
5
+ * Every true mutation declares whether it is provably idempotent, protected by
6
+ * a durable caller key, reconciliation-only, or forbidden from automatic retry.
7
+ */
8
+
9
+ const read = (method = 'POST') => ({ method, effect: 'read', retry: 'bounded' });
10
+ const idempotent = (method, inspectWith, matchFields) => ({
11
+ method,
12
+ effect: 'mutation',
13
+ retry: 'idempotent',
14
+ inspect_with: inspectWith,
15
+ match_fields: matchFields,
16
+ });
17
+ const keyed = (method, inspectWith, matchFields) => ({
18
+ method,
19
+ effect: 'mutation',
20
+ retry: 'idempotency_key',
21
+ inspect_with: inspectWith,
22
+ match_fields: matchFields,
23
+ });
24
+ const reconcile = (method, inspectWith, matchFields) => ({
25
+ method,
26
+ effect: 'mutation',
27
+ retry: 'reconcile',
28
+ inspect_with: inspectWith,
29
+ match_fields: matchFields,
30
+ });
31
+ const never = (method, inspectWith, matchFields) => ({
32
+ method,
33
+ effect: 'mutation',
34
+ retry: 'never',
35
+ inspect_with: inspectWith,
36
+ match_fields: matchFields,
37
+ });
38
+
39
+ export const MUTATION_POLICIES = Object.freeze({
40
+ create_integration: keyed('POST', ['list_integrations'], ['vendor', 'plugin_kind']),
41
+ add_credential: reconcile('POST', ['list_credentials'], ['integration_id', 'label']),
42
+ test_credential: idempotent('POST', ['list_credentials'], ['credential_id']),
43
+ estimate_scrape: read(),
44
+ submit_scrape: keyed('POST', ['list_jobs'], ['kind', 'integration_id', 'credential_id', 'table_id']),
45
+ cancel_job: never('POST', ['get_job'], ['job_id', 'status']),
46
+ search_leads: read(),
47
+ estimate_leads: read(),
48
+ expand_job_titles: read(),
49
+ reveal_lead: idempotent('POST', ['search_leads', 'get_credits'], ['global_person_id']),
50
+ save_leads: reconcile('POST', ['search_leads', 'get_credits'], ['global_person_ids']),
51
+ estimate_lead_import: read(),
52
+ import_leads_to_table: reconcile('POST', ['get_lists', 'get_list_rows'], ['list_id', 'new_list_name']),
53
+ save_search: idempotent('POST', ['list_saved_searches'], ['name']),
54
+ bulk_verify_leads: reconcile('POST', ['list_jobs'], ['lead_ids', 'global_person_ids']),
55
+ search_local_leads: read(),
56
+ estimate_local_leads: read(),
57
+ reveal_local_lead: idempotent('POST', ['search_local_leads', 'get_credits'], ['place_id']),
58
+ fill_coverage_gap: reconcile('POST', ['list_jobs', 'search_local_leads'], ['filters']),
59
+ verify_email: never('POST', ['get_credits'], ['email']),
60
+ verify_catchall: keyed('POST', ['get_credits'], ['email']),
61
+ preview_cleaners: read(),
62
+ apply_cleaners: reconcile('POST', ['get_lists'], ['list_id', 'cleaners']),
63
+ create_preset: reconcile('POST', ['list_presets'], ['name']),
64
+ estimate_enrich: read(),
65
+ run_enrich: never('POST', ['list_jobs'], ['preset_slug', 'preset_id', 'lead_ids', 'list_id']),
66
+ test_recipe: never('POST', ['get_credits'], ['lead_id']),
67
+ update_ai_settings: idempotent('PUT', ['get_ai_settings'], ['default_ai_model', 'enabled_models']),
68
+ update_ai_context: idempotent('PUT', ['get_ai_context'], ['company_description', 'icp']),
69
+ generate_ai_context: never('POST', ['get_ai_context', 'get_credits'], ['domain']),
70
+ create_strategy: reconcile('POST', ['list_strategies'], ['name']),
71
+ assign_strategy: reconcile('POST', ['list_strategies'], ['strategy_id', 'lead_ids', 'list_id']),
72
+ import_instantly_campaigns: reconcile('POST', ['list_campaigns'], ['credential_id', 'campaign_ids']),
73
+ import_instantly_lead_list: reconcile('POST', ['get_lists'], ['credential_id', 'lead_list_id']),
74
+ create_segment: reconcile('POST', ['list_segments'], ['name']),
75
+ preview_segment: read(),
76
+ preview_add_leads_to_campaign: read(),
77
+ add_leads_to_campaign: never('POST', ['list_campaigns', 'campaign_stats'], ['campaign_id', 'list_id']),
78
+ create_campaign: keyed('POST', ['list_campaigns'], ['name', 'sender_credential_id', 'source_list_id']),
79
+ update_campaign: idempotent('PATCH', ['list_campaigns'], ['campaign_id']),
80
+ duplicate_campaign: keyed('POST', ['list_campaigns'], ['campaign_id']),
81
+ activate_campaign: keyed('POST', ['list_campaigns', 'campaign_stats'], ['campaign_id', 'status']),
82
+ pause_campaign: reconcile('POST', ['list_campaigns'], ['campaign_id', 'status']),
83
+ sync_campaign: idempotent('POST', ['campaign_stats'], ['campaign_id']),
84
+ update_sender_config: idempotent('PUT', ['get_sender_config'], ['credential_id']),
85
+ create_list: keyed('POST', ['get_lists'], ['name']),
86
+ add_list_members: idempotent('POST', ['get_list_rows'], ['list_id', 'global_person_ids']),
87
+ create_workbook: reconcile('POST', ['list_workbooks'], ['name', 'list_ids']),
88
+ add_table_to_workbook: reconcile(
89
+ 'POST',
90
+ ['list_workbooks'],
91
+ ['workbook_id', 'list_id', 'new_table_name'],
92
+ ),
93
+ remove_table_from_workbook: reconcile(
94
+ 'DELETE',
95
+ ['list_workbooks'],
96
+ ['workbook_id', 'list_id'],
97
+ ),
98
+ reorder_workbook_table: idempotent(
99
+ 'PATCH',
100
+ ['list_workbooks'],
101
+ ['workbook_id', 'list_id', 'position'],
102
+ ),
103
+ duplicate_workbook: reconcile(
104
+ 'POST',
105
+ ['list_workbooks'],
106
+ ['workbook_id', 'name', 'folder_id'],
107
+ ),
108
+ create_folder: reconcile('POST', ['list_workbooks'], ['name']),
109
+ move_to_folder: idempotent(
110
+ 'PATCH',
111
+ ['list_workbooks'],
112
+ ['folder_id', 'workbook_id', 'list_id'],
113
+ ),
114
+ delete_folder: never('DELETE', ['list_workbooks'], ['folder_id']),
115
+ create_table: idempotent('POST', ['get_tables'], ['name', 'operation_id']),
116
+ create_table_column: idempotent(
117
+ 'POST',
118
+ ['get_table_columns'],
119
+ ['table_id', 'label', 'operation_id'],
120
+ ),
121
+ create_table_preset_column: idempotent(
122
+ 'POST',
123
+ ['get_table_columns'],
124
+ ['table_id', 'preset_slug', 'preset_id', 'label', 'operation_id'],
125
+ ),
126
+ set_table_cells: idempotent('POST', ['list_table_rows'], ['table_id']),
127
+ import_leads: idempotent(
128
+ 'POST',
129
+ ['get_tables', 'get_list_rows'],
130
+ ['list_id', 'list_name', 'dedupe_by', 'operation_id'],
131
+ ),
132
+ import_leads_csv: idempotent(
133
+ 'POST',
134
+ ['get_tables', 'get_list_rows'],
135
+ ['list_id', 'list_name', 'dedupe_by', 'operation_id'],
136
+ ),
137
+ preview_import: read(),
138
+ preview_apify_import: read(),
139
+ import_apify_dataset: idempotent(
140
+ 'POST',
141
+ ['get_tables', 'get_list_rows'],
142
+ ['list_id', 'list_name', 'dataset_id', 'preview_hash'],
143
+ ),
144
+ capture_community_intent: idempotent(
145
+ 'POST',
146
+ ['get_tables', 'get_list_rows'],
147
+ ['source_url', 'public_profile_url', 'observed_at', 'operation_id'],
148
+ ),
149
+ save_flow_layout: idempotent('PUT', ['get_flow_graph'], ['scope_key']),
150
+ create_table_flow_rule: reconcile('POST', ['list_table_flow_rules'], ['list_id', 'name']),
151
+ toggle_table_flow_rule: idempotent('PATCH', ['list_table_flow_rules'], ['list_id', 'rule_id', 'enabled']),
152
+ create_campaign_flow_rule: reconcile(
153
+ 'POST',
154
+ ['list_campaign_flow_rules'],
155
+ ['campaign_id', 'name'],
156
+ ),
157
+ toggle_campaign_flow_rule: idempotent(
158
+ 'PATCH',
159
+ ['list_campaign_flow_rules'],
160
+ ['campaign_id', 'rule_id', 'enabled'],
161
+ ),
162
+ test_flow_rule: never(
163
+ 'POST',
164
+ ['get_flow_rule_stats', 'list_table_flow_rules', 'list_campaign_flow_rules'],
165
+ ['list_id', 'campaign_id', 'rule_id', 'lead_id', 'execute'],
166
+ ),
167
+ preview_send_to_table: read(),
168
+ send_to_table: idempotent('POST', ['get_list_rows'], ['list_id', 'destination_list_id', 'new_table_name']),
169
+ preview_table_write_back: read(),
170
+ apply_table_write_back: idempotent('POST', ['get_list_rows'], ['list_id', 'column_id', 'field']),
171
+ export_table_csv: reconcile('POST', ['get_table_export'], ['list_id', 'filename']),
172
+ create_table_view: idempotent(
173
+ 'POST',
174
+ ['list_table_views'],
175
+ ['list_id', 'name', 'operation_id'],
176
+ ),
177
+ update_table_view: idempotent('PATCH', ['list_table_views'], ['list_id', 'view_id']),
178
+ delete_table_view: reconcile('DELETE', ['list_table_views'], ['list_id', 'view_id']),
179
+ estimate_table_column: read(),
180
+ run_table_column: never('POST', ['get_list_history'], ['list_id', 'column_id']),
181
+ run_scope_summary: read(),
182
+ estimate_table_run_all: read(),
183
+ run_table_all: never('POST', ['get_list_history'], ['list_id', 'column_ids']),
184
+ remove_table_rows: reconcile('DELETE', ['list_table_rows'], ['list_id', 'lead_ids']),
185
+ create_list_webhook: keyed('POST', ['get_list_webhook'], ['list_id']),
186
+ update_list_webhook: idempotent('PATCH', ['get_list_webhook'], ['list_id']),
187
+ revoke_list_webhook: never('DELETE', ['get_list_webhook'], ['list_id']),
188
+ export_list_to_webhook: never('POST', ['get_list_history'], ['list_id']),
189
+ delete_list: never('DELETE', ['get_lists'], ['list_id']),
190
+ delete_campaign: never('DELETE', ['list_campaigns'], ['campaign_id']),
191
+ update_reply: idempotent('PATCH', ['list_replies'], ['reply_id']),
192
+ add_suppression_entry: reconcile('POST', ['list_suppression_entries'], ['kind', 'value']),
193
+ remove_suppression_entry: reconcile('DELETE', ['list_suppression_entries'], ['entry_id']),
194
+ update_suppression_settings: idempotent('PUT', ['get_suppression_settings'], ['auto_suppress_mode']),
195
+ roadmap_update_status: idempotent('PATCH', ['roadmap_list'], ['slug', 'status']),
196
+ roadmap_create_item: reconcile('POST', ['roadmap_list'], ['slug']),
197
+ roadmap_update_plan: idempotent('PATCH', ['roadmap_list'], ['slug']),
198
+ });
199
+
200
+ export const RETRY_CONTRACT_COPY = Object.freeze({
201
+ bounded: 'Read-only operation. Retries transport errors, 429, and 5xx with bounded backoff.',
202
+ idempotent: 'Proven idempotent write. Retries transient failures with bounded backoff.',
203
+ idempotency_key: 'Durable Idempotency-Key required. Transient retries replay one stored result.',
204
+ reconcile: 'One request only. An ambiguous result returns reconciliation tools and stable match fields.',
205
+ never: 'Never retried automatically. An ambiguous result must be reconciled before any new attempt.',
206
+ });