@legioncodeinc/honeycomb 0.1.7 → 0.1.8

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.
@@ -2,7 +2,7 @@
2
2
  import { createServer } from "node:http";
3
3
 
4
4
  // dist/src/shared/constants.js
5
- var HONEYCOMB_VERSION = true ? "0.1.7" : "0.0.0-dev";
5
+ var HONEYCOMB_VERSION = true ? "0.1.8" : "0.0.0-dev";
6
6
 
7
7
  // dist/embeddings/src/index.js
8
8
  var EMBED_DIMS = 768;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "honeycomb",
3
3
  "description": "Honeycomb — persistent memory for Claude Code sessions via the local Honeycomb daemon",
4
- "version": "0.1.7",
4
+ "version": "0.1.8",
5
5
  "author": {
6
6
  "name": "Honeycomb"
7
7
  },
@@ -92,8 +92,61 @@ function nestedString(raw, a, b) {
92
92
  function userMessageData(text) {
93
93
  return { kind: "user_message", text };
94
94
  }
95
- function assistantMessageData(text) {
96
- return { kind: "assistant_message", text };
95
+ function assistantMessageData(text, usage) {
96
+ const normalized = usage !== void 0 ? compactUsage(usage) : void 0;
97
+ return {
98
+ kind: "assistant_message",
99
+ text,
100
+ ...normalized !== void 0 ? { usage: normalized } : {}
101
+ };
102
+ }
103
+ function compactUsage(usage) {
104
+ const out = {};
105
+ if (isCount(usage.input))
106
+ out.input = usage.input;
107
+ if (isCount(usage.output))
108
+ out.output = usage.output;
109
+ if (isCount(usage.cacheRead))
110
+ out.cacheRead = usage.cacheRead;
111
+ if (isCount(usage.cacheCreation))
112
+ out.cacheCreation = usage.cacheCreation;
113
+ return Object.keys(out).length > 0 ? out : void 0;
114
+ }
115
+ function isCount(n) {
116
+ return typeof n === "number" && Number.isInteger(n) && n >= 0;
117
+ }
118
+ function extractTurnUsage(raw) {
119
+ const block = usageBlock(raw);
120
+ if (block === void 0)
121
+ return void 0;
122
+ const usage = {
123
+ ...readCount(block, "input_tokens") !== void 0 ? { input: readCount(block, "input_tokens") } : {},
124
+ ...readCount(block, "output_tokens") !== void 0 ? { output: readCount(block, "output_tokens") } : {},
125
+ ...readCount(block, "cache_read_input_tokens") !== void 0 ? { cacheRead: readCount(block, "cache_read_input_tokens") } : {},
126
+ ...readCount(block, "cache_creation_input_tokens") !== void 0 ? { cacheCreation: readCount(block, "cache_creation_input_tokens") } : {}
127
+ };
128
+ return compactUsage(usage);
129
+ }
130
+ function usageBlock(raw) {
131
+ const top = nested(raw, "usage");
132
+ if (top !== null && typeof top === "object")
133
+ return top;
134
+ const inner = nestedRecord(nested(raw, "message"), "usage");
135
+ return inner;
136
+ }
137
+ function nestedRecord(obj, key) {
138
+ if (obj !== null && typeof obj === "object") {
139
+ const value = obj[key];
140
+ if (value !== null && typeof value === "object")
141
+ return value;
142
+ }
143
+ return void 0;
144
+ }
145
+ function readCount(block, key) {
146
+ const value = block[key];
147
+ if (typeof value !== "number" || !Number.isInteger(value) || value < 0)
148
+ return void 0;
149
+ return value;
97
150
  }
98
151
  function toolCallData(tool, input, response) {
99
152
  return { kind: "tool_call", tool, input, response };
@@ -143,7 +196,7 @@ function claudeCodeExtractData(raw, logical) {
143
196
  case "tool_call":
144
197
  return toolCallData(pickString(raw, "tool_name", "tool"), nested(raw, "tool_input"), nested(raw, "tool_response"));
145
198
  case "assistant_message":
146
- return assistantMessageData(pickString(raw, "text", "message"));
199
+ return assistantMessageData(pickString(raw, "text", "message"), extractTurnUsage(raw));
147
200
  case "session-end":
148
201
  return sessionEndData(pickString(raw, "reason") || "Stop");
149
202
  default:
@@ -92,8 +92,61 @@ function nestedString(raw, a, b) {
92
92
  function userMessageData(text) {
93
93
  return { kind: "user_message", text };
94
94
  }
95
- function assistantMessageData(text) {
96
- return { kind: "assistant_message", text };
95
+ function assistantMessageData(text, usage) {
96
+ const normalized = usage !== void 0 ? compactUsage(usage) : void 0;
97
+ return {
98
+ kind: "assistant_message",
99
+ text,
100
+ ...normalized !== void 0 ? { usage: normalized } : {}
101
+ };
102
+ }
103
+ function compactUsage(usage) {
104
+ const out = {};
105
+ if (isCount(usage.input))
106
+ out.input = usage.input;
107
+ if (isCount(usage.output))
108
+ out.output = usage.output;
109
+ if (isCount(usage.cacheRead))
110
+ out.cacheRead = usage.cacheRead;
111
+ if (isCount(usage.cacheCreation))
112
+ out.cacheCreation = usage.cacheCreation;
113
+ return Object.keys(out).length > 0 ? out : void 0;
114
+ }
115
+ function isCount(n) {
116
+ return typeof n === "number" && Number.isInteger(n) && n >= 0;
117
+ }
118
+ function extractTurnUsage(raw) {
119
+ const block = usageBlock(raw);
120
+ if (block === void 0)
121
+ return void 0;
122
+ const usage = {
123
+ ...readCount(block, "input_tokens") !== void 0 ? { input: readCount(block, "input_tokens") } : {},
124
+ ...readCount(block, "output_tokens") !== void 0 ? { output: readCount(block, "output_tokens") } : {},
125
+ ...readCount(block, "cache_read_input_tokens") !== void 0 ? { cacheRead: readCount(block, "cache_read_input_tokens") } : {},
126
+ ...readCount(block, "cache_creation_input_tokens") !== void 0 ? { cacheCreation: readCount(block, "cache_creation_input_tokens") } : {}
127
+ };
128
+ return compactUsage(usage);
129
+ }
130
+ function usageBlock(raw) {
131
+ const top = nested(raw, "usage");
132
+ if (top !== null && typeof top === "object")
133
+ return top;
134
+ const inner = nestedRecord(nested(raw, "message"), "usage");
135
+ return inner;
136
+ }
137
+ function nestedRecord(obj, key) {
138
+ if (obj !== null && typeof obj === "object") {
139
+ const value = obj[key];
140
+ if (value !== null && typeof value === "object")
141
+ return value;
142
+ }
143
+ return void 0;
144
+ }
145
+ function readCount(block, key) {
146
+ const value = block[key];
147
+ if (typeof value !== "number" || !Number.isInteger(value) || value < 0)
148
+ return void 0;
149
+ return value;
97
150
  }
98
151
  function toolCallData(tool, input, response) {
99
152
  return { kind: "tool_call", tool, input, response };
@@ -143,7 +196,7 @@ function claudeCodeExtractData(raw, logical) {
143
196
  case "tool_call":
144
197
  return toolCallData(pickString(raw, "tool_name", "tool"), nested(raw, "tool_input"), nested(raw, "tool_response"));
145
198
  case "assistant_message":
146
- return assistantMessageData(pickString(raw, "text", "message"));
199
+ return assistantMessageData(pickString(raw, "text", "message"), extractTurnUsage(raw));
147
200
  case "session-end":
148
201
  return sessionEndData(pickString(raw, "reason") || "Stop");
149
202
  default:
@@ -92,8 +92,61 @@ function nestedString(raw, a, b) {
92
92
  function userMessageData(text) {
93
93
  return { kind: "user_message", text };
94
94
  }
95
- function assistantMessageData(text) {
96
- return { kind: "assistant_message", text };
95
+ function assistantMessageData(text, usage) {
96
+ const normalized = usage !== void 0 ? compactUsage(usage) : void 0;
97
+ return {
98
+ kind: "assistant_message",
99
+ text,
100
+ ...normalized !== void 0 ? { usage: normalized } : {}
101
+ };
102
+ }
103
+ function compactUsage(usage) {
104
+ const out = {};
105
+ if (isCount(usage.input))
106
+ out.input = usage.input;
107
+ if (isCount(usage.output))
108
+ out.output = usage.output;
109
+ if (isCount(usage.cacheRead))
110
+ out.cacheRead = usage.cacheRead;
111
+ if (isCount(usage.cacheCreation))
112
+ out.cacheCreation = usage.cacheCreation;
113
+ return Object.keys(out).length > 0 ? out : void 0;
114
+ }
115
+ function isCount(n) {
116
+ return typeof n === "number" && Number.isInteger(n) && n >= 0;
117
+ }
118
+ function extractTurnUsage(raw) {
119
+ const block = usageBlock(raw);
120
+ if (block === void 0)
121
+ return void 0;
122
+ const usage = {
123
+ ...readCount(block, "input_tokens") !== void 0 ? { input: readCount(block, "input_tokens") } : {},
124
+ ...readCount(block, "output_tokens") !== void 0 ? { output: readCount(block, "output_tokens") } : {},
125
+ ...readCount(block, "cache_read_input_tokens") !== void 0 ? { cacheRead: readCount(block, "cache_read_input_tokens") } : {},
126
+ ...readCount(block, "cache_creation_input_tokens") !== void 0 ? { cacheCreation: readCount(block, "cache_creation_input_tokens") } : {}
127
+ };
128
+ return compactUsage(usage);
129
+ }
130
+ function usageBlock(raw) {
131
+ const top = nested(raw, "usage");
132
+ if (top !== null && typeof top === "object")
133
+ return top;
134
+ const inner = nestedRecord(nested(raw, "message"), "usage");
135
+ return inner;
136
+ }
137
+ function nestedRecord(obj, key) {
138
+ if (obj !== null && typeof obj === "object") {
139
+ const value = obj[key];
140
+ if (value !== null && typeof value === "object")
141
+ return value;
142
+ }
143
+ return void 0;
144
+ }
145
+ function readCount(block, key) {
146
+ const value = block[key];
147
+ if (typeof value !== "number" || !Number.isInteger(value) || value < 0)
148
+ return void 0;
149
+ return value;
97
150
  }
98
151
  function toolCallData(tool, input, response) {
99
152
  return { kind: "tool_call", tool, input, response };
@@ -143,7 +196,7 @@ function claudeCodeExtractData(raw, logical) {
143
196
  case "tool_call":
144
197
  return toolCallData(pickString(raw, "tool_name", "tool"), nested(raw, "tool_input"), nested(raw, "tool_response"));
145
198
  case "assistant_message":
146
- return assistantMessageData(pickString(raw, "text", "message"));
199
+ return assistantMessageData(pickString(raw, "text", "message"), extractTurnUsage(raw));
147
200
  case "session-end":
148
201
  return sessionEndData(pickString(raw, "reason") || "Stop");
149
202
  default:
@@ -92,8 +92,61 @@ function nestedString(raw, a, b) {
92
92
  function userMessageData(text) {
93
93
  return { kind: "user_message", text };
94
94
  }
95
- function assistantMessageData(text) {
96
- return { kind: "assistant_message", text };
95
+ function assistantMessageData(text, usage) {
96
+ const normalized = usage !== void 0 ? compactUsage(usage) : void 0;
97
+ return {
98
+ kind: "assistant_message",
99
+ text,
100
+ ...normalized !== void 0 ? { usage: normalized } : {}
101
+ };
102
+ }
103
+ function compactUsage(usage) {
104
+ const out = {};
105
+ if (isCount(usage.input))
106
+ out.input = usage.input;
107
+ if (isCount(usage.output))
108
+ out.output = usage.output;
109
+ if (isCount(usage.cacheRead))
110
+ out.cacheRead = usage.cacheRead;
111
+ if (isCount(usage.cacheCreation))
112
+ out.cacheCreation = usage.cacheCreation;
113
+ return Object.keys(out).length > 0 ? out : void 0;
114
+ }
115
+ function isCount(n) {
116
+ return typeof n === "number" && Number.isInteger(n) && n >= 0;
117
+ }
118
+ function extractTurnUsage(raw) {
119
+ const block = usageBlock(raw);
120
+ if (block === void 0)
121
+ return void 0;
122
+ const usage = {
123
+ ...readCount(block, "input_tokens") !== void 0 ? { input: readCount(block, "input_tokens") } : {},
124
+ ...readCount(block, "output_tokens") !== void 0 ? { output: readCount(block, "output_tokens") } : {},
125
+ ...readCount(block, "cache_read_input_tokens") !== void 0 ? { cacheRead: readCount(block, "cache_read_input_tokens") } : {},
126
+ ...readCount(block, "cache_creation_input_tokens") !== void 0 ? { cacheCreation: readCount(block, "cache_creation_input_tokens") } : {}
127
+ };
128
+ return compactUsage(usage);
129
+ }
130
+ function usageBlock(raw) {
131
+ const top = nested(raw, "usage");
132
+ if (top !== null && typeof top === "object")
133
+ return top;
134
+ const inner = nestedRecord(nested(raw, "message"), "usage");
135
+ return inner;
136
+ }
137
+ function nestedRecord(obj, key) {
138
+ if (obj !== null && typeof obj === "object") {
139
+ const value = obj[key];
140
+ if (value !== null && typeof value === "object")
141
+ return value;
142
+ }
143
+ return void 0;
144
+ }
145
+ function readCount(block, key) {
146
+ const value = block[key];
147
+ if (typeof value !== "number" || !Number.isInteger(value) || value < 0)
148
+ return void 0;
149
+ return value;
97
150
  }
98
151
  function toolCallData(tool, input, response) {
99
152
  return { kind: "tool_call", tool, input, response };
@@ -143,7 +196,7 @@ function claudeCodeExtractData(raw, logical) {
143
196
  case "tool_call":
144
197
  return toolCallData(pickString(raw, "tool_name", "tool"), nested(raw, "tool_input"), nested(raw, "tool_response"));
145
198
  case "assistant_message":
146
- return assistantMessageData(pickString(raw, "text", "message"));
199
+ return assistantMessageData(pickString(raw, "text", "message"), extractTurnUsage(raw));
147
200
  case "session-end":
148
201
  return sessionEndData(pickString(raw, "reason") || "Stop");
149
202
  default:
@@ -92,8 +92,61 @@ function nestedString(raw, a, b) {
92
92
  function userMessageData(text) {
93
93
  return { kind: "user_message", text };
94
94
  }
95
- function assistantMessageData(text) {
96
- return { kind: "assistant_message", text };
95
+ function assistantMessageData(text, usage) {
96
+ const normalized = usage !== void 0 ? compactUsage(usage) : void 0;
97
+ return {
98
+ kind: "assistant_message",
99
+ text,
100
+ ...normalized !== void 0 ? { usage: normalized } : {}
101
+ };
102
+ }
103
+ function compactUsage(usage) {
104
+ const out = {};
105
+ if (isCount(usage.input))
106
+ out.input = usage.input;
107
+ if (isCount(usage.output))
108
+ out.output = usage.output;
109
+ if (isCount(usage.cacheRead))
110
+ out.cacheRead = usage.cacheRead;
111
+ if (isCount(usage.cacheCreation))
112
+ out.cacheCreation = usage.cacheCreation;
113
+ return Object.keys(out).length > 0 ? out : void 0;
114
+ }
115
+ function isCount(n) {
116
+ return typeof n === "number" && Number.isInteger(n) && n >= 0;
117
+ }
118
+ function extractTurnUsage(raw) {
119
+ const block = usageBlock(raw);
120
+ if (block === void 0)
121
+ return void 0;
122
+ const usage = {
123
+ ...readCount(block, "input_tokens") !== void 0 ? { input: readCount(block, "input_tokens") } : {},
124
+ ...readCount(block, "output_tokens") !== void 0 ? { output: readCount(block, "output_tokens") } : {},
125
+ ...readCount(block, "cache_read_input_tokens") !== void 0 ? { cacheRead: readCount(block, "cache_read_input_tokens") } : {},
126
+ ...readCount(block, "cache_creation_input_tokens") !== void 0 ? { cacheCreation: readCount(block, "cache_creation_input_tokens") } : {}
127
+ };
128
+ return compactUsage(usage);
129
+ }
130
+ function usageBlock(raw) {
131
+ const top = nested(raw, "usage");
132
+ if (top !== null && typeof top === "object")
133
+ return top;
134
+ const inner = nestedRecord(nested(raw, "message"), "usage");
135
+ return inner;
136
+ }
137
+ function nestedRecord(obj, key) {
138
+ if (obj !== null && typeof obj === "object") {
139
+ const value = obj[key];
140
+ if (value !== null && typeof value === "object")
141
+ return value;
142
+ }
143
+ return void 0;
144
+ }
145
+ function readCount(block, key) {
146
+ const value = block[key];
147
+ if (typeof value !== "number" || !Number.isInteger(value) || value < 0)
148
+ return void 0;
149
+ return value;
97
150
  }
98
151
  function toolCallData(tool, input, response) {
99
152
  return { kind: "tool_call", tool, input, response };
@@ -143,7 +196,7 @@ function claudeCodeExtractData(raw, logical) {
143
196
  case "tool_call":
144
197
  return toolCallData(pickString(raw, "tool_name", "tool"), nested(raw, "tool_input"), nested(raw, "tool_response"));
145
198
  case "assistant_message":
146
- return assistantMessageData(pickString(raw, "text", "message"));
199
+ return assistantMessageData(pickString(raw, "text", "message"), extractTurnUsage(raw));
147
200
  case "session-end":
148
201
  return sessionEndData(pickString(raw, "reason") || "Stop");
149
202
  default:
@@ -83,8 +83,28 @@ function nested(raw, key) {
83
83
  function userMessageData(text) {
84
84
  return { kind: "user_message", text };
85
85
  }
86
- function assistantMessageData(text) {
87
- return { kind: "assistant_message", text };
86
+ function assistantMessageData(text, usage) {
87
+ const normalized = usage !== void 0 ? compactUsage(usage) : void 0;
88
+ return {
89
+ kind: "assistant_message",
90
+ text,
91
+ ...normalized !== void 0 ? { usage: normalized } : {}
92
+ };
93
+ }
94
+ function compactUsage(usage) {
95
+ const out = {};
96
+ if (isCount(usage.input))
97
+ out.input = usage.input;
98
+ if (isCount(usage.output))
99
+ out.output = usage.output;
100
+ if (isCount(usage.cacheRead))
101
+ out.cacheRead = usage.cacheRead;
102
+ if (isCount(usage.cacheCreation))
103
+ out.cacheCreation = usage.cacheCreation;
104
+ return Object.keys(out).length > 0 ? out : void 0;
105
+ }
106
+ function isCount(n) {
107
+ return typeof n === "number" && Number.isInteger(n) && n >= 0;
88
108
  }
89
109
  function toolCallData(tool, input, response) {
90
110
  return { kind: "tool_call", tool, input, response };
@@ -83,8 +83,28 @@ function nested(raw, key) {
83
83
  function userMessageData(text) {
84
84
  return { kind: "user_message", text };
85
85
  }
86
- function assistantMessageData(text) {
87
- return { kind: "assistant_message", text };
86
+ function assistantMessageData(text, usage) {
87
+ const normalized = usage !== void 0 ? compactUsage(usage) : void 0;
88
+ return {
89
+ kind: "assistant_message",
90
+ text,
91
+ ...normalized !== void 0 ? { usage: normalized } : {}
92
+ };
93
+ }
94
+ function compactUsage(usage) {
95
+ const out = {};
96
+ if (isCount(usage.input))
97
+ out.input = usage.input;
98
+ if (isCount(usage.output))
99
+ out.output = usage.output;
100
+ if (isCount(usage.cacheRead))
101
+ out.cacheRead = usage.cacheRead;
102
+ if (isCount(usage.cacheCreation))
103
+ out.cacheCreation = usage.cacheCreation;
104
+ return Object.keys(out).length > 0 ? out : void 0;
105
+ }
106
+ function isCount(n) {
107
+ return typeof n === "number" && Number.isInteger(n) && n >= 0;
88
108
  }
89
109
  function toolCallData(tool, input, response) {
90
110
  return { kind: "tool_call", tool, input, response };
@@ -83,8 +83,28 @@ function nested(raw, key) {
83
83
  function userMessageData(text) {
84
84
  return { kind: "user_message", text };
85
85
  }
86
- function assistantMessageData(text) {
87
- return { kind: "assistant_message", text };
86
+ function assistantMessageData(text, usage) {
87
+ const normalized = usage !== void 0 ? compactUsage(usage) : void 0;
88
+ return {
89
+ kind: "assistant_message",
90
+ text,
91
+ ...normalized !== void 0 ? { usage: normalized } : {}
92
+ };
93
+ }
94
+ function compactUsage(usage) {
95
+ const out = {};
96
+ if (isCount(usage.input))
97
+ out.input = usage.input;
98
+ if (isCount(usage.output))
99
+ out.output = usage.output;
100
+ if (isCount(usage.cacheRead))
101
+ out.cacheRead = usage.cacheRead;
102
+ if (isCount(usage.cacheCreation))
103
+ out.cacheCreation = usage.cacheCreation;
104
+ return Object.keys(out).length > 0 ? out : void 0;
105
+ }
106
+ function isCount(n) {
107
+ return typeof n === "number" && Number.isInteger(n) && n >= 0;
88
108
  }
89
109
  function toolCallData(tool, input, response) {
90
110
  return { kind: "tool_call", tool, input, response };
@@ -83,8 +83,28 @@ function nested(raw, key) {
83
83
  function userMessageData(text) {
84
84
  return { kind: "user_message", text };
85
85
  }
86
- function assistantMessageData(text) {
87
- return { kind: "assistant_message", text };
86
+ function assistantMessageData(text, usage) {
87
+ const normalized = usage !== void 0 ? compactUsage(usage) : void 0;
88
+ return {
89
+ kind: "assistant_message",
90
+ text,
91
+ ...normalized !== void 0 ? { usage: normalized } : {}
92
+ };
93
+ }
94
+ function compactUsage(usage) {
95
+ const out = {};
96
+ if (isCount(usage.input))
97
+ out.input = usage.input;
98
+ if (isCount(usage.output))
99
+ out.output = usage.output;
100
+ if (isCount(usage.cacheRead))
101
+ out.cacheRead = usage.cacheRead;
102
+ if (isCount(usage.cacheCreation))
103
+ out.cacheCreation = usage.cacheCreation;
104
+ return Object.keys(out).length > 0 ? out : void 0;
105
+ }
106
+ function isCount(n) {
107
+ return typeof n === "number" && Number.isInteger(n) && n >= 0;
88
108
  }
89
109
  function toolCallData(tool, input, response) {
90
110
  return { kind: "tool_call", tool, input, response };
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "honeycomb-codex",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "description": "Honeycomb — persistent shared memory for OpenAI Codex CLI via the local Honeycomb daemon",
5
5
  "type": "module",
6
6
  "license": "MIT"
@@ -83,8 +83,28 @@ function nested(raw, key) {
83
83
  function userMessageData(text) {
84
84
  return { kind: "user_message", text };
85
85
  }
86
- function assistantMessageData(text) {
87
- return { kind: "assistant_message", text };
86
+ function assistantMessageData(text, usage) {
87
+ const normalized = usage !== void 0 ? compactUsage(usage) : void 0;
88
+ return {
89
+ kind: "assistant_message",
90
+ text,
91
+ ...normalized !== void 0 ? { usage: normalized } : {}
92
+ };
93
+ }
94
+ function compactUsage(usage) {
95
+ const out = {};
96
+ if (isCount(usage.input))
97
+ out.input = usage.input;
98
+ if (isCount(usage.output))
99
+ out.output = usage.output;
100
+ if (isCount(usage.cacheRead))
101
+ out.cacheRead = usage.cacheRead;
102
+ if (isCount(usage.cacheCreation))
103
+ out.cacheCreation = usage.cacheCreation;
104
+ return Object.keys(out).length > 0 ? out : void 0;
105
+ }
106
+ function isCount(n) {
107
+ return typeof n === "number" && Number.isInteger(n) && n >= 0;
88
108
  }
89
109
  function toolCallData(tool, input, response) {
90
110
  return { kind: "tool_call", tool, input, response };
@@ -83,8 +83,28 @@ function nested(raw, key) {
83
83
  function userMessageData(text) {
84
84
  return { kind: "user_message", text };
85
85
  }
86
- function assistantMessageData(text) {
87
- return { kind: "assistant_message", text };
86
+ function assistantMessageData(text, usage) {
87
+ const normalized = usage !== void 0 ? compactUsage(usage) : void 0;
88
+ return {
89
+ kind: "assistant_message",
90
+ text,
91
+ ...normalized !== void 0 ? { usage: normalized } : {}
92
+ };
93
+ }
94
+ function compactUsage(usage) {
95
+ const out = {};
96
+ if (isCount(usage.input))
97
+ out.input = usage.input;
98
+ if (isCount(usage.output))
99
+ out.output = usage.output;
100
+ if (isCount(usage.cacheRead))
101
+ out.cacheRead = usage.cacheRead;
102
+ if (isCount(usage.cacheCreation))
103
+ out.cacheCreation = usage.cacheCreation;
104
+ return Object.keys(out).length > 0 ? out : void 0;
105
+ }
106
+ function isCount(n) {
107
+ return typeof n === "number" && Number.isInteger(n) && n >= 0;
88
108
  }
89
109
  function toolCallData(tool, input, response) {
90
110
  return { kind: "tool_call", tool, input, response };
@@ -83,8 +83,28 @@ function nested(raw, key) {
83
83
  function userMessageData(text) {
84
84
  return { kind: "user_message", text };
85
85
  }
86
- function assistantMessageData(text) {
87
- return { kind: "assistant_message", text };
86
+ function assistantMessageData(text, usage) {
87
+ const normalized = usage !== void 0 ? compactUsage(usage) : void 0;
88
+ return {
89
+ kind: "assistant_message",
90
+ text,
91
+ ...normalized !== void 0 ? { usage: normalized } : {}
92
+ };
93
+ }
94
+ function compactUsage(usage) {
95
+ const out = {};
96
+ if (isCount(usage.input))
97
+ out.input = usage.input;
98
+ if (isCount(usage.output))
99
+ out.output = usage.output;
100
+ if (isCount(usage.cacheRead))
101
+ out.cacheRead = usage.cacheRead;
102
+ if (isCount(usage.cacheCreation))
103
+ out.cacheCreation = usage.cacheCreation;
104
+ return Object.keys(out).length > 0 ? out : void 0;
105
+ }
106
+ function isCount(n) {
107
+ return typeof n === "number" && Number.isInteger(n) && n >= 0;
88
108
  }
89
109
  function toolCallData(tool, input, response) {
90
110
  return { kind: "tool_call", tool, input, response };
@@ -83,8 +83,28 @@ function nested(raw, key) {
83
83
  function userMessageData(text) {
84
84
  return { kind: "user_message", text };
85
85
  }
86
- function assistantMessageData(text) {
87
- return { kind: "assistant_message", text };
86
+ function assistantMessageData(text, usage) {
87
+ const normalized = usage !== void 0 ? compactUsage(usage) : void 0;
88
+ return {
89
+ kind: "assistant_message",
90
+ text,
91
+ ...normalized !== void 0 ? { usage: normalized } : {}
92
+ };
93
+ }
94
+ function compactUsage(usage) {
95
+ const out = {};
96
+ if (isCount(usage.input))
97
+ out.input = usage.input;
98
+ if (isCount(usage.output))
99
+ out.output = usage.output;
100
+ if (isCount(usage.cacheRead))
101
+ out.cacheRead = usage.cacheRead;
102
+ if (isCount(usage.cacheCreation))
103
+ out.cacheCreation = usage.cacheCreation;
104
+ return Object.keys(out).length > 0 ? out : void 0;
105
+ }
106
+ function isCount(n) {
107
+ return typeof n === "number" && Number.isInteger(n) && n >= 0;
88
108
  }
89
109
  function toolCallData(tool, input, response) {
90
110
  return { kind: "tool_call", tool, input, response };