@rubytech/create-realagent-code 0.1.593 → 0.1.594

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 (244) hide show
  1. package/package.json +2 -2
  2. package/payload/platform/package.json +1 -0
  3. package/payload/platform/plugins/admin/skills/platform-architecture/SKILL.md +5 -3
  4. package/payload/platform/plugins/admin/skills/whats-new/SKILL.md +5 -0
  5. package/payload/platform/plugins/cloudflare/PLUGIN.md +2 -0
  6. package/payload/platform/plugins/docs/references/internals.md +1 -1
  7. package/payload/platform/plugins/docs/references/telegram-guide.md +3 -1
  8. package/payload/platform/scripts/__tests__/agent-identity-reconcile.test.sh +110 -0
  9. package/payload/platform/scripts/__tests__/check-orphan-dist.test.sh +87 -0
  10. package/payload/platform/scripts/check-orphan-dist.mjs +143 -0
  11. package/payload/platform/scripts/lib/agent-identity-reconcile.sh +122 -0
  12. package/payload/platform/scripts/lib/provision-account-dir.sh +8 -26
  13. package/payload/platform/scripts/setup-account.sh +15 -0
  14. package/payload/platform/services/claude-session-manager/dist/index.js +5 -0
  15. package/payload/platform/services/claude-session-manager/dist/index.js.map +1 -1
  16. package/payload/platform/services/claude-session-manager/dist/public-agent-reachability.d.ts +5 -0
  17. package/payload/platform/services/claude-session-manager/dist/public-agent-reachability.d.ts.map +1 -1
  18. package/payload/platform/services/claude-session-manager/dist/public-agent-reachability.js +42 -1
  19. package/payload/platform/services/claude-session-manager/dist/public-agent-reachability.js.map +1 -1
  20. package/payload/platform/templates/agents/public/IDENTITY.md +3 -3
  21. package/payload/platform/lib/anthropic-key/dist/index.d.ts +0 -22
  22. package/payload/platform/lib/anthropic-key/dist/index.d.ts.map +0 -1
  23. package/payload/platform/lib/anthropic-key/dist/index.js +0 -232
  24. package/payload/platform/lib/anthropic-key/dist/index.js.map +0 -1
  25. package/payload/platform/lib/graph-search/dist/query-expansion.d.ts +0 -37
  26. package/payload/platform/lib/graph-search/dist/query-expansion.d.ts.map +0 -1
  27. package/payload/platform/lib/graph-search/dist/query-expansion.js +0 -101
  28. package/payload/platform/lib/graph-search/dist/query-expansion.js.map +0 -1
  29. package/payload/platform/lib/oauth-llm/dist/index.d.ts +0 -116
  30. package/payload/platform/lib/oauth-llm/dist/index.d.ts.map +0 -1
  31. package/payload/platform/lib/oauth-llm/dist/index.js +0 -386
  32. package/payload/platform/lib/oauth-llm/dist/index.js.map +0 -1
  33. package/payload/platform/lib/screening-patterns/dist/index.d.ts +0 -29
  34. package/payload/platform/lib/screening-patterns/dist/index.d.ts.map +0 -1
  35. package/payload/platform/lib/screening-patterns/dist/index.js +0 -48
  36. package/payload/platform/lib/screening-patterns/dist/index.js.map +0 -1
  37. package/payload/platform/plugins/admin/mcp/dist/__tests__/admin-identity-authenticate.test.d.ts +0 -2
  38. package/payload/platform/plugins/admin/mcp/dist/__tests__/admin-identity-authenticate.test.d.ts.map +0 -1
  39. package/payload/platform/plugins/admin/mcp/dist/__tests__/admin-identity-authenticate.test.js +0 -34
  40. package/payload/platform/plugins/admin/mcp/dist/__tests__/admin-identity-authenticate.test.js.map +0 -1
  41. package/payload/platform/plugins/admin/mcp/dist/lib/onboarding.d.ts +0 -39
  42. package/payload/platform/plugins/admin/mcp/dist/lib/onboarding.d.ts.map +0 -1
  43. package/payload/platform/plugins/admin/mcp/dist/lib/onboarding.js +0 -249
  44. package/payload/platform/plugins/admin/mcp/dist/lib/onboarding.js.map +0 -1
  45. package/payload/platform/plugins/admin/mcp/dist/tools/admin-identity-authenticate.d.ts +0 -6
  46. package/payload/platform/plugins/admin/mcp/dist/tools/admin-identity-authenticate.d.ts.map +0 -1
  47. package/payload/platform/plugins/admin/mcp/dist/tools/admin-identity-authenticate.js +0 -32
  48. package/payload/platform/plugins/admin/mcp/dist/tools/admin-identity-authenticate.js.map +0 -1
  49. package/payload/platform/plugins/cloudflare/mcp/dist/lib/cloudflared.d.ts +0 -283
  50. package/payload/platform/plugins/cloudflare/mcp/dist/lib/cloudflared.d.ts.map +0 -1
  51. package/payload/platform/plugins/cloudflare/mcp/dist/lib/cloudflared.js +0 -1155
  52. package/payload/platform/plugins/cloudflare/mcp/dist/lib/cloudflared.js.map +0 -1
  53. package/payload/platform/plugins/cloudflare/mcp/dist/lib/setup-orchestrator.d.ts +0 -90
  54. package/payload/platform/plugins/cloudflare/mcp/dist/lib/setup-orchestrator.d.ts.map +0 -1
  55. package/payload/platform/plugins/cloudflare/mcp/dist/lib/setup-orchestrator.js +0 -551
  56. package/payload/platform/plugins/cloudflare/mcp/dist/lib/setup-orchestrator.js.map +0 -1
  57. package/payload/platform/plugins/email/mcp/dist/lib/claude-bridge.d.ts +0 -17
  58. package/payload/platform/plugins/email/mcp/dist/lib/claude-bridge.d.ts.map +0 -1
  59. package/payload/platform/plugins/email/mcp/dist/lib/claude-bridge.js +0 -186
  60. package/payload/platform/plugins/email/mcp/dist/lib/claude-bridge.js.map +0 -1
  61. package/payload/platform/plugins/email/mcp/dist/lib/screening.d.ts +0 -29
  62. package/payload/platform/plugins/email/mcp/dist/lib/screening.d.ts.map +0 -1
  63. package/payload/platform/plugins/email/mcp/dist/lib/screening.js +0 -105
  64. package/payload/platform/plugins/email/mcp/dist/lib/screening.js.map +0 -1
  65. package/payload/platform/plugins/email/mcp/dist/scripts/email-auto-respond.d.ts +0 -38
  66. package/payload/platform/plugins/email/mcp/dist/scripts/email-auto-respond.d.ts.map +0 -1
  67. package/payload/platform/plugins/email/mcp/dist/scripts/email-auto-respond.js +0 -817
  68. package/payload/platform/plugins/email/mcp/dist/scripts/email-auto-respond.js.map +0 -1
  69. package/payload/platform/plugins/email/mcp/dist/scripts/email-fetch.d.ts +0 -30
  70. package/payload/platform/plugins/email/mcp/dist/scripts/email-fetch.d.ts.map +0 -1
  71. package/payload/platform/plugins/email/mcp/dist/scripts/email-fetch.js +0 -215
  72. package/payload/platform/plugins/email/mcp/dist/scripts/email-fetch.js.map +0 -1
  73. package/payload/platform/plugins/email/mcp/dist/tools/email-auto-respond-config.d.ts +0 -19
  74. package/payload/platform/plugins/email/mcp/dist/tools/email-auto-respond-config.d.ts.map +0 -1
  75. package/payload/platform/plugins/email/mcp/dist/tools/email-auto-respond-config.js +0 -151
  76. package/payload/platform/plugins/email/mcp/dist/tools/email-auto-respond-config.js.map +0 -1
  77. package/payload/platform/plugins/email/mcp/dist/tools/email-classify.d.ts +0 -6
  78. package/payload/platform/plugins/email/mcp/dist/tools/email-classify.d.ts.map +0 -1
  79. package/payload/platform/plugins/email/mcp/dist/tools/email-classify.js +0 -89
  80. package/payload/platform/plugins/email/mcp/dist/tools/email-classify.js.map +0 -1
  81. package/payload/platform/plugins/memory/mcp/dist/lib/__tests__/compiled-truth-rewriter-operator-hint.test.d.ts +0 -2
  82. package/payload/platform/plugins/memory/mcp/dist/lib/__tests__/compiled-truth-rewriter-operator-hint.test.d.ts.map +0 -1
  83. package/payload/platform/plugins/memory/mcp/dist/lib/__tests__/compiled-truth-rewriter-operator-hint.test.js +0 -90
  84. package/payload/platform/plugins/memory/mcp/dist/lib/__tests__/compiled-truth-rewriter-operator-hint.test.js.map +0 -1
  85. package/payload/platform/plugins/memory/mcp/dist/lib/__tests__/llm-classifier.test.d.ts +0 -2
  86. package/payload/platform/plugins/memory/mcp/dist/lib/__tests__/llm-classifier.test.d.ts.map +0 -1
  87. package/payload/platform/plugins/memory/mcp/dist/lib/__tests__/llm-classifier.test.js +0 -226
  88. package/payload/platform/plugins/memory/mcp/dist/lib/__tests__/llm-classifier.test.js.map +0 -1
  89. package/payload/platform/plugins/memory/mcp/dist/lib/compiled-truth-rewriter.d.ts +0 -60
  90. package/payload/platform/plugins/memory/mcp/dist/lib/compiled-truth-rewriter.d.ts.map +0 -1
  91. package/payload/platform/plugins/memory/mcp/dist/lib/compiled-truth-rewriter.js +0 -169
  92. package/payload/platform/plugins/memory/mcp/dist/lib/compiled-truth-rewriter.js.map +0 -1
  93. package/payload/platform/plugins/memory/mcp/dist/lib/llm-classifier.d.ts +0 -248
  94. package/payload/platform/plugins/memory/mcp/dist/lib/llm-classifier.d.ts.map +0 -1
  95. package/payload/platform/plugins/memory/mcp/dist/lib/llm-classifier.js +0 -824
  96. package/payload/platform/plugins/memory/mcp/dist/lib/llm-classifier.js.map +0 -1
  97. package/payload/platform/plugins/memory/mcp/dist/lib/llm-ranker.d.ts +0 -63
  98. package/payload/platform/plugins/memory/mcp/dist/lib/llm-ranker.d.ts.map +0 -1
  99. package/payload/platform/plugins/memory/mcp/dist/lib/llm-ranker.js +0 -210
  100. package/payload/platform/plugins/memory/mcp/dist/lib/llm-ranker.js.map +0 -1
  101. package/payload/platform/plugins/memory/mcp/dist/lib/typed-edge-pass.d.ts +0 -35
  102. package/payload/platform/plugins/memory/mcp/dist/lib/typed-edge-pass.d.ts.map +0 -1
  103. package/payload/platform/plugins/memory/mcp/dist/lib/typed-edge-pass.js +0 -28
  104. package/payload/platform/plugins/memory/mcp/dist/lib/typed-edge-pass.js.map +0 -1
  105. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/conversation-archive-derive-insights-emit.test.d.ts +0 -2
  106. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/conversation-archive-derive-insights-emit.test.d.ts.map +0 -1
  107. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/conversation-archive-derive-insights-emit.test.js +0 -68
  108. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/conversation-archive-derive-insights-emit.test.js.map +0 -1
  109. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/memory-archive-write-emit.test.d.ts +0 -2
  110. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/memory-archive-write-emit.test.d.ts.map +0 -1
  111. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/memory-archive-write-emit.test.js +0 -88
  112. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/memory-archive-write-emit.test.js.map +0 -1
  113. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/memory-classify-emit.test.d.ts +0 -2
  114. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/memory-classify-emit.test.d.ts.map +0 -1
  115. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/memory-classify-emit.test.js +0 -58
  116. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/memory-classify-emit.test.js.map +0 -1
  117. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/memory-delete-emit.test.d.ts +0 -2
  118. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/memory-delete-emit.test.d.ts.map +0 -1
  119. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/memory-delete-emit.test.js +0 -64
  120. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/memory-delete-emit.test.js.map +0 -1
  121. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/memory-edit-attachment-emit.test.d.ts +0 -2
  122. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/memory-edit-attachment-emit.test.d.ts.map +0 -1
  123. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/memory-edit-attachment-emit.test.js +0 -70
  124. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/memory-edit-attachment-emit.test.js.map +0 -1
  125. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/memory-empty-trash-emit.test.d.ts +0 -2
  126. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/memory-empty-trash-emit.test.d.ts.map +0 -1
  127. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/memory-empty-trash-emit.test.js +0 -48
  128. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/memory-empty-trash-emit.test.js.map +0 -1
  129. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/memory-ingest-emit.test.d.ts +0 -2
  130. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/memory-ingest-emit.test.d.ts.map +0 -1
  131. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/memory-ingest-emit.test.js +0 -74
  132. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/memory-ingest-emit.test.js.map +0 -1
  133. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/memory-ingest-extract-emit.test.d.ts +0 -2
  134. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/memory-ingest-extract-emit.test.d.ts.map +0 -1
  135. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/memory-ingest-extract-emit.test.js +0 -47
  136. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/memory-ingest-extract-emit.test.js.map +0 -1
  137. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/memory-ingest-web-emit.test.d.ts +0 -2
  138. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/memory-ingest-web-emit.test.d.ts.map +0 -1
  139. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/memory-ingest-web-emit.test.js +0 -65
  140. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/memory-ingest-web-emit.test.js.map +0 -1
  141. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/memory-reindex-emit.test.d.ts +0 -2
  142. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/memory-reindex-emit.test.d.ts.map +0 -1
  143. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/memory-reindex-emit.test.js +0 -43
  144. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/memory-reindex-emit.test.js.map +0 -1
  145. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/memory-rename-attachment-emit.test.d.ts +0 -2
  146. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/memory-rename-attachment-emit.test.d.ts.map +0 -1
  147. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/memory-rename-attachment-emit.test.js +0 -65
  148. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/memory-rename-attachment-emit.test.js.map +0 -1
  149. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/memory-restore-emit.test.d.ts +0 -2
  150. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/memory-restore-emit.test.d.ts.map +0 -1
  151. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/memory-restore-emit.test.js +0 -49
  152. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/memory-restore-emit.test.js.map +0 -1
  153. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/memory-update-emit.test.d.ts +0 -2
  154. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/memory-update-emit.test.d.ts.map +0 -1
  155. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/memory-update-emit.test.js +0 -79
  156. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/memory-update-emit.test.js.map +0 -1
  157. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/memory-update-operator-hint.test.d.ts +0 -2
  158. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/memory-update-operator-hint.test.d.ts.map +0 -1
  159. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/memory-update-operator-hint.test.js +0 -329
  160. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/memory-update-operator-hint.test.js.map +0 -1
  161. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/memory-write-emit.test.d.ts +0 -2
  162. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/memory-write-emit.test.d.ts.map +0 -1
  163. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/memory-write-emit.test.js +0 -81
  164. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/memory-write-emit.test.js.map +0 -1
  165. package/payload/platform/plugins/memory/mcp/dist/tools/memory-classify.d.ts +0 -34
  166. package/payload/platform/plugins/memory/mcp/dist/tools/memory-classify.d.ts.map +0 -1
  167. package/payload/platform/plugins/memory/mcp/dist/tools/memory-classify.js +0 -62
  168. package/payload/platform/plugins/memory/mcp/dist/tools/memory-classify.js.map +0 -1
  169. package/payload/platform/plugins/memory/mcp/dist/tools/memory-rank.d.ts +0 -61
  170. package/payload/platform/plugins/memory/mcp/dist/tools/memory-rank.d.ts.map +0 -1
  171. package/payload/platform/plugins/memory/mcp/dist/tools/memory-rank.js +0 -102
  172. package/payload/platform/plugins/memory/mcp/dist/tools/memory-rank.js.map +0 -1
  173. package/payload/platform/plugins/memory/mcp/dist/tools/memory-signals-recent.d.ts +0 -35
  174. package/payload/platform/plugins/memory/mcp/dist/tools/memory-signals-recent.d.ts.map +0 -1
  175. package/payload/platform/plugins/memory/mcp/dist/tools/memory-signals-recent.js +0 -73
  176. package/payload/platform/plugins/memory/mcp/dist/tools/memory-signals-recent.js.map +0 -1
  177. package/payload/platform/plugins/memory/mcp/dist/tools/memory-typed-edge-pass.d.ts +0 -29
  178. package/payload/platform/plugins/memory/mcp/dist/tools/memory-typed-edge-pass.d.ts.map +0 -1
  179. package/payload/platform/plugins/memory/mcp/dist/tools/memory-typed-edge-pass.js +0 -22
  180. package/payload/platform/plugins/memory/mcp/dist/tools/memory-typed-edge-pass.js.map +0 -1
  181. package/payload/platform/plugins/memory/mcp/dist/tools/session-retrospective-skip-rate.d.ts +0 -30
  182. package/payload/platform/plugins/memory/mcp/dist/tools/session-retrospective-skip-rate.d.ts.map +0 -1
  183. package/payload/platform/plugins/memory/mcp/dist/tools/session-retrospective-skip-rate.js +0 -130
  184. package/payload/platform/plugins/memory/mcp/dist/tools/session-retrospective-skip-rate.js.map +0 -1
  185. package/payload/platform/plugins/outlook/mcp/dist/auth/pkce-flow.d.ts +0 -65
  186. package/payload/platform/plugins/outlook/mcp/dist/auth/pkce-flow.d.ts.map +0 -1
  187. package/payload/platform/plugins/outlook/mcp/dist/auth/pkce-flow.js +0 -262
  188. package/payload/platform/plugins/outlook/mcp/dist/auth/pkce-flow.js.map +0 -1
  189. package/payload/platform/plugins/scheduling/mcp/dist/lib/__tests__/normalise-start-date.test.d.ts +0 -2
  190. package/payload/platform/plugins/scheduling/mcp/dist/lib/__tests__/normalise-start-date.test.d.ts.map +0 -1
  191. package/payload/platform/plugins/scheduling/mcp/dist/lib/__tests__/normalise-start-date.test.js +0 -100
  192. package/payload/platform/plugins/scheduling/mcp/dist/lib/__tests__/normalise-start-date.test.js.map +0 -1
  193. package/payload/platform/plugins/scheduling/mcp/dist/lib/__tests__/scheduled-seat-id.test.d.ts +0 -2
  194. package/payload/platform/plugins/scheduling/mcp/dist/lib/__tests__/scheduled-seat-id.test.d.ts.map +0 -1
  195. package/payload/platform/plugins/scheduling/mcp/dist/lib/__tests__/scheduled-seat-id.test.js +0 -22
  196. package/payload/platform/plugins/scheduling/mcp/dist/lib/__tests__/scheduled-seat-id.test.js.map +0 -1
  197. package/payload/platform/plugins/scheduling/mcp/dist/lib/scheduled-seat-id.d.ts +0 -11
  198. package/payload/platform/plugins/scheduling/mcp/dist/lib/scheduled-seat-id.d.ts.map +0 -1
  199. package/payload/platform/plugins/scheduling/mcp/dist/lib/scheduled-seat-id.js +0 -19
  200. package/payload/platform/plugins/scheduling/mcp/dist/lib/scheduled-seat-id.js.map +0 -1
  201. package/payload/platform/plugins/url-get/mcp/dist/lib/summarise.d.ts +0 -8
  202. package/payload/platform/plugins/url-get/mcp/dist/lib/summarise.d.ts.map +0 -1
  203. package/payload/platform/plugins/url-get/mcp/dist/lib/summarise.js +0 -83
  204. package/payload/platform/plugins/url-get/mcp/dist/lib/summarise.js.map +0 -1
  205. package/payload/platform/plugins/workflows/mcp/dist/lib/llm-call.d.ts +0 -151
  206. package/payload/platform/plugins/workflows/mcp/dist/lib/llm-call.d.ts.map +0 -1
  207. package/payload/platform/plugins/workflows/mcp/dist/lib/llm-call.js +0 -299
  208. package/payload/platform/plugins/workflows/mcp/dist/lib/llm-call.js.map +0 -1
  209. package/payload/platform/services/claude-session-manager/dist/account-admin-census.d.ts +0 -39
  210. package/payload/platform/services/claude-session-manager/dist/account-admin-census.d.ts.map +0 -1
  211. package/payload/platform/services/claude-session-manager/dist/account-admin-census.js +0 -122
  212. package/payload/platform/services/claude-session-manager/dist/account-admin-census.js.map +0 -1
  213. package/payload/platform/services/claude-session-manager/dist/admin-identity-audit.d.ts +0 -39
  214. package/payload/platform/services/claude-session-manager/dist/admin-identity-audit.d.ts.map +0 -1
  215. package/payload/platform/services/claude-session-manager/dist/admin-identity-audit.js +0 -133
  216. package/payload/platform/services/claude-session-manager/dist/admin-identity-audit.js.map +0 -1
  217. package/payload/platform/services/claude-session-manager/dist/input-postcondition.d.ts +0 -22
  218. package/payload/platform/services/claude-session-manager/dist/input-postcondition.d.ts.map +0 -1
  219. package/payload/platform/services/claude-session-manager/dist/input-postcondition.js +0 -50
  220. package/payload/platform/services/claude-session-manager/dist/input-postcondition.js.map +0 -1
  221. package/payload/platform/services/claude-session-manager/dist/jsonl-observer.d.ts +0 -30
  222. package/payload/platform/services/claude-session-manager/dist/jsonl-observer.d.ts.map +0 -1
  223. package/payload/platform/services/claude-session-manager/dist/jsonl-observer.js +0 -204
  224. package/payload/platform/services/claude-session-manager/dist/jsonl-observer.js.map +0 -1
  225. package/payload/platform/services/claude-session-manager/dist/rc-script-spawn.d.ts +0 -80
  226. package/payload/platform/services/claude-session-manager/dist/rc-script-spawn.d.ts.map +0 -1
  227. package/payload/platform/services/claude-session-manager/dist/rc-script-spawn.js +0 -306
  228. package/payload/platform/services/claude-session-manager/dist/rc-script-spawn.js.map +0 -1
  229. package/payload/platform/services/claude-session-manager/dist/session-store.d.ts +0 -49
  230. package/payload/platform/services/claude-session-manager/dist/session-store.d.ts.map +0 -1
  231. package/payload/platform/services/claude-session-manager/dist/session-store.js +0 -52
  232. package/payload/platform/services/claude-session-manager/dist/session-store.js.map +0 -1
  233. package/payload/platform/services/claude-session-manager/dist/systemd-spawn.d.ts +0 -83
  234. package/payload/platform/services/claude-session-manager/dist/systemd-spawn.d.ts.map +0 -1
  235. package/payload/platform/services/claude-session-manager/dist/systemd-spawn.js +0 -345
  236. package/payload/platform/services/claude-session-manager/dist/systemd-spawn.js.map +0 -1
  237. package/payload/platform/services/telegram-channel/dist/turn-follow.d.ts +0 -104
  238. package/payload/platform/services/telegram-channel/dist/turn-follow.d.ts.map +0 -1
  239. package/payload/platform/services/telegram-channel/dist/turn-follow.js +0 -408
  240. package/payload/platform/services/telegram-channel/dist/turn-follow.js.map +0 -1
  241. package/payload/platform/services/whatsapp-channel/dist/turn-follow.d.ts +0 -104
  242. package/payload/platform/services/whatsapp-channel/dist/turn-follow.d.ts.map +0 -1
  243. package/payload/platform/services/whatsapp-channel/dist/turn-follow.js +0 -393
  244. package/payload/platform/services/whatsapp-channel/dist/turn-follow.js.map +0 -1
