zk-agent-cli 0.1.0-beta.8 → 0.1.0-beta.9

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 (3) hide show
  1. package/README.md +3 -2
  2. package/dist/index.js +633 -16
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -23,8 +23,9 @@ npx skills add https://github.com/AgiWeb3/zk-agent-cli
23
23
  ```
24
24
 
25
25
  This repo currently ships a repository skill bundle for compatible harnesses.
26
- It does not yet ship a native ChatGPT/Codex plugin bundle such as
27
- `.codex-plugin/plugin.json`.
26
+ The repository root now also ships a native ChatGPT/Codex plugin manifest at
27
+ `.codex-plugin/plugin.json`, but that plugin source belongs to the repository
28
+ surface rather than this published npm tarball.
28
29
 
29
30
  For direct terminal use, install the packaged CLI:
30
31
 
package/dist/index.js CHANGED
@@ -7745,6 +7745,71 @@ function formatHumanErrorMessage(error) {
7745
7745
  return lines.join("\n");
7746
7746
  }
7747
7747
 
7748
+ // src/lib/discovery-summary.ts
7749
+ function createEmptyDiscoverySourceCounts() {
7750
+ return {
7751
+ localDeployments: 0,
7752
+ tokenDirectory: 0,
7753
+ unknown: 0
7754
+ };
7755
+ }
7756
+ function createEmptyDiscoveryRoleCounts() {
7757
+ return Object.fromEntries(
7758
+ REGISTRY_TOKEN_ROLES.map((role) => [role, 0])
7759
+ );
7760
+ }
7761
+ function summarizeDiscoveryEntrySources(entries) {
7762
+ const counts = createEmptyDiscoverySourceCounts();
7763
+ for (const entry of entries) {
7764
+ if (entry.source === "local-deployments") {
7765
+ counts.localDeployments += 1;
7766
+ continue;
7767
+ }
7768
+ if (entry.source === "token-directory") {
7769
+ counts.tokenDirectory += 1;
7770
+ continue;
7771
+ }
7772
+ counts.unknown += 1;
7773
+ }
7774
+ return counts;
7775
+ }
7776
+ function summarizeDiscoveryRoleMatches(entries) {
7777
+ const counts = createEmptyDiscoveryRoleCounts();
7778
+ for (const entry of entries) {
7779
+ for (const match of entry.defaultsRegistryMatches || []) {
7780
+ counts[match.role] += 1;
7781
+ }
7782
+ }
7783
+ return counts;
7784
+ }
7785
+ function countCurrentValidatedDefaultEntries(entries) {
7786
+ return entries.filter(
7787
+ (entry) => (entry.defaultsRegistryMatches || []).some((match) => match.isCurrentValidatedDefault)
7788
+ ).length;
7789
+ }
7790
+ function listUniqueDiscoveryChains(entries) {
7791
+ return [...new Set(
7792
+ entries.map((entry) => entry.chainKey?.trim()).filter((value) => Boolean(value))
7793
+ )];
7794
+ }
7795
+ function firstDiscoverySymbol(entries) {
7796
+ return entries.find((entry) => entry.symbol?.trim())?.symbol?.trim() || null;
7797
+ }
7798
+ function firstDiscoverySource(entries) {
7799
+ if (entries.length === 0) return null;
7800
+ return entries[0]?.source || "unknown";
7801
+ }
7802
+ function summarizeTokenRegistrySources(sources) {
7803
+ return sources.map((source) => ({
7804
+ id: source.id,
7805
+ enabled: source.enabled,
7806
+ exists: source.exists
7807
+ }));
7808
+ }
7809
+ function findNativeBalance(balances) {
7810
+ return balances.find((balance) => balance.type === "native") || null;
7811
+ }
7812
+
7748
7813
  // src/lib/recommended-commands.ts
7749
7814
  function appendPaymasterMode(command, paymasterMode) {
7750
7815
  if (!paymasterMode || paymasterMode === "none") {
@@ -9181,6 +9246,27 @@ function linesForMultiBalances(result) {
9181
9246
  }
9182
9247
  return lines;
9183
9248
  }
9249
+ function buildAssetsDiscoverySummary(result) {
9250
+ const nativeBalance = findNativeBalance(result.balances);
9251
+ const ownedTokenSymbols = (result.ownedTokenRegistry?.entries || []).map((entry) => entry.symbol?.trim()).filter((value) => Boolean(value));
9252
+ return {
9253
+ walletName: result.walletName,
9254
+ chain: result.chain,
9255
+ chainId: result.chainId,
9256
+ assetCount: result.balances.length,
9257
+ nativeAssetSymbol: nativeBalance?.symbol || null,
9258
+ nativeAssetBalance: nativeBalance?.balance || null,
9259
+ ownedTokenCount: result.ownedTokenRegistry?.entryCount || 0,
9260
+ primaryOwnedTokenSymbol: firstDiscoverySymbol(result.ownedTokenRegistry?.entries || []),
9261
+ ownedTokenSymbols,
9262
+ ownedTokenSourceCounts: result.ownedTokenRegistry?.summary.sourceCounts || null,
9263
+ ownedBridgeMappingCounts: result.ownedTokenRegistry?.summary.bridgeMappingCounts || null,
9264
+ ownedRegistryRoleCounts: result.ownedTokenRegistry?.summary.registryRoleCounts || null
9265
+ };
9266
+ }
9267
+ function buildBalancesDiscoverySummary(result) {
9268
+ return buildAssetsDiscoverySummary(result);
9269
+ }
9184
9270
  function withPaymasterOptions(command) {
9185
9271
  return command.option("--paymaster-mode <mode>", "none, sponsored, or approval-based").option("--paymaster-address <address>", "Explicit paymaster contract address override").option("--paymaster-token <address>", "ERC-20 token address for approval-based paymaster mode");
9186
9272
  }
@@ -9240,7 +9326,23 @@ function createBalancesCommand(deps) {
9240
9326
  provider: resolvedDeps.provider,
9241
9327
  ownedTokens: options.ownedTokens
9242
9328
  });
9243
- printResult(linesForSingleBalances(payload), { ok: true, ...payload });
9329
+ const discoverySummary = options.ownedTokens && "ownedTokenRegistry" in payload ? buildBalancesDiscoverySummary(payload) : void 0;
9330
+ const recommendedCommands = options.ownedTokens ? buildDiscoveryRecommendedCommands({
9331
+ walletName,
9332
+ chain: payload.chain
9333
+ }) : void 0;
9334
+ printResult(
9335
+ [
9336
+ ...linesForSingleBalances(payload),
9337
+ ...recommendedCommands ? workflowFollowupLines(recommendedCommands) : []
9338
+ ],
9339
+ {
9340
+ ok: true,
9341
+ ...discoverySummary ? { discoverySummary } : {},
9342
+ ...recommendedCommands ? { recommendedCommands } : {},
9343
+ ...payload
9344
+ }
9345
+ );
9244
9346
  });
9245
9347
  }
9246
9348
  function createAssetsCommand(deps) {
@@ -9279,9 +9381,12 @@ function createAssetsCommand(deps) {
9279
9381
  chain: payload.chain,
9280
9382
  includeAssets: false
9281
9383
  });
9384
+ const discoverySummary = buildAssetsDiscoverySummary(
9385
+ payload
9386
+ );
9282
9387
  printResult(
9283
9388
  [...linesForSingleBalances(payload), ...workflowFollowupLines(recommendedCommands)],
9284
- { ok: true, recommendedCommands, ...payload }
9389
+ { ok: true, discoverySummary, recommendedCommands, ...payload }
9285
9390
  );
9286
9391
  });
9287
9392
  }
@@ -10409,6 +10514,36 @@ function buildWalletNextRecommendedCommands(walletName, summary) {
10409
10514
  ...summary.recommendedCommand ? { nextAction: summary.recommendedCommand } : {}
10410
10515
  };
10411
10516
  }
10517
+ function workflowIntentSupportsTokenDiscovery(intent) {
10518
+ return intent === "send-token" || intent === "swap" || intent === "bridge" || intent === "deposit" || intent === "withdraw";
10519
+ }
10520
+ function buildWalletTokenDiscoverySummary(input) {
10521
+ if (!input.recommendedCommands) {
10522
+ return void 0;
10523
+ }
10524
+ const hasTokenDiscovery = Boolean(input.recommendedCommands.discoverAssets) || Boolean(input.recommendedCommands.discoverOwnedTokens) || Boolean(input.recommendedCommands.discoverTokens) || Boolean(input.recommendedCommands.inspectToken) || Boolean(input.recommendedCommands.discoverPaymasterTokens) || Boolean(input.recommendedCommands.inspectPaymasterToken);
10525
+ if (!hasTokenDiscovery) {
10526
+ return void 0;
10527
+ }
10528
+ return {
10529
+ walletName: input.walletName,
10530
+ chain: input.chain,
10531
+ intent: input.intent || null,
10532
+ nextAction: input.nextAction || null,
10533
+ paymasterMode: input.paymasterMode || null,
10534
+ tokenizedIntent: workflowIntentSupportsTokenDiscovery(input.intent),
10535
+ includesAssetDiscovery: Boolean(input.recommendedCommands.discoverAssets),
10536
+ includesOwnedTokenDiscovery: Boolean(input.recommendedCommands.discoverOwnedTokens),
10537
+ includesChainTokenDiscovery: Boolean(input.recommendedCommands.discoverTokens),
10538
+ includesDirectTokenInspection: Boolean(input.recommendedCommands.inspectToken),
10539
+ includesPaymasterTokenDiscovery: Boolean(
10540
+ input.recommendedCommands.discoverPaymasterTokens
10541
+ ),
10542
+ includesPaymasterTokenInspection: Boolean(
10543
+ input.recommendedCommands.inspectPaymasterToken
10544
+ )
10545
+ };
10546
+ }
10412
10547
  function walletNextLines(summary) {
10413
10548
  const lines = [
10414
10549
  ["wallet", summary.walletName],
@@ -10443,7 +10578,7 @@ var defaultProvider = new ZkSyncWalletProvider();
10443
10578
  var defaultDefiProvider = new ZkSyncDefiProvider({
10444
10579
  walletWriter: defaultProvider
10445
10580
  });
10446
- function workflowIntentSupportsTokenDiscovery(intent) {
10581
+ function workflowIntentSupportsTokenDiscovery2(intent) {
10447
10582
  return intent === "send-token" || intent === "swap" || intent === "bridge" || intent === "deposit" || intent === "withdraw";
10448
10583
  }
10449
10584
  function buildTopLevelWorkflowRecommendedCommands(input) {
@@ -10457,7 +10592,7 @@ function buildTopLevelWorkflowRecommendedCommands(input) {
10457
10592
  delete: buildWorkflowDeleteRecommendedCommand(input.requestId),
10458
10593
  walletStatus: buildWalletStatusRecommendedCommand(input.walletName),
10459
10594
  ...input.nextAction ? { nextAction: input.nextAction } : {},
10460
- ...workflowIntentSupportsTokenDiscovery(input.intent) ? {
10595
+ ...workflowIntentSupportsTokenDiscovery2(input.intent) ? {
10461
10596
  discoverAssets: buildAssetsRecommendedCommand(input.walletName),
10462
10597
  discoverOwnedTokens: buildOwnedTokensRecommendedCommand(input.walletName),
10463
10598
  discoverTokens: buildTokensRecommendedCommand(input.chain),
@@ -10565,6 +10700,14 @@ function createNextCommand(deps) {
10565
10700
  intent: result.intent,
10566
10701
  paymasterMode: extractCheckpointPaymasterMode(updatedCheckpoint)
10567
10702
  });
10703
+ const tokenDiscoverySummary2 = buildWalletTokenDiscoverySummary({
10704
+ walletName: wallet2.walletName,
10705
+ chain: result.plan.chain,
10706
+ intent: result.intent,
10707
+ nextAction: nextCommand2,
10708
+ paymasterMode: extractCheckpointPaymasterMode(updatedCheckpoint),
10709
+ recommendedCommands: recommendedCommands2
10710
+ });
10568
10711
  const workflowAgentProfile = await loadAgentIdentitySummary(wallet2.walletName);
10569
10712
  const agentFollowup2 = buildAgentFollowup(workflowAgentProfile, {
10570
10713
  walletName: wallet2.walletName,
@@ -10599,6 +10742,7 @@ function createNextCommand(deps) {
10599
10742
  agentFollowup: agentFollowup2,
10600
10743
  result,
10601
10744
  checkpoint: updatedCheckpoint,
10745
+ tokenDiscoverySummary: tokenDiscoverySummary2,
10602
10746
  recommendedCommands: recommendedCommands2
10603
10747
  }
10604
10748
  );
@@ -10721,6 +10865,13 @@ function createNextCommand(deps) {
10721
10865
  nextAction: nextCommand,
10722
10866
  inspectDefaults: buildDefaultsRecommendedCommand()
10723
10867
  };
10868
+ const tokenDiscoverySummary = buildWalletTokenDiscoverySummary({
10869
+ walletName: wallet.walletName,
10870
+ chain: wallet.chain,
10871
+ nextAction: nextCommand,
10872
+ paymasterMode,
10873
+ recommendedCommands
10874
+ });
10724
10875
  printResult(
10725
10876
  topLevelNextLines("wallet", [
10726
10877
  ...walletNextLines(summary),
@@ -10744,6 +10895,7 @@ function createNextCommand(deps) {
10744
10895
  inspection,
10745
10896
  summary,
10746
10897
  nextCommand,
10898
+ tokenDiscoverySummary,
10747
10899
  recommendedCommands
10748
10900
  }
10749
10901
  );
@@ -11036,6 +11188,80 @@ function createAgentCommand() {
11036
11188
 
11037
11189
  // src/commands/defaults.ts
11038
11190
  import { Command as Command5 } from "commander";
11191
+ function inferPrimaryDiscoveryChain(defaults) {
11192
+ return defaults.defaultSelections.paymaster.validatedDefault?.chain || defaults.defaultSelections.swap.validatedDefault?.chain || defaults.defaultSelections.bridge.validatedWithdraw?.fromChain || defaults.defaultSelections.bridge.validatedDeposit?.toChain || defaults.validated.feeTokenEraVm?.chain || defaults.builtinChains.find((chain) => chain.key === "zksync-sepolia")?.key || defaults.builtinChains[0]?.key || "zksync-sepolia";
11193
+ }
11194
+ function inferExampleTokenSymbol(defaults) {
11195
+ return defaults.defaultSelections.swap.validatedDefault?.trackedTokenA.symbol || defaults.defaultSelections.paymaster.validatedApprovalBased?.feeTokenSymbol || defaults.validated.feeTokenEraVm?.symbol || defaults.registry.tokens.find((entry) => entry.symbol?.trim())?.symbol || "USDC";
11196
+ }
11197
+ function inferPaymasterFeeTokenSymbol(defaults) {
11198
+ return defaults.defaultSelections.paymaster.validatedApprovalBased?.feeTokenSymbol || defaults.validated.feeTokenEraVm?.symbol || null;
11199
+ }
11200
+ function buildDefaultsRecommendedCommands(defaults) {
11201
+ const primaryChain = inferPrimaryDiscoveryChain(defaults);
11202
+ const exampleSymbol = inferExampleTokenSymbol(defaults);
11203
+ const paymasterFeeTokenSymbol = inferPaymasterFeeTokenSymbol(defaults) || exampleSymbol;
11204
+ return {
11205
+ inspectDefaults: buildDefaultsRecommendedCommand(),
11206
+ discoverTokens: buildTokensRecommendedCommand(primaryChain),
11207
+ inspectToken: buildResolveTokenRecommendedCommand(primaryChain, exampleSymbol),
11208
+ discoverPaymasterTokens: buildPaymasterFeeTokensRecommendedCommand(primaryChain),
11209
+ inspectPaymasterToken: buildPaymasterFeeTokenResolveRecommendedCommand(
11210
+ primaryChain,
11211
+ paymasterFeeTokenSymbol
11212
+ )
11213
+ };
11214
+ }
11215
+ function buildDefaultsSummary(input) {
11216
+ const { defaults, localTokenRegistry, tokenRegistrySources, tokenDirectoryChains } = input;
11217
+ const primaryChain = inferPrimaryDiscoveryChain(defaults);
11218
+ const exampleTokenSymbol = inferExampleTokenSymbol(defaults);
11219
+ const paymasterFeeTokenSymbol = inferPaymasterFeeTokenSymbol(defaults);
11220
+ return {
11221
+ primaryDiscoveryChain: primaryChain,
11222
+ exampleTokenSymbol,
11223
+ paymasterFeeTokenSymbol,
11224
+ localTokenCount: localTokenRegistry.length,
11225
+ tokenDirectoryChainCount: tokenDirectoryChains.length,
11226
+ tokenRegistrySources: tokenRegistrySources.map((source) => ({
11227
+ id: source.id,
11228
+ enabled: source.enabled,
11229
+ exists: source.exists
11230
+ })),
11231
+ resolvedDefaults: {
11232
+ swap: defaults.defaultSelections.swap.validatedDefault ? {
11233
+ entryId: defaults.defaultSelections.swap.validatedDefault.entryId,
11234
+ chain: defaults.defaultSelections.swap.validatedDefault.chain,
11235
+ protocol: defaults.defaultSelections.swap.validatedDefault.protocol,
11236
+ status: defaults.defaultSelections.swap.validatedDefault.status
11237
+ } : null,
11238
+ bridgeDeposit: defaults.defaultSelections.bridge.validatedDeposit ? {
11239
+ entryId: defaults.defaultSelections.bridge.validatedDeposit.entryId,
11240
+ fromChain: defaults.defaultSelections.bridge.validatedDeposit.fromChain,
11241
+ toChain: defaults.defaultSelections.bridge.validatedDeposit.toChain,
11242
+ status: defaults.defaultSelections.bridge.validatedDeposit.status
11243
+ } : null,
11244
+ bridgeWithdraw: defaults.defaultSelections.bridge.validatedWithdraw ? {
11245
+ entryId: defaults.defaultSelections.bridge.validatedWithdraw.entryId,
11246
+ fromChain: defaults.defaultSelections.bridge.validatedWithdraw.fromChain,
11247
+ toChain: defaults.defaultSelections.bridge.validatedWithdraw.toChain,
11248
+ status: defaults.defaultSelections.bridge.validatedWithdraw.status,
11249
+ requiresFinalize: defaults.defaultSelections.bridge.validatedWithdraw.requiresFinalize
11250
+ } : null,
11251
+ paymasterDefault: defaults.defaultSelections.paymaster.validatedDefault ? {
11252
+ entryId: defaults.defaultSelections.paymaster.validatedDefault.entryId,
11253
+ chain: defaults.defaultSelections.paymaster.validatedDefault.chain,
11254
+ mode: defaults.defaultSelections.paymaster.validatedDefault.mode,
11255
+ status: defaults.defaultSelections.paymaster.validatedDefault.status
11256
+ } : null,
11257
+ paymasterByMode: {
11258
+ none: defaults.defaultSelections.paymaster.validatedNone?.entryId || null,
11259
+ sponsored: defaults.defaultSelections.paymaster.validatedSponsored?.entryId || null,
11260
+ approvalBased: defaults.defaultSelections.paymaster.validatedApprovalBased?.entryId || null
11261
+ }
11262
+ }
11263
+ };
11264
+ }
11039
11265
  function formatTrackedTokenSummary(token) {
11040
11266
  if (!token.address) return null;
11041
11267
  const label = token.symbol || token.address;
@@ -11531,14 +11757,34 @@ function createDefaultsCommand() {
11531
11757
  const localTokenRegistry = listLocalTokenRegistryEntries();
11532
11758
  const tokenRegistrySources = describeDefaultTokenRegistrySources();
11533
11759
  const tokenDirectoryChains = await listTokenDirectoryIndexedChains();
11760
+ const recommendedCommands = buildDefaultsRecommendedCommands(defaults);
11761
+ const summary = buildDefaultsSummary({
11762
+ defaults,
11763
+ localTokenRegistry,
11764
+ tokenRegistrySources,
11765
+ tokenDirectoryChains
11766
+ });
11534
11767
  const lines = buildDefaultsLines({
11535
11768
  defaults,
11536
11769
  localTokenRegistry,
11537
11770
  tokenRegistrySources,
11538
11771
  tokenDirectoryChains
11539
11772
  });
11773
+ lines.push([
11774
+ "next discovery chain",
11775
+ summary.primaryDiscoveryChain
11776
+ ]);
11777
+ lines.push([
11778
+ "example token",
11779
+ summary.exampleTokenSymbol
11780
+ ]);
11781
+ if (summary.paymasterFeeTokenSymbol) {
11782
+ lines.push(["paymaster fee token symbol", summary.paymasterFeeTokenSymbol]);
11783
+ }
11540
11784
  printResult(lines, {
11541
11785
  ok: true,
11786
+ summary,
11787
+ recommendedCommands,
11542
11788
  defaults,
11543
11789
  localTokenRegistry,
11544
11790
  tokenRegistrySources,
@@ -11584,6 +11830,26 @@ async function resolveActiveChain(options, deps) {
11584
11830
  }
11585
11831
  );
11586
11832
  }
11833
+ function buildResolveTokenDiscoverySummary(result) {
11834
+ return {
11835
+ chain: result.chainKey,
11836
+ chainId: result.chainId,
11837
+ queryType: result.queryType,
11838
+ query: result.queryType === "symbol" ? result.symbol || null : result.address || null,
11839
+ roleFilter: result.role || null,
11840
+ sourceFilter: result.source || null,
11841
+ matchCount: result.matchCount,
11842
+ ambiguous: result.ambiguous,
11843
+ primarySymbol: result.primaryMatch?.symbol || null,
11844
+ primaryAddress: result.primaryMatch?.address || null,
11845
+ primaryDecimals: result.primaryMatch?.decimals ?? null,
11846
+ primarySource: result.primaryMatch?.source || (result.primaryMatch ? "unknown" : null),
11847
+ sourceCounts: summarizeDiscoveryEntrySources(result.matches),
11848
+ roleMatchCounts: summarizeDiscoveryRoleMatches(result.matches),
11849
+ currentDefaultEntryCount: countCurrentValidatedDefaultEntries(result.matches),
11850
+ tokenRegistrySources: summarizeTokenRegistrySources(result.tokenRegistrySources)
11851
+ };
11852
+ }
11587
11853
  function createResolveTokenCommand(deps) {
11588
11854
  const resolvedDeps = resolveResolveTokenCommandDeps(deps);
11589
11855
  return new Command6("resolve-token").description("Resolve a token symbol or address against the configured local-first token registry").addHelpText(
@@ -11688,6 +11954,7 @@ function createResolveTokenCommand(deps) {
11688
11954
  lines.push(...workflowFollowupLines(recommendedCommands));
11689
11955
  printResult(lines, {
11690
11956
  ok: true,
11957
+ discoverySummary: buildResolveTokenDiscoverySummary(result),
11691
11958
  recommendedCommands,
11692
11959
  ...result
11693
11960
  });
@@ -11807,6 +12074,46 @@ function ownedTokenSummaryLines2(summary) {
11807
12074
  }
11808
12075
  return lines;
11809
12076
  }
12077
+ function buildOwnedTokensDiscoverySummary(result) {
12078
+ return {
12079
+ mode: "owned-registry-erc20",
12080
+ walletName: result.walletName,
12081
+ chainScope: result.chainFilter.chainKey,
12082
+ chainCount: 1,
12083
+ entryCount: result.entryCount,
12084
+ symbolFilter: result.symbol || null,
12085
+ roleFilter: result.role || null,
12086
+ sourceFilter: result.source || null,
12087
+ primarySymbol: firstDiscoverySymbol(result.entries),
12088
+ primarySource: firstDiscoverySource(result.entries),
12089
+ sourceCounts: result.summary.sourceCounts,
12090
+ roleMatchCounts: result.summary.registryRoleCounts,
12091
+ currentDefaultEntryCount: countCurrentValidatedDefaultEntries(result.entries),
12092
+ probeFailureCount: result.probeFailureCount,
12093
+ bridgeMappingCounts: result.summary.bridgeMappingCounts,
12094
+ tokenRegistrySources: summarizeTokenRegistrySources(result.tokenRegistrySources)
12095
+ };
12096
+ }
12097
+ function buildTokenDiscoverySummary(result) {
12098
+ return {
12099
+ mode: "discoverable",
12100
+ walletName: null,
12101
+ chainScope: result.chainFilter?.chainKey || "all-built-in-chains",
12102
+ chainCount: result.chainFilter ? 1 : listUniqueDiscoveryChains(result.entries).length,
12103
+ entryCount: result.entryCount,
12104
+ symbolFilter: result.symbol || null,
12105
+ roleFilter: result.role || null,
12106
+ sourceFilter: result.source || null,
12107
+ primarySymbol: firstDiscoverySymbol(result.entries),
12108
+ primarySource: firstDiscoverySource(result.entries),
12109
+ sourceCounts: summarizeDiscoveryEntrySources(result.entries),
12110
+ roleMatchCounts: summarizeDiscoveryRoleMatches(result.entries),
12111
+ currentDefaultEntryCount: countCurrentValidatedDefaultEntries(result.entries),
12112
+ probeFailureCount: null,
12113
+ bridgeMappingCounts: null,
12114
+ tokenRegistrySources: summarizeTokenRegistrySources(result.tokenRegistrySources)
12115
+ };
12116
+ }
11810
12117
  function createTokensCommand(deps) {
11811
12118
  const resolvedDeps = resolveTokensCommandDeps(deps);
11812
12119
  return new Command7("tokens").description("List discoverable tokens from the configured local-first token registry, or inspect the owned ERC-20 registry subset for one wallet").addHelpText(
@@ -11940,6 +12247,7 @@ function createTokensCommand(deps) {
11940
12247
  lines2.push(...workflowFollowupLines(recommendedCommands2));
11941
12248
  printResult(lines2, {
11942
12249
  ok: true,
12250
+ discoverySummary: buildOwnedTokensDiscoverySummary(result2),
11943
12251
  recommendedCommands: recommendedCommands2,
11944
12252
  ...result2
11945
12253
  });
@@ -11995,6 +12303,7 @@ function createTokensCommand(deps) {
11995
12303
  lines.push(...workflowFollowupLines(recommendedCommands));
11996
12304
  printResult(lines, {
11997
12305
  ok: true,
12306
+ discoverySummary: buildTokenDiscoverySummary(result),
11998
12307
  recommendedCommands,
11999
12308
  ...result
12000
12309
  });
@@ -12672,6 +12981,20 @@ function relayOriginRelationshipNotes(options) {
12672
12981
  }
12673
12982
  return notes;
12674
12983
  }
12984
+ function buildRelayDeploymentSummary(options) {
12985
+ return {
12986
+ origin: options.origin,
12987
+ publicOrigin: options.publicOrigin,
12988
+ publicOriginSource: options.publicOriginSource,
12989
+ shareLinkBaseUrl: options.shareLinkBaseUrl,
12990
+ statusApiBaseUrl: options.statusApiBaseUrl,
12991
+ publicOriginConfigured: options.publicOriginSource === "configured",
12992
+ publicOriginLooksLocal: options.publicOriginLooksLocal,
12993
+ connectorUiAvailable: options.connectorUiAvailable,
12994
+ hostedShareRedirectReady: options.hostedShareRedirectReady,
12995
+ singleHostFileState: options.stateBackend === "local-filesystem" && options.deploymentScope === "single-host" && options.sameHostRestartPersists === true
12996
+ };
12997
+ }
12675
12998
  function buildRelayInspectPayload(relayUrl, rawHealth) {
12676
12999
  const health = asRelayHealthResponse(rawHealth);
12677
13000
  const fallbackPublicOrigin = isRecord3(rawHealth) && typeof rawHealth.public_origin === "string" ? rawHealth.public_origin : relayUrl;
@@ -12690,6 +13013,19 @@ function buildRelayInspectPayload(relayUrl, rawHealth) {
12690
13013
  const publicOriginLooksLocal = relayPublicOriginLooksLocal(publicOrigin);
12691
13014
  const hostedShareRedirectReady = compatible && connectorUiAvailable === true && !publicOriginLooksLocal;
12692
13015
  const { shareLinkBaseUrl, statusApiBaseUrl } = buildAdvertisedRelayBases(publicOrigin);
13016
+ const deploymentSummary = buildRelayDeploymentSummary({
13017
+ origin: health?.origin || null,
13018
+ publicOrigin,
13019
+ publicOriginSource,
13020
+ shareLinkBaseUrl,
13021
+ statusApiBaseUrl,
13022
+ publicOriginLooksLocal,
13023
+ connectorUiAvailable,
13024
+ hostedShareRedirectReady,
13025
+ stateBackend,
13026
+ deploymentScope,
13027
+ sameHostRestartPersists
13028
+ });
12693
13029
  const notes = [
12694
13030
  ...relayHostedReadinessNotes({
12695
13031
  compatible,
@@ -12731,6 +13067,7 @@ function buildRelayInspectPayload(relayUrl, rawHealth) {
12731
13067
  publicOriginLooksLocal,
12732
13068
  connectorUiAvailable,
12733
13069
  hostedShareRedirectReady,
13070
+ deploymentSummary,
12734
13071
  capabilities: health?.capabilities || [],
12735
13072
  recommendedCommands: compatible ? buildRelayServeRecommendedCommands(publicOrigin) : {},
12736
13073
  notes
@@ -12776,6 +13113,19 @@ function createRelayCommand() {
12776
13113
  const hostedShareRedirectReady = connectorUiAvailable && !publicOriginLooksLocal;
12777
13114
  const { shareLinkBaseUrl, statusApiBaseUrl } = buildAdvertisedRelayBases(publicOrigin);
12778
13115
  const recommendedCommands = buildRelayServeRecommendedCommands(publicOrigin);
13116
+ const deploymentSummary = buildRelayDeploymentSummary({
13117
+ origin: server.origin,
13118
+ publicOrigin,
13119
+ publicOriginSource,
13120
+ shareLinkBaseUrl,
13121
+ statusApiBaseUrl,
13122
+ publicOriginLooksLocal,
13123
+ connectorUiAvailable,
13124
+ hostedShareRedirectReady,
13125
+ stateBackend: "local-filesystem",
13126
+ deploymentScope: "single-host",
13127
+ sameHostRestartPersists: true
13128
+ });
12779
13129
  const notes = relayHostedReadinessNotes({
12780
13130
  compatible: true,
12781
13131
  publicOrigin,
@@ -12794,6 +13144,7 @@ function createRelayCommand() {
12794
13144
  shareLinkBaseUrl,
12795
13145
  statusApiBaseUrl,
12796
13146
  publicOriginLooksLocal,
13147
+ deploymentSummary,
12797
13148
  port: server.port,
12798
13149
  healthUrl: `${server.origin}/health`,
12799
13150
  publicHealthUrl: `${publicOrigin}/health`,
@@ -13536,6 +13887,39 @@ function relayOutputAliases(relay) {
13536
13887
  relayStatusApiBaseUrl: statusApiBaseUrl
13537
13888
  };
13538
13889
  }
13890
+ function determineRelayRecoveryMode(options) {
13891
+ if (options.recommendedCommands.reissueRemoteApproval && options.nextAction === options.recommendedCommands.reissueRemoteApproval) {
13892
+ return "reissue-remote-approval";
13893
+ }
13894
+ if (options.recommendedCommands.relayInspect && options.nextAction === options.recommendedCommands.relayInspect) {
13895
+ return "inspect-relay";
13896
+ }
13897
+ if (options.recommendedCommands.approve && options.nextAction === options.recommendedCommands.approve) {
13898
+ return "approve";
13899
+ }
13900
+ return "status-poll";
13901
+ }
13902
+ function buildRelayRecoverySummary(options) {
13903
+ const aliases = relayOutputAliases(options.relay);
13904
+ return {
13905
+ requestId: options.requestId,
13906
+ walletName: options.walletName || null,
13907
+ relayUrl: options.relayUrl,
13908
+ relayStatus: options.relayStatus ?? options.relay?.status ?? null,
13909
+ approvalReady: typeof options.approvalReady === "boolean" ? options.approvalReady : options.relay && "approval_ready" in options.relay ? options.relay.approval_ready : null,
13910
+ nextAction: options.nextAction,
13911
+ shareLinkBaseUrl: aliases.relayShareLinkBaseUrl || null,
13912
+ statusApiBaseUrl: aliases.relayStatusApiBaseUrl || null,
13913
+ recoveryMode: determineRelayRecoveryMode({
13914
+ nextAction: options.nextAction,
13915
+ recommendedCommands: options.recommendedCommands
13916
+ }),
13917
+ includesStatusPoll: Boolean(options.recommendedCommands.status),
13918
+ includesApprove: Boolean(options.recommendedCommands.approve),
13919
+ includesRelayInspect: Boolean(options.recommendedCommands.relayInspect),
13920
+ includesRemoteReissue: Boolean(options.recommendedCommands.reissueRemoteApproval)
13921
+ };
13922
+ }
13539
13923
  function sanitizeWalletRequestRecord(request) {
13540
13924
  const { sessionSecretKey: _sessionSecretKey, ...rest } = request;
13541
13925
  return rest;
@@ -14913,6 +15297,18 @@ function buildRelayApprovalTimeoutError(options) {
14913
15297
  retryable: true,
14914
15298
  statusCommand,
14915
15299
  approveCommand,
15300
+ relayRecoverySummary: buildRelayRecoverySummary({
15301
+ requestId: options.requestId,
15302
+ walletName: options.walletName,
15303
+ relayUrl: options.relayUrl,
15304
+ relayStatus: null,
15305
+ approvalReady: null,
15306
+ nextAction: statusCommand,
15307
+ recommendedCommands: {
15308
+ status: statusCommand,
15309
+ approve: approveCommand
15310
+ }
15311
+ }),
14916
15312
  suggestedAction: "Check the current relay status, then finalize the wallet approval once approval_ready=true."
14917
15313
  }
14918
15314
  );
@@ -14934,6 +15330,15 @@ async function buildRelayApprovalExpiredError(options) {
14934
15330
  note: recovery.note,
14935
15331
  relayInspectCommand: recovery.recommendedCommands.relayInspect,
14936
15332
  reissueRemoteApprovalCommand: recovery.recommendedCommands.reissueRemoteApproval,
15333
+ relayRecoverySummary: buildRelayRecoverySummary({
15334
+ requestId: options.requestId,
15335
+ walletName: options.walletName,
15336
+ relayUrl: options.relayUrl,
15337
+ relayStatus: "expired",
15338
+ approvalReady: false,
15339
+ nextAction: recovery.nextAction,
15340
+ recommendedCommands: recovery.recommendedCommands
15341
+ }),
14937
15342
  suggestedAction: "Inspect the hosted relay, then reissue the remote approval request."
14938
15343
  }
14939
15344
  );
@@ -14958,6 +15363,17 @@ function buildRelayApprovalNotReadyError(options) {
14958
15363
  retryable: true,
14959
15364
  statusCommand,
14960
15365
  approveCommand,
15366
+ relayRecoverySummary: buildRelayRecoverySummary({
15367
+ requestId: options.requestId,
15368
+ relayUrl: options.relayUrl,
15369
+ relayStatus: options.status,
15370
+ approvalReady: options.approvalReady,
15371
+ nextAction: statusCommand,
15372
+ recommendedCommands: {
15373
+ status: statusCommand,
15374
+ approve: approveCommand
15375
+ }
15376
+ }),
14961
15377
  suggestedAction: "Check the current relay status, then retry approval once approval_ready=true."
14962
15378
  }
14963
15379
  );
@@ -15137,6 +15553,7 @@ async function finalizePublishedRelayWalletRequest(options) {
15137
15553
  if (error instanceof Error && error.message.startsWith("Timed out waiting for relay approval after ")) {
15138
15554
  throw buildRelayApprovalTimeoutError({
15139
15555
  requestId: options.walletRequest.requestId,
15556
+ walletName: options.walletRequest.walletName,
15140
15557
  relayUrl: options.relayUrl,
15141
15558
  timeoutMs: options.timeoutMs,
15142
15559
  intervalMs: options.intervalMs
@@ -15737,6 +16154,20 @@ function createWalletCommand(deps) {
15737
16154
  options.relayUrl,
15738
16155
  request2.requestedPaymasterMode
15739
16156
  );
16157
+ const nextAction = buildPendingRequestNextAction(recommendedCommands);
16158
+ const relayRecoverySummary = relay && recommendedCommands.relayStatus && recommendedCommands.relayApprove ? buildRelayRecoverySummary({
16159
+ requestId: request2.requestId,
16160
+ walletName: request2.walletName,
16161
+ relayUrl: options.relayUrl,
16162
+ relayStatus: relay.status,
16163
+ approvalReady: null,
16164
+ nextAction,
16165
+ recommendedCommands: {
16166
+ status: recommendedCommands.relayStatus,
16167
+ approve: recommendedCommands.relayApprove
16168
+ },
16169
+ relay
16170
+ }) : void 0;
15740
16171
  printResult(
15741
16172
  [
15742
16173
  ["wallet", request2.walletName],
@@ -15779,6 +16210,7 @@ function createWalletCommand(deps) {
15779
16210
  approvalUrl: request2.approvalUrl,
15780
16211
  relay,
15781
16212
  ...relayOutputAliases(relay),
16213
+ relayRecoverySummary,
15782
16214
  expiresAt: request2.expiresAt,
15783
16215
  chain: request2.chain,
15784
16216
  chainId: request2.chainId,
@@ -15786,7 +16218,7 @@ function createWalletCommand(deps) {
15786
16218
  paymasterMode: request2.requestedPaymasterMode,
15787
16219
  capabilities: request2.requestedCapabilities,
15788
16220
  sessionScope: request2.requestedSessionScope,
15789
- nextAction: buildPendingRequestNextAction(recommendedCommands),
16221
+ nextAction,
15790
16222
  recommendedCommands
15791
16223
  }
15792
16224
  );
@@ -15902,6 +16334,20 @@ function createWalletCommand(deps) {
15902
16334
  options.relayUrl,
15903
16335
  request2.requestedPaymasterMode
15904
16336
  );
16337
+ const nextAction = buildPendingRequestNextAction(recommendedCommands);
16338
+ const relayRecoverySummary = relay && recommendedCommands.relayStatus && recommendedCommands.relayApprove ? buildRelayRecoverySummary({
16339
+ requestId: request2.requestId,
16340
+ walletName: request2.walletName,
16341
+ relayUrl: options.relayUrl,
16342
+ relayStatus: relay.status,
16343
+ approvalReady: null,
16344
+ nextAction,
16345
+ recommendedCommands: {
16346
+ status: recommendedCommands.relayStatus,
16347
+ approve: recommendedCommands.relayApprove
16348
+ },
16349
+ relay
16350
+ }) : void 0;
15905
16351
  printResult(
15906
16352
  [
15907
16353
  ["wallet", request2.walletName],
@@ -15944,7 +16390,8 @@ function createWalletCommand(deps) {
15944
16390
  request: sanitizeWalletRequestRecord(request2),
15945
16391
  relay,
15946
16392
  ...relayOutputAliases(relay),
15947
- nextAction: buildPendingRequestNextAction(recommendedCommands),
16393
+ relayRecoverySummary,
16394
+ nextAction,
15948
16395
  recommendedCommands
15949
16396
  }
15950
16397
  );
@@ -16088,6 +16535,13 @@ function createWalletCommand(deps) {
16088
16535
  walletRecord.walletName,
16089
16536
  summary
16090
16537
  );
16538
+ const tokenDiscoverySummary = buildWalletTokenDiscoverySummary({
16539
+ walletName: walletRecord.walletName,
16540
+ chain: summary.chain,
16541
+ nextAction: summary.recommendedCommand,
16542
+ paymasterMode: resolveEffectivePaymasterSelection(walletRecord)?.mode,
16543
+ recommendedCommands
16544
+ });
16091
16545
  printResult(
16092
16546
  [
16093
16547
  ...walletNextLines(summary),
@@ -16101,6 +16555,7 @@ function createWalletCommand(deps) {
16101
16555
  ok: true,
16102
16556
  inspection,
16103
16557
  summary,
16558
+ tokenDiscoverySummary,
16104
16559
  recommendedCommands
16105
16560
  }
16106
16561
  );
@@ -16264,6 +16719,30 @@ function createWalletCommand(deps) {
16264
16719
  request.command("relay-publish").description("Publish a stored wallet request to a relay server and get a shareable approval URL").requiredOption("--request-id <id>", "Wallet request id").requiredOption("--relay-url <url>", "Relay server base URL").action(async (options) => {
16265
16720
  const walletRequest = await requireActiveWalletRequest(options.requestId);
16266
16721
  const relay = await publishWalletRequestToRelay(walletRequest, options.relayUrl);
16722
+ const nextAction = buildWalletRequestRelayStatusRecommendedCommand(
16723
+ relay.request_id,
16724
+ options.relayUrl
16725
+ );
16726
+ const recommendedCommands = {
16727
+ status: buildWalletRequestRelayStatusRecommendedCommand(
16728
+ relay.request_id,
16729
+ options.relayUrl
16730
+ ),
16731
+ approve: buildWalletRequestRelayApproveRecommendedCommand(
16732
+ relay.request_id,
16733
+ options.relayUrl
16734
+ )
16735
+ };
16736
+ const relayRecoverySummary = buildRelayRecoverySummary({
16737
+ requestId: relay.request_id,
16738
+ walletName: walletRequest.walletName,
16739
+ relayUrl: options.relayUrl,
16740
+ relayStatus: relay.status,
16741
+ approvalReady: null,
16742
+ nextAction,
16743
+ recommendedCommands,
16744
+ relay
16745
+ });
16267
16746
  printResult(
16268
16747
  [
16269
16748
  ["status", relay.status],
@@ -16272,26 +16751,25 @@ function createWalletCommand(deps) {
16272
16751
  ["status url", relay.status_url],
16273
16752
  ["share-link base", relay.share_url.replace(/\/[^/]+$/, "")],
16274
16753
  ["status api base", relay.status_url.replace(/\/[^/]+$/, "")],
16275
- ["next status", buildWalletRequestRelayStatusRecommendedCommand(relay.request_id, options.relayUrl)],
16276
- ["next approve", buildWalletRequestRelayApproveRecommendedCommand(relay.request_id, options.relayUrl)]
16754
+ ["next status", recommendedCommands.status],
16755
+ ["next approve", recommendedCommands.approve]
16277
16756
  ],
16278
16757
  {
16279
16758
  ok: true,
16280
16759
  walletRequestId: walletRequest.requestId,
16281
16760
  relay,
16282
16761
  ...relayOutputAliases(relay),
16762
+ relayRecoverySummary,
16283
16763
  request: sanitizeWalletRequestRecord(walletRequest),
16284
- nextAction: buildWalletRequestRelayStatusRecommendedCommand(relay.request_id, options.relayUrl),
16285
- recommendedCommands: {
16286
- status: buildWalletRequestRelayStatusRecommendedCommand(relay.request_id, options.relayUrl),
16287
- approve: buildWalletRequestRelayApproveRecommendedCommand(relay.request_id, options.relayUrl)
16288
- }
16764
+ nextAction,
16765
+ recommendedCommands
16289
16766
  }
16290
16767
  );
16291
16768
  });
16292
16769
  request.command("relay-status").description("Inspect the relay status of a published wallet request, optionally waiting until approval is ready").requiredOption("--request-id <id>", "Wallet request id").requiredOption("--relay-url <url>", "Relay server base URL").option("--wait", "Poll until the encrypted relay approval is ready or the request expires").option("--timeout-seconds <seconds>", "How long to wait while polling relay status", "600").option("--interval-ms <milliseconds>", "How often to poll relay status while waiting", "2000").action(async (options) => {
16293
16770
  const timeoutMs = parsePositiveIntegerOption(options.timeoutSeconds, "--timeout-seconds", 600) * 1e3;
16294
16771
  const intervalMs = parsePositiveIntegerOption(options.intervalMs, "--interval-ms", 2e3);
16772
+ const walletRequest = await loadWalletRequest(options.requestId);
16295
16773
  let relay;
16296
16774
  try {
16297
16775
  relay = options.wait ? await waitForRelayApprovalReady(options.relayUrl, options.requestId, {
@@ -16302,6 +16780,7 @@ function createWalletCommand(deps) {
16302
16780
  if (options.wait && error instanceof Error && error.message.startsWith("Timed out waiting for relay approval after ")) {
16303
16781
  throw buildRelayApprovalTimeoutError({
16304
16782
  requestId: options.requestId,
16783
+ walletName: walletRequest?.walletName,
16305
16784
  relayUrl: options.relayUrl,
16306
16785
  timeoutMs,
16307
16786
  intervalMs
@@ -16313,6 +16792,16 @@ function createWalletCommand(deps) {
16313
16792
  relay,
16314
16793
  relayUrl: options.relayUrl
16315
16794
  });
16795
+ const relayRecoverySummary = buildRelayRecoverySummary({
16796
+ requestId: relay.request_id,
16797
+ walletName: relay.request?.walletName || walletRequest?.walletName,
16798
+ relayUrl: options.relayUrl,
16799
+ relayStatus: relay.status,
16800
+ approvalReady: relay.approval_ready,
16801
+ nextAction: followUp.nextAction,
16802
+ recommendedCommands: followUp.recommendedCommands,
16803
+ relay
16804
+ });
16316
16805
  printResult(
16317
16806
  [
16318
16807
  ["status", relay.status],
@@ -16334,6 +16823,7 @@ function createWalletCommand(deps) {
16334
16823
  walletRequestId: relay.request_id,
16335
16824
  relay,
16336
16825
  ...relayOutputAliases(relay),
16826
+ relayRecoverySummary,
16337
16827
  nextAction: followUp.nextAction,
16338
16828
  recommendedCommands: followUp.recommendedCommands,
16339
16829
  ...followUp.note ? { note: followUp.note } : {}
@@ -18677,6 +19167,14 @@ async function printWorkflowRunCommandResult(execution) {
18677
19167
  intent: execution.result.intent,
18678
19168
  paymasterMode: execution.walletApproval?.request.requestedPaymasterMode ?? extractWorkflowGoalPaymasterMode(execution.goal)
18679
19169
  });
19170
+ const tokenDiscoverySummary2 = buildWorkflowTokenDiscoverySummary({
19171
+ walletName: execution.result.walletName,
19172
+ chain: execution.result.plan.chain,
19173
+ intent: execution.result.intent,
19174
+ nextAction: execution.result.nextCommand,
19175
+ paymasterMode: execution.walletApproval?.request.requestedPaymasterMode ?? extractWorkflowGoalPaymasterMode(execution.goal),
19176
+ recommendedCommands: recommendedCommands2
19177
+ });
18680
19178
  printResult(
18681
19179
  prependWorkflowRequestId(
18682
19180
  execution.requestId,
@@ -18701,6 +19199,7 @@ async function printWorkflowRunCommandResult(execution) {
18701
19199
  ...workflowWalletApprovalRelayAliases(execution.walletApproval?.relay),
18702
19200
  walletApprovalRecommendedCommands: execution.walletApproval?.recommendedCommands,
18703
19201
  walletApproval: serializeWalletApproval(execution.walletApproval),
19202
+ tokenDiscoverySummary: tokenDiscoverySummary2,
18704
19203
  recommendedCommands: recommendedCommands2
18705
19204
  }
18706
19205
  );
@@ -18719,6 +19218,14 @@ async function printWorkflowRunCommandResult(execution) {
18719
19218
  intent: execution.status.intent,
18720
19219
  paymasterMode: execution.walletApproval?.request.requestedPaymasterMode ?? extractWorkflowGoalPaymasterMode(execution.checkpoint?.goal)
18721
19220
  });
19221
+ const tokenDiscoverySummary = buildWorkflowTokenDiscoverySummary({
19222
+ walletName: execution.status.walletName,
19223
+ chain: execution.status.plan.chain,
19224
+ intent: execution.status.intent,
19225
+ nextAction: execution.status.recommendedCommand,
19226
+ paymasterMode: execution.walletApproval?.request.requestedPaymasterMode ?? extractWorkflowGoalPaymasterMode(execution.checkpoint?.goal),
19227
+ recommendedCommands
19228
+ });
18722
19229
  printResult(
18723
19230
  prependWorkflowRequestId(
18724
19231
  execution.requestId,
@@ -18744,6 +19251,7 @@ async function printWorkflowRunCommandResult(execution) {
18744
19251
  ...workflowWalletApprovalRelayAliases(execution.walletApproval?.relay),
18745
19252
  walletApprovalRecommendedCommands: execution.walletApproval?.recommendedCommands,
18746
19253
  walletApproval: serializeWalletApproval(execution.walletApproval),
19254
+ tokenDiscoverySummary,
18747
19255
  recommendedCommands
18748
19256
  }
18749
19257
  );
@@ -19011,6 +19519,14 @@ async function printWorkflowAutoCommandResult(execution) {
19011
19519
  intent: execution.status.intent,
19012
19520
  paymasterMode: execution.walletApproval?.request.requestedPaymasterMode ?? extractWorkflowGoalPaymasterMode(execution.goal) ?? extractWorkflowGoalPaymasterMode(execution.checkpoint?.goal)
19013
19521
  });
19522
+ const tokenDiscoverySummary = buildWorkflowTokenDiscoverySummary({
19523
+ walletName: execution.status.walletName,
19524
+ chain: execution.status.plan.chain,
19525
+ intent: execution.status.intent,
19526
+ nextAction,
19527
+ paymasterMode: execution.walletApproval?.request.requestedPaymasterMode ?? extractWorkflowGoalPaymasterMode(execution.goal) ?? extractWorkflowGoalPaymasterMode(execution.checkpoint?.goal),
19528
+ recommendedCommands
19529
+ });
19014
19530
  const summaryLines = [
19015
19531
  ["source", execution.source],
19016
19532
  ["action", execution.action],
@@ -19047,6 +19563,7 @@ async function printWorkflowAutoCommandResult(execution) {
19047
19563
  ...workflowWalletApprovalRelayAliases(execution.walletApproval?.relay),
19048
19564
  walletApprovalRecommendedCommands: execution.walletApproval?.recommendedCommands,
19049
19565
  walletApproval: serializeWalletApproval(execution.walletApproval),
19566
+ tokenDiscoverySummary,
19050
19567
  recommendedCommands
19051
19568
  }
19052
19569
  );
@@ -19102,7 +19619,7 @@ function buildWorkflowRuntimeRecommendedCommands(input) {
19102
19619
  ...input.nextAction ? {
19103
19620
  nextAction: input.nextAction
19104
19621
  } : {},
19105
- ...input.chain && input.intent && workflowIntentSupportsTokenDiscovery2(input.intent) ? {
19622
+ ...input.chain && input.intent && workflowIntentSupportsTokenDiscovery3(input.intent) ? {
19106
19623
  ...input.walletName ? {
19107
19624
  discoverAssets: `zk-agent assets --wallet ${input.walletName}`,
19108
19625
  discoverOwnedTokens: `zk-agent tokens --wallet ${input.walletName} --owned`
@@ -19116,16 +19633,54 @@ function buildWorkflowRuntimeRecommendedCommands(input) {
19116
19633
  } : {}
19117
19634
  };
19118
19635
  }
19119
- function workflowIntentSupportsTokenDiscovery2(intent) {
19636
+ function workflowIntentSupportsTokenDiscovery3(intent) {
19120
19637
  return intent === "send-token" || intent === "swap" || intent === "bridge" || intent === "deposit" || intent === "withdraw";
19121
19638
  }
19639
+ function buildWorkflowTokenDiscoverySummary(input) {
19640
+ if (!input.recommendedCommands) {
19641
+ return void 0;
19642
+ }
19643
+ const hasTokenDiscovery = Boolean(input.recommendedCommands.discoverAssets) || Boolean(input.recommendedCommands.discoverOwnedTokens) || Boolean(input.recommendedCommands.discoverTokens) || Boolean(input.recommendedCommands.inspectToken) || Boolean(input.recommendedCommands.discoverPaymasterTokens) || Boolean(input.recommendedCommands.inspectPaymasterToken);
19644
+ if (!hasTokenDiscovery) {
19645
+ return void 0;
19646
+ }
19647
+ return {
19648
+ walletName: input.walletName || null,
19649
+ chain: input.chain || null,
19650
+ intent: input.intent || null,
19651
+ nextAction: input.nextAction || null,
19652
+ paymasterMode: input.paymasterMode || null,
19653
+ tokenizedIntent: input.intent ? workflowIntentSupportsTokenDiscovery3(input.intent) : false,
19654
+ includesAssetDiscovery: Boolean(input.recommendedCommands.discoverAssets),
19655
+ includesOwnedTokenDiscovery: Boolean(input.recommendedCommands.discoverOwnedTokens),
19656
+ includesChainTokenDiscovery: Boolean(input.recommendedCommands.discoverTokens),
19657
+ includesDirectTokenInspection: Boolean(input.recommendedCommands.inspectToken),
19658
+ includesPaymasterTokenDiscovery: Boolean(
19659
+ input.recommendedCommands.discoverPaymasterTokens
19660
+ ),
19661
+ includesPaymasterTokenInspection: Boolean(
19662
+ input.recommendedCommands.inspectPaymasterToken
19663
+ )
19664
+ };
19665
+ }
19666
+ function buildWorkflowTokenInputErrorSummary(input) {
19667
+ return {
19668
+ chain: input.chain || null,
19669
+ queryType: input.tokenAddress ? "address" : input.symbol ? "symbol" : null,
19670
+ query: input.tokenAddress || input.symbol || null,
19671
+ roleFilter: input.role || null,
19672
+ includesChainTokenDiscovery: Boolean(input.recommendedCommands.discoverTokens),
19673
+ includesDirectTokenInspection: Boolean(input.recommendedCommands.inspectToken),
19674
+ workflowHelp: input.recommendedCommands.workflowHelp
19675
+ };
19676
+ }
19122
19677
  function buildWorkflowPlanRecommendedCommands(plan) {
19123
19678
  return {
19124
19679
  inspectDefaults: "zk-agent defaults",
19125
19680
  next: plan.recommendedCommand,
19126
19681
  goal: plan.goalCommand,
19127
19682
  workflowHelp: "zk-agent workflow --help",
19128
- ...workflowIntentSupportsTokenDiscovery2(plan.intent) ? {
19683
+ ...workflowIntentSupportsTokenDiscovery3(plan.intent) ? {
19129
19684
  discoverAssets: buildAssetsRecommendedCommand(plan.walletName),
19130
19685
  discoverOwnedTokens: buildOwnedTokensRecommendedCommand(plan.walletName),
19131
19686
  discoverTokens: buildTokensRecommendedCommand(plan.chain),
@@ -19169,6 +19724,13 @@ function buildWorkflowTokenErrorRecommendedCommands(error) {
19169
19724
  }
19170
19725
  function printWorkflowTokenInputError(error) {
19171
19726
  const recommendedCommands = buildWorkflowTokenErrorRecommendedCommands(error);
19727
+ const tokenDiscoverySummary = buildWorkflowTokenInputErrorSummary({
19728
+ chain: typeof error.details?.chain === "string" ? error.details.chain : void 0,
19729
+ symbol: typeof error.details?.symbol === "string" ? error.details.symbol : void 0,
19730
+ tokenAddress: typeof error.details?.tokenAddress === "string" ? error.details.tokenAddress : void 0,
19731
+ role: typeof error.details?.role === "string" ? error.details.role : void 0,
19732
+ recommendedCommands
19733
+ });
19172
19734
  const lines = [["error", error.message], ["code", error.code]];
19173
19735
  if (typeof error.details?.suggestedAction === "string" && error.details.suggestedAction.length > 0) {
19174
19736
  lines.push(["suggested action", error.details.suggestedAction]);
@@ -19176,6 +19738,7 @@ function printWorkflowTokenInputError(error) {
19176
19738
  lines.push(...workflowFollowupLines(recommendedCommands));
19177
19739
  printResult(lines, {
19178
19740
  ...formatErrorPayload(error),
19741
+ tokenDiscoverySummary,
19179
19742
  recommendedCommands
19180
19743
  });
19181
19744
  process.exitCode = 1;
@@ -19583,6 +20146,14 @@ function createWorkflowCommand(deps) {
19583
20146
  ...plan,
19584
20147
  paymasterMode: paymasterInput?.mode
19585
20148
  });
20149
+ const tokenDiscoverySummary = buildWorkflowTokenDiscoverySummary({
20150
+ walletName: plan.walletName,
20151
+ chain: plan.chain,
20152
+ intent: plan.intent,
20153
+ paymasterMode: paymasterInput?.mode,
20154
+ nextAction: plan.recommendedCommand,
20155
+ recommendedCommands
20156
+ });
19586
20157
  const agentProfile = await loadWorkflowAgentProfile(plan.walletName);
19587
20158
  const agentFollowup = buildAgentFollowup(agentProfile, {
19588
20159
  walletName: plan.walletName,
@@ -19600,6 +20171,7 @@ function createWorkflowCommand(deps) {
19600
20171
  agentFollowup,
19601
20172
  inspection,
19602
20173
  plan,
20174
+ tokenDiscoverySummary,
19603
20175
  recommendedCommands
19604
20176
  }
19605
20177
  );
@@ -19803,6 +20375,14 @@ function createWorkflowCommand(deps) {
19803
20375
  intent: inspection.result.intent,
19804
20376
  paymasterMode: inspection.walletApproval?.request.requestedPaymasterMode ?? extractWorkflowGoalPaymasterMode(inspection.checkpoint?.goal)
19805
20377
  });
20378
+ const tokenDiscoverySummary = buildWorkflowTokenDiscoverySummary({
20379
+ walletName: inspection.result.walletName,
20380
+ chain: inspection.result.plan.chain,
20381
+ intent: inspection.result.intent,
20382
+ nextAction: inspection.result.recommendedCommand,
20383
+ paymasterMode: inspection.walletApproval?.request.requestedPaymasterMode ?? extractWorkflowGoalPaymasterMode(inspection.checkpoint?.goal),
20384
+ recommendedCommands
20385
+ });
19806
20386
  const agentProfile = await loadWorkflowAgentProfile(inspection.result.walletName);
19807
20387
  const agentFollowup = buildAgentFollowup(agentProfile, {
19808
20388
  walletName: inspection.result.walletName,
@@ -19833,6 +20413,7 @@ function createWorkflowCommand(deps) {
19833
20413
  ...workflowWalletApprovalRelayAliases(inspection.walletApproval?.relay),
19834
20414
  walletApprovalRecommendedCommands: inspection.walletApproval?.recommendedCommands,
19835
20415
  walletApproval: serializeWalletApproval(inspection.walletApproval),
20416
+ tokenDiscoverySummary,
19836
20417
  recommendedCommands
19837
20418
  }
19838
20419
  );
@@ -19855,6 +20436,14 @@ function createWorkflowCommand(deps) {
19855
20436
  intent: inspection.result.intent,
19856
20437
  paymasterMode: inspection.walletApproval?.request.requestedPaymasterMode ?? extractWorkflowGoalPaymasterMode(inspection.checkpoint?.goal)
19857
20438
  });
20439
+ const tokenDiscoverySummary = buildWorkflowTokenDiscoverySummary({
20440
+ walletName: inspection.result.walletName,
20441
+ chain: inspection.result.plan.chain,
20442
+ intent: inspection.result.intent,
20443
+ nextAction: nextCommand,
20444
+ paymasterMode: inspection.walletApproval?.request.requestedPaymasterMode ?? extractWorkflowGoalPaymasterMode(inspection.checkpoint?.goal),
20445
+ recommendedCommands
20446
+ });
19858
20447
  const agentProfile = await loadWorkflowAgentProfile(inspection.result.walletName);
19859
20448
  const agentFollowup = buildAgentFollowup(agentProfile, {
19860
20449
  walletName: inspection.result.walletName,
@@ -19898,6 +20487,7 @@ function createWorkflowCommand(deps) {
19898
20487
  ...workflowWalletApprovalRelayAliases(inspection.walletApproval?.relay),
19899
20488
  walletApprovalRecommendedCommands: inspection.walletApproval?.recommendedCommands,
19900
20489
  walletApproval: serializeWalletApproval(inspection.walletApproval),
20490
+ tokenDiscoverySummary,
19901
20491
  recommendedCommands
19902
20492
  }
19903
20493
  );
@@ -19921,6 +20511,14 @@ function createWorkflowCommand(deps) {
19921
20511
  intent: inspection.result.intent,
19922
20512
  paymasterMode: inspection.walletApproval.request.requestedPaymasterMode
19923
20513
  });
20514
+ const tokenDiscoverySummary2 = buildWorkflowTokenDiscoverySummary({
20515
+ walletName: inspection.result.walletName,
20516
+ chain: inspection.result.plan.chain,
20517
+ intent: inspection.result.intent,
20518
+ nextAction: inspection.result.recommendedCommand,
20519
+ paymasterMode: inspection.walletApproval.request.requestedPaymasterMode,
20520
+ recommendedCommands: recommendedCommands2
20521
+ });
19924
20522
  const agentProfile2 = await loadWorkflowAgentProfile(inspection.result.walletName);
19925
20523
  const agentFollowup2 = buildAgentFollowup(agentProfile2, {
19926
20524
  walletName: inspection.result.walletName,
@@ -19951,6 +20549,7 @@ function createWorkflowCommand(deps) {
19951
20549
  ...workflowWalletApprovalRelayAliases(inspection.walletApproval.relay),
19952
20550
  walletApprovalRecommendedCommands: inspection.walletApproval.recommendedCommands,
19953
20551
  walletApproval: serializeWalletApproval(inspection.walletApproval),
20552
+ tokenDiscoverySummary: tokenDiscoverySummary2,
19954
20553
  recommendedCommands: recommendedCommands2
19955
20554
  }
19956
20555
  );
@@ -19973,6 +20572,14 @@ function createWorkflowCommand(deps) {
19973
20572
  intent: execution.status.intent,
19974
20573
  paymasterMode: execution.walletApproval?.request.requestedPaymasterMode ?? extractWorkflowGoalPaymasterMode(execution.checkpoint?.goal)
19975
20574
  });
20575
+ const tokenDiscoverySummary2 = buildWorkflowTokenDiscoverySummary({
20576
+ walletName: execution.status.walletName,
20577
+ chain: execution.status.plan.chain,
20578
+ intent: execution.status.intent,
20579
+ nextAction: execution.status.recommendedCommand,
20580
+ paymasterMode: execution.walletApproval?.request.requestedPaymasterMode ?? extractWorkflowGoalPaymasterMode(execution.checkpoint?.goal),
20581
+ recommendedCommands: recommendedCommands2
20582
+ });
19976
20583
  const agentProfile2 = await loadWorkflowAgentProfile(execution.status.walletName);
19977
20584
  const agentFollowup2 = buildAgentFollowup(agentProfile2, {
19978
20585
  walletName: execution.status.walletName,
@@ -20003,6 +20610,7 @@ function createWorkflowCommand(deps) {
20003
20610
  ...workflowWalletApprovalRelayAliases(execution.walletApproval?.relay),
20004
20611
  walletApprovalRecommendedCommands: execution.walletApproval?.recommendedCommands,
20005
20612
  walletApproval: serializeWalletApproval(execution.walletApproval),
20613
+ tokenDiscoverySummary: tokenDiscoverySummary2,
20006
20614
  recommendedCommands: recommendedCommands2
20007
20615
  }
20008
20616
  );
@@ -20016,6 +20624,14 @@ function createWorkflowCommand(deps) {
20016
20624
  intent: execution.result.intent,
20017
20625
  paymasterMode: execution.walletApproval?.request.requestedPaymasterMode ?? extractWorkflowGoalPaymasterMode(execution.goal)
20018
20626
  });
20627
+ const tokenDiscoverySummary = buildWorkflowTokenDiscoverySummary({
20628
+ walletName: execution.result.walletName,
20629
+ chain: execution.result.plan.chain,
20630
+ intent: execution.result.intent,
20631
+ nextAction: execution.result.nextCommand,
20632
+ paymasterMode: execution.walletApproval?.request.requestedPaymasterMode ?? extractWorkflowGoalPaymasterMode(execution.goal),
20633
+ recommendedCommands
20634
+ });
20019
20635
  const agentProfile = await loadWorkflowAgentProfile(execution.result.walletName);
20020
20636
  const agentFollowup = buildAgentFollowup(agentProfile, {
20021
20637
  walletName: execution.result.walletName,
@@ -20046,6 +20662,7 @@ function createWorkflowCommand(deps) {
20046
20662
  ...workflowWalletApprovalRelayAliases(inspection.walletApproval?.relay),
20047
20663
  walletApprovalRecommendedCommands: inspection.walletApproval?.recommendedCommands,
20048
20664
  walletApproval: serializeWalletApproval(inspection.walletApproval),
20665
+ tokenDiscoverySummary,
20049
20666
  recommendedCommands
20050
20667
  }
20051
20668
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zk-agent-cli",
3
- "version": "0.1.0-beta.8",
3
+ "version": "0.1.0-beta.9",
4
4
  "description": "Local-first zkSync Era and ZK Stack agent CLI with wallet session recovery, workflow orchestration, relay-backed approval, and SED smart-account support.",
5
5
  "license": "MIT",
6
6
  "type": "module",