Skip to content

feat(ts)!: turn the protocol features into installed plugins and move them out of the package - #1065

Open
gummy789j wants to merge 111 commits into
developfrom
feat/plugin-architecture
Open

gummy789j wants to merge 111 commits into
developfrom
feat/plugin-architecture

Conversation

@gummy789j

Copy link
Copy Markdown
Collaborator

Summary

Protocol features of the TypeScript CLI become plugins a user installs. A plugin adds a command group to the
same executable through one contract; the core keeps wallets, accounts, credentials, configuration, signing,
the transaction lifecycle and the chain-native commands, and no longer knows a feature's commands, options,
error codes or settings. wallet-cli ships no protocol feature and its source names none. Java is unchanged
except for the version: both implementations become 5.0.0.

  • SunSwap, SunPump, GasFree, ERC-8004, x402 and B.AI leave this repository. They are plugins built in their
    own repositories against the same contract.
  • New commands: wallet-cli plugin install <package>, plugin list, plugin update [name],
    plugin uninstall <name>.

What changes for users

  • Every protocol command group needs one install step after upgrading. wallet-cli plugin install with
    the package name of the SunSwap, SunPump, GasFree, ERC-8004, x402 or B.AI plugin brings the commands back
    with the same options and outputs. Wallets, credentials and config.yaml need no change. Without its
    plugin a group answers unknown_command with a pointer to plugin list and plugin install, and the root
    help and --json-schema do not list it. config gives the same pointer for a key such as gasfreeApiKey
    until a plugin that declares it is installed; the value stays in config.yaml.
  • The command group 8004 is named erc8004. wallet-cli 8004 show becomes wallet-cli erc8004 show,
    for all eight commands, and the command value of their envelopes is erc8004.<verb>. There is no alias.
    Options, outputs, error codes and capability keys are unchanged.
  • Each plugin works alone: bai recharge does not need the x402 plugin, and a GasFree payment of x402 or
    bai does not need the GasFree plugin.
  • A plugin installs from an npm registry by its package name only (@scope/name or name, with an
    optional exact version or dist-tag). Without one, the latest dist-tag is installed and the source is
    recorded and shown as name@latest. A directory or a .tgz is refused. The core knows no package scope and
    no short names. wallet-cli does not use npm for this, so the standalone executable needs neither npm nor
    Node; it checks the registry's integrity value before reading a package and never updates a plugin on its
    own. New configuration key pluginRegistry, for a private or local registry.
  • Credential keys belong to the plugins. gasfreeApiKey, gasfreeApiSecret and baiApiKey keep their names
    and their values stay in config.yaml, but config knows a key only while an installed plugin declares
    it. The help of config lists the declared keys with each plugin's summary.
  • Configured credentials are masked in every output, not only in errors. Masked JSON output stays valid JSON.
  • A plugin runs with the same access as wallet-cli. The install output and help say so.
  • Machine interface: a command served by a plugin carries meta.plugin: {name, version}; six new error codes
    (plugin_conflict, plugin_not_installed, plugin_invalid, plugin_incompatible, plugin_integrity,
    plugin_load_failed); the unknown_command message for an unknown first word names the install command;
    the commands and error codes of a protocol feature are in --json-schema only while its plugin is
    installed. The core commands and the envelope are unchanged.
  • x402 serve has its own option for the time one request may take, --request-timeout <ms> (default
    90000, 0 for no limit). The global --timeout now limits only the start-up of the server; a user who tuned
    the request limit through --timeout passes --request-timeout instead.
  • Every error and warning prints the text it printed before.
  • The root help lists the groups of installed plugins in their own section, Plugin Commands:, between
    Management Commands: and Commands:. With no plugin installed the section is absent and the root help is
    unchanged. Group help, command help and --json-schema are unchanged.
  • A plugin declares the plugin SDK versions it works with as a semver range in sdkVersion, as in
    package.json (the build writes ^1.0.0; 1.0.0 is the first plugin SDK version). wallet-cli loads it when its own plugin SDK version is in the
    range, and an incompatible plugin's message names the range, this wallet-cli's SDK version and, when one is
    sure to help, the side to update.

