llms-py 3.0.14__py3-none-any.whl → 3.0.16__py3-none-any.whl
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.
- llms/extensions/app/ui/threadStore.mjs +10 -3
- llms/extensions/computer/README.md +96 -0
- llms/extensions/computer/__init__.py +59 -0
- llms/extensions/{computer_use → computer}/bash.py +2 -2
- llms/extensions/{computer_use → computer}/edit.py +10 -14
- llms/extensions/computer/filesystem.py +542 -0
- llms/extensions/core_tools/__init__.py +0 -38
- llms/extensions/providers/google.py +57 -30
- llms/extensions/skills/LICENSE +202 -0
- llms/extensions/skills/__init__.py +130 -0
- llms/extensions/skills/errors.py +25 -0
- llms/extensions/skills/models.py +39 -0
- llms/extensions/skills/parser.py +178 -0
- llms/extensions/skills/ui/index.mjs +362 -0
- llms/extensions/skills/ui/skills/create-plan/SKILL.md +74 -0
- llms/extensions/skills/validator.py +177 -0
- llms/extensions/system_prompts/ui/index.mjs +6 -10
- llms/extensions/tools/__init__.py +5 -82
- llms/extensions/tools/ui/index.mjs +93 -5
- llms/main.py +215 -35
- llms/ui/ai.mjs +1 -1
- llms/ui/app.css +527 -22
- llms/ui/ctx.mjs +53 -6
- llms/ui/modules/chat/ChatBody.mjs +186 -24
- llms/ui/modules/chat/index.mjs +107 -103
- llms/ui/tailwind.input.css +10 -0
- llms/ui/utils.mjs +25 -1
- {llms_py-3.0.14.dist-info → llms_py-3.0.16.dist-info}/METADATA +1 -1
- {llms_py-3.0.14.dist-info → llms_py-3.0.16.dist-info}/RECORD +37 -27
- {llms_py-3.0.14.dist-info → llms_py-3.0.16.dist-info}/WHEEL +1 -1
- llms/extensions/computer_use/__init__.py +0 -27
- /llms/extensions/{computer_use → computer}/base.py +0 -0
- /llms/extensions/{computer_use → computer}/computer.py +0 -0
- /llms/extensions/{computer_use → computer}/platform.py +0 -0
- /llms/extensions/{computer_use → computer}/run.py +0 -0
- {llms_py-3.0.14.dist-info → llms_py-3.0.16.dist-info}/entry_points.txt +0 -0
- {llms_py-3.0.14.dist-info → llms_py-3.0.16.dist-info}/licenses/LICENSE +0 -0
- {llms_py-3.0.14.dist-info → llms_py-3.0.16.dist-info}/top_level.txt +0 -0
|
@@ -354,11 +354,11 @@ async function startNewThread({ title, model, tools, redirect }) {
|
|
|
354
354
|
async function queueChat(ctxRequest, options = {}) {
|
|
355
355
|
if (!ctxRequest.request) return ctx.createErrorResult({ message: 'No request provided' })
|
|
356
356
|
if (!ctxRequest.thread) return ctx.createErrorResult({ message: 'No thread provided' })
|
|
357
|
-
|
|
358
|
-
ctxRequest.request.metadata = {}
|
|
359
|
-
}
|
|
357
|
+
ctxRequest = ctx.createChatContext(ctxRequest)
|
|
360
358
|
ctx.chatRequestFilters.forEach(f => f(ctxRequest))
|
|
361
359
|
const { thread, request } = ctxRequest
|
|
360
|
+
ctx.completeChatContext(ctxRequest)
|
|
361
|
+
|
|
362
362
|
const api = await ctx.postJson(`/ext/app/threads/${thread.id}/chat`, {
|
|
363
363
|
...options,
|
|
364
364
|
body: typeof request == 'string'
|
|
@@ -381,6 +381,12 @@ async function loadThreadDetails(id, opt = null) {
|
|
|
381
381
|
return threadDetails.value[id]
|
|
382
382
|
}
|
|
383
383
|
|
|
384
|
+
function getCurrentThreadSystemPrompt() {
|
|
385
|
+
return currentThread.value?.systemPrompt
|
|
386
|
+
?? currentThread.value?.messages?.find(m => m.role == 'system')?.content
|
|
387
|
+
?? ''
|
|
388
|
+
}
|
|
389
|
+
|
|
384
390
|
// Export the store
|
|
385
391
|
export function useThreadStore() {
|
|
386
392
|
return {
|
|
@@ -391,6 +397,7 @@ export function useThreadStore() {
|
|
|
391
397
|
groupedThreads,
|
|
392
398
|
|
|
393
399
|
// Actions
|
|
400
|
+
getCurrentThreadSystemPrompt,
|
|
394
401
|
query,
|
|
395
402
|
createThread,
|
|
396
403
|
updateThread,
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# Computer Use Tools
|
|
2
|
+
|
|
3
|
+
This extension provides a set of tools that allow an Agent to interact with a computer environment in a way similar to a human user. It includes capabilities for screen interaction (mouse/keyboard), shell execution, and file editing. Based on [Anthropic's computer use tools](https://github.com/anthropics/anthropic-quickstarts/tree/main/computer-use-demo).
|
|
4
|
+
|
|
5
|
+
## Available Tools
|
|
6
|
+
|
|
7
|
+
### 1. Computer Tool (`computer`)
|
|
8
|
+
Allows interaction with the screen, keyboard, and mouse.
|
|
9
|
+
|
|
10
|
+
**Capabilities:**
|
|
11
|
+
- **Mouse Interaction**: Move cursor, click (left, right, middle, double, triple), click & drag.
|
|
12
|
+
- **Keyboard Interaction**: Type text, press specific keys or key combinations.
|
|
13
|
+
- **Screen**: Take screenshots, get cursor position.
|
|
14
|
+
- **Zooming**: Zoom into specific regions of the screen (Action: `zoom`).
|
|
15
|
+
|
|
16
|
+
**Key Parameters:**
|
|
17
|
+
- `action`: The action to perform (e.g., `mouse_move`, `left_click`, `type`, `screenshot`, `zoom`).
|
|
18
|
+
- `coordinate`: `(x, y)` coordinates for mouse actions.
|
|
19
|
+
- `text`: Text to type.
|
|
20
|
+
- `key`: Key sequence to press (e.g., `Return`, `Control+c`).
|
|
21
|
+
- `region`: `(x0, y0, x1, y1)` region for zooming.
|
|
22
|
+
|
|
23
|
+
### 2. Bash Tool (`bash`)
|
|
24
|
+
Provides a persistent shell session to execute command-line instructions.
|
|
25
|
+
|
|
26
|
+
**Capabilities:**
|
|
27
|
+
- **Execute Commands**: Run any bash command.
|
|
28
|
+
- **Persistent Session**: State (like environment variables, working directory) is preserved between calls within the same session.
|
|
29
|
+
- **Process Management**: Can restart the session if needed.
|
|
30
|
+
- **Open Files/URLs**: Helper function `open` allows opening files or URLs using the system's default handler (`xdg-open`, `open`, or `start`).
|
|
31
|
+
|
|
32
|
+
**Key Parameters:**
|
|
33
|
+
- `command`: The bash command to execute.
|
|
34
|
+
- `restart`: Boolean to restart the session.
|
|
35
|
+
|
|
36
|
+
### 3. Edit Tool (`str_replace_editor`)
|
|
37
|
+
A filesystem editor for viewing and modifying files.
|
|
38
|
+
|
|
39
|
+
**Capabilities:**
|
|
40
|
+
- **View**: Read file contents or list directories.
|
|
41
|
+
- **Create**: Create new files with content.
|
|
42
|
+
- **String Replace**: Replace unique strings in a file (robust for LLM editing).
|
|
43
|
+
- **Insert**: Insert text at specific line numbers.
|
|
44
|
+
- **Undo**: Undo the last edit to a file.
|
|
45
|
+
|
|
46
|
+
**Key Parameters:**
|
|
47
|
+
- `command`: The edit command (`view`, `create`, `str_replace`, `insert`, `undo_edit`).
|
|
48
|
+
- `path`: Absolute path to the file or directory.
|
|
49
|
+
- `file_text`: Content for file creation.
|
|
50
|
+
- `old_str` / `new_str`: Strings for replacement.
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## Capabilities & Workflows
|
|
55
|
+
|
|
56
|
+
These tools are designed to work together to enable complex end-to-end tasks. An Agent can act as a developer, tester, or general user.
|
|
57
|
+
|
|
58
|
+
### Example: "Build a Tetris web app in a tetris folder, open it then take a screenshot"
|
|
59
|
+
|
|
60
|
+
To achieve this high-level task, the Agent would sequence the tools as follows:
|
|
61
|
+
|
|
62
|
+
1. **Create the Project Structure**
|
|
63
|
+
* **Tool**: `bash`
|
|
64
|
+
* **Command**: `mkdir -p tetris`
|
|
65
|
+
* *Result*: Creates the folder.
|
|
66
|
+
|
|
67
|
+
2. **Create the Application Files**
|
|
68
|
+
* **Tool**: `edit` (command: `create`)
|
|
69
|
+
* **Path**: `/path/to/tetris/index.html`
|
|
70
|
+
* **Content**: (HTML code for Tetris game)
|
|
71
|
+
* *Result*: Writes the HTML file.
|
|
72
|
+
|
|
73
|
+
3. **Open the Application**
|
|
74
|
+
* **Tool**: `bash` (via helper `open`) or `bash` directly.
|
|
75
|
+
* **Command**: `xdg-open /path/to/tetris/index.html` (Linux) or just `python -m http.server` and open localhost.
|
|
76
|
+
* *Result*: Opens the file in the default web browser.
|
|
77
|
+
|
|
78
|
+
4. **Wait & Verify**
|
|
79
|
+
* **Tool**: `computer`
|
|
80
|
+
* **Action**: `wait` or `screenshot` to see if it loaded.
|
|
81
|
+
|
|
82
|
+
5. **Take a Screenshot**
|
|
83
|
+
* **Tool**: `computer`
|
|
84
|
+
* **Action**: `screenshot`
|
|
85
|
+
* *Result*: Captures the visual state of the running Tetris app for the user to see.
|
|
86
|
+
|
|
87
|
+
### How it handles the "Build a Tetris..." request:
|
|
88
|
+
When a user gives the command:
|
|
89
|
+
> "Build a Tetris web app in a tetris folder, open it then take a screenshot"
|
|
90
|
+
|
|
91
|
+
The Agent decomposes this into:
|
|
92
|
+
1. **"Build... in a tetris folder"** -> Uses `bash` to make the directory and `edit` to write the `index.html` / `style.css` / `script.js` files.
|
|
93
|
+
2. **"Open it"** -> Uses `bash` to run a server or open the file in a browser.
|
|
94
|
+
3. **"Take a screenshot"** -> Uses `computer` to verify the visual output.
|
|
95
|
+
|
|
96
|
+
This combination allows the Agent to not just generate code, but **verify** it visually and interactively, closing the loop on development tasks.
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Anthropic's Computer Use Tools
|
|
3
|
+
https://github.com/anthropics/claude-quickstarts/tree/main/computer-use-demo
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
import os
|
|
7
|
+
|
|
8
|
+
from .bash import open, run_bash
|
|
9
|
+
from .computer import computer
|
|
10
|
+
from .edit import edit
|
|
11
|
+
from .filesystem import (
|
|
12
|
+
create_directory,
|
|
13
|
+
directory_tree,
|
|
14
|
+
edit_file,
|
|
15
|
+
filesystem_init,
|
|
16
|
+
get_file_info,
|
|
17
|
+
list_allowed_directories,
|
|
18
|
+
list_directory,
|
|
19
|
+
list_directory_with_sizes,
|
|
20
|
+
move_file,
|
|
21
|
+
read_media_file,
|
|
22
|
+
read_multiple_files,
|
|
23
|
+
read_text_file,
|
|
24
|
+
search_files,
|
|
25
|
+
write_file,
|
|
26
|
+
)
|
|
27
|
+
from .platform import get_display_num, get_screen_resolution
|
|
28
|
+
|
|
29
|
+
width, height = get_screen_resolution()
|
|
30
|
+
# set enviroment variables
|
|
31
|
+
os.environ["WIDTH"] = str(width)
|
|
32
|
+
os.environ["HEIGHT"] = str(height)
|
|
33
|
+
os.environ["DISPLAY_NUM"] = str(get_display_num())
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def install(ctx):
|
|
37
|
+
filesystem_init(ctx)
|
|
38
|
+
|
|
39
|
+
ctx.register_tool(run_bash, group="computer")
|
|
40
|
+
ctx.register_tool(open, group="computer")
|
|
41
|
+
ctx.register_tool(edit, group="computer")
|
|
42
|
+
ctx.register_tool(computer, group="computer")
|
|
43
|
+
|
|
44
|
+
ctx.register_tool(read_text_file, group="filesystem")
|
|
45
|
+
ctx.register_tool(read_media_file, group="filesystem")
|
|
46
|
+
ctx.register_tool(read_multiple_files, group="filesystem")
|
|
47
|
+
ctx.register_tool(write_file, group="filesystem")
|
|
48
|
+
ctx.register_tool(edit_file, group="filesystem")
|
|
49
|
+
ctx.register_tool(create_directory, group="filesystem")
|
|
50
|
+
ctx.register_tool(list_directory, group="filesystem")
|
|
51
|
+
ctx.register_tool(list_directory_with_sizes, group="filesystem")
|
|
52
|
+
ctx.register_tool(directory_tree, group="filesystem")
|
|
53
|
+
ctx.register_tool(move_file, group="filesystem")
|
|
54
|
+
ctx.register_tool(search_files, group="filesystem")
|
|
55
|
+
ctx.register_tool(get_file_info, group="filesystem")
|
|
56
|
+
ctx.register_tool(list_allowed_directories, group="filesystem")
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
__install__ = install
|
|
@@ -158,7 +158,7 @@ async def run_bash(
|
|
|
158
158
|
if g_tool is None:
|
|
159
159
|
g_tool = BashTool20241022()
|
|
160
160
|
|
|
161
|
-
result = await g_tool(command, restart)
|
|
161
|
+
result = await g_tool(command=command, restart=restart)
|
|
162
162
|
if isinstance(result, Exception):
|
|
163
163
|
raise result
|
|
164
164
|
else:
|
|
@@ -182,4 +182,4 @@ async def open(target: Annotated[str, "URL or file path to open"]) -> list[dict[
|
|
|
182
182
|
else: # Linux and other Unix-like
|
|
183
183
|
cmd = ["xdg-open", target]
|
|
184
184
|
|
|
185
|
-
return await run_bash(" ".join(cmd))
|
|
185
|
+
return await run_bash(command=" ".join(cmd))
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
from collections import defaultdict
|
|
2
2
|
from pathlib import Path
|
|
3
|
-
from typing import Annotated, Any, Literal, get_args
|
|
3
|
+
from typing import Annotated, Any, List, Literal, get_args
|
|
4
4
|
|
|
5
5
|
from .base import BaseTool, CLIResult, ToolError, ToolResult
|
|
6
6
|
from .run import maybe_truncate, run
|
|
@@ -272,10 +272,10 @@ async def edit(
|
|
|
272
272
|
command: Command_20250124,
|
|
273
273
|
path: Annotated[str, "The absolute path to the file or directory"],
|
|
274
274
|
file_text: Annotated[str | None, "The content to write to the file (required for create)"] = None,
|
|
275
|
-
view_range: Annotated[
|
|
275
|
+
view_range: Annotated[List[int], "The range of lines to view (e.g. [1, 10])"] = None,
|
|
276
276
|
old_str: Annotated[str | None, "The string to replace (required for str_replace)"] = None,
|
|
277
277
|
new_str: Annotated[str | None, "The replacement string (required for str_replace and insert)"] = None,
|
|
278
|
-
insert_line: Annotated[int
|
|
278
|
+
insert_line: Annotated[int, "The line number after which to insert (required for insert)"] = None,
|
|
279
279
|
) -> list[dict[str, Any]]:
|
|
280
280
|
"""
|
|
281
281
|
An filesystem editor tool that allows the agent to view, create, and edit files.
|
|
@@ -284,18 +284,14 @@ async def edit(
|
|
|
284
284
|
if g_tool is None:
|
|
285
285
|
g_tool = EditTool20250124()
|
|
286
286
|
|
|
287
|
-
view_range_values = None
|
|
288
|
-
if view_range:
|
|
289
|
-
view_range_values = [int(x) for x in view_range]
|
|
290
|
-
|
|
291
287
|
result = await g_tool(
|
|
292
|
-
command,
|
|
293
|
-
path if path else None,
|
|
294
|
-
file_text if file_text else None,
|
|
295
|
-
|
|
296
|
-
old_str if old_str else None,
|
|
297
|
-
new_str if new_str else None,
|
|
298
|
-
int(insert_line) if insert_line else None,
|
|
288
|
+
command=command,
|
|
289
|
+
path=path if path else None,
|
|
290
|
+
file_text=file_text if file_text else None,
|
|
291
|
+
view_range=view_range,
|
|
292
|
+
old_str=old_str if old_str else None,
|
|
293
|
+
new_str=new_str if new_str else None,
|
|
294
|
+
insert_line=int(insert_line) if insert_line else None,
|
|
299
295
|
)
|
|
300
296
|
if isinstance(result, Exception):
|
|
301
297
|
raise result
|