@getcliqio/cliq-sdk 0.0.0-stage → 1.15.32

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 (338) hide show
  1. package/README.md +28 -2
  2. package/dist/agent_api.d.ts +39 -0
  3. package/dist/agent_api.d.ts.map +1 -0
  4. package/dist/agent_api.js +105 -0
  5. package/dist/agent_api.js.map +1 -0
  6. package/dist/agent_manifest.d.ts +162 -0
  7. package/dist/agent_manifest.d.ts.map +1 -0
  8. package/dist/agent_manifest.js +242 -0
  9. package/dist/agent_manifest.js.map +1 -0
  10. package/dist/agent_payloads.d.ts +103 -0
  11. package/dist/agent_payloads.d.ts.map +1 -0
  12. package/dist/agent_payloads.js +56 -0
  13. package/dist/agent_payloads.js.map +1 -0
  14. package/dist/agents/base_agent.d.ts +113 -0
  15. package/dist/agents/base_agent.d.ts.map +1 -0
  16. package/dist/agents/base_agent.js +413 -0
  17. package/dist/agents/base_agent.js.map +1 -0
  18. package/dist/agents/cli_agent.d.ts +98 -0
  19. package/dist/agents/cli_agent.d.ts.map +1 -0
  20. package/dist/agents/cli_agent.js +303 -0
  21. package/dist/agents/cli_agent.js.map +1 -0
  22. package/dist/agents/cli_rehydrate.d.ts +29 -0
  23. package/dist/agents/cli_rehydrate.d.ts.map +1 -0
  24. package/dist/agents/cli_rehydrate.js +32 -0
  25. package/dist/agents/cli_rehydrate.js.map +1 -0
  26. package/dist/agents/connector_agent.d.ts +20 -0
  27. package/dist/agents/connector_agent.d.ts.map +1 -0
  28. package/dist/agents/connector_agent.js +110 -0
  29. package/dist/agents/connector_agent.js.map +1 -0
  30. package/dist/agents/event_artifacts.d.ts +33 -0
  31. package/dist/agents/event_artifacts.d.ts.map +1 -0
  32. package/dist/agents/event_artifacts.js +73 -0
  33. package/dist/agents/event_artifacts.js.map +1 -0
  34. package/dist/agents/gate_agent.d.ts +40 -0
  35. package/dist/agents/gate_agent.d.ts.map +1 -0
  36. package/dist/agents/gate_agent.js +121 -0
  37. package/dist/agents/gate_agent.js.map +1 -0
  38. package/dist/agents/index.d.ts +32 -0
  39. package/dist/agents/index.d.ts.map +1 -0
  40. package/dist/agents/index.js +26 -0
  41. package/dist/agents/index.js.map +1 -0
  42. package/dist/agents/llm_agent.d.ts +109 -0
  43. package/dist/agents/llm_agent.d.ts.map +1 -0
  44. package/dist/agents/llm_agent.js +285 -0
  45. package/dist/agents/llm_agent.js.map +1 -0
  46. package/dist/agents/llm_contract.d.ts +7 -0
  47. package/dist/agents/llm_contract.d.ts.map +1 -0
  48. package/dist/agents/llm_contract.js +7 -0
  49. package/dist/agents/llm_contract.js.map +1 -0
  50. package/dist/agents/standard_agent.d.ts +15 -0
  51. package/dist/agents/standard_agent.d.ts.map +1 -0
  52. package/dist/agents/standard_agent.js +34 -0
  53. package/dist/agents/standard_agent.js.map +1 -0
  54. package/dist/agents/turn_result.d.ts +67 -0
  55. package/dist/agents/turn_result.d.ts.map +1 -0
  56. package/dist/agents/turn_result.js +81 -0
  57. package/dist/agents/turn_result.js.map +1 -0
  58. package/dist/agents/types.d.ts +314 -0
  59. package/dist/agents/types.d.ts.map +1 -0
  60. package/dist/agents/types.js +20 -0
  61. package/dist/agents/types.js.map +1 -0
  62. package/dist/builtin_teams/hello_hug.d.ts +9 -0
  63. package/dist/builtin_teams/hello_hug.d.ts.map +1 -0
  64. package/dist/builtin_teams/hello_hug.js +68 -0
  65. package/dist/builtin_teams/hello_hug.js.map +1 -0
  66. package/dist/builtin_teams/hello_world.d.ts +8 -0
  67. package/dist/builtin_teams/hello_world.d.ts.map +1 -0
  68. package/dist/builtin_teams/hello_world.js +65 -0
  69. package/dist/builtin_teams/hello_world.js.map +1 -0
  70. package/dist/builtin_teams/hug_example.d.ts +10 -0
  71. package/dist/builtin_teams/hug_example.d.ts.map +1 -0
  72. package/dist/builtin_teams/hug_example.js +94 -0
  73. package/dist/builtin_teams/hug_example.js.map +1 -0
  74. package/dist/builtin_teams/index.d.ts +12 -0
  75. package/dist/builtin_teams/index.d.ts.map +1 -0
  76. package/dist/builtin_teams/index.js +18 -0
  77. package/dist/builtin_teams/index.js.map +1 -0
  78. package/dist/builtin_teams/types.d.ts +29 -0
  79. package/dist/builtin_teams/types.d.ts.map +1 -0
  80. package/dist/builtin_teams/types.js +3 -0
  81. package/dist/builtin_teams/types.js.map +1 -0
  82. package/dist/core_api_client.d.ts +48 -0
  83. package/dist/core_api_client.d.ts.map +1 -0
  84. package/dist/core_api_client.js +132 -0
  85. package/dist/core_api_client.js.map +1 -0
  86. package/dist/daemon_wire.d.ts +122 -0
  87. package/dist/daemon_wire.d.ts.map +1 -0
  88. package/dist/daemon_wire.js +105 -0
  89. package/dist/daemon_wire.js.map +1 -0
  90. package/dist/events/catalog.d.ts +40 -0
  91. package/dist/events/catalog.d.ts.map +1 -0
  92. package/dist/events/catalog.js +76 -0
  93. package/dist/events/catalog.js.map +1 -0
  94. package/dist/http_daemon_client.d.ts +136 -0
  95. package/dist/http_daemon_client.d.ts.map +1 -0
  96. package/dist/http_daemon_client.js +192 -0
  97. package/dist/http_daemon_client.js.map +1 -0
  98. package/dist/hug/ask.d.ts +160 -0
  99. package/dist/hug/ask.d.ts.map +1 -0
  100. package/dist/hug/ask.js +318 -0
  101. package/dist/hug/ask.js.map +1 -0
  102. package/dist/hug/attach.d.ts +60 -0
  103. package/dist/hug/attach.d.ts.map +1 -0
  104. package/dist/hug/attach.js +103 -0
  105. package/dist/hug/attach.js.map +1 -0
  106. package/dist/hug/bridge/index.d.ts +16 -0
  107. package/dist/hug/bridge/index.d.ts.map +1 -0
  108. package/dist/hug/bridge/index.js +13 -0
  109. package/dist/hug/bridge/index.js.map +1 -0
  110. package/dist/hug/bridge/messages.d.ts +559 -0
  111. package/dist/hug/bridge/messages.d.ts.map +1 -0
  112. package/dist/hug/bridge/messages.js +165 -0
  113. package/dist/hug/bridge/messages.js.map +1 -0
  114. package/dist/hug/client.d.ts +70 -0
  115. package/dist/hug/client.d.ts.map +1 -0
  116. package/dist/hug/client.js +144 -0
  117. package/dist/hug/client.js.map +1 -0
  118. package/dist/hug/context.d.ts +54 -0
  119. package/dist/hug/context.d.ts.map +1 -0
  120. package/dist/hug/context.js +27 -0
  121. package/dist/hug/context.js.map +1 -0
  122. package/dist/hug/define.d.ts +116 -0
  123. package/dist/hug/define.d.ts.map +1 -0
  124. package/dist/hug/define.js +119 -0
  125. package/dist/hug/define.js.map +1 -0
  126. package/dist/hug/definitions/approval.d.ts +216 -0
  127. package/dist/hug/definitions/approval.d.ts.map +1 -0
  128. package/dist/hug/definitions/approval.js +50 -0
  129. package/dist/hug/definitions/approval.js.map +1 -0
  130. package/dist/hug/definitions/common.d.ts +122 -0
  131. package/dist/hug/definitions/common.d.ts.map +1 -0
  132. package/dist/hug/definitions/common.js +70 -0
  133. package/dist/hug/definitions/common.js.map +1 -0
  134. package/dist/hug/definitions/form.d.ts +197 -0
  135. package/dist/hug/definitions/form.d.ts.map +1 -0
  136. package/dist/hug/definitions/form.js +29 -0
  137. package/dist/hug/definitions/form.js.map +1 -0
  138. package/dist/hug/definitions/index.d.ts +10 -0
  139. package/dist/hug/definitions/index.d.ts.map +1 -0
  140. package/dist/hug/definitions/index.js +8 -0
  141. package/dist/hug/definitions/index.js.map +1 -0
  142. package/dist/hug/errors.d.ts +30 -0
  143. package/dist/hug/errors.d.ts.map +1 -0
  144. package/dist/hug/errors.js +46 -0
  145. package/dist/hug/errors.js.map +1 -0
  146. package/dist/hug/file_checks.d.ts +41 -0
  147. package/dist/hug/file_checks.d.ts.map +1 -0
  148. package/dist/hug/file_checks.js +105 -0
  149. package/dist/hug/file_checks.js.map +1 -0
  150. package/dist/hug/files.d.ts +137 -0
  151. package/dist/hug/files.d.ts.map +1 -0
  152. package/dist/hug/files.js +283 -0
  153. package/dist/hug/files.js.map +1 -0
  154. package/dist/hug/hug_bundle.d.ts +70 -0
  155. package/dist/hug/hug_bundle.d.ts.map +1 -0
  156. package/dist/hug/hug_bundle.js +299 -0
  157. package/dist/hug/hug_bundle.js.map +1 -0
  158. package/dist/hug/hug_catalog.d.ts +38 -0
  159. package/dist/hug/hug_catalog.d.ts.map +1 -0
  160. package/dist/hug/hug_catalog.js +67 -0
  161. package/dist/hug/hug_catalog.js.map +1 -0
  162. package/dist/hug/hug_definitions.d.ts +32 -0
  163. package/dist/hug/hug_definitions.d.ts.map +1 -0
  164. package/dist/hug/hug_definitions.js +74 -0
  165. package/dist/hug/hug_definitions.js.map +1 -0
  166. package/dist/hug/index.d.ts +37 -0
  167. package/dist/hug/index.d.ts.map +1 -0
  168. package/dist/hug/index.js +23 -0
  169. package/dist/hug/index.js.map +1 -0
  170. package/dist/hug/llm.d.ts +106 -0
  171. package/dist/hug/llm.d.ts.map +1 -0
  172. package/dist/hug/llm.js +250 -0
  173. package/dist/hug/llm.js.map +1 -0
  174. package/dist/hug/policies.d.ts +65 -0
  175. package/dist/hug/policies.d.ts.map +1 -0
  176. package/dist/hug/policies.js +80 -0
  177. package/dist/hug/policies.js.map +1 -0
  178. package/dist/hug/problems.d.ts +35 -0
  179. package/dist/hug/problems.d.ts.map +1 -0
  180. package/dist/hug/problems.js +53 -0
  181. package/dist/hug/problems.js.map +1 -0
  182. package/dist/hug/requested_inputs.d.ts +190 -0
  183. package/dist/hug/requested_inputs.d.ts.map +1 -0
  184. package/dist/hug/requested_inputs.js +220 -0
  185. package/dist/hug/requested_inputs.js.map +1 -0
  186. package/dist/hug/schema_for_inputs.d.ts +20 -0
  187. package/dist/hug/schema_for_inputs.d.ts.map +1 -0
  188. package/dist/hug/schema_for_inputs.js +95 -0
  189. package/dist/hug/schema_for_inputs.js.map +1 -0
  190. package/dist/hug/session.d.ts +113 -0
  191. package/dist/hug/session.d.ts.map +1 -0
  192. package/dist/hug/session.js +210 -0
  193. package/dist/hug/session.js.map +1 -0
  194. package/dist/hug/types.d.ts +141 -0
  195. package/dist/hug/types.d.ts.map +1 -0
  196. package/dist/hug/types.js +80 -0
  197. package/dist/hug/types.js.map +1 -0
  198. package/dist/index.d.ts +72 -0
  199. package/dist/index.d.ts.map +1 -0
  200. package/dist/index.js +54 -0
  201. package/dist/index.js.map +1 -0
  202. package/dist/logging.d.ts +172 -0
  203. package/dist/logging.d.ts.map +1 -0
  204. package/dist/logging.js +306 -0
  205. package/dist/logging.js.map +1 -0
  206. package/dist/mcp.d.ts +119 -0
  207. package/dist/mcp.d.ts.map +1 -0
  208. package/dist/mcp.js +259 -0
  209. package/dist/mcp.js.map +1 -0
  210. package/dist/mcp_client.d.ts +145 -0
  211. package/dist/mcp_client.d.ts.map +1 -0
  212. package/dist/mcp_client.js +374 -0
  213. package/dist/mcp_client.js.map +1 -0
  214. package/dist/paths.d.ts +20 -0
  215. package/dist/paths.d.ts.map +1 -0
  216. package/dist/paths.js +20 -0
  217. package/dist/paths.js.map +1 -0
  218. package/dist/protocol/factory.d.ts +32 -0
  219. package/dist/protocol/factory.d.ts.map +1 -0
  220. package/dist/protocol/factory.js +31 -0
  221. package/dist/protocol/factory.js.map +1 -0
  222. package/dist/protocol/framing.d.ts +35 -0
  223. package/dist/protocol/framing.d.ts.map +1 -0
  224. package/dist/protocol/framing.js +73 -0
  225. package/dist/protocol/framing.js.map +1 -0
  226. package/dist/protocol/index.d.ts +13 -0
  227. package/dist/protocol/index.d.ts.map +1 -0
  228. package/dist/protocol/index.js +13 -0
  229. package/dist/protocol/index.js.map +1 -0
  230. package/dist/protocol/types/agent.d.ts +42 -0
  231. package/dist/protocol/types/agent.d.ts.map +1 -0
  232. package/dist/protocol/types/agent.js +9 -0
  233. package/dist/protocol/types/agent.js.map +1 -0
  234. package/dist/protocol/types/cliq_core.d.ts +79 -0
  235. package/dist/protocol/types/cliq_core.d.ts.map +1 -0
  236. package/dist/protocol/types/cliq_core.js +17 -0
  237. package/dist/protocol/types/cliq_core.js.map +1 -0
  238. package/dist/protocol/types/foundations.d.ts +41 -0
  239. package/dist/protocol/types/foundations.d.ts.map +1 -0
  240. package/dist/protocol/types/foundations.js +10 -0
  241. package/dist/protocol/types/foundations.js.map +1 -0
  242. package/dist/protocol/types/index.d.ts +32 -0
  243. package/dist/protocol/types/index.d.ts.map +1 -0
  244. package/dist/protocol/types/index.js +27 -0
  245. package/dist/protocol/types/index.js.map +1 -0
  246. package/dist/protocol/types/messages.d.ts +827 -0
  247. package/dist/protocol/types/messages.d.ts.map +1 -0
  248. package/dist/protocol/types/messages.js +117 -0
  249. package/dist/protocol/types/messages.js.map +1 -0
  250. package/dist/protocol/types/pipeline.d.ts +122 -0
  251. package/dist/protocol/types/pipeline.d.ts.map +1 -0
  252. package/dist/protocol/types/pipeline.js +16 -0
  253. package/dist/protocol/types/pipeline.js.map +1 -0
  254. package/dist/protocol/types/schemas.d.ts +814 -0
  255. package/dist/protocol/types/schemas.d.ts.map +1 -0
  256. package/dist/protocol/types/schemas.js +772 -0
  257. package/dist/protocol/types/schemas.js.map +1 -0
  258. package/dist/protocol/types/team.d.ts +42 -0
  259. package/dist/protocol/types/team.d.ts.map +1 -0
  260. package/dist/protocol/types/team.js +15 -0
  261. package/dist/protocol/types/team.js.map +1 -0
  262. package/dist/protocol/types/workspace.d.ts +46 -0
  263. package/dist/protocol/types/workspace.d.ts.map +1 -0
  264. package/dist/protocol/types/workspace.js +9 -0
  265. package/dist/protocol/types/workspace.js.map +1 -0
  266. package/dist/settings_keys.d.ts +12 -0
  267. package/dist/settings_keys.d.ts.map +1 -0
  268. package/dist/settings_keys.js +35 -0
  269. package/dist/settings_keys.js.map +1 -0
  270. package/dist/tcp/client.d.ts +15 -0
  271. package/dist/tcp/client.d.ts.map +1 -0
  272. package/dist/tcp/client.js +28 -0
  273. package/dist/tcp/client.js.map +1 -0
  274. package/dist/tcp/connection.d.ts +79 -0
  275. package/dist/tcp/connection.d.ts.map +1 -0
  276. package/dist/tcp/connection.js +153 -0
  277. package/dist/tcp/connection.js.map +1 -0
  278. package/dist/tcp/index.d.ts +10 -0
  279. package/dist/tcp/index.d.ts.map +1 -0
  280. package/dist/tcp/index.js +7 -0
  281. package/dist/tcp/index.js.map +1 -0
  282. package/dist/tcp/server.d.ts +31 -0
  283. package/dist/tcp/server.d.ts.map +1 -0
  284. package/dist/tcp/server.js +54 -0
  285. package/dist/tcp/server.js.map +1 -0
  286. package/dist/team/bundle.d.ts +88 -0
  287. package/dist/team/bundle.d.ts.map +1 -0
  288. package/dist/team/bundle.js +214 -0
  289. package/dist/team/bundle.js.map +1 -0
  290. package/dist/team/identity.d.ts +31 -0
  291. package/dist/team/identity.d.ts.map +1 -0
  292. package/dist/team/identity.js +83 -0
  293. package/dist/team/identity.js.map +1 -0
  294. package/dist/team/index.d.ts +13 -0
  295. package/dist/team/index.d.ts.map +1 -0
  296. package/dist/team/index.js +8 -0
  297. package/dist/team/index.js.map +1 -0
  298. package/dist/team/lint_bundle.d.ts +16 -0
  299. package/dist/team/lint_bundle.d.ts.map +1 -0
  300. package/dist/team/lint_bundle.js +35 -0
  301. package/dist/team/lint_bundle.js.map +1 -0
  302. package/dist/team/ref.d.ts +48 -0
  303. package/dist/team/ref.d.ts.map +1 -0
  304. package/dist/team/ref.js +70 -0
  305. package/dist/team/ref.js.map +1 -0
  306. package/dist/team/roles.d.ts +22 -0
  307. package/dist/team/roles.d.ts.map +1 -0
  308. package/dist/team/roles.js +33 -0
  309. package/dist/team/roles.js.map +1 -0
  310. package/dist/team/tree.d.ts +101 -0
  311. package/dist/team/tree.d.ts.map +1 -0
  312. package/dist/team/tree.js +125 -0
  313. package/dist/team/tree.js.map +1 -0
  314. package/dist/team_lint.d.ts +57 -0
  315. package/dist/team_lint.d.ts.map +1 -0
  316. package/dist/team_lint.js +277 -0
  317. package/dist/team_lint.js.map +1 -0
  318. package/dist/telemetry/stream_json_usage.d.ts +39 -0
  319. package/dist/telemetry/stream_json_usage.d.ts.map +1 -0
  320. package/dist/telemetry/stream_json_usage.js +139 -0
  321. package/dist/telemetry/stream_json_usage.js.map +1 -0
  322. package/dist/telemetry/usage.d.ts +288 -0
  323. package/dist/telemetry/usage.d.ts.map +1 -0
  324. package/dist/telemetry/usage.js +421 -0
  325. package/dist/telemetry/usage.js.map +1 -0
  326. package/dist/utils/duration.d.ts +11 -0
  327. package/dist/utils/duration.d.ts.map +1 -0
  328. package/dist/utils/duration.js +22 -0
  329. package/dist/utils/duration.js.map +1 -0
  330. package/dist/utils/redact.d.ts +26 -0
  331. package/dist/utils/redact.d.ts.map +1 -0
  332. package/dist/utils/redact.js +52 -0
  333. package/dist/utils/redact.js.map +1 -0
  334. package/dist/utils/url.d.ts +6 -0
  335. package/dist/utils/url.d.ts.map +1 -0
  336. package/dist/utils/url.js +11 -0
  337. package/dist/utils/url.js.map +1 -0
  338. package/package.json +72 -5
