@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,54 @@
1
+ /**
2
+ * TCP server side: accept sockets and wrap each one in a {@link Connection}.
3
+ */
4
+ import net from 'node:net';
5
+ import { Connection } from './connection.js';
6
+ /**
7
+ * NDJSON TCP server. Every accepted socket becomes a {@link Connection} with the
8
+ * options given to the constructor; open connections are closed by `close()`.
9
+ */
10
+ export class TcpServer {
11
+ server;
12
+ connections = new Set();
13
+ conn_options;
14
+ on_connection_handler;
15
+ constructor(options = {}) {
16
+ this.conn_options = options;
17
+ this.server = net.createServer((socket) => {
18
+ const conn = new Connection(socket, this.conn_options);
19
+ this.connections.add(conn);
20
+ conn.on('close', () => this.connections.delete(conn));
21
+ this.on_connection_handler?.(conn);
22
+ });
23
+ }
24
+ /** Set the handler called with each new connection (replaces any earlier one). */
25
+ on_connection(handler) {
26
+ this.on_connection_handler = handler;
27
+ }
28
+ /** Start listening; resolves with the bound address, rejects on a listen error (e.g. port in use). */
29
+ listen(options = {}) {
30
+ const { host = '0.0.0.0', port = 0 } = options;
31
+ return new Promise((resolve, reject) => {
32
+ this.server.once('error', reject);
33
+ this.server.listen(port, host, () => {
34
+ const addr = this.server.address();
35
+ resolve({ host: addr.address, port: addr.port });
36
+ });
37
+ });
38
+ }
39
+ /** Close every open connection, then stop the server; resolves once it has stopped. */
40
+ close() {
41
+ return new Promise((resolve) => {
42
+ for (const conn of this.connections) {
43
+ conn.close();
44
+ }
45
+ this.connections.clear();
46
+ this.server.close(() => resolve());
47
+ });
48
+ }
49
+ /** Number of connections currently open. */
50
+ get connection_count() {
51
+ return this.connections.size;
52
+ }
53
+ }
54
+ //# sourceMappingURL=server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/tcp/server.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,GAAG,MAAM,UAAU,CAAC;AAC3B,OAAO,EAAE,UAAU,EAA0B,MAAM,iBAAiB,CAAC;AAUrE;;;GAGG;AACH,MAAM,OAAO,SAAS;IACH,MAAM,CAAa;IACnB,WAAW,GAAG,IAAI,GAAG,EAAc,CAAC;IACpC,YAAY,CAAoB;IACzC,qBAAqB,CAA8B;IAE3D,YAAY,UAA6B,EAAE;QACzC,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC;QAC5B,IAAI,CAAC,MAAM,GAAG,GAAG,CAAC,YAAY,CAAC,CAAC,MAAM,EAAE,EAAE;YACxC,MAAM,IAAI,GAAG,IAAI,UAAU,CAAC,MAAM,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;YACvD,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YAC3B,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;YACtD,IAAI,CAAC,qBAAqB,EAAE,CAAC,IAAI,CAAC,CAAC;QACrC,CAAC,CAAC,CAAC;IACL,CAAC;IAED,kFAAkF;IAClF,aAAa,CAAC,OAAmC;QAC/C,IAAI,CAAC,qBAAqB,GAAG,OAAO,CAAC;IACvC,CAAC;IAED,sGAAsG;IACtG,MAAM,CAAC,UAAyB,EAAE;QAChC,MAAM,EAAE,IAAI,GAAG,SAAS,EAAE,IAAI,GAAG,CAAC,EAAE,GAAG,OAAO,CAAC;QAC/C,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACrC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;YAClC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE;gBAClC,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,EAAqB,CAAC;gBACtD,OAAO,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;YACnD,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;IAED,uFAAuF;IACvF,KAAK;QACH,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YAC7B,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;gBACpC,IAAI,CAAC,KAAK,EAAE,CAAC;YACf,CAAC;YACD,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC;YACzB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC;QACrC,CAAC,CAAC,CAAC;IACL,CAAC;IAED,4CAA4C;IAC5C,IAAI,gBAAgB;QAClB,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;IAC/B,CAAC;CACF"}
@@ -0,0 +1,88 @@
1
+ /**
2
+ * A team bundle: the files a team is made of (PLAN-team-bundle §2.2), and the one way every repo
3
+ * reads, writes, packs and unpacks it. Moved here from Core's `package_parser.ts` and cliqd's
4
+ * `zip_team_package` so the CLI, cliqd and Core all carry the same files.
5
+ */
6
+ /** A team's files by bundle path (`team.yml`, `roles/x.md`, …), as text. */
7
+ export interface TeamBundle {
8
+ files: Record<string, string>;
9
+ }
10
+ /** The largest packed bundle accepted (zip bytes). */
11
+ export declare const MAX_BUNDLE_PACKED: number;
12
+ /** The most a team's files may total, unpacked (PLAN-team-bundle §2.2: they travel as JSON). */
13
+ export declare const MAX_BUNDLE_UNPACKED: number;
14
+ /** The most files a bundle may hold. */
15
+ export declare const MAX_BUNDLE_FILES = 1000;
16
+ /** The bundle's main file. */
17
+ export declare const TEAM_YML = "team.yml";
18
+ /** Raised when a bundle can't be read, packed or unpacked. */
19
+ export declare class TeamBundleError extends Error {
20
+ readonly code: 'too_large' | 'no_team_yml' | 'not_a_zip' | 'unsafe_path' | 'not_text' | 'no_role_file';
21
+ constructor(code: 'too_large' | 'no_team_yml' | 'not_a_zip' | 'unsafe_path' | 'not_text' | 'no_role_file', message: string);
22
+ }
23
+ /**
24
+ * Whether a path is part of a team: `team.yml`, `dependencies.yml`, `README.md`, `roles/<name>.md`, or a file of a
25
+ * team hug's built bundle (`hugs/<name>/dist/**`). A team is text; anything else (images, scripts, subfolders of
26
+ * roles/, a hug's source) isn't part of it.
27
+ *
28
+ * @param path - A bundle path, `/`-separated.
29
+ */
30
+ export declare function is_bundle_path(path: string): boolean;
31
+ /** Whether a path is a file of a team hug's built bundle (`hugs/<name>/dist/**`). */
32
+ export declare function is_hug_bundle_path(path: string): boolean;
33
+ /**
34
+ * Bundle paths that aren't part of a team; a lint warns about them.
35
+ *
36
+ * @param bundle - The bundle to check.
37
+ */
38
+ export declare function unknown_paths(bundle: TeamBundle): string[];
39
+ /**
40
+ * Read a team directory as a bundle: `team.yml` and every other team file in it.
41
+ *
42
+ * @param dir - The team directory.
43
+ * @throws TeamBundleError `no_team_yml` when the directory has no team.yml; `too_large` over the limit.
44
+ */
45
+ export declare function read_bundle(dir: string): TeamBundle;
46
+ /**
47
+ * Write a bundle's files into a directory (created as needed).
48
+ *
49
+ * @param dir - Where to write.
50
+ * @param bundle - The bundle.
51
+ * @throws TeamBundleError `unsafe_path` for a path that would leave `dir`.
52
+ */
53
+ export declare function write_bundle(dir: string, bundle: TeamBundle): void;
54
+ /**
55
+ * Pack a bundle as a zip.
56
+ *
57
+ * @param bundle - The bundle.
58
+ * @returns The zip bytes.
59
+ */
60
+ export declare function pack_bundle(bundle: TeamBundle): Promise<Buffer>;
61
+ /** Whether bytes start like a zip (`PK`). */
62
+ export declare function is_zip(data: Buffer): boolean;
63
+ /**
64
+ * Unpack a zip into a bundle. Directories are skipped; a single top-level folder wrapping every
65
+ * file (`my-team/team.yml`) is unwrapped.
66
+ *
67
+ * @param data - The zip bytes.
68
+ * @throws TeamBundleError `not_a_zip`, `too_large`, `unsafe_path`.
69
+ */
70
+ export declare function unpack_bundle(data: Buffer): Promise<TeamBundle>;
71
+ /**
72
+ * A hash of the bundle's files, for checking a download arrived intact and telling whether two
73
+ * copies differ. Not an identity: a team version is its team id and version.
74
+ *
75
+ * @param bundle - The bundle.
76
+ * @returns Hex sha256 over the sorted paths and their contents.
77
+ */
78
+ export declare function content_hash(bundle: TeamBundle): string;
79
+ /**
80
+ * The role files in a bundle, by role name (`roles/<name>.md` → `<name>`).
81
+ *
82
+ * @param bundle - The bundle.
83
+ */
84
+ export declare function bundle_roles(bundle: TeamBundle): Array<{
85
+ name: string;
86
+ content: string;
87
+ }>;
88
+ //# sourceMappingURL=bundle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bundle.d.ts","sourceRoot":"","sources":["../../src/team/bundle.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAQH,4EAA4E;AAC5E,MAAM,WAAW,UAAU;IACvB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACjC;AAED,sDAAsD;AACtD,eAAO,MAAM,iBAAiB,QAAmB,CAAC;AAClD,gGAAgG;AAChG,eAAO,MAAM,mBAAmB,QAAmB,CAAC;AACpD,wCAAwC;AACxC,eAAO,MAAM,gBAAgB,OAAO,CAAC;AAErC,8BAA8B;AAC9B,eAAO,MAAM,QAAQ,aAAa,CAAC;AAKnC,8DAA8D;AAC9D,qBAAa,eAAgB,SAAQ,KAAK;IAC1B,QAAQ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packs and unpacks it. Moved here from Core's `package_parser.ts` and cliqd's
4
+ * `zip_team_package` so the CLI, cliqd and Core all carry the same files.
5
+ */
6
+ import { createHash } from 'node:crypto';
7
+ import { mkdirSync, readdirSync, readFileSync, statSync, writeFileSync } from 'node:fs';
8
+ import { dirname, join, relative, sep } from 'node:path';
9
+ import JSZip from 'jszip';
10
+ /** The largest packed bundle accepted (zip bytes). */
11
+ export const MAX_BUNDLE_PACKED = 10 * 1024 * 1024;
12
+ /** The most a team's files may total, unpacked (PLAN-team-bundle §2.2: they travel as JSON). */
13
+ export const MAX_BUNDLE_UNPACKED = 10 * 1024 * 1024;
14
+ /** The most files a bundle may hold. */
15
+ export const MAX_BUNDLE_FILES = 1000;
16
+ /** The bundle's main file. */
17
+ export const TEAM_YML = 'team.yml';
18
+ /** Optional top-level files a bundle may carry. */
19
+ const OPTIONAL_FILES = new Set(['dependencies.yml', 'README.md']);
20
+ /** Raised when a bundle can't be read, packed or unpacked. */
21
+ export class TeamBundleError extends Error {
22
+ code;
23
+ constructor(code, message) {
24
+ super(message);
25
+ this.code = code;
26
+ this.name = 'TeamBundleError';
27
+ }
28
+ }
29
+ /** A role brief: `roles/<name>.md`, directly in `roles/` (decided: `.md` only, no subfolders). */
30
+ const ROLE_PATH = /^roles\/[^/]+\.md$/;
31
+ /**
32
+ * A team hug's built bundle (PLAN-hug-widgets §4.6): `hugs/<name>/dist/**`. Only `dist/` — never the hug's source
33
+ * (`src/`, `hug.ts`, `package.json`). The name follows the hug-name rule (lowercase letters, digits, `-`).
34
+ */
35
+ const HUG_DIST_PATH = /^hugs\/[a-z][a-z0-9-]{0,63}\/dist\/[^/]/;
36
+ /**
37
+ * Whether a path is part of a team: `team.yml`, `dependencies.yml`, `README.md`, `roles/<name>.md`, or a file of a
38
+ * team hug's built bundle (`hugs/<name>/dist/**`). A team is text; anything else (images, scripts, subfolders of
39
+ * roles/, a hug's source) isn't part of it.
40
+ *
41
+ * @param path - A bundle path, `/`-separated.
42
+ */
43
+ export function is_bundle_path(path) {
44
+ return path === TEAM_YML || OPTIONAL_FILES.has(path) || ROLE_PATH.test(path) || is_hug_bundle_path(path);
45
+ }
46
+ /** Whether a path is a file of a team hug's built bundle (`hugs/<name>/dist/**`). */
47
+ export function is_hug_bundle_path(path) {
48
+ return HUG_DIST_PATH.test(path) && !path.split('/').some((part) => part === '..' || part === '');
49
+ }
50
+ /** Folders `read_bundle` walks into: `roles/`, `hugs/`, `hugs/<name>/` and everything under `hugs/<name>/dist/`. */
51
+ function walks_into(path) {
52
+ if (path === 'roles' || path === 'hugs')
53
+ return true;
54
+ const parts = path.split('/');
55
+ if (parts[0] !== 'hugs')
56
+ return false;
57
+ if (parts.length === 2)
58
+ return true;
59
+ return parts[2] === 'dist';
60
+ }
61
+ /** Decodes UTF-8 and throws on bytes that aren't (a binary file). */
62
+ const STRICT_UTF8 = new TextDecoder('utf-8', { fatal: true });
63
+ /**
64
+ * Bundle paths that aren't part of a team; a lint warns about them.
65
+ *
66
+ * @param bundle - The bundle to check.
67
+ */
68
+ export function unknown_paths(bundle) {
69
+ return Object.keys(bundle.files).filter((p) => !is_bundle_path(p)).sort();
70
+ }
71
+ /** A path that would escape the bundle when written or unpacked. */
72
+ function unsafe(path) {
73
+ return path.startsWith('/') || path.split('/').some((part) => part === '..') || path.includes('\\');
74
+ }
75
+ /**
76
+ * Read a team directory as a bundle: `team.yml` and every other team file in it.
77
+ *
78
+ * @param dir - The team directory.
79
+ * @throws TeamBundleError `no_team_yml` when the directory has no team.yml; `too_large` over the limit.
80
+ */
81
+ export function read_bundle(dir) {
82
+ const files = {};
83
+ let total = 0;
84
+ const walk = (at) => {
85
+ for (const name of readdirSync(at).sort()) {
86
+ if (name.startsWith('.') || name === 'node_modules')
87
+ continue;
88
+ const full = join(at, name);
89
+ const path = relative(dir, full).split(sep).join('/');
90
+ if (statSync(full).isDirectory()) {
91
+ if (walks_into(path))
92
+ walk(full);
93
+ continue;
94
+ }
95
+ if (!is_bundle_path(path))
96
+ continue;
97
+ let text;
98
+ try {
99
+ text = STRICT_UTF8.decode(readFileSync(full));
100
+ }
101
+ catch {
102
+ throw new TeamBundleError('not_text', `${path} isn't text (a team's files are UTF-8 text)`);
103
+ }
104
+ total += Buffer.byteLength(text);
105
+ if (total > MAX_BUNDLE_UNPACKED)
106
+ throw new TeamBundleError('too_large', `Team files are larger than ${MAX_BUNDLE_UNPACKED / 1024 / 1024} MB`);
107
+ files[path] = text;
108
+ }
109
+ };
110
+ walk(dir);
111
+ if (files[TEAM_YML] === undefined)
112
+ throw new TeamBundleError('no_team_yml', `No team.yml in ${dir}`);
113
+ return { files };
114
+ }
115
+ /**
116
+ * Write a bundle's files into a directory (created as needed).
117
+ *
118
+ * @param dir - Where to write.
119
+ * @param bundle - The bundle.
120
+ * @throws TeamBundleError `unsafe_path` for a path that would leave `dir`.
121
+ */
122
+ export function write_bundle(dir, bundle) {
123
+ for (const [path, text] of Object.entries(bundle.files)) {
124
+ if (unsafe(path))
125
+ throw new TeamBundleError('unsafe_path', `Bundle path '${path}' is not allowed`);
126
+ const full = join(dir, ...path.split('/'));
127
+ mkdirSync(dirname(full), { recursive: true });
128
+ writeFileSync(full, text);
129
+ }
130
+ }
131
+ /**
132
+ * Pack a bundle as a zip.
133
+ *
134
+ * @param bundle - The bundle.
135
+ * @returns The zip bytes.
136
+ */
137
+ export async function pack_bundle(bundle) {
138
+ const zip = new JSZip();
139
+ for (const path of Object.keys(bundle.files).sort())
140
+ zip.file(path, bundle.files[path]);
141
+ return zip.generateAsync({ type: 'nodebuffer', compression: 'DEFLATE' });
142
+ }
143
+ /** Whether bytes start like a zip (`PK`). */
144
+ export function is_zip(data) {
145
+ return data.length > 1 && data[0] === 0x50 && data[1] === 0x4B;
146
+ }
147
+ /**
148
+ * Unpack a zip into a bundle. Directories are skipped; a single top-level folder wrapping every
149
+ * file (`my-team/team.yml`) is unwrapped.
150
+ *
151
+ * @param data - The zip bytes.
152
+ * @throws TeamBundleError `not_a_zip`, `too_large`, `unsafe_path`.
153
+ */
154
+ export async function unpack_bundle(data) {
155
+ if (data.length > MAX_BUNDLE_PACKED)
156
+ throw new TeamBundleError('too_large', `Package too large (max ${MAX_BUNDLE_PACKED / 1024 / 1024}MB)`);
157
+ if (!is_zip(data))
158
+ throw new TeamBundleError('not_a_zip', 'Package is not a zip');
159
+ // Reviewed: packed size, file count, unpacked total and unsafe paths are all checked here.
160
+ // eslint-disable-next-line sonarjs/no-unsafe-unzip
161
+ const zip = await JSZip.loadAsync(data);
162
+ const entries = Object.values(zip.files).filter((f) => !f.dir);
163
+ if (entries.length > MAX_BUNDLE_FILES)
164
+ throw new TeamBundleError('too_large', `Package has more than ${MAX_BUNDLE_FILES} files`);
165
+ const prefix = common_folder(entries.map((f) => f.name));
166
+ const files = {};
167
+ let total = 0;
168
+ for (const entry of entries) {
169
+ const path = entry.name.slice(prefix.length);
170
+ if (!path || path.startsWith('__MACOSX/') || path.split('/').pop().startsWith('.'))
171
+ continue;
172
+ if (unsafe(path))
173
+ throw new TeamBundleError('unsafe_path', `Package path '${entry.name}' is not allowed`);
174
+ const text = await entry.async('string');
175
+ total += Buffer.byteLength(text);
176
+ if (total > MAX_BUNDLE_UNPACKED)
177
+ throw new TeamBundleError('too_large', `Package too large when extracted (max ${MAX_BUNDLE_UNPACKED / 1024 / 1024}MB)`);
178
+ files[path] = text;
179
+ }
180
+ return { files };
181
+ }
182
+ /** The one folder every path sits in (`team/`), or ''. */
183
+ function common_folder(paths) {
184
+ if (paths.length === 0 || paths.some((p) => !p.includes('/')))
185
+ return '';
186
+ const first = paths[0].split('/')[0] + '/';
187
+ return paths.every((p) => p.startsWith(first)) && first !== 'roles/' ? first : '';
188
+ }
189
+ /**
190
+ * A hash of the bundle's files, for checking a download arrived intact and telling whether two
191
+ * copies differ. Not an identity: a team version is its team id and version.
192
+ *
193
+ * @param bundle - The bundle.
194
+ * @returns Hex sha256 over the sorted paths and their contents.
195
+ */
196
+ export function content_hash(bundle) {
197
+ const hash = createHash('sha256');
198
+ for (const path of Object.keys(bundle.files).sort()) {
199
+ hash.update(path).update('\0').update(bundle.files[path]).update('\0');
200
+ }
201
+ return hash.digest('hex');
202
+ }
203
+ /**
204
+ * The role files in a bundle, by role name (`roles/<name>.md` → `<name>`).
205
+ *
206
+ * @param bundle - The bundle.
207
+ */
208
+ export function bundle_roles(bundle) {
209
+ return Object.keys(bundle.files)
210
+ .filter((p) => p.startsWith('roles/'))
211
+ .sort()
212
+ .map((p) => ({ name: p.slice('roles/'.length).replace(/\.md$/, ''), content: bundle.files[p] }));
213
+ }
214
+ //# sourceMappingURL=bundle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bundle.js","sourceRoot":"","sources":["../../src/team/bundle.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxF,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAEzD,OAAO,KAAK,MAAM,OAAO,CAAC;AAO1B,sDAAsD;AACtD,MAAM,CAAC,MAAM,iBAAiB,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;AAClD,gGAAgG;AAChG,MAAM,CAAC,MAAM,mBAAmB,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;AACpD,wCAAwC;AACxC,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,CAAC;AAErC,8BAA8B;AAC9B,MAAM,CAAC,MAAM,QAAQ,GAAG,UAAU,CAAC;AAEnC,mDAAmD;AACnD,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC,CAAC,kBAAkB,EAAE,WAAW,CAAC,CAAC,CAAC;AAElE,8DAA8D;AAC9D,MAAM,OAAO,eAAgB,SAAQ,KAAK;IACjB;IAArB,YAAqB,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EAAE,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACzG,CAAC"}
@@ -0,0 +1,31 @@
1
+ /** Raised when team.yml can't take the identity (no name, not a mapping, or the edit wouldn't parse back). */
2
+ export declare class TeamIdentityError extends Error {
3
+ constructor(message: string);
4
+ }
5
+ /** A team's identity: what `name` and `version` in team.yml say. */
6
+ export interface TeamIdentity {
7
+ scope?: string;
8
+ slug: string;
9
+ version?: string;
10
+ }
11
+ /**
12
+ * What team.yml says about the team's identity.
13
+ *
14
+ * @param team_yml - The team.yml text.
15
+ * @throws TeamIdentityError when it has no name.
16
+ */
17
+ export declare function read_identity(team_yml: string): TeamIdentity;
18
+ /**
19
+ * team.yml with the scope and/or version set: `name` becomes `@<scope>/<slug>` (the slug is kept), `version`
20
+ * becomes the version (added after `name` when missing). Values are written double-quoted.
21
+ *
22
+ * @param team_yml - The team.yml text.
23
+ * @param identity - The scope and/or version to write; omitted fields are left as they are.
24
+ * @returns The new text (the same text when nothing changes).
25
+ * @throws TeamIdentityError when team.yml has no top-level name line, or the result doesn't read back.
26
+ */
27
+ export declare function set_identity(team_yml: string, identity: {
28
+ scope?: string;
29
+ version?: string;
30
+ }): string;
31
+ //# sourceMappingURL=identity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../../src/team/identity.ts"],"names":[],"mappings":"AASA,8GAA8G;AAC9G,qBAAa,iBAAkB,SAAQ,KAAK;gBAC5B,OAAO,EAAE,MAAM;CAI9B;AAED,oEAAoE;AACpE,MAAM,WAAW,YAAY;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB;AAgBD;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,YAAY,CAO5D;AAED;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAyBrG"}
@@ -0,0 +1,83 @@
1
+ /**
2
+ * A team's identity in its team.yml: `name: "@scope/slug"` and `version: "x.y.z"` (PLAN-team-bundle S2). The one
3
+ * way the CLI (before upload) and Core (before publish) write the scope and version they were given, so the
4
+ * stored team.yml always says what was published. Only those two top-level lines change; the rest of the file,
5
+ * comments and order included, stays as it was.
6
+ */
7
+ import yaml from 'js-yaml';
8
+ import { TEAM_YML } from './bundle.js';
9
+ /** Raised when team.yml can't take the identity (no name, not a mapping, or the edit wouldn't parse back). */
10
+ export class TeamIdentityError extends Error {
11
+ constructor(message) {
12
+ super(message);
13
+ this.name = 'TeamIdentityError';
14
+ }
15
+ }
16
+ /** A top-level `key:` line (column 0) and its value. */
17
+ const top_level = (key) => new RegExp(`^${key}[ \\t]*:[ \\t]*(.*)$`, 'm');
18
+ function parse_doc(text) {
19
+ let doc;
20
+ try {
21
+ doc = yaml.load(text);
22
+ }
23
+ catch (err) {
24
+ throw new TeamIdentityError(`${TEAM_YML} isn't valid YAML: ${err instanceof Error ? err.message : String(err)}`);
25
+ }
26
+ if (!doc || typeof doc !== 'object' || Array.isArray(doc))
27
+ throw new TeamIdentityError(`${TEAM_YML} isn't a mapping`);
28
+ return doc;
29
+ }
30
+ /**
31
+ * What team.yml says about the team's identity.
32
+ *
33
+ * @param team_yml - The team.yml text.
34
+ * @throws TeamIdentityError when it has no name.
35
+ */
36
+ export function read_identity(team_yml) {
37
+ const doc = parse_doc(team_yml);
38
+ const name = typeof doc.name === 'string' ? doc.name.trim() : '';
39
+ if (!name)
40
+ throw new TeamIdentityError(`${TEAM_YML} has no name`);
41
+ const m = /^@([^/\s]+)\/(\S+)$/.exec(name);
42
+ const version = doc.version === undefined || doc.version === null ? undefined : String(doc.version);
43
+ return m ? { scope: m[1], slug: m[2], version } : { slug: name, version };
44
+ }
45
+ /**
46
+ * team.yml with the scope and/or version set: `name` becomes `@<scope>/<slug>` (the slug is kept), `version`
47
+ * becomes the version (added after `name` when missing). Values are written double-quoted.
48
+ *
49
+ * @param team_yml - The team.yml text.
50
+ * @param identity - The scope and/or version to write; omitted fields are left as they are.
51
+ * @returns The new text (the same text when nothing changes).
52
+ * @throws TeamIdentityError when team.yml has no top-level name line, or the result doesn't read back.
53
+ */
54
+ export function set_identity(team_yml, identity) {
55
+ const current = read_identity(team_yml);
56
+ let text = team_yml;
57
+ if (identity.scope !== undefined && identity.scope !== current.scope) {
58
+ if (!top_level('name').test(text))
59
+ throw new TeamIdentityError(`${TEAM_YML} has no top-level name line to set the scope on`);
60
+ text = text.replace(top_level('name'), `name: "@${identity.scope}/${current.slug}"`);
61
+ }
62
+ if (identity.version !== undefined && identity.version !== current.version) {
63
+ const line = `version: "${identity.version}"`;
64
+ if (top_level('version').test(text)) {
65
+ text = text.replace(top_level('version'), line);
66
+ }
67
+ else {
68
+ const name_line = top_level('name').exec(text);
69
+ if (!name_line)
70
+ throw new TeamIdentityError(`${TEAM_YML} has no top-level name line to put the version after`);
71
+ const end = name_line.index + name_line[0].length;
72
+ text = `${text.slice(0, end)}\n${line}${text.slice(end)}`;
73
+ }
74
+ }
75
+ const back = read_identity(text);
76
+ const want_scope = identity.scope ?? current.scope;
77
+ const want_version = identity.version ?? current.version;
78
+ if (back.scope !== want_scope || back.slug !== current.slug || back.version !== want_version) {
79
+ throw new TeamIdentityError(`${TEAM_YML}'s name and version couldn't be set (they don't read back)`);
80
+ }
81
+ return text;
82
+ }
83
+ //# sourceMappingURL=identity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identity.js","sourceRoot":"","sources":["../../src/team/identity.ts"],"names":[],"mappings":"AAAA;;;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NDLE_UNPACKED, TEAM_YML, TeamBundleError, bundle_roles, content_hash, is_bundle_path, is_zip, pack_bundle, read_bundle, unknown_paths, unpack_bundle, write_bundle, } from './bundle.js';
3
+ export type { TeamBundle } from './bundle.js';
4
+ export { TeamRefError, format_team_ref, is_dynamic_team_ref, parse_team_ref, pinned_version } from './ref.js';
5
+ export type { ParsedTeamRef } from './ref.js';
6
+ export { MAX_TREE_DEPTH, MAX_TREE_NODES, TeamTreeError, allowed_teams, phase_ref, resolve_tree } from './tree.js';
7
+ export type { ResolvedTree, TreeDynamicCall, TreeNode } from './tree.js';
8
+ export type { ResolveTreeOptions, TreeLookup, TreePhase, TreeTeam } from './tree.js';
9
+ export { lint_bundle } from './lint_bundle.js';
10
+ export { resolve_role } from './roles.js';
11
+ export { TeamIdentityError, read_identity, set_identity } from './identity.js';
12
+ export type { TeamIdentity } from './identity.js';
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/team/index.ts"],"names":[],"mappings":"AAAA,0GAA0G;AAC1G,OAAO,EACH,gBAAgB,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,QAAQ,EAAE,eAAe,EACnF,YAAY,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,EAAE,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,aAAa,EAAE,YAAY,GAC3H,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,mBAAmB,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC9G,YAAY,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,aAAa,EAAE,aAAa,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAClH,YAAY,EAAE,YAAY,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACzE,YAAY,EAAE,kBAAkB,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrF,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC/E,YAAY,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC"}
@@ -0,0 +1,8 @@
1
+ /** The team bundle, refs and tree (PLAN-team-bundle S0): what `@getcliqio/cliq-sdk` exports for teams. */
2
+ export { MAX_BUNDLE_FILES, MAX_BUNDLE_PACKED, MAX_BUNDLE_UNPACKED, TEAM_YML, TeamBundleError, bundle_roles, content_hash, is_bundle_path, is_zip, pack_bundle, read_bundle, unknown_paths, unpack_bundle, write_bundle, } from './bundle.js';
3
+ export { TeamRefError, format_team_ref, is_dynamic_team_ref, parse_team_ref, pinned_version } from './ref.js';
4
+ export { MAX_TREE_DEPTH, MAX_TREE_NODES, TeamTreeError, allowed_teams, phase_ref, resolve_tree } from './tree.js';
5
+ export { lint_bundle } from './lint_bundle.js';
6
+ export { resolve_role } from './roles.js';
7
+ export { TeamIdentityError, read_identity, set_identity } from './identity.js';
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/team/index.ts"],"names":[],"mappings":"AAAA,0GAA0G;AAC1G,OAAO,EACH,gBAAgB,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,QAAQ,EAAE,eAAe,EACnF,YAAY,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,EAAE,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,aAAa,EAAE,YAAY,GAC3H,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,mBAAmB,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE9G,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,aAAa,EAAE,aAAa,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAGlH,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Lint a whole bundle: the team.yml checks of `lint_team`, with the role briefs the bundle actually
3
+ * carries, plus files that aren't part of a team.
4
+ */
5
+ import { type AgentInputs, type TeamInputDef, type TeamProblem } from '../team_lint.js';
6
+ import { type TeamBundle } from './bundle.js';
7
+ /**
8
+ * Every problem in a bundle.
9
+ *
10
+ * @param bundle - The team's files.
11
+ * @param agents - Each known agent's declared inputs, by name.
12
+ * @param team_inputs - Each known sub-team's declared inputs, by `@scope/slug`.
13
+ * @returns Problems in file order: an unreadable team.yml, the team.yml problems, then unknown files.
14
+ */
15
+ export declare function lint_bundle(bundle: TeamBundle, agents: ReadonlyMap<string, AgentInputs>, team_inputs?: ReadonlyMap<string, readonly TeamInputDef[]>): TeamProblem[];
16
+ //# sourceMappingURL=lint_bundle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lint_bundle.d.ts","sourceRoot":"","sources":["../../src/team/lint_bundle.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAa,KAAK,WAAW,EAAE,KAAK,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACnG,OAAO,EAAyC,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AAErF;;;;;;;GAOG;AACH,wBAAgB,WAAW,CACvB,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,WAAW,CAAC,EACxC,WAAW,GAAE,WAAW,CAAC,MAAM,EAAE,SAAS,YAAY,EAAE,CAAa,GACtE,WAAW,EAAE,CAiBf"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Lint a whole bundle: the team.yml checks of `lint_team`, with the role briefs the bundle actually
3
+ * carries, plus files that aren't part of a team.
4
+ */
5
+ import yaml from 'js-yaml';
6
+ import { lint_team } from '../team_lint.js';
7
+ import { bundle_roles, TEAM_YML, unknown_paths } from './bundle.js';
8
+ /**
9
+ * Every problem in a bundle.
10
+ *
11
+ * @param bundle - The team's files.
12
+ * @param agents - Each known agent's declared inputs, by name.
13
+ * @param team_inputs - Each known sub-team's declared inputs, by `@scope/slug`.
14
+ * @returns Problems in file order: an unreadable team.yml, the team.yml problems, then unknown files.
15
+ */
16
+ export function lint_bundle(bundle, agents, team_inputs = new Map()) {
17
+ const problems = [];
18
+ let team;
19
+ try {
20
+ team = yaml.load(bundle.files[TEAM_YML] ?? '');
21
+ }
22
+ catch (err) {
23
+ return [{ phase: null, line: TEAM_YML, message: `team.yml doesn't parse: ${err.message}` }];
24
+ }
25
+ if (!team || typeof team !== 'object' || Array.isArray(team)) {
26
+ return [{ phase: null, line: TEAM_YML, message: 'team.yml is empty or not a mapping' }];
27
+ }
28
+ const briefs = new Set(bundle_roles(bundle).map((r) => r.name));
29
+ problems.push(...lint_team(team, agents, briefs, team_inputs));
30
+ for (const path of unknown_paths(bundle)) {
31
+ problems.push({ phase: null, line: path, message: `'${path}' is not part of a team (team.yml, roles/, dependencies.yml, README.md)` });
32
+ }
33
+ return problems;
34
+ }
35
+ //# sourceMappingURL=lint_bundle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lint_bundle.js","sourceRoot":"","sources":["../../src/team/lint_bundle.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,IAAI,MAAM,SAAS,CAAC;AAE3B,OAAO,EAAE,SAAS,EAAyD,MAAM,iBAAiB,CAAC;AACnG,OAAO,EAAE,YAA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