Design

  • ts/src/plugin-sdk/ is the contract: the types a plugin implements, the host services it receives, and
    curated helpers. Every export is part of the contract and pinned by a snapshot (architecture rule 9.7).
  • The core holds no output of a plugin. The agent identity fields of ERC-8004 (receipt fields, text rows, the
    approve receipt) moved into the erc8004 plugin; TxFormatters.txReceipt takes a caller's own rows, and the
    core keeps only the general flag that an approve(address,uint256) names an ERC-721 token id. The output of
    the erc8004 commands is unchanged. Help examples and core tests use a neutral plugin name.
  • The contract holds only what a plugin cannot own: what involves a secret or a privilege, what the core must
    guarantee on every path, what only the core knows, and what the core needs declared for its own work. A
    plugin brings its own clock, request timers and helpers.
  • A plugin is described once, in the walletCli.plugin manifest of its package.json (name, groups,
    credential keys, the range of SDK versions it works with), as a VS Code extension is. Its entry module exports
    one function, register(host).
  • ts/plugin-template/ is a plugin to copy: two commands, a test for each, the esbuild build and the testing
    setup. The SDK README links its files instead of carrying copies.
  • ts/plugin-sdk is publishable as @tron-walletcli/plugin-sdk: public access, and npm publish builds
    its dist first.
  • A plugin declares and the core acts: it registers commands (one Zod schema each), error codes and capability
    predicates; the core parses, runs, prints and sets the exit code.
  • A command is declared one way, with host.command: its fields, an optional refine and one run.
    With families (for example ["tron", "evm"]) it is a chain command: the core resolves the network
    before run, and familyFields may give a family its own options and checks. Without families its
    network is "none" or "optional". The host turns each declaration into the core's own command forms,
    which the SDK does not export.
  • The SDK's names carry no Plugin prefix (Host, Command, CommandContext, SigningService,
    Gateways, ...), as VS Code's extension API names its types: the package already says plugin SDK. The
    core keeps its own names for what is "of a plugin" from its side (PluginLoader, the plugin_* error
    codes), and the testing entry gives the core types that the SDK narrows their own names
    (CoreSigningService, TronGatewayPort, EvmGatewayPort).
  • The contract has one version, the SDK package version. A plugin declares a semver range of SDK versions,
    and the core loads it when its own SDK version satisfies the range, as npm's semver decides; the core adds
    no rule of its own. semver is a new direct dependency, resolved to the root 7.7.3 that Ledger already pins, so it adds no
    installation.
  • A message names commands and options as the text the user reads, in every layer, and the CLI prints it as
    written (architecture rule 7.1, rewritten). The references to inputs and next steps that inbound used to
    spell are gone from the core.
  • Plugins are independent when each installs and works with no other plugin installed (rule 9.1). Plugins of
    one repository may share source that each bundles.
  • A plugin lists the credential keys it reads in its manifest. The core stores them (stdin only, mode 0600,
    masked) and names none of them; a plugin reads only the keys it declared. An error code that only plugins
    raise is declared by each plugin that raises it, also when several do.
  • A plugin never receives a signer, the keystore, the secret resolver or a password. It signs through the
    signing host service, which passes through the one signing entry and its chain identity checks, and it
    submits only through host services that run the transaction lifecycle and the dry-run guard.
  • A plugin package is read in memory with node-tar (tar 7.5.24), the tar parser npm uses, so wallet-cli reads
    the files npm would install. Its own path rule is stricter: ASCII names, at most 32 segments and 255
    characters, no names that differ only in case, no trailing dot or Windows device name, and no links. A
    package outside the rule is refused with plugin_invalid. tar is a new direct dependency with five small
    dependencies of its own.
  • Installed plugins live in <home>/plugins/<name>/ as immutable version directories plus one active.json;
    replacing that file is the commit point of an install or update. A plugin that cannot be loaded affects no
    core command and no other plugin.
  • Plugins build against @tron-walletcli/plugin-sdk (ts/plugin-sdk/, built by npm run build:plugin-sdk).
    A built plugin imports the SDK entries domain, application, cli and http by name, and the core
    answers those imports with its own objects through module.registerHooks, the way VS Code serves vscode
    to an extension. Errors, Zod and services exist once, in the core. The hooks are registered only when a
    command loads a plugin.
  • The standalone executable is a Node single executable application (npm run build:standalone, Node
    26.13.1); Bun is no longer used. The Ledger HID addon is embedded and loaded from a private temporary copy.
    A plugin starts a detached process (x402 serve --daemon) through a host service, in both builds.
  • The core has one way to load a plugin: from the home directory. There is no built-in plugin.
  • Architecture rules: new section 9 in ts/docs/dev/rules/architecture.md.

Also fixed

  • sleepWithin, the wait that confirmation polling and plugins use, could report a full wait when its timer
    fired a moment before the command deadline. It now measures the interval on a monotonic clock.
  • Credential masking ran on error output only, against architecture rule 6.6: a service that echoed an API key
    in a successful response had it printed. The stream writer now masks every write.

Size

dist/index.js shrinks from about 2.8 MB to 1.9 MB. The x402 and ERC-8004 SDK dependencies leave
ts/package.json.

Documentation

ts/docs/guide/plugins.md, ts/docs/commands/plugin/, the Plugins section of ts/docs/machine-interface.md,
and the README. The command pages of the six protocol features and their parts of the machine interface moved
to the plugin repositories.

