openzoo 0.43.8 → 0.43.9

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/lib/grokui.mjs CHANGED
@@ -529,7 +529,7 @@ const APP_HTML = `<!doctype html>
529
529
  .tname { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
530
530
  .tprev { font-size: 12px; color: #8e8e93; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
531
531
  .tdot { width: 8px; height: 8px; border-radius: 50%; background: #0a84ff; flex: 0 0 8px; }
532
- #main { flex: 1; display: flex; flex-direction: column; height: 100vh; }
532
+ #main { flex: 1; min-width: 0; display: flex; flex-direction: column; height: 100vh; }
533
533
  #chatHeader { padding: 14px 20px; border-bottom: 1px solid #1c1c1e; display: flex; align-items: center; gap: 10px;
534
534
  font-weight: 600; }
535
535
  #chatHeader .tavatar { width: 26px; height: 26px; border-radius: 7px; font-size: 11px; flex: 0 0 26px; }
@@ -549,16 +549,23 @@ const APP_HTML = `<!doctype html>
549
549
  #hud .hember { color: #f28c4d; }
550
550
  #hud .hfoot { border-top: 1px solid #333340; margin-top: 10px; padding-top: 8px; color: #999aa8; font-size: 10px; }
551
551
  #sidebar, #main { -webkit-app-region: no-drag; }
552
- #log { flex: 1; overflow-y: auto; padding: 20px 24px 12px; display: flex; flex-direction: column; gap: 6px;
552
+ #log { flex: 1; min-width: 0; overflow-y: auto; overflow-x: hidden; padding: 20px 24px 12px;
553
+ display: flex; flex-direction: column; gap: 6px;
553
554
  -webkit-user-select: text; user-select: text; }
