@thehammer/danx-session-telemetry 0.1.1

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.
@@ -0,0 +1,19 @@
1
+ /**
2
+ * DX-2962: moved from danxbot root `src/agent/tool-summary.ts` unchanged —
3
+ * used only by `session-log-watcher.ts` in the root repo, so it moved
4
+ * wholesale rather than being duplicated or injected.
5
+ *
6
+ * Summarizes a tool's input into a short human-readable string.
7
+ */
8
+ export declare function summarizeToolInput(name: string, input: Record<string, unknown>): string;
9
+ export declare function truncStr(s: string, max: number): string;
10
+ /**
11
+ * Builds a human-readable summary for an assistant message from its content blocks.
12
+ * Returns "Tools: Read(...), Bash(...)" for tool calls, or "Text: <preview>" for text-only.
13
+ */
14
+ export declare function buildAssistantSummary(content: Record<string, unknown>[]): string;
15
+ /**
16
+ * Builds a human-readable summary for a user message containing tool results.
17
+ * Returns "Tool results: toolu_01, toolu_02".
18
+ */
19
+ export declare function buildToolResultSummary(content: Record<string, unknown>[]): string;
@@ -0,0 +1,58 @@
1
+ /**
2
+ * DX-2962: moved from danxbot root `src/agent/tool-summary.ts` unchanged —
3
+ * used only by `session-log-watcher.ts` in the root repo, so it moved
4
+ * wholesale rather than being duplicated or injected.
5
+ *
6
+ * Summarizes a tool's input into a short human-readable string.
7
+ */
8
+ export function summarizeToolInput(name, input) {
9
+ switch (name) {
10
+ case "Read":
11
+ return truncStr(String(input.file_path || ""), 80);
12
+ case "Grep":
13
+ return truncStr(String(input.pattern || ""), 60);
14
+ case "Glob":
15
+ return truncStr(String(input.pattern || ""), 60);
16
+ case "Bash":
17
+ return truncStr(String(input.command || ""), 100);
18
+ default:
19
+ return "";
20
+ }
21
+ }
22
+ export function truncStr(s, max) {
23
+ return s.length > max ? s.slice(0, max) + "..." : s;
24
+ }
25
+ /**
26
+ * Builds a human-readable summary for an assistant message from its content blocks.
27
+ * Returns "Tools: Read(...), Bash(...)" for tool calls, or "Text: <preview>" for text-only.
28
+ */
29
+ export function buildAssistantSummary(content) {
30
+ const toolUses = content.filter((b) => b.type === "tool_use");
31
+ const textBlocks = content.filter((b) => b.type === "text");
32
+ const toolNames = toolUses
33
+ .map((t) => {
34
+ const name = t.name || "unknown";
35
+ const input = (t.input ?? {});
36
+ const detail = summarizeToolInput(name, input);
37
+ return detail ? `${name}(${detail})` : name;
38
+ })
39
+ .join(", ");
40
+ const textPreview = textBlocks
41
+ .map((b) => b.text)
42
+ .join(" ")
43
+ .slice(0, 200);
44
+ return toolNames
45
+ ? `Tools: ${toolNames}`
46
+ : `Text: ${textPreview || "(empty)"}`;
47
+ }
48
+ /**
49
+ * Builds a human-readable summary for a user message containing tool results.
50
+ * Returns "Tool results: toolu_01, toolu_02".
51
+ */
52
+ export function buildToolResultSummary(content) {
53
+ const toolResults = content.filter((r) => r.type === "tool_result");
54
+ const ids = toolResults
55
+ .map((r) => r.tool_use_id || "result")
56
+ .join(", ");
57
+ return `Tool results: ${ids}`;
58
+ }
@@ -0,0 +1,25 @@
1
+ /**
2
+ * DX-2962: moved from danxbot root `src/types.ts` — this package is the
3
+ * canonical source now. Root `src/types.ts` re-exports these two names
4
+ * verbatim so every existing root import (`from "../types.js"` /
5
+ * `from "./types.js"`) keeps working unchanged (Core Principle 1 — single
6
+ * canonical schema, one home).
7
+ */
8
+ export interface AgentLogEntry {
9
+ timestamp: number;
10
+ type: string;
11
+ subtype?: string;
12
+ summary: string;
13
+ data: Record<string, unknown>;
14
+ }
15
+ /**
16
+ * Sub-agent lineage carried on AgentLogEntry.data (and propagated into every
17
+ * emitted EventPayload.data) so gpt-manager can attribute usage to the
18
+ * originating sub-agent within the same dispatch. Set by SessionLogWatcher for
19
+ * entries read from `<parent-session>/subagents/*.jsonl`; absent on parent entries.
20
+ */
21
+ export interface AgentLineage {
22
+ subagent_id: string;
23
+ parent_session_id: string | null;
24
+ agent_type: string | undefined;
25
+ }
package/dist/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "@thehammer/danx-session-telemetry",
3
+ "version": "0.1.1",
4
+ "description": "Shared Claude Code transcript collector (DX-2962) — incremental JSONL tailing for the danxbot worker and the danx-dashboard-mcp desktop bridge, so both run identical collector code.",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "main": "dist/index.js",
8
+ "types": "dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "default": "./dist/index.js"
13
+ },
14
+ "./browser": {
15
+ "types": "./dist/browser.d.ts",
16
+ "default": "./dist/browser.js"
17
+ }
18
+ },
19
+ "files": [
20
+ "dist",
21
+ "README.md"
22
+ ],
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "https://github.com/newms87/danxbot.git",
26
+ "directory": "packages/danx-session-telemetry"
27
+ },
28
+ "engines": {
29
+ "node": ">=20"
30
+ },
31
+ "scripts": {
32
+ "build": "tsc -p tsconfig.json",
33
+ "verify:boot": "bash scripts/verify-boot.sh",
34
+ "test": "vitest run",
35
+ "test:watch": "vitest"
36
+ },
37
+ "devDependencies": {
38
+ "@types/node": "^22.0.0",
39
+ "typescript": "^5.7.0",
40
+ "vitest": "^4.1.5"
41
+ }
42
+ }