Verification

  • npm run depcruise, npm run typecheck, npm run lint, npm run format:check, npm run test:unit:
    282 files, 4289 tests.
  • At 4bc3a969, by independent QA, with the six plugins packed and served by a loopback registry: each
    installed alone in an empty home by its package name (state ok, name@latest, only its group, all 40
    command help pages, a live read where no key is needed); directories, ~ paths, .tgz, file: and
    version ranges refused with invalid_value before any request; exact versions, dist-tags and a name ending
    in .tgz with a version installed; a record stored without a version listed as @latest and left
    byte-identical by an unchanged update; records from a local directory or archive listed as broken and
    uninstalled while the other plugins and the core kept working. The Node executable, with neither npm nor
    Node on PATH, installed, ran, updated and uninstalled one plugin of each repository and refused a
    package whose integrity value did not match.
  • The package reader, by independent review and QA at 46aa11fa: the six published plugins read the same files
    and bytes as npm's extraction; crafted archives (drive and colon paths, a newline in a path, a
    400,000-character path, names that differ only in case, link targets, symbolic links, a path that is both a
    file and a directory) are refused with plugin_invalid and leave no plugin directory; text output keeps
    each message on one line and shortens a long path.
  • The full regression suite at 7d052bd0, by independent QA on Nile with a Ledger emulator: 962 cases passed;
    4 differ from the suite's expectation and wait for a product decision; 134 need funds, keys or networks the
    run did not have.
  • npm run test:golden, in one isolated run at 452a66f3: 9 files, 235 passed, 2 skipped. After the
    Plugin Commands: section, test/plugin-fixture.test.ts, the golden file that reads the root help with
    a plugin installed, passes alone (30 tests).
  • The Plugin Commands: section: the root help with no plugin is byte-equal to the one before it; with the
    six plugins installed, the three core sections are byte-equal to the help with no plugin, and the root
    --json-schema is byte-equal to the one before it.
  • At f9ad3624, by independent QA: the root help, the root schema, the six group help pages and the
    help and schema entries of the 40 plugin commands equal the build before the command declaration and the
    SDK names changed, on the npm build and on the executable, and the recorded plugin runs match it. The
    author example of ts/plugin-sdk/README.md builds, installs and runs as written in a home with no
    account, on TRON and on EVM.
  • Regression against 4.16.0, by independent QA before the command declaration and the SDK names changed: the 40 commands of the six protocol groups
    have the same schema entries and help, reading 8004 as erc8004, except x402 serve (the
    --request-timeout option above); wallet-cli 8004 show 1 answers unknown_command. 348 command cases of
    the regression suite that need neither funds nor a key were run on both builds in text and JSON, and
    stdout, stderr, error code and exit code match except where a live quote, a timestamp or a rate limit of
    the public node differed between the two runs; 31 core groups compared with no plugin installed.
  • The plugin commands on the npm build and on the Node executable, 62 scenarios: installs from a local
    registry by package name; npm:name, a version range, node_modules and
    favicon.ico refused with no request sent; SDK version compatibility with the side to update named; a
    record of the earlier store schema reported, uninstalled and installed again; a failed update with its results;
    an update that changes only the manifest; malformed names refused.
  • A plugin whose entry exports no register, whose register throws, or whose register is asynchronous is
    broken alone; the process ends normally and the other plugins and the core commands keep working. The
    author example of ts/plugin-sdk/README.md builds, installs and runs as written.
  • Each of the six plugins installed alone under Node 22.23.4, 24.22.1 and 26.13.1: 18 combinations load, list
    only their own group, and answer every command's help. Each built entry exports only register and
    imports only the four SDK runtime entries.
  • The Node executable on darwin-arm64: verify-standalone.mjs passes, the six plugins load, --json-schema
    through a pipe is complete (197,869 bytes), and x402 serve --daemon starts, answers 402 and stops.
  • A plugin that imports a name the core does not export fails alone; the other plugins and the core commands
    keep working.
  • 69 refusals of core commands and 76 refusals of plugin commands print the same stdout, stderr and exit code
    as before the messages were rewritten as text, in text mode and in JSON mode.
  • With no plugin installed, the 92 core commands keep their --json-schema entries and help; the differences
    are the wording of config and plugin list, which no longer mention built-in plugins.
  • With the four protocol plugins installed from local builds, the 23 commands of GasFree, ERC-8004, x402 and
    B.AI, their four group help pages and the 161 error codes are identical to the build before the move; the
    end-to-end suite of the protocol plugin repository (the former golden tests of the four) passes against
    this build, also with each plugin installed alone (197 passed, 100 skipped).
  • With both Sun plugins installed, all 17 SunSwap and SunPump schema entries and both group help pages are
    identical to develop; that repository's end-to-end suite (212 cases) passes against this build.
  • Independent QA against the acceptance criteria: install, update and uninstall, integrity
    failure and rollback, concurrent management commands, broken and incompatible plugins, secret boundaries,
    signing and transaction modes on a controlled node, the single-file binary on darwin-arm64 including the
    detached x402 server, an upgraded home with the old credential keys, and masking of every credential on
    every output path. A second pass, before the command declaration and the SDK names changed: each of the six plugins installed alone into an empty
    home with all 40 command help pages and a read against the real service where none needs a key, the
    request time limit of x402 serve in the foreground and as a daemon, and the single-file binary running
    the plugins a Node build installed.

