@townco/agent 0.1.50 ā 0.1.52
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.d.ts +10 -0
- package/dist/acp-server/adapter.js +287 -80
- package/dist/acp-server/cli.d.ts +1 -3
- package/dist/acp-server/http.js +8 -1
- package/dist/acp-server/index.js +5 -0
- package/dist/acp-server/session-storage.d.ts +17 -3
- package/dist/acp-server/session-storage.js +9 -0
- package/dist/bin.js +0 -0
- package/dist/check-jaeger.d.ts +5 -0
- package/dist/check-jaeger.js +82 -0
- package/dist/definition/index.d.ts +16 -4
- package/dist/definition/index.js +17 -4
- package/dist/index.js +1 -1
- package/dist/run-subagents.d.ts +9 -0
- package/dist/run-subagents.js +110 -0
- package/dist/runner/agent-runner.d.ts +10 -2
- package/dist/runner/agent-runner.js +4 -0
- package/dist/runner/hooks/executor.d.ts +17 -0
- package/dist/runner/hooks/executor.js +66 -0
- package/dist/runner/hooks/predefined/compaction-tool.js +9 -1
- package/dist/runner/hooks/predefined/tool-response-compactor.d.ts +6 -0
- package/dist/runner/hooks/predefined/tool-response-compactor.js +461 -0
- package/dist/runner/hooks/registry.js +2 -0
- package/dist/runner/hooks/types.d.ts +39 -3
- package/dist/runner/hooks/types.js +9 -4
- package/dist/runner/index.d.ts +1 -3
- package/dist/runner/langchain/custom-stream-types.d.ts +36 -0
- package/dist/runner/langchain/custom-stream-types.js +23 -0
- package/dist/runner/langchain/index.js +102 -76
- package/dist/runner/langchain/otel-callbacks.js +67 -1
- package/dist/runner/langchain/tools/bash.d.ts +14 -0
- package/dist/runner/langchain/tools/bash.js +135 -0
- package/dist/scaffold/link-local.d.ts +1 -0
- package/dist/scaffold/link-local.js +54 -0
- package/dist/scaffold/project-scaffold.js +1 -0
- package/dist/telemetry/setup.d.ts +3 -1
- package/dist/telemetry/setup.js +33 -3
- package/dist/templates/index.d.ts +7 -0
- package/dist/test-telemetry.d.ts +5 -0
- package/dist/test-telemetry.js +88 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/context-size-calculator.d.ts +29 -0
- package/dist/utils/context-size-calculator.js +78 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.js +2 -0
- package/dist/utils/token-counter.d.ts +19 -0
- package/dist/utils/token-counter.js +44 -0
- package/index.ts +1 -1
- package/package.json +7 -6
- package/templates/index.ts +18 -6
- package/dist/definition/mcp.d.ts +0 -0
- package/dist/definition/mcp.js +0 -0
- package/dist/definition/tools/todo.d.ts +0 -49
- package/dist/definition/tools/todo.js +0 -80
- package/dist/definition/tools/web_search.d.ts +0 -4
- package/dist/definition/tools/web_search.js +0 -26
- package/dist/dev-agent/index.d.ts +0 -2
- package/dist/dev-agent/index.js +0 -18
- package/dist/example.d.ts +0 -2
- package/dist/example.js +0 -19
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Simple test script to verify OpenTelemetry is working
|
|
3
|
+
* Run with: ENABLE_TELEMETRY=true DEBUG_TELEMETRY=true bun test-telemetry.ts
|
|
4
|
+
*/
|
|
5
|
+
import { makeRunnerFromDefinition } from "./runner/index.js";
|
|
6
|
+
import { configureTelemetry } from "./telemetry/index.js";
|
|
7
|
+
// Initialize OpenTelemetry
|
|
8
|
+
console.log("š§ Initializing OpenTelemetry...");
|
|
9
|
+
const { NodeTracerProvider } = await import("@opentelemetry/sdk-trace-node");
|
|
10
|
+
const { BatchSpanProcessor } = await import("@opentelemetry/sdk-trace-base");
|
|
11
|
+
const { OTLPTraceExporter } = await import("@opentelemetry/exporter-trace-otlp-grpc");
|
|
12
|
+
const { Resource } = await import("@opentelemetry/resources");
|
|
13
|
+
const { ATTR_SERVICE_NAME } = await import("@opentelemetry/semantic-conventions");
|
|
14
|
+
const serviceName = "test-agent";
|
|
15
|
+
const otlpEndpoint = process.env.OTEL_EXPORTER_OTLP_ENDPOINT ?? "http://localhost:4317";
|
|
16
|
+
console.log(`š” Service: ${serviceName}`);
|
|
17
|
+
console.log(`š” Endpoint: ${otlpEndpoint}`);
|
|
18
|
+
const provider = new NodeTracerProvider({
|
|
19
|
+
resource: new Resource({
|
|
20
|
+
[ATTR_SERVICE_NAME]: serviceName,
|
|
21
|
+
}),
|
|
22
|
+
});
|
|
23
|
+
const exporter = new OTLPTraceExporter({
|
|
24
|
+
url: otlpEndpoint,
|
|
25
|
+
});
|
|
26
|
+
provider.addSpanProcessor(new BatchSpanProcessor(exporter));
|
|
27
|
+
provider.register();
|
|
28
|
+
configureTelemetry({
|
|
29
|
+
enabled: true,
|
|
30
|
+
serviceName,
|
|
31
|
+
attributes: {
|
|
32
|
+
"test.run": "true",
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
console.log("ā
OpenTelemetry initialized\n");
|
|
36
|
+
// Create a simple test agent
|
|
37
|
+
console.log("š¤ Creating test agent...");
|
|
38
|
+
const runner = makeRunnerFromDefinition({
|
|
39
|
+
model: "claude-sonnet-4-5-20250929",
|
|
40
|
+
systemPrompt: "You are a helpful assistant. Keep responses brief.",
|
|
41
|
+
tools: ["get_weather"],
|
|
42
|
+
});
|
|
43
|
+
console.log("ā
Agent created\n");
|
|
44
|
+
// Run a simple test invocation
|
|
45
|
+
console.log("š Running test invocation...");
|
|
46
|
+
const result = runner.invoke({
|
|
47
|
+
prompt: [
|
|
48
|
+
{
|
|
49
|
+
type: "text",
|
|
50
|
+
text: "What's the weather like in San Francisco?",
|
|
51
|
+
},
|
|
52
|
+
],
|
|
53
|
+
sessionId: "test-session-123",
|
|
54
|
+
messageId: "test-msg-1",
|
|
55
|
+
});
|
|
56
|
+
console.log("šØ Processing response...\n");
|
|
57
|
+
let tokenCount = 0;
|
|
58
|
+
let toolCalls = 0;
|
|
59
|
+
for await (const chunk of result) {
|
|
60
|
+
if (chunk.sessionUpdate === "tool_call") {
|
|
61
|
+
console.log(`š§ Tool called: ${chunk.title}`);
|
|
62
|
+
toolCalls++;
|
|
63
|
+
}
|
|
64
|
+
else if (chunk.sessionUpdate === "agent_message_chunk") {
|
|
65
|
+
if (chunk.content.type === "text") {
|
|
66
|
+
process.stdout.write(chunk.content.text);
|
|
67
|
+
}
|
|
68
|
+
if (chunk._meta &&
|
|
69
|
+
"tokenUsage" in chunk._meta &&
|
|
70
|
+
chunk._meta.tokenUsage &&
|
|
71
|
+
typeof chunk._meta.tokenUsage === "object" &&
|
|
72
|
+
"outputTokens" in chunk._meta.tokenUsage) {
|
|
73
|
+
tokenCount += chunk._meta.tokenUsage.outputTokens ?? 0;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
console.log("\n\nā
Test completed!");
|
|
78
|
+
console.log(`š Stats: ${toolCalls} tool calls, ~${tokenCount} output tokens`);
|
|
79
|
+
// Force flush before exit
|
|
80
|
+
console.log("\nā³ Flushing telemetry data...");
|
|
81
|
+
await provider.forceFlush();
|
|
82
|
+
console.log("ā
Telemetry flushed!");
|
|
83
|
+
console.log("\nšÆ Check Jaeger UI at: http://localhost:16686");
|
|
84
|
+
console.log(` Service: ${serviceName}`);
|
|
85
|
+
console.log(` Look for "agent.invoke" spans`);
|
|
86
|
+
// Give a moment for final flush
|
|
87
|
+
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
88
|
+
process.exit(0);
|