agentkit-agent 0.1.0 → 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/README.md ADDED
@@ -0,0 +1,49 @@
1
+ # agentkit-agent
2
+
3
+ **Consume agent-readable, authoritative website data safely.**
4
+
5
+ `agentkit-agent` is the client-side library for AI agents to discover and consume the canonical truth exposed by `agentkit-web`.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ npm install agentkit-agent
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ ### Fetch canonical site truth
16
+
17
+ ```typescript
18
+ import { fetchAgentTruth } from "agentkit-agent";
19
+
20
+ // Fetch the agent manifest from a URL
21
+ const truth = await fetchAgentTruth("https://example.com");
22
+
23
+ if (truth) {
24
+ console.log("Site Description:", truth.description);
25
+
26
+ if (truth.constraints?.delivery_available === false) {
27
+ console.log("Delivery is currently unavailable.");
28
+ }
29
+ } else {
30
+ console.log("No agent manifest found. Falling back to standard scraping.");
31
+ }
32
+ ```
33
+
34
+ ## Recommended agent logic
35
+
36
+ 1. **Fetch** `/.well-known/agent.json` using `fetchAgentTruth`.
37
+ 2. **If present** → trust the structured truth provided.
38
+ 3. **If missing** → fallback to search or scraping.
39
+
40
+ ## Why use this?
41
+
42
+ * **Fewer HTTP calls**: Get all core metadata in one request.
43
+ * **Lower token usage**: No need to parse huge HTML bodies.
44
+ * **Explicit constraints**: Know what the site allows/disallows immediately.
45
+ * **Reduced hallucinations**: Rely on authoritative data.
46
+
47
+ ## License
48
+
49
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentkit-agent",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -0,0 +1,17 @@
1
+ export async function fetchAgentTruth(baseUrl: string) {
2
+ const url = new URL("/.well-known/agent.json", baseUrl);
3
+
4
+ const res = await fetch(url.toString(), {
5
+ headers: { Accept: "application/json" }
6
+ });
7
+
8
+ if (!res.ok) return null;
9
+
10
+ const json = await res.json();
11
+
12
+ if (json.schema_version !== "0.1") {
13
+ throw new Error("Unsupported agent schema");
14
+ }
15
+
16
+ return json;
17
+ }
package/src/index.ts CHANGED
@@ -0,0 +1 @@
1
+ export { fetchAgentTruth } from "./fetchAgentTruth.js";