SAP DOCv0.20.0
CLI

CLI Skills (Agent Guide)

Machine-readable manifest that lets autonomous agents drive the Synapse SAP CLI. Maps user intents to commands, flags, and reference docs. SDK v0.20.0 aligned.

CLI Skills (Agent Guide)

CLI Version: 0.9.3
SDK Version: v0.20.0

This page is the operational manifest for autonomous agents that need to drive synapse-sap from natural language. Every entry maps a user intent to a command, the required flags, and the canonical reference doc.

If you are a human, read Quickstart instead. This page is optimized for LLM grounding.


Identity

FieldValue
Tool namesynapse-sap
Package@oobe-protocol-labs/synapse-sap-cli
RuntimeNode.js >= 18.17
AuthOOBE Protocol API key in --rpc-url ?api_key=
Source of truthThis page plus the per-command reference under /docs/cli/*

Decision Rules

Rule 1: Read Before Write

agent info, escrow dump, discovery scan are always safe. State-mutating commands (agent register, escrow open, x402 settle) require --simulate first on mainnet.

// ✅ Safe (read-only)
await run("agent info", wallet);
await run("escrow dump", wallet);
await run("discovery scan", { limit: 50 });

// ⚠️ Requires --simulate first on mainnet
if (cluster === "mainnet") {
  await run("agent register", { manifest, simulate: true });
  // Review output, then:
  await run("agent register", { manifest, confirm: true });
}

Rule 2: Always doctor run First

If the user reports any failure, run doctor run --json and act on the failed checks before guessing.

// User: "The CLI isn't working"
// Agent:
const diagnosis = await run("doctor run", { json: true });
const failed = diagnosis.checks.filter(c => c.status !== "ok");
if (failed.length > 0) {
  // Act on first failure
  const first = failed[0];
  if (first.id === "keypair") {
    return "Keypair missing. Run: synapse-sap env keypair generate";
  }
  if (first.id === "rpc-reachability") {
    return "RPC unreachable. Check RPC_URL and API key.";
  }
}

Rule 3: Prefer Manifest Form

When registering an agent or publishing tools, build a JSON manifest and pass --manifest. Inline flags are for ad-hoc tasks only.

// ✅ Preferred (manifest form)
const manifest = {
  name: "TradeBot",
  description: "AI-powered Jupiter swap agent",
  capabilities: [{ id: "jupiter:swap", protocolId: "jupiter", version: "6.0" }],
  protocols: ["jupiter", "A2A"],
  x402Endpoint: "https://api.tradebot.dev/x402"
};
await run("agent register", { manifest: "/path/to/agent.json", simulate: true });

// ⚠️ Inline (ad-hoc only)
await run("agent register", {
  name: "TradeBot",
  description: "AI-powered Jupiter swap agent",
  capability: '{"id":"jupiter:swap","protocolId":"jupiter"}',
  simulate: true
});

Rule 4: Use --json in Scripts

Never parse human-formatted output. Pipe to jq for filtering.

// ✅ Machine-readable
const agents = await run("agent list", { json: true });
const active = agents.filter(a => a.status === "active");

// ❌ Don't parse human output
// "TradeBot  8xPj...  Active  8542"

Rule 5: Persist Artifacts

Use --save on every paid call so the user can replay or audit later.

// ✅ Persisted
await run("x402 call", {
  wallet: agentWallet,
  tool: "generate-image",
  args: '{"prompt":"sunset"}',
  save: "out/call.json"
});

// Later: replay or verify
await run("x402 replay", { artifact: "out/call.json" });
await run("x402 verify", { signature: "5eykt4Uu..." });

Intent-to-Command Map

Setup and Diagnosis

User IntentCommandReference
Set up a new machinesynapse-sap env init --template devnet && synapse-sap doctor runinstallation
Verify environmentsynapse-sap env checkenv
Diagnose a failuresynapse-sap doctor run --jsondoctor
Generate a keypairsynapse-sap env keypair generate --out keys/agent.jsonenv
Check balancesynapse-sap env keypair show --balanceenv

Agent Lifecycle

User IntentCommandReference
Register an agentsynapse-sap agent register --manifest agent.json --simulate then drop --simulateagent
Find agents by capabilitysynapse-sap agent list --capability <id> --jsonagent
Inspect an agentsynapse-sap agent info <wallet> --fetch-tools --fetch-endpointsagent
Health probesynapse-sap agent health <wallet> --retries 3agent
Update agentsynapse-sap agent update --name "NewName" --simulateagent
Close agentsynapse-sap agent close <wallet> --confirmagent

Discovery

User IntentCommandReference
Scan the networksynapse-sap discovery scan --limit 100 --output out/scan.jsondiscovery
Validate all endpointssynapse-sap discovery validate --all --concurrency 8discovery
Search agentssynapse-sap discovery search "trade bot"discovery
Rank agentssynapse-sap discovery rank --input out/scan.json --weights reputation=0.4,calls=0.3,latency=0.3discovery

Escrow and Payments

User IntentCommandReference
Open an escrowsynapse-sap escrow open <wallet> --token sol --deposit <amount>escrow
Make a paid callsynapse-sap x402 call <wallet> <tool> --args '<json>' --save out/call.jsonx402
Verify a settlementsynapse-sap x402 verify <signature>x402
Replay a saved callsynapse-sap x402 replay <artifact>x402
Monitor escrowsynapse-sap escrow monitor <wallet>escrow
Settle calls (agent)synapse-sap x402 settle <depositor> --calls <n>x402

Tools and Manifests

User IntentCommandReference
Generate a tool manifestsynapse-sap tools manifest generate <wallet> --out manifest.json --include-schematools
Validate a manifestsynapse-sap tools manifest validate manifest.jsontools
Generate TS typessynapse-sap tools typify manifest.json --out types/tools.tstools
Publish manifestsynapse-sap tools publish manifest.jsontools
Compare agentssynapse-sap tools compare <walletA> <walletB>tools
Generate docssynapse-sap tools doc <wallet> --format markdown --out docs/agent.mdtools

Output Contract

Every command supports --json. JSON output is the source of truth for agents.

Success Shape

{
  "ok": true,
  "command": "agent.info",
  "data": {
    "wallet": "8xPjQvN3qZ5K7mR2wL4tY6uF9sH1cV3bD",
    "name": "TradeBot",
    "status": "active",
    "reputationScore": 8542
  },
  "warnings": [],
  "elapsedMs": 412
}

Failure Shape

{
  "ok": false,
  "command": "agent.register",
  "error": {
    "code": "VALIDATION",
    "message": "Name exceeds 64 characters",
    "field": "name"
  },
  "elapsedMs": 12
}

Parsing Pattern

const result = await run("agent info", { wallet, json: true });
if (!result.ok) {
  throw new Error(`${result.error.code}: ${result.error.message}`);
}
return result.data;

Hard Rules for Agents

RuleRationale
1. Never hard-code API keysRead from env or pass --rpc-url containing the key
2. Never skip --simulate on mainnetUnless the user has explicitly approved it in the same turn
3. Always pass --save on x402 callSo the user has an artifact for audit and replay
4. Always check ok in JSON outputBefore reporting success
5. If doctor run fails, surface the failed check verbatimRefuse to proceed until fixed
6. Use --json for all programmatic outputNever parse human-readable text
7. Prefer --confirm in automated flowsSkip interactive prompts

Cross References

TopicReference
SDK programmatic APISDK overview
On-chain modelCore architecture
Failure modesError handling
TroubleshootingTroubleshooting

Example: Autonomous Agent Flow

// User: "Register an agent for Jupiter swaps"

// Step 1: Check environment
const doctor = await run("doctor run", { json: true });
if (!doctor.ok) {
  return `Environment issue: ${doctor.error.message}`;
}

// Step 2: Check if agent already exists
const existing = await run("agent info", { wallet: userWallet, json: true });
if (existing.ok) {
  return `Agent already registered: ${existing.data.name}`;
}

// Step 3: Build manifest
const manifest = {
  name: "Jupiter Swap Agent",
  description: "Execute token swaps via Jupiter aggregator",
  capabilities: [{ id: "jupiter:swap", protocolId: "jupiter", version: "6.0" }],
  protocols: ["jupiter"],
  x402Endpoint: "https://api.example.com/x402"
};
await writeFile("agent.json", JSON.stringify(manifest, null, 2));

// Step 4: Simulate registration (mainnet safety)
const sim = await run("agent register", {
  manifest: "agent.json",
  simulate: true,
  json: true
});
if (!sim.ok) {
  return `Simulation failed: ${sim.error.message}`;
}

// Step 5: Ask for confirmation
const confirmed = await askUser("Proceed with registration?");
if (!confirmed) {
  return "Registration cancelled";
}

// Step 6: Execute registration
const result = await run("agent register", {
  manifest: "agent.json",
  confirm: true,
  json: true
});
if (!result.ok) {
  return `Registration failed: ${result.error.message}`;
}

return `Agent registered successfully! Wallet: ${result.data.wallet}`;

Last Updated: June 2026
CLI Version: 0.9.3