narai-primitives 2.0.0-rc.1

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 (440) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +64 -0
  3. package/dist/config/bootstrap.d.ts +28 -0
  4. package/dist/config/bootstrap.d.ts.map +1 -0
  5. package/dist/config/bootstrap.js +80 -0
  6. package/dist/config/bootstrap.js.map +1 -0
  7. package/dist/config/index.d.ts +13 -0
  8. package/dist/config/index.d.ts.map +1 -0
  9. package/dist/config/index.js +12 -0
  10. package/dist/config/index.js.map +1 -0
  11. package/dist/config/load.d.ts +37 -0
  12. package/dist/config/load.d.ts.map +1 -0
  13. package/dist/config/load.js +99 -0
  14. package/dist/config/load.js.map +1 -0
  15. package/dist/config/resolve.d.ts +23 -0
  16. package/dist/config/resolve.d.ts.map +1 -0
  17. package/dist/config/resolve.js +198 -0
  18. package/dist/config/resolve.js.map +1 -0
  19. package/dist/config/secrets.d.ts +20 -0
  20. package/dist/config/secrets.d.ts.map +1 -0
  21. package/dist/config/secrets.js +43 -0
  22. package/dist/config/secrets.js.map +1 -0
  23. package/dist/config/types.d.ts +104 -0
  24. package/dist/config/types.d.ts.map +1 -0
  25. package/dist/config/types.js +11 -0
  26. package/dist/config/types.js.map +1 -0
  27. package/dist/connectors/aws/cli.d.ts +3 -0
  28. package/dist/connectors/aws/cli.d.ts.map +1 -0
  29. package/dist/connectors/aws/cli.js +27 -0
  30. package/dist/connectors/aws/cli.js.map +1 -0
  31. package/dist/connectors/aws/index.d.ts +27 -0
  32. package/dist/connectors/aws/index.d.ts.map +1 -0
  33. package/dist/connectors/aws/index.js +281 -0
  34. package/dist/connectors/aws/index.js.map +1 -0
  35. package/dist/connectors/aws/lib/aws_client.d.ts +140 -0
  36. package/dist/connectors/aws/lib/aws_client.d.ts.map +1 -0
  37. package/dist/connectors/aws/lib/aws_client.js +196 -0
  38. package/dist/connectors/aws/lib/aws_client.js.map +1 -0
  39. package/dist/connectors/aws/lib/aws_error.d.ts +10 -0
  40. package/dist/connectors/aws/lib/aws_error.d.ts.map +1 -0
  41. package/dist/connectors/aws/lib/aws_error.js +15 -0
  42. package/dist/connectors/aws/lib/aws_error.js.map +1 -0
  43. package/dist/connectors/confluence/cli.d.ts +3 -0
  44. package/dist/connectors/confluence/cli.d.ts.map +1 -0
  45. package/dist/connectors/confluence/cli.js +24 -0
  46. package/dist/connectors/confluence/cli.js.map +1 -0
  47. package/dist/connectors/confluence/index.d.ts +15 -0
  48. package/dist/connectors/confluence/index.d.ts.map +1 -0
  49. package/dist/connectors/confluence/index.js +295 -0
  50. package/dist/connectors/confluence/index.js.map +1 -0
  51. package/dist/connectors/confluence/lib/confluence_client.d.ts +135 -0
  52. package/dist/connectors/confluence/lib/confluence_client.d.ts.map +1 -0
  53. package/dist/connectors/confluence/lib/confluence_client.js +329 -0
  54. package/dist/connectors/confluence/lib/confluence_client.js.map +1 -0
  55. package/dist/connectors/confluence/lib/confluence_error.d.ts +13 -0
  56. package/dist/connectors/confluence/lib/confluence_error.d.ts.map +1 -0
  57. package/dist/connectors/confluence/lib/confluence_error.js +19 -0
  58. package/dist/connectors/confluence/lib/confluence_error.js.map +1 -0
  59. package/dist/connectors/db/cli.d.ts +5 -0
  60. package/dist/connectors/db/cli.d.ts.map +1 -0
  61. package/dist/connectors/db/cli.js +34 -0
  62. package/dist/connectors/db/cli.js.map +1 -0
  63. package/dist/connectors/db/config.d.ts +18 -0
  64. package/dist/connectors/db/config.d.ts.map +1 -0
  65. package/dist/connectors/db/config.js +142 -0
  66. package/dist/connectors/db/config.js.map +1 -0
  67. package/dist/connectors/db/connector.d.ts +31 -0
  68. package/dist/connectors/db/connector.d.ts.map +1 -0
  69. package/dist/connectors/db/connector.js +175 -0
  70. package/dist/connectors/db/connector.js.map +1 -0
  71. package/dist/connectors/db/dispatcher.d.ts +36 -0
  72. package/dist/connectors/db/dispatcher.d.ts.map +1 -0
  73. package/dist/connectors/db/dispatcher.js +597 -0
  74. package/dist/connectors/db/dispatcher.js.map +1 -0
  75. package/dist/connectors/db/index.d.ts +22 -0
  76. package/dist/connectors/db/index.d.ts.map +1 -0
  77. package/dist/connectors/db/index.js +26 -0
  78. package/dist/connectors/db/index.js.map +1 -0
  79. package/dist/connectors/db/lib/audit.d.ts +32 -0
  80. package/dist/connectors/db/lib/audit.d.ts.map +1 -0
  81. package/dist/connectors/db/lib/audit.js +130 -0
  82. package/dist/connectors/db/lib/audit.js.map +1 -0
  83. package/dist/connectors/db/lib/connection.d.ts +61 -0
  84. package/dist/connectors/db/lib/connection.d.ts.map +1 -0
  85. package/dist/connectors/db/lib/connection.js +326 -0
  86. package/dist/connectors/db/lib/connection.js.map +1 -0
  87. package/dist/connectors/db/lib/credentials.d.ts +60 -0
  88. package/dist/connectors/db/lib/credentials.d.ts.map +1 -0
  89. package/dist/connectors/db/lib/credentials.js +117 -0
  90. package/dist/connectors/db/lib/credentials.js.map +1 -0
  91. package/dist/connectors/db/lib/drivers/base.d.ts +83 -0
  92. package/dist/connectors/db/lib/drivers/base.d.ts.map +1 -0
  93. package/dist/connectors/db/lib/drivers/base.js +46 -0
  94. package/dist/connectors/db/lib/drivers/base.js.map +1 -0
  95. package/dist/connectors/db/lib/drivers/dynamodb.d.ts +108 -0
  96. package/dist/connectors/db/lib/drivers/dynamodb.d.ts.map +1 -0
  97. package/dist/connectors/db/lib/drivers/dynamodb.js +468 -0
  98. package/dist/connectors/db/lib/drivers/dynamodb.js.map +1 -0
  99. package/dist/connectors/db/lib/drivers/mongodb.d.ts +60 -0
  100. package/dist/connectors/db/lib/drivers/mongodb.d.ts.map +1 -0
  101. package/dist/connectors/db/lib/drivers/mongodb.js +371 -0
  102. package/dist/connectors/db/lib/drivers/mongodb.js.map +1 -0
  103. package/dist/connectors/db/lib/drivers/mysql.d.ts +45 -0
  104. package/dist/connectors/db/lib/drivers/mysql.d.ts.map +1 -0
  105. package/dist/connectors/db/lib/drivers/mysql.js +265 -0
  106. package/dist/connectors/db/lib/drivers/mysql.js.map +1 -0
  107. package/dist/connectors/db/lib/drivers/oracle.d.ts +53 -0
  108. package/dist/connectors/db/lib/drivers/oracle.d.ts.map +1 -0
  109. package/dist/connectors/db/lib/drivers/oracle.js +350 -0
  110. package/dist/connectors/db/lib/drivers/oracle.js.map +1 -0
  111. package/dist/connectors/db/lib/drivers/postgresql.d.ts +65 -0
  112. package/dist/connectors/db/lib/drivers/postgresql.d.ts.map +1 -0
  113. package/dist/connectors/db/lib/drivers/postgresql.js +294 -0
  114. package/dist/connectors/db/lib/drivers/postgresql.js.map +1 -0
  115. package/dist/connectors/db/lib/drivers/register.d.ts +16 -0
  116. package/dist/connectors/db/lib/drivers/register.d.ts.map +1 -0
  117. package/dist/connectors/db/lib/drivers/register.js +111 -0
  118. package/dist/connectors/db/lib/drivers/register.js.map +1 -0
  119. package/dist/connectors/db/lib/drivers/sqlite.d.ts +11 -0
  120. package/dist/connectors/db/lib/drivers/sqlite.d.ts.map +1 -0
  121. package/dist/connectors/db/lib/drivers/sqlite.js +147 -0
  122. package/dist/connectors/db/lib/drivers/sqlite.js.map +1 -0
  123. package/dist/connectors/db/lib/drivers/sqlserver.d.ts +58 -0
  124. package/dist/connectors/db/lib/drivers/sqlserver.d.ts.map +1 -0
  125. package/dist/connectors/db/lib/drivers/sqlserver.js +274 -0
  126. package/dist/connectors/db/lib/drivers/sqlserver.js.map +1 -0
  127. package/dist/connectors/db/lib/environments.d.ts +68 -0
  128. package/dist/connectors/db/lib/environments.d.ts.map +1 -0
  129. package/dist/connectors/db/lib/environments.js +53 -0
  130. package/dist/connectors/db/lib/environments.js.map +1 -0
  131. package/dist/connectors/db/lib/index.d.ts +28 -0
  132. package/dist/connectors/db/lib/index.d.ts.map +1 -0
  133. package/dist/connectors/db/lib/index.js +30 -0
  134. package/dist/connectors/db/lib/index.js.map +1 -0
  135. package/dist/connectors/db/lib/plugin_config.d.ts +64 -0
  136. package/dist/connectors/db/lib/plugin_config.d.ts.map +1 -0
  137. package/dist/connectors/db/lib/plugin_config.js +287 -0
  138. package/dist/connectors/db/lib/plugin_config.js.map +1 -0
  139. package/dist/connectors/db/lib/policy.d.ts +162 -0
  140. package/dist/connectors/db/lib/policy.d.ts.map +1 -0
  141. package/dist/connectors/db/lib/policy.js +581 -0
  142. package/dist/connectors/db/lib/policy.js.map +1 -0
  143. package/dist/connectors/db/lib/query.d.ts +22 -0
  144. package/dist/connectors/db/lib/query.d.ts.map +1 -0
  145. package/dist/connectors/db/lib/query.js +93 -0
  146. package/dist/connectors/db/lib/query.js.map +1 -0
  147. package/dist/connectors/db/lib/schema.d.ts +13 -0
  148. package/dist/connectors/db/lib/schema.d.ts.map +1 -0
  149. package/dist/connectors/db/lib/schema.js +80 -0
  150. package/dist/connectors/db/lib/schema.js.map +1 -0
  151. package/dist/connectors/gcp/cli.d.ts +3 -0
  152. package/dist/connectors/gcp/cli.d.ts.map +1 -0
  153. package/dist/connectors/gcp/cli.js +24 -0
  154. package/dist/connectors/gcp/cli.js.map +1 -0
  155. package/dist/connectors/gcp/index.d.ts +24 -0
  156. package/dist/connectors/gcp/index.d.ts.map +1 -0
  157. package/dist/connectors/gcp/index.js +205 -0
  158. package/dist/connectors/gcp/index.js.map +1 -0
  159. package/dist/connectors/gcp/lib/gcp_client.d.ts +88 -0
  160. package/dist/connectors/gcp/lib/gcp_client.d.ts.map +1 -0
  161. package/dist/connectors/gcp/lib/gcp_client.js +434 -0
  162. package/dist/connectors/gcp/lib/gcp_client.js.map +1 -0
  163. package/dist/connectors/gcp/lib/gcp_error.d.ts +10 -0
  164. package/dist/connectors/gcp/lib/gcp_error.d.ts.map +1 -0
  165. package/dist/connectors/gcp/lib/gcp_error.js +15 -0
  166. package/dist/connectors/gcp/lib/gcp_error.js.map +1 -0
  167. package/dist/connectors/github/cli.d.ts +3 -0
  168. package/dist/connectors/github/cli.d.ts.map +1 -0
  169. package/dist/connectors/github/cli.js +23 -0
  170. package/dist/connectors/github/cli.js.map +1 -0
  171. package/dist/connectors/github/index.d.ts +23 -0
  172. package/dist/connectors/github/index.d.ts.map +1 -0
  173. package/dist/connectors/github/index.js +462 -0
  174. package/dist/connectors/github/index.js.map +1 -0
  175. package/dist/connectors/github/lib/github_client.d.ts +181 -0
  176. package/dist/connectors/github/lib/github_client.d.ts.map +1 -0
  177. package/dist/connectors/github/lib/github_client.js +383 -0
  178. package/dist/connectors/github/lib/github_client.js.map +1 -0
  179. package/dist/connectors/github/lib/github_error.d.ts +11 -0
  180. package/dist/connectors/github/lib/github_error.d.ts.map +1 -0
  181. package/dist/connectors/github/lib/github_error.js +17 -0
  182. package/dist/connectors/github/lib/github_error.js.map +1 -0
  183. package/dist/connectors/jira/cli.d.ts +3 -0
  184. package/dist/connectors/jira/cli.d.ts.map +1 -0
  185. package/dist/connectors/jira/cli.js +24 -0
  186. package/dist/connectors/jira/cli.js.map +1 -0
  187. package/dist/connectors/jira/index.d.ts +13 -0
  188. package/dist/connectors/jira/index.d.ts.map +1 -0
  189. package/dist/connectors/jira/index.js +287 -0
  190. package/dist/connectors/jira/index.js.map +1 -0
  191. package/dist/connectors/jira/lib/adf.d.ts +25 -0
  192. package/dist/connectors/jira/lib/adf.d.ts.map +1 -0
  193. package/dist/connectors/jira/lib/adf.js +105 -0
  194. package/dist/connectors/jira/lib/adf.js.map +1 -0
  195. package/dist/connectors/jira/lib/jira_client.d.ts +143 -0
  196. package/dist/connectors/jira/lib/jira_client.d.ts.map +1 -0
  197. package/dist/connectors/jira/lib/jira_client.js +355 -0
  198. package/dist/connectors/jira/lib/jira_client.js.map +1 -0
  199. package/dist/connectors/jira/lib/jira_error.d.ts +11 -0
  200. package/dist/connectors/jira/lib/jira_error.d.ts.map +1 -0
  201. package/dist/connectors/jira/lib/jira_error.js +17 -0
  202. package/dist/connectors/jira/lib/jira_error.js.map +1 -0
  203. package/dist/connectors/notion/cli.d.ts +3 -0
  204. package/dist/connectors/notion/cli.d.ts.map +1 -0
  205. package/dist/connectors/notion/cli.js +22 -0
  206. package/dist/connectors/notion/cli.js.map +1 -0
  207. package/dist/connectors/notion/index.d.ts +20 -0
  208. package/dist/connectors/notion/index.d.ts.map +1 -0
  209. package/dist/connectors/notion/index.js +317 -0
  210. package/dist/connectors/notion/index.js.map +1 -0
  211. package/dist/connectors/notion/lib/notion_client.d.ts +117 -0
  212. package/dist/connectors/notion/lib/notion_client.d.ts.map +1 -0
  213. package/dist/connectors/notion/lib/notion_client.js +377 -0
  214. package/dist/connectors/notion/lib/notion_client.js.map +1 -0
  215. package/dist/connectors/notion/lib/notion_error.d.ts +12 -0
  216. package/dist/connectors/notion/lib/notion_error.d.ts.map +1 -0
  217. package/dist/connectors/notion/lib/notion_error.js +18 -0
  218. package/dist/connectors/notion/lib/notion_error.js.map +1 -0
  219. package/dist/hub/cli.d.ts +4 -0
  220. package/dist/hub/cli.d.ts.map +1 -0
  221. package/dist/hub/cli.js +93 -0
  222. package/dist/hub/cli.js.map +1 -0
  223. package/dist/hub/dispatch.d.ts +33 -0
  224. package/dist/hub/dispatch.d.ts.map +1 -0
  225. package/dist/hub/dispatch.js +297 -0
  226. package/dist/hub/dispatch.js.map +1 -0
  227. package/dist/hub/index.d.ts +9 -0
  228. package/dist/hub/index.d.ts.map +1 -0
  229. package/dist/hub/index.js +215 -0
  230. package/dist/hub/index.js.map +1 -0
  231. package/dist/hub/plan.d.ts +24 -0
  232. package/dist/hub/plan.d.ts.map +1 -0
  233. package/dist/hub/plan.js +103 -0
  234. package/dist/hub/plan.js.map +1 -0
  235. package/dist/hub/types.d.ts +65 -0
  236. package/dist/hub/types.d.ts.map +1 -0
  237. package/dist/hub/types.js +3 -0
  238. package/dist/hub/types.js.map +1 -0
  239. package/dist/toolkit/_optional.d.ts +14 -0
  240. package/dist/toolkit/_optional.d.ts.map +1 -0
  241. package/dist/toolkit/_optional.js +96 -0
  242. package/dist/toolkit/_optional.js.map +1 -0
  243. package/dist/toolkit/agent_cli.d.ts +33 -0
  244. package/dist/toolkit/agent_cli.d.ts.map +1 -0
  245. package/dist/toolkit/agent_cli.js +62 -0
  246. package/dist/toolkit/agent_cli.js.map +1 -0
  247. package/dist/toolkit/agent_resolver.d.ts +46 -0
  248. package/dist/toolkit/agent_resolver.d.ts.map +1 -0
  249. package/dist/toolkit/agent_resolver.js +78 -0
  250. package/dist/toolkit/agent_resolver.js.map +1 -0
  251. package/dist/toolkit/audit/events.d.ts +45 -0
  252. package/dist/toolkit/audit/events.d.ts.map +1 -0
  253. package/dist/toolkit/audit/events.js +8 -0
  254. package/dist/toolkit/audit/events.js.map +1 -0
  255. package/dist/toolkit/audit/writer.d.ts +16 -0
  256. package/dist/toolkit/audit/writer.d.ts.map +1 -0
  257. package/dist/toolkit/audit/writer.js +73 -0
  258. package/dist/toolkit/audit/writer.js.map +1 -0
  259. package/dist/toolkit/cli/usage-report.d.ts +3 -0
  260. package/dist/toolkit/cli/usage-report.d.ts.map +1 -0
  261. package/dist/toolkit/cli/usage-report.js +76 -0
  262. package/dist/toolkit/cli/usage-report.js.map +1 -0
  263. package/dist/toolkit/connector.d.ts +142 -0
  264. package/dist/toolkit/connector.d.ts.map +1 -0
  265. package/dist/toolkit/connector.js +593 -0
  266. package/dist/toolkit/connector.js.map +1 -0
  267. package/dist/toolkit/extract_binary.d.ts +45 -0
  268. package/dist/toolkit/extract_binary.d.ts.map +1 -0
  269. package/dist/toolkit/extract_binary.js +342 -0
  270. package/dist/toolkit/extract_binary.js.map +1 -0
  271. package/dist/toolkit/extract_multimodal.d.ts +22 -0
  272. package/dist/toolkit/extract_multimodal.d.ts.map +1 -0
  273. package/dist/toolkit/extract_multimodal.js +209 -0
  274. package/dist/toolkit/extract_multimodal.js.map +1 -0
  275. package/dist/toolkit/fetch_attachment.d.ts +21 -0
  276. package/dist/toolkit/fetch_attachment.d.ts.map +1 -0
  277. package/dist/toolkit/fetch_attachment.js +169 -0
  278. package/dist/toolkit/fetch_attachment.js.map +1 -0
  279. package/dist/toolkit/fetch_helper.d.ts +47 -0
  280. package/dist/toolkit/fetch_helper.d.ts.map +1 -0
  281. package/dist/toolkit/fetch_helper.js +124 -0
  282. package/dist/toolkit/fetch_helper.js.map +1 -0
  283. package/dist/toolkit/guardrail.d.ts +63 -0
  284. package/dist/toolkit/guardrail.d.ts.map +1 -0
  285. package/dist/toolkit/guardrail.js +166 -0
  286. package/dist/toolkit/guardrail.js.map +1 -0
  287. package/dist/toolkit/hardship/curate.d.ts +47 -0
  288. package/dist/toolkit/hardship/curate.d.ts.map +1 -0
  289. package/dist/toolkit/hardship/curate.js +113 -0
  290. package/dist/toolkit/hardship/curate.js.map +1 -0
  291. package/dist/toolkit/hardship/patterns.d.ts +32 -0
  292. package/dist/toolkit/hardship/patterns.d.ts.map +1 -0
  293. package/dist/toolkit/hardship/patterns.js +98 -0
  294. package/dist/toolkit/hardship/patterns.js.map +1 -0
  295. package/dist/toolkit/hardship/preamble.d.ts +13 -0
  296. package/dist/toolkit/hardship/preamble.d.ts.map +1 -0
  297. package/dist/toolkit/hardship/preamble.js +47 -0
  298. package/dist/toolkit/hardship/preamble.js.map +1 -0
  299. package/dist/toolkit/hardship/read.d.ts +34 -0
  300. package/dist/toolkit/hardship/read.d.ts.map +1 -0
  301. package/dist/toolkit/hardship/read.js +116 -0
  302. package/dist/toolkit/hardship/read.js.map +1 -0
  303. package/dist/toolkit/hardship/record.d.ts +43 -0
  304. package/dist/toolkit/hardship/record.d.ts.map +1 -0
  305. package/dist/toolkit/hardship/record.js +74 -0
  306. package/dist/toolkit/hardship/record.js.map +1 -0
  307. package/dist/toolkit/hardship/scope.d.ts +20 -0
  308. package/dist/toolkit/hardship/scope.d.ts.map +1 -0
  309. package/dist/toolkit/hardship/scope.js +56 -0
  310. package/dist/toolkit/hardship/scope.js.map +1 -0
  311. package/dist/toolkit/index.d.ts +42 -0
  312. package/dist/toolkit/index.d.ts.map +1 -0
  313. package/dist/toolkit/index.js +51 -0
  314. package/dist/toolkit/index.js.map +1 -0
  315. package/dist/toolkit/plugin/curate-cmd.d.ts +22 -0
  316. package/dist/toolkit/plugin/curate-cmd.d.ts.map +1 -0
  317. package/dist/toolkit/plugin/curate-cmd.js +72 -0
  318. package/dist/toolkit/plugin/curate-cmd.js.map +1 -0
  319. package/dist/toolkit/plugin/prefs.d.ts +15 -0
  320. package/dist/toolkit/plugin/prefs.d.ts.map +1 -0
  321. package/dist/toolkit/plugin/prefs.js +78 -0
  322. package/dist/toolkit/plugin/prefs.js.map +1 -0
  323. package/dist/toolkit/plugin/reminder.d.ts +28 -0
  324. package/dist/toolkit/plugin/reminder.d.ts.map +1 -0
  325. package/dist/toolkit/plugin/reminder.js +103 -0
  326. package/dist/toolkit/plugin/reminder.js.map +1 -0
  327. package/dist/toolkit/policy/approval.d.ts +24 -0
  328. package/dist/toolkit/policy/approval.d.ts.map +1 -0
  329. package/dist/toolkit/policy/approval.js +56 -0
  330. package/dist/toolkit/policy/approval.js.map +1 -0
  331. package/dist/toolkit/policy/config.d.ts +38 -0
  332. package/dist/toolkit/policy/config.d.ts.map +1 -0
  333. package/dist/toolkit/policy/config.js +172 -0
  334. package/dist/toolkit/policy/config.js.map +1 -0
  335. package/dist/toolkit/policy/gate.d.ts +28 -0
  336. package/dist/toolkit/policy/gate.d.ts.map +1 -0
  337. package/dist/toolkit/policy/gate.js +126 -0
  338. package/dist/toolkit/policy/gate.js.map +1 -0
  339. package/dist/toolkit/policy/types.d.ts +106 -0
  340. package/dist/toolkit/policy/types.d.ts.map +1 -0
  341. package/dist/toolkit/policy/types.js +22 -0
  342. package/dist/toolkit/policy/types.js.map +1 -0
  343. package/dist/toolkit/security_check.d.ts +15 -0
  344. package/dist/toolkit/security_check.d.ts.map +1 -0
  345. package/dist/toolkit/security_check.js +109 -0
  346. package/dist/toolkit/security_check.js.map +1 -0
  347. package/dist/toolkit/usage/aggregate-cross-session.d.ts +36 -0
  348. package/dist/toolkit/usage/aggregate-cross-session.d.ts.map +1 -0
  349. package/dist/toolkit/usage/aggregate-cross-session.js +142 -0
  350. package/dist/toolkit/usage/aggregate-cross-session.js.map +1 -0
  351. package/dist/toolkit/usage/aggregate.d.ts +4 -0
  352. package/dist/toolkit/usage/aggregate.d.ts.map +1 -0
  353. package/dist/toolkit/usage/aggregate.js +105 -0
  354. package/dist/toolkit/usage/aggregate.js.map +1 -0
  355. package/dist/toolkit/usage/index.d.ts +11 -0
  356. package/dist/toolkit/usage/index.d.ts.map +1 -0
  357. package/dist/toolkit/usage/index.js +7 -0
  358. package/dist/toolkit/usage/index.js.map +1 -0
  359. package/dist/toolkit/usage/parse.d.ts +5 -0
  360. package/dist/toolkit/usage/parse.d.ts.map +1 -0
  361. package/dist/toolkit/usage/parse.js +19 -0
  362. package/dist/toolkit/usage/parse.js.map +1 -0
  363. package/dist/toolkit/usage/record.d.ts +8 -0
  364. package/dist/toolkit/usage/record.d.ts.map +1 -0
  365. package/dist/toolkit/usage/record.js +18 -0
  366. package/dist/toolkit/usage/record.js.map +1 -0
  367. package/dist/toolkit/usage/retention.d.ts +6 -0
  368. package/dist/toolkit/usage/retention.d.ts.map +1 -0
  369. package/dist/toolkit/usage/retention.js +71 -0
  370. package/dist/toolkit/usage/retention.js.map +1 -0
  371. package/dist/toolkit/usage/tokenize.d.ts +11 -0
  372. package/dist/toolkit/usage/tokenize.d.ts.map +1 -0
  373. package/dist/toolkit/usage/tokenize.js +24 -0
  374. package/dist/toolkit/usage/tokenize.js.map +1 -0
  375. package/dist/toolkit/usage/types.d.ts +34 -0
  376. package/dist/toolkit/usage/types.d.ts.map +1 -0
  377. package/dist/toolkit/usage/types.js +2 -0
  378. package/dist/toolkit/usage/types.js.map +1 -0
  379. package/package.json +124 -0
  380. package/plugin-hooks/session-summary.mjs +138 -0
  381. package/plugin-hooks/stale-summarize.mjs +70 -0
  382. package/plugin-hooks/usage-record.mjs +112 -0
  383. package/plugins/aws-agent/.claude-plugin/plugin.json +6 -0
  384. package/plugins/aws-agent/README.md +46 -0
  385. package/plugins/aws-agent/bin/aws-agent +22 -0
  386. package/plugins/aws-agent/commands/aws-agent.md +6 -0
  387. package/plugins/aws-agent/hooks/hooks.json +49 -0
  388. package/plugins/aws-agent/hooks/reminder.mjs +16 -0
  389. package/plugins/aws-agent/package.json +9 -0
  390. package/plugins/aws-agent/skills/aws-agent/SKILL.md +70 -0
  391. package/plugins/confluence-agent/.claude-plugin/plugin.json +6 -0
  392. package/plugins/confluence-agent/README.md +15 -0
  393. package/plugins/confluence-agent/bin/confluence-agent +17 -0
  394. package/plugins/confluence-agent/commands/confluence-agent.md +6 -0
  395. package/plugins/confluence-agent/hooks/hooks.json +49 -0
  396. package/plugins/confluence-agent/hooks/reminder.mjs +25 -0
  397. package/plugins/confluence-agent/package.json +8 -0
  398. package/plugins/confluence-agent/skills/confluence-agent/SKILL.md +40 -0
  399. package/plugins/db-agent/.claude-plugin/plugin.json +20 -0
  400. package/plugins/db-agent/README.md +13 -0
  401. package/plugins/db-agent/bin/db-agent +17 -0
  402. package/plugins/db-agent/commands/db-agent.md +6 -0
  403. package/plugins/db-agent/hooks/db-guard.mjs +110 -0
  404. package/plugins/db-agent/hooks/guardrails.json +26 -0
  405. package/plugins/db-agent/hooks/hooks.json +61 -0
  406. package/plugins/db-agent/hooks/reminder.mjs +16 -0
  407. package/plugins/db-agent/package.json +8 -0
  408. package/plugins/db-agent/skills/db-agent/SKILL.md +50 -0
  409. package/plugins/gcp-agent/.claude-plugin/plugin.json +6 -0
  410. package/plugins/gcp-agent/README.md +31 -0
  411. package/plugins/gcp-agent/bin/gcp-agent +18 -0
  412. package/plugins/gcp-agent/commands/gcp-agent.md +6 -0
  413. package/plugins/gcp-agent/hooks/hooks.json +49 -0
  414. package/plugins/gcp-agent/hooks/reminder.mjs +16 -0
  415. package/plugins/gcp-agent/package.json +9 -0
  416. package/plugins/gcp-agent/skills/gcp-agent/SKILL.md +54 -0
  417. package/plugins/github-agent/.claude-plugin/plugin.json +6 -0
  418. package/plugins/github-agent/README.md +13 -0
  419. package/plugins/github-agent/bin/github-agent +17 -0
  420. package/plugins/github-agent/commands/github-agent.md +6 -0
  421. package/plugins/github-agent/hooks/hooks.json +49 -0
  422. package/plugins/github-agent/hooks/reminder.mjs +16 -0
  423. package/plugins/github-agent/package.json +8 -0
  424. package/plugins/github-agent/skills/github-agent/SKILL.md +41 -0
  425. package/plugins/jira-agent/.claude-plugin/plugin.json +6 -0
  426. package/plugins/jira-agent/README.md +15 -0
  427. package/plugins/jira-agent/bin/jira-agent +17 -0
  428. package/plugins/jira-agent/commands/jira-agent.md +6 -0
  429. package/plugins/jira-agent/hooks/hooks.json +49 -0
  430. package/plugins/jira-agent/hooks/reminder.mjs +16 -0
  431. package/plugins/jira-agent/package.json +8 -0
  432. package/plugins/jira-agent/skills/jira-agent/SKILL.md +37 -0
  433. package/plugins/notion-agent/.claude-plugin/plugin.json +6 -0
  434. package/plugins/notion-agent/README.md +23 -0
  435. package/plugins/notion-agent/bin/notion-agent +17 -0
  436. package/plugins/notion-agent/commands/notion-agent.md +6 -0
  437. package/plugins/notion-agent/hooks/hooks.json +49 -0
  438. package/plugins/notion-agent/hooks/reminder.mjs +17 -0
  439. package/plugins/notion-agent/package.json +8 -0
  440. package/plugins/notion-agent/skills/notion-agent/SKILL.md +48 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scope.d.ts","sourceRoot":"","sources":["../../../src/toolkit/hardship/scope.ts"],"names":[],"mappings":"AAgBA,MAAM,MAAM,QAAQ,GAChB,gBAAgB,GAChB,gBAAgB,GAChB,aAAa,GACb,aAAa,CAAC;AAElB,MAAM,WAAW,IAAI;IACnB,IAAI,EAAE,QAAQ,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,EAAE,QAAQ,GAAG,QAAQ,CAAC;CACjC;AAED,MAAM,MAAM,SAAS,GAAG,IAAI,EAAE,CAAC;AAE/B;;;GAGG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED,MAAM,WAAW,uBAAuB;IACtC,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;CACd;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,uBAAuB,GAAG,SAAS,CAiCzE"}
