@ever-works/linkup-plugin 1.0.0 → 1.0.2
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.
- package/dist/index.cjs +339 -0
- package/dist/index.d.cts +28 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.js +334 -0
- package/package.json +88 -75
- package/LICENSE +0 -661
- package/src/__tests__/linkup.plugin.spec.ts +0 -297
- package/src/index.ts +0 -2
- package/src/linkup.plugin.ts +0 -369
- package/tsconfig.json +0 -22
- package/tsup.config.ts +0 -12
package/dist/index.js
ADDED
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
import { isIP } from 'net';
|
|
2
|
+
|
|
3
|
+
// ../../plugin/dist/helpers/ssrf-guard.js
|
|
4
|
+
function isSafeWebhookUrl(rawUrl) {
|
|
5
|
+
let url;
|
|
6
|
+
try {
|
|
7
|
+
url = new URL(rawUrl);
|
|
8
|
+
} catch {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
if (url.protocol !== "https:" && url.protocol !== "http:") {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
let host = url.hostname.toLowerCase();
|
|
15
|
+
if (host.startsWith("[") && host.endsWith("]")) {
|
|
16
|
+
host = host.slice(1, -1);
|
|
17
|
+
}
|
|
18
|
+
if (CLOUD_METADATA_HOSTNAMES.has(host)) {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
const ipKind = isIP(host);
|
|
22
|
+
if (ipKind === 4 && isPrivateIPv4(host)) return false;
|
|
23
|
+
if (ipKind === 6 && isPrivateIPv6(host)) return false;
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
var CLOUD_METADATA_HOSTNAMES = /* @__PURE__ */ new Set([
|
|
27
|
+
// GCP
|
|
28
|
+
"metadata.google.internal",
|
|
29
|
+
"metadata.goog",
|
|
30
|
+
// AWS
|
|
31
|
+
"instance-data",
|
|
32
|
+
"instance-data.ec2.internal",
|
|
33
|
+
// Azure
|
|
34
|
+
"metadata.azure.internal"
|
|
35
|
+
]);
|
|
36
|
+
function isPrivateIPv4(ip) {
|
|
37
|
+
const parts = ip.split(".").map((p) => Number(p));
|
|
38
|
+
if (parts.length !== 4 || parts.some((n) => Number.isNaN(n))) return false;
|
|
39
|
+
const [a, b] = parts;
|
|
40
|
+
if (a === 10) return true;
|
|
41
|
+
if (a === 127) return true;
|
|
42
|
+
if (a === 0) return true;
|
|
43
|
+
if (a === 169 && b === 254) return true;
|
|
44
|
+
if (a === 172 && b >= 16 && b <= 31) return true;
|
|
45
|
+
if (a === 192 && b === 168) return true;
|
|
46
|
+
if (a === 192 && b === 0 && parts[2] === 0) return true;
|
|
47
|
+
if (a === 100 && b >= 64 && b <= 127) return true;
|
|
48
|
+
if (a >= 224) return true;
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
function isPrivateIPv6(ip) {
|
|
52
|
+
const lower = ip.toLowerCase();
|
|
53
|
+
if (lower === "::1" || lower === "::") return true;
|
|
54
|
+
if (lower.startsWith("fc") || lower.startsWith("fd")) return true;
|
|
55
|
+
const firstHextet = lower.split(":", 1)[0];
|
|
56
|
+
if (/^[0-9a-f]{1,4}$/.test(firstHextet)) {
|
|
57
|
+
const group0 = parseInt(firstHextet, 16);
|
|
58
|
+
if ((group0 & 65472) === 65152) return true;
|
|
59
|
+
}
|
|
60
|
+
if (lower.startsWith("::ffff:")) {
|
|
61
|
+
const v4 = lower.slice("::ffff:".length);
|
|
62
|
+
if (isIP(v4) === 4) return isPrivateIPv4(v4);
|
|
63
|
+
}
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// src/linkup.plugin.ts
|
|
68
|
+
var LINKUP_API_BASE = "https://api.linkup.so/v1";
|
|
69
|
+
var LinkupSearchPlugin = class {
|
|
70
|
+
id = "linkup";
|
|
71
|
+
name = "Linkup";
|
|
72
|
+
version = "1.0.0";
|
|
73
|
+
category = "search";
|
|
74
|
+
capabilities = ["search", "content-extractor"];
|
|
75
|
+
providerName = "Linkup";
|
|
76
|
+
settingsSchema = {
|
|
77
|
+
type: "object",
|
|
78
|
+
properties: {
|
|
79
|
+
apiKey: {
|
|
80
|
+
type: "string",
|
|
81
|
+
title: "API Key",
|
|
82
|
+
description: "Your Linkup API key. Get one at https://linkup.so",
|
|
83
|
+
"x-secret": true,
|
|
84
|
+
"x-envVar": "PLUGIN_LINKUP_API_KEY",
|
|
85
|
+
"x-scope": "user"
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
required: ["apiKey"]
|
|
89
|
+
};
|
|
90
|
+
configurationMode = "hybrid";
|
|
91
|
+
context;
|
|
92
|
+
async search(options) {
|
|
93
|
+
const apiKey = this.getApiKey(options.settings);
|
|
94
|
+
const startTime = Date.now();
|
|
95
|
+
try {
|
|
96
|
+
const body = {
|
|
97
|
+
q: options.query,
|
|
98
|
+
depth: "deep",
|
|
99
|
+
outputType: "searchResults"
|
|
100
|
+
};
|
|
101
|
+
if (options.includeDomains?.length) {
|
|
102
|
+
body.includeDomains = options.includeDomains;
|
|
103
|
+
}
|
|
104
|
+
if (options.excludeDomains?.length) {
|
|
105
|
+
body.excludeDomains = options.excludeDomains;
|
|
106
|
+
}
|
|
107
|
+
const response = await fetch(`${LINKUP_API_BASE}/search`, {
|
|
108
|
+
method: "POST",
|
|
109
|
+
headers: {
|
|
110
|
+
Authorization: `Bearer ${apiKey}`,
|
|
111
|
+
"Content-Type": "application/json"
|
|
112
|
+
},
|
|
113
|
+
body: JSON.stringify(body)
|
|
114
|
+
});
|
|
115
|
+
if (!response.ok) {
|
|
116
|
+
throw new Error(`Linkup search failed with status ${response.status}: ${response.statusText}`);
|
|
117
|
+
}
|
|
118
|
+
const data = await response.json();
|
|
119
|
+
const results = (data.results || data.sources || []).map((r, index) => ({
|
|
120
|
+
title: "name" in r ? r.name : "",
|
|
121
|
+
url: r.url,
|
|
122
|
+
snippet: "content" in r ? r.content : "snippet" in r ? r.snippet : "",
|
|
123
|
+
position: index + 1,
|
|
124
|
+
metadata: {}
|
|
125
|
+
}));
|
|
126
|
+
return {
|
|
127
|
+
results,
|
|
128
|
+
query: options.query,
|
|
129
|
+
totalResults: results.length,
|
|
130
|
+
hasMore: false,
|
|
131
|
+
duration: Date.now() - startTime
|
|
132
|
+
};
|
|
133
|
+
} catch (error) {
|
|
134
|
+
this.context?.logger.error(
|
|
135
|
+
`Linkup search failed: ${error instanceof Error ? error.message : String(error)}`
|
|
136
|
+
);
|
|
137
|
+
throw error;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
async isAvailable() {
|
|
141
|
+
if (!this.context) return false;
|
|
142
|
+
const settings = await this.context.getSettings();
|
|
143
|
+
return Boolean(settings?.apiKey);
|
|
144
|
+
}
|
|
145
|
+
async validateConnection(settings) {
|
|
146
|
+
const apiKey = settings.apiKey;
|
|
147
|
+
if (!apiKey) {
|
|
148
|
+
return { success: false, message: "Linkup API key is not configured." };
|
|
149
|
+
}
|
|
150
|
+
try {
|
|
151
|
+
const response = await fetch(`${LINKUP_API_BASE}/search`, {
|
|
152
|
+
method: "POST",
|
|
153
|
+
headers: {
|
|
154
|
+
Authorization: `Bearer ${apiKey}`,
|
|
155
|
+
"Content-Type": "application/json"
|
|
156
|
+
},
|
|
157
|
+
body: JSON.stringify({
|
|
158
|
+
q: "test",
|
|
159
|
+
depth: "standard",
|
|
160
|
+
outputType: "searchResults"
|
|
161
|
+
})
|
|
162
|
+
});
|
|
163
|
+
if (!response.ok) {
|
|
164
|
+
return {
|
|
165
|
+
success: false,
|
|
166
|
+
message: `Linkup connection failed (${response.status}): ${response.statusText}`
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
return { success: true, message: "Linkup connection verified." };
|
|
170
|
+
} catch (error) {
|
|
171
|
+
return {
|
|
172
|
+
success: false,
|
|
173
|
+
message: `Linkup connection failed: ${error instanceof Error ? error.message : String(error)}`
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
async getRateLimitInfo() {
|
|
178
|
+
return {
|
|
179
|
+
remaining: -1,
|
|
180
|
+
limit: 10,
|
|
181
|
+
period: "second"
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
async extract(options) {
|
|
185
|
+
const apiKey = this.getApiKey(options.settings);
|
|
186
|
+
const startTime = Date.now();
|
|
187
|
+
if (!isSafeWebhookUrl(options.url)) {
|
|
188
|
+
return {
|
|
189
|
+
success: false,
|
|
190
|
+
url: options.url,
|
|
191
|
+
error: `URL host is not safe to fetch (SSRF guard blocked: ${options.url})`,
|
|
192
|
+
duration: Date.now() - startTime
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
try {
|
|
196
|
+
const response = await fetch(`${LINKUP_API_BASE}/fetch`, {
|
|
197
|
+
method: "POST",
|
|
198
|
+
headers: {
|
|
199
|
+
Authorization: `Bearer ${apiKey}`,
|
|
200
|
+
"Content-Type": "application/json"
|
|
201
|
+
},
|
|
202
|
+
body: JSON.stringify({
|
|
203
|
+
url: options.url,
|
|
204
|
+
renderJs: true,
|
|
205
|
+
includeRawHtml: false,
|
|
206
|
+
extractImages: false
|
|
207
|
+
})
|
|
208
|
+
});
|
|
209
|
+
if (!response.ok) {
|
|
210
|
+
return {
|
|
211
|
+
success: false,
|
|
212
|
+
url: options.url,
|
|
213
|
+
error: `Linkup fetch failed with status ${response.status}: ${response.statusText}`,
|
|
214
|
+
duration: Date.now() - startTime
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
const data = await response.json();
|
|
218
|
+
if (!data.markdown) {
|
|
219
|
+
return {
|
|
220
|
+
success: false,
|
|
221
|
+
url: options.url,
|
|
222
|
+
error: "No content extracted",
|
|
223
|
+
duration: Date.now() - startTime
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
return {
|
|
227
|
+
success: true,
|
|
228
|
+
url: options.url,
|
|
229
|
+
content: data.markdown,
|
|
230
|
+
markdown: data.markdown,
|
|
231
|
+
duration: Date.now() - startTime,
|
|
232
|
+
wordCount: data.markdown.split(/\s+/).length
|
|
233
|
+
};
|
|
234
|
+
} catch (error) {
|
|
235
|
+
return {
|
|
236
|
+
success: false,
|
|
237
|
+
url: options.url,
|
|
238
|
+
error: error instanceof Error ? error.message : String(error),
|
|
239
|
+
duration: Date.now() - startTime
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
async extractBatch(urls, options) {
|
|
244
|
+
const results = await Promise.all(
|
|
245
|
+
urls.map(
|
|
246
|
+
(url) => this.extract({
|
|
247
|
+
url,
|
|
248
|
+
...options
|
|
249
|
+
})
|
|
250
|
+
)
|
|
251
|
+
);
|
|
252
|
+
return results;
|
|
253
|
+
}
|
|
254
|
+
async canExtract(url) {
|
|
255
|
+
try {
|
|
256
|
+
const parsed = new URL(url);
|
|
257
|
+
return parsed.protocol === "http:" || parsed.protocol === "https:";
|
|
258
|
+
} catch {
|
|
259
|
+
return false;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
getSupportedFormats() {
|
|
263
|
+
return ["text", "markdown"];
|
|
264
|
+
}
|
|
265
|
+
getApiKey(settings) {
|
|
266
|
+
const apiKey = settings?.apiKey;
|
|
267
|
+
if (!apiKey) {
|
|
268
|
+
throw new Error(
|
|
269
|
+
"Linkup API key not configured. Set it in plugin settings or via PLUGIN_LINKUP_API_KEY environment variable."
|
|
270
|
+
);
|
|
271
|
+
}
|
|
272
|
+
return apiKey;
|
|
273
|
+
}
|
|
274
|
+
async onLoad(context) {
|
|
275
|
+
this.context = context;
|
|
276
|
+
context.logger.log("Linkup Plugin loaded");
|
|
277
|
+
}
|
|
278
|
+
async onUnload() {
|
|
279
|
+
this.context = void 0;
|
|
280
|
+
}
|
|
281
|
+
async healthCheck() {
|
|
282
|
+
return {
|
|
283
|
+
status: "healthy",
|
|
284
|
+
message: "Linkup plugin is ready (API key required for operations)",
|
|
285
|
+
checkedAt: Date.now()
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
getManifest() {
|
|
289
|
+
return {
|
|
290
|
+
id: this.id,
|
|
291
|
+
name: this.name,
|
|
292
|
+
version: this.version,
|
|
293
|
+
description: "Search the web and extract content from websites using Linkup",
|
|
294
|
+
category: this.category,
|
|
295
|
+
capabilities: [...this.capabilities],
|
|
296
|
+
author: { name: "Ever Works Team" },
|
|
297
|
+
license: "AGPL-3.0",
|
|
298
|
+
builtIn: true,
|
|
299
|
+
systemPlugin: false,
|
|
300
|
+
autoEnable: false,
|
|
301
|
+
defaultForCapabilities: [],
|
|
302
|
+
homepage: "https://linkup.so",
|
|
303
|
+
icon: {
|
|
304
|
+
type: "url",
|
|
305
|
+
value: "https://framerusercontent.com/images/PuShJA41szIkwbQopIjqoEoOvUc.png"
|
|
306
|
+
},
|
|
307
|
+
readme: [
|
|
308
|
+
"## What does Linkup do?",
|
|
309
|
+
"",
|
|
310
|
+
"Linkup connects AI applications to the internet, providing grounding data to enrich AI output with precision and factuality. It searches the web for relevant content and extracts clean markdown from any URL.",
|
|
311
|
+
"",
|
|
312
|
+
"## Why use it?",
|
|
313
|
+
"",
|
|
314
|
+
"- **High precision search** \u2014 optimized for factual grounding of LLM responses",
|
|
315
|
+
"- **Deep search mode** \u2014 iterative search for comprehensive results when needed",
|
|
316
|
+
"- **Content extraction** \u2014 fetches clean markdown from any webpage via the /fetch endpoint",
|
|
317
|
+
"- **Domain filtering** \u2014 include or exclude specific websites from search results",
|
|
318
|
+
"",
|
|
319
|
+
"## How it works in Ever Works",
|
|
320
|
+
"",
|
|
321
|
+
"During work generation, the search facade uses Linkup to find information about each item, discover relevant source URLs, and extract content from web pages. This powers automatic descriptions, source URL resolution, and content enrichment across the generation pipeline.",
|
|
322
|
+
"",
|
|
323
|
+
"## Getting started",
|
|
324
|
+
"",
|
|
325
|
+
"1. Create an account at [linkup.so](https://linkup.so)",
|
|
326
|
+
"2. Copy your API key from the Linkup dashboard",
|
|
327
|
+
"3. Enter the key in the **API Key** field below",
|
|
328
|
+
"4. Linkup will be available for use during work generation"
|
|
329
|
+
].join("\n")
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
};
|
|
333
|
+
|
|
334
|
+
export { LinkupSearchPlugin, LinkupSearchPlugin as default };
|
package/package.json
CHANGED
|
@@ -1,76 +1,89 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
2
|
+
"name": "@ever-works/linkup-plugin",
|
|
3
|
+
"version": "1.0.2",
|
|
4
|
+
"description": "Linkup Plugin - Web search and content extraction using Linkup API",
|
|
5
|
+
"author": {
|
|
6
|
+
"name": "Ever Co. LTD",
|
|
7
|
+
"email": "ever@ever.co",
|
|
8
|
+
"url": "https://ever.co"
|
|
9
|
+
},
|
|
10
|
+
"license": "AGPL-3.0",
|
|
11
|
+
"private": false,
|
|
12
|
+
"type": "module",
|
|
13
|
+
"main": "./dist/index.cjs",
|
|
14
|
+
"module": "./dist/index.js",
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"import": "./dist/index.js",
|
|
20
|
+
"require": "./dist/index.cjs"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"dist"
|
|
25
|
+
],
|
|
26
|
+
"scripts": {
|
|
27
|
+
"build": "tsc --noEmit && tsup",
|
|
28
|
+
"dev": "tsup --watch",
|
|
29
|
+
"type-check": "tsc --noEmit",
|
|
30
|
+
"clean": "rm -rf dist",
|
|
31
|
+
"test": "vitest run --passWithNoTests",
|
|
32
|
+
"test:watch": "vitest",
|
|
33
|
+
"test:coverage": "vitest run --coverage"
|
|
34
|
+
},
|
|
35
|
+
"peerDependencies": {
|
|
36
|
+
"@ever-works/plugin": "^1.2.4"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@types/node": "^26.6.4",
|
|
40
|
+
"@ever-works/plugin": "^1.2.4",
|
|
41
|
+
"tsup": "^8.4.0",
|
|
42
|
+
"typescript": "^5.7.3",
|
|
43
|
+
"vitest": "^4.1.0"
|
|
44
|
+
},
|
|
45
|
+
"everworks": {
|
|
46
|
+
"plugin": {
|
|
47
|
+
"id": "linkup",
|
|
48
|
+
"name": "Linkup",
|
|
49
|
+
"version": "1.0.0",
|
|
50
|
+
"category": "search",
|
|
51
|
+
"capabilities": [
|
|
52
|
+
"search",
|
|
53
|
+
"content-extractor"
|
|
54
|
+
],
|
|
55
|
+
"description": "Web search and content extraction using Linkup API. Search the web with AI-optimized precision and extract clean content from any URL.",
|
|
56
|
+
"author": {
|
|
57
|
+
"name": "Ever Works Team"
|
|
58
|
+
},
|
|
59
|
+
"license": "AGPL-3.0",
|
|
60
|
+
"autoEnable": false,
|
|
61
|
+
"defaultForCapabilities": [],
|
|
62
|
+
"systemPlugin": false,
|
|
63
|
+
"builtIn": true,
|
|
64
|
+
"envVars": [
|
|
65
|
+
{
|
|
66
|
+
"name": "PLUGIN_LINKUP_API_KEY",
|
|
67
|
+
"required": false,
|
|
68
|
+
"secret": true,
|
|
69
|
+
"description": "Linkup API key (optional - can be set via admin/user settings)"
|
|
70
|
+
}
|
|
71
|
+
],
|
|
72
|
+
"distribution": "registry"
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
"repository": {
|
|
76
|
+
"type": "git",
|
|
77
|
+
"url": "git+https://github.com/ever-works/ever-works.git",
|
|
78
|
+
"directory": "packages/plugins/linkup"
|
|
79
|
+
},
|
|
80
|
+
"homepage": "https://github.com/ever-works/ever-works/tree/main/packages/plugins/linkup#readme",
|
|
81
|
+
"bugs": {
|
|
82
|
+
"url": "https://github.com/ever-works/ever-works/issues"
|
|
83
|
+
},
|
|
84
|
+
"everworksRelease": {
|
|
85
|
+
"contentHash": "sha256:b2ab7ce88a8b94912333b7e47e6c1047d0d83728115384343f1b34948c630f0a",
|
|
86
|
+
"commit": "61b8320b4ad7d30bf5161acf7ee13b250a6172b9",
|
|
87
|
+
"source": "https://github.com/ever-works/ever-works/tree/61b8320b4ad7d30bf5161acf7ee13b250a6172b9/packages/plugins/linkup"
|
|
88
|
+
}
|
|
89
|
+
}
|