diff --git a/.changeset/next-bootstrap-literal-env.md b/.changeset/next-bootstrap-literal-env.md new file mode 100644 index 0000000..c4cd9ff --- /dev/null +++ b/.changeset/next-bootstrap-literal-env.md @@ -0,0 +1,9 @@ +--- +'@agent-devtools/next': patch +--- + +fix(next): read the pairing-token env through literal `process.env` so the App Router client bundle inlines it + +The bootstrap read the enabled flag, base URL, and pairing token through a dynamic `globalThis.process.env[key]` lookup. Bundlers can only statically replace **literal** `process.env.` member expressions, so that indirection was never substituted — and the Next App Router client bundle has no runtime `process` object, so the lookup resolved to `undefined` and the widget silently never mounted (verified against Next 16 + Turbopack: `typeof process === 'undefined'` in the browser). + +`readEnv` now reads each value as a literal `process.env.` expression (mirroring the `process.env.NODE_ENV` literal the same module already relies on), so Next's `env`-config inlining substitutes the dev values at build time and the widget mounts. The production dev-only guard is unchanged. diff --git a/.changeset/pre.json b/.changeset/pre.json new file mode 100644 index 0000000..5273bd0 --- /dev/null +++ b/.changeset/pre.json @@ -0,0 +1,37 @@ +{ + "mode": "pre", + "tag": "beta", + "initialVersions": { + "@agent-devtools/docs": "0.0.6", + "@agent-devtools/example-angular-vite": "0.0.0", + "@agent-devtools/example-html": "0.0.0", + "@agent-devtools/example-next": "0.0.0", + "@agent-devtools/example-next-pages": "0.0.0", + "@agent-devtools/example-nuxt": "0.0.0", + "@agent-devtools/example-nuxt2": "0.0.0", + "@agent-devtools/example-react-vite": "0.0.0", + "@agent-devtools/example-svelte-vite": "0.0.0", + "@agent-devtools/example-sveltekit": "0.0.0", + "@agent-devtools/example-vue-vite": "0.0.0", + "@agent-devtools/example-vue2-vite": "0.0.0", + "@agent-devtools/angular": "1.3.0", + "@agent-devtools/core": "1.3.0", + "@agent-devtools/e2e": "0.0.0", + "@agent-devtools/harness-core": "1.3.0", + "@agent-devtools/html": "1.3.0", + "@agent-devtools/next": "1.3.0", + "@agent-devtools/next-pages": "1.3.0", + "@agent-devtools/nuxt": "1.3.0", + "@agent-devtools/nuxt2": "1.3.0", + "@agent-devtools/react": "1.3.0", + "@agent-devtools/svelte": "1.3.0", + "@agent-devtools/sveltekit": "1.3.0", + "@agent-devtools/vite": "1.3.0", + "@agent-devtools/vue": "1.3.0", + "@agent-devtools/vue2": "1.3.0", + "@agent-devtools/widget-core": "1.3.0" + }, + "changesets": [ + "next-bootstrap-literal-env" + ] +} diff --git a/packages/angular/CHANGELOG.md b/packages/angular/CHANGELOG.md index 56a9b22..b6b6272 100644 --- a/packages/angular/CHANGELOG.md +++ b/packages/angular/CHANGELOG.md @@ -1,5 +1,13 @@ # @agent-devtools/angular +## 1.3.1-beta.0 + +### Patch Changes + +- Updated dependencies []: + - @agent-devtools/core@1.3.1-beta.0 + - @agent-devtools/widget-core@1.3.1-beta.0 + ## 1.3.0 ### Patch Changes diff --git a/packages/angular/package.json b/packages/angular/package.json index 92a5969..db0d7ad 100644 --- a/packages/angular/package.json +++ b/packages/angular/package.json @@ -1,6 +1,6 @@ { "name": "@agent-devtools/angular", - "version": "1.3.0", + "version": "1.3.1-beta.0", "description": "Angular adapter for agent-devtools — Ivy component walker + DOM picker + closed Shadow DOM widget", "keywords": [ "agent-devtools", diff --git a/packages/core/CHANGELOG.md b/packages/core/CHANGELOG.md index 710234e..efc2bef 100644 --- a/packages/core/CHANGELOG.md +++ b/packages/core/CHANGELOG.md @@ -1,5 +1,7 @@ # Changelog +## 1.3.1-beta.0 + ## 1.3.0 ### Minor Changes diff --git a/packages/core/package.json b/packages/core/package.json index 5c62e40..bef7be7 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "@agent-devtools/core", - "version": "1.3.0", + "version": "1.3.1-beta.0", "description": "Framework-agnostic core for agent-devtools — server, agent engine, widget shell", "keywords": [ "agent-devtools", diff --git a/packages/harness-core/CHANGELOG.md b/packages/harness-core/CHANGELOG.md index 6e56691..4cbf168 100644 --- a/packages/harness-core/CHANGELOG.md +++ b/packages/harness-core/CHANGELOG.md @@ -1,5 +1,7 @@ # Changelog +## 1.3.1-beta.0 + ## 1.3.0 ## 1.3.0-beta.0 diff --git a/packages/harness-core/package.json b/packages/harness-core/package.json index 818d638..dc6141b 100644 --- a/packages/harness-core/package.json +++ b/packages/harness-core/package.json @@ -1,6 +1,6 @@ { "name": "@agent-devtools/harness-core", - "version": "1.3.0", + "version": "1.3.1-beta.0", "description": "Generic agent harness — domain-agnostic loop strategies + LLM provider abstraction. Source for both @agent-devtools and external SaaS consumers.", "license": "MIT", "type": "module", diff --git a/packages/html/CHANGELOG.md b/packages/html/CHANGELOG.md index 1aed629..8f9cd4a 100644 --- a/packages/html/CHANGELOG.md +++ b/packages/html/CHANGELOG.md @@ -1,5 +1,13 @@ # @agent-devtools/html +## 1.3.1-beta.0 + +### Patch Changes + +- Updated dependencies []: + - @agent-devtools/vite@1.3.1-beta.0 + - @agent-devtools/widget-core@1.3.1-beta.0 + ## 1.3.0 ### Patch Changes diff --git a/packages/html/package.json b/packages/html/package.json index 2031645..58157ec 100644 --- a/packages/html/package.json +++ b/packages/html/package.json @@ -1,6 +1,6 @@ { "name": "@agent-devtools/html", - "version": "1.3.0", + "version": "1.3.1-beta.0", "description": "npx runner for agent-devtools — serve a plain HTML folder with the dev-only widget injected, no framework, no config", "keywords": [ "agent-devtools", diff --git a/packages/next-pages/CHANGELOG.md b/packages/next-pages/CHANGELOG.md index 5540c23..630e280 100644 --- a/packages/next-pages/CHANGELOG.md +++ b/packages/next-pages/CHANGELOG.md @@ -1,5 +1,13 @@ # @agent-devtools/next-pages +## 1.3.1-beta.0 + +### Patch Changes + +- Updated dependencies []: + - @agent-devtools/core@1.3.1-beta.0 + - @agent-devtools/react@1.3.1-beta.0 + ## 1.3.0 ### Patch Changes diff --git a/packages/next-pages/package.json b/packages/next-pages/package.json index 2f321ce..f8649e4 100644 --- a/packages/next-pages/package.json +++ b/packages/next-pages/package.json @@ -1,6 +1,6 @@ { "name": "@agent-devtools/next-pages", - "version": "1.3.0", + "version": "1.3.1-beta.0", "description": "Next.js Pages Router adapter for agent-devtools — wraps the React widget for legacy pages/_app.tsx hosts", "keywords": [ "agent-devtools", diff --git a/packages/next/CHANGELOG.md b/packages/next/CHANGELOG.md index ec9ca58..5434d95 100644 --- a/packages/next/CHANGELOG.md +++ b/packages/next/CHANGELOG.md @@ -1,5 +1,19 @@ # @agent-devtools/next +## 1.3.1-beta.0 + +### Patch Changes + +- [#16](https://github.com/Seungwoo321/agent-devtools/pull/16) [`007b6c3`](https://github.com/Seungwoo321/agent-devtools/commit/007b6c31b54468d64493da8f3d7f5de73d6aa048) Thanks [@Seungwoo321](https://github.com/Seungwoo321)! - fix(next): read the pairing-token env through literal `process.env` so the App Router client bundle inlines it + + The bootstrap read the enabled flag, base URL, and pairing token through a dynamic `globalThis.process.env[key]` lookup. Bundlers can only statically replace **literal** `process.env.` member expressions, so that indirection was never substituted — and the Next App Router client bundle has no runtime `process` object, so the lookup resolved to `undefined` and the widget silently never mounted (verified against Next 16 + Turbopack: `typeof process === 'undefined'` in the browser). + + `readEnv` now reads each value as a literal `process.env.` expression (mirroring the `process.env.NODE_ENV` literal the same module already relies on), so Next's `env`-config inlining substitutes the dev values at build time and the widget mounts. The production dev-only guard is unchanged. + +- Updated dependencies []: + - @agent-devtools/core@1.3.1-beta.0 + - @agent-devtools/react@1.3.1-beta.0 + ## 1.3.0 ### Patch Changes diff --git a/packages/next/package.json b/packages/next/package.json index 5adfced..f28719f 100644 --- a/packages/next/package.json +++ b/packages/next/package.json @@ -1,6 +1,6 @@ { "name": "@agent-devtools/next", - "version": "1.3.0", + "version": "1.3.1-beta.0", "description": "Next.js 15 adapter for agent-devtools — re-exports the React widget + adds App / Pages router dev-only injection", "keywords": [ "agent-devtools", diff --git a/packages/next/src/bootstrap.test.ts b/packages/next/src/bootstrap.test.ts index 7220aac..60c9eb1 100644 --- a/packages/next/src/bootstrap.test.ts +++ b/packages/next/src/bootstrap.test.ts @@ -2,10 +2,12 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; const mountSpy = vi.fn(); const transportSpy = vi.fn((args: unknown) => ({ kind: 'transport', args })); +const commandsFetcherSpy = vi.fn((args: unknown) => ({ kind: 'commands', args })); vi.mock('@agent-devtools/react', () => ({ mountAgentDevtools: (options: unknown) => mountSpy(options), createDefaultTransport: (args: unknown) => transportSpy(args), + createAgentCommandsFetcher: (args: unknown) => commandsFetcherSpy(args), })); describe('bootstrapAgentDevtools', () => { diff --git a/packages/next/src/bootstrap.ts b/packages/next/src/bootstrap.ts index 29b1e5a..7c3e00b 100644 --- a/packages/next/src/bootstrap.ts +++ b/packages/next/src/bootstrap.ts @@ -60,16 +60,19 @@ export function bootstrapAgentDevtools(options: AgentDevtoolsBootstrapOptions = } function readEnv(): { enabled?: string; baseUrl?: string; pairingToken?: string } { - const proc = - typeof globalThis !== 'undefined' - ? (globalThis as { process?: { env?: Record } }).process - : undefined; - const env = proc?.env; - if (!env) return {}; + // Read each value as a LITERAL `process.env.` expression so the bundler + // substitutes it at compile time (Next's `env`-config inlining via webpack + // DefinePlugin / Turbopack). The App Router client bundle has no runtime + // `process` object, so a dynamic `globalThis.process.env[key]` lookup resolves + // to undefined and the widget never mounts — literal member access is the only + // form the bundler can statically replace. (Mirrors the `process.env.NODE_ENV` + // literal already relied on in bootstrapAgentDevtools above.) const result: { enabled?: string; baseUrl?: string; pairingToken?: string } = {}; - if (env.AGENT_DEVTOOLS_NEXT_ENABLED) result.enabled = env.AGENT_DEVTOOLS_NEXT_ENABLED; - if (env.AGENT_DEVTOOLS_NEXT_BASE_URL) result.baseUrl = env.AGENT_DEVTOOLS_NEXT_BASE_URL; - if (env.AGENT_DEVTOOLS_NEXT_PAIRING_TOKEN) - result.pairingToken = env.AGENT_DEVTOOLS_NEXT_PAIRING_TOKEN; + if (process.env.AGENT_DEVTOOLS_NEXT_ENABLED) + result.enabled = process.env.AGENT_DEVTOOLS_NEXT_ENABLED; + if (process.env.AGENT_DEVTOOLS_NEXT_BASE_URL) + result.baseUrl = process.env.AGENT_DEVTOOLS_NEXT_BASE_URL; + if (process.env.AGENT_DEVTOOLS_NEXT_PAIRING_TOKEN) + result.pairingToken = process.env.AGENT_DEVTOOLS_NEXT_PAIRING_TOKEN; return result; } diff --git a/packages/nuxt/CHANGELOG.md b/packages/nuxt/CHANGELOG.md index 76db6ac..12a8a40 100644 --- a/packages/nuxt/CHANGELOG.md +++ b/packages/nuxt/CHANGELOG.md @@ -1,5 +1,14 @@ # @agent-devtools/nuxt +## 1.3.1-beta.0 + +### Patch Changes + +- Updated dependencies []: + - @agent-devtools/core@1.3.1-beta.0 + - @agent-devtools/vue@1.3.1-beta.0 + - @agent-devtools/widget-core@1.3.1-beta.0 + ## 1.3.0 ### Patch Changes diff --git a/packages/nuxt/package.json b/packages/nuxt/package.json index e67bc70..0c570c8 100644 --- a/packages/nuxt/package.json +++ b/packages/nuxt/package.json @@ -1,6 +1,6 @@ { "name": "@agent-devtools/nuxt", - "version": "1.3.0", + "version": "1.3.1-beta.0", "description": "Nuxt 3 module for agent-devtools — re-exports the Vue widget + adds dev-only injection through defineNuxtModule", "keywords": [ "agent-devtools", diff --git a/packages/nuxt2/CHANGELOG.md b/packages/nuxt2/CHANGELOG.md index e7a0f87..3b50d9d 100644 --- a/packages/nuxt2/CHANGELOG.md +++ b/packages/nuxt2/CHANGELOG.md @@ -1,5 +1,14 @@ # @agent-devtools/nuxt2 +## 1.3.1-beta.0 + +### Patch Changes + +- Updated dependencies []: + - @agent-devtools/core@1.3.1-beta.0 + - @agent-devtools/vue2@1.3.1-beta.0 + - @agent-devtools/widget-core@1.3.1-beta.0 + ## 1.3.0 ### Patch Changes diff --git a/packages/nuxt2/package.json b/packages/nuxt2/package.json index 66e2090..565d1da 100644 --- a/packages/nuxt2/package.json +++ b/packages/nuxt2/package.json @@ -1,6 +1,6 @@ { "name": "@agent-devtools/nuxt2", - "version": "1.3.0", + "version": "1.3.1-beta.0", "description": "Nuxt 2 module for agent-devtools — re-exports the Vue 2 widget + adds dev-only injection through the Nuxt 2 module API", "keywords": [ "agent-devtools", diff --git a/packages/react/CHANGELOG.md b/packages/react/CHANGELOG.md index ef00c4f..22f8397 100644 --- a/packages/react/CHANGELOG.md +++ b/packages/react/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## 1.3.1-beta.0 + +### Patch Changes + +- Updated dependencies []: + - @agent-devtools/core@1.3.1-beta.0 + - @agent-devtools/widget-core@1.3.1-beta.0 + ## 1.3.0 ### Patch Changes diff --git a/packages/react/package.json b/packages/react/package.json index 13c2095..263a68b 100644 --- a/packages/react/package.json +++ b/packages/react/package.json @@ -1,6 +1,6 @@ { "name": "@agent-devtools/react", - "version": "1.3.0", + "version": "1.3.1-beta.0", "description": "React 19 adapter for agent-devtools — fiber walker + DOM picker + closed Shadow DOM widget", "keywords": [ "agent-devtools", diff --git a/packages/svelte/CHANGELOG.md b/packages/svelte/CHANGELOG.md index 3ce2afc..c714656 100644 --- a/packages/svelte/CHANGELOG.md +++ b/packages/svelte/CHANGELOG.md @@ -1,5 +1,13 @@ # @agent-devtools/svelte +## 1.3.1-beta.0 + +### Patch Changes + +- Updated dependencies []: + - @agent-devtools/core@1.3.1-beta.0 + - @agent-devtools/widget-core@1.3.1-beta.0 + ## 1.3.0 ### Patch Changes diff --git a/packages/svelte/package.json b/packages/svelte/package.json index 557d169..243eb98 100644 --- a/packages/svelte/package.json +++ b/packages/svelte/package.json @@ -1,6 +1,6 @@ { "name": "@agent-devtools/svelte", - "version": "1.3.0", + "version": "1.3.1-beta.0", "description": "Svelte adapter for agent-devtools — Svelte 4/5 component walker + DOM picker + closed Shadow DOM widget", "keywords": [ "agent-devtools", diff --git a/packages/sveltekit/CHANGELOG.md b/packages/sveltekit/CHANGELOG.md index 72bcb25..40eeb41 100644 --- a/packages/sveltekit/CHANGELOG.md +++ b/packages/sveltekit/CHANGELOG.md @@ -1,5 +1,13 @@ # @agent-devtools/sveltekit +## 1.3.1-beta.0 + +### Patch Changes + +- Updated dependencies []: + - @agent-devtools/core@1.3.1-beta.0 + - @agent-devtools/svelte@1.3.1-beta.0 + ## 1.3.0 ### Patch Changes diff --git a/packages/sveltekit/package.json b/packages/sveltekit/package.json index 217fbf1..453582c 100644 --- a/packages/sveltekit/package.json +++ b/packages/sveltekit/package.json @@ -1,6 +1,6 @@ { "name": "@agent-devtools/sveltekit", - "version": "1.3.0", + "version": "1.3.1-beta.0", "description": "SvelteKit adapter for agent-devtools — dev-only handle hook + Svelte adapter mount", "keywords": [ "agent-devtools", diff --git a/packages/vite/CHANGELOG.md b/packages/vite/CHANGELOG.md index ab02cf7..dc5d55b 100644 --- a/packages/vite/CHANGELOG.md +++ b/packages/vite/CHANGELOG.md @@ -1,5 +1,13 @@ # @agent-devtools/vite +## 1.3.1-beta.0 + +### Patch Changes + +- Updated dependencies []: + - @agent-devtools/core@1.3.1-beta.0 + - @agent-devtools/widget-core@1.3.1-beta.0 + ## 1.3.0 ### Minor Changes diff --git a/packages/vite/package.json b/packages/vite/package.json index e3458a1..7efe53a 100644 --- a/packages/vite/package.json +++ b/packages/vite/package.json @@ -1,6 +1,6 @@ { "name": "@agent-devtools/vite", - "version": "1.3.0", + "version": "1.3.1-beta.0", "description": "Vite plugin for agent-devtools — auto-spawn agent server + dev-only widget injection (Vite 5+)", "keywords": [ "agent-devtools", diff --git a/packages/vue/CHANGELOG.md b/packages/vue/CHANGELOG.md index 04ec8a8..685b912 100644 --- a/packages/vue/CHANGELOG.md +++ b/packages/vue/CHANGELOG.md @@ -1,5 +1,13 @@ # @agent-devtools/vue +## 1.3.1-beta.0 + +### Patch Changes + +- Updated dependencies []: + - @agent-devtools/core@1.3.1-beta.0 + - @agent-devtools/widget-core@1.3.1-beta.0 + ## 1.3.0 ### Patch Changes diff --git a/packages/vue/package.json b/packages/vue/package.json index 6246a70..c5e47a2 100644 --- a/packages/vue/package.json +++ b/packages/vue/package.json @@ -1,6 +1,6 @@ { "name": "@agent-devtools/vue", - "version": "1.3.0", + "version": "1.3.1-beta.0", "description": "Vue 3 adapter for agent-devtools — vnode walker + DOM picker + closed Shadow DOM widget", "keywords": [ "agent-devtools", diff --git a/packages/vue2/CHANGELOG.md b/packages/vue2/CHANGELOG.md index c00c5c6..cd8ada6 100644 --- a/packages/vue2/CHANGELOG.md +++ b/packages/vue2/CHANGELOG.md @@ -1,5 +1,13 @@ # @agent-devtools/vue2 +## 1.3.1-beta.0 + +### Patch Changes + +- Updated dependencies []: + - @agent-devtools/core@1.3.1-beta.0 + - @agent-devtools/widget-core@1.3.1-beta.0 + ## 1.3.0 ### Patch Changes diff --git a/packages/vue2/package.json b/packages/vue2/package.json index 39b71ea..16dc237 100644 --- a/packages/vue2/package.json +++ b/packages/vue2/package.json @@ -1,6 +1,6 @@ { "name": "@agent-devtools/vue2", - "version": "1.3.0", + "version": "1.3.1-beta.0", "description": "Vue 2 adapter for agent-devtools — Vue 2.7 component walker + DOM picker + closed Shadow DOM widget", "keywords": [ "agent-devtools", diff --git a/packages/widget-core/CHANGELOG.md b/packages/widget-core/CHANGELOG.md index bfe8a9d..09b3049 100644 --- a/packages/widget-core/CHANGELOG.md +++ b/packages/widget-core/CHANGELOG.md @@ -1,5 +1,12 @@ # @agent-devtools/widget-core +## 1.3.1-beta.0 + +### Patch Changes + +- Updated dependencies []: + - @agent-devtools/core@1.3.1-beta.0 + ## 1.3.0 ### Minor Changes diff --git a/packages/widget-core/package.json b/packages/widget-core/package.json index 1b54f9d..0a16da2 100644 --- a/packages/widget-core/package.json +++ b/packages/widget-core/package.json @@ -1,6 +1,6 @@ { "name": "@agent-devtools/widget-core", - "version": "1.3.0", + "version": "1.3.1-beta.0", "description": "Framework-agnostic widget shell for agent-devtools — closed Shadow DOM mount, composer, picker overlay, SSE transport", "keywords": [ "agent-devtools",