@toon-protocol/hub 0.34.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +226 -0
- package/dist/chunk-5O4SBV5O.js +538 -0
- package/dist/chunk-5O4SBV5O.js.map +1 -0
- package/dist/chunk-I2R4CRUX.js +39 -0
- package/dist/chunk-I2R4CRUX.js.map +1 -0
- package/dist/chunk-JCOFMUPL.js +65 -0
- package/dist/chunk-JCOFMUPL.js.map +1 -0
- package/dist/chunk-L2U4G4OK.js +30219 -0
- package/dist/chunk-L2U4G4OK.js.map +1 -0
- package/dist/chunk-MNVIN5XK.js +125 -0
- package/dist/chunk-MNVIN5XK.js.map +1 -0
- package/dist/cli.d.ts +209 -0
- package/dist/cli.js +4809 -0
- package/dist/cli.js.map +1 -0
- package/dist/compose/townhouse-dev.yml +415 -0
- package/dist/compose/townhouse-direct.yml +391 -0
- package/dist/compose/townhouse-hs.yml +468 -0
- package/dist/demo-UJ37MLCG.js +118 -0
- package/dist/demo-UJ37MLCG.js.map +1 -0
- package/dist/index.d.ts +1342 -0
- package/dist/index.js +77 -0
- package/dist/index.js.map +1 -0
- package/dist/orchestrator-dGq7CeaO.d.ts +1507 -0
- package/dist/rsa-from-seed-XIT6EU73.js +67 -0
- package/dist/rsa-from-seed-XIT6EU73.js.map +1 -0
- package/dist/tui-QE3ZRZO3.js +638 -0
- package/dist/tui-QE3ZRZO3.js.map +1 -0
- package/package.json +89 -0
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
|
|
3
|
+
// src/constants.ts
|
|
4
|
+
var CONTAINER_PREFIX = "townhouse-";
|
|
5
|
+
var NODE_BTP_PORT = 3e3;
|
|
6
|
+
var DEFAULT_CONNECTOR_IMAGE = (
|
|
7
|
+
// v3.10.4 — connector#137 (non-EVM inbound claim validator: Solana Ed25519 /
|
|
8
|
+
// Mina verification wired to the BTP server) + connector#136 (dynamic-HS-peer
|
|
9
|
+
// settlement: peerIdToChainMap populated via registerPeerChain), closing
|
|
10
|
+
// toon#213 and unblocking Solana + Mina pay-to-write for dynamic HS apexes.
|
|
11
|
+
// Validated live: bumping a running apex 3.10.3→3.10.4 made dynamic-HS Solana
|
|
12
|
+
// and Mina on-chain settlement work end-to-end. Builds on:
|
|
13
|
+
// v3.10.3 — connector#133 Mina claimFromChannel balance-conservation fix
|
|
14
|
+
// (#134 + #135 test follow-up). For an inbound unidirectional Mina claim the
|
|
15
|
+
// provider built the co-signed claim with balanceB=0, but the on-chain
|
|
16
|
+
// PaymentChannel.claimFromChannel circuit asserts balanceA + balanceB ==
|
|
17
|
+
// depositTotal and verifies both signatures over Poseidon([balanceA,balanceB,
|
|
18
|
+
// salt]); balanceB=0 violated conservation → PROOF_GENERATION_FAILED before any
|
|
19
|
+
// tx. 3.10.2 derives balanceB = depositTotal − balanceA from the public
|
|
20
|
+
// on-chain depositTotal (3.10.3 hardens the integration tests). This is the
|
|
21
|
+
// connector half of the LAST Mina publish-settle blocker (#158): with it +
|
|
22
|
+
// the client conserved-balanceB signing fix, a Mina-settled publish drives
|
|
23
|
+
// claimFromChannel to an on-chain landing (nonceField 0→1, proven live).
|
|
24
|
+
// Patch bump — no SDK/admin contract change vs 3.10.1; bumped because townhouse
|
|
25
|
+
// needs the conservation-correct settle behavior (CONNECTOR_RELEASE_CONTRACT.md
|
|
26
|
+
// patch-bump exception).
|
|
27
|
+
// v3.10.1 — connector#132 settlement claim-chain routing fix. The
|
|
28
|
+
// settlement-executor was routing Solana/Mina settle by a stale EVM channel
|
|
29
|
+
// instead of by the claim's own chain, so non-EVM publish-settle mis-routed
|
|
30
|
+
// to the EVM path. 3.10.1 selects the settlement chain from the inbound
|
|
31
|
+
// claim's `blockchain` (claim-driven) with guards. This is the connector half
|
|
32
|
+
// of #159 (Solana publish-settle proven on-chain; unblocks the Mina #158 /
|
|
33
|
+
// mill #157 town-side fixes for end-to-end validation). Patch bump — no
|
|
34
|
+
// SDK/admin contract change vs 3.10.0; bumped because townhouse needs the
|
|
35
|
+
// fixed (non-EVM-misrouting) settlement behavior per
|
|
36
|
+
// CONNECTOR_RELEASE_CONTRACT.md's patch-bump exception.
|
|
37
|
+
// v3.10.0 — Story 34.4 fund-custody zkApp bundle (#130/#131, closes #134). The
|
|
38
|
+
// connector now bundles the Story 34.4 `PaymentChannel` zkApp (FUND CUSTODY on
|
|
39
|
+
// deposit + FUND DISTRIBUTION on settle: the zkApp account escrows the deposit
|
|
40
|
+
// and `settle()` drains balanceB→participantB / balanceA→participantA). Its
|
|
41
|
+
// compiled verification key is byte-identical to the zkApp our harness deploys
|
|
42
|
+
// (VK hash 21482326729342759163995140331524541410906862862696135294081643945442581537217),
|
|
43
|
+
// so connector-driven `claimFromChannel`/`settle` proofs verify against the
|
|
44
|
+
// deployed contract. Minor bump; SDK/admin contract unchanged within 3.x.
|
|
45
|
+
// v3.9.13 — #128 openChannel deploy/initialize split. The zkApp openChannel
|
|
46
|
+
// path was combining contract deploy + initialize into one tx; 3.9.13 splits
|
|
47
|
+
// them so the on-chain channel opens cleanly.
|
|
48
|
+
// v3.9.12 — #126 zkApp tx fee + balance conservation. The apex's
|
|
49
|
+
// `claimFromChannel` settlement tx was broadcast with NO fee (failed at
|
|
50
|
+
// `Insufficient fee`); 3.9.12 sets the zkApp tx fee AND guards balance
|
|
51
|
+
// conservation (rejects a claim whose transferred amount would violate
|
|
52
|
+
// deposit-total conservation). Together with 3.9.13 the on-chain Mina
|
|
53
|
+
// claimFromChannel tx broadcasts and LANDS (zkApp nonce/balanceCommitment
|
|
54
|
+
// advance) — completing the non-EVM pay-to-write settle loop.
|
|
55
|
+
// v3.9.11 — #123 apex co-signs signatureB. `claimFromChannel` previously
|
|
56
|
+
// reused the client's signatureA as signatureB, so the on-chain dual-party
|
|
57
|
+
// verification reverted at `participant B signature verification failed`. With
|
|
58
|
+
// 3.9.11 the connector co-signs signatureB with the apex Mina key, so both
|
|
59
|
+
// signature checks pass and the on-chain Mina claimFromChannel tx lands
|
|
60
|
+
// (zkApp nonce/balanceCommitment advance). This was the LAST Mina blocker.
|
|
61
|
+
// v3.9.10 — #121 claimFromChannel signatureA wrapper. `claimFromChannel` now
|
|
62
|
+
// accepts the `signBalanceProof` wrapper ({commitment,signature:{r,s},...}) as
|
|
63
|
+
// `signatureA` (was: INVALID_PARAMETERS "Invalid signatureA" — wrapper vs bare
|
|
64
|
+
// {r,s} mismatch threw before any tx). This is the LAST Mina settle blocker:
|
|
65
|
+
// with it the connector submits the on-chain Mina claimFromChannel tx and the
|
|
66
|
+
// zkApp nonce/balanceCommitment advance.
|
|
67
|
+
// v3.9.9 — #118 advancing-claims acceptance in verifyBalanceProof. Resolves the
|
|
68
|
+
// nonce tension that blocked the Mina settle leg: the claim nonce was required to
|
|
69
|
+
// EQUAL the on-chain nonce, but `claimFromChannel` needs the claim to ADVANCE the
|
|
70
|
+
// channel (nonce > on-chain). 3.9.9 makes verifyBalanceProof accept advancing
|
|
71
|
+
// claims, so the connector can auto-drive `claimFromChannel` on a Mina publish.
|
|
72
|
+
// v3.9.8 — #117 Mina settlement-trigger fix. `CLAIM_RECEIVED` now emits the real
|
|
73
|
+
// `transferredAmount` (was hardcoded `BigInt(0)`), so the settlement-threshold
|
|
74
|
+
// check actually fires for Mina, triggering claimFromChannel().
|
|
75
|
+
// Together 3.9.8 + 3.9.9 complete the connector-driven on-chain Mina settle.
|
|
76
|
+
// v3.9.7 — #114 inbound Mina claimFromChannel + #84 dual-party. Enables the
|
|
77
|
+
// on-chain `claimFromChannel` for externally-opened (inbound) channels, fixing
|
|
78
|
+
// the `_participantCache` miss (ACCOUNT_NOT_FOUND) + off-chain/on-chain
|
|
79
|
+
// proof-message mismatch that blocked the Mina settle leg in 3.9.6; also closes
|
|
80
|
+
// #98/#84 (dual-party). This completes the full non-EVM on-chain settle
|
|
81
|
+
// (CLAIM_FROM_CHANNEL + SETTLE_CHANNEL) for BOTH Solana and Mina.
|
|
82
|
+
// Builds on the 3.9.6 chain:
|
|
83
|
+
// #94 (3.9.4) — Solana Ed25519 precompile / on-chain message reconstruction.
|
|
84
|
+
// #95 (3.9.4) — Mina getChannelState missing setActiveInstance.
|
|
85
|
+
// #98 (3.9.5) — Mina balance-proof commitment was compared against the zkApp
|
|
86
|
+
// address; fixed to compare the on-chain `balanceCommitment`.
|
|
87
|
+
// #99 (3.9.5) — Solana CLAIM_FROM_CHANNEL fee-payer decoupled from the claiming
|
|
88
|
+
// participant so the connector can unilaterally redeem a
|
|
89
|
+
// peer-signed inbound claim.
|
|
90
|
+
// 3.9.6 — connector-CI fix only (no runtime change vs 3.9.5).
|
|
91
|
+
// #114 (3.9.7) — on-chain claimFromChannel enabled for inbound channels.
|
|
92
|
+
// Builds on 3.9.3's Solana settle-executor channel-lookup fix (#92), 3.9.2's Mina
|
|
93
|
+
// settlement-side proof-encoding fix (#90), 3.9.1's #88 fix (SettlementExecutor
|
|
94
|
+
// resolves the settlement chain for dynamic anonymous HS peers), and 3.9.1's
|
|
95
|
+
// blockchain-typed inbound claim validation (validateClaimMessage switches on
|
|
96
|
+
// claim.blockchain → validateEVMClaim / validateSolanaClaim / validateMinaClaim).
|
|
97
|
+
// validateSolanaClaim accepts { blockchain:'solana', programId, channelAccount
|
|
98
|
+
// (base58), nonce, transferredAmount, signature, signerPublicKey (base58),
|
|
99
|
+
// cluster? }. No breaking changes to the SDK/admin contract within 3.x (verified
|
|
100
|
+
// >=3.3.2 through 3.10.3 — see packages/sdk/CONNECTOR_MIGRATION.md). Digest
|
|
101
|
+
// resolved via `docker buildx imagetools inspect` for tag 3.10.3 (manifest-index
|
|
102
|
+
// digest). To bump: see CONNECTOR_RELEASE_CONTRACT.md.
|
|
103
|
+
"ghcr.io/toon-protocol/connector@sha256:48d2160e4479aae068ebd8b735a0a063995f1f2f17308c847f3a9b6cc57b1de4"
|
|
104
|
+
);
|
|
105
|
+
var ACCOUNT_INDEX_TOWN = 0;
|
|
106
|
+
var ACCOUNT_INDEX_MILL = 1;
|
|
107
|
+
var ACCOUNT_INDEX_DVM = 2;
|
|
108
|
+
var ACCOUNT_INDEX_APEX = 3;
|
|
109
|
+
var TOWN_HEALTH_PORT = 3100;
|
|
110
|
+
var MILL_HEALTH_PORT = 3200;
|
|
111
|
+
var DVM_HEALTH_PORT = 3400;
|
|
112
|
+
|
|
113
|
+
export {
|
|
114
|
+
CONTAINER_PREFIX,
|
|
115
|
+
NODE_BTP_PORT,
|
|
116
|
+
DEFAULT_CONNECTOR_IMAGE,
|
|
117
|
+
ACCOUNT_INDEX_TOWN,
|
|
118
|
+
ACCOUNT_INDEX_MILL,
|
|
119
|
+
ACCOUNT_INDEX_DVM,
|
|
120
|
+
ACCOUNT_INDEX_APEX,
|
|
121
|
+
TOWN_HEALTH_PORT,
|
|
122
|
+
MILL_HEALTH_PORT,
|
|
123
|
+
DVM_HEALTH_PORT
|
|
124
|
+
};
|
|
125
|
+
//# sourceMappingURL=chunk-MNVIN5XK.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/constants.ts"],"sourcesContent":["/**\n * Shared constants for Townhouse package.\n *\n * Single source of truth for values used across multiple modules\n * (orchestrator, config-generator, CLI).\n */\n\n/** Container name prefix for all Townhouse-managed Docker containers */\nexport const CONTAINER_PREFIX = 'townhouse-';\n\n/** Internal BTP port exposed by node containers (Docker-internal only) */\nexport const NODE_BTP_PORT = 3000;\n\n/**\n * Default connector Docker image — digest-pinned per CONNECTOR_RELEASE_CONTRACT.md.\n *\n * To bump: capture a new digest by running the Story 45.1 publish workflow\n * against the desired connector tag, copy the resulting image-manifest.json\n * connector entry's digest, and update this constant + the contract canary\n * fixture. See packages/sdk/CONNECTOR_RELEASE_CONTRACT.md for the full bump\n * checklist + breaking-changes history.\n *\n * To read the human-readable tag for log output, consult dist/image-manifest.json:\n * manifest.images.connector.tag\n */\nexport const DEFAULT_CONNECTOR_IMAGE =\n // v3.10.4 — connector#137 (non-EVM inbound claim validator: Solana Ed25519 /\n // Mina verification wired to the BTP server) + connector#136 (dynamic-HS-peer\n // settlement: peerIdToChainMap populated via registerPeerChain), closing\n // toon#213 and unblocking Solana + Mina pay-to-write for dynamic HS apexes.\n // Validated live: bumping a running apex 3.10.3→3.10.4 made dynamic-HS Solana\n // and Mina on-chain settlement work end-to-end. Builds on:\n // v3.10.3 — connector#133 Mina claimFromChannel balance-conservation fix\n // (#134 + #135 test follow-up). For an inbound unidirectional Mina claim the\n // provider built the co-signed claim with balanceB=0, but the on-chain\n // PaymentChannel.claimFromChannel circuit asserts balanceA + balanceB ==\n // depositTotal and verifies both signatures over Poseidon([balanceA,balanceB,\n // salt]); balanceB=0 violated conservation → PROOF_GENERATION_FAILED before any\n // tx. 3.10.2 derives balanceB = depositTotal − balanceA from the public\n // on-chain depositTotal (3.10.3 hardens the integration tests). This is the\n // connector half of the LAST Mina publish-settle blocker (#158): with it +\n // the client conserved-balanceB signing fix, a Mina-settled publish drives\n // claimFromChannel to an on-chain landing (nonceField 0→1, proven live).\n // Patch bump — no SDK/admin contract change vs 3.10.1; bumped because townhouse\n // needs the conservation-correct settle behavior (CONNECTOR_RELEASE_CONTRACT.md\n // patch-bump exception).\n // v3.10.1 — connector#132 settlement claim-chain routing fix. The\n // settlement-executor was routing Solana/Mina settle by a stale EVM channel\n // instead of by the claim's own chain, so non-EVM publish-settle mis-routed\n // to the EVM path. 3.10.1 selects the settlement chain from the inbound\n // claim's `blockchain` (claim-driven) with guards. This is the connector half\n // of #159 (Solana publish-settle proven on-chain; unblocks the Mina #158 /\n // mill #157 town-side fixes for end-to-end validation). Patch bump — no\n // SDK/admin contract change vs 3.10.0; bumped because townhouse needs the\n // fixed (non-EVM-misrouting) settlement behavior per\n // CONNECTOR_RELEASE_CONTRACT.md's patch-bump exception.\n // v3.10.0 — Story 34.4 fund-custody zkApp bundle (#130/#131, closes #134). The\n // connector now bundles the Story 34.4 `PaymentChannel` zkApp (FUND CUSTODY on\n // deposit + FUND DISTRIBUTION on settle: the zkApp account escrows the deposit\n // and `settle()` drains balanceB→participantB / balanceA→participantA). Its\n // compiled verification key is byte-identical to the zkApp our harness deploys\n // (VK hash 21482326729342759163995140331524541410906862862696135294081643945442581537217),\n // so connector-driven `claimFromChannel`/`settle` proofs verify against the\n // deployed contract. Minor bump; SDK/admin contract unchanged within 3.x.\n // v3.9.13 — #128 openChannel deploy/initialize split. The zkApp openChannel\n // path was combining contract deploy + initialize into one tx; 3.9.13 splits\n // them so the on-chain channel opens cleanly.\n // v3.9.12 — #126 zkApp tx fee + balance conservation. The apex's\n // `claimFromChannel` settlement tx was broadcast with NO fee (failed at\n // `Insufficient fee`); 3.9.12 sets the zkApp tx fee AND guards balance\n // conservation (rejects a claim whose transferred amount would violate\n // deposit-total conservation). Together with 3.9.13 the on-chain Mina\n // claimFromChannel tx broadcasts and LANDS (zkApp nonce/balanceCommitment\n // advance) — completing the non-EVM pay-to-write settle loop.\n // v3.9.11 — #123 apex co-signs signatureB. `claimFromChannel` previously\n // reused the client's signatureA as signatureB, so the on-chain dual-party\n // verification reverted at `participant B signature verification failed`. With\n // 3.9.11 the connector co-signs signatureB with the apex Mina key, so both\n // signature checks pass and the on-chain Mina claimFromChannel tx lands\n // (zkApp nonce/balanceCommitment advance). This was the LAST Mina blocker.\n // v3.9.10 — #121 claimFromChannel signatureA wrapper. `claimFromChannel` now\n // accepts the `signBalanceProof` wrapper ({commitment,signature:{r,s},...}) as\n // `signatureA` (was: INVALID_PARAMETERS \"Invalid signatureA\" — wrapper vs bare\n // {r,s} mismatch threw before any tx). This is the LAST Mina settle blocker:\n // with it the connector submits the on-chain Mina claimFromChannel tx and the\n // zkApp nonce/balanceCommitment advance.\n // v3.9.9 — #118 advancing-claims acceptance in verifyBalanceProof. Resolves the\n // nonce tension that blocked the Mina settle leg: the claim nonce was required to\n // EQUAL the on-chain nonce, but `claimFromChannel` needs the claim to ADVANCE the\n // channel (nonce > on-chain). 3.9.9 makes verifyBalanceProof accept advancing\n // claims, so the connector can auto-drive `claimFromChannel` on a Mina publish.\n // v3.9.8 — #117 Mina settlement-trigger fix. `CLAIM_RECEIVED` now emits the real\n // `transferredAmount` (was hardcoded `BigInt(0)`), so the settlement-threshold\n // check actually fires for Mina, triggering claimFromChannel().\n // Together 3.9.8 + 3.9.9 complete the connector-driven on-chain Mina settle.\n // v3.9.7 — #114 inbound Mina claimFromChannel + #84 dual-party. Enables the\n // on-chain `claimFromChannel` for externally-opened (inbound) channels, fixing\n // the `_participantCache` miss (ACCOUNT_NOT_FOUND) + off-chain/on-chain\n // proof-message mismatch that blocked the Mina settle leg in 3.9.6; also closes\n // #98/#84 (dual-party). This completes the full non-EVM on-chain settle\n // (CLAIM_FROM_CHANNEL + SETTLE_CHANNEL) for BOTH Solana and Mina.\n // Builds on the 3.9.6 chain:\n // #94 (3.9.4) — Solana Ed25519 precompile / on-chain message reconstruction.\n // #95 (3.9.4) — Mina getChannelState missing setActiveInstance.\n // #98 (3.9.5) — Mina balance-proof commitment was compared against the zkApp\n // address; fixed to compare the on-chain `balanceCommitment`.\n // #99 (3.9.5) — Solana CLAIM_FROM_CHANNEL fee-payer decoupled from the claiming\n // participant so the connector can unilaterally redeem a\n // peer-signed inbound claim.\n // 3.9.6 — connector-CI fix only (no runtime change vs 3.9.5).\n // #114 (3.9.7) — on-chain claimFromChannel enabled for inbound channels.\n // Builds on 3.9.3's Solana settle-executor channel-lookup fix (#92), 3.9.2's Mina\n // settlement-side proof-encoding fix (#90), 3.9.1's #88 fix (SettlementExecutor\n // resolves the settlement chain for dynamic anonymous HS peers), and 3.9.1's\n // blockchain-typed inbound claim validation (validateClaimMessage switches on\n // claim.blockchain → validateEVMClaim / validateSolanaClaim / validateMinaClaim).\n // validateSolanaClaim accepts { blockchain:'solana', programId, channelAccount\n // (base58), nonce, transferredAmount, signature, signerPublicKey (base58),\n // cluster? }. No breaking changes to the SDK/admin contract within 3.x (verified\n // >=3.3.2 through 3.10.3 — see packages/sdk/CONNECTOR_MIGRATION.md). Digest\n // resolved via `docker buildx imagetools inspect` for tag 3.10.3 (manifest-index\n // digest). To bump: see CONNECTOR_RELEASE_CONTRACT.md.\n 'ghcr.io/toon-protocol/connector@sha256:48d2160e4479aae068ebd8b735a0a063995f1f2f17308c847f3a9b6cc57b1de4';\n\n/**\n * Human-readable connector tag for the digest pinned in DEFAULT_CONNECTOR_IMAGE.\n *\n * This is the machine-readable counterpart to the `@sha256:` digest above. It\n * MUST stay in lockstep with BOTH:\n * 1. the `@sha256:<digest>` in DEFAULT_CONNECTOR_IMAGE (above), and\n * 2. `env.CONNECTOR_VERSION_DEFAULT` in\n * `.github/workflows/publish-townhouse-images.yml`.\n *\n * The `connector-version-alignment.test.ts` source-level guard asserts (1) the\n * workflow env equals this tag and (2) DEFAULT_CONNECTOR_IMAGE is well-formed,\n * so a human bumping one but not the other fails CI at PR time — BEFORE a\n * release. (PR #165 drifted constants.ts to 3.10.3 while leaving the workflow\n * env at 3.10.0, hard-failing preflight and silently breaking the v0.17.4 and\n * v0.17.5 publishes.) The live tag↔digest resolution stays in the workflow's\n * preflight job (`docker buildx imagetools inspect`); this constant only guards\n * the SOURCE-level human drift. When bumping the connector: update the digest\n * above, this tag, AND the workflow env together.\n */\nexport const DEFAULT_CONNECTOR_TAG = '3.10.4';\n\n/**\n * HD wallet account indices per node type (Story 21.4, D21-008).\n * BIP-44 paths: m/44'/{coin}'/ACCOUNT'/0/0\n */\nexport const ACCOUNT_INDEX_TOWN = 0;\nexport const ACCOUNT_INDEX_MILL = 1;\nexport const ACCOUNT_INDEX_DVM = 2;\n/**\n * Apex (connector) settlement account. The apex is the parent connector\n * (`g.townhouse`) that signs settlement claims; its key is derived from the\n * operator mnemonic at this index so the operator never has to supply a raw\n * settlement key. Index 3 continues the town/mill/dvm sequence (and matches the\n * dev convention where the apex is Anvil account[3], 0x90F79bf6…).\n */\nexport const ACCOUNT_INDEX_APEX = 3;\n\n/** BLS health port exposed by each node container type (internal Docker port). */\nexport const TOWN_HEALTH_PORT = 3100;\nexport const MILL_HEALTH_PORT = 3200;\nexport const DVM_HEALTH_PORT = 3400;\n"],"mappings":";;;AAQO,IAAM,mBAAmB;AAGzB,IAAM,gBAAgB;AActB,IAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAiGX;AAAA;AA2BK,IAAM,qBAAqB;AAC3B,IAAM,qBAAqB;AAC3B,IAAM,oBAAoB;AAQ1B,IAAM,qBAAqB;AAG3B,IAAM,mBAAmB;AACzB,IAAM,mBAAmB;AACzB,IAAM,kBAAkB;","names":[]}
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import Docker from 'dockerode';
|
|
3
|
+
import { W as WalletManager, D as DockerOrchestrator, T as TownhouseConfig, C as ComposeLoaderOptions, N as NodeType } from './orchestrator-dGq7CeaO.js';
|
|
4
|
+
import 'node:events';
|
|
5
|
+
import '@toon-protocol/core';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Boot rebinder — recreate provisioned child node containers from nodes.yaml on
|
|
9
|
+
* `townhouse hs up`.
|
|
10
|
+
*
|
|
11
|
+
* `hs down` runs `docker compose down` (removing child containers) and `hs up`'s
|
|
12
|
+
* `orchestrator.up([])` only boots the apex (connector + townhouse-api). Without
|
|
13
|
+
* this, a restart leaves previously-added town/mill/dvm children stopped, and
|
|
14
|
+
* the BootReconciler would re-register peers pointing at containers that no
|
|
15
|
+
* longer exist. This module rebuilds each child's full env from the wallet +
|
|
16
|
+
* config and (re)starts it via `startNodeViaCompose`, which is idempotent:
|
|
17
|
+
* - container already running with identical env → docker compose no-ops;
|
|
18
|
+
* - config changed since last start (e.g. mill relays edited) → recreated.
|
|
19
|
+
* That second case is the "auto-rebind from config" behaviour: edit config.yaml,
|
|
20
|
+
* `hs up`, and the children pick up the change.
|
|
21
|
+
*
|
|
22
|
+
* Run this BEFORE the BootReconciler so containers exist when peers re-register.
|
|
23
|
+
* Every step is non-fatal — a failure to rebind one node is logged and the rest
|
|
24
|
+
* proceed; apex boot is never blocked.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
/** Minimal wallet surface the rebinder needs (keeps it test-stubbable). */
|
|
28
|
+
type RebindWallet = Pick<WalletManager, 'deriveNodeKey' | 'getMnemonic' | 'getNodeKeys'>;
|
|
29
|
+
/** Minimal orchestrator surface the rebinder needs. */
|
|
30
|
+
type RebindOrchestrator = Pick<DockerOrchestrator, 'startNodeViaCompose'>;
|
|
31
|
+
interface RebindDeps {
|
|
32
|
+
nodesYamlPath: string;
|
|
33
|
+
wallet: RebindWallet;
|
|
34
|
+
orchestrator: RebindOrchestrator;
|
|
35
|
+
config: TownhouseConfig;
|
|
36
|
+
/**
|
|
37
|
+
* Apex public BTP URL injected into the town's env so its kind:10032
|
|
38
|
+
* advertises a reachable endpoint (resolved by the caller from
|
|
39
|
+
* config/host.json — see resolvePublicBtpUrl). Omit for non-town or when the
|
|
40
|
+
* hostname isn't resolved yet (town falls back to its default).
|
|
41
|
+
*/
|
|
42
|
+
publicBtpUrl?: string;
|
|
43
|
+
/**
|
|
44
|
+
* Public Nostr relay read URL injected into the town's env so its
|
|
45
|
+
* kind:10032 advertises where clients subscribe (resolved by the caller from
|
|
46
|
+
* config/host.json — see resolveRelayUrl). Omit for non-town / unexposed.
|
|
47
|
+
*/
|
|
48
|
+
relayUrl?: string;
|
|
49
|
+
/** Optional progress sink (defaults to no-op). */
|
|
50
|
+
log?: (line: string) => void;
|
|
51
|
+
}
|
|
52
|
+
interface RebindSummary {
|
|
53
|
+
/** Node ids whose `startNodeViaCompose` was invoked successfully. */
|
|
54
|
+
started: string[];
|
|
55
|
+
/** Node ids deliberately not started, with the reason. */
|
|
56
|
+
skipped: {
|
|
57
|
+
id: string;
|
|
58
|
+
reason: string;
|
|
59
|
+
}[];
|
|
60
|
+
/** Node ids whose rebind threw, with the error message. */
|
|
61
|
+
failed: {
|
|
62
|
+
id: string;
|
|
63
|
+
err: string;
|
|
64
|
+
}[];
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Cross-platform browser opener for the wizard CLI command.
|
|
69
|
+
* Uses platform-native launchers; errors are non-fatal.
|
|
70
|
+
*/
|
|
71
|
+
interface BrowserOpener {
|
|
72
|
+
open(url: string): Promise<void>;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Port-collision preflight for `townhouse hs up` (Epic 49 Followup B).
|
|
77
|
+
*
|
|
78
|
+
* Detects host-port conflicts BEFORE handing off to Docker, so operators get
|
|
79
|
+
* an actionable error message instead of a cryptic mid-boot EADDRINUSE.
|
|
80
|
+
*
|
|
81
|
+
* Detection strategy (defense in depth):
|
|
82
|
+
* 1. Bind a transient TCP socket to 127.0.0.1:<port> and immediately close.
|
|
83
|
+
* If bind throws EADDRINUSE, the port is occupied. Pure Node, no deps,
|
|
84
|
+
* works on Linux/Mac/WSL — this is the source of truth.
|
|
85
|
+
* 2. If (1) flags a collision, ask Docker for the offending container's
|
|
86
|
+
* name + compose project so the message can name a culprit. Best-effort
|
|
87
|
+
* enrichment — Docker may be unreachable, in which case we still report
|
|
88
|
+
* the port and suggest `lsof` for non-Docker processes.
|
|
89
|
+
*/
|
|
90
|
+
|
|
91
|
+
interface PortCollision {
|
|
92
|
+
/** The host port that is already bound. */
|
|
93
|
+
port: number;
|
|
94
|
+
/** Name of the Docker container holding the port (when known). */
|
|
95
|
+
containerName?: string;
|
|
96
|
+
/** Compose project the container belongs to (when known). */
|
|
97
|
+
composeProject?: string;
|
|
98
|
+
/** Container status string e.g. "Up 5 hours" (when known). */
|
|
99
|
+
status?: string;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* CLI entrypoint for `@toon-protocol/hub` (Story 21.1).
|
|
104
|
+
*
|
|
105
|
+
* Subcommands: init, up, down, status, --help
|
|
106
|
+
*
|
|
107
|
+
* Usage:
|
|
108
|
+
* townhouse init [--force]
|
|
109
|
+
* townhouse up
|
|
110
|
+
* townhouse down
|
|
111
|
+
* townhouse status
|
|
112
|
+
*/
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Error thrown when `main()` is invoked with `--help`. Callers (tests) can
|
|
116
|
+
* distinguish this from genuine failures; the top-level entrypoint catches
|
|
117
|
+
* it and exits 0.
|
|
118
|
+
*/
|
|
119
|
+
declare class CliHelpRequested extends Error {
|
|
120
|
+
constructor();
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* This package's version, read from its own package.json at runtime. Used by
|
|
124
|
+
* `townhouse --version` so tooling that shells out (e.g. @toon-protocol/
|
|
125
|
+
* townhouse-mcp's version-skew probe) has a real version to compare against.
|
|
126
|
+
* Resolves `../package.json` relative to the module — package root from
|
|
127
|
+
* `dist/cli.js`, and `packages/townhouse/package.json` under vitest/src.
|
|
128
|
+
*/
|
|
129
|
+
declare function readCliVersion(): string;
|
|
130
|
+
/**
|
|
131
|
+
* Dependency-injection overrides for the `hs up` / `hs down` CLI path.
|
|
132
|
+
* Used by unit tests to stub out Docker, file I/O, and admin client.
|
|
133
|
+
*/
|
|
134
|
+
interface CliHsOverrides {
|
|
135
|
+
/** Override materializeComposeTemplate (avoids disk writes in tests). */
|
|
136
|
+
materializeComposeTemplate?: (profile: string, opts?: ComposeLoaderOptions) => {
|
|
137
|
+
composePath: string;
|
|
138
|
+
manifestPath: string;
|
|
139
|
+
};
|
|
140
|
+
/** Override the DockerOrchestrator constructor (avoids real Docker in tests). */
|
|
141
|
+
createOrchestrator?: (docker: Docker, config: TownhouseConfig, walletManager: WalletManager | undefined, options: {
|
|
142
|
+
profile: 'hs' | 'direct';
|
|
143
|
+
composePath: string;
|
|
144
|
+
}) => {
|
|
145
|
+
up: (profiles: NodeType[]) => Promise<void>;
|
|
146
|
+
down: () => Promise<void>;
|
|
147
|
+
on: (event: string, handler: (...args: unknown[]) => void) => unknown;
|
|
148
|
+
/**
|
|
149
|
+
* Pre-pull a single image ref (Epic 49 Followup D).
|
|
150
|
+
* Optional on the stub interface — when omitted on a real orchestrator,
|
|
151
|
+
* the cold-pull narration phase is skipped (silent degrade).
|
|
152
|
+
*/
|
|
153
|
+
pullImage?: (image: string) => Promise<void>;
|
|
154
|
+
/**
|
|
155
|
+
* Start/recreate a child node container with the given env overlay. Used by
|
|
156
|
+
* the boot rebinder; optional on the stub so existing tests that don't
|
|
157
|
+
* provision children need not implement it.
|
|
158
|
+
*/
|
|
159
|
+
startNodeViaCompose?: (type: NodeType, env: Record<string, string>) => Promise<void>;
|
|
160
|
+
/** Relay hidden-service sidecar lifecycle (HS-mode public relay reads). */
|
|
161
|
+
ensureRelaySidecar?: () => Promise<void>;
|
|
162
|
+
getRelayHsHostname?: (timeoutMs?: number) => Promise<string | null>;
|
|
163
|
+
};
|
|
164
|
+
/**
|
|
165
|
+
* Override the boot rebinder (auto-rebind of child containers on `hs up`).
|
|
166
|
+
* Tests inject a spy to assert wiring without touching Docker/the wallet.
|
|
167
|
+
* When omitted, the default calls the real `rebindChildContainers`.
|
|
168
|
+
*/
|
|
169
|
+
rebindChildren?: (deps: RebindDeps) => Promise<RebindSummary>;
|
|
170
|
+
/** Override ConnectorAdminClient construction (avoids real HTTP in tests). */
|
|
171
|
+
createAdminClient?: (baseUrl: string, timeoutMs: number) => {
|
|
172
|
+
getHsHostname: () => Promise<{
|
|
173
|
+
hostname: string | null;
|
|
174
|
+
publishedAt: string | null;
|
|
175
|
+
}>;
|
|
176
|
+
};
|
|
177
|
+
/** Override `docker compose down -v` spawn for --rotate-keys (avoids real Docker). */
|
|
178
|
+
runComposeDown?: (composePath: string, withVolumes: boolean) => Promise<void>;
|
|
179
|
+
/**
|
|
180
|
+
* Override BootReconciler construction (Story 46.1). Tests inject a stub
|
|
181
|
+
* with a spied-on `reconcile()` to assert wiring without touching disk
|
|
182
|
+
* or the connector. When omitted, the default constructs a real
|
|
183
|
+
* `BootReconciler` against `~/.townhouse/{nodes.yaml,reconciler.log}`.
|
|
184
|
+
*/
|
|
185
|
+
createReconciler?: (nodesYamlPath: string, reconcilerLogPath: string) => {
|
|
186
|
+
reconcile: () => Promise<void>;
|
|
187
|
+
};
|
|
188
|
+
/**
|
|
189
|
+
* Override the port-collision preflight check (Epic 49 Followup B).
|
|
190
|
+
* Default invokes `checkHsPortCollisions(docker)` from
|
|
191
|
+
* `./cli/preflight-ports.js`. Tests inject a stub that returns either
|
|
192
|
+
* `[]` (happy path) or a fabricated PortCollision[] (collision path) so
|
|
193
|
+
* the production socket-bind + Docker enrichment is not exercised in
|
|
194
|
+
* unit tests.
|
|
195
|
+
*/
|
|
196
|
+
checkPortCollisions?: (docker: Docker) => Promise<PortCollision[]>;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Dependency-injection overrides for the `node add` / `node remove` / `node list` CLI path.
|
|
200
|
+
* Used by unit tests to stub `fetch` and the interactive confirmation prompt.
|
|
201
|
+
*/
|
|
202
|
+
interface CliNodeCommandOverrides {
|
|
203
|
+
fetch?: (url: string, init?: RequestInit) => Promise<Response>;
|
|
204
|
+
confirm?: (question: string) => Promise<boolean>;
|
|
205
|
+
apiUrl?: string;
|
|
206
|
+
}
|
|
207
|
+
declare function main(argv: string[], dockerInstance?: Docker, browserOpener?: BrowserOpener, hsOverrides?: CliHsOverrides, nodeCommandOverrides?: CliNodeCommandOverrides): Promise<void>;
|
|
208
|
+
|
|
209
|
+
export { CliHelpRequested, type CliHsOverrides, type CliNodeCommandOverrides, main, readCliVersion };
|