Skip to content

Commit 2ba2244

Browse files
committed
spike: Add proof-of-concept for Devtools Extension
1 parent 3b4f602 commit 2ba2244

32 files changed

+2642
-217
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,9 @@ pnpm turbo run storybook:build --filter=storybook
6060
- `packages/runtime` - Server-side runtime handlers
6161
- `packages/shared` - Common utilities
6262
- `apps/storybook` - Component documentation and examples
63+
64+
### Inspector and DevTools packages
65+
66+
- `packages/web-inspector` - Lit-based `<web-inspector>` custom element that attaches to a live `CopilotKitCore` to mirror runtime status, agents, tools, context, and AG-UI events (caps 200 per agent / 500 total). Includes persistence helpers for layout/dock state.
67+
- `packages/devtools-inspector` - Proof-of-concept host that depends on `@copilotkitnext/web-inspector`, registers the element, and injects a remote core/agent shim so streamed data can render inside DevTools.
68+
- `packages/devtools-extension` - Chrome DevTools MV3 extension scaffold (background/content/page scripts, devtools panel) that relays CopilotKit data from the inspected page to the `devtools-inspector` host and renders a “CopilotKit” panel.

apps/angular/demo/src/app/app.config.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
import { ApplicationConfig, importProvidersFrom } from "@angular/core";
22
import { BrowserModule } from "@angular/platform-browser";
3-
import {
4-
provideCopilotKit,
5-
provideCopilotChatLabels,
6-
} from "@copilotkitnext/angular";
3+
import { provideCopilotKit, provideCopilotChatLabels, provideCopilotKitDevtools } from "@copilotkitnext/angular";
74
import { WildcardToolRenderComponent } from "./components/wildcard-tool-render.component";
85

96
export const appConfig: ApplicationConfig = {
@@ -20,10 +17,10 @@ export const appConfig: ApplicationConfig = {
2017
frontendTools: [],
2118
humanInTheLoop: [],
2219
}),
20+
provideCopilotKitDevtools(),
2321
provideCopilotChatLabels({
2422
chatInputPlaceholder: "Ask me anything...",
25-
chatDisclaimerText:
26-
"CopilotKit Angular Demo - AI responses may need verification.",
23+
chatDisclaimerText: "CopilotKit Angular Demo - AI responses may need verification.",
2724
}),
2825
],
2926
};
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { APP_INITIALIZER, Provider } from "@angular/core";
2+
import { CopilotKit } from "./copilotkit";
3+
4+
type DevtoolsHook = {
5+
core?: unknown;
6+
setCore: (core: unknown) => void;
7+
};
8+
9+
function initializeDevtools(copilotkit: CopilotKit): () => void {
10+
return () => {
11+
if (typeof window === "undefined") {
12+
return;
13+
}
14+
15+
const globalWindow = window as typeof window & { __COPILOTKIT_DEVTOOLS__?: DevtoolsHook };
16+
const hook = globalWindow.__COPILOTKIT_DEVTOOLS__ ?? {
17+
core: undefined,
18+
setCore(nextCore: unknown) {
19+
this.core = nextCore;
20+
},
21+
};
22+
23+
hook.setCore(copilotkit.core);
24+
globalWindow.__COPILOTKIT_DEVTOOLS__ = hook;
25+
};
26+
}
27+
28+
export function provideCopilotKitDevtools(): Provider {
29+
return {
30+
provide: APP_INITIALIZER,
31+
useFactory: initializeDevtools,
32+
deps: [CopilotKit],
33+
multi: true,
34+
};
35+
}

packages/angular/src/public-api.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,4 @@ export * from "./lib/components/chat/copilot-chat-view-input-container";
4848
export * from "./lib/components/chat/copilot-chat-view-scroll-to-bottom-button";
4949
export * from "./lib/components/chat/copilot-chat-view-scroll-view";
5050
export * from "./lib/components/chat/copilot-chat-view.types";
51+
export * from "./lib/devtools";
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# CopilotKit DevTools extension
2+
3+
Builds a Chrome DevTools panel that hosts the CopilotKit web inspector.
4+
5+
## Commands
6+
7+
- `pnpm --filter @copilotkitnext/devtools-extension build` – bundle scripts to `dist/` and copy the manifest/assets.
8+
- `pnpm --filter @copilotkitnext/devtools-extension dev` – watch mode for local iteration.
9+
10+
## Loading the extension
11+
12+
1. Run the build command above.
13+
2. In Chrome, open `chrome://extensions`, enable **Developer mode**, and click **Load unpacked**.
14+
3. Select `packages/devtools-extension/dist`. A “CopilotKit” DevTools panel will appear when inspecting a tab.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { config as baseConfig } from "@copilotkitnext/eslint-config/base";
2+
3+
export default [...baseConfig];
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"name": "@copilotkitnext/devtools-extension",
3+
"version": "0.0.1",
4+
"private": true,
5+
"description": "Chrome DevTools panel for CopilotKit",
6+
"scripts": {
7+
"build": "node ./scripts/build.mjs",
8+
"dev": "node ./scripts/build.mjs --watch",
9+
"lint": "eslint . --max-warnings 0",
10+
"check-types": "tsc --noEmit",
11+
"clean": "rm -rf dist"
12+
},
13+
"dependencies": {
14+
"@ag-ui/client": "0.0.42-alpha.1",
15+
"@copilotkitnext/core": "workspace:*",
16+
"@copilotkitnext/devtools-inspector": "workspace:*"
17+
},
18+
"devDependencies": {
19+
"@copilotkitnext/eslint-config": "workspace:*",
20+
"@copilotkitnext/typescript-config": "workspace:*",
21+
"@types/chrome": "^0.0.300",
22+
"@types/node": "^22.15.3",
23+
"esbuild": "^0.24.2",
24+
"eslint": "^9.30.0",
25+
"typescript": "5.8.2"
26+
},
27+
"engines": {
28+
"node": ">=18"
29+
}
30+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<title>CopilotKit DevTools</title>
6+
</head>
7+
<body>
8+
<script src="devtools.js"></script>
9+
</body>
10+
</html>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"manifest_version": 3,
3+
"name": "CopilotKit DevTools",
4+
"version": "0.0.1",
5+
"description": "DevTools panel for CopilotKit runtime inspection.",
6+
"devtools_page": "devtools.html",
7+
"background": {
8+
"service_worker": "background.js"
9+
},
10+
"permissions": ["storage"],
11+
"host_permissions": ["file:///*", "http://*/*", "https://*/*"],
12+
"content_scripts": [
13+
{
14+
"matches": ["<all_urls>"],
15+
"js": ["content.js"],
16+
"run_at": "document_start"
17+
},
18+
{
19+
"matches": ["<all_urls>"],
20+
"js": ["page.js"],
21+
"run_at": "document_start",
22+
"world": "MAIN"
23+
}
24+
]
25+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<title>CopilotKit Panel</title>
6+
<style>
7+
html,
8+
body,
9+
#app {
10+
height: 100%;
11+
margin: 0;
12+
}
13+
body {
14+
background: #f8fafc;
15+
}
16+
</style>
17+
</head>
18+
<body>
19+
<div id="app"></div>
20+
<script src="panel.js"></script>
21+
</body>
22+
</html>

0 commit comments

Comments
 (0)