smolagents-surface 0.1.0__py3-none-any.whl

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.
@@ -0,0 +1,15 @@
1
+ """Surface for smolagents: the link-safety layer between an AI agent and the open web."""
2
+ from smolagents import Tool
3
+ from ._core import preflight, preflight_text, TOOL_DESCRIPTION
4
+
5
+ class SurfacePreflightTool(Tool):
6
+ name = "surface_preflight"
7
+ description = TOOL_DESCRIPTION
8
+ inputs = {"url": {"type": "string", "description": "The link to check"}}
9
+ output_type = "string"
10
+ def forward(self, url: str) -> str:
11
+ return preflight_text(url, ua="smolagents-surface/0.1.0")
12
+
13
+ surface_preflight = SurfacePreflightTool()
14
+
15
+ __all__ = [n for n in dir() if not n.startswith("__")]
@@ -0,0 +1,48 @@
1
+ """Surface Preflight client: the link-safety layer between an AI agent and the open web."""
2
+ from __future__ import annotations
3
+ import json, os, urllib.parse, urllib.request
4
+ from typing import Any, Dict, Optional
5
+
6
+ DEFAULT_BASE_URL = "https://nova-otter-delta-cloud.grok.me"
7
+ TOOL_NAME = "surface_preflight"
8
+ TOOL_DESCRIPTION = (
9
+ "Check a link before you open it. Surface unwraps short links (t.co, bit.ly, "
10
+ "lnkd.in, youtu.be), follows redirects, and tells you whether the destination "
11
+ "is worth fetching ('fetch') or should be skipped ('skip'), plus where the "
12
+ "link really goes. It never returns the page itself."
13
+ )
14
+
15
+ def preflight(url: str, api_key: Optional[str] = None, base_url: Optional[str] = None,
16
+ timeout: float = 15.0, headers: Optional[Dict[str, str]] = None, ua: str = "surface-python/0.1.0") -> Dict[str, Any]:
17
+ """Call Surface Preflight and return a compact verdict dict."""
18
+ base = (base_url or os.environ.get("SURFACE_BASE_URL") or DEFAULT_BASE_URL).rstrip("/")
19
+ key = api_key or os.environ.get("SURFACE_API_KEY")
20
+ h = {"Content-Type": "application/json", "Accept": "application/json",
21
+ "User-Agent": ua}
22
+ if key:
23
+ h["Authorization"] = "Bearer " + key
24
+ if headers:
25
+ h.update(headers)
26
+ req = urllib.request.Request(base + "/v1/preflight", data=json.dumps({"url": url}).encode(),
27
+ headers=h, method="POST")
28
+ with urllib.request.urlopen(req, timeout=timeout) as r:
29
+ data = json.loads(r.read().decode())
30
+ nxt = data.get("next") or data.get("verdict")
31
+ return {
32
+ "next": nxt,
33
+ "fetch": nxt == "fetch",
34
+ "url": data.get("url", url),
35
+ "final_url": data.get("final_url"),
36
+ "final_host": data.get("final_host"),
37
+ "status": data.get("status"),
38
+ "redirects": data.get("redirects"),
39
+ "shortener": data.get("shortener"),
40
+ "reason": data.get("reason"),
41
+ }
42
+
43
+ def preflight_text(url: str, **kw: Any) -> str:
44
+ """Same as preflight() but returns a JSON string, handy for LLM tool output."""
45
+ try:
46
+ return json.dumps(preflight(url, **kw))
47
+ except Exception as e: # tool output should never crash the agent loop
48
+ return json.dumps({"next": "skip", "fetch": False, "url": url, "error": str(e)})
@@ -0,0 +1,57 @@
1
+ Metadata-Version: 2.5
2
+ Name: smolagents-surface
3
+ Version: 0.1.0
4
+ Summary: Surface for smolagents: the link-safety layer between an AI agent and the open web. One tool, surface_preflight, that tells your agent whether a link is worth fetching.
5
+ Project-URL: Homepage, https://otter-sand-wolf-spring.grok.me
6
+ Project-URL: Documentation, https://nova-otter-delta-cloud.grok.me/docs
7
+ Project-URL: API reference, https://nova-otter-delta-cloud.grok.me/llms.txt
8
+ Project-URL: MCP server, https://nova-otter-delta-cloud.grok.me/mcp
9
+ Author-email: Canada Site Ops <canada.site.ops@gmail.com>
10
+ Maintainer-email: Canada Site Ops <canada.site.ops@gmail.com>
11
+ License: MIT
12
+ License-File: LICENSE
13
+ Keywords: ai-agents,hf-tool,huggingface,link-safety,mcp,preflight,smolagents,surface,tools,url
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Topic :: Internet :: WWW/HTTP
17
+ Requires-Python: >=3.10
18
+ Requires-Dist: smolagents>=1.0
19
+ Description-Content-Type: text/markdown
20
+
21
+ # smolagents-surface
22
+
23
+ **Surface is the link-safety layer between an AI agent and the open web.** Before your agent opens a link someone pasted, Surface checks it: it unwraps short links (t.co, bit.ly, lnkd.in, youtu.be), follows the redirects, and answers **fetch** or **skip**, along with where the link really goes. It never downloads the page for you, so it's fast and cheap. If Surface can't be reached, the tool answers skip, so your agent stays safe.
24
+
25
+ This package gives smolagents agents that check as one ready-made tool: `surface_preflight`.
26
+
27
+ ```bash
28
+ pip install smolagents-surface
29
+ ```
30
+
31
+ ```python
32
+ from smolagents import CodeAgent
33
+ from smolagents_surface import surface_preflight
34
+
35
+ agent = CodeAgent(tools=[surface_preflight], model=model)
36
+ ```
37
+
38
+ ## Free to start
39
+
40
+ 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:
41
+
42
+ ```bash
43
+ curl -s -X POST https://nova-otter-delta-cloud.grok.me/v1/keys
44
+ export SURFACE_API_KEY=...
45
+ ```
46
+
47
+ After the free tier: $0.25 USD per 1,000 preflights.
48
+
49
+ ## Prefer MCP?
50
+
51
+ Point any MCP client at `https://nova-otter-delta-cloud.grok.me/mcp` (tool `preflight_url`).
52
+
53
+ - Website: https://otter-sand-wolf-spring.grok.me
54
+ - Docs: https://nova-otter-delta-cloud.grok.me/docs
55
+ - LLM reference: https://nova-otter-delta-cloud.grok.me/llms.txt
56
+
57
+ Made by Canada Site Ops. MIT licensed.
@@ -0,0 +1,6 @@
1
+ smolagents_surface/__init__.py,sha256=9jfrhCXcnInruwh8re3Gueq2W81jNG0wiQhC-cyZjCc,592
2
+ smolagents_surface/_core.py,sha256=qatbSQobIepBZit1YIbTIgb01gXRe-STlwVWohtjJ3Q,2300
3
+ smolagents_surface-0.1.0.dist-info/METADATA,sha256=zHzUFkNKq4gLBQDpPn6PWb-A6LDkSiseCozb-BGAz6w,2405
4
+ smolagents_surface-0.1.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
5
+ smolagents_surface-0.1.0.dist-info/licenses/LICENSE,sha256=fNLwqKpxzMvMZQTP1NQeJcBxAGsliU7T10uGRDcQeNo,675
6
+ smolagents_surface-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.33.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -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.