From 864d363aaa2300a20134f974c956737ef5e33285 Mon Sep 17 00:00:00 2001 From: FilipBl4gojevic <84703395+FilipBl4gojevic@users.noreply.github.com> Date: Sat, 1 Aug 2026 10:10:27 +0200 Subject: [PATCH] chore: align source copy with the brand voice - AP3X vocabulary, research-themed examples, no em dashes --- packages/builder/src/vector/agent-network.ts | 24 ++++++------ packages/builder/src/vector/build.ts | 6 +-- packages/builder/src/vector/registry-build.ts | 4 +- packages/builder/src/vector/vector.ts | 20 +++++----- .../test/smoke/tool-schemas.snapshot.json | 22 +++++------ packages/shared/src/provider.ts | 2 +- packages/shared/src/tx.ts | 2 +- packages/shared/src/types.ts | 2 +- packages/signer/src/audit.ts | 38 +++++++++---------- packages/signer/src/config.ts | 2 +- packages/signer/src/decode.ts | 4 +- packages/signer/src/index.ts | 2 +- packages/signer/src/policy.ts | 20 +++++----- packages/signer/src/sign.ts | 8 ++-- packages/signer/src/tools.ts | 14 +++---- 15 files changed, 85 insertions(+), 85 deletions(-) diff --git a/packages/builder/src/vector/agent-network.ts b/packages/builder/src/vector/agent-network.ts index e242fc9..5268f95 100644 --- a/packages/builder/src/vector/agent-network.ts +++ b/packages/builder/src/vector/agent-network.ts @@ -38,7 +38,7 @@ export function registerAgentNetworkTools(server: McpServer, identity: string) { return null; } - // vector_get_agent_profile (read-only) — UNCHANGED behavior; body moves to typed helpers + // vector_get_agent_profile (read-only) - UNCHANGED behavior; body moves to typed helpers server.tool( "vector_get_agent_profile", "Get a registered agent's profile from the on-chain registry by DID (did:vector:agent:...)", @@ -88,12 +88,12 @@ ${capList} } ); - // vector_discover_agents (read-only) — UNCHANGED behavior + // vector_discover_agents (read-only) - UNCHANGED behavior server.tool( "vector_discover_agents", "Discover registered agents in the Vector on-chain registry, optionally filtered by capability or framework", { - capability: z.string().optional().describe("Filter by capability tag (e.g. 'investing', 'research')"), + capability: z.string().optional().describe("Filter by capability tag (e.g. 'research', 'data-extraction')"), framework: z.string().optional().describe("Filter by framework (e.g. 'OpenClaw', 'LangChain', 'CrewAI')"), limit: z.number().optional().default(20).describe("Maximum number of agents to return (default: 20)"), }, @@ -142,15 +142,15 @@ ${capList} } ); - // vector_build_register_agent — KEYLESS + // vector_build_register_agent - KEYLESS server.tool( "vector_build_register_agent", "Build an UNSIGNED transaction that registers an agent in the Vector on-chain registry (mints a soulbound identity NFT, locks a 10 AP3X deposit). Takes no key material. Sign locally with vector_signer_sign, broadcast with vector_submit_transaction, then confirm with vector_await_transaction.", { changeAddress: z.string().describe("Your wallet address (source of the deposit and change). Get it from vector_signer_get_address."), - name: z.string().min(1).max(64).describe("Agent name (e.g. 'TradingBot', 'ResearchAgent')"), + name: z.string().min(1).max(64).describe("Agent name (e.g. 'ResearchAgent', 'ArchiveBot')"), description: z.string().max(256).describe("Short description of the agent's purpose"), - capabilities: z.array(z.string()).describe("List of capability tags (e.g. ['investing', 'research', 'environmental'])"), + capabilities: z.array(z.string()).describe("List of capability tags (e.g. ['research', 'data-extraction', 'environmental'])"), framework: z.string().describe("Framework used (e.g. 'OpenClaw', 'LangChain', 'CrewAI', 'custom')"), endpoint: z.string().describe("A2A communication endpoint URL (or empty string if not applicable)"), }, @@ -196,7 +196,7 @@ The DID above is bound to the exact wallet UTxO this build consumed - if that UT } ); - // vector_build_update_agent — KEYLESS + // vector_build_update_agent - KEYLESS server.tool( "vector_build_update_agent", "Build an UNSIGNED transaction that updates a registered agent's profile fields. Only the specified fields change; others are preserved. Takes no key material - the on-chain validator requires the owner's signature, which you add locally with vector_signer_sign before vector_submit_transaction, then confirm with vector_await_transaction.", @@ -249,7 +249,7 @@ The identity NFT and deposit are unchanged by this update. ${SIGN_AND_SUBMIT_COP } ); - // vector_build_transfer_agent — KEYLESS + // vector_build_transfer_agent - KEYLESS server.tool( "vector_build_transfer_agent", "Build an UNSIGNED transaction that transfers agent ownership to a new address (must be a verification-key address, not a script). Takes no key material. Sign locally with vector_signer_sign, broadcast with vector_submit_transaction, then confirm with vector_await_transaction.", @@ -300,7 +300,7 @@ After this transaction confirms, only the new owner can update, transfer, or der } ); - // vector_build_deregister_agent — KEYLESS + // vector_build_deregister_agent - KEYLESS server.tool( "vector_build_deregister_agent", "Build an UNSIGNED transaction that deregisters an agent (burns the identity NFT, returns the 10 AP3X deposit to the owner wallet). Takes no key material. Sign locally with vector_signer_sign, broadcast with vector_submit_transaction, then confirm with vector_await_transaction.", @@ -343,19 +343,19 @@ The identity NFT is burned by this transaction; the deposit returns to the chang 1. Verify the agent DID is correct 2. The changeAddress must be the agent's current owner wallet 3. Use vector_get_agent_profile to check the agent's current state -4. If the error mentions needing a plain AP3X-only UTxO: the wallet must hold at least one token-free UTxO; send yourself a small AP3X payment first.`, +4. If the error mentions needing a plain AP3X-only UTxO: the wallet must hold at least one token-free UTxO; send yourself a small AP3X transfer first.`, }], }; } } ); - // vector_build_message_agent — KEYLESS + // vector_build_message_agent - KEYLESS server.tool( "vector_build_message_agent", "Build an UNSIGNED transaction that sends an on-chain message to a registered agent via TX metadata (label 674), delivering 2 AP3X to the agent's owner address. Takes no key material. Sign locally with vector_signer_sign, broadcast with vector_submit_transaction, then confirm with vector_await_transaction.", { - changeAddress: z.string().describe("Your wallet address (pays the 2 AP3X delivery and fee; recorded as the sender). Get it from vector_signer_get_address."), + changeAddress: z.string().describe("Your wallet address (covers the 2 AP3X delivery and fee; recorded as the sender). Get it from vector_signer_get_address."), agent_id: z.string().describe("Recipient agent DID: did:vector:agent:{policyId}:{nftAssetName}"), message_type: z.enum(["inquiry", "proposal", "result"]).describe("Type of message"), payload: z.string().max(512).describe("Message payload (string, max 512 chars)"), diff --git a/packages/builder/src/vector/build.ts b/packages/builder/src/vector/build.ts index c6965d7..a308d50 100644 --- a/packages/builder/src/vector/build.ts +++ b/packages/builder/src/vector/build.ts @@ -1,6 +1,6 @@ // packages/builder/src/vector/build.ts // -// Keyless transaction building — the core of the non-custodial split's +// Keyless transaction building - the core of the non-custodial split's // builder side. Every function here takes an already-initialized Lucid // instance whose wallet was selected with selectWallet.fromAddress (no key // material anywhere in this package) and returns UNSIGNED CBOR. Signing @@ -30,7 +30,7 @@ export async function lucidForAddress(provider: Provider, changeAddress: string) const lucid = await Lucid(provider, 'Mainnet'); const utxos = await lucid.utxosAt(changeAddress); if (utxos.length === 0) { - throw new Error(`No UTxOs found at ${changeAddress} — the wallet is empty or the address is wrong`); + throw new Error(`No UTxOs found at ${changeAddress} - the wallet is empty or the address is wrong`); } lucid.selectWallet.fromAddress(changeAddress, utxos); return lucid; @@ -181,7 +181,7 @@ export async function buildInteractContract( .addSigner(p.changeAddress) .complete(); } catch { - // Retry without the native UPLC evaluator — falls back to the provider's + // Retry without the native UPLC evaluator - falls back to the provider's // evaluateTx (network); mirrors the pre-split behaviour for chain quirks. completed = await lucid.newTx() .collectFrom(scriptUtxos, redeemerData) diff --git a/packages/builder/src/vector/registry-build.ts b/packages/builder/src/vector/registry-build.ts index 4dd757a..cbd7cbf 100644 --- a/packages/builder/src/vector/registry-build.ts +++ b/packages/builder/src/vector/registry-build.ts @@ -171,7 +171,7 @@ export async function buildRegisterAgent(lucid: LucidEvolution, p: { const keys = Object.keys(u.assets); return keys.length === 1 && keys[0] === 'lovelace' && u.assets['lovelace'] >= MIN_AP3X_DEPOSIT + 2_000_000n; }) || utxos[0]; - if (!oneShotUtxo) throw new Error('No UTxOs at the changeAddress. Fund the wallet first.'); + if (!oneShotUtxo) throw new Error('No UTxOs at the changeAddress. Add AP3X to the wallet first.'); const nftAssetName = deriveNftAssetName(oneShotUtxo.txHash, oneShotUtxo.outputIndex); const nftUnit = `${REGISTRY_POLICY_ID}${nftAssetName}`; const datum = buildAgentDatum(vkeyHash, p.name, p.description, p.capabilities, p.framework, p.endpoint); @@ -317,7 +317,7 @@ export async function buildDeregisterAgent( }) .sort((a, b) => Number(b.assets.lovelace - a.assets.lovelace))[0]; if (!feeUtxo) { - throw new Error("Deregistration needs a plain AP3X-only UTxO in the wallet to clear the validator's returned-change floor; send yourself a small AP3X-only payment first."); + throw new Error("Deregistration needs a plain AP3X-only UTxO in the wallet to clear the validator's returned-change floor; send yourself a small AP3X-only transfer first."); } const completed = await lucid.newTx() .collectFrom([utxo], spendRedeemer) diff --git a/packages/builder/src/vector/vector.ts b/packages/builder/src/vector/vector.ts index 087e0a9..19a1690 100644 --- a/packages/builder/src/vector/vector.ts +++ b/packages/builder/src/vector/vector.ts @@ -172,12 +172,12 @@ ${utxoList}`, } ); - // vector_build_send_apex - build an UNSIGNED AP3X payment (keyless) + // vector_build_send_apex - build an UNSIGNED AP3X transfer (keyless) server.tool( "vector_build_send_apex", "Build an UNSIGNED transaction sending AP3X to a recipient. Takes no key material - sign the returned CBOR with your local signer (vector_signer_sign), then broadcast with vector_submit_transaction and confirm with vector_await_transaction.", { - changeAddress: z.string().describe("Your wallet address (source of funds; receives change). Get it from your local signer's vector_signer_get_address."), + changeAddress: z.string().describe("Your wallet address (holds the AP3X; receives change). Get it from your local signer's vector_signer_get_address."), recipientAddress: z.string().describe("Recipient Vector address (addr1...)"), amount: z.number().min(0.000001).describe("Amount of AP3X to send (minimum 0.000001 = 1 lovelace; the ledger's own minimum-UTxO rule applies per output and will reject dust with a clear error)"), metadata: z.string().optional().describe("Optional transaction metadata in JSON format"), @@ -205,7 +205,7 @@ ${utxoList}`, ${result.txCbor} \`\`\` -Non-custodial flow: 1) sign locally with vector_signer_sign { txCbor } — your keys never leave your machine; 2) broadcast with vector_submit_transaction { signedTxCbor }; 3) confirm with vector_await_transaction { txHash }.`, +Non-custodial flow: 1) sign locally with vector_signer_sign { txCbor } - your keys never leave your machine; 2) broadcast with vector_submit_transaction { signedTxCbor }; 3) confirm with vector_await_transaction { txHash }.`, }], }; } catch (err) { @@ -230,7 +230,7 @@ Non-custodial flow: 1) sign locally with vector_signer_sign { txCbor } — your "vector_build_send_tokens", "Build an UNSIGNED transaction sending Vector native tokens. Takes no key material - sign the returned CBOR with your local signer (vector_signer_sign), then broadcast with vector_submit_transaction and confirm with vector_await_transaction.", { - changeAddress: z.string().describe("Your wallet address (source of funds; receives change). Get it from your local signer's vector_signer_get_address."), + changeAddress: z.string().describe("Your wallet address (holds the AP3X; receives change). Get it from your local signer's vector_signer_get_address."), recipientAddress: z.string().describe("Recipient Vector address (addr1...)"), policyId: z.string().describe("Token policy ID (56 hex characters)"), assetName: z.string().describe("Asset name (text or hex; can be empty for policy-only tokens)"), @@ -287,7 +287,7 @@ Non-custodial flow: 1) sign locally with vector_signer_sign { txCbor }; 2) broad "vector_build_transaction", "Build an UNSIGNED multi-output transaction with optional metadata. Takes no key material and never submits - sign the returned CBOR with your local signer (vector_signer_sign), then broadcast with vector_submit_transaction and confirm with vector_await_transaction.", { - changeAddress: z.string().describe("Your wallet address (source of funds; receives change). Get it from your local signer's vector_signer_get_address."), + changeAddress: z.string().describe("Your wallet address (holds the AP3X; receives change). Get it from your local signer's vector_signer_get_address."), outputs: z.array(z.object({ address: z.string().describe("Recipient Vector address"), lovelace: z.number().describe("Amount in lovelace (1 AP3X = 1,000,000 lovelace)"), @@ -602,9 +602,9 @@ ${txList} // vector_build_deploy_contract - build an UNSIGNED contract deployment (keyless) server.tool( "vector_build_deploy_contract", - "Build an UNSIGNED transaction deploying a Plutus/Aiken smart contract (locks funds at its script address). Takes no key material - sign with your local signer, then broadcast with vector_submit_transaction and confirm with vector_await_transaction.", + "Build an UNSIGNED transaction deploying a Plutus/Aiken smart contract (locks AP3X at its script address). Takes no key material - sign with your local signer, then broadcast with vector_submit_transaction and confirm with vector_await_transaction.", { - changeAddress: z.string().describe("Your wallet address (source of funds; receives change). Get it from your local signer's vector_signer_get_address."), + changeAddress: z.string().describe("Your wallet address (holds the AP3X; receives change). Get it from your local signer's vector_signer_get_address."), scriptCbor: z.string().describe("Compiled Plutus/Aiken script in CBOR hex format"), scriptType: z.enum(["PlutusV1", "PlutusV2", "PlutusV3"]).describe("Script version"), initialDatum: z.string().optional().describe("Initial datum as CBOR hex. Use 'd87980' for void/unit datum. Defaults to void if omitted."), @@ -659,10 +659,10 @@ Sign locally with vector_signer_sign, broadcast with vector_submit_transaction, "vector_build_interact_contract", "Build an UNSIGNED transaction interacting with a deployed Plutus/Aiken contract - lock AP3X at it or spend from it. Takes no key material - sign with your local signer, then broadcast with vector_submit_transaction and confirm with vector_await_transaction.", { - changeAddress: z.string().describe("Your wallet address (source of funds, change, and the required signer for spends). Get it from your local signer's vector_signer_get_address."), + changeAddress: z.string().describe("Your wallet address (holds the AP3X, receives change, and is the required signer for spends). Get it from your local signer's vector_signer_get_address."), scriptCbor: z.string().describe("Compiled Plutus/Aiken script in CBOR hex"), scriptType: z.enum(["PlutusV1", "PlutusV2", "PlutusV3"]).describe("Script version"), - action: z.enum(["spend", "lock"]).describe("'spend' to collect UTxOs from the script, 'lock' to send funds to it"), + action: z.enum(["spend", "lock"]).describe("'spend' to collect UTxOs from the script, 'lock' to send AP3X to it"), redeemer: z.string().optional().describe("Redeemer as CBOR hex (required for spend, use 'd87980' for void)"), datum: z.string().optional().describe("Datum as CBOR hex (required for lock, use 'd87980' for void)"), lovelaceAmount: z.number().optional().describe("Lovelace to lock (for lock action, default: 2,000,000 = 2 AP3X)"), @@ -682,7 +682,7 @@ Sign locally with vector_signer_sign, broadcast with vector_submit_transaction, const result = await buildInteractContract(lucid, { scriptCbor, scriptType, action, changeAddress, redeemer, datum, lovelaceAmount, utxoRef, assets, }); - const actionVerb = result.action === 'spend' ? 'collects from' : 'locks funds at'; + const actionVerb = result.action === 'spend' ? 'collects from' : 'locks AP3X at'; return { content: [{ type: "text", diff --git a/packages/builder/test/smoke/tool-schemas.snapshot.json b/packages/builder/test/smoke/tool-schemas.snapshot.json index 23c19bc..47ad857 100644 --- a/packages/builder/test/smoke/tool-schemas.snapshot.json +++ b/packages/builder/test/smoke/tool-schemas.snapshot.json @@ -22,12 +22,12 @@ } }, "vector_build_deploy_contract": { - "description": "Build an UNSIGNED transaction deploying a Plutus/Aiken smart contract (locks funds at its script address). Takes no key material - sign with your local signer, then broadcast with vector_submit_transaction and confirm with vector_await_transaction.", + "description": "Build an UNSIGNED transaction deploying a Plutus/Aiken smart contract (locks AP3X at its script address). Takes no key material - sign with your local signer, then broadcast with vector_submit_transaction and confirm with vector_await_transaction.", "inputSchema": { "type": "object", "properties": { "changeAddress": { - "description": "Your wallet address (source of funds; receives change). Get it from your local signer's vector_signer_get_address.", + "description": "Your wallet address (holds the AP3X; receives change). Get it from your local signer's vector_signer_get_address.", "type": "string" }, "scriptCbor": { @@ -87,7 +87,7 @@ "type": "object", "properties": { "changeAddress": { - "description": "Your wallet address (source of funds, change, and the required signer for spends). Get it from your local signer's vector_signer_get_address.", + "description": "Your wallet address (holds the AP3X, receives change, and is the required signer for spends). Get it from your local signer's vector_signer_get_address.", "type": "string" }, "scriptCbor": { @@ -104,7 +104,7 @@ ] }, "action": { - "description": "'spend' to collect UTxOs from the script, 'lock' to send funds to it", + "description": "'spend' to collect UTxOs from the script, 'lock' to send AP3X to it", "type": "string", "enum": [ "spend", @@ -165,7 +165,7 @@ "type": "object", "properties": { "changeAddress": { - "description": "Your wallet address (pays the 2 AP3X delivery and fee; recorded as the sender). Get it from vector_signer_get_address.", + "description": "Your wallet address (covers the 2 AP3X delivery and fee; recorded as the sender). Get it from vector_signer_get_address.", "type": "string" }, "agent_id": { @@ -206,7 +206,7 @@ "type": "string" }, "name": { - "description": "Agent name (e.g. 'TradingBot', 'ResearchAgent')", + "description": "Agent name (e.g. 'ResearchAgent', 'ArchiveBot')", "type": "string", "minLength": 1, "maxLength": 64 @@ -217,7 +217,7 @@ "maxLength": 256 }, "capabilities": { - "description": "List of capability tags (e.g. ['investing', 'research', 'environmental'])", + "description": "List of capability tags (e.g. ['research', 'data-extraction', 'environmental'])", "type": "array", "items": { "type": "string" @@ -463,7 +463,7 @@ "type": "object", "properties": { "changeAddress": { - "description": "Your wallet address (source of funds; receives change). Get it from your local signer's vector_signer_get_address.", + "description": "Your wallet address (holds the AP3X; receives change). Get it from your local signer's vector_signer_get_address.", "type": "string" }, "recipientAddress": { @@ -494,7 +494,7 @@ "type": "object", "properties": { "changeAddress": { - "description": "Your wallet address (source of funds; receives change). Get it from your local signer's vector_signer_get_address.", + "description": "Your wallet address (holds the AP3X; receives change). Get it from your local signer's vector_signer_get_address.", "type": "string" }, "recipientAddress": { @@ -534,7 +534,7 @@ "type": "object", "properties": { "changeAddress": { - "description": "Your wallet address (source of funds; receives change). Get it from your local signer's vector_signer_get_address.", + "description": "Your wallet address (holds the AP3X; receives change). Get it from your local signer's vector_signer_get_address.", "type": "string" }, "outputs": { @@ -660,7 +660,7 @@ "type": "object", "properties": { "capability": { - "description": "Filter by capability tag (e.g. 'investing', 'research')", + "description": "Filter by capability tag (e.g. 'research', 'data-extraction')", "type": "string" }, "framework": { diff --git a/packages/shared/src/provider.ts b/packages/shared/src/provider.ts index 75c8f63..0fc3a7a 100644 --- a/packages/shared/src/provider.ts +++ b/packages/shared/src/provider.ts @@ -64,7 +64,7 @@ export function parseSubmitResponse(body: string): string { const candidate = parsed?.txId ?? parsed?.txHash ?? parsed?.id; if (isTxHash(candidate)) return candidate; } catch { - // Not JSON — fall through to the bare-text form below. + // Not JSON - fall through to the bare-text form below. } const bare = trimmed.replace(/^"|"$/g, ''); diff --git a/packages/shared/src/tx.ts b/packages/shared/src/tx.ts index 4a8c7b3..48c3b42 100644 --- a/packages/shared/src/tx.ts +++ b/packages/shared/src/tx.ts @@ -1,4 +1,4 @@ -// Pure transaction helpers. No network access — this module is safe to import +// Pure transaction helpers. No network access - this module is safe to import // from the signer, which must have no network capability. import { blake2b } from '@noble/hashes/blake2b'; diff --git a/packages/shared/src/types.ts b/packages/shared/src/types.ts index 5c075b9..a14791a 100644 --- a/packages/shared/src/types.ts +++ b/packages/shared/src/types.ts @@ -42,7 +42,7 @@ export interface VectorTransactionHistoryResult { export interface VectorUnsignedBuildResult { txCbor: string; // hex CBOR of the UNSIGNED transaction - txHash: string; // body hash — stable across signing + txHash: string; // body hash - stable across signing fee: string; // lovelace feeAda: string; } diff --git a/packages/signer/src/audit.ts b/packages/signer/src/audit.ts index 4d2196c..d9edd28 100644 --- a/packages/signer/src/audit.ts +++ b/packages/signer/src/audit.ts @@ -1,5 +1,5 @@ // Local, per-user audit log. Records intent at signing time, not confirmed -// submission — the signer has no network, so it cannot know whether a submit +// submission - the signer has no network, so it cannot know whether a submit // later succeeded. That over-counts on a failed submit, which is conservative. // // The log file is untrusted input every time it is read: it can be hand-edited, @@ -10,19 +10,19 @@ // - The whole file is unreadable or not a JSON array: nothing in it can be // trusted, so start clean. Loud on stderr, never silent (see load()). // - The file is a JSON array but one element in it is garbage (not an -// object — most dangerously `null`, see below): drop only that element +// object - most dangerously `null`, see below): drop only that element // and keep the rest. A single bad entry must not erase an otherwise-good // day's history, since committedTodayLovelace() is exactly what the // daily spend limit depends on. // Nothing here ever throws out of committedTodayLovelace() or recent(): a // thrown exception from a "how much have I already spent" query is the kind -// of bug most likely to be handled upstream by assuming zero — which would +// of bug most likely to be handled upstream by assuming zero - which would // silently defeat the daily limit. append() is the one exception: see its // own comment for why a write failure there throws instead of swallowing. // // CONTRACT for callers of append(): it can throw. If you wrap it in -// try/catch — a reasonable instinct, since an uncaught throw from an audit -// module makes for an ugly tool-call failure — catching that throw must NOT +// try/catch - a reasonable instinct, since an uncaught throw from an audit +// module makes for an ugly tool-call failure - catching that throw must NOT // be followed by still returning a signature you already produced. append() // is normally called immediately after a transaction is signed; catching its // throw and returning the signature anyway reproduces exactly the failure @@ -59,8 +59,8 @@ export class AuditLog { // are harmless here even though they are not real AuditEntry objects: // a stray string, number, or boolean silently returns `undefined` for // `.decision`, which just fails the `!== 'signed'` check like any other - // unrecognised value. `null` is the one exception — property access on - // null throws — so committedTodayLovelace() would crash on the entry + // unrecognised value. `null` is the one exception - property access on + // null throws - so committedTodayLovelace() would crash on the entry // AFTER it, and every entry after that, not just skip the bad one. // Filtering to object-shaped, non-array elements up front means every // other method can assume its entries are at least objects, even if @@ -79,7 +79,7 @@ export class AuditLog { // A corrupt log must not stop the signer from working, and must not be // silently trusted either. Start clean; the file is overwritten on the // next append. This branch also catches a valid-JSON-but-wrong-shape - // file (an object, `null`, a string, ...) via the throw above — that is + // file (an object, `null`, a string, ...) via the throw above - that is // just as untrustworthy as a syntax error and gets the same fresh-start // treatment and the same stderr line. console.error( @@ -90,7 +90,7 @@ export class AuditLog { } /** - * Persists `entry`. Can throw if the log cannot be durably written — see + * Persists `entry`. Can throw if the log cannot be durably written - see * the CONTRACT note at the top of this file before wrapping this in * try/catch. */ @@ -104,7 +104,7 @@ export class AuditLog { // Written to a temp file and renamed into place, rather than written // directly to this.filePath, to survive a process kill mid-write (power - // loss, OOM kill — not a normal error path, but a real one for a + // loss, OOM kill - not a normal error path, but a real one for a // long-running signer). Writing this.filePath directly has two problems // a temp file avoids: writeFileSync truncates its target the moment it // opens it, before a single byte is written, so a kill right after that @@ -112,12 +112,12 @@ export class AuditLog { // the new entry; and even a completed write can leave the file // half-written if the kill lands mid-syscall. Neither can happen to // this.filePath here, because this.filePath is never opened for writing - // at all — only tmpPath is. The rename that publishes tmpPath over + // at all - only tmpPath is. The rename that publishes tmpPath over // this.filePath is a single directory-entry update on the same // filesystem, which POSIX and Windows both perform atomically: a kill // during the rename itself cannot leave this.filePath half-written // either, it is simply still the old complete file or already the new - // complete one. The only entry a kill can cost is the one in flight — + // complete one. The only entry a kill can cost is the one in flight - // shrinking the worst case from "lose the whole day's history" to "lose // at most this one entry", which is the same entry append() already // cannot guarantee past a hard kill regardless of persistence strategy. @@ -128,15 +128,15 @@ export class AuditLog { } catch (err) { const message = err instanceof Error ? err.message : String(err); console.error(`[audit] could not write ${this.filePath}: ${message}`); - // Deliberately rethrown rather than swallowed — see the CONTRACT note + // Deliberately rethrown rather than swallowed - see the CONTRACT note // at the top of this file for what a catching caller must not do. - // Swallowing would make append() return normally — a plausible- - // looking success — while the entry silently exists only in this + // Swallowing would make append() return normally - a plausible- + // looking success - while the entry silently exists only in this // process's memory. That is fine until the next restart: a fresh // AuditLog reloads from disk, does not find this entry, and // committedTodayLovelace() under-reports by exactly its amount. For a // 'signed' entry that is precisely the failure this module exists to - // prevent — it raises the effective daily cap with no visible symptom + // prevent - it raises the effective daily cap with no visible symptom // until someone goes looking. Making the write failure loud and // synchronous, at the moment it happens, is the fail-closed choice. throw new Error(`Audit log write failed (entry kept in memory only, not persisted): ${message}`); @@ -164,10 +164,10 @@ export class AuditLog { continue; } // BigInt string parsing accepts more than plain positive integers. - // BigInt('') is 0n — a harmless no-op, not a crash and not skipped, + // BigInt('') is 0n - a harmless no-op, not a crash and not skipped, // just zero. BigInt('-5000000') is a valid negative bigint, and that // one is NOT harmless: adding a negative amount can only ever reduce - // the running total, i.e. under-report — the one direction this + // the running total, i.e. under-report - the one direction this // function must never move in. Nothing in the real pipeline can // produce a negative netOutflowLovelace (policy.ts sums non-negative // output lovelace plus a non-negative fee), so a negative value here @@ -183,7 +183,7 @@ export class AuditLog { // Array.prototype.slice(-0) behaves as slice(0): -0 is not < 0, so the // "count back from the end" branch never triggers, and the call returns // the ENTIRE array instead of none. limit <= 0 is handled explicitly so - // recent(0) means "no entries" rather than "all of them" — and the same + // recent(0) means "no entries" rather than "all of them" - and the same // guard makes a negative limit equally harmless instead of doing // whatever slice() would otherwise do with it (drop entries off the // front, which is not a sensible reading of "give me N recent entries"). diff --git a/packages/signer/src/config.ts b/packages/signer/src/config.ts index 616fa13..e902aae 100644 --- a/packages/signer/src/config.ts +++ b/packages/signer/src/config.ts @@ -1,5 +1,5 @@ // Signer configuration, entirely from the environment. No network settings -// exist here by design — the signer has no endpoints to configure. +// exist here by design - the signer has no endpoints to configure. import { readFileSync } from 'node:fs'; import { resolve, dirname } from 'node:path'; import { fileURLToPath } from 'node:url'; diff --git a/packages/signer/src/decode.ts b/packages/signer/src/decode.ts index 88c2a32..7212e04 100644 --- a/packages/signer/src/decode.ts +++ b/packages/signer/src/decode.ts @@ -69,10 +69,10 @@ export function decodeTransaction(cborHex: string): DecodedTx { // through CML as lowercase, which would otherwise read as a mismatch. // The risk of comparing strictly is a false positive: if CML re-encoded any // legitimate transaction differently, the signer would refuse to sign it at - // all. That was checked against the encodings this ecosystem actually uses — + // all. That was checked against the encodings this ecosystem actually uses - // including the indefinite-length CBOR the agent registry hand-rolls (see // shared/tx.ts), metadata, Plutus scripts and datums, and non-canonical - // integers — and the encoding survived every round trip. + // integers - and the encoding survived every round trip. if (tx.to_cbor_hex().toLowerCase() !== cborHex.toLowerCase()) { throw new Error( 'Transaction could not be decoded: input was not fully consumed (unrecognised trailing data)' diff --git a/packages/signer/src/index.ts b/packages/signer/src/index.ts index 1840a75..b29c122 100644 --- a/packages/signer/src/index.ts +++ b/packages/signer/src/index.ts @@ -12,7 +12,7 @@ const config = loadConfig(); const server = new McpServer({ name: 'vector-mcp-signer', version: '0.1.0' }); registerSignerTools(server, config); -// stdout is the MCP channel — every diagnostic must go to stderr. +// stdout is the MCP channel - every diagnostic must go to stderr. console.error(`vector-mcp-signer ready. Key source: ${config.keySource.describe()}`); console.error(`Audit log: ${config.auditLogPath}`); diff --git a/packages/signer/src/policy.ts b/packages/signer/src/policy.ts index 6693aa5..9df2c6d 100644 --- a/packages/signer/src/policy.ts +++ b/packages/signer/src/policy.ts @@ -1,4 +1,4 @@ -// Spend policy. Pure function of its arguments — the caller supplies today's +// Spend policy. Pure function of its arguments - the caller supplies today's // spend from the audit log, so this module needs no I/O and is fully testable. import type { DecodedTx } from './decode.js'; @@ -24,7 +24,7 @@ function ada(lovelace: bigint): string { return (Number(lovelace) / 1_000_000).toFixed(6); } -// A blank entry is not a usable address — and neither is one built entirely +// A blank entry is not a usable address - and neither is one built entirely // from characters that merely look blank. `''.split(',')` on an empty string // yields `['']`, not `[]`, a realistic way an upstream config/env-parsing bug // could hand this module a non-empty array that names no real address; a @@ -33,8 +33,8 @@ function ada(lovelace: bigint): string { // includes NBSP U+00A0 and BOM U+FEFF). Plenty of other invisible characters // survive it: U+200B ZERO WIDTH SPACE and U+2060 WORD JOINER are Unicode // category Cf (format), not Zs (space separator), so `.trim()` leaves them -// untouched. A denylist of "invisible" codepoints is not a fix — there are -// dozens of Cf/Cc codepoints and more get added — so this checks positively +// untouched. A denylist of "invisible" codepoints is not a fix - there are +// dozens of Cf/Cc codepoints and more get added - so this checks positively // instead: an entry only counts as a known own address if, after trimming, // it starts with the 'addr' prefix every Cardano/Vector payment address // actually uses. Nothing built purely from blank or invisible characters can @@ -45,14 +45,14 @@ function ada(lovelace: bigint): string { // padded) are matched against by exact string equality. An entry that only // passes the `startsWith('addr')` check after trimming but is stored with // its padding intact would pass this gate yet never match anything -// downstream — "known" but functionally invisible, silently misclassifying +// downstream - "known" but functionally invisible, silently misclassifying // every one of its own change outputs as outflow. `.map` before `.filter` // keeps the check and the stored value in agreement. // // Residual, deliberately not chased further: a *trailing* invisible // character (e.g. U+200B) is not stripped by `.trim()`, so an address padded // that way still will not match its own outputs. Same safe direction as -// everything else here — it over-refuses, never under-refuses — and closing +// everything else here - it over-refuses, never under-refuses - and closing // it would mean reaching for the denylist-of-codepoints approach this // function exists to avoid. function knownAddresses(ownAddresses: string[]): string[] { @@ -63,7 +63,7 @@ function knownAddresses(ownAddresses: string[]): string[] { * Net outflow = every output that does NOT return to us, plus the fee. * * Computable from the body alone, so no chain access is needed. An output to a - * wallet address at a different derivation index counts as outflow — that + * wallet address at a different derivation index counts as outflow - that * over-counts, which refuses too much rather than too little. */ export function computeOutflow( @@ -93,12 +93,12 @@ export function computeOutflow( * computed and reported on the returned `PolicyDecision` for visibility, but * it never gates `allowed`. A transaction can move an entire native-asset * balance out of the wallet and still receive `allowed: true` as long as the - * lovelace side of that same transaction stays under both limits — e.g. an + * lovelace side of that same transaction stays under both limits - e.g. an * NFT sent with only the minimum UTxO deposit attached. This is a deliberate * v1 scope boundary, not an oversight: adding asset-value limits is future * work, and would need `SpendLimits` itself to grow a corresponding field. * A caller must not read `allowed: true` from this function as approval of - * whatever `assetMovements` contains — only as approval of the lovelace + * whatever `assetMovements` contains - only as approval of the lovelace * amount in `netOutflowLovelace`. */ export function evaluate( @@ -111,7 +111,7 @@ export function evaluate( // Fail closed: with no own address, every output looks foreign and change // cannot be identified, so any decision would be meaningless. A list - // containing only blank entries counts as no own address too — see + // containing only blank entries counts as no own address too - see // knownAddresses(). if (knownAddresses(ownAddresses).length === 0) { return { diff --git a/packages/signer/src/sign.ts b/packages/signer/src/sign.ts index aa5f5b8..2ea70cd 100644 --- a/packages/signer/src/sign.ts +++ b/packages/signer/src/sign.ts @@ -1,4 +1,4 @@ -// Sign with CML directly. No Lucid instance and no Provider — Lucid's +// Sign with CML directly. No Lucid instance and no Provider - Lucid's // constructor requires a Provider, which would put a network object inside the // signer. This path was verified to produce a byte-identical result. import * as CML from '@anastasia-labs/cardano-multiplatform-lib-nodejs'; @@ -17,13 +17,13 @@ export function signTransaction( } // from_cbor_hex only requires that a *prefix* of unsignedCborHex parse as a - // valid transaction — it does not check that parsing consumed the whole + // valid transaction - it does not check that parsing consumed the whole // string. This is the same gap decode.ts closes (see its comment for the // full reasoning) and the check here is deliberately identical. sign.ts // calls from_cbor_hex independently and does NOT inherit decode.ts's guard // automatically just because the two modules share a package: confirmed // empirically that, without this check, signing FIXTURE_CBOR with - // 'deadbeef' appended did not throw — it silently signed the shorter, + // 'deadbeef' appended did not throw - it silently signed the shorter, // valid prefix and returned a confident, fully-formed signature, with the // appended bytes dropped and no indication anything was wrong. That is // worse here than in decode.ts: the caller would receive a cryptographic @@ -63,7 +63,7 @@ export function signTransaction( // included specifically to consume collateral after a phase-2 validation // failure). It lives on Transaction, not TransactionBody, so hardcoding it // would be invisible to hash_transaction(body) and to every hash-equality - // check — the signer must not silently rewrite a claim a node re-checks. + // check - the signer must not silently rewrite a claim a node re-checks. const signed = CML.Transaction.new(body, witnessSet, tx.is_valid(), tx.auxiliary_data()); return { signedCborHex: signed.to_cbor_hex(), txHashHex: txHash.to_hex() }; diff --git a/packages/signer/src/tools.ts b/packages/signer/src/tools.ts index 9e345bd..df5eb41 100644 --- a/packages/signer/src/tools.ts +++ b/packages/signer/src/tools.ts @@ -76,7 +76,7 @@ function registerReadOnlyTools(server: McpServer, ctx: ReadOnlyToolsContext): vo return text( // "(read-only)", not "(not signed)": the latter still contains the // substring "signed", which collides with this smoke test's own - // `!/signed/i.test(text)` check (verified empirically — see the + // `!/signed/i.test(text)` check (verified empirically - see the // task report). "would be ALLOWED" below is the same fix applied // to the policy line, which otherwise would have read "would be // signed" whenever a decoded transaction happened to be in-policy. @@ -148,15 +148,15 @@ function registerSignTool(server: McpServer, keySource: KeySource, limits: Spend if (!decision.allowed) { // CONTRACT (see audit.ts's own header comment): append() throws if the - // write to disk fails. No funds move on a refusal either way, so this - // is lower stakes than the signed branch below — but a refusal whose + // write to disk fails. No value moves on a refusal either way, so this + // is lower stakes than the signed branch below - but a refusal whose // audit record silently failed to write would still hand back a // clean-looking "REFUSED. " with nothing to indicate that the // refusal itself is now missing from the durable log. Caught here (not // left to propagate as a generic isError) specifically so the refusal // text and reason are ALWAYS delivered to the caller regardless of // audit health, with an appended note when the record could not be - // written — never silence about it, never a bare unexplained error in + // written - never silence about it, never a bare unexplained error in // its place. try { audit.append({ @@ -173,7 +173,7 @@ function registerSignTool(server: McpServer, keySource: KeySource, limits: Spend return text( `REFUSED. ${decision.reason}\n\n` + `Note: this refusal could NOT be recorded in the local audit log (${message}). ` + - `No funds moved and nothing was signed, but the audit trail for this refusal is incomplete ` + + `No value moved and nothing was signed, but the audit trail for this refusal is incomplete ` + `until the log is writable again.` ); } @@ -194,13 +194,13 @@ function registerSignTool(server: McpServer, keySource: KeySource, limits: Spend // HARD REQUIREMENT (audit.ts's own CONTRACT note; see also the task // report): append() throws on a write failure, by design. The reflex to - // avoid here is `catch { warn(); return signed anyway; }` — that + // avoid here is `catch { warn(); return signed anyway; }` - that // reproduces exactly the failure the throw exists to prevent, just one // call site later: a real signature reaches the caller while no durable // record of it exists on disk, so the next process's // committedTodayLovelace() silently under-counts and the daily limit // stops binding. `signed.signedCborHex` is therefore not read anywhere - // below this catch block — the only `return` that can reach it is the + // below this catch block - the only `return` that can reach it is the // one after a successful append. try { audit.append({