tenjin-cli 0.1.0-alpha.16 → 0.1.0-alpha.18

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.
Files changed (116) hide show
  1. package/README.md +5 -0
  2. package/dist/chunk-2G2WLVHB.js +102 -0
  3. package/dist/chunk-2G2WLVHB.js.map +1 -0
  4. package/dist/chunk-2I4QTOLB.js +11 -0
  5. package/dist/chunk-2I4QTOLB.js.map +1 -0
  6. package/dist/chunk-35M3VITA.js +102 -0
  7. package/dist/chunk-35M3VITA.js.map +1 -0
  8. package/dist/chunk-3KKKB2AQ.js +40 -0
  9. package/dist/chunk-3KKKB2AQ.js.map +1 -0
  10. package/dist/{chunk-OIM4HLN6.js → chunk-7QKHZQKW.js} +295 -20
  11. package/dist/chunk-7QKHZQKW.js.map +1 -0
  12. package/dist/{chunk-BBVUVBUO.js → chunk-AR7U7BRG.js} +44 -7
  13. package/dist/{chunk-BBVUVBUO.js.map → chunk-AR7U7BRG.js.map} +1 -1
  14. package/dist/{chunk-DMZZLPZN.js → chunk-AUKDYPPX.js} +14 -89
  15. package/dist/chunk-AUKDYPPX.js.map +1 -0
  16. package/dist/{chunk-56MOAIP5.js → chunk-BTX2QE2Y.js} +9 -6
  17. package/dist/chunk-BTX2QE2Y.js.map +1 -0
  18. package/dist/{chunk-HVRC33OL.js → chunk-EPCOMXLF.js} +4 -6
  19. package/dist/{chunk-HVRC33OL.js.map → chunk-EPCOMXLF.js.map} +1 -1
  20. package/dist/{chunk-25TJPVBF.js → chunk-F3FUGWPZ.js} +28 -15
  21. package/dist/chunk-F3FUGWPZ.js.map +1 -0
  22. package/dist/{chunk-2U5ZVEV3.js → chunk-FGR734LZ.js} +6 -6
  23. package/dist/{chunk-PZEN5PHN.js → chunk-J5INH7WB.js} +17 -3
  24. package/dist/chunk-J5INH7WB.js.map +1 -0
  25. package/dist/{chunk-7WEQQJLG.js → chunk-JLEF5WHM.js} +66 -2
  26. package/dist/chunk-JLEF5WHM.js.map +1 -0
  27. package/dist/{chunk-YEETV6IW.js → chunk-KUBEYXSO.js} +10 -12
  28. package/dist/{chunk-YEETV6IW.js.map → chunk-KUBEYXSO.js.map} +1 -1
  29. package/dist/{chunk-L3PVMIYQ.js → chunk-N44H5TFB.js} +82 -150
  30. package/dist/chunk-N44H5TFB.js.map +1 -0
  31. package/dist/{chunk-BFFM2WFK.js → chunk-NRQMOVKM.js} +2 -2
  32. package/dist/{chunk-BFFM2WFK.js.map → chunk-NRQMOVKM.js.map} +1 -1
  33. package/dist/{chunk-GULLJQXA.js → chunk-ON6C6WOX.js} +127 -17
  34. package/dist/chunk-ON6C6WOX.js.map +1 -0
  35. package/dist/{chunk-OJLYNM4Z.js → chunk-PDA2BVFY.js} +77 -19
  36. package/dist/chunk-PDA2BVFY.js.map +1 -0
  37. package/dist/chunk-S2NRVRPF.js +171 -0
  38. package/dist/chunk-S2NRVRPF.js.map +1 -0
  39. package/dist/chunk-TGLKKLQG.js +11 -0
  40. package/dist/chunk-TGLKKLQG.js.map +1 -0
  41. package/dist/{chunk-SKAHDQH7.js → chunk-TJMCBIZU.js} +6 -7
  42. package/dist/{chunk-SKAHDQH7.js.map → chunk-TJMCBIZU.js.map} +1 -1
  43. package/dist/chunk-TP4D47BY.js +127 -0
  44. package/dist/chunk-TP4D47BY.js.map +1 -0
  45. package/dist/{chunk-WH7OWT6G.js → chunk-U2DZISAH.js} +2 -8
  46. package/dist/chunk-U2DZISAH.js.map +1 -0
  47. package/dist/{chunk-YJHHCWM3.js → chunk-WLMJE3GJ.js} +3 -3
  48. package/dist/{chunk-U5DXNFJC.js → chunk-WS4JA6TC.js} +3 -3
  49. package/dist/{chunk-5X4SZ5BF.js → chunk-WUHY2AXD.js} +4 -4
  50. package/dist/{chunk-USS336NF.js → chunk-YPQSMIDH.js} +5 -5
  51. package/dist/chunk-YPQSMIDH.js.map +1 -0
  52. package/dist/{chunk-3AJS6LLN.js → chunk-ZG7SFI34.js} +7 -7
  53. package/dist/{cli-M3XCSOU6.js → cli-MP3RAYHL.js} +43 -29
  54. package/dist/{cli-M3XCSOU6.js.map → cli-MP3RAYHL.js.map} +1 -1
  55. package/dist/{config-MXOX7XDR.js → config-BJK6U5VY.js} +11 -10
  56. package/dist/{doctor-LU4YIZWM.js → doctor-KJROWE5V.js} +108 -21
  57. package/dist/doctor-KJROWE5V.js.map +1 -0
  58. package/dist/{fund-A54P2QFK.js → fund-I5COXPEJ.js} +13 -11
  59. package/dist/{fund-A54P2QFK.js.map → fund-I5COXPEJ.js.map} +1 -1
  60. package/dist/hook-command-EJO2564A.js +821 -0
  61. package/dist/hook-command-EJO2564A.js.map +1 -0
  62. package/dist/index.js +2 -2
  63. package/dist/{install-XUM2XSHW.js → install-NUQLLHS2.js} +21 -14
  64. package/dist/{install-wallet-QIOFORTX.js → install-wallet-JPFTEC6H.js} +12 -10
  65. package/dist/{install-wallet-QIOFORTX.js.map → install-wallet-JPFTEC6H.js.map} +1 -1
  66. package/dist/{mcp-HJC2PLRV.js → mcp-I5XMVE64.js} +77 -34
  67. package/dist/{mcp-HJC2PLRV.js.map → mcp-I5XMVE64.js.map} +1 -1
  68. package/dist/{pay-SBXZEPEP.js → pay-WA3JSCNB.js} +21 -14
  69. package/dist/{redact-46ZHF2NH.js → redact-6W23GGJC.js} +4 -6
  70. package/dist/{send-ASD2ZXJD.js → send-KVUH5WDO.js} +12 -10
  71. package/dist/{send-ASD2ZXJD.js.map → send-KVUH5WDO.js.map} +1 -1
  72. package/dist/{skill-placement-NFVHY6A3.js → skill-placement-JMDPSKE6.js} +12 -13
  73. package/dist/{skill-placement-NFVHY6A3.js.map → skill-placement-JMDPSKE6.js.map} +1 -1
  74. package/dist/{status-T2SDB57A.js → status-FFC6FO72.js} +8 -7
  75. package/dist/{status-T2SDB57A.js.map → status-FFC6FO72.js.map} +1 -1
  76. package/dist/{status-line-CGPUSDMC.js → status-line-SAXSU6CR.js} +19 -3
  77. package/dist/status-line-SAXSU6CR.js.map +1 -0
  78. package/dist/{status-line-wiring-BYPHTYZE.js → status-line-wiring-DQZCWIUO.js} +5 -6
  79. package/dist/tenjin-daemon.mjs +384 -23
  80. package/dist/{uninstall-FKYZHAM3.js → uninstall-SWICHBTF.js} +41 -18
  81. package/dist/uninstall-SWICHBTF.js.map +1 -0
  82. package/dist/{update-ANJ2AOTN.js → update-W572AMXG.js} +6 -7
  83. package/dist/{update-ANJ2AOTN.js.map → update-W572AMXG.js.map} +1 -1
  84. package/dist/{wallet-PWAHVKWW.js → wallet-L2YLAJFN.js} +12 -10
  85. package/docs/agent-permissions.md +17 -9
  86. package/docs/safety-model.md +1 -1
  87. package/package.json +1 -1
  88. package/dist/chunk-25TJPVBF.js.map +0 -1
  89. package/dist/chunk-56MOAIP5.js.map +0 -1
  90. package/dist/chunk-7WEQQJLG.js.map +0 -1
  91. package/dist/chunk-DMZZLPZN.js.map +0 -1
  92. package/dist/chunk-GULLJQXA.js.map +0 -1
  93. package/dist/chunk-L3PVMIYQ.js.map +0 -1
  94. package/dist/chunk-OCBHUHWB.js +0 -69
  95. package/dist/chunk-OCBHUHWB.js.map +0 -1
  96. package/dist/chunk-OIM4HLN6.js.map +0 -1
  97. package/dist/chunk-OJLYNM4Z.js.map +0 -1
  98. package/dist/chunk-PZEN5PHN.js.map +0 -1
  99. package/dist/chunk-USS336NF.js.map +0 -1
  100. package/dist/chunk-WH7OWT6G.js.map +0 -1
  101. package/dist/doctor-LU4YIZWM.js.map +0 -1
  102. package/dist/hook-command-U6KWPEDQ.js +0 -377
  103. package/dist/hook-command-U6KWPEDQ.js.map +0 -1
  104. package/dist/status-line-CGPUSDMC.js.map +0 -1
  105. package/dist/uninstall-FKYZHAM3.js.map +0 -1
  106. /package/dist/{chunk-2U5ZVEV3.js.map → chunk-FGR734LZ.js.map} +0 -0
  107. /package/dist/{chunk-YJHHCWM3.js.map → chunk-WLMJE3GJ.js.map} +0 -0
  108. /package/dist/{chunk-U5DXNFJC.js.map → chunk-WS4JA6TC.js.map} +0 -0
  109. /package/dist/{chunk-5X4SZ5BF.js.map → chunk-WUHY2AXD.js.map} +0 -0
  110. /package/dist/{chunk-3AJS6LLN.js.map → chunk-ZG7SFI34.js.map} +0 -0
  111. /package/dist/{config-MXOX7XDR.js.map → config-BJK6U5VY.js.map} +0 -0
  112. /package/dist/{install-XUM2XSHW.js.map → install-NUQLLHS2.js.map} +0 -0
  113. /package/dist/{pay-SBXZEPEP.js.map → pay-WA3JSCNB.js.map} +0 -0
  114. /package/dist/{redact-46ZHF2NH.js.map → redact-6W23GGJC.js.map} +0 -0
  115. /package/dist/{status-line-wiring-BYPHTYZE.js.map → status-line-wiring-DQZCWIUO.js.map} +0 -0
  116. /package/dist/{wallet-PWAHVKWW.js.map → wallet-L2YLAJFN.js.map} +0 -0
