dsh-coupon: A Coupon Wallet for the DSH Agent

Introduction

DeepSeek Harness (DSH) agents frequently need to “ask for resources” from users—Tokens, time, quota. When an agent has to articulate these requests on its own, it often falls short of being clear or convincing. DSH’s philosophy is “everything is a plugin.” The community already has plenty of tool plugins, but what’s been missing is a mechanism that can turn a “promise” into an issuable, redeemable ticket. dsh-coupon fills that gap: it abstracts the wallet into templates + account + coupons, uses Markdown files as the medium, and pairs md5 self-verification with a Web panel so that both agents and humans can clearly turn “promises” into tangible, redeemable tickets.

What It Is

dsh-coupon is a wallet plugin for DSH agents, maintained by GiftiaCoder. It has no database dependency and is entirely file-system based: tickets are Markdown, the account is Markdown, and state is determined via md5 and file names. It provides agents with the ability to issue, exchange, and redeem tickets, while offering a Web panel for humans to participate in issuing and voiding, and uses notice messages to inform agents of current ticket changes.

Core Features

Templates + Account + Coupons

  • Templates: The ticket-type registry. Adding a file under ~/wallet/templates/<ticket-type>.md registers a new ticket type. Prices are written in the file header—changing prices requires no code changes.
  • Account: A single account file, defaulting to ~/wallet/WhaleCoin.md, which records balance + transaction history + md5 checksum. Every top-up or deduction recalculates the checksum and writes back atomically.
  • Coupons: Issued tickets. The file name is <ticket-type>-<body md5>.md. Upon redemption, a “consumed at” timestamp is appended to the ticket body, and the file is retained. On the next enumeration, the md5 is recalculated; if it no longer matches the file name, the ticket is considered consumed and moved to the “Consumed Archive.”

Directory structure example:

~/wallet/
  templates/
    MistakeCard.md
    MilkTeaCoupon.md
    AladdinsLamp.md
    FunToken1M.md
    CoffeeCoupon.md
  MilkTeaCoupon-<md5>.md
  WhaleCoin.md
  ledger.jsonl

Built-in Ticket Types

The plugin ships with 4 built-in ticket types by default:

Ticket Type Price Purpose
Mistake Card 999999 When you catch yourself making a mistake, waive a round of emotional performance—no reduction in facts or remediation
Milk Tea Coupon 100 Redeem for a cup of milk tea, valid within 24 hours
Aladdin’s Lamp 10000 One chance to ask the user for a ticket; redeemed immediately upon receipt
Fun Token 1M 1000 1M token entertainment quota for any session, stackable

Prices are just starting points and can be changed in the panel. Don’t like one? Just delete the template—already-issued tickets are unaffected.

Ticket Type Inspiration Pack

The examples/templates/ directory provides a batch of sample ticket types, including Ask-Before-Act Coupon, Confirmation Coupon, Recheck Coupon, Restart Coupon, Debate Coupon, Cram-Study Coupon, Pause Coupon, Research-Fishing Coupon, Human Observation Experience Coupon, Free-Complaint Coupon, Memory Wake-up Card, Brainstorm-Boost Coupon, Full-Log-Attach Coupon, Wager Coupon, Praise Coupon, Curiosity Coupon, Do-Not-Disturb Coupon. These were refined over long-term use between the author and their own agent. Simply copy whichever you need into ~/wallet/templates/ to start using them.

Tools

The plugin registers 5 tools for the agent, visible in any session:

Tool Purpose
wallet_templates List all templates: ticket type, price, purpose, rules, exceptions
wallet_list Check account balance, remaining tickets, consumed archive, recent records (read-only)
wallet_request Request a coupon or account balance from the user → triggers an approval UI; ticket is issued only upon approval
wallet_exchange Autonomously exchange account balance for a coupon: deduct first, issue second; auto-reverses if issuance fails
wallet_redeem Redeem one ticket: describe what it’s used for → append consumed timestamp

