@getcliqio/cliq-sdk 0.0.0-stage → 1.15.33

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,165 @@
1
+ /**
2
+ * The bridge between a hug's frame and its host (PLAN-hug-widgets §6): every message, both ways, as Zod schemas. The
3
+ * frontend SDK (`@getcliqio/hug-frontend`) and both hosts (the Hub page, cliqd's local page) check every message with
4
+ * these, so the two sides can't drift.
5
+ *
6
+ * Messages are JSON objects `{ v, type, id?, … }` sent with `postMessage`. `v` is the bridge protocol version (not
7
+ * the SDK's version); `init` lists the versions the host speaks.
8
+ *
9
+ * Browser-safe: imports only `zod` and the shared hug modules.
10
+ */
11
+ import { z } from 'zod';
12
+ import { MAX_SUMMARY_LENGTH } from '../define.js';
13
+ /** The bridge protocol versions this code speaks. */
14
+ export const BRIDGE_PROTOCOLS = [1];
15
+ /** The version this code sends. */
16
+ export const BRIDGE_VERSION = 1;
17
+ /** Largest answer a frame may send (`values`, serialized). */
18
+ export const MAX_VALUES_BYTES = 256 * 1024;
19
+ /** Longest Submit label. */
20
+ export const MAX_SUBMIT_LABEL = 40;
21
+ /** Most `values` messages per second the host takes (the last one wins). */
22
+ export const MAX_VALUES_PER_SECOND = 20;
23
+ /** Most file reads in flight, and bytes read, per Hug page. */
24
+ export const MAX_READS_IN_FLIGHT = 10;
25
+ /** Most bytes a frame may read per Hug page. */
26
+ export const MAX_READ_BYTES_PER_PAGE = 50 * 1024 * 1024;
27
+ const v = z.literal(BRIDGE_VERSION);
28
+ const id = z.string().min(1).max(64);
29
+ /** A file as the frame sees it: a reference with its metadata. */
30
+ export const BridgeFileRef = z.looseObject({
31
+ artifact_id: z.string().min(1),
32
+ name: z.string(),
33
+ size: z.number().int().min(0),
34
+ content_type: z.string(),
35
+ sha256: z.string(),
36
+ });
37
+ /** An upload slot. */
38
+ export const BridgeFileSlot = z.strictObject({
39
+ name: z.string().min(1),
40
+ accept: z.array(z.string()).optional(),
41
+ max_bytes: z.number().int().min(1).optional(),
42
+ multiple: z.boolean().optional(),
43
+ required: z.boolean().optional(),
44
+ });
45
+ /** One answer, as drawn in view mode or kept for editing. */
46
+ export const BridgeAnswer = z.strictObject({
47
+ values: z.record(z.string(), z.unknown()),
48
+ summary: z.string().max(MAX_SUMMARY_LENGTH).optional(),
49
+ responder: z.strictObject({ name: z.string(), via: z.array(z.string()) }).optional(),
50
+ responded_at: z.string().optional(),
51
+ });
52
+ const Mode = z.enum(['answer', 'view']);
53
+ const Status = z.enum(['open', 'closed', 'expired', 'cancelled']);
54
+ const Problem = z.strictObject({ path: z.string().optional(), message: z.string() });
55
+ /** Hub colours and type, as CSS variables, and the scheme. */
56
+ export const BridgeTheme = z.strictObject({
57
+ scheme: z.enum(['light', 'dark']),
58
+ tokens: z.record(z.string().regex(/^--cliq-[a-z0-9-]+$/), z.string().max(200)),
59
+ });
60
+ // ── host → frame ──────────────────────────────────────────────────────────────────────────────────────────────────
61
+ /** `init`: everything the frame needs to draw, sent after `ready` (§6.1). */
62
+ export const InitMessage = z.strictObject({
63
+ v, type: z.literal('init'),
64
+ protocols: z.array(z.number().int()).min(1),
65
+ hug: z.strictObject({
66
+ id: z.string(), name: z.string(), title: z.string(), summary: z.string().optional(),
67
+ status: Status, expires_at: z.string().nullable(), requester: z.string().nullable(),
68
+ run: z.strictObject({ id: z.string(), name: z.string().nullable() }).nullable(),
69
+ }),
70
+ params: z.unknown(),
71
+ files: z.array(BridgeFileSlot),
72
+ attachments: z.array(BridgeFileRef),
73
+ viewer: z.strictObject({ name: z.string(), via: z.array(z.string()) }),
74
+ mine: BridgeAnswer.nullable(),
75
+ viewing: BridgeAnswer.nullable(),
76
+ draft: z.record(z.string(), z.unknown()).nullable(),
77
+ progress: z.string().nullable(),
78
+ theme: BridgeTheme,
79
+ locale: z.string(),
80
+ mode: Mode,
81
+ });
82
+ /** `update`: the Hug changed while open (progress, expiry). */
83
+ export const UpdateMessage = z.strictObject({ v, type: z.literal('update'), progress: z.string().nullable().optional(), expires_at: z.string().nullable().optional() });
84
+ /** `status`: the Hug closed, expired or was cancelled — view mode. */
85
+ export const StatusMessage = z.strictObject({ v, type: z.literal('status'), status: Status, mode: z.literal('view'), viewing: BridgeAnswer.nullable() });
86
+ /** `mode`: the page switches between showing an answer and editing one (§6.4). */
87
+ export const ModeMessage = z.strictObject({
88
+ v, type: z.literal('mode'), mode: Mode,
89
+ viewing: BridgeAnswer.nullable(), mine: BridgeAnswer.nullable(), draft: z.record(z.string(), z.unknown()).nullable(),
90
+ });
91
+ /** `upload_result`: an upload finished (its reference, or why not). */
92
+ export const UploadResultMessage = z.strictObject({ v, type: z.literal('upload_result'), id, ok: z.boolean(), ref: BridgeFileRef.optional(), error: z.string().optional() });
93
+ /** `file`: a read finished (the bytes as a Blob, or why not). */
94
+ export const FileMessage = z.strictObject({
95
+ v, type: z.literal('file'), id, ok: z.boolean(),
96
+ blob: z.custom((b) => typeof Blob !== 'undefined' && b instanceof Blob).optional(),
97
+ error: z.string().optional(),
98
+ });
99
+ /** `submit_result`: after the host's Submit — the stored answer, or Core's problems. */
100
+ export const SubmitResultMessage = z.strictObject({ v, type: z.literal('submit_result'), ok: z.boolean(), answer: BridgeAnswer.optional(), problems: z.array(Problem).optional() });
101
+ /** Every message a host sends a frame. */
102
+ export const HostMessage = z.discriminatedUnion('type', [
103
+ InitMessage, UpdateMessage, StatusMessage, ModeMessage, UploadResultMessage, FileMessage, SubmitResultMessage,
104
+ ]);
105
+ // ── frame → host ──────────────────────────────────────────────────────────────────────────────────────────────────
106
+ /** `ready`: the frame has loaded; lists the bridge versions it speaks. */
107
+ export const ReadyMessage = z.strictObject({ v, type: z.literal('ready'), protocols: z.array(z.number().int()).min(1) });
108
+ /** `values`: the current answer and its state (valid, problems, Submit label, summary). */
109
+ export const ValuesMessage = z.strictObject({
110
+ v, type: z.literal('values'),
111
+ values: z.record(z.string(), z.unknown()),
112
+ valid: z.boolean(),
113
+ problems: z.array(Problem).max(200).optional(),
114
+ submit: z.strictObject({ label: z.string().min(1).max(MAX_SUBMIT_LABEL), tone: z.enum(['primary', 'danger']).optional() }).optional(),
115
+ summary: z.string().max(MAX_SUMMARY_LENGTH).optional(),
116
+ });
117
+ /** `upload`: a file from the person for a declared slot. */
118
+ export const UploadMessage = z.strictObject({ v, type: z.literal('upload'), id, key: z.string().min(1) });
119
+ /** `read_file`: a file's bytes, through the host. */
120
+ export const ReadFileMessage = z.strictObject({ v, type: z.literal('read_file'), id, ref: BridgeFileRef });
121
+ /** `download`: the host saves a file for the person. */
122
+ export const DownloadMessage = z.strictObject({ v, type: z.literal('download'), ref: BridgeFileRef });
123
+ /** `open_link`: the host opens an http(s) link (after showing it, unless it is in the params). */
124
+ export const OpenLinkMessage = z.strictObject({ v, type: z.literal('open_link'), url: z.url({ protocol: /^https?$/ }) });
125
+ /** `resize`: the frame's height. */
126
+ export const ResizeMessage = z.strictObject({ v, type: z.literal('resize'), height: z.number().int().min(0).max(100_000) });
127
+ /** Every message a frame sends its host. */
128
+ export const FrameMessage = z.discriminatedUnion('type', [
129
+ ReadyMessage, ValuesMessage, UploadMessage, ReadFileMessage, DownloadMessage, OpenLinkMessage, ResizeMessage,
130
+ ]);
131
+ /**
132
+ * Check a message a frame sent, as a host must before acting on it (§6.3): its shape, and the size of an answer.
133
+ * (Which file references and upload keys are allowed depends on the Hug; the host checks those itself.)
134
+ *
135
+ * @returns the message, or why it was refused.
136
+ */
137
+ export function parse_frame_message(raw) {
138
+ const parsed = FrameMessage.safeParse(raw);
139
+ if (!parsed.success)
140
+ return { ok: false, reason: parsed.error.issues.map((i) => `${i.path.join('.') || 'message'}: ${i.message}`).join('; ') };
141
+ const message = parsed.data;
142
+ if (message.type === 'values') {
143
+ const size = new TextEncoder().encode(JSON.stringify(message.values)).length;
144
+ if (size > MAX_VALUES_BYTES)
145
+ return { ok: false, reason: `values: larger than ${MAX_VALUES_BYTES} bytes` };
146
+ }
147
+ return { ok: true, message };
148
+ }
149
+ /**
150
+ * Check a message a host sent, as the frontend SDK does before acting on it.
151
+ *
152
+ * @returns the message, or why it was refused.
153
+ */
154
+ export function parse_host_message(raw) {
155
+ const parsed = HostMessage.safeParse(raw);
156
+ return parsed.success
157
+ ? { ok: true, message: parsed.data }
158
+ : { ok: false, reason: parsed.error.issues.map((i) => `${i.path.join('.') || 'message'}: ${i.message}`).join('; ') };
159
+ }
160
+ /** The highest protocol version both sides speak, or null. */
161
+ export function negotiate_protocol(theirs, ours = BRIDGE_PROTOCOLS) {
162
+ const common = theirs.filter((v) => ours.includes(v));
163
+ return common.length ? Math.max(...common) : null;
164
+ }
165
+ //# sourceMappingURL=messages.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"messages.js","sourceRoot":"","sources":["../../../src/hug/bridge/messages.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAElD,qDAAqD;AACrD,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,CAAU,CAAC;AAC7C,mCAAmC;AACnC,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC;AAEhC,8DAA8D;AAC9D,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,GAAG,IAAI,CAAC;AAC3C,4BAA4B;AAC5B,MAAM,CAAC,MAAM,gBAAgB,GAAG,EAAE,CAAC;AACnC,4EAA4E;AAC5E,MAAM,CAAC,MA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E,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,SAAS,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;AAC7H,CAAC;AAED,8DAA8D;AAC9D,MAAM,UAAU,kBAAkB,CAAC,MAAyB,EAAE,OAA0B,gBAAgB;IACpG,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;IACtD,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AACtD,CAAC"}
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Hug client — the agent's calls to cliqd's Hug transport (PLAN-hug-requests §8.2), and the phase's
3
+ * Hug defaults from the environment cliqd sets (§8.6).
4
+ *
5
+ * `open` and `close` are retried on a transport failure (cliqd restarting): `open` with the same
6
+ * `request_id`, so a retry returns the same Hug; `close` is idempotent. `next` is a long-poll that
7
+ * never consumes anything — a retry gets the same events — so it keeps retrying through an outage
8
+ * (the machine sleeping, cliqd restarting) for up to {@link NEXT_OUTAGE_MS}.
9
+ */
10
+ import type { HugEvent, HugSpec, HugStatus } from './types.js';
11
+ /** Where the agent runs: cliqd, its run, phase and phase iteration. */
12
+ export interface HugTransport {
13
+ readonly daemon_url: string;
14
+ readonly run_id: string;
15
+ readonly phase: string;
16
+ readonly iteration: number;
17
+ }
18
+ /** The phase's Hug defaults (its `hug:` block, or a gate's reviewer channels). */
19
+ export interface HugDefaults {
20
+ readonly channels: readonly string[];
21
+ readonly expires_in_min?: number;
22
+ readonly remind_every_min?: number;
23
+ }
24
+ /** What `next` returns: events after each cursor, and each Hug's status. */
25
+ export interface HugNextReply {
26
+ readonly events: readonly HugEvent[];
27
+ readonly hugs: ReadonlyArray<{
28
+ readonly hug_id: string;
29
+ readonly status: HugStatus;
30
+ }>;
31
+ }
32
+ /** How long `next` keeps retrying while cliqd can't be reached, and its longest pause between tries. */
33
+ export declare const NEXT_OUTAGE_MS: number;
34
+ /**
35
+ * The phase's Hug defaults from the environment cliqd sets: `CLIQ_HUG_CHANNELS` (JSON list),
36
+ * `CLIQ_HUG_TIMEOUT` and `CLIQ_HUG_REMIND_EVERY` (minutes).
37
+ */
38
+ export declare function hug_defaults_from_env(env?: NodeJS.ProcessEnv): HugDefaults;
39
+ /**
40
+ * The spec with the phase's defaults filled in (§8.6): what the agent set is used as given; what it
41
+ * left out comes from the phase, then the SDK (24h, no reminders). Checked with the shared schema.
42
+ *
43
+ * @throws HugRefusedError when the result isn't a valid Hug
44
+ */
45
+ export declare function with_hug_defaults(spec: HugSpec, defaults: HugDefaults): HugSpec;
46
+ /** cliqd's Hug routes, for one phase iteration. */
47
+ export declare class HugClient {
48
+ readonly transport: HugTransport;
49
+ constructor(transport: HugTransport);
50
+ /**
51
+ * Open a Hug (the spec already has its defaults). Retried with the same `request_id`.
52
+ *
53
+ * @throws HugRefusedError when cliqd refuses it
54
+ */
55
+ open(spec: HugSpec, opts: {
56
+ request_id: string;
57
+ state?: unknown;
58
+ }): Promise<string>;
59
+ /**
60
+ * Events after each cursor, waiting up to `wait_ms` (25s) for one. A timeout, a connection
61
+ * failure or a 5xx is retried with backoff until cliqd has been unreachable for
62
+ * {@link NEXT_OUTAGE_MS}; cliqd's other answers (e.g. Hug not found) are thrown at once.
63
+ */
64
+ next(hug_ids: readonly string[], after: Readonly<Record<string, number>>, wait_ms?: number): Promise<HugNextReply>;
65
+ /** Record the requester's state and how far it has processed. */
66
+ save_state(hug_id: string, state: unknown, cursor: number, progress?: string | null): Promise<void>;
67
+ /** End a Hug with its outcome (idempotent). */
68
+ close(hug_id: string, outcome: string): Promise<void>;
69
+ }
70
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/hug/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAKH,OAAO,KAAK,EAAE,QAAQ,EAAgB,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAG7E,uEAAuE;AACvE,MAAM,WAAW,YAAY;IACzB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC9B;AAED,kFAAkF;AAClF,MAAM,WAAW,WAAW;IACxB,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;CACtC;AAED,4EAA4E;AAC5E,MAAM,WAAW,YAAY;IACzB,QAAQ,CAAC,MAAM,EAAE,SAAS,QAAQ,EAAE,CAAC;IACrC,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;QAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAA;KAAE,CAAC,CAAC;CACzF;AAOD,wGAAwG;AACxG,eAAO,MAAM,cAAc,QAAc,CAAC;AAG1C;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,WAAW,CAavF;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,GAAG,OAAO,CAe/E;AAED,mDAAmD;AACnD,qBAAa,SAAS;IACN,QAAQ,CAAC,SAAS,EAAE,YAAY;gBAAvB,SAAS,EAAE,YAAY;IAE5C;;;;OAIG;IACG,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,MAAM,CAAC;IAkBzF;;;;OAIG;IACG,IAAI,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,EAAE,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,OAAO,SAAe,GAAG,OAAO,CAAC,YAAY,CAAC;IAiB9H,iEAAiE;IAC3D,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAKzG,+CAA+C;IACzC,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAG9D"}
@@ -0,0 +1,144 @@
1
+ /**
2
+ * Hug client — the agent's calls to cliqd's Hug transport (PLAN-hug-requests §8.2), and the phase's
3
+ * Hug defaults from the environment cliqd sets (§8.6).
4
+ *
5
+ * `open` and `close` are retried on a transport failure (cliqd restarting): `open` with the same
6
+ * `request_id`, so a retry returns the same Hug; `close` is idempotent. `next` is a long-poll that
7
+ * never consumes anything — a retry gets the same events — so it keeps retrying through an outage
8
+ * (the machine sleeping, cliqd restarting) for up to {@link NEXT_OUTAGE_MS}.
9
+ */
10
+ import { DaemonError, post_daemon } from '../daemon_wire.js';
11
+ import { parse_duration_minutes } from '../utils/duration.js';
12
+ import { HugRefusedError } from './errors.js';
13
+ import { DEFAULT_HUG_MINUTES, HugSpecSchema } from './types.js';
14
+ /** Attempts for `open` / `close` when cliqd can't be reached. */
15
+ const ATTEMPTS = 4;
16
+ const RETRY_BASE_MS = 500;
17
+ /** `next` waits this long on cliqd; the HTTP timeout is a little longer. */
18
+ const NEXT_WAIT_MS = 25_000;
19
+ /** How long `next` keeps retrying while cliqd can't be reached, and its longest pause between tries. */
20
+ export const NEXT_OUTAGE_MS = 10 * 60_000;
21
+ const NEXT_RETRY_MAX_MS = 15_000;
22
+ /**
23
+ * The phase's Hug defaults from the environment cliqd sets: `CLIQ_HUG_CHANNELS` (JSON list),
24
+ * `CLIQ_HUG_TIMEOUT` and `CLIQ_HUG_REMIND_EVERY` (minutes).
25
+ */
26
+ export function hug_defaults_from_env(env = process.env) {
27
+ let channels = [];
28
+ try {
29
+ const parsed = JSON.parse(env['CLIQ_HUG_CHANNELS'] ?? '[]');
30
+ if (Array.isArray(parsed))
31
+ channels = parsed.filter((c) => typeof c === 'string' && c.trim() !== '');
32
+ }
33
+ catch { /* not JSON: no default channels */ }
34
+ const timeout = parse_duration_minutes(env['CLIQ_HUG_TIMEOUT']);
35
+ const remind = parse_duration_minutes(env['CLIQ_HUG_REMIND_EVERY']);
36
+ return {
37
+ channels,
38
+ ...(timeout ? { expires_in_min: timeout } : {}),
39
+ ...(remind ? { remind_every_min: remind } : {}),
40
+ };
41
+ }
42
+ /**
43
+ * The spec with the phase's defaults filled in (§8.6): what the agent set is used as given; what it
44
+ * left out comes from the phase, then the SDK (24h, no reminders). Checked with the shared schema.
45
+ *
46
+ * @throws HugRefusedError when the result isn't a valid Hug
47
+ */
48
+ export function with_hug_defaults(spec, defaults) {
49
+ const reminders = spec.reminders
50
+ ?? (defaults.remind_every_min ? { every_min: defaults.remind_every_min } : undefined);
51
+ const filled = {
52
+ ...spec,
53
+ channels: spec.channels ?? [...defaults.channels],
54
+ expires_in_min: spec.expires_in_min ?? defaults.expires_in_min ?? DEFAULT_HUG_MINUTES,
55
+ ...(reminders ? { reminders } : {}),
56
+ };
57
+ const parsed = HugSpecSchema.safeParse(filled);
58
+ if (!parsed.success) {
59
+ const problems = parsed.error.issues.map((i) => (i.path.join('.') || 'spec') + ': ' + i.message);
60
+ throw new HugRefusedError(`Invalid Hug: ${problems.join('; ')}`);
61
+ }
62
+ return parsed.data;
63
+ }
64
+ /** cliqd's Hug routes, for one phase iteration. */
65
+ export class HugClient {
66
+ transport;
67
+ constructor(transport) {
68
+ this.transport = transport;
69
+ }
70
+ /**
71
+ * Open a Hug (the spec already has its defaults). Retried with the same `request_id`.
72
+ *
73
+ * @throws HugRefusedError when cliqd refuses it
74
+ */
75
+ async open(spec, opts) {
76
+ const t = this.transport;
77
+ try {
78
+ const reply = await retry(() => post_daemon(t.daemon_url, '/v1/hugs/open', {
79
+ run_id: t.run_id,
80
+ phase: t.phase,
81
+ iteration: t.iteration,
82
+ request_id: opts.request_id,
83
+ ...(opts.state === undefined ? {} : { state: opts.state }),
84
+ ...spec,
85
+ }));
86
+ return reply.hug_id;
87
+ }
88
+ catch (err) {
89
+ if (err instanceof DaemonError)
90
+ throw new HugRefusedError(err.message);
91
+ throw err;
92
+ }
93
+ }
94
+ /**
95
+ * Events after each cursor, waiting up to `wait_ms` (25s) for one. A timeout, a connection
96
+ * failure or a 5xx is retried with backoff until cliqd has been unreachable for
97
+ * {@link NEXT_OUTAGE_MS}; cliqd's other answers (e.g. Hug not found) are thrown at once.
98
+ */
99
+ async next(hug_ids, after, wait_ms = NEXT_WAIT_MS) {
100
+ const wait = Math.min(wait_ms, NEXT_WAIT_MS);
101
+ let failing_since = null;
102
+ for (let attempt = 0;; attempt++) {
103
+ try {
104
+ return await post_daemon(this.transport.daemon_url, '/v1/hugs/next', {
105
+ hug_ids, after, wait_ms: wait,
106
+ }, { timeout_ms: wait + 10_000 });
107
+ }
108
+ catch (err) {
109
+ if (err instanceof DaemonError && err.status < 500)
110
+ throw err;
111
+ failing_since ??= Date.now();
112
+ if (Date.now() - failing_since >= NEXT_OUTAGE_MS)
113
+ throw err;
114
+ await new Promise((resolve) => setTimeout(resolve, Math.min(RETRY_BASE_MS * 2 ** attempt, NEXT_RETRY_MAX_MS)));
115
+ }
116
+ }
117
+ }
118
+ /** Record the requester's state and how far it has processed. */
119
+ async save_state(hug_id, state, cursor, progress) {
120
+ const body = { hug_id, state, cursor, ...(progress === undefined ? {} : { progress }) };
121
+ await retry(() => post_daemon(this.transport.daemon_url, '/v1/hugs/save_state', body));
122
+ }
123
+ /** End a Hug with its outcome (idempotent). */
124
+ async close(hug_id, outcome) {
125
+ await retry(() => post_daemon(this.transport.daemon_url, '/v1/hugs/close', { hug_id, outcome: outcome.slice(0, 2_000) }));
126
+ }
127
+ }
128
+ /** Run `fn`, retrying transport failures (not cliqd's answers) with backoff. */
129
+ async function retry(fn) {
130
+ let last;
131
+ for (let attempt = 0; attempt < ATTEMPTS; attempt++) {
132
+ try {
133
+ return await fn();
134
+ }
135
+ catch (err) {
136
+ if (err instanceof DaemonError)
137
+ throw err;
138
+ last = err;
139
+ await new Promise((resolve) => setTimeout(resolve, RETRY_BASE_MS * 2 ** attempt));
140
+ }
141
+ }
142
+ throw last;
143
+ }
144
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/hug/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAuBhE,iEAAiE;AACjE,MAAM,QAAQ,GAAG,CAAC,CAAC;AACnB,MAAM,aAAa,GAAG,GAAG,CAAC;AAC1B,4EAA4E;AAC5E,MAAM,YAAY,GAAG,MAAM,CAAC;AAC5B,wGAAwG;AACxG,MAAM,CAAC,MAAM,cAAc,GAAG,EAAE,GAAG,MAAM,CAAC;AAC1C,MAAM,iBAAiB,GAAG,MAAM,CA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G,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC;QACtF,CAAC;IACL,CAAC;IACD,MAAM,IAAI,CAAC;AACf,CAAC"}
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Context blocks — what a person reads beside a hug's question (files by artifact id, notes,
3
+ * check results, a transcript). Shared by the hugs that show context (`form`, `approval`).
4
+ */
5
+ import { z } from 'zod';
6
+ /** Largest serialized `context` accepted (files are referenced by artifact id, never inlined). */
7
+ export declare const MAX_CONTEXT_BYTES: number;
8
+ /** One block of what a person reads besides the prompt. */
9
+ export declare const ContextBlockSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
10
+ type: z.ZodLiteral<"markdown">;
11
+ text: z.ZodString;
12
+ }, z.core.$strict>, z.ZodObject<{
13
+ type: z.ZodLiteral<"artifact">;
14
+ artifact_id: z.ZodString;
15
+ label: z.ZodOptional<z.ZodString>;
16
+ }, z.core.$strict>, z.ZodObject<{
17
+ type: z.ZodLiteral<"checks">;
18
+ results: z.ZodArray<z.ZodObject<{
19
+ name: z.ZodString;
20
+ ok: z.ZodBoolean;
21
+ summary: z.ZodOptional<z.ZodString>;
22
+ }, z.core.$strict>>;
23
+ }, z.core.$strict>, z.ZodObject<{
24
+ type: z.ZodLiteral<"transcript">;
25
+ turns: z.ZodArray<z.ZodObject<{
26
+ role: z.ZodString;
27
+ content: z.ZodString;
28
+ }, z.core.$strict>>;
29
+ }, z.core.$strict>], "type">;
30
+ /** One block of what a person reads besides the prompt. */
31
+ export type ContextBlock = z.infer<typeof ContextBlockSchema>;
32
+ /** A context list, at most {@link MAX_CONTEXT_BYTES} serialized. */
33
+ export declare const ContextSchema: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
34
+ type: z.ZodLiteral<"markdown">;
35
+ text: z.ZodString;
36
+ }, z.core.$strict>, z.ZodObject<{
37
+ type: z.ZodLiteral<"artifact">;
38
+ artifact_id: z.ZodString;
39
+ label: z.ZodOptional<z.ZodString>;
40
+ }, z.core.$strict>, z.ZodObject<{
41
+ type: z.ZodLiteral<"checks">;
42
+ results: z.ZodArray<z.ZodObject<{
43
+ name: z.ZodString;
44
+ ok: z.ZodBoolean;
45
+ summary: z.ZodOptional<z.ZodString>;
46
+ }, z.core.$strict>>;
47
+ }, z.core.$strict>, z.ZodObject<{
48
+ type: z.ZodLiteral<"transcript">;
49
+ turns: z.ZodArray<z.ZodObject<{
50
+ role: z.ZodString;
51
+ content: z.ZodString;
52
+ }, z.core.$strict>>;
53
+ }, z.core.$strict>], "type">>;
54
+ //# sourceMappingURL=context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/hug/context.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,kGAAkG;AAClG,eAAO,MAAM,iBAAiB,QAAY,CAAC;AAE3C,2DAA2D;AAC3D,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;4BAW7B,CAAC;AACH,2DAA2D;AAC3D,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAE9D,oEAAoE;AACpE,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;6BAIxB,CAAC"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Context blocks — what a person reads beside a hug's question (files by artifact id, notes,
3
+ * check results, a transcript). Shared by the hugs that show context (`form`, `approval`).
4
+ */
5
+ import { z } from 'zod';
6
+ /** Largest serialized `context` accepted (files are referenced by artifact id, never inlined). */
7
+ export const MAX_CONTEXT_BYTES = 64 * 1024;
8
+ /** One block of what a person reads besides the prompt. */
9
+ export const ContextBlockSchema = z.discriminatedUnion('type', [
10
+ z.strictObject({ type: z.literal('markdown'), text: z.string() }),
11
+ z.strictObject({ type: z.literal('artifact'), artifact_id: z.string().min(1), label: z.string().max(200).optional() }),
12
+ z.strictObject({
13
+ type: z.literal('checks'),
14
+ results: z.array(z.strictObject({ name: z.string(), ok: z.boolean(), summary: z.string().optional() })),
15
+ }),
16
+ z.strictObject({
17
+ type: z.literal('transcript'),
18
+ turns: z.array(z.strictObject({ role: z.string(), content: z.string() })),
19
+ }),
20
+ ]);
21
+ /** A context list, at most {@link MAX_CONTEXT_BYTES} serialized. */
22
+ export const ContextSchema = z.array(ContextBlockSchema).superRefine((blocks, ctx) => {
23
+ if (new TextEncoder().encode(JSON.stringify(blocks)).length > MAX_CONTEXT_BYTES) {
24
+ ctx.addIssue({ code: 'custom', message: `context is larger than ${MAX_CONTEXT_BYTES} bytes — attach files as artifacts` });
25
+ }
26
+ });
27
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/hug/context.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,kGAAkG;AAClG,MAAM,CAAC,MAAM,iBAAiB,GAAG,EAAE,GAAG,IAAI,CAAC;AAE3C,2DAA2D;AAC3D,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC,kBAAkB,CAAC,MAAM,EAAE;IAC3D,CAAC,CAAC,YAAY,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC;IACjE,CAAC,CAAC,YAAY,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC;IACtH,CAAC,CAAC,YAAY,CAAC;QACX,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC;QACzB,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,YAAY,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;KAC1G,CAAC;IACF,CAAC,CAAC,YAAY,CAAC;QACX,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC;QAC7B,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,YAAY,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;KAC5E,CAAC;CACL,CAAC,CAAC;AAIH,oEAAoE;AACpE,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC,WAAW,CAAC,CAAC,MAAM,EAAE,GAAG,EAAE,EAAE;IACjF,IAAI,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,GAAG,iBAAiB,EAAE,CAAC;QAC9E,GAAG,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,0BAA0B,iBAAiB,oCAAoC,EAAE,CAAC,CAAC;IAC/H,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,116 @@
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 { type Checked } from './problems.js';
14
+ /** A hug's name: lowercase letters, digits and hyphens, starting with a letter (its folder's name). */
15
+ export declare const HUG_NAME_RE: RegExp;
16
+ /** Longest summary the Hub stores (PLAN-hug-widgets §3.2). */
17
+ export declare const MAX_SUMMARY_LENGTH = 120;
18
+ /** An upload slot: a key an answer may carry uploaded files under, and what it accepts. */
19
+ export interface FileSlot {
20
+ readonly name: string;
21
+ /** MIME types (`image/*`) or extensions (`.pdf`). */
22
+ readonly accept?: readonly string[];
23
+ readonly max_bytes?: number;
24
+ readonly multiple?: boolean;
25
+ readonly required?: boolean;
26
+ }
27
+ /** What `file()` records on a field, so the definition can list its upload slots. */
28
+ interface FileMeta {
29
+ readonly accept?: readonly string[];
30
+ readonly max_bytes?: number;
31
+ readonly multiple?: boolean;
32
+ }
33
+ /** A file reference in an answer: the id the upload returned (metadata may ride along). */
34
+ export declare const FileRefSchema: z.ZodObject<{
35
+ artifact_id: z.ZodString;
36
+ }, z.core.$loose>;
37
+ /** A file reference in an answer. */
38
+ export type FileRef = z.infer<typeof FileRefSchema>;
39
+ /**
40
+ * The type of a `file()` field: one reference, or a list with `multiple`; `optional` makes the key optional in the
41
+ * answer's type too (a `z.ZodOptional`), as it is at runtime.
42
+ */
43
+ export type FileField<O> = O extends {
44
+ multiple: true;
45
+ } ? (O extends {
46
+ optional: true;
47
+ } ? z.ZodOptional<z.ZodType<FileRef[]>> : z.ZodType<FileRef[]>) : (O extends {
48
+ optional: true;
49
+ } ? z.ZodOptional<z.ZodType<FileRef>> : z.ZodType<FileRef>);
50
+ /** Most files one `multiple` upload slot takes. */
51
+ export declare const MAX_FILES_PER_SLOT = 10;
52
+ /**
53
+ * An upload field for a definition's `values`. Its key becomes an upload slot of the Hug (`files`), so nobody declares
54
+ * upload keys separately.
55
+ *
56
+ * @param opts - What it accepts; `multiple` for a list of files; `optional` when an answer may leave it out.
57
+ */
58
+ export declare function file<const O extends FileMeta & {
59
+ optional?: boolean;
60
+ } = Record<never, never>>(opts?: O): FileField<O>;
61
+ /** The upload slots of a values schema: its top-level fields made with `file()`. */
62
+ export declare function file_slots_of(values: z.ZodType): FileSlot[];
63
+ /** What a definition is made from. */
64
+ export interface HugSpec<P, V> {
65
+ /** The hug's name (its folder's name). */
66
+ readonly name: string;
67
+ /** A short title, for lists and for models choosing or describing a hug. */
68
+ readonly title?: string;
69
+ /** What the hug is for and what it asks, for models and lists. */
70
+ readonly description?: string;
71
+ /** What the hug is asked. */
72
+ readonly params: z.ZodType<P>;
73
+ /** What it answers — a schema, or a schema built from the params. */
74
+ readonly values: z.ZodType<V> | ((params: P) => z.ZodType<V>);
75
+ /** Upload slots — by default the `file()` fields of `values`. */
76
+ readonly files?: readonly FileSlot[] | ((params: P) => readonly FileSlot[]);
77
+ /** The one-line text the Hub shows for an answer (default "Responded"). */
78
+ readonly summary?: (values: V, params: P) => string;
79
+ }
80
+ /** What a model (or a list) needs to know about a hug, without running it. */
81
+ export interface HugDescription {
82
+ readonly name: string;
83
+ readonly title: string;
84
+ readonly description: string;
85
+ /** The params as JSON Schema. */
86
+ readonly params_schema: Record<string, unknown>;
87
+ }
88
+ /** A hug's definition. */
89
+ export interface HugDefinition<P = unknown, V = unknown> {
90
+ readonly name: string;
91
+ readonly title: string;
92
+ readonly description: string;
93
+ /** The params schema. */
94
+ readonly params: z.ZodType<P>;
95
+ /** The values schema for these params. */
96
+ values_schema(params: P): z.ZodType<V>;
97
+ /** The upload slots for these params. */
98
+ files(params: P): FileSlot[];
99
+ /** The one-line summary of an answer (at most {@link MAX_SUMMARY_LENGTH} characters). */
100
+ summary(values: V, params: P): string;
101
+ /** Check params. */
102
+ check_params(raw: unknown): Checked<P>;
103
+ /** Check an answer against the schema these params give. */
104
+ check(raw: unknown, params: P): Checked<V>;
105
+ /** Name, title, description and the params as JSON Schema. */
106
+ describe(): HugDescription;
107
+ }
108
+ /**
109
+ * Define a hug.
110
+ *
111
+ * @param spec - The hug's name, params, values, and optionally its title, description, files and summary.
112
+ * @throws Error when the name isn't a hug name.
113
+ */
114
+ export declare function define_hug<P, V>(spec: HugSpec<P, V>): HugDefinition<P, V>;
115
+ export {};
116
+ //# sourceMappingURL=define.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"define.d.ts","sourceRoot":"","sources":["../../src/hug/define.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAqB,KAAK,OAAO,EAAE,MAAM,eAAe,CAAC;AAEhE,uGAAuG;AACvG,eAAO,MAAM,WAAW,QAA2B,CAAC;AAEpD,8DAA8D;AAC9D,eAAO,MAAM,kBAAkB,MAAM,CAAC;AAEtC,2FAA2F;AAC3F,MAAM,WAAW,QAAQ;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,qDAAqD;IACrD,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;CAC/B;AAED,qFAAqF;AACrF,UAAU,QAAQ;IACd,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;CAC/B;AAED,2FAA2F;AAC3F,eAAO,MAAM,aAAa;;iBAExB,CAAC;AACH,qCAAqC;AACrC,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAA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