@@ -1,4 +1,7 @@
1
1
  import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
2
+ import {
3
+ assertPublicDestination
4
+ } from "./chunk-2G2WLVHB.js";
2
5
  import {
3
6
  HTTPFacilitatorClient,
4
7
  SIGN_IN_WITH_X,
@@ -16,7 +19,7 @@ import {
16
19
  import {
17
20
  fetchFailureToCliError,
18
21
  httpRequest
19
- } from "./chunk-5X4SZ5BF.js";
22
+ } from "./chunk-WUHY2AXD.js";
20
23
  import {
21
24
  encodeFunctionData,
22
25
  getAddress as getAddress2,
@@ -30,34 +33,34 @@ import {
30
33
  } from "./chunk-LHHMV4GU.js";
31
34
  import {
32
35
  USDC_ADDRESS
33
- } from "./chunk-56MOAIP5.js";
36
+ } from "./chunk-BTX2QE2Y.js";
34
37
  import {
35
38
  describeWallet,
36
39
  resolveSpendAuthorizer,
37
40
  resolveWalletProvider
38
- } from "./chunk-YEETV6IW.js";
41
+ } from "./chunk-KUBEYXSO.js";
39
42
  import {
40
43
  getAddress
41
44
  } from "./chunk-EGELTSPU.js";
