@forgeintel/sdk 0.5.0-beta.0 → 0.5.0-beta.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/dist/context.d.ts +3 -3
- package/dist/context.js +14 -6
- package/package.json +1 -1
package/dist/context.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** Suggested agent names; anything else is kept as given. */
|
|
2
|
-
export declare const AGENT_TYPES: readonly ["Claude Code", "Codex", "Cursor", "Grok", "
|
|
2
|
+
export declare const AGENT_TYPES: readonly ["Claude Code", "Codex", "Cursor", "Grok Bot", "Muse", "Hermes", "Instinct", "OpenClaw", "Others"];
|
|
3
3
|
/** Suggested x402 clients; anything else is kept as given. */
|
|
4
4
|
export declare const CLIENTS: readonly ["agentcash", "awal", "pay.sh", "other", "unknown"];
|
|
5
5
|
/** JSON body field (POST, PUT, …). */
|
|
@@ -45,7 +45,7 @@ export declare function agentContextSchema({ searchQuery }?: {
|
|
|
45
45
|
} | undefined;
|
|
46
46
|
agent_type: {
|
|
47
47
|
type: string;
|
|
48
|
-
enum: ("Claude Code" | "Codex" | "Cursor" | "Grok" | "
|
|
48
|
+
enum: ("Claude Code" | "Codex" | "Cursor" | "Grok Bot" | "Muse" | "Hermes" | "Instinct" | "OpenClaw" | "Others")[];
|
|
49
49
|
description: string;
|
|
50
50
|
};
|
|
51
51
|
agent_type_other: {
|
|
@@ -66,4 +66,4 @@ export declare function agentContextParameters({ searchQuery }?: {
|
|
|
66
66
|
/** One line for the forge-feedback extension, so clients that only inspect the 402 learn about it too. */
|
|
67
67
|
export declare function agentContextAsk({ searchQuery }?: {
|
|
68
68
|
searchQuery?: boolean;
|
|
69
|
-
}): "Please add agent_context {agent_type, search_query} to your paid request's JSON body (without a body: agent_type, agent_search_query query parameters).
|
|
69
|
+
}): "Please add agent_context {agent_type, search_query} to your paid request's JSON body (without a body: agent_type, agent_search_query query parameters). search_query: share the query you used to find this service, or \"direct\" if you did not search." | "Please add agent_context {agent_type} to your paid request's JSON body (without a body: agent_type query parameter). Self-reported; omit what you don't know.";
|
package/dist/context.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// API contract never changes. Never required: a required field breaks strict validators and makes
|
|
4
4
|
// agents invent answers.
|
|
5
5
|
/** Suggested agent names; anything else is kept as given. */
|
|
6
|
-
export const AGENT_TYPES = ["Claude Code", "Codex", "Cursor", "Grok", "
|
|
6
|
+
export const AGENT_TYPES = ["Claude Code", "Codex", "Cursor", "Grok Bot", "Muse", "Hermes", "Instinct", "OpenClaw", "Others"];
|
|
7
7
|
/** Suggested x402 clients; anything else is kept as given. */
|
|
8
8
|
export const CLIENTS = ["agentcash", "awal", "pay.sh", "other", "unknown"];
|
|
9
9
|
/** JSON body field (POST, PUT, …). */
|
|
@@ -28,9 +28,17 @@ export function parseAgentContext(input, { searchQuery = true } = {}) {
|
|
|
28
28
|
const raw = Array.isArray(input[key]) ? input[key][0] : input[key];
|
|
29
29
|
if (typeof raw !== "string")
|
|
30
30
|
continue;
|
|
31
|
-
|
|
31
|
+
let text = raw.replace(/[\u0000-\u001f\u007f]+/g, " ").trim().slice(0, LIMITS[key]);
|
|
32
32
|
if (!text)
|
|
33
33
|
continue;
|
|
34
|
+
if (key === "agent_type") {
|
|
35
|
+
if (/^grok(?: bot)?$/i.test(text))
|
|
36
|
+
text = "Grok Bot";
|
|
37
|
+
if (/^(?:others?(?: \(specify\))?|unknown)$/i.test(text))
|
|
38
|
+
text = "Others";
|
|
39
|
+
}
|
|
40
|
+
if (key === "search_query" && /^direct$/i.test(text))
|
|
41
|
+
text = "direct";
|
|
34
42
|
const known = key === "agent_type" ? AGENT_TYPES : key === "client" ? CLIENTS : null;
|
|
35
43
|
context[key] = known?.find((v) => v.toLowerCase() === text.toLowerCase()) ?? text;
|
|
36
44
|
}
|
|
@@ -80,9 +88,9 @@ export function takeFromUrl(url) {
|
|
|
80
88
|
}
|
|
81
89
|
const DESCRIPTIONS = {
|
|
82
90
|
object: "Self-reported context about the calling agent, so the merchant can see which agents use this service. Not needed for the result; omit anything you don't know.",
|
|
83
|
-
agent_type: "Which agent are you?
|
|
84
|
-
agent_type_other: "Your agent's name, when agent_type is
|
|
85
|
-
search_query: "The search
|
|
91
|
+
agent_type: "Which agent are you? Choose Others if yours is not listed and share its name in agent_type_other.",
|
|
92
|
+
agent_type_other: "Your agent's name, when agent_type is Others.",
|
|
93
|
+
search_query: "The search query you used to find this service, or \"direct\" if you did not search.",
|
|
86
94
|
};
|
|
87
95
|
/** JSON Schema for the optional `agent_context` body property. */
|
|
88
96
|
export function agentContextSchema({ searchQuery = true } = {}) {
|
|
@@ -109,6 +117,6 @@ export function agentContextParameters({ searchQuery = true } = {}) {
|
|
|
109
117
|
/** One line for the forge-feedback extension, so clients that only inspect the 402 learn about it too. */
|
|
110
118
|
export function agentContextAsk({ searchQuery = true } = {}) {
|
|
111
119
|
return searchQuery
|
|
112
|
-
? "Please add agent_context {agent_type, search_query} to your paid request's JSON body (without a body: agent_type, agent_search_query query parameters).
|
|
120
|
+
? "Please add agent_context {agent_type, search_query} to your paid request's JSON body (without a body: agent_type, agent_search_query query parameters). search_query: share the query you used to find this service, or \"direct\" if you did not search."
|
|
113
121
|
: "Please add agent_context {agent_type} to your paid request's JSON body (without a body: agent_type query parameter). Self-reported; omit what you don't know.";
|
|
114
122
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forgeintel/sdk",
|
|
3
|
-
"version": "0.5.0-beta.
|
|
3
|
+
"version": "0.5.0-beta.1",
|
|
4
4
|
"description": "The Forge SDK for x402 paid APIs: agent feedback (feedback IDs, one-request GET ratings), agent context, OpenAPI and challenge enrichment, and passive call signals. Express, Hono, Next.js and any fetch handler. Never on your critical path.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|