@@ -0,0 +1,119 @@
1
+ /**
2
+ * `define_hug` — a hug's definition (PLAN-hug-widgets §9.2.0): its name, what it is asked (`params`), what it answers
3
+ * (`values`), its upload slots (`files`) and its one-line `summary`. Written once in a hug's `hug.ts` and imported by
4
+ * its frontend (`mount_hug` checks every change with it) and by agent code (`ctx.ask` checks every response with it);
5
+ * compiled into the bundle's `definition.mjs` so generic agents can use it too.
6
+ *
7
+ * `values`, `files` and `summary` may be functions of `params`, for a hug whose answer depends on what it was asked
8
+ * (`form`'s fields, the gate's `approval` inputs and route choices).
9
+ *
10
+ * Browser-safe and Node-safe: imports only `zod` and the shared problem helpers.
11
+ */
12
+ import { z } from 'zod';
13
+ import { problems_from_zod } from './problems.js';
14
+ /** A hug's name: lowercase letters, digits and hyphens, starting with a letter (its folder's name). */
15
+ export const HUG_NAME_RE = /^[a-z][a-z0-9-]{0,63}$/;
16
+ /** Longest summary the Hub stores (PLAN-hug-widgets §3.2). */
17
+ export const MAX_SUMMARY_LENGTH = 120;
18
+ /** A file reference in an answer: the id the upload returned (metadata may ride along). */
19
+ export const FileRefSchema = z.looseObject({
20
+ artifact_id: z.string({ error: 'must be an uploaded file' }).min(1, 'must be an uploaded file'),
21
+ });
22
+ /** Most files one `multiple` upload slot takes. */
23
+ export const MAX_FILES_PER_SLOT = 10;
24
+ /**
25
+ * An upload field for a definition's `values`. Its key becomes an upload slot of the Hug (`files`), so nobody declares
26
+ * upload keys separately.
27
+ *
28
+ * @param opts - What it accepts; `multiple` for a list of files; `optional` when an answer may leave it out.
29
+ */
30
+ export function file(opts = {}) {
31
+ const meta = {
32
+ ...(opts.accept ? { accept: opts.accept } : {}),
33
+ ...(opts.max_bytes ? { max_bytes: opts.max_bytes } : {}),
34
+ ...(opts.multiple ? { multiple: true } : {}),
35
+ };
36
+ const least = opts.optional ? 0 : 1;
37
+ const many = z.array(FileRefSchema, { error: 'must be a list of uploaded files' })
38
+ .max(MAX_FILES_PER_SLOT, `takes at most ${MAX_FILES_PER_SLOT} files`)
39
+ .min(least, 'required');
40
+ const one = opts.multiple ? many : FileRefSchema;
41
+ const marked = one.meta({ cliq_file: meta });
42
+ return (opts.optional ? marked.optional() : marked);
43
+ }
44
+ /** The `file()` metadata on a field (looking through `optional`/`nullable`/`default`), or null. */
45
+ function file_meta(schema) {
46
+ let s = schema;
47
+ let required = true;
48
+ for (let depth = 0; depth < 5; depth++) {
49
+ const meta = s.meta()?.cliq_file;
50
+ if (meta)
51
+ return { meta, required };
52
+ const inner = s._zod.def;
53
+ if (!inner.innerType)
54
+ return null;
55
+ if (['optional', 'nullable', 'default', 'prefault'].includes(inner.type))
56
+ required = false;
57
+ s = inner.innerType;
58
+ }
59
+ return null;
60
+ }
61
+ /** The upload slots of a values schema: its top-level fields made with `file()`. */
62
+ export function file_slots_of(values) {
63
+ if (!(values instanceof z.ZodObject))
64
+ return [];
65
+ const slots = [];
66
+ for (const [name, field] of Object.entries(values.shape)) {
67
+ const found = file_meta(field);
68
+ if (found)
69
+ slots.push({ name, ...found.meta, required: found.required });
70
+ }
71
+ return slots;
72
+ }
73
+ /** The text cut to `max` characters, with an ellipsis when cut. */
74
+ function clip(text, max) {
75
+ const one_line = text.replace(/\s+/g, ' ').trim();
76
+ return one_line.length <= max ? one_line : `${one_line.slice(0, max - 1)}…`;
77
+ }
78
+ /**
79
+ * Define a hug.
80
+ *
81
+ * @param spec - The hug's name, params, values, and optionally its title, description, files and summary.
82
+ * @throws Error when the name isn't a hug name.
83
+ */
84
+ export function define_hug(spec) {
85
+ if (!HUG_NAME_RE.test(spec.name))
86
+ throw new Error(`'${spec.name}' is not a hug name (lowercase letters, digits and hyphens, starting with a letter)`);
87
+ const values_schema = (params) => (typeof spec.values === 'function' ? spec.values(params) : spec.values);
88
+ const files = (params) => {
89
+ if (spec.files)
90
+ return [...(typeof spec.files === 'function' ? spec.files(params) : spec.files)];
91
+ return file_slots_of(values_schema(params));
92
+ };
93
+ return {
94
+ name: spec.name,
95
+ title: spec.title ?? spec.name,
96
+ description: spec.description ?? '',
97
+ params: spec.params,
98
+ values_schema,
99
+ files,
100
+ summary: (values, params) => clip(spec.summary ? spec.summary(values, params) : 'Responded', MAX_SUMMARY_LENGTH),
101
+ check_params(raw) {
102
+ const parsed = spec.params.safeParse(raw ?? {});
103
+ return parsed.success ? { ok: true, value: parsed.data } : { ok: false, problems: problems_from_zod(parsed.error) };
104
+ },
105
+ check(raw, params) {
106
+ const parsed = values_schema(params).safeParse(raw);
107
+ return parsed.success ? { ok: true, value: parsed.data } : { ok: false, problems: problems_from_zod(parsed.error) };
108
+ },
109
+ describe() {
110
+ return {
111
+ name: spec.name,
112
+ title: spec.title ?? spec.name,
113
+ description: spec.description ?? '',
114
+ params_schema: z.toJSONSchema(spec.params, { unrepresentable: 'any', io: 'input' }),
115
+ };
116
+ },
117
+ };
118
+ }
119
+ //# sourceMappingURL=define.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"define.js","sourceRoot":"","sources":["../../src/hug/define.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,iBAAiB,EAAgB,MAAM,eAAe,CAAC;AAEhE,uGAAuG;AACvG,MAAM,CAAC,MAAM,WAAW,GAAG,wBAAwB,CAAC;AAEpD,8DAA8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E,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,IAAI;gBAC9B,WAAW,EAAE,IAAI,CAAC,WAAW,IAAI,EAAE;gBACnC,aAAa,EAAE,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,eAAe,EAAE,KAAK,EAAE,EAAE,EAAE,OAAO,EAAE,CAA4B;aACjH,CAAC;QACN,CAAC;KACJ,CAAC;AACN,CAAC"}
@@ -0,0 +1,216 @@
1
+ /**
2
+ * `approval` — the built-in hug that approves or rejects the work (PLAN-hug-widgets §10.1); the Hug gate always asks
3
+ * with it. A gate configures it through its params: `review.inputs` → `inputs` (the fields approving requires),
4
+ * `route_targets` → `reject_choices` ("Send back to …"), `review.params` → the labels and `show_comment`.
5
+ *
6
+ * Answer: `{ decision: 'approve', …one key per input (required ones enforced), comment? }`, or
7
+ * `{ decision: 'reject', reason, choice? }` — a rejection never needs the inputs. The same rules as today's
8
+ * `approval_v1` (the parity is tested).
9
+ */
10
+ import { z } from 'zod';
11
+ /** The answer keys `approval` adds itself; inputs can't use them. */
12
+ export declare const APPROVAL_OWN_KEYS: readonly ["decision", "reason", "choice", "comment"];
13
+ /** `approval`'s params. */
14
+ export declare const ApprovalParams: z.ZodObject<{
15
+ reject_choices: z.ZodOptional<z.ZodArray<z.ZodObject<{
16
+ value: z.ZodString;
17
+ label: z.ZodOptional<z.ZodString>;
18
+ }, z.core.$strict>>>;
19
+ approve_label: z.ZodOptional<z.ZodString>;
20
+ reject_label: z.ZodOptional<z.ZodString>;
21
+ show_comment: z.ZodOptional<z.ZodBoolean>;
22
+ prompt: z.ZodOptional<z.ZodString>;
23
+ context: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
24
+ type: z.ZodLiteral<"markdown">;
25
+ text: z.ZodString;
26
+ }, z.core.$strict>, z.ZodObject<{
27
+ type: z.ZodLiteral<"artifact">;
28
+ artifact_id: z.ZodString;
29
+ label: z.ZodOptional<z.ZodString>;
30
+ }, z.core.$strict>, z.ZodObject<{
31
+ type: z.ZodLiteral<"checks">;
32
+ results: z.ZodArray<z.ZodObject<{
33
+ name: z.ZodString;
34
+ ok: z.ZodBoolean;
35
+ summary: z.ZodOptional<z.ZodString>;
36
+ }, z.core.$strict>>;
37
+ }, z.core.$strict>, z.ZodObject<{
38
+ type: z.ZodLiteral<"transcript">;
39
+ turns: z.ZodArray<z.ZodObject<{
40
+ role: z.ZodString;
41
+ content: z.ZodString;
42
+ }, z.core.$strict>>;
43
+ }, z.core.$strict>], "type">>>;
44
+ inputs: z.ZodDefault<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
45
+ type: z.ZodLiteral<"text">;
46
+ multiline: z.ZodOptional<z.ZodBoolean>;
47
+ min_length: z.ZodOptional<z.ZodNumber>;
48
+ max_length: z.ZodOptional<z.ZodNumber>;
49
+ name: z.ZodString;
50
+ label: z.ZodOptional<z.ZodString>;
51
+ help: z.ZodOptional<z.ZodString>;
52
+ required: z.ZodOptional<z.ZodBoolean>;
53
+ default: z.ZodOptional<z.ZodUnknown>;
54
+ ui: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
55
+ }, z.core.$strict>, z.ZodObject<{
56
+ type: z.ZodLiteral<"number">;
57
+ min: z.ZodOptional<z.ZodNumber>;
58
+ max: z.ZodOptional<z.ZodNumber>;
59
+ integer: z.ZodOptional<z.ZodBoolean>;
60
+ name: z.ZodString;
61
+ label: z.ZodOptional<z.ZodString>;
62
+ help: z.ZodOptional<z.ZodString>;
63
+ required: z.ZodOptional<z.ZodBoolean>;
64
+ default: z.ZodOptional<z.ZodUnknown>;
65
+ ui: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
66
+ }, z.core.$strict>, z.ZodObject<{
67
+ type: z.ZodLiteral<"boolean">;
68
+ name: z.ZodString;
69
+ label: z.ZodOptional<z.ZodString>;
70
+ help: z.ZodOptional<z.ZodString>;
71
+ required: z.ZodOptional<z.ZodBoolean>;
72
+ default: z.ZodOptional<z.ZodUnknown>;
73
+ ui: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
74
+ }, z.core.$strict>, z.ZodObject<{
75
+ type: z.ZodLiteral<"enum">;
76
+ choices: z.ZodArray<z.ZodObject<{
77
+ value: z.ZodString;
78
+ label: z.ZodOptional<z.ZodString>;
79
+ }, z.core.$strict>>;
80
+ multiple: z.ZodOptional<z.ZodBoolean>;
81
+ name: z.ZodString;
82
+ label: z.ZodOptional<z.ZodString>;
83
+ help: z.ZodOptional<z.ZodString>;
84
+ required: z.ZodOptional<z.ZodBoolean>;
85
+ default: z.ZodOptional<z.ZodUnknown>;
86
+ ui: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
87
+ }, z.core.$strict>, z.ZodObject<{
88
+ type: z.ZodLiteral<"file">;
89
+ accept: z.ZodOptional<z.ZodArray<z.ZodString>>;
90
+ max_bytes: z.ZodOptional<z.ZodNumber>;
91
+ multiple: z.ZodOptional<z.ZodBoolean>;
92
+ name: z.ZodString;
93
+ label: z.ZodOptional<z.ZodString>;
94
+ help: z.ZodOptional<z.ZodString>;
95
+ required: z.ZodOptional<z.ZodBoolean>;
96
+ default: z.ZodOptional<z.ZodUnknown>;
97
+ ui: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
98
+ }, z.core.$strict>, z.ZodObject<{
99
+ type: z.ZodLiteral<"channel">;
100
+ multiple: z.ZodOptional<z.ZodBoolean>;
101
+ name: z.ZodString;
102
+ label: z.ZodOptional<z.ZodString>;
103
+ help: z.ZodOptional<z.ZodString>;
104
+ required: z.ZodOptional<z.ZodBoolean>;
105
+ default: z.ZodOptional<z.ZodUnknown>;
106
+ ui: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
107
+ }, z.core.$strict>], "type">>>;
108
+ }, z.core.$strict>;
109
+ /** `approval`'s params. */
110
+ export type ApprovalParams = z.infer<typeof ApprovalParams>;
111
+ /** An `approval` answer. */
112
+ export type ApprovalValues = ({
113
+ decision: 'approve';
114
+ comment?: string | null;
115
+ } & Record<string, unknown>) | {
116
+ decision: 'reject';
117
+ reason: string;
118
+ choice?: string | null;
119
+ };
120
+ /** The built-in `approval` hug. */
121
+ export declare const approval: import("../define.js").HugDefinition<{
122
+ inputs: ({
123
+ type: "text";
124
+ name: string;
125
+ multiline?: boolean | undefined;
126
+ min_length?: number | undefined;
127
+ max_length?: number | undefined;
128
+ label?: string | undefined;
129
+ help?: string | undefined;
130
+ required?: boolean | undefined;
131
+ default?: unknown;
132
+ ui?: Record<string, unknown> | undefined;
133
+ } | {
134
+ type: "number";
135
+ name: string;
136
+ min?: number | undefined;
137
+ max?: number | undefined;
138
+ integer?: boolean | undefined;
139
+ label?: string | undefined;
140
+ help?: string | undefined;
141
+ required?: boolean | undefined;
142
+ default?: unknown;
143
+ ui?: Record<string, unknown> | undefined;
144
+ } | {
145
+ type: "boolean";
146
+ name: string;
147
+ label?: string | undefined;
148
+ help?: string | undefined;
149
+ required?: boolean | undefined;
150
+ default?: unknown;
151
+ ui?: Record<string, unknown> | undefined;
152
+ } | {
153
+ type: "enum";
154
+ choices: {
155
+ value: string;
156
+ label?: string | undefined;
157
+ }[];
158
+ name: string;
159
+ multiple?: boolean | undefined;
160
+ label?: string | undefined;
161
+ help?: string | undefined;
162
+ required?: boolean | undefined;
163
+ default?: unknown;
164
+ ui?: Record<string, unknown> | undefined;
165
+ } | {
166
+ type: "file";
167
+ name: string;
168
+ accept?: string[] | undefined;
169
+ max_bytes?: number | undefined;
170
+ multiple?: boolean | undefined;
171
+ label?: string | undefined;
172
+ help?: string | undefined;
173
+ required?: boolean | undefined;
174
+ default?: unknown;
175
+ ui?: Record<string, unknown> | undefined;
176
+ } | {
177
+ type: "channel";
178
+ name: string;
179
+ multiple?: boolean | undefined;
180
+ label?: string | undefined;
181
+ help?: string | undefined;
182
+ required?: boolean | undefined;
183
+ default?: unknown;
184
+ ui?: Record<string, unknown> | undefined;
185
+ })[];
186
+ reject_choices?: {
187
+ value: string;
188
+ label?: string | undefined;
189
+ }[] | undefined;
190
+ approve_label?: string | undefined;
191
+ reject_label?: string | undefined;
192
+ show_comment?: boolean | undefined;
193
+ prompt?: string | undefined;
194
+ context?: ({
195
+ type: "markdown";
196
+ text: string;
197
+ } | {
198
+ type: "artifact";
199
+ artifact_id: string;
200
+ label?: string | undefined;
201
+ } | {
202
+ type: "checks";
203
+ results: {
204
+ name: string;
205
+ ok: boolean;
206
+ summary?: string | undefined;
207
+ }[];
208
+ } | {
209
+ type: "transcript";
210
+ turns: {
211
+ role: string;
212
+ content: string;
213
+ }[];
214
+ })[] | undefined;
215
+ }, ApprovalValues>;
216
+ //# sourceMappingURL=approval.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"approval.d.ts","sourceRoot":"","sources":["../../../src/hug/definitions/approval.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB,qEAAqE;AACrE,eAAO,MAAM,iBAAiB,sDAAuD,CAAC;AAItF,2BAA2B;AAC3B,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBASmB,CAAC;AAC/C,2BAA2B;AAC3B,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAE5D,4BAA4B;AAC5B,MAAM,MAAM,cAAc,GACpB,CAAC;IAAE,QAAQ,EAAE,SAAS,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAC5E;IAAE,QAAQ,EAAE,QAAQ,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAAC;AASrE,mCAAmC;AACnC,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAenB,CAAC"}
@@ -0,0 +1,50 @@
1
+ /**
2
+ * `approval` — the built-in hug that approves or rejects the work (PLAN-hug-widgets §10.1); the Hug gate always asks
3
+ * with it. A gate configures it through its params: `review.inputs` → `inputs` (the fields approving requires),
4
+ * `route_targets` → `reject_choices` ("Send back to …"), `review.params` → the labels and `show_comment`.
5
+ *
6
+ * Answer: `{ decision: 'approve', …one key per input (required ones enforced), comment? }`, or
7
+ * `{ decision: 'reject', reason, choice? }` — a rejection never needs the inputs. The same rules as today's
8
+ * `approval_v1` (the parity is tested).
9
+ */
10
+ import { z } from 'zod';
11
+ import { define_hug } from '../define.js';
12
+ import { schema_for_inputs } from '../schema_for_inputs.js';
13
+ import { base_params, file_inputs, no_own_keys, note } from './common.js';
14
+ /** The answer keys `approval` adds itself; inputs can't use them. */
15
+ export const APPROVAL_OWN_KEYS = ['decision', 'reason', 'choice', 'comment'];
16
+ const Choice = z.strictObject({ value: z.string().min(1).max(200), label: z.string().max(200).optional() });
17
+ /** `approval`'s params. */
18
+ export const ApprovalParams = z.strictObject({
19
+ ...base_params,
20
+ reject_choices: z.array(Choice).max(20).refine((choices) => new Set(choices.map((c) => c.value)).size === choices.length, 'values must be unique').optional(),
21
+ approve_label: z.string().min(1).max(40).optional(),
22
+ reject_label: z.string().min(1).max(40).optional(),
23
+ show_comment: z.boolean().optional(),
24
+ }).superRefine(no_own_keys(APPROVAL_OWN_KEYS));
25
+ /** The choice schema for these params: one of `reject_choices`, or none when none are offered. */
26
+ function choice_schema(p) {
27
+ const values = (p.reject_choices ?? []).map((c) => c.value);
28
+ if (values.length === 0)
29
+ return z.null({ error: 'must be one of (none offered)' }).optional();
30
+ return z.enum(values, { error: `must be one of ${values.join(', ')}` }).nullish();
31
+ }
32
+ /** The built-in `approval` hug. */
33
+ export const approval = define_hug({
34
+ name: 'approval',
35
+ title: 'Approval',
36
+ description: 'Asks people to approve the work (filling in any fields approving requires) or reject it with a reason and, when offered, where to send it back.',
37
+ params: ApprovalParams,
38
+ values: (p) => z.discriminatedUnion('decision', [
39
+ z.strictObject({ ...schema_for_inputs(p.inputs).shape, decision: z.literal('approve'), comment: note(false) }),
40
+ z.strictObject({ decision: z.literal('reject'), reason: note(true), choice: choice_schema(p) }),
41
+ ], { error: 'decision: must be approve or reject' }),
42
+ files: (p) => file_inputs(p.inputs),
43
+ summary: (v, p) => {
44
+ if (v.decision === 'approve')
45
+ return 'Approved';
46
+ const choice = (p.reject_choices ?? []).find((c) => c.value === v.choice);
47
+ return choice ? (choice.label ?? `Rejected — ${choice.value}`) : 'Rejected';
48
+ },
49
+ });
50
+ //# sourceMappingURL=approval.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"approval.js","sourceRoot":"","sources":["../../../src/hug/definitions/approval.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAE1E,qEAAqE;AACrE,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,CAAU,CAAC;AAEtF,MAAM,MAAM,GAAG,CAAC,CAAC,YAAY,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAA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AC,KAAK,IAAI,cAAc,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC;IAChF,CAAC;CACJ,CAAC,CAAC"}
@@ -0,0 +1,122 @@
1
+ /**
2
+ * Pieces the built-in definitions share (PLAN-hug-widgets §9.2.0): their common params, notes (a comment, a reason),
3
+ * the "inputs can't use our own keys" rule, and the first-answer summary.
4
+ *
5
+ * Browser-safe: imports only `zod` and the shared hug modules.
6
+ */
7
+ import { z } from 'zod';
8
+ import { type RequestedInput } from '../requested_inputs.js';
9
+ /** Longest prompt (markdown). */
10
+ export declare const MAX_PROMPT_LENGTH = 20000;
11
+ /** Longest free-text answer a built-in hug adds itself (a reason, a comment). */
12
+ export declare const MAX_NOTE_LENGTH = 20000;
13
+ /** Params every built-in hug takes: what is asked, what is shown with it, and the fields. */
14
+ export declare const base_params: {
15
+ prompt: z.ZodOptional<z.ZodString>;
16
+ context: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
17
+ type: z.ZodLiteral<"markdown">;
18
+ text: z.ZodString;
19
+ }, z.core.$strict>, z.ZodObject<{
20
+ type: z.ZodLiteral<"artifact">;
21
+ artifact_id: z.ZodString;
22
+ label: z.ZodOptional<z.ZodString>;
23
+ }, z.core.$strict>, z.ZodObject<{
24
+ type: z.ZodLiteral<"checks">;
25
+ results: z.ZodArray<z.ZodObject<{
26
+ name: z.ZodString;
27
+ ok: z.ZodBoolean;
28
+ summary: z.ZodOptional<z.ZodString>;
29
+ }, z.core.$strict>>;
30
+ }, z.core.$strict>, z.ZodObject<{
31
+ type: z.ZodLiteral<"transcript">;
32
+ turns: z.ZodArray<z.ZodObject<{
33
+ role: z.ZodString;
34
+ content: z.ZodString;
35
+ }, z.core.$strict>>;
36
+ }, z.core.$strict>], "type">>>;
37
+ inputs: z.ZodDefault<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
38
+ type: z.ZodLiteral<"text">;
39
+ multiline: z.ZodOptional<z.ZodBoolean>;
40
+ min_length: z.ZodOptional<z.ZodNumber>;
41
+ max_length: z.ZodOptional<z.ZodNumber>;
42
+ name: z.ZodString;
43
+ label: z.ZodOptional<z.ZodString>;
44
+ help: z.ZodOptional<z.ZodString>;
45
+ required: z.ZodOptional<z.ZodBoolean>;
46
+ default: z.ZodOptional<z.ZodUnknown>;
47
+ ui: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
48
+ }, z.core.$strict>, z.ZodObject<{
49
+ type: z.ZodLiteral<"number">;
50
+ min: z.ZodOptional<z.ZodNumber>;
51
+ max: z.ZodOptional<z.ZodNumber>;
52
+ integer: z.ZodOptional<z.ZodBoolean>;
53
+ name: z.ZodString;
54
+ label: z.ZodOptional<z.ZodString>;
55
+ help: z.ZodOptional<z.ZodString>;
56
+ required: z.ZodOptional<z.ZodBoolean>;
57
+ default: z.ZodOptional<z.ZodUnknown>;
58
+ ui: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
59
+ }, z.core.$strict>, z.ZodObject<{
60
+ type: z.ZodLiteral<"boolean">;
61
+ name: z.ZodString;
62
+ label: z.ZodOptional<z.ZodString>;
63
+ help: z.ZodOptional<z.ZodString>;
64
+ required: z.ZodOptional<z.ZodBoolean>;
65
+ default: z.ZodOptional<z.ZodUnknown>;
66
+ ui: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
67
+ }, z.core.$strict>, z.ZodObject<{
68
+ type: z.ZodLiteral<"enum">;
69
+ choices: z.ZodArray<z.ZodObject<{
70
+ value: z.ZodString;
71
+ label: z.ZodOptional<z.ZodString>;
72
+ }, z.core.$strict>>;
73
+ multiple: z.ZodOptional<z.ZodBoolean>;
74
+ name: z.ZodString;
75
+ label: z.ZodOptional<z.ZodString>;
76
+ help: z.ZodOptional<z.ZodString>;
77
+ required: z.ZodOptional<z.ZodBoolean>;
78
+ default: z.ZodOptional<z.ZodUnknown>;
79
+ ui: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
80
+ }, z.core.$strict>, z.ZodObject<{
81
+ type: z.ZodLiteral<"file">;
82
+ accept: z.ZodOptional<z.ZodArray<z.ZodString>>;
83
+ max_bytes: z.ZodOptional<z.ZodNumber>;
84
+ multiple: z.ZodOptional<z.ZodBoolean>;
85
+ name: z.ZodString;
86
+ label: z.ZodOptional<z.ZodString>;
87
+ help: z.ZodOptional<z.ZodString>;
88
+ required: z.ZodOptional<z.ZodBoolean>;
89
+ default: z.ZodOptional<z.ZodUnknown>;
90
+ ui: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
91
+ }, z.core.$strict>, z.ZodObject<{
92
+ type: z.ZodLiteral<"channel">;
93
+ multiple: z.ZodOptional<z.ZodBoolean>;
94
+ name: z.ZodString;
95
+ label: z.ZodOptional<z.ZodString>;
96
+ help: z.ZodOptional<z.ZodString>;
97
+ required: z.ZodOptional<z.ZodBoolean>;
98
+ default: z.ZodOptional<z.ZodUnknown>;
99
+ ui: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
100
+ }, z.core.$strict>], "type">>>;
101
+ };
102
+ /**
103
+ * Refuses inputs named like one of the hug's own answer keys.
104
+ *
105
+ * @param own - The keys the hug adds to an answer itself (`comment`, `declined`, …).
106
+ */
107
+ export declare const no_own_keys: (own: readonly string[]) => (p: {
108
+ inputs: RequestedInput[];
109
+ }, ctx: z.RefinementCtx) => void;
110
+ /** A note: text of at most {@link MAX_NOTE_LENGTH}, trimmed (the checked value has no surrounding spaces); required means not blank. */
111
+ export declare function note(required: boolean): z.ZodType<string | null | undefined>;
112
+ /** The upload slots of requested inputs: their file inputs. */
113
+ export declare function file_inputs(inputs: readonly RequestedInput[]): {
114
+ required: boolean;
115
+ multiple?: boolean | undefined;
116
+ max_bytes?: number | undefined;
117
+ accept?: string[] | undefined;
118
+ name: string;
119
+ }[];
120
+ /** The first answered value that reads as a line (not a file), as today's "others responded" line shows it. */
121
+ export declare function first_answer(inputs: readonly RequestedInput[], values: Record<string, unknown>): string | null;
122
+ //# sourceMappingURL=common.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/hug/definitions/common.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAyB,KAAK,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAEpF,iCAAiC;AACjC,eAAO,MAAM,iBAAiB,QAAS,CAAC;AACxC,iFAAiF;AACjF,eAAO,MAAM,eAAe,QAAS,CAAC;AAEtC,6FAA6F;AAC7F,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAIvB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,WAAW,GAAI,KAAK,SAAS,MAAM,EAAE,MAAM,GAAG;IAAE,MAAM,EAAE,cAAc,EAAE,CAAA;CAAE,EAAE,KAAK,CAAC,CAAC,aAAa,KAAG,IAI/G,CAAC;AAEF,wIAAwI;AACxI,wBAAgB,IAAI,CAAC,QAAQ,EAAE,OAAO,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,CAK5E;AAED,+DAA+D;AAC/D,wBAAgB,WAAW,CAAC,MAAM,EAAE,SAAS,cAAc,EAAE;;;;;;IAQ5D;AAaD,+GAA+G;AAC/G,wBAAgB,YAAY,CAAC,MAAM,EAAE,SAAS,cAAc,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,GAAG,IAAI,CAO9G"}
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Pieces the built-in definitions share (PLAN-hug-widgets §9.2.0): their common params, notes (a comment, a reason),
3
+ * the "inputs can't use our own keys" rule, and the first-answer summary.
4
+ *
5
+ * Browser-safe: imports only `zod` and the shared hug modules.
6
+ */
7
+ import { z } from 'zod';
8
+ import { ContextSchema } from '../context.js';
9
+ import { RequestedInputsSchema } from '../requested_inputs.js';
10
+ /** Longest prompt (markdown). */
11
+ export const MAX_PROMPT_LENGTH = 20_000;
12
+ /** Longest free-text answer a built-in hug adds itself (a reason, a comment). */
13
+ export const MAX_NOTE_LENGTH = 20_000;
14
+ /** Params every built-in hug takes: what is asked, what is shown with it, and the fields. */
15
+ export const base_params = {
16
+ prompt: z.string().max(MAX_PROMPT_LENGTH).optional(),
17
+ context: ContextSchema.optional(),
18
+ inputs: RequestedInputsSchema.default([]),
19
+ };
20
+ /**
21
+ * Refuses inputs named like one of the hug's own answer keys.
22
+ *
23
+ * @param own - The keys the hug adds to an answer itself (`comment`, `declined`, …).
24
+ */
25
+ export const no_own_keys = (own) => (p, ctx) => {
26
+ p.inputs.forEach((input, i) => {
27
+ if (own.includes(input.name))
28
+ ctx.addIssue({ code: 'custom', path: ['inputs', i, 'name'], message: `'${input.name}' is a key of the hug's own` });
29
+ });
30
+ };
31
+ /** A note: text of at most {@link MAX_NOTE_LENGTH}, trimmed (the checked value has no surrounding spaces); required means not blank. */
32
+ export function note(required) {
33
+ const text = z.string({ error: (i) => (i.input === undefined || i.input === null ? 'required' : 'must be text') })
34
+ .trim()
35
+ .max(MAX_NOTE_LENGTH, `at most ${MAX_NOTE_LENGTH} characters`);
36
+ return required ? text.refine((v) => v !== '', 'required') : text.nullish();
37
+ }
38
+ /** The upload slots of requested inputs: their file inputs. */
39
+ export function file_inputs(inputs) {
40
+ return inputs.filter((i) => i.type === 'file').map((i) => ({
41
+ name: i.name,
42
+ ...(i.accept ? { accept: i.accept } : {}),
43
+ ...(i.max_bytes ? { max_bytes: i.max_bytes } : {}),
44
+ ...(i.multiple ? { multiple: true } : {}),
45
+ required: i.required !== false,
46
+ }));
47
+ }
48
+ /** An input's value as words: an enum's choice labels, Yes / No, channels joined, else the text. */
49
+ function value_words(input, value) {
50
+ if (input.type === 'enum') {
51
+ const label = (v) => input.choices.find((c) => c.value === v)?.label ?? String(v);
52
+ return Array.isArray(value) ? value.map(label).join(', ') : label(value);
53
+ }
54
+ if (input.type === 'boolean')
55
+ return value ? 'Yes' : 'No';
56
+ if (Array.isArray(value))
57
+ return value.join(', ');
58
+ return String(value);
59
+ }
60
+ /** The first answered value that reads as a line (not a file), as today's "others responded" line shows it. */
61
+ export function first_answer(inputs, values) {
62
+ for (const input of inputs) {
63
+ const value = values[input.name];
64
+ if (input.type === 'file' || value === undefined || value === null || value === '')
65
+ continue;
66
+ return value_words(input, value);
67
+ }
68
+ return null;
69
+ }
70
+ //# sourceMappingURL=common.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common.js","sourceRoot":"","sources":["../../../src/hug/definitions/common.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,qBAAqB,EAAuB,MAAM,wBAAwB,CAAC;AAEpF,iCAAiC;AACjC,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC;AACxC,iFAAiF;AACjF,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC;AAEtC,6FAA6F;AAC7F,MAAM,CAAC,MAAM,WAAW,GAAG;IACvB,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC,QAAQ,EAAE;IACpD,OAAO,EAAE,aAAa,CAAC,QAAQ,EAAE;IACjC,MAAM,EAAE,qBAAqB,CAAC,OAAO,CAAC,EAAE,CAAC;CAC5C,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,GAAsB,EAAE,EAAE,CAAC,CAAC,CAA+B,EAAE,GAAoB,EAAQ,EAAE;IACnH,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,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