@proompteng/temporal-bun-sdk 0.1.0

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 (448) hide show
  1. package/README.md +387 -0
  2. package/dist/bin/start-worker.js +3 -0
  3. package/dist/bin/temporal-bun.js +3 -0
  4. package/dist/src/activities/index.d.ts +6 -0
  5. package/dist/src/activities/index.d.ts.map +1 -0
  6. package/dist/src/activities/index.js +5 -0
  7. package/dist/src/activities/index.js.map +1 -0
  8. package/dist/src/activities/lifecycle.d.ts +48 -0
  9. package/dist/src/activities/lifecycle.d.ts.map +1 -0
  10. package/dist/src/activities/lifecycle.js +306 -0
  11. package/dist/src/activities/lifecycle.js.map +1 -0
  12. package/dist/src/bin/replay-command.d.ts +104 -0
  13. package/dist/src/bin/replay-command.d.ts.map +1 -0
  14. package/dist/src/bin/replay-command.js +582 -0
  15. package/dist/src/bin/replay-command.js.map +1 -0
  16. package/dist/src/bin/start-worker.d.ts +3 -0
  17. package/dist/src/bin/start-worker.d.ts.map +1 -0
  18. package/dist/src/bin/start-worker.js +29 -0
  19. package/dist/src/bin/start-worker.js.map +1 -0
  20. package/dist/src/bin/temporal-bun.d.ts +25 -0
  21. package/dist/src/bin/temporal-bun.d.ts.map +1 -0
  22. package/dist/src/bin/temporal-bun.js +427 -0
  23. package/dist/src/bin/temporal-bun.js.map +1 -0
  24. package/dist/src/build_id_preflight.d.ts +7 -0
  25. package/dist/src/build_id_preflight.d.ts.map +1 -0
  26. package/dist/src/build_id_preflight.js +123 -0
  27. package/dist/src/build_id_preflight.js.map +1 -0
  28. package/dist/src/client/headers.d.ts +4 -0
  29. package/dist/src/client/headers.d.ts.map +1 -0
  30. package/dist/src/client/headers.js +79 -0
  31. package/dist/src/client/headers.js.map +1 -0
  32. package/dist/src/client/index.d.ts +2 -0
  33. package/dist/src/client/index.d.ts.map +1 -0
  34. package/dist/src/client/index.js +2 -0
  35. package/dist/src/client/index.js.map +1 -0
  36. package/dist/src/client/interceptors.d.ts +17 -0
  37. package/dist/src/client/interceptors.d.ts.map +1 -0
  38. package/dist/src/client/interceptors.js +71 -0
  39. package/dist/src/client/interceptors.js.map +1 -0
  40. package/dist/src/client/layer.d.ts +10 -0
  41. package/dist/src/client/layer.d.ts.map +1 -0
  42. package/dist/src/client/layer.js +7 -0
  43. package/dist/src/client/layer.js.map +1 -0
  44. package/dist/src/client/retries.d.ts +13 -0
  45. package/dist/src/client/retries.d.ts.map +1 -0
  46. package/dist/src/client/retries.js +51 -0
  47. package/dist/src/client/retries.js.map +1 -0
  48. package/dist/src/client/serialization.d.ts +48 -0
  49. package/dist/src/client/serialization.d.ts.map +1 -0
  50. package/dist/src/client/serialization.js +310 -0
  51. package/dist/src/client/serialization.js.map +1 -0
  52. package/dist/src/client/serialization.test.d.ts +2 -0
  53. package/dist/src/client/serialization.test.d.ts.map +1 -0
  54. package/dist/src/client/serialization.test.js +251 -0
  55. package/dist/src/client/serialization.test.js.map +1 -0
  56. package/dist/src/client/transport.d.ts +12 -0
  57. package/dist/src/client/transport.d.ts.map +1 -0
  58. package/dist/src/client/transport.js +36 -0
  59. package/dist/src/client/transport.js.map +1 -0
  60. package/dist/src/client/types.d.ts +51 -0
  61. package/dist/src/client/types.d.ts.map +1 -0
  62. package/dist/src/client/types.js +7 -0
  63. package/dist/src/client/types.js.map +1 -0
  64. package/dist/src/client.d.ts +92 -0
  65. package/dist/src/client.d.ts.map +1 -0
  66. package/dist/src/client.js +666 -0
  67. package/dist/src/client.js.map +1 -0
  68. package/dist/src/common/duration.d.ts +4 -0
  69. package/dist/src/common/duration.d.ts.map +1 -0
  70. package/dist/src/common/duration.js +14 -0
  71. package/dist/src/common/duration.js.map +1 -0
  72. package/dist/src/common/index.d.ts +2 -0
  73. package/dist/src/common/index.d.ts.map +1 -0
  74. package/dist/src/common/index.js +2 -0
  75. package/dist/src/common/index.js.map +1 -0
  76. package/dist/src/common/payloads/converter.d.ts +16 -0
  77. package/dist/src/common/payloads/converter.d.ts.map +1 -0
  78. package/dist/src/common/payloads/converter.js +33 -0
  79. package/dist/src/common/payloads/converter.js.map +1 -0
  80. package/dist/src/common/payloads/failure.d.ts +7 -0
  81. package/dist/src/common/payloads/failure.d.ts.map +1 -0
  82. package/dist/src/common/payloads/failure.js +53 -0
  83. package/dist/src/common/payloads/failure.js.map +1 -0
  84. package/dist/src/common/payloads/index.d.ts +4 -0
  85. package/dist/src/common/payloads/index.d.ts.map +1 -0
  86. package/dist/src/common/payloads/index.js +4 -0
  87. package/dist/src/common/payloads/index.js.map +1 -0
  88. package/dist/src/common/payloads/json-codec.d.ts +16 -0
  89. package/dist/src/common/payloads/json-codec.d.ts.map +1 -0
  90. package/dist/src/common/payloads/json-codec.js +185 -0
  91. package/dist/src/common/payloads/json-codec.js.map +1 -0
  92. package/dist/src/common/sleep.d.ts +2 -0
  93. package/dist/src/common/sleep.d.ts.map +1 -0
  94. package/dist/src/common/sleep.js +3 -0
  95. package/dist/src/common/sleep.js.map +1 -0
  96. package/dist/src/config.d.ts +115 -0
  97. package/dist/src/config.d.ts.map +1 -0
  98. package/dist/src/config.js +505 -0
  99. package/dist/src/config.js.map +1 -0
  100. package/dist/src/core-bridge/client.d.ts +36 -0
  101. package/dist/src/core-bridge/client.d.ts.map +1 -0
  102. package/dist/src/core-bridge/client.js +111 -0
  103. package/dist/src/core-bridge/client.js.map +1 -0
  104. package/dist/src/core-bridge/index.d.ts +4 -0
  105. package/dist/src/core-bridge/index.d.ts.map +1 -0
  106. package/dist/src/core-bridge/index.js +4 -0
  107. package/dist/src/core-bridge/index.js.map +1 -0
  108. package/dist/src/core-bridge/runtime.d.ts +20 -0
  109. package/dist/src/core-bridge/runtime.d.ts.map +1 -0
  110. package/dist/src/core-bridge/runtime.js +62 -0
  111. package/dist/src/core-bridge/runtime.js.map +1 -0
  112. package/dist/src/core-bridge/runtime.test.d.ts +2 -0
  113. package/dist/src/core-bridge/runtime.test.d.ts.map +1 -0
  114. package/dist/src/core-bridge/runtime.test.js +68 -0
  115. package/dist/src/core-bridge/runtime.test.js.map +1 -0
  116. package/dist/src/index.d.ts +11 -0
  117. package/dist/src/index.d.ts.map +1 -0
  118. package/dist/src/index.js +7 -0
  119. package/dist/src/index.js.map +1 -0
  120. package/dist/src/internal/core-bridge/native.d.ts +176 -0
  121. package/dist/src/internal/core-bridge/native.d.ts.map +1 -0
  122. package/dist/src/internal/core-bridge/native.js +1208 -0
  123. package/dist/src/internal/core-bridge/native.js.map +1 -0
  124. package/dist/src/observability/index.d.ts +21 -0
  125. package/dist/src/observability/index.d.ts.map +1 -0
  126. package/dist/src/observability/index.js +19 -0
  127. package/dist/src/observability/index.js.map +1 -0
  128. package/dist/src/observability/logger.d.ts +28 -0
  129. package/dist/src/observability/logger.d.ts.map +1 -0
  130. package/dist/src/observability/logger.js +53 -0
  131. package/dist/src/observability/logger.js.map +1 -0
  132. package/dist/src/observability/metrics.d.ts +28 -0
  133. package/dist/src/observability/metrics.d.ts.map +1 -0
  134. package/dist/src/observability/metrics.js +355 -0
  135. package/dist/src/observability/metrics.js.map +1 -0
  136. package/dist/src/proto/google/api/annotations_pb.d.ts +14 -0
  137. package/dist/src/proto/google/api/annotations_pb.d.ts.map +1 -0
  138. package/dist/src/proto/google/api/annotations_pb.js +27 -0
  139. package/dist/src/proto/google/api/annotations_pb.js.map +1 -0
  140. package/dist/src/proto/google/api/http_pb.d.ts +441 -0
  141. package/dist/src/proto/google/api/http_pb.d.ts.map +1 -0
  142. package/dist/src/proto/google/api/http_pb.js +34 -0
  143. package/dist/src/proto/google/api/http_pb.js.map +1 -0
  144. package/dist/src/proto/temporal/api/activity/v1/message_pb.d.ts +67 -0
  145. package/dist/src/proto/temporal/api/activity/v1/message_pb.d.ts.map +1 -0
  146. package/dist/src/proto/temporal/api/activity/v1/message_pb.js +17 -0
  147. package/dist/src/proto/temporal/api/activity/v1/message_pb.js.map +1 -0
  148. package/dist/src/proto/temporal/api/batch/v1/message_pb.d.ts +464 -0
  149. package/dist/src/proto/temporal/api/batch/v1/message_pb.d.ts.map +1 -0
  150. package/dist/src/proto/temporal/api/batch/v1/message_pb.js +71 -0
  151. package/dist/src/proto/temporal/api/batch/v1/message_pb.js.map +1 -0
  152. package/dist/src/proto/temporal/api/command/v1/message_pb.d.ts +796 -0
  153. package/dist/src/proto/temporal/api/command/v1/message_pb.d.ts.map +1 -0
  154. package/dist/src/proto/temporal/api/command/v1/message_pb.js +106 -0
  155. package/dist/src/proto/temporal/api/command/v1/message_pb.js.map +1 -0
  156. package/dist/src/proto/temporal/api/common/v1/message_pb.d.ts +751 -0
  157. package/dist/src/proto/temporal/api/common/v1/message_pb.d.ts.map +1 -0
  158. package/dist/src/proto/temporal/api/common/v1/message_pb.js +133 -0
  159. package/dist/src/proto/temporal/api/common/v1/message_pb.js.map +1 -0
  160. package/dist/src/proto/temporal/api/deployment/v1/message_pb.d.ts +639 -0
  161. package/dist/src/proto/temporal/api/deployment/v1/message_pb.d.ts.map +1 -0
  162. package/dist/src/proto/temporal/api/deployment/v1/message_pb.js +83 -0
  163. package/dist/src/proto/temporal/api/deployment/v1/message_pb.js.map +1 -0
  164. package/dist/src/proto/temporal/api/enums/v1/batch_operation_pb.d.ts +80 -0
  165. package/dist/src/proto/temporal/api/enums/v1/batch_operation_pb.d.ts.map +1 -0
  166. package/dist/src/proto/temporal/api/enums/v1/batch_operation_pb.js +85 -0
  167. package/dist/src/proto/temporal/api/enums/v1/batch_operation_pb.js.map +1 -0
  168. package/dist/src/proto/temporal/api/enums/v1/command_type_pb.d.ts +89 -0
  169. package/dist/src/proto/temporal/api/enums/v1/command_type_pb.d.ts.map +1 -0
  170. package/dist/src/proto/temporal/api/enums/v1/command_type_pb.js +93 -0
  171. package/dist/src/proto/temporal/api/enums/v1/command_type_pb.js.map +1 -0
  172. package/dist/src/proto/temporal/api/enums/v1/common_pb.d.ts +314 -0
  173. package/dist/src/proto/temporal/api/enums/v1/common_pb.d.ts.map +1 -0
  174. package/dist/src/proto/temporal/api/enums/v1/common_pb.js +326 -0
  175. package/dist/src/proto/temporal/api/enums/v1/common_pb.js.map +1 -0
  176. package/dist/src/proto/temporal/api/enums/v1/deployment_pb.d.ts +186 -0
  177. package/dist/src/proto/temporal/api/enums/v1/deployment_pb.d.ts.map +1 -0
  178. package/dist/src/proto/temporal/api/enums/v1/deployment_pb.js +193 -0
  179. package/dist/src/proto/temporal/api/enums/v1/deployment_pb.js.map +1 -0
  180. package/dist/src/proto/temporal/api/enums/v1/event_type_pb.d.ts +407 -0
  181. package/dist/src/proto/temporal/api/enums/v1/event_type_pb.d.ts.map +1 -0
  182. package/dist/src/proto/temporal/api/enums/v1/event_type_pb.js +411 -0
  183. package/dist/src/proto/temporal/api/enums/v1/event_type_pb.js.map +1 -0
  184. package/dist/src/proto/temporal/api/enums/v1/failed_cause_pb.d.ts +371 -0
  185. package/dist/src/proto/temporal/api/enums/v1/failed_cause_pb.d.ts.map +1 -0
  186. package/dist/src/proto/temporal/api/enums/v1/failed_cause_pb.js +380 -0
  187. package/dist/src/proto/temporal/api/enums/v1/failed_cause_pb.js.map +1 -0
  188. package/dist/src/proto/temporal/api/enums/v1/namespace_pb.d.ts +73 -0
  189. package/dist/src/proto/temporal/api/enums/v1/namespace_pb.d.ts.map +1 -0
  190. package/dist/src/proto/temporal/api/enums/v1/namespace_pb.js +79 -0
  191. package/dist/src/proto/temporal/api/enums/v1/namespace_pb.js.map +1 -0
  192. package/dist/src/proto/temporal/api/enums/v1/nexus_pb.d.ts +35 -0
  193. package/dist/src/proto/temporal/api/enums/v1/nexus_pb.d.ts.map +1 -0
  194. package/dist/src/proto/temporal/api/enums/v1/nexus_pb.js +39 -0
  195. package/dist/src/proto/temporal/api/enums/v1/nexus_pb.js.map +1 -0
  196. package/dist/src/proto/temporal/api/enums/v1/query_pb.d.ts +58 -0
  197. package/dist/src/proto/temporal/api/enums/v1/query_pb.d.ts.map +1 -0
  198. package/dist/src/proto/temporal/api/enums/v1/query_pb.js +63 -0
  199. package/dist/src/proto/temporal/api/enums/v1/query_pb.js.map +1 -0
  200. package/dist/src/proto/temporal/api/enums/v1/reset_pb.d.ts +108 -0
  201. package/dist/src/proto/temporal/api/enums/v1/reset_pb.d.ts.map +1 -0
  202. package/dist/src/proto/temporal/api/enums/v1/reset_pb.js +114 -0
  203. package/dist/src/proto/temporal/api/enums/v1/reset_pb.js.map +1 -0
  204. package/dist/src/proto/temporal/api/enums/v1/schedule_pb.d.ts +67 -0
  205. package/dist/src/proto/temporal/api/enums/v1/schedule_pb.d.ts.map +1 -0
  206. package/dist/src/proto/temporal/api/enums/v1/schedule_pb.js +71 -0
  207. package/dist/src/proto/temporal/api/enums/v1/schedule_pb.js.map +1 -0
  208. package/dist/src/proto/temporal/api/enums/v1/task_queue_pb.d.ts +249 -0
  209. package/dist/src/proto/temporal/api/enums/v1/task_queue_pb.d.ts.map +1 -0
  210. package/dist/src/proto/temporal/api/enums/v1/task_queue_pb.js +259 -0
  211. package/dist/src/proto/temporal/api/enums/v1/task_queue_pb.js.map +1 -0
  212. package/dist/src/proto/temporal/api/enums/v1/update_pb.d.ts +78 -0
  213. package/dist/src/proto/temporal/api/enums/v1/update_pb.d.ts.map +1 -0
  214. package/dist/src/proto/temporal/api/enums/v1/update_pb.js +83 -0
  215. package/dist/src/proto/temporal/api/enums/v1/update_pb.js.map +1 -0
  216. package/dist/src/proto/temporal/api/enums/v1/workflow_pb.d.ts +408 -0
  217. package/dist/src/proto/temporal/api/enums/v1/workflow_pb.d.ts.map +1 -0
  218. package/dist/src/proto/temporal/api/enums/v1/workflow_pb.js +422 -0
  219. package/dist/src/proto/temporal/api/enums/v1/workflow_pb.js.map +1 -0
  220. package/dist/src/proto/temporal/api/errordetails/v1/message_pb.d.ts +331 -0
  221. package/dist/src/proto/temporal/api/errordetails/v1/message_pb.d.ts.map +1 -0
  222. package/dist/src/proto/temporal/api/errordetails/v1/message_pb.js +104 -0
  223. package/dist/src/proto/temporal/api/errordetails/v1/message_pb.js.map +1 -0
  224. package/dist/src/proto/temporal/api/export/v1/message_pb.d.ts +39 -0
  225. package/dist/src/proto/temporal/api/export/v1/message_pb.d.ts.map +1 -0
  226. package/dist/src/proto/temporal/api/export/v1/message_pb.js +20 -0
  227. package/dist/src/proto/temporal/api/export/v1/message_pb.js.map +1 -0
  228. package/dist/src/proto/temporal/api/failure/v1/message_pb.d.ts +381 -0
  229. package/dist/src/proto/temporal/api/failure/v1/message_pb.d.ts.map +1 -0
  230. package/dist/src/proto/temporal/api/failure/v1/message_pb.js +74 -0
  231. package/dist/src/proto/temporal/api/failure/v1/message_pb.js.map +1 -0
  232. package/dist/src/proto/temporal/api/filter/v1/message_pb.d.ts +73 -0
  233. package/dist/src/proto/temporal/api/filter/v1/message_pb.d.ts.map +1 -0
  234. package/dist/src/proto/temporal/api/filter/v1/message_pb.js +31 -0
  235. package/dist/src/proto/temporal/api/filter/v1/message_pb.js.map +1 -0
  236. package/dist/src/proto/temporal/api/history/v1/message_pb.d.ts +3136 -0
  237. package/dist/src/proto/temporal/api/history/v1/message_pb.d.ts.map +1 -0
  238. package/dist/src/proto/temporal/api/history/v1/message_pb.js +317 -0
  239. package/dist/src/proto/temporal/api/history/v1/message_pb.js.map +1 -0
  240. package/dist/src/proto/temporal/api/namespace/v1/message_pb.d.ts +242 -0
  241. package/dist/src/proto/temporal/api/namespace/v1/message_pb.d.ts.map +1 -0
  242. package/dist/src/proto/temporal/api/namespace/v1/message_pb.js +46 -0
  243. package/dist/src/proto/temporal/api/namespace/v1/message_pb.js.map +1 -0
  244. package/dist/src/proto/temporal/api/nexus/v1/message_pb.d.ts +549 -0
  245. package/dist/src/proto/temporal/api/nexus/v1/message_pb.d.ts.map +1 -0
  246. package/dist/src/proto/temporal/api/nexus/v1/message_pb.js +97 -0
  247. package/dist/src/proto/temporal/api/nexus/v1/message_pb.js.map +1 -0
  248. package/dist/src/proto/temporal/api/operatorservice/v1/request_response_pb.d.ts +499 -0
  249. package/dist/src/proto/temporal/api/operatorservice/v1/request_response_pb.d.ts.map +1 -0
  250. package/dist/src/proto/temporal/api/operatorservice/v1/request_response_pb.js +137 -0
  251. package/dist/src/proto/temporal/api/operatorservice/v1/request_response_pb.js.map +1 -0
  252. package/dist/src/proto/temporal/api/operatorservice/v1/service_pb.d.ts +153 -0
  253. package/dist/src/proto/temporal/api/operatorservice/v1/service_pb.d.ts.map +1 -0
  254. package/dist/src/proto/temporal/api/operatorservice/v1/service_pb.js +22 -0
  255. package/dist/src/proto/temporal/api/operatorservice/v1/service_pb.js.map +1 -0
  256. package/dist/src/proto/temporal/api/protocol/v1/message_pb.d.ts +64 -0
  257. package/dist/src/proto/temporal/api/protocol/v1/message_pb.d.ts.map +1 -0
  258. package/dist/src/proto/temporal/api/protocol/v1/message_pb.js +15 -0
  259. package/dist/src/proto/temporal/api/protocol/v1/message_pb.js.map +1 -0
  260. package/dist/src/proto/temporal/api/query/v1/message_pb.d.ts +96 -0
  261. package/dist/src/proto/temporal/api/query/v1/message_pb.d.ts.map +1 -0
  262. package/dist/src/proto/temporal/api/query/v1/message_pb.js +28 -0
  263. package/dist/src/proto/temporal/api/query/v1/message_pb.js.map +1 -0
  264. package/dist/src/proto/temporal/api/replication/v1/message_pb.d.ts +67 -0
  265. package/dist/src/proto/temporal/api/replication/v1/message_pb.d.ts.map +1 -0
  266. package/dist/src/proto/temporal/api/replication/v1/message_pb.js +26 -0
  267. package/dist/src/proto/temporal/api/replication/v1/message_pb.js.map +1 -0
  268. package/dist/src/proto/temporal/api/rules/v1/message_pb.d.ts +172 -0
  269. package/dist/src/proto/temporal/api/rules/v1/message_pb.d.ts.map +1 -0
  270. package/dist/src/proto/temporal/api/rules/v1/message_pb.js +35 -0
  271. package/dist/src/proto/temporal/api/rules/v1/message_pb.js.map +1 -0
  272. package/dist/src/proto/temporal/api/schedule/v1/message_pb.d.ts +779 -0
  273. package/dist/src/proto/temporal/api/schedule/v1/message_pb.d.ts.map +1 -0
  274. package/dist/src/proto/temporal/api/schedule/v1/message_pb.js +95 -0
  275. package/dist/src/proto/temporal/api/schedule/v1/message_pb.js.map +1 -0
  276. package/dist/src/proto/temporal/api/sdk/v1/enhanced_stack_trace_pb.d.ts +157 -0
  277. package/dist/src/proto/temporal/api/sdk/v1/enhanced_stack_trace_pb.d.ts.map +1 -0
  278. package/dist/src/proto/temporal/api/sdk/v1/enhanced_stack_trace_pb.js +34 -0
  279. package/dist/src/proto/temporal/api/sdk/v1/enhanced_stack_trace_pb.js.map +1 -0
  280. package/dist/src/proto/temporal/api/sdk/v1/task_complete_metadata_pb.d.ts +71 -0
  281. package/dist/src/proto/temporal/api/sdk/v1/task_complete_metadata_pb.d.ts.map +1 -0
  282. package/dist/src/proto/temporal/api/sdk/v1/task_complete_metadata_pb.js +14 -0
  283. package/dist/src/proto/temporal/api/sdk/v1/task_complete_metadata_pb.js.map +1 -0
  284. package/dist/src/proto/temporal/api/sdk/v1/user_metadata_pb.d.ts +37 -0
  285. package/dist/src/proto/temporal/api/sdk/v1/user_metadata_pb.d.ts.map +1 -0
  286. package/dist/src/proto/temporal/api/sdk/v1/user_metadata_pb.js +15 -0
  287. package/dist/src/proto/temporal/api/sdk/v1/user_metadata_pb.js.map +1 -0
  288. package/dist/src/proto/temporal/api/sdk/v1/worker_config_pb.d.ts +84 -0
  289. package/dist/src/proto/temporal/api/sdk/v1/worker_config_pb.d.ts.map +1 -0
  290. package/dist/src/proto/temporal/api/sdk/v1/worker_config_pb.js +24 -0
  291. package/dist/src/proto/temporal/api/sdk/v1/worker_config_pb.js.map +1 -0
  292. package/dist/src/proto/temporal/api/sdk/v1/workflow_metadata_pb.d.ts +99 -0
  293. package/dist/src/proto/temporal/api/sdk/v1/workflow_metadata_pb.d.ts.map +1 -0
  294. package/dist/src/proto/temporal/api/sdk/v1/workflow_metadata_pb.js +24 -0
  295. package/dist/src/proto/temporal/api/sdk/v1/workflow_metadata_pb.js.map +1 -0
  296. package/dist/src/proto/temporal/api/taskqueue/v1/message_pb.d.ts +757 -0
  297. package/dist/src/proto/temporal/api/taskqueue/v1/message_pb.d.ts.map +1 -0
  298. package/dist/src/proto/temporal/api/taskqueue/v1/message_pb.js +138 -0
  299. package/dist/src/proto/temporal/api/taskqueue/v1/message_pb.js.map +1 -0
  300. package/dist/src/proto/temporal/api/update/v1/message_pb.d.ts +230 -0
  301. package/dist/src/proto/temporal/api/update/v1/message_pb.d.ts.map +1 -0
  302. package/dist/src/proto/temporal/api/update/v1/message_pb.js +57 -0
  303. package/dist/src/proto/temporal/api/update/v1/message_pb.js.map +1 -0
  304. package/dist/src/proto/temporal/api/version/v1/message_pb.d.ts +85 -0
  305. package/dist/src/proto/temporal/api/version/v1/message_pb.d.ts.map +1 -0
  306. package/dist/src/proto/temporal/api/version/v1/message_pb.js +26 -0
  307. package/dist/src/proto/temporal/api/version/v1/message_pb.js.map +1 -0
  308. package/dist/src/proto/temporal/api/worker/v1/message_pb.d.ts +311 -0
  309. package/dist/src/proto/temporal/api/worker/v1/message_pb.d.ts.map +1 -0
  310. package/dist/src/proto/temporal/api/worker/v1/message_pb.js +42 -0
  311. package/dist/src/proto/temporal/api/worker/v1/message_pb.js.map +1 -0
  312. package/dist/src/proto/temporal/api/workflow/v1/message_pb.d.ts +1500 -0
  313. package/dist/src/proto/temporal/api/workflow/v1/message_pb.d.ts.map +1 -0
  314. package/dist/src/proto/temporal/api/workflow/v1/message_pb.js +183 -0
  315. package/dist/src/proto/temporal/api/workflow/v1/message_pb.js.map +1 -0
  316. package/dist/src/proto/temporal/api/workflowservice/v1/request_response_pb.d.ts +6967 -0
  317. package/dist/src/proto/temporal/api/workflowservice/v1/request_response_pb.d.ts.map +1 -0
  318. package/dist/src/proto/temporal/api/workflowservice/v1/request_response_pb.js +1073 -0
  319. package/dist/src/proto/temporal/api/workflowservice/v1/request_response_pb.js.map +1 -0
  320. package/dist/src/proto/temporal/api/workflowservice/v1/service_pb.d.ts +1305 -0
  321. package/dist/src/proto/temporal/api/workflowservice/v1/service_pb.d.ts.map +1 -0
  322. package/dist/src/proto/temporal/api/workflowservice/v1/service_pb.js +27 -0
  323. package/dist/src/proto/temporal/api/workflowservice/v1/service_pb.js.map +1 -0
  324. package/dist/src/runtime/cli-layer.d.ts +12 -0
  325. package/dist/src/runtime/cli-layer.d.ts.map +1 -0
  326. package/dist/src/runtime/cli-layer.js +19 -0
  327. package/dist/src/runtime/cli-layer.js.map +1 -0
  328. package/dist/src/runtime/config-layer.d.ts +9 -0
  329. package/dist/src/runtime/config-layer.d.ts.map +1 -0
  330. package/dist/src/runtime/config-layer.js +15 -0
  331. package/dist/src/runtime/config-layer.js.map +1 -0
  332. package/dist/src/runtime/effect-layers.d.ts +518 -0
  333. package/dist/src/runtime/effect-layers.d.ts.map +1 -0
  334. package/dist/src/runtime/effect-layers.js +68 -0
  335. package/dist/src/runtime/effect-layers.js.map +1 -0
  336. package/dist/src/runtime/worker-app.d.ts +14 -0
  337. package/dist/src/runtime/worker-app.d.ts.map +1 -0
  338. package/dist/src/runtime/worker-app.js +58 -0
  339. package/dist/src/runtime/worker-app.js.map +1 -0
  340. package/dist/src/telemetry/runtime.d.ts +5 -0
  341. package/dist/src/telemetry/runtime.d.ts.map +1 -0
  342. package/dist/src/telemetry/runtime.js +94 -0
  343. package/dist/src/telemetry/runtime.js.map +1 -0
  344. package/dist/src/worker/activity-context.d.ts +30 -0
  345. package/dist/src/worker/activity-context.d.ts.map +1 -0
  346. package/dist/src/worker/activity-context.js +9 -0
  347. package/dist/src/worker/activity-context.js.map +1 -0
  348. package/dist/src/worker/build-id.d.ts +20 -0
  349. package/dist/src/worker/build-id.d.ts.map +1 -0
  350. package/dist/src/worker/build-id.js +98 -0
  351. package/dist/src/worker/build-id.js.map +1 -0
  352. package/dist/src/worker/concurrency.d.ts +31 -0
  353. package/dist/src/worker/concurrency.d.ts.map +1 -0
  354. package/dist/src/worker/concurrency.js +129 -0
  355. package/dist/src/worker/concurrency.js.map +1 -0
  356. package/dist/src/worker/defaults.d.ts +9 -0
  357. package/dist/src/worker/defaults.d.ts.map +1 -0
  358. package/dist/src/worker/defaults.js +53 -0
  359. package/dist/src/worker/defaults.js.map +1 -0
  360. package/dist/src/worker/index.d.ts +7 -0
  361. package/dist/src/worker/index.d.ts.map +1 -0
  362. package/dist/src/worker/index.js +4 -0
  363. package/dist/src/worker/index.js.map +1 -0
  364. package/dist/src/worker/layer.d.ts +19 -0
  365. package/dist/src/worker/layer.d.ts.map +1 -0
  366. package/dist/src/worker/layer.js +71 -0
  367. package/dist/src/worker/layer.js.map +1 -0
  368. package/dist/src/worker/runtime.d.ts +59 -0
  369. package/dist/src/worker/runtime.d.ts.map +1 -0
  370. package/dist/src/worker/runtime.js +1415 -0
  371. package/dist/src/worker/runtime.js.map +1 -0
  372. package/dist/src/worker/service.d.ts +19 -0
  373. package/dist/src/worker/service.d.ts.map +1 -0
  374. package/dist/src/worker/service.js +14 -0
  375. package/dist/src/worker/service.js.map +1 -0
  376. package/dist/src/worker/sticky-cache.d.ts +41 -0
  377. package/dist/src/worker/sticky-cache.d.ts.map +1 -0
  378. package/dist/src/worker/sticky-cache.js +127 -0
  379. package/dist/src/worker/sticky-cache.js.map +1 -0
  380. package/dist/src/worker.d.ts +30 -0
  381. package/dist/src/worker.d.ts.map +1 -0
  382. package/dist/src/worker.js +82 -0
  383. package/dist/src/worker.js.map +1 -0
  384. package/dist/src/workflow/commands.d.ts +84 -0
  385. package/dist/src/workflow/commands.d.ts.map +1 -0
  386. package/dist/src/workflow/commands.js +159 -0
  387. package/dist/src/workflow/commands.js.map +1 -0
  388. package/dist/src/workflow/context.d.ts +119 -0
  389. package/dist/src/workflow/context.d.ts.map +1 -0
  390. package/dist/src/workflow/context.js +197 -0
  391. package/dist/src/workflow/context.js.map +1 -0
  392. package/dist/src/workflow/definition.d.ts +15 -0
  393. package/dist/src/workflow/definition.d.ts.map +1 -0
  394. package/dist/src/workflow/definition.js +19 -0
  395. package/dist/src/workflow/definition.js.map +1 -0
  396. package/dist/src/workflow/determinism.d.ts +54 -0
  397. package/dist/src/workflow/determinism.d.ts.map +1 -0
  398. package/dist/src/workflow/determinism.js +147 -0
  399. package/dist/src/workflow/determinism.js.map +1 -0
  400. package/dist/src/workflow/errors.d.ts +37 -0
  401. package/dist/src/workflow/errors.d.ts.map +1 -0
  402. package/dist/src/workflow/errors.js +35 -0
  403. package/dist/src/workflow/errors.js.map +1 -0
  404. package/dist/src/workflow/executor.d.ts +35 -0
  405. package/dist/src/workflow/executor.d.ts.map +1 -0
  406. package/dist/src/workflow/executor.js +178 -0
  407. package/dist/src/workflow/executor.js.map +1 -0
  408. package/dist/src/workflow/index.d.ts +8 -0
  409. package/dist/src/workflow/index.d.ts.map +1 -0
  410. package/dist/src/workflow/index.js +8 -0
  411. package/dist/src/workflow/index.js.map +1 -0
  412. package/dist/src/workflow/registry.d.ts +9 -0
  413. package/dist/src/workflow/registry.d.ts.map +1 -0
  414. package/dist/src/workflow/registry.js +51 -0
  415. package/dist/src/workflow/registry.js.map +1 -0
  416. package/dist/src/workflow/replay.d.ts +87 -0
  417. package/dist/src/workflow/replay.d.ts.map +1 -0
  418. package/dist/src/workflow/replay.js +759 -0
  419. package/dist/src/workflow/replay.js.map +1 -0
  420. package/dist/src/workflow/runtime/bootstrap.d.ts +15 -0
  421. package/dist/src/workflow/runtime/bootstrap.d.ts.map +1 -0
  422. package/dist/src/workflow/runtime/bootstrap.js +124 -0
  423. package/dist/src/workflow/runtime/bootstrap.js.map +1 -0
  424. package/dist/src/workflow/runtime/engine.d.ts +21 -0
  425. package/dist/src/workflow/runtime/engine.d.ts.map +1 -0
  426. package/dist/src/workflow/runtime/engine.js +73 -0
  427. package/dist/src/workflow/runtime/engine.js.map +1 -0
  428. package/dist/src/workflow/runtime/environment.d.ts +29 -0
  429. package/dist/src/workflow/runtime/environment.d.ts.map +1 -0
  430. package/dist/src/workflow/runtime/environment.js +298 -0
  431. package/dist/src/workflow/runtime/environment.js.map +1 -0
  432. package/dist/src/workflow/runtime/index.d.ts +7 -0
  433. package/dist/src/workflow/runtime/index.d.ts.map +1 -0
  434. package/dist/src/workflow/runtime/index.js +4 -0
  435. package/dist/src/workflow/runtime/index.js.map +1 -0
  436. package/dist/src/workflow/runtime/info.d.ts +5 -0
  437. package/dist/src/workflow/runtime/info.d.ts.map +1 -0
  438. package/dist/src/workflow/runtime/info.js +22 -0
  439. package/dist/src/workflow/runtime/info.js.map +1 -0
  440. package/dist/src/workflow/runtime/replay.d.ts +26 -0
  441. package/dist/src/workflow/runtime/replay.d.ts.map +1 -0
  442. package/dist/src/workflow/runtime/replay.js +254 -0
  443. package/dist/src/workflow/runtime/replay.js.map +1 -0
  444. package/dist/src/workflows/index.d.ts +3 -0
  445. package/dist/src/workflows/index.d.ts.map +1 -0
  446. package/dist/src/workflows/index.js +15 -0
  447. package/dist/src/workflows/index.js.map +1 -0
  448. package/package.json +74 -0