554
555
  .hdr { align-self: flex-start; display: flex; align-items: center; gap: 6px; margin: 12px 0 4px;
555
556
  color: #8e8e93; font-size: 13px; }
556
557
  .hdr .avatar { width: 18px; height: 18px; border-radius: 5px; display: flex; align-items: center;
557
558
  justify-content: center; color: #fff; font-size: 9px; font-weight: 700; }
558
- .row { display: flex; max-width: 78%; margin: 2px 0; }
559
+ /* min-width:0 is load-bearing. A flex item defaults to min-width:auto, so it
560
+ refuses to shrink below its content's intrinsic width — one long
561
+ unbreakable line (a curl command, a JSON blob) in a <pre> then stretches
562
+ the row past max-width, widens the whole column, and pushes the header's
563
+ cost button off-screen. */
564
+ .row { display: flex; max-width: 78%; min-width: 0; margin: 2px 0; }
559
565
  .row.user { align-self: flex-end; }
560
566
  .row.bot { align-self: flex-start; }
561
567
  .bubble { padding: 11px 16px; border-radius: 20px; white-space: pre-wrap; word-break: break-word;
568
+ min-width: 0; max-width: 100%; overflow-x: hidden;
562
569
  -webkit-user-select: text; user-select: text; cursor: text; }
563
570
  .bubble a { color: #6ab0ff; text-decoration: underline; cursor: pointer; }
564
571
  /* rendered markdown. The bubble is pre-wrap for plain text, but block
@@ -582,7 +589,8 @@ const APP_HTML = `<!doctype html>
582
589
  .md-table th { background: #1c1c1e; font-weight: 600; }
583
590
  .bubble-images { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
584
591
  .bubble-images img { max-width: 160px; max-height: 160px; border-radius: 12px; display: block; }
585
- .runcard { background: #1c1c1e; border: 1px solid #333; border-radius: 14px; padding: 12px 14px; max-width: 100%; }
592
+ .runcard { background: #1c1c1e; border: 1px solid #333; border-radius: 14px; padding: 12px 14px;
593
+ max-width: 100%; min-width: 0; overflow: hidden; }
586
594
  .runcmd { font-family: Menlo, monospace; font-size: 12.5px; color: #ececec; white-space: pre-wrap;
587
595
  word-break: break-word; margin-bottom: 8px; }
588
596
  .runactions { display: flex; gap: 8px; }
package/lib/namespace.js CHANGED
@@ -47,8 +47,73 @@ export function namespaceHeaderValue() {
47
47
  return cached;
48
48
  }
49
49
 
50
- /** Merge the namespace header into any headers object. */
50
+ /**
51
+ * PROVE the namespace claim instead of merely asserting it.
52
+ *
53
+ * The header above is derived from the PUBLIC key, so on its own it is not
54
+ * authentication: anyone who knows this wallet's address can recompute the
55
+ * same value and land in the same sidecar tenant — and since the sidecar gates
56
+ * context access purely on tenant match, that is the whole door. The gateway
57
+ * (nsauth.ts) verifies a signature over `openzoo-namespace:<ns>:<ts>` and
58
+ * derives the tenant from sha256(chain:signer:namespace), which binds the
59
+ * PROVEN signer in, so another wallet signing an identical label lands
60
+ * somewhere else.
61
+ *
62
+ * Signed with the same Solana key x402 already pays from — no new secret, and
63
+ * nothing leaves the machine but a public key and a signature. The timestamp
64
+ * is what bounds replay (the gateway enforces its own window), so it is minted
65
+ * per call and these headers are deliberately NOT cached.
66
+ */
67
+ const PKCS8_ED25519_PREFIX = Buffer.from('302e020100300506032b657004220420', 'hex');
68
+
69
+ function signNamespace(namespace) {
70
+ const w = loadOrCreateWallet();
71
+ const timestamp = String(Date.now());
72
+ // Node has no raw-ed25519 signer, but it will build one from a PKCS8 DER
73
+ // wrapper around the 32-byte seed (a Solana secretKey is seed||pubkey).
74
+ const der = Buffer.concat([PKCS8_ED25519_PREFIX, Buffer.from(w.keypair.secretKey.slice(0, 32))]);
75
+ const key = crypto.createPrivateKey({ key: der, format: 'der', type: 'pkcs8' });
76
+ const sig = crypto.sign(null, Buffer.from(`openzoo-namespace:${namespace}:${timestamp}`), key);
77
+ return {
78
+ 'x-openzoo-namespace-sig': base58encode(sig),
79
+ 'x-openzoo-namespace-signer': w.keypair.publicKey.toBase58(),
80
+ 'x-openzoo-namespace-ts': timestamp,
81
+ 'x-openzoo-namespace-chain': 'solana',
82
+ };
83
+ }
84
+
85
+ /** Merge the namespace header — and its proof — into any headers object. */
51
86
  export function withNamespace(headers = {}) {
52
87
  const ns = namespaceHeaderValue();
53
- return ns ? { ...headers, 'x-openzoo-namespace': ns } : headers;
88
+ if (!ns) return headers;
89
+ let proof = {};
90
+ try {
91
+ proof = signNamespace(ns);
92
+ } catch {
93
+ // Unsigned still works while the gateway is in soft launch. Sending the
94
+ // bare namespace is strictly better than sending nothing: it keeps the
95
+ // caller in their existing tenant instead of silently relocating every
96
+ // bound corpus to the shared one.
97
+ }
98
+ return { ...headers, 'x-openzoo-namespace': ns, ...proof };
99
+ }
100
+
101
+ // Bitcoin-alphabet base58, matching what the gateway's bs58 decode expects.
102
+ // Local rather than a dependency for the same reason lib/x402.js keeps its own.
103
+ const B58 = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
104
+ function base58encode(bytes) {
105
+ const digits = [0];
106
+ for (const byte of bytes) {
107
+ let carry = byte;
108
+ for (let j = 0; j < digits.length; j++) {
109
+ carry += digits[j] << 8;
110
+ digits[j] = carry % 58;
111
+ carry = (carry / 58) | 0;
112
+ }
113
+ while (carry > 0) { digits.push(carry % 58); carry = (carry / 58) | 0; }
114
+ }
115
+ let out = '';
116
+ for (const b of bytes) { if (b === 0) out += '1'; else break; } // leading zeros
117
+ for (let i = digits.length - 1; i >= 0; i--) out += B58[digits[i]];
118
+ return out;
54
119
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openzoo",
3
- "version": "0.43.8",
3
+ "version": "0.43.9",
4
4
  "description": "Local x402-paying proxy + MCP server for openzoo.fun — point any OpenAI-compatible harness (Cursor, Claude Code, aider, SDKs) at localhost and it pays per call from a local burner wallet. Solana and Base rails live; Robinhood experimental.",
5
5
  "license": "MIT",
6
6
  "type": "module",