@@ -1,130 +0,0 @@
1
- /**
2
- * Session-retrospective skip-rate visibility tool.
3
- *
4
- * Called by the admin agent at session start. Returns the ratio of recent
5
- * sessions that closed without calling `session-retrospective-mark-complete`
6
- * — sessions where the typed-edge pass, learnings pass, and SOUL.md pass
7
- * never ran. The admin agent surfaces the result to the operator if the
8
- * rate is non-zero so closing via Sidebar Archive / tab-close becomes a
9
- * visible cost rather than a silent one.
10
- *
11
- * Mechanism: count `:Conversation` nodes for this account in the recent
12
- * window; count those whose corresponding session log contains the
13
- * sentinel tool-use of `session-retrospective-mark-complete`. The ratio
14
- * is the skip rate. Pending nodes (prose with `updatedAt` later than the
15
- * most-recent completed retrospective) carry the deferred typed-edge work
16
- * that will land at the next /end.
17
- */
18
- import { int } from "neo4j-driver";
19
- export async function sessionRetrospectiveSkipRate(args, session, accountId) {
20
- const windowSize = Math.max(1, Math.min(args.windowSize ?? 10, 100));
21
- // Conversations carry `retrospectiveCompletedAt` when the sentinel tool
22
- // fired (set by the admin mark-complete tool through log-ingest +
23
- // platform/ui session writer). When the property is null/missing, the
24
- // retrospective was skipped.
25
- // The oldest-pending bound is the earliest updatedAt across prose nodes
26
- // for this account whose updatedAt is *after* the most-recent completed
27
- // retrospective — i.e. nodes the next session's pass will pick up.
28
- const cypher = `
29
- CALL {
30
- MATCH (c:Conversation {accountId: $accountId})
31
- RETURN c
32
- ORDER BY c.updatedAt DESC
33
- LIMIT $windowSize
34
- }
35
- WITH collect(c) AS recent
36
- WITH recent,
37
- [c IN recent WHERE c.retrospectiveCompletedAt IS NOT NULL] AS done,
38
- [c IN recent WHERE c.retrospectiveCompletedAt IS NOT NULL | c.retrospectiveCompletedAt]
39
- AS doneTimestamps
40
- WITH size(recent) AS windowSessions,
41
- size(done) AS completedRetrospectives,
42
- CASE WHEN size(doneTimestamps) > 0
43
- THEN apoc.coll.max(doneTimestamps)
44
- ELSE null END AS lastCompletedAt
45
- OPTIONAL MATCH (n)
46
- WHERE n.accountId = $accountId
47
- AND ANY(l IN labels(n) WHERE l IN $proseLabels)
48
- AND (lastCompletedAt IS NULL OR n.updatedAt > lastCompletedAt)
49
- WITH windowSessions, completedRetrospectives, min(n.updatedAt) AS oldestPending
50
- RETURN windowSessions, completedRetrospectives, oldestPending
51
- `;
52
- // APOC is bundled with the Maxy Neo4j install. If unavailable, fall back to
53
- // a pure-Cypher variant that uses reduce() for max.
54
- const fallbackCypher = `
55
- CALL {
56
- MATCH (c:Conversation {accountId: $accountId})
57
- RETURN c
58
- ORDER BY c.updatedAt DESC
59
- LIMIT $windowSize
60
- }
61
- WITH collect(c) AS recent
62
- WITH recent,
63
- [c IN recent WHERE c.retrospectiveCompletedAt IS NOT NULL] AS done,
64
- [c IN recent WHERE c.retrospectiveCompletedAt IS NOT NULL | c.retrospectiveCompletedAt]
65
- AS doneTimestamps
66
- WITH size(recent) AS windowSessions,
67
- size(done) AS completedRetrospectives,
68
- reduce(acc = null, ts IN doneTimestamps |
69
- CASE WHEN acc IS NULL OR ts > acc THEN ts ELSE acc END)
70
- AS lastCompletedAt
71
- OPTIONAL MATCH (n)
72
- WHERE n.accountId = $accountId
73
- AND ANY(l IN labels(n) WHERE l IN $proseLabels)
74
- AND (lastCompletedAt IS NULL OR n.updatedAt > lastCompletedAt)
75
- WITH windowSessions, completedRetrospectives, min(n.updatedAt) AS oldestPending
76
- RETURN windowSessions, completedRetrospectives, oldestPending
77
- `;
78
- const proseLabels = [
79
- "Message",
80
- "Page",
81
- "Meeting",
82
- "Email",
83
- "Idea",
84
- "Note",
85
- "Post",
86
- "Report",
87
- ];
88
- let records;
89
- try {
90
- const result = await session.run(cypher, {
91
- accountId,
92
- windowSize: int(windowSize),
93
- proseLabels,
94
- });
95
- records = result.records;
96
- }
97
- catch {
98
- const result = await session.run(fallbackCypher, {
99
- accountId,
100
- windowSize: int(windowSize),
101
- proseLabels,
102
- });
103
- records = result.records;
104
- }
105
- if (records.length === 0) {
106
- return {
107
- windowSessions: 0,
108
- completedRetrospectives: 0,
109
- skipRate: 0,
110
- oldestPendingSinceIso: null,
111
- };
112
- }
113
- const r = records[0];
114
- const windowSessions = Number(r.get("windowSessions") ?? 0);
115
- const completedRetrospectives = Number(r.get("completedRetrospectives") ?? 0);
116
- const oldestPending = r.get("oldestPending");
117
- const skipRate = windowSessions > 0
118
- ? Number(((windowSessions - completedRetrospectives) / windowSessions).toFixed(3))
119
- : 0;
120
- const accountShort = accountId.slice(0, 8);
121
- const oldestPendingIso = oldestPending == null ? null : String(oldestPending);
122
- console.log(`[session-retrospective-skip-rate] accountId=${accountShort}… window=${windowSessions} completed=${completedRetrospectives} skip-rate=${skipRate} oldest-pending=${oldestPendingIso ?? "none"}`);
123
- return {
124
- windowSessions,
125
- completedRetrospectives,
126
- skipRate,
127
- oldestPendingSinceIso: oldestPendingIso,
128
- };
129
- }
130
- //# sourceMappingURL=session-retrospective-skip-rate.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"session-retrospective-skip-rate.js","sourceRoot":"","sources":["../../src/tools/session-retrospective-skip-rate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,GAAG,EAAgB,MAAM,cAAc,CAAC;AAcjD,MAAM,CAAC,KAAK,UAAU,4BAA4B,CAChD,IAAyB,EACzB,OAAgB,EAChB,SAAiB;IAEjB,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,IAAI,EAAE,EAAE,GAAG,CAAC,CAAC,CAAC;IAErE,wEAAwE;IACxE,kEAAkE;IAClE,sE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AAC,IAAI,CAAC,CAAC,CAAC;IAC9E,MAAM,aAAa,GAAG,CAAC,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;IAC7C,MAAM,QAAQ,GAAG,cAAc,GAAG,CAAC;QACjC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,cAAc,GAAG,uBAAuB,CAAC,GAAG,cAAc,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QAClF,CAAC,CAAC,CAAC,CAAC;IACN,MAAM,YAAY,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC3C,MAAM,gBAAgB,GAAG,aAAa,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;IAE9E,OAAO,CAAC,GAAG,CACT,+CAA+C,YAAY,YAAY,cAAc,cAAc,uBAAuB,cAAc,QAAQ,mBAAmB,gBAAgB,IAAI,MAAM,EAAE,CAChM,CAAC;IAEF,OAAO;QACL,cAAc;QACd,uBAAuB;QACvB,QAAQ;QACR,qBAAqB,EAAE,gBAAgB;KACxC,CAAC;AACJ,CAAC"}
@@ -1,65 +0,0 @@
1
- /**
2
- * OAuth 2.0 Authorization Code + PKCE flow for Microsoft Identity Platform.
3
- *
4
- * Adapted from nsakki55/outlook-mcp@e49d8e68ac8d69db653c25803127dc3b98626cda
5
- * (MIT). Adaptations:
6
- * - Ephemeral loopback port via `server.listen(0)` (upstream uses fixed
7
- * 49152). The Entra app is registered with `http://localhost` (no port);
8
- * Microsoft Identity Platform treats native-app loopback redirects with
9
- * port-flexible matching.
10
- * - No `xdg-open` browser auto-launch; the auth URL is logged to stderr
11
- * and returned to the caller for the operator to open in the VNC browser.
12
- * - Tool handler awaits the full PKCE flow synchronously (5-min timeout)
13
- * instead of upstream's background-promise + immediate-error pattern.
14
- */
15
- export interface PkceFlowConfig {
16
- clientId: string;
17
- tenantId: string;
18
- accountId: string;
19
- }
20
- export interface TokenResponse {
21
- access_token: string;
22
- refresh_token?: string;
23
- expires_in: number;
24
- token_type: string;
25
- scope?: string;
26
- }
27
- export interface PkceFlowResult {
28
- tokenResponse: TokenResponse;
29
- scopes: string[];
30
- }
31
- export interface PkceFlowStart {
32
- authUrl: string;
33
- redirectUri: string;
34
- result: Promise<PkceFlowResult>;
35
- }
36
- /**
37
- * Start the PKCE flow:
38
- * 1. Generate code_verifier + code_challenge (S256) + state.
39
- * 2. Bind a one-shot HTTP server on an ephemeral loopback port.
40
- * 3. Build the authorize URL with the actual port; return it to the caller.
41
- * 4. The returned `result` promise resolves when the callback arrives (or
42
- * rejects on state mismatch / OAuth error / timeout) and tokens are
43
- * exchanged.
44
- *
45
- * The caller (the outlook-account-register tool) prints the auth URL,
46
- * returns it in the tool response, and awaits `result`.
47
- */
48
- export declare function startPkceFlow(config: PkceFlowConfig): Promise<PkceFlowStart>;
49
- export declare function refreshAccessToken(args: {
50
- clientId: string;
51
- tenantId: string;
52
- refreshToken: string;
53
- }): Promise<TokenResponse>;
54
- /**
55
- * Constant-time equality on equal-length strings. Returns false (not throws)
56
- * for length mismatch so the caller can branch without leaking length via
57
- * timing. State comparison MUST go through this helper, not `!==`.
58
- */
59
- declare function sameLengthEqual(a: string, b: string): boolean;
60
- export declare const _internals: {
61
- SCOPES: string[];
62
- sameLengthEqual: typeof sameLengthEqual;
63
- };
64
- export {};
65
- //# sourceMappingURL=pkce-flow.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"pkce-flow.d.ts","sourceRoot":"","sources":["../../src/auth/pkce-flow.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AA+BH,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,aAAa;IAC5B,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,cAAc;IAC7B,aAAa,EAAE,aAAa,CAAC;IAC7B,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,OAAO,CAAC,cAAc,CAAC,CAAC;CACjC;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,aAAa,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC,CAsDlF;AAgJD,wBAAsB,kBAAkB,CAAC,IAAI,EAAE;IAC7C,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;CACtB,GAAG,OAAO,CAAC,aAAa,CAAC,CAmBzB;AAuBD;;;;GAIG;AACH,iBAAS,eAAe,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAKtD;AAED,eAAO,MAAM,UAAU;;;CAA8B,CAAC"}
@@ -1,262 +0,0 @@
1
- /**
2
- * OAuth 2.0 Authorization Code + PKCE flow for Microsoft Identity Platform.
3
- *
4
- * Adapted from nsakki55/outlook-mcp@e49d8e68ac8d69db653c25803127dc3b98626cda
5
- * (MIT). Adaptations:
6
- * - Ephemeral loopback port via `server.listen(0)` (upstream uses fixed
7
- * 49152). The Entra app is registered with `http://localhost` (no port);
8
- * Microsoft Identity Platform treats native-app loopback redirects with
9
- * port-flexible matching.
10
- * - No `xdg-open` browser auto-launch; the auth URL is logged to stderr
11
- * and returned to the caller for the operator to open in the VNC browser.
12
- * - Tool handler awaits the full PKCE flow synchronously (5-min timeout)
13
- * instead of upstream's background-promise + immediate-error pattern.
14
- */
15
- import { createHash, randomBytes, timingSafeEqual } from "node:crypto";
16
- import { createServer } from "node:http";
17
- import { URL } from "node:url";
18
- import { log, challengePrefix } from "../lib/log.js";
19
- const FLOW_TIMEOUT_MS = 5 * 60 * 1000; // 5 minutes
20
- const SCOPES = [
21
- "offline_access",
22
- "User.Read",
23
- "Mail.ReadWrite",
24
- "Mail.Send",
25
- "Calendars.ReadWrite",
26
- "Contacts.Read",
27
- ];
28
- function buildUrls(tenantId) {
29
- const tenant = tenantId || "common";
30
- return {
31
- authorizeUrl: `https://login.microsoftonline.com/${tenant}/oauth2/v2.0/authorize`,
32
- tokenUrl: `https://login.microsoftonline.com/${tenant}/oauth2/v2.0/token`,
33
- };
34
- }
35
- /**
36
- * Start the PKCE flow:
37
- * 1. Generate code_verifier + code_challenge (S256) + state.
38
- * 2. Bind a one-shot HTTP server on an ephemeral loopback port.
39
- * 3. Build the authorize URL with the actual port; return it to the caller.
40
- * 4. The returned `result` promise resolves when the callback arrives (or
41
- * rejects on state mismatch / OAuth error / timeout) and tokens are
42
- * exchanged.
43
- *
44
- * The caller (the outlook-account-register tool) prints the auth URL,
45
- * returns it in the tool response, and awaits `result`.
46
- */
47
- export async function startPkceFlow(config) {
48
- const codeVerifier = randomBytes(32).toString("base64url");
49
- const codeChallenge = createHash("sha256").update(codeVerifier).digest("base64url");
50
- const state = randomBytes(16).toString("hex");
51
- const bound = await bindCallbackServer(state);
52
- const redirectUri = `http://localhost:${bound.port}/callback`;
53
- const { authorizeUrl, tokenUrl } = buildUrls(config.tenantId);
54
- const authUrl = new URL(authorizeUrl);
55
- authUrl.searchParams.set("client_id", config.clientId);
56
- authUrl.searchParams.set("response_type", "code");
57
- authUrl.searchParams.set("redirect_uri", redirectUri);
58
- authUrl.searchParams.set("scope", SCOPES.join(" "));
59
- authUrl.searchParams.set("state", state);
60
- authUrl.searchParams.set("code_challenge", codeChallenge);
61
- authUrl.searchParams.set("code_challenge_method", "S256");
62
- authUrl.searchParams.set("prompt", "select_account");
63
- log({
64
- event: "auth-init",
65
- account: config.accountId,
66
- codeChallenge: challengePrefix(codeChallenge),
67
- redirectPath: `/callback (port ${bound.port})`,
68
- });
69
- const result = (async () => {
70
- const startMs = Date.now();
71
- try {
72
- const code = await bound.codePromise;
73
- log({
74
- event: "auth-callback",
75
- account: config.accountId,
76
- elapsedMs: Date.now() - startMs,
77
- });
78
- const tokenResponse = await exchangeCode({
79
- code,
80
- codeVerifier,
81
- redirectUri,
82
- clientId: config.clientId,
83
- tokenUrl,
84
- });
85
- const scopes = (tokenResponse.scope ?? SCOPES.join(" ")).split(/\s+/);
86
- return { tokenResponse, scopes };
87
- }
88
- finally {
89
- bound.close();
90
- }
91
- })();
92
- return {
93
- authUrl: authUrl.toString(),
94
- redirectUri,
95
- result,
96
- };
97
- }
98
- function bindCallbackServer(expectedState) {
99
- return new Promise((resolveBind, rejectBind) => {
100
- let resolved = false;
101
- let codeResolve = null;
102
- let codeReject = null;
103
- const codePromise = new Promise((resolve, reject) => {
104
- codeResolve = resolve;
105
- codeReject = reject;
106
- });
107
- let timer = null;
108
- const server = createServer((req, res) => {
109
- if (!req.url) {
110
- res.writeHead(400);
111
- res.end();
112
- return;
113
- }
114
- const parsed = new URL(req.url, "http://localhost");
115
- if (parsed.pathname !== "/callback") {
116
- res.writeHead(404, { "Content-Type": "text/plain" });
117
- res.end("not found");
118
- return;
119
- }
120
- const code = parsed.searchParams.get("code");
121
- const returnedState = parsed.searchParams.get("state");
122
- const error = parsed.searchParams.get("error");
123
- const errorDescription = parsed.searchParams.get("error_description");
124
- // Reject Host header rebinding (RFC 6749 native-client guidance).
125
- const host = req.headers.host ?? "";
126
- if (!/^(localhost|127\.0\.0\.1)(:\d+)?$/.test(host)) {
127
- respondHtml(res, 400, "Invalid host", "Loopback callback rejected non-localhost host header.");
128
- finish();
129
- codeReject?.(new Error(`Loopback callback received unexpected host header: ${host}`));
130
- return;
131
- }
132
- if (error) {
133
- respondHtml(res, 400, "Authentication error", `${error}: ${errorDescription ?? ""}`);
134
- finish();
135
- codeReject?.(new Error(`OAuth error: ${error} - ${errorDescription ?? ""}`));
136
- return;
137
- }
138
- if (!returnedState || !sameLengthEqual(returnedState, expectedState)) {
139
- respondHtml(res, 400, "State mismatch", "Authorization state did not match. Possible CSRF; retry register.");
140
- finish();
141
- codeReject?.(new Error("State mismatch — possible CSRF"));
142
- return;
143
- }
144
- if (!code) {
145
- respondHtml(res, 400, "No authorization code", "The authorization callback did not include a code.");
146
- finish();
147
- codeReject?.(new Error("No authorization code received"));
148
- return;
149
- }
150
- respondHtml(res, 200, "Outlook authorized", "You may close this window. Return to admin chat to continue.");
151
- finish();
152
- codeResolve?.(code);
153
- });
154
- server.on("error", (err) => {
155
- finish();
156
- // If we never resolved bind, fail bind; otherwise fail the code wait.
157
- if (!resolvedBind)
158
- rejectBind(err);
159
- codeReject?.(err);
160
- });
161
- let resolvedBind = false;
162
- server.listen(0, "127.0.0.1", () => {
163
- const address = server.address();
164
- if (!address || typeof address !== "object") {
165
- rejectBind(new Error("Loopback bind failed: address unavailable"));
166
- return;
167
- }
168
- resolvedBind = true;
169
- timer = setTimeout(() => {
170
- finish();
171
- codeReject?.(new Error("Authentication timeout (5 minutes)"));
172
- }, FLOW_TIMEOUT_MS);
173
- resolveBind({
174
- port: address.port,
175
- codePromise,
176
- close: finish,
177
- });
178
- });
179
- function finish() {
180
- if (resolved)
181
- return;
182
- resolved = true;
183
- if (timer)
184
- clearTimeout(timer);
185
- timer = null;
186
- try {
187
- server.close();
188
- }
189
- catch {
190
- // best-effort
191
- }
192
- }
193
- });
194
- }
195
- async function exchangeCode(args) {
196
- const params = new URLSearchParams({
197
- client_id: args.clientId,
198
- scope: SCOPES.join(" "),
199
- code: args.code,
200
- redirect_uri: args.redirectUri,
201
- grant_type: "authorization_code",
202
- code_verifier: args.codeVerifier,
203
- });
204
- const response = await fetch(args.tokenUrl, {
205
- method: "POST",
206
- headers: { "Content-Type": "application/x-www-form-urlencoded" },
207
- body: params.toString(),
208
- });
209
- if (!response.ok) {
210
- const text = await response.text();
211
- throw new Error(`Token exchange failed (${response.status}): ${text}`);
212
- }
213
- return (await response.json());
214
- }
215
- export async function refreshAccessToken(args) {
216
- const { tokenUrl } = buildUrls(args.tenantId);
217
- const params = new URLSearchParams({
218
- client_id: args.clientId,
219
- scope: SCOPES.join(" "),
220
- refresh_token: args.refreshToken,
221
- grant_type: "refresh_token",
222
- });
223
- const response = await fetch(tokenUrl, {
224
- method: "POST",
225
- headers: { "Content-Type": "application/x-www-form-urlencoded" },
226
- body: params.toString(),
227
- });
228
- if (!response.ok) {
229
- const text = await response.text();
230
- throw new Error(`Token refresh failed (${response.status}): ${text}`);
231
- }
232
- return (await response.json());
233
- }
234
- function respondHtml(res, status, title, message) {
235
- const color = status === 200 ? "#107c10" : "#d83b01";
236
- const body = `<!DOCTYPE html>
237
- <html lang="en"><head><meta charset="UTF-8"><title>${title}</title>
238
- <style>
239
- body{font-family:'Segoe UI',sans-serif;text-align:center;padding:60px;background:#f3f2f1;}
240
- .card{background:white;border-radius:8px;padding:40px;max-width:480px;margin:0 auto;
241
- box-shadow:0 2px 8px rgba(0,0,0,0.1);}
242
- h1{color:${color};margin:0 0 16px;}
243
- p{color:#605e5c;margin:0;line-height:1.5;}
244
- </style></head>
245
- <body><div class="card"><h1>${title}</h1><p>${message}</p></div></body></html>`;
246
- res.writeHead(status, { "Content-Type": "text/html; charset=utf-8" });
247
- res.end(body);
248
- }
249
- /**
250
- * Constant-time equality on equal-length strings. Returns false (not throws)
251
- * for length mismatch so the caller can branch without leaking length via
252
- * timing. State comparison MUST go through this helper, not `!==`.
253
- */
254
- function sameLengthEqual(a, b) {
255
- if (a.length !== b.length)
256
- return false;
257
- const aBuf = Buffer.from(a, "utf8");
258
- const bBuf = Buffer.from(b, "utf8");
259
- return timingSafeEqual(aBuf, bBuf);
260
- }
261
- export const _internals = { SCOPES, sameLengthEqual };
262
- //# sourceMappingURL=pkce-flow.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"pkce-flow.js","sourceRoot":"","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DACsC,KAAK;;;;;WAK/C,KAAK;;;8BAGc,KAAK,WAAW,OAAO,0BAA0B,CAAC;IAC9E,GAAG,CAAC,SAAS,CAAC,MAAM,EAAE,EAAE,cAAc,EAAE,0BAA0B,EAAE,CAAC,CAAC;IACtE,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC;AAED;;;;GAIG;AACH,SAAS,eAAe,CAAC,CAAS,EAAE,CAAS;IAC3C,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM;QAAE,OAAO,KAAK,CAAC;IACxC,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;IACpC,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;IACpC,OAAO,eAAe,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AACrC,CAAC;AAED,MAAM,CAAC,MAAM,UAAU,GAAG,EAAE,MAAM,EAAE,eAAe,EAAE,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=normalise-start-date.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"normalise-start-date.test.d.ts","sourceRoot":"","sources":["../../../src/lib/__tests__/normalise-start-date.test.ts"],"names":[],"mappings":""}
@@ -1,100 +0,0 @@
1
- // Task 2213. The due predicate compares startDate lexically against
2
- // new Date().toISOString(), so every stored value must share that exact shape.
3
- import { describe, it, expect } from "vitest";
4
- import { normaliseStartDate, isCanonicalStartDate } from "../time-format.js";
5
- describe("normaliseStartDate — offset-bearing input", () => {
6
- it("converts a BST offset to the equivalent UTC instant", () => {
7
- expect(normaliseStartDate("2026-07-30T11:45:00+01:00", "Europe/London")).toBe("2026-07-30T10:45:00.000Z");
8
- });
9
- it("leaves an already-canonical value byte-identical", () => {
10
- expect(normaliseStartDate("2026-06-28T05:00:00.000Z", "UTC")).toBe("2026-06-28T05:00:00.000Z");
11
- });
12
- it("adds the missing .000 to a Z value that lacks it", () => {
13
- expect(normaliseStartDate("2026-07-28T10:00:00Z", "UTC")).toBe("2026-07-28T10:00:00.000Z");
14
- });
15
- it("handles the milliseconds-plus-offset shape", () => {
16
- expect(normaliseStartDate("2026-08-02T19:00:00.000+01:00", "Europe/London")).toBe("2026-08-02T18:00:00.000Z");
17
- });
18
- it("ignores the zone argument entirely when the value carries one", () => {
19
- expect(normaliseStartDate("2026-07-30T11:45:00+01:00", "America/New_York")).toBe("2026-07-30T10:45:00.000Z");
20
- });
21
- });
22
- describe("normaliseStartDate — zoneless wall clock", () => {
23
- it("reads a summer wall clock in the given zone", () => {
24
- expect(normaliseStartDate("2026-07-20T09:00:00", "Europe/London")).toBe("2026-07-20T08:00:00.000Z");
25
- });
26
- it("reads a winter wall clock in the given zone", () => {
27
- expect(normaliseStartDate("2026-01-15T09:00:00", "Europe/London")).toBe("2026-01-15T09:00:00.000Z");
28
- });
29
- it("reads a non-UK zone", () => {
30
- expect(normaliseStartDate("2026-07-20T09:00:00", "America/New_York")).toBe("2026-07-20T13:00:00.000Z");
31
- });
32
- it("shifts a spring-forward gap wall clock past the gap", () => {
33
- // 01:30 on 29 Mar 2026 does not exist in Europe/London; 01:00 GMT -> 02:00 BST.
34
- expect(normaliseStartDate("2026-03-29T01:30:00", "Europe/London")).toBe("2026-03-29T01:30:00.000Z");
35
- });
36
- it("takes the earlier occurrence of an ambiguous autumn wall clock", () => {
37
- // 01:30 on 25 Oct 2026 happens twice; the earlier one is BST at 00:30Z.
38
- expect(normaliseStartDate("2026-10-25T01:30:00", "Europe/London")).toBe("2026-10-25T00:30:00.000Z");
39
- });
40
- it("takes the earlier occurrence of an ambiguous US wall clock", () => {
41
- expect(normaliseStartDate("2026-11-01T01:30:00", "America/New_York")).toBe("2026-11-01T05:30:00.000Z");
42
- });
43
- });
44
- describe("normaliseStartDate — partial and sub-second precision", () => {
45
- it("keeps the fractional second on a zoneless value", () => {
46
- // Intl resolves only to seconds. Differencing its reconstruction against a
47
- // millisecond-bearing instant used to fold the fraction into the offset and
48
- // land a full second out (09:00:00.5 BST came back as 08:00:01.000Z).
49
- expect(normaliseStartDate("2026-07-20T09:00:00.5", "Europe/London")).toBe("2026-07-20T08:00:00.500Z");
50
- expect(normaliseStartDate("2026-01-15T09:00:00.123", "Europe/London")).toBe("2026-01-15T09:00:00.123Z");
51
- });
52
- it("reads a minute-precision value in the zone", () => {
53
- expect(normaliseStartDate("2026-07-20T09:00", "Europe/London")).toBe("2026-07-20T08:00:00.000Z");
54
- });
55
- it("reads a date-only value as midnight in the zone", () => {
56
- // Midnight on 20 July in London is 23:00Z on the 19th.
57
- expect(normaliseStartDate("2026-07-20", "Europe/London")).toBe("2026-07-19T23:00:00.000Z");
58
- expect(normaliseStartDate("2026-01-15", "Europe/London")).toBe("2026-01-15T00:00:00.000Z");
59
- });
60
- it("accepts an offset written without a colon", () => {
61
- expect(normaliseStartDate("2026-07-20T09:00:00+0100", "Europe/London")).toBe("2026-07-20T08:00:00.000Z");
62
- });
63
- });
64
- describe("normaliseStartDate — refusals", () => {
65
- it("throws on a zoneless value with a null zone, naming the value", () => {
66
- expect(() => normaliseStartDate("2026-07-20T09:00:00", null)).toThrow(/2026-07-20T09:00:00/);
67
- });
68
- it("throws on a zoneless value with an invalid zone", () => {
69
- expect(() => normaliseStartDate("2026-07-20T09:00:00", "Not/AZone")).toThrow(/Not\/AZone/);
70
- });
71
- it("throws on an unparseable value, naming it", () => {
72
- expect(() => normaliseStartDate("next tuesday", "Europe/London")).toThrow(/next tuesday/);
73
- });
74
- });
75
- describe("normaliseStartDate — server timezone independence", () => {
76
- it("gives the same answer whatever the process TZ is", () => {
77
- // A server-local reading (new Date("2026-07-20T09:00:00")) would differ here.
78
- const before = process.env.TZ;
79
- try {
80
- process.env.TZ = "Asia/Tokyo";
81
- expect(normaliseStartDate("2026-07-20T09:00:00", "Europe/London")).toBe("2026-07-20T08:00:00.000Z");
82
- process.env.TZ = "America/Los_Angeles";
83
- expect(normaliseStartDate("2026-07-20T09:00:00", "Europe/London")).toBe("2026-07-20T08:00:00.000Z");
84
- }
85
- finally {
86
- process.env.TZ = before;
87
- }
88
- });
89
- });
90
- describe("isCanonicalStartDate", () => {
91
- it("accepts only the full 24-character shape", () => {
92
- expect(isCanonicalStartDate("2026-07-30T10:45:00.000Z")).toBe(true);
93
- // Right instant, wrong shape: "…00.000Z" sorts BEFORE "…00Z", so a mixed
94
- // corpus breaks the ordering the whole fix restores.
95
- expect(isCanonicalStartDate("2026-07-30T10:45:00Z")).toBe(false);
96
- expect(isCanonicalStartDate("2026-07-30T11:45:00+01:00")).toBe(false);
97
- expect(isCanonicalStartDate("2026-07-20T09:00:00")).toBe(false);
98
- });
99
- });
100
- //# sourceMappingURL=normalise-start-date.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"normalise-start-date.test.js","sourceRoot":"","sources":["../../../src/lib/__tests__/normalise-start-date.test.ts"],"names":[],"mappings":"AAAA,oEAAoE;AACpE,+EAA+E;AAC/E,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAE7E,QAAQ,CAAC,2CAA2C,EAAE,GAAG,EAAE;IACzD,EAAE,CAAC,qDAAqD,EAAE,GAAG,EAAE;QAC7D,MAAM,CAAC,kBAAkB,CAAC,2BAA2B,EAAE,eAAe,CAAC,CAAC,CAAC,IAAI,CAC3E,0BAA0B,CAC3B,CAAC;IACJ,CAAC,CAAC,CAAC;IACH,EAAE,CAAC,kDAAkD,EAAE,GAAG,EAAE;QAC1D,MAAM,CAAC,kBAAkB,CAAC,0BAA0B,EAAE,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC;IACjG,CAAC,CAAC,CAAC;IACH,EAAE,CAAC,kDAAkD,EAAE,GAAG,EAAE;QAC1D,MAAM,CAAC,kB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,kBAAkB,CAAC,qBAAqB,EAAE,eAAe,CAAC,CAAC,CAAC,IAAI,CACrE,0BAA0B,CAC3B,CAAC;QACJ,CAAC;gBAAS,CAAC;YACT,OAAO,CAAC,GAAG,CAAC,EAAE,GAAG,MAAM,CAAC;QAC1B,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,QAAQ,CAAC,sBAAsB,EAAE,GAAG,EAAE;IACpC,EAAE,CAAC,0CAA0C,EAAE,GAAG,EAAE;QAClD,MAAM,CAAC,oBAAoB,CAAC,0BAA0B,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACpE,yEAAyE;QACzE,qDAAqD;QACrD,MAAM,CAAC,oBAAoB,CAAC,sBAAsB,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACjE,MAAM,CAAC,oBAAoB,CAAC,2BAA2B,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACtE,MAAM,CAAC,oBAAoB,CAAC,qBAAqB,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAClE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=scheduled-seat-id.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"scheduled-seat-id.test.d.ts","sourceRoot":"","sources":["../../../src/lib/__tests__/scheduled-seat-id.test.ts"],"names":[],"mappings":""}
@@ -1,22 +0,0 @@
1
- import { describe, it, expect } from "vitest";
2
- import { scheduledSeatIdFor } from "../scheduled-seat-id.js";
3
- const V4 = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;
4
- describe("scheduledSeatIdFor — per-firing scheduled seat id (Task 1526)", () => {
5
- it("is v4-shaped", () => {
6
- expect(scheduledSeatIdFor("acct", "+447504472444", "evt-1", "2026-07-10T09:00:00.000Z")).toMatch(V4);
7
- });
8
- it("differs per firing (dispatchedAt is the salt)", () => {
9
- const a = scheduledSeatIdFor("acct", "+447504472444", "evt-1", "2026-07-10T09:00:00.000Z");
10
- const b = scheduledSeatIdFor("acct", "+447504472444", "evt-1", "2026-07-10T10:00:00.000Z");
11
- expect(a).not.toBe(b);
12
- });
13
- it("is a pure function of its four inputs", () => {
14
- expect(scheduledSeatIdFor("acct", "d", "evt-1", "2026-07-10T09:00:00.000Z")).toBe(scheduledSeatIdFor("acct", "d", "evt-1", "2026-07-10T09:00:00.000Z"));
15
- });
16
- it("differs when only the eventId differs (no cross-event collision)", () => {
17
- const a = scheduledSeatIdFor("acct", "d", "evt-1", "2026-07-10T09:00:00.000Z");
18
- const b = scheduledSeatIdFor("acct", "d", "evt-2", "2026-07-10T09:00:00.000Z");
19
- expect(a).not.toBe(b);
20
- });
21
- });
22
- //# sourceMappingURL=scheduled-seat-id.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"scheduled-seat-id.test.js","sourceRoot":"","sources":["../../../src/lib/__tests__/scheduled-seat-id.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D,MAAM,EAAE,GAAG,uEAAuE,CAAC;AAEnF,QAAQ,CAAC,+DAA+D,EAAE,GAAG,EAAE;IAC7E,EAAE,CAAC,cAAc,EAAE,GAAG,EAAE;QACtB,MAAM,CAAC,kBAAkB,CAAC,MAAM,EAAE,eAAe,EAAE,OAAO,EAAE,0BAA0B,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IACvG,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,+CAA+C,EAAE,GAAG,EAAE;QACvD,MAAM,CAAC,GAAG,kBAAkB,CAAC,MAAM,EAAE,eAAe,EAAE,OAAO,EAAE,0BAA0B,CAAC,CAAC;QAC3F,MAAM,CAAC,GAAG,kBAAkB,CAAC,MAAM,EAAE,eAAe,EAAE,OAAO,EAAE,0BAA0B,CAAC,CAAC;QAC3F,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACxB,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,uCAAuC,EAAE,GAAG,EAAE;QAC/C,MAAM,CAAC,kBAAkB,CAAC,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,0BAA0B,CAAC,CAAC,CAAC,IAAI,CAC/E,kBAAkB,CAAC,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,0BAA0B,CAAC,CACrE,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,kEAAkE,EAAE,GAAG,EAAE;QAC1E,MAAM,CAAC,GAAG,kBAAkB,CAAC,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,0BAA0B,CAAC,CAAC;QAC/E,MAAM,CAAC,GAAG,kBAAkB,CAAC,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,0BAA0B,CAAC,CAAC;QAC/E,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACxB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,11 +0,0 @@
1
- /** Task 1526 — the per-firing scheduled seat id. A recurring agent-bearing
2
- * :Event that resumed the deterministic adminSessionIdFor(effectiveAccount,
3
- * destination) seat accreted every firing into one compaction-lossy session.
4
- * This id salts the seat with the firing's own eventId + dispatchedAt, so each
5
- * firing is a session id the manager has never seen and spawns FRESH (the
6
- * manager's resume-vs-fresh decision keys purely on JSONL existence). Same v4
7
- * shaping as adminSessionIdFor so it satisfies `claude --session-id`, but a
8
- * distinct hash domain (`:scheduled:`) so it can never collide with a real
9
- * inbound seat for the same sender. Pure — reproducible and testable. */
10
- export declare function scheduledSeatIdFor(accountId: string, destination: string, eventId: string, dispatchedAt: string): string;
11
- //# sourceMappingURL=scheduled-seat-id.d.ts.map