package/README.md ADDED
@@ -0,0 +1,387 @@
1
+ # `@proompteng/temporal-bun-sdk`
2
+
3
+ A Bun-first Temporal SDK implemented entirely in TypeScript. It speaks gRPC over HTTP/2 using [Connect](https://connectrpc.com/) and executes workflows with the [Effect](https://effect.website/) runtime so you can run Temporal workers without shipping Node.js or any native bridge.
4
+
5
+ ## Highlights
6
+ - **TypeScript-only runtime** – workflow polling, activity execution, and command generation run in Bun using generated Temporal protobuf stubs.
7
+ - **Effect-based workflows** – define deterministic workflows with `Effect` and let the runtime translate results/failures into Temporal commands.
8
+ - **Connect-powered client** – `createTemporalClient` gives you a fully typed Temporal WorkflowService client backed by @bufbuild/protobuf.
9
+ - **Simple data conversion** – JSON payload conversion out of the box with hooks for custom codecs.
10
+ - **Bun CLI** – `temporal-bun` scaffolds workers and ships lightweight Docker helpers (no Zig build steps required).
11
+
12
+ ## Prerequisites
13
+ - **Bun ≥ 1.1.20** – required for the runtime and CLI.
14
+ - **Temporal CLI ≥ 1.4** – optional, but useful for spinning up a local dev server.
15
+
16
+ ## Quickstart
17
+ 1. **Install dependencies**
18
+ ```bash
19
+ bun install
20
+ ```
21
+
22
+ 2. **Configure Temporal access**
23
+ Create an `.env` (or export variables in your shell) with the connection details. `loadTemporalConfig` reads these at runtime:
24
+ ```env
25
+ TEMPORAL_ADDRESS=temporal.example.com:7233
26
+ TEMPORAL_NAMESPACE=default
27
+ TEMPORAL_API_KEY=temporal-cloud-api-key-123 # optional
28
+ TEMPORAL_TLS_CA_PATH=certs/cloud-ca.pem # optional – enable TLS
29
+ TEMPORAL_TLS_CERT_PATH=certs/worker.crt # optional – only for mTLS
30
+ TEMPORAL_TLS_KEY_PATH=certs/worker.key # optional – only for mTLS
31
+ TEMPORAL_TLS_SERVER_NAME=temporal.example.com # optional – SNI override
32
+ TEMPORAL_CLIENT_RETRY_MAX_ATTEMPTS=5 # optional – WorkflowService RPC attempts
33
+ TEMPORAL_CLIENT_RETRY_INITIAL_MS=200 # optional – first retry delay in ms
34
+ TEMPORAL_CLIENT_RETRY_MAX_MS=5000 # optional – max retry delay in ms
35
+ TEMPORAL_CLIENT_RETRY_BACKOFF=2 # optional – exponential backoff coefficient
36
+ TEMPORAL_CLIENT_RETRY_JITTER_FACTOR=0.2 # optional – decorrelated jitter (0-1)
37
+ TEMPORAL_CLIENT_RETRY_STATUS_CODES=UNAVAILABLE,DEADLINE_EXCEEDED # optional – retryable gRPC codes
38
+ TEMPORAL_TASK_QUEUE=prix
39
+ TEMPORAL_WORKFLOW_CONCURRENCY=4 # optional – workflow pollers
40
+ TEMPORAL_ACTIVITY_CONCURRENCY=4 # optional – activity pollers
41
+ TEMPORAL_STICKY_CACHE_SIZE=256 # optional – determinism cache capacity
42
+ TEMPORAL_STICKY_TTL_MS=300000 # optional – eviction TTL in ms
43
+ TEMPORAL_STICKY_SCHEDULING_ENABLED=1 # optional – disable to bypass sticky scheduling
44
+ TEMPORAL_ACTIVITY_HEARTBEAT_INTERVAL_MS=4000 # optional – heartbeat throttle interval in ms
45
+ TEMPORAL_ACTIVITY_HEARTBEAT_RPC_TIMEOUT_MS=5000 # optional – heartbeat RPC timeout in ms
46
+ TEMPORAL_WORKER_DEPLOYMENT_NAME=prix-deploy # optional – worker deployment metadata
47
+ TEMPORAL_WORKER_BUILD_ID=git-sha # optional – build-id for versioning
48
+ ```
49
+
50
+ > Running against `temporal server start-dev`? Omit TLS variables and set `TEMPORAL_ADDRESS=127.0.0.1:7233`. Set `TEMPORAL_ALLOW_INSECURE=1` when testing with self-signed certificates.
51
+
52
+ 3. **Build the SDK once**
53
+ ```bash
54
+ bun run build
55
+ ```
56
+
57
+ 4. **Run the Bun worker**
58
+ ```bash
59
+ # optional: in another shell
60
+ bun scripts/start-temporal-cli.ts
61
+
62
+ # run the worker
63
+ bun run start:worker
64
+ ```
65
+
66
+ 5. **Scaffold a new worker project**
67
+ ```bash
68
+ temporal-bun init hello-worker
69
+ ```
70
+
71
+ ## WorkflowService client resilience
72
+
73
+ `createTemporalClient()` now includes built-in resilience features:
74
+
75
+ - **Configurable retries** – `loadTemporalConfig()` populates `config.rpcRetryPolicy` from the `TEMPORAL_CLIENT_RETRY_*` env vars (or from defaults). Every WorkflowService RPC is wrapped in `withTemporalRetry()` (decorrelated jitter + exponential backoff). Override per-call values with the new `TemporalClientCallOptions.retryPolicy` field when you need a bespoke attempt budget.
76
+ - **Optional call options on every method** – `startWorkflow`, `signalWorkflow`, `queryWorkflow`, `signalWithStart`, `terminateWorkflow`, and `describeNamespace` accept an optional trailing `callOptions` argument. Wrap them with `temporalCallOptions()` so payload objects are never mistaken for options:
77
+ ```ts
78
+ import { temporalCallOptions } from '@proompteng/temporal-bun-sdk'
79
+
80
+ await client.queryWorkflow(
81
+ handle,
82
+ 'currentState',
83
+ { kind: 'snapshot' },
84
+ temporalCallOptions({
85
+ timeoutMs: 15_000,
86
+ headers: { 'x-trace-id': traceId },
87
+ }),
88
+ )
89
+ ```
90
+ - **Telemetry-friendly interceptors** – the default interceptor builder injects namespace/identity headers, logs RPC attempts, and records latency/error counters with your configured metrics registry/exporter. Provide `interceptors` when creating a client to append custom tracing or auth middleware.
91
+ - **Memo & search attribute helpers** – `client.memo.encode/decode` and `client.searchAttributes.encode/decode` reuse the client’s `DataConverter`, making it trivial to prepare `Memo`/`SearchAttributes` payloads for raw WorkflowService requests.
92
+ - **TLS validation & handshake errors** – TLS buffers are validated up front (missing files, invalid PEMs, and mismatched cert/key pairs throw `TemporalTlsConfigurationError`). Runtime handshake failures raise `TemporalTlsHandshakeError` with remediation hints (verify CA bundles, check `TEMPORAL_TLS_SERVER_NAME`, or use `TEMPORAL_ALLOW_INSECURE=1` in trusted dev clusters).
93
+
94
+ ## Workflow surface
95
+
96
+ Workflow handlers receive a rich context that captures command intents deterministically. Alongside `input` you now get:
97
+
98
+ - `activities.schedule(type, args, options)` – buffers a `SCHEDULE_ACTIVITY_TASK` command. Activity IDs default to `activity-{n}` and inherit the workflow task queue unless overridden.
99
+ - `timers.start({ timeoutMs })` – emits a `START_TIMER` command and returns a handle for bookkeeping.
100
+ - `childWorkflows.start(type, args, options)` – records `START_CHILD_WORKFLOW_EXECUTION` with optional `workflowId`, retry policy, and task queue overrides.
101
+ - `signals.signal(name, args, options)` – queues `SIGNAL_EXTERNAL_WORKFLOW_EXECUTION` for another run or child.
102
+ - `continueAsNew(options)` – records a `CONTINUE_AS_NEW_WORKFLOW_EXECUTION` command and short-circuits the current run.
103
+ - `determinism.now()` / `determinism.random()` – shims for wall clock time and randomness that log values into the replay ledger so replays must produce identical sequences.
104
+
105
+ Example:
106
+
107
+ ```ts
108
+ import { Effect } from 'effect'
109
+ import * as Schema from 'effect/Schema'
110
+ import { defineWorkflow } from '@proompteng/temporal-bun-sdk/workflow'
111
+
112
+ export const workflows = [
113
+ defineWorkflow('greet', Schema.Array(Schema.String), ({ input, activities, timers, determinism }) => {
114
+ const [name = 'Temporal'] = input
115
+ return Effect.flatMap(activities.schedule('recordGreeting', [name]), () =>
116
+ Effect.flatMap(timers.start({ timeoutMs: 1_000 }), () =>
117
+ Effect.sync(() => {
118
+ const iso = new Date(determinism.now()).toISOString()
119
+ return `Greeting enqueued for ${name} at ${iso}`
120
+ }),
121
+ ),
122
+ )
123
+ }),
124
+ ]
125
+ ```
126
+
127
+ On each workflow task the executor compares newly emitted intents, random values, and logical timestamps against the stored determinism state. Mismatches raise `WorkflowNondeterminismError` and cause the worker to fail the task with `WORKFLOW_TASK_FAILED_CAUSE_NON_DETERMINISTIC_ERROR`, mirroring Temporal’s official SDK behavior. Determinism snapshots are recorded as `temporal-bun-sdk/determinism` markers in workflow history and optionally cached via a sticky determinism cache. Tune cache behaviour with `TEMPORAL_STICKY_CACHE_SIZE` and `TEMPORAL_STICKY_TTL_MS`; the sticky worker queue inherits its schedule-to-start timeout from the TTL value.
128
+
129
+ ## Activity lifecycle
130
+
131
+ Activities run with an ambient `ActivityContext` (available through `currentActivityContext()`) so you can send heartbeats, observe cancellation, and inspect attempt metadata:
132
+
133
+ ```ts
134
+ import { currentActivityContext } from '@proompteng/temporal-bun-sdk/worker'
135
+
136
+ export const ingestLargeFile = async (chunks: Iterable<string>) => {
137
+ const ctx = currentActivityContext()
138
+ let processed = 0
139
+ for (const chunk of chunks) {
140
+ // do expensive work
141
+ await writeChunk(chunk)
142
+ processed += 1
143
+ await ctx?.heartbeat({ processed })
144
+ ctx?.throwIfCancelled()
145
+ }
146
+ return processed
147
+ }
148
+ ```
149
+
150
+ - `activityContext.heartbeat(...details)` is throttled by `TEMPORAL_ACTIVITY_HEARTBEAT_INTERVAL_MS` and retried with exponential backoff (tunable via `TEMPORAL_ACTIVITY_HEARTBEAT_RPC_TIMEOUT_MS`) so transient RPC failures do not kill the attempt.
151
+ - The latest heartbeat payload automatically flows into cancellation/failure responses so Temporal UI surfaces helpful metadata.
152
+ - WorkerRuntime honours workflow `retry` policies locally: `maximumAttempts`, `initialInterval`, `maximumInterval`, `backoffCoefficient`, and `nonRetryableErrorTypes` all apply before a terminal failure is reported back to the server. Errors flagged as non-retryable (`error.nonRetryable = true` or matching the configured type list) short-circuit the retry loop.
153
+ - Activity attempts that exhaust the policy are reported as `nonRetryable` failures so the Temporal service does not perform redundant retries.
154
+
155
+ ## Integration harness
156
+
157
+ The SDK ships an integration harness that wraps the Temporal CLI dev server scripts. It can execute workflows through `temporal workflow execute`/`temporal workflow show`, turn the emitted history into `HistoryEvent[]`, and feed the ingestion pipeline. To use it locally:
158
+
159
+ 1. Install the [Temporal CLI](https://github.com/temporalio/cli) and ensure the `temporal` binary is on your `PATH` (or set `TEMPORAL_CLI_PATH`).
160
+ 2. Start the dev server with `bun scripts/start-temporal-cli.ts` or let the harness do it for you.
161
+ 3. Run the integration suite:
162
+ ```bash
163
+ bun test tests/integration/history-replay.test.ts
164
+ ```
165
+
166
+ If the CLI is missing the tests log a skip and continue so the rest of the suite still passes. The harness lives in `tests/integration/harness.ts` and exposes helpers for bespoke scenarios if you need to extend coverage.
167
+
168
+ ## Worker load & performance tests
169
+
170
+ The TBS-003 load harness lives under `tests/integration/load/**` and uses CPU-heavy workflows, I/O-heavy activities, and the worker runtime's file metrics exporter to guard throughput, poll latency, and sticky cache hit ratios. There are two supported entry points:
171
+
172
+ 1. **Bun test suite** (reuses the Temporal CLI harness):
173
+ ```bash
174
+ TEMPORAL_INTEGRATION_TESTS=1 pnpm --filter @proompteng/temporal-bun-sdk exec bun test tests/integration/worker-load.test.ts
175
+ ```
176
+ 2. **Developer-friendly CLI runner** (wraps the same scenario without `bun test`):
177
+ ```bash
178
+ pnpm --filter @proompteng/temporal-bun-sdk run test:load
179
+ ```
180
+
181
+ Both commands start the Temporal CLI dev server (unless `TEMPORAL_TEST_SERVER=1` is set), run the worker load scenario, and write artefacts to `.artifacts/worker-load/`:
182
+
183
+ - `metrics.jsonl` – raw JSONL stream from the file metrics exporter.
184
+ - `report.json` – human-readable summary (config, peak concurrency, throughput, latency percentiles, sticky cache hit ratio).
185
+ - `temporal-cli.log` – CLI stdout/stderr captured during the run.
186
+
187
+ The default profile now submits 36 workflows (roughly a 2:1 mix of CPU-heavy to IO-heavy types) with worker poller concurrency of 10/14 (workflow/activity) and a 100-second workflow deadline. That keeps the CI run comfortably under two minutes while actually saturating the scheduler. The Bun test wrapper adds a 15-second safety buffer on top of `TEMPORAL_LOAD_TEST_TIMEOUT_MS + TEMPORAL_LOAD_TEST_METRICS_FLUSH_MS`, so keep that env var in sync with any threshold tweaks.
188
+
189
+ ### Tuning the load harness
190
+
191
+ The harness is driven by env vars (also exposed as CLI flags via `--workflows`, `--workflow-concurrency`, `--activity-concurrency`, and `--timeout` when calling `pnpm run test:load`). Key overrides:
192
+
193
+ - `TEMPORAL_LOAD_TEST_WORKFLOWS` – total workflows to submit.
194
+ - `TEMPORAL_LOAD_TEST_WORKFLOW_CONCURRENCY` / `TEMPORAL_LOAD_TEST_ACTIVITY_CONCURRENCY` – poller counts / concurrency targets.
195
+ - `TEMPORAL_LOAD_TEST_WORKFLOW_POLL_P95_MS` / `TEMPORAL_LOAD_TEST_ACTIVITY_POLL_P95_MS` – max allowed P95 poll latency.
196
+ - `TEMPORAL_LOAD_TEST_STICKY_MIN_RATIO` – minimum sticky cache hit ratio before the suite fails.
197
+ - `TEMPORAL_LOAD_TEST_TIMEOUT_MS` – overall completion timeout per batch.
198
+ - `TEMPORAL_LOAD_TEST_ACTIVITY_BURSTS`, `TEMPORAL_LOAD_TEST_COMPUTE_ITERATIONS`, `TEMPORAL_LOAD_TEST_ACTIVITY_DELAY_MS`, `TEMPORAL_LOAD_TEST_ACTIVITY_PAYLOAD_BYTES` – fine-tune CPU/IO stress.
199
+
200
+ CI runs `pnpm --filter @proompteng/temporal-bun-sdk run test:load` inside `.github/workflows/temporal-bun-sdk.yml` and uploads `.artifacts/worker-load/{metrics.jsonl,report.json,temporal-cli.log}` so reviewers can inspect regressions. When running locally on slower hardware, lower the concurrency knobs or bump the latency thresholds to avoid spurious failures.
201
+
202
+ ## Effect service integration
203
+
204
+ ```ts
205
+ import { Effect, Layer } from 'effect'
206
+ import { WorkerService } from '@proompteng/temporal-bun-sdk/worker'
207
+
208
+ const workerLayer = WorkerService({
209
+ workflowsPath: new URL('./workflows/index.ts', import.meta.url).pathname,
210
+ })
211
+
212
+ const program = Effect.gen(function* () {
213
+ const { run } = yield* WorkerService
214
+ yield* run
215
+ })
216
+
217
+ await Effect.provide(program, workerLayer)
218
+ ```
219
+
220
+ Define workflows with the Effect runtime:
221
+
222
+ ```ts
223
+ import { Effect } from 'effect'
224
+ import { defineWorkflow } from '@proompteng/temporal-bun-sdk/workflow'
225
+
226
+ export const workflows = [
227
+ defineWorkflow('helloWorkflow', ({ input }) =>
228
+ Effect.sync(() => {
229
+ const [name] = Array.isArray(input) ? input : []
230
+ return typeof name === 'string' && name.length > 0 ? `Hello, ${name}!` : 'Hello, Temporal!'
231
+ }),
232
+ ),
233
+ ]
234
+ ```
235
+
236
+ Point the worker at a module exporting either `workflows` or a default array of definitions. Activity handlers remain plain async functions:
237
+
238
+ ```ts
239
+ import { createWorker } from '@proompteng/temporal-bun-sdk/worker'
240
+ import * as activities from './activities'
241
+
242
+ const { worker } = await createWorker({
243
+ activities,
244
+ workflowsPath: new URL('./workflows/index.ts', import.meta.url).pathname,
245
+ })
246
+
247
+ await worker.run()
248
+ ```
249
+
250
+ ### Layer-based worker bootstrap
251
+
252
+ ```ts
253
+ import { runWorkerApp } from '@proompteng/temporal-bun-sdk/runtime/worker-app'
254
+ import * as activities from './activities'
255
+
256
+ await runWorkerApp({
257
+ config: {
258
+ defaults: {
259
+ address: '127.0.0.1:7233',
260
+ namespace: 'staging',
261
+ taskQueue: 'staging-worker',
262
+ },
263
+ },
264
+ worker: {
265
+ activities,
266
+ workflowsPath: new URL('./workflows/index.ts', import.meta.url).pathname,
267
+ },
268
+ })
269
+ ```
270
+
271
+ ### CLI layer helpers
272
+
273
+ Use `runTemporalCliEffect` to run ad-hoc Effect programs (doctor checks, replay helpers,
274
+ tests) against the same layered config/logging/workflow stack without hand-loading env vars:
275
+
276
+ ```ts
277
+ import { Effect } from 'effect'
278
+ import { runTemporalCliEffect } from '@proompteng/temporal-bun-sdk/runtime/cli-layer'
279
+ import { TemporalConfigService } from '@proompteng/temporal-bun-sdk/runtime/effect-layers'
280
+
281
+ await runTemporalCliEffect(
282
+ Effect.gen(function* () {
283
+ const config = yield* TemporalConfigService
284
+ console.log('Active namespace:', config.namespace)
285
+ }),
286
+ {
287
+ config: {
288
+ defaults: {
289
+ address: '127.0.0.1:7233',
290
+ namespace: 'cli-layer',
291
+ taskQueue: 'cli-layer',
292
+ },
293
+ },
294
+ },
295
+ )
296
+ ```
297
+
298
+ ## CLI commands
299
+ ```
300
+ temporal-bun init [directory] Scaffold a new worker project
301
+ temporal-bun docker-build Build a Docker image for the current project
302
+ temporal-bun doctor Validate config + observability sinks
303
+ temporal-bun replay Replay workflow histories and diff determinism
304
+ temporal-bun help Show available commands
305
+ ```
306
+
307
+ ### Replay workflow histories
308
+
309
+ `temporal-bun replay` ingests workflow histories from JSON files or live
310
+ executions, reuses the existing determinism ingestion pipeline, and exits with a
311
+ non-zero status when mismatches surface (`0` success, `2` nondeterminism, `1`
312
+ configuration or IO failures).
313
+
314
+ - **History files** – accept either raw `temporal workflow show --history --output
315
+ json` output or fixture-style envelopes containing `history` + `info`.
316
+ - **Live executions** – pass `--execution <workflowId/runId>` and the command
317
+ shells out to the Temporal CLI (`--source cli`) or the WorkflowService RPC API
318
+ (`--source service`). `--source auto` (default) tries the CLI first and falls
319
+ back to WorkflowService when the binary is missing.
320
+ - **Observability** – the command composes `runTemporalCliEffect` layers (config,
321
+ observability, WorkflowService) before running and increments
322
+ `temporal_bun_replay_runs_total` / `temporal_bun_replay_mismatches_total`.
323
+ - **Troubleshooting** – surface the mismatching command index, event ids, and
324
+ workflow-task metadata on stdout plus a JSON summary when `--json` is set.
325
+
326
+ Examples:
327
+
328
+ ```bash
329
+ # Replay a captured history file
330
+ bunx temporal-bun replay \
331
+ --history-file packages/temporal-bun-sdk/tests/replay/fixtures/timer-workflow.json \
332
+ --workflow-type timerWorkflow \
333
+ --json
334
+
335
+ # Diff a live execution using the Temporal CLI harness
336
+ TEMPORAL_ADDRESS=127.0.0.1:7233 TEMPORAL_NAMESPACE=temporal-bun-integration \
337
+ bunx temporal-bun replay \
338
+ --execution workflow-id/run-id \
339
+ --workflow-type integrationWorkflow \
340
+ --namespace temporal-bun-integration \
341
+ --source cli
342
+
343
+ # Force WorkflowService RPCs (no CLI installed)
344
+ bunx temporal-bun replay \
345
+ --execution workflow-id/run-id \
346
+ --workflow-type integrationWorkflow \
347
+ --namespace temporal-bun-integration \
348
+ --source service
349
+ ```
350
+
351
+ Set `TEMPORAL_CLI_PATH` or `--temporal-cli` if the Temporal CLI binary is not on
352
+ your `PATH`. TLS, API key, and namespace overrides rely on the same environment
353
+ variables consumed by worker/client code (`TEMPORAL_ADDRESS`,
354
+ `TEMPORAL_NAMESPACE`, `TEMPORAL_TLS_*`, etc.).
355
+
356
+ ## Data conversion
357
+ `createDefaultDataConverter()` encodes payloads as JSON. Implement `DataConverter` if you need a custom codec or encryption layer:
358
+
359
+ ```ts
360
+ import { createDefaultDataConverter } from '@proompteng/temporal-bun-sdk/common/payloads'
361
+
362
+ const dataConverter = createDefaultDataConverter()
363
+ ```
364
+
365
+ Pass your converter to both the worker and client factories to keep payload handling consistent.
366
+
367
+ ## License
368
+ MIT © Proompt Engineering
369
+
370
+ ## Worker versioning and build IDs
371
+
372
+ Workers derive their build ID from `TEMPORAL_WORKER_BUILD_ID`, the package version, or the configured identity. When `deployment.versioningMode` is `WorkerVersioningMode.VERSIONED`, `WorkerRuntime.create()` now:
373
+
374
+ 1. Calls `GetWorkerBuildIdCompatibility` to confirm the WorkflowService supports worker versioning for the namespace/task queue.
375
+ 2. Registers the build ID via `UpdateWorkerBuildIdCompatibility` before any pollers start, retrying transient `Unavailable`, `DeadlineExceeded`, `Aborted`, and `Internal` errors with incremental backoff.
376
+ 3. Emits an info log so deploy pipelines can trace which build IDs were registered.
377
+
378
+ If the capability probe returns `Unimplemented` or `FailedPrecondition`, the runtime logs a warning and skips registration so local development servers (for example, the Temporal CLI dev server started via `bun scripts/start-temporal-cli.ts`) continue working even though they lack worker versioning APIs. Any other error aborts startup because versioned task queues will refuse to hand out work without a registered build ID.
379
+
380
+ Example logs:
381
+
382
+ ```
383
+ [temporal-bun-sdk] registered worker build ID prix-worker@1.2.3 for default/prix
384
+ [temporal-bun-sdk] skipping worker build ID registration for default/prix: worker versioning API unavailable (Unimplemented (12)). If you are running against the Temporal CLI dev server via bun scripts/start-temporal-cli.ts this warning is expected because that server does not implement worker versioning APIs yet.
385
+ ```
386
+
387
+ Production clusters should enable worker versioning, watch for the registration log during deploys, and alert on failures so versioned queues stay healthy.
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env bun
2
+ console.error('temporal-bun-sdk placeholder: dist has not been built yet. Run "bun run build" to generate CLI entrypoints.')
3
+ process.exit(1)
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env bun
2
+ console.error('temporal-bun-sdk placeholder: dist has not been built yet. Run "bun run build" to generate CLI entrypoints.')
3
+ process.exit(1)
@@ -0,0 +1,6 @@
1
+ export type EchoActivityInput = {
2
+ message: string;
3
+ };
4
+ export declare const echoActivity: ({ message }: EchoActivityInput) => Promise<string>;
5
+ export declare const sleepActivity: (milliseconds: number) => Promise<void>;
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/activities/index.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,iBAAiB,GAAG;IAC9B,OAAO,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,eAAO,MAAM,YAAY,GAAU,aAAa,iBAAiB,KAAG,OAAO,CAAC,MAAM,CAEjF,CAAA;AAED,eAAO,MAAM,aAAa,GAAU,cAAc,MAAM,KAAG,OAAO,CAAC,IAAI,CACJ,CAAA"}
@@ -0,0 +1,5 @@
1
+ export const echoActivity = async ({ message }) => {
2
+ return message;
3
+ };
4
+ export const sleepActivity = async (milliseconds) => await new Promise((resolve) => setTimeout(resolve, milliseconds));
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/activities/index.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,MAAM,YAAY,GAAG,KAAK,EAAE,EAAE,OAAO,EAAqB,EAAmB,EAAE;IACpF,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,EAAE,YAAoB,EAAiB,EAAE,CACzE,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC,CAAA"}
@@ -0,0 +1,48 @@
1
+ import { Effect } from 'effect';
2
+ import type { DataConverter } from '../common/payloads';
3
+ import type { Logger } from '../observability/logger';
4
+ import type { Counter } from '../observability/metrics';
5
+ import type { ActivityContext } from '../worker/activity-context';
6
+ import type { WorkflowServiceClient } from '../worker/runtime';
7
+ import type { WorkflowRetryPolicyInput } from '../workflow/determinism';
8
+ export interface ActivityRetryState {
9
+ readonly attempt: number;
10
+ readonly retryCount: number;
11
+ readonly nextDelayMs: number;
12
+ }
13
+ export interface ActivityLifecycleConfig {
14
+ readonly heartbeatIntervalMs: number;
15
+ readonly heartbeatRpcTimeoutMs: number;
16
+ readonly heartbeatRetry: {
17
+ readonly initialIntervalMs: number;
18
+ readonly maxIntervalMs: number;
19
+ readonly backoffCoefficient: number;
20
+ readonly maxAttempts: number;
21
+ readonly jitterRatio?: number;
22
+ };
23
+ readonly observability?: ActivityLifecycleObservability;
24
+ }
25
+ export interface ActivityLifecycleObservability {
26
+ readonly logger: Logger;
27
+ readonly heartbeatRetryCounter: Counter;
28
+ readonly heartbeatFailureCounter: Counter;
29
+ }
30
+ export interface ActivityHeartbeatRegistrationOptions {
31
+ readonly context: ActivityContext;
32
+ readonly workflowService: WorkflowServiceClient;
33
+ readonly taskToken: Uint8Array;
34
+ readonly identity: string;
35
+ readonly namespace: string;
36
+ readonly dataConverter: DataConverter;
37
+ readonly abortController: AbortController;
38
+ }
39
+ export interface ActivityHeartbeatRegistration {
40
+ readonly heartbeat: (details: unknown[]) => Effect.Effect<void, unknown, never>;
41
+ readonly shutdown: Effect.Effect<void, never, never>;
42
+ }
43
+ export interface ActivityLifecycle {
44
+ readonly registerHeartbeat: (options: ActivityHeartbeatRegistrationOptions) => Effect.Effect<ActivityHeartbeatRegistration, unknown, never>;
45
+ readonly nextRetryDelay: (retry: WorkflowRetryPolicyInput | undefined, state: ActivityRetryState) => Effect.Effect<ActivityRetryState | undefined, never, never>;
46
+ }
47
+ export declare const makeActivityLifecycle: (config: ActivityLifecycleConfig) => Effect.Effect<ActivityLifecycle, never, never>;
48
+ //# sourceMappingURL=lifecycle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lifecycle.d.ts","sourceRoot":"","sources":["../../../src/activities/lifecycle.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC/B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAGvD,OAAO,KAAK,EAAa,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAChE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAA;AAGvD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AACjE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAA;AAC9D,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAA;AAevE,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;CAC7B;AAED,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,mBAAmB,EAAE,MAAM,CAAA;IACpC,QAAQ,CAAC,qBAAqB,EAAE,MAAM,CAAA;IACtC,QAAQ,CAAC,cAAc,EAAE;QACvB,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAA;QAClC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAA;QAC9B,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAA;QACnC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;QAC5B,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAC9B,CAAA;IACD,QAAQ,CAAC,aAAa,CAAC,EAAE,8BAA8B,CAAA;CACxD;AAED,MAAM,WAAW,8BAA8B;IAC7C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,qBAAqB,EAAE,OAAO,CAAA;IACvC,QAAQ,CAAC,uBAAuB,EAAE,OAAO,CAAA;CAC1C;AAED,MAAM,WAAW,oCAAoC;IACnD,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAA;IACjC,QAAQ,CAAC,eAAe,EAAE,qBAAqB,CAAA;IAC/C,QAAQ,CAAC,SAAS,EAAE,UAAU,CAAA;IAC9B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,aAAa,EAAE,aAAa,CAAA;IACrC,QAAQ,CAAC,eAAe,EAAE,eAAe,CAAA;CAC1C;AAED,MAAM,WAAW,6BAA6B;IAC5C,QAAQ,CAAC,SAAS,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,CAAA;IAC/E,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,CAAA;CACrD;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,iBAAiB,EAAE,CAC1B,OAAO,EAAE,oCAAoC,KAC1C,MAAM,CAAC,MAAM,CAAC,6BAA6B,EAAE,OAAO,EAAE,KAAK,CAAC,CAAA;IACjE,QAAQ,CAAC,cAAc,EAAE,CACvB,KAAK,EAAE,wBAAwB,GAAG,SAAS,EAC3C,KAAK,EAAE,kBAAkB,KACtB,MAAM,CAAC,MAAM,CAAC,kBAAkB,GAAG,SAAS,EAAE,KAAK,EAAE,KAAK,CAAC,CAAA;CACjE;AAED,eAAO,MAAM,qBAAqB,GAChC,QAAQ,uBAAuB,KAC9B,MAAM,CAAC,MAAM,CAAC,iBAAiB,EAAE,KAAK,EAAE,KAAK,CA4C5C,CAAA"}