@surfaceapi/ai-sdk 0.1.0 → 0.1.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/README.md +31 -28
- package/index.js +2 -2
- package/package.json +36 -8
package/README.md
CHANGED
|
@@ -1,11 +1,27 @@
|
|
|
1
1
|
# @surfaceapi/ai-sdk
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Surface checks a short link before your agent opens it. The answer is fetch or skip. It never returns the page. A hop or a 1×1 pixel counts the same way, with no install. Free for the first million requests a month. https://nova-otter-delta-cloud.grok.me
|
|
4
4
|
|
|
5
|
-
This package
|
|
5
|
+
This package adds that check to the Vercel AI SDK as one tool: `surface_preflight`.
|
|
6
|
+
|
|
7
|
+
Surface by Canada Site Ops. Ontario, Canada.
|
|
8
|
+
|
|
9
|
+
## Get a free API key in about 10 seconds
|
|
10
|
+
|
|
11
|
+
No email, no card. Then set `SURFACE_KEY` or `SURFACE_API_KEY`, or pass `apiKey`. The tool sends it as `Authorization: Bearer <key>`.
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
curl -s -X POST https://nova-otter-delta-cloud.grok.me/v1/keys
|
|
15
|
+
# returns {"key","created_at","free_monthly":1000000,"usage_url"}
|
|
16
|
+
export SURFACE_KEY=... # or SURFACE_API_KEY; paste the key value
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
A key gets its own million free requests a month. Anonymous calls still work on a shared demo limit.
|
|
20
|
+
|
|
21
|
+
## Install
|
|
6
22
|
|
|
7
23
|
```bash
|
|
8
|
-
npm
|
|
24
|
+
npm i @surfaceapi/ai-sdk ai zod
|
|
9
25
|
```
|
|
10
26
|
|
|
11
27
|
```js
|
|
@@ -15,36 +31,23 @@ import { surface_preflight } from "@surfaceapi/ai-sdk";
|
|
|
15
31
|
const { text } = await generateText({
|
|
16
32
|
model,
|
|
17
33
|
tools: { surface_preflight },
|
|
18
|
-
prompt: "Summarize https://bit.ly/... if it
|
|
34
|
+
prompt: "Summarize https://bit.ly/... if it is safe to open",
|
|
19
35
|
});
|
|
20
36
|
```
|
|
21
37
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
```json
|
|
25
|
-
{"next": "fetch", "fetch": true, "url": "https://youtu.be/jNQXAC9IVRw",
|
|
26
|
-
"final_url": "https://www.youtube.com/watch?v=jNQXAC9IVRw&feature=youtu.be",
|
|
27
|
-
"final_host": "youtube.com", "status": 200, "redirects": 1, "shortener": true,
|
|
28
|
-
"reason": "unwrapped youtu.be → youtube.com · alive, worth a fetch"}
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
## Free to start
|
|
32
|
-
|
|
33
|
-
The first 1M requests a month are free. It works with no key at all (shared demo limit), or grab your own free key in one call, with no email and no card:
|
|
34
|
-
|
|
35
|
-
```bash
|
|
36
|
-
curl -s -X POST https://nova-otter-delta-cloud.grok.me/v1/keys
|
|
37
|
-
export SURFACE_API_KEY=...
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
After the free tier: $0.25 USD per 1,000 preflights.
|
|
38
|
+
On any error the tool answers `skip`. You can also call `preflight(url, { apiKey })` directly.
|
|
41
39
|
|
|
42
40
|
## Prefer MCP?
|
|
43
41
|
|
|
44
|
-
Point any MCP client at `https://nova-otter-delta-cloud.grok.me/mcp` (tool `preflight_url`)
|
|
42
|
+
Point any MCP client at `https://nova-otter-delta-cloud.grok.me/mcp` (tool `preflight_url`), with the same key in `Authorization: Bearer <key>`.
|
|
43
|
+
|
|
44
|
+
## Also listed
|
|
45
45
|
|
|
46
|
-
-
|
|
47
|
-
-
|
|
48
|
-
-
|
|
46
|
+
- Official MCP Registry: `me.grok.nova-otter-delta-cloud/surface`
|
|
47
|
+
- https://www.curatedmcp.com/marketplace/surface
|
|
48
|
+
- https://www.npmjs.com/package/@surfaceapi/ai-sdk
|
|
49
|
+
- https://www.npmjs.com/package/@surfaceapi/surface
|
|
50
|
+
- https://pypi.org/project/surfaceapi/
|
|
51
|
+
- https://huggingface.co/spaces/surfaceapi/surface-preflight
|
|
49
52
|
|
|
50
|
-
|
|
53
|
+
CLI and GitHub Action are coming soon.
|
package/index.js
CHANGED
|
@@ -12,13 +12,13 @@ const env = (k) => (typeof process !== "undefined" && process.env ? process.env[
|
|
|
12
12
|
|
|
13
13
|
export async function preflight(url, { apiKey, baseUrl, headers, timeoutMs = 15000 } = {}) {
|
|
14
14
|
const base = (baseUrl || env("SURFACE_BASE_URL") || DEFAULT_BASE_URL).replace(/\/$/, "");
|
|
15
|
-
const key = apiKey || env("SURFACE_API_KEY");
|
|
15
|
+
const key = apiKey || env("SURFACE_KEY") || env("SURFACE_API_KEY");
|
|
16
16
|
const res = await fetch(base + "/v1/preflight", {
|
|
17
17
|
method: "POST",
|
|
18
18
|
headers: {
|
|
19
19
|
"content-type": "application/json",
|
|
20
20
|
accept: "application/json",
|
|
21
|
-
"user-agent": "@surfaceapi/ai-sdk/0.1.
|
|
21
|
+
"user-agent": "@surfaceapi/ai-sdk/0.1.2",
|
|
22
22
|
...(key ? { authorization: "Bearer " + key } : {}),
|
|
23
23
|
...(headers || {}),
|
|
24
24
|
},
|
package/package.json
CHANGED
|
@@ -1,17 +1,45 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@surfaceapi/ai-sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Surface for the Vercel AI SDK: the link-safety layer between an AI agent and the open web. One tool, surfacePreflight, that tells your agent whether a link is worth fetching.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./index.js",
|
|
7
7
|
"types": "./index.d.ts",
|
|
8
|
-
"exports": {
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./index.d.ts",
|
|
11
|
+
"import": "./index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"index.js",
|
|
16
|
+
"index.d.ts",
|
|
17
|
+
"README.md",
|
|
18
|
+
"LICENSE"
|
|
19
|
+
],
|
|
20
|
+
"keywords": [
|
|
21
|
+
"ai",
|
|
22
|
+
"ai-sdk",
|
|
23
|
+
"vercel",
|
|
24
|
+
"ai-agents",
|
|
25
|
+
"tools",
|
|
26
|
+
"link-safety",
|
|
27
|
+
"url",
|
|
28
|
+
"preflight",
|
|
29
|
+
"mcp",
|
|
30
|
+
"surface"
|
|
31
|
+
],
|
|
11
32
|
"author": "Canada Site Ops <canada.site.ops@gmail.com>",
|
|
12
33
|
"license": "MIT",
|
|
13
|
-
"homepage": "https://otter-
|
|
14
|
-
"peerDependencies": {
|
|
15
|
-
|
|
16
|
-
|
|
34
|
+
"homepage": "https://nova-otter-delta-cloud.grok.me",
|
|
35
|
+
"peerDependencies": {
|
|
36
|
+
"ai": ">=4.0.0",
|
|
37
|
+
"zod": ">=3.22.0"
|
|
38
|
+
},
|
|
39
|
+
"engines": {
|
|
40
|
+
"node": ">=18"
|
|
41
|
+
},
|
|
42
|
+
"publishConfig": {
|
|
43
|
+
"access": "public"
|
|
44
|
+
}
|
|
17
45
|
}
|