kennel 0.2.0 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -5
- package/dist/cli/dispatch.js +9 -0
- package/dist/cli/src/automations/notifications.d.ts +40 -0
- package/dist/cli/src/automations/notifications.js +220 -0
- package/dist/cli/src/cli/dispatch.d.ts +1 -0
- package/dist/cli/src/cli/dispatch.js +125 -0
- package/dist/cli/src/cli/usage.d.ts +1 -0
- package/dist/cli/src/cli/usage.js +25 -0
- package/dist/cli/src/core/api-client.d.ts +13 -0
- package/dist/cli/src/core/api-client.js +1 -0
- package/dist/cli/src/core/command.d.ts +1 -0
- package/dist/cli/src/core/command.js +69 -0
- package/dist/cli/src/core/core-folders.d.ts +1 -0
- package/dist/cli/src/core/core-folders.js +42 -0
- package/dist/cli/src/core/init.d.ts +1 -0
- package/dist/cli/src/core/init.js +141 -0
- package/dist/cli/src/core/runtime.d.ts +14 -0
- package/dist/cli/src/core/runtime.js +1 -0
- package/dist/cli/src/deploy/cloudflare.d.ts +6 -0
- package/dist/cli/src/deploy/cloudflare.js +100 -0
- package/dist/cli/src/deploy/environment.d.ts +2 -0
- package/dist/cli/src/deploy/environment.js +47 -0
- package/dist/cli/src/deploy/smoke-tests.d.ts +4 -0
- package/dist/cli/src/deploy/smoke-tests.js +92 -0
- package/dist/cli/src/deploy/trigger-dev.d.ts +2 -0
- package/dist/cli/src/deploy/trigger-dev.js +255 -0
- package/dist/cli/src/deploy/vercel.d.ts +3 -0
- package/dist/cli/src/deploy/vercel.js +67 -0
- package/dist/cli/src/main.d.ts +1 -0
- package/dist/cli/src/main.js +9 -0
- package/dist/cli/src/mcp/agent-tools.d.ts +8 -0
- package/dist/cli/src/mcp/agent-tools.js +247 -0
- package/dist/cli/src/mcp/config.d.ts +25 -0
- package/dist/cli/src/mcp/config.js +185 -0
- package/dist/cli/src/mcp/function-source.d.ts +7 -0
- package/dist/cli/src/mcp/function-source.js +42 -0
- package/dist/cli/src/mcp/generate.d.ts +1 -0
- package/dist/cli/src/mcp/generate.js +47 -0
- package/dist/cli/src/mcp/install-page.d.ts +12 -0
- package/dist/cli/src/mcp/install-page.js +5 -0
- package/dist/cli/src/notifications/email-worker.d.ts +8 -0
- package/dist/cli/src/notifications/email-worker.js +137 -0
- package/dist/cli/src/package/mcp-data.d.ts +1 -0
- package/dist/cli/src/package/mcp-data.js +1 -0
- package/dist/cli/src/package/mcp-email-worker.d.ts +1 -0
- package/dist/cli/src/package/mcp-email-worker.js +1 -0
- package/dist/cli/src/package/mcp-http.d.ts +1 -0
- package/dist/cli/src/package/mcp-http.js +1 -0
- package/dist/cli/src/package/mcp-stdio.d.ts +1 -0
- package/dist/cli/src/package/mcp-stdio.js +1 -0
- package/dist/cli/src/package/mcp.d.ts +1 -0
- package/dist/cli/src/package/mcp.js +1 -0
- package/dist/cli/src/package/preview.d.ts +9 -0
- package/dist/cli/src/package/preview.js +1 -0
- package/dist/cli/src/plugins/external.d.ts +36 -0
- package/dist/cli/src/plugins/external.js +503 -0
- package/dist/cli/src/publish/cloudflare-init.d.ts +12 -0
- package/dist/cli/src/publish/cloudflare-init.js +101 -0
- package/dist/cli/src/publish/config.d.ts +28 -0
- package/dist/cli/src/publish/config.js +178 -0
- package/dist/cli/src/publish/options.d.ts +13 -0
- package/dist/cli/src/publish/options.js +78 -0
- package/dist/cli/src/publish/vercel-init.d.ts +9 -0
- package/dist/cli/src/publish/vercel-init.js +52 -0
- package/dist/cli/src/shared/json.d.ts +4 -0
- package/dist/cli/src/shared/json.js +56 -0
- package/dist/cli/src/shared/object.d.ts +2 -0
- package/dist/cli/src/shared/object.js +3 -0
- package/dist/cli/src/shared/package-manager.d.ts +11 -0
- package/dist/cli/src/shared/package-manager.js +39 -0
- package/dist/cli/src/shared/path.d.ts +4 -0
- package/dist/cli/src/shared/path.js +40 -0
- package/dist/cli/src/shared/process.d.ts +7 -0
- package/dist/cli/src/shared/process.js +12 -0
- package/dist/cli/src/shared/project-config.d.ts +2 -0
- package/dist/cli/src/shared/project-config.js +26 -0
- package/dist/cli/src/site/dev.d.ts +10 -0
- package/dist/cli/src/site/dev.js +126 -0
- package/dist/cli/src/site/extension.d.ts +8 -0
- package/dist/cli/src/site/extension.js +113 -0
- package/dist/cli/src/site/folder-icons.d.ts +46 -0
- package/dist/cli/src/site/folder-icons.js +86 -0
- package/dist/cli/src/site/hot-viewer.d.ts +2 -0
- package/dist/cli/src/site/hot-viewer.js +231 -0
- package/dist/cli/src/site/kinds.d.ts +1 -0
- package/dist/cli/src/site/kinds.js +1 -0
- package/dist/cli/src/site/mail.d.ts +1 -0
- package/dist/cli/src/site/mail.js +10 -0
- package/dist/cli/src/site/renderers.d.ts +61 -0
- package/dist/cli/src/site/renderers.js +219 -0
- package/dist/cli/src/site/server-plugins.d.ts +54 -0
- package/dist/cli/src/site/server-plugins.js +1 -0
- package/dist/cli/src/site/viewer.d.ts +36 -0
- package/dist/cli/src/site/viewer.js +352 -0
- package/dist/cli/src/site/vitepress.d.ts +1 -0
- package/dist/cli/src/site/vitepress.js +1 -0
- package/dist/cli/usage.js +1 -0
- package/dist/core/api-client.js +75 -44
- package/dist/core/command.js +6 -3
- package/dist/core/core-folders.js +38280 -33
- package/dist/core/init.js +59 -4
- package/dist/core/runtime.js +57163 -41853
- package/dist/package/preview.js +40589 -17894
- package/dist/plugins/external.d.ts +36 -0
- package/dist/plugins/external.js +503 -0
- package/dist/site/server-plugins.js +394 -59
- package/dist/site/viewer.js +18 -5
- package/kernel/apps/web/.env.example +11 -0
- package/kernel/apps/web/components.json +20 -0
- package/kernel/apps/web/eslint.config.mjs +60 -0
- package/kernel/apps/web/index.html +17 -0
- package/kernel/apps/web/package.json +79 -0
- package/kernel/apps/web/public/favicon.svg +6 -0
- package/kernel/apps/web/public/providers/claude.svg +1 -0
- package/kernel/apps/web/public/providers/codex.svg +1 -0
- package/kernel/apps/web/public/providers/cursor.svg +1 -0
- package/kernel/apps/web/public/providers/opencode.svg +1 -0
- package/kernel/apps/web/public/providers/pi.svg +1 -0
- package/kernel/apps/web/server/acp/index.ts +1 -0
- package/kernel/apps/web/server/acp/live-agent-connection.ts +1 -0
- package/kernel/apps/web/server/acp/process-manager.ts +1 -0
- package/kernel/apps/web/server/acp/registry.ts +1 -0
- package/kernel/apps/web/server/acp/sdk.ts +1 -0
- package/kernel/apps/web/server/acp/transport.ts +1 -0
- package/kernel/apps/web/server/acp/types.ts +1 -0
- package/kernel/apps/web/server/acp-live-plugin.ts +30 -0
- package/kernel/apps/web/server/api/document-edit.ts +1 -0
- package/kernel/apps/web/server/api/open-path.ts +1 -0
- package/kernel/apps/web/server/core-plugin.ts +49 -0
- package/kernel/apps/web/server/folder-favicon.ts +1 -0
- package/kernel/apps/web/server/folder-icons.ts +1 -0
- package/kernel/apps/web/server/folder-metadata-plugin.ts +31 -0
- package/kernel/apps/web/server/plugins.ts +1 -0
- package/kernel/apps/web/server/preview-kinds.ts +1 -0
- package/kernel/apps/web/src/ai-input.tsx +62 -0
- package/kernel/apps/web/src/annotations.tsx +430 -0
- package/kernel/apps/web/src/api/client.ts +3 -0
- package/kernel/apps/web/src/api/errors.ts +1 -0
- package/kernel/apps/web/src/api/events.ts +42 -0
- package/kernel/apps/web/src/app.css +332 -0
- package/kernel/apps/web/src/app.tsx +667 -0
- package/kernel/apps/web/src/ask-draft.ts +164 -0
- package/kernel/apps/web/src/ask-tray.tsx +256 -0
- package/kernel/apps/web/src/comment-editor.tsx +93 -0
- package/kernel/apps/web/src/comment-form.tsx +162 -0
- package/kernel/apps/web/src/copy-path.ts +18 -0
- package/kernel/apps/web/src/deferred-ask-tray.tsx +20 -0
- package/kernel/apps/web/src/document-url.ts +46 -0
- package/kernel/apps/web/src/documents-url.ts +23 -0
- package/kernel/apps/web/src/dropped-folder.ts +64 -0
- package/kernel/apps/web/src/external-plugins.ts +3 -0
- package/kernel/apps/web/src/file-viewer.tsx +171 -0
- package/kernel/apps/web/src/folder-filter-icons.tsx +39 -0
- package/kernel/apps/web/src/folder-metadata.ts +76 -0
- package/kernel/apps/web/src/folder-plugin-view.tsx +87 -0
- package/kernel/apps/web/src/folder-query-cache.ts +66 -0
- package/kernel/apps/web/src/host-adapters.ts +209 -0
- package/kernel/apps/web/src/host-bridge.ts +214 -0
- package/kernel/apps/web/src/lib/entity-folder.ts +2 -0
- package/kernel/apps/web/src/linked-session-header.tsx +43 -0
- package/kernel/apps/web/src/live-session-controls.tsx +326 -0
- package/kernel/apps/web/src/local-source.ts +32 -0
- package/kernel/apps/web/src/main.tsx +24 -0
- package/kernel/apps/web/src/markdown-page.tsx +444 -0
- package/kernel/apps/web/src/notes-page.tsx +103 -0
- package/kernel/apps/web/src/plugins.ts +53 -0
- package/kernel/apps/web/src/project-search-dialog.tsx +257 -0
- package/kernel/apps/web/src/project-search.ts +18 -0
- package/kernel/apps/web/src/query-client.ts +4 -0
- package/kernel/apps/web/src/rehype-source-lines.ts +22 -0
- package/kernel/apps/web/src/routes/document.tsx +1 -0
- package/kernel/apps/web/src/routes/entities.tsx +277 -0
- package/kernel/apps/web/src/routes/search.tsx +60 -0
- package/kernel/apps/web/src/selection-context.ts +68 -0
- package/kernel/apps/web/src/selection-input.tsx +58 -0
- package/kernel/apps/web/src/selection-popup.tsx +155 -0
- package/kernel/apps/web/src/session-transcript-page.tsx +152 -0
- package/kernel/apps/web/src/use-annotations.ts +162 -0
- package/kernel/apps/web/src/use-ask-ai.ts +26 -0
- package/kernel/apps/web/src/use-ask-draft.ts +27 -0
- package/kernel/apps/web/src/use-document.ts +37 -0
- package/kernel/apps/web/src/use-folder-notes.ts +49 -0
- package/kernel/apps/web/src/use-linked-session.ts +33 -0
- package/kernel/apps/web/src/view-context.tsx +69 -0
- package/kernel/apps/web/src/view-header.tsx +66 -0
- package/kernel/apps/web/src/viewer-capabilities.ts +33 -0
- package/kernel/apps/web/src/viewer-route.ts +1 -0
- package/kernel/apps/web/src/viewport-height.ts +33 -0
- package/kernel/apps/web/tsconfig.json +24 -0
- package/kernel/apps/web/vite.config.ts +252 -0
- package/kernel/packages/agents/eslint.config.js +10 -0
- package/kernel/packages/agents/package.json +75 -0
- package/kernel/packages/agents/src/agent-card.tsx +334 -0
- package/kernel/packages/agents/src/client.tsx +13 -0
- package/kernel/packages/agents/src/index.ts +18 -0
- package/kernel/packages/agents/src/manifest.ts +7 -0
- package/kernel/packages/agents/src/node.ts +447 -0
- package/kernel/packages/agents/src/profiles.ts +137 -0
- package/kernel/packages/agents/src/resolve.ts +69 -0
- package/kernel/packages/agents/src/server.ts +60 -0
- package/kernel/packages/agents/src/types.ts +82 -0
- package/kernel/packages/agents/src/viewer.tsx +370 -0
- package/kernel/packages/agents/test/profiles.test.mjs +88 -0
- package/kernel/packages/agents/test/resolve.test.mjs +729 -0
- package/kernel/packages/agents/tsconfig.json +17 -0
- package/kernel/packages/api/README.md +73 -0
- package/kernel/packages/api/openapi.json +3368 -0
- package/kernel/packages/api/package.json +41 -0
- package/kernel/packages/api/src/client/errors.ts +1 -0
- package/kernel/packages/api/src/client/index.ts +2 -0
- package/kernel/packages/api/src/contracts/schemas.ts +277 -0
- package/kernel/packages/api/src/contracts.ts +20 -0
- package/kernel/packages/api/src/index.ts +34 -0
- package/kernel/packages/api/src/server/acp/index.ts +35 -0
- package/kernel/packages/api/src/server/acp/live-agent-connection.ts +44 -0
- package/kernel/packages/api/src/server/acp/process-manager.ts +291 -0
- package/kernel/packages/api/src/server/acp/registry.ts +140 -0
- package/kernel/packages/api/src/server/acp/sdk.ts +15 -0
- package/kernel/packages/api/src/server/acp/transport.ts +115 -0
- package/kernel/packages/api/src/server/acp/types.ts +89 -0
- package/kernel/packages/api/src/server/acp-live-plugin.ts +423 -0
- package/kernel/packages/api/src/server/api/create-agent-file.ts +46 -0
- package/kernel/packages/api/src/server/api/document-edit.ts +125 -0
- package/kernel/packages/api/src/server/api/open-path.ts +40 -0
- package/kernel/packages/api/src/server/contracts.ts +85 -0
- package/kernel/packages/api/src/server/entity-folder.ts +353 -0
- package/kernel/packages/api/src/server/folder-favicon.ts +17 -0
- package/kernel/packages/api/src/server/folder-icons.ts +113 -0
- package/kernel/packages/api/src/server/folder-metadata-plugin.ts +1758 -0
- package/kernel/packages/api/src/server/host.ts +21 -0
- package/kernel/packages/api/src/server/index.ts +197 -0
- package/kernel/packages/api/src/server/linked-folder-discovery.ts +158 -0
- package/kernel/packages/api/src/server/plugins.ts +205 -0
- package/kernel/packages/api/src/server/project-discovery.ts +69 -0
- package/kernel/packages/api/src/server/watcher.ts +46 -0
- package/kernel/packages/api/src/shared/selection.ts +16 -0
- package/kernel/packages/api/src/shared/viewer-route.ts +200 -0
- package/kernel/packages/api/test/agents-loading.test.ts +94 -0
- package/kernel/packages/api/test/core.test.ts +364 -0
- package/kernel/packages/api/test/entity-folder.test.ts +131 -0
- package/kernel/packages/api/test/linked-folder-discovery.test.ts +78 -0
- package/kernel/packages/api/test/media-endpoint.test.ts +83 -0
- package/kernel/packages/api/test/partial-loading.test.ts +43 -0
- package/kernel/packages/api/test/project-discovery.test.ts +44 -0
- package/kernel/packages/api/tsconfig.json +11 -0
- package/kernel/packages/api-client/README.md +72 -0
- package/kernel/packages/api-client/package.json +26 -0
- package/kernel/packages/api-client/scripts/generate.ts +68 -0
- package/kernel/packages/api-client/src/errors.ts +59 -0
- package/kernel/packages/api-client/src/generated.d.ts +1248 -0
- package/kernel/packages/api-client/src/index.ts +206 -0
- package/kernel/packages/api-client/src/responses.ts +19 -0
- package/kernel/packages/api-client/test/client.test.ts +143 -0
- package/kernel/packages/api-client/tsconfig.json +12 -0
- package/kernel/packages/folder-plugin/eslint.config.js +10 -0
- package/kernel/packages/folder-plugin/package.json +50 -0
- package/kernel/packages/folder-plugin/src/client.ts +73 -0
- package/kernel/packages/folder-plugin/src/endpoint.ts +273 -0
- package/kernel/packages/folder-plugin/src/index.ts +15 -0
- package/kernel/packages/folder-plugin/src/server.ts +78 -0
- package/kernel/packages/folder-plugin/src/subpath.ts +34 -0
- package/kernel/packages/folder-plugin/src/types.ts +86 -0
- package/kernel/packages/folder-plugin/src/validation.ts +56 -0
- package/kernel/packages/folder-plugin/test/contract.test.mjs +133 -0
- package/kernel/packages/folder-plugin/tsconfig.json +17 -0
- package/kernel/packages/kinds/package.json +24 -0
- package/kernel/packages/kinds/src/kinds.ts +172 -0
- package/kernel/packages/markdown/README.md +40 -0
- package/kernel/packages/markdown/explorer.css +1 -0
- package/kernel/packages/markdown/package.json +30 -0
- package/kernel/packages/markdown/src/documents.ts +1 -0
- package/kernel/packages/markdown/src/explorer.ts +1 -0
- package/kernel/packages/markdown/src/index.ts +2 -0
- package/kernel/packages/markdown/src/metadata.ts +63 -0
- package/kernel/packages/markdown/src/node.ts +1 -0
- package/kernel/packages/markdown/styles.css +1 -0
- package/kernel/packages/notes/SKILL.md +19 -0
- package/kernel/packages/notes/eslint.config.js +10 -0
- package/kernel/packages/notes/package.json +72 -0
- package/kernel/packages/notes/src/client.tsx +12 -0
- package/kernel/packages/notes/src/data/ai-input.ts +58 -0
- package/kernel/packages/notes/src/data/api.ts +40 -0
- package/kernel/packages/notes/src/data/parse.ts +15 -0
- package/kernel/packages/notes/src/data/routing.ts +33 -0
- package/kernel/packages/notes/src/data/use-folder-notes.ts +49 -0
- package/kernel/packages/notes/src/index.ts +2 -0
- package/kernel/packages/notes/src/manifest.ts +6 -0
- package/kernel/packages/notes/src/pages/notes-page.tsx +79 -0
- package/kernel/packages/notes/src/pages/single-note-page.tsx +57 -0
- package/kernel/packages/notes/src/server.ts +88 -0
- package/kernel/packages/notes/src/ui/ai-composer-controls.tsx +70 -0
- package/kernel/packages/notes/src/ui/folder-notes-list.tsx +140 -0
- package/kernel/packages/notes/tsconfig.json +16 -0
- package/kernel/packages/schemas/ICON-POLICY.md +43 -0
- package/kernel/packages/schemas/SKILL.md +185 -0
- package/kernel/packages/schemas/eslint.config.js +10 -0
- package/kernel/packages/schemas/package.json +81 -0
- package/kernel/packages/schemas/src/client.tsx +137 -0
- package/kernel/packages/schemas/src/data/config-file.ts +37 -0
- package/kernel/packages/schemas/src/data/contract.ts +174 -0
- package/kernel/packages/schemas/src/data/favicon.ts +218 -0
- package/kernel/packages/schemas/src/data/fields.ts +96 -0
- package/kernel/packages/schemas/src/data/icon-image.ts +53 -0
- package/kernel/packages/schemas/src/data/icon.ts +97 -0
- package/kernel/packages/schemas/src/data/load.ts +161 -0
- package/kernel/packages/schemas/src/data/params.ts +103 -0
- package/kernel/packages/schemas/src/data/query.ts +33 -0
- package/kernel/packages/schemas/src/data/sort.ts +50 -0
- package/kernel/packages/schemas/src/data/workspace.ts +101 -0
- package/kernel/packages/schemas/src/index.ts +22 -0
- package/kernel/packages/schemas/src/manifest.ts +4 -0
- package/kernel/packages/schemas/src/node.ts +384 -0
- package/kernel/packages/schemas/src/pages/collection.tsx +252 -0
- package/kernel/packages/schemas/src/server.ts +208 -0
- package/kernel/packages/schemas/src/ui/schema-entity-list.tsx +124 -0
- package/kernel/packages/schemas/src/ui/schema-filters.tsx +186 -0
- package/kernel/packages/schemas/src/ui/schema-search.tsx +35 -0
- package/kernel/packages/schemas/src/ui/use-query-param-filter-setting.tsx +15 -0
- package/kernel/packages/schemas/test/contract.test.mjs +26 -0
- package/kernel/packages/schemas/test/fields.test.mjs +187 -0
- package/kernel/packages/schemas/test/load.test.mjs +12 -0
- package/kernel/packages/schemas/test/node.test.mjs +412 -0
- package/kernel/packages/schemas/test/query.test.mjs +134 -0
- package/kernel/packages/schemas/test/workspace.test.mjs +86 -0
- package/kernel/packages/schemas/tsconfig.json +17 -0
- package/kernel/packages/session-finding/package.json +33 -0
- package/kernel/packages/session-finding/src/index.ts +120 -0
- package/kernel/packages/session-finding/test/list-sessions.test.mjs +139 -0
- package/kernel/packages/session-finding/tsconfig.json +12 -0
- package/kernel/packages/ui/LICENSE +21 -0
- package/kernel/packages/ui/components.json +20 -0
- package/kernel/packages/ui/eslint.config.js +8 -0
- package/kernel/packages/ui/package.json +106 -0
- package/kernel/packages/ui/src/chat/file-link.ts +178 -0
- package/kernel/packages/ui/src/chat/index.ts +18 -0
- package/kernel/packages/ui/src/chat/transcript.tsx +348 -0
- package/kernel/packages/ui/src/chat/turns.ts +76 -0
- package/kernel/packages/ui/src/chat/types.ts +23 -0
- package/kernel/packages/ui/src/chat/use-overflowing.ts +56 -0
- package/kernel/packages/ui/src/components/accordion.tsx +74 -0
- package/kernel/packages/ui/src/components/alert-dialog.tsx +164 -0
- package/kernel/packages/ui/src/components/alert.tsx +68 -0
- package/kernel/packages/ui/src/components/app-breadcrumbs.tsx +170 -0
- package/kernel/packages/ui/src/components/app-header.tsx +125 -0
- package/kernel/packages/ui/src/components/app-options.tsx +87 -0
- package/kernel/packages/ui/src/components/app-view-header.tsx +34 -0
- package/kernel/packages/ui/src/components/aspect-ratio.tsx +11 -0
- package/kernel/packages/ui/src/components/avatar.tsx +53 -0
- package/kernel/packages/ui/src/components/badge.tsx +47 -0
- package/kernel/packages/ui/src/components/base-dialog.tsx +3 -0
- package/kernel/packages/ui/src/components/base-tabs.tsx +63 -0
- package/kernel/packages/ui/src/components/breadcrumb.tsx +110 -0
- package/kernel/packages/ui/src/components/button-group.tsx +86 -0
- package/kernel/packages/ui/src/components/button.tsx +65 -0
- package/kernel/packages/ui/src/components/calendar.tsx +240 -0
- package/kernel/packages/ui/src/components/card.tsx +95 -0
- package/kernel/packages/ui/src/components/carousel.tsx +240 -0
- package/kernel/packages/ui/src/components/chart.tsx +375 -0
- package/kernel/packages/ui/src/components/checkbox.tsx +39 -0
- package/kernel/packages/ui/src/components/collapsible.tsx +33 -0
- package/kernel/packages/ui/src/components/collection-icon.tsx +28 -0
- package/kernel/packages/ui/src/components/command.tsx +205 -0
- package/kernel/packages/ui/src/components/content-issues.tsx +63 -0
- package/kernel/packages/ui/src/components/context-menu.tsx +298 -0
- package/kernel/packages/ui/src/components/copy-context.tsx +134 -0
- package/kernel/packages/ui/src/components/dialog.tsx +157 -0
- package/kernel/packages/ui/src/components/drawer.tsx +162 -0
- package/kernel/packages/ui/src/components/dropdown-menu.tsx +303 -0
- package/kernel/packages/ui/src/components/empty.tsx +108 -0
- package/kernel/packages/ui/src/components/field.tsx +260 -0
- package/kernel/packages/ui/src/components/file-preview.tsx +152 -0
- package/kernel/packages/ui/src/components/file-renderer.tsx +466 -0
- package/kernel/packages/ui/src/components/filter-chip-panel.tsx +157 -0
- package/kernel/packages/ui/src/components/filter-select.tsx +127 -0
- package/kernel/packages/ui/src/components/folder-activity.tsx +646 -0
- package/kernel/packages/ui/src/components/folder-file-list.tsx +58 -0
- package/kernel/packages/ui/src/components/folder-filter-bar.tsx +191 -0
- package/kernel/packages/ui/src/components/folder-image.tsx +18 -0
- package/kernel/packages/ui/src/components/folder-landing.tsx +70 -0
- package/kernel/packages/ui/src/components/folder-list.tsx +140 -0
- package/kernel/packages/ui/src/components/folder-metadata.tsx +107 -0
- package/kernel/packages/ui/src/components/folder-mobile-bar.tsx +60 -0
- package/kernel/packages/ui/src/components/folder-project-list.tsx +133 -0
- package/kernel/packages/ui/src/components/folder-session-list.tsx +113 -0
- package/kernel/packages/ui/src/components/folder-session-page.tsx +126 -0
- package/kernel/packages/ui/src/components/folder-sidebar.tsx +52 -0
- package/kernel/packages/ui/src/components/folder-skill-list.tsx +62 -0
- package/kernel/packages/ui/src/components/folder-tabs.tsx +156 -0
- package/kernel/packages/ui/src/components/form.tsx +167 -0
- package/kernel/packages/ui/src/components/hover-card.tsx +52 -0
- package/kernel/packages/ui/src/components/icons.tsx +34 -0
- package/kernel/packages/ui/src/components/input-group.tsx +184 -0
- package/kernel/packages/ui/src/components/input-otp.tsx +90 -0
- package/kernel/packages/ui/src/components/input.tsx +29 -0
- package/kernel/packages/ui/src/components/item.tsx +195 -0
- package/kernel/packages/ui/src/components/kbd.tsx +32 -0
- package/kernel/packages/ui/src/components/label.tsx +27 -0
- package/kernel/packages/ui/src/components/link.tsx +45 -0
- package/kernel/packages/ui/src/components/live-tool-call.tsx +193 -0
- package/kernel/packages/ui/src/components/menubar.tsx +323 -0
- package/kernel/packages/ui/src/components/navigation-menu.tsx +210 -0
- package/kernel/packages/ui/src/components/note-card.tsx +149 -0
- package/kernel/packages/ui/src/components/pagination.tsx +128 -0
- package/kernel/packages/ui/src/components/popover.tsx +56 -0
- package/kernel/packages/ui/src/components/progress.tsx +31 -0
- package/kernel/packages/ui/src/components/radio-group.tsx +54 -0
- package/kernel/packages/ui/src/components/scroll-area.tsx +61 -0
- package/kernel/packages/ui/src/components/select.tsx +219 -0
- package/kernel/packages/ui/src/components/separator.tsx +30 -0
- package/kernel/packages/ui/src/components/session-icon.tsx +124 -0
- package/kernel/packages/ui/src/components/sheet.tsx +157 -0
- package/kernel/packages/ui/src/components/sidebar.tsx +789 -0
- package/kernel/packages/ui/src/components/skeleton.tsx +13 -0
- package/kernel/packages/ui/src/components/slider.tsx +73 -0
- package/kernel/packages/ui/src/components/sonner.tsx +41 -0
- package/kernel/packages/ui/src/components/spinner.tsx +16 -0
- package/kernel/packages/ui/src/components/switch.tsx +40 -0
- package/kernel/packages/ui/src/components/table.tsx +120 -0
- package/kernel/packages/ui/src/components/tabs.tsx +78 -0
- package/kernel/packages/ui/src/components/textarea.tsx +25 -0
- package/kernel/packages/ui/src/components/toggle-group.tsx +87 -0
- package/kernel/packages/ui/src/components/toggle.tsx +48 -0
- package/kernel/packages/ui/src/components/tooltip.tsx +71 -0
- package/kernel/packages/ui/src/components/viewer-options.tsx +166 -0
- package/kernel/packages/ui/src/hooks/use-folder-filter.ts +103 -0
- package/kernel/packages/ui/src/hooks/use-mobile.ts +19 -0
- package/kernel/packages/ui/src/index.ts +13 -0
- package/kernel/packages/ui/src/lib/document-extensions.ts +83 -0
- package/kernel/packages/ui/src/lib/folder-activity.ts +143 -0
- package/kernel/packages/ui/src/lib/folder-filter.ts +284 -0
- package/kernel/packages/ui/src/lib/live-tool-call.tsx +109 -0
- package/kernel/packages/ui/src/lib/media-urls.ts +176 -0
- package/kernel/packages/ui/src/lib/obsidian-links.ts +120 -0
- package/kernel/packages/ui/src/lib/source-components.tsx +65 -0
- package/kernel/packages/ui/src/lib/utils.tsx +7 -0
- package/kernel/packages/ui/src/pages/entity-detail-page.tsx +82 -0
- package/kernel/packages/ui/src/pages/entity-list-page.tsx +50 -0
- package/kernel/packages/ui/src/pages/entity-page.tsx +69 -0
- package/kernel/packages/ui/src/styles/folder-activity.css +2151 -0
- package/kernel/packages/ui/test/copy-context.test.mjs +48 -0
- package/kernel/packages/ui/test/folder-filter.test.mjs +484 -0
- package/kernel/packages/ui/tsconfig.json +15 -0
- package/kernel/plugins/calendar/SKILL.md +173 -0
- package/kernel/plugins/calendar/eslint.config.js +10 -0
- package/kernel/plugins/calendar/package.json +73 -0
- package/kernel/plugins/calendar/schema.json +137 -0
- package/kernel/plugins/calendar/src/calendar.tsx +328 -0
- package/kernel/plugins/calendar/src/client.tsx +139 -0
- package/kernel/plugins/calendar/src/context.ts +48 -0
- package/kernel/plugins/calendar/src/copy-button.tsx +66 -0
- package/kernel/plugins/calendar/src/event-dialog.tsx +270 -0
- package/kernel/plugins/calendar/src/index.ts +4 -0
- package/kernel/plugins/calendar/src/manifest.ts +7 -0
- package/kernel/plugins/calendar/src/parse.ts +610 -0
- package/kernel/plugins/calendar/src/server.ts +160 -0
- package/kernel/plugins/calendar/src/utils.ts +80 -0
- package/kernel/plugins/calendar/src/views.tsx +418 -0
- package/kernel/plugins/calendar/test/context.test.mjs +60 -0
- package/kernel/plugins/calendar/test/package.test.mjs +43 -0
- package/kernel/plugins/calendar/test/parse.test.mjs +392 -0
- package/kernel/plugins/calendar/test/server.test.mjs +126 -0
- package/kernel/plugins/calendar/tsconfig.json +17 -0
- package/kernel/plugins/mail/SKILL.md +97 -0
- package/kernel/plugins/mail/eslint.config.js +10 -0
- package/kernel/plugins/mail/package.json +79 -0
- package/kernel/plugins/mail/src/api.ts +359 -0
- package/kernel/plugins/mail/src/bun-ffi.d.ts +14 -0
- package/kernel/plugins/mail/src/client.tsx +14 -0
- package/kernel/plugins/mail/src/flock.ts +137 -0
- package/kernel/plugins/mail/src/folders.ts +37 -0
- package/kernel/plugins/mail/src/history.ts +485 -0
- package/kernel/plugins/mail/src/index.ts +3 -0
- package/kernel/plugins/mail/src/mail-card.tsx +123 -0
- package/kernel/plugins/mail/src/mail-conversation.tsx +153 -0
- package/kernel/plugins/mail/src/mail-detail-page.tsx +467 -0
- package/kernel/plugins/mail/src/mail-hooks.ts +252 -0
- package/kernel/plugins/mail/src/mail-page.tsx +109 -0
- package/kernel/plugins/mail/src/mail-request.ts +78 -0
- package/kernel/plugins/mail/src/mail-send-box.tsx +175 -0
- package/kernel/plugins/mail/src/mailos.ts +723 -0
- package/kernel/plugins/mail/src/manifest.ts +7 -0
- package/kernel/plugins/mail/src/node.ts +171 -0
- package/kernel/plugins/mail/src/parse.ts +139 -0
- package/kernel/plugins/mail/src/server.ts +125 -0
- package/kernel/plugins/mail/src/types.ts +10 -0
- package/kernel/plugins/mail/src/viewer.tsx +147 -0
- package/kernel/plugins/mail/test/flock.test.mjs +156 -0
- package/kernel/plugins/mail/test/folders.test.mjs +138 -0
- package/kernel/plugins/mail/test/history.test.mjs +460 -0
- package/kernel/plugins/mail/test/mailos.test.mjs +752 -0
- package/kernel/plugins/mail/test/node.test.mjs +207 -0
- package/kernel/plugins/mail/test/package.test.mjs +54 -0
- package/kernel/plugins/mail/test/parse.test.mjs +32 -0
- package/kernel/plugins/mail/test/server.test.mjs +116 -0
- package/kernel/plugins/mail/test/viewer.test.mjs +192 -0
- package/kernel/plugins/mail/tsconfig.json +17 -0
- package/kernel/plugins/projects/SKILL.md +73 -0
- package/kernel/plugins/projects/eslint.config.js +10 -0
- package/kernel/plugins/projects/package.json +70 -0
- package/kernel/plugins/projects/src/client.tsx +17 -0
- package/kernel/plugins/projects/src/data/model.ts +129 -0
- package/kernel/plugins/projects/src/index.ts +17 -0
- package/kernel/plugins/projects/src/manifest.ts +7 -0
- package/kernel/plugins/projects/src/project-context.ts +41 -0
- package/kernel/plugins/projects/src/server.ts +276 -0
- package/kernel/plugins/projects/src/ui/project-card.tsx +61 -0
- package/kernel/plugins/projects/src/ui/projects-page.tsx +102 -0
- package/kernel/plugins/projects/test/package.test.mjs +51 -0
- package/kernel/plugins/projects/tsconfig.json +17 -0
- package/kernel/plugins/tasks/SKILL.md +341 -0
- package/kernel/plugins/tasks/eslint.config.js +10 -0
- package/kernel/plugins/tasks/package.json +74 -0
- package/kernel/plugins/tasks/schema.json +939 -0
- package/kernel/plugins/tasks/src/api.ts +212 -0
- package/kernel/plugins/tasks/src/client.tsx +23 -0
- package/kernel/plugins/tasks/src/data/parse.ts +544 -0
- package/kernel/plugins/tasks/src/data/task-id.ts +56 -0
- package/kernel/plugins/tasks/src/data/todo-model.ts +795 -0
- package/kernel/plugins/tasks/src/index.ts +34 -0
- package/kernel/plugins/tasks/src/manifest.ts +7 -0
- package/kernel/plugins/tasks/src/pages/task-detail.tsx +48 -0
- package/kernel/plugins/tasks/src/pages/task-list.tsx +88 -0
- package/kernel/plugins/tasks/src/server.ts +447 -0
- package/kernel/plugins/tasks/src/styles.css +9 -0
- package/kernel/plugins/tasks/src/ui/compact-todo-list.tsx +372 -0
- package/kernel/plugins/tasks/src/ui/error-details.tsx +78 -0
- package/kernel/plugins/tasks/src/ui/task-page.tsx +392 -0
- package/kernel/plugins/tasks/src/ui/todo-agent-filter.tsx +36 -0
- package/kernel/plugins/tasks/src/ui/todo-filter-bar.tsx +66 -0
- package/kernel/plugins/tasks/src/ui/todo-item.tsx +494 -0
- package/kernel/plugins/tasks/src/ui/todo-status-filter.tsx +60 -0
- package/kernel/plugins/tasks/src/ui/todo-tag-filter.tsx +48 -0
- package/kernel/plugins/tasks/src/ui/todo-warnings.tsx +106 -0
- package/kernel/plugins/tasks/test/api.test.mjs +99 -0
- package/kernel/plugins/tasks/test/folder-sources.test.mjs +46 -0
- package/kernel/plugins/tasks/test/package.test.mjs +54 -0
- package/kernel/plugins/tasks/test/parse.test.mjs +225 -0
- package/kernel/plugins/tasks/test/server.test.mjs +386 -0
- package/kernel/plugins/tasks/tsconfig.json +17 -0
- package/node_modules/@agentclientprotocol/sdk/LICENSE +191 -0
- package/node_modules/@agentclientprotocol/sdk/README.md +70 -0
- package/node_modules/@agentclientprotocol/sdk/dist/acp.d.ts +1835 -0
- package/node_modules/@agentclientprotocol/sdk/dist/acp.js +1885 -0
- package/node_modules/@agentclientprotocol/sdk/dist/acp.js.map +1 -0
- package/node_modules/@agentclientprotocol/sdk/dist/acp.test.d.ts +1 -0
- package/node_modules/@agentclientprotocol/sdk/dist/acp.test.js +5036 -0
- package/node_modules/@agentclientprotocol/sdk/dist/acp.test.js.map +1 -0
- package/node_modules/@agentclientprotocol/sdk/dist/connection.d.ts +82 -0
- package/node_modules/@agentclientprotocol/sdk/dist/connection.js +428 -0
- package/node_modules/@agentclientprotocol/sdk/dist/connection.js.map +1 -0
- package/node_modules/@agentclientprotocol/sdk/dist/connection.test.d.ts +1 -0
- package/node_modules/@agentclientprotocol/sdk/dist/connection.test.js +470 -0
- package/node_modules/@agentclientprotocol/sdk/dist/connection.test.js.map +1 -0
- package/node_modules/@agentclientprotocol/sdk/dist/cookie-store.d.ts +26 -0
- package/node_modules/@agentclientprotocol/sdk/dist/cookie-store.js +96 -0
- package/node_modules/@agentclientprotocol/sdk/dist/cookie-store.js.map +1 -0
- package/node_modules/@agentclientprotocol/sdk/dist/cookie-store.test.d.ts +1 -0
- package/node_modules/@agentclientprotocol/sdk/dist/cookie-store.test.js +77 -0
- package/node_modules/@agentclientprotocol/sdk/dist/cookie-store.test.js.map +1 -0
- package/node_modules/@agentclientprotocol/sdk/dist/examples/agent.d.ts +2 -0
- package/node_modules/@agentclientprotocol/sdk/dist/examples/agent.js +232 -0
- package/node_modules/@agentclientprotocol/sdk/dist/examples/agent.js.map +1 -0
- package/node_modules/@agentclientprotocol/sdk/dist/examples/client.d.ts +2 -0
- package/node_modules/@agentclientprotocol/sdk/dist/examples/client.js +132 -0
- package/node_modules/@agentclientprotocol/sdk/dist/examples/client.js.map +1 -0
- package/node_modules/@agentclientprotocol/sdk/dist/examples/dual-version-agent.d.ts +9 -0
- package/node_modules/@agentclientprotocol/sdk/dist/examples/dual-version-agent.js +221 -0
- package/node_modules/@agentclientprotocol/sdk/dist/examples/dual-version-agent.js.map +1 -0
- package/node_modules/@agentclientprotocol/sdk/dist/examples/http-client.d.ts +2 -0
- package/node_modules/@agentclientprotocol/sdk/dist/examples/http-client.js +86 -0
- package/node_modules/@agentclientprotocol/sdk/dist/examples/http-client.js.map +1 -0
- package/node_modules/@agentclientprotocol/sdk/dist/examples/http-server.d.ts +2 -0
- package/node_modules/@agentclientprotocol/sdk/dist/examples/http-server.js +112 -0
- package/node_modules/@agentclientprotocol/sdk/dist/examples/http-server.js.map +1 -0
- package/node_modules/@agentclientprotocol/sdk/dist/examples/ws-client.d.ts +2 -0
- package/node_modules/@agentclientprotocol/sdk/dist/examples/ws-client.js +88 -0
- package/node_modules/@agentclientprotocol/sdk/dist/examples/ws-client.js.map +1 -0
- package/node_modules/@agentclientprotocol/sdk/dist/http-stream.d.ts +33 -0
- package/node_modules/@agentclientprotocol/sdk/dist/http-stream.js +435 -0
- package/node_modules/@agentclientprotocol/sdk/dist/http-stream.js.map +1 -0
- package/node_modules/@agentclientprotocol/sdk/dist/http-stream.test.d.ts +1 -0
- package/node_modules/@agentclientprotocol/sdk/dist/http-stream.test.js +1380 -0
- package/node_modules/@agentclientprotocol/sdk/dist/http-stream.test.js.map +1 -0
- package/node_modules/@agentclientprotocol/sdk/dist/jsonrpc.d.ts +603 -0
- package/node_modules/@agentclientprotocol/sdk/dist/jsonrpc.js +1064 -0
- package/node_modules/@agentclientprotocol/sdk/dist/jsonrpc.js.map +1 -0
- package/node_modules/@agentclientprotocol/sdk/dist/jsonrpc.test.d.ts +1 -0
- package/node_modules/@agentclientprotocol/sdk/dist/jsonrpc.test.js +851 -0
- package/node_modules/@agentclientprotocol/sdk/dist/jsonrpc.test.js.map +1 -0
- package/node_modules/@agentclientprotocol/sdk/dist/line-buffer.d.ts +22 -0
- package/node_modules/@agentclientprotocol/sdk/dist/line-buffer.js +64 -0
- package/node_modules/@agentclientprotocol/sdk/dist/line-buffer.js.map +1 -0
- package/node_modules/@agentclientprotocol/sdk/dist/line-buffer.test.d.ts +1 -0
- package/node_modules/@agentclientprotocol/sdk/dist/line-buffer.test.js +45 -0
- package/node_modules/@agentclientprotocol/sdk/dist/line-buffer.test.js.map +1 -0
- package/node_modules/@agentclientprotocol/sdk/dist/node-adapter.d.ts +17 -0
- package/node_modules/@agentclientprotocol/sdk/dist/node-adapter.js +426 -0
- package/node_modules/@agentclientprotocol/sdk/dist/node-adapter.js.map +1 -0
- package/node_modules/@agentclientprotocol/sdk/dist/node-adapter.test.d.ts +1 -0
- package/node_modules/@agentclientprotocol/sdk/dist/node-adapter.test.js +499 -0
- package/node_modules/@agentclientprotocol/sdk/dist/node-adapter.test.js.map +1 -0
- package/node_modules/@agentclientprotocol/sdk/dist/protocol-router.d.ts +37 -0
- package/node_modules/@agentclientprotocol/sdk/dist/protocol-router.js +474 -0
- package/node_modules/@agentclientprotocol/sdk/dist/protocol-router.js.map +1 -0
- package/node_modules/@agentclientprotocol/sdk/dist/protocol-router.test.d.ts +1 -0
- package/node_modules/@agentclientprotocol/sdk/dist/protocol-router.test.js +535 -0
- package/node_modules/@agentclientprotocol/sdk/dist/protocol-router.test.js.map +1 -0
- package/node_modules/@agentclientprotocol/sdk/dist/protocol.d.ts +11 -0
- package/node_modules/@agentclientprotocol/sdk/dist/protocol.js +57 -0
- package/node_modules/@agentclientprotocol/sdk/dist/protocol.js.map +1 -0
- package/node_modules/@agentclientprotocol/sdk/dist/protocol.test.d.ts +1 -0
- package/node_modules/@agentclientprotocol/sdk/dist/protocol.test.js +73 -0
- package/node_modules/@agentclientprotocol/sdk/dist/protocol.test.js.map +1 -0
- package/node_modules/@agentclientprotocol/sdk/dist/schema/guards.gen.d.ts +199 -0
- package/node_modules/@agentclientprotocol/sdk/dist/schema/guards.gen.js +211 -0
- package/node_modules/@agentclientprotocol/sdk/dist/schema/guards.gen.js.map +1 -0
- package/node_modules/@agentclientprotocol/sdk/dist/schema/index.d.ts +51 -0
- package/node_modules/@agentclientprotocol/sdk/dist/schema/index.js +52 -0
- package/node_modules/@agentclientprotocol/sdk/dist/schema/index.js.map +1 -0
- package/node_modules/@agentclientprotocol/sdk/dist/schema/types.gen.d.ts +6118 -0
- package/node_modules/@agentclientprotocol/sdk/dist/schema/types.gen.js +3 -0
- package/node_modules/@agentclientprotocol/sdk/dist/schema/types.gen.js.map +1 -0
- package/node_modules/@agentclientprotocol/sdk/dist/schema/zod.gen.d.ts +14160 -0
- package/node_modules/@agentclientprotocol/sdk/dist/schema/zod.gen.js +3066 -0
- package/node_modules/@agentclientprotocol/sdk/dist/schema/zod.gen.js.map +1 -0
- package/node_modules/@agentclientprotocol/sdk/dist/schema-deserialize.d.ts +30 -0
- package/node_modules/@agentclientprotocol/sdk/dist/schema-deserialize.js +98 -0
- package/node_modules/@agentclientprotocol/sdk/dist/schema-deserialize.js.map +1 -0
- package/node_modules/@agentclientprotocol/sdk/dist/schema-deserialize.test.d.ts +1 -0
- package/node_modules/@agentclientprotocol/sdk/dist/schema-deserialize.test.js +93 -0
- package/node_modules/@agentclientprotocol/sdk/dist/schema-deserialize.test.js.map +1 -0
- package/node_modules/@agentclientprotocol/sdk/dist/server-permission.test.d.ts +1 -0
- package/node_modules/@agentclientprotocol/sdk/dist/server-permission.test.js +261 -0
- package/node_modules/@agentclientprotocol/sdk/dist/server-permission.test.js.map +1 -0
- package/node_modules/@agentclientprotocol/sdk/dist/server-session-sse.test.d.ts +1 -0
- package/node_modules/@agentclientprotocol/sdk/dist/server-session-sse.test.js +490 -0
- package/node_modules/@agentclientprotocol/sdk/dist/server-session-sse.test.js.map +1 -0
- package/node_modules/@agentclientprotocol/sdk/dist/server-sse.d.ts +2 -0
- package/node_modules/@agentclientprotocol/sdk/dist/server-sse.js +104 -0
- package/node_modules/@agentclientprotocol/sdk/dist/server-sse.js.map +1 -0
- package/node_modules/@agentclientprotocol/sdk/dist/server-sse.test.d.ts +1 -0
- package/node_modules/@agentclientprotocol/sdk/dist/server-sse.test.js +52 -0
- package/node_modules/@agentclientprotocol/sdk/dist/server-sse.test.js.map +1 -0
- package/node_modules/@agentclientprotocol/sdk/dist/server-websocket-upgrade.test.d.ts +1 -0
- package/node_modules/@agentclientprotocol/sdk/dist/server-websocket-upgrade.test.js +946 -0
- package/node_modules/@agentclientprotocol/sdk/dist/server-websocket-upgrade.test.js.map +1 -0
- package/node_modules/@agentclientprotocol/sdk/dist/server.d.ts +81 -0
- package/node_modules/@agentclientprotocol/sdk/dist/server.js +380 -0
- package/node_modules/@agentclientprotocol/sdk/dist/server.js.map +1 -0
- package/node_modules/@agentclientprotocol/sdk/dist/server.test.d.ts +1 -0
- package/node_modules/@agentclientprotocol/sdk/dist/server.test.js +1082 -0
- package/node_modules/@agentclientprotocol/sdk/dist/server.test.js.map +1 -0
- package/node_modules/@agentclientprotocol/sdk/dist/sse.d.ts +4 -0
- package/node_modules/@agentclientprotocol/sdk/dist/sse.js +91 -0
- package/node_modules/@agentclientprotocol/sdk/dist/sse.js.map +1 -0
- package/node_modules/@agentclientprotocol/sdk/dist/sse.test.d.ts +1 -0
- package/node_modules/@agentclientprotocol/sdk/dist/sse.test.js +126 -0
- package/node_modules/@agentclientprotocol/sdk/dist/sse.test.js.map +1 -0
- package/node_modules/@agentclientprotocol/sdk/dist/stream.d.ts +35 -0
- package/node_modules/@agentclientprotocol/sdk/dist/stream.js +106 -0
- package/node_modules/@agentclientprotocol/sdk/dist/stream.js.map +1 -0
- package/node_modules/@agentclientprotocol/sdk/dist/stream.test.d.ts +1 -0
- package/node_modules/@agentclientprotocol/sdk/dist/stream.test.js +206 -0
- package/node_modules/@agentclientprotocol/sdk/dist/stream.test.js.map +1 -0
- package/node_modules/@agentclientprotocol/sdk/dist/test-support/streams.d.ts +8 -0
- package/node_modules/@agentclientprotocol/sdk/dist/test-support/streams.js +51 -0
- package/node_modules/@agentclientprotocol/sdk/dist/test-support/streams.js.map +1 -0
- package/node_modules/@agentclientprotocol/sdk/dist/test-support/test-agent.d.ts +24 -0
- package/node_modules/@agentclientprotocol/sdk/dist/test-support/test-agent.js +163 -0
- package/node_modules/@agentclientprotocol/sdk/dist/test-support/test-agent.js.map +1 -0
- package/node_modules/@agentclientprotocol/sdk/dist/test-support/test-http-server.d.ts +9 -0
- package/node_modules/@agentclientprotocol/sdk/dist/test-support/test-http-server.js +74 -0
- package/node_modules/@agentclientprotocol/sdk/dist/test-support/test-http-server.js.map +1 -0
- package/node_modules/@agentclientprotocol/sdk/dist/v2/acp.d.ts +806 -0
- package/node_modules/@agentclientprotocol/sdk/dist/v2/acp.js +1183 -0
- package/node_modules/@agentclientprotocol/sdk/dist/v2/acp.js.map +1 -0
- package/node_modules/@agentclientprotocol/sdk/dist/v2/acp.test.d.ts +1 -0
- package/node_modules/@agentclientprotocol/sdk/dist/v2/acp.test.js +512 -0
- package/node_modules/@agentclientprotocol/sdk/dist/v2/acp.test.js.map +1 -0
- package/node_modules/@agentclientprotocol/sdk/dist/v2/schema/guards.gen.d.ts +954 -0
- package/node_modules/@agentclientprotocol/sdk/dist/v2/schema/guards.gen.js +1035 -0
- package/node_modules/@agentclientprotocol/sdk/dist/v2/schema/guards.gen.js.map +1 -0
- package/node_modules/@agentclientprotocol/sdk/dist/v2/schema/index.d.ts +42 -0
- package/node_modules/@agentclientprotocol/sdk/dist/v2/schema/index.js +43 -0
- package/node_modules/@agentclientprotocol/sdk/dist/v2/schema/index.js.map +1 -0
- package/node_modules/@agentclientprotocol/sdk/dist/v2/schema/types.gen.d.ts +6146 -0
- package/node_modules/@agentclientprotocol/sdk/dist/v2/schema/types.gen.js +3 -0
- package/node_modules/@agentclientprotocol/sdk/dist/v2/schema/types.gen.js.map +1 -0
- package/node_modules/@agentclientprotocol/sdk/dist/v2/schema/zod.gen.d.ts +30552 -0
- package/node_modules/@agentclientprotocol/sdk/dist/v2/schema/zod.gen.js +3204 -0
- package/node_modules/@agentclientprotocol/sdk/dist/v2/schema/zod.gen.js.map +1 -0
- package/node_modules/@agentclientprotocol/sdk/dist/ws-server.d.ts +14 -0
- package/node_modules/@agentclientprotocol/sdk/dist/ws-server.js +358 -0
- package/node_modules/@agentclientprotocol/sdk/dist/ws-server.js.map +1 -0
- package/node_modules/@agentclientprotocol/sdk/dist/ws-stream.d.ts +54 -0
- package/node_modules/@agentclientprotocol/sdk/dist/ws-stream.js +246 -0
- package/node_modules/@agentclientprotocol/sdk/dist/ws-stream.js.map +1 -0
- package/node_modules/@agentclientprotocol/sdk/dist/ws-stream.test.d.ts +1 -0
- package/node_modules/@agentclientprotocol/sdk/dist/ws-stream.test.js +833 -0
- package/node_modules/@agentclientprotocol/sdk/dist/ws-stream.test.js.map +1 -0
- package/node_modules/@agentclientprotocol/sdk/dist/ws-utils.d.ts +13 -0
- package/node_modules/@agentclientprotocol/sdk/dist/ws-utils.js +78 -0
- package/node_modules/@agentclientprotocol/sdk/dist/ws-utils.js.map +1 -0
- package/node_modules/@agentclientprotocol/sdk/dist/ws-utils.test.d.ts +1 -0
- package/node_modules/@agentclientprotocol/sdk/dist/ws-utils.test.js +42 -0
- package/node_modules/@agentclientprotocol/sdk/dist/ws-utils.test.js.map +1 -0
- package/node_modules/@agentclientprotocol/sdk/package.json +105 -0
- package/node_modules/@agentclientprotocol/sdk/schema/schema.json +8819 -0
- package/node_modules/@agentclientprotocol/sdk/schema/v2/schema.unstable.json +10098 -0
- package/package.json +52 -6
- package/web/assets/{abnfDiagram-VRR7QNED-Nfq-O04D.js → abnfDiagram-VRR7QNED-Bgfb1nEB.js} +1 -1
- package/web/assets/app-DoGr2Zi7.js +2 -0
- package/web/assets/app-options-D-RJiQ-X.js +25 -0
- package/web/assets/app-view-header-BLvLq02T.js +1 -0
- package/web/assets/arc-Dk_KI36B.js +1 -0
- package/web/assets/{architectureDiagram-ZJ3FMSHR-qhRwPNcQ.js → architectureDiagram-ZJ3FMSHR-NR_KhRCf.js} +1 -1
- package/web/assets/ask-tray-TzeTcO6-.js +14 -0
- package/web/assets/{blockDiagram-677ZJIJ3-C56P3bGu.js → blockDiagram-677ZJIJ3-CkLkwx9C.js} +1 -1
- package/web/assets/button-C6arH7zt.js +1 -0
- package/web/assets/{c4Diagram-LMCZKHZV-Ey1M72zD.js → c4Diagram-LMCZKHZV-CFCUH8e_.js} +1 -1
- package/web/assets/channel-uMEjV8qc.js +1 -0
- package/web/assets/{chunk-2Q5K7J3B-a6isk9VU.js → chunk-2Q5K7J3B-B_BPLWsW.js} +1 -1
- package/web/assets/{chunk-32BRIVSS-uy4kdSLL.js → chunk-32BRIVSS-B1VB1hOy.js} +1 -1
- package/web/assets/{chunk-5VM5RSS4-oj2sBFd7.js → chunk-5VM5RSS4-KFcYr8Co.js} +1 -1
- package/web/assets/{chunk-EX3LRPZG-Bzl1ukAi.js → chunk-EX3LRPZG-CpBX3kuK.js} +3 -3
- package/web/assets/{chunk-JWPE2WC7-sUph7I_t.js → chunk-JWPE2WC7-BPSl40wG.js} +1 -1
- package/web/assets/{chunk-MOJQB5TN-C0ERSuVK.js → chunk-MOJQB5TN-D2RcYmoU.js} +1 -1
- package/web/assets/{chunk-RYQCIY6F-Dyw1Hfwp.js → chunk-RYQCIY6F-m7Gyn-t3.js} +1 -1
- package/web/assets/{chunk-V7JOEXUC-DnSz22rb.js → chunk-V7JOEXUC-TDvdopxS.js} +1 -1
- package/web/assets/{chunk-VR4S4FIN-Bp2SNel7.js → chunk-VR4S4FIN-DZTsG51a.js} +1 -1
- package/web/assets/{chunk-XXDRQBXY-Dqtar746.js → chunk-XXDRQBXY-Dp0--RE2.js} +1 -1
- package/web/assets/classDiagram-OUVF2IWQ-fbZocVor.js +1 -0
- package/web/assets/classDiagram-v2-EOCWNBFH-fbZocVor.js +1 -0
- package/web/assets/client-C6Nxdfif.js +2 -0
- package/web/assets/client-CXYfBko5.js +17 -0
- package/web/assets/client-CoKtOq-X.js +7 -0
- package/web/assets/client-DyRQz5RU.js +53 -0
- package/web/assets/client-OY6HUzuD.js +98 -0
- package/web/assets/client-YOYWZIFi.js +34 -0
- package/web/assets/client-j2kQmxsO.js +22 -0
- package/web/assets/command-BugZBGXE.js +38 -0
- package/web/assets/copy-context-C0Uqsp-3.js +1 -0
- package/web/assets/{cose-bilkent-JH36ORCC-Dx1VqMjj.js → cose-bilkent-JH36ORCC-CPu3PI8h.js} +1 -1
- package/web/assets/{cynefin-VYW2F7L2-SjhCWmIV.js → cynefin-VYW2F7L2-DWxftYAm.js} +1 -1
- package/web/assets/{cynefinDiagram-TSTJHNR4-Dvqz2594.js → cynefinDiagram-TSTJHNR4-DsmN2V-p.js} +1 -1
- package/web/assets/{dagre-VKFMJZFB-Ju2m2qXt.js → dagre-VKFMJZFB-COEbApyY.js} +1 -1
- package/web/assets/{diagram-FQU43EPY-DsHKTt0k.js → diagram-FQU43EPY-0O9WGWKB.js} +1 -1
- package/web/assets/{diagram-G47NLZAW-DWHAcLkJ.js → diagram-G47NLZAW-CutEdMVh.js} +1 -1
- package/web/assets/{diagram-NH7WQ7WH-uUMz46ZD.js → diagram-NH7WQ7WH-C9KZc3B2.js} +1 -1
- package/web/assets/{diagram-OA4YK3LP-BRjVzjdp.js → diagram-OA4YK3LP-D8kkPXbY.js} +1 -1
- package/web/assets/{diagram-WEI45ONY-Cb-FhBpQ.js → diagram-WEI45ONY-_YqiTaGP.js} +1 -1
- package/web/assets/document-Dgt5eZFj.js +19 -0
- package/web/assets/{ebnfDiagram-CCIWWBDH-IhhxX3IB.js → ebnfDiagram-CCIWWBDH-JO-zQh6g.js} +1 -1
- package/web/assets/{entities-DUnx74kH.js → entities-C3wz7FCx.js} +12 -12
- package/web/assets/{erDiagram-Q63AITRT-D1frgeWf.js → erDiagram-Q63AITRT-9UjQwJ4P.js} +1 -1
- package/web/assets/file-viewer-DZJ8nYnl.js +1 -0
- package/web/assets/{flowDiagram-23GEKE2U-BiPPM-FY.js → flowDiagram-23GEKE2U-Ca08tnYM.js} +5 -5
- package/web/assets/folder-image-BfGgxo7i.js +1 -0
- package/web/assets/folder-landing-qUKBCnG-.js +54 -0
- package/web/assets/folder-list-BfFjv7rR.js +1 -0
- package/web/assets/folder-metadata-DCw8xzHk.js +2 -0
- package/web/assets/folder-mobile-bar-Ubz4babf.js +1 -0
- package/web/assets/folder-plugin-view-DsWR1zmQ.js +6 -0
- package/web/assets/{ganttDiagram-NO4QXBWP-CmEOlHD7.js → ganttDiagram-NO4QXBWP-KnHzX5W3.js} +1 -1
- package/web/assets/{gitGraphDiagram-IHSO6WYX-tTjcpZpU.js → gitGraphDiagram-IHSO6WYX-Cm8woNtK.js} +1 -1
- package/web/assets/index-BaRnbYRw.js +1 -0
- package/web/assets/index-BexmLxIP.css +1 -0
- package/web/assets/index-Bp9DidgD.js +1 -0
- package/web/assets/{index-eL1k96k8.js → index-CCXE8zc9.js} +1 -1
- package/web/assets/index-CNyy98F8.js +2 -0
- package/web/assets/{index-DmrKjrlM.js → index-CXhBn-ar.js} +1 -1
- package/web/assets/index-DDirZMgx.js +1 -0
- package/web/assets/{infoDiagram-FWYZ7A6U-Ok2sdbc1.js → infoDiagram-FWYZ7A6U-yyqmUtIb.js} +1 -1
- package/web/assets/{ishikawaDiagram-FXEZZL3T-kPnM5psX.js → ishikawaDiagram-FXEZZL3T-BfvR_Zy4.js} +4 -4
- package/web/assets/{journeyDiagram-5HDEW3XC-BkoT0-45.js → journeyDiagram-5HDEW3XC-BKuw06HM.js} +1 -1
- package/web/assets/{kanban-definition-HUTT4EX6-xnm_eFoU.js → kanban-definition-HUTT4EX6-n0010rmQ.js} +8 -8
- package/web/assets/{linear-CLZpgLH-.js → linear-C0d0lT8O.js} +1 -1
- package/web/assets/linked-session-header-BkEweU0Z.js +3 -0
- package/web/assets/{markdown-njUwQKsR.js → markdown-Bw9RgUGR.js} +9 -9
- package/web/assets/{mermaid.core-Bvxj3RoN.js → mermaid.core-BDVbShyO.js} +6 -6
- package/web/assets/metadata-KV0dpp4G.js +1 -0
- package/web/assets/{mindmap-definition-LN4V7U3C-42Uoox79.js → mindmap-definition-LN4V7U3C--_0ks3GF.js} +1 -1
- package/web/assets/note-card-DBfX6gW1.js +6 -0
- package/web/assets/{pegDiagram-2B236MQR-B-GZCw3w.js → pegDiagram-2B236MQR-CBoNIpKR.js} +1 -1
- package/web/assets/{pieDiagram-ENE6RG2P-DRmmssIB.js → pieDiagram-ENE6RG2P-MA5tkYh5.js} +3 -3
- package/web/assets/popover-DBD7FF-W.js +9 -0
- package/web/assets/{project-search-dialog-B730oZ1S.js → project-search-dialog-DM1IkSZu.js} +6 -6
- package/web/assets/{quadrantDiagram-ABIIQ3AL-BfhVQ7V9.js → quadrantDiagram-ABIIQ3AL-CWT1ryqF.js} +1 -1
- package/web/assets/{railroadDiagram-RFXS5EU6-DxKx7XRp.js → railroadDiagram-RFXS5EU6-ZiLB5FGi.js} +1 -1
- package/web/assets/{react-DZzLHL-l.js → react-B9jn2M18.js} +2 -2
- package/web/assets/{requirementDiagram-TGXJPOKE-NUzj9fw1.js → requirementDiagram-TGXJPOKE-CQq9uneq.js} +1 -1
- package/web/assets/{sankeyDiagram-HTMAVEWB-Cy9OMnl-.js → sankeyDiagram-HTMAVEWB-qDG-0JqI.js} +1 -1
- package/web/assets/search-DNrQA5fF.js +2 -0
- package/web/assets/select-D8cqNgcp.js +30 -0
- package/web/assets/selection-popup-DmtTeRs2.js +7 -0
- package/web/assets/{sequenceDiagram-DBY2YBRQ-CBNE9mzn.js → sequenceDiagram-DBY2YBRQ-CiApurLO.js} +1 -1
- package/web/assets/{sizeCapture-X5ZJPWSS-S4HhfX0n.js → sizeCapture-X5ZJPWSS-DZSR5QXm.js} +1 -1
- package/web/assets/stateDiagram-2N3HPSRC-CjJJR9_z.js +1 -0
- package/web/assets/stateDiagram-v2-6OUMAXLB-BpeGSCu9.js +1 -0
- package/web/assets/{swimlanes-5IMT3BWC-DJ2aLWal.js → swimlanes-5IMT3BWC-CKmo1sg6.js} +2 -2
- package/web/assets/swimlanesDiagram-G3AALYLV-D9RjLKb9.js +8 -0
- package/web/assets/tanstack-YzX_Mi37.js +3 -0
- package/web/assets/{timeline-definition-FHXFAJF6-vFDUVPCX.js → timeline-definition-FHXFAJF6-D-NMwS3y.js} +1 -1
- package/web/assets/{use-folder-filter-BbTUlXgG.js → use-folder-filter-LQyXns5Q.js} +1 -1
- package/web/assets/{utils-CwHGE3BB.js → utils-DCaHk0Gm.js} +1 -1
- package/web/assets/{vennDiagram-L72KCM5P-AsnhK2zW.js → vennDiagram-L72KCM5P-CfL6LBWw.js} +1 -1
- package/web/assets/view-context-gyDl_p2V.js +229 -0
- package/web/assets/viewer-capabilities-Bpp8Uvcg.js +1 -0
- package/web/assets/{wardleyDiagram-EHGQE667-Cj1wFbNV.js → wardleyDiagram-EHGQE667-DgldMxaj.js} +1 -1
- package/web/assets/{xychartDiagram-FW5EYKEG-Bbvnutsm.js → xychartDiagram-FW5EYKEG-CIoAIFX8.js} +1 -1
- package/web/favicon.svg +6 -0
- package/web/index.html +5 -4
- package/web/assets/app-CPSmsokP.js +0 -2
- package/web/assets/app-options-XEWvevsz.js +0 -25
- package/web/assets/app-view-header-BKZ90ToF.js +0 -1
- package/web/assets/arc-DbpbZvCt.js +0 -1
- package/web/assets/arrow-left-CFeHb-Z1.js +0 -1
- package/web/assets/ask-tray-D2YHtbPj.js +0 -14
- package/web/assets/button-BJ7z-ZA7.js +0 -1
- package/web/assets/calendar-days-DWh2XMO2.js +0 -1
- package/web/assets/channel-dSRp_qTo.js +0 -1
- package/web/assets/chevron-down-C5oRtqbX.js +0 -1
- package/web/assets/chevron-right-CsPtvh8C.js +0 -1
- package/web/assets/chevron-up-DjpU6Pyv.js +0 -1
- package/web/assets/classDiagram-OUVF2IWQ-B7B2zLzM.js +0 -1
- package/web/assets/classDiagram-v2-EOCWNBFH-B7B2zLzM.js +0 -1
- package/web/assets/client-CAudjYV9.js +0 -34
- package/web/assets/client-Dn9-_Gm_.js +0 -14
- package/web/assets/client-Dxrf2tyq.js +0 -102
- package/web/assets/client-aFI2M4pE.js +0 -53
- package/web/assets/collection-icon-TbOVyORG.js +0 -1
- package/web/assets/collection-page-Du6FKkuU.js +0 -10
- package/web/assets/command-C_g5E1Wx.js +0 -38
- package/web/assets/copy-Ikmr6Iq2.js +0 -1
- package/web/assets/copy-context-Cl1TE2PJ.js +0 -1
- package/web/assets/document-DcjNSJCk.js +0 -2
- package/web/assets/external-link-BXmSXqqF.js +0 -1
- package/web/assets/file-renderer-BRZTrYx8.js +0 -19
- package/web/assets/file-text-CiiSsCDq.js +0 -1
- package/web/assets/file-viewer-C1wAeVDK.js +0 -1
- package/web/assets/folder-image-AXBrHUcU.js +0 -1
- package/web/assets/folder-landing-BhRg7hwn.js +0 -54
- package/web/assets/folder-list-rIdszVde.js +0 -1
- package/web/assets/folder-metadata-puTC5QqJ.js +0 -2
- package/web/assets/folder-mobile-bar-DjjRQo3T.js +0 -1
- package/web/assets/folder-plugin-view-BU_kzR8j.js +0 -6
- package/web/assets/index-DS2Wmd9I.css +0 -1
- package/web/assets/index-DgqzSeIR.js +0 -1
- package/web/assets/index-DnlTDqaa.js +0 -1
- package/web/assets/index-DztTMDFz.js +0 -2
- package/web/assets/index-kY75qc96.js +0 -1
- package/web/assets/index-p38i_yyY.js +0 -1
- package/web/assets/link-2-BWKA6t--.js +0 -1
- package/web/assets/link-DC_1Z6Yy.js +0 -11
- package/web/assets/linked-session-header-DJYWZ_-q.js +0 -3
- package/web/assets/mail-2rCdIFul.js +0 -1
- package/web/assets/markdown-title-dncAYYiP.js +0 -131
- package/web/assets/notes-page-DIW6rgJp.js +0 -10
- package/web/assets/pencil-8cobiSSq.js +0 -1
- package/web/assets/plus-BHV2wJr7.js +0 -1
- package/web/assets/popover-Cmmgj-MJ.js +0 -9
- package/web/assets/search-CvlYUkN6.js +0 -2
- package/web/assets/select-1SvaKQsS.js +0 -30
- package/web/assets/selection-popup-ntjycEVh.js +0 -7
- package/web/assets/sparkles-CBhGREdc.js +0 -1
- package/web/assets/stateDiagram-2N3HPSRC-BEw1Mheu.js +0 -1
- package/web/assets/stateDiagram-v2-6OUMAXLB-BHtjl1iD.js +0 -1
- package/web/assets/swimlanesDiagram-G3AALYLV-Z362aroZ.js +0 -8
- package/web/assets/tanstack-CD46mJkU.js +0 -1
- package/web/assets/view-context-D-fh9AbH.js +0 -81
- package/web/assets/viewer-capabilities-CROIaoqh.js +0 -1
- package/web/assets/x-BUeE--I4.js +0 -1
|
@@ -0,0 +1,1183 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Experimental TypeScript API for the draft ACP v2 protocol.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* ACP v2 is still a draft. Its wire protocol and this API may change
|
|
6
|
+
* incompatibly in any SDK release. The stable package entry point remains ACP
|
|
7
|
+
* v1; consumers must opt in through
|
|
8
|
+
* `@agentclientprotocol/sdk/experimental/v2`.
|
|
9
|
+
*
|
|
10
|
+
* @packageDocumentation
|
|
11
|
+
* @experimental
|
|
12
|
+
*/
|
|
13
|
+
import * as schema from "./schema/index.js";
|
|
14
|
+
import * as validate from "./schema/zod.gen.js";
|
|
15
|
+
import * as guards from "./schema/guards.gen.js";
|
|
16
|
+
import { ndJsonStream as createJsonStream } from "../stream.js";
|
|
17
|
+
// Runtime narrowing helpers for extensible unions, exposed as companion values
|
|
18
|
+
// that merge (declaration merging) with the like-named types — e.g.
|
|
19
|
+
// `CreateElicitationResponse.isAccept(response)`. See schema/guards.gen.ts.
|
|
20
|
+
//
|
|
21
|
+
// Listed explicitly (not `export *`) so each value+type pair merges rather than
|
|
22
|
+
// colliding with the `export type *` above. The guards.gen re-export test
|
|
23
|
+
// asserts this list stays in sync as new extensible unions are added.
|
|
24
|
+
export { AuthMethod, AvailableCommandInput, ContentBlock, CreateElicitationRequest, CreateElicitationResponse, DiffChange, ElicitationPropertySchema, McpServer, MultiSelectItems, NesSuggestion, PlanUpdateContent, ReplayFrom, RequestPermissionOutcome, RequestPermissionSubject, SessionConfigOption, SessionUpdate, SetSessionConfigOptionRequest, StateUpdate, ToolCallContent, } from "./schema/guards.gen.js";
|
|
25
|
+
export { AGENT_METHODS, CLIENT_METHODS, PROTOCOL_METHODS, PROTOCOL_VERSION, } from "./schema/index.js";
|
|
26
|
+
/**
|
|
27
|
+
* Creates an experimental draft ACP v2 stream from newline-delimited JSON.
|
|
28
|
+
*
|
|
29
|
+
* Individual and batch JSON-RPC messages are accepted by default.
|
|
30
|
+
*
|
|
31
|
+
* @experimental
|
|
32
|
+
*/
|
|
33
|
+
export function ndJsonStream(output, input) {
|
|
34
|
+
return createJsonStream(output, input);
|
|
35
|
+
}
|
|
36
|
+
export { RequestError, batchNotification, batchRequest } from "../jsonrpc.js";
|
|
37
|
+
export { AgentProtocolRouter, agentProtocolRouter, } from "../protocol-router.js";
|
|
38
|
+
import { Connection, Handled, HandlerRegistration, RequestError, } from "../jsonrpc.js";
|
|
39
|
+
function emptyObjectResponse(response) {
|
|
40
|
+
return response ?? {};
|
|
41
|
+
}
|
|
42
|
+
function assertV2Method(method, builtIns, kind, allowProtocolNotification = false) {
|
|
43
|
+
if (Object.hasOwn(builtIns, method) ||
|
|
44
|
+
(allowProtocolNotification &&
|
|
45
|
+
method === schema.PROTOCOL_METHODS.cancel_request)) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
if (!method.startsWith("_")) {
|
|
49
|
+
throw new TypeError(`Custom ACP v2 ${kind} method '${method}' must start with '_'`);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
function assertV2BatchMethods(entries, requestMethods, notificationMethods) {
|
|
53
|
+
for (const entry of entries) {
|
|
54
|
+
assertV2Method(entry.method, entry.kind === "request" ? requestMethods : notificationMethods, entry.kind, entry.kind === "notification");
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
function parseV2InitializeRequest(params) {
|
|
58
|
+
const request = validate.zInitializeRequest.parse(params);
|
|
59
|
+
if (request.protocolVersion !== schema.PROTOCOL_VERSION) {
|
|
60
|
+
throw RequestError.invalidParams({
|
|
61
|
+
expectedProtocolVersion: schema.PROTOCOL_VERSION,
|
|
62
|
+
receivedProtocolVersion: request.protocolVersion,
|
|
63
|
+
}, `The v2 API only supports protocol version ${schema.PROTOCOL_VERSION}`);
|
|
64
|
+
}
|
|
65
|
+
return request;
|
|
66
|
+
}
|
|
67
|
+
function normalizeOutgoingV2InitializeRequest(params) {
|
|
68
|
+
const request = typeof params === "object" && params !== null && !Array.isArray(params)
|
|
69
|
+
? params
|
|
70
|
+
: {};
|
|
71
|
+
return parseV2InitializeRequest({
|
|
72
|
+
...request,
|
|
73
|
+
protocolVersion: schema.PROTOCOL_VERSION,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
function mapV2InitializeResponse(response) {
|
|
77
|
+
const parsed = validate.zInitializeResponse.parse(response);
|
|
78
|
+
if (parsed.protocolVersion !== schema.PROTOCOL_VERSION) {
|
|
79
|
+
throw RequestError.invalidRequest({
|
|
80
|
+
expectedProtocolVersion: schema.PROTOCOL_VERSION,
|
|
81
|
+
receivedProtocolVersion: parsed.protocolVersion,
|
|
82
|
+
}, `The v2 API only supports protocol version ${schema.PROTOCOL_VERSION}`);
|
|
83
|
+
}
|
|
84
|
+
return parsed;
|
|
85
|
+
}
|
|
86
|
+
function normalizeClientBatch(entries) {
|
|
87
|
+
return entries.map((entry) => {
|
|
88
|
+
if (entry.kind !== "request" ||
|
|
89
|
+
entry.method !== schema.AGENT_METHODS.initialize) {
|
|
90
|
+
return entry;
|
|
91
|
+
}
|
|
92
|
+
const mapResponse = entry.mapResponse;
|
|
93
|
+
return {
|
|
94
|
+
...entry,
|
|
95
|
+
params: normalizeOutgoingV2InitializeRequest(entry.params),
|
|
96
|
+
mapResponse: (response) => {
|
|
97
|
+
const parsed = mapV2InitializeResponse(response);
|
|
98
|
+
return mapResponse ? mapResponse(parsed) : parsed;
|
|
99
|
+
},
|
|
100
|
+
};
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
function isStream(value) {
|
|
104
|
+
return (typeof value === "object" &&
|
|
105
|
+
value !== null &&
|
|
106
|
+
"readable" in value &&
|
|
107
|
+
"writable" in value);
|
|
108
|
+
}
|
|
109
|
+
function memoryStreamPair() {
|
|
110
|
+
const leftToRight = new TransformStream();
|
|
111
|
+
const rightToLeft = new TransformStream();
|
|
112
|
+
return [
|
|
113
|
+
{
|
|
114
|
+
readable: rightToLeft.readable,
|
|
115
|
+
writable: leftToRight.writable,
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
readable: leftToRight.readable,
|
|
119
|
+
writable: rightToLeft.writable,
|
|
120
|
+
},
|
|
121
|
+
];
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* ACP method-name constants for the experimental draft v2 API.
|
|
125
|
+
*
|
|
126
|
+
* Use these with `onRequest(...)`, `onNotification(...)`, `request(...)`, and
|
|
127
|
+
* `notify(...)` when you want literal-string type inference without spelling
|
|
128
|
+
* protocol strings inline.
|
|
129
|
+
*
|
|
130
|
+
* @experimental
|
|
131
|
+
*/
|
|
132
|
+
export const methods = {
|
|
133
|
+
agent: {
|
|
134
|
+
initialize: schema.AGENT_METHODS.initialize,
|
|
135
|
+
auth: {
|
|
136
|
+
login: schema.AGENT_METHODS.auth_login,
|
|
137
|
+
logout: schema.AGENT_METHODS.auth_logout,
|
|
138
|
+
},
|
|
139
|
+
providers: {
|
|
140
|
+
list: schema.AGENT_METHODS.providers_list,
|
|
141
|
+
set: schema.AGENT_METHODS.providers_set,
|
|
142
|
+
disable: schema.AGENT_METHODS.providers_disable,
|
|
143
|
+
},
|
|
144
|
+
session: {
|
|
145
|
+
new: schema.AGENT_METHODS.session_new,
|
|
146
|
+
list: schema.AGENT_METHODS.session_list,
|
|
147
|
+
delete: schema.AGENT_METHODS.session_delete,
|
|
148
|
+
fork: schema.AGENT_METHODS.session_fork,
|
|
149
|
+
resume: schema.AGENT_METHODS.session_resume,
|
|
150
|
+
close: schema.AGENT_METHODS.session_close,
|
|
151
|
+
setConfigOption: schema.AGENT_METHODS.session_set_config_option,
|
|
152
|
+
prompt: schema.AGENT_METHODS.session_prompt,
|
|
153
|
+
cancel: schema.AGENT_METHODS.session_cancel,
|
|
154
|
+
},
|
|
155
|
+
mcp: {
|
|
156
|
+
message: schema.AGENT_METHODS.mcp_message,
|
|
157
|
+
},
|
|
158
|
+
nes: {
|
|
159
|
+
start: schema.AGENT_METHODS.nes_start,
|
|
160
|
+
suggest: schema.AGENT_METHODS.nes_suggest,
|
|
161
|
+
accept: schema.AGENT_METHODS.nes_accept,
|
|
162
|
+
reject: schema.AGENT_METHODS.nes_reject,
|
|
163
|
+
close: schema.AGENT_METHODS.nes_close,
|
|
164
|
+
},
|
|
165
|
+
document: {
|
|
166
|
+
didOpen: schema.AGENT_METHODS.document_did_open,
|
|
167
|
+
didChange: schema.AGENT_METHODS.document_did_change,
|
|
168
|
+
didClose: schema.AGENT_METHODS.document_did_close,
|
|
169
|
+
didSave: schema.AGENT_METHODS.document_did_save,
|
|
170
|
+
didFocus: schema.AGENT_METHODS.document_did_focus,
|
|
171
|
+
},
|
|
172
|
+
},
|
|
173
|
+
client: {
|
|
174
|
+
session: {
|
|
175
|
+
requestPermission: schema.CLIENT_METHODS.session_request_permission,
|
|
176
|
+
update: schema.CLIENT_METHODS.session_update,
|
|
177
|
+
},
|
|
178
|
+
mcp: {
|
|
179
|
+
connect: schema.CLIENT_METHODS.mcp_connect,
|
|
180
|
+
message: schema.CLIENT_METHODS.mcp_message,
|
|
181
|
+
disconnect: schema.CLIENT_METHODS.mcp_disconnect,
|
|
182
|
+
},
|
|
183
|
+
elicitation: {
|
|
184
|
+
create: schema.CLIENT_METHODS.elicitation_create,
|
|
185
|
+
complete: schema.CLIENT_METHODS.elicitation_complete,
|
|
186
|
+
},
|
|
187
|
+
},
|
|
188
|
+
protocol: {
|
|
189
|
+
cancelRequest: schema.PROTOCOL_METHODS.cancel_request,
|
|
190
|
+
},
|
|
191
|
+
};
|
|
192
|
+
const startActiveSession = Symbol("startActiveSession");
|
|
193
|
+
class AcpContext {
|
|
194
|
+
cx;
|
|
195
|
+
currentRequestId;
|
|
196
|
+
/** @internal */
|
|
197
|
+
constructor(cx, currentRequestId) {
|
|
198
|
+
this.cx = cx;
|
|
199
|
+
this.currentRequestId = currentRequestId;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* JSON-RPC id of the request currently being handled.
|
|
203
|
+
*
|
|
204
|
+
* This is `undefined` for notification handlers and for contexts created
|
|
205
|
+
* outside an inbound request, such as `connect(...)` and `connectWith(...)`.
|
|
206
|
+
*/
|
|
207
|
+
get requestId() {
|
|
208
|
+
return this.currentRequestId;
|
|
209
|
+
}
|
|
210
|
+
/** @internal */
|
|
211
|
+
get connectionContext() {
|
|
212
|
+
return this.cx;
|
|
213
|
+
}
|
|
214
|
+
/** @internal */
|
|
215
|
+
sendRequest(method, params, mapResponse, options) {
|
|
216
|
+
return this.cx.sendRequest(method, params, mapResponse, options);
|
|
217
|
+
}
|
|
218
|
+
/** @internal */
|
|
219
|
+
sendNotification(method, params) {
|
|
220
|
+
return this.cx.sendNotification(method, params);
|
|
221
|
+
}
|
|
222
|
+
/** @internal */
|
|
223
|
+
sendBatch(entries) {
|
|
224
|
+
return this.cx.sendBatch(entries);
|
|
225
|
+
}
|
|
226
|
+
/** @internal */
|
|
227
|
+
addDynamicHandler(handler) {
|
|
228
|
+
return this.cx.addDynamicHandler(handler);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Experimental draft ACP v2 context passed to agent-side handlers.
|
|
233
|
+
*
|
|
234
|
+
* Agents use this context to call client-side ACP methods while handling
|
|
235
|
+
* requests such as `session/prompt`.
|
|
236
|
+
*
|
|
237
|
+
* @experimental
|
|
238
|
+
*/
|
|
239
|
+
export class AgentContext extends AcpContext {
|
|
240
|
+
constructor(cx, requestId) {
|
|
241
|
+
super(cx, requestId);
|
|
242
|
+
}
|
|
243
|
+
/** @internal */
|
|
244
|
+
static create(cx, requestId) {
|
|
245
|
+
return new AgentContext(cx, requestId);
|
|
246
|
+
}
|
|
247
|
+
request(method, params, options) {
|
|
248
|
+
assertV2Method(method, clientRequestSpecsByMethod, "request");
|
|
249
|
+
const spec = clientRequestSpecsByMethod[method];
|
|
250
|
+
return this.sendRequest(method, params, spec?.mapResponse, options);
|
|
251
|
+
}
|
|
252
|
+
notify(method, params) {
|
|
253
|
+
assertV2Method(method, clientNotificationSpecsByMethod, "notification", true);
|
|
254
|
+
return this.sendNotification(method, params);
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Sends requests and notifications to the client as one JSON-RPC batch.
|
|
258
|
+
*/
|
|
259
|
+
batch(entries) {
|
|
260
|
+
assertV2BatchMethods(entries, clientRequestSpecsByMethod, clientNotificationSpecsByMethod);
|
|
261
|
+
return this.sendBatch(entries);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Experimental draft ACP v2 context used by clients to call agent-side ACP
|
|
266
|
+
* methods.
|
|
267
|
+
*
|
|
268
|
+
* `connectWith` passes a `ClientContext` to the callback. Client handlers also
|
|
269
|
+
* receive one as `ctx.agent` when they need to call back into the agent.
|
|
270
|
+
*
|
|
271
|
+
* @experimental
|
|
272
|
+
*/
|
|
273
|
+
export class ClientContext extends AcpContext {
|
|
274
|
+
constructor(cx, requestId) {
|
|
275
|
+
super(cx, requestId);
|
|
276
|
+
}
|
|
277
|
+
/** @internal */
|
|
278
|
+
static create(cx, requestId) {
|
|
279
|
+
return new ClientContext(cx, requestId);
|
|
280
|
+
}
|
|
281
|
+
/** @internal */
|
|
282
|
+
[startActiveSession](params, options) {
|
|
283
|
+
return this.sendRequest(schema.AGENT_METHODS.session_new, params, (response) => this.attachSession(response), options);
|
|
284
|
+
}
|
|
285
|
+
buildSession(cwdOrRequest) {
|
|
286
|
+
if (typeof cwdOrRequest === "string") {
|
|
287
|
+
return SessionBuilder.create(this, {
|
|
288
|
+
cwd: cwdOrRequest,
|
|
289
|
+
mcpServers: [],
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
return SessionBuilder.create(this, cwdOrRequest);
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Builds active-session helpers around a `session/new` response.
|
|
296
|
+
*/
|
|
297
|
+
attachSession(response) {
|
|
298
|
+
const updates = new AsyncQueue();
|
|
299
|
+
const activePrompts = new Set();
|
|
300
|
+
const activeSessionQueue = {
|
|
301
|
+
enqueue: (value) => updates.enqueue(value),
|
|
302
|
+
reject: (error) => updates.reject(error),
|
|
303
|
+
clearErrors: () => updates.clearErrors(),
|
|
304
|
+
fail: (error) => updates.fail(error),
|
|
305
|
+
next: () => updates.next(),
|
|
306
|
+
nextAfter: (cursor, signal) => updates.nextAfter(cursor, signal),
|
|
307
|
+
beginPrompt: () => {
|
|
308
|
+
const prompt = {
|
|
309
|
+
updateCursor: updates.cursor(),
|
|
310
|
+
overlapController: new AbortController(),
|
|
311
|
+
};
|
|
312
|
+
if (activePrompts.size > 0) {
|
|
313
|
+
const error = new Error("readText() cannot attribute updates across overlapping prompts; use nextUpdate() instead");
|
|
314
|
+
for (const activePrompt of activePrompts) {
|
|
315
|
+
activePrompt.overlapController.abort(error);
|
|
316
|
+
}
|
|
317
|
+
prompt.overlapController.abort(error);
|
|
318
|
+
}
|
|
319
|
+
activePrompts.add(prompt);
|
|
320
|
+
return prompt;
|
|
321
|
+
},
|
|
322
|
+
cancelPrompt: (prompt) => activePrompts.delete(prompt),
|
|
323
|
+
isAwaitingPromptCompletion: () => activePrompts.size > 0,
|
|
324
|
+
completePrompt: () => {
|
|
325
|
+
activePrompts.clear();
|
|
326
|
+
},
|
|
327
|
+
};
|
|
328
|
+
const closeSignal = this.connectionContext.signal;
|
|
329
|
+
const failUpdatesOnClose = () => {
|
|
330
|
+
updates.fail(closeSignal.reason ?? new Error("ACP connection closed"));
|
|
331
|
+
};
|
|
332
|
+
if (closeSignal.aborted) {
|
|
333
|
+
failUpdatesOnClose();
|
|
334
|
+
}
|
|
335
|
+
else {
|
|
336
|
+
closeSignal.addEventListener("abort", failUpdatesOnClose);
|
|
337
|
+
}
|
|
338
|
+
const sessionRegistration = sessionUpdateRouter(this.connectionContext).attach(response, activeSessionQueue);
|
|
339
|
+
const closeRegistration = new HandlerRegistration(() => {
|
|
340
|
+
closeSignal.removeEventListener("abort", failUpdatesOnClose);
|
|
341
|
+
});
|
|
342
|
+
return ActiveSession.create(this, response, activeSessionQueue, [
|
|
343
|
+
sessionRegistration,
|
|
344
|
+
closeRegistration,
|
|
345
|
+
]);
|
|
346
|
+
}
|
|
347
|
+
request(method, params, options) {
|
|
348
|
+
assertV2Method(method, agentRequestSpecsByMethod, "request");
|
|
349
|
+
const spec = agentRequestSpecsByMethod[method];
|
|
350
|
+
const wireParams = method === schema.AGENT_METHODS.initialize
|
|
351
|
+
? normalizeOutgoingV2InitializeRequest(params)
|
|
352
|
+
: params;
|
|
353
|
+
return this.sendRequest(method, wireParams, spec?.mapResponse, options);
|
|
354
|
+
}
|
|
355
|
+
notify(method, params) {
|
|
356
|
+
assertV2Method(method, agentNotificationSpecsByMethod, "notification", true);
|
|
357
|
+
return this.sendNotification(method, params);
|
|
358
|
+
}
|
|
359
|
+
/**
|
|
360
|
+
* Sends requests and notifications to the agent as one JSON-RPC batch.
|
|
361
|
+
*/
|
|
362
|
+
batch(entries) {
|
|
363
|
+
assertV2BatchMethods(entries, agentRequestSpecsByMethod, agentNotificationSpecsByMethod);
|
|
364
|
+
return this.sendBatch(normalizeClientBatch(entries));
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
class AcpConnectionHandle {
|
|
368
|
+
connection;
|
|
369
|
+
constructor(connection) {
|
|
370
|
+
this.connection = connection;
|
|
371
|
+
}
|
|
372
|
+
get signal() {
|
|
373
|
+
return this.connection.signal;
|
|
374
|
+
}
|
|
375
|
+
get closed() {
|
|
376
|
+
return this.connection.closed;
|
|
377
|
+
}
|
|
378
|
+
close(error) {
|
|
379
|
+
this.connection.close(error);
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
class AgentConnectionHandle extends AcpConnectionHandle {
|
|
383
|
+
connectHandlers;
|
|
384
|
+
client;
|
|
385
|
+
didStartConnectHandlers = false;
|
|
386
|
+
constructor(connection, connectHandlers = []) {
|
|
387
|
+
super(connection);
|
|
388
|
+
this.connectHandlers = connectHandlers;
|
|
389
|
+
this.client = AgentContext.create(connection.getContext());
|
|
390
|
+
}
|
|
391
|
+
/** @internal */
|
|
392
|
+
startConnectHandlers() {
|
|
393
|
+
if (this.didStartConnectHandlers) {
|
|
394
|
+
return;
|
|
395
|
+
}
|
|
396
|
+
this.didStartConnectHandlers = true;
|
|
397
|
+
runConnectHandlers(this, this.connectHandlers);
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
class ClientConnectionHandle extends AcpConnectionHandle {
|
|
401
|
+
connectHandlers;
|
|
402
|
+
agent;
|
|
403
|
+
didStartConnectHandlers = false;
|
|
404
|
+
constructor(connection, connectHandlers = []) {
|
|
405
|
+
super(connection);
|
|
406
|
+
this.connectHandlers = connectHandlers;
|
|
407
|
+
this.agent = ClientContext.create(connection.getContext());
|
|
408
|
+
}
|
|
409
|
+
/** @internal */
|
|
410
|
+
startConnectHandlers() {
|
|
411
|
+
if (this.didStartConnectHandlers) {
|
|
412
|
+
return;
|
|
413
|
+
}
|
|
414
|
+
this.didStartConnectHandlers = true;
|
|
415
|
+
runConnectHandlers(this, this.connectHandlers);
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
function agentConnection(connection, connectHandlers = []) {
|
|
419
|
+
return new AgentConnectionHandle(connection, connectHandlers);
|
|
420
|
+
}
|
|
421
|
+
function clientConnection(connection, connectHandlers = []) {
|
|
422
|
+
return new ClientConnectionHandle(connection, connectHandlers);
|
|
423
|
+
}
|
|
424
|
+
class AsyncQueue {
|
|
425
|
+
values = [];
|
|
426
|
+
waiters = [];
|
|
427
|
+
failed = false;
|
|
428
|
+
failure;
|
|
429
|
+
nextSequence = 0;
|
|
430
|
+
enqueue(value) {
|
|
431
|
+
if (this.failed) {
|
|
432
|
+
return;
|
|
433
|
+
}
|
|
434
|
+
const sequence = this.nextSequence++;
|
|
435
|
+
const waiter = this.waiters.shift();
|
|
436
|
+
if (waiter) {
|
|
437
|
+
waiter.resolve(value);
|
|
438
|
+
}
|
|
439
|
+
else {
|
|
440
|
+
this.values.push({ kind: "value", value, sequence });
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
reject(error) {
|
|
444
|
+
if (this.failed) {
|
|
445
|
+
return;
|
|
446
|
+
}
|
|
447
|
+
const sequence = this.nextSequence++;
|
|
448
|
+
if (this.waiters.length > 0) {
|
|
449
|
+
for (const waiter of this.waiters.splice(0)) {
|
|
450
|
+
waiter.reject(error);
|
|
451
|
+
}
|
|
452
|
+
return;
|
|
453
|
+
}
|
|
454
|
+
this.values.push({ kind: "error", error, sequence });
|
|
455
|
+
}
|
|
456
|
+
clearErrors() {
|
|
457
|
+
this.values = this.values.filter((entry) => entry.kind === "value");
|
|
458
|
+
}
|
|
459
|
+
cursor() {
|
|
460
|
+
return this.nextSequence;
|
|
461
|
+
}
|
|
462
|
+
nextAfter(cursor, signal) {
|
|
463
|
+
if (signal?.aborted) {
|
|
464
|
+
return Promise.reject(signal.reason);
|
|
465
|
+
}
|
|
466
|
+
while (this.values[0] && this.values[0].sequence < cursor) {
|
|
467
|
+
this.values.shift();
|
|
468
|
+
}
|
|
469
|
+
return this.next(signal);
|
|
470
|
+
}
|
|
471
|
+
fail(error) {
|
|
472
|
+
if (this.failed) {
|
|
473
|
+
return;
|
|
474
|
+
}
|
|
475
|
+
this.failed = true;
|
|
476
|
+
this.failure = error;
|
|
477
|
+
for (const waiter of this.waiters.splice(0)) {
|
|
478
|
+
waiter.reject(error);
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
next(signal) {
|
|
482
|
+
if (signal?.aborted) {
|
|
483
|
+
return Promise.reject(signal.reason);
|
|
484
|
+
}
|
|
485
|
+
if (this.values.length > 0) {
|
|
486
|
+
const entry = this.values.shift();
|
|
487
|
+
if (entry.kind === "error") {
|
|
488
|
+
return Promise.reject(entry.error);
|
|
489
|
+
}
|
|
490
|
+
return Promise.resolve(entry.value);
|
|
491
|
+
}
|
|
492
|
+
if (this.failed) {
|
|
493
|
+
return Promise.reject(this.failure);
|
|
494
|
+
}
|
|
495
|
+
return new Promise((resolve, reject) => {
|
|
496
|
+
const cleanup = () => {
|
|
497
|
+
signal?.removeEventListener("abort", onAbort);
|
|
498
|
+
};
|
|
499
|
+
const waiter = {
|
|
500
|
+
resolve: (value) => {
|
|
501
|
+
cleanup();
|
|
502
|
+
resolve(value);
|
|
503
|
+
},
|
|
504
|
+
reject: (error) => {
|
|
505
|
+
cleanup();
|
|
506
|
+
reject(error);
|
|
507
|
+
},
|
|
508
|
+
};
|
|
509
|
+
const onAbort = () => {
|
|
510
|
+
const index = this.waiters.indexOf(waiter);
|
|
511
|
+
if (index >= 0) {
|
|
512
|
+
this.waiters.splice(index, 1);
|
|
513
|
+
}
|
|
514
|
+
waiter.reject(signal?.reason);
|
|
515
|
+
};
|
|
516
|
+
this.waiters.push(waiter);
|
|
517
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
518
|
+
if (signal?.aborted) {
|
|
519
|
+
onAbort();
|
|
520
|
+
}
|
|
521
|
+
});
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
function cloneNewSessionRequest(request) {
|
|
525
|
+
return structuredClone(request);
|
|
526
|
+
}
|
|
527
|
+
/**
|
|
528
|
+
* Experimental draft ACP v2 builder for creating an `ActiveSession`.
|
|
529
|
+
*
|
|
530
|
+
* Start from `ctx.buildSession("/absolute/cwd")` for the common case, or
|
|
531
|
+
* pass a full `NewSessionRequest` to `ctx.buildSession(...)` when the session
|
|
532
|
+
* needs MCP servers, `_meta`, or additional request fields. All paths in ACP
|
|
533
|
+
* payloads should be absolute.
|
|
534
|
+
*
|
|
535
|
+
* @experimental
|
|
536
|
+
*/
|
|
537
|
+
export class SessionBuilder {
|
|
538
|
+
cx;
|
|
539
|
+
request;
|
|
540
|
+
constructor(cx, request) {
|
|
541
|
+
this.cx = cx;
|
|
542
|
+
this.request = cloneNewSessionRequest(request);
|
|
543
|
+
}
|
|
544
|
+
/** @internal */
|
|
545
|
+
static create(cx, request) {
|
|
546
|
+
return new SessionBuilder(cx, request);
|
|
547
|
+
}
|
|
548
|
+
/**
|
|
549
|
+
* Returns the `session/new` request that will be sent.
|
|
550
|
+
*
|
|
551
|
+
* The returned object is a defensive copy, so mutating it does not change the
|
|
552
|
+
* builder.
|
|
553
|
+
*/
|
|
554
|
+
toRequest() {
|
|
555
|
+
return cloneNewSessionRequest(this.request);
|
|
556
|
+
}
|
|
557
|
+
/**
|
|
558
|
+
* Replaces the additional workspace roots for this session.
|
|
559
|
+
*
|
|
560
|
+
* `additionalDirectories` expand the session's file-system scope without
|
|
561
|
+
* changing `cwd`. Each path should be absolute.
|
|
562
|
+
*/
|
|
563
|
+
withAdditionalDirectories(additionalDirectories) {
|
|
564
|
+
this.request = {
|
|
565
|
+
...this.request,
|
|
566
|
+
additionalDirectories: [...additionalDirectories],
|
|
567
|
+
};
|
|
568
|
+
return this;
|
|
569
|
+
}
|
|
570
|
+
/**
|
|
571
|
+
* Adds one MCP server to the `session/new` request.
|
|
572
|
+
*/
|
|
573
|
+
withMcpServer(mcpServer) {
|
|
574
|
+
this.request = {
|
|
575
|
+
...this.request,
|
|
576
|
+
mcpServers: [
|
|
577
|
+
...(this.request.mcpServers ?? []),
|
|
578
|
+
structuredClone(mcpServer),
|
|
579
|
+
],
|
|
580
|
+
};
|
|
581
|
+
return this;
|
|
582
|
+
}
|
|
583
|
+
/**
|
|
584
|
+
* Starts the session and returns an `ActiveSession` for prompting and reading
|
|
585
|
+
* updates.
|
|
586
|
+
*
|
|
587
|
+
* Call `dispose()` on the returned session when you no longer need update
|
|
588
|
+
* routing, or use `withSession(...)` to scope disposal automatically.
|
|
589
|
+
*/
|
|
590
|
+
async start(options) {
|
|
591
|
+
return this.cx[startActiveSession](this.toRequest(), options);
|
|
592
|
+
}
|
|
593
|
+
/**
|
|
594
|
+
* Starts the session, runs `op`, and disposes the active-session update
|
|
595
|
+
* routing when `op` finishes or throws.
|
|
596
|
+
*/
|
|
597
|
+
async withSession(op) {
|
|
598
|
+
const session = await this.start();
|
|
599
|
+
try {
|
|
600
|
+
return await op(session);
|
|
601
|
+
}
|
|
602
|
+
finally {
|
|
603
|
+
session.dispose();
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
/**
|
|
608
|
+
* Experimental draft ACP v2 convenience wrapper for an active session.
|
|
609
|
+
*
|
|
610
|
+
* An active session routes `session/update` notifications for one session ID
|
|
611
|
+
* into an async queue. Use `prompt(...)` to send user content, then read updates
|
|
612
|
+
* with `nextUpdate()` until a `stop` message is returned.
|
|
613
|
+
*
|
|
614
|
+
* @experimental
|
|
615
|
+
*/
|
|
616
|
+
export class ActiveSession {
|
|
617
|
+
cx;
|
|
618
|
+
sessionResponse;
|
|
619
|
+
updates;
|
|
620
|
+
registrations;
|
|
621
|
+
latestPrompt;
|
|
622
|
+
constructor(cx, sessionResponse, updates, registrations) {
|
|
623
|
+
this.cx = cx;
|
|
624
|
+
this.sessionResponse = sessionResponse;
|
|
625
|
+
this.updates = updates;
|
|
626
|
+
this.registrations = registrations;
|
|
627
|
+
}
|
|
628
|
+
/** @internal */
|
|
629
|
+
static create(cx, sessionResponse, updates, registrations) {
|
|
630
|
+
return new ActiveSession(cx, sessionResponse, updates, registrations);
|
|
631
|
+
}
|
|
632
|
+
/**
|
|
633
|
+
* Session ID returned by `session/new`.
|
|
634
|
+
*/
|
|
635
|
+
get sessionId() {
|
|
636
|
+
return this.sessionResponse.sessionId;
|
|
637
|
+
}
|
|
638
|
+
/**
|
|
639
|
+
* Configuration options returned when the session was created, if provided.
|
|
640
|
+
*/
|
|
641
|
+
get configOptions() {
|
|
642
|
+
return this.sessionResponse.configOptions;
|
|
643
|
+
}
|
|
644
|
+
/**
|
|
645
|
+
* Metadata returned when the session was created.
|
|
646
|
+
*/
|
|
647
|
+
get meta() {
|
|
648
|
+
return this.sessionResponse._meta;
|
|
649
|
+
}
|
|
650
|
+
/**
|
|
651
|
+
* Full response returned by `session/new`.
|
|
652
|
+
*/
|
|
653
|
+
get newSessionResponse() {
|
|
654
|
+
return this.sessionResponse;
|
|
655
|
+
}
|
|
656
|
+
/**
|
|
657
|
+
* Sends a prompt to this session.
|
|
658
|
+
*
|
|
659
|
+
* Strings are converted to one text content block. A single content block is
|
|
660
|
+
* wrapped in an array. The returned promise resolves when the agent accepts
|
|
661
|
+
* the prompt. Completion is reported separately by an idle `state_update`,
|
|
662
|
+
* which is queued as a `stop` message for `nextUpdate()`.
|
|
663
|
+
*/
|
|
664
|
+
prompt(prompt, options) {
|
|
665
|
+
this.updates.clearErrors();
|
|
666
|
+
const activePrompt = this.updates.beginPrompt();
|
|
667
|
+
this.latestPrompt = activePrompt;
|
|
668
|
+
const response = this.cx.request(schema.AGENT_METHODS.session_prompt, {
|
|
669
|
+
sessionId: this.sessionId,
|
|
670
|
+
prompt: this.promptBlocks(prompt),
|
|
671
|
+
}, options);
|
|
672
|
+
void response.catch((error) => {
|
|
673
|
+
if (this.updates.cancelPrompt(activePrompt)) {
|
|
674
|
+
this.updates.reject(error);
|
|
675
|
+
}
|
|
676
|
+
});
|
|
677
|
+
return response;
|
|
678
|
+
}
|
|
679
|
+
/**
|
|
680
|
+
* Reads the next update or stop message for this session.
|
|
681
|
+
*/
|
|
682
|
+
nextUpdate() {
|
|
683
|
+
return this.updates.next();
|
|
684
|
+
}
|
|
685
|
+
/**
|
|
686
|
+
* Reads agent text until the current prompt turn stops.
|
|
687
|
+
*
|
|
688
|
+
* Updates queued before the most recent call to `prompt(...)` are skipped.
|
|
689
|
+
* Call prompts serially, after the preceding turn reports `stop`: session
|
|
690
|
+
* updates do not carry a prompt ID and cannot be attributed across overlapping
|
|
691
|
+
* prompt requests. Use `nextUpdate()` when coordinating requests directly.
|
|
692
|
+
*
|
|
693
|
+
* Full `agent_message` updates replace content for their `messageId`, while
|
|
694
|
+
* `agent_message_chunk` updates append to it. Non-text content and other
|
|
695
|
+
* update types are ignored; use `nextUpdate()` when you need them.
|
|
696
|
+
*/
|
|
697
|
+
async readText() {
|
|
698
|
+
const activePrompt = this.latestPrompt;
|
|
699
|
+
const updateCursor = activePrompt?.updateCursor;
|
|
700
|
+
const messageOrder = [];
|
|
701
|
+
const messageContent = new Map();
|
|
702
|
+
const ensureMessage = (messageId) => {
|
|
703
|
+
let content = messageContent.get(messageId);
|
|
704
|
+
if (!content) {
|
|
705
|
+
content = [];
|
|
706
|
+
messageOrder.push(messageId);
|
|
707
|
+
messageContent.set(messageId, content);
|
|
708
|
+
}
|
|
709
|
+
return content;
|
|
710
|
+
};
|
|
711
|
+
for (;;) {
|
|
712
|
+
const message = updateCursor === undefined
|
|
713
|
+
? await this.nextUpdate()
|
|
714
|
+
: await this.updates.nextAfter(updateCursor, activePrompt?.overlapController.signal);
|
|
715
|
+
if (message.kind === "stop") {
|
|
716
|
+
return messageOrder
|
|
717
|
+
.flatMap((messageId) => messageContent.get(messageId) ?? [])
|
|
718
|
+
.filter(guards.ContentBlock.isText)
|
|
719
|
+
.map((content) => content.text)
|
|
720
|
+
.join("");
|
|
721
|
+
}
|
|
722
|
+
const { update } = message;
|
|
723
|
+
if (guards.SessionUpdate.isAgentMessage(update)) {
|
|
724
|
+
ensureMessage(update.messageId);
|
|
725
|
+
if (update.content !== undefined) {
|
|
726
|
+
messageContent.set(update.messageId, update.content ?? []);
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
else if (guards.SessionUpdate.isAgentMessageChunk(update)) {
|
|
730
|
+
ensureMessage(update.messageId).push(update.content);
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
/**
|
|
735
|
+
* Stops routing updates to this active-session helper.
|
|
736
|
+
*
|
|
737
|
+
* This does not close the ACP session on the agent. Use `ClientContext`
|
|
738
|
+
* session lifecycle methods when the protocol session itself should be closed
|
|
739
|
+
* or deleted.
|
|
740
|
+
*/
|
|
741
|
+
dispose() {
|
|
742
|
+
for (const registration of this.registrations.splice(0)) {
|
|
743
|
+
registration.dispose();
|
|
744
|
+
}
|
|
745
|
+
this.updates.fail(new Error("Active session disposed"));
|
|
746
|
+
}
|
|
747
|
+
/**
|
|
748
|
+
* Supports explicit resource management with `using`.
|
|
749
|
+
*/
|
|
750
|
+
[Symbol.dispose]() {
|
|
751
|
+
this.dispose();
|
|
752
|
+
}
|
|
753
|
+
promptBlocks(prompt) {
|
|
754
|
+
if (typeof prompt === "string") {
|
|
755
|
+
return [{ type: "text", text: prompt }];
|
|
756
|
+
}
|
|
757
|
+
if (Array.isArray(prompt)) {
|
|
758
|
+
return prompt;
|
|
759
|
+
}
|
|
760
|
+
return [prompt];
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
function parseParams(parser, params) {
|
|
764
|
+
if (!parser) {
|
|
765
|
+
return params;
|
|
766
|
+
}
|
|
767
|
+
if (typeof parser === "function") {
|
|
768
|
+
return parser(params);
|
|
769
|
+
}
|
|
770
|
+
return parser.parse(params);
|
|
771
|
+
}
|
|
772
|
+
function requestSpec(method, params, mapResponse) {
|
|
773
|
+
return { method, params, mapResponse };
|
|
774
|
+
}
|
|
775
|
+
function notificationSpec(method, params) {
|
|
776
|
+
return { method, params };
|
|
777
|
+
}
|
|
778
|
+
function registerAppRequest(builder, spec, context, handler) {
|
|
779
|
+
builder.onReceiveRequest(spec.method, (params) => parseParams(spec.params, params), async (params, responder, cx) => {
|
|
780
|
+
const response = await handler(context(params, cx, responder.signal, responder.id));
|
|
781
|
+
await responder.respond((spec.mapResponse
|
|
782
|
+
? spec.mapResponse(response)
|
|
783
|
+
: response));
|
|
784
|
+
});
|
|
785
|
+
}
|
|
786
|
+
function registerAppNotification(builder, spec, context, handler) {
|
|
787
|
+
builder.onReceiveNotification(spec.method, (params) => parseParams(spec.params, params), (params, cx) => handler(context(params, cx, cx.signal)));
|
|
788
|
+
}
|
|
789
|
+
function specsByMethod(specs) {
|
|
790
|
+
const byMethod = Object.create(null);
|
|
791
|
+
for (const spec of Object.values(specs)) {
|
|
792
|
+
byMethod[spec.method] = spec;
|
|
793
|
+
}
|
|
794
|
+
return byMethod;
|
|
795
|
+
}
|
|
796
|
+
const agentRequestSpecs = {
|
|
797
|
+
initialize: requestSpec(schema.AGENT_METHODS.initialize, parseV2InitializeRequest, mapV2InitializeResponse),
|
|
798
|
+
loginAuth: requestSpec(schema.AGENT_METHODS.auth_login, validate.zLoginAuthRequest, emptyObjectResponse),
|
|
799
|
+
unstable_listProviders: requestSpec(schema.AGENT_METHODS.providers_list, validate.zListProvidersRequest),
|
|
800
|
+
unstable_setProvider: requestSpec(schema.AGENT_METHODS.providers_set, validate.zSetProviderRequest, emptyObjectResponse),
|
|
801
|
+
unstable_disableProvider: requestSpec(schema.AGENT_METHODS.providers_disable, validate.zDisableProviderRequest, emptyObjectResponse),
|
|
802
|
+
newSession: requestSpec(schema.AGENT_METHODS.session_new, validate.zNewSessionRequest),
|
|
803
|
+
setSessionConfigOption: requestSpec(schema.AGENT_METHODS.session_set_config_option, validate.zSetSessionConfigOptionRequest),
|
|
804
|
+
prompt: requestSpec(schema.AGENT_METHODS.session_prompt, validate.zPromptRequest, emptyObjectResponse),
|
|
805
|
+
unstable_messageMcp: requestSpec(schema.AGENT_METHODS.mcp_message, validate.zMessageMcpRequest),
|
|
806
|
+
listSessions: requestSpec(schema.AGENT_METHODS.session_list, validate.zListSessionsRequest),
|
|
807
|
+
deleteSession: requestSpec(schema.AGENT_METHODS.session_delete, validate.zDeleteSessionRequest, emptyObjectResponse),
|
|
808
|
+
unstable_forkSession: requestSpec(schema.AGENT_METHODS.session_fork, validate.zForkSessionRequest),
|
|
809
|
+
resumeSession: requestSpec(schema.AGENT_METHODS.session_resume, validate.zResumeSessionRequest),
|
|
810
|
+
closeSession: requestSpec(schema.AGENT_METHODS.session_close, validate.zCloseSessionRequest, emptyObjectResponse),
|
|
811
|
+
logoutAuth: requestSpec(schema.AGENT_METHODS.auth_logout, validate.zLogoutAuthRequest, emptyObjectResponse),
|
|
812
|
+
unstable_startNes: requestSpec(schema.AGENT_METHODS.nes_start, validate.zStartNesRequest),
|
|
813
|
+
unstable_suggestNes: requestSpec(schema.AGENT_METHODS.nes_suggest, validate.zSuggestNesRequest),
|
|
814
|
+
unstable_closeNes: requestSpec(schema.AGENT_METHODS.nes_close, validate.zCloseNesRequest, emptyObjectResponse),
|
|
815
|
+
};
|
|
816
|
+
const agentNotificationSpecs = {
|
|
817
|
+
cancelSession: notificationSpec(schema.AGENT_METHODS.session_cancel, validate.zCancelSessionNotification),
|
|
818
|
+
unstable_messageMcp: notificationSpec(schema.AGENT_METHODS.mcp_message, validate.zMessageMcpNotification),
|
|
819
|
+
unstable_didOpenDocument: notificationSpec(schema.AGENT_METHODS.document_did_open, validate.zDidOpenDocumentNotification),
|
|
820
|
+
unstable_didChangeDocument: notificationSpec(schema.AGENT_METHODS.document_did_change, validate.zDidChangeDocumentNotification),
|
|
821
|
+
unstable_didCloseDocument: notificationSpec(schema.AGENT_METHODS.document_did_close, validate.zDidCloseDocumentNotification),
|
|
822
|
+
unstable_didSaveDocument: notificationSpec(schema.AGENT_METHODS.document_did_save, validate.zDidSaveDocumentNotification),
|
|
823
|
+
unstable_didFocusDocument: notificationSpec(schema.AGENT_METHODS.document_did_focus, validate.zDidFocusDocumentNotification),
|
|
824
|
+
unstable_acceptNes: notificationSpec(schema.AGENT_METHODS.nes_accept, validate.zAcceptNesNotification),
|
|
825
|
+
unstable_rejectNes: notificationSpec(schema.AGENT_METHODS.nes_reject, validate.zRejectNesNotification),
|
|
826
|
+
};
|
|
827
|
+
const clientRequestSpecs = {
|
|
828
|
+
requestPermission: requestSpec(schema.CLIENT_METHODS.session_request_permission, validate.zRequestPermissionRequest),
|
|
829
|
+
unstable_connectMcp: requestSpec(schema.CLIENT_METHODS.mcp_connect, validate.zConnectMcpRequest),
|
|
830
|
+
unstable_messageMcp: requestSpec(schema.CLIENT_METHODS.mcp_message, validate.zMessageMcpRequest),
|
|
831
|
+
unstable_disconnectMcp: requestSpec(schema.CLIENT_METHODS.mcp_disconnect, validate.zDisconnectMcpRequest, emptyObjectResponse),
|
|
832
|
+
unstable_createElicitation: requestSpec(schema.CLIENT_METHODS.elicitation_create, validate.zCreateElicitationRequest),
|
|
833
|
+
};
|
|
834
|
+
const clientNotificationSpecs = {
|
|
835
|
+
sessionUpdate: notificationSpec(schema.CLIENT_METHODS.session_update, validate.zUpdateSessionNotification),
|
|
836
|
+
unstable_messageMcp: notificationSpec(schema.CLIENT_METHODS.mcp_message, validate.zMessageMcpNotification),
|
|
837
|
+
unstable_completeElicitation: notificationSpec(schema.CLIENT_METHODS.elicitation_complete, validate.zCompleteElicitationNotification),
|
|
838
|
+
};
|
|
839
|
+
const agentRequestSpecsByMethod = specsByMethod(agentRequestSpecs);
|
|
840
|
+
const agentNotificationSpecsByMethod = specsByMethod(agentNotificationSpecs);
|
|
841
|
+
const clientRequestSpecsByMethod = specsByMethod(clientRequestSpecs);
|
|
842
|
+
const clientNotificationSpecsByMethod = specsByMethod(clientNotificationSpecs);
|
|
843
|
+
function agentRequestContext(params, client, signal, requestId) {
|
|
844
|
+
return {
|
|
845
|
+
params,
|
|
846
|
+
requestId,
|
|
847
|
+
signal,
|
|
848
|
+
client,
|
|
849
|
+
};
|
|
850
|
+
}
|
|
851
|
+
function agentNotificationContext(params, client, signal) {
|
|
852
|
+
return {
|
|
853
|
+
params,
|
|
854
|
+
signal,
|
|
855
|
+
client,
|
|
856
|
+
};
|
|
857
|
+
}
|
|
858
|
+
function clientRequestContext(params, agent, signal, requestId) {
|
|
859
|
+
return {
|
|
860
|
+
params,
|
|
861
|
+
requestId,
|
|
862
|
+
signal,
|
|
863
|
+
agent,
|
|
864
|
+
};
|
|
865
|
+
}
|
|
866
|
+
function clientNotificationContext(params, agent, signal) {
|
|
867
|
+
return {
|
|
868
|
+
params,
|
|
869
|
+
signal,
|
|
870
|
+
agent,
|
|
871
|
+
};
|
|
872
|
+
}
|
|
873
|
+
class SessionUpdateRouter {
|
|
874
|
+
activeSessions = new Map();
|
|
875
|
+
handleMessage(message) {
|
|
876
|
+
if (message.kind !== "notification" ||
|
|
877
|
+
message.method !== schema.CLIENT_METHODS.session_update) {
|
|
878
|
+
return Handled.no(message);
|
|
879
|
+
}
|
|
880
|
+
const notification = validate.zUpdateSessionNotification.parse(message.params);
|
|
881
|
+
const { update } = notification;
|
|
882
|
+
const isIdle = guards.SessionUpdate.isStateUpdate(update) &&
|
|
883
|
+
guards.StateUpdate.isIdle(update);
|
|
884
|
+
const activeSessions = this.activeSessions.get(notification.sessionId);
|
|
885
|
+
if (activeSessions && activeSessions.size > 0) {
|
|
886
|
+
for (const session of activeSessions) {
|
|
887
|
+
if (isIdle && session.isAwaitingPromptCompletion()) {
|
|
888
|
+
session.completePrompt();
|
|
889
|
+
session.enqueue({
|
|
890
|
+
kind: "stop",
|
|
891
|
+
notification,
|
|
892
|
+
update,
|
|
893
|
+
stopReason: update.stopReason,
|
|
894
|
+
});
|
|
895
|
+
}
|
|
896
|
+
else {
|
|
897
|
+
session.enqueue({
|
|
898
|
+
kind: "session_update",
|
|
899
|
+
notification,
|
|
900
|
+
update,
|
|
901
|
+
});
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
}
|
|
905
|
+
return Handled.no(message);
|
|
906
|
+
}
|
|
907
|
+
attach(response, updates) {
|
|
908
|
+
const sessions = this.activeSessions.get(response.sessionId) ??
|
|
909
|
+
new Set();
|
|
910
|
+
sessions.add(updates);
|
|
911
|
+
this.activeSessions.set(response.sessionId, sessions);
|
|
912
|
+
return new HandlerRegistration(() => {
|
|
913
|
+
sessions.delete(updates);
|
|
914
|
+
if (sessions.size === 0) {
|
|
915
|
+
this.activeSessions.delete(response.sessionId);
|
|
916
|
+
}
|
|
917
|
+
});
|
|
918
|
+
}
|
|
919
|
+
}
|
|
920
|
+
const sessionUpdateRouters = new WeakMap();
|
|
921
|
+
function sessionUpdateRouter(cx) {
|
|
922
|
+
let router = sessionUpdateRouters.get(cx);
|
|
923
|
+
if (!router) {
|
|
924
|
+
router = new SessionUpdateRouter();
|
|
925
|
+
sessionUpdateRouters.set(cx, router);
|
|
926
|
+
}
|
|
927
|
+
return router;
|
|
928
|
+
}
|
|
929
|
+
function runConnectHandlers(connection, handlers) {
|
|
930
|
+
for (const handler of handlers) {
|
|
931
|
+
let result;
|
|
932
|
+
try {
|
|
933
|
+
result = handler(connection);
|
|
934
|
+
}
|
|
935
|
+
catch (error) {
|
|
936
|
+
connection.close(error);
|
|
937
|
+
throw error;
|
|
938
|
+
}
|
|
939
|
+
void Promise.resolve(result).catch((error) => {
|
|
940
|
+
connection.close(error);
|
|
941
|
+
});
|
|
942
|
+
}
|
|
943
|
+
}
|
|
944
|
+
const appBuilder = Symbol("appBuilder");
|
|
945
|
+
const runAgentConnectHandlers = Symbol("runAgentConnectHandlers");
|
|
946
|
+
const runClientConnectHandlers = Symbol("runClientConnectHandlers");
|
|
947
|
+
/**
|
|
948
|
+
* Creates an agent-side app for the experimental draft ACP v2 API.
|
|
949
|
+
*
|
|
950
|
+
* Register request and notification handlers by ACP method name, then call
|
|
951
|
+
* `connect(stream)` to serve an ACP client.
|
|
952
|
+
*
|
|
953
|
+
* @experimental
|
|
954
|
+
*/
|
|
955
|
+
export function agent(options) {
|
|
956
|
+
return new AgentApp(options);
|
|
957
|
+
}
|
|
958
|
+
/**
|
|
959
|
+
* Agent-side app builder for the experimental draft ACP v2 API.
|
|
960
|
+
*
|
|
961
|
+
* Methods on this class register typed request or notification handlers and
|
|
962
|
+
* return `this`, so apps can be built with a fluent chain. Handler params are
|
|
963
|
+
* parsed with the generated ACP schemas before your handler runs, and thrown
|
|
964
|
+
* errors are converted to JSON-RPC errors by the connection layer.
|
|
965
|
+
*
|
|
966
|
+
* @experimental
|
|
967
|
+
*/
|
|
968
|
+
export class AgentApp {
|
|
969
|
+
builder = Connection.builder();
|
|
970
|
+
connectHandlers = [];
|
|
971
|
+
constructor(options = {}) {
|
|
972
|
+
if (options.name) {
|
|
973
|
+
this.builder.name(options.name);
|
|
974
|
+
}
|
|
975
|
+
}
|
|
976
|
+
/** @internal */
|
|
977
|
+
[appBuilder]() {
|
|
978
|
+
return this.builder;
|
|
979
|
+
}
|
|
980
|
+
/** @internal */
|
|
981
|
+
[runAgentConnectHandlers](connection) {
|
|
982
|
+
runConnectHandlers(connection, this.connectHandlers);
|
|
983
|
+
}
|
|
984
|
+
connect(target, options = {}) {
|
|
985
|
+
return this.connectConnection(target, options).connection;
|
|
986
|
+
}
|
|
987
|
+
connectWith(target, op) {
|
|
988
|
+
const { rawConnection, connection } = this.connectConnection(target);
|
|
989
|
+
return rawConnection.runUntil(() => op(connection.client));
|
|
990
|
+
}
|
|
991
|
+
/**
|
|
992
|
+
* Registers a handler that runs when this agent app opens a connection.
|
|
993
|
+
*
|
|
994
|
+
* Use this for connection-scoped work that needs to call client-side ACP
|
|
995
|
+
* methods outside an inbound request handler.
|
|
996
|
+
*/
|
|
997
|
+
onConnect(handler) {
|
|
998
|
+
this.connectHandlers.push(handler);
|
|
999
|
+
return this;
|
|
1000
|
+
}
|
|
1001
|
+
onRequest(method, handlerOrParams, handler) {
|
|
1002
|
+
if (handler) {
|
|
1003
|
+
assertV2Method(method, agentRequestSpecsByMethod, "request");
|
|
1004
|
+
return this.request({ method, params: handlerOrParams }, handler);
|
|
1005
|
+
}
|
|
1006
|
+
const spec = agentRequestSpecsByMethod[method];
|
|
1007
|
+
if (!spec) {
|
|
1008
|
+
throw new Error(`Unknown ACP request method '${method}'. Pass a params parser for custom methods.`);
|
|
1009
|
+
}
|
|
1010
|
+
return this.request(spec, handlerOrParams);
|
|
1011
|
+
}
|
|
1012
|
+
onNotification(method, handlerOrParams, handler) {
|
|
1013
|
+
if (handler) {
|
|
1014
|
+
assertV2Method(method, agentNotificationSpecsByMethod, "notification", true);
|
|
1015
|
+
return this.notification({ method, params: handlerOrParams }, handler);
|
|
1016
|
+
}
|
|
1017
|
+
const spec = agentNotificationSpecsByMethod[method];
|
|
1018
|
+
if (!spec) {
|
|
1019
|
+
throw new Error(`Unknown ACP notification method '${method}'. Pass a params parser for custom methods.`);
|
|
1020
|
+
}
|
|
1021
|
+
return this.notification(spec, handlerOrParams);
|
|
1022
|
+
}
|
|
1023
|
+
request(spec, handler) {
|
|
1024
|
+
registerAppRequest(this.builder, spec, (params, cx, signal, requestId) => agentRequestContext(params, AgentContext.create(cx, requestId), signal, requestId), handler);
|
|
1025
|
+
return this;
|
|
1026
|
+
}
|
|
1027
|
+
notification(spec, handler) {
|
|
1028
|
+
registerAppNotification(this.builder, spec, (params, cx, signal) => agentNotificationContext(params, AgentContext.create(cx), signal), handler);
|
|
1029
|
+
return this;
|
|
1030
|
+
}
|
|
1031
|
+
connectConnection(target, options = {}) {
|
|
1032
|
+
if (isStream(target)) {
|
|
1033
|
+
const state = this.openStreamConnection(target);
|
|
1034
|
+
if (!options.deferConnectHandlers) {
|
|
1035
|
+
this[runAgentConnectHandlers](state.connection);
|
|
1036
|
+
}
|
|
1037
|
+
return state;
|
|
1038
|
+
}
|
|
1039
|
+
const [thisStream, peerStream] = memoryStreamPair();
|
|
1040
|
+
const peerRawConnection = target[appBuilder]().connect(peerStream);
|
|
1041
|
+
const peerConnection = clientConnection(peerRawConnection);
|
|
1042
|
+
const state = this.openStreamConnection(thisStream);
|
|
1043
|
+
void state.rawConnection.closed.then(() => peerConnection.close());
|
|
1044
|
+
void peerRawConnection.closed.then(() => state.connection.close());
|
|
1045
|
+
try {
|
|
1046
|
+
target[runClientConnectHandlers](peerConnection);
|
|
1047
|
+
this[runAgentConnectHandlers](state.connection);
|
|
1048
|
+
}
|
|
1049
|
+
catch (error) {
|
|
1050
|
+
peerConnection.close(error);
|
|
1051
|
+
state.connection.close(error);
|
|
1052
|
+
throw error;
|
|
1053
|
+
}
|
|
1054
|
+
return state;
|
|
1055
|
+
}
|
|
1056
|
+
openStreamConnection(stream) {
|
|
1057
|
+
const rawConnection = this.builder.connect(stream);
|
|
1058
|
+
return {
|
|
1059
|
+
rawConnection,
|
|
1060
|
+
connection: agentConnection(rawConnection, this.connectHandlers),
|
|
1061
|
+
};
|
|
1062
|
+
}
|
|
1063
|
+
}
|
|
1064
|
+
/**
|
|
1065
|
+
* Creates a client-side app for the experimental draft ACP v2 API.
|
|
1066
|
+
*
|
|
1067
|
+
* Register request and notification handlers by ACP method name, then use
|
|
1068
|
+
* `connectWith(...)` to run the workflow that calls agent-side methods.
|
|
1069
|
+
*
|
|
1070
|
+
* @experimental
|
|
1071
|
+
*/
|
|
1072
|
+
export function client(options) {
|
|
1073
|
+
return new ClientApp(options);
|
|
1074
|
+
}
|
|
1075
|
+
/**
|
|
1076
|
+
* Client-side app builder for the experimental draft ACP v2 API.
|
|
1077
|
+
*
|
|
1078
|
+
* Methods on this class register typed client handlers and return `this`, so
|
|
1079
|
+
* apps can be built with a fluent chain. `connectWith(...)` is the usual entry
|
|
1080
|
+
* point for clients because it provides a `ClientContext` for calling
|
|
1081
|
+
* agent-side requests and session helpers.
|
|
1082
|
+
*
|
|
1083
|
+
* @experimental
|
|
1084
|
+
*/
|
|
1085
|
+
export class ClientApp {
|
|
1086
|
+
builder = Connection.builder();
|
|
1087
|
+
connectHandlers = [];
|
|
1088
|
+
constructor(options = {}) {
|
|
1089
|
+
if (options.name) {
|
|
1090
|
+
this.builder.name(options.name);
|
|
1091
|
+
}
|
|
1092
|
+
this.builder.withHandler({
|
|
1093
|
+
handleMessage: (message, cx) => sessionUpdateRouter(cx).handleMessage(message),
|
|
1094
|
+
describe: () => "client-session-update-router",
|
|
1095
|
+
});
|
|
1096
|
+
}
|
|
1097
|
+
/** @internal */
|
|
1098
|
+
[appBuilder]() {
|
|
1099
|
+
return this.builder;
|
|
1100
|
+
}
|
|
1101
|
+
/** @internal */
|
|
1102
|
+
[runClientConnectHandlers](connection) {
|
|
1103
|
+
runConnectHandlers(connection, this.connectHandlers);
|
|
1104
|
+
}
|
|
1105
|
+
connect(target) {
|
|
1106
|
+
return this.connectConnection(target).connection;
|
|
1107
|
+
}
|
|
1108
|
+
connectWith(target, op) {
|
|
1109
|
+
const { rawConnection, connection } = this.connectConnection(target);
|
|
1110
|
+
return rawConnection.runUntil(() => op(connection.agent));
|
|
1111
|
+
}
|
|
1112
|
+
/**
|
|
1113
|
+
* Registers a handler that runs when this client app opens a connection.
|
|
1114
|
+
*
|
|
1115
|
+
* Use this for connection-scoped work that needs to call agent-side ACP
|
|
1116
|
+
* methods outside an inbound request handler.
|
|
1117
|
+
*/
|
|
1118
|
+
onConnect(handler) {
|
|
1119
|
+
this.connectHandlers.push(handler);
|
|
1120
|
+
return this;
|
|
1121
|
+
}
|
|
1122
|
+
onRequest(method, handlerOrParams, handler) {
|
|
1123
|
+
if (handler) {
|
|
1124
|
+
assertV2Method(method, clientRequestSpecsByMethod, "request");
|
|
1125
|
+
return this.request({ method, params: handlerOrParams }, handler);
|
|
1126
|
+
}
|
|
1127
|
+
const spec = clientRequestSpecsByMethod[method];
|
|
1128
|
+
if (!spec) {
|
|
1129
|
+
throw new Error(`Unknown ACP request method '${method}'. Pass a params parser for custom methods.`);
|
|
1130
|
+
}
|
|
1131
|
+
return this.request(spec, handlerOrParams);
|
|
1132
|
+
}
|
|
1133
|
+
onNotification(method, handlerOrParams, handler) {
|
|
1134
|
+
if (handler) {
|
|
1135
|
+
assertV2Method(method, clientNotificationSpecsByMethod, "notification", true);
|
|
1136
|
+
return this.notification({ method, params: handlerOrParams }, handler);
|
|
1137
|
+
}
|
|
1138
|
+
const spec = clientNotificationSpecsByMethod[method];
|
|
1139
|
+
if (!spec) {
|
|
1140
|
+
throw new Error(`Unknown ACP notification method '${method}'. Pass a params parser for custom methods.`);
|
|
1141
|
+
}
|
|
1142
|
+
return this.notification(spec, handlerOrParams);
|
|
1143
|
+
}
|
|
1144
|
+
request(spec, handler) {
|
|
1145
|
+
registerAppRequest(this.builder, spec, (params, cx, signal, requestId) => clientRequestContext(params, ClientContext.create(cx, requestId), signal, requestId), handler);
|
|
1146
|
+
return this;
|
|
1147
|
+
}
|
|
1148
|
+
notification(spec, handler) {
|
|
1149
|
+
registerAppNotification(this.builder, spec, (params, cx, signal) => clientNotificationContext(params, ClientContext.create(cx), signal), handler);
|
|
1150
|
+
return this;
|
|
1151
|
+
}
|
|
1152
|
+
connectConnection(target) {
|
|
1153
|
+
if (isStream(target)) {
|
|
1154
|
+
const state = this.openStreamConnection(target);
|
|
1155
|
+
this[runClientConnectHandlers](state.connection);
|
|
1156
|
+
return state;
|
|
1157
|
+
}
|
|
1158
|
+
const [thisStream, peerStream] = memoryStreamPair();
|
|
1159
|
+
const peerRawConnection = target[appBuilder]().connect(peerStream);
|
|
1160
|
+
const peerConnection = agentConnection(peerRawConnection);
|
|
1161
|
+
const state = this.openStreamConnection(thisStream);
|
|
1162
|
+
void state.rawConnection.closed.then(() => peerConnection.close());
|
|
1163
|
+
void peerRawConnection.closed.then(() => state.connection.close());
|
|
1164
|
+
try {
|
|
1165
|
+
target[runAgentConnectHandlers](peerConnection);
|
|
1166
|
+
this[runClientConnectHandlers](state.connection);
|
|
1167
|
+
}
|
|
1168
|
+
catch (error) {
|
|
1169
|
+
peerConnection.close(error);
|
|
1170
|
+
state.connection.close(error);
|
|
1171
|
+
throw error;
|
|
1172
|
+
}
|
|
1173
|
+
return state;
|
|
1174
|
+
}
|
|
1175
|
+
openStreamConnection(stream) {
|
|
1176
|
+
const rawConnection = this.builder.connect(stream);
|
|
1177
|
+
return {
|
|
1178
|
+
rawConnection,
|
|
1179
|
+
connection: clientConnection(rawConnection, this.connectHandlers),
|
|
1180
|
+
};
|
|
1181
|
+
}
|
|
1182
|
+
}
|
|
1183
|
+
//# sourceMappingURL=acp.js.map
|