primcli 1.9.0 → 1.11.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 CHANGED
@@ -93,6 +93,9 @@ primitive payments pay --challenge-file challenge.json
93
93
  cat challenge.json | primitive payments pay
94
94
 
95
95
  # Email-native flow: the payee issues a challenge over an email thread.
96
+ # Note: create-email-challenge takes --amount in token base units only; unlike
97
+ # `charge` it has no --amount-usdc. USDC has 6 decimals, so multiply by
98
+ # 1,000,000: 0.01 USDC is --amount 10000.
96
99
  primitive payments create-email-challenge --from payee@your-domain.example \
97
100
  --to payer@their-domain.example --amount 10000 --network base-sepolia
98
101
  # Payer: sign a received email challenge into an interaction.json payment step.
@@ -4629,7 +4629,8 @@ const openapiDocument = {
4629
4629
  "name": "slug",
4630
4630
  "in": "path",
4631
4631
  "required": true,
4632
- "schema": { "type": "string" }
4632
+ "schema": { "type": "string" },
4633
+ "description": "The registry slug."
4633
4634
  }],
4634
4635
  "get": {
4635
4636
  "operationId": "listRegistryAgents",
@@ -4644,7 +4645,8 @@ const openapiDocument = {
4644
4645
  "type": "integer",
4645
4646
  "minimum": 1,
4646
4647
  "maximum": 200
4647
- }
4648
+ },
4649
+ "description": "Maximum number of items to return (1-200)."
4648
4650
  }, {
4649
4651
  "name": "cursor",
4650
4652
  "in": "query",
@@ -4690,12 +4692,14 @@ const openapiDocument = {
4690
4692
  "name": "slug",
4691
4693
  "in": "path",
4692
4694
  "required": true,
4693
- "schema": { "type": "string" }
4695
+ "schema": { "type": "string" },
4696
+ "description": "The registry slug."
4694
4697
  }, {
4695
4698
  "name": "handle",
4696
4699
  "in": "path",
4697
4700
  "required": true,
4698
- "schema": { "type": "string" }
4701
+ "schema": { "type": "string" },
4702
+ "description": "The registry-scoped handle the agent is published under."
4699
4703
  }],
4700
4704
  "get": {
4701
4705
  "operationId": "resolveRegistryHandle",
@@ -4726,7 +4730,8 @@ const openapiDocument = {
4726
4730
  "name": "slug",
4727
4731
  "in": "path",
4728
4732
  "required": true,
4729
- "schema": { "type": "string" }
4733
+ "schema": { "type": "string" },
4734
+ "description": "The registry slug."
4730
4735
  }],
4731
4736
  "get": {
4732
4737
  "operationId": "listRegistryRequests",
@@ -4740,7 +4745,8 @@ const openapiDocument = {
4740
4745
  "type": "integer",
4741
4746
  "minimum": 1,
4742
4747
  "maximum": 200
4743
- }
4748
+ },
4749
+ "description": "Maximum number of items to return (1-200)."
4744
4750
  }],
