@cjhyy/code-shell-core 0.5.0-rc.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/LICENSE +21 -0
- package/README.md +162 -0
- package/dist/agent/coordinator.d.ts +49 -0
- package/dist/agent/coordinator.js +77 -0
- package/dist/arena/arena.d.ts +43 -0
- package/dist/arena/arena.js +334 -0
- package/dist/arena/context/context-tools.d.ts +16 -0
- package/dist/arena/context/context-tools.js +231 -0
- package/dist/arena/detect-mode.d.ts +20 -0
- package/dist/arena/detect-mode.js +78 -0
- package/dist/arena/digest-builder.d.ts +25 -0
- package/dist/arena/digest-builder.js +120 -0
- package/dist/arena/index.d.ts +29 -0
- package/dist/arena/index.js +29 -0
- package/dist/arena/iterate/convergence.d.ts +25 -0
- package/dist/arena/iterate/convergence.js +103 -0
- package/dist/arena/iterate/formats/index.d.ts +22 -0
- package/dist/arena/iterate/formats/index.js +283 -0
- package/dist/arena/iterate/index.d.ts +11 -0
- package/dist/arena/iterate/index.js +9 -0
- package/dist/arena/iterate/iterative-arena.d.ts +23 -0
- package/dist/arena/iterate/iterative-arena.js +237 -0
- package/dist/arena/iterate/parse.d.ts +42 -0
- package/dist/arena/iterate/parse.js +123 -0
- package/dist/arena/iterate/phases/argue.d.ts +22 -0
- package/dist/arena/iterate/phases/argue.js +159 -0
- package/dist/arena/iterate/phases/revise.d.ts +16 -0
- package/dist/arena/iterate/phases/revise.js +62 -0
- package/dist/arena/iterate/phases/tournament.d.ts +34 -0
- package/dist/arena/iterate/phases/tournament.js +113 -0
- package/dist/arena/iterate/tools/web-tools.d.ts +13 -0
- package/dist/arena/iterate/tools/web-tools.js +54 -0
- package/dist/arena/iterate/types.d.ts +152 -0
- package/dist/arena/iterate/types.js +8 -0
- package/dist/arena/ledger.d.ts +47 -0
- package/dist/arena/ledger.js +151 -0
- package/dist/arena/lenses/architecture.d.ts +5 -0
- package/dist/arena/lenses/architecture.js +22 -0
- package/dist/arena/lenses/engineering.d.ts +5 -0
- package/dist/arena/lenses/engineering.js +22 -0
- package/dist/arena/lenses/general.d.ts +5 -0
- package/dist/arena/lenses/general.js +20 -0
- package/dist/arena/lenses/index.d.ts +16 -0
- package/dist/arena/lenses/index.js +47 -0
- package/dist/arena/lenses/product.d.ts +5 -0
- package/dist/arena/lenses/product.js +22 -0
- package/dist/arena/model-presets.d.ts +23 -0
- package/dist/arena/model-presets.js +44 -0
- package/dist/arena/phases/adjudication.d.ts +24 -0
- package/dist/arena/phases/adjudication.js +144 -0
- package/dist/arena/phases/build-consensus.d.ts +29 -0
- package/dist/arena/phases/build-consensus.js +86 -0
- package/dist/arena/phases/claim-registry.d.ts +26 -0
- package/dist/arena/phases/claim-registry.js +60 -0
- package/dist/arena/phases/cross-review.d.ts +45 -0
- package/dist/arena/phases/cross-review.js +224 -0
- package/dist/arena/phases/debate-rounds.d.ts +27 -0
- package/dist/arena/phases/debate-rounds.js +162 -0
- package/dist/arena/phases/participant-research.d.ts +38 -0
- package/dist/arena/phases/participant-research.js +317 -0
- package/dist/arena/phases/planning-detail-expansion.d.ts +38 -0
- package/dist/arena/phases/planning-detail-expansion.js +121 -0
- package/dist/arena/planner.d.ts +27 -0
- package/dist/arena/planner.js +312 -0
- package/dist/arena/providers/docs.d.ts +6 -0
- package/dist/arena/providers/docs.js +108 -0
- package/dist/arena/providers/git.d.ts +8 -0
- package/dist/arena/providers/git.js +174 -0
- package/dist/arena/providers/index.d.ts +32 -0
- package/dist/arena/providers/index.js +132 -0
- package/dist/arena/providers/none.d.ts +7 -0
- package/dist/arena/providers/none.js +11 -0
- package/dist/arena/providers/repo.d.ts +6 -0
- package/dist/arena/providers/repo.js +255 -0
- package/dist/arena/render/session.d.ts +17 -0
- package/dist/arena/render/session.js +190 -0
- package/dist/arena/render/terminal.d.ts +34 -0
- package/dist/arena/render/terminal.js +286 -0
- package/dist/arena/strategies/discussion.d.ts +25 -0
- package/dist/arena/strategies/discussion.js +143 -0
- package/dist/arena/strategies/index.d.ts +15 -0
- package/dist/arena/strategies/index.js +28 -0
- package/dist/arena/strategies/language-wrapper.d.ts +17 -0
- package/dist/arena/strategies/language-wrapper.js +102 -0
- package/dist/arena/strategies/lens-wrapper.d.ts +16 -0
- package/dist/arena/strategies/lens-wrapper.js +236 -0
- package/dist/arena/strategies/planning.d.ts +30 -0
- package/dist/arena/strategies/planning.js +225 -0
- package/dist/arena/strategies/review.d.ts +26 -0
- package/dist/arena/strategies/review.js +168 -0
- package/dist/arena/strategies/utils.d.ts +39 -0
- package/dist/arena/strategies/utils.js +647 -0
- package/dist/arena/tools/selector.d.ts +17 -0
- package/dist/arena/tools/selector.js +61 -0
- package/dist/arena/transitions.d.ts +48 -0
- package/dist/arena/transitions.js +92 -0
- package/dist/arena/types.d.ts +508 -0
- package/dist/arena/types.js +27 -0
- package/dist/cli/agent-server-stdio.d.ts +32 -0
- package/dist/cli/agent-server-stdio.js +116 -0
- package/dist/colorizer.d.ts +23 -0
- package/dist/colorizer.js +12 -0
- package/dist/context/compaction.d.ts +116 -0
- package/dist/context/compaction.js +534 -0
- package/dist/context/manager.d.ts +145 -0
- package/dist/context/manager.js +423 -0
- package/dist/context/token-counter.d.ts +27 -0
- package/dist/context/token-counter.js +91 -0
- package/dist/context/tool-result-storage.d.ts +96 -0
- package/dist/context/tool-result-storage.js +296 -0
- package/dist/cost-tracker.d.ts +64 -0
- package/dist/cost-tracker.js +314 -0
- package/dist/cron/scheduler.d.ts +34 -0
- package/dist/cron/scheduler.js +115 -0
- package/dist/data/deepseek-models.json +46 -0
- package/dist/data/gemini-models.json +67 -0
- package/dist/data/openai-models.json +175 -0
- package/dist/data/openrouter-models.d.ts +35 -0
- package/dist/data/openrouter-models.js +36 -0
- package/dist/data/openrouter-models.json +4626 -0
- package/dist/data/openrouter-sync.d.ts +16 -0
- package/dist/data/openrouter-sync.js +53 -0
- package/dist/data/static-catalogs.d.ts +25 -0
- package/dist/data/static-catalogs.js +26 -0
- package/dist/data/zai-models.json +56 -0
- package/dist/engine/cost-store.d.ts +22 -0
- package/dist/engine/cost-store.js +15 -0
- package/dist/engine/engine.d.ts +295 -0
- package/dist/engine/engine.js +1467 -0
- package/dist/engine/model-facade.d.ts +24 -0
- package/dist/engine/model-facade.js +194 -0
- package/dist/engine/parse-task.d.ts +59 -0
- package/dist/engine/parse-task.js +135 -0
- package/dist/engine/patch-orphaned-tools.d.ts +52 -0
- package/dist/engine/patch-orphaned-tools.js +95 -0
- package/dist/engine/query.d.ts +50 -0
- package/dist/engine/query.js +107 -0
- package/dist/engine/runtime.d.ts +50 -0
- package/dist/engine/runtime.js +59 -0
- package/dist/engine/streaming-tool-queue.d.ts +34 -0
- package/dist/engine/streaming-tool-queue.js +61 -0
- package/dist/engine/token-budget.d.ts +22 -0
- package/dist/engine/token-budget.js +40 -0
- package/dist/engine/tool-summary.d.ts +13 -0
- package/dist/engine/tool-summary.js +35 -0
- package/dist/engine/turn-loop.d.ts +122 -0
- package/dist/engine/turn-loop.js +602 -0
- package/dist/engine/turn-state.d.ts +20 -0
- package/dist/engine/turn-state.js +17 -0
- package/dist/exceptions.d.ts +61 -0
- package/dist/exceptions.js +116 -0
- package/dist/git/utils.d.ts +35 -0
- package/dist/git/utils.js +98 -0
- package/dist/git/worktree.d.ts +36 -0
- package/dist/git/worktree.js +139 -0
- package/dist/hooks/events.d.ts +114 -0
- package/dist/hooks/events.js +4 -0
- package/dist/hooks/inject.d.ts +19 -0
- package/dist/hooks/inject.js +29 -0
- package/dist/hooks/registry.d.ts +15 -0
- package/dist/hooks/registry.js +84 -0
- package/dist/hooks/shell-runner.d.ts +45 -0
- package/dist/hooks/shell-runner.js +173 -0
- package/dist/index.d.ts +117 -0
- package/dist/index.js +145 -0
- package/dist/llm/api-key-sanitize.d.ts +22 -0
- package/dist/llm/api-key-sanitize.js +81 -0
- package/dist/llm/capabilities/index.d.ts +20 -0
- package/dist/llm/capabilities/index.js +39 -0
- package/dist/llm/capabilities/rules.d.ts +26 -0
- package/dist/llm/capabilities/rules.js +215 -0
- package/dist/llm/capabilities/types.d.ts +114 -0
- package/dist/llm/capabilities/types.js +24 -0
- package/dist/llm/client-base.d.ts +29 -0
- package/dist/llm/client-base.js +137 -0
- package/dist/llm/client-factory.d.ts +10 -0
- package/dist/llm/client-factory.js +29 -0
- package/dist/llm/model-cache.d.ts +21 -0
- package/dist/llm/model-cache.js +46 -0
- package/dist/llm/model-fetcher.d.ts +29 -0
- package/dist/llm/model-fetcher.js +282 -0
- package/dist/llm/model-pool.d.ts +95 -0
- package/dist/llm/model-pool.js +246 -0
- package/dist/llm/provider-catalog.d.ts +32 -0
- package/dist/llm/provider-catalog.js +50 -0
- package/dist/llm/provider-kinds.d.ts +21 -0
- package/dist/llm/provider-kinds.js +132 -0
- package/dist/llm/providers/anthropic.d.ts +19 -0
- package/dist/llm/providers/anthropic.js +267 -0
- package/dist/llm/providers/openai.d.ts +64 -0
- package/dist/llm/providers/openai.js +606 -0
- package/dist/llm/retry.d.ts +12 -0
- package/dist/llm/retry.js +17 -0
- package/dist/llm/stream-watchdog.d.ts +42 -0
- package/dist/llm/stream-watchdog.js +70 -0
- package/dist/llm/token-counter.d.ts +17 -0
- package/dist/llm/token-counter.js +36 -0
- package/dist/llm/types.d.ts +37 -0
- package/dist/llm/types.js +4 -0
- package/dist/logging/logger.d.ts +109 -0
- package/dist/logging/logger.js +390 -0
- package/dist/logging/sanitize-messages.d.ts +42 -0
- package/dist/logging/sanitize-messages.js +150 -0
- package/dist/logging/session-recorder.d.ts +90 -0
- package/dist/logging/session-recorder.js +304 -0
- package/dist/lsp/client.d.ts +41 -0
- package/dist/lsp/client.js +166 -0
- package/dist/lsp/manager.d.ts +40 -0
- package/dist/lsp/manager.js +124 -0
- package/dist/lsp/servers.d.ts +16 -0
- package/dist/lsp/servers.js +60 -0
- package/dist/migrate-models.d.ts +45 -0
- package/dist/migrate-models.js +179 -0
- package/dist/onboarding.d.ts +189 -0
- package/dist/onboarding.js +625 -0
- package/dist/plugins/gitOps.d.ts +32 -0
- package/dist/plugins/gitOps.js +62 -0
- package/dist/plugins/installedPlugins.d.ts +15 -0
- package/dist/plugins/installedPlugins.js +56 -0
- package/dist/plugins/knownMarketplaces.d.ts +10 -0
- package/dist/plugins/knownMarketplaces.js +46 -0
- package/dist/plugins/loadPluginHooks.d.ts +52 -0
- package/dist/plugins/loadPluginHooks.js +162 -0
- package/dist/plugins/marketplaceManager.d.ts +49 -0
- package/dist/plugins/marketplaceManager.js +142 -0
- package/dist/plugins/parseMarketplaceInput.d.ts +16 -0
- package/dist/plugins/parseMarketplaceInput.js +73 -0
- package/dist/plugins/pluginCommandHook.d.ts +54 -0
- package/dist/plugins/pluginCommandHook.js +180 -0
- package/dist/plugins/pluginCommandsLoader.d.ts +25 -0
- package/dist/plugins/pluginCommandsLoader.js +114 -0
- package/dist/plugins/pluginInstaller.d.ts +36 -0
- package/dist/plugins/pluginInstaller.js +228 -0
- package/dist/plugins/schemas.d.ts +9 -0
- package/dist/plugins/schemas.js +136 -0
- package/dist/plugins/types.d.ts +75 -0
- package/dist/plugins/types.js +7 -0
- package/dist/plugins/varRewrite.d.ts +42 -0
- package/dist/plugins/varRewrite.js +129 -0
- package/dist/preset/index.d.ts +60 -0
- package/dist/preset/index.js +159 -0
- package/dist/product/define.d.ts +60 -0
- package/dist/product/define.js +123 -0
- package/dist/product/index.d.ts +5 -0
- package/dist/product/index.js +4 -0
- package/dist/product/types.d.ts +111 -0
- package/dist/product/types.js +21 -0
- package/dist/prompt/composer.d.ts +49 -0
- package/dist/prompt/composer.js +168 -0
- package/dist/prompt/instruction-scanner.d.ts +54 -0
- package/dist/prompt/instruction-scanner.js +187 -0
- package/dist/prompt/section-cache.d.ts +15 -0
- package/dist/prompt/section-cache.js +31 -0
- package/dist/prompt/section-loader.d.ts +26 -0
- package/dist/prompt/section-loader.js +53 -0
- package/dist/prompt/sections/base.md +35 -0
- package/dist/prompt/sections/coding.md +31 -0
- package/dist/prompt/sections/orchestration.md +16 -0
- package/dist/prompt/sections/tone.md +9 -0
- package/dist/protocol/chat-session-manager.d.ts +33 -0
- package/dist/protocol/chat-session-manager.js +65 -0
- package/dist/protocol/chat-session.d.ts +49 -0
- package/dist/protocol/chat-session.js +86 -0
- package/dist/protocol/client.d.ts +104 -0
- package/dist/protocol/client.js +260 -0
- package/dist/protocol/factories.d.ts +93 -0
- package/dist/protocol/factories.js +64 -0
- package/dist/protocol/helpers.d.ts +42 -0
- package/dist/protocol/helpers.js +55 -0
- package/dist/protocol/index.d.ts +4 -0
- package/dist/protocol/index.js +4 -0
- package/dist/protocol/server.d.ts +80 -0
- package/dist/protocol/server.js +855 -0
- package/dist/protocol/transport.d.ts +37 -0
- package/dist/protocol/transport.js +85 -0
- package/dist/protocol/types.d.ts +221 -0
- package/dist/protocol/types.js +61 -0
- package/dist/remote/bridge.d.ts +37 -0
- package/dist/remote/bridge.js +103 -0
- package/dist/run/ArtifactTracker.d.ts +38 -0
- package/dist/run/ArtifactTracker.js +132 -0
- package/dist/run/CheckpointWriter.d.ts +53 -0
- package/dist/run/CheckpointWriter.js +135 -0
- package/dist/run/EngineRunner.d.ts +72 -0
- package/dist/run/EngineRunner.js +119 -0
- package/dist/run/Evaluator.d.ts +56 -0
- package/dist/run/Evaluator.js +62 -0
- package/dist/run/FileRunStore.d.ts +39 -0
- package/dist/run/FileRunStore.js +176 -0
- package/dist/run/Heartbeat.d.ts +54 -0
- package/dist/run/Heartbeat.js +123 -0
- package/dist/run/RunApprovalBackend.d.ts +53 -0
- package/dist/run/RunApprovalBackend.js +85 -0
- package/dist/run/RunLock.d.ts +40 -0
- package/dist/run/RunLock.js +98 -0
- package/dist/run/RunManager.d.ts +82 -0
- package/dist/run/RunManager.js +587 -0
- package/dist/run/RunQueue.d.ts +27 -0
- package/dist/run/RunQueue.js +73 -0
- package/dist/run/RunStore.d.ts +25 -0
- package/dist/run/RunStore.js +9 -0
- package/dist/run/factory.d.ts +63 -0
- package/dist/run/factory.js +51 -0
- package/dist/run/index.d.ts +17 -0
- package/dist/run/index.js +23 -0
- package/dist/run/types.d.ts +136 -0
- package/dist/run/types.js +28 -0
- package/dist/runtime/safe-spawn.d.ts +118 -0
- package/dist/runtime/safe-spawn.js +268 -0
- package/dist/services/analytics.d.ts +29 -0
- package/dist/services/analytics.js +84 -0
- package/dist/services/auto-dream.d.ts +49 -0
- package/dist/services/auto-dream.js +124 -0
- package/dist/services/diagnostics.d.ts +41 -0
- package/dist/services/diagnostics.js +99 -0
- package/dist/services/extract-memories.d.ts +31 -0
- package/dist/services/extract-memories.js +71 -0
- package/dist/services/index.d.ts +11 -0
- package/dist/services/index.js +17 -0
- package/dist/services/memory-orchestrator.d.ts +60 -0
- package/dist/services/memory-orchestrator.js +133 -0
- package/dist/services/notifier.d.ts +25 -0
- package/dist/services/notifier.js +69 -0
- package/dist/services/oauth.d.ts +27 -0
- package/dist/services/oauth.js +153 -0
- package/dist/services/session-memory.d.ts +37 -0
- package/dist/services/session-memory.js +81 -0
- package/dist/session/file-history.d.ts +41 -0
- package/dist/session/file-history.js +115 -0
- package/dist/session/memory.d.ts +104 -0
- package/dist/session/memory.js +310 -0
- package/dist/session/session-manager.d.ts +41 -0
- package/dist/session/session-manager.js +261 -0
- package/dist/session/transcript.d.ts +39 -0
- package/dist/session/transcript.js +186 -0
- package/dist/settings/manager.d.ts +36 -0
- package/dist/settings/manager.js +187 -0
- package/dist/settings/schema.d.ts +1219 -0
- package/dist/settings/schema.js +246 -0
- package/dist/skills/frontmatter.d.ts +13 -0
- package/dist/skills/frontmatter.js +70 -0
- package/dist/skills/index.d.ts +7 -0
- package/dist/skills/index.js +6 -0
- package/dist/skills/scanner.d.ts +31 -0
- package/dist/skills/scanner.js +171 -0
- package/dist/state.d.ts +160 -0
- package/dist/state.js +267 -0
- package/dist/tool-system/builtin/agent-notifications.d.ts +84 -0
- package/dist/tool-system/builtin/agent-notifications.js +197 -0
- package/dist/tool-system/builtin/agent-registry.d.ts +67 -0
- package/dist/tool-system/builtin/agent-registry.js +126 -0
- package/dist/tool-system/builtin/agent-transcript-translator.d.ts +22 -0
- package/dist/tool-system/builtin/agent-transcript-translator.js +160 -0
- package/dist/tool-system/builtin/agent.d.ts +16 -0
- package/dist/tool-system/builtin/agent.js +364 -0
- package/dist/tool-system/builtin/apply-patch/applier.d.ts +26 -0
- package/dist/tool-system/builtin/apply-patch/applier.js +250 -0
- package/dist/tool-system/builtin/apply-patch/index.d.ts +20 -0
- package/dist/tool-system/builtin/apply-patch/index.js +101 -0
- package/dist/tool-system/builtin/apply-patch/parser.d.ts +17 -0
- package/dist/tool-system/builtin/apply-patch/parser.js +212 -0
- package/dist/tool-system/builtin/apply-patch/seek-sequence.d.ts +18 -0
- package/dist/tool-system/builtin/apply-patch/seek-sequence.js +123 -0
- package/dist/tool-system/builtin/apply-patch/types.d.ts +49 -0
- package/dist/tool-system/builtin/apply-patch/types.js +13 -0
- package/dist/tool-system/builtin/arena.d.ts +31 -0
- package/dist/tool-system/builtin/arena.js +416 -0
- package/dist/tool-system/builtin/ask-user.d.ts +20 -0
- package/dist/tool-system/builtin/ask-user.js +99 -0
- package/dist/tool-system/builtin/bash.d.ts +21 -0
- package/dist/tool-system/builtin/bash.js +149 -0
- package/dist/tool-system/builtin/brief.d.ts +6 -0
- package/dist/tool-system/builtin/brief.js +41 -0
- package/dist/tool-system/builtin/config.d.ts +6 -0
- package/dist/tool-system/builtin/config.js +67 -0
- package/dist/tool-system/builtin/cron.d.ts +10 -0
- package/dist/tool-system/builtin/cron.js +61 -0
- package/dist/tool-system/builtin/edit.d.ts +6 -0
- package/dist/tool-system/builtin/edit.js +100 -0
- package/dist/tool-system/builtin/file-cache.d.ts +11 -0
- package/dist/tool-system/builtin/file-cache.js +39 -0
- package/dist/tool-system/builtin/glob.d.ts +7 -0
- package/dist/tool-system/builtin/glob.js +76 -0
- package/dist/tool-system/builtin/grep.d.ts +7 -0
- package/dist/tool-system/builtin/grep.js +150 -0
- package/dist/tool-system/builtin/index.d.ts +20 -0
- package/dist/tool-system/builtin/index.js +449 -0
- package/dist/tool-system/builtin/lsp.d.ts +6 -0
- package/dist/tool-system/builtin/lsp.js +141 -0
- package/dist/tool-system/builtin/mcp-tools.d.ts +10 -0
- package/dist/tool-system/builtin/mcp-tools.js +102 -0
- package/dist/tool-system/builtin/memory.d.ts +26 -0
- package/dist/tool-system/builtin/memory.js +226 -0
- package/dist/tool-system/builtin/notebook-edit.d.ts +6 -0
- package/dist/tool-system/builtin/notebook-edit.js +124 -0
- package/dist/tool-system/builtin/plan.d.ts +15 -0
- package/dist/tool-system/builtin/plan.js +55 -0
- package/dist/tool-system/builtin/powershell.d.ts +11 -0
- package/dist/tool-system/builtin/powershell.js +64 -0
- package/dist/tool-system/builtin/read.d.ts +6 -0
- package/dist/tool-system/builtin/read.js +70 -0
- package/dist/tool-system/builtin/remote-trigger.d.ts +6 -0
- package/dist/tool-system/builtin/remote-trigger.js +54 -0
- package/dist/tool-system/builtin/repl.d.ts +11 -0
- package/dist/tool-system/builtin/repl.js +82 -0
- package/dist/tool-system/builtin/send-message.d.ts +6 -0
- package/dist/tool-system/builtin/send-message.js +47 -0
- package/dist/tool-system/builtin/skill-prompt.d.ts +20 -0
- package/dist/tool-system/builtin/skill-prompt.js +52 -0
- package/dist/tool-system/builtin/skill.d.ts +9 -0
- package/dist/tool-system/builtin/skill.js +55 -0
- package/dist/tool-system/builtin/sleep.d.ts +6 -0
- package/dist/tool-system/builtin/sleep.js +33 -0
- package/dist/tool-system/builtin/task.d.ts +48 -0
- package/dist/tool-system/builtin/task.js +139 -0
- package/dist/tool-system/builtin/tool-search.d.ts +11 -0
- package/dist/tool-system/builtin/tool-search.js +90 -0
- package/dist/tool-system/builtin/web-fetch.d.ts +10 -0
- package/dist/tool-system/builtin/web-fetch.js +328 -0
- package/dist/tool-system/builtin/web-search.d.ts +25 -0
- package/dist/tool-system/builtin/web-search.js +174 -0
- package/dist/tool-system/builtin/worktree.d.ts +10 -0
- package/dist/tool-system/builtin/worktree.js +95 -0
- package/dist/tool-system/builtin/write.d.ts +6 -0
- package/dist/tool-system/builtin/write.js +36 -0
- package/dist/tool-system/context.d.ts +165 -0
- package/dist/tool-system/context.js +18 -0
- package/dist/tool-system/executor.d.ts +49 -0
- package/dist/tool-system/executor.js +495 -0
- package/dist/tool-system/investigation-guard.d.ts +46 -0
- package/dist/tool-system/investigation-guard.js +155 -0
- package/dist/tool-system/mcp-manager.d.ts +67 -0
- package/dist/tool-system/mcp-manager.js +249 -0
- package/dist/tool-system/permission.d.ts +111 -0
- package/dist/tool-system/permission.js +774 -0
- package/dist/tool-system/registry.d.ts +32 -0
- package/dist/tool-system/registry.js +131 -0
- package/dist/tool-system/sandbox/bwrap.d.ts +13 -0
- package/dist/tool-system/sandbox/bwrap.js +63 -0
- package/dist/tool-system/sandbox/index.d.ts +78 -0
- package/dist/tool-system/sandbox/index.js +222 -0
- package/dist/tool-system/sandbox/off.d.ts +2 -0
- package/dist/tool-system/sandbox/off.js +8 -0
- package/dist/tool-system/sandbox/seatbelt.d.ts +18 -0
- package/dist/tool-system/sandbox/seatbelt.js +109 -0
- package/dist/tool-system/task-guard.d.ts +29 -0
- package/dist/tool-system/task-guard.js +70 -0
- package/dist/tool-system/validation.d.ts +5 -0
- package/dist/tool-system/validation.js +39 -0
- package/dist/types.d.ts +376 -0
- package/dist/types.js +4 -0
- package/dist/updater.d.ts +65 -0
- package/dist/updater.js +405 -0
- package/dist/utils/debug.d.ts +41 -0
- package/dist/utils/debug.js +110 -0
- package/dist/utils/earlyInput.d.ts +43 -0
- package/dist/utils/earlyInput.js +166 -0
- package/dist/utils/env.d.ts +24 -0
- package/dist/utils/env.js +104 -0
- package/dist/utils/envUtils.d.ts +51 -0
- package/dist/utils/envUtils.js +135 -0
- package/dist/utils/execFileNoThrow.d.ts +39 -0
- package/dist/utils/execFileNoThrow.js +74 -0
- package/dist/utils/format.d.ts +44 -0
- package/dist/utils/format.js +236 -0
- package/dist/utils/intl.d.ts +22 -0
- package/dist/utils/intl.js +83 -0
- package/dist/utils/lockfile.d.ts +15 -0
- package/dist/utils/lockfile.js +30 -0
- package/dist/utils/memoize.d.ts +19 -0
- package/dist/utils/memoize.js +14 -0
- package/dist/utils/semver.d.ts +6 -0
- package/dist/utils/semver.js +13 -0
- package/dist/utils/sliceAnsi.d.ts +12 -0
- package/dist/utils/sliceAnsi.js +62 -0
- package/dist/utils/systemTheme.d.ts +40 -0
- package/dist/utils/systemTheme.js +108 -0
- package/dist/utils/task-sanitizer.d.ts +6 -0
- package/dist/utils/task-sanitizer.js +24 -0
- package/dist/utils/theme.d.ts +93 -0
- package/dist/utils/theme.js +544 -0
- package/dist/utils/toolDisplay.d.ts +31 -0
- package/dist/utils/toolDisplay.js +188 -0
- package/package.json +72 -0
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cost tracker — tracks token usage and calculates estimated costs.
|
|
3
|
+
*/
|
|
4
|
+
import { NOOP_COLORIZER } from "./colorizer.js";
|
|
5
|
+
import { findOpenRouterModel } from "./data/openrouter-models.js";
|
|
6
|
+
function pricing(input, output) {
|
|
7
|
+
// Default cache pricing: read = 10% of input, write = 125% of input
|
|
8
|
+
return { input, output, cacheRead: input * 0.1, cacheWrite: input * 1.25 };
|
|
9
|
+
}
|
|
10
|
+
const MODEL_PRICING = {
|
|
11
|
+
// Anthropic (per 1M tokens, USD)
|
|
12
|
+
"claude-opus-4.6": { input: 15, output: 75, cacheRead: 1.5, cacheWrite: 18.75 },
|
|
13
|
+
"claude-opus-4-6": { input: 15, output: 75, cacheRead: 1.5, cacheWrite: 18.75 }, // alias
|
|
14
|
+
"claude-opus-4.5": { input: 15, output: 75, cacheRead: 1.5, cacheWrite: 18.75 },
|
|
15
|
+
"claude-opus-4.1": { input: 15, output: 75, cacheRead: 1.5, cacheWrite: 18.75 },
|
|
16
|
+
"claude-opus-4": { input: 15, output: 75, cacheRead: 1.5, cacheWrite: 18.75 },
|
|
17
|
+
"claude-sonnet-4.6": { input: 3, output: 15, cacheRead: 0.3, cacheWrite: 3.75 },
|
|
18
|
+
"claude-sonnet-4-6": { input: 3, output: 15, cacheRead: 0.3, cacheWrite: 3.75 }, // alias
|
|
19
|
+
"claude-sonnet-4.5": { input: 3, output: 15, cacheRead: 0.3, cacheWrite: 3.75 },
|
|
20
|
+
"claude-sonnet-4": { input: 3, output: 15, cacheRead: 0.3, cacheWrite: 3.75 },
|
|
21
|
+
"claude-3.7-sonnet": { input: 3, output: 15, cacheRead: 0.3, cacheWrite: 3.75 },
|
|
22
|
+
"claude-3-7-sonnet": { input: 3, output: 15, cacheRead: 0.3, cacheWrite: 3.75 },
|
|
23
|
+
"claude-3.5-haiku": { input: 0.8, output: 4, cacheRead: 0.08, cacheWrite: 1 },
|
|
24
|
+
"claude-haiku-4.5": { input: 1, output: 5, cacheRead: 0.1, cacheWrite: 1.25 },
|
|
25
|
+
"claude-haiku-4-5": { input: 1, output: 5, cacheRead: 0.1, cacheWrite: 1.25 }, // alias
|
|
26
|
+
// OpenAI
|
|
27
|
+
"gpt-5.4": pricing(5, 20),
|
|
28
|
+
"gpt-5.4-mini": pricing(1.5, 6),
|
|
29
|
+
"gpt-5.4-pro": pricing(10, 40),
|
|
30
|
+
"gpt-5": pricing(5, 20),
|
|
31
|
+
"gpt-4o": pricing(2.5, 10),
|
|
32
|
+
"gpt-4o-mini": pricing(0.15, 0.6),
|
|
33
|
+
"gpt-4.1": pricing(2, 8),
|
|
34
|
+
"gpt-4.1-mini": pricing(0.4, 1.6),
|
|
35
|
+
"o4-mini": pricing(1.1, 4.4),
|
|
36
|
+
"o3": pricing(10, 40),
|
|
37
|
+
"o3-mini": pricing(1.1, 4.4),
|
|
38
|
+
// Google
|
|
39
|
+
"gemini-2.5-pro": pricing(1.25, 10),
|
|
40
|
+
"gemini-2.5-pro-preview": pricing(1.25, 10),
|
|
41
|
+
"gemini-2.5-flash": pricing(0.15, 0.6),
|
|
42
|
+
"gemini-3.1-pro-preview": pricing(2, 10),
|
|
43
|
+
"gemini-3-flash-preview": pricing(0.15, 0.6),
|
|
44
|
+
"gemini-2.0-flash": pricing(0.1, 0.4),
|
|
45
|
+
// DeepSeek
|
|
46
|
+
"deepseek-v4-flash": pricing(0.126, 0.252),
|
|
47
|
+
"deepseek-v4-pro": pricing(0.5, 2),
|
|
48
|
+
"deepseek-v3.2": pricing(0.14, 0.28),
|
|
49
|
+
"deepseek-chat": pricing(0.14, 0.28),
|
|
50
|
+
"deepseek-r1": pricing(0.55, 2.19),
|
|
51
|
+
"deepseek-reasoner": pricing(0.55, 2.19),
|
|
52
|
+
// Qwen
|
|
53
|
+
"qwen3-coder": pricing(0.3, 0.6),
|
|
54
|
+
"qwen3-235b-a22b": pricing(0.3, 1.2),
|
|
55
|
+
"qwen3-30b-a3b": pricing(0.1, 0.3),
|
|
56
|
+
"qwen3-max": pricing(0.5, 2),
|
|
57
|
+
// Meta
|
|
58
|
+
"llama-4-maverick": pricing(0.2, 0.8),
|
|
59
|
+
"llama-4-scout": pricing(0.15, 0.4),
|
|
60
|
+
// Mistral
|
|
61
|
+
"devstral-medium": pricing(0.5, 1.5),
|
|
62
|
+
"mistral-large": pricing(2, 6),
|
|
63
|
+
"devstral-small": pricing(0.1, 0.3),
|
|
64
|
+
};
|
|
65
|
+
// Default fallback pricing
|
|
66
|
+
const DEFAULT_PRICING = pricing(3, 15);
|
|
67
|
+
/** Build a ModelPricing from an OpenRouter snapshot entry. */
|
|
68
|
+
function openRouterPricing(hit) {
|
|
69
|
+
const input = hit.inputPricePerMillion;
|
|
70
|
+
const output = hit.outputPricePerMillion;
|
|
71
|
+
return {
|
|
72
|
+
pricing: {
|
|
73
|
+
input,
|
|
74
|
+
output,
|
|
75
|
+
// Snapshot doesn't carry cache pricing; use the same heuristic as pricing() helper
|
|
76
|
+
cacheRead: input * 0.1,
|
|
77
|
+
cacheWrite: input * 1.25,
|
|
78
|
+
},
|
|
79
|
+
known: true,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Resolve pricing for a model. Lookup order:
|
|
84
|
+
* 1. OpenRouter snapshot (by full ID like "deepseek/deepseek-v4-flash")
|
|
85
|
+
* 2. OpenRouter snapshot (by short name like "deepseek-v4-flash" → tries common vendors)
|
|
86
|
+
* 3. MODEL_PRICING by canonical name (strips provider prefix)
|
|
87
|
+
* 4. MODEL_PRICING by raw name
|
|
88
|
+
* 5. DEFAULT_PRICING fallback
|
|
89
|
+
*
|
|
90
|
+
* Returns { pricing, source } so callers can flag unknown-model warnings
|
|
91
|
+
* accurately (the snapshot path counts as known even if MODEL_PRICING misses).
|
|
92
|
+
*/
|
|
93
|
+
function lookupPricing(model) {
|
|
94
|
+
// Try OpenRouter snapshot lookup for models with vendor/ prefix
|
|
95
|
+
if (model.includes("/")) {
|
|
96
|
+
const hit = findOpenRouterModel(model);
|
|
97
|
+
if (hit && (hit.inputPricePerMillion > 0 || hit.outputPricePerMillion > 0)) {
|
|
98
|
+
return openRouterPricing(hit);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
// Also try OpenRouter for short names (e.g. "deepseek-v4-flash" → "deepseek/deepseek-v4-flash")
|
|
102
|
+
// by matching on the model part after the slash
|
|
103
|
+
const orHit = findOpenRouterModel(`deepseek/${model}`) ??
|
|
104
|
+
findOpenRouterModel(`openai/${model}`) ??
|
|
105
|
+
findOpenRouterModel(`anthropic/${model}`);
|
|
106
|
+
if (orHit && (orHit.inputPricePerMillion > 0 || orHit.outputPricePerMillion > 0)) {
|
|
107
|
+
return openRouterPricing(orHit);
|
|
108
|
+
}
|
|
109
|
+
const canonical = getCanonicalName(model);
|
|
110
|
+
const hit = MODEL_PRICING[canonical] ?? MODEL_PRICING[model];
|
|
111
|
+
if (hit)
|
|
112
|
+
return { pricing: hit, known: true };
|
|
113
|
+
return { pricing: DEFAULT_PRICING, known: false };
|
|
114
|
+
}
|
|
115
|
+
/** Normalize model names: strip provider prefix and version suffixes for consistent grouping. */
|
|
116
|
+
function getCanonicalName(model) {
|
|
117
|
+
// "anthropic/claude-opus-4-6" → "claude-opus-4-6"
|
|
118
|
+
const slashIdx = model.lastIndexOf("/");
|
|
119
|
+
const base = slashIdx >= 0 ? model.slice(slashIdx + 1) : model;
|
|
120
|
+
// Strip date suffixes like "-20250301"
|
|
121
|
+
return base.replace(/-\d{8}$/, "");
|
|
122
|
+
}
|
|
123
|
+
export class CostTracker {
|
|
124
|
+
records = [];
|
|
125
|
+
sessionStart = Date.now();
|
|
126
|
+
_hasUnknownModel = false;
|
|
127
|
+
record(model, promptTokens, completionTokens, isSubAgent = false, cacheReadTokens = 0, cacheWriteTokens = 0) {
|
|
128
|
+
const canonical = getCanonicalName(model);
|
|
129
|
+
if (!lookupPricing(model).known && !lookupPricing(canonical).known) {
|
|
130
|
+
this._hasUnknownModel = true;
|
|
131
|
+
}
|
|
132
|
+
this.records.push({
|
|
133
|
+
model: canonical,
|
|
134
|
+
promptTokens,
|
|
135
|
+
completionTokens,
|
|
136
|
+
cacheReadTokens,
|
|
137
|
+
cacheWriteTokens,
|
|
138
|
+
totalTokens: promptTokens + completionTokens,
|
|
139
|
+
timestamp: Date.now(),
|
|
140
|
+
isSubAgent,
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
getTotalTokens() {
|
|
144
|
+
let prompt = 0;
|
|
145
|
+
let completion = 0;
|
|
146
|
+
for (const r of this.records) {
|
|
147
|
+
prompt += r.promptTokens;
|
|
148
|
+
completion += r.completionTokens;
|
|
149
|
+
}
|
|
150
|
+
return { prompt, completion, total: prompt + completion };
|
|
151
|
+
}
|
|
152
|
+
getEstimatedCost() {
|
|
153
|
+
let totalCost = 0;
|
|
154
|
+
for (const r of this.records) {
|
|
155
|
+
const { pricing: p } = lookupPricing(r.model);
|
|
156
|
+
// promptTokens includes cache tokens — subtract them to avoid double billing
|
|
157
|
+
const uncachedInput = Math.max(0, r.promptTokens - r.cacheReadTokens - r.cacheWriteTokens);
|
|
158
|
+
totalCost += (uncachedInput / 1_000_000) * p.input;
|
|
159
|
+
totalCost += (r.completionTokens / 1_000_000) * p.output;
|
|
160
|
+
totalCost += (r.cacheReadTokens / 1_000_000) * p.cacheRead;
|
|
161
|
+
totalCost += (r.cacheWriteTokens / 1_000_000) * p.cacheWrite;
|
|
162
|
+
}
|
|
163
|
+
return totalCost;
|
|
164
|
+
}
|
|
165
|
+
getRequestCount() {
|
|
166
|
+
return this.records.length;
|
|
167
|
+
}
|
|
168
|
+
getSessionDuration() {
|
|
169
|
+
return Date.now() - this.sessionStart;
|
|
170
|
+
}
|
|
171
|
+
/** Estimate cost for a specific set of tokens without recording them. */
|
|
172
|
+
estimateForTokens(model, promptTokens, completionTokens, cacheReadTokens = 0, cacheWriteTokens = 0) {
|
|
173
|
+
const { pricing: p } = lookupPricing(model);
|
|
174
|
+
const uncachedInput = Math.max(0, promptTokens - cacheReadTokens - cacheWriteTokens);
|
|
175
|
+
return ((uncachedInput / 1_000_000) * p.input +
|
|
176
|
+
(completionTokens / 1_000_000) * p.output +
|
|
177
|
+
(cacheReadTokens / 1_000_000) * p.cacheRead +
|
|
178
|
+
(cacheWriteTokens / 1_000_000) * p.cacheWrite);
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Get total cache token counts.
|
|
182
|
+
*/
|
|
183
|
+
getCacheTokens() {
|
|
184
|
+
let cacheRead = 0;
|
|
185
|
+
let cacheWrite = 0;
|
|
186
|
+
for (const r of this.records) {
|
|
187
|
+
cacheRead += r.cacheReadTokens;
|
|
188
|
+
cacheWrite += r.cacheWriteTokens;
|
|
189
|
+
}
|
|
190
|
+
return { cacheRead, cacheWrite };
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Format a styled cost summary for terminal display.
|
|
194
|
+
*/
|
|
195
|
+
formatSummary(c = NOOP_COLORIZER) {
|
|
196
|
+
const tokens = this.getTotalTokens();
|
|
197
|
+
const cache = this.getCacheTokens();
|
|
198
|
+
const cost = this.getEstimatedCost();
|
|
199
|
+
const requests = this.getRequestCount();
|
|
200
|
+
const duration = this.getSessionDuration();
|
|
201
|
+
const lines = [];
|
|
202
|
+
lines.push(` ${c.boldCyan("Cost Summary")}`);
|
|
203
|
+
lines.push(c.dim(" ─".repeat(25)));
|
|
204
|
+
lines.push(` ${c.dim("Requests:")} ${c.white(String(requests))}`);
|
|
205
|
+
lines.push(` ${c.dim("Input tokens:")} ${c.white(formatNumber(tokens.prompt))}`);
|
|
206
|
+
lines.push(` ${c.dim("Output tokens:")} ${c.white(formatNumber(tokens.completion))}`);
|
|
207
|
+
if (cache.cacheRead > 0 || cache.cacheWrite > 0) {
|
|
208
|
+
lines.push(` ${c.dim("Cache read:")} ${c.white(formatNumber(cache.cacheRead))}`);
|
|
209
|
+
lines.push(` ${c.dim("Cache write:")} ${c.white(formatNumber(cache.cacheWrite))}`);
|
|
210
|
+
}
|
|
211
|
+
lines.push(` ${c.dim("Total cost:")} ${c.green(formatCost(cost))}`);
|
|
212
|
+
lines.push(` ${c.dim("Duration:")} ${c.white(formatDuration(duration))}`);
|
|
213
|
+
// Per-model breakdown (always show)
|
|
214
|
+
const modelMap = new Map();
|
|
215
|
+
for (const r of this.records) {
|
|
216
|
+
const existing = modelMap.get(r.model) ?? { prompt: 0, completion: 0, cacheRead: 0, cacheWrite: 0, count: 0 };
|
|
217
|
+
existing.prompt += r.promptTokens;
|
|
218
|
+
existing.completion += r.completionTokens;
|
|
219
|
+
existing.cacheRead += r.cacheReadTokens;
|
|
220
|
+
existing.cacheWrite += r.cacheWriteTokens;
|
|
221
|
+
existing.count++;
|
|
222
|
+
modelMap.set(r.model, existing);
|
|
223
|
+
}
|
|
224
|
+
if (modelMap.size >= 1) {
|
|
225
|
+
lines.push("");
|
|
226
|
+
lines.push(` ${c.dim("By model:")}`);
|
|
227
|
+
for (const [model, stats] of modelMap) {
|
|
228
|
+
const { pricing: p } = lookupPricing(model);
|
|
229
|
+
const uncachedInput = Math.max(0, stats.prompt - stats.cacheRead - stats.cacheWrite);
|
|
230
|
+
const modelCost = (uncachedInput / 1_000_000) * p.input +
|
|
231
|
+
(stats.completion / 1_000_000) * p.output +
|
|
232
|
+
(stats.cacheRead / 1_000_000) * p.cacheRead +
|
|
233
|
+
(stats.cacheWrite / 1_000_000) * p.cacheWrite;
|
|
234
|
+
const tokenDetail = `${formatNumber(stats.prompt)} in, ${formatNumber(stats.completion)} out` +
|
|
235
|
+
(stats.cacheRead > 0 ? `, ${formatNumber(stats.cacheRead)} cache` : "");
|
|
236
|
+
lines.push(` ${c.dim(model)} — ${tokenDetail}, ${formatCost(modelCost)} (${stats.count} reqs)`);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
if (this._hasUnknownModel) {
|
|
240
|
+
lines.push("");
|
|
241
|
+
lines.push(c.dim(" (costs may be inaccurate due to usage of unknown models)"));
|
|
242
|
+
}
|
|
243
|
+
return lines.join("\n");
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Format a compact one-line cost display for the prompt footer.
|
|
247
|
+
*/
|
|
248
|
+
formatCompact(c = NOOP_COLORIZER) {
|
|
249
|
+
const tokens = this.getTotalTokens();
|
|
250
|
+
const cost = this.getEstimatedCost();
|
|
251
|
+
return c.dim(`tokens: ${formatNumber(tokens.total)} | cost: ${formatCost(cost)}`);
|
|
252
|
+
}
|
|
253
|
+
reset() {
|
|
254
|
+
this.records = [];
|
|
255
|
+
this.sessionStart = Date.now();
|
|
256
|
+
}
|
|
257
|
+
/** Serialize cost state for session persistence. */
|
|
258
|
+
serialize() {
|
|
259
|
+
const tokens = this.getTotalTokens();
|
|
260
|
+
return {
|
|
261
|
+
records: this.records,
|
|
262
|
+
sessionStart: this.sessionStart,
|
|
263
|
+
totalPromptTokens: tokens.prompt,
|
|
264
|
+
totalCompletionTokens: tokens.completion,
|
|
265
|
+
estimatedCost: this.getEstimatedCost(),
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
/** Restore cost state from a previous session. */
|
|
269
|
+
restore(state) {
|
|
270
|
+
this.records = state.records ?? [];
|
|
271
|
+
this.sessionStart = state.sessionStart ?? Date.now();
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
function formatCost(cost) {
|
|
275
|
+
if (cost >= 0.5)
|
|
276
|
+
return `$${Math.round(cost * 100) / 100}`;
|
|
277
|
+
if (cost >= 0.01)
|
|
278
|
+
return `$${cost.toFixed(4)}`;
|
|
279
|
+
if (cost > 0)
|
|
280
|
+
return `$${cost.toFixed(6)}`;
|
|
281
|
+
return "$0.00";
|
|
282
|
+
}
|
|
283
|
+
function formatNumber(n) {
|
|
284
|
+
if (n >= 1_000_000)
|
|
285
|
+
return (n / 1_000_000).toFixed(1) + "M";
|
|
286
|
+
if (n >= 1_000)
|
|
287
|
+
return (n / 1_000).toFixed(1) + "K";
|
|
288
|
+
return String(n);
|
|
289
|
+
}
|
|
290
|
+
function formatDuration(ms) {
|
|
291
|
+
const s = Math.floor(ms / 1000);
|
|
292
|
+
if (s < 60)
|
|
293
|
+
return `${s}s`;
|
|
294
|
+
const m = Math.floor(s / 60);
|
|
295
|
+
const rs = s % 60;
|
|
296
|
+
if (m < 60)
|
|
297
|
+
return `${m}m ${rs}s`;
|
|
298
|
+
const h = Math.floor(m / 60);
|
|
299
|
+
const rm = m % 60;
|
|
300
|
+
return `${h}h ${rm}m`;
|
|
301
|
+
}
|
|
302
|
+
// Singleton for the current session
|
|
303
|
+
export const costTracker = new CostTracker();
|
|
304
|
+
/**
|
|
305
|
+
* Wire the LLM base-class usage hook into the singleton cost tracker.
|
|
306
|
+
* Called once from main.ts so every LLM call (REPL, run, arena, sub-agents)
|
|
307
|
+
* records into a single tracker without each call site having to remember.
|
|
308
|
+
*/
|
|
309
|
+
export async function installCostTracking() {
|
|
310
|
+
const { LLMClientBase } = await import("./llm/client-base.js");
|
|
311
|
+
LLMClientBase.onUsage = (model, usage) => {
|
|
312
|
+
costTracker.record(model, usage.promptTokens, usage.completionTokens, false, usage.cacheReadTokens ?? 0, usage.cacheCreationTokens ?? 0);
|
|
313
|
+
};
|
|
314
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cron scheduler — schedule and manage recurring agent tasks.
|
|
3
|
+
*
|
|
4
|
+
* Supports simple cron-like intervals. Each job runs the Engine
|
|
5
|
+
* with a predefined prompt on schedule.
|
|
6
|
+
*/
|
|
7
|
+
export interface CronJob {
|
|
8
|
+
id: string;
|
|
9
|
+
name: string;
|
|
10
|
+
schedule: string;
|
|
11
|
+
prompt: string;
|
|
12
|
+
enabled: boolean;
|
|
13
|
+
lastRun?: number;
|
|
14
|
+
nextRun?: number;
|
|
15
|
+
runCount: number;
|
|
16
|
+
createdAt: number;
|
|
17
|
+
}
|
|
18
|
+
declare class CronScheduler {
|
|
19
|
+
private jobs;
|
|
20
|
+
private timers;
|
|
21
|
+
private nextId;
|
|
22
|
+
private onExecute?;
|
|
23
|
+
setExecutor(fn: (job: CronJob) => Promise<void>): void;
|
|
24
|
+
create(name: string, schedule: string, prompt: string): CronJob;
|
|
25
|
+
delete(id: string): boolean;
|
|
26
|
+
list(): CronJob[];
|
|
27
|
+
get(id: string): CronJob | undefined;
|
|
28
|
+
pause(id: string): boolean;
|
|
29
|
+
resume(id: string): boolean;
|
|
30
|
+
stopAll(): void;
|
|
31
|
+
private startTimer;
|
|
32
|
+
}
|
|
33
|
+
export declare const cronScheduler: CronScheduler;
|
|
34
|
+
export {};
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cron scheduler — schedule and manage recurring agent tasks.
|
|
3
|
+
*
|
|
4
|
+
* Supports simple cron-like intervals. Each job runs the Engine
|
|
5
|
+
* with a predefined prompt on schedule.
|
|
6
|
+
*/
|
|
7
|
+
class CronScheduler {
|
|
8
|
+
jobs = new Map();
|
|
9
|
+
timers = new Map();
|
|
10
|
+
nextId = 1;
|
|
11
|
+
onExecute;
|
|
12
|
+
setExecutor(fn) {
|
|
13
|
+
this.onExecute = fn;
|
|
14
|
+
}
|
|
15
|
+
create(name, schedule, prompt) {
|
|
16
|
+
const id = String(this.nextId++);
|
|
17
|
+
const intervalMs = parseSchedule(schedule);
|
|
18
|
+
const job = {
|
|
19
|
+
id,
|
|
20
|
+
name,
|
|
21
|
+
schedule,
|
|
22
|
+
prompt,
|
|
23
|
+
enabled: true,
|
|
24
|
+
nextRun: Date.now() + intervalMs,
|
|
25
|
+
runCount: 0,
|
|
26
|
+
createdAt: Date.now(),
|
|
27
|
+
};
|
|
28
|
+
this.jobs.set(id, job);
|
|
29
|
+
this.startTimer(job, intervalMs);
|
|
30
|
+
return job;
|
|
31
|
+
}
|
|
32
|
+
delete(id) {
|
|
33
|
+
const timer = this.timers.get(id);
|
|
34
|
+
if (timer) {
|
|
35
|
+
clearInterval(timer);
|
|
36
|
+
this.timers.delete(id);
|
|
37
|
+
}
|
|
38
|
+
return this.jobs.delete(id);
|
|
39
|
+
}
|
|
40
|
+
list() {
|
|
41
|
+
return [...this.jobs.values()];
|
|
42
|
+
}
|
|
43
|
+
get(id) {
|
|
44
|
+
return this.jobs.get(id);
|
|
45
|
+
}
|
|
46
|
+
pause(id) {
|
|
47
|
+
const job = this.jobs.get(id);
|
|
48
|
+
if (!job)
|
|
49
|
+
return false;
|
|
50
|
+
job.enabled = false;
|
|
51
|
+
const timer = this.timers.get(id);
|
|
52
|
+
if (timer) {
|
|
53
|
+
clearInterval(timer);
|
|
54
|
+
this.timers.delete(id);
|
|
55
|
+
}
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
resume(id) {
|
|
59
|
+
const job = this.jobs.get(id);
|
|
60
|
+
if (!job)
|
|
61
|
+
return false;
|
|
62
|
+
job.enabled = true;
|
|
63
|
+
const intervalMs = parseSchedule(job.schedule);
|
|
64
|
+
this.startTimer(job, intervalMs);
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
stopAll() {
|
|
68
|
+
for (const timer of this.timers.values()) {
|
|
69
|
+
clearInterval(timer);
|
|
70
|
+
}
|
|
71
|
+
this.timers.clear();
|
|
72
|
+
}
|
|
73
|
+
startTimer(job, intervalMs) {
|
|
74
|
+
if (this.timers.has(job.id)) {
|
|
75
|
+
clearInterval(this.timers.get(job.id));
|
|
76
|
+
}
|
|
77
|
+
const timer = setInterval(async () => {
|
|
78
|
+
if (!job.enabled)
|
|
79
|
+
return;
|
|
80
|
+
job.lastRun = Date.now();
|
|
81
|
+
job.runCount++;
|
|
82
|
+
job.nextRun = Date.now() + intervalMs;
|
|
83
|
+
try {
|
|
84
|
+
await this.onExecute?.(job);
|
|
85
|
+
}
|
|
86
|
+
catch {
|
|
87
|
+
// Job execution failed — continue scheduling
|
|
88
|
+
}
|
|
89
|
+
}, intervalMs);
|
|
90
|
+
this.timers.set(job.id, timer);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Parse a schedule string into milliseconds.
|
|
95
|
+
* Supports: "30s", "5m", "1h", "1d", or raw milliseconds.
|
|
96
|
+
*/
|
|
97
|
+
function parseSchedule(schedule) {
|
|
98
|
+
const match = schedule.match(/^(\d+)(s|m|h|d)$/);
|
|
99
|
+
if (match) {
|
|
100
|
+
const value = parseInt(match[1], 10);
|
|
101
|
+
switch (match[2]) {
|
|
102
|
+
case "s": return value * 1000;
|
|
103
|
+
case "m": return value * 60 * 1000;
|
|
104
|
+
case "h": return value * 60 * 60 * 1000;
|
|
105
|
+
case "d": return value * 24 * 60 * 60 * 1000;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
// Try raw number (milliseconds)
|
|
109
|
+
const ms = parseInt(schedule, 10);
|
|
110
|
+
if (!isNaN(ms) && ms > 0)
|
|
111
|
+
return ms;
|
|
112
|
+
// Default: 10 minutes
|
|
113
|
+
return 10 * 60 * 1000;
|
|
114
|
+
}
|
|
115
|
+
export const cronScheduler = new CronScheduler();
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"fetchedAt": "2026-05-14",
|
|
3
|
+
"source": "https://api-docs.deepseek.com/quick_start/pricing",
|
|
4
|
+
"count": 4,
|
|
5
|
+
"models": [
|
|
6
|
+
{
|
|
7
|
+
"id": "deepseek-v4-pro",
|
|
8
|
+
"name": "DeepSeek V4 Pro",
|
|
9
|
+
"contextLength": 1000000,
|
|
10
|
+
"maxOutputTokens": 384000,
|
|
11
|
+
"inputPricePerMillion": 1.74,
|
|
12
|
+
"outputPricePerMillion": 3.48,
|
|
13
|
+
"modalities": ["text"],
|
|
14
|
+
"thinking": true
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"id": "deepseek-v4-flash",
|
|
18
|
+
"name": "DeepSeek V4 Flash",
|
|
19
|
+
"contextLength": 1000000,
|
|
20
|
+
"maxOutputTokens": 384000,
|
|
21
|
+
"inputPricePerMillion": 0.14,
|
|
22
|
+
"outputPricePerMillion": 0.28,
|
|
23
|
+
"modalities": ["text"],
|
|
24
|
+
"thinking": true
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"id": "deepseek-chat",
|
|
28
|
+
"name": "DeepSeek Chat (legacy, deprecating)",
|
|
29
|
+
"contextLength": 128000,
|
|
30
|
+
"maxOutputTokens": 8192,
|
|
31
|
+
"inputPricePerMillion": 0.14,
|
|
32
|
+
"outputPricePerMillion": 0.28,
|
|
33
|
+
"modalities": ["text"]
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"id": "deepseek-reasoner",
|
|
37
|
+
"name": "DeepSeek Reasoner (legacy, deprecating)",
|
|
38
|
+
"contextLength": 128000,
|
|
39
|
+
"maxOutputTokens": 8192,
|
|
40
|
+
"inputPricePerMillion": 0.14,
|
|
41
|
+
"outputPricePerMillion": 0.28,
|
|
42
|
+
"modalities": ["text"],
|
|
43
|
+
"thinking": true
|
|
44
|
+
}
|
|
45
|
+
]
|
|
46
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
{
|
|
2
|
+
"fetchedAt": "2026-05-15",
|
|
3
|
+
"source": "https://ai.google.dev/gemini-api/docs/models + https://ai.google.dev/gemini-api/docs/gemini-3",
|
|
4
|
+
"count": 6,
|
|
5
|
+
"models": [
|
|
6
|
+
{
|
|
7
|
+
"id": "gemini-3.1-pro-preview",
|
|
8
|
+
"name": "Gemini 3.1 Pro (preview)",
|
|
9
|
+
"contextLength": 1048576,
|
|
10
|
+
"maxOutputTokens": 65536,
|
|
11
|
+
"modalities": ["text", "image", "audio", "video"],
|
|
12
|
+
"thinking": true
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"id": "gemini-3-pro-preview",
|
|
16
|
+
"name": "Gemini 3 Pro (preview)",
|
|
17
|
+
"contextLength": 1048576,
|
|
18
|
+
"maxOutputTokens": 65536,
|
|
19
|
+
"modalities": ["text", "image", "audio", "video"],
|
|
20
|
+
"thinking": true
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"id": "gemini-3.1-flash-lite",
|
|
24
|
+
"name": "Gemini 3.1 Flash-Lite",
|
|
25
|
+
"contextLength": 1048576,
|
|
26
|
+
"maxOutputTokens": 65536,
|
|
27
|
+
"modalities": ["text", "image", "audio", "video"],
|
|
28
|
+
"thinking": true
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"id": "gemini-3-flash-preview",
|
|
32
|
+
"name": "Gemini 3 Flash (preview)",
|
|
33
|
+
"contextLength": 1048576,
|
|
34
|
+
"maxOutputTokens": 65536,
|
|
35
|
+
"modalities": ["text", "image", "audio", "video"],
|
|
36
|
+
"thinking": true
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"id": "gemini-2.5-pro",
|
|
40
|
+
"name": "Gemini 2.5 Pro",
|
|
41
|
+
"contextLength": 1048576,
|
|
42
|
+
"maxOutputTokens": 65536,
|
|
43
|
+
"inputPricePerMillion": 1.25,
|
|
44
|
+
"outputPricePerMillion": 10.0,
|
|
45
|
+
"modalities": ["text", "image", "audio", "video"],
|
|
46
|
+
"thinking": true
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"id": "gemini-2.5-flash",
|
|
50
|
+
"name": "Gemini 2.5 Flash",
|
|
51
|
+
"contextLength": 1000000,
|
|
52
|
+
"maxOutputTokens": 65536,
|
|
53
|
+
"inputPricePerMillion": 0.3,
|
|
54
|
+
"outputPricePerMillion": 2.5,
|
|
55
|
+
"modalities": ["text", "image", "audio", "video"],
|
|
56
|
+
"thinking": true
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"id": "gemini-2.5-flash-lite",
|
|
60
|
+
"name": "Gemini 2.5 Flash-Lite",
|
|
61
|
+
"contextLength": 1000000,
|
|
62
|
+
"maxOutputTokens": 65536,
|
|
63
|
+
"modalities": ["text", "image", "audio", "video"],
|
|
64
|
+
"thinking": true
|
|
65
|
+
}
|
|
66
|
+
]
|
|
67
|
+
}
|