@levelcode/sdk 0.0.4 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/common/src/actions.d.ts +176 -0
- package/dist/common/src/analytics-core.d.ts +52 -0
- package/dist/common/src/analytics.d.ts +9 -0
- package/dist/common/src/browser-actions.d.ts +1200 -0
- package/dist/common/src/constants/agents.d.ts +47 -0
- package/dist/common/src/constants/analytics-events.d.ts +107 -0
- package/dist/common/src/constants/byok.d.ts +2 -0
- package/dist/common/src/constants/claude-oauth.d.ts +36 -0
- package/dist/common/src/constants/index.d.ts +4 -0
- package/dist/common/src/constants/knowledge.d.ts +21 -0
- package/dist/common/src/constants/limits.d.ts +14 -0
- package/dist/common/src/constants/model-config.d.ts +117 -0
- package/dist/common/src/constants/paths.d.ts +23 -0
- package/dist/common/src/constants/skills.d.ts +42 -0
- package/dist/common/src/constants/ui.d.ts +14 -0
- package/dist/common/src/env-ci.d.ts +22 -0
- package/dist/common/src/env-process.d.ts +28 -0
- package/dist/common/src/env-schema.d.ts +24 -0
- package/dist/common/src/env.d.ts +16 -0
- package/dist/common/src/mcp/client.d.ts +6 -0
- package/dist/common/src/old-constants.d.ts +10 -0
- package/dist/common/src/project-file-tree.d.ts +27 -0
- package/dist/common/src/templates/agent-validation.d.ts +48 -0
- package/dist/common/src/templates/initial-agents-dir/types/agent-definition.d.ts +296 -0
- package/dist/common/src/templates/initial-agents-dir/types/tools.d.ts +308 -0
- package/dist/common/src/templates/initial-agents-dir/types/util-types.d.ts +128 -0
- package/dist/common/src/testing/errors.d.ts +14 -0
- package/dist/common/src/testing/mock-modules.d.ts +11 -0
- package/dist/common/src/testing/mock-types.d.ts +97 -0
- package/dist/common/src/testing/mocks/analytics.d.ts +182 -0
- package/dist/common/src/testing/mocks/child-process.d.ts +29 -0
- package/dist/common/src/testing/mocks/crypto.d.ts +159 -0
- package/dist/common/src/testing/mocks/database.d.ts +197 -0
- package/dist/common/src/testing/mocks/fetch.d.ts +35 -0
- package/dist/common/src/testing/mocks/filesystem.d.ts +31 -0
- package/dist/common/src/testing/mocks/index.d.ts +25 -0
- package/dist/common/src/testing/mocks/logger.d.ts +35 -0
- package/dist/common/src/testing/mocks/stream.d.ts +203 -0
- package/dist/common/src/testing/mocks/timers.d.ts +27 -0
- package/dist/common/src/testing/mocks/tree-sitter.d.ts +58 -0
- package/dist/common/src/testing-env-process.d.ts +7 -0
- package/dist/common/src/tools/constants.d.ts +17 -0
- package/dist/common/src/tools/list.d.ts +1140 -0
- package/dist/common/src/tools/params/tool/add-message.d.ts +19 -0
- package/dist/common/src/tools/params/tool/add-subgoal.d.ts +26 -0
- package/dist/common/src/tools/params/tool/ask-user.d.ts +59 -0
- package/dist/common/src/tools/params/tool/browser-logs.d.ts +127 -0
- package/dist/common/src/tools/params/tool/code-search.d.ts +30 -0
- package/dist/common/src/tools/params/tool/create-plan.d.ts +30 -0
- package/dist/common/src/tools/params/tool/end-turn.d.ts +13 -0
- package/dist/common/src/tools/params/tool/find-files.d.ts +31 -0
- package/dist/common/src/tools/params/tool/glob.d.ts +26 -0
- package/dist/common/src/tools/params/tool/list-directory.d.ts +25 -0
- package/dist/common/src/tools/params/tool/lookup-agent-info.d.ts +13 -0
- package/dist/common/src/tools/params/tool/propose-str-replace.d.ts +40 -0
- package/dist/common/src/tools/params/tool/propose-write-file.d.ts +29 -0
- package/dist/common/src/tools/params/tool/read-docs.d.ts +19 -0
- package/dist/common/src/tools/params/tool/read-files.d.ts +35 -0
- package/dist/common/src/tools/params/tool/read-subtree.d.ts +40 -0
- package/dist/common/src/tools/params/tool/run-file-change-hooks.d.ts +63 -0
- package/dist/common/src/tools/params/tool/run-terminal-command.d.ts +88 -0
- package/dist/common/src/tools/params/tool/send-message.d.ts +26 -0
- package/dist/common/src/tools/params/tool/set-messages.d.ts +15 -0
- package/dist/common/src/tools/params/tool/set-output.d.ts +15 -0
- package/dist/common/src/tools/params/tool/skill.d.ts +28 -0
- package/dist/common/src/tools/params/tool/spawn-agent-inline.d.ts +17 -0
- package/dist/common/src/tools/params/tool/spawn-agents.d.ts +26 -0
- package/dist/common/src/tools/params/tool/str-replace.d.ts +43 -0
- package/dist/common/src/tools/params/tool/suggest-followups.d.ts +26 -0
- package/dist/common/src/tools/params/tool/task-completed.d.ts +13 -0
- package/dist/common/src/tools/params/tool/task-create.d.ts +18 -0
- package/dist/common/src/tools/params/tool/task-get.d.ts +15 -0
- package/dist/common/src/tools/params/tool/task-list.d.ts +13 -0
- package/dist/common/src/tools/params/tool/task-update.d.ts +23 -0
- package/dist/common/src/tools/params/tool/team-create.d.ts +17 -0
- package/dist/common/src/tools/params/tool/team-delete.d.ts +13 -0
- package/dist/common/src/tools/params/tool/think-deeply.d.ts +15 -0
- package/dist/common/src/tools/params/tool/update-subgoal.d.ts +25 -0
- package/dist/common/src/tools/params/tool/web-search.d.ts +25 -0
- package/dist/common/src/tools/params/tool/write-file.d.ts +31 -0
- package/dist/common/src/tools/params/tool/write-todos.d.ts +18 -0
- package/dist/common/src/tools/params/utils.d.ts +35 -0
- package/dist/common/src/tools/utils.d.ts +4 -0
- package/dist/common/src/types/agent-template.d.ts +156 -0
- package/dist/common/src/types/contracts/agent-runtime.d.ts +36 -0
- package/dist/common/src/types/contracts/analytics.d.ts +8 -0
- package/dist/common/src/types/contracts/billing.d.ts +40 -0
- package/dist/common/src/types/contracts/client.d.ts +45 -0
- package/dist/common/src/types/contracts/database.d.ts +80 -0
- package/dist/common/src/types/contracts/env.d.ts +150 -0
- package/dist/common/src/types/contracts/llm.d.ts +102 -0
- package/dist/common/src/types/contracts/logger.d.ts +8 -0
- package/dist/common/src/types/dynamic-agent-template.d.ts +227 -0
- package/dist/common/src/types/filesystem.d.ts +6 -0
- package/dist/common/src/types/function-params.d.ts +15 -0
- package/dist/common/src/types/grant.d.ts +2 -0
- package/dist/common/src/types/json.d.ts +9 -0
- package/dist/common/src/types/mcp.d.ts +31 -0
- package/dist/common/src/types/messages/content-part.d.ts +46 -0
- package/dist/common/src/types/messages/data-content.d.ts +3 -0
- package/dist/common/src/types/messages/levelcode-message.d.ts +37 -0
- package/dist/common/src/types/messages/provider-metadata.d.ts +3 -0
- package/dist/common/src/types/print-mode.d.ts +155 -0
- package/dist/common/src/types/session-state.d.ts +94 -0
- package/dist/common/src/types/skill.d.ts +31 -0
- package/dist/common/src/types/source.d.ts +8 -0
- package/dist/common/src/types/spawn.d.ts +8 -0
- package/dist/common/src/types/team-config.d.ts +39 -0
- package/dist/common/src/types/team-protocol.d.ts +64 -0
- package/dist/common/src/util/agent-id-parsing.d.ts +22 -0
- package/dist/common/src/util/agent-name-normalization.d.ts +12 -0
- package/dist/common/src/util/array.d.ts +6 -0
- package/dist/common/src/util/credentials.d.ts +11 -0
- package/dist/common/src/util/error.d.ts +128 -0
- package/dist/common/src/util/file.d.ts +133 -0
- package/dist/common/src/util/format-code-search.d.ts +16 -0
- package/dist/common/src/util/lru-cache.d.ts +30 -0
- package/dist/common/src/util/messages.d.ts +46 -0
- package/dist/common/src/util/model-utils.d.ts +8 -0
- package/dist/common/src/util/object.d.ts +22 -0
- package/dist/common/src/util/promise.d.ts +16 -0
- package/dist/common/src/util/random.d.ts +1 -0
- package/dist/common/src/util/skills.d.ts +5 -0
- package/dist/common/src/util/stop-sequence.d.ts +14 -0
- package/dist/common/src/util/string.d.ts +82 -0
- package/dist/common/src/util/xml.d.ts +12 -0
- package/dist/common/src/util/zod-schema.d.ts +5 -0
- package/dist/common/src/utils/team-fs.d.ts +17 -0
- package/dist/index.cjs +1958 -917
- package/dist/index.cjs.map +25 -10
- package/dist/index.mjs +2392 -1351
- package/dist/index.mjs.map +25 -10
- package/dist/packages/agent-runtime/src/constants.d.ts +1 -0
- package/dist/packages/agent-runtime/src/fast-rewrite.d.ts +45 -0
- package/dist/packages/agent-runtime/src/find-files/request-files-prompt.d.ts +71 -0
- package/dist/packages/agent-runtime/src/generate-diffs-prompt.d.ts +53 -0
- package/dist/packages/agent-runtime/src/get-file-reading-updates.d.ts +8 -0
- package/dist/packages/agent-runtime/src/llm-api/claude.d.ts +5 -0
- package/dist/packages/agent-runtime/src/llm-api/context7-api.d.ts +55 -0
- package/dist/packages/agent-runtime/src/llm-api/gemini-with-fallbacks.d.ts +40 -0
- package/dist/packages/agent-runtime/src/llm-api/levelcode-web-api.d.ts +49 -0
- package/dist/packages/agent-runtime/src/llm-api/relace-api.d.ts +16 -0
- package/dist/packages/agent-runtime/src/main-prompt.d.ts +29 -0
- package/dist/packages/agent-runtime/src/mcp-constants.d.ts +12 -0
- package/dist/packages/agent-runtime/src/mcp.d.ts +10 -0
- package/dist/packages/agent-runtime/src/process-file-block.d.ts +56 -0
- package/dist/packages/agent-runtime/src/process-str-replace.d.ts +21 -0
- package/dist/packages/agent-runtime/src/prompt-agent-stream.d.ts +28 -0
- package/dist/packages/agent-runtime/src/run-agent-step.d.ts +73 -0
- package/dist/packages/agent-runtime/src/run-programmatic-step.d.ts +40 -0
- package/dist/packages/agent-runtime/src/system-prompt/prompts.d.ts +19 -0
- package/dist/packages/agent-runtime/src/system-prompt/search-system-prompt.d.ts +14 -0
- package/dist/packages/agent-runtime/src/system-prompt/truncate-file-tree.d.ts +13 -0
- package/dist/packages/agent-runtime/src/templates/agent-registry.d.ts +35 -0
- package/dist/packages/agent-runtime/src/templates/prompts.d.ts +35 -0
- package/dist/packages/agent-runtime/src/templates/strings.d.ts +32 -0
- package/dist/packages/agent-runtime/src/templates/types.d.ts +13 -0
- package/dist/packages/agent-runtime/src/tool-stream-parser.d.ts +31 -0
- package/dist/packages/agent-runtime/src/tools/handlers/handler-function-type.d.ts +51 -0
- package/dist/packages/agent-runtime/src/tools/handlers/list.d.ts +347 -0
- package/dist/packages/agent-runtime/src/tools/handlers/tool/add-message.d.ts +9 -0
- package/dist/packages/agent-runtime/src/tools/handlers/tool/add-subgoal.d.ts +9 -0
- package/dist/packages/agent-runtime/src/tools/handlers/tool/ask-user.d.ts +10 -0
- package/dist/packages/agent-runtime/src/tools/handlers/tool/browser-logs.d.ts +8 -0
- package/dist/packages/agent-runtime/src/tools/handlers/tool/code-search.d.ts +8 -0
- package/dist/packages/agent-runtime/src/tools/handlers/tool/create-plan.d.ts +13 -0
- package/dist/packages/agent-runtime/src/tools/handlers/tool/end-turn.d.ts +7 -0
- package/dist/packages/agent-runtime/src/tools/handlers/tool/find-files.d.ts +27 -0
- package/dist/packages/agent-runtime/src/tools/handlers/tool/glob.d.ts +10 -0
- package/dist/packages/agent-runtime/src/tools/handlers/tool/list-directory.d.ts +10 -0
- package/dist/packages/agent-runtime/src/tools/handlers/tool/lookup-agent-info.d.ts +14 -0
- package/dist/packages/agent-runtime/src/tools/handlers/tool/propose-str-replace.d.ts +15 -0
- package/dist/packages/agent-runtime/src/tools/handlers/tool/propose-write-file.d.ts +7 -0
- package/dist/packages/agent-runtime/src/tools/handlers/tool/proposed-content-store.d.ts +27 -0
- package/dist/packages/agent-runtime/src/tools/handlers/tool/read-docs.d.ts +21 -0
- package/dist/packages/agent-runtime/src/tools/handlers/tool/read-files.d.ts +13 -0
- package/dist/packages/agent-runtime/src/tools/handlers/tool/read-subtree.d.ts +13 -0
- package/dist/packages/agent-runtime/src/tools/handlers/tool/run-file-change-hooks.d.ts +10 -0
- package/dist/packages/agent-runtime/src/tools/handlers/tool/run-terminal-command.d.ts +10 -0
- package/dist/packages/agent-runtime/src/tools/handlers/tool/send-message.d.ts +10 -0
- package/dist/packages/agent-runtime/src/tools/handlers/tool/set-messages.d.ts +9 -0
- package/dist/packages/agent-runtime/src/tools/handlers/tool/set-output.d.ts +18 -0
- package/dist/packages/agent-runtime/src/tools/handlers/tool/skill.d.ts +11 -0
- package/dist/packages/agent-runtime/src/tools/handlers/tool/spawn-agent-inline.d.ts +29 -0
- package/dist/packages/agent-runtime/src/tools/handlers/tool/spawn-agent-utils.d.ts +100 -0
- package/dist/packages/agent-runtime/src/tools/handlers/tool/spawn-agents.d.ts +35 -0
- package/dist/packages/agent-runtime/src/tools/handlers/tool/str-replace.d.ts +16 -0
- package/dist/packages/agent-runtime/src/tools/handlers/tool/suggest-followups.d.ts +9 -0
- package/dist/packages/agent-runtime/src/tools/handlers/tool/task-completed.d.ts +7 -0
- package/dist/packages/agent-runtime/src/tools/handlers/tool/task-create.d.ts +9 -0
- package/dist/packages/agent-runtime/src/tools/handlers/tool/task-get.d.ts +9 -0
- package/dist/packages/agent-runtime/src/tools/handlers/tool/task-list.d.ts +9 -0
- package/dist/packages/agent-runtime/src/tools/handlers/tool/task-update.d.ts +9 -0
- package/dist/packages/agent-runtime/src/tools/handlers/tool/team-create.d.ts +10 -0
- package/dist/packages/agent-runtime/src/tools/handlers/tool/team-delete.d.ts +10 -0
- package/dist/packages/agent-runtime/src/tools/handlers/tool/think-deeply.d.ts +9 -0
- package/dist/packages/agent-runtime/src/tools/handlers/tool/update-subgoal.d.ts +11 -0
- package/dist/packages/agent-runtime/src/tools/handlers/tool/web-search.d.ts +22 -0
- package/dist/packages/agent-runtime/src/tools/handlers/tool/write-file.d.ts +49 -0
- package/dist/packages/agent-runtime/src/tools/handlers/tool/write-todos.d.ts +9 -0
- package/dist/packages/agent-runtime/src/tools/prompts.d.ts +31 -0
- package/dist/packages/agent-runtime/src/tools/stream-parser.d.ts +33 -0
- package/dist/packages/agent-runtime/src/tools/tool-executor.d.ts +87 -0
- package/dist/packages/agent-runtime/src/util/agent-output.d.ts +3 -0
- package/dist/packages/agent-runtime/src/util/messages.d.ts +68 -0
- package/dist/packages/agent-runtime/src/util/parse-tool-calls-from-text.d.ts +38 -0
- package/dist/packages/agent-runtime/src/util/render-read-files-result.d.ts +15 -0
- package/dist/packages/agent-runtime/src/util/simplify-tool-results.d.ts +7 -0
- package/dist/packages/agent-runtime/src/util/stream-xml-parser.d.ts +34 -0
- package/dist/packages/agent-runtime/src/util/token-counter.d.ts +3 -0
- package/dist/packages/code-map/src/index.d.ts +3 -0
- package/dist/packages/code-map/src/init-node.d.ts +4 -0
- package/dist/packages/code-map/src/languages.d.ts +36 -0
- package/dist/packages/code-map/src/parse.d.ts +21 -0
- package/dist/packages/code-map/src/types.d.ts +8 -0
- package/dist/packages/code-map/src/utils.d.ts +1 -0
- package/dist/sdk/src/__tests__/client.test.d.ts +1 -0
- package/dist/sdk/src/__tests__/code-search.test.d.ts +1 -0
- package/dist/sdk/src/__tests__/credentials.test.d.ts +1 -0
- package/dist/sdk/src/__tests__/database.test.d.ts +1 -0
- package/dist/sdk/src/__tests__/env.test.d.ts +1 -0
- package/dist/sdk/src/__tests__/error-utils.test.d.ts +1 -0
- package/dist/sdk/src/__tests__/initial-session-state.test.d.ts +1 -0
- package/dist/sdk/src/__tests__/knowledge-file-selection.test.d.ts +1 -0
- package/dist/sdk/src/__tests__/load-agents.test.d.ts +1 -0
- package/dist/sdk/src/__tests__/load-mcp-config.test.d.ts +1 -0
- package/dist/sdk/src/__tests__/model-provider.test.d.ts +1 -0
- package/dist/sdk/src/__tests__/read-files.test.d.ts +1 -0
- package/dist/sdk/src/__tests__/run-cancellation.test.d.ts +1 -0
- package/dist/sdk/src/__tests__/run-file-filter.test.d.ts +1 -0
- package/dist/sdk/src/__tests__/run-handle-event.test.d.ts +1 -0
- package/dist/sdk/src/__tests__/run.integration.test.d.ts +1 -0
- package/dist/sdk/src/__tests__/user-knowledge-files.test.d.ts +1 -0
- package/dist/sdk/src/__tests__/validate-agents.test.d.ts +1 -0
- package/dist/sdk/src/agents/load-agents.d.ts +106 -0
- package/dist/sdk/src/agents/load-mcp-config.d.ts +69 -0
- package/dist/sdk/src/client.d.ts +33 -0
- package/dist/sdk/src/constants.d.ts +4 -0
- package/dist/sdk/src/credentials.d.ts +58 -0
- package/dist/sdk/src/custom-tool.d.ts +32 -0
- package/dist/sdk/src/env.d.ts +31 -0
- package/dist/sdk/src/error-utils.d.ts +55 -0
- package/dist/sdk/src/impl/__tests__/prompt-result.test.d.ts +1 -0
- package/dist/sdk/src/impl/agent-runtime.d.ts +8 -0
- package/dist/sdk/src/impl/database.d.ts +7 -0
- package/dist/sdk/src/impl/llm.d.ts +8 -0
- package/dist/sdk/src/impl/model-provider.d.ts +61 -0
- package/dist/sdk/src/index.d.ts +41 -0
- package/dist/sdk/src/native/ripgrep.d.ts +7 -0
- package/dist/sdk/src/retry-config.d.ts +46 -0
- package/dist/sdk/src/run-state.d.ts +81 -0
- package/dist/sdk/src/run.d.ts +79 -0
- package/dist/sdk/src/skills/load-skills.d.ts +42 -0
- package/dist/sdk/src/testing/env.d.ts +5 -0
- package/dist/sdk/src/tools/change-file.d.ts +7 -0
- package/dist/sdk/src/tools/code-search.d.ts +13 -0
- package/dist/sdk/src/tools/glob.d.ts +8 -0
- package/dist/sdk/src/tools/index.d.ts +16 -0
- package/dist/sdk/src/tools/list-directory.d.ts +7 -0
- package/dist/sdk/src/tools/read-files.d.ts +16 -0
- package/dist/sdk/src/tools/run-file-change-hooks.d.ts +4 -0
- package/dist/sdk/src/tools/run-terminal-command.d.ts +8 -0
- package/dist/sdk/src/types/env.d.ts +30 -0
- package/dist/sdk/src/validate-agents.d.ts +45 -0
- package/package.json +1 -1
- package/dist/index.d.ts +0 -3443
package/dist/index.cjs
CHANGED
|
@@ -7269,8 +7269,8 @@ var require_uri_all = __commonJS((exports3, module2) => {
|
|
|
7269
7269
|
wsComponents.secure = undefined;
|
|
7270
7270
|
}
|
|
7271
7271
|
if (wsComponents.resourceName) {
|
|
7272
|
-
var _wsComponents$resourc = wsComponents.resourceName.split("?"), _wsComponents$resourc2 = slicedToArray(_wsComponents$resourc, 2),
|
|
7273
|
-
wsComponents.path =
|
|
7272
|
+
var _wsComponents$resourc = wsComponents.resourceName.split("?"), _wsComponents$resourc2 = slicedToArray(_wsComponents$resourc, 2), path6 = _wsComponents$resourc2[0], query = _wsComponents$resourc2[1];
|
|
7273
|
+
wsComponents.path = path6 && path6 !== "/" ? path6 : undefined;
|
|
7274
7274
|
wsComponents.query = query;
|
|
7275
7275
|
wsComponents.resourceName = undefined;
|
|
7276
7276
|
}
|
|
@@ -7663,12 +7663,12 @@ var require_util = __commonJS((exports3, module2) => {
|
|
|
7663
7663
|
return "'" + escapeQuotes(str) + "'";
|
|
7664
7664
|
}
|
|
7665
7665
|
function getPathExpr(currentPath, expr, jsonPointers, isNumber2) {
|
|
7666
|
-
var
|
|
7667
|
-
return joinPaths(currentPath,
|
|
7666
|
+
var path6 = jsonPointers ? "'/' + " + expr + (isNumber2 ? "" : ".replace(/~/g, '~0').replace(/\\//g, '~1')") : isNumber2 ? "'[' + " + expr + " + ']'" : "'[\\'' + " + expr + " + '\\']'";
|
|
7667
|
+
return joinPaths(currentPath, path6);
|
|
7668
7668
|
}
|
|
7669
7669
|
function getPath(currentPath, prop, jsonPointers) {
|
|
7670
|
-
var
|
|
7671
|
-
return joinPaths(currentPath,
|
|
7670
|
+
var path6 = jsonPointers ? toQuotedString("/" + escapeJsonPointer(prop)) : toQuotedString(getProperty(prop));
|
|
7671
|
+
return joinPaths(currentPath, path6);
|
|
7672
7672
|
}
|
|
7673
7673
|
var JSON_POINTER = /^\/(?:[^~]|~0|~1)*$/;
|
|
7674
7674
|
var RELATIVE_JSON_POINTER = /^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;
|
|
@@ -12633,8 +12633,8 @@ var require_ajv = __commonJS((exports3, module2) => {
|
|
|
12633
12633
|
var require_windows = __commonJS((exports3, module2) => {
|
|
12634
12634
|
module2.exports = isexe;
|
|
12635
12635
|
isexe.sync = sync;
|
|
12636
|
-
var
|
|
12637
|
-
function checkPathExt(
|
|
12636
|
+
var fs8 = require("fs");
|
|
12637
|
+
function checkPathExt(path6, options) {
|
|
12638
12638
|
var pathext = options.pathExt !== undefined ? options.pathExt : process.env.PATHEXT;
|
|
12639
12639
|
if (!pathext) {
|
|
12640
12640
|
return true;
|
|
@@ -12645,25 +12645,25 @@ var require_windows = __commonJS((exports3, module2) => {
|
|
|
12645
12645
|
}
|
|
12646
12646
|
for (var i = 0;i < pathext.length; i++) {
|
|
12647
12647
|
var p = pathext[i].toLowerCase();
|
|
12648
|
-
if (p &&
|
|
12648
|
+
if (p && path6.substr(-p.length).toLowerCase() === p) {
|
|
12649
12649
|
return true;
|
|
12650
12650
|
}
|
|
12651
12651
|
}
|
|
12652
12652
|
return false;
|
|
12653
12653
|
}
|
|
12654
|
-
function checkStat(stat,
|
|
12654
|
+
function checkStat(stat, path6, options) {
|
|
12655
12655
|
if (!stat.isSymbolicLink() && !stat.isFile()) {
|
|
12656
12656
|
return false;
|
|
12657
12657
|
}
|
|
12658
|
-
return checkPathExt(
|
|
12658
|
+
return checkPathExt(path6, options);
|
|
12659
12659
|
}
|
|
12660
|
-
function isexe(
|
|
12661
|
-
|
|
12662
|
-
cb(er, er ? false : checkStat(stat,
|
|
12660
|
+
function isexe(path6, options, cb) {
|
|
12661
|
+
fs8.stat(path6, function(er, stat) {
|
|
12662
|
+
cb(er, er ? false : checkStat(stat, path6, options));
|
|
12663
12663
|
});
|
|
12664
12664
|
}
|
|
12665
|
-
function sync(
|
|
12666
|
-
return checkStat(
|
|
12665
|
+
function sync(path6, options) {
|
|
12666
|
+
return checkStat(fs8.statSync(path6), path6, options);
|
|
12667
12667
|
}
|
|
12668
12668
|
});
|
|
12669
12669
|
|
|
@@ -12671,14 +12671,14 @@ var require_windows = __commonJS((exports3, module2) => {
|
|
|
12671
12671
|
var require_mode = __commonJS((exports3, module2) => {
|
|
12672
12672
|
module2.exports = isexe;
|
|
12673
12673
|
isexe.sync = sync;
|
|
12674
|
-
var
|
|
12675
|
-
function isexe(
|
|
12676
|
-
|
|
12674
|
+
var fs8 = require("fs");
|
|
12675
|
+
function isexe(path6, options, cb) {
|
|
12676
|
+
fs8.stat(path6, function(er, stat) {
|
|
12677
12677
|
cb(er, er ? false : checkStat(stat, options));
|
|
12678
12678
|
});
|
|
12679
12679
|
}
|
|
12680
|
-
function sync(
|
|
12681
|
-
return checkStat(
|
|
12680
|
+
function sync(path6, options) {
|
|
12681
|
+
return checkStat(fs8.statSync(path6), options);
|
|
12682
12682
|
}
|
|
12683
12683
|
function checkStat(stat, options) {
|
|
12684
12684
|
return stat.isFile() && checkMode(stat, options);
|
|
@@ -12700,7 +12700,7 @@ var require_mode = __commonJS((exports3, module2) => {
|
|
|
12700
12700
|
|
|
12701
12701
|
// ../node_modules/isexe/index.js
|
|
12702
12702
|
var require_isexe = __commonJS((exports3, module2) => {
|
|
12703
|
-
var
|
|
12703
|
+
var fs8 = require("fs");
|
|
12704
12704
|
var core;
|
|
12705
12705
|
if (process.platform === "win32" || global.TESTING_WINDOWS) {
|
|
12706
12706
|
core = require_windows();
|
|
@@ -12709,7 +12709,7 @@ var require_isexe = __commonJS((exports3, module2) => {
|
|
|
12709
12709
|
}
|
|
12710
12710
|
module2.exports = isexe;
|
|
12711
12711
|
isexe.sync = sync;
|
|
12712
|
-
function isexe(
|
|
12712
|
+
function isexe(path6, options, cb) {
|
|
12713
12713
|
if (typeof options === "function") {
|
|
12714
12714
|
cb = options;
|
|
12715
12715
|
options = {};
|
|
@@ -12719,7 +12719,7 @@ var require_isexe = __commonJS((exports3, module2) => {
|
|
|
12719
12719
|
throw new TypeError("callback not provided");
|
|
12720
12720
|
}
|
|
12721
12721
|
return new Promise(function(resolve2, reject) {
|
|
12722
|
-
isexe(
|
|
12722
|
+
isexe(path6, options || {}, function(er, is) {
|
|
12723
12723
|
if (er) {
|
|
12724
12724
|
reject(er);
|
|
12725
12725
|
} else {
|
|
@@ -12728,7 +12728,7 @@ var require_isexe = __commonJS((exports3, module2) => {
|
|
|
12728
12728
|
});
|
|
12729
12729
|
});
|
|
12730
12730
|
}
|
|
12731
|
-
core(
|
|
12731
|
+
core(path6, options || {}, function(er, is) {
|
|
12732
12732
|
if (er) {
|
|
12733
12733
|
if (er.code === "EACCES" || options && options.ignoreErrors) {
|
|
12734
12734
|
er = null;
|
|
@@ -12738,9 +12738,9 @@ var require_isexe = __commonJS((exports3, module2) => {
|
|
|
12738
12738
|
cb(er, is);
|
|
12739
12739
|
});
|
|
12740
12740
|
}
|
|
12741
|
-
function sync(
|
|
12741
|
+
function sync(path6, options) {
|
|
12742
12742
|
try {
|
|
12743
|
-
return core.sync(
|
|
12743
|
+
return core.sync(path6, options || {});
|
|
12744
12744
|
} catch (er) {
|
|
12745
12745
|
if (options && options.ignoreErrors || er.code === "EACCES") {
|
|
12746
12746
|
return false;
|
|
@@ -12754,7 +12754,7 @@ var require_isexe = __commonJS((exports3, module2) => {
|
|
|
12754
12754
|
// ../node_modules/which/which.js
|
|
12755
12755
|
var require_which = __commonJS((exports3, module2) => {
|
|
12756
12756
|
var isWindows = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys";
|
|
12757
|
-
var
|
|
12757
|
+
var path6 = require("path");
|
|
12758
12758
|
var COLON = isWindows ? ";" : ":";
|
|
12759
12759
|
var isexe = require_isexe();
|
|
12760
12760
|
var getNotFoundError = (cmd) => Object.assign(new Error(`not found: ${cmd}`), { code: "ENOENT" });
|
|
@@ -12790,7 +12790,7 @@ var require_which = __commonJS((exports3, module2) => {
|
|
|
12790
12790
|
return opt.all && found.length ? resolve2(found) : reject(getNotFoundError(cmd));
|
|
12791
12791
|
const ppRaw = pathEnv[i];
|
|
12792
12792
|
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
12793
|
-
const pCmd =
|
|
12793
|
+
const pCmd = path6.join(pathPart, cmd);
|
|
12794
12794
|
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
12795
12795
|
resolve2(subStep(p, i, 0));
|
|
12796
12796
|
});
|
|
@@ -12817,7 +12817,7 @@ var require_which = __commonJS((exports3, module2) => {
|
|
|
12817
12817
|
for (let i = 0;i < pathEnv.length; i++) {
|
|
12818
12818
|
const ppRaw = pathEnv[i];
|
|
12819
12819
|
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
12820
|
-
const pCmd =
|
|
12820
|
+
const pCmd = path6.join(pathPart, cmd);
|
|
12821
12821
|
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
12822
12822
|
for (let j = 0;j < pathExt.length; j++) {
|
|
12823
12823
|
const cur = p + pathExt[j];
|
|
@@ -12858,7 +12858,7 @@ var require_path_key = __commonJS((exports3, module2) => {
|
|
|
12858
12858
|
|
|
12859
12859
|
// ../node_modules/cross-spawn/lib/util/resolveCommand.js
|
|
12860
12860
|
var require_resolveCommand = __commonJS((exports3, module2) => {
|
|
12861
|
-
var
|
|
12861
|
+
var path6 = require("path");
|
|
12862
12862
|
var which = require_which();
|
|
12863
12863
|
var getPathKey = require_path_key();
|
|
12864
12864
|
function resolveCommandAttempt(parsed, withoutPathExt) {
|
|
@@ -12875,7 +12875,7 @@ var require_resolveCommand = __commonJS((exports3, module2) => {
|
|
|
12875
12875
|
try {
|
|
12876
12876
|
resolved = which.sync(parsed.command, {
|
|
12877
12877
|
path: env2[getPathKey({ env: env2 })],
|
|
12878
|
-
pathExt: withoutPathExt ?
|
|
12878
|
+
pathExt: withoutPathExt ? path6.delimiter : undefined
|
|
12879
12879
|
});
|
|
12880
12880
|
} catch (e) {} finally {
|
|
12881
12881
|
if (shouldSwitchCwd) {
|
|
@@ -12883,7 +12883,7 @@ var require_resolveCommand = __commonJS((exports3, module2) => {
|
|
|
12883
12883
|
}
|
|
12884
12884
|
}
|
|
12885
12885
|
if (resolved) {
|
|
12886
|
-
resolved =
|
|
12886
|
+
resolved = path6.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved);
|
|
12887
12887
|
}
|
|
12888
12888
|
return resolved;
|
|
12889
12889
|
}
|
|
@@ -12928,8 +12928,8 @@ var require_shebang_command = __commonJS((exports3, module2) => {
|
|
|
12928
12928
|
if (!match) {
|
|
12929
12929
|
return null;
|
|
12930
12930
|
}
|
|
12931
|
-
const [
|
|
12932
|
-
const binary =
|
|
12931
|
+
const [path6, argument] = match[0].replace(/#! ?/, "").split(" ");
|
|
12932
|
+
const binary = path6.split("/").pop();
|
|
12933
12933
|
if (binary === "env") {
|
|
12934
12934
|
return argument;
|
|
12935
12935
|
}
|
|
@@ -12939,16 +12939,16 @@ var require_shebang_command = __commonJS((exports3, module2) => {
|
|
|
12939
12939
|
|
|
12940
12940
|
// ../node_modules/cross-spawn/lib/util/readShebang.js
|
|
12941
12941
|
var require_readShebang = __commonJS((exports3, module2) => {
|
|
12942
|
-
var
|
|
12942
|
+
var fs8 = require("fs");
|
|
12943
12943
|
var shebangCommand = require_shebang_command();
|
|
12944
12944
|
function readShebang(command) {
|
|
12945
12945
|
const size = 150;
|
|
12946
12946
|
const buffer = Buffer.alloc(size);
|
|
12947
12947
|
let fd;
|
|
12948
12948
|
try {
|
|
12949
|
-
fd =
|
|
12950
|
-
|
|
12951
|
-
|
|
12949
|
+
fd = fs8.openSync(command, "r");
|
|
12950
|
+
fs8.readSync(fd, buffer, 0, size, 0);
|
|
12951
|
+
fs8.closeSync(fd);
|
|
12952
12952
|
} catch (e) {}
|
|
12953
12953
|
return shebangCommand(buffer.toString());
|
|
12954
12954
|
}
|
|
@@ -12957,7 +12957,7 @@ var require_readShebang = __commonJS((exports3, module2) => {
|
|
|
12957
12957
|
|
|
12958
12958
|
// ../node_modules/cross-spawn/lib/parse.js
|
|
12959
12959
|
var require_parse = __commonJS((exports3, module2) => {
|
|
12960
|
-
var
|
|
12960
|
+
var path6 = require("path");
|
|
12961
12961
|
var resolveCommand = require_resolveCommand();
|
|
12962
12962
|
var escape = require_escape();
|
|
12963
12963
|
var readShebang = require_readShebang();
|
|
@@ -12982,7 +12982,7 @@ var require_parse = __commonJS((exports3, module2) => {
|
|
|
12982
12982
|
const needsShell = !isExecutableRegExp.test(commandFile);
|
|
12983
12983
|
if (parsed.options.forceShell || needsShell) {
|
|
12984
12984
|
const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile);
|
|
12985
|
-
parsed.command =
|
|
12985
|
+
parsed.command = path6.normalize(parsed.command);
|
|
12986
12986
|
parsed.command = escape.command(parsed.command);
|
|
12987
12987
|
parsed.args = parsed.args.map((arg) => escape.argument(arg, needsDoubleEscapeMetaChars));
|
|
12988
12988
|
const shellCommand = [parsed.command].concat(parsed.args).join(" ");
|
|
@@ -16906,6 +16906,7 @@ var toolNames = [
|
|
|
16906
16906
|
"read_subtree",
|
|
16907
16907
|
"run_file_change_hooks",
|
|
16908
16908
|
"run_terminal_command",
|
|
16909
|
+
"send_message",
|
|
16909
16910
|
"set_messages",
|
|
16910
16911
|
"set_output",
|
|
16911
16912
|
"skill",
|
|
@@ -16914,6 +16915,12 @@ var toolNames = [
|
|
|
16914
16915
|
"str_replace",
|
|
16915
16916
|
"suggest_followups",
|
|
16916
16917
|
"task_completed",
|
|
16918
|
+
"task_create",
|
|
16919
|
+
"task_get",
|
|
16920
|
+
"task_list",
|
|
16921
|
+
"task_update",
|
|
16922
|
+
"team_create",
|
|
16923
|
+
"team_delete",
|
|
16917
16924
|
"think_deeply",
|
|
16918
16925
|
"update_subgoal",
|
|
16919
16926
|
"web_search",
|
|
@@ -18415,7 +18422,7 @@ function clearProposedContentForRun(runId) {
|
|
|
18415
18422
|
}
|
|
18416
18423
|
|
|
18417
18424
|
// ../common/src/tools/list.ts
|
|
18418
|
-
var
|
|
18425
|
+
var import_v459 = __toESM(require("zod/v4"));
|
|
18419
18426
|
|
|
18420
18427
|
// ../common/src/actions.ts
|
|
18421
18428
|
var import_v417 = require("zod/v4");
|
|
@@ -19828,18 +19835,79 @@ var runFileChangeHooksParams = {
|
|
|
19828
19835
|
]).array())
|
|
19829
19836
|
};
|
|
19830
19837
|
|
|
19831
|
-
// ../common/src/tools/params/tool/
|
|
19838
|
+
// ../common/src/tools/params/tool/send-message.ts
|
|
19832
19839
|
var import_v440 = __toESM(require("zod/v4"));
|
|
19833
|
-
var toolName20 = "
|
|
19834
|
-
var endsAgentStep20 =
|
|
19840
|
+
var toolName20 = "send_message";
|
|
19841
|
+
var endsAgentStep20 = false;
|
|
19835
19842
|
var inputSchema20 = import_v440.default.object({
|
|
19836
|
-
|
|
19837
|
-
|
|
19843
|
+
type: import_v440.default.enum([
|
|
19844
|
+
"message",
|
|
19845
|
+
"broadcast",
|
|
19846
|
+
"shutdown_request",
|
|
19847
|
+
"shutdown_response",
|
|
19848
|
+
"plan_approval_response"
|
|
19849
|
+
]).describe('Message type: "message" for DMs, "broadcast" to all teammates, "shutdown_request" to request shutdown, "shutdown_response" to respond to shutdown, "plan_approval_response" to approve/reject plans'),
|
|
19850
|
+
recipient: import_v440.default.string().optional().describe("Agent name of the recipient (required for message, shutdown_request, plan_approval_response)"),
|
|
19851
|
+
content: import_v440.default.string().optional().describe("Message text, reason, or feedback"),
|
|
19852
|
+
summary: import_v440.default.string().optional().describe("A 5-10 word summary of the message, shown as a preview in the UI (required for message, broadcast)"),
|
|
19853
|
+
request_id: import_v440.default.string().optional().describe("Request ID to respond to (required for shutdown_response, plan_approval_response)"),
|
|
19854
|
+
approve: import_v440.default.boolean().optional().describe("Whether to approve the request (required for shutdown_response, plan_approval_response)")
|
|
19855
|
+
}).describe(`Send a message to a teammate or broadcast to all teammates in the current team/swarm.`);
|
|
19838
19856
|
var description20 = `
|
|
19839
|
-
|
|
19857
|
+
Send messages to agent teammates and handle protocol requests/responses in a team.
|
|
19858
|
+
|
|
19859
|
+
Message types:
|
|
19860
|
+
- "message": Send a direct message to a specific teammate (requires recipient)
|
|
19861
|
+
- "broadcast": Send a message to all teammates (use sparingly)
|
|
19862
|
+
- "shutdown_request": Request a teammate to shut down (requires recipient)
|
|
19863
|
+
- "shutdown_response": Respond to a shutdown request (requires request_id, approve)
|
|
19864
|
+
- "plan_approval_response": Approve or reject a teammate's plan (requires request_id, recipient, approve)
|
|
19865
|
+
|
|
19866
|
+
Example - Direct message:
|
|
19840
19867
|
${$getNativeToolCallExampleString({
|
|
19841
19868
|
toolName: toolName20,
|
|
19842
19869
|
inputSchema: inputSchema20,
|
|
19870
|
+
input: {
|
|
19871
|
+
type: "message",
|
|
19872
|
+
recipient: "researcher",
|
|
19873
|
+
content: "Found the bug in the auth module",
|
|
19874
|
+
summary: "Auth bug found"
|
|
19875
|
+
},
|
|
19876
|
+
endsAgentStep: endsAgentStep20
|
|
19877
|
+
})}
|
|
19878
|
+
|
|
19879
|
+
Example - Broadcast:
|
|
19880
|
+
${$getNativeToolCallExampleString({
|
|
19881
|
+
toolName: toolName20,
|
|
19882
|
+
inputSchema: inputSchema20,
|
|
19883
|
+
input: {
|
|
19884
|
+
type: "broadcast",
|
|
19885
|
+
content: "Blocking issue found, please pause work",
|
|
19886
|
+
summary: "Critical blocking issue"
|
|
19887
|
+
},
|
|
19888
|
+
endsAgentStep: endsAgentStep20
|
|
19889
|
+
})}
|
|
19890
|
+
`.trim();
|
|
19891
|
+
var sendMessageParams = {
|
|
19892
|
+
toolName: toolName20,
|
|
19893
|
+
endsAgentStep: endsAgentStep20,
|
|
19894
|
+
description: description20,
|
|
19895
|
+
inputSchema: inputSchema20,
|
|
19896
|
+
outputSchema: textToolResultSchema()
|
|
19897
|
+
};
|
|
19898
|
+
|
|
19899
|
+
// ../common/src/tools/params/tool/set-messages.ts
|
|
19900
|
+
var import_v441 = __toESM(require("zod/v4"));
|
|
19901
|
+
var toolName21 = "set_messages";
|
|
19902
|
+
var endsAgentStep21 = true;
|
|
19903
|
+
var inputSchema21 = import_v441.default.object({
|
|
19904
|
+
messages: import_v441.default.any()
|
|
19905
|
+
}).describe(`Set the conversation history to the provided messages.`);
|
|
19906
|
+
var description21 = `
|
|
19907
|
+
Example:
|
|
19908
|
+
${$getNativeToolCallExampleString({
|
|
19909
|
+
toolName: toolName21,
|
|
19910
|
+
inputSchema: inputSchema21,
|
|
19843
19911
|
input: {
|
|
19844
19912
|
messages: [
|
|
19845
19913
|
{
|
|
@@ -19852,25 +19920,25 @@ ${$getNativeToolCallExampleString({
|
|
|
19852
19920
|
}
|
|
19853
19921
|
]
|
|
19854
19922
|
},
|
|
19855
|
-
endsAgentStep:
|
|
19923
|
+
endsAgentStep: endsAgentStep21
|
|
19856
19924
|
})}
|
|
19857
19925
|
`.trim();
|
|
19858
19926
|
var setMessagesParams = {
|
|
19859
|
-
toolName:
|
|
19860
|
-
endsAgentStep:
|
|
19861
|
-
description:
|
|
19862
|
-
inputSchema:
|
|
19927
|
+
toolName: toolName21,
|
|
19928
|
+
endsAgentStep: endsAgentStep21,
|
|
19929
|
+
description: description21,
|
|
19930
|
+
inputSchema: inputSchema21,
|
|
19863
19931
|
outputSchema: textToolResultSchema()
|
|
19864
19932
|
};
|
|
19865
19933
|
|
|
19866
19934
|
// ../common/src/tools/params/tool/set-output.ts
|
|
19867
|
-
var
|
|
19868
|
-
var
|
|
19869
|
-
var
|
|
19870
|
-
var
|
|
19871
|
-
data:
|
|
19935
|
+
var import_v442 = __toESM(require("zod/v4"));
|
|
19936
|
+
var toolName22 = "set_output";
|
|
19937
|
+
var endsAgentStep22 = false;
|
|
19938
|
+
var inputSchema22 = import_v442.default.looseObject({
|
|
19939
|
+
data: import_v442.default.record(import_v442.default.string(), import_v442.default.any()).optional()
|
|
19872
19940
|
}).describe("JSON object to set as the agent output. The shape of the parameters are specified dynamically further down in the conversation. This completely replaces any previous output. If the agent was spawned, this value will be passed back to its parent. If the agent has an outputSchema defined, the output will be validated against it.");
|
|
19873
|
-
var
|
|
19941
|
+
var description22 = `
|
|
19874
19942
|
Subagents must use this tool as it is the only way to report any findings. Nothing else you write will be visible to the user/parent agent.
|
|
19875
19943
|
|
|
19876
19944
|
Note that the output schema is provided dynamically in a user prompt further down in the conversation. Be sure to follow what the latest output schema is when using this tool.
|
|
@@ -19878,41 +19946,41 @@ Note that the output schema is provided dynamically in a user prompt further dow
|
|
|
19878
19946
|
Please set the output with all the information and analysis you want to pass on. If you just want to send a simple message, use an object with the key "message" and value of the message you want to send.
|
|
19879
19947
|
Example:
|
|
19880
19948
|
${$getNativeToolCallExampleString({
|
|
19881
|
-
toolName:
|
|
19882
|
-
inputSchema:
|
|
19949
|
+
toolName: toolName22,
|
|
19950
|
+
inputSchema: inputSchema22,
|
|
19883
19951
|
input: {
|
|
19884
19952
|
message: "I found a bug in the code!"
|
|
19885
19953
|
},
|
|
19886
|
-
endsAgentStep:
|
|
19954
|
+
endsAgentStep: endsAgentStep22
|
|
19887
19955
|
})}
|
|
19888
19956
|
`.trim();
|
|
19889
19957
|
var setOutputParams = {
|
|
19890
|
-
toolName:
|
|
19891
|
-
endsAgentStep:
|
|
19892
|
-
description:
|
|
19893
|
-
inputSchema:
|
|
19894
|
-
outputSchema:
|
|
19895
|
-
|
|
19896
|
-
type:
|
|
19897
|
-
value:
|
|
19898
|
-
message:
|
|
19958
|
+
toolName: toolName22,
|
|
19959
|
+
endsAgentStep: endsAgentStep22,
|
|
19960
|
+
description: description22,
|
|
19961
|
+
inputSchema: inputSchema22,
|
|
19962
|
+
outputSchema: import_v442.default.tuple([
|
|
19963
|
+
import_v442.default.object({
|
|
19964
|
+
type: import_v442.default.literal("json"),
|
|
19965
|
+
value: import_v442.default.object({
|
|
19966
|
+
message: import_v442.default.string()
|
|
19899
19967
|
})
|
|
19900
19968
|
})
|
|
19901
19969
|
])
|
|
19902
19970
|
};
|
|
19903
19971
|
|
|
19904
19972
|
// ../common/src/tools/params/tool/skill.ts
|
|
19905
|
-
var
|
|
19906
|
-
var
|
|
19907
|
-
var
|
|
19908
|
-
var
|
|
19909
|
-
name:
|
|
19973
|
+
var import_v443 = __toESM(require("zod/v4"));
|
|
19974
|
+
var toolName23 = "skill";
|
|
19975
|
+
var endsAgentStep23 = true;
|
|
19976
|
+
var inputSchema23 = import_v443.default.object({
|
|
19977
|
+
name: import_v443.default.string().min(1).describe("The name of the skill to load")
|
|
19910
19978
|
}).describe("Load a skill by name to get its full instructions. Skills provide reusable behaviors and instructions.");
|
|
19911
|
-
var outputValueSchema =
|
|
19912
|
-
name:
|
|
19913
|
-
description:
|
|
19914
|
-
content:
|
|
19915
|
-
license:
|
|
19979
|
+
var outputValueSchema = import_v443.default.object({
|
|
19980
|
+
name: import_v443.default.string(),
|
|
19981
|
+
description: import_v443.default.string(),
|
|
19982
|
+
content: import_v443.default.string(),
|
|
19983
|
+
license: import_v443.default.string().optional()
|
|
19916
19984
|
});
|
|
19917
19985
|
var AVAILABLE_SKILLS_PLACEHOLDER = "{{AVAILABLE_SKILLS}}";
|
|
19918
19986
|
var baseDescription = `Load a skill by name to get its full instructions. Skills provide reusable behaviors and domain-specific knowledge that you can use to complete tasks.
|
|
@@ -19921,32 +19989,32 @@ ${AVAILABLE_SKILLS_PLACEHOLDER}
|
|
|
19921
19989
|
|
|
19922
19990
|
Example:
|
|
19923
19991
|
${$getNativeToolCallExampleString({
|
|
19924
|
-
toolName:
|
|
19925
|
-
inputSchema:
|
|
19992
|
+
toolName: toolName23,
|
|
19993
|
+
inputSchema: inputSchema23,
|
|
19926
19994
|
input: {
|
|
19927
19995
|
name: "git-release"
|
|
19928
19996
|
},
|
|
19929
|
-
endsAgentStep:
|
|
19997
|
+
endsAgentStep: endsAgentStep23
|
|
19930
19998
|
})}
|
|
19931
19999
|
`;
|
|
19932
20000
|
var skillParams = {
|
|
19933
|
-
toolName:
|
|
19934
|
-
endsAgentStep:
|
|
20001
|
+
toolName: toolName23,
|
|
20002
|
+
endsAgentStep: endsAgentStep23,
|
|
19935
20003
|
description: baseDescription.trim(),
|
|
19936
|
-
inputSchema:
|
|
20004
|
+
inputSchema: inputSchema23,
|
|
19937
20005
|
outputSchema: jsonToolResultSchema(outputValueSchema)
|
|
19938
20006
|
};
|
|
19939
20007
|
|
|
19940
20008
|
// ../common/src/tools/params/tool/spawn-agent-inline.ts
|
|
19941
|
-
var
|
|
19942
|
-
var
|
|
19943
|
-
var
|
|
19944
|
-
var
|
|
19945
|
-
agent_type:
|
|
19946
|
-
prompt:
|
|
19947
|
-
params:
|
|
20009
|
+
var import_v444 = __toESM(require("zod/v4"));
|
|
20010
|
+
var toolName24 = "spawn_agent_inline";
|
|
20011
|
+
var endsAgentStep24 = true;
|
|
20012
|
+
var inputSchema24 = import_v444.default.object({
|
|
20013
|
+
agent_type: import_v444.default.string().describe("Agent to spawn"),
|
|
20014
|
+
prompt: import_v444.default.string().optional().describe("Prompt to send to the agent"),
|
|
20015
|
+
params: import_v444.default.record(import_v444.default.string(), import_v444.default.any()).optional().describe("Parameters object for the agent (if any)")
|
|
19948
20016
|
}).describe(`Spawn a single agent that runs within the current message history.`);
|
|
19949
|
-
var
|
|
20017
|
+
var description23 = `
|
|
19950
20018
|
Spawn a single agent that runs within the current message history.
|
|
19951
20019
|
The spawned agent sees all previous messages and any messages it adds
|
|
19952
20020
|
are preserved when control returns to you.
|
|
@@ -19960,39 +20028,41 @@ This is useful for:
|
|
|
19960
20028
|
The agent will run until it calls end_turn, then control returns to you. There is no tool result for this tool.
|
|
19961
20029
|
Example:
|
|
19962
20030
|
${$getNativeToolCallExampleString({
|
|
19963
|
-
toolName:
|
|
19964
|
-
inputSchema:
|
|
20031
|
+
toolName: toolName24,
|
|
20032
|
+
inputSchema: inputSchema24,
|
|
19965
20033
|
input: {
|
|
19966
20034
|
agent_type: "file-picker",
|
|
19967
20035
|
prompt: "Find files related to authentication",
|
|
19968
20036
|
params: { paths: ["src/auth.ts", "src/user.ts"] }
|
|
19969
20037
|
},
|
|
19970
|
-
endsAgentStep:
|
|
20038
|
+
endsAgentStep: endsAgentStep24
|
|
19971
20039
|
})}
|
|
19972
20040
|
`.trim();
|
|
19973
20041
|
var spawnAgentInlineParams = {
|
|
19974
|
-
toolName:
|
|
19975
|
-
endsAgentStep:
|
|
19976
|
-
description:
|
|
19977
|
-
inputSchema:
|
|
20042
|
+
toolName: toolName24,
|
|
20043
|
+
endsAgentStep: endsAgentStep24,
|
|
20044
|
+
description: description23,
|
|
20045
|
+
inputSchema: inputSchema24,
|
|
19978
20046
|
outputSchema: textToolResultSchema()
|
|
19979
20047
|
};
|
|
19980
20048
|
|
|
19981
20049
|
// ../common/src/tools/params/tool/spawn-agents.ts
|
|
19982
|
-
var
|
|
19983
|
-
var spawnAgentsOutputSchema =
|
|
19984
|
-
agentType:
|
|
20050
|
+
var import_v445 = __toESM(require("zod/v4"));
|
|
20051
|
+
var spawnAgentsOutputSchema = import_v445.default.object({
|
|
20052
|
+
agentType: import_v445.default.string()
|
|
19985
20053
|
}).and(jsonObjectSchema).array();
|
|
19986
|
-
var
|
|
19987
|
-
var
|
|
19988
|
-
var
|
|
19989
|
-
agents:
|
|
19990
|
-
agent_type:
|
|
19991
|
-
prompt:
|
|
19992
|
-
params:
|
|
20054
|
+
var toolName25 = "spawn_agents";
|
|
20055
|
+
var endsAgentStep25 = true;
|
|
20056
|
+
var inputSchema25 = import_v445.default.object({
|
|
20057
|
+
agents: import_v445.default.object({
|
|
20058
|
+
agent_type: import_v445.default.string().describe("Agent to spawn"),
|
|
20059
|
+
prompt: import_v445.default.string().optional().describe("Prompt to send to the agent"),
|
|
20060
|
+
params: import_v445.default.record(import_v445.default.string(), import_v445.default.any()).optional().describe("Parameters object for the agent (if any)"),
|
|
20061
|
+
team_name: import_v445.default.string().optional().describe("Optional team name to register this agent as a member of. The team must already exist (created via team_create)."),
|
|
20062
|
+
team_role: import_v445.default.string().optional().describe('Optional role for the agent within the team (e.g. "senior-engineer", "researcher"). Defaults to "mid-level-engineer".')
|
|
19993
20063
|
}).array()
|
|
19994
20064
|
}).describe(`Spawn multiple agents and send a prompt and/or parameters to each of them. These agents will run in parallel. Note that that means they will run independently. If you need to run agents sequentially, use spawn_agents with one agent at a time instead.`);
|
|
19995
|
-
var
|
|
20065
|
+
var description24 = `
|
|
19996
20066
|
Use this tool to spawn agents to help you complete the user request. Each agent has specific requirements for prompt and params based on their tools schema.
|
|
19997
20067
|
|
|
19998
20068
|
The prompt field is a simple string, while params is a JSON object that gets validated against the agent's schema.
|
|
@@ -20007,8 +20077,8 @@ You can call agents either as direct tool calls (e.g., \`example-agent\`) or use
|
|
|
20007
20077
|
|
|
20008
20078
|
Example:
|
|
20009
20079
|
${$getNativeToolCallExampleString({
|
|
20010
|
-
toolName:
|
|
20011
|
-
inputSchema:
|
|
20080
|
+
toolName: toolName25,
|
|
20081
|
+
inputSchema: inputSchema25,
|
|
20012
20082
|
input: {
|
|
20013
20083
|
agents: [
|
|
20014
20084
|
{
|
|
@@ -20026,32 +20096,32 @@ ${$getNativeToolCallExampleString({
|
|
|
20026
20096
|
}
|
|
20027
20097
|
]
|
|
20028
20098
|
},
|
|
20029
|
-
endsAgentStep:
|
|
20099
|
+
endsAgentStep: endsAgentStep25
|
|
20030
20100
|
})}
|
|
20031
20101
|
`.trim();
|
|
20032
20102
|
var spawnAgentsParams = {
|
|
20033
|
-
toolName:
|
|
20034
|
-
endsAgentStep:
|
|
20035
|
-
description:
|
|
20036
|
-
inputSchema:
|
|
20103
|
+
toolName: toolName25,
|
|
20104
|
+
endsAgentStep: endsAgentStep25,
|
|
20105
|
+
description: description24,
|
|
20106
|
+
inputSchema: inputSchema25,
|
|
20037
20107
|
outputSchema: jsonToolResultSchema(spawnAgentsOutputSchema)
|
|
20038
20108
|
};
|
|
20039
20109
|
|
|
20040
20110
|
// ../common/src/tools/params/tool/suggest-followups.ts
|
|
20041
|
-
var
|
|
20042
|
-
var
|
|
20043
|
-
var
|
|
20044
|
-
var followupSchema =
|
|
20045
|
-
prompt:
|
|
20046
|
-
label:
|
|
20111
|
+
var import_v446 = __toESM(require("zod/v4"));
|
|
20112
|
+
var toolName26 = "suggest_followups";
|
|
20113
|
+
var endsAgentStep26 = false;
|
|
20114
|
+
var followupSchema = import_v446.default.object({
|
|
20115
|
+
prompt: import_v446.default.string().describe("The full prompt text to send as a user message when clicked"),
|
|
20116
|
+
label: import_v446.default.string().optional().describe("Short display label for the card (defaults to truncated prompt if not provided)")
|
|
20047
20117
|
});
|
|
20048
|
-
var
|
|
20049
|
-
followups:
|
|
20118
|
+
var inputSchema26 = import_v446.default.object({
|
|
20119
|
+
followups: import_v446.default.array(followupSchema).min(1, "Must provide at least one followup").describe("List of suggested followup prompts the user can click to send")
|
|
20050
20120
|
}).describe(`Suggest clickable followup prompts to the user. Each followup becomes a card the user can click to send that prompt.`);
|
|
20051
|
-
var outputSchema2 =
|
|
20052
|
-
message:
|
|
20121
|
+
var outputSchema2 = import_v446.default.object({
|
|
20122
|
+
message: import_v446.default.string()
|
|
20053
20123
|
});
|
|
20054
|
-
var
|
|
20124
|
+
var description25 = `
|
|
20055
20125
|
Suggest clickable followup prompts to the user. When the user clicks a suggestion, it sends that prompt as a new user message.
|
|
20056
20126
|
|
|
20057
20127
|
Use this tool after completing a task to suggest what the user might want to do next. Good suggestions include:
|
|
@@ -20070,8 +20140,8 @@ Try to make different suggestions than you did in past steps. That's because use
|
|
|
20070
20140
|
Aim for around 3 suggestions. The suggestions persist and remain clickable, with clicked ones visually updated to show they were used.
|
|
20071
20141
|
|
|
20072
20142
|
${$getNativeToolCallExampleString({
|
|
20073
|
-
toolName:
|
|
20074
|
-
inputSchema:
|
|
20143
|
+
toolName: toolName26,
|
|
20144
|
+
inputSchema: inputSchema26,
|
|
20075
20145
|
input: {
|
|
20076
20146
|
followups: [
|
|
20077
20147
|
{
|
|
@@ -20088,28 +20158,28 @@ ${$getNativeToolCallExampleString({
|
|
|
20088
20158
|
}
|
|
20089
20159
|
]
|
|
20090
20160
|
},
|
|
20091
|
-
endsAgentStep:
|
|
20161
|
+
endsAgentStep: endsAgentStep26
|
|
20092
20162
|
})}
|
|
20093
20163
|
`.trim();
|
|
20094
20164
|
var suggestFollowupsParams = {
|
|
20095
|
-
toolName:
|
|
20096
|
-
endsAgentStep:
|
|
20097
|
-
description:
|
|
20098
|
-
inputSchema:
|
|
20165
|
+
toolName: toolName26,
|
|
20166
|
+
endsAgentStep: endsAgentStep26,
|
|
20167
|
+
description: description25,
|
|
20168
|
+
inputSchema: inputSchema26,
|
|
20099
20169
|
outputSchema: jsonToolResultSchema(outputSchema2)
|
|
20100
20170
|
};
|
|
20101
20171
|
|
|
20102
20172
|
// ../common/src/tools/params/tool/task-completed.ts
|
|
20103
|
-
var
|
|
20104
|
-
var
|
|
20105
|
-
var
|
|
20106
|
-
var
|
|
20173
|
+
var import_v447 = __toESM(require("zod/v4"));
|
|
20174
|
+
var toolName27 = "task_completed";
|
|
20175
|
+
var endsAgentStep27 = true;
|
|
20176
|
+
var inputSchema27 = import_v447.default.object({}).describe(`Signal that the task is complete. Use this tool when:
|
|
20107
20177
|
- The user's request is completely fulfilled
|
|
20108
20178
|
- You need clarification from the user before continuing
|
|
20109
20179
|
- You are stuck or need help from the user to continue
|
|
20110
20180
|
|
|
20111
20181
|
This tool explicitly marks the end of your work on the current task.`);
|
|
20112
|
-
var
|
|
20182
|
+
var description26 = `
|
|
20113
20183
|
Use this tool to signal that the task is complete.
|
|
20114
20184
|
|
|
20115
20185
|
- When to use:
|
|
@@ -20129,36 +20199,248 @@ Use this tool to signal that the task is complete.
|
|
|
20129
20199
|
|
|
20130
20200
|
All changes have been implemented and tested successfully!
|
|
20131
20201
|
|
|
20132
|
-
${$getNativeToolCallExampleString({ toolName:
|
|
20202
|
+
${$getNativeToolCallExampleString({ toolName: toolName27, inputSchema: inputSchema27, input: {}, endsAgentStep: endsAgentStep27 })}
|
|
20133
20203
|
|
|
20134
20204
|
OR
|
|
20135
20205
|
|
|
20136
20206
|
I need more information to proceed. Which database schema should I use for this migration?
|
|
20137
20207
|
|
|
20138
|
-
${$getNativeToolCallExampleString({ toolName:
|
|
20208
|
+
${$getNativeToolCallExampleString({ toolName: toolName27, inputSchema: inputSchema27, input: {}, endsAgentStep: endsAgentStep27 })}
|
|
20139
20209
|
|
|
20140
20210
|
OR
|
|
20141
20211
|
|
|
20142
20212
|
I can't get the tests to pass after several different attempts. I need help from the user to proceed.
|
|
20143
20213
|
|
|
20144
|
-
${$getNativeToolCallExampleString({ toolName:
|
|
20214
|
+
${$getNativeToolCallExampleString({ toolName: toolName27, inputSchema: inputSchema27, input: {}, endsAgentStep: endsAgentStep27 })}
|
|
20145
20215
|
`.trim();
|
|
20146
20216
|
var taskCompletedParams = {
|
|
20147
|
-
toolName:
|
|
20148
|
-
endsAgentStep:
|
|
20149
|
-
description:
|
|
20150
|
-
inputSchema:
|
|
20217
|
+
toolName: toolName27,
|
|
20218
|
+
endsAgentStep: endsAgentStep27,
|
|
20219
|
+
description: description26,
|
|
20220
|
+
inputSchema: inputSchema27,
|
|
20221
|
+
outputSchema: textToolResultSchema()
|
|
20222
|
+
};
|
|
20223
|
+
|
|
20224
|
+
// ../common/src/tools/params/tool/task-create.ts
|
|
20225
|
+
var import_v448 = __toESM(require("zod/v4"));
|
|
20226
|
+
var toolName28 = "task_create";
|
|
20227
|
+
var endsAgentStep28 = false;
|
|
20228
|
+
var inputSchema28 = import_v448.default.object({
|
|
20229
|
+
subject: import_v448.default.string().describe("A brief, actionable title for the task"),
|
|
20230
|
+
description: import_v448.default.string().describe("A detailed description of what needs to be done"),
|
|
20231
|
+
activeForm: import_v448.default.string().optional().describe('Present continuous form shown in spinner when in_progress (e.g., "Running tests")'),
|
|
20232
|
+
metadata: import_v448.default.record(import_v448.default.string(), import_v448.default.unknown()).optional().describe("Arbitrary metadata to attach to the task")
|
|
20233
|
+
}).describe(`Create a new task in the team task list for tracking work items.`);
|
|
20234
|
+
var description27 = `
|
|
20235
|
+
Create a structured task for tracking work in the current team/swarm.
|
|
20236
|
+
|
|
20237
|
+
- When to use: When a task requires multiple steps or needs to be tracked and coordinated across agents.
|
|
20238
|
+
- The subject should be imperative (e.g., "Fix authentication bug").
|
|
20239
|
+
- The activeForm should be present continuous (e.g., "Fixing authentication bug").
|
|
20240
|
+
- New tasks are created with status "pending".
|
|
20241
|
+
|
|
20242
|
+
Example:
|
|
20243
|
+
${$getNativeToolCallExampleString({
|
|
20244
|
+
toolName: toolName28,
|
|
20245
|
+
inputSchema: inputSchema28,
|
|
20246
|
+
input: {
|
|
20247
|
+
subject: "Fix authentication bug in login flow",
|
|
20248
|
+
description: "The login endpoint returns 500 when password contains special characters",
|
|
20249
|
+
activeForm: "Fixing authentication bug"
|
|
20250
|
+
},
|
|
20251
|
+
endsAgentStep: endsAgentStep28
|
|
20252
|
+
})}
|
|
20253
|
+
`.trim();
|
|
20254
|
+
var taskCreateParams = {
|
|
20255
|
+
toolName: toolName28,
|
|
20256
|
+
endsAgentStep: endsAgentStep28,
|
|
20257
|
+
description: description27,
|
|
20258
|
+
inputSchema: inputSchema28,
|
|
20259
|
+
outputSchema: textToolResultSchema()
|
|
20260
|
+
};
|
|
20261
|
+
|
|
20262
|
+
// ../common/src/tools/params/tool/task-get.ts
|
|
20263
|
+
var import_v449 = __toESM(require("zod/v4"));
|
|
20264
|
+
var toolName29 = "task_get";
|
|
20265
|
+
var endsAgentStep29 = false;
|
|
20266
|
+
var inputSchema29 = import_v449.default.object({
|
|
20267
|
+
taskId: import_v449.default.string().describe("The ID of the task to retrieve")
|
|
20268
|
+
}).describe(`Retrieve a task by its ID from the team task list.`);
|
|
20269
|
+
var description28 = `
|
|
20270
|
+
Retrieve the full details of a task by its ID.
|
|
20271
|
+
|
|
20272
|
+
- When to use: When you need the full description and context before starting work on a task.
|
|
20273
|
+
- Returns: subject, description, status, blocks, blockedBy, and other task details.
|
|
20274
|
+
|
|
20275
|
+
Example:
|
|
20276
|
+
${$getNativeToolCallExampleString({
|
|
20277
|
+
toolName: toolName29,
|
|
20278
|
+
inputSchema: inputSchema29,
|
|
20279
|
+
input: {
|
|
20280
|
+
taskId: "1"
|
|
20281
|
+
},
|
|
20282
|
+
endsAgentStep: endsAgentStep29
|
|
20283
|
+
})}
|
|
20284
|
+
`.trim();
|
|
20285
|
+
var taskGetParams = {
|
|
20286
|
+
toolName: toolName29,
|
|
20287
|
+
endsAgentStep: endsAgentStep29,
|
|
20288
|
+
description: description28,
|
|
20289
|
+
inputSchema: inputSchema29,
|
|
20290
|
+
outputSchema: textToolResultSchema()
|
|
20291
|
+
};
|
|
20292
|
+
|
|
20293
|
+
// ../common/src/tools/params/tool/task-list.ts
|
|
20294
|
+
var import_v450 = __toESM(require("zod/v4"));
|
|
20295
|
+
var toolName30 = "task_list";
|
|
20296
|
+
var endsAgentStep30 = false;
|
|
20297
|
+
var inputSchema30 = import_v450.default.object({}).describe(`List all tasks in the team task list.`);
|
|
20298
|
+
var description29 = `
|
|
20299
|
+
List all tasks in the current team's task list.
|
|
20300
|
+
|
|
20301
|
+
- When to use: To see available tasks, check progress, or find unblocked work to claim.
|
|
20302
|
+
- Returns a summary of each task: id, subject, status, owner, blockedBy.
|
|
20303
|
+
|
|
20304
|
+
Example:
|
|
20305
|
+
${$getNativeToolCallExampleString({
|
|
20306
|
+
toolName: toolName30,
|
|
20307
|
+
inputSchema: inputSchema30,
|
|
20308
|
+
input: {},
|
|
20309
|
+
endsAgentStep: endsAgentStep30
|
|
20310
|
+
})}
|
|
20311
|
+
`.trim();
|
|
20312
|
+
var taskListParams = {
|
|
20313
|
+
toolName: toolName30,
|
|
20314
|
+
endsAgentStep: endsAgentStep30,
|
|
20315
|
+
description: description29,
|
|
20316
|
+
inputSchema: inputSchema30,
|
|
20317
|
+
outputSchema: textToolResultSchema()
|
|
20318
|
+
};
|
|
20319
|
+
|
|
20320
|
+
// ../common/src/tools/params/tool/task-update.ts
|
|
20321
|
+
var import_v451 = __toESM(require("zod/v4"));
|
|
20322
|
+
var toolName31 = "task_update";
|
|
20323
|
+
var endsAgentStep31 = false;
|
|
20324
|
+
var inputSchema31 = import_v451.default.object({
|
|
20325
|
+
taskId: import_v451.default.string().describe("The ID of the task to update"),
|
|
20326
|
+
status: import_v451.default.string().optional().describe('New status for the task: "pending", "in_progress", "completed", or "deleted"'),
|
|
20327
|
+
subject: import_v451.default.string().optional().describe("New subject for the task"),
|
|
20328
|
+
description: import_v451.default.string().optional().describe("New description for the task"),
|
|
20329
|
+
activeForm: import_v451.default.string().optional().describe('Present continuous form shown in spinner when in_progress (e.g., "Running tests")'),
|
|
20330
|
+
owner: import_v451.default.string().optional().describe("New owner for the task (agent name)"),
|
|
20331
|
+
addBlocks: import_v451.default.array(import_v451.default.string()).optional().describe("Task IDs that this task blocks"),
|
|
20332
|
+
addBlockedBy: import_v451.default.array(import_v451.default.string()).optional().describe("Task IDs that block this task"),
|
|
20333
|
+
metadata: import_v451.default.record(import_v451.default.string(), import_v451.default.unknown()).optional().describe("Metadata keys to merge into the task. Set a key to null to delete it.")
|
|
20334
|
+
}).describe(`Update an existing task in the team task list.`);
|
|
20335
|
+
var description30 = `
|
|
20336
|
+
Update a task's status, details, or dependencies.
|
|
20337
|
+
|
|
20338
|
+
- When to use: To mark tasks as in_progress, completed, or to update task details.
|
|
20339
|
+
- Status workflow: pending -> in_progress -> completed. Use "deleted" to remove a task.
|
|
20340
|
+
- Only mark a task as completed when you have fully accomplished it.
|
|
20341
|
+
|
|
20342
|
+
Example - Mark as in progress:
|
|
20343
|
+
${$getNativeToolCallExampleString({
|
|
20344
|
+
toolName: toolName31,
|
|
20345
|
+
inputSchema: inputSchema31,
|
|
20346
|
+
input: {
|
|
20347
|
+
taskId: "1",
|
|
20348
|
+
status: "in_progress"
|
|
20349
|
+
},
|
|
20350
|
+
endsAgentStep: endsAgentStep31
|
|
20351
|
+
})}
|
|
20352
|
+
|
|
20353
|
+
Example - Mark as completed:
|
|
20354
|
+
${$getNativeToolCallExampleString({
|
|
20355
|
+
toolName: toolName31,
|
|
20356
|
+
inputSchema: inputSchema31,
|
|
20357
|
+
input: {
|
|
20358
|
+
taskId: "1",
|
|
20359
|
+
status: "completed"
|
|
20360
|
+
},
|
|
20361
|
+
endsAgentStep: endsAgentStep31
|
|
20362
|
+
})}
|
|
20363
|
+
`.trim();
|
|
20364
|
+
var taskUpdateParams = {
|
|
20365
|
+
toolName: toolName31,
|
|
20366
|
+
endsAgentStep: endsAgentStep31,
|
|
20367
|
+
description: description30,
|
|
20368
|
+
inputSchema: inputSchema31,
|
|
20369
|
+
outputSchema: textToolResultSchema()
|
|
20370
|
+
};
|
|
20371
|
+
|
|
20372
|
+
// ../common/src/tools/params/tool/team-create.ts
|
|
20373
|
+
var import_v452 = __toESM(require("zod/v4"));
|
|
20374
|
+
var toolName32 = "team_create";
|
|
20375
|
+
var endsAgentStep32 = false;
|
|
20376
|
+
var inputSchema32 = import_v452.default.object({
|
|
20377
|
+
team_name: import_v452.default.string().describe("Name of the team to create"),
|
|
20378
|
+
description: import_v452.default.string().optional().describe("Optional description of the team purpose"),
|
|
20379
|
+
agent_type: import_v452.default.string().optional().describe("Optional agent type template to use for the team")
|
|
20380
|
+
}).describe(`Create a new team/swarm with the given name and optional configuration.`);
|
|
20381
|
+
var description31 = `
|
|
20382
|
+
Create a new team for collaborative multi-agent work.
|
|
20383
|
+
|
|
20384
|
+
- When to use: When you need to create a new team/swarm to coordinate multiple agents on a task.
|
|
20385
|
+
- Before calling: Ensure the team name is unique and descriptive.
|
|
20386
|
+
- Effect: Creates a new team context that agents can be spawned into.
|
|
20387
|
+
|
|
20388
|
+
Example:
|
|
20389
|
+
${$getNativeToolCallExampleString({
|
|
20390
|
+
toolName: toolName32,
|
|
20391
|
+
inputSchema: inputSchema32,
|
|
20392
|
+
input: {
|
|
20393
|
+
team_name: "backend-refactor",
|
|
20394
|
+
description: "Team for refactoring the backend API layer",
|
|
20395
|
+
agent_type: "coordinator"
|
|
20396
|
+
},
|
|
20397
|
+
endsAgentStep: endsAgentStep32
|
|
20398
|
+
})}
|
|
20399
|
+
`.trim();
|
|
20400
|
+
var teamCreateParams = {
|
|
20401
|
+
toolName: toolName32,
|
|
20402
|
+
endsAgentStep: endsAgentStep32,
|
|
20403
|
+
description: description31,
|
|
20404
|
+
inputSchema: inputSchema32,
|
|
20405
|
+
outputSchema: textToolResultSchema()
|
|
20406
|
+
};
|
|
20407
|
+
|
|
20408
|
+
// ../common/src/tools/params/tool/team-delete.ts
|
|
20409
|
+
var import_v453 = __toESM(require("zod/v4"));
|
|
20410
|
+
var toolName33 = "team_delete";
|
|
20411
|
+
var endsAgentStep33 = false;
|
|
20412
|
+
var inputSchema33 = import_v453.default.object({}).describe(`Delete the current team/swarm. Uses the current team context to determine which team to delete.`);
|
|
20413
|
+
var description32 = `
|
|
20414
|
+
Delete the current team and clean up all associated resources.
|
|
20415
|
+
|
|
20416
|
+
- When to use: When a team's work is complete and it should be disbanded.
|
|
20417
|
+
- Before calling: Ensure all agents in the team have completed their work.
|
|
20418
|
+
- Effect: Removes the team context and all associated state.
|
|
20419
|
+
|
|
20420
|
+
Example:
|
|
20421
|
+
${$getNativeToolCallExampleString({
|
|
20422
|
+
toolName: toolName33,
|
|
20423
|
+
inputSchema: inputSchema33,
|
|
20424
|
+
input: {},
|
|
20425
|
+
endsAgentStep: endsAgentStep33
|
|
20426
|
+
})}
|
|
20427
|
+
`.trim();
|
|
20428
|
+
var teamDeleteParams = {
|
|
20429
|
+
toolName: toolName33,
|
|
20430
|
+
endsAgentStep: endsAgentStep33,
|
|
20431
|
+
description: description32,
|
|
20432
|
+
inputSchema: inputSchema33,
|
|
20151
20433
|
outputSchema: textToolResultSchema()
|
|
20152
20434
|
};
|
|
20153
20435
|
|
|
20154
20436
|
// ../common/src/tools/params/tool/think-deeply.ts
|
|
20155
|
-
var
|
|
20156
|
-
var
|
|
20157
|
-
var
|
|
20158
|
-
var
|
|
20159
|
-
thought:
|
|
20437
|
+
var import_v454 = __toESM(require("zod/v4"));
|
|
20438
|
+
var toolName34 = "think_deeply";
|
|
20439
|
+
var endsAgentStep34 = false;
|
|
20440
|
+
var inputSchema34 = import_v454.default.object({
|
|
20441
|
+
thought: import_v454.default.string().min(1, "Thought cannot be empty").describe(`Detailed step-by-step analysis. Initially keep each step concise (max ~5-7 words per step).`)
|
|
20160
20442
|
}).describe(`Deeply consider complex tasks by brainstorming approaches and tradeoffs step-by-step.`);
|
|
20161
|
-
var
|
|
20443
|
+
var description33 = `
|
|
20162
20444
|
Use when user request:
|
|
20163
20445
|
- Explicitly asks for deep planning.
|
|
20164
20446
|
- Requires multi-file changes or complex logic.
|
|
@@ -20170,8 +20452,8 @@ This tool does not generate a tool result.
|
|
|
20170
20452
|
|
|
20171
20453
|
Example:
|
|
20172
20454
|
${$getNativeToolCallExampleString({
|
|
20173
|
-
toolName:
|
|
20174
|
-
inputSchema:
|
|
20455
|
+
toolName: toolName34,
|
|
20456
|
+
inputSchema: inputSchema34,
|
|
20175
20457
|
input: {
|
|
20176
20458
|
thought: [
|
|
20177
20459
|
"1. Check current user authentication",
|
|
@@ -20181,94 +20463,94 @@ ${$getNativeToolCallExampleString({
|
|
|
20181
20463
|
].join(`
|
|
20182
20464
|
`)
|
|
20183
20465
|
},
|
|
20184
|
-
endsAgentStep:
|
|
20466
|
+
endsAgentStep: endsAgentStep34
|
|
20185
20467
|
})}
|
|
20186
20468
|
`.trim();
|
|
20187
20469
|
var thinkDeeplyParams = {
|
|
20188
|
-
toolName:
|
|
20189
|
-
endsAgentStep:
|
|
20190
|
-
description:
|
|
20191
|
-
inputSchema:
|
|
20470
|
+
toolName: toolName34,
|
|
20471
|
+
endsAgentStep: endsAgentStep34,
|
|
20472
|
+
description: description33,
|
|
20473
|
+
inputSchema: inputSchema34,
|
|
20192
20474
|
outputSchema: textToolResultSchema()
|
|
20193
20475
|
};
|
|
20194
20476
|
|
|
20195
20477
|
// ../common/src/tools/params/tool/update-subgoal.ts
|
|
20196
|
-
var
|
|
20197
|
-
var
|
|
20198
|
-
var
|
|
20199
|
-
var
|
|
20200
|
-
id:
|
|
20201
|
-
status:
|
|
20202
|
-
plan:
|
|
20203
|
-
log:
|
|
20478
|
+
var import_v455 = __toESM(require("zod/v4"));
|
|
20479
|
+
var toolName35 = "update_subgoal";
|
|
20480
|
+
var endsAgentStep35 = false;
|
|
20481
|
+
var inputSchema35 = import_v455.default.object({
|
|
20482
|
+
id: import_v455.default.string().min(1, "Id cannot be empty").describe(`The id of the subgoal to update.`),
|
|
20483
|
+
status: import_v455.default.enum(["NOT_STARTED", "IN_PROGRESS", "COMPLETE", "ABORTED"]).optional().describe(`Change the status of the subgoal.`),
|
|
20484
|
+
plan: import_v455.default.string().optional().describe(`Change the plan for the subgoal.`),
|
|
20485
|
+
log: import_v455.default.string().optional().describe(`Add a log message to the subgoal. This will create a new log entry and append it to the existing logs. Use this to record your progress and any new information you learned as you go.`)
|
|
20204
20486
|
}).describe(`Update a subgoal in the context given the id, and optionally the status or plan, or a new log to append. Feel free to update any combination of the status, plan, or log in one invocation.`);
|
|
20205
|
-
var
|
|
20487
|
+
var description34 = `
|
|
20206
20488
|
Examples:
|
|
20207
20489
|
|
|
20208
20490
|
Usage 1 (update status):
|
|
20209
20491
|
${$getNativeToolCallExampleString({
|
|
20210
|
-
toolName:
|
|
20211
|
-
inputSchema:
|
|
20492
|
+
toolName: toolName35,
|
|
20493
|
+
inputSchema: inputSchema35,
|
|
20212
20494
|
input: {
|
|
20213
20495
|
id: "1",
|
|
20214
20496
|
status: "COMPLETE"
|
|
20215
20497
|
},
|
|
20216
|
-
endsAgentStep:
|
|
20498
|
+
endsAgentStep: endsAgentStep35
|
|
20217
20499
|
})}
|
|
20218
20500
|
|
|
20219
20501
|
Usage 2 (update plan):
|
|
20220
20502
|
${$getNativeToolCallExampleString({
|
|
20221
|
-
toolName:
|
|
20222
|
-
inputSchema:
|
|
20503
|
+
toolName: toolName35,
|
|
20504
|
+
inputSchema: inputSchema35,
|
|
20223
20505
|
input: {
|
|
20224
20506
|
id: "3",
|
|
20225
20507
|
plan: "Create file for endpoint in the api. Register it in the router."
|
|
20226
20508
|
},
|
|
20227
|
-
endsAgentStep:
|
|
20509
|
+
endsAgentStep: endsAgentStep35
|
|
20228
20510
|
})}
|
|
20229
20511
|
|
|
20230
20512
|
Usage 3 (add log):
|
|
20231
20513
|
${$getNativeToolCallExampleString({
|
|
20232
|
-
toolName:
|
|
20233
|
-
inputSchema:
|
|
20514
|
+
toolName: toolName35,
|
|
20515
|
+
inputSchema: inputSchema35,
|
|
20234
20516
|
input: {
|
|
20235
20517
|
id: "1",
|
|
20236
20518
|
log: "Found the error in the tests. Culprit: foo function."
|
|
20237
20519
|
},
|
|
20238
|
-
endsAgentStep:
|
|
20520
|
+
endsAgentStep: endsAgentStep35
|
|
20239
20521
|
})}
|
|
20240
20522
|
|
|
20241
20523
|
Usage 4 (update status and add log):
|
|
20242
20524
|
${$getNativeToolCallExampleString({
|
|
20243
|
-
toolName:
|
|
20244
|
-
inputSchema:
|
|
20525
|
+
toolName: toolName35,
|
|
20526
|
+
inputSchema: inputSchema35,
|
|
20245
20527
|
input: {
|
|
20246
20528
|
id: "1",
|
|
20247
20529
|
status: "COMPLETE",
|
|
20248
20530
|
log: "Reran the tests (passed)"
|
|
20249
20531
|
},
|
|
20250
|
-
endsAgentStep:
|
|
20532
|
+
endsAgentStep: endsAgentStep35
|
|
20251
20533
|
})}
|
|
20252
20534
|
`.trim();
|
|
20253
20535
|
var updateSubgoalParams = {
|
|
20254
|
-
toolName:
|
|
20255
|
-
endsAgentStep:
|
|
20256
|
-
description:
|
|
20257
|
-
inputSchema:
|
|
20258
|
-
outputSchema: jsonToolResultSchema(
|
|
20259
|
-
message:
|
|
20536
|
+
toolName: toolName35,
|
|
20537
|
+
endsAgentStep: endsAgentStep35,
|
|
20538
|
+
description: description34,
|
|
20539
|
+
inputSchema: inputSchema35,
|
|
20540
|
+
outputSchema: jsonToolResultSchema(import_v455.default.object({
|
|
20541
|
+
message: import_v455.default.string()
|
|
20260
20542
|
}))
|
|
20261
20543
|
};
|
|
20262
20544
|
|
|
20263
20545
|
// ../common/src/tools/params/tool/web-search.ts
|
|
20264
|
-
var
|
|
20265
|
-
var
|
|
20266
|
-
var
|
|
20267
|
-
var
|
|
20268
|
-
query:
|
|
20269
|
-
depth:
|
|
20546
|
+
var import_v456 = __toESM(require("zod/v4"));
|
|
20547
|
+
var toolName36 = "web_search";
|
|
20548
|
+
var endsAgentStep36 = true;
|
|
20549
|
+
var inputSchema36 = import_v456.default.object({
|
|
20550
|
+
query: import_v456.default.string().min(1, "Query cannot be empty").describe(`The search query to find relevant web content`),
|
|
20551
|
+
depth: import_v456.default.enum(["standard", "deep"]).optional().default("standard").describe(`Search depth - 'standard' for quick results, 'deep' for more comprehensive search. Default is 'standard'.`)
|
|
20270
20552
|
}).describe(`Search the web for current information using Linkup API.`);
|
|
20271
|
-
var
|
|
20553
|
+
var description35 = `
|
|
20272
20554
|
Purpose: Search the web for current, up-to-date information on any topic. This tool uses Linkup's web search API to find relevant content from across the internet.
|
|
20273
20555
|
|
|
20274
20556
|
Use cases:
|
|
@@ -20282,50 +20564,50 @@ The tool will return search results with titles, URLs, and content snippets.
|
|
|
20282
20564
|
|
|
20283
20565
|
Example:
|
|
20284
20566
|
${$getNativeToolCallExampleString({
|
|
20285
|
-
toolName:
|
|
20286
|
-
inputSchema:
|
|
20567
|
+
toolName: toolName36,
|
|
20568
|
+
inputSchema: inputSchema36,
|
|
20287
20569
|
input: {
|
|
20288
20570
|
query: "Next.js 15 new features",
|
|
20289
20571
|
depth: "standard"
|
|
20290
20572
|
},
|
|
20291
|
-
endsAgentStep:
|
|
20573
|
+
endsAgentStep: endsAgentStep36
|
|
20292
20574
|
})}
|
|
20293
20575
|
|
|
20294
20576
|
${$getNativeToolCallExampleString({
|
|
20295
|
-
toolName:
|
|
20296
|
-
inputSchema:
|
|
20577
|
+
toolName: toolName36,
|
|
20578
|
+
inputSchema: inputSchema36,
|
|
20297
20579
|
input: {
|
|
20298
20580
|
query: "React Server Components tutorial",
|
|
20299
20581
|
depth: "deep"
|
|
20300
20582
|
},
|
|
20301
|
-
endsAgentStep:
|
|
20583
|
+
endsAgentStep: endsAgentStep36
|
|
20302
20584
|
})}
|
|
20303
20585
|
`.trim();
|
|
20304
20586
|
var webSearchParams = {
|
|
20305
|
-
toolName:
|
|
20306
|
-
endsAgentStep:
|
|
20307
|
-
description:
|
|
20308
|
-
inputSchema:
|
|
20309
|
-
outputSchema: jsonToolResultSchema(
|
|
20310
|
-
|
|
20311
|
-
result:
|
|
20587
|
+
toolName: toolName36,
|
|
20588
|
+
endsAgentStep: endsAgentStep36,
|
|
20589
|
+
description: description35,
|
|
20590
|
+
inputSchema: inputSchema36,
|
|
20591
|
+
outputSchema: jsonToolResultSchema(import_v456.default.union([
|
|
20592
|
+
import_v456.default.object({
|
|
20593
|
+
result: import_v456.default.string()
|
|
20312
20594
|
}),
|
|
20313
|
-
|
|
20314
|
-
errorMessage:
|
|
20595
|
+
import_v456.default.object({
|
|
20596
|
+
errorMessage: import_v456.default.string()
|
|
20315
20597
|
})
|
|
20316
20598
|
]))
|
|
20317
20599
|
};
|
|
20318
20600
|
|
|
20319
20601
|
// ../common/src/tools/params/tool/write-file.ts
|
|
20320
|
-
var
|
|
20321
|
-
var
|
|
20322
|
-
var
|
|
20323
|
-
var
|
|
20324
|
-
path:
|
|
20325
|
-
instructions:
|
|
20326
|
-
content:
|
|
20602
|
+
var import_v457 = __toESM(require("zod/v4"));
|
|
20603
|
+
var toolName37 = "write_file";
|
|
20604
|
+
var endsAgentStep37 = false;
|
|
20605
|
+
var inputSchema37 = import_v457.default.object({
|
|
20606
|
+
path: import_v457.default.string().min(1, "Path cannot be empty").describe(`Path to the file relative to the **project root**`),
|
|
20607
|
+
instructions: import_v457.default.string().describe("What the change is intended to do in only one sentence."),
|
|
20608
|
+
content: import_v457.default.string().describe(`Edit snippet to apply to the file.`)
|
|
20327
20609
|
}).describe(`Create or edit a file with the given content.`);
|
|
20328
|
-
var
|
|
20610
|
+
var description36 = `
|
|
20329
20611
|
Create or replace a file with the given content.
|
|
20330
20612
|
|
|
20331
20613
|
#### Edit Snippet
|
|
@@ -20346,20 +20628,20 @@ Examples:
|
|
|
20346
20628
|
|
|
20347
20629
|
Example 1 - Simple file creation:
|
|
20348
20630
|
${$getNativeToolCallExampleString({
|
|
20349
|
-
toolName:
|
|
20350
|
-
inputSchema:
|
|
20631
|
+
toolName: toolName37,
|
|
20632
|
+
inputSchema: inputSchema37,
|
|
20351
20633
|
input: {
|
|
20352
20634
|
path: "new-file.ts",
|
|
20353
20635
|
instructions: "Prints Hello, world",
|
|
20354
20636
|
content: 'console.log("Hello, world!");'
|
|
20355
20637
|
},
|
|
20356
|
-
endsAgentStep:
|
|
20638
|
+
endsAgentStep: endsAgentStep37
|
|
20357
20639
|
})}
|
|
20358
20640
|
|
|
20359
20641
|
Example 2 - Editing with placeholder comments:
|
|
20360
20642
|
${$getNativeToolCallExampleString({
|
|
20361
|
-
toolName:
|
|
20362
|
-
inputSchema:
|
|
20643
|
+
toolName: toolName37,
|
|
20644
|
+
inputSchema: inputSchema37,
|
|
20363
20645
|
input: {
|
|
20364
20646
|
path: "foo.ts",
|
|
20365
20647
|
instructions: "Update foo and remove console.log",
|
|
@@ -20379,28 +20661,28 @@ function foo() {
|
|
|
20379
20661
|
|
|
20380
20662
|
// ... existing code ...`
|
|
20381
20663
|
},
|
|
20382
|
-
endsAgentStep:
|
|
20664
|
+
endsAgentStep: endsAgentStep37
|
|
20383
20665
|
})}
|
|
20384
20666
|
`.trim();
|
|
20385
20667
|
var writeFileParams = {
|
|
20386
|
-
toolName:
|
|
20387
|
-
endsAgentStep:
|
|
20388
|
-
description:
|
|
20389
|
-
inputSchema:
|
|
20668
|
+
toolName: toolName37,
|
|
20669
|
+
endsAgentStep: endsAgentStep37,
|
|
20670
|
+
description: description36,
|
|
20671
|
+
inputSchema: inputSchema37,
|
|
20390
20672
|
outputSchema: jsonToolResultSchema(updateFileResultSchema)
|
|
20391
20673
|
};
|
|
20392
20674
|
|
|
20393
20675
|
// ../common/src/tools/params/tool/write-todos.ts
|
|
20394
|
-
var
|
|
20395
|
-
var
|
|
20396
|
-
var
|
|
20397
|
-
var
|
|
20398
|
-
todos:
|
|
20399
|
-
task:
|
|
20400
|
-
completed:
|
|
20676
|
+
var import_v458 = __toESM(require("zod/v4"));
|
|
20677
|
+
var toolName38 = "write_todos";
|
|
20678
|
+
var endsAgentStep38 = false;
|
|
20679
|
+
var inputSchema38 = import_v458.default.object({
|
|
20680
|
+
todos: import_v458.default.array(import_v458.default.object({
|
|
20681
|
+
task: import_v458.default.string().describe("Description of the task"),
|
|
20682
|
+
completed: import_v458.default.boolean().describe("Whether the task is completed")
|
|
20401
20683
|
})).describe("List of todos with their completion status. Add ALL of the applicable tasks to the list, so you don't forget to do anything. Try to order the todos the same way you will complete them. Do not mark todos as completed if you have not completed them yet!")
|
|
20402
20684
|
}).describe("Write a todo list to track tasks for multi-step implementations. Use this frequently to maintain an updated step-by-step plan.");
|
|
20403
|
-
var
|
|
20685
|
+
var description37 = `
|
|
20404
20686
|
Use this tool to track your objectives through an ordered step-by-step plan. Call this tool after you have gathered context on the user's request to plan out the implementation steps for the user's request.
|
|
20405
20687
|
|
|
20406
20688
|
After completing each todo step, call this tool again to update the list and mark that task as completed. Note that each time you call this tool, rewrite ALL todos with their current status.
|
|
@@ -20409,8 +20691,8 @@ Use this tool frequently as you work through tasks to update the list of todos w
|
|
|
20409
20691
|
|
|
20410
20692
|
Example:
|
|
20411
20693
|
${$getNativeToolCallExampleString({
|
|
20412
|
-
toolName:
|
|
20413
|
-
inputSchema:
|
|
20694
|
+
toolName: toolName38,
|
|
20695
|
+
inputSchema: inputSchema38,
|
|
20414
20696
|
input: {
|
|
20415
20697
|
todos: [
|
|
20416
20698
|
{ task: "Create new implementation in foo.ts", completed: true },
|
|
@@ -20422,19 +20704,19 @@ ${$getNativeToolCallExampleString({
|
|
|
20422
20704
|
}
|
|
20423
20705
|
]
|
|
20424
20706
|
},
|
|
20425
|
-
endsAgentStep:
|
|
20707
|
+
endsAgentStep: endsAgentStep38
|
|
20426
20708
|
})}
|
|
20427
20709
|
`.trim();
|
|
20428
20710
|
var writeTodosParams = {
|
|
20429
|
-
toolName:
|
|
20430
|
-
endsAgentStep:
|
|
20431
|
-
description:
|
|
20432
|
-
inputSchema:
|
|
20433
|
-
outputSchema:
|
|
20434
|
-
|
|
20435
|
-
type:
|
|
20436
|
-
value:
|
|
20437
|
-
message:
|
|
20711
|
+
toolName: toolName38,
|
|
20712
|
+
endsAgentStep: endsAgentStep38,
|
|
20713
|
+
description: description37,
|
|
20714
|
+
inputSchema: inputSchema38,
|
|
20715
|
+
outputSchema: import_v458.default.tuple([
|
|
20716
|
+
import_v458.default.object({
|
|
20717
|
+
type: import_v458.default.literal("json"),
|
|
20718
|
+
value: import_v458.default.object({
|
|
20719
|
+
message: import_v458.default.string()
|
|
20438
20720
|
})
|
|
20439
20721
|
})
|
|
20440
20722
|
])
|
|
@@ -20460,6 +20742,7 @@ var toolParams = {
|
|
|
20460
20742
|
read_subtree: readSubtreeParams,
|
|
20461
20743
|
run_file_change_hooks: runFileChangeHooksParams,
|
|
20462
20744
|
run_terminal_command: runTerminalCommandParams,
|
|
20745
|
+
send_message: sendMessageParams,
|
|
20463
20746
|
set_messages: setMessagesParams,
|
|
20464
20747
|
set_output: setOutputParams,
|
|
20465
20748
|
skill: skillParams,
|
|
@@ -20468,51 +20751,57 @@ var toolParams = {
|
|
|
20468
20751
|
str_replace: strReplaceParams,
|
|
20469
20752
|
suggest_followups: suggestFollowupsParams,
|
|
20470
20753
|
task_completed: taskCompletedParams,
|
|
20754
|
+
task_create: taskCreateParams,
|
|
20755
|
+
task_get: taskGetParams,
|
|
20756
|
+
task_list: taskListParams,
|
|
20757
|
+
task_update: taskUpdateParams,
|
|
20758
|
+
team_create: teamCreateParams,
|
|
20759
|
+
team_delete: teamDeleteParams,
|
|
20471
20760
|
think_deeply: thinkDeeplyParams,
|
|
20472
20761
|
update_subgoal: updateSubgoalParams,
|
|
20473
20762
|
web_search: webSearchParams,
|
|
20474
20763
|
write_file: writeFileParams,
|
|
20475
20764
|
write_todos: writeTodosParams
|
|
20476
20765
|
};
|
|
20477
|
-
var clientToolCallSchema =
|
|
20478
|
-
|
|
20479
|
-
toolName:
|
|
20766
|
+
var clientToolCallSchema = import_v459.default.discriminatedUnion("toolName", [
|
|
20767
|
+
import_v459.default.object({
|
|
20768
|
+
toolName: import_v459.default.literal("ask_user"),
|
|
20480
20769
|
input: toolParams.ask_user.inputSchema
|
|
20481
20770
|
}),
|
|
20482
|
-
|
|
20483
|
-
toolName:
|
|
20771
|
+
import_v459.default.object({
|
|
20772
|
+
toolName: import_v459.default.literal("browser_logs"),
|
|
20484
20773
|
input: toolParams.browser_logs.inputSchema
|
|
20485
20774
|
}),
|
|
20486
|
-
|
|
20487
|
-
toolName:
|
|
20775
|
+
import_v459.default.object({
|
|
20776
|
+
toolName: import_v459.default.literal("code_search"),
|
|
20488
20777
|
input: toolParams.code_search.inputSchema
|
|
20489
20778
|
}),
|
|
20490
|
-
|
|
20491
|
-
toolName:
|
|
20779
|
+
import_v459.default.object({
|
|
20780
|
+
toolName: import_v459.default.literal("create_plan"),
|
|
20492
20781
|
input: FileChangeSchema
|
|
20493
20782
|
}),
|
|
20494
|
-
|
|
20495
|
-
toolName:
|
|
20783
|
+
import_v459.default.object({
|
|
20784
|
+
toolName: import_v459.default.literal("glob"),
|
|
20496
20785
|
input: toolParams.glob.inputSchema
|
|
20497
20786
|
}),
|
|
20498
|
-
|
|
20499
|
-
toolName:
|
|
20787
|
+
import_v459.default.object({
|
|
20788
|
+
toolName: import_v459.default.literal("list_directory"),
|
|
20500
20789
|
input: toolParams.list_directory.inputSchema
|
|
20501
20790
|
}),
|
|
20502
|
-
|
|
20503
|
-
toolName:
|
|
20791
|
+
import_v459.default.object({
|
|
20792
|
+
toolName: import_v459.default.literal("run_file_change_hooks"),
|
|
20504
20793
|
input: toolParams.run_file_change_hooks.inputSchema
|
|
20505
20794
|
}),
|
|
20506
|
-
|
|
20507
|
-
toolName:
|
|
20508
|
-
input: toolParams.run_terminal_command.inputSchema.and(
|
|
20795
|
+
import_v459.default.object({
|
|
20796
|
+
toolName: import_v459.default.literal("run_terminal_command"),
|
|
20797
|
+
input: toolParams.run_terminal_command.inputSchema.and(import_v459.default.object({ mode: import_v459.default.enum(["assistant", "user"]) }))
|
|
20509
20798
|
}),
|
|
20510
|
-
|
|
20511
|
-
toolName:
|
|
20799
|
+
import_v459.default.object({
|
|
20800
|
+
toolName: import_v459.default.literal("str_replace"),
|
|
20512
20801
|
input: FileChangeSchema
|
|
20513
20802
|
}),
|
|
20514
|
-
|
|
20515
|
-
toolName:
|
|
20803
|
+
import_v459.default.object({
|
|
20804
|
+
toolName: import_v459.default.literal("write_file"),
|
|
20516
20805
|
input: FileChangeSchema
|
|
20517
20806
|
})
|
|
20518
20807
|
]);
|
|
@@ -20741,13 +21030,13 @@ var escapeString = (str) => {
|
|
|
20741
21030
|
var import_lodash13 = __toESM(require_lodash());
|
|
20742
21031
|
|
|
20743
21032
|
// ../common/src/util/zod-schema.ts
|
|
20744
|
-
var
|
|
21033
|
+
var import_v460 = __toESM(require("zod/v4"));
|
|
20745
21034
|
function schemaToJsonStr(schema, options) {
|
|
20746
21035
|
if (!schema)
|
|
20747
21036
|
return "None";
|
|
20748
21037
|
try {
|
|
20749
|
-
if (schema instanceof
|
|
20750
|
-
const jsonSchema =
|
|
21038
|
+
if (schema instanceof import_v460.default.ZodType) {
|
|
21039
|
+
const jsonSchema = import_v460.default.toJSONSchema(schema, options);
|
|
20751
21040
|
delete jsonSchema["$schema"];
|
|
20752
21041
|
return JSON.stringify(jsonSchema, null, 2);
|
|
20753
21042
|
}
|
|
@@ -20758,27 +21047,27 @@ function schemaToJsonStr(schema, options) {
|
|
|
20758
21047
|
}
|
|
20759
21048
|
|
|
20760
21049
|
// ../packages/agent-runtime/src/templates/prompts.ts
|
|
20761
|
-
var
|
|
21050
|
+
var import_v463 = require("zod/v4");
|
|
20762
21051
|
|
|
20763
21052
|
// ../common/src/types/dynamic-agent-template.ts
|
|
20764
|
-
var
|
|
21053
|
+
var import_v462 = require("zod/v4");
|
|
20765
21054
|
init_old_constants();
|
|
20766
21055
|
|
|
20767
21056
|
// ../common/src/types/mcp.ts
|
|
20768
|
-
var
|
|
20769
|
-
var mcpConfigStdioSchema =
|
|
20770
|
-
type:
|
|
20771
|
-
command:
|
|
20772
|
-
args:
|
|
20773
|
-
env:
|
|
21057
|
+
var import_v461 = require("zod/v4");
|
|
21058
|
+
var mcpConfigStdioSchema = import_v461.z.strictObject({
|
|
21059
|
+
type: import_v461.z.literal("stdio").default("stdio"),
|
|
21060
|
+
command: import_v461.z.string(),
|
|
21061
|
+
args: import_v461.z.string().array().default(() => []),
|
|
21062
|
+
env: import_v461.z.record(import_v461.z.string(), import_v461.z.string()).default(() => ({}))
|
|
20774
21063
|
});
|
|
20775
|
-
var mcpConfigRemoteSchema =
|
|
20776
|
-
type:
|
|
20777
|
-
url:
|
|
20778
|
-
params:
|
|
20779
|
-
headers:
|
|
21064
|
+
var mcpConfigRemoteSchema = import_v461.z.strictObject({
|
|
21065
|
+
type: import_v461.z.enum(["http", "sse"]).default("http"),
|
|
21066
|
+
url: import_v461.z.string(),
|
|
21067
|
+
params: import_v461.z.record(import_v461.z.string(), import_v461.z.string()).default(() => ({})),
|
|
21068
|
+
headers: import_v461.z.record(import_v461.z.string(), import_v461.z.string()).default(() => ({}))
|
|
20780
21069
|
});
|
|
20781
|
-
var mcpConfigSchema =
|
|
21070
|
+
var mcpConfigSchema = import_v461.z.union([
|
|
20782
21071
|
mcpConfigRemoteSchema,
|
|
20783
21072
|
mcpConfigStdioSchema
|
|
20784
21073
|
]);
|
|
@@ -20788,8 +21077,8 @@ var filteredModels = Object.values(models).filter((model) => ALLOWED_MODEL_PREFI
|
|
|
20788
21077
|
if (filteredModels.length === 0) {
|
|
20789
21078
|
throw new Error("No valid models found with allowed prefixes");
|
|
20790
21079
|
}
|
|
20791
|
-
var JsonSchemaSchema =
|
|
20792
|
-
type:
|
|
21080
|
+
var JsonSchemaSchema = import_v462.z.lazy(() => import_v462.z.looseObject({
|
|
21081
|
+
type: import_v462.z.enum([
|
|
20793
21082
|
"object",
|
|
20794
21083
|
"array",
|
|
20795
21084
|
"string",
|
|
@@ -20798,78 +21087,78 @@ var JsonSchemaSchema = import_v455.z.lazy(() => import_v455.z.looseObject({
|
|
|
20798
21087
|
"null",
|
|
20799
21088
|
"integer"
|
|
20800
21089
|
]).optional(),
|
|
20801
|
-
description:
|
|
20802
|
-
properties:
|
|
20803
|
-
required:
|
|
20804
|
-
enum:
|
|
21090
|
+
description: import_v462.z.string().optional(),
|
|
21091
|
+
properties: import_v462.z.record(import_v462.z.string(), JsonSchemaSchema.or(import_v462.z.boolean())).optional(),
|
|
21092
|
+
required: import_v462.z.string().array().optional(),
|
|
21093
|
+
enum: import_v462.z.union([import_v462.z.string(), import_v462.z.number(), import_v462.z.boolean(), import_v462.z.null()]).array().optional()
|
|
20805
21094
|
}));
|
|
20806
|
-
var JsonObjectSchemaSchema =
|
|
20807
|
-
var InputSchemaObjectSchema =
|
|
20808
|
-
prompt:
|
|
20809
|
-
type:
|
|
20810
|
-
description:
|
|
21095
|
+
var JsonObjectSchemaSchema = import_v462.z.intersection(JsonSchemaSchema, import_v462.z.object({ type: import_v462.z.literal("object") }));
|
|
21096
|
+
var InputSchemaObjectSchema = import_v462.z.looseObject({
|
|
21097
|
+
prompt: import_v462.z.looseObject({
|
|
21098
|
+
type: import_v462.z.literal("string"),
|
|
21099
|
+
description: import_v462.z.string().optional()
|
|
20811
21100
|
}).optional(),
|
|
20812
21101
|
params: JsonObjectSchemaSchema.optional()
|
|
20813
21102
|
}).optional();
|
|
20814
|
-
var PromptFieldSchema =
|
|
20815
|
-
|
|
20816
|
-
|
|
21103
|
+
var PromptFieldSchema = import_v462.z.union([
|
|
21104
|
+
import_v462.z.string(),
|
|
21105
|
+
import_v462.z.object({ path: import_v462.z.string() })
|
|
20817
21106
|
]);
|
|
20818
|
-
var functionSchema = (schema) =>
|
|
20819
|
-
var LoggerSchema =
|
|
20820
|
-
debug:
|
|
20821
|
-
input: [
|
|
20822
|
-
output:
|
|
21107
|
+
var functionSchema = (schema) => import_v462.z.custom((fn) => schema.implement(fn));
|
|
21108
|
+
var LoggerSchema = import_v462.z.object({
|
|
21109
|
+
debug: import_v462.z.function({
|
|
21110
|
+
input: [import_v462.z.any(), import_v462.z.string().optional()],
|
|
21111
|
+
output: import_v462.z.void()
|
|
20823
21112
|
}),
|
|
20824
|
-
info:
|
|
20825
|
-
input: [
|
|
20826
|
-
output:
|
|
21113
|
+
info: import_v462.z.function({
|
|
21114
|
+
input: [import_v462.z.any(), import_v462.z.string().optional()],
|
|
21115
|
+
output: import_v462.z.void()
|
|
20827
21116
|
}),
|
|
20828
|
-
warn:
|
|
20829
|
-
input: [
|
|
20830
|
-
output:
|
|
21117
|
+
warn: import_v462.z.function({
|
|
21118
|
+
input: [import_v462.z.any(), import_v462.z.string().optional()],
|
|
21119
|
+
output: import_v462.z.void()
|
|
20831
21120
|
}),
|
|
20832
|
-
error:
|
|
20833
|
-
input: [
|
|
20834
|
-
output:
|
|
21121
|
+
error: import_v462.z.function({
|
|
21122
|
+
input: [import_v462.z.any(), import_v462.z.string().optional()],
|
|
21123
|
+
output: import_v462.z.void()
|
|
20835
21124
|
})
|
|
20836
21125
|
});
|
|
20837
|
-
var HandleStepsSchema = functionSchema(
|
|
21126
|
+
var HandleStepsSchema = functionSchema(import_v462.z.function({
|
|
20838
21127
|
input: [
|
|
20839
|
-
|
|
20840
|
-
agentState:
|
|
20841
|
-
agentId:
|
|
20842
|
-
parentId:
|
|
20843
|
-
messageHistory:
|
|
21128
|
+
import_v462.z.object({
|
|
21129
|
+
agentState: import_v462.z.object({
|
|
21130
|
+
agentId: import_v462.z.string(),
|
|
21131
|
+
parentId: import_v462.z.string(),
|
|
21132
|
+
messageHistory: import_v462.z.array(import_v462.z.any())
|
|
20844
21133
|
}),
|
|
20845
|
-
prompt:
|
|
20846
|
-
params:
|
|
21134
|
+
prompt: import_v462.z.string().optional(),
|
|
21135
|
+
params: import_v462.z.any().optional()
|
|
20847
21136
|
}),
|
|
20848
21137
|
LoggerSchema.optional()
|
|
20849
21138
|
],
|
|
20850
|
-
output:
|
|
21139
|
+
output: import_v462.z.any()
|
|
20851
21140
|
})).optional();
|
|
20852
|
-
var DynamicAgentDefinitionSchema =
|
|
20853
|
-
id:
|
|
20854
|
-
version:
|
|
20855
|
-
publisher:
|
|
20856
|
-
displayName:
|
|
20857
|
-
model:
|
|
20858
|
-
reasoningOptions:
|
|
20859
|
-
enabled:
|
|
20860
|
-
exclude:
|
|
20861
|
-
}).and(
|
|
20862
|
-
|
|
20863
|
-
|
|
21141
|
+
var DynamicAgentDefinitionSchema = import_v462.z.object({
|
|
21142
|
+
id: import_v462.z.string().regex(/^[a-z0-9-]+$/, "Agent ID must contain only lowercase letters, numbers, and hyphens"),
|
|
21143
|
+
version: import_v462.z.string().optional(),
|
|
21144
|
+
publisher: import_v462.z.string().optional(),
|
|
21145
|
+
displayName: import_v462.z.string(),
|
|
21146
|
+
model: import_v462.z.string(),
|
|
21147
|
+
reasoningOptions: import_v462.z.object({
|
|
21148
|
+
enabled: import_v462.z.boolean().optional(),
|
|
21149
|
+
exclude: import_v462.z.boolean().optional()
|
|
21150
|
+
}).and(import_v462.z.union([
|
|
21151
|
+
import_v462.z.object({ max_tokens: import_v462.z.number() }),
|
|
21152
|
+
import_v462.z.object({ effort: import_v462.z.enum(["high", "medium", "low", "minimal", "none"]) })
|
|
20864
21153
|
])).optional(),
|
|
20865
|
-
providerOptions:
|
|
20866
|
-
order:
|
|
20867
|
-
allow_fallbacks:
|
|
20868
|
-
require_parameters:
|
|
20869
|
-
data_collection:
|
|
20870
|
-
only:
|
|
20871
|
-
ignore:
|
|
20872
|
-
quantizations:
|
|
21154
|
+
providerOptions: import_v462.z.object({
|
|
21155
|
+
order: import_v462.z.array(import_v462.z.string()).optional(),
|
|
21156
|
+
allow_fallbacks: import_v462.z.boolean().optional(),
|
|
21157
|
+
require_parameters: import_v462.z.boolean().optional(),
|
|
21158
|
+
data_collection: import_v462.z.enum(["allow", "deny"]).optional(),
|
|
21159
|
+
only: import_v462.z.array(import_v462.z.string()).optional(),
|
|
21160
|
+
ignore: import_v462.z.array(import_v462.z.string()).optional(),
|
|
21161
|
+
quantizations: import_v462.z.array(import_v462.z.enum([
|
|
20873
21162
|
"int4",
|
|
20874
21163
|
"int8",
|
|
20875
21164
|
"fp4",
|
|
@@ -20880,34 +21169,34 @@ var DynamicAgentDefinitionSchema = import_v455.z.object({
|
|
|
20880
21169
|
"fp32",
|
|
20881
21170
|
"unknown"
|
|
20882
21171
|
])).optional(),
|
|
20883
|
-
sort:
|
|
20884
|
-
max_price:
|
|
20885
|
-
prompt:
|
|
20886
|
-
completion:
|
|
20887
|
-
image:
|
|
20888
|
-
audio:
|
|
20889
|
-
request:
|
|
21172
|
+
sort: import_v462.z.enum(["price", "throughput", "latency"]).optional(),
|
|
21173
|
+
max_price: import_v462.z.object({
|
|
21174
|
+
prompt: import_v462.z.union([import_v462.z.number(), import_v462.z.string()]).optional(),
|
|
21175
|
+
completion: import_v462.z.union([import_v462.z.number(), import_v462.z.string()]).optional(),
|
|
21176
|
+
image: import_v462.z.union([import_v462.z.number(), import_v462.z.string()]).optional(),
|
|
21177
|
+
audio: import_v462.z.union([import_v462.z.number(), import_v462.z.string()]).optional(),
|
|
21178
|
+
request: import_v462.z.union([import_v462.z.number(), import_v462.z.string()]).optional()
|
|
20890
21179
|
}).optional()
|
|
20891
21180
|
}).optional(),
|
|
20892
|
-
mcpServers:
|
|
20893
|
-
toolNames:
|
|
20894
|
-
spawnableAgents:
|
|
21181
|
+
mcpServers: import_v462.z.record(import_v462.z.string(), mcpConfigSchema).default(() => ({})),
|
|
21182
|
+
toolNames: import_v462.z.string().array().optional().default(() => []),
|
|
21183
|
+
spawnableAgents: import_v462.z.array(import_v462.z.string()).optional().default(() => []),
|
|
20895
21184
|
inputSchema: InputSchemaObjectSchema,
|
|
20896
|
-
includeMessageHistory:
|
|
20897
|
-
inheritParentSystemPrompt:
|
|
20898
|
-
outputMode:
|
|
21185
|
+
includeMessageHistory: import_v462.z.boolean().default(false),
|
|
21186
|
+
inheritParentSystemPrompt: import_v462.z.boolean().default(false),
|
|
21187
|
+
outputMode: import_v462.z.enum(["last_message", "all_messages", "structured_output"]).default("last_message"),
|
|
20899
21188
|
outputSchema: JsonObjectSchemaSchema.optional(),
|
|
20900
|
-
spawnerPrompt:
|
|
20901
|
-
systemPrompt:
|
|
20902
|
-
instructionsPrompt:
|
|
20903
|
-
stepPrompt:
|
|
20904
|
-
handleSteps:
|
|
21189
|
+
spawnerPrompt: import_v462.z.string().optional(),
|
|
21190
|
+
systemPrompt: import_v462.z.string().optional(),
|
|
21191
|
+
instructionsPrompt: import_v462.z.string().optional(),
|
|
21192
|
+
stepPrompt: import_v462.z.string().optional(),
|
|
21193
|
+
handleSteps: import_v462.z.union([import_v462.z.string(), HandleStepsSchema]).optional()
|
|
20905
21194
|
});
|
|
20906
21195
|
var DynamicAgentTemplateSchema = DynamicAgentDefinitionSchema.extend({
|
|
20907
|
-
systemPrompt:
|
|
20908
|
-
instructionsPrompt:
|
|
20909
|
-
stepPrompt:
|
|
20910
|
-
handleSteps:
|
|
21196
|
+
systemPrompt: import_v462.z.string(),
|
|
21197
|
+
instructionsPrompt: import_v462.z.string(),
|
|
21198
|
+
stepPrompt: import_v462.z.string(),
|
|
21199
|
+
handleSteps: import_v462.z.string().optional()
|
|
20911
21200
|
}).refine((data) => {
|
|
20912
21201
|
if (data.outputSchema && data.outputMode !== "structured_output") {
|
|
20913
21202
|
return false;
|
|
@@ -21016,9 +21305,9 @@ function validateSingleAgent(params2) {
|
|
|
21016
21305
|
error: `${agentContext2}: Schema validation failed: ${error.message}`
|
|
21017
21306
|
};
|
|
21018
21307
|
}
|
|
21019
|
-
let
|
|
21308
|
+
let inputSchema39;
|
|
21020
21309
|
try {
|
|
21021
|
-
|
|
21310
|
+
inputSchema39 = convertInputSchema(validatedConfig.inputSchema?.prompt, validatedConfig.inputSchema?.params, filePath);
|
|
21022
21311
|
} catch (error) {
|
|
21023
21312
|
const agentContext2 = validatedConfig.id ? `Agent "${validatedConfig.id}"${validatedConfig.displayName ? ` (${validatedConfig.displayName})` : ""}` : filePath ? `Agent in ${filePath}` : "Agent";
|
|
21024
21313
|
return {
|
|
@@ -21053,7 +21342,7 @@ function validateSingleAgent(params2) {
|
|
|
21053
21342
|
instructionsPrompt: validatedConfig.instructionsPrompt ?? "",
|
|
21054
21343
|
stepPrompt: validatedConfig.stepPrompt ?? "",
|
|
21055
21344
|
outputSchema: outputSchema3,
|
|
21056
|
-
inputSchema:
|
|
21345
|
+
inputSchema: inputSchema39
|
|
21057
21346
|
};
|
|
21058
21347
|
return {
|
|
21059
21348
|
success: true,
|
|
@@ -21237,10 +21526,10 @@ function assembleLocalAgentTemplates(params2) {
|
|
|
21237
21526
|
// ../packages/agent-runtime/src/templates/prompts.ts
|
|
21238
21527
|
function ensureJsonSchemaCompatible(schema) {
|
|
21239
21528
|
try {
|
|
21240
|
-
|
|
21529
|
+
import_v463.z.toJSONSchema(schema, { io: "input" });
|
|
21241
21530
|
return schema;
|
|
21242
21531
|
} catch {
|
|
21243
|
-
const fallback =
|
|
21532
|
+
const fallback = import_v463.z.object({}).passthrough();
|
|
21244
21533
|
return schema.description ? fallback.describe(schema.description) : fallback;
|
|
21245
21534
|
}
|
|
21246
21535
|
}
|
|
@@ -21250,15 +21539,15 @@ function getAgentShortName(agentType) {
|
|
|
21250
21539
|
return parts[parts.length - 1];
|
|
21251
21540
|
}
|
|
21252
21541
|
function buildAgentToolInputSchema(agentTemplate) {
|
|
21253
|
-
const { inputSchema:
|
|
21542
|
+
const { inputSchema: inputSchema39 } = agentTemplate;
|
|
21254
21543
|
let schemaFields = {};
|
|
21255
|
-
if (
|
|
21256
|
-
schemaFields.prompt =
|
|
21544
|
+
if (inputSchema39?.prompt) {
|
|
21545
|
+
schemaFields.prompt = inputSchema39.prompt;
|
|
21257
21546
|
}
|
|
21258
|
-
if (
|
|
21259
|
-
schemaFields.params =
|
|
21547
|
+
if (inputSchema39?.params) {
|
|
21548
|
+
schemaFields.params = inputSchema39.params;
|
|
21260
21549
|
}
|
|
21261
|
-
return
|
|
21550
|
+
return import_v463.z.object(schemaFields).describe(agentTemplate.spawnerPrompt || `Spawn the ${agentTemplate.displayName} agent`);
|
|
21262
21551
|
}
|
|
21263
21552
|
async function buildAgentToolSet(params2) {
|
|
21264
21553
|
const { spawnableAgents, agentTemplates } = params2;
|
|
@@ -21272,10 +21561,10 @@ async function buildAgentToolSet(params2) {
|
|
|
21272
21561
|
if (!agentTemplate)
|
|
21273
21562
|
continue;
|
|
21274
21563
|
const shortName = getAgentShortName(agentType);
|
|
21275
|
-
const
|
|
21564
|
+
const inputSchema39 = ensureJsonSchemaCompatible(buildAgentToolInputSchema(agentTemplate));
|
|
21276
21565
|
toolSet[shortName] = {
|
|
21277
21566
|
description: agentTemplate.spawnerPrompt || `Spawn the ${agentTemplate.displayName} agent`,
|
|
21278
|
-
inputSchema:
|
|
21567
|
+
inputSchema: inputSchema39
|
|
21279
21568
|
};
|
|
21280
21569
|
}
|
|
21281
21570
|
return toolSet;
|
|
@@ -21286,10 +21575,10 @@ function buildSingleAgentDescription(agentType, agentTemplate) {
|
|
|
21286
21575
|
prompt: {"description": "A coding task to complete", "type": "string"}
|
|
21287
21576
|
params: None`;
|
|
21288
21577
|
}
|
|
21289
|
-
const { inputSchema:
|
|
21290
|
-
const inputSchemaStr =
|
|
21291
|
-
`prompt: ${schemaToJsonStr(
|
|
21292
|
-
`params: ${schemaToJsonStr(
|
|
21578
|
+
const { inputSchema: inputSchema39 } = agentTemplate;
|
|
21579
|
+
const inputSchemaStr = inputSchema39 ? [
|
|
21580
|
+
`prompt: ${schemaToJsonStr(inputSchema39.prompt)}`,
|
|
21581
|
+
`params: ${schemaToJsonStr(inputSchema39.params)}`
|
|
21293
21582
|
].join(`
|
|
21294
21583
|
`) : ["prompt: None", "params: None"].join(`
|
|
21295
21584
|
`);
|
|
@@ -21377,49 +21666,49 @@ init_model_config();
|
|
|
21377
21666
|
// ../common/src/util/file.ts
|
|
21378
21667
|
var os = __toESM(require("os"));
|
|
21379
21668
|
var path = __toESM(require("path"));
|
|
21380
|
-
var
|
|
21381
|
-
var FileTreeNodeSchema =
|
|
21382
|
-
name:
|
|
21383
|
-
type:
|
|
21384
|
-
children:
|
|
21385
|
-
filePath:
|
|
21669
|
+
var import_v464 = require("zod/v4");
|
|
21670
|
+
var FileTreeNodeSchema = import_v464.z.object({
|
|
21671
|
+
name: import_v464.z.string(),
|
|
21672
|
+
type: import_v464.z.enum(["file", "directory"]),
|
|
21673
|
+
children: import_v464.z.lazy(() => import_v464.z.array(FileTreeNodeSchema).optional()),
|
|
21674
|
+
filePath: import_v464.z.string()
|
|
21386
21675
|
});
|
|
21387
|
-
var FileVersionSchema =
|
|
21388
|
-
path:
|
|
21389
|
-
content:
|
|
21676
|
+
var FileVersionSchema = import_v464.z.object({
|
|
21677
|
+
path: import_v464.z.string(),
|
|
21678
|
+
content: import_v464.z.string()
|
|
21390
21679
|
});
|
|
21391
|
-
var customToolDefinitionsSchema =
|
|
21392
|
-
inputSchema:
|
|
21393
|
-
endsAgentStep:
|
|
21394
|
-
description:
|
|
21395
|
-
exampleInputs:
|
|
21680
|
+
var customToolDefinitionsSchema = import_v464.z.record(import_v464.z.string(), import_v464.z.object({
|
|
21681
|
+
inputSchema: import_v464.z.custom(),
|
|
21682
|
+
endsAgentStep: import_v464.z.boolean().optional().default(false),
|
|
21683
|
+
description: import_v464.z.string().optional(),
|
|
21684
|
+
exampleInputs: import_v464.z.record(import_v464.z.string(), import_v464.z.any()).array().optional()
|
|
21396
21685
|
})).default(() => ({}));
|
|
21397
|
-
var ProjectFileContextSchema =
|
|
21398
|
-
projectRoot:
|
|
21399
|
-
cwd:
|
|
21400
|
-
fileTree:
|
|
21401
|
-
fileTokenScores:
|
|
21402
|
-
tokenCallers:
|
|
21403
|
-
knowledgeFiles:
|
|
21404
|
-
userKnowledgeFiles:
|
|
21405
|
-
agentTemplates:
|
|
21686
|
+
var ProjectFileContextSchema = import_v464.z.object({
|
|
21687
|
+
projectRoot: import_v464.z.string(),
|
|
21688
|
+
cwd: import_v464.z.string(),
|
|
21689
|
+
fileTree: import_v464.z.array(import_v464.z.custom()),
|
|
21690
|
+
fileTokenScores: import_v464.z.record(import_v464.z.string(), import_v464.z.record(import_v464.z.string(), import_v464.z.number())),
|
|
21691
|
+
tokenCallers: import_v464.z.record(import_v464.z.string(), import_v464.z.record(import_v464.z.string(), import_v464.z.array(import_v464.z.string()))).optional(),
|
|
21692
|
+
knowledgeFiles: import_v464.z.record(import_v464.z.string(), import_v464.z.string()),
|
|
21693
|
+
userKnowledgeFiles: import_v464.z.record(import_v464.z.string(), import_v464.z.string()).optional(),
|
|
21694
|
+
agentTemplates: import_v464.z.record(import_v464.z.string(), import_v464.z.any()).default(() => ({})),
|
|
21406
21695
|
customToolDefinitions: customToolDefinitionsSchema,
|
|
21407
|
-
skills:
|
|
21408
|
-
gitChanges:
|
|
21409
|
-
status:
|
|
21410
|
-
diff:
|
|
21411
|
-
diffCached:
|
|
21412
|
-
lastCommitMessages:
|
|
21696
|
+
skills: import_v464.z.record(import_v464.z.string(), import_v464.z.any()).optional(),
|
|
21697
|
+
gitChanges: import_v464.z.object({
|
|
21698
|
+
status: import_v464.z.string(),
|
|
21699
|
+
diff: import_v464.z.string(),
|
|
21700
|
+
diffCached: import_v464.z.string(),
|
|
21701
|
+
lastCommitMessages: import_v464.z.string()
|
|
21413
21702
|
}),
|
|
21414
|
-
changesSinceLastChat:
|
|
21415
|
-
shellConfigFiles:
|
|
21416
|
-
systemInfo:
|
|
21417
|
-
platform:
|
|
21418
|
-
shell:
|
|
21419
|
-
nodeVersion:
|
|
21420
|
-
arch:
|
|
21421
|
-
homedir:
|
|
21422
|
-
cpus:
|
|
21703
|
+
changesSinceLastChat: import_v464.z.record(import_v464.z.string(), import_v464.z.string()),
|
|
21704
|
+
shellConfigFiles: import_v464.z.record(import_v464.z.string(), import_v464.z.string()),
|
|
21705
|
+
systemInfo: import_v464.z.object({
|
|
21706
|
+
platform: import_v464.z.string(),
|
|
21707
|
+
shell: import_v464.z.string(),
|
|
21708
|
+
nodeVersion: import_v464.z.string(),
|
|
21709
|
+
arch: import_v464.z.string(),
|
|
21710
|
+
homedir: import_v464.z.string(),
|
|
21711
|
+
cpus: import_v464.z.number()
|
|
21423
21712
|
})
|
|
21424
21713
|
});
|
|
21425
21714
|
var createMarkdownFileBlock = (filePath, content) => {
|
|
@@ -27425,8 +27714,8 @@ var import_lodash8 = __toESM(require_lodash());
|
|
|
27425
27714
|
var import_assert = require("assert");
|
|
27426
27715
|
|
|
27427
27716
|
// ../common/src/util/xml.ts
|
|
27428
|
-
function closeXml(
|
|
27429
|
-
return `</${
|
|
27717
|
+
function closeXml(toolName39) {
|
|
27718
|
+
return `</${toolName39}>`;
|
|
27430
27719
|
}
|
|
27431
27720
|
|
|
27432
27721
|
// ../packages/agent-runtime/src/util/messages.ts
|
|
@@ -28573,7 +28862,7 @@ var removeUndefinedProps = (obj) => {
|
|
|
28573
28862
|
};
|
|
28574
28863
|
|
|
28575
28864
|
// ../packages/agent-runtime/src/tools/handlers/tool/lookup-agent-info.ts
|
|
28576
|
-
var
|
|
28865
|
+
var import_v465 = __toESM(require("zod/v4"));
|
|
28577
28866
|
var handleLookupAgentInfo = async (params2) => {
|
|
28578
28867
|
const { toolCall, previousToolCallFinished } = params2;
|
|
28579
28868
|
const { agentId } = toolCall.input;
|
|
@@ -28595,7 +28884,7 @@ var handleLookupAgentInfo = async (params2) => {
|
|
|
28595
28884
|
displayName,
|
|
28596
28885
|
model,
|
|
28597
28886
|
includeMessageHistory,
|
|
28598
|
-
inputSchema:
|
|
28887
|
+
inputSchema: inputSchema39,
|
|
28599
28888
|
spawnerPrompt,
|
|
28600
28889
|
outputMode,
|
|
28601
28890
|
outputSchema: outputSchema3,
|
|
@@ -28615,8 +28904,8 @@ var handleLookupAgentInfo = async (params2) => {
|
|
|
28615
28904
|
spawnableAgents,
|
|
28616
28905
|
includeMessageHistory,
|
|
28617
28906
|
spawnerPrompt,
|
|
28618
|
-
...
|
|
28619
|
-
inputSchema: inputSchemaToJSONSchema(
|
|
28907
|
+
...inputSchema39 && {
|
|
28908
|
+
inputSchema: inputSchemaToJSONSchema(inputSchema39)
|
|
28620
28909
|
},
|
|
28621
28910
|
outputMode,
|
|
28622
28911
|
...outputSchema3 && {
|
|
@@ -28629,17 +28918,17 @@ var handleLookupAgentInfo = async (params2) => {
|
|
|
28629
28918
|
};
|
|
28630
28919
|
var toJSONSchema = (schema) => {
|
|
28631
28920
|
try {
|
|
28632
|
-
const jsonSchema =
|
|
28921
|
+
const jsonSchema = import_v465.default.toJSONSchema(schema, { io: "input" });
|
|
28633
28922
|
delete jsonSchema["$schema"];
|
|
28634
28923
|
return jsonSchema;
|
|
28635
28924
|
} catch {
|
|
28636
28925
|
return { type: "object", description: "Schema unavailable" };
|
|
28637
28926
|
}
|
|
28638
28927
|
};
|
|
28639
|
-
var inputSchemaToJSONSchema = (
|
|
28928
|
+
var inputSchemaToJSONSchema = (inputSchema39) => {
|
|
28640
28929
|
return removeUndefinedProps({
|
|
28641
|
-
prompt:
|
|
28642
|
-
params:
|
|
28930
|
+
prompt: inputSchema39.prompt ? toJSONSchema(inputSchema39.prompt) : undefined,
|
|
28931
|
+
params: inputSchema39.params ? toJSONSchema(inputSchema39.params) : undefined
|
|
28643
28932
|
});
|
|
28644
28933
|
};
|
|
28645
28934
|
|
|
@@ -29222,6 +29511,119 @@ var handleSkill = async (params2) => {
|
|
|
29222
29511
|
// ../packages/agent-runtime/src/tools/handlers/tool/spawn-agent-inline.ts
|
|
29223
29512
|
var import_lodash11 = __toESM(require_lodash());
|
|
29224
29513
|
|
|
29514
|
+
// ../common/src/utils/team-fs.ts
|
|
29515
|
+
var fs = __toESM(require("fs"));
|
|
29516
|
+
var path3 = __toESM(require("path"));
|
|
29517
|
+
var os2 = __toESM(require("os"));
|
|
29518
|
+
function getConfigRoot() {
|
|
29519
|
+
return path3.join(os2.homedir(), ".config", "levelcode");
|
|
29520
|
+
}
|
|
29521
|
+
function getTeamsDir() {
|
|
29522
|
+
return path3.join(getConfigRoot(), "teams");
|
|
29523
|
+
}
|
|
29524
|
+
function getTasksDir(teamName) {
|
|
29525
|
+
return path3.join(getConfigRoot(), "tasks", teamName);
|
|
29526
|
+
}
|
|
29527
|
+
function getTeamDir(teamName) {
|
|
29528
|
+
return path3.join(getTeamsDir(), teamName);
|
|
29529
|
+
}
|
|
29530
|
+
function getTeamConfigPath(teamName) {
|
|
29531
|
+
return path3.join(getTeamDir(teamName), "config.json");
|
|
29532
|
+
}
|
|
29533
|
+
function getInboxesDir(teamName) {
|
|
29534
|
+
return path3.join(getTeamDir(teamName), "inboxes");
|
|
29535
|
+
}
|
|
29536
|
+
function getInboxPath(teamName, agentName) {
|
|
29537
|
+
return path3.join(getInboxesDir(teamName), `${agentName}.json`);
|
|
29538
|
+
}
|
|
29539
|
+
function getTaskPath(teamName, taskId) {
|
|
29540
|
+
return path3.join(getTasksDir(teamName), `${taskId}.json`);
|
|
29541
|
+
}
|
|
29542
|
+
function createTeam(config) {
|
|
29543
|
+
const teamDir = getTeamDir(config.name);
|
|
29544
|
+
fs.mkdirSync(teamDir, { recursive: true });
|
|
29545
|
+
fs.mkdirSync(getInboxesDir(config.name), { recursive: true });
|
|
29546
|
+
fs.mkdirSync(getTasksDir(config.name), { recursive: true });
|
|
29547
|
+
fs.writeFileSync(getTeamConfigPath(config.name), JSON.stringify(config, null, 2));
|
|
29548
|
+
}
|
|
29549
|
+
function loadTeamConfig(teamName) {
|
|
29550
|
+
const configPath = getTeamConfigPath(teamName);
|
|
29551
|
+
if (!fs.existsSync(configPath)) {
|
|
29552
|
+
return null;
|
|
29553
|
+
}
|
|
29554
|
+
const raw = fs.readFileSync(configPath, "utf-8");
|
|
29555
|
+
return JSON.parse(raw);
|
|
29556
|
+
}
|
|
29557
|
+
function saveTeamConfig(teamName, config) {
|
|
29558
|
+
const configPath = getTeamConfigPath(teamName);
|
|
29559
|
+
fs.mkdirSync(path3.dirname(configPath), { recursive: true });
|
|
29560
|
+
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
|
|
29561
|
+
}
|
|
29562
|
+
function deleteTeam(teamName) {
|
|
29563
|
+
const teamDir = getTeamDir(teamName);
|
|
29564
|
+
if (fs.existsSync(teamDir)) {
|
|
29565
|
+
fs.rmSync(teamDir, { recursive: true, force: true });
|
|
29566
|
+
}
|
|
29567
|
+
const tasksDir = getTasksDir(teamName);
|
|
29568
|
+
if (fs.existsSync(tasksDir)) {
|
|
29569
|
+
fs.rmSync(tasksDir, { recursive: true, force: true });
|
|
29570
|
+
}
|
|
29571
|
+
}
|
|
29572
|
+
function addTeamMember(teamName, member) {
|
|
29573
|
+
const config = loadTeamConfig(teamName);
|
|
29574
|
+
if (!config) {
|
|
29575
|
+
throw new Error(`Team "${teamName}" not found`);
|
|
29576
|
+
}
|
|
29577
|
+
config.members.push(member);
|
|
29578
|
+
saveTeamConfig(teamName, config);
|
|
29579
|
+
}
|
|
29580
|
+
function createTask(teamName, task) {
|
|
29581
|
+
const tasksDir = getTasksDir(teamName);
|
|
29582
|
+
fs.mkdirSync(tasksDir, { recursive: true });
|
|
29583
|
+
fs.writeFileSync(getTaskPath(teamName, task.id), JSON.stringify(task, null, 2));
|
|
29584
|
+
}
|
|
29585
|
+
function updateTask(teamName, taskId, updates) {
|
|
29586
|
+
const taskPath = getTaskPath(teamName, taskId);
|
|
29587
|
+
if (!fs.existsSync(taskPath)) {
|
|
29588
|
+
throw new Error(`Task "${taskId}" not found in team "${teamName}"`);
|
|
29589
|
+
}
|
|
29590
|
+
const raw = fs.readFileSync(taskPath, "utf-8");
|
|
29591
|
+
const task = JSON.parse(raw);
|
|
29592
|
+
const updated = { ...task, ...updates, updatedAt: Date.now() };
|
|
29593
|
+
fs.writeFileSync(taskPath, JSON.stringify(updated, null, 2));
|
|
29594
|
+
}
|
|
29595
|
+
function listTasks(teamName) {
|
|
29596
|
+
const tasksDir = getTasksDir(teamName);
|
|
29597
|
+
if (!fs.existsSync(tasksDir)) {
|
|
29598
|
+
return [];
|
|
29599
|
+
}
|
|
29600
|
+
const files = fs.readdirSync(tasksDir).filter((f) => f.endsWith(".json"));
|
|
29601
|
+
return files.map((f) => {
|
|
29602
|
+
const raw = fs.readFileSync(path3.join(tasksDir, f), "utf-8");
|
|
29603
|
+
return JSON.parse(raw);
|
|
29604
|
+
});
|
|
29605
|
+
}
|
|
29606
|
+
function getTask(teamName, taskId) {
|
|
29607
|
+
const taskPath = getTaskPath(teamName, taskId);
|
|
29608
|
+
if (!fs.existsSync(taskPath)) {
|
|
29609
|
+
return null;
|
|
29610
|
+
}
|
|
29611
|
+
const raw = fs.readFileSync(taskPath, "utf-8");
|
|
29612
|
+
return JSON.parse(raw);
|
|
29613
|
+
}
|
|
29614
|
+
function sendMessage(teamName, to, message) {
|
|
29615
|
+
const inboxesDir = getInboxesDir(teamName);
|
|
29616
|
+
fs.mkdirSync(inboxesDir, { recursive: true });
|
|
29617
|
+
const inboxPath = getInboxPath(teamName, to);
|
|
29618
|
+
let messages = [];
|
|
29619
|
+
if (fs.existsSync(inboxPath)) {
|
|
29620
|
+
const raw = fs.readFileSync(inboxPath, "utf-8");
|
|
29621
|
+
messages = JSON.parse(raw);
|
|
29622
|
+
}
|
|
29623
|
+
messages.push(message);
|
|
29624
|
+
fs.writeFileSync(inboxPath, JSON.stringify(messages, null, 2));
|
|
29625
|
+
}
|
|
29626
|
+
|
|
29225
29627
|
// ../packages/agent-runtime/src/tools/handlers/tool/spawn-agent-utils.ts
|
|
29226
29628
|
function extractSubagentContextParams(params2) {
|
|
29227
29629
|
return {
|
|
@@ -29360,15 +29762,15 @@ async function validateAndGetAgentTemplate(params2) {
|
|
|
29360
29762
|
return { agentTemplate, agentType };
|
|
29361
29763
|
}
|
|
29362
29764
|
function validateAgentInput(agentTemplate, agentType, prompt2, params2) {
|
|
29363
|
-
const { inputSchema:
|
|
29364
|
-
if (
|
|
29365
|
-
const result =
|
|
29765
|
+
const { inputSchema: inputSchema39 } = agentTemplate;
|
|
29766
|
+
if (inputSchema39.prompt) {
|
|
29767
|
+
const result = inputSchema39.prompt.safeParse(prompt2 ?? "");
|
|
29366
29768
|
if (!result.success) {
|
|
29367
29769
|
throw new Error(`Invalid prompt for agent ${agentType}: ${JSON.stringify(result.error.issues, null, 2)}`);
|
|
29368
29770
|
}
|
|
29369
29771
|
}
|
|
29370
|
-
if (
|
|
29371
|
-
const result =
|
|
29772
|
+
if (inputSchema39.params) {
|
|
29773
|
+
const result = inputSchema39.params.safeParse(params2 ?? {});
|
|
29372
29774
|
if (!result.success) {
|
|
29373
29775
|
throw new Error(`Invalid params for agent ${agentType}: ${JSON.stringify(result.error.issues, null, 2)}`);
|
|
29374
29776
|
}
|
|
@@ -29458,6 +29860,48 @@ async function executeSubagent(options) {
|
|
|
29458
29860
|
}
|
|
29459
29861
|
return result;
|
|
29460
29862
|
}
|
|
29863
|
+
function registerAgentAsTeamMember(agentId, agentType, options, logger2) {
|
|
29864
|
+
const { teamName, teamRole } = options;
|
|
29865
|
+
const teamConfig = loadTeamConfig(teamName);
|
|
29866
|
+
if (!teamConfig) {
|
|
29867
|
+
logger2.debug({ teamName, agentId }, `Team "${teamName}" not found; skipping team registration`);
|
|
29868
|
+
return null;
|
|
29869
|
+
}
|
|
29870
|
+
const role = teamRole || "mid-level-engineer";
|
|
29871
|
+
const memberName = `${agentType}-${agentId}`;
|
|
29872
|
+
const member = {
|
|
29873
|
+
agentId,
|
|
29874
|
+
name: memberName,
|
|
29875
|
+
role,
|
|
29876
|
+
agentType,
|
|
29877
|
+
model: "",
|
|
29878
|
+
joinedAt: Date.now(),
|
|
29879
|
+
status: "active",
|
|
29880
|
+
cwd: process.cwd()
|
|
29881
|
+
};
|
|
29882
|
+
try {
|
|
29883
|
+
addTeamMember(teamName, member);
|
|
29884
|
+
} catch (error) {
|
|
29885
|
+
logger2.debug({ teamName, agentId, error }, `Failed to register agent as team member`);
|
|
29886
|
+
return null;
|
|
29887
|
+
}
|
|
29888
|
+
return buildTeamContextPrompt(teamName, memberName, role, teamConfig.leadAgentId);
|
|
29889
|
+
}
|
|
29890
|
+
function buildTeamContextPrompt(teamName, agentName, role, leadAgentId) {
|
|
29891
|
+
const tasksDir = getTasksDir(teamName);
|
|
29892
|
+
return [
|
|
29893
|
+
`
|
|
29894
|
+
# Team Context`,
|
|
29895
|
+
`You are a member of team "${teamName}".`,
|
|
29896
|
+
`Your name in this team: ${agentName}`,
|
|
29897
|
+
`Your role: ${role}`,
|
|
29898
|
+
`Team lead agent ID: ${leadAgentId}`,
|
|
29899
|
+
`Team task directory: ${tasksDir}`,
|
|
29900
|
+
`Use the team messaging tools (send_message, broadcast) to communicate with teammates.`,
|
|
29901
|
+
`Use the task tools (task_create, task_update, task_list) to coordinate work.`
|
|
29902
|
+
].join(`
|
|
29903
|
+
`);
|
|
29904
|
+
}
|
|
29461
29905
|
|
|
29462
29906
|
// ../packages/agent-runtime/src/tools/handlers/tool/spawn-agent-inline.ts
|
|
29463
29907
|
var handleSpawnAgentInline = async (params2) => {
|
|
@@ -29543,7 +29987,13 @@ var handleSpawnAgents = async (params2) => {
|
|
|
29543
29987
|
const { agents } = toolCall.input;
|
|
29544
29988
|
const { logger: logger2 } = params2;
|
|
29545
29989
|
await previousToolCallFinished;
|
|
29546
|
-
const results = await Promise.allSettled(agents.map(async ({
|
|
29990
|
+
const results = await Promise.allSettled(agents.map(async ({
|
|
29991
|
+
agent_type: agentTypeStr,
|
|
29992
|
+
prompt: prompt2,
|
|
29993
|
+
params: spawnParams,
|
|
29994
|
+
team_name: teamName,
|
|
29995
|
+
team_role: teamRole
|
|
29996
|
+
}) => {
|
|
29547
29997
|
const { agentTemplate, agentType } = await validateAndGetAgentTemplate({
|
|
29548
29998
|
...params2,
|
|
29549
29999
|
agentTypeStr,
|
|
@@ -29551,12 +30001,21 @@ var handleSpawnAgents = async (params2) => {
|
|
|
29551
30001
|
});
|
|
29552
30002
|
validateAgentInput(agentTemplate, agentType, prompt2, spawnParams);
|
|
29553
30003
|
const subAgentState = createAgentState(agentType, agentTemplate, parentAgentState, {});
|
|
30004
|
+
let effectivePrompt = prompt2 || "";
|
|
30005
|
+
if (teamName) {
|
|
30006
|
+
const teamContext = registerAgentAsTeamMember(subAgentState.agentId, agentType, { teamName, teamRole }, logger2);
|
|
30007
|
+
if (teamContext) {
|
|
30008
|
+
effectivePrompt = teamContext + `
|
|
30009
|
+
|
|
30010
|
+
` + effectivePrompt;
|
|
30011
|
+
}
|
|
30012
|
+
}
|
|
29554
30013
|
const contextParams = extractSubagentContextParams(params2);
|
|
29555
30014
|
const result = await executeSubagent({
|
|
29556
30015
|
...contextParams,
|
|
29557
30016
|
ancestorRunIds: parentAgentState.ancestorRunIds,
|
|
29558
30017
|
userInputId: `${userInputId2}-${agentType}${subAgentState.agentId}`,
|
|
29559
|
-
prompt:
|
|
30018
|
+
prompt: effectivePrompt,
|
|
29560
30019
|
spawnParams,
|
|
29561
30020
|
agentTemplate,
|
|
29562
30021
|
parentAgentState,
|
|
@@ -29659,15 +30118,15 @@ var handleStrReplace = async (params2) => {
|
|
|
29659
30118
|
requestOptionalFile,
|
|
29660
30119
|
writeToClient
|
|
29661
30120
|
} = params2;
|
|
29662
|
-
const { path:
|
|
29663
|
-
if (!fileProcessingState2.promisesByPath[
|
|
29664
|
-
fileProcessingState2.promisesByPath[
|
|
30121
|
+
const { path: path4, replacements } = toolCall.input;
|
|
30122
|
+
if (!fileProcessingState2.promisesByPath[path4]) {
|
|
30123
|
+
fileProcessingState2.promisesByPath[path4] = [];
|
|
29665
30124
|
}
|
|
29666
|
-
const previousPromises = fileProcessingState2.promisesByPath[
|
|
30125
|
+
const previousPromises = fileProcessingState2.promisesByPath[path4];
|
|
29667
30126
|
const previousEdit = previousPromises[previousPromises.length - 1];
|
|
29668
|
-
const latestContentPromise = previousEdit ? previousEdit.then((maybeResult) => maybeResult && ("content" in maybeResult) ? maybeResult.content : requestOptionalFile({ ...params2, filePath:
|
|
30127
|
+
const latestContentPromise = previousEdit ? previousEdit.then((maybeResult) => maybeResult && ("content" in maybeResult) ? maybeResult.content : requestOptionalFile({ ...params2, filePath: path4 })) : requestOptionalFile({ ...params2, filePath: path4 });
|
|
29669
30128
|
const newPromise = processStrReplace({
|
|
29670
|
-
path:
|
|
30129
|
+
path: path4,
|
|
29671
30130
|
replacements,
|
|
29672
30131
|
initialContentPromise: latestContentPromise,
|
|
29673
30132
|
logger: logger2
|
|
@@ -29675,14 +30134,14 @@ var handleStrReplace = async (params2) => {
|
|
|
29675
30134
|
logger2.error(error, "Error processing str_replace block");
|
|
29676
30135
|
return {
|
|
29677
30136
|
tool: "str_replace",
|
|
29678
|
-
path:
|
|
30137
|
+
path: path4,
|
|
29679
30138
|
error: "Unknown error: Failed to process the str_replace block."
|
|
29680
30139
|
};
|
|
29681
30140
|
}).then((fileProcessingResult) => ({
|
|
29682
30141
|
...fileProcessingResult,
|
|
29683
30142
|
toolCallId: toolCall.toolCallId
|
|
29684
30143
|
}));
|
|
29685
|
-
fileProcessingState2.promisesByPath[
|
|
30144
|
+
fileProcessingState2.promisesByPath[path4].push(newPromise);
|
|
29686
30145
|
fileProcessingState2.allPromises.push(newPromise);
|
|
29687
30146
|
await previousToolCallFinished;
|
|
29688
30147
|
const strReplaceResult = await newPromise;
|
|
@@ -29859,6 +30318,563 @@ var handleWriteTodos = async (params2) => {
|
|
|
29859
30318
|
return { output: jsonToolResult({ message: "Todos written" }) };
|
|
29860
30319
|
};
|
|
29861
30320
|
|
|
30321
|
+
// ../packages/agent-runtime/src/tools/handlers/tool/send-message.ts
|
|
30322
|
+
var fs2 = __toESM(require("fs"));
|
|
30323
|
+
function findCurrentTeamAndAgent(agentStepId2) {
|
|
30324
|
+
const teamsDir = getTeamsDir();
|
|
30325
|
+
if (!fs2.existsSync(teamsDir)) {
|
|
30326
|
+
return null;
|
|
30327
|
+
}
|
|
30328
|
+
const entries = fs2.readdirSync(teamsDir, { withFileTypes: true });
|
|
30329
|
+
for (const entry of entries) {
|
|
30330
|
+
if (!entry.isDirectory()) {
|
|
30331
|
+
continue;
|
|
30332
|
+
}
|
|
30333
|
+
const config = loadTeamConfig(entry.name);
|
|
30334
|
+
if (!config) {
|
|
30335
|
+
continue;
|
|
30336
|
+
}
|
|
30337
|
+
for (const member of config.members) {
|
|
30338
|
+
if (member.agentId === `lead-${agentStepId2}` || member.agentId === agentStepId2) {
|
|
30339
|
+
return { teamName: config.name, agentName: member.name, config };
|
|
30340
|
+
}
|
|
30341
|
+
}
|
|
30342
|
+
}
|
|
30343
|
+
return null;
|
|
30344
|
+
}
|
|
30345
|
+
function errorResult(message) {
|
|
30346
|
+
return { output: jsonToolResult({ message }) };
|
|
30347
|
+
}
|
|
30348
|
+
var handleSendMessage = async (params2) => {
|
|
30349
|
+
const { previousToolCallFinished, toolCall, agentStepId: agentStepId2 } = params2;
|
|
30350
|
+
const { type, recipient, content, summary, request_id, approve } = toolCall.input;
|
|
30351
|
+
await previousToolCallFinished;
|
|
30352
|
+
const teamContext = findCurrentTeamAndAgent(agentStepId2);
|
|
30353
|
+
if (!teamContext) {
|
|
30354
|
+
return errorResult("No team found for the current agent context. Cannot send messages outside a team.");
|
|
30355
|
+
}
|
|
30356
|
+
const { teamName, agentName, config } = teamContext;
|
|
30357
|
+
const timestamp = new Date().toISOString();
|
|
30358
|
+
switch (type) {
|
|
30359
|
+
case "message": {
|
|
30360
|
+
if (!recipient) {
|
|
30361
|
+
return errorResult('A "recipient" is required for type "message".');
|
|
30362
|
+
}
|
|
30363
|
+
if (!summary) {
|
|
30364
|
+
return errorResult('A "summary" is required for type "message".');
|
|
30365
|
+
}
|
|
30366
|
+
const memberExists = config.members.some((m) => m.name === recipient);
|
|
30367
|
+
if (!memberExists) {
|
|
30368
|
+
return errorResult(`Recipient "${recipient}" is not a member of team "${teamName}".`);
|
|
30369
|
+
}
|
|
30370
|
+
const msg = {
|
|
30371
|
+
type: "message",
|
|
30372
|
+
from: agentName,
|
|
30373
|
+
to: recipient,
|
|
30374
|
+
text: content ?? "",
|
|
30375
|
+
summary,
|
|
30376
|
+
timestamp
|
|
30377
|
+
};
|
|
30378
|
+
sendMessage(teamName, recipient, msg);
|
|
30379
|
+
return {
|
|
30380
|
+
output: jsonToolResult({
|
|
30381
|
+
message: `Message sent to "${recipient}" in team "${teamName}".`
|
|
30382
|
+
})
|
|
30383
|
+
};
|
|
30384
|
+
}
|
|
30385
|
+
case "broadcast": {
|
|
30386
|
+
if (!summary) {
|
|
30387
|
+
return errorResult('A "summary" is required for type "broadcast".');
|
|
30388
|
+
}
|
|
30389
|
+
const msg = {
|
|
30390
|
+
type: "broadcast",
|
|
30391
|
+
from: agentName,
|
|
30392
|
+
text: content ?? "",
|
|
30393
|
+
summary,
|
|
30394
|
+
timestamp
|
|
30395
|
+
};
|
|
30396
|
+
const recipients = config.members.filter((m) => m.name !== agentName).map((m) => m.name);
|
|
30397
|
+
for (const memberName of recipients) {
|
|
30398
|
+
sendMessage(teamName, memberName, msg);
|
|
30399
|
+
}
|
|
30400
|
+
return {
|
|
30401
|
+
output: jsonToolResult({
|
|
30402
|
+
message: `Broadcast sent to ${recipients.length} teammate(s) in team "${teamName}".`
|
|
30403
|
+
})
|
|
30404
|
+
};
|
|
30405
|
+
}
|
|
30406
|
+
case "shutdown_request": {
|
|
30407
|
+
if (!recipient) {
|
|
30408
|
+
return errorResult('A "recipient" is required for type "shutdown_request".');
|
|
30409
|
+
}
|
|
30410
|
+
const memberExists = config.members.some((m) => m.name === recipient);
|
|
30411
|
+
if (!memberExists) {
|
|
30412
|
+
return errorResult(`Recipient "${recipient}" is not a member of team "${teamName}".`);
|
|
30413
|
+
}
|
|
30414
|
+
const msg = {
|
|
30415
|
+
type: "shutdown_request",
|
|
30416
|
+
requestId: generateCompactId(),
|
|
30417
|
+
from: agentName,
|
|
30418
|
+
reason: content,
|
|
30419
|
+
timestamp
|
|
30420
|
+
};
|
|
30421
|
+
sendMessage(teamName, recipient, msg);
|
|
30422
|
+
return {
|
|
30423
|
+
output: jsonToolResult({
|
|
30424
|
+
message: `Shutdown request sent to "${recipient}" (requestId: ${msg.requestId}).`
|
|
30425
|
+
})
|
|
30426
|
+
};
|
|
30427
|
+
}
|
|
30428
|
+
case "shutdown_response": {
|
|
30429
|
+
if (!request_id) {
|
|
30430
|
+
return errorResult('A "request_id" is required for type "shutdown_response".');
|
|
30431
|
+
}
|
|
30432
|
+
if (approve === undefined || approve === null) {
|
|
30433
|
+
return errorResult('An "approve" boolean is required for type "shutdown_response".');
|
|
30434
|
+
}
|
|
30435
|
+
if (approve) {
|
|
30436
|
+
const msg = {
|
|
30437
|
+
type: "shutdown_approved",
|
|
30438
|
+
requestId: request_id,
|
|
30439
|
+
from: agentName,
|
|
30440
|
+
timestamp
|
|
30441
|
+
};
|
|
30442
|
+
for (const member of config.members) {
|
|
30443
|
+
if (member.name !== agentName) {
|
|
30444
|
+
sendMessage(teamName, member.name, msg);
|
|
30445
|
+
}
|
|
30446
|
+
}
|
|
30447
|
+
return {
|
|
30448
|
+
output: jsonToolResult({
|
|
30449
|
+
message: `Shutdown approved (requestId: ${request_id}). Agent will exit.`
|
|
30450
|
+
})
|
|
30451
|
+
};
|
|
30452
|
+
} else {
|
|
30453
|
+
const msg = {
|
|
30454
|
+
type: "shutdown_rejected",
|
|
30455
|
+
requestId: request_id,
|
|
30456
|
+
from: agentName,
|
|
30457
|
+
reason: content ?? "Shutdown rejected without a reason.",
|
|
30458
|
+
timestamp
|
|
30459
|
+
};
|
|
30460
|
+
for (const member of config.members) {
|
|
30461
|
+
if (member.name !== agentName) {
|
|
30462
|
+
sendMessage(teamName, member.name, msg);
|
|
30463
|
+
}
|
|
30464
|
+
}
|
|
30465
|
+
return {
|
|
30466
|
+
output: jsonToolResult({
|
|
30467
|
+
message: `Shutdown rejected (requestId: ${request_id}).`
|
|
30468
|
+
})
|
|
30469
|
+
};
|
|
30470
|
+
}
|
|
30471
|
+
}
|
|
30472
|
+
case "plan_approval_response": {
|
|
30473
|
+
if (!request_id) {
|
|
30474
|
+
return errorResult('A "request_id" is required for type "plan_approval_response".');
|
|
30475
|
+
}
|
|
30476
|
+
if (!recipient) {
|
|
30477
|
+
return errorResult('A "recipient" is required for type "plan_approval_response".');
|
|
30478
|
+
}
|
|
30479
|
+
if (approve === undefined || approve === null) {
|
|
30480
|
+
return errorResult('An "approve" boolean is required for type "plan_approval_response".');
|
|
30481
|
+
}
|
|
30482
|
+
const memberExists = config.members.some((m) => m.name === recipient);
|
|
30483
|
+
if (!memberExists) {
|
|
30484
|
+
return errorResult(`Recipient "${recipient}" is not a member of team "${teamName}".`);
|
|
30485
|
+
}
|
|
30486
|
+
const msg = {
|
|
30487
|
+
type: "plan_approval_response",
|
|
30488
|
+
requestId: request_id,
|
|
30489
|
+
approved: approve,
|
|
30490
|
+
feedback: content,
|
|
30491
|
+
timestamp
|
|
30492
|
+
};
|
|
30493
|
+
sendMessage(teamName, recipient, msg);
|
|
30494
|
+
const action = approve ? "approved" : "rejected";
|
|
30495
|
+
return {
|
|
30496
|
+
output: jsonToolResult({
|
|
30497
|
+
message: `Plan ${action} for "${recipient}" (requestId: ${request_id}).`
|
|
30498
|
+
})
|
|
30499
|
+
};
|
|
30500
|
+
}
|
|
30501
|
+
default: {
|
|
30502
|
+
return errorResult(`Unknown message type: "${type}". Expected one of: message, broadcast, shutdown_request, shutdown_response, plan_approval_response.`);
|
|
30503
|
+
}
|
|
30504
|
+
}
|
|
30505
|
+
};
|
|
30506
|
+
|
|
30507
|
+
// ../packages/agent-runtime/src/tools/handlers/tool/task-create.ts
|
|
30508
|
+
var fs3 = __toESM(require("fs"));
|
|
30509
|
+
function getActiveTeamName() {
|
|
30510
|
+
const teamsDir = getTeamsDir();
|
|
30511
|
+
if (!fs3.existsSync(teamsDir)) {
|
|
30512
|
+
return null;
|
|
30513
|
+
}
|
|
30514
|
+
const entries = fs3.readdirSync(teamsDir, { withFileTypes: true });
|
|
30515
|
+
const teamDirs = entries.filter((e) => e.isDirectory());
|
|
30516
|
+
if (teamDirs.length === 0) {
|
|
30517
|
+
return null;
|
|
30518
|
+
}
|
|
30519
|
+
return teamDirs[0].name;
|
|
30520
|
+
}
|
|
30521
|
+
var handleTaskCreate = async (params2) => {
|
|
30522
|
+
const { previousToolCallFinished, toolCall } = params2;
|
|
30523
|
+
const { subject, description: description38, activeForm, metadata } = toolCall.input;
|
|
30524
|
+
await previousToolCallFinished;
|
|
30525
|
+
const teamName = getActiveTeamName();
|
|
30526
|
+
if (!teamName) {
|
|
30527
|
+
return {
|
|
30528
|
+
output: jsonToolResult({
|
|
30529
|
+
error: "No active team found. Create a team first using TeamCreate."
|
|
30530
|
+
})
|
|
30531
|
+
};
|
|
30532
|
+
}
|
|
30533
|
+
const existingTasks = listTasks(teamName);
|
|
30534
|
+
const maxId = existingTasks.reduce((max, t) => {
|
|
30535
|
+
const num = parseInt(t.id, 10);
|
|
30536
|
+
return isNaN(num) ? max : Math.max(max, num);
|
|
30537
|
+
}, 0);
|
|
30538
|
+
const taskId = String(maxId + 1);
|
|
30539
|
+
const now = Date.now();
|
|
30540
|
+
const task = {
|
|
30541
|
+
id: taskId,
|
|
30542
|
+
subject,
|
|
30543
|
+
description: description38,
|
|
30544
|
+
status: "pending",
|
|
30545
|
+
blockedBy: [],
|
|
30546
|
+
blocks: [],
|
|
30547
|
+
phase: "planning",
|
|
30548
|
+
activeForm,
|
|
30549
|
+
createdAt: now,
|
|
30550
|
+
updatedAt: now,
|
|
30551
|
+
metadata
|
|
30552
|
+
};
|
|
30553
|
+
try {
|
|
30554
|
+
createTask(teamName, task);
|
|
30555
|
+
} catch (error) {
|
|
30556
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
30557
|
+
return {
|
|
30558
|
+
output: jsonToolResult({
|
|
30559
|
+
error: `Failed to create task: ${errorMessage}`
|
|
30560
|
+
})
|
|
30561
|
+
};
|
|
30562
|
+
}
|
|
30563
|
+
return {
|
|
30564
|
+
output: jsonToolResult({
|
|
30565
|
+
taskId,
|
|
30566
|
+
subject
|
|
30567
|
+
})
|
|
30568
|
+
};
|
|
30569
|
+
};
|
|
30570
|
+
|
|
30571
|
+
// ../packages/agent-runtime/src/tools/handlers/tool/task-get.ts
|
|
30572
|
+
var fs4 = __toESM(require("fs"));
|
|
30573
|
+
function getActiveTeamName2() {
|
|
30574
|
+
const teamsDir = getTeamsDir();
|
|
30575
|
+
if (!fs4.existsSync(teamsDir)) {
|
|
30576
|
+
return null;
|
|
30577
|
+
}
|
|
30578
|
+
const entries = fs4.readdirSync(teamsDir, { withFileTypes: true });
|
|
30579
|
+
const teamDirs = entries.filter((e) => e.isDirectory());
|
|
30580
|
+
if (teamDirs.length === 0) {
|
|
30581
|
+
return null;
|
|
30582
|
+
}
|
|
30583
|
+
return teamDirs[0].name;
|
|
30584
|
+
}
|
|
30585
|
+
var handleTaskGet = async (params2) => {
|
|
30586
|
+
const { previousToolCallFinished, toolCall } = params2;
|
|
30587
|
+
const { taskId } = toolCall.input;
|
|
30588
|
+
await previousToolCallFinished;
|
|
30589
|
+
const teamName = getActiveTeamName2();
|
|
30590
|
+
if (!teamName) {
|
|
30591
|
+
return {
|
|
30592
|
+
output: jsonToolResult({
|
|
30593
|
+
error: "No active team found. Create a team first using TeamCreate."
|
|
30594
|
+
})
|
|
30595
|
+
};
|
|
30596
|
+
}
|
|
30597
|
+
const task = getTask(teamName, taskId);
|
|
30598
|
+
if (!task) {
|
|
30599
|
+
return {
|
|
30600
|
+
output: jsonToolResult({
|
|
30601
|
+
error: `Task "${taskId}" not found.`
|
|
30602
|
+
})
|
|
30603
|
+
};
|
|
30604
|
+
}
|
|
30605
|
+
return {
|
|
30606
|
+
output: jsonToolResult(task)
|
|
30607
|
+
};
|
|
30608
|
+
};
|
|
30609
|
+
|
|
30610
|
+
// ../packages/agent-runtime/src/tools/handlers/tool/task-list.ts
|
|
30611
|
+
var fs5 = __toESM(require("fs"));
|
|
30612
|
+
function getActiveTeamName3() {
|
|
30613
|
+
const teamsDir = getTeamsDir();
|
|
30614
|
+
if (!fs5.existsSync(teamsDir)) {
|
|
30615
|
+
return null;
|
|
30616
|
+
}
|
|
30617
|
+
const entries = fs5.readdirSync(teamsDir, { withFileTypes: true });
|
|
30618
|
+
const teamDirs = entries.filter((e) => e.isDirectory());
|
|
30619
|
+
if (teamDirs.length === 0) {
|
|
30620
|
+
return null;
|
|
30621
|
+
}
|
|
30622
|
+
return teamDirs[0].name;
|
|
30623
|
+
}
|
|
30624
|
+
var handleTaskList = async (params2) => {
|
|
30625
|
+
const { previousToolCallFinished } = params2;
|
|
30626
|
+
await previousToolCallFinished;
|
|
30627
|
+
const teamName = getActiveTeamName3();
|
|
30628
|
+
if (!teamName) {
|
|
30629
|
+
return {
|
|
30630
|
+
output: jsonToolResult({
|
|
30631
|
+
error: "No active team found. Create a team first using TeamCreate.",
|
|
30632
|
+
tasks: []
|
|
30633
|
+
})
|
|
30634
|
+
};
|
|
30635
|
+
}
|
|
30636
|
+
const tasks = listTasks(teamName);
|
|
30637
|
+
const summary = tasks.map((t) => ({
|
|
30638
|
+
id: t.id,
|
|
30639
|
+
subject: t.subject,
|
|
30640
|
+
status: t.status,
|
|
30641
|
+
owner: t.owner ?? null,
|
|
30642
|
+
blockedBy: t.blockedBy.filter((id) => {
|
|
30643
|
+
const blocker = tasks.find((bt) => bt.id === id);
|
|
30644
|
+
return blocker && blocker.status !== "completed";
|
|
30645
|
+
})
|
|
30646
|
+
}));
|
|
30647
|
+
return {
|
|
30648
|
+
output: jsonToolResult({ tasks: summary })
|
|
30649
|
+
};
|
|
30650
|
+
};
|
|
30651
|
+
|
|
30652
|
+
// ../packages/agent-runtime/src/tools/handlers/tool/task-update.ts
|
|
30653
|
+
var fs6 = __toESM(require("fs"));
|
|
30654
|
+
var path4 = __toESM(require("path"));
|
|
30655
|
+
function getActiveTeamName4() {
|
|
30656
|
+
const teamsDir = getTeamsDir();
|
|
30657
|
+
if (!fs6.existsSync(teamsDir)) {
|
|
30658
|
+
return null;
|
|
30659
|
+
}
|
|
30660
|
+
const entries = fs6.readdirSync(teamsDir, { withFileTypes: true });
|
|
30661
|
+
const teamDirs = entries.filter((e) => e.isDirectory());
|
|
30662
|
+
if (teamDirs.length === 0) {
|
|
30663
|
+
return null;
|
|
30664
|
+
}
|
|
30665
|
+
return teamDirs[0].name;
|
|
30666
|
+
}
|
|
30667
|
+
var handleTaskUpdate = async (params2) => {
|
|
30668
|
+
const { previousToolCallFinished, toolCall } = params2;
|
|
30669
|
+
const {
|
|
30670
|
+
taskId,
|
|
30671
|
+
status,
|
|
30672
|
+
subject,
|
|
30673
|
+
description: description38,
|
|
30674
|
+
activeForm,
|
|
30675
|
+
owner,
|
|
30676
|
+
addBlocks,
|
|
30677
|
+
addBlockedBy,
|
|
30678
|
+
metadata
|
|
30679
|
+
} = toolCall.input;
|
|
30680
|
+
await previousToolCallFinished;
|
|
30681
|
+
const teamName = getActiveTeamName4();
|
|
30682
|
+
if (!teamName) {
|
|
30683
|
+
return {
|
|
30684
|
+
output: jsonToolResult({
|
|
30685
|
+
error: "No active team found. Create a team first using TeamCreate."
|
|
30686
|
+
})
|
|
30687
|
+
};
|
|
30688
|
+
}
|
|
30689
|
+
const existingTask = getTask(teamName, taskId);
|
|
30690
|
+
if (!existingTask) {
|
|
30691
|
+
return {
|
|
30692
|
+
output: jsonToolResult({
|
|
30693
|
+
error: `Task "${taskId}" not found.`
|
|
30694
|
+
})
|
|
30695
|
+
};
|
|
30696
|
+
}
|
|
30697
|
+
if (status === "deleted") {
|
|
30698
|
+
const taskPath = path4.join(getTasksDir(teamName), `${taskId}.json`);
|
|
30699
|
+
if (fs6.existsSync(taskPath)) {
|
|
30700
|
+
fs6.unlinkSync(taskPath);
|
|
30701
|
+
}
|
|
30702
|
+
return {
|
|
30703
|
+
output: jsonToolResult({
|
|
30704
|
+
message: `Task "${taskId}" deleted.`
|
|
30705
|
+
})
|
|
30706
|
+
};
|
|
30707
|
+
}
|
|
30708
|
+
const updates = {};
|
|
30709
|
+
if (status !== undefined)
|
|
30710
|
+
updates.status = status;
|
|
30711
|
+
if (subject !== undefined)
|
|
30712
|
+
updates.subject = subject;
|
|
30713
|
+
if (description38 !== undefined)
|
|
30714
|
+
updates.description = description38;
|
|
30715
|
+
if (activeForm !== undefined)
|
|
30716
|
+
updates.activeForm = activeForm;
|
|
30717
|
+
if (owner !== undefined)
|
|
30718
|
+
updates.owner = owner;
|
|
30719
|
+
if (addBlocks && addBlocks.length > 0) {
|
|
30720
|
+
const currentBlocks = existingTask.blocks ?? [];
|
|
30721
|
+
const newBlocks = [...new Set([...currentBlocks, ...addBlocks])];
|
|
30722
|
+
updates.blocks = newBlocks;
|
|
30723
|
+
}
|
|
30724
|
+
if (addBlockedBy && addBlockedBy.length > 0) {
|
|
30725
|
+
const currentBlockedBy = existingTask.blockedBy ?? [];
|
|
30726
|
+
const newBlockedBy = [...new Set([...currentBlockedBy, ...addBlockedBy])];
|
|
30727
|
+
updates.blockedBy = newBlockedBy;
|
|
30728
|
+
}
|
|
30729
|
+
if (metadata !== undefined) {
|
|
30730
|
+
const currentMetadata = existingTask.metadata ?? {};
|
|
30731
|
+
const mergedMetadata = { ...currentMetadata };
|
|
30732
|
+
for (const [key, value] of Object.entries(metadata)) {
|
|
30733
|
+
if (value === null) {
|
|
30734
|
+
delete mergedMetadata[key];
|
|
30735
|
+
} else {
|
|
30736
|
+
mergedMetadata[key] = value;
|
|
30737
|
+
}
|
|
30738
|
+
}
|
|
30739
|
+
updates.metadata = mergedMetadata;
|
|
30740
|
+
}
|
|
30741
|
+
try {
|
|
30742
|
+
updateTask(teamName, taskId, updates);
|
|
30743
|
+
} catch (error) {
|
|
30744
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
30745
|
+
return {
|
|
30746
|
+
output: jsonToolResult({
|
|
30747
|
+
error: `Failed to update task "${taskId}": ${errorMessage}`
|
|
30748
|
+
})
|
|
30749
|
+
};
|
|
30750
|
+
}
|
|
30751
|
+
const updatedTask = getTask(teamName, taskId);
|
|
30752
|
+
return {
|
|
30753
|
+
output: jsonToolResult(updatedTask)
|
|
30754
|
+
};
|
|
30755
|
+
};
|
|
30756
|
+
|
|
30757
|
+
// ../packages/agent-runtime/src/tools/handlers/tool/team-create.ts
|
|
30758
|
+
var handleTeamCreate = async (params2) => {
|
|
30759
|
+
const { previousToolCallFinished, toolCall, agentStepId: agentStepId2 } = params2;
|
|
30760
|
+
const { team_name, description: description38, agent_type } = toolCall.input;
|
|
30761
|
+
await previousToolCallFinished;
|
|
30762
|
+
const leadAgentId = `lead-${agentStepId2}`;
|
|
30763
|
+
const now = Date.now();
|
|
30764
|
+
const teamConfig = {
|
|
30765
|
+
name: team_name,
|
|
30766
|
+
description: description38 ?? "",
|
|
30767
|
+
createdAt: now,
|
|
30768
|
+
leadAgentId,
|
|
30769
|
+
phase: "planning",
|
|
30770
|
+
members: [
|
|
30771
|
+
{
|
|
30772
|
+
agentId: leadAgentId,
|
|
30773
|
+
name: "team-lead",
|
|
30774
|
+
role: "coordinator",
|
|
30775
|
+
agentType: agent_type ?? "coordinator",
|
|
30776
|
+
model: "",
|
|
30777
|
+
joinedAt: now,
|
|
30778
|
+
status: "active",
|
|
30779
|
+
cwd: process.cwd()
|
|
30780
|
+
}
|
|
30781
|
+
],
|
|
30782
|
+
settings: {
|
|
30783
|
+
maxMembers: 20,
|
|
30784
|
+
autoAssign: true
|
|
30785
|
+
}
|
|
30786
|
+
};
|
|
30787
|
+
try {
|
|
30788
|
+
createTeam(teamConfig);
|
|
30789
|
+
} catch (error) {
|
|
30790
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
30791
|
+
return {
|
|
30792
|
+
output: jsonToolResult({
|
|
30793
|
+
message: `Failed to create team "${team_name}": ${errorMessage}`
|
|
30794
|
+
})
|
|
30795
|
+
};
|
|
30796
|
+
}
|
|
30797
|
+
const teamFilePath = `${getTeamsDir()}/${team_name}/config.json`;
|
|
30798
|
+
const taskDirPath = getTasksDir(team_name);
|
|
30799
|
+
return {
|
|
30800
|
+
output: jsonToolResult({
|
|
30801
|
+
message: `Team "${team_name}" created successfully. Config: ${teamFilePath}, Tasks: ${taskDirPath}, Lead: ${leadAgentId}`
|
|
30802
|
+
})
|
|
30803
|
+
};
|
|
30804
|
+
};
|
|
30805
|
+
|
|
30806
|
+
// ../packages/agent-runtime/src/tools/handlers/tool/team-delete.ts
|
|
30807
|
+
var fs7 = __toESM(require("fs"));
|
|
30808
|
+
function findCurrentTeam(agentStepId2) {
|
|
30809
|
+
const teamsDir = getTeamsDir();
|
|
30810
|
+
if (!fs7.existsSync(teamsDir)) {
|
|
30811
|
+
return null;
|
|
30812
|
+
}
|
|
30813
|
+
const entries = fs7.readdirSync(teamsDir, { withFileTypes: true });
|
|
30814
|
+
for (const entry of entries) {
|
|
30815
|
+
if (!entry.isDirectory()) {
|
|
30816
|
+
continue;
|
|
30817
|
+
}
|
|
30818
|
+
const config = loadTeamConfig(entry.name);
|
|
30819
|
+
if (!config) {
|
|
30820
|
+
continue;
|
|
30821
|
+
}
|
|
30822
|
+
if (config.leadAgentId === `lead-${agentStepId2}`) {
|
|
30823
|
+
return config.name;
|
|
30824
|
+
}
|
|
30825
|
+
for (const member of config.members) {
|
|
30826
|
+
if (member.agentId === `lead-${agentStepId2}` || member.agentId === agentStepId2) {
|
|
30827
|
+
return config.name;
|
|
30828
|
+
}
|
|
30829
|
+
}
|
|
30830
|
+
}
|
|
30831
|
+
return null;
|
|
30832
|
+
}
|
|
30833
|
+
var handleTeamDelete = async (params2) => {
|
|
30834
|
+
const { previousToolCallFinished, agentStepId: agentStepId2 } = params2;
|
|
30835
|
+
await previousToolCallFinished;
|
|
30836
|
+
const teamName = findCurrentTeam(agentStepId2);
|
|
30837
|
+
if (!teamName) {
|
|
30838
|
+
return {
|
|
30839
|
+
output: jsonToolResult({
|
|
30840
|
+
message: "No team found for the current agent context. Cannot delete."
|
|
30841
|
+
})
|
|
30842
|
+
};
|
|
30843
|
+
}
|
|
30844
|
+
const config = loadTeamConfig(teamName);
|
|
30845
|
+
if (!config) {
|
|
30846
|
+
return {
|
|
30847
|
+
output: jsonToolResult({
|
|
30848
|
+
message: `Team "${teamName}" config not found. It may have already been deleted.`
|
|
30849
|
+
})
|
|
30850
|
+
};
|
|
30851
|
+
}
|
|
30852
|
+
const activeNonLeadMembers = config.members.filter((m) => m.status === "active" && m.agentId !== config.leadAgentId);
|
|
30853
|
+
if (activeNonLeadMembers.length > 0) {
|
|
30854
|
+
const activeNames = activeNonLeadMembers.map((m) => m.name).join(", ");
|
|
30855
|
+
return {
|
|
30856
|
+
output: jsonToolResult({
|
|
30857
|
+
message: `Cannot delete team "${teamName}": ${activeNonLeadMembers.length} active member(s) besides lead: ${activeNames}. Ensure all agents have completed their work before deleting the team.`
|
|
30858
|
+
})
|
|
30859
|
+
};
|
|
30860
|
+
}
|
|
30861
|
+
try {
|
|
30862
|
+
deleteTeam(teamName);
|
|
30863
|
+
} catch (error) {
|
|
30864
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
30865
|
+
return {
|
|
30866
|
+
output: jsonToolResult({
|
|
30867
|
+
message: `Failed to delete team "${teamName}": ${errorMessage}`
|
|
30868
|
+
})
|
|
30869
|
+
};
|
|
30870
|
+
}
|
|
30871
|
+
return {
|
|
30872
|
+
output: jsonToolResult({
|
|
30873
|
+
message: `Team "${teamName}" deleted successfully. All team and task directories have been removed.`
|
|
30874
|
+
})
|
|
30875
|
+
};
|
|
30876
|
+
};
|
|
30877
|
+
|
|
29862
30878
|
// ../packages/agent-runtime/src/tools/handlers/list.ts
|
|
29863
30879
|
var levelcodeToolHandlers = {
|
|
29864
30880
|
add_message: handleAddMessage,
|
|
@@ -29887,6 +30903,13 @@ var levelcodeToolHandlers = {
|
|
|
29887
30903
|
str_replace: handleStrReplace,
|
|
29888
30904
|
suggest_followups: handleSuggestFollowups,
|
|
29889
30905
|
task_completed: handleTaskCompleted,
|
|
30906
|
+
task_create: handleTaskCreate,
|
|
30907
|
+
task_get: handleTaskGet,
|
|
30908
|
+
task_list: handleTaskList,
|
|
30909
|
+
task_update: handleTaskUpdate,
|
|
30910
|
+
send_message: handleSendMessage,
|
|
30911
|
+
team_create: handleTeamCreate,
|
|
30912
|
+
team_delete: handleTeamDelete,
|
|
29890
30913
|
think_deeply: handleThinkDeeply,
|
|
29891
30914
|
update_subgoal: handleUpdateSubgoal,
|
|
29892
30915
|
web_search: handleWebSearch,
|
|
@@ -29895,10 +30918,10 @@ var levelcodeToolHandlers = {
|
|
|
29895
30918
|
};
|
|
29896
30919
|
|
|
29897
30920
|
// ../common/src/tools/utils.ts
|
|
29898
|
-
function getToolCallString(
|
|
29899
|
-
const endsAgentStepValue =
|
|
30921
|
+
function getToolCallString(toolName39, input, ...endsAgentStep39) {
|
|
30922
|
+
const endsAgentStepValue = toolName39 in toolParams ? toolParams[toolName39].endsAgentStep : endsAgentStep39[0] ?? false;
|
|
29900
30923
|
return $getToolCallString({
|
|
29901
|
-
toolName:
|
|
30924
|
+
toolName: toolName39,
|
|
29902
30925
|
inputSchema: null,
|
|
29903
30926
|
input,
|
|
29904
30927
|
endsAgentStep: endsAgentStepValue
|
|
@@ -29926,7 +30949,7 @@ ${skillsXml}
|
|
|
29926
30949
|
|
|
29927
30950
|
// ../packages/agent-runtime/src/tools/prompts.ts
|
|
29928
30951
|
var import_lodash12 = __toESM(require_lodash());
|
|
29929
|
-
var
|
|
30952
|
+
var import_v466 = __toESM(require("zod/v4"));
|
|
29930
30953
|
function ensureZodSchema(schema) {
|
|
29931
30954
|
if (schema && typeof schema.safeParse === "function") {
|
|
29932
30955
|
return schema;
|
|
@@ -29935,25 +30958,25 @@ function ensureZodSchema(schema) {
|
|
|
29935
30958
|
}
|
|
29936
30959
|
function ensureJsonSchemaCompatible2(schema) {
|
|
29937
30960
|
try {
|
|
29938
|
-
|
|
30961
|
+
import_v466.default.toJSONSchema(schema, { io: "input" });
|
|
29939
30962
|
return schema;
|
|
29940
30963
|
} catch {
|
|
29941
|
-
const fallback =
|
|
30964
|
+
const fallback = import_v466.default.object({}).passthrough();
|
|
29942
30965
|
return schema.description ? fallback.describe(schema.description) : fallback;
|
|
29943
30966
|
}
|
|
29944
30967
|
}
|
|
29945
30968
|
function toJsonSchemaSafe(schema) {
|
|
29946
30969
|
try {
|
|
29947
|
-
return
|
|
30970
|
+
return import_v466.default.toJSONSchema(schema, { io: "input" });
|
|
29948
30971
|
} catch {
|
|
29949
30972
|
return { type: "object", properties: {} };
|
|
29950
30973
|
}
|
|
29951
30974
|
}
|
|
29952
30975
|
function paramsSection(params2) {
|
|
29953
|
-
const { schema, endsAgentStep:
|
|
30976
|
+
const { schema, endsAgentStep: endsAgentStep39 } = params2;
|
|
29954
30977
|
const safeSchema = ensureJsonSchemaCompatible2(schema);
|
|
29955
|
-
const schemaWithEndsAgentStepParam =
|
|
29956
|
-
[endsAgentStepParam]:
|
|
30978
|
+
const schemaWithEndsAgentStepParam = endsAgentStep39 ? safeSchema.and(import_v466.default.object({
|
|
30979
|
+
[endsAgentStepParam]: import_v466.default.literal(endsAgentStep39).describe("Easp flag must be set to true")
|
|
29957
30980
|
})) : safeSchema;
|
|
29958
30981
|
const jsonSchema = toJsonSchemaSafe(schemaWithEndsAgentStepParam);
|
|
29959
30982
|
delete jsonSchema.description;
|
|
@@ -29969,19 +30992,19 @@ function paramsSection(params2) {
|
|
|
29969
30992
|
}
|
|
29970
30993
|
function buildToolDescription(params2) {
|
|
29971
30994
|
const {
|
|
29972
|
-
toolName:
|
|
30995
|
+
toolName: toolName39,
|
|
29973
30996
|
schema,
|
|
29974
|
-
description:
|
|
29975
|
-
endsAgentStep:
|
|
30997
|
+
description: description38 = "",
|
|
30998
|
+
endsAgentStep: endsAgentStep39,
|
|
29976
30999
|
exampleInputs = []
|
|
29977
31000
|
} = params2;
|
|
29978
|
-
const descriptionWithExamples = buildArray(
|
|
31001
|
+
const descriptionWithExamples = buildArray(description38, exampleInputs.length > 0 ? `${pluralize(exampleInputs.length, "Example")}:` : "", ...exampleInputs.map((example) => getToolCallString(toolName39, example, endsAgentStep39))).join(`
|
|
29979
31002
|
|
|
29980
31003
|
`);
|
|
29981
31004
|
return buildArray([
|
|
29982
|
-
`### ${
|
|
31005
|
+
`### ${toolName39}`,
|
|
29983
31006
|
schema.description || "",
|
|
29984
|
-
paramsSection({ schema, endsAgentStep:
|
|
31007
|
+
paramsSection({ schema, endsAgentStep: endsAgentStep39 }),
|
|
29985
31008
|
descriptionWithExamples
|
|
29986
31009
|
]).join(`
|
|
29987
31010
|
|
|
@@ -30000,43 +31023,43 @@ async function getToolSet(params2) {
|
|
|
30000
31023
|
const { toolNames: toolNames2, additionalToolDefinitions, agentTools, skills } = params2;
|
|
30001
31024
|
const availableSkillsXml = formatAvailableSkillsXml(skills);
|
|
30002
31025
|
const toolSet = {};
|
|
30003
|
-
for (const
|
|
30004
|
-
if (
|
|
30005
|
-
const toolDef = toolParams[
|
|
30006
|
-
if (
|
|
30007
|
-
let
|
|
30008
|
-
|
|
30009
|
-
toolSet[
|
|
31026
|
+
for (const toolName39 of toolNames2) {
|
|
31027
|
+
if (toolName39 in toolParams) {
|
|
31028
|
+
const toolDef = toolParams[toolName39];
|
|
31029
|
+
if (toolName39 === "skill" && availableSkillsXml) {
|
|
31030
|
+
let description38 = toolDef.description ?? "";
|
|
31031
|
+
description38 = description38.replace(AVAILABLE_SKILLS_PLACEHOLDER, availableSkillsXml);
|
|
31032
|
+
toolSet[toolName39] = {
|
|
30010
31033
|
...toolDef,
|
|
30011
|
-
description:
|
|
31034
|
+
description: description38
|
|
30012
31035
|
};
|
|
30013
|
-
} else if (
|
|
30014
|
-
let
|
|
30015
|
-
|
|
31036
|
+
} else if (toolName39 === "skill") {
|
|
31037
|
+
let description38 = toolDef.description ?? "";
|
|
31038
|
+
description38 = description38.replace(AVAILABLE_SKILLS_PLACEHOLDER + `
|
|
30016
31039
|
|
|
30017
31040
|
`, "");
|
|
30018
|
-
|
|
30019
|
-
toolSet[
|
|
31041
|
+
description38 = description38.replace(AVAILABLE_SKILLS_PLACEHOLDER, "");
|
|
31042
|
+
toolSet[toolName39] = {
|
|
30020
31043
|
...toolDef,
|
|
30021
|
-
description:
|
|
31044
|
+
description: description38
|
|
30022
31045
|
};
|
|
30023
31046
|
} else {
|
|
30024
|
-
toolSet[
|
|
31047
|
+
toolSet[toolName39] = toolDef;
|
|
30025
31048
|
}
|
|
30026
31049
|
}
|
|
30027
31050
|
}
|
|
30028
31051
|
const toolDefinitions = await additionalToolDefinitions();
|
|
30029
|
-
for (const [
|
|
31052
|
+
for (const [toolName39, toolDefinition] of Object.entries(toolDefinitions)) {
|
|
30030
31053
|
const clonedDef = import_lodash12.cloneDeep(toolDefinition);
|
|
30031
31054
|
const zodSchema = ensureZodSchema(clonedDef.inputSchema);
|
|
30032
31055
|
const safeSchema = ensureJsonSchemaCompatible2(zodSchema);
|
|
30033
|
-
toolSet[
|
|
31056
|
+
toolSet[toolName39] = {
|
|
30034
31057
|
...clonedDef,
|
|
30035
31058
|
inputSchema: safeSchema
|
|
30036
31059
|
};
|
|
30037
31060
|
}
|
|
30038
|
-
for (const [
|
|
30039
|
-
toolSet[
|
|
31061
|
+
for (const [toolName39, toolDefinition] of Object.entries(agentTools)) {
|
|
31062
|
+
toolSet[toolName39] = toolDefinition;
|
|
30040
31063
|
}
|
|
30041
31064
|
return toolSet;
|
|
30042
31065
|
}
|
|
@@ -30044,30 +31067,30 @@ async function getToolSet(params2) {
|
|
|
30044
31067
|
// ../packages/agent-runtime/src/tools/tool-executor.ts
|
|
30045
31068
|
function parseRawToolCall(params2) {
|
|
30046
31069
|
const { rawToolCall } = params2;
|
|
30047
|
-
const
|
|
31070
|
+
const toolName39 = rawToolCall.toolName;
|
|
30048
31071
|
const processedParameters = rawToolCall.input;
|
|
30049
|
-
const paramsSchema = toolParams[
|
|
31072
|
+
const paramsSchema = toolParams[toolName39].inputSchema;
|
|
30050
31073
|
const result = paramsSchema.safeParse(processedParameters);
|
|
30051
31074
|
if (!result.success) {
|
|
30052
31075
|
return {
|
|
30053
|
-
toolName:
|
|
31076
|
+
toolName: toolName39,
|
|
30054
31077
|
toolCallId: rawToolCall.toolCallId,
|
|
30055
31078
|
input: rawToolCall.input,
|
|
30056
|
-
error: `Invalid parameters for ${
|
|
31079
|
+
error: `Invalid parameters for ${toolName39}: ${JSON.stringify(result.error.issues, null, 2)}`
|
|
30057
31080
|
};
|
|
30058
31081
|
}
|
|
30059
31082
|
if (endsAgentStepParam in result.data) {
|
|
30060
31083
|
delete result.data[endsAgentStepParam];
|
|
30061
31084
|
}
|
|
30062
31085
|
return {
|
|
30063
|
-
toolName:
|
|
31086
|
+
toolName: toolName39,
|
|
30064
31087
|
input: result.data,
|
|
30065
31088
|
toolCallId: rawToolCall.toolCallId
|
|
30066
31089
|
};
|
|
30067
31090
|
}
|
|
30068
31091
|
async function executeToolCall(params2) {
|
|
30069
31092
|
const {
|
|
30070
|
-
toolName:
|
|
31093
|
+
toolName: toolName39,
|
|
30071
31094
|
input,
|
|
30072
31095
|
excludeToolFromMessageHistory = false,
|
|
30073
31096
|
fromHandleSteps = false,
|
|
@@ -30086,7 +31109,7 @@ async function executeToolCall(params2) {
|
|
|
30086
31109
|
const toolCallId = params2.toolCallId ?? generateCompactId();
|
|
30087
31110
|
const toolCall = parseRawToolCall({
|
|
30088
31111
|
rawToolCall: {
|
|
30089
|
-
toolName:
|
|
31112
|
+
toolName: toolName39,
|
|
30090
31113
|
toolCallId,
|
|
30091
31114
|
input
|
|
30092
31115
|
}
|
|
@@ -30094,7 +31117,7 @@ async function executeToolCall(params2) {
|
|
|
30094
31117
|
if (toolCall.toolName && !agentTemplate.toolNames.includes(toolCall.toolName) && !fromHandleSteps) {
|
|
30095
31118
|
onResponseChunk2({
|
|
30096
31119
|
type: "error",
|
|
30097
|
-
message: `Tool \`${
|
|
31120
|
+
message: `Tool \`${toolName39}\` is not currently available. Make sure to only use tools provided at the start of the conversation AND that you most recently have permission to use.`
|
|
30098
31121
|
});
|
|
30099
31122
|
return previousToolCallFinished;
|
|
30100
31123
|
}
|
|
@@ -30103,12 +31126,12 @@ async function executeToolCall(params2) {
|
|
|
30103
31126
|
type: "error",
|
|
30104
31127
|
message: toolCall.error
|
|
30105
31128
|
});
|
|
30106
|
-
logger2.debug({ toolCall, error: toolCall.error }, `${
|
|
31129
|
+
logger2.debug({ toolCall, error: toolCall.error }, `${toolName39} error: ${toolCall.error}`);
|
|
30107
31130
|
return previousToolCallFinished;
|
|
30108
31131
|
}
|
|
30109
|
-
const transformedInput =
|
|
31132
|
+
const transformedInput = toolName39 === "spawn_agents" ? transformSpawnAgentsInput(input, agentTemplate.spawnableAgents) : input;
|
|
30110
31133
|
let effectiveInput = transformedInput;
|
|
30111
|
-
if (
|
|
31134
|
+
if (toolName39 === "spawn_agents") {
|
|
30112
31135
|
const agents = transformedInput.agents;
|
|
30113
31136
|
if (Array.isArray(agents)) {
|
|
30114
31137
|
const BASE_AGENTS = [
|
|
@@ -30170,7 +31193,7 @@ async function executeToolCall(params2) {
|
|
|
30170
31193
|
if (validAgents.length === 0) {
|
|
30171
31194
|
const errorMsg2 = `Failed to spawn agents: ${errors.join("; ")}`;
|
|
30172
31195
|
onResponseChunk2({ type: "error", message: errorMsg2 });
|
|
30173
|
-
logger2.debug({ toolName:
|
|
31196
|
+
logger2.debug({ toolName: toolName39, errors }, "All agents in spawn_agents are invalid, not streaming tool call");
|
|
30174
31197
|
return previousToolCallFinished;
|
|
30175
31198
|
}
|
|
30176
31199
|
const errorMsg = `Some agents could not be spawned: ${errors.join("; ")}. Proceeding with valid agents only.`;
|
|
@@ -30182,15 +31205,15 @@ async function executeToolCall(params2) {
|
|
|
30182
31205
|
onResponseChunk2({
|
|
30183
31206
|
type: "tool_call",
|
|
30184
31207
|
toolCallId,
|
|
30185
|
-
toolName:
|
|
31208
|
+
toolName: toolName39,
|
|
30186
31209
|
input: effectiveInput,
|
|
30187
31210
|
agentId: agentState2.agentId,
|
|
30188
31211
|
parentAgentId: agentState2.parentId,
|
|
30189
31212
|
includeToolCall: !excludeToolFromMessageHistory
|
|
30190
31213
|
});
|
|
30191
31214
|
toolCalls2.push(toolCall);
|
|
30192
|
-
const handler = levelcodeToolHandlers[
|
|
30193
|
-
const finalToolCall =
|
|
31215
|
+
const handler = levelcodeToolHandlers[toolName39];
|
|
31216
|
+
const finalToolCall = toolName39 === "spawn_agents" ? { ...toolCall, input: effectiveInput } : toolCall;
|
|
30194
31217
|
const toolResultPromise = handler({
|
|
30195
31218
|
...params2,
|
|
30196
31219
|
toolCall: finalToolCall,
|
|
@@ -30211,7 +31234,7 @@ async function executeToolCall(params2) {
|
|
|
30211
31234
|
return toolResultPromise.then(async ({ output, creditsUsed }) => {
|
|
30212
31235
|
const toolResult2 = {
|
|
30213
31236
|
role: "tool",
|
|
30214
|
-
toolName:
|
|
31237
|
+
toolName: toolName39,
|
|
30215
31238
|
toolCallId: toolCall.toolCallId,
|
|
30216
31239
|
content: output
|
|
30217
31240
|
};
|
|
@@ -30227,19 +31250,19 @@ async function executeToolCall(params2) {
|
|
|
30227
31250
|
}
|
|
30228
31251
|
if (creditsUsed) {
|
|
30229
31252
|
onCostCalculated(creditsUsed);
|
|
30230
|
-
logger2.debug({ credits: creditsUsed, totalCredits: agentState2.creditsUsed }, `Added ${creditsUsed} credits from ${
|
|
31253
|
+
logger2.debug({ credits: creditsUsed, totalCredits: agentState2.creditsUsed }, `Added ${creditsUsed} credits from ${toolName39} to agent state`);
|
|
30231
31254
|
}
|
|
30232
31255
|
});
|
|
30233
31256
|
}
|
|
30234
31257
|
function parseRawCustomToolCall(params2) {
|
|
30235
31258
|
const { customToolDefs, rawToolCall, autoInsertEndStepParam = false } = params2;
|
|
30236
|
-
const
|
|
30237
|
-
if (!(customToolDefs && (
|
|
31259
|
+
const toolName39 = rawToolCall.toolName;
|
|
31260
|
+
if (!(customToolDefs && (toolName39 in customToolDefs)) && !toolName39.includes(MCP_TOOL_SEPARATOR)) {
|
|
30238
31261
|
return {
|
|
30239
|
-
toolName:
|
|
31262
|
+
toolName: toolName39,
|
|
30240
31263
|
toolCallId: rawToolCall.toolCallId,
|
|
30241
31264
|
input: rawToolCall.input,
|
|
30242
|
-
error: `Tool ${
|
|
31265
|
+
error: `Tool ${toolName39} not found`
|
|
30243
31266
|
};
|
|
30244
31267
|
}
|
|
30245
31268
|
const processedParameters = {};
|
|
@@ -30247,18 +31270,18 @@ function parseRawCustomToolCall(params2) {
|
|
|
30247
31270
|
processedParameters[param] = val;
|
|
30248
31271
|
}
|
|
30249
31272
|
if (autoInsertEndStepParam) {
|
|
30250
|
-
processedParameters[endsAgentStepParam] = customToolDefs?.[
|
|
31273
|
+
processedParameters[endsAgentStepParam] = customToolDefs?.[toolName39]?.endsAgentStep;
|
|
30251
31274
|
}
|
|
30252
|
-
const rawSchema = customToolDefs?.[
|
|
31275
|
+
const rawSchema = customToolDefs?.[toolName39]?.inputSchema;
|
|
30253
31276
|
if (rawSchema) {
|
|
30254
31277
|
const paramsSchema = ensureZodSchema(rawSchema);
|
|
30255
31278
|
const result = paramsSchema.safeParse(processedParameters);
|
|
30256
31279
|
if (!result.success) {
|
|
30257
31280
|
return {
|
|
30258
|
-
toolName:
|
|
31281
|
+
toolName: toolName39,
|
|
30259
31282
|
toolCallId: rawToolCall.toolCallId,
|
|
30260
31283
|
input: rawToolCall.input,
|
|
30261
|
-
error: `Invalid parameters for ${
|
|
31284
|
+
error: `Invalid parameters for ${toolName39}: ${JSON.stringify(result.error.issues, null, 2)}`
|
|
30262
31285
|
};
|
|
30263
31286
|
}
|
|
30264
31287
|
}
|
|
@@ -30267,14 +31290,14 @@ function parseRawCustomToolCall(params2) {
|
|
|
30267
31290
|
delete input[endsAgentStepParam];
|
|
30268
31291
|
}
|
|
30269
31292
|
return {
|
|
30270
|
-
toolName:
|
|
31293
|
+
toolName: toolName39,
|
|
30271
31294
|
input,
|
|
30272
31295
|
toolCallId: rawToolCall.toolCallId
|
|
30273
31296
|
};
|
|
30274
31297
|
}
|
|
30275
31298
|
async function executeCustomToolCall(params2) {
|
|
30276
31299
|
const {
|
|
30277
|
-
toolName:
|
|
31300
|
+
toolName: toolName39,
|
|
30278
31301
|
input,
|
|
30279
31302
|
autoInsertEndStepParam = false,
|
|
30280
31303
|
excludeToolFromMessageHistory = false,
|
|
@@ -30300,7 +31323,7 @@ async function executeCustomToolCall(params2) {
|
|
|
30300
31323
|
writeTo: import_lodash13.cloneDeep(fileContext.customToolDefinitions)
|
|
30301
31324
|
}),
|
|
30302
31325
|
rawToolCall: {
|
|
30303
|
-
toolName:
|
|
31326
|
+
toolName: toolName39,
|
|
30304
31327
|
toolCallId: toolCallId ?? generateCompactId(),
|
|
30305
31328
|
input
|
|
30306
31329
|
},
|
|
@@ -30309,7 +31332,7 @@ async function executeCustomToolCall(params2) {
|
|
|
30309
31332
|
if (toolCall.toolName && !agentTemplate.toolNames.includes(toolCall.toolName) && !fromHandleSteps && !(toolCall.toolName.includes(MCP_TOOL_SEPARATOR) && (toolCall.toolName.split(MCP_TOOL_SEPARATOR)[0] in agentTemplate.mcpServers))) {
|
|
30310
31333
|
onResponseChunk2({
|
|
30311
31334
|
type: "error",
|
|
30312
|
-
message: `Tool \`${
|
|
31335
|
+
message: `Tool \`${toolName39}\` is not currently available. Make sure to only use tools listed in the system instructions.`
|
|
30313
31336
|
});
|
|
30314
31337
|
return previousToolCallFinished;
|
|
30315
31338
|
}
|
|
@@ -30318,13 +31341,13 @@ async function executeCustomToolCall(params2) {
|
|
|
30318
31341
|
type: "error",
|
|
30319
31342
|
message: toolCall.error
|
|
30320
31343
|
});
|
|
30321
|
-
logger2.debug({ toolCall, error: toolCall.error }, `${
|
|
31344
|
+
logger2.debug({ toolCall, error: toolCall.error }, `${toolName39} error: ${toolCall.error}`);
|
|
30322
31345
|
return previousToolCallFinished;
|
|
30323
31346
|
}
|
|
30324
31347
|
onResponseChunk2({
|
|
30325
31348
|
type: "tool_call",
|
|
30326
31349
|
toolCallId: toolCall.toolCallId,
|
|
30327
|
-
toolName:
|
|
31350
|
+
toolName: toolName39,
|
|
30328
31351
|
input: toolCall.input,
|
|
30329
31352
|
...agentState2?.parentId && { agentId: agentState2.agentId },
|
|
30330
31353
|
...excludeToolFromMessageHistory && { includeToolCall: false }
|
|
@@ -30334,10 +31357,10 @@ async function executeCustomToolCall(params2) {
|
|
|
30334
31357
|
if (params2.signal.aborted) {
|
|
30335
31358
|
return null;
|
|
30336
31359
|
}
|
|
30337
|
-
const
|
|
31360
|
+
const toolName40 = toolCall.toolName.includes(MCP_TOOL_SEPARATOR) ? toolCall.toolName.split(MCP_TOOL_SEPARATOR).slice(1).join(MCP_TOOL_SEPARATOR) : toolCall.toolName;
|
|
30338
31361
|
const clientToolResult = await requestToolCall({
|
|
30339
31362
|
userInputId: userInputId2,
|
|
30340
|
-
toolName:
|
|
31363
|
+
toolName: toolName40,
|
|
30341
31364
|
input: toolCall.input,
|
|
30342
31365
|
mcpConfig: toolCall.toolName.includes(MCP_TOOL_SEPARATOR) ? agentTemplate.mcpServers[toolCall.toolName.split(MCP_TOOL_SEPARATOR)[0]] : undefined
|
|
30343
31366
|
});
|
|
@@ -30348,11 +31371,11 @@ async function executeCustomToolCall(params2) {
|
|
|
30348
31371
|
}
|
|
30349
31372
|
const toolResult2 = {
|
|
30350
31373
|
role: "tool",
|
|
30351
|
-
toolName:
|
|
31374
|
+
toolName: toolName39,
|
|
30352
31375
|
toolCallId: toolCall.toolCallId,
|
|
30353
31376
|
content: result
|
|
30354
31377
|
};
|
|
30355
|
-
logger2.debug({ input, toolResult: toolResult2 }, `${
|
|
31378
|
+
logger2.debug({ input, toolResult: toolResult2 }, `${toolName39} custom tool call & result (${toolResult2.toolCallId})`);
|
|
30356
31379
|
if (result === undefined) {
|
|
30357
31380
|
return;
|
|
30358
31381
|
}
|
|
@@ -30370,14 +31393,14 @@ async function executeCustomToolCall(params2) {
|
|
|
30370
31393
|
});
|
|
30371
31394
|
}
|
|
30372
31395
|
function tryTransformAgentToolCall(params2) {
|
|
30373
|
-
const { toolName:
|
|
31396
|
+
const { toolName: toolName39, input, spawnableAgents } = params2;
|
|
30374
31397
|
const agentShortNames = spawnableAgents.map(getAgentShortName);
|
|
30375
|
-
if (!agentShortNames.includes(
|
|
31398
|
+
if (!agentShortNames.includes(toolName39)) {
|
|
30376
31399
|
return null;
|
|
30377
31400
|
}
|
|
30378
|
-
const fullAgentType = spawnableAgents.find((agentType) => getAgentShortName(agentType) ===
|
|
31401
|
+
const fullAgentType = spawnableAgents.find((agentType) => getAgentShortName(agentType) === toolName39);
|
|
30379
31402
|
const agentEntry = {
|
|
30380
|
-
agent_type: fullAgentType ||
|
|
31403
|
+
agent_type: fullAgentType || toolName39
|
|
30381
31404
|
};
|
|
30382
31405
|
if (typeof input.prompt === "string") {
|
|
30383
31406
|
agentEntry.prompt = input.prompt;
|
|
@@ -30406,14 +31429,14 @@ function parseTextWithToolCalls(text) {
|
|
|
30406
31429
|
const jsonContent = match[1].trim();
|
|
30407
31430
|
try {
|
|
30408
31431
|
const parsed = JSON.parse(jsonContent);
|
|
30409
|
-
const
|
|
30410
|
-
if (typeof
|
|
31432
|
+
const toolName39 = parsed[toolNameParam];
|
|
31433
|
+
if (typeof toolName39 === "string") {
|
|
30411
31434
|
const input = { ...parsed };
|
|
30412
31435
|
delete input[toolNameParam];
|
|
30413
31436
|
delete input["cb_easp"];
|
|
30414
31437
|
segments.push({
|
|
30415
31438
|
type: "tool_call",
|
|
30416
|
-
toolName:
|
|
31439
|
+
toolName: toolName39,
|
|
30417
31440
|
input
|
|
30418
31441
|
});
|
|
30419
31442
|
}
|
|
@@ -30785,7 +31808,7 @@ function isKnowledgeFile(filePath) {
|
|
|
30785
31808
|
}
|
|
30786
31809
|
|
|
30787
31810
|
// ../packages/agent-runtime/src/templates/strings.ts
|
|
30788
|
-
var
|
|
31811
|
+
var import_v467 = require("zod/v4");
|
|
30789
31812
|
|
|
30790
31813
|
// ../packages/agent-runtime/src/templates/types.ts
|
|
30791
31814
|
var placeholderNames = [
|
|
@@ -30866,10 +31889,10 @@ async function formatPrompt(params2) {
|
|
|
30866
31889
|
...Object.fromEntries(Object.entries(fileContext.knowledgeFiles).filter(([filePath]) => {
|
|
30867
31890
|
const lowerPath = filePath.toLowerCase();
|
|
30868
31891
|
return KNOWLEDGE_FILE_NAMES_LOWERCASE.includes(lowerPath);
|
|
30869
|
-
}).map(([
|
|
31892
|
+
}).map(([path6, content]) => [path6, content.trim()])),
|
|
30870
31893
|
...fileContext.userKnowledgeFiles
|
|
30871
|
-
}).map(([
|
|
30872
|
-
return `\`\`\`${
|
|
31894
|
+
}).map(([path6, content]) => {
|
|
31895
|
+
return `\`\`\`${path6}
|
|
30873
31896
|
${content.trim()}
|
|
30874
31897
|
\`\`\``;
|
|
30875
31898
|
}).join(`
|
|
@@ -30949,7 +31972,7 @@ ${agentDescriptions.join(`
|
|
|
30949
31972
|
`;
|
|
30950
31973
|
addendum += "```json\n";
|
|
30951
31974
|
try {
|
|
30952
|
-
const jsonSchema =
|
|
31975
|
+
const jsonSchema = import_v467.z.toJSONSchema(outputSchema3, {
|
|
30953
31976
|
io: "input"
|
|
30954
31977
|
});
|
|
30955
31978
|
delete jsonSchema["$schema"];
|
|
@@ -31030,14 +32053,14 @@ function parseToolCallContent(content) {
|
|
|
31030
32053
|
}
|
|
31031
32054
|
try {
|
|
31032
32055
|
const parsed = JSON.parse(trimmed);
|
|
31033
|
-
const
|
|
31034
|
-
if (typeof
|
|
32056
|
+
const toolName39 = parsed[toolNameParam];
|
|
32057
|
+
if (typeof toolName39 !== "string") {
|
|
31035
32058
|
return null;
|
|
31036
32059
|
}
|
|
31037
32060
|
const input = { ...parsed };
|
|
31038
32061
|
delete input[toolNameParam];
|
|
31039
32062
|
delete input["cb_easp"];
|
|
31040
|
-
return { toolName:
|
|
32063
|
+
return { toolName: toolName39, input };
|
|
31041
32064
|
} catch {
|
|
31042
32065
|
return null;
|
|
31043
32066
|
}
|
|
@@ -31072,13 +32095,13 @@ async function* processStreamWithTools(params2) {
|
|
|
31072
32095
|
let autocompleted = false;
|
|
31073
32096
|
const xmlParserState = createStreamParserState();
|
|
31074
32097
|
function processToolCallObject(params3) {
|
|
31075
|
-
const { toolName:
|
|
31076
|
-
const processor = processors[
|
|
32098
|
+
const { toolName: toolName39, input, contents } = params3;
|
|
32099
|
+
const processor = processors[toolName39] ?? defaultProcessor(toolName39);
|
|
31077
32100
|
trackEvent2({
|
|
31078
32101
|
event: "backend.tool_use" /* TOOL_USE */,
|
|
31079
32102
|
userId: loggerOptions?.userId ?? "",
|
|
31080
32103
|
properties: {
|
|
31081
|
-
toolName:
|
|
32104
|
+
toolName: toolName39,
|
|
31082
32105
|
contents,
|
|
31083
32106
|
parsedParams: input,
|
|
31084
32107
|
autocompleted,
|
|
@@ -31087,8 +32110,8 @@ async function* processStreamWithTools(params2) {
|
|
|
31087
32110
|
},
|
|
31088
32111
|
logger: logger2
|
|
31089
32112
|
});
|
|
31090
|
-
processor.onTagStart(
|
|
31091
|
-
processor.onTagEnd(
|
|
32113
|
+
processor.onTagStart(toolName39, {});
|
|
32114
|
+
processor.onTagEnd(toolName39, input);
|
|
31092
32115
|
}
|
|
31093
32116
|
function flush() {
|
|
31094
32117
|
if (buffer) {
|
|
@@ -31203,7 +32226,7 @@ async function processStream(params2) {
|
|
|
31203
32226
|
return onResponseChunk2(chunk);
|
|
31204
32227
|
};
|
|
31205
32228
|
}
|
|
31206
|
-
function createToolExecutionCallback(
|
|
32229
|
+
function createToolExecutionCallback(toolName39, isXmlMode) {
|
|
31207
32230
|
const responseHandler = createResponseHandler(isXmlMode);
|
|
31208
32231
|
const resultsArray = isXmlMode ? [] : toolResultsToAddAfterStream;
|
|
31209
32232
|
return {
|
|
@@ -31213,9 +32236,9 @@ async function processStream(params2) {
|
|
|
31213
32236
|
return;
|
|
31214
32237
|
}
|
|
31215
32238
|
const toolCallId = generateCompactId();
|
|
31216
|
-
const isNativeTool = toolNames.includes(
|
|
32239
|
+
const isNativeTool = toolNames.includes(toolName39);
|
|
31217
32240
|
const transformed = !isNativeTool ? tryTransformAgentToolCall({
|
|
31218
|
-
toolName:
|
|
32241
|
+
toolName: toolName39,
|
|
31219
32242
|
input,
|
|
31220
32243
|
spawnableAgents: agentTemplate.spawnableAgents
|
|
31221
32244
|
}) : null;
|
|
@@ -31224,7 +32247,7 @@ async function processStream(params2) {
|
|
|
31224
32247
|
if (isNativeTool || transformed) {
|
|
31225
32248
|
toolPromise = executeToolCall({
|
|
31226
32249
|
...params2,
|
|
31227
|
-
toolName: transformed ? transformed.toolName :
|
|
32250
|
+
toolName: transformed ? transformed.toolName : toolName39,
|
|
31228
32251
|
input: transformed ? transformed.input : input,
|
|
31229
32252
|
fromHandleSteps: false,
|
|
31230
32253
|
skipDirectResultPush: isXmlMode,
|
|
@@ -31241,7 +32264,7 @@ async function processStream(params2) {
|
|
|
31241
32264
|
} else {
|
|
31242
32265
|
toolPromise = executeCustomToolCall({
|
|
31243
32266
|
...params2,
|
|
31244
|
-
toolName:
|
|
32267
|
+
toolName: toolName39,
|
|
31245
32268
|
input,
|
|
31246
32269
|
skipDirectResultPush: isXmlMode,
|
|
31247
32270
|
fileProcessingState: fileProcessingState2,
|
|
@@ -31274,10 +32297,10 @@ async function processStream(params2) {
|
|
|
31274
32297
|
])
|
|
31275
32298
|
]),
|
|
31276
32299
|
defaultProcessor: (name) => createToolExecutionCallback(name, false),
|
|
31277
|
-
onError: (
|
|
32300
|
+
onError: (toolName39, error) => {
|
|
31278
32301
|
const toolResult2 = {
|
|
31279
32302
|
role: "tool",
|
|
31280
|
-
toolName:
|
|
32303
|
+
toolName: toolName39,
|
|
31281
32304
|
toolCallId: generateCompactId(),
|
|
31282
32305
|
content: jsonToolResult({ errorMessage: error })
|
|
31283
32306
|
};
|
|
@@ -31299,12 +32322,12 @@ async function processStream(params2) {
|
|
|
31299
32322
|
}
|
|
31300
32323
|
return onResponseChunk2(chunk);
|
|
31301
32324
|
},
|
|
31302
|
-
executeXmlToolCall: async ({ toolName:
|
|
32325
|
+
executeXmlToolCall: async ({ toolName: toolName39, input }) => {
|
|
31303
32326
|
if (signal.aborted) {
|
|
31304
32327
|
return;
|
|
31305
32328
|
}
|
|
31306
|
-
const callback = createToolExecutionCallback(
|
|
31307
|
-
await callback.onTagEnd(
|
|
32329
|
+
const callback = createToolExecutionCallback(toolName39, true);
|
|
32330
|
+
await callback.onTagEnd(toolName39, input);
|
|
31308
32331
|
}
|
|
31309
32332
|
});
|
|
31310
32333
|
let messageId = null;
|
|
@@ -31422,7 +32445,7 @@ function getAgentOutput(agentState2, agentTemplate) {
|
|
|
31422
32445
|
// ../packages/agent-runtime/src/run-agent-step.ts
|
|
31423
32446
|
async function additionalToolDefinitions(params2) {
|
|
31424
32447
|
const { agentTemplate, fileContext } = params2;
|
|
31425
|
-
const defs = import_lodash16.cloneDeep(Object.fromEntries(Object.entries(fileContext.customToolDefinitions).filter(([
|
|
32448
|
+
const defs = import_lodash16.cloneDeep(Object.fromEntries(Object.entries(fileContext.customToolDefinitions).filter(([toolName39]) => agentTemplate.toolNames.includes(toolName39))));
|
|
31426
32449
|
return getMCPToolData({
|
|
31427
32450
|
...params2,
|
|
31428
32451
|
toolNames: agentTemplate.toolNames,
|
|
@@ -33253,8 +34276,8 @@ class Client extends Protocol {
|
|
|
33253
34276
|
}
|
|
33254
34277
|
}
|
|
33255
34278
|
}
|
|
33256
|
-
getToolOutputValidator(
|
|
33257
|
-
return this._cachedToolOutputValidators.get(
|
|
34279
|
+
getToolOutputValidator(toolName39) {
|
|
34280
|
+
return this._cachedToolOutputValidators.get(toolName39);
|
|
33258
34281
|
}
|
|
33259
34282
|
async listTools(params2, options) {
|
|
33260
34283
|
const result = await this.request({ method: "tools/list", params: params2 }, ListToolsResultSchema, options);
|
|
@@ -35226,7 +36249,7 @@ var getCiEnv = () => ({
|
|
|
35226
36249
|
var ciEnv = getCiEnv();
|
|
35227
36250
|
|
|
35228
36251
|
// src/impl/database.ts
|
|
35229
|
-
var
|
|
36252
|
+
var import_v468 = __toESM(require("zod/v4"));
|
|
35230
36253
|
|
|
35231
36254
|
// src/constants.ts
|
|
35232
36255
|
var LEVELCODE_BINARY = "levelcode";
|
|
@@ -35392,8 +36415,8 @@ var RECONNECTION_RETRY_DELAY_MS = 500;
|
|
|
35392
36415
|
|
|
35393
36416
|
// src/impl/database.ts
|
|
35394
36417
|
var userInfoCache = {};
|
|
35395
|
-
var agentsResponseSchema =
|
|
35396
|
-
version:
|
|
36418
|
+
var agentsResponseSchema = import_v468.default.object({
|
|
36419
|
+
version: import_v468.default.string(),
|
|
35397
36420
|
data: DynamicAgentTemplateSchema
|
|
35398
36421
|
});
|
|
35399
36422
|
async function fetchWithRetry(url, options, logger2) {
|
|
@@ -36132,30 +37155,30 @@ function loadApiKey({
|
|
|
36132
37155
|
apiKey,
|
|
36133
37156
|
environmentVariableName,
|
|
36134
37157
|
apiKeyParameterName = "apiKey",
|
|
36135
|
-
description:
|
|
37158
|
+
description: description38
|
|
36136
37159
|
}) {
|
|
36137
37160
|
if (typeof apiKey === "string") {
|
|
36138
37161
|
return apiKey;
|
|
36139
37162
|
}
|
|
36140
37163
|
if (apiKey != null) {
|
|
36141
37164
|
throw new LoadAPIKeyError({
|
|
36142
|
-
message: `${
|
|
37165
|
+
message: `${description38} API key must be a string.`
|
|
36143
37166
|
});
|
|
36144
37167
|
}
|
|
36145
37168
|
if (typeof process === "undefined") {
|
|
36146
37169
|
throw new LoadAPIKeyError({
|
|
36147
|
-
message: `${
|
|
37170
|
+
message: `${description38} API key is missing. Pass it using the '${apiKeyParameterName}' parameter. Environment variables is not supported in this environment.`
|
|
36148
37171
|
});
|
|
36149
37172
|
}
|
|
36150
37173
|
apiKey = process.env[environmentVariableName];
|
|
36151
37174
|
if (apiKey == null) {
|
|
36152
37175
|
throw new LoadAPIKeyError({
|
|
36153
|
-
message: `${
|
|
37176
|
+
message: `${description38} API key is missing. Pass it using the '${apiKeyParameterName}' parameter or the ${environmentVariableName} environment variable.`
|
|
36154
37177
|
});
|
|
36155
37178
|
}
|
|
36156
37179
|
if (typeof apiKey !== "string") {
|
|
36157
37180
|
throw new LoadAPIKeyError({
|
|
36158
|
-
message: `${
|
|
37181
|
+
message: `${description38} API key must be a string. The value of the ${environmentVariableName} environment variable is not a string.`
|
|
36159
37182
|
});
|
|
36160
37183
|
}
|
|
36161
37184
|
return apiKey;
|
|
@@ -36541,7 +37564,7 @@ function withoutTrailingSlash(url) {
|
|
|
36541
37564
|
}
|
|
36542
37565
|
|
|
36543
37566
|
// ../packages/internal/src/openai-compatible/chat/openai-compatible-chat-language-model.ts
|
|
36544
|
-
var
|
|
37567
|
+
var import_v471 = require("zod/v4");
|
|
36545
37568
|
|
|
36546
37569
|
// ../packages/internal/src/openai-compatible/chat/convert-to-openai-compatible-chat-messages.ts
|
|
36547
37570
|
function getOpenAIMetadata(message) {
|
|
@@ -36684,21 +37707,21 @@ function mapOpenAICompatibleFinishReason(finishReason) {
|
|
|
36684
37707
|
}
|
|
36685
37708
|
|
|
36686
37709
|
// ../packages/internal/src/openai-compatible/chat/openai-compatible-chat-options.ts
|
|
36687
|
-
var
|
|
36688
|
-
var openaiCompatibleProviderOptions =
|
|
36689
|
-
user:
|
|
36690
|
-
reasoningEffort:
|
|
36691
|
-
textVerbosity:
|
|
37710
|
+
var import_v469 = require("zod/v4");
|
|
37711
|
+
var openaiCompatibleProviderOptions = import_v469.z.object({
|
|
37712
|
+
user: import_v469.z.string().optional(),
|
|
37713
|
+
reasoningEffort: import_v469.z.string().optional(),
|
|
37714
|
+
textVerbosity: import_v469.z.string().optional()
|
|
36692
37715
|
});
|
|
36693
37716
|
|
|
36694
37717
|
// ../packages/internal/src/openai-compatible/openai-compatible-error.ts
|
|
36695
|
-
var
|
|
36696
|
-
var openaiCompatibleErrorDataSchema =
|
|
36697
|
-
error:
|
|
36698
|
-
message:
|
|
36699
|
-
type:
|
|
36700
|
-
param:
|
|
36701
|
-
code:
|
|
37718
|
+
var import_v470 = require("zod/v4");
|
|
37719
|
+
var openaiCompatibleErrorDataSchema = import_v470.z.object({
|
|
37720
|
+
error: import_v470.z.object({
|
|
37721
|
+
message: import_v470.z.string(),
|
|
37722
|
+
type: import_v470.z.string().nullish(),
|
|
37723
|
+
param: import_v470.z.any().nullish(),
|
|
37724
|
+
code: import_v470.z.union([import_v470.z.string(), import_v470.z.number()]).nullish()
|
|
36702
37725
|
})
|
|
36703
37726
|
});
|
|
36704
37727
|
var defaultOpenAICompatibleErrorStructure = {
|
|
@@ -37184,62 +38207,62 @@ class OpenAICompatibleChatLanguageModel {
|
|
|
37184
38207
|
};
|
|
37185
38208
|
}
|
|
37186
38209
|
}
|
|
37187
|
-
var openaiCompatibleTokenUsageSchema =
|
|
37188
|
-
prompt_tokens:
|
|
37189
|
-
completion_tokens:
|
|
37190
|
-
total_tokens:
|
|
37191
|
-
prompt_tokens_details:
|
|
37192
|
-
cached_tokens:
|
|
38210
|
+
var openaiCompatibleTokenUsageSchema = import_v471.z.object({
|
|
38211
|
+
prompt_tokens: import_v471.z.number().nullish(),
|
|
38212
|
+
completion_tokens: import_v471.z.number().nullish(),
|
|
38213
|
+
total_tokens: import_v471.z.number().nullish(),
|
|
38214
|
+
prompt_tokens_details: import_v471.z.object({
|
|
38215
|
+
cached_tokens: import_v471.z.number().nullish()
|
|
37193
38216
|
}).nullish(),
|
|
37194
|
-
completion_tokens_details:
|
|
37195
|
-
reasoning_tokens:
|
|
37196
|
-
accepted_prediction_tokens:
|
|
37197
|
-
rejected_prediction_tokens:
|
|
38217
|
+
completion_tokens_details: import_v471.z.object({
|
|
38218
|
+
reasoning_tokens: import_v471.z.number().nullish(),
|
|
38219
|
+
accepted_prediction_tokens: import_v471.z.number().nullish(),
|
|
38220
|
+
rejected_prediction_tokens: import_v471.z.number().nullish()
|
|
37198
38221
|
}).nullish()
|
|
37199
38222
|
}).nullish();
|
|
37200
|
-
var OpenAICompatibleChatResponseSchema =
|
|
37201
|
-
id:
|
|
37202
|
-
created:
|
|
37203
|
-
model:
|
|
37204
|
-
choices:
|
|
37205
|
-
message:
|
|
37206
|
-
role:
|
|
37207
|
-
content:
|
|
37208
|
-
reasoning_content:
|
|
37209
|
-
reasoning:
|
|
37210
|
-
tool_calls:
|
|
37211
|
-
id:
|
|
37212
|
-
function:
|
|
37213
|
-
name:
|
|
37214
|
-
arguments:
|
|
38223
|
+
var OpenAICompatibleChatResponseSchema = import_v471.z.object({
|
|
38224
|
+
id: import_v471.z.string().nullish(),
|
|
38225
|
+
created: import_v471.z.number().nullish(),
|
|
38226
|
+
model: import_v471.z.string().nullish(),
|
|
38227
|
+
choices: import_v471.z.array(import_v471.z.object({
|
|
38228
|
+
message: import_v471.z.object({
|
|
38229
|
+
role: import_v471.z.literal("assistant").nullish(),
|
|
38230
|
+
content: import_v471.z.string().nullish(),
|
|
38231
|
+
reasoning_content: import_v471.z.string().nullish(),
|
|
38232
|
+
reasoning: import_v471.z.string().nullish(),
|
|
38233
|
+
tool_calls: import_v471.z.array(import_v471.z.object({
|
|
38234
|
+
id: import_v471.z.string().nullish(),
|
|
38235
|
+
function: import_v471.z.object({
|
|
38236
|
+
name: import_v471.z.string(),
|
|
38237
|
+
arguments: import_v471.z.string()
|
|
37215
38238
|
})
|
|
37216
38239
|
})).nullish()
|
|
37217
38240
|
}),
|
|
37218
|
-
finish_reason:
|
|
38241
|
+
finish_reason: import_v471.z.string().nullish()
|
|
37219
38242
|
})),
|
|
37220
38243
|
usage: openaiCompatibleTokenUsageSchema
|
|
37221
38244
|
});
|
|
37222
|
-
var createOpenAICompatibleChatChunkSchema = (errorSchema) =>
|
|
37223
|
-
|
|
37224
|
-
id:
|
|
37225
|
-
created:
|
|
37226
|
-
model:
|
|
37227
|
-
choices:
|
|
37228
|
-
delta:
|
|
37229
|
-
role:
|
|
37230
|
-
content:
|
|
37231
|
-
reasoning_content:
|
|
37232
|
-
reasoning:
|
|
37233
|
-
tool_calls:
|
|
37234
|
-
index:
|
|
37235
|
-
id:
|
|
37236
|
-
function:
|
|
37237
|
-
name:
|
|
37238
|
-
arguments:
|
|
38245
|
+
var createOpenAICompatibleChatChunkSchema = (errorSchema) => import_v471.z.union([
|
|
38246
|
+
import_v471.z.object({
|
|
38247
|
+
id: import_v471.z.string().nullish(),
|
|
38248
|
+
created: import_v471.z.number().nullish(),
|
|
38249
|
+
model: import_v471.z.string().nullish(),
|
|
38250
|
+
choices: import_v471.z.array(import_v471.z.object({
|
|
38251
|
+
delta: import_v471.z.object({
|
|
38252
|
+
role: import_v471.z.enum(["assistant"]).nullish(),
|
|
38253
|
+
content: import_v471.z.string().nullish(),
|
|
38254
|
+
reasoning_content: import_v471.z.string().nullish(),
|
|
38255
|
+
reasoning: import_v471.z.string().nullish(),
|
|
38256
|
+
tool_calls: import_v471.z.array(import_v471.z.object({
|
|
38257
|
+
index: import_v471.z.number(),
|
|
38258
|
+
id: import_v471.z.string().nullish(),
|
|
38259
|
+
function: import_v471.z.object({
|
|
38260
|
+
name: import_v471.z.string().nullish(),
|
|
38261
|
+
arguments: import_v471.z.string().nullish()
|
|
37239
38262
|
})
|
|
37240
38263
|
})).nullish()
|
|
37241
38264
|
}).nullish(),
|
|
37242
|
-
finish_reason:
|
|
38265
|
+
finish_reason: import_v471.z.string().nullish()
|
|
37243
38266
|
})),
|
|
37244
38267
|
usage: openaiCompatibleTokenUsageSchema
|
|
37245
38268
|
}),
|
|
@@ -37280,30 +38303,30 @@ function getFileUrl({
|
|
|
37280
38303
|
}
|
|
37281
38304
|
|
|
37282
38305
|
// ../packages/internal/src/openrouter-ai-sdk/schemas/reasoning-details.ts
|
|
37283
|
-
var
|
|
37284
|
-
var ReasoningDetailSummarySchema =
|
|
37285
|
-
type:
|
|
37286
|
-
summary:
|
|
38306
|
+
var import_v472 = require("zod/v4");
|
|
38307
|
+
var ReasoningDetailSummarySchema = import_v472.z.object({
|
|
38308
|
+
type: import_v472.z.literal("reasoning.summary" /* Summary */),
|
|
38309
|
+
summary: import_v472.z.string()
|
|
37287
38310
|
});
|
|
37288
|
-
var ReasoningDetailEncryptedSchema =
|
|
37289
|
-
type:
|
|
37290
|
-
data:
|
|
38311
|
+
var ReasoningDetailEncryptedSchema = import_v472.z.object({
|
|
38312
|
+
type: import_v472.z.literal("reasoning.encrypted" /* Encrypted */),
|
|
38313
|
+
data: import_v472.z.string()
|
|
37291
38314
|
});
|
|
37292
|
-
var ReasoningDetailTextSchema =
|
|
37293
|
-
type:
|
|
37294
|
-
text:
|
|
37295
|
-
signature:
|
|
38315
|
+
var ReasoningDetailTextSchema = import_v472.z.object({
|
|
38316
|
+
type: import_v472.z.literal("reasoning.text" /* Text */),
|
|
38317
|
+
text: import_v472.z.string().nullish(),
|
|
38318
|
+
signature: import_v472.z.string().nullish()
|
|
37296
38319
|
});
|
|
37297
|
-
var ReasoningDetailUnionSchema =
|
|
38320
|
+
var ReasoningDetailUnionSchema = import_v472.z.union([
|
|
37298
38321
|
ReasoningDetailSummarySchema,
|
|
37299
38322
|
ReasoningDetailEncryptedSchema,
|
|
37300
38323
|
ReasoningDetailTextSchema
|
|
37301
38324
|
]);
|
|
37302
|
-
var ReasoningDetailsWithUnknownSchema =
|
|
38325
|
+
var ReasoningDetailsWithUnknownSchema = import_v472.z.union([
|
|
37303
38326
|
ReasoningDetailUnionSchema,
|
|
37304
|
-
|
|
38327
|
+
import_v472.z.unknown().transform(() => null)
|
|
37305
38328
|
]);
|
|
37306
|
-
var ReasoningDetailArraySchema =
|
|
38329
|
+
var ReasoningDetailArraySchema = import_v472.z.array(ReasoningDetailsWithUnknownSchema).transform((d) => d.filter((d2) => !!d2));
|
|
37307
38330
|
|
|
37308
38331
|
// ../packages/internal/src/openrouter-ai-sdk/chat/convert-to-openrouter-chat-messages.ts
|
|
37309
38332
|
function getCacheControl(providerMetadata) {
|
|
@@ -37460,15 +38483,15 @@ function getToolResultContent(input) {
|
|
|
37460
38483
|
}
|
|
37461
38484
|
|
|
37462
38485
|
// ../packages/internal/src/openrouter-ai-sdk/chat/get-tool-choice.ts
|
|
37463
|
-
var
|
|
37464
|
-
var ChatCompletionToolChoiceSchema =
|
|
37465
|
-
|
|
37466
|
-
|
|
37467
|
-
|
|
37468
|
-
|
|
37469
|
-
type:
|
|
37470
|
-
function:
|
|
37471
|
-
name:
|
|
38486
|
+
var import_v473 = require("zod/v4");
|
|
38487
|
+
var ChatCompletionToolChoiceSchema = import_v473.z.union([
|
|
38488
|
+
import_v473.z.literal("auto"),
|
|
38489
|
+
import_v473.z.literal("none"),
|
|
38490
|
+
import_v473.z.literal("required"),
|
|
38491
|
+
import_v473.z.object({
|
|
38492
|
+
type: import_v473.z.literal("function"),
|
|
38493
|
+
function: import_v473.z.object({
|
|
38494
|
+
name: import_v473.z.string()
|
|
37472
38495
|
})
|
|
37473
38496
|
})
|
|
37474
38497
|
]);
|
|
@@ -37491,16 +38514,16 @@ function getChatCompletionToolChoice(toolChoice) {
|
|
|
37491
38514
|
}
|
|
37492
38515
|
|
|
37493
38516
|
// ../packages/internal/src/openrouter-ai-sdk/chat/schemas.ts
|
|
37494
|
-
var
|
|
38517
|
+
var import_v475 = require("zod/v4");
|
|
37495
38518
|
|
|
37496
38519
|
// ../packages/internal/src/openrouter-ai-sdk/schemas/error-response.ts
|
|
37497
|
-
var
|
|
37498
|
-
var OpenRouterErrorResponseSchema =
|
|
37499
|
-
error:
|
|
37500
|
-
code:
|
|
37501
|
-
message:
|
|
37502
|
-
type:
|
|
37503
|
-
param:
|
|
38520
|
+
var import_v474 = require("zod/v4");
|
|
38521
|
+
var OpenRouterErrorResponseSchema = import_v474.z.object({
|
|
38522
|
+
error: import_v474.z.object({
|
|
38523
|
+
code: import_v474.z.union([import_v474.z.string(), import_v474.z.number()]).nullable().optional().default(null),
|
|
38524
|
+
message: import_v474.z.string(),
|
|
38525
|
+
type: import_v474.z.string().nullable().optional().default(null),
|
|
38526
|
+
param: import_v474.z.any().nullable().optional().default(null)
|
|
37504
38527
|
})
|
|
37505
38528
|
});
|
|
37506
38529
|
var openrouterFailedResponseHandler = createJsonErrorResponseHandler({
|
|
@@ -37509,106 +38532,106 @@ var openrouterFailedResponseHandler = createJsonErrorResponseHandler({
|
|
|
37509
38532
|
});
|
|
37510
38533
|
|
|
37511
38534
|
// ../packages/internal/src/openrouter-ai-sdk/chat/schemas.ts
|
|
37512
|
-
var OpenRouterChatCompletionBaseResponseSchema =
|
|
37513
|
-
id:
|
|
37514
|
-
model:
|
|
37515
|
-
provider:
|
|
37516
|
-
usage:
|
|
37517
|
-
prompt_tokens:
|
|
37518
|
-
prompt_tokens_details:
|
|
37519
|
-
cached_tokens:
|
|
38535
|
+
var OpenRouterChatCompletionBaseResponseSchema = import_v475.z.object({
|
|
38536
|
+
id: import_v475.z.string().optional(),
|
|
38537
|
+
model: import_v475.z.string().optional(),
|
|
38538
|
+
provider: import_v475.z.string().optional(),
|
|
38539
|
+
usage: import_v475.z.object({
|
|
38540
|
+
prompt_tokens: import_v475.z.number(),
|
|
38541
|
+
prompt_tokens_details: import_v475.z.object({
|
|
38542
|
+
cached_tokens: import_v475.z.number()
|
|
37520
38543
|
}).nullish(),
|
|
37521
|
-
completion_tokens:
|
|
37522
|
-
completion_tokens_details:
|
|
37523
|
-
reasoning_tokens:
|
|
38544
|
+
completion_tokens: import_v475.z.number(),
|
|
38545
|
+
completion_tokens_details: import_v475.z.object({
|
|
38546
|
+
reasoning_tokens: import_v475.z.number()
|
|
37524
38547
|
}).nullish(),
|
|
37525
|
-
total_tokens:
|
|
37526
|
-
cost:
|
|
37527
|
-
cost_details:
|
|
37528
|
-
upstream_inference_cost:
|
|
38548
|
+
total_tokens: import_v475.z.number(),
|
|
38549
|
+
cost: import_v475.z.number().optional(),
|
|
38550
|
+
cost_details: import_v475.z.object({
|
|
38551
|
+
upstream_inference_cost: import_v475.z.number().nullish()
|
|
37529
38552
|
}).nullish()
|
|
37530
38553
|
}).nullish()
|
|
37531
38554
|
});
|
|
37532
38555
|
var OpenRouterNonStreamChatCompletionResponseSchema = OpenRouterChatCompletionBaseResponseSchema.extend({
|
|
37533
|
-
choices:
|
|
37534
|
-
message:
|
|
37535
|
-
role:
|
|
37536
|
-
content:
|
|
37537
|
-
reasoning:
|
|
38556
|
+
choices: import_v475.z.array(import_v475.z.object({
|
|
38557
|
+
message: import_v475.z.object({
|
|
38558
|
+
role: import_v475.z.literal("assistant"),
|
|
38559
|
+
content: import_v475.z.string().nullable().optional(),
|
|
38560
|
+
reasoning: import_v475.z.string().nullable().optional(),
|
|
37538
38561
|
reasoning_details: ReasoningDetailArraySchema.nullish(),
|
|
37539
|
-
tool_calls:
|
|
37540
|
-
id:
|
|
37541
|
-
type:
|
|
37542
|
-
function:
|
|
37543
|
-
name:
|
|
37544
|
-
arguments:
|
|
38562
|
+
tool_calls: import_v475.z.array(import_v475.z.object({
|
|
38563
|
+
id: import_v475.z.string().optional().nullable(),
|
|
38564
|
+
type: import_v475.z.literal("function"),
|
|
38565
|
+
function: import_v475.z.object({
|
|
38566
|
+
name: import_v475.z.string(),
|
|
38567
|
+
arguments: import_v475.z.string()
|
|
37545
38568
|
})
|
|
37546
38569
|
})).optional(),
|
|
37547
|
-
annotations:
|
|
37548
|
-
type:
|
|
37549
|
-
url_citation:
|
|
37550
|
-
end_index:
|
|
37551
|
-
start_index:
|
|
37552
|
-
title:
|
|
37553
|
-
url:
|
|
37554
|
-
content:
|
|
38570
|
+
annotations: import_v475.z.array(import_v475.z.object({
|
|
38571
|
+
type: import_v475.z.enum(["url_citation"]),
|
|
38572
|
+
url_citation: import_v475.z.object({
|
|
38573
|
+
end_index: import_v475.z.number(),
|
|
38574
|
+
start_index: import_v475.z.number(),
|
|
38575
|
+
title: import_v475.z.string(),
|
|
38576
|
+
url: import_v475.z.string(),
|
|
38577
|
+
content: import_v475.z.string().optional()
|
|
37555
38578
|
})
|
|
37556
38579
|
})).nullish()
|
|
37557
38580
|
}),
|
|
37558
|
-
index:
|
|
37559
|
-
logprobs:
|
|
37560
|
-
content:
|
|
37561
|
-
token:
|
|
37562
|
-
logprob:
|
|
37563
|
-
top_logprobs:
|
|
37564
|
-
token:
|
|
37565
|
-
logprob:
|
|
38581
|
+
index: import_v475.z.number().nullish(),
|
|
38582
|
+
logprobs: import_v475.z.object({
|
|
38583
|
+
content: import_v475.z.array(import_v475.z.object({
|
|
38584
|
+
token: import_v475.z.string(),
|
|
38585
|
+
logprob: import_v475.z.number(),
|
|
38586
|
+
top_logprobs: import_v475.z.array(import_v475.z.object({
|
|
38587
|
+
token: import_v475.z.string(),
|
|
38588
|
+
logprob: import_v475.z.number()
|
|
37566
38589
|
}))
|
|
37567
38590
|
})).nullable()
|
|
37568
38591
|
}).nullable().optional(),
|
|
37569
|
-
finish_reason:
|
|
38592
|
+
finish_reason: import_v475.z.string().optional().nullable()
|
|
37570
38593
|
}))
|
|
37571
38594
|
});
|
|
37572
|
-
var OpenRouterStreamChatCompletionChunkSchema =
|
|
38595
|
+
var OpenRouterStreamChatCompletionChunkSchema = import_v475.z.union([
|
|
37573
38596
|
OpenRouterChatCompletionBaseResponseSchema.extend({
|
|
37574
|
-
choices:
|
|
37575
|
-
delta:
|
|
37576
|
-
role:
|
|
37577
|
-
content:
|
|
37578
|
-
reasoning:
|
|
38597
|
+
choices: import_v475.z.array(import_v475.z.object({
|
|
38598
|
+
delta: import_v475.z.object({
|
|
38599
|
+
role: import_v475.z.enum(["assistant"]).optional(),
|
|
38600
|
+
content: import_v475.z.string().nullish(),
|
|
38601
|
+
reasoning: import_v475.z.string().nullish().optional(),
|
|
37579
38602
|
reasoning_details: ReasoningDetailArraySchema.nullish(),
|
|
37580
|
-
tool_calls:
|
|
37581
|
-
index:
|
|
37582
|
-
id:
|
|
37583
|
-
type:
|
|
37584
|
-
function:
|
|
37585
|
-
name:
|
|
37586
|
-
arguments:
|
|
38603
|
+
tool_calls: import_v475.z.array(import_v475.z.object({
|
|
38604
|
+
index: import_v475.z.number().nullish(),
|
|
38605
|
+
id: import_v475.z.string().nullish(),
|
|
38606
|
+
type: import_v475.z.literal("function").optional(),
|
|
38607
|
+
function: import_v475.z.object({
|
|
38608
|
+
name: import_v475.z.string().nullish(),
|
|
38609
|
+
arguments: import_v475.z.string().nullish()
|
|
37587
38610
|
})
|
|
37588
38611
|
})).nullish(),
|
|
37589
|
-
annotations:
|
|
37590
|
-
type:
|
|
37591
|
-
url_citation:
|
|
37592
|
-
end_index:
|
|
37593
|
-
start_index:
|
|
37594
|
-
title:
|
|
37595
|
-
url:
|
|
37596
|
-
content:
|
|
38612
|
+
annotations: import_v475.z.array(import_v475.z.object({
|
|
38613
|
+
type: import_v475.z.enum(["url_citation"]),
|
|
38614
|
+
url_citation: import_v475.z.object({
|
|
38615
|
+
end_index: import_v475.z.number(),
|
|
38616
|
+
start_index: import_v475.z.number(),
|
|
38617
|
+
title: import_v475.z.string(),
|
|
38618
|
+
url: import_v475.z.string(),
|
|
38619
|
+
content: import_v475.z.string().optional()
|
|
37597
38620
|
})
|
|
37598
38621
|
})).nullish()
|
|
37599
38622
|
}).nullish(),
|
|
37600
|
-
logprobs:
|
|
37601
|
-
content:
|
|
37602
|
-
token:
|
|
37603
|
-
logprob:
|
|
37604
|
-
top_logprobs:
|
|
37605
|
-
token:
|
|
37606
|
-
logprob:
|
|
38623
|
+
logprobs: import_v475.z.object({
|
|
38624
|
+
content: import_v475.z.array(import_v475.z.object({
|
|
38625
|
+
token: import_v475.z.string(),
|
|
38626
|
+
logprob: import_v475.z.number(),
|
|
38627
|
+
top_logprobs: import_v475.z.array(import_v475.z.object({
|
|
38628
|
+
token: import_v475.z.string(),
|
|
38629
|
+
logprob: import_v475.z.number()
|
|
37607
38630
|
}))
|
|
37608
38631
|
})).nullable()
|
|
37609
38632
|
}).nullish(),
|
|
37610
|
-
finish_reason:
|
|
37611
|
-
index:
|
|
38633
|
+
finish_reason: import_v475.z.string().nullable().optional(),
|
|
38634
|
+
index: import_v475.z.number().nullish()
|
|
37612
38635
|
}))
|
|
37613
38636
|
}),
|
|
37614
38637
|
OpenRouterErrorResponseSchema
|
|
@@ -38309,34 +39332,34 @@ ${assistantMessage2}
|
|
|
38309
39332
|
}
|
|
38310
39333
|
|
|
38311
39334
|
// ../packages/internal/src/openrouter-ai-sdk/completion/schemas.ts
|
|
38312
|
-
var
|
|
38313
|
-
var OpenRouterCompletionChunkSchema =
|
|
38314
|
-
|
|
38315
|
-
id:
|
|
38316
|
-
model:
|
|
38317
|
-
choices:
|
|
38318
|
-
text:
|
|
38319
|
-
reasoning:
|
|
39335
|
+
var import_v476 = require("zod/v4");
|
|
39336
|
+
var OpenRouterCompletionChunkSchema = import_v476.z.union([
|
|
39337
|
+
import_v476.z.object({
|
|
39338
|
+
id: import_v476.z.string().optional(),
|
|
39339
|
+
model: import_v476.z.string().optional(),
|
|
39340
|
+
choices: import_v476.z.array(import_v476.z.object({
|
|
39341
|
+
text: import_v476.z.string(),
|
|
39342
|
+
reasoning: import_v476.z.string().nullish().optional(),
|
|
38320
39343
|
reasoning_details: ReasoningDetailArraySchema.nullish(),
|
|
38321
|
-
finish_reason:
|
|
38322
|
-
index:
|
|
38323
|
-
logprobs:
|
|
38324
|
-
tokens:
|
|
38325
|
-
token_logprobs:
|
|
38326
|
-
top_logprobs:
|
|
39344
|
+
finish_reason: import_v476.z.string().nullish(),
|
|
39345
|
+
index: import_v476.z.number().nullish(),
|
|
39346
|
+
logprobs: import_v476.z.object({
|
|
39347
|
+
tokens: import_v476.z.array(import_v476.z.string()),
|
|
39348
|
+
token_logprobs: import_v476.z.array(import_v476.z.number()),
|
|
39349
|
+
top_logprobs: import_v476.z.array(import_v476.z.record(import_v476.z.string(), import_v476.z.number())).nullable()
|
|
38327
39350
|
}).nullable().optional()
|
|
38328
39351
|
})),
|
|
38329
|
-
usage:
|
|
38330
|
-
prompt_tokens:
|
|
38331
|
-
prompt_tokens_details:
|
|
38332
|
-
cached_tokens:
|
|
39352
|
+
usage: import_v476.z.object({
|
|
39353
|
+
prompt_tokens: import_v476.z.number(),
|
|
39354
|
+
prompt_tokens_details: import_v476.z.object({
|
|
39355
|
+
cached_tokens: import_v476.z.number()
|
|
38333
39356
|
}).nullish(),
|
|
38334
|
-
completion_tokens:
|
|
38335
|
-
completion_tokens_details:
|
|
38336
|
-
reasoning_tokens:
|
|
39357
|
+
completion_tokens: import_v476.z.number(),
|
|
39358
|
+
completion_tokens_details: import_v476.z.object({
|
|
39359
|
+
reasoning_tokens: import_v476.z.number()
|
|
38337
39360
|
}).nullish(),
|
|
38338
|
-
total_tokens:
|
|
38339
|
-
cost:
|
|
39361
|
+
total_tokens: import_v476.z.number(),
|
|
39362
|
+
cost: import_v476.z.number().optional()
|
|
38340
39363
|
}).nullish()
|
|
38341
39364
|
}),
|
|
38342
39365
|
OpenRouterErrorResponseSchema
|
|
@@ -38578,7 +39601,7 @@ function createOpenRouter(options = {}) {
|
|
|
38578
39601
|
});
|
|
38579
39602
|
const createChatModel = (modelId, settings = {}) => new OpenRouterChatLanguageModel(modelId, settings, {
|
|
38580
39603
|
provider: "openrouter.chat",
|
|
38581
|
-
url: ({ path:
|
|
39604
|
+
url: ({ path: path6 }) => `${baseURL}${path6}`,
|
|
38582
39605
|
headers: getHeaders,
|
|
38583
39606
|
compatibility,
|
|
38584
39607
|
fetch: options.fetch,
|
|
@@ -38586,7 +39609,7 @@ function createOpenRouter(options = {}) {
|
|
|
38586
39609
|
});
|
|
38587
39610
|
const createCompletionModel = (modelId, settings = {}) => new OpenRouterCompletionLanguageModel(modelId, settings, {
|
|
38588
39611
|
provider: "openrouter.completion",
|
|
38589
|
-
url: ({ path:
|
|
39612
|
+
url: ({ path: path6 }) => `${baseURL}${path6}`,
|
|
38590
39613
|
headers: getHeaders,
|
|
38591
39614
|
compatibility,
|
|
38592
39615
|
fetch: options.fetch,
|
|
@@ -38617,25 +39640,25 @@ var import_node_path = __toESM(require("node:path"));
|
|
|
38617
39640
|
var import_os = __toESM(require("os"));
|
|
38618
39641
|
|
|
38619
39642
|
// ../common/src/util/credentials.ts
|
|
38620
|
-
var
|
|
38621
|
-
var userSchema =
|
|
38622
|
-
id:
|
|
38623
|
-
email:
|
|
38624
|
-
name:
|
|
38625
|
-
authToken:
|
|
38626
|
-
fingerprintId:
|
|
38627
|
-
fingerprintHash:
|
|
39643
|
+
var import_v477 = require("zod/v4");
|
|
39644
|
+
var userSchema = import_v477.z.object({
|
|
39645
|
+
id: import_v477.z.string(),
|
|
39646
|
+
email: import_v477.z.string(),
|
|
39647
|
+
name: import_v477.z.string().nullable(),
|
|
39648
|
+
authToken: import_v477.z.string(),
|
|
39649
|
+
fingerprintId: import_v477.z.string(),
|
|
39650
|
+
fingerprintHash: import_v477.z.string()
|
|
38628
39651
|
});
|
|
38629
39652
|
|
|
38630
39653
|
// src/credentials.ts
|
|
38631
|
-
var
|
|
38632
|
-
var claudeOAuthSchema =
|
|
38633
|
-
accessToken:
|
|
38634
|
-
refreshToken:
|
|
38635
|
-
expiresAt:
|
|
38636
|
-
connectedAt:
|
|
39654
|
+
var import_v478 = require("zod/v4");
|
|
39655
|
+
var claudeOAuthSchema = import_v478.z.object({
|
|
39656
|
+
accessToken: import_v478.z.string(),
|
|
39657
|
+
refreshToken: import_v478.z.string(),
|
|
39658
|
+
expiresAt: import_v478.z.number(),
|
|
39659
|
+
connectedAt: import_v478.z.number()
|
|
38637
39660
|
});
|
|
38638
|
-
var credentialsFileSchema =
|
|
39661
|
+
var credentialsFileSchema = import_v478.z.object({
|
|
38639
39662
|
default: userSchema.optional(),
|
|
38640
39663
|
claudeOAuth: claudeOAuthSchema.optional()
|
|
38641
39664
|
});
|
|
@@ -38652,11 +39675,29 @@ var userFromJson = (json) => {
|
|
|
38652
39675
|
return null;
|
|
38653
39676
|
}
|
|
38654
39677
|
};
|
|
39678
|
+
var getLegacyConfigDir = (clientEnv = env) => {
|
|
39679
|
+
const envSuffix = clientEnv.NEXT_PUBLIC_CB_ENVIRONMENT && clientEnv.NEXT_PUBLIC_CB_ENVIRONMENT !== "prod" ? `-${clientEnv.NEXT_PUBLIC_CB_ENVIRONMENT}` : "";
|
|
39680
|
+
return import_node_path.default.join(import_os.default.homedir(), ".config", `manicode${envSuffix}`);
|
|
39681
|
+
};
|
|
38655
39682
|
var getConfigDir = (clientEnv = env) => {
|
|
38656
39683
|
const envSuffix = clientEnv.NEXT_PUBLIC_CB_ENVIRONMENT && clientEnv.NEXT_PUBLIC_CB_ENVIRONMENT !== "prod" ? `-${clientEnv.NEXT_PUBLIC_CB_ENVIRONMENT}` : "";
|
|
38657
39684
|
return import_node_path.default.join(import_os.default.homedir(), ".config", `levelcode${envSuffix}`);
|
|
38658
39685
|
};
|
|
39686
|
+
var migrateFromLegacyConfigDir = (clientEnv = env) => {
|
|
39687
|
+
const newDir = getConfigDir(clientEnv);
|
|
39688
|
+
const newCredsPath = import_node_path.default.join(newDir, "credentials.json");
|
|
39689
|
+
if (import_fs.default.existsSync(newCredsPath))
|
|
39690
|
+
return;
|
|
39691
|
+
const legacyCredsPath = import_node_path.default.join(getLegacyConfigDir(clientEnv), "credentials.json");
|
|
39692
|
+
if (!import_fs.default.existsSync(legacyCredsPath))
|
|
39693
|
+
return;
|
|
39694
|
+
try {
|
|
39695
|
+
ensureDirectoryExistsSync(newDir);
|
|
39696
|
+
import_fs.default.copyFileSync(legacyCredsPath, newCredsPath);
|
|
39697
|
+
} catch {}
|
|
39698
|
+
};
|
|
38659
39699
|
var getCredentialsPath = (clientEnv = env) => {
|
|
39700
|
+
migrateFromLegacyConfigDir(clientEnv);
|
|
38660
39701
|
return import_node_path.default.join(getConfigDir(clientEnv), "credentials.json");
|
|
38661
39702
|
};
|
|
38662
39703
|
var getUserCredentials = (clientEnv = env) => {
|
|
@@ -39107,17 +40148,17 @@ async function* promptAiSdkStream(params2) {
|
|
|
39107
40148
|
}),
|
|
39108
40149
|
experimental_repairToolCall: async ({ toolCall, tools, error }) => {
|
|
39109
40150
|
const { spawnableAgents = [], localAgentTemplates = {} } = params2;
|
|
39110
|
-
const
|
|
40151
|
+
const toolName39 = toolCall.toolName;
|
|
39111
40152
|
if (import_ai3.NoSuchToolError.isInstance(error) && "spawn_agents" in tools) {
|
|
39112
|
-
const toolNameWithHyphens =
|
|
40153
|
+
const toolNameWithHyphens = toolName39.replace(/_/g, "-");
|
|
39113
40154
|
const matchingAgentId = spawnableAgents.find((agentId) => {
|
|
39114
40155
|
const withoutVersion = agentId.split("@")[0];
|
|
39115
40156
|
const parts = withoutVersion.split("/");
|
|
39116
40157
|
const agentName = parts[parts.length - 1];
|
|
39117
|
-
return agentName ===
|
|
40158
|
+
return agentName === toolName39 || agentName === toolNameWithHyphens || agentId === toolName39;
|
|
39118
40159
|
});
|
|
39119
40160
|
const isSpawnableAgent = matchingAgentId !== undefined;
|
|
39120
|
-
const isLocalAgent =
|
|
40161
|
+
const isLocalAgent = toolName39 in localAgentTemplates || toolNameWithHyphens in localAgentTemplates;
|
|
39121
40162
|
if (isSpawnableAgent || isLocalAgent) {
|
|
39122
40163
|
const deepParseJson = (value) => {
|
|
39123
40164
|
if (typeof value === "string") {
|
|
@@ -39141,7 +40182,7 @@ async function* promptAiSdkStream(params2) {
|
|
|
39141
40182
|
} catch {}
|
|
39142
40183
|
const prompt2 = typeof input.prompt === "string" ? input.prompt : undefined;
|
|
39143
40184
|
const agentParams = Object.fromEntries(Object.entries(input).filter(([key, value]) => !(key === "prompt" && typeof value === "string")));
|
|
39144
|
-
const correctedAgentType = matchingAgentId ?? (toolNameWithHyphens in localAgentTemplates ? toolNameWithHyphens :
|
|
40185
|
+
const correctedAgentType = matchingAgentId ?? (toolNameWithHyphens in localAgentTemplates ? toolNameWithHyphens : toolName39);
|
|
39145
40186
|
const spawnAgentsInput = {
|
|
39146
40187
|
agents: [
|
|
39147
40188
|
{
|
|
@@ -39153,7 +40194,7 @@ async function* promptAiSdkStream(params2) {
|
|
|
39153
40194
|
}
|
|
39154
40195
|
]
|
|
39155
40196
|
};
|
|
39156
|
-
logger2.info({ originalToolName:
|
|
40197
|
+
logger2.info({ originalToolName: toolName39, transformedInput: spawnAgentsInput }, "Transformed agent tool call to spawn_agents");
|
|
39157
40198
|
return {
|
|
39158
40199
|
...toolCall,
|
|
39159
40200
|
toolName: "spawn_agents",
|
|
@@ -39162,7 +40203,7 @@ async function* promptAiSdkStream(params2) {
|
|
|
39162
40203
|
}
|
|
39163
40204
|
}
|
|
39164
40205
|
logger2.info({
|
|
39165
|
-
toolName:
|
|
40206
|
+
toolName: toolName39,
|
|
39166
40207
|
errorType: error.name,
|
|
39167
40208
|
error: error.message
|
|
39168
40209
|
}, "Tool error - passing through for graceful error handling");
|
|
@@ -39444,38 +40485,38 @@ var noopLogger = {
|
|
|
39444
40485
|
};
|
|
39445
40486
|
|
|
39446
40487
|
// src/run-state.ts
|
|
39447
|
-
var
|
|
40488
|
+
var os6 = __toESM(require("os"));
|
|
39448
40489
|
var import_path8 = __toESM(require("path"));
|
|
39449
40490
|
|
|
39450
40491
|
// ../packages/code-map/src/parse.ts
|
|
39451
|
-
var
|
|
39452
|
-
var
|
|
40492
|
+
var fs11 = __toESM(require("fs"));
|
|
40493
|
+
var path10 = __toESM(require("path"));
|
|
39453
40494
|
|
|
39454
40495
|
// ../packages/code-map/src/languages.ts
|
|
39455
|
-
var
|
|
39456
|
-
var
|
|
40496
|
+
var fs10 = __toESM(require("fs"));
|
|
40497
|
+
var path9 = __toESM(require("path"));
|
|
39457
40498
|
var import_web_tree_sitter2 = require("web-tree-sitter");
|
|
39458
40499
|
|
|
39459
40500
|
// ../packages/code-map/src/init-node.ts
|
|
39460
|
-
var
|
|
39461
|
-
var
|
|
40501
|
+
var fs9 = __toESM(require("fs"));
|
|
40502
|
+
var path8 = __toESM(require("path"));
|
|
39462
40503
|
var import_web_tree_sitter = require("web-tree-sitter");
|
|
39463
40504
|
async function initTreeSitterForNode() {
|
|
39464
40505
|
await import_web_tree_sitter.Parser.init({
|
|
39465
40506
|
locateFile: (name14, scriptDir) => {
|
|
39466
40507
|
if (name14 === "tree-sitter.wasm") {
|
|
39467
|
-
const fallback =
|
|
39468
|
-
if (
|
|
40508
|
+
const fallback = path8.join(scriptDir, name14);
|
|
40509
|
+
if (fs9.existsSync(fallback)) {
|
|
39469
40510
|
return fallback;
|
|
39470
40511
|
}
|
|
39471
|
-
const pkgDir =
|
|
39472
|
-
const wasm =
|
|
39473
|
-
if (
|
|
40512
|
+
const pkgDir = path8.dirname(require.resolve("web-tree-sitter"));
|
|
40513
|
+
const wasm = path8.join(pkgDir, "tree-sitter.wasm");
|
|
40514
|
+
if (fs9.existsSync(wasm)) {
|
|
39474
40515
|
return wasm;
|
|
39475
40516
|
}
|
|
39476
40517
|
throw new Error(`Internal error: web-tree-sitter/tree-sitter.wasm not found at ${wasm}. Ensure the file is included in your deployment bundle.`);
|
|
39477
40518
|
}
|
|
39478
|
-
return
|
|
40519
|
+
return path8.join(scriptDir, name14);
|
|
39479
40520
|
}
|
|
39480
40521
|
});
|
|
39481
40522
|
}
|
|
@@ -39815,23 +40856,23 @@ function getWasmDir() {
|
|
|
39815
40856
|
function resolveWasmPath(wasmFileName) {
|
|
39816
40857
|
const customWasmDirPath = getWasmDir();
|
|
39817
40858
|
if (customWasmDirPath) {
|
|
39818
|
-
return
|
|
40859
|
+
return path9.join(customWasmDirPath, wasmFileName);
|
|
39819
40860
|
}
|
|
39820
40861
|
const envWasmDir = process.env.LEVELCODE_WASM_DIR;
|
|
39821
40862
|
if (envWasmDir) {
|
|
39822
|
-
return
|
|
40863
|
+
return path9.join(envWasmDir, wasmFileName);
|
|
39823
40864
|
}
|
|
39824
40865
|
const moduleDir = (() => {
|
|
39825
|
-
const
|
|
39826
|
-
if (typeof
|
|
39827
|
-
return
|
|
40866
|
+
const dirname5 = getDirnameDynamically();
|
|
40867
|
+
if (typeof dirname5 !== "undefined") {
|
|
40868
|
+
return dirname5;
|
|
39828
40869
|
}
|
|
39829
40870
|
return process.cwd();
|
|
39830
40871
|
})();
|
|
39831
40872
|
const possiblePaths = [
|
|
39832
|
-
|
|
39833
|
-
|
|
39834
|
-
|
|
40873
|
+
path9.join(moduleDir, "..", "wasm", wasmFileName),
|
|
40874
|
+
path9.join(moduleDir, "wasm", wasmFileName),
|
|
40875
|
+
path9.join(process.cwd(), "dist", "wasm", wasmFileName)
|
|
39835
40876
|
];
|
|
39836
40877
|
for (const wasmPath of possiblePaths) {
|
|
39837
40878
|
try {
|
|
@@ -39875,7 +40916,7 @@ class UnifiedLanguageLoader {
|
|
|
39875
40916
|
}
|
|
39876
40917
|
}
|
|
39877
40918
|
function findLanguageConfigByExtension(filePath) {
|
|
39878
|
-
const ext =
|
|
40919
|
+
const ext = path9.extname(filePath);
|
|
39879
40920
|
return languageTable.find((c) => c.extensions.includes(ext));
|
|
39880
40921
|
}
|
|
39881
40922
|
async function createLanguageConfig(filePath, runtimeLoader) {
|
|
@@ -39889,7 +40930,7 @@ async function createLanguageConfig(filePath, runtimeLoader) {
|
|
|
39889
40930
|
const lang = await runtimeLoader.loadLanguage(cfg.wasmFile);
|
|
39890
40931
|
const parser = new import_web_tree_sitter2.Parser;
|
|
39891
40932
|
parser.setLanguage(lang);
|
|
39892
|
-
const queryContent =
|
|
40933
|
+
const queryContent = path9.isAbsolute(cfg.queryPathOrContent) ? fs10.readFileSync(cfg.queryPathOrContent, "utf8") : cfg.queryPathOrContent;
|
|
39893
40934
|
cfg.language = lang;
|
|
39894
40935
|
cfg.parser = parser;
|
|
39895
40936
|
cfg.query = new import_web_tree_sitter2.Query(lang, queryContent);
|
|
@@ -39921,7 +40962,7 @@ async function getFileTokenScores(projectRoot, filePaths, readFile) {
|
|
|
39921
40962
|
const externalCalls = {};
|
|
39922
40963
|
const fileCallsMap = new Map;
|
|
39923
40964
|
for (const filePath of filePaths) {
|
|
39924
|
-
const fullPath =
|
|
40965
|
+
const fullPath = path10.join(projectRoot, filePath);
|
|
39925
40966
|
const languageConfig = await getLanguageConfig(fullPath);
|
|
39926
40967
|
if (languageConfig) {
|
|
39927
40968
|
let parseResults;
|
|
@@ -39933,7 +40974,7 @@ async function getFileTokenScores(projectRoot, filePaths, readFile) {
|
|
|
39933
40974
|
const { identifiers, calls, numLines } = parseResults;
|
|
39934
40975
|
const tokenScoresForFile = {};
|
|
39935
40976
|
tokenScores[filePath] = tokenScoresForFile;
|
|
39936
|
-
const dirs =
|
|
40977
|
+
const dirs = path10.dirname(fullPath).split(path10.sep);
|
|
39937
40978
|
const depth = dirs.length;
|
|
39938
40979
|
const tokenBaseScore = 0.8 ** depth * Math.sqrt(numLines / (identifiers.length + 1));
|
|
39939
40980
|
for (const identifier of identifiers) {
|
|
@@ -39995,7 +41036,7 @@ async function getFileTokenScores(projectRoot, filePaths, readFile) {
|
|
|
39995
41036
|
const endTime = Date.now();
|
|
39996
41037
|
console.log(`Parsed ${filePaths.length} files in ${endTime - startTime2}ms`);
|
|
39997
41038
|
try {
|
|
39998
|
-
|
|
41039
|
+
fs11.writeFileSync("../debug/debug-parse.json", JSON.stringify({
|
|
39999
41040
|
tokenCallers,
|
|
40000
41041
|
tokenScores,
|
|
40001
41042
|
fileCallsMap,
|
|
@@ -40008,7 +41049,7 @@ async function getFileTokenScores(projectRoot, filePaths, readFile) {
|
|
|
40008
41049
|
function parseTokens(filePath, languageConfig, readFile) {
|
|
40009
41050
|
const { parser, query } = languageConfig;
|
|
40010
41051
|
try {
|
|
40011
|
-
const sourceCode = readFile ? readFile(filePath) :
|
|
41052
|
+
const sourceCode = readFile ? readFile(filePath) : fs11.readFileSync(filePath, "utf8");
|
|
40012
41053
|
if (sourceCode === null) {
|
|
40013
41054
|
return {
|
|
40014
41055
|
numLines: 0,
|
|
@@ -40065,7 +41106,7 @@ function parseFile(parser, query, sourceCode) {
|
|
|
40065
41106
|
|
|
40066
41107
|
// src/run-state.ts
|
|
40067
41108
|
var import_lodash17 = __toESM(require_lodash());
|
|
40068
|
-
var
|
|
41109
|
+
var import_v480 = __toESM(require("zod/v4"));
|
|
40069
41110
|
|
|
40070
41111
|
// src/agents/load-agents.ts
|
|
40071
41112
|
var import_fs2 = __toESM(require("fs"));
|
|
@@ -40307,21 +41348,21 @@ function isValidSkillName(name14) {
|
|
|
40307
41348
|
}
|
|
40308
41349
|
|
|
40309
41350
|
// ../common/src/types/skill.ts
|
|
40310
|
-
var
|
|
40311
|
-
var SkillMetadataSchema =
|
|
40312
|
-
var SkillFrontmatterSchema =
|
|
40313
|
-
name:
|
|
40314
|
-
description:
|
|
40315
|
-
license:
|
|
41351
|
+
var import_v479 = require("zod/v4");
|
|
41352
|
+
var SkillMetadataSchema = import_v479.z.record(import_v479.z.string(), import_v479.z.string());
|
|
41353
|
+
var SkillFrontmatterSchema = import_v479.z.object({
|
|
41354
|
+
name: import_v479.z.string().min(1).max(SKILL_NAME_MAX_LENGTH).regex(SKILL_NAME_REGEX, "Name must be lowercase alphanumeric with single hyphen separators"),
|
|
41355
|
+
description: import_v479.z.string().min(1).max(SKILL_DESCRIPTION_MAX_LENGTH),
|
|
41356
|
+
license: import_v479.z.string().optional(),
|
|
40316
41357
|
metadata: SkillMetadataSchema.optional()
|
|
40317
41358
|
});
|
|
40318
|
-
var SkillDefinitionSchema =
|
|
40319
|
-
name:
|
|
40320
|
-
description:
|
|
40321
|
-
license:
|
|
41359
|
+
var SkillDefinitionSchema = import_v479.z.object({
|
|
41360
|
+
name: import_v479.z.string(),
|
|
41361
|
+
description: import_v479.z.string(),
|
|
41362
|
+
license: import_v479.z.string().optional(),
|
|
40322
41363
|
metadata: SkillMetadataSchema.optional(),
|
|
40323
|
-
content:
|
|
40324
|
-
filePath:
|
|
41364
|
+
content: import_v479.z.string(),
|
|
41365
|
+
filePath: import_v479.z.string()
|
|
40325
41366
|
});
|
|
40326
41367
|
|
|
40327
41368
|
// src/skills/load-skills.ts
|
|
@@ -40461,7 +41502,7 @@ function processAgentDefinitions(agentDefinitions) {
|
|
|
40461
41502
|
}
|
|
40462
41503
|
function processCustomToolDefinitions(customToolDefinitions) {
|
|
40463
41504
|
return Object.fromEntries(customToolDefinitions.map((toolDefinition) => {
|
|
40464
|
-
const jsonSchema =
|
|
41505
|
+
const jsonSchema = import_v480.default.toJSONSchema(toolDefinition.inputSchema, {
|
|
40465
41506
|
io: "input"
|
|
40466
41507
|
});
|
|
40467
41508
|
delete jsonSchema["$schema"];
|
|
@@ -40540,13 +41581,13 @@ async function getGitChanges(params2) {
|
|
|
40540
41581
|
};
|
|
40541
41582
|
}
|
|
40542
41583
|
async function discoverProjectFiles(params2) {
|
|
40543
|
-
const { cwd, fs:
|
|
40544
|
-
const fileTree = await getProjectFileTree({ projectRoot: cwd, fs:
|
|
41584
|
+
const { cwd, fs: fs14, logger: logger2 } = params2;
|
|
41585
|
+
const fileTree = await getProjectFileTree({ projectRoot: cwd, fs: fs14 });
|
|
40545
41586
|
const filePaths = getAllFilePaths(fileTree);
|
|
40546
41587
|
let error;
|
|
40547
41588
|
const projectFilePromises = Object.fromEntries(filePaths.map((filePath) => [
|
|
40548
41589
|
filePath,
|
|
40549
|
-
|
|
41590
|
+
fs14.readFile(import_path8.default.join(cwd, filePath), "utf8").catch((err) => {
|
|
40550
41591
|
error = err;
|
|
40551
41592
|
return "[ERROR_READING_FILE]";
|
|
40552
41593
|
})
|
|
@@ -40561,12 +41602,12 @@ async function discoverProjectFiles(params2) {
|
|
|
40561
41602
|
return projectFilesResolved;
|
|
40562
41603
|
}
|
|
40563
41604
|
async function loadUserKnowledgeFiles(params2) {
|
|
40564
|
-
const { fs:
|
|
40565
|
-
const homeDir = params2.homeDir ??
|
|
41605
|
+
const { fs: fs14, logger: logger2 } = params2;
|
|
41606
|
+
const homeDir = params2.homeDir ?? os6.homedir();
|
|
40566
41607
|
const userKnowledgeFiles = {};
|
|
40567
41608
|
let entries;
|
|
40568
41609
|
try {
|
|
40569
|
-
entries = await
|
|
41610
|
+
entries = await fs14.readdir(homeDir);
|
|
40570
41611
|
} catch (error) {
|
|
40571
41612
|
logger2.debug?.({ homeDir, error: getErrorObject(error) }, "Failed to read home directory");
|
|
40572
41613
|
return userKnowledgeFiles;
|
|
@@ -40586,7 +41627,7 @@ async function loadUserKnowledgeFiles(params2) {
|
|
|
40586
41627
|
if (actualFileName) {
|
|
40587
41628
|
const filePath = import_path8.default.join(homeDir, actualFileName);
|
|
40588
41629
|
try {
|
|
40589
|
-
const content = await
|
|
41630
|
+
const content = await fs14.readFile(filePath, "utf8");
|
|
40590
41631
|
const tildeKey = `~/${actualFileName}`;
|
|
40591
41632
|
userKnowledgeFiles[tildeKey] = content;
|
|
40592
41633
|
break;
|
|
@@ -40633,7 +41674,7 @@ async function initialSessionState(params2) {
|
|
|
40633
41674
|
projectFiles,
|
|
40634
41675
|
knowledgeFiles,
|
|
40635
41676
|
userKnowledgeFiles: providedUserKnowledgeFiles,
|
|
40636
|
-
fs:
|
|
41677
|
+
fs: fs14,
|
|
40637
41678
|
spawn: spawn2,
|
|
40638
41679
|
logger: logger2
|
|
40639
41680
|
} = params2;
|
|
@@ -40643,8 +41684,8 @@ async function initialSessionState(params2) {
|
|
|
40643
41684
|
if (!customToolDefinitions) {
|
|
40644
41685
|
customToolDefinitions = [];
|
|
40645
41686
|
}
|
|
40646
|
-
if (!
|
|
40647
|
-
|
|
41687
|
+
if (!fs14) {
|
|
41688
|
+
fs14 = require("fs").promises;
|
|
40648
41689
|
}
|
|
40649
41690
|
if (!spawn2) {
|
|
40650
41691
|
const { spawn: nodeSpawn } = require("child_process");
|
|
@@ -40659,7 +41700,7 @@ async function initialSessionState(params2) {
|
|
|
40659
41700
|
};
|
|
40660
41701
|
}
|
|
40661
41702
|
if (projectFiles === undefined && cwd) {
|
|
40662
|
-
projectFiles = await discoverProjectFiles({ cwd, fs:
|
|
41703
|
+
projectFiles = await discoverProjectFiles({ cwd, fs: fs14, logger: logger2 });
|
|
40663
41704
|
}
|
|
40664
41705
|
if (knowledgeFiles === undefined) {
|
|
40665
41706
|
knowledgeFiles = projectFiles ? deriveKnowledgeFiles(projectFiles) : {};
|
|
@@ -40686,7 +41727,7 @@ async function initialSessionState(params2) {
|
|
|
40686
41727
|
diffCached: "",
|
|
40687
41728
|
lastCommitMessages: ""
|
|
40688
41729
|
};
|
|
40689
|
-
const homeKnowledgeFiles = await loadUserKnowledgeFiles({ fs:
|
|
41730
|
+
const homeKnowledgeFiles = await loadUserKnowledgeFiles({ fs: fs14, logger: logger2 });
|
|
40690
41731
|
const userKnowledgeFiles = {
|
|
40691
41732
|
...homeKnowledgeFiles,
|
|
40692
41733
|
...providedUserKnowledgeFiles
|
|
@@ -40711,8 +41752,8 @@ async function initialSessionState(params2) {
|
|
|
40711
41752
|
shell: "bash",
|
|
40712
41753
|
nodeVersion: process.version,
|
|
40713
41754
|
arch: process.arch,
|
|
40714
|
-
homedir:
|
|
40715
|
-
cpus:
|
|
41755
|
+
homedir: os6.homedir(),
|
|
41756
|
+
cpus: os6.cpus().length ?? 1
|
|
40716
41757
|
}
|
|
40717
41758
|
});
|
|
40718
41759
|
if (maxAgentSteps) {
|
|
@@ -40728,7 +41769,7 @@ async function generateInitialRunState({
|
|
|
40728
41769
|
agentDefinitions,
|
|
40729
41770
|
customToolDefinitions,
|
|
40730
41771
|
maxAgentSteps,
|
|
40731
|
-
fs:
|
|
41772
|
+
fs: fs14
|
|
40732
41773
|
}) {
|
|
40733
41774
|
return {
|
|
40734
41775
|
sessionState: await initialSessionState({
|
|
@@ -40739,7 +41780,7 @@ async function generateInitialRunState({
|
|
|
40739
41780
|
agentDefinitions,
|
|
40740
41781
|
customToolDefinitions,
|
|
40741
41782
|
maxAgentSteps,
|
|
40742
|
-
fs:
|
|
41783
|
+
fs: fs14
|
|
40743
41784
|
}),
|
|
40744
41785
|
output: {
|
|
40745
41786
|
type: "error",
|
|
@@ -40825,19 +41866,19 @@ function buildFileTree(filePaths) {
|
|
|
40825
41866
|
}
|
|
40826
41867
|
const rootNodes = [];
|
|
40827
41868
|
const processed = new Set;
|
|
40828
|
-
for (const [
|
|
40829
|
-
if (processed.has(
|
|
41869
|
+
for (const [path14, node] of Object.entries(tree)) {
|
|
41870
|
+
if (processed.has(path14))
|
|
40830
41871
|
continue;
|
|
40831
|
-
const parentPath =
|
|
41872
|
+
const parentPath = path14.substring(0, path14.lastIndexOf("/"));
|
|
40832
41873
|
if (parentPath && tree[parentPath]) {
|
|
40833
41874
|
const parent = tree[parentPath];
|
|
40834
|
-
if (parent.children && !parent.children.some((child) => child.filePath ===
|
|
41875
|
+
if (parent.children && !parent.children.some((child) => child.filePath === path14)) {
|
|
40835
41876
|
parent.children.push(node);
|
|
40836
41877
|
}
|
|
40837
41878
|
} else {
|
|
40838
41879
|
rootNodes.push(node);
|
|
40839
41880
|
}
|
|
40840
|
-
processed.add(
|
|
41881
|
+
processed.add(path14);
|
|
40841
41882
|
}
|
|
40842
41883
|
function sortNodes(nodes) {
|
|
40843
41884
|
nodes.sort((a, b) => {
|
|
@@ -40859,11 +41900,11 @@ function buildFileTree(filePaths) {
|
|
|
40859
41900
|
// src/tools/change-file.ts
|
|
40860
41901
|
var import_path9 = __toESM(require("path"));
|
|
40861
41902
|
var import_diff4 = require("diff");
|
|
40862
|
-
var
|
|
40863
|
-
var FileChangeSchema2 =
|
|
40864
|
-
type:
|
|
40865
|
-
path:
|
|
40866
|
-
content:
|
|
41903
|
+
var import_v481 = __toESM(require("zod/v4"));
|
|
41904
|
+
var FileChangeSchema2 = import_v481.default.object({
|
|
41905
|
+
type: import_v481.default.enum(["patch", "file"]),
|
|
41906
|
+
path: import_v481.default.string(),
|
|
41907
|
+
content: import_v481.default.string()
|
|
40867
41908
|
});
|
|
40868
41909
|
function containsUpwardTraversal(dirPath) {
|
|
40869
41910
|
const normalized = import_path9.default.normalize(dirPath);
|
|
@@ -40874,7 +41915,7 @@ function containsPathTraversal(filePath) {
|
|
|
40874
41915
|
return import_path9.default.isAbsolute(normalized) || normalized.startsWith("..");
|
|
40875
41916
|
}
|
|
40876
41917
|
async function changeFile(params2) {
|
|
40877
|
-
const { parameters, cwd, fs:
|
|
41918
|
+
const { parameters, cwd, fs: fs14 } = params2;
|
|
40878
41919
|
if (containsUpwardTraversal(cwd)) {
|
|
40879
41920
|
throw new Error("cwd contains invalid path traversal");
|
|
40880
41921
|
}
|
|
@@ -40887,7 +41928,7 @@ async function changeFile(params2) {
|
|
|
40887
41928
|
const { created, modified, invalid, patchFailed } = await applyChanges({
|
|
40888
41929
|
projectRoot: cwd,
|
|
40889
41930
|
changes: [fileChange],
|
|
40890
|
-
fs:
|
|
41931
|
+
fs: fs14
|
|
40891
41932
|
});
|
|
40892
41933
|
const results = [];
|
|
40893
41934
|
for (const file of created) {
|
|
@@ -40926,7 +41967,7 @@ async function changeFile(params2) {
|
|
|
40926
41967
|
return [{ type: "json", value: results[0] }];
|
|
40927
41968
|
}
|
|
40928
41969
|
async function applyChanges(params2) {
|
|
40929
|
-
const { projectRoot, changes, fs:
|
|
41970
|
+
const { projectRoot, changes, fs: fs14 } = params2;
|
|
40930
41971
|
const created = [];
|
|
40931
41972
|
const modified = [];
|
|
40932
41973
|
const patchFailed = [];
|
|
@@ -40935,21 +41976,21 @@ async function applyChanges(params2) {
|
|
|
40935
41976
|
const { path: filePath, content, type } = change;
|
|
40936
41977
|
try {
|
|
40937
41978
|
const fullPath = import_path9.default.join(projectRoot, filePath);
|
|
40938
|
-
const exists = await fileExists({ filePath: fullPath, fs:
|
|
41979
|
+
const exists = await fileExists({ filePath: fullPath, fs: fs14 });
|
|
40939
41980
|
if (!exists) {
|
|
40940
41981
|
const dirPath = import_path9.default.dirname(fullPath);
|
|
40941
|
-
await
|
|
41982
|
+
await fs14.mkdir(dirPath, { recursive: true });
|
|
40942
41983
|
}
|
|
40943
41984
|
if (type === "file") {
|
|
40944
|
-
await
|
|
41985
|
+
await fs14.writeFile(fullPath, content);
|
|
40945
41986
|
} else {
|
|
40946
|
-
const oldContent = await
|
|
41987
|
+
const oldContent = await fs14.readFile(fullPath, "utf-8");
|
|
40947
41988
|
const newContent = import_diff4.applyPatch(oldContent, content);
|
|
40948
41989
|
if (newContent === false) {
|
|
40949
41990
|
patchFailed.push(filePath);
|
|
40950
41991
|
continue;
|
|
40951
41992
|
}
|
|
40952
|
-
await
|
|
41993
|
+
await fs14.writeFile(fullPath, newContent);
|
|
40953
41994
|
}
|
|
40954
41995
|
if (exists) {
|
|
40955
41996
|
modified.push(filePath);
|
|
@@ -40966,8 +42007,8 @@ async function applyChanges(params2) {
|
|
|
40966
42007
|
|
|
40967
42008
|
// src/tools/code-search.ts
|
|
40968
42009
|
var import_child_process = require("child_process");
|
|
40969
|
-
var
|
|
40970
|
-
var
|
|
42010
|
+
var fs14 = __toESM(require("fs"));
|
|
42011
|
+
var path15 = __toESM(require("path"));
|
|
40971
42012
|
|
|
40972
42013
|
// ../common/src/util/format-code-search.ts
|
|
40973
42014
|
function formatCodeSearchOutput(stdout) {
|
|
@@ -41065,13 +42106,13 @@ function getBundledRgPath(importMetaUrl, env2 = getSdkEnv()) {
|
|
|
41065
42106
|
}
|
|
41066
42107
|
}
|
|
41067
42108
|
if (!vendorPath) {
|
|
41068
|
-
const
|
|
41069
|
-
if (typeof
|
|
41070
|
-
const cjsPath = import_path10.join(
|
|
42109
|
+
const dirname7 = new Function(`try { return __dirname; } catch (e) { return undefined; }`)();
|
|
42110
|
+
if (typeof dirname7 !== "undefined") {
|
|
42111
|
+
const cjsPath = import_path10.join(dirname7, "..", "..", "vendor", "ripgrep", platformDir, binaryName);
|
|
41071
42112
|
if (import_fs4.existsSync(cjsPath)) {
|
|
41072
42113
|
vendorPath = cjsPath;
|
|
41073
42114
|
}
|
|
41074
|
-
const cjsPath2 = import_path10.join(
|
|
42115
|
+
const cjsPath2 = import_path10.join(dirname7, "vendor", "ripgrep", platformDir, binaryName);
|
|
41075
42116
|
if (import_fs4.existsSync(cjsPath2)) {
|
|
41076
42117
|
vendorPath = cjsPath2;
|
|
41077
42118
|
}
|
|
@@ -41109,9 +42150,9 @@ function codeSearch({
|
|
|
41109
42150
|
}) {
|
|
41110
42151
|
return new Promise((resolve3) => {
|
|
41111
42152
|
let isResolved = false;
|
|
41112
|
-
const projectRoot =
|
|
41113
|
-
const searchCwd = cwd ?
|
|
41114
|
-
if (!searchCwd.startsWith(projectRoot +
|
|
42153
|
+
const projectRoot = path15.resolve(projectPath);
|
|
42154
|
+
const searchCwd = cwd ? path15.resolve(projectRoot, cwd) : projectRoot;
|
|
42155
|
+
if (!searchCwd.startsWith(projectRoot + path15.sep) && searchCwd !== projectRoot) {
|
|
41115
42156
|
return resolve3([
|
|
41116
42157
|
{
|
|
41117
42158
|
type: "json",
|
|
@@ -41124,7 +42165,7 @@ function codeSearch({
|
|
|
41124
42165
|
const flagsArray = (flags || "").split(" ").filter(Boolean).map((token) => token.replace(/^['"]|['"]$/g, ""));
|
|
41125
42166
|
const existingHiddenDirs = INCLUDED_HIDDEN_DIRS.filter((dir) => {
|
|
41126
42167
|
try {
|
|
41127
|
-
return
|
|
42168
|
+
return fs14.statSync(path15.join(searchCwd, dir)).isDirectory();
|
|
41128
42169
|
} catch {
|
|
41129
42170
|
return false;
|
|
41130
42171
|
}
|
|
@@ -41372,9 +42413,9 @@ ${truncatedFiles.join(`
|
|
|
41372
42413
|
// src/tools/glob.ts
|
|
41373
42414
|
var import_micromatch = __toESM(require("micromatch"));
|
|
41374
42415
|
async function glob(params2) {
|
|
41375
|
-
const { pattern, projectPath, cwd, fs:
|
|
42416
|
+
const { pattern, projectPath, cwd, fs: fs15 } = params2;
|
|
41376
42417
|
try {
|
|
41377
|
-
const fileTree = await getProjectFileTree({ projectRoot: projectPath, fs:
|
|
42418
|
+
const fileTree = await getProjectFileTree({ projectRoot: projectPath, fs: fs15 });
|
|
41378
42419
|
const flattenedNodes = flattenTree(fileTree);
|
|
41379
42420
|
let allFilePaths = flattenedNodes.filter((node) => node.type === "file").map((node) => node.filePath);
|
|
41380
42421
|
if (cwd) {
|
|
@@ -41406,11 +42447,11 @@ async function glob(params2) {
|
|
|
41406
42447
|
}
|
|
41407
42448
|
|
|
41408
42449
|
// src/tools/list-directory.ts
|
|
41409
|
-
var
|
|
42450
|
+
var path16 = __toESM(require("path"));
|
|
41410
42451
|
async function listDirectory(params2) {
|
|
41411
|
-
const { directoryPath, projectPath, fs:
|
|
42452
|
+
const { directoryPath, projectPath, fs: fs15 } = params2;
|
|
41412
42453
|
try {
|
|
41413
|
-
const resolvedPath =
|
|
42454
|
+
const resolvedPath = path16.resolve(projectPath, directoryPath);
|
|
41414
42455
|
if (!resolvedPath.startsWith(projectPath)) {
|
|
41415
42456
|
return [
|
|
41416
42457
|
{
|
|
@@ -41421,7 +42462,7 @@ async function listDirectory(params2) {
|
|
|
41421
42462
|
}
|
|
41422
42463
|
];
|
|
41423
42464
|
}
|
|
41424
|
-
const entries = await
|
|
42465
|
+
const entries = await fs15.readdir(resolvedPath, {
|
|
41425
42466
|
withFileTypes: true
|
|
41426
42467
|
});
|
|
41427
42468
|
const files = [];
|
|
@@ -41460,7 +42501,7 @@ async function listDirectory(params2) {
|
|
|
41460
42501
|
var import_path11 = __toESM(require("path"));
|
|
41461
42502
|
init_old_constants();
|
|
41462
42503
|
async function getFiles(params2) {
|
|
41463
|
-
const { filePaths, cwd, fs:
|
|
42504
|
+
const { filePaths, cwd, fs: fs15, fileFilter } = params2;
|
|
41464
42505
|
const hasCustomFilter = fileFilter !== undefined;
|
|
41465
42506
|
const result = {};
|
|
41466
42507
|
const MAX_FILE_SIZE = 1024 * 1024;
|
|
@@ -41484,7 +42525,7 @@ async function getFiles(params2) {
|
|
|
41484
42525
|
const ignored = await isFileIgnored({
|
|
41485
42526
|
filePath: relativePath,
|
|
41486
42527
|
projectRoot: cwd,
|
|
41487
|
-
fs:
|
|
42528
|
+
fs: fs15
|
|
41488
42529
|
});
|
|
41489
42530
|
if (ignored) {
|
|
41490
42531
|
result[relativePath] = FILE_READ_STATUS.IGNORED;
|
|
@@ -41492,11 +42533,11 @@ async function getFiles(params2) {
|
|
|
41492
42533
|
}
|
|
41493
42534
|
}
|
|
41494
42535
|
try {
|
|
41495
|
-
const stats = await
|
|
42536
|
+
const stats = await fs15.stat(fullPath);
|
|
41496
42537
|
if (stats.size > MAX_FILE_SIZE) {
|
|
41497
42538
|
result[relativePath] = FILE_READ_STATUS.TOO_LARGE + ` [${(stats.size / (1024 * 1024)).toFixed(2)}MB]`;
|
|
41498
42539
|
} else {
|
|
41499
|
-
const content = await
|
|
42540
|
+
const content = await fs15.readFile(fullPath, "utf8");
|
|
41500
42541
|
result[relativePath] = isExampleFile ? FILE_READ_STATUS.TEMPLATE + `
|
|
41501
42542
|
` + content : content;
|
|
41502
42543
|
}
|
|
@@ -41513,9 +42554,9 @@ async function getFiles(params2) {
|
|
|
41513
42554
|
|
|
41514
42555
|
// src/tools/run-terminal-command.ts
|
|
41515
42556
|
var import_child_process2 = require("child_process");
|
|
41516
|
-
var
|
|
41517
|
-
var
|
|
41518
|
-
var
|
|
42557
|
+
var fs15 = __toESM(require("fs"));
|
|
42558
|
+
var os7 = __toESM(require("os"));
|
|
42559
|
+
var path18 = __toESM(require("path"));
|
|
41519
42560
|
var COMMAND_OUTPUT_LIMIT = 50000;
|
|
41520
42561
|
var GIT_BASH_COMMON_PATHS = [
|
|
41521
42562
|
"C:\\Program Files\\Git\\bin\\bash.exe",
|
|
@@ -41528,30 +42569,30 @@ var WSL_BASH_PATH_PATTERNS = [
|
|
|
41528
42569
|
];
|
|
41529
42570
|
function findWindowsBash(env2) {
|
|
41530
42571
|
const customPath = env2.LEVELCODE_GIT_BASH_PATH;
|
|
41531
|
-
if (customPath &&
|
|
42572
|
+
if (customPath && fs15.existsSync(customPath)) {
|
|
41532
42573
|
return customPath;
|
|
41533
42574
|
}
|
|
41534
42575
|
for (const commonPath of GIT_BASH_COMMON_PATHS) {
|
|
41535
|
-
if (
|
|
42576
|
+
if (fs15.existsSync(commonPath)) {
|
|
41536
42577
|
return commonPath;
|
|
41537
42578
|
}
|
|
41538
42579
|
}
|
|
41539
42580
|
const pathEnv = env2.PATH || env2.Path || "";
|
|
41540
|
-
const pathDirs = pathEnv.split(
|
|
42581
|
+
const pathDirs = pathEnv.split(path18.delimiter);
|
|
41541
42582
|
const wslFallbackPaths = [];
|
|
41542
42583
|
for (const dir of pathDirs) {
|
|
41543
42584
|
const dirLower = dir.toLowerCase();
|
|
41544
42585
|
const isWslPath = WSL_BASH_PATH_PATTERNS.some((pattern) => dirLower.includes(pattern));
|
|
41545
|
-
const bashPath =
|
|
41546
|
-
if (
|
|
42586
|
+
const bashPath = path18.join(dir, "bash.exe");
|
|
42587
|
+
if (fs15.existsSync(bashPath)) {
|
|
41547
42588
|
if (isWslPath) {
|
|
41548
42589
|
wslFallbackPaths.push(bashPath);
|
|
41549
42590
|
} else {
|
|
41550
42591
|
return bashPath;
|
|
41551
42592
|
}
|
|
41552
42593
|
}
|
|
41553
|
-
const bashPathNoExt =
|
|
41554
|
-
if (
|
|
42594
|
+
const bashPathNoExt = path18.join(dir, "bash");
|
|
42595
|
+
if (fs15.existsSync(bashPathNoExt)) {
|
|
41555
42596
|
if (isWslPath) {
|
|
41556
42597
|
wslFallbackPaths.push(bashPathNoExt);
|
|
41557
42598
|
} else {
|
|
@@ -41591,7 +42632,7 @@ function runTerminalCommand({
|
|
|
41591
42632
|
throw new Error("BACKGROUND process_type not implemented");
|
|
41592
42633
|
}
|
|
41593
42634
|
return new Promise((resolve5, reject) => {
|
|
41594
|
-
const isWindows =
|
|
42635
|
+
const isWindows = os7.platform() === "win32";
|
|
41595
42636
|
const processEnv2 = {
|
|
41596
42637
|
...getSystemProcessEnv(),
|
|
41597
42638
|
...env2 ?? {}
|
|
@@ -41610,7 +42651,7 @@ function runTerminalCommand({
|
|
|
41610
42651
|
shell = "bash";
|
|
41611
42652
|
shellArgs = ["-c"];
|
|
41612
42653
|
}
|
|
41613
|
-
const resolvedCwd =
|
|
42654
|
+
const resolvedCwd = path18.resolve(cwd);
|
|
41614
42655
|
const childProcess = import_child_process2.spawn(shell, [...shellArgs, command], {
|
|
41615
42656
|
cwd: resolvedCwd,
|
|
41616
42657
|
env: processEnv2,
|
|
@@ -41731,7 +42772,7 @@ async function runOnce({
|
|
|
41731
42772
|
costMode
|
|
41732
42773
|
}) {
|
|
41733
42774
|
const fsSourceValue = typeof fsSource === "function" ? fsSource() : fsSource;
|
|
41734
|
-
const
|
|
42775
|
+
const fs16 = await fsSourceValue;
|
|
41735
42776
|
let spawn4;
|
|
41736
42777
|
if (spawnSource) {
|
|
41737
42778
|
const spawnSourceValue = await spawnSource;
|
|
@@ -41765,7 +42806,7 @@ async function runOnce({
|
|
|
41765
42806
|
customToolDefinitions,
|
|
41766
42807
|
projectFiles,
|
|
41767
42808
|
maxAgentSteps,
|
|
41768
|
-
fs:
|
|
42809
|
+
fs: fs16,
|
|
41769
42810
|
spawn: spawn4,
|
|
41770
42811
|
logger: logger2
|
|
41771
42812
|
});
|
|
@@ -41850,13 +42891,13 @@ async function runOnce({
|
|
|
41850
42891
|
logger: logger2,
|
|
41851
42892
|
apiKey,
|
|
41852
42893
|
handleStepsLogChunk: () => {},
|
|
41853
|
-
requestToolCall: async ({ userInputId: userInputId2, toolName:
|
|
42894
|
+
requestToolCall: async ({ userInputId: userInputId2, toolName: toolName39, input, mcpConfig }) => {
|
|
41854
42895
|
return handleToolCall({
|
|
41855
42896
|
action: {
|
|
41856
42897
|
type: "tool-call-request",
|
|
41857
42898
|
requestId: crypto.randomUUID(),
|
|
41858
42899
|
userInputId: userInputId2,
|
|
41859
|
-
toolName:
|
|
42900
|
+
toolName: toolName39,
|
|
41860
42901
|
input,
|
|
41861
42902
|
timeout: undefined,
|
|
41862
42903
|
mcpConfig
|
|
@@ -41864,7 +42905,7 @@ async function runOnce({
|
|
|
41864
42905
|
overrides: overrideTools ?? {},
|
|
41865
42906
|
customToolDefinitions: customToolDefinitions ? Object.fromEntries(customToolDefinitions.map((def) => [def.toolName, def])) : {},
|
|
41866
42907
|
cwd,
|
|
41867
|
-
fs:
|
|
42908
|
+
fs: fs16,
|
|
41868
42909
|
env: env2
|
|
41869
42910
|
});
|
|
41870
42911
|
},
|
|
@@ -41890,7 +42931,7 @@ async function runOnce({
|
|
|
41890
42931
|
override: overrideTools?.read_files,
|
|
41891
42932
|
fileFilter,
|
|
41892
42933
|
cwd,
|
|
41893
|
-
fs:
|
|
42934
|
+
fs: fs16
|
|
41894
42935
|
}),
|
|
41895
42936
|
requestOptionalFile: async ({ filePath }) => {
|
|
41896
42937
|
const files = await readFiles({
|
|
@@ -41898,7 +42939,7 @@ async function runOnce({
|
|
|
41898
42939
|
override: overrideTools?.read_files,
|
|
41899
42940
|
fileFilter,
|
|
41900
42941
|
cwd,
|
|
41901
|
-
fs:
|
|
42942
|
+
fs: fs16
|
|
41902
42943
|
});
|
|
41903
42944
|
return toOptionalFile(files[filePath] ?? null);
|
|
41904
42945
|
},
|
|
@@ -42004,9 +43045,9 @@ async function runOnce({
|
|
|
42004
43045
|
});
|
|
42005
43046
|
return promise;
|
|
42006
43047
|
}
|
|
42007
|
-
function requireCwd(cwd,
|
|
43048
|
+
function requireCwd(cwd, toolName39) {
|
|
42008
43049
|
if (!cwd) {
|
|
42009
|
-
throw new Error(`cwd is required for the ${
|
|
43050
|
+
throw new Error(`cwd is required for the ${toolName39} tool. Please provide cwd in LevelCodeClientOptions or override the ${toolName39} tool.`);
|
|
42010
43051
|
}
|
|
42011
43052
|
return cwd;
|
|
42012
43053
|
}
|
|
@@ -42015,28 +43056,28 @@ async function readFiles({
|
|
|
42015
43056
|
override,
|
|
42016
43057
|
fileFilter,
|
|
42017
43058
|
cwd,
|
|
42018
|
-
fs:
|
|
43059
|
+
fs: fs16
|
|
42019
43060
|
}) {
|
|
42020
43061
|
if (override) {
|
|
42021
43062
|
return await override({ filePaths });
|
|
42022
43063
|
}
|
|
42023
|
-
return getFiles({ filePaths, cwd: requireCwd(cwd, "read_files"), fs:
|
|
43064
|
+
return getFiles({ filePaths, cwd: requireCwd(cwd, "read_files"), fs: fs16, fileFilter });
|
|
42024
43065
|
}
|
|
42025
43066
|
async function handleToolCall({
|
|
42026
43067
|
action,
|
|
42027
43068
|
overrides,
|
|
42028
43069
|
customToolDefinitions,
|
|
42029
43070
|
cwd,
|
|
42030
|
-
fs:
|
|
43071
|
+
fs: fs16,
|
|
42031
43072
|
env: env2
|
|
42032
43073
|
}) {
|
|
42033
|
-
const
|
|
43074
|
+
const toolName39 = action.toolName;
|
|
42034
43075
|
const input = action.input;
|
|
42035
43076
|
if (action.mcpConfig) {
|
|
42036
43077
|
try {
|
|
42037
43078
|
const mcpClientId = await getMCPClient(action.mcpConfig);
|
|
42038
43079
|
const result2 = await callMCPTool(mcpClientId, {
|
|
42039
|
-
name:
|
|
43080
|
+
name: toolName39,
|
|
42040
43081
|
arguments: input
|
|
42041
43082
|
});
|
|
42042
43083
|
return { output: result2 };
|
|
@@ -42054,10 +43095,10 @@ async function handleToolCall({
|
|
|
42054
43095
|
}
|
|
42055
43096
|
}
|
|
42056
43097
|
let result;
|
|
42057
|
-
if (toolNames.includes(
|
|
43098
|
+
if (toolNames.includes(toolName39)) {
|
|
42058
43099
|
clientToolCallSchema.parse(action);
|
|
42059
43100
|
} else {
|
|
42060
|
-
const customToolHandler = customToolDefinitions[
|
|
43101
|
+
const customToolHandler = customToolDefinitions[toolName39];
|
|
42061
43102
|
if (!customToolHandler) {
|
|
42062
43103
|
throw new Error(`Custom tool handler not found for user input ID ${action.userInputId}`);
|
|
42063
43104
|
}
|
|
@@ -42066,46 +43107,46 @@ async function handleToolCall({
|
|
|
42066
43107
|
};
|
|
42067
43108
|
}
|
|
42068
43109
|
try {
|
|
42069
|
-
let override = overrides[
|
|
42070
|
-
if (!override &&
|
|
43110
|
+
let override = overrides[toolName39];
|
|
43111
|
+
if (!override && toolName39 === "str_replace") {
|
|
42071
43112
|
override = overrides["write_file"];
|
|
42072
43113
|
}
|
|
42073
43114
|
if (override) {
|
|
42074
43115
|
result = await override(input);
|
|
42075
|
-
} else if (
|
|
43116
|
+
} else if (toolName39 === "end_turn") {
|
|
42076
43117
|
result = [{ type: "json", value: { message: "Turn ended." } }];
|
|
42077
|
-
} else if (
|
|
43118
|
+
} else if (toolName39 === "write_file" || toolName39 === "str_replace") {
|
|
42078
43119
|
result = await changeFile({
|
|
42079
43120
|
parameters: input,
|
|
42080
|
-
cwd: requireCwd(cwd,
|
|
42081
|
-
fs:
|
|
43121
|
+
cwd: requireCwd(cwd, toolName39),
|
|
43122
|
+
fs: fs16
|
|
42082
43123
|
});
|
|
42083
|
-
} else if (
|
|
43124
|
+
} else if (toolName39 === "run_terminal_command") {
|
|
42084
43125
|
const resolvedCwd = requireCwd(cwd, "run_terminal_command");
|
|
42085
43126
|
result = await runTerminalCommand({
|
|
42086
43127
|
...input,
|
|
42087
43128
|
cwd: import_path12.default.resolve(resolvedCwd, input.cwd ?? "."),
|
|
42088
43129
|
env: env2
|
|
42089
43130
|
});
|
|
42090
|
-
} else if (
|
|
43131
|
+
} else if (toolName39 === "code_search") {
|
|
42091
43132
|
result = await codeSearch({
|
|
42092
43133
|
projectPath: requireCwd(cwd, "code_search"),
|
|
42093
43134
|
...input
|
|
42094
43135
|
});
|
|
42095
|
-
} else if (
|
|
43136
|
+
} else if (toolName39 === "list_directory") {
|
|
42096
43137
|
result = await listDirectory({
|
|
42097
43138
|
directoryPath: input.path,
|
|
42098
43139
|
projectPath: requireCwd(cwd, "list_directory"),
|
|
42099
|
-
fs:
|
|
43140
|
+
fs: fs16
|
|
42100
43141
|
});
|
|
42101
|
-
} else if (
|
|
43142
|
+
} else if (toolName39 === "glob") {
|
|
42102
43143
|
result = await glob({
|
|
42103
43144
|
pattern: input.pattern,
|
|
42104
43145
|
projectPath: requireCwd(cwd, "glob"),
|
|
42105
43146
|
cwd: input.cwd,
|
|
42106
|
-
fs:
|
|
43147
|
+
fs: fs16
|
|
42107
43148
|
});
|
|
42108
|
-
} else if (
|
|
43149
|
+
} else if (toolName39 === "run_file_change_hooks") {
|
|
42109
43150
|
result = [
|
|
42110
43151
|
{
|
|
42111
43152
|
type: "json",
|
|
@@ -42115,7 +43156,7 @@ async function handleToolCall({
|
|
|
42115
43156
|
}
|
|
42116
43157
|
];
|
|
42117
43158
|
} else {
|
|
42118
|
-
throw new Error(`Tool not implemented in SDK. Please provide an override or modify your agent to not use this tool: ${
|
|
43159
|
+
throw new Error(`Tool not implemented in SDK. Please provide an override or modify your agent to not use this tool: ${toolName39}`);
|
|
42119
43160
|
}
|
|
42120
43161
|
} catch (error) {
|
|
42121
43162
|
result = [
|
|
@@ -42296,18 +43337,18 @@ Provide a handleEvent function to handle this error.`);
|
|
|
42296
43337
|
}
|
|
42297
43338
|
// src/custom-tool.ts
|
|
42298
43339
|
function getCustomToolDefinition({
|
|
42299
|
-
toolName:
|
|
42300
|
-
inputSchema:
|
|
42301
|
-
description:
|
|
42302
|
-
endsAgentStep:
|
|
43340
|
+
toolName: toolName39,
|
|
43341
|
+
inputSchema: inputSchema39,
|
|
43342
|
+
description: description38,
|
|
43343
|
+
endsAgentStep: endsAgentStep39 = true,
|
|
42303
43344
|
exampleInputs = [],
|
|
42304
43345
|
execute
|
|
42305
43346
|
}) {
|
|
42306
43347
|
return {
|
|
42307
|
-
toolName:
|
|
42308
|
-
inputSchema:
|
|
42309
|
-
description:
|
|
42310
|
-
endsAgentStep:
|
|
43348
|
+
toolName: toolName39,
|
|
43349
|
+
inputSchema: inputSchema39,
|
|
43350
|
+
description: description38,
|
|
43351
|
+
endsAgentStep: endsAgentStep39,
|
|
42311
43352
|
exampleInputs,
|
|
42312
43353
|
execute: async (params2) => {
|
|
42313
43354
|
return await execute(params2);
|
|
@@ -42345,9 +43386,9 @@ var import_fs5 = __toESM(require("fs"));
|
|
|
42345
43386
|
var import_promises = __toESM(require("fs/promises"));
|
|
42346
43387
|
var import_os4 = __toESM(require("os"));
|
|
42347
43388
|
var import_path13 = __toESM(require("path"));
|
|
42348
|
-
var
|
|
42349
|
-
var mcpFileSchema =
|
|
42350
|
-
mcpServers:
|
|
43389
|
+
var import_v482 = require("zod/v4");
|
|
43390
|
+
var mcpFileSchema = import_v482.z.object({
|
|
43391
|
+
mcpServers: import_v482.z.record(import_v482.z.string(), mcpConfigSchema).default(() => ({}))
|
|
42351
43392
|
});
|
|
42352
43393
|
var envKey = "env";
|
|
42353
43394
|
var processEnv2 = process[envKey];
|
|
@@ -42476,5 +43517,5 @@ function loadMCPConfigSync(options) {
|
|
|
42476
43517
|
return mergedConfig;
|
|
42477
43518
|
}
|
|
42478
43519
|
|
|
42479
|
-
//# debugId=
|
|
43520
|
+
//# debugId=532E2EE00FAB612B64756E2164756E21
|
|
42480
43521
|
//# sourceMappingURL=index.cjs.map
|