@pecot/visual-mcp 1.3.0 → 2.0.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.
- package/.claude-plugin/plugin.json +1 -1
- package/README.md +44 -14
- package/assets/slidev/package.json +2 -2
- package/assets/slidev/runtime/package.json +1 -1
- package/cli/dist/commands/drawio/errors.d.ts +5 -4
- package/cli/dist/commands/drawio/export.d.ts +6 -5
- package/cli/dist/commands/drawio/export.js +0 -2
- package/cli/dist/commands/drawio/url.d.ts +2 -1
- package/cli/dist/commands/drawio/url.js +0 -1
- package/cli/dist/commands/evidence-xlsx/create.d.ts +2 -1
- package/cli/dist/commands/evidence-xlsx/create.js +0 -1
- package/cli/dist/commands/pptx-ooxml/preview.d.ts +4 -3
- package/cli/dist/commands/pptx-ooxml/preview.js +0 -3
- package/cli/dist/commands/slidev-project/create.d.ts +2 -1
- package/cli/dist/commands/slidev-project/create.js +0 -1
- package/cli/dist/commands/slidev-project/lint.d.ts +2 -1
- package/cli/dist/commands/slidev-project/sync.d.ts +2 -1
- package/cli/dist/commands/slidev-project/sync.js +0 -1
- package/cli/dist/commands/slidev-project/theme.d.ts +2 -1
- package/cli/dist/commands/slidev-to-pptx/convert.d.ts +6 -5
- package/cli/dist/commands/slidev-to-pptx/convert.js +0 -4
- package/cli/dist/domain/_shared/failure-kind.d.ts +13 -0
- package/cli/dist/domain/_shared/failure-kind.js +103 -0
- package/cli/dist/domain/evidence-xlsx/layout.d.ts +2 -3
- package/cli/dist/domain/evidence-xlsx/ooxml.d.ts +1 -8
- package/cli/dist/domain/evidence-xlsx/ooxml.js +35 -24
- package/cli/dist/domain/slidev-project/errors.d.ts +5 -4
- package/cli/dist/domain/slidev-theme/error-reason.d.ts +9 -5
- package/cli/dist/infra/_shared/dependency-root.d.ts +3 -3
- package/cli/dist/infra/_shared/dependency-root.js +5 -5
- package/cli/dist/infra/_shared/runtime-install.d.ts +1 -1
- package/cli/dist/infra/_shared/runtime-install.js +1 -1
- package/cli/dist/infra/_shared/slidev-bin.d.ts +1 -1
- package/cli/dist/infra/_shared/slidev-bin.js +1 -1
- package/cli/dist/infra/playwright/chromium.js +2 -2
- package/cli/dist/infra/playwright/host-dependencies.js +1 -1
- package/cli/dist/infra/playwright/launch.js +1 -1
- package/cli/dist/infra/slidev-to-pptx/pipeline.js +1 -1
- package/cli/dist/infra/slidev-to-pptx/runner.js +1 -1
- package/cli/dist/mcp/dev-server-registry.d.ts +2 -1
- package/cli/dist/mcp/result.d.ts +19 -5
- package/cli/dist/mcp/result.js +2 -0
- package/cli/dist/mcp/tool-names.d.ts +17 -0
- package/cli/dist/mcp/tool-names.js +26 -0
- package/cli/dist/mcp/tools/_shared.d.ts +4 -3
- package/cli/dist/mcp/tools/_shared.js +10 -6
- package/cli/dist/mcp/tools/drawio.js +8 -3
- package/cli/dist/mcp/tools/evidence.js +3 -1
- package/cli/dist/mcp/tools/setup.d.ts +1 -1
- package/cli/dist/mcp/tools/setup.js +5 -3
- package/cli/dist/mcp/tools/slide-dev.js +4 -1
- package/cli/dist/mcp/tools/slide-page.d.ts +2 -1
- package/cli/dist/mcp/tools/slide-page.js +4 -2
- package/cli/dist/mcp/tools/slide-theme.js +4 -1
- package/cli/dist/mcp/tools/slide.js +4 -2
- package/npm-shrinkwrap.json +113 -60
- package/package.json +1 -1
- package/vendor/text-rules/dist/source-hash +1 -1
|
@@ -395,18 +395,9 @@ function cellXfXml(definition) {
|
|
|
395
395
|
+ `</xf>`;
|
|
396
396
|
}
|
|
397
397
|
/**
|
|
398
|
-
drawing1.xml
|
|
399
|
-
`xdr:oneCellAnchor` の子要素順は `xdr:from → xdr:ext → (xdr:pic|xdr:sp) → xdr:clientData`。
|
|
400
|
-
`xdr:pic` の子要素順は `nvPicPr → blipFill → spPr`。
|
|
401
|
-
`r:embed` の rId は placement の並び順で振るため、buildDrawingRelsXml と同じ順で渡す。
|
|
402
|
-
|
|
403
|
-
注記図形は画像と同じアンカーセルに置き、画像左上からの EMU オフセットを
|
|
404
|
-
colOff / rowOff で与える (画像側の colOff / rowOff が 0 であることに依存する)。
|
|
405
|
-
cNvPr の id は画像・注記を通した連番で、drawing 全体で一意にする。
|
|
398
|
+
drawing1.xml。`r:embed` の rId は placement の並び順で振るため、buildDrawingRelsXml と同じ順で渡す。
|
|
406
399
|
*/
|
|
407
400
|
export function buildDrawingXml(placements) {
|
|
408
|
-
// 画像 → その画像の注記 の順に採番する。id を先に確定させてから XML を組むことで、
|
|
409
|
-
// 連結の順序と採番の順序を切り離す。
|
|
410
401
|
let nextShapeId = FIRST_SHAPE_ID;
|
|
411
402
|
const takeShapeId = () => {
|
|
412
403
|
const id = nextShapeId;
|
|
@@ -415,30 +406,49 @@ export function buildDrawingXml(placements) {
|
|
|
415
406
|
};
|
|
416
407
|
const anchors = placements.map((placement, offset) => {
|
|
417
408
|
const { anchor } = placement;
|
|
418
|
-
const
|
|
409
|
+
const relationshipId = imageRelationshipId(offset);
|
|
410
|
+
let body;
|
|
411
|
+
if (placement.annotationShapes.length > 0) {
|
|
412
|
+
const groupId = takeShapeId();
|
|
413
|
+
const pictureXml = buildPictureXml(placement, relationshipId, takeShapeId());
|
|
414
|
+
const shapesXml = placement.annotationShapes.map(shape => buildShapeXml(shape, takeShapeId())).join('');
|
|
415
|
+
body = buildGroupXml(placement, groupId, pictureXml, shapesXml);
|
|
416
|
+
}
|
|
417
|
+
else {
|
|
418
|
+
body = buildPictureXml(placement, relationshipId, takeShapeId());
|
|
419
|
+
}
|
|
420
|
+
return anchorXml({
|
|
419
421
|
column: anchor.column,
|
|
420
422
|
row: anchor.row,
|
|
421
423
|
columnOffsetEmu: 0,
|
|
422
424
|
rowOffsetEmu: 0,
|
|
423
425
|
widthEmu: anchor.widthEmu,
|
|
424
426
|
heightEmu: anchor.heightEmu,
|
|
425
|
-
},
|
|
426
|
-
const shapeAnchors = placement.annotationShapes
|
|
427
|
-
.map(shape => anchorXml({
|
|
428
|
-
column: anchor.column,
|
|
429
|
-
row: anchor.row,
|
|
430
|
-
columnOffsetEmu: shape.offsetXEmu,
|
|
431
|
-
rowOffsetEmu: shape.offsetYEmu,
|
|
432
|
-
widthEmu: shape.widthEmu,
|
|
433
|
-
heightEmu: shape.heightEmu,
|
|
434
|
-
}, buildShapeXml(shape, takeShapeId())))
|
|
435
|
-
.join('');
|
|
436
|
-
return pictureAnchor + shapeAnchors;
|
|
427
|
+
}, body);
|
|
437
428
|
}).join('');
|
|
438
429
|
return `${XML_DECLARATION}\n<xdr:wsDr xmlns:xdr="${NS_SPREADSHEET_DRAWING}" xmlns:a="${NS_DRAWINGML}"`
|
|
439
430
|
+ ` xmlns:r="${NS_OFFICE_RELATIONSHIPS}">${anchors}</xdr:wsDr>`;
|
|
440
431
|
}
|
|
441
432
|
/**
|
|
433
|
+
画像と注記をまとめる `xdr:grpSp`。子の座標系 (chOff / chExt) は画像の寸法に揃え、
|
|
434
|
+
グループ内の座標が EMU のまま画像左上を原点にする。
|
|
435
|
+
*/
|
|
436
|
+
function buildGroupXml(placement, groupId, pictureXml, shapesXml) {
|
|
437
|
+
const { widthEmu, heightEmu } = placement.anchor;
|
|
438
|
+
const cx = widthEmu.toString();
|
|
439
|
+
const cy = heightEmu.toString();
|
|
440
|
+
return `<xdr:grpSp>`
|
|
441
|
+
+ `<xdr:nvGrpSpPr>`
|
|
442
|
+
+ `<xdr:cNvPr id="${groupId.toString()}" name="Group ${placement.index.toString()}"/>`
|
|
443
|
+
+ `<xdr:cNvGrpSpPr/>`
|
|
444
|
+
+ `</xdr:nvGrpSpPr>`
|
|
445
|
+
+ `<xdr:grpSpPr><a:xfrm><a:off x="0" y="0"/><a:ext cx="${cx}" cy="${cy}"/>`
|
|
446
|
+
+ `<a:chOff x="0" y="0"/><a:chExt cx="${cx}" cy="${cy}"/></a:xfrm></xdr:grpSpPr>`
|
|
447
|
+
+ pictureXml
|
|
448
|
+
+ shapesXml
|
|
449
|
+
+ `</xdr:grpSp>`;
|
|
450
|
+
}
|
|
451
|
+
/**
|
|
442
452
|
oneCellAnchor の外枠。clientData は省略不可 (欠くと LibreOffice が図形を描画しない)。
|
|
443
453
|
`editAs` は CT_TwoCellAnchor だけが持つ属性なので oneCellAnchor には出さない。
|
|
444
454
|
*/
|
|
@@ -488,7 +498,8 @@ function buildShapeXml(shape, shapeId) {
|
|
|
488
498
|
+ `<xdr:cNvSpPr/>`
|
|
489
499
|
+ `</xdr:nvSpPr>`
|
|
490
500
|
+ `<xdr:spPr>`
|
|
491
|
-
+ `<a:xfrm${parts.transformAttributes}
|
|
501
|
+
+ `<a:xfrm${parts.transformAttributes}>`
|
|
502
|
+
+ `<a:off x="${shape.offsetXEmu.toString()}" y="${shape.offsetYEmu.toString()}"/>${extent}</a:xfrm>`
|
|
492
503
|
+ parts.geometry
|
|
493
504
|
+ parts.style
|
|
494
505
|
+ `</xdr:spPr>`
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import type { FailureReason } from '../_shared/failure-kind.js';
|
|
1
2
|
export declare class SlideCreateUsageError extends Error {
|
|
2
|
-
readonly reason:
|
|
3
|
-
constructor(message: string, reason:
|
|
3
|
+
readonly reason: FailureReason;
|
|
4
|
+
constructor(message: string, reason: FailureReason);
|
|
4
5
|
}
|
|
5
6
|
export declare class SlideCreateRuntimeError extends Error {
|
|
6
|
-
readonly reason:
|
|
7
|
-
constructor(message: string, reason:
|
|
7
|
+
readonly reason: FailureReason;
|
|
8
|
+
constructor(message: string, reason: FailureReason);
|
|
8
9
|
}
|
|
9
10
|
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import { ThemeDeclarationError } from './declaration.js';
|
|
2
|
-
import { ThemeFetchError } from './store-layout.js';
|
|
3
|
-
import { ThemeResolveError } from './talk-theme.js';
|
|
4
|
-
import { ThemeSpecError } from './theme-spec.js';
|
|
1
|
+
import { ThemeDeclarationError, type ThemeDeclarationErrorReason } from './declaration.js';
|
|
2
|
+
import { ThemeFetchError, type ThemeFetchErrorReason } from './store-layout.js';
|
|
3
|
+
import { ThemeResolveError, type ThemeResolveErrorReason } from './talk-theme.js';
|
|
4
|
+
import { ThemeSpecError, type ThemeSpecErrorReason } from './theme-spec.js';
|
|
5
|
+
/**
|
|
6
|
+
テーマの失敗の reason。`ThemeResolveError` の reason は最初から `theme-` を含む。
|
|
7
|
+
*/
|
|
8
|
+
export type ThemeErrorReason = ThemeResolveErrorReason | `theme-${ThemeFetchErrorReason | ThemeDeclarationErrorReason | ThemeSpecErrorReason}`;
|
|
5
9
|
export type ThemeError = ThemeResolveError | ThemeDeclarationError | ThemeFetchError | ThemeSpecError;
|
|
6
10
|
/**
|
|
7
11
|
テーマの解決・宣言・取得・指定のどれかの例外か。
|
|
@@ -11,5 +15,5 @@ export declare function isThemeError(error: unknown): error is ThemeError;
|
|
|
11
15
|
失敗の reason。テーマに関わる例外だけ `theme-<reason>` の形で返し、それ以外は undefined。
|
|
12
16
|
`ThemeResolveError` の reason は最初から `theme-` を含むので、そのまま返す。
|
|
13
17
|
*/
|
|
14
|
-
export declare function themeErrorReason(error: unknown):
|
|
18
|
+
export declare function themeErrorReason(error: unknown): ThemeErrorReason | undefined;
|
|
15
19
|
//# sourceMappingURL=error-reason.d.ts.map
|
|
@@ -86,8 +86,8 @@ create / sync は deps 経由で依存ルートを受け取っており、その
|
|
|
86
86
|
判定は `node_modules` の実在ではなく、代表パッケージ(RUNTIME_DEPENDENCY_PROBES)が
|
|
87
87
|
その `node_modules` 配下から引けるかで行う。
|
|
88
88
|
areRuntimeDependenciesInstalled と基準を揃え、次の食い違いを避ける。
|
|
89
|
-
npm が版衝突で `<配布パッケージ>/node_modules`
|
|
90
|
-
|
|
89
|
+
npm が版衝突で `<配布パッケージ>/node_modules` を掘ると、symlink は依存を含まないツリーを指す。
|
|
90
|
+
一方で runtime_setup は永続層へ install する。
|
|
91
91
|
*/
|
|
92
92
|
export declare function resolveTalkDirectoryNodeModules(dependencyRoot: string): string | undefined;
|
|
93
93
|
/**
|
|
@@ -126,7 +126,7 @@ export declare function runtimeInstallStampPath(): string | undefined;
|
|
|
126
126
|
|
|
127
127
|
同梱依存(プラグイン配布)を先に見る。
|
|
128
128
|
本モジュール自身の位置も基準に含めるのは、CLAUDE_PLUGIN_ROOT が立っていなくても、同梱の node_modules から引けるため。
|
|
129
|
-
env の有無で「未取得」と誤判定して、`
|
|
129
|
+
env の有無で「未取得」と誤判定して、`runtime_setup` が 600MB の npm install を始めるのを防ぐ。
|
|
130
130
|
単体配布では、本モジュールは `_npx/<hash>/node_modules/<pkg>/cli/dist/infra/_shared/` にある。
|
|
131
131
|
隣の node_modules には起動層しか無いので、この基準では解決できず永続層へ降りる。
|
|
132
132
|
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
// これは MCP クライアントの接続タイムアウトを超える。
|
|
17
17
|
// Claude Code の MCP_TIMEOUT は既定 30000ms。
|
|
18
18
|
//
|
|
19
|
-
// そこで重量依存だけをデータ置き場の `mcp-dist/node_modules` へ置き、`
|
|
19
|
+
// そこで重量依存だけをデータ置き場の `mcp-dist/node_modules` へ置き、`runtime_setup` ツールが取得する。
|
|
20
20
|
// この領域は npx の作り直しの影響を受けず残る。
|
|
21
21
|
// chromium が `~/.cache/ms-playwright` を使うのと同じ構造になる。
|
|
22
22
|
// データ置き場の解決は bin/_lib.sh の plugin_data_dir_resolve と同じ。
|
|
@@ -250,8 +250,8 @@ create / sync は deps 経由で依存ルートを受け取っており、その
|
|
|
250
250
|
判定は `node_modules` の実在ではなく、代表パッケージ(RUNTIME_DEPENDENCY_PROBES)が
|
|
251
251
|
その `node_modules` 配下から引けるかで行う。
|
|
252
252
|
areRuntimeDependenciesInstalled と基準を揃え、次の食い違いを避ける。
|
|
253
|
-
npm が版衝突で `<配布パッケージ>/node_modules`
|
|
254
|
-
|
|
253
|
+
npm が版衝突で `<配布パッケージ>/node_modules` を掘ると、symlink は依存を含まないツリーを指す。
|
|
254
|
+
一方で runtime_setup は永続層へ install する。
|
|
255
255
|
*/
|
|
256
256
|
export function resolveTalkDirectoryNodeModules(dependencyRoot) {
|
|
257
257
|
const runtimeRoot = runtimeDependencyRoot();
|
|
@@ -297,7 +297,7 @@ function resolveFrom(bases, specifier) {
|
|
|
297
297
|
判定できるのは依存ルートの実在だけで、配布形態そのものではない。
|
|
298
298
|
*/
|
|
299
299
|
export const DEPENDENCY_RECOVERY_HINT = 'for the plugin distribution, delete runtime/ in the data directory and restart pecotv (the dependencies are prepared again); '
|
|
300
|
-
+ 'for the standalone distribution, call the `
|
|
300
|
+
+ 'for the standalone distribution, call the `runtime_setup` tool (it fetches the runtime dependencies)';
|
|
301
301
|
/**
|
|
302
302
|
実行時依存が揃っているかの判定に使う specifier。
|
|
303
303
|
|
|
@@ -370,7 +370,7 @@ function readRuntimeInstallStamp() {
|
|
|
370
370
|
|
|
371
371
|
同梱依存(プラグイン配布)を先に見る。
|
|
372
372
|
本モジュール自身の位置も基準に含めるのは、CLAUDE_PLUGIN_ROOT が立っていなくても、同梱の node_modules から引けるため。
|
|
373
|
-
env の有無で「未取得」と誤判定して、`
|
|
373
|
+
env の有無で「未取得」と誤判定して、`runtime_setup` が 600MB の npm install を始めるのを防ぐ。
|
|
374
374
|
単体配布では、本モジュールは `_npx/<hash>/node_modules/<pkg>/cli/dist/infra/_shared/` にある。
|
|
375
375
|
隣の node_modules には起動層しか無いので、この基準では解決できず永続層へ降りる。
|
|
376
376
|
|
|
@@ -66,7 +66,7 @@ export interface InstallRuntimeDependenciesOptions {
|
|
|
66
66
|
/**
|
|
67
67
|
永続層へ実行時依存を install する。取得先は無ければここで作る。
|
|
68
68
|
`--prefix` を使うには install 先に package.json が要る(無いと npm は上位へ遡る)ので、毎回書き直す。
|
|
69
|
-
複数セッションの `
|
|
69
|
+
複数セッションの `runtime_setup` が並走し得るため、flock(1) で直列化する(無い環境ではロックなし)。
|
|
70
70
|
stamp は成功時だけ置き、先に消す。途中で失敗した残骸を取得済みと誤判定させないため。
|
|
71
71
|
manifest から plan を組めないときは、起動失敗(exitCode: null, failedStage: 'npm')として返す。
|
|
72
72
|
*/
|
|
@@ -136,7 +136,7 @@ export function runtimeInstallLockPath() {
|
|
|
136
136
|
/**
|
|
137
137
|
永続層へ実行時依存を install する。取得先は無ければここで作る。
|
|
138
138
|
`--prefix` を使うには install 先に package.json が要る(無いと npm は上位へ遡る)ので、毎回書き直す。
|
|
139
|
-
複数セッションの `
|
|
139
|
+
複数セッションの `runtime_setup` が並走し得るため、flock(1) で直列化する(無い環境ではロックなし)。
|
|
140
140
|
stamp は成功時だけ置き、先に消す。途中で失敗した残骸を取得済みと誤判定させないため。
|
|
141
141
|
manifest から plan を組めないときは、起動失敗(exitCode: null, failedStage: 'npm')として返す。
|
|
142
142
|
*/
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
解決できないときは throw する。畳み方は呼び出し元で違う。
|
|
7
7
|
pptx 変換 (slidev-to-pptx/runner.ts) は、commands/slidev-to-pptx が RuntimeError として扱う。
|
|
8
|
-
MCP 側では `
|
|
8
|
+
MCP 側では `runtime_setup` 誘導つきの ToolResult になる。
|
|
9
9
|
dev サーバ (mcp/dev-server-registry.ts) は、起動試行の try/catch が `dev-server-spawn-failed` として畳む。
|
|
10
10
|
*/
|
|
11
11
|
export declare function resolveSlidevBin(): string;
|
|
@@ -18,7 +18,7 @@ const requireFromHere = createRequire(import.meta.url);
|
|
|
18
18
|
|
|
19
19
|
解決できないときは throw する。畳み方は呼び出し元で違う。
|
|
20
20
|
pptx 変換 (slidev-to-pptx/runner.ts) は、commands/slidev-to-pptx が RuntimeError として扱う。
|
|
21
|
-
MCP 側では `
|
|
21
|
+
MCP 側では `runtime_setup` 誘導つきの ToolResult になる。
|
|
22
22
|
dev サーバ (mcp/dev-server-registry.ts) は、起動試行の try/catch が `dev-server-spawn-failed` として畳む。
|
|
23
23
|
*/
|
|
24
24
|
/* c8 ignore start -- production の `@slidev/cli` を resolve する箇所。test は port で差し替える */
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
//
|
|
3
3
|
// `pecotv mcp` は、MCP クライアントの接続タイムアウトに収めるため、起動時に Chromium を取得しない。
|
|
4
4
|
// 接続タイムアウトは、Claude Code の MCP_TIMEOUT が既定 30000ms。
|
|
5
|
-
// 取得は `
|
|
5
|
+
// 取得は `runtime_setup` ツールを明示的に呼んだとき、または PECOTV_AUTO_INSTALL_BROWSER=1 のときにだけ動く。
|
|
6
6
|
//
|
|
7
7
|
// 通常の CLI 実行 (`pecotv drawio url` 等) の取得手段は bin/pecotv 側にあり、本モジュールは通らない。
|
|
8
8
|
// 両者の「取得済みか」の判定基準は、Playwright が完了時に置く INSTALLATION_COMPLETE マーカーで揃える。
|
|
@@ -153,7 +153,7 @@ export async function installChromium(options = {}) {
|
|
|
153
153
|
}
|
|
154
154
|
catch (error) {
|
|
155
155
|
// ここで throw すると MCP ハンドラの外へ例外が出て、SDK が structuredContent 無しのエラーへまとめる。
|
|
156
|
-
// ToolResult 契約 (reason と `
|
|
156
|
+
// ToolResult 契約 (reason と `runtime_setup` 誘導) を保つため、起動失敗として返す。
|
|
157
157
|
const detail = error instanceof Error ? error.message : String(error);
|
|
158
158
|
return {
|
|
159
159
|
// eslint-disable-next-line unicorn/no-null -- SpawnResult は起動失敗を exitCode: null で表す
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// Chromium の実行ファイルは `playwright install chromium` で取得できるが、それが読み込む
|
|
4
4
|
// libatk / libpango 等の OS ライブラリは入らない。利用環境に無ければ drawio export / url の
|
|
5
5
|
// PNG 出力と slide convert が起動時に失敗する。利用者に手作業をさせないため、bootstrap と
|
|
6
|
-
// MCP の `
|
|
6
|
+
// MCP の `runtime_setup` ツールがここを通り、足りなければ自分で入れる。
|
|
7
7
|
//
|
|
8
8
|
// 入れるのは共有ライブラリだけにする。
|
|
9
9
|
// `playwright install-deps` は、フォント (fonts-wqy-zenhei 等) と headed 用の X サーバ (xvfb 等) も入れる。
|
|
@@ -16,7 +16,7 @@ export function chromiumLaunchError(message, cause) {
|
|
|
16
16
|
const libraries = missingSharedLibraries(message);
|
|
17
17
|
const libraryList = libraries.length > 0 ? ` (${libraries.join(', ')})` : '';
|
|
18
18
|
return new Error(`Playwright Chromium cannot launch because OS libraries are missing${libraryList}: ${message}\n`
|
|
19
|
-
+ ' run the pecotv setup (plugins/pecot-visual/setup.sh, or the
|
|
19
|
+
+ ' run the pecotv setup (plugins/pecot-visual/setup.sh, or the runtime_setup tool in MCP); it installs them automatically where sudo is available;'
|
|
20
20
|
+ ' where sudo is not available, ask an administrator to run the command that setup shows', { cause });
|
|
21
21
|
}
|
|
22
22
|
return /Executable doesn't exist|browserType\.launch|playwright\S*chromium/i.test(message)
|
|
@@ -443,7 +443,7 @@ export async function convertToPptx(config, deps = {}) {
|
|
|
443
443
|
? deps.resolveDomToPptx()
|
|
444
444
|
: (() => {
|
|
445
445
|
// 依存ルート越しに解決する。
|
|
446
|
-
// プラグイン配布では同梱の実体が、単体配布では `
|
|
446
|
+
// プラグイン配布では同梱の実体が、単体配布では `runtime_setup` が置いた永続層の実体が引かれる。
|
|
447
447
|
const entry = resolveDependency('dom-to-pptx', import.meta.url);
|
|
448
448
|
if (entry === undefined) {
|
|
449
449
|
throw new Error('cannot resolve dom-to-pptx.bundle.js: dom-to-pptx package not found\n'
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// `slidev build` を子プロセスで起動する SlidevRunner 実装。
|
|
2
2
|
// `@slidev/cli` の bin を依存ルート (infra/_shared/dependency-root.ts) から解決し、
|
|
3
3
|
// `node <slidev-bin>` で起動する。プラグイン形態では cli の direct dep として hoist された
|
|
4
|
-
// 実体が、単体配布形態では `
|
|
4
|
+
// 実体が、単体配布形態では `runtime_setup` が置いた永続層の実体が引かれる。利用者 project 側に
|
|
5
5
|
// slidev bin が無くても動作する。bin の解決そのものは dev サーバ起動 (mcp/dev-server-registry.ts)
|
|
6
6
|
// と共有するため infra/_shared/slidev-bin.ts に置く。
|
|
7
7
|
// `--theme` は command 側で許容文字 validate 済の前提で受け取る。
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Readable } from 'node:stream';
|
|
2
|
+
import type { FailureKind } from '../domain/_shared/failure-kind.js';
|
|
2
3
|
/**
|
|
3
4
|
レジストリが子プロセスへ求める最小の面 (node:child_process の ChildProcess がそのまま満たす)。
|
|
4
5
|
*/
|
|
@@ -48,7 +49,7 @@ export interface DevServerDependencies {
|
|
|
48
49
|
readonly pollIntervalMs: number;
|
|
49
50
|
readonly killEscalationMs: number;
|
|
50
51
|
}
|
|
51
|
-
export type DevServerFailureReason =
|
|
52
|
+
export type DevServerFailureReason = Extract<FailureKind, `dev-server-${string}`>;
|
|
52
53
|
export interface DevServerStartOptions {
|
|
53
54
|
/**
|
|
54
55
|
起動するポート。省略時は既定のポートを小さい順に試す。
|
package/cli/dist/mcp/result.d.ts
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import { Writable } from 'node:stream';
|
|
2
2
|
import type { CallToolResult } from '@modelcontextprotocol/server';
|
|
3
3
|
import type { z } from 'zod';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
ツールが目的を達成したか。false のとき CallToolResult は isError: true になる。
|
|
7
|
-
*/
|
|
8
|
-
readonly ok: boolean;
|
|
4
|
+
import type { FailureKind } from '../domain/_shared/failure-kind.js';
|
|
5
|
+
interface ToolResultFields {
|
|
9
6
|
/**
|
|
10
7
|
対応する CLI コマンドの exit code 規約をそのまま載せる (0 = success, 3 = warnings 等)。
|
|
11
8
|
*/
|
|
@@ -32,6 +29,22 @@ export interface ToolResult {
|
|
|
32
29
|
readonly stderr?: string;
|
|
33
30
|
}
|
|
34
31
|
/**
|
|
32
|
+
ok が false のとき CallToolResult は isError: true になり、kind に失敗の名前が入る。
|
|
33
|
+
*/
|
|
34
|
+
export type ToolResult = SucceededToolResult | FailedToolResult;
|
|
35
|
+
export type SucceededToolResult = ToolResultFields & {
|
|
36
|
+
readonly ok: true;
|
|
37
|
+
readonly kind?: never;
|
|
38
|
+
};
|
|
39
|
+
export type FailedToolResult = ToolResultFields & {
|
|
40
|
+
readonly ok: false;
|
|
41
|
+
readonly kind: FailureKind;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
stdout / stderr を呼び出し側が付ける前の ToolResult。Omit<ToolResult> では ok と kind の対応が崩れる。
|
|
45
|
+
*/
|
|
46
|
+
export type ToolResultBody = Omit<SucceededToolResult, 'stdout' | 'stderr'> | Omit<FailedToolResult, 'stdout' | 'stderr'>;
|
|
47
|
+
/**
|
|
35
48
|
ToolResult を MCP の CallToolResult へ変換する。
|
|
36
49
|
|
|
37
50
|
content には structuredContent と同じ内容の JSON テキストを載せる。structuredContent を
|
|
@@ -102,4 +115,5 @@ MCP サーバのプロセス stdout は JSON-RPC 専有なので、既存コマ
|
|
|
102
115
|
蓄積量は OUTPUT_CAPTURE_LIMIT_BYTES で頭打ちにし、超えた分は先頭から捨てる。
|
|
103
116
|
*/
|
|
104
117
|
export declare function createOutputCapture(): OutputCapture;
|
|
118
|
+
export {};
|
|
105
119
|
//# sourceMappingURL=result.d.ts.map
|
package/cli/dist/mcp/result.js
CHANGED
|
@@ -45,6 +45,7 @@ function toStructuredContent(result) {
|
|
|
45
45
|
return {
|
|
46
46
|
ok: result.ok,
|
|
47
47
|
exitCode: result.exitCode,
|
|
48
|
+
...(!result.ok && { kind: result.kind }),
|
|
48
49
|
artifacts: [...result.artifacts],
|
|
49
50
|
data: { ...result.data },
|
|
50
51
|
message: result.message,
|
|
@@ -117,6 +118,7 @@ schema, arguments_, keys) {
|
|
|
117
118
|
rejected: {
|
|
118
119
|
ok: false,
|
|
119
120
|
exitCode: USAGE_ERROR_EXIT_CODE,
|
|
121
|
+
kind: 'invalid-path',
|
|
120
122
|
artifacts: [],
|
|
121
123
|
data: { invalidPaths, ...convertedPart },
|
|
122
124
|
message: messages.join('; '),
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
ツール名の語と、その意味
|
|
3
|
+
*/
|
|
4
|
+
export interface ToolNameWord {
|
|
5
|
+
readonly word: string;
|
|
6
|
+
readonly meaning: string;
|
|
7
|
+
}
|
|
8
|
+
export declare const TOOL_NAME_SEPARATOR = "_";
|
|
9
|
+
/**
|
|
10
|
+
ツール名の 1 語目。ツールが扱う対象
|
|
11
|
+
*/
|
|
12
|
+
export declare const TOOL_SUBJECTS: readonly ToolNameWord[];
|
|
13
|
+
/**
|
|
14
|
+
ツール名の 2 語目。対象に対する操作
|
|
15
|
+
*/
|
|
16
|
+
export declare const TOOL_VERBS: readonly ToolNameWord[];
|
|
17
|
+
//# sourceMappingURL=tool-names.d.ts.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// MCP ツール名の語彙。名前は `<対象>_<動詞>` の 2 語で、定義書の書き出しが names に写す。
|
|
2
|
+
export const TOOL_NAME_SEPARATOR = '_';
|
|
3
|
+
/**
|
|
4
|
+
ツール名の 1 語目。ツールが扱う対象
|
|
5
|
+
*/
|
|
6
|
+
export const TOOL_SUBJECTS = [
|
|
7
|
+
{ word: 'drawio', meaning: 'draw.io diagrams' },
|
|
8
|
+
{ word: 'evidence', meaning: 'evidence workbooks built from screenshots' },
|
|
9
|
+
{ word: 'slide', meaning: 'Slidev decks and talk directories' },
|
|
10
|
+
{ word: 'runtime', meaning: 'runtime dependencies and Playwright Chromium' },
|
|
11
|
+
];
|
|
12
|
+
/**
|
|
13
|
+
ツール名の 2 語目。対象に対する操作
|
|
14
|
+
*/
|
|
15
|
+
export const TOOL_VERBS = [
|
|
16
|
+
{ word: 'create', meaning: 'generate a new file or directory' },
|
|
17
|
+
{ word: 'export', meaning: 'write a diagram out as SVG and PDF' },
|
|
18
|
+
{ word: 'convert', meaning: 'convert a deck to PPTX' },
|
|
19
|
+
{ word: 'dev', meaning: 'start the dev server' },
|
|
20
|
+
{ word: 'lint', meaning: 'list rule violations in a talk directory' },
|
|
21
|
+
{ word: 'page', meaning: 'generate a page skeleton for a layout' },
|
|
22
|
+
{ word: 'sync', meaning: 'bring a talk directory in line with its theme' },
|
|
23
|
+
{ word: 'theme', meaning: 'return the theme declaration and its layouts' },
|
|
24
|
+
{ word: 'setup', meaning: 'download what other tools need at run time' },
|
|
25
|
+
];
|
|
26
|
+
//# sourceMappingURL=tool-names.js.map
|
|
@@ -21,6 +21,7 @@ record として受け、同形性の検証は contract / parity テスト側で
|
|
|
21
21
|
export declare const TOOL_OUTPUT_SCHEMA: z.ZodObject<{
|
|
22
22
|
ok: z.ZodBoolean;
|
|
23
23
|
exitCode: z.ZodNumber;
|
|
24
|
+
kind: z.ZodOptional<z.ZodString>;
|
|
24
25
|
artifacts: z.ZodArray<z.ZodString>;
|
|
25
26
|
data: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
26
27
|
message: z.ZodString;
|
|
@@ -106,7 +107,7 @@ chromium を要するツールのハンドラ冒頭で使う実行時ガード (
|
|
|
106
107
|
|
|
107
108
|
`pecotv mcp` は接続タイムアウト (Claude Code の MCP_TIMEOUT は 30000ms が初期値) に収めるため、
|
|
108
109
|
起動時に chromium を取得しない。モデルから呼ばれるツールが 120MB のダウンロードを無断で始めないよう、
|
|
109
|
-
初期状態では取得せず、`
|
|
110
|
+
初期状態では取得せず、`runtime_setup` ツールの呼び出しを案内する。
|
|
110
111
|
PECOTV_AUTO_INSTALL_BROWSER=1 のときだけ、その場で取得してから処理を続行する。
|
|
111
112
|
これは CI・コンテナ・繰り返し使う開発者が、往復を省くための抜け道になる。
|
|
112
113
|
|
|
@@ -135,9 +136,9 @@ slide_create / slide_convert / slide_sync / slide_dev の 4 ツールが引数
|
|
|
135
136
|
実行時解決、dev は @slidev/cli の bin を使う。そこで未取得のときの失敗の型を、1 か所に置いて揃える。
|
|
136
137
|
|
|
137
138
|
プラグインとして導入した場合、実行時依存は同梱されているため、このガードは常に通る。
|
|
138
|
-
単体配布では起動層に重量依存を載せられないため、`
|
|
139
|
+
単体配布では起動層に重量依存を載せられないため、`runtime_setup` を呼ぶまで解決できない。
|
|
139
140
|
ensureChromium と違い、自動取得の抜け道は持たない。npm install は 600MB 級で、
|
|
140
|
-
モデルから呼ばれるツールが無断で始めてよい規模ではないため、必ず `
|
|
141
|
+
モデルから呼ばれるツールが無断で始めてよい規模ではないため、必ず `runtime_setup` を経由させる。
|
|
141
142
|
*/
|
|
142
143
|
export declare function ensureRuntimeDependencies(label: string, dependencies?: Readonly<RuntimeDependencies>): ToolResult | undefined;
|
|
143
144
|
export type NormalizedThemeArgument = {
|
|
@@ -39,6 +39,7 @@ record として受け、同形性の検証は contract / parity テスト側で
|
|
|
39
39
|
export const TOOL_OUTPUT_SCHEMA = z.object({
|
|
40
40
|
ok: z.boolean().describe('Whether the tool completed its intended run'),
|
|
41
41
|
exitCode: z.number().describe('Exit code (0 = success)'),
|
|
42
|
+
kind: z.string().optional().describe('Failure kind (omitted on success)'),
|
|
42
43
|
artifacts: z.array(z.string()).describe('Absolute paths of files and directories created or updated'),
|
|
43
44
|
data: z.record(z.string(), z.unknown()).describe('Object with the details of the run'),
|
|
44
45
|
message: z.string().describe('One-line summary for the calling agent'),
|
|
@@ -189,7 +190,7 @@ chromium を要するツールのハンドラ冒頭で使う実行時ガード (
|
|
|
189
190
|
|
|
190
191
|
`pecotv mcp` は接続タイムアウト (Claude Code の MCP_TIMEOUT は 30000ms が初期値) に収めるため、
|
|
191
192
|
起動時に chromium を取得しない。モデルから呼ばれるツールが 120MB のダウンロードを無断で始めないよう、
|
|
192
|
-
初期状態では取得せず、`
|
|
193
|
+
初期状態では取得せず、`runtime_setup` ツールの呼び出しを案内する。
|
|
193
194
|
PECOTV_AUTO_INSTALL_BROWSER=1 のときだけ、その場で取得してから処理を続行する。
|
|
194
195
|
これは CI・コンテナ・繰り返し使う開発者が、往復を省くための抜け道になる。
|
|
195
196
|
|
|
@@ -206,15 +207,16 @@ signal) {
|
|
|
206
207
|
ok: false,
|
|
207
208
|
exitCode: CHROMIUM_UNAVAILABLE_EXIT_CODE,
|
|
208
209
|
artifacts: [],
|
|
210
|
+
kind: 'chromium-not-installed',
|
|
209
211
|
data: {
|
|
210
212
|
event: 'chromium.unavailable',
|
|
211
213
|
reason: 'chromium-not-installed',
|
|
212
214
|
detail: `${label} needs Playwright Chromium, but it is not found in ${expectedLocation(dependencies)}`
|
|
213
|
-
+ '; call the `
|
|
215
|
+
+ '; call the `runtime_setup` tool to download it (about 120MB)'
|
|
214
216
|
+ `; to automate the download, set ${AUTO_INSTALL_ENV}=1`,
|
|
215
217
|
expectedAt: expectedLocation(dependencies),
|
|
216
218
|
},
|
|
217
|
-
message: `cannot run ${label}: Playwright Chromium is not installed; call the \`
|
|
219
|
+
message: `cannot run ${label}: Playwright Chromium is not installed; call the \`runtime_setup\` tool`,
|
|
218
220
|
};
|
|
219
221
|
}
|
|
220
222
|
const result = await dependencies.install(signal);
|
|
@@ -229,6 +231,7 @@ signal) {
|
|
|
229
231
|
ok: false,
|
|
230
232
|
exitCode: CHROMIUM_UNAVAILABLE_EXIT_CODE,
|
|
231
233
|
artifacts: [],
|
|
234
|
+
kind: 'chromium-install-failed',
|
|
232
235
|
data: {
|
|
233
236
|
event: 'chromium.unavailable',
|
|
234
237
|
reason: 'chromium-install-failed',
|
|
@@ -269,9 +272,9 @@ slide_create / slide_convert / slide_sync / slide_dev の 4 ツールが引数
|
|
|
269
272
|
実行時解決、dev は @slidev/cli の bin を使う。そこで未取得のときの失敗の型を、1 か所に置いて揃える。
|
|
270
273
|
|
|
271
274
|
プラグインとして導入した場合、実行時依存は同梱されているため、このガードは常に通る。
|
|
272
|
-
単体配布では起動層に重量依存を載せられないため、`
|
|
275
|
+
単体配布では起動層に重量依存を載せられないため、`runtime_setup` を呼ぶまで解決できない。
|
|
273
276
|
ensureChromium と違い、自動取得の抜け道は持たない。npm install は 600MB 級で、
|
|
274
|
-
モデルから呼ばれるツールが無断で始めてよい規模ではないため、必ず `
|
|
277
|
+
モデルから呼ばれるツールが無断で始めてよい規模ではないため、必ず `runtime_setup` を経由させる。
|
|
275
278
|
*/
|
|
276
279
|
export function ensureRuntimeDependencies(label, dependencies = runtimeDefaultDependencies()) {
|
|
277
280
|
if (dependencies.isInstalled())
|
|
@@ -281,6 +284,7 @@ export function ensureRuntimeDependencies(label, dependencies = runtimeDefaultDe
|
|
|
281
284
|
ok: false,
|
|
282
285
|
exitCode: RUNTIME_UNAVAILABLE_EXIT_CODE,
|
|
283
286
|
artifacts: [],
|
|
287
|
+
kind: 'runtime-dependencies-not-installed',
|
|
284
288
|
data: {
|
|
285
289
|
event: 'runtime-dependencies.unavailable',
|
|
286
290
|
reason: 'runtime-dependencies-not-installed',
|
|
@@ -288,7 +292,7 @@ export function ensureRuntimeDependencies(label, dependencies = runtimeDefaultDe
|
|
|
288
292
|
+ DEPENDENCY_RECOVERY_HINT,
|
|
289
293
|
expectedAt,
|
|
290
294
|
},
|
|
291
|
-
message: `cannot run ${label}: runtime dependencies are not installed; call the \`
|
|
295
|
+
message: `cannot run ${label}: runtime dependencies are not installed; call the \`runtime_setup\` tool`,
|
|
292
296
|
};
|
|
293
297
|
}
|
|
294
298
|
/**
|
|
@@ -8,8 +8,9 @@
|
|
|
8
8
|
// module top-level で評価すると、サーバ起動と tools/list がまとめて落ちる。
|
|
9
9
|
import { z } from 'zod';
|
|
10
10
|
import { assertOutputExtension as assertDrawioExportOutputExtension, drawioExportDefaultDependencies, errorToReason as drawioExportErrorToReason, executeDrawioExport, toExitCode as drawioExportToExitCode, } from '../../commands/drawio/export.js';
|
|
11
|
-
import { drawioUrlDefaultDependencies, errorData as drawioUrlErrorData, executeDrawioUrl, toExitCode as drawioUrlToExitCode, } from '../../commands/drawio/url.js';
|
|
11
|
+
import { drawioUrlDefaultDependencies, errorData as drawioUrlErrorData, errorToReason as drawioUrlErrorToReason, executeDrawioUrl, toExitCode as drawioUrlToExitCode, } from '../../commands/drawio/url.js';
|
|
12
12
|
import { createDiagnostics } from '../../diagnostics.js';
|
|
13
|
+
import { failureKindOf } from '../../domain/_shared/failure-kind.js';
|
|
13
14
|
import { resolvePluginRoot } from '../../infra/_shared/plugin-root.js';
|
|
14
15
|
import { defaultIconRoot } from '../../infra/drawio/icons.js';
|
|
15
16
|
import { parsePathArguments, toCallToolResult } from '../result.js';
|
|
@@ -56,7 +57,7 @@ CLI (`pecotv drawio url`) は PNG 生成の失敗を warning に格下げする
|
|
|
56
57
|
表示用 HTML は書いたうえで、`png: null` / `pngFailed: true` / warnings +1 / exit 3 を返す。
|
|
57
58
|
MCP だけが実処理の前に hard-fail すると、CLI と結果が食い違う。
|
|
58
59
|
degrade できる条件はこれだけ。drawio_export と slide_convert は、chromium が無いと成果物を 1 つも作れない。
|
|
59
|
-
data は CLI の PNG 失敗時と同一にし、`
|
|
60
|
+
data は CLI の PNG 失敗時と同一にし、`runtime_setup` の誘導は message へ載せる。
|
|
60
61
|
*/
|
|
61
62
|
function degradeToPngSkipped(execution, unavailable) {
|
|
62
63
|
return {
|
|
@@ -85,6 +86,7 @@ call) => {
|
|
|
85
86
|
return toCallToolResult({
|
|
86
87
|
ok: false,
|
|
87
88
|
exitCode: 2,
|
|
89
|
+
kind: 'invalid-option',
|
|
88
90
|
artifacts: [],
|
|
89
91
|
data: { event: 'drawio.url.error', reason: 'invalid-option', detail },
|
|
90
92
|
message: `pecotv drawio url: ${detail}`,
|
|
@@ -121,6 +123,7 @@ call) => {
|
|
|
121
123
|
const result = {
|
|
122
124
|
ok: false,
|
|
123
125
|
exitCode: drawioUrlToExitCode(error),
|
|
126
|
+
kind: failureKindOf(drawioUrlErrorToReason(error)),
|
|
124
127
|
artifacts: [],
|
|
125
128
|
data,
|
|
126
129
|
message: violationCount === undefined ? `pecotv drawio url: ${formatError(error)}` : textViolationMessage(violationCount),
|
|
@@ -176,11 +179,13 @@ drawio_export の失敗を CLI の `--json` エラーと同形の ToolResult に
|
|
|
176
179
|
*/
|
|
177
180
|
function drawioExportFailure(error) {
|
|
178
181
|
const detail = formatError(error);
|
|
182
|
+
const reason = drawioExportErrorToReason(error);
|
|
179
183
|
return {
|
|
180
184
|
ok: false,
|
|
181
185
|
exitCode: drawioExportToExitCode(error),
|
|
186
|
+
kind: failureKindOf(reason),
|
|
182
187
|
artifacts: [],
|
|
183
|
-
data: { event: 'drawio.export.error', reason
|
|
188
|
+
data: { event: 'drawio.export.error', reason, detail },
|
|
184
189
|
message: `pecotv drawio export: ${detail}`,
|
|
185
190
|
};
|
|
186
191
|
}
|
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
// オブジェクトをそのまま ToolResult.data に載せるため、CLI と MCP の結果は同形になる。
|
|
5
5
|
import path from 'node:path';
|
|
6
6
|
import { z } from 'zod';
|
|
7
|
-
import { errorData, EVIDENCE_CREATE_FAILURE_EXIT_CODE, evidenceCreateDefaultDependencies, executeEvidenceCreate, } from '../../commands/evidence-xlsx/create.js';
|
|
7
|
+
import { errorData, errorToReason, EVIDENCE_CREATE_FAILURE_EXIT_CODE, evidenceCreateDefaultDependencies, executeEvidenceCreate, } from '../../commands/evidence-xlsx/create.js';
|
|
8
|
+
import { failureKindOf } from '../../domain/_shared/failure-kind.js';
|
|
8
9
|
import { parsePathArguments, toCallToolResult } from '../result.js';
|
|
9
10
|
import { captureCommandOutput, formatError, textViolationMessage, TOOL_OUTPUT_SCHEMA, violationCountOf, WINDOWS_PATH_NOTE } from './_shared.js';
|
|
10
11
|
const evidenceCreateInput = z.object({
|
|
@@ -53,6 +54,7 @@ async function handleEvidenceCreate(arguments_) {
|
|
|
53
54
|
// usage エラー (exit 2) は commander の引数検証にしか無い。MCP では
|
|
54
55
|
// inputSchema と parsePathArguments が先に弾くため、ここは実行失敗の 1 のみ。
|
|
55
56
|
exitCode: EVIDENCE_CREATE_FAILURE_EXIT_CODE,
|
|
57
|
+
kind: failureKindOf(errorToReason(error)),
|
|
56
58
|
artifacts: [],
|
|
57
59
|
data,
|
|
58
60
|
message: violationCount === undefined ? formatError(error) : textViolationMessage(violationCount),
|
|
@@ -2,7 +2,7 @@ import { type HostDependencies } from '../../infra/playwright/host-dependencies.
|
|
|
2
2
|
import type { ToolDefinition } from '../server.js';
|
|
3
3
|
import { type ChromiumDependencies, type RuntimeDependencies } from './_shared.js';
|
|
4
4
|
/**
|
|
5
|
-
`
|
|
5
|
+
`runtime_setup` を公開する。
|
|
6
6
|
|
|
7
7
|
引数は取らない。chromium 側は取得済みかを見て早期 return はしない。
|
|
8
8
|
判定が「取得済み」になる状態でも、実体が欠けていることがある。
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//
|
|
1
|
+
// runtime_setup ツール。実行時依存 (永続層) と Playwright Chromium を明示的に取得する。
|
|
2
2
|
//
|
|
3
3
|
// `pecotv mcp` は MCP クライアントの接続タイムアウト (Claude Code の MCP_TIMEOUT は既定
|
|
4
4
|
// 30000ms) に収めるため、起動時に何も取得しない。また、モデルが呼ぶツールの側から 120MB 級の
|
|
@@ -181,7 +181,7 @@ function successMessage(runtime, chromium, hostDependencies) {
|
|
|
181
181
|
return parts.join(' / ');
|
|
182
182
|
}
|
|
183
183
|
/**
|
|
184
|
-
`
|
|
184
|
+
`runtime_setup` を公開する。
|
|
185
185
|
|
|
186
186
|
引数は取らない。chromium 側は取得済みかを見て早期 return はしない。
|
|
187
187
|
判定が「取得済み」になる状態でも、実体が欠けていることがある。
|
|
@@ -250,6 +250,8 @@ export function setupTool(buildDependencies = chromiumDefaultDependencies, build
|
|
|
250
250
|
const result = {
|
|
251
251
|
ok: false,
|
|
252
252
|
exitCode: runtime.installed ? CHROMIUM_UNAVAILABLE_EXIT_CODE : RUNTIME_UNAVAILABLE_EXIT_CODE,
|
|
253
|
+
// data.reason は失敗した段をカンマでつなぐ。kind には最初に失敗した段の名前を入れる。
|
|
254
|
+
kind: failures[0]?.reason ?? 'unknown',
|
|
253
255
|
artifacts,
|
|
254
256
|
data: {
|
|
255
257
|
event: 'setup.error',
|
|
@@ -263,7 +265,7 @@ export function setupTool(buildDependencies = chromiumDefaultDependencies, build
|
|
|
263
265
|
return toCallToolResult(result);
|
|
264
266
|
};
|
|
265
267
|
return {
|
|
266
|
-
name: '
|
|
268
|
+
name: 'runtime_setup',
|
|
267
269
|
config: {
|
|
268
270
|
title: 'Prepare the runtime (runtime dependencies / Chromium download and OS libraries)',
|
|
269
271
|
description: 'Downloads the runtime dependencies pecotv uses (@slidev/cli / dom-to-pptx / @slidev/parser, etc.) and Playwright Chromium. '
|