mcp-scraper 0.88.2 → 0.89.0

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 (87) hide show
  1. package/CHANGELOG.md +36 -15
  2. package/README.md +6 -5
  3. package/THIRD_PARTY_NOTICES.html +203 -0
  4. package/dist/analytics-repository-2BMT5JNE.js +1 -0
  5. package/dist/bin/api-server.js +2 -41
  6. package/dist/bin/mcp-scraper-cli.js +39 -756
  7. package/dist/bin/mcp-scraper-core.js +1 -60
  8. package/dist/bin/mcp-scraper-install.js +2 -25
  9. package/dist/bin/mcp-stdio-server.js +1 -19
  10. package/dist/bin/paa-harvest.js +1 -41
  11. package/dist/chunk-3GP5CYZX.js +1 -0
  12. package/dist/chunk-4AI7DOS7.js +59 -0
  13. package/dist/chunk-4FROKQJN.js +1 -0
  14. package/dist/chunk-7YGVI5J4.js +21710 -0
  15. package/dist/chunk-CCYWSJNG.js +16 -0
  16. package/dist/chunk-CFI6CXIV.js +182 -0
  17. package/dist/chunk-E2WRWV3A.js +1 -0
  18. package/dist/chunk-GMWKPIYX.js +1172 -0
  19. package/dist/chunk-HDPYG3XV.js +102 -0
  20. package/dist/chunk-HE45FFBU.js +1 -0
  21. package/dist/chunk-HUV2WTRW.js +1 -0
  22. package/dist/chunk-KJQXUZ4Y.js +4 -0
  23. package/dist/chunk-L4CGLFPU.js +4 -0
  24. package/dist/chunk-M22MM4N4.js +84 -0
  25. package/dist/chunk-MASR22K4.js +73 -0
  26. package/dist/chunk-MZN4U5BL.js +1 -0
  27. package/dist/chunk-PUHFVA7P.js +1280 -0
  28. package/dist/chunk-QPWPR5XG.js +10 -0
  29. package/dist/chunk-TMB56NCA.js +1 -0
  30. package/dist/chunk-TXENITMS.js +20 -0
  31. package/dist/chunk-W2BVJ7S2.js +13 -0
  32. package/dist/chunk-WO3N5FH2.js +5 -0
  33. package/dist/chunk-WSCGYRWA.js +2595 -0
  34. package/dist/chunk-X54CQLK2.js +1 -0
  35. package/dist/chunk-XLWNEVUZ.js +27 -0
  36. package/dist/chunk-XPZVJIZ2.js +100 -0
  37. package/dist/chunk-YQZGZBB4.js +1 -0
  38. package/dist/chunk-Z2QGQJS2.js +1 -0
  39. package/dist/db-F2MX63GI.js +1 -0
  40. package/dist/extract-bundle-SNUIHM3J.js +26 -0
  41. package/dist/gmail-service-BZ3H75XC.js +1 -0
  42. package/dist/index.cjs +21750 -6045
  43. package/dist/index.d.cts +14 -14
  44. package/dist/index.d.ts +14 -14
  45. package/dist/index.js +18 -315
  46. package/dist/lead-list-enrichment-repository-S2H3U7T7.js +1 -0
  47. package/dist/location-data-repository-OTWHWMV6.js +1 -0
  48. package/dist/server-RFR2A5UJ.js +7303 -0
  49. package/dist/site-extract-repository-SE776XDC.js +1 -0
  50. package/dist/worker-XUDSM3AL.js +1 -0
  51. package/package.json +17 -124
  52. package/dist/analytics-repository-GGJJCVVP.js +0 -194
  53. package/dist/chunk-4QMUF6XM.js +0 -1013
  54. package/dist/chunk-6HAV7LCE.js +0 -265
  55. package/dist/chunk-ABF2CGOZ.js +0 -113
  56. package/dist/chunk-C5Z4OFKW.js +0 -404
  57. package/dist/chunk-DNM65UCK.js +0 -299
  58. package/dist/chunk-EQGTEHLZ.js +0 -592
  59. package/dist/chunk-F5GQJWZU.js +0 -732
  60. package/dist/chunk-GGZEC22A.js +0 -215
  61. package/dist/chunk-GXBZXWXB.js +0 -184
  62. package/dist/chunk-IHXAXYIS.js +0 -843
  63. package/dist/chunk-K3Z5AQYE.js +0 -683
  64. package/dist/chunk-K45K75OF.js +0 -6
  65. package/dist/chunk-LFW2FRPJ.js +0 -224
  66. package/dist/chunk-MZDNZQWT.js +0 -2078
  67. package/dist/chunk-NVUKO5NN.js +0 -256
  68. package/dist/chunk-OM7HVEJ3.js +0 -26
  69. package/dist/chunk-OPQIGAFB.js +0 -286
  70. package/dist/chunk-OZJMVCDK.js +0 -16
  71. package/dist/chunk-P7FWOMU7.js +0 -505
  72. package/dist/chunk-PGJQDMC2.js +0 -383
  73. package/dist/chunk-PKZS6SHW.js +0 -33139
  74. package/dist/chunk-RJ7JVYKU.js +0 -68
  75. package/dist/chunk-S24LFPL7.js +0 -5262
  76. package/dist/chunk-T3MZISOF.js +0 -240
  77. package/dist/chunk-UZPTGUDV.js +0 -1915
  78. package/dist/chunk-X623GTBV.js +0 -8290
  79. package/dist/chunk-YXNDOQXN.js +0 -4018
  80. package/dist/db-Z34LPZNR.js +0 -284
  81. package/dist/extract-bundle-565SBZCR.js +0 -1003
  82. package/dist/gmail-service-E6ALS7JG.js +0 -25
  83. package/dist/lead-list-enrichment-repository-36RPVV6N.js +0 -67
  84. package/dist/location-data-repository-WPRG62GE.js +0 -34
  85. package/dist/server-SQZ3A7SY.js +0 -86606
  86. package/dist/site-extract-repository-VYFZASPU.js +0 -69
  87. package/dist/worker-LDCAULWL.js +0 -146
