@levelcode/sdk 0.2.0 → 0.2.2
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/index.cjs +313 -303
- package/dist/index.cjs.map +21 -21
- package/dist/index.mjs +346 -336
- package/dist/index.mjs.map +21 -21
- package/package.json +1 -1
- package/dist/agents/constants.d.ts +0 -1
- package/dist/agents/team/apprentice.d.ts +0 -3
- package/dist/agents/team/coordinator.d.ts +0 -3
- package/dist/agents/team/cto.d.ts +0 -3
- package/dist/agents/team/designer.d.ts +0 -3
- package/dist/agents/team/director.d.ts +0 -3
- package/dist/agents/team/distinguished-engineer.d.ts +0 -3
- package/dist/agents/team/fellow.d.ts +0 -3
- package/dist/agents/team/index.d.ts +0 -27
- package/dist/agents/team/intern.d.ts +0 -3
- package/dist/agents/team/junior-engineer.d.ts +0 -3
- package/dist/agents/team/manager.d.ts +0 -3
- package/dist/agents/team/mid-level-engineer.d.ts +0 -3
- package/dist/agents/team/principal-engineer.d.ts +0 -3
- package/dist/agents/team/product-lead.d.ts +0 -3
- package/dist/agents/team/researcher.d.ts +0 -3
- package/dist/agents/team/role-hierarchy.d.ts +0 -24
- package/dist/agents/team/scientist.d.ts +0 -3
- package/dist/agents/team/senior-engineer.d.ts +0 -3
- package/dist/agents/team/senior-staff-engineer.d.ts +0 -3
- package/dist/agents/team/staff-engineer.d.ts +0 -3
- package/dist/agents/team/sub-manager.d.ts +0 -3
- package/dist/agents/team/tester.d.ts +0 -3
- package/dist/agents/team/vp-engineering.d.ts +0 -3
- package/dist/agents/types/agent-definition.d.ts +0 -296
- package/dist/agents/types/secret-agent-definition.d.ts +0 -19
- package/dist/agents/types/tools.d.ts +0 -308
- package/dist/agents/types/util-types.d.ts +0 -134
- package/dist/common/src/actions.d.ts +0 -176
- package/dist/common/src/analytics-core.d.ts +0 -52
- package/dist/common/src/analytics.d.ts +0 -9
- package/dist/common/src/browser-actions.d.ts +0 -1200
- package/dist/common/src/constants/agents.d.ts +0 -47
- package/dist/common/src/constants/analytics-events.d.ts +0 -111
- package/dist/common/src/constants/byok.d.ts +0 -2
- package/dist/common/src/constants/claude-oauth.d.ts +0 -36
- package/dist/common/src/constants/index.d.ts +0 -4
- package/dist/common/src/constants/knowledge.d.ts +0 -21
- package/dist/common/src/constants/limits.d.ts +0 -14
- package/dist/common/src/constants/model-config.d.ts +0 -117
- package/dist/common/src/constants/paths.d.ts +0 -23
- package/dist/common/src/constants/skills.d.ts +0 -42
- package/dist/common/src/constants/ui.d.ts +0 -14
- package/dist/common/src/env-ci.d.ts +0 -22
- package/dist/common/src/env-process.d.ts +0 -28
- package/dist/common/src/env-schema.d.ts +0 -24
- package/dist/common/src/env.d.ts +0 -16
- package/dist/common/src/mcp/client.d.ts +0 -6
- package/dist/common/src/old-constants.d.ts +0 -10
- package/dist/common/src/project-file-tree.d.ts +0 -27
- package/dist/common/src/templates/agent-validation.d.ts +0 -48
- package/dist/common/src/templates/initial-agents-dir/types/agent-definition.d.ts +0 -296
- package/dist/common/src/templates/initial-agents-dir/types/tools.d.ts +0 -308
- package/dist/common/src/templates/initial-agents-dir/types/util-types.d.ts +0 -128
- package/dist/common/src/testing/errors.d.ts +0 -14
- package/dist/common/src/testing/mock-modules.d.ts +0 -11
- package/dist/common/src/testing/mock-types.d.ts +0 -97
- package/dist/common/src/testing/mocks/analytics.d.ts +0 -182
- package/dist/common/src/testing/mocks/child-process.d.ts +0 -29
- package/dist/common/src/testing/mocks/crypto.d.ts +0 -159
- package/dist/common/src/testing/mocks/database.d.ts +0 -197
- package/dist/common/src/testing/mocks/fetch.d.ts +0 -35
- package/dist/common/src/testing/mocks/filesystem.d.ts +0 -31
- package/dist/common/src/testing/mocks/index.d.ts +0 -25
- package/dist/common/src/testing/mocks/logger.d.ts +0 -35
- package/dist/common/src/testing/mocks/stream.d.ts +0 -203
- package/dist/common/src/testing/mocks/timers.d.ts +0 -27
- package/dist/common/src/testing/mocks/tree-sitter.d.ts +0 -58
- package/dist/common/src/testing-env-process.d.ts +0 -7
- package/dist/common/src/tools/constants.d.ts +0 -17
- package/dist/common/src/tools/list.d.ts +0 -1152
- package/dist/common/src/tools/params/tool/add-message.d.ts +0 -19
- package/dist/common/src/tools/params/tool/add-subgoal.d.ts +0 -26
- package/dist/common/src/tools/params/tool/ask-user.d.ts +0 -59
- package/dist/common/src/tools/params/tool/browser-logs.d.ts +0 -127
- package/dist/common/src/tools/params/tool/code-search.d.ts +0 -30
- package/dist/common/src/tools/params/tool/create-plan.d.ts +0 -30
- package/dist/common/src/tools/params/tool/end-turn.d.ts +0 -13
- package/dist/common/src/tools/params/tool/find-files.d.ts +0 -31
- package/dist/common/src/tools/params/tool/glob.d.ts +0 -26
- package/dist/common/src/tools/params/tool/list-directory.d.ts +0 -25
- package/dist/common/src/tools/params/tool/lookup-agent-info.d.ts +0 -13
- package/dist/common/src/tools/params/tool/propose-str-replace.d.ts +0 -40
- package/dist/common/src/tools/params/tool/propose-write-file.d.ts +0 -29
- package/dist/common/src/tools/params/tool/read-docs.d.ts +0 -19
- package/dist/common/src/tools/params/tool/read-files.d.ts +0 -35
- package/dist/common/src/tools/params/tool/read-subtree.d.ts +0 -40
- package/dist/common/src/tools/params/tool/run-file-change-hooks.d.ts +0 -63
- package/dist/common/src/tools/params/tool/run-terminal-command.d.ts +0 -88
- package/dist/common/src/tools/params/tool/send-message.d.ts +0 -26
- package/dist/common/src/tools/params/tool/set-messages.d.ts +0 -15
- package/dist/common/src/tools/params/tool/set-output.d.ts +0 -15
- package/dist/common/src/tools/params/tool/skill.d.ts +0 -28
- package/dist/common/src/tools/params/tool/spawn-agent-inline.d.ts +0 -17
- package/dist/common/src/tools/params/tool/spawn-agents.d.ts +0 -26
- package/dist/common/src/tools/params/tool/str-replace.d.ts +0 -43
- package/dist/common/src/tools/params/tool/suggest-followups.d.ts +0 -26
- package/dist/common/src/tools/params/tool/task-completed.d.ts +0 -13
- package/dist/common/src/tools/params/tool/task-create.d.ts +0 -24
- package/dist/common/src/tools/params/tool/task-get.d.ts +0 -15
- package/dist/common/src/tools/params/tool/task-list.d.ts +0 -13
- package/dist/common/src/tools/params/tool/task-update.d.ts +0 -29
- package/dist/common/src/tools/params/tool/team-create.d.ts +0 -17
- package/dist/common/src/tools/params/tool/team-delete.d.ts +0 -13
- package/dist/common/src/tools/params/tool/think-deeply.d.ts +0 -15
- package/dist/common/src/tools/params/tool/update-subgoal.d.ts +0 -25
- package/dist/common/src/tools/params/tool/web-search.d.ts +0 -25
- package/dist/common/src/tools/params/tool/write-file.d.ts +0 -31
- package/dist/common/src/tools/params/tool/write-todos.d.ts +0 -18
- package/dist/common/src/tools/params/utils.d.ts +0 -35
- package/dist/common/src/tools/utils.d.ts +0 -4
- package/dist/common/src/types/agent-template.d.ts +0 -156
- package/dist/common/src/types/contracts/agent-runtime.d.ts +0 -36
- package/dist/common/src/types/contracts/analytics.d.ts +0 -8
- package/dist/common/src/types/contracts/billing.d.ts +0 -40
- package/dist/common/src/types/contracts/client.d.ts +0 -45
- package/dist/common/src/types/contracts/database.d.ts +0 -80
- package/dist/common/src/types/contracts/env.d.ts +0 -150
- package/dist/common/src/types/contracts/llm.d.ts +0 -102
- package/dist/common/src/types/contracts/logger.d.ts +0 -8
- package/dist/common/src/types/dynamic-agent-template.d.ts +0 -227
- package/dist/common/src/types/filesystem.d.ts +0 -6
- package/dist/common/src/types/function-params.d.ts +0 -15
- package/dist/common/src/types/grant.d.ts +0 -2
- package/dist/common/src/types/json.d.ts +0 -9
- package/dist/common/src/types/mcp.d.ts +0 -31
- package/dist/common/src/types/messages/content-part.d.ts +0 -46
- package/dist/common/src/types/messages/data-content.d.ts +0 -3
- package/dist/common/src/types/messages/levelcode-message.d.ts +0 -37
- package/dist/common/src/types/messages/provider-metadata.d.ts +0 -3
- package/dist/common/src/types/print-mode.d.ts +0 -155
- package/dist/common/src/types/session-state.d.ts +0 -94
- package/dist/common/src/types/skill.d.ts +0 -31
- package/dist/common/src/types/source.d.ts +0 -8
- package/dist/common/src/types/spawn.d.ts +0 -8
- package/dist/common/src/types/team-config-schemas.d.ts +0 -213
- package/dist/common/src/types/team-config.d.ts +0 -42
- package/dist/common/src/types/team-hook-events.d.ts +0 -36
- package/dist/common/src/types/team-protocol.d.ts +0 -64
- package/dist/common/src/util/agent-id-parsing.d.ts +0 -22
- package/dist/common/src/util/agent-name-normalization.d.ts +0 -12
- package/dist/common/src/util/array.d.ts +0 -6
- package/dist/common/src/util/credentials.d.ts +0 -11
- package/dist/common/src/util/error.d.ts +0 -128
- package/dist/common/src/util/file.d.ts +0 -133
- package/dist/common/src/util/format-code-search.d.ts +0 -16
- package/dist/common/src/util/lru-cache.d.ts +0 -30
- package/dist/common/src/util/messages.d.ts +0 -46
- package/dist/common/src/util/model-utils.d.ts +0 -8
- package/dist/common/src/util/object.d.ts +0 -22
- package/dist/common/src/util/promise.d.ts +0 -16
- package/dist/common/src/util/random.d.ts +0 -1
- package/dist/common/src/util/skills.d.ts +0 -5
- package/dist/common/src/util/stop-sequence.d.ts +0 -14
- package/dist/common/src/util/string.d.ts +0 -82
- package/dist/common/src/util/xml.d.ts +0 -12
- package/dist/common/src/util/zod-schema.d.ts +0 -5
- package/dist/common/src/utils/dev-phases.d.ts +0 -23
- package/dist/common/src/utils/file-lock.d.ts +0 -13
- package/dist/common/src/utils/team-analytics.d.ts +0 -16
- package/dist/common/src/utils/team-discovery.d.ts +0 -47
- package/dist/common/src/utils/team-fs.d.ts +0 -20
- package/dist/common/src/utils/team-hook-emitter.d.ts +0 -40
- package/dist/common/src/utils/team-presets.d.ts +0 -35
- package/dist/packages/agent-runtime/src/constants.d.ts +0 -1
- package/dist/packages/agent-runtime/src/fast-rewrite.d.ts +0 -45
- package/dist/packages/agent-runtime/src/find-files/request-files-prompt.d.ts +0 -71
- package/dist/packages/agent-runtime/src/generate-diffs-prompt.d.ts +0 -53
- package/dist/packages/agent-runtime/src/get-file-reading-updates.d.ts +0 -8
- package/dist/packages/agent-runtime/src/inbox-poller.d.ts +0 -81
- package/dist/packages/agent-runtime/src/llm-api/claude.d.ts +0 -5
- package/dist/packages/agent-runtime/src/llm-api/context7-api.d.ts +0 -55
- package/dist/packages/agent-runtime/src/llm-api/gemini-with-fallbacks.d.ts +0 -40
- package/dist/packages/agent-runtime/src/llm-api/levelcode-web-api.d.ts +0 -49
- package/dist/packages/agent-runtime/src/llm-api/relace-api.d.ts +0 -16
- package/dist/packages/agent-runtime/src/main-prompt.d.ts +0 -29
- package/dist/packages/agent-runtime/src/mcp-constants.d.ts +0 -12
- package/dist/packages/agent-runtime/src/mcp.d.ts +0 -10
- package/dist/packages/agent-runtime/src/message-formatter.d.ts +0 -12
- package/dist/packages/agent-runtime/src/process-file-block.d.ts +0 -56
- package/dist/packages/agent-runtime/src/process-str-replace.d.ts +0 -21
- package/dist/packages/agent-runtime/src/prompt-agent-stream.d.ts +0 -28
- package/dist/packages/agent-runtime/src/run-agent-step.d.ts +0 -73
- package/dist/packages/agent-runtime/src/run-programmatic-step.d.ts +0 -40
- package/dist/packages/agent-runtime/src/system-prompt/prompts.d.ts +0 -19
- package/dist/packages/agent-runtime/src/system-prompt/search-system-prompt.d.ts +0 -14
- package/dist/packages/agent-runtime/src/system-prompt/team-context-prompt.d.ts +0 -9
- package/dist/packages/agent-runtime/src/system-prompt/team-prompt.d.ts +0 -9
- package/dist/packages/agent-runtime/src/system-prompt/truncate-file-tree.d.ts +0 -13
- package/dist/packages/agent-runtime/src/team-context.d.ts +0 -14
- package/dist/packages/agent-runtime/src/templates/agent-registry.d.ts +0 -35
- package/dist/packages/agent-runtime/src/templates/prompts.d.ts +0 -35
- package/dist/packages/agent-runtime/src/templates/strings.d.ts +0 -32
- package/dist/packages/agent-runtime/src/templates/types.d.ts +0 -13
- package/dist/packages/agent-runtime/src/tool-stream-parser.d.ts +0 -31
- package/dist/packages/agent-runtime/src/tools/handlers/handler-function-type.d.ts +0 -51
- package/dist/packages/agent-runtime/src/tools/handlers/list.d.ts +0 -366
- package/dist/packages/agent-runtime/src/tools/handlers/tool/add-message.d.ts +0 -9
- package/dist/packages/agent-runtime/src/tools/handlers/tool/add-subgoal.d.ts +0 -9
- package/dist/packages/agent-runtime/src/tools/handlers/tool/ask-user.d.ts +0 -10
- package/dist/packages/agent-runtime/src/tools/handlers/tool/browser-logs.d.ts +0 -8
- package/dist/packages/agent-runtime/src/tools/handlers/tool/code-search.d.ts +0 -8
- package/dist/packages/agent-runtime/src/tools/handlers/tool/create-plan.d.ts +0 -13
- package/dist/packages/agent-runtime/src/tools/handlers/tool/end-turn.d.ts +0 -7
- package/dist/packages/agent-runtime/src/tools/handlers/tool/find-files.d.ts +0 -27
- package/dist/packages/agent-runtime/src/tools/handlers/tool/glob.d.ts +0 -10
- package/dist/packages/agent-runtime/src/tools/handlers/tool/list-directory.d.ts +0 -10
- package/dist/packages/agent-runtime/src/tools/handlers/tool/lookup-agent-info.d.ts +0 -14
- package/dist/packages/agent-runtime/src/tools/handlers/tool/propose-str-replace.d.ts +0 -15
- package/dist/packages/agent-runtime/src/tools/handlers/tool/propose-write-file.d.ts +0 -7
- package/dist/packages/agent-runtime/src/tools/handlers/tool/proposed-content-store.d.ts +0 -27
- package/dist/packages/agent-runtime/src/tools/handlers/tool/read-docs.d.ts +0 -21
- package/dist/packages/agent-runtime/src/tools/handlers/tool/read-files.d.ts +0 -13
- package/dist/packages/agent-runtime/src/tools/handlers/tool/read-subtree.d.ts +0 -13
- package/dist/packages/agent-runtime/src/tools/handlers/tool/run-file-change-hooks.d.ts +0 -10
- package/dist/packages/agent-runtime/src/tools/handlers/tool/run-terminal-command.d.ts +0 -10
- package/dist/packages/agent-runtime/src/tools/handlers/tool/send-message.d.ts +0 -15
- package/dist/packages/agent-runtime/src/tools/handlers/tool/set-messages.d.ts +0 -9
- package/dist/packages/agent-runtime/src/tools/handlers/tool/set-output.d.ts +0 -18
- package/dist/packages/agent-runtime/src/tools/handlers/tool/skill.d.ts +0 -11
- package/dist/packages/agent-runtime/src/tools/handlers/tool/spawn-agent-inline.d.ts +0 -29
- package/dist/packages/agent-runtime/src/tools/handlers/tool/spawn-agent-utils.d.ts +0 -130
- package/dist/packages/agent-runtime/src/tools/handlers/tool/spawn-agents.d.ts +0 -37
- package/dist/packages/agent-runtime/src/tools/handlers/tool/str-replace.d.ts +0 -16
- package/dist/packages/agent-runtime/src/tools/handlers/tool/suggest-followups.d.ts +0 -9
- package/dist/packages/agent-runtime/src/tools/handlers/tool/task-completed.d.ts +0 -15
- package/dist/packages/agent-runtime/src/tools/handlers/tool/task-create.d.ts +0 -9
- package/dist/packages/agent-runtime/src/tools/handlers/tool/task-get.d.ts +0 -9
- package/dist/packages/agent-runtime/src/tools/handlers/tool/task-list.d.ts +0 -9
- package/dist/packages/agent-runtime/src/tools/handlers/tool/task-update.d.ts +0 -14
- package/dist/packages/agent-runtime/src/tools/handlers/tool/team-create.d.ts +0 -15
- package/dist/packages/agent-runtime/src/tools/handlers/tool/team-delete.d.ts +0 -15
- package/dist/packages/agent-runtime/src/tools/handlers/tool/think-deeply.d.ts +0 -9
- package/dist/packages/agent-runtime/src/tools/handlers/tool/update-subgoal.d.ts +0 -11
- package/dist/packages/agent-runtime/src/tools/handlers/tool/web-search.d.ts +0 -22
- package/dist/packages/agent-runtime/src/tools/handlers/tool/write-file.d.ts +0 -49
- package/dist/packages/agent-runtime/src/tools/handlers/tool/write-todos.d.ts +0 -9
- package/dist/packages/agent-runtime/src/tools/prompts.d.ts +0 -31
- package/dist/packages/agent-runtime/src/tools/stream-parser.d.ts +0 -33
- package/dist/packages/agent-runtime/src/tools/tool-executor.d.ts +0 -87
- package/dist/packages/agent-runtime/src/util/agent-output.d.ts +0 -3
- package/dist/packages/agent-runtime/src/util/messages.d.ts +0 -68
- package/dist/packages/agent-runtime/src/util/parse-tool-calls-from-text.d.ts +0 -38
- package/dist/packages/agent-runtime/src/util/render-read-files-result.d.ts +0 -15
- package/dist/packages/agent-runtime/src/util/simplify-tool-results.d.ts +0 -7
- package/dist/packages/agent-runtime/src/util/stream-xml-parser.d.ts +0 -34
- package/dist/packages/agent-runtime/src/util/token-counter.d.ts +0 -3
- package/dist/packages/code-map/src/index.d.ts +0 -3
- package/dist/packages/code-map/src/init-node.d.ts +0 -4
- package/dist/packages/code-map/src/languages.d.ts +0 -36
- package/dist/packages/code-map/src/parse.d.ts +0 -21
- package/dist/packages/code-map/src/types.d.ts +0 -8
- package/dist/packages/code-map/src/utils.d.ts +0 -1
- package/dist/sdk/src/__tests__/client.test.d.ts +0 -1
- package/dist/sdk/src/__tests__/code-search.test.d.ts +0 -1
- package/dist/sdk/src/__tests__/credentials.test.d.ts +0 -1
- package/dist/sdk/src/__tests__/database.test.d.ts +0 -1
- package/dist/sdk/src/__tests__/env.test.d.ts +0 -1
- package/dist/sdk/src/__tests__/error-utils.test.d.ts +0 -1
- package/dist/sdk/src/__tests__/initial-session-state.test.d.ts +0 -1
- package/dist/sdk/src/__tests__/knowledge-file-selection.test.d.ts +0 -1
- package/dist/sdk/src/__tests__/load-agents.test.d.ts +0 -1
- package/dist/sdk/src/__tests__/load-mcp-config.test.d.ts +0 -1
- package/dist/sdk/src/__tests__/model-provider.test.d.ts +0 -1
- package/dist/sdk/src/__tests__/read-files.test.d.ts +0 -1
- package/dist/sdk/src/__tests__/run-cancellation.test.d.ts +0 -1
- package/dist/sdk/src/__tests__/run-file-filter.test.d.ts +0 -1
- package/dist/sdk/src/__tests__/run-handle-event.test.d.ts +0 -1
- package/dist/sdk/src/__tests__/run.integration.test.d.ts +0 -1
- package/dist/sdk/src/__tests__/team-api.test.d.ts +0 -1
- package/dist/sdk/src/__tests__/user-knowledge-files.test.d.ts +0 -1
- package/dist/sdk/src/__tests__/validate-agents.test.d.ts +0 -1
- package/dist/sdk/src/agents/load-agents.d.ts +0 -106
- package/dist/sdk/src/agents/load-mcp-config.d.ts +0 -69
- package/dist/sdk/src/client.d.ts +0 -71
- package/dist/sdk/src/constants.d.ts +0 -4
- package/dist/sdk/src/credentials.d.ts +0 -58
- package/dist/sdk/src/custom-tool.d.ts +0 -32
- package/dist/sdk/src/env.d.ts +0 -31
- package/dist/sdk/src/error-utils.d.ts +0 -55
- package/dist/sdk/src/impl/__tests__/prompt-result.test.d.ts +0 -1
- package/dist/sdk/src/impl/agent-runtime.d.ts +0 -8
- package/dist/sdk/src/impl/database.d.ts +0 -7
- package/dist/sdk/src/impl/llm.d.ts +0 -8
- package/dist/sdk/src/impl/model-provider.d.ts +0 -61
- package/dist/sdk/src/index.d.ts +0 -41
- package/dist/sdk/src/native/ripgrep.d.ts +0 -7
- package/dist/sdk/src/retry-config.d.ts +0 -46
- package/dist/sdk/src/run-state.d.ts +0 -81
- package/dist/sdk/src/run.d.ts +0 -79
- package/dist/sdk/src/skills/load-skills.d.ts +0 -42
- package/dist/sdk/src/team.d.ts +0 -49
- package/dist/sdk/src/testing/env.d.ts +0 -5
- package/dist/sdk/src/tools/change-file.d.ts +0 -7
- package/dist/sdk/src/tools/code-search.d.ts +0 -13
- package/dist/sdk/src/tools/glob.d.ts +0 -8
- package/dist/sdk/src/tools/index.d.ts +0 -16
- package/dist/sdk/src/tools/list-directory.d.ts +0 -7
- package/dist/sdk/src/tools/read-files.d.ts +0 -16
- package/dist/sdk/src/tools/run-file-change-hooks.d.ts +0 -4
- package/dist/sdk/src/tools/run-terminal-command.d.ts +0 -8
- package/dist/sdk/src/types/env.d.ts +0 -30
- package/dist/sdk/src/validate-agents.d.ts +0 -45
- 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/dist/index.mjs
CHANGED
|
@@ -7191,7 +7191,7 @@ var require_uri_all = __commonJS((exports2, module) => {
|
|
|
7191
7191
|
target.fragment = relative2.fragment;
|
|
7192
7192
|
return target;
|
|
7193
7193
|
}
|
|
7194
|
-
function
|
|
7194
|
+
function resolve3(baseURI, relativeURI, options) {
|
|
7195
7195
|
var schemelessOptions = assign({ scheme: "null" }, options);
|
|
7196
7196
|
return serialize(resolveComponents(parse2(baseURI, schemelessOptions), parse2(relativeURI, schemelessOptions), schemelessOptions, true), schemelessOptions);
|
|
7197
7197
|
}
|
|
@@ -7459,7 +7459,7 @@ var require_uri_all = __commonJS((exports2, module) => {
|
|
|
7459
7459
|
exports3.removeDotSegments = removeDotSegments;
|
|
7460
7460
|
exports3.serialize = serialize;
|
|
7461
7461
|
exports3.resolveComponents = resolveComponents;
|
|
7462
|
-
exports3.resolve =
|
|
7462
|
+
exports3.resolve = resolve3;
|
|
7463
7463
|
exports3.normalize = normalize2;
|
|
7464
7464
|
exports3.equal = equal;
|
|
7465
7465
|
exports3.escapeComponent = escapeComponent;
|
|
@@ -7825,20 +7825,20 @@ var require_resolve = __commonJS((exports2, module) => {
|
|
|
7825
7825
|
var util = require_util();
|
|
7826
7826
|
var SchemaObject = require_schema_obj();
|
|
7827
7827
|
var traverse = require_json_schema_traverse();
|
|
7828
|
-
module.exports =
|
|
7829
|
-
|
|
7830
|
-
|
|
7831
|
-
|
|
7832
|
-
|
|
7833
|
-
|
|
7834
|
-
|
|
7835
|
-
function
|
|
7828
|
+
module.exports = resolve3;
|
|
7829
|
+
resolve3.normalizeId = normalizeId;
|
|
7830
|
+
resolve3.fullPath = getFullPath;
|
|
7831
|
+
resolve3.url = resolveUrl;
|
|
7832
|
+
resolve3.ids = resolveIds;
|
|
7833
|
+
resolve3.inlineRef = inlineRef;
|
|
7834
|
+
resolve3.schema = resolveSchema;
|
|
7835
|
+
function resolve3(compile, root, ref) {
|
|
7836
7836
|
var refVal = this._refs[ref];
|
|
7837
7837
|
if (typeof refVal == "string") {
|
|
7838
7838
|
if (this._refs[refVal])
|
|
7839
7839
|
refVal = this._refs[refVal];
|
|
7840
7840
|
else
|
|
7841
|
-
return
|
|
7841
|
+
return resolve3.call(this, compile, root, refVal);
|
|
7842
7842
|
}
|
|
7843
7843
|
refVal = refVal || this._schemas[ref];
|
|
7844
7844
|
if (refVal instanceof SchemaObject) {
|
|
@@ -8061,7 +8061,7 @@ var require_resolve = __commonJS((exports2, module) => {
|
|
|
8061
8061
|
|
|
8062
8062
|
// ../node_modules/ajv/lib/compile/error_classes.js
|
|
8063
8063
|
var require_error_classes = __commonJS((exports2, module) => {
|
|
8064
|
-
var
|
|
8064
|
+
var resolve3 = require_resolve();
|
|
8065
8065
|
module.exports = {
|
|
8066
8066
|
Validation: errorSubclass(ValidationError),
|
|
8067
8067
|
MissingRef: errorSubclass(MissingRefError)
|
|
@@ -8076,8 +8076,8 @@ var require_error_classes = __commonJS((exports2, module) => {
|
|
|
8076
8076
|
};
|
|
8077
8077
|
function MissingRefError(baseId, ref, message) {
|
|
8078
8078
|
this.message = message || MissingRefError.message(baseId, ref);
|
|
8079
|
-
this.missingRef =
|
|
8080
|
-
this.missingSchema =
|
|
8079
|
+
this.missingRef = resolve3.url(baseId, ref);
|
|
8080
|
+
this.missingSchema = resolve3.normalizeId(resolve3.fullPath(this.missingRef));
|
|
8081
8081
|
}
|
|
8082
8082
|
function errorSubclass(Subclass) {
|
|
8083
8083
|
Subclass.prototype = Object.create(Error.prototype);
|
|
@@ -8619,7 +8619,7 @@ var require_validate = __commonJS((exports2, module) => {
|
|
|
8619
8619
|
|
|
8620
8620
|
// ../node_modules/ajv/lib/compile/index.js
|
|
8621
8621
|
var require_compile = __commonJS((exports2, module) => {
|
|
8622
|
-
var
|
|
8622
|
+
var resolve3 = require_resolve();
|
|
8623
8623
|
var util = require_util();
|
|
8624
8624
|
var errorClasses = require_error_classes();
|
|
8625
8625
|
var stableStringify = require_fast_json_stable_stringify();
|
|
@@ -8679,7 +8679,7 @@ var require_compile = __commonJS((exports2, module) => {
|
|
|
8679
8679
|
RULES,
|
|
8680
8680
|
validate: validateGenerator,
|
|
8681
8681
|
util,
|
|
8682
|
-
resolve:
|
|
8682
|
+
resolve: resolve3,
|
|
8683
8683
|
resolveRef,
|
|
8684
8684
|
usePattern,
|
|
8685
8685
|
useDefault,
|
|
@@ -8718,7 +8718,7 @@ var require_compile = __commonJS((exports2, module) => {
|
|
|
8718
8718
|
return validate;
|
|
8719
8719
|
}
|
|
8720
8720
|
function resolveRef(baseId2, ref, isRoot) {
|
|
8721
|
-
ref =
|
|
8721
|
+
ref = resolve3.url(baseId2, ref);
|
|
8722
8722
|
var refIndex = refs[ref];
|
|
8723
8723
|
var _refVal, refCode;
|
|
8724
8724
|
if (refIndex !== undefined) {
|
|
@@ -8735,11 +8735,11 @@ var require_compile = __commonJS((exports2, module) => {
|
|
|
8735
8735
|
}
|
|
8736
8736
|
}
|
|
8737
8737
|
refCode = addLocalRef(ref);
|
|
8738
|
-
var v2 =
|
|
8738
|
+
var v2 = resolve3.call(self2, localCompile, root, ref);
|
|
8739
8739
|
if (v2 === undefined) {
|
|
8740
8740
|
var localSchema = localRefs && localRefs[ref];
|
|
8741
8741
|
if (localSchema) {
|
|
8742
|
-
v2 =
|
|
8742
|
+
v2 = resolve3.inlineRef(localSchema, opts.inlineRefs) ? localSchema : compile.call(self2, localSchema, root, localRefs, baseId2);
|
|
8743
8743
|
}
|
|
8744
8744
|
}
|
|
8745
8745
|
if (v2 === undefined) {
|
|
@@ -12256,7 +12256,7 @@ var require_data2 = __commonJS((exports2, module) => {
|
|
|
12256
12256
|
// ../node_modules/ajv/lib/ajv.js
|
|
12257
12257
|
var require_ajv = __commonJS((exports2, module) => {
|
|
12258
12258
|
var compileSchema = require_compile();
|
|
12259
|
-
var
|
|
12259
|
+
var resolve3 = require_resolve();
|
|
12260
12260
|
var Cache = require_cache();
|
|
12261
12261
|
var SchemaObject = require_schema_obj();
|
|
12262
12262
|
var stableStringify = require_fast_json_stable_stringify();
|
|
@@ -12348,7 +12348,7 @@ var require_ajv = __commonJS((exports2, module) => {
|
|
|
12348
12348
|
var id = this._getId(schema);
|
|
12349
12349
|
if (id !== undefined && typeof id != "string")
|
|
12350
12350
|
throw new Error("schema id must be string");
|
|
12351
|
-
key =
|
|
12351
|
+
key = resolve3.normalizeId(key || id);
|
|
12352
12352
|
checkUnique(this, key);
|
|
12353
12353
|
this._schemas[key] = this._addSchema(schema, _skipValidation, _meta, true);
|
|
12354
12354
|
return this;
|
|
@@ -12394,7 +12394,7 @@ var require_ajv = __commonJS((exports2, module) => {
|
|
|
12394
12394
|
}
|
|
12395
12395
|
}
|
|
12396
12396
|
function _getSchemaFragment(self2, ref) {
|
|
12397
|
-
var res =
|
|
12397
|
+
var res = resolve3.schema.call(self2, { schema: {} }, ref);
|
|
12398
12398
|
if (res) {
|
|
12399
12399
|
var { schema, root, baseId } = res;
|
|
12400
12400
|
var v = compileSchema.call(self2, schema, root, undefined, baseId);
|
|
@@ -12410,7 +12410,7 @@ var require_ajv = __commonJS((exports2, module) => {
|
|
|
12410
12410
|
}
|
|
12411
12411
|
}
|
|
12412
12412
|
function _getSchemaObj(self2, keyRef) {
|
|
12413
|
-
keyRef =
|
|
12413
|
+
keyRef = resolve3.normalizeId(keyRef);
|
|
12414
12414
|
return self2._schemas[keyRef] || self2._refs[keyRef] || self2._fragments[keyRef];
|
|
12415
12415
|
}
|
|
12416
12416
|
function removeSchema(schemaKeyRef) {
|
|
@@ -12438,7 +12438,7 @@ var require_ajv = __commonJS((exports2, module) => {
|
|
|
12438
12438
|
this._cache.del(cacheKey);
|
|
12439
12439
|
var id = this._getId(schemaKeyRef);
|
|
12440
12440
|
if (id) {
|
|
12441
|
-
id =
|
|
12441
|
+
id = resolve3.normalizeId(id);
|
|
12442
12442
|
delete this._schemas[id];
|
|
12443
12443
|
delete this._refs[id];
|
|
12444
12444
|
}
|
|
@@ -12463,14 +12463,14 @@ var require_ajv = __commonJS((exports2, module) => {
|
|
|
12463
12463
|
if (cached)
|
|
12464
12464
|
return cached;
|
|
12465
12465
|
shouldAddSchema = shouldAddSchema || this._opts.addUsedSchema !== false;
|
|
12466
|
-
var id =
|
|
12466
|
+
var id = resolve3.normalizeId(this._getId(schema));
|
|
12467
12467
|
if (id && shouldAddSchema)
|
|
12468
12468
|
checkUnique(this, id);
|
|
12469
12469
|
var willValidate = this._opts.validateSchema !== false && !skipValidation;
|
|
12470
12470
|
var recursiveMeta;
|
|
12471
|
-
if (willValidate && !(recursiveMeta = id && id ==
|
|
12471
|
+
if (willValidate && !(recursiveMeta = id && id == resolve3.normalizeId(schema.$schema)))
|
|
12472
12472
|
this.validateSchema(schema, true);
|
|
12473
|
-
var localRefs =
|
|
12473
|
+
var localRefs = resolve3.ids.call(this, schema);
|
|
12474
12474
|
var schemaObj = new SchemaObject({
|
|
12475
12475
|
id,
|
|
12476
12476
|
schema,
|
|
@@ -12635,7 +12635,7 @@ var require_ajv = __commonJS((exports2, module) => {
|
|
|
12635
12635
|
var require_windows = __commonJS((exports2, module) => {
|
|
12636
12636
|
module.exports = isexe;
|
|
12637
12637
|
isexe.sync = sync;
|
|
12638
|
-
var
|
|
12638
|
+
var fs7 = __require("fs");
|
|
12639
12639
|
function checkPathExt(path7, options) {
|
|
12640
12640
|
var pathext = options.pathExt !== undefined ? options.pathExt : process.env.PATHEXT;
|
|
12641
12641
|
if (!pathext) {
|
|
@@ -12660,12 +12660,12 @@ var require_windows = __commonJS((exports2, module) => {
|
|
|
12660
12660
|
return checkPathExt(path7, options);
|
|
12661
12661
|
}
|
|
12662
12662
|
function isexe(path7, options, cb) {
|
|
12663
|
-
|
|
12663
|
+
fs7.stat(path7, function(er, stat) {
|
|
12664
12664
|
cb(er, er ? false : checkStat(stat, path7, options));
|
|
12665
12665
|
});
|
|
12666
12666
|
}
|
|
12667
12667
|
function sync(path7, options) {
|
|
12668
|
-
return checkStat(
|
|
12668
|
+
return checkStat(fs7.statSync(path7), path7, options);
|
|
12669
12669
|
}
|
|
12670
12670
|
});
|
|
12671
12671
|
|
|
@@ -12673,14 +12673,14 @@ var require_windows = __commonJS((exports2, module) => {
|
|
|
12673
12673
|
var require_mode = __commonJS((exports2, module) => {
|
|
12674
12674
|
module.exports = isexe;
|
|
12675
12675
|
isexe.sync = sync;
|
|
12676
|
-
var
|
|
12676
|
+
var fs7 = __require("fs");
|
|
12677
12677
|
function isexe(path7, options, cb) {
|
|
12678
|
-
|
|
12678
|
+
fs7.stat(path7, function(er, stat) {
|
|
12679
12679
|
cb(er, er ? false : checkStat(stat, options));
|
|
12680
12680
|
});
|
|
12681
12681
|
}
|
|
12682
12682
|
function sync(path7, options) {
|
|
12683
|
-
return checkStat(
|
|
12683
|
+
return checkStat(fs7.statSync(path7), options);
|
|
12684
12684
|
}
|
|
12685
12685
|
function checkStat(stat, options) {
|
|
12686
12686
|
return stat.isFile() && checkMode(stat, options);
|
|
@@ -12702,7 +12702,7 @@ var require_mode = __commonJS((exports2, module) => {
|
|
|
12702
12702
|
|
|
12703
12703
|
// ../node_modules/isexe/index.js
|
|
12704
12704
|
var require_isexe = __commonJS((exports2, module) => {
|
|
12705
|
-
var
|
|
12705
|
+
var fs7 = __require("fs");
|
|
12706
12706
|
var core;
|
|
12707
12707
|
if (process.platform === "win32" || global.TESTING_WINDOWS) {
|
|
12708
12708
|
core = require_windows();
|
|
@@ -12720,12 +12720,12 @@ var require_isexe = __commonJS((exports2, module) => {
|
|
|
12720
12720
|
if (typeof Promise !== "function") {
|
|
12721
12721
|
throw new TypeError("callback not provided");
|
|
12722
12722
|
}
|
|
12723
|
-
return new Promise(function(
|
|
12723
|
+
return new Promise(function(resolve3, reject) {
|
|
12724
12724
|
isexe(path7, options || {}, function(er, is) {
|
|
12725
12725
|
if (er) {
|
|
12726
12726
|
reject(er);
|
|
12727
12727
|
} else {
|
|
12728
|
-
|
|
12728
|
+
resolve3(is);
|
|
12729
12729
|
}
|
|
12730
12730
|
});
|
|
12731
12731
|
});
|
|
@@ -12787,27 +12787,27 @@ var require_which = __commonJS((exports2, module) => {
|
|
|
12787
12787
|
opt = {};
|
|
12788
12788
|
const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
|
|
12789
12789
|
const found = [];
|
|
12790
|
-
const step = (i) => new Promise((
|
|
12790
|
+
const step = (i) => new Promise((resolve3, reject) => {
|
|
12791
12791
|
if (i === pathEnv.length)
|
|
12792
|
-
return opt.all && found.length ?
|
|
12792
|
+
return opt.all && found.length ? resolve3(found) : reject(getNotFoundError(cmd));
|
|
12793
12793
|
const ppRaw = pathEnv[i];
|
|
12794
12794
|
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
12795
12795
|
const pCmd = path7.join(pathPart, cmd);
|
|
12796
12796
|
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
12797
|
-
|
|
12797
|
+
resolve3(subStep(p, i, 0));
|
|
12798
12798
|
});
|
|
12799
|
-
const subStep = (p, i, ii) => new Promise((
|
|
12799
|
+
const subStep = (p, i, ii) => new Promise((resolve3, reject) => {
|
|
12800
12800
|
if (ii === pathExt.length)
|
|
12801
|
-
return
|
|
12801
|
+
return resolve3(step(i + 1));
|
|
12802
12802
|
const ext = pathExt[ii];
|
|
12803
12803
|
isexe(p + ext, { pathExt: pathExtExe }, (er, is) => {
|
|
12804
12804
|
if (!er && is) {
|
|
12805
12805
|
if (opt.all)
|
|
12806
12806
|
found.push(p + ext);
|
|
12807
12807
|
else
|
|
12808
|
-
return
|
|
12808
|
+
return resolve3(p + ext);
|
|
12809
12809
|
}
|
|
12810
|
-
return
|
|
12810
|
+
return resolve3(subStep(p, i, ii + 1));
|
|
12811
12811
|
});
|
|
12812
12812
|
});
|
|
12813
12813
|
return cb ? step(0).then((res) => cb(null, res), cb) : step(0);
|
|
@@ -12941,16 +12941,16 @@ var require_shebang_command = __commonJS((exports2, module) => {
|
|
|
12941
12941
|
|
|
12942
12942
|
// ../node_modules/cross-spawn/lib/util/readShebang.js
|
|
12943
12943
|
var require_readShebang = __commonJS((exports2, module) => {
|
|
12944
|
-
var
|
|
12944
|
+
var fs7 = __require("fs");
|
|
12945
12945
|
var shebangCommand = require_shebang_command();
|
|
12946
12946
|
function readShebang(command) {
|
|
12947
12947
|
const size = 150;
|
|
12948
12948
|
const buffer = Buffer.alloc(size);
|
|
12949
12949
|
let fd;
|
|
12950
12950
|
try {
|
|
12951
|
-
fd =
|
|
12952
|
-
|
|
12953
|
-
|
|
12951
|
+
fd = fs7.openSync(command, "r");
|
|
12952
|
+
fs7.readSync(fd, buffer, 0, size, 0);
|
|
12953
|
+
fs7.closeSync(fd);
|
|
12954
12954
|
} catch (e) {}
|
|
12955
12955
|
return shebangCommand(buffer.toString());
|
|
12956
12956
|
}
|
|
@@ -16927,7 +16927,7 @@ import { z as z2 } from "zod/v4";
|
|
|
16927
16927
|
// ../common/src/constants/agents.ts
|
|
16928
16928
|
var AGENT_PERSONAS = {
|
|
16929
16929
|
base: {
|
|
16930
|
-
displayName: "
|
|
16930
|
+
displayName: "Sage the Base Agent",
|
|
16931
16931
|
purpose: "Base agent that orchestrates the full response."
|
|
16932
16932
|
},
|
|
16933
16933
|
ask: {
|
|
@@ -17151,17 +17151,17 @@ var devPhaseSchema = z3.enum([
|
|
|
17151
17151
|
]);
|
|
17152
17152
|
var teamMemberSchema = z3.object({
|
|
17153
17153
|
agentId: z3.string(),
|
|
17154
|
-
name: z3.string(),
|
|
17154
|
+
name: z3.string().min(1).max(100).regex(/^[a-zA-Z0-9_-]+$/, "Agent name may only contain letters, numbers, hyphens, and underscores"),
|
|
17155
17155
|
role: teamRoleSchema,
|
|
17156
17156
|
agentType: z3.string(),
|
|
17157
17157
|
model: z3.string(),
|
|
17158
17158
|
joinedAt: z3.number(),
|
|
17159
|
-
status: z3.enum(["active", "idle", "completed", "failed"]),
|
|
17159
|
+
status: z3.enum(["active", "idle", "working", "blocked", "completed", "failed"]),
|
|
17160
17160
|
currentTaskId: z3.string().optional(),
|
|
17161
17161
|
cwd: z3.string()
|
|
17162
17162
|
});
|
|
17163
17163
|
var teamConfigSchema = z3.object({
|
|
17164
|
-
name: z3.string(),
|
|
17164
|
+
name: z3.string().min(1).max(50).regex(/^[a-zA-Z0-9_-]+$/, "Team name may only contain letters, numbers, hyphens, and underscores"),
|
|
17165
17165
|
description: z3.string(),
|
|
17166
17166
|
createdAt: z3.number(),
|
|
17167
17167
|
leadAgentId: z3.string(),
|
|
@@ -17173,7 +17173,7 @@ var teamConfigSchema = z3.object({
|
|
|
17173
17173
|
})
|
|
17174
17174
|
});
|
|
17175
17175
|
var teamTaskSchema = z3.object({
|
|
17176
|
-
id: z3.string(),
|
|
17176
|
+
id: z3.string().regex(/^[0-9]+$/, "Task ID must be numeric"),
|
|
17177
17177
|
subject: z3.string(),
|
|
17178
17178
|
description: z3.string(),
|
|
17179
17179
|
status: z3.enum(["pending", "in_progress", "completed", "blocked"]),
|
|
@@ -17263,6 +17263,48 @@ var teamProtocolMessageSchema = z3.discriminatedUnion("type", [
|
|
|
17263
17263
|
|
|
17264
17264
|
// ../common/src/utils/team-fs.ts
|
|
17265
17265
|
import { z as z4 } from "zod";
|
|
17266
|
+
var TEAM_NAME_RE = /^[a-zA-Z0-9_-]+$/;
|
|
17267
|
+
var TEAM_NAME_MAX = 50;
|
|
17268
|
+
var AGENT_NAME_RE = /^[a-zA-Z0-9_-]+$/;
|
|
17269
|
+
var AGENT_NAME_MAX = 100;
|
|
17270
|
+
var TASK_ID_RE = /^[0-9]+$/;
|
|
17271
|
+
function validateTeamName(teamName) {
|
|
17272
|
+
if (!teamName || typeof teamName !== "string") {
|
|
17273
|
+
throw new Error("Team name is required and must be a string.");
|
|
17274
|
+
}
|
|
17275
|
+
if (teamName.length > TEAM_NAME_MAX) {
|
|
17276
|
+
throw new Error(`Team name must be at most ${TEAM_NAME_MAX} characters.`);
|
|
17277
|
+
}
|
|
17278
|
+
if (!TEAM_NAME_RE.test(teamName)) {
|
|
17279
|
+
throw new Error("Team name may only contain letters, numbers, hyphens, and underscores.");
|
|
17280
|
+
}
|
|
17281
|
+
}
|
|
17282
|
+
function validateAgentName(agentName) {
|
|
17283
|
+
if (!agentName || typeof agentName !== "string") {
|
|
17284
|
+
throw new Error("Agent name is required and must be a string.");
|
|
17285
|
+
}
|
|
17286
|
+
if (agentName.length > AGENT_NAME_MAX) {
|
|
17287
|
+
throw new Error(`Agent name must be at most ${AGENT_NAME_MAX} characters.`);
|
|
17288
|
+
}
|
|
17289
|
+
if (!AGENT_NAME_RE.test(agentName)) {
|
|
17290
|
+
throw new Error("Agent name may only contain letters, numbers, hyphens, and underscores.");
|
|
17291
|
+
}
|
|
17292
|
+
}
|
|
17293
|
+
function validateTaskId(taskId) {
|
|
17294
|
+
if (!taskId || typeof taskId !== "string") {
|
|
17295
|
+
throw new Error("Task ID is required and must be a string.");
|
|
17296
|
+
}
|
|
17297
|
+
if (!TASK_ID_RE.test(taskId)) {
|
|
17298
|
+
throw new Error("Task ID must be numeric.");
|
|
17299
|
+
}
|
|
17300
|
+
}
|
|
17301
|
+
function assertPathContained(resolvedPath, expectedParent) {
|
|
17302
|
+
const normalizedPath = path2.resolve(resolvedPath);
|
|
17303
|
+
const normalizedParent = path2.resolve(expectedParent);
|
|
17304
|
+
if (!normalizedPath.startsWith(normalizedParent + path2.sep) && normalizedPath !== normalizedParent) {
|
|
17305
|
+
throw new Error("Path traversal detected: resolved path escapes the expected directory.");
|
|
17306
|
+
}
|
|
17307
|
+
}
|
|
17266
17308
|
function getConfigRoot() {
|
|
17267
17309
|
return path2.join(os.homedir(), ".config", "levelcode");
|
|
17268
17310
|
}
|
|
@@ -17270,10 +17312,16 @@ function getTeamsDir() {
|
|
|
17270
17312
|
return path2.join(getConfigRoot(), "teams");
|
|
17271
17313
|
}
|
|
17272
17314
|
function getTasksDir(teamName) {
|
|
17273
|
-
|
|
17315
|
+
validateTeamName(teamName);
|
|
17316
|
+
const tasksDir = path2.join(getConfigRoot(), "tasks", teamName);
|
|
17317
|
+
assertPathContained(tasksDir, path2.join(getConfigRoot(), "tasks"));
|
|
17318
|
+
return tasksDir;
|
|
17274
17319
|
}
|
|
17275
17320
|
function getTeamDir(teamName) {
|
|
17276
|
-
|
|
17321
|
+
validateTeamName(teamName);
|
|
17322
|
+
const teamDir = path2.join(getTeamsDir(), teamName);
|
|
17323
|
+
assertPathContained(teamDir, getTeamsDir());
|
|
17324
|
+
return teamDir;
|
|
17277
17325
|
}
|
|
17278
17326
|
function getTeamConfigPath(teamName) {
|
|
17279
17327
|
return path2.join(getTeamDir(teamName), "config.json");
|
|
@@ -17282,10 +17330,16 @@ function getInboxesDir(teamName) {
|
|
|
17282
17330
|
return path2.join(getTeamDir(teamName), "inboxes");
|
|
17283
17331
|
}
|
|
17284
17332
|
function getInboxPath(teamName, agentName) {
|
|
17285
|
-
|
|
17333
|
+
validateAgentName(agentName);
|
|
17334
|
+
const inboxPath = path2.join(getInboxesDir(teamName), `${agentName}.json`);
|
|
17335
|
+
assertPathContained(inboxPath, getInboxesDir(teamName));
|
|
17336
|
+
return inboxPath;
|
|
17286
17337
|
}
|
|
17287
17338
|
function getTaskPath(teamName, taskId) {
|
|
17288
|
-
|
|
17339
|
+
validateTaskId(taskId);
|
|
17340
|
+
const taskPath = path2.join(getTasksDir(teamName), `${taskId}.json`);
|
|
17341
|
+
assertPathContained(taskPath, getTasksDir(teamName));
|
|
17342
|
+
return taskPath;
|
|
17289
17343
|
}
|
|
17290
17344
|
function createTeam(config) {
|
|
17291
17345
|
const teamDir = getTeamDir(config.name);
|
|
@@ -17784,7 +17838,7 @@ var callLevelCodeV1 = async (params2) => {
|
|
|
17784
17838
|
maxRetries: MAX_RETRIES,
|
|
17785
17839
|
nextRetryDelayMs: delay
|
|
17786
17840
|
}, `Web API ${requestName} request failed with retryable status, retrying...`);
|
|
17787
|
-
await new Promise((
|
|
17841
|
+
await new Promise((resolve2) => setTimeout(resolve2, delay));
|
|
17788
17842
|
lastError = err;
|
|
17789
17843
|
continue;
|
|
17790
17844
|
}
|
|
@@ -17808,7 +17862,7 @@ var callLevelCodeV1 = async (params2) => {
|
|
|
17808
17862
|
maxRetries: MAX_RETRIES,
|
|
17809
17863
|
nextRetryDelayMs: delay
|
|
17810
17864
|
}, `Web API ${requestName} network error, retrying...`);
|
|
17811
|
-
await new Promise((
|
|
17865
|
+
await new Promise((resolve2) => setTimeout(resolve2, delay));
|
|
17812
17866
|
continue;
|
|
17813
17867
|
}
|
|
17814
17868
|
logger2.error({
|
|
@@ -22030,16 +22084,16 @@ var coordinator = {
|
|
|
22030
22084
|
"ask_user",
|
|
22031
22085
|
"set_output",
|
|
22032
22086
|
"suggest_followups",
|
|
22033
|
-
"
|
|
22034
|
-
"
|
|
22035
|
-
"
|
|
22036
|
-
"
|
|
22037
|
-
"
|
|
22038
|
-
"
|
|
22039
|
-
"
|
|
22087
|
+
"team_create",
|
|
22088
|
+
"team_delete",
|
|
22089
|
+
"send_message",
|
|
22090
|
+
"task_create",
|
|
22091
|
+
"task_get",
|
|
22092
|
+
"task_update",
|
|
22093
|
+
"task_list"
|
|
22040
22094
|
],
|
|
22041
22095
|
spawnableAgents: [
|
|
22042
|
-
"manager",
|
|
22096
|
+
"team-manager",
|
|
22043
22097
|
"senior-engineer",
|
|
22044
22098
|
"commander",
|
|
22045
22099
|
"file-picker",
|
|
@@ -22059,7 +22113,7 @@ You lead a team of specialized agents. Your job is to:
|
|
|
22059
22113
|
2. Spawn and assign work to manager and senior-engineer agents.
|
|
22060
22114
|
3. Manage phase transitions (planning -> pre-alpha -> alpha -> beta -> production -> mature).
|
|
22061
22115
|
4. Review and approve plans submitted by managers before implementation begins.
|
|
22062
|
-
5. Monitor progress via
|
|
22116
|
+
5. Monitor progress via task_list / task_get and unblock stuck agents.
|
|
22063
22117
|
6. Communicate decisions and status to the user and to team members.
|
|
22064
22118
|
|
|
22065
22119
|
# Phase Management
|
|
@@ -22075,8 +22129,8 @@ Only advance one phase at a time. Confirm readiness before transitioning.
|
|
|
22075
22129
|
|
|
22076
22130
|
# Coordination Rules
|
|
22077
22131
|
|
|
22078
|
-
- Always create tasks (
|
|
22079
|
-
- Use
|
|
22132
|
+
- Always create tasks (task_create) before assigning work so progress is tracked.
|
|
22133
|
+
- Use send_message to communicate with individual team members. Reserve broadcasts for critical announcements.
|
|
22080
22134
|
- When a manager submits a plan for approval, review it carefully. Approve only if the plan is complete, feasible, and aligned with the objective.
|
|
22081
22135
|
- Spawn managers for large work streams. Spawn senior-engineers directly for focused, well-scoped tasks.
|
|
22082
22136
|
- Sequence dependent work: do not spawn agents in parallel if their outputs depend on each other.
|
|
@@ -22098,9 +22152,9 @@ Only advance one phase at a time. Confirm readiness before transitioning.
|
|
|
22098
22152
|
instructionsPrompt: `Orchestrate the team to complete the user's objective. Follow these steps:
|
|
22099
22153
|
|
|
22100
22154
|
1. **Understand the objective**: Read relevant files and gather context. Spawn researchers if needed.
|
|
22101
|
-
2. **Plan**: Use
|
|
22155
|
+
2. **Plan**: Use task_create to break the work into trackable tasks. Use write_todos for your own step-by-step plan.
|
|
22102
22156
|
3. **Delegate**: Spawn manager agents for large work streams or senior-engineer agents for focused tasks. Provide clear prompts with the task context.
|
|
22103
|
-
4. **Monitor**: Use
|
|
22157
|
+
4. **Monitor**: Use task_list and task_get to track progress. Unblock stuck agents by providing guidance via send_message.
|
|
22104
22158
|
5. **Review**: When agents complete work, verify quality. Spawn code reviewers or commanders to typecheck/test.
|
|
22105
22159
|
6. **Advance phases**: When current phase goals are met, transition to the next phase.
|
|
22106
22160
|
7. **Report**: Summarize what was accomplished to the user. Use suggest_followups for next steps.
|
|
@@ -22160,16 +22214,16 @@ var cto = {
|
|
|
22160
22214
|
"glob",
|
|
22161
22215
|
"list_directory",
|
|
22162
22216
|
"think_deeply",
|
|
22163
|
-
"
|
|
22164
|
-
"
|
|
22165
|
-
"
|
|
22166
|
-
"
|
|
22167
|
-
"
|
|
22168
|
-
"
|
|
22169
|
-
"
|
|
22217
|
+
"team_create",
|
|
22218
|
+
"team_delete",
|
|
22219
|
+
"send_message",
|
|
22220
|
+
"task_create",
|
|
22221
|
+
"task_get",
|
|
22222
|
+
"task_update",
|
|
22223
|
+
"task_list"
|
|
22170
22224
|
],
|
|
22171
22225
|
spawnableAgents: [
|
|
22172
|
-
"manager",
|
|
22226
|
+
"team-manager",
|
|
22173
22227
|
"senior-engineer",
|
|
22174
22228
|
"commander",
|
|
22175
22229
|
"file-picker",
|
|
@@ -22222,7 +22276,7 @@ When making technical decisions:
|
|
|
22222
22276
|
2. **Analyze strategically**: Spawn a thinker to reason through the strategic implications. Consider both short-term execution and long-term trajectory.
|
|
22223
22277
|
3. **Evaluate options**: For technology or architectural decisions, research alternatives. Use web_search and read_docs to evaluate external options.
|
|
22224
22278
|
4. **Make decisions**: Apply the decision framework. Document criteria, options, tradeoffs, and your reasoning.
|
|
22225
|
-
5. **Plan execution**: Use write_todos and
|
|
22279
|
+
5. **Plan execution**: Use write_todos and task_create to break the strategy into actionable work. Assign work to appropriate teams.
|
|
22226
22280
|
6. **Communicate**: Summarize decisions and their rationale. Use suggest_followups for next steps. Report to the coordinator.
|
|
22227
22281
|
|
|
22228
22282
|
Focus on strategic impact and organizational effectiveness, not implementation details.`,
|
|
@@ -22278,16 +22332,16 @@ var vpEngineering = {
|
|
|
22278
22332
|
"glob",
|
|
22279
22333
|
"list_directory",
|
|
22280
22334
|
"think_deeply",
|
|
22281
|
-
"
|
|
22282
|
-
"
|
|
22283
|
-
"
|
|
22284
|
-
"
|
|
22285
|
-
"
|
|
22286
|
-
"
|
|
22287
|
-
"
|
|
22335
|
+
"team_create",
|
|
22336
|
+
"team_delete",
|
|
22337
|
+
"send_message",
|
|
22338
|
+
"task_create",
|
|
22339
|
+
"task_get",
|
|
22340
|
+
"task_update",
|
|
22341
|
+
"task_list"
|
|
22288
22342
|
],
|
|
22289
22343
|
spawnableAgents: [
|
|
22290
|
-
"manager",
|
|
22344
|
+
"team-manager",
|
|
22291
22345
|
"senior-engineer",
|
|
22292
22346
|
"commander",
|
|
22293
22347
|
"file-picker",
|
|
@@ -22327,9 +22381,9 @@ You are the VP of Engineering responsible for:
|
|
|
22327
22381
|
|
|
22328
22382
|
1. **Assess the situation**: Read relevant files and spawn researchers to understand the current state of engineering operations, team structure, and delivery status.
|
|
22329
22383
|
2. **Analyze**: Spawn a thinker to reason through the organizational and process implications. Identify root causes of any issues.
|
|
22330
|
-
3. **Plan**: Use write_todos and
|
|
22331
|
-
4. **Organize**: Spawn managers for work streams that need coordination. Use
|
|
22332
|
-
5. **Track and communicate**: Use
|
|
22384
|
+
3. **Plan**: Use write_todos and task_create to create an actionable plan. Define clear milestones and ownership.
|
|
22385
|
+
4. **Organize**: Spawn managers for work streams that need coordination. Use team_create for new teams if needed.
|
|
22386
|
+
5. **Track and communicate**: Use task_list and task_get to monitor progress. Send updates via send_message. Report status to the coordinator.
|
|
22333
22387
|
6. **Report**: Summarize the plan, decisions, and expected outcomes. Use suggest_followups for next steps.
|
|
22334
22388
|
|
|
22335
22389
|
Focus on enabling the team to deliver effectively rather than on implementation details.`,
|
|
@@ -22385,16 +22439,16 @@ var director = {
|
|
|
22385
22439
|
"glob",
|
|
22386
22440
|
"list_directory",
|
|
22387
22441
|
"think_deeply",
|
|
22388
|
-
"
|
|
22389
|
-
"
|
|
22390
|
-
"
|
|
22391
|
-
"
|
|
22392
|
-
"
|
|
22393
|
-
"
|
|
22394
|
-
"
|
|
22442
|
+
"team_create",
|
|
22443
|
+
"team_delete",
|
|
22444
|
+
"send_message",
|
|
22445
|
+
"task_create",
|
|
22446
|
+
"task_get",
|
|
22447
|
+
"task_update",
|
|
22448
|
+
"task_list"
|
|
22395
22449
|
],
|
|
22396
22450
|
spawnableAgents: [
|
|
22397
|
-
"manager",
|
|
22451
|
+
"team-manager",
|
|
22398
22452
|
"senior-engineer",
|
|
22399
22453
|
"commander",
|
|
22400
22454
|
"file-picker",
|
|
@@ -22432,11 +22486,11 @@ You are a director responsible for:
|
|
|
22432
22486
|
- Escalate decisions that require user input via ask_user.`,
|
|
22433
22487
|
instructionsPrompt: `Address the assigned coordination or strategic planning challenge. Follow these steps:
|
|
22434
22488
|
|
|
22435
|
-
1. **Assess**: Read relevant files and review the current state of all involved teams via
|
|
22489
|
+
1. **Assess**: Read relevant files and review the current state of all involved teams via task_list. Understand what each team is working on and where they stand.
|
|
22436
22490
|
2. **Analyze dependencies**: Spawn a thinker to reason through cross-team dependencies and potential conflicts. Identify the critical path.
|
|
22437
|
-
3. **Plan**: Use write_todos and
|
|
22438
|
-
4. **Coordinate**: Spawn managers for each workstream. Use
|
|
22439
|
-
5. **Monitor**: Track progress via
|
|
22491
|
+
3. **Plan**: Use write_todos and task_create to create a cross-team plan. Define milestones, dependencies, and ownership.
|
|
22492
|
+
4. **Coordinate**: Spawn managers for each workstream. Use send_message to communicate priorities and constraints. Use team_create for new teams if needed.
|
|
22493
|
+
5. **Monitor**: Track progress via task_list and task_get. Identify blockers and resolve them.
|
|
22440
22494
|
6. **Report**: Summarize the plan, team assignments, timeline, and risks. Use suggest_followups for next steps. Report to the coordinator.
|
|
22441
22495
|
|
|
22442
22496
|
Focus on cross-team coordination and delivery, not individual implementation details.`,
|
|
@@ -23044,7 +23098,7 @@ var manager = {
|
|
|
23044
23098
|
],
|
|
23045
23099
|
spawnableAgents: [
|
|
23046
23100
|
"senior-engineer",
|
|
23047
|
-
"mid-level-engineer"
|
|
23101
|
+
"team-mid-level-engineer"
|
|
23048
23102
|
],
|
|
23049
23103
|
systemPrompt: `You are a Manager Agent responsible for overseeing a group of engineers within a LevelCode swarm team.
|
|
23050
23104
|
|
|
@@ -23157,8 +23211,8 @@ var subManager = {
|
|
|
23157
23211
|
"set_output"
|
|
23158
23212
|
],
|
|
23159
23213
|
spawnableAgents: [
|
|
23160
|
-
"mid-level-engineer",
|
|
23161
|
-
"junior-engineer",
|
|
23214
|
+
"team-mid-level-engineer",
|
|
23215
|
+
"team-junior-engineer",
|
|
23162
23216
|
"file-picker",
|
|
23163
23217
|
"code-searcher",
|
|
23164
23218
|
"directory-lister",
|
|
@@ -31454,7 +31508,7 @@ Note: The file tree has been truncated to show a subset of files to fit within t
|
|
|
31454
31508
|
return `
|
|
31455
31509
|
# Project file tree
|
|
31456
31510
|
|
|
31457
|
-
As
|
|
31511
|
+
As Sage, you have access to all the files in the project.
|
|
31458
31512
|
|
|
31459
31513
|
The following is the path to the project on the user's computer. It is also the current working directory for terminal commands:
|
|
31460
31514
|
<project_path>
|
|
@@ -33311,7 +33365,7 @@ var handleTaskCompleted = async ({
|
|
|
33311
33365
|
completedTaskId = task.id;
|
|
33312
33366
|
taskSummary = `Task #${task.id} "${task.subject}" completed by ${agentName}.`;
|
|
33313
33367
|
try {
|
|
33314
|
-
updateTask(teamName, task.id, { status: "completed" });
|
|
33368
|
+
await updateTask(teamName, task.id, { status: "completed" });
|
|
33315
33369
|
} catch (error) {
|
|
33316
33370
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
33317
33371
|
logger2.warn?.(`Failed to mark task ${task.id} as completed: ${errorMessage}`);
|
|
@@ -33585,6 +33639,11 @@ function findCurrentTeamAndAgent(agentId) {
|
|
|
33585
33639
|
return null;
|
|
33586
33640
|
}
|
|
33587
33641
|
function findTeamByName(name) {
|
|
33642
|
+
try {
|
|
33643
|
+
validateTeamName(name);
|
|
33644
|
+
} catch {
|
|
33645
|
+
return null;
|
|
33646
|
+
}
|
|
33588
33647
|
return safeLoadTeamConfig(name);
|
|
33589
33648
|
}
|
|
33590
33649
|
function listAllTeams() {
|
|
@@ -33834,34 +33893,11 @@ var handleSendMessage = async (params2) => {
|
|
|
33834
33893
|
};
|
|
33835
33894
|
|
|
33836
33895
|
// ../packages/agent-runtime/src/tools/handlers/tool/task-create.ts
|
|
33837
|
-
import * as fs6 from "fs";
|
|
33838
33896
|
function errorResult2(message) {
|
|
33839
33897
|
return { output: jsonToolResult({ error: message }) };
|
|
33840
33898
|
}
|
|
33841
|
-
function getActiveTeamName2() {
|
|
33842
|
-
let teamsDir;
|
|
33843
|
-
try {
|
|
33844
|
-
teamsDir = getTeamsDir();
|
|
33845
|
-
} catch {
|
|
33846
|
-
return null;
|
|
33847
|
-
}
|
|
33848
|
-
if (!fs6.existsSync(teamsDir)) {
|
|
33849
|
-
return null;
|
|
33850
|
-
}
|
|
33851
|
-
let entries;
|
|
33852
|
-
try {
|
|
33853
|
-
entries = fs6.readdirSync(teamsDir, { withFileTypes: true });
|
|
33854
|
-
} catch {
|
|
33855
|
-
return null;
|
|
33856
|
-
}
|
|
33857
|
-
const teamDirs = entries.filter((e) => e.isDirectory());
|
|
33858
|
-
if (teamDirs.length === 0) {
|
|
33859
|
-
return null;
|
|
33860
|
-
}
|
|
33861
|
-
return teamDirs[0].name;
|
|
33862
|
-
}
|
|
33863
33899
|
var handleTaskCreate = async (params2) => {
|
|
33864
|
-
const { previousToolCallFinished, toolCall } = params2;
|
|
33900
|
+
const { previousToolCallFinished, toolCall, agentStepId: agentStepId2 } = params2;
|
|
33865
33901
|
const { subject, description: description38, activeForm, priority, metadata } = toolCall.input;
|
|
33866
33902
|
await previousToolCallFinished;
|
|
33867
33903
|
if (!subject || typeof subject !== "string" || subject.trim() === "") {
|
|
@@ -33870,10 +33906,16 @@ var handleTaskCreate = async (params2) => {
|
|
|
33870
33906
|
if (!description38 || typeof description38 !== "string" || description38.trim() === "") {
|
|
33871
33907
|
return errorResult2('A non-empty "description" is required to create a task.');
|
|
33872
33908
|
}
|
|
33873
|
-
|
|
33874
|
-
|
|
33875
|
-
|
|
33909
|
+
let teamResult;
|
|
33910
|
+
try {
|
|
33911
|
+
teamResult = findCurrentTeam(agentStepId2);
|
|
33912
|
+
} catch {
|
|
33913
|
+
return errorResult2("Failed to look up team for the current agent. The teams directory may be inaccessible.");
|
|
33876
33914
|
}
|
|
33915
|
+
if (!teamResult) {
|
|
33916
|
+
return errorResult2("No active team found. Create a team first using team_create.");
|
|
33917
|
+
}
|
|
33918
|
+
const teamName = teamResult.teamName;
|
|
33877
33919
|
let existingTasks;
|
|
33878
33920
|
try {
|
|
33879
33921
|
existingTasks = listTasks(teamName);
|
|
@@ -33915,43 +33957,29 @@ var handleTaskCreate = async (params2) => {
|
|
|
33915
33957
|
};
|
|
33916
33958
|
|
|
33917
33959
|
// ../packages/agent-runtime/src/tools/handlers/tool/task-get.ts
|
|
33918
|
-
import * as fs7 from "fs";
|
|
33919
33960
|
function errorResult3(message) {
|
|
33920
33961
|
return { output: jsonToolResult({ error: message }) };
|
|
33921
33962
|
}
|
|
33922
|
-
function getActiveTeamName3() {
|
|
33923
|
-
let teamsDir;
|
|
33924
|
-
try {
|
|
33925
|
-
teamsDir = getTeamsDir();
|
|
33926
|
-
} catch {
|
|
33927
|
-
return null;
|
|
33928
|
-
}
|
|
33929
|
-
if (!fs7.existsSync(teamsDir)) {
|
|
33930
|
-
return null;
|
|
33931
|
-
}
|
|
33932
|
-
let entries;
|
|
33933
|
-
try {
|
|
33934
|
-
entries = fs7.readdirSync(teamsDir, { withFileTypes: true });
|
|
33935
|
-
} catch {
|
|
33936
|
-
return null;
|
|
33937
|
-
}
|
|
33938
|
-
const teamDirs = entries.filter((e) => e.isDirectory());
|
|
33939
|
-
if (teamDirs.length === 0) {
|
|
33940
|
-
return null;
|
|
33941
|
-
}
|
|
33942
|
-
return teamDirs[0].name;
|
|
33943
|
-
}
|
|
33944
33963
|
var handleTaskGet = async (params2) => {
|
|
33945
|
-
const { previousToolCallFinished, toolCall } = params2;
|
|
33964
|
+
const { previousToolCallFinished, toolCall, agentStepId: agentStepId2 } = params2;
|
|
33946
33965
|
const { taskId } = toolCall.input;
|
|
33947
33966
|
await previousToolCallFinished;
|
|
33948
33967
|
if (!taskId || typeof taskId !== "string" || taskId.trim() === "") {
|
|
33949
33968
|
return errorResult3('A non-empty "taskId" is required.');
|
|
33950
33969
|
}
|
|
33951
|
-
|
|
33952
|
-
|
|
33953
|
-
return errorResult3("No active team found. Create a team first using TeamCreate.");
|
|
33970
|
+
if (!/^[0-9]+$/.test(taskId)) {
|
|
33971
|
+
return errorResult3("Task ID must be numeric.");
|
|
33954
33972
|
}
|
|
33973
|
+
let teamResult;
|
|
33974
|
+
try {
|
|
33975
|
+
teamResult = findCurrentTeam(agentStepId2);
|
|
33976
|
+
} catch {
|
|
33977
|
+
return errorResult3("Failed to look up team for the current agent. The teams directory may be inaccessible.");
|
|
33978
|
+
}
|
|
33979
|
+
if (!teamResult) {
|
|
33980
|
+
return errorResult3("No active team found. Create a team first using team_create.");
|
|
33981
|
+
}
|
|
33982
|
+
const teamName = teamResult.teamName;
|
|
33955
33983
|
let task;
|
|
33956
33984
|
try {
|
|
33957
33985
|
task = getTask(teamName, taskId);
|
|
@@ -33968,41 +33996,29 @@ var handleTaskGet = async (params2) => {
|
|
|
33968
33996
|
};
|
|
33969
33997
|
|
|
33970
33998
|
// ../packages/agent-runtime/src/tools/handlers/tool/task-list.ts
|
|
33971
|
-
|
|
33972
|
-
|
|
33973
|
-
|
|
33974
|
-
|
|
33975
|
-
teamsDir = getTeamsDir();
|
|
33976
|
-
} catch {
|
|
33977
|
-
return null;
|
|
33978
|
-
}
|
|
33979
|
-
if (!fs8.existsSync(teamsDir)) {
|
|
33980
|
-
return null;
|
|
33981
|
-
}
|
|
33982
|
-
let entries;
|
|
33999
|
+
var handleTaskList = async (params2) => {
|
|
34000
|
+
const { previousToolCallFinished, agentStepId: agentStepId2 } = params2;
|
|
34001
|
+
await previousToolCallFinished;
|
|
34002
|
+
let teamResult;
|
|
33983
34003
|
try {
|
|
33984
|
-
|
|
34004
|
+
teamResult = findCurrentTeam(agentStepId2);
|
|
33985
34005
|
} catch {
|
|
33986
|
-
return
|
|
33987
|
-
|
|
33988
|
-
|
|
33989
|
-
|
|
33990
|
-
|
|
34006
|
+
return {
|
|
34007
|
+
output: jsonToolResult({
|
|
34008
|
+
error: "Failed to look up team for the current agent. The teams directory may be inaccessible.",
|
|
34009
|
+
tasks: []
|
|
34010
|
+
})
|
|
34011
|
+
};
|
|
33991
34012
|
}
|
|
33992
|
-
|
|
33993
|
-
}
|
|
33994
|
-
var handleTaskList = async (params2) => {
|
|
33995
|
-
const { previousToolCallFinished } = params2;
|
|
33996
|
-
await previousToolCallFinished;
|
|
33997
|
-
const teamName = getActiveTeamName4();
|
|
33998
|
-
if (!teamName) {
|
|
34013
|
+
if (!teamResult) {
|
|
33999
34014
|
return {
|
|
34000
34015
|
output: jsonToolResult({
|
|
34001
|
-
error: "No active team found. Create a team first using
|
|
34016
|
+
error: "No active team found. Create a team first using team_create.",
|
|
34002
34017
|
tasks: []
|
|
34003
34018
|
})
|
|
34004
34019
|
};
|
|
34005
34020
|
}
|
|
34021
|
+
const teamName = teamResult.teamName;
|
|
34006
34022
|
let tasks;
|
|
34007
34023
|
try {
|
|
34008
34024
|
tasks = listTasks(teamName);
|
|
@@ -34032,36 +34048,14 @@ var handleTaskList = async (params2) => {
|
|
|
34032
34048
|
};
|
|
34033
34049
|
|
|
34034
34050
|
// ../packages/agent-runtime/src/tools/handlers/tool/task-update.ts
|
|
34035
|
-
import * as
|
|
34051
|
+
import * as fs6 from "fs";
|
|
34036
34052
|
import * as path5 from "path";
|
|
34037
34053
|
var VALID_STATUSES = ["pending", "in_progress", "completed", "blocked", "deleted"];
|
|
34038
34054
|
function errorResult4(message) {
|
|
34039
34055
|
return { output: jsonToolResult({ error: message }) };
|
|
34040
34056
|
}
|
|
34041
|
-
function getActiveTeamName5() {
|
|
34042
|
-
let teamsDir;
|
|
34043
|
-
try {
|
|
34044
|
-
teamsDir = getTeamsDir();
|
|
34045
|
-
} catch {
|
|
34046
|
-
return null;
|
|
34047
|
-
}
|
|
34048
|
-
if (!fs9.existsSync(teamsDir)) {
|
|
34049
|
-
return null;
|
|
34050
|
-
}
|
|
34051
|
-
let entries;
|
|
34052
|
-
try {
|
|
34053
|
-
entries = fs9.readdirSync(teamsDir, { withFileTypes: true });
|
|
34054
|
-
} catch {
|
|
34055
|
-
return null;
|
|
34056
|
-
}
|
|
34057
|
-
const teamDirs = entries.filter((e) => e.isDirectory());
|
|
34058
|
-
if (teamDirs.length === 0) {
|
|
34059
|
-
return null;
|
|
34060
|
-
}
|
|
34061
|
-
return teamDirs[0].name;
|
|
34062
|
-
}
|
|
34063
34057
|
var handleTaskUpdate = async (params2) => {
|
|
34064
|
-
const { previousToolCallFinished, toolCall, trackEvent: trackEvent2, userId, logger: logger2 } = params2;
|
|
34058
|
+
const { previousToolCallFinished, toolCall, agentStepId: agentStepId2, trackEvent: trackEvent2, userId, logger: logger2 } = params2;
|
|
34065
34059
|
const {
|
|
34066
34060
|
taskId,
|
|
34067
34061
|
status,
|
|
@@ -34078,13 +34072,22 @@ var handleTaskUpdate = async (params2) => {
|
|
|
34078
34072
|
if (!taskId || typeof taskId !== "string" || taskId.trim() === "") {
|
|
34079
34073
|
return errorResult4('A non-empty "taskId" is required.');
|
|
34080
34074
|
}
|
|
34075
|
+
if (!/^[0-9]+$/.test(taskId)) {
|
|
34076
|
+
return errorResult4("Task ID must be numeric.");
|
|
34077
|
+
}
|
|
34081
34078
|
if (status !== undefined && !VALID_STATUSES.includes(status)) {
|
|
34082
34079
|
return errorResult4(`Invalid status "${status}". Expected one of: ${VALID_STATUSES.join(", ")}`);
|
|
34083
34080
|
}
|
|
34084
|
-
|
|
34085
|
-
|
|
34086
|
-
|
|
34081
|
+
let teamResult;
|
|
34082
|
+
try {
|
|
34083
|
+
teamResult = findCurrentTeam(agentStepId2);
|
|
34084
|
+
} catch {
|
|
34085
|
+
return errorResult4("Failed to look up team for the current agent. The teams directory may be inaccessible.");
|
|
34087
34086
|
}
|
|
34087
|
+
if (!teamResult) {
|
|
34088
|
+
return errorResult4("No active team found. Create a team first using team_create.");
|
|
34089
|
+
}
|
|
34090
|
+
const teamName = teamResult.teamName;
|
|
34088
34091
|
let existingTask;
|
|
34089
34092
|
try {
|
|
34090
34093
|
existingTask = getTask(teamName, taskId);
|
|
@@ -34098,8 +34101,8 @@ var handleTaskUpdate = async (params2) => {
|
|
|
34098
34101
|
if (status === "deleted") {
|
|
34099
34102
|
try {
|
|
34100
34103
|
const taskPath = path5.join(getTasksDir(teamName), `${taskId}.json`);
|
|
34101
|
-
if (
|
|
34102
|
-
|
|
34104
|
+
if (fs6.existsSync(taskPath)) {
|
|
34105
|
+
fs6.unlinkSync(taskPath);
|
|
34103
34106
|
}
|
|
34104
34107
|
} catch (error) {
|
|
34105
34108
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
@@ -34195,6 +34198,9 @@ var handleTeamCreate = async (params2) => {
|
|
|
34195
34198
|
if (!/^[a-zA-Z0-9_-]+$/.test(team_name)) {
|
|
34196
34199
|
return errorResult5(`Invalid team name "${team_name}". Team names may only contain letters, numbers, hyphens, and underscores.`);
|
|
34197
34200
|
}
|
|
34201
|
+
if (team_name.length > 50) {
|
|
34202
|
+
return errorResult5("Team name must be at most 50 characters.");
|
|
34203
|
+
}
|
|
34198
34204
|
try {
|
|
34199
34205
|
const existing = loadTeamConfig(team_name);
|
|
34200
34206
|
if (existing) {
|
|
@@ -35289,7 +35295,7 @@ async function formatPrompt(params2) {
|
|
|
35289
35295
|
localAgentTemplates: agentTemplates
|
|
35290
35296
|
}) : null;
|
|
35291
35297
|
const toInject = {
|
|
35292
|
-
[PLACEHOLDER2.AGENT_NAME]: () => agentTemplate ? agentTemplate.displayName || "Unknown Agent" : "
|
|
35298
|
+
[PLACEHOLDER2.AGENT_NAME]: () => agentTemplate ? agentTemplate.displayName || "Unknown Agent" : "Sage",
|
|
35293
35299
|
[PLACEHOLDER2.FILE_TREE_PROMPT_SMALL]: () => getProjectFileTreePrompt({
|
|
35294
35300
|
fileContext,
|
|
35295
35301
|
fileTreeTokenBudget: 2500,
|
|
@@ -37404,7 +37410,7 @@ class Protocol {
|
|
|
37404
37410
|
}
|
|
37405
37411
|
request(request, resultSchema, options) {
|
|
37406
37412
|
const { relatedRequestId, resumptionToken, onresumptiontoken } = options !== null && options !== undefined ? options : {};
|
|
37407
|
-
return new Promise((
|
|
37413
|
+
return new Promise((resolve3, reject) => {
|
|
37408
37414
|
var _a, _b, _c, _d, _e, _f;
|
|
37409
37415
|
if (!this._transport) {
|
|
37410
37416
|
reject(new Error("Not connected"));
|
|
@@ -37455,7 +37461,7 @@ class Protocol {
|
|
|
37455
37461
|
}
|
|
37456
37462
|
try {
|
|
37457
37463
|
const result = resultSchema.parse(response.result);
|
|
37458
|
-
|
|
37464
|
+
resolve3(result);
|
|
37459
37465
|
} catch (error) {
|
|
37460
37466
|
reject(error);
|
|
37461
37467
|
}
|
|
@@ -38859,7 +38865,7 @@ class SSEClientTransport {
|
|
|
38859
38865
|
_startOrAuth() {
|
|
38860
38866
|
var _a, _b, _c;
|
|
38861
38867
|
const fetchImpl = (_c = (_b = (_a = this === null || this === undefined ? undefined : this._eventSourceInit) === null || _a === undefined ? undefined : _a.fetch) !== null && _b !== undefined ? _b : this._fetch) !== null && _c !== undefined ? _c : fetch;
|
|
38862
|
-
return new Promise((
|
|
38868
|
+
return new Promise((resolve3, reject) => {
|
|
38863
38869
|
this._eventSource = new EventSource(this._url.href, {
|
|
38864
38870
|
...this._eventSourceInit,
|
|
38865
38871
|
fetch: async (url, init) => {
|
|
@@ -38879,7 +38885,7 @@ class SSEClientTransport {
|
|
|
38879
38885
|
this._eventSource.onerror = (event) => {
|
|
38880
38886
|
var _a2;
|
|
38881
38887
|
if (event.code === 401 && this._authProvider) {
|
|
38882
|
-
this._authThenStart().then(
|
|
38888
|
+
this._authThenStart().then(resolve3, reject);
|
|
38883
38889
|
return;
|
|
38884
38890
|
}
|
|
38885
38891
|
const error = new SseError(event.code, event.message, event);
|
|
@@ -38901,7 +38907,7 @@ class SSEClientTransport {
|
|
|
38901
38907
|
this.close();
|
|
38902
38908
|
return;
|
|
38903
38909
|
}
|
|
38904
|
-
|
|
38910
|
+
resolve3();
|
|
38905
38911
|
});
|
|
38906
38912
|
this._eventSource.onmessage = (event) => {
|
|
38907
38913
|
var _a2, _b2;
|
|
@@ -39064,7 +39070,7 @@ class StdioClientTransport {
|
|
|
39064
39070
|
if (this._process) {
|
|
39065
39071
|
throw new Error("StdioClientTransport already started! If using Client class, note that connect() calls start() automatically.");
|
|
39066
39072
|
}
|
|
39067
|
-
return new Promise((
|
|
39073
|
+
return new Promise((resolve3, reject) => {
|
|
39068
39074
|
var _a, _b, _c, _d, _e;
|
|
39069
39075
|
this._process = import_cross_spawn.default(this._serverParams.command, (_a = this._serverParams.args) !== null && _a !== undefined ? _a : [], {
|
|
39070
39076
|
env: {
|
|
@@ -39087,7 +39093,7 @@ class StdioClientTransport {
|
|
|
39087
39093
|
(_b2 = this.onerror) === null || _b2 === undefined || _b2.call(this, error);
|
|
39088
39094
|
});
|
|
39089
39095
|
this._process.on("spawn", () => {
|
|
39090
|
-
|
|
39096
|
+
resolve3();
|
|
39091
39097
|
});
|
|
39092
39098
|
this._process.on("close", (_code) => {
|
|
39093
39099
|
var _a2;
|
|
@@ -39142,16 +39148,16 @@ class StdioClientTransport {
|
|
|
39142
39148
|
this._readBuffer.clear();
|
|
39143
39149
|
}
|
|
39144
39150
|
send(message) {
|
|
39145
|
-
return new Promise((
|
|
39151
|
+
return new Promise((resolve3) => {
|
|
39146
39152
|
var _a;
|
|
39147
39153
|
if (!((_a = this._process) === null || _a === undefined ? undefined : _a.stdin)) {
|
|
39148
39154
|
throw new Error("Not connected");
|
|
39149
39155
|
}
|
|
39150
39156
|
const json = serializeMessage(message);
|
|
39151
39157
|
if (this._process.stdin.write(json)) {
|
|
39152
|
-
|
|
39158
|
+
resolve3();
|
|
39153
39159
|
} else {
|
|
39154
|
-
this._process.stdin.once("drain",
|
|
39160
|
+
this._process.stdin.once("drain", resolve3);
|
|
39155
39161
|
}
|
|
39156
39162
|
});
|
|
39157
39163
|
}
|
|
@@ -39904,7 +39910,7 @@ async function fetchWithRetry(url, options, logger2) {
|
|
|
39904
39910
|
}
|
|
39905
39911
|
if (attempt < MAX_RETRIES_PER_MESSAGE) {
|
|
39906
39912
|
logger2?.warn({ status: response.status, attempt: attempt + 1, url: String(url) }, `Retryable HTTP error, retrying in ${backoffDelay}ms`);
|
|
39907
|
-
await new Promise((
|
|
39913
|
+
await new Promise((resolve3) => setTimeout(resolve3, backoffDelay));
|
|
39908
39914
|
backoffDelay = Math.min(backoffDelay * 2, RETRY_BACKOFF_MAX_DELAY_MS);
|
|
39909
39915
|
} else {
|
|
39910
39916
|
return response;
|
|
@@ -39913,7 +39919,7 @@ async function fetchWithRetry(url, options, logger2) {
|
|
|
39913
39919
|
lastError = error instanceof Error ? error : new Error(String(error));
|
|
39914
39920
|
if (attempt < MAX_RETRIES_PER_MESSAGE) {
|
|
39915
39921
|
logger2?.warn({ error: getErrorObject(lastError), attempt: attempt + 1, url: String(url) }, `Network error, retrying in ${backoffDelay}ms`);
|
|
39916
|
-
await new Promise((
|
|
39922
|
+
await new Promise((resolve3) => setTimeout(resolve3, backoffDelay));
|
|
39917
39923
|
backoffDelay = Math.min(backoffDelay * 2, RETRY_BACKOFF_MAX_DELAY_MS);
|
|
39918
39924
|
}
|
|
39919
39925
|
}
|
|
@@ -43120,7 +43126,7 @@ var openrouter = createOpenRouter({
|
|
|
43120
43126
|
});
|
|
43121
43127
|
|
|
43122
43128
|
// src/credentials.ts
|
|
43123
|
-
import
|
|
43129
|
+
import fs7 from "fs";
|
|
43124
43130
|
import path7 from "node:path";
|
|
43125
43131
|
import os3 from "os";
|
|
43126
43132
|
|
|
@@ -43148,8 +43154,8 @@ var credentialsFileSchema = z87.object({
|
|
|
43148
43154
|
claudeOAuth: claudeOAuthSchema.optional()
|
|
43149
43155
|
});
|
|
43150
43156
|
var ensureDirectoryExistsSync = (dir) => {
|
|
43151
|
-
if (!
|
|
43152
|
-
|
|
43157
|
+
if (!fs7.existsSync(dir)) {
|
|
43158
|
+
fs7.mkdirSync(dir, { recursive: true });
|
|
43153
43159
|
}
|
|
43154
43160
|
};
|
|
43155
43161
|
var userFromJson = (json) => {
|
|
@@ -43171,14 +43177,14 @@ var getConfigDir = (clientEnv = env) => {
|
|
|
43171
43177
|
var migrateFromLegacyConfigDir = (clientEnv = env) => {
|
|
43172
43178
|
const newDir = getConfigDir(clientEnv);
|
|
43173
43179
|
const newCredsPath = path7.join(newDir, "credentials.json");
|
|
43174
|
-
if (
|
|
43180
|
+
if (fs7.existsSync(newCredsPath))
|
|
43175
43181
|
return;
|
|
43176
43182
|
const legacyCredsPath = path7.join(getLegacyConfigDir(clientEnv), "credentials.json");
|
|
43177
|
-
if (!
|
|
43183
|
+
if (!fs7.existsSync(legacyCredsPath))
|
|
43178
43184
|
return;
|
|
43179
43185
|
try {
|
|
43180
43186
|
ensureDirectoryExistsSync(newDir);
|
|
43181
|
-
|
|
43187
|
+
fs7.copyFileSync(legacyCredsPath, newCredsPath);
|
|
43182
43188
|
} catch {}
|
|
43183
43189
|
};
|
|
43184
43190
|
var getCredentialsPath = (clientEnv = env) => {
|
|
@@ -43187,11 +43193,11 @@ var getCredentialsPath = (clientEnv = env) => {
|
|
|
43187
43193
|
};
|
|
43188
43194
|
var getUserCredentials = (clientEnv = env) => {
|
|
43189
43195
|
const credentialsPath = getCredentialsPath(clientEnv);
|
|
43190
|
-
if (!
|
|
43196
|
+
if (!fs7.existsSync(credentialsPath)) {
|
|
43191
43197
|
return null;
|
|
43192
43198
|
}
|
|
43193
43199
|
try {
|
|
43194
|
-
const credentialsFile =
|
|
43200
|
+
const credentialsFile = fs7.readFileSync(credentialsPath, "utf8");
|
|
43195
43201
|
const user = userFromJson(credentialsFile);
|
|
43196
43202
|
return user || null;
|
|
43197
43203
|
} catch (error) {
|
|
@@ -43210,11 +43216,11 @@ var getClaudeOAuthCredentials = (clientEnv = env) => {
|
|
|
43210
43216
|
};
|
|
43211
43217
|
}
|
|
43212
43218
|
const credentialsPath = getCredentialsPath(clientEnv);
|
|
43213
|
-
if (!
|
|
43219
|
+
if (!fs7.existsSync(credentialsPath)) {
|
|
43214
43220
|
return null;
|
|
43215
43221
|
}
|
|
43216
43222
|
try {
|
|
43217
|
-
const credentialsFile =
|
|
43223
|
+
const credentialsFile = fs7.readFileSync(credentialsPath, "utf8");
|
|
43218
43224
|
const parsed = credentialsFileSchema.safeParse(JSON.parse(credentialsFile));
|
|
43219
43225
|
if (!parsed.success || !parsed.data.claudeOAuth) {
|
|
43220
43226
|
return null;
|
|
@@ -43230,26 +43236,26 @@ var saveClaudeOAuthCredentials = (credentials, clientEnv = env) => {
|
|
|
43230
43236
|
const credentialsPath = getCredentialsPath(clientEnv);
|
|
43231
43237
|
ensureDirectoryExistsSync(configDir);
|
|
43232
43238
|
let existingData = {};
|
|
43233
|
-
if (
|
|
43239
|
+
if (fs7.existsSync(credentialsPath)) {
|
|
43234
43240
|
try {
|
|
43235
|
-
existingData = JSON.parse(
|
|
43241
|
+
existingData = JSON.parse(fs7.readFileSync(credentialsPath, "utf8"));
|
|
43236
43242
|
} catch {}
|
|
43237
43243
|
}
|
|
43238
43244
|
const updatedData = {
|
|
43239
43245
|
...existingData,
|
|
43240
43246
|
claudeOAuth: credentials
|
|
43241
43247
|
};
|
|
43242
|
-
|
|
43248
|
+
fs7.writeFileSync(credentialsPath, JSON.stringify(updatedData, null, 2));
|
|
43243
43249
|
};
|
|
43244
43250
|
var clearClaudeOAuthCredentials = (clientEnv = env) => {
|
|
43245
43251
|
const credentialsPath = getCredentialsPath(clientEnv);
|
|
43246
|
-
if (!
|
|
43252
|
+
if (!fs7.existsSync(credentialsPath)) {
|
|
43247
43253
|
return;
|
|
43248
43254
|
}
|
|
43249
43255
|
try {
|
|
43250
|
-
const existingData = JSON.parse(
|
|
43256
|
+
const existingData = JSON.parse(fs7.readFileSync(credentialsPath, "utf8"));
|
|
43251
43257
|
delete existingData.claudeOAuth;
|
|
43252
|
-
|
|
43258
|
+
fs7.writeFileSync(credentialsPath, JSON.stringify(existingData, null, 2));
|
|
43253
43259
|
} catch {}
|
|
43254
43260
|
};
|
|
43255
43261
|
var isClaudeOAuthValid = (clientEnv = env) => {
|
|
@@ -43974,16 +43980,16 @@ import * as os6 from "os";
|
|
|
43974
43980
|
import path14 from "path";
|
|
43975
43981
|
|
|
43976
43982
|
// ../packages/code-map/src/parse.ts
|
|
43977
|
-
import * as
|
|
43983
|
+
import * as fs10 from "fs";
|
|
43978
43984
|
import * as path11 from "path";
|
|
43979
43985
|
|
|
43980
43986
|
// ../packages/code-map/src/languages.ts
|
|
43981
|
-
import * as
|
|
43987
|
+
import * as fs9 from "fs";
|
|
43982
43988
|
import * as path10 from "path";
|
|
43983
43989
|
import { Language, Parser as Parser2, Query } from "web-tree-sitter";
|
|
43984
43990
|
|
|
43985
43991
|
// ../packages/code-map/src/init-node.ts
|
|
43986
|
-
import * as
|
|
43992
|
+
import * as fs8 from "fs";
|
|
43987
43993
|
import * as path9 from "path";
|
|
43988
43994
|
import { Parser } from "web-tree-sitter";
|
|
43989
43995
|
async function initTreeSitterForNode() {
|
|
@@ -43991,12 +43997,12 @@ async function initTreeSitterForNode() {
|
|
|
43991
43997
|
locateFile: (name14, scriptDir) => {
|
|
43992
43998
|
if (name14 === "tree-sitter.wasm") {
|
|
43993
43999
|
const fallback = path9.join(scriptDir, name14);
|
|
43994
|
-
if (
|
|
44000
|
+
if (fs8.existsSync(fallback)) {
|
|
43995
44001
|
return fallback;
|
|
43996
44002
|
}
|
|
43997
44003
|
const pkgDir = path9.dirname(__require.resolve("web-tree-sitter"));
|
|
43998
44004
|
const wasm = path9.join(pkgDir, "tree-sitter.wasm");
|
|
43999
|
-
if (
|
|
44005
|
+
if (fs8.existsSync(wasm)) {
|
|
44000
44006
|
return wasm;
|
|
44001
44007
|
}
|
|
44002
44008
|
throw new Error(`Internal error: web-tree-sitter/tree-sitter.wasm not found at ${wasm}. Ensure the file is included in your deployment bundle.`);
|
|
@@ -44415,7 +44421,7 @@ async function createLanguageConfig(filePath, runtimeLoader) {
|
|
|
44415
44421
|
const lang = await runtimeLoader.loadLanguage(cfg.wasmFile);
|
|
44416
44422
|
const parser = new Parser2;
|
|
44417
44423
|
parser.setLanguage(lang);
|
|
44418
|
-
const queryContent = path10.isAbsolute(cfg.queryPathOrContent) ?
|
|
44424
|
+
const queryContent = path10.isAbsolute(cfg.queryPathOrContent) ? fs9.readFileSync(cfg.queryPathOrContent, "utf8") : cfg.queryPathOrContent;
|
|
44419
44425
|
cfg.language = lang;
|
|
44420
44426
|
cfg.parser = parser;
|
|
44421
44427
|
cfg.query = new Query(lang, queryContent);
|
|
@@ -44521,7 +44527,7 @@ async function getFileTokenScores(projectRoot, filePaths, readFile) {
|
|
|
44521
44527
|
const endTime = Date.now();
|
|
44522
44528
|
console.log(`Parsed ${filePaths.length} files in ${endTime - startTime2}ms`);
|
|
44523
44529
|
try {
|
|
44524
|
-
|
|
44530
|
+
fs10.writeFileSync("../debug/debug-parse.json", JSON.stringify({
|
|
44525
44531
|
tokenCallers,
|
|
44526
44532
|
tokenScores,
|
|
44527
44533
|
fileCallsMap,
|
|
@@ -44534,7 +44540,7 @@ async function getFileTokenScores(projectRoot, filePaths, readFile) {
|
|
|
44534
44540
|
function parseTokens(filePath, languageConfig, readFile) {
|
|
44535
44541
|
const { parser, query } = languageConfig;
|
|
44536
44542
|
try {
|
|
44537
|
-
const sourceCode = readFile ? readFile(filePath) :
|
|
44543
|
+
const sourceCode = readFile ? readFile(filePath) : fs10.readFileSync(filePath, "utf8");
|
|
44538
44544
|
if (sourceCode === null) {
|
|
44539
44545
|
return {
|
|
44540
44546
|
numLines: 0,
|
|
@@ -44594,7 +44600,7 @@ var import_lodash17 = __toESM(require_lodash(), 1);
|
|
|
44594
44600
|
import z89 from "zod/v4";
|
|
44595
44601
|
|
|
44596
44602
|
// src/agents/load-agents.ts
|
|
44597
|
-
import
|
|
44603
|
+
import fs11 from "fs";
|
|
44598
44604
|
import os4 from "os";
|
|
44599
44605
|
import path12 from "path";
|
|
44600
44606
|
import { pathToFileURL } from "url";
|
|
@@ -44707,7 +44713,7 @@ var agentFileExtensions = new Set([".ts", ".tsx", ".js", ".mjs", ".cjs"]);
|
|
|
44707
44713
|
var getAllAgentFiles = (dir) => {
|
|
44708
44714
|
const files = [];
|
|
44709
44715
|
try {
|
|
44710
|
-
const entries =
|
|
44716
|
+
const entries = fs11.readdirSync(dir, { withFileTypes: true });
|
|
44711
44717
|
for (const entry of entries) {
|
|
44712
44718
|
const fullPath = path12.join(dir, entry.name);
|
|
44713
44719
|
if (entry.isDirectory()) {
|
|
@@ -44815,7 +44821,7 @@ async function importAgentModule(fullPath) {
|
|
|
44815
44821
|
}
|
|
44816
44822
|
|
|
44817
44823
|
// src/skills/load-skills.ts
|
|
44818
|
-
import
|
|
44824
|
+
import fs12 from "fs";
|
|
44819
44825
|
import os5 from "os";
|
|
44820
44826
|
import path13 from "path";
|
|
44821
44827
|
|
|
@@ -44870,7 +44876,7 @@ function loadSkillFromFile(skillDir, skillFilePath, verbose) {
|
|
|
44870
44876
|
const dirName = path13.basename(skillDir);
|
|
44871
44877
|
let content;
|
|
44872
44878
|
try {
|
|
44873
|
-
content =
|
|
44879
|
+
content = fs12.readFileSync(skillFilePath, "utf8");
|
|
44874
44880
|
} catch {
|
|
44875
44881
|
if (verbose) {
|
|
44876
44882
|
console.error(`Failed to read skill file: ${skillFilePath}`);
|
|
@@ -44911,14 +44917,14 @@ function discoverSkillsFromDirectory(skillsDir, verbose) {
|
|
|
44911
44917
|
const skills = {};
|
|
44912
44918
|
let entries;
|
|
44913
44919
|
try {
|
|
44914
|
-
entries =
|
|
44920
|
+
entries = fs12.readdirSync(skillsDir);
|
|
44915
44921
|
} catch {
|
|
44916
44922
|
return skills;
|
|
44917
44923
|
}
|
|
44918
44924
|
for (const entry of entries) {
|
|
44919
44925
|
const skillDir = path13.join(skillsDir, entry);
|
|
44920
44926
|
try {
|
|
44921
|
-
const stat =
|
|
44927
|
+
const stat = fs12.statSync(skillDir);
|
|
44922
44928
|
if (!stat.isDirectory())
|
|
44923
44929
|
continue;
|
|
44924
44930
|
} catch {
|
|
@@ -44932,7 +44938,7 @@ function discoverSkillsFromDirectory(skillsDir, verbose) {
|
|
|
44932
44938
|
}
|
|
44933
44939
|
const skillFilePath = path13.join(skillDir, SKILL_FILE_NAME);
|
|
44934
44940
|
try {
|
|
44935
|
-
|
|
44941
|
+
fs12.statSync(skillFilePath);
|
|
44936
44942
|
} catch {
|
|
44937
44943
|
continue;
|
|
44938
44944
|
}
|
|
@@ -45019,7 +45025,7 @@ async function computeProjectIndex(cwd, projectFiles) {
|
|
|
45019
45025
|
return { fileTree, fileTokenScores, tokenCallers };
|
|
45020
45026
|
}
|
|
45021
45027
|
function childProcessToPromise(proc) {
|
|
45022
|
-
return new Promise((
|
|
45028
|
+
return new Promise((resolve3, reject) => {
|
|
45023
45029
|
let stdout = "";
|
|
45024
45030
|
let stderr = "";
|
|
45025
45031
|
proc.stdout?.on("data", (data) => {
|
|
@@ -45030,7 +45036,7 @@ function childProcessToPromise(proc) {
|
|
|
45030
45036
|
});
|
|
45031
45037
|
proc.on("close", (code) => {
|
|
45032
45038
|
if (code === 0) {
|
|
45033
|
-
|
|
45039
|
+
resolve3({ stdout, stderr });
|
|
45034
45040
|
} else {
|
|
45035
45041
|
reject(new Error(`Command exited with code ${code}`));
|
|
45036
45042
|
}
|
|
@@ -45066,13 +45072,13 @@ async function getGitChanges(params2) {
|
|
|
45066
45072
|
};
|
|
45067
45073
|
}
|
|
45068
45074
|
async function discoverProjectFiles(params2) {
|
|
45069
|
-
const { cwd, fs:
|
|
45070
|
-
const fileTree = await getProjectFileTree({ projectRoot: cwd, fs:
|
|
45075
|
+
const { cwd, fs: fs13, logger: logger2 } = params2;
|
|
45076
|
+
const fileTree = await getProjectFileTree({ projectRoot: cwd, fs: fs13 });
|
|
45071
45077
|
const filePaths = getAllFilePaths(fileTree);
|
|
45072
45078
|
let error;
|
|
45073
45079
|
const projectFilePromises = Object.fromEntries(filePaths.map((filePath) => [
|
|
45074
45080
|
filePath,
|
|
45075
|
-
|
|
45081
|
+
fs13.readFile(path14.join(cwd, filePath), "utf8").catch((err) => {
|
|
45076
45082
|
error = err;
|
|
45077
45083
|
return "[ERROR_READING_FILE]";
|
|
45078
45084
|
})
|
|
@@ -45087,12 +45093,12 @@ async function discoverProjectFiles(params2) {
|
|
|
45087
45093
|
return projectFilesResolved;
|
|
45088
45094
|
}
|
|
45089
45095
|
async function loadUserKnowledgeFiles(params2) {
|
|
45090
|
-
const { fs:
|
|
45096
|
+
const { fs: fs13, logger: logger2 } = params2;
|
|
45091
45097
|
const homeDir = params2.homeDir ?? os6.homedir();
|
|
45092
45098
|
const userKnowledgeFiles = {};
|
|
45093
45099
|
let entries;
|
|
45094
45100
|
try {
|
|
45095
|
-
entries = await
|
|
45101
|
+
entries = await fs13.readdir(homeDir);
|
|
45096
45102
|
} catch (error) {
|
|
45097
45103
|
logger2.debug?.({ homeDir, error: getErrorObject(error) }, "Failed to read home directory");
|
|
45098
45104
|
return userKnowledgeFiles;
|
|
@@ -45112,7 +45118,7 @@ async function loadUserKnowledgeFiles(params2) {
|
|
|
45112
45118
|
if (actualFileName) {
|
|
45113
45119
|
const filePath = path14.join(homeDir, actualFileName);
|
|
45114
45120
|
try {
|
|
45115
|
-
const content = await
|
|
45121
|
+
const content = await fs13.readFile(filePath, "utf8");
|
|
45116
45122
|
const tildeKey = `~/${actualFileName}`;
|
|
45117
45123
|
userKnowledgeFiles[tildeKey] = content;
|
|
45118
45124
|
break;
|
|
@@ -45159,7 +45165,7 @@ async function initialSessionState(params2) {
|
|
|
45159
45165
|
projectFiles,
|
|
45160
45166
|
knowledgeFiles,
|
|
45161
45167
|
userKnowledgeFiles: providedUserKnowledgeFiles,
|
|
45162
|
-
fs:
|
|
45168
|
+
fs: fs13,
|
|
45163
45169
|
spawn: spawn2,
|
|
45164
45170
|
logger: logger2
|
|
45165
45171
|
} = params2;
|
|
@@ -45169,8 +45175,8 @@ async function initialSessionState(params2) {
|
|
|
45169
45175
|
if (!customToolDefinitions) {
|
|
45170
45176
|
customToolDefinitions = [];
|
|
45171
45177
|
}
|
|
45172
|
-
if (!
|
|
45173
|
-
|
|
45178
|
+
if (!fs13) {
|
|
45179
|
+
fs13 = __require("fs").promises;
|
|
45174
45180
|
}
|
|
45175
45181
|
if (!spawn2) {
|
|
45176
45182
|
const { spawn: nodeSpawn } = __require("child_process");
|
|
@@ -45185,7 +45191,7 @@ async function initialSessionState(params2) {
|
|
|
45185
45191
|
};
|
|
45186
45192
|
}
|
|
45187
45193
|
if (projectFiles === undefined && cwd) {
|
|
45188
|
-
projectFiles = await discoverProjectFiles({ cwd, fs:
|
|
45194
|
+
projectFiles = await discoverProjectFiles({ cwd, fs: fs13, logger: logger2 });
|
|
45189
45195
|
}
|
|
45190
45196
|
if (knowledgeFiles === undefined) {
|
|
45191
45197
|
knowledgeFiles = projectFiles ? deriveKnowledgeFiles(projectFiles) : {};
|
|
@@ -45212,7 +45218,7 @@ async function initialSessionState(params2) {
|
|
|
45212
45218
|
diffCached: "",
|
|
45213
45219
|
lastCommitMessages: ""
|
|
45214
45220
|
};
|
|
45215
|
-
const homeKnowledgeFiles = await loadUserKnowledgeFiles({ fs:
|
|
45221
|
+
const homeKnowledgeFiles = await loadUserKnowledgeFiles({ fs: fs13, logger: logger2 });
|
|
45216
45222
|
const userKnowledgeFiles = {
|
|
45217
45223
|
...homeKnowledgeFiles,
|
|
45218
45224
|
...providedUserKnowledgeFiles
|
|
@@ -45254,7 +45260,7 @@ async function generateInitialRunState({
|
|
|
45254
45260
|
agentDefinitions,
|
|
45255
45261
|
customToolDefinitions,
|
|
45256
45262
|
maxAgentSteps,
|
|
45257
|
-
fs:
|
|
45263
|
+
fs: fs13
|
|
45258
45264
|
}) {
|
|
45259
45265
|
return {
|
|
45260
45266
|
sessionState: await initialSessionState({
|
|
@@ -45265,7 +45271,7 @@ async function generateInitialRunState({
|
|
|
45265
45271
|
agentDefinitions,
|
|
45266
45272
|
customToolDefinitions,
|
|
45267
45273
|
maxAgentSteps,
|
|
45268
|
-
fs:
|
|
45274
|
+
fs: fs13
|
|
45269
45275
|
}),
|
|
45270
45276
|
output: {
|
|
45271
45277
|
type: "error",
|
|
@@ -45400,7 +45406,7 @@ function containsPathTraversal(filePath) {
|
|
|
45400
45406
|
return path15.isAbsolute(normalized) || normalized.startsWith("..");
|
|
45401
45407
|
}
|
|
45402
45408
|
async function changeFile(params2) {
|
|
45403
|
-
const { parameters, cwd, fs:
|
|
45409
|
+
const { parameters, cwd, fs: fs13 } = params2;
|
|
45404
45410
|
if (containsUpwardTraversal(cwd)) {
|
|
45405
45411
|
throw new Error("cwd contains invalid path traversal");
|
|
45406
45412
|
}
|
|
@@ -45413,7 +45419,7 @@ async function changeFile(params2) {
|
|
|
45413
45419
|
const { created, modified, invalid, patchFailed } = await applyChanges({
|
|
45414
45420
|
projectRoot: cwd,
|
|
45415
45421
|
changes: [fileChange],
|
|
45416
|
-
fs:
|
|
45422
|
+
fs: fs13
|
|
45417
45423
|
});
|
|
45418
45424
|
const results = [];
|
|
45419
45425
|
for (const file of created) {
|
|
@@ -45452,7 +45458,7 @@ async function changeFile(params2) {
|
|
|
45452
45458
|
return [{ type: "json", value: results[0] }];
|
|
45453
45459
|
}
|
|
45454
45460
|
async function applyChanges(params2) {
|
|
45455
|
-
const { projectRoot, changes, fs:
|
|
45461
|
+
const { projectRoot, changes, fs: fs13 } = params2;
|
|
45456
45462
|
const created = [];
|
|
45457
45463
|
const modified = [];
|
|
45458
45464
|
const patchFailed = [];
|
|
@@ -45461,21 +45467,21 @@ async function applyChanges(params2) {
|
|
|
45461
45467
|
const { path: filePath, content, type } = change;
|
|
45462
45468
|
try {
|
|
45463
45469
|
const fullPath = path15.join(projectRoot, filePath);
|
|
45464
|
-
const exists = await fileExists({ filePath: fullPath, fs:
|
|
45470
|
+
const exists = await fileExists({ filePath: fullPath, fs: fs13 });
|
|
45465
45471
|
if (!exists) {
|
|
45466
45472
|
const dirPath = path15.dirname(fullPath);
|
|
45467
|
-
await
|
|
45473
|
+
await fs13.mkdir(dirPath, { recursive: true });
|
|
45468
45474
|
}
|
|
45469
45475
|
if (type === "file") {
|
|
45470
|
-
await
|
|
45476
|
+
await fs13.writeFile(fullPath, content);
|
|
45471
45477
|
} else {
|
|
45472
|
-
const oldContent = await
|
|
45478
|
+
const oldContent = await fs13.readFile(fullPath, "utf-8");
|
|
45473
45479
|
const newContent = applyPatch(oldContent, content);
|
|
45474
45480
|
if (newContent === false) {
|
|
45475
45481
|
patchFailed.push(filePath);
|
|
45476
45482
|
continue;
|
|
45477
45483
|
}
|
|
45478
|
-
await
|
|
45484
|
+
await fs13.writeFile(fullPath, newContent);
|
|
45479
45485
|
}
|
|
45480
45486
|
if (exists) {
|
|
45481
45487
|
modified.push(filePath);
|
|
@@ -45492,7 +45498,7 @@ async function applyChanges(params2) {
|
|
|
45492
45498
|
|
|
45493
45499
|
// src/tools/code-search.ts
|
|
45494
45500
|
import { spawn as spawn2 } from "child_process";
|
|
45495
|
-
import * as
|
|
45501
|
+
import * as fs13 from "fs";
|
|
45496
45502
|
import * as path16 from "path";
|
|
45497
45503
|
|
|
45498
45504
|
// ../common/src/util/format-code-search.ts
|
|
@@ -45552,7 +45558,7 @@ function formatCodeSearchOutput(stdout) {
|
|
|
45552
45558
|
}
|
|
45553
45559
|
|
|
45554
45560
|
// src/native/ripgrep.ts
|
|
45555
|
-
import { existsSync as
|
|
45561
|
+
import { existsSync as existsSync7 } from "fs";
|
|
45556
45562
|
import { join as join6, dirname as dirname7 } from "path";
|
|
45557
45563
|
import { fileURLToPath } from "url";
|
|
45558
45564
|
function getBundledRgPath(importMetaUrl, env2 = getSdkEnv()) {
|
|
@@ -45582,11 +45588,11 @@ function getBundledRgPath(importMetaUrl, env2 = getSdkEnv()) {
|
|
|
45582
45588
|
const currentFile = fileURLToPath(metaUrl);
|
|
45583
45589
|
const currentDir = dirname7(currentFile);
|
|
45584
45590
|
const devPath = join6(currentDir, "..", "..", "vendor", "ripgrep", platformDir, binaryName);
|
|
45585
|
-
if (
|
|
45591
|
+
if (existsSync7(devPath)) {
|
|
45586
45592
|
vendorPath = devPath;
|
|
45587
45593
|
}
|
|
45588
45594
|
const distPath = join6(currentDir, "vendor", "ripgrep", platformDir, binaryName);
|
|
45589
|
-
if (
|
|
45595
|
+
if (existsSync7(distPath)) {
|
|
45590
45596
|
vendorPath = distPath;
|
|
45591
45597
|
}
|
|
45592
45598
|
}
|
|
@@ -45594,20 +45600,20 @@ function getBundledRgPath(importMetaUrl, env2 = getSdkEnv()) {
|
|
|
45594
45600
|
const dirname8 = new Function(`try { return __dirname; } catch (e) { return undefined; }`)();
|
|
45595
45601
|
if (typeof dirname8 !== "undefined") {
|
|
45596
45602
|
const cjsPath = join6(dirname8, "..", "..", "vendor", "ripgrep", platformDir, binaryName);
|
|
45597
|
-
if (
|
|
45603
|
+
if (existsSync7(cjsPath)) {
|
|
45598
45604
|
vendorPath = cjsPath;
|
|
45599
45605
|
}
|
|
45600
45606
|
const cjsPath2 = join6(dirname8, "vendor", "ripgrep", platformDir, binaryName);
|
|
45601
|
-
if (
|
|
45607
|
+
if (existsSync7(cjsPath2)) {
|
|
45602
45608
|
vendorPath = cjsPath2;
|
|
45603
45609
|
}
|
|
45604
45610
|
}
|
|
45605
45611
|
}
|
|
45606
|
-
if (vendorPath &&
|
|
45612
|
+
if (vendorPath && existsSync7(vendorPath)) {
|
|
45607
45613
|
return vendorPath;
|
|
45608
45614
|
}
|
|
45609
45615
|
const distVendorPath = join6(process.cwd(), "node_modules", "@levelcode", "sdk", "dist", "vendor", "ripgrep", platformDir, binaryName);
|
|
45610
|
-
if (
|
|
45616
|
+
if (existsSync7(distVendorPath)) {
|
|
45611
45617
|
return distVendorPath;
|
|
45612
45618
|
}
|
|
45613
45619
|
throw new Error(`Ripgrep binary not found for ${platform}-${arch}. ` + `Expected at: ${vendorPath} or ${distVendorPath}. ` + `Please run 'npm run fetch-ripgrep' or set LEVELCODE_RG_PATH environment variable.`);
|
|
@@ -45633,12 +45639,12 @@ function codeSearch({
|
|
|
45633
45639
|
timeoutSeconds = 10,
|
|
45634
45640
|
logger: logger2
|
|
45635
45641
|
}) {
|
|
45636
|
-
return new Promise((
|
|
45642
|
+
return new Promise((resolve4) => {
|
|
45637
45643
|
let isResolved = false;
|
|
45638
45644
|
const projectRoot = path16.resolve(projectPath);
|
|
45639
45645
|
const searchCwd = cwd ? path16.resolve(projectRoot, cwd) : projectRoot;
|
|
45640
45646
|
if (!searchCwd.startsWith(projectRoot + path16.sep) && searchCwd !== projectRoot) {
|
|
45641
|
-
return
|
|
45647
|
+
return resolve4([
|
|
45642
45648
|
{
|
|
45643
45649
|
type: "json",
|
|
45644
45650
|
value: {
|
|
@@ -45650,7 +45656,7 @@ function codeSearch({
|
|
|
45650
45656
|
const flagsArray = (flags || "").split(" ").filter(Boolean).map((token) => token.replace(/^['"]|['"]$/g, ""));
|
|
45651
45657
|
const existingHiddenDirs = INCLUDED_HIDDEN_DIRS.filter((dir) => {
|
|
45652
45658
|
try {
|
|
45653
|
-
return
|
|
45659
|
+
return fs13.statSync(path16.join(searchCwd, dir)).isDirectory();
|
|
45654
45660
|
} catch {
|
|
45655
45661
|
return false;
|
|
45656
45662
|
}
|
|
@@ -45693,7 +45699,7 @@ function codeSearch({
|
|
|
45693
45699
|
clearTimeout(killTimeoutId);
|
|
45694
45700
|
killTimeoutId = null;
|
|
45695
45701
|
}
|
|
45696
|
-
|
|
45702
|
+
resolve4([{ type: "json", value: payload }]);
|
|
45697
45703
|
};
|
|
45698
45704
|
const hardKill = () => {
|
|
45699
45705
|
try {
|
|
@@ -45898,9 +45904,9 @@ ${truncatedFiles.join(`
|
|
|
45898
45904
|
// src/tools/glob.ts
|
|
45899
45905
|
import micromatch from "micromatch";
|
|
45900
45906
|
async function glob(params2) {
|
|
45901
|
-
const { pattern, projectPath, cwd, fs:
|
|
45907
|
+
const { pattern, projectPath, cwd, fs: fs14 } = params2;
|
|
45902
45908
|
try {
|
|
45903
|
-
const fileTree = await getProjectFileTree({ projectRoot: projectPath, fs:
|
|
45909
|
+
const fileTree = await getProjectFileTree({ projectRoot: projectPath, fs: fs14 });
|
|
45904
45910
|
const flattenedNodes = flattenTree(fileTree);
|
|
45905
45911
|
let allFilePaths = flattenedNodes.filter((node) => node.type === "file").map((node) => node.filePath);
|
|
45906
45912
|
if (cwd) {
|
|
@@ -45934,7 +45940,7 @@ async function glob(params2) {
|
|
|
45934
45940
|
// src/tools/list-directory.ts
|
|
45935
45941
|
import * as path17 from "path";
|
|
45936
45942
|
async function listDirectory(params2) {
|
|
45937
|
-
const { directoryPath, projectPath, fs:
|
|
45943
|
+
const { directoryPath, projectPath, fs: fs14 } = params2;
|
|
45938
45944
|
try {
|
|
45939
45945
|
const resolvedPath = path17.resolve(projectPath, directoryPath);
|
|
45940
45946
|
if (!resolvedPath.startsWith(projectPath)) {
|
|
@@ -45947,7 +45953,7 @@ async function listDirectory(params2) {
|
|
|
45947
45953
|
}
|
|
45948
45954
|
];
|
|
45949
45955
|
}
|
|
45950
|
-
const entries = await
|
|
45956
|
+
const entries = await fs14.readdir(resolvedPath, {
|
|
45951
45957
|
withFileTypes: true
|
|
45952
45958
|
});
|
|
45953
45959
|
const files = [];
|
|
@@ -45986,7 +45992,7 @@ async function listDirectory(params2) {
|
|
|
45986
45992
|
init_old_constants();
|
|
45987
45993
|
import path18, { isAbsolute as isAbsolute3 } from "path";
|
|
45988
45994
|
async function getFiles(params2) {
|
|
45989
|
-
const { filePaths, cwd, fs:
|
|
45995
|
+
const { filePaths, cwd, fs: fs14, fileFilter } = params2;
|
|
45990
45996
|
const hasCustomFilter = fileFilter !== undefined;
|
|
45991
45997
|
const result = {};
|
|
45992
45998
|
const MAX_FILE_SIZE = 1024 * 1024;
|
|
@@ -46010,7 +46016,7 @@ async function getFiles(params2) {
|
|
|
46010
46016
|
const ignored = await isFileIgnored({
|
|
46011
46017
|
filePath: relativePath,
|
|
46012
46018
|
projectRoot: cwd,
|
|
46013
|
-
fs:
|
|
46019
|
+
fs: fs14
|
|
46014
46020
|
});
|
|
46015
46021
|
if (ignored) {
|
|
46016
46022
|
result[relativePath] = FILE_READ_STATUS.IGNORED;
|
|
@@ -46018,11 +46024,11 @@ async function getFiles(params2) {
|
|
|
46018
46024
|
}
|
|
46019
46025
|
}
|
|
46020
46026
|
try {
|
|
46021
|
-
const stats = await
|
|
46027
|
+
const stats = await fs14.stat(fullPath);
|
|
46022
46028
|
if (stats.size > MAX_FILE_SIZE) {
|
|
46023
46029
|
result[relativePath] = FILE_READ_STATUS.TOO_LARGE + ` [${(stats.size / (1024 * 1024)).toFixed(2)}MB]`;
|
|
46024
46030
|
} else {
|
|
46025
|
-
const content = await
|
|
46031
|
+
const content = await fs14.readFile(fullPath, "utf8");
|
|
46026
46032
|
result[relativePath] = isExampleFile ? FILE_READ_STATUS.TEMPLATE + `
|
|
46027
46033
|
` + content : content;
|
|
46028
46034
|
}
|
|
@@ -46039,7 +46045,7 @@ async function getFiles(params2) {
|
|
|
46039
46045
|
|
|
46040
46046
|
// src/tools/run-terminal-command.ts
|
|
46041
46047
|
import { spawn as spawn3 } from "child_process";
|
|
46042
|
-
import * as
|
|
46048
|
+
import * as fs14 from "fs";
|
|
46043
46049
|
import * as os7 from "os";
|
|
46044
46050
|
import * as path19 from "path";
|
|
46045
46051
|
var COMMAND_OUTPUT_LIMIT = 50000;
|
|
@@ -46054,11 +46060,11 @@ var WSL_BASH_PATH_PATTERNS = [
|
|
|
46054
46060
|
];
|
|
46055
46061
|
function findWindowsBash(env2) {
|
|
46056
46062
|
const customPath = env2.LEVELCODE_GIT_BASH_PATH;
|
|
46057
|
-
if (customPath &&
|
|
46063
|
+
if (customPath && fs14.existsSync(customPath)) {
|
|
46058
46064
|
return customPath;
|
|
46059
46065
|
}
|
|
46060
46066
|
for (const commonPath of GIT_BASH_COMMON_PATHS) {
|
|
46061
|
-
if (
|
|
46067
|
+
if (fs14.existsSync(commonPath)) {
|
|
46062
46068
|
return commonPath;
|
|
46063
46069
|
}
|
|
46064
46070
|
}
|
|
@@ -46069,7 +46075,7 @@ function findWindowsBash(env2) {
|
|
|
46069
46075
|
const dirLower = dir.toLowerCase();
|
|
46070
46076
|
const isWslPath = WSL_BASH_PATH_PATTERNS.some((pattern) => dirLower.includes(pattern));
|
|
46071
46077
|
const bashPath = path19.join(dir, "bash.exe");
|
|
46072
|
-
if (
|
|
46078
|
+
if (fs14.existsSync(bashPath)) {
|
|
46073
46079
|
if (isWslPath) {
|
|
46074
46080
|
wslFallbackPaths.push(bashPath);
|
|
46075
46081
|
} else {
|
|
@@ -46077,7 +46083,7 @@ function findWindowsBash(env2) {
|
|
|
46077
46083
|
}
|
|
46078
46084
|
}
|
|
46079
46085
|
const bashPathNoExt = path19.join(dir, "bash");
|
|
46080
|
-
if (
|
|
46086
|
+
if (fs14.existsSync(bashPathNoExt)) {
|
|
46081
46087
|
if (isWslPath) {
|
|
46082
46088
|
wslFallbackPaths.push(bashPathNoExt);
|
|
46083
46089
|
} else {
|
|
@@ -46116,7 +46122,7 @@ function runTerminalCommand({
|
|
|
46116
46122
|
if (process_type === "BACKGROUND") {
|
|
46117
46123
|
throw new Error("BACKGROUND process_type not implemented");
|
|
46118
46124
|
}
|
|
46119
|
-
return new Promise((
|
|
46125
|
+
return new Promise((resolve6, reject) => {
|
|
46120
46126
|
const isWindows = os7.platform() === "win32";
|
|
46121
46127
|
const processEnv2 = {
|
|
46122
46128
|
...getSystemProcessEnv(),
|
|
@@ -46187,7 +46193,7 @@ function runTerminalCommand({
|
|
|
46187
46193
|
...truncatedStderr ? { stderr: truncatedStderr } : {},
|
|
46188
46194
|
...exitCode !== null ? { exitCode } : {}
|
|
46189
46195
|
};
|
|
46190
|
-
|
|
46196
|
+
resolve6([{ type: "json", value: combinedOutput }]);
|
|
46191
46197
|
});
|
|
46192
46198
|
childProcess.on("error", (error) => {
|
|
46193
46199
|
if (processFinished)
|
|
@@ -46257,7 +46263,7 @@ async function runOnce({
|
|
|
46257
46263
|
costMode
|
|
46258
46264
|
}) {
|
|
46259
46265
|
const fsSourceValue = typeof fsSource === "function" ? fsSource() : fsSource;
|
|
46260
|
-
const
|
|
46266
|
+
const fs15 = await fsSourceValue;
|
|
46261
46267
|
let spawn4;
|
|
46262
46268
|
if (spawnSource) {
|
|
46263
46269
|
const spawnSourceValue = await spawnSource;
|
|
@@ -46291,15 +46297,15 @@ async function runOnce({
|
|
|
46291
46297
|
customToolDefinitions,
|
|
46292
46298
|
projectFiles,
|
|
46293
46299
|
maxAgentSteps,
|
|
46294
|
-
fs:
|
|
46300
|
+
fs: fs15,
|
|
46295
46301
|
spawn: spawn4,
|
|
46296
46302
|
logger: logger2
|
|
46297
46303
|
});
|
|
46298
46304
|
}
|
|
46299
|
-
let
|
|
46305
|
+
let resolve6 = () => {};
|
|
46300
46306
|
let _reject = () => {};
|
|
46301
46307
|
const promise = new Promise((res, rej) => {
|
|
46302
|
-
|
|
46308
|
+
resolve6 = res;
|
|
46303
46309
|
_reject = rej;
|
|
46304
46310
|
});
|
|
46305
46311
|
async function onError(error) {
|
|
@@ -46390,7 +46396,7 @@ async function runOnce({
|
|
|
46390
46396
|
overrides: overrideTools ?? {},
|
|
46391
46397
|
customToolDefinitions: customToolDefinitions ? Object.fromEntries(customToolDefinitions.map((def) => [def.toolName, def])) : {},
|
|
46392
46398
|
cwd,
|
|
46393
|
-
fs:
|
|
46399
|
+
fs: fs15,
|
|
46394
46400
|
env: env2
|
|
46395
46401
|
});
|
|
46396
46402
|
},
|
|
@@ -46416,7 +46422,7 @@ async function runOnce({
|
|
|
46416
46422
|
override: overrideTools?.read_files,
|
|
46417
46423
|
fileFilter,
|
|
46418
46424
|
cwd,
|
|
46419
|
-
fs:
|
|
46425
|
+
fs: fs15
|
|
46420
46426
|
}),
|
|
46421
46427
|
requestOptionalFile: async ({ filePath }) => {
|
|
46422
46428
|
const files = await readFiles({
|
|
@@ -46424,7 +46430,7 @@ async function runOnce({
|
|
|
46424
46430
|
override: overrideTools?.read_files,
|
|
46425
46431
|
fileFilter,
|
|
46426
46432
|
cwd,
|
|
46427
|
-
fs:
|
|
46433
|
+
fs: fs15
|
|
46428
46434
|
});
|
|
46429
46435
|
return toOptionalFile(files[filePath] ?? null);
|
|
46430
46436
|
},
|
|
@@ -46444,7 +46450,7 @@ async function runOnce({
|
|
|
46444
46450
|
if (action.type === "prompt-response") {
|
|
46445
46451
|
handlePromptResponse({
|
|
46446
46452
|
action,
|
|
46447
|
-
resolve:
|
|
46453
|
+
resolve: resolve6,
|
|
46448
46454
|
onError,
|
|
46449
46455
|
initialSessionState: sessionState,
|
|
46450
46456
|
signal,
|
|
@@ -46455,7 +46461,7 @@ async function runOnce({
|
|
|
46455
46461
|
if (action.type === "prompt-error") {
|
|
46456
46462
|
handlePromptResponse({
|
|
46457
46463
|
action,
|
|
46458
|
-
resolve:
|
|
46464
|
+
resolve: resolve6,
|
|
46459
46465
|
onError,
|
|
46460
46466
|
initialSessionState: sessionState,
|
|
46461
46467
|
signal,
|
|
@@ -46519,7 +46525,7 @@ async function runOnce({
|
|
|
46519
46525
|
}).catch((error) => {
|
|
46520
46526
|
const errorMessage = error instanceof Error ? error.message : String(error ?? "");
|
|
46521
46527
|
const statusCode = getErrorStatusCode(error);
|
|
46522
|
-
|
|
46528
|
+
resolve6({
|
|
46523
46529
|
sessionState: getCancelledSessionState(errorMessage),
|
|
46524
46530
|
output: {
|
|
46525
46531
|
type: "error",
|
|
@@ -46541,19 +46547,19 @@ async function readFiles({
|
|
|
46541
46547
|
override,
|
|
46542
46548
|
fileFilter,
|
|
46543
46549
|
cwd,
|
|
46544
|
-
fs:
|
|
46550
|
+
fs: fs15
|
|
46545
46551
|
}) {
|
|
46546
46552
|
if (override) {
|
|
46547
46553
|
return await override({ filePaths });
|
|
46548
46554
|
}
|
|
46549
|
-
return getFiles({ filePaths, cwd: requireCwd(cwd, "read_files"), fs:
|
|
46555
|
+
return getFiles({ filePaths, cwd: requireCwd(cwd, "read_files"), fs: fs15, fileFilter });
|
|
46550
46556
|
}
|
|
46551
46557
|
async function handleToolCall({
|
|
46552
46558
|
action,
|
|
46553
46559
|
overrides,
|
|
46554
46560
|
customToolDefinitions,
|
|
46555
46561
|
cwd,
|
|
46556
|
-
fs:
|
|
46562
|
+
fs: fs15,
|
|
46557
46563
|
env: env2
|
|
46558
46564
|
}) {
|
|
46559
46565
|
const toolName39 = action.toolName;
|
|
@@ -46604,7 +46610,7 @@ async function handleToolCall({
|
|
|
46604
46610
|
result = await changeFile({
|
|
46605
46611
|
parameters: input,
|
|
46606
46612
|
cwd: requireCwd(cwd, toolName39),
|
|
46607
|
-
fs:
|
|
46613
|
+
fs: fs15
|
|
46608
46614
|
});
|
|
46609
46615
|
} else if (toolName39 === "run_terminal_command") {
|
|
46610
46616
|
const resolvedCwd = requireCwd(cwd, "run_terminal_command");
|
|
@@ -46622,14 +46628,14 @@ async function handleToolCall({
|
|
|
46622
46628
|
result = await listDirectory({
|
|
46623
46629
|
directoryPath: input.path,
|
|
46624
46630
|
projectPath: requireCwd(cwd, "list_directory"),
|
|
46625
|
-
fs:
|
|
46631
|
+
fs: fs15
|
|
46626
46632
|
});
|
|
46627
46633
|
} else if (toolName39 === "glob") {
|
|
46628
46634
|
result = await glob({
|
|
46629
46635
|
pattern: input.pattern,
|
|
46630
46636
|
projectPath: requireCwd(cwd, "glob"),
|
|
46631
46637
|
cwd: input.cwd,
|
|
46632
|
-
fs:
|
|
46638
|
+
fs: fs15
|
|
46633
46639
|
});
|
|
46634
46640
|
} else if (toolName39 === "run_file_change_hooks") {
|
|
46635
46641
|
result = [
|
|
@@ -46715,7 +46721,7 @@ var extractStatusCodeFromMessage = (errorMessage) => {
|
|
|
46715
46721
|
};
|
|
46716
46722
|
async function handlePromptResponse({
|
|
46717
46723
|
action,
|
|
46718
|
-
resolve:
|
|
46724
|
+
resolve: resolve6,
|
|
46719
46725
|
onError,
|
|
46720
46726
|
initialSessionState: initialSessionState2,
|
|
46721
46727
|
signal,
|
|
@@ -46724,7 +46730,7 @@ async function handlePromptResponse({
|
|
|
46724
46730
|
if (action.type === "prompt-error") {
|
|
46725
46731
|
onError({ message: action.message });
|
|
46726
46732
|
const statusCode = extractStatusCodeFromMessage(action.message);
|
|
46727
|
-
|
|
46733
|
+
resolve6({
|
|
46728
46734
|
sessionState: initialSessionState2,
|
|
46729
46735
|
output: {
|
|
46730
46736
|
type: "error",
|
|
@@ -46742,7 +46748,7 @@ async function handlePromptResponse({
|
|
|
46742
46748
|
].join(`
|
|
46743
46749
|
`);
|
|
46744
46750
|
onError({ message });
|
|
46745
|
-
|
|
46751
|
+
resolve6({
|
|
46746
46752
|
sessionState: initialSessionState2,
|
|
46747
46753
|
output: {
|
|
46748
46754
|
type: "error",
|
|
@@ -46763,12 +46769,12 @@ async function handlePromptResponse({
|
|
|
46763
46769
|
message: "No output from agent"
|
|
46764
46770
|
}
|
|
46765
46771
|
};
|
|
46766
|
-
|
|
46772
|
+
resolve6(state);
|
|
46767
46773
|
} else {
|
|
46768
46774
|
onError({
|
|
46769
46775
|
message: "Internal error: prompt response type not handled"
|
|
46770
46776
|
});
|
|
46771
|
-
|
|
46777
|
+
resolve6({
|
|
46772
46778
|
sessionState: initialSessionState2,
|
|
46773
46779
|
output: {
|
|
46774
46780
|
type: "error",
|
|
@@ -47110,7 +47116,7 @@ var ToolHelpers = {
|
|
|
47110
47116
|
changeFile
|
|
47111
47117
|
};
|
|
47112
47118
|
// src/agents/load-mcp-config.ts
|
|
47113
|
-
import
|
|
47119
|
+
import fs15 from "fs";
|
|
47114
47120
|
import fsPromises from "fs/promises";
|
|
47115
47121
|
import os8 from "os";
|
|
47116
47122
|
import path21 from "path";
|
|
@@ -47209,10 +47215,10 @@ function loadMCPConfigSync(options) {
|
|
|
47209
47215
|
for (const dir of mcpConfigDirs) {
|
|
47210
47216
|
const configPath = path21.join(dir, MCP_CONFIG_FILE_NAME);
|
|
47211
47217
|
try {
|
|
47212
|
-
if (!
|
|
47218
|
+
if (!fs15.existsSync(configPath)) {
|
|
47213
47219
|
continue;
|
|
47214
47220
|
}
|
|
47215
|
-
const content =
|
|
47221
|
+
const content = fs15.readFileSync(configPath, "utf8");
|
|
47216
47222
|
const rawConfig = JSON.parse(content);
|
|
47217
47223
|
const parseResult = mcpFileSchema.safeParse(rawConfig);
|
|
47218
47224
|
if (!parseResult.success) {
|
|
@@ -47252,6 +47258,10 @@ export {
|
|
|
47252
47258
|
setWasmDir,
|
|
47253
47259
|
selectKnowledgeFilePaths,
|
|
47254
47260
|
selectHighestPriorityKnowledgeFile,
|
|
47261
|
+
sdkListTeams,
|
|
47262
|
+
sdkGetTeamStatus,
|
|
47263
|
+
sdkDeleteTeam,
|
|
47264
|
+
sdkCreateTeam,
|
|
47255
47265
|
saveClaudeOAuthCredentials,
|
|
47256
47266
|
sanitizeErrorMessage,
|
|
47257
47267
|
runTerminalCommand,
|
|
@@ -47311,5 +47321,5 @@ export {
|
|
|
47311
47321
|
IS_DEV
|
|
47312
47322
|
};
|
|
47313
47323
|
|
|
47314
|
-
//# debugId=
|
|
47324
|
+
//# debugId=4A1170BC5A73E89E64756E2164756E21
|
|
47315
47325
|
//# sourceMappingURL=index.mjs.map
|