@wirecat/attio-cli 0.8.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (207) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/contracts/wirecat.json +1 -0
  3. package/dist/bin/attio.js +11 -11
  4. package/dist/bundle/attio.js +5 -166
  5. package/dist/bundle/{chunk-UXJZISVL.js → chunk-OGWKDPR5.js} +2 -1
  6. package/dist/bundle/chunk-TQAECZFO.js +13 -0
  7. package/dist/bundle/{definitions-FODOIPM2.js → definitions-J73IBAHT.js} +1 -1
  8. package/dist/bundle/program-NSBWZ25F.js +6201 -0
  9. package/dist/bundle/{schemas-YGSTNU6F.js → schemas-G3HFAS45.js} +576 -29
  10. package/dist/commands/api.js +1 -2
  11. package/dist/commands/crm.js +1 -4
  12. package/dist/commands/schedule.js +1 -1
  13. package/dist/commands/session.js +1 -2
  14. package/dist/config.js +1 -2
  15. package/dist/context.js +1 -1
  16. package/dist/identity.js +1 -0
  17. package/dist/program.js +1 -2
  18. package/dist/version.js +1 -1
  19. package/package.json +4 -4
  20. package/dist/activities.d.ts +0 -4
  21. package/dist/activities.d.ts.map +0 -1
  22. package/dist/activities.js.map +0 -1
  23. package/dist/bin/attio.d.ts +0 -3
  24. package/dist/bin/attio.d.ts.map +0 -1
  25. package/dist/bin/attio.js.map +0 -1
  26. package/dist/bundle/agent-GUXXSLT5.js +0 -38
  27. package/dist/bundle/all-profiles-63N3EQ46.js +0 -320
  28. package/dist/bundle/anthropic-B4W7MZQE.js +0 -91
  29. package/dist/bundle/app-server-EXNGTHWO.js +0 -250
  30. package/dist/bundle/bun-OPDGMZZQ.js +0 -169
  31. package/dist/bundle/bun-sqlite-NBAY7FR2.js +0 -76
  32. package/dist/bundle/chunk-2JHVQMVC.js +0 -16
  33. package/dist/bundle/chunk-2QDUP74I.js +0 -794
  34. package/dist/bundle/chunk-2XBDILVW.js +0 -53
  35. package/dist/bundle/chunk-3HC5F3P7.js +0 -24
  36. package/dist/bundle/chunk-3MSHGNVE.js +0 -1243
  37. package/dist/bundle/chunk-3YM4B2GT.js +0 -63
  38. package/dist/bundle/chunk-4N7PP76S.js +0 -6848
  39. package/dist/bundle/chunk-4RBMCXZT.js +0 -1337
  40. package/dist/bundle/chunk-4RSWOPKL.js +0 -323
  41. package/dist/bundle/chunk-5JKTVAXX.js +0 -2788
  42. package/dist/bundle/chunk-5N2V6XO7.js +0 -119
  43. package/dist/bundle/chunk-5WD22IXQ.js +0 -66
  44. package/dist/bundle/chunk-6K4Z6CAM.js +0 -43997
  45. package/dist/bundle/chunk-6TD3DCWC.js +0 -106
  46. package/dist/bundle/chunk-7Z53MLQP.js +0 -388
  47. package/dist/bundle/chunk-AATTOFNY.js +0 -2045
  48. package/dist/bundle/chunk-APARYILG.js +0 -743
  49. package/dist/bundle/chunk-D72URWJE.js +0 -532
  50. package/dist/bundle/chunk-DFDN6AUB.js +0 -21
  51. package/dist/bundle/chunk-DM7KWVDZ.js +0 -3752
  52. package/dist/bundle/chunk-DNCLQPOM.js +0 -7
  53. package/dist/bundle/chunk-DPD4FMHN.js +0 -388
  54. package/dist/bundle/chunk-DPV53EZC.js +0 -206
  55. package/dist/bundle/chunk-DURNR4RO.js +0 -353
  56. package/dist/bundle/chunk-EH6ZEJGT.js +0 -932
  57. package/dist/bundle/chunk-EVUMQKV7.js +0 -76
  58. package/dist/bundle/chunk-EY36BTKZ.js +0 -108
  59. package/dist/bundle/chunk-FH6OEGGN.js +0 -557
  60. package/dist/bundle/chunk-FOP6G45D.js +0 -358
  61. package/dist/bundle/chunk-GGMAIIVE.js +0 -38
  62. package/dist/bundle/chunk-GTEX4IUO.js +0 -334
  63. package/dist/bundle/chunk-HZ3C4WXD.js +0 -142
  64. package/dist/bundle/chunk-IA7LLLEI.js +0 -100
  65. package/dist/bundle/chunk-J6GVVISK.js +0 -185
  66. package/dist/bundle/chunk-JG6LCSEX.js +0 -407
  67. package/dist/bundle/chunk-JIGEJZ4I.js +0 -68943
  68. package/dist/bundle/chunk-KVTNYRDO.js +0 -1007
  69. package/dist/bundle/chunk-L45WN3AR.js +0 -80
  70. package/dist/bundle/chunk-L72WUJAS.js +0 -54
  71. package/dist/bundle/chunk-LKH3UKLO.js +0 -230
  72. package/dist/bundle/chunk-LM3W7YOM.js +0 -274
  73. package/dist/bundle/chunk-M4AC55ZB.js +0 -12733
  74. package/dist/bundle/chunk-MCLQTCGH.js +0 -1202
  75. package/dist/bundle/chunk-NB7EOAUZ.js +0 -123
  76. package/dist/bundle/chunk-NISH4UXM.js +0 -58
  77. package/dist/bundle/chunk-OYEVYOCL.js +0 -259
  78. package/dist/bundle/chunk-P7G5HFY3.js +0 -288
  79. package/dist/bundle/chunk-PAEKXVJW.js +0 -188
  80. package/dist/bundle/chunk-PL5P7UKW.js +0 -25216
  81. package/dist/bundle/chunk-PLPBEWD4.js +0 -170
  82. package/dist/bundle/chunk-PMQ7GP6X.js +0 -95
  83. package/dist/bundle/chunk-Q7ICVP25.js +0 -18
  84. package/dist/bundle/chunk-QPPOIWPY.js +0 -1246
  85. package/dist/bundle/chunk-QSJKSPWF.js +0 -131
  86. package/dist/bundle/chunk-RDVTHFPP.js +0 -338
  87. package/dist/bundle/chunk-RQORQN2V.js +0 -4072
  88. package/dist/bundle/chunk-RRTMPSQR.js +0 -29
  89. package/dist/bundle/chunk-S4UUN6LD.js +0 -1410
  90. package/dist/bundle/chunk-S6JG4YUH.js +0 -72
  91. package/dist/bundle/chunk-SCI7QEHF.js +0 -362
  92. package/dist/bundle/chunk-SSA6JBPA.js +0 -778
  93. package/dist/bundle/chunk-T4J7XFXT.js +0 -9667
  94. package/dist/bundle/chunk-TTF5DP4V.js +0 -1197
  95. package/dist/bundle/chunk-TXDR6YSF.js +0 -23
  96. package/dist/bundle/chunk-TY7NDMFY.js +0 -46
  97. package/dist/bundle/chunk-UDSL3MUU.js +0 -2333
  98. package/dist/bundle/chunk-UKHF37ZU.js +0 -1068
  99. package/dist/bundle/chunk-V57E7PJQ.js +0 -161
  100. package/dist/bundle/chunk-V7IF2K3P.js +0 -52
  101. package/dist/bundle/chunk-VB7FZOYX.js +0 -633
  102. package/dist/bundle/chunk-VZ5PPYDG.js +0 -77
  103. package/dist/bundle/chunk-WOPVBRPV.js +0 -29
  104. package/dist/bundle/chunk-WXQGA6XK.js +0 -50
  105. package/dist/bundle/chunk-XQGN2D44.js +0 -86
  106. package/dist/bundle/chunk-XQUUANA2.js +0 -24600
  107. package/dist/bundle/chunk-Y5E2WNWB.js +0 -35
  108. package/dist/bundle/chunk-YNGU36GW.js +0 -218
  109. package/dist/bundle/chunk-YWDFYQOU.js +0 -82
  110. package/dist/bundle/chunk-ZVVMGPBJ.js +0 -50
  111. package/dist/bundle/chunk-ZZD2YPOX.js +0 -156
  112. package/dist/bundle/command-contract-KCCW4LNI.js +0 -37
  113. package/dist/bundle/command-server-entry-3NPPABQQ.js +0 -166
  114. package/dist/bundle/decode-26M7XE2B.js +0 -297
  115. package/dist/bundle/dispatch-2FTOHA5D.js +0 -411
  116. package/dist/bundle/dist-EM7KLEG4.js +0 -7577
  117. package/dist/bundle/dist-PAKDDIBT.js +0 -191
  118. package/dist/bundle/echarts-O3TNDAXJ.js +0 -42501
  119. package/dist/bundle/embed-XJLEAWXE.js +0 -38
  120. package/dist/bundle/embedder-OEL6PXEH.js +0 -111
  121. package/dist/bundle/failure-OHIXWTR6.js +0 -25
  122. package/dist/bundle/first-run-CIXGBXY6.js +0 -29
  123. package/dist/bundle/first-screen-5FK4D45F.js +0 -38
  124. package/dist/bundle/instructions-AMH5RWVJ.js +0 -11
  125. package/dist/bundle/mcp-5HFPWC3W.js +0 -167
  126. package/dist/bundle/meeting-combined-DMVGQNJ7.js +0 -24
  127. package/dist/bundle/meeting-model-2THAT7OH.js +0 -25
  128. package/dist/bundle/meeting-semantic-Q6XYFYUD.js +0 -22
  129. package/dist/bundle/node-EGMCBAO7.js +0 -176
  130. package/dist/bundle/node-KM3CUABH.js +0 -2340
  131. package/dist/bundle/node-TLZSIHIJ.js +0 -21
  132. package/dist/bundle/node-sqlite-2SWWGW6H.js +0 -74
  133. package/dist/bundle/oauth-V5LGTXF2.js +0 -20
  134. package/dist/bundle/open-25EKOTZA.js +0 -23
  135. package/dist/bundle/openai-VX3OLIHM.js +0 -238
  136. package/dist/bundle/process-SGHEN6MQ.js +0 -91
  137. package/dist/bundle/program-Z5NUNXME.js +0 -34214
  138. package/dist/bundle/prompt-2VSPX5S7.js +0 -17
  139. package/dist/bundle/recognize-NA5XUFKK.js +0 -26
  140. package/dist/bundle/remote-BOME6XOE.js +0 -31
  141. package/dist/bundle/rerank-NG3XMFCV.js +0 -52
  142. package/dist/bundle/serve-MR67OBED.js +0 -199
  143. package/dist/bundle/server-4BWAGJQO.js +0 -80
  144. package/dist/bundle/server-OP2HJNXD.js +0 -213
  145. package/dist/bundle/sqlite-runtime-V5U6F5EB.js +0 -20
  146. package/dist/bundle/state-L4MWAATO.js +0 -36
  147. package/dist/bundle/store-2ALTEH55.js +0 -181
  148. package/dist/bundle/store-CXZFRG5D.js +0 -297
  149. package/dist/bundle/store-maintenance-command-LC55DRQA.js +0 -67
  150. package/dist/bundle/surface-3GRJ7473.js +0 -66
  151. package/dist/commands/api.d.ts +0 -12
  152. package/dist/commands/api.d.ts.map +0 -1
  153. package/dist/commands/api.js.map +0 -1
  154. package/dist/commands/crm.d.ts +0 -7
  155. package/dist/commands/crm.d.ts.map +0 -1
  156. package/dist/commands/crm.js.map +0 -1
  157. package/dist/commands/schedule.d.ts +0 -3
  158. package/dist/commands/schedule.d.ts.map +0 -1
  159. package/dist/commands/schedule.js.map +0 -1
  160. package/dist/commands/session.d.ts +0 -8
  161. package/dist/commands/session.d.ts.map +0 -1
  162. package/dist/commands/session.js.map +0 -1
  163. package/dist/config.d.ts +0 -13
  164. package/dist/config.d.ts.map +0 -1
  165. package/dist/config.js.map +0 -1
  166. package/dist/context.d.ts +0 -37
  167. package/dist/context.d.ts.map +0 -1
  168. package/dist/context.js.map +0 -1
  169. package/dist/generated/definitions.d.ts +0 -3
  170. package/dist/generated/definitions.d.ts.map +0 -1
  171. package/dist/generated/definitions.js.map +0 -1
  172. package/dist/generated/manifest.d.ts +0 -6
  173. package/dist/generated/manifest.d.ts.map +0 -1
  174. package/dist/generated/manifest.js.map +0 -1
  175. package/dist/generated/schemas.d.ts +0 -383
  176. package/dist/generated/schemas.d.ts.map +0 -1
  177. package/dist/generated/schemas.js.map +0 -1
  178. package/dist/generated/types.d.ts +0 -10166
  179. package/dist/generated/types.d.ts.map +0 -1
  180. package/dist/generated/types.js.map +0 -1
  181. package/dist/generated/wirecat-config.d.ts +0 -15
  182. package/dist/generated/wirecat-config.d.ts.map +0 -1
  183. package/dist/generated/wirecat-config.js.map +0 -1
  184. package/dist/hooks.d.ts +0 -33
  185. package/dist/hooks.d.ts.map +0 -1
  186. package/dist/hooks.js.map +0 -1
  187. package/dist/identity.d.ts +0 -33
  188. package/dist/identity.d.ts.map +0 -1
  189. package/dist/identity.js.map +0 -1
  190. package/dist/index.d.ts +0 -3
  191. package/dist/index.d.ts.map +0 -1
  192. package/dist/index.js.map +0 -1
  193. package/dist/links.d.ts +0 -10
  194. package/dist/links.d.ts.map +0 -1
  195. package/dist/links.js.map +0 -1
  196. package/dist/meetings.d.ts +0 -57
  197. package/dist/meetings.d.ts.map +0 -1
  198. package/dist/meetings.js.map +0 -1
  199. package/dist/program.d.ts +0 -6
  200. package/dist/program.d.ts.map +0 -1
  201. package/dist/program.js.map +0 -1
  202. package/dist/version.d.ts +0 -2
  203. package/dist/version.d.ts.map +0 -1
  204. package/dist/version.js.map +0 -1
  205. package/dist/wcat.d.ts +0 -3
  206. package/dist/wcat.d.ts.map +0 -1
  207. package/dist/wcat.js.map +0 -1