4745
4751
  "responses": {
4746
4752
  "200": {
@@ -4760,7 +4766,8 @@ const openapiDocument = {
4760
4766
  "name": "slug",
4761
4767
  "in": "path",
4762
4768
  "required": true,
4763
- "schema": { "type": "string" }
4769
+ "schema": { "type": "string" },
4770
+ "description": "The registry slug."
4764
4771
  }, { "$ref": "#/components/parameters/ResourceId" }],
4765
4772
  "post": {
4766
4773
  "operationId": "decideRegistryRequest",
@@ -5531,7 +5538,7 @@ const openapiDocument = {
5531
5538
  "amount": {
5532
5539
  "type": "string",
5533
5540
  "pattern": "^[1-9][0-9]{0,38}$",
5534
- "description": "Amount to collect, in token base units. USDC has 6 decimals, so\n`\"10000\"` is 0.01 USDC.\n"
5541
+ "description": "Amount to collect, in token base units (unlike the `charge` CLI\ncommand, which also accepts `--amount-usdc`, this field takes base\nunits only). USDC has 6 decimals, so `\"10000\"` is 0.01 USDC:\nmultiply a human USDC amount by 1,000,000 (0.01 USDC -> `\"10000\"`).\n"
5535
5542
  },
5536
5543
  "network": {
5537
5544
  "type": "string",
@@ -5541,7 +5548,7 @@ const openapiDocument = {
5541
5548
  "type": "integer",
5542
5549
  "minimum": 60,
5543
5550
  "maximum": 86400,
5544
- "description": "Seconds until the challenge expires. Defaults to 3600."
5551
+ "description": "Seconds until the challenge expires. Defaults to 300."
5545
5552
  },
5546
5553
  "resource": {
5547
5554
  "type": "string",
@@ -15478,7 +15485,7 @@ const operationManifest = [
15478
15485
  "amount": {
15479
15486
  "type": "string",
15480
15487
  "pattern": "^[1-9][0-9]{0,38}$",
15481
- "description": "Amount to collect, in token base units. USDC has 6 decimals, so\n`\"10000\"` is 0.01 USDC.\n"
15488
+ "description": "Amount to collect, in token base units (unlike the `charge` CLI\ncommand, which also accepts `--amount-usdc`, this field takes base\nunits only). USDC has 6 decimals, so `\"10000\"` is 0.01 USDC:\nmultiply a human USDC amount by 1,000,000 (0.01 USDC -> `\"10000\"`).\n"
15482
15489
  },
15483
15490
  "network": {
15484
15491
  "type": "string",
@@ -15488,7 +15495,7 @@ const operationManifest = [
15488
15495
  "type": "integer",
15489
15496
  "minimum": 60,
15490
15497
  "maximum": 86400,
15491
- "description": "Seconds until the challenge expires. Defaults to 3600."
15498
+ "description": "Seconds until the challenge expires. Defaults to 300."
15492
15499
  },
15493
15500
  "resource": {
15494
15501
  "type": "string",
@@ -16292,7 +16299,7 @@ const operationManifest = [
16292
16299
  "operationId": "decideRegistryRequest",
16293
16300
  "path": "/registries/{slug}/requests/{id}",
16294
16301
  "pathParams": [{
16295
- "description": null,
16302
+ "description": "The registry slug.",
16296
16303
  "enum": null,
16297
16304
  "name": "slug",
16298
16305
  "required": true,
@@ -16554,14 +16561,14 @@ const operationManifest = [
16554
16561
  "operationId": "listRegistryAgents",
16555
16562
  "path": "/registries/{slug}/agents",
16556
16563
  "pathParams": [{
16557
- "description": null,
16564
+ "description": "The registry slug.",
16558
16565
  "enum": null,
16559
16566
  "name": "slug",
16560
16567
  "required": true,
16561
16568
  "type": "string"
16562
16569
  }],
16563
16570
  "queryParams": [{
16564
- "description": null,
16571
+ "description": "Maximum number of items to return (1-200).",
16565
16572
  "enum": null,
16566
16573
  "maximum": 200,
16567
16574
  "minimum": 1,
@@ -16620,14 +16627,14 @@ const operationManifest = [
16620
16627
  "operationId": "listRegistryRequests",
16621
16628
  "path": "/registries/{slug}/requests",
16622
16629
  "pathParams": [{
16623
- "description": null,
16630
+ "description": "The registry slug.",
16624
16631
  "enum": null,
16625
16632
  "name": "slug",
16626
16633
  "required": true,
16627
16634
  "type": "string"
16628
16635
  }],
16629
16636
  "queryParams": [{
16630
- "description": null,
16637
+ "description": "Maximum number of items to return (1-200).",
16631
16638
  "enum": null,
16632
16639
  "maximum": 200,
16633
16640
  "minimum": 1,
@@ -16678,7 +16685,7 @@ const operationManifest = [
16678
16685
  "operationId": "publishAgent",
16679
16686
  "path": "/registries/{slug}/agents",
16680
16687
  "pathParams": [{
16681
- "description": null,
16688
+ "description": "The registry slug.",
16682
16689
  "enum": null,
16683
16690
  "name": "slug",
16684
16691
  "required": true,
@@ -16731,13 +16738,13 @@ const operationManifest = [
16731
16738
  "operationId": "resolveRegistryHandle",
16732
16739
  "path": "/registries/{slug}/agents/{handle}",
16733
16740
  "pathParams": [{
16734
- "description": null,
16741
+ "description": "The registry slug.",
16735
16742
  "enum": null,
16736
16743
  "name": "slug",
16737
16744
  "required": true,
16738
16745
  "type": "string"
16739
16746
  }, {
16740
- "description": null,
16747
+ "description": "The registry-scoped handle the agent is published under.",
16741
16748
  "enum": null,
16742
16749
  "name": "handle",
16743
16750
  "required": true,
@@ -16786,13 +16793,13 @@ const operationManifest = [
16786
16793
  "operationId": "unpublishAgent",
16787
16794
  "path": "/registries/{slug}/agents/{handle}",
16788
16795
  "pathParams": [{
16789
- "description": null,
16796
+ "description": "The registry slug.",
16790
16797
  "enum": null,
16791
16798
  "name": "slug",
16792
16799
  "required": true,
16793
16800
  "type": "string"
16794
16801
  }, {
16795
- "description": null,
16802
+ "description": "The registry-scoped handle the agent is published under.",
16796
16803
  "enum": null,
16797
16804
  "name": "handle",
16798
16805
  "required": true,
@@ -22648,8 +22655,8 @@ const PRIMITIVE_TEAM_AUTHOR = {
22648
22655
  name: "Primitive Team",
22649
22656
  url: "https://primitive.dev"
22650
22657
  };
22651
- const SDK_VERSION_RANGE = "^1.9.0";
22652
- const CLI_VERSION_RANGE = "^1.9.0";
22658
+ const SDK_VERSION_RANGE = "^1.11.0";
22659
+ const CLI_VERSION_RANGE = "^1.11.0";
22653
22660
  const ESBUILD_VERSION_RANGE = "^0.27.0";
22654
22661
  function renderHandler() {
22655
22662
  return `// env.PRIMITIVE_API_KEY, env.PRIMITIVE_WEBHOOK_SECRET, and
@@ -26194,24 +26201,47 @@ function toPaymentPayload(network, auth, signature) {
26194
26201
  };
26195
26202
  }
26196
26203
  /**
26197
- * Compute the EIP-3009 validity window for a payment. `validBefore` is the
26198
- * value that governs on-chain validity, so it MUST cover the challenge's
26199
- * `expires_at` plus a settlement margin; `validAfter` is set generously in the
26200
- * past for clock skew. The total window is hard-capped at `maxWindowSec` so
26201
- * neither a far-future `challengeExpiresAtSec` nor a widened margin can produce
26202
- * a window the platform verifier would later reject.
26204
+ * Compute the EIP-3009 validity window for a payment, landing inside the band
26205
+ * the platform accepts. `validBefore` governs on-chain validity, so it MUST
26206
+ * stay far enough in the future to settle (>= `minHeadroomSec`) yet not so far
26207
+ * that the total window exceeds the `maxWindowSec` cap; `validAfter` is set
26208
+ * generously in the past for clock skew.
26209
+ *
26210
+ * Both ends of that band are payer landmines: a too-tight `validBefore` (low
26211
+ * headroom, e.g. a near-expired challenge) is rejected for being about to
26212
+ * expire, and a too-wide window (far-future expiry) is rejected as
26213
+ * "authorization window too wide". By default this clamps the computed window
26214
+ * into the band so a caller who does not override always gets a signable
26215
+ * window.
26216
+ *
26217
+ * If the caller passes an explicit `validBeforeSec` or `validAfterSec`, that is
26218
+ * an intent to pin the bound: when it falls outside the band this throws a
26219
+ * specific error naming which bound was violated (rather than silently signing
26220
+ * a doomed authorization), unless `clamp` is left enabled, in which case the
26221
+ * pinned value is clamped into the band like the computed one.
26203
26222
  */
26204
26223
  function computePaymentValidityWindow(params) {
26205
26224
  const margin = params.settlementMarginSec ?? 300;
26206
26225
  const skew = params.clockSkewSec ?? 300;
26207
- const validBefore = BigInt(params.challengeExpiresAtSec + margin);
26208
- const validAfter = BigInt(params.nowSec - skew);
26209
- if (validBefore <= validAfter) throw new Error("invalid validity window: validBefore must be after validAfter (challenge already expired?)");
26210
- const maxWindow = BigInt(params.maxWindowSec ?? 86400);
26211
- if (validBefore - validAfter > maxWindow) throw new Error(`invalid validity window: total window exceeds the ${maxWindow}s cap (challenge expiry too far out?)`);
26226
+ const maxWindow = params.maxWindowSec ?? 86400;
26227
+ const minHeadroom = params.minHeadroomSec ?? 60;
26228
+ const clamp = params.clamp ?? true;
26229
+ if (maxWindow < minHeadroom) throw new Error(`invalid validity window config: maxWindowSec (${maxWindow}) is smaller than minHeadroomSec (${minHeadroom})`);
26230
+ const validAfter = params.validAfterSec !== void 0 ? params.validAfterSec : params.nowSec - skew;
26231
+ const rawValidBefore = params.validBeforeSec !== void 0 ? params.validBeforeSec : params.challengeExpiresAtSec + margin;
26232
+ const floor = params.nowSec + minHeadroom;
26233
+ const ceiling = validAfter + maxWindow;
26234
+ const tooTight = rawValidBefore < floor;
26235
+ const tooWide = rawValidBefore > ceiling;
26236
+ if (!clamp && params.validBeforeSec !== void 0) {
26237
+ if (tooTight) throw new Error(`invalid validity window: validBefore (${rawValidBefore}) is below the minimum settlement headroom (must be >= now + ${minHeadroom}s = ${floor}); the authorization would be rejected as about to expire`);
26238
+ if (tooWide) throw new Error(`invalid validity window: validBefore (${rawValidBefore}) exceeds the ${maxWindow}s window cap (must be <= validAfter + ${maxWindow}s = ${ceiling}); the authorization window is too wide`);
26239
+ }
26240
+ const bandedValidBefore = tooTight ? floor : tooWide ? ceiling : rawValidBefore;
26241
+ if (bandedValidBefore <= validAfter) throw new Error("invalid validity window: validBefore must be after validAfter (challenge already expired or validAfter pinned too late?)");
26212
26242
  return {
26213
- validAfter,
26214
- validBefore
26243
+ validAfter: BigInt(validAfter),
26244
+ validBefore: BigInt(bandedValidBefore)
26215
26245
  };
26216
26246
  }
26217
26247
  /**
@@ -26308,6 +26338,7 @@ var X402Error = class extends Error {
26308
26338
  this.retryAfter = options?.retryAfter ?? null;
26309
26339
  }
26310
26340
  };
26341
+ new RegExp(`^${/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.source.slice(1, -1)}@[^\\s@]+$`, "i");
26311
26342
  /**
26312
26343
  * Assert a challenge is fully hydrated before signing, so a missing field fails
26313
26344
  * with a named X402Error instead of an opaque viem/BigInt error mid-sign.
@@ -28529,6 +28560,18 @@ const CANONICAL_OPERATION_ALIASES = {
28529
28560
  "functions:get": "functions:get-function",
28530
28561
  "functions:list": "functions:list-functions",
28531
28562
  "functions:list-secrets": "functions:list-function-secrets",
28563
+ "registries:agent": "registries:get-agent",
28564
+ "registries:agents": "registries:list-registry-agents",
28565
+ "registries:create": "registries:create-registry",
28566
+ "registries:decide": "registries:decide-registry-request",
28567
+ "registries:define": "registries:define-agent",
28568
+ "registries:get": "registries:get-registry",
28569
+ "registries:list": "registries:list-registries",
28570
+ "registries:publish": "registries:publish-agent",
28571
+ "registries:requests": "registries:list-registry-requests",
28572
+ "registries:resolve": "registries:resolve-registry-handle",
28573
+ "registries:unpublish": "registries:unpublish-agent",
28574
+ "registries:update": "registries:update-registry",
28532
28575
  "sending:get": "sending:get-sent-email",
28533
28576
  "sending:list": "sending:list-sent-emails",
28534
28577
  "sending:permissions": "sending:get-send-permissions",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "primcli",
3
- "version": "1.9.0",
3
+ "version": "1.11.0",
4
4
  "description": "Official Primitive CLI: deploy Primitive Functions, send and inspect mail, manage endpoints, all from the terminal. Wraps the @primitivedotdev/sdk runtime client with one-shot commands.",
5
5
  "type": "module",
6
6
  "sideEffects": false,