@wirecat/wordpress-cli 0.0.0-stage → 0.1.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/CHANGELOG.md +27 -0
- package/LICENSE +204 -0
- package/README.md +248 -2
- package/contracts/wirecat.json +2535 -0
- package/dist/bin/wordpress.d.ts +3 -0
- package/dist/bin/wordpress.d.ts.map +1 -0
- package/dist/bin/wordpress.js +40 -0
- package/dist/bin/wordpress.js.map +1 -0
- package/dist/bundle/agent-LKBRYKNB.js +37 -0
- package/dist/bundle/all-profiles-OEV7VFQG.js +320 -0
- package/dist/bundle/anthropic-JKTZP2DW.js +91 -0
- package/dist/bundle/app-server-7LWLDDE2.js +249 -0
- package/dist/bundle/bun-2FLR4IV4.js +169 -0
- package/dist/bundle/bun-sqlite-GRSRX5P4.js +76 -0
- package/dist/bundle/chunk-2BI25SEE.js +259 -0
- package/dist/bundle/chunk-2UEGJ5AJ.js +52 -0
- package/dist/bundle/chunk-2XUV7HNE.js +58 -0
- package/dist/bundle/chunk-2Z7UOXFC.js +16 -0
- package/dist/bundle/chunk-3BM6KBWP.js +2788 -0
- package/dist/bundle/chunk-3BRAZVHR.js +1010 -0
- package/dist/bundle/chunk-3LMW7U7F.js +1233 -0
- package/dist/bundle/chunk-3LVTQFGB.js +2000 -0
- package/dist/bundle/chunk-3TKFFSFU.js +106 -0
- package/dist/bundle/chunk-3UX4VJWD.js +78 -0
- package/dist/bundle/chunk-4HEXAGKT.js +334 -0
- package/dist/bundle/chunk-4HP6KGBI.js +32 -0
- package/dist/bundle/chunk-4ZAQMDLD.js +1308 -0
- package/dist/bundle/chunk-4ZTB7LS3.js +87 -0
- package/dist/bundle/chunk-5XPHFV7H.js +2333 -0
- package/dist/bundle/chunk-5Z3P543G.js +80 -0
- package/dist/bundle/chunk-6UYDKCV6.js +794 -0
- package/dist/bundle/chunk-7GNB4LBX.js +50 -0
- package/dist/bundle/chunk-7HJFBOAT.js +161 -0
- package/dist/bundle/chunk-7JVKQ6NM.js +206 -0
- package/dist/bundle/chunk-7QH5BZUG.js +142 -0
- package/dist/bundle/chunk-A474OVIW.js +1392 -0
- package/dist/bundle/chunk-AENEMQL3.js +1068 -0
- package/dist/bundle/chunk-AL7I4DT4.js +65718 -0
- package/dist/bundle/chunk-ARGRGTPX.js +108 -0
- package/dist/bundle/chunk-AV2ZJ4WX.js +7 -0
- package/dist/bundle/chunk-BAXNAOOL.js +76 -0
- package/dist/bundle/chunk-BH63B66W.js +407 -0
- package/dist/bundle/chunk-CCOSG3F2.js +24616 -0
- package/dist/bundle/chunk-CFQQTDSA.js +46 -0
- package/dist/bundle/chunk-CGCUOT67.js +388 -0
- package/dist/bundle/chunk-CHPWBQUK.js +39 -0
- package/dist/bundle/chunk-D72URWJE.js +532 -0
- package/dist/bundle/chunk-DFDN6AUB.js +21 -0
- package/dist/bundle/chunk-DQSOYH6N.js +20 -0
- package/dist/bundle/chunk-ECYOTDJM.js +14 -0
- package/dist/bundle/chunk-EH6ZEJGT.js +932 -0
- package/dist/bundle/chunk-EHW45LLT.js +100 -0
- package/dist/bundle/chunk-F3AV5ZSL.js +338 -0
- package/dist/bundle/chunk-F4BX7TH2.js +15 -0
- package/dist/bundle/chunk-F5ZAN7OC.js +6848 -0
- package/dist/bundle/chunk-FMMYBVCH.js +38 -0
- package/dist/bundle/chunk-FNB4SWTY.js +66 -0
- package/dist/bundle/chunk-FQROWBKV.js +12660 -0
- package/dist/bundle/chunk-FV2HJOSC.js +771 -0
- package/dist/bundle/chunk-GCAJW4SR.js +53 -0
- package/dist/bundle/chunk-GPRJXJC7.js +102 -0
- package/dist/bundle/chunk-HCOZUOSN.js +54 -0
- package/dist/bundle/chunk-HM6AMYHR.js +72 -0
- package/dist/bundle/chunk-HVXOA4FO.js +23 -0
- package/dist/bundle/chunk-HWQ7572G.js +95 -0
- package/dist/bundle/chunk-IJVTN5L3.js +82 -0
- package/dist/bundle/chunk-IZDDBOHU.js +3610 -0
- package/dist/bundle/chunk-JAE5B4G7.js +388 -0
- package/dist/bundle/chunk-K2Y5K37O.js +218 -0
- package/dist/bundle/chunk-KCH224US.js +9581 -0
- package/dist/bundle/chunk-KZJQPJK5.js +230 -0
- package/dist/bundle/chunk-L7P3LUDQ.js +286 -0
- package/dist/bundle/chunk-LECMHK2F.js +18 -0
- package/dist/bundle/chunk-LWEMZJLG.js +1332 -0
- package/dist/bundle/chunk-LWTETL2O.js +185 -0
- package/dist/bundle/chunk-MEYYH47C.js +25 -0
- package/dist/bundle/chunk-MJ6LTG4L.js +170 -0
- package/dist/bundle/chunk-NMQRSEZM.js +37 -0
- package/dist/bundle/chunk-ODVGFCBE.js +557 -0
- package/dist/bundle/chunk-OEQNP56V.js +633 -0
- package/dist/bundle/chunk-OV6WQY3L.js +39 -0
- package/dist/bundle/chunk-PL5P7UKW.js +25216 -0
- package/dist/bundle/chunk-PPNTY7LD.js +733 -0
- package/dist/bundle/chunk-PRZYRA66.js +358 -0
- package/dist/bundle/chunk-PV5UYGRJ.js +41594 -0
- package/dist/bundle/chunk-QYTOLPNI.js +52 -0
- package/dist/bundle/chunk-R7Y3XU66.js +362 -0
- package/dist/bundle/chunk-S4UUN6LD.js +1410 -0
- package/dist/bundle/chunk-SD5CXGIG.js +188 -0
- package/dist/bundle/chunk-SXY5G62I.js +288 -0
- package/dist/bundle/chunk-T37TAXVL.js +29 -0
- package/dist/bundle/chunk-T5SOY3AE.js +1197 -0
- package/dist/bundle/chunk-TJ7OORSO.js +1876 -0
- package/dist/bundle/chunk-TRYYWV7J.js +291 -0
- package/dist/bundle/chunk-U6VLNYCO.js +73 -0
- package/dist/bundle/chunk-UC7JLE6J.js +58 -0
- package/dist/bundle/chunk-UUIOAZPH.js +156 -0
- package/dist/bundle/chunk-UXQ24OY6.js +4072 -0
- package/dist/bundle/chunk-VBRRMGON.js +1007 -0
- package/dist/bundle/chunk-VRIBES2C.js +319 -0
- package/dist/bundle/chunk-XFLCVHSQ.js +50 -0
- package/dist/bundle/chunk-XT5XYQEZ.js +3414 -0
- package/dist/bundle/chunk-XTAS5Z3G.js +2231 -0
- package/dist/bundle/chunk-XYQVVW4R.js +24 -0
- package/dist/bundle/chunk-Y5E2WNWB.js +35 -0
- package/dist/bundle/chunk-YHWFF6DN.js +39 -0
- package/dist/bundle/chunk-YUDVRFXN.js +63 -0
- package/dist/bundle/chunk-Z3I2MCUT.js +131 -0
- package/dist/bundle/chunk-ZDI3WC7V.js +353 -0
- package/dist/bundle/chunk-ZVQ7KFMT.js +274 -0
- package/dist/bundle/chunk-ZVVMGPBJ.js +50 -0
- package/dist/bundle/command-contract-P7YE4EKS.js +37 -0
- package/dist/bundle/command-server-entry-XIMCBWMV.js +166 -0
- package/dist/bundle/decode-6XK55WYV.js +297 -0
- package/dist/bundle/definitions-GIQCGYPR.js +7986 -0
- package/dist/bundle/dispatch-JQBAZWCL.js +411 -0
- package/dist/bundle/dist-2TV3NVE5.js +7577 -0
- package/dist/bundle/dist-PAKDDIBT.js +191 -0
- package/dist/bundle/echarts-YRRVLEX3.js +42501 -0
- package/dist/bundle/embed-L3EEQSGX.js +38 -0
- package/dist/bundle/embedder-BIKLBV3J.js +111 -0
- package/dist/bundle/failure-I6AAF5R5.js +25 -0
- package/dist/bundle/first-run-W6G6TYZ2.js +29 -0
- package/dist/bundle/first-screen-ITIAJIBU.js +37 -0
- package/dist/bundle/hast-util-from-html-ZHU6HGIE.js +10531 -0
- package/dist/bundle/hast-util-to-html-IIFHILP5.js +998 -0
- package/dist/bundle/hast-util-to-mdast-D62XX3NR.js +2272 -0
- package/dist/bundle/instructions-AG7SRWTR.js +11 -0
- package/dist/bundle/mcp-YGOAUNC3.js +167 -0
- package/dist/bundle/mdast-util-from-markdown-WVUJDSUO.js +1900 -0
- package/dist/bundle/mdast-util-gfm-KN2D32QS.js +1040 -0
- package/dist/bundle/mdast-util-to-hast-AYJV7KAE.js +879 -0
- package/dist/bundle/mdast-util-to-markdown-UCAJNHJO.js +18 -0
- package/dist/bundle/meeting-combined-CQJ3JHHU.js +24 -0
- package/dist/bundle/meeting-model-MZ7VVBNK.js +25 -0
- package/dist/bundle/meeting-semantic-DADWRRHP.js +22 -0
- package/dist/bundle/micromark-extension-gfm-EEJRRJ36.js +1771 -0
- package/dist/bundle/node-GJQYN4FT.js +176 -0
- package/dist/bundle/node-JJ3WDCNJ.js +2340 -0
- package/dist/bundle/node-TLZSIHIJ.js +21 -0
- package/dist/bundle/node-sqlite-TPR62DT2.js +74 -0
- package/dist/bundle/oauth-WGY7JQVW.js +20 -0
- package/dist/bundle/open-DE7QZNAN.js +23 -0
- package/dist/bundle/openai-NHEFT3HS.js +238 -0
- package/dist/bundle/process-MEKCZMX3.js +91 -0
- package/dist/bundle/program-EP2S5BTM.js +38857 -0
- package/dist/bundle/prompt-PWY53BYH.js +17 -0
- package/dist/bundle/recognize-74TXHKMQ.js +26 -0
- package/dist/bundle/remote-F5TJZ5ER.js +31 -0
- package/dist/bundle/rerank-HWUO52UF.js +52 -0
- package/dist/bundle/schemas-4K6WWS5N.js +2157 -0
- package/dist/bundle/serve-I2USUY4X.js +199 -0
- package/dist/bundle/server-GDYDNO6K.js +79 -0
- package/dist/bundle/server-KYUW2AHB.js +212 -0
- package/dist/bundle/sqlite-runtime-N6VFGBJK.js +20 -0
- package/dist/bundle/state-L6JSCN77.js +36 -0
- package/dist/bundle/store-EPG2YPN3.js +291 -0
- package/dist/bundle/store-SQWQJE32.js +181 -0
- package/dist/bundle/store-maintenance-command-FTGSICVA.js +66 -0
- package/dist/bundle/surface-SNMHY6GP.js +65 -0
- package/dist/bundle/wordpress.js +183 -0
- package/dist/commands/api.d.ts +22 -0
- package/dist/commands/api.d.ts.map +1 -0
- package/dist/commands/api.js +37 -0
- package/dist/commands/api.js.map +1 -0
- package/dist/commands/content.d.ts +4 -0
- package/dist/commands/content.d.ts.map +1 -0
- package/dist/commands/content.js +94 -0
- package/dist/commands/content.js.map +1 -0
- package/dist/commands/session.d.ts +8 -0
- package/dist/commands/session.d.ts.map +1 -0
- package/dist/commands/session.js +28 -0
- package/dist/commands/session.js.map +1 -0
- package/dist/config.d.ts +13 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +69 -0
- package/dist/config.js.map +1 -0
- package/dist/context.d.ts +37 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +31 -0
- package/dist/context.js.map +1 -0
- package/dist/generated/definitions.d.ts +3 -0
- package/dist/generated/definitions.d.ts.map +1 -0
- package/dist/generated/definitions.js +7982 -0
- package/dist/generated/definitions.js.map +1 -0
- package/dist/generated/manifest.d.ts +6 -0
- package/dist/generated/manifest.d.ts.map +1 -0
- package/dist/generated/manifest.js +8830 -0
- package/dist/generated/manifest.js.map +1 -0
- package/dist/generated/schemas.d.ts +229 -0
- package/dist/generated/schemas.d.ts.map +1 -0
- package/dist/generated/schemas.js +2019 -0
- package/dist/generated/schemas.js.map +1 -0
- package/dist/generated/types.d.ts +3365 -0
- package/dist/generated/types.d.ts.map +1 -0
- package/dist/generated/types.js +5 -0
- package/dist/generated/types.js.map +1 -0
- package/dist/generated/wirecat-config.d.ts +11 -0
- package/dist/generated/wirecat-config.d.ts.map +1 -0
- package/dist/generated/wirecat-config.js +337 -0
- package/dist/generated/wirecat-config.js.map +1 -0
- package/dist/identity.d.ts +28 -0
- package/dist/identity.d.ts.map +1 -0
- package/dist/identity.js +29 -0
- package/dist/identity.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/program.d.ts +6 -0
- package/dist/program.d.ts.map +1 -0
- package/dist/program.js +53 -0
- package/dist/program.js.map +1 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +2 -0
- package/dist/version.js.map +1 -0
- package/dist/wcat.d.ts +3 -0
- package/dist/wcat.d.ts.map +1 -0
- package/dist/wcat.js +4 -0
- package/dist/wcat.js.map +1 -0
- package/package.json +87 -4
- package/skills/wordpress-cli/SKILL.md +88 -0
- package/skills/wordpress-cli/references/api/api-block-directory.md +17 -0
- package/skills/wordpress-cli/references/api/api-block-patterns.md +13 -0
- package/skills/wordpress-cli/references/api/api-block-types.md +34 -0
- package/skills/wordpress-cli/references/api/api-blocks.md +159 -0
- package/skills/wordpress-cli/references/api/api-categories.md +69 -0
- package/skills/wordpress-cli/references/api/api-comments.md +79 -0
- package/skills/wordpress-cli/references/api/api-font-collections.md +16 -0
- package/skills/wordpress-cli/references/api/api-font-families.md +122 -0
- package/skills/wordpress-cli/references/api/api-global-styles.md +29 -0
- package/skills/wordpress-cli/references/api/api-media.md +106 -0
- package/skills/wordpress-cli/references/api/api-menu-items.md +115 -0
- package/skills/wordpress-cli/references/api/api-menu-locations.md +22 -0
- package/skills/wordpress-cli/references/api/api-menus.md +69 -0
- package/skills/wordpress-cli/references/api/api-navigation.md +155 -0
- package/skills/wordpress-cli/references/api/api-pages.md +161 -0
- package/skills/wordpress-cli/references/api/api-pattern-directory.md +23 -0
- package/skills/wordpress-cli/references/api/api-plugins.md +25 -0
- package/skills/wordpress-cli/references/api/api-posts.md +166 -0
- package/skills/wordpress-cli/references/api/api-search.md +21 -0
- package/skills/wordpress-cli/references/api/api-settings.md +19 -0
- package/skills/wordpress-cli/references/api/api-sidebars.md +34 -0
- package/skills/wordpress-cli/references/api/api-statuses.md +22 -0
- package/skills/wordpress-cli/references/api/api-tags.md +69 -0
- package/skills/wordpress-cli/references/api/api-taxonomies.md +23 -0
- package/skills/wordpress-cli/references/api/api-template-parts.md +38 -0
- package/skills/wordpress-cli/references/api/api-templates.md +38 -0
- package/skills/wordpress-cli/references/api/api-themes.md +12 -0
- package/skills/wordpress-cli/references/api/api-types.md +22 -0
- package/skills/wordpress-cli/references/api/api-users.md +149 -0
- package/skills/wordpress-cli/references/api/api-widget-types.md +46 -0
- package/skills/wordpress-cli/references/api/api-widgets.md +57 -0
- package/skills/wordpress-cli/references/api/api-wp-pattern-category.md +69 -0
- package/skills/wordpress-cli/references/api.md +44 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wordpress.d.ts","sourceRoot":"","sources":["../../src/bin/wordpress.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// cli-dev bundle loader
|
|
3
|
+
import * as module from "node:module"
|
|
4
|
+
|
|
5
|
+
const words = process.argv.slice(2)
|
|
6
|
+
// As the CLI answers it, unless a test records the argv: then the CLI writes the record too.
|
|
7
|
+
if (
|
|
8
|
+
words.length === 1 &&
|
|
9
|
+
(words[0] === "--version" || words[0] === "-V") &&
|
|
10
|
+
!Object.keys(process.env).some((key) => key.endsWith("_TEST_ARGV_LOG"))
|
|
11
|
+
) {
|
|
12
|
+
process.stdout.write("0.1.0\n")
|
|
13
|
+
} else {
|
|
14
|
+
// Before the bundle compiles: the bundle's own call comes after its chunks.
|
|
15
|
+
module.enableCompileCache()
|
|
16
|
+
const serves = ((words) => {
|
|
17
|
+
const plain = words.filter((word) => !word.startsWith("-"));
|
|
18
|
+
return plain
|
|
19
|
+
.slice(0, 4)
|
|
20
|
+
.some((word, at) => word === "serve" || word === "watch" || (word === "mcp" && plain[at + 1] === undefined));
|
|
21
|
+
})(words)
|
|
22
|
+
if (serves && module.registerHooks) {
|
|
23
|
+
const bundle = new URL("../bundle/", import.meta.url).href
|
|
24
|
+
module.registerHooks({
|
|
25
|
+
resolve: (specifier, context, next) =>
|
|
26
|
+
specifier.startsWith("./") && context.parentURL?.startsWith(bundle)
|
|
27
|
+
? { url: new URL(specifier, context.parentURL).href, format: "module", shortCircuit: true }
|
|
28
|
+
: next(specifier, context),
|
|
29
|
+
})
|
|
30
|
+
}
|
|
31
|
+
const chunks = ["../bundle/agent-LKBRYKNB.js","../bundle/all-profiles-OEV7VFQG.js","../bundle/anthropic-JKTZP2DW.js","../bundle/app-server-7LWLDDE2.js","../bundle/bun-2FLR4IV4.js","../bundle/bun-sqlite-GRSRX5P4.js","../bundle/decode-6XK55WYV.js","../bundle/definitions-GIQCGYPR.js","../bundle/dispatch-JQBAZWCL.js","../bundle/dist-2TV3NVE5.js","../bundle/dist-PAKDDIBT.js","../bundle/echarts-YRRVLEX3.js","../bundle/embed-L3EEQSGX.js","../bundle/embedder-BIKLBV3J.js","../bundle/failure-I6AAF5R5.js","../bundle/first-screen-ITIAJIBU.js","../bundle/hast-util-from-html-ZHU6HGIE.js","../bundle/hast-util-to-html-IIFHILP5.js","../bundle/hast-util-to-mdast-D62XX3NR.js","../bundle/instructions-AG7SRWTR.js","../bundle/mcp-YGOAUNC3.js","../bundle/mdast-util-from-markdown-WVUJDSUO.js","../bundle/mdast-util-gfm-KN2D32QS.js","../bundle/mdast-util-to-hast-AYJV7KAE.js","../bundle/mdast-util-to-markdown-UCAJNHJO.js","../bundle/micromark-extension-gfm-EEJRRJ36.js","../bundle/node-GJQYN4FT.js","../bundle/node-JJ3WDCNJ.js","../bundle/node-TLZSIHIJ.js","../bundle/node-sqlite-TPR62DT2.js","../bundle/oauth-WGY7JQVW.js","../bundle/open-DE7QZNAN.js","../bundle/openai-NHEFT3HS.js","../bundle/process-MEKCZMX3.js","../bundle/program-EP2S5BTM.js","../bundle/prompt-PWY53BYH.js","../bundle/recognize-74TXHKMQ.js","../bundle/remote-F5TJZ5ER.js","../bundle/rerank-HWUO52UF.js","../bundle/schemas-4K6WWS5N.js","../bundle/serve-I2USUY4X.js","../bundle/server-GDYDNO6K.js","../bundle/server-KYUW2AHB.js","../bundle/sqlite-runtime-N6VFGBJK.js","../bundle/state-L6JSCN77.js","../bundle/store-EPG2YPN3.js","../bundle/store-SQWQJE32.js","../bundle/store-maintenance-command-FTGSICVA.js","../bundle/surface-SNMHY6GP.js"]
|
|
32
|
+
if (((words) => words
|
|
33
|
+
.filter((word) => !word.startsWith("-"))
|
|
34
|
+
.slice(0, 2)
|
|
35
|
+
.includes("upgrade"))(words)) await Promise.allSettled(chunks.map((chunk) => import(chunk)))
|
|
36
|
+
const running = import("../bundle/wordpress.js")
|
|
37
|
+
// After the server answers its first request, so it starts no later.
|
|
38
|
+
if (serves) setTimeout(() => void Promise.allSettled(chunks.map((chunk) => import(chunk))), 2000).unref()
|
|
39
|
+
await running
|
|
40
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wordpress.js","sourceRoot":"","sources":["../../src/bin/wordpress.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAA;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAExC,kBAAkB,EAAE,CAAA;AACpB,oGAAoG;AACpG,MAAM,YAAY,GAAG,YAAY,CAAC,EAAE,GAAG,EAAE,OAAO,CAAC,OAAO,EAAE,WAAW,EAAE,OAAO,CAAC,MAAM,CAAC,KAAK,KAAK,IAAI,EAAE,CAAC,CAAA;AACvG,MAAM,IAAI,GAAG,MAAM,SAAS,CAAC,OAAO,CAAC,CAAA;AACrC,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;IAC5B,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAA;AAC9B,CAAC;KAAM,CAAC;IACN,MAAM,EAAE,GAAG,EAAE,GAAG,MAAM,MAAM,CAAC,eAAe,CAAC,CAAA;IAC7C,OAAO,CAAC,QAAQ,GAAG,MAAM,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;AACrD,CAAC;AACD,YAAY,EAAE,CAAA"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
+
const require = __bundleRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
runCommandForAgent,
|
|
5
|
+
toolsFromCommands
|
|
6
|
+
} from "./chunk-IZDDBOHU.js";
|
|
7
|
+
import "./chunk-7GNB4LBX.js";
|
|
8
|
+
import "./chunk-F3AV5ZSL.js";
|
|
9
|
+
import "./chunk-ARGRGTPX.js";
|
|
10
|
+
import "./chunk-PPNTY7LD.js";
|
|
11
|
+
import "./chunk-PL5P7UKW.js";
|
|
12
|
+
import "./chunk-FQROWBKV.js";
|
|
13
|
+
import "./chunk-R7Y3XU66.js";
|
|
14
|
+
import "./chunk-2UEGJ5AJ.js";
|
|
15
|
+
import "./chunk-4HEXAGKT.js";
|
|
16
|
+
import "./chunk-YUDVRFXN.js";
|
|
17
|
+
import "./chunk-FNB4SWTY.js";
|
|
18
|
+
import "./chunk-5Z3P543G.js";
|
|
19
|
+
import "./chunk-3LVTQFGB.js";
|
|
20
|
+
import "./chunk-UUIOAZPH.js";
|
|
21
|
+
import "./chunk-T37TAXVL.js";
|
|
22
|
+
import "./chunk-UXQ24OY6.js";
|
|
23
|
+
import "./chunk-AV2ZJ4WX.js";
|
|
24
|
+
import "./chunk-JAE5B4G7.js";
|
|
25
|
+
import "./chunk-T5SOY3AE.js";
|
|
26
|
+
import "./chunk-ZVQ7KFMT.js";
|
|
27
|
+
import "./chunk-HCOZUOSN.js";
|
|
28
|
+
import "./chunk-3BM6KBWP.js";
|
|
29
|
+
import "./chunk-3LMW7U7F.js";
|
|
30
|
+
import "./chunk-S4UUN6LD.js";
|
|
31
|
+
import "./chunk-Y5E2WNWB.js";
|
|
32
|
+
import "./chunk-HM6AMYHR.js";
|
|
33
|
+
import "./chunk-ZVVMGPBJ.js";
|
|
34
|
+
export {
|
|
35
|
+
runCommandForAgent,
|
|
36
|
+
toolsFromCommands
|
|
37
|
+
};
|
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
+
const require = __bundleRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
StdioServerTransport,
|
|
5
|
+
answeredWire,
|
|
6
|
+
serveStdio
|
|
7
|
+
} from "./chunk-OEQNP56V.js";
|
|
8
|
+
import {
|
|
9
|
+
CALLER_META_KEY,
|
|
10
|
+
PROXY_CLIENT_NAME,
|
|
11
|
+
callerOf
|
|
12
|
+
} from "./chunk-ARGRGTPX.js";
|
|
13
|
+
import {
|
|
14
|
+
InMemoryTransport,
|
|
15
|
+
McpServer
|
|
16
|
+
} from "./chunk-PL5P7UKW.js";
|
|
17
|
+
import "./chunk-R7Y3XU66.js";
|
|
18
|
+
import "./chunk-UUIOAZPH.js";
|
|
19
|
+
import "./chunk-AV2ZJ4WX.js";
|
|
20
|
+
import "./chunk-3BM6KBWP.js";
|
|
21
|
+
import {
|
|
22
|
+
errorObjectOf,
|
|
23
|
+
mcpErrorResult
|
|
24
|
+
} from "./chunk-3LMW7U7F.js";
|
|
25
|
+
import "./chunk-S4UUN6LD.js";
|
|
26
|
+
import "./chunk-Y5E2WNWB.js";
|
|
27
|
+
import {
|
|
28
|
+
CliError
|
|
29
|
+
} from "./chunk-HM6AMYHR.js";
|
|
30
|
+
import {
|
|
31
|
+
__name
|
|
32
|
+
} from "./chunk-ZVVMGPBJ.js";
|
|
33
|
+
|
|
34
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.707.0_@wirecat+cli-base@0.124.0_commander@15.0.0_esbuild@0.28.2_typ_1ab7200af0919d16d129ae0ece32d37f/node_modules/@wirecat/cli-core/dist/mcp/all-profiles.js
|
|
35
|
+
import { spawn } from "node:child_process";
|
|
36
|
+
import { randomUUID } from "node:crypto";
|
|
37
|
+
var PROTOCOL = "2025-06-18";
|
|
38
|
+
var START_MS = 3e4;
|
|
39
|
+
var CHILD_IDLE_MS = 10 * 60 * 1e3;
|
|
40
|
+
var startChild = /* @__PURE__ */ __name((spec, note, onExit) => {
|
|
41
|
+
const child = spawn(spec.command, spec.args, { env: spec.env, stdio: "pipe" });
|
|
42
|
+
const pending = /* @__PURE__ */ new Map();
|
|
43
|
+
let next = 1;
|
|
44
|
+
let buffer = "";
|
|
45
|
+
let gone;
|
|
46
|
+
const fail = /* @__PURE__ */ __name((error) => {
|
|
47
|
+
gone ??= error;
|
|
48
|
+
for (const waiter of pending.values())
|
|
49
|
+
waiter.reject(error);
|
|
50
|
+
pending.clear();
|
|
51
|
+
}, "fail");
|
|
52
|
+
child.on("error", () => fail(new Error("the profile's MCP server could not be started")));
|
|
53
|
+
child.on("exit", () => {
|
|
54
|
+
fail(new Error("the profile's MCP server stopped"));
|
|
55
|
+
onExit();
|
|
56
|
+
});
|
|
57
|
+
child.stdin.on("error", () => fail(new Error("the profile's MCP server closed its input")));
|
|
58
|
+
child.stderr.setEncoding("utf8");
|
|
59
|
+
let errors = "";
|
|
60
|
+
child.stderr.on("data", (chunk) => {
|
|
61
|
+
const lines = (errors + chunk).split("\n");
|
|
62
|
+
errors = lines.pop() ?? "";
|
|
63
|
+
for (const line of lines)
|
|
64
|
+
if (line.trim())
|
|
65
|
+
note(line);
|
|
66
|
+
});
|
|
67
|
+
child.stdout.setEncoding("utf8");
|
|
68
|
+
child.stdout.on("data", (chunk) => {
|
|
69
|
+
buffer += chunk;
|
|
70
|
+
for (let at = buffer.indexOf("\n"); at !== -1; at = buffer.indexOf("\n")) {
|
|
71
|
+
const line = buffer.slice(0, at);
|
|
72
|
+
buffer = buffer.slice(at + 1);
|
|
73
|
+
let message;
|
|
74
|
+
try {
|
|
75
|
+
message = JSON.parse(line);
|
|
76
|
+
} catch {
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
if (message.method !== void 0 && message.id !== void 0) {
|
|
80
|
+
send({ id: message.id, error: { code: -32601, message: "not offered through the all-profiles server" } });
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
if (typeof message.id !== "number")
|
|
84
|
+
continue;
|
|
85
|
+
const waiter = pending.get(message.id);
|
|
86
|
+
if (!waiter)
|
|
87
|
+
continue;
|
|
88
|
+
pending.delete(message.id);
|
|
89
|
+
if (message.error)
|
|
90
|
+
waiter.reject(new Error(message.error.message ?? "the profile's MCP server refused"));
|
|
91
|
+
else
|
|
92
|
+
waiter.resolve(message.result ?? {});
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
const send = /* @__PURE__ */ __name((message) => child.stdin.write(`${JSON.stringify({ jsonrpc: "2.0", ...message })}
|
|
96
|
+
`), "send");
|
|
97
|
+
const request = /* @__PURE__ */ __name((method, params) => new Promise((resolve, reject) => {
|
|
98
|
+
if (gone)
|
|
99
|
+
return reject(gone);
|
|
100
|
+
const id = next++;
|
|
101
|
+
pending.set(id, { resolve, reject });
|
|
102
|
+
send({ id, method, params });
|
|
103
|
+
}), "request");
|
|
104
|
+
const close = /* @__PURE__ */ __name(() => new Promise((resolve) => {
|
|
105
|
+
if (child.exitCode !== null || child.signalCode !== null)
|
|
106
|
+
return resolve();
|
|
107
|
+
child.once("exit", () => resolve());
|
|
108
|
+
child.stdin.end();
|
|
109
|
+
}), "close");
|
|
110
|
+
const timer = setTimeout(() => fail(new Error("the profile's MCP server did not answer in time")), START_MS);
|
|
111
|
+
return request("initialize", {
|
|
112
|
+
protocolVersion: PROTOCOL,
|
|
113
|
+
capabilities: {},
|
|
114
|
+
clientInfo: { name: PROXY_CLIENT_NAME, version: "1" }
|
|
115
|
+
}).then(() => {
|
|
116
|
+
send({ method: "notifications/initialized" });
|
|
117
|
+
return { request, close };
|
|
118
|
+
}).catch(async (error) => {
|
|
119
|
+
await close();
|
|
120
|
+
throw error;
|
|
121
|
+
}).finally(() => clearTimeout(timer));
|
|
122
|
+
}, "startChild");
|
|
123
|
+
var pool = /* @__PURE__ */ __name((options) => {
|
|
124
|
+
const idleMs = options.idleMs ?? CHILD_IDLE_MS;
|
|
125
|
+
const note = options.note ?? (() => {
|
|
126
|
+
});
|
|
127
|
+
const running = /* @__PURE__ */ new Map();
|
|
128
|
+
const forget = /* @__PURE__ */ __name((profile, child) => {
|
|
129
|
+
const one = running.get(profile);
|
|
130
|
+
if (one?.child !== child)
|
|
131
|
+
return;
|
|
132
|
+
clearTimeout(one.timer);
|
|
133
|
+
running.delete(profile);
|
|
134
|
+
}, "forget");
|
|
135
|
+
const use = /* @__PURE__ */ __name(async (profile, work) => {
|
|
136
|
+
let one = running.get(profile);
|
|
137
|
+
if (!one) {
|
|
138
|
+
const child = startChild(options.child(profile), (line) => note(`${profile}: ${line}`), () => forget(profile, child));
|
|
139
|
+
child.catch(() => forget(profile, child));
|
|
140
|
+
one = { child };
|
|
141
|
+
running.set(profile, one);
|
|
142
|
+
}
|
|
143
|
+
clearTimeout(one.timer);
|
|
144
|
+
const entry = one;
|
|
145
|
+
try {
|
|
146
|
+
return await work(await entry.child);
|
|
147
|
+
} finally {
|
|
148
|
+
if (running.get(profile) === entry) {
|
|
149
|
+
entry.timer = setTimeout(() => {
|
|
150
|
+
forget(profile, entry.child);
|
|
151
|
+
void entry.child.then((child) => child.close()).catch(() => void 0);
|
|
152
|
+
}, idleMs);
|
|
153
|
+
entry.timer.unref();
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}, "use");
|
|
157
|
+
const close = /* @__PURE__ */ __name(async () => {
|
|
158
|
+
const all = [...running.values()];
|
|
159
|
+
running.clear();
|
|
160
|
+
for (const one of all)
|
|
161
|
+
clearTimeout(one.timer);
|
|
162
|
+
await Promise.all(all.map((one) => one.child.then((child) => child.close()).catch(() => void 0)));
|
|
163
|
+
}, "close");
|
|
164
|
+
return { use, close };
|
|
165
|
+
}, "pool");
|
|
166
|
+
var withProfile = /* @__PURE__ */ __name((tool, profiles, name, signedIn = () => true) => {
|
|
167
|
+
const schema = tool.inputSchema;
|
|
168
|
+
const out = profiles.filter((profile) => !signedIn(profile));
|
|
169
|
+
const states = out.length === 0 ? "" : ` Signed in: ${profiles.filter(signedIn).join(", ") || "none"} \xB7 Not signed in: ${out.join(", ")}.`;
|
|
170
|
+
return {
|
|
171
|
+
...tool,
|
|
172
|
+
inputSchema: {
|
|
173
|
+
...tool.inputSchema,
|
|
174
|
+
properties: {
|
|
175
|
+
profile: profiles.length === 0 ? (
|
|
176
|
+
// An empty enum matches nothing, and a directory that checks the schema refuses the tool.
|
|
177
|
+
{
|
|
178
|
+
type: "string",
|
|
179
|
+
description: `Which ${name} account, by its profile. None is set up on this computer yet.`
|
|
180
|
+
}
|
|
181
|
+
) : {
|
|
182
|
+
type: "string",
|
|
183
|
+
enum: [...profiles],
|
|
184
|
+
oneOf: profiles.map((one) => ({ const: one, title: signedIn(one) ? one : `${one} \u2014 not signed in` })),
|
|
185
|
+
description: `Which ${name} account, by its profile. If the owner did not name one, ask which \u2014 never guess.${states}`
|
|
186
|
+
},
|
|
187
|
+
...schema.properties
|
|
188
|
+
},
|
|
189
|
+
required: ["profile", ...(schema.required ?? []).filter((field) => field !== "profile")]
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
}, "withProfile");
|
|
193
|
+
var refusal = /* @__PURE__ */ __name((code, text, details) => mcpErrorResult(errorObjectOf(new CliError(code, text, details), { effects: { remote: "none", local: "none" } })), "refusal");
|
|
194
|
+
var allProfilesServer = /* @__PURE__ */ __name((options) => {
|
|
195
|
+
const children = pool(options);
|
|
196
|
+
let listed;
|
|
197
|
+
const tools = /* @__PURE__ */ __name((profiles) => {
|
|
198
|
+
listed ??= children.use(profiles.find(signedIn) ?? profiles[0], (child) => child.request("tools/list", {})).then((answer) => answer.tools ?? []);
|
|
199
|
+
listed.catch(() => {
|
|
200
|
+
listed = void 0;
|
|
201
|
+
});
|
|
202
|
+
return listed;
|
|
203
|
+
}, "tools");
|
|
204
|
+
const signedIn = /* @__PURE__ */ __name((profile) => options.signedIn?.(profile) ?? true, "signedIn");
|
|
205
|
+
const build = /* @__PURE__ */ __name(() => {
|
|
206
|
+
const profiles = [...options.profiles()].sort();
|
|
207
|
+
const server = new McpServer({ name: options.command, version: options.version }, {
|
|
208
|
+
capabilities: { tools: {} },
|
|
209
|
+
// Read per session, as the profiles are: clients cut the instructions short, so this line comes first.
|
|
210
|
+
instructions: profiles.length === 0 && options.setup ? `${options.setup.charAt(0).toUpperCase()}${options.setup.slice(1)}.
|
|
211
|
+
${options.instructions}` : options.instructions
|
|
212
|
+
});
|
|
213
|
+
server.server.setRequestHandler("tools/list", async () => ({
|
|
214
|
+
tools: (profiles.length === 0 ? await options.catalogue?.() ?? [] : await tools(profiles)).map((one) => withProfile(one, profiles, options.name, signedIn))
|
|
215
|
+
}));
|
|
216
|
+
const callers = {
|
|
217
|
+
env: options.env ?? process.env,
|
|
218
|
+
client: /* @__PURE__ */ __name(() => server.server.getClientVersion(), "client"),
|
|
219
|
+
connectionId: randomUUID()
|
|
220
|
+
};
|
|
221
|
+
server.server.setRequestHandler("tools/call", async (request, ctx) => {
|
|
222
|
+
const { name, arguments: given = {}, _meta } = request.params;
|
|
223
|
+
const { profile, ...rest } = given;
|
|
224
|
+
if (profiles.length === 0)
|
|
225
|
+
return refusal("configuration_error", options.setup ?? `no ${options.command} profile on this computer yet.`);
|
|
226
|
+
if (typeof profile !== "string" || !profiles.includes(profile))
|
|
227
|
+
return refusal("validation_error", `${name} needs "profile", one of: ${profiles.join(", ")}. If the owner did not say which account, ask.`);
|
|
228
|
+
if (!signedIn(profile))
|
|
229
|
+
return refusal("authentication_error", options.signIn?.(profile) ?? `profile ${profile} is not signed in.`);
|
|
230
|
+
try {
|
|
231
|
+
return await children.use(profile, (child) => (
|
|
232
|
+
// Children are shared by every session, so each call names its own caller.
|
|
233
|
+
child.request("tools/call", {
|
|
234
|
+
name,
|
|
235
|
+
arguments: rest,
|
|
236
|
+
_meta: { ..._meta, [CALLER_META_KEY]: callerOf(ctx, name, callers) }
|
|
237
|
+
})
|
|
238
|
+
));
|
|
239
|
+
} catch (error) {
|
|
240
|
+
return refusal("outcome_unknown", `profile ${profile}: ${error instanceof Error ? error.message : String(error)}`);
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
return server;
|
|
244
|
+
}, "build");
|
|
245
|
+
return { build, close: /* @__PURE__ */ __name(() => children.close(), "close") };
|
|
246
|
+
}, "allProfilesServer");
|
|
247
|
+
var listedTools = /* @__PURE__ */ __name(async (server) => {
|
|
248
|
+
const [own, other] = InMemoryTransport.createLinkedPair();
|
|
249
|
+
const answers = /* @__PURE__ */ new Map();
|
|
250
|
+
other.onmessage = (message) => {
|
|
251
|
+
const { id, result, error } = message;
|
|
252
|
+
if (typeof id === "number")
|
|
253
|
+
answers.get(id)?.(result, error);
|
|
254
|
+
};
|
|
255
|
+
const ask = /* @__PURE__ */ __name((id, method, params) => new Promise((resolve, reject) => {
|
|
256
|
+
answers.set(id, (result, error) => error || !result ? reject(new Error(error?.message ?? `${method} had no answer`)) : resolve(result));
|
|
257
|
+
void other.send({ jsonrpc: "2.0", id, method, params });
|
|
258
|
+
}), "ask");
|
|
259
|
+
await server.connect(own);
|
|
260
|
+
try {
|
|
261
|
+
await ask(1, "initialize", {
|
|
262
|
+
protocolVersion: PROTOCOL,
|
|
263
|
+
capabilities: {},
|
|
264
|
+
clientInfo: { name: PROXY_CLIENT_NAME, version: "1" }
|
|
265
|
+
});
|
|
266
|
+
await other.send({ jsonrpc: "2.0", method: "notifications/initialized" });
|
|
267
|
+
const answer = await ask(2, "tools/list", {});
|
|
268
|
+
if (!Array.isArray(answer.tools))
|
|
269
|
+
throw new Error("the catalogue server listed no tools");
|
|
270
|
+
return answer.tools;
|
|
271
|
+
} finally {
|
|
272
|
+
await server.close();
|
|
273
|
+
}
|
|
274
|
+
}, "listedTools");
|
|
275
|
+
var serveAllProfilesOverStdio = /* @__PURE__ */ __name(async (options, io = {}) => {
|
|
276
|
+
const { build, close } = allProfilesServer(options);
|
|
277
|
+
const own = io.stdin !== void 0 && io.stdin !== process.stdin;
|
|
278
|
+
const wire = answeredWire(io.stdin ?? process.stdin, io.stdout ?? process.stdout);
|
|
279
|
+
const handle = serveStdio(build, {
|
|
280
|
+
transport: new StdioServerTransport(wire.input, wire.output),
|
|
281
|
+
onerror: /* @__PURE__ */ __name((error) => options.note?.(`mcp: ${error.message}`), "onerror")
|
|
282
|
+
});
|
|
283
|
+
await wire.finished(own ? io.signal : void 0);
|
|
284
|
+
try {
|
|
285
|
+
wire.release();
|
|
286
|
+
await handle.close();
|
|
287
|
+
} finally {
|
|
288
|
+
await close();
|
|
289
|
+
}
|
|
290
|
+
}, "serveAllProfilesOverStdio");
|
|
291
|
+
var serveAllProfilesOverHttp = /* @__PURE__ */ __name(async (options, http) => {
|
|
292
|
+
const { build, close } = allProfilesServer(options);
|
|
293
|
+
const { serveOverHttp } = await import("./serve-I2USUY4X.js");
|
|
294
|
+
const listening = await serveOverHttp(build, {
|
|
295
|
+
...http,
|
|
296
|
+
appName: options.command,
|
|
297
|
+
onError: /* @__PURE__ */ __name((error) => options.note?.(`mcp: ${error.message}`), "onError")
|
|
298
|
+
}).catch(async (error) => {
|
|
299
|
+
await close();
|
|
300
|
+
throw error;
|
|
301
|
+
});
|
|
302
|
+
return {
|
|
303
|
+
url: listening.url,
|
|
304
|
+
close: /* @__PURE__ */ __name(async () => {
|
|
305
|
+
try {
|
|
306
|
+
await listening.close();
|
|
307
|
+
} finally {
|
|
308
|
+
await close();
|
|
309
|
+
}
|
|
310
|
+
}, "close")
|
|
311
|
+
};
|
|
312
|
+
}, "serveAllProfilesOverHttp");
|
|
313
|
+
export {
|
|
314
|
+
CHILD_IDLE_MS,
|
|
315
|
+
allProfilesServer,
|
|
316
|
+
listedTools,
|
|
317
|
+
serveAllProfilesOverHttp,
|
|
318
|
+
serveAllProfilesOverStdio,
|
|
319
|
+
withProfile
|
|
320
|
+
};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
+
const require = __bundleRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
EmptyAnswer,
|
|
5
|
+
checkedOptions,
|
|
6
|
+
messagesFor,
|
|
7
|
+
systemFor
|
|
8
|
+
} from "./chunk-BAXNAOOL.js";
|
|
9
|
+
import {
|
|
10
|
+
Anthropic
|
|
11
|
+
} from "./chunk-CCOSG3F2.js";
|
|
12
|
+
import "./chunk-3BM6KBWP.js";
|
|
13
|
+
import "./chunk-3LMW7U7F.js";
|
|
14
|
+
import {
|
|
15
|
+
array,
|
|
16
|
+
literal,
|
|
17
|
+
optional,
|
|
18
|
+
picklist,
|
|
19
|
+
record,
|
|
20
|
+
strictObject,
|
|
21
|
+
string,
|
|
22
|
+
unknown
|
|
23
|
+
} from "./chunk-S4UUN6LD.js";
|
|
24
|
+
import "./chunk-Y5E2WNWB.js";
|
|
25
|
+
import "./chunk-HM6AMYHR.js";
|
|
26
|
+
import {
|
|
27
|
+
__name
|
|
28
|
+
} from "./chunk-ZVVMGPBJ.js";
|
|
29
|
+
|
|
30
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.707.0_@wirecat+cli-base@0.124.0_commander@15.0.0_esbuild@0.28.2_typ_1ab7200af0919d16d129ae0ece32d37f/node_modules/@wirecat/cli-core/dist/models/anthropic.js
|
|
31
|
+
var options = strictObject({
|
|
32
|
+
stop_sequences: optional(array(string())),
|
|
33
|
+
thinking: optional(strictObject({ type: picklist(["disabled", "adaptive"]) })),
|
|
34
|
+
output_config: optional(strictObject({
|
|
35
|
+
effort: optional(picklist(["low", "medium", "high"])),
|
|
36
|
+
format: optional(strictObject({ type: literal("json_schema"), schema: record(string(), unknown()) }))
|
|
37
|
+
}))
|
|
38
|
+
});
|
|
39
|
+
var anthropic = {
|
|
40
|
+
images: true,
|
|
41
|
+
baseUrl: "https://api.anthropic.com",
|
|
42
|
+
validate: /* @__PURE__ */ __name((given) => checkedOptions("anthropic", options, given), "validate"),
|
|
43
|
+
complete: /* @__PURE__ */ __name(async (target, request, checked, apiKey, fetcher) => {
|
|
44
|
+
const client = new Anthropic({
|
|
45
|
+
apiKey: apiKey ?? "",
|
|
46
|
+
authToken: null,
|
|
47
|
+
fetch: /* @__PURE__ */ __name((input, init) => fetcher(input, { ...init, redirect: "error" }), "fetch"),
|
|
48
|
+
baseURL: target.baseUrl,
|
|
49
|
+
maxRetries: 0,
|
|
50
|
+
logLevel: "off",
|
|
51
|
+
timeout: 12e4
|
|
52
|
+
});
|
|
53
|
+
const response = await client.messages.stream({
|
|
54
|
+
...checked,
|
|
55
|
+
model: target.model,
|
|
56
|
+
system: systemFor(request),
|
|
57
|
+
messages: [
|
|
58
|
+
...messagesFor(request),
|
|
59
|
+
...request.images === void 0 ? [] : [
|
|
60
|
+
{
|
|
61
|
+
role: "user",
|
|
62
|
+
content: [
|
|
63
|
+
{ type: "text", text: request.prompt },
|
|
64
|
+
...request.images.map((image) => ({
|
|
65
|
+
type: "image",
|
|
66
|
+
source: { type: "base64", media_type: image.mimeType, data: image.data }
|
|
67
|
+
}))
|
|
68
|
+
]
|
|
69
|
+
}
|
|
70
|
+
]
|
|
71
|
+
],
|
|
72
|
+
max_tokens: request.maxTokens
|
|
73
|
+
}).finalMessage();
|
|
74
|
+
if (response.stop_reason !== "end_turn")
|
|
75
|
+
throw new Error("incomplete response");
|
|
76
|
+
const text = response.content.filter((block) => block.type === "text").map((block) => block.text).join("");
|
|
77
|
+
if (text.trim() === "")
|
|
78
|
+
throw new EmptyAnswer();
|
|
79
|
+
return {
|
|
80
|
+
text,
|
|
81
|
+
usage: {
|
|
82
|
+
input: response.usage.input_tokens + (response.usage.cache_creation_input_tokens ?? 0) + (response.usage.cache_read_input_tokens ?? 0),
|
|
83
|
+
output: response.usage.output_tokens
|
|
84
|
+
},
|
|
85
|
+
tokens: response.usage.input_tokens + response.usage.output_tokens + (response.usage.cache_creation_input_tokens ?? 0) + (response.usage.cache_read_input_tokens ?? 0)
|
|
86
|
+
};
|
|
87
|
+
}, "complete")
|
|
88
|
+
};
|
|
89
|
+
export {
|
|
90
|
+
anthropic
|
|
91
|
+
};
|