@capyclaw/ppt-suite 2.5.68 → 2.5.70
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/composition.lock.json +5 -5
- package/contract/ppt-contract.json +27 -1
- package/dsh-suite.json +5 -5
- package/node_modules/@capyclaw/asset-service/src/index.mjs +6 -1
- package/node_modules/@capyclaw/foundation/abi/loader.mjs +8 -1
- package/node_modules/@capyclaw/foundation/abi/spec.mjs +5 -2
- package/node_modules/@capyclaw/foundation/abi/version.mjs +63 -5
- package/node_modules/@capyclaw/foundation/lib/host/memory.mjs +29 -2
- package/node_modules/@capyclaw/foundation/lib/subsystems/net.mjs +12 -2
- package/node_modules/@capyclaw/plugin-kit/src/editor/lease.mjs +3 -1
- package/node_modules/@capyclaw/ppt-editor/contract/ppt-contract.json +27 -1
- package/node_modules/@capyclaw/ppt-skill-api/contract/ppt-contract.json +27 -1
- package/node_modules/@capyclaw/ppt-skill-api/skills/pptist-api/references/tool-contract.md +1 -1
- package/node_modules/@capyclaw/ppt-skill-proposal/contract/ppt-contract.json +27 -1
- package/node_modules/@capyclaw/ppt-workbench/contract/ppt-contract.json +27 -1
- package/node_modules/@capyclaw/ppt-workbench/package.json +2 -2
- package/node_modules/@capyclaw/ppt-workbench/server/contract.mjs +1 -1
- package/node_modules/@capyclaw/ppt-workbench/server/embedded-host.mjs +11 -1
- package/node_modules/@capyclaw/ppt-workbench/server/shared/SHARED_MANIFEST.json +1 -1
- package/node_modules/@capyclaw/ppt-workbench/server/workbench-framework.mjs +34 -0
- package/node_modules/@capyclaw/service-broker/lib/control.mjs +23 -7
- package/node_modules/@capyclaw/service-broker/lib/engine.mjs +60 -6
- package/node_modules/@capyclaw/service-broker/lib/manifest.mjs +15 -2
- package/node_modules/@capyclaw/service-broker/lib/skills-client.mjs +17 -5
- package/node_modules/@capyclaw/service-host/src/index.mjs +9 -1
- package/node_modules/@capyclaw/tool-host/dsh-suite.json +2 -2
- package/node_modules/@capyclaw/tool-host/lib/host.mjs +23 -4
- package/node_modules/@capyclaw/tool-host/package.json +1 -1
- package/node_modules/@capyclaw/tool-host/src/admit-images.mjs +80 -0
- package/node_modules/@capyclaw/tool-host/src/caller-session.mjs +25 -0
- package/node_modules/@capyclaw/tool-host/src/index.mjs +45 -14
- package/node_modules/@capyclaw/tool-host/src/mode-gate.mjs +204 -0
- package/node_modules/playwright-core/LICENSE +202 -0
- package/node_modules/playwright-core/NOTICE +5 -0
- package/node_modules/playwright-core/README.md +3 -0
- package/node_modules/playwright-core/ThirdPartyNotices.txt +13 -0
- package/node_modules/playwright-core/bin/install_media_pack.ps1 +5 -0
- package/node_modules/playwright-core/bin/install_webkit_wsl.ps1 +33 -0
- package/node_modules/playwright-core/bin/reinstall_chrome_beta_linux.sh +42 -0
- package/node_modules/playwright-core/bin/reinstall_chrome_beta_mac.sh +13 -0
- package/node_modules/playwright-core/bin/reinstall_chrome_beta_win.ps1 +24 -0
- package/node_modules/playwright-core/bin/reinstall_chrome_stable_linux.sh +42 -0
- package/node_modules/playwright-core/bin/reinstall_chrome_stable_mac.sh +12 -0
- package/node_modules/playwright-core/bin/reinstall_chrome_stable_win.ps1 +24 -0
- package/node_modules/playwright-core/bin/reinstall_msedge_beta_linux.sh +48 -0
- package/node_modules/playwright-core/bin/reinstall_msedge_beta_mac.sh +11 -0
- package/node_modules/playwright-core/bin/reinstall_msedge_beta_win.ps1 +23 -0
- package/node_modules/playwright-core/bin/reinstall_msedge_dev_linux.sh +48 -0
- package/node_modules/playwright-core/bin/reinstall_msedge_dev_mac.sh +11 -0
- package/node_modules/playwright-core/bin/reinstall_msedge_dev_win.ps1 +23 -0
- package/node_modules/playwright-core/bin/reinstall_msedge_stable_linux.sh +48 -0
- package/node_modules/playwright-core/bin/reinstall_msedge_stable_mac.sh +11 -0
- package/node_modules/playwright-core/bin/reinstall_msedge_stable_win.ps1 +24 -0
- package/node_modules/playwright-core/browsers.json +52 -0
- package/node_modules/playwright-core/cli.js +22 -0
- package/node_modules/playwright-core/index.d.ts +17 -0
- package/node_modules/playwright-core/index.js +17 -0
- package/node_modules/playwright-core/index.mjs +28 -0
- package/node_modules/playwright-core/lib/bootstrap.js +149 -0
- package/node_modules/playwright-core/lib/coreBundle.js +78041 -0
- package/node_modules/playwright-core/lib/entry/cliDaemon.js +5 -0
- package/node_modules/playwright-core/lib/entry/dashboardApp.js +3 -0
- package/node_modules/playwright-core/lib/entry/mcp.js +10 -0
- package/node_modules/playwright-core/lib/entry/oopBrowserDownload.js +3 -0
- package/node_modules/playwright-core/lib/package.js +50 -0
- package/node_modules/playwright-core/lib/server/chromium/appIcon.png +0 -0
- package/node_modules/playwright-core/lib/server/electron/loader.js +123 -0
- package/node_modules/playwright-core/lib/serverRegistry.js +1939 -0
- package/node_modules/playwright-core/lib/serverRegistry.js.LICENSE +65 -0
- package/node_modules/playwright-core/lib/tools/cli-client/channelSessions.js +141 -0
- package/node_modules/playwright-core/lib/tools/cli-client/cli.js +7 -0
- package/node_modules/playwright-core/lib/tools/cli-client/help.json +808 -0
- package/node_modules/playwright-core/lib/tools/cli-client/minimist.js +128 -0
- package/node_modules/playwright-core/lib/tools/cli-client/output.js +352 -0
- package/node_modules/playwright-core/lib/tools/cli-client/program.js +422 -0
- package/node_modules/playwright-core/lib/tools/cli-client/registry.js +180 -0
- package/node_modules/playwright-core/lib/tools/cli-client/session.js +261 -0
- package/node_modules/playwright-core/lib/tools/dashboard/appIcon.png +0 -0
- package/node_modules/playwright-core/lib/tools/skills/playwright-cli/SKILL.md +493 -0
- package/node_modules/playwright-core/lib/tools/skills/playwright-cli/references/element-attributes.md +23 -0
- package/node_modules/playwright-core/lib/tools/skills/playwright-cli/references/playwright-tests.md +39 -0
- package/node_modules/playwright-core/lib/tools/skills/playwright-cli/references/pr-attachments.md +60 -0
- package/node_modules/playwright-core/lib/tools/skills/playwright-cli/references/request-mocking.md +87 -0
- package/node_modules/playwright-core/lib/tools/skills/playwright-cli/references/running-code.md +245 -0
- package/node_modules/playwright-core/lib/tools/skills/playwright-cli/references/session-management.md +227 -0
- package/node_modules/playwright-core/lib/tools/skills/playwright-cli/references/storage-state.md +275 -0
- package/node_modules/playwright-core/lib/tools/skills/playwright-cli/references/test-generation.md +433 -0
- package/node_modules/playwright-core/lib/tools/skills/playwright-cli/references/tracing.md +139 -0
- package/node_modules/playwright-core/lib/tools/skills/playwright-cli/references/video-recording.md +216 -0
- package/node_modules/playwright-core/lib/tools/skills/playwright-component-testing/SKILL.md +136 -0
- package/node_modules/playwright-core/lib/tools/skills/playwright-component-testing/references/gallery-spec.md +144 -0
- package/node_modules/playwright-core/lib/tools/skills/playwright-component-testing/references/migration.md +89 -0
- package/node_modules/playwright-core/lib/tools/skills/playwright-component-testing/references/react.md +69 -0
- package/node_modules/playwright-core/lib/tools/skills/playwright-component-testing/references/typing.md +173 -0
- package/node_modules/playwright-core/lib/tools/skills/playwright-component-testing/references/vue.md +77 -0
- package/node_modules/playwright-core/lib/tools/skills/playwright-trace/SKILL.md +174 -0
- package/node_modules/playwright-core/lib/tools/utils/extension.js +112 -0
- package/node_modules/playwright-core/lib/tools/utils/socketConnection.js +108 -0
- package/node_modules/playwright-core/lib/utilsBundle.js +86078 -0
- package/node_modules/playwright-core/lib/utilsBundle.js.LICENSE +1890 -0
- package/node_modules/playwright-core/lib/vite/dashboard/assets/codeMirrorModule--QdMvsKi.css +1 -0
- package/node_modules/playwright-core/lib/vite/dashboard/assets/codeMirrorModule-CQ8RZGBm.js +32 -0
- package/node_modules/playwright-core/lib/vite/dashboard/assets/codicon-DCmgc-ay.ttf +0 -0
- package/node_modules/playwright-core/lib/vite/dashboard/assets/firefox-1bWoP6pv.svg +1 -0
- package/node_modules/playwright-core/lib/vite/dashboard/assets/firefox-beta-k3eOH_eK.svg +1 -0
- package/node_modules/playwright-core/lib/vite/dashboard/assets/firefox-nightly-Cp5nfeDT.svg +1 -0
- package/node_modules/playwright-core/lib/vite/dashboard/assets/index-AwgwcYie.css +1 -0
- package/node_modules/playwright-core/lib/vite/dashboard/assets/index-hRvO4yU2.js +12 -0
- package/node_modules/playwright-core/lib/vite/dashboard/assets/safari-na3_-uQk.svg +1 -0
- package/node_modules/playwright-core/lib/vite/dashboard/index.html +29 -0
- package/node_modules/playwright-core/lib/vite/dashboard/playwright-logo.svg +24 -0
- package/node_modules/playwright-core/lib/vite/htmlReport/index.html +16 -0
- package/node_modules/playwright-core/lib/vite/htmlReport/report.css +2 -0
- package/node_modules/playwright-core/lib/vite/htmlReport/report.js +32 -0
- package/node_modules/playwright-core/lib/vite/recorder/assets/codeMirrorModule--QdMvsKi.css +1 -0
- package/node_modules/playwright-core/lib/vite/recorder/assets/codeMirrorModule-DK72OMRi.js +32 -0
- package/node_modules/playwright-core/lib/vite/recorder/assets/codicon-DCmgc-ay.ttf +0 -0
- package/node_modules/playwright-core/lib/vite/recorder/assets/index-BZpYJZ-P.css +1 -0
- package/node_modules/playwright-core/lib/vite/recorder/assets/index-Cn0mmDuv.js +129 -0
- package/node_modules/playwright-core/lib/vite/recorder/index.html +29 -0
- package/node_modules/playwright-core/lib/vite/recorder/playwright-logo.svg +9 -0
- package/node_modules/playwright-core/lib/vite/traceViewer/assets/codeMirrorModule-BEB2e8M3.js +32 -0
- package/node_modules/playwright-core/lib/vite/traceViewer/assets/defaultSettingsView-D-g2vrvf.js +184 -0
- package/node_modules/playwright-core/lib/vite/traceViewer/assets/urlMatch-L3liM589.js +1 -0
- package/node_modules/playwright-core/lib/vite/traceViewer/assets/xtermModule-B794rD2Z.js +7 -0
- package/node_modules/playwright-core/lib/vite/traceViewer/codeMirrorModule.-QdMvsKi.css +1 -0
- package/node_modules/playwright-core/lib/vite/traceViewer/codicon.DCmgc-ay.ttf +0 -0
- package/node_modules/playwright-core/lib/vite/traceViewer/defaultSettingsView.C8BeHuxd.css +1 -0
- package/node_modules/playwright-core/lib/vite/traceViewer/index.B_TqY17P.css +1 -0
- package/node_modules/playwright-core/lib/vite/traceViewer/index.html +44 -0
- package/node_modules/playwright-core/lib/vite/traceViewer/index.oNry3Hjv.js +1 -0
- package/node_modules/playwright-core/lib/vite/traceViewer/manifest.webmanifest +16 -0
- package/node_modules/playwright-core/lib/vite/traceViewer/playwright-logo.svg +9 -0
- package/node_modules/playwright-core/lib/vite/traceViewer/snapshot.B_Jk1wbt.js +1 -0
- package/node_modules/playwright-core/lib/vite/traceViewer/snapshot.html +10 -0
- package/node_modules/playwright-core/lib/vite/traceViewer/sw.bundle.js +4 -0
- package/node_modules/playwright-core/lib/vite/traceViewer/uiMode.CYwC_gH1.js +5 -0
- package/node_modules/playwright-core/lib/vite/traceViewer/uiMode.CyMfwkXJ.css +1 -0
- package/node_modules/playwright-core/lib/vite/traceViewer/uiMode.html +18 -0
- package/node_modules/playwright-core/lib/vite/traceViewer/xtermModule.kHJ-D0s7.css +1 -0
- package/node_modules/playwright-core/lib/webp_codec.LICENSE +173 -0
- package/node_modules/playwright-core/lib/webp_codec.wasm +0 -0
- package/node_modules/playwright-core/lib/xdg-open +1267 -0
- package/node_modules/playwright-core/package.json +34 -0
- package/node_modules/playwright-core/types/protocol.d.ts +24776 -0
- package/node_modules/playwright-core/types/structs.d.ts +52 -0
- package/node_modules/playwright-core/types/types.d.ts +27167 -0
- package/package.json +4 -4
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"contractVersion": "2.5.0",
|
|
3
|
-
"packageVersion": "2.5.
|
|
3
|
+
"packageVersion": "2.5.70",
|
|
4
4
|
"toolCount": 32,
|
|
5
5
|
"tools": [
|
|
6
6
|
{
|
|
@@ -1520,6 +1520,7 @@
|
|
|
1520
1520
|
"compose",
|
|
1521
1521
|
"edit"
|
|
1522
1522
|
],
|
|
1523
|
+
"domain": "",
|
|
1523
1524
|
"tools": [
|
|
1524
1525
|
"ppt_outline",
|
|
1525
1526
|
"ppt_write",
|
|
@@ -1534,6 +1535,7 @@
|
|
|
1534
1535
|
"tags": [
|
|
1535
1536
|
"meta"
|
|
1536
1537
|
],
|
|
1538
|
+
"domain": "",
|
|
1537
1539
|
"tools": [
|
|
1538
1540
|
"ppt_capabilities"
|
|
1539
1541
|
]
|
|
@@ -1545,6 +1547,7 @@
|
|
|
1545
1547
|
"tags": [
|
|
1546
1548
|
"read"
|
|
1547
1549
|
],
|
|
1550
|
+
"domain": "",
|
|
1548
1551
|
"tools": [
|
|
1549
1552
|
"ppt_get_deck"
|
|
1550
1553
|
]
|
|
@@ -1557,6 +1560,7 @@
|
|
|
1557
1560
|
"read",
|
|
1558
1561
|
"quality"
|
|
1559
1562
|
],
|
|
1563
|
+
"domain": "",
|
|
1560
1564
|
"tools": [
|
|
1561
1565
|
"ppt_audit"
|
|
1562
1566
|
]
|
|
@@ -1570,6 +1574,7 @@
|
|
|
1570
1574
|
"layout",
|
|
1571
1575
|
"visual"
|
|
1572
1576
|
],
|
|
1577
|
+
"domain": "",
|
|
1573
1578
|
"tools": [
|
|
1574
1579
|
"ppt_inspect"
|
|
1575
1580
|
]
|
|
@@ -1581,6 +1586,7 @@
|
|
|
1581
1586
|
"tags": [
|
|
1582
1587
|
"state"
|
|
1583
1588
|
],
|
|
1589
|
+
"domain": "",
|
|
1584
1590
|
"tools": [
|
|
1585
1591
|
"ppt_task"
|
|
1586
1592
|
]
|
|
@@ -1593,6 +1599,7 @@
|
|
|
1593
1599
|
"write",
|
|
1594
1600
|
"content"
|
|
1595
1601
|
],
|
|
1602
|
+
"domain": "",
|
|
1596
1603
|
"tools": [
|
|
1597
1604
|
"ppt_text",
|
|
1598
1605
|
"ppt_fill"
|
|
@@ -1606,6 +1613,7 @@
|
|
|
1606
1613
|
"write",
|
|
1607
1614
|
"style"
|
|
1608
1615
|
],
|
|
1616
|
+
"domain": "",
|
|
1609
1617
|
"tools": [
|
|
1610
1618
|
"ppt_style"
|
|
1611
1619
|
]
|
|
@@ -1618,6 +1626,7 @@
|
|
|
1618
1626
|
"write",
|
|
1619
1627
|
"layout"
|
|
1620
1628
|
],
|
|
1629
|
+
"domain": "",
|
|
1621
1630
|
"tools": [
|
|
1622
1631
|
"ppt_element"
|
|
1623
1632
|
]
|
|
@@ -1630,6 +1639,7 @@
|
|
|
1630
1639
|
"write",
|
|
1631
1640
|
"structure"
|
|
1632
1641
|
],
|
|
1642
|
+
"domain": "",
|
|
1633
1643
|
"tools": [
|
|
1634
1644
|
"ppt_slide"
|
|
1635
1645
|
]
|
|
@@ -1641,6 +1651,7 @@
|
|
|
1641
1651
|
"tags": [
|
|
1642
1652
|
"advanced"
|
|
1643
1653
|
],
|
|
1654
|
+
"domain": "",
|
|
1644
1655
|
"tools": [
|
|
1645
1656
|
"ppt_apply"
|
|
1646
1657
|
]
|
|
@@ -1653,6 +1664,7 @@
|
|
|
1653
1664
|
"recipe",
|
|
1654
1665
|
"layout"
|
|
1655
1666
|
],
|
|
1667
|
+
"domain": "",
|
|
1656
1668
|
"tools": [
|
|
1657
1669
|
"ppt_deck",
|
|
1658
1670
|
"ppt_page"
|
|
@@ -1666,6 +1678,7 @@
|
|
|
1666
1678
|
"recipe",
|
|
1667
1679
|
"style"
|
|
1668
1680
|
],
|
|
1681
|
+
"domain": "",
|
|
1669
1682
|
"tools": [
|
|
1670
1683
|
"ppt_recolor"
|
|
1671
1684
|
]
|
|
@@ -1678,6 +1691,7 @@
|
|
|
1678
1691
|
"write",
|
|
1679
1692
|
"media"
|
|
1680
1693
|
],
|
|
1694
|
+
"domain": "",
|
|
1681
1695
|
"tools": [
|
|
1682
1696
|
"ppt_image"
|
|
1683
1697
|
]
|
|
@@ -1689,6 +1703,7 @@
|
|
|
1689
1703
|
"tags": [
|
|
1690
1704
|
"read"
|
|
1691
1705
|
],
|
|
1706
|
+
"domain": "",
|
|
1692
1707
|
"tools": [
|
|
1693
1708
|
"ppt_images"
|
|
1694
1709
|
]
|
|
@@ -1701,6 +1716,7 @@
|
|
|
1701
1716
|
"read",
|
|
1702
1717
|
"visual"
|
|
1703
1718
|
],
|
|
1719
|
+
"domain": "",
|
|
1704
1720
|
"tools": [
|
|
1705
1721
|
"ppt_screenshot"
|
|
1706
1722
|
]
|
|
@@ -1712,6 +1728,7 @@
|
|
|
1712
1728
|
"tags": [
|
|
1713
1729
|
"control"
|
|
1714
1730
|
],
|
|
1731
|
+
"domain": "",
|
|
1715
1732
|
"tools": [
|
|
1716
1733
|
"ppt_present"
|
|
1717
1734
|
]
|
|
@@ -1723,6 +1740,7 @@
|
|
|
1723
1740
|
"tags": [
|
|
1724
1741
|
"control"
|
|
1725
1742
|
],
|
|
1743
|
+
"domain": "",
|
|
1726
1744
|
"tools": [
|
|
1727
1745
|
"ppt_history"
|
|
1728
1746
|
]
|
|
@@ -1735,6 +1753,7 @@
|
|
|
1735
1753
|
"write",
|
|
1736
1754
|
"data"
|
|
1737
1755
|
],
|
|
1756
|
+
"domain": "",
|
|
1738
1757
|
"tools": [
|
|
1739
1758
|
"ppt_chart"
|
|
1740
1759
|
]
|
|
@@ -1747,6 +1766,7 @@
|
|
|
1747
1766
|
"write",
|
|
1748
1767
|
"data"
|
|
1749
1768
|
],
|
|
1769
|
+
"domain": "",
|
|
1750
1770
|
"tools": [
|
|
1751
1771
|
"ppt_table",
|
|
1752
1772
|
"ppt_table_cells"
|
|
@@ -1760,6 +1780,7 @@
|
|
|
1760
1780
|
"write",
|
|
1761
1781
|
"content"
|
|
1762
1782
|
],
|
|
1783
|
+
"domain": "",
|
|
1763
1784
|
"tools": [
|
|
1764
1785
|
"ppt_notes"
|
|
1765
1786
|
]
|
|
@@ -1772,6 +1793,7 @@
|
|
|
1772
1793
|
"write",
|
|
1773
1794
|
"layout"
|
|
1774
1795
|
],
|
|
1796
|
+
"domain": "",
|
|
1775
1797
|
"tools": [
|
|
1776
1798
|
"ppt_shape"
|
|
1777
1799
|
]
|
|
@@ -1784,6 +1806,7 @@
|
|
|
1784
1806
|
"write",
|
|
1785
1807
|
"layout"
|
|
1786
1808
|
],
|
|
1809
|
+
"domain": "",
|
|
1787
1810
|
"tools": [
|
|
1788
1811
|
"ppt_line"
|
|
1789
1812
|
]
|
|
@@ -1796,6 +1819,7 @@
|
|
|
1796
1819
|
"write",
|
|
1797
1820
|
"content"
|
|
1798
1821
|
],
|
|
1822
|
+
"domain": "",
|
|
1799
1823
|
"tools": [
|
|
1800
1824
|
"ppt_formula"
|
|
1801
1825
|
]
|
|
@@ -1808,6 +1832,7 @@
|
|
|
1808
1832
|
"write",
|
|
1809
1833
|
"file"
|
|
1810
1834
|
],
|
|
1835
|
+
"domain": "",
|
|
1811
1836
|
"tools": [
|
|
1812
1837
|
"ppt_import_pptx"
|
|
1813
1838
|
]
|
|
@@ -1820,6 +1845,7 @@
|
|
|
1820
1845
|
"write",
|
|
1821
1846
|
"file"
|
|
1822
1847
|
],
|
|
1848
|
+
"domain": "",
|
|
1823
1849
|
"tools": [
|
|
1824
1850
|
"ppt_export_pptx"
|
|
1825
1851
|
]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capyclaw/ppt-workbench",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.70",
|
|
4
4
|
"description": "PPT 工作台运行时(headless 可用):32 个 ppt_* MCP 工具(导入/导出 PPTX + 图表/表格/公式/形状/线条/备注 + 契约探测);浏览器实时编辑器由可选成员包 @capyclaw/ppt-editor 提供。",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./plugin.mjs",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"@capyclaw/foundation": "^0.1.9",
|
|
53
53
|
"@capyclaw/plugin-kit": "^0.2.6",
|
|
54
54
|
"@capyclaw/service-host": "^0.1.5",
|
|
55
|
-
"@capyclaw/tool-host": "^0.
|
|
55
|
+
"@capyclaw/tool-host": "^0.3.0",
|
|
56
56
|
"playwright-core": "^1.60.0",
|
|
57
57
|
"pptxgenjs": "^3.12.0"
|
|
58
58
|
},
|
|
@@ -10,7 +10,7 @@ import { createCapabilityReport } from './shared/tool-host.mjs'
|
|
|
10
10
|
export const CONTRACT_VERSION = '2.5.0'
|
|
11
11
|
|
|
12
12
|
/** 工作台包版本。 */
|
|
13
|
-
export const PACKAGE_VERSION = '2.5.
|
|
13
|
+
export const PACKAGE_VERSION = '2.5.70'
|
|
14
14
|
|
|
15
15
|
/** 生成模型可读的能力报告(`editorPath` 由 tool-host 从 editorUrl 推出:同源相对路径,不带端口)。 */
|
|
16
16
|
export function capabilityReport(args, editorUrl = '', runtime = {}) {
|
|
@@ -129,6 +129,15 @@ export async function apply(ctx, config) {
|
|
|
129
129
|
const registry = relay.tools
|
|
130
130
|
const tools = safeGet(ctx, 'tools')
|
|
131
131
|
const toolState = { registered: [], errors: [], hasTools: !!(tools && typeof tools.register === 'function') }
|
|
132
|
+
/* 会话模式锁(框架级强制):把本套件工具声明为 ppt 领域,注册时逐个挂 when
|
|
133
|
+
* 可见性条件,并装全局 guard 兜底。锁定其他领域的会话里,本套件工具从工具面消失
|
|
134
|
+
* 且被硬拒。toolHost/modeGate 缺席(老宿主)时优雅降级为不屏蔽。domain=cfg.ns
|
|
135
|
+
* 一处覆盖所有 bridge 套件,无需各 capability 文件自接。 */
|
|
136
|
+
const modeGate = toolHost && toolHost.modeGate
|
|
137
|
+
if (modeGate && registry && Array.isArray(registry.TOOLS)) {
|
|
138
|
+
modeGate.declareTools('ppt', registry.TOOLS.map((t) => t.name), 'ppt')
|
|
139
|
+
if (toolState.hasTools) modeGate.install(tools)
|
|
140
|
+
}
|
|
132
141
|
const OUTPUT_SCHEMA = { type: 'object', additionalProperties: true }
|
|
133
142
|
|
|
134
143
|
function toolText(value) {
|
|
@@ -147,6 +156,7 @@ export async function apply(ctx, config) {
|
|
|
147
156
|
if (registry && Array.isArray(registry.TOOLS) && toolState.hasTools) {
|
|
148
157
|
for (const tool of registry.TOOLS) {
|
|
149
158
|
try {
|
|
159
|
+
const when = modeGate && modeGate.whenFor(tool.name)
|
|
150
160
|
const dispose = tools.register({
|
|
151
161
|
name: tool.name,
|
|
152
162
|
description: tool.description,
|
|
@@ -159,7 +169,7 @@ export async function apply(ctx, config) {
|
|
|
159
169
|
* 「是哪个会话在调用」,多会话工作台才能把读写落到调用者自己那份文档上;
|
|
160
170
|
* 早期版本只接 args,工具只能猜用户正在看哪个窗口。 */
|
|
161
171
|
execute: async (args, exec) => registry.TOOL_IMPL[tool.name](args || {}, exec),
|
|
162
|
-
})
|
|
172
|
+
}, when ? { when } : {})
|
|
163
173
|
if (typeof dispose === 'function') disposers.push(dispose)
|
|
164
174
|
toolState.registered.push(tool.name)
|
|
165
175
|
} catch (error) {
|
|
@@ -111,7 +111,13 @@ export function createWorkbench(spec) {
|
|
|
111
111
|
* 已创建的资源——否则引擎/仓库泄漏在仍存活的进程里(reused 分支的 stop 是
|
|
112
112
|
* no-op,不会有人替它清理)。外部传入的 assetStore 不归本框架关。 */
|
|
113
113
|
let app
|
|
114
|
+
/* 资产仓库周期 GC:默认只清孤儿临时文件(安全——内容寻址资产被稿件引用,
|
|
115
|
+
* 按龄/LRU 淘汰会毁掉旧稿渲染,必须经 tuning 显式 opt-in)。定时器 unref,
|
|
116
|
+
* 不拖住进程退出;所有关闭路径都要清掉它。 */
|
|
117
|
+
let assetGcTimer = null
|
|
118
|
+
const stopAssetGc = () => { if (assetGcTimer) { clearInterval(assetGcTimer); assetGcTimer = null } }
|
|
114
119
|
const closeCreatedResources = async (why) => {
|
|
120
|
+
stopAssetGc()
|
|
115
121
|
try { if (spec.beforeStop) await spec.beforeStop(ctx) } catch (error) { console.error(`[${spec.id}] ${why}:beforeStop 失败`, error?.message || error) }
|
|
116
122
|
try { if (!givenAssetStore) await assetStore?.close?.() } catch (error) { console.error(`[${spec.id}] ${why}:assetStore 关闭失败`, error?.message || error) }
|
|
117
123
|
try { await store?.close?.() } catch (error) { console.error(`[${spec.id}] ${why}:store 关闭失败`, error?.message || error) }
|
|
@@ -213,6 +219,32 @@ export function createWorkbench(spec) {
|
|
|
213
219
|
}
|
|
214
220
|
}
|
|
215
221
|
|
|
222
|
+
/* 只有真正提供服务的形态才起周期 GC(reused 形态已回收资源,不起定时器)。
|
|
223
|
+
* tuning.assetGcIntervalMs<=0 可整体关闭;maxAgeMs/maxBytes 缺省 0=不按龄/量淘汰。 */
|
|
224
|
+
if (assetStore && typeof assetStore.gc === 'function') {
|
|
225
|
+
const gcIntervalMs = Number(tuning.assetGcIntervalMs ?? 3600000)
|
|
226
|
+
if (gcIntervalMs > 0) {
|
|
227
|
+
const gcOptions = {
|
|
228
|
+
maxAgeMs: Number(tuning.assetGcMaxAgeMs) || 0,
|
|
229
|
+
maxBytes: Number(tuning.assetGcMaxBytes) || 0,
|
|
230
|
+
}
|
|
231
|
+
const runGc = async () => {
|
|
232
|
+
try {
|
|
233
|
+
const result = await assetStore.gc(gcOptions)
|
|
234
|
+
if (result?.removed || result?.orphanTmpRemoved) {
|
|
235
|
+
console.log(`[${spec.id}] 资产 GC:清理 ${result.removed || 0} 项、孤儿临时文件 ${result.orphanTmpRemoved || 0} 个,释放 ${result.freedBytes || 0} 字节`)
|
|
236
|
+
}
|
|
237
|
+
} catch (error) {
|
|
238
|
+
console.error(`[${spec.id}] 资产 GC 失败(下轮再试):`, error?.message || error)
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
assetGcTimer = setInterval(runGc, gcIntervalMs)
|
|
242
|
+
assetGcTimer.unref?.()
|
|
243
|
+
/* 启动即跑一轮:清掉上次进程崩溃留下的孤儿 tmp,不必等第一个周期。 */
|
|
244
|
+
runGc()
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
216
248
|
try {
|
|
217
249
|
/* 业务钩子:设置 URL 环境变量、崩溃恢复等(必须在工具装载之前)。 */
|
|
218
250
|
if (spec.onListening) await spec.onListening(ctx, info, url)
|
|
@@ -255,12 +287,14 @@ export function createWorkbench(spec) {
|
|
|
255
287
|
tools: ctx.toolsRegistry || null,
|
|
256
288
|
...(spec.resultExtras ? spec.resultExtras(ctx) : {}),
|
|
257
289
|
stop: async () => {
|
|
290
|
+
stopAssetGc()
|
|
258
291
|
if (!ctx.embedded) removeDiscovery(hostDir)
|
|
259
292
|
if (spec.beforeStop) await spec.beforeStop(ctx)
|
|
260
293
|
await info.stop()
|
|
261
294
|
},
|
|
262
295
|
}
|
|
263
296
|
} catch (error) {
|
|
297
|
+
stopAssetGc()
|
|
264
298
|
try { if (!ctx.embedded) removeDiscovery(hostDir) } catch { /* 忽略 */ }
|
|
265
299
|
try { if (spec.beforeStop) await spec.beforeStop(ctx) } catch { /* 忽略 */ }
|
|
266
300
|
try { await info.stop() } catch { /* 忽略 */ }
|
|
@@ -61,21 +61,36 @@ function tokenMatches(expected, actual) {
|
|
|
61
61
|
|
|
62
62
|
const isLoopback = isLoopbackAddress
|
|
63
63
|
|
|
64
|
-
function jsonBody(req, limit = 8 * 1024 * 1024) {
|
|
64
|
+
function jsonBody(req, res, limit = 8 * 1024 * 1024) {
|
|
65
65
|
return new Promise((resolve, reject) => {
|
|
66
66
|
let size = 0
|
|
67
|
+
let aborted = false
|
|
67
68
|
const chunks = []
|
|
68
69
|
req.on('data', (chunk) => {
|
|
70
|
+
if (aborted) return
|
|
69
71
|
size += chunk.length
|
|
70
|
-
if (size > limit) {
|
|
72
|
+
if (size > limit) {
|
|
73
|
+
/* 先回 413 再处理连接:客户端要能区分「体太大」与「连接被莫名掐断」。
|
|
74
|
+
* 不能立刻 destroy——响应字节还没刷出去就断连,客户端只会看到 ECONNRESET。
|
|
75
|
+
* 这里回完 413 后把剩余请求体排空丢弃(有 8MB 上限兜底,量可控),
|
|
76
|
+
* 让响应干净送达;病态超长上传由服务器级请求超时兜底。 */
|
|
77
|
+
aborted = true
|
|
78
|
+
if (res && !res.headersSent && !res.writableEnded) {
|
|
79
|
+
send(res, 413, { ok: false, error: `请求体超过上限 ${limit} 字节` })
|
|
80
|
+
}
|
|
81
|
+
reject(new Error('body too large'))
|
|
82
|
+
req.resume()
|
|
83
|
+
return
|
|
84
|
+
}
|
|
71
85
|
chunks.push(chunk)
|
|
72
86
|
})
|
|
73
87
|
req.on('end', () => {
|
|
88
|
+
if (aborted) return
|
|
74
89
|
const raw = Buffer.concat(chunks).toString('utf8')
|
|
75
90
|
if (!raw) return resolve({})
|
|
76
91
|
try { resolve(JSON.parse(raw)) } catch { reject(new Error('bad json')) }
|
|
77
92
|
})
|
|
78
|
-
req.on('error', reject)
|
|
93
|
+
req.on('error', (err) => { if (!aborted) reject(err) })
|
|
79
94
|
})
|
|
80
95
|
}
|
|
81
96
|
|
|
@@ -132,13 +147,13 @@ export function createControlServer(engine, options = {}) {
|
|
|
132
147
|
}
|
|
133
148
|
|
|
134
149
|
if (route === 'POST /control/apply') {
|
|
135
|
-
const body = await jsonBody(req)
|
|
150
|
+
const body = await jsonBody(req, res)
|
|
136
151
|
const result = await engine.apply(body.commands || [], { waitMs: body.waitMs })
|
|
137
152
|
return send(res, result.ok ? 200 : 207, result)
|
|
138
153
|
}
|
|
139
154
|
|
|
140
155
|
if (route === 'POST /control/start') {
|
|
141
|
-
const body = await jsonBody(req)
|
|
156
|
+
const body = await jsonBody(req, res)
|
|
142
157
|
let spec = body.service
|
|
143
158
|
if (!spec && body.id && manifestPath && existsSync(manifestPath)) {
|
|
144
159
|
const manifest = JSON.parse(readFileSync(manifestPath, 'utf8'))
|
|
@@ -170,7 +185,7 @@ export function createControlServer(engine, options = {}) {
|
|
|
170
185
|
}
|
|
171
186
|
|
|
172
187
|
if (route === 'POST /control/stop') {
|
|
173
|
-
const body = await jsonBody(req)
|
|
188
|
+
const body = await jsonBody(req, res)
|
|
174
189
|
if (!body.id) return send(res, 400, { ok: false, error: '缺 id' })
|
|
175
190
|
return send(res, 200, await engine.stop(body.id))
|
|
176
191
|
}
|
|
@@ -183,7 +198,8 @@ export function createControlServer(engine, options = {}) {
|
|
|
183
198
|
|
|
184
199
|
send(res, 404, { ok: false, error: `未知端点 ${route}` })
|
|
185
200
|
} catch (err) {
|
|
186
|
-
|
|
201
|
+
/* jsonBody 超限时已回过 413 并断连,不能再往已结束的响应上写。 */
|
|
202
|
+
if (!res.headersSent && !res.writableEnded) send(res, 400, { ok: false, error: err.message })
|
|
187
203
|
}
|
|
188
204
|
})
|
|
189
205
|
// 供宿主打日志用:只暴露位置,不暴露 token 本身。
|
|
@@ -186,6 +186,10 @@ export class ServiceEngine {
|
|
|
186
186
|
this._unhealthy = new Map()
|
|
187
187
|
// 深探节流:id → 上次健康/工具探测时间。
|
|
188
188
|
this._lastProbe = new Map()
|
|
189
|
+
// 重启退避:id → 上次自动重启尝试时间(崩溃循环不再每 2s 硬拉一次)。
|
|
190
|
+
this._lastRestart = new Map()
|
|
191
|
+
// error 态恢复:id → { count, lastAt }(冷却指数翻倍,不再永久移出扫描)。
|
|
192
|
+
this._errorRetries = new Map()
|
|
189
193
|
// broker 自身的创建身份在本进程生命周期内不变;Windows 上 marker() 约 900ms,
|
|
190
194
|
// 每次 up 重算会白烧近 1 秒。null 时不缓存(瞬时查询失败可重试)。
|
|
191
195
|
this._brokerMarker = null
|
|
@@ -963,9 +967,10 @@ export class ServiceEngine {
|
|
|
963
967
|
maxUnhealthy = 3,
|
|
964
968
|
requireTools = true,
|
|
965
969
|
probeEveryMs = 15000,
|
|
970
|
+
errorRetryMs = 300000,
|
|
966
971
|
} = {}) {
|
|
967
972
|
if (this._guardTimer) return
|
|
968
|
-
this._guardConfig = { maxConsecutive, maxUnhealthy, requireTools, probeEveryMs }
|
|
973
|
+
this._guardConfig = { maxConsecutive, maxUnhealthy, requireTools, probeEveryMs, errorRetryMs }
|
|
969
974
|
this._guardTimer = setInterval(() => {
|
|
970
975
|
if (this._stopping || this._sweeping) return
|
|
971
976
|
this._sweeping = true
|
|
@@ -1048,6 +1053,13 @@ export class ServiceEngine {
|
|
|
1048
1053
|
cur[row.id] = { ...current, state: 'error', error: message }
|
|
1049
1054
|
await this._saveRegistry(cur)
|
|
1050
1055
|
})
|
|
1056
|
+
/* 冷却从「进入 error 态」起算,而不是从恢复尝试起算:否则 breaker 触发前的
|
|
1057
|
+
* 最后一次重启时间会被当成冷却起点,errorRetryMs 短于崩溃循环时长时,
|
|
1058
|
+
* 行刚变 error 就立刻被重试,冷却形同虚设。仅状态真的翻转时登记。 */
|
|
1059
|
+
const after = (await this._loadRegistry())[row.id]
|
|
1060
|
+
if (after?.state === 'error' && after.pid === row.pid && after.startedAt === row.startedAt) {
|
|
1061
|
+
this._errorRetries.set(row.id, { count: 0, lastAt: Date.now() })
|
|
1062
|
+
}
|
|
1051
1063
|
this.log(`✗ ${row.id} ${message}`)
|
|
1052
1064
|
}
|
|
1053
1065
|
|
|
@@ -1058,7 +1070,7 @@ export class ServiceEngine {
|
|
|
1058
1070
|
* 孤儿行)。只看 _owned 是历史故障的根因:服务被外部杀掉后行还在、_owned 里
|
|
1059
1071
|
* 没有它,于是 2s 一轮的守护永远跳过它,注册表一直写着 running 的假状态。 */
|
|
1060
1072
|
const rows = Object.values(services).filter((row) =>
|
|
1061
|
-
row.keepAlive && row.state === 'running'
|
|
1073
|
+
row.keepAlive && (row.state === 'running' || row.state === 'error')
|
|
1062
1074
|
&& (this._owned.has(row.id) || this._lastSpecs.has(row.id)))
|
|
1063
1075
|
/* 并行探测:一个服务探测慢/超时不能拖住其他服务的巡检。 */
|
|
1064
1076
|
await Promise.all(rows.map((row) => this._sweepOne(row, maxConsecutive).catch(() => {})))
|
|
@@ -1066,8 +1078,12 @@ export class ServiceEngine {
|
|
|
1066
1078
|
}
|
|
1067
1079
|
|
|
1068
1080
|
async _sweepOne(row, maxConsecutive) {
|
|
1081
|
+
/* error 态不是终点:带冷却地重试(见 _recoverError),不再永久移出扫描。 */
|
|
1082
|
+
if (row.state === 'error') return this._recoverError(row)
|
|
1069
1083
|
if (pidAlive(row.pid)) {
|
|
1070
|
-
|
|
1084
|
+
/* 注意:这里**不能**无条件清 _guardFailures——进程只要活过一个巡检间隔
|
|
1085
|
+
* 就把计数清零,「起-死-起」崩溃循环(活得比巡检间隔长)永远打不满熔断,
|
|
1086
|
+
* 变成无限重试。计数只在下方「稳定跑过一分钟」或手动 up 成功时翻篇。 */
|
|
1071
1087
|
/* 分两档节奏:
|
|
1072
1088
|
* - 存活检查每一轮都做(默认 2s 一轮)→ 进程一死,2s 内就重启;
|
|
1073
1089
|
* - 健康/工具深探按 probeEveryMs(默认 15s)做一次,避免频繁打 HTTP。
|
|
@@ -1082,7 +1098,11 @@ export class ServiceEngine {
|
|
|
1082
1098
|
/* "连续"重启次数:稳定跑过一分钟才算翻篇,避免“起-死-起”抖动
|
|
1083
1099
|
* 每次都把计数清零,最后无限重试。 */
|
|
1084
1100
|
const startedAt = Date.parse(row.startedAt || '') || 0
|
|
1085
|
-
if (startedAt && Date.now() - startedAt > 60_000)
|
|
1101
|
+
if (startedAt && Date.now() - startedAt > 60_000) {
|
|
1102
|
+
this._guardFailures.delete(row.id)
|
|
1103
|
+
this._errorRetries.delete(row.id)
|
|
1104
|
+
this._lastRestart.delete(row.id)
|
|
1105
|
+
}
|
|
1086
1106
|
return
|
|
1087
1107
|
}
|
|
1088
1108
|
const count = (this._unhealthy.get(row.id) || 0) + 1
|
|
@@ -1137,10 +1157,18 @@ export class ServiceEngine {
|
|
|
1137
1157
|
const failures = this._guardFailures.get(row.id) || 0
|
|
1138
1158
|
const spec = this._lastSpecs.get(row.id)
|
|
1139
1159
|
if (!spec) { await this._markError(row, '缺少重启规格,拒绝自动重启'); return }
|
|
1140
|
-
if (failures >= maxConsecutive) { await this._markError(row, '
|
|
1141
|
-
|
|
1160
|
+
if (failures >= maxConsecutive) { await this._markError(row, '连续重启次数超限,进入冷却(稍后自动重试)'); return }
|
|
1161
|
+
/* 重启退避:崩溃循环不能每 2s 硬拉一次,间隔随失败次数翻倍(2s→4s→8s…上限 60s)。 */
|
|
1162
|
+
const backoff = Math.min(2000 * 2 ** failures, 60_000)
|
|
1163
|
+
const lastRestart = this._lastRestart.get(row.id) || 0
|
|
1164
|
+
if (Date.now() - lastRestart < backoff) return
|
|
1165
|
+
this._lastRestart.set(row.id, Date.now())
|
|
1142
1166
|
try {
|
|
1143
1167
|
await this._upOnce(spec, {})
|
|
1168
|
+
/* 计数必须在重启**成功后**累加:_upOnce 的健康拉起路径会清 _guardFailures
|
|
1169
|
+
* (手动 up 语义=翻篇),守护重启若先加后清,崩溃循环永远打不满熔断。
|
|
1170
|
+
* 只有「稳定跑过 60s」或手动 up 才真正翻篇(见 _sweepOne)。 */
|
|
1171
|
+
this._guardFailures.set(row.id, failures + 1)
|
|
1144
1172
|
this.log(`↻ ${row.id} 已自动重启`)
|
|
1145
1173
|
} catch (err) {
|
|
1146
1174
|
await this._markError(row, `自动重启失败: ${err.message}`)
|
|
@@ -1148,6 +1176,32 @@ export class ServiceEngine {
|
|
|
1148
1176
|
})
|
|
1149
1177
|
}
|
|
1150
1178
|
|
|
1179
|
+
/** error 态恢复:冷却指数翻倍(默认 5min→10min→20min…上限 30min)后按规格重试。
|
|
1180
|
+
* _upOnce 自带仲裁——端口上已有健康实例就复用,不会双开;成功即回到 running,
|
|
1181
|
+
* 稳定跑过 60s 后冷却计数清零(见 _sweepOne)。没有重启规格的行无法自愈,留给手动 up。 */
|
|
1182
|
+
async _recoverError(row) {
|
|
1183
|
+
const cfg = this._guardConfig || {}
|
|
1184
|
+
const base = cfg.errorRetryMs ?? 300_000
|
|
1185
|
+
const retry = this._errorRetries.get(row.id) || { count: 0, lastAt: 0 }
|
|
1186
|
+
const cooldown = Math.min(base * 2 ** retry.count, 1_800_000)
|
|
1187
|
+
if (Date.now() - retry.lastAt < cooldown) return
|
|
1188
|
+
const spec = this._lastSpecs.get(row.id)
|
|
1189
|
+
if (!spec) return
|
|
1190
|
+
await this._withServiceLock(row.id, async () => {
|
|
1191
|
+
if (this._stopping) return
|
|
1192
|
+
this._errorRetries.set(row.id, { count: retry.count + 1, lastAt: Date.now() })
|
|
1193
|
+
/* error 恢复是新一轮:不背旧的连续重启计数。 */
|
|
1194
|
+
this._guardFailures.delete(row.id)
|
|
1195
|
+
this._unhealthy.delete(row.id)
|
|
1196
|
+
try {
|
|
1197
|
+
await this._upOnce(spec, {})
|
|
1198
|
+
this.log(`↻ ${row.id} 已从 error 态恢复(第 ${retry.count + 1} 次尝试)`)
|
|
1199
|
+
} catch (err) {
|
|
1200
|
+
this.log(`… ${row.id} error 恢复失败(第 ${retry.count + 1} 次尝试):${err.message},冷却后再试`)
|
|
1201
|
+
}
|
|
1202
|
+
})
|
|
1203
|
+
}
|
|
1204
|
+
|
|
1151
1205
|
/** 与服务级启动锁串行,避免与并发的 up/stop 交叉执行。 */
|
|
1152
1206
|
_withServiceLock(id, fn) {
|
|
1153
1207
|
const prev = this._upLocks.get(id) || Promise.resolve()
|
|
@@ -39,12 +39,18 @@ export function findSuiteRoot(startDir = path.dirname(PKG_DIR)) {
|
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
+
/** 读 JSON 并剥 UTF-8 BOM:带 BOM 的清单会让 JSON.parse 抛「Unexpected token」,
|
|
43
|
+
* 表现为 boot 永久失败且极难归因(文件看着完全正常)。统一在此剥掉。 */
|
|
44
|
+
function parseJsonFile(file) {
|
|
45
|
+
return JSON.parse(readFileSync(file, 'utf8').replace(/^\uFEFF/, ''))
|
|
46
|
+
}
|
|
47
|
+
|
|
42
48
|
/** 套件根判据:含 dsh-suite.json + services.json,且不是 broker 自带的 dsh-suite.json。 */
|
|
43
49
|
function isSuiteRoot(dir) {
|
|
44
50
|
const suiteFile = path.join(dir, 'dsh-suite.json')
|
|
45
51
|
if (!existsSync(suiteFile) || !existsSync(path.join(dir, 'services.json'))) return false
|
|
46
52
|
try {
|
|
47
|
-
const manifest =
|
|
53
|
+
const manifest = parseJsonFile(suiteFile)
|
|
48
54
|
return Boolean(manifest) && typeof manifest === 'object' && manifest.name !== 'dsh-service-broker-suite'
|
|
49
55
|
} catch {
|
|
50
56
|
return false
|
|
@@ -201,7 +207,7 @@ export function loadManifest(manifestPath) {
|
|
|
201
207
|
|
|
202
208
|
function loadFile(file) {
|
|
203
209
|
if (!existsSync(file)) return []
|
|
204
|
-
const raw =
|
|
210
|
+
const raw = parseJsonFile(file)
|
|
205
211
|
const services = Array.isArray(raw) ? raw : raw.services
|
|
206
212
|
if (!Array.isArray(services)) throw new Error(`manifest 格式非法(缺 services 数组): ${file}`)
|
|
207
213
|
const specErrors = validateServiceManifest(services, file)
|
|
@@ -245,5 +251,12 @@ function expandPackageDir(service, base) {
|
|
|
245
251
|
for (const key of ['url', 'cwd', 'logFile']) {
|
|
246
252
|
if (typeof out[key] === 'string') out[key] = String(out[key]).replaceAll('${PACKAGE_DIR}', base)
|
|
247
253
|
}
|
|
254
|
+
/* env 值同样展开 ${PACKAGE_DIR}:旧实现只展开 url/cwd/logFile,env 里引用
|
|
255
|
+
* ${PACKAGE_DIR} 的变量(如自定义数据目录/脚本路径)原样传给子进程 → 路径错。 */
|
|
256
|
+
for (const [key, value] of Object.entries(out.env)) {
|
|
257
|
+
if (typeof value === 'string' && value.includes('${PACKAGE_DIR}')) {
|
|
258
|
+
out.env[key] = value.replaceAll('${PACKAGE_DIR}', base)
|
|
259
|
+
}
|
|
260
|
+
}
|
|
248
261
|
return out
|
|
249
262
|
}
|
|
@@ -10,7 +10,12 @@ export function createSkillsClient(baseUrl) {
|
|
|
10
10
|
return {
|
|
11
11
|
api: { name: 'skills', version: '1.0.0', kind: 'thin-client' },
|
|
12
12
|
async list(signal) {
|
|
13
|
-
|
|
13
|
+
let res
|
|
14
|
+
try {
|
|
15
|
+
res = await fetch(`${root}/skills`, { signal: signal ?? AbortSignal.timeout(5000) })
|
|
16
|
+
} catch (error) {
|
|
17
|
+
throw new Error(`skills 服务不可达(${root}):${error.message}`, { cause: error })
|
|
18
|
+
}
|
|
14
19
|
if (!res.ok) throw new Error(`skills list HTTP ${res.status}`)
|
|
15
20
|
const body = await res.json()
|
|
16
21
|
return Array.isArray(body?.skills) ? body.skills : []
|
|
@@ -18,10 +23,17 @@ export function createSkillsClient(baseUrl) {
|
|
|
18
23
|
async get(candidate, options = {}) {
|
|
19
24
|
const name = typeof candidate === 'string' ? candidate : candidate?.name
|
|
20
25
|
if (!name) throw new Error('skills get: 缺 name')
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
26
|
+
let res
|
|
27
|
+
try {
|
|
28
|
+
res = await fetch(`${root}/skills/${encodeURIComponent(name)}`, {
|
|
29
|
+
signal: options.signal ?? AbortSignal.timeout(10000),
|
|
30
|
+
})
|
|
31
|
+
} catch (error) {
|
|
32
|
+
throw new Error(`skills 服务不可达(${root}):${error.message}`, { cause: error })
|
|
33
|
+
}
|
|
34
|
+
/* 只有 404 才是「未知 skill」;500/503 是服务端故障,不能误导成名字写错。 */
|
|
35
|
+
if (res.status === 404) throw new Error(`未知 skill ${name}(HTTP 404)`)
|
|
36
|
+
if (!res.ok) throw new Error(`skills get ${name} 失败(HTTP ${res.status},服务端错误)`)
|
|
25
37
|
return res.json()
|
|
26
38
|
},
|
|
27
39
|
}
|
|
@@ -211,7 +211,15 @@ export function createServiceApp(options = {}) {
|
|
|
211
211
|
if (req.method !== 'GET' && req.method !== 'HEAD') return false
|
|
212
212
|
if (cleanPrefix && u.pathname !== cleanPrefix && !u.pathname.startsWith(cleanPrefix + '/')) return false
|
|
213
213
|
const relRaw = cleanPrefix ? u.pathname.slice(cleanPrefix.length) : u.pathname
|
|
214
|
-
|
|
214
|
+
let rel
|
|
215
|
+
try {
|
|
216
|
+
rel = relRaw === '' || relRaw === '/' ? index : decodeURIComponent(relRaw.replace(/^\/+/, ''))
|
|
217
|
+
} catch {
|
|
218
|
+
/* 畸形百分号编码 → URIError,不包会冒成 500;客户端错误回 400。 */
|
|
219
|
+
res.writeHead(400, { 'content-type': 'text/plain; charset=utf-8' })
|
|
220
|
+
res.end(req.method === 'HEAD' ? undefined : 'malformed path encoding')
|
|
221
|
+
return true
|
|
222
|
+
}
|
|
215
223
|
let file = null
|
|
216
224
|
let type = mimeFor(rel)
|
|
217
225
|
if (files) {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "../capyclaw-suite-kit/suite.schema.json",
|
|
3
3
|
"name": "dsh-tool-host-suite",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.3.0",
|
|
5
5
|
"title": "Tool Host",
|
|
6
6
|
"description": "通用工具面:能力 DSL、注册表、校验、契约、MCP 壳、跨套件能力描述符注册/发现。",
|
|
7
7
|
"packages": {
|
|
8
8
|
"@capyclaw/tool-host": {
|
|
9
9
|
"role": "provider",
|
|
10
|
-
"version": "^0.
|
|
10
|
+
"version": "^0.3.0",
|
|
11
11
|
"path": ".",
|
|
12
12
|
"provides": {
|
|
13
13
|
"services": [
|