@mastra/code-sdk 0.0.0-agent-tags-alpha-20261125185303
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/LICENSE.md +32 -0
- package/README.md +284 -0
- package/dist/acp/agent.d.ts +48 -0
- package/dist/acp/agent.js +414 -0
- package/dist/acp/errors.d.ts +3 -0
- package/dist/acp/errors.js +11 -0
- package/dist/acp/event-mapper.d.ts +28 -0
- package/dist/acp/event-mapper.js +274 -0
- package/dist/acp/index.d.ts +9 -0
- package/dist/acp/index.js +21 -0
- package/dist/acp/runtime.d.ts +5 -0
- package/dist/acp/runtime.js +91 -0
- package/dist/acp/server.d.ts +4 -0
- package/dist/acp/server.js +35 -0
- package/dist/acp/skills.d.ts +6 -0
- package/dist/acp/skills.js +30 -0
- package/dist/acp.d.ts +2 -0
- package/dist/acp.js +1 -0
- package/dist/agent-connections/messaging-processor.d.ts +17 -0
- package/dist/agent-connections/messaging-processor.js +131 -0
- package/dist/agent-connections/ownership.d.ts +24 -0
- package/dist/agent-connections/ownership.js +96 -0
- package/dist/agent-connections/registry.d.ts +20 -0
- package/dist/agent-connections/registry.js +167 -0
- package/dist/agent-connections/session-advertisement.d.ts +27 -0
- package/dist/agent-connections/session-advertisement.js +86 -0
- package/dist/agent-connections/signal-provider.d.ts +141 -0
- package/dist/agent-connections/signal-provider.js +35 -0
- package/dist/agent-connections/state-processor.d.ts +23 -0
- package/dist/agent-connections/state-processor.js +270 -0
- package/dist/agent-connections/thread-state.d.ts +41 -0
- package/dist/agent-connections/thread-state.js +157 -0
- package/dist/agent-connections/tools.d.ts +133 -0
- package/dist/agent-connections/tools.js +616 -0
- package/dist/agent-connections/types.d.ts +99 -0
- package/dist/agent-connections/types.js +4 -0
- package/dist/agent-connections/untrusted-text.d.ts +5 -0
- package/dist/agent-connections/untrusted-text.js +19 -0
- package/dist/agents/background-completion-events.d.ts +16 -0
- package/dist/agents/background-completion-events.js +16 -0
- package/dist/agents/background-completion.d.ts +22 -0
- package/dist/agents/background-completion.js +73 -0
- package/dist/agents/context-audit.d.ts +84 -0
- package/dist/agents/context-audit.js +115 -0
- package/dist/agents/credential-resolver.d.ts +74 -0
- package/dist/agents/credential-resolver.js +142 -0
- package/dist/agents/custom-provider-source.d.ts +35 -0
- package/dist/agents/custom-provider-source.js +22 -0
- package/dist/agents/fastembed-subprocess.d.ts +52 -0
- package/dist/agents/fastembed-subprocess.js +282 -0
- package/dist/agents/instructions.d.ts +42 -0
- package/dist/agents/instructions.js +69 -0
- package/dist/agents/mastracode-gateway.d.ts +85 -0
- package/dist/agents/mastracode-gateway.js +500 -0
- package/dist/agents/memory.d.ts +36 -0
- package/dist/agents/memory.js +248 -0
- package/dist/agents/model.d.ts +158 -0
- package/dist/agents/model.js +382 -0
- package/dist/agents/modes/build.d.ts +12 -0
- package/dist/agents/modes/build.js +33 -0
- package/dist/agents/modes/explore.d.ts +10 -0
- package/dist/agents/modes/explore.js +25 -0
- package/dist/agents/modes/plan.d.ts +8 -0
- package/dist/agents/modes/plan.js +43 -0
- package/dist/agents/prompts/agent-instructions.d.ts +122 -0
- package/dist/agents/prompts/agent-instructions.js +617 -0
- package/dist/agents/prompts/build.d.ts +12 -0
- package/dist/agents/prompts/build.js +73 -0
- package/dist/agents/prompts/fast.d.ts +5 -0
- package/dist/agents/prompts/fast.js +23 -0
- package/dist/agents/prompts/index.d.ts +61 -0
- package/dist/agents/prompts/index.js +141 -0
- package/dist/agents/prompts/model.d.ts +5 -0
- package/dist/agents/prompts/model.js +20 -0
- package/dist/agents/prompts/plan.d.ts +11 -0
- package/dist/agents/prompts/plan.js +132 -0
- package/dist/agents/prompts/tool-guidance.d.ts +18 -0
- package/dist/agents/prompts/tool-guidance.js +158 -0
- package/dist/agents/sandbox-filesystem.d.ts +232 -0
- package/dist/agents/sandbox-filesystem.js +851 -0
- package/dist/agents/subagents/execute.d.ts +3 -0
- package/dist/agents/subagents/execute.js +24 -0
- package/dist/agents/subagents/explore.d.ts +3 -0
- package/dist/agents/subagents/explore.js +15 -0
- package/dist/agents/subagents/index.d.ts +6 -0
- package/dist/agents/subagents/index.js +15 -0
- package/dist/agents/subagents/plan.d.ts +3 -0
- package/dist/agents/subagents/plan.js +15 -0
- package/dist/agents/thread-caveman-state.d.ts +17 -0
- package/dist/agents/thread-caveman-state.js +104 -0
- package/dist/agents/tool-availability.d.ts +17 -0
- package/dist/agents/tool-availability.js +134 -0
- package/dist/agents/tools.d.ts +37 -0
- package/dist/agents/tools.js +154 -0
- package/dist/agents/workflow-builder-agent.d.ts +2 -0
- package/dist/agents/workflow-builder-agent.js +79 -0
- package/dist/agents/workspace.d.ts +35 -0
- package/dist/agents/workspace.js +207 -0
- package/dist/analytics.d.ts +18 -0
- package/dist/analytics.js +159 -0
- package/dist/auth/account-rotation-processor.d.ts +210 -0
- package/dist/auth/account-rotation-processor.js +662 -0
- package/dist/auth/account-routing-context.d.ts +17 -0
- package/dist/auth/account-routing-context.js +38 -0
- package/dist/auth/authorization-input.d.ts +16 -0
- package/dist/auth/authorization-input.js +39 -0
- package/dist/auth/device-code.d.ts +93 -0
- package/dist/auth/device-code.js +126 -0
- package/dist/auth/index.d.ts +13 -0
- package/dist/auth/index.js +9 -0
- package/dist/auth/pkce.d.ts +13 -0
- package/dist/auth/pkce.js +29 -0
- package/dist/auth/provider-auth-error.d.ts +24 -0
- package/dist/auth/provider-auth-error.js +44 -0
- package/dist/auth/providers/anthropic.d.ts +40 -0
- package/dist/auth/providers/anthropic.js +117 -0
- package/dist/auth/providers/github-copilot.d.ts +154 -0
- package/dist/auth/providers/github-copilot.js +359 -0
- package/dist/auth/providers/kimi-coding.d.ts +38 -0
- package/dist/auth/providers/kimi-coding.js +225 -0
- package/dist/auth/providers/openai-codex.d.ts +141 -0
- package/dist/auth/providers/openai-codex.js +531 -0
- package/dist/auth/providers/xai.d.ts +64 -0
- package/dist/auth/providers/xai.js +223 -0
- package/dist/auth/storage.d.ts +222 -0
- package/dist/auth/storage.js +805 -0
- package/dist/auth/types.d.ts +164 -0
- package/dist/auth/types.js +1 -0
- package/dist/clipboard/index.d.ts +26 -0
- package/dist/clipboard/index.js +224 -0
- package/dist/constants.d.ts +29 -0
- package/dist/constants.js +34 -0
- package/dist/error-classification.d.ts +10 -0
- package/dist/error-classification.js +19 -0
- package/dist/evals/context-builder.d.ts +41 -0
- package/dist/evals/context-builder.js +156 -0
- package/dist/evals/index.d.ts +4 -0
- package/dist/evals/index.js +5 -0
- package/dist/evals/scorers/classify-command.d.ts +30 -0
- package/dist/evals/scorers/classify-command.js +61 -0
- package/dist/evals/scorers/efficiency.d.ts +44 -0
- package/dist/evals/scorers/efficiency.js +256 -0
- package/dist/evals/scorers/extract-tools.d.ts +25 -0
- package/dist/evals/scorers/extract-tools.js +57 -0
- package/dist/evals/scorers/index.d.ts +3 -0
- package/dist/evals/scorers/index.js +3 -0
- package/dist/evals/scorers/outcome.d.ts +49 -0
- package/dist/evals/scorers/outcome.js +360 -0
- package/dist/experimental-agent.d.ts +19 -0
- package/dist/experimental-agent.js +45 -0
- package/dist/factory/client.d.ts +44 -0
- package/dist/factory/client.js +110 -0
- package/dist/factory/remote-controller.d.ts +34 -0
- package/dist/factory/remote-controller.js +40 -0
- package/dist/factory/remote-session.d.ts +210 -0
- package/dist/factory/remote-session.js +415 -0
- package/dist/goal-manager.d.ts +114 -0
- package/dist/goal-manager.js +351 -0
- package/dist/goal-signal.d.ts +14 -0
- package/dist/goal-signal.js +14 -0
- package/dist/headless/cli.d.ts +55 -0
- package/dist/headless/cli.js +261 -0
- package/dist/headless/flags.d.ts +33 -0
- package/dist/headless/flags.js +207 -0
- package/dist/headless/format.d.ts +41 -0
- package/dist/headless/format.js +94 -0
- package/dist/headless/index.d.ts +25 -0
- package/dist/headless/index.js +6 -0
- package/dist/headless/policy.d.ts +17 -0
- package/dist/headless/policy.js +39 -0
- package/dist/headless/run-mc.d.ts +7 -0
- package/dist/headless/run-mc.js +438 -0
- package/dist/headless/types.d.ts +175 -0
- package/dist/headless/types.js +16 -0
- package/dist/hooks/config.d.ts +11 -0
- package/dist/hooks/config.js +77 -0
- package/dist/hooks/executor.d.ts +13 -0
- package/dist/hooks/executor.js +128 -0
- package/dist/hooks/index.d.ts +6 -0
- package/dist/hooks/index.js +5 -0
- package/dist/hooks/manager.d.ts +75 -0
- package/dist/hooks/manager.js +289 -0
- package/dist/hooks/types.d.ts +180 -0
- package/dist/hooks/types.js +5 -0
- package/dist/index.d.ts +537 -0
- package/dist/index.js +1399 -0
- package/dist/ipc/ipc-reporter.d.ts +14 -0
- package/dist/ipc/ipc-reporter.js +18 -0
- package/dist/knowledge-inspector.d.ts +139 -0
- package/dist/knowledge-inspector.js +533 -0
- package/dist/knowledge-scope-id.d.ts +7 -0
- package/dist/knowledge-scope-id.js +10 -0
- package/dist/knowledge-scope.d.ts +41 -0
- package/dist/knowledge-scope.js +85 -0
- package/dist/lsp/client.d.ts +56 -0
- package/dist/lsp/client.js +248 -0
- package/dist/lsp/index.d.ts +4 -0
- package/dist/lsp/index.js +4 -0
- package/dist/lsp/language.d.ts +9 -0
- package/dist/lsp/language.js +41 -0
- package/dist/lsp/manager.d.ts +34 -0
- package/dist/lsp/manager.js +79 -0
- package/dist/lsp/server.d.ts +27 -0
- package/dist/lsp/server.js +158 -0
- package/dist/lsp/workspace.d.ts +9 -0
- package/dist/lsp/workspace.js +52 -0
- package/dist/mcp/config.d.ts +77 -0
- package/dist/mcp/config.js +313 -0
- package/dist/mcp/index.d.ts +6 -0
- package/dist/mcp/index.js +3 -0
- package/dist/mcp/manager.d.ts +104 -0
- package/dist/mcp/manager.js +693 -0
- package/dist/mcp/state.d.ts +35 -0
- package/dist/mcp/state.js +94 -0
- package/dist/mcp/types.d.ts +139 -0
- package/dist/mcp/types.js +1 -0
- package/dist/onboarding/custom-packs.d.ts +7 -0
- package/dist/onboarding/custom-packs.js +17 -0
- package/dist/onboarding/custom-providers.d.ts +4 -0
- package/dist/onboarding/custom-providers.js +27 -0
- package/dist/onboarding/index.d.ts +5 -0
- package/dist/onboarding/index.js +3 -0
- package/dist/onboarding/om-settings.d.ts +47 -0
- package/dist/onboarding/om-settings.js +80 -0
- package/dist/onboarding/pack-activation.d.ts +43 -0
- package/dist/onboarding/pack-activation.js +105 -0
- package/dist/onboarding/packs.d.ts +106 -0
- package/dist/onboarding/packs.js +283 -0
- package/dist/onboarding/settings.d.ts +563 -0
- package/dist/onboarding/settings.js +1110 -0
- package/dist/permissions.d.ts +55 -0
- package/dist/permissions.js +139 -0
- package/dist/platform/index.d.ts +74 -0
- package/dist/platform/index.js +199 -0
- package/dist/plugin.d.ts +156 -0
- package/dist/plugin.js +27 -0
- package/dist/plugins/dependencies.d.ts +9 -0
- package/dist/plugins/dependencies.js +84 -0
- package/dist/plugins/install.d.ts +21 -0
- package/dist/plugins/install.js +187 -0
- package/dist/plugins/loader.d.ts +25 -0
- package/dist/plugins/loader.js +264 -0
- package/dist/plugins/manager.d.ts +115 -0
- package/dist/plugins/manager.js +507 -0
- package/dist/plugins/manifest.d.ts +14 -0
- package/dist/plugins/manifest.js +47 -0
- package/dist/plugins/package-link.d.ts +3 -0
- package/dist/plugins/package-link.js +58 -0
- package/dist/plugins/paths.d.ts +10 -0
- package/dist/plugins/paths.js +22 -0
- package/dist/plugins/registry.d.ts +8 -0
- package/dist/plugins/registry.js +109 -0
- package/dist/plugins/scaffold.d.ts +10 -0
- package/dist/plugins/scaffold.js +115 -0
- package/dist/plugins/signal-lane.d.ts +59 -0
- package/dist/plugins/signal-lane.js +163 -0
- package/dist/plugins/types.d.ts +95 -0
- package/dist/plugins/types.js +1 -0
- package/dist/process-memory-diagnostics.d.ts +136 -0
- package/dist/process-memory-diagnostics.js +497 -0
- package/dist/processors/plan-rejection-abort.d.ts +16 -0
- package/dist/processors/plan-rejection-abort.js +62 -0
- package/dist/providers/amazon-bedrock-gateway.d.ts +47 -0
- package/dist/providers/amazon-bedrock-gateway.js +142 -0
- package/dist/providers/amazon-bedrock.d.ts +28 -0
- package/dist/providers/amazon-bedrock.js +99 -0
- package/dist/providers/anthropic-prompt-cache.d.ts +19 -0
- package/dist/providers/anthropic-prompt-cache.js +8 -0
- package/dist/providers/anthropic-thinking.d.ts +5 -0
- package/dist/providers/anthropic-thinking.js +22 -0
- package/dist/providers/claude-max.d.ts +67 -0
- package/dist/providers/claude-max.js +232 -0
- package/dist/providers/github-copilot-gateway.d.ts +35 -0
- package/dist/providers/github-copilot-gateway.js +58 -0
- package/dist/providers/github-copilot.d.ts +60 -0
- package/dist/providers/github-copilot.js +320 -0
- package/dist/providers/google-thinking.d.ts +31 -0
- package/dist/providers/google-thinking.js +64 -0
- package/dist/providers/google-vertex-gateway.d.ts +23 -0
- package/dist/providers/google-vertex-gateway.js +49 -0
- package/dist/providers/google-vertex.d.ts +6 -0
- package/dist/providers/google-vertex.js +51 -0
- package/dist/providers/kimi-coding.d.ts +14 -0
- package/dist/providers/kimi-coding.js +80 -0
- package/dist/providers/model-ids.d.ts +53 -0
- package/dist/providers/model-ids.js +132 -0
- package/dist/providers/openai-codex.d.ts +114 -0
- package/dist/providers/openai-codex.js +427 -0
- package/dist/providers/provider-thinking.d.ts +23 -0
- package/dist/providers/provider-thinking.js +61 -0
- package/dist/providers/thinking-request.d.ts +14 -0
- package/dist/providers/thinking-request.js +87 -0
- package/dist/providers/xai.d.ts +33 -0
- package/dist/providers/xai.js +72 -0
- package/dist/schedules/index.d.ts +10 -0
- package/dist/schedules/index.js +6 -0
- package/dist/schedules/interval.d.ts +49 -0
- package/dist/schedules/interval.js +212 -0
- package/dist/schedules/prompt.d.ts +36 -0
- package/dist/schedules/prompt.js +36 -0
- package/dist/schedules/run-script.d.ts +8 -0
- package/dist/schedules/run-script.js +80 -0
- package/dist/schedules/scheduler.d.ts +101 -0
- package/dist/schedules/scheduler.js +167 -0
- package/dist/schedules/tools.d.ts +57 -0
- package/dist/schedules/tools.js +217 -0
- package/dist/schema.d.ts +499 -0
- package/dist/schema.js +131 -0
- package/dist/theme-palette.d.ts +17 -0
- package/dist/theme-palette.js +18 -0
- package/dist/thinking-catalog.d.ts +4 -0
- package/dist/thinking-catalog.js +13 -0
- package/dist/thinking.d.ts +37 -0
- package/dist/thinking.js +134 -0
- package/dist/tool-names.d.ts +77 -0
- package/dist/tool-names.js +53 -0
- package/dist/tools/index.d.ts +6 -0
- package/dist/tools/index.js +3 -0
- package/dist/tools/request-sandbox-access.d.ts +6 -0
- package/dist/tools/request-sandbox-access.js +80 -0
- package/dist/tools/utils.d.ts +20 -0
- package/dist/tools/utils.js +31 -0
- package/dist/tools/web-search.d.ts +116 -0
- package/dist/tools/web-search.js +158 -0
- package/dist/tools/workflows/create-workflow.d.ts +7 -0
- package/dist/tools/workflows/create-workflow.js +82 -0
- package/dist/tools/workflows/delete-workflow.d.ts +7 -0
- package/dist/tools/workflows/delete-workflow.js +18 -0
- package/dist/tools/workflows/ephemeral-memory.d.ts +28 -0
- package/dist/tools/workflows/ephemeral-memory.js +41 -0
- package/dist/tools/workflows/extract-json-schema.d.ts +12 -0
- package/dist/tools/workflows/extract-json-schema.js +19 -0
- package/dist/tools/workflows/get-workflow.d.ts +11 -0
- package/dist/tools/workflows/get-workflow.js +31 -0
- package/dist/tools/workflows/list-available-agents.d.ts +8 -0
- package/dist/tools/workflows/list-available-agents.js +29 -0
- package/dist/tools/workflows/list-available-classifiers.d.ts +19 -0
- package/dist/tools/workflows/list-available-classifiers.js +53 -0
- package/dist/tools/workflows/list-available-tools.d.ts +9 -0
- package/dist/tools/workflows/list-available-tools.js +37 -0
- package/dist/tools/workflows/list-available-workflows.d.ts +9 -0
- package/dist/tools/workflows/list-available-workflows.js +29 -0
- package/dist/tools/workflows/list-workflows.d.ts +9 -0
- package/dist/tools/workflows/list-workflows.js +30 -0
- package/dist/tools/workflows/run-workflow.d.ts +9 -0
- package/dist/tools/workflows/run-workflow.js +49 -0
- package/dist/tools/workflows/save-workflow.d.ts +1125 -0
- package/dist/tools/workflows/save-workflow.js +25 -0
- package/dist/tools/workflows/tool-ids.d.ts +16 -0
- package/dist/tools/workflows/tool-ids.js +17 -0
- package/dist/utils/binaries.d.ts +7 -0
- package/dist/utils/binaries.js +97 -0
- package/dist/utils/debug-log.d.ts +12 -0
- package/dist/utils/debug-log.js +56 -0
- package/dist/utils/discarding-scores-storage.d.ts +33 -0
- package/dist/utils/discarding-scores-storage.js +51 -0
- package/dist/utils/errors.d.ts +36 -0
- package/dist/utils/errors.js +215 -0
- package/dist/utils/gateway-sync.d.ts +26 -0
- package/dist/utils/gateway-sync.js +58 -0
- package/dist/utils/local-observability.d.ts +19 -0
- package/dist/utils/local-observability.js +54 -0
- package/dist/utils/maintenance-lock.d.ts +42 -0
- package/dist/utils/maintenance-lock.js +196 -0
- package/dist/utils/notification-dispatch.d.ts +74 -0
- package/dist/utils/notification-dispatch.js +128 -0
- package/dist/utils/open-url.d.ts +10 -0
- package/dist/utils/open-url.js +27 -0
- package/dist/utils/path-security.d.ts +2 -0
- package/dist/utils/path-security.js +7 -0
- package/dist/utils/plan-diff.d.ts +25 -0
- package/dist/utils/plan-diff.js +59 -0
- package/dist/utils/plans.d.ts +61 -0
- package/dist/utils/plans.js +120 -0
- package/dist/utils/project.d.ts +160 -0
- package/dist/utils/project.js +361 -0
- package/dist/utils/prune-cli.d.ts +24 -0
- package/dist/utils/prune-cli.js +124 -0
- package/dist/utils/signals-pubsub.d.ts +103 -0
- package/dist/utils/signals-pubsub.js +409 -0
- package/dist/utils/slash-command-loader.d.ts +52 -0
- package/dist/utils/slash-command-loader.js +139 -0
- package/dist/utils/slash-command-processor.d.ts +14 -0
- package/dist/utils/slash-command-processor.js +106 -0
- package/dist/utils/stdin-pipe.d.ts +33 -0
- package/dist/utils/stdin-pipe.js +93 -0
- package/dist/utils/storage-factory.d.ts +50 -0
- package/dist/utils/storage-factory.js +118 -0
- package/dist/utils/storage-maintenance.d.ts +121 -0
- package/dist/utils/storage-maintenance.js +352 -0
- package/dist/utils/thread-lock.d.ts +26 -0
- package/dist/utils/thread-lock.js +109 -0
- package/dist/utils/token-estimator.d.ts +3 -0
- package/dist/utils/token-estimator.js +19 -0
- package/dist/utils/update-check.d.ts +151 -0
- package/dist/utils/update-check.js +430 -0
- package/dist/utils/wake-session.d.ts +44 -0
- package/dist/utils/wake-session.js +83 -0
- package/dist/voice/stt-registry.d.ts +67 -0
- package/dist/voice/stt-registry.js +144 -0
- package/dist/voice/transcribe.d.ts +10 -0
- package/dist/voice/transcribe.js +75 -0
- package/dist/workflows/register-primitives.d.ts +52 -0
- package/dist/workflows/register-primitives.js +40 -0
- package/dist/workflows/service.d.ts +64 -0
- package/dist/workflows/service.js +50 -0
- package/package.json +117 -0
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { nextFireTime, validateInterval } from "./interval.js";
|
|
2
|
+
import { randomUUID } from "crypto";
|
|
3
|
+
// src/schedules/scheduler.ts
|
|
4
|
+
/**
|
|
5
|
+
* Process-local scheduler behind `/schedules`.
|
|
6
|
+
*
|
|
7
|
+
* Schedules live only in this process: timers fire them and they die with it.
|
|
8
|
+
* Nothing is written to shared storage, so other Mastra Code processes on the
|
|
9
|
+
* same database never see — or fire — this session's schedules.
|
|
10
|
+
*/
|
|
11
|
+
/** `source` attribute on fired signals; the TUI labels these turns `schedule`. */
|
|
12
|
+
const SCHEDULE_SIGNAL_SOURCE = "schedule";
|
|
13
|
+
/** How late a timer may run before its fire counts as missed (sleep, stalled event loop). */
|
|
14
|
+
const LATE_FIRE_GRACE_MS = 6e4;
|
|
15
|
+
var ThreadScheduler = class {
|
|
16
|
+
#entries = /* @__PURE__ */ new Map();
|
|
17
|
+
#options;
|
|
18
|
+
constructor(options) {
|
|
19
|
+
this.#options = options;
|
|
20
|
+
}
|
|
21
|
+
#now() {
|
|
22
|
+
return this.#options.now?.() ?? Date.now();
|
|
23
|
+
}
|
|
24
|
+
/** Throws when the interval is not a supported wall-clock cadence (see `validateInterval`) or the prompt is empty. */
|
|
25
|
+
create(spec, target) {
|
|
26
|
+
const { interval } = spec.trigger;
|
|
27
|
+
const check = validateInterval(interval);
|
|
28
|
+
if ("error" in check) throw new Error(`Invalid schedule interval: ${check.error}${check.suggestion ? ` Try ${check.suggestion}.` : ""}`);
|
|
29
|
+
if ("prompt" in spec && !spec.prompt.trim()) throw new Error("Schedule prompt is empty.");
|
|
30
|
+
const now = this.#now();
|
|
31
|
+
const schedule = {
|
|
32
|
+
id: randomUUID(),
|
|
33
|
+
threadId: target.threadId,
|
|
34
|
+
resourceId: target.resourceId,
|
|
35
|
+
trigger: {
|
|
36
|
+
kind: "every",
|
|
37
|
+
interval: { ...interval }
|
|
38
|
+
},
|
|
39
|
+
..."file" in spec ? {
|
|
40
|
+
file: { ...spec.file },
|
|
41
|
+
...spec.extraPrompt ? { extraPrompt: spec.extraPrompt } : {}
|
|
42
|
+
} : { prompt: spec.prompt },
|
|
43
|
+
createdBy: spec.createdBy ?? "user",
|
|
44
|
+
status: "active",
|
|
45
|
+
nextFireAt: nextFireTime(interval.ms, now),
|
|
46
|
+
createdAt: now
|
|
47
|
+
};
|
|
48
|
+
const entry = {
|
|
49
|
+
schedule,
|
|
50
|
+
inFlight: 0
|
|
51
|
+
};
|
|
52
|
+
this.#entries.set(schedule.id, entry);
|
|
53
|
+
this.#arm(entry);
|
|
54
|
+
return { ...schedule };
|
|
55
|
+
}
|
|
56
|
+
list(filter = {}) {
|
|
57
|
+
return [...this.#entries.values()].map((entry) => ({ ...entry.schedule })).filter((schedule) => !filter.threadId || schedule.threadId === filter.threadId).sort((a, b) => a.createdAt - b.createdAt);
|
|
58
|
+
}
|
|
59
|
+
delete(id) {
|
|
60
|
+
const entry = this.#entries.get(id);
|
|
61
|
+
if (!entry) return false;
|
|
62
|
+
clearTimeout(entry.timer);
|
|
63
|
+
this.#entries.delete(id);
|
|
64
|
+
return true;
|
|
65
|
+
}
|
|
66
|
+
pause(id) {
|
|
67
|
+
const entry = this.#entries.get(id);
|
|
68
|
+
if (!entry) return false;
|
|
69
|
+
clearTimeout(entry.timer);
|
|
70
|
+
entry.timer = void 0;
|
|
71
|
+
entry.schedule.status = "paused";
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
74
|
+
resume(id) {
|
|
75
|
+
const entry = this.#entries.get(id);
|
|
76
|
+
if (!entry) return false;
|
|
77
|
+
if (entry.schedule.status === "active") return true;
|
|
78
|
+
entry.schedule.status = "active";
|
|
79
|
+
entry.schedule.nextFireAt = nextFireTime(entry.schedule.trigger.interval.ms, this.#now());
|
|
80
|
+
this.#arm(entry);
|
|
81
|
+
return true;
|
|
82
|
+
}
|
|
83
|
+
/** Whether a fire of this schedule (timer or manual) is still assembling or delivering. */
|
|
84
|
+
isFiring(id) {
|
|
85
|
+
return (this.#entries.get(id)?.inFlight ?? 0) > 0;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Fire once now, outside the cadence. Returns `busy` without firing when a
|
|
89
|
+
* fire of this schedule is still running (a slow script, say), so the same
|
|
90
|
+
* script never runs twice at once. Resolves once the fire finished; a fire
|
|
91
|
+
* that never reached the agent resolves `failed` instead of calling `onError`.
|
|
92
|
+
*/
|
|
93
|
+
async run(id) {
|
|
94
|
+
const entry = this.#entries.get(id);
|
|
95
|
+
if (!entry) return { status: "not-found" };
|
|
96
|
+
if (entry.inFlight > 0) return { status: "busy" };
|
|
97
|
+
const result = await this.#fire(entry);
|
|
98
|
+
if (result.kind === "failed") return {
|
|
99
|
+
status: "failed",
|
|
100
|
+
error: result.error
|
|
101
|
+
};
|
|
102
|
+
return result.kind === "delivered" ? { status: "fired" } : { status: "not-found" };
|
|
103
|
+
}
|
|
104
|
+
/** Drop every schedule and timer (process shutdown). */
|
|
105
|
+
stop() {
|
|
106
|
+
for (const entry of this.#entries.values()) clearTimeout(entry.timer);
|
|
107
|
+
this.#entries.clear();
|
|
108
|
+
}
|
|
109
|
+
#arm(entry) {
|
|
110
|
+
clearTimeout(entry.timer);
|
|
111
|
+
const scheduledAt = entry.schedule.nextFireAt;
|
|
112
|
+
entry.timer = setTimeout(() => {
|
|
113
|
+
if (this.#entries.get(entry.schedule.id) !== entry || entry.schedule.status !== "active") return;
|
|
114
|
+
const now = this.#now();
|
|
115
|
+
entry.schedule.nextFireAt = nextFireTime(entry.schedule.trigger.interval.ms, Math.max(now, scheduledAt));
|
|
116
|
+
this.#arm(entry);
|
|
117
|
+
if (now - scheduledAt > 6e4) return;
|
|
118
|
+
if (entry.inFlight === 0) this.#fire(entry).then((result) => {
|
|
119
|
+
if (result.kind === "failed") this.#options.onError?.(result.error, { ...entry.schedule });
|
|
120
|
+
});
|
|
121
|
+
}, Math.max(0, scheduledAt - this.#now()));
|
|
122
|
+
entry.timer.unref?.();
|
|
123
|
+
}
|
|
124
|
+
async #fire(entry) {
|
|
125
|
+
const schedule = { ...entry.schedule };
|
|
126
|
+
entry.inFlight++;
|
|
127
|
+
try {
|
|
128
|
+
const assembled = await this.#options.assemblePrompt(schedule);
|
|
129
|
+
if (this.#entries.get(schedule.id) !== entry) return { kind: "deleted" };
|
|
130
|
+
await this.#options.deliver(schedule, assembled);
|
|
131
|
+
return { kind: "delivered" };
|
|
132
|
+
} catch (error) {
|
|
133
|
+
return {
|
|
134
|
+
kind: "failed",
|
|
135
|
+
error
|
|
136
|
+
};
|
|
137
|
+
} finally {
|
|
138
|
+
entry.inFlight--;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
function shortScheduleId(id) {
|
|
143
|
+
return id.slice(0, 8);
|
|
144
|
+
}
|
|
145
|
+
/** One-line human summary of what a schedule sends: `run ./check.sh + "extra"`, `read notes.md`, `"prompt"`. */
|
|
146
|
+
function describeScheduleSource(schedule) {
|
|
147
|
+
const oneLine = (text) => text.replace(/\s+/g, " ").trim();
|
|
148
|
+
if (!schedule.file) return `"${oneLine(schedule.prompt ?? "")}"`;
|
|
149
|
+
const verb = schedule.file.mode === "script" ? "run" : "read";
|
|
150
|
+
const extra = schedule.extraPrompt ? ` + "${oneLine(schedule.extraPrompt)}"` : "";
|
|
151
|
+
return `${verb} ${schedule.file.displayPath}${extra}`;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Attributes on a fired schedule signal. They carry everything the transcript
|
|
155
|
+
* header needs, so reloaded history renders without the process-local entry.
|
|
156
|
+
*/
|
|
157
|
+
function scheduleSignalAttributes(schedule, assembled = {}) {
|
|
158
|
+
return {
|
|
159
|
+
source: SCHEDULE_SIGNAL_SOURCE,
|
|
160
|
+
scheduleId: schedule.id,
|
|
161
|
+
scheduleCadence: schedule.trigger.interval.label,
|
|
162
|
+
scheduleSource: describeScheduleSource(schedule),
|
|
163
|
+
scheduleCreatedBy: schedule.createdBy,
|
|
164
|
+
...assembled.outcome ? { scheduleOutcome: assembled.outcome } : {}
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
export { LATE_FIRE_GRACE_MS, SCHEDULE_SIGNAL_SOURCE, ThreadScheduler, describeScheduleSource, scheduleSignalAttributes, shortScheduleId };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { ThreadScheduler } from './scheduler.js';
|
|
2
|
+
export declare const SCHEDULE_TOOL_IDS: {
|
|
3
|
+
readonly create: 'schedule_create';
|
|
4
|
+
readonly list: 'schedule_list';
|
|
5
|
+
readonly update: 'schedule_update';
|
|
6
|
+
readonly resume: 'schedule_resume';
|
|
7
|
+
readonly run: 'schedule_run';
|
|
8
|
+
};
|
|
9
|
+
export type ScheduleFileOptions = {
|
|
10
|
+
/** Directory relative paths resolve against (the project root). */
|
|
11
|
+
cwd: string;
|
|
12
|
+
homeDir?: string;
|
|
13
|
+
fileExists: (absPath: string) => boolean;
|
|
14
|
+
};
|
|
15
|
+
export type ScheduleToolsOptions = {
|
|
16
|
+
scheduler: ThreadScheduler;
|
|
17
|
+
fileOptions: () => ScheduleFileOptions;
|
|
18
|
+
};
|
|
19
|
+
export declare function createScheduleTools({ scheduler, fileOptions }: ScheduleToolsOptions): {
|
|
20
|
+
schedule_create: import("@mastra/core/tools").Tool<{
|
|
21
|
+
trigger: {
|
|
22
|
+
kind: "every";
|
|
23
|
+
interval: import("./interval.js").ParsedInterval;
|
|
24
|
+
};
|
|
25
|
+
prompt?: string | undefined;
|
|
26
|
+
promptFile?: string | undefined;
|
|
27
|
+
script?: string | undefined;
|
|
28
|
+
extraPrompt?: string | undefined;
|
|
29
|
+
}, {
|
|
30
|
+
content: string;
|
|
31
|
+
isError?: boolean | undefined;
|
|
32
|
+
}, unknown, unknown, import("@mastra/core/tools").ToolExecutionContext<unknown, unknown, unknown>, "schedule_create", unknown>;
|
|
33
|
+
schedule_list: import("@mastra/core/tools").Tool<Record<string, never>, {
|
|
34
|
+
content: string;
|
|
35
|
+
isError?: boolean | undefined;
|
|
36
|
+
}, unknown, unknown, import("@mastra/core/tools").ToolExecutionContext<unknown, unknown, unknown>, "schedule_list", unknown>;
|
|
37
|
+
schedule_update: import("@mastra/core/tools").Tool<{
|
|
38
|
+
id: string;
|
|
39
|
+
action: "delete" | "pause";
|
|
40
|
+
}, {
|
|
41
|
+
content: string;
|
|
42
|
+
isError?: boolean | undefined;
|
|
43
|
+
}, unknown, unknown, import("@mastra/core/tools").ToolExecutionContext<unknown, unknown, unknown>, "schedule_update", unknown>;
|
|
44
|
+
schedule_resume: import("@mastra/core/tools").Tool<{
|
|
45
|
+
id: string;
|
|
46
|
+
}, {
|
|
47
|
+
content: string;
|
|
48
|
+
isError?: boolean | undefined;
|
|
49
|
+
}, unknown, unknown, import("@mastra/core/tools").ToolExecutionContext<unknown, unknown, unknown>, "schedule_resume", unknown>;
|
|
50
|
+
schedule_run: import("@mastra/core/tools").Tool<{
|
|
51
|
+
id: string;
|
|
52
|
+
}, {
|
|
53
|
+
content: string;
|
|
54
|
+
isError?: boolean | undefined;
|
|
55
|
+
}, unknown, unknown, import("@mastra/core/tools").ToolExecutionContext<unknown, unknown, unknown>, "schedule_run", unknown>;
|
|
56
|
+
};
|
|
57
|
+
//# sourceMappingURL=tools.d.ts.map
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import { parseInterval, validateInterval } from "./interval.js";
|
|
2
|
+
import { resolveScriptCommand } from "./run-script.js";
|
|
3
|
+
import { describeScheduleSource, shortScheduleId } from "./scheduler.js";
|
|
4
|
+
import * as path$1 from "path";
|
|
5
|
+
import { createTool } from "@mastra/core/tools";
|
|
6
|
+
import { z } from "zod";
|
|
7
|
+
// src/schedules/tools.ts
|
|
8
|
+
/**
|
|
9
|
+
* Agent-facing tools for the process-local `/schedules` scheduler.
|
|
10
|
+
*
|
|
11
|
+
* Opt-in (experimental setting). Every tool is bound to the thread of the run
|
|
12
|
+
* that calls it — the model never picks a thread or resource — and can only
|
|
13
|
+
* see or manage schedules on that thread.
|
|
14
|
+
*/
|
|
15
|
+
const SCHEDULE_TOOL_IDS = {
|
|
16
|
+
create: "schedule_create",
|
|
17
|
+
list: "schedule_list",
|
|
18
|
+
update: "schedule_update",
|
|
19
|
+
resume: "schedule_resume",
|
|
20
|
+
run: "schedule_run"
|
|
21
|
+
};
|
|
22
|
+
const resultSchema = z.object({
|
|
23
|
+
content: z.string(),
|
|
24
|
+
isError: z.boolean().optional()
|
|
25
|
+
});
|
|
26
|
+
const intervalSchema = z.string().min(1).transform((value, ctx) => {
|
|
27
|
+
const interval = parseInterval(value);
|
|
28
|
+
if ("error" in interval) {
|
|
29
|
+
ctx.addIssue({
|
|
30
|
+
code: "custom",
|
|
31
|
+
message: interval.error
|
|
32
|
+
});
|
|
33
|
+
return z.NEVER;
|
|
34
|
+
}
|
|
35
|
+
const check = validateInterval(interval);
|
|
36
|
+
if ("error" in check) {
|
|
37
|
+
const suggestion = check.suggestion ? ` Try ${check.suggestion}.` : "";
|
|
38
|
+
ctx.addIssue({
|
|
39
|
+
code: "custom",
|
|
40
|
+
message: `${check.error}${suggestion}`
|
|
41
|
+
});
|
|
42
|
+
return z.NEVER;
|
|
43
|
+
}
|
|
44
|
+
return interval;
|
|
45
|
+
}).describe("Cadence such as \"5m\", \"2h\", or \"1d\". Minute steps must divide 60, hour steps must divide 24.");
|
|
46
|
+
const triggerSchema = z.discriminatedUnion("kind", [z.object({
|
|
47
|
+
kind: z.literal("every"),
|
|
48
|
+
interval: intervalSchema
|
|
49
|
+
})]).describe("When the schedule fires. \"every\" repeats on wall-clock boundaries (5m fires at :00, :05, …).");
|
|
50
|
+
const idSchema = z.string().min(1).describe("Schedule id, or a unique prefix of it (the 8-character short id works).");
|
|
51
|
+
function threadOf(context) {
|
|
52
|
+
const agent = context?.agent;
|
|
53
|
+
return agent?.threadId && agent.resourceId ? {
|
|
54
|
+
threadId: agent.threadId,
|
|
55
|
+
resourceId: agent.resourceId
|
|
56
|
+
} : void 0;
|
|
57
|
+
}
|
|
58
|
+
const NO_THREAD = {
|
|
59
|
+
content: "Schedules require a memory-backed thread.",
|
|
60
|
+
isError: true
|
|
61
|
+
};
|
|
62
|
+
function resolveFile(token, mode, options) {
|
|
63
|
+
const expanded = token.startsWith("~/") && options.homeDir ? path$1.join(options.homeDir, token.slice(2)) : token;
|
|
64
|
+
const absPath = path$1.resolve(options.cwd, expanded);
|
|
65
|
+
return options.fileExists(absPath) ? {
|
|
66
|
+
path: absPath,
|
|
67
|
+
displayPath: token,
|
|
68
|
+
mode
|
|
69
|
+
} : void 0;
|
|
70
|
+
}
|
|
71
|
+
function formatSchedule(schedule) {
|
|
72
|
+
const timing = schedule.status === "paused" ? "paused" : `next at ${new Date(schedule.nextFireAt).toLocaleTimeString()}`;
|
|
73
|
+
return `${shortScheduleId(schedule.id)} every ${schedule.trigger.interval.label} ${timing} ${describeScheduleSource(schedule)} (created by ${schedule.createdBy})`;
|
|
74
|
+
}
|
|
75
|
+
function errorMessage(error) {
|
|
76
|
+
return error instanceof Error ? error.message : String(error);
|
|
77
|
+
}
|
|
78
|
+
function findOne(scheduler, threadId, id) {
|
|
79
|
+
const needle = id.toLowerCase();
|
|
80
|
+
const matches = scheduler.list({ threadId }).filter((schedule) => schedule.id.toLowerCase().startsWith(needle));
|
|
81
|
+
if (matches.length === 1) return { schedule: matches[0] };
|
|
82
|
+
return {
|
|
83
|
+
content: matches.length === 0 ? `No schedule "${id}" on this thread.` : `"${id}" matches several schedules.`,
|
|
84
|
+
isError: true
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
function createScheduleTools({ scheduler, fileOptions }) {
|
|
88
|
+
const scheduleCreateTool = createTool({
|
|
89
|
+
id: SCHEDULE_TOOL_IDS.create,
|
|
90
|
+
description: `Schedule a recurring prompt on this thread. Each fire arrives as a new user turn labelled "schedule".
|
|
91
|
+
|
|
92
|
+
Pass exactly one source: "prompt" (text sent each fire), "promptFile" (a file re-read and sent as the prompt each fire), or "script" (run each fire; its output is sent, followed by "extraPrompt" if given). Schedules live only until Mastra Code exits.`,
|
|
93
|
+
inputSchema: z.object({
|
|
94
|
+
trigger: triggerSchema,
|
|
95
|
+
prompt: z.string().trim().min(1).optional().describe("Prompt text to send on every fire."),
|
|
96
|
+
promptFile: z.string().trim().min(1).optional().describe("Path to a file to re-read and send on every fire."),
|
|
97
|
+
script: z.string().trim().min(1).optional().describe("Path to a script to run on every fire."),
|
|
98
|
+
extraPrompt: z.string().trim().min(1).optional().describe("Text sent after the script output.")
|
|
99
|
+
}).refine((input) => [
|
|
100
|
+
input.prompt,
|
|
101
|
+
input.promptFile,
|
|
102
|
+
input.script
|
|
103
|
+
].filter(Boolean).length === 1, { message: "Provide exactly one of \"prompt\", \"promptFile\", or \"script\"." }).refine((input) => !input.extraPrompt || input.script, { message: "\"extraPrompt\" only applies with \"script\"." }),
|
|
104
|
+
outputSchema: resultSchema,
|
|
105
|
+
execute: async (input, context) => {
|
|
106
|
+
const target = threadOf(context);
|
|
107
|
+
if (!target) return NO_THREAD;
|
|
108
|
+
let schedule;
|
|
109
|
+
if (input.prompt) schedule = scheduler.create({
|
|
110
|
+
trigger: input.trigger,
|
|
111
|
+
prompt: input.prompt,
|
|
112
|
+
createdBy: "agent"
|
|
113
|
+
}, target);
|
|
114
|
+
else {
|
|
115
|
+
const token = input.script ?? input.promptFile;
|
|
116
|
+
const file = resolveFile(token, input.script ? "script" : "prompt", fileOptions());
|
|
117
|
+
if (!file) return {
|
|
118
|
+
content: `File not found: ${token}`,
|
|
119
|
+
isError: true
|
|
120
|
+
};
|
|
121
|
+
if (file.mode === "script") try {
|
|
122
|
+
resolveScriptCommand(file.path);
|
|
123
|
+
} catch (error) {
|
|
124
|
+
return {
|
|
125
|
+
content: `Can't run ${token}: ${error instanceof Error ? error.message : String(error)}`,
|
|
126
|
+
isError: true
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
schedule = scheduler.create({
|
|
130
|
+
trigger: input.trigger,
|
|
131
|
+
file,
|
|
132
|
+
...input.extraPrompt ? { extraPrompt: input.extraPrompt } : {},
|
|
133
|
+
createdBy: "agent"
|
|
134
|
+
}, target);
|
|
135
|
+
}
|
|
136
|
+
return { content: `Created schedule ${formatSchedule(schedule)}` };
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
const scheduleListTool = createTool({
|
|
140
|
+
id: SCHEDULE_TOOL_IDS.list,
|
|
141
|
+
description: "List the recurring prompt schedules on this thread, including ones the user created with /schedules.",
|
|
142
|
+
inputSchema: z.object({}),
|
|
143
|
+
outputSchema: resultSchema,
|
|
144
|
+
execute: async (_input, context) => {
|
|
145
|
+
const target = threadOf(context);
|
|
146
|
+
if (!target) return NO_THREAD;
|
|
147
|
+
const schedules = scheduler.list({ threadId: target.threadId });
|
|
148
|
+
if (schedules.length === 0) return { content: "No schedules on this thread." };
|
|
149
|
+
return { content: [`Schedules on this thread (${schedules.length}):`, ...schedules.map(formatSchedule)].join("\n") };
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
const scheduleUpdateTool = createTool({
|
|
153
|
+
id: SCHEDULE_TOOL_IDS.update,
|
|
154
|
+
description: "Pause or delete a schedule on this thread. Use schedule_resume to resume a paused one.",
|
|
155
|
+
inputSchema: z.object({
|
|
156
|
+
id: idSchema,
|
|
157
|
+
action: z.enum(["pause", "delete"])
|
|
158
|
+
}),
|
|
159
|
+
outputSchema: resultSchema,
|
|
160
|
+
execute: async ({ id, action }, context) => {
|
|
161
|
+
const target = threadOf(context);
|
|
162
|
+
if (!target) return NO_THREAD;
|
|
163
|
+
const found = findOne(scheduler, target.threadId, id);
|
|
164
|
+
if (!("schedule" in found)) return found;
|
|
165
|
+
scheduler[action](found.schedule.id);
|
|
166
|
+
return { content: `${action === "pause" ? "Paused" : "Deleted"} schedule ${shortScheduleId(found.schedule.id)}.` };
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
const scheduleResumeTool = createTool({
|
|
170
|
+
id: SCHEDULE_TOOL_IDS.resume,
|
|
171
|
+
description: "Resume a paused schedule on this thread. It fires again from the next clock boundary.",
|
|
172
|
+
inputSchema: z.object({ id: idSchema }),
|
|
173
|
+
outputSchema: resultSchema,
|
|
174
|
+
execute: async ({ id }, context) => {
|
|
175
|
+
const target = threadOf(context);
|
|
176
|
+
if (!target) return NO_THREAD;
|
|
177
|
+
const found = findOne(scheduler, target.threadId, id);
|
|
178
|
+
if (!("schedule" in found)) return found;
|
|
179
|
+
scheduler.resume(found.schedule.id);
|
|
180
|
+
return { content: `Resumed schedule ${shortScheduleId(found.schedule.id)}.` };
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
const scheduleRunTool = createTool({
|
|
184
|
+
id: SCHEDULE_TOOL_IDS.run,
|
|
185
|
+
description: "Fire a schedule on this thread once now, even if it is paused, without changing its cadence. Its prompt arrives as the next user turn.",
|
|
186
|
+
inputSchema: z.object({ id: idSchema }),
|
|
187
|
+
outputSchema: resultSchema,
|
|
188
|
+
execute: async ({ id }, context) => {
|
|
189
|
+
const target = threadOf(context);
|
|
190
|
+
if (!target) return NO_THREAD;
|
|
191
|
+
const found = findOne(scheduler, target.threadId, id);
|
|
192
|
+
if (!("schedule" in found)) return found;
|
|
193
|
+
const short = shortScheduleId(found.schedule.id);
|
|
194
|
+
const result = await scheduler.run(found.schedule.id);
|
|
195
|
+
switch (result.status) {
|
|
196
|
+
case "fired": return { content: `Triggered schedule ${short}; its prompt arrives as the next turn.` };
|
|
197
|
+
case "busy": return { content: `Schedule ${short} is already firing; skipped so its prompt isn't sent twice.` };
|
|
198
|
+
case "not-found": return {
|
|
199
|
+
content: `Schedule ${short} was deleted before it fired.`,
|
|
200
|
+
isError: true
|
|
201
|
+
};
|
|
202
|
+
case "failed": return {
|
|
203
|
+
content: `Schedule ${short} failed to fire: ${errorMessage(result.error)}`,
|
|
204
|
+
isError: true
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
return {
|
|
210
|
+
[SCHEDULE_TOOL_IDS.create]: scheduleCreateTool,
|
|
211
|
+
[SCHEDULE_TOOL_IDS.list]: scheduleListTool,
|
|
212
|
+
[SCHEDULE_TOOL_IDS.update]: scheduleUpdateTool,
|
|
213
|
+
[SCHEDULE_TOOL_IDS.resume]: scheduleResumeTool,
|
|
214
|
+
[SCHEDULE_TOOL_IDS.run]: scheduleRunTool
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
export { SCHEDULE_TOOL_IDS, createScheduleTools };
|