Known limits

  • A credential value left in config.yaml after its plugin was uninstalled is no longer checked or masked;
    nothing reads it.
  • The mask finds a value as text and in the spellings the core's renderers and common JSON encoders produce.
    A service that returns it in another encoding, interactive prompts, and an error raised while the
    configuration file is being read are outside it.
  • The core reserves only its own command words. A group word of a plugin that is not installed can be claimed
    by another plugin the user installs.

Before a release

  • Publish @tron-walletcli/plugin-sdk 1.0.0, then the release versions of the six plugin packages. Test builds
    0.1.0-next.1 are on npm under the next and latest tags; they declare ^1.0.0.
  • Make sun-protocol/wallet-cli-plugins and BofAI/wallet-cli-plugins public: the README's official plugin
    table links them.
  • The release note needs the migration text for the six features.

… a built-in plugin

Add plugin-api with its five entries, the plugin host and the built-in plugin list
under bootstrap/plugins, and generic registries for error codes, capability
predicates, follow-ups, help groups and per-network extension blocks. GasFree now
lives in plugins/gasfree and registers through the host; it signs through the
signing service with origin "service" and never receives a signer.

An unknown first word now suggests the plugin commands. Help, --json-schema,
envelopes and exit codes are otherwise unchanged. Dependency-cruiser and ESLint
rules cover the plugin directories.
…untime

- Snapshot what a plugin declares when the host accepts it, check the whole
  batch against the target registries before publishing, and refuse
  inherited wallet-management fields.
- Evaluate plugin capability predicates on every configured network before
  publishing, so a throwing predicate fails only its plugin.
- Fail a registration on any refused declaration, even when the plugin
  catches it; a refused bulk declaration stages none of its entries.
- Move plugin error codes and follow-up spellings into tables owned by the
  composed runtime; the catalog, exit codes and message spelling read them.
- Allow the ERC-8004 and x402 SDK wrappers at their plugin-layout paths.
… plugin SDK

- plugin install | list | update | remove: sources are a short name, an npm
  spec with an exact version or dist-tag, a directory or a .tgz. Registry
  downloads are checked against their SHA-512 integrity value before they
  are read; npm is never run. Six new error codes and the pluginRegistry
  config key. Install output and help carry the trust notice.
- The store keeps <home>/plugins/<name>/active.json and immutable
  versions/<id>/ directories; replacing active.json under the store lock is
  the commit point. Tarballs are read in memory with size limits, and links
  and entries that leave the package root are refused.
- The loader reads every manifest, imports a plugin only for its own group,
  --json-schema and plugin list, checks its definition against the manifest,
  and contains every failure to that plugin. Root help lists installed
  groups from the manifests. The host publishes its API object before the
  first import, and envelopes of installed-plugin commands carry
  meta.plugin.
- plugin-sdk builds standalone type declarations of the five plugin-api
  entries, runtime modules bound to the host object, and a stamp tool for
  the manifest's API numbers.
- The qaprobe fixture plugin, built only against the SDK, with variants for
  the failure cases; unit tests for store, tar, registry, service and
  loader; golden tests against a local registry stub.
- Host services gain contracts.tron/evm call and send, and message signing.
…, and a test API

- tronCalls runs one TRON contract call through the transaction lifecycle:
  the transaction mode, the fee limit, whether the fee can be estimated
  yet, the multi-signature preflight, a required confirmation,
  onDispatched with the txId before the node answers, and onSubmitted
  before the confirmation wait.
- The TRON gateway facade gains getAccount, getTransactionInfoById,
  receivedAmount and triggerConstantContract; tokens gives the token book's
  official and account layers; networks gives the configured aliases.
- plugin-api re-exports the value, error, execution, text and schema
  helpers that feature code imports, and the host's Zod for HTTP response
  checks.
- The plugin SDK gains a testing entry: one bundle that publishes the real
  plugin API in a test process and exports the core pieces plugin tests
  construct.
- received-amount names native TRX by the TRON zero address directly.
…ries

testing.d.ts now shares its declarations with the other SDK entries, so a
core class from the testing entry is assignable to the matching host
service type of the application entry.
SunSwap and SunPump are now the installed plugins sunswap and sunpump,
built in their own repository against the plugin SDK. The core no longer
registers their commands, error codes, follow-ups or capability
predicates, ships no sunswap or sunpump network defaults, and no longer
merges or validates those config.yaml blocks: they reach the plugin as
written. The sun-sdk dependencies, the command pages and the helpers only
these features used leave with them.

