@ametyst/cli 0.2.43 → 0.2.45

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 (2) hide show
  1. package/dist/index.js +64 -3
  2. package/package.json +5 -6
package/dist/index.js CHANGED
@@ -109691,7 +109691,39 @@ async function runStartSession(ctx, timing = new TimingCollector("start_session"
109691
109691
  }
109692
109692
  return { responseKey: "unlocked_pending_authorization", credentials, timingReport: timing.report() };
109693
109693
  }
109694
+ var WALLET_SCOPED_CREDENTIAL_KEYS = [
109695
+ "virtualWalletId",
109696
+ "virtualWalletName",
109697
+ "virtualWalletStatus",
109698
+ "walletAddress",
109699
+ "paymentManagerAddress",
109700
+ "jwtToken",
109701
+ "policyId",
109702
+ "policyName",
109703
+ "policyDescription",
109704
+ "policyOnchainPermissions",
109705
+ "policyValidUntil",
109706
+ "policyPrecheckPassed",
109707
+ "virtualWalletKernelAccountClient",
109708
+ "permissionPlugin",
109709
+ "kernelDomain",
109710
+ "authorizationStatus",
109711
+ "pendingWalletId",
109712
+ "authorizationRequestId"
109713
+ ];
109714
+ function clearWalletScopedCredentials(target) {
109715
+ for (const key of WALLET_SCOPED_CREDENTIAL_KEYS) {
109716
+ delete target[key];
109717
+ }
109718
+ }
109719
+ function sameAddress(a, b) {
109720
+ return String(a ?? "").toLowerCase() === String(b ?? "").toLowerCase();
109721
+ }
109694
109722
  function mergeStartSessionCredentials(target, patch, responseKey) {
109723
+ const walletChanged = patch.eoaAddress !== void 0 && !sameAddress(patch.eoaAddress, target.eoaAddress);
109724
+ if (walletChanged) {
109725
+ clearWalletScopedCredentials(target);
109726
+ }
109695
109727
  if (patch.walletKeystoreJson !== void 0) {
109696
109728
  target.walletKeystoreJson = patch.walletKeystoreJson;
109697
109729
  }
@@ -109700,10 +109732,16 @@ function mergeStartSessionCredentials(target, patch, responseKey) {
109700
109732
  target.signerAddress = patch.eoaAddress;
109701
109733
  }
109702
109734
  if (responseKey === "wrong_passphrase" || responseKey === "no_keystore") {
109703
- return;
109735
+ return { walletChanged };
109704
109736
  }
109705
109737
  const { walletKeystoreJson: _wk, eoaAddress: _eo, ...rest } = patch;
109706
109738
  applyCredentialsPatch(target, rest);
109739
+ if (walletChanged && target.policyId === void 0) {
109740
+ target.requiresNewPolicy = true;
109741
+ } else if (target.policyId !== void 0) {
109742
+ delete target.requiresNewPolicy;
109743
+ }
109744
+ return { walletChanged };
109707
109745
  }
109708
109746
 
109709
109747
  // src/mcp-server/system-prompt.ts
@@ -111185,7 +111223,12 @@ server.tool(
111185
111223
  readPolicyActiveOnchain: buildPolicyActiveOnchainReader(sdk)
111186
111224
  }
111187
111225
  );
111188
- mergeStartSessionCredentials(currentCredentials, result.credentials, result.responseKey);
111226
+ const { walletChanged } = mergeStartSessionCredentials(currentCredentials, result.credentials, result.responseKey);
111227
+ if (walletChanged) {
111228
+ walletsCache = null;
111229
+ policiesCache = null;
111230
+ transactionsCache = null;
111231
+ }
111189
111232
  if (result.responseKey === "wrong_passphrase" || result.responseKey === "confirm_reset") {
111190
111233
  currentCredentials.wrongPassphraseAttempts = (currentCredentials.wrongPassphraseAttempts ?? 0) + 1;
111191
111234
  } else {
@@ -112309,6 +112352,24 @@ server.tool(
112309
112352
  }
112310
112353
  }
112311
112354
  }
112355
+ if (currentCredentials.requiresNewPolicy && !currentCredentials.policyId) {
112356
+ logSpendTelemetryEarlyErr();
112357
+ return {
112358
+ content: [
112359
+ {
112360
+ type: "text",
112361
+ text: JSON.stringify({
112362
+ success: false,
112363
+ error: "policy_required_for_new_wallet",
112364
+ guidance: {
112365
+ say_to_user: "Your wallet was reset, so this is a brand-new wallet with a new address. The spending policy your admin approved belonged to the old one and no longer applies \u2014 you need to request a new policy before you can pay.",
112366
+ next_action: "Call getAvailablePolicies, let the user pick one, then call requestAccess with it. Once the admin approves it, retry this spend."
112367
+ }
112368
+ }, null, 2)
112369
+ }
112370
+ ]
112371
+ };
112372
+ }
112312
112373
  const kernelClient = currentCredentials.virtualWalletKernelAccountClient;
112313
112374
  const apiKey = currentCredentials.apiKey;
112314
112375
  if (!kernelClient || !apiKey) {
@@ -113134,7 +113195,7 @@ async function startMCPServer(walletKeystoreJson, eoaAddress, config, versionNot
113134
113195
 
113135
113196
  // src/version.ts
113136
113197
  init_esm_shims();
113137
- var CLI_VERSION = true ? "0.2.43" : "0.0.0-dev";
113198
+ var CLI_VERSION = true ? "0.2.45" : "0.0.0-dev";
113138
113199
 
113139
113200
  // src/version-check.ts
113140
113201
  init_esm_shims();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ametyst/cli",
3
- "version": "0.2.43",
3
+ "version": "0.2.45",
4
4
  "private": false,
5
5
  "description": "Ametyst CLI — embedded MCP server, wallet ops, agent payments",
6
6
  "type": "module",
@@ -37,7 +37,6 @@
37
37
  }
38
38
  },
39
39
  "dependencies": {
40
- "@ametyst-dev/sdk-prod": "^0.8.34",
41
40
  "@modelcontextprotocol/sdk": "1.29.0",
42
41
  "@napi-rs/keyring": "1.1.7",
43
42
  "mcp-use": "1.24.2"
@@ -78,10 +77,10 @@
78
77
  "esbuild@>=0.27.3 <0.28.1": "0.28.1"
79
78
  },
80
79
  "optionalDependencies": {
81
- "@ametyst/cli-darwin-arm64": "0.2.43",
82
- "@ametyst/cli-darwin-x64": "0.2.43",
83
- "@ametyst/cli-linux-x64-gnu": "0.2.43",
84
- "@ametyst/cli-win32-x64-msvc": "0.2.43"
80
+ "@ametyst/cli-darwin-arm64": "0.2.45",
81
+ "@ametyst/cli-darwin-x64": "0.2.45",
82
+ "@ametyst/cli-linux-x64-gnu": "0.2.45",
83
+ "@ametyst/cli-win32-x64-msvc": "0.2.45"
85
84
  },
86
85
  "scripts": {
87
86
  "build:native": "cd native && cargo build --release && napi build --release",