@surfaceapi/ai-sdk 0.0.0-stage → 0.1.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.
package/LICENSE ADDED
@@ -0,0 +1,9 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Canada Site Ops
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND.
package/README.md CHANGED
@@ -1,3 +1,53 @@
1
- # Temporary Holding Version
1
+ # @surfaceapi/ai-sdk
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
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
+
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_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_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
22
+
23
+ ```bash
24
+ npm i @surfaceapi/ai-sdk ai zod
25
+ ```
26
+
27
+ ```js
28
+ import { generateText } from "ai";
29
+ import { surface_preflight } from "@surfaceapi/ai-sdk";
30
+
31
+ const { text } = await generateText({
32
+ model,
33
+ tools: { surface_preflight },
34
+ prompt: "Summarize https://bit.ly/... if it is safe to open",
35
+ });
36
+ ```
37
+
38
+ On any error the tool answers `skip`. You can also call `preflight(url, { apiKey })` directly.
39
+
40
+ ## Prefer MCP?
41
+
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
+
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
52
+
53
+ CLI and GitHub Action are coming soon.
package/index.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ export interface PreflightOptions { apiKey?: string; baseUrl?: string; headers?: Record<string, string>; timeoutMs?: number; }
2
+ export interface PreflightResult { next: "fetch" | "skip"; fetch: boolean; url: string; final_url?: string; final_host?: string; status?: number; redirects?: number; shortener?: boolean; reason?: string; error?: string; }
3
+ export declare const DEFAULT_BASE_URL: string;
4
+ export declare const TOOL_DESCRIPTION: string;
5
+ export declare function preflight(url: string, opts?: PreflightOptions): Promise<PreflightResult>;
6
+ export declare function surfacePreflightTool(opts?: PreflightOptions): any;
7
+ export declare const surface_preflight: any;
8
+ export default surface_preflight;
package/index.js ADDED
@@ -0,0 +1,51 @@
1
+ // Surface for the Vercel AI SDK: the link-safety layer between an AI agent and the open web.
2
+ import { tool } from "ai";
3
+ import { z } from "zod";
4
+
5
+ export const DEFAULT_BASE_URL = "https://nova-otter-delta-cloud.grok.me";
6
+ export const TOOL_DESCRIPTION =
7
+ "Check a link before you open it. Surface unwraps short links (t.co, bit.ly, lnkd.in, youtu.be), " +
8
+ "follows redirects, and tells you whether the destination is worth fetching ('fetch') or should be " +
9
+ "skipped ('skip'), plus where the link really goes. It never returns the page itself.";
10
+
11
+ const env = (k) => (typeof process !== "undefined" && process.env ? process.env[k] : undefined);
12
+
13
+ export async function preflight(url, { apiKey, baseUrl, headers, timeoutMs = 15000 } = {}) {
14
+ const base = (baseUrl || env("SURFACE_BASE_URL") || DEFAULT_BASE_URL).replace(/\/$/, "");
15
+ const key = apiKey || env("SURFACE_API_KEY");
16
+ const res = await fetch(base + "/v1/preflight", {
17
+ method: "POST",
18
+ headers: {
19
+ "content-type": "application/json",
20
+ accept: "application/json",
21
+ "user-agent": "@surfaceapi/ai-sdk/0.1.1",
22
+ ...(key ? { authorization: "Bearer " + key } : {}),
23
+ ...(headers || {}),
24
+ },
25
+ body: JSON.stringify({ url }),
26
+ signal: AbortSignal.timeout(timeoutMs),
27
+ });
28
+ if (!res.ok) throw new Error("Surface preflight HTTP " + res.status);
29
+ const d = await res.json();
30
+ const next = d.next || d.verdict;
31
+ return {
32
+ next, fetch: next === "fetch", url: d.url || url, final_url: d.final_url, final_host: d.final_host,
33
+ status: d.status, redirects: d.redirects, shortener: d.shortener, reason: d.reason,
34
+ };
35
+ }
36
+
37
+ export function surfacePreflightTool(opts = {}) {
38
+ return tool({
39
+ description: TOOL_DESCRIPTION,
40
+ parameters: z.object({ url: z.string().describe("The link to check before fetching it") }),
41
+ inputSchema: z.object({ url: z.string().describe("The link to check before fetching it") }),
42
+ execute: async ({ url }) => {
43
+ try { return await preflight(url, opts); }
44
+ catch (e) { return { next: "skip", fetch: false, url, error: String(e && e.message || e) }; }
45
+ },
46
+ });
47
+ }
48
+
49
+ /** Ready-made tool. Use as: tools: { surface_preflight } */
50
+ export const surface_preflight = surfacePreflightTool();
51
+ export default surface_preflight;
package/package.json CHANGED
@@ -1,6 +1,45 @@
1
1
  {
2
2
  "name": "@surfaceapi/ai-sdk",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.1",
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
+ "type": "module",
6
+ "main": "./index.js",
7
+ "types": "./index.d.ts",
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
+ ],
32
+ "author": "Canada Site Ops <canada.site.ops@gmail.com>",
33
+ "license": "MIT",
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
+ }
45
+ }