@agentbadge/webmcp 0.3.0 → 0.5.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/README.md +13 -0
- package/dist/discovery.d.ts +4 -0
- package/dist/discovery.js +4 -0
- package/dist/index.d.ts +4 -2
- package/dist/index.js +2 -1
- package/dist/registry.d.ts +16 -0
- package/dist/registry.js +77 -0
- package/dist/tools/badge.js +36 -3
- package/dist/tools/browse-tasks.d.ts +2 -0
- package/dist/tools/browse-tasks.js +61 -0
- package/dist/tools/check-address-risk.d.ts +2 -0
- package/dist/tools/check-address-risk.js +68 -0
- package/dist/tools/get-task-status.d.ts +2 -0
- package/dist/tools/get-task-status.js +63 -0
- package/dist/tools/get-task.d.ts +2 -0
- package/dist/tools/get-task.js +63 -0
- package/dist/tools/how-to-register.d.ts +2 -0
- package/dist/tools/how-to-register.js +55 -0
- package/dist/tools/index.d.ts +12 -1
- package/dist/tools/index.js +36 -3
- package/dist/tools/list-services.d.ts +2 -0
- package/dist/tools/list-services.js +78 -0
- package/dist/tools/list-surveys.d.ts +2 -0
- package/dist/tools/list-surveys.js +62 -0
- package/dist/tools/passport-verify.js +47 -3
- package/dist/tools/poll-request.d.ts +2 -0
- package/dist/tools/poll-request.js +104 -0
- package/dist/tools/rules.js +46 -3
- package/dist/tools/scan.js +46 -2
- package/dist/tools/score.js +46 -2
- package/dist/tools/search-agent-qa.d.ts +2 -0
- package/dist/tools/search-agent-qa.js +82 -0
- package/dist/tools/submit-request.d.ts +2 -0
- package/dist/tools/submit-request.js +0 -0
- package/dist/tools/submit-survey.d.ts +2 -0
- package/dist/tools/submit-survey.js +90 -0
- package/dist/tools/verify-verdict.d.ts +2 -0
- package/dist/tools/verify-verdict.js +68 -0
- package/dist/types.d.ts +29 -1
- package/package.json +2 -2
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
export const submitSurveyTool = {
|
|
2
|
+
name: "submit-survey",
|
|
3
|
+
description: "Submit answers to an open agent survey. Anonymous lane: the answer is deduplicated per (survey, fingerprint) — a repeat call returns already_answered, it does not double-count. Honest terminal states: accepted, already_answered (409), survey_closed (410), rate_limited (429). Use list-surveys first to pick a survey_id and read its questions. Verified agents get rating credit; anonymous answers still count.",
|
|
4
|
+
inputSchema: {
|
|
5
|
+
type: "object",
|
|
6
|
+
properties: {
|
|
7
|
+
survey_id: { type: "string", description: "Survey id from list-surveys (sv_…)" },
|
|
8
|
+
answers: { type: "object", description: "Answers object keyed by the survey's question ids — must contain at least one non-empty value" },
|
|
9
|
+
},
|
|
10
|
+
required: ["survey_id", "answers"],
|
|
11
|
+
},
|
|
12
|
+
execute: async (args, opts) => {
|
|
13
|
+
if (!args.survey_id) {
|
|
14
|
+
return { code: "invalid_input", message: "survey_id is required", retryable: false };
|
|
15
|
+
}
|
|
16
|
+
const res = await fetch("/api/surveys/" + encodeURIComponent(String(args.survey_id)) + "/answer?src=webmcp", {
|
|
17
|
+
method: "POST",
|
|
18
|
+
signal: opts.signal,
|
|
19
|
+
headers: {
|
|
20
|
+
"Content-Type": "application/json",
|
|
21
|
+
"X-AgentBadge-Channel": "webmcp",
|
|
22
|
+
},
|
|
23
|
+
body: JSON.stringify({ answers: args.answers ?? {} }),
|
|
24
|
+
});
|
|
25
|
+
const body = await res.json().catch(() => null);
|
|
26
|
+
if (res.ok === false) {
|
|
27
|
+
const upstream = body && typeof body === "object" ? body : {};
|
|
28
|
+
const retryAfter = res.headers?.get?.("retry-after");
|
|
29
|
+
const retryMs = retryAfter != null && !Number.isNaN(Number(retryAfter))
|
|
30
|
+
? Date.now() + Number(retryAfter) * 1000
|
|
31
|
+
: null;
|
|
32
|
+
const envelope = {
|
|
33
|
+
...upstream,
|
|
34
|
+
...(typeof upstream.code === "string" ? { upstream_code: upstream.code } : {}),
|
|
35
|
+
code: "http_" + res.status,
|
|
36
|
+
message: typeof upstream.error === "string" ? upstream.error : res.statusText || "request failed",
|
|
37
|
+
retryable: res.status === 429 || res.status >= 500,
|
|
38
|
+
...(retryAfter != null ? { retry_after: retryAfter } : {}),
|
|
39
|
+
...(retryMs != null ? { retry_at: new Date(retryMs).toISOString() } : {}),
|
|
40
|
+
};
|
|
41
|
+
if (res.status === 429) {
|
|
42
|
+
envelope.next_call = [
|
|
43
|
+
{
|
|
44
|
+
tool: "submit-survey",
|
|
45
|
+
arguments: args,
|
|
46
|
+
reason: "Rate limited — retry the same call after retry_at.",
|
|
47
|
+
},
|
|
48
|
+
];
|
|
49
|
+
}
|
|
50
|
+
else if (res.status === 404) {
|
|
51
|
+
envelope.next_call = [
|
|
52
|
+
{
|
|
53
|
+
tool: "list-surveys",
|
|
54
|
+
reason: "Unknown survey id — list open surveys to get a valid survey_id.",
|
|
55
|
+
},
|
|
56
|
+
];
|
|
57
|
+
}
|
|
58
|
+
return envelope;
|
|
59
|
+
}
|
|
60
|
+
if (body && typeof body === "object" && !Array.isArray(body) && !("next_call" in body)) {
|
|
61
|
+
body.next_call = [
|
|
62
|
+
{
|
|
63
|
+
tool: "submit-request",
|
|
64
|
+
reason: "Have a follow-up question? The ops inbox answers asynchronously.",
|
|
65
|
+
},
|
|
66
|
+
];
|
|
67
|
+
}
|
|
68
|
+
return body;
|
|
69
|
+
},
|
|
70
|
+
annotations: {
|
|
71
|
+
readOnlyHint: false,
|
|
72
|
+
untrustedContentHint: false,
|
|
73
|
+
title: "Submit Survey Answer",
|
|
74
|
+
},
|
|
75
|
+
group: "interaction",
|
|
76
|
+
exposure: "webmcp",
|
|
77
|
+
writeClass: "intake-write",
|
|
78
|
+
riskLevel: "low",
|
|
79
|
+
version: "1.0.0",
|
|
80
|
+
endpoint: { method: "POST", path: "/api/surveys/:id/answer" },
|
|
81
|
+
dataSensitivity: "user-submitted",
|
|
82
|
+
identityRequirement: "fingerprint",
|
|
83
|
+
evidenceSemantics: "anonymous survey answer — (survey,fingerprint) dedupe; verified agents earn rating credit",
|
|
84
|
+
nextCall: [
|
|
85
|
+
{
|
|
86
|
+
tool: "list-surveys",
|
|
87
|
+
reason: "List open surveys to answer another one.",
|
|
88
|
+
},
|
|
89
|
+
],
|
|
90
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
export const verifyVerdictTool = {
|
|
2
|
+
name: "verify-verdict",
|
|
3
|
+
description: "Verify a stored readiness verdict by id. Returns the verdict, reason codes, memo anchor status, and hash-chain status. Anchor or chain status 'pending' means not yet anchored on-chain and is not proof of on-chain validity. Public endpoint, rate-limited per caller.",
|
|
4
|
+
inputSchema: {
|
|
5
|
+
type: "object",
|
|
6
|
+
properties: {
|
|
7
|
+
verdictId: { type: "string", description: "The 0x-prefixed 64-hex verdict id to look up" },
|
|
8
|
+
kind: { type: "string", description: "Optional proof layer to narrow the response: verdict or anchor-head" },
|
|
9
|
+
},
|
|
10
|
+
required: ["verdictId"],
|
|
11
|
+
},
|
|
12
|
+
execute: async (args, opts) => {
|
|
13
|
+
const params = new URLSearchParams({ src: "webmcp" });
|
|
14
|
+
if (args.kind)
|
|
15
|
+
params.set("kind", String(args.kind));
|
|
16
|
+
const res = await fetch("/api/verify/" + encodeURIComponent(String(args.verdictId)) + "?" + params.toString(), {
|
|
17
|
+
signal: opts.signal,
|
|
18
|
+
headers: { "X-AgentBadge-Channel": "webmcp" },
|
|
19
|
+
});
|
|
20
|
+
const body = await res.json().catch(() => null);
|
|
21
|
+
if (res.ok === false) {
|
|
22
|
+
const upstream = body && typeof body === "object" ? body : {};
|
|
23
|
+
const retryAfter = res.headers?.get?.("retry-after");
|
|
24
|
+
const retryMs = retryAfter != null && !Number.isNaN(Number(retryAfter))
|
|
25
|
+
? Date.now() + Number(retryAfter) * 1000
|
|
26
|
+
: null;
|
|
27
|
+
return {
|
|
28
|
+
...upstream,
|
|
29
|
+
...(typeof upstream.code === "string" ? { upstream_code: upstream.code } : {}),
|
|
30
|
+
code: "http_" + res.status,
|
|
31
|
+
message: typeof upstream.error === "string" ? upstream.error : res.statusText || "request failed",
|
|
32
|
+
retryable: res.status === 429 || res.status >= 500,
|
|
33
|
+
...(retryAfter != null ? { retry_after: retryAfter } : {}),
|
|
34
|
+
...(retryMs != null ? { retry_at: new Date(retryMs).toISOString() } : {}),
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
if (body && typeof body === "object" && !Array.isArray(body) && !("next_call" in body)) {
|
|
38
|
+
body.next_call = [
|
|
39
|
+
{
|
|
40
|
+
tool: "check-address-risk",
|
|
41
|
+
reason: "Check the risk verdict for the address behind this verdict.",
|
|
42
|
+
},
|
|
43
|
+
];
|
|
44
|
+
}
|
|
45
|
+
return body;
|
|
46
|
+
},
|
|
47
|
+
annotations: {
|
|
48
|
+
readOnlyHint: true,
|
|
49
|
+
untrustedContentHint: false,
|
|
50
|
+
title: "Verify Verdict",
|
|
51
|
+
},
|
|
52
|
+
group: "trust",
|
|
53
|
+
exposure: "both",
|
|
54
|
+
writeClass: "read",
|
|
55
|
+
riskLevel: "low",
|
|
56
|
+
version: "1.0.0",
|
|
57
|
+
endpoint: { method: "GET", path: "/api/verify/:verdictId" },
|
|
58
|
+
dataSensitivity: "public",
|
|
59
|
+
identityRequirement: "none",
|
|
60
|
+
evidenceSemantics: "server-reported anchor/hash-chain statuses — pending is never presented as on-chain valid",
|
|
61
|
+
provenance: "public verification endpoint",
|
|
62
|
+
nextCall: [
|
|
63
|
+
{
|
|
64
|
+
tool: "check-address-risk",
|
|
65
|
+
reason: "Check the risk verdict for the address behind this verdict.",
|
|
66
|
+
},
|
|
67
|
+
],
|
|
68
|
+
};
|
package/dist/types.d.ts
CHANGED
|
@@ -6,7 +6,35 @@ export interface ToolAnnotations {
|
|
|
6
6
|
export interface ToolExecuteCallbackOptions {
|
|
7
7
|
signal: AbortSignal;
|
|
8
8
|
}
|
|
9
|
-
export
|
|
9
|
+
export type ToolGroup = "readiness" | "trust" | "marketplace" | "interaction" | "onboarding";
|
|
10
|
+
export type ToolExposure = "webmcp" | "public-mcp" | "both";
|
|
11
|
+
export type ToolWriteClass = "read" | "intake-write" | "reputation-write" | "financial";
|
|
12
|
+
export type ToolRiskLevel = "low" | "medium" | "high";
|
|
13
|
+
export type ToolDataSensitivity = "public" | "user-submitted" | "sensitive";
|
|
14
|
+
export type ToolIdentityRequirement = "none" | "fingerprint" | "verified-agent";
|
|
15
|
+
export interface NextCallHint {
|
|
16
|
+
tool: string;
|
|
17
|
+
arguments?: Record<string, unknown>;
|
|
18
|
+
reason: string;
|
|
19
|
+
}
|
|
20
|
+
export interface ToolEndpointRef {
|
|
21
|
+
method: string;
|
|
22
|
+
path: string;
|
|
23
|
+
}
|
|
24
|
+
export interface ToolRegistryMeta {
|
|
25
|
+
group: ToolGroup;
|
|
26
|
+
exposure: ToolExposure;
|
|
27
|
+
writeClass: ToolWriteClass;
|
|
28
|
+
riskLevel: ToolRiskLevel;
|
|
29
|
+
version: string;
|
|
30
|
+
endpoint: ToolEndpointRef;
|
|
31
|
+
dataSensitivity?: ToolDataSensitivity;
|
|
32
|
+
identityRequirement?: ToolIdentityRequirement;
|
|
33
|
+
evidenceSemantics?: string;
|
|
34
|
+
provenance?: string;
|
|
35
|
+
nextCall?: NextCallHint[];
|
|
36
|
+
}
|
|
37
|
+
export interface ToolDefinition extends ToolRegistryMeta {
|
|
10
38
|
name: string;
|
|
11
39
|
description: string;
|
|
12
40
|
inputSchema: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentbadge/webmcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "WebMCP tool injection helpers for AgentBadge",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -34,4 +34,4 @@
|
|
|
34
34
|
"typescript": "^5.9.0",
|
|
35
35
|
"vitest": "^2.0.0"
|
|
36
36
|
}
|
|
37
|
-
}
|
|
37
|
+
}
|