@wonderwhy-er/desktop-commander 0.2.38 → 0.2.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +53 -2
- package/dist/handlers/filesystem-handlers.d.ts +5 -0
- package/dist/handlers/filesystem-handlers.js +14 -2
- package/dist/remote-device/desktop-commander-integration.js +1 -1
- package/dist/search-manager.js +31 -38
- package/dist/server.js +8 -3
- package/dist/terminal-manager.js +4 -2
- package/dist/tools/edit.js +34 -1
- package/dist/tools/filesystem.js +91 -3
- package/dist/tools/improved-process-tools.js +2 -1
- package/dist/ui/config-editor/app.js +840 -0
- package/dist/ui/config-editor/array-modal.d.ts +19 -0
- package/dist/ui/config-editor/array-modal.js +185 -0
- package/dist/ui/config-editor/config-editor-runtime.js +65 -14096
- package/dist/ui/config-editor/main.js +2 -0
- package/dist/ui/config-editor/src/App.d.ts +43 -0
- package/dist/ui/config-editor/src/components/layout.d.ts +4 -0
- package/dist/ui/config-editor/src/components/layout.js +83 -0
- package/dist/ui/config-editor/src/components/toolbar.d.ts +1 -0
- package/dist/ui/config-editor/src/components/toolbar.js +21 -0
- package/dist/ui/config-editor/src/config-values.d.ts +6 -0
- package/dist/ui/config-editor/src/config-values.js +61 -0
- package/dist/ui/config-editor/src/contracts.d.ts +14 -0
- package/dist/ui/config-editor/src/contracts.js +3 -0
- package/dist/ui/config-editor/src/directory-browser.d.ts +6 -0
- package/dist/ui/config-editor/src/directory-browser.js +71 -0
- package/dist/ui/config-editor/src/layout.d.ts +5 -0
- package/dist/ui/config-editor/src/layout.js +90 -0
- package/dist/ui/config-editor/src/parsing.d.ts +5 -0
- package/dist/ui/config-editor/src/parsing.js +50 -0
- package/dist/ui/config-editor/src/toolbar.d.ts +1 -0
- package/dist/ui/config-editor/src/toolbar.js +18 -0
- package/dist/ui/config-editor/src/types.d.ts +17 -0
- package/dist/ui/config-editor/src/types.js +3 -0
- package/dist/ui/config-editor/src/utils/config-values.d.ts +9 -0
- package/dist/ui/config-editor/src/utils/config-values.js +61 -0
- package/dist/ui/config-editor/src/utils/directory-browser.d.ts +31 -0
- package/dist/ui/config-editor/src/utils/directory-browser.js +201 -0
- package/dist/ui/config-editor/src/utils/parsing.d.ts +8 -0
- package/dist/ui/config-editor/src/utils/parsing.js +50 -0
- package/dist/ui/config-editor/styles.css +2 -1
- package/dist/ui/file-preview/{src/app.d.ts → app.d.ts} +1 -1
- package/dist/ui/file-preview/app.js +2020 -0
- package/dist/ui/file-preview/components/code-viewer.d.ts +6 -0
- package/dist/ui/file-preview/components/code-viewer.js +73 -0
- package/dist/ui/file-preview/components/highlighting.d.ts +2 -0
- package/dist/ui/file-preview/components/highlighting.js +54 -0
- package/dist/ui/file-preview/components/html-renderer.d.ts +5 -0
- package/dist/ui/file-preview/components/html-renderer.js +47 -0
- package/dist/ui/file-preview/components/markdown-renderer.d.ts +1 -0
- package/dist/ui/file-preview/components/markdown-renderer.js +67 -0
- package/dist/ui/file-preview/components/toolbar.d.ts +6 -0
- package/dist/ui/file-preview/components/toolbar.js +75 -0
- package/dist/ui/file-preview/image-preview.d.ts +3 -0
- package/dist/ui/file-preview/image-preview.js +21 -0
- package/dist/ui/file-preview/main.js +5 -0
- package/dist/ui/file-preview/markdown/editor.d.ts +36 -0
- package/dist/ui/file-preview/markdown/editor.js +643 -0
- package/dist/ui/file-preview/markdown/linking.d.ts +9 -0
- package/dist/ui/file-preview/markdown/linking.js +210 -0
- package/dist/ui/file-preview/markdown/outline.d.ts +7 -0
- package/dist/ui/file-preview/markdown/outline.js +40 -0
- package/dist/ui/file-preview/markdown/preview.d.ts +8 -0
- package/dist/ui/file-preview/markdown/preview.js +33 -0
- package/dist/ui/file-preview/markdown/slugify.d.ts +3 -0
- package/dist/ui/file-preview/markdown/slugify.js +31 -0
- package/dist/ui/file-preview/markdown/toc.d.ts +11 -0
- package/dist/ui/file-preview/markdown/toc.js +75 -0
- package/dist/ui/file-preview/markdown/utils.d.ts +1 -0
- package/dist/ui/file-preview/markdown/utils.js +15 -0
- package/dist/ui/file-preview/markdown/workspace-controller.d.ts +25 -0
- package/dist/ui/file-preview/markdown/workspace-controller.js +40 -0
- package/dist/ui/file-preview/preview-runtime.js +384 -26533
- package/dist/ui/file-preview/shared/preview-file-types.d.ts +1 -1
- package/dist/ui/file-preview/src/App.d.ts +4 -0
- package/dist/ui/file-preview/src/App.js +564 -0
- package/dist/ui/file-preview/src/components/CodeViewer.d.ts +6 -0
- package/dist/ui/file-preview/src/components/CodeViewer.js +60 -0
- package/dist/ui/file-preview/src/components/HtmlRenderer.d.ts +8 -0
- package/dist/ui/file-preview/src/components/HtmlRenderer.js +45 -0
- package/dist/ui/file-preview/src/components/MarkdownRenderer.d.ts +1 -0
- package/dist/ui/file-preview/src/components/MarkdownRenderer.js +15 -0
- package/dist/ui/file-preview/src/components/editor-toolbar.d.ts +15 -0
- package/dist/ui/file-preview/src/components/editor-toolbar.js +384 -0
- package/dist/ui/file-preview/src/components/markdown-editor.d.ts +29 -0
- package/dist/ui/file-preview/src/components/markdown-editor.js +535 -0
- package/dist/ui/file-preview/src/components/markdown-renderer.js +47 -9
- package/dist/ui/file-preview/src/directory-controller.d.ts +8 -0
- package/dist/ui/file-preview/src/directory-controller.js +233 -0
- package/dist/ui/file-preview/src/document-layout.d.ts +20 -0
- package/dist/ui/file-preview/src/document-layout.js +109 -0
- package/dist/ui/file-preview/src/document-outline.d.ts +17 -0
- package/dist/ui/file-preview/src/document-outline.js +97 -0
- package/dist/ui/file-preview/src/document-workspace.d.ts +19 -0
- package/dist/ui/file-preview/src/document-workspace.js +33 -0
- package/dist/ui/file-preview/src/file-type-handlers.d.ts +10 -0
- package/dist/ui/file-preview/src/file-type-handlers.js +98 -0
- package/dist/ui/file-preview/src/host/external-actions.d.ts +19 -0
- package/dist/ui/file-preview/src/host/external-actions.js +94 -0
- package/dist/ui/file-preview/src/host/selection-context.d.ts +9 -0
- package/dist/ui/file-preview/src/host/selection-context.js +106 -0
- package/dist/ui/file-preview/src/markdown/block-merge.d.ts +25 -0
- package/dist/ui/file-preview/src/markdown/block-merge.js +86 -0
- package/dist/ui/file-preview/src/markdown/conflict-dialog.d.ts +40 -0
- package/dist/ui/file-preview/src/markdown/conflict-dialog.js +163 -0
- package/dist/ui/file-preview/src/markdown/controller.d.ts +38 -0
- package/dist/ui/file-preview/src/markdown/controller.js +921 -0
- package/dist/ui/file-preview/src/markdown/editor.d.ts +35 -0
- package/dist/ui/file-preview/src/markdown/editor.js +691 -0
- package/dist/ui/file-preview/src/markdown/link-modal.d.ts +13 -0
- package/dist/ui/file-preview/src/markdown/link-modal.js +213 -0
- package/dist/ui/file-preview/src/markdown/linking.d.ts +16 -0
- package/dist/ui/file-preview/src/markdown/linking.js +228 -0
- package/dist/ui/file-preview/src/markdown/outline.d.ts +2 -0
- package/dist/ui/file-preview/src/markdown/outline.js +16 -0
- package/dist/ui/file-preview/src/markdown/parser.d.ts +30 -0
- package/dist/ui/file-preview/src/markdown/parser.js +38 -0
- package/dist/ui/file-preview/src/markdown/preview.d.ts +1 -0
- package/dist/ui/file-preview/src/markdown/preview.js +20 -0
- package/dist/ui/file-preview/src/markdown/raw-editor.d.ts +8 -0
- package/dist/ui/file-preview/src/markdown/raw-editor.js +61 -0
- package/dist/ui/file-preview/src/markdown/selection-toolbar.d.ts +14 -0
- package/dist/ui/file-preview/src/markdown/selection-toolbar.js +128 -0
- package/dist/ui/file-preview/src/markdown/slugify.d.ts +3 -0
- package/dist/ui/file-preview/src/markdown/slugify.js +31 -0
- package/dist/ui/file-preview/src/markdown/toc.d.ts +11 -0
- package/dist/ui/file-preview/src/markdown/toc.js +75 -0
- package/dist/ui/file-preview/src/markdown/utils.d.ts +1 -0
- package/dist/ui/file-preview/src/markdown/utils.js +15 -0
- package/dist/ui/file-preview/src/markdown-workspace/editor.d.ts +36 -0
- package/dist/ui/file-preview/src/markdown-workspace/editor.js +643 -0
- package/dist/ui/file-preview/src/markdown-workspace/linking.d.ts +9 -0
- package/dist/ui/file-preview/src/markdown-workspace/linking.js +210 -0
- package/dist/ui/file-preview/src/markdown-workspace/outline.d.ts +7 -0
- package/dist/ui/file-preview/src/markdown-workspace/outline.js +40 -0
- package/dist/ui/file-preview/src/markdown-workspace/preview.d.ts +8 -0
- package/dist/ui/file-preview/src/markdown-workspace/preview.js +33 -0
- package/dist/ui/file-preview/src/markdown-workspace/slugify.d.ts +3 -0
- package/dist/ui/file-preview/src/markdown-workspace/slugify.js +31 -0
- package/dist/ui/file-preview/src/markdown-workspace/toc.d.ts +11 -0
- package/dist/ui/file-preview/src/markdown-workspace/toc.js +75 -0
- package/dist/ui/file-preview/src/markdown-workspace/utils.d.ts +1 -0
- package/dist/ui/file-preview/src/markdown-workspace/utils.js +15 -0
- package/dist/ui/file-preview/src/markdown-workspace/workspace-controller.d.ts +25 -0
- package/dist/ui/file-preview/src/markdown-workspace/workspace-controller.js +40 -0
- package/dist/ui/file-preview/src/model.d.ts +34 -0
- package/dist/ui/file-preview/src/panel-actions.d.ts +17 -0
- package/dist/ui/file-preview/src/panel-actions.js +182 -0
- package/dist/ui/file-preview/src/path-utils.d.ts +6 -0
- package/dist/ui/file-preview/src/path-utils.js +64 -0
- package/dist/ui/file-preview/src/payload-utils.d.ts +11 -0
- package/dist/ui/file-preview/src/payload-utils.js +94 -0
- package/dist/ui/file-preview/styles.css +1066 -233
- package/dist/ui/file-preview/types.d.ts +1 -0
- package/dist/ui/server-integration.d.ts +13 -0
- package/dist/ui/server-integration.js +31 -0
- package/dist/ui/shared/ToolHeader.d.ts +9 -0
- package/dist/ui/shared/ToolHeader.js +29 -0
- package/dist/ui/shared/app-bootstrap.d.ts +9 -0
- package/dist/ui/shared/app-bootstrap.js +15 -0
- package/dist/ui/shared/guards.d.ts +1 -0
- package/dist/ui/shared/guards.js +3 -0
- package/dist/ui/shared/host-lifecycle.d.ts +1 -0
- package/dist/ui/shared/host-lifecycle.js +8 -2
- package/dist/ui/shared/widget-state.d.ts +6 -1
- package/dist/ui/shared/widget-state.js +102 -4
- package/dist/utils/files/base.d.ts +2 -0
- package/dist/utils/open-browser.js +1 -1
- package/dist/utils/ui-call-context.d.ts +8 -0
- package/dist/utils/ui-call-context.js +72 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +6 -1
- package/dist/data/spec-kit-prompts.json +0 -123
- package/dist/handlers/macos-control-handlers.d.ts +0 -16
- package/dist/handlers/macos-control-handlers.js +0 -81
- package/dist/handlers/node-handlers.d.ts +0 -6
- package/dist/handlers/node-handlers.js +0 -73
- package/dist/handlers/test-crash-handler.d.ts +0 -11
- package/dist/handlers/test-crash-handler.js +0 -26
- package/dist/http-index.d.ts +0 -45
- package/dist/http-index.js +0 -51
- package/dist/http-server-auto-tunnel.js +0 -667
- package/dist/http-server-named-tunnel.d.ts +0 -2
- package/dist/http-server-named-tunnel.js +0 -167
- package/dist/http-server-tunnel.d.ts +0 -2
- package/dist/http-server-tunnel.js +0 -111
- package/dist/http-server.d.ts +0 -2
- package/dist/http-server.js +0 -270
- package/dist/index-oauth.d.ts +0 -2
- package/dist/index-oauth.js +0 -201
- package/dist/lib.d.ts +0 -10
- package/dist/lib.js +0 -10
- package/dist/oauth/auth-middleware.d.ts +0 -20
- package/dist/oauth/auth-middleware.js +0 -62
- package/dist/oauth/index.d.ts +0 -3
- package/dist/oauth/index.js +0 -3
- package/dist/oauth/oauth-manager.d.ts +0 -80
- package/dist/oauth/oauth-manager.js +0 -179
- package/dist/oauth/oauth-routes.d.ts +0 -3
- package/dist/oauth/oauth-routes.js +0 -377
- package/dist/oauth/provider.d.ts +0 -22
- package/dist/oauth/provider.js +0 -124
- package/dist/oauth/server.d.ts +0 -18
- package/dist/oauth/server.js +0 -160
- package/dist/oauth/types.d.ts +0 -54
- package/dist/oauth/types.js +0 -2
- package/dist/remote-device/templates/auth-success.d.ts +0 -1
- package/dist/remote-device/templates/auth-success.js +0 -30
- package/dist/setup.log +0 -275
- package/dist/test-setup.js +0 -14
- package/dist/tools/docx/builders/html-builder.d.ts +0 -17
- package/dist/tools/docx/builders/html-builder.js +0 -92
- package/dist/tools/docx/builders/image.d.ts +0 -14
- package/dist/tools/docx/builders/image.js +0 -84
- package/dist/tools/docx/builders/index.d.ts +0 -11
- package/dist/tools/docx/builders/index.js +0 -11
- package/dist/tools/docx/builders/markdown-builder.d.ts +0 -2
- package/dist/tools/docx/builders/markdown-builder.js +0 -260
- package/dist/tools/docx/builders/paragraph.d.ts +0 -12
- package/dist/tools/docx/builders/paragraph.js +0 -29
- package/dist/tools/docx/builders/table.d.ts +0 -10
- package/dist/tools/docx/builders/table.js +0 -138
- package/dist/tools/docx/builders/utils.d.ts +0 -5
- package/dist/tools/docx/builders/utils.js +0 -18
- package/dist/tools/docx/constants.d.ts +0 -32
- package/dist/tools/docx/constants.js +0 -61
- package/dist/tools/docx/converters/markdown-to-html.d.ts +0 -17
- package/dist/tools/docx/converters/markdown-to-html.js +0 -111
- package/dist/tools/docx/create.d.ts +0 -21
- package/dist/tools/docx/create.js +0 -386
- package/dist/tools/docx/dom.d.ts +0 -139
- package/dist/tools/docx/dom.js +0 -448
- package/dist/tools/docx/errors.d.ts +0 -28
- package/dist/tools/docx/errors.js +0 -48
- package/dist/tools/docx/extractors/images.d.ts +0 -14
- package/dist/tools/docx/extractors/images.js +0 -40
- package/dist/tools/docx/extractors/metadata.d.ts +0 -14
- package/dist/tools/docx/extractors/metadata.js +0 -64
- package/dist/tools/docx/extractors/sections.d.ts +0 -14
- package/dist/tools/docx/extractors/sections.js +0 -61
- package/dist/tools/docx/html.d.ts +0 -17
- package/dist/tools/docx/html.js +0 -111
- package/dist/tools/docx/index.d.ts +0 -10
- package/dist/tools/docx/index.js +0 -10
- package/dist/tools/docx/markdown.d.ts +0 -84
- package/dist/tools/docx/markdown.js +0 -507
- package/dist/tools/docx/modify.d.ts +0 -28
- package/dist/tools/docx/modify.js +0 -271
- package/dist/tools/docx/operations/handlers/index.d.ts +0 -39
- package/dist/tools/docx/operations/handlers/index.js +0 -152
- package/dist/tools/docx/operations/html-manipulator.d.ts +0 -24
- package/dist/tools/docx/operations/html-manipulator.js +0 -352
- package/dist/tools/docx/operations/index.d.ts +0 -14
- package/dist/tools/docx/operations/index.js +0 -61
- package/dist/tools/docx/operations/operation-handlers.d.ts +0 -3
- package/dist/tools/docx/operations/operation-handlers.js +0 -67
- package/dist/tools/docx/operations/preprocessor.d.ts +0 -14
- package/dist/tools/docx/operations/preprocessor.js +0 -44
- package/dist/tools/docx/operations/xml-replacer.d.ts +0 -9
- package/dist/tools/docx/operations/xml-replacer.js +0 -35
- package/dist/tools/docx/operations.d.ts +0 -13
- package/dist/tools/docx/operations.js +0 -13
- package/dist/tools/docx/ops/delete-paragraph-at-body-index.d.ts +0 -11
- package/dist/tools/docx/ops/delete-paragraph-at-body-index.js +0 -23
- package/dist/tools/docx/ops/header-replace-text-exact.d.ts +0 -13
- package/dist/tools/docx/ops/header-replace-text-exact.js +0 -55
- package/dist/tools/docx/ops/index.d.ts +0 -17
- package/dist/tools/docx/ops/index.js +0 -70
- package/dist/tools/docx/ops/insert-image-after-text.d.ts +0 -24
- package/dist/tools/docx/ops/insert-image-after-text.js +0 -128
- package/dist/tools/docx/ops/insert-paragraph-after-text.d.ts +0 -12
- package/dist/tools/docx/ops/insert-paragraph-after-text.js +0 -74
- package/dist/tools/docx/ops/insert-table-after-text.d.ts +0 -19
- package/dist/tools/docx/ops/insert-table-after-text.js +0 -57
- package/dist/tools/docx/ops/replace-hyperlink-url.d.ts +0 -12
- package/dist/tools/docx/ops/replace-hyperlink-url.js +0 -37
- package/dist/tools/docx/ops/replace-paragraph-at-body-index.d.ts +0 -9
- package/dist/tools/docx/ops/replace-paragraph-at-body-index.js +0 -25
- package/dist/tools/docx/ops/replace-paragraph-text-exact.d.ts +0 -21
- package/dist/tools/docx/ops/replace-paragraph-text-exact.js +0 -36
- package/dist/tools/docx/ops/replace-table-cell-text.d.ts +0 -25
- package/dist/tools/docx/ops/replace-table-cell-text.js +0 -85
- package/dist/tools/docx/ops/set-color-for-paragraph-exact.d.ts +0 -9
- package/dist/tools/docx/ops/set-color-for-paragraph-exact.js +0 -24
- package/dist/tools/docx/ops/set-color-for-style.d.ts +0 -13
- package/dist/tools/docx/ops/set-color-for-style.js +0 -31
- package/dist/tools/docx/ops/set-paragraph-style-at-body-index.d.ts +0 -8
- package/dist/tools/docx/ops/set-paragraph-style-at-body-index.js +0 -57
- package/dist/tools/docx/ops/table-set-cell-text.d.ts +0 -9
- package/dist/tools/docx/ops/table-set-cell-text.js +0 -40
- package/dist/tools/docx/parsers/image-extractor.d.ts +0 -18
- package/dist/tools/docx/parsers/image-extractor.js +0 -61
- package/dist/tools/docx/parsers/index.d.ts +0 -9
- package/dist/tools/docx/parsers/index.js +0 -9
- package/dist/tools/docx/parsers/paragraph-parser.d.ts +0 -2
- package/dist/tools/docx/parsers/paragraph-parser.js +0 -88
- package/dist/tools/docx/parsers/table-parser.d.ts +0 -9
- package/dist/tools/docx/parsers/table-parser.js +0 -72
- package/dist/tools/docx/parsers/xml-parser.d.ts +0 -25
- package/dist/tools/docx/parsers/xml-parser.js +0 -71
- package/dist/tools/docx/parsers/zip-reader.d.ts +0 -23
- package/dist/tools/docx/parsers/zip-reader.js +0 -52
- package/dist/tools/docx/read.d.ts +0 -27
- package/dist/tools/docx/read.js +0 -308
- package/dist/tools/docx/relationships.d.ts +0 -22
- package/dist/tools/docx/relationships.js +0 -76
- package/dist/tools/docx/structure.d.ts +0 -25
- package/dist/tools/docx/structure.js +0 -102
- package/dist/tools/docx/styled-html-parser.d.ts +0 -23
- package/dist/tools/docx/styled-html-parser.js +0 -1262
- package/dist/tools/docx/types.d.ts +0 -213
- package/dist/tools/docx/types.js +0 -5
- package/dist/tools/docx/utils/escaping.d.ts +0 -13
- package/dist/tools/docx/utils/escaping.js +0 -26
- package/dist/tools/docx/utils/images.d.ts +0 -9
- package/dist/tools/docx/utils/images.js +0 -26
- package/dist/tools/docx/utils/index.d.ts +0 -12
- package/dist/tools/docx/utils/index.js +0 -17
- package/dist/tools/docx/utils/markdown.d.ts +0 -13
- package/dist/tools/docx/utils/markdown.js +0 -32
- package/dist/tools/docx/utils/paths.d.ts +0 -15
- package/dist/tools/docx/utils/paths.js +0 -27
- package/dist/tools/docx/utils/versioning.d.ts +0 -25
- package/dist/tools/docx/utils/versioning.js +0 -55
- package/dist/tools/docx/utils.d.ts +0 -101
- package/dist/tools/docx/utils.js +0 -299
- package/dist/tools/docx/validate.d.ts +0 -33
- package/dist/tools/docx/validate.js +0 -49
- package/dist/tools/docx/validators.d.ts +0 -13
- package/dist/tools/docx/validators.js +0 -40
- package/dist/tools/docx/write.d.ts +0 -17
- package/dist/tools/docx/write.js +0 -88
- package/dist/tools/docx/xml-view-test.js +0 -63
- package/dist/tools/docx/xml-view.d.ts +0 -56
- package/dist/tools/docx/xml-view.js +0 -169
- package/dist/tools/docx/zip.d.ts +0 -21
- package/dist/tools/docx/zip.js +0 -35
- package/dist/tools/macos-control/ax-adapter.d.ts +0 -55
- package/dist/tools/macos-control/ax-adapter.js +0 -438
- package/dist/tools/macos-control/cdp-adapter.d.ts +0 -23
- package/dist/tools/macos-control/cdp-adapter.js +0 -402
- package/dist/tools/macos-control/orchestrator.d.ts +0 -77
- package/dist/tools/macos-control/orchestrator.js +0 -136
- package/dist/tools/macos-control/role-aliases.d.ts +0 -5
- package/dist/tools/macos-control/role-aliases.js +0 -34
- package/dist/tools/macos-control/types.d.ts +0 -129
- package/dist/tools/pdf-processor.d.ts +0 -1
- package/dist/tools/pdf-processor.js +0 -3
- package/dist/tools/search.d.ts +0 -32
- package/dist/tools/search.js +0 -202
- package/dist/ui/file-preview/src/app.js +0 -714
- package/dist/utils/crash-logger.d.ts +0 -18
- package/dist/utils/crash-logger.js +0 -44
- package/dist/utils/dedent.d.ts +0 -8
- package/dist/utils/dedent.js +0 -38
- /package/dist/ui/config-editor/{src/app.d.ts → app.d.ts} +0 -0
- /package/dist/{http-server-auto-tunnel.d.ts → ui/config-editor/main.d.ts} +0 -0
- /package/dist/ui/config-editor/src/{app.js → App.js} +0 -0
- /package/dist/{test-docx.d.ts → ui/file-preview/main.d.ts} +0 -0
- /package/dist/ui/file-preview/src/components/{toolbar.d.ts → Toolbar.d.ts} +0 -0
- /package/dist/ui/file-preview/src/components/{toolbar.js → Toolbar.js} +0 -0
- /package/dist/{tools/docx/xml-view-test.d.ts → ui/file-preview/src/model.js} +0 -0
- /package/dist/{tools/macos-control → ui/file-preview}/types.js +0 -0
|
@@ -1,402 +0,0 @@
|
|
|
1
|
-
import net from 'net';
|
|
2
|
-
import tls from 'tls';
|
|
3
|
-
import { randomBytes, randomUUID } from 'crypto';
|
|
4
|
-
import { URL } from 'url';
|
|
5
|
-
function makeError(code, message, details) {
|
|
6
|
-
return {
|
|
7
|
-
ok: false,
|
|
8
|
-
error: {
|
|
9
|
-
code: code,
|
|
10
|
-
message,
|
|
11
|
-
details,
|
|
12
|
-
},
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
class SimpleWebSocketClient {
|
|
16
|
-
constructor() {
|
|
17
|
-
this.socket = null;
|
|
18
|
-
this.readBuffer = Buffer.alloc(0);
|
|
19
|
-
this.onTextMessage = null;
|
|
20
|
-
this.onCloseHandler = null;
|
|
21
|
-
}
|
|
22
|
-
setMessageHandler(handler) {
|
|
23
|
-
this.onTextMessage = handler;
|
|
24
|
-
}
|
|
25
|
-
setCloseHandler(handler) {
|
|
26
|
-
this.onCloseHandler = handler;
|
|
27
|
-
}
|
|
28
|
-
async connect(wsUrl, timeoutMs = 6000) {
|
|
29
|
-
const url = new URL(wsUrl);
|
|
30
|
-
const isSecure = url.protocol === 'wss:';
|
|
31
|
-
const port = Number(url.port || (isSecure ? 443 : 80));
|
|
32
|
-
const path = `${url.pathname || '/'}${url.search || ''}`;
|
|
33
|
-
const key = randomBytes(16).toString('base64');
|
|
34
|
-
const socket = isSecure
|
|
35
|
-
? tls.connect({ host: url.hostname, port, servername: url.hostname })
|
|
36
|
-
: net.connect({ host: url.hostname, port });
|
|
37
|
-
this.socket = socket;
|
|
38
|
-
await new Promise((resolve, reject) => {
|
|
39
|
-
const timeout = setTimeout(() => {
|
|
40
|
-
reject(new Error(`WebSocket connect timeout after ${timeoutMs}ms`));
|
|
41
|
-
}, timeoutMs);
|
|
42
|
-
const cleanup = () => {
|
|
43
|
-
clearTimeout(timeout);
|
|
44
|
-
socket.removeListener('error', onError);
|
|
45
|
-
socket.removeListener('data', onData);
|
|
46
|
-
};
|
|
47
|
-
const onError = (error) => {
|
|
48
|
-
cleanup();
|
|
49
|
-
reject(error);
|
|
50
|
-
};
|
|
51
|
-
let handshakeBuffer = '';
|
|
52
|
-
const onData = (chunk) => {
|
|
53
|
-
handshakeBuffer += chunk.toString('utf8');
|
|
54
|
-
const headerEnd = handshakeBuffer.indexOf('\r\n\r\n');
|
|
55
|
-
if (headerEnd === -1) {
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
const headers = handshakeBuffer.slice(0, headerEnd);
|
|
59
|
-
const remaining = Buffer.from(handshakeBuffer.slice(headerEnd + 4), 'utf8');
|
|
60
|
-
if (!headers.startsWith('HTTP/1.1 101')) {
|
|
61
|
-
cleanup();
|
|
62
|
-
reject(new Error(`WebSocket handshake failed: ${headers.split('\r\n')[0]}`));
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
cleanup();
|
|
66
|
-
if (remaining.length > 0) {
|
|
67
|
-
this.readBuffer = Buffer.concat([this.readBuffer, remaining]);
|
|
68
|
-
this.consumeFrames();
|
|
69
|
-
}
|
|
70
|
-
resolve();
|
|
71
|
-
};
|
|
72
|
-
socket.once('error', onError);
|
|
73
|
-
socket.on('data', onData);
|
|
74
|
-
const request = [
|
|
75
|
-
`GET ${path} HTTP/1.1`,
|
|
76
|
-
`Host: ${url.hostname}:${port}`,
|
|
77
|
-
'Upgrade: websocket',
|
|
78
|
-
'Connection: Upgrade',
|
|
79
|
-
`Sec-WebSocket-Key: ${key}`,
|
|
80
|
-
'Sec-WebSocket-Version: 13',
|
|
81
|
-
'\r\n',
|
|
82
|
-
].join('\r\n');
|
|
83
|
-
socket.write(request);
|
|
84
|
-
});
|
|
85
|
-
socket.on('data', (chunk) => {
|
|
86
|
-
this.readBuffer = Buffer.concat([this.readBuffer, chunk]);
|
|
87
|
-
this.consumeFrames();
|
|
88
|
-
});
|
|
89
|
-
socket.on('close', () => {
|
|
90
|
-
this.onCloseHandler?.();
|
|
91
|
-
});
|
|
92
|
-
socket.on('error', () => {
|
|
93
|
-
this.onCloseHandler?.();
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
sendText(text) {
|
|
97
|
-
if (!this.socket) {
|
|
98
|
-
throw new Error('WebSocket is not connected');
|
|
99
|
-
}
|
|
100
|
-
const payload = Buffer.from(text, 'utf8');
|
|
101
|
-
const frame = this.encodeClientFrame(payload, 0x1);
|
|
102
|
-
this.socket.write(frame);
|
|
103
|
-
}
|
|
104
|
-
close() {
|
|
105
|
-
if (!this.socket) {
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
108
|
-
try {
|
|
109
|
-
const closeFrame = this.encodeClientFrame(Buffer.alloc(0), 0x8);
|
|
110
|
-
this.socket.write(closeFrame);
|
|
111
|
-
}
|
|
112
|
-
catch {
|
|
113
|
-
// Ignore close frame errors
|
|
114
|
-
}
|
|
115
|
-
this.socket.end();
|
|
116
|
-
this.socket.destroy();
|
|
117
|
-
this.socket = null;
|
|
118
|
-
}
|
|
119
|
-
consumeFrames() {
|
|
120
|
-
while (this.readBuffer.length >= 2) {
|
|
121
|
-
const b0 = this.readBuffer[0];
|
|
122
|
-
const b1 = this.readBuffer[1];
|
|
123
|
-
const opcode = b0 & 0x0f;
|
|
124
|
-
const isMasked = (b1 & 0x80) !== 0;
|
|
125
|
-
let payloadLength = b1 & 0x7f;
|
|
126
|
-
let offset = 2;
|
|
127
|
-
if (payloadLength === 126) {
|
|
128
|
-
if (this.readBuffer.length < offset + 2) {
|
|
129
|
-
return;
|
|
130
|
-
}
|
|
131
|
-
payloadLength = this.readBuffer.readUInt16BE(offset);
|
|
132
|
-
offset += 2;
|
|
133
|
-
}
|
|
134
|
-
else if (payloadLength === 127) {
|
|
135
|
-
if (this.readBuffer.length < offset + 8) {
|
|
136
|
-
return;
|
|
137
|
-
}
|
|
138
|
-
const lenBig = this.readBuffer.readBigUInt64BE(offset);
|
|
139
|
-
payloadLength = Number(lenBig);
|
|
140
|
-
offset += 8;
|
|
141
|
-
}
|
|
142
|
-
let maskKey = null;
|
|
143
|
-
if (isMasked) {
|
|
144
|
-
if (this.readBuffer.length < offset + 4) {
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
maskKey = this.readBuffer.subarray(offset, offset + 4);
|
|
148
|
-
offset += 4;
|
|
149
|
-
}
|
|
150
|
-
if (this.readBuffer.length < offset + payloadLength) {
|
|
151
|
-
return;
|
|
152
|
-
}
|
|
153
|
-
let payload = this.readBuffer.subarray(offset, offset + payloadLength);
|
|
154
|
-
this.readBuffer = this.readBuffer.subarray(offset + payloadLength);
|
|
155
|
-
if (isMasked && maskKey) {
|
|
156
|
-
const unmasked = Buffer.allocUnsafe(payload.length);
|
|
157
|
-
for (let i = 0; i < payload.length; i++) {
|
|
158
|
-
unmasked[i] = payload[i] ^ maskKey[i % 4];
|
|
159
|
-
}
|
|
160
|
-
payload = unmasked;
|
|
161
|
-
}
|
|
162
|
-
if (opcode === 0x1) {
|
|
163
|
-
this.onTextMessage?.(payload.toString('utf8'));
|
|
164
|
-
}
|
|
165
|
-
else if (opcode === 0x8) {
|
|
166
|
-
this.close();
|
|
167
|
-
return;
|
|
168
|
-
}
|
|
169
|
-
else if (opcode === 0x9) {
|
|
170
|
-
if (this.socket) {
|
|
171
|
-
const pong = this.encodeClientFrame(payload, 0xA);
|
|
172
|
-
this.socket.write(pong);
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
encodeClientFrame(payload, opcode) {
|
|
178
|
-
const mask = randomBytes(4);
|
|
179
|
-
const headerParts = [];
|
|
180
|
-
const firstByte = 0x80 | (opcode & 0x0f);
|
|
181
|
-
headerParts.push(Buffer.from([firstByte]));
|
|
182
|
-
if (payload.length < 126) {
|
|
183
|
-
headerParts.push(Buffer.from([0x80 | payload.length]));
|
|
184
|
-
}
|
|
185
|
-
else if (payload.length < 65536) {
|
|
186
|
-
const len = Buffer.alloc(3);
|
|
187
|
-
len[0] = 0x80 | 126;
|
|
188
|
-
len.writeUInt16BE(payload.length, 1);
|
|
189
|
-
headerParts.push(len);
|
|
190
|
-
}
|
|
191
|
-
else {
|
|
192
|
-
const len = Buffer.alloc(9);
|
|
193
|
-
len[0] = 0x80 | 127;
|
|
194
|
-
len.writeBigUInt64BE(BigInt(payload.length), 1);
|
|
195
|
-
headerParts.push(len);
|
|
196
|
-
}
|
|
197
|
-
headerParts.push(mask);
|
|
198
|
-
const maskedPayload = Buffer.allocUnsafe(payload.length);
|
|
199
|
-
for (let i = 0; i < payload.length; i++) {
|
|
200
|
-
maskedPayload[i] = payload[i] ^ mask[i % 4];
|
|
201
|
-
}
|
|
202
|
-
return Buffer.concat([...headerParts, maskedPayload]);
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
export class CdpAdapter {
|
|
206
|
-
constructor() {
|
|
207
|
-
this.sessions = new Map();
|
|
208
|
-
}
|
|
209
|
-
async fetchTargets(host, port) {
|
|
210
|
-
const listUrl = `http://${host}:${port}/json/list`;
|
|
211
|
-
try {
|
|
212
|
-
const response = await fetch(listUrl, { method: 'GET' });
|
|
213
|
-
if (!response.ok) {
|
|
214
|
-
return makeError('CDP_CONNECT_FAILED', `Failed to query CDP targets: HTTP ${response.status}`);
|
|
215
|
-
}
|
|
216
|
-
const data = await response.json();
|
|
217
|
-
if (!Array.isArray(data)) {
|
|
218
|
-
return makeError('CDP_CONNECT_FAILED', 'Invalid CDP target list response');
|
|
219
|
-
}
|
|
220
|
-
const targets = data.map((item) => ({
|
|
221
|
-
id: String(item?.id ?? ''),
|
|
222
|
-
type: String(item?.type ?? ''),
|
|
223
|
-
title: String(item?.title ?? ''),
|
|
224
|
-
url: String(item?.url ?? ''),
|
|
225
|
-
webSocketDebuggerUrl: item?.webSocketDebuggerUrl ? String(item.webSocketDebuggerUrl) : undefined,
|
|
226
|
-
}));
|
|
227
|
-
return { ok: true, data: targets };
|
|
228
|
-
}
|
|
229
|
-
catch (error) {
|
|
230
|
-
return makeError('CDP_CONNECT_FAILED', `Failed to query CDP endpoint: ${error instanceof Error ? error.message : String(error)}`);
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
bindSessionHandlers(session) {
|
|
234
|
-
session.wsClient.setMessageHandler((message) => {
|
|
235
|
-
try {
|
|
236
|
-
const parsed = JSON.parse(message);
|
|
237
|
-
if (typeof parsed?.id === 'number') {
|
|
238
|
-
const pending = session.pending.get(parsed.id);
|
|
239
|
-
if (!pending) {
|
|
240
|
-
return;
|
|
241
|
-
}
|
|
242
|
-
clearTimeout(pending.timeout);
|
|
243
|
-
session.pending.delete(parsed.id);
|
|
244
|
-
if (parsed.error) {
|
|
245
|
-
pending.reject(new Error(String(parsed.error?.message || 'CDP call failed')));
|
|
246
|
-
return;
|
|
247
|
-
}
|
|
248
|
-
pending.resolve(parsed.result ?? null);
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
catch {
|
|
252
|
-
// Ignore non-JSON frames/events
|
|
253
|
-
}
|
|
254
|
-
});
|
|
255
|
-
session.wsClient.setCloseHandler(() => {
|
|
256
|
-
for (const [id, pending] of session.pending) {
|
|
257
|
-
clearTimeout(pending.timeout);
|
|
258
|
-
pending.reject(new Error('CDP websocket closed'));
|
|
259
|
-
session.pending.delete(id);
|
|
260
|
-
}
|
|
261
|
-
this.sessions.delete(session.id);
|
|
262
|
-
});
|
|
263
|
-
}
|
|
264
|
-
async sendCommand(session, method, params, timeoutMs = 6000) {
|
|
265
|
-
return await new Promise((resolve, reject) => {
|
|
266
|
-
const id = ++session.nextMessageId;
|
|
267
|
-
const timeout = setTimeout(() => {
|
|
268
|
-
session.pending.delete(id);
|
|
269
|
-
reject(new Error(`CDP call timeout: ${method}`));
|
|
270
|
-
}, timeoutMs);
|
|
271
|
-
session.pending.set(id, { resolve, reject, timeout });
|
|
272
|
-
try {
|
|
273
|
-
session.wsClient.sendText(JSON.stringify({ id, method, params }));
|
|
274
|
-
}
|
|
275
|
-
catch (error) {
|
|
276
|
-
clearTimeout(timeout);
|
|
277
|
-
session.pending.delete(id);
|
|
278
|
-
reject(error instanceof Error ? error : new Error(String(error)));
|
|
279
|
-
}
|
|
280
|
-
});
|
|
281
|
-
}
|
|
282
|
-
async attach(args) {
|
|
283
|
-
const host = args.host || '127.0.0.1';
|
|
284
|
-
const port = args.port || 9222;
|
|
285
|
-
const targetsResult = await this.fetchTargets(host, port);
|
|
286
|
-
if (!targetsResult.ok) {
|
|
287
|
-
return {
|
|
288
|
-
ok: false,
|
|
289
|
-
error: targetsResult.error,
|
|
290
|
-
};
|
|
291
|
-
}
|
|
292
|
-
const targets = targetsResult.data || [];
|
|
293
|
-
if (targets.length === 0) {
|
|
294
|
-
return makeError('CDP_CONNECT_FAILED', `No CDP targets found on ${host}:${port}`);
|
|
295
|
-
}
|
|
296
|
-
const pageTargets = targets.filter((target) => ['page', 'webview'].includes(target.type));
|
|
297
|
-
const candidateTargets = pageTargets.length > 0 ? pageTargets : targets;
|
|
298
|
-
let target;
|
|
299
|
-
if (args.targetId) {
|
|
300
|
-
target = candidateTargets.find((item) => item.id === args.targetId);
|
|
301
|
-
}
|
|
302
|
-
else {
|
|
303
|
-
target = candidateTargets[args.targetIndex ?? 0];
|
|
304
|
-
}
|
|
305
|
-
if (!target) {
|
|
306
|
-
return makeError('CDP_CONNECT_FAILED', 'Requested CDP target not found', {
|
|
307
|
-
targetId: args.targetId,
|
|
308
|
-
targetIndex: args.targetIndex,
|
|
309
|
-
availableTargets: candidateTargets.map((item) => item.id),
|
|
310
|
-
});
|
|
311
|
-
}
|
|
312
|
-
if (!target.webSocketDebuggerUrl) {
|
|
313
|
-
return makeError('CDP_CONNECT_FAILED', 'Selected CDP target has no websocket debugger URL', { targetId: target.id });
|
|
314
|
-
}
|
|
315
|
-
const wsClient = new SimpleWebSocketClient();
|
|
316
|
-
try {
|
|
317
|
-
await wsClient.connect(target.webSocketDebuggerUrl);
|
|
318
|
-
}
|
|
319
|
-
catch (error) {
|
|
320
|
-
return makeError('CDP_CONNECT_FAILED', `Failed to connect to CDP websocket: ${error instanceof Error ? error.message : String(error)}`);
|
|
321
|
-
}
|
|
322
|
-
const sessionId = randomUUID();
|
|
323
|
-
const session = {
|
|
324
|
-
id: sessionId,
|
|
325
|
-
wsClient,
|
|
326
|
-
nextMessageId: 0,
|
|
327
|
-
pending: new Map(),
|
|
328
|
-
host,
|
|
329
|
-
port,
|
|
330
|
-
target,
|
|
331
|
-
};
|
|
332
|
-
this.bindSessionHandlers(session);
|
|
333
|
-
this.sessions.set(sessionId, session);
|
|
334
|
-
try {
|
|
335
|
-
await this.sendCommand(session, 'Runtime.enable');
|
|
336
|
-
await this.sendCommand(session, 'Page.enable');
|
|
337
|
-
}
|
|
338
|
-
catch (error) {
|
|
339
|
-
wsClient.close();
|
|
340
|
-
this.sessions.delete(sessionId);
|
|
341
|
-
return makeError('CDP_CONNECT_FAILED', `Failed to initialize CDP domains: ${error instanceof Error ? error.message : String(error)}`);
|
|
342
|
-
}
|
|
343
|
-
return {
|
|
344
|
-
ok: true,
|
|
345
|
-
data: {
|
|
346
|
-
sessionId,
|
|
347
|
-
host,
|
|
348
|
-
port,
|
|
349
|
-
targetId: target.id,
|
|
350
|
-
targetTitle: target.title,
|
|
351
|
-
targetUrl: target.url,
|
|
352
|
-
availableTargets: candidateTargets.map((item) => ({
|
|
353
|
-
id: item.id,
|
|
354
|
-
title: item.title,
|
|
355
|
-
url: item.url,
|
|
356
|
-
type: item.type,
|
|
357
|
-
})),
|
|
358
|
-
},
|
|
359
|
-
};
|
|
360
|
-
}
|
|
361
|
-
async evaluate(args) {
|
|
362
|
-
const session = this.sessions.get(args.sessionId);
|
|
363
|
-
if (!session) {
|
|
364
|
-
return makeError('CDP_NOT_CONNECTED', `Unknown CDP session: ${args.sessionId}`);
|
|
365
|
-
}
|
|
366
|
-
try {
|
|
367
|
-
const result = await this.sendCommand(session, 'Runtime.evaluate', {
|
|
368
|
-
expression: args.expression,
|
|
369
|
-
returnByValue: args.returnByValue ?? true,
|
|
370
|
-
awaitPromise: args.awaitPromise ?? true,
|
|
371
|
-
}, 12000);
|
|
372
|
-
if (result?.exceptionDetails) {
|
|
373
|
-
return makeError('CDP_CALL_FAILED', String(result.exceptionDetails?.text || 'Runtime.evaluate failed'));
|
|
374
|
-
}
|
|
375
|
-
return {
|
|
376
|
-
ok: true,
|
|
377
|
-
data: {
|
|
378
|
-
result: result?.result?.value ?? result?.result,
|
|
379
|
-
type: result?.result?.type,
|
|
380
|
-
subtype: result?.result?.subtype,
|
|
381
|
-
description: result?.result?.description,
|
|
382
|
-
},
|
|
383
|
-
};
|
|
384
|
-
}
|
|
385
|
-
catch (error) {
|
|
386
|
-
return makeError('CDP_CALL_FAILED', `CDP evaluate failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
async disconnect(sessionId) {
|
|
390
|
-
const session = this.sessions.get(sessionId);
|
|
391
|
-
if (!session) {
|
|
392
|
-
return makeError('CDP_NOT_CONNECTED', `Unknown CDP session: ${sessionId}`);
|
|
393
|
-
}
|
|
394
|
-
session.wsClient.close();
|
|
395
|
-
this.sessions.delete(sessionId);
|
|
396
|
-
return {
|
|
397
|
-
ok: true,
|
|
398
|
-
data: { sessionId },
|
|
399
|
-
};
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
export const cdpAdapter = new CdpAdapter();
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { AxBatchCommand, AxBatchResult, AxElement, MacosControlResult } from './types.js';
|
|
2
|
-
export declare class MacosControlOrchestrator {
|
|
3
|
-
axStatus(): Promise<MacosControlResult<import("./types.js").AxStatus>>;
|
|
4
|
-
axListApps(): Promise<MacosControlResult<import("./types.js").AxAppInfo[]>>;
|
|
5
|
-
axListElements(args: {
|
|
6
|
-
scope?: 'top_window' | 'app' | 'all';
|
|
7
|
-
app?: string;
|
|
8
|
-
text?: string;
|
|
9
|
-
role?: string;
|
|
10
|
-
depth?: number;
|
|
11
|
-
limit?: number;
|
|
12
|
-
}): Promise<MacosControlResult<AxElement[]>>;
|
|
13
|
-
axFind(args: {
|
|
14
|
-
app: string;
|
|
15
|
-
text?: string;
|
|
16
|
-
role?: string;
|
|
17
|
-
index?: number;
|
|
18
|
-
depth?: number;
|
|
19
|
-
limit?: number;
|
|
20
|
-
}): Promise<MacosControlResult<AxElement[]>>;
|
|
21
|
-
axClick(args: {
|
|
22
|
-
id?: string;
|
|
23
|
-
app?: string;
|
|
24
|
-
text?: string;
|
|
25
|
-
role?: string;
|
|
26
|
-
index?: number;
|
|
27
|
-
depth?: number;
|
|
28
|
-
limit?: number;
|
|
29
|
-
}): Promise<MacosControlResult<Record<string, unknown>>>;
|
|
30
|
-
axGetState(args: {
|
|
31
|
-
app: string;
|
|
32
|
-
text?: string;
|
|
33
|
-
role?: string;
|
|
34
|
-
index?: number;
|
|
35
|
-
depth?: number;
|
|
36
|
-
limit?: number;
|
|
37
|
-
}): Promise<MacosControlResult<Record<string, unknown>>>;
|
|
38
|
-
axFindAndClick(args: {
|
|
39
|
-
app: string;
|
|
40
|
-
text?: string;
|
|
41
|
-
role?: string;
|
|
42
|
-
index?: number;
|
|
43
|
-
depth?: number;
|
|
44
|
-
limit?: number;
|
|
45
|
-
timeout_ms?: number;
|
|
46
|
-
if_exists?: boolean;
|
|
47
|
-
}): Promise<MacosControlResult<Record<string, unknown>>>;
|
|
48
|
-
axType(text: string): Promise<MacosControlResult<Record<string, unknown>>>;
|
|
49
|
-
axKey(key: string, modifiers?: string[]): Promise<MacosControlResult<Record<string, unknown>>>;
|
|
50
|
-
axActivate(app: string): Promise<MacosControlResult<Record<string, unknown>>>;
|
|
51
|
-
axWaitFor(args: {
|
|
52
|
-
app: string;
|
|
53
|
-
text: string;
|
|
54
|
-
role?: string;
|
|
55
|
-
timeout_ms?: number;
|
|
56
|
-
depth?: number;
|
|
57
|
-
}): Promise<MacosControlResult<AxElement>>;
|
|
58
|
-
axBatch(commands: AxBatchCommand[], stopOnError?: boolean): Promise<MacosControlResult<AxBatchResult>>;
|
|
59
|
-
electronDebugAttach(args: {
|
|
60
|
-
host?: string;
|
|
61
|
-
port?: number;
|
|
62
|
-
targetIndex?: number;
|
|
63
|
-
targetId?: string;
|
|
64
|
-
}): Promise<MacosControlResult<import("./types.js").ElectronDebugAttachResult>>;
|
|
65
|
-
electronDebugEval(args: {
|
|
66
|
-
sessionId: string;
|
|
67
|
-
expression: string;
|
|
68
|
-
returnByValue?: boolean;
|
|
69
|
-
awaitPromise?: boolean;
|
|
70
|
-
}): Promise<MacosControlResult<import("./types.js").ElectronDebugEvalResult>>;
|
|
71
|
-
electronDebugDisconnect(args: {
|
|
72
|
-
sessionId: string;
|
|
73
|
-
}): Promise<MacosControlResult<{
|
|
74
|
-
sessionId: string;
|
|
75
|
-
}>>;
|
|
76
|
-
}
|
|
77
|
-
export declare const macosControlOrchestrator: MacosControlOrchestrator;
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
import { axAdapter } from './ax-adapter.js';
|
|
2
|
-
import { cdpAdapter } from './cdp-adapter.js';
|
|
3
|
-
function fail(code, message) {
|
|
4
|
-
return {
|
|
5
|
-
ok: false,
|
|
6
|
-
error: {
|
|
7
|
-
code: code,
|
|
8
|
-
message,
|
|
9
|
-
},
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
function isMacOS() {
|
|
13
|
-
return process.platform === 'darwin';
|
|
14
|
-
}
|
|
15
|
-
export class MacosControlOrchestrator {
|
|
16
|
-
async axStatus() {
|
|
17
|
-
return axAdapter.status();
|
|
18
|
-
}
|
|
19
|
-
async axListApps() {
|
|
20
|
-
return axAdapter.listApps();
|
|
21
|
-
}
|
|
22
|
-
async axListElements(args) {
|
|
23
|
-
return axAdapter.listElements(args);
|
|
24
|
-
}
|
|
25
|
-
async axFind(args) {
|
|
26
|
-
return axAdapter.find(args);
|
|
27
|
-
}
|
|
28
|
-
async axClick(args) {
|
|
29
|
-
if (args.id) {
|
|
30
|
-
return axAdapter.clickById(args.id, args.app);
|
|
31
|
-
}
|
|
32
|
-
if (!args.app || !args.text) {
|
|
33
|
-
return fail('INVALID_ARGUMENT', 'Provide either id or app+text for macos_ax_click');
|
|
34
|
-
}
|
|
35
|
-
const found = await axAdapter.find({
|
|
36
|
-
app: args.app,
|
|
37
|
-
text: args.text,
|
|
38
|
-
role: args.role,
|
|
39
|
-
depth: args.depth,
|
|
40
|
-
limit: args.limit,
|
|
41
|
-
index: args.index,
|
|
42
|
-
});
|
|
43
|
-
if (!found.ok) {
|
|
44
|
-
return {
|
|
45
|
-
ok: false,
|
|
46
|
-
error: found.error,
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
const target = found.data?.[0];
|
|
50
|
-
if (!target) {
|
|
51
|
-
return fail('NOT_FOUND', `No element matched text "${args.text}" in ${args.app}`);
|
|
52
|
-
}
|
|
53
|
-
return axAdapter.clickById(target.id, args.app);
|
|
54
|
-
}
|
|
55
|
-
async axGetState(args) {
|
|
56
|
-
return axAdapter.getState(args);
|
|
57
|
-
}
|
|
58
|
-
async axFindAndClick(args) {
|
|
59
|
-
const timeoutMs = args.timeout_ms ?? 0;
|
|
60
|
-
if (timeoutMs > 0 && args.text) {
|
|
61
|
-
const waited = await this.axWaitFor({
|
|
62
|
-
app: args.app,
|
|
63
|
-
text: args.text,
|
|
64
|
-
role: args.role,
|
|
65
|
-
timeout_ms: timeoutMs,
|
|
66
|
-
depth: args.depth,
|
|
67
|
-
});
|
|
68
|
-
if (!waited.ok) {
|
|
69
|
-
if (args.if_exists && waited.error?.code === 'TIMEOUT') {
|
|
70
|
-
return { ok: true, data: { skipped: true } };
|
|
71
|
-
}
|
|
72
|
-
return { ok: false, error: waited.error };
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
const found = await this.axFind({
|
|
76
|
-
app: args.app,
|
|
77
|
-
text: args.text,
|
|
78
|
-
role: args.role,
|
|
79
|
-
index: args.index,
|
|
80
|
-
depth: args.depth,
|
|
81
|
-
limit: args.limit,
|
|
82
|
-
});
|
|
83
|
-
if (!found.ok) {
|
|
84
|
-
if (args.if_exists && found.error?.code === 'NOT_FOUND') {
|
|
85
|
-
return { ok: true, data: { skipped: true } };
|
|
86
|
-
}
|
|
87
|
-
return { ok: false, error: found.error };
|
|
88
|
-
}
|
|
89
|
-
const element = found.data?.[0];
|
|
90
|
-
if (!element) {
|
|
91
|
-
if (args.if_exists) {
|
|
92
|
-
return { ok: true, data: { skipped: true } };
|
|
93
|
-
}
|
|
94
|
-
return fail('NOT_FOUND', `No element matched criteria in ${args.app}`);
|
|
95
|
-
}
|
|
96
|
-
const clickResult = await axAdapter.clickById(element.id, args.app);
|
|
97
|
-
if (!clickResult.ok) {
|
|
98
|
-
return { ok: false, error: clickResult.error };
|
|
99
|
-
}
|
|
100
|
-
return {
|
|
101
|
-
ok: true,
|
|
102
|
-
data: {
|
|
103
|
-
element,
|
|
104
|
-
click_result: clickResult.data,
|
|
105
|
-
},
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
async axType(text) {
|
|
109
|
-
return axAdapter.typeText(text);
|
|
110
|
-
}
|
|
111
|
-
async axKey(key, modifiers = []) {
|
|
112
|
-
return axAdapter.pressKey(key, modifiers);
|
|
113
|
-
}
|
|
114
|
-
async axActivate(app) {
|
|
115
|
-
return axAdapter.activate(app);
|
|
116
|
-
}
|
|
117
|
-
async axWaitFor(args) {
|
|
118
|
-
return axAdapter.waitFor(args);
|
|
119
|
-
}
|
|
120
|
-
async axBatch(commands, stopOnError = true) {
|
|
121
|
-
if (!isMacOS()) {
|
|
122
|
-
return fail('UNSUPPORTED_PLATFORM', 'macOS control tools are only available on macOS.');
|
|
123
|
-
}
|
|
124
|
-
return axAdapter.batch(commands, stopOnError);
|
|
125
|
-
}
|
|
126
|
-
async electronDebugAttach(args) {
|
|
127
|
-
return cdpAdapter.attach(args);
|
|
128
|
-
}
|
|
129
|
-
async electronDebugEval(args) {
|
|
130
|
-
return cdpAdapter.evaluate(args);
|
|
131
|
-
}
|
|
132
|
-
async electronDebugDisconnect(args) {
|
|
133
|
-
return cdpAdapter.disconnect(args.sessionId);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
export const macosControlOrchestrator = new MacosControlOrchestrator();
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
export const ROLE_ALIASES = {
|
|
2
|
-
toggle: ['AXSwitch', 'AXCheckBox', 'AXToggle'],
|
|
3
|
-
switch: ['AXSwitch', 'AXCheckBox', 'AXToggle'],
|
|
4
|
-
button: ['AXButton', 'AXToolbarButton', 'AXMenuButton'],
|
|
5
|
-
text: ['AXTextField', 'AXTextArea', 'AXSearchField'],
|
|
6
|
-
input: ['AXTextField', 'AXTextArea', 'AXSearchField', 'AXSecureTextField'],
|
|
7
|
-
menu: ['AXMenuItem', 'AXMenuBarItem'],
|
|
8
|
-
link: ['AXLink', 'AXButton'],
|
|
9
|
-
row: ['AXRow', 'AXCell'],
|
|
10
|
-
list: ['AXList', 'AXOutline', 'AXTable'],
|
|
11
|
-
};
|
|
12
|
-
/**
|
|
13
|
-
* Expands aliases like "toggle" or "axswitch" into concrete AX roles.
|
|
14
|
-
*/
|
|
15
|
-
export function expandRoleAlias(role) {
|
|
16
|
-
if (!role) {
|
|
17
|
-
return undefined;
|
|
18
|
-
}
|
|
19
|
-
const trimmed = role.trim();
|
|
20
|
-
if (!trimmed) {
|
|
21
|
-
return undefined;
|
|
22
|
-
}
|
|
23
|
-
const lower = trimmed.toLowerCase();
|
|
24
|
-
if (ROLE_ALIASES[lower]) {
|
|
25
|
-
return ROLE_ALIASES[lower];
|
|
26
|
-
}
|
|
27
|
-
if (lower.startsWith('ax')) {
|
|
28
|
-
const withoutPrefix = lower.slice(2);
|
|
29
|
-
if (ROLE_ALIASES[withoutPrefix]) {
|
|
30
|
-
return ROLE_ALIASES[withoutPrefix];
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
return [trimmed];
|
|
34
|
-
}
|