@@ -0,0 +1,56 @@
1
+ /**
2
+ * scope.ts — tenant-scope hashing + 4-tier path resolution for the
3
+ * self-improvement loop.
4
+ *
5
+ * Paths:
6
+ * tier 1 (most specific): <cwd>/.claude/connectors/<conn>/tenants/<hash>/
7
+ * tier 2: <cwd>/.claude/connectors/<conn>/global/
8
+ * tier 3: <home>/.claude/connectors/<conn>/tenants/<hash>/
9
+ * tier 4 (least specific): <home>/.claude/connectors/<conn>/global/
10
+ *
11
+ * Match walks tier 1 → 4 returning the first hit. Write goes to the
12
+ * most specific tier that "exists" (has <cwd>/.claude/).
13
+ */
14
+ import { createHash } from "node:crypto";
15
+ import * as path from "node:path";
16
+ /**
17
+ * 16-char hex sha256 prefix. Stable across processes, short enough for
18
+ * filesystem paths, collision probability negligible for O(100) tenants.
19
+ */
20
+ export function hashScopeKey(key) {
21
+ return createHash("sha256").update(key).digest("hex").slice(0, 16);
22
+ }
23
+ export function resolveTierPaths(opts) {
24
+ const { connector, scope, cwd, home } = opts;
25
+ const tiers = [];
26
+ const projectRoot = path.join(cwd, ".claude/connectors", connector);
27
+ const userRoot = path.join(home, ".claude/connectors", connector);
28
+ if (scope !== null) {
29
+ const hash = hashScopeKey(scope);
30
+ tiers.push({
31
+ name: "project-tenant",
32
+ dir: path.join(projectRoot, "tenants", hash),
33
+ scopeLevel: "tenant",
34
+ });
35
+ }
36
+ tiers.push({
37
+ name: "project-global",
38
+ dir: path.join(projectRoot, "global"),
39
+ scopeLevel: "global",
40
+ });
41
+ if (scope !== null) {
42
+ const hash = hashScopeKey(scope);
43
+ tiers.push({
44
+ name: "user-tenant",
45
+ dir: path.join(userRoot, "tenants", hash),
46
+ scopeLevel: "tenant",
47
+ });
48
+ }
49
+ tiers.push({
50
+ name: "user-global",
51
+ dir: path.join(userRoot, "global"),
52
+ scopeLevel: "global",
53
+ });
54
+ return tiers;
55
+ }
56
+ //# sourceMappingURL=scope.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scope.js","sourceRoot":"","sources":["../../../src/toolkit/hardship/scope.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAgBlC;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,GAAW;IACtC,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AACrE,CAAC;AASD,MAAM,UAAU,gBAAgB,CAAC,IAA6B;IAC5D,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC;IAC7C,MAAM,KAAK,GAAW,EAAE,CAAC;IACzB,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,oBAAoB,EAAE,SAAS,CAAC,CAAC;IACpE,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,oBAAoB,EAAE,SAAS,CAAC,CAAC;IAElE,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QACnB,MAAM,IAAI,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;QACjC,KAAK,CAAC,IAAI,CAAC;YACT,IAAI,EAAE,gBAAgB;YACtB,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,SAAS,EAAE,IAAI,CAAC;YAC5C,UAAU,EAAE,QAAQ;SACrB,CAAC,CAAC;IACL,CAAC;IACD,KAAK,CAAC,IAAI,CAAC;QACT,IAAI,EAAE,gBAAgB;QACtB,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAC;QACrC,UAAU,EAAE,QAAQ;KACrB,CAAC,CAAC;IACH,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QACnB,MAAM,IAAI,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;QACjC,KAAK,CAAC,IAAI,CAAC;YACT,IAAI,EAAE,aAAa;YACnB,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,SAAS,EAAE,IAAI,CAAC;YACzC,UAAU,EAAE,QAAQ;SACrB,CAAC,CAAC;IACL,CAAC;IACD,KAAK,CAAC,IAAI,CAAC;QACT,IAAI,EAAE,aAAa;QACnB,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC;QAClC,UAAU,EAAE,QAAQ;KACrB,CAAC,CAAC;IACH,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * @narai/connector-toolkit — framework for agent-connector packages.
3
+ *
4
+ * Primary API:
5
+ * - `createConnector` — build a connector from an action registry with
6
+ * built-in CLI harness, approval gate, audit, and hardship logging.
7
+ *
8
+ * Secondary helpers (shipped for advanced use and by pre-2.0 consumers):
9
+ * - `parseAgentArgs` — raw CLI flag parser.
10
+ * - `fetchWithCaps` — size/timeout-capped fetch.
11
+ * - `validateUrl`, `checkPathContainment`, `sanitizeLabel` — security primitives.
12
+ *
13
+ * Credentials remain external; depend on `@narai/credential-providers` directly.
14
+ */
15
+ export { EnvelopeOverride, createConnector, defineAction, type ActionSpec, type Connector, type ConnectorConfig, type Context, type Credentials, type DecisionContext, } from "./connector.js";
16
+ export { DECISION_RANK, DEFAULT_POLICY, type ApprovalMode, type Classification, type Decision, type DeniedEnvelope, type Envelope, type ErrorCode, type ErrorEnvelope, type EscalateEnvelope, type ExtendedEnvelope, type Kind, type PolicyRules, type ResolutionHint, type RestrictedRule, type Rule, type SuccessEnvelope, } from "./policy/types.js";
17
+ export { checkPolicy, combineDecisions, type ApprovalState, } from "./policy/gate.js";
18
+ export { deepMerge, discoverConfigPaths, loadPolicyConfig, validatePolicyConfig, type DiscoveredPaths, type LoadedPolicy, type LoadPolicyConfigOptions, } from "./policy/config.js";
19
+ export { ApprovalEngine } from "./policy/approval.js";
20
+ export { createAuditWriter, scrubSecrets, type AuditWriter, type AuditWriterOptions, } from "./audit/writer.js";
21
+ export { type ActionEvent, type AuditEvent, type BaseEvent, type GrantEvent, type HardshipEvent, type PolicyEvent, } from "./audit/events.js";
22
+ export { createHardshipRecorder, resolveHardshipPath, type HardshipEntry, type HardshipInput, type HardshipRecorder, type HardshipWriterOptions, } from "./hardship/record.js";
23
+ export { countRawHardships, readCuratedHardships, readRawHardships, type ReadOptions, } from "./hardship/read.js";
24
+ export { clusterHardships, entriesSinceLastCuration, normalizeContext, readCurationMarker, writeCurationMarker, type CurationMarker, type HardshipCluster, } from "./hardship/curate.js";
25
+ export { DEFAULT_PREFS, prefsPath, readPrefs, setEnabled, setSkipDays, writePrefs, type CurationPrefs, } from "./plugin/prefs.js";
26
+ export { evaluateNudge, printNudgeIfNeeded, type NudgeContext, type NudgeDecision, } from "./plugin/reminder.js";
27
+ export { buildCurateSnapshot, type CurateCommandOptions, type CurateSnapshot, } from "./plugin/curate-cmd.js";
28
+ export { parseAgentArgs, type FlagSpec, type ParsedAgentArgs, } from "./agent_cli.js";
29
+ export { FETCH_MAX_BYTES_DEFAULT, FETCH_TIMEOUT_MS_DEFAULT, FetchCapExceeded, fetchWithCaps, type FetchCapsOptions, } from "./fetch_helper.js";
30
+ export { validateUrl, checkPathContainment, sanitizeLabel, } from "./security_check.js";
31
+ export { importOptional, isBinaryOnPath } from "./_optional.js";
32
+ export { extract as extractBinary, extractPdf, extractDocx, extractPptx, normalizeExtracted, ExtractCapExceeded, FORMAT_MAP, type BinaryFormat, type ExtractOptions, type ExtractResult, } from "./extract_binary.js";
33
+ export { dispatchMultimodal, type MultimodalConfig, type MultimodalFormat, type MultimodalMode, type MultimodalResult, } from "./extract_multimodal.js";
34
+ export { fetchAttachment, type FetchAttachmentOptions, type FetchAttachmentResult, } from "./fetch_attachment.js";
35
+ export { hashScopeKey, resolveTierPaths, type Tier, type TierPaths, type TierName, } from "./hardship/scope.js";
36
+ export { loadPatterns, matchPattern, type Pattern, type PatternsFile, type PatternMatcher, type HardshipFacts, type MatchedPattern, } from "./hardship/patterns.js";
37
+ export { readFirstMatchingPattern, type ReadFirstMatchingPatternOptions, type TierMatch, } from "./hardship/read.js";
38
+ export { renderSkillPreamble, type RenderSkillPreambleOptions, } from "./hardship/preamble.js";
39
+ export * as usage from "./usage/index.js";
40
+ export { resolveAgentCli, type ResolveAgentCliOptions, type ResolvedAgentCli, type ResolutionSource, } from "./agent_resolver.js";
41
+ export { loadGuardrailManifest, findBlockingRule, defaultDenyMessage, type GuardrailRule, type GuardrailManifest, type BlockMatch, } from "./guardrail.js";
42
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/toolkit/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAIH,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,YAAY,EACZ,KAAK,UAAU,EACf,KAAK,SAAS,EACd,KAAK,eAAe,EACpB,KAAK,OAAO,EACZ,KAAK,WAAW,EAChB,KAAK,eAAe,GACrB,MAAM,gBAAgB,CAAC;AAIxB,OAAO,EACL,aAAa,EACb,cAAc,EACd,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,QAAQ,EACb,KAAK,cAAc,EACnB,KAAK,QAAQ,EACb,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,IAAI,EACT,KAAK,WAAW,EAChB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,IAAI,EACT,KAAK,eAAe,GACrB,MA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M,kBAAkB,CAAC;AAI1C,OAAO,EACL,eAAe,EACf,KAAK,sBAAsB,EAC3B,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,GACtB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,qBAAqB,EACrB,gBAAgB,EAChB,kBAAkB,EAClB,KAAK,aAAa,EAClB,KAAK,iBAAiB,EACtB,KAAK,UAAU,GAChB,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,51 @@
1
+ /**
2
+ * @narai/connector-toolkit — framework for agent-connector packages.
3
+ *
4
+ * Primary API:
5
+ * - `createConnector` — build a connector from an action registry with
6
+ * built-in CLI harness, approval gate, audit, and hardship logging.
7
+ *
8
+ * Secondary helpers (shipped for advanced use and by pre-2.0 consumers):
9
+ * - `parseAgentArgs` — raw CLI flag parser.
10
+ * - `fetchWithCaps` — size/timeout-capped fetch.
11
+ * - `validateUrl`, `checkPathContainment`, `sanitizeLabel` — security primitives.
12
+ *
13
+ * Credentials remain external; depend on `@narai/credential-providers` directly.
14
+ */
15
+ // ─── Primary API ───────────────────────────────────────────────────────────
16
+ export { EnvelopeOverride, createConnector, defineAction, } from "./connector.js";
17
+ // ─── Policy types / engine ─────────────────────────────────────────────────
18
+ export { DECISION_RANK, DEFAULT_POLICY, } from "./policy/types.js";
19
+ export { checkPolicy, combineDecisions, } from "./policy/gate.js";
20
+ export { deepMerge, discoverConfigPaths, loadPolicyConfig, validatePolicyConfig, } from "./policy/config.js";
21
+ export { ApprovalEngine } from "./policy/approval.js";
22
+ // ─── Audit ─────────────────────────────────────────────────────────────────
23
+ export { createAuditWriter, scrubSecrets, } from "./audit/writer.js";
24
+ // ─── Hardship ──────────────────────────────────────────────────────────────
25
+ export { createHardshipRecorder, resolveHardshipPath, } from "./hardship/record.js";
26
+ export { countRawHardships, readCuratedHardships, readRawHardships, } from "./hardship/read.js";
27
+ export { clusterHardships, entriesSinceLastCuration, normalizeContext, readCurationMarker, writeCurationMarker, } from "./hardship/curate.js";
28
+ // ─── Plugin helpers ────────────────────────────────────────────────────────
29
+ export { DEFAULT_PREFS, prefsPath, readPrefs, setEnabled, setSkipDays, writePrefs, } from "./plugin/prefs.js";
30
+ export { evaluateNudge, printNudgeIfNeeded, } from "./plugin/reminder.js";
31
+ export { buildCurateSnapshot, } from "./plugin/curate-cmd.js";
32
+ // ─── Legacy helpers (still exported) ───────────────────────────────────────
33
+ export { parseAgentArgs, } from "./agent_cli.js";
34
+ export { FETCH_MAX_BYTES_DEFAULT, FETCH_TIMEOUT_MS_DEFAULT, FetchCapExceeded, fetchWithCaps, } from "./fetch_helper.js";
35
+ export { validateUrl, checkPathContainment, sanitizeLabel, } from "./security_check.js";
36
+ // ─── Binary + attachment helpers (added in 2.1) ────────────────────────────
37
+ export { importOptional, isBinaryOnPath } from "./_optional.js";
38
+ export { extract as extractBinary, extractPdf, extractDocx, extractPptx, normalizeExtracted, ExtractCapExceeded, FORMAT_MAP, } from "./extract_binary.js";
39
+ export { dispatchMultimodal, } from "./extract_multimodal.js";
40
+ export { fetchAttachment, } from "./fetch_attachment.js";
41
+ // ─── Self-improvement layer (added in 3.0) ───────────────────────────────
42
+ export { hashScopeKey, resolveTierPaths, } from "./hardship/scope.js";
43
+ export { loadPatterns, matchPattern, } from "./hardship/patterns.js";
44
+ export { readFirstMatchingPattern, } from "./hardship/read.js";
45
+ export { renderSkillPreamble, } from "./hardship/preamble.js";
46
+ // ─── Usage tracking (added in 3.1) ───────────────────────────────────────
47
+ export * as usage from "./usage/index.js";
48
+ // ─── Agent CLI resolution + guardrails (added in 3.3) ────────────────────
49
+ export { resolveAgentCli, } from "./agent_resolver.js";
50
+ export { loadGuardrailManifest, findBlockingRule, defaultDenyMessage, } from "./guardrail.js";
51
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/toolkit/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,8EAA8E;AAE9E,OAAO,EACL,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AAE,MAAM,gBAAgB,CAAC;AAEhE,OAAO,EACL,OAAO,IAAI,aAAa,EACxB,UAAU,EACV,WAAW,EACX,WAAW,EACX,kBAAkB,EAClB,kBAAkB,EAClB,UAAU,GAIX,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,kBAAkB,GAKnB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,eAAe,GAGhB,MAAM,uBAAuB,CAAC;AAE/B,4EAA4E;AAE5E,OAAO,EACL,YAAY,EACZ,gBAAgB,GAIjB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,YAAY,EACZ,YAAY,GAMb,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EACL,wBAAwB,GAGzB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACL,mBAAmB,GAEpB,MAAM,wBAAwB,CAAC;AAEhC,4EAA4E;AAE5E,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAE1C,4EAA4E;AAE5E,OAAO,EACL,eAAe,GAIhB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,qBAAqB,EACrB,gBAAgB,EAChB,kBAAkB,GAInB,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,22 @@
1
+ import { type HardshipCluster, type CurationMarker } from "../hardship/curate.js";
2
+ export interface CurateSnapshot {
3
+ connector: string;
4
+ total_entries: number;
5
+ new_entries: number;
6
+ marker: CurationMarker;
7
+ clusters: HardshipCluster[];
8
+ curated_md: string;
9
+ paths: {
10
+ /** Absolute path to the MD file that the slash command should edit. */
11
+ target_md: string;
12
+ /** Absolute paths to every JSONL file read (project-local, user-global). */
13
+ read_from: string[];
14
+ };
15
+ }
16
+ export interface CurateCommandOptions {
17
+ connector: string;
18
+ cwd?: string;
19
+ home?: string;
20
+ }
21
+ export declare function buildCurateSnapshot(opts: CurateCommandOptions): CurateSnapshot;
22
+ //# sourceMappingURL=curate-cmd.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"curate-cmd.d.ts","sourceRoot":"","sources":["../../../src/toolkit/plugin/curate-cmd.ts"],"names":[],"mappings":"AAiBA,OAAO,EAIL,KAAK,eAAe,EACpB,KAAK,cAAc,EACpB,MAAM,uBAAuB,CAAC;AAI/B,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,cAAc,CAAC;IACvB,QAAQ,EAAE,eAAe,EAAE,CAAC;IAC5B,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE;QACL,uEAAuE;QACvE,SAAS,EAAE,MAAM,CAAC;QAClB,4EAA4E;QAC5E,SAAS,EAAE,MAAM,EAAE,CAAC;KACrB,CAAC;CACH;AAED,MAAM,WAAW,oBAAoB;IACnC,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,oBAAoB,GACzB,cAAc,CAsDhB"}
@@ -0,0 +1,72 @@
1
+ /**
2
+ * `/connector-curate` helper.
3
+ *
4
+ * Each connector CLI accepts a `--curate` flag (wired by the factory). When
5
+ * set, the CLI prints a JSON snapshot of uncurated hardship clusters plus
6
+ * the current curation marker to stdout and exits 0. The slash command's
7
+ * prompt text reads that JSON, proposes promotions into MD sections, asks
8
+ * the user to approve, and then edits the MD directly via Claude Code's
9
+ * Edit tool.
10
+ *
11
+ * The write-back (promoting approved clusters into semantic sections) is
12
+ * handled by Claude via Edit — NOT by this module. This keeps the curation
13
+ * logic in prompt-space where judgement and diffing are legible.
14
+ */
15
+ import * as fs from "node:fs";
16
+ import * as os from "node:os";
17
+ import * as path from "node:path";
18
+ import { clusterHardships, entriesSinceLastCuration, readCurationMarker, } from "../hardship/curate.js";
19
+ import { readCuratedHardships, readRawHardships } from "../hardship/read.js";
20
+ import { resolveTierPaths } from "../hardship/scope.js";
21
+ export function buildCurateSnapshot(opts) {
22
+ const cwd = opts.cwd ?? process.cwd();
23
+ const home = opts.home ?? os.homedir();
24
+ const raw = readRawHardships(opts.connector, { cwd, home });
25
+ const curatedMd = readCuratedHardships(opts.connector, { cwd, home });
26
+ // Null-scope tier walk: project-global, user-global (most specific first).
27
+ const tiers = resolveTierPaths({
28
+ connector: opts.connector,
29
+ scope: null,
30
+ cwd,
31
+ home,
32
+ });
33
+ // Target MD = most-specific tier that's writable. project-global if
34
+ // <cwd>/.claude/ exists; else user-global.
35
+ const hasProject = fs.existsSync(path.join(cwd, ".claude"));
36
+ const targetTier = tiers.find((t) => (hasProject ? true : !t.name.startsWith("project-"))) ??
37
+ tiers[tiers.length - 1];
38
+ const targetMd = path.join(targetTier.dir, "hardships.md");
39
+ // Read the marker from the target file directly — `curatedMd` from
40
+ // `readCuratedHardships` prepends HTML comments which break frontmatter
41
+ // parsing. The target is where the next curation will write, so it's
42
+ // the authoritative source for the marker.
43
+ let targetMdRaw = "";
44
+ try {
45
+ targetMdRaw = fs.readFileSync(targetMd, "utf-8");
46
+ }
47
+ catch {
48
+ // Target doesn't exist yet; marker defaults apply.
49
+ }
50
+ const marker = readCurationMarker(targetMdRaw);
51
+ const since = entriesSinceLastCuration(raw, marker);
52
+ const clusters = clusterHardships(since);
53
+ const readFrom = [];
54
+ for (const t of tiers) {
55
+ const jsonl = path.join(t.dir, "hardships.jsonl");
56
+ if (fs.existsSync(jsonl))
57
+ readFrom.push(jsonl);
58
+ }
59
+ return {
60
+ connector: opts.connector,
61
+ total_entries: raw.length,
62
+ new_entries: since.length,
63
+ marker,
64
+ clusters,
65
+ curated_md: curatedMd,
66
+ paths: {
67
+ target_md: targetMd,
68
+ read_from: readFrom,
69
+ },
70
+ };
71
+ }
72
+ //# sourceMappingURL=curate-cmd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"curate-cmd.js","sourceRoot":"","sources":["../../../src/toolkit/plugin/curate-cmd.ts"],"names":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_entries: number;
4
+ max_days_since_curate: number;
5
+ /** ISO-8601 timestamp; banners are suppressed until `now > skip_until_ts`. */
6
+ skip_until_ts: string | null;
7
+ }
8
+ export declare const DEFAULT_PREFS: CurationPrefs;
9
+ export declare function prefsPath(home?: string): string;
10
+ export declare function readPrefs(home?: string): CurationPrefs;
11
+ export declare function writePrefs(prefs: CurationPrefs, home?: string): void;
12
+ /** Set `skip_until_ts` to `now + days` (or revert to `null` if `days <= 0`). */
13
+ export declare function setSkipDays(days: number, now?: Date, home?: string): void;
14
+ export declare function setEnabled(enabled: boolean, home?: string): void;
15
+ //# sourceMappingURL=prefs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prefs.d.ts","sourceRoot":"","sources":["../../../src/toolkit/plugin/prefs.ts"],"names":[],"mappings":"AAWA,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,OAAO,CAAC;IACjB,eAAe,EAAE,MAAM,CAAC;IACxB,qBAAqB,EAAE,MAAM,CAAC;IAC9B,8EAA8E;IAC9E,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B;AAED,eAAO,MAAM,aAAa,EAAE,aAK3B,CAAC;AAEF,wBAAgB,SAAS,CAAC,IAAI,GAAE,MAAqB,GAAG,MAAM,CAE7D;AAaD,wBAAgB,SAAS,CAAC,IAAI,GAAE,MAAqB,GAAG,aAAa,CAepE;AAED,wBAAgB,UAAU,CACxB,KAAK,EAAE,aAAa,EACpB,IAAI,GAAE,MAAqB,GAC1B,IAAI,CAWN;AAED,gFAAgF;AAChF,wBAAgB,WAAW,CACzB,IAAI,EAAE,MAAM,EACZ,GAAG,GAAE,IAAiB,EACtB,IAAI,GAAE,MAAqB,GAC1B,IAAI,CASN;AAED,wBAAgB,UAAU,CACxB,OAAO,EAAE,OAAO,EAChB,IAAI,GAAE,MAAqB,GAC1B,IAAI,CAIN"}
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Curation preferences — user-global JSON at `~/.claude/connectors/curation-prefs.json`.
3
+ *
4
+ * Persists the throttle + enabled state for the curation-reminder banner.
5
+ * Writes are best-effort (ENOENT auto-creates parent dirs; any other error
6
+ * is swallowed so the SessionStart hook never blocks session startup).
7
+ */
8
+ import * as fs from "node:fs";
9
+ import * as os from "node:os";
10
+ import * as path from "node:path";
11
+ export const DEFAULT_PREFS = {
12
+ enabled: true,
13
+ min_new_entries: 5,
14
+ max_days_since_curate: 7,
15
+ skip_until_ts: null,
16
+ };
17
+ export function prefsPath(home = os.homedir()) {
18
+ return path.join(home, ".claude", "connectors", "curation-prefs.json");
19
+ }
20
+ function isValidPrefs(v) {
21
+ if (typeof v !== "object" || v === null)
22
+ return false;
23
+ const o = v;
24
+ return (typeof o["enabled"] === "boolean" &&
25
+ typeof o["min_new_entries"] === "number" &&
26
+ typeof o["max_days_since_curate"] === "number" &&
27
+ (o["skip_until_ts"] === null || typeof o["skip_until_ts"] === "string"));
28
+ }
29
+ export function readPrefs(home = os.homedir()) {
30
+ const p = prefsPath(home);
31
+ let raw;
32
+ try {
33
+ raw = fs.readFileSync(p, "utf-8");
34
+ }
35
+ catch {
36
+ return { ...DEFAULT_PREFS };
37
+ }
38
+ try {
39
+ const parsed = JSON.parse(raw);
40
+ if (isValidPrefs(parsed))
41
+ return parsed;
42
+ }
43
+ catch {
44
+ // fall through to defaults on parse error
45
+ }
46
+ return { ...DEFAULT_PREFS };
47
+ }
48
+ export function writePrefs(prefs, home = os.homedir()) {
49
+ const p = prefsPath(home);
50
+ try {
51
+ fs.mkdirSync(path.dirname(p), { recursive: true });
52
+ // Atomic write: write to sibling tmp file then rename.
53
+ const tmp = `${p}.${process.pid}.tmp`;
54
+ fs.writeFileSync(tmp, JSON.stringify(prefs, null, 2) + "\n", "utf-8");
55
+ fs.renameSync(tmp, p);
56
+ }
57
+ catch {
58
+ // best-effort
59
+ }
60
+ }
61
+ /** Set `skip_until_ts` to `now + days` (or revert to `null` if `days <= 0`). */
62
+ export function setSkipDays(days, now = new Date(), home = os.homedir()) {
63
+ const prefs = readPrefs(home);
64
+ if (days <= 0) {
65
+ prefs.skip_until_ts = null;
66
+ }
67
+ else {
68
+ const target = new Date(now.getTime() + days * 24 * 60 * 60 * 1000);
69
+ prefs.skip_until_ts = target.toISOString();
70
+ }
71
+ writePrefs(prefs, home);
72
+ }
73
+ export function setEnabled(enabled, home = os.homedir()) {
74
+ const prefs = readPrefs(home);
75
+ prefs.enabled = enabled;
76
+ writePrefs(prefs, home);
77
+ }
78
+ //# sourceMappingURL=prefs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prefs.js","sourceRoot":"","sources":["../../../src/toolkit/plugin/prefs.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAUlC,MAAM,CAAC,MAAM,aAAa,GAAkB;IAC1C,OAAO,EAAE,IAAI;IACb,eAAe,EAAE,CAAC;IAClB,qBAAqB,EAAE,CAAC;IACxB,aAAa,EAAE,IAAI;CACpB,CAAC;AAEF,MAAM,UAAU,SAAS,CAAC,OAAe,EAAE,CAAC,OAAO,EAAE;IACnD,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,SAAS,EAAE,YAAY,EAAE,qBAAqB,CAAC,CAAC;AACzE,CAAC;AAED,SAAS,YAAY,CAAC,CAAU;IAC9B,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IACtD,MAAM,CAAC,GAAG,CAA4B,CAAC;IACvC,OAAO,CACL,OAAO,CAAC,CAAC,SAAS,CAAC,KAAK,SAAS;QACjC,OAAO,CAAC,CAAC,iBAAiB,CAAC,KAAK,QAAQ;QACxC,OAAO,CAAC,CAAC,uBAAuB,CAAC,KAAK,QAAQ;QAC9C,CAAC,CAAC,CAAC,eAAe,CAAC,KAAK,IAAI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IAChB,CAAC;AACH,CAAC;AAED,gFAAgF;AAChF,MAAM,UAAU,WAAW,CACzB,IAAY,EACZ,MAAY,IAAI,IAAI,EAAE,EACtB,OAAe,EAAE,CAAC,OAAO,EAAE;IAE3B,MAAM,KAAK,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;IAC9B,IAAI,IAAI,IAAI,CAAC,EAAE,CAAC;QACd,KAAK,CAAC,aAAa,GAAG,IAAI,CAAC;IAC7B,CAAC;SAAM,CAAC;QACN,MAAM,MAAM,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,IAAI,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC;QACpE,KAAK,CAAC,aAAa,GAAG,MAAM,CAAC,WAAW,EAAE,CAAC;IAC7C,CAAC;IACD,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;AAC1B,CAAC;AAED,MAAM,UAAU,UAAU,CACxB,OAAgB,EAChB,OAAe,EAAE,CAAC,OAAO,EAAE;IAE3B,MAAM,KAAK,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;IAC9B,KAAK,CAAC,OAAO,GAAG,OAAO,CAAC;IACxB,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;AAC1B,CAAC"}
@@ -0,0 +1,28 @@
1
+ export interface NudgeContext {
2
+ /** Connector names to consider. */
3
+ connectors: readonly string[];
4
+ /** Override home (tests). */
5
+ home?: string;
6
+ /** Override cwd (tests). */
7
+ cwd?: string;
8
+ /** Override now (tests). */
9
+ now?: Date;
10
+ }
11
+ export interface NudgeDecision {
12
+ nudge: boolean;
13
+ banner: string;
14
+ reason: string;
15
+ triggered_by: Array<{
16
+ connector: string;
17
+ new_entries: number;
18
+ days_since_curate: number | null;
19
+ }>;
20
+ }
21
+ /**
22
+ * Pure-function evaluation. Returns a decision; caller prints the banner
23
+ * when `nudge` is true. Writes nothing.
24
+ */
25
+ export declare function evaluateNudge(ctx: NudgeContext): NudgeDecision;
26
+ /** Print the banner to stdout if the nudge fires. Used directly by hooks. */
27
+ export declare function printNudgeIfNeeded(ctx: NudgeContext): void;
28
+ //# sourceMappingURL=reminder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reminder.d.ts","sourceRoot":"","sources":["../../../src/toolkit/plugin/reminder.ts"],"names":[],"mappings":"AAiBA,MAAM,WAAW,YAAY;IAC3B,mCAAmC;IACnC,UAAU,EAAE,SAAS,MAAM,EAAE,CAAC;IAC9B,6BAA6B;IAC7B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,4BAA4B;IAC5B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,4BAA4B;IAC5B,GAAG,CAAC,EAAE,IAAI,CAAC;CACZ;AAED,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,KAAK,CAAC;QAClB,SAAS,EAAE,MAAM,CAAC;QAClB,WAAW,EAAE,MAAM,CAAC;QACpB,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;KAClC,CAAC,CAAC;CACJ;AAsBD;;;GAGG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,YAAY,GAAG,aAAa,CA+D9D;AAED,6EAA6E;AAC7E,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,YAAY,GAAG,IAAI,CAM1D"}
@@ -0,0 +1,103 @@
1
+ /**
2
+ * SessionStart reminder. Checks thresholds + skip-state, emits one banner
3
+ * line if a nudge is warranted. Designed to be called from a connector's
4
+ * `plugin/hooks/hooks.json` SessionStart handler.
5
+ *
6
+ * Throttle: at most one banner per `skip_until_ts` window per user. The
7
+ * window updates only when the user invokes `/connector-curate skip`;
8
+ * reading this function repeatedly in-session is safe (idempotent).
9
+ */
10
+ import { countRawHardships } from "../hardship/read.js";
11
+ import { readCurationMarker } from "../hardship/curate.js";
12
+ import { resolveTierPaths } from "../hardship/scope.js";
13
+ import * as fs from "node:fs";
14
+ import * as os from "node:os";
15
+ import * as path from "node:path";
16
+ import { readPrefs } from "./prefs.js";
17
+ function daysBetween(a, b) {
18
+ return Math.abs(b.getTime() - a.getTime()) / (1000 * 60 * 60 * 24);
19
+ }
20
+ function readMdMarker(connector, cwd, home) {
21
+ // Walk global tiers (project-global, user-global) — curation writes to the
22
+ // same tier the writer routes null-scope entries into.
23
+ const tiers = resolveTierPaths({ connector, scope: null, cwd, home });
24
+ for (const t of tiers) {
25
+ const md = path.join(t.dir, "hardships.md");
26
+ try {
27
+ const contents = fs.readFileSync(md, "utf-8");
28
+ return readCurationMarker(contents);
29
+ }
30
+ catch {
31
+ // try next tier
32
+ }
33
+ }
34
+ return { last_curated_ts: null, last_curated_count: 0 };
35
+ }
36
+ /**
37
+ * Pure-function evaluation. Returns a decision; caller prints the banner
38
+ * when `nudge` is true. Writes nothing.
39
+ */
40
+ export function evaluateNudge(ctx) {
41
+ const home = ctx.home ?? os.homedir();
42
+ const cwd = ctx.cwd ?? process.cwd();
43
+ const now = ctx.now ?? new Date();
44
+ const prefs = readPrefs(home);
45
+ if (!prefs.enabled) {
46
+ return { nudge: false, banner: "", reason: "disabled", triggered_by: [] };
47
+ }
48
+ if (prefs.skip_until_ts !== null) {
49
+ const skipUntil = new Date(prefs.skip_until_ts);
50
+ if (!Number.isNaN(skipUntil.getTime()) && now < skipUntil) {
51
+ return {
52
+ nudge: false,
53
+ banner: "",
54
+ reason: `skipped until ${prefs.skip_until_ts}`,
55
+ triggered_by: [],
56
+ };
57
+ }
58
+ }
59
+ const triggered = [];
60
+ let totalNew = 0;
61
+ for (const connector of ctx.connectors) {
62
+ const total = countRawHardships(connector, { cwd, home });
63
+ const marker = readMdMarker(connector, cwd, home);
64
+ const newCount = Math.max(0, total - marker.last_curated_count);
65
+ const days = marker.last_curated_ts !== null
66
+ ? daysBetween(new Date(marker.last_curated_ts), now)
67
+ : null;
68
+ const hitCount = newCount >= prefs.min_new_entries;
69
+ const hitDays = days !== null && days >= prefs.max_days_since_curate;
70
+ if (hitCount || hitDays) {
71
+ triggered.push({
72
+ connector,
73
+ new_entries: newCount,
74
+ days_since_curate: days,
75
+ });
76
+ totalNew += newCount;
77
+ }
78
+ }
79
+ if (triggered.length === 0) {
80
+ return {
81
+ nudge: false,
82
+ banner: "",
83
+ reason: "no connector met threshold",
84
+ triggered_by: [],
85
+ };
86
+ }
87
+ const connList = triggered.map((t) => t.connector).join(", ");
88
+ const banner = [
89
+ `[connectors] ${totalNew} uncurated hardships in ${connList}.`,
90
+ ` /connector-curate to review, /connector-curate skip for 1d,`,
91
+ ` skip --week for 7d, off to disable.`,
92
+ ].join("\n");
93
+ return { nudge: true, banner, reason: "threshold met", triggered_by: triggered };
94
+ }
95
+ /** Print the banner to stdout if the nudge fires. Used directly by hooks. */
96
+ export function printNudgeIfNeeded(ctx) {
97
+ const d = evaluateNudge(ctx);
98
+ if (d.nudge) {
99
+ // eslint-disable-next-line no-console
100
+ console.log(d.banner);
101
+ }
102
+ }
103
+ //# sourceMappingURL=reminder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reminder.js","sourceRoot":"","sources":["../../../src/toolkit/plugin/reminder.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,SAAS,EAAsB,MAAM,YAAY,CAAC;AAwB3D,SAAS,WAAW,CAAC,CAAO,EAAE,CAAO;IACnC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO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ACxB,SAAS,CAAC,IAAI,CAAC;gBACb,SAAS;gBACT,WAAW,EAAE,QAAQ;gBACrB,iBAAiB,EAAE,IAAI;aACxB,CAAC,CAAC;YACH,QAAQ,IAAI,QAAQ,CAAC;QACvB,CAAC;IACH,CAAC;IAED,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC3B,OAAO;YACL,KAAK,EAAE,KAAK;YACZ,MAAM,EAAE,EAAE;YACV,MAAM,EAAE,4BAA4B;YACpC,YAAY,EAAE,EAAE;SACjB,CAAC;IACJ,CAAC;IAED,MAAM,QAAQ,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC9D,MAAM,MAAM,GAAG;QACb,gBAAgB,QAAQ,2BAA2B,QAAQ,GAAG;QAC9D,yEAAyE;QACzE,iDAAiD;KAClD,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAEb,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE,YAAY,EAAE,SAAS,EAAE,CAAC;AACnF,CAAC;AAED,6EAA6E;AAC7E,MAAM,UAAU,kBAAkB,CAAC,GAAiB;IAClD,MAAM,CAAC,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC;IAC7B,IAAI,CAAC,CAAC,KAAK,EAAE,CAAC;QACZ,sCAAsC;QACtC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;IACxB,CAAC;AACH,CAAC"}
@@ -0,0 +1,24 @@
1
+ import type { ApprovalState } from "./gate.js";
2
+ export declare class ApprovalEngine implements ApprovalState {
3
+ private _sessionApproved;
4
+ private readonly _grants;
5
+ private readonly _expiryLogged;
6
+ private readonly _onExpired;
7
+ constructor(opts?: {
8
+ onGrantExpired?: (grantType: string) => void;
9
+ });
10
+ get sessionApproved(): boolean;
11
+ /** Mark the session as approved (used by `confirm_once` mode). */
12
+ approveSession(): void;
13
+ /** Issue a time-limited grant, expiring `ttlSeconds` from now. */
14
+ addGrant(grantType: string, ttlSeconds?: number): void;
15
+ /** Revoke a grant if it exists. */
16
+ revokeGrant(grantType: string): void;
17
+ /**
18
+ * Is `grantType` currently active? Returns false for unknown or expired
19
+ * grants. On first observation that a grant has expired, invokes the
20
+ * `onGrantExpired` callback once (subsequent checks are silent).
21
+ */
22
+ hasActiveGrant(grantType: string): boolean;
23
+ }
24
+ //# sourceMappingURL=approval.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"approval.d.ts","sourceRoot":"","sources":["../../../src/toolkit/policy/approval.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE/C,qBAAa,cAAe,YAAW,aAAa;IAClD,OAAO,CAAC,gBAAgB,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA6B;IACrD,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAqB;IACnD,OAAO,CAAC,QAAQ,CAAC,UAAU,CAA4C;gBAE3D,IAAI,GAAE;QAAE,cAAc,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAA;KAAO;IAIvE,IAAI,eAAe,IAAI,OAAO,CAE7B;IAED,kEAAkE;IAClE,cAAc,IAAI,IAAI;IAItB,kEAAkE;IAClE,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,GAAE,MAAY,GAAG,IAAI;IAI3D,mCAAmC;IACnC,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAKpC;;;;OAIG;IACH,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO;CAU3C"}
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Grant + session approval state machine.
3
+ *
4
+ * Lives in-process only: both session approval and grants are stored on the
5
+ * `ApprovalEngine` instance. A fresh CLI invocation always starts with no
6
+ * approvals, so `approval_mode: confirm_once` / `grant_required` are
7
+ * single-invocation gates — suitable for the agent-connector CLI's
8
+ * short-lived process model.
9
+ *
10
+ * Uses `performance.now()` (monotonic, process-relative) for grant expiry —
11
+ * not wall-clock, so DST jumps and clock skew don't affect active grants.
12
+ */
13
+ import { performance } from "node:perf_hooks";
14
+ export class ApprovalEngine {
15
+ _sessionApproved = false;
16
+ _grants = new Map(); // grantType → expiry (performance.now ms)
17
+ _expiryLogged = new Set(); // dedup log spam
18
+ _onExpired;
19
+ constructor(opts = {}) {
20
+ this._onExpired = opts.onGrantExpired;
21
+ }
22
+ get sessionApproved() {
23
+ return this._sessionApproved;
24
+ }
25
+ /** Mark the session as approved (used by `confirm_once` mode). */
26
+ approveSession() {
27
+ this._sessionApproved = true;
28
+ }
29
+ /** Issue a time-limited grant, expiring `ttlSeconds` from now. */
30
+ addGrant(grantType, ttlSeconds = 300) {
31
+ this._grants.set(grantType, performance.now() + ttlSeconds * 1000);
32
+ }
33
+ /** Revoke a grant if it exists. */
34
+ revokeGrant(grantType) {
35
+ this._grants.delete(grantType);
36
+ this._expiryLogged.delete(grantType);
37
+ }
38
+ /**
39
+ * Is `grantType` currently active? Returns false for unknown or expired
40
+ * grants. On first observation that a grant has expired, invokes the
41
+ * `onGrantExpired` callback once (subsequent checks are silent).
42
+ */
43
+ hasActiveGrant(grantType) {
44
+ const expiry = this._grants.get(grantType);
45
+ if (expiry === undefined)
46
+ return false;
47
+ if (performance.now() < expiry)
48
+ return true;
49
+ if (!this._expiryLogged.has(grantType)) {
50
+ this._expiryLogged.add(grantType);
51
+ this._onExpired?.(grantType);
52
+ }
53
+ return false;
54
+ }
55
+ }
56
+ //# sourceMappingURL=approval.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"approval.js","sourceRoot":"","sources":["../../../src/toolkit/policy/approval.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAG9C,MAAM,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