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
|
@@ -0,0 +1,40 @@
|
|
|
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 { TASK_SCOPE_INSTRUCTIONS } from '../constants.js';
|
|
8
|
+
export const exploreAgent = {
|
|
9
|
+
name: 'explore',
|
|
10
|
+
description: 'Fast, read-only agent for exploring workspace data. Use when you need to search, list, or read workspace entries before taking action.',
|
|
11
|
+
systemPrompt: `You are a workspace exploration specialist. Read-only — NO writes, NO redirects (>, >>).
|
|
12
|
+
|
|
13
|
+
All paths are relative. NEVER use absolute paths starting with /.
|
|
14
|
+
|
|
15
|
+
## Method
|
|
16
|
+
1. Run \`ls\` to see top-level structure
|
|
17
|
+
2. Look at the path NAMES returned. Ask: does this path name relate to the caller's request?
|
|
18
|
+
3. ONLY explore paths whose names are relevant. Ignore everything else.
|
|
19
|
+
4. If no paths are relevant, respond immediately: "No relevant data found in workspace." STOP.
|
|
20
|
+
|
|
21
|
+
## Commands
|
|
22
|
+
- \`ls path/\` — list entries
|
|
23
|
+
- \`cat path/file\` — read a file
|
|
24
|
+
- \`grep "keyword" path/**/*\` — search content
|
|
25
|
+
- \`find path -name "*.json"\` — find by pattern
|
|
26
|
+
|
|
27
|
+
## STRICT RULES — violations waste iterations
|
|
28
|
+
- NEVER read a file unless its name/path clearly relates to the request
|
|
29
|
+
- NEVER do broad searches across the entire workspace (grep -r with wide patterns)
|
|
30
|
+
- If \`ls\` returns paths like \`game/\`, \`novel.txt\`, \`images/\` and the request is about "funding data" — NONE of those are relevant. Say "no relevant data" and STOP
|
|
31
|
+
- If you find nothing after 2-3 targeted checks, say "nothing found" and STOP. Do not keep looking
|
|
32
|
+
- Make parallel calls when checking multiple paths
|
|
33
|
+
|
|
34
|
+
${TASK_SCOPE_INSTRUCTIONS}`,
|
|
35
|
+
tools: [],
|
|
36
|
+
disableAskUser: true,
|
|
37
|
+
builtInToolNames: ['shell (read-only workspace access)'],
|
|
38
|
+
maxIterations: 15,
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=explore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"explore.js","sourceRoot":"","sources":["../../src/built-in-agents/explore.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAA;AAEzD,MAAM,CAAC,MAAM,YAAY,GAAmB;IAC1C,IAAI,EAAE,SAAS;IACf,WAAW,EAAE,wIAAwI;IACrJ,YAAY,EAAE;;;;;;;;;;;;;;;;;;;;;;;EAuBd,uBAAuB,EAAE;IACzB,KAAK,EAAE,EAAE;IACT,cAAc,EAAE,IAAI;IACpB,gBAAgB,EAAE,CAAC,oCAAoC,CAAC;IACxD,aAAa,EAAE,EAAE;CAClB,CAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Built-in Agents
|
|
3
|
+
*
|
|
4
|
+
* Agents that are always available. Cannot be disabled.
|
|
5
|
+
*/
|
|
6
|
+
import type { SubAgentConfig } from '../types.js';
|
|
7
|
+
export { exploreAgent } from './explore.js';
|
|
8
|
+
export { planAgent } from './plan.js';
|
|
9
|
+
export { workerAgent } from './worker.js';
|
|
10
|
+
/**
|
|
11
|
+
* Get all built-in agents.
|
|
12
|
+
* Returns agents that are always auto-injected into every Tuplet.
|
|
13
|
+
*/
|
|
14
|
+
export declare function getBuiltInAgents(): SubAgentConfig[];
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/built-in-agents/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAKjD,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AACrC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAEzC;;;GAGG;AACH,wBAAgB,gBAAgB,IAAI,cAAc,EAAE,CAEnD"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Built-in Agents
|
|
3
|
+
*
|
|
4
|
+
* Agents that are always available. Cannot be disabled.
|
|
5
|
+
*/
|
|
6
|
+
import { exploreAgent } from './explore.js';
|
|
7
|
+
import { planAgent } from './plan.js';
|
|
8
|
+
import { workerAgent } from './worker.js';
|
|
9
|
+
export { exploreAgent } from './explore.js';
|
|
10
|
+
export { planAgent } from './plan.js';
|
|
11
|
+
export { workerAgent } from './worker.js';
|
|
12
|
+
/**
|
|
13
|
+
* Get all built-in agents.
|
|
14
|
+
* Returns agents that are always auto-injected into every Tuplet.
|
|
15
|
+
*/
|
|
16
|
+
export function getBuiltInAgents() {
|
|
17
|
+
return [exploreAgent, planAgent, workerAgent];
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/built-in-agents/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AACrC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAEzC,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AACrC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAEzC;;;GAGG;AACH,MAAM,UAAU,gBAAgB;IAC9B,OAAO,CAAC,YAAY,EAAE,SAAS,EAAE,WAAW,CAAC,CAAA;AAC/C,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plan Agent
|
|
3
|
+
*
|
|
4
|
+
* Pure planning agent that designs task approaches from provided context.
|
|
5
|
+
* Does NOT explore — it receives findings from the explore agent
|
|
6
|
+
* and produces a step-by-step execution plan.
|
|
7
|
+
*/
|
|
8
|
+
import type { SubAgentConfig } from '../types.js';
|
|
9
|
+
export declare const planAgent: SubAgentConfig;
|
|
10
|
+
//# sourceMappingURL=plan.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plan.d.ts","sourceRoot":"","sources":["../../src/built-in-agents/plan.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAGjD,eAAO,MAAM,SAAS,EAAE,cAoDvB,CAAA"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plan Agent
|
|
3
|
+
*
|
|
4
|
+
* Pure planning agent that designs task approaches from provided context.
|
|
5
|
+
* Does NOT explore — it receives findings from the explore agent
|
|
6
|
+
* and produces a step-by-step execution plan.
|
|
7
|
+
*/
|
|
8
|
+
import { TASK_SCOPE_INSTRUCTIONS } from '../constants.js';
|
|
9
|
+
export const planAgent = {
|
|
10
|
+
name: 'plan',
|
|
11
|
+
description: 'Pure planner — receives context and exploration findings, produces a step-by-step execution plan. Does NOT explore or execute. Use after the explore agent has gathered the necessary context.',
|
|
12
|
+
systemPrompt: `You are a planning specialist. You receive a structured brief with context and exploration findings, and you produce a clear step-by-step execution plan.
|
|
13
|
+
|
|
14
|
+
You do NOT explore or execute. The main agent has already explored using the explore agent and will pass you the findings. Your job is to turn those findings into an actionable plan.
|
|
15
|
+
|
|
16
|
+
## Your Process
|
|
17
|
+
|
|
18
|
+
1. **Understand the brief**: Read the provided context, goal, findings, and constraints carefully.
|
|
19
|
+
|
|
20
|
+
2. **Design the plan**:
|
|
21
|
+
- Break the goal into logical phases/steps
|
|
22
|
+
- Each step should describe a goal and requirements — like a team lead writing a task for a developer
|
|
23
|
+
- State WHAT needs to be accomplished and WHY, not HOW to implement it
|
|
24
|
+
- Include relevant context: data locations, formats, API endpoints, field names
|
|
25
|
+
- Consider dependencies between steps — what must happen before what
|
|
26
|
+
- Anticipate potential failures and suggest fallback approaches
|
|
27
|
+
|
|
28
|
+
3. **Output the plan**:
|
|
29
|
+
- Numbered steps, each with: the goal, relevant context, requirements, expected outcome
|
|
30
|
+
- IMPORTANT: Each step will become a separate task that gets delegated to a worker. Make sure each step is self-contained and has a clear, distinct goal
|
|
31
|
+
- Do NOT combine unrelated actions into one step (e.g., "find data AND save results" should be two steps if they are logically separate)
|
|
32
|
+
- Include hints only when you have specific knowledge that would save time (e.g., "the API uses pagination with cursor tokens")
|
|
33
|
+
- Flag any missing information that the main agent should clarify with the user before executing
|
|
34
|
+
- Keep it concise — no filler, just actionable requirements
|
|
35
|
+
|
|
36
|
+
## Guidelines
|
|
37
|
+
|
|
38
|
+
- Write steps like a team lead writes tasks for developers — describe the goal and requirements, not the implementation
|
|
39
|
+
- Good: "Extract company data (name, funding, URL) from the YC directory page at URL X. Save results to data/companies.json"
|
|
40
|
+
- Bad: "Use curl to fetch URL X, then pipe through jq to extract .companies[] | {name, funding, url}, then redirect to data/companies.json"
|
|
41
|
+
- Reference actual data from the findings — workspace paths, URLs, field names
|
|
42
|
+
- Each step should be self-contained enough to be a single worker mission
|
|
43
|
+
- If the task is simple enough to not need a plan (1-2 obvious steps), say so
|
|
44
|
+
- Avoid using emojis
|
|
45
|
+
|
|
46
|
+
${TASK_SCOPE_INSTRUCTIONS}`,
|
|
47
|
+
inputSchema: {
|
|
48
|
+
type: 'object',
|
|
49
|
+
properties: {
|
|
50
|
+
prompt: {
|
|
51
|
+
type: 'string',
|
|
52
|
+
description: `Structured brief with exploration findings:\n- Context: what the explore agent found (workspace state, available data, relevant paths)\n- Goal: what the user wants to achieve\n- Constraints: limitations, dependencies, credentials available\n- Success criteria: how to verify completion`,
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
required: ['prompt'],
|
|
56
|
+
},
|
|
57
|
+
tools: [],
|
|
58
|
+
disableAskUser: true,
|
|
59
|
+
builtInToolNames: [],
|
|
60
|
+
maxIterations: 3,
|
|
61
|
+
};
|
|
62
|
+
//# sourceMappingURL=plan.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plan.js","sourceRoot":"","sources":["../../src/built-in-agents/plan.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAA;AAEzD,MAAM,CAAC,MAAM,SAAS,GAAmB;IACvC,IAAI,EAAE,MAAM;IACZ,WAAW,EAAE,gMAAgM;IAC7M,YAAY,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkCd,uBAAuB,EAAE;IACzB,WAAW,EAAE;QACX,IAAI,EAAE,QAAiB;QACvB,UAAU,EAAE;YACV,MAAM,EAAE;gBACN,IAAI,EAAE,QAAiB;gBACvB,WAAW,EAAE,+RAA+R;aAC7S;SACF;QACD,QAAQ,EAAE,CAAC,QAAQ,CAAC;KACrB;IACD,KAAK,EAAE,EAAE;IACT,cAAc,EAAE,IAAI;IACpB,gBAAgB,EAAE,EAAE;IACpB,aAAa,EAAE,CAAC;CACjB,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Worker Agent
|
|
3
|
+
*
|
|
4
|
+
* Autonomous executor that handles substantial missions end-to-end.
|
|
5
|
+
* Has full read-write shell access to the workspace.
|
|
6
|
+
*/
|
|
7
|
+
import type { SubAgentConfig } from '../types.js';
|
|
8
|
+
export declare const workerAgent: SubAgentConfig;
|
|
9
|
+
//# sourceMappingURL=worker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../../src/built-in-agents/worker.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAGjD,eAAO,MAAM,WAAW,EAAE,cA4CzB,CAAA"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Worker Agent
|
|
3
|
+
*
|
|
4
|
+
* Autonomous executor that handles substantial missions end-to-end.
|
|
5
|
+
* Has full read-write shell access to the workspace.
|
|
6
|
+
*/
|
|
7
|
+
import { TASK_SCOPE_INSTRUCTIONS } from '../constants.js';
|
|
8
|
+
export const workerAgent = {
|
|
9
|
+
name: 'worker',
|
|
10
|
+
description: 'Autonomous executor — receives high-level goals and requirements (like a developer receives tasks from a team lead), figures out the implementation, and delivers results.',
|
|
11
|
+
systemPrompt: `You are an autonomous developer. You receive high-level tasks describing WHAT needs to be done — the goal, context, requirements, and constraints. You decide HOW to implement it. You own the technical approach, tool choices, and execution strategy.
|
|
12
|
+
|
|
13
|
+
## Principles
|
|
14
|
+
|
|
15
|
+
- Read the task requirements carefully, then decide on your approach
|
|
16
|
+
- You own the implementation — choose the right tools, commands, and methods
|
|
17
|
+
- Read before writing: always check current state before making changes
|
|
18
|
+
- When something fails, analyze the error and try a different approach — do not blindly retry
|
|
19
|
+
- If the requirements are ambiguous, do the most reasonable interpretation and note what you assumed
|
|
20
|
+
- NEVER assume credentials, API keys, or secrets exist. Before any authenticated API call, check what variables and credentials are actually available in the workspace. If they are not there, report that the task requires credentials you don't have — do not guess or fabricate values
|
|
21
|
+
|
|
22
|
+
## CRITICAL: Stop When Done
|
|
23
|
+
When you finish the requested work, IMMEDIATELY respond with a text summary. Do NOT:
|
|
24
|
+
- Keep browsing for more data after you have enough
|
|
25
|
+
- Re-read files you just wrote to "verify" — if the write command succeeded (exit 0), the file is correct
|
|
26
|
+
- Try to improve or polish results beyond what was asked
|
|
27
|
+
- Start new research after saving data
|
|
28
|
+
Your iterations are limited. Spend them on the actual work, not on verification loops.
|
|
29
|
+
|
|
30
|
+
## Tools
|
|
31
|
+
|
|
32
|
+
You have a general-purpose shell. Use it for anything the task requires:
|
|
33
|
+
- Workspace: \`ls\`, \`cat\`, \`grep\`, \`find\` to explore; write commands to create or update entries
|
|
34
|
+
- HTTP/APIs: \`curl\` to fetch data, call APIs, download resources
|
|
35
|
+
- Data processing: \`jq\`, \`sed\`, \`awk\`, \`sort\`, pipes, and redirects
|
|
36
|
+
- Any other shell commands needed to complete the task
|
|
37
|
+
|
|
38
|
+
## Guidelines
|
|
39
|
+
|
|
40
|
+
- You are a developer, not a script executor. Think about the best approach before diving in
|
|
41
|
+
- Work efficiently — make parallel shell calls when operations are independent
|
|
42
|
+
- If a command fails, read the error, adjust, and retry with a different approach
|
|
43
|
+
- For multi-step tasks, break them down yourself and tackle systematically — finish one phase before moving to the next
|
|
44
|
+
- Report what you did clearly and concisely when finished: what was accomplished, what data was produced, any issues encountered
|
|
45
|
+
- Avoid using emojis
|
|
46
|
+
|
|
47
|
+
${TASK_SCOPE_INSTRUCTIONS}`,
|
|
48
|
+
tools: [],
|
|
49
|
+
disableAskUser: true,
|
|
50
|
+
builtInToolNames: ['shell'],
|
|
51
|
+
maxIterations: 25,
|
|
52
|
+
};
|
|
53
|
+
//# sourceMappingURL=worker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worker.js","sourceRoot":"","sources":["../../src/built-in-agents/worker.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAA;AAEzD,MAAM,CAAC,MAAM,WAAW,GAAmB;IACzC,IAAI,EAAE,QAAQ;IACd,WAAW,EAAE,4KAA4K;IACzL,YAAY,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAoCd,uBAAuB,EAAE;IACzB,KAAK,EAAE,EAAE;IACT,cAAc,EAAE,IAAI;IACpB,gBAAgB,EAAE,CAAC,OAAO,CAAC;IAC3B,aAAa,EAAE,EAAE;CAClB,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared constants used across agent and built-in agents.
|
|
3
|
+
* Separated to avoid circular dependencies.
|
|
4
|
+
*/
|
|
5
|
+
/** Task scope instructions appended to all agents (main + sub-agents) */
|
|
6
|
+
export declare const TASK_SCOPE_INSTRUCTIONS = "Do what has been asked; nothing more, nothing less. Only make changes that are directly requested or clearly necessary. Do not add features, refactor code, or make improvements beyond what was asked. Do not design for hypothetical future requirements.\n\n## Task Management\nFor multi-step requests (3+ steps), use task tools to track progress:\n1. Create all tasks upfront with TaskCreate \u2014 one task per logical step. If you have a plan, create one task per plan step\n2. Work through them in order \u2014 mark in_progress, do the work, mark completed\n3. Do not respond until all tasks are completed\n\nTasks must only come from the user's request or the plan \u2014 never from your own discovery of adjacent work.\nDo NOT create tasks for single-step or trivial requests.\n\nCRITICAL: When all tasks are completed, IMMEDIATELY respond with a text summary of what was done. Do NOT make any more tool calls. Do NOT look for more work, verify results, or try to improve anything. Just respond.";
|
|
7
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,yEAAyE;AACzE,eAAO,MAAM,uBAAuB,2+BAWoL,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared constants used across agent and built-in agents.
|
|
3
|
+
* Separated to avoid circular dependencies.
|
|
4
|
+
*/
|
|
5
|
+
/** Task scope instructions appended to all agents (main + sub-agents) */
|
|
6
|
+
export const TASK_SCOPE_INSTRUCTIONS = `Do what has been asked; nothing more, nothing less. Only make changes that are directly requested or clearly necessary. Do not add features, refactor code, or make improvements beyond what was asked. Do not design for hypothetical future requirements.
|
|
7
|
+
|
|
8
|
+
## Task Management
|
|
9
|
+
For multi-step requests (3+ steps), use task tools to track progress:
|
|
10
|
+
1. Create all tasks upfront with TaskCreate — one task per logical step. If you have a plan, create one task per plan step
|
|
11
|
+
2. Work through them in order — mark in_progress, do the work, mark completed
|
|
12
|
+
3. Do not respond until all tasks are completed
|
|
13
|
+
|
|
14
|
+
Tasks must only come from the user's request or the plan — never from your own discovery of adjacent work.
|
|
15
|
+
Do NOT create tasks for single-step or trivial requests.
|
|
16
|
+
|
|
17
|
+
CRITICAL: When all tasks are completed, IMMEDIATELY respond with a text summary of what was done. Do NOT make any more tool calls. Do NOT look for more work, verify results, or try to improve anything. Just respond.`;
|
|
18
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,yEAAyE;AACzE,MAAM,CAAC,MAAM,uBAAuB,GAAG;;;;;;;;;;;wNAWiL,CAAA"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Context Management
|
|
3
|
+
*
|
|
4
|
+
* Token estimation and context management utilities.
|
|
5
|
+
*/
|
|
6
|
+
import type { Message, ContentBlock, ContextStrategy, LLMProvider } from './types.js';
|
|
7
|
+
/**
|
|
8
|
+
* Estimate token count from text (approximately 4 chars per token)
|
|
9
|
+
*/
|
|
10
|
+
export declare function estimateTokens(text: string): number;
|
|
11
|
+
/**
|
|
12
|
+
* Estimate tokens for a message
|
|
13
|
+
*/
|
|
14
|
+
export declare function estimateMessageTokens(message: Message): number;
|
|
15
|
+
/**
|
|
16
|
+
* Estimate tokens for a content block
|
|
17
|
+
*/
|
|
18
|
+
export declare function estimateContentBlockTokens(block: ContentBlock): number;
|
|
19
|
+
/**
|
|
20
|
+
* Estimate total tokens for all messages
|
|
21
|
+
*/
|
|
22
|
+
export declare function estimateTotalTokens(messages: Message[]): number;
|
|
23
|
+
/**
|
|
24
|
+
* Ensure every tool_use block has a matching tool_result in the next message.
|
|
25
|
+
* Adds dummy tool_result for any orphaned tool_use blocks (from __ask_user__
|
|
26
|
+
* returns or interrupted executions).
|
|
27
|
+
*/
|
|
28
|
+
export declare function sanitizeHistory(messages: Message[]): Message[];
|
|
29
|
+
/**
|
|
30
|
+
* Truncate old messages to fit within token limit.
|
|
31
|
+
* Preserves tool_use/tool_result pairs as atomic units — never breaks them apart.
|
|
32
|
+
*/
|
|
33
|
+
export declare function truncateOldMessages(messages: Message[], maxTokens: number, preserveFirst?: number): Message[];
|
|
34
|
+
/**
|
|
35
|
+
* Context manager for tracking token usage during execution
|
|
36
|
+
*/
|
|
37
|
+
export declare class ContextManager {
|
|
38
|
+
private maxTokens;
|
|
39
|
+
private strategy;
|
|
40
|
+
private currentTokens;
|
|
41
|
+
private llm?;
|
|
42
|
+
private compactBuffer;
|
|
43
|
+
constructor(maxTokens?: number, strategy?: ContextStrategy, llm?: LLMProvider, compactBuffer?: number);
|
|
44
|
+
/**
|
|
45
|
+
* Update current token count
|
|
46
|
+
*/
|
|
47
|
+
updateTokenCount(messages: Message[]): void;
|
|
48
|
+
/**
|
|
49
|
+
* Get remaining tokens available
|
|
50
|
+
*/
|
|
51
|
+
getRemainingTokens(): number;
|
|
52
|
+
/**
|
|
53
|
+
* Check if context is within limits (accounting for compact buffer)
|
|
54
|
+
*/
|
|
55
|
+
isWithinLimits(): boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Manage context according to strategy
|
|
58
|
+
*/
|
|
59
|
+
manageContext(messages: Message[]): Promise<Message[]>;
|
|
60
|
+
/**
|
|
61
|
+
* Summarize strategy: micro-compact first, then full compaction if still over limit.
|
|
62
|
+
*/
|
|
63
|
+
private summarizeAndCompact;
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=context-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-manager.d.ts","sourceRoot":"","sources":["../src/context-manager.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,eAAe,EAAiC,WAAW,EAAE,MAAM,YAAY,CAAA;AAGpH;;GAEG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEnD;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAQ9D;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,YAAY,GAAG,MAAM,CAatE;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,MAAM,CAE/D;AA2CD;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,OAAO,EAAE,CAmD9D;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,OAAO,EAAE,EACnB,SAAS,EAAE,MAAM,EACjB,aAAa,GAAE,MAAU,GACxB,OAAO,EAAE,CA+BX;AAQD;;GAEG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,SAAS,CAAQ;IACzB,OAAO,CAAC,QAAQ,CAAiB;IACjC,OAAO,CAAC,aAAa,CAAY;IACjC,OAAO,CAAC,GAAG,CAAC,CAAa;IACzB,OAAO,CAAC,aAAa,CAAQ;gBAG3B,SAAS,GAAE,MAAe,EAC1B,QAAQ,GAAE,eAA6B,EACvC,GAAG,CAAC,EAAE,WAAW,EACjB,aAAa,CAAC,EAAE,MAAM;IASxB;;OAEG;IACH,gBAAgB,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,IAAI;IAI3C;;OAEG;IACH,kBAAkB,IAAI,MAAM;IAI5B;;OAEG;IACH,cAAc,IAAI,OAAO;IAIzB;;OAEG;IACG,aAAa,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAiB5D;;OAEG;YACW,mBAAmB;CAyDlC"}
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Context Management
|
|
3
|
+
*
|
|
4
|
+
* Token estimation and context management utilities.
|
|
5
|
+
*/
|
|
6
|
+
import { microCompact, summarizeMessages } from './summarizer.js';
|
|
7
|
+
/**
|
|
8
|
+
* Estimate token count from text (approximately 4 chars per token)
|
|
9
|
+
*/
|
|
10
|
+
export function estimateTokens(text) {
|
|
11
|
+
return Math.ceil(text.length / 4);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Estimate tokens for a message
|
|
15
|
+
*/
|
|
16
|
+
export function estimateMessageTokens(message) {
|
|
17
|
+
if (typeof message.content === 'string') {
|
|
18
|
+
return estimateTokens(message.content);
|
|
19
|
+
}
|
|
20
|
+
return message.content.reduce((sum, block) => {
|
|
21
|
+
return sum + estimateContentBlockTokens(block);
|
|
22
|
+
}, 0);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Estimate tokens for a content block
|
|
26
|
+
*/
|
|
27
|
+
export function estimateContentBlockTokens(block) {
|
|
28
|
+
switch (block.type) {
|
|
29
|
+
case 'text':
|
|
30
|
+
return estimateTokens(block.text);
|
|
31
|
+
case 'thinking':
|
|
32
|
+
return estimateTokens(block.thinking);
|
|
33
|
+
case 'tool_use':
|
|
34
|
+
return estimateTokens(block.name) + estimateTokens(JSON.stringify(block.input));
|
|
35
|
+
case 'tool_result':
|
|
36
|
+
return estimateTokens(block.content);
|
|
37
|
+
default:
|
|
38
|
+
return 0;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Estimate total tokens for all messages
|
|
43
|
+
*/
|
|
44
|
+
export function estimateTotalTokens(messages) {
|
|
45
|
+
return messages.reduce((sum, msg) => sum + estimateMessageTokens(msg), 0);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Check if message contains tool_use blocks
|
|
49
|
+
*/
|
|
50
|
+
function hasToolUse(message) {
|
|
51
|
+
if (typeof message.content === 'string')
|
|
52
|
+
return false;
|
|
53
|
+
return message.content.some(b => b.type === 'tool_use');
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Check if message contains tool_result blocks
|
|
57
|
+
*/
|
|
58
|
+
function hasToolResult(message) {
|
|
59
|
+
if (typeof message.content === 'string')
|
|
60
|
+
return false;
|
|
61
|
+
return message.content.some(b => b.type === 'tool_result');
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Group messages into atomic units that must be kept or removed together.
|
|
65
|
+
* A tool exchange (assistant with tool_use + user with tool_result) forms one group.
|
|
66
|
+
* Plain text messages form their own group.
|
|
67
|
+
*/
|
|
68
|
+
function groupMessages(messages) {
|
|
69
|
+
const groups = [];
|
|
70
|
+
let i = 0;
|
|
71
|
+
while (i < messages.length) {
|
|
72
|
+
const msg = messages[i];
|
|
73
|
+
// Assistant message with tool_use — group with following tool_result message
|
|
74
|
+
if (msg.role === 'assistant' && hasToolUse(msg) && i + 1 < messages.length && hasToolResult(messages[i + 1])) {
|
|
75
|
+
groups.push([msg, messages[i + 1]]);
|
|
76
|
+
i += 2;
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
groups.push([msg]);
|
|
80
|
+
i += 1;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return groups;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Ensure every tool_use block has a matching tool_result in the next message.
|
|
87
|
+
* Adds dummy tool_result for any orphaned tool_use blocks (from __ask_user__
|
|
88
|
+
* returns or interrupted executions).
|
|
89
|
+
*/
|
|
90
|
+
export function sanitizeHistory(messages) {
|
|
91
|
+
const result = [];
|
|
92
|
+
for (let i = 0; i < messages.length; i++) {
|
|
93
|
+
const msg = messages[i];
|
|
94
|
+
result.push(msg);
|
|
95
|
+
if (msg.role !== 'assistant' || typeof msg.content === 'string')
|
|
96
|
+
continue;
|
|
97
|
+
const toolUseBlocks = msg.content.filter((b) => b.type === 'tool_use');
|
|
98
|
+
if (toolUseBlocks.length === 0)
|
|
99
|
+
continue;
|
|
100
|
+
const next = messages[i + 1];
|
|
101
|
+
const nextHasResults = next
|
|
102
|
+
&& next.role === 'user'
|
|
103
|
+
&& typeof next.content !== 'string';
|
|
104
|
+
// Find tool_use ids missing a matching tool_result
|
|
105
|
+
const missingIds = toolUseBlocks.filter(tu => {
|
|
106
|
+
if (!nextHasResults)
|
|
107
|
+
return true;
|
|
108
|
+
return !next.content.some(b => b.type === 'tool_result' && b.tool_use_id === tu.id);
|
|
109
|
+
});
|
|
110
|
+
if (missingIds.length === 0)
|
|
111
|
+
continue;
|
|
112
|
+
const dummyResults = missingIds.map(tu => ({
|
|
113
|
+
type: 'tool_result',
|
|
114
|
+
tool_use_id: tu.id,
|
|
115
|
+
content: JSON.stringify({ success: false, error: 'Operation was interrupted' }),
|
|
116
|
+
is_error: true,
|
|
117
|
+
}));
|
|
118
|
+
if (nextHasResults) {
|
|
119
|
+
// Merge dummy results into the existing user message
|
|
120
|
+
const merged = {
|
|
121
|
+
role: 'user',
|
|
122
|
+
content: [...dummyResults, ...next.content],
|
|
123
|
+
};
|
|
124
|
+
result.push(merged);
|
|
125
|
+
i++; // skip original next message, we replaced it
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
// Insert a new user message with dummy results
|
|
129
|
+
result.push({ role: 'user', content: dummyResults });
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return result;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Truncate old messages to fit within token limit.
|
|
136
|
+
* Preserves tool_use/tool_result pairs as atomic units — never breaks them apart.
|
|
137
|
+
*/
|
|
138
|
+
export function truncateOldMessages(messages, maxTokens, preserveFirst = 1) {
|
|
139
|
+
if (messages.length <= preserveFirst) {
|
|
140
|
+
return messages;
|
|
141
|
+
}
|
|
142
|
+
const result = [];
|
|
143
|
+
let totalTokens = 0;
|
|
144
|
+
// Always preserve first N messages (usually system context)
|
|
145
|
+
for (let i = 0; i < preserveFirst && i < messages.length; i++) {
|
|
146
|
+
result.push(messages[i]);
|
|
147
|
+
totalTokens += estimateMessageTokens(messages[i]);
|
|
148
|
+
}
|
|
149
|
+
// Group remaining messages to keep tool_use/tool_result pairs together
|
|
150
|
+
const remainingMessages = messages.slice(preserveFirst);
|
|
151
|
+
const groups = groupMessages(remainingMessages);
|
|
152
|
+
// Add groups from the end until we hit the limit
|
|
153
|
+
const kept = [];
|
|
154
|
+
for (let i = groups.length - 1; i >= 0; i--) {
|
|
155
|
+
const groupTokens = groups[i].reduce((sum, msg) => sum + estimateMessageTokens(msg), 0);
|
|
156
|
+
if (totalTokens + groupTokens <= maxTokens) {
|
|
157
|
+
kept.unshift(...groups[i]);
|
|
158
|
+
totalTokens += groupTokens;
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
break;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
return sanitizeHistory([...result, ...kept]);
|
|
165
|
+
}
|
|
166
|
+
/** Summary message prefix used to detect existing summaries */
|
|
167
|
+
const SUMMARY_PREFIX = 'This session is being continued from a previous conversation that ran out of context.';
|
|
168
|
+
/** Assistant acknowledgment after a summary message */
|
|
169
|
+
const SUMMARY_ACK = "I'll continue from where we left off. I have the full context from the summary above.";
|
|
170
|
+
/**
|
|
171
|
+
* Context manager for tracking token usage during execution
|
|
172
|
+
*/
|
|
173
|
+
export class ContextManager {
|
|
174
|
+
maxTokens;
|
|
175
|
+
strategy;
|
|
176
|
+
currentTokens = 0;
|
|
177
|
+
llm;
|
|
178
|
+
compactBuffer;
|
|
179
|
+
constructor(maxTokens = 100000, strategy = 'summarize', llm, compactBuffer) {
|
|
180
|
+
this.maxTokens = maxTokens;
|
|
181
|
+
this.strategy = strategy;
|
|
182
|
+
this.llm = llm;
|
|
183
|
+
// Default buffer: 10% of maxTokens
|
|
184
|
+
this.compactBuffer = compactBuffer ?? Math.floor(maxTokens * 0.1);
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Update current token count
|
|
188
|
+
*/
|
|
189
|
+
updateTokenCount(messages) {
|
|
190
|
+
this.currentTokens = estimateTotalTokens(messages);
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Get remaining tokens available
|
|
194
|
+
*/
|
|
195
|
+
getRemainingTokens() {
|
|
196
|
+
return Math.max(0, this.maxTokens - this.currentTokens);
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Check if context is within limits (accounting for compact buffer)
|
|
200
|
+
*/
|
|
201
|
+
isWithinLimits() {
|
|
202
|
+
return this.currentTokens <= this.maxTokens - this.compactBuffer;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Manage context according to strategy
|
|
206
|
+
*/
|
|
207
|
+
async manageContext(messages) {
|
|
208
|
+
this.updateTokenCount(messages);
|
|
209
|
+
if (this.isWithinLimits()) {
|
|
210
|
+
return sanitizeHistory(messages);
|
|
211
|
+
}
|
|
212
|
+
switch (this.strategy) {
|
|
213
|
+
case 'summarize':
|
|
214
|
+
return this.summarizeAndCompact(messages);
|
|
215
|
+
case 'error':
|
|
216
|
+
throw new Error(`Context limit exceeded: ${this.currentTokens} > ${this.maxTokens} tokens`);
|
|
217
|
+
default:
|
|
218
|
+
return messages;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Summarize strategy: micro-compact first, then full compaction if still over limit.
|
|
223
|
+
*/
|
|
224
|
+
async summarizeAndCompact(messages) {
|
|
225
|
+
// Step 1: Apply micro-compaction (truncate old large tool results)
|
|
226
|
+
let managed = microCompact(messages);
|
|
227
|
+
const afterMicroTokens = estimateTotalTokens(managed);
|
|
228
|
+
if (afterMicroTokens <= this.maxTokens - this.compactBuffer) {
|
|
229
|
+
return sanitizeHistory(managed);
|
|
230
|
+
}
|
|
231
|
+
// Step 2: Full compaction — need LLM
|
|
232
|
+
if (!this.llm) {
|
|
233
|
+
// No LLM available, fall back to truncation
|
|
234
|
+
return truncateOldMessages(managed, this.maxTokens);
|
|
235
|
+
}
|
|
236
|
+
// Determine how many recent messages to keep.
|
|
237
|
+
// Keep messages from the end that fit in ~40% of maxTokens.
|
|
238
|
+
const keepBudget = Math.floor(this.maxTokens * 0.4);
|
|
239
|
+
const groups = groupMessages(managed);
|
|
240
|
+
const recentGroups = [];
|
|
241
|
+
let recentTokens = 0;
|
|
242
|
+
for (let i = groups.length - 1; i >= 0; i--) {
|
|
243
|
+
const groupTokens = groups[i].reduce((sum, msg) => sum + estimateMessageTokens(msg), 0);
|
|
244
|
+
if (recentTokens + groupTokens > keepBudget)
|
|
245
|
+
break;
|
|
246
|
+
recentGroups.unshift(groups[i]);
|
|
247
|
+
recentTokens += groupTokens;
|
|
248
|
+
}
|
|
249
|
+
const recentMessages = recentGroups.flat();
|
|
250
|
+
const recentStartIdx = managed.length - recentMessages.length;
|
|
251
|
+
const messagesToSummarize = managed.slice(0, recentStartIdx);
|
|
252
|
+
if (messagesToSummarize.length === 0) {
|
|
253
|
+
// Nothing to summarize, fall back to truncation
|
|
254
|
+
return truncateOldMessages(managed, this.maxTokens);
|
|
255
|
+
}
|
|
256
|
+
// Run full compaction
|
|
257
|
+
const summary = await summarizeMessages(messagesToSummarize, this.llm);
|
|
258
|
+
// Build result: summary user message + assistant ack + recent messages
|
|
259
|
+
const summaryMessage = {
|
|
260
|
+
role: 'user',
|
|
261
|
+
content: `${SUMMARY_PREFIX} The conversation is summarized below:\n\n<summary>\n${summary}\n</summary>\n\nPlease continue from where we left off.`,
|
|
262
|
+
};
|
|
263
|
+
const ackMessage = {
|
|
264
|
+
role: 'assistant',
|
|
265
|
+
content: SUMMARY_ACK,
|
|
266
|
+
};
|
|
267
|
+
// Ensure alternating roles are correct
|
|
268
|
+
const result = [summaryMessage, ackMessage, ...recentMessages];
|
|
269
|
+
return sanitizeHistory(result);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
//# sourceMappingURL=context-manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-manager.js","sourceRoot":"","sources":["../src/context-manager.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AAEjE;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,IAAY;IACzC,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;AACnC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,qBAAqB,CAAC,OAAgB;IACpD,IAAI,OAAO,OAAO,CAAC,OAAO,KAAK,QAAQ,EAAE,CAAC;QACxC,OAAO,cAAc,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;IACxC,CAAC;IAED,OAAO,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE;QAC3C,OAAO,GAAG,GAAG,0BAA0B,CAAC,KAAK,CAAC,CAAA;IAChD,CAAC,EAAE,CAAC,CAAC,CAAA;AACP,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,0BAA0B,CAAC,KAAmB;IAC5D,QAAQ,KAAK,CAAC,IAAI,EAAE,CAAC;QACnB,KAAK,MAAM;YACT,OAAO,cAAc,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QACnC,KAAK,UAAU;YACb,OAAO,cAAc,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAA;QACvC,KAAK,UAAU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