@agent-score/commerce 1.0.3 → 1.2.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 +28 -1
- package/dist/agent_instructions-d3UWTdam.d.mts +129 -0
- package/dist/agent_instructions-d3UWTdam.d.ts +129 -0
- package/dist/challenge/index.d.mts +3 -110
- package/dist/challenge/index.d.ts +3 -110
- package/dist/challenge/index.js +76 -5
- package/dist/challenge/index.js.map +1 -1
- package/dist/challenge/index.mjs +82 -5
- package/dist/challenge/index.mjs.map +1 -1
- package/dist/core.d.mts +28 -1
- package/dist/core.d.ts +28 -1
- package/dist/core.js +237 -157
- package/dist/core.js.map +1 -1
- package/dist/core.mjs +246 -157
- package/dist/core.mjs.map +1 -1
- package/dist/discovery/index.d.mts +120 -1
- package/dist/discovery/index.d.ts +120 -1
- package/dist/discovery/index.js +204 -0
- package/dist/discovery/index.js.map +1 -1
- package/dist/discovery/index.mjs +202 -0
- package/dist/discovery/index.mjs.map +1 -1
- package/dist/identity/express.d.mts +18 -2
- package/dist/identity/express.d.ts +18 -2
- package/dist/identity/express.js +227 -164
- package/dist/identity/express.js.map +1 -1
- package/dist/identity/express.mjs +232 -164
- package/dist/identity/express.mjs.map +1 -1
- package/dist/identity/fastify.d.mts +17 -2
- package/dist/identity/fastify.d.ts +17 -2
- package/dist/identity/fastify.js +227 -164
- package/dist/identity/fastify.js.map +1 -1
- package/dist/identity/fastify.mjs +232 -164
- package/dist/identity/fastify.mjs.map +1 -1
- package/dist/identity/hono.d.mts +22 -2
- package/dist/identity/hono.d.ts +22 -2
- package/dist/identity/hono.js +227 -164
- package/dist/identity/hono.js.map +1 -1
- package/dist/identity/hono.mjs +232 -164
- package/dist/identity/hono.mjs.map +1 -1
- package/dist/identity/nextjs.d.mts +8 -1
- package/dist/identity/nextjs.d.ts +8 -1
- package/dist/identity/nextjs.js +213 -166
- package/dist/identity/nextjs.js.map +1 -1
- package/dist/identity/nextjs.mjs +220 -166
- package/dist/identity/nextjs.mjs.map +1 -1
- package/dist/identity/web.d.mts +15 -1
- package/dist/identity/web.d.ts +15 -1
- package/dist/identity/web.js +213 -166
- package/dist/identity/web.js.map +1 -1
- package/dist/identity/web.mjs +220 -166
- package/dist/identity/web.mjs.map +1 -1
- package/dist/index.js +120 -101
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +127 -101
- package/dist/index.mjs.map +1 -1
- package/dist/payment/index.js.map +1 -1
- package/dist/payment/index.mjs.map +1 -1
- package/dist/stripe-multichain/index.js.map +1 -1
- package/dist/stripe-multichain/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/challenge/index.js
CHANGED
|
@@ -28,6 +28,7 @@ __export(challenge_exports, {
|
|
|
28
28
|
buildIdentityMetadata: () => buildIdentityMetadata,
|
|
29
29
|
buildPricingBlock: () => buildPricingBlock,
|
|
30
30
|
buildValidationError: () => buildValidationError,
|
|
31
|
+
compatibleClientsByRails: () => compatibleClientsByRails,
|
|
31
32
|
firstEncounterAgentMemory: () => firstEncounterAgentMemory,
|
|
32
33
|
respond402: () => respond402
|
|
33
34
|
});
|
|
@@ -193,14 +194,25 @@ function defaultWarnings(howToPay) {
|
|
|
193
194
|
if (howToPay.x402_base || howToPay.x402_solana) w.push(X402_WARNING);
|
|
194
195
|
return w;
|
|
195
196
|
}
|
|
196
|
-
|
|
197
|
+
var RAIL_CLIENTS = {
|
|
198
|
+
tempo_mpp: ["agentscore-pay", "tempo request", "x402-proxy"],
|
|
199
|
+
x402_base: ["agentscore-pay", "x402-proxy", "purl (omit --network flag)"],
|
|
200
|
+
x402_solana: ["agentscore-pay"],
|
|
201
|
+
stripe: ["link-cli"]
|
|
202
|
+
};
|
|
203
|
+
function compatibleClientsByRails(rails) {
|
|
197
204
|
const out = {};
|
|
198
|
-
|
|
199
|
-
if (howToPay.x402_base) out.x402_base = ["agentscore-pay", "x402-proxy", "purl (omit --network flag)"];
|
|
200
|
-
if (howToPay.x402_solana) out.x402_solana = ["agentscore-pay"];
|
|
201
|
-
if (howToPay.stripe) out.stripe = ["link-cli"];
|
|
205
|
+
for (const r of rails) out[r] = [...RAIL_CLIENTS[r]];
|
|
202
206
|
return Object.keys(out).length === 0 ? void 0 : out;
|
|
203
207
|
}
|
|
208
|
+
function defaultCompatibleClients(howToPay) {
|
|
209
|
+
const rails = [];
|
|
210
|
+
if (howToPay.tempo) rails.push("tempo_mpp");
|
|
211
|
+
if (howToPay.x402_base) rails.push("x402_base");
|
|
212
|
+
if (howToPay.x402_solana) rails.push("x402_solana");
|
|
213
|
+
if (howToPay.stripe) rails.push("stripe");
|
|
214
|
+
return compatibleClientsByRails(rails);
|
|
215
|
+
}
|
|
204
216
|
function buildAgentInstructions(input) {
|
|
205
217
|
const compatibleClients = input.compatibleClients ?? defaultCompatibleClients(input.howToPay);
|
|
206
218
|
return {
|
|
@@ -215,6 +227,64 @@ function buildAgentInstructions(input) {
|
|
|
215
227
|
};
|
|
216
228
|
}
|
|
217
229
|
|
|
230
|
+
// src/core.ts
|
|
231
|
+
var import_sdk = require("@agent-score/sdk");
|
|
232
|
+
|
|
233
|
+
// src/_response.ts
|
|
234
|
+
var WALLET_NOT_TRUSTED_INSTRUCTIONS = JSON.stringify({
|
|
235
|
+
action: "contact_support",
|
|
236
|
+
steps: [
|
|
237
|
+
"The wallet's operator failed an UNFIXABLE compliance check (sanctions, age, or jurisdiction). `reasons` lists which: `sanctions_flagged` / `age_insufficient` / `jurisdiction_restricted`. KYC re-verification won't change the outcome \u2014 the policy denial is structural.",
|
|
238
|
+
"Surface the denial to the user with the merchant's support contact. Do not retry the same merchant request; do not hand the user a verify_url (verification won't fix this code path).",
|
|
239
|
+
"Fixable compliance reasons (`kyc_required`, `kyc_pending`, `kyc_failed`) do NOT land on this code \u2014 the gate auto-mints a verification session for those and returns `identity_verification_required` with poll endpoints, same shape as `missing_identity`. `jurisdiction_restricted` IS in the unfixable bucket because the API only emits it after KYC is verified (the user's KYC'd country is in the blocked list \u2014 re-doing KYC won't change the country)."
|
|
240
|
+
],
|
|
241
|
+
user_message: "This purchase is denied by the merchant's compliance policy and cannot be resolved by re-verifying. Contact the merchant's support if you believe this is in error."
|
|
242
|
+
});
|
|
243
|
+
var PAYMENT_REQUIRED_INSTRUCTIONS = JSON.stringify({
|
|
244
|
+
action: "contact_merchant",
|
|
245
|
+
steps: [
|
|
246
|
+
"The merchant's AgentScore account does not have the assess endpoint enabled, so agent identity cannot be evaluated. This is a merchant-side configuration gap \u2014 there is no agent-side recovery.",
|
|
247
|
+
"Contact the merchant (their support channel \u2014 typically listed in /llms.txt or the OpenAPI servers metadata) so they can resolve the configuration on their side."
|
|
248
|
+
],
|
|
249
|
+
user_message: "This merchant's identity gate is misconfigured. Contact the merchant \u2014 there's nothing to fix on the agent side."
|
|
250
|
+
});
|
|
251
|
+
var IDENTITY_VERIFICATION_REQUIRED_FALLBACK_INSTRUCTIONS = JSON.stringify({
|
|
252
|
+
action: "deliver_verify_url_and_poll",
|
|
253
|
+
steps: [
|
|
254
|
+
"Share verify_url with the user \u2014 they complete identity verification on AgentScore.",
|
|
255
|
+
"If session_id + poll_secret are present in the body, poll poll_url every 5 seconds with header `X-Poll-Secret: <poll_secret>` until status=verified. The poll returns a one-time operator_token.",
|
|
256
|
+
"Retry the original request with header `X-Operator-Token: <opc_...>`."
|
|
257
|
+
],
|
|
258
|
+
user_message: "Identity verification is required. Visit verify_url, then poll poll_url for the operator token and retry."
|
|
259
|
+
});
|
|
260
|
+
var API_ERROR_INSTRUCTIONS = JSON.stringify({
|
|
261
|
+
action: "retry_with_backoff",
|
|
262
|
+
steps: [
|
|
263
|
+
"Verification is temporarily unavailable. Retry the request after 5\u201330 seconds with exponential backoff.",
|
|
264
|
+
"This is NOT a compliance denial \u2014 the user does not need to re-verify their identity. Send the same identity headers (X-Wallet-Address or X-Operator-Token) on retry.",
|
|
265
|
+
"If the request continues to fail after 3+ retries (~60 seconds total), surface the error to the user with the merchant's support contact."
|
|
266
|
+
],
|
|
267
|
+
user_message: "Verification is temporarily unavailable. Please try again in a moment \u2014 this is a transient issue, not a problem with your account."
|
|
268
|
+
});
|
|
269
|
+
var QUOTA_EXCEEDED_INSTRUCTIONS = JSON.stringify({
|
|
270
|
+
action: "contact_merchant",
|
|
271
|
+
steps: [
|
|
272
|
+
"AgentScore identity verification is unavailable for this merchant. This is a merchant-side issue and is NOT recoverable via retry.",
|
|
273
|
+
"Do not retry: the same 503 will be returned until the merchant resolves the issue on their side.",
|
|
274
|
+
"Surface to the user with the merchant's support contact. The merchant (not the agent) needs to act."
|
|
275
|
+
],
|
|
276
|
+
user_message: "This merchant's identity verification is temporarily unavailable. Try again later, or contact the merchant directly."
|
|
277
|
+
});
|
|
278
|
+
var TOKEN_EXPIRED_FALLBACK_INSTRUCTIONS = JSON.stringify({
|
|
279
|
+
action: "deliver_verify_url_and_poll",
|
|
280
|
+
steps: [
|
|
281
|
+
"The operator token is expired or revoked. AgentScore auto-mints a fresh verification session \u2014 complete it to receive a new opc_...",
|
|
282
|
+
"Share verify_url with the user, then poll poll_url every 5 seconds with header `X-Poll-Secret: <poll_secret>` until status=verified. The poll returns a fresh one-time operator_token.",
|
|
283
|
+
"Retry the original request with header `X-Operator-Token: <new_opc_...>`."
|
|
284
|
+
],
|
|
285
|
+
user_message: "Operator token is expired or revoked. A new verification session has been minted \u2014 visit verify_url to refresh."
|
|
286
|
+
});
|
|
287
|
+
|
|
218
288
|
// src/core.ts
|
|
219
289
|
var CANONICAL_AGENTSCORE_API = "https://api.agentscore.sh";
|
|
220
290
|
var WALLET_SIGNER_MISMATCH_INSTRUCTIONS = JSON.stringify({
|
|
@@ -348,6 +418,7 @@ function buildValidationError(input) {
|
|
|
348
418
|
buildIdentityMetadata,
|
|
349
419
|
buildPricingBlock,
|
|
350
420
|
buildValidationError,
|
|
421
|
+
compatibleClientsByRails,
|
|
351
422
|
firstEncounterAgentMemory,
|
|
352
423
|
respond402
|
|
353
424
|
});
|