Add edge workers commands#2918
Open
alexcriss wants to merge 23 commits into
Open
Conversation
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Also extracts API_HOST/API_URL/PRODUCTION_API_HOST into a leaf constants module and lazy-requires the rechallenge link inside API() to break a circular-dependency cycle that caused Jest mocks to misfire in the rechallenge test suite.
Implements `vip defensive-mode configure` with full flag validation, interactive prompting for missing required flags, and non-interactive hard-error mode.
…e guards, telemetry order, teardown race) - configure: log current effective config and proposed input before mutating (Fix 1) - enable/disable: add --non-interactive option and guard; error on production mutation attempted non-interactively without --skip-confirmation (Fix 2) - flow: add clientType=cli to rechallenge_required event (Fix 3) - flow: fire rechallenge_verified before rechallenge_exchanged to match spec order (Fix 4) - link: split innerSub into firstSub/retrySub to eliminate teardown race during async gap (Fix 5) - enable/disable/configure: use console.error for error-path chalk.red messages (Fix 6) - token-cache: document single-blob keychain strategy (Fix 7) - tests: assert proposed config logged in configure; add non-interactive-production exit tests for enable/disable; assert rechallenge_verified fires before rechallenge_exchanged Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ad validation, dedupe commands) Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…bin loader, sleep, flag parsing) - Render current/proposed defensive-mode config as a table instead of raw JSON, and drop the JSON blob from the production confirm prompt - Clear the elevated-token cache when `vip login` replaces the stored token, so cached elevation cannot carry across user identities - Register the four vip-defensive-mode* bins in internal-bin-loader.js - Replace the hand-rolled abortable sleep in rechallenge flow with setTimeout from node:timers/promises - Reject boolean/blank values in parsePositiveInt so bare flags like `--connection-threshold-absolute` error instead of coercing to 1 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The loop polls session status sequentially by design; each iteration must finish before the next starts. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…e client trunk replaced node-fetch with undici (#2837), so in the PR merge ref the node-fetch types no longer resolve and type-aware lint flags every member access as unsafe. Derive the response type from http() instead, which tracks whichever fetch implementation the merged tree uses. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
|
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new vip edge-workers command suite to scaffold, compile, validate, and deploy WASM-based edge workers on VIP, including an AssemblyScript toolchain and GraphQL API integration.
Changes:
- Introduces an
edge-workerslibrary (project discovery, manifests, location parsing) plus an AssemblyScript toolchain for scaffolding and local.wasmbuilds. - Adds GraphQL API helpers for listing/getting/validating/creating/updating/enabling/disabling/deleting edge workers, and wires new CLI subcommands.
- Adds initial Jest coverage for the new lib modules and several bin commands (
deploy,validate,list).
Reviewed changes
Copilot reviewed 14 out of 30 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/lib/edge-workers/types.ts | Defines shared edge-worker domain types (manifests, locations, API shapes). |
| src/lib/edge-workers/toolchains/index.ts | Introduces toolchain registry + getToolchain() lookup. |
| src/lib/edge-workers/toolchains/assemblyscript/templates.ts | Adds scaffolded AssemblyScript project/worker template contents. |
| src/lib/edge-workers/toolchains/assemblyscript/index.ts | Implements AssemblyScript scaffold + compiler invocation (asc) to produce .wasm. |
| src/lib/edge-workers/toolchains/assemblyscript/constants.ts | Centralizes AssemblyScript toolchain constants (SDK/version/paths). |
| src/lib/edge-workers/project.ts | Adds project resolution + descriptor/manifest IO + worker discovery. |
| src/lib/edge-workers/location.ts | Adds CLI parsing for --location <op>:<value>. |
| src/lib/edge-workers/index.ts | Adds build/read helpers for artifacts and worker source. |
| src/lib/api/edge-workers.ts | Adds GraphQL query/mutation wrappers for edge workers. |
| src/lib/api.ts | Adds extra debug logging for GraphQL error details / partial data. |
| src/bin/vip.js | Registers the new top-level edge-workers command. |
| src/bin/vip-edge-workers.js | Adds the vip edge-workers subcommand dispatcher. |
| src/bin/vip-edge-workers-validate.js | Adds vip edge-workers validate implementation. |
| src/bin/vip-edge-workers-new.js | Adds vip edge-workers new implementation. |
| src/bin/vip-edge-workers-list.js | Adds vip edge-workers list implementation with formatter output. |
| src/bin/vip-edge-workers-init.js | Adds vip edge-workers init implementation (project scaffolding). |
| src/bin/vip-edge-workers-get.js | Adds vip edge-workers get implementation (optionally prints source). |
| src/bin/vip-edge-workers-enable.js | Adds vip edge-workers enable implementation. |
| src/bin/vip-edge-workers-disable.js | Adds vip edge-workers disable implementation. |
| src/bin/vip-edge-workers-deploy.js | Adds vip edge-workers deploy implementation (validate + create/update). |
| src/bin/vip-edge-workers-delete.js | Adds vip edge-workers delete implementation with confirmation gate. |
| src/bin/vip-edge-workers-build.js | Adds vip edge-workers build implementation for local compilation. |
| package.json | Registers new published vip-edge-workers-* bin entrypoints. |
| npm-shrinkwrap.json | Updates shrinkwrap bin map to include new vip-edge-workers-* entrypoints. |
| tests/lib/edge-workers/toolchains.js | Adds tests for toolchain registry + AssemblyScript scaffolding behavior. |
| tests/lib/edge-workers/project.js | Adds tests for project resolution and worker discovery helpers. |
| tests/lib/edge-workers/location.js | Adds tests for --location parsing and validation. |
| tests/bin/vip-edge-workers-validate.js | Adds CLI-wrapper tests for validate behavior. |
| tests/bin/vip-edge-workers-list.js | Adds CLI-wrapper tests for list mapping and error handling. |
| tests/bin/vip-edge-workers-deploy.js | Adds CLI-wrapper tests for deploy create/update/validation behaviors. |
Files not reviewed (1)
- npm-shrinkwrap.json: Generated file
|
|
||
| import gql from 'graphql-tag'; | ||
|
|
||
| import API from '../../lib/api'; |
Comment on lines
+59
to
+66
| export function readWorkerSource( worker: DiscoveredWorker ): string | undefined { | ||
| const entry = path.resolve( worker.dir, worker.manifest.entry ); | ||
| try { | ||
| return fs.readFileSync( entry, 'utf8' ); | ||
| } catch { | ||
| return undefined; | ||
| } | ||
| } |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.



Description
Adds a vip edge-workers command suite for creating and managing edge workers on VIP.
The commands are
Pull request checklist
New release checklist
Steps to Test
Build the CLI from this branch and alias it:
npm run clean && npm run build
alias vipdev="node $(pwd)/dist/bin/vip.js"
Scaffold a project and create test-worker:
cd /tmp/ew-test # any empty dir
vipdev edge-workers init
cd edge-workers
npm install
vipdev edge-workers new test-worker
(optional) scope it: vipdev edge-workers new test-worker --location starts_with:/api/
Build, validate, and deploy it (replace /):
vipdev edge-workers build test-worker
vipdev edge-workers validate @. edge-workers validate test-worker # needs the API endpoint
vipdev @. edge-workers deploy test-worker # add --skip-validate until the API ships
Verify and clean up:
vipdev @. edge-workers list
vipdev @. edge-workers get test-worker
vipdev @. edge-workers disable test-worker
vipdev @. edge-workers delete test-worker