Tests that only mentioned the features are adjusted; the shell refusals
that only plugin commands declare are tested on demo commands, and the
reserved view key on the fixture plugin.
…late predicates

- The loader inspects and registers an imported definition inside the per-plugin failure
  boundary; a throwing getter marks that plugin broken and the others load.
- The definition must match the manifest's group name, summary, description and families.
- A capability key recorded before its installed plugin's predicate was known takes that
  predicate's answer at the next registration, in the gate and in discovery.
…n sources

- The store makes the new version directory and every directory it created durable
  before it replaces active.json, reads active.json through one opened handle, and marks
  failures after a commit point as committed.
- Install, update and remove report a failure after the commit point as the change it is;
  update with no name carries it in the plugin's result.
- An update is refused when the plugin was replaced while it was fetched.
- Directory sources bound package.json and entry reads before allocating.
- The tar reader validates each whole path and refuses mixed top-level directories.
- A tarball HTTP 429 reports provider_rate_limited.
- plugin install reads native absolute paths, bare .tgz names and npm:<name> specs.
- plugin list reports a built-in plugin that failed to register as broken.
…missions

- read, sign and transfer are bound for TRON and EVM; read reports the selected network
  and account address.
- inspect reports whether any value reachable through its context and services equals a
  canary private key, mnemonic or password, reports the signatures and submissions the
  controlled fixture observed for the last transfer, and signs with --sign.
- The golden test runs transfer through the host's TRON lifecycle against a controlled
  local node: dry run, build only, sign only, wait, no wait, a reverted receipt and a lost
  submit reply.
…on every publication

- The active manifest and package readers open non-blocking, so a FIFO is refused by the
  handle's regular-file check instead of blocking the open.
- Every publication syncs the links of plugins/, the plugin directory and versions/ before
  active.json is replaced, including directories left by an earlier failed attempt.
- The fixture test searches its output for the raw private keys, with and without 0x; the
  plugin still receives only their digests.
The 8004 commands, the agent use case and ports, the registry, revert
and registration adapters, the Agent formatters, the capability
predicates and the error code now live in plugins/erc8004 and register
through the plugin host for both families. The plugin reaches EVM
receipts through a gateways overload that exposes only
getTransactionReceipt, and plugin-api re-exports the helpers the moved
code uses.
x402 and B.AI become the built-in plugins x402 and bai under
src/plugins/, registered after gasfree and erc8004. bai uses the x402
service through x402/api.ts. Both move together because the core cannot
import a plugin and the core B.AI code depended on x402.

- Plugins sign through the signing host service and submit through
  tronCalls; the x402 server lifecycle uses the lifetime service.
- New host members: signing.prepare, gateways.client, the EVM
  getErc20Balance read, networks.resolve, lifetime and accounts.
- The daemon child receives its time limit as a global --timeout.
- The shell's x402 provider special case is the command field
  rejectsGlobals.
- The x402.serve and bai.recharge predicates and default tokens move
  into the plugins.
- depcruise: a plugin's application and inbound layers may import the
  api.ts of a plugin it depends on.
The 20 codes that only one plugin uses leave the core table: gasfree,
erc8004, x402 and bai each declare theirs. Codes shared by the core and
a plugin, or by two plugins, stay in the core table, including
gasfree_credentials_missing, payer_mismatch and invalid_x402_response.

--json-schema lists the same codes with the same entries; the moved
codes now follow the core codes, in plugin order. The error-code index
tests check the core table plus the built-in declarations, and that no
plugin declares a core code or another plugin's code.
Expose ./testing only under the wallet-cli-testing export condition, refuse
to load it in a process where wallet-cli published its plugin API, and
document how plugin tests opt in.
The test no longer rebuilds plugin-sdk/dist, which other golden files read in
parallel. build-plugin-sdk.mjs takes an optional output directory; the
default is unchanged.
…index

The exit-code tables of machine-interface.md no longer list the codes of
installed plugins, so a code that is in a table and not in the index is an
error again. Also drop a comment in network.ts that described the removed
SunSwap settings.
- sleepWithin succeeds only after the whole interval; a timer cut to the
  deadline that fires before the deadline's clock expires no longer ends
  the sleep with success.
- plugin update reports plugin_conflict when the plugin was removed while
  its update was being fetched.
- The unknown-command hint names the first word the user typed, worded as
  a condition.
- plugin list text has a SOURCE column after KIND.
- qaprobe: read requires --value, and qaprobe_refused exits 1.
…gin list

The plugin list examples are captured again from the built CLI. The
unknown-command example quotes the new hint, list.md says the integrity
value is in the JSON output only, and update.md says to install a plugin
again when it was removed during its update.
sleepWithin decides that its interval has passed from a monotonic clock,
not from the sum of timer delays. After a step cut to the deadline's
remaining time finds the deadline not expired, the next step is at least
25 ms, so a paused deadline with a sub-millisecond remainder cannot
cause thousands of wakeups or end the sleep early.
… deadlines