@@ -1,404 +0,0 @@
1
- import {
2
- getDb,
3
- getUserByEmail
4
- } from "./chunk-YXNDOQXN.js";
5
-
6
- // src/api/session.ts
7
- import { createHmac, timingSafeEqual } from "crypto";
8
- var isProduction = () => process.env.NODE_ENV === "production" || process.env.VERCEL === "1";
9
- function getSessionSecret() {
10
- const configured = process.env.SESSION_SECRET?.trim();
11
- if (configured) return configured;
12
- if (isProduction()) throw new Error("SESSION_SECRET is not set \u2014 add it to your Vercel env vars (see src/api/env.ts)");
13
- return "dev-secret-change-me";
14
- }
15
- var secret = () => getSessionSecret();
16
- function safeEqualHex(a, b) {
17
- if (a.length !== b.length) return false;
18
- try {
19
- return timingSafeEqual(Buffer.from(a, "hex"), Buffer.from(b, "hex"));
20
- } catch {
21
- return false;
22
- }
23
- }
24
- function signSession(userId) {
25
- const payload = String(userId);
26
- const sig = createHmac("sha256", secret()).update(payload).digest("hex");
27
- return `${payload}.${sig}`;
28
- }
29
- function verifySession(token) {
30
- const dot = token.lastIndexOf(".");
31
- if (dot === -1) return null;
32
- const payload = token.slice(0, dot);
33
- const sig = token.slice(dot + 1);
34
- const expected = createHmac("sha256", secret()).update(payload).digest("hex");
35
- if (!safeEqualHex(sig, expected)) return null;
36
- const id = parseInt(payload);
37
- return isNaN(id) ? null : id;
38
- }
39
-
40
- // src/api/service-connections.ts
41
- import { randomUUID } from "crypto";
42
- function serviceConnectionAdvertisesAction(connection, providerConfigKeys, actionName) {
43
- return connection.lifecycleStatus === "connected" && connection.actionsEnabled && providerConfigKeys.includes(connection.providerConfigKey) && connection.actionTools.includes(actionName);
44
- }
45
- var schemaReady = null;
46
- var schemaDb = null;
47
- function ensureServiceConnectionsSchema() {
48
- const currentDb = getDb();
49
- if (schemaReady && schemaDb === currentDb) return schemaReady;
50
- schemaDb = currentDb;
51
- schemaReady = (async () => {
52
- const db = currentDb;
53
- await db.execute(`
54
- CREATE TABLE IF NOT EXISTS service_connections (
55
- id TEXT PRIMARY KEY,
56
- user_id INTEGER NOT NULL REFERENCES users(id),
57
- provider_config_key TEXT NOT NULL,
58
- provider TEXT,
59
- transport TEXT NOT NULL,
60
- upstream_connection_id TEXT,
61
- label TEXT,
62
- user_label TEXT,
63
- provider_account_id TEXT,
64
- provider_account_email TEXT,
65
- provider_account_name TEXT,
66
- provider_identity_checked_at TEXT,
67
- provider_identity_source_updated_at TEXT,
68
- lifecycle_status TEXT NOT NULL DEFAULT 'pending',
69
- operational_status TEXT NOT NULL DEFAULT 'unknown',
70
- reconnect_required INTEGER NOT NULL DEFAULT 0,
71
- actions_enabled INTEGER NOT NULL DEFAULT 0,
72
- read_tools_json TEXT NOT NULL DEFAULT '[]',
73
- action_tools_json TEXT NOT NULL DEFAULT '[]',
74
- tool_revision TEXT,
75
- last_checked_at TEXT,
76
- last_successful_call_at TEXT,
77
- last_failure_at TEXT,
78
- last_failure_code TEXT,
79
- last_failure_retryable INTEGER,
80
- consecutive_failures INTEGER NOT NULL DEFAULT 0,
81
- vault_name TEXT,
82
- table_name TEXT,
83
- legacy_owner_identity TEXT,
84
- created_at TEXT NOT NULL DEFAULT (datetime('now')),
85
- updated_at TEXT NOT NULL DEFAULT (datetime('now')),
86
- UNIQUE(user_id, provider_config_key, upstream_connection_id)
87
- )
88
- `);
89
- try {
90
- await db.execute(`ALTER TABLE service_connections ADD COLUMN user_label TEXT`);
91
- } catch {
92
- }
93
- try {
94
- await db.execute(`ALTER TABLE service_connections ADD COLUMN provider_account_id TEXT`);
95
- } catch {
96
- }
97
- try {
98
- await db.execute(`ALTER TABLE service_connections ADD COLUMN provider_account_email TEXT`);
99
- } catch {
100
- }
101
- try {
102
- await db.execute(`ALTER TABLE service_connections ADD COLUMN provider_account_name TEXT`);
103
- } catch {
104
- }
105
- try {
106
- await db.execute(`ALTER TABLE service_connections ADD COLUMN provider_identity_checked_at TEXT`);
107
- } catch {
108
- }
109
- try {
110
- await db.execute(`ALTER TABLE service_connections ADD COLUMN provider_identity_source_updated_at TEXT`);
111
- } catch {
112
- }
113
- await db.execute(`CREATE INDEX IF NOT EXISTS service_connections_user_updated ON service_connections(user_id, updated_at DESC)`);
114
- await db.execute(`CREATE INDEX IF NOT EXISTS service_connections_upstream ON service_connections(provider_config_key, upstream_connection_id)`);
115
- await db.execute(`
116
- CREATE TABLE IF NOT EXISTS service_connection_health_events (
117
- id TEXT PRIMARY KEY,
118
- connection_id TEXT NOT NULL REFERENCES service_connections(id) ON DELETE CASCADE,
119
- operational_status TEXT NOT NULL,
120
- failure_code TEXT,
121
- retryable INTEGER,
122
- evidence_source TEXT NOT NULL,
123
- created_at TEXT NOT NULL DEFAULT (datetime('now'))
124
- )
125
- `);
126
- await db.execute(`CREATE INDEX IF NOT EXISTS service_connection_health_events_connection ON service_connection_health_events(connection_id, created_at DESC)`);
127
- await db.execute(`
128
- CREATE TABLE IF NOT EXISTS service_connection_action_audit (
129
- id TEXT PRIMARY KEY,
130
- connection_id TEXT NOT NULL REFERENCES service_connections(id) ON DELETE CASCADE,
131
- user_id INTEGER NOT NULL REFERENCES users(id),
132
- tool TEXT NOT NULL,
133
- request_id TEXT NOT NULL,
134
- status TEXT NOT NULL,
135
- error_code TEXT,
136
- created_at TEXT NOT NULL DEFAULT (datetime('now')),
137
- UNIQUE(user_id, request_id)
138
- )
139
- `);
140
- try {
141
- await db.execute(`ALTER TABLE service_connection_action_audit ADD COLUMN request_digest TEXT`);
142
- } catch {
143
- }
144
- try {
145
- await db.execute(`ALTER TABLE service_connection_action_audit ADD COLUMN result_json TEXT`);
146
- } catch {
147
- }
148
- })().catch((error) => {
149
- schemaReady = null;
150
- schemaDb = null;
151
- throw error;
152
- });
153
- return schemaReady;
154
- }
155
- function parseTools(value) {
156
- if (typeof value !== "string") return [];
157
- try {
158
- const parsed = JSON.parse(value);
159
- return Array.isArray(parsed) ? parsed.filter((item) => typeof item === "string") : [];
160
- } catch {
161
- return [];
162
- }
163
- }
164
- function rowToRecord(row) {
165
- return {
166
- id: String(row.id),
167
- userId: Number(row.user_id),
168
- providerConfigKey: String(row.provider_config_key),
169
- provider: typeof row.provider === "string" ? row.provider : null,
170
- transport: row.transport === "remote_mcp" ? "remote_mcp" : row.transport === "credential_reference" ? "credential_reference" : "nango",
171
- upstreamConnectionId: typeof row.upstream_connection_id === "string" ? row.upstream_connection_id : null,
172
- label: typeof row.label === "string" ? row.label : null,
173
- userLabel: typeof row.user_label === "string" ? row.user_label : null,
174
- providerAccountId: typeof row.provider_account_id === "string" ? row.provider_account_id : null,
175
- providerAccountEmail: typeof row.provider_account_email === "string" ? row.provider_account_email : null,
176
- providerAccountName: typeof row.provider_account_name === "string" ? row.provider_account_name : null,
177
- providerIdentityCheckedAt: typeof row.provider_identity_checked_at === "string" ? row.provider_identity_checked_at : null,
178
- providerIdentitySourceUpdatedAt: typeof row.provider_identity_source_updated_at === "string" ? row.provider_identity_source_updated_at : null,
179
- lifecycleStatus: String(row.lifecycle_status),
180
- operationalStatus: String(row.operational_status),
181
- reconnectRequired: Number(row.reconnect_required) === 1,
182
- actionsEnabled: Number(row.actions_enabled) === 1,
183
- readTools: parseTools(row.read_tools_json),
184
- actionTools: parseTools(row.action_tools_json),
185
- toolRevision: typeof row.tool_revision === "string" ? row.tool_revision : null,
186
- lastCheckedAt: typeof row.last_checked_at === "string" ? row.last_checked_at : null,
187
- lastSuccessfulCallAt: typeof row.last_successful_call_at === "string" ? row.last_successful_call_at : null,
188
- lastFailureAt: typeof row.last_failure_at === "string" ? row.last_failure_at : null,
189
- lastFailureCode: typeof row.last_failure_code === "string" ? row.last_failure_code : null,
190
- lastFailureRetryable: row.last_failure_retryable === null || row.last_failure_retryable === void 0 ? null : Number(row.last_failure_retryable) === 1,
191
- consecutiveFailures: Number(row.consecutive_failures ?? 0),
192
- vaultName: typeof row.vault_name === "string" ? row.vault_name : null,
193
- tableName: typeof row.table_name === "string" ? row.table_name : null,
194
- createdAt: String(row.created_at),
195
- updatedAt: String(row.updated_at)
196
- };
197
- }
198
- async function userIdForIdentity(identity) {
199
- const user = await getUserByEmail(identity.normalize("NFKC").trim().toLowerCase());
200
- if (!user) throw new Error("service_connection_user_not_found");
201
- return Number(user.id);
202
- }
203
- async function reconcileDiscoveredNangoConnections(identity, discovered) {
204
- await ensureServiceConnectionsSchema();
205
- const db = getDb();
206
- const userId = await userIdForIdentity(identity);
207
- for (const connection of discovered) {
208
- await db.execute({
209
- sql: `
210
- INSERT INTO service_connections (
211
- id, user_id, provider_config_key, provider, transport, upstream_connection_id,
212
- label, lifecycle_status, reconnect_required, actions_enabled, legacy_owner_identity, created_at, updated_at
213
- ) VALUES (?, ?, ?, ?, 'nango', ?, ?, ?, ?, 1, ?, COALESCE(?, datetime('now')), COALESCE(?, datetime('now')))
214
- ON CONFLICT(user_id, provider_config_key, upstream_connection_id) DO UPDATE SET
215
- provider = excluded.provider,
216
- label = COALESCE(excluded.label, service_connections.label),
217
- lifecycle_status = excluded.lifecycle_status,
218
- reconnect_required = excluded.reconnect_required,
219
- updated_at = excluded.updated_at
220
- `,
221
- args: [
222
- randomUUID(),
223
- userId,
224
- connection.providerConfigKey,
225
- connection.provider,
226
- connection.upstreamConnectionId,
227
- connection.label,
228
- connection.lifecycleStatus,
229
- connection.reconnectRequired ? 1 : 0,
230
- identity,
231
- connection.createdAt,
232
- connection.updatedAt
233
- ]
234
- });
235
- }
236
- return listServiceConnections(identity, "nango");
237
- }
238
- async function listServiceConnections(identity, transport) {
239
- await ensureServiceConnectionsSchema();
240
- const userId = await userIdForIdentity(identity);
241
- const result = await getDb().execute({
242
- sql: `SELECT * FROM service_connections WHERE user_id = ?${transport ? " AND transport = ?" : ""} AND lifecycle_status <> 'disconnected' ORDER BY updated_at DESC`,
243
- args: transport ? [userId, transport] : [userId]
244
- });
245
- return result.rows.map((row) => rowToRecord(row));
246
- }
247
- async function getOwnedServiceConnection(identity, connectionId) {
248
- await ensureServiceConnectionsSchema();
249
- const userId = await userIdForIdentity(identity);
250
- const result = await getDb().execute({
251
- sql: "SELECT * FROM service_connections WHERE id = ? AND user_id = ? LIMIT 1",
252
- args: [connectionId, userId]
253
- });
254
- const row = result.rows[0];
255
- return row ? rowToRecord(row) : null;
256
- }
257
- async function updateServiceConnectionTools(connectionId, readTools, actionTools, toolRevision) {
258
- await ensureServiceConnectionsSchema();
259
- await getDb().execute({
260
- sql: `UPDATE service_connections SET read_tools_json = ?, action_tools_json = ?, tool_revision = ?, updated_at = datetime('now') WHERE id = ?`,
261
- args: [JSON.stringify(readTools), JSON.stringify(actionTools), toolRevision, connectionId]
262
- });
263
- }
264
- async function setServiceConnectionProviderIdentity(args) {
265
- await ensureServiceConnectionsSchema();
266
- await getDb().execute({
267
- sql: `
268
- UPDATE service_connections SET
269
- provider_account_id = ?, provider_account_email = ?, provider_account_name = ?,
270
- provider_identity_checked_at = datetime('now'), provider_identity_source_updated_at = ?,
271
- updated_at = datetime('now')
272
- WHERE id = ?
273
- `,
274
- args: [
275
- args.providerAccountId ?? null,
276
- args.providerAccountEmail?.toLowerCase() ?? null,
277
- args.providerAccountName ?? null,
278
- args.sourceUpdatedAt,
279
- args.connectionId
280
- ]
281
- });
282
- }
283
- async function setServiceConnectionUserLabel(identity, connectionId, userLabel) {
284
- const connection = await getOwnedServiceConnection(identity, connectionId);
285
- if (!connection || connection.lifecycleStatus === "disconnected") throw new Error("service_connection_not_found");
286
- await getDb().execute({
287
- sql: `UPDATE service_connections SET user_label = ?, updated_at = datetime('now') WHERE id = ? AND user_id = ?`,
288
- args: [userLabel, connectionId, connection.userId]
289
- });
290
- return userLabel;
291
- }
292
- async function recordServiceConnectionHealth(args) {
293
- await ensureServiceConnectionsSchema();
294
- const now = (/* @__PURE__ */ new Date()).toISOString();
295
- await getDb().execute({
296
- sql: `
297
- UPDATE service_connections SET
298
- operational_status = ?, last_checked_at = ?,
299
- last_successful_call_at = CASE WHEN ? = 'available' THEN ? ELSE last_successful_call_at END,
300
- last_failure_at = CASE WHEN ? IN ('degraded', 'unavailable') THEN ? ELSE NULL END,
301
- last_failure_code = ?, last_failure_retryable = ?,
302
- consecutive_failures = CASE WHEN ? = 'available' THEN 0 ELSE consecutive_failures + 1 END,
303
- updated_at = datetime('now')
304
- WHERE id = ?
305
- `,
306
- args: [
307
- args.operationalStatus,
308
- now,
309
- args.operationalStatus,
310
- now,
311
- args.operationalStatus,
312
- now,
313
- args.failureCode ?? null,
314
- args.retryable == null ? null : args.retryable ? 1 : 0,
315
- args.operationalStatus,
316
- args.connectionId
317
- ]
318
- });
319
- await getDb().execute({
320
- sql: `INSERT INTO service_connection_health_events (id, connection_id, operational_status, failure_code, retryable, evidence_source) VALUES (?, ?, ?, ?, ?, ?)`,
321
- args: [randomUUID(), args.connectionId, args.operationalStatus, args.failureCode ?? null, args.retryable == null ? null : args.retryable ? 1 : 0, args.evidenceSource]
322
- });
323
- }
324
- async function setServiceConnectionActions(identity, connectionId, enabled) {
325
- const connection = await getOwnedServiceConnection(identity, connectionId);
326
- if (!connection || connection.lifecycleStatus === "disconnected") throw new Error("service_connection_not_found");
327
- await getDb().execute({
328
- sql: `UPDATE service_connections SET actions_enabled = ?, updated_at = datetime('now') WHERE id = ? AND user_id = ?`,
329
- args: [enabled ? 1 : 0, connectionId, connection.userId]
330
- });
331
- return enabled;
332
- }
333
- async function markServiceConnectionDisconnected(identity, connectionId) {
334
- const connection = await getOwnedServiceConnection(identity, connectionId);
335
- if (!connection) throw new Error("service_connection_not_found");
336
- await getDb().execute({
337
- sql: `UPDATE service_connections SET lifecycle_status = 'disconnected', operational_status = 'unknown', reconnect_required = 0, updated_at = datetime('now') WHERE id = ? AND user_id = ?`,
338
- args: [connectionId, connection.userId]
339
- });
340
- const remaining = await getDb().execute({
341
- sql: `SELECT COUNT(*) AS count FROM service_connections WHERE user_id = ? AND transport = 'nango' AND lifecycle_status = 'connected'`,
342
- args: [connection.userId]
343
- });
344
- return Number(remaining.rows[0]?.count ?? 0);
345
- }
346
- async function recordServiceConnectionAction(args) {
347
- await ensureServiceConnectionsSchema();
348
- const connection = await getOwnedServiceConnection(args.identity, args.connectionId);
349
- if (!connection) throw new Error("service_connection_not_found");
350
- await getDb().execute({
351
- sql: `UPDATE service_connection_action_audit SET status = ?, error_code = ?, result_json = ? WHERE user_id = ? AND request_id = ? AND connection_id = ?`,
352
- args: [args.status, args.errorCode ?? null, args.result === void 0 ? null : JSON.stringify(args.result), connection.userId, args.requestId, connection.id]
353
- });
354
- }
355
- async function claimServiceConnectionAction(args) {
356
- await ensureServiceConnectionsSchema();
357
- const connection = await getOwnedServiceConnection(args.identity, args.connectionId);
358
- if (!connection) throw new Error("service_connection_not_found");
359
- const inserted = await getDb().execute({
360
- sql: `INSERT OR IGNORE INTO service_connection_action_audit (id, connection_id, user_id, tool, request_id, status, request_digest) VALUES (?, ?, ?, ?, ?, 'started', ?)`,
361
- args: [randomUUID(), connection.id, connection.userId, args.tool, args.requestId, args.requestDigest]
362
- });
363
- if (Number(inserted.rowsAffected ?? 0) === 1) return { claimed: true };
364
- const existing = await getDb().execute({
365
- sql: `SELECT connection_id, tool, status, error_code, request_digest, result_json FROM service_connection_action_audit WHERE user_id = ? AND request_id = ? LIMIT 1`,
366
- args: [connection.userId, args.requestId]
367
- });
368
- const row = existing.rows[0];
369
- const conflict = String(row?.connection_id ?? "") !== connection.id || String(row?.tool ?? "") !== args.tool || String(row?.request_digest ?? "") !== args.requestDigest;
370
- let result = void 0;
371
- if (!conflict && typeof row?.result_json === "string") {
372
- try {
373
- result = JSON.parse(row.result_json);
374
- } catch {
375
- result = void 0;
376
- }
377
- }
378
- return {
379
- claimed: false,
380
- status: String(row?.status ?? "unknown"),
381
- errorCode: typeof row?.error_code === "string" ? row.error_code : null,
382
- conflict,
383
- ...result !== void 0 ? { result } : {}
384
- };
385
- }
386
-
387
- export {
388
- getSessionSecret,
389
- signSession,
390
- verifySession,
391
- serviceConnectionAdvertisesAction,
392
- ensureServiceConnectionsSchema,
393
- reconcileDiscoveredNangoConnections,
394
- listServiceConnections,
395
- getOwnedServiceConnection,
396
- updateServiceConnectionTools,
397
- setServiceConnectionProviderIdentity,
398
- setServiceConnectionUserLabel,
399
- recordServiceConnectionHealth,
400
- setServiceConnectionActions,
401
- markServiceConnectionDisconnected,
402
- recordServiceConnectionAction,
403
- claimServiceConnectionAction
404
- };