Dashboard home page
Browse filesFiles changed (7)
14 unmodified lines15161718192014 unmodified linesCOPY --from=build --chown=node /app/services/wallet/node_modules ./node_modulesCOPY --from=build --chown=node /app/services/wallet/dist ./distCOPY --chown=node services/wallet/package.json ./ENV NODE_ENV=production PORT=7860EXPOSE 7860CMD ["node", "dist/index.js"]14 unmodified lines1516171819202114 unmodified linesCOPY --from=build --chown=node /app/services/wallet/node_modules ./node_modulesCOPY --from=build --chown=node /app/services/wallet/dist ./distCOPY --chown=node services/wallet/package.json ./COPY --chown=node services/wallet/public ./publicENV NODE_ENV=production PORT=7860EXPOSE 7860CMD ["node", "dist/index.js"]
12345678910111213141516171819202122232425:root{--ink:#25252a;--muted:#83838d;--line:#ecebf0;--paper:#fbfaf8;--purple:#7164c8;--green:#379b70;--red:#c2524a}*{box-sizing:border-box}body{margin:0;background:var(--paper);color:var(--ink);font:14px 'DM Sans',system-ui,sans-serif;-webkit-font-smoothing:antialiased}.top{display:flex;justify-content:space-between;align-items:center;height:62px;padding:0 32px;background:#fff;border-bottom:1px solid var(--line)}.brand{display:flex;gap:10px;align-items:center;font:800 19px Manrope,system-ui,sans-serif;letter-spacing:-.6px}.light{color:#8983af}.mark{width:34px;height:34px;border-radius:10px;background:#7768cf;color:#fff;display:grid;place-items:center;box-shadow:0 4px 9px #7768cf38}.badge{background:#fff5e8;color:#c88942;border:1px solid #f3e1c6;padding:5px 10px;border-radius:6px;font-size:11px;font-weight:700;letter-spacing:.8px}.wrap{max-width:1100px;margin:0 auto;padding:30px 32px 70px}.eyebrow{color:#9b98a3;font-size:10px;font-weight:700;letter-spacing:1.3px;margin:0 0 10px}.rule{display:inline-block;width:19px;height:1px;background:#d8d6dd;vertical-align:middle;margin:0 8px}h1{font:700 30px Manrope,system-ui,sans-serif;letter-spacing:-1.1px;margin:0 0 24px}h1 span{color:#766bc0}h2{font:700 17px Manrope,system-ui,sans-serif;margin:30px 0 12px}.grid2{display:grid;grid-template-columns:1fr 1.3fr;gap:14px;margin-bottom:14px}.card{background:#fff;border:1px solid var(--line);border-radius:10px;padding:18px}.label{color:#9997a1;font-size:10px;letter-spacing:.7px;font-weight:700;margin-bottom:10px}.big{font:700 38px Manrope,system-ui,sans-serif;letter-spacing:-1px;margin:4px 0 16px}.row{display:flex;gap:8px}input,textarea{font:inherit;border:1px solid var(--line);border-radius:7px;padding:9px;width:100%;background:#fdfdfe}input{width:110px}textarea{resize:vertical;font-family:ui-monospace,monospace;font-size:12px;margin-bottom:10px}.primary{border:0;background:var(--purple);color:#fff;padding:10px 16px;border-radius:7px;font-weight:600;cursor:pointer;box-shadow:0 3px 8px #7164c82c}.primary:hover{background:#6255b7}.primary:disabled{opacity:.6}.msg{margin-top:10px;font-size:13px;min-height:18px}.ok{color:var(--green)}.err{color:var(--red)}.warn{color:#b5813b;background:#fff8ed;border:1px solid #f3e8d6;padding:8px 10px;border-radius:7px}.txs{list-style:none;margin:0;padding:0}.txs li{display:flex;justify-content:space-between;gap:10px;padding:11px 0;border-top:1px solid #f1f0f3}.txs li:first-child{border-top:0}.txs small{display:block;color:var(--muted);font-size:11px;margin-top:3px}.amt.pos{color:var(--green)}.amt.neg{color:var(--ink)}.muted{color:var(--muted)}.apps{display:grid;grid-template-columns:repeat(auto-fill,minmax(200px,1fr));gap:12px}.app{display:block;text-decoration:none;color:inherit;background:#fff;border:1px solid var(--line);border-radius:10px;padding:16px;transition:.15s}a.app:hover{border-color:#d9d4f5;box-shadow:0 4px 14px #7164c81a;transform:translateY(-1px)}.app .ic{width:32px;height:32px;border-radius:9px;background:#f0edff;color:#766bc8;display:grid;place-items:center;font:700 14px Manrope,sans-serif;margin-bottom:10px}.app strong{display:block}.app small{color:var(--muted);font-size:12px}.app .sec{display:inline-block;margin-top:10px;font-size:12px;color:var(--purple);font-weight:600;text-decoration:none}.app.disabled{opacity:.55;cursor:not-allowed;background:#f7f6f9}.foot{text-align:center;color:var(--muted);font-size:12px;padding:16px;border-top:1px solid var(--line);background:#fff}@media(max-width:760px){.grid2{grid-template-columns:1fr}.wrap{padding:22px 16px 60px}.top{padding:0 16px}h1{font-size:24px}}12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849const $ = (id) => document.getElementById(id);const fmt = (minor, cur = "usd") => new Intl.NumberFormat(undefined, { style: "currency", currency: cur.toUpperCase() }).format(minor / 100);const esc = (s) => String(s ?? "").replace(/[&<>"']/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" }[c]));async function api(path, opts) { const r = await fetch(path, opts); let body = {}; try { body = await r.json(); } catch {} return { ok: r.ok, status: r.status, body };}async function loadBalance() { const r = await api("/wallet/balance?currency=usd"); $("balance").textContent = r.ok ? fmt(r.body.balance, r.body.currency) : "Unavailable"; }async function loadTxs() { const r = await api("/wallet/transactions"); const ul = $("txs"); if (!r.ok) { ul.innerHTML = '<li class="err">Could not load transactions</li>'; return; } if (!r.body.length) { ul.innerHTML = '<li class="muted">No transactions yet — add funds or pay an invoice.</li>'; return; } ul.innerHTML = r.body.slice(0, 10).map((t) => { const amt = Math.abs(t.postings[0]?.amount ?? 0); const pos = t.kind === "funding"; return `<li><div><strong>${esc(t.memo || t.kind)}</strong><small>${esc(t.kind)} · ${new Date(t.created_at).toLocaleString()}</small></div><span class="amt ${pos ? "pos" : "neg"}">${pos ? "+" : "−"}${fmt(amt)}</span></li>`; }).join("");}function msg(el, cls, text) { el.className = "msg " + cls; el.textContent = text; }$("payForm").addEventListener("submit", async (e) => { e.preventDefault(); const qr = $("qr").value.trim(); const m = $("payMsg"); if (!qr) return msg(m, "err", "Paste an invoice QR payload first."); const r = await api("/invoices/pay", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ qr }) }); if (r.ok) { msg(m, "ok", r.body.status === "already_paid" ? "This invoice was already paid." : `Paid ✓ — new balance ${fmt(r.body.balance)}`); $("qr").value = ""; refresh(); } else msg(m, "err", r.body.error || `Payment failed (${r.status})`);});$("fund").addEventListener("click", async () => { const m = $("fundMsg"); const amount = Math.round(Number($("fundAmt").value) * 100); $("fund").disabled = true; const r = await api("/funding/checkout", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ amount, currency: "usd" }) }); $("fund").disabled = false; if (r.status === 503) return msg(m, "warn", "Stripe not configured yet — add Stripe TEST keys as Space secrets to enable top-ups."); if (r.ok && r.body.url) { location.href = r.body.url; return; } msg(m, "err", r.body.error || `Could not start checkout (${r.status})`);});async function loadApps() { const r = await api("/links.json"); const el = $("apps"); if (!r.ok) { el.innerHTML = '<p class="muted">No apps configured.</p>'; return; } el.innerHTML = r.body.apps.map((a) => { const ic = esc(a.name.slice(0, 1)); if (!a.url) return `<div class="app disabled" aria-disabled="true"><div class="ic">${ic}</div><strong>${esc(a.name)}</strong><small>Coming soon</small></div>`; const sec = a.secondary ? `<a class="sec" href="${esc(a.secondary.url)}" target="_blank" rel="noopener">${esc(a.secondary.label)} ↗</a>` : ""; return `<div class="app"><a href="${esc(a.url)}" target="_blank" rel="noopener" style="text-decoration:none;color:inherit;display:block"><div class="ic">${ic}</div><strong>${esc(a.name)} ↗</strong><small>${esc(a.description || "")}</small></a>${sec}</div>`; }).join("");}async function loadStatus() { const r = await api("/healthz"); $("status").textContent = r.ok ? `● Service OK · mode: ${r.body.mode} · Stripe: ${r.body.stripe ? "configured" : "not configured"} · ${new Date().toLocaleTimeString()}` : "Service unreachable";}function refresh() { loadBalance(); loadTxs(); loadStatus(); }refresh(); loadApps();12345678910111213141516171819202122<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>ProjectOS — Wallet</title><link rel="stylesheet" href="/app.css"></head><body><header class="top"><div class="brand"><span class="mark">◆</span>Project<span class="light">OS</span></div><span class="badge">TEST MODE</span></header><main class="wrap"> <p class="eyebrow">WALLET <span class="rule"></span> PERSONAL</p> <h1>Welcome back, <span>Architect</span></h1> <section class="grid2"> <div class="card balance"><div class="label">WALLET BALANCE</div><div id="balance" class="big">—</div> <div class="row"><button id="fund" class="primary">+ Add funds</button><input id="fundAmt" type="number" min="0.5" step="0.01" value="25" aria-label="Amount (USD)"></div> <div id="fundMsg" class="msg"></div></div> <div class="card"><div class="label">PAY INVOICE</div> <form id="payForm"><textarea id="qr" rows="4" placeholder='Paste QR payload: {"v":1,"invoice_id":"INV-1","merchant_id":"m1","amount":1200,"currency":"usd"} or projectos-invoice:?v=1&...'></textarea> <button class="primary" type="submit">Pay from balance</button></form><div id="payMsg" class="msg"></div></div> </section> <section class="card"><div class="label">RECENT TRANSACTIONS</div><ul id="txs" class="txs"><li class="muted">Loading…</li></ul></section> <h2>Apps</h2><section id="apps" class="apps"></section></main><footer id="status" class="foot">Checking status…</footer><script src="/app.js"></script></body></html>1234567891011{ "apps": [ { "name": "KlawChat", "description": "Retrieval chat", "url": "https://huggingface.co/spaces/AnthropicallyHuggingFaces/klawchat-retrieval", "secondary": { "label": "GitHub", "url": "https://github.com/mindtdilly/klaw-chat" } }, { "name": "Klaw Command", "description": "Workbench", "url": "https://huggingface.co/spaces/AnthropicallyHuggingFaces/klaw-workbench" }, { "name": "OpenKlaw", "description": "Modules", "url": "https://huggingface.co/spaces/AnthropicallyHuggingFaces/openclaw-modules" }, { "name": "ProcureNet", "description": "Procurement atlas", "url": "https://huggingface.co/spaces/AnthropicallyHuggingFaces/procure-atlas", "secondary": { "label": "GitHub", "url": "https://github.com/mindtdilly/Procurenet" } }, { "name": "KlawPay", "description": "Wallet atlas", "url": "https://huggingface.co/spaces/AnthropicallyHuggingFaces/wallet-atlas", "secondary": { "label": "GitHub", "url": "https://github.com/mindtdilly/Omnipay" } }, { "name": "ProcureMe", "description": "Coming soon", "url": null }, { "name": "ChargeMe", "description": "Coming soon", "url": null } ]}123414 unmodified lines1920212223242526272829303132333435import express from "express";import type Stripe from "stripe";import type { Config } from "./config.js";import { Ledger, LedgerError } from "./ledger.js";14 unmodified lines});app.use(express.json({ limit: "32kb" }));app.get("/", (_req, res) => {const on = Boolean(stripeReady(true));res.type("html").send(`<!doctype html><html><head><meta charset="utf-8"><title>ProjectOS Wallet (test mode)</title><style>body{font-family:system-ui,sans-serif;max-width:640px;margin:40px auto;padding:0 16px}code{background:#eee;padding:1px 4px}</style></head><body><h1>ProjectOS Wallet <small>(test mode)</small></h1><p>Stripe: <strong>${on ? "configured (test keys)" : "not configured — funding/webhook routes return 503"}</strong></p><ul><li><a href="/healthz">GET /healthz</a></li><li><a href="/wallet/balance">GET /wallet/balance</a></li><li><a href="/wallet/transactions">GET /wallet/transactions</a></li><li><code>POST /invoices/pay</code></li><li><code>POST /funding/checkout</code></li><li><code>POST /funding/payment-intent</code></li><li><code>POST /webhooks/stripe</code></li></ul><p>No real money: test mode only.</p></body></html>`);});app.get("/healthz", (_req, res) => res.json({ ok: true, mode: "test", stripe: Boolean(stripeReady(true)) }));app.get("/wallet/balance", async (req, res, next) => {try { const currency = String(req.query.currency ?? "usd"); res.json({ currency, balance: await ledger.walletBalance(userId, currency) }); } catch (e) { next(e); }1234567814 unmodified lines23242526272829import express from "express";import { fileURLToPath } from "node:url";import path from "node:path";const publicDir = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..", "public");import type Stripe from "stripe";import type { Config } from "./config.js";import { Ledger, LedgerError } from "./ledger.js";14 unmodified lines});app.use(express.json({ limit: "32kb" }));app.use(express.static(publicDir, { index: "index.html" }));app.get("/healthz", (_req, res) => res.json({ ok: true, mode: "test", stripe: Boolean(stripeReady(true)) }));app.get("/wallet/balance", async (req, res, next) => {try { const currency = String(req.query.currency ?? "usd"); res.json({ currency, balance: await ledger.walletBalance(userId, currency) }); } catch (e) { next(e); }
24 unmodified lines25262728293031323324 unmodified linesconst root = await fetch(url + "/");expect(root.status).toBe(200);const html = await root.text();expect(html).toContain("ProjectOS Wallet");expect(html).toContain("not configured");expect(html).toContain('href="/healthz"');expect((await (await fetch(url + "/healthz")).json())).toMatchObject({ ok: true, stripe: false });const pay = await post("/invoices/pay", { invoice: { v: 1, invoice_id: "I1", merchant_id: "m", amount: 400, currency: "usd" } });expect(pay.status).toBe(200);24 unmodified lines252627282930313233343524 unmodified linesconst root = await fetch(url + "/");expect(root.status).toBe(200);const html = await root.text();expect(html).toContain("TEST MODE");expect(html).toContain('id="payForm"');const links = await (await fetch(url + "/links.json")).json();expect(links.apps.map((a: { name: string }) => a.name)).toEqual(["KlawChat","Klaw Command","OpenKlaw","ProcureNet","KlawPay","ProcureMe","ChargeMe"]);expect((await fetch(url + "/app.js")).status).toBe(200);expect((await (await fetch(url + "/healthz")).json())).toMatchObject({ ok: true, stripe: false });const pay = await post("/invoices/pay", { invoice: { v: 1, invoice_id: "I1", merchant_id: "m", amount: 400, currency: "usd" } });expect(pay.status).toBe(200);
Dockerfile+1
services/wallet/public/app.cssAdded+25
services/wallet/public/app.jsAdded+49
services/wallet/public/index.htmlAdded+22
services/wallet/public/links.jsonAdded+11
services/wallet/src/app.ts+5-11
services/wallet/test/app.test.ts+5-3