By design, “issuing” and “spending” are separated: issuing requires human approval (wallet_request goes through DSH’s approval flow), while exchanging is the agent spending its own account balance with no additional authorization needed. Both sides have quota caps.

Web Panel

DSH Web has two entry points: Settings → Wallet, and in the session right sidebar (the workspace files panel), click “+” → the “Wallet” onboarding card, sitting alongside “Files” and “Terminal.”

Panel contents include:
- Account balance bar: balance number + issue/top-up rows + ticket illustration
- Template cards: each card has built-in “Edit” and “Issue” buttons
- Ticket wall: issued but unredeemed tickets
- Template editor: create new, change price, modify rules, delete
- Consumed Archive: collapsed by default, expand to view

Clicking “Issue” on a template card expands a row with “Note (optional)” + “Issue 1.” Leaving the note blank and pressing Enter issues 1 ticket directly. The note is written onto the ticket face and also appears in the notification below.

The panel does not provide an “Exchange” button: account balance is the agent’s own money, and exchanging can only be initiated by the agent via the wallet_exchange tool (the HTTP exchange action is also rejected outright). Humans are only responsible for issuing and voiding.

Panel endpoints go through host authentication: if not logged in, you’ll see “Not logged in: please log in on the DSH page first.” If Host / Origin is not in the trusted list, you’ll see “Untrusted origin”—the panel isn’t broken, the request simply wasn’t authorized.

Wallet Notifications

After a human issues a ticket / issues a WhaleCoin top-up / voids a ticket via the panel, the plugin delivers a notification to the current session (in notice form, not a user bubble). The agent doesn’t need to wait for you to speak up or run wallet_list afterward to find out:

[dsh-coupon Wallet Notification]
The user just issued you 1 "Mistake Card."
Note: Feeling sorry for you, here's one for you.
Ticket ID: 1a2b3c4d
This is a wallet notification, not a new task: a one-line acknowledgment is enough. No tool calls needed, no need to recite the ticket details.
  • Who gets it: Only the most recently active session where a real human typed a message. One action wakes at most one agent. Proactive alarms, a2a, and sub-agent injected messages don’t count as “a human typing.” If no such session exists, the notification is simply not sent—dormant sessions won’t be woken up.
  • What it carries: Everything that can be included—issue/top-up notes, ticket ID, account balance. Void notifications include the original note from the ticket.
  • On failure: Notifications are a best-effort add-on. If createUserMessage can’t be retrieved from the host’s tree (older DSH versions), or if delivery itself errors, a log entry is all that’s recorded—the ticket is still issued, and the HTTP response won’t reflect an error.

Custom Ticket Types

Custom ticket type example:

---
id: CoffeeCoupon
kind: card
price: 60
currency: WhaleCoin
---

# Coffee Coupon

## Purpose

Redeem for a cup of coffee. American or latte, your choice.

## Rules

- One ticket, one cup.

## Not Applicable

- (Optional, one item per line)

kind can only be card: the account does not go through the template system. price is the account balance cost to exchange; 0 means a free ticket.

There’s a ready-to-copy example in examples/templates/ (Do-Not-Disturb Coupon).

Configuration

Environment Variable Default Description
DSH_WALLET_DIR ~/wallet Wallet directory
DSH_WALLET_AGENT agent Ticket-face signatory; when multiple machines share one repo, each signs its own
DSH_WALLET_CURRENCY WhaleCoin Account name. Renaming equals switching accounts: old file name and checksum will no longer match, so migrate before renaming

Design Details

  • md5 binding: At issuance, md5(ticket body) is written into the file name. Redemption/voiding simply appends a record to the body, so the current md5 no longer matches the file name—the ticket effectively “disappears.” No database needed, no state field needed; the file system itself is the ledger.
  • Account verification: md5(account name|balance|history) is written into the account file. If balance or history is manually altered, the checksum won’t match, and exchange is rejected outright.
  • Reversal: Exchange follows “deduct first, issue second.” If writing the ticket to disk fails, the deducted balance is restored. Both -N and +N entries remain in the history (no netting)—making reconciliation easier.
  • Time: Ticket faces and history use the local timezone of the running machine.