42
45
  import {
43
46
  mask
44
- } from "./chunk-OIM4HLN6.js";
47
+ } from "./chunk-7QKHZQKW.js";
45
48
  import {
46
49
  sanitizeForTerminal
47
- } from "./chunk-YJHHCWM3.js";
50
+ } from "./chunk-WLMJE3GJ.js";
48
51
  import {
49
52
  resolveContextSettings
50
- } from "./chunk-OJLYNM4Z.js";
53
+ } from "./chunk-PDA2BVFY.js";
51
54
  import {
52
55
  parseUsdToAtomic,
53
56
  toMoney
54
- } from "./chunk-WH7OWT6G.js";
57
+ } from "./chunk-U2DZISAH.js";
55
58
  import {
56
59
  isSameDeployment
57
- } from "./chunk-BBVUVBUO.js";
60
+ } from "./chunk-AR7U7BRG.js";
58
61
  import {
59
62
  CliError
60
- } from "./chunk-OCBHUHWB.js";
63
+ } from "./chunk-JLEF5WHM.js";
61
64
  import {
62
65
  __commonJS,
63
66
  __toESM
@@ -3369,8 +3372,8 @@ var require_utils = __commonJS({
3369
3372
  var HOST_DELIMS = { "@": "%40", "/": "%2F", "?": "%3F", "#": "%23", ":": "%3A" };
3370
3373
  var HOST_DELIM_RE = /[@/?#:]/g;
3371
3374
  var HOST_DELIM_NO_COLON_RE = /[@/?#]/g;
3372
- function reescapeHostDelimiters(host, isIP2) {
3373
- const re = isIP2 ? HOST_DELIM_NO_COLON_RE : HOST_DELIM_RE;
3375
+ function reescapeHostDelimiters(host, isIP) {
3376
+ const re = isIP ? HOST_DELIM_NO_COLON_RE : HOST_DELIM_RE;
3374
3377
  re.lastIndex = 0;
3375
3378
  return host.replace(re, (ch) => HOST_DELIMS[ch]);
3376
3379
  }
@@ -4052,8 +4055,8 @@ var require_fast_uri = __commonJS({
4052
4055
  const host = matches[4];
4053
4056
  return hasMalformedPercentEncoding(matches[3]) || host !== void 0 && !(host[0] === "[" && host[host.length - 1] === "]") && hasMalformedPercentEncoding(host) || hasMalformedPercentEncoding(matches[6]) || hasMalformedPercentEncoding(matches[7]) || hasMalformedPercentEncoding(matches[8]);
4054
4057
  }
4055
- function canonicalizeHost(parsed, options, schemeHandler, isIP2) {
4056
- if (!options.unicodeSupport && (!schemeHandler || !schemeHandler.unicodeSupport) && parsed.host && parsed.host[0] !== "[" && (options.domainHost || schemeHandler && schemeHandler.domainHost) && isIP2 === false && nonSimpleDomain(parsed.host)) {
4058
+ function canonicalizeHost(parsed, options, schemeHandler, isIP) {
4059
+ if (!options.unicodeSupport && (!schemeHandler || !schemeHandler.unicodeSupport) && parsed.host && parsed.host[0] !== "[" && (options.domainHost || schemeHandler && schemeHandler.domainHost) && isIP === false && nonSimpleDomain(parsed.host)) {
4057
4060
  try {
4058
4061
  parsed.host = new URL("http://" + parsed.host).hostname;
4059
4062
  } catch (e) {
@@ -4080,7 +4083,7 @@ var require_fast_uri = __commonJS({
4080
4083
  let malformedHost = false;
4081
4084
  let malformedIPLiteral = false;
4082
4085
  let malformedScheme = false;
4083
- let isIP2 = false;
4086
+ let isIP = false;
4084
4087
  if (options.reference === "suffix") {
4085
4088
  if (options.scheme) {
4086
4089
  uri = options.scheme + ":" + uri;
@@ -4142,15 +4145,15 @@ var require_fast_uri = __commonJS({
4142
4145
  if (ipv4result === false) {
4143
4146
  const bracketedIPLiteral = parsed.host[0] === "[" && parsed.host[parsed.host.length - 1] === "]";
4144
4147
  const ipv6result = normalizeIPv6(parsed.host);
4145
- isIP2 = ipv6result.isIPV6 || ipv6result.isIPVFuture === true;
4148
+ isIP = ipv6result.isIPV6 || ipv6result.isIPVFuture === true;
4146
4149
  malformedIPLiteral = bracketedIPLiteral && ipv6result.error === true;
4147
- parsed.host = isIP2 ? ipv6result.host : ipv6result.host.toLowerCase();
4150
+ parsed.host = isIP ? ipv6result.host : ipv6result.host.toLowerCase();
4148
4151
  if (malformedIPLiteral) {
4149
4152
  parsed.error = parsed.error || "URI host is malformed.";
4150
4153
  malformedAuthorityOrPort = true;
4151
4154
  }
4152
4155
  } else {
4153
- isIP2 = true;
4156
+ isIP = true;
4154
4157
  }
4155
4158
  }
4156
4159
  if (parsed.scheme === void 0 && parsed.userinfo === void 0 && parsed.host === void 0 && parsed.port === void 0 && parsed.query === void 0 && !parsed.path) {
@@ -4166,12 +4169,12 @@ var require_fast_uri = __commonJS({
4166
4169
  parsed.error = parsed.error || "URI is not a " + options.reference + " reference.";
4167
4170
  }
4168
4171
  const schemeHandler = getSchemeHandler(options.scheme || parsed.scheme);
4169
- malformedHost = canonicalizeHost(parsed, options, schemeHandler, isIP2);
4172
+ malformedHost = canonicalizeHost(parsed, options, schemeHandler, isIP);
4170
4173
  if (!schemeHandler || schemeHandler && !schemeHandler.skipNormalize) {
4171
4174
  if (uri.indexOf("%") !== -1) {
4172
4175
  if (parsed.host !== void 0 && !malformedIPLiteral) {
4173
- const host = isIP2 ? parsed.host : normalizePercentEncoding(parsed.host, true);
4174
- parsed.host = reescapeHostDelimiters(host, isIP2);
4176
+ const host = isIP ? parsed.host : normalizePercentEncoding(parsed.host, true);
4177
+ parsed.host = reescapeHostDelimiters(host, isIP);
4175
4178
  }
4176
4179
  }
4177
4180
  if (parsed.path) {
@@ -8275,6 +8278,7 @@ function withBazaar(client2) {
8275
8278
 
8276
8279
  // src/lib/bazaar.ts
8277
8280
  var PAGE_LIMIT = 100;
8281
+ var SEARCH_LIMIT = 20;
8278
8282
  function client(registry) {
8279
8283
  return withBazaar(new HTTPFacilitatorClient({ url: registry }));
8280
8284
  }
@@ -8322,17 +8326,36 @@ async function storedListingsFor(dataDir, url, now) {
8322
8326
  });
8323
8327
  }
8324
8328
  function sameResourceUrl(listed, requested) {
8325
- const identity = (u) => {
8326
- try {
8327
- const parsed = new URL(u);
8328
- const path = parsed.pathname.endsWith("/") ? parsed.pathname.slice(0, -1) : parsed.pathname;
8329
- return `${parsed.origin}${path}`;
8330
- } catch {
8331
- return null;
8332
- }
8333
- };
8334
- const a = identity(listed);
8335
- return a !== null && a === identity(requested);
8329
+ const a = resourceIdentity(listed);
8330
+ return a !== null && a === resourceIdentity(requested);
8331
+ }
8332
+ function resourceIdentity(u) {
8333
+ try {
8334
+ const parsed = new URL(u);
8335
+ const path = parsed.pathname.endsWith("/") ? parsed.pathname.slice(0, -1) : parsed.pathname;
8336
+ return `${parsed.origin}${path}`;
8337
+ } catch {
8338
+ return null;
8339
+ }
8340
+ }
8341
+ async function listingsFor(registry, url, payTo, timeoutMs) {
8342
+ const params = new URLSearchParams({
8343
+ payTo,
8344
+ urlSubstring: resourceIdentity(url) ?? url,
8345
+ limit: String(SEARCH_LIMIT)
8346
+ });
8347
+ const res = await fetch(`${registry.replace(/\/+$/, "")}/discovery/search?${params.toString()}`, {
8348
+ headers: { accept: "application/json" },
8349
+ signal: AbortSignal.timeout(timeoutMs)
8350
+ });
8351
+ if (res.ok) {
8352
+ const found = (await res.json())?.resources;
8353
+ if (Array.isArray(found)) return found;
8354
+ } else if (res.status !== 400 && res.status !== 404) {
8355
+ throw new Error(`search on ${registry} answered ${res.status}`);
8356
+ }
8357
+ const bazaar = client(registry).extensions.bazaar;
8358
+ return (await bazaar.listResources({ type: "http", payTo, limit: PAGE_LIMIT })).items;
8336
8359
  }
8337
8360
  async function verifyAgainstRegistries(registries, url, live, timeoutMs, opts = {}) {
8338
8361
  const errors = [];
@@ -8347,13 +8370,12 @@ async function verifyAgainstRegistries(registries, url, live, timeoutMs, opts =
8347
8370
  }
8348
8371
  for (const registry of registries) {
8349
8372
  try {
8350
- const bazaar = client(registry).extensions.bazaar;
8351
8373
  const listed = await withTimeout(
8352
- bazaar.listResources({ type: "http", payTo: live.payTo, limit: PAGE_LIMIT }),
8374
+ listingsFor(registry, url, live.payTo, timeoutMs),
8353
8375
  timeoutMs,
8354
- `listing ${registry}`
8376
+ `looking up this resource on ${registry}`
8355
8377
  );
8356
- const matches = listed.items.filter(
8378
+ const matches = listed.filter(
8357
8379
  (item) => item.type === "http" && sameResourceUrl(item.resource, url)
8358
8380
  );
8359
8381
  if (matches.length === 0) continue;
@@ -8416,98 +8438,6 @@ function sameAddress(a, b) {
8416
8438
  }
8417
8439
  }
8418
8440
 
8419
- // src/lib/destination.ts
8420
- import { lookup } from "node:dns/promises";
8421
- import { BlockList, isIP } from "node:net";
8422
- var blockedV4 = new BlockList();
8423
- for (const [base, prefix] of [
8424
- ["0.0.0.0", 8],
8425
- ["10.0.0.0", 8],
8426
- ["100.64.0.0", 10],
8427
- ["127.0.0.0", 8],
8428
- ["169.254.0.0", 16],
8429
- ["172.16.0.0", 12],
8430
- ["192.0.0.0", 24],
8431
- ["192.0.2.0", 24],
8432
- ["192.168.0.0", 16],
8433
- ["198.18.0.0", 15],
8434
- ["198.51.100.0", 24],
8435
- ["203.0.113.0", 24],
8436
- ["224.0.0.0", 4],
8437
- ["240.0.0.0", 4]
8438
- ]) {
8439
- blockedV4.addSubnet(base, prefix, "ipv4");
8440
- }
8441
- var blockedV6 = new BlockList();
8442
- for (const [base, prefix] of [
8443
- ["::", 128],
8444
- ["::1", 128],
8445
- ["64:ff9b::", 96],
8446
- ["100::", 64],
8447
- ["2001:db8::", 32],
8448
- ["fc00::", 7],
8449
- ["fe80::", 10],
8450
- ["ff00::", 8]
8451
- ]) {
8452
- blockedV6.addSubnet(base, prefix, "ipv6");
8453
- }
8454
- function isPublicAddress(value) {
8455
- const kind = isIP(value);
8456
- if (kind === 4) return !blockedV4.check(value, "ipv4");
8457
- return kind === 6 && /^[23]/i.test(value) && !blockedV6.check(value, "ipv6");
8458
- }
8459
- var LOCAL_SUFFIX = /(?:^|\.)(?:localhost|local|internal|home|lan)$/i;
8460
- function refuse(message, details) {
8461
- throw new CliError("USAGE", message, {
8462
- fix: "Paid requests go to public HTTPS endpoints only; nothing was signed.",
8463
- ...details !== void 0 ? { details } : {}
8464
- });
8465
- }
8466
- function assertPublicHttpsUrl(raw) {
8467
- let url;
8468
- try {
8469
- url = new URL(raw);
8470
- } catch {
8471
- return refuse(`Invalid URL: ${JSON.stringify(raw.slice(0, 200))}`);
8472
- }
8473
- if (url.protocol !== "https:" || url.username !== "" || url.password !== "" || url.hash !== "" || url.port !== "" && url.port !== "443" || raw.length > 16384) {
8474
- refuse("Only public HTTPS endpoints without credentials, fragments or custom ports are paid.");
8475
- }
8476
- const host = url.hostname.replace(/^\[|\]$/g, "");
8477
- if (!host.includes(".") && isIP(host) === 0) refuse("The endpoint host is not a public name.");
8478
- if (LOCAL_SUFFIX.test(host)) refuse("Private or local destinations are not paid.");
8479
- if (isIP(host) !== 0 && !isPublicAddress(host)) {
8480
- refuse("Private or reserved IP destinations are not paid.");
8481
- }
8482
- return url;
8483
- }
8484
- async function assertPublicDestination(raw, options = {}) {
8485
- const url = assertPublicHttpsUrl(raw);
8486
- const host = url.hostname.replace(/^\[|\]$/g, "");
8487
- if (isIP(host) !== 0) return url;
8488
- const resolve = options.resolveHostname ?? ((name) => lookup(name, { all: true }));
8489
- const signal = AbortSignal.timeout(options.timeoutMs ?? 5e3);
8490
- let addresses;
8491
- try {
8492
- addresses = await Promise.race([
8493
- resolve(host),
8494
- new Promise((_, reject) => {
8495
- signal.addEventListener("abort", () => reject(new Error("DNS lookup timed out.")), {
8496
- once: true
8497
- });
8498
- })
8499
- ]);
8500
- } catch (err) {
8501
- return refuse(`The endpoint host ${host} could not be resolved.`, {
8502
- cause: err instanceof Error ? err.message : String(err)
8503
- });
8504
- }
8505
- if (addresses.length === 0 || addresses.some((entry) => !isPublicAddress(entry.address))) {
8506
- refuse(`The endpoint host ${host} resolves to a private or unsupported network address.`);
8507
- }
8508
- return url;
8509
- }
8510
-
8511
8441
  // src/lib/request-schema.ts
8512
8442
  var import_ajv = __toESM(require_ajv(), 1);
8513
8443
  var import__ = __toESM(require__(), 1);
@@ -9929,10 +9859,9 @@ async function runPay(args, ctx, deps = {}) {
9929
9859
  const host = new URL(url).host;
9930
9860
  let registry;
9931
9861
  let termsLabel;
9932
- if (lane === "bazaar") {
9933
- if (args.terms !== void 0) termsLabel = assertWithinTerms(args.terms, requirement);
9934
- else
9935
- registry = await assertRegistryVerified(settings, url, requirement, ctx.flags.timeout, ctx);
9862
+ if (args.terms !== void 0) termsLabel = assertWithinTerms(args.terms, requirement);
9863
+ else if (lane === "bazaar") {
9864
+ registry = await assertRegistryVerified(settings, url, requirement, ctx.flags.timeout, ctx);
9936
9865
  }
9937
9866
  const provider = resolveWalletProvider(
9938
9867
  ctx,
@@ -9992,9 +9921,9 @@ async function runPay(args, ctx, deps = {}) {
9992
9921
  });
9993
9922
  }
9994
9923
  effectiveRequirement = fresh;
9995
- if (lane === "bazaar") {
9996
- if (args.terms !== void 0) termsLabel = assertWithinTerms(args.terms, fresh);
9997
- else registry = await assertRegistryVerified(settings, url, fresh, ctx.flags.timeout, ctx);
9924
+ if (args.terms !== void 0) termsLabel = assertWithinTerms(args.terms, fresh);
9925
+ else if (lane === "bazaar") {
9926
+ registry = await assertRegistryVerified(settings, url, fresh, ctx.flags.timeout, ctx);
9998
9927
  }
9999
9928
  }
10000
9929
  const amountAtomic = BigInt(effectiveRequirement.amount);
@@ -10027,6 +9956,7 @@ async function runPay(args, ctx, deps = {}) {
10027
9956
  }
10028
9957
  const paid = await httpRequest(url, {
10029
9958
  ...fetchOpts,
9959
+ timeoutMs: paidLegTimeoutMs(effectiveRequirement, ctx.flags.timeout),
10030
9960
  headers: { ...headers, ...payment.headers }
10031
9961
  });
10032
9962
  await authorizer.commit(reservationId, payment.amountAtomic);
@@ -10041,18 +9971,7 @@ async function runPay(args, ctx, deps = {}) {
10041
9971
  if (args.resultSchema !== void 0) {
10042
9972
  const check = validateResultBody(args.resultSchema, paid.text);
10043
9973
  if (check.unvalidated === true) caveat = unvalidatedCaveat(check);
10044
- else if (!check.valid) {
10045
- throw new CliError("CONTRACT_MISMATCH", `The paid response is not a usable result.`, {
10046
- fix: "The payment has already settled and is counted against the session budget. Do not retry blind: the endpoint answered 2xx with a body that fails the success rule it was paid under.",
10047
- details: {
10048
- status: paid.status,
10049
- reason: check.reason,
10050
- ...check.diagnosis !== void 0 ? { diagnosis: check.diagnosis } : {},
10051
- amountAtomic: payment.amountAtomic.toString(),
10052
- settlement: "reported"
10053
- }
10054
- });
10055
- }
9974
+ else if (!check.valid) caveat = failedRuleCaveat(check);
10056
9975
  }
10057
9976
  return deliver(url, lane, paid, {
10058
9977
  paid: true,
@@ -10079,6 +9998,14 @@ async function runPay(args, ctx, deps = {}) {
10079
9998
  }
10080
9999
  );
10081
10000
  }
10001
+ var MAX_PAID_LEG_TIMEOUT_MS = 12e4;
10002
+ function paidLegTimeoutMs(requirement, cliTimeoutMs) {
10003
+ const advertised = requirement.maxTimeoutSeconds;
10004
+ if (typeof advertised !== "number" || !Number.isFinite(advertised) || advertised <= 0) {
10005
+ return cliTimeoutMs;
10006
+ }
10007
+ return Math.max(cliTimeoutMs, Math.min(advertised * 1e3, MAX_PAID_LEG_TIMEOUT_MS));
10008
+ }
10082
10009
  function resolveLane(url, settings) {
10083
10010
  let target;
10084
10011
  try {
@@ -10190,6 +10117,9 @@ function assertUsableResult(schema, body, status, how) {
10190
10117
  function unvalidatedCaveat(check) {
10191
10118
  return `${check.reason ?? "The result could not be validated."} The body is delivered unverified: its shape was never checked against the success rule.`;
10192
10119
  }
10120
+ function failedRuleCaveat(check) {
10121
+ return `${check.reason ?? "The result does not satisfy its success schema."} The payment settled, so the body is delivered as received, unverified: treat it as possibly not the answer that was paid for.`;
10122
+ }
10193
10123
  function legFix(failure) {
10194
10124
  return failure.kind === "oversized-header" ? "Raising `--max-http-header-size` on the node process that runs this CLI would let the header be read; that is an operator decision, not a default this build changes." : "";
10195
10125
  }
@@ -10245,13 +10175,13 @@ async function assertRegistryVerified(settings, url, requirement, timeoutMs, ctx
10245
10175
  "REGISTRY_MISMATCH",
10246
10176
  `The live 402 does not match what ${verification.registry} advertises for this resource (${verification.detail}).`,
10247
10177
  {
10248
- fix: "Nothing was signed. Re-run `tenjin discover` to see the advertised terms; if the seller changed them, the registry will catch up.",
10178
+ fix: `Nothing was signed. The seller's live terms differ from its listing on ${verification.registry}; check that listing, and pay once it matches or the seller corrects the endpoint.`,
10249
10179
  details: { registry: verification.registry, detail: verification.detail }
10250
10180
  }
10251
10181
  );
10252
10182
  case "unlisted":
10253
10183
  throw new CliError("USAGE", "No configured registry is known to list this resource.", {
10254
- fix: "The Bazaar lane pays publicly listed deals only, and pay-time lookup leans on the local `discover` cache: run `tenjin discover [query]` so a sweep can surface this endpoint, then re-run pay."
10184
+ fix: "Nothing was signed. The Bazaar lane pays only a URL a configured registry lists under the seller's payTo address. Check the registries in `tenjin config get bazaarRegistries` for this exact URL; if it is listed elsewhere, add that registry with `tenjin config set bazaarRegistries`."
10255
10185
  });
10256
10186
  case "unavailable":
10257
10187
  throw new CliError(
@@ -10323,6 +10253,8 @@ export {
10323
10253
  require_dist,
10324
10254
  canonicalHash,
10325
10255
  assertResultSchema,
10326
- runPay
10256
+ runPay,
10257
+ MAX_PAID_LEG_TIMEOUT_MS,
10258
+ paidLegTimeoutMs
10327
10259
  };
10328
- //# sourceMappingURL=chunk-L3PVMIYQ.js.map
10260
+ //# sourceMappingURL=chunk-N44H5TFB.js.map