@3rtools/tyts-mcp 1.15.0

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.
Files changed (88) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +12 -0
  3. package/README.md +103 -0
  4. package/dist/chrome.d.ts +3 -0
  5. package/dist/chrome.js +36 -0
  6. package/dist/chrome.js.map +1 -0
  7. package/dist/cli.d.ts +2 -0
  8. package/dist/cli.js +23 -0
  9. package/dist/cli.js.map +1 -0
  10. package/dist/document.d.ts +76 -0
  11. package/dist/document.js +101 -0
  12. package/dist/document.js.map +1 -0
  13. package/dist/image.d.ts +16 -0
  14. package/dist/image.js +70 -0
  15. package/dist/image.js.map +1 -0
  16. package/dist/schemas.d.ts +490 -0
  17. package/dist/schemas.js +49 -0
  18. package/dist/schemas.js.map +1 -0
  19. package/dist/server.d.ts +21 -0
  20. package/dist/server.js +199 -0
  21. package/dist/server.js.map +1 -0
  22. package/dist/session.d.ts +57 -0
  23. package/dist/session.js +186 -0
  24. package/dist/session.js.map +1 -0
  25. package/editor/appicon/Icon 1024.png +0 -0
  26. package/editor/appicon/Icon 128.png +0 -0
  27. package/editor/appicon/Icon 16.png +0 -0
  28. package/editor/appicon/Icon 256.png +0 -0
  29. package/editor/appicon/Icon 32.png +0 -0
  30. package/editor/appicon/Icon 512.png +0 -0
  31. package/editor/appicon/Icon 64.png +0 -0
  32. package/editor/assets/bootstrap-icons-BeopsB42.woff +0 -0
  33. package/editor/assets/bootstrap-icons-mSm7cUeB.woff2 +0 -0
  34. package/editor/assets/html2canvas.esm-DXEQVQnt.js +5 -0
  35. package/editor/assets/index-DkXpHR6W.css +1 -0
  36. package/editor/assets/index-hVs-TDOT.js +232 -0
  37. package/editor/assets/index.es-B4Pcu2qZ.js +5 -0
  38. package/editor/assets/purify.es-CEBYger9.js +3 -0
  39. package/editor/favicon/192.png +0 -0
  40. package/editor/favicon/512.png +0 -0
  41. package/editor/favicon/apple-touch-icon.png +0 -0
  42. package/editor/favicon/favicon.ico +0 -0
  43. package/editor/favicon/favicon.svg +12 -0
  44. package/editor/favicon/png/favicon-16x16.png +0 -0
  45. package/editor/favicon/png/favicon-32x32.png +0 -0
  46. package/editor/favicon/png/favicon-64x64.png +0 -0
  47. package/editor/fonts/road-ui/LICENSE.md +20 -0
  48. package/editor/fonts/road-ui/RoadUI-Bold.woff +0 -0
  49. package/editor/fonts/road-ui/RoadUI-Bold.woff2 +0 -0
  50. package/editor/fonts/road-ui/RoadUI-BoldOblique.woff +0 -0
  51. package/editor/fonts/road-ui/RoadUI-BoldOblique.woff2 +0 -0
  52. package/editor/fonts/road-ui/RoadUI-ExtraBold.woff +0 -0
  53. package/editor/fonts/road-ui/RoadUI-ExtraBold.woff2 +0 -0
  54. package/editor/fonts/road-ui/RoadUI-ExtraBoldOblique.woff +0 -0
  55. package/editor/fonts/road-ui/RoadUI-ExtraBoldOblique.woff2 +0 -0
  56. package/editor/fonts/road-ui/RoadUI-ExtraLight.woff +0 -0
  57. package/editor/fonts/road-ui/RoadUI-ExtraLight.woff2 +0 -0
  58. package/editor/fonts/road-ui/RoadUI-ExtraLightOblique.woff +0 -0
  59. package/editor/fonts/road-ui/RoadUI-ExtraLightOblique.woff2 +0 -0
  60. package/editor/fonts/road-ui/RoadUI-Light.woff +0 -0
  61. package/editor/fonts/road-ui/RoadUI-Light.woff2 +0 -0
  62. package/editor/fonts/road-ui/RoadUI-LightOblique.woff +0 -0
  63. package/editor/fonts/road-ui/RoadUI-LightOblique.woff2 +0 -0
  64. package/editor/fonts/road-ui/RoadUI-Medium.woff +0 -0
  65. package/editor/fonts/road-ui/RoadUI-Medium.woff2 +0 -0
  66. package/editor/fonts/road-ui/RoadUI-MediumOblique.woff +0 -0
  67. package/editor/fonts/road-ui/RoadUI-MediumOblique.woff2 +0 -0
  68. package/editor/fonts/road-ui/RoadUI-Oblique.woff +0 -0
  69. package/editor/fonts/road-ui/RoadUI-Oblique.woff2 +0 -0
  70. package/editor/fonts/road-ui/RoadUI-Regular.woff +0 -0
  71. package/editor/fonts/road-ui/RoadUI-Regular.woff2 +0 -0
  72. package/editor/fonts/road-ui/RoadUI-SemiBold.woff +0 -0
  73. package/editor/fonts/road-ui/RoadUI-SemiBold.woff2 +0 -0
  74. package/editor/fonts/road-ui/RoadUI-SemiBoldOblique.woff +0 -0
  75. package/editor/fonts/road-ui/RoadUI-SemiBoldOblique.woff2 +0 -0
  76. package/editor/fonts/road-ui/RoadUI-Thin.woff +0 -0
  77. package/editor/fonts/road-ui/RoadUI-Thin.woff2 +0 -0
  78. package/editor/fonts/road-ui/RoadUI-ThinOblique.woff +0 -0
  79. package/editor/fonts/road-ui/RoadUI-ThinOblique.woff2 +0 -0
  80. package/editor/fonts/road-ui/road-ui.css +113 -0
  81. package/editor/images/crypto/btc.svg +31 -0
  82. package/editor/images/crypto/eth.svg +11 -0
  83. package/editor/images/crypto/trx.svg +11 -0
  84. package/editor/images/crypto/usdt.svg +8 -0
  85. package/editor/index.html +23 -0
  86. package/editor/tyts-embed.js +242 -0
  87. package/package.json +56 -0
  88. package/static/harness.html +45 -0
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/NOTICE ADDED
@@ -0,0 +1,12 @@
1
+ @3rtools/tyts-mcp
2
+ Copyright (c) 2026 Marvin / 3R Tools
3
+
4
+ Licensed under the Apache License, Version 2.0 (see LICENSE).
5
+
6
+ Сторонні компоненти у пакеті / Third-party components bundled in this package:
7
+
8
+ - Road UI font (editor/fonts/road-ui) — CC BY-ND 4.0; distributed unmodified, see editor/fonts/road-ui/LICENSE.md.
9
+ - Bootstrap Icons (in editor/assets) — MIT, The Bootstrap Authors.
10
+ - jsPDF, TipTap, React (in editor/assets) — MIT; see the respective projects.
11
+
12
+ The UAF Sans font is not included in this package.
package/README.md ADDED
@@ -0,0 +1,103 @@
1
+ # @3rtools/tyts-mcp
2
+
3
+ MCP-сервер редактора [ТИЦЬ (Tyts)](https://tyts.vercel.app/): агент дає картинку й
4
+ список анотацій, отримує готовий PNG/JPEG/PDF з нумерованими виносками. Працює через
5
+ headless Chrome із вбудованою збіркою редактора, тож результат піксель-у-піксель такий,
6
+ як у застосунку.
7
+
8
+ MCP server for the Tyts annotated-collage editor: an agent passes an image plus annotations
9
+ and gets a rendered PNG/JPEG/PDF back.
10
+
11
+ ## Вимоги
12
+
13
+ - Node.js ≥ 20
14
+ - Google Chrome, Chromium або Edge на машині (пакет не завантажує Chromium). Якщо браузер у
15
+ нестандартному місці — `TYTS_CHROME_PATH=/шлях/до/chrome`.
16
+
17
+ ## Підключення
18
+
19
+ Claude Code:
20
+
21
+ ```bash
22
+ claude mcp add tyts -- npx -y @3rtools/tyts-mcp
23
+ ```
24
+
25
+ Будь-який MCP-клієнт (Cursor, Claude Desktop, `.mcp.json` у проєкті):
26
+
27
+ ```json
28
+ {
29
+ "mcpServers": {
30
+ "tyts": {
31
+ "command": "npx",
32
+ "args": ["-y", "@3rtools/tyts-mcp"],
33
+ "env": { "TYTS_OUTPUT_DIR": "./collages" }
34
+ }
35
+ }
36
+ }
37
+ ```
38
+
39
+ Змінні середовища: `TYTS_OUTPUT_DIR` (куди класти результати; типово тимчасова тека),
40
+ `TYTS_CHROME_PATH`, `TYTS_EDITOR_DIR` (своя збірка редактора замість вбудованої).
41
+
42
+ ## Інструменти
43
+
44
+ ### `tyts_render`
45
+
46
+ Головний інструмент. Вхід:
47
+
48
+ | Поле | Опис |
49
+ |---|---|
50
+ | `image` | шлях до файлу, http(s) URL або data URL |
51
+ | `pins` | анотації; координати в пікселях **оригінальної** картинки |
52
+ | `document` | замість `image`+`pins` — повний `TytsDocument` (наприклад, з попереднього рендера) |
53
+ | `format` | `png` (типово), `jpeg`, `pdf` |
54
+ | `width` або `scale` | цільова ширина в px або множник (1 = полотно × 2) |
55
+ | `output` | шлях для файлу; типово `$TYTS_OUTPUT_DIR/tyts-<час>.<ext>` |
56
+ | `preview` | повернути зменшений PNG (≤ 1024 px) як картинку для самоперевірки (типово так) |
57
+
58
+ Відповідь: JSON `{ path, bytes, width, height, imageSize, sourceImageSize, pins, document }` і preview.
59
+
60
+ ```json
61
+ {
62
+ "image": "./photo.jpg",
63
+ "pins": [
64
+ { "type": "rectangle", "x": 130, "y": 360, "width": 220, "height": 130, "text": "Техніка" },
65
+ { "type": "point", "x": 460, "y": 460, "text": "Дорога", "color": "#0088FF" },
66
+ { "type": "arrow", "start": { "x": 300, "y": 120 }, "end": { "x": 520, "y": 260 }, "text": "Напрямок руху" }
67
+ ],
68
+ "width": 1600
69
+ }
70
+ ```
71
+
72
+ Типи фігур: `point`, `rectangle`, `ellipse`, `polygon`, `polyline`, `arrow`, `text`, `compass`,
73
+ `standalone`. Поля кожного — у ресурсі `tyts://docs/annotations` (агент може його прочитати сам).
74
+
75
+ ### `tyts_image_info`
76
+
77
+ `{ image }` → `{ width, height, mime, editorSize }`. Викликати першим, щоб знати систему координат.
78
+
79
+ ### `tyts_validate`
80
+
81
+ `{ document }` → `{ ok: true }` або `{ ok: false, code, message }` без рендера.
82
+
83
+ ### Ресурс і промпт
84
+
85
+ - `tyts://docs/annotations` — формат анотацій, палітра, поради.
86
+ - Промпт `annotate-image(image, task?)` — покрокова інструкція агенту: розмір → рендер → перевірка preview.
87
+
88
+ ## Як це працює
89
+
90
+ Сервер піднімає статику з вбудованою embed-збіркою ТИЦЬ на `127.0.0.1`, відкриває її в headless
91
+ Chrome і керує редактором через postMessage-протокол `@3rtools/tyts-embed`. Браузер стартує
92
+ ліниво на першому виклику і закривається після 5 хв без роботи. Файли нікуди не надсилаються.
93
+
94
+ ## Розробка
95
+
96
+ ```bash
97
+ npm run build:embed # збірка редактора → build/embed (без UAF Sans)
98
+ npm run build -w @3rtools/tyts-mcp # tsc → dist/
99
+ npx vitest run --project mcp # unit + e2e (e2e пропускається без Chrome)
100
+ node packages/mcp/dist/cli.js # stdio-сервер
101
+ ```
102
+
103
+ Перед публікацією `prepack` копіює `build/embed` у `editor/` пакета.
@@ -0,0 +1,3 @@
1
+ /** Бінарник Chrome/Chromium/Edge: `TYTS_CHROME_PATH`, далі стандартні місця для платформи. */
2
+ export declare function findChrome(env?: NodeJS.ProcessEnv): string | null;
3
+ export declare const CHROME_NOT_FOUND_HINT = "Chrome/Chromium not found. Install Google Chrome, Chromium or Edge, or set TYTS_CHROME_PATH to the browser executable.";
package/dist/chrome.js ADDED
@@ -0,0 +1,36 @@
1
+ import { existsSync } from 'node:fs';
2
+ import { homedir } from 'node:os';
3
+ import { join } from 'node:path';
4
+ const MAC = [
5
+ '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
6
+ '/Applications/Chromium.app/Contents/MacOS/Chromium',
7
+ '/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge',
8
+ '/Applications/Brave Browser.app/Contents/MacOS/Brave Browser',
9
+ join(homedir(), 'Applications/Google Chrome.app/Contents/MacOS/Google Chrome'),
10
+ ];
11
+ const LINUX = [
12
+ '/usr/bin/google-chrome',
13
+ '/usr/bin/google-chrome-stable',
14
+ '/usr/bin/chromium',
15
+ '/usr/bin/chromium-browser',
16
+ '/snap/bin/chromium',
17
+ '/usr/bin/microsoft-edge',
18
+ '/usr/bin/brave-browser',
19
+ ];
20
+ const WIN = [
21
+ 'C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe',
22
+ 'C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe',
23
+ 'C:\\Program Files\\Microsoft\\Edge\\Application\\msedge.exe',
24
+ 'C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe',
25
+ join(process.env.LOCALAPPDATA ?? '', 'Google\\Chrome\\Application\\chrome.exe'),
26
+ ];
27
+ /** Бінарник Chrome/Chromium/Edge: `TYTS_CHROME_PATH`, далі стандартні місця для платформи. */
28
+ export function findChrome(env = process.env) {
29
+ const fromEnv = env.TYTS_CHROME_PATH ?? env.PUPPETEER_EXECUTABLE_PATH ?? env.CHROME_PATH;
30
+ if (fromEnv)
31
+ return existsSync(fromEnv) ? fromEnv : null;
32
+ const candidates = process.platform === 'darwin' ? MAC : process.platform === 'win32' ? WIN : LINUX;
33
+ return candidates.find((p) => p && existsSync(p)) ?? null;
34
+ }
35
+ export const CHROME_NOT_FOUND_HINT = 'Chrome/Chromium not found. Install Google Chrome, Chromium or Edge, or set TYTS_CHROME_PATH to the browser executable.';
36
+ //# sourceMappingURL=chrome.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chrome.js","sourceRoot":"","sources":["../src/chrome.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,MAAM,GAAG,GAAG;IACV,8DAA8D;IAC9D,oDAAoD;IACpD,gEAAgE;IAChE,8DAA8D;IAC9D,IAAI,CAAC,OAAO,EAAE,EAAE,6DAA6D,CAAC;CAC/E,CAAC;AACF,MAAM,KAAK,GAAG;IACZ,wBAAwB;IACxB,+BAA+B;IAC/B,mBAAmB;IACnB,2BAA2B;IAC3B,oBAAoB;IACpB,yBAAyB;IACzB,wBAAwB;CACzB,CAAC;AACF,MAAM,GAAG,GAAG;IACV,4DAA4D;IAC5D,kEAAkE;IAClE,6DAA6D;IAC7D,mEAAmE;IACnE,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,YAAY,IAAI,EAAE,EAAE,yCAAyC,CAAC;CAChF,CAAC;AAEF,8FAA8F;AAC9F,MAAM,UAAU,UAAU,CAAC,MAAyB,OAAO,CAAC,GAAG;IAC7D,MAAM,OAAO,GAAG,GAAG,CAAC,gBAAgB,IAAI,GAAG,CAAC,yBAAyB,IAAI,GAAG,CAAC,WAAW,CAAC;IACzF,IAAI,OAAO;QAAE,OAAO,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC;IACzD,MAAM,UAAU,GAAG,OAAO,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC;IACpG,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC;AAC5D,CAAC;AAED,MAAM,CAAC,MAAM,qBAAqB,GAChC,wHAAwH,CAAC"}
package/dist/cli.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/dist/cli.js ADDED
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env node
2
+ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
3
+ import { createServer } from './server.js';
4
+ // stdout належить MCP-транспорту, тож уся діагностика — у stderr.
5
+ const log = (message) => { process.stderr.write(`[tyts-mcp] ${message}\n`); };
6
+ const { server, session } = createServer({ log });
7
+ const transport = new StdioServerTransport();
8
+ let closing = false;
9
+ async function shutdown(reason) {
10
+ if (closing)
11
+ return;
12
+ closing = true;
13
+ log(`shutting down (${reason})`);
14
+ await session.close().catch(() => { });
15
+ await server.close().catch(() => { });
16
+ process.exit(0);
17
+ }
18
+ process.on('SIGINT', () => void shutdown('SIGINT'));
19
+ process.on('SIGTERM', () => void shutdown('SIGTERM'));
20
+ process.stdin.on('end', () => void shutdown('stdin closed'));
21
+ await server.connect(transport);
22
+ log(`ready; editor bundle: ${session.editorBundleDir}`);
23
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,YAAY,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';
2
+ /** Палітра редактора (src/constants.ts PIN_COLORS); дублюється, бо пакет не імпортує код застосунку. */
3
+ export declare const PIN_COLORS: readonly ["#FBD710", "#F0462F", "#FF8D28", "#4FD553", "#00C0E8", "#0088FF", "#E246A1", "#FFFFFF", "#A0522D", "#888888", "#000000"];
4
+ export interface Size {
5
+ w: number;
6
+ h: number;
7
+ }
8
+ export interface EditorPin {
9
+ id: string;
10
+ label: number;
11
+ color: string;
12
+ description: string;
13
+ descPos: 'above' | 'below';
14
+ image: null;
15
+ imageAspect: null;
16
+ anchor: Record<string, unknown>;
17
+ strokeStyle?: 'solid' | 'dashed';
18
+ fillStyle?: 'filled' | 'none';
19
+ }
20
+ export interface CardPosition {
21
+ x: number;
22
+ y: number;
23
+ width: number;
24
+ height: number;
25
+ }
26
+ export interface EditorDocument {
27
+ version: 1;
28
+ backgroundImage: string;
29
+ imageSize: Size;
30
+ sourceImageSize: Size | null;
31
+ pins: EditorPin[];
32
+ cardPositions: Record<string, CardPosition>;
33
+ settings?: {
34
+ fontId?: string;
35
+ strokeWidthScale?: number;
36
+ };
37
+ meta?: {
38
+ sourceUrl?: string;
39
+ sourceTitle?: string;
40
+ capturedAt?: number;
41
+ };
42
+ }
43
+ export declare function escapeHtml(text: string): string;
44
+ /** Текст агента → HTML картки (TipTap): один `<p>`, переноси рядків як `<br>`. */
45
+ export declare function textToDescription(text: string | undefined): string;
46
+ /** Коефіцієнт «оригінальні пікселі → простір редактора» (редактор масштабує до 1500 px). */
47
+ export declare function scaleFactor(imageSize: Size, sourceImageSize: Size | null): number;
48
+ export declare function toAnchor(pin: SimplePin, k: number): Record<string, unknown>;
49
+ export interface BuildDocumentInput {
50
+ backgroundImage: string;
51
+ imageSize: Size;
52
+ sourceImageSize: Size | null;
53
+ pins: SimplePin[];
54
+ /** 'source' — координати в пікселях оригіналу (масштабуються), 'editor' — уже в просторі редактора. */
55
+ coordinates?: 'source' | 'editor';
56
+ meta?: EditorDocument['meta'];
57
+ }
58
+ export declare function buildDocument(input: BuildDocumentInput): EditorDocument;
59
+ /** Документ без base64-картинки — для відповіді агенту. */
60
+ export declare function summarizeDocument(doc: EditorDocument | null): {
61
+ backgroundImage: string;
62
+ version: 1;
63
+ imageSize: Size;
64
+ sourceImageSize: Size | null;
65
+ pins: EditorPin[];
66
+ cardPositions: Record<string, CardPosition>;
67
+ settings?: {
68
+ fontId?: string;
69
+ strokeWidthScale?: number;
70
+ };
71
+ meta?: {
72
+ sourceUrl?: string;
73
+ sourceTitle?: string;
74
+ capturedAt?: number;
75
+ };
76
+ } | null;
@@ -0,0 +1,101 @@
1
+ /** Палітра редактора (src/constants.ts PIN_COLORS); дублюється, бо пакет не імпортує код застосунку. */
2
+ export const PIN_COLORS = [
3
+ '#FBD710', '#F0462F', '#FF8D28', '#4FD553', '#00C0E8', '#0088FF', '#E246A1', '#FFFFFF', '#A0522D', '#888888', '#000000',
4
+ ];
5
+ export function escapeHtml(text) {
6
+ return text
7
+ .replace(/&/g, '&amp;')
8
+ .replace(/</g, '&lt;')
9
+ .replace(/>/g, '&gt;')
10
+ .replace(/"/g, '&quot;');
11
+ }
12
+ /** Текст агента → HTML картки (TipTap): один `<p>`, переноси рядків як `<br>`. */
13
+ export function textToDescription(text) {
14
+ const trimmed = (text ?? '').trim();
15
+ if (!trimmed)
16
+ return '';
17
+ return `<p>${escapeHtml(trimmed).replace(/\r?\n/g, '<br>')}</p>`;
18
+ }
19
+ /** Коефіцієнт «оригінальні пікселі → простір редактора» (редактор масштабує до 1500 px). */
20
+ export function scaleFactor(imageSize, sourceImageSize) {
21
+ if (!sourceImageSize || !sourceImageSize.w)
22
+ return 1;
23
+ return imageSize.w / sourceImageSize.w;
24
+ }
25
+ const s = (v, k) => Math.round(v * k * 1000) / 1000;
26
+ const sp = (p, k) => ({ x: s(p.x, k), y: s(p.y, k) });
27
+ export function toAnchor(pin, k) {
28
+ switch (pin.type) {
29
+ case 'point':
30
+ case 'standalone':
31
+ return { type: pin.type, x: s(pin.x, k), y: s(pin.y, k) };
32
+ case 'rectangle':
33
+ case 'text':
34
+ return {
35
+ type: pin.type,
36
+ x: s(pin.x, k), y: s(pin.y, k), width: s(pin.width, k), height: s(pin.height, k),
37
+ ...('rotation' in pin && pin.rotation !== undefined ? { rotation: pin.rotation } : {}),
38
+ };
39
+ case 'ellipse':
40
+ return { type: 'ellipse', cx: s(pin.cx, k), cy: s(pin.cy, k), rx: s(pin.rx, k), ry: s(pin.ry, k), ...(pin.rotation !== undefined ? { rotation: pin.rotation } : {}) };
41
+ case 'polygon':
42
+ case 'polyline':
43
+ return { type: pin.type, points: pin.points.map((p) => sp(p, k)), ...(pin.rotation !== undefined ? { rotation: pin.rotation } : {}) };
44
+ case 'arrow': {
45
+ const control = pin.control ?? { x: (pin.start.x + pin.end.x) / 2, y: (pin.start.y + pin.end.y) / 2 };
46
+ return { type: 'arrow', start: sp(pin.start, k), end: sp(pin.end, k), control: sp(control, k) };
47
+ }
48
+ case 'compass':
49
+ return { type: 'compass', cx: s(pin.cx, k), cy: s(pin.cy, k), radius: s(pin.radius, k), ...(pin.rotation !== undefined ? { rotation: pin.rotation } : {}) };
50
+ }
51
+ }
52
+ export function buildDocument(input) {
53
+ const k = input.coordinates === 'editor' ? 1 : scaleFactor(input.imageSize, input.sourceImageSize);
54
+ const cardPositions = {};
55
+ const pins = input.pins.map((pin, index) => {
56
+ const id = pin.id ?? `pin-${index + 1}`;
57
+ const editorPin = {
58
+ id,
59
+ label: index + 1,
60
+ color: pin.color ?? PIN_COLORS[index % PIN_COLORS.length],
61
+ description: textToDescription(pin.text),
62
+ descPos: 'below',
63
+ image: null,
64
+ imageAspect: null,
65
+ anchor: toAnchor(pin, k),
66
+ };
67
+ if (pin.strokeStyle)
68
+ editorPin.strokeStyle = pin.strokeStyle;
69
+ if (pin.fillStyle)
70
+ editorPin.fillStyle = pin.fillStyle;
71
+ if (pin.card) {
72
+ cardPositions[id] = { x: s(pin.card.x, k), y: s(pin.card.y, k), width: s(pin.card.width, k), height: s(pin.card.height, k) };
73
+ }
74
+ return editorPin;
75
+ });
76
+ const ids = new Set();
77
+ for (const pin of pins) {
78
+ if (ids.has(pin.id))
79
+ throw new Error(`Duplicate pin id: ${pin.id}`);
80
+ ids.add(pin.id);
81
+ }
82
+ return {
83
+ version: 1,
84
+ backgroundImage: input.backgroundImage,
85
+ imageSize: input.imageSize,
86
+ sourceImageSize: input.sourceImageSize,
87
+ pins,
88
+ cardPositions,
89
+ meta: input.meta,
90
+ };
91
+ }
92
+ /** Документ без base64-картинки — для відповіді агенту. */
93
+ export function summarizeDocument(doc) {
94
+ if (!doc)
95
+ return null;
96
+ return {
97
+ ...doc,
98
+ backgroundImage: `<data URL, ${Math.round(doc.backgroundImage.length * 0.75 / 1024)} KB>`,
99
+ };
100
+ }
101
+ //# sourceMappingURL=document.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"document.js","sourceRoot":"","sources":["../src/document.ts"],"names":[],"mappings":"AAEA,wGAAwG;AACxG,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS;CAC/G,CAAC;AA8BX,MAAM,UAAU,UAAU,CAAC,IAAY;IACrC,OAAO,IAAI;SACR,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC;SACtB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;AAC7B,CAAC;AAED,kFAAkF;AAClF,MAAM,UAAU,iBAAiB,CAAC,IAAwB;IACxD,MAAM,OAAO,GAAG,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IACpC,IAAI,CAAC,OAAO;QAAE,OAAO,EAAE,CAAC;IACxB,OAAO,MAAM,UAAU,CAA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AI,KAAK,CAAC,qBAAqB,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC;QACpE,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAClB,CAAC;IACD,OAAO;QACL,OAAO,EAAE,CAAC;QACV,eAAe,EAAE,KAAK,CAAC,eAAe;QACtC,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,eAAe,EAAE,KAAK,CAAC,eAAe;QACtC,IAAI;QACJ,aAAa;QACb,IAAI,EAAE,KAAK,CAAC,IAAI;KACjB,CAAC;AACJ,CAAC;AAED,2DAA2D;AAC3D,MAAM,UAAU,iBAAiB,CAAC,GAA0B;IAC1D,IAAI,CAAC,GAAG;QAAE,OAAO,IAAI,CAAC;IACtB,OAAO;QACL,GAAG,GAAG;QACN,eAAe,EAAE,cAAc,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,eAAe,CAAC,MAAM,GAAG,IAAI,GAAG,IAAI,CAAC,MAAM;KAC1F,CAAC;AACJ,CAAC"}
@@ -0,0 +1,16 @@
1
+ /** Ліміт на картинку: base64 у postMessage і в контексті агента дорогий. */
2
+ export declare const MAX_IMAGE_BYTES: number;
3
+ export declare function mimeForPath(path: string): string | null;
4
+ export declare function resolveImagePath(path: string, cwd?: string): string;
5
+ /**
6
+ * Будь-яке джерело картинки → data URL для `loadImage`.
7
+ * Приймає шлях до файлу (абсолютний, відносний, `~/`), http(s) URL або готовий data URL.
8
+ */
9
+ export declare function loadImageSource(source: string, opts?: {
10
+ cwd?: string;
11
+ fetchImpl?: typeof fetch;
12
+ }): Promise<string>;
13
+ /** Розширення файлу для формату експорту. */
14
+ export declare function extensionForFormat(format: 'png' | 'jpeg' | 'pdf'): string;
15
+ /** data URL → Buffer (для запису результату експорту). */
16
+ export declare function dataUrlToBuffer(dataUrl: string): Buffer;