sleepWithin(deadline, ms) is the plugin API signature again; its clock
is private and the tests fake performance. The 25 ms minimum step
applies only when the deadline's remaining time did not shrink since the
previous cut step, so a disposed deadline is found expired when its
remainder is over, not up to 25 ms later.
The stream writer masks every configured credential in everything it
writes to stdout and stderr: results, text output, warnings, progress
events, log lines, discovery output and errors. It covers the raw, the
JSON-escaped and the terminal-escaped form of each value. The error
formatter and the internal-error path no longer mask on their own.
…ror codes

A plugin lists the configuration keys it reads in `credentials`, in its
definition and in its package manifest. The manifest list is validated
at install, stored in active.json, and compared with the definition
before registration. `config.credential(key)` fails for a key the plugin
did not declare. A key the core reads itself is refused.

The installed manifests are read once, before the configuration, and the
declared keys are read from config.yaml with the rules of the core
credentials: stdin only, masked, mode 0600. `config` lists a key while a
built-in plugin or an installed plugin with a readable manifest declares
it; a key several plugins declare is listed once.

GasFree, x402 and B.AI declare their keys. gasfree_credentials_missing,
invalid_x402_response and payer_mismatch leave the core table; each
plugin that can raise one declares it with the same entry. The qaprobe
fixture declares qaprobeApiKey and gains a credential command.
…nifest

The stream writer now masks a JSON frame by token: a credential inside a
string, key or value, is replaced in the decoded string and the string
is encoded again, and a number, true, false or null equal to a
credential becomes the string "********". A frame without a credential
is written unchanged. Callers say which frames are JSON. Text output is
masked as before, now also in the form an error value takes on one line.

An installed plugin may read only the credentials of the manifest it
was loaded with; the module's own list is read once, for the comparison.
The last-resort report uses the masked streams once they exist.
The manifest comparison reads the module's credentials property once.
The mask also covers a credential's JSON-escaped spelling with every /
written as \/, as some JSON encoders write it.
x402 holds copies of the GasFree network table and lookup, the two
GasFree credential declarations and the gasfree_credentials_missing
entry, and resolves the GasFree Open API of a network itself.
gasfree/api.ts is deleted. A host test registers each built-in plugin
with no other plugin registered.
…etween plugins

B.AI holds a copy of the x402 code its recharge reaches, at the same
paths under plugins/bai/, with its tests; domain/errors.ts and
application/capabilities.ts are copied as x402-errors.ts and
x402-capabilities.ts, and the capability copy keeps only the default
token. B.AI builds the x402 service in its own index.ts and declares
the GasFree keys and every x402 and GasFree code its copy raises.

x402/api.ts is deleted and x402 builds its service in index.ts. The
x402 test cases that drove B.AI's recharge flow now live only in
B.AI's copies. The copied payment client and its tests join the
known-violation baseline of the x402 payment-module rule, as their
sources are.
…n repository

The GasFree, ERC-8004, x402 and B.AI plugins are now built and tested in
their own repository and installed with `wallet-cli plugin install`. Without
them, their command groups fail with `unknown_command` and the generic
install hint, and their credential keys are unknown to `config`; values
already in config.yaml stay in the file.

- Remove src/plugins and empty the built-in plugin list.
- Remove the dependencies only those plugins used: @bankofai/8004-sdk, the
  four @bankofai/x402 packages and their override, and wrap-ansi.
- Move their command pages and the parts of the machine interface, the
  config page and the guides that describe them.
- Move their golden tests; rewrite core tests that used them as an example
  onto demo commands, groups and credential keys.
- Export more core test seams from the SDK testing entry for the moved tests.
- Drop the depcruise baseline entries of the removed files.
walletCli.plugin.sdkVersion is a semver range in the syntax of
package.json, and the core loads a plugin when its own plugin SDK
version satisfies that range, as npm's semver library decides with
default options. The core adds no rule of its own. A blank value stays
invalid, and the declared string is stored and printed as written.

An incompatible plugin names the declared range and the core's SDK
version. The message and error.details name the side to update when
the core's version is below the whole range (wallet-cli) or above it
(the plugin); in a gap of the range they name no side. The error code,
its retry and exit class, and the incompatible state of plugin list do
not change. An exact version now means that version only.

The stamp tool writes ^<major>.<minor>.0 of the SDK it ships in
(^1.1.0 for SDK 1.1.x) and needs no new dependency. semver becomes a
direct dependency at the version Ledger already pins, stays bundled,
and joins the allowlist of rule 1.5; rule 9.7 states the range rule.
The plugin's own version keeps the strict semver pattern.
The allowlist of rule 1.5 matched node_modules/ anywhere in a path, so
a scoped package such as @node_modules/semver or
@other-node_modules/semver passed as semver. node_modules now has to be
a whole path component; the firing test refuses both lookalikes.

