@agntk/core 0.3.5 → 1.0.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.
- package/dist/advanced/index.d.ts +13 -22
- package/dist/advanced/index.d.ts.map +1 -1
- package/dist/advanced/index.js +10 -55
- package/dist/advanced/index.js.map +1 -1
- package/dist/agent-v2.d.ts +48 -0
- package/dist/agent-v2.d.ts.map +1 -0
- package/dist/agent-v2.js +365 -0
- package/dist/agent-v2.js.map +1 -0
- package/dist/agent.d.ts +0 -40
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +101 -101
- package/dist/agent.js.map +1 -1
- package/dist/config/defaults.d.ts +1 -5
- package/dist/config/defaults.d.ts.map +1 -1
- package/dist/config/defaults.js +1 -11
- package/dist/config/defaults.js.map +1 -1
- package/dist/config/index.d.ts +5 -1
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +7 -7
- package/dist/config/index.js.map +1 -1
- package/dist/config/loader.d.ts +0 -40
- package/dist/config/loader.d.ts.map +1 -1
- package/dist/config/loader.js +3 -80
- package/dist/config/loader.js.map +1 -1
- package/dist/config/schema.d.ts +117 -788
- package/dist/config/schema.d.ts.map +1 -1
- package/dist/config/schema.js +52 -63
- package/dist/config/schema.js.map +1 -1
- package/dist/constants.d.ts +0 -11
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +0 -17
- package/dist/constants.js.map +1 -1
- package/dist/evals/assertions.d.ts +0 -35
- package/dist/evals/assertions.d.ts.map +1 -1
- package/dist/evals/assertions.js +0 -51
- package/dist/evals/assertions.js.map +1 -1
- package/dist/evals/index.d.ts +0 -5
- package/dist/evals/index.d.ts.map +1 -1
- package/dist/evals/index.js +0 -5
- package/dist/evals/index.js.map +1 -1
- package/dist/evals/runner.d.ts +0 -27
- package/dist/evals/runner.d.ts.map +1 -1
- package/dist/evals/runner.js +3 -45
- package/dist/evals/runner.js.map +1 -1
- package/dist/evals/types.d.ts +0 -14
- package/dist/evals/types.d.ts.map +1 -1
- package/dist/evals/types.js +0 -3
- package/dist/evals/types.js.map +1 -1
- package/dist/guardrails/built-ins.d.ts +0 -28
- package/dist/guardrails/built-ins.d.ts.map +1 -1
- package/dist/guardrails/built-ins.js +21 -47
- package/dist/guardrails/built-ins.js.map +1 -1
- package/dist/guardrails/index.d.ts +1 -4
- package/dist/guardrails/index.d.ts.map +1 -1
- package/dist/guardrails/index.js +1 -4
- package/dist/guardrails/index.js.map +1 -1
- package/dist/guardrails/runner.d.ts +0 -30
- package/dist/guardrails/runner.d.ts.map +1 -1
- package/dist/guardrails/runner.js +1 -46
- package/dist/guardrails/runner.js.map +1 -1
- package/dist/guardrails/types.d.ts +0 -35
- package/dist/guardrails/types.d.ts.map +1 -1
- package/dist/guardrails/types.js +4 -7
- package/dist/guardrails/types.js.map +1 -1
- package/dist/index.d.ts +1 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -29
- package/dist/index.js.map +1 -1
- package/dist/memory/engine.d.ts +130 -0
- package/dist/memory/engine.d.ts.map +1 -0
- package/dist/memory/engine.js +227 -0
- package/dist/memory/engine.js.map +1 -0
- package/dist/memory/loader.d.ts +0 -17
- package/dist/memory/loader.d.ts.map +1 -1
- package/dist/memory/loader.js +5 -27
- package/dist/memory/loader.js.map +1 -1
- package/dist/memory/store.d.ts +8 -16
- package/dist/memory/store.d.ts.map +1 -1
- package/dist/memory/store.js +101 -32
- package/dist/memory/store.js.map +1 -1
- package/dist/memory/types.d.ts +10 -30
- package/dist/memory/types.d.ts.map +1 -1
- package/dist/memory/types.js +0 -6
- package/dist/memory/types.js.map +1 -1
- package/dist/memory/vectra-store.d.ts +31 -0
- package/dist/memory/vectra-store.d.ts.map +1 -0
- package/dist/memory/vectra-store.js +122 -0
- package/dist/memory/vectra-store.js.map +1 -0
- package/dist/models.d.ts +9 -32
- package/dist/models.d.ts.map +1 -1
- package/dist/models.js +25 -68
- package/dist/models.js.map +1 -1
- package/dist/observability/index.d.ts +0 -3
- package/dist/observability/index.d.ts.map +1 -1
- package/dist/observability/index.js +0 -3
- package/dist/observability/index.js.map +1 -1
- package/dist/observability/langfuse.d.ts +0 -38
- package/dist/observability/langfuse.d.ts.map +1 -1
- package/dist/observability/langfuse.js +6 -55
- package/dist/observability/langfuse.js.map +1 -1
- package/dist/observability/types.d.ts +0 -21
- package/dist/observability/types.d.ts.map +1 -1
- package/dist/observability/types.js +0 -3
- package/dist/observability/types.js.map +1 -1
- package/dist/pool/index.d.ts +7 -0
- package/dist/pool/index.d.ts.map +1 -0
- package/dist/pool/index.js +6 -0
- package/dist/pool/index.js.map +1 -0
- package/dist/pool/specialist-pool.d.ts +59 -0
- package/dist/pool/specialist-pool.d.ts.map +1 -0
- package/dist/pool/specialist-pool.js +224 -0
- package/dist/pool/specialist-pool.js.map +1 -0
- package/dist/pool/tools.d.ts +63 -0
- package/dist/pool/tools.d.ts.map +1 -0
- package/dist/pool/tools.js +83 -0
- package/dist/pool/tools.js.map +1 -0
- package/dist/pool/types.d.ts +79 -0
- package/dist/pool/types.d.ts.map +1 -0
- package/dist/pool/types.js +5 -0
- package/dist/pool/types.js.map +1 -0
- package/dist/presets/index.d.ts +5 -0
- package/dist/presets/index.d.ts.map +1 -0
- package/dist/presets/index.js +5 -0
- package/dist/presets/index.js.map +1 -0
- package/dist/presets/role-registry.d.ts +41 -0
- package/dist/presets/role-registry.d.ts.map +1 -0
- package/dist/presets/role-registry.js +213 -0
- package/dist/presets/role-registry.js.map +1 -0
- package/dist/presets/roles.d.ts +105 -0
- package/dist/presets/roles.d.ts.map +1 -0
- package/dist/presets/roles.js +207 -0
- package/dist/presets/roles.js.map +1 -0
- package/dist/presets/tool-preset-registry.d.ts +0 -21
- package/dist/presets/tool-preset-registry.d.ts.map +1 -1
- package/dist/presets/tool-preset-registry.js +15 -34
- package/dist/presets/tool-preset-registry.js.map +1 -1
- package/dist/presets/tools.d.ts +41 -39
- package/dist/presets/tools.d.ts.map +1 -1
- package/dist/presets/tools.js +46 -40
- package/dist/presets/tools.js.map +1 -1
- package/dist/prompts/context.d.ts +0 -4
- package/dist/prompts/context.d.ts.map +1 -1
- package/dist/prompts/context.js +21 -33
- package/dist/prompts/context.js.map +1 -1
- package/dist/prompts/template.d.ts +0 -11
- package/dist/prompts/template.d.ts.map +1 -1
- package/dist/prompts/template.js +4 -14
- package/dist/prompts/template.js.map +1 -1
- package/dist/prompts/templates.d.ts +11 -0
- package/dist/prompts/templates.d.ts.map +1 -0
- package/dist/prompts/templates.js +115 -0
- package/dist/prompts/templates.js.map +1 -0
- package/dist/provider-resolver.d.ts +0 -29
- package/dist/provider-resolver.d.ts.map +1 -1
- package/dist/provider-resolver.js +17 -61
- package/dist/provider-resolver.js.map +1 -1
- package/dist/reflection.d.ts +0 -34
- package/dist/reflection.d.ts.map +1 -1
- package/dist/reflection.js +0 -40
- package/dist/reflection.js.map +1 -1
- package/dist/skills/index.d.ts +0 -3
- package/dist/skills/index.d.ts.map +1 -1
- package/dist/skills/index.js +0 -3
- package/dist/skills/index.js.map +1 -1
- package/dist/skills/loader.d.ts +0 -69
- package/dist/skills/loader.d.ts.map +1 -1
- package/dist/skills/loader.js +38 -130
- package/dist/skills/loader.js.map +1 -1
- package/dist/skills/types.d.ts +0 -36
- package/dist/skills/types.d.ts.map +1 -1
- package/dist/skills/types.js +0 -4
- package/dist/skills/types.js.map +1 -1
- package/dist/streaming/data-parts.d.ts +163 -0
- package/dist/streaming/data-parts.d.ts.map +1 -0
- package/dist/streaming/data-parts.js +14 -0
- package/dist/streaming/data-parts.js.map +1 -0
- package/dist/streaming/index.d.ts +8 -0
- package/dist/streaming/index.d.ts.map +1 -0
- package/dist/streaming/index.js +10 -0
- package/dist/streaming/index.js.map +1 -0
- package/dist/streaming/transient.d.ts +136 -0
- package/dist/streaming/transient.d.ts.map +1 -0
- package/dist/streaming/transient.js +201 -0
- package/dist/streaming/transient.js.map +1 -0
- package/dist/system-detect.d.ts +0 -57
- package/dist/system-detect.d.ts.map +1 -1
- package/dist/system-detect.js +9 -114
- package/dist/system-detect.js.map +1 -1
- package/dist/tools/approval.d.ts +0 -47
- package/dist/tools/approval.d.ts.map +1 -1
- package/dist/tools/approval.js +0 -46
- package/dist/tools/approval.js.map +1 -1
- package/dist/tools/ast-grep/cli.d.ts.map +1 -1
- package/dist/tools/ast-grep/cli.js +10 -4
- package/dist/tools/ast-grep/cli.js.map +1 -1
- package/dist/tools/ast-grep/constants.d.ts.map +1 -1
- package/dist/tools/ast-grep/constants.js +7 -14
- package/dist/tools/ast-grep/constants.js.map +1 -1
- package/dist/tools/ast-grep/downloader.d.ts.map +1 -1
- package/dist/tools/ast-grep/downloader.js +1 -4
- package/dist/tools/ast-grep/downloader.js.map +1 -1
- package/dist/tools/ast-grep/index.d.ts +2 -2
- package/dist/tools/ast-grep/index.d.ts.map +1 -1
- package/dist/tools/ast-grep/index.js +1 -1
- package/dist/tools/ast-grep/index.js.map +1 -1
- package/dist/tools/ast-grep/tools.d.ts +4 -4
- package/dist/tools/ast-grep/tools.d.ts.map +1 -1
- package/dist/tools/ast-grep/tools.js +2 -8
- package/dist/tools/ast-grep/tools.js.map +1 -1
- package/dist/tools/browser/index.d.ts +4 -4
- package/dist/tools/browser/index.d.ts.map +1 -1
- package/dist/tools/browser/index.js +2 -3
- package/dist/tools/browser/index.js.map +1 -1
- package/dist/tools/browser/stream.d.ts +0 -32
- package/dist/tools/browser/stream.d.ts.map +1 -1
- package/dist/tools/browser/stream.js +0 -53
- package/dist/tools/browser/stream.js.map +1 -1
- package/dist/tools/browser/tool.d.ts +10 -15
- package/dist/tools/browser/tool.d.ts.map +1 -1
- package/dist/tools/browser/tool.js +2 -26
- package/dist/tools/browser/tool.js.map +1 -1
- package/dist/tools/browser/types.d.ts +31 -156
- package/dist/tools/browser/types.d.ts.map +1 -1
- package/dist/tools/browser/types.js +22 -17
- package/dist/tools/browser/types.js.map +1 -1
- package/dist/tools/deep-reasoning/constants.d.ts +0 -6
- package/dist/tools/deep-reasoning/constants.d.ts.map +1 -1
- package/dist/tools/deep-reasoning/constants.js +0 -6
- package/dist/tools/deep-reasoning/constants.js.map +1 -1
- package/dist/tools/deep-reasoning/engine.d.ts.map +1 -1
- package/dist/tools/deep-reasoning/engine.js +0 -1
- package/dist/tools/deep-reasoning/engine.js.map +1 -1
- package/dist/tools/deep-reasoning/index.d.ts +4 -0
- package/dist/tools/deep-reasoning/index.d.ts.map +1 -1
- package/dist/tools/deep-reasoning/index.js +4 -3
- package/dist/tools/deep-reasoning/index.js.map +1 -1
- package/dist/tools/deep-reasoning/tools.d.ts.map +1 -1
- package/dist/tools/deep-reasoning/tools.js +8 -1
- package/dist/tools/deep-reasoning/tools.js.map +1 -1
- package/dist/tools/deep-reasoning/types.d.ts +5 -30
- package/dist/tools/deep-reasoning/types.d.ts.map +1 -1
- package/dist/tools/deep-reasoning/types.js +10 -1
- package/dist/tools/deep-reasoning/types.js.map +1 -1
- package/dist/tools/factory.d.ts +109 -0
- package/dist/tools/factory.d.ts.map +1 -0
- package/dist/tools/factory.js +166 -0
- package/dist/tools/factory.js.map +1 -0
- package/dist/tools/file/index.d.ts +3 -5
- package/dist/tools/file/index.d.ts.map +1 -1
- package/dist/tools/file/index.js +2 -4
- package/dist/tools/file/index.js.map +1 -1
- package/dist/tools/file/tools.d.ts +8 -11
- package/dist/tools/file/tools.d.ts.map +1 -1
- package/dist/tools/file/tools.js +45 -59
- package/dist/tools/file/tools.js.map +1 -1
- package/dist/tools/glob/cli.d.ts.map +1 -1
- package/dist/tools/glob/cli.js +8 -6
- package/dist/tools/glob/cli.js.map +1 -1
- package/dist/tools/glob/tools.d.ts.map +1 -1
- package/dist/tools/glob/tools.js +7 -10
- package/dist/tools/glob/tools.js.map +1 -1
- package/dist/tools/grep/cli.d.ts.map +1 -1
- package/dist/tools/grep/cli.js +0 -2
- package/dist/tools/grep/cli.js.map +1 -1
- package/dist/tools/grep/constants.d.ts.map +1 -1
- package/dist/tools/grep/constants.js +3 -5
- package/dist/tools/grep/constants.js.map +1 -1
- package/dist/tools/grep/downloader.d.ts.map +1 -1
- package/dist/tools/grep/downloader.js +3 -3
- package/dist/tools/grep/downloader.js.map +1 -1
- package/dist/tools/grep/tools.d.ts +2 -2
- package/dist/tools/grep/tools.d.ts.map +1 -1
- package/dist/tools/grep/tools.js +8 -14
- package/dist/tools/grep/tools.js.map +1 -1
- package/dist/tools/index.d.ts +10 -11
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +9 -22
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/model-retry.d.ts +0 -40
- package/dist/tools/model-retry.d.ts.map +1 -1
- package/dist/tools/model-retry.js +1 -49
- package/dist/tools/model-retry.js.map +1 -1
- package/dist/tools/plan/constants.d.ts +0 -6
- package/dist/tools/plan/constants.d.ts.map +1 -1
- package/dist/tools/plan/constants.js +9 -6
- package/dist/tools/plan/constants.js.map +1 -1
- package/dist/tools/plan/index.d.ts +1 -1
- package/dist/tools/plan/index.d.ts.map +1 -1
- package/dist/tools/plan/index.js +1 -4
- package/dist/tools/plan/index.js.map +1 -1
- package/dist/tools/plan/tools.d.ts +2 -2
- package/dist/tools/plan/tools.d.ts.map +1 -1
- package/dist/tools/plan/tools.js +10 -11
- package/dist/tools/plan/tools.js.map +1 -1
- package/dist/tools/plan/types.d.ts +22 -32
- package/dist/tools/plan/types.d.ts.map +1 -1
- package/dist/tools/plan/types.js +11 -3
- package/dist/tools/plan/types.js.map +1 -1
- package/dist/tools/progress/index.d.ts +3 -22
- package/dist/tools/progress/index.d.ts.map +1 -1
- package/dist/tools/progress/index.js +19 -34
- package/dist/tools/progress/index.js.map +1 -1
- package/dist/tools/provider.d.ts +97 -0
- package/dist/tools/provider.d.ts.map +1 -0
- package/dist/tools/provider.js +178 -0
- package/dist/tools/provider.js.map +1 -0
- package/dist/tools/search-skills.d.ts +0 -23
- package/dist/tools/search-skills.d.ts.map +1 -1
- package/dist/tools/search-skills.js +3 -32
- package/dist/tools/search-skills.js.map +1 -1
- package/dist/tools/shell/background.d.ts +2 -18
- package/dist/tools/shell/background.d.ts.map +1 -1
- package/dist/tools/shell/background.js +45 -48
- package/dist/tools/shell/background.js.map +1 -1
- package/dist/tools/shell/constants.d.ts +0 -3
- package/dist/tools/shell/constants.d.ts.map +1 -1
- package/dist/tools/shell/constants.js +16 -6
- package/dist/tools/shell/constants.js.map +1 -1
- package/dist/tools/shell/index.d.ts +1 -1
- package/dist/tools/shell/index.d.ts.map +1 -1
- package/dist/tools/shell/index.js +1 -1
- package/dist/tools/shell/index.js.map +1 -1
- package/dist/tools/shell/tools.d.ts +3 -3
- package/dist/tools/shell/tools.d.ts.map +1 -1
- package/dist/tools/shell/tools.js +0 -2
- package/dist/tools/shell/tools.js.map +1 -1
- package/dist/tools/shell/types.d.ts +5 -13
- package/dist/tools/shell/types.d.ts.map +1 -1
- package/dist/tools/shell/types.js +10 -1
- package/dist/tools/shell/types.js.map +1 -1
- package/dist/tools/spawn-agent/check-agent.d.ts +45 -0
- package/dist/tools/spawn-agent/check-agent.d.ts.map +1 -0
- package/dist/tools/spawn-agent/check-agent.js +84 -0
- package/dist/tools/spawn-agent/check-agent.js.map +1 -0
- package/dist/tools/spawn-agent/index.d.ts +44 -51
- package/dist/tools/spawn-agent/index.d.ts.map +1 -1
- package/dist/tools/spawn-agent/index.js +196 -84
- package/dist/tools/spawn-agent/index.js.map +1 -1
- package/dist/tools/spawn-agent/registry.d.ts +36 -0
- package/dist/tools/spawn-agent/registry.d.ts.map +1 -0
- package/dist/tools/spawn-agent/registry.js +88 -0
- package/dist/tools/spawn-agent/registry.js.map +1 -0
- package/dist/tools/utils/errors.d.ts +2 -1
- package/dist/tools/utils/errors.d.ts.map +1 -1
- package/dist/tools/utils/errors.js +2 -1
- package/dist/tools/utils/errors.js.map +1 -1
- package/dist/tools/utils/shell.d.ts +0 -11
- package/dist/tools/utils/shell.d.ts.map +1 -1
- package/dist/tools/utils/shell.js +10 -78
- package/dist/tools/utils/shell.js.map +1 -1
- package/dist/tools/utils/tool-result.d.ts +0 -3
- package/dist/tools/utils/tool-result.d.ts.map +1 -1
- package/dist/tools/utils/tool-result.js +4 -4
- package/dist/tools/utils/tool-result.js.map +1 -1
- package/dist/tools/web-search/index.d.ts +4 -0
- package/dist/tools/web-search/index.d.ts.map +1 -0
- package/dist/tools/web-search/index.js +3 -0
- package/dist/tools/web-search/index.js.map +1 -0
- package/dist/tools/web-search/tools.d.ts +17 -0
- package/dist/tools/web-search/tools.d.ts.map +1 -0
- package/dist/tools/web-search/tools.js +81 -0
- package/dist/tools/web-search/tools.js.map +1 -0
- package/dist/tools/web-search/types.d.ts +16 -0
- package/dist/tools/web-search/types.d.ts.map +1 -0
- package/dist/tools/web-search/types.js +29 -0
- package/dist/tools/web-search/types.js.map +1 -0
- package/dist/tools/workspace-middleware.d.ts +14 -0
- package/dist/tools/workspace-middleware.d.ts.map +1 -0
- package/dist/tools/workspace-middleware.js +97 -0
- package/dist/tools/workspace-middleware.js.map +1 -0
- package/dist/types/agent-v2.d.ts +83 -0
- package/dist/types/agent-v2.d.ts.map +1 -0
- package/dist/types/agent-v2.js +8 -0
- package/dist/types/agent-v2.js.map +1 -0
- package/dist/types/agent.d.ts +1 -66
- package/dist/types/agent.d.ts.map +1 -1
- package/dist/types/agent.js +0 -6
- package/dist/types/agent.js.map +1 -1
- package/dist/types/index.d.ts +4 -3
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +3 -3
- package/dist/types/index.js.map +1 -1
- package/dist/types/lifecycle.d.ts +0 -141
- package/dist/types/lifecycle.d.ts.map +1 -1
- package/dist/types/lifecycle.js +4 -54
- package/dist/types/lifecycle.js.map +1 -1
- package/dist/types/streaming.d.ts +0 -4
- package/dist/types/streaming.d.ts.map +1 -1
- package/dist/types/streaming.js +0 -4
- package/dist/types/streaming.js.map +1 -1
- package/dist/usage-limits.d.ts +0 -37
- package/dist/usage-limits.d.ts.map +1 -1
- package/dist/usage-limits.js +1 -40
- package/dist/usage-limits.js.map +1 -1
- package/dist/utils/logger.d.ts +35 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +149 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/workflow/builders/adapt.d.ts +20 -0
- package/dist/workflow/builders/adapt.d.ts.map +1 -0
- package/dist/workflow/builders/adapt.js +33 -0
- package/dist/workflow/builders/adapt.js.map +1 -0
- package/dist/workflow/builders/index.d.ts +8 -0
- package/dist/workflow/builders/index.d.ts.map +1 -0
- package/dist/workflow/builders/index.js +7 -0
- package/dist/workflow/builders/index.js.map +1 -0
- package/dist/workflow/builders/parallel.d.ts +25 -0
- package/dist/workflow/builders/parallel.d.ts.map +1 -0
- package/dist/workflow/builders/parallel.js +60 -0
- package/dist/workflow/builders/parallel.js.map +1 -0
- package/dist/workflow/builders/pipeline.d.ts +22 -0
- package/dist/workflow/builders/pipeline.d.ts.map +1 -0
- package/dist/workflow/builders/pipeline.js +48 -0
- package/dist/workflow/builders/pipeline.js.map +1 -0
- package/dist/workflow/builders/types.d.ts +54 -0
- package/dist/workflow/builders/types.d.ts.map +1 -0
- package/dist/workflow/builders/types.js +5 -0
- package/dist/workflow/builders/types.js.map +1 -0
- package/dist/workflow/durable-agent.d.ts +128 -0
- package/dist/workflow/durable-agent.d.ts.map +1 -0
- package/dist/workflow/durable-agent.js +323 -0
- package/dist/workflow/durable-agent.js.map +1 -0
- package/dist/workflow/durable-tool.d.ts +0 -84
- package/dist/workflow/durable-tool.d.ts.map +1 -1
- package/dist/workflow/durable-tool.js +2 -104
- package/dist/workflow/durable-tool.js.map +1 -1
- package/dist/workflow/hooks.d.ts +0 -215
- package/dist/workflow/hooks.d.ts.map +1 -1
- package/dist/workflow/hooks.js +15 -221
- package/dist/workflow/hooks.js.map +1 -1
- package/dist/workflow/index.d.ts +0 -9
- package/dist/workflow/index.d.ts.map +1 -1
- package/dist/workflow/index.js +0 -12
- package/dist/workflow/index.js.map +1 -1
- package/dist/workflow/schedulers.d.ts +231 -0
- package/dist/workflow/schedulers.d.ts.map +1 -0
- package/dist/workflow/schedulers.js +250 -0
- package/dist/workflow/schedulers.js.map +1 -0
- package/dist/workflow/team/create-team.d.ts +34 -0
- package/dist/workflow/team/create-team.d.ts.map +1 -0
- package/dist/workflow/team/create-team.js +242 -0
- package/dist/workflow/team/create-team.js.map +1 -0
- package/dist/workflow/team/index.d.ts +9 -0
- package/dist/workflow/team/index.d.ts.map +1 -0
- package/dist/workflow/team/index.js +8 -0
- package/dist/workflow/team/index.js.map +1 -0
- package/dist/workflow/team/machines.d.ts +152 -0
- package/dist/workflow/team/machines.d.ts.map +1 -0
- package/dist/workflow/team/machines.js +197 -0
- package/dist/workflow/team/machines.js.map +1 -0
- package/dist/workflow/team/task-board.d.ts +47 -0
- package/dist/workflow/team/task-board.d.ts.map +1 -0
- package/dist/workflow/team/task-board.js +111 -0
- package/dist/workflow/team/task-board.js.map +1 -0
- package/dist/workflow/team/tools.d.ts +66 -0
- package/dist/workflow/team/tools.d.ts.map +1 -0
- package/dist/workflow/team/tools.js +100 -0
- package/dist/workflow/team/tools.js.map +1 -0
- package/dist/workflow/team/types.d.ts +109 -0
- package/dist/workflow/team/types.d.ts.map +1 -0
- package/dist/workflow/team/types.js +5 -0
- package/dist/workflow/team/types.js.map +1 -0
- package/dist/workflow/templates.d.ts +71 -0
- package/dist/workflow/templates.d.ts.map +1 -0
- package/dist/workflow/templates.js +132 -0
- package/dist/workflow/templates.js.map +1 -0
- package/dist/workflow/utils.d.ts +0 -24
- package/dist/workflow/utils.d.ts.map +1 -1
- package/dist/workflow/utils.js +1 -32
- package/dist/workflow/utils.js.map +1 -1
- package/dist/wrappers/best-of-n.d.ts +0 -35
- package/dist/wrappers/best-of-n.d.ts.map +1 -1
- package/dist/wrappers/best-of-n.js +4 -53
- package/dist/wrappers/best-of-n.js.map +1 -1
- package/dist/wrappers/refine-loop.d.ts +36 -0
- package/dist/wrappers/refine-loop.d.ts.map +1 -0
- package/dist/wrappers/refine-loop.js +135 -0
- package/dist/wrappers/refine-loop.js.map +1 -0
- package/package.json +13 -7
|
@@ -1,41 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @agntk/core - Durable Tool Wrapper
|
|
3
|
-
*
|
|
4
|
-
* Wraps tools with durability directives for crash recovery.
|
|
5
|
-
* Uses the Workflow DevKit's "use step" directive to checkpoint tool executions.
|
|
6
|
-
* Each tool step gets a descriptive name for observability in the workflow inspector.
|
|
7
|
-
*
|
|
8
|
-
* @see https://useworkflow.dev
|
|
9
|
-
*/
|
|
10
1
|
import { createLogger } from '@agntk/logger';
|
|
11
2
|
const log = createLogger('@agntk/core:workflow:tool');
|
|
12
|
-
// ============================================================================
|
|
13
|
-
// Single Tool Wrapper
|
|
14
|
-
// ============================================================================
|
|
15
|
-
/**
|
|
16
|
-
* Wrap a single tool with durability directives.
|
|
17
|
-
*
|
|
18
|
-
* When wrapped, the tool's execute function uses the "use step" directive
|
|
19
|
-
* to create a checkpoint. If the process crashes, the workflow runtime
|
|
20
|
-
* resumes from the last checkpoint.
|
|
21
|
-
*
|
|
22
|
-
* Each wrapped tool gets a descriptive step name for the workflow inspector:
|
|
23
|
-
* - Default: "tool-exec-{toolName}"
|
|
24
|
-
* - Custom via `config.stepName`
|
|
25
|
-
*
|
|
26
|
-
* @param tool - The tool to wrap
|
|
27
|
-
* @param config - Durability configuration
|
|
28
|
-
* @param toolName - Name of the tool (used for step naming)
|
|
29
|
-
* @returns Wrapped tool with durability enabled
|
|
30
|
-
*
|
|
31
|
-
* @example
|
|
32
|
-
* ```typescript
|
|
33
|
-
* const durableReadFile = wrapToolAsDurableStep(readFileTool, {
|
|
34
|
-
* retryCount: 3,
|
|
35
|
-
* timeout: '30s',
|
|
36
|
-
* }, 'read_file');
|
|
37
|
-
* ```
|
|
38
|
-
*/
|
|
39
3
|
export function wrapToolAsDurableStep(tool, config = {}, toolName) {
|
|
40
4
|
const { enabled = true } = config;
|
|
41
5
|
if (!enabled) {
|
|
@@ -51,10 +15,7 @@ export function wrapToolAsDurableStep(tool, config = {}, toolName) {
|
|
|
51
15
|
...tool,
|
|
52
16
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
53
17
|
execute: async (input, options) => {
|
|
54
|
-
|
|
55
|
-
// When the workflow resumes after a crash, it skips to this point
|
|
56
|
-
// and returns the cached result instead of re-executing.
|
|
57
|
-
"use step";
|
|
18
|
+
'use step';
|
|
58
19
|
log.debug(`Executing durable step: ${stepName}`, {
|
|
59
20
|
stepName,
|
|
60
21
|
retryCount: config.retryCount,
|
|
@@ -69,52 +30,17 @@ export function wrapToolAsDurableStep(tool, config = {}, toolName) {
|
|
|
69
30
|
log.error(`Durable step failed: ${stepName}`, {
|
|
70
31
|
error: error instanceof Error ? error.message : String(error),
|
|
71
32
|
});
|
|
72
|
-
// Re-throw to let the workflow runtime handle retries
|
|
73
33
|
throw error;
|
|
74
34
|
}
|
|
75
35
|
},
|
|
76
36
|
};
|
|
77
|
-
// Store step name and config as metadata
|
|
78
37
|
setDurabilityConfig(wrappedTool, { ...config, stepName });
|
|
79
38
|
return wrappedTool;
|
|
80
39
|
}
|
|
81
|
-
// ============================================================================
|
|
82
|
-
// Batch Tool Wrapper
|
|
83
|
-
// ============================================================================
|
|
84
|
-
/**
|
|
85
|
-
* Wrap all tools in a set with durability directives.
|
|
86
|
-
* Each tool gets a step name based on its key in the record.
|
|
87
|
-
*
|
|
88
|
-
* @param tools - Record of tools to wrap
|
|
89
|
-
* @param config - Durability configuration applied to all tools
|
|
90
|
-
* @returns Record of wrapped tools
|
|
91
|
-
*
|
|
92
|
-
* @example
|
|
93
|
-
* ```typescript
|
|
94
|
-
* const durableTools = wrapToolsAsDurable(myTools, {
|
|
95
|
-
* retryCount: 3,
|
|
96
|
-
* timeout: '5m',
|
|
97
|
-
* });
|
|
98
|
-
* ```
|
|
99
|
-
*/
|
|
100
40
|
export function wrapToolsAsDurable(tools, config = {}) {
|
|
101
41
|
log.debug('Wrapping all tools as durable', { count: Object.keys(tools).length });
|
|
102
|
-
return Object.fromEntries(Object.entries(tools).map(([name, tool]) => [
|
|
103
|
-
name,
|
|
104
|
-
wrapToolAsDurableStep(tool, config, name),
|
|
105
|
-
]));
|
|
42
|
+
return Object.fromEntries(Object.entries(tools).map(([name, tool]) => [name, wrapToolAsDurableStep(tool, config, name)]));
|
|
106
43
|
}
|
|
107
|
-
// ============================================================================
|
|
108
|
-
// Selective Wrapping
|
|
109
|
-
// ============================================================================
|
|
110
|
-
/**
|
|
111
|
-
* Wrap only specified tools with durability, leaving others unchanged.
|
|
112
|
-
*
|
|
113
|
-
* @param tools - All tools
|
|
114
|
-
* @param toolNames - Names of tools to wrap
|
|
115
|
-
* @param config - Durability configuration
|
|
116
|
-
* @returns Tools with selective durability applied
|
|
117
|
-
*/
|
|
118
44
|
export function wrapSelectedToolsAsDurable(tools, toolNames, config = {}) {
|
|
119
45
|
const nameSet = new Set(toolNames);
|
|
120
46
|
log.debug('Selectively wrapping tools as durable', {
|
|
@@ -126,47 +52,19 @@ export function wrapSelectedToolsAsDurable(tools, toolNames, config = {}) {
|
|
|
126
52
|
nameSet.has(name) ? wrapToolAsDurableStep(tool, config, name) : tool,
|
|
127
53
|
]));
|
|
128
54
|
}
|
|
129
|
-
// ============================================================================
|
|
130
|
-
// Independent Step Wrapper
|
|
131
|
-
// ============================================================================
|
|
132
|
-
/**
|
|
133
|
-
* Wrap a tool as an independent durable step.
|
|
134
|
-
*
|
|
135
|
-
* Independent steps can be executed in parallel with other independent steps.
|
|
136
|
-
* The workflow runtime optimizes by running these concurrently.
|
|
137
|
-
*
|
|
138
|
-
* @param tool - The tool to wrap
|
|
139
|
-
* @param toolName - Name of the tool (used for step naming)
|
|
140
|
-
* @returns Wrapped tool marked as independent
|
|
141
|
-
*/
|
|
142
55
|
export function wrapToolAsIndependentStep(tool, toolName) {
|
|
143
56
|
return wrapToolAsDurableStep(tool, { independent: true }, toolName);
|
|
144
57
|
}
|
|
145
|
-
// ============================================================================
|
|
146
|
-
// Durability Metadata
|
|
147
|
-
// ============================================================================
|
|
148
|
-
/**
|
|
149
|
-
* Symbol for storing durability metadata on tools.
|
|
150
|
-
*/
|
|
151
58
|
export const DURABILITY_CONFIG = Symbol('durabilityConfig');
|
|
152
|
-
/**
|
|
153
|
-
* Get durability configuration from a tool (if set).
|
|
154
|
-
*/
|
|
155
59
|
export function getDurabilityConfig(tool) {
|
|
156
60
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
157
61
|
return tool[DURABILITY_CONFIG];
|
|
158
62
|
}
|
|
159
|
-
/**
|
|
160
|
-
* Set durability configuration on a tool.
|
|
161
|
-
*/
|
|
162
63
|
export function setDurabilityConfig(tool, config) {
|
|
163
64
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
164
65
|
tool[DURABILITY_CONFIG] = config;
|
|
165
66
|
return tool;
|
|
166
67
|
}
|
|
167
|
-
/**
|
|
168
|
-
* Get the step name assigned to a durable tool.
|
|
169
|
-
*/
|
|
170
68
|
export function getStepName(tool) {
|
|
171
69
|
return getDurabilityConfig(tool)?.stepName;
|
|
172
70
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"durable-tool.js","sourceRoot":"","sources":["../../src/workflow/durable-tool.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"durable-tool.js","sourceRoot":"","sources":["../../src/workflow/durable-tool.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C,MAAM,GAAG,GAAG,YAAY,CAAC,2BAA2B,CAAC,CAAC;AAgBtD,MAAM,UAAU,qBAAqB,CACnC,IAAU,EACV,SAA2B,EAAE,EAC7B,QAAiB;IAEjB,MAAM,EAAE,OAAO,GAAG,IAAI,EAAE,GAAG,MAAM,CAAC;IAElC,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,IAAI,CAAC;IACd,CAAC;IAED,8DAA8D;IAC9D,MAAM,eAAe,GAAI,IAAY,CAAC,OAAO,CAAC;IAC9C,I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AAC,CAAC;AAC1C,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,IAAU,EAAE,MAAwB;IACtE,8DAA8D;IAC7D,IAAY,CAAC,iBAAiB,CAAC,GAAG,MAAM,CAAC;IAC1C,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,IAAU;IACpC,OAAO,mBAAmB,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC;AAC7C,CAAC"}
|
package/dist/workflow/hooks.d.ts
CHANGED
|
@@ -1,202 +1,83 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @agntk/core - Workflow Hooks & Human-in-the-Loop
|
|
3
|
-
*
|
|
4
|
-
* Provides typed suspension points for workflow execution.
|
|
5
|
-
* When a hook fires, the workflow pauses (zero compute) and waits for
|
|
6
|
-
* external input — typically a human approval via the `/hooks/:id/resume` endpoint.
|
|
7
|
-
*
|
|
8
|
-
* Uses Vercel's Workflow DevKit (WDK) primitives when available:
|
|
9
|
-
* - `defineHook` → WDK defineHook with Standard Schema validation
|
|
10
|
-
* - `createWebhook` → WDK createWebhook with auto-generated URLs
|
|
11
|
-
* - `sleep` → WDK sleep with zero-compute durable delay
|
|
12
|
-
* - `FatalError` / `RetryableError` → WDK error classes
|
|
13
|
-
*
|
|
14
|
-
* Falls back to in-memory implementation when WDK is not installed.
|
|
15
|
-
*
|
|
16
|
-
* @see SDK-HOOKS-008
|
|
17
|
-
* @see https://useworkflow.dev
|
|
18
|
-
*/
|
|
19
|
-
/**
|
|
20
|
-
* Reset WDK cache (for testing).
|
|
21
|
-
* When `forceNoWdk` is true, marks WDK as already checked but unavailable,
|
|
22
|
-
* preventing the dynamic import from running.
|
|
23
|
-
* @internal
|
|
24
|
-
*/
|
|
25
1
|
export declare function _resetWdkCache(forceNoWdk?: boolean): void;
|
|
26
|
-
/** Status of a hook instance. */
|
|
27
2
|
export type HookStatus = 'pending' | 'resolved' | 'rejected' | 'timed_out';
|
|
28
|
-
/** Configuration for defining a hook factory. */
|
|
29
3
|
export interface HookDefinition<TPayload = unknown, TResult = unknown> {
|
|
30
|
-
/** Human-readable name for this hook type. */
|
|
31
4
|
name: string;
|
|
32
|
-
/** Description of what this hook does / what the human should decide. */
|
|
33
5
|
description?: string;
|
|
34
|
-
/**
|
|
35
|
-
* Timeout duration string (e.g., "30m", "1h").
|
|
36
|
-
* After this time, the hook resolves with `defaultValue`.
|
|
37
|
-
* If no timeout is specified, the hook waits indefinitely.
|
|
38
|
-
*/
|
|
39
6
|
timeout?: string;
|
|
40
|
-
/**
|
|
41
|
-
* Default value returned when the hook times out.
|
|
42
|
-
* Required if `timeout` is specified.
|
|
43
|
-
*/
|
|
44
7
|
defaultValue?: TResult;
|
|
45
|
-
/**
|
|
46
|
-
* Optional validation function for the resume payload.
|
|
47
|
-
* Throw to reject the resume attempt.
|
|
48
|
-
*/
|
|
49
8
|
validate?: (payload: TResult) => void | Promise<void>;
|
|
50
9
|
}
|
|
51
|
-
/** A live hook instance that is waiting for resolution. */
|
|
52
10
|
export interface HookInstance<TPayload = unknown, TResult = unknown> {
|
|
53
|
-
/** Unique ID for this hook instance (maps to WDK token when available). */
|
|
54
11
|
id: string;
|
|
55
|
-
/** Name from the hook definition. */
|
|
56
12
|
name: string;
|
|
57
|
-
/** Description from the hook definition. */
|
|
58
13
|
description?: string;
|
|
59
|
-
/** The payload passed when the hook was created (context for the human). */
|
|
60
14
|
payload: TPayload;
|
|
61
|
-
/** Current status. */
|
|
62
15
|
status: HookStatus;
|
|
63
|
-
/** When this hook was created. */
|
|
64
16
|
createdAt: Date;
|
|
65
|
-
/** When this hook was resolved/rejected/timed out (if applicable). */
|
|
66
17
|
resolvedAt?: Date;
|
|
67
|
-
/** Timeout in ms (undefined = no timeout). */
|
|
68
18
|
timeoutMs?: number;
|
|
69
|
-
/** The result value once resolved. */
|
|
70
19
|
result?: TResult;
|
|
71
20
|
}
|
|
72
|
-
/** A typed hook factory returned by `defineHook()`. */
|
|
73
21
|
export interface Hook<TPayload = unknown, TResult = unknown> {
|
|
74
|
-
/** The hook definition name. */
|
|
75
22
|
readonly name: string;
|
|
76
|
-
/** The hook definition description. */
|
|
77
23
|
readonly description?: string;
|
|
78
|
-
/**
|
|
79
|
-
* Create a suspension point in the workflow.
|
|
80
|
-
* Suspends execution and waits for external input.
|
|
81
|
-
* Under WDK: uses createHook with auto-generated token.
|
|
82
|
-
* Without WDK: uses in-memory HookRegistry.
|
|
83
|
-
*
|
|
84
|
-
* @param payload - Context sent to the human (what they're approving/deciding)
|
|
85
|
-
* @returns The result from the human (or default value on timeout)
|
|
86
|
-
*/
|
|
87
24
|
wait: (payload: TPayload) => Promise<TResult>;
|
|
88
|
-
/**
|
|
89
|
-
* Create a suspension point with an explicit hook ID/token.
|
|
90
|
-
* Useful for deterministic testing or resuming by known ID.
|
|
91
|
-
*/
|
|
92
25
|
waitWithId: (id: string, payload: TPayload) => Promise<TResult>;
|
|
93
26
|
}
|
|
94
|
-
/** Options for creating a webhook suspension point. */
|
|
95
27
|
export interface WebhookOptions {
|
|
96
|
-
/** Unique webhook ID/token. Auto-generated if not provided. */
|
|
97
28
|
id?: string;
|
|
98
|
-
/** URL path for the webhook callback (informational without WDK, auto-generated with WDK). */
|
|
99
29
|
callbackPath?: string;
|
|
100
|
-
/** Timeout for the webhook response. */
|
|
101
30
|
timeout?: string;
|
|
102
|
-
/** Default value if webhook times out. */
|
|
103
31
|
defaultValue?: unknown;
|
|
104
32
|
}
|
|
105
|
-
/** Result from a webhook suspension. */
|
|
106
33
|
export interface WebhookResult<T = unknown> {
|
|
107
|
-
/** The payload received from the webhook callback. */
|
|
108
34
|
data: T;
|
|
109
|
-
/** Whether this was a timeout (data = defaultValue). */
|
|
110
35
|
timedOut: boolean;
|
|
111
|
-
/** The webhook URL (only available when WDK is active). */
|
|
112
36
|
url?: string;
|
|
113
37
|
}
|
|
114
|
-
/** Options for the sleep() function. */
|
|
115
38
|
export interface SleepOptions {
|
|
116
|
-
/** Reason for the sleep (logged for observability). */
|
|
117
39
|
reason?: string;
|
|
118
40
|
}
|
|
119
|
-
/**
|
|
120
|
-
* In-memory registry that tracks active hook instances.
|
|
121
|
-
* Used when WDK is not available. When WDK is active, hooks are managed
|
|
122
|
-
* by the WDK runtime and this registry is only used for tracking metadata.
|
|
123
|
-
*/
|
|
124
41
|
export declare class HookRegistry {
|
|
125
42
|
private hooks;
|
|
126
43
|
private resolvers;
|
|
127
44
|
private validators;
|
|
128
45
|
private timeouts;
|
|
129
|
-
/** Get a hook instance by ID. */
|
|
130
46
|
get(id: string): HookInstance | undefined;
|
|
131
|
-
/** Check if a hook exists. */
|
|
132
47
|
has(id: string): boolean;
|
|
133
|
-
/** Get all hooks, optionally filtered by status. */
|
|
134
48
|
list(status?: HookStatus): HookInstance[];
|
|
135
|
-
/** Get all pending hooks. */
|
|
136
49
|
listPending(): HookInstance[];
|
|
137
|
-
/**
|
|
138
|
-
* Register a new hook instance and return a promise that resolves
|
|
139
|
-
* when the hook is resumed.
|
|
140
|
-
*/
|
|
141
50
|
register<TPayload, TResult>(id: string, name: string, payload: TPayload, options?: {
|
|
142
51
|
description?: string;
|
|
143
52
|
timeoutMs?: number;
|
|
144
53
|
defaultValue?: TResult;
|
|
145
54
|
validate?: (payload: TResult) => void | Promise<void>;
|
|
146
55
|
}): Promise<TResult>;
|
|
147
|
-
/**
|
|
148
|
-
* Resume a suspended hook with a payload.
|
|
149
|
-
*
|
|
150
|
-
* Uses a status guard to prevent double resolution (race between
|
|
151
|
-
* resume and timeout). Only the first to transition from 'pending' wins.
|
|
152
|
-
*
|
|
153
|
-
* @throws If hook not found, not pending, or validation fails
|
|
154
|
-
*/
|
|
155
56
|
resume(id: string, result: unknown): Promise<HookInstance>;
|
|
156
|
-
/**
|
|
157
|
-
* Reject a suspended hook with a reason.
|
|
158
|
-
* Useful for cancellation flows.
|
|
159
|
-
*/
|
|
160
57
|
reject(id: string, reason: string): HookInstance;
|
|
161
|
-
/** Clean up resolver and timeout for a hook. */
|
|
162
58
|
private cleanup;
|
|
163
|
-
/** Clear all hooks (for testing). */
|
|
164
59
|
clear(): void;
|
|
165
|
-
/** Number of registered hooks. */
|
|
166
60
|
get size(): number;
|
|
167
61
|
}
|
|
168
|
-
/** Thrown when a hook ID is not found in the registry. */
|
|
169
62
|
export declare class HookNotFoundError extends Error {
|
|
170
63
|
readonly hookId: string;
|
|
171
64
|
constructor(hookId: string);
|
|
172
65
|
}
|
|
173
|
-
/** Thrown when attempting to resume a hook that is not pending. */
|
|
174
66
|
export declare class HookNotPendingError extends Error {
|
|
175
67
|
readonly hookId: string;
|
|
176
68
|
readonly currentStatus: HookStatus;
|
|
177
69
|
constructor(hookId: string, currentStatus: HookStatus);
|
|
178
70
|
}
|
|
179
|
-
/** Thrown when a hook is rejected. */
|
|
180
71
|
export declare class HookRejectedError extends Error {
|
|
181
72
|
readonly hookId: string;
|
|
182
73
|
readonly reason: string;
|
|
183
74
|
constructor(hookId: string, reason: string);
|
|
184
75
|
}
|
|
185
|
-
/**
|
|
186
|
-
* FatalError — a non-retryable error that permanently fails a workflow step.
|
|
187
|
-
* When WDK is available, this is the real WDK FatalError class.
|
|
188
|
-
* Without WDK, falls back to a simple Error subclass.
|
|
189
|
-
*/
|
|
190
76
|
export declare class FatalError extends Error {
|
|
191
77
|
readonly fatal = true;
|
|
192
78
|
constructor(message: string);
|
|
193
79
|
static is(value: unknown): value is FatalError;
|
|
194
80
|
}
|
|
195
|
-
/**
|
|
196
|
-
* RetryableError — an error that allows the WDK runtime to retry a step.
|
|
197
|
-
* When WDK is available, prefer using the WDK version directly.
|
|
198
|
-
* Without WDK, this provides the same interface.
|
|
199
|
-
*/
|
|
200
81
|
export declare class RetryableError extends Error {
|
|
201
82
|
readonly retryAfter: Date;
|
|
202
83
|
constructor(message: string, options?: {
|
|
@@ -204,115 +85,19 @@ export declare class RetryableError extends Error {
|
|
|
204
85
|
});
|
|
205
86
|
static is(value: unknown): value is RetryableError;
|
|
206
87
|
}
|
|
207
|
-
/**
|
|
208
|
-
* Get WDK error classes if available, otherwise return our fallbacks.
|
|
209
|
-
* Use these in durable-agent.ts for step-level error handling.
|
|
210
|
-
*/
|
|
211
88
|
export declare function getWdkErrors(): {
|
|
212
89
|
FatalError: typeof FatalError;
|
|
213
90
|
RetryableError: typeof RetryableError;
|
|
214
91
|
};
|
|
215
|
-
/** Get or create the global hook registry. */
|
|
216
92
|
export declare function getHookRegistry(): HookRegistry;
|
|
217
|
-
/**
|
|
218
|
-
* Reset the global hook registry (for testing).
|
|
219
|
-
* @internal
|
|
220
|
-
*/
|
|
221
93
|
export declare function _resetHookRegistry(): void;
|
|
222
|
-
/**
|
|
223
|
-
* Reset the hook counter (for testing).
|
|
224
|
-
* @internal
|
|
225
|
-
*/
|
|
226
94
|
export declare function _resetHookCounter(): void;
|
|
227
|
-
/**
|
|
228
|
-
* Define a typed hook factory.
|
|
229
|
-
*
|
|
230
|
-
* When WDK is available, creates hooks using `wdk.defineHook()` and
|
|
231
|
-
* `wdk.createHook()` for durable suspension with auto-generated webhook tokens.
|
|
232
|
-
*
|
|
233
|
-
* Without WDK, falls back to in-memory HookRegistry.
|
|
234
|
-
*
|
|
235
|
-
* @param definition - Hook configuration
|
|
236
|
-
* @returns A typed hook factory
|
|
237
|
-
*
|
|
238
|
-
* @example
|
|
239
|
-
* ```typescript
|
|
240
|
-
* const approvalHook = defineHook<
|
|
241
|
-
* { action: string; details: string },
|
|
242
|
-
* { approved: boolean; reason?: string }
|
|
243
|
-
* >({
|
|
244
|
-
* name: 'approval',
|
|
245
|
-
* description: 'Approve dangerous agent actions',
|
|
246
|
-
* timeout: '30m',
|
|
247
|
-
* defaultValue: { approved: false, reason: 'Timed out' },
|
|
248
|
-
* });
|
|
249
|
-
*
|
|
250
|
-
* // In a workflow:
|
|
251
|
-
* const result = await approvalHook.wait({
|
|
252
|
-
* action: 'delete files',
|
|
253
|
-
* details: '50 files will be removed',
|
|
254
|
-
* });
|
|
255
|
-
*
|
|
256
|
-
* if (result.approved) {
|
|
257
|
-
* // proceed with deletion
|
|
258
|
-
* }
|
|
259
|
-
* ```
|
|
260
|
-
*/
|
|
261
95
|
export declare function defineHook<TPayload = unknown, TResult = unknown>(definition: HookDefinition<TPayload, TResult>): Hook<TPayload, TResult>;
|
|
262
|
-
/**
|
|
263
|
-
* Create a webhook-backed suspension point.
|
|
264
|
-
*
|
|
265
|
-
* When WDK is available, uses `wdk.createWebhook()` for auto-generated
|
|
266
|
-
* webhook URLs (pattern: /.well-known/workflow/v1/webhook/:token).
|
|
267
|
-
*
|
|
268
|
-
* Without WDK, falls back to in-memory HookRegistry.
|
|
269
|
-
*
|
|
270
|
-
* @param options - Webhook configuration
|
|
271
|
-
* @returns Object with id, promise, and url (if WDK is available)
|
|
272
|
-
*
|
|
273
|
-
* @example
|
|
274
|
-
* ```typescript
|
|
275
|
-
* const result = await createWebhook<{ approved: boolean }>({
|
|
276
|
-
* callbackPath: '/api/approve',
|
|
277
|
-
* timeout: '1h',
|
|
278
|
-
* defaultValue: { approved: false },
|
|
279
|
-
* });
|
|
280
|
-
*
|
|
281
|
-
* if (result.data.approved) {
|
|
282
|
-
* // proceed
|
|
283
|
-
* }
|
|
284
|
-
* ```
|
|
285
|
-
*/
|
|
286
96
|
export declare function createWebhook<T = unknown>(options?: WebhookOptions): {
|
|
287
97
|
id: string;
|
|
288
98
|
promise: Promise<WebhookResult<T>>;
|
|
289
99
|
url?: string;
|
|
290
100
|
};
|
|
291
|
-
/**
|
|
292
|
-
* Resume a hook by its token/ID.
|
|
293
|
-
*
|
|
294
|
-
* When WDK is available, delegates to `wdk.resumeHook()`.
|
|
295
|
-
* Without WDK, uses the in-memory HookRegistry.
|
|
296
|
-
*
|
|
297
|
-
* @param tokenOrId - The hook token or ID
|
|
298
|
-
* @param payload - The payload to send to the hook
|
|
299
|
-
*/
|
|
300
101
|
export declare function resumeHook<T = unknown>(tokenOrId: string, payload: T): Promise<void>;
|
|
301
|
-
/**
|
|
302
|
-
* Pause workflow execution with zero compute cost.
|
|
303
|
-
*
|
|
304
|
-
* Under WDK, this uses durable sleep — the process is suspended and
|
|
305
|
-
* resumed by the runtime after the delay. Without WDK, falls back to
|
|
306
|
-
* `setTimeout`.
|
|
307
|
-
*
|
|
308
|
-
* @param duration - Duration string (e.g., "30s", "5m", "1h")
|
|
309
|
-
* @param options - Optional configuration
|
|
310
|
-
*
|
|
311
|
-
* @example
|
|
312
|
-
* ```typescript
|
|
313
|
-
* // Pause for 5 minutes (zero compute under WDK runtime)
|
|
314
|
-
* await sleep('5m', { reason: 'Rate limit cooldown' });
|
|
315
|
-
* ```
|
|
316
|
-
*/
|
|
317
102
|
export declare function sleep(duration: string, options?: SleepOptions): Promise<void>;
|
|
318
103
|
//# sourceMappingURL=hooks.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../src/workflow/hooks.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../src/workflow/hooks.ts"],"names":[],"mappings":"AA4BA,wBAAgB,cAAc,CAAC,UAAU,UAAQ,GAAG,IAAI,CAGvD;AAED,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,UAAU,GAAG,UAAU,GAAG,WAAW,CAAC;AAG3E,MAAM,WAAW,cAAc,CAAC,QAAQ,GAAG,OAAO,EAAE,OAAO,GAAG,OAAO;IACnE,IAAI,EAAE,MAAM,CAAC;IAEb,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,YAAY,CAAC,EAAE,OAAO,CAAC;IAEvB,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACvD;AAED,MAAM,WAAW,YAAY,CAAC,QAAQ,GAAG,OAAO,EAAE,OAAO,GAAG,OAAO;IACjE,EAAE,EAAE,MAAM,CAAC;IAEX,IAAI,EAAE,MAA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