Repository navigation
feat: run CLI commands in a browser #90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
86dc3de
feat: run CLI commands in a browser
purpshell 4913847
fix: queue browser commands and format the generated registry
purpshell 103b3cf
fix: browser runner review findings and the zod advisory
purpshell dc78083
fix: browser runner handles late aborts; emitter matches Node
purpshell ae82718
fix: qualify browser CLI on current main
purpshell 17e601d
fix: reject local agent setup before browser loading
purpshell 664166e
fix: clean browser verification metadata without home storage
purpshell File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,3 +6,4 @@ coverage/ | |
| .DS_Store | ||
|
|
||
| .release/ | ||
| dist-browser/ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| # CLI #90 integration after accepted CLI #85 | ||
|
|
||
| Collaborator: purpshell. Agent: gpt-6.1-sol, xhigh, T3 Code. Thread: 7793bd59-7f5e-4ad0-bcf2-8da9ea202931. Selected hand-authored evidence is recorded here with a full-transcript capture gap; no credentials, customer content or hidden reasoning is included. | ||
|
|
||
| ## Source and preservation | ||
|
|
||
| Release accepted CLI85 main 637f9991342279133bb000a7db01574bcffaf174, source 541f9a01. CLI90 old 8b42b62cc18391567da0d786beff34c529b73d3c on base a9a19cd68eecf7f33eae495665c1f389b6906a5e was actually rebased with --rebase-merges onto live main 637f9991342279133bb000a7db01574bcffaf174. Rebased source: ae827188d429b1fc15a778107e39036a50d4c81a. The four feature commits and prior checkpoint retain their authored history/dates; original patches, bundle, index, conflict stages and range-diff are retained under backup/rebase-20261028-cli90-8b42b62c-after-cli85. JSON fields were reconciled semantically; the fixed Zod 4.6.7 floor, current graph and both script families remain. Installed dependencies match lock version/resolved/integrity, with foreign optional platforms explicitly excluded. No install ran. | ||
|
|
||
| ## Verification | ||
|
|
||
| The pre-load tripwire failed before the guard and passed after shared unsupported metadata was applied. Loader/module, filesystem/configuration and installer tripwires prevent local effects. An independent artifact check failed while the old producer still bundled installer modules, then passed when the genuine producer used the same literal typed policy. Unsupported command IDs stay in the inventory with rejecting loaders. No generated inventory was hand-edited or old count hard-coded. The emitted artifact refuses setup before environment/fetch access, excludes installer/native module inputs, and preserves the real text-send POST/path/body/output using synthetic fetch only. | ||
|
|
||
| Fresh serial Node 24: 1164 tests in 118 files passed; format/lint/types/build/reference/metadata/browser artifact/pack/audit and installed Actionlint on both unchanged workflows passed. The targeted artifact build/recorder runs again after commit because its embedded Git identity changes. Exact metrics, artifact input graph and final source proof are retained privately and linked from the PR. Natural rewritten-head hosted jobs and review remain required; old-head green is not reused. | ||
|
|
||
| ## Impact and gates | ||
|
|
||
| CLI source/producers and its README change. Accepted CLI85 process/helper/consent/native fixture and both workflows remain byte-identical. API and all six SDK wire/version/package pins are unchanged; the existing opaque-key SDK limitation remains. Docs #888 keeps its older source-bound bundle until its sole Opus owner accepts a new one. No Admin/MCP, runner, Temporal, audit, Inspector, Console, Connect, Help Center, marketing, ZK custody, QuickLink or browser pairing tunnel runtime changed. No UI/browser action, real installer, network API, registry, provider, migration or deployment effect occurred. Release owns merge; staging/availability gates remain and trackers were not synchronized. |
11 changes: 11 additions & 0 deletions
11
internal/agent-sessions/cli90-current-main-rebase-20261028.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| # CLI90 current-main rebase | ||
|
|
||
| Collaborator: purpshell. Agent: gpt-6.1-sol, xhigh, through T3 Code. Thread: 7793bd59-7f5e-4ad0-bcf2-8da9ea202931. This is a hand-authored selected checkpoint with a full-transcript capture gap. No credentials, customer content or hidden reasoning is included. | ||
|
|
||
| The user authorized guarded rebases of existing PRs. Old fde26bbee054101b20f71f9525d75acb4719a5c0 on 58e91a18d1a4afc108eb3119db0830340bb2a926 was actually rebased with --rebase-merges onto live main a9a19cd68eecf7f33eae495665c1f389b6906a5e. Rebased source: 826b87f9751f0ae6c7896b6744fabde0af2ab064. Durable backup: backup/rebase-20261028-cli90-fde26bbe. Old patch, bundle, index, author records, range-diff and each conflict stage are retained privately. Only divergent root Zod constraint fields were selected semantically at the authored 4.6.7 floor; current main and authored lock graph values otherwise merge field by field. No install or dependency download ran. | ||
|
|
||
| The browser registry was regenerated from actual command files. Agent setup is not present in this accepted main source. CLI85 must land before the next combined registry refresh; this head does not claim its unpublished parent is accepted. | ||
|
|
||
| Fresh serial Node 24 checks passed: full CLI suite, formatting, lint, typecheck, Node build, browser build, release metadata, package dry-run, production audit and an emitted browser module recording the real text-send command against a synthetic in-memory transport. No request reached a network API. New hosted checks and review remain required; old-head evidence does not qualify this head. A real browser, native agent installers and package publication were not checked in this task. | ||
|
|
||
| Impact: CLI runner/source and browser registry are qualified against the same accepted main revision. SDK package/API contract pins are unchanged; opaque-key support still depends on the pinned SDK, and client-token acceptance here is synthetic. Docs888 retains its existing source-bound browser bundle until its sole Opus owner accepts a new binding. API/Admin authority, runners, Temporal, audit, Inspector, Console, Connect, Help Center and marketing runtime are unchanged by this CLI-only delta. ZK custody, QuickLink and the browser pairing tunnel are unaffected: no credential-exchange or pairing code changed, and the recorder performs only a synthetic message request. Feature/registry/environment availability remains gated, staging deferred, Release owns merge. Roadmap records were not synchronized. |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,110 @@ | ||
| // Builds dist-browser/: the CLI's commands as a browser module (src/browser/index.ts). | ||
| // Node built-ins and local-only packages resolve to src/browser/stubs; each command loads on demand. | ||
| import console from 'node:console' | ||
| import process from 'node:process' | ||
| import {URL, fileURLToPath} from 'node:url' | ||
| import {execFileSync} from 'node:child_process' | ||
| import {readFileSync, writeFileSync, rmSync} from 'node:fs' | ||
| import {builtinModules} from 'node:module' | ||
| import {build} from 'esbuild' | ||
|
|
||
| const pkg = JSON.parse( | ||
| readFileSync(new URL('../package.json', import.meta.url), 'utf8'), | ||
| ) | ||
| const stub = (name) => | ||
| fileURLToPath(new URL(`../src/browser/stubs/${name}.ts`, import.meta.url)) | ||
| const NODE = { | ||
| fs: stub('fs'), | ||
| 'fs/promises': stub('fs-promises'), | ||
| path: stub('path'), | ||
| 'path/posix': stub('path'), | ||
| os: stub('os'), | ||
| crypto: stub('crypto'), | ||
| events: stub('events'), | ||
| buffer: stub('buffer'), | ||
| child_process: stub('unavailable'), | ||
| net: stub('unavailable'), | ||
| dns: stub('unavailable'), | ||
| 'dns/promises': stub('unavailable'), | ||
| http: stub('unavailable'), | ||
| https: stub('unavailable'), | ||
| readline: stub('unavailable'), | ||
| 'readline/promises': stub('unavailable'), | ||
| } | ||
| const PACKAGES = new Set([ | ||
| '@napi-rs/keyring', | ||
| '@modelcontextprotocol/server', | ||
| '@modelcontextprotocol/server/stdio', | ||
| 'jq-wasm', | ||
| '@polymorfa/sdk/node', | ||
| ]) | ||
| const escape = (value) => value.replace(/[.*+?^${}()|[\]\\/]/g, '\\$&') | ||
| const builtins = new RegExp(`^(${builtinModules.map(escape).join('|')})$`) | ||
|
|
||
| const stubs = { | ||
| name: 'browser-stubs', | ||
| setup(builder) { | ||
| builder.onResolve({filter: /^node:/}, (args) => ({ | ||
| path: NODE[args.path.slice(5)] ?? stub('misc'), | ||
| })) | ||
| builder.onResolve({filter: builtins}, (args) => ({ | ||
| path: NODE[args.path] ?? stub('misc'), | ||
| })) | ||
| builder.onResolve( | ||
| { | ||
| filter: | ||
| /^(@napi-rs\/keyring|@modelcontextprotocol\/server(\/stdio)?|jq-wasm|@polymorfa\/sdk\/node)$/, | ||
| }, | ||
| (args) => | ||
| PACKAGES.has(args.path) ? {path: stub('packages')} : undefined, | ||
| ) | ||
| }, | ||
| } | ||
|
|
||
| const commit = execFileSync('git', ['rev-parse', 'HEAD'], { | ||
| encoding: 'utf8', | ||
| }).trim() | ||
| rmSync(new URL('../dist-browser', import.meta.url), { | ||
| recursive: true, | ||
| force: true, | ||
| }) | ||
| const result = await build({ | ||
| entryPoints: ['src/browser/index.ts'], | ||
| bundle: true, | ||
| splitting: true, | ||
| format: 'esm', | ||
| platform: 'browser', | ||
| target: 'es2022', | ||
| outdir: 'dist-browser', | ||
| entryNames: 'polymorfa-cli', | ||
| chunkNames: 'chunks/[name]-[hash]', | ||
| inject: [stub('process'), stub('buffer-global')], | ||
| define: { | ||
| __CLI_VERSION__: JSON.stringify(pkg.version), | ||
| __CLI_COMMIT__: JSON.stringify(commit), | ||
| global: 'globalThis', | ||
| }, | ||
| plugins: [stubs], | ||
| mainFields: ['browser', 'module', 'main'], | ||
| conditions: ['browser', 'import', 'default'], | ||
| minify: process.env.BROWSER_MINIFY !== '0', | ||
| legalComments: 'linked', | ||
| metafile: true, | ||
| logLevel: 'warning', | ||
| }) | ||
| if (process.env.BROWSER_METAFILE) | ||
| writeFileSync( | ||
| process.env.BROWSER_METAFILE, | ||
| JSON.stringify(result.metafile, null, 2) + '\n', | ||
| ) | ||
| const bytes = Object.values(result.metafile.outputs).reduce( | ||
| (sum, output) => sum + output.bytes, | ||
| 0, | ||
| ) | ||
| writeFileSync( | ||
| new URL('../dist-browser/manifest.json', import.meta.url), | ||
| `${JSON.stringify({package: pkg.name, version: pkg.version, commit, entry: 'polymorfa-cli.js', files: Object.keys(result.metafile.outputs).length, bytes}, null, 2)}\n`, | ||
| ) | ||
| console.log( | ||
| `dist-browser: ${Object.keys(result.metafile.outputs).length} files, ${(bytes / 1024 / 1024).toFixed(2)} MiB, commit ${commit.slice(0, 10)}`, | ||
| ) | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.