@agntk/core 0.1.2 → 0.3.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 (186) hide show
  1. package/README.md +56 -90
  2. package/dist/advanced/index.d.ts +9 -2
  3. package/dist/advanced/index.d.ts.map +1 -1
  4. package/dist/advanced/index.js +13 -2
  5. package/dist/advanced/index.js.map +1 -1
  6. package/dist/agent.d.ts +27 -31
  7. package/dist/agent.d.ts.map +1 -1
  8. package/dist/agent.js +251 -280
  9. package/dist/agent.js.map +1 -1
  10. package/dist/config/defaults.d.ts.map +1 -1
  11. package/dist/config/defaults.js +16 -4
  12. package/dist/config/defaults.js.map +1 -1
  13. package/dist/config/loader.d.ts +14 -6
  14. package/dist/config/loader.d.ts.map +1 -1
  15. package/dist/config/loader.js +38 -16
  16. package/dist/config/loader.js.map +1 -1
  17. package/dist/config/schema.d.ts +52 -52
  18. package/dist/config/schema.d.ts.map +1 -1
  19. package/dist/config/schema.js +1 -1
  20. package/dist/config/schema.js.map +1 -1
  21. package/dist/evals/runner.js +16 -9
  22. package/dist/evals/runner.js.map +1 -1
  23. package/dist/evals/types.d.ts +1 -1
  24. package/dist/evals/types.d.ts.map +1 -1
  25. package/dist/guardrails/runner.d.ts.map +1 -1
  26. package/dist/guardrails/runner.js +4 -0
  27. package/dist/guardrails/runner.js.map +1 -1
  28. package/dist/index.d.ts +9 -10
  29. package/dist/index.d.ts.map +1 -1
  30. package/dist/index.js +15 -10
  31. package/dist/index.js.map +1 -1
  32. package/dist/models.d.ts +24 -1
  33. package/dist/models.d.ts.map +1 -1
  34. package/dist/models.js +50 -4
  35. package/dist/models.js.map +1 -1
  36. package/dist/observability/langfuse.d.ts +2 -2
  37. package/dist/observability/langfuse.d.ts.map +1 -1
  38. package/dist/observability/langfuse.js +39 -17
  39. package/dist/observability/langfuse.js.map +1 -1
  40. package/dist/presets/sub-agent-configs.d.ts +11 -3
  41. package/dist/presets/sub-agent-configs.d.ts.map +1 -1
  42. package/dist/presets/sub-agent-configs.js +5 -10
  43. package/dist/presets/sub-agent-configs.js.map +1 -1
  44. package/dist/presets/tools.d.ts +3 -3
  45. package/dist/provider-resolver.d.ts +38 -0
  46. package/dist/provider-resolver.d.ts.map +1 -0
  47. package/dist/provider-resolver.js +142 -0
  48. package/dist/provider-resolver.js.map +1 -0
  49. package/dist/reflection.d.ts +5 -2
  50. package/dist/reflection.d.ts.map +1 -1
  51. package/dist/reflection.js +8 -3
  52. package/dist/reflection.js.map +1 -1
  53. package/dist/skills/loader.d.ts +18 -0
  54. package/dist/skills/loader.d.ts.map +1 -1
  55. package/dist/skills/loader.js +58 -2
  56. package/dist/skills/loader.js.map +1 -1
  57. package/dist/system-detect.d.ts +59 -0
  58. package/dist/system-detect.d.ts.map +1 -0
  59. package/dist/system-detect.js +193 -0
  60. package/dist/system-detect.js.map +1 -0
  61. package/dist/tools/file/tools.d.ts.map +1 -1
  62. package/dist/tools/file/tools.js +30 -1
  63. package/dist/tools/file/tools.js.map +1 -1
  64. package/dist/tools/index.d.ts +0 -1
  65. package/dist/tools/index.d.ts.map +1 -1
  66. package/dist/tools/index.js +0 -2
  67. package/dist/tools/index.js.map +1 -1
  68. package/dist/tools/plan/tools.d.ts +1 -1
  69. package/dist/tools/plan/types.d.ts +2 -2
  70. package/dist/tools/progress/index.d.ts +1 -1
  71. package/dist/tools/shell/background.d.ts.map +1 -1
  72. package/dist/tools/shell/background.js +45 -3
  73. package/dist/tools/shell/background.js.map +1 -1
  74. package/dist/tools/shell/tools.d.ts.map +1 -1
  75. package/dist/tools/shell/tools.js +9 -2
  76. package/dist/tools/shell/tools.js.map +1 -1
  77. package/dist/tools/spawn-agent/index.d.ts +7 -9
  78. package/dist/tools/spawn-agent/index.d.ts.map +1 -1
  79. package/dist/tools/spawn-agent/index.js +2 -4
  80. package/dist/tools/spawn-agent/index.js.map +1 -1
  81. package/dist/tools/utils/shell.d.ts +14 -0
  82. package/dist/tools/utils/shell.d.ts.map +1 -1
  83. package/dist/tools/utils/shell.js +171 -12
  84. package/dist/tools/utils/shell.js.map +1 -1
  85. package/dist/types/agent.d.ts +75 -195
  86. package/dist/types/agent.d.ts.map +1 -1
  87. package/dist/types/agent.js +4 -2
  88. package/dist/types/agent.js.map +1 -1
  89. package/dist/types/index.d.ts +1 -1
  90. package/dist/types/index.d.ts.map +1 -1
  91. package/dist/types/index.js.map +1 -1
  92. package/dist/usage-limits.d.ts +1 -1
  93. package/dist/usage-limits.js +1 -1
  94. package/dist/workflow/index.d.ts +1 -5
  95. package/dist/workflow/index.d.ts.map +1 -1
  96. package/dist/workflow/index.js +1 -9
  97. package/dist/workflow/index.js.map +1 -1
  98. package/dist/wrappers/best-of-n.d.ts +1 -1
  99. package/dist/wrappers/best-of-n.d.ts.map +1 -1
  100. package/dist/wrappers/best-of-n.js +11 -6
  101. package/dist/wrappers/best-of-n.js.map +1 -1
  102. package/package.json +4 -14
  103. package/dist/pool/index.d.ts +0 -7
  104. package/dist/pool/index.d.ts.map +0 -1
  105. package/dist/pool/index.js +0 -6
  106. package/dist/pool/index.js.map +0 -1
  107. package/dist/pool/specialist-pool.d.ts +0 -59
  108. package/dist/pool/specialist-pool.d.ts.map +0 -1
  109. package/dist/pool/specialist-pool.js +0 -224
  110. package/dist/pool/specialist-pool.js.map +0 -1
  111. package/dist/pool/tools.d.ts +0 -63
  112. package/dist/pool/tools.d.ts.map +0 -1
  113. package/dist/pool/tools.js +0 -83
  114. package/dist/pool/tools.js.map +0 -1
  115. package/dist/pool/types.d.ts +0 -79
  116. package/dist/pool/types.d.ts.map +0 -1
  117. package/dist/pool/types.js +0 -5
  118. package/dist/pool/types.js.map +0 -1
  119. package/dist/presets/index.d.ts +0 -5
  120. package/dist/presets/index.d.ts.map +0 -1
  121. package/dist/presets/index.js +0 -5
  122. package/dist/presets/index.js.map +0 -1
  123. package/dist/presets/role-registry.d.ts +0 -41
  124. package/dist/presets/role-registry.d.ts.map +0 -1
  125. package/dist/presets/role-registry.js +0 -213
  126. package/dist/presets/role-registry.js.map +0 -1
  127. package/dist/presets/roles.d.ts +0 -105
  128. package/dist/presets/roles.d.ts.map +0 -1
  129. package/dist/presets/roles.js +0 -207
  130. package/dist/presets/roles.js.map +0 -1
  131. package/dist/tools/factory.d.ts +0 -109
  132. package/dist/tools/factory.d.ts.map +0 -1
  133. package/dist/tools/factory.js +0 -166
  134. package/dist/tools/factory.js.map +0 -1
  135. package/dist/workflow/builders/adapt.d.ts +0 -20
  136. package/dist/workflow/builders/adapt.d.ts.map +0 -1
  137. package/dist/workflow/builders/adapt.js +0 -33
  138. package/dist/workflow/builders/adapt.js.map +0 -1
  139. package/dist/workflow/builders/index.d.ts +0 -8
  140. package/dist/workflow/builders/index.d.ts.map +0 -1
  141. package/dist/workflow/builders/index.js +0 -7
  142. package/dist/workflow/builders/index.js.map +0 -1
  143. package/dist/workflow/builders/parallel.d.ts +0 -25
  144. package/dist/workflow/builders/parallel.d.ts.map +0 -1
  145. package/dist/workflow/builders/parallel.js +0 -60
  146. package/dist/workflow/builders/parallel.js.map +0 -1
  147. package/dist/workflow/builders/pipeline.d.ts +0 -22
  148. package/dist/workflow/builders/pipeline.d.ts.map +0 -1
  149. package/dist/workflow/builders/pipeline.js +0 -48
  150. package/dist/workflow/builders/pipeline.js.map +0 -1
  151. package/dist/workflow/builders/types.d.ts +0 -54
  152. package/dist/workflow/builders/types.d.ts.map +0 -1
  153. package/dist/workflow/builders/types.js +0 -5
  154. package/dist/workflow/builders/types.js.map +0 -1
  155. package/dist/workflow/schedulers.d.ts +0 -231
  156. package/dist/workflow/schedulers.d.ts.map +0 -1
  157. package/dist/workflow/schedulers.js +0 -250
  158. package/dist/workflow/schedulers.js.map +0 -1
  159. package/dist/workflow/team/create-team.d.ts +0 -34
  160. package/dist/workflow/team/create-team.d.ts.map +0 -1
  161. package/dist/workflow/team/create-team.js +0 -242
  162. package/dist/workflow/team/create-team.js.map +0 -1
  163. package/dist/workflow/team/index.d.ts +0 -9
  164. package/dist/workflow/team/index.d.ts.map +0 -1
  165. package/dist/workflow/team/index.js +0 -8
  166. package/dist/workflow/team/index.js.map +0 -1
  167. package/dist/workflow/team/machines.d.ts +0 -152
  168. package/dist/workflow/team/machines.d.ts.map +0 -1
  169. package/dist/workflow/team/machines.js +0 -197
  170. package/dist/workflow/team/machines.js.map +0 -1
  171. package/dist/workflow/team/task-board.d.ts +0 -47
  172. package/dist/workflow/team/task-board.d.ts.map +0 -1
  173. package/dist/workflow/team/task-board.js +0 -111
  174. package/dist/workflow/team/task-board.js.map +0 -1
  175. package/dist/workflow/team/tools.d.ts +0 -66
  176. package/dist/workflow/team/tools.d.ts.map +0 -1
  177. package/dist/workflow/team/tools.js +0 -100
  178. package/dist/workflow/team/tools.js.map +0 -1
  179. package/dist/workflow/team/types.d.ts +0 -109
  180. package/dist/workflow/team/types.d.ts.map +0 -1
  181. package/dist/workflow/team/types.js +0 -5
  182. package/dist/workflow/team/types.js.map +0 -1
  183. package/dist/workflow/templates.d.ts +0 -71
  184. package/dist/workflow/templates.d.ts.map +0 -1
  185. package/dist/workflow/templates.js +0 -132
  186. package/dist/workflow/templates.js.map +0 -1
