@levelcode/sdk 0.2.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agents/constants.d.ts +1 -0
- package/dist/agents/team/apprentice.d.ts +3 -0
- package/dist/agents/team/coordinator.d.ts +3 -0
- package/dist/agents/team/cto.d.ts +3 -0
- package/dist/agents/team/designer.d.ts +3 -0
- package/dist/agents/team/director.d.ts +3 -0
- package/dist/agents/team/distinguished-engineer.d.ts +3 -0
- package/dist/agents/team/fellow.d.ts +3 -0
- package/dist/agents/team/index.d.ts +27 -0
- package/dist/agents/team/intern.d.ts +3 -0
- package/dist/agents/team/junior-engineer.d.ts +3 -0
- package/dist/agents/team/manager.d.ts +3 -0
- package/dist/agents/team/mid-level-engineer.d.ts +3 -0
- package/dist/agents/team/principal-engineer.d.ts +3 -0
- package/dist/agents/team/product-lead.d.ts +3 -0
- package/dist/agents/team/researcher.d.ts +3 -0
- package/dist/agents/team/role-hierarchy.d.ts +24 -0
- package/dist/agents/team/scientist.d.ts +3 -0
- package/dist/agents/team/senior-engineer.d.ts +3 -0
- package/dist/agents/team/senior-staff-engineer.d.ts +3 -0
- package/dist/agents/team/staff-engineer.d.ts +3 -0
- package/dist/agents/team/sub-manager.d.ts +3 -0
- package/dist/agents/team/tester.d.ts +3 -0
- package/dist/agents/team/vp-engineering.d.ts +3 -0
- package/dist/agents/types/agent-definition.d.ts +296 -0
- package/dist/agents/types/secret-agent-definition.d.ts +19 -0
- package/dist/agents/types/tools.d.ts +308 -0
- package/dist/agents/types/util-types.d.ts +134 -0
- package/dist/common/src/actions.d.ts +176 -0
- package/dist/common/src/analytics-core.d.ts +52 -0
- package/dist/common/src/analytics.d.ts +9 -0
- package/dist/common/src/browser-actions.d.ts +1200 -0
- package/dist/common/src/constants/agents.d.ts +47 -0
- package/dist/common/src/constants/analytics-events.d.ts +111 -0
- package/dist/common/src/constants/byok.d.ts +2 -0
- package/dist/common/src/constants/claude-oauth.d.ts +36 -0
- package/dist/common/src/constants/index.d.ts +4 -0
- package/dist/common/src/constants/knowledge.d.ts +21 -0
- package/dist/common/src/constants/limits.d.ts +14 -0
- package/dist/common/src/constants/model-config.d.ts +117 -0
- package/dist/common/src/constants/paths.d.ts +23 -0
- package/dist/common/src/constants/skills.d.ts +42 -0
- package/dist/common/src/constants/ui.d.ts +14 -0
- package/dist/common/src/env-ci.d.ts +22 -0
- package/dist/common/src/env-process.d.ts +28 -0
- package/dist/common/src/env-schema.d.ts +24 -0
- package/dist/common/src/env.d.ts +16 -0
- package/dist/common/src/mcp/client.d.ts +6 -0
- package/dist/common/src/old-constants.d.ts +10 -0
- package/dist/common/src/project-file-tree.d.ts +27 -0
- package/dist/common/src/templates/agent-validation.d.ts +48 -0
- package/dist/common/src/templates/initial-agents-dir/types/agent-definition.d.ts +296 -0
- package/dist/common/src/templates/initial-agents-dir/types/tools.d.ts +308 -0
- package/dist/common/src/templates/initial-agents-dir/types/util-types.d.ts +128 -0
- package/dist/common/src/testing/errors.d.ts +14 -0
- package/dist/common/src/testing/mock-modules.d.ts +11 -0
- package/dist/common/src/testing/mock-types.d.ts +97 -0
- package/dist/common/src/testing/mocks/analytics.d.ts +182 -0
- package/dist/common/src/testing/mocks/child-process.d.ts +29 -0
- package/dist/common/src/testing/mocks/crypto.d.ts +159 -0
- package/dist/common/src/testing/mocks/database.d.ts +197 -0
- package/dist/common/src/testing/mocks/fetch.d.ts +35 -0
- package/dist/common/src/testing/mocks/filesystem.d.ts +31 -0
- package/dist/common/src/testing/mocks/index.d.ts +25 -0
- package/dist/common/src/testing/mocks/logger.d.ts +35 -0
- package/dist/common/src/testing/mocks/stream.d.ts +203 -0
- package/dist/common/src/testing/mocks/timers.d.ts +27 -0
- package/dist/common/src/testing/mocks/tree-sitter.d.ts +58 -0
- package/dist/common/src/testing-env-process.d.ts +7 -0
- package/dist/common/src/tools/constants.d.ts +17 -0
- package/dist/common/src/tools/list.d.ts +1152 -0
- package/dist/common/src/tools/params/tool/add-message.d.ts +19 -0
- package/dist/common/src/tools/params/tool/add-subgoal.d.ts +26 -0
- package/dist/common/src/tools/params/tool/ask-user.d.ts +59 -0
- package/dist/common/src/tools/params/tool/browser-logs.d.ts +127 -0
- package/dist/common/src/tools/params/tool/code-search.d.ts +30 -0
- package/dist/common/src/tools/params/tool/create-plan.d.ts +30 -0
- package/dist/common/src/tools/params/tool/end-turn.d.ts +13 -0
- package/dist/common/src/tools/params/tool/find-files.d.ts +31 -0
- package/dist/common/src/tools/params/tool/glob.d.ts +26 -0
- package/dist/common/src/tools/params/tool/list-directory.d.ts +25 -0
- package/dist/common/src/tools/params/tool/lookup-agent-info.d.ts +13 -0
- package/dist/common/src/tools/params/tool/propose-str-replace.d.ts +40 -0
- package/dist/common/src/tools/params/tool/propose-write-file.d.ts +29 -0
- package/dist/common/src/tools/params/tool/read-docs.d.ts +19 -0
- package/dist/common/src/tools/params/tool/read-files.d.ts +35 -0
- package/dist/common/src/tools/params/tool/read-subtree.d.ts +40 -0
- package/dist/common/src/tools/params/tool/run-file-change-hooks.d.ts +63 -0
- package/dist/common/src/tools/params/tool/run-terminal-command.d.ts +88 -0
- package/dist/common/src/tools/params/tool/send-message.d.ts +26 -0
- package/dist/common/src/tools/params/tool/set-messages.d.ts +15 -0
- package/dist/common/src/tools/params/tool/set-output.d.ts +15 -0
- package/dist/common/src/tools/params/tool/skill.d.ts +28 -0
- package/dist/common/src/tools/params/tool/spawn-agent-inline.d.ts +17 -0
- package/dist/common/src/tools/params/tool/spawn-agents.d.ts +26 -0
- package/dist/common/src/tools/params/tool/str-replace.d.ts +43 -0
- package/dist/common/src/tools/params/tool/suggest-followups.d.ts +26 -0
- package/dist/common/src/tools/params/tool/task-completed.d.ts +13 -0
- package/dist/common/src/tools/params/tool/task-create.d.ts +24 -0
- package/dist/common/src/tools/params/tool/task-get.d.ts +15 -0
- package/dist/common/src/tools/params/tool/task-list.d.ts +13 -0
- package/dist/common/src/tools/params/tool/task-update.d.ts +29 -0
- package/dist/common/src/tools/params/tool/team-create.d.ts +17 -0
- package/dist/common/src/tools/params/tool/team-delete.d.ts +13 -0
- package/dist/common/src/tools/params/tool/think-deeply.d.ts +15 -0
- package/dist/common/src/tools/params/tool/update-subgoal.d.ts +25 -0
- package/dist/common/src/tools/params/tool/web-search.d.ts +25 -0
- package/dist/common/src/tools/params/tool/write-file.d.ts +31 -0
- package/dist/common/src/tools/params/tool/write-todos.d.ts +18 -0
- package/dist/common/src/tools/params/utils.d.ts +35 -0
- package/dist/common/src/tools/utils.d.ts +4 -0
- package/dist/common/src/types/agent-template.d.ts +156 -0
- package/dist/common/src/types/contracts/agent-runtime.d.ts +36 -0
- package/dist/common/src/types/contracts/analytics.d.ts +8 -0
- package/dist/common/src/types/contracts/billing.d.ts +40 -0
- package/dist/common/src/types/contracts/client.d.ts +45 -0
- package/dist/common/src/types/contracts/database.d.ts +80 -0
- package/dist/common/src/types/contracts/env.d.ts +150 -0
- package/dist/common/src/types/contracts/llm.d.ts +102 -0
- package/dist/common/src/types/contracts/logger.d.ts +8 -0
- package/dist/common/src/types/dynamic-agent-template.d.ts +227 -0
- package/dist/common/src/types/filesystem.d.ts +6 -0
- package/dist/common/src/types/function-params.d.ts +15 -0
- package/dist/common/src/types/grant.d.ts +2 -0
- package/dist/common/src/types/json.d.ts +9 -0
- package/dist/common/src/types/mcp.d.ts +31 -0
- package/dist/common/src/types/messages/content-part.d.ts +46 -0
- package/dist/common/src/types/messages/data-content.d.ts +3 -0
- package/dist/common/src/types/messages/levelcode-message.d.ts +37 -0
- package/dist/common/src/types/messages/provider-metadata.d.ts +3 -0
- package/dist/common/src/types/print-mode.d.ts +155 -0
- package/dist/common/src/types/session-state.d.ts +94 -0
- package/dist/common/src/types/skill.d.ts +31 -0
- package/dist/common/src/types/source.d.ts +8 -0
- package/dist/common/src/types/spawn.d.ts +8 -0
- package/dist/common/src/types/team-config-schemas.d.ts +217 -0
- package/dist/common/src/types/team-config.d.ts +42 -0
- package/dist/common/src/types/team-hook-events.d.ts +36 -0
- package/dist/common/src/types/team-protocol.d.ts +64 -0
- package/dist/common/src/util/agent-id-parsing.d.ts +22 -0
- package/dist/common/src/util/agent-name-normalization.d.ts +12 -0
- package/dist/common/src/util/array.d.ts +6 -0
- package/dist/common/src/util/credentials.d.ts +11 -0
- package/dist/common/src/util/error.d.ts +128 -0
- package/dist/common/src/util/file.d.ts +133 -0
- package/dist/common/src/util/format-code-search.d.ts +16 -0
- package/dist/common/src/util/lru-cache.d.ts +30 -0
- package/dist/common/src/util/messages.d.ts +46 -0
- package/dist/common/src/util/model-utils.d.ts +8 -0
- package/dist/common/src/util/object.d.ts +22 -0
- package/dist/common/src/util/promise.d.ts +16 -0
- package/dist/common/src/util/random.d.ts +1 -0
- package/dist/common/src/util/skills.d.ts +5 -0
- package/dist/common/src/util/stop-sequence.d.ts +14 -0
- package/dist/common/src/util/string.d.ts +82 -0
- package/dist/common/src/util/xml.d.ts +12 -0
- package/dist/common/src/util/zod-schema.d.ts +5 -0
- package/dist/common/src/utils/dev-phases.d.ts +23 -0
- package/dist/common/src/utils/file-lock.d.ts +13 -0
- package/dist/common/src/utils/team-analytics.d.ts +16 -0
- package/dist/common/src/utils/team-discovery.d.ts +47 -0
- package/dist/common/src/utils/team-fs.d.ts +20 -0
- package/dist/common/src/utils/team-hook-emitter.d.ts +40 -0
- package/dist/common/src/utils/team-presets.d.ts +35 -0
- package/dist/index.cjs +2 -1
- package/dist/index.cjs.map +3 -3
- package/dist/index.mjs +2 -1
- package/dist/index.mjs.map +3 -3
- package/dist/packages/agent-runtime/src/constants.d.ts +1 -0
- package/dist/packages/agent-runtime/src/fast-rewrite.d.ts +45 -0
- package/dist/packages/agent-runtime/src/find-files/request-files-prompt.d.ts +71 -0
- package/dist/packages/agent-runtime/src/generate-diffs-prompt.d.ts +53 -0
- package/dist/packages/agent-runtime/src/get-file-reading-updates.d.ts +8 -0
- package/dist/packages/agent-runtime/src/inbox-poller.d.ts +81 -0
- package/dist/packages/agent-runtime/src/llm-api/claude.d.ts +5 -0
- package/dist/packages/agent-runtime/src/llm-api/context7-api.d.ts +55 -0
- package/dist/packages/agent-runtime/src/llm-api/gemini-with-fallbacks.d.ts +40 -0
- package/dist/packages/agent-runtime/src/llm-api/levelcode-web-api.d.ts +49 -0
- package/dist/packages/agent-runtime/src/llm-api/relace-api.d.ts +16 -0
- package/dist/packages/agent-runtime/src/main-prompt.d.ts +29 -0
- package/dist/packages/agent-runtime/src/mcp-constants.d.ts +12 -0
- package/dist/packages/agent-runtime/src/mcp.d.ts +10 -0
- package/dist/packages/agent-runtime/src/message-formatter.d.ts +12 -0
- package/dist/packages/agent-runtime/src/process-file-block.d.ts +56 -0
- package/dist/packages/agent-runtime/src/process-str-replace.d.ts +21 -0
- package/dist/packages/agent-runtime/src/prompt-agent-stream.d.ts +28 -0
- package/dist/packages/agent-runtime/src/run-agent-step.d.ts +73 -0
- package/dist/packages/agent-runtime/src/run-programmatic-step.d.ts +40 -0
- package/dist/packages/agent-runtime/src/system-prompt/prompts.d.ts +19 -0
- package/dist/packages/agent-runtime/src/system-prompt/search-system-prompt.d.ts +14 -0
- package/dist/packages/agent-runtime/src/system-prompt/team-context-prompt.d.ts +9 -0
- package/dist/packages/agent-runtime/src/system-prompt/team-prompt.d.ts +9 -0
- package/dist/packages/agent-runtime/src/system-prompt/truncate-file-tree.d.ts +13 -0
- package/dist/packages/agent-runtime/src/team-context.d.ts +14 -0
- package/dist/packages/agent-runtime/src/templates/agent-registry.d.ts +35 -0
- package/dist/packages/agent-runtime/src/templates/prompts.d.ts +35 -0
- package/dist/packages/agent-runtime/src/templates/strings.d.ts +32 -0
- package/dist/packages/agent-runtime/src/templates/types.d.ts +13 -0
- package/dist/packages/agent-runtime/src/tool-stream-parser.d.ts +31 -0
- package/dist/packages/agent-runtime/src/tools/handlers/handler-function-type.d.ts +51 -0
- package/dist/packages/agent-runtime/src/tools/handlers/list.d.ts +370 -0
- package/dist/packages/agent-runtime/src/tools/handlers/tool/add-message.d.ts +9 -0
- package/dist/packages/agent-runtime/src/tools/handlers/tool/add-subgoal.d.ts +9 -0
- package/dist/packages/agent-runtime/src/tools/handlers/tool/ask-user.d.ts +10 -0
- package/dist/packages/agent-runtime/src/tools/handlers/tool/browser-logs.d.ts +8 -0
- package/dist/packages/agent-runtime/src/tools/handlers/tool/code-search.d.ts +8 -0
- package/dist/packages/agent-runtime/src/tools/handlers/tool/create-plan.d.ts +13 -0
- package/dist/packages/agent-runtime/src/tools/handlers/tool/end-turn.d.ts +7 -0
- package/dist/packages/agent-runtime/src/tools/handlers/tool/find-files.d.ts +27 -0
- package/dist/packages/agent-runtime/src/tools/handlers/tool/glob.d.ts +10 -0
- package/dist/packages/agent-runtime/src/tools/handlers/tool/list-directory.d.ts +10 -0
- package/dist/packages/agent-runtime/src/tools/handlers/tool/lookup-agent-info.d.ts +14 -0
- package/dist/packages/agent-runtime/src/tools/handlers/tool/propose-str-replace.d.ts +15 -0
- package/dist/packages/agent-runtime/src/tools/handlers/tool/propose-write-file.d.ts +7 -0
- package/dist/packages/agent-runtime/src/tools/handlers/tool/proposed-content-store.d.ts +27 -0
- package/dist/packages/agent-runtime/src/tools/handlers/tool/read-docs.d.ts +21 -0
- package/dist/packages/agent-runtime/src/tools/handlers/tool/read-files.d.ts +13 -0
- package/dist/packages/agent-runtime/src/tools/handlers/tool/read-subtree.d.ts +13 -0
- package/dist/packages/agent-runtime/src/tools/handlers/tool/run-file-change-hooks.d.ts +10 -0
- package/dist/packages/agent-runtime/src/tools/handlers/tool/run-terminal-command.d.ts +10 -0
- package/dist/packages/agent-runtime/src/tools/handlers/tool/send-message.d.ts +15 -0
- package/dist/packages/agent-runtime/src/tools/handlers/tool/set-messages.d.ts +9 -0
- package/dist/packages/agent-runtime/src/tools/handlers/tool/set-output.d.ts +18 -0
- package/dist/packages/agent-runtime/src/tools/handlers/tool/skill.d.ts +11 -0
- package/dist/packages/agent-runtime/src/tools/handlers/tool/spawn-agent-inline.d.ts +29 -0
- package/dist/packages/agent-runtime/src/tools/handlers/tool/spawn-agent-utils.d.ts +130 -0
- package/dist/packages/agent-runtime/src/tools/handlers/tool/spawn-agents.d.ts +37 -0
- package/dist/packages/agent-runtime/src/tools/handlers/tool/str-replace.d.ts +16 -0
- package/dist/packages/agent-runtime/src/tools/handlers/tool/suggest-followups.d.ts +9 -0
- package/dist/packages/agent-runtime/src/tools/handlers/tool/task-completed.d.ts +15 -0
- package/dist/packages/agent-runtime/src/tools/handlers/tool/task-create.d.ts +10 -0
- package/dist/packages/agent-runtime/src/tools/handlers/tool/task-get.d.ts +10 -0
- package/dist/packages/agent-runtime/src/tools/handlers/tool/task-list.d.ts +10 -0
- package/dist/packages/agent-runtime/src/tools/handlers/tool/task-update.d.ts +15 -0
- package/dist/packages/agent-runtime/src/tools/handlers/tool/team-create.d.ts +15 -0
- package/dist/packages/agent-runtime/src/tools/handlers/tool/team-delete.d.ts +15 -0
- package/dist/packages/agent-runtime/src/tools/handlers/tool/think-deeply.d.ts +9 -0
- package/dist/packages/agent-runtime/src/tools/handlers/tool/update-subgoal.d.ts +11 -0
- package/dist/packages/agent-runtime/src/tools/handlers/tool/web-search.d.ts +22 -0
- package/dist/packages/agent-runtime/src/tools/handlers/tool/write-file.d.ts +49 -0
- package/dist/packages/agent-runtime/src/tools/handlers/tool/write-todos.d.ts +9 -0
- package/dist/packages/agent-runtime/src/tools/prompts.d.ts +31 -0
- package/dist/packages/agent-runtime/src/tools/stream-parser.d.ts +33 -0
- package/dist/packages/agent-runtime/src/tools/tool-executor.d.ts +87 -0
- package/dist/packages/agent-runtime/src/util/agent-output.d.ts +3 -0
- package/dist/packages/agent-runtime/src/util/messages.d.ts +68 -0
- package/dist/packages/agent-runtime/src/util/parse-tool-calls-from-text.d.ts +38 -0
- package/dist/packages/agent-runtime/src/util/render-read-files-result.d.ts +15 -0
- package/dist/packages/agent-runtime/src/util/simplify-tool-results.d.ts +7 -0
- package/dist/packages/agent-runtime/src/util/stream-xml-parser.d.ts +34 -0
- package/dist/packages/agent-runtime/src/util/token-counter.d.ts +3 -0
- package/dist/packages/code-map/src/index.d.ts +3 -0
- package/dist/packages/code-map/src/init-node.d.ts +4 -0
- package/dist/packages/code-map/src/languages.d.ts +36 -0
- package/dist/packages/code-map/src/parse.d.ts +21 -0
- package/dist/packages/code-map/src/types.d.ts +8 -0
- package/dist/packages/code-map/src/utils.d.ts +1 -0
- package/dist/sdk/src/__tests__/client.test.d.ts +1 -0
- package/dist/sdk/src/__tests__/code-search.test.d.ts +1 -0
- package/dist/sdk/src/__tests__/credentials.test.d.ts +1 -0
- package/dist/sdk/src/__tests__/database.test.d.ts +1 -0
- package/dist/sdk/src/__tests__/env.test.d.ts +1 -0
- package/dist/sdk/src/__tests__/error-utils.test.d.ts +1 -0
- package/dist/sdk/src/__tests__/initial-session-state.test.d.ts +1 -0
- package/dist/sdk/src/__tests__/knowledge-file-selection.test.d.ts +1 -0
- package/dist/sdk/src/__tests__/load-agents.test.d.ts +1 -0
- package/dist/sdk/src/__tests__/load-mcp-config.test.d.ts +1 -0
- package/dist/sdk/src/__tests__/model-provider.test.d.ts +1 -0
- package/dist/sdk/src/__tests__/read-files.test.d.ts +1 -0
- package/dist/sdk/src/__tests__/run-cancellation.test.d.ts +1 -0
- package/dist/sdk/src/__tests__/run-file-filter.test.d.ts +1 -0
- package/dist/sdk/src/__tests__/run-handle-event.test.d.ts +1 -0
- package/dist/sdk/src/__tests__/run.integration.test.d.ts +1 -0
- package/dist/sdk/src/__tests__/team-api.test.d.ts +1 -0
- package/dist/sdk/src/__tests__/user-knowledge-files.test.d.ts +1 -0
- package/dist/sdk/src/__tests__/validate-agents.test.d.ts +1 -0
- package/dist/sdk/src/agents/load-agents.d.ts +106 -0
- package/dist/sdk/src/agents/load-mcp-config.d.ts +69 -0
- package/dist/sdk/src/client.d.ts +71 -0
- package/dist/sdk/src/constants.d.ts +4 -0
- package/dist/sdk/src/credentials.d.ts +58 -0
- package/dist/sdk/src/custom-tool.d.ts +32 -0
- package/dist/sdk/src/env.d.ts +31 -0
- package/dist/sdk/src/error-utils.d.ts +55 -0
- package/dist/sdk/src/impl/__tests__/prompt-result.test.d.ts +1 -0
- package/dist/sdk/src/impl/agent-runtime.d.ts +8 -0
- package/dist/sdk/src/impl/database.d.ts +7 -0
- package/dist/sdk/src/impl/llm.d.ts +8 -0
- package/dist/sdk/src/impl/model-provider.d.ts +61 -0
- package/dist/sdk/src/index.d.ts +42 -0
- package/dist/sdk/src/native/ripgrep.d.ts +7 -0
- package/dist/sdk/src/retry-config.d.ts +46 -0
- package/dist/sdk/src/run-state.d.ts +81 -0
- package/dist/sdk/src/run.d.ts +79 -0
- package/dist/sdk/src/skills/load-skills.d.ts +42 -0
- package/dist/sdk/src/team.d.ts +49 -0
- package/dist/sdk/src/testing/env.d.ts +5 -0
- package/dist/sdk/src/tools/change-file.d.ts +7 -0
- package/dist/sdk/src/tools/code-search.d.ts +13 -0
- package/dist/sdk/src/tools/glob.d.ts +8 -0
- package/dist/sdk/src/tools/index.d.ts +16 -0
- package/dist/sdk/src/tools/list-directory.d.ts +7 -0
- package/dist/sdk/src/tools/read-files.d.ts +16 -0
- package/dist/sdk/src/tools/run-file-change-hooks.d.ts +4 -0
- package/dist/sdk/src/tools/run-terminal-command.d.ts +8 -0
- package/dist/sdk/src/types/env.d.ts +30 -0
- package/dist/sdk/src/validate-agents.d.ts +45 -0
- package/dist/vendor/ripgrep/arm64-darwin/rg +0 -0
- package/dist/vendor/ripgrep/arm64-linux/rg +0 -0
- package/dist/vendor/ripgrep/x64-darwin/rg +0 -0
- package/dist/vendor/ripgrep/x64-linux/rg +0 -0
- package/dist/vendor/ripgrep/x64-win32/rg.exe +0 -0
- package/dist/wasm/tree-sitter-c-sharp.wasm +0 -0
- package/dist/wasm/tree-sitter-cpp.wasm +0 -0
- package/dist/wasm/tree-sitter-go.wasm +0 -0
- package/dist/wasm/tree-sitter-java.wasm +0 -0
- package/dist/wasm/tree-sitter-javascript.wasm +0 -0
- package/dist/wasm/tree-sitter-python.wasm +0 -0
- package/dist/wasm/tree-sitter-ruby.wasm +0 -0
- package/dist/wasm/tree-sitter-rust.wasm +0 -0
- package/dist/wasm/tree-sitter-tsx.wasm +0 -0
- package/dist/wasm/tree-sitter-typescript.wasm +0 -0
- package/dist/wasm/tree-sitter.wasm +0 -0
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const globalStopSequence: string;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { promptFlashWithFallbacks } from './llm-api/gemini-with-fallbacks';
|
|
2
|
+
import { promptRelaceAI } from './llm-api/relace-api';
|
|
3
|
+
import type { PromptAiSdkFn } from '@levelcode/common/types/contracts/llm';
|
|
4
|
+
import type { Logger } from '@levelcode/common/types/contracts/logger';
|
|
5
|
+
import type { ParamsExcluding } from '@levelcode/common/types/function-params';
|
|
6
|
+
import type { Message } from '@levelcode/common/types/messages/levelcode-message';
|
|
7
|
+
/**
|
|
8
|
+
* Rewrites file content using Relace AI with fallback to OpenAI.
|
|
9
|
+
*
|
|
10
|
+
* @throws {Error} When the request is aborted by user. Check with `isAbortError()`.
|
|
11
|
+
*/
|
|
12
|
+
export declare function fastRewrite(params: {
|
|
13
|
+
initialContent: string;
|
|
14
|
+
editSnippet: string;
|
|
15
|
+
filePath: string;
|
|
16
|
+
userMessage: string | undefined;
|
|
17
|
+
logger: Logger;
|
|
18
|
+
} & ParamsExcluding<typeof promptRelaceAI, 'initialCode'> & ParamsExcluding<typeof rewriteWithOpenAI, 'oldContent'>): Promise<string>;
|
|
19
|
+
/**
|
|
20
|
+
* Rewrites file content using OpenAI's o3-mini model when Gemini Flash output limit is exceeded.
|
|
21
|
+
* Gemini flash can only output 8k tokens, openai models can do at least 16k tokens.
|
|
22
|
+
*
|
|
23
|
+
* @throws {Error} When the request is aborted by user. Check with `isAbortError()`.
|
|
24
|
+
*/
|
|
25
|
+
export declare function rewriteWithOpenAI(params: {
|
|
26
|
+
oldContent: string;
|
|
27
|
+
editSnippet: string;
|
|
28
|
+
promptAiSdk: PromptAiSdkFn;
|
|
29
|
+
} & ParamsExcluding<PromptAiSdkFn, 'messages' | 'model'>): Promise<string>;
|
|
30
|
+
/**
|
|
31
|
+
* Checks if Claude forgot to add "... existing code ..." placeholders.
|
|
32
|
+
*
|
|
33
|
+
* This handles a specific case where Claude sketches an update to a single function,
|
|
34
|
+
* but forgets to add ... existing code ... above and below the function.
|
|
35
|
+
*
|
|
36
|
+
* @throws {Error} When the request is aborted by user. Check with `isAbortError()`.
|
|
37
|
+
*/
|
|
38
|
+
export declare const shouldAddFilePlaceholders: (params: {
|
|
39
|
+
filePath: string;
|
|
40
|
+
oldContent: string;
|
|
41
|
+
rewrittenNewContent: string;
|
|
42
|
+
messageHistory: Message[];
|
|
43
|
+
fullResponse: string;
|
|
44
|
+
logger: Logger;
|
|
45
|
+
} & ParamsExcluding<typeof promptFlashWithFallbacks, "messages" | "model">) => Promise<boolean>;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { type FinetunedVertexModel } from '@levelcode/common/old-constants';
|
|
2
|
+
import { promptFlashWithFallbacks } from '../llm-api/gemini-with-fallbacks';
|
|
3
|
+
import type { TextBlock } from '../llm-api/claude';
|
|
4
|
+
import type { PromptAiSdkFn } from '@levelcode/common/types/contracts/llm';
|
|
5
|
+
import type { Logger } from '@levelcode/common/types/contracts/logger';
|
|
6
|
+
import type { ParamsExcluding } from '@levelcode/common/types/function-params';
|
|
7
|
+
import type { Message } from '@levelcode/common/types/messages/levelcode-message';
|
|
8
|
+
import type { ProjectFileContext } from '@levelcode/common/util/file';
|
|
9
|
+
export declare function requestRelevantFiles(params: {
|
|
10
|
+
messages: Message[];
|
|
11
|
+
system: string | Array<TextBlock>;
|
|
12
|
+
fileContext: ProjectFileContext;
|
|
13
|
+
assistantPrompt: string | null;
|
|
14
|
+
agentStepId: string;
|
|
15
|
+
clientSessionId: string;
|
|
16
|
+
fingerprintId: string;
|
|
17
|
+
userInputId: string;
|
|
18
|
+
userId: string | undefined;
|
|
19
|
+
repoId: string | undefined;
|
|
20
|
+
logger: Logger;
|
|
21
|
+
} & ParamsExcluding<typeof getRelevantFiles, 'messages' | 'userPrompt' | 'requestType' | 'modelId'>): Promise<string[]>;
|
|
22
|
+
export declare function requestRelevantFilesForTraining(params: {
|
|
23
|
+
messages: Message[];
|
|
24
|
+
fileContext: ProjectFileContext;
|
|
25
|
+
assistantPrompt: string | null;
|
|
26
|
+
logger: Logger;
|
|
27
|
+
} & ParamsExcluding<typeof getRelevantFilesForTraining, 'messages' | 'userPrompt' | 'requestType'>): Promise<string[]>;
|
|
28
|
+
declare function getRelevantFiles(params: {
|
|
29
|
+
messages: Message[];
|
|
30
|
+
system: string | Array<TextBlock>;
|
|
31
|
+
userPrompt: string;
|
|
32
|
+
requestType: string;
|
|
33
|
+
agentStepId: string;
|
|
34
|
+
clientSessionId: string;
|
|
35
|
+
fingerprintId: string;
|
|
36
|
+
userInputId: string;
|
|
37
|
+
userId: string | undefined;
|
|
38
|
+
repoId: string | undefined;
|
|
39
|
+
modelId?: FinetunedVertexModel;
|
|
40
|
+
logger: Logger;
|
|
41
|
+
} & ParamsExcluding<typeof promptFlashWithFallbacks, 'messages' | 'model' | 'useFinetunedModel'>): Promise<{
|
|
42
|
+
files: string[];
|
|
43
|
+
duration: number;
|
|
44
|
+
requestType: string;
|
|
45
|
+
response: string;
|
|
46
|
+
}>;
|
|
47
|
+
/**
|
|
48
|
+
* Gets relevant files for training using Claude Sonnet.
|
|
49
|
+
*
|
|
50
|
+
* @throws {Error} When the request is aborted by user. Check with `isAbortError()`.
|
|
51
|
+
*/
|
|
52
|
+
declare function getRelevantFilesForTraining(params: {
|
|
53
|
+
messages: Message[];
|
|
54
|
+
system: string | Array<TextBlock>;
|
|
55
|
+
userPrompt: string;
|
|
56
|
+
requestType: string;
|
|
57
|
+
agentStepId: string;
|
|
58
|
+
clientSessionId: string;
|
|
59
|
+
fingerprintId: string;
|
|
60
|
+
userInputId: string;
|
|
61
|
+
userId: string | undefined;
|
|
62
|
+
repoId: string | undefined;
|
|
63
|
+
promptAiSdk: PromptAiSdkFn;
|
|
64
|
+
logger: Logger;
|
|
65
|
+
} & ParamsExcluding<PromptAiSdkFn, 'messages' | 'model' | 'chargeUser'>): Promise<{
|
|
66
|
+
files: string[];
|
|
67
|
+
duration: number;
|
|
68
|
+
requestType: string;
|
|
69
|
+
response: string;
|
|
70
|
+
}>;
|
|
71
|
+
export {};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { PromptAiSdkFn } from '@levelcode/common/types/contracts/llm';
|
|
2
|
+
import type { Logger } from '@levelcode/common/types/contracts/logger';
|
|
3
|
+
import type { ParamsExcluding } from '@levelcode/common/types/function-params';
|
|
4
|
+
export declare const parseAndGetDiffBlocksSingleFile: (params: {
|
|
5
|
+
newContent: string;
|
|
6
|
+
oldFileContent: string;
|
|
7
|
+
logger: Logger;
|
|
8
|
+
}) => {
|
|
9
|
+
diffBlocks: {
|
|
10
|
+
searchContent: string;
|
|
11
|
+
replaceContent: string;
|
|
12
|
+
}[];
|
|
13
|
+
diffBlocksThatDidntMatch: {
|
|
14
|
+
searchContent: string;
|
|
15
|
+
replaceContent: string;
|
|
16
|
+
}[];
|
|
17
|
+
};
|
|
18
|
+
export declare const tryToDoStringReplacementWithExtraIndentation: (params: {
|
|
19
|
+
oldFileContent: string;
|
|
20
|
+
searchContent: string;
|
|
21
|
+
replaceContent: string;
|
|
22
|
+
}) => {
|
|
23
|
+
searchContent: string;
|
|
24
|
+
replaceContent: string;
|
|
25
|
+
} | null;
|
|
26
|
+
/**
|
|
27
|
+
* Retries generating diff blocks when initial blocks failed to match the old file content.
|
|
28
|
+
*
|
|
29
|
+
* @throws {Error} When the request is aborted by user. Check with `isAbortError()`.
|
|
30
|
+
*/
|
|
31
|
+
export declare function retryDiffBlocksPrompt(params: {
|
|
32
|
+
filePath: string;
|
|
33
|
+
oldContent: string;
|
|
34
|
+
clientSessionId: string;
|
|
35
|
+
fingerprintId: string;
|
|
36
|
+
userInputId: string;
|
|
37
|
+
userId: string | undefined;
|
|
38
|
+
diffBlocksThatDidntMatch: {
|
|
39
|
+
searchContent: string;
|
|
40
|
+
replaceContent: string;
|
|
41
|
+
}[];
|
|
42
|
+
promptAiSdk: PromptAiSdkFn;
|
|
43
|
+
logger: Logger;
|
|
44
|
+
} & ParamsExcluding<PromptAiSdkFn, 'messages' | 'model'>): Promise<{
|
|
45
|
+
newDiffBlocks: {
|
|
46
|
+
searchContent: string;
|
|
47
|
+
replaceContent: string;
|
|
48
|
+
}[];
|
|
49
|
+
newDiffBlocksThatDidntMatch: {
|
|
50
|
+
searchContent: string;
|
|
51
|
+
replaceContent: string;
|
|
52
|
+
}[];
|
|
53
|
+
}>;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { TeamProtocolMessage } from '@levelcode/common/types/team-protocol';
|
|
2
|
+
import type { Logger } from '@levelcode/common/types/contracts/logger';
|
|
3
|
+
export interface InboxPollerConfig {
|
|
4
|
+
teamName: string;
|
|
5
|
+
agentName: string;
|
|
6
|
+
pollIntervalMs?: number;
|
|
7
|
+
logger: Logger;
|
|
8
|
+
}
|
|
9
|
+
export interface InboxPollResult {
|
|
10
|
+
messages: TeamProtocolMessage[];
|
|
11
|
+
formattedContent: string | null;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* InboxPoller continuously polls an agent's inbox file for new messages
|
|
15
|
+
* and provides them in a format suitable for injection into the agent's
|
|
16
|
+
* next prompt turn.
|
|
17
|
+
*
|
|
18
|
+
* Usage:
|
|
19
|
+
* const poller = new InboxPoller({ teamName, agentName, logger })
|
|
20
|
+
* poller.start()
|
|
21
|
+
* // Between agent turns:
|
|
22
|
+
* const result = poller.drain()
|
|
23
|
+
* if (result.formattedContent) {
|
|
24
|
+
* // inject into message history
|
|
25
|
+
* }
|
|
26
|
+
* // When agent shuts down:
|
|
27
|
+
* poller.stop()
|
|
28
|
+
*/
|
|
29
|
+
export declare class InboxPoller {
|
|
30
|
+
private teamName;
|
|
31
|
+
private agentName;
|
|
32
|
+
private pollIntervalMs;
|
|
33
|
+
private logger;
|
|
34
|
+
private timer;
|
|
35
|
+
private pendingMessages;
|
|
36
|
+
private running;
|
|
37
|
+
constructor(config: InboxPollerConfig);
|
|
38
|
+
/**
|
|
39
|
+
* Start polling the inbox file at the configured interval.
|
|
40
|
+
*/
|
|
41
|
+
start(): void;
|
|
42
|
+
/**
|
|
43
|
+
* Stop polling.
|
|
44
|
+
*/
|
|
45
|
+
stop(): void;
|
|
46
|
+
/**
|
|
47
|
+
* Poll the inbox once and accumulate any new messages.
|
|
48
|
+
* Messages are read from the filesystem and the inbox is cleared
|
|
49
|
+
* after reading to prevent duplicate delivery.
|
|
50
|
+
*/
|
|
51
|
+
private poll;
|
|
52
|
+
/**
|
|
53
|
+
* Drain all accumulated pending messages and return them.
|
|
54
|
+
* After calling drain(), the internal buffer is cleared.
|
|
55
|
+
* Returns both the raw messages and a formatted string suitable
|
|
56
|
+
* for injection into the agent's message history.
|
|
57
|
+
*/
|
|
58
|
+
drain(): InboxPollResult;
|
|
59
|
+
/**
|
|
60
|
+
* Check if there are any pending messages without draining them.
|
|
61
|
+
*/
|
|
62
|
+
hasPendingMessages(): boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Force an immediate poll (useful before draining between turns).
|
|
65
|
+
*/
|
|
66
|
+
pollNow(): void;
|
|
67
|
+
/**
|
|
68
|
+
* Returns whether the poller is currently running.
|
|
69
|
+
*/
|
|
70
|
+
isRunning(): boolean;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* One-shot convenience function: reads the inbox, formats messages,
|
|
74
|
+
* clears the inbox, and returns the result. Useful when you don't need
|
|
75
|
+
* continuous background polling and just want to check between turns.
|
|
76
|
+
*/
|
|
77
|
+
export declare function drainInbox(params: {
|
|
78
|
+
teamName: string;
|
|
79
|
+
agentName: string;
|
|
80
|
+
logger: Logger;
|
|
81
|
+
}): InboxPollResult;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { Logger } from '@levelcode/common/types/contracts/logger';
|
|
2
|
+
import type { ParamsOf } from '@levelcode/common/types/function-params';
|
|
3
|
+
export interface SearchResponse {
|
|
4
|
+
results: Array<{
|
|
5
|
+
id: string;
|
|
6
|
+
title: string;
|
|
7
|
+
description: string;
|
|
8
|
+
branch: string;
|
|
9
|
+
lastUpdateDate: string;
|
|
10
|
+
state: DocumentState;
|
|
11
|
+
totalTokens: number;
|
|
12
|
+
totalSnippets: number;
|
|
13
|
+
totalPages: number;
|
|
14
|
+
stars?: number;
|
|
15
|
+
trustScore?: number;
|
|
16
|
+
}>;
|
|
17
|
+
}
|
|
18
|
+
type DocumentState = 'initial' | 'finalized' | 'error' | 'delete';
|
|
19
|
+
export interface SearchResult {
|
|
20
|
+
id: string;
|
|
21
|
+
title: string;
|
|
22
|
+
description: string;
|
|
23
|
+
branch: string;
|
|
24
|
+
lastUpdateDate: string;
|
|
25
|
+
state: DocumentState;
|
|
26
|
+
totalTokens: number;
|
|
27
|
+
totalSnippets: number;
|
|
28
|
+
totalPages: number;
|
|
29
|
+
stars?: number;
|
|
30
|
+
trustScore?: number;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Lists all available documentation projects from Context7
|
|
34
|
+
* @returns Array of projects with their metadata, or null if the request fails
|
|
35
|
+
*/
|
|
36
|
+
export declare function searchLibraries(params: {
|
|
37
|
+
query: string;
|
|
38
|
+
logger: Logger;
|
|
39
|
+
fetch: typeof globalThis.fetch;
|
|
40
|
+
}): Promise<SearchResult[] | null>;
|
|
41
|
+
/**
|
|
42
|
+
* Fetches documentation context for a specific library
|
|
43
|
+
* @param libraryId The library ID to fetch documentation for
|
|
44
|
+
* @param options Options for the request
|
|
45
|
+
* @returns The documentation text or null if the request fails
|
|
46
|
+
*/
|
|
47
|
+
export declare function fetchContext7LibraryDocumentation(params: {
|
|
48
|
+
query: string;
|
|
49
|
+
tokens?: number;
|
|
50
|
+
topic?: string;
|
|
51
|
+
folders?: string;
|
|
52
|
+
logger: Logger;
|
|
53
|
+
fetch: typeof globalThis.fetch;
|
|
54
|
+
} & ParamsOf<typeof searchLibraries>): Promise<string | null>;
|
|
55
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { FinetunedVertexModel } from '@levelcode/common/old-constants';
|
|
2
|
+
import type { PromptAiSdkFn } from '@levelcode/common/types/contracts/llm';
|
|
3
|
+
import type { Logger } from '@levelcode/common/types/contracts/logger';
|
|
4
|
+
import type { ParamsExcluding } from '@levelcode/common/types/function-params';
|
|
5
|
+
import type { Message } from '@levelcode/common/types/messages/levelcode-message';
|
|
6
|
+
/**
|
|
7
|
+
* Prompts a Gemini model with fallback logic.
|
|
8
|
+
*
|
|
9
|
+
* Attempts to call the specified Gemini model via the standard Gemini API.
|
|
10
|
+
* If that fails, it falls back to using the Vertex AI Gemini endpoint.
|
|
11
|
+
* If Vertex AI also fails, it falls back to either GPT-4o (if `useGPT4oInsteadOfClaude` is true)
|
|
12
|
+
* or a Claude model (Sonnet for 'max' costMode, Haiku otherwise).
|
|
13
|
+
*
|
|
14
|
+
* This function handles non-streaming requests and returns the complete response string.
|
|
15
|
+
*
|
|
16
|
+
* @param messages - The array of messages forming the conversation history.
|
|
17
|
+
* @param system - An optional system prompt string or array of text blocks.
|
|
18
|
+
* @param options - Configuration options for the API call.
|
|
19
|
+
* @param options.clientSessionId - Unique ID for the client session.
|
|
20
|
+
* @param options.fingerprintId - Unique ID for the user's device/fingerprint.
|
|
21
|
+
* @param options.userInputId - Unique ID for the specific user input triggering this call.
|
|
22
|
+
* @param options.model - The primary Gemini model to attempt.
|
|
23
|
+
* @param options.userId - The ID of the user making the request.
|
|
24
|
+
* @param options.maxTokens - Optional maximum number of tokens for the response.
|
|
25
|
+
* @param options.temperature - Optional temperature setting for generation (0-1).
|
|
26
|
+
* @param options.costMode - Optional cost mode ('free', 'normal', 'max') influencing fallback model choice.
|
|
27
|
+
* @param options.useGPT4oInsteadOfClaude - Optional flag to use GPT-4o instead of Claude as the final fallback.
|
|
28
|
+
* @returns A promise that resolves to the complete response string from the successful API call.
|
|
29
|
+
* @throws {Error} If all API calls (primary and fallbacks) fail.
|
|
30
|
+
* @throws {Error} When the request is aborted by user. Check with `isAbortError()`. Aborts are not retried.
|
|
31
|
+
*/
|
|
32
|
+
export declare function promptFlashWithFallbacks(params: {
|
|
33
|
+
messages: Message[];
|
|
34
|
+
costMode?: string;
|
|
35
|
+
useGPT4oInsteadOfClaude?: boolean;
|
|
36
|
+
thinkingBudget?: number;
|
|
37
|
+
useFinetunedModel?: FinetunedVertexModel | undefined;
|
|
38
|
+
promptAiSdk: PromptAiSdkFn;
|
|
39
|
+
logger: Logger;
|
|
40
|
+
} & ParamsExcluding<PromptAiSdkFn, 'messages'>): Promise<string>;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { ClientEnv, CiEnv } from '@levelcode/common/types/contracts/env';
|
|
2
|
+
import type { Logger } from '@levelcode/common/types/contracts/logger';
|
|
3
|
+
interface LevelCodeWebApiEnv {
|
|
4
|
+
clientEnv: ClientEnv;
|
|
5
|
+
ciEnv: CiEnv;
|
|
6
|
+
}
|
|
7
|
+
export declare function callWebSearchAPI(params: {
|
|
8
|
+
query: string;
|
|
9
|
+
depth?: 'standard' | 'deep';
|
|
10
|
+
repoUrl?: string | null;
|
|
11
|
+
fetch: typeof globalThis.fetch;
|
|
12
|
+
logger: Logger;
|
|
13
|
+
env: LevelCodeWebApiEnv;
|
|
14
|
+
baseUrl?: string;
|
|
15
|
+
apiKey?: string;
|
|
16
|
+
}): Promise<{
|
|
17
|
+
result?: string;
|
|
18
|
+
error?: string;
|
|
19
|
+
creditsUsed?: number;
|
|
20
|
+
}>;
|
|
21
|
+
export declare function callDocsSearchAPI(params: {
|
|
22
|
+
libraryTitle: string;
|
|
23
|
+
topic?: string;
|
|
24
|
+
maxTokens?: number;
|
|
25
|
+
repoUrl?: string | null;
|
|
26
|
+
fetch: typeof globalThis.fetch;
|
|
27
|
+
logger: Logger;
|
|
28
|
+
env: LevelCodeWebApiEnv;
|
|
29
|
+
baseUrl?: string;
|
|
30
|
+
apiKey?: string;
|
|
31
|
+
}): Promise<{
|
|
32
|
+
documentation?: string;
|
|
33
|
+
error?: string;
|
|
34
|
+
creditsUsed?: number;
|
|
35
|
+
}>;
|
|
36
|
+
export declare function callTokenCountAPI(params: {
|
|
37
|
+
messages: unknown[];
|
|
38
|
+
system?: string;
|
|
39
|
+
model?: string;
|
|
40
|
+
fetch: typeof globalThis.fetch;
|
|
41
|
+
logger: Logger;
|
|
42
|
+
env: LevelCodeWebApiEnv;
|
|
43
|
+
baseUrl?: string;
|
|
44
|
+
apiKey?: string;
|
|
45
|
+
}): Promise<{
|
|
46
|
+
inputTokens?: number;
|
|
47
|
+
error?: string;
|
|
48
|
+
}>;
|
|
49
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { PromptAiSdkFn } from '@levelcode/common/types/contracts/llm';
|
|
2
|
+
import type { Logger } from '@levelcode/common/types/contracts/logger';
|
|
3
|
+
import type { ParamsExcluding } from '@levelcode/common/types/function-params';
|
|
4
|
+
/**
|
|
5
|
+
* Applies code edits using Relace AI, with fallback to o3-mini on failure.
|
|
6
|
+
*
|
|
7
|
+
* @returns The updated code with edits applied.
|
|
8
|
+
* @throws {Error} When the request is aborted by user. Check with `isAbortError()`. Aborts are not retried.
|
|
9
|
+
*/
|
|
10
|
+
export declare function promptRelaceAI(params: {
|
|
11
|
+
initialCode: string;
|
|
12
|
+
editSnippet: string;
|
|
13
|
+
instructions: string | undefined;
|
|
14
|
+
promptAiSdk: PromptAiSdkFn;
|
|
15
|
+
logger: Logger;
|
|
16
|
+
} & ParamsExcluding<PromptAiSdkFn, 'messages' | 'model'>): Promise<string>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { loopAgentSteps } from './run-agent-step';
|
|
2
|
+
import { getAgentTemplate } from './templates/agent-registry';
|
|
3
|
+
import type { AgentTemplate } from './templates/types';
|
|
4
|
+
import type { ClientAction } from '@levelcode/common/actions';
|
|
5
|
+
import type { RequestToolCallFn, SendActionFn } from '@levelcode/common/types/contracts/client';
|
|
6
|
+
import type { Logger } from '@levelcode/common/types/contracts/logger';
|
|
7
|
+
import type { ParamsExcluding } from '@levelcode/common/types/function-params';
|
|
8
|
+
import type { PrintModeEvent } from '@levelcode/common/types/print-mode';
|
|
9
|
+
import type { SessionState, AgentOutput } from '@levelcode/common/types/session-state';
|
|
10
|
+
export declare function mainPrompt(params: {
|
|
11
|
+
action: ClientAction<'prompt'>;
|
|
12
|
+
onResponseChunk: (chunk: string | PrintModeEvent) => void;
|
|
13
|
+
localAgentTemplates: Record<string, AgentTemplate>;
|
|
14
|
+
requestToolCall: RequestToolCallFn;
|
|
15
|
+
logger: Logger;
|
|
16
|
+
} & ParamsExcluding<typeof loopAgentSteps, 'userInputId' | 'spawnParams' | 'agentState' | 'prompt' | 'content' | 'agentType' | 'fingerprintId' | 'fileContext' | 'ancestorRunIds'> & ParamsExcluding<typeof getAgentTemplate, 'agentId'>): Promise<{
|
|
17
|
+
sessionState: SessionState;
|
|
18
|
+
output: AgentOutput;
|
|
19
|
+
}>;
|
|
20
|
+
export declare function callMainPrompt(params: {
|
|
21
|
+
action: ClientAction<'prompt'>;
|
|
22
|
+
promptId: string;
|
|
23
|
+
sendAction: SendActionFn;
|
|
24
|
+
logger: Logger;
|
|
25
|
+
signal: AbortSignal;
|
|
26
|
+
} & ParamsExcluding<typeof mainPrompt, 'localAgentTemplates' | 'onResponseChunk'>): Promise<{
|
|
27
|
+
sessionState: SessionState;
|
|
28
|
+
output: AgentOutput;
|
|
29
|
+
}>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Separator used between MCP server name and tool name.
|
|
3
|
+
*
|
|
4
|
+
* LLM APIs (OpenRouter/Anthropic) only allow tool names matching the pattern
|
|
5
|
+
* ^[a-zA-Z0-9_-]{1,128}$, which doesn't include forward slashes.
|
|
6
|
+
*
|
|
7
|
+
* We use double underscore as the separator since it's:
|
|
8
|
+
* - Allowed by the LLM API pattern
|
|
9
|
+
* - Unlikely to conflict with existing tool names
|
|
10
|
+
* - Clearly identifiable as a separator
|
|
11
|
+
*/
|
|
12
|
+
export declare const MCP_TOOL_SEPARATOR = "__";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { AgentTemplate } from './templates/types';
|
|
2
|
+
import type { RequestMcpToolDataFn } from '@levelcode/common/types/contracts/client';
|
|
3
|
+
import type { OptionalFields } from '@levelcode/common/types/function-params';
|
|
4
|
+
import type { CustomToolDefinitions, ProjectFileContext } from '@levelcode/common/util/file';
|
|
5
|
+
export declare function getMCPToolData(params: OptionalFields<{
|
|
6
|
+
toolNames: AgentTemplate['toolNames'];
|
|
7
|
+
mcpServers: AgentTemplate['mcpServers'];
|
|
8
|
+
writeTo: ProjectFileContext['customToolDefinitions'];
|
|
9
|
+
requestMcpToolData: RequestMcpToolDataFn;
|
|
10
|
+
}, 'writeTo'>): Promise<CustomToolDefinitions>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { TeamProtocolMessage } from '@levelcode/common/types/team-protocol';
|
|
2
|
+
/**
|
|
3
|
+
* Formats a single TeamProtocolMessage into a human-readable string
|
|
4
|
+
* suitable for injection into an agent's message history.
|
|
5
|
+
*/
|
|
6
|
+
export declare function formatTeamMessage(message: TeamProtocolMessage): string;
|
|
7
|
+
/**
|
|
8
|
+
* Formats an array of TeamProtocolMessages into a single string block
|
|
9
|
+
* wrapped in a system-level container tag, ready for injection into
|
|
10
|
+
* the agent's message history.
|
|
11
|
+
*/
|
|
12
|
+
export declare function formatInboxMessages(messages: TeamProtocolMessage[]): string | null;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { type PromptResult } from '@levelcode/common/util/error';
|
|
2
|
+
import { fastRewrite, shouldAddFilePlaceholders } from './fast-rewrite';
|
|
3
|
+
import { retryDiffBlocksPrompt } from './generate-diffs-prompt';
|
|
4
|
+
import type { PromptAiSdkFn } from '@levelcode/common/types/contracts/llm';
|
|
5
|
+
import type { Logger } from '@levelcode/common/types/contracts/logger';
|
|
6
|
+
import type { ParamsExcluding } from '@levelcode/common/types/function-params';
|
|
7
|
+
import type { Message } from '@levelcode/common/types/messages/levelcode-message';
|
|
8
|
+
type WriteFileSuccess = {
|
|
9
|
+
tool: 'write_file';
|
|
10
|
+
path: string;
|
|
11
|
+
content: string;
|
|
12
|
+
patch: string | undefined;
|
|
13
|
+
messages: string[];
|
|
14
|
+
};
|
|
15
|
+
type WriteFileError = {
|
|
16
|
+
tool: 'write_file';
|
|
17
|
+
path: string;
|
|
18
|
+
error: string;
|
|
19
|
+
};
|
|
20
|
+
export type WriteFileResult = WriteFileSuccess | WriteFileError;
|
|
21
|
+
/**
|
|
22
|
+
* Processes a file block from the LLM response, applying edits to create updated file content.
|
|
23
|
+
*
|
|
24
|
+
* Returns a PromptResult to explicitly handle the abort case:
|
|
25
|
+
* - `{ aborted: true }` when the user cancels the operation
|
|
26
|
+
* - `{ aborted: false, value: WriteFileResult }` on success or recoverable error
|
|
27
|
+
*/
|
|
28
|
+
export declare function processFileBlock(params: {
|
|
29
|
+
path: string;
|
|
30
|
+
initialContentPromise: Promise<string | null>;
|
|
31
|
+
newContent: string;
|
|
32
|
+
messages: Message[];
|
|
33
|
+
fullResponse: string;
|
|
34
|
+
lastUserPrompt: string | undefined;
|
|
35
|
+
clientSessionId: string;
|
|
36
|
+
fingerprintId: string;
|
|
37
|
+
userInputId: string;
|
|
38
|
+
userId: string | undefined;
|
|
39
|
+
logger: Logger;
|
|
40
|
+
} & ParamsExcluding<typeof handleLargeFile, 'oldContent' | 'editSnippet' | 'filePath'> & ParamsExcluding<typeof fastRewrite, 'initialContent' | 'editSnippet' | 'filePath' | 'userMessage'> & ParamsExcluding<typeof shouldAddFilePlaceholders, 'filePath' | 'oldContent' | 'rewrittenNewContent' | 'messageHistory'>): Promise<PromptResult<WriteFileResult>>;
|
|
41
|
+
/**
|
|
42
|
+
* Handles large file edits by generating SEARCH/REPLACE blocks.
|
|
43
|
+
*
|
|
44
|
+
* Returns a PromptResult to explicitly handle the abort case:
|
|
45
|
+
* - `{ aborted: true }` when the user cancels the operation
|
|
46
|
+
* - `{ aborted: false, value: string }` on success
|
|
47
|
+
* - `{ aborted: false, value: null }` if diff blocks failed to match after retry
|
|
48
|
+
*/
|
|
49
|
+
export declare function handleLargeFile(params: {
|
|
50
|
+
oldContent: string;
|
|
51
|
+
editSnippet: string;
|
|
52
|
+
filePath: string;
|
|
53
|
+
logger: Logger;
|
|
54
|
+
promptAiSdk: PromptAiSdkFn;
|
|
55
|
+
} & ParamsExcluding<typeof retryDiffBlocksPrompt, 'oldContent' | 'diffBlocksThatDidntMatch'> & ParamsExcluding<PromptAiSdkFn, 'messages' | 'model'>): Promise<PromptResult<string | null>>;
|
|
56
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Logger } from '@levelcode/common/types/contracts/logger';
|
|
2
|
+
export declare function processStrReplace(params: {
|
|
3
|
+
path: string;
|
|
4
|
+
replacements: {
|
|
5
|
+
old: string;
|
|
6
|
+
new: string;
|
|
7
|
+
allowMultiple: boolean;
|
|
8
|
+
}[];
|
|
9
|
+
initialContentPromise: Promise<string | null>;
|
|
10
|
+
logger: Logger;
|
|
11
|
+
}): Promise<{
|
|
12
|
+
tool: 'str_replace';
|
|
13
|
+
path: string;
|
|
14
|
+
content: string;
|
|
15
|
+
patch: string;
|
|
16
|
+
messages: string[];
|
|
17
|
+
} | {
|
|
18
|
+
tool: 'str_replace';
|
|
19
|
+
path: string;
|
|
20
|
+
error: string;
|
|
21
|
+
}>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { AgentTemplate } from './templates/types';
|
|
2
|
+
import type { TrackEventFn } from '@levelcode/common/types/contracts/analytics';
|
|
3
|
+
import type { SendActionFn } from '@levelcode/common/types/contracts/client';
|
|
4
|
+
import type { PromptAiSdkStreamFn } from '@levelcode/common/types/contracts/llm';
|
|
5
|
+
import type { Logger } from '@levelcode/common/types/contracts/logger';
|
|
6
|
+
import type { Message } from '@levelcode/common/types/messages/levelcode-message';
|
|
7
|
+
import type { ToolSet } from 'ai';
|
|
8
|
+
export declare const getAgentStreamFromTemplate: (params: {
|
|
9
|
+
agentId?: string;
|
|
10
|
+
apiKey: string;
|
|
11
|
+
clientSessionId: string;
|
|
12
|
+
costMode?: string;
|
|
13
|
+
fingerprintId: string;
|
|
14
|
+
includeCacheControl?: boolean;
|
|
15
|
+
localAgentTemplates: Record<string, AgentTemplate>;
|
|
16
|
+
logger: Logger;
|
|
17
|
+
messages: Message[];
|
|
18
|
+
runId: string;
|
|
19
|
+
signal: AbortSignal;
|
|
20
|
+
template: AgentTemplate;
|
|
21
|
+
tools: ToolSet;
|
|
22
|
+
userId: string | undefined;
|
|
23
|
+
userInputId: string;
|
|
24
|
+
onCostCalculated?: (credits: number) => Promise<void>;
|
|
25
|
+
promptAiSdkStream: PromptAiSdkStreamFn;
|
|
26
|
+
sendAction: SendActionFn;
|
|
27
|
+
trackEvent: TrackEventFn;
|
|
28
|
+
}) => ReturnType<PromptAiSdkStreamFn>;
|