@surfaceapi/mastra 0.0.0-stage → 0.1.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.
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,19 @@
1
- # Temporary Holding Version
1
+ # @surfaceapi/mastra
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 for Mastra: **the link-safety layer between an AI agent and the open web.**
4
+
5
+ `surface_preflight` unwraps short links (t.co, bit.ly, lnkd.in, youtu.be), follows redirects and answers `fetch` or `skip`, without returning the page. On any error it answers `skip`.
6
+
7
+ ```bash
8
+ npm i @surfaceapi/mastra @mastra/core zod
9
+ ```
10
+
11
+ ```js
12
+ import { Agent } from "@mastra/core/agent";
13
+ import { surface_preflight } from "@surfaceapi/mastra";
14
+ const agent = new Agent({ name: "reader", instructions: "Preflight every link before fetching it.", model, tools: { surface_preflight } });
15
+ ```
16
+
17
+ Free up to 1M requests/month; optional `SURFACE_API_KEY`. Remote MCP: `https://nova-otter-delta-cloud.grok.me/mcp` (tool `preflight_url`).
18
+
19
+ Homepage: https://otter-sand-wolf-spring.grok.me · MIT · Canada Site Ops
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,52 @@
1
+ // Surface for the Mastra: the link-safety layer between an AI agent and the open web.
2
+ import { createTool } from "@mastra/core/tools";
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/mastra/0.1.0",
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 createTool({
39
+ id: "surface_preflight",
40
+ description: TOOL_DESCRIPTION,
41
+ inputSchema: z.object({ url: z.string().describe("The link to check before fetching it") }),
42
+ execute: async (arg) => {
43
+ const url = (arg && arg.context && arg.context.url) || (arg && arg.url);
44
+ try { return await preflight(url, opts); }
45
+ catch (e) { return { next: "skip", fetch: false, url, error: String(e && e.message || e) }; }
46
+ },
47
+ });
48
+ }
49
+
50
+ /** Ready-made tool. Use as: tools: { surface_preflight } */
51
+ export const surface_preflight = surfacePreflightTool();
52
+ export default surface_preflight;
package/package.json CHANGED
@@ -1,6 +1,17 @@
1
1
  {
2
2
  "name": "@surfaceapi/mastra",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "Surface for Mastra: the link-safety layer between an AI agent and the open web. One tool, surface_preflight, that answers fetch or skip without returning the page.",
5
+ "type": "module",
6
+ "main": "./index.js",
7
+ "types": "./index.d.ts",
8
+ "exports": { ".": { "types": "./index.d.ts", "import": "./index.js" } },
9
+ "files": ["index.js", "index.d.ts", "README.md", "LICENSE"],
10
+ "keywords": ["mastra", "ai-agents", "tools", "link-safety", "url", "preflight", "mcp", "surface"],
11
+ "author": "Canada Site Ops <canada.site.ops@gmail.com>",
12
+ "license": "MIT",
13
+ "homepage": "https://otter-sand-wolf-spring.grok.me",
14
+ "peerDependencies": { "@mastra/core": ">=0.10.0", "zod": ">=3.22.0" },
15
+ "engines": { "node": ">=18" },
16
+ "publishConfig": { "access": "public" }
17
+ }