@townco/agent 0.1.81 → 0.1.83
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/dist/acp-server/adapter.js +12 -12
- package/dist/acp-server/http.js +1 -1
- package/dist/acp-server/session-storage.d.ts +13 -6
- package/dist/acp-server/session-storage.js +94 -59
- package/dist/runner/agent-runner.d.ts +3 -1
- package/dist/runner/hooks/executor.js +1 -1
- package/dist/runner/hooks/predefined/compaction-tool.js +31 -8
- package/dist/runner/hooks/predefined/tool-response-compactor.js +2 -2
- package/dist/runner/langchain/index.d.ts +1 -0
- package/dist/runner/langchain/index.js +151 -27
- package/dist/runner/langchain/tools/artifacts.d.ts +68 -0
- package/dist/runner/langchain/tools/artifacts.js +469 -0
- package/dist/runner/langchain/tools/browser.js +15 -3
- package/dist/runner/langchain/tools/filesystem.d.ts +8 -4
- package/dist/runner/langchain/tools/filesystem.js +118 -82
- package/dist/runner/langchain/tools/generate_image.d.ts +19 -0
- package/dist/runner/langchain/tools/generate_image.js +54 -14
- package/dist/runner/langchain/tools/subagent.js +2 -2
- package/dist/runner/langchain/tools/todo.js +3 -0
- package/dist/runner/langchain/tools/web_search.js +6 -0
- package/dist/runner/session-context.d.ts +40 -0
- package/dist/runner/session-context.js +69 -0
- package/dist/runner/tools.d.ts +2 -2
- package/dist/runner/tools.js +2 -0
- package/dist/scaffold/project-scaffold.js +7 -3
- package/dist/telemetry/setup.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/context-size-calculator.d.ts +1 -2
- package/dist/utils/context-size-calculator.js +2 -6
- package/dist/utils/token-counter.js +2 -2
- package/package.json +10 -10
|
@@ -32,6 +32,5 @@ export interface ContextSize {
|
|
|
32
32
|
* @param toolOverheadTokens - Pre-calculated tool overhead (built-in/custom/filesystem tool definitions + TODO instructions)
|
|
33
33
|
* @param mcpOverheadTokens - Pre-calculated MCP tool overhead (MCP tool definitions)
|
|
34
34
|
* @param modelContextWindow - Model's max context window size
|
|
35
|
-
* @param excludeToolResults - When true, don't count toolResultsTokens (use at turn end since tool results aren't sent in subsequent turns)
|
|
36
35
|
*/
|
|
37
|
-
export declare function calculateContextSize(messages: SessionMessage[], systemPrompt?: string, llmReportedTokens?: number, toolOverheadTokens?: number, mcpOverheadTokens?: number, modelContextWindow?: number
|
|
36
|
+
export declare function calculateContextSize(messages: SessionMessage[], systemPrompt?: string, llmReportedTokens?: number, toolOverheadTokens?: number, mcpOverheadTokens?: number, modelContextWindow?: number): ContextSize;
|
|
@@ -44,9 +44,8 @@ function countContentBlock(block) {
|
|
|
44
44
|
* @param toolOverheadTokens - Pre-calculated tool overhead (built-in/custom/filesystem tool definitions + TODO instructions)
|
|
45
45
|
* @param mcpOverheadTokens - Pre-calculated MCP tool overhead (MCP tool definitions)
|
|
46
46
|
* @param modelContextWindow - Model's max context window size
|
|
47
|
-
* @param excludeToolResults - When true, don't count toolResultsTokens (use at turn end since tool results aren't sent in subsequent turns)
|
|
48
47
|
*/
|
|
49
|
-
export function calculateContextSize(messages, systemPrompt, llmReportedTokens, toolOverheadTokens, mcpOverheadTokens, modelContextWindow
|
|
48
|
+
export function calculateContextSize(messages, systemPrompt, llmReportedTokens, toolOverheadTokens, mcpOverheadTokens, modelContextWindow) {
|
|
50
49
|
const systemPromptTokens = systemPrompt ? countTokens(systemPrompt) : 0;
|
|
51
50
|
const toolOverheadTokensEstimate = toolOverheadTokens ?? 0;
|
|
52
51
|
const mcpOverheadTokensEstimate = mcpOverheadTokens ?? 0;
|
|
@@ -65,10 +64,7 @@ export function calculateContextSize(messages, systemPrompt, llmReportedTokens,
|
|
|
65
64
|
else if (message.role === "assistant") {
|
|
66
65
|
assistantMessagesTokens += counts.textTokens;
|
|
67
66
|
toolInputTokens += counts.toolInputTokens;
|
|
68
|
-
|
|
69
|
-
if (!excludeToolResults) {
|
|
70
|
-
toolResultsTokens += counts.toolResultTokens;
|
|
71
|
-
}
|
|
67
|
+
toolResultsTokens += counts.toolResultTokens;
|
|
72
68
|
}
|
|
73
69
|
}
|
|
74
70
|
}
|
|
@@ -12,7 +12,7 @@ export function countTokens(text) {
|
|
|
12
12
|
try {
|
|
13
13
|
return anthropicCountTokens(text);
|
|
14
14
|
}
|
|
15
|
-
catch (
|
|
15
|
+
catch (_error) {
|
|
16
16
|
// Fallback to rough estimation if tokenizer fails
|
|
17
17
|
// Approximate: ~4 characters per token
|
|
18
18
|
return Math.ceil(text.length / 4);
|
|
@@ -31,7 +31,7 @@ export function countToolResultTokens(rawOutput) {
|
|
|
31
31
|
const text = JSON.stringify(rawOutput);
|
|
32
32
|
return countTokens(text);
|
|
33
33
|
}
|
|
34
|
-
catch (
|
|
34
|
+
catch (_error) {
|
|
35
35
|
// If JSON.stringify fails, return 0
|
|
36
36
|
return 0;
|
|
37
37
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@townco/agent",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.83",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"module": "index.ts",
|
|
6
6
|
"files": [
|
|
@@ -59,35 +59,35 @@
|
|
|
59
59
|
"@agentclientprotocol/sdk": "^0.5.1",
|
|
60
60
|
"@anthropic-ai/sandbox-runtime": "^0.0.2",
|
|
61
61
|
"@anthropic-ai/sdk": "^0.70.0",
|
|
62
|
-
"@google/genai": "^0.14.1",
|
|
63
62
|
"@anthropic-ai/tokenizer": "^0.0.4",
|
|
64
|
-
"@onkernel/sdk": "^0.16.0",
|
|
65
63
|
"@electric-sql/pglite": "^0.2.15",
|
|
64
|
+
"@google/genai": "^0.14.1",
|
|
66
65
|
"@langchain/anthropic": "1.0.1",
|
|
67
66
|
"@langchain/core": "^1.0.3",
|
|
68
67
|
"@langchain/google-genai": "^1.0.3",
|
|
69
68
|
"@langchain/google-vertexai": "^1.0.3",
|
|
70
69
|
"@langchain/mcp-adapters": "^1.0.0",
|
|
70
|
+
"@onkernel/sdk": "^0.16.0",
|
|
71
71
|
"@opentelemetry/api": "^1.9.0",
|
|
72
72
|
"@opentelemetry/api-logs": "^0.56.0",
|
|
73
73
|
"@opentelemetry/core": "^1.28.0",
|
|
74
74
|
"@opentelemetry/exporter-logs-otlp-http": "^0.56.0",
|
|
75
75
|
"@opentelemetry/exporter-trace-otlp-http": "^0.56.0",
|
|
76
|
-
"@opentelemetry/instrumentation": "^0.56.0",
|
|
77
76
|
"@opentelemetry/resources": "^1.28.0",
|
|
78
77
|
"@opentelemetry/sdk-logs": "^0.56.0",
|
|
79
78
|
"@opentelemetry/sdk-trace-base": "^1.28.0",
|
|
80
79
|
"@opentelemetry/sdk-trace-node": "^1.28.0",
|
|
81
80
|
"@opentelemetry/semantic-conventions": "^1.28.0",
|
|
82
|
-
"@townco/core": "0.0.
|
|
83
|
-
"@townco/gui-template": "0.1.
|
|
84
|
-
"@townco/
|
|
85
|
-
"@townco/
|
|
86
|
-
"@townco/
|
|
81
|
+
"@townco/core": "0.0.56",
|
|
82
|
+
"@townco/gui-template": "0.1.75",
|
|
83
|
+
"@townco/supabase": "workspace:*",
|
|
84
|
+
"@townco/tsconfig": "0.1.75",
|
|
85
|
+
"@townco/tui-template": "0.1.75",
|
|
86
|
+
"@townco/ui": "0.1.78",
|
|
87
87
|
"exa-js": "^2.0.0",
|
|
88
88
|
"hono": "^4.10.4",
|
|
89
89
|
"langchain": "^1.0.3",
|
|
90
|
-
"prettier": "^3.
|
|
90
|
+
"prettier": "^3.7.4",
|
|
91
91
|
"zod": "^4.1.12"
|
|
92
92
|
},
|
|
93
93
|
"devDependencies": {
|