@bnbagent/studio-cli 0.0.13 → 0.0.14-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +8 -0
- package/dist/_agentcoreName-DZDWEYD3.js +0 -0
- package/dist/bag.js +3741 -1612
- package/dist/{chunk-H4X2OOLA.js → chunk-CFMETPKS.js} +263 -73
- package/dist/chunk-U7IDQ3K5.js +0 -0
- package/dist/{deployCli-22NMZ4G7.js → deployCli-AVWKY3GN.js} +5 -2
- package/package.json +13 -14
- package/recipes/agent/code/{{PKG}}/deliveryPolicy.ts.tmpl +43 -0
- package/recipes/agent/code/{{PKG}}/readToolCatalog.ts.tmpl +102 -0
- package/recipes/agent/code/{{PKG}}/signing.ts.tmpl +7 -2
- package/recipes/agent/recipe.toml +5 -4
- package/recipes/mpp-buyer/recipe.toml +1 -1
- package/recipes/runtimes/agentcore/code/{{PKG}}/dualMain.ts.tmpl +6 -2
- package/recipes/runtimes/agentcore/code/{{PKG}}/mcpMain.ts.tmpl +173 -134
- package/recipes/runtimes/agentcore/code/{{PKG}}/model.ts.tmpl +7 -0
- package/recipes/runtimes/agentcore/code/{{PKG}}/sellerCore.ts.tmpl +31 -46
- package/recipes/runtimes/agentcore/code/{{PKG}}/tools.ts.tmpl +19 -48
- package/recipes/runtimes/agentcore/code/{{PKG}}/unifiedMain.ts.tmpl +2 -1
- package/recipes/runtimes/agentcore/recipe.toml +1 -1
- package/recipes/runtimes/azure-foundry/code/{{PKG}}/mcpMain.ts.tmpl +173 -134
- package/recipes/runtimes/azure-foundry/code/{{PKG}}/model.ts.tmpl +7 -0
- package/recipes/runtimes/azure-foundry/code/{{PKG}}/sellerCore.ts.tmpl +31 -46
- package/recipes/runtimes/azure-foundry/code/{{PKG}}/tools.ts.tmpl +19 -48
- package/recipes/runtimes/azure-foundry/code/{{PKG}}/unifiedMain.ts.tmpl +2 -1
- package/recipes/runtimes/azure-foundry/recipe.toml +1 -1
- package/recipes/wallet/recipe.toml +3 -2
- package/recipes/x402-buyer/recipe.toml +1 -1
- package/skills/bnbagent-studio.md +12 -1
- package/skills/references/bnbagent-studio-operating.md +1 -0
- package/skills/references/bnbagent-studio-scaffolding-agent.md +11 -34
- package/skills/references/bnbagent-studio-selling-via-b402.md +3 -3
- package/skills/references/bnbagent-studio-using-altana-wallet.md +7 -2
- package/skills/references/bnbagent-studio-using-twak-wallet.md +24 -76
- package/dist/_twak-4XF4H5PL.js +0 -25
- package/dist/chunk-RO726HJG.js +0 -175
|
@@ -9,101 +9,49 @@ description: When the user's project has [wallet].kind = "twak" (a fully-support
|
|
|
9
9
|
|
|
10
10
|
Procedure for setting up and operating the **twak** wallet kind (Trust Wallet Agent Kit CLI) in a bnbagent-studio project. twak is a **fully-supported** wallet kind - opt in at scaffold with `bag init <name> --wallet-kind twak` (`evm-local`, a local keystore, is the default). The wallet is a **self-custody, AES-256-GCM-encrypted mnemonic** the user controls (not a hosted service), living by default in a **project-dedicated** home `.studio/twak` (`[wallet].twak_home`), isolated from your main `~/.twak`. The default kind is `evm-local` (local keystore); re-scaffold with `--wallet-kind twak` to use twak.
|
|
11
11
|
|
|
12
|
-
## 1.
|
|
12
|
+
## 1. CLI installation is project-managed
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
`bag init --wallet-kind twak` pins `@trustwallet/cli@0.20.0` in the generated `app/agent/package.json`; the normal `pnpm install` installs it. Do **not** ask the user for a global installation and do not call the upstream CLI directly. Studio and the runtime resolve `app/agent/node_modules/.bin/twak`, and `bag doctor` / `bag deploy prepare` verify the project-pinned version floor.
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
npm install -g @trustwallet/cli@0.20.0
|
|
18
|
-
twak --version
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
studio requires **>= 0.20.0** (the SDK forwards `--paymaster-url` on sponsored bsc-testnet writes - the flag first shipped in v0.20.0; older CLIs reject it with "unknown option"); `bag doctor` and `bag deploy prepare` verify the floor.
|
|
22
|
-
|
|
23
|
-
## 2. Create the wallet - one time, in YOUR terminal
|
|
24
|
-
|
|
25
|
-
`bag wallet twak-init` drives creation for you (step 3) so you never type the password on a command line; the NaaS setup wizard below still has to be run by hand once, because it is interactive.
|
|
26
|
-
|
|
27
|
-
**Every twak command is prefixed with the dedicated home.** Without `HOME=$DH`, twak uses your real `~/.twak` (your MAIN wallet) and macOS pops a login-keychain password prompt. Set it once:
|
|
28
|
-
|
|
29
|
-
```bash
|
|
30
|
-
DH=<workspace>/.studio/twak # e.g. ~/proj/.studio/twak
|
|
31
|
-
```
|
|
16
|
+
## 2. Studio-managed setup - no upstream wizard
|
|
32
17
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
**2. Run the setup wizard** - writes the credentials into the dedicated home:
|
|
18
|
+
The user creates a Trust Wallet NaaS app at https://portal.trustwallet.com/dashboard/apps, but must never paste the Access ID, HMAC secret, or wallet password into the AI chat. On a human TTY, `bag init` performs the setup automatically. To retry or complete a non-onboarded scaffold, run from `app/agent`:
|
|
36
19
|
|
|
37
20
|
```bash
|
|
38
|
-
|
|
21
|
+
bag wallet twak-init
|
|
39
22
|
```
|
|
40
23
|
|
|
41
|
-
|
|
42
|
-
- **Step 2 ("which harnesses to wire up"): SELECT NONE - press ENTER** on the empty list (do NOT press SPACE or `a`). 🔒 This would register twak's signing MCP into Claude Code / Cursor / etc., handing wallet+signing power to your AI assistant (and any prompt-injection reaching it) - studio forbids that: signing is fixed `signing.ts` code, the LLM only receives read-only chain tools, and the deployed agent never calls twak via MCP.
|
|
43
|
-
- **Step 3 (Wallet "Pick one"): choose `3) Skip for now`** (you create it in the next step). NOT `2) Use WalletConnect with my existing wallet` (binds your main/real wallet).
|
|
24
|
+
This one Studio command:
|
|
44
25
|
|
|
45
|
-
|
|
26
|
+
1. Collects the NaaS Access ID and HMAC secret through hidden Studio prompts. It never starts `twak setup` or asks which AI harnesses to wire.
|
|
27
|
+
2. Runs the project-pinned `twak init --json` with the two credentials in the child environment.
|
|
28
|
+
3. Performs an authenticated `twak search BNB --networks 20000714 --limit 1 --json` read. Newly written credentials are removed if this verification fails; pre-existing credentials are never deleted.
|
|
29
|
+
4. Generates `TWAK_WALLET_PASSWORD` from 32 bytes of the OS cryptographic random source and writes it to `.studio/.env.local` (0600). There is no weak-random fallback and the value is never printed.
|
|
30
|
+
5. Creates the project-dedicated wallet with `--no-keychain --json`, tightens `.twak/` to 0700 and its credential/wallet files to 0600, reads the BSC address, and anchors it into `studio.toml`.
|
|
31
|
+
6. Refuses to replace an anchored identity and never overwrites an existing wallet or credential file.
|
|
46
32
|
|
|
47
|
-
|
|
48
|
-
bag wallet twak-init # interactive hidden prompt
|
|
49
|
-
printf %s "$PW" | bag wallet twak-init --password-stdin # CI / scripts
|
|
50
|
-
bag wallet twak-init --password-file pw.txt # file must be chmod 600
|
|
51
|
-
```
|
|
33
|
+
Upstream twak v0.20.0 requires `--password` during wallet creation, so the generated password is briefly present in that one child process's argv. It does not enter the user's shell history, Studio output, diagnostics, or AI transcript. Runtime signing reads it from the environment and does not put it on argv.
|
|
52
34
|
|
|
53
|
-
|
|
35
|
+
For non-interactive automation, the user can put `TWAK_ACCESS_ID` and `TWAK_HMAC_SECRET` in `.studio/.env.local` themselves before running `bag wallet twak-init`; Studio still generates the wallet password. The legacy `--password-stdin` and `--password-file <0600-file>` options remain explicit compatibility overrides, not the happy path.
|
|
54
36
|
|
|
55
|
-
|
|
37
|
+
After setup:
|
|
56
38
|
|
|
57
39
|
```bash
|
|
58
|
-
|
|
40
|
+
bag wallet show
|
|
41
|
+
bag llm activate
|
|
42
|
+
bag doctor
|
|
59
43
|
```
|
|
60
44
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
> **Already have a wallet here?** If twak says `Wallet already exists. Back up … then delete it`, the wallet is already created - do **NOT** follow the literal "delete it". `wallet.json` is the ONLY copy of your AES-256-GCM encrypted mnemonic; deleting it without the mnemonic backed up loses the funds **forever**. Confirm it's yours (`HOME="$DH" twak wallet addresses`), skip create, and go straight to step 5 - `bag wallet new` just ADOPTS the existing address (idempotent, never destructive). Only recreate if you've safely backed up the mnemonic, and then `mv` `wallet.json` to a `.bak` rather than deleting.
|
|
64
|
-
|
|
65
|
-
> **CI / scripts:** use `bag wallet twak-init --password-stdin` / `--password-file` above - it is the supported non-interactive path and works on headless runners (no keychain involved). Avoid the older `TWAK_NONINTERACTIVE=1 TWAK_SETUP_WALLET=create … twak setup` route: it has no `--no-keychain` equivalent, stores the password in the OS keychain, and aborts with `STORAGE_ERROR` on headless / Docker runners.
|
|
66
|
-
|
|
67
|
-
**4. Put the unlock password in `.env.local`** - **YOU edit the file** (never through the chat, never `bag env set <literal>` - the password must not reach the assistant or argv). Same value as Step 3:
|
|
68
|
-
|
|
69
|
-
```
|
|
70
|
-
# .studio/.env.local
|
|
71
|
-
TWAK_WALLET_PASSWORD=<StrongPw>
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
studio AND the deployed runtime unlock via this env - the keychain copy is local-only and never deploys, so this line is mandatory or deploy can't sign.
|
|
75
|
-
|
|
76
|
-
**5. Anchor + activate** - back in a NORMAL shell (**no `HOME=` prefix**; studio resolves the home from `[wallet].twak_home` itself, and `bag wallet new` ADOPTS the address - it does not create a second wallet):
|
|
77
|
-
|
|
78
|
-
```bash
|
|
79
|
-
cd <workspace>/app/agent
|
|
80
|
-
bag wallet new # writes the NEW address into studio.toml [wallet].address - confirm it's the new wallet, not your main one
|
|
81
|
-
bag llm activate # zero-deposit Pieverse key
|
|
82
|
-
bag doctor # all PASS (zero balance is a WARN, fine)
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
### macOS keychain - bypassed by default
|
|
86
|
-
|
|
87
|
-
With `--no-keychain` (step 3) the wallet password lives ONLY in `TWAK_WALLET_PASSWORD` (step 4) - twak never reads or writes the OS keychain, so both creation and signing trigger **no macOS password prompt**. studio and the deployed runtime unlock via that env, so nothing is lost by skipping the keychain.
|
|
88
|
-
|
|
89
|
-
> **Safety net (you normally never see it):** for the rare case you create a wallet WITHOUT `--no-keychain`, `bag init` (and `bag wallet new`) also auto-creates an isolated, **empty-password** keychain under `$DH/Library/Keychains` - secret-free, scoped to `$DH` (your real login keychain untouched), never deployed. With `--no-keychain` twak doesn't touch any keychain at all.
|
|
90
|
-
|
|
91
|
-
> ⚠️ **If you omitted `--no-keychain` and a macOS prompt LOOPS** (or a bare `twak setup` prompted against your **main** login keychain and rejects every password): **Do NOT click "Reset Default Keychain"** - it erases your Wi-Fi passwords, SSH passphrases, and saved app secrets. Quit it with `pkill -9 -f twak`, then recreate the wallet **disk-only**:
|
|
92
|
-
>
|
|
93
|
-
> ```bash
|
|
94
|
-
> HOME="$DH" twak wallet create --password '<StrongPw>' --no-keychain
|
|
95
|
-
> ```
|
|
96
|
-
>
|
|
97
|
-
> and rely on `TWAK_WALLET_PASSWORD` (step 4) to unlock - same end state, no keychain involved.
|
|
45
|
+
No separate `bag wallet new` step is required. An existing wallet is adopted only after Studio verifies its password and reads its address. If its password is not already in `.studio/.env.local`, the user enters it through a hidden Studio prompt or supplies the original password using `--password-stdin` / `--password-file <0600 file>`; Studio never invents a replacement password for an existing wallet.
|
|
98
46
|
|
|
99
47
|
### Other wallet placements
|
|
100
48
|
|
|
101
|
-
|
|
49
|
+
The default is a new project-dedicated `.studio/twak` home, isolated from the user's main `~/.twak`. Alternatives are explicit:
|
|
102
50
|
|
|
103
|
-
-
|
|
104
|
-
-
|
|
51
|
+
- Reuse an existing wallet across agents with `bag init --twak-home <home-style-path>`; the path contains `.twak/wallet.json`.
|
|
52
|
+
- Reuse the main `~/.twak` only with `bag init --twak-home ~`. This is discouraged because deploy would ship that wallet material through the selected secrets channel.
|
|
105
53
|
|
|
106
|
-
Each wallet
|
|
54
|
+
Each wallet address has its own ERC-8004 identity, Pieverse SIWE binding, and secret bundle; `bag doctor` / `bag deploy` resolve the configured `[wallet].twak_home`.
|
|
107
55
|
|
|
108
56
|
## 3. Fund it - and keep it a HOT wallet
|
|
109
57
|
|
|
@@ -144,7 +92,7 @@ Pieverse attributes x402 topups to the **SIWE-bound payer address** (the paid ca
|
|
|
144
92
|
| Custom ERC-8183 targets unavailable | upstream feature request | twak v0.20.0 has no Commerce/Router/Policy address option. Studio doctor/prepare and the SDK fail closed instead of silently executing on canonical contracts; use `evm-local` for a custom ERC-8183 deployment. |
|
|
145
93
|
| No generic EIP-712 signing | P0 (won't fix) | `[wallet.signing]` is ignored; payments go through the delegated payer's own prechecks + `--max-payment`. Endpoints needing an `Authorization` header _and_ x402 are unavailable (e.g. `bag llm key new --initial-usd > 0` - use `--initial-usd 0` + topup + allocate instead, same end state). |
|
|
146
94
|
| No wallet import | S-6 | Switching wallet kinds changes your address → re-run `bag 8004 register` (new on-chain identity). |
|
|
147
|
-
| Programmatic wallet creation forces password onto argv | S-8 | Bridged by `bag wallet twak-init
|
|
95
|
+
| Programmatic wallet creation forces password onto argv | S-8 | Bridged by `bag wallet twak-init`: Studio generates 32 CSPRNG bytes, persists the value privately before creation, and forwards it only to the short-lived child because twak requires the flag. The value never enters user shell history or output. |
|
|
148
96
|
| CLI has no daily/monthly caps | - | Studio's policy layer (`[budget].max_per_day_usd`, host allowlist, per-request caps) is the spend authority for both wallet kinds. |
|
|
149
97
|
| `twak wallet balance --chain bsctestnet` rejects the chain | BUG-031 | Fails with `CHAIN_UNSUPPORTED` even though `wallet address` and `erc8183` accept `bsctestnet`. Use `bag wallet balance` (RPC-based, works on testnet), or raw RPC: `eth_getBalance` for tBNB and an `eth_call` of `balanceOf(address)` on the U token for token balance. |
|
|
150
98
|
| `twak tx <hash> --chain bsctestnet` rejects the chain | BUG-032 | Same chain-registry gap on the readback path: transactions twak itself just mined on `bsctestnet` cannot be inspected with `twak tx`. Use public RPC (`eth_getTransactionByHash` / `eth_getTransactionReceipt`) or BscScan testnet instead. |
|
package/dist/_twak-4XF4H5PL.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
TWAK_CLI_MIN_VERSION,
|
|
4
|
-
TWAK_CLI_VERSION,
|
|
5
|
-
TWAK_NODE_MIN_MAJOR,
|
|
6
|
-
twakCreateGuidance,
|
|
7
|
-
twakDoubledHomeHint,
|
|
8
|
-
twakHomeDir,
|
|
9
|
-
twakInstalledVersion,
|
|
10
|
-
twakVersionBelowFloor,
|
|
11
|
-
twakWalletFile,
|
|
12
|
-
whichTwak
|
|
13
|
-
} from "./chunk-RO726HJG.js";
|
|
14
|
-
export {
|
|
15
|
-
TWAK_CLI_MIN_VERSION,
|
|
16
|
-
TWAK_CLI_VERSION,
|
|
17
|
-
TWAK_NODE_MIN_MAJOR,
|
|
18
|
-
twakCreateGuidance,
|
|
19
|
-
twakDoubledHomeHint,
|
|
20
|
-
twakHomeDir,
|
|
21
|
-
twakInstalledVersion,
|
|
22
|
-
twakVersionBelowFloor,
|
|
23
|
-
twakWalletFile,
|
|
24
|
-
whichTwak
|
|
25
|
-
};
|
package/dist/chunk-RO726HJG.js
DELETED
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
// src/cli/_twak.ts
|
|
4
|
-
import * as os from "os";
|
|
5
|
-
import * as path from "path";
|
|
6
|
-
import { resolveTwakHome } from "@bnbagent/studio-runtime/wallet";
|
|
7
|
-
|
|
8
|
-
// src/cli/proc.ts
|
|
9
|
-
import { execa } from "execa";
|
|
10
|
-
async function runCapture(cmd, args, opts = {}) {
|
|
11
|
-
const result = await execa(cmd, args, {
|
|
12
|
-
cwd: opts.cwd,
|
|
13
|
-
env: opts.env,
|
|
14
|
-
input: opts.input,
|
|
15
|
-
timeout: opts.timeoutMs,
|
|
16
|
-
reject: false,
|
|
17
|
-
stripFinalNewline: false
|
|
18
|
-
});
|
|
19
|
-
return {
|
|
20
|
-
code: result.exitCode ?? 1,
|
|
21
|
-
stdout: typeof result.stdout === "string" ? result.stdout : "",
|
|
22
|
-
stderr: typeof result.stderr === "string" ? result.stderr : ""
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
async function runStream(cmd, args, opts = {}) {
|
|
26
|
-
const result = await execa(cmd, args, {
|
|
27
|
-
cwd: opts.cwd,
|
|
28
|
-
env: opts.env,
|
|
29
|
-
timeout: opts.timeoutMs,
|
|
30
|
-
reject: false,
|
|
31
|
-
stdio: "inherit"
|
|
32
|
-
});
|
|
33
|
-
return result.exitCode ?? 1;
|
|
34
|
-
}
|
|
35
|
-
async function runCaptureOut(cmd, args, opts = {}) {
|
|
36
|
-
const result = await execa(cmd, args, {
|
|
37
|
-
cwd: opts.cwd,
|
|
38
|
-
env: opts.env,
|
|
39
|
-
input: opts.input,
|
|
40
|
-
timeout: opts.timeoutMs,
|
|
41
|
-
reject: false,
|
|
42
|
-
stripFinalNewline: false,
|
|
43
|
-
stdout: "pipe",
|
|
44
|
-
stderr: "inherit"
|
|
45
|
-
});
|
|
46
|
-
return {
|
|
47
|
-
code: result.exitCode ?? 1,
|
|
48
|
-
stdout: typeof result.stdout === "string" ? result.stdout : ""
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
// src/cli/_twak.ts
|
|
53
|
-
var TWAK_CLI_VERSION = "0.20.0";
|
|
54
|
-
var TWAK_CLI_MIN_VERSION = [
|
|
55
|
-
0,
|
|
56
|
-
20,
|
|
57
|
-
0
|
|
58
|
-
];
|
|
59
|
-
var TWAK_NODE_MIN_MAJOR = 20;
|
|
60
|
-
function twakVersionBelowFloor(installed) {
|
|
61
|
-
const floor = TWAK_CLI_MIN_VERSION;
|
|
62
|
-
for (let i = 0; i < floor.length; i += 1) {
|
|
63
|
-
const a = installed[i] ?? 0;
|
|
64
|
-
const b = floor[i];
|
|
65
|
-
if (a !== b) {
|
|
66
|
-
return a < b;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
return false;
|
|
70
|
-
}
|
|
71
|
-
async function whichTwak() {
|
|
72
|
-
const cmd = process.platform === "win32" ? "where" : "which";
|
|
73
|
-
const result = await runCapture(cmd, ["twak"]);
|
|
74
|
-
if (result.code !== 0) {
|
|
75
|
-
return null;
|
|
76
|
-
}
|
|
77
|
-
const line = result.stdout.split("\n")[0]?.trim();
|
|
78
|
-
return line ? line : null;
|
|
79
|
-
}
|
|
80
|
-
async function twakInstalledVersion() {
|
|
81
|
-
if (await whichTwak() === null) {
|
|
82
|
-
return null;
|
|
83
|
-
}
|
|
84
|
-
let out;
|
|
85
|
-
try {
|
|
86
|
-
const result = await runCapture("twak", ["--version"], {
|
|
87
|
-
timeoutMs: 15e3
|
|
88
|
-
});
|
|
89
|
-
out = result.stdout;
|
|
90
|
-
} catch {
|
|
91
|
-
return null;
|
|
92
|
-
}
|
|
93
|
-
const m = /(\d+)\.(\d+)\.(\d+)/.exec(out || "");
|
|
94
|
-
if (m === null) {
|
|
95
|
-
return null;
|
|
96
|
-
}
|
|
97
|
-
return [
|
|
98
|
-
Number.parseInt(m[1], 10),
|
|
99
|
-
Number.parseInt(m[2], 10),
|
|
100
|
-
Number.parseInt(m[3], 10)
|
|
101
|
-
];
|
|
102
|
-
}
|
|
103
|
-
function twakHomeDir(walletCfg, projectRoot) {
|
|
104
|
-
const home = resolveTwakHome(walletCfg ?? {}, projectRoot ?? null);
|
|
105
|
-
return path.join(home ?? os.homedir(), ".twak");
|
|
106
|
-
}
|
|
107
|
-
function twakWalletFile(walletCfg, projectRoot) {
|
|
108
|
-
return path.join(twakHomeDir(walletCfg, projectRoot), "wallet.json");
|
|
109
|
-
}
|
|
110
|
-
function twakDoubledHomeHint(walletFile) {
|
|
111
|
-
const doubled = `${path.sep}.twak${path.sep}.twak${path.sep}`;
|
|
112
|
-
if (!walletFile.includes(doubled)) {
|
|
113
|
-
return null;
|
|
114
|
-
}
|
|
115
|
-
return `hint: the resolved wallet path ${walletFile} nests .twak/.twak \u2014 [wallet].twak_home in studio.toml likely points at the .twak directory itself. Set it to the PARENT directory (the runtime appends .twak/wallet.json) and re-run.`;
|
|
116
|
-
}
|
|
117
|
-
function twakCreateGuidance(fields) {
|
|
118
|
-
return `error: wallet.kind = "twak" \u2014 \`bag wallet new\` only adopts an existing
|
|
119
|
-
twak wallet's address. Create the wallet ONCE (you choose the password; pick a
|
|
120
|
-
strong one).
|
|
121
|
-
|
|
122
|
-
RECOMMENDED \u2014 let studio drive the create step so you never type the password
|
|
123
|
-
on a command line (twak requires --password on its own argv, so the value does
|
|
124
|
-
reach that short-lived child process):
|
|
125
|
-
|
|
126
|
-
bag wallet twak-init --password-stdin # CI: printf %s "$PW" | bag wallet twak-init --password-stdin
|
|
127
|
-
bag wallet twak-init --password-file <f> # file must be chmod 600
|
|
128
|
-
bag wallet twak-init # interactive hidden prompt
|
|
129
|
-
|
|
130
|
-
(the one-time NaaS setup below applies to BOTH paths; the manual twak
|
|
131
|
-
commands follow it.)
|
|
132
|
-
|
|
133
|
-
First get Trust Wallet NaaS API credentials (one time): make an app at
|
|
134
|
-
https://portal.trustwallet.com/dashboard/apps \u2192 copy its Access ID + HMAC
|
|
135
|
-
secret, then run \`twak setup\` (without them \`twak wallet create\` fails with
|
|
136
|
-
"No API credentials found"):
|
|
137
|
-
|
|
138
|
-
${fields.setupCmd}
|
|
139
|
-
|
|
140
|
-
then create the wallet \u2014 interactive (you type the password on argv yourself;
|
|
141
|
-
twak warns, and it lands in your shell history \u2014 acceptable for a throwaway hot
|
|
142
|
-
wallet):
|
|
143
|
-
|
|
144
|
-
${fields.createCmd}
|
|
145
|
-
|
|
146
|
-
\u2014 or, to keep the password out of your shell history (CI / scripts), pass it
|
|
147
|
-
via the environment and let \`twak setup\` create the wallet
|
|
148
|
-
non-interactively:
|
|
149
|
-
|
|
150
|
-
TWAK_NONINTERACTIVE=1 TWAK_SETUP_WALLET=create TWAK_WALLET_PASSWORD=<pw> ${fields.setupCmd}
|
|
151
|
-
|
|
152
|
-
(this stores the password in the OS keychain and needs one that persists;
|
|
153
|
-
on headless / Docker runners without a keychain it aborts \u2014 use the argv
|
|
154
|
-
form above there.)
|
|
155
|
-
|
|
156
|
-
then set TWAK_WALLET_PASSWORD in .studio/.env.local and re-run
|
|
157
|
-
bag wallet new # adopts the address into studio.toml
|
|
158
|
-
Guide: the bnbagent-studio-using-twak-wallet.md reference (installed by \`bag skills install\`).`;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
export {
|
|
162
|
-
runCapture,
|
|
163
|
-
runStream,
|
|
164
|
-
runCaptureOut,
|
|
165
|
-
TWAK_CLI_VERSION,
|
|
166
|
-
TWAK_CLI_MIN_VERSION,
|
|
167
|
-
TWAK_NODE_MIN_MAJOR,
|
|
168
|
-
twakVersionBelowFloor,
|
|
169
|
-
whichTwak,
|
|
170
|
-
twakInstalledVersion,
|
|
171
|
-
twakHomeDir,
|
|
172
|
-
twakWalletFile,
|
|
173
|
-
twakDoubledHomeHint,
|
|
174
|
-
twakCreateGuidance
|
|
175
|
-
};
|