omp-opencode-bridge 0.0.0-stage → 2.6.0

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/package.json CHANGED
@@ -1,6 +1,81 @@
1
1
  {
2
2
  "name": "omp-opencode-bridge",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "2.6.0",
4
+ "description": "OpenCode free-tier models for OMP/pi: a local OpenAI-compatible bridge (no account required) plus the keyless provider plugin",
5
+ "main": "server.ts",
6
+ "bin": {
7
+ "opencode-free-bridge": "server.ts"
8
+ },
9
+ "scripts": {
10
+ "start": "bun server.ts",
11
+ "test": "bun test test/*.test.js",
12
+ "drill": "bun gate-drill.ts",
13
+ "verify": "bun verify.ts",
14
+ "verify:quick": "bun verify.ts --quick",
15
+ "fingerprint": "bun transport-fingerprint.ts",
16
+ "fingerprint:check": "bun transport-fingerprint.ts --check",
17
+ "start:node": "node server.ts",
18
+ "test:node": "node --test test/*.test.js",
19
+ "drill:node": "node gate-drill.ts"
20
+ },
21
+ "engines": {
22
+ "bun": ">=1.0.0"
23
+ },
24
+ "files": [
25
+ "server.ts",
26
+ "identity.ts",
27
+ "token-budget.ts",
28
+ "verify.ts",
29
+ "gate-drill.ts",
30
+ "README.md",
31
+ "AGENTS.md",
32
+ "install.sh",
33
+ "THIRD_PARTY_NOTICES.md",
34
+ "egress-proxy.ts",
35
+ "transport-fingerprint.ts",
36
+ "transport-baseline.json",
37
+ "tunnel-doctor.sh",
38
+ "proxy.ts",
39
+ "panel.ts",
40
+ "anthropic.ts",
41
+ "src"
42
+ ],
43
+ "keywords": [
44
+ "opencode",
45
+ "openai",
46
+ "bridge",
47
+ "proxy",
48
+ "free",
49
+ "llm",
50
+ "9router",
51
+ "cursor",
52
+ "continue",
53
+ "vscode",
54
+ "pi-package",
55
+ "pi-extension",
56
+ "omp",
57
+ "coding-agent"
58
+ ],
59
+ "pi": {
60
+ "extensions": [
61
+ "./src/index.ts"
62
+ ]
63
+ },
64
+ "peerDependencies": {
65
+ "@earendil-works/pi-coding-agent": ">=1.0.0"
66
+ },
67
+ "peerDependenciesMeta": {
68
+ "@earendil-works/pi-coding-agent": {
69
+ "optional": true
70
+ }
71
+ },
72
+ "repository": {
73
+ "type": "git",
74
+ "url": "git+https://github.com/yayayapluto/omp-opencode-bridge.git"
75
+ },
76
+ "homepage": "https://github.com/yayayapluto/omp-opencode-bridge#readme",
77
+ "bugs": {
78
+ "url": "https://github.com/yayayapluto/omp-opencode-bridge/issues"
79
+ },
80
+ "license": "MIT"
81
+ }
package/panel.ts ADDED
@@ -0,0 +1,537 @@
1
+ #!/usr/bin/env bun
2
+ /**
3
+ * panel.ts: the browser panel served at `/`.
4
+ *
5
+ * One job: let the operator point the bridge's egress at an HTTP proxy and see
6
+ * whether that proxy actually reaches upstream. Everything the panel draws comes
7
+ * from `proxy.describe()` over JSON; no user-supplied value is interpolated into
8
+ * this HTML, and the client sets every dynamic string with `textContent`.
9
+ *
10
+ * Design direction (my call, no DESIGN.md in this repo): an operations console for
11
+ * a developer running a local bridge. Warm paper and ink, one clay accent reserved
12
+ * for the commit action and the focus ring, system UI type for prose and monospace
13
+ * only where characters are read one by one (a proxy URL). Dials: ENERGY 1,
14
+ * RHYTHM 1, MOTION 1: this is a settings surface, not a landing page.
15
+ */
16
+
17
+ const STYLE = `
18
+ :root {
19
+ color-scheme: light dark;
20
+ --paper: #f7f5f1;
21
+ --surface: #ffffff;
22
+ --ink: #1c1a16;
23
+ --muted: #5c574e;
24
+ --rule: #cfc9bf;
25
+ --field: #8d857a;
26
+ --accent: #9a3f10;
27
+ --accent-ink: #ffffff;
28
+ --ok: #2c6a33;
29
+ --bad: #9b2118;
30
+ }
31
+ @media (prefers-color-scheme: dark) {
32
+ :root {
33
+ --paper: #131211;
34
+ --surface: #1b1a18;
35
+ --ink: #ece7de;
36
+ --muted: #a49c92;
37
+ --rule: #3a3631;
38
+ --field: #7a746a;
39
+ --accent: #e39a63;
40
+ --accent-ink: #1a1208;
41
+ --ok: #7bc48a;
42
+ --bad: #f08c82;
43
+ }
44
+ }
45
+ * { box-sizing: border-box; }
46
+ body {
47
+ margin: 0;
48
+ padding: 40px 20px 64px;
49
+ background: var(--paper);
50
+ color: var(--ink);
51
+ font: 16px/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
52
+ }
53
+ main { max-width: 620px; margin: 0 auto; }
54
+ header { border-bottom: 1px solid var(--rule); padding-bottom: 16px; margin-bottom: 28px; }
55
+ h1 { font-size: 1.25rem; line-height: 1.3; margin: 0 0 6px; letter-spacing: -0.01em; }
56
+ .sub { margin: 0; color: var(--muted); font-size: 0.9375rem; }
57
+ h2 { font-size: 0.8125rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); margin: 0 0 12px; }
58
+ section { margin-bottom: 32px; }
59
+ .status {
60
+ display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 12px;
61
+ padding: 14px 16px; border: 1px solid var(--rule); border-radius: 3px; background: var(--surface);
62
+ }
63
+ .status .mode { font-weight: 600; }
64
+ .status .mode[data-mode="proxy"] { color: var(--ok); }
65
+ .status .host { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.9375rem; }
66
+ .status .note { color: var(--muted); font-size: 0.875rem; width: 100%; }
67
+ .field { margin-bottom: 20px; }
68
+ label { display: block; font-weight: 600; font-size: 0.9375rem; margin-bottom: 6px; }
69
+ input[type="text"] {
70
+ width: 100%; padding: 10px 12px; font-size: 1rem;
71
+ font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
72
+ color: var(--ink); background: var(--surface);
73
+ border: 1px solid var(--field); border-radius: 3px;
74
+ }
75
+ textarea {
76
+ width: 100%; padding: 10px 12px; font-size: 0.9375rem; resize: vertical;
77
+ font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
78
+ color: var(--ink); background: var(--surface);
79
+ border: 1px solid var(--field); border-radius: 3px;
80
+ }
81
+ select {
82
+ width: 100%; padding: 10px 12px; font-size: 0.9375rem;
83
+ color: var(--ink); background: var(--surface);
84
+ border: 1px solid var(--field); border-radius: 3px;
85
+ }
86
+ .pool-list { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 6px; }
87
+ .pool-list[hidden] { display: none; }
88
+ .pool-list li {
89
+ display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px;
90
+ padding: 8px 12px; border: 1px solid var(--rule); border-radius: 3px;
91
+ background: var(--surface); font-size: 0.9375rem;
92
+ }
93
+ .pool-list .name { font-weight: 600; }
94
+ .pool-list .addr { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.875rem; }
95
+ .pool-list .state { margin-left: auto; font-size: 0.8125rem; font-weight: 600; letter-spacing: 0.02em; text-transform: uppercase; }
96
+ .pool-list .state[data-state="ready"] { color: var(--ok); }
97
+ .pool-list .state[data-state="cooling"] { color: var(--bad); }
98
+ .pool-list .state[data-state="disabled"] { color: var(--muted); }
99
+ .pool-list .detail { width: 100%; color: var(--muted); font-size: 0.8125rem; }
100
+ input[type="text"]::placeholder { color: var(--muted); opacity: 1; }
101
+ .hint { margin: 6px 0 0; font-size: 0.875rem; color: var(--muted); }
102
+ .hint code { font-size: 0.8125rem; }
103
+ .actions { display: flex; flex-wrap: wrap; gap: 10px; }
104
+ button {
105
+ font: inherit; font-size: 0.9375rem; font-weight: 600;
106
+ padding: 10px 18px; min-height: 44px;
107
+ border: 1px solid var(--field); border-radius: 3px;
108
+ background: var(--surface); color: var(--ink); cursor: pointer;
109
+ }
110
+ button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
111
+ button:disabled { opacity: 0.55; cursor: default; }
112
+ :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
113
+ .report { margin-top: 20px; font-size: 0.9375rem; }
114
+ .report[hidden] { display: none; }
115
+ .report .line { margin: 0 0 4px; }
116
+ .report .ok { color: var(--ok); font-weight: 600; }
117
+ .report .bad { color: var(--bad); font-weight: 600; }
118
+ .report .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
119
+ dl { display: grid; grid-template-columns: max-content 1fr; gap: 8px 20px; margin: 0; font-size: 0.9375rem; }
120
+ dt { color: var(--muted); }
121
+ dd { margin: 0; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; overflow-wrap: anywhere; }
122
+ footer { border-top: 1px solid var(--rule); padding-top: 16px; color: var(--muted); font-size: 0.875rem; }
123
+ footer a { color: var(--ink); }
124
+ @media (max-width: 480px) {
125
+ body { padding: 28px 16px 48px; }
126
+ .actions button { width: 100%; }
127
+ dl { grid-template-columns: 1fr; gap: 2px 0; }
128
+ dd { margin-bottom: 8px; }
129
+ }
130
+ `;
131
+
132
+ const SCRIPT = `
133
+ const $ = (id) => document.getElementById(id);
134
+ const urlInput = $("proxy-url");
135
+ const saveBtn = $("save");
136
+ const testBtn = $("test");
137
+ const directBtn = $("direct");
138
+ const report = $("report");
139
+ const form = $("form");
140
+
141
+ function line(text, cls) {
142
+ const p = document.createElement("p");
143
+ p.className = "line" + (cls ? " " + cls : "");
144
+ p.textContent = text;
145
+ return p;
146
+ }
147
+
148
+ function showReport(nodes) {
149
+ report.replaceChildren(...nodes);
150
+ report.hidden = false;
151
+ }
152
+
153
+ let locked = false;
154
+
155
+ // Busy disables everything so a second click cannot race the first. Idle
156
+ // restores the lock: an env-owned proxy blocks saving, but probing a candidate
157
+ // proxy is read-only and stays available.
158
+ function setBusy(busy) {
159
+ saveBtn.disabled = busy || locked;
160
+ directBtn.disabled = busy || locked;
161
+ testBtn.disabled = busy;
162
+ }
163
+
164
+ function renderStatus(state) {
165
+ $("mode").textContent =
166
+ state.mode === "pool" ? "Pool aktif" : state.mode === "proxy" ? "Lewat proxy" : "Langsung (IP asli)";
167
+ $("mode").dataset.mode = state.mode === "direct" ? "direct" : "proxy";
168
+ $("host").textContent = state.proxy || "tidak ada proxy";
169
+ const notes = [];
170
+ if (state.locked) notes.push("Dikunci " + state.source + ": ubah variabel environment lalu restart.");
171
+ if (state.hasCredentials) notes.push("Kredensial tersimpan, tidak ditampilkan.");
172
+ if (state.source === "file") notes.push("Disimpan di " + state.configPath);
173
+ if (state.error) notes.push(state.error);
174
+ $("note").textContent = notes.join(" ");
175
+ $("note").hidden = notes.length === 0;
176
+ renderPool(state.pool);
177
+ }
178
+
179
+ function renderPool(pool) {
180
+ const list = $("pool-list");
181
+ const state = pool || {};
182
+ const entries = Array.isArray(state.entries) ? state.entries : [];
183
+
184
+ if (!state.active || entries.length === 0) {
185
+ list.hidden = true;
186
+ list.replaceChildren();
187
+ return;
188
+ }
189
+
190
+ list.replaceChildren(
191
+ ...entries.map((entry) => {
192
+ const li = document.createElement("li");
193
+
194
+ const name = document.createElement("span");
195
+ name.className = "name";
196
+ name.textContent = entry.label || entry.id;
197
+
198
+ const addr = document.createElement("span");
199
+ addr.className = "addr";
200
+ addr.textContent = entry.host || "?";
201
+
202
+ const badge = document.createElement("span");
203
+ badge.className = "state";
204
+ badge.dataset.state = entry.state;
205
+ badge.textContent =
206
+ entry.state === "ready" ? "siap" : entry.state === "cooling" ? "cooldown" : "nonaktif";
207
+
208
+ li.append(name, addr, badge);
209
+
210
+ const detail = document.createElement("span");
211
+ detail.className = "detail";
212
+ const bits = [];
213
+ if (entry.state === "cooling" && entry.cooldownMsLeft) {
214
+ bits.push("pulih dalam " + Math.ceil(entry.cooldownMsLeft / 1000) + " dtk");
215
+ }
216
+ if (entry.failures) bits.push(entry.failures + " kegagalan");
217
+ if (entry.lastError) bits.push(entry.lastError);
218
+ if (entry.weight !== 1) bits.push("bobot " + entry.weight);
219
+ if (bits.length) detail.textContent = bits.join(" · ");
220
+ if (bits.length) li.append(detail);
221
+
222
+ return li;
223
+ })
224
+ );
225
+ list.hidden = false;
226
+ }
227
+
228
+ /**
229
+ * Parse the textarea into entries. One per line; label=url or a bare URL.
230
+ * Validation happens on the server, which already owns the URL rules, so this
231
+ * only splits the text.
232
+ */
233
+ function readPoolInput() {
234
+ return $("pool-entries")
235
+ .value.split("\\n")
236
+ .map((line) => line.trim())
237
+ .filter(Boolean)
238
+ .map((line) => {
239
+ const eq = line.indexOf("=");
240
+ if (eq > 0 && !line.slice(0, eq).includes("/")) {
241
+ return { label: line.slice(0, eq).trim(), url: line.slice(eq + 1).trim() };
242
+ }
243
+ return { url: line };
244
+ });
245
+ }
246
+
247
+ function poolEntriesToText(pool) {
248
+ const entries = Array.isArray(pool?.entries) ? pool.entries : [];
249
+ return entries
250
+ .map((entry) => (entry.label && entry.label !== entry.id ? entry.label + "=" : "") + (entry.host || ""))
251
+ .join("\\n");
252
+ }
253
+
254
+ async function readJson(res) {
255
+ const body = await res.json().catch(() => ({}));
256
+ if (!res.ok) throw new Error(body.error || "HTTP " + res.status);
257
+ return body;
258
+ }
259
+
260
+ async function load() {
261
+ try {
262
+ const state = await readJson(await fetch("/api/proxy"));
263
+ renderStatus(state);
264
+
265
+ // Prefill the pool editor from the live config so an operator can edit an
266
+ // existing entry instead of retyping it. Host:port is enough to identify an
267
+ // entry; credentials never round-trip through the panel.
268
+ const poolState = state.pool || {};
269
+ $("pool-entries").value = poolEntriesToText(poolState);
270
+ // Reset the select first: an unknown strategy from a newer release must
271
+ // not leave the select stuck on a stale option, and an existing selection
272
+ // survives because setting an invalid value makes .value empty.
273
+ $("pool-strategy").value = "";
274
+ $("pool-strategy").value = poolState.strategy || "round-robin";
275
+
276
+ locked = state.locked;
277
+
278
+ // An env-owned proxy is read-only for saving, but the field stays usable so
279
+ // a candidate can still be probed before the operator edits the service unit.
280
+ saveBtn.disabled = locked;
281
+ directBtn.disabled = locked;
282
+ $("pool-save").disabled = locked;
283
+ $("pool-clear").disabled = locked;
284
+ } catch (err) {
285
+ showReport([line("Gagal memuat status: " + err.message, "bad")]);
286
+ }
287
+ }
288
+
289
+ async function send(path, payload) {
290
+ setBusy(true);
291
+ try {
292
+ const res = await fetch(path, {
293
+ method: "POST",
294
+ headers: { "Content-Type": "application/json" },
295
+ body: JSON.stringify(payload),
296
+ });
297
+ return await readJson(res);
298
+ } finally {
299
+ setBusy(false);
300
+ }
301
+ }
302
+
303
+ async function save() {
304
+ const value = urlInput.value;
305
+ try {
306
+ const state = await send("/api/proxy", { url: value });
307
+ renderStatus(state);
308
+ urlInput.value = "";
309
+ showReport([line(state.mode === "proxy" ? "Proxy aktif. Request berikutnya memakai egress ini." : "Proxy dimatikan. Egress kembali langsung.", "ok")]);
310
+ } catch (err) {
311
+ showReport([line(err.message, "bad")]);
312
+ }
313
+ }
314
+
315
+ saveBtn.addEventListener("click", save);
316
+ form.addEventListener("submit", (event) => {
317
+ event.preventDefault();
318
+ save();
319
+ });
320
+
321
+ testBtn.addEventListener("click", async () => {
322
+ const target = urlInput.value.trim();
323
+ if (!target) {
324
+ showReport([line("Isi URL proxy dulu untuk diuji.", "bad")]);
325
+ return;
326
+ }
327
+ showReport([line("Menguji " + target + " …")]);
328
+ try {
329
+ const r = await send("/api/proxy/test", { url: target });
330
+ const nodes = [];
331
+ if (r.ok) {
332
+ nodes.push(line("Proxy menjawab upstream (HTTP " + r.apiStatus + ") dalam " + r.latencyMs + " ms.", "ok"));
333
+ if (r.exitIp) nodes.push(line("IP keluar: " + r.exitIp, "mono"));
334
+ else nodes.push(line("IP keluar tidak terbaca: " + (r.exitError || "tidak diketahui"), "bad"));
335
+ } else {
336
+ nodes.push(line(r.error || "Uji proxy gagal.", "bad"));
337
+ if (r.exitIp) nodes.push(line("IP keluar: " + r.exitIp, "mono"));
338
+ }
339
+ showReport(nodes);
340
+ } catch (err) {
341
+ showReport([line(err.message, "bad")]);
342
+ }
343
+ });
344
+
345
+ directBtn.addEventListener("click", async () => {
346
+ try {
347
+ const state = await send("/api/proxy", { url: "" });
348
+ renderStatus(state);
349
+ urlInput.value = "";
350
+ showReport([line("Proxy dimatikan. Egress kembali langsung dari IP mesin ini.", "ok")]);
351
+ } catch (err) {
352
+ showReport([line(err.message, "bad")]);
353
+ }
354
+ });
355
+
356
+ function showPoolReport(nodes) {
357
+ const box = $("pool-report");
358
+ box.replaceChildren(...nodes);
359
+ box.hidden = false;
360
+ }
361
+
362
+ $("pool-save").addEventListener("click", async () => {
363
+ const entries = readPoolInput();
364
+ if (entries.length === 0) {
365
+ showPoolReport([line("Isi minimal satu proxy.", "bad")]);
366
+ return;
367
+ }
368
+ try {
369
+ const state = await send("/api/proxy", {
370
+ entries,
371
+ strategy: $("pool-strategy").value,
372
+ });
373
+ renderStatus(state);
374
+ showPoolReport([
375
+ line(
376
+ "Pool aktif: " + state.pool.enabled + "/" + state.pool.size + " entri, strategi " + state.pool.strategy + ".",
377
+ "ok"
378
+ ),
379
+ ]);
380
+ } catch (err) {
381
+ showPoolReport([line(err.message, "bad")]);
382
+ }
383
+ });
384
+
385
+ $("pool-test").addEventListener("click", async () => {
386
+ const entries = readPoolInput();
387
+ if (entries.length === 0) {
388
+ showPoolReport([line("Isi minimal satu proxy untuk diuji.", "bad")]);
389
+ return;
390
+ }
391
+ showPoolReport([line("Menguji " + entries.length + " proxy …")]);
392
+ try {
393
+ const r = await send("/api/proxy/test", { entries });
394
+ const nodes = (r.entries || []).map((entry) => {
395
+ const head = (entry.label || entry.host || entry.id) + " — ";
396
+ if (entry.ok) {
397
+ return line(head + "ok, " + entry.latencyMs + " ms, IP " + (entry.exitIp || "tidak terbaca"), "ok");
398
+ }
399
+ return line(head + (entry.error || "gagal"), "bad");
400
+ });
401
+ showPoolReport(nodes.length ? nodes : [line("Tidak ada hasil.", "bad")]);
402
+ } catch (err) {
403
+ showPoolReport([line(err.message, "bad")]);
404
+ }
405
+ });
406
+
407
+ $("pool-clear").addEventListener("click", async () => {
408
+ try {
409
+ const state = await send("/api/proxy", { entries: [] });
410
+ renderStatus(state);
411
+ $("pool-entries").value = "";
412
+ showPoolReport([line("Pool dikosongkan. Egress kembali ke proxy tunggal atau langsung.", "ok")]);
413
+ } catch (err) {
414
+ showPoolReport([line(err.message, "bad")]);
415
+ }
416
+ });
417
+
418
+ load();
419
+ `;
420
+
421
+ interface PanelOptions {
422
+ version?: string | number;
423
+ port?: string | number;
424
+ }
425
+
426
+ /** Shape of `proxy.describe()`; only the scalar fields are read here. */
427
+ interface PanelDescription {
428
+ mode?: string;
429
+ proxy?: string | null;
430
+ hasCredentials?: boolean;
431
+ source?: string;
432
+ locked?: boolean;
433
+ configPath?: string;
434
+ error?: string | null;
435
+ pool?: Record<string, unknown>;
436
+ }
437
+
438
+ function escapeHtml(value: unknown): string {
439
+ return String(value).replace(/[&<>"]/g, (c) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;" })[c]);
440
+ }
441
+
442
+ /**
443
+ * Full panel document. `description` is `proxy.describe()`; only its scalar
444
+ * fields are read, and they are escaped, so a value from the config file cannot
445
+ * become markup.
446
+ */
447
+ function renderPanel(description?: PanelDescription | null, { version = "", port = "" }: PanelOptions = {}): string {
448
+ const state: PanelDescription = description || {};
449
+ return `<!doctype html>
450
+ <html lang="id">
451
+ <head>
452
+ <meta charset="utf-8">
453
+ <meta name="viewport" content="width=device-width, initial-scale=1">
454
+ <meta name="color-scheme" content="light dark">
455
+ <title>Proxy egress · opencode-free-bridge</title>
456
+ <style>${STYLE}</style>
457
+ </head>
458
+ <body>
459
+ <main>
460
+ <header>
461
+ <h1>Proxy egress</h1>
462
+ <p class="sub">Arahkan semua koneksi keluar bridge lewat proxy HTTP, supaya upstream tidak melihat IP mesin ini.</p>
463
+ </header>
464
+
465
+ <section aria-labelledby="status-title">
466
+ <h2 id="status-title">Status sekarang</h2>
467
+ <div class="status">
468
+ <span class="mode" id="mode">${escapeHtml(state.mode === "pool" ? "Pool aktif" : state.mode === "proxy" ? "Lewat proxy" : "Langsung (IP asli)")}</span>
469
+ <span class="host" id="host">${escapeHtml(state.proxy || "tidak ada proxy")}</span>
470
+ <span class="note" id="note" hidden></span>
471
+ </div>
472
+ <ul class="pool-list" id="pool-list" hidden></ul>
473
+ </section>
474
+
475
+ <section aria-labelledby="pool-title">
476
+ <h2 id="pool-title">Pool egress</h2>
477
+ <p class="hint">Satu URL per baris. Tambahkan label dengan <code>nama=url</code>. Pool dipakai bergantian; entri yang ditolak upstream masuk cooldown dan dilewati sampai pulih.</p>
478
+ <div class="field">
479
+ <label for="pool-entries">Daftar proxy</label>
480
+ <textarea id="pool-entries" rows="6" spellcheck="false" placeholder="med1=http://10.0.0.1:8888&#10;med2=http://10.0.0.2:8888"></textarea>
481
+ </div>
482
+ <div class="field">
483
+ <label for="pool-strategy">Strategi</label>
484
+ <select id="pool-strategy">
485
+ <option value="priority-failover">Prioritas + failover (utamakan urutan atas, balik otomatis)</option>
486
+ <option value="round-robin">Round-robin (sebar rata)</option>
487
+ <option value="failover">Failover (pakai yang pertama sampai ditolak)</option>
488
+ <option value="random">Acak berbobot</option>
489
+ </select>
490
+ </div>
491
+ <div class="actions">
492
+ <button type="button" class="primary" id="pool-save">Simpan pool</button>
493
+ <button type="button" id="pool-test">Uji semua</button>
494
+ <button type="button" id="pool-clear">Kosongkan pool</button>
495
+ </div>
496
+ <div class="report" id="pool-report" role="status" aria-live="polite" hidden></div>
497
+ </section>
498
+
499
+ <section aria-labelledby="form-title">
500
+ <h2 id="form-title">Atur proxy</h2>
501
+ <form id="form" novalidate>
502
+ <div class="field">
503
+ <label for="proxy-url">URL proxy</label>
504
+ <input id="proxy-url" name="proxy-url" type="text" inputmode="url" autocomplete="off"
505
+ spellcheck="false" placeholder="http://user:pass@host:8080"
506
+ aria-describedby="url-hint">
507
+ <p class="hint" id="url-hint">Format <code>http://[user:pass@]host:port</code>. Hanya HTTP/HTTPS (tunnel CONNECT). Kosongkan lalu simpan untuk kembali langsung.</p>
508
+ </div>
509
+ <div class="actions">
510
+ <button type="button" class="primary" id="save">Simpan dan pakai</button>
511
+ <button type="button" id="test">Uji koneksi</button>
512
+ <button type="button" id="direct">Matikan proxy</button>
513
+ </div>
514
+ <div class="report" id="report" role="status" aria-live="polite" hidden></div>
515
+ </form>
516
+ </section>
517
+
518
+ <section aria-labelledby="endpoint-title">
519
+ <h2 id="endpoint-title">Endpoint klien</h2>
520
+ <dl>
521
+ <dt>Base URL</dt><dd>http://127.0.0.1:${escapeHtml(port || "20129")}/v1</dd>
522
+ <dt>API key</dt><dd>public</dd>
523
+ <dt>Versi</dt><dd>${escapeHtml(version || "")}</dd>
524
+ <dt>Health</dt><dd><a href="/health">/health</a></dd>
525
+ </dl>
526
+ </section>
527
+
528
+ <footer>
529
+ Proxy berlaku untuk inference, discovery model, sinkronisasi identity, dan cek update. Perubahan langsung dipakai request berikutnya, tanpa restart.
530
+ </footer>
531
+ </main>
532
+ <script>${SCRIPT}</script>
533
+ </body>
534
+ </html>`;
535
+ }
536
+
537
+ module.exports = { renderPanel };