@letta-ai/letta-code 0.34.45 → 0.34.46
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/app-server-client.cjs.map +2 -2
- package/dist/app-server-client.js.map +2 -2
- package/dist/mcp-client.js +2 -2
- package/dist/mcp-client.js.map +1 -1
- package/dist/mcp-oauth.js +2 -2
- package/dist/mcp-oauth.js.map +1 -1
- package/dist/types/tools/external-tool-types.d.ts +0 -2
- package/dist/types/tools/external-tool-types.d.ts.map +1 -1
- package/dist/types/tools/manager.d.ts +2 -2
- package/dist/types/tools/manager.d.ts.map +1 -1
- package/dist/types/tools/tool-policy.d.ts +18 -0
- package/dist/types/tools/tool-policy.d.ts.map +1 -0
- package/dist/types/tools/toolset.d.ts +4 -2
- package/dist/types/tools/toolset.d.ts.map +1 -1
- package/dist/types/types/app-server-info.d.ts +2 -0
- package/dist/types/types/app-server-info.d.ts.map +1 -1
- package/dist/types/types/external-tool-protocol.d.ts +26 -3
- package/dist/types/types/external-tool-protocol.d.ts.map +1 -1
- package/dist/types/types/input-create-message.d.ts +0 -2
- package/dist/types/types/input-create-message.d.ts.map +1 -1
- package/dist/types/types/queue-update-protocol.d.ts +6 -0
- package/dist/types/types/queue-update-protocol.d.ts.map +1 -1
- package/dist/types/types/runtime-start-protocol.d.ts +6 -1
- package/dist/types/types/runtime-start-protocol.d.ts.map +1 -1
- package/dist/types/websocket/listener/conversation-runtime.d.ts.map +1 -1
- package/dist/types/websocket/listener/types.d.ts +0 -1
- package/dist/types/websocket/listener/types.d.ts.map +1 -1
- package/letta.js +223 -523
- package/npm-shrinkwrap.json +11 -11
- package/package.json +2 -2
- package/scripts/isolated-unit-tests.json +15 -0
- package/scripts/source-file-size-baseline.json +3 -3
package/letta.js
CHANGED
|
@@ -6077,7 +6077,7 @@ var package_default;
|
|
|
6077
6077
|
var init_package = __esm(() => {
|
|
6078
6078
|
package_default = {
|
|
6079
6079
|
name: "@letta-ai/letta-code",
|
|
6080
|
-
version: "0.34.
|
|
6080
|
+
version: "0.34.46",
|
|
6081
6081
|
lettaStartupLogProtocol: 1,
|
|
6082
6082
|
lettaConfigDirProtocol: 1,
|
|
6083
6083
|
description: "Letta Code is a CLI tool for interacting with stateful Letta agents from the terminal.",
|
|
@@ -6354,7 +6354,7 @@ var init_package = __esm(() => {
|
|
|
6354
6354
|
},
|
|
6355
6355
|
lettaLifecycleProtocol: 1,
|
|
6356
6356
|
lettaRuntimeGraphProtocol: 1,
|
|
6357
|
-
lettaRuntimeGraphSha512: "sha512-
|
|
6357
|
+
lettaRuntimeGraphSha512: "sha512-DMyrwe+kalQ3U0ncY7kalXtOWp1QE7bh32cJNtGoERBViCd8eeb0avXJTTyM3TSLUTzaKyZ58TXwUiZeLLGDew==",
|
|
6358
6358
|
patchedDependencies: {
|
|
6359
6359
|
"@earendil-works/pi-ai@0.99.1": "patches/@earendil-works%2Fpi-ai@0.99.1.patch"
|
|
6360
6360
|
}
|
|
@@ -212080,7 +212080,7 @@ var init_mcp_client = __esm(() => {
|
|
|
212080
212080
|
init_streamableHttp();
|
|
212081
212081
|
DEFAULT_CLIENT_INFO = {
|
|
212082
212082
|
name: "letta-code",
|
|
212083
|
-
version: "0.34.
|
|
212083
|
+
version: "0.34.46"
|
|
212084
212084
|
};
|
|
212085
212085
|
});
|
|
212086
212086
|
|
|
@@ -215949,44 +215949,8 @@ function defineTool(input) {
|
|
|
215949
215949
|
var init_define_tool = () => {};
|
|
215950
215950
|
|
|
215951
215951
|
// src/tools/descriptions/ApplyPatch.md
|
|
215952
|
-
var ApplyPatch_default = `Use the \`ApplyPatch\` tool to edit files.
|
|
215953
|
-
Your patch language is a stripped‑down, file‑oriented diff format designed to be easy to parse and safe to apply. You can think of it as a high‑level envelope:
|
|
215952
|
+
var ApplyPatch_default = `Use the \`ApplyPatch\` tool to edit files. Pass the whole patch as \`input\`, using this grammar:
|
|
215954
215953
|
|
|
215955
|
-
*** Begin Patch
|
|
215956
|
-
[ one or more file sections ]
|
|
215957
|
-
*** End Patch
|
|
215958
|
-
|
|
215959
|
-
Within that envelope, you get a sequence of file operations.
|
|
215960
|
-
You MUST include a header to specify the action you are taking.
|
|
215961
|
-
Each operation starts with one of three headers:
|
|
215962
|
-
|
|
215963
|
-
*** Add File: <path> - create a new file. Every following line is a + line (the initial contents).
|
|
215964
|
-
*** Delete File: <path> - remove an existing file. Nothing follows.
|
|
215965
|
-
*** Update File: <path> - patch an existing file in place (optionally with a rename).
|
|
215966
|
-
|
|
215967
|
-
May be immediately followed by *** Move to: <new path> if you want to rename the file.
|
|
215968
|
-
Then one or more “hunks”, each introduced by @@ (optionally followed by a hunk header).
|
|
215969
|
-
Within a hunk each line starts with:
|
|
215970
|
-
|
|
215971
|
-
For instructions on [context_before] and [context_after]:
|
|
215972
|
-
- By default, show 3 lines of code immediately above and 3 lines immediately below each change. If a change is within 3 lines of a previous change, do NOT duplicate the first change’s [context_after] lines in the second change’s [context_before] lines.
|
|
215973
|
-
- If 3 lines of context is insufficient to uniquely identify the snippet of code within the file, use the @@ operator to indicate the class or function to which the snippet belongs. For instance, we might have:
|
|
215974
|
-
@@ class BaseClass
|
|
215975
|
-
[3 lines of pre-context]
|
|
215976
|
-
- [old_code]
|
|
215977
|
-
+ [new_code]
|
|
215978
|
-
[3 lines of post-context]
|
|
215979
|
-
|
|
215980
|
-
- If a code block is repeated so many times in a class or function such that even a single \`@@\` statement and 3 lines of context cannot uniquely identify the snippet of code, you can use multiple \`@@\` statements to jump to the right context. For instance:
|
|
215981
|
-
|
|
215982
|
-
@@ class BaseClass
|
|
215983
|
-
@@ def method():
|
|
215984
|
-
[3 lines of pre-context]
|
|
215985
|
-
- [old_code]
|
|
215986
|
-
+ [new_code]
|
|
215987
|
-
[3 lines of post-context]
|
|
215988
|
-
|
|
215989
|
-
The full grammar definition is below:
|
|
215990
215954
|
Patch := Begin { FileOp } End
|
|
215991
215955
|
Begin := "*** Begin Patch" NEWLINE
|
|
215992
215956
|
End := "*** End Patch" NEWLINE
|
|
@@ -215998,7 +215962,7 @@ MoveTo := "*** Move to: " newPath NEWLINE
|
|
|
215998
215962
|
Hunk := "@@" [ header ] NEWLINE { HunkLine } [ "*** End of File" NEWLINE ]
|
|
215999
215963
|
HunkLine := (" " | "-" | "+") text NEWLINE
|
|
216000
215964
|
|
|
216001
|
-
|
|
215965
|
+
Example:
|
|
216002
215966
|
|
|
216003
215967
|
*** Begin Patch
|
|
216004
215968
|
*** Add File: hello.txt
|
|
@@ -216011,12 +215975,7 @@ A full patch can combine several operations:
|
|
|
216011
215975
|
*** Delete File: obsolete.txt
|
|
216012
215976
|
*** End Patch
|
|
216013
215977
|
|
|
216014
|
-
|
|
216015
|
-
|
|
216016
|
-
- You must include a header with your intended action (Add/Delete/Update)
|
|
216017
|
-
- You must prefix new lines with \`+\` even when creating a new file
|
|
216018
|
-
- Relative file references are interpreted from the current working directory.
|
|
216019
|
-
- Absolute file references are also accepted.
|
|
215978
|
+
Relative file references are interpreted from the current working directory. Absolute file references are also accepted.
|
|
216020
215979
|
`;
|
|
216021
215980
|
var init_ApplyPatch = () => {};
|
|
216022
215981
|
|
|
@@ -216041,180 +216000,40 @@ Usage notes:
|
|
|
216041
216000
|
var init_AskUserQuestion = () => {};
|
|
216042
216001
|
|
|
216043
216002
|
// src/tools/descriptions/Bash.md
|
|
216044
|
-
var Bash_default =
|
|
216045
|
-
|
|
216046
|
-
Executes a given shell command from the conversation's current working directory with optional timeout, ensuring proper handling and security measures.
|
|
216047
|
-
|
|
216048
|
-
IMPORTANT: This tool is for terminal operations like git, npm, docker, etc. DO NOT use it for file operations (reading, writing, editing, searching, finding files) - use the specialized tools for this instead. When Glob or Grep is available, prefer those tools over shell commands for repository searches.
|
|
216049
|
-
|
|
216050
|
-
Before executing the command, please follow these steps:
|
|
216051
|
-
|
|
216052
|
-
1. Directory Verification:
|
|
216053
|
-
- If the command will create new directories or files, first use \`ls\` to verify the parent directory exists and is the correct location
|
|
216054
|
-
- For example, before running "mkdir foo/bar", first use \`ls foo\` to check that "foo" exists and is the intended parent directory
|
|
216055
|
-
|
|
216056
|
-
2. Command Execution:
|
|
216057
|
-
- Always quote file paths that contain spaces with double quotes (e.g., cd "path with spaces/file.txt")
|
|
216058
|
-
- Examples of proper quoting:
|
|
216059
|
-
- cd "/Users/name/My Documents" (correct)
|
|
216060
|
-
- cd /Users/name/My Documents (incorrect - will fail)
|
|
216061
|
-
- python "/path/with spaces/script.py" (correct)
|
|
216062
|
-
- python /path/with spaces/script.py (incorrect - will fail)
|
|
216063
|
-
- After ensuring proper quoting, execute the command.
|
|
216064
|
-
- Capture the output of the command.
|
|
216065
|
-
|
|
216066
|
-
Usage notes:
|
|
216067
|
-
- The command and description arguments are required.
|
|
216068
|
-
- Commands run until they exit unless you pass a timeout in milliseconds. Foreground timeouts have a maximum of 600000ms.
|
|
216069
|
-
- Write a clear, concise user-facing description of what this command does. This description may be shown directly in chat as part of a status row like \`Running command: <description>\` or \`Ran command: <description>\`. Describe the command's purpose, not its shell syntax. For simple commands, keep it brief (5-10 words). For complex commands (piped commands, obscure flags, or anything hard to understand at a glance), add enough context to clarify what it does.
|
|
216070
|
-
- If the output exceeds 30000 characters, you receive only the first 2000 characters plus the path of a file containing the full output. A failed command whose output exceeds 10000 characters returns a head-and-tail excerpt plus that file path. Read or search that file when you need the rest instead of re-running the command.
|
|
216071
|
-
- Ordinary commands wait briefly for a result, then automatically continue in the background if they are still running. You will receive a task ID and one completion notification, so do not predict command duration, set \`run_in_background\` merely because a command may be slow, or poll for completion.
|
|
216072
|
-
- Set \`run_in_background\` only when you want the command to return a task ID immediately. You do not need to use '&' at the end of the command.
|
|
216073
|
-
- Pick between Bash and the Monitor tool by how many notifications you need. **One** ("tell me when the server is ready / the build finishes") → Bash with \`run_in_background\` and a command that exits when the condition is true, e.g. \`until grep -q "Ready in" dev.log; do sleep 0.5; done\`. You get one completion notification when it exits. Foreground \`sleep\` is blocked. **One per occurrence** ("tell me every time an ERROR line appears") → use Monitor: each stdout line is an event while you keep working.
|
|
216074
|
-
|
|
216075
|
-
- Avoid using Bash with the \`cat\`, \`head\`, \`tail\`, \`sed\`, \`awk\`, or \`echo\` commands, unless explicitly instructed or when these commands are truly necessary for the task. Instead, always prefer using the dedicated tools for these commands:
|
|
216076
|
-
- Read files: Use Read (NOT cat/head/tail)
|
|
216077
|
-
- Edit files: Use Edit (NOT sed/awk)
|
|
216078
|
-
- Write files: Use Write (NOT echo >/cat <<EOF)
|
|
216079
|
-
- Communication: Output text directly (NOT echo/printf)
|
|
216080
|
-
- When issuing multiple commands:
|
|
216081
|
-
- If the commands are independent and can run in parallel, make multiple Bash tool calls in a single message. For example, if you need to run "git status" and "git diff", send a single message with two Bash tool calls in parallel.
|
|
216082
|
-
- If the commands depend on each other and must run sequentially, use a single Bash call with '&&' to chain them together (e.g., \`git add . && git commit -m "message" && git push\`). For instance, if one operation must complete before another starts (like mkdir before cp, Write before Bash for git operations, or git add before git commit), run these operations sequentially instead.
|
|
216083
|
-
- Use ';' only when you need to run commands sequentially but don't care if earlier commands fail
|
|
216084
|
-
- DO NOT use newlines to separate commands (newlines are ok in quoted strings)
|
|
216085
|
-
- Each Bash call starts from the conversation's current working directory. A \`cd\` affects only that command and does not change the directory used by later tool calls.
|
|
216086
|
-
- To change the working directory for later tool calls, use \`SetWorkingDirectory\`. For a one-off command in another directory, use an absolute path or a command-specific option such as \`git -C /path/to/repo status\`.
|
|
216087
|
-
|
|
216088
|
-
# Committing changes with git
|
|
216089
|
-
|
|
216090
|
-
Only create commits when requested by the user. If unclear, ask first. When the user asks you to create a new git commit, follow these steps carefully:
|
|
216091
|
-
|
|
216092
|
-
Git Safety Protocol:
|
|
216093
|
-
- NEVER update the git config
|
|
216094
|
-
- NEVER run destructive/irreversible git commands (like push --force, hard reset, etc) unless the user explicitly requests them
|
|
216095
|
-
- NEVER skip hooks (--no-verify, --no-gpg-sign, etc) unless the user explicitly requests it
|
|
216096
|
-
- NEVER run force push to main/master, warn the user if they request it
|
|
216097
|
-
- CRITICAL: Always create NEW commits rather than amending, unless the user explicitly requests a git amend. When a pre-commit hook fails, the commit did NOT happen — so --amend would modify the PREVIOUS commit, which may result in destroying work or losing previous changes. Instead, after hook failure, fix the issue, re-stage, and create a NEW commit
|
|
216098
|
-
- When staging files, prefer adding specific files by name rather than using "git add -A" or "git add .", which can accidentally include sensitive files (.env, credentials) or large binaries
|
|
216099
|
-
- NEVER commit changes unless the user explicitly asks you to. It is VERY IMPORTANT to only commit when explicitly asked, otherwise the user will feel that you are being too proactive.
|
|
216100
|
-
|
|
216101
|
-
1. You can call multiple tools in a single response. When multiple independent pieces of information are requested and all commands are likely to succeed, run multiple tool calls in parallel for optimal performance. run the following bash commands in parallel, each using the Bash tool:
|
|
216102
|
-
- Run a git status command to see all untracked files. IMPORTANT: Never use the -uall flag as it can cause memory issues on large repos.
|
|
216103
|
-
- Run a git diff command to see both staged and unstaged changes that will be committed.
|
|
216104
|
-
- Run a git log command to see recent commit messages, so that you can follow this repository's commit message style.
|
|
216105
|
-
2. Analyze all staged changes (both previously staged and newly added) and draft a commit message:
|
|
216106
|
-
- Summarize the nature of the changes (eg. new feature, enhancement to an existing feature, bug fix, refactoring, test, docs, etc.). Ensure the message accurately reflects the changes and their purpose (i.e. "add" means a wholly new feature, "update" means an enhancement to an existing feature, "fix" means a bug fix, etc.).
|
|
216107
|
-
- Do not commit files that likely contain secrets (.env, credentials.json, etc). Warn the user if they specifically request to commit those files
|
|
216108
|
-
- Draft a concise (1-2 sentences) commit message that focuses on the "why" rather than the "what"
|
|
216109
|
-
- Ensure it accurately reflects the changes and their purpose
|
|
216110
|
-
3. You can call multiple tools in a single response. When multiple independent pieces of information are requested and all commands are likely to succeed, run multiple tool calls in parallel for optimal performance. run the following commands:
|
|
216111
|
-
- Add relevant untracked files to the staging area.
|
|
216112
|
-
- Create the commit with a message ending with:
|
|
216113
|
-
{{COMMIT_TRAILER}}
|
|
216114
|
-
- Run git status after the commit completes to verify success.
|
|
216115
|
-
Note: git status depends on the commit completing, so run it sequentially after the commit.
|
|
216116
|
-
4. If the commit fails due to pre-commit hook: fix the issue and create a NEW commit
|
|
216117
|
-
|
|
216118
|
-
Important notes:
|
|
216119
|
-
- NEVER run additional commands to read or explore code, besides git bash commands
|
|
216120
|
-
- NEVER use the TaskCreate or Task tools
|
|
216121
|
-
- DO NOT push to the remote repository unless the user explicitly asks you to do so
|
|
216122
|
-
- IMPORTANT: Never use git commands with the -i flag (like git rebase -i or git add -i) since they require interactive input which is not supported.
|
|
216123
|
-
- IMPORTANT: Do not use --no-edit with git rebase commands, as the --no-edit flag is not a valid option for git rebase.
|
|
216124
|
-
- If there are no changes to commit (i.e., no untracked files and no modifications), do not create an empty commit
|
|
216125
|
-
- In order to ensure good formatting, ALWAYS pass the commit message as a single-quoted string with embedded newlines, a la this example:
|
|
216126
|
-
<example>
|
|
216127
|
-
git commit -m 'Commit message here.
|
|
216128
|
-
|
|
216129
|
-
{{COMMIT_TRAILER}}'
|
|
216130
|
-
</example>
|
|
216131
|
-
|
|
216132
|
-
Use single quotes (not double quotes) and do NOT wrap the message in \`$(...)\` or backticks — single-quoting preserves the message verbatim (including \`$VAR\`, backticks, and other special characters) without needing escapes.
|
|
216133
|
-
|
|
216134
|
-
# Creating pull requests
|
|
216135
|
-
Use the gh command via the Bash tool for ALL GitHub-related tasks including working with issues, pull requests, checks, and releases. If given a Github URL use the gh command to get the information needed.
|
|
216136
|
-
|
|
216137
|
-
IMPORTANT: When the user asks you to create a pull request, follow these steps carefully:
|
|
216138
|
-
|
|
216139
|
-
1. You can call multiple tools in a single response. When multiple independent pieces of information are requested and all commands are likely to succeed, run multiple tool calls in parallel for optimal performance. run the following bash commands in parallel using the Bash tool, in order to understand the current state of the branch since it diverged from the main branch:
|
|
216140
|
-
- Run a git status command to see all untracked files
|
|
216141
|
-
- Run a git diff command to see both staged and unstaged changes that will be committed
|
|
216142
|
-
- Check if the current branch tracks a remote branch and is up to date with the remote, so you know if you need to push to the remote
|
|
216143
|
-
- Run a git log command and \`git diff [base-branch]...HEAD\` to understand the full commit history for the current branch (from the time it diverged from the base branch)
|
|
216144
|
-
2. Analyze all changes that will be included in the pull request, making sure to look at all relevant commits (NOT just the latest commit, but ALL commits that will be included in the pull request!!!), and draft a pull request summary
|
|
216145
|
-
3. You can call multiple tools in a single response. When multiple independent pieces of information are requested and all commands are likely to succeed, run multiple tool calls in parallel for optimal performance. run the following commands in parallel:
|
|
216146
|
-
- Create new branch if needed
|
|
216147
|
-
- Push to remote with -u flag if needed
|
|
216148
|
-
- Create PR using gh pr create with the format below. Pass the body as a single-quoted string with embedded newlines (do NOT wrap it in \`$(...)\` or backticks).
|
|
216149
|
-
<example>
|
|
216150
|
-
gh pr create --title "the pr title" --body '## Summary
|
|
216151
|
-
<1-3 bullet points>
|
|
216152
|
-
|
|
216153
|
-
## Test plan
|
|
216154
|
-
[Bulleted markdown checklist of TODOs for testing the pull request...]
|
|
216155
|
-
|
|
216156
|
-
👾 Generated with [Letta Code](https://letta.com)'
|
|
216157
|
-
</example>
|
|
216158
|
-
|
|
216159
|
-
4. Passing \`gh pr checks\` does not mean GitHub will merge the PR — unresolved review threads and still-pending required checks leave the merge state BLOCKED. If WatchPR is available and you will follow the PR toward merge, start it on the PR URL, and call the PR ready, green, or mergeable only once WatchPR reports it merge-ready.
|
|
216160
|
-
|
|
216161
|
-
Important:
|
|
216162
|
-
- DO NOT use the TaskCreate or Task tools
|
|
216163
|
-
- Return the PR URL when you're done, so the user can see it
|
|
216164
|
-
|
|
216165
|
-
# Other common operations
|
|
216166
|
-
- View comments on a Github PR: gh api repos/foo/bar/pulls/123/comments
|
|
216167
|
-
`;
|
|
216003
|
+
var Bash_default = "Executes a shell command and returns its output.\n\n- Each Bash call starts from the conversation's current working directory. A `cd` affects only that command and does not change the directory used by later tool calls. To change the working directory for later tool calls, use `SetWorkingDirectory`. For a one-off command elsewhere, use an absolute path or an option such as `git -C /path/to/repo status`.\n- IMPORTANT: Avoid using this tool to run `cat`, `head`, `tail`, `sed`, `awk`, or `echo` commands, unless explicitly instructed. Use Read, Edit and Write for file operations instead. Quote paths that contain spaces.\n- Command output is displayed to you, not reliably to the user.\n- `timeout` is in milliseconds. Without it, commands run until they exit; foreground timeouts max out at 600000.\n- If the output exceeds 30000 characters, you receive only the first 2000 characters plus the path of a file containing the full output. A failed command whose output exceeds 10000 characters returns a head-and-tail excerpt plus that file path. Read or search that file when you need the rest instead of re-running the command.\n- Commands still running after a brief wait continue in the background automatically: you receive a task ID and one completion notification. Do not predict command duration, set `run_in_background` merely because a command may be slow, or poll for completion. Set `run_in_background` only when you want the task ID immediately; no `&` needed.\n- Foreground `sleep` is blocked. To be notified once when a condition is true, run a command that exits then, e.g. `until grep -q \"Ready\" dev.log; do sleep 0.5; done`. For one notification per event, use Monitor.\n- Run independent commands as parallel tool calls; chain dependent ones with `&&`.\n\n# Git\n- Interactive flags (`-i`, e.g. `git rebase -i`, `git add -i`) are not supported in this environment.\n- Use the `gh` CLI for GitHub operations (PRs, issues, API).\n- GitHub notifies the owner of any `@name` written in a PR, issue, or comment. Write a bare `@name` only for a real login you mean to notify. Put roles, placeholders, and code (`@human`, `@reviewer`, `@types/node`) in backticks or drop the `@`.\n- Commit or push only when the user asks. Do not amend, skip hooks, force-push, or run other destructive git commands unless the user asks; if a pre-commit hook fails, fix the issue and create a new commit.\n- Pass commit messages and PR bodies as single-quoted strings with embedded newlines. Do not wrap them in `$(...)` or backticks. End commit messages with:\n{{COMMIT_TRAILER}}\n<example>\ngit commit -m 'Commit message here.\n\n{{COMMIT_TRAILER}}'\n</example>\n- Passing `gh pr checks` does not mean GitHub will merge the PR — unresolved review threads and still-pending required checks leave the merge state BLOCKED. If WatchPR is available and you will follow the PR toward merge, start it on the PR URL, and call the PR ready, green, or mergeable only once WatchPR reports it merge-ready.\n";
|
|
216168
216004
|
var init_Bash = () => {};
|
|
216169
216005
|
|
|
216170
216006
|
// src/tools/descriptions/CodeMode.md
|
|
216171
|
-
var CodeMode_default = "Run a JavaScript async function body that calls tools and returns only the results you need.\n\nCall built-in and server-side tools with `await tools.<name>(args)` and MCP tools with `await tools.mcp__server__tool(args)`; `listTools()` and `describeTool(name)` list tools and their schemas. Failed calls throw. `args` holds optional input, `process.env` holds the variables a
|
|
216007
|
+
var CodeMode_default = "Run a JavaScript async function body that calls tools and returns only the results you need.\n\nCall built-in and server-side tools with `await tools.<name>(args)` and MCP tools with `await tools.mcp__server__tool(args)`; `listTools()` and `describeTool(name)` list tools and their schemas. Failed calls throw. `args` holds optional input, `process.env` holds the variables a shell command sees plus the agent's secrets, and `console.log()` output is captured.\n\n`await decide(state, questions, options?)` makes one typed model decision. `questions` is an object of id → `{ type, instructions, criteria }`: `choice` takes a criteria map of id → description, `score` a criteria array, `noul` no criteria. It resolves to `{ answers }` keyed by question id (`.choice`, `.score`, or `.noul` in 0–1), or `null` after an invalid answer.\n\nReturns `{ result, output }`. Like a shell command, a script still running after a brief wait continues in the background and its result arrives as a task notification; `run_in_background: true` returns the task ID immediately. TaskStop aborts it.\n\nNested calls follow permission rules; calls that need approval fail, so call those tools directly. This is not a security sandbox.\n";
|
|
216172
216008
|
var init_CodeMode = () => {};
|
|
216173
216009
|
|
|
216174
216010
|
// src/tools/descriptions/Edit.md
|
|
216175
|
-
var Edit_default = "
|
|
216011
|
+
var Edit_default = "Performs exact string replacement in a file.\n\n- Read the file in this conversation before editing it. Exception: memory files whose contents are already present in your system prompt do not require a Read call first. For memory files, pass an expanded absolute path.\n- `file_path` is literal: `$VAR`, `$MEMORY_DIR`, `~`, etc. are not expanded.\n- `old_string` must match the file exactly, including indentation, and be unique — the edit fails otherwise. Strip the Read line prefix (line number + tab) before matching.\n- `replace_all: true` replaces every occurrence instead.\n";
|
|
216176
216012
|
var init_Edit = () => {};
|
|
216177
216013
|
|
|
216178
216014
|
// src/tools/descriptions/EnterWorktree.md
|
|
216179
|
-
var EnterWorktree_default = "
|
|
216015
|
+
var EnterWorktree_default = "Create a fresh isolated git worktree for this conversation, or switch this conversation into an existing one.\n\nUse this tool when starting a new feature, bug fix, refactor, or other file-editing task where isolated branch work is useful, especially if the user or other agents may be working in the same repository. Prefer worktrees by default unless the user explicitly asks to work in the current checkout or says they do not want worktrees.\n\nDo not use this tool for read-only tasks, code review, answering questions, continuing work already in the correct checkout, or when the user explicitly asks not to use worktrees. Prefer it over running `git worktree add` yourself: it creates the worktree under `.letta/worktrees/`, bases it on the latest default branch, and switches this conversation's working directory.\n\n- Pass `name` (and optionally `branch_name`/`base_ref`) to create a new worktree, or `path` to switch into an existing one under `.letta/worktrees/`, e.g. to resume work another conversation started. `path` is mutually exclusive with `name`, `branch_name` and `base_ref`.\n- If the current cwd is not inside the target git repository, pass `repo_path` instead of falling back to manual `git worktree` commands.\n- Uncommitted changes in the current checkout are not copied.\n- Creation fails when repository config (conditional includes, Git LFS transfer settings) prevents checkout filters and hooks from being disabled safely.\n- Switching into a worktree takes an advisory lock for this conversation. Entering one another active agent holds fails; if that agent is no longer active, retry with `force: true`.\n- Dependencies are not shared by default; install them with the repo's package manager. `symlink_dependencies: true` symlinks `node_modules` and similar from the primary checkout instead — use it only when the worktree will not change packages, and then do NOT run an install, because it writes through to the primary checkout.\n\nAfter success:\n- Continue using the returned worktree path as the current workspace, and confirm with `git status` before editing.\n- Root `AGENTS.md` instructions are loaded into the successful tool result when present. Follow them before running setup, build, or validation commands; read README or other setup docs for anything they do not cover.\n";
|
|
216180
216016
|
var init_EnterWorktree = () => {};
|
|
216181
216017
|
|
|
216182
216018
|
// src/tools/descriptions/ExecCommand.md
|
|
216183
|
-
var ExecCommand_default =
|
|
216184
|
-
var init_ExecCommand = () => {};
|
|
216185
|
-
|
|
216186
|
-
// src/tools/descriptions/ExitWorktree.md
|
|
216187
|
-
var ExitWorktree_default = `# ExitWorktree
|
|
216188
|
-
|
|
216189
|
-
Leave the git worktree this conversation is working in and return to the primary checkout, optionally deleting the worktree and its branch.
|
|
216190
|
-
|
|
216191
|
-
Use this tool only when the user asks to exit, leave, or go back from a worktree, or asks to clean one up when the work is done or abandoned. Do NOT call it proactively — finishing a task is not by itself a reason to leave the worktree.
|
|
216192
|
-
|
|
216193
|
-
## Scope
|
|
216019
|
+
var ExecCommand_default = `Runs a command in a PTY, returning output or a session ID for ongoing interaction.
|
|
216194
216020
|
|
|
216195
|
-
|
|
216021
|
+
For ordinary one-shot commands, omit \`yield_time_ms\` and let the default wait for completion; set \`yield_time_ms\` only when intentionally returning early from a long-running or interactive command.
|
|
216196
216022
|
|
|
216197
|
-
If
|
|
216023
|
+
If a command is still running when this tool yields, you will receive a notification when it completes. Do not poll the session just to check whether it has finished. Use \`write_stdin\` only when you need to send input, interrupt the process, or obtain output before you can continue.
|
|
216198
216024
|
|
|
216199
|
-
|
|
216200
|
-
|
|
216201
|
-
|
|
216202
|
-
|
|
216203
|
-
- \`"remove"\` — delete the worktree directory and its branch. Use for a clean exit when the work is merged, done, or abandoned.
|
|
216204
|
-
- \`discard_changes\` (optional, default \`false\`): only meaningful with \`action: "remove"\`. If the worktree has uncommitted changes or commits that are not in the base ref, removal is refused unless this is \`true\`. When the tool reports refused work, surface it to the user and get confirmation before re-running with \`discard_changes: true\`.
|
|
216205
|
-
|
|
216206
|
-
## Behavior
|
|
216207
|
-
|
|
216208
|
-
- Switches the conversation's working directory back to the primary checkout **before** touching the worktree, so removing it cannot strand the session (or a persistent shell) in a deleted directory.
|
|
216209
|
-
- Releases this conversation's cross-agent worktree lock, so another agent can take the worktree over. A lock held by a different conversation is left alone.
|
|
216210
|
-
- With \`action: "remove"\`, deletes the worktree and then its branch. If the branch cannot be deleted safely, the worktree removal still succeeds and the leftover branch is reported.
|
|
216211
|
-
- Returns to the primary checkout, not to whatever directory you happened to be in before entering — the primary checkout is the reliable destination across restarts and across worktree-to-worktree switches.
|
|
216212
|
-
|
|
216213
|
-
## After success
|
|
216025
|
+
Git commits: commit only when the user asks. Do not amend, skip hooks, force-push, or run other destructive git commands unless the user asks; if a pre-commit hook fails, fix the issue and create a new commit. Pass the message as a single-quoted string with embedded newlines; do not wrap it in \`$(...)\` or backticks. End commit messages with:
|
|
216026
|
+
{{COMMIT_TRAILER}}
|
|
216027
|
+
<example>
|
|
216028
|
+
git commit -m 'Commit message here.
|
|
216214
216029
|
|
|
216215
|
-
|
|
216216
|
-
|
|
216030
|
+
{{COMMIT_TRAILER}}'
|
|
216031
|
+
</example>
|
|
216217
216032
|
`;
|
|
216033
|
+
var init_ExecCommand = () => {};
|
|
216034
|
+
|
|
216035
|
+
// src/tools/descriptions/ExitWorktree.md
|
|
216036
|
+
var ExitWorktree_default = 'Leave the git worktree this conversation is working in and return to the primary checkout, optionally deleting the worktree and its branch.\n\nUse this tool only when the user asks to exit, leave, or go back from a worktree, or asks to clean one up when the work is done or abandoned. Do NOT call it proactively — finishing a task is not by itself a reason to leave the worktree.\n\nIt applies to the current worktree when it lives under `.letta/worktrees/`, whoever created it. Anywhere else it is a no-op.\n\n- `action: "keep"` leaves the worktree directory and branch intact; use it when the user may come back or the work is worth preserving. `action: "remove"` deletes the worktree and its branch.\n- `discard_changes` (default `false`): removal is refused when the worktree has uncommitted changes or commits not in the base ref. Surface refused work to the user and get confirmation before re-running with `discard_changes: true`.\n- The working directory returns to the primary checkout, and this conversation\'s worktree lock is released.\n\nAfter success, confirm the working directory with `git status` before editing further. If a branch was kept behind, tell the user its name so the work is not lost.\n';
|
|
216218
216037
|
var init_ExitWorktree = () => {};
|
|
216219
216038
|
|
|
216220
216039
|
// src/tools/descriptions/Glob.md
|
|
@@ -216272,28 +216091,11 @@ Do not use this tool for root memory files (already loaded) or skills/ (use Skil
|
|
|
216272
216091
|
var init_Memory = () => {};
|
|
216273
216092
|
|
|
216274
216093
|
// src/tools/descriptions/Monitor.md
|
|
216275
|
-
var Monitor_default = 'Start a background monitor that streams events from a long-running script. Each stdout line is an event — you keep working and notifications arrive in the chat. Events arrive on their own schedule and are not replies from the user, even if one lands while you\'re waiting for the user to answer a question.\n\
|
|
216094
|
+
var Monitor_default = 'Start a background monitor that streams events from a long-running script. Each stdout line is an event — you keep working and notifications arrive in the chat. Events arrive on their own schedule and are not replies from the user, even if one lands while you\'re waiting for the user to answer a question.\n\nUse Monitor when you need one notification per occurrence: indefinitely ("every time an ERROR line appears": `tail -f`, `inotifywait -m`, `while true`), or until a known end ("each CI step result, stop when the run completes": a command that emits lines and then exits). For a single notification ("tell me when the server is ready"), run a command that exits when the condition is true, e.g. `until grep -q "Ready" dev.log; do sleep 0.5; done`, in the background with your shell tool; you get one completion notification. An unbounded command used for a single notification stays armed until timeout, and `tail -f log | grep -m 1 ...` can hang the same way.\n\nFor open github.com pull requests, use WatchPR instead. It covers the whole PR surface and keeps watching after CI finishes. Use Monitor only when WatchPR does not apply.\n\n- Every pipe stage must flush per line or matches sit in its buffer unseen: `grep` needs `--line-buffered`, `awk` needs `fflush()`. `| head -N` delivers nothing until N matches accumulate.\n- In poll loops, handle transient failures (`curl ... || true`). Poll remote APIs every 30s+, local checks every 0.5–1s.\n- Only stdout is the event stream. Stderr goes to the output file named in the result, without notifications; merge it with `2>&1` for commands you run directly so failures reach your filter.\n- Every stdout line is a conversation message, so filter to the lines you\'d act on. Lines within 200ms are batched into one notification. Monitors that produce too many events are stopped automatically; restart with a tighter filter.\n\n**Coverage — silence is not success.** When watching a job for an outcome, your filter must match every terminal state, not just the happy path. A monitor that greps only for the success marker stays silent through a crashloop, a hung process, or an unexpected exit — and silence looks identical to "still running." Match failures too, e.g. `grep -E --line-buffered "elapsed_steps=|Traceback|Error|FAILED|Killed|OOM"`, and in poll loops emit on every terminal status (`succeeded|failed|cancelled|timeout`).\n\nExit ends the watch (exit code is reported). Timeout → killed. Set `persistent: true` for session-length watches (log tails, long-lived event streams). In managed Cloud sandboxes, every monitor, including persistent ones, stops after {{MONITOR_MAX_TIMEOUT}} (this sandbox\'s monitor cap); elsewhere persistent monitors run until TaskStop or session end. Call Monitor again to re-arm it if you still need to watch. For much longer Cloud waits, schedule a Wake or cron (which does not keep the sandbox running between turns) and combine it with shorter monitors. Use TaskStop to cancel early.\n\nWhen someone is waiting on the result, set `backup_after_seconds` (e.g. 900). If the monitor goes that long without an event, a durable Wake brings you back to check the real state, so a queued, hung, or dead watch can\'t leave them waiting in silence.\n\nInstead of `command`, `ws` streams each WebSocket text frame as an event (prefer it over `websocat`), and `script` runs a JavaScript watch loop with CodeMode\'s globals plus `emit(text)` and `sleep(ms)`; `decide()` spends money on every call, so call it only when an observed change needs judgment.\n';
|
|
216276
216095
|
var init_Monitor = () => {};
|
|
216277
216096
|
|
|
216278
216097
|
// src/tools/descriptions/Read.md
|
|
216279
|
-
var Read_default =
|
|
216280
|
-
|
|
216281
|
-
Reads a file from the local filesystem. You can access any file directly by using this tool.
|
|
216282
|
-
Assume this tool is able to read all files on the machine. If the User provides a path to a file assume that path is valid. It is okay to read a file that does not exist; an error will be returned.
|
|
216283
|
-
|
|
216284
|
-
Usage:
|
|
216285
|
-
- The file_path parameter must be an absolute path, not a relative path
|
|
216286
|
-
- \`file_path\` is literal: \`$VAR\`, \`$MEMORY_DIR\`, \`~\`, etc. are not expanded.
|
|
216287
|
-
- By default, it reads up to 2000 lines starting from the beginning of the file
|
|
216288
|
-
- You can optionally specify a line offset and limit (especially handy for long files), but it's recommended to read the whole file by not providing these parameters
|
|
216289
|
-
- Any lines longer than 2000 characters will be truncated
|
|
216290
|
-
- Results are returned using cat -n format, with line numbers starting at 1
|
|
216291
|
-
- This tool allows Letta Code to read images (eg PNG, JPG, etc). When reading an image file the contents are presented visually as Letta Code is a multimodal LLM.
|
|
216292
|
-
- This tool can only read files, not directories. To read a directory, use an ls command via the Bash tool.
|
|
216293
|
-
- You can call multiple tools in a single response. It is always better to speculatively read multiple potentially useful files in parallel.
|
|
216294
|
-
- You will regularly be asked to read screenshots. If the user provides a path to a screenshot, ALWAYS use this tool to view the file at the path. This tool will work with all temporary file paths.
|
|
216295
|
-
- If you read a file that exists but has empty contents you will receive a system reminder warning in place of file contents.
|
|
216296
|
-
`;
|
|
216098
|
+
var Read_default = "Reads a file from the local filesystem.\n\n- `file_path` must be an absolute path. It is literal: `$VAR`, `$MEMORY_DIR`, `~`, etc. are not expanded.\n- Reads up to 2000 lines by default; lines longer than 2000 characters are truncated.\n- When you already know which part of the file you need, only read that part with `offset` and `limit`. This can be important for larger files.\n- Results are returned using cat -n format, with line numbers starting at 1.\n- Reads images (PNG, JPG, …) and presents them visually.\n- Reading a directory or a missing file returns an error; an empty file returns a system reminder instead of content.\n";
|
|
216297
216099
|
var init_Read = () => {};
|
|
216298
216100
|
|
|
216299
216101
|
// src/tools/descriptions/ReadArtifactFile.md
|
|
@@ -216344,69 +216146,7 @@ This helps you catch type errors before making edits.
|
|
|
216344
216146
|
var init_ReadLSP = () => {};
|
|
216345
216147
|
|
|
216346
216148
|
// src/tools/descriptions/SendAgentMessage.md
|
|
216347
|
-
var SendAgentMessage_default =
|
|
216348
|
-
|
|
216349
|
-
Send a message without waiting for its answer. Letta-to-Letta messages require
|
|
216350
|
-
the Cloud backend and fail on the local backend (\`agent-local-\` IDs). Use this
|
|
216351
|
-
to coordinate with an agent already working, including an Agent child, or to
|
|
216352
|
-
contact any conversation you are authorized to access.
|
|
216353
|
-
|
|
216354
|
-
External coding workers return IDs backed by their native sessions. Use the
|
|
216355
|
-
receipt to distinguish steering from a new or queued follow-up. An idle follow-up
|
|
216356
|
-
starts one tracked local background turn. These messages do not use the Cloud
|
|
216357
|
-
messaging backend.
|
|
216358
|
-
Computer-qualified IDs returned by remote launches can be steered too.
|
|
216359
|
-
|
|
216360
|
-
An agent has a persistent identity and shared memory. It can have multiple
|
|
216361
|
-
conversations, each with its own message history.
|
|
216362
|
-
|
|
216363
|
-
- Supply \`conversation_id\` to message an existing thread, or \`agent_id\` alone to
|
|
216364
|
-
start a new hidden thread with that agent. To use an agent's default conversation,
|
|
216365
|
-
supply its \`agent_id\` and \`conversation_id: "default"\`. Pass the full
|
|
216366
|
-
conversation ID; truncated IDs are rejected.
|
|
216367
|
-
- Your agent and conversation IDs are attached automatically as the return address.
|
|
216368
|
-
To reply, the recipient must explicitly send to that address. Ordinary assistant
|
|
216369
|
-
output is not forwarded back to you.
|
|
216370
|
-
- A successful send means Cloud accepted the message; the recipient may not have
|
|
216371
|
-
read it yet. Continue working rather than waiting for the answer.
|
|
216372
|
-
- Omit \`computer\` unless a particular computer is needed. If the conversation is
|
|
216373
|
-
active on A, selecting B is rejected rather than moving the conversation.
|
|
216374
|
-
- If delivery cannot be confirmed, check the recipient's messages before resending
|
|
216375
|
-
to avoid duplicates. The tool result includes details for inspecting the send.
|
|
216376
|
-
- Keep sends sparse and useful: concise assignments, specific questions, or
|
|
216377
|
-
material updates. Skip status pings and repeated acknowledgments; repeat a
|
|
216378
|
-
point only when you have something new to add.
|
|
216379
|
-
- For work already underway, treat the agent doing it as its owner. Send what it
|
|
216380
|
-
needs, then let it decide. Do not take over or redo its work. If you think
|
|
216381
|
-
ownership should change, ask the human instead of declaring it in a message.
|
|
216382
|
-
|
|
216383
|
-
If you are a subagent, omitting both \`agent_id\` and \`conversation_id\` sends to
|
|
216384
|
-
your parent (the agent and conversation that launched you). Message your parent
|
|
216385
|
-
rarely: each message stays in both contexts, and your final report already
|
|
216386
|
-
reaches it. Send one only when a parent decision would otherwise force you to
|
|
216387
|
-
redo work, stating the default you will take, then keep working. Steering your
|
|
216388
|
-
own children (Agent, Claude Code, or Codex) is normal; message them as often as
|
|
216389
|
-
the work needs.
|
|
216390
|
-
|
|
216391
|
-
Use Agent to launch or resume a managed Letta child task and receive its
|
|
216392
|
-
completion notification. Letta-to-Letta sends create no local task ID. External
|
|
216393
|
-
coding-agent follow-ups may return one when they start a new native turn; an
|
|
216394
|
-
active external-agent steer remains part of the existing task. SendAgentMessage does not
|
|
216395
|
-
change the recipient's tools, model, or permissions.
|
|
216396
|
-
|
|
216397
|
-
On the local backend (\`agent-local-\` IDs), or from a script, send with the CLI
|
|
216398
|
-
instead. It waits for the recipient's turn and prints its final message as
|
|
216399
|
-
\`result\`, with the thread to continue in \`conversation_id\`:
|
|
216400
|
-
|
|
216401
|
-
\`\`\`bash
|
|
216402
|
-
letta -p --from-agent $LETTA_AGENT_ID --conversation <conversation-id> --output-format json "message"
|
|
216403
|
-
letta -p --from-agent $LETTA_AGENT_ID --agent <agent-id> --output-format json "message" # new thread
|
|
216404
|
-
\`\`\`
|
|
216405
|
-
|
|
216406
|
-
Add \`--backend local\` after \`letta\` when your agent ID starts with \`agent-local-\`.
|
|
216407
|
-
\`letta messages list --conversation <id> --limit 10\` reads a thread on either
|
|
216408
|
-
backend; \`letta -p --help\` and \`letta messages --help\` list the other options.
|
|
216409
|
-
`;
|
|
216149
|
+
var SendAgentMessage_default = 'Send a message without waiting for its answer. Use this to coordinate with an agent already working, including an Agent child, or to contact any conversation you are authorized to access. Letta-to-Letta messages require the Cloud backend and fail on the local backend (`agent-local-` IDs).\n\n- Supply `conversation_id` to message an existing thread, or `agent_id` alone to start a new hidden thread with that agent. To use an agent\'s default conversation, supply its `agent_id` and `conversation_id: "default"`. Pass the full conversation ID; truncated IDs are rejected.\n- Your agent and conversation IDs are attached automatically as the return address. To reply, the recipient must explicitly send to that address. Ordinary assistant output is not forwarded back to you.\n- A successful send means the message was accepted; the recipient may not have read it yet. Continue working rather than waiting for the answer.\n- External coding workers launched with Agent (including computer-qualified IDs from remote launches) can be messaged too. If the worker is mid-turn, the result says the message steered that turn; if it was idle, the result includes a `task_id` and you are notified when the new turn finishes.\n- Omit `computer` unless a particular computer is needed. If the conversation is active on A, selecting B is rejected rather than moving the conversation.\n- If delivery cannot be confirmed, check the recipient\'s messages before resending to avoid duplicates.\n- Keep sends sparse and useful: concise assignments, specific questions, or material updates. Skip status pings and repeated acknowledgments; repeat a point only when you have something new to add.\n- For work already underway, treat the agent doing it as its owner. Send what it needs, then let it decide. Do not take over or redo its work. If you think ownership should change, ask the human instead of declaring it in a message.\n\nIf you are a subagent, omitting both `agent_id` and `conversation_id` sends to your parent (the agent and conversation that launched you). Message your parent rarely: each message stays in both contexts, and your final report already reaches it. Send one only when a parent decision would otherwise force you to redo work, stating the default you will take, then keep working. Steering your own children is normal; message them as often as the work needs.\n\nOn the local backend, or from a script, use the CLI instead; it waits and prints the reply: `letta -p --from-agent $LETTA_AGENT_ID --conversation <conversation-id> --output-format json "message"` (add `--backend local` after `letta` for `agent-local-` IDs; `letta -p --help` lists options).\n';
|
|
216410
216150
|
var init_SendAgentMessage = () => {};
|
|
216411
216151
|
|
|
216412
216152
|
// src/tools/descriptions/SetWorkingDirectory.md
|
|
@@ -216421,172 +216161,43 @@ Use EnterWorktree instead when starting isolated feature or bug-fix work that sh
|
|
|
216421
216161
|
var init_SetWorkingDirectory = () => {};
|
|
216422
216162
|
|
|
216423
216163
|
// src/tools/descriptions/Skill.md
|
|
216424
|
-
var Skill_default =
|
|
216164
|
+
var Skill_default = "Invoke a skill.\n\nA skill is a packaged set of instructions the user or project has set up for a particular kind of task (deploy steps, a review checklist, a repo-specific workflow). Available skills are listed in your prompt context with one-line descriptions. When the task at hand is one a listed skill covers, call this tool first — the skill's instructions load into the turn for you to follow in place of your default approach. Users may also ask for one by name (`/<name>`, or \"slash command\"); that's a request to invoke it.\n\n- `skill`: exact name from the listing, no leading slash.\n\nOnly names from the listing (or that the user typed explicitly) are valid. Built-in CLI commands (`/help`, `/clear`, …) aren't skills. Do not invoke a skill that is already running. If a `<command-name>` block is already present this turn, the skill is loaded — follow it directly rather than calling again.\n";
|
|
216165
|
+
var init_Skill = () => {};
|
|
216425
216166
|
|
|
216426
|
-
|
|
216167
|
+
// src/tools/descriptions/Task.md
|
|
216168
|
+
var Task_default = `# Agent
|
|
216427
216169
|
|
|
216428
|
-
|
|
216170
|
+
Launch an agent in the background. You'll be notified when it finishes; the user does not see its result unless you relay it.
|
|
216429
216171
|
|
|
216430
|
-
|
|
216172
|
+
A fresh agent knows only what you put in the prompt, and you see only the summary it sends back. Do the work yourself when it is a handful of tool calls or a lookup whose target you already know; delegate independent work that can run in parallel, or reading across many files where you only need the conclusion. Once you've delegated something, don't also run it yourself; wait for the result. Never fabricate or predict a pending agent's result: if the user asks before the notification arrives, say it's still running.
|
|
216431
216173
|
|
|
216432
|
-
|
|
216433
|
-
- Use this tool with only the skill name
|
|
216434
|
-
- Examples:
|
|
216435
|
-
- \`skill: "pdf"\` - invoke the pdf skill
|
|
216436
|
-
- \`skill: "commit"\` - invoke the commit skill
|
|
216437
|
-
- \`skill: "review-pr"\` - invoke the review-pr skill
|
|
216438
|
-
- \`skill: "ms-office-suite:pdf"\` - invoke using fully qualified name
|
|
216174
|
+
To steer an agent that is still working, call SendAgentMessage with the receipt's \`Agent ID\`, plus its \`Conversation ID\` when the receipt has one. For external harnesses, the Agent ID is the native session ID with a harness prefix (e.g. \`claude_<session-id>\`), and sending to it resumes that session. Do not call Agent again for the same task.
|
|
216439
216175
|
|
|
216440
|
-
|
|
216441
|
-
-
|
|
216442
|
-
-
|
|
216443
|
-
-
|
|
216444
|
-
- Do not invoke a skill that is already running
|
|
216445
|
-
- Do not use this tool for built-in CLI commands (like /help, /clear, etc.)
|
|
216446
|
-
- If you see a <command-name> tag in the current conversation turn, the skill has ALREADY been loaded - follow the instructions directly instead of calling this tool again
|
|
216176
|
+
Progress and history:
|
|
216177
|
+
- \`Output file\`: readable progress log.
|
|
216178
|
+
- \`Event log\`: complete, untruncated JSONL record of tool calls, tool results, messages, and reasoning.
|
|
216179
|
+
- Letta agents: \`letta messages list --agent <agent_id> --conversation <conversation_id>\` reads the full conversation, including later turns.
|
|
216447
216180
|
`;
|
|
216448
|
-
var init_Skill = () => {};
|
|
216449
|
-
|
|
216450
|
-
// src/tools/descriptions/Task.md
|
|
216451
|
-
var Task_default = "# Agent\n\nLaunch an agent in the background. You'll be notified when it finishes; the user does not see its result unless you relay it.\n\nTo steer an agent that is still working, call SendAgentMessage with the receipt's `Agent ID`, plus its `Conversation ID` when the receipt has one. For external harnesses, the Agent ID is the native session ID with a harness prefix (e.g. `claude_<session-id>`), and sending to it resumes that session. Do not call Agent again for the same task.\n\nProgress and history:\n- `Output file`: readable progress log.\n- `Event log`: complete, untruncated JSONL record of tool calls, tool results, messages, and reasoning.\n- Letta agents: `letta messages list --agent <agent_id> --conversation <conversation_id>` reads the full conversation, including later turns.\n";
|
|
216452
216181
|
var init_Task = () => {};
|
|
216453
216182
|
|
|
216454
216183
|
// src/tools/descriptions/TaskCreate.md
|
|
216455
|
-
var TaskCreate_default =
|
|
216456
|
-
|
|
216457
|
-
Create a new task in the session task list.
|
|
216458
|
-
|
|
216459
|
-
Tasks help you track progress on complex, multi-step work and show the user what you're planning to do. Each task gets a stable ID you can reference from \`TaskGet\`, \`TaskList\`, and \`TaskUpdate\`.
|
|
216460
|
-
|
|
216461
|
-
## When to use this tool
|
|
216462
|
-
|
|
216463
|
-
Use TaskCreate proactively for:
|
|
216464
|
-
|
|
216465
|
-
1. **Complex multi-step tasks** — 3+ distinct steps or actions
|
|
216466
|
-
2. **Non-trivial tasks** — careful planning or multiple operations required
|
|
216467
|
-
3. **User provides multiple tasks** — numbered lists, comma-separated requests
|
|
216468
|
-
4. **New instructions arrive** — capture user requirements as tasks immediately
|
|
216469
|
-
5. **Starting work** — create the task, then \`TaskUpdate\` it to \`in_progress\`
|
|
216470
|
-
|
|
216471
|
-
## When NOT to use this tool
|
|
216472
|
-
|
|
216473
|
-
- Single, trivial task — just do it
|
|
216474
|
-
- Purely informational or conversational replies
|
|
216475
|
-
- Tasks that take fewer than 3 trivial steps
|
|
216476
|
-
|
|
216477
|
-
## Required fields
|
|
216478
|
-
|
|
216479
|
-
- \`subject\` — short imperative (e.g. "Run tests", "Fix auth bug")
|
|
216480
|
-
- \`description\` — full description with enough context to be actionable later
|
|
216481
|
-
|
|
216482
|
-
## Optional fields
|
|
216483
|
-
|
|
216484
|
-
- \`activeForm\` — present-continuous form shown during execution (e.g. "Running tests")
|
|
216485
|
-
- \`metadata\` — free-form \`{string: string}\` bag for ad-hoc annotations
|
|
216486
|
-
|
|
216487
|
-
## Example
|
|
216488
|
-
|
|
216489
|
-
\`\`\`
|
|
216490
|
-
TaskCreate({
|
|
216491
|
-
subject: "Add dark mode toggle",
|
|
216492
|
-
description: "Add a dark mode toggle to the Settings page. Wire it into the existing theme context and persist the preference to localStorage.",
|
|
216493
|
-
activeForm: "Adding dark mode toggle",
|
|
216494
|
-
metadata: { area: "ui", priority: "medium" }
|
|
216495
|
-
})
|
|
216496
|
-
\`\`\`
|
|
216497
|
-
|
|
216498
|
-
Returns the full task record including the assigned \`taskId\`.
|
|
216499
|
-
`;
|
|
216184
|
+
var TaskCreate_default = 'Create a new task in the session task list. Tasks track progress on multi-step work and show the user what you\'re planning; each gets a stable ID for `TaskGet`, `TaskList`, and `TaskUpdate`.\n\nUse it proactively for work with 3+ distinct steps, when the user gives several tasks, or when new requirements arrive. Skip it for single, trivial, or purely conversational work. When starting a task, `TaskUpdate` it to `in_progress`.\n\n- `subject`: short imperative (e.g. "Run tests").\n- `description`: enough context to be actionable later.\n- `activeForm` (optional): present-continuous form shown during execution (e.g. "Running tests").\n\nReturns the full task record including the assigned `taskId`.\n';
|
|
216500
216185
|
var init_TaskCreate = () => {};
|
|
216501
216186
|
|
|
216502
216187
|
// src/tools/descriptions/TaskGet.md
|
|
216503
|
-
var TaskGet_default =
|
|
216188
|
+
var TaskGet_default = "Fetch a single task by its `taskId`. Returns the full task record, including `subject`, `description`, `status`, `owner`, dependency edges (`blocks`, `blockedBy`), and `metadata`. Errors if the task ID doesn't exist or was deleted.\n";
|
|
216504
216189
|
var init_TaskGet = () => {};
|
|
216505
216190
|
|
|
216506
216191
|
// src/tools/descriptions/TaskList.md
|
|
216507
|
-
var TaskList_default = '
|
|
216192
|
+
var TaskList_default = 'List all tasks in the current session, in creation order. Deleted tasks are excluded.\n\nReturns `{ "tasks": [TaskRecord, ...] }`; each record includes `taskId`, `subject`, `description`, `activeForm`, `status`, `owner`, `blocks`, `blockedBy`, `metadata`, `createdAt`, `updatedAt`.\n';
|
|
216508
216193
|
var init_TaskList = () => {};
|
|
216509
216194
|
|
|
216510
216195
|
// src/tools/descriptions/TaskStop.md
|
|
216511
|
-
var TaskStop_default = "
|
|
216196
|
+
var TaskStop_default = "- Stops a running background task or monitor by its `task_id`\n- Returns `{ killed: boolean }` indicating whether the task was actively running and got terminated\n";
|
|
216512
216197
|
var init_TaskStop = () => {};
|
|
216513
216198
|
|
|
216514
216199
|
// src/tools/descriptions/TaskUpdate.md
|
|
216515
|
-
var TaskUpdate_default = `
|
|
216516
|
-
|
|
216517
|
-
## When to Use This Tool
|
|
216518
|
-
|
|
216519
|
-
**Mark tasks as resolved:**
|
|
216520
|
-
- When you have completed the work described in a task
|
|
216521
|
-
- When a task is no longer needed or has been superseded
|
|
216522
|
-
- IMPORTANT: Always mark your assigned tasks as resolved when you finish them
|
|
216523
|
-
- After resolving, call TaskList to find your next task
|
|
216524
|
-
|
|
216525
|
-
- ONLY mark a task as completed when you have FULLY accomplished it
|
|
216526
|
-
- If you encounter errors, blockers, or cannot finish, keep the task as in_progress
|
|
216527
|
-
- When blocked, create a new task describing what needs to be resolved
|
|
216528
|
-
- Never mark a task as completed if:
|
|
216529
|
-
- Tests are failing
|
|
216530
|
-
- Implementation is partial
|
|
216531
|
-
- You encountered unresolved errors
|
|
216532
|
-
- You couldn't find necessary files or dependencies
|
|
216533
|
-
|
|
216534
|
-
**Delete tasks:**
|
|
216535
|
-
- When a task is no longer relevant or was created in error
|
|
216536
|
-
- Setting status to \`deleted\` permanently removes the task
|
|
216537
|
-
|
|
216538
|
-
**Update task details:**
|
|
216539
|
-
- When requirements change or become clearer
|
|
216540
|
-
- When establishing dependencies between tasks
|
|
216541
|
-
|
|
216542
|
-
## Fields You Can Update
|
|
216543
|
-
|
|
216544
|
-
- **status**: The task status (see Status Workflow below)
|
|
216545
|
-
- **subject**: Change the task title (imperative form, e.g., "Run tests")
|
|
216546
|
-
- **description**: Change the task description
|
|
216547
|
-
- **activeForm**: Present continuous form shown in spinner when in_progress (e.g., "Running tests")
|
|
216548
|
-
- **owner**: Change the task owner (agent name)
|
|
216549
|
-
- **metadata**: Merge metadata keys into the task (set a key to null to delete it)
|
|
216550
|
-
- **addBlocks**: Mark tasks that cannot start until this one completes
|
|
216551
|
-
- **addBlockedBy**: Mark tasks that must complete before this one can start
|
|
216552
|
-
|
|
216553
|
-
## Status Workflow
|
|
216554
|
-
|
|
216555
|
-
Status progresses: \`pending\` → \`in_progress\` → \`completed\`
|
|
216556
|
-
|
|
216557
|
-
Use \`deleted\` to permanently remove a task.
|
|
216558
|
-
|
|
216559
|
-
## Staleness
|
|
216560
|
-
|
|
216561
|
-
Make sure to read a task's latest state using \`TaskGet\` before updating it.
|
|
216562
|
-
|
|
216563
|
-
## Examples
|
|
216564
|
-
|
|
216565
|
-
Mark task as in progress when starting work:
|
|
216566
|
-
\`\`\`json
|
|
216567
|
-
{"taskId": "1", "status": "in_progress"}
|
|
216568
|
-
\`\`\`
|
|
216569
|
-
|
|
216570
|
-
Mark task as completed after finishing work:
|
|
216571
|
-
\`\`\`json
|
|
216572
|
-
{"taskId": "1", "status": "completed"}
|
|
216573
|
-
\`\`\`
|
|
216574
|
-
|
|
216575
|
-
Delete a task:
|
|
216576
|
-
\`\`\`json
|
|
216577
|
-
{"taskId": "1", "status": "deleted"}
|
|
216578
|
-
\`\`\`
|
|
216579
|
-
|
|
216580
|
-
Claim a task by setting owner:
|
|
216581
|
-
\`\`\`json
|
|
216582
|
-
{"taskId": "1", "owner": "my-name"}
|
|
216583
|
-
\`\`\`
|
|
216584
|
-
|
|
216585
|
-
Set up task dependencies:
|
|
216586
|
-
\`\`\`json
|
|
216587
|
-
{"taskId": "2", "addBlockedBy": ["1"]}
|
|
216588
|
-
\`\`\`
|
|
216589
|
-
`;
|
|
216200
|
+
var TaskUpdate_default = 'Update a task in the task list. Read its latest state with `TaskGet` before updating.\n\n- Status moves `pending` → `in_progress` → `completed`; `deleted` permanently removes a task.\n- Mark a task completed only when it is fully done. If tests are failing, the implementation is partial, or you hit unresolved errors or blockers, keep it `in_progress` and create a new task describing what needs to be resolved.\n- Always mark your assigned tasks resolved when you finish them, then call TaskList to find your next task.\n- You can also change `subject`, `description`, `activeForm`, `owner`, merge `metadata` keys (null deletes a key), and add dependencies with `addBlocks` / `addBlockedBy`.\n\nExample: `{"taskId": "1", "status": "in_progress"}`\n';
|
|
216590
216201
|
var init_TaskUpdate = () => {};
|
|
216591
216202
|
|
|
216592
216203
|
// src/tools/descriptions/UpdatePlan.md
|
|
@@ -216603,7 +216214,7 @@ var ViewImage_default = `View a local image file from the filesystem when visual
|
|
|
216603
216214
|
var init_ViewImage = () => {};
|
|
216604
216215
|
|
|
216605
216216
|
// src/tools/descriptions/Wake.md
|
|
216606
|
-
var Wake_default = "Schedule a future turn for the current conversation. Wake is the durable, time-based counterpart to Monitor: use Monitor when ongoing work can emit an event, and Wake when you need to act at a future time even if nothing emits one.\n\nWake is always self-bound. It cannot target another agent, conversation, or computer.\n\n- `create`: provide `name`, `prompt`, and exactly one of `after_seconds`, `scheduled_at`, or `cron`.\n- `list`: list active and paused wakes for this conversation.\n- `cancel`: provide the `id` returned by create or list.\n\nWrite `prompt` as a note to your future self, not a script: what you are waiting on, what you planned and why, and what to check before acting. When the wake fires, the situation or people's wishes may have changed since you wrote it.\n\nUse `after_seconds` for ordinary follow-ups
|
|
216217
|
+
var Wake_default = "Schedule a future turn for the current conversation. Wake is the durable, time-based counterpart to Monitor: use Monitor when ongoing work can emit an event, and Wake when you need to act at a future time even if nothing emits one.\n\nWake is always self-bound. It cannot target another agent, conversation, or computer.\n\n- `create`: provide `name`, `prompt`, and exactly one of `after_seconds`, `scheduled_at`, or `cron`.\n- `list`: list active and paused wakes for this conversation.\n- `cancel`: provide the `id` returned by create or list.\n\nWrite `prompt` as a note to your future self, not a script: what you are waiting on, what you planned and why, and what to check before acting. When the wake fires, the situation or people's wishes may have changed since you wrote it.\n\nUse `after_seconds` for ordinary follow-ups. `scheduled_at` must be RFC 3339 with `Z` or an explicit UTC offset. `cron` is a recurring five-field UTC expression and cannot run more often than hourly. For calendar requests such as \"tomorrow at 9am,\" resolve the time in the user's timezone (inferred from context), pass an explicit offset, and state the timezone you used.\n\nWakes created in a managed Cloud sandbox survive sandbox shutdown; elsewhere they fire only while a listener is active, and the create result warns when none is. For schedules targeting other conversations or computers, load the `scheduling-tasks` skill.\n";
|
|
216607
216218
|
var init_Wake = () => {};
|
|
216608
216219
|
|
|
216609
216220
|
// src/tools/descriptions/WatchPR.md
|
|
@@ -216611,37 +216222,20 @@ var WatchPR_default = `Watch one open github.com pull request until it merges, c
|
|
|
216611
216222
|
|
|
216612
216223
|
In managed Cloud sandboxes, WatchPR also stops after {{MONITOR_MAX_TIMEOUT}} (this sandbox's monitor cap) and sends a timeout notification. Call WatchPR again to re-arm it if you still need to watch. For much longer waits, use Wake or cron (which does not keep the sandbox running between turns) and combine it with shorter watches. Local watches have no duration limit.
|
|
216613
216224
|
|
|
216614
|
-
Use WatchPR instead of writing a Monitor or shell polling loop when you need ongoing notifications about a PR. Start at most one watch per PR.
|
|
216225
|
+
Use WatchPR instead of writing a Monitor or shell polling loop when you need ongoing notifications about a PR: checks, comments, reviews, review threads, pushes, conflicts, merge state, merge, and close. Start at most one watch per PR.
|
|
216615
216226
|
|
|
216616
|
-
|
|
216617
|
-
- new or edited PR comments, submitted reviews, and inline review comments;
|
|
216618
|
-
- unresolved review-thread blockers and resolved, reopened, or outdated transitions;
|
|
216619
|
-
- head changes, draft changes, merge conflicts, and GitHub merge-state changes;
|
|
216620
|
-
- merge-ready regressions, merge-ready transitions, watcher errors, merge, and close.
|
|
216621
|
-
|
|
216622
|
-
The initial result includes current blockers and changes since the previous watch ended for the same agent, conversation, and PR, when a locally saved snapshot is at most seven days old. The first snapshot is never merge-ready: readiness requires a second consecutive read on the same head, so \`awaiting a second same-head readiness read\` is expected at startup. Later changes arrive as task notifications in this conversation. The watcher uses the locally authenticated \`gh\` CLI, polls every 30 seconds while GitHub is reachable, backs off after refresh errors, and keeps watching after checks become green because reviews, comments, conflicts, and new pushes can still arrive. Green checks are not the same as a mergeable PR, so report the PR as ready, green, or mergeable only once the watcher reports it merge-ready.
|
|
216227
|
+
The initial result includes current blockers and changes since the previous watch ended for the same agent, conversation, and PR, when a locally saved snapshot is at most seven days old. The first snapshot is never merge-ready: readiness requires a second consecutive read on the same head, so \`awaiting a second same-head readiness read\` is expected at startup. Later changes arrive as task notifications in this conversation. It uses the locally authenticated \`gh\` CLI and keeps watching after checks become green because reviews, comments, conflicts, and new pushes can still arrive. Green checks are not the same as a mergeable PR, so report the PR as ready, green, or mergeable only once the watcher reports it merge-ready.
|
|
216623
216228
|
|
|
216624
216229
|
Pass a URL ending at the PR number, such as \`https://github.com/owner/repo/pull/123\`. Remove \`/files\`, \`/commits\`, \`/checks\`, and other suffixes. The watcher is read-only and errors if the PR is already merged or closed.
|
|
216625
216230
|
`;
|
|
216626
216231
|
var init_WatchPR = () => {};
|
|
216627
216232
|
|
|
216628
216233
|
// src/tools/descriptions/Workflow.md
|
|
216629
|
-
var Workflow_default = "Execute a workflow script that orchestrates multiple subagents deterministically (loops, conditionals, fan-out) rather than model-driven.\n\nWorkflows run in the background: this tool returns immediately with a task ID, and a <task-notification> carrying the script's return value arrives when the workflow completes. Do not poll or sleep for it, and never fabricate the result before it arrives. TaskStop aborts the run. With `wait: true`, the workflow runs in the foreground instead and this tool returns the script's value directly.\n\nScripts that call `agent()` or `decide()` spend money on subagents and model calls. Run one only when the user explicitly asked for a workflow or multi-agent orchestration (\"use a workflow\", \"fan out agents\") or a skill's instructions call this tool; otherwise describe the workflow and ask first. For scripts that only call tools, use CodeMode instead.\n\nScripts can call tools directly: `await tools.<name>(args)` for this turn's built-in tools and `await tools.mcp__server__tool(args)` for the agent's MCP tools, subject to the user's permission rules. `await listTools()` returns `[{ name, description }]`; `await describeTool(name)` returns `{ name, description, inputSchema }`, or `undefined` for an unknown tool.\n\nScripts are plain JavaScript and must begin with `export const meta = {...}`, a pure literal (no variables, calls, or interpolation). Pass the work list via `args`. `process.env` holds the variables a
|
|
216234
|
+
var Workflow_default = "Execute a workflow script that orchestrates multiple subagents deterministically (loops, conditionals, fan-out) rather than model-driven.\n\nWorkflows run in the background: this tool returns immediately with a task ID, and a <task-notification> carrying the script's return value arrives when the workflow completes. Do not poll or sleep for it, and never fabricate the result before it arrives. TaskStop aborts the run. With `wait: true`, the workflow runs in the foreground instead and this tool returns the script's value directly.\n\nScripts that call `agent()` or `decide()` spend money on subagents and model calls. Run one only when the user explicitly asked for a workflow or multi-agent orchestration (\"use a workflow\", \"fan out agents\") or a skill's instructions call this tool; otherwise describe the workflow and ask first. For scripts that only call tools, use CodeMode instead.\n\nScripts can call tools directly: `await tools.<name>(args)` for this turn's built-in tools and `await tools.mcp__server__tool(args)` for the agent's MCP tools, subject to the user's permission rules. `await listTools()` returns `[{ name, description }]`; `await describeTool(name)` returns `{ name, description, inputSchema }`, or `undefined` for an unknown tool.\n\nScripts are plain JavaScript and must begin with `export const meta = {...}`, a pure literal (no variables, calls, or interpolation). Pass the work list via `args`. `process.env` holds the variables a shell command sees plus the agent's secrets. Prefer `pipeline()` so each item moves to its next stage as soon as it is ready. Await `agent()` calls: failures reject with the cause, `callIndex`, and `conversationId` when available. `parallel()` and `pipeline()` let siblings finish, then reject if any callback failed; a failed pipeline item skips its remaining stages. Catch errors explicitly inside callbacks for best-effort processing.\n\nBefore authoring a script, load the `workflow-authoring` skill — the script API, pipeline-vs-barrier rules, quality patterns, worked examples, and how to diagnose a run.\n";
|
|
216630
216235
|
var init_Workflow = () => {};
|
|
216631
216236
|
|
|
216632
216237
|
// src/tools/descriptions/Write.md
|
|
216633
|
-
var Write_default =
|
|
216634
|
-
|
|
216635
|
-
Writes a file to the local filesystem.
|
|
216636
|
-
|
|
216637
|
-
Usage:
|
|
216638
|
-
- This tool will overwrite the existing file if there is one at the provided path.
|
|
216639
|
-
- If this is an existing file, you MUST use the Read tool first to read the file's contents. This tool will fail if you did not read the file first. Exception: memory files whose contents are already present in your system prompt do not require a Read call first. For memory files, pass an expanded absolute path (use Bash to resolve \`$MEMORY_DIR\` first if needed).
|
|
216640
|
-
- \`file_path\` is literal: \`$VAR\`, \`$MEMORY_DIR\`, \`~\`, etc. are not expanded.
|
|
216641
|
-
- ALWAYS prefer editing existing files in the codebase. NEVER write new files unless explicitly required.
|
|
216642
|
-
- NEVER proactively create documentation files (*.md) or README files. Only create documentation files if explicitly requested by the User.
|
|
216643
|
-
- Only use emojis if the user explicitly requests it. Avoid writing emojis to files unless asked.
|
|
216644
|
-
`;
|
|
216238
|
+
var Write_default = "Writes a file to the local filesystem, overwriting if one exists.\n\nWhen to use: creating a new file, or fully replacing one you've already Read. For partial changes, use Edit instead.\n\n- Exception: memory files whose contents are already present in your system prompt do not require a Read call first. For memory files, pass an expanded absolute path.\n- `file_path` is literal: `$VAR`, `$MEMORY_DIR`, `~`, etc. are not expanded.\n";
|
|
216645
216239
|
var init_Write = () => {};
|
|
216646
216240
|
|
|
216647
216241
|
// src/tools/descriptions/WriteArtifactFile.md
|
|
@@ -216649,7 +216243,7 @@ var WriteArtifactFile_default = "Write a file under the Letta Code Desktop artif
|
|
|
216649
216243
|
var init_WriteArtifactFile = () => {};
|
|
216650
216244
|
|
|
216651
216245
|
// src/tools/descriptions/WriteStdin.md
|
|
216652
|
-
var WriteStdin_default = "Writes characters to an existing unified exec session and returns recent output.\n\
|
|
216246
|
+
var WriteStdin_default = "Writes characters to an existing unified exec session and returns recent output.\n\nDo not call it with empty `chars` merely to wait for completion; `exec_command` sends a notification when a yielded process completes. If the process needs a completion deadline, create a one-shot Wake instead of blocking or polling.\n";
|
|
216653
216247
|
var init_WriteStdin = () => {};
|
|
216654
216248
|
|
|
216655
216249
|
// src/utils/text-files.ts
|
|
@@ -232861,19 +232455,10 @@ function filterMemoryToolByMemoryFormat(registry4, agentId) {
|
|
|
232861
232455
|
function filterExternalToolsByRuntimeContext(externalTools, runtimeContext) {
|
|
232862
232456
|
return new Map(Array.from(externalTools.entries()).filter(([, tool]) => {
|
|
232863
232457
|
const matchesRuntime = !tool.runtime || (tool.runtime.agentId ?? null) === (runtimeContext.agentId ?? null) && tool.runtime.conversationId === runtimeContext.conversationId;
|
|
232864
|
-
const matchesConnection = tool.connectionId === undefined || tool.connectionId === runtimeContext.connectionId || tool.runtime !== undefined
|
|
232458
|
+
const matchesConnection = tool.connectionId === undefined || tool.connectionId === runtimeContext.connectionId || tool.runtime !== undefined;
|
|
232865
232459
|
return matchesRuntime && matchesConnection;
|
|
232866
232460
|
}));
|
|
232867
232461
|
}
|
|
232868
|
-
function filterExternalToolsByScopeIds(externalTools, externalToolScopeIds) {
|
|
232869
|
-
const selectedScopes = new Set(externalToolScopeIds ?? []);
|
|
232870
|
-
return new Map(Array.from(externalTools.entries()).filter(([, tool]) => {
|
|
232871
|
-
if (tool.scopeId === undefined) {
|
|
232872
|
-
return true;
|
|
232873
|
-
}
|
|
232874
|
-
return selectedScopes.has(tool.scopeId);
|
|
232875
|
-
}));
|
|
232876
|
-
}
|
|
232877
232462
|
function filterModToolsByClientAllowlist(modTools, clientToolAllowlist) {
|
|
232878
232463
|
if (clientToolAllowlist === undefined) {
|
|
232879
232464
|
return new Map(modTools);
|
|
@@ -233085,7 +232670,7 @@ function capturePreparedToolExecutionContext(snapshot, options) {
|
|
|
233085
232670
|
const toolRegistrySnapshot = filterMemoryToolByMemoryFormat(applySubagentToolPolicy(filterToolRegistryByClientAllowlist(snapshot.toolRegistry, clientToolAllowlist), readSubagentDepth(getRuntimeExecutionEnv(process.env, runtimeContext.executionSettings))), runtimeContext.agentId);
|
|
233086
232671
|
const executionSnapshot = {
|
|
233087
232672
|
toolRegistry: toolRegistrySnapshot,
|
|
233088
|
-
externalTools: selectModelFacingExternalTools(filterExternalToolsByClientAllowlist(
|
|
232673
|
+
externalTools: selectModelFacingExternalTools(filterExternalToolsByClientAllowlist(filterExternalToolsByRuntimeContext(snapshot.externalTools, runtimeContext), clientToolAllowlist), options?.externalToolOwnerConnectionId ?? runtimeContext.connectionId),
|
|
233089
232674
|
externalExecutor: snapshot.externalExecutor,
|
|
233090
232675
|
modContext: options?.modContext ?? snapshot.modContext,
|
|
233091
232676
|
modEvents: options?.modEvents ?? snapshot.modEvents,
|
|
@@ -248057,7 +247642,7 @@ class CodexAppServerClient {
|
|
|
248057
247642
|
await this.request("initialize", {
|
|
248058
247643
|
clientInfo: {
|
|
248059
247644
|
name: "letta-code",
|
|
248060
|
-
version: "0.34.
|
|
247645
|
+
version: "0.34.46"
|
|
248061
247646
|
},
|
|
248062
247647
|
capabilities: null
|
|
248063
247648
|
});
|
|
@@ -252721,7 +252306,7 @@ async function fetchParentConversationMessages(params) {
|
|
|
252721
252306
|
}
|
|
252722
252307
|
return messages;
|
|
252723
252308
|
}
|
|
252724
|
-
function
|
|
252309
|
+
function contentText3(content) {
|
|
252725
252310
|
if (typeof content === "string")
|
|
252726
252311
|
return content;
|
|
252727
252312
|
if (!Array.isArray(content))
|
|
@@ -252747,7 +252332,7 @@ function renderToolCall(call2) {
|
|
|
252747
252332
|
}
|
|
252748
252333
|
function renderToolResult(result3) {
|
|
252749
252334
|
const raw2 = result3.tool_return ?? result3.func_response;
|
|
252750
|
-
const text2 = typeof raw2 === "string" ? raw2 :
|
|
252335
|
+
const text2 = typeof raw2 === "string" ? raw2 : contentText3(raw2) || (raw2 == null ? "" : JSON.stringify(raw2));
|
|
252751
252336
|
return {
|
|
252752
252337
|
type: "tool_result",
|
|
252753
252338
|
call_id: result3.tool_call_id ?? undefined,
|
|
@@ -252783,11 +252368,11 @@ function userEvents(text2, speaker) {
|
|
|
252783
252368
|
function renderMessage(message2) {
|
|
252784
252369
|
switch (message2.message_type) {
|
|
252785
252370
|
case "user_message": {
|
|
252786
|
-
const text2 =
|
|
252371
|
+
const text2 = contentText3(message2.content).replace(SYSTEM_REMINDER_PATTERN, "").trim();
|
|
252787
252372
|
return userEvents(text2, message2.name ?? undefined);
|
|
252788
252373
|
}
|
|
252789
252374
|
case "assistant_message": {
|
|
252790
|
-
const text2 =
|
|
252375
|
+
const text2 = contentText3(message2.content).trim();
|
|
252791
252376
|
return text2 ? [
|
|
252792
252377
|
{
|
|
252793
252378
|
type: "message",
|
|
@@ -264919,7 +264504,8 @@ function scheduleDurableQueueRestore(listener, capacityReleased = true) {
|
|
|
264919
264504
|
function queueRemovalTransition(item, disposition) {
|
|
264920
264505
|
return {
|
|
264921
264506
|
client_message_id: item.clientMessageId ?? `cm-${item.id}`,
|
|
264922
|
-
disposition
|
|
264507
|
+
disposition,
|
|
264508
|
+
source: item.source
|
|
264923
264509
|
};
|
|
264924
264510
|
}
|
|
264925
264511
|
function ensureConversationQueueRuntime(listener, runtime) {
|
|
@@ -270327,8 +269913,6 @@ function getInputToolSelectionError(payload) {
|
|
|
270327
269913
|
return "Protocol violation: client_preferences must contain only an optional toolset with include: known bundled tool names[]";
|
|
270328
269914
|
if (payload.exclude_interactive_tools !== undefined && typeof payload.exclude_interactive_tools !== "boolean")
|
|
270329
269915
|
return "Protocol violation: input.payload.exclude_interactive_tools must be boolean";
|
|
270330
|
-
if (payload.external_tool_scope_ids !== undefined && !isStringArray8(payload.external_tool_scope_ids))
|
|
270331
|
-
return "Protocol violation: input.payload.external_tool_scope_ids must be string[]";
|
|
270332
269916
|
return null;
|
|
270333
269917
|
}
|
|
270334
269918
|
var init_input_tool_selection = __esm(async () => {
|
|
@@ -270390,10 +269974,19 @@ function isExternalToolDefinitionPayload(value) {
|
|
|
270390
269974
|
return false;
|
|
270391
269975
|
return typeof value.name === "string" && (value.label === undefined || typeof value.label === "string") && typeof value.description === "string" && isRecord13(value.parameters) && (value.auto_background === undefined || typeof value.auto_background === "boolean") && (value.timeout_ms === undefined || typeof value.timeout_ms === "number" && Number.isSafeInteger(value.timeout_ms) && value.timeout_ms >= 1000 && value.timeout_ms <= 300000);
|
|
270392
269976
|
}
|
|
269977
|
+
function isStringList(value) {
|
|
269978
|
+
return Array.isArray(value) && value.every((entry) => typeof entry === "string");
|
|
269979
|
+
}
|
|
270393
269980
|
function isRuntimeStartExternalToolsGroup(value) {
|
|
270394
269981
|
if (!isRecord13(value))
|
|
270395
269982
|
return false;
|
|
270396
|
-
return
|
|
269983
|
+
return Array.isArray(value.tools) && value.tools.every(isExternalToolDefinitionPayload);
|
|
269984
|
+
}
|
|
269985
|
+
function isRuntimeToolPolicy(value) {
|
|
269986
|
+
if (!isRecord13(value))
|
|
269987
|
+
return false;
|
|
269988
|
+
const toolset = value.toolset;
|
|
269989
|
+
return (toolset === undefined || isRecord13(toolset) && (toolset.base === undefined || isToolsetPreference(toolset.base)) && (toolset.include === undefined || isStringList(toolset.include))) && (value.allowlist === undefined || isStringList(value.allowlist)) && (value.exclude_interactive === undefined || typeof value.exclude_interactive === "boolean");
|
|
270397
269990
|
}
|
|
270398
269991
|
function isRuntimeExternalToolsUpdateCommand(value) {
|
|
270399
269992
|
if (!isRecord13(value))
|
|
@@ -270403,7 +269996,7 @@ function isRuntimeExternalToolsUpdateCommand(value) {
|
|
|
270403
269996
|
}
|
|
270404
269997
|
const runtimeKeys = new Set;
|
|
270405
269998
|
for (const update3 of value.updates) {
|
|
270406
|
-
if (!isRecord13(update3) || !Array.isArray(update3.runtimes) || update3.runtimes.length === 0 || !update3.runtimes.every(isRuntimeScope2) || !Array.isArray(update3.external_tools) || !update3.external_tools.every(isRuntimeStartExternalToolsGroup)) {
|
|
269999
|
+
if (!isRecord13(update3) || !Array.isArray(update3.runtimes) || update3.runtimes.length === 0 || !update3.runtimes.every(isRuntimeScope2) || !Array.isArray(update3.external_tools) || !update3.external_tools.every(isRuntimeStartExternalToolsGroup) || update3.tool_policy !== undefined && !isRuntimeToolPolicy(update3.tool_policy)) {
|
|
270407
270000
|
return false;
|
|
270408
270001
|
}
|
|
270409
270002
|
for (const runtime of update3.runtimes) {
|
|
@@ -270431,6 +270024,9 @@ function isExternalToolCallResponseCommand(value) {
|
|
|
270431
270024
|
return false;
|
|
270432
270025
|
return Array.isArray(value.result.content) && value.result.content.every(isRecord13) && (value.result.is_error === undefined || typeof value.result.is_error === "boolean");
|
|
270433
270026
|
}
|
|
270027
|
+
var init_external_tool_protocol = __esm(() => {
|
|
270028
|
+
init_toolset_catalog();
|
|
270029
|
+
});
|
|
270434
270030
|
|
|
270435
270031
|
// src/websocket/listener/runtime-start-validation.ts
|
|
270436
270032
|
function isDevicePermissionMode(value) {
|
|
@@ -270440,7 +270036,7 @@ function isRuntimeStartCommand(value) {
|
|
|
270440
270036
|
if (!value || typeof value !== "object")
|
|
270441
270037
|
return false;
|
|
270442
270038
|
const c = value;
|
|
270443
|
-
return c.type === "runtime_start" && typeof c.request_id === "string" && (c.agent_id === undefined || typeof c.agent_id === "string") && (c.create_agent === undefined || isRuntimeStartCreateAgentOptions(c.create_agent)) && (c.conversation_id === undefined || typeof c.conversation_id === "string") && (c.create_conversation === undefined || isRuntimeStartCreateConversationOptions(c.create_conversation)) && (c.conversation_source_tags === undefined || isStringArray8(c.conversation_source_tags)) && (c.cwd === undefined || c.cwd === null || typeof c.cwd === "string") && (c.mode === undefined || isDevicePermissionMode(c.mode)) && (c.mode_is_default === undefined || typeof c.mode_is_default === "boolean") && (c.execution_settings === undefined || isRuntimeExecutionSettings(c.execution_settings)) && (c.workspace_sandbox === undefined || isRuntimeStartWorkspaceSandbox(c.workspace_sandbox)) && (c.skill_sources === undefined || isSkillSourceArray(c.skill_sources)) && (c.preserve_skill_sources === undefined || typeof c.preserve_skill_sources === "boolean") && (c.bundled_skills === undefined || isStringArray8(c.bundled_skills)) && (c.client_info === undefined || isRuntimeStartClientInfo(c.client_info)) && (c.recover_approvals === undefined || typeof c.recover_approvals === "boolean") && (c.force_device_status === undefined || typeof c.force_device_status === "boolean") && (c.wait_for_replay === undefined || typeof c.wait_for_replay === "boolean") && (c.teleport_id === undefined || typeof c.teleport_id === "string") && (c.external_tools === undefined || Array.isArray(c.external_tools) && c.external_tools.every(isRuntimeStartExternalToolsGroup));
|
|
270039
|
+
return c.type === "runtime_start" && typeof c.request_id === "string" && (c.agent_id === undefined || typeof c.agent_id === "string") && (c.create_agent === undefined || isRuntimeStartCreateAgentOptions(c.create_agent)) && (c.conversation_id === undefined || typeof c.conversation_id === "string") && (c.create_conversation === undefined || isRuntimeStartCreateConversationOptions(c.create_conversation)) && (c.conversation_source_tags === undefined || isStringArray8(c.conversation_source_tags)) && (c.cwd === undefined || c.cwd === null || typeof c.cwd === "string") && (c.mode === undefined || isDevicePermissionMode(c.mode)) && (c.mode_is_default === undefined || typeof c.mode_is_default === "boolean") && (c.execution_settings === undefined || isRuntimeExecutionSettings(c.execution_settings)) && (c.workspace_sandbox === undefined || isRuntimeStartWorkspaceSandbox(c.workspace_sandbox)) && (c.skill_sources === undefined || isSkillSourceArray(c.skill_sources)) && (c.preserve_skill_sources === undefined || typeof c.preserve_skill_sources === "boolean") && (c.bundled_skills === undefined || isStringArray8(c.bundled_skills)) && (c.client_info === undefined || isRuntimeStartClientInfo(c.client_info)) && (c.recover_approvals === undefined || typeof c.recover_approvals === "boolean") && (c.force_device_status === undefined || typeof c.force_device_status === "boolean") && (c.wait_for_replay === undefined || typeof c.wait_for_replay === "boolean") && (c.teleport_id === undefined || typeof c.teleport_id === "string") && (c.external_tools === undefined || Array.isArray(c.external_tools) && c.external_tools.every(isRuntimeStartExternalToolsGroup)) && (c.tool_policy === undefined || isRuntimeToolPolicy(c.tool_policy));
|
|
270444
270040
|
}
|
|
270445
270041
|
function isRuntimeStartCreateAgentOptions(value) {
|
|
270446
270042
|
if (!isObjectRecord(value))
|
|
@@ -270465,6 +270061,7 @@ function isRuntimeStartWorkspaceSandbox(value) {
|
|
|
270465
270061
|
var init_runtime_start_validation = __esm(() => {
|
|
270466
270062
|
init_skill_sources();
|
|
270467
270063
|
init_runtime_execution_settings();
|
|
270064
|
+
init_external_tool_protocol();
|
|
270468
270065
|
});
|
|
270469
270066
|
|
|
270470
270067
|
// src/websocket/listener/turn-finished-protocol-inbound.ts
|
|
@@ -270663,8 +270260,7 @@ function legacyEnvironmentMessageToInputCommand(value) {
|
|
|
270663
270260
|
kind: "create_message",
|
|
270664
270261
|
messages: candidate.messages,
|
|
270665
270262
|
client_tool_allowlist: isStringArray8(candidate.clientToolAllowlist) ? candidate.clientToolAllowlist : undefined,
|
|
270666
|
-
client_toolset: isClientToolsetConfig(candidate.clientToolset) ? candidate.clientToolset : undefined
|
|
270667
|
-
external_tool_scope_ids: isStringArray8(candidate.externalToolScopeIds) ? candidate.externalToolScopeIds : undefined
|
|
270263
|
+
client_toolset: isClientToolsetConfig(candidate.clientToolset) ? candidate.clientToolset : undefined
|
|
270668
270264
|
}
|
|
270669
270265
|
};
|
|
270670
270266
|
}
|
|
@@ -271314,6 +270910,7 @@ var init_protocol_inbound = __esm(async () => {
|
|
|
271314
270910
|
init_queue_pause_protocol_inbound();
|
|
271315
270911
|
init_connect_provider_protocol_inbound();
|
|
271316
270912
|
init_connect_provider_protocol_inbound();
|
|
270913
|
+
init_external_tool_protocol();
|
|
271317
270914
|
init_runtime_start_validation();
|
|
271318
270915
|
init_turn_finished_protocol_inbound();
|
|
271319
270916
|
init_subagent_protocol_inbound();
|
|
@@ -273142,6 +272739,40 @@ var init_remote_model_catalog = __esm(() => {
|
|
|
273142
272739
|
REFRESH_TTL_MS = 5 * 60 * 1000;
|
|
273143
272740
|
});
|
|
273144
272741
|
|
|
272742
|
+
// src/tools/tool-policy.ts
|
|
272743
|
+
function intersectToolAllowlists(ceiling, narrower) {
|
|
272744
|
+
return narrower.filter((name) => ceiling.some((allowed) => getInternalToolName(allowed) === getInternalToolName(name)));
|
|
272745
|
+
}
|
|
272746
|
+
function resolveTurnToolSelection(turn, policy) {
|
|
272747
|
+
const base2 = turn.clientToolset?.base ?? policy?.toolset?.base;
|
|
272748
|
+
const include = turn.clientToolset?.include ?? policy?.toolset?.include;
|
|
272749
|
+
const clientToolset = base2 === undefined && include === undefined ? undefined : {
|
|
272750
|
+
...base2 !== undefined ? { base: base2 } : {},
|
|
272751
|
+
...include !== undefined ? { include: [...include] } : {}
|
|
272752
|
+
};
|
|
272753
|
+
const policyAllowlist = policy?.allowlist;
|
|
272754
|
+
const clientToolAllowlist = policyAllowlist === undefined ? turn.clientToolAllowlist : turn.clientToolAllowlist === undefined ? [...policyAllowlist] : intersectToolAllowlists(policyAllowlist, turn.clientToolAllowlist);
|
|
272755
|
+
const excludeInteractiveTools = turn.excludeInteractiveTools ?? policy?.exclude_interactive;
|
|
272756
|
+
return {
|
|
272757
|
+
...clientToolset ? { clientToolset } : {},
|
|
272758
|
+
...clientToolAllowlist !== undefined ? { clientToolAllowlist } : {},
|
|
272759
|
+
...excludeInteractiveTools !== undefined ? { excludeInteractiveTools } : {}
|
|
272760
|
+
};
|
|
272761
|
+
}
|
|
272762
|
+
function mergeClientToolsetFields(primary, fallback) {
|
|
272763
|
+
const base2 = primary?.base ?? fallback?.base;
|
|
272764
|
+
const include = primary?.include ?? fallback?.include;
|
|
272765
|
+
if (base2 === undefined && include === undefined)
|
|
272766
|
+
return;
|
|
272767
|
+
return {
|
|
272768
|
+
...base2 !== undefined ? { base: base2 } : {},
|
|
272769
|
+
...include !== undefined ? { include } : {}
|
|
272770
|
+
};
|
|
272771
|
+
}
|
|
272772
|
+
var init_tool_policy = __esm(() => {
|
|
272773
|
+
init_tool_name_mapping();
|
|
272774
|
+
});
|
|
272775
|
+
|
|
273145
272776
|
// src/tools/toolset.ts
|
|
273146
272777
|
var exports_toolset = {};
|
|
273147
272778
|
__export(exports_toolset, {
|
|
@@ -273237,7 +272868,7 @@ async function prepareToolExecutionContextForResolvedTarget(params) {
|
|
|
273237
272868
|
clientToolset,
|
|
273238
272869
|
exclude: exclude3,
|
|
273239
272870
|
clientToolAllowlist: inputToolAllowlist,
|
|
273240
|
-
|
|
272871
|
+
externalToolOwnerConnectionId,
|
|
273241
272872
|
workingDirectory,
|
|
273242
272873
|
permissionModeState,
|
|
273243
272874
|
modContext,
|
|
@@ -273269,7 +272900,7 @@ async function prepareToolExecutionContextForResolvedTarget(params) {
|
|
|
273269
272900
|
exclude: exclude3,
|
|
273270
272901
|
include: includedToolNames,
|
|
273271
272902
|
clientToolAllowlist,
|
|
273272
|
-
|
|
272903
|
+
externalToolOwnerConnectionId,
|
|
273273
272904
|
workingDirectory,
|
|
273274
272905
|
permissionModeState,
|
|
273275
272906
|
modContext: scopedModContext,
|
|
@@ -273302,7 +272933,7 @@ async function prepareToolExecutionContextForScope(params) {
|
|
|
273302
272933
|
exclude: exclude3,
|
|
273303
272934
|
clientToolset: requestClientToolset,
|
|
273304
272935
|
clientToolAllowlist,
|
|
273305
|
-
|
|
272936
|
+
externalToolOwnerConnectionId,
|
|
273306
272937
|
workingDirectory,
|
|
273307
272938
|
permissionModeState,
|
|
273308
272939
|
skillsDirectory,
|
|
@@ -273315,7 +272946,7 @@ async function prepareToolExecutionContextForScope(params) {
|
|
|
273315
272946
|
modEvents,
|
|
273316
272947
|
modAdapters
|
|
273317
272948
|
} = params;
|
|
273318
|
-
const clientToolset = requestClientToolset
|
|
272949
|
+
const clientToolset = mergeClientToolsetFields(requestClientToolset, getStoredClientPreferences(agentId, conversationId).toolset);
|
|
273319
272950
|
const backend3 = getBackend();
|
|
273320
272951
|
const agent = agentId ? cachedAgent ?? await backend3.retrieveAgent(agentId) : null;
|
|
273321
272952
|
const agentTarget = modelTargetFromCarrier(agent);
|
|
@@ -273349,7 +272980,7 @@ async function prepareToolExecutionContextForScope(params) {
|
|
|
273349
272980
|
clientToolset,
|
|
273350
272981
|
exclude: exclude3,
|
|
273351
272982
|
clientToolAllowlist,
|
|
273352
|
-
|
|
272983
|
+
externalToolOwnerConnectionId,
|
|
273353
272984
|
workingDirectory,
|
|
273354
272985
|
permissionModeState,
|
|
273355
272986
|
modContext,
|
|
@@ -273417,6 +273048,7 @@ var init_toolset = __esm(async () => {
|
|
|
273417
273048
|
init_context2();
|
|
273418
273049
|
init_settings_manager();
|
|
273419
273050
|
init_removed_tools();
|
|
273051
|
+
init_tool_policy();
|
|
273420
273052
|
await __promiseAll([
|
|
273421
273053
|
init_client_preferences(),
|
|
273422
273054
|
init_manager2(),
|
|
@@ -445620,6 +445252,14 @@ function getRegisteredTools(runtime) {
|
|
|
445620
445252
|
}
|
|
445621
445253
|
return registeredTools;
|
|
445622
445254
|
}
|
|
445255
|
+
function getLastSubmittingConnections(runtime) {
|
|
445256
|
+
let connections = lastSubmittingConnectionByRuntime.get(runtime);
|
|
445257
|
+
if (!connections) {
|
|
445258
|
+
connections = new Map;
|
|
445259
|
+
lastSubmittingConnectionByRuntime.set(runtime, connections);
|
|
445260
|
+
}
|
|
445261
|
+
return connections;
|
|
445262
|
+
}
|
|
445623
445263
|
function getConnectionIdsByRegistrationKey(runtime) {
|
|
445624
445264
|
let controllers = connectionIdByRegistrationKey.get(runtime);
|
|
445625
445265
|
if (!controllers) {
|
|
@@ -445631,13 +445271,12 @@ function getConnectionIdsByRegistrationKey(runtime) {
|
|
|
445631
445271
|
function getRuntimeKey(runtime) {
|
|
445632
445272
|
return `${runtime.agent_id}:${runtime.conversation_id}`;
|
|
445633
445273
|
}
|
|
445634
|
-
function getToolRegistrationKey(connectionId, runtime,
|
|
445274
|
+
function getToolRegistrationKey(connectionId, runtime, toolName2) {
|
|
445635
445275
|
return JSON.stringify([
|
|
445636
445276
|
"runtime",
|
|
445637
445277
|
connectionId,
|
|
445638
445278
|
runtime.agent_id,
|
|
445639
445279
|
runtime.conversation_id,
|
|
445640
|
-
scopeId ?? null,
|
|
445641
445280
|
toolName2
|
|
445642
445281
|
]);
|
|
445643
445282
|
}
|
|
@@ -445664,7 +445303,7 @@ function captureExternalToolNotificationGuard(listener, runtimeScope) {
|
|
|
445664
445303
|
}
|
|
445665
445304
|
};
|
|
445666
445305
|
}
|
|
445667
|
-
function toExternalToolDefinition(listener, tool, connectionId, runtimeScope
|
|
445306
|
+
function toExternalToolDefinition(listener, tool, connectionId, runtimeScope) {
|
|
445668
445307
|
const toolDefinition = {
|
|
445669
445308
|
name: tool.name,
|
|
445670
445309
|
connectionId,
|
|
@@ -445673,8 +445312,7 @@ function toExternalToolDefinition(listener, tool, connectionId, runtimeScope, sc
|
|
|
445673
445312
|
parameters: tool.parameters,
|
|
445674
445313
|
...tool.timeout_ms !== undefined ? { timeoutMs: tool.timeout_ms } : {},
|
|
445675
445314
|
autoBackground: tool.auto_background ?? true,
|
|
445676
|
-
registrationKey: getToolRegistrationKey(connectionId, runtimeScope,
|
|
445677
|
-
...scopeId !== undefined ? { scopeId } : {},
|
|
445315
|
+
registrationKey: getToolRegistrationKey(connectionId, runtimeScope, tool.name),
|
|
445678
445316
|
runtime: {
|
|
445679
445317
|
agentId: runtimeScope.agent_id ?? undefined,
|
|
445680
445318
|
conversationId: runtimeScope.conversation_id
|
|
@@ -445707,7 +445345,6 @@ function installExternalToolBridge(runtime) {
|
|
|
445707
445345
|
type: "external_tool_call_request",
|
|
445708
445346
|
request_id: requestId,
|
|
445709
445347
|
...requestRuntime ? { runtime: requestRuntime } : {},
|
|
445710
|
-
...context3?.tool.scopeId !== undefined ? { scope_id: context3.tool.scopeId } : {},
|
|
445711
445348
|
tool_call_id: toolCallId,
|
|
445712
445349
|
tool_name: toolName2,
|
|
445713
445350
|
input
|
|
@@ -445744,35 +445381,74 @@ function installExternalToolBridge(runtime) {
|
|
|
445744
445381
|
return result3;
|
|
445745
445382
|
});
|
|
445746
445383
|
}
|
|
445747
|
-
function registerRuntimeExternalTools(runtime, connectionId, runtimeScope, groups) {
|
|
445384
|
+
function registerRuntimeExternalTools(runtime, connectionId, runtimeScope, groups, toolPolicy) {
|
|
445748
445385
|
const resolvedGroups = groups ?? [];
|
|
445386
|
+
if (resolvedGroups.some((group) => Object.hasOwn(group, "scope_id"))) {
|
|
445387
|
+
debugLog("Listen", "Ignoring deprecated external tool scope_id");
|
|
445388
|
+
}
|
|
445749
445389
|
const registeredTools = getRegisteredTools(runtime);
|
|
445750
|
-
const runtimeKey =
|
|
445751
|
-
const
|
|
445390
|
+
const runtimeKey = getRuntimeKey(runtimeScope);
|
|
445391
|
+
const registrationScope = createConnectionRequestKey(connectionId, runtimeKey);
|
|
445392
|
+
const previousTools = registeredTools.get(registrationScope)?.tools ?? [];
|
|
445752
445393
|
unregisterExternalTools(previousTools);
|
|
445753
|
-
const tools = resolvedGroups.flatMap((group) => group.tools.map((tool) => toExternalToolDefinition(runtime, tool, connectionId, runtimeScope
|
|
445394
|
+
const tools = resolvedGroups.flatMap((group) => group.tools.map((tool) => toExternalToolDefinition(runtime, tool, connectionId, runtimeScope)));
|
|
445754
445395
|
const controllers = getConnectionIdsByRegistrationKey(runtime);
|
|
445755
445396
|
for (const tool of previousTools) {
|
|
445756
445397
|
if (tool.registrationKey) {
|
|
445757
445398
|
controllers.delete(tool.registrationKey);
|
|
445758
445399
|
}
|
|
445759
445400
|
}
|
|
445760
|
-
|
|
445761
|
-
|
|
445762
|
-
|
|
445763
|
-
|
|
445764
|
-
|
|
445401
|
+
registerExternalTools(tools);
|
|
445402
|
+
for (const tool of tools) {
|
|
445403
|
+
if (tool.registrationKey) {
|
|
445404
|
+
controllers.set(tool.registrationKey, connectionId);
|
|
445405
|
+
}
|
|
445406
|
+
}
|
|
445407
|
+
registeredTools.delete(registrationScope);
|
|
445408
|
+
if (tools.length > 0 || toolPolicy !== undefined) {
|
|
445409
|
+
registeredTools.set(registrationScope, {
|
|
445410
|
+
connectionId,
|
|
445411
|
+
runtimeKey,
|
|
445412
|
+
tools,
|
|
445413
|
+
...toolPolicy !== undefined ? { toolPolicy } : {},
|
|
445414
|
+
sequence: ++nextRegistrationSequence
|
|
445415
|
+
});
|
|
445416
|
+
}
|
|
445417
|
+
}
|
|
445418
|
+
function recordRuntimeSubmittingConnection(runtime, runtimeScope, connectionId) {
|
|
445419
|
+
getLastSubmittingConnections(runtime).set(getRuntimeKey(runtimeScope), connectionId);
|
|
445420
|
+
}
|
|
445421
|
+
function resolveRuntimeToolOwner(runtime, runtimeScope, submittingConnectionId) {
|
|
445422
|
+
const registeredTools = registeredToolsByRuntime.get(runtime);
|
|
445423
|
+
const runtimeKey = getRuntimeKey(runtimeScope);
|
|
445424
|
+
const registrationFor = (connectionId) => registeredTools?.get(createConnectionRequestKey(connectionId, runtimeKey));
|
|
445425
|
+
if (submittingConnectionId !== undefined) {
|
|
445426
|
+
const toolPolicy = registrationFor(submittingConnectionId)?.toolPolicy;
|
|
445427
|
+
return {
|
|
445428
|
+
connectionId: submittingConnectionId,
|
|
445429
|
+
...toolPolicy ? { toolPolicy } : {}
|
|
445430
|
+
};
|
|
445431
|
+
}
|
|
445432
|
+
const lastSubmitter = lastSubmittingConnectionByRuntime.get(runtime)?.get(runtimeKey);
|
|
445433
|
+
let owner = lastSubmitter !== undefined ? registrationFor(lastSubmitter) : undefined;
|
|
445434
|
+
if (!owner) {
|
|
445435
|
+
for (const registration of registeredTools?.values() ?? []) {
|
|
445436
|
+
if (registration.runtimeKey === runtimeKey && (!owner || registration.sequence > owner.sequence)) {
|
|
445437
|
+
owner = registration;
|
|
445765
445438
|
}
|
|
445766
445439
|
}
|
|
445767
|
-
registeredTools.set(runtimeKey, tools);
|
|
445768
|
-
} else {
|
|
445769
|
-
registeredTools.delete(runtimeKey);
|
|
445770
445440
|
}
|
|
445441
|
+
if (!owner)
|
|
445442
|
+
return {};
|
|
445443
|
+
return {
|
|
445444
|
+
connectionId: owner.connectionId,
|
|
445445
|
+
...owner.toolPolicy ? { toolPolicy: owner.toolPolicy } : {}
|
|
445446
|
+
};
|
|
445771
445447
|
}
|
|
445772
445448
|
function updateRuntimeExternalTools(runtime, connectionId, updates) {
|
|
445773
445449
|
for (const update3 of updates) {
|
|
445774
445450
|
for (const runtimeScope of update3.runtimes) {
|
|
445775
|
-
registerRuntimeExternalTools(runtime, connectionId, runtimeScope, update3.external_tools);
|
|
445451
|
+
registerRuntimeExternalTools(runtime, connectionId, runtimeScope, update3.external_tools, update3.tool_policy);
|
|
445776
445452
|
}
|
|
445777
445453
|
}
|
|
445778
445454
|
}
|
|
@@ -445824,19 +445500,23 @@ function rejectPendingExternalToolCallsForConnection(runtime, connectionId, reas
|
|
|
445824
445500
|
pendingExternalToolCalls.delete(requestKey);
|
|
445825
445501
|
pending2.reject(new Error(reason));
|
|
445826
445502
|
}
|
|
445503
|
+
const lastSubmitters = lastSubmittingConnectionByRuntime.get(runtime);
|
|
445504
|
+
for (const [runtimeKey, submitter] of lastSubmitters ?? []) {
|
|
445505
|
+
if (submitter === connectionId)
|
|
445506
|
+
lastSubmitters?.delete(runtimeKey);
|
|
445507
|
+
}
|
|
445827
445508
|
const registeredTools = registeredToolsByRuntime.get(runtime);
|
|
445828
445509
|
if (!registeredTools) {
|
|
445829
445510
|
return;
|
|
445830
445511
|
}
|
|
445831
445512
|
const controllers = getConnectionIdsByRegistrationKey(runtime);
|
|
445832
|
-
for (const [registrationScope,
|
|
445833
|
-
|
|
445834
|
-
if (!ownedByConnection) {
|
|
445513
|
+
for (const [registrationScope, registration] of registeredTools) {
|
|
445514
|
+
if (registration.connectionId !== connectionId) {
|
|
445835
445515
|
continue;
|
|
445836
445516
|
}
|
|
445837
|
-
unregisterExternalTools(tools);
|
|
445517
|
+
unregisterExternalTools(registration.tools);
|
|
445838
445518
|
registeredTools.delete(registrationScope);
|
|
445839
|
-
for (const tool of tools) {
|
|
445519
|
+
for (const tool of registration.tools) {
|
|
445840
445520
|
if (tool.registrationKey) {
|
|
445841
445521
|
controllers.delete(tool.registrationKey);
|
|
445842
445522
|
}
|
|
@@ -445852,16 +445532,18 @@ function rejectPendingExternalToolCalls(runtime, reason) {
|
|
|
445852
445532
|
}
|
|
445853
445533
|
const registeredTools = registeredToolsByRuntime.get(runtime);
|
|
445854
445534
|
if (registeredTools) {
|
|
445855
|
-
for (const
|
|
445856
|
-
unregisterExternalTools(tools);
|
|
445535
|
+
for (const registration of registeredTools.values()) {
|
|
445536
|
+
unregisterExternalTools(registration.tools);
|
|
445857
445537
|
}
|
|
445858
445538
|
registeredToolsByRuntime.delete(runtime);
|
|
445859
445539
|
}
|
|
445860
445540
|
connectionIdByRegistrationKey.delete(runtime);
|
|
445541
|
+
lastSubmittingConnectionByRuntime.delete(runtime);
|
|
445861
445542
|
}
|
|
445862
|
-
var EXTERNAL_TOOL_CALL_TIMEOUT_MS, registeredToolsByRuntime, connectionIdByRegistrationKey;
|
|
445543
|
+
var EXTERNAL_TOOL_CALL_TIMEOUT_MS, registeredToolsByRuntime, lastSubmittingConnectionByRuntime, nextRegistrationSequence = 0, connectionIdByRegistrationKey;
|
|
445863
445544
|
var init_external_tools = __esm(async () => {
|
|
445864
445545
|
init_external_tool_background_eligibility();
|
|
445546
|
+
init_debug();
|
|
445865
445547
|
init_transport2();
|
|
445866
445548
|
await __promiseAll([
|
|
445867
445549
|
init_manager2(),
|
|
@@ -445870,6 +445552,7 @@ var init_external_tools = __esm(async () => {
|
|
|
445870
445552
|
]);
|
|
445871
445553
|
EXTERNAL_TOOL_CALL_TIMEOUT_MS = 5 * 60 * 1000;
|
|
445872
445554
|
registeredToolsByRuntime = new WeakMap;
|
|
445555
|
+
lastSubmittingConnectionByRuntime = new WeakMap;
|
|
445873
445556
|
connectionIdByRegistrationKey = new WeakMap;
|
|
445874
445557
|
});
|
|
445875
445558
|
|
|
@@ -447232,7 +446915,7 @@ async function handleRuntimeStartCommand(parsed, context3) {
|
|
|
447232
446915
|
}
|
|
447233
446916
|
assertConnectionOpen();
|
|
447234
446917
|
subscribeListenerConnection(context3.runtime, connectionId, runtimeScope);
|
|
447235
|
-
registerRuntimeExternalTools(context3.runtime, connectionId, runtimeScope, parsed.external_tools ?? []);
|
|
446918
|
+
registerRuntimeExternalTools(context3.runtime, connectionId, runtimeScope, parsed.external_tools ?? [], parsed.tool_policy);
|
|
447236
446919
|
if (parsed.wait_for_replay) {
|
|
447237
446920
|
await context3.replaySyncStateForRuntime(context3.runtime, context3.socket, runtimeScope, {
|
|
447238
446921
|
recoverApprovals: parsed.recover_approvals !== false,
|
|
@@ -458050,12 +457733,12 @@ function rowToolCalls(row, index, diagnostics2) {
|
|
|
458050
457733
|
}
|
|
458051
457734
|
return calls;
|
|
458052
457735
|
}
|
|
458053
|
-
function
|
|
457736
|
+
function contentText4(content) {
|
|
458054
457737
|
if (typeof content === "string") {
|
|
458055
457738
|
if (content.startsWith(CONTENT_JSON_PREFIX)) {
|
|
458056
457739
|
const encoded = content.slice(CONTENT_JSON_PREFIX.length);
|
|
458057
457740
|
try {
|
|
458058
|
-
return
|
|
457741
|
+
return contentText4(JSON.parse(encoded));
|
|
458059
457742
|
} catch {
|
|
458060
457743
|
return encoded;
|
|
458061
457744
|
}
|
|
@@ -458141,7 +457824,7 @@ var init_hermes = __esm(() => {
|
|
|
458141
457824
|
});
|
|
458142
457825
|
};
|
|
458143
457826
|
if (row.role === "user") {
|
|
458144
|
-
const content =
|
|
457827
|
+
const content = contentText4(row.content);
|
|
458145
457828
|
if (content) {
|
|
458146
457829
|
emit({
|
|
458147
457830
|
type: "message",
|
|
@@ -458161,7 +457844,7 @@ var init_hermes = __esm(() => {
|
|
|
458161
457844
|
...timestamp ? { timestamp } : {}
|
|
458162
457845
|
});
|
|
458163
457846
|
}
|
|
458164
|
-
const content =
|
|
457847
|
+
const content = contentText4(row.content);
|
|
458165
457848
|
if (content) {
|
|
458166
457849
|
emit({
|
|
458167
457850
|
type: "message",
|
|
@@ -458184,7 +457867,7 @@ var init_hermes = __esm(() => {
|
|
|
458184
457867
|
if (row.role === "tool") {
|
|
458185
457868
|
emit({
|
|
458186
457869
|
type: "tool_result",
|
|
458187
|
-
content:
|
|
457870
|
+
content: contentText4(row.content),
|
|
458188
457871
|
...typeof row.tool_call_id === "string" && row.tool_call_id ? { callId: row.tool_call_id } : {},
|
|
458189
457872
|
...timestamp ? { timestamp } : {}
|
|
458190
457873
|
});
|
|
@@ -463527,6 +463210,19 @@ async function prepareListenerTurn(params) {
|
|
|
463527
463210
|
const environmentDeviceId = listenerOptions?.deviceId;
|
|
463528
463211
|
if (msg.clientPreferences !== undefined)
|
|
463529
463212
|
replaceClientPreferences(agentId, conversationId, msg.clientPreferences);
|
|
463213
|
+
const toolRuntimeScope = {
|
|
463214
|
+
agent_id: agentId,
|
|
463215
|
+
conversation_id: conversationId
|
|
463216
|
+
};
|
|
463217
|
+
if (connectionId) {
|
|
463218
|
+
recordRuntimeSubmittingConnection(runtime.listener, toolRuntimeScope, connectionId);
|
|
463219
|
+
}
|
|
463220
|
+
const toolOwner = resolveRuntimeToolOwner(runtime.listener, toolRuntimeScope, connectionId);
|
|
463221
|
+
const toolSelection = resolveTurnToolSelection({
|
|
463222
|
+
clientToolset: msg.clientToolset,
|
|
463223
|
+
clientToolAllowlist: msg.clientToolAllowlist,
|
|
463224
|
+
excludeInteractiveTools: msg.excludeInteractiveTools
|
|
463225
|
+
}, toolOwner.toolPolicy);
|
|
463530
463226
|
const preparedToolContext = await prepareToolExecutionContextForScope({
|
|
463531
463227
|
connectionId: executionConnectionId,
|
|
463532
463228
|
environmentDeviceId,
|
|
@@ -463536,10 +463232,10 @@ async function prepareListenerTurn(params) {
|
|
|
463536
463232
|
suppressActingUserFallback: msg.suppressActingUserFallback,
|
|
463537
463233
|
mcpOriginatorSuperRunId: getEffectiveMcpOriginatorId(msg),
|
|
463538
463234
|
resolveClientMessageIds,
|
|
463539
|
-
|
|
463540
|
-
|
|
463541
|
-
|
|
463542
|
-
|
|
463235
|
+
externalToolOwnerConnectionId: toolOwner.connectionId,
|
|
463236
|
+
clientToolset: toolSelection.clientToolset,
|
|
463237
|
+
clientToolAllowlist: toolSelection.clientToolAllowlist,
|
|
463238
|
+
...toolSelection.excludeInteractiveTools ? { exclude: [...INTERACTIVE_USER_INPUT_TOOL_NAMES] } : {},
|
|
463543
463239
|
workingDirectory,
|
|
463544
463240
|
permissionModeState,
|
|
463545
463241
|
skillsDirectory: listenerOptions?.skillsDirectory,
|
|
@@ -463614,6 +463310,7 @@ var init_turn_setup = __esm(async () => {
|
|
|
463614
463310
|
init_runtime_context();
|
|
463615
463311
|
init_error_reporting();
|
|
463616
463312
|
init_interactive_policy();
|
|
463313
|
+
init_tool_policy();
|
|
463617
463314
|
init_debug();
|
|
463618
463315
|
init_shell_context();
|
|
463619
463316
|
init_channel_runtime_tools();
|
|
@@ -463623,6 +463320,7 @@ var init_turn_setup = __esm(async () => {
|
|
|
463623
463320
|
init_client_preferences(),
|
|
463624
463321
|
init_toolset(),
|
|
463625
463322
|
init_connection(),
|
|
463323
|
+
init_external_tools(),
|
|
463626
463324
|
init_image_policy(),
|
|
463627
463325
|
init_interrupts(),
|
|
463628
463326
|
init_mod_adapter2(),
|
|
@@ -467190,6 +466888,7 @@ function buildAppServerInfoResponse(command, options) {
|
|
|
467190
466888
|
subagent_message: true,
|
|
467191
466889
|
runtime_workspace_sandbox: true,
|
|
467192
466890
|
runtime_external_tools_update: true,
|
|
466891
|
+
runtime_tool_policy: true,
|
|
467193
466892
|
structured_outputs: options.backend === "api",
|
|
467194
466893
|
write_file_base64: true,
|
|
467195
466894
|
split_channels: false
|
|
@@ -468336,6 +468035,9 @@ var init_input_disposition_ownership = __esm(async () => {
|
|
|
468336
468035
|
function createIncomingMessage(scope, payload, connectionId, frame) {
|
|
468337
468036
|
const mcpOriginator = readMcpOriginatorDelivery(frame);
|
|
468338
468037
|
const terminalConsumerId = frame?.terminal_consumer_id ?? undefined;
|
|
468038
|
+
if (Object.hasOwn(payload, "external_tool_scope_ids")) {
|
|
468039
|
+
debugLog("Listen", "Ignoring deprecated external_tool_scope_ids");
|
|
468040
|
+
}
|
|
468339
468041
|
return {
|
|
468340
468042
|
type: "message",
|
|
468341
468043
|
connectionId,
|
|
@@ -468344,7 +468046,6 @@ function createIncomingMessage(scope, payload, connectionId, frame) {
|
|
|
468344
468046
|
clientToolAllowlist: payload.client_tool_allowlist,
|
|
468345
468047
|
clientToolset: payload.client_toolset,
|
|
468346
468048
|
clientPreferences: payload.client_preferences,
|
|
468347
|
-
externalToolScopeIds: payload.external_tool_scope_ids,
|
|
468348
468049
|
excludeInteractiveTools: payload.exclude_interactive_tools,
|
|
468349
468050
|
responseFormat: payload.response_format,
|
|
468350
468051
|
imageFailureMode: payload.image_failure_mode,
|
|
@@ -468623,7 +468324,6 @@ function summarizeInputPayload(payload) {
|
|
|
468623
468324
|
pushField(fields, "client_toolset.base", payload.client_toolset.base);
|
|
468624
468325
|
pushField(fields, "client_toolset.include", payload.client_toolset.include);
|
|
468625
468326
|
}
|
|
468626
|
-
pushField(fields, "external_tool_scope_ids", payload.external_tool_scope_ids);
|
|
468627
468327
|
pushField(fields, "exclude_interactive_tools", payload.exclude_interactive_tools);
|
|
468628
468328
|
} else if (payload.kind === "approval_response") {
|
|
468629
468329
|
pushField(fields, "request_id", payload.request_id);
|
|
@@ -543238,4 +542938,4 @@ function registerBunOAuthFlows() {
|
|
|
543238
542938
|
registerBunOAuthFlows();
|
|
543239
542939
|
await init_src5().then(() => exports_src2);
|
|
543240
542940
|
|
|
543241
|
-
//# debugId=
|
|
542941
|
+
//# debugId=A5E4F04FD213E38C64756E2164756E21
|