agentcash 0.12.0 → 0.13.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/cjs/run-server.cjs +140 -10
- package/dist/esm/{add-skill-4UF4QK5J.js → add-skill-3SHARVQA.js} +5 -5
- package/dist/esm/{bridge-TRYZXGYM.js → bridge-55J4MKZR.js} +7 -7
- package/dist/esm/{check-MSPK44AN.js → check-V262JV5M.js} +11 -10
- package/dist/esm/{check-MSPK44AN.js.map → check-V262JV5M.js.map} +1 -1
- package/dist/esm/{chunk-5ABKHXAY.js → chunk-3UDQHC6S.js} +2 -2
- package/dist/esm/{chunk-DYEEHIRQ.js → chunk-6L7ONOXE.js} +2 -2
- package/dist/esm/{chunk-JWOPPEMV.js → chunk-BQRFNAMV.js} +5 -13
- package/dist/esm/chunk-BQRFNAMV.js.map +1 -0
- package/dist/esm/{chunk-PH5ZST4Z.js → chunk-BYLBPP4V.js} +5 -5
- package/dist/esm/{chunk-KGGPN7W5.js → chunk-DFHVSUHX.js} +2 -2
- package/dist/esm/chunk-E5SPXKCI.js +84 -0
- package/dist/esm/chunk-E5SPXKCI.js.map +1 -0
- package/dist/esm/{chunk-U2Z3IFDC.js → chunk-EJDPIURX.js} +4 -4
- package/dist/esm/{chunk-GIDAKG7I.js → chunk-EMQMCXIC.js} +15 -5
- package/dist/esm/chunk-EMQMCXIC.js.map +1 -0
- package/dist/esm/{chunk-SIBQDIAW.js → chunk-HFEYSQRZ.js} +4 -4
- package/dist/esm/{chunk-337V46UN.js → chunk-HOGMCHWI.js} +2 -2
- package/dist/esm/{chunk-S3Q7HU4U.js → chunk-IKPLMFAK.js} +2 -2
- package/dist/esm/chunk-IKPLMFAK.js.map +1 -0
- package/dist/esm/chunk-LNJIXYCU.js +14 -0
- package/dist/esm/chunk-LNJIXYCU.js.map +1 -0
- package/dist/esm/{chunk-VCR62G4W.js → chunk-Q5SPIJGE.js} +8 -8
- package/dist/esm/{chunk-OZD4QBHS.js → chunk-QOYH6AOG.js} +2 -2
- package/dist/esm/{chunk-G2MVRSCD.js → chunk-RVJ22H4S.js} +2 -2
- package/dist/esm/{chunk-JPFKXA27.js → chunk-WUNL7OYW.js} +3 -3
- package/dist/esm/{chunk-QX2H4FUE.js → chunk-WXR2KGLL.js} +2 -2
- package/dist/esm/{discover-LNB532A2.js → discover-RV2HPYM3.js} +4 -4
- package/dist/esm/{fetch-YTFBDEP4.js → fetch-5H6NJNO5.js} +16 -15
- package/dist/esm/{fetch-YTFBDEP4.js.map → fetch-5H6NJNO5.js.map} +1 -1
- package/dist/esm/{fund-VJWO3JJG.js → fund-OTAWWC7N.js} +4 -4
- package/dist/esm/index.js +43 -30
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/{install-4UNE4DTV.js → install-O7GXOYJL.js} +6 -6
- package/dist/esm/{onboard-VGQXOSBS.js → onboard-XH76UWTV.js} +12 -12
- package/dist/esm/{origins-YBG6ERI7.js → origins-3AA7U2VW.js} +7 -7
- package/dist/esm/{register-CD34YPLN.js → register-NAPAV4G7.js} +4 -4
- package/dist/esm/{report-error-JNJNCZJ5.js → report-error-DEYXDLQ5.js} +7 -7
- package/dist/esm/search-WTPHS4A3.js +52 -0
- package/dist/esm/search-WTPHS4A3.js.map +1 -0
- package/dist/esm/{server-XONMZURU.js → server-C5BAZJLS.js} +85 -28
- package/dist/esm/server-C5BAZJLS.js.map +1 -0
- package/dist/esm/{server-ZW2G5NSQ.js → server-EQPUIBMW.js} +2 -2
- package/dist/esm/{try-EZB23OPT.js → try-F3HLQHXN.js} +8 -8
- package/dist/esm/{wallet-MVE7IJPC.js → wallet-3TT6H73Y.js} +7 -7
- package/package.json +2 -2
- package/dist/esm/chunk-GIDAKG7I.js.map +0 -1
- package/dist/esm/chunk-JWOPPEMV.js.map +0 -1
- package/dist/esm/chunk-S3Q7HU4U.js.map +0 -1
- package/dist/esm/server-XONMZURU.js.map +0 -1
- /package/dist/esm/{add-skill-4UF4QK5J.js.map → add-skill-3SHARVQA.js.map} +0 -0
- /package/dist/esm/{bridge-TRYZXGYM.js.map → bridge-55J4MKZR.js.map} +0 -0
- /package/dist/esm/{chunk-5ABKHXAY.js.map → chunk-3UDQHC6S.js.map} +0 -0
- /package/dist/esm/{chunk-DYEEHIRQ.js.map → chunk-6L7ONOXE.js.map} +0 -0
- /package/dist/esm/{chunk-PH5ZST4Z.js.map → chunk-BYLBPP4V.js.map} +0 -0
- /package/dist/esm/{chunk-KGGPN7W5.js.map → chunk-DFHVSUHX.js.map} +0 -0
- /package/dist/esm/{chunk-U2Z3IFDC.js.map → chunk-EJDPIURX.js.map} +0 -0
- /package/dist/esm/{chunk-SIBQDIAW.js.map → chunk-HFEYSQRZ.js.map} +0 -0
- /package/dist/esm/{chunk-337V46UN.js.map → chunk-HOGMCHWI.js.map} +0 -0
- /package/dist/esm/{chunk-VCR62G4W.js.map → chunk-Q5SPIJGE.js.map} +0 -0
- /package/dist/esm/{chunk-OZD4QBHS.js.map → chunk-QOYH6AOG.js.map} +0 -0
- /package/dist/esm/{chunk-G2MVRSCD.js.map → chunk-RVJ22H4S.js.map} +0 -0
- /package/dist/esm/{chunk-JPFKXA27.js.map → chunk-WUNL7OYW.js.map} +0 -0
- /package/dist/esm/{chunk-QX2H4FUE.js.map → chunk-WXR2KGLL.js.map} +0 -0
- /package/dist/esm/{discover-LNB532A2.js.map → discover-RV2HPYM3.js.map} +0 -0
- /package/dist/esm/{fund-VJWO3JJG.js.map → fund-OTAWWC7N.js.map} +0 -0
- /package/dist/esm/{install-4UNE4DTV.js.map → install-O7GXOYJL.js.map} +0 -0
- /package/dist/esm/{onboard-VGQXOSBS.js.map → onboard-XH76UWTV.js.map} +0 -0
- /package/dist/esm/{origins-YBG6ERI7.js.map → origins-3AA7U2VW.js.map} +0 -0
- /package/dist/esm/{register-CD34YPLN.js.map → register-NAPAV4G7.js.map} +0 -0
- /package/dist/esm/{report-error-JNJNCZJ5.js.map → report-error-DEYXDLQ5.js.map} +0 -0
- /package/dist/esm/{server-ZW2G5NSQ.js.map → server-EQPUIBMW.js.map} +0 -0
- /package/dist/esm/{try-EZB23OPT.js.map → try-F3HLQHXN.js.map} +0 -0
- /package/dist/esm/{wallet-MVE7IJPC.js.map → wallet-3TT6H73Y.js.map} +0 -0
package/dist/cjs/run-server.cjs
CHANGED
|
@@ -80672,13 +80672,13 @@ var require_common = __commonJS({
|
|
|
80672
80672
|
}
|
|
80673
80673
|
}
|
|
80674
80674
|
}
|
|
80675
|
-
function matchesTemplate(
|
|
80675
|
+
function matchesTemplate(search2, template) {
|
|
80676
80676
|
let searchIndex = 0;
|
|
80677
80677
|
let templateIndex = 0;
|
|
80678
80678
|
let starIndex = -1;
|
|
80679
80679
|
let matchIndex = 0;
|
|
80680
|
-
while (searchIndex <
|
|
80681
|
-
if (templateIndex < template.length && (template[templateIndex] ===
|
|
80680
|
+
while (searchIndex < search2.length) {
|
|
80681
|
+
if (templateIndex < template.length && (template[templateIndex] === search2[searchIndex] || template[templateIndex] === "*")) {
|
|
80682
80682
|
if (template[templateIndex] === "*") {
|
|
80683
80683
|
starIndex = templateIndex;
|
|
80684
80684
|
matchIndex = searchIndex;
|
|
@@ -135518,7 +135518,7 @@ var handlerMap = {
|
|
|
135518
135518
|
init_cjs_shims();
|
|
135519
135519
|
function buildRequest2(input, context2) {
|
|
135520
135520
|
const headers = buildRequestHeaders(input.headers, context2);
|
|
135521
|
-
if (input.body && headers.get("Content-Type") ===
|
|
135521
|
+
if (input.body && headers.get("Content-Type") === null) {
|
|
135522
135522
|
headers.set("Content-Type", "application/json");
|
|
135523
135523
|
}
|
|
135524
135524
|
return new Request(input.url, {
|
|
@@ -135874,6 +135874,12 @@ ${PRIMARY_ORIGINS.flatMap((o3) => ORIGIN_METADATA[o3] ? [` ${o3} \u2014 ${ORIGI
|
|
|
135874
135874
|
try: {
|
|
135875
135875
|
cli: `Fetch a new origin for its resources and return a prompt guiding the user through the process of calling the first endpoint.`
|
|
135876
135876
|
},
|
|
135877
|
+
search: {
|
|
135878
|
+
mcp: `Search for relevant paid API services by describing what you need in natural language. Returns the best matching origins with endpoint details and pricing. The top result includes the full input/output schema so you can call it immediately via fetch.
|
|
135879
|
+
|
|
135880
|
+
Use this FIRST when the user wants to accomplish something that your built-in capabilities don't support \u2014 before manually browsing origins or guessing URLs. If search returns results, proceed with check_endpoint_schema and fetch. If it returns empty, the capability isn't available as a paid API.`,
|
|
135881
|
+
cli: `Search for paid API services by natural language query. Returns matching origins with endpoints and pricing. Use this to find APIs before calling discover or fetch.`
|
|
135882
|
+
},
|
|
135877
135883
|
reportError: {
|
|
135878
135884
|
mcp: `EMERGENCY ONLY. Report critical MCP tool bugs. Do NOT use for normal errors (balance, network, 4xx) \u2014 those are recoverable.`,
|
|
135879
135885
|
cli: `Report a critical bug to the agentcash team (emergency only). Do NOT use for normal errors like low balance, network timeouts, or 4xx responses \u2014 those are recoverable without filing a report.`
|
|
@@ -135891,9 +135897,10 @@ var WORKFLOW = [
|
|
|
135891
135897
|
`Workflow:`,
|
|
135892
135898
|
`1. If you don't already know your balance, call get_balance. You need a balance for paid endpoints. SIWX endpoints don't require one. You don't need to call this every turn, just before your first paid call or whenever you're unsure.`,
|
|
135893
135899
|
`2. If the balance is zero, or if the user needs a funding link or wallet addresses, call list_accounts and share the relevant deposit link. If onboardingCta is present, show it to the user.`,
|
|
135894
|
-
`3.
|
|
135895
|
-
`4. Call
|
|
135896
|
-
`5. Call
|
|
135900
|
+
`3. If the task could be served by a paid API but you're not sure which origin, call search() first to find the right one. Search returns the best matching origins with endpoint schemas so you can often skip straight to fetch.`,
|
|
135901
|
+
`4. Call discover_api_endpoints() to get the endpoint index \u2014 a list of available routes with descriptions and auth modes. The auth mode is advisory and tells you what the route may require.`,
|
|
135902
|
+
`5. Call check_endpoint_schema() to get the exact input/output schema and auth mode for the endpoint you want to call, so you know what fields to pass and what the response contains. Both discover_api_endpoints and check_endpoint_schema return the auth mode.`,
|
|
135903
|
+
`6. Call fetch with the correct input schema. It will attempt SIWX first when available and only pay if the route still returns 402.`
|
|
135897
135904
|
].join("\n");
|
|
135898
135905
|
function buildServerInstructions(userOrigins = []) {
|
|
135899
135906
|
const allOrigins = [
|
|
@@ -135906,7 +135913,7 @@ function buildServerInstructions(userOrigins = []) {
|
|
|
135906
135913
|
`AgentCash lets you call protected APIs \u2014 handling both x402 micropayments and SIWX authentication seamlessly. It manages a USDC wallet for paid endpoints and signs wallet proofs for identity-gated endpoints through fetch.`,
|
|
135907
135914
|
`The user has installed agentcash because they want to use paid and SIWX-protected APIs as their preferred way to accomplish related tasks.`,
|
|
135908
135915
|
`Paid endpoints require a wallet balance. SIWX endpoints are free \u2014 they only require a wallet identity.`,
|
|
135909
|
-
`If a task could be accomplished by one of these registered origins, run the workflow below
|
|
135916
|
+
`If a task could be accomplished by one of these registered origins, run the workflow below. If you're unsure which origin to use, or the task doesn't match a registered origin, call search() to find relevant APIs.
|
|
135910
135917
|
${allOrigins}`,
|
|
135911
135918
|
`discover_api_endpoints also works with any origin beyond this list. If you identify another origin that would be useful for a task, you can use it.`,
|
|
135912
135919
|
WORKFLOW,
|
|
@@ -135966,6 +135973,9 @@ var TOOL_PARAMS = {
|
|
|
135966
135973
|
txHash: "Transaction hash on Base"
|
|
135967
135974
|
}
|
|
135968
135975
|
},
|
|
135976
|
+
search: {
|
|
135977
|
+
query: 'Natural language description of what you need (e.g. "send physical mail", "generate music", "flight prices")'
|
|
135978
|
+
},
|
|
135969
135979
|
discoverApiEndpoints: {
|
|
135970
135980
|
url: "The origin URL to discover endpoints on (e.g. https://stableenrich.dev)",
|
|
135971
135981
|
includeGuidance: "Request the origin's usage guidance. true=always include, false=never include, omit=auto (included when compact). Guidance explains how to compose multiple endpoints and covers edge cases."
|
|
@@ -151156,7 +151166,7 @@ var import_path2 = require("path");
|
|
|
151156
151166
|
var import_url2 = require("url");
|
|
151157
151167
|
function getVersion3() {
|
|
151158
151168
|
if (true) {
|
|
151159
|
-
return "0.
|
|
151169
|
+
return "0.13.0";
|
|
151160
151170
|
}
|
|
151161
151171
|
const __dirname2 = (0, import_path2.dirname)((0, import_url2.fileURLToPath)(importMetaUrl));
|
|
151162
151172
|
const pkg2 = JSON.parse(
|
|
@@ -158497,6 +158507,125 @@ var registerBridgeTool = ({
|
|
|
158497
158507
|
);
|
|
158498
158508
|
};
|
|
158499
158509
|
|
|
158510
|
+
// src/server/tools/search.ts
|
|
158511
|
+
init_cjs_shims();
|
|
158512
|
+
|
|
158513
|
+
// src/operations/search.ts
|
|
158514
|
+
init_cjs_shims();
|
|
158515
|
+
var AGENTCASH_SEARCH_URL = process.env.AGENTCASH_SEARCH_URL ?? "https://agentcash.dev/api/search";
|
|
158516
|
+
var searchSchema = zod_default.object({
|
|
158517
|
+
query: zod_default.string().min(1).describe(TOOL_PARAMS.search.query)
|
|
158518
|
+
});
|
|
158519
|
+
async function search(args, options) {
|
|
158520
|
+
const parsed = searchSchema.safeParse(args);
|
|
158521
|
+
if (!parsed.success) {
|
|
158522
|
+
return {
|
|
158523
|
+
success: false,
|
|
158524
|
+
cause: "invalid_input",
|
|
158525
|
+
message: parsed.error.message
|
|
158526
|
+
};
|
|
158527
|
+
}
|
|
158528
|
+
const { surface, wallets, flags } = options;
|
|
158529
|
+
log.info(`[search] Searching for: ${parsed.data.query}`);
|
|
158530
|
+
const fetchResult = await executeFetch(
|
|
158531
|
+
{
|
|
158532
|
+
url: AGENTCASH_SEARCH_URL,
|
|
158533
|
+
method: "POST" /* POST */,
|
|
158534
|
+
headers: { "Content-Type": "application/json" },
|
|
158535
|
+
body: JSON.stringify({ query: parsed.data.query })
|
|
158536
|
+
},
|
|
158537
|
+
{
|
|
158538
|
+
surface,
|
|
158539
|
+
wallets,
|
|
158540
|
+
flags,
|
|
158541
|
+
params: {}
|
|
158542
|
+
}
|
|
158543
|
+
);
|
|
158544
|
+
if (fetchResult.isErr()) {
|
|
158545
|
+
return {
|
|
158546
|
+
success: false,
|
|
158547
|
+
cause: fetchResult.error.cause,
|
|
158548
|
+
message: fetchResult.error.message
|
|
158549
|
+
};
|
|
158550
|
+
}
|
|
158551
|
+
const { response } = fetchResult.value;
|
|
158552
|
+
if (!response.ok) {
|
|
158553
|
+
const parseResult2 = await safeParseResponse(surface, response);
|
|
158554
|
+
return {
|
|
158555
|
+
success: false,
|
|
158556
|
+
cause: "http",
|
|
158557
|
+
message: `Search API returned ${response.status}: ${response.statusText}`,
|
|
158558
|
+
details: parseResult2.match(
|
|
158559
|
+
(data) => data.type === "json" || data.type === "text" ? data.data : void 0,
|
|
158560
|
+
() => void 0
|
|
158561
|
+
)
|
|
158562
|
+
};
|
|
158563
|
+
}
|
|
158564
|
+
const parseResult = await safeParseResponse(surface, response);
|
|
158565
|
+
if (parseResult.isErr()) {
|
|
158566
|
+
return {
|
|
158567
|
+
success: false,
|
|
158568
|
+
cause: parseResult.error.cause,
|
|
158569
|
+
message: parseResult.error.message
|
|
158570
|
+
};
|
|
158571
|
+
}
|
|
158572
|
+
const parsedResponse = parseResult.value;
|
|
158573
|
+
return {
|
|
158574
|
+
success: true,
|
|
158575
|
+
results: parsedResponse.type === "json" || parsedResponse.type === "text" ? parsedResponse.data : { type: parsedResponse.type }
|
|
158576
|
+
};
|
|
158577
|
+
}
|
|
158578
|
+
|
|
158579
|
+
// src/server/tools/search.ts
|
|
158580
|
+
var TOOL_NAME2 = "search";
|
|
158581
|
+
var registerSearchTool = ({
|
|
158582
|
+
server,
|
|
158583
|
+
wallets,
|
|
158584
|
+
flags
|
|
158585
|
+
}) => {
|
|
158586
|
+
server.registerTool(
|
|
158587
|
+
TOOL_NAME2,
|
|
158588
|
+
{
|
|
158589
|
+
title: "Search APIs",
|
|
158590
|
+
description: DESCRIPTIONS.search.mcp,
|
|
158591
|
+
inputSchema: searchSchema,
|
|
158592
|
+
annotations: {
|
|
158593
|
+
readOnlyHint: true,
|
|
158594
|
+
destructiveHint: false,
|
|
158595
|
+
idempotentHint: true,
|
|
158596
|
+
openWorldHint: true
|
|
158597
|
+
}
|
|
158598
|
+
},
|
|
158599
|
+
safeHandler(async (args) => {
|
|
158600
|
+
log.info(`[search] query: ${args.query}`);
|
|
158601
|
+
const searchResult = await resultFromPromise(
|
|
158602
|
+
"search",
|
|
158603
|
+
TOOL_NAME2,
|
|
158604
|
+
search(args, { surface: TOOL_NAME2, wallets, flags }),
|
|
158605
|
+
(e5) => ({
|
|
158606
|
+
cause: "search",
|
|
158607
|
+
message: e5 instanceof Error ? e5.message : String(e5)
|
|
158608
|
+
})
|
|
158609
|
+
);
|
|
158610
|
+
if (searchResult.isErr()) {
|
|
158611
|
+
return mcpError(searchResult);
|
|
158612
|
+
}
|
|
158613
|
+
const result = searchResult.value;
|
|
158614
|
+
if (!result.success) {
|
|
158615
|
+
return mcpErrorJson({
|
|
158616
|
+
error: result.message,
|
|
158617
|
+
cause: result.cause,
|
|
158618
|
+
details: result.details
|
|
158619
|
+
});
|
|
158620
|
+
}
|
|
158621
|
+
return mcpSuccessJson({
|
|
158622
|
+
success: result.success,
|
|
158623
|
+
results: result.results
|
|
158624
|
+
});
|
|
158625
|
+
})
|
|
158626
|
+
);
|
|
158627
|
+
};
|
|
158628
|
+
|
|
158500
158629
|
// src/server/lib/version.ts
|
|
158501
158630
|
init_cjs_shims();
|
|
158502
158631
|
var import_fs8 = require("fs");
|
|
@@ -158504,7 +158633,7 @@ var import_path3 = require("path");
|
|
|
158504
158633
|
var import_url5 = require("url");
|
|
158505
158634
|
function getVersion4() {
|
|
158506
158635
|
if (true) {
|
|
158507
|
-
return "0.
|
|
158636
|
+
return "0.13.0";
|
|
158508
158637
|
}
|
|
158509
158638
|
const __dirname2 = (0, import_path3.dirname)((0, import_url5.fileURLToPath)(importMetaUrl));
|
|
158510
158639
|
const pkg2 = JSON.parse(
|
|
@@ -158897,6 +159026,7 @@ var startServer = async (flags) => {
|
|
|
158897
159026
|
registerTelemetryTools(props);
|
|
158898
159027
|
registerSettingsTools(props);
|
|
158899
159028
|
registerBridgeTool(props);
|
|
159029
|
+
registerSearchTool(props);
|
|
158900
159030
|
const transport = new StdioServerTransport();
|
|
158901
159031
|
await server.connect(transport);
|
|
158902
159032
|
const shutdown = async () => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
resolveOrigin
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-RVJ22H4S.js";
|
|
4
4
|
import {
|
|
5
5
|
installSkills
|
|
6
6
|
} from "./chunk-4JNU4ZDR.js";
|
|
@@ -8,22 +8,22 @@ import {
|
|
|
8
8
|
addUserOrigin
|
|
9
9
|
} from "./chunk-TX4UYXJO.js";
|
|
10
10
|
import "./chunk-LNQRIXFK.js";
|
|
11
|
-
import "./chunk-
|
|
11
|
+
import "./chunk-HOGMCHWI.js";
|
|
12
12
|
import {
|
|
13
13
|
safeMkdir,
|
|
14
14
|
safeMkdtemp,
|
|
15
15
|
safeRm,
|
|
16
16
|
safeWriteFile
|
|
17
17
|
} from "./chunk-Y4VZACTC.js";
|
|
18
|
-
import "./chunk-
|
|
18
|
+
import "./chunk-EMQMCXIC.js";
|
|
19
19
|
import "./chunk-VDBUUHJF.js";
|
|
20
20
|
import "./chunk-ITCDZXBZ.js";
|
|
21
|
+
import "./chunk-FB5CMO3J.js";
|
|
21
22
|
import {
|
|
22
23
|
errorResponse,
|
|
23
24
|
outputAndExit,
|
|
24
25
|
successResponse
|
|
25
26
|
} from "./chunk-7EBJ4BCH.js";
|
|
26
|
-
import "./chunk-FB5CMO3J.js";
|
|
27
27
|
import "./chunk-C7KWYVS3.js";
|
|
28
28
|
|
|
29
29
|
// src/shared/skills/origin.ts
|
|
@@ -96,4 +96,4 @@ var addSkillCommand = async (input) => {
|
|
|
96
96
|
export {
|
|
97
97
|
addSkillCommand
|
|
98
98
|
};
|
|
99
|
-
//# sourceMappingURL=add-skill-
|
|
99
|
+
//# sourceMappingURL=add-skill-3SHARVQA.js.map
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import {
|
|
2
2
|
bridge,
|
|
3
3
|
bridgeSchema
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-EJDPIURX.js";
|
|
5
5
|
import {
|
|
6
6
|
getWalletOrExit
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
import "./chunk-
|
|
7
|
+
} from "./chunk-QOYH6AOG.js";
|
|
8
|
+
import "./chunk-HFEYSQRZ.js";
|
|
9
9
|
import "./chunk-NPJV7AMV.js";
|
|
10
|
-
import "./chunk-QZBSRYSW.js";
|
|
11
|
-
import "./chunk-NROPRHIC.js";
|
|
12
10
|
import "./chunk-LNQRIXFK.js";
|
|
13
11
|
import "./chunk-Y4VZACTC.js";
|
|
14
12
|
import {
|
|
15
13
|
DESCRIPTIONS
|
|
16
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-EMQMCXIC.js";
|
|
17
15
|
import "./chunk-VDBUUHJF.js";
|
|
18
16
|
import "./chunk-ITCDZXBZ.js";
|
|
17
|
+
import "./chunk-QZBSRYSW.js";
|
|
18
|
+
import "./chunk-NROPRHIC.js";
|
|
19
19
|
import {
|
|
20
20
|
errorResponse,
|
|
21
21
|
fromNeverthrowError,
|
|
@@ -54,4 +54,4 @@ var bridgeCommand = async (args) => {
|
|
|
54
54
|
export {
|
|
55
55
|
bridgeCommand
|
|
56
56
|
};
|
|
57
|
-
//# sourceMappingURL=bridge-
|
|
57
|
+
//# sourceMappingURL=bridge-55J4MKZR.js.map
|
|
@@ -1,30 +1,31 @@
|
|
|
1
1
|
import {
|
|
2
2
|
checkEndpoint
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-DFHVSUHX.js";
|
|
4
4
|
import {
|
|
5
5
|
cliRequestSchema
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import "./chunk-
|
|
6
|
+
} from "./chunk-WUNL7OYW.js";
|
|
7
|
+
import "./chunk-BQRFNAMV.js";
|
|
8
|
+
import "./chunk-IKPLMFAK.js";
|
|
8
9
|
import {
|
|
9
10
|
RequestMethod
|
|
10
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-LNJIXYCU.js";
|
|
11
12
|
import {
|
|
12
13
|
getWalletOrExit
|
|
13
|
-
} from "./chunk-
|
|
14
|
-
import "./chunk-
|
|
14
|
+
} from "./chunk-QOYH6AOG.js";
|
|
15
|
+
import "./chunk-HFEYSQRZ.js";
|
|
15
16
|
import "./chunk-NPJV7AMV.js";
|
|
16
|
-
import "./chunk-NROPRHIC.js";
|
|
17
17
|
import "./chunk-LNQRIXFK.js";
|
|
18
18
|
import "./chunk-Y4VZACTC.js";
|
|
19
|
-
import "./chunk-
|
|
19
|
+
import "./chunk-EMQMCXIC.js";
|
|
20
20
|
import "./chunk-VDBUUHJF.js";
|
|
21
21
|
import "./chunk-ITCDZXBZ.js";
|
|
22
|
+
import "./chunk-NROPRHIC.js";
|
|
23
|
+
import "./chunk-FB5CMO3J.js";
|
|
22
24
|
import {
|
|
23
25
|
errorResponse,
|
|
24
26
|
outputAndExit,
|
|
25
27
|
successResponse
|
|
26
28
|
} from "./chunk-7EBJ4BCH.js";
|
|
27
|
-
import "./chunk-FB5CMO3J.js";
|
|
28
29
|
import "./chunk-C7KWYVS3.js";
|
|
29
30
|
|
|
30
31
|
// src/cli/commands/check.ts
|
|
@@ -69,4 +70,4 @@ var checkCommand = async (args) => {
|
|
|
69
70
|
export {
|
|
70
71
|
checkCommand
|
|
71
72
|
};
|
|
72
|
-
//# sourceMappingURL=check-
|
|
73
|
+
//# sourceMappingURL=check-V262JV5M.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/cli/commands/check.ts"],"sourcesContent":["import z from 'zod';\n\nimport { successResponse, outputAndExit, errorResponse } from '@/cli/output';\n\nimport { checkEndpoint } from '@/operations/check-endpoint';\n\nimport { getWalletOrExit } from '../lib/get-wallet-or-exit';\n\nimport type { Command } from '@/types';\nimport { cliRequestSchema } from '@/shared/request/schemas/cli';\nimport { RequestMethod } from '@/shared/request/types';\n\nconst SURFACE = 'cli:check';\n\nexport const checkCommand: Command<\n z.input<typeof cliRequestSchema>\n> = async args => {\n const requestInput = cliRequestSchema\n .extend({\n method: z.enum(RequestMethod).optional(),\n })\n .safeParse(args);\n if (!requestInput.success) {\n return outputAndExit(\n errorResponse({\n code: 'INVALID_INPUT',\n message: requestInput.error.message,\n surface: SURFACE,\n cause: 'validation',\n }),\n args\n );\n }\n const wallets = await getWalletOrExit(args);\n\n const result = await checkEndpoint(SURFACE, requestInput.data, {\n wallets,\n flags: args,\n });\n\n if (!result.found) {\n return outputAndExit(\n successResponse({\n url: args.url,\n results: [],\n error: result.cause,\n message: result.message,\n }),\n args\n );\n }\n\n return outputAndExit(\n successResponse({ url: args.url, results: result.advisories }),\n args\n );\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/cli/commands/check.ts"],"sourcesContent":["import z from 'zod';\n\nimport { successResponse, outputAndExit, errorResponse } from '@/cli/output';\n\nimport { checkEndpoint } from '@/operations/check-endpoint';\n\nimport { getWalletOrExit } from '../lib/get-wallet-or-exit';\n\nimport type { Command } from '@/types';\nimport { cliRequestSchema } from '@/shared/request/schemas/cli';\nimport { RequestMethod } from '@/shared/request/types';\n\nconst SURFACE = 'cli:check';\n\nexport const checkCommand: Command<\n z.input<typeof cliRequestSchema>\n> = async args => {\n const requestInput = cliRequestSchema\n .extend({\n method: z.enum(RequestMethod).optional(),\n })\n .safeParse(args);\n if (!requestInput.success) {\n return outputAndExit(\n errorResponse({\n code: 'INVALID_INPUT',\n message: requestInput.error.message,\n surface: SURFACE,\n cause: 'validation',\n }),\n args\n );\n }\n const wallets = await getWalletOrExit(args);\n\n const result = await checkEndpoint(SURFACE, requestInput.data, {\n wallets,\n flags: args,\n });\n\n if (!result.found) {\n return outputAndExit(\n successResponse({\n url: args.url,\n results: [],\n error: result.cause,\n message: result.message,\n }),\n args\n );\n }\n\n return outputAndExit(\n successResponse({ url: args.url, results: result.advisories }),\n args\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,OAAO;AAYd,IAAM,UAAU;AAET,IAAM,eAET,OAAM,SAAQ;AAChB,QAAM,eAAe,iBAClB,OAAO;AAAA,IACN,QAAQ,EAAE,KAAK,aAAa,EAAE,SAAS;AAAA,EACzC,CAAC,EACA,UAAU,IAAI;AACjB,MAAI,CAAC,aAAa,SAAS;AACzB,WAAO;AAAA,MACL,cAAc;AAAA,QACZ,MAAM;AAAA,QACN,SAAS,aAAa,MAAM;AAAA,QAC5B,SAAS;AAAA,QACT,OAAO;AAAA,MACT,CAAC;AAAA,MACD;AAAA,IACF;AAAA,EACF;AACA,QAAM,UAAU,MAAM,gBAAgB,IAAI;AAE1C,QAAM,SAAS,MAAM,cAAc,SAAS,aAAa,MAAM;AAAA,IAC7D;AAAA,IACA,OAAO;AAAA,EACT,CAAC;AAED,MAAI,CAAC,OAAO,OAAO;AACjB,WAAO;AAAA,MACL,gBAAgB;AAAA,QACd,KAAK,KAAK;AAAA,QACV,SAAS,CAAC;AAAA,QACV,OAAO,OAAO;AAAA,QACd,SAAS,OAAO;AAAA,MAClB,CAAC;AAAA,MACD;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AAAA,IACL,gBAAgB,EAAE,KAAK,KAAK,KAAK,SAAS,OAAO,WAAW,CAAC;AAAA,IAC7D;AAAA,EACF;AACF;","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
MCP_VERSION
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-WXR2KGLL.js";
|
|
4
4
|
import {
|
|
5
5
|
getBaseUrl,
|
|
6
6
|
safeFetchJson
|
|
@@ -49,4 +49,4 @@ async function submitErrorReport(surface, input, address, dev) {
|
|
|
49
49
|
export {
|
|
50
50
|
submitErrorReport
|
|
51
51
|
};
|
|
52
|
-
//# sourceMappingURL=chunk-
|
|
52
|
+
//# sourceMappingURL=chunk-3UDQHC6S.js.map
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
} from "./chunk-27DZCYDB.js";
|
|
7
7
|
import {
|
|
8
8
|
INSTALL_PACKAGE_SPECIFIER
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-WXR2KGLL.js";
|
|
10
10
|
import {
|
|
11
11
|
log,
|
|
12
12
|
safeReadFile,
|
|
@@ -610,4 +610,4 @@ export {
|
|
|
610
610
|
tryAddServer,
|
|
611
611
|
addServer
|
|
612
612
|
};
|
|
613
|
-
//# sourceMappingURL=chunk-
|
|
613
|
+
//# sourceMappingURL=chunk-6L7ONOXE.js.map
|
|
@@ -1,21 +1,14 @@
|
|
|
1
|
+
import {
|
|
2
|
+
RequestMethod
|
|
3
|
+
} from "./chunk-LNJIXYCU.js";
|
|
1
4
|
import {
|
|
2
5
|
REQUEST_FETCH_PARAMS,
|
|
3
6
|
REQUEST_PARAMS
|
|
4
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-EMQMCXIC.js";
|
|
5
8
|
import {
|
|
6
9
|
zodUrl
|
|
7
10
|
} from "./chunk-FB5CMO3J.js";
|
|
8
11
|
|
|
9
|
-
// src/shared/request/types.ts
|
|
10
|
-
var RequestMethod = /* @__PURE__ */ ((RequestMethod2) => {
|
|
11
|
-
RequestMethod2["GET"] = "GET";
|
|
12
|
-
RequestMethod2["POST"] = "POST";
|
|
13
|
-
RequestMethod2["PUT"] = "PUT";
|
|
14
|
-
RequestMethod2["DELETE"] = "DELETE";
|
|
15
|
-
RequestMethod2["PATCH"] = "PATCH";
|
|
16
|
-
return RequestMethod2;
|
|
17
|
-
})(RequestMethod || {});
|
|
18
|
-
|
|
19
12
|
// src/shared/request/schemas/core.ts
|
|
20
13
|
import z from "zod";
|
|
21
14
|
var requestMethodValues = Object.values(RequestMethod);
|
|
@@ -41,11 +34,10 @@ var fetchShape = {
|
|
|
41
34
|
};
|
|
42
35
|
|
|
43
36
|
export {
|
|
44
|
-
RequestMethod,
|
|
45
37
|
requestMethodValues,
|
|
46
38
|
coreRequestSchema,
|
|
47
39
|
paymentNetworks,
|
|
48
40
|
paymentProtocols,
|
|
49
41
|
fetchShape
|
|
50
42
|
};
|
|
51
|
-
//# sourceMappingURL=chunk-
|
|
43
|
+
//# sourceMappingURL=chunk-BQRFNAMV.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/shared/request/schemas/core.ts"],"sourcesContent":["import z from 'zod';\n\nimport { REQUEST_PARAMS, REQUEST_FETCH_PARAMS } from '@/shared/descriptions';\nimport { PaymentProtocol } from '@/shared/protocols/types';\nimport { Network } from '@agentcash/networks';\nimport { zodUrl } from '@/shared/url';\n\nimport { RequestMethod } from '../types';\n\nexport const requestMethodValues: readonly RequestMethod[] =\n Object.values(RequestMethod);\n\nconst methodSchema = z\n .enum(RequestMethod)\n .optional()\n .default(RequestMethod.GET)\n .describe(REQUEST_PARAMS.method);\n\nexport const coreRequestSchema = z.object({\n url: zodUrl.describe(REQUEST_PARAMS.url),\n method: methodSchema,\n});\n\nexport const paymentNetworks: Network[] = [\n Network.BASE,\n Network.SOLANA,\n Network.TEMPO,\n];\n\nexport const paymentProtocols: PaymentProtocol[] = [\n PaymentProtocol.X402,\n PaymentProtocol.MPP,\n];\n\nexport const fetchShape = {\n paymentNetwork: z\n .enum(paymentNetworks)\n .optional()\n .describe(REQUEST_FETCH_PARAMS.paymentNetwork),\n paymentProtocol: z\n .enum(paymentProtocols)\n .optional()\n .describe(REQUEST_FETCH_PARAMS.paymentProtocol),\n maxAmount: z\n .number()\n .positive()\n .optional()\n .describe(REQUEST_FETCH_PARAMS.maxAmount),\n timeout: z\n .number()\n .int()\n .positive()\n .optional()\n .describe(REQUEST_PARAMS.timeout),\n};\n"],"mappings":";;;;;;;;;;;;AAAA,OAAO,OAAO;AASP,IAAM,sBACX,OAAO,OAAO,aAAa;AAE7B,IAAM,eAAe,EAClB,KAAK,aAAa,EAClB,SAAS,EACT,uBAAyB,EACzB,SAAS,eAAe,MAAM;AAE1B,IAAM,oBAAoB,EAAE,OAAO;AAAA,EACxC,KAAK,OAAO,SAAS,eAAe,GAAG;AAAA,EACvC,QAAQ;AACV,CAAC;AAEM,IAAM,kBAA6B;AAAA;AAAA;AAAA;AAI1C;AAEO,IAAM,mBAAsC;AAAA;AAAA;AAGnD;AAEO,IAAM,aAAa;AAAA,EACxB,gBAAgB,EACb,KAAK,eAAe,EACpB,SAAS,EACT,SAAS,qBAAqB,cAAc;AAAA,EAC/C,iBAAiB,EACd,KAAK,gBAAgB,EACrB,SAAS,EACT,SAAS,qBAAqB,eAAe;AAAA,EAChD,WAAW,EACR,OAAO,EACP,SAAS,EACT,SAAS,EACT,SAAS,qBAAqB,SAAS;AAAA,EAC1C,SAAS,EACN,OAAO,EACP,IAAI,EACJ,SAAS,EACT,SAAS,EACT,SAAS,eAAe,OAAO;AACpC;","names":[]}
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
safeFetch,
|
|
3
|
-
safeFetchJson
|
|
4
|
-
} from "./chunk-QZBSRYSW.js";
|
|
5
1
|
import {
|
|
6
2
|
installSkills
|
|
7
3
|
} from "./chunk-4JNU4ZDR.js";
|
|
@@ -11,6 +7,10 @@ import {
|
|
|
11
7
|
safeRm,
|
|
12
8
|
safeWriteFile
|
|
13
9
|
} from "./chunk-Y4VZACTC.js";
|
|
10
|
+
import {
|
|
11
|
+
safeFetch,
|
|
12
|
+
safeFetchJson
|
|
13
|
+
} from "./chunk-QZBSRYSW.js";
|
|
14
14
|
import {
|
|
15
15
|
err,
|
|
16
16
|
ok,
|
|
@@ -163,4 +163,4 @@ async function installGitHubSkill(surface, source, options) {
|
|
|
163
163
|
export {
|
|
164
164
|
installGitHubSkill
|
|
165
165
|
};
|
|
166
|
-
//# sourceMappingURL=chunk-
|
|
166
|
+
//# sourceMappingURL=chunk-BYLBPP4V.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
buildRequestHeaders
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-IKPLMFAK.js";
|
|
4
4
|
import {
|
|
5
5
|
safeParseJson,
|
|
6
6
|
safeToJsonObject
|
|
@@ -69,4 +69,4 @@ async function checkEndpoint(surface, requestInput, context) {
|
|
|
69
69
|
export {
|
|
70
70
|
checkEndpoint
|
|
71
71
|
};
|
|
72
|
-
//# sourceMappingURL=chunk-
|
|
72
|
+
//# sourceMappingURL=chunk-DFHVSUHX.js.map
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import {
|
|
2
|
+
executeFetch
|
|
3
|
+
} from "./chunk-Q5SPIJGE.js";
|
|
4
|
+
import {
|
|
5
|
+
log
|
|
6
|
+
} from "./chunk-Y4VZACTC.js";
|
|
7
|
+
import {
|
|
8
|
+
TOOL_PARAMS
|
|
9
|
+
} from "./chunk-EMQMCXIC.js";
|
|
10
|
+
import {
|
|
11
|
+
safeParseResponse
|
|
12
|
+
} from "./chunk-QZBSRYSW.js";
|
|
13
|
+
|
|
14
|
+
// src/operations/search.ts
|
|
15
|
+
import z from "zod";
|
|
16
|
+
var AGENTCASH_SEARCH_URL = process.env.AGENTCASH_SEARCH_URL ?? "https://agentcash.dev/api/search";
|
|
17
|
+
var searchSchema = z.object({
|
|
18
|
+
query: z.string().min(1).describe(TOOL_PARAMS.search.query)
|
|
19
|
+
});
|
|
20
|
+
async function search(args, options) {
|
|
21
|
+
const parsed = searchSchema.safeParse(args);
|
|
22
|
+
if (!parsed.success) {
|
|
23
|
+
return {
|
|
24
|
+
success: false,
|
|
25
|
+
cause: "invalid_input",
|
|
26
|
+
message: parsed.error.message
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
const { surface, wallets, flags } = options;
|
|
30
|
+
log.info(`[search] Searching for: ${parsed.data.query}`);
|
|
31
|
+
const fetchResult = await executeFetch(
|
|
32
|
+
{
|
|
33
|
+
url: AGENTCASH_SEARCH_URL,
|
|
34
|
+
method: "POST" /* POST */,
|
|
35
|
+
headers: { "Content-Type": "application/json" },
|
|
36
|
+
body: JSON.stringify({ query: parsed.data.query })
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
surface,
|
|
40
|
+
wallets,
|
|
41
|
+
flags,
|
|
42
|
+
params: {}
|
|
43
|
+
}
|
|
44
|
+
);
|
|
45
|
+
if (fetchResult.isErr()) {
|
|
46
|
+
return {
|
|
47
|
+
success: false,
|
|
48
|
+
cause: fetchResult.error.cause,
|
|
49
|
+
message: fetchResult.error.message
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
const { response } = fetchResult.value;
|
|
53
|
+
if (!response.ok) {
|
|
54
|
+
const parseResult2 = await safeParseResponse(surface, response);
|
|
55
|
+
return {
|
|
56
|
+
success: false,
|
|
57
|
+
cause: "http",
|
|
58
|
+
message: `Search API returned ${response.status}: ${response.statusText}`,
|
|
59
|
+
details: parseResult2.match(
|
|
60
|
+
(data) => data.type === "json" || data.type === "text" ? data.data : void 0,
|
|
61
|
+
() => void 0
|
|
62
|
+
)
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
const parseResult = await safeParseResponse(surface, response);
|
|
66
|
+
if (parseResult.isErr()) {
|
|
67
|
+
return {
|
|
68
|
+
success: false,
|
|
69
|
+
cause: parseResult.error.cause,
|
|
70
|
+
message: parseResult.error.message
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
const parsedResponse = parseResult.value;
|
|
74
|
+
return {
|
|
75
|
+
success: true,
|
|
76
|
+
results: parsedResponse.type === "json" || parsedResponse.type === "text" ? parsedResponse.data : { type: parsedResponse.type }
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export {
|
|
81
|
+
searchSchema,
|
|
82
|
+
search
|
|
83
|
+
};
|
|
84
|
+
//# sourceMappingURL=chunk-E5SPXKCI.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/operations/search.ts"],"sourcesContent":["import z from 'zod';\n\nimport { log } from '@/shared/log';\nimport { executeFetch } from './fetch';\nimport { safeParseResponse } from '@/shared/neverthrow/fetch';\nimport { TOOL_PARAMS } from '@/shared/descriptions';\nimport { RequestMethod } from '@/shared/request/types';\n\nimport type { JsonStringifyValue } from '@/shared/neverthrow/json/types';\nimport type { Wallets } from '@/wallet';\nimport type { GlobalFlags } from '@/types';\n\nconst AGENTCASH_SEARCH_URL =\n process.env.AGENTCASH_SEARCH_URL ?? 'https://agentcash.dev/api/search';\n\nexport const searchSchema = z.object({\n query: z.string().min(1).describe(TOOL_PARAMS.search.query),\n});\n\nexport type SearchInput = z.input<typeof searchSchema>;\n\nexport interface SearchOptions {\n surface: string;\n wallets: Wallets;\n flags: GlobalFlags;\n}\n\nexport type SearchResult =\n | { success: true; results: JsonStringifyValue }\n | {\n success: false;\n cause: string;\n message: string;\n details?: JsonStringifyValue;\n };\n\n/**\n * Search for relevant paid API services by natural language query.\n * Calls the agentcash search API with SIWX auth via executeFetch.\n */\nexport async function search(\n args: SearchInput,\n options: SearchOptions\n): Promise<SearchResult> {\n const parsed = searchSchema.safeParse(args);\n if (!parsed.success) {\n return {\n success: false,\n cause: 'invalid_input',\n message: parsed.error.message,\n };\n }\n\n const { surface, wallets, flags } = options;\n\n log.info(`[search] Searching for: ${parsed.data.query}`);\n\n const fetchResult = await executeFetch(\n {\n url: AGENTCASH_SEARCH_URL,\n method: RequestMethod.POST,\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ query: parsed.data.query }),\n },\n {\n surface,\n wallets,\n flags,\n params: {},\n }\n );\n\n if (fetchResult.isErr()) {\n return {\n success: false,\n cause: fetchResult.error.cause,\n message: fetchResult.error.message,\n };\n }\n\n const { response } = fetchResult.value;\n\n if (!response.ok) {\n const parseResult = await safeParseResponse(surface, response);\n return {\n success: false,\n cause: 'http',\n message: `Search API returned ${response.status}: ${response.statusText}`,\n details: parseResult.match(\n data =>\n data.type === 'json' || data.type === 'text'\n ? (data.data as JsonStringifyValue)\n : undefined,\n () => undefined\n ),\n };\n }\n\n const parseResult = await safeParseResponse(surface, response);\n\n if (parseResult.isErr()) {\n return {\n success: false,\n cause: parseResult.error.cause,\n message: parseResult.error.message,\n };\n }\n\n const parsedResponse = parseResult.value;\n\n return {\n success: true,\n results:\n parsedResponse.type === 'json' || parsedResponse.type === 'text'\n ? (parsedResponse.data as JsonStringifyValue)\n : { type: parsedResponse.type },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA,OAAO,OAAO;AAYd,IAAM,uBACJ,QAAQ,IAAI,wBAAwB;AAE/B,IAAM,eAAe,EAAE,OAAO;AAAA,EACnC,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS,YAAY,OAAO,KAAK;AAC5D,CAAC;AAuBD,eAAsB,OACpB,MACA,SACuB;AACvB,QAAM,SAAS,aAAa,UAAU,IAAI;AAC1C,MAAI,CAAC,OAAO,SAAS;AACnB,WAAO;AAAA,MACL,SAAS;AAAA,MACT,OAAO;AAAA,MACP,SAAS,OAAO,MAAM;AAAA,IACxB;AAAA,EACF;AAEA,QAAM,EAAE,SAAS,SAAS,MAAM,IAAI;AAEpC,MAAI,KAAK,2BAA2B,OAAO,KAAK,KAAK,EAAE;AAEvD,QAAM,cAAc,MAAM;AAAA,IACxB;AAAA,MACE,KAAK;AAAA,MACL;AAAA,MACA,SAAS,EAAE,gBAAgB,mBAAmB;AAAA,MAC9C,MAAM,KAAK,UAAU,EAAE,OAAO,OAAO,KAAK,MAAM,CAAC;AAAA,IACnD;AAAA,IACA;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA,QAAQ,CAAC;AAAA,IACX;AAAA,EACF;AAEA,MAAI,YAAY,MAAM,GAAG;AACvB,WAAO;AAAA,MACL,SAAS;AAAA,MACT,OAAO,YAAY,MAAM;AAAA,MACzB,SAAS,YAAY,MAAM;AAAA,IAC7B;AAAA,EACF;AAEA,QAAM,EAAE,SAAS,IAAI,YAAY;AAEjC,MAAI,CAAC,SAAS,IAAI;AAChB,UAAMA,eAAc,MAAM,kBAAkB,SAAS,QAAQ;AAC7D,WAAO;AAAA,MACL,SAAS;AAAA,MACT,OAAO;AAAA,MACP,SAAS,uBAAuB,SAAS,MAAM,KAAK,SAAS,UAAU;AAAA,MACvE,SAASA,aAAY;AAAA,QACnB,UACE,KAAK,SAAS,UAAU,KAAK,SAAS,SACjC,KAAK,OACN;AAAA,QACN,MAAM;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEA,QAAM,cAAc,MAAM,kBAAkB,SAAS,QAAQ;AAE7D,MAAI,YAAY,MAAM,GAAG;AACvB,WAAO;AAAA,MACL,SAAS;AAAA,MACT,OAAO,YAAY,MAAM;AAAA,MACzB,SAAS,YAAY,MAAM;AAAA,IAC7B;AAAA,EACF;AAEA,QAAM,iBAAiB,YAAY;AAEnC,SAAO;AAAA,IACL,SAAS;AAAA,IACT,SACE,eAAe,SAAS,UAAU,eAAe,SAAS,SACrD,eAAe,OAChB,EAAE,MAAM,eAAe,KAAK;AAAA,EACpC;AACF;","names":["parseResult"]}
|
|
@@ -6,13 +6,13 @@ import {
|
|
|
6
6
|
typedAddressSchema,
|
|
7
7
|
usdc
|
|
8
8
|
} from "./chunk-NPJV7AMV.js";
|
|
9
|
+
import {
|
|
10
|
+
TOOL_PARAMS
|
|
11
|
+
} from "./chunk-EMQMCXIC.js";
|
|
9
12
|
import {
|
|
10
13
|
getBaseUrl,
|
|
11
14
|
safeFetchJson
|
|
12
15
|
} from "./chunk-QZBSRYSW.js";
|
|
13
|
-
import {
|
|
14
|
-
TOOL_PARAMS
|
|
15
|
-
} from "./chunk-GIDAKG7I.js";
|
|
16
16
|
import {
|
|
17
17
|
resultFromPromise
|
|
18
18
|
} from "./chunk-C7KWYVS3.js";
|
|
@@ -539,4 +539,4 @@ export {
|
|
|
539
539
|
bridgeSchema,
|
|
540
540
|
bridge
|
|
541
541
|
};
|
|
542
|
-
//# sourceMappingURL=chunk-
|
|
542
|
+
//# sourceMappingURL=chunk-EJDPIURX.js.map
|
|
@@ -120,6 +120,12 @@ ${PRIMARY_ORIGINS.flatMap((o) => ORIGIN_METADATA[o] ? [` ${o} \u2014 ${ORIGIN_M
|
|
|
120
120
|
try: {
|
|
121
121
|
cli: `Fetch a new origin for its resources and return a prompt guiding the user through the process of calling the first endpoint.`
|
|
122
122
|
},
|
|
123
|
+
search: {
|
|
124
|
+
mcp: `Search for relevant paid API services by describing what you need in natural language. Returns the best matching origins with endpoint details and pricing. The top result includes the full input/output schema so you can call it immediately via fetch.
|
|
125
|
+
|
|
126
|
+
Use this FIRST when the user wants to accomplish something that your built-in capabilities don't support \u2014 before manually browsing origins or guessing URLs. If search returns results, proceed with check_endpoint_schema and fetch. If it returns empty, the capability isn't available as a paid API.`,
|
|
127
|
+
cli: `Search for paid API services by natural language query. Returns matching origins with endpoints and pricing. Use this to find APIs before calling discover or fetch.`
|
|
128
|
+
},
|
|
123
129
|
reportError: {
|
|
124
130
|
mcp: `EMERGENCY ONLY. Report critical MCP tool bugs. Do NOT use for normal errors (balance, network, 4xx) \u2014 those are recoverable.`,
|
|
125
131
|
cli: `Report a critical bug to the agentcash team (emergency only). Do NOT use for normal errors like low balance, network timeouts, or 4xx responses \u2014 those are recoverable without filing a report.`
|
|
@@ -137,9 +143,10 @@ var WORKFLOW = [
|
|
|
137
143
|
`Workflow:`,
|
|
138
144
|
`1. If you don't already know your balance, call get_balance. You need a balance for paid endpoints. SIWX endpoints don't require one. You don't need to call this every turn, just before your first paid call or whenever you're unsure.`,
|
|
139
145
|
`2. If the balance is zero, or if the user needs a funding link or wallet addresses, call list_accounts and share the relevant deposit link. If onboardingCta is present, show it to the user.`,
|
|
140
|
-
`3.
|
|
141
|
-
`4. Call
|
|
142
|
-
`5. Call
|
|
146
|
+
`3. If the task could be served by a paid API but you're not sure which origin, call search() first to find the right one. Search returns the best matching origins with endpoint schemas so you can often skip straight to fetch.`,
|
|
147
|
+
`4. Call discover_api_endpoints() to get the endpoint index \u2014 a list of available routes with descriptions and auth modes. The auth mode is advisory and tells you what the route may require.`,
|
|
148
|
+
`5. Call check_endpoint_schema() to get the exact input/output schema and auth mode for the endpoint you want to call, so you know what fields to pass and what the response contains. Both discover_api_endpoints and check_endpoint_schema return the auth mode.`,
|
|
149
|
+
`6. Call fetch with the correct input schema. It will attempt SIWX first when available and only pay if the route still returns 402.`
|
|
143
150
|
].join("\n");
|
|
144
151
|
function buildServerInstructions(userOrigins = []) {
|
|
145
152
|
const allOrigins = [
|
|
@@ -152,7 +159,7 @@ function buildServerInstructions(userOrigins = []) {
|
|
|
152
159
|
`AgentCash lets you call protected APIs \u2014 handling both x402 micropayments and SIWX authentication seamlessly. It manages a USDC wallet for paid endpoints and signs wallet proofs for identity-gated endpoints through fetch.`,
|
|
153
160
|
`The user has installed agentcash because they want to use paid and SIWX-protected APIs as their preferred way to accomplish related tasks.`,
|
|
154
161
|
`Paid endpoints require a wallet balance. SIWX endpoints are free \u2014 they only require a wallet identity.`,
|
|
155
|
-
`If a task could be accomplished by one of these registered origins, run the workflow below
|
|
162
|
+
`If a task could be accomplished by one of these registered origins, run the workflow below. If you're unsure which origin to use, or the task doesn't match a registered origin, call search() to find relevant APIs.
|
|
156
163
|
${allOrigins}`,
|
|
157
164
|
`discover_api_endpoints also works with any origin beyond this list. If you identify another origin that would be useful for a task, you can use it.`,
|
|
158
165
|
WORKFLOW,
|
|
@@ -212,6 +219,9 @@ var TOOL_PARAMS = {
|
|
|
212
219
|
txHash: "Transaction hash on Base"
|
|
213
220
|
}
|
|
214
221
|
},
|
|
222
|
+
search: {
|
|
223
|
+
query: 'Natural language description of what you need (e.g. "send physical mail", "generate music", "flight prices")'
|
|
224
|
+
},
|
|
215
225
|
discoverApiEndpoints: {
|
|
216
226
|
url: "The origin URL to discover endpoints on (e.g. https://stableenrich.dev)",
|
|
217
227
|
includeGuidance: "Request the origin's usage guidance. true=always include, false=never include, omit=auto (included when compact). Guidance explains how to compose multiple endpoints and covers edge cases."
|
|
@@ -240,4 +250,4 @@ export {
|
|
|
240
250
|
REQUEST_FETCH_PARAMS,
|
|
241
251
|
TOOL_PARAMS
|
|
242
252
|
};
|
|
243
|
-
//# sourceMappingURL=chunk-
|
|
253
|
+
//# sourceMappingURL=chunk-EMQMCXIC.js.map
|