@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,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed factories — the recommended public entry points for business
|
|
3
|
+
* consumers of `@cjhyy/code-shell-core`.
|
|
4
|
+
*
|
|
5
|
+
* Standard §7 declares a stable API shape:
|
|
6
|
+
*
|
|
7
|
+
* const [serverT, clientT] = createInProcessTransport();
|
|
8
|
+
* const server = await createServer({ transport: serverT, cwd, llm });
|
|
9
|
+
* const client = createClient({ transport: clientT });
|
|
10
|
+
* client.onStreamEvent(({ sessionId, event }) => {});
|
|
11
|
+
* await client.run({ sessionId: "main", task: "..." });
|
|
12
|
+
*
|
|
13
|
+
* Direct `new Engine(...)` / `new AgentServer(...)` / `new AgentClient(...)`
|
|
14
|
+
* remain supported for advanced cases, but most embedders should use these
|
|
15
|
+
* helpers. They:
|
|
16
|
+
*
|
|
17
|
+
* - Construct the Engine for you from a flat config.
|
|
18
|
+
* - Wire the AgentServer to the supplied transport.
|
|
19
|
+
* - Return a `close()` lifecycle hook that cleans up in the right order.
|
|
20
|
+
*
|
|
21
|
+
* These factories deliberately accept a `Transport` rather than building
|
|
22
|
+
* one internally — they need to compose with `createInProcessTransport`
|
|
23
|
+
* (for in-process embedders), `StdioTransport` (for the worker), or a
|
|
24
|
+
* future `IpcAdapter`. A factory that hides the transport choice would
|
|
25
|
+
* preclude the multi-host story standard §S8 describes.
|
|
26
|
+
*/
|
|
27
|
+
import { Engine } from "../engine/engine.js";
|
|
28
|
+
import { AgentServer } from "./server.js";
|
|
29
|
+
import { AgentClient } from "./client.js";
|
|
30
|
+
/**
|
|
31
|
+
* Build an `Engine` + `AgentServer` from a flat config and wire them to
|
|
32
|
+
* the caller's `Transport`. Most embedders should call this rather than
|
|
33
|
+
* instantiating the engine/server pair manually.
|
|
34
|
+
*/
|
|
35
|
+
export function createServer(options) {
|
|
36
|
+
const config = {
|
|
37
|
+
llm: options.llm,
|
|
38
|
+
cwd: options.cwd,
|
|
39
|
+
permissionMode: options.permissionMode,
|
|
40
|
+
...options.engineOverrides,
|
|
41
|
+
};
|
|
42
|
+
const engine = new Engine(config);
|
|
43
|
+
const server = new AgentServer({ engine, transport: options.transport });
|
|
44
|
+
let closed = false;
|
|
45
|
+
return {
|
|
46
|
+
server,
|
|
47
|
+
engine,
|
|
48
|
+
close() {
|
|
49
|
+
if (closed)
|
|
50
|
+
return;
|
|
51
|
+
closed = true;
|
|
52
|
+
server.close();
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Thin convenience wrapper around `new AgentClient`. Exists so the
|
|
58
|
+
* recommended public surface is fully createX-style, mirroring
|
|
59
|
+
* `createServer`. Future versions may add typed event subscriptions or
|
|
60
|
+
* stream-event filters here without breaking embedders.
|
|
61
|
+
*/
|
|
62
|
+
export function createClient(options) {
|
|
63
|
+
return new AgentClient({ transport: options.transport });
|
|
64
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helpers for spinning up an in-process AgentServer + AgentClient pair.
|
|
3
|
+
*
|
|
4
|
+
* All internal codeshell paths that want to run an engine should go through
|
|
5
|
+
* the protocol layer (AgentServer wraps the engine, AgentClient is the
|
|
6
|
+
* consumer-facing handle). This helper exists so callers don't repeat the
|
|
7
|
+
* 6-line "create transport / new server / new client / wire onStream /
|
|
8
|
+
* try-finally close" boilerplate at every call site.
|
|
9
|
+
*
|
|
10
|
+
* Existing call sites that should use this:
|
|
11
|
+
* - src/cli/commands/run.ts (headless CLI)
|
|
12
|
+
* - src/run/EngineRunner.ts (RunManager)
|
|
13
|
+
*
|
|
14
|
+
* The REPL builds its own server+client because it needs the long-lived
|
|
15
|
+
* AgentClient instance to drive the React UI's lifecycle (subscribing to
|
|
16
|
+
* stream events, approval requests, status changes). One-shot callers want
|
|
17
|
+
* the simpler "give me a client, hand back close()" shape this helper
|
|
18
|
+
* provides.
|
|
19
|
+
*/
|
|
20
|
+
import type { Engine } from "../engine/engine.js";
|
|
21
|
+
import type { StreamCallback } from "../types.js";
|
|
22
|
+
import { AgentClient } from "./client.js";
|
|
23
|
+
export interface InProcessClientHandle {
|
|
24
|
+
/** The client; pass to `client.run(task, { cwd, sessionId })` to execute. */
|
|
25
|
+
readonly client: AgentClient;
|
|
26
|
+
/**
|
|
27
|
+
* Tear down server + client + transports. Call from a `finally` block.
|
|
28
|
+
* Safe to call multiple times; subsequent calls are no-ops.
|
|
29
|
+
*/
|
|
30
|
+
close(): void;
|
|
31
|
+
}
|
|
32
|
+
export interface CreateInProcessClientOptions {
|
|
33
|
+
/** Stream callback to receive every event the server emits. */
|
|
34
|
+
onStream?: StreamCallback;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Wrap an Engine in an in-process AgentServer and return a client handle.
|
|
38
|
+
* The handle's `close()` tears the whole pair down in the correct order:
|
|
39
|
+
* client first (so its pending requests reject cleanly), then server (which
|
|
40
|
+
* aborts any active run and clears approval timers).
|
|
41
|
+
*/
|
|
42
|
+
export declare function createInProcessClient(engine: Engine, options?: CreateInProcessClientOptions): InProcessClientHandle;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helpers for spinning up an in-process AgentServer + AgentClient pair.
|
|
3
|
+
*
|
|
4
|
+
* All internal codeshell paths that want to run an engine should go through
|
|
5
|
+
* the protocol layer (AgentServer wraps the engine, AgentClient is the
|
|
6
|
+
* consumer-facing handle). This helper exists so callers don't repeat the
|
|
7
|
+
* 6-line "create transport / new server / new client / wire onStream /
|
|
8
|
+
* try-finally close" boilerplate at every call site.
|
|
9
|
+
*
|
|
10
|
+
* Existing call sites that should use this:
|
|
11
|
+
* - src/cli/commands/run.ts (headless CLI)
|
|
12
|
+
* - src/run/EngineRunner.ts (RunManager)
|
|
13
|
+
*
|
|
14
|
+
* The REPL builds its own server+client because it needs the long-lived
|
|
15
|
+
* AgentClient instance to drive the React UI's lifecycle (subscribing to
|
|
16
|
+
* stream events, approval requests, status changes). One-shot callers want
|
|
17
|
+
* the simpler "give me a client, hand back close()" shape this helper
|
|
18
|
+
* provides.
|
|
19
|
+
*/
|
|
20
|
+
import { AgentServer } from "./server.js";
|
|
21
|
+
import { AgentClient } from "./client.js";
|
|
22
|
+
import { createInProcessTransport } from "./transport.js";
|
|
23
|
+
/**
|
|
24
|
+
* Wrap an Engine in an in-process AgentServer and return a client handle.
|
|
25
|
+
* The handle's `close()` tears the whole pair down in the correct order:
|
|
26
|
+
* client first (so its pending requests reject cleanly), then server (which
|
|
27
|
+
* aborts any active run and clears approval timers).
|
|
28
|
+
*/
|
|
29
|
+
export function createInProcessClient(engine, options = {}) {
|
|
30
|
+
const [serverTransport, clientTransport] = createInProcessTransport();
|
|
31
|
+
const server = new AgentServer({ engine, transport: serverTransport });
|
|
32
|
+
const client = new AgentClient({ transport: clientTransport });
|
|
33
|
+
if (options.onStream) {
|
|
34
|
+
const cb = options.onStream;
|
|
35
|
+
client.onStreamEvent((envelope) => cb(envelope.event));
|
|
36
|
+
}
|
|
37
|
+
let closed = false;
|
|
38
|
+
return {
|
|
39
|
+
client,
|
|
40
|
+
close() {
|
|
41
|
+
if (closed)
|
|
42
|
+
return;
|
|
43
|
+
closed = true;
|
|
44
|
+
// Order matters: server.close() aborts the in-flight run AND emits
|
|
45
|
+
// a final "shutdown" status notification through the still-open
|
|
46
|
+
// transport pair. Then client.close() drains/rejects any pending
|
|
47
|
+
// requests and tears down its transport end. Reversing this order
|
|
48
|
+
// would silently drop the "shutdown" notification because the
|
|
49
|
+
// client's transport would already be closed when server.notify
|
|
50
|
+
// tries to send.
|
|
51
|
+
server.close();
|
|
52
|
+
client.close();
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { AgentServer, type AgentServerOptions } from "./server.js";
|
|
2
|
+
export { AgentClient } from "./client.js";
|
|
3
|
+
export { createInProcessTransport, StdioTransport, type Transport, } from "./transport.js";
|
|
4
|
+
export { Methods, ErrorCodes, type RpcMessage, type RunResult } from "./types.js";
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AgentServer — wraps ChatSessionManager and exposes it over the protocol.
|
|
3
|
+
*
|
|
4
|
+
* Responsibilities:
|
|
5
|
+
* - Handles RPC requests from the client (run, approve, cancel, configure, query)
|
|
6
|
+
* - Forwards StreamEvents to the client as notifications with sessionId envelope
|
|
7
|
+
* - Manages per-session approval flow
|
|
8
|
+
* - Dispatches agent/run through ChatSessionManager so multiple sessions
|
|
9
|
+
* run concurrently without cross-talk
|
|
10
|
+
*
|
|
11
|
+
* Backward compat: an optional `engine` can be supplied for global operations
|
|
12
|
+
* (model list, config reads/writes, tool registry queries, etc.) that don't
|
|
13
|
+
* yet have a natural "which session" answer. When not supplied the server
|
|
14
|
+
* falls back to borrowing any live session's engine for those reads.
|
|
15
|
+
*/
|
|
16
|
+
import type { Transport } from "./transport.js";
|
|
17
|
+
import type { Engine } from "../engine/engine.js";
|
|
18
|
+
import type { ChatSessionManager } from "./chat-session-manager.js";
|
|
19
|
+
export interface AgentServerOptions {
|
|
20
|
+
/**
|
|
21
|
+
* Multi-session manager. Required for the new multi-session protocol.
|
|
22
|
+
* When present, agent/run dispatches through the manager.
|
|
23
|
+
*/
|
|
24
|
+
chatManager?: ChatSessionManager;
|
|
25
|
+
/**
|
|
26
|
+
* Legacy single-engine mode. When chatManager is not supplied the server
|
|
27
|
+
* falls back to the old single-engine behaviour (backwards compat for
|
|
28
|
+
* createInProcessClient and agent-server-stdio until T11).
|
|
29
|
+
*/
|
|
30
|
+
engine?: Engine;
|
|
31
|
+
transport: Transport;
|
|
32
|
+
}
|
|
33
|
+
export declare class AgentServer {
|
|
34
|
+
private readonly chatManager;
|
|
35
|
+
private readonly legacyEngine;
|
|
36
|
+
private transport;
|
|
37
|
+
private running;
|
|
38
|
+
private abortController;
|
|
39
|
+
/** Pending approval requests: requestId → resolve function (legacy path) */
|
|
40
|
+
private pendingApprovals;
|
|
41
|
+
/** Timers for approval timeouts */
|
|
42
|
+
private approvalTimers;
|
|
43
|
+
/** Default approval timeout: 5 minutes */
|
|
44
|
+
private static readonly APPROVAL_TIMEOUT_MS;
|
|
45
|
+
/**
|
|
46
|
+
* Unsubscribe handle for the process-local `agentNotificationBus`
|
|
47
|
+
* subscription set up in the constructor. Called from `close()` so a
|
|
48
|
+
* shut-down server stops forwarding completion events even if the bus
|
|
49
|
+
* itself outlives the server (it's a process-local singleton).
|
|
50
|
+
*/
|
|
51
|
+
private bgAgentBusUnsubscribe;
|
|
52
|
+
constructor(options: AgentServerOptions);
|
|
53
|
+
private handleRequest;
|
|
54
|
+
private handleRun;
|
|
55
|
+
private handleRunMulti;
|
|
56
|
+
private handleRunLegacy;
|
|
57
|
+
private handleApprove;
|
|
58
|
+
private handleCancel;
|
|
59
|
+
private handleCloseSession;
|
|
60
|
+
private handleConfigure;
|
|
61
|
+
private handleQuery;
|
|
62
|
+
private handleInject;
|
|
63
|
+
/**
|
|
64
|
+
* Ask the client to approve a tool operation (legacy single-engine path).
|
|
65
|
+
*/
|
|
66
|
+
private requestApprovalFromClient;
|
|
67
|
+
/**
|
|
68
|
+
* Ask the client to answer a question from the agent (legacy single-engine path).
|
|
69
|
+
*/
|
|
70
|
+
private requestAskUserFromClient;
|
|
71
|
+
private notify;
|
|
72
|
+
/**
|
|
73
|
+
* Get any available engine — used for global query ops when chatManager is
|
|
74
|
+
* present but no legacyEngine was supplied. Borrows the first live session.
|
|
75
|
+
*/
|
|
76
|
+
private anyEngine;
|
|
77
|
+
close(): void;
|
|
78
|
+
private clearApprovalTimer;
|
|
79
|
+
private clearAllApprovalTimers;
|
|
80
|
+
}
|