tuplet 2.7.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 +21 -0
- package/README.md +136 -0
- package/dist/agent.d.ts +46 -0
- package/dist/agent.d.ts.map +1 -0
- package/dist/agent.js +393 -0
- package/dist/agent.js.map +1 -0
- package/dist/built-in-agents/explore.d.ts +9 -0
- package/dist/built-in-agents/explore.d.ts.map +1 -0
- package/dist/built-in-agents/explore.js +40 -0
- package/dist/built-in-agents/explore.js.map +1 -0
- package/dist/built-in-agents/index.d.ts +15 -0
- package/dist/built-in-agents/index.d.ts.map +1 -0
- package/dist/built-in-agents/index.js +19 -0
- package/dist/built-in-agents/index.js.map +1 -0
- package/dist/built-in-agents/plan.d.ts +10 -0
- package/dist/built-in-agents/plan.d.ts.map +1 -0
- package/dist/built-in-agents/plan.js +62 -0
- package/dist/built-in-agents/plan.js.map +1 -0
- package/dist/built-in-agents/worker.d.ts +9 -0
- package/dist/built-in-agents/worker.d.ts.map +1 -0
- package/dist/built-in-agents/worker.js +53 -0
- package/dist/built-in-agents/worker.js.map +1 -0
- package/dist/constants.d.ts +7 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +18 -0
- package/dist/constants.js.map +1 -0
- package/dist/context-manager.d.ts +65 -0
- package/dist/context-manager.d.ts.map +1 -0
- package/dist/context-manager.js +272 -0
- package/dist/context-manager.js.map +1 -0
- package/dist/context-manager.test.d.ts +2 -0
- package/dist/context-manager.test.d.ts.map +1 -0
- package/dist/context-manager.test.js +394 -0
- package/dist/context-manager.test.js.map +1 -0
- package/dist/executor.d.ts +29 -0
- package/dist/executor.d.ts.map +1 -0
- package/dist/executor.js +399 -0
- package/dist/executor.js.map +1 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +40 -0
- package/dist/index.js.map +1 -0
- package/dist/prompt/index.d.ts +9 -0
- package/dist/prompt/index.d.ts.map +1 -0
- package/dist/prompt/index.js +10 -0
- package/dist/prompt/index.js.map +1 -0
- package/dist/prompt/main-agent-builder.d.ts +81 -0
- package/dist/prompt/main-agent-builder.d.ts.map +1 -0
- package/dist/prompt/main-agent-builder.js +287 -0
- package/dist/prompt/main-agent-builder.js.map +1 -0
- package/dist/prompt/sub-agent-builder.d.ts +133 -0
- package/dist/prompt/sub-agent-builder.d.ts.map +1 -0
- package/dist/prompt/sub-agent-builder.js +337 -0
- package/dist/prompt/sub-agent-builder.js.map +1 -0
- package/dist/prompt/templates.d.ts +87 -0
- package/dist/prompt/templates.d.ts.map +1 -0
- package/dist/prompt/templates.js +343 -0
- package/dist/prompt/templates.js.map +1 -0
- package/dist/prompt/types.d.ts +159 -0
- package/dist/prompt/types.d.ts.map +1 -0
- package/dist/prompt/types.js +5 -0
- package/dist/prompt/types.js.map +1 -0
- package/dist/prompt.d.ts +32 -0
- package/dist/prompt.d.ts.map +1 -0
- package/dist/prompt.js +86 -0
- package/dist/prompt.js.map +1 -0
- package/dist/providers/dataset/base.d.ts +74 -0
- package/dist/providers/dataset/base.d.ts.map +1 -0
- package/dist/providers/dataset/base.js +7 -0
- package/dist/providers/dataset/base.js.map +1 -0
- package/dist/providers/dataset/index.d.ts +8 -0
- package/dist/providers/dataset/index.d.ts.map +1 -0
- package/dist/providers/dataset/index.js +8 -0
- package/dist/providers/dataset/index.js.map +1 -0
- package/dist/providers/dataset/recorder.d.ts +46 -0
- package/dist/providers/dataset/recorder.d.ts.map +1 -0
- package/dist/providers/dataset/recorder.js +105 -0
- package/dist/providers/dataset/recorder.js.map +1 -0
- package/dist/providers/dataset/replayer.d.ts +46 -0
- package/dist/providers/dataset/replayer.d.ts.map +1 -0
- package/dist/providers/dataset/replayer.js +163 -0
- package/dist/providers/dataset/replayer.js.map +1 -0
- package/dist/providers/dataset/tester.d.ts +89 -0
- package/dist/providers/dataset/tester.d.ts.map +1 -0
- package/dist/providers/dataset/tester.js +143 -0
- package/dist/providers/dataset/tester.js.map +1 -0
- package/dist/providers/env/memory.d.ts +14 -0
- package/dist/providers/env/memory.d.ts.map +1 -0
- package/dist/providers/env/memory.js +19 -0
- package/dist/providers/env/memory.js.map +1 -0
- package/dist/providers/index.d.ts +12 -0
- package/dist/providers/index.d.ts.map +1 -0
- package/dist/providers/index.js +10 -0
- package/dist/providers/index.js.map +1 -0
- package/dist/providers/llm/base.d.ts +7 -0
- package/dist/providers/llm/base.d.ts.map +1 -0
- package/dist/providers/llm/base.js +7 -0
- package/dist/providers/llm/base.js.map +1 -0
- package/dist/providers/llm/claude.d.ts +32 -0
- package/dist/providers/llm/claude.d.ts.map +1 -0
- package/dist/providers/llm/claude.js +171 -0
- package/dist/providers/llm/claude.js.map +1 -0
- package/dist/providers/llm/openai.d.ts +26 -0
- package/dist/providers/llm/openai.d.ts.map +1 -0
- package/dist/providers/llm/openai.js +174 -0
- package/dist/providers/llm/openai.js.map +1 -0
- package/dist/providers/llm/openrouter.d.ts +43 -0
- package/dist/providers/llm/openrouter.d.ts.map +1 -0
- package/dist/providers/llm/openrouter.js +288 -0
- package/dist/providers/llm/openrouter.js.map +1 -0
- package/dist/providers/logger/base.d.ts +7 -0
- package/dist/providers/logger/base.d.ts.map +1 -0
- package/dist/providers/logger/base.js +7 -0
- package/dist/providers/logger/base.js.map +1 -0
- package/dist/providers/logger/console.d.ts +29 -0
- package/dist/providers/logger/console.d.ts.map +1 -0
- package/dist/providers/logger/console.js +70 -0
- package/dist/providers/logger/console.js.map +1 -0
- package/dist/providers/repository/base.d.ts +7 -0
- package/dist/providers/repository/base.d.ts.map +1 -0
- package/dist/providers/repository/base.js +7 -0
- package/dist/providers/repository/base.js.map +1 -0
- package/dist/providers/repository/memory.d.ts +21 -0
- package/dist/providers/repository/memory.d.ts.map +1 -0
- package/dist/providers/repository/memory.js +50 -0
- package/dist/providers/repository/memory.js.map +1 -0
- package/dist/providers/workspace/file.d.ts +26 -0
- package/dist/providers/workspace/file.d.ts.map +1 -0
- package/dist/providers/workspace/file.js +151 -0
- package/dist/providers/workspace/file.js.map +1 -0
- package/dist/providers/workspace/index.d.ts +7 -0
- package/dist/providers/workspace/index.d.ts.map +1 -0
- package/dist/providers/workspace/index.js +6 -0
- package/dist/providers/workspace/index.js.map +1 -0
- package/dist/providers/workspace/memory.d.ts +26 -0
- package/dist/providers/workspace/memory.d.ts.map +1 -0
- package/dist/providers/workspace/memory.js +136 -0
- package/dist/providers/workspace/memory.js.map +1 -0
- package/dist/providers/workspace/types.d.ts +27 -0
- package/dist/providers/workspace/types.d.ts.map +1 -0
- package/dist/providers/workspace/types.js +8 -0
- package/dist/providers/workspace/types.js.map +1 -0
- package/dist/providers/workspace/workspace-provider.test.d.ts +2 -0
- package/dist/providers/workspace/workspace-provider.test.d.ts.map +1 -0
- package/dist/providers/workspace/workspace-provider.test.js +250 -0
- package/dist/providers/workspace/workspace-provider.test.js.map +1 -0
- package/dist/shell/commands/browse.d.ts +6 -0
- package/dist/shell/commands/browse.d.ts.map +1 -0
- package/dist/shell/commands/browse.js +158 -0
- package/dist/shell/commands/browse.js.map +1 -0
- package/dist/shell/commands/cat.d.ts +6 -0
- package/dist/shell/commands/cat.d.ts.map +1 -0
- package/dist/shell/commands/cat.js +104 -0
- package/dist/shell/commands/cat.js.map +1 -0
- package/dist/shell/commands/curl.d.ts +6 -0
- package/dist/shell/commands/curl.d.ts.map +1 -0
- package/dist/shell/commands/curl.js +190 -0
- package/dist/shell/commands/curl.js.map +1 -0
- package/dist/shell/commands/date.d.ts +6 -0
- package/dist/shell/commands/date.d.ts.map +1 -0
- package/dist/shell/commands/date.js +151 -0
- package/dist/shell/commands/date.js.map +1 -0
- package/dist/shell/commands/echo.d.ts +6 -0
- package/dist/shell/commands/echo.d.ts.map +1 -0
- package/dist/shell/commands/echo.js +48 -0
- package/dist/shell/commands/echo.js.map +1 -0
- package/dist/shell/commands/env.d.ts +8 -0
- package/dist/shell/commands/env.d.ts.map +1 -0
- package/dist/shell/commands/env.js +41 -0
- package/dist/shell/commands/env.js.map +1 -0
- package/dist/shell/commands/file.d.ts +6 -0
- package/dist/shell/commands/file.d.ts.map +1 -0
- package/dist/shell/commands/file.js +213 -0
- package/dist/shell/commands/file.js.map +1 -0
- package/dist/shell/commands/find.d.ts +6 -0
- package/dist/shell/commands/find.d.ts.map +1 -0
- package/dist/shell/commands/find.js +100 -0
- package/dist/shell/commands/find.js.map +1 -0
- package/dist/shell/commands/grep.d.ts +6 -0
- package/dist/shell/commands/grep.d.ts.map +1 -0
- package/dist/shell/commands/grep.js +229 -0
- package/dist/shell/commands/grep.js.map +1 -0
- package/dist/shell/commands/head.d.ts +6 -0
- package/dist/shell/commands/head.d.ts.map +1 -0
- package/dist/shell/commands/head.js +88 -0
- package/dist/shell/commands/head.js.map +1 -0
- package/dist/shell/commands/index.d.ts +25 -0
- package/dist/shell/commands/index.d.ts.map +1 -0
- package/dist/shell/commands/index.js +43 -0
- package/dist/shell/commands/index.js.map +1 -0
- package/dist/shell/commands/jq.d.ts +8 -0
- package/dist/shell/commands/jq.d.ts.map +1 -0
- package/dist/shell/commands/jq.js +233 -0
- package/dist/shell/commands/jq.js.map +1 -0
- package/dist/shell/commands/ls.d.ts +6 -0
- package/dist/shell/commands/ls.d.ts.map +1 -0
- package/dist/shell/commands/ls.js +88 -0
- package/dist/shell/commands/ls.js.map +1 -0
- package/dist/shell/commands/mkdir.d.ts +6 -0
- package/dist/shell/commands/mkdir.d.ts.map +1 -0
- package/dist/shell/commands/mkdir.js +43 -0
- package/dist/shell/commands/mkdir.js.map +1 -0
- package/dist/shell/commands/rm.d.ts +6 -0
- package/dist/shell/commands/rm.d.ts.map +1 -0
- package/dist/shell/commands/rm.js +64 -0
- package/dist/shell/commands/rm.js.map +1 -0
- package/dist/shell/commands/sed.d.ts +6 -0
- package/dist/shell/commands/sed.d.ts.map +1 -0
- package/dist/shell/commands/sed.js +414 -0
- package/dist/shell/commands/sed.js.map +1 -0
- package/dist/shell/commands/sort.d.ts +6 -0
- package/dist/shell/commands/sort.d.ts.map +1 -0
- package/dist/shell/commands/sort.js +109 -0
- package/dist/shell/commands/sort.js.map +1 -0
- package/dist/shell/commands/tail.d.ts +6 -0
- package/dist/shell/commands/tail.d.ts.map +1 -0
- package/dist/shell/commands/tail.js +68 -0
- package/dist/shell/commands/tail.js.map +1 -0
- package/dist/shell/commands/wc.d.ts +6 -0
- package/dist/shell/commands/wc.d.ts.map +1 -0
- package/dist/shell/commands/wc.js +86 -0
- package/dist/shell/commands/wc.js.map +1 -0
- package/dist/shell/index.d.ts +10 -0
- package/dist/shell/index.d.ts.map +1 -0
- package/dist/shell/index.js +10 -0
- package/dist/shell/index.js.map +1 -0
- package/dist/shell/limits.d.ts +5 -0
- package/dist/shell/limits.d.ts.map +1 -0
- package/dist/shell/limits.js +5 -0
- package/dist/shell/limits.js.map +1 -0
- package/dist/shell/parser.d.ts +8 -0
- package/dist/shell/parser.d.ts.map +1 -0
- package/dist/shell/parser.js +307 -0
- package/dist/shell/parser.js.map +1 -0
- package/dist/shell/path-validation.d.ts +35 -0
- package/dist/shell/path-validation.d.ts.map +1 -0
- package/dist/shell/path-validation.js +81 -0
- package/dist/shell/path-validation.js.map +1 -0
- package/dist/shell/shell.d.ts +66 -0
- package/dist/shell/shell.d.ts.map +1 -0
- package/dist/shell/shell.js +301 -0
- package/dist/shell/shell.js.map +1 -0
- package/dist/shell/shell.test.d.ts +2 -0
- package/dist/shell/shell.test.d.ts.map +1 -0
- package/dist/shell/shell.test.js +1088 -0
- package/dist/shell/shell.test.js.map +1 -0
- package/dist/shell/types.d.ts +82 -0
- package/dist/shell/types.d.ts.map +1 -0
- package/dist/shell/types.js +5 -0
- package/dist/shell/types.js.map +1 -0
- package/dist/summarizer.d.ts +28 -0
- package/dist/summarizer.d.ts.map +1 -0
- package/dist/summarizer.js +136 -0
- package/dist/summarizer.js.map +1 -0
- package/dist/summarizer.test.d.ts +2 -0
- package/dist/summarizer.test.d.ts.map +1 -0
- package/dist/summarizer.test.js +192 -0
- package/dist/summarizer.test.js.map +1 -0
- package/dist/tools/ask-user.d.ts +11 -0
- package/dist/tools/ask-user.d.ts.map +1 -0
- package/dist/tools/ask-user.js +35 -0
- package/dist/tools/ask-user.js.map +1 -0
- package/dist/tools/index.d.ts +11 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +18 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/output.d.ts +15 -0
- package/dist/tools/output.d.ts.map +1 -0
- package/dist/tools/output.js +40 -0
- package/dist/tools/output.js.map +1 -0
- package/dist/tools/shell.d.ts +13 -0
- package/dist/tools/shell.d.ts.map +1 -0
- package/dist/tools/shell.js +166 -0
- package/dist/tools/shell.js.map +1 -0
- package/dist/tools/sub-agent.d.ts +25 -0
- package/dist/tools/sub-agent.d.ts.map +1 -0
- package/dist/tools/sub-agent.js +312 -0
- package/dist/tools/sub-agent.js.map +1 -0
- package/dist/tools/tasks.d.ts +170 -0
- package/dist/tools/tasks.d.ts.map +1 -0
- package/dist/tools/tasks.js +947 -0
- package/dist/tools/tasks.js.map +1 -0
- package/dist/trace/builder.d.ts +54 -0
- package/dist/trace/builder.d.ts.map +1 -0
- package/dist/trace/builder.js +229 -0
- package/dist/trace/builder.js.map +1 -0
- package/dist/trace/console.d.ts +45 -0
- package/dist/trace/console.d.ts.map +1 -0
- package/dist/trace/console.js +143 -0
- package/dist/trace/console.js.map +1 -0
- package/dist/trace/index.d.ts +11 -0
- package/dist/trace/index.d.ts.map +1 -0
- package/dist/trace/index.js +11 -0
- package/dist/trace/index.js.map +1 -0
- package/dist/trace/openrouter-pricing.d.ts +9 -0
- package/dist/trace/openrouter-pricing.d.ts.map +1 -0
- package/dist/trace/openrouter-pricing.js +321 -0
- package/dist/trace/openrouter-pricing.js.map +1 -0
- package/dist/trace/pricing.d.ts +13 -0
- package/dist/trace/pricing.d.ts.map +1 -0
- package/dist/trace/pricing.js +41 -0
- package/dist/trace/pricing.js.map +1 -0
- package/dist/trace/types.d.ts +142 -0
- package/dist/trace/types.d.ts.map +1 -0
- package/dist/trace/types.js +16 -0
- package/dist/trace/types.js.map +1 -0
- package/dist/trace.d.ts +5 -0
- package/dist/trace.d.ts.map +1 -0
- package/dist/trace.js +5 -0
- package/dist/trace.js.map +1 -0
- package/dist/types.d.ts +382 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +5 -0
- package/dist/types.js.map +1 -0
- package/dist/workspace.d.ts +287 -0
- package/dist/workspace.d.ts.map +1 -0
- package/dist/workspace.js +560 -0
- package/dist/workspace.js.map +1 -0
- package/package.json +47 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Aleksandr Netrebskii
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
# Tuplet
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/tuplet)
|
|
4
|
+
[](https://github.com/anetrebskii/hive-agent/actions)
|
|
5
|
+
[](https://github.com/anetrebskii/hive-agent/blob/main/LICENSE)
|
|
6
|
+
[](https://www.typescriptlang.org/)
|
|
7
|
+
[](https://discord.gg/WrZhA6wfdr)
|
|
8
|
+
|
|
9
|
+
**Claude Code-like AI agent for your own application. Add a few lines — get a multi-agent system that asks clarifying questions, plans tasks, and works with your data.**
|
|
10
|
+
|
|
11
|
+
Claude Code is impressive: you open a terminal, ask it to code something, and it plans, clarifies, executes. But it's locked to the terminal and local filesystem. What if you need that same intelligence inside your SaaS product, web app, or serverless function — working with your database, your blob storage, your users' data?
|
|
12
|
+
|
|
13
|
+
Tuplet gives you exactly that. A powerful, multi-agent framework you plug into your application. Your users get an AI that feels custom-built. You get a library that handles the hard parts.
|
|
14
|
+
|
|
15
|
+
## You Need Tuplet If
|
|
16
|
+
|
|
17
|
+
- You want your own AI agent in your app that codes, manages documents, or works with any workspace you share with it
|
|
18
|
+
- You're building on Firebase, Vercel, AWS Lambda, or any serverless platform — Tuplet is stateless by design
|
|
19
|
+
- You're building a SaaS and want to give users a smart AI chat without building an agent framework from scratch
|
|
20
|
+
- Your data lives in databases, blob storage, or APIs — not just the local filesystem
|
|
21
|
+
- You want Claude Code-level intelligence but inside a web application, without VMs or infrastructure to manage
|
|
22
|
+
- You don't want to spend time teaching AI how to work well — Tuplet handles planning, task tracking, clarifying questions, and tool use out of the box
|
|
23
|
+
|
|
24
|
+
## Features
|
|
25
|
+
|
|
26
|
+
### Agent Intelligence
|
|
27
|
+
|
|
28
|
+
- **Built-in planning & exploration sub-agents** — AI plans its work before executing, just like Claude Code
|
|
29
|
+
- **Task generation & tracking** — AI generates tasks and follows them, showing progress in real time
|
|
30
|
+
- **Clarifying questions** — AI asks one question or a series of questions when it needs more context
|
|
31
|
+
- **Interruption mode** — Correct the AI mid-execution if it goes in the wrong direction, just like Claude Code
|
|
32
|
+
- **Optimized built-in prompts** — Carefully tuned prompts for better results across all providers
|
|
33
|
+
|
|
34
|
+
### Built-in Capabilities
|
|
35
|
+
|
|
36
|
+
- **Workspace** — Like projects in Claude Code. Tuplet works with workspace files (virtual or real) the same way Claude Code works with your project
|
|
37
|
+
- **Large file processing** — AI reads files >256KB in chunks, just like Claude Code does
|
|
38
|
+
- **Web browsing** — Navigate websites, extract data, interact with pages
|
|
39
|
+
- **API requests with authentication** — Make HTTP requests to external services
|
|
40
|
+
|
|
41
|
+
### Multi-Provider
|
|
42
|
+
|
|
43
|
+
- **Claude** (Anthropic) — First-class support with caching and extended thinking
|
|
44
|
+
- **OpenAI** — GPT-4o and other models
|
|
45
|
+
- **OpenRouter** — Access to 100+ models via [openrouter.ai](https://openrouter.ai), with optimized prompts so non-Claude models use built-in tools effectively
|
|
46
|
+
- **Custom providers** — Implement the `LLMProvider` interface to use any AI model
|
|
47
|
+
|
|
48
|
+
### Cost & Performance
|
|
49
|
+
|
|
50
|
+
- **Prompt caching** — Up to 90% cost reduction with Claude's prompt caching
|
|
51
|
+
- **Chat history summarization** — Automatic summarization of long conversations to stay within context limits
|
|
52
|
+
- **Execution tracing** — Full cost breakdown per request, per model, per sub-agent
|
|
53
|
+
|
|
54
|
+
### Production-Ready
|
|
55
|
+
|
|
56
|
+
- **Stateless design** — Works in Firebase Functions, AWS Lambda, any serverless environment
|
|
57
|
+
- **Conversation history management** — Automatic load/save with pluggable repository providers
|
|
58
|
+
- **Secrets management** — Keep credentials for external systems outside AI context. AI can use them without seeing actual values
|
|
59
|
+
- **Interruption & cancellation** — AbortController support, Firestore-based stop signals, graceful partial results
|
|
60
|
+
|
|
61
|
+
### Extensibility
|
|
62
|
+
|
|
63
|
+
- **Custom tools** — Define any tool with typed parameters and execution logic
|
|
64
|
+
- **Custom sub-agents** — Spawn specialized agents with their own tools, prompts, and even different LLM providers
|
|
65
|
+
- **Pluggable storage** — Bring your own chat history provider (Firestore, Redis, Postgres, anything)
|
|
66
|
+
- **Pluggable logging & tracing** — Integrate with Datadog, custom dashboards, or any observability platform
|
|
67
|
+
- **Pluggable workspaces** — Virtual file systems, database-backed storage, or real file system
|
|
68
|
+
|
|
69
|
+
## Tuplet vs LangChain.js
|
|
70
|
+
|
|
71
|
+
| | **Tuplet** | **LangChain.js** |
|
|
72
|
+
|---|---|---|
|
|
73
|
+
| **Runtime dependencies** | 1 | 11+ (core) + per-provider packages |
|
|
74
|
+
| **Setup** | `new Tuplet({ tools, llm })` — one object, done | Chains, Runnables, LCEL, Memory, Agents — multiple abstractions to learn |
|
|
75
|
+
| **Planning & task tracking** | Built-in, works out of the box | Requires separate `@langchain/langgraph` package |
|
|
76
|
+
| **Clarifying questions** | Built-in | Not included — build your own |
|
|
77
|
+
| **Serverless** | Stateless by design — drop into Lambda/Firebase as-is | Requires external state management and architectural changes |
|
|
78
|
+
| **Multi-provider** | Claude, OpenAI, OpenRouter (100+ models), custom | 50+ providers via separate packages |
|
|
79
|
+
| **Prompt caching** | Built-in for Claude (up to 90% cost savings) | Not built-in |
|
|
80
|
+
| **Best for** | Production apps that need an embedded AI agent | Prototyping, RAG pipelines, complex LLM orchestration |
|
|
81
|
+
|
|
82
|
+
**When to choose LangChain:** You need a massive ecosystem of integrations (vector stores, retrievers, 50+ providers) or are building complex RAG pipelines with many data sources.
|
|
83
|
+
|
|
84
|
+
**When to choose Tuplet:** You want a production-ready agent in your app without the abstraction overhead. One dependency, stateless, works in serverless — and your users get planning, task tracking, and clarifying questions out of the box.
|
|
85
|
+
|
|
86
|
+
## Installation
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
npm install tuplet
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
pnpm add tuplet
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## Quick Start
|
|
97
|
+
|
|
98
|
+
```typescript
|
|
99
|
+
import { Tuplet, ClaudeProvider } from 'tuplet'
|
|
100
|
+
|
|
101
|
+
const agent = new Tuplet({
|
|
102
|
+
role: 'a helpful assistant',
|
|
103
|
+
tools: [myTool],
|
|
104
|
+
llm: new ClaudeProvider({ apiKey: process.env.ANTHROPIC_API_KEY })
|
|
105
|
+
})
|
|
106
|
+
|
|
107
|
+
const result = await agent.run('Hello!')
|
|
108
|
+
console.log(result.response)
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## Examples
|
|
112
|
+
|
|
113
|
+
- [**Coder**](https://github.com/anetrebskii/hive-agent/tree/main/examples/coder) — AI software developer that creates projects from scratch using built-in shell, workspace, planning, and task tracking. Zero custom tools.
|
|
114
|
+
- [**Eating Consultant**](https://github.com/anetrebskii/hive-agent/tree/main/examples/eating-consultant) — Nutrition assistant with custom tools (OpenFoodFacts API), sub-agents (meal planner), workspace persistence, and run recording.
|
|
115
|
+
|
|
116
|
+
## Documentation
|
|
117
|
+
|
|
118
|
+
- [Quick Start](https://github.com/anetrebskii/hive-agent/blob/main/docs/README.md)
|
|
119
|
+
- [Tools](https://github.com/anetrebskii/hive-agent/blob/main/docs/tools.md)
|
|
120
|
+
- [Sub-Agents](https://github.com/anetrebskii/hive-agent/blob/main/docs/sub-agents.md)
|
|
121
|
+
- [Workspace](https://github.com/anetrebskii/hive-agent/blob/main/docs/workspace.md)
|
|
122
|
+
- [Secrets](https://github.com/anetrebskii/hive-agent/blob/main/docs/secrets.md)
|
|
123
|
+
- [Providers](https://github.com/anetrebskii/hive-agent/blob/main/docs/providers.md)
|
|
124
|
+
- [History](https://github.com/anetrebskii/hive-agent/blob/main/docs/history.md)
|
|
125
|
+
- [Interactive Questions](https://github.com/anetrebskii/hive-agent/blob/main/docs/interactive.md)
|
|
126
|
+
- [Interruption](https://github.com/anetrebskii/hive-agent/blob/main/docs/interruption.md)
|
|
127
|
+
- [Plan Mode](https://github.com/anetrebskii/hive-agent/blob/main/docs/plan-mode.md)
|
|
128
|
+
- [Task Management](https://github.com/anetrebskii/hive-agent/blob/main/docs/task-management.md)
|
|
129
|
+
- [Progress Status](https://github.com/anetrebskii/hive-agent/blob/main/docs/progress-status.md)
|
|
130
|
+
- [Logger](https://github.com/anetrebskii/hive-agent/blob/main/docs/logger.md)
|
|
131
|
+
- [Tracing](https://github.com/anetrebskii/hive-agent/blob/main/docs/tracing.md)
|
|
132
|
+
- [Run Recording](https://github.com/anetrebskii/hive-agent/blob/main/docs/run-recording.md)
|
|
133
|
+
|
|
134
|
+
## License
|
|
135
|
+
|
|
136
|
+
MIT
|
package/dist/agent.d.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tuplet Agent
|
|
3
|
+
*
|
|
4
|
+
* Main agent class that orchestrates tool execution, sub-agents, and workspace management.
|
|
5
|
+
*/
|
|
6
|
+
import type { TupletConfig, RunOptions, AgentResult } from "./types.js";
|
|
7
|
+
import { TraceBuilder } from "./trace.js";
|
|
8
|
+
/** Path where the plan is stored in workspace (relative) */
|
|
9
|
+
export declare const PLAN_PATH = ".tuplet/plan.md";
|
|
10
|
+
export { TASK_SCOPE_INSTRUCTIONS } from "./constants.js";
|
|
11
|
+
/**
|
|
12
|
+
* Tuplet Agent Class
|
|
13
|
+
*/
|
|
14
|
+
export declare class Tuplet {
|
|
15
|
+
readonly config: TupletConfig;
|
|
16
|
+
private contextManager;
|
|
17
|
+
private tools;
|
|
18
|
+
/** Auto-generated system prompt */
|
|
19
|
+
private systemPrompt;
|
|
20
|
+
/** Current trace builder (set during run, used by __sub_agent__ tool) */
|
|
21
|
+
private currentTraceBuilder?;
|
|
22
|
+
constructor(config: TupletConfig);
|
|
23
|
+
/**
|
|
24
|
+
* Build system prompt from config.description using MainAgentBuilder.
|
|
25
|
+
* If _systemPrompt is set (sub-agent internal), use it directly.
|
|
26
|
+
*/
|
|
27
|
+
private buildSystemPrompt;
|
|
28
|
+
/**
|
|
29
|
+
* Get the current trace builder (used by __sub_agent__ tool for sub-agent tracing)
|
|
30
|
+
*/
|
|
31
|
+
getCurrentTraceBuilder(): TraceBuilder | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* Set the current trace builder (called at start of run)
|
|
34
|
+
*/
|
|
35
|
+
setCurrentTraceBuilder(builder: TraceBuilder | undefined): void;
|
|
36
|
+
/**
|
|
37
|
+
* Get tools including internal tools for a specific run.
|
|
38
|
+
* In plan mode, only a restricted set of tools is returned.
|
|
39
|
+
*/
|
|
40
|
+
private getRunTools;
|
|
41
|
+
/**
|
|
42
|
+
* Run the agent with a user message
|
|
43
|
+
*/
|
|
44
|
+
run(message: string, options?: RunOptions): Promise<AgentResult>;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=agent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,YAAY,EAGZ,UAAU,EACV,WAAW,EAEZ,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAe1C,4DAA4D;AAC5D,eAAO,MAAM,SAAS,oBAAoB,CAAC;AAG3C,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AA4CzD;;GAEG;AACH,qBAAa,MAAM;IACjB,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,OAAO,CAAC,cAAc,CAAiB;IACvC,OAAO,CAAC,KAAK,CAAS;IACtB,mCAAmC;IACnC,OAAO,CAAC,YAAY,CAAS;IAC7B,yEAAyE;IACzE,OAAO,CAAC,mBAAmB,CAAC,CAAe;gBAE/B,MAAM,EAAE,YAAY;IAsDhC;;;OAGG;IACH,OAAO,CAAC,iBAAiB;IAmBzB;;OAEG;IACH,sBAAsB,IAAI,YAAY,GAAG,SAAS;IAIlD;;OAEG;IACH,sBAAsB,CAAC,OAAO,EAAE,YAAY,GAAG,SAAS,GAAG,IAAI;IAI/D;;;OAGG;IACH,OAAO,CAAC,WAAW;IA6DnB;;OAEG;IACG,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,UAAe,GAAG,OAAO,CAAC,WAAW,CAAC;CAuP3E"}
|
package/dist/agent.js
ADDED
|
@@ -0,0 +1,393 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tuplet Agent
|
|
3
|
+
*
|
|
4
|
+
* Main agent class that orchestrates tool execution, sub-agents, and workspace management.
|
|
5
|
+
*/
|
|
6
|
+
import { ContextManager } from "./context-manager.js";
|
|
7
|
+
import { executeLoop } from "./executor.js";
|
|
8
|
+
import { TraceBuilder } from "./trace.js";
|
|
9
|
+
import { Workspace } from "./workspace.js";
|
|
10
|
+
import { createShellTool } from "./tools/shell.js";
|
|
11
|
+
import { createAskUserTool, createTaskTool as createSubAgentTool, TaskManager, createTaskTools, createTaskGetTool, createTaskListTool, } from "./tools/index.js";
|
|
12
|
+
import { getBuiltInAgents } from "./built-in-agents/index.js";
|
|
13
|
+
import { MainAgentBuilder } from "./prompt/main-agent-builder.js";
|
|
14
|
+
import { TASK_SCOPE_INSTRUCTIONS } from "./constants.js";
|
|
15
|
+
/** Path where the plan is stored in workspace (relative) */
|
|
16
|
+
export const PLAN_PATH = ".tuplet/plan.md";
|
|
17
|
+
// Re-export for public API
|
|
18
|
+
export { TASK_SCOPE_INSTRUCTIONS } from "./constants.js";
|
|
19
|
+
/** System prompt prepended in plan mode */
|
|
20
|
+
const PLAN_MODE_INSTRUCTIONS = `# Plan Mode
|
|
21
|
+
|
|
22
|
+
You are in **plan mode**. Your job is to understand the current state, then write a plan.
|
|
23
|
+
|
|
24
|
+
## Workflow
|
|
25
|
+
|
|
26
|
+
1. **Explore first** — Use the \`explore\` sub-agent to discover what data and state currently exists. This is mandatory before writing a plan.
|
|
27
|
+
2. **Formulate requirements** — Synthesize exploration findings into a structured brief:
|
|
28
|
+
- Context: current state and exploration findings
|
|
29
|
+
- Goal: what the user wants to achieve
|
|
30
|
+
- Affected areas: workspace paths and components involved
|
|
31
|
+
- Constraints: limitations and dependencies
|
|
32
|
+
- Success criteria: how to verify completion
|
|
33
|
+
3. **Write the plan** — Using the structured requirements as input, save your plan to \`${PLAN_PATH}\` using the shell.
|
|
34
|
+
|
|
35
|
+
## Rules
|
|
36
|
+
|
|
37
|
+
- **Read-only**: The shell is in read-only mode. You cannot create, modify, or delete files except the plan file.
|
|
38
|
+
- **Explore before planning**: Always launch the \`explore\` agent first to understand what exists. Do not skip this step.
|
|
39
|
+
- **Allowed tools**: shell (read-only), \`explore\` and \`plan\` sub-agents, TaskList, TaskGet, __ask_user__.
|
|
40
|
+
- **Write your plan**:
|
|
41
|
+
\`\`\`
|
|
42
|
+
cat << 'EOF' > ${PLAN_PATH}
|
|
43
|
+
# Plan
|
|
44
|
+
...your plan here...
|
|
45
|
+
EOF
|
|
46
|
+
\`\`\`
|
|
47
|
+
- When your plan is complete, tell the user and summarize it.
|
|
48
|
+
|
|
49
|
+
`;
|
|
50
|
+
/** User message injected at start of execute mode when a plan exists */
|
|
51
|
+
function planContextMessage(planContent) {
|
|
52
|
+
return `The following plan was created during the planning phase. Use it as guidance for your implementation. Follow the plan steps and mark tasks as completed as you finish them.
|
|
53
|
+
|
|
54
|
+
<plan>
|
|
55
|
+
${planContent}
|
|
56
|
+
</plan>`;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Tuplet Agent Class
|
|
60
|
+
*/
|
|
61
|
+
export class Tuplet {
|
|
62
|
+
config;
|
|
63
|
+
contextManager;
|
|
64
|
+
tools;
|
|
65
|
+
/** Auto-generated system prompt */
|
|
66
|
+
systemPrompt;
|
|
67
|
+
/** Current trace builder (set during run, used by __sub_agent__ tool) */
|
|
68
|
+
currentTraceBuilder;
|
|
69
|
+
constructor(config) {
|
|
70
|
+
this.config = {
|
|
71
|
+
maxIterations: 50,
|
|
72
|
+
maxContextTokens: 100000,
|
|
73
|
+
contextStrategy: "summarize",
|
|
74
|
+
...config,
|
|
75
|
+
};
|
|
76
|
+
this.contextManager = new ContextManager(this.config.maxContextTokens, this.config.contextStrategy, this.config.llm, this.config.compactBuffer);
|
|
77
|
+
// Build tools list with internal tools (todo tool added per-run)
|
|
78
|
+
this.tools = [...config.tools];
|
|
79
|
+
// Add __ask_user__ tool unless disabled (sub-agents shouldn't use it)
|
|
80
|
+
if (!config.disableAskUser) {
|
|
81
|
+
this.tools.push(createAskUserTool());
|
|
82
|
+
}
|
|
83
|
+
// Auto-merge built-in agents only when agents is not explicitly set.
|
|
84
|
+
// If agents is explicitly provided (even as []), respect that — no auto-injection.
|
|
85
|
+
// This prevents sub-agents from recursively spawning their own sub-agents.
|
|
86
|
+
if (!('agents' in config)) {
|
|
87
|
+
const builtIn = getBuiltInAgents();
|
|
88
|
+
this.config.agents = [...builtIn];
|
|
89
|
+
}
|
|
90
|
+
else if (config.agents && config.agents.length > 0) {
|
|
91
|
+
const builtIn = getBuiltInAgents();
|
|
92
|
+
const userAgentNames = new Set(config.agents.map((a) => a.name));
|
|
93
|
+
const newAgents = builtIn.filter((a) => !userAgentNames.has(a.name));
|
|
94
|
+
this.config.agents = [...config.agents, ...newAgents];
|
|
95
|
+
}
|
|
96
|
+
// Build system prompt from description (after agents are merged)
|
|
97
|
+
this.systemPrompt = this.buildSystemPrompt();
|
|
98
|
+
// Add __sub_agent__ tool if sub-agents are defined
|
|
99
|
+
if (this.config.agents && this.config.agents.length > 0) {
|
|
100
|
+
this.tools.push(createSubAgentTool({
|
|
101
|
+
config: this.config,
|
|
102
|
+
getCurrentTraceBuilder: () => this.getCurrentTraceBuilder(),
|
|
103
|
+
}, this.config.agents, (subConfig) => new Tuplet(subConfig)));
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Build system prompt from config.description using MainAgentBuilder.
|
|
108
|
+
* If _systemPrompt is set (sub-agent internal), use it directly.
|
|
109
|
+
*/
|
|
110
|
+
buildSystemPrompt() {
|
|
111
|
+
if (this.config._systemPrompt) {
|
|
112
|
+
return this.config._systemPrompt;
|
|
113
|
+
}
|
|
114
|
+
const builder = new MainAgentBuilder()
|
|
115
|
+
.role(this.config.role)
|
|
116
|
+
.skipBuiltInAgents();
|
|
117
|
+
if (this.config.agents?.length) {
|
|
118
|
+
builder.agents(this.config.agents);
|
|
119
|
+
}
|
|
120
|
+
if (this.config.tools?.length) {
|
|
121
|
+
builder.tools(this.config.tools);
|
|
122
|
+
}
|
|
123
|
+
return builder.build();
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Get the current trace builder (used by __sub_agent__ tool for sub-agent tracing)
|
|
127
|
+
*/
|
|
128
|
+
getCurrentTraceBuilder() {
|
|
129
|
+
return this.currentTraceBuilder;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Set the current trace builder (called at start of run)
|
|
133
|
+
*/
|
|
134
|
+
setCurrentTraceBuilder(builder) {
|
|
135
|
+
this.currentTraceBuilder = builder;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Get tools including internal tools for a specific run.
|
|
139
|
+
* In plan mode, only a restricted set of tools is returned.
|
|
140
|
+
*/
|
|
141
|
+
getRunTools(taskManager, workspace, agentName, mode) {
|
|
142
|
+
const taskToolOptions = {
|
|
143
|
+
logger: this.config.logger,
|
|
144
|
+
agentName,
|
|
145
|
+
workspace,
|
|
146
|
+
};
|
|
147
|
+
if (mode === "plan") {
|
|
148
|
+
// Plan mode: restricted tool set
|
|
149
|
+
const planTools = [];
|
|
150
|
+
// __ask_user__ (if not disabled)
|
|
151
|
+
const askUser = this.tools.find((t) => t.name === "__ask_user__");
|
|
152
|
+
if (askUser) {
|
|
153
|
+
planTools.push(askUser);
|
|
154
|
+
}
|
|
155
|
+
// __sub_agent__ restricted to explore + plan agents only
|
|
156
|
+
const subAgentTool = this.tools.find((t) => t.name === "__sub_agent__");
|
|
157
|
+
if (subAgentTool) {
|
|
158
|
+
// Create a wrapper that only allows explore and plan agents
|
|
159
|
+
planTools.push({
|
|
160
|
+
...subAgentTool,
|
|
161
|
+
execute: async (params, context) => {
|
|
162
|
+
const agentParam = params.agent;
|
|
163
|
+
if (agentParam !== "explore" && agentParam !== "plan") {
|
|
164
|
+
return {
|
|
165
|
+
success: false,
|
|
166
|
+
error: `Plan mode: only 'explore' and 'plan' sub-agents are allowed. Got: '${agentParam}'`,
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
return subAgentTool.execute(params, context);
|
|
170
|
+
},
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
// TaskList and TaskGet only (no TaskCreate, TaskUpdate)
|
|
174
|
+
planTools.push(createTaskListTool(taskManager, taskToolOptions));
|
|
175
|
+
planTools.push(createTaskGetTool(taskManager, taskToolOptions));
|
|
176
|
+
// Shell (already in read-only mode via setReadOnly)
|
|
177
|
+
planTools.push(createShellTool(workspace.getShell()));
|
|
178
|
+
return planTools;
|
|
179
|
+
}
|
|
180
|
+
// Default / execute mode: all tools
|
|
181
|
+
return [
|
|
182
|
+
...this.tools,
|
|
183
|
+
...createTaskTools(taskManager, taskToolOptions),
|
|
184
|
+
createShellTool(workspace.getShell()),
|
|
185
|
+
];
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Run the agent with a user message
|
|
189
|
+
*/
|
|
190
|
+
async run(message, options = {}) {
|
|
191
|
+
const { conversationId, userId, history: providedHistory, signal, shouldContinue, workspace, mode, } = options;
|
|
192
|
+
// Load history from repository or use provided
|
|
193
|
+
let history = [];
|
|
194
|
+
if (providedHistory) {
|
|
195
|
+
history = providedHistory;
|
|
196
|
+
}
|
|
197
|
+
else if (conversationId && this.config.repository) {
|
|
198
|
+
history = await this.config.repository.getHistory(conversationId);
|
|
199
|
+
}
|
|
200
|
+
// Handle history with pending tool_use blocks (from interrupted executions)
|
|
201
|
+
const messages = [...history];
|
|
202
|
+
const lastMessage = messages[messages.length - 1];
|
|
203
|
+
// Detect if we're resuming from an interrupted execution (__ask_user__ pause etc.)
|
|
204
|
+
// This is true when the last message is assistant with pending tool_use blocks.
|
|
205
|
+
let isResuming = false;
|
|
206
|
+
// Check if last message is assistant with tool_use blocks that need results
|
|
207
|
+
if (lastMessage?.role === "assistant" &&
|
|
208
|
+
Array.isArray(lastMessage.content)) {
|
|
209
|
+
const toolUseBlocks = lastMessage.content.filter((block) => block.type === "tool_use");
|
|
210
|
+
if (toolUseBlocks.length > 0) {
|
|
211
|
+
isResuming = true;
|
|
212
|
+
// Find __ask_user__ tool if present
|
|
213
|
+
const askUserToolUse = toolUseBlocks.find((block) => block.name === "__ask_user__");
|
|
214
|
+
// Build tool_results for all tool_use blocks
|
|
215
|
+
const toolResults = toolUseBlocks.map((toolUse) => {
|
|
216
|
+
if (toolUse.name === "__ask_user__") {
|
|
217
|
+
// User's message is the answer to __ask_user__
|
|
218
|
+
return {
|
|
219
|
+
type: "tool_result",
|
|
220
|
+
tool_use_id: toolUse.id,
|
|
221
|
+
content: JSON.stringify({
|
|
222
|
+
success: true,
|
|
223
|
+
data: { answer: message },
|
|
224
|
+
}),
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
else {
|
|
228
|
+
// Other tools were interrupted - mark as cancelled
|
|
229
|
+
return {
|
|
230
|
+
type: "tool_result",
|
|
231
|
+
tool_use_id: toolUse.id,
|
|
232
|
+
content: JSON.stringify({
|
|
233
|
+
success: false,
|
|
234
|
+
error: "Operation cancelled - execution was interrupted",
|
|
235
|
+
}),
|
|
236
|
+
is_error: true,
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
// If there was an __ask_user__, the user's message is already the answer
|
|
241
|
+
// Otherwise, we need to include both the tool_results and the user message
|
|
242
|
+
if (askUserToolUse) {
|
|
243
|
+
messages.push({ role: "user", content: toolResults });
|
|
244
|
+
}
|
|
245
|
+
else {
|
|
246
|
+
// Combine tool_results and user message in a single user message
|
|
247
|
+
// (API doesn't allow consecutive user messages)
|
|
248
|
+
messages.push({
|
|
249
|
+
role: "user",
|
|
250
|
+
content: [...toolResults, { type: "text", text: message }],
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
else {
|
|
255
|
+
// No tool_use blocks, normal user message
|
|
256
|
+
messages.push({ role: "user", content: message });
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
else {
|
|
260
|
+
// Normal user message
|
|
261
|
+
messages.push({ role: "user", content: message });
|
|
262
|
+
}
|
|
263
|
+
// Ensure workspace always exists (create default if not provided)
|
|
264
|
+
const ws = workspace ?? new Workspace();
|
|
265
|
+
await ws.init();
|
|
266
|
+
// Capture existing plan content before cleanup (for prompt injection)
|
|
267
|
+
const existingPlan = await ws.read(PLAN_PATH);
|
|
268
|
+
const hasExistingPlan = !!existingPlan && typeof existingPlan === "string";
|
|
269
|
+
// Always delete old plan file — each run starts clean.
|
|
270
|
+
// The content is already captured above for prompt injection.
|
|
271
|
+
if (hasExistingPlan) {
|
|
272
|
+
await ws.delete(PLAN_PATH);
|
|
273
|
+
}
|
|
274
|
+
// Set environment provider if provided
|
|
275
|
+
if (options.env) {
|
|
276
|
+
ws.setEnvProvider(options.env);
|
|
277
|
+
}
|
|
278
|
+
// Configure shell read-only mode based on mode option
|
|
279
|
+
const shell = ws.getShell();
|
|
280
|
+
if (mode === "plan") {
|
|
281
|
+
// Plan mode: read-only shell, only allow writing to the plan file
|
|
282
|
+
shell.setReadOnly(true, [PLAN_PATH]);
|
|
283
|
+
}
|
|
284
|
+
else {
|
|
285
|
+
shell.setReadOnly(false);
|
|
286
|
+
}
|
|
287
|
+
// Create task manager for this run.
|
|
288
|
+
// Only restore from workspace when resuming from a pause (e.g., __ask_user__) —
|
|
289
|
+
// detected by pending tool_use blocks in the last history message.
|
|
290
|
+
// On a normal run (even with conversation history), start with a clean task list.
|
|
291
|
+
const taskManager = new TaskManager();
|
|
292
|
+
if (isResuming) {
|
|
293
|
+
await taskManager.restoreFromWorkspace(ws);
|
|
294
|
+
}
|
|
295
|
+
else {
|
|
296
|
+
await ws.delete(".tuplet/tasks.json");
|
|
297
|
+
}
|
|
298
|
+
// Create tool context
|
|
299
|
+
const toolContext = {
|
|
300
|
+
remainingTokens: this.contextManager.getRemainingTokens(),
|
|
301
|
+
conversationId,
|
|
302
|
+
userId,
|
|
303
|
+
workspace: ws,
|
|
304
|
+
};
|
|
305
|
+
// Create or use existing trace builder
|
|
306
|
+
// If _traceBuilder is passed (from parent agent), use it
|
|
307
|
+
// Otherwise create a new one if trace provider is configured
|
|
308
|
+
const traceBuilder = options._traceBuilder ||
|
|
309
|
+
(this.config.trace
|
|
310
|
+
? new TraceBuilder(this.config.agentName || "agent", this.config.trace, message // Pass input message to trace
|
|
311
|
+
)
|
|
312
|
+
: undefined);
|
|
313
|
+
// Store trace builder for __sub_agent__ tool to access
|
|
314
|
+
this.setCurrentTraceBuilder(traceBuilder);
|
|
315
|
+
// Build system prompt based on mode
|
|
316
|
+
let systemPrompt = this.systemPrompt;
|
|
317
|
+
if (mode === "plan") {
|
|
318
|
+
systemPrompt = PLAN_MODE_INSTRUCTIONS + systemPrompt;
|
|
319
|
+
}
|
|
320
|
+
// Inject plan content as a user message (not system prompt) to preserve cache
|
|
321
|
+
if (mode === "execute" && hasExistingPlan) {
|
|
322
|
+
messages.unshift({ role: "user", content: planContextMessage(existingPlan) });
|
|
323
|
+
messages.splice(1, 0, { role: "assistant", content: "I'll follow this plan." });
|
|
324
|
+
}
|
|
325
|
+
// Inject task scope + built-in tool guidance into system prompt
|
|
326
|
+
systemPrompt += `\n\n${TASK_SCOPE_INSTRUCTIONS}
|
|
327
|
+
|
|
328
|
+
### Asking the User
|
|
329
|
+
When you need information the user hasn't provided and you cannot find it via other tools, call __ask_user__ with 1-4 questions. Each question should include relevant options. Do NOT ask for information already in the conversation or in workspace data.`;
|
|
330
|
+
// Execute the agent loop — wrapped in try/finally to guarantee history is saved
|
|
331
|
+
// on any outcome: complete, interrupted, error, or unexpected crash.
|
|
332
|
+
let result;
|
|
333
|
+
try {
|
|
334
|
+
result = await executeLoop({
|
|
335
|
+
systemPrompt,
|
|
336
|
+
tools: this.getRunTools(taskManager, ws, this.config.agentName, mode),
|
|
337
|
+
llm: this.config.llm,
|
|
338
|
+
logger: this.config.logger,
|
|
339
|
+
maxIterations: this.config.maxIterations,
|
|
340
|
+
contextManager: this.contextManager,
|
|
341
|
+
taskManager,
|
|
342
|
+
llmOptions: {},
|
|
343
|
+
signal,
|
|
344
|
+
shouldContinue,
|
|
345
|
+
traceBuilder,
|
|
346
|
+
}, messages, toolContext);
|
|
347
|
+
}
|
|
348
|
+
catch (error) {
|
|
349
|
+
// Unexpected crash — build an error result from current messages
|
|
350
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
351
|
+
this.config.logger?.error("Execution loop crashed", error);
|
|
352
|
+
result = {
|
|
353
|
+
response: '',
|
|
354
|
+
history: messages,
|
|
355
|
+
toolCalls: [],
|
|
356
|
+
status: 'error',
|
|
357
|
+
error: errorMessage,
|
|
358
|
+
};
|
|
359
|
+
}
|
|
360
|
+
finally {
|
|
361
|
+
// Always save history — complete, interrupted, error, or crash
|
|
362
|
+
if (conversationId && this.config.repository) {
|
|
363
|
+
try {
|
|
364
|
+
const historyToSave = result?.history ?? messages;
|
|
365
|
+
await this.config.repository.saveHistory(conversationId, historyToSave);
|
|
366
|
+
}
|
|
367
|
+
catch (saveError) {
|
|
368
|
+
this.config.logger?.warn("Failed to save history", saveError);
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
// End trace and attach to result (only for root agent, not sub-agents)
|
|
373
|
+
if (traceBuilder && !options._traceBuilder) {
|
|
374
|
+
const status = result.status === "error"
|
|
375
|
+
? "error"
|
|
376
|
+
: result.status === "interrupted"
|
|
377
|
+
? "interrupted"
|
|
378
|
+
: "complete";
|
|
379
|
+
result.trace = traceBuilder.endTrace(status, result.response);
|
|
380
|
+
}
|
|
381
|
+
// Record the run (only for root agent, not sub-agents)
|
|
382
|
+
if (this.config.recorder && !options._traceBuilder) {
|
|
383
|
+
try {
|
|
384
|
+
await this.config.recorder.record(message, history, this.config, result);
|
|
385
|
+
}
|
|
386
|
+
catch (error) {
|
|
387
|
+
this.config.logger?.warn("Failed to record run", error);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
return result;
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
//# sourceMappingURL=agent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent.js","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAUH,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EACL,iBAAiB,EACjB,cAAc,IAAI,kBAAkB,EACpC,WAAW,EACX,eAAe,EACf,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAEzD,4DAA4D;AAC5D,MAAM,CAAC,MAAM,SAAS,GAAG,iBAAiB,CAAC;AAE3C,2BAA2B;AAC3B,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAEzD,2CAA2C;AAC3C,MAAM,sBAAsB,GAAG;;;;;;;;;;;;;0FAa2D,SAAS;;;;;;;;;mBAShF,SAAS;;;;;;;CAO3B,CAAC;AAEF,wEAAwE;AACxE,SAAS,kBAAkB,CAAC,WAAmB;I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AC,MAAM,CAAC,QAAQ,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC;YACnD,IAAI,CAAC;gBACH,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAC/B,OAAO,EACP,OAAO,EACP,IAAI,CAAC,MAAM,EACX,MAAM,CACP,CAAC;YACJ,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,sBAAsB,EAAE,KAAK,CAAC,CAAC;YAC1D,CAAC;QACH,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Explore Agent
|
|
3
|
+
*
|
|
4
|
+
* Fast, read-only agent for investigating workspace data.
|
|
5
|
+
* Uses shell commands to explore the workspace virtual filesystem.
|
|
6
|
+
*/
|
|
7
|
+
import type { SubAgentConfig } from '../types.js';
|
|
8
|
+
export declare const exploreAgent: SubAgentConfig;
|
|
9
|
+
//# sourceMappingURL=explore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"explore.d.ts","sourceRoot":"","sources":["../../src/built-in-agents/explore.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAGjD,eAAO,MAAM,YAAY,EAAE,cA+B1B,CAAA"}
|