The SDK README's opening paragraph, the comment of the SDK build
script, the plugin list and update pages and the plugin guide still
described the build version and the major/minor rule; they now
describe the declared range.

The stamp test adds SDK 2.3.4, so a constant stamp fails it, and a
padded range is read, stored and listed as written, so trimming it
fails three tests.
A plugin command now has one shape with one run. With families, a list
such as ["tron", "evm"], it is a ChainCommand: the core resolves the
network before run, and every declared family is bound to the same run;
familyFields gives a declared family its own extra fields and refine.
Without families it is a NeutralCommand whose network is "none" or
"optional". TypeScript types the network of run from whether the literal
names families. The host translates both cases into the core's
CommandDefinition, or one ChainSpec with a FamilyBinding per family; the
core's command model does not change, and the validation order of each
case stays as it was.

The host checks the whole declaration before it adds any of it, and
refuses: a missing run or one that is not a function; families that are
not a list, empty, or name an unknown family or one family twice; no
families and a network other than "none" or "optional"; a field of the
other case; familyFields that are malformed or name a family the
command does not declare. The checks for "both run and families",
"neither" and a family handler without run are gone. The qaprobe
fixture and the README example use the new shape.

BREAKING CHANGE: RunCommand, FamilyCommand and FamilyHandler are removed
with no alias; ChainCommand and NeutralCommand are exported beside
Command from /cli. All are types, so the runtime export-name snapshot
does not change; the SDK version stays 1.1.0.
The host took any value whose shape was an object as a schema, so
familyFields.tron.fields of { shape: null }, { shape: [] } or
{ shape: { memo: 42 } } registered and failed later when the command was
parsed. Family fields and the command's own fields must now be Zod object
schemas, and the command's refine a function.

familyFields was checked over its own entries but bound by property
lookup, so an entry inherited from a prototype reached the registry
unchecked. familyFields and each of its entries must now be plain
objects, and the bindings use a record rebuilt from the entries that
were checked; an undefined entry still means no extra fields or checks.

Tests cover each case through host.command and through addCommand of
/testing, with the registry unchanged after each refusal.
The SunSwap and SunPump packages now live in sun-protocol/wallet-cli-plugins.
The plugin list table shows the new source directory, and the JSON
examples of plugin install and plugin list are recaptured from a run of
the current build against the new directory.
The SunSwap and SunPump packages are now @sun-protocol/wallet-cli-*-plugin
and the GasFree, x402, B.AI and ERC-8004 packages
@bankofai/wallet-cli-*-plugin. None is on npm yet, so the README and the
plugin guide link the two plugin repositories and show an install from a
checkout first, captured from a run, and an install by name as the way
once a package is published.
plugin install now takes an npm package name, with an optional exact
version or dist-tag, fetched from the pluginRegistry config key and
checked against the registry's SHA-512 integrity value. A package
directory, a ~ or absolute path, and a .tgz or .tar.gz archive are
refused as invalid_value (exit 2) before anything is read, and the
message names the package-name form. plugin update keeps its registry
semantics: a pinned version stays, an unpinned one or a dist-tag moves.

A plugin whose record names a local directory or archive is listed as
broken with a reason to uninstall it and install it by name; plugin
update reports it as failed and leaves it as it is, and plugin uninstall
removes it. To install a plugin that is not on npm, or to test a build,
publish it to a private or local registry and set pluginRegistry to it.
The Plugins section of the TypeScript README lists the six official plugins with their npm package and what each adds, and the plugin command row links the plugin guide.
The table of contents gains the Plugins section, the section opens with one line like the other command sections, and the Quickstart's topic links include the plugin guide.
The Plugins section lists the plugin command first, as the other command sections do, then the official plugins with the install form.
plugin install <name> without a version installs the latest dist-tag, as before, and now records and shows the source as <name>@latest, so every source in plugin install and plugin list output names its version or dist-tag. An exact version or a dist-tag is recorded as given. plugin update still moves latest and leaves an exact version. A record without a version still loads and updates, and is recorded with @latest when an update publishes a new version.
A package name that ends in .tgz or .tar.gz, given with a version or dist-tag (demo.tgz@1.0.0, @acme/demo.tar.gz@latest), is a registry package again, and a pinned record of such a name updates as unchanged. Input that itself ends in .tgz or .tar.gz is still refused. The install transcripts in the docs now show the integrity line every registry install prints.
A record whose spec has no version, written before 640114b, now reads as name@latest in plugin list text and JSON, and in every use of the record. The file is not rewritten and no version directory is created. A stored spec that is not a package spec reports the plugin as broken.
…uide

Root README: the supported Node.js versions come from the TypeScript prerequisites instead of a wrong 20+, the prompt sentence names what prompts, the feature cells drop the unbounded claims, plugins are a link instead of a second list, and the TypeScript links include the plugin guide.

