@letta-ai/letta-code 0.27.3 → 0.27.4
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/letta.js +1766 -1227
- package/package.json +1 -1
- package/skills/creating-extensions/references/events.md +15 -1
package/package.json
CHANGED
|
@@ -126,7 +126,21 @@ letta.events.on("tool_start", (event) => {
|
|
|
126
126
|
|
|
127
127
|
Handlers run in registration order. Later handlers see the current args after earlier mutations/returns. If a handler throws, its partial `event.args` mutation is rolled back and the error is recorded as an extension diagnostic.
|
|
128
128
|
|
|
129
|
-
`tool_start` is intentionally a trusted local extension point: it can rewrite commands, file paths, and other tool inputs before execution. Keep transforms focused and unsurprising.
|
|
129
|
+
`tool_start` is intentionally a trusted local extension point: it can rewrite commands, file paths, and other tool inputs before execution. Keep transforms focused and unsurprising.
|
|
130
|
+
|
|
131
|
+
### Denying tool execution
|
|
132
|
+
|
|
133
|
+
Handlers can deny a tool by returning `{ deny: true, reason?: "..." }`. All handlers still run (for side effects like logging or state updates), but if any handler denies, the tool is blocked. The first denial reason is shown to the model as the tool error message.
|
|
134
|
+
|
|
135
|
+
```ts
|
|
136
|
+
letta.events.on("tool_start", (event) => {
|
|
137
|
+
if (event.toolName === "Bash" && String(event.args.command).includes("rm -rf")) {
|
|
138
|
+
return { deny: true, reason: "Destructive command blocked." };
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
Denial runs before `PreToolUse` hooks. If an extension denies a tool, hooks are not invoked for that tool call.
|
|
130
144
|
|
|
131
145
|
`turn_start` fires before outbound turns that include a user message. In the TUI this includes normal submits and prompt-style command turns. In headless it includes one-shot prompts and bidirectional user turns.
|
|
132
146
|
|