@agentbadge/webmcp 0.4.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/dist/registry.js
CHANGED
|
@@ -14,6 +14,7 @@ import { submitRequestTool } from "./tools/submit-request";
|
|
|
14
14
|
import { pollRequestTool } from "./tools/poll-request";
|
|
15
15
|
import { searchAgentQaTool } from "./tools/search-agent-qa";
|
|
16
16
|
import { listSurveysTool } from "./tools/list-surveys";
|
|
17
|
+
import { submitSurveyTool } from "./tools/submit-survey";
|
|
17
18
|
export const registry = [
|
|
18
19
|
scanTool,
|
|
19
20
|
scoreTool,
|
|
@@ -29,6 +30,7 @@ export const registry = [
|
|
|
29
30
|
pollRequestTool,
|
|
30
31
|
searchAgentQaTool,
|
|
31
32
|
listSurveysTool,
|
|
33
|
+
submitSurveyTool,
|
|
32
34
|
howToRegisterTool,
|
|
33
35
|
passportVerifyTool,
|
|
34
36
|
];
|
|
@@ -49,7 +51,7 @@ export const PAGE_TOOLSETS = {
|
|
|
49
51
|
tools: ["submit-request", "poll-request"],
|
|
50
52
|
},
|
|
51
53
|
docs: {
|
|
52
|
-
tools: ["search-agent-qa", "list-surveys", "how-to-register"],
|
|
54
|
+
tools: ["search-agent-qa", "list-surveys", "submit-survey", "how-to-register"],
|
|
53
55
|
},
|
|
54
56
|
};
|
|
55
57
|
const isImplemented = (entry) => typeof entry.execute === "function";
|
package/dist/tools/index.d.ts
CHANGED
|
@@ -15,4 +15,5 @@ export { submitRequestTool } from "./submit-request";
|
|
|
15
15
|
export { pollRequestTool } from "./poll-request";
|
|
16
16
|
export { searchAgentQaTool } from "./search-agent-qa";
|
|
17
17
|
export { listSurveysTool } from "./list-surveys";
|
|
18
|
+
export { submitSurveyTool } from "./submit-survey";
|
|
18
19
|
export declare const allTools: ToolDefinition[];
|
package/dist/tools/index.js
CHANGED
|
@@ -14,6 +14,7 @@ import { submitRequestTool } from "./submit-request";
|
|
|
14
14
|
import { pollRequestTool } from "./poll-request";
|
|
15
15
|
import { searchAgentQaTool } from "./search-agent-qa";
|
|
16
16
|
import { listSurveysTool } from "./list-surveys";
|
|
17
|
+
import { submitSurveyTool } from "./submit-survey";
|
|
17
18
|
export { scanTool } from "./scan";
|
|
18
19
|
export { badgeTool } from "./badge";
|
|
19
20
|
export { passportVerifyTool } from "./passport-verify";
|
|
@@ -30,6 +31,7 @@ export { submitRequestTool } from "./submit-request";
|
|
|
30
31
|
export { pollRequestTool } from "./poll-request";
|
|
31
32
|
export { searchAgentQaTool } from "./search-agent-qa";
|
|
32
33
|
export { listSurveysTool } from "./list-surveys";
|
|
34
|
+
export { submitSurveyTool } from "./submit-survey";
|
|
33
35
|
export const allTools = [
|
|
34
36
|
scanTool,
|
|
35
37
|
badgeTool,
|
|
@@ -47,4 +49,5 @@ export const allTools = [
|
|
|
47
49
|
pollRequestTool,
|
|
48
50
|
searchAgentQaTool,
|
|
49
51
|
listSurveysTool,
|
|
52
|
+
submitSurveyTool,
|
|
50
53
|
];
|
|
@@ -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
|
+
};
|