@@ -1,60 +0,0 @@
1
- /**
2
- * @agntk/core - Parallel Workflow Builder
3
- *
4
- * Fan out to multiple agents/workflows concurrently,
5
- * then synthesize the results.
6
- */
7
- import { createLogger } from '@agntk/logger';
8
- const log = createLogger('@agntk/core:workflow:parallel');
9
- /**
10
- * Create a parallel workflow that fans out to multiple steps concurrently.
11
- * All steps receive the same input prompt. Results are merged by the synthesize function.
12
- *
13
- * @example
14
- * ```typescript
15
- * const parallel = createParallel({
16
- * name: 'multi-analysis',
17
- * steps: [securityAgent, performanceAgent, codeQualityAgent],
18
- * synthesize: (outputs) => ({
19
- * text: outputs.map(o => o.text).join('\n\n---\n\n'),
20
- * }),
21
- * });
22
- * const result = await parallel.execute({ prompt: 'Analyze this codebase' });
23
- * ```
24
- */
25
- export function createParallel(config) {
26
- const { name = 'parallel', steps, synthesize } = config;
27
- if (steps.length === 0) {
28
- throw new Error('Parallel workflow must have at least one step');
29
- }
30
- return {
31
- name,
32
- stepCount: steps.length,
33
- async execute(input) {
34
- log.info('Parallel started', { name, stepCount: steps.length, promptLength: input.prompt.length });
35
- const results = await Promise.allSettled(steps.map((step, i) => {
36
- log.debug('Parallel step launched', { name, step: i + 1 });
37
- return step.execute(input);
38
- }));
39
- const outputs = [];
40
- for (let i = 0; i < results.length; i++) {
41
- const result = results[i];
42
- if (result.status === 'fulfilled') {
43
- outputs.push(result.value);
44
- }
45
- else {
46
- log.error('Parallel step failed', { name, step: i + 1, error: String(result.reason) });
47
- outputs.push({
48
- text: `[Step ${i + 1} failed: ${result.reason instanceof Error ? result.reason.message : String(result.reason)}]`,
49
- metadata: { error: true },
50
- });
51
- }
52
- }
53
- log.debug('Synthesizing parallel outputs', { name, outputCount: outputs.length });
54
- const synthesized = await synthesize(outputs);
55
- log.info('Parallel completed', { name, textLength: synthesized.text.length });
56
- return synthesized;
57
- },
58
- };
59
- }
60
- //# sourceMappingURL=parallel.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"parallel.js","sourceRoot":"","sources":["../../../src/workflow/builders/parallel.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAG7C,MAAM,GAAG,GAAG,YAAY,CAAC,+BAA+B,CAAC,CAAC;AAE1D;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,cAAc,CAAC,MAAsB;IACnD,MAAM,EAAE,IAAI,GAAG,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE,GAAG,MAAM,CAAC;IAExD,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;IACnE,CAAC;IAED,OAAO;QACL,IAAI;QACJ,SAAS,EAAE,KAAK,CAAC,MAAM;QAEvB,KAAK,CAAC,OAAO,CAAC,KAA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EAAE,IAAI,EAAE;qBAC1B,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;YAED,GAAG,CAAC,KAAK,CAAC,+BAA+B,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;YAClF,MAAM,WAAW,GAAG,MAAM,UAAU,CAAC,OAAO,CAAC,CAAC;YAE9C,GAAG,CAAC,IAAI,CAAC,oBAAoB,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,WAAW,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;YAE9E,OAAO,WAAW,CAAC;QACrB,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -1,22 +0,0 @@
1
- /**
2
- * @agntk/core - Pipeline Workflow Builder
3
- *
4
- * Chain agents/workflows sequentially. Each step's output
5
- * becomes the next step's input prompt.
6
- */
7
- import type { Workflow, PipelineConfig } from './types.js';
8
- /**
9
- * Create a pipeline that chains steps sequentially.
10
- * Each step's text output becomes the next step's prompt.
11
- *
12
- * @example
13
- * ```typescript
14
- * const pipeline = createPipeline({
15
- * name: 'research-then-write',
16
- * steps: [researchAgent, writerAgent],
17
- * });
18
- * const result = await pipeline.execute({ prompt: 'Write about quantum computing' });
19
- * ```
20
- */
21
- export declare function createPipeline(config: PipelineConfig): Workflow;
22
- //# sourceMappingURL=pipeline.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"pipeline.d.ts","sourceRoot":"","sources":["../../../src/workflow/builders/pipeline.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,QAAQ,EAAiC,cAAc,EAAE,MAAM,SAAS,CAAC;AAIvF;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,cAAc,GAAG,QAAQ,CAkC/D"}
@@ -1,48 +0,0 @@
1
- /**
2
- * @agntk/core - Pipeline Workflow Builder
3
- *
4
- * Chain agents/workflows sequentially. Each step's output
5
- * becomes the next step's input prompt.
6
- */
7
- import { createLogger } from '@agntk/logger';
8
- const log = createLogger('@agntk/core:workflow:pipeline');
9
- /**
10
- * Create a pipeline that chains steps sequentially.
11
- * Each step's text output becomes the next step's prompt.
12
- *
13
- * @example
14
- * ```typescript
15
- * const pipeline = createPipeline({
16
- * name: 'research-then-write',
17
- * steps: [researchAgent, writerAgent],
18
- * });
19
- * const result = await pipeline.execute({ prompt: 'Write about quantum computing' });
20
- * ```
21
- */
22
- export function createPipeline(config) {
23
- const { name = 'pipeline', steps, transform } = config;
24
- if (steps.length === 0) {
25
- throw new Error('Pipeline must have at least one step');
26
- }
27
- return {
28
- name,
29
- stepCount: steps.length,
30
- async execute(input) {
31
- log.info('Pipeline started', { name, stepCount: steps.length, promptLength: input.prompt.length });
32
- let currentOutput = { text: input.prompt };
33
- for (let i = 0; i < steps.length; i++) {
34
- const step = steps[i];
35
- const prompt = i === 0
36
- ? input.prompt
37
- : transform
38
- ? transform(currentOutput, i)
39
- : currentOutput.text;
40
- log.debug('Pipeline step', { name, step: i + 1, total: steps.length, promptLength: prompt.length });
41
- currentOutput = await step.execute({ prompt });
42
- }
43
- log.info('Pipeline completed', { name, textLength: currentOutput.text.length });
44
- return currentOutput;
45
- },
46
- };
47
- }
48
- //# sourceMappingURL=pipeline.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"pipeline.js","sourceRoot":"","sources":["../../../src/workflow/builders/pipeline.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAG7C,MAAM,GAAG,GAAG,YAAY,CAAC,+BAA+B,CAAC,CAAC;AAE1D;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,cAAc,CAAC,MAAsB;IACnD,MAAM,EAAE,IAAI,GAAG,UAAU,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,MAAM,CAAC;IAEvD,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,MAAM,IAAI,K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verview Types for workflow builders (Pipeline, Parallel).
3
- */
4
- /**
5
- * A Workflow step that can execute with a prompt and return text.
6
- * Compatible with the Agent interface so agents and workflows are interchangeable.
7
- */
8
- export interface WorkflowStep {
9
- /** Execute the step with a prompt. */
10
- execute: (input: WorkflowInput) => Promise<WorkflowOutput>;
11
- }
12
- /** Input to a workflow step. */
13
- export interface WorkflowInput {
14
- prompt: string;
15
- }
16
- /** Output from a workflow step. */
17
- export interface WorkflowOutput {
18
- text: string;
19
- metadata?: Record<string, unknown>;
20
- }
21
- /**
22
- * A Workflow that composes multiple steps.
23
- * Implements WorkflowStep so it can nest inside other workflows.
24
- */
25
- export interface Workflow extends WorkflowStep {
26
- /** Name of this workflow. */
27
- name: string;
28
- /** Number of steps in this workflow. */
29
- stepCount: number;
30
- }
31
- /**
32
- * Synthesize function for parallel workflows.
33
- * Receives all outputs and produces a merged result.
34
- */
35
- export type SynthesizeFn = (outputs: WorkflowOutput[]) => WorkflowOutput | Promise<WorkflowOutput>;
36
- /** Configuration for createPipeline. */
37
- export interface PipelineConfig {
38
- /** Pipeline name. */
39
- name?: string;
40
- /** Steps to execute sequentially. */
41
- steps: WorkflowStep[];
42
- /** Optional transform between steps (receives previous output, returns next prompt). */
43
- transform?: (output: WorkflowOutput, stepIndex: number) => string;
44
- }
45
- /** Configuration for createParallel. */
46
- export interface ParallelConfig {
47
- /** Parallel workflow name. */
48
- name?: string;
49
- /** Steps to execute concurrently. */
50
- steps: WorkflowStep[];
51
- /** Function to synthesize/merge parallel outputs. */
52
- synthesize: SynthesizeFn;
53
- }
54
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/workflow/builders/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,sCAAsC;IACtC,OAAO,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,OAAO,CAAC,cAAc,CAAC,CAAC;CAC5D;AAED,gCAAgC;AAChC,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,mCAAmC;AACnC,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED;;;GAGG;AACH,MAAM,WAAW,QAAS,SAAQ,YAAY;IAC5C,6BAA6B;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,wCAAwC;IACxC,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,EAAE,cAAc,EAAE,KAAK,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;AAEnG,wCAAwC;AACxC,MAAM,WAAW,cAAc;IAC7B,qBAAqB;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,qCAAqC;IACrC,KAAK,EAAE,YAAY,EAAE,CAAC;IACtB,wFAAwF;IACxF,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,KAAK,MAAM,CAAC;CACnE;AAED,wCAAwC;AACxC,MAAM,WAAW,cAAc;IAC7B,8BAA8B;IAC9B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,qCAAqC;IACrC,KAAK,EAAE,YAAY,EAAE,CAAC;IACtB,qDAAqD;IACrD,UAAU,EAAE,YAAY,CAAC;CAC1B"}
@@ -1,5 +0,0 @@
1
- /**
2
- * @fileoverview Types for workflow builders (Pipeline, Parallel).
3
- */
4
- export {};
5
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/workflow/builders/types.ts"],"names":[],"mappings":"AAAA;;GAEG"}
@@ -1,231 +0,0 @@
1
- /**
2
- * @agntk/core - Scheduled Workflows
3
- *
4
- * Implements recurring task execution using Workflow DevKit's `sleep()`.
5
- * Each scheduled workflow is a durable loop: execute → sleep → repeat.
6
- * Zero compute cost during sleep — the workflow runtime suspends the process.
7
- *
8
- * @see ADV-SCHEDULER-018
9
- * @see https://useworkflow.dev
10
- */
11
- import { parseDuration, formatDuration } from './utils.js';
12
- /**
13
- * Configuration for a scheduled workflow.
14
- *
15
- * @typeParam T - The return type of the task function
16
- */
17
- export interface ScheduledWorkflowConfig<T = void> {
18
- /** Human-readable name for this schedule. */
19
- name: string;
20
- /** Description of what the scheduled task does. */
21
- description?: string;
22
- /**
23
- * Interval between executions.
24
- * Duration string (e.g., "1h", "1d", "7d").
25
- */
26
- interval: string;
27
- /**
28
- * The task to execute on each tick.
29
- * Receives the current iteration number (0-indexed) and returns a result.
30
- */
31
- task: (iteration: number) => Promise<T> | T;
32
- /**
33
- * Maximum number of iterations before the workflow stops.
34
- * Omit or set to `Infinity` for an infinite loop.
35
- * @default Infinity
36
- */
37
- maxIterations?: number;
38
- /**
39
- * Whether to run the task immediately on start, or wait for the first interval.
40
- * @default true
41
- */
42
- immediate?: boolean;
43
- /**
44
- * Called after each successful task execution.
45
- */
46
- onTick?: (result: T, iteration: number) => void | Promise<void>;
47
- /**
48
- * Called when a task execution throws an error.
49
- * Return `true` to continue the schedule despite the error (default).
50
- * Return `false` to stop the schedule.
51
- * @default continue
52
- */
53
- onError?: (error: Error, iteration: number) => boolean | Promise<boolean>;
54
- }
55
- /**
56
- * A running scheduled workflow instance.
57
- *
58
- * @typeParam T - The return type of the task function
59
- */
60
- export interface ScheduledWorkflow<T = void> {
61
- /** The schedule configuration name. */
62
- readonly name: string;
63
- /** The schedule configuration description. */
64
- readonly description?: string;
65
- /** The interval between executions. */
66
- readonly interval: string;
67
- /**
68
- * Start the schedule loop. Returns a promise that resolves
69
- * when the schedule completes (hits maxIterations or is cancelled).
70
- */
71
- start: () => Promise<ScheduleResult<T>>;
72
- /**
73
- * Cancel the schedule. The current sleep will be interrupted,
74
- * and the loop will exit after the current tick completes.
75
- */
76
- cancel: () => void;
77
- /** Whether the schedule is currently running. */
78
- readonly isRunning: boolean;
79
- /** Number of completed iterations. */
80
- readonly completedIterations: number;
81
- /** Results from completed iterations. */
82
- readonly results: ScheduleTickResult<T>[];
83
- }
84
- /**
85
- * Result from a single scheduled tick.
86
- */
87
- export interface ScheduleTickResult<T = void> {
88
- /** 0-indexed iteration number. */
89
- iteration: number;
90
- /** Whether the tick succeeded. */
91
- success: boolean;
92
- /** The result value (if success). */
93
- result?: T;
94
- /** The error message (if failed). */
95
- error?: string;
96
- /** Timestamp when the tick completed. */
97
- completedAt: Date;
98
- }
99
- /**
100
- * Final result from a completed schedule.
101
- */
102
- export interface ScheduleResult<T = void> {
103
- /** Schedule name. */
104
- name: string;
105
- /** Total completed iterations. */
106
- totalIterations: number;
107
- /** Whether the schedule was cancelled. */
108
- cancelled: boolean;
109
- /** All tick results. */
110
- ticks: ScheduleTickResult<T>[];
111
- }
112
- /**
113
- * Create a scheduled workflow that loops with durable sleep.
114
- *
115
- * The workflow executes a task, sleeps for the configured interval,
116
- * and repeats. Under the Workflow runtime, sleep is zero-compute.
117
- *
118
- * @param config - Schedule configuration
119
- * @returns A `ScheduledWorkflow` instance (call `.start()` to begin)
120
- *
121
- * @example
122
- * ```typescript
123
- * const daily = createScheduledWorkflow({
124
- * name: 'daily-briefing',
125
- * interval: '1d',
126
- * task: async (iteration) => {
127
- * const agent = createAgent({ role: 'analyst' });
128
- * const result = await agent.generate({
129
- * prompt: 'Generate a daily briefing summary.',
130
- * });
131
- * return result.text;
132
- * },
133
- * onTick: (text, i) => console.log(`Briefing #${i}:`, text),
134
- * });
135
- *
136
- * await daily.start(); // Loops forever with 1d sleep between ticks
137
- * ```
138
- */
139
- export declare function createScheduledWorkflow<T = void>(config: ScheduledWorkflowConfig<T>): ScheduledWorkflow<T>;
140
- /**
141
- * Options for the daily briefing schedule preset.
142
- */
143
- export interface DailyBriefingOptions {
144
- /**
145
- * The task that generates the briefing content.
146
- * Receives the iteration number.
147
- */
148
- generateBriefing: (iteration: number) => Promise<string>;
149
- /**
150
- * Called with each briefing (e.g., send email, post to Slack).
151
- */
152
- deliver: (briefing: string, iteration: number) => void | Promise<void>;
153
- /**
154
- * Override the default interval. Default: "1d"
155
- */
156
- interval?: string;
157
- /**
158
- * Maximum number of briefings. Default: Infinity
159
- */
160
- maxIterations?: number;
161
- }
162
- /**
163
- * Create a daily briefing scheduled workflow.
164
- *
165
- * Runs a briefing generation task once per day (configurable),
166
- * delivering the result via a callback.
167
- *
168
- * @example
169
- * ```typescript
170
- * const briefing = createDailyBriefing({
171
- * generateBriefing: async () => {
172
- * const agent = createAgent({ role: 'analyst' });
173
- * const result = await agent.generate({
174
- * prompt: 'Summarize today\'s calendar, emails, and tasks.',
175
- * });
176
- * return result.text;
177
- * },
178
- * deliver: (text) => sendSlackMessage('#daily', text),
179
- * });
180
- *
181
- * await briefing.start();
182
- * ```
183
- */
184
- export declare function createDailyBriefing(options: DailyBriefingOptions): ScheduledWorkflow<string>;
185
- /**
186
- * Options for the weekly report schedule preset.
187
- */
188
- export interface WeeklyReportOptions {
189
- /**
190
- * The task that generates the weekly report.
191
- * Receives the iteration (week) number.
192
- */
193
- generateReport: (week: number) => Promise<string>;
194
- /**
195
- * Called with each report (e.g., send email, save to file).
196
- */
197
- deliver: (report: string, week: number) => void | Promise<void>;
198
- /**
199
- * Override the default interval. Default: "7d"
200
- */
201
- interval?: string;
202
- /**
203
- * Maximum number of reports. Default: Infinity
204
- */
205
- maxIterations?: number;
206
- }
207
- /**
208
- * Create a weekly report scheduled workflow.
209
- *
210
- * Runs a report generation task once per week (configurable),
211
- * delivering the result via a callback.
212
- *
213
- * @example
214
- * ```typescript
215
- * const report = createWeeklyReport({
216
- * generateReport: async (week) => {
217
- * const agent = createAgent({ role: 'analyst' });
218
- * const result = await agent.generate({
219
- * prompt: `Generate weekly report #${week + 1}.`,
220
- * });
221
- * return result.text;
222
- * },
223
- * deliver: (text) => sendEmail('team@company.com', 'Weekly Report', text),
224
- * });
225
- *
226
- * await report.start();
227
- * ```
228
- */
229
- export declare function createWeeklyReport(options: WeeklyReportOptions): ScheduledWorkflow<string>;
230
- export { parseDuration, formatDuration };
231
- //# sourceMappingURL=schedulers.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"schedulers.d.ts","sourceRoot":"","sources":["../../src/workflow/schedulers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAQxD;;;;GAIG;AACH,MAAM,WAAW,uBAAuB,CAAC,CAAC,GAAG,IAAI;IAC/C,6CAA6C;IAC7C,IAAI,EAAE,MAAM,CAAC;IAEb,mDAAmD;IACnD,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAC;IAEjB;;;OAGG;IACH,IAAI,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IAE5C;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB;;OAEG;IACH,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,EAAE,SAAS,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEhE;;;;;OAKG;IACH,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAC3E;AAED;;;;GAIG;AACH,MAAM,WAAW,iBAAiB,CAAC,CAAC,GAAG,IAAI;IACzC,uCAAuC;IACvC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,8CAA8C;IAC9C,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAE9B,uCAAuC;IACvC,QAAQ,CAAC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