mini-coder 0.5.12 → 0.5.14
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/BENCHMARK.md +15 -316
- package/PROGRESS.md +3 -3
- package/README.md +54 -21
- package/benchmark-baseline.sh +15 -0
- package/bun.lock +265 -90
- package/package.json +8 -7
- package/skills-lock.json +15 -0
- package/src/agent.ts +526 -13
- package/src/assistant-output.ts +73 -0
- package/src/cli.ts +2 -1
- package/src/delegation.ts +238 -0
- package/src/headless.ts +90 -44
- package/src/index.ts +267 -102
- package/src/input.ts +13 -1
- package/src/mcp.ts +609 -0
- package/src/prompt.ts +11 -13
- package/src/session-message.ts +57 -65
- package/src/session.ts +389 -42
- package/src/settings.ts +199 -7
- package/src/skills.ts +12 -3
- package/src/submit.ts +24 -2
- package/src/theme.ts +186 -3
- package/src/tool-common.ts +2 -0
- package/src/tool-delegate.ts +125 -0
- package/src/tool-shell.ts +190 -8
- package/src/tools.ts +335 -6
- package/src/ui/agent.ts +10 -0
- package/src/ui/commands.test.ts +525 -10
- package/src/ui/commands.ts +224 -8
- package/src/ui/conversation.test.ts +252 -27
- package/src/ui/conversation.ts +468 -390
- package/src/ui/help.ts +27 -11
- package/src/ui.ts +230 -75
- package/src/plugins.ts +0 -183
package/src/session-message.ts
CHANGED
|
@@ -126,23 +126,61 @@ function isToolCallContentBlock(
|
|
|
126
126
|
);
|
|
127
127
|
}
|
|
128
128
|
|
|
129
|
-
|
|
129
|
+
/**
|
|
130
|
+
* Parse and validate an assistant usage payload from unknown input.
|
|
131
|
+
*
|
|
132
|
+
* @param value - Unknown value to validate.
|
|
133
|
+
* @returns The parsed assistant usage, or `null` when invalid.
|
|
134
|
+
*/
|
|
135
|
+
export function readAssistantUsage(
|
|
136
|
+
value: unknown,
|
|
137
|
+
): AssistantMessage["usage"] | null {
|
|
130
138
|
const usageRecord = toRecord(value);
|
|
131
139
|
const costRecord = toRecord(usageRecord?.cost);
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
);
|
|
140
|
+
if (!usageRecord || !costRecord) {
|
|
141
|
+
return null;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const input = readFiniteNumber(usageRecord, "input");
|
|
145
|
+
const output = readFiniteNumber(usageRecord, "output");
|
|
146
|
+
const cacheRead = readFiniteNumber(usageRecord, "cacheRead");
|
|
147
|
+
const cacheWrite = readFiniteNumber(usageRecord, "cacheWrite");
|
|
148
|
+
const totalTokens = readFiniteNumber(usageRecord, "totalTokens");
|
|
149
|
+
const costInput = readFiniteNumber(costRecord, "input");
|
|
150
|
+
const costOutput = readFiniteNumber(costRecord, "output");
|
|
151
|
+
const costCacheRead = readFiniteNumber(costRecord, "cacheRead");
|
|
152
|
+
const costCacheWrite = readFiniteNumber(costRecord, "cacheWrite");
|
|
153
|
+
const costTotal = readFiniteNumber(costRecord, "total");
|
|
154
|
+
|
|
155
|
+
if (
|
|
156
|
+
input === null ||
|
|
157
|
+
output === null ||
|
|
158
|
+
cacheRead === null ||
|
|
159
|
+
cacheWrite === null ||
|
|
160
|
+
totalTokens === null ||
|
|
161
|
+
costInput === null ||
|
|
162
|
+
costOutput === null ||
|
|
163
|
+
costCacheRead === null ||
|
|
164
|
+
costCacheWrite === null ||
|
|
165
|
+
costTotal === null
|
|
166
|
+
) {
|
|
167
|
+
return null;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
return {
|
|
171
|
+
input,
|
|
172
|
+
output,
|
|
173
|
+
cacheRead,
|
|
174
|
+
cacheWrite,
|
|
175
|
+
totalTokens,
|
|
176
|
+
cost: {
|
|
177
|
+
input: costInput,
|
|
178
|
+
output: costOutput,
|
|
179
|
+
cacheRead: costCacheRead,
|
|
180
|
+
cacheWrite: costCacheWrite,
|
|
181
|
+
total: costTotal,
|
|
182
|
+
},
|
|
183
|
+
};
|
|
146
184
|
}
|
|
147
185
|
|
|
148
186
|
function isStopReason(value: unknown): value is AssistantMessage["stopReason"] {
|
|
@@ -206,9 +244,9 @@ function parseAssistantMessageRecord(value: unknown): AssistantMessage | null {
|
|
|
206
244
|
api,
|
|
207
245
|
provider,
|
|
208
246
|
model,
|
|
209
|
-
usage:
|
|
210
|
-
|
|
211
|
-
|
|
247
|
+
usage:
|
|
248
|
+
readAssistantUsage(record.usage) ??
|
|
249
|
+
structuredClone(EMPTY_ASSISTANT_USAGE),
|
|
212
250
|
stopReason: record.stopReason,
|
|
213
251
|
...(errorMessage !== null ? { errorMessage } : {}),
|
|
214
252
|
timestamp,
|
|
@@ -343,51 +381,5 @@ export function getAssistantUsage(
|
|
|
343
381
|
return null;
|
|
344
382
|
}
|
|
345
383
|
|
|
346
|
-
|
|
347
|
-
const usageRecord = toRecord(messageRecord?.usage);
|
|
348
|
-
const costRecord = toRecord(usageRecord?.cost);
|
|
349
|
-
if (!usageRecord || !costRecord) {
|
|
350
|
-
return null;
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
const input = readFiniteNumber(usageRecord, "input");
|
|
354
|
-
const output = readFiniteNumber(usageRecord, "output");
|
|
355
|
-
const cacheRead = readFiniteNumber(usageRecord, "cacheRead");
|
|
356
|
-
const cacheWrite = readFiniteNumber(usageRecord, "cacheWrite");
|
|
357
|
-
const totalTokens = readFiniteNumber(usageRecord, "totalTokens");
|
|
358
|
-
const costInput = readFiniteNumber(costRecord, "input");
|
|
359
|
-
const costOutput = readFiniteNumber(costRecord, "output");
|
|
360
|
-
const costCacheRead = readFiniteNumber(costRecord, "cacheRead");
|
|
361
|
-
const costCacheWrite = readFiniteNumber(costRecord, "cacheWrite");
|
|
362
|
-
const costTotal = readFiniteNumber(costRecord, "total");
|
|
363
|
-
|
|
364
|
-
if (
|
|
365
|
-
input === null ||
|
|
366
|
-
output === null ||
|
|
367
|
-
cacheRead === null ||
|
|
368
|
-
cacheWrite === null ||
|
|
369
|
-
totalTokens === null ||
|
|
370
|
-
costInput === null ||
|
|
371
|
-
costOutput === null ||
|
|
372
|
-
costCacheRead === null ||
|
|
373
|
-
costCacheWrite === null ||
|
|
374
|
-
costTotal === null
|
|
375
|
-
) {
|
|
376
|
-
return null;
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
return {
|
|
380
|
-
input,
|
|
381
|
-
output,
|
|
382
|
-
cacheRead,
|
|
383
|
-
cacheWrite,
|
|
384
|
-
totalTokens,
|
|
385
|
-
cost: {
|
|
386
|
-
input: costInput,
|
|
387
|
-
output: costOutput,
|
|
388
|
-
cacheRead: costCacheRead,
|
|
389
|
-
cacheWrite: costCacheWrite,
|
|
390
|
-
total: costTotal,
|
|
391
|
-
},
|
|
392
|
-
};
|
|
384
|
+
return readAssistantUsage(toRecord(message)?.usage);
|
|
393
385
|
}
|