Skip to content

Add edge workers commands#2918

Open
alexcriss wants to merge 23 commits into
trunkfrom
add/edge-workers-commands
Open

Add edge workers commands#2918
alexcriss wants to merge 23 commits into
trunkfrom
add/edge-workers-commands

Conversation

@alexcriss

@alexcriss alexcriss commented Jun 25, 2026

Copy link
Copy Markdown

Description

Adds a vip edge-workers command suite for creating and managing edge workers on VIP.

The commands are

  • init — scaffold a project using the AsseblyScript SDK @automattic/vip-edge-workers-sdk@^0.2.0)
  • new — add a worker; --location : scopes it to matching request paths
  • build [name] | --all — compile to .wasm locally
  • validate | --all — server-side dry-run against an env (no upload)
  • deploy | --all — validate + upload (create or update by name)
  • list / get — inspect deployed workers
  • enable / disable / delete — manage deployed workers

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

rinatkhaziev and others added 22 commits June 4, 2026 14:00
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>
@github-actions

Copy link
Copy Markdown
Contributor

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@rinatkhaziev rinatkhaziev requested a review from Copilot July 6, 2026 21:17
@sonarqubecloud

sonarqubecloud Bot commented Jul 6, 2026

Copy link
Copy Markdown

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-workers library (project discovery, manifests, location parsing) plus an AssemblyScript toolchain for scaffolding and local .wasm builds.
  • 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;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants