@hyperwindmill/caretaker-cli 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +110 -0
- package/README.md +25 -0
- package/dist/agents/dispatch.d.ts +35 -0
- package/dist/agents/dispatch.d.ts.map +1 -0
- package/dist/agents/dispatch.js +108 -0
- package/dist/agents/sync.d.ts +10 -0
- package/dist/agents/sync.d.ts.map +1 -0
- package/dist/agents/sync.js +95 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +50 -0
- package/dist/cli/run.d.ts +11 -0
- package/dist/cli/run.d.ts.map +1 -0
- package/dist/cli/run.js +89 -0
- package/dist/cli/web/fs.d.ts +3 -0
- package/dist/cli/web/fs.d.ts.map +1 -0
- package/dist/cli/web/fs.js +35 -0
- package/dist/cli/web/mcp_bridge.d.ts +7 -0
- package/dist/cli/web/mcp_bridge.d.ts.map +1 -0
- package/dist/cli/web/mcp_bridge.js +86 -0
- package/dist/cli/web/scheduler/heartbeat.d.ts +16 -0
- package/dist/cli/web/scheduler/heartbeat.d.ts.map +1 -0
- package/dist/cli/web/scheduler/heartbeat.js +181 -0
- package/dist/cli/web/scheduler/locks.d.ts +8 -0
- package/dist/cli/web/scheduler/locks.d.ts.map +1 -0
- package/dist/cli/web/scheduler/locks.js +7 -0
- package/dist/cli/web/scheduler/logs.d.ts +21 -0
- package/dist/cli/web/scheduler/logs.d.ts.map +1 -0
- package/dist/cli/web/scheduler/logs.js +62 -0
- package/dist/cli/web/scheduler/strategy.d.ts +6 -0
- package/dist/cli/web/scheduler/strategy.d.ts.map +1 -0
- package/dist/cli/web/scheduler/strategy.js +1 -0
- package/dist/cli/web/scheduler/task_review.d.ts +18 -0
- package/dist/cli/web/scheduler/task_review.d.ts.map +1 -0
- package/dist/cli/web/scheduler/task_review.js +77 -0
- package/dist/cli/web/scheduler/task_roles.d.ts +22 -0
- package/dist/cli/web/scheduler/task_roles.d.ts.map +1 -0
- package/dist/cli/web/scheduler/task_roles.js +70 -0
- package/dist/cli/web/scheduler/task_strategy.d.ts +2 -0
- package/dist/cli/web/scheduler/task_strategy.d.ts.map +1 -0
- package/dist/cli/web/scheduler/task_strategy.js +437 -0
- package/dist/cli/web/scheduler/telegram.d.ts +7 -0
- package/dist/cli/web/scheduler/telegram.d.ts.map +1 -0
- package/dist/cli/web/scheduler/telegram.js +393 -0
- package/dist/cli/web/scheduler.d.ts +15 -0
- package/dist/cli/web/scheduler.d.ts.map +1 -0
- package/dist/cli/web/scheduler.js +60 -0
- package/dist/cli/web/server.d.ts +38 -0
- package/dist/cli/web/server.d.ts.map +1 -0
- package/dist/cli/web/server.js +970 -0
- package/dist/commands/loader.d.ts +37 -0
- package/dist/commands/loader.d.ts.map +1 -0
- package/dist/commands/loader.js +110 -0
- package/dist/harness/claude_code_runner.d.ts +47 -0
- package/dist/harness/claude_code_runner.d.ts.map +1 -0
- package/dist/harness/claude_code_runner.js +325 -0
- package/dist/harness/claude_code_stream.d.ts +32 -0
- package/dist/harness/claude_code_stream.d.ts.map +1 -0
- package/dist/harness/claude_code_stream.js +121 -0
- package/dist/harness/context_files.d.ts +23 -0
- package/dist/harness/context_files.d.ts.map +1 -0
- package/dist/harness/context_files.js +126 -0
- package/dist/harness/history.d.ts +4 -0
- package/dist/harness/history.d.ts.map +1 -0
- package/dist/harness/history.js +120 -0
- package/dist/harness/index.d.ts +8 -0
- package/dist/harness/index.d.ts.map +1 -0
- package/dist/harness/index.js +8 -0
- package/dist/harness/loop.d.ts +73 -0
- package/dist/harness/loop.d.ts.map +1 -0
- package/dist/harness/loop.js +373 -0
- package/dist/harness/model_limits.d.ts +25 -0
- package/dist/harness/model_limits.d.ts.map +1 -0
- package/dist/harness/model_limits.js +67 -0
- package/dist/harness/models.d.ts +9 -0
- package/dist/harness/models.d.ts.map +1 -0
- package/dist/harness/models.js +38 -0
- package/dist/harness/prelude.d.ts +21 -0
- package/dist/harness/prelude.d.ts.map +1 -0
- package/dist/harness/prelude.js +41 -0
- package/dist/harness/provider.d.ts +87 -0
- package/dist/harness/provider.d.ts.map +1 -0
- package/dist/harness/provider.js +140 -0
- package/dist/harness/runtime_info.d.ts +7 -0
- package/dist/harness/runtime_info.d.ts.map +1 -0
- package/dist/harness/runtime_info.js +15 -0
- package/dist/harness/think_tag_splitter.d.ts +33 -0
- package/dist/harness/think_tag_splitter.d.ts.map +1 -0
- package/dist/harness/think_tag_splitter.js +70 -0
- package/dist/harness/title.d.ts +17 -0
- package/dist/harness/title.d.ts.map +1 -0
- package/dist/harness/title.js +75 -0
- package/dist/harness/tools/builtin/bash.d.ts +3 -0
- package/dist/harness/tools/builtin/bash.d.ts.map +1 -0
- package/dist/harness/tools/builtin/bash.js +137 -0
- package/dist/harness/tools/builtin/edit.d.ts +6 -0
- package/dist/harness/tools/builtin/edit.d.ts.map +1 -0
- package/dist/harness/tools/builtin/edit.js +85 -0
- package/dist/harness/tools/builtin/fetch.d.ts +3 -0
- package/dist/harness/tools/builtin/fetch.d.ts.map +1 -0
- package/dist/harness/tools/builtin/fetch.js +75 -0
- package/dist/harness/tools/builtin/get_agent_context.d.ts +3 -0
- package/dist/harness/tools/builtin/get_agent_context.d.ts.map +1 -0
- package/dist/harness/tools/builtin/get_agent_context.js +76 -0
- package/dist/harness/tools/builtin/glob.d.ts +3 -0
- package/dist/harness/tools/builtin/glob.d.ts.map +1 -0
- package/dist/harness/tools/builtin/glob.js +52 -0
- package/dist/harness/tools/builtin/grep.d.ts +3 -0
- package/dist/harness/tools/builtin/grep.d.ts.map +1 -0
- package/dist/harness/tools/builtin/grep.js +126 -0
- package/dist/harness/tools/builtin/index.d.ts +23 -0
- package/dist/harness/tools/builtin/index.d.ts.map +1 -0
- package/dist/harness/tools/builtin/index.js +74 -0
- package/dist/harness/tools/builtin/invoke_agent.d.ts +3 -0
- package/dist/harness/tools/builtin/invoke_agent.d.ts.map +1 -0
- package/dist/harness/tools/builtin/invoke_agent.js +106 -0
- package/dist/harness/tools/builtin/invoke_command.d.ts +3 -0
- package/dist/harness/tools/builtin/invoke_command.d.ts.map +1 -0
- package/dist/harness/tools/builtin/invoke_command.js +42 -0
- package/dist/harness/tools/builtin/list_agents.d.ts +3 -0
- package/dist/harness/tools/builtin/list_agents.d.ts.map +1 -0
- package/dist/harness/tools/builtin/list_agents.js +32 -0
- package/dist/harness/tools/builtin/list_commands.d.ts +3 -0
- package/dist/harness/tools/builtin/list_commands.d.ts.map +1 -0
- package/dist/harness/tools/builtin/list_commands.js +27 -0
- package/dist/harness/tools/builtin/list_skills.d.ts +3 -0
- package/dist/harness/tools/builtin/list_skills.d.ts.map +1 -0
- package/dist/harness/tools/builtin/list_skills.js +24 -0
- package/dist/harness/tools/builtin/multiedit.d.ts +3 -0
- package/dist/harness/tools/builtin/multiedit.d.ts.map +1 -0
- package/dist/harness/tools/builtin/multiedit.js +88 -0
- package/dist/harness/tools/builtin/read_attachment.d.ts +3 -0
- package/dist/harness/tools/builtin/read_attachment.d.ts.map +1 -0
- package/dist/harness/tools/builtin/read_attachment.js +128 -0
- package/dist/harness/tools/builtin/read_document.d.ts +37 -0
- package/dist/harness/tools/builtin/read_document.d.ts.map +1 -0
- package/dist/harness/tools/builtin/read_document.js +238 -0
- package/dist/harness/tools/builtin/read_file.d.ts +3 -0
- package/dist/harness/tools/builtin/read_file.d.ts.map +1 -0
- package/dist/harness/tools/builtin/read_file.js +141 -0
- package/dist/harness/tools/builtin/read_image.d.ts +3 -0
- package/dist/harness/tools/builtin/read_image.d.ts.map +1 -0
- package/dist/harness/tools/builtin/read_image.js +80 -0
- package/dist/harness/tools/builtin/read_skill.d.ts +3 -0
- package/dist/harness/tools/builtin/read_skill.d.ts.map +1 -0
- package/dist/harness/tools/builtin/read_skill.js +30 -0
- package/dist/harness/tools/builtin/shell-env.d.ts +55 -0
- package/dist/harness/tools/builtin/shell-env.d.ts.map +1 -0
- package/dist/harness/tools/builtin/shell-env.js +181 -0
- package/dist/harness/tools/builtin/task_tools.d.ts +21 -0
- package/dist/harness/tools/builtin/task_tools.d.ts.map +1 -0
- package/dist/harness/tools/builtin/task_tools.js +708 -0
- package/dist/harness/tools/builtin/write.d.ts +3 -0
- package/dist/harness/tools/builtin/write.d.ts.map +1 -0
- package/dist/harness/tools/builtin/write.js +56 -0
- package/dist/harness/tools/index.d.ts +6 -0
- package/dist/harness/tools/index.d.ts.map +1 -0
- package/dist/harness/tools/index.js +7 -0
- package/dist/harness/tools/instance.d.ts +3 -0
- package/dist/harness/tools/instance.d.ts.map +1 -0
- package/dist/harness/tools/instance.js +19 -0
- package/dist/harness/tools/registry.d.ts +21 -0
- package/dist/harness/tools/registry.d.ts.map +1 -0
- package/dist/harness/tools/registry.js +33 -0
- package/dist/harness/tools/resolve.d.ts +5 -0
- package/dist/harness/tools/resolve.d.ts.map +1 -0
- package/dist/harness/tools/resolve.js +60 -0
- package/dist/harness/tools/sandbox.d.ts +6 -0
- package/dist/harness/tools/sandbox.d.ts.map +1 -0
- package/dist/harness/tools/sandbox.js +23 -0
- package/dist/harness/tools/types.d.ts +80 -0
- package/dist/harness/tools/types.d.ts.map +1 -0
- package/dist/harness/tools/types.js +16 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +46 -0
- package/dist/lib/encryption.d.ts +24 -0
- package/dist/lib/encryption.d.ts.map +1 -0
- package/dist/lib/encryption.js +163 -0
- package/dist/lib/open_url.d.ts +9 -0
- package/dist/lib/open_url.d.ts.map +1 -0
- package/dist/lib/open_url.js +23 -0
- package/dist/lib/task_git.d.ts +11 -0
- package/dist/lib/task_git.d.ts.map +1 -0
- package/dist/lib/task_git.js +100 -0
- package/dist/mcp/adapter.d.ts +9 -0
- package/dist/mcp/adapter.d.ts.map +1 -0
- package/dist/mcp/adapter.js +74 -0
- package/dist/mcp/client.d.ts +50 -0
- package/dist/mcp/client.d.ts.map +1 -0
- package/dist/mcp/client.js +243 -0
- package/dist/mcp/oauth.d.ts +30 -0
- package/dist/mcp/oauth.d.ts.map +1 -0
- package/dist/mcp/oauth.js +171 -0
- package/dist/mcp/oauth_callback.d.ts +9 -0
- package/dist/mcp/oauth_callback.d.ts.map +1 -0
- package/dist/mcp/oauth_callback.js +51 -0
- package/dist/mcp/oauth_store.d.ts +22 -0
- package/dist/mcp/oauth_store.d.ts.map +1 -0
- package/dist/mcp/oauth_store.js +40 -0
- package/dist/mcp/server_manager.d.ts +49 -0
- package/dist/mcp/server_manager.d.ts.map +1 -0
- package/dist/mcp/server_manager.js +271 -0
- package/dist/plugins/fetchers/git.d.ts +67 -0
- package/dist/plugins/fetchers/git.d.ts.map +1 -0
- package/dist/plugins/fetchers/git.js +130 -0
- package/dist/plugins/fetchers/path.d.ts +4 -0
- package/dist/plugins/fetchers/path.d.ts.map +1 -0
- package/dist/plugins/fetchers/path.js +22 -0
- package/dist/plugins/loader.d.ts +31 -0
- package/dist/plugins/loader.d.ts.map +1 -0
- package/dist/plugins/loader.js +146 -0
- package/dist/plugins/manifest.d.ts +56 -0
- package/dist/plugins/manifest.d.ts.map +1 -0
- package/dist/plugins/manifest.js +389 -0
- package/dist/plugins/refresh_on_start.d.ts +7 -0
- package/dist/plugins/refresh_on_start.d.ts.map +1 -0
- package/dist/plugins/refresh_on_start.js +35 -0
- package/dist/plugins/source_manager.d.ts +27 -0
- package/dist/plugins/source_manager.d.ts.map +1 -0
- package/dist/plugins/source_manager.js +211 -0
- package/dist/plugins/types.d.ts +41 -0
- package/dist/plugins/types.d.ts.map +1 -0
- package/dist/plugins/types.js +11 -0
- package/dist/session/context_usage.d.ts +13 -0
- package/dist/session/context_usage.d.ts.map +1 -0
- package/dist/session/context_usage.js +25 -0
- package/dist/session/index.d.ts +7 -0
- package/dist/session/index.d.ts.map +1 -0
- package/dist/session/index.js +5 -0
- package/dist/session/store.d.ts +68 -0
- package/dist/session/store.d.ts.map +1 -0
- package/dist/session/store.js +268 -0
- package/dist/session/types.d.ts +60 -0
- package/dist/session/types.d.ts.map +1 -0
- package/dist/session/types.js +11 -0
- package/dist/store/db.d.ts +64 -0
- package/dist/store/db.d.ts.map +1 -0
- package/dist/store/db.js +91 -0
- package/dist/store/json.d.ts +21 -0
- package/dist/store/json.d.ts.map +1 -0
- package/dist/store/json.js +135 -0
- package/dist/tui/agents.d.ts +4 -0
- package/dist/tui/agents.d.ts.map +1 -0
- package/dist/tui/agents.js +616 -0
- package/dist/tui/app.d.ts +2 -0
- package/dist/tui/app.d.ts.map +1 -0
- package/dist/tui/app.js +32 -0
- package/dist/tui/chat.d.ts +10 -0
- package/dist/tui/chat.d.ts.map +1 -0
- package/dist/tui/chat.js +258 -0
- package/dist/tui/logo.d.ts +2 -0
- package/dist/tui/logo.d.ts.map +1 -0
- package/dist/tui/logo.js +10 -0
- package/dist/tui/mcp_servers.d.ts +4 -0
- package/dist/tui/mcp_servers.d.ts.map +1 -0
- package/dist/tui/mcp_servers.js +287 -0
- package/dist/tui/plugins.d.ts +4 -0
- package/dist/tui/plugins.d.ts.map +1 -0
- package/dist/tui/plugins.js +234 -0
- package/dist/tui/providers.d.ts +4 -0
- package/dist/tui/providers.d.ts.map +1 -0
- package/dist/tui/providers.js +178 -0
- package/dist/tui/tool_picker_state.d.ts +9 -0
- package/dist/tui/tool_picker_state.d.ts.map +1 -0
- package/dist/tui/tool_picker_state.js +37 -0
- package/dist/types.d.ts +2 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +1 -0
- package/dist/webview/index.html +22 -0
- package/dist/webview/standalone.css +2732 -0
- package/dist/webview/standalone.css.map +7 -0
- package/dist/webview/standalone.js +20641 -0
- package/dist/webview/standalone.js.map +7 -0
- package/package.json +120 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# Functional Source License, Version 1.1, MIT Future License
|
|
2
|
+
|
|
3
|
+
## Abbreviation
|
|
4
|
+
|
|
5
|
+
FSL-1.1-MIT
|
|
6
|
+
|
|
7
|
+
## Notice
|
|
8
|
+
|
|
9
|
+
Copyright 2026 Hyperwindmill
|
|
10
|
+
|
|
11
|
+
## Terms and Conditions
|
|
12
|
+
|
|
13
|
+
### Licensor ("We")
|
|
14
|
+
|
|
15
|
+
The party offering the Software under these Terms and Conditions.
|
|
16
|
+
|
|
17
|
+
### The Software
|
|
18
|
+
|
|
19
|
+
The "Software" is each version of the software that we make available under
|
|
20
|
+
these Terms and Conditions, as indicated by our inclusion of these Terms and
|
|
21
|
+
Conditions with the Software.
|
|
22
|
+
|
|
23
|
+
### License Grant
|
|
24
|
+
|
|
25
|
+
Subject to your compliance with this License Grant and the Patents,
|
|
26
|
+
Redistribution and Trademark clauses below, we hereby grant you the right to
|
|
27
|
+
use, copy, modify, create derivative works, publicly perform, publicly display
|
|
28
|
+
and redistribute the Software for any Permitted Purpose identified below.
|
|
29
|
+
|
|
30
|
+
### Permitted Purpose
|
|
31
|
+
|
|
32
|
+
A Permitted Purpose is any purpose other than a Competing Use. A Competing Use
|
|
33
|
+
means making the Software available to others in a commercial product or
|
|
34
|
+
service that:
|
|
35
|
+
|
|
36
|
+
1. substitutes for the Software;
|
|
37
|
+
|
|
38
|
+
2. substitutes for any other product or service we offer using the Software
|
|
39
|
+
that exists as of the date we make the Software available; or
|
|
40
|
+
|
|
41
|
+
3. offers the same or substantially similar functionality as the Software.
|
|
42
|
+
|
|
43
|
+
Permitted Purposes specifically include using the Software:
|
|
44
|
+
|
|
45
|
+
1. for your internal use and access;
|
|
46
|
+
|
|
47
|
+
2. for non-commercial education;
|
|
48
|
+
|
|
49
|
+
3. for non-commercial research; and
|
|
50
|
+
|
|
51
|
+
4. in connection with professional services that you provide to a licensee
|
|
52
|
+
using the Software in accordance with these Terms and Conditions.
|
|
53
|
+
|
|
54
|
+
### Patents
|
|
55
|
+
|
|
56
|
+
To the extent your use for a Permitted Purpose would necessarily infringe our
|
|
57
|
+
patents, the license grant above includes a license under our patents. If you
|
|
58
|
+
make a claim against any party that the Software infringes or contributes to
|
|
59
|
+
the infringement of any patent, then your patent license to the Software ends
|
|
60
|
+
immediately.
|
|
61
|
+
|
|
62
|
+
### Redistribution
|
|
63
|
+
|
|
64
|
+
The Terms and Conditions apply to all copies, modifications and derivatives of
|
|
65
|
+
the Software.
|
|
66
|
+
|
|
67
|
+
If you redistribute any copies, modifications or derivatives of the Software,
|
|
68
|
+
you must include a copy of or a link to these Terms and Conditions and not
|
|
69
|
+
remove any copyright notices provided in or with the Software.
|
|
70
|
+
|
|
71
|
+
### Disclaimer
|
|
72
|
+
|
|
73
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EXPRESS OR
|
|
74
|
+
IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR
|
|
75
|
+
PURPOSE, MERCHANTABILITY, TITLE OR NON-INFRINGEMENT.
|
|
76
|
+
|
|
77
|
+
IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO THE
|
|
78
|
+
SOFTWARE, INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES,
|
|
79
|
+
EVEN IF WE HAVE BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
|
|
80
|
+
|
|
81
|
+
### Trademarks
|
|
82
|
+
|
|
83
|
+
Except for displaying the License Details and identifying us as the origin of
|
|
84
|
+
the Software, you have no right under these Terms and Conditions to use our
|
|
85
|
+
trademarks, trade names, service marks or product names.
|
|
86
|
+
|
|
87
|
+
## Grant of Future License
|
|
88
|
+
|
|
89
|
+
We hereby irrevocably grant you an additional license to use the Software under
|
|
90
|
+
the MIT license that is effective on the second anniversary of the date we make
|
|
91
|
+
the Software available. On or after that date, you may use the Software under
|
|
92
|
+
the MIT license, in which case the following will apply:
|
|
93
|
+
|
|
94
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
95
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
96
|
+
the Software without restriction, including without limitation the rights to
|
|
97
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
98
|
+
of the Software, and to permit persons to whom the Software is furnished to do
|
|
99
|
+
so, subject to the following conditions:
|
|
100
|
+
|
|
101
|
+
The above copyright notice and this permission notice shall be included in all
|
|
102
|
+
copies or substantial portions of the Software.
|
|
103
|
+
|
|
104
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
105
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
106
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
107
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
108
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
109
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
110
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# caretaker-cli
|
|
2
|
+
|
|
3
|
+
Caretaker — an in-process AI agent harness with a TUI, a local web GUI, headless runs, and a scheduler. Bring your own OpenAI-compatible key (or use a `claude-code` provider). File-based state under `~/.caretaker/`, no database.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -g @hyperwindmill/caretaker-cli
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
caretaker-cli # launch the TUI
|
|
15
|
+
caretaker-cli web # local web GUI on http://127.0.0.1:3000
|
|
16
|
+
caretaker-cli run "…" --agent <name> # headless run
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
State (providers, agents, sessions, plugins, MCP, scheduler) lives under `~/.caretaker/` (override with `CARETAKER_HOME`).
|
|
20
|
+
|
|
21
|
+
## License
|
|
22
|
+
|
|
23
|
+
[FSL-1.1-MIT](./LICENSE) — Functional Source License, converts to MIT.
|
|
24
|
+
|
|
25
|
+
Source, issues, and full docs: <https://github.com/Hyperwindmill/caretaker-cli>
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { ToolContext } from '../harness/tools/types.js';
|
|
2
|
+
import type { AgentConfig } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Compute the effective AgentConfig the invoked agent will run as. Empty
|
|
5
|
+
* runtime fields fall back to the caller's; the systemPrompt is always the
|
|
6
|
+
* invoked agent's own (overriding it would defeat the point of dispatch).
|
|
7
|
+
*
|
|
8
|
+
* Inheritance is per-invocation only — the result is never persisted back
|
|
9
|
+
* into agents.json. `maxTurns` is intentionally NOT inherited; the invoked
|
|
10
|
+
* agent's value (or the AgentConfig default) is fine.
|
|
11
|
+
*/
|
|
12
|
+
export declare function effectiveAgent(invoked: AgentConfig, caller: AgentConfig | undefined): AgentConfig;
|
|
13
|
+
export interface DispatchResult {
|
|
14
|
+
/** Final assistant text the invoked agent produced. Empty string when the
|
|
15
|
+
* child finished without text (e.g. tool-loop ran out of turns). */
|
|
16
|
+
text: string;
|
|
17
|
+
/** "done" | "max_turns" | "aborted" — mirrors loop.RunResult.stop. */
|
|
18
|
+
stop: 'done' | 'max_turns' | 'aborted';
|
|
19
|
+
/** True when the child halted because of the recursion / self-invoke
|
|
20
|
+
* guard. The caller renders this as `Error: ...` in the tool result. */
|
|
21
|
+
guardError?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface DispatchOptions {
|
|
24
|
+
invoked: AgentConfig;
|
|
25
|
+
task: string;
|
|
26
|
+
ctx: ToolContext;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Run the invoked agent one-shot with the task as its only user message
|
|
30
|
+
* and return its final assistant text. No history is replayed — the child
|
|
31
|
+
* starts fresh. The parent's confirm gate and abort signal are inherited
|
|
32
|
+
* via ToolContext so the user keeps authority over the child's tool calls.
|
|
33
|
+
*/
|
|
34
|
+
export declare function dispatchAgent(opts: DispatchOptions): Promise<DispatchResult>;
|
|
35
|
+
//# sourceMappingURL=dispatch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dispatch.d.ts","sourceRoot":"","sources":["../../src/agents/dispatch.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAQ,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAI/C;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,WAAW,GAAG,SAAS,GAAG,WAAW,CAcjG;AAED,MAAM,WAAW,cAAc;IAC7B;yEACqE;IACrE,IAAI,EAAE,MAAM,CAAC;IACb,sEAAsE;IACtE,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,CAAC;IACvC;6EACyE;IACzE,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,WAAW,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,WAAW,CAAC;CAClB;AAED;;;;;GAKG;AACH,wBAAsB,aAAa,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,cAAc,CAAC,CA2ElF"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
// Sub-agent dispatch: an agent in the loop can invoke another configured
|
|
2
|
+
// agent as a one-shot tool. The invoked agent runs in a re-entry of
|
|
3
|
+
// `harness/loop.run` with its own (effective) AgentConfig. Empty runtime
|
|
4
|
+
// fields on the invoked agent inherit from the caller — see
|
|
5
|
+
// `effectiveAgent` below for the exact rule. The final assistant text is
|
|
6
|
+
// returned to the caller as a Tool result string.
|
|
7
|
+
import { run as runLoop } from '../harness/loop.js';
|
|
8
|
+
import { resolveAgentTools } from '../harness/tools/index.js';
|
|
9
|
+
import { tools as registry } from '../harness/tools/instance.js';
|
|
10
|
+
import { loadConfig } from '../store/json.js';
|
|
11
|
+
const MAX_DISPATCH_DEPTH = 5;
|
|
12
|
+
/**
|
|
13
|
+
* Compute the effective AgentConfig the invoked agent will run as. Empty
|
|
14
|
+
* runtime fields fall back to the caller's; the systemPrompt is always the
|
|
15
|
+
* invoked agent's own (overriding it would defeat the point of dispatch).
|
|
16
|
+
*
|
|
17
|
+
* Inheritance is per-invocation only — the result is never persisted back
|
|
18
|
+
* into agents.json. `maxTurns` is intentionally NOT inherited; the invoked
|
|
19
|
+
* agent's value (or the AgentConfig default) is fine.
|
|
20
|
+
*/
|
|
21
|
+
export function effectiveAgent(invoked, caller) {
|
|
22
|
+
if (!caller)
|
|
23
|
+
return invoked;
|
|
24
|
+
const inheritArr = (child, parent) => child !== undefined && child.length > 0 ? child : parent;
|
|
25
|
+
return {
|
|
26
|
+
...invoked,
|
|
27
|
+
provider: invoked.provider || caller.provider,
|
|
28
|
+
model: invoked.model || caller.model,
|
|
29
|
+
allowedTools: invoked.allowedTools.length > 0 ? invoked.allowedTools : caller.allowedTools,
|
|
30
|
+
confirmTools: inheritArr(invoked.confirmTools, caller.confirmTools),
|
|
31
|
+
plugins: inheritArr(invoked.plugins, caller.plugins),
|
|
32
|
+
mcpServers: inheritArr(invoked.mcpServers, caller.mcpServers),
|
|
33
|
+
workingDir: invoked.workingDir || caller.workingDir,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Run the invoked agent one-shot with the task as its only user message
|
|
38
|
+
* and return its final assistant text. No history is replayed — the child
|
|
39
|
+
* starts fresh. The parent's confirm gate and abort signal are inherited
|
|
40
|
+
* via ToolContext so the user keeps authority over the child's tool calls.
|
|
41
|
+
*/
|
|
42
|
+
export async function dispatchAgent(opts) {
|
|
43
|
+
const caller = opts.ctx.callerAgent;
|
|
44
|
+
if (caller && caller.id === opts.invoked.id) {
|
|
45
|
+
return { text: '', stop: 'done', guardError: 'agent cannot invoke itself' };
|
|
46
|
+
}
|
|
47
|
+
const depth = (opts.ctx.dispatchDepth ?? 0) + 1;
|
|
48
|
+
if (depth > MAX_DISPATCH_DEPTH) {
|
|
49
|
+
return {
|
|
50
|
+
text: '',
|
|
51
|
+
stop: 'done',
|
|
52
|
+
guardError: `dispatch depth exceeded (${MAX_DISPATCH_DEPTH})`,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
const effective = effectiveAgent(opts.invoked, caller);
|
|
56
|
+
if (!effective.provider) {
|
|
57
|
+
return {
|
|
58
|
+
text: '',
|
|
59
|
+
stop: 'done',
|
|
60
|
+
guardError: 'invoked agent has no provider and the caller does not either',
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
let providers;
|
|
64
|
+
try {
|
|
65
|
+
providers = (await loadConfig()).providers;
|
|
66
|
+
}
|
|
67
|
+
catch (err) {
|
|
68
|
+
return {
|
|
69
|
+
text: '',
|
|
70
|
+
stop: 'done',
|
|
71
|
+
guardError: `failed to load providers: ${err instanceof Error ? err.message : String(err)}`,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
const provider = providers.find((p) => p.name === effective.provider);
|
|
75
|
+
if (!provider) {
|
|
76
|
+
return {
|
|
77
|
+
text: '',
|
|
78
|
+
stop: 'done',
|
|
79
|
+
guardError: `provider "${effective.provider}" is not configured`,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
let tools;
|
|
83
|
+
try {
|
|
84
|
+
tools = await resolveAgentTools(effective, registry);
|
|
85
|
+
}
|
|
86
|
+
catch (err) {
|
|
87
|
+
return {
|
|
88
|
+
text: '',
|
|
89
|
+
stop: 'done',
|
|
90
|
+
guardError: `failed to resolve tools: ${err instanceof Error ? err.message : String(err)}`,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
const result = await runLoop({
|
|
94
|
+
agent: effective,
|
|
95
|
+
provider,
|
|
96
|
+
tools,
|
|
97
|
+
prompt: opts.task,
|
|
98
|
+
// No history — sub-agent invocation is one-shot.
|
|
99
|
+
signal: opts.ctx.signal,
|
|
100
|
+
workingDir: effective.workingDir ?? opts.ctx.workingDir,
|
|
101
|
+
dispatchDepth: depth,
|
|
102
|
+
}, {
|
|
103
|
+
// Pass the parent's confirm gate down so the user still gates child
|
|
104
|
+
// tool calls.
|
|
105
|
+
confirmTool: opts.ctx.confirmTool,
|
|
106
|
+
});
|
|
107
|
+
return { text: result.text, stop: result.stop };
|
|
108
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reconcile agents.json with plugins.json. For every plugin with an
|
|
3
|
+
* `agents` manifest entry, ensure a corresponding managed AgentConfig
|
|
4
|
+
* exists (created if missing, refreshed in place if present). Managed rows
|
|
5
|
+
* whose source plugin or manifest entry has disappeared are removed.
|
|
6
|
+
*
|
|
7
|
+
* User-authored agents (no `pluginId`) are never touched. Idempotent.
|
|
8
|
+
*/
|
|
9
|
+
export declare function syncManagedAgents(): Promise<void>;
|
|
10
|
+
//# sourceMappingURL=sync.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../../src/agents/sync.ts"],"names":[],"mappings":"AAoEA;;;;;;;GAOG;AACH,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC,CAoCvD"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
// Reconcile agents.json with plugin-declared agent specs. Mirrors
|
|
2
|
+
// src/mcp/server_manager.syncManagedMcpServers but for AgentConfig rows.
|
|
3
|
+
//
|
|
4
|
+
// Field policy across re-syncs:
|
|
5
|
+
// - manifest-owned (rewritten every time): name, systemPrompt
|
|
6
|
+
// - user-controlled (preserved across syncs): provider, model,
|
|
7
|
+
// allowedTools, confirmTools, plugins, mcpServers, workingDir, maxTurns
|
|
8
|
+
// - first-create only: provider defaults to the first configured provider,
|
|
9
|
+
// model defaults to the frontmatter `model:` literal (or "")
|
|
10
|
+
//
|
|
11
|
+
// Frontmatter `tools:` is intentionally dropped — its vocabulary is
|
|
12
|
+
// Anthropic's tool surface, ours is a different namespace, and silent
|
|
13
|
+
// remapping would grant or deny tools incorrectly. The user wires
|
|
14
|
+
// allowedTools via the agent form after the row is materialized.
|
|
15
|
+
import { randomUUID } from 'node:crypto';
|
|
16
|
+
import { loadAgents, loadConfig, loadPlugins, saveAgents } from '../store/json.js';
|
|
17
|
+
function managedRowKey(pluginId, scopedName) {
|
|
18
|
+
return `${pluginId}::${scopedName}`;
|
|
19
|
+
}
|
|
20
|
+
async function defaultProviderName() {
|
|
21
|
+
try {
|
|
22
|
+
const cfg = await loadConfig();
|
|
23
|
+
return cfg.providers[0]?.name ?? '';
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
return '';
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function buildManagedAgent(plugin, scopedName, spec, defaultProvider) {
|
|
30
|
+
return {
|
|
31
|
+
id: randomUUID(),
|
|
32
|
+
name: `${plugin.name}/${scopedName}`,
|
|
33
|
+
systemPrompt: spec.systemPrompt,
|
|
34
|
+
provider: defaultProvider,
|
|
35
|
+
model: spec.model ?? '',
|
|
36
|
+
allowedTools: [],
|
|
37
|
+
maxTurns: 30,
|
|
38
|
+
pluginId: plugin.id,
|
|
39
|
+
pluginScopedName: scopedName,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function applySpecToManagedAgent(existing, plugin, scopedName, spec) {
|
|
43
|
+
// Only the manifest-owned fields are rewritten. Everything the user can
|
|
44
|
+
// touch via the form is left untouched.
|
|
45
|
+
return {
|
|
46
|
+
...existing,
|
|
47
|
+
name: `${plugin.name}/${scopedName}`,
|
|
48
|
+
systemPrompt: spec.systemPrompt,
|
|
49
|
+
pluginId: plugin.id,
|
|
50
|
+
pluginScopedName: scopedName,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Reconcile agents.json with plugins.json. For every plugin with an
|
|
55
|
+
* `agents` manifest entry, ensure a corresponding managed AgentConfig
|
|
56
|
+
* exists (created if missing, refreshed in place if present). Managed rows
|
|
57
|
+
* whose source plugin or manifest entry has disappeared are removed.
|
|
58
|
+
*
|
|
59
|
+
* User-authored agents (no `pluginId`) are never touched. Idempotent.
|
|
60
|
+
*/
|
|
61
|
+
export async function syncManagedAgents() {
|
|
62
|
+
const pluginsFile = await loadPlugins();
|
|
63
|
+
const agents = await loadAgents();
|
|
64
|
+
const expected = new Map();
|
|
65
|
+
for (const plugin of pluginsFile.plugins) {
|
|
66
|
+
if (!plugin.agents)
|
|
67
|
+
continue;
|
|
68
|
+
for (const [scopedName, spec] of Object.entries(plugin.agents)) {
|
|
69
|
+
expected.set(managedRowKey(plugin.id, scopedName), { plugin, scopedName, spec });
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
const out = [];
|
|
73
|
+
const seen = new Set();
|
|
74
|
+
for (const a of agents) {
|
|
75
|
+
if (!a.pluginId) {
|
|
76
|
+
out.push(a); // user-authored, leave alone
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
const key = managedRowKey(a.pluginId, a.pluginScopedName ?? '');
|
|
80
|
+
const exp = expected.get(key);
|
|
81
|
+
if (!exp)
|
|
82
|
+
continue; // managed but no longer expected — drop
|
|
83
|
+
seen.add(key);
|
|
84
|
+
out.push(applySpecToManagedAgent(a, exp.plugin, exp.scopedName, exp.spec));
|
|
85
|
+
}
|
|
86
|
+
if (expected.size > seen.size) {
|
|
87
|
+
const defaultProvider = await defaultProviderName();
|
|
88
|
+
for (const [key, exp] of expected) {
|
|
89
|
+
if (seen.has(key))
|
|
90
|
+
continue;
|
|
91
|
+
out.push(buildManagedAgent(exp.plugin, exp.scopedName, exp.spec, defaultProvider));
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
await saveAgents(out);
|
|
95
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AAcA,wBAAsB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAkD1D"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// CLI entry: dispatch based on argv.
|
|
2
|
+
// `caretaker` → render the Ink TUI (default)
|
|
3
|
+
// `caretaker run [prompt...]` → headless one-shot via the harness
|
|
4
|
+
// `caretaker --help|-h` → commander's help
|
|
5
|
+
//
|
|
6
|
+
// More subcommands (web, exec, session, agent, plugin, …) plug in
|
|
7
|
+
// alongside `run` via `program.command(…)`.
|
|
8
|
+
import { Command } from 'commander';
|
|
9
|
+
import { createElement } from 'react';
|
|
10
|
+
import { render } from 'ink';
|
|
11
|
+
import App from '../tui/app.js';
|
|
12
|
+
import { runCommand } from './run.js';
|
|
13
|
+
export async function runCli(argv) {
|
|
14
|
+
// No subcommand and no flags → TUI. Anything else flows through commander
|
|
15
|
+
// so `--help`, `--version` and unknown-command diagnostics behave normally.
|
|
16
|
+
if (argv.length <= 2) {
|
|
17
|
+
// Wait for Ink to unmount (ESC / Quit call useApp().exit()), then force the
|
|
18
|
+
// process down. Without this the event loop stays alive on background boot
|
|
19
|
+
// handles (MCP pool, model-limits fetch, refresh-on-start) and the TUI
|
|
20
|
+
// appears frozen after exit until the user hits Ctrl+C.
|
|
21
|
+
const { waitUntilExit } = render(createElement(App));
|
|
22
|
+
await waitUntilExit();
|
|
23
|
+
process.exit(0);
|
|
24
|
+
}
|
|
25
|
+
const program = new Command();
|
|
26
|
+
program
|
|
27
|
+
.name('caretaker-cli')
|
|
28
|
+
.description('Caretaker — TUI agent harness with subcommands for scripting.');
|
|
29
|
+
program
|
|
30
|
+
.command('run [prompt...]')
|
|
31
|
+
.description('Run an agent headlessly with a one-shot prompt.')
|
|
32
|
+
.option('-a, --agent <name>', 'agent to run (auto-picks when exactly one exists)')
|
|
33
|
+
.option('-t, --tools <list>', "comma-separated tool names, overriding the agent's allowedTools")
|
|
34
|
+
.option('-o, --output <format>', 'output format: plain (streaming text) or json (final blob)', 'plain')
|
|
35
|
+
.action(async (promptParts, opts) => {
|
|
36
|
+
const prompt = (promptParts ?? []).join(' ').trim();
|
|
37
|
+
const code = await runCommand(prompt, opts);
|
|
38
|
+
process.exit(code);
|
|
39
|
+
});
|
|
40
|
+
program
|
|
41
|
+
.command('web')
|
|
42
|
+
.description('Launch the Caretaker web server local-first GUI.')
|
|
43
|
+
.option('-p, --port <number>', 'Port to listen on', '3000')
|
|
44
|
+
.option('-h, --host <string>', 'Host to bind to', '127.0.0.1')
|
|
45
|
+
.action(async (opts) => {
|
|
46
|
+
const { startServer } = await import('./web/server.js');
|
|
47
|
+
await startServer(parseInt(opts.port, 10), opts.host);
|
|
48
|
+
});
|
|
49
|
+
await program.parseAsync(argv);
|
|
50
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { AgentConfig } from '../types.js';
|
|
2
|
+
export type OutputFormat = 'plain' | 'json';
|
|
3
|
+
export interface RunOptions {
|
|
4
|
+
agent?: string;
|
|
5
|
+
tools?: string;
|
|
6
|
+
output?: OutputFormat;
|
|
7
|
+
}
|
|
8
|
+
export declare function selectAgent(agents: AgentConfig[], name: string | undefined): Promise<AgentConfig>;
|
|
9
|
+
export declare function parseToolsOverride(raw: string | undefined): string[] | null;
|
|
10
|
+
export declare function runCommand(prompt: string, opts: RunOptions): Promise<number>;
|
|
11
|
+
//# sourceMappingURL=run.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../src/cli/run.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,MAAM,CAAC;AAE5C,MAAM,WAAW,UAAU;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,YAAY,CAAC;CACvB;AAED,wBAAsB,WAAW,CAC/B,MAAM,EAAE,WAAW,EAAE,EACrB,IAAI,EAAE,MAAM,GAAG,SAAS,GACvB,OAAO,CAAC,WAAW,CAAC,CAetB;AAED,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,EAAE,GAAG,IAAI,CAM3E;AAED,wBAAsB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAyElF"}
|
package/dist/cli/run.js
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
// The `caretaker run` subcommand: one-shot headless invocation of an agent.
|
|
2
|
+
// Honors --agent (auto-picks when exactly one agent is configured),
|
|
3
|
+
// --tools (comma-separated allowedTools override), and --output (plain
|
|
4
|
+
// streaming text vs final JSON blob). Pure helpers (selectAgent,
|
|
5
|
+
// parseToolsOverride) are exported for unit tests.
|
|
6
|
+
import { loadAgents, loadConfig } from '../store/json.js';
|
|
7
|
+
import { run } from '../harness/loop.js';
|
|
8
|
+
import { tools as toolRegistry } from '../harness/tools/instance.js';
|
|
9
|
+
import { resolveAgentTools } from '../harness/tools/index.js';
|
|
10
|
+
export async function selectAgent(agents, name) {
|
|
11
|
+
if (name) {
|
|
12
|
+
const found = agents.find((a) => a.name === name);
|
|
13
|
+
if (!found) {
|
|
14
|
+
const names = agents.map((a) => a.name).join(', ') || '(none)';
|
|
15
|
+
throw new Error(`agent "${name}" not found. available: ${names}`);
|
|
16
|
+
}
|
|
17
|
+
return found;
|
|
18
|
+
}
|
|
19
|
+
if (agents.length === 0) {
|
|
20
|
+
throw new Error('no agents configured. open the TUI to create one.');
|
|
21
|
+
}
|
|
22
|
+
if (agents.length === 1)
|
|
23
|
+
return agents[0];
|
|
24
|
+
const names = agents.map((a) => a.name).join(', ');
|
|
25
|
+
throw new Error(`multiple agents configured (${names}). pick one with --agent <name>.`);
|
|
26
|
+
}
|
|
27
|
+
export function parseToolsOverride(raw) {
|
|
28
|
+
if (raw === undefined)
|
|
29
|
+
return null;
|
|
30
|
+
return raw
|
|
31
|
+
.split(',')
|
|
32
|
+
.map((s) => s.trim())
|
|
33
|
+
.filter((s) => s.length > 0);
|
|
34
|
+
}
|
|
35
|
+
export async function runCommand(prompt, opts) {
|
|
36
|
+
if (!prompt) {
|
|
37
|
+
process.stderr.write('error: prompt is required\n');
|
|
38
|
+
return 1;
|
|
39
|
+
}
|
|
40
|
+
const output = opts.output ?? 'plain';
|
|
41
|
+
if (output !== 'plain' && output !== 'json') {
|
|
42
|
+
process.stderr.write(`error: --output must be "plain" or "json", got "${output}"\n`);
|
|
43
|
+
return 1;
|
|
44
|
+
}
|
|
45
|
+
const [agents, config] = await Promise.all([loadAgents(), loadConfig()]);
|
|
46
|
+
let agent;
|
|
47
|
+
try {
|
|
48
|
+
agent = await selectAgent(agents, opts.agent);
|
|
49
|
+
}
|
|
50
|
+
catch (err) {
|
|
51
|
+
process.stderr.write(`error: ${err.message}\n`);
|
|
52
|
+
return 1;
|
|
53
|
+
}
|
|
54
|
+
const provider = config.providers.find((p) => p.name === agent.provider);
|
|
55
|
+
if (!provider) {
|
|
56
|
+
process.stderr.write(`error: agent "${agent.name}" references provider "${agent.provider}" which is missing\n`);
|
|
57
|
+
return 1;
|
|
58
|
+
}
|
|
59
|
+
const toolsOverride = parseToolsOverride(opts.tools);
|
|
60
|
+
const effective = toolsOverride === null ? agent : { ...agent, allowedTools: toolsOverride };
|
|
61
|
+
if (output === 'plain') {
|
|
62
|
+
process.stdout.write(`→ running "${effective.name}" (${effective.model} via ${provider.name})\n\n`);
|
|
63
|
+
}
|
|
64
|
+
const result = await run({
|
|
65
|
+
agent: effective,
|
|
66
|
+
provider,
|
|
67
|
+
tools: await resolveAgentTools(effective, toolRegistry),
|
|
68
|
+
prompt,
|
|
69
|
+
workingDir: effective.workingDir,
|
|
70
|
+
}, output === 'json'
|
|
71
|
+
? {}
|
|
72
|
+
: {
|
|
73
|
+
onChunk: (s) => process.stdout.write(s),
|
|
74
|
+
onToolCall: (_id, name, args) => process.stdout.write(`\n → tool ${name}(${JSON.stringify(args)})`),
|
|
75
|
+
onToolResult: (_id, content) => process.stdout.write(`\n ← ${content.slice(0, 200)}\n`),
|
|
76
|
+
});
|
|
77
|
+
if (output === 'json') {
|
|
78
|
+
process.stdout.write(JSON.stringify({
|
|
79
|
+
text: result.text,
|
|
80
|
+
toolCalls: result.toolCalls,
|
|
81
|
+
stop: result.stop,
|
|
82
|
+
usage: result.usage,
|
|
83
|
+
}) + '\n');
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
process.stdout.write(`\n\n[stop=${result.stop} tool_calls=${result.toolCalls} usage=${JSON.stringify(result.usage)}]\n`);
|
|
87
|
+
}
|
|
88
|
+
return result.stop === 'done' ? 0 : 2;
|
|
89
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fs.d.ts","sourceRoot":"","sources":["../../../src/cli/web/fs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAI5B,eAAO,MAAM,QAAQ,4EAAa,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Hono } from 'hono';
|
|
2
|
+
import { readdir } from 'node:fs/promises';
|
|
3
|
+
import { join, normalize, resolve } from 'node:path';
|
|
4
|
+
export const fsRouter = new Hono();
|
|
5
|
+
fsRouter.get('/ls', async (c) => {
|
|
6
|
+
try {
|
|
7
|
+
const rawPath = c.req.query('path');
|
|
8
|
+
// Default to root (/) or primary Windows drive (C:\) if path is omitted
|
|
9
|
+
let targetPath = rawPath ? resolve(normalize(rawPath)) : '/';
|
|
10
|
+
if (!rawPath && process.platform === 'win32') {
|
|
11
|
+
targetPath = 'C:\\';
|
|
12
|
+
}
|
|
13
|
+
const entries = await readdir(targetPath, { withFileTypes: true });
|
|
14
|
+
const directories = [];
|
|
15
|
+
for (const entry of entries) {
|
|
16
|
+
// Skip hidden folders starting with "." (e.g. .git, .vscode, .atl)
|
|
17
|
+
if (entry.isDirectory() && !entry.name.startsWith('.')) {
|
|
18
|
+
directories.push({
|
|
19
|
+
name: entry.name,
|
|
20
|
+
path: join(targetPath, entry.name),
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
// Sort folders alphabetically for better UX
|
|
25
|
+
directories.sort((a, b) => a.name.localeCompare(b.name));
|
|
26
|
+
return c.json({
|
|
27
|
+
currentPath: targetPath,
|
|
28
|
+
directories,
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
catch (err) {
|
|
32
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
33
|
+
return c.json({ error: msg, directories: [], currentPath: null }, 400);
|
|
34
|
+
}
|
|
35
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Hono } from 'hono';
|
|
2
|
+
export declare function issueBridgeToken(): string;
|
|
3
|
+
export declare function revokeBridgeToken(token: string): void;
|
|
4
|
+
export declare function setTaskBridgeUrl(url: string): void;
|
|
5
|
+
export declare function getTaskBridgeUrl(): string | null;
|
|
6
|
+
export declare function registerTaskBridge(app: Hono): void;
|
|
7
|
+
//# sourceMappingURL=mcp_bridge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp_bridge.d.ts","sourceRoot":"","sources":["../../../src/cli/web/mcp_bridge.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAWjC,wBAAgB,gBAAgB,IAAI,MAAM,CAIzC;AACD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAErD;AAGD,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAElD;AACD,wBAAgB,gBAAgB,IAAI,MAAM,GAAG,IAAI,CAEhD;AA6CD,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,IAAI,GAAG,IAAI,CAgBlD"}
|