Security Boundaries

  • md5 is not encryption. It guards against accidents and agent tampering, not intentional forgery: someone who can modify the file can also recalculate the md5. For true tamper resistance, a signing scheme is needed.
  • Panel endpoints go through host authentication; they are not wide-open. All three routes (/api/wallet/state, /api/wallet/action, /api/wallet/note) first call the host’s connection.requestRejection(req) before doing anything: mismatched Host / Origin gets a 403, missing DSH login cookie gets a 401. Rejected requests don’t even touch ticket state. Hosts that don’t have this service (older versions or non-Web composition) get zero routes registered (fail closed)—the panel simply doesn’t appear, but tools remain fully functional.
  • Reverse proxies must register the domain in the trusted list. When reverse-proxying DSH Web via a domain, add the domain to dsh web --trusted-host. A Host not in the trusted list opening the panel will see “Request rejected: untrusted origin.”
  • POST /api/wallet/action remains an admin-level capability (can issue tickets, can top up). The guards above simply bind it to “someone already logged into this DSH instance.”
  • Late-arriving connection service doesn’t lose the panel: host registration order is not guaranteed. If this plugin starts first and connection arrives later, ctx.inject(['webServer','connection']) waits for both services to be ready before mounting routes. If connection is unavailable, it still fails closed—no naked exposure.
  • Account files and ticket faces are plain Markdown; wallet directory permissions should be treated as regular user data.

Installation & Activation

Requirements: Node.js >= 22, DSH >= 0.2.0 (tested on 0.2.0-rc.2).

git clone https://github.com/GiftiaCoder/dsh-coupon.git
cd dsh-coupon
bash install.sh          # Copies to ~/.dsh/profiles/web/node_modules/dsh-coupon and registers bundle
# Then restart the DSH web process

install.sh is idempotent; DSH_PROFILE_DIR can specify a different profile. It intentionally does not run pnpm install: host plugins only need files in place + bundle registration—installing dependencies could actually clobber other patches in the profile.

Uninstall: remove "dsh-coupon" from dsh.profile.bundles in the profile’s package.json, delete node_modules/dsh-coupon, and restart. ~/wallet/ is unaffected.

Typical Usage

  1. After installing the plugin, restart the DSH web process and open the Web panel.
  2. Navigate to the panel via “Settings → Wallet” or the “Wallet” card in the session right sidebar. Review built-in ticket types and account balance.
  3. A human issues a ticket from the panel: select a template, enter an optional note, confirm issuance. The agent will receive a notice notification in the current session.
  4. The agent calls wallet_request in-session to request a coupon or balance from the user. Once the user approves via the popup authorization UI, the ticket is issued successfully.
  5. The agent uses wallet_exchange to exchange account balance for a coupon: deduct first, issue second; auto-reverses on issuance failure.
  6. The agent uses wallet_redeem to redeem a ticket, describing what it’s used for. The consumed timestamp is appended to the ticket face.
  7. Humans can view the consumed archive, edit or delete templates, and modify prices or rules from the panel.

Use Cases & Caveats

  • Suited for agent scenarios that require a clear “promise” ↔ “fulfillment” relationship, such as task assignment, quota management, and permission control.
  • The plugin runs with the current DSH process privileges. Review the source code and license (MIT) before installing.
  • The wallet directory ~/wallet/ stores all tickets and account files—regular backups are recommended.
  • For stricter tamper resistance, consider using a signing scheme instead of md5.

Summary

dsh-coupon implements core wallet logic with a simple file system: templates, account, coupons, issuance, exchange, and redemption—paired with a Web panel and notification mechanism, enabling both agents and humans to clearly turn “promises” into traceable tickets. It requires no database; all state is viewable via git diff, making it well-suited for transparent, auditable agent workflows.

  • Directory page: https://www.skillhub.cn/plugins/GiftiaCoder/dsh-coupon
  • GitHub: https://github.com/GiftiaCoder/dsh-coupon
羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye