@aicalas/loopy 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 (244) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +101 -0
  3. package/dist/adapters.d.ts +111 -0
  4. package/dist/adapters.d.ts.map +1 -0
  5. package/dist/adapters.js +27 -0
  6. package/dist/adapters.js.map +1 -0
  7. package/dist/attention/github.d.ts +57 -0
  8. package/dist/attention/github.d.ts.map +1 -0
  9. package/dist/attention/github.js +162 -0
  10. package/dist/attention/github.js.map +1 -0
  11. package/dist/authoring/attention-config.d.ts +16 -0
  12. package/dist/authoring/attention-config.d.ts.map +1 -0
  13. package/dist/authoring/attention-config.js +19 -0
  14. package/dist/authoring/attention-config.js.map +1 -0
  15. package/dist/authoring/channel-config.d.ts +16 -0
  16. package/dist/authoring/channel-config.d.ts.map +1 -0
  17. package/dist/authoring/channel-config.js +16 -0
  18. package/dist/authoring/channel-config.js.map +1 -0
  19. package/dist/authoring/define.d.ts +13 -0
  20. package/dist/authoring/define.d.ts.map +1 -0
  21. package/dist/authoring/define.js +13 -0
  22. package/dist/authoring/define.js.map +1 -0
  23. package/dist/authoring/effect-config.d.ts +16 -0
  24. package/dist/authoring/effect-config.d.ts.map +1 -0
  25. package/dist/authoring/effect-config.js +17 -0
  26. package/dist/authoring/effect-config.js.map +1 -0
  27. package/dist/authoring/harness-config.d.ts +30 -0
  28. package/dist/authoring/harness-config.d.ts.map +1 -0
  29. package/dist/authoring/harness-config.js +36 -0
  30. package/dist/authoring/harness-config.js.map +1 -0
  31. package/dist/authoring/index.d.ts +10 -0
  32. package/dist/authoring/index.d.ts.map +1 -0
  33. package/dist/authoring/index.js +9 -0
  34. package/dist/authoring/index.js.map +1 -0
  35. package/dist/authoring/schema.d.ts +9 -0
  36. package/dist/authoring/schema.d.ts.map +1 -0
  37. package/dist/authoring/schema.js +28 -0
  38. package/dist/authoring/schema.js.map +1 -0
  39. package/dist/authoring/types.d.ts +115 -0
  40. package/dist/authoring/types.d.ts.map +1 -0
  41. package/dist/authoring/types.js +2 -0
  42. package/dist/authoring/types.js.map +1 -0
  43. package/dist/authoring/watcher-config.d.ts +33 -0
  44. package/dist/authoring/watcher-config.d.ts.map +1 -0
  45. package/dist/authoring/watcher-config.js +61 -0
  46. package/dist/authoring/watcher-config.js.map +1 -0
  47. package/dist/build/discover.d.ts +34 -0
  48. package/dist/build/discover.d.ts.map +1 -0
  49. package/dist/build/discover.js +165 -0
  50. package/dist/build/discover.js.map +1 -0
  51. package/dist/build/identity.d.ts +9 -0
  52. package/dist/build/identity.d.ts.map +1 -0
  53. package/dist/build/identity.js +0 -0
  54. package/dist/build/identity.js.map +1 -0
  55. package/dist/channels/github.d.ts +14 -0
  56. package/dist/channels/github.d.ts.map +1 -0
  57. package/dist/channels/github.js +118 -0
  58. package/dist/channels/github.js.map +1 -0
  59. package/dist/channels/index.d.ts +2 -0
  60. package/dist/channels/index.d.ts.map +1 -0
  61. package/dist/channels/index.js +2 -0
  62. package/dist/channels/index.js.map +1 -0
  63. package/dist/cli-help.d.ts +23 -0
  64. package/dist/cli-help.d.ts.map +1 -0
  65. package/dist/cli-help.js +186 -0
  66. package/dist/cli-help.js.map +1 -0
  67. package/dist/cli.d.ts +37 -0
  68. package/dist/cli.d.ts.map +1 -0
  69. package/dist/cli.js +385 -0
  70. package/dist/cli.js.map +1 -0
  71. package/dist/config.d.ts +71 -0
  72. package/dist/config.d.ts.map +1 -0
  73. package/dist/config.js +426 -0
  74. package/dist/config.js.map +1 -0
  75. package/dist/core/calls.d.ts +67 -0
  76. package/dist/core/calls.d.ts.map +1 -0
  77. package/dist/core/calls.js +109 -0
  78. package/dist/core/calls.js.map +1 -0
  79. package/dist/core/identifiers.d.ts +24 -0
  80. package/dist/core/identifiers.d.ts.map +1 -0
  81. package/dist/core/identifiers.js +129 -0
  82. package/dist/core/identifiers.js.map +1 -0
  83. package/dist/core/prompt.d.ts +5 -0
  84. package/dist/core/prompt.d.ts.map +1 -0
  85. package/dist/core/prompt.js +47 -0
  86. package/dist/core/prompt.js.map +1 -0
  87. package/dist/core/reconcile.d.ts +27 -0
  88. package/dist/core/reconcile.d.ts.map +1 -0
  89. package/dist/core/reconcile.js +36 -0
  90. package/dist/core/reconcile.js.map +1 -0
  91. package/dist/core/wire.d.ts +332 -0
  92. package/dist/core/wire.d.ts.map +1 -0
  93. package/dist/core/wire.js +543 -0
  94. package/dist/core/wire.js.map +1 -0
  95. package/dist/emitters/github.d.ts +15 -0
  96. package/dist/emitters/github.d.ts.map +1 -0
  97. package/dist/emitters/github.js +43 -0
  98. package/dist/emitters/github.js.map +1 -0
  99. package/dist/emitters/index.d.ts +2 -0
  100. package/dist/emitters/index.d.ts.map +1 -0
  101. package/dist/emitters/index.js +2 -0
  102. package/dist/emitters/index.js.map +1 -0
  103. package/dist/git.d.ts +17 -0
  104. package/dist/git.d.ts.map +1 -0
  105. package/dist/git.js +122 -0
  106. package/dist/git.js.map +1 -0
  107. package/dist/github/client.d.ts +53 -0
  108. package/dist/github/client.d.ts.map +1 -0
  109. package/dist/github/client.js +169 -0
  110. package/dist/github/client.js.map +1 -0
  111. package/dist/github/trigger.d.ts +12 -0
  112. package/dist/github/trigger.d.ts.map +1 -0
  113. package/dist/github/trigger.js +21 -0
  114. package/dist/github/trigger.js.map +1 -0
  115. package/dist/github/writes.d.ts +4 -0
  116. package/dist/github/writes.d.ts.map +1 -0
  117. package/dist/github/writes.js +21 -0
  118. package/dist/github/writes.js.map +1 -0
  119. package/dist/harnesses/base.d.ts +41 -0
  120. package/dist/harnesses/base.d.ts.map +1 -0
  121. package/dist/harnesses/base.js +182 -0
  122. package/dist/harnesses/base.js.map +1 -0
  123. package/dist/harnesses/claude-executable.d.ts +42 -0
  124. package/dist/harnesses/claude-executable.d.ts.map +1 -0
  125. package/dist/harnesses/claude-executable.js +138 -0
  126. package/dist/harnesses/claude-executable.js.map +1 -0
  127. package/dist/harnesses/claude.d.ts +35 -0
  128. package/dist/harnesses/claude.d.ts.map +1 -0
  129. package/dist/harnesses/claude.js +160 -0
  130. package/dist/harnesses/claude.js.map +1 -0
  131. package/dist/harnesses/codex.d.ts +40 -0
  132. package/dist/harnesses/codex.d.ts.map +1 -0
  133. package/dist/harnesses/codex.js +118 -0
  134. package/dist/harnesses/codex.js.map +1 -0
  135. package/dist/harnesses/index.d.ts +2 -0
  136. package/dist/harnesses/index.d.ts.map +1 -0
  137. package/dist/harnesses/index.js +2 -0
  138. package/dist/harnesses/index.js.map +1 -0
  139. package/dist/harnesses/opencode.d.ts +33 -0
  140. package/dist/harnesses/opencode.d.ts.map +1 -0
  141. package/dist/harnesses/opencode.js +203 -0
  142. package/dist/harnesses/opencode.js.map +1 -0
  143. package/dist/identifiers.d.ts +26 -0
  144. package/dist/identifiers.d.ts.map +1 -0
  145. package/dist/identifiers.js +62 -0
  146. package/dist/identifiers.js.map +1 -0
  147. package/dist/index.d.ts +10 -0
  148. package/dist/index.d.ts.map +1 -0
  149. package/dist/index.js +10 -0
  150. package/dist/index.js.map +1 -0
  151. package/dist/log.d.ts +10 -0
  152. package/dist/log.d.ts.map +1 -0
  153. package/dist/log.js +44 -0
  154. package/dist/log.js.map +1 -0
  155. package/dist/settings.d.ts +43 -0
  156. package/dist/settings.d.ts.map +1 -0
  157. package/dist/settings.js +128 -0
  158. package/dist/settings.js.map +1 -0
  159. package/dist/temporal/activities.d.ts +57 -0
  160. package/dist/temporal/activities.d.ts.map +1 -0
  161. package/dist/temporal/activities.js +366 -0
  162. package/dist/temporal/activities.js.map +1 -0
  163. package/dist/temporal/answers.d.ts +48 -0
  164. package/dist/temporal/answers.d.ts.map +1 -0
  165. package/dist/temporal/answers.js +78 -0
  166. package/dist/temporal/answers.js.map +1 -0
  167. package/dist/temporal/client.d.ts +13 -0
  168. package/dist/temporal/client.d.ts.map +1 -0
  169. package/dist/temporal/client.js +20 -0
  170. package/dist/temporal/client.js.map +1 -0
  171. package/dist/temporal/contracts.d.ts +19 -0
  172. package/dist/temporal/contracts.d.ts.map +1 -0
  173. package/dist/temporal/contracts.js +22 -0
  174. package/dist/temporal/contracts.js.map +1 -0
  175. package/dist/temporal/drain.d.ts +19 -0
  176. package/dist/temporal/drain.d.ts.map +1 -0
  177. package/dist/temporal/drain.js +109 -0
  178. package/dist/temporal/drain.js.map +1 -0
  179. package/dist/temporal/executions.d.ts +18 -0
  180. package/dist/temporal/executions.d.ts.map +1 -0
  181. package/dist/temporal/executions.js +15 -0
  182. package/dist/temporal/executions.js.map +1 -0
  183. package/dist/temporal/handle.d.ts +39 -0
  184. package/dist/temporal/handle.d.ts.map +1 -0
  185. package/dist/temporal/handle.js +95 -0
  186. package/dist/temporal/handle.js.map +1 -0
  187. package/dist/temporal/history.d.ts +75 -0
  188. package/dist/temporal/history.d.ts.map +1 -0
  189. package/dist/temporal/history.js +310 -0
  190. package/dist/temporal/history.js.map +1 -0
  191. package/dist/temporal/observe.d.ts +85 -0
  192. package/dist/temporal/observe.d.ts.map +1 -0
  193. package/dist/temporal/observe.js +110 -0
  194. package/dist/temporal/observe.js.map +1 -0
  195. package/dist/temporal/schedules.d.ts +26 -0
  196. package/dist/temporal/schedules.d.ts.map +1 -0
  197. package/dist/temporal/schedules.js +200 -0
  198. package/dist/temporal/schedules.js.map +1 -0
  199. package/dist/temporal/status.d.ts +63 -0
  200. package/dist/temporal/status.d.ts.map +1 -0
  201. package/dist/temporal/status.js +153 -0
  202. package/dist/temporal/status.js.map +1 -0
  203. package/dist/temporal/stuck.d.ts +58 -0
  204. package/dist/temporal/stuck.d.ts.map +1 -0
  205. package/dist/temporal/stuck.js +53 -0
  206. package/dist/temporal/stuck.js.map +1 -0
  207. package/dist/temporal/supervisor.d.ts +11 -0
  208. package/dist/temporal/supervisor.d.ts.map +1 -0
  209. package/dist/temporal/supervisor.js +506 -0
  210. package/dist/temporal/supervisor.js.map +1 -0
  211. package/dist/temporal/worker.d.ts +21 -0
  212. package/dist/temporal/worker.d.ts.map +1 -0
  213. package/dist/temporal/worker.js +82 -0
  214. package/dist/temporal/worker.js.map +1 -0
  215. package/dist/temporal/workflow-bundle.js +12742 -0
  216. package/dist/temporal/workflows.d.ts +9 -0
  217. package/dist/temporal/workflows.d.ts.map +1 -0
  218. package/dist/temporal/workflows.js +144 -0
  219. package/dist/temporal/workflows.js.map +1 -0
  220. package/dist/version.d.ts +2 -0
  221. package/dist/version.d.ts.map +1 -0
  222. package/dist/version.js +2 -0
  223. package/dist/version.js.map +1 -0
  224. package/dist/watchers/base.d.ts +4 -0
  225. package/dist/watchers/base.d.ts.map +1 -0
  226. package/dist/watchers/base.js +7 -0
  227. package/dist/watchers/base.js.map +1 -0
  228. package/dist/watchers/github/client.d.ts +52 -0
  229. package/dist/watchers/github/client.d.ts.map +1 -0
  230. package/dist/watchers/github/client.js +165 -0
  231. package/dist/watchers/github/client.js.map +1 -0
  232. package/dist/watchers/github/index.d.ts +19 -0
  233. package/dist/watchers/github/index.d.ts.map +1 -0
  234. package/dist/watchers/github/index.js +83 -0
  235. package/dist/watchers/github/index.js.map +1 -0
  236. package/dist/watchers/index.d.ts +2 -0
  237. package/dist/watchers/index.d.ts.map +1 -0
  238. package/dist/watchers/index.js +2 -0
  239. package/dist/watchers/index.js.map +1 -0
  240. package/dist/worker-lock.d.ts +11 -0
  241. package/dist/worker-lock.d.ts.map +1 -0
  242. package/dist/worker-lock.js +53 -0
  243. package/dist/worker-lock.js.map +1 -0
  244. package/package.json +92 -0
@@ -0,0 +1,16 @@
1
+ import type { EffectConfig } from "../core/wire.js";
2
+ import type { PromptFileRef } from "./types.js";
3
+ export interface GitHubLabelsAction {
4
+ /** The repository whose issue/PR labels change; use `ctx.trigger.repository` for the trigger. */
5
+ repository: string;
6
+ /** The issue or pull-request number to label; populate with `triggerIssue(ctx.trigger)`. */
7
+ issue: number;
8
+ add?: readonly string[];
9
+ remove?: readonly string[];
10
+ /** Credential source; `"env"` is the only one today and the default, declared rather than inherited. */
11
+ credentials?: "env";
12
+ }
13
+ export declare function githubLabels(action: GitHubLabelsAction): EffectConfig;
14
+ /** Reference a prompt file by a path relative to the configured project directory. */
15
+ export declare function promptFile(path: string): PromptFileRef;
16
+ //# sourceMappingURL=effect-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"effect-config.d.ts","sourceRoot":"","sources":["../../src/authoring/effect-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,MAAM,WAAW,kBAAkB;IACjC,iGAAiG;IACjG,UAAU,EAAE,MAAM,CAAC;IACnB,4FAA4F;IAC5F,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACxB,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC3B,wGAAwG;IACxG,WAAW,CAAC,EAAE,KAAK,CAAC;CACrB;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,kBAAkB,GAAG,YAAY,CAWrE;AAED,sFAAsF;AACtF,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,CAEtD"}
@@ -0,0 +1,17 @@
1
+ export function githubLabels(action) {
2
+ return {
3
+ emitter: "github_labels",
4
+ action: {
5
+ repository: action.repository,
6
+ issue: action.issue,
7
+ add: [...(action.add ?? [])],
8
+ remove: [...(action.remove ?? [])],
9
+ credentials: action.credentials ?? "env",
10
+ },
11
+ };
12
+ }
13
+ /** Reference a prompt file by a path relative to the configured project directory. */
14
+ export function promptFile(path) {
15
+ return { file: path };
16
+ }
17
+ //# sourceMappingURL=effect-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"effect-config.js","sourceRoot":"","sources":["../../src/authoring/effect-config.ts"],"names":[],"mappings":"AAcA,MAAM,UAAU,YAAY,CAAC,MAA0B;IACrD,OAAO;QACL,OAAO,EAAE,eAAe;QACxB,MAAM,EAAE;YACN,UAAU,EAAE,MAAM,CAAC,UAAU;YAC7B,KAAK,EAAE,MAAM,CAAC,KAAK;YACnB,GAAG,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,IAAI,EAAE,CAAC,CAAC;YAC5B,MAAM,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC;YAClC,WAAW,EAAE,MAAM,CAAC,WAAW,IAAI,KAAK;SACzC;KACF,CAAC;AACJ,CAAC;AAED,sFAAsF;AACtF,MAAM,UAAU,UAAU,CAAC,IAAY;IACrC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;AACxB,CAAC"}
@@ -0,0 +1,30 @@
1
+ import type { HarnessConfig } from "../core/wire.js";
2
+ export type ClaudeEffort = "low" | "medium" | "high" | "xhigh" | "max";
3
+ export type ClaudePermissionMode = "default" | "acceptEdits" | "plan" | "bypassPermissions" | "dontAsk" | "auto";
4
+ export interface ClaudeOptions {
5
+ model: string;
6
+ effort: ClaudeEffort;
7
+ /** Seal the agent off from on-disk provider config (`~/.claude`, project settings). */
8
+ isolated?: boolean;
9
+ permissionMode?: ClaudePermissionMode;
10
+ executablePath?: string;
11
+ }
12
+ export type CodexEffort = "none" | "minimal" | "low" | "medium" | "high" | "xhigh";
13
+ export type CodexSandbox = "read-only" | "workspace-write" | "full-access";
14
+ export type CodexApprovalMode = "deny_all" | "auto_review";
15
+ export interface CodexOptions {
16
+ model: string;
17
+ effort: CodexEffort;
18
+ isolated?: boolean;
19
+ sandbox?: CodexSandbox;
20
+ approvalMode?: CodexApprovalMode;
21
+ }
22
+ export interface OpenCodeOptions {
23
+ /** `provider/model`, for example `anthropic/claude-opus-4-8`. */
24
+ model: string;
25
+ effort: string;
26
+ }
27
+ export declare function claude(options: ClaudeOptions): HarnessConfig;
28
+ export declare function codex(options: CodexOptions): HarnessConfig;
29
+ export declare function opencode(options: OpenCodeOptions): HarnessConfig;
30
+ //# sourceMappingURL=harness-config.d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AAED,wBAAgB,QAAQ,CAAC,OAAO,EAAE,eAAe,GAAG,aAAa,CAKhE"}
@@ -0,0 +1,36 @@
1
+ export function claude(options) {
2
+ return {
3
+ harness: "claude",
4
+ options: compact({
5
+ model: options.model,
6
+ model_effort: options.effort,
7
+ isolated: options.isolated,
8
+ permission_mode: options.permissionMode,
9
+ executable_path: options.executablePath,
10
+ }),
11
+ };
12
+ }
13
+ export function codex(options) {
14
+ return {
15
+ harness: "codex",
16
+ options: compact({
17
+ model: options.model,
18
+ model_effort: options.effort,
19
+ isolated: options.isolated,
20
+ sandbox: options.sandbox,
21
+ approval_mode: options.approvalMode,
22
+ }),
23
+ };
24
+ }
25
+ export function opencode(options) {
26
+ return {
27
+ harness: "opencode",
28
+ options: compact({ model: options.model, model_effort: options.effort }),
29
+ };
30
+ }
31
+ // The harness Zod schemas are strict, and an explicit `undefined` is not the same as an absent key
32
+ // once the payload converter has turned it into `null`.
33
+ function compact(values) {
34
+ return Object.fromEntries(Object.entries(values).filter((entry) => entry[1] !== undefined));
35
+ }
36
+ //# sourceMappingURL=harness-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"harness-config.js","sourceRoot":"","sources":["../../src/authoring/harness-config.ts"],"names":[],"mappings":"AAsCA,MAAM,UAAU,MAAM,CAAC,OAAsB;IAC3C,OAAO;QACL,OAAO,EAAE,QAAQ;QACjB,OAAO,EAAE,OAAO,CAAC;YACf,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,YAAY,EAAE,OAAO,CAAC,MAAM;YAC5B,QAAQ,EAAE,OAAO,CAAC,QAAQ;YAC1B,eAAe,EAAE,OAAO,CAAC,cAAc;YACvC,eAAe,EAAE,OAAO,CAAC,cAAc;SACxC,CAAC;KACH,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,KAAK,CAAC,OAAqB;IACzC,OAAO;QACL,OAAO,EAAE,OAAO;QAChB,OAAO,EAAE,OAAO,CAAC;YACf,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,YAAY,EAAE,OAAO,CAAC,MAAM;YAC5B,QAAQ,EAAE,OAAO,CAAC,QAAQ;YAC1B,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,aAAa,EAAE,OAAO,CAAC,YAAY;SACpC,CAAC;KACH,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,OAAwB;IAC/C,OAAO;QACL,OAAO,EAAE,UAAU;QACnB,OAAO,EAAE,OAAO,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,YAAY,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC;KACzE,CAAC;AACJ,CAAC;AAED,mGAAmG;AACnG,wDAAwD;AACxD,SAAS,OAAO,CAAC,MAAoD;IACnE,OAAO,MAAM,CAAC,WAAW,CACvB,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,CAC3B,CAAC,KAAK,EAAuC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,SAAS,CACvE,CACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,10 @@
1
+ export type { CallState, InstanceResult, JsonObject, JsonValue, TriggerCandidate, } from "../core/wire.js";
2
+ export * from "./attention-config.js";
3
+ export * from "./channel-config.js";
4
+ export * from "./define.js";
5
+ export * from "./effect-config.js";
6
+ export * from "./harness-config.js";
7
+ export * from "./schema.js";
8
+ export * from "./types.js";
9
+ export * from "./watcher-config.js";
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/authoring/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,SAAS,EACT,cAAc,EACd,UAAU,EACV,SAAS,EACT,gBAAgB,GACjB,MAAM,iBAAiB,CAAC;AACzB,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,qBAAqB,CAAC"}
@@ -0,0 +1,9 @@
1
+ export * from "./attention-config.js";
2
+ export * from "./channel-config.js";
3
+ export * from "./define.js";
4
+ export * from "./effect-config.js";
5
+ export * from "./harness-config.js";
6
+ export * from "./schema.js";
7
+ export * from "./types.js";
8
+ export * from "./watcher-config.js";
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/authoring/index.ts"],"names":[],"mappings":"AAOA,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,qBAAqB,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { type JsonObject } from "../core/wire.js";
2
+ import type { OutputSchema } from "./types.js";
3
+ /**
4
+ * Render an output schema as a plain JSON Schema. Only the rendered schema crosses to the
5
+ * Activity, because a validator instance would not survive the payload converter and a bare
6
+ * Standard Schema validator would strip provider-native structured output.
7
+ */
8
+ export declare function toJsonSchema(output: OutputSchema): JsonObject;
9
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/authoring/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC/D,OAAO,KAAK,EAAE,YAAY,EAA6B,MAAM,YAAY,CAAC;AAK1E;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,YAAY,GAAG,UAAU,CAa7D"}
@@ -0,0 +1,28 @@
1
+ import { isJsonValue } from "../core/wire.js";
2
+ /** Ajv validates the returned outcome with the 2020-12 dialect, so ask converters for that one. */
3
+ const JSON_SCHEMA_TARGET = "draft-2020-12";
4
+ /**
5
+ * Render an output schema as a plain JSON Schema. Only the rendered schema crosses to the
6
+ * Activity, because a validator instance would not survive the payload converter and a bare
7
+ * Standard Schema validator would strip provider-native structured output.
8
+ */
9
+ export function toJsonSchema(output) {
10
+ const standard = output["~standard"];
11
+ if (standard === undefined)
12
+ return expectSchemaObject(output, "output schema");
13
+ const renderer = standard.jsonSchema;
14
+ if (typeof renderer?.output !== "function") {
15
+ throw new Error("output validator does not implement Standard JSON Schema; pass a JSON Schema object instead");
16
+ }
17
+ const rendered = renderer.output({ target: JSON_SCHEMA_TARGET });
18
+ return expectSchemaObject(rendered, "rendered output schema");
19
+ }
20
+ function expectSchemaObject(value, label) {
21
+ if (typeof value !== "object" || value === null || Array.isArray(value)) {
22
+ throw new Error(`${label} must be a JSON object`);
23
+ }
24
+ if (!isJsonValue(value))
25
+ throw new Error(`${label} must contain only JSON values`);
26
+ return value;
27
+ }
28
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/authoring/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAmB,MAAM,iBAAiB,CAAC;AAG/D,mGAAmG;AACnG,MAAM,kBAAkB,GAAG,eAAe,CAAC;AAE3C;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,MAAoB;IAC/C,MAAM,QAAQ,GAAI,MAAgD,CAAC,WAAW,CAAC,CAAC;IAChF,IAAI,QAAQ,KAAK,SAAS;QAAE,OAAO,kBAAkB,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IAC/E,MAAM,QAAQ,GAAI,QAAkD,CAAC,UAAU,CAAC;IAChF,IAAI,OAAO,QAAQ,EAAE,MAAM,KAAK,UAAU,EAAE,CAAC;QAC3C,MAAM,IAAI,KAAK,CACb,6FAA6F,CAC9F,CAAC;IACJ,CAAC;IACD,MAAM,QAAQ,GAAI,QAAwE,CAAC,MAAM,CAC/F,EAAE,MAAM,EAAE,kBAAkB,EAAE,CAC/B,CAAC;IACF,OAAO,kBAAkB,CAAC,QAAQ,EAAE,wBAAwB,CAAC,CAAC;AAChE,CAAC;AAED,SAAS,kBAAkB,CAAC,KAAc,EAAE,KAAa;IACvD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACxE,MAAM,IAAI,KAAK,CAAC,GAAG,KAAK,wBAAwB,CAAC,CAAC;IACpD,CAAC;IACD,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,GAAG,KAAK,gCAAgC,CAAC,CAAC;IACnF,OAAO,KAAmB,CAAC;AAC7B,CAAC"}
@@ -0,0 +1,115 @@
1
+ import type { Duration } from "@temporalio/common";
2
+ import type { AttentionConfig, ChannelConfig, EffectConfig, HarnessConfig, JsonObject, JsonValue, ReadonlyJsonObject, TriggerCandidate } from "../core/wire.js";
3
+ export type { AttentionConfig, ChannelConfig, EffectConfig, HarnessConfig } from "../core/wire.js";
4
+ /** A watcher selector plus its match configuration, as produced by `src/authoring/watcher-config.ts`. */
5
+ export interface WatcherDeclaration {
6
+ name: string;
7
+ options: JsonObject;
8
+ /**
9
+ * Bind the engine's claim effect to one trigger, whose concrete target (a GitHub trigger's issue)
10
+ * is only known per instance. Adapter code on the bundle declaration - never on the wire - so the
11
+ * engine executes the claim without naming any adapter field. Absent for a watcher that re-fires
12
+ * while its condition holds. Throwing `WorkflowHalt` halts the claim as an expected failure.
13
+ */
14
+ intake?: (trigger: TriggerCandidate) => EffectConfig;
15
+ }
16
+ /** A Temporal Schedule that starts this workflow directly, without polling a watcher. */
17
+ export interface ScheduleDeclaration {
18
+ /** A Temporal cron expression. */
19
+ cron?: string;
20
+ /** A fixed delay between starts, in seconds. */
21
+ intervalSeconds?: number;
22
+ /** IANA time zone used to interpret a cron expression. */
23
+ timezone?: string;
24
+ /** What Temporal does when a tick arrives while an earlier run is still open. */
25
+ overlap?: "SKIP" | "BUFFER_ONE" | "BUFFER_ALL" | "CANCEL_OTHER" | "TERMINATE_OTHER" | "ALLOW_ALL";
26
+ }
27
+ /** An attention adapter plus its destination parameters. */
28
+ export type AttentionDeclaration = AttentionConfig;
29
+ /** A channel adapter plus its explicit inputs, as produced by `src/authoring/channel-config.ts`. */
30
+ export type ChannelDeclaration = ChannelConfig;
31
+ /** A prompt segment the agent Activity reads from disk; the isolate cannot touch the filesystem. */
32
+ export interface PromptFileRef {
33
+ readonly file: string;
34
+ }
35
+ /**
36
+ * The Standard JSON Schema surface loopy consumes: a validator that can render itself as a plain
37
+ * JSON Schema. Zod 4, Valibot, and ArkType all implement it.
38
+ */
39
+ export interface StandardJSONSchemaV1<Output = unknown> {
40
+ readonly "~standard": {
41
+ readonly version: 1;
42
+ readonly vendor: string;
43
+ readonly jsonSchema: {
44
+ readonly output: (options: StandardJSONSchemaOptions) => Record<string, unknown>;
45
+ };
46
+ readonly types?: {
47
+ readonly output: Output;
48
+ } | undefined;
49
+ };
50
+ }
51
+ export interface StandardJSONSchemaOptions {
52
+ readonly target: string;
53
+ readonly libraryOptions?: Record<string, unknown> | undefined;
54
+ }
55
+ /** Either a Standard JSON Schema validator or a literal JSON Schema object. */
56
+ export type OutputSchema = StandardJSONSchemaV1 | ReadonlyJsonObject;
57
+ /** A literal JSON Schema carries no static type, so its output is typed as a plain JSON object. */
58
+ export type InferOutput<S> = S extends {
59
+ readonly "~standard": {
60
+ readonly types?: {
61
+ readonly output: infer Output;
62
+ } | undefined;
63
+ };
64
+ } ? Output : JsonObject;
65
+ export interface AgentRequest<S extends OutputSchema> {
66
+ output: S;
67
+ prompt: ReadonlyArray<string | PromptFileRef>;
68
+ timeout?: Duration;
69
+ }
70
+ /**
71
+ * One agent, carrying its provider session across calls. A handle serves one call at a time; a
72
+ * second concurrent call is rejected rather than racing for the worktree.
73
+ */
74
+ export interface AgentHandle {
75
+ readonly id: string;
76
+ /** Throws an expected workflow halt on a definitive failure. */
77
+ run<S extends OutputSchema>(request: AgentRequest<S>): Promise<InferOutput<S>>;
78
+ }
79
+ /**
80
+ * A question to a human. The prompt is markdown the agent authored (and interprets on resume), so
81
+ * the answer is validated only as a non-empty string. `timeoutSeconds` bounds the park; it defaults
82
+ * to two days and must be finite and positive.
83
+ */
84
+ export interface AskRequest {
85
+ prompt: ReadonlyArray<string | PromptFileRef>;
86
+ timeoutSeconds?: number;
87
+ }
88
+ export interface WorkflowContext {
89
+ readonly trigger: TriggerCandidate;
90
+ /** Repository cloned into agent workspaces; the trigger may live in another repository. */
91
+ readonly repository: string;
92
+ readonly defaultBranch: string;
93
+ readonly workflowRunId: string;
94
+ agent(id: string, harness: HarnessConfig): AgentHandle;
95
+ effect(id: string, effect: EffectConfig): Promise<void>;
96
+ /**
97
+ * Ask a human a question over a configured channel and park until a reply arrives, returning the
98
+ * answer as a string. The instance parks on a durable wait - no agent slot is held - and resumes
99
+ * from the reply-poll or `loopy answer`. An unanswered ask halts at its deadline; wrap the call in
100
+ * `try/catch` to proceed with a default instead.
101
+ */
102
+ ask(id: string, channel: ChannelDeclaration, request: AskRequest): Promise<string>;
103
+ }
104
+ export interface WorkflowDefinition<R extends JsonValue> {
105
+ /** Becomes the Temporal Workflow Type; duplicates are rejected at startup. */
106
+ name: string;
107
+ /** GitHub-style intake. Exactly one of `watcher` and `schedule` is required. */
108
+ watcher?: WatcherDeclaration;
109
+ /** Time-based intake. Exactly one of `watcher` and `schedule` is required. */
110
+ schedule?: ScheduleDeclaration;
111
+ /** Operational notifications. Required for watcher workflows and optional for scheduled ones. */
112
+ attention?: AttentionDeclaration;
113
+ run: (ctx: WorkflowContext) => Promise<R>;
114
+ }
115
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/authoring/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAA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ED,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,OAAO,EAAE,gBAAgB,CAAC;IACnC,2FAA2F;IAC3F,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,KAAK,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,GAAG,WAAW,CAAC;IACvD,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACxD;;;;;OAKG;IACH,GAAG,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,kBAAkB,EAAE,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CACpF;AAED,MAAM,WAAW,kBAAkB,CAAC,CAAC,SAAS,SAAS;IACrD,8EAA8E;IAC9E,IAAI,EAAE,MAAM,CAAC;IACb,gFAAgF;IAChF,OAAO,CAAC,EAAE,kBAAkB,CAAC;IAC7B,8EAA8E;IAC9E,QAAQ,CAAC,EAAE,mBAAmB,CAAC;IAC/B,iGAAiG;IACjG,SAAS,CAAC,EAAE,oBAAoB,CAAC;IACjC,GAAG,EAAE,CAAC,GAAG,EAAE,eAAe,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC;CAC3C"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/authoring/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,33 @@
1
+ import type { TriggerCandidate } from "../core/wire.js";
2
+ import type { WatcherDeclaration } from "./types.js";
3
+ /**
4
+ * The issue/PR number a GitHub trigger identifies, for populating a port's explicit `issue` input
5
+ * (`issue: triggerIssue(ctx.trigger)`). A trigger that names none is a misconfiguration, so this
6
+ * halts the instance - an expected, catchable failure that runs cleanup - rather than raising a
7
+ * bare exception that would wedge the Workflow Task into `stuck`.
8
+ */
9
+ export declare function triggerIssue(trigger: TriggerCandidate): number;
10
+ export interface GitHubLabelMatch {
11
+ /** The repository this watcher polls; its own declared identity, not inherited from the engine. */
12
+ repository: string;
13
+ label: string;
14
+ /**
15
+ * Extra labels to converge on when the instance claims the trigger. The intake label is always
16
+ * removed, so a workflow cannot forget the part that stops it re-firing.
17
+ */
18
+ onStart?: {
19
+ add?: readonly string[];
20
+ remove?: readonly string[];
21
+ };
22
+ /**
23
+ * `"edge"`, the default, consumes the intake label before user code runs, so one labelling
24
+ * produces one run. `"level"` leaves the label alone and re-runs for as long as it is attached,
25
+ * which only suits a workflow whose repetition is the point.
26
+ */
27
+ mode?: "edge" | "level";
28
+ /** Credential source; `"env"` is the only one today and the default, declared rather than inherited. */
29
+ credentials?: "env";
30
+ }
31
+ export declare function githubPullRequests(match: GitHubLabelMatch): WatcherDeclaration;
32
+ export declare function githubIssues(match: GitHubLabelMatch): WatcherDeclaration;
33
+ //# sourceMappingURL=watcher-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"watcher-config.d.ts","sourceRoot":"","sources":["../../src/authoring/watcher-config.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAgB,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEtE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAErD;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,gBAAgB,GAAG,MAAM,CAM9D;AAED,MAAM,WAAW,gBAAgB;IAC/B,mGAAmG;IACnG,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,OAAO,CAAC,EAAE;QAAE,GAAG,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;QAAC,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;KAAE,CAAC;IAClE;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IACxB,wGAAwG;IACxG,WAAW,CAAC,EAAE,KAAK,CAAC;CACrB;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,gBAAgB,GAAG,kBAAkB,CAE9E;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,gBAAgB,GAAG,kBAAkB,CAExE"}
@@ -0,0 +1,61 @@
1
+ import { WorkflowHalt } from "../core/calls.js";
2
+ import { gitHubTriggerNumber } from "../github/trigger.js";
3
+ /**
4
+ * The issue/PR number a GitHub trigger identifies, for populating a port's explicit `issue` input
5
+ * (`issue: triggerIssue(ctx.trigger)`). A trigger that names none is a misconfiguration, so this
6
+ * halts the instance - an expected, catchable failure that runs cleanup - rather than raising a
7
+ * bare exception that would wedge the Workflow Task into `stuck`.
8
+ */
9
+ export function triggerIssue(trigger) {
10
+ try {
11
+ return gitHubTriggerNumber(trigger);
12
+ }
13
+ catch {
14
+ throw new WorkflowHalt(`invalid-trigger-issue:${JSON.stringify(trigger.id)}`);
15
+ }
16
+ }
17
+ export function githubPullRequests(match) {
18
+ return labelWatcher("github_pull_request", match);
19
+ }
20
+ export function githubIssues(match) {
21
+ return labelWatcher("github_issue", match);
22
+ }
23
+ function labelWatcher(name, match) {
24
+ const options = {
25
+ repository: match.repository,
26
+ label: match.label,
27
+ credentials: match.credentials ?? "env",
28
+ };
29
+ const declaration = { name, options };
30
+ if (match.mode === "level")
31
+ return declaration;
32
+ return { ...declaration, intake: intakeEffect(match) };
33
+ }
34
+ /**
35
+ * Convergent by construction: the emitter computes a label set, so a repeat claim is a no-op. The
36
+ * repository is the watcher's own, but the trigger's issue is only known per instance, so this
37
+ * returns a binder the engine applies to the trigger at claim time - the adapter, not the engine,
38
+ * names its `issue` input.
39
+ */
40
+ function intakeEffect(match) {
41
+ const add = [...(match.onStart?.add ?? [])];
42
+ const remove = [match.label, ...(match.onStart?.remove ?? [])];
43
+ // A label on both sides has no answer the emitter could be trusted to give, and the intake label
44
+ // in `add` asks to re-apply the very thing the claim exists to consume. Both are authoring
45
+ // mistakes, so they fail at module load rather than becoming whatever the emitter happens to do.
46
+ const contradictory = add.filter((label) => remove.includes(label));
47
+ if (contradictory.length > 0) {
48
+ throw new Error(`watcher intake adds and removes the same label(s): ${contradictory.sort().join(", ")}`);
49
+ }
50
+ const action = {
51
+ repository: match.repository,
52
+ add,
53
+ remove,
54
+ credentials: match.credentials ?? "env",
55
+ };
56
+ return (trigger) => ({
57
+ emitter: "github_labels",
58
+ action: { ...action, issue: triggerIssue(trigger) },
59
+ });
60
+ }
61
+ //# sourceMappingURL=watcher-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"watcher-config.js","sourceRoot":"","sources":["../../src/authoring/watcher-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAG3D;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,OAAyB;IACpD,IAAI,CAAC;QACH,OAAO,mBAAmB,CAAC,OAAO,CAAC,CAAC;IACtC,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,YAAY,CAAC,yBAAyB,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IAChF,CAAC;AACH,CAAC;AAqBD,MAAM,UAAU,kBAAkB,CAAC,KAAuB;IACxD,OAAO,YAAY,CAAC,qBAAqB,EAAE,KAAK,CAAC,CAAC;AACpD,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,KAAuB;IAClD,OAAO,YAAY,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;AAC7C,CAAC;AAED,SAAS,YAAY,CAAC,IAAY,EAAE,KAAuB;IACzD,MAAM,OAAO,GAAG;QACd,UAAU,EAAE,KAAK,CAAC,UAAU;QAC5B,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB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}
@@ -0,0 +1,34 @@
1
+ import { type BundleOptions, type WorkflowBundleOption } from "@temporalio/worker";
2
+ import type { ScheduleDeclaration } from "../authoring/types.js";
3
+ import type { AttentionConfig, WatcherSnapshot } from "../core/wire.js";
4
+ export interface DiscoveredWorkflow {
5
+ name: string;
6
+ watcher?: WatcherSnapshot;
7
+ schedule?: ScheduleDeclaration;
8
+ attention?: AttentionConfig;
9
+ modulePath: string;
10
+ }
11
+ /**
12
+ * Import each workflow module under plain Node to read its declared name and watcher. The same
13
+ * modules are bundled for the isolate, so they must be safe to import twice and free of top-level
14
+ * side effects.
15
+ */
16
+ export declare function discoverWorkflows(directory: string): Promise<DiscoveredWorkflow[]>;
17
+ export declare function workflowModulePaths(directory: string): string[];
18
+ /**
19
+ * The entry module names every Workflow Type the bundle serves. Workflow names are not JavaScript
20
+ * identifiers, so each is exported under an arbitrary module namespace name.
21
+ */
22
+ export declare function generateEntryModule(workflows: readonly DiscoveredWorkflow[], pollModulePath: string): string;
23
+ export interface BundleRequest {
24
+ workflows: readonly DiscoveredWorkflow[];
25
+ workingDirectory: string;
26
+ /** Lets tests layer coverage instrumentation onto the same bundle production runs. */
27
+ augment?: (options: BundleOptions) => BundleOptions;
28
+ }
29
+ /**
30
+ * Bundle the discovered workflows for the isolate. The entry module is written beneath the working
31
+ * directory so webpack resolves the project's `node_modules` the same way Node does.
32
+ */
33
+ export declare function buildWorkflowBundle(request: BundleRequest): Promise<WorkflowBundleOption>;
34
+ //# sourceMappingURL=discover.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"discover.d.ts","sourceRoot":"","sources":["../../src/build/discover.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,KAAK,aAAa,EAElB,KAAK,oBAAoB,EAC1B,MAAM,oBAAoB,CAAC;AAG5B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAEjE,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAMxE,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,eAAe,CAAC;IAC1B,QAAQ,CAAC,EAAE,mBAAmB,CAAC;IAC/B,SAAS,CAAC,EAAE,eAAe,CAAC;IAC5B,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;;;GAIG;AACH,wBAAsB,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAkBxF;AAED,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,CAK/D;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,SAAS,kBAAkB,EAAE,EACxC,cAAc,EAAE,MAAM,GACrB,MAAM,CAaR;AAED,MAAM,WAAW,aAAa;IAC5B,SAAS,EAAE,SAAS,kBAAkB,EAAE,CAAC;IACzC,gBAAgB,EAAE,MAAM,CAAC;IACzB,sFAAsF;IACtF,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,aAAa,KAAK,aAAa,CAAC;CACrD;AAED;;;GAGG;AACH,wBAAsB,mBAAmB,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,oBAAoB,CAAC,CA2B/F"}
@@ -0,0 +1,165 @@
1
+ import { existsSync, mkdirSync, readdirSync, writeFileSync } from "node:fs";
2
+ import { createRequire } from "node:module";
3
+ import { dirname, extname, join, resolve, sep } from "node:path";
4
+ import { fileURLToPath, pathToFileURL } from "node:url";
5
+ import { bundleWorkflowCode, } from "@temporalio/worker";
6
+ import { IDENTIFIER_PATTERN } from "../core/calls.js";
7
+ const MODULE_EXTENSIONS = new Set([".ts", ".mts", ".js", ".mjs"]);
8
+ /** Workflow modules import loopy through this specifier; the bundle aliases it to this build. */
9
+ const AUTHORING_SPECIFIER = "@aicalas/loopy/workflow";
10
+ /**
11
+ * Import each workflow module under plain Node to read its declared name and watcher. The same
12
+ * modules are bundled for the isolate, so they must be safe to import twice and free of top-level
13
+ * side effects.
14
+ */
15
+ export async function discoverWorkflows(directory) {
16
+ const root = resolve(directory);
17
+ if (!existsSync(root))
18
+ throw new Error(`workflows directory not found: ${root}`);
19
+ const discovered = [];
20
+ const names = new Map();
21
+ for (const modulePath of workflowModulePaths(root)) {
22
+ const workflow = await importWorkflow(modulePath);
23
+ const claimed = names.get(workflow.name);
24
+ if (claimed !== undefined) {
25
+ throw new Error(`duplicate workflow name ${JSON.stringify(workflow.name)} in ${modulePath} and ${claimed}`);
26
+ }
27
+ names.set(workflow.name, modulePath);
28
+ discovered.push(workflow);
29
+ }
30
+ if (discovered.length === 0)
31
+ throw new Error(`no workflow modules found in ${root}`);
32
+ return discovered;
33
+ }
34
+ export function workflowModulePaths(directory) {
35
+ return readdirSync(directory, { withFileTypes: true })
36
+ .filter((entry) => entry.isFile() && MODULE_EXTENSIONS.has(extname(entry.name)))
37
+ .map((entry) => join(directory, entry.name))
38
+ .sort();
39
+ }
40
+ /**
41
+ * The entry module names every Workflow Type the bundle serves. Workflow names are not JavaScript
42
+ * identifiers, so each is exported under an arbitrary module namespace name.
43
+ */
44
+ export function generateEntryModule(workflows, pollModulePath) {
45
+ const imports = workflows.map((workflow, index) => `import workflow${index} from ${JSON.stringify(workflow.modulePath)};`);
46
+ const exports = workflows.map((workflow, index) => `export { workflow${index} as ${JSON.stringify(workflow.name)} };`);
47
+ return [
48
+ `export { PollWorkflow } from ${JSON.stringify(pollModulePath)};`,
49
+ ...imports,
50
+ ...exports,
51
+ "",
52
+ ].join("\n");
53
+ }
54
+ /**
55
+ * Bundle the discovered workflows for the isolate. The entry module is written beneath the working
56
+ * directory so webpack resolves the project's `node_modules` the same way Node does.
57
+ */
58
+ export async function buildWorkflowBundle(request) {
59
+ const directory = join(request.workingDirectory, "build");
60
+ mkdirSync(directory, { recursive: true });
61
+ const entryPath = join(directory, "workflows.ts");
62
+ const entry = generateEntryModule(request.workflows, runtimeModule("temporal/workflows"));
63
+ writeFileSync(entryPath, entry, "utf8");
64
+ const authoringModule = runtimeModule("authoring/index");
65
+ const augmented = (request.augment ?? ((options) => options))({ workflowsPath: entryPath });
66
+ const bundle = await bundleWorkflowCode({
67
+ ...augmented,
68
+ webpackConfigHook: (config) => {
69
+ const resolved = augmented.webpackConfigHook?.(config) ?? config;
70
+ resolved.resolve = resolved.resolve ?? {};
71
+ resolved.resolve.alias = {
72
+ ...resolved.resolve.alias,
73
+ [`${AUTHORING_SPECIFIER}$`]: authoringModule,
74
+ };
75
+ // The entry module lives under the working directory, which need not sit inside the
76
+ // project, so the SDK's own generated entrypoint gets explicit module roots.
77
+ resolved.resolve.modules = [
78
+ ...(resolved.resolve.modules ?? ["node_modules"]),
79
+ ...temporalModuleRoots(),
80
+ ];
81
+ return resolved;
82
+ },
83
+ });
84
+ return { code: bundle.code };
85
+ }
86
+ /** Both the flat and the pnpm-nested `node_modules` that hold the Temporal SDK loopy resolved. */
87
+ function temporalModuleRoots() {
88
+ const entry = createRequire(import.meta.url).resolve("@temporalio/worker");
89
+ const marker = `${sep}node_modules${sep}`;
90
+ const roots = new Set();
91
+ for (const index of [entry.indexOf(marker), entry.lastIndexOf(marker)]) {
92
+ if (index >= 0)
93
+ roots.add(entry.slice(0, index + marker.length - 1));
94
+ }
95
+ return [...roots];
96
+ }
97
+ /** Resolve one of loopy's own modules on disk, which is TypeScript in development and JavaScript once built. */
98
+ function runtimeModule(relativePath) {
99
+ const base = join(dirname(fileURLToPath(import.meta.url)), "..", relativePath);
100
+ for (const extension of [".js", ".ts"]) {
101
+ if (existsSync(`${base}${extension}`))
102
+ return `${base}${extension}`;
103
+ }
104
+ throw new Error(`loopy runtime module not found: ${base}`);
105
+ }
106
+ async function importWorkflow(modulePath) {
107
+ const module = await import(pathToFileURL(modulePath).href);
108
+ const exported = module.default;
109
+ if (typeof exported !== "function" || !("definition" in exported)) {
110
+ throw new Error(`${modulePath} must default-export the result of defineWorkflow()`);
111
+ }
112
+ const { definition } = exported;
113
+ if (typeof definition.name !== "string" || !IDENTIFIER_PATTERN.test(definition.name)) {
114
+ throw new Error(`${modulePath} declares an invalid workflow name`);
115
+ }
116
+ const hasWatcher = definition.watcher !== undefined;
117
+ const hasSchedule = definition.schedule !== undefined;
118
+ if (hasWatcher === hasSchedule) {
119
+ throw new Error(`${modulePath} must declare exactly one of watcher or schedule`);
120
+ }
121
+ if (definition.watcher !== undefined && typeof definition.watcher.name !== "string") {
122
+ throw new Error(`${modulePath} declares an invalid watcher`);
123
+ }
124
+ if (definition.watcher !== undefined && definition.attention === undefined) {
125
+ throw new Error(`${modulePath} watcher workflows must declare attention`);
126
+ }
127
+ if (definition.schedule !== undefined)
128
+ validateSchedule(definition.schedule, modulePath);
129
+ if (definition.attention !== undefined && typeof definition.attention.emitter !== "string") {
130
+ throw new Error(`${modulePath} declares an invalid attention emitter`);
131
+ }
132
+ if (definition.schedule !== undefined &&
133
+ definition.attention?.emitter === "github" &&
134
+ definition.attention.options.target === "trigger") {
135
+ throw new Error(`${modulePath} scheduled workflows cannot use trigger attention`);
136
+ }
137
+ return {
138
+ name: definition.name,
139
+ // Only the wire-safe selector travels to Schedules; the claim binder stays in the bundle.
140
+ ...(definition.watcher === undefined
141
+ ? {}
142
+ : { watcher: { name: definition.watcher.name, options: definition.watcher.options } }),
143
+ ...(definition.schedule === undefined ? {} : { schedule: definition.schedule }),
144
+ ...(definition.attention === undefined ? {} : { attention: definition.attention }),
145
+ modulePath,
146
+ };
147
+ }
148
+ function validateSchedule(schedule, modulePath) {
149
+ const hasCron = typeof schedule.cron === "string" && schedule.cron.trim().length > 0;
150
+ const hasInterval = typeof schedule.intervalSeconds === "number" &&
151
+ Number.isFinite(schedule.intervalSeconds) &&
152
+ schedule.intervalSeconds > 0;
153
+ if (hasCron === hasInterval) {
154
+ throw new Error(`${modulePath} schedule must declare exactly one of cron or intervalSeconds`);
155
+ }
156
+ if (schedule.timezone !== undefined &&
157
+ (typeof schedule.timezone !== "string" || schedule.timezone === "")) {
158
+ throw new Error(`${modulePath} schedule timezone must be a non-empty string`);
159
+ }
160
+ if (schedule.overlap !== undefined &&
161
+ !["SKIP", "BUFFER_ONE", "BUFFER_ALL", "CANCEL_OTHER", "TERMINATE_OTHER", "ALLOW_ALL"].includes(schedule.overlap)) {
162
+ throw new Error(`${modulePath} schedule overlap is invalid`);
163
+ }
164
+ }
165
+ //# sourceMappingURL=discover.js.map