@hmharness/kernel 0.9.8 → 0.18.15

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/dist/index.d.ts CHANGED
@@ -13,3 +13,4 @@ export * from './mcp.js';
13
13
  export * from './goal.js';
14
14
  export * from './mcp2026.js';
15
15
  export * from './adaptive-router.js';
16
+ export * from './qrcode.js';
package/dist/index.js CHANGED
@@ -13,3 +13,4 @@ export * from "./mcp.js";
13
13
  export * from "./goal.js";
14
14
  export * from "./mcp2026.js";
15
15
  export * from "./adaptive-router.js";
16
+ export * from "./qrcode.js";
@@ -0,0 +1,22 @@
1
+ /**
2
+ * @hmharness/kernel - qrcode
3
+ * QR Code generation facade. The kernel itself stays zero-dependency; the
4
+ * web/cli packages pull in the `qrcode` npm lib and call through these
5
+ * typed wrappers. When the lib is absent (pure-kernel consumers), the
6
+ * functions throw with a clear message instead of crashing.
7
+ *
8
+ * The previous hand-rolled encoder had format-info and data-placement bugs
9
+ * that made codes unscannable by every phone QR reader (2026-09-29 lesson:
10
+ * QR spec is 100+ pages of exact bit placement - use a proven library).
11
+ */
12
+ export interface QrOutput {
13
+ /** ASCII art for terminal display (half-block Unicode). */
14
+ terminal: string;
15
+ /** SVG string for web display. */
16
+ svg: string;
17
+ }
18
+ /**
19
+ * Generate QR code output for a text (typically a URL).
20
+ * Requires the `qrcode` npm package to be installed in the consuming package.
21
+ */
22
+ export declare function generateQr(text: string): Promise<QrOutput>;
package/dist/qrcode.js ADDED
@@ -0,0 +1,29 @@
1
+ /**
2
+ * @hmharness/kernel - qrcode
3
+ * QR Code generation facade. The kernel itself stays zero-dependency; the
4
+ * web/cli packages pull in the `qrcode` npm lib and call through these
5
+ * typed wrappers. When the lib is absent (pure-kernel consumers), the
6
+ * functions throw with a clear message instead of crashing.
7
+ *
8
+ * The previous hand-rolled encoder had format-info and data-placement bugs
9
+ * that made codes unscannable by every phone QR reader (2026-09-29 lesson:
10
+ * QR spec is 100+ pages of exact bit placement - use a proven library).
11
+ */
12
+ /**
13
+ * Generate QR code output for a text (typically a URL).
14
+ * Requires the `qrcode` npm package to be installed in the consuming package.
15
+ */
16
+ export async function generateQr(text) {
17
+ let QR;
18
+ try {
19
+ QR = (await import('qrcode'));
20
+ }
21
+ catch {
22
+ throw new Error('qrcode package not installed - run: npm install qrcode');
23
+ }
24
+ const [terminal, svg] = await Promise.all([
25
+ QR.toString(text, { type: 'terminal', small: true, margin: 1 }),
26
+ QR.toString(text, { type: 'svg', margin: 2, width: 240 }),
27
+ ]);
28
+ return { terminal, svg };
29
+ }
package/dist/types.d.ts CHANGED
@@ -122,6 +122,26 @@ export interface HmhConfig {
122
122
  };
123
123
  /** Named vendor endpoints for multi-provider routing. */
124
124
  providers?: Record<string, ProviderConfig>;
125
+ /** Web UI exposure. Default loopback-only (zero remote attack surface).
126
+ * LAN/WAN listening REQUIRES a token: the approval endpoint is RCE by
127
+ * design, so any non-loopback bind without auth is a remote-code-execution
128
+ * hole, not a feature. */
129
+ web?: {
130
+ /** 'loopback' (default) | 'lan' | 'wan'. lan = bind 0.0.0.0, host-allowlist
131
+ * accepts private-range IPs; wan = same but host-allowlist is disabled
132
+ * (any Host/Origin header accepted) because WAN visitors arrive through
133
+ * NAT/frp/tailscale domains we cannot enumerate. Token is MANDATORY for
134
+ * both. */
135
+ exposure?: 'loopback' | 'lan' | 'wan';
136
+ /** Shared secret for non-loopback access. Sent as ?key= on first load,
137
+ * then via the X-Hmh-Key header (SSE cannot set custom headers, so the
138
+ * page keeps the key in sessionStorage and appends it to /api/events). */
139
+ token?: string;
140
+ /** Internet tunnel intent (cloudflared Quick Tunnel / pinggy). Set from
141
+ * the pairing modal; on restart the server brings the tunnel back so
142
+ * previously printed QR URLs do not rot into Cloudflare 1033 pages. */
143
+ tunnel?: boolean;
144
+ };
125
145
  /** Per-purpose provider names resolved against `providers`. */
126
146
  routing?: {
127
147
  /** main chat loop (default: `provider`) */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hmharness/kernel",
3
- "version": "0.9.8",
3
+ "version": "0.18.15",
4
4
  "description": "hmharness kernel: tool registry, provider adapters, the agent loop, session log, config. Zero runtime dependencies (Node >=22 native fetch).",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",