@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,557 @@
|
|
|
1
|
+
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
+
const require = __bundleRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
UNTRUSTED,
|
|
5
|
+
UNTRUSTED_NEUTRAL,
|
|
6
|
+
agentArguments,
|
|
7
|
+
agentJson,
|
|
8
|
+
failureContext
|
|
9
|
+
} from "./chunk-3BRAZVHR.js";
|
|
10
|
+
import {
|
|
11
|
+
onlineDeps,
|
|
12
|
+
refuseLacking,
|
|
13
|
+
servicesFor,
|
|
14
|
+
storeModeDeps
|
|
15
|
+
} from "./chunk-PV5UYGRJ.js";
|
|
16
|
+
import {
|
|
17
|
+
callerOf
|
|
18
|
+
} from "./chunk-ARGRGTPX.js";
|
|
19
|
+
import {
|
|
20
|
+
DEFAULT_OUTPUT_BYTES,
|
|
21
|
+
ENTITIES,
|
|
22
|
+
LOCAL_WRITE,
|
|
23
|
+
REMOTE_WRITE,
|
|
24
|
+
answerSchema,
|
|
25
|
+
fetchesAt,
|
|
26
|
+
judgedAnswer,
|
|
27
|
+
judgedEffects,
|
|
28
|
+
keyForCommand,
|
|
29
|
+
levelFor,
|
|
30
|
+
listOf,
|
|
31
|
+
readKeysForCommand,
|
|
32
|
+
refuseStoreChange,
|
|
33
|
+
sealed,
|
|
34
|
+
startRecording
|
|
35
|
+
} from "./chunk-FQROWBKV.js";
|
|
36
|
+
import {
|
|
37
|
+
currentCaller,
|
|
38
|
+
keepsSuccess,
|
|
39
|
+
runContextOf,
|
|
40
|
+
withCaller
|
|
41
|
+
} from "./chunk-R7Y3XU66.js";
|
|
42
|
+
import {
|
|
43
|
+
MAX_BUFFERED_INPUT
|
|
44
|
+
} from "./chunk-IJVTN5L3.js";
|
|
45
|
+
import {
|
|
46
|
+
inRun,
|
|
47
|
+
newRunId
|
|
48
|
+
} from "./chunk-3LVTQFGB.js";
|
|
49
|
+
import {
|
|
50
|
+
storeDamaged
|
|
51
|
+
} from "./chunk-UUIOAZPH.js";
|
|
52
|
+
import {
|
|
53
|
+
traceIdOf
|
|
54
|
+
} from "./chunk-3BM6KBWP.js";
|
|
55
|
+
import {
|
|
56
|
+
errorObjectOf,
|
|
57
|
+
itemEnvelopeSchema,
|
|
58
|
+
listEnvelopeSchema,
|
|
59
|
+
mcpErrorResult,
|
|
60
|
+
toJsonSchema,
|
|
61
|
+
toStandardJsonSchema
|
|
62
|
+
} from "./chunk-3LMW7U7F.js";
|
|
63
|
+
import {
|
|
64
|
+
array,
|
|
65
|
+
boolean,
|
|
66
|
+
description,
|
|
67
|
+
integer,
|
|
68
|
+
looseObject,
|
|
69
|
+
maxLength,
|
|
70
|
+
maxValue,
|
|
71
|
+
minLength,
|
|
72
|
+
minValue,
|
|
73
|
+
number,
|
|
74
|
+
optional,
|
|
75
|
+
pipe,
|
|
76
|
+
record,
|
|
77
|
+
regex,
|
|
78
|
+
safeParse,
|
|
79
|
+
strictObject,
|
|
80
|
+
string,
|
|
81
|
+
summarize,
|
|
82
|
+
unknown
|
|
83
|
+
} from "./chunk-S4UUN6LD.js";
|
|
84
|
+
import {
|
|
85
|
+
CliError,
|
|
86
|
+
errorCodes
|
|
87
|
+
} from "./chunk-HM6AMYHR.js";
|
|
88
|
+
import {
|
|
89
|
+
__name
|
|
90
|
+
} from "./chunk-ZVVMGPBJ.js";
|
|
91
|
+
|
|
92
|
+
// 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/surface.js
|
|
93
|
+
import { randomUUID } from "node:crypto";
|
|
94
|
+
|
|
95
|
+
// 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/tool.js
|
|
96
|
+
var limit = optional(pipe(number(), integer(), minValue(1), maxValue(100), description("how many")));
|
|
97
|
+
var page = optional(pipe(number(), integer(), minValue(1), description("which page, from 1")));
|
|
98
|
+
var message = pipe(
|
|
99
|
+
string(),
|
|
100
|
+
maxLength(256),
|
|
101
|
+
// biome-ignore lint/suspicious/noControlCharactersInRegex: refusing them is the point
|
|
102
|
+
regex(/^[^\s\x00-\x1F\x7F-\x9F]+$/, "a message id has no spaces or control characters"),
|
|
103
|
+
description("message id")
|
|
104
|
+
);
|
|
105
|
+
var READ = { readOnlyHint: true, destructiveHint: false, openWorldHint: true };
|
|
106
|
+
var WRITE = {
|
|
107
|
+
readOnlyHint: false,
|
|
108
|
+
destructiveHint: true,
|
|
109
|
+
idempotentHint: false,
|
|
110
|
+
openWorldHint: true
|
|
111
|
+
};
|
|
112
|
+
var tool = /* @__PURE__ */ __name((definition) => definition, "tool");
|
|
113
|
+
var chatOf = /* @__PURE__ */ __name((messenger) => pipe(string(), minLength(1), description(messenger.chatArgument)), "chatOf");
|
|
114
|
+
var tierOf = /* @__PURE__ */ __name((key, definition, messenger) => {
|
|
115
|
+
if (definition.annotations.readOnlyHint === true)
|
|
116
|
+
return "read";
|
|
117
|
+
if (/^admin|_admin/.test(key))
|
|
118
|
+
return "admin";
|
|
119
|
+
if (/delete|ban|kick|remove|purge|block/.test(key))
|
|
120
|
+
return "destructive";
|
|
121
|
+
if (/draft/.test(key))
|
|
122
|
+
return "draft";
|
|
123
|
+
if (key === "messages_pin" && messenger?.quietPins === false)
|
|
124
|
+
return "write-public";
|
|
125
|
+
if (/mark_read|mark_unread|read_mark|archive|mute|pin|tag|note|label|folder|alias|save|_(un)?star$/.test(key))
|
|
126
|
+
return "write-private";
|
|
127
|
+
return "write-public";
|
|
128
|
+
}, "tierOf");
|
|
129
|
+
var effectsOf = /* @__PURE__ */ __name((definition) => {
|
|
130
|
+
if (definition.effects)
|
|
131
|
+
return definition.effects;
|
|
132
|
+
const { readOnlyHint, openWorldHint } = definition.annotations;
|
|
133
|
+
if (readOnlyHint === true)
|
|
134
|
+
return { remote: openWorldHint === false ? "none" : "read", local: "read" };
|
|
135
|
+
return openWorldHint === false ? LOCAL_WRITE : REMOTE_WRITE;
|
|
136
|
+
}, "effectsOf");
|
|
137
|
+
var outcomeOf = /* @__PURE__ */ __name((result) => {
|
|
138
|
+
if (!result.isError)
|
|
139
|
+
return { status: "ok" };
|
|
140
|
+
const code = result.structuredContent?.error?.code;
|
|
141
|
+
const error = typeof code === "string" ? code : "generic_failure";
|
|
142
|
+
return { status: error === "permission_error" ? "refused" : "failed", error };
|
|
143
|
+
}, "outcomeOf");
|
|
144
|
+
var commandOf = /* @__PURE__ */ __name((name, definition) => definition.command ?? name.replaceAll("_", " "), "commandOf");
|
|
145
|
+
var toolKey = /* @__PURE__ */ __name((name, definition) => definition.key !== void 0 ? definition.key : keyForCommand(commandOf(name, definition).split(" ")), "toolKey");
|
|
146
|
+
var inputOf = /* @__PURE__ */ __name((definition, syncAllowed) => strictObject(syncAllowed || !("sync_first" in definition.input.entries) ? definition.input.entries : Object.fromEntries(Object.entries(definition.input.entries).filter(([name]) => !["sync_first", "sync_time", "max_chats", "max_messages"].includes(name)))), "inputOf");
|
|
147
|
+
var syncAllowedFor = /* @__PURE__ */ __name((key, defaults) => {
|
|
148
|
+
const permissions = defaults.settings.permissions ?? {};
|
|
149
|
+
const shared = defaults.syncAllowed ?? fetchesAt(levelFor(permissions, "messages.sync-first").level);
|
|
150
|
+
return shared && (!key.startsWith("stats_") || fetchesAt(levelFor(permissions, `${key.replaceAll("_", ".")}.sync-first`).level));
|
|
151
|
+
}, "syncAllowedFor");
|
|
152
|
+
var entryRunner = /* @__PURE__ */ __name((registration) => {
|
|
153
|
+
const run = callRunner(registration);
|
|
154
|
+
const { log } = registration;
|
|
155
|
+
return async (key, definition, args, ctx) => {
|
|
156
|
+
const startedAt = Date.now();
|
|
157
|
+
const command = `mcp ${commandOf(key, definition)}`;
|
|
158
|
+
const traceId = traceIdOf(ctx?.mcpReq?._meta?.traceparent);
|
|
159
|
+
const app = registration.messenger?.app;
|
|
160
|
+
const caller = registration.callers ? callerOf(ctx, key, registration.callers) : currentCaller();
|
|
161
|
+
const env = registration.defaults.env ?? process.env;
|
|
162
|
+
const settings = registration.defaults.settings;
|
|
163
|
+
const recording = key !== "runs_search" && settings.keepFailedRuns !== false && app?.appName ? startRecording({
|
|
164
|
+
app,
|
|
165
|
+
command,
|
|
166
|
+
...settings.profile === void 0 ? {} : { profile: settings.profile },
|
|
167
|
+
env,
|
|
168
|
+
record: keepsSuccess({ record: settings.record ?? true, fromFlag: false, env, caller }),
|
|
169
|
+
keepFailed: true,
|
|
170
|
+
trace: false,
|
|
171
|
+
format: "json",
|
|
172
|
+
context: runContextOf({ bin: app.command, command, env, caller }),
|
|
173
|
+
...settings.keepRunsForDays === void 0 ? {} : { keepDays: settings.keepRunsForDays },
|
|
174
|
+
...settings.keepSuccessfulRunsForDays === void 0 ? {} : { keepSuccessDays: settings.keepSuccessfulRunsForDays },
|
|
175
|
+
...settings.runsSizeLimitMb === void 0 ? {} : { maxBytes: settings.runsSizeLimitMb * 1024 * 1024 },
|
|
176
|
+
...traceId === void 0 ? {} : { traceId }
|
|
177
|
+
}) : void 0;
|
|
178
|
+
const profile = registration.defaults.settings.profile;
|
|
179
|
+
const scope = {
|
|
180
|
+
runId: recording?.runId ?? newRunId(new Date(startedAt), command),
|
|
181
|
+
command,
|
|
182
|
+
startedAt,
|
|
183
|
+
...profile === void 0 ? {} : { profile },
|
|
184
|
+
...traceId === void 0 ? {} : { traceId },
|
|
185
|
+
...recording ? { events: recording.events } : {}
|
|
186
|
+
};
|
|
187
|
+
const work = /* @__PURE__ */ __name(() => inRun(scope, () => {
|
|
188
|
+
const input = inputOf(definition, syncAllowedFor(key, registration.defaults));
|
|
189
|
+
const parsed = safeParse(input, args);
|
|
190
|
+
return parsed.success ? run(key, definition, parsed.output, ctx) : failed(new CliError("validation_error", `${commandOf(key, definition)}: ${summarize(parsed.issues)}`, {
|
|
191
|
+
arguments: toJsonSchema(input)
|
|
192
|
+
}), app?.errors);
|
|
193
|
+
}), "work");
|
|
194
|
+
const result = await (caller ? withCaller(caller, work) : work());
|
|
195
|
+
if (recording) {
|
|
196
|
+
if (result.isError) {
|
|
197
|
+
const error = result.structuredContent?.error;
|
|
198
|
+
const code = error?.code && errorCodes.includes(error.code) ? error.code : void 0;
|
|
199
|
+
await recording.fail(code ? new CliError(code, "MCP operation failed") : new Error("MCP operation failed")).catch(() => void 0);
|
|
200
|
+
} else
|
|
201
|
+
await recording.succeed(result.structuredContent).catch(() => void 0);
|
|
202
|
+
}
|
|
203
|
+
await log?.({
|
|
204
|
+
tool: key,
|
|
205
|
+
tier: tierOf(key, definition, registration.messenger),
|
|
206
|
+
...outcomeOf(result),
|
|
207
|
+
startedAt,
|
|
208
|
+
finishedAt: Date.now()
|
|
209
|
+
}, caller)?.catch(() => void 0);
|
|
210
|
+
return result;
|
|
211
|
+
};
|
|
212
|
+
}, "entryRunner");
|
|
213
|
+
var callRunner = /* @__PURE__ */ __name(({ messenger, session, withStore, withServices, defaults, around, targets }) => {
|
|
214
|
+
const where = {
|
|
215
|
+
profile: defaults.settings.profile,
|
|
216
|
+
env: defaults.env,
|
|
217
|
+
pictures: defaults.settings.pictureSearch,
|
|
218
|
+
reranker: defaults.settings.searchReranker
|
|
219
|
+
};
|
|
220
|
+
return async (key, definition, args, ctx) => {
|
|
221
|
+
const path = commandOf(key, definition).split(" ");
|
|
222
|
+
const run = `mcp ${path.join(" ")}`;
|
|
223
|
+
try {
|
|
224
|
+
const execute = /* @__PURE__ */ __name(async () => {
|
|
225
|
+
const syncAllowed = syncAllowedFor(key, defaults);
|
|
226
|
+
if (Buffer.byteLength(JSON.stringify(args)) > MAX_BUFFERED_INPUT)
|
|
227
|
+
throw new CliError("validation_error", "tool arguments exceed the buffered input limit", {
|
|
228
|
+
reason: "input.too-large",
|
|
229
|
+
max_bytes: MAX_BUFFERED_INPUT,
|
|
230
|
+
retryable: false
|
|
231
|
+
});
|
|
232
|
+
definition.check?.(args);
|
|
233
|
+
if (definition.changesStore)
|
|
234
|
+
refuseStoreChange(messenger.app, defaults.env);
|
|
235
|
+
refuseLacking(messenger, path);
|
|
236
|
+
for (const permission of readKeysForCommand(path)) {
|
|
237
|
+
if (levelFor(defaults.settings.permissions ?? {}, permission).level === "deny")
|
|
238
|
+
throw new CliError("permission_error", `profile denies ${permission}`, { permission });
|
|
239
|
+
}
|
|
240
|
+
if (args.sync_first && !syncAllowed)
|
|
241
|
+
throw new CliError("permission_error", "messages.sync-first is not allowed by this profile");
|
|
242
|
+
if (definition.custom) {
|
|
243
|
+
const result2 = await definition.custom(args, { ...defaults, signal: ctx.mcpReq.signal }, ctx);
|
|
244
|
+
return answered(result2, definition.outputLimit?.(args, defaults), targets);
|
|
245
|
+
}
|
|
246
|
+
if (definition.local)
|
|
247
|
+
return answered(await definition.local(args, defaults), definition.outputLimit?.(args, defaults), targets);
|
|
248
|
+
const { online, stored: local, served } = definition;
|
|
249
|
+
const stored = local && (!definition.storedWhen || definition.storedWhen(args)) ? local : void 0;
|
|
250
|
+
const result = stored ? await withStore((store, account) => stored(store, account, args, { ...defaults, signal: ctx.mcpReq.signal }, (work) => session.use(run, work)), {
|
|
251
|
+
name: run
|
|
252
|
+
}) : served && withServices ? await withServices((services, connect) => served(services, args, defaults, connect), { name: run }) : served && messenger.history === "store" ? await withStore((store, account) => served(servicesFor({
|
|
253
|
+
...storeModeDeps(messenger, store, account, defaults.guard),
|
|
254
|
+
...where,
|
|
255
|
+
embedders: defaults.embedders
|
|
256
|
+
}), args, defaults, (work) => session.use(run, async (adapter, release) => {
|
|
257
|
+
try {
|
|
258
|
+
return await work(adapter);
|
|
259
|
+
} finally {
|
|
260
|
+
await release();
|
|
261
|
+
}
|
|
262
|
+
})), { name: run }) : served ? await session.use(run, (adapter, release) => served(servicesFor(onlineDeps(messenger, adapter, defaults.guard, where)), args, defaults, (work) => (async () => {
|
|
263
|
+
try {
|
|
264
|
+
return await work(adapter);
|
|
265
|
+
} finally {
|
|
266
|
+
await release();
|
|
267
|
+
}
|
|
268
|
+
})())) : await session.use(run, (adapter, release) => online(adapter, args, { ...defaults, release }));
|
|
269
|
+
return answered(result, definition.outputLimit?.(args, defaults), targets);
|
|
270
|
+
}, "execute");
|
|
271
|
+
return around ? await around(key, definition, execute) : await execute();
|
|
272
|
+
} catch (error) {
|
|
273
|
+
return failed(error, messenger?.app?.errors, effectsOf(definition));
|
|
274
|
+
}
|
|
275
|
+
};
|
|
276
|
+
}, "callRunner");
|
|
277
|
+
var outputSchemaOf = /* @__PURE__ */ __name((definition) => {
|
|
278
|
+
if (!definition.output)
|
|
279
|
+
return looseObject({});
|
|
280
|
+
const entity = ENTITIES[definition.output.entity];
|
|
281
|
+
return definition.output.list ? listEnvelopeSchema(entity) : itemEnvelopeSchema(entity);
|
|
282
|
+
}, "outputSchemaOf");
|
|
283
|
+
var Picture = class {
|
|
284
|
+
static {
|
|
285
|
+
__name(this, "Picture");
|
|
286
|
+
}
|
|
287
|
+
bytes;
|
|
288
|
+
mimeType;
|
|
289
|
+
about;
|
|
290
|
+
constructor(bytes, mimeType, about) {
|
|
291
|
+
this.bytes = bytes;
|
|
292
|
+
this.mimeType = mimeType;
|
|
293
|
+
this.about = about;
|
|
294
|
+
}
|
|
295
|
+
};
|
|
296
|
+
var BinaryResource = class {
|
|
297
|
+
static {
|
|
298
|
+
__name(this, "BinaryResource");
|
|
299
|
+
}
|
|
300
|
+
base64;
|
|
301
|
+
mimeType;
|
|
302
|
+
uri;
|
|
303
|
+
about;
|
|
304
|
+
constructor(base64, mimeType, uri, about) {
|
|
305
|
+
this.base64 = base64;
|
|
306
|
+
this.mimeType = mimeType;
|
|
307
|
+
this.uri = uri;
|
|
308
|
+
this.about = about;
|
|
309
|
+
}
|
|
310
|
+
};
|
|
311
|
+
var answered = /* @__PURE__ */ __name((answer, maxBytes = DEFAULT_OUTPUT_BYTES, targets) => {
|
|
312
|
+
const bounded = /* @__PURE__ */ __name((result) => {
|
|
313
|
+
if (maxBytes !== 0 && Buffer.byteLength(JSON.stringify(result.content)) > maxBytes)
|
|
314
|
+
throw new CliError("invalid_response", "tool output exceeds its byte limit \u2014 reduce limit or use a narrower request", { reason: "output.too-large", max_bytes: maxBytes, retryable: false });
|
|
315
|
+
return result;
|
|
316
|
+
}, "bounded");
|
|
317
|
+
if (answer === null || Array.isArray(answer) || typeof answer !== "object")
|
|
318
|
+
throw new CliError("invalid_response", "tool result must be an object", { retryable: false });
|
|
319
|
+
const objectBody = /* @__PURE__ */ __name((value) => {
|
|
320
|
+
const serialized = JSON.parse(agentJson(value));
|
|
321
|
+
if (serialized === null || Array.isArray(serialized) || typeof serialized !== "object")
|
|
322
|
+
throw new CliError("invalid_response", "serialized tool result must be an object", { retryable: false });
|
|
323
|
+
return serialized;
|
|
324
|
+
}, "objectBody");
|
|
325
|
+
if (answer instanceof BinaryResource) {
|
|
326
|
+
const about = sealed(answer.about);
|
|
327
|
+
return bounded({
|
|
328
|
+
structuredContent: objectBody(about),
|
|
329
|
+
content: [
|
|
330
|
+
{ type: "resource", resource: { uri: answer.uri, mimeType: answer.mimeType, blob: answer.base64 } },
|
|
331
|
+
{ type: "text", text: agentJson(about) }
|
|
332
|
+
]
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
if (answer instanceof Picture) {
|
|
336
|
+
const about = sealed(answer.about);
|
|
337
|
+
return bounded({
|
|
338
|
+
structuredContent: objectBody(about),
|
|
339
|
+
content: [
|
|
340
|
+
{ type: "image", data: Buffer.from(answer.bytes).toString("base64"), mimeType: answer.mimeType },
|
|
341
|
+
{ type: "text", text: agentJson(about) }
|
|
342
|
+
]
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
const body = objectBody(sealed(targets ? judgedAnswer(answer, targets) : answer));
|
|
346
|
+
return bounded({ content: [{ type: "text", text: JSON.stringify(body) }], structuredContent: body });
|
|
347
|
+
}, "answered");
|
|
348
|
+
var failed = /* @__PURE__ */ __name((error, errors, effects) => {
|
|
349
|
+
const judged = judgedEffects(effects);
|
|
350
|
+
const context = { ...failureContext(errors), ...judged ? { effects: judged } : {} };
|
|
351
|
+
return mcpErrorResult(JSON.parse(agentJson(errorObjectOf(storeDamaged(error), context))));
|
|
352
|
+
}, "failed");
|
|
353
|
+
|
|
354
|
+
// 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/surface.js
|
|
355
|
+
var MATCHES = 8;
|
|
356
|
+
var ANSWER = answerSchema();
|
|
357
|
+
var agentAnswer = /* @__PURE__ */ __name((prefix, writes) => {
|
|
358
|
+
const meta = pipe(looseObject({}), description(`run facts; ${prefix}_tools_search shows the full answer`));
|
|
359
|
+
const next = optional(pipe(array(looseObject({})), description("steps to run next: command and args")));
|
|
360
|
+
return looseObject(writes ? { item: optional(unknown()), next, meta } : {
|
|
361
|
+
items: optional(array(unknown())),
|
|
362
|
+
item: optional(unknown()),
|
|
363
|
+
page: optional(looseObject({ has_more: boolean() })),
|
|
364
|
+
next,
|
|
365
|
+
missing: optional(array(looseObject({ field: string(), why: string() }))),
|
|
366
|
+
meta
|
|
367
|
+
});
|
|
368
|
+
}, "agentAnswer");
|
|
369
|
+
var listedAs = /* @__PURE__ */ __name((prefix, writes) => {
|
|
370
|
+
const checked = toStandardJsonSchema(ANSWER);
|
|
371
|
+
const shown = toStandardJsonSchema(agentAnswer(prefix, writes))["~standard"].jsonSchema;
|
|
372
|
+
return { "~standard": { ...checked["~standard"], jsonSchema: shown } };
|
|
373
|
+
}, "listedAs");
|
|
374
|
+
var normal = /* @__PURE__ */ __name((command) => command.trim().toLowerCase().split(/[\s_-]+/).join(" "), "normal");
|
|
375
|
+
var STOP_WORDS = new Set("a an the to of in on at by for from with into out about and or but is are be been was were it its this that these those which who whom whose what when where how do does did can could should would will my our your their his her them they we you i one some any all each every another other".split(" "));
|
|
376
|
+
var wordsOf = /* @__PURE__ */ __name((text) => text.toLowerCase().split(/[^\p{L}\p{N}]+/u).filter(Boolean), "wordsOf");
|
|
377
|
+
var stem = /* @__PURE__ */ __name((word) => {
|
|
378
|
+
const bare = word.replace(/'s$/u, "");
|
|
379
|
+
if (bare.length > 4 && bare.endsWith("ies"))
|
|
380
|
+
return `${bare.slice(0, -3)}y`;
|
|
381
|
+
for (const ending of ["ing", "ed", "es", "s"])
|
|
382
|
+
if (bare.length - ending.length >= 3 && bare.endsWith(ending))
|
|
383
|
+
return bare.slice(0, -ending.length);
|
|
384
|
+
return bare;
|
|
385
|
+
}, "stem");
|
|
386
|
+
var sameWord = /* @__PURE__ */ __name((asked, known) => {
|
|
387
|
+
if (asked === known)
|
|
388
|
+
return true;
|
|
389
|
+
const [short, long] = asked.length <= known.length ? [asked, known] : [known, asked];
|
|
390
|
+
return short.length >= 3 && long.startsWith(short);
|
|
391
|
+
}, "sameWord");
|
|
392
|
+
var fieldsOf = /* @__PURE__ */ __name((command, one) => [
|
|
393
|
+
[4, [...wordsOf(command), ...(one.aliases ?? []).flatMap(wordsOf)]],
|
|
394
|
+
[2, wordsOf(one.title)],
|
|
395
|
+
[1, [...wordsOf(one.description), ...(one.keywords ?? []).flatMap(wordsOf), ...Object.keys(one.input.entries)]]
|
|
396
|
+
].map(([weight, words]) => [weight, [...new Set(words.map(stem))]]), "fieldsOf");
|
|
397
|
+
var search = /* @__PURE__ */ __name((commands, query) => {
|
|
398
|
+
const named = normal(query);
|
|
399
|
+
const all = Object.entries(commands);
|
|
400
|
+
if (!named)
|
|
401
|
+
return all.map((entry) => entry).sort((a, b) => a[0].localeCompare(b[0]));
|
|
402
|
+
const words = [
|
|
403
|
+
...new Set(wordsOf(query).filter((word) => word.length > 1 && !STOP_WORDS.has(word)).map(stem))
|
|
404
|
+
];
|
|
405
|
+
return all.map((entry) => {
|
|
406
|
+
const fields = fieldsOf(entry[0], entry[1]);
|
|
407
|
+
const weights = words.map((word) => fields.reduce((best, [weight, known]) => known.some((one) => sameWord(word, one)) ? Math.max(best, weight) : best, 0));
|
|
408
|
+
const matched = weights.filter((weight) => weight > 0).length;
|
|
409
|
+
const exact = normal(entry[0]) === named || (entry[1].aliases ?? []).some((alias) => normal(alias) === named);
|
|
410
|
+
return { entry, matched, rank: (exact ? 1e3 : 0) + matched * 10 + weights.reduce((a, b) => a + b, 0) };
|
|
411
|
+
}).filter(({ matched, rank }) => matched > 0 || rank >= 1e3).sort((a, b) => b.rank - a.rank || wordsOf(a.entry[0]).length - wordsOf(b.entry[0]).length || a.entry[0].localeCompare(b.entry[0])).map(({ entry }) => entry);
|
|
412
|
+
}, "search");
|
|
413
|
+
var nearest = /* @__PURE__ */ __name((commands, asked) => {
|
|
414
|
+
const words = normal(asked).split(" ");
|
|
415
|
+
return Object.keys(commands).map((one) => ({ one, shared: words.filter((word) => normal(one).split(" ").includes(word)).length })).filter(({ shared }) => shared > 0).sort((a, b) => b.shared - a.shared).slice(0, 3).map(({ one }) => one);
|
|
416
|
+
}, "nearest");
|
|
417
|
+
var runnableOnly = /* @__PURE__ */ __name((result, offered) => {
|
|
418
|
+
const body = result.structuredContent;
|
|
419
|
+
if (result.isError || !Array.isArray(body?.next))
|
|
420
|
+
return result;
|
|
421
|
+
const next = body.next.filter((step) => step.command === void 0 || offered(step.command));
|
|
422
|
+
const { next: _, ...rest } = body;
|
|
423
|
+
const kept = next.length > 0 ? { ...rest, next } : rest;
|
|
424
|
+
return {
|
|
425
|
+
...result,
|
|
426
|
+
structuredContent: kept,
|
|
427
|
+
content: result.content.map((part) => part.type === "text" ? { ...part, text: JSON.stringify(kept) } : part)
|
|
428
|
+
};
|
|
429
|
+
}, "runnableOnly");
|
|
430
|
+
var takesNothing = /* @__PURE__ */ __name((one) => Object.values(one.input.entries).every((entry) => entry.type === "optional"), "takesNothing");
|
|
431
|
+
var sampleOf = /* @__PURE__ */ __name((commands) => {
|
|
432
|
+
const reading = Object.entries(commands).filter(([, one]) => !one.writes);
|
|
433
|
+
const bare = reading.filter(([, one]) => takesNothing(one));
|
|
434
|
+
return bare.find(([command]) => command.endsWith(" list"))?.[0] ?? bare[0]?.[0] ?? reading[0]?.[0] ?? Object.keys(commands)[0] ?? "";
|
|
435
|
+
}, "sampleOf");
|
|
436
|
+
var registerCommands = /* @__PURE__ */ __name((server, prefix, commands, errors, withheld, isMessenger) => {
|
|
437
|
+
const byNormal = new Map(Object.keys(commands).map((command) => [normal(command), command]));
|
|
438
|
+
const messenger = isMessenger ?? Object.keys(commands).some((command) => command.split(" ")[0] === "messages");
|
|
439
|
+
const tasks = messenger ? '"unread", "send message", "chat members"' : '"list", "show", "change a setting"';
|
|
440
|
+
const sample = messenger ? "messages list" : sampleOf(commands);
|
|
441
|
+
const untrusted = messenger ? UNTRUSTED : UNTRUSTED_NEUTRAL;
|
|
442
|
+
server.registerTool(`${prefix}_tools_search`, {
|
|
443
|
+
outputSchema: toStandardJsonSchema(looseObject({})),
|
|
444
|
+
title: "Find a command",
|
|
445
|
+
description: `Find the command for a task \u2014 ${tasks} \u2014 before calling ${prefix}_read or ${prefix}_write with it. Each match gives its command, whether it writes, its arguments and the shape of its answer. With no words, lists every command and title, without arguments.`,
|
|
446
|
+
inputSchema: toStandardJsonSchema(strictObject({ query: optional(pipe(string(), description("words that describe the task"))) })),
|
|
447
|
+
annotations: { ...READ, openWorldHint: false, idempotentHint: true }
|
|
448
|
+
}, async ({ query }) => {
|
|
449
|
+
const found = search(commands, query ?? "");
|
|
450
|
+
const items = query?.trim() ? found.slice(0, MATCHES).map(([command, one]) => ({
|
|
451
|
+
command,
|
|
452
|
+
title: one.title,
|
|
453
|
+
description: one.description,
|
|
454
|
+
writes: one.writes,
|
|
455
|
+
availability: one.availability?.() ?? { available: true },
|
|
456
|
+
arguments: toJsonSchema(one.input),
|
|
457
|
+
output: toJsonSchema(one.output ?? ANSWER)
|
|
458
|
+
})) : found.map(([command, one]) => ({
|
|
459
|
+
command,
|
|
460
|
+
title: one.title,
|
|
461
|
+
writes: one.writes,
|
|
462
|
+
availability: one.availability?.() ?? { available: true }
|
|
463
|
+
}));
|
|
464
|
+
const { next: _paging, ...list } = listOf(`${prefix}_tools_search`, {
|
|
465
|
+
items,
|
|
466
|
+
limit: Math.max(items.length, query?.trim() ? MATCHES : 1),
|
|
467
|
+
has_more: found.length > items.length
|
|
468
|
+
});
|
|
469
|
+
return answered(list);
|
|
470
|
+
});
|
|
471
|
+
const callers = {
|
|
472
|
+
env: process.env,
|
|
473
|
+
client: /* @__PURE__ */ __name(() => server.server.getClientVersion(), "client"),
|
|
474
|
+
connectionId: randomUUID()
|
|
475
|
+
};
|
|
476
|
+
const runner = /* @__PURE__ */ __name((writing) => async ({ command: asked, arguments: given }, ctx) => {
|
|
477
|
+
try {
|
|
478
|
+
const command = byNormal.get(normal(asked));
|
|
479
|
+
const one = command === void 0 ? void 0 : commands[command];
|
|
480
|
+
if (command === void 0 || !one) {
|
|
481
|
+
withheld?.(normal(asked));
|
|
482
|
+
const near = nearest(commands, asked);
|
|
483
|
+
throw new CliError("validation_error", `no command "${asked}" here${near.length ? ` \u2014 did you mean ${near.map((name) => `"${name}"`).join(", ")}?` : ""}; ${prefix}_tools_search finds one`);
|
|
484
|
+
}
|
|
485
|
+
if (one.writes !== writing)
|
|
486
|
+
throw new CliError("validation_error", `"${command}" ${writing ? "only reads" : "writes"}: call it with ${prefix}_${writing ? "read" : "write"}`);
|
|
487
|
+
const args = writing ? agentArguments(given ?? {}) : given ?? {};
|
|
488
|
+
const caller = currentCaller() ?? callerOf(ctx, command.replace(/[ -]/g, "_"), callers);
|
|
489
|
+
if (one.checked)
|
|
490
|
+
return runnableOnly(await withCaller(caller, () => one.run(args, ctx)), (named) => byNormal.has(normal(named)));
|
|
491
|
+
const parsed = safeParse(strictObject(one.input.entries), args);
|
|
492
|
+
if (!parsed.success)
|
|
493
|
+
throw new CliError("validation_error", `${command}: ${summarize(parsed.issues)}`, {
|
|
494
|
+
arguments: toJsonSchema(one.input)
|
|
495
|
+
});
|
|
496
|
+
return runnableOnly(await withCaller(caller, () => one.run(parsed.output, ctx)), (named) => byNormal.has(normal(named)));
|
|
497
|
+
} catch (error) {
|
|
498
|
+
return failed(error, errors);
|
|
499
|
+
}
|
|
500
|
+
}, "runner");
|
|
501
|
+
const call = strictObject({
|
|
502
|
+
command: pipe(string(), minLength(1), description(`a command ${prefix}_tools_search returned: "${sample}"`)),
|
|
503
|
+
arguments: optional(pipe(record(string(), unknown()), description("that command's arguments")))
|
|
504
|
+
});
|
|
505
|
+
server.registerTool(`${prefix}_read`, {
|
|
506
|
+
outputSchema: listedAs(prefix, false),
|
|
507
|
+
title: "Run a reading command",
|
|
508
|
+
description: `Run one command that only reads, with the arguments ${prefix}_tools_search showed. ${untrusted}`,
|
|
509
|
+
inputSchema: toStandardJsonSchema(call),
|
|
510
|
+
annotations: READ
|
|
511
|
+
}, runner(false));
|
|
512
|
+
if (Object.values(commands).some((one) => one.writes))
|
|
513
|
+
server.registerTool(`${prefix}_write`, {
|
|
514
|
+
outputSchema: listedAs(prefix, true),
|
|
515
|
+
title: "Run a writing command",
|
|
516
|
+
description: `Run one command that changes something \u2014 ${messenger ? "sends, edits, deletes, joins" : "creates, edits, deletes"} \u2014 with the arguments ${prefix}_tools_search showed. ${untrusted}`,
|
|
517
|
+
inputSchema: toStandardJsonSchema(call),
|
|
518
|
+
annotations: WRITE
|
|
519
|
+
}, runner(true));
|
|
520
|
+
}, "registerCommands");
|
|
521
|
+
var surfaceCommands = /* @__PURE__ */ __name((tools, registration) => {
|
|
522
|
+
const run = entryRunner(registration);
|
|
523
|
+
return Object.fromEntries(Object.entries(tools).map(([key, definition]) => [
|
|
524
|
+
commandOf(key, definition),
|
|
525
|
+
{
|
|
526
|
+
title: definition.title,
|
|
527
|
+
description: definition.description,
|
|
528
|
+
writes: definition.annotations.readOnlyHint !== true,
|
|
529
|
+
input: inputOf(definition, syncAllowedFor(key, registration.defaults)),
|
|
530
|
+
...definition.output ? { output: outputSchemaOf(definition) } : {},
|
|
531
|
+
checked: true,
|
|
532
|
+
run: /* @__PURE__ */ __name((args, ctx) => run(key, definition, args, ctx), "run")
|
|
533
|
+
}
|
|
534
|
+
]));
|
|
535
|
+
}, "surfaceCommands");
|
|
536
|
+
var outputOf = /* @__PURE__ */ __name(({ entity, view }) => answerSchema(ENTITIES[view ? `${entity}.${view}` : entity] ?? unknown()), "outputOf");
|
|
537
|
+
|
|
538
|
+
export {
|
|
539
|
+
message,
|
|
540
|
+
READ,
|
|
541
|
+
WRITE,
|
|
542
|
+
tool,
|
|
543
|
+
chatOf,
|
|
544
|
+
tierOf,
|
|
545
|
+
outcomeOf,
|
|
546
|
+
commandOf,
|
|
547
|
+
toolKey,
|
|
548
|
+
Picture,
|
|
549
|
+
BinaryResource,
|
|
550
|
+
answered,
|
|
551
|
+
failed,
|
|
552
|
+
normal,
|
|
553
|
+
search,
|
|
554
|
+
registerCommands,
|
|
555
|
+
surfaceCommands,
|
|
556
|
+
outputOf
|
|
557
|
+
};
|