@agent-native/core 0.80.8 → 0.80.10
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/corpus/README.md +2 -2
- package/corpus/core/CHANGELOG.md +19 -0
- package/corpus/core/docs/content/locales/ar-SA/template-design.mdx +6 -0
- package/corpus/core/docs/content/locales/de-DE/template-design.mdx +8 -0
- package/corpus/core/docs/content/locales/es-ES/template-design.mdx +10 -2
- package/corpus/core/docs/content/locales/fr-FR/template-design.mdx +10 -2
- package/corpus/core/docs/content/locales/hi-IN/template-design.mdx +7 -0
- package/corpus/core/docs/content/locales/ja-JP/template-design.mdx +7 -0
- package/corpus/core/docs/content/locales/ko-KR/template-design.mdx +7 -0
- package/corpus/core/docs/content/locales/pt-BR/template-design.mdx +9 -2
- package/corpus/core/docs/content/locales/zh-CN/template-design.mdx +6 -0
- package/corpus/core/docs/content/locales/zh-TW/template-design.mdx +6 -0
- package/corpus/core/docs/content/template-design.mdx +9 -2
- package/corpus/core/package.json +1 -1
- package/corpus/core/src/cli/design-connect.ts +28 -2
- package/corpus/core/src/cli/mcp.ts +10 -0
- package/corpus/core/src/cli/skills.ts +103 -36
- package/corpus/core/src/client/error-format.ts +25 -0
- package/corpus/core/src/client/extensions/ExtensionViewer.tsx +13 -11
- package/corpus/core/src/client/guided-questions.tsx +32 -4
- package/corpus/core/src/client/onboarding/OnboardingPanel.tsx +33 -1
- package/corpus/core/src/client/resources/BuiltinCapabilityDetail.tsx +8 -0
- package/corpus/core/src/client/resources/use-builtin-capabilities.ts +4 -2
- package/corpus/core/src/client/session-replay.ts +34 -0
- package/corpus/core/src/client/sharing/ShareButton.tsx +106 -21
- package/corpus/core/src/coding-tools/index.ts +1 -1
- package/corpus/core/src/mcp/index.ts +2 -0
- package/corpus/core/src/mcp/screen-memory-stdio.ts +290 -0
- package/corpus/core/src/mcp-client/builtin-capabilities.ts +13 -1
- package/corpus/core/src/mcp-client/index.ts +9 -0
- package/corpus/core/src/mcp-client/screen-memory-local.ts +461 -0
- package/corpus/core/src/onboarding/types.ts +7 -0
- package/corpus/core/src/server/agent-chat-plugin.ts +25 -0
- package/corpus/core/src/server/agents-bundle.ts +35 -7
- package/corpus/core/src/styles/agent-native.css +5 -0
- package/corpus/core/src/templates/default/app/global.css +35 -35
- package/corpus/templates/analytics/AGENTS.md +6 -0
- package/corpus/templates/analytics/actions/github-repo-files.ts +9 -0
- package/corpus/templates/analytics/app/components/layout/Layout.tsx +4 -4
- package/corpus/templates/analytics/app/global.css +144 -40
- package/corpus/templates/analytics/app/pages/adhoc/explorer/index.tsx +1 -1
- package/corpus/templates/analytics/app/pages/adhoc/explorer-dashboard/ChartCard.tsx +1 -1
- package/corpus/templates/analytics/app/pages/adhoc/explorer-dashboard/index.tsx +1 -1
- package/corpus/templates/analytics/app/pages/sessions/SessionDetailPage.tsx +4 -4
- package/corpus/templates/analytics/app/pages/sessions/SessionsPage.tsx +9 -9
- package/corpus/templates/analytics/changelog/2026-06-29-agents-can-search-and-read-connected-github-repositories-whe.md +6 -0
- package/corpus/templates/analytics/changelog/2026-06-29-sessions-and-explorer-layouts-adapt-when-the-agent-sidebar-is.md +6 -0
- package/corpus/templates/assets/app/components/layout/Layout.tsx +3 -1
- package/corpus/templates/assets/app/components/library/LibraryPresetGrid.tsx +1 -1
- package/corpus/templates/assets/app/global.css +99 -35
- package/corpus/templates/assets/app/routes/asset.$id.tsx +2 -2
- package/corpus/templates/assets/app/routes/brand-kits.$id.tsx +4 -4
- package/corpus/templates/assets/app/routes/library.tsx +4 -4
- package/corpus/templates/assets/changelog/2026-06-29-asset-library-and-detail-layouts-adapt-when-the-agent-sidebar.md +6 -0
- package/corpus/templates/brain/app/components/layout/Layout.tsx +1 -1
- package/corpus/templates/brain/app/global.css +63 -35
- package/corpus/templates/brain/app/routes/search.tsx +1 -1
- package/corpus/templates/brain/app/routes/settings.tsx +1 -1
- package/corpus/templates/brain/app/routes/sources.tsx +2 -2
- package/corpus/templates/brain/changelog/2026-06-29-search-settings-and-source-layouts-adapt-when-the-agent-sidebar.md +6 -0
- package/corpus/templates/calendar/app/components/calendar/EventDetailPanel.tsx +4 -4
- package/corpus/templates/calendar/app/components/calendar/FindTimePanel.tsx +3 -2
- package/corpus/templates/calendar/app/components/layout/AppLayout.tsx +4 -2
- package/corpus/templates/calendar/app/global.css +69 -35
- package/corpus/templates/calendar/changelog/2026-06-29-event-and-find-time-layouts-adapt-when-the-agent-sidebar-is.md +6 -0
- package/corpus/templates/chat/app/components/layout/Layout.tsx +1 -1
- package/corpus/templates/chat/app/global.css +35 -35
- package/corpus/templates/chat/changelog/2026-06-29-chat-layouts-adapt-when-the-agent-sidebar-is-open.md +6 -0
- package/corpus/templates/clips/AGENTS.md +13 -0
- package/corpus/templates/clips/actions/get-screen-memory-status.ts +12 -0
- package/corpus/templates/clips/actions/query-screen-memory-context.ts +29 -0
- package/corpus/templates/clips/actions/view-screen.ts +2 -2
- package/corpus/templates/clips/app/components/library/library-layout.tsx +1 -1
- package/corpus/templates/clips/app/global.css +47 -35
- package/corpus/templates/clips/app/routes/_app.meetings.$meetingId.tsx +3 -3
- package/corpus/templates/clips/app/routes/r.$recordingId.tsx +45 -18
- package/corpus/templates/clips/changelog/2026-06-29-meeting-detail-layouts-adapt-when-the-agent-sidebar-is-open.md +6 -0
- package/corpus/templates/clips/changelog/2026-06-29-screen-memory-keeps-a-local-rolling-screen-buffer-for-agent-context.md +5 -0
- package/corpus/templates/clips/changelog/2026-06-29-video-chat-is-easier-to-find-on-recording-pages-and-s3-setup.md +6 -0
- package/corpus/templates/clips/chrome-extension/src/styles.css +39 -39
- package/corpus/templates/clips/desktop/src/app.tsx +290 -1
- package/corpus/templates/clips/desktop/src/shared/config.ts +83 -0
- package/corpus/templates/clips/desktop/src/styles.css +67 -52
- package/corpus/templates/clips/desktop/src-tauri/src/config.rs +50 -0
- package/corpus/templates/clips/desktop/src-tauri/src/lib.rs +17 -0
- package/corpus/templates/clips/desktop/src-tauri/src/native_screen.rs +13 -13
- package/corpus/templates/clips/desktop/src-tauri/src/screen_memory.rs +990 -0
- package/corpus/templates/clips/server/plugins/onboarding.ts +2 -0
- package/corpus/templates/content/app/components/editor/database/DatabaseView.tsx +3 -3
- package/corpus/templates/content/app/components/layout/Layout.tsx +1 -1
- package/corpus/templates/content/app/global.css +29 -15
- package/corpus/templates/content/changelog/2026-06-29-database-gallery-layouts-adapt-when-the-agent-sidebar-is-open.md +6 -0
- package/corpus/templates/design/.agents/skills/design-generation/SKILL.md +25 -20
- package/corpus/templates/design/.agents/skills/design-systems/SKILL.md +8 -0
- package/corpus/templates/design/.agents/skills/export-handoff/SKILL.md +8 -0
- package/corpus/templates/design/.agents/skills/visual-edit/SKILL.md +13 -0
- package/corpus/templates/design/AGENTS.md +20 -12
- package/corpus/templates/design/CODE_NATIVE_DESIGN_STUDIO_IMPLEMENTATION_PLAN.md +1054 -0
- package/corpus/templates/design/DESIGN-STUDIO-PLAN.md +717 -0
- package/corpus/templates/design/actions/add-breakpoint.ts +143 -0
- package/corpus/templates/design/actions/add-localhost-screens.ts +5 -0
- package/corpus/templates/design/actions/apply-a11y-fix.ts +317 -0
- package/corpus/templates/design/actions/apply-component-prop-edit.ts +433 -0
- package/corpus/templates/design/actions/apply-design-state.ts +200 -0
- package/corpus/templates/design/actions/apply-design-token-edit.ts +202 -0
- package/corpus/templates/design/actions/apply-motion-edit.ts +450 -0
- package/corpus/templates/design/actions/apply-shader-fill.ts +404 -0
- package/corpus/templates/design/actions/apply-visual-edit.ts +214 -8
- package/corpus/templates/design/actions/capture-design-state.ts +224 -0
- package/corpus/templates/design/actions/connect-builder-app.ts +162 -0
- package/corpus/templates/design/actions/create-component.ts +447 -0
- package/corpus/templates/design/actions/create-design-branch.ts +263 -0
- package/corpus/templates/design/actions/create-design-state.ts +162 -0
- package/corpus/templates/design/actions/delete-design-state.ts +55 -0
- package/corpus/templates/design/actions/deploy-design-preview.ts +275 -0
- package/corpus/templates/design/actions/export-coding-handoff.ts +12 -4
- package/corpus/templates/design/actions/generate-design.ts +6 -21
- package/corpus/templates/design/actions/generate-screens.ts +43 -2
- package/corpus/templates/design/actions/get-component-details.ts +242 -0
- package/corpus/templates/design/actions/get-design-branch-diff.ts +362 -0
- package/corpus/templates/design/actions/get-design-review.ts +314 -0
- package/corpus/templates/design/actions/get-design-surface-index.ts +582 -0
- package/corpus/templates/design/actions/get-design.ts +1 -0
- package/corpus/templates/design/actions/get-motion-timeline.ts +99 -0
- package/corpus/templates/design/actions/index-components.ts +258 -0
- package/corpus/templates/design/actions/index-design-tokens.ts +273 -0
- package/corpus/templates/design/actions/list-design-extensions.ts +309 -0
- package/corpus/templates/design/actions/list-design-source-capabilities.ts +153 -0
- package/corpus/templates/design/actions/list-design-states.ts +72 -0
- package/corpus/templates/design/actions/migrate-inline-design-to-app.ts +298 -0
- package/corpus/templates/design/actions/open-component-source.ts +237 -0
- package/corpus/templates/design/actions/present-design-variants.ts +355 -30
- package/corpus/templates/design/actions/preview-component-prop-edit.ts +254 -0
- package/corpus/templates/design/actions/preview-design-token-edit.ts +113 -0
- package/corpus/templates/design/actions/preview-shader-fill.ts +189 -0
- package/corpus/templates/design/actions/remove-breakpoint.ts +103 -0
- package/corpus/templates/design/actions/remove-motion-timeline.ts +196 -0
- package/corpus/templates/design/actions/run-design-audit.ts +421 -0
- package/corpus/templates/design/actions/run-design-extension-action.ts +284 -0
- package/corpus/templates/design/actions/set-active-breakpoint.ts +39 -0
- package/corpus/templates/design/actions/view-screen.ts +75 -31
- package/corpus/templates/design/app/components/design/DesignCanvas.tsx +1738 -135
- package/corpus/templates/design/app/components/design/DesignEditorSkeleton.tsx +1 -1
- package/corpus/templates/design/app/components/design/DesignExtensionsPanel.tsx +632 -43
- package/corpus/templates/design/app/components/design/DrawOverlay.tsx +1 -1
- package/corpus/templates/design/app/components/design/EditPanel.tsx +1873 -132
- package/corpus/templates/design/app/components/design/LayersPanel.tsx +384 -219
- package/corpus/templates/design/app/components/design/LocalSourceEditBanner.tsx +157 -0
- package/corpus/templates/design/app/components/design/MotionDock.tsx +1062 -0
- package/corpus/templates/design/app/components/design/MultiScreenCanvas.tsx +2103 -295
- package/corpus/templates/design/app/components/design/QuestionFlow.tsx +83 -206
- package/corpus/templates/design/app/components/design/ReviewPanel.tsx +759 -0
- package/corpus/templates/design/app/components/design/StatesPanel.tsx +579 -0
- package/corpus/templates/design/app/components/design/TokensPanel.tsx +573 -0
- package/corpus/templates/design/app/components/design/TweaksPanel.tsx +1 -1
- package/corpus/templates/design/app/components/design/canvas-primitive-style.ts +241 -0
- package/corpus/templates/design/app/components/design/index.ts +16 -1
- package/corpus/templates/design/app/components/design/inspector/AutoLayoutMatrix.tsx +238 -137
- package/corpus/templates/design/app/components/design/inspector/DesignColorPicker.tsx +188 -14
- package/corpus/templates/design/app/components/design/inspector/ExportSettingsPanel.tsx +24 -5
- package/corpus/templates/design/app/components/design/inspector/ImageFillControls.tsx +57 -1
- package/corpus/templates/design/app/components/design/inspector/InspectorAiActions.tsx +145 -0
- package/corpus/templates/design/app/components/design/inspector/SHADER_INTEGRATION.md +42 -12
- package/corpus/templates/design/app/components/design/inspector/ScrubInput.tsx +37 -12
- package/corpus/templates/design/app/components/design/inspector/index.ts +1 -0
- package/corpus/templates/design/app/components/design/inspector/scrub-input-utils.ts +12 -5
- package/corpus/templates/design/app/components/design/types.ts +9 -0
- package/corpus/templates/design/app/components/layout/Layout.tsx +23 -5
- package/corpus/templates/design/app/components/visual-editor/DrawOverlay.tsx +1 -1
- package/corpus/templates/design/app/global.css +77 -49
- package/corpus/templates/design/app/hooks/use-question-flow.ts +2 -2
- package/corpus/templates/design/app/hooks/useAgentEditRequest.ts +131 -0
- package/corpus/templates/design/app/hooks/useDesignHotkeys.ts +11 -2
- package/corpus/templates/design/app/i18n/zh-TW.ts +34 -0
- package/corpus/templates/design/app/i18n-data.ts +314 -3
- package/corpus/templates/design/app/pages/DesignEditor.tsx +4929 -892
- package/corpus/templates/design/app/root.tsx +1 -1
- package/corpus/templates/design/changelog/2026-06-29-added-a-review-panel-in-the-design-editor-s-inspector-with-a.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-containers-no-longer-block-selecting-nested-elements-and-nor.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-copying-and-pasting-layers-no-longer-shows-success-notificat.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-design-agents-now-generate-and-refine-variants-from-stronger.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-design-inspector-controls-now-match-figmas-softer-dark-chrome.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-design-questions-now-appear-as-a-cleaner-canvas-intake-with-.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-design-variant-directions-now-appear-as-board-screens-with-chat-buttons.md +5 -0
- package/corpus/templates/design/changelog/2026-06-29-device-presets-in-all-screens-view-resize-the-selected-previ.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-element-selection-no-longer-snaps-back-to-the-previous-layer.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-frame-resize-measurements-now-stay-beside-the-cursor-while-d.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-inspector-number-fields-have-cleaner-tooltips-and-draggable-.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-layer-and-canvas-drags-keep-the-layer-list-stable-while-chan.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-layer-locking-layer-nesting-generated-question-intake-and-im.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-layer-moves-can-be-undone-and-redone-without-flashing-the-ca.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-layer-names-in-the-sidebar-can-scroll-horizontally-instead-o.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-layer-nesting-in-the-sidebar-now-uses-tighter-spacing-so-nam.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-layers-no-longer-repeat-document-wrapper-rows-when-a-screen-.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-overview-previews-now-keep-element-hover-and-selection-tied-.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-pressing-escape-now-cancels-a-stuck-screen-drag-in-the-overv.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-screen-overview-is-easier-to-find-and-named-screens-open-dir.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-screen-overview-only-highlights-screens-when-the-frame-or-ti.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-screen-overview-previews-now-resize-to-match-the-selected-de.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-screen-overview-selection-now-uses-a-pointer-cursor-instead-.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-screen-overview-selection-outlines-now-stay-locked-to-the-se.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-screen-overview-zoom-now-reports-real-screen-scale-separatel.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-screen-overview-zooming-feels-smoother-and-selection-outline.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-screen-overview-zooming-now-stays-on-the-overview-canvas-ins.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-screen-previews-use-a-single-blue-hover-border-in-all-screen.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-selected-containers-show-draggable-padding-and-gap-guides-on.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-selecting-a-nested-layer-from-all-screens-now-keeps-you-in-a.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-share-now-groups-link-sharing-exports-and-agent-handoff.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-the-design-editor-adds-a-studio-layer-with-tokens-respon.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-the-design-editor-loading-skeleton-now-uses-a-softer-charcoa.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-the-device-preview-menu-now-sits-next-to-the-preview-button-.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-the-inspector-stays-read-only-while-an-empty-design-is-still.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-the-missing-design-view-now-matches-the-rest-of-the-editor-c.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-the-pen-tool-icon-and-tool-option-menus-better-match-the-edi.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-typography-controls-now-keep-the-font-name-visible-and-move-.md +6 -0
- package/corpus/templates/design/changelog/2026-06-30-accessibility-findings-now-offer-a-one-click-fix.md +6 -0
- package/corpus/templates/design/changelog/2026-06-30-component-instances-now-have-editable-props-in-the-inspe.md +6 -0
- package/corpus/templates/design/changelog/2026-06-30-inspect-code-now-shows-the-elements-opening-tag-at-a-gla.md +6 -0
- package/corpus/templates/design/changelog/2026-06-30-shader-fill-presets-can-now-be-applied-to-an-element.md +6 -0
- package/corpus/templates/design/changelog/2026-06-30-the-motion-timeline-can-now-add-a-track-to-any-element-a.md +6 -0
- package/corpus/templates/design/changelog/2026-06-30-visual-editor-selection-layer-paint-and-drawing-controls-are-more-reliable.md +6 -0
- package/corpus/templates/design/e2e/README.md +3 -3
- package/corpus/templates/design/e2e/global-setup.ts +11 -22
- package/corpus/templates/design/e2e/helpers.ts +128 -11
- package/corpus/templates/design/playwright.config.ts +9 -3
- package/corpus/templates/design/server/db/schema.ts +123 -0
- package/corpus/templates/design/server/lib/coding-handoff.ts +126 -2
- package/corpus/templates/design/server/plugins/core-routes.ts +1 -2
- package/corpus/templates/design/server/plugins/db.ts +90 -0
- package/corpus/templates/design/server/routes/api/design-handoff/[id].zip.get.ts +86 -0
- package/corpus/templates/design/shared/builder-app.ts +297 -0
- package/corpus/templates/design/shared/capability-resolver.ts +123 -0
- package/corpus/templates/design/shared/capture-sanitize.ts +70 -0
- package/corpus/templates/design/shared/code-layer.ts +1141 -93
- package/corpus/templates/design/shared/component-model.ts +239 -0
- package/corpus/templates/design/shared/design-review.ts +275 -0
- package/corpus/templates/design/shared/design-source-capabilities.ts +286 -0
- package/corpus/templates/design/shared/design-state.ts +112 -0
- package/corpus/templates/design/shared/design-surface-index.ts +258 -0
- package/corpus/templates/design/shared/generation-session.ts +41 -0
- package/corpus/templates/design/shared/motion-compiler.ts +278 -0
- package/corpus/templates/design/shared/motion-timeline.ts +193 -0
- package/corpus/templates/design/shared/responsive-classes.ts +452 -0
- package/corpus/templates/design/shared/shader-fill.ts +323 -0
- package/corpus/templates/design/shared/source-mode.ts +245 -0
- package/corpus/templates/dispatch/app/global.css +79 -35
- package/corpus/templates/dispatch/app/routes/integrations.tsx +8 -7
- package/corpus/templates/dispatch/changelog/2026-06-29-integration-layouts-adapt-when-the-agent-sidebar-is-open.md +6 -0
- package/corpus/templates/forms/app/components/layout/Layout.tsx +6 -2
- package/corpus/templates/forms/app/global.css +64 -35
- package/corpus/templates/forms/app/pages/FormsListPage.tsx +2 -2
- package/corpus/templates/forms/app/pages/ResponseInsightsPage.tsx +3 -3
- package/corpus/templates/forms/changelog/2026-06-29-form-list-and-insight-layouts-adapt-when-the-agent-sidebar.md +6 -0
- package/corpus/templates/macros/app/components/layout/AppLayout.tsx +3 -1
- package/corpus/templates/macros/app/global.css +25 -9
- package/corpus/templates/macros/changelog/2026-06-29-macro-layouts-adapt-when-the-agent-sidebar-is-open.md +6 -0
- package/corpus/templates/mail/app/components/layout/AppLayout.tsx +6 -2
- package/corpus/templates/mail/app/global.css +42 -36
- package/corpus/templates/mail/app/pages/InboxPage.tsx +1 -1
- package/corpus/templates/mail/changelog/2026-06-29-the-contact-panel-now-adapts-to-the-available-mail-pane-width.md +6 -0
- package/corpus/templates/plan/app/components/layout/Layout.tsx +3 -1
- package/corpus/templates/plan/app/components/plan/CanvasArea.tsx +6 -2
- package/corpus/templates/plan/app/components/plan/DocumentArea.tsx +6 -7
- package/corpus/templates/plan/app/global.css +74 -42
- package/corpus/templates/plan/changelog/2026-06-29-plan-canvases-open-without-an-initial-pan-and-zoom-flicker.md +6 -0
- package/corpus/templates/plan/changelog/2026-06-29-plan-document-blocks-adapt-to-the-available-document-width.md +6 -0
- package/corpus/templates/plan/changelog/2026-06-29-plan-titles-and-summaries-can-be-edited-inline-without-focus.md +6 -0
- package/corpus/templates/slides/app/components/layout/Layout.tsx +3 -1
- package/corpus/templates/slides/app/global.css +49 -33
- package/corpus/templates/slides/changelog/2026-06-29-slide-layouts-adapt-when-the-agent-sidebar-is-open.md +6 -0
- package/corpus/templates/videos/app/components/layout/Layout.tsx +3 -1
- package/corpus/templates/videos/app/global.css +35 -35
- package/corpus/templates/videos/changelog/2026-06-29-video-layouts-adapt-when-the-agent-sidebar-is-open.md +6 -0
- package/dist/cli/design-connect.d.ts.map +1 -1
- package/dist/cli/design-connect.js +28 -2
- package/dist/cli/design-connect.js.map +1 -1
- package/dist/cli/mcp.d.ts.map +1 -1
- package/dist/cli/mcp.js +10 -0
- package/dist/cli/mcp.js.map +1 -1
- package/dist/cli/skills.d.ts.map +1 -1
- package/dist/cli/skills.js +95 -33
- package/dist/cli/skills.js.map +1 -1
- package/dist/client/error-format.d.ts.map +1 -1
- package/dist/client/error-format.js +17 -0
- package/dist/client/error-format.js.map +1 -1
- package/dist/client/extensions/ExtensionViewer.d.ts.map +1 -1
- package/dist/client/extensions/ExtensionViewer.js +3 -4
- package/dist/client/extensions/ExtensionViewer.js.map +1 -1
- package/dist/client/guided-questions.d.ts +4 -0
- package/dist/client/guided-questions.d.ts.map +1 -1
- package/dist/client/guided-questions.js +16 -7
- package/dist/client/guided-questions.js.map +1 -1
- package/dist/client/onboarding/OnboardingPanel.js +26 -1
- package/dist/client/onboarding/OnboardingPanel.js.map +1 -1
- package/dist/client/resources/BuiltinCapabilityDetail.d.ts.map +1 -1
- package/dist/client/resources/BuiltinCapabilityDetail.js +1 -1
- package/dist/client/resources/BuiltinCapabilityDetail.js.map +1 -1
- package/dist/client/resources/use-builtin-capabilities.d.ts +1 -1
- package/dist/client/resources/use-builtin-capabilities.d.ts.map +1 -1
- package/dist/client/resources/use-builtin-capabilities.js +2 -1
- package/dist/client/resources/use-builtin-capabilities.js.map +1 -1
- package/dist/client/session-replay.d.ts.map +1 -1
- package/dist/client/session-replay.js +31 -0
- package/dist/client/session-replay.js.map +1 -1
- package/dist/client/sharing/ShareButton.d.ts +14 -0
- package/dist/client/sharing/ShareButton.d.ts.map +1 -1
- package/dist/client/sharing/ShareButton.js +36 -7
- package/dist/client/sharing/ShareButton.js.map +1 -1
- package/dist/coding-tools/index.js +1 -1
- package/dist/coding-tools/index.js.map +1 -1
- package/dist/mcp/index.d.ts +2 -0
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js +1 -0
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/screen-memory-stdio.d.ts +6 -0
- package/dist/mcp/screen-memory-stdio.d.ts.map +1 -0
- package/dist/mcp/screen-memory-stdio.js +213 -0
- package/dist/mcp/screen-memory-stdio.js.map +1 -0
- package/dist/mcp-client/builtin-capabilities.d.ts +1 -1
- package/dist/mcp-client/builtin-capabilities.d.ts.map +1 -1
- package/dist/mcp-client/builtin-capabilities.js +10 -0
- package/dist/mcp-client/builtin-capabilities.js.map +1 -1
- package/dist/mcp-client/index.d.ts +1 -0
- package/dist/mcp-client/index.d.ts.map +1 -1
- package/dist/mcp-client/index.js +1 -0
- package/dist/mcp-client/index.js.map +1 -1
- package/dist/mcp-client/screen-memory-local.d.ts +61 -0
- package/dist/mcp-client/screen-memory-local.d.ts.map +1 -0
- package/dist/mcp-client/screen-memory-local.js +336 -0
- package/dist/mcp-client/screen-memory-local.js.map +1 -0
- package/dist/observability/routes.d.ts +3 -3
- package/dist/onboarding/types.d.ts +7 -0
- package/dist/onboarding/types.d.ts.map +1 -1
- package/dist/onboarding/types.js.map +1 -1
- package/dist/server/agent-chat-plugin.d.ts.map +1 -1
- package/dist/server/agent-chat-plugin.js +26 -0
- package/dist/server/agent-chat-plugin.js.map +1 -1
- package/dist/server/agent-engine-api-key-route.d.ts +1 -1
- package/dist/server/agents-bundle.d.ts.map +1 -1
- package/dist/server/agents-bundle.js +22 -7
- package/dist/server/agents-bundle.js.map +1 -1
- package/dist/styles/agent-native.css +5 -0
- package/dist/templates/default/app/global.css +35 -35
- package/docs/content/locales/ar-SA/template-design.mdx +6 -0
- package/docs/content/locales/de-DE/template-design.mdx +8 -0
- package/docs/content/locales/es-ES/template-design.mdx +10 -2
- package/docs/content/locales/fr-FR/template-design.mdx +10 -2
- package/docs/content/locales/hi-IN/template-design.mdx +7 -0
- package/docs/content/locales/ja-JP/template-design.mdx +7 -0
- package/docs/content/locales/ko-KR/template-design.mdx +7 -0
- package/docs/content/locales/pt-BR/template-design.mdx +9 -2
- package/docs/content/locales/zh-CN/template-design.mdx +6 -0
- package/docs/content/locales/zh-TW/template-design.mdx +6 -0
- package/docs/content/template-design.mdx +9 -2
- package/package.json +1 -1
- package/src/templates/default/app/global.css +35 -35
- package/corpus/templates/design/app/components/design/VariantGrid.tsx +0 -189
- package/corpus/templates/design/app/components/design/VariantHandoffCard.tsx +0 -115
- package/corpus/templates/design/app/hooks/use-variant-flow.ts +0 -342
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/coding-tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AA8F7B,MAAM,0BAA0B,GAAG,OAAO,CAAC;AAC3C,MAAM,wBAAwB,GAAG,MAAM,CAAC;AACxC,MAAM,2BAA2B,GAAG,OAAO,CAAC;AAE5C;;;GAGG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,KAAK,CAAC;AAC5C,MAAM,CAAC,MAAM,sBAAsB,GAAG,MAAM,CAAC;AAE7C,yEAAyE;AACzE,MAAM,CAAC,MAAM,sBAAsB,GAAG,MAAM,CAAC;AAE7C,MAAM,cAAc,GAAG,IAAI,GAAG,EAA4B,CAAC;AAE3D,MAAM,UAAU,wBAAwB,CACtC,OAAO,GAAoC,EAAE;IAE7C,MAAM,GAA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AAC,CAAC,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC;AACtE,CAAC;AAED,SAAS,SAAS,CAAC,KAAc;IAC/B,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;AAChD,CAAC;AAED,SAAS,eAAe,CAAC,KAAc,EAAE,QAAgB;IACvD,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC7B,OAAO,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;AAC/E,CAAC","sourcesContent":["import { spawn } from \"node:child_process\";\nimport fs from \"node:fs\";\nimport os from \"node:os\";\nimport path from \"node:path\";\n\nimport type { ActionEntry } from \"../agent/production-agent.js\";\n\nexport interface CodingCommandResult {\n code: number | null;\n stdout: string;\n stderr: string;\n timedOut: boolean;\n durationMs?: number;\n}\n\n/**\n * Structured metadata emitted on tool_start / tool_done events so the UI can\n * render bespoke cells (bash terminal, edit diff, etc.) instead of the generic\n * pill. Fields are additive — older consumers that don't know them are unaffected.\n */\nexport interface BashToolMetadata {\n toolKind: \"bash\";\n command: string;\n cwd: string;\n exitCode?: number | null;\n durationMs?: number;\n timedOut?: boolean;\n}\n\nexport interface EditToolMetadata {\n toolKind: \"edit\";\n filePath: string;\n /** The exact old text replaced (capped at EDIT_CONTENT_MAX_CHARS). */\n oldText?: string;\n /** The exact new text written (capped at EDIT_CONTENT_MAX_CHARS). */\n newText?: string;\n truncated?: boolean;\n}\n\nexport interface WriteToolMetadata {\n toolKind: \"write\";\n filePath: string;\n /** Full file content written (capped at EDIT_CONTENT_MAX_CHARS). */\n content?: string;\n truncated?: boolean;\n lineCount?: number;\n}\n\nexport interface ReadToolMetadata {\n toolKind: \"read\";\n filePath: string;\n lineCount?: number;\n}\n\nexport type StructuredToolMetadata =\n | BashToolMetadata\n | EditToolMetadata\n | WriteToolMetadata\n | ReadToolMetadata;\n\n/** Callback invoked with incremental bash output while the command is running. */\nexport type BashOutputChunkCallback = (chunk: string) => void;\n\nexport interface CreateCodingToolRegistryOptions {\n cwd?: string;\n restrictToCwd?: boolean;\n commandTimeoutMs?: number;\n maxOutputChars?: number;\n maxFileReadChars?: number;\n bashThrowsOnNonZero?: boolean;\n canWrite?: (toolName: \"edit\" | \"write\") => string | null;\n beforeBash?: (input: {\n command: string;\n cwd: string;\n timeoutMs: number;\n }) => string | null | Promise<string | null>;\n /** Called with incremental stdout+stderr chunks while a bash command runs. */\n onBashOutputChunk?: BashOutputChunkCallback;\n /**\n * Called when structured metadata is available for a tool call. The\n * `phase` is \"start\" (right before execution) or \"done\" (after execution).\n * This is the side-channel used to populate bespoke tool-cell fields without\n * changing the string-result contract that the agent sees.\n */\n onToolMetadata?: (\n toolName: string,\n phase: \"start\" | \"done\",\n meta: StructuredToolMetadata,\n ) => void;\n}\n\ninterface EditOperation {\n oldText: string;\n newText: string;\n replaceAll: boolean;\n}\n\nconst DEFAULT_COMMAND_TIMEOUT_MS = 120_000;\nconst DEFAULT_MAX_OUTPUT_CHARS = 50_000;\nconst DEFAULT_MAX_FILE_READ_CHARS = 120_000;\n\n/**\n * Output retention window for bash: keep first HEAD_CHARS + last TAIL_CHARS,\n * separated by a truncation marker. Replaces the old flat 4 000-char cap.\n */\nexport const BASH_OUTPUT_HEAD_CHARS = 4_096;\nexport const BASH_OUTPUT_TAIL_CHARS = 16_384;\n\n/** Maximum chars stored per side of an edit/write for diff rendering. */\nexport const EDIT_CONTENT_MAX_CHARS = 49_152;\n\nconst mutationQueues = new Map<string, Promise<unknown>>();\n\nexport function createCodingToolRegistry(\n options: CreateCodingToolRegistryOptions = {},\n): Record<\"bash\" | \"read\" | \"edit\" | \"write\", ActionEntry> {\n const cwd = path.resolve(options.cwd ?? process.cwd());\n const restrictToCwd = options.restrictToCwd ?? false;\n const commandTimeoutMs =\n options.commandTimeoutMs ?? DEFAULT_COMMAND_TIMEOUT_MS;\n const maxOutputChars = options.maxOutputChars ?? DEFAULT_MAX_OUTPUT_CHARS;\n const maxFileReadChars =\n options.maxFileReadChars ?? DEFAULT_MAX_FILE_READ_CHARS;\n\n return {\n bash: {\n tool: {\n description:\n 'Run a shell command. This is the tool for file discovery, directory listing, and search: reach first for `rg <pattern>` and `rg --files`, which are much faster than `grep` or `find`. Also use it to run tests, builds, package scripts, `git status`/`git diff`, and project CLIs. Use the read tool to view a single file\\'s contents; use bash for everything else. Very long output is truncated.\\n\\nSet `background` to \"true\" to spawn the command detached and return immediately. The tool returns the PID and a log file path; the process writes its stdout/stderr to that log file. You can read or tail the log file to check progress, and run `kill <pid>` to stop it. Background processes are not killed when the timeout expires.',\n parameters: {\n type: \"object\",\n properties: {\n command: {\n type: \"string\",\n description: \"The shell command to run (executed via bash).\",\n },\n cwd: {\n type: \"string\",\n description:\n \"Working directory for the command. Relative to the workspace root unless absolute paths are allowed. Defaults to the workspace root.\",\n },\n timeoutMs: {\n type: \"string\",\n description:\n \"Timeout in milliseconds; the command is killed if it exceeds this. Defaults to 120000, capped at 600000. Ignored when background is true.\",\n },\n stdin: {\n type: \"string\",\n description: \"Text to pipe into the command's stdin.\",\n },\n background: {\n type: \"string\",\n description:\n 'Set to \"true\" to spawn the command detached in the background and return immediately. Returns the process PID and a log file path where stdout/stderr are written.',\n enum: [\"true\", \"false\"],\n },\n },\n required: [\"command\"],\n },\n },\n run: async (args) => {\n const command = stringArg(args.command);\n if (!command) return \"Error: command is required.\";\n const commandCwd =\n resolveCodingPath(cwd, stringArg(args.cwd) || \".\", {\n restrictToCwd,\n allowEmpty: true,\n }) ?? \"\";\n if (!commandCwd) {\n return \"Error: cwd must stay inside the workspace.\";\n }\n const requestedTimeoutMs = Number(args.timeoutMs);\n const timeoutMs =\n Number.isFinite(requestedTimeoutMs) && requestedTimeoutMs > 0\n ? Math.min(requestedTimeoutMs, 10 * 60_000)\n : commandTimeoutMs;\n\n const isBackground =\n stringArg(args.background).toLowerCase() === \"true\";\n\n const policyResult =\n (await options.beforeBash?.({\n command,\n cwd: commandCwd,\n timeoutMs,\n })) ?? null;\n if (policyResult) return policyResult;\n\n options.onToolMetadata?.(\"bash\", \"start\", {\n toolKind: \"bash\",\n command,\n cwd: commandCwd,\n });\n\n if (isBackground) {\n const result = spawnBackgroundCommand(command, commandCwd);\n options.onToolMetadata?.(\"bash\", \"done\", {\n toolKind: \"bash\",\n command,\n cwd: commandCwd,\n });\n return result;\n }\n\n const result = await runCodingCommand(command, commandCwd, timeoutMs, {\n stdin: stringArg(args.stdin) || undefined,\n onChunk: options.onBashOutputChunk,\n });\n\n options.onToolMetadata?.(\"bash\", \"done\", {\n toolKind: \"bash\",\n command,\n cwd: commandCwd,\n exitCode: result.code,\n durationMs: result.durationMs,\n timedOut: result.timedOut || undefined,\n });\n\n if (options.bashThrowsOnNonZero && result.code !== 0) {\n throw new Error(formatCodingCommandResult(result, maxOutputChars));\n }\n return formatCodingCommandResult(result, maxOutputChars, {\n omitEmptyExitCode: options.bashThrowsOnNonZero && result.code === 0,\n });\n },\n },\n read: {\n readOnly: true,\n tool: {\n description:\n \"Read a single UTF-8 text file, returned with 1-based line numbers. For a large file, use offset and limit to page through it instead of reading the whole thing. Read a file before editing it so your edit's oldText matches exactly. Use bash (`ls`, `rg --files`, `rg`) for directory listings, file discovery, and search; this tool reads one file only.\",\n parameters: {\n type: \"object\",\n properties: {\n path: {\n type: \"string\",\n description:\n \"Path to the file to read, relative to the workspace root unless absolute paths are allowed.\",\n },\n offset: {\n type: \"string\",\n description:\n \"1-based line number to start reading from. Defaults to the first line.\",\n },\n limit: {\n type: \"string\",\n description:\n \"Maximum number of lines to read from offset. Defaults to the rest of the file.\",\n },\n },\n required: [\"path\"],\n },\n },\n run: async (args) => {\n const requestedPath = stringArg(args.path);\n const filePath = resolveCodingPath(cwd, requestedPath, {\n restrictToCwd,\n });\n if (!filePath) return \"Error: path must stay inside the workspace.\";\n if (!fs.existsSync(filePath)) {\n return `Error: file not found: ${requestedPath}`;\n }\n const stat = fs.statSync(filePath);\n if (!stat.isFile()) {\n return `Error: ${requestedPath} is not a file. Use bash for directories and file lists.`;\n }\n const content = fs.readFileSync(filePath, \"utf8\");\n const lineCount = content.split(\"\\n\").length;\n options.onToolMetadata?.(\"read\", \"start\", {\n toolKind: \"read\",\n filePath: path.relative(cwd, filePath) || requestedPath,\n lineCount,\n });\n const result = truncateCodingOutput(\n formatFileReadOutput(cwd, filePath, content, args),\n maxFileReadChars,\n );\n options.onToolMetadata?.(\"read\", \"done\", {\n toolKind: \"read\",\n filePath: path.relative(cwd, filePath) || requestedPath,\n lineCount,\n });\n return result;\n },\n },\n edit: {\n tool: {\n description:\n \"Edit an existing UTF-8 text file by replacing exact text. Prefer this over write for changes to existing files. Read the file first so oldText matches byte-for-byte, including whitespace and indentation. oldText must occur EXACTLY ONCE in the file: include enough surrounding context to make it unique. The edit fails (and the file is left unchanged) if oldText is not found or matches more than once, unless replaceAll is true, which replaces every occurrence. To apply several edits to one file in a single call, pass edits as a JSON array of {oldText, newText, replaceAll} objects; they apply in order, and any failure aborts the whole call.\",\n parameters: {\n type: \"object\",\n properties: {\n path: {\n type: \"string\",\n description:\n \"Path to the file to edit, relative to the workspace root unless absolute paths are allowed.\",\n },\n oldText: {\n type: \"string\",\n description:\n \"Exact existing text to replace, for a single edit. Must match the file exactly and uniquely (include surrounding context) unless replaceAll is true.\",\n },\n newText: {\n type: \"string\",\n description: \"Text to replace oldText with, for a single edit.\",\n },\n replaceAll: {\n type: \"string\",\n description:\n 'Set to \"true\" to replace every occurrence of oldText instead of requiring a unique match. Defaults to \"false\".',\n enum: [\"true\", \"false\"],\n },\n edits: {\n type: \"string\",\n description:\n 'JSON array of edits to apply to this file in one call, e.g. [{\"oldText\":\"foo\",\"newText\":\"bar\"},{\"oldText\":\"baz\",\"newText\":\"qux\",\"replaceAll\":\"true\"}]. When provided, the top-level oldText/newText are ignored.',\n },\n },\n required: [\"path\"],\n },\n },\n run: async (args) => {\n const permissionError = options.canWrite?.(\"edit\") ?? null;\n if (permissionError) return permissionError;\n\n const requestedPath = stringArg(args.path);\n const filePath = resolveCodingPath(cwd, requestedPath, {\n restrictToCwd,\n });\n if (!filePath) return \"Error: path must stay inside the workspace.\";\n const edits = parseEditOperations(args);\n const relPath = path.relative(cwd, filePath) || requestedPath;\n\n options.onToolMetadata?.(\"edit\", \"start\", {\n toolKind: \"edit\",\n filePath: relPath,\n });\n\n return queueFileMutation(filePath, async () => {\n if (!fs.existsSync(filePath)) {\n throw new Error(`file not found: ${requestedPath}`);\n }\n const stat = fs.statSync(filePath);\n if (!stat.isFile()) {\n throw new Error(`${requestedPath} is not a file`);\n }\n\n const originalContent = fs.readFileSync(filePath, \"utf8\");\n let content = originalContent;\n let replacements = 0;\n for (const edit of edits) {\n const count = countOccurrences(content, edit.oldText);\n if (count === 0) {\n throw new Error(\n `oldText was not found in ${requestedPath}: ${previewText(\n edit.oldText,\n )}`,\n );\n }\n if (!edit.replaceAll && count !== 1) {\n throw new Error(\n `oldText matched ${count} times in ${requestedPath}; make it unique or set replaceAll=true.`,\n );\n }\n content = edit.replaceAll\n ? content.split(edit.oldText).join(edit.newText)\n : content.replace(edit.oldText, edit.newText);\n replacements += edit.replaceAll ? count : 1;\n }\n\n fs.writeFileSync(filePath, content, \"utf8\");\n\n // Emit structured diff metadata so the UI can render a real diff.\n const truncated =\n originalContent.length > EDIT_CONTENT_MAX_CHARS ||\n content.length > EDIT_CONTENT_MAX_CHARS;\n options.onToolMetadata?.(\"edit\", \"done\", {\n toolKind: \"edit\",\n filePath: relPath,\n oldText: originalContent.slice(0, EDIT_CONTENT_MAX_CHARS),\n newText: content.slice(0, EDIT_CONTENT_MAX_CHARS),\n truncated,\n });\n\n return `Edited ${relPath} (${replacements} replacement${replacements === 1 ? \"\" : \"s\"}).`;\n });\n },\n },\n write: {\n tool: {\n description:\n \"Create a new UTF-8 text file, or fully overwrite an existing one with the given content. Missing parent directories are created. For changes to an existing file, prefer edit; only use write when you intend to replace the entire file. Default to ASCII content unless the file already uses other characters or there is a clear reason not to.\",\n parameters: {\n type: \"object\",\n properties: {\n path: {\n type: \"string\",\n description:\n \"Path to the file to write, relative to the workspace root unless absolute paths are allowed.\",\n },\n content: {\n type: \"string\",\n description:\n \"Full contents to write. This replaces the entire file; existing content is not preserved.\",\n },\n },\n required: [\"path\", \"content\"],\n },\n },\n run: async (args) => {\n const permissionError = options.canWrite?.(\"write\") ?? null;\n if (permissionError) return permissionError;\n\n const requestedPath = stringArg(args.path);\n const filePath = resolveCodingPath(cwd, requestedPath, {\n restrictToCwd,\n });\n if (!filePath) return \"Error: path must stay inside the workspace.\";\n const content = stringArg(args.content);\n const relPath = path.relative(cwd, filePath) || requestedPath;\n\n options.onToolMetadata?.(\"write\", \"start\", {\n toolKind: \"write\",\n filePath: relPath,\n });\n\n return queueFileMutation(filePath, async () => {\n fs.mkdirSync(path.dirname(filePath), { recursive: true });\n const existed = fs.existsSync(filePath);\n fs.writeFileSync(filePath, content, \"utf8\");\n const bytes = Buffer.byteLength(content, \"utf8\");\n const lines = content.split(\"\\n\").length;\n\n const truncated = content.length > EDIT_CONTENT_MAX_CHARS;\n options.onToolMetadata?.(\"write\", \"done\", {\n toolKind: \"write\",\n filePath: relPath,\n content: content.slice(0, EDIT_CONTENT_MAX_CHARS),\n truncated,\n lineCount: lines,\n });\n\n return `${existed ? \"Updated\" : \"Created\"} ${relPath} (${lines} lines, ${bytes} bytes).`;\n });\n },\n },\n };\n}\n\nexport async function runCodingCommand(\n command: string,\n cwd: string,\n timeoutMs: number,\n options: { stdin?: string; onChunk?: BashOutputChunkCallback } = {},\n): Promise<CodingCommandResult> {\n const child = spawn(command, {\n cwd,\n shell: true,\n stdio: [\"pipe\", \"pipe\", \"pipe\"],\n env: { ...process.env, FORCE_COLOR: \"0\" },\n });\n let stdout = \"\";\n let stderr = \"\";\n let timedOut = false;\n const startMs = Date.now();\n const timer = setTimeout(() => {\n timedOut = true;\n child.kill(\"SIGTERM\");\n }, timeoutMs);\n child.stdout?.on(\"data\", (chunk: Buffer) => {\n const text = chunk.toString();\n stdout += text;\n options.onChunk?.(text);\n });\n child.stderr?.on(\"data\", (chunk: Buffer) => {\n const text = chunk.toString();\n stderr += text;\n options.onChunk?.(text);\n });\n if (options.stdin) child.stdin?.end(options.stdin);\n else child.stdin?.end();\n const code = await new Promise<number | null>((resolve, reject) => {\n child.once(\"error\", reject);\n child.once(\"exit\", resolve);\n });\n clearTimeout(timer);\n return { code, stdout, stderr, timedOut, durationMs: Date.now() - startMs };\n}\n\n/**\n * Spawn a command detached in the background. Returns immediately with the\n * process PID and a temporary log file path where stdout + stderr are written.\n *\n * The child process is intentionally detached from the parent's process group\n * (`detached: true`, `unref()`) so it continues running after the tool call\n * completes and is not killed if the agent run exits. The approval classifier\n * still applies before this function is reached (see `beforeBash` in the\n * calling registry).\n */\nexport function spawnBackgroundCommand(command: string, cwd: string): string {\n const logFile = path.join(\n os.tmpdir(),\n `an-bg-${Date.now()}-${Math.random().toString(36).slice(2, 8)}.log`,\n );\n\n const logFd = fs.openSync(logFile, \"a\");\n const child = spawn(command, {\n cwd,\n shell: true,\n stdio: [\"ignore\", logFd, logFd],\n detached: true,\n env: { ...process.env, FORCE_COLOR: \"0\" },\n });\n child.unref();\n fs.closeSync(logFd);\n\n const pid = child.pid ?? 0;\n return [\n `Background process spawned.`,\n `pid: ${pid}`,\n `log: ${logFile}`,\n `Read the log file to check progress. Run \\`kill ${pid}\\` to stop the process.`,\n ].join(\"\\n\");\n}\n\nexport function formatCodingCommandResult(\n result: CodingCommandResult,\n maxChars = DEFAULT_MAX_OUTPUT_CHARS,\n options: { omitEmptyExitCode?: boolean } = {},\n): string {\n const parts = [\n options.omitEmptyExitCode && result.code === 0\n ? \"\"\n : `exitCode: ${result.code}`,\n result.timedOut ? \"timedOut: true\" : \"\",\n result.stdout ? `stdout:\\n${result.stdout}` : \"\",\n result.stderr ? `stderr:\\n${result.stderr}` : \"\",\n ].filter(Boolean);\n return truncateCodingOutput(parts.join(\"\\n\\n\") || \"(no output)\", maxChars);\n}\n\nexport function truncateCodingOutput(value: string, max: number): string {\n if (value.length <= max) return value;\n return `${value.slice(0, max)}\\n\\n...[truncated ${value.length - max} chars]`;\n}\n\n/**\n * Retain the first HEAD_CHARS and the last TAIL_CHARS of bash output, inserting\n * a truncation marker in the middle. This is a better window than a simple\n * prefix slice because the end of the output usually contains the most important\n * signal (error messages, test results, etc.).\n */\nexport function truncateBashOutput(\n value: string,\n headChars = BASH_OUTPUT_HEAD_CHARS,\n tailChars = BASH_OUTPUT_TAIL_CHARS,\n): string {\n const max = headChars + tailChars;\n if (value.length <= max) return value;\n const omitted = value.length - max;\n return `${value.slice(0, headChars)}\\n\\n...[${omitted} chars omitted]\\n\\n${value.slice(value.length - tailChars)}`;\n}\n\nexport function isReadOnlyShellCommand(command: string): boolean {\n const normalized = command.trim().toLowerCase();\n if (!normalized) return false;\n\n // Read-only modes get a deliberately tiny shell grammar: one command only,\n // no redirection, pipes, sequencing, backgrounding, or command substitution.\n // Prefix allowlists are not safe until these shell forms are excluded.\n if (/[\\n\\r;&|<>]/.test(normalized)) return false;\n if (/\\$\\(|`|\\${|\\\\\\n/.test(command)) return false;\n\n // `sed` can WRITE even in `-n` mode via the `w`/`W` commands or `-i`\n // (e.g. `sed -n '1w out.txt' file`), so the `^sed -n` allowlist entry\n // below is not safe on its own. Reject any sed that can write.\n if (/^sed\\b/.test(normalized)) {\n if (/(^|\\s)-i(\\b|=)|--in-place/.test(normalized)) return false;\n // `w`/`W` used as a sed command: preceded by an address/separator\n // (digit, $, /, }, ;, quote, space) and followed by a filename arg or\n // end. Catches `1w f`, `$w f`, `/re/w f`, `s/x/y/w f`, `2W f`; leaves\n // prints like `/window/p`, `1,5p`, `s/a/b/` untouched.\n if (/[\\s'\"0-9$}/;](w|W)([\\s'\"]|$)/.test(normalized)) return false;\n }\n\n const allowedPrefixes = [\n /^pwd\\b/,\n /^ls\\b/,\n /^find\\b/,\n /^rg\\b/,\n /^grep\\b/,\n /^cat\\b/,\n /^sed\\s+-n\\b/,\n /^head\\b/,\n /^tail\\b/,\n /^wc\\b/,\n /^git\\s+(status|diff|show|log)\\b/,\n /^git\\s+branch\\s+--show-current\\b/,\n ];\n return allowedPrefixes.some((pattern) => pattern.test(normalized));\n}\n\nfunction resolveCodingPath(\n cwd: string,\n value: string,\n options: { restrictToCwd: boolean; allowEmpty?: boolean },\n): string | null {\n if (!value.trim() && !options.allowEmpty) return null;\n const target = value.trim() || \".\";\n const resolved = path.isAbsolute(target)\n ? path.resolve(target)\n : path.resolve(cwd, target);\n if (!options.restrictToCwd) return resolved;\n\n const relative = path.relative(cwd, resolved);\n if (relative.startsWith(\"..\") || path.isAbsolute(relative)) return null;\n return resolved;\n}\n\nfunction formatFileReadOutput(\n cwd: string,\n filePath: string,\n content: string,\n args: Record<string, unknown>,\n): string {\n const lines = content.split(\"\\n\");\n const offset = positiveInteger(args.offset, 1);\n const limit = positiveInteger(args.limit, lines.length - offset + 1);\n const selected = lines.slice(offset - 1, offset - 1 + limit);\n const body = selected\n .map((line, index) => `${String(offset + index).padStart(5)} | ${line}`)\n .join(\"\\n\");\n return `${path.relative(cwd, filePath) || filePath} (${lines.length} lines)\\n${body}`;\n}\n\nfunction parseEditOperations(args: Record<string, unknown>): EditOperation[] {\n const editsJson = stringArg(args.edits);\n if (editsJson.trim()) {\n let parsed: unknown;\n try {\n parsed = JSON.parse(editsJson);\n } catch (err) {\n throw new Error(\n `edits must be valid JSON: ${err instanceof Error ? err.message : String(err)}`,\n );\n }\n if (!Array.isArray(parsed) || parsed.length === 0) {\n throw new Error(\"edits must be a non-empty JSON array.\");\n }\n return parsed.map((edit, index) => {\n if (!edit || typeof edit !== \"object\") {\n throw new Error(`edits[${index}] must be an object.`);\n }\n return normalizeEditOperation(edit as Record<string, unknown>, index);\n });\n }\n\n return [normalizeEditOperation(args, 0)];\n}\n\nfunction normalizeEditOperation(\n edit: Record<string, unknown>,\n index: number,\n): EditOperation {\n const oldText = typeof edit.oldText === \"string\" ? edit.oldText : undefined;\n const newText = typeof edit.newText === \"string\" ? edit.newText : undefined;\n if (!oldText) {\n throw new Error(\n index === 0\n ? \"oldText is required and cannot be empty.\"\n : `edits[${index}].oldText is required and cannot be empty.`,\n );\n }\n if (newText === undefined) {\n throw new Error(\n index === 0\n ? \"newText is required.\"\n : `edits[${index}].newText is required.`,\n );\n }\n return {\n oldText,\n newText,\n replaceAll: stringArg(edit.replaceAll).toLowerCase() === \"true\",\n };\n}\n\nfunction countOccurrences(value: string, needle: string): number {\n let count = 0;\n let index = 0;\n while (true) {\n index = value.indexOf(needle, index);\n if (index === -1) return count;\n count += 1;\n index += needle.length;\n }\n}\n\nfunction queueFileMutation<T>(filePath: string, task: () => Promise<T> | T) {\n const previous = mutationQueues.get(filePath) ?? Promise.resolve();\n const next = previous.catch(() => undefined).then(task);\n let queued: Promise<unknown>;\n queued = next.finally(() => {\n if (mutationQueues.get(filePath) === queued)\n mutationQueues.delete(filePath);\n });\n mutationQueues.set(filePath, queued);\n return next;\n}\n\nfunction previewText(value: string): string {\n const oneLine = value.replace(/\\s+/g, \" \").trim();\n return oneLine.length > 80 ? `${oneLine.slice(0, 80)}...` : oneLine;\n}\n\nfunction stringArg(value: unknown): string {\n return typeof value === \"string\" ? value : \"\";\n}\n\nfunction positiveInteger(value: unknown, fallback: number): number {\n const parsed = Number(value);\n return Number.isFinite(parsed) && parsed > 0 ? Math.floor(parsed) : fallback;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/coding-tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,MAAM,SAAS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AAwB,CAAC;IAC7B,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE;QACzB,IAAI,cAAc,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,MAAM;YACzC,cAAc,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IACpC,CAAC,CAAC,CAAC;IACH,cAAc,CAAC,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IACrC,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,WAAW,CAAC,KAAa;IAChC,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;IAClD,OAAO,OAAO,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC;AACtE,CAAC;AAED,SAAS,SAAS,CAAC,KAAc;IAC/B,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;AAChD,CAAC;AAED,SAAS,eAAe,CAAC,KAAc,EAAE,QAAgB;IACvD,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC7B,OAAO,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;AAC/E,CAAC","sourcesContent":["import { spawn } from \"node:child_process\";\nimport fs from \"node:fs\";\nimport os from \"node:os\";\nimport path from \"node:path\";\n\nimport type { ActionEntry } from \"../agent/production-agent.js\";\n\nexport interface CodingCommandResult {\n code: number | null;\n stdout: string;\n stderr: string;\n timedOut: boolean;\n durationMs?: number;\n}\n\n/**\n * Structured metadata emitted on tool_start / tool_done events so the UI can\n * render bespoke cells (bash terminal, edit diff, etc.) instead of the generic\n * pill. Fields are additive — older consumers that don't know them are unaffected.\n */\nexport interface BashToolMetadata {\n toolKind: \"bash\";\n command: string;\n cwd: string;\n exitCode?: number | null;\n durationMs?: number;\n timedOut?: boolean;\n}\n\nexport interface EditToolMetadata {\n toolKind: \"edit\";\n filePath: string;\n /** The exact old text replaced (capped at EDIT_CONTENT_MAX_CHARS). */\n oldText?: string;\n /** The exact new text written (capped at EDIT_CONTENT_MAX_CHARS). */\n newText?: string;\n truncated?: boolean;\n}\n\nexport interface WriteToolMetadata {\n toolKind: \"write\";\n filePath: string;\n /** Full file content written (capped at EDIT_CONTENT_MAX_CHARS). */\n content?: string;\n truncated?: boolean;\n lineCount?: number;\n}\n\nexport interface ReadToolMetadata {\n toolKind: \"read\";\n filePath: string;\n lineCount?: number;\n}\n\nexport type StructuredToolMetadata =\n | BashToolMetadata\n | EditToolMetadata\n | WriteToolMetadata\n | ReadToolMetadata;\n\n/** Callback invoked with incremental bash output while the command is running. */\nexport type BashOutputChunkCallback = (chunk: string) => void;\n\nexport interface CreateCodingToolRegistryOptions {\n cwd?: string;\n restrictToCwd?: boolean;\n commandTimeoutMs?: number;\n maxOutputChars?: number;\n maxFileReadChars?: number;\n bashThrowsOnNonZero?: boolean;\n canWrite?: (toolName: \"edit\" | \"write\") => string | null;\n beforeBash?: (input: {\n command: string;\n cwd: string;\n timeoutMs: number;\n }) => string | null | Promise<string | null>;\n /** Called with incremental stdout+stderr chunks while a bash command runs. */\n onBashOutputChunk?: BashOutputChunkCallback;\n /**\n * Called when structured metadata is available for a tool call. The\n * `phase` is \"start\" (right before execution) or \"done\" (after execution).\n * This is the side-channel used to populate bespoke tool-cell fields without\n * changing the string-result contract that the agent sees.\n */\n onToolMetadata?: (\n toolName: string,\n phase: \"start\" | \"done\",\n meta: StructuredToolMetadata,\n ) => void;\n}\n\ninterface EditOperation {\n oldText: string;\n newText: string;\n replaceAll: boolean;\n}\n\nconst DEFAULT_COMMAND_TIMEOUT_MS = 120_000;\nconst DEFAULT_MAX_OUTPUT_CHARS = 50_000;\nconst DEFAULT_MAX_FILE_READ_CHARS = 120_000;\n\n/**\n * Output retention window for bash: keep first HEAD_CHARS + last TAIL_CHARS,\n * separated by a truncation marker. Replaces the old flat 4 000-char cap.\n */\nexport const BASH_OUTPUT_HEAD_CHARS = 4_096;\nexport const BASH_OUTPUT_TAIL_CHARS = 16_384;\n\n/** Maximum chars stored per side of an edit/write for diff rendering. */\nexport const EDIT_CONTENT_MAX_CHARS = 49_152;\n\nconst mutationQueues = new Map<string, Promise<unknown>>();\n\nexport function createCodingToolRegistry(\n options: CreateCodingToolRegistryOptions = {},\n): Record<\"bash\" | \"read\" | \"edit\" | \"write\", ActionEntry> {\n const cwd = path.resolve(options.cwd ?? process.cwd());\n const restrictToCwd = options.restrictToCwd ?? false;\n const commandTimeoutMs =\n options.commandTimeoutMs ?? DEFAULT_COMMAND_TIMEOUT_MS;\n const maxOutputChars = options.maxOutputChars ?? DEFAULT_MAX_OUTPUT_CHARS;\n const maxFileReadChars =\n options.maxFileReadChars ?? DEFAULT_MAX_FILE_READ_CHARS;\n\n return {\n bash: {\n tool: {\n description:\n 'Run a shell command. This is the tool for file discovery, directory listing, and search: reach first for `rg <pattern>` and `rg --files`, which are much faster than `grep` or `find`. Also use it to run tests, builds, package scripts, `git status`/`git diff`, and project CLIs. Use the read tool to view a single file\\'s contents; use bash for everything else. Very long output is truncated.\\n\\nSet `background` to \"true\" to spawn the command detached and return immediately. The tool returns the PID and a log file path; the process writes its stdout/stderr to that log file. You can read or tail the log file to check progress, and run `kill <pid>` to stop it. Background processes are not killed when the timeout expires.',\n parameters: {\n type: \"object\",\n properties: {\n command: {\n type: \"string\",\n description: \"The shell command to run (executed via bash).\",\n },\n cwd: {\n type: \"string\",\n description:\n \"Working directory for the command. Relative to the workspace root unless absolute paths are allowed. Defaults to the workspace root.\",\n },\n timeoutMs: {\n type: \"string\",\n description:\n \"Timeout in milliseconds; the command is killed if it exceeds this. Defaults to 120000, capped at 600000. Ignored when background is true.\",\n },\n stdin: {\n type: \"string\",\n description: \"Text to pipe into the command's stdin.\",\n },\n background: {\n type: \"string\",\n description:\n 'Set to \"true\" to spawn the command detached in the background and return immediately. Returns the process PID and a log file path where stdout/stderr are written.',\n enum: [\"true\", \"false\"],\n },\n },\n required: [\"command\"],\n },\n },\n run: async (args) => {\n const command = stringArg(args.command);\n if (!command) return \"Error: command is required.\";\n const commandCwd =\n resolveCodingPath(cwd, stringArg(args.cwd) || \".\", {\n restrictToCwd,\n allowEmpty: true,\n }) ?? \"\";\n if (!commandCwd) {\n return \"Error: cwd must stay inside the workspace.\";\n }\n const requestedTimeoutMs = Number(args.timeoutMs);\n const timeoutMs =\n Number.isFinite(requestedTimeoutMs) && requestedTimeoutMs > 0\n ? Math.min(requestedTimeoutMs, 10 * 60_000)\n : commandTimeoutMs;\n\n const isBackground =\n stringArg(args.background).toLowerCase() === \"true\";\n\n const policyResult =\n (await options.beforeBash?.({\n command,\n cwd: commandCwd,\n timeoutMs,\n })) ?? null;\n if (policyResult) return policyResult;\n\n options.onToolMetadata?.(\"bash\", \"start\", {\n toolKind: \"bash\",\n command,\n cwd: commandCwd,\n });\n\n if (isBackground) {\n const result = spawnBackgroundCommand(command, commandCwd);\n options.onToolMetadata?.(\"bash\", \"done\", {\n toolKind: \"bash\",\n command,\n cwd: commandCwd,\n });\n return result;\n }\n\n const result = await runCodingCommand(command, commandCwd, timeoutMs, {\n stdin: stringArg(args.stdin) || undefined,\n onChunk: options.onBashOutputChunk,\n });\n\n options.onToolMetadata?.(\"bash\", \"done\", {\n toolKind: \"bash\",\n command,\n cwd: commandCwd,\n exitCode: result.code,\n durationMs: result.durationMs,\n timedOut: result.timedOut || undefined,\n });\n\n if (options.bashThrowsOnNonZero && result.code !== 0) {\n throw new Error(formatCodingCommandResult(result, maxOutputChars));\n }\n return formatCodingCommandResult(result, maxOutputChars, {\n omitEmptyExitCode: options.bashThrowsOnNonZero && result.code === 0,\n });\n },\n },\n read: {\n readOnly: true,\n tool: {\n description:\n \"Read a single UTF-8 text file, returned with 1-based line numbers. For a large file, use offset and limit to page through it instead of reading the whole thing. Read a file before editing it so your edit's oldText matches exactly. Use bash (`ls`, `rg --files`, `rg`) for directory listings, file discovery, and search; this tool reads one file only.\",\n parameters: {\n type: \"object\",\n properties: {\n path: {\n type: \"string\",\n description:\n \"Path to the file to read, relative to the workspace root unless absolute paths are allowed.\",\n },\n offset: {\n type: \"string\",\n description:\n \"1-based line number to start reading from. Defaults to the first line.\",\n },\n limit: {\n type: \"string\",\n description:\n \"Maximum number of lines to read from offset. Defaults to the rest of the file.\",\n },\n },\n required: [\"path\"],\n },\n },\n run: async (args) => {\n const requestedPath = stringArg(args.path);\n const filePath = resolveCodingPath(cwd, requestedPath, {\n restrictToCwd,\n });\n if (!filePath) return \"Error: path must stay inside the workspace.\";\n if (!fs.existsSync(filePath)) {\n return `Error: file not found: ${requestedPath}`;\n }\n const stat = fs.statSync(filePath);\n if (!stat.isFile()) {\n return `Error: ${requestedPath} is not a file. Use bash for directories and file lists.`;\n }\n const content = fs.readFileSync(filePath, \"utf8\");\n const lineCount = content.split(\"\\n\").length;\n options.onToolMetadata?.(\"read\", \"start\", {\n toolKind: \"read\",\n filePath: path.relative(cwd, filePath) || requestedPath,\n lineCount,\n });\n const result = truncateCodingOutput(\n formatFileReadOutput(cwd, filePath, content, args),\n maxFileReadChars,\n );\n options.onToolMetadata?.(\"read\", \"done\", {\n toolKind: \"read\",\n filePath: path.relative(cwd, filePath) || requestedPath,\n lineCount,\n });\n return result;\n },\n },\n edit: {\n tool: {\n description:\n \"Edit an existing UTF-8 text file by replacing exact text. Prefer this over write for changes to existing files. Read the file first so oldText matches byte-for-byte, including whitespace and indentation. oldText must occur EXACTLY ONCE in the file: include enough surrounding context to make it unique. The edit fails (and the file is left unchanged) if oldText is not found or matches more than once, unless replaceAll is true, which replaces every occurrence. To apply several edits to one file in a single call, pass edits as a JSON array of {oldText, newText, replaceAll} objects; they apply in order, and any failure aborts the whole call.\",\n parameters: {\n type: \"object\",\n properties: {\n path: {\n type: \"string\",\n description:\n \"Path to the file to edit, relative to the workspace root unless absolute paths are allowed.\",\n },\n oldText: {\n type: \"string\",\n description:\n \"Exact existing text to replace, for a single edit. Must match the file exactly and uniquely (include surrounding context) unless replaceAll is true.\",\n },\n newText: {\n type: \"string\",\n description: \"Text to replace oldText with, for a single edit.\",\n },\n replaceAll: {\n type: \"string\",\n description:\n 'Set to \"true\" to replace every occurrence of oldText instead of requiring a unique match. Defaults to \"false\".',\n enum: [\"true\", \"false\"],\n },\n edits: {\n type: \"string\",\n description:\n 'JSON array of edits to apply to this file in one call, e.g. [{\"oldText\":\"foo\",\"newText\":\"bar\"},{\"oldText\":\"baz\",\"newText\":\"qux\",\"replaceAll\":\"true\"}]. When provided, the top-level oldText/newText are ignored.',\n },\n },\n required: [\"path\"],\n },\n },\n run: async (args) => {\n const permissionError = options.canWrite?.(\"edit\") ?? null;\n if (permissionError) return permissionError;\n\n const requestedPath = stringArg(args.path);\n const filePath = resolveCodingPath(cwd, requestedPath, {\n restrictToCwd,\n });\n if (!filePath) return \"Error: path must stay inside the workspace.\";\n const edits = parseEditOperations(args);\n const relPath = path.relative(cwd, filePath) || requestedPath;\n\n options.onToolMetadata?.(\"edit\", \"start\", {\n toolKind: \"edit\",\n filePath: relPath,\n });\n\n return queueFileMutation(filePath, async () => {\n if (!fs.existsSync(filePath)) {\n throw new Error(`file not found: ${requestedPath}`);\n }\n const stat = fs.statSync(filePath);\n if (!stat.isFile()) {\n throw new Error(`${requestedPath} is not a file`);\n }\n\n const originalContent = fs.readFileSync(filePath, \"utf8\");\n let content = originalContent;\n let replacements = 0;\n for (const edit of edits) {\n const count = countOccurrences(content, edit.oldText);\n if (count === 0) {\n throw new Error(\n `oldText was not found in ${requestedPath}: ${previewText(\n edit.oldText,\n )}`,\n );\n }\n if (!edit.replaceAll && count !== 1) {\n throw new Error(\n `oldText matched ${count} times in ${requestedPath}; make it unique or set replaceAll=true.`,\n );\n }\n content = edit.replaceAll\n ? content.split(edit.oldText).join(edit.newText)\n : content.replace(edit.oldText, edit.newText);\n replacements += edit.replaceAll ? count : 1;\n }\n\n fs.writeFileSync(filePath, content, \"utf8\");\n\n // Emit structured diff metadata so the UI can render a real diff.\n const truncated =\n originalContent.length > EDIT_CONTENT_MAX_CHARS ||\n content.length > EDIT_CONTENT_MAX_CHARS;\n options.onToolMetadata?.(\"edit\", \"done\", {\n toolKind: \"edit\",\n filePath: relPath,\n oldText: originalContent.slice(0, EDIT_CONTENT_MAX_CHARS),\n newText: content.slice(0, EDIT_CONTENT_MAX_CHARS),\n truncated,\n });\n\n return `Edited ${relPath} (${replacements} replacement${replacements === 1 ? \"\" : \"s\"}).`;\n });\n },\n },\n write: {\n tool: {\n description:\n \"Create a new UTF-8 text file, or fully overwrite an existing one with the given content. Missing parent directories are created. For changes to an existing file, prefer edit; only use write when you intend to replace the entire file. Default to ASCII content unless the file already uses other characters or there is a clear reason not to.\",\n parameters: {\n type: \"object\",\n properties: {\n path: {\n type: \"string\",\n description:\n \"Path to the file to write, relative to the workspace root unless absolute paths are allowed.\",\n },\n content: {\n type: \"string\",\n description:\n \"Full contents to write. This replaces the entire file; existing content is not preserved.\",\n },\n },\n required: [\"path\", \"content\"],\n },\n },\n run: async (args) => {\n const permissionError = options.canWrite?.(\"write\") ?? null;\n if (permissionError) return permissionError;\n\n const requestedPath = stringArg(args.path);\n const filePath = resolveCodingPath(cwd, requestedPath, {\n restrictToCwd,\n });\n if (!filePath) return \"Error: path must stay inside the workspace.\";\n const content = stringArg(args.content);\n const relPath = path.relative(cwd, filePath) || requestedPath;\n\n options.onToolMetadata?.(\"write\", \"start\", {\n toolKind: \"write\",\n filePath: relPath,\n });\n\n return queueFileMutation(filePath, async () => {\n fs.mkdirSync(path.dirname(filePath), { recursive: true });\n const existed = fs.existsSync(filePath);\n fs.writeFileSync(filePath, content, \"utf8\");\n const bytes = Buffer.byteLength(content, \"utf8\");\n const lines = content.split(\"\\n\").length;\n\n const truncated = content.length > EDIT_CONTENT_MAX_CHARS;\n options.onToolMetadata?.(\"write\", \"done\", {\n toolKind: \"write\",\n filePath: relPath,\n content: content.slice(0, EDIT_CONTENT_MAX_CHARS),\n truncated,\n lineCount: lines,\n });\n\n return `${existed ? \"Updated\" : \"Created\"} ${relPath} (${lines} lines, ${bytes} bytes).`;\n });\n },\n },\n };\n}\n\nexport async function runCodingCommand(\n command: string,\n cwd: string,\n timeoutMs: number,\n options: { stdin?: string; onChunk?: BashOutputChunkCallback } = {},\n): Promise<CodingCommandResult> {\n const child = spawn(command, {\n cwd,\n shell: true,\n stdio: [\"pipe\", \"pipe\", \"pipe\"],\n env: { ...process.env, FORCE_COLOR: \"0\" },\n });\n let stdout = \"\";\n let stderr = \"\";\n let timedOut = false;\n const startMs = Date.now();\n const timer = setTimeout(() => {\n timedOut = true;\n child.kill(\"SIGTERM\");\n }, timeoutMs);\n child.stdout?.on(\"data\", (chunk: Buffer) => {\n const text = chunk.toString();\n stdout += text;\n options.onChunk?.(text);\n });\n child.stderr?.on(\"data\", (chunk: Buffer) => {\n const text = chunk.toString();\n stderr += text;\n options.onChunk?.(text);\n });\n if (options.stdin) child.stdin?.end(options.stdin);\n else child.stdin?.end();\n const code = await new Promise<number | null>((resolve, reject) => {\n child.once(\"error\", reject);\n child.once(\"close\", resolve);\n });\n clearTimeout(timer);\n return { code, stdout, stderr, timedOut, durationMs: Date.now() - startMs };\n}\n\n/**\n * Spawn a command detached in the background. Returns immediately with the\n * process PID and a temporary log file path where stdout + stderr are written.\n *\n * The child process is intentionally detached from the parent's process group\n * (`detached: true`, `unref()`) so it continues running after the tool call\n * completes and is not killed if the agent run exits. The approval classifier\n * still applies before this function is reached (see `beforeBash` in the\n * calling registry).\n */\nexport function spawnBackgroundCommand(command: string, cwd: string): string {\n const logFile = path.join(\n os.tmpdir(),\n `an-bg-${Date.now()}-${Math.random().toString(36).slice(2, 8)}.log`,\n );\n\n const logFd = fs.openSync(logFile, \"a\");\n const child = spawn(command, {\n cwd,\n shell: true,\n stdio: [\"ignore\", logFd, logFd],\n detached: true,\n env: { ...process.env, FORCE_COLOR: \"0\" },\n });\n child.unref();\n fs.closeSync(logFd);\n\n const pid = child.pid ?? 0;\n return [\n `Background process spawned.`,\n `pid: ${pid}`,\n `log: ${logFile}`,\n `Read the log file to check progress. Run \\`kill ${pid}\\` to stop the process.`,\n ].join(\"\\n\");\n}\n\nexport function formatCodingCommandResult(\n result: CodingCommandResult,\n maxChars = DEFAULT_MAX_OUTPUT_CHARS,\n options: { omitEmptyExitCode?: boolean } = {},\n): string {\n const parts = [\n options.omitEmptyExitCode && result.code === 0\n ? \"\"\n : `exitCode: ${result.code}`,\n result.timedOut ? \"timedOut: true\" : \"\",\n result.stdout ? `stdout:\\n${result.stdout}` : \"\",\n result.stderr ? `stderr:\\n${result.stderr}` : \"\",\n ].filter(Boolean);\n return truncateCodingOutput(parts.join(\"\\n\\n\") || \"(no output)\", maxChars);\n}\n\nexport function truncateCodingOutput(value: string, max: number): string {\n if (value.length <= max) return value;\n return `${value.slice(0, max)}\\n\\n...[truncated ${value.length - max} chars]`;\n}\n\n/**\n * Retain the first HEAD_CHARS and the last TAIL_CHARS of bash output, inserting\n * a truncation marker in the middle. This is a better window than a simple\n * prefix slice because the end of the output usually contains the most important\n * signal (error messages, test results, etc.).\n */\nexport function truncateBashOutput(\n value: string,\n headChars = BASH_OUTPUT_HEAD_CHARS,\n tailChars = BASH_OUTPUT_TAIL_CHARS,\n): string {\n const max = headChars + tailChars;\n if (value.length <= max) return value;\n const omitted = value.length - max;\n return `${value.slice(0, headChars)}\\n\\n...[${omitted} chars omitted]\\n\\n${value.slice(value.length - tailChars)}`;\n}\n\nexport function isReadOnlyShellCommand(command: string): boolean {\n const normalized = command.trim().toLowerCase();\n if (!normalized) return false;\n\n // Read-only modes get a deliberately tiny shell grammar: one command only,\n // no redirection, pipes, sequencing, backgrounding, or command substitution.\n // Prefix allowlists are not safe until these shell forms are excluded.\n if (/[\\n\\r;&|<>]/.test(normalized)) return false;\n if (/\\$\\(|`|\\${|\\\\\\n/.test(command)) return false;\n\n // `sed` can WRITE even in `-n` mode via the `w`/`W` commands or `-i`\n // (e.g. `sed -n '1w out.txt' file`), so the `^sed -n` allowlist entry\n // below is not safe on its own. Reject any sed that can write.\n if (/^sed\\b/.test(normalized)) {\n if (/(^|\\s)-i(\\b|=)|--in-place/.test(normalized)) return false;\n // `w`/`W` used as a sed command: preceded by an address/separator\n // (digit, $, /, }, ;, quote, space) and followed by a filename arg or\n // end. Catches `1w f`, `$w f`, `/re/w f`, `s/x/y/w f`, `2W f`; leaves\n // prints like `/window/p`, `1,5p`, `s/a/b/` untouched.\n if (/[\\s'\"0-9$}/;](w|W)([\\s'\"]|$)/.test(normalized)) return false;\n }\n\n const allowedPrefixes = [\n /^pwd\\b/,\n /^ls\\b/,\n /^find\\b/,\n /^rg\\b/,\n /^grep\\b/,\n /^cat\\b/,\n /^sed\\s+-n\\b/,\n /^head\\b/,\n /^tail\\b/,\n /^wc\\b/,\n /^git\\s+(status|diff|show|log)\\b/,\n /^git\\s+branch\\s+--show-current\\b/,\n ];\n return allowedPrefixes.some((pattern) => pattern.test(normalized));\n}\n\nfunction resolveCodingPath(\n cwd: string,\n value: string,\n options: { restrictToCwd: boolean; allowEmpty?: boolean },\n): string | null {\n if (!value.trim() && !options.allowEmpty) return null;\n const target = value.trim() || \".\";\n const resolved = path.isAbsolute(target)\n ? path.resolve(target)\n : path.resolve(cwd, target);\n if (!options.restrictToCwd) return resolved;\n\n const relative = path.relative(cwd, resolved);\n if (relative.startsWith(\"..\") || path.isAbsolute(relative)) return null;\n return resolved;\n}\n\nfunction formatFileReadOutput(\n cwd: string,\n filePath: string,\n content: string,\n args: Record<string, unknown>,\n): string {\n const lines = content.split(\"\\n\");\n const offset = positiveInteger(args.offset, 1);\n const limit = positiveInteger(args.limit, lines.length - offset + 1);\n const selected = lines.slice(offset - 1, offset - 1 + limit);\n const body = selected\n .map((line, index) => `${String(offset + index).padStart(5)} | ${line}`)\n .join(\"\\n\");\n return `${path.relative(cwd, filePath) || filePath} (${lines.length} lines)\\n${body}`;\n}\n\nfunction parseEditOperations(args: Record<string, unknown>): EditOperation[] {\n const editsJson = stringArg(args.edits);\n if (editsJson.trim()) {\n let parsed: unknown;\n try {\n parsed = JSON.parse(editsJson);\n } catch (err) {\n throw new Error(\n `edits must be valid JSON: ${err instanceof Error ? err.message : String(err)}`,\n );\n }\n if (!Array.isArray(parsed) || parsed.length === 0) {\n throw new Error(\"edits must be a non-empty JSON array.\");\n }\n return parsed.map((edit, index) => {\n if (!edit || typeof edit !== \"object\") {\n throw new Error(`edits[${index}] must be an object.`);\n }\n return normalizeEditOperation(edit as Record<string, unknown>, index);\n });\n }\n\n return [normalizeEditOperation(args, 0)];\n}\n\nfunction normalizeEditOperation(\n edit: Record<string, unknown>,\n index: number,\n): EditOperation {\n const oldText = typeof edit.oldText === \"string\" ? edit.oldText : undefined;\n const newText = typeof edit.newText === \"string\" ? edit.newText : undefined;\n if (!oldText) {\n throw new Error(\n index === 0\n ? \"oldText is required and cannot be empty.\"\n : `edits[${index}].oldText is required and cannot be empty.`,\n );\n }\n if (newText === undefined) {\n throw new Error(\n index === 0\n ? \"newText is required.\"\n : `edits[${index}].newText is required.`,\n );\n }\n return {\n oldText,\n newText,\n replaceAll: stringArg(edit.replaceAll).toLowerCase() === \"true\",\n };\n}\n\nfunction countOccurrences(value: string, needle: string): number {\n let count = 0;\n let index = 0;\n while (true) {\n index = value.indexOf(needle, index);\n if (index === -1) return count;\n count += 1;\n index += needle.length;\n }\n}\n\nfunction queueFileMutation<T>(filePath: string, task: () => Promise<T> | T) {\n const previous = mutationQueues.get(filePath) ?? Promise.resolve();\n const next = previous.catch(() => undefined).then(task);\n let queued: Promise<unknown>;\n queued = next.finally(() => {\n if (mutationQueues.get(filePath) === queued)\n mutationQueues.delete(filePath);\n });\n mutationQueues.set(filePath, queued);\n return next;\n}\n\nfunction previewText(value: string): string {\n const oneLine = value.replace(/\\s+/g, \" \").trim();\n return oneLine.length > 80 ? `${oneLine.slice(0, 80)}...` : oneLine;\n}\n\nfunction stringArg(value: unknown): string {\n return typeof value === \"string\" ? value : \"\";\n}\n\nfunction positiveInteger(value: unknown, fallback: number): number {\n const parsed = Number(value);\n return Number.isFinite(parsed) && parsed > 0 ? Math.floor(parsed) : fallback;\n}\n"]}
|
package/dist/mcp/index.d.ts
CHANGED
|
@@ -4,6 +4,8 @@ export { createMCPServerForRequest, verifyAuth, getAccessTokens, resolveOrgIdFro
|
|
|
4
4
|
export type { MCPCallerIdentity, MCPRequestMeta } from "./build-server.js";
|
|
5
5
|
export { runMCPStdio } from "./stdio.js";
|
|
6
6
|
export type { RunMCPStdioOptions } from "./stdio.js";
|
|
7
|
+
export { runScreenMemoryMCPStdio } from "./screen-memory-stdio.js";
|
|
8
|
+
export type { RunScreenMemoryMCPStdioOptions } from "./screen-memory-stdio.js";
|
|
7
9
|
export { getBuiltinCrossAppTools } from "./builtin-tools.js";
|
|
8
10
|
export { embedApp, MCP_APP_REQUEST_ORIGIN_CSP_SOURCE, type EmbedAppOptions, } from "./embed-app.js";
|
|
9
11
|
export { embedRoute, type EmbedRouteContext, type EmbedRouteOptions, type EmbedRoutePathBuilder, type EmbedRouteResult, } from "./embed-route.js";
|
package/dist/mcp/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mcp/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,YAAY,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAG7C,OAAO,EACL,yBAAyB,EACzB,UAAU,EACV,eAAe,EACf,sBAAsB,EACtB,kBAAkB,GACnB,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAG3E,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,YAAY,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mcp/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,YAAY,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAG7C,OAAO,EACL,yBAAyB,EACzB,UAAU,EACV,eAAe,EACf,sBAAsB,EACtB,kBAAkB,GACnB,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAG3E,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,YAAY,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AACnE,YAAY,EAAE,8BAA8B,EAAE,MAAM,0BAA0B,CAAC;AAG/E,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EACL,QAAQ,EACR,iCAAiC,EACjC,KAAK,eAAe,GACrB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,UAAU,EACV,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,KAAK,qBAAqB,EAC1B,KAAK,gBAAgB,GACtB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EACL,gBAAgB,EAChB,qBAAqB,EACrB,iBAAiB,GAClB,MAAM,wBAAwB,CAAC;AAChC,YAAY,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC7E,OAAO,EACL,YAAY,EACZ,yBAAyB,EACzB,KAAK,MAAM,GACZ,MAAM,oBAAoB,CAAC"}
|
package/dist/mcp/index.js
CHANGED
|
@@ -3,6 +3,7 @@ export { mountMCP } from "./server.js";
|
|
|
3
3
|
export { createMCPServerForRequest, verifyAuth, getAccessTokens, resolveOrgIdFromDomain, buildLinkArtifacts, } from "./build-server.js";
|
|
4
4
|
// stdio transport for `agent-native mcp serve` (Node-only).
|
|
5
5
|
export { runMCPStdio } from "./stdio.js";
|
|
6
|
+
export { runScreenMemoryMCPStdio } from "./screen-memory-stdio.js";
|
|
6
7
|
// Generic cross-app builtin tools (merged into the registry, template wins).
|
|
7
8
|
export { getBuiltinCrossAppTools } from "./builtin-tools.js";
|
|
8
9
|
export { embedApp, MCP_APP_REQUEST_ORIGIN_CSP_SOURCE, } from "./embed-app.js";
|
package/dist/mcp/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/mcp/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAGvC,iFAAiF;AACjF,OAAO,EACL,yBAAyB,EACzB,UAAU,EACV,eAAe,EACf,sBAAsB,EACtB,kBAAkB,GACnB,MAAM,mBAAmB,CAAC;AAG3B,4DAA4D;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/mcp/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAGvC,iFAAiF;AACjF,OAAO,EACL,yBAAyB,EACzB,UAAU,EACV,eAAe,EACf,sBAAsB,EACtB,kBAAkB,GACnB,MAAM,mBAAmB,CAAC;AAG3B,4DAA4D;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzC,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AAGnE,6EAA6E;AAC7E,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EACL,QAAQ,EACR,iCAAiC,GAElC,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,UAAU,GAKX,MAAM,kBAAkB,CAAC;AAE1B,kDAAkD;AAClD,OAAO,EACL,gBAAgB,EAChB,qBAAqB,EACrB,iBAAiB,GAClB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EACL,YAAY,EACZ,yBAAyB,GAE1B,MAAM,oBAAoB,CAAC","sourcesContent":["export { mountMCP } from \"./server.js\";\nexport type { MCPConfig } from \"./server.js\";\n\n// Shared MCP server builder (also re-exported from ./server.js for back-compat).\nexport {\n createMCPServerForRequest,\n verifyAuth,\n getAccessTokens,\n resolveOrgIdFromDomain,\n buildLinkArtifacts,\n} from \"./build-server.js\";\nexport type { MCPCallerIdentity, MCPRequestMeta } from \"./build-server.js\";\n\n// stdio transport for `agent-native mcp serve` (Node-only).\nexport { runMCPStdio } from \"./stdio.js\";\nexport type { RunMCPStdioOptions } from \"./stdio.js\";\nexport { runScreenMemoryMCPStdio } from \"./screen-memory-stdio.js\";\nexport type { RunScreenMemoryMCPStdioOptions } from \"./screen-memory-stdio.js\";\n\n// Generic cross-app builtin tools (merged into the registry, template wins).\nexport { getBuiltinCrossAppTools } from \"./builtin-tools.js\";\nexport {\n embedApp,\n MCP_APP_REQUEST_ORIGIN_CSP_SOURCE,\n type EmbedAppOptions,\n} from \"./embed-app.js\";\nexport {\n embedRoute,\n type EmbedRouteContext,\n type EmbedRouteOptions,\n type EmbedRoutePathBuilder,\n type EmbedRouteResult,\n} from \"./embed-route.js\";\n\n// Workspace / app resolution helpers (Node-only).\nexport {\n resolveWorkspace,\n resolveLocalAppOrigin,\n findWorkspaceRoot,\n} from \"./workspace-resolve.js\";\nexport type { ResolvedApp, ResolvedWorkspace } from \"./workspace-resolve.js\";\nexport {\n fetchOrgApps,\n resolveOrgDirectoryOrigin,\n type OrgApp,\n} from \"./org-directory.js\";\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"screen-memory-stdio.d.ts","sourceRoot":"","sources":["../../src/mcp/screen-memory-stdio.ts"],"names":[],"mappings":"AA+BA,MAAM,WAAW,8BAA8B;IAC7C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;CACzB;AAgJD,wBAAsB,uBAAuB,CAC3C,IAAI,GAAE,8BAAmC,GACxC,OAAO,CAAC,IAAI,CAAC,CA6Gf"}
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import os from "node:os";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
const EVENTS_JSONL = "events.jsonl";
|
|
5
|
+
function log(msg) {
|
|
6
|
+
process.stderr.write(`[screen-memory-mcp] ${msg}\n`);
|
|
7
|
+
}
|
|
8
|
+
function defaultAppDataDir(env) {
|
|
9
|
+
const home = os.homedir();
|
|
10
|
+
if (process.platform === "darwin") {
|
|
11
|
+
return path.join(home, "Library", "Application Support", "com.clips.tray");
|
|
12
|
+
}
|
|
13
|
+
if (process.platform === "win32") {
|
|
14
|
+
return path.join(env.APPDATA || path.join(home, "AppData", "Roaming"), "com.clips.tray");
|
|
15
|
+
}
|
|
16
|
+
return path.join(env.XDG_DATA_HOME || path.join(home, ".local", "share"), "com.clips.tray");
|
|
17
|
+
}
|
|
18
|
+
function defaultStoreDir(env) {
|
|
19
|
+
const envDir = env.AGENT_NATIVE_SCREEN_MEMORY_DIR ?? env.CLIPS_SCREEN_MEMORY_DIR;
|
|
20
|
+
if (envDir)
|
|
21
|
+
return envDir;
|
|
22
|
+
return path.join(defaultAppDataDir(env), "screen-memory");
|
|
23
|
+
}
|
|
24
|
+
function readJsonl(file) {
|
|
25
|
+
let body = "";
|
|
26
|
+
try {
|
|
27
|
+
body = fs.readFileSync(file, "utf-8");
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
return [];
|
|
31
|
+
}
|
|
32
|
+
return body
|
|
33
|
+
.split(/\r?\n/)
|
|
34
|
+
.filter(Boolean)
|
|
35
|
+
.map((line) => {
|
|
36
|
+
try {
|
|
37
|
+
return JSON.parse(line);
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
})
|
|
43
|
+
.filter((value) => Boolean(value));
|
|
44
|
+
}
|
|
45
|
+
function readFeatureConfig(storeDir) {
|
|
46
|
+
const configPath = path.join(path.dirname(storeDir), "feature-config.json");
|
|
47
|
+
try {
|
|
48
|
+
const parsed = JSON.parse(fs.readFileSync(configPath, "utf-8"));
|
|
49
|
+
return parsed.screenMemory ?? {};
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
return {};
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
function cutoffFor(minutes) {
|
|
56
|
+
return Date.now() - Math.max(1, Math.min(minutes, 24 * 60)) * 60_000;
|
|
57
|
+
}
|
|
58
|
+
function eventMatches(event, query) {
|
|
59
|
+
const needle = query.trim().toLowerCase();
|
|
60
|
+
if (!needle)
|
|
61
|
+
return true;
|
|
62
|
+
return [event.appName, event.windowTitle, event.bundleId, event.source].some((value) => value?.toLowerCase().includes(needle));
|
|
63
|
+
}
|
|
64
|
+
function recentEvents(storeDir, args) {
|
|
65
|
+
const cutoff = cutoffFor(args.minutes ?? 30);
|
|
66
|
+
const limit = Math.max(1, Math.min(args.limit ?? 40, 200));
|
|
67
|
+
return readJsonl(path.join(storeDir, EVENTS_JSONL))
|
|
68
|
+
.filter((event) => {
|
|
69
|
+
const capturedAt = Date.parse(event.capturedAt);
|
|
70
|
+
return Number.isFinite(capturedAt) && capturedAt >= cutoff;
|
|
71
|
+
})
|
|
72
|
+
.filter((event) => eventMatches(event, args.query ?? ""))
|
|
73
|
+
.sort((a, b) => b.capturedAt.localeCompare(a.capturedAt))
|
|
74
|
+
.slice(0, limit);
|
|
75
|
+
}
|
|
76
|
+
function readSegments(storeDir) {
|
|
77
|
+
let entries = [];
|
|
78
|
+
try {
|
|
79
|
+
entries = fs.readdirSync(storeDir);
|
|
80
|
+
}
|
|
81
|
+
catch {
|
|
82
|
+
return [];
|
|
83
|
+
}
|
|
84
|
+
return entries
|
|
85
|
+
.filter((entry) => entry.endsWith(".json"))
|
|
86
|
+
.map((entry) => {
|
|
87
|
+
try {
|
|
88
|
+
return JSON.parse(fs.readFileSync(path.join(storeDir, entry), "utf-8"));
|
|
89
|
+
}
|
|
90
|
+
catch {
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
})
|
|
94
|
+
.filter((segment) => Boolean(segment));
|
|
95
|
+
}
|
|
96
|
+
function recentSegments(storeDir, minutes) {
|
|
97
|
+
const cutoff = cutoffFor(minutes);
|
|
98
|
+
return readSegments(storeDir)
|
|
99
|
+
.filter((segment) => {
|
|
100
|
+
const endedAt = Date.parse(segment.endedAt);
|
|
101
|
+
return (Number.isFinite(endedAt) &&
|
|
102
|
+
endedAt >= cutoff &&
|
|
103
|
+
typeof segment.path === "string" &&
|
|
104
|
+
fs.existsSync(segment.path) &&
|
|
105
|
+
segment.corrupt !== true);
|
|
106
|
+
})
|
|
107
|
+
.sort((a, b) => b.endedAt.localeCompare(a.endedAt));
|
|
108
|
+
}
|
|
109
|
+
function textResult(value) {
|
|
110
|
+
return {
|
|
111
|
+
content: [
|
|
112
|
+
{
|
|
113
|
+
type: "text",
|
|
114
|
+
text: typeof value === "string" ? value : JSON.stringify(value, null, 2),
|
|
115
|
+
},
|
|
116
|
+
],
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
export async function runScreenMemoryMCPStdio(opts = {}) {
|
|
120
|
+
const env = opts.env ?? process.env;
|
|
121
|
+
const storeDir = opts.storeDir ?? defaultStoreDir(env);
|
|
122
|
+
const { Server } = await import("@modelcontextprotocol/sdk/server/index.js");
|
|
123
|
+
const { StdioServerTransport } = await import("@modelcontextprotocol/sdk/server/stdio.js");
|
|
124
|
+
const { CallToolRequestSchema, ListToolsRequestSchema } = await import("@modelcontextprotocol/sdk/types.js");
|
|
125
|
+
const server = new Server({ name: "clips-screen-memory", version: "0.1.0" }, { capabilities: { tools: {} } });
|
|
126
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
127
|
+
tools: [
|
|
128
|
+
{
|
|
129
|
+
name: "screen_memory_status",
|
|
130
|
+
description: "Read local Clips Screen Memory status, retention, disk usage, and store path. Local-only.",
|
|
131
|
+
inputSchema: { type: "object", properties: {} },
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
name: "screen_memory_recent_context",
|
|
135
|
+
description: "Search recent local Screen Memory app/window context. Returns timestamps, app names, window titles, and bundle ids; does not return images.",
|
|
136
|
+
inputSchema: {
|
|
137
|
+
type: "object",
|
|
138
|
+
properties: {
|
|
139
|
+
query: {
|
|
140
|
+
type: "string",
|
|
141
|
+
description: "Optional case-insensitive text filter.",
|
|
142
|
+
},
|
|
143
|
+
minutes: {
|
|
144
|
+
type: "number",
|
|
145
|
+
description: "Lookback window in minutes. Defaults to 30.",
|
|
146
|
+
},
|
|
147
|
+
limit: {
|
|
148
|
+
type: "number",
|
|
149
|
+
description: "Maximum events to return. Defaults to 40.",
|
|
150
|
+
},
|
|
151
|
+
},
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
name: "screen_memory_recent_segments",
|
|
156
|
+
description: "List recent local Screen Memory video segment file paths and timestamps. Use only when the user asks to inspect or export local context.",
|
|
157
|
+
inputSchema: {
|
|
158
|
+
type: "object",
|
|
159
|
+
properties: {
|
|
160
|
+
minutes: {
|
|
161
|
+
type: "number",
|
|
162
|
+
description: "Lookback window in minutes. Defaults to 30.",
|
|
163
|
+
},
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
},
|
|
167
|
+
],
|
|
168
|
+
}));
|
|
169
|
+
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
170
|
+
const name = request.params?.name;
|
|
171
|
+
const args = (request.params?.arguments ?? {});
|
|
172
|
+
if (name === "screen_memory_status") {
|
|
173
|
+
const config = readFeatureConfig(storeDir);
|
|
174
|
+
const segments = recentSegments(storeDir, 24 * 60);
|
|
175
|
+
return textResult({
|
|
176
|
+
enabled: config.enabled === true,
|
|
177
|
+
paused: config.paused === true,
|
|
178
|
+
retentionHours: config.retentionHours ?? 24,
|
|
179
|
+
maxBytes: config.maxBytes ?? 20 * 1024 * 1024 * 1024,
|
|
180
|
+
segmentCount: segments.length,
|
|
181
|
+
totalBytes: segments.reduce((sum, segment) => sum + (segment.bytes || 0), 0),
|
|
182
|
+
storeDir,
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
if (name === "screen_memory_recent_context") {
|
|
186
|
+
return textResult({
|
|
187
|
+
storeDir,
|
|
188
|
+
events: recentEvents(storeDir, {
|
|
189
|
+
query: typeof args.query === "string" ? args.query : undefined,
|
|
190
|
+
minutes: typeof args.minutes === "number" ? args.minutes : undefined,
|
|
191
|
+
limit: typeof args.limit === "number" ? args.limit : undefined,
|
|
192
|
+
}),
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
if (name === "screen_memory_recent_segments") {
|
|
196
|
+
const minutes = typeof args.minutes === "number" ? args.minutes : 30;
|
|
197
|
+
return textResult({
|
|
198
|
+
storeDir,
|
|
199
|
+
segments: recentSegments(storeDir, minutes),
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
throw new Error(`Unknown Screen Memory tool: ${name}`);
|
|
203
|
+
});
|
|
204
|
+
log(`Serving local Screen Memory from ${storeDir}`);
|
|
205
|
+
const transport = new StdioServerTransport();
|
|
206
|
+
await server.connect(transport);
|
|
207
|
+
await new Promise((resolve) => {
|
|
208
|
+
transport.onclose = resolve;
|
|
209
|
+
process.once("SIGINT", resolve);
|
|
210
|
+
process.once("SIGTERM", resolve);
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
//# sourceMappingURL=screen-memory-stdio.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"screen-memory-stdio.js","sourceRoot":"","sources":["../../src/mcp/screen-memory-stdio.ts"],"names":[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,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAChC,MAAM,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE;QAClC,SAAS,CAAC,OAAO,GAAG,OAAO,CAAC;QAC5B,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QAChC,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IACnC,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import fs from \"node:fs\";\nimport os from \"node:os\";\nimport path from \"node:path\";\n\ninterface ScreenMemoryEvent {\n capturedAt: string;\n appName?: string | null;\n windowTitle?: string | null;\n bundleId?: string | null;\n source: string;\n}\n\ninterface ScreenMemorySegment {\n id: string;\n startedAt: string;\n endedAt: string;\n path: string;\n fileName?: string;\n mimeType: string;\n bytes: number;\n durationMs: number;\n corrupt?: boolean;\n}\n\ninterface ScreenMemoryConfig {\n enabled?: boolean;\n paused?: boolean;\n retentionHours?: number;\n maxBytes?: number;\n}\n\nexport interface RunScreenMemoryMCPStdioOptions {\n storeDir?: string;\n env?: NodeJS.ProcessEnv;\n}\n\nconst EVENTS_JSONL = \"events.jsonl\";\n\nfunction log(msg: string): void {\n process.stderr.write(`[screen-memory-mcp] ${msg}\\n`);\n}\n\nfunction defaultAppDataDir(env: NodeJS.ProcessEnv): string {\n const home = os.homedir();\n if (process.platform === \"darwin\") {\n return path.join(home, \"Library\", \"Application Support\", \"com.clips.tray\");\n }\n if (process.platform === \"win32\") {\n return path.join(\n env.APPDATA || path.join(home, \"AppData\", \"Roaming\"),\n \"com.clips.tray\",\n );\n }\n return path.join(\n env.XDG_DATA_HOME || path.join(home, \".local\", \"share\"),\n \"com.clips.tray\",\n );\n}\n\nfunction defaultStoreDir(env: NodeJS.ProcessEnv): string {\n const envDir =\n env.AGENT_NATIVE_SCREEN_MEMORY_DIR ?? env.CLIPS_SCREEN_MEMORY_DIR;\n if (envDir) return envDir;\n return path.join(defaultAppDataDir(env), \"screen-memory\");\n}\n\nfunction readJsonl<T>(file: string): T[] {\n let body = \"\";\n try {\n body = fs.readFileSync(file, \"utf-8\");\n } catch {\n return [];\n }\n return body\n .split(/\\r?\\n/)\n .filter(Boolean)\n .map((line) => {\n try {\n return JSON.parse(line) as T;\n } catch {\n return null;\n }\n })\n .filter((value): value is T => Boolean(value));\n}\n\nfunction readFeatureConfig(storeDir: string): ScreenMemoryConfig {\n const configPath = path.join(path.dirname(storeDir), \"feature-config.json\");\n try {\n const parsed = JSON.parse(fs.readFileSync(configPath, \"utf-8\")) as {\n screenMemory?: ScreenMemoryConfig;\n };\n return parsed.screenMemory ?? {};\n } catch {\n return {};\n }\n}\n\nfunction cutoffFor(minutes: number): number {\n return Date.now() - Math.max(1, Math.min(minutes, 24 * 60)) * 60_000;\n}\n\nfunction eventMatches(event: ScreenMemoryEvent, query: string): boolean {\n const needle = query.trim().toLowerCase();\n if (!needle) return true;\n return [event.appName, event.windowTitle, event.bundleId, event.source].some(\n (value) => value?.toLowerCase().includes(needle),\n );\n}\n\nfunction recentEvents(\n storeDir: string,\n args: { query?: string; minutes?: number; limit?: number },\n): ScreenMemoryEvent[] {\n const cutoff = cutoffFor(args.minutes ?? 30);\n const limit = Math.max(1, Math.min(args.limit ?? 40, 200));\n return readJsonl<ScreenMemoryEvent>(path.join(storeDir, EVENTS_JSONL))\n .filter((event) => {\n const capturedAt = Date.parse(event.capturedAt);\n return Number.isFinite(capturedAt) && capturedAt >= cutoff;\n })\n .filter((event) => eventMatches(event, args.query ?? \"\"))\n .sort((a, b) => b.capturedAt.localeCompare(a.capturedAt))\n .slice(0, limit);\n}\n\nfunction readSegments(storeDir: string): ScreenMemorySegment[] {\n let entries: string[] = [];\n try {\n entries = fs.readdirSync(storeDir);\n } catch {\n return [];\n }\n return entries\n .filter((entry) => entry.endsWith(\".json\"))\n .map((entry) => {\n try {\n return JSON.parse(\n fs.readFileSync(path.join(storeDir, entry), \"utf-8\"),\n ) as ScreenMemorySegment;\n } catch {\n return null;\n }\n })\n .filter((segment): segment is ScreenMemorySegment => Boolean(segment));\n}\n\nfunction recentSegments(\n storeDir: string,\n minutes: number,\n): ScreenMemorySegment[] {\n const cutoff = cutoffFor(minutes);\n return readSegments(storeDir)\n .filter((segment) => {\n const endedAt = Date.parse(segment.endedAt);\n return (\n Number.isFinite(endedAt) &&\n endedAt >= cutoff &&\n typeof segment.path === \"string\" &&\n fs.existsSync(segment.path) &&\n segment.corrupt !== true\n );\n })\n .sort((a, b) => b.endedAt.localeCompare(a.endedAt));\n}\n\nfunction textResult(value: unknown) {\n return {\n content: [\n {\n type: \"text\" as const,\n text:\n typeof value === \"string\" ? value : JSON.stringify(value, null, 2),\n },\n ],\n };\n}\n\nexport async function runScreenMemoryMCPStdio(\n opts: RunScreenMemoryMCPStdioOptions = {},\n): Promise<void> {\n const env = opts.env ?? process.env;\n const storeDir = opts.storeDir ?? defaultStoreDir(env);\n\n const { Server } = await import(\"@modelcontextprotocol/sdk/server/index.js\");\n const { StdioServerTransport } =\n await import(\"@modelcontextprotocol/sdk/server/stdio.js\");\n const { CallToolRequestSchema, ListToolsRequestSchema } =\n await import(\"@modelcontextprotocol/sdk/types.js\");\n\n const server = new Server(\n { name: \"clips-screen-memory\", version: \"0.1.0\" },\n { capabilities: { tools: {} } },\n );\n\n server.setRequestHandler(ListToolsRequestSchema, async () => ({\n tools: [\n {\n name: \"screen_memory_status\",\n description:\n \"Read local Clips Screen Memory status, retention, disk usage, and store path. Local-only.\",\n inputSchema: { type: \"object\", properties: {} },\n },\n {\n name: \"screen_memory_recent_context\",\n description:\n \"Search recent local Screen Memory app/window context. Returns timestamps, app names, window titles, and bundle ids; does not return images.\",\n inputSchema: {\n type: \"object\",\n properties: {\n query: {\n type: \"string\",\n description: \"Optional case-insensitive text filter.\",\n },\n minutes: {\n type: \"number\",\n description: \"Lookback window in minutes. Defaults to 30.\",\n },\n limit: {\n type: \"number\",\n description: \"Maximum events to return. Defaults to 40.\",\n },\n },\n },\n },\n {\n name: \"screen_memory_recent_segments\",\n description:\n \"List recent local Screen Memory video segment file paths and timestamps. Use only when the user asks to inspect or export local context.\",\n inputSchema: {\n type: \"object\",\n properties: {\n minutes: {\n type: \"number\",\n description: \"Lookback window in minutes. Defaults to 30.\",\n },\n },\n },\n },\n ],\n }));\n\n server.setRequestHandler(CallToolRequestSchema, async (request: any) => {\n const name = request.params?.name;\n const args = (request.params?.arguments ?? {}) as Record<string, unknown>;\n if (name === \"screen_memory_status\") {\n const config = readFeatureConfig(storeDir);\n const segments = recentSegments(storeDir, 24 * 60);\n return textResult({\n enabled: config.enabled === true,\n paused: config.paused === true,\n retentionHours: config.retentionHours ?? 24,\n maxBytes: config.maxBytes ?? 20 * 1024 * 1024 * 1024,\n segmentCount: segments.length,\n totalBytes: segments.reduce(\n (sum, segment) => sum + (segment.bytes || 0),\n 0,\n ),\n storeDir,\n });\n }\n if (name === \"screen_memory_recent_context\") {\n return textResult({\n storeDir,\n events: recentEvents(storeDir, {\n query: typeof args.query === \"string\" ? args.query : undefined,\n minutes: typeof args.minutes === \"number\" ? args.minutes : undefined,\n limit: typeof args.limit === \"number\" ? args.limit : undefined,\n }),\n });\n }\n if (name === \"screen_memory_recent_segments\") {\n const minutes = typeof args.minutes === \"number\" ? args.minutes : 30;\n return textResult({\n storeDir,\n segments: recentSegments(storeDir, minutes),\n });\n }\n throw new Error(`Unknown Screen Memory tool: ${name}`);\n });\n\n log(`Serving local Screen Memory from ${storeDir}`);\n const transport = new StdioServerTransport();\n await server.connect(transport);\n await new Promise<void>((resolve) => {\n transport.onclose = resolve;\n process.once(\"SIGINT\", resolve);\n process.once(\"SIGTERM\", resolve);\n });\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { McpStdioServerConfig } from "./config.js";
|
|
2
|
-
export type BuiltinMcpCapabilityId = "browser-chrome-devtools" | "browser-playwright" | "computer-use";
|
|
2
|
+
export type BuiltinMcpCapabilityId = "browser-chrome-devtools" | "browser-playwright" | "computer-use" | "screen-memory";
|
|
3
3
|
export interface BuiltinMcpCapability {
|
|
4
4
|
id: BuiltinMcpCapabilityId;
|
|
5
5
|
serverId: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builtin-capabilities.d.ts","sourceRoot":"","sources":["../../src/mcp-client/builtin-capabilities.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAExD,MAAM,MAAM,sBAAsB,GAC9B,yBAAyB,GACzB,oBAAoB,GACpB,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"builtin-capabilities.d.ts","sourceRoot":"","sources":["../../src/mcp-client/builtin-capabilities.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAExD,MAAM,MAAM,sBAAsB,GAC9B,yBAAyB,GACzB,oBAAoB,GACpB,cAAc,GACd,eAAe,CAAC;AAEpB,MAAM,WAAW,oBAAoB;IACnC,EAAE,EAAE,sBAAsB,CAAC;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,cAAc,CAAC,EAAE,SAAS,CAAC;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC,QAAQ,EAAE,CAAC;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,eAAO,MAAM,wBAAwB,EAAE,oBAAoB,EA+C1D,CAAC;AAMF,wBAAgB,kCAAkC,IAAI,OAAO,CAW5D;AAED,wBAAgB,uBAAuB,CACrC,EAAE,EAAE,MAAM,GACT,oBAAoB,GAAG,IAAI,CAE7B;AAED,wBAAgB,wBAAwB,CACtC,EAAE,EAAE,MAAM,GACT,EAAE,IAAI,sBAAsB,CAE9B;AAED,wBAAgB,+BAA+B,CAC7C,UAAU,EAAE,oBAAoB,EAChC,QAAQ,GAAE,MAAM,CAAC,QAA2B,GAC3C,OAAO,CAET;AAED,wBAAgB,mCAAmC,CACjD,QAAQ,GAAE,MAAM,CAAC,QAA2B,GAC3C,oBAAoB,EAAE,CAKxB;AAED,wBAAgB,gCAAgC,CAC9C,GAAG,EAAE,SAAS,MAAM,EAAE,GACrB,sBAAsB,EAAE,CAkB1B;AAED,wBAAgB,wBAAwB,CACtC,UAAU,EAAE,oBAAoB,GAC/B,oBAAoB,CAOtB"}
|
|
@@ -32,6 +32,16 @@ export const BUILTIN_MCP_CAPABILITIES = [
|
|
|
32
32
|
args: ["-y", "computer-use-mcp@1.8.0"],
|
|
33
33
|
platforms: ["darwin"],
|
|
34
34
|
},
|
|
35
|
+
{
|
|
36
|
+
id: "screen-memory",
|
|
37
|
+
serverId: "screen-memory",
|
|
38
|
+
name: "Screen Memory",
|
|
39
|
+
description: "Query local Clips Screen Memory context from this machine.",
|
|
40
|
+
command: "agent-native",
|
|
41
|
+
args: ["mcp", "screen-memory"],
|
|
42
|
+
platforms: ["darwin"],
|
|
43
|
+
notes: "Requires Clips desktop Screen Memory to be enabled. Local-only and disabled by default.",
|
|
44
|
+
},
|
|
35
45
|
];
|
|
36
46
|
const CAPABILITY_BY_ID = new Map(BUILTIN_MCP_CAPABILITIES.map((capability) => [capability.id, capability]));
|
|
37
47
|
export function areBuiltinMcpCapabilitiesSupported() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builtin-capabilities.js","sourceRoot":"","sources":["../../src/mcp-client/builtin-capabilities.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"builtin-capabilities.js","sourceRoot":"","sources":["../../src/mcp-client/builtin-capabilities.ts"],"names":[],"mappings":"AAoBA,MAAM,CAAC,MAAM,wBAAwB,GAA2B;IAC9D;QACE,EAAE,EAAE,yBAAyB;QAC7B,QAAQ,EAAE,iBAAiB;QAC3B,IAAI,EAAE,iBAAiB;QACvB,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AAU,GAAG,uBAAuB,CAAC,KAAK,CAAC,CAAC;QAClD,IAAI,CAAC,UAAU;YAAE,SAAS;QAC1B,IAAI,UAAU,CAAC,cAAc,EAAE,CAAC;YAC9B,KAAK,IAAI,CAAC,GAAG,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;gBAC7C,MAAM,QAAQ,GAAG,uBAAuB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;gBACrD,IAAI,QAAQ,EAAE,cAAc,KAAK,UAAU,CAAC,cAAc,EAAE,CAAC;oBAC3D,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;gBACvB,CAAC;YACH,CAAC;QACH,CAAC;aAAM,IAAI,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC,EAAE,CAAC;YAC3C,SAAS;QACX,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;IAC9B,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,MAAM,UAAU,wBAAwB,CACtC,UAAgC;IAEhC,OAAO;QACL,IAAI,EAAE,OAAO;QACb,OAAO,EAAE,UAAU,CAAC,OAAO;QAC3B,IAAI,EAAE,UAAU,CAAC,IAAI;QACrB,WAAW,EAAE,UAAU,CAAC,WAAW;KACpC,CAAC;AACJ,CAAC","sourcesContent":["import type { McpStdioServerConfig } from \"./config.js\";\n\nexport type BuiltinMcpCapabilityId =\n | \"browser-chrome-devtools\"\n | \"browser-playwright\"\n | \"computer-use\"\n | \"screen-memory\";\n\nexport interface BuiltinMcpCapability {\n id: BuiltinMcpCapabilityId;\n serverId: string;\n name: string;\n description: string;\n command: string;\n args: string[];\n exclusiveGroup?: \"browser\";\n platforms?: NodeJS.Platform[];\n notes?: string;\n}\n\nexport const BUILTIN_MCP_CAPABILITIES: BuiltinMcpCapability[] = [\n {\n id: \"browser-chrome-devtools\",\n serverId: \"chrome-devtools\",\n name: \"Chrome DevTools\",\n description: \"Attach to a live Chrome browser through Chrome DevTools MCP.\",\n command: \"npx\",\n args: [\n \"-y\",\n \"chrome-devtools-mcp@0.26.0\",\n \"--autoConnect\",\n \"--no-usage-statistics\",\n ],\n exclusiveGroup: \"browser\",\n notes:\n \"Uses --autoConnect and requires Chrome 144+ with remote debugging enabled.\",\n },\n {\n id: \"browser-playwright\",\n serverId: \"playwright\",\n name: \"Playwright Browser\",\n description: \"Launch and control a Playwright-managed browser.\",\n command: \"npx\",\n args: [\"-y\", \"@playwright/mcp@0.0.75\"],\n exclusiveGroup: \"browser\",\n },\n {\n id: \"computer-use\",\n serverId: \"computer-use\",\n name: \"Computer Use\",\n description:\n \"Control local macOS apps through the Computer Use MCP server.\",\n command: \"npx\",\n args: [\"-y\", \"computer-use-mcp@1.8.0\"],\n platforms: [\"darwin\"],\n },\n {\n id: \"screen-memory\",\n serverId: \"screen-memory\",\n name: \"Screen Memory\",\n description: \"Query local Clips Screen Memory context from this machine.\",\n command: \"agent-native\",\n args: [\"mcp\", \"screen-memory\"],\n platforms: [\"darwin\"],\n notes:\n \"Requires Clips desktop Screen Memory to be enabled. Local-only and disabled by default.\",\n },\n];\n\nconst CAPABILITY_BY_ID = new Map(\n BUILTIN_MCP_CAPABILITIES.map((capability) => [capability.id, capability]),\n);\n\nexport function areBuiltinMcpCapabilitiesSupported(): boolean {\n if (process.env.NODE_ENV === \"production\") return false;\n if (process.env.VERCEL || process.env.VERCEL_ENV) return false;\n if (process.env.NETLIFY && process.env.NETLIFY_LOCAL !== \"true\") {\n return false;\n }\n if (process.env.AWS_LAMBDA_FUNCTION_NAME || process.env.AWS_EXECUTION_ENV) {\n return false;\n }\n if (process.env.CF_PAGES || process.env.CLOUDFLARE_WORKERS) return false;\n return true;\n}\n\nexport function getBuiltinMcpCapability(\n id: string,\n): BuiltinMcpCapability | null {\n return CAPABILITY_BY_ID.get(id as BuiltinMcpCapabilityId) ?? null;\n}\n\nexport function isBuiltinMcpCapabilityId(\n id: string,\n): id is BuiltinMcpCapabilityId {\n return CAPABILITY_BY_ID.has(id as BuiltinMcpCapabilityId);\n}\n\nexport function isBuiltinMcpCapabilityAvailable(\n capability: BuiltinMcpCapability,\n platform: NodeJS.Platform = process.platform,\n): boolean {\n return !capability.platforms || capability.platforms.includes(platform);\n}\n\nexport function listSupportedBuiltinMcpCapabilities(\n platform: NodeJS.Platform = process.platform,\n): BuiltinMcpCapability[] {\n if (!areBuiltinMcpCapabilitiesSupported()) return [];\n return BUILTIN_MCP_CAPABILITIES.filter((capability) =>\n isBuiltinMcpCapabilityAvailable(capability, platform),\n );\n}\n\nexport function normalizeBuiltinMcpCapabilityIds(\n ids: readonly string[],\n): BuiltinMcpCapabilityId[] {\n const enabled: BuiltinMcpCapabilityId[] = [];\n for (const rawId of ids) {\n const capability = getBuiltinMcpCapability(rawId);\n if (!capability) continue;\n if (capability.exclusiveGroup) {\n for (let i = enabled.length - 1; i >= 0; i--) {\n const existing = getBuiltinMcpCapability(enabled[i]);\n if (existing?.exclusiveGroup === capability.exclusiveGroup) {\n enabled.splice(i, 1);\n }\n }\n } else if (enabled.includes(capability.id)) {\n continue;\n }\n enabled.push(capability.id);\n }\n return enabled;\n}\n\nexport function toBuiltinMcpServerConfig(\n capability: BuiltinMcpCapability,\n): McpStdioServerConfig {\n return {\n type: \"stdio\",\n command: capability.command,\n args: capability.args,\n description: capability.description,\n };\n}\n"]}
|
|
@@ -13,6 +13,7 @@ export { mountMcpServersRoutes, buildMergedConfig, builtinMergedConfigKey, start
|
|
|
13
13
|
export { mountMcpHubRoutes, listHubServers, getHubStatus, isHubServeEnabled, isHubConsumeEnabled, type HubServerRecord, type HubServersResponse, } from "./hub-routes.js";
|
|
14
14
|
export { fetchHubServers } from "./hub-client.js";
|
|
15
15
|
export { isMcpToolAllowedForRequest } from "./visibility.js";
|
|
16
|
+
export { configureScreenMemory, queryScreenMemoryContext, readScreenMemoryStatus, type ScreenMemoryConfig, type ScreenMemoryContextItem, type ScreenMemoryQueryResult, type ScreenMemoryStatus, } from "./screen-memory-local.js";
|
|
16
17
|
export { MCP_ACTION_RESULT_MARKER, isMcpActionResult, type AgentMcpAppPayload, type AgentMcpAppResourceContent, type McpActionResult, } from "./app-result.js";
|
|
17
18
|
/**
|
|
18
19
|
* Convert MCP tools into `ActionEntry` values suitable for registration in
|