TypeScript README: a short opening, Key features in the contents, accurate account and family wording, tx send covers EVM tokens, the queries section is named for what it holds, the Plugins section states the trust rule and that the official plugins are not on npm yet, the machine interface section has a plain name and lists import keystore as interactive-only, and the example note is limited to what it can promise.

Guides: the index points at Getting started without filler; Getting started offers the password manager as an alternative, defines the password variable before using it, drops the stale faucet amount and timing, fixes the list sample, and links the plugin guide.
Without IFS=, read strips leading and trailing spaces, so a valid master password with them fails authentication when piped to tx send.
…k the trust rules

The plugins guide links the official catalog instead of repeating it, and shows the registry setting before the first install command, so a reader of an unpublished plugin does not hit not_found first. Its link to the SDK README points at GitHub, because the npm package does not include that file. The plugin command pages link the guide's trust section instead of repeating it, and plugin install says that a source without a version is recorded with @latest. The command index no longer calls plugin install offline, and troubleshooting lists pluginRegistry among the config keys.
ts/plugin-template is the SDK README's hello plugin as files: manifest,
register with hello greet and hello network, an esbuild build that keeps
the four SDK runtime entries external, refuses the testing entry and
stamps the SDK range, a Vitest setup with one test per command. The SDK
README and the plugins guide link it instead of carrying copies.
npx would fetch an unrelated wallet-cli-plugin-stamp package from the
registry when the SDK is missing; run the SDK's bin by its installed path.
…not type-check

The SDK README no longer repeats the template's Vitest configuration, and it says that npm run build bundles and stamps while npm run typecheck checks the types.
The package is no longer private, publishes with public access and builds its dist before npm publish. The stamp bin path drops its leading ./, which npm 11 otherwise removes from the published manifest.
wallet-cli read the tar format with its own parser, so one tarball could
hold one package for npm and another for wallet-cli: a single zero block,
a GNU header's prefix field, and a pax size record were read differently.
The integrity check covers the same bytes, so it did not notice.

readPackageTarball now hands the tar format to node-tar (pinned 7.5.24),
the parser npm uses, in memory. It keeps wallet-cli's own checks: size
limits before and after gunzip, the entry limit, regular files and
directories only, package paths under one top-level directory, and no
duplicate paths. A second gzip layer, which node-tar would decode and
npm would not, is refused.
…all differently

readPackageTarball still let three archives through that npm extracts
differently or that broke wallet-cli's own rules:

- A path that is both a file and a directory, in either order and
  through implicit parent directories. Extraction lets the directory
  replace the file or skips the later entry. It is now refused.
- Empty metadata headers emit no node-tar event, so they escaped the
  entry limit. Every non-zero header block now counts, through the
  parser method node-tar calls for each header.
- Entries that node-tar ignores (sparse, unknown types) skipped the type
  and path rules. They now go through them and are refused as a link or
  special file. Metadata over node-tar's size limit is still skipped,
  as npm skips it.
A path inside a plugin package must use only ASCII letters, digits and
. _ - @ +, have at most 32 segments and 255 characters, and differ from
every other path in more than case. Drive letters, colons, deep paths,
non-ASCII names and case-only differences are refused instead of being
read differently from npm's extraction.

File/directory conflicts are checked once after parsing over sorted
paths, so memory stays linear in the total path length. The entry limit
counts node-tar's public entry, ignoredEntry and meta events; empty
metadata headers are bounded by the unpacked size limit.
…in errors

A regular file or directory whose pax or GNU long-link metadata sets a
link target is refused: npm's extraction skips such an entry when the
target escapes.

Every message that names an archive path is built with errorMessage, so
line separators in a path are escaped in text output, and a path longer
than 200 characters is cut with a marker that gives its full length.

A path segment inside a plugin package may no longer end with a dot or
be a Windows device name (con, prn, aux, nul, com1-9, lpt1-9, with any
extension).
The plugin SDK has never been published, so it starts at 1.0.0. The
template, the qaprobe fixture, the docs and the examples declare ^1.0.0.
Compatibility tests keep their cases against core 1.0.0: a newer minor is
^1.1.0, and an older pre-release (1.0.0-beta.1) replaces the older-minor
refusal. The older-sdk-minor fixture variant is dropped, as SDK 1.0.0 has
no older minor.
inputSchema.required now lists only what a caller must pass: a top-level
field whose outermost schema is an unchecked default is optional and keeps
its default. Every other field keeps its output-mode requiredness, and the
schema stays closed to unknown flags.

The catalog usage names positionals with the same text as the help Usage
line, and a new positionals field lists them in argv order. Core and plugin
commands share one usage builder.
plugin list already prints each plugin's state and reason, so the
loader's "warning: plugin <name> is <state>" lines on stderr and in
meta.warnings repeated them. The runner now drops those warnings for
plugin list. --json-schema keeps them, because a plugin that is not ok
is missing from its catalog.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant