Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
{
"settings.html": "<!doctype html>\n<html lang=\"en\">\n <head>\n <meta charset=\"utf-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n <title>QA original plugin settings</title>\n <style>\n * { box-sizing: border-box; }\n body { margin: 0; padding: 16px; font: 16px/1.5 system-ui, sans-serif; color: var(--text-primary, CanvasText); background: var(--surface, Canvas); }\n main { width: 100%; max-width: 40rem; margin: auto; }\n h1, h2 { font-size: 18px; line-height: 1.4; }\n fieldset { min-width: 0; margin: 16px 0; padding: 12px; border: 1px solid var(--border-default, GrayText); }\n label { display: block; margin: 12px 0; }\n input:not([type=\"checkbox\"]), select, textarea { display: block; width: 100%; margin-top: 4px; padding: 8px; font: inherit; color: inherit; background: var(--surface-elevated, Field); border: 1px solid var(--border-default, GrayText); }\n button { min-height: 44px; max-width: 100%; padding: 8px 12px; margin: 4px 0; font: inherit; white-space: normal; color: inherit; background: var(--surface-elevated, ButtonFace); border: 1px solid var(--border-default, GrayText); }\n output, li { overflow-wrap: anywhere; }\n :focus-visible { outline: 2px solid var(--focus-ring, Highlight); outline-offset: 2px; }\n </style>\n </head>\n <body>\n <main>\n <a href=\"navigation.html\" style=\"display:block;min-height:44px;line-height:44px;color:inherit\">Open document B</a>\n <h1>QA original plugin settings</h1>\n <p>TEST DATA ONLY · original HTML fixture · no file import</p>\n <output id=\"status\" role=\"status\" aria-live=\"polite\">Reading target Host…</output>\n <form id=\"preferences\">\n <fieldset>\n <legend>Ordinary settings on the target Host</legend>\n <label>Display label <input id=\"displayLabel\" name=\"displayLabel\" required maxlength=\"80\"></label>\n <label><input id=\"notifications\" name=\"notifications\" type=\"checkbox\"> Notifications</label>\n <label>Language <select id=\"language\" name=\"language\"><option value=\"en\">English</option><option value=\"zh-CN\">简体中文</option></select></label>\n <button type=\"submit\">Save ordinary settings</button>\n <button id=\"reload\" type=\"button\">Read target again</button>\n </fieldset>\n </form>\n <fieldset>\n <legend>Write-only synthetic secret</legend>\n <output id=\"secretState\">Status unknown</output>\n <label>Test key <input id=\"secret\" type=\"password\" autocomplete=\"off\" placeholder=\"Use an invalid QA value only\"></label>\n <button id=\"saveSecret\" type=\"button\">Save test key to target</button>\n </fieldset>\n <fieldset>\n <legend>OAuth accounts</legend>\n <ul id=\"accounts\"></ul>\n <button id=\"connect\" type=\"button\">Connect a test account</button>\n </fieldset>\n <fieldset>\n <legend>Directory and original channel interaction</legend>\n <button id=\"pickDirectory\" type=\"button\">Choose a directory on the target</button>\n <output id=\"directory\">No directory selected</output>\n <button id=\"echo\" type=\"button\">Send channel probe</button>\n <output id=\"channelState\">No reply received</output>\n </fieldset>\n <form id=\"longForm\">\n <fieldset>\n <legend>Long form: keyboard and scroll</legend>\n <div id=\"longFields\"></div>\n <label>Last field <textarea id=\"lastField\" rows=\"4\" placeholder=\"Keep this draft while opening the keyboard or changing theme\"></textarea></label>\n <button type=\"submit\">Save bottom field</button>\n </fieldset>\n </form>\n </main>\n <script src=\"settings.js\"></script>\n </body>\n</html>\n",
"settings.js": "// Test-only original plugin code: no local persistence, production ID branching, or external fetch.\n(() => {\n const element = (id) => document.getElementById(id);\n const status = (text) => { element('status').textContent = text; };\n const channel = new BroadcastChannel('qa-settings');\n let sequence = 0;\n let pendingDirectory;\n let pendingProbe;\n const request = async (path, method = 'GET', body) => {\n const response = await fetch(path, {\n method,\n ...(body === undefined ? {} : {\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify(body),\n }),\n });\n if (!response.ok) throw new Error('Target request failed: ' + response.status);\n return response.status === 204 ? undefined : response.json();\n };\n const action = (id, run) => {\n element(id).addEventListener('click', async () => {\n element(id).disabled = true;\n try { await run(); } catch { status('Target request failed; read target again before retrying a write.'); }\n finally { element(id).disabled = false; }\n });\n };\n const refreshAccounts = async () => {\n const declarations = await request('/oauth');\n const accounts = declarations.find((entry) => entry.key === 'login')?.accounts ?? [];\n element('accounts').replaceChildren();\n for (const account of accounts) {\n const row = document.createElement('li');\n row.textContent = account.label + (account.isDefault ? ' (default)' : '');\n const choose = document.createElement('button');\n choose.type = 'button';\n choose.textContent = 'Use ' + account.label;\n choose.addEventListener('click', async () => {\n choose.disabled = true;\n try {\n await request('/oauth/login/default', 'POST', { accountId: account.id });\n await refreshAccounts();\n status('Default test account read back from target.');\n } catch { status('Account change not confirmed; read target again.'); }\n finally { choose.disabled = false; }\n });\n row.append(document.createTextNode(' '), choose);\n element('accounts').append(row);\n }\n };\n const readTarget = async () => {\n const preferences = await request('/kv');\n element('displayLabel').value = preferences.displayLabel ?? '';\n element('notifications').checked = preferences.notifications === true;\n element('language').value = preferences.language ?? 'en';\n element('lastField').value = preferences.lastField ?? '';\n const secrets = await request('/secrets');\n element('secretState').textContent = secrets.find((entry) => entry.key === 'key')?.saved\n ? 'Test key saved on target (value is not returned)' : 'No test key saved';\n await refreshAccounts();\n status('Target Host state read.');\n };\n const savePreferences = async (patch) => {\n // /kv replaces an object. Preserve unrelated keys; concurrent-edit semantics remain the plugin's.\n const preferences = { ...await request('/kv'), ...patch };\n await request('/kv', 'PUT', preferences);\n const confirmed = await request('/kv');\n status('Ordinary settings read back: ' + confirmed.displayLabel);\n };\n element('preferences').addEventListener('submit', async (event) => {\n event.preventDefault();\n const submit = element('preferences').querySelector('[type=\"submit\"]');\n if (submit.disabled) return;\n submit.disabled = true;\n try {\n await savePreferences({\n displayLabel: element('displayLabel').value,\n notifications: element('notifications').checked,\n language: element('language').value,\n });\n } catch { status('Save not confirmed; read target again.'); }\n finally { submit.disabled = false; }\n });\n action('reload', readTarget);\n action('saveSecret', async () => {\n try {\n await request('/secrets/key', 'PUT', { value: element('secret').value });\n const secrets = await request('/secrets');\n element('secretState').textContent = secrets.find((entry) => entry.key === 'key')?.saved\n ? 'Test key saved on target (value is not returned)' : 'No test key saved';\n status('Secret status read back from target.');\n } finally { element('secret').value = ''; }\n });\n action('connect', async () => {\n const result = await request('/oauth/login/connect', 'POST', {});\n await refreshAccounts();\n status(result?.ok ? 'Authorization completed on target.' : 'Authorization did not complete.');\n });\n action('pickDirectory', () => {\n pendingDirectory = 'directory-' + ++sequence;\n channel.postMessage({ kind: 'choose-directory', requestId: pendingDirectory });\n element('directory').textContent = 'Waiting for target directory selection…';\n });\n action('echo', () => {\n pendingProbe = 'probe-' + ++sequence;\n channel.postMessage({ kind: 'probe', requestId: pendingProbe });\n element('channelState').textContent = 'Waiting for channel reply…';\n });\n channel.onmessage = ({ data }) => {\n if (data?.kind === 'directory-result' && data.requestId === pendingDirectory) {\n pendingDirectory = undefined;\n element('directory').textContent = data.cancelled ? 'Directory selection cancelled' : data.name;\n }\n if (data?.kind === 'probe-result' && data.requestId === pendingProbe) {\n pendingProbe = undefined;\n element('channelState').textContent = data.targetLabel;\n }\n };\n for (let index = 1; index <= 16; index++) {\n const label = document.createElement('label');\n label.textContent = 'Unsaved scroll probe ' + index;\n const input = document.createElement('input');\n input.id = 'scrollProbe' + index;\n input.placeholder = 'Local page draft only';\n label.append(input);\n element('longFields').append(label);\n }\n element('longForm').addEventListener('submit', async (event) => {\n event.preventDefault();\n const submit = element('longForm').querySelector('[type=\"submit\"]');\n if (submit.disabled) return;\n submit.disabled = true;\n try { await savePreferences({ lastField: element('lastField').value }); }\n catch { status('Bottom field save not confirmed; read target again.'); }\n finally { submit.disabled = false; }\n });\n window.addEventListener('pagehide', () => {\n pendingDirectory = undefined;\n pendingProbe = undefined;\n element('secret').value = '';\n channel.close();\n }, { once: true });\n readTarget().catch(() => status('Cannot read target Host. No fallback data was substituted.'));\n})();\n",
"navigation.html": "<!doctype html><html><head><meta charset=\"utf-8\"><meta name=\"viewport\" content=\"width=device-width,initial-scale=1\"><title>QA document B</title><style>body{margin:0;padding:16px;font:16px/1.5 system-ui;color:var(--text-primary,CanvasText);background:var(--surface,Canvas)}a{display:block;min-height:44px;line-height:44px;color:inherit}</style></head><body><h1>Document B</h1><p id=\"result\">Reading document identity</p><a href=\"settings.html\">Return to document A</a><script src=\"navigation.js\"></script></body></html>",
"navigation.js": "fetch('/kv').then(response => response.json()).then(value => { document.getElementById('result').textContent = 'Host document epoch: ' + value.documentEpoch; }).catch(() => { document.getElementById('result').textContent = 'Document read failed'; });"
}