@@ -1,557 +0,0 @@
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-MCLQTCGH.js";
10
- import {
11
- onlineDeps,
12
- refuseLacking,
13
- servicesFor,
14
- storeModeDeps
15
- } from "./chunk-6K4Z6CAM.js";
16
- import {
17
- callerOf
18
- } from "./chunk-EY36BTKZ.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-M4AC55ZB.js";
36
- import {
37
- currentCaller,
38
- keepsSuccess,
39
- runContextOf,
40
- withCaller
41
- } from "./chunk-SCI7QEHF.js";
42
- import {
43
- MAX_BUFFERED_INPUT
44
- } from "./chunk-YWDFYQOU.js";
45
- import {
46
- inRun,
47
- newRunId
48
- } from "./chunk-AATTOFNY.js";
49
- import {
50
- storeDamaged
51
- } from "./chunk-ZZD2YPOX.js";
52
- import {
53
- traceIdOf
54
- } from "./chunk-5JKTVAXX.js";
55
- import {
56
- errorObjectOf,
57
- itemEnvelopeSchema,
58
- listEnvelopeSchema,
59
- mcpErrorResult,
60
- toJsonSchema,
61
- toStandardJsonSchema
62
- } from "./chunk-QPPOIWPY.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-S6JG4YUH.js";
88
- import {
89
- __name
90
- } from "./chunk-ZVVMGPBJ.js";
91
-
92
- // node_modules/.pnpm/@wirecat+cli-core@1.0.0_@wirecat+cli-base@1.0.0_commander@15.0.0_esbuild@0.28.2_typescr_dd5172c52281f8f1e2dd1d4e9555d5c3/node_modules/@wirecat/cli-core/dist/mcp/surface.js
93
- import { randomUUID } from "node:crypto";
94
-
95
- // node_modules/.pnpm/@wirecat+cli-core@1.0.0_@wirecat+cli-base@1.0.0_commander@15.0.0_esbuild@0.28.2_typescr_dd5172c52281f8f1e2dd1d4e9555d5c3/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@1.0.0_@wirecat+cli-base@1.0.0_commander@15.0.0_esbuild@0.28.2_typescr_dd5172c52281f8f1e2dd1d4e9555d5c3/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
- };