@polka-codes/core 0.9.34 → 0.9.36

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.
@@ -321,6 +321,7 @@ declare type CommandProvider = {
321
321
  stdout: string;
322
322
  stderr: string;
323
323
  exitCode: number;
324
+ summary?: string;
324
325
  }>;
325
326
  };
326
327
  export { CommandProvider }
@@ -381,6 +382,7 @@ declare const configSchema: z.ZodObject<{
381
382
  budget: z.ZodOptional<z.ZodNumber>;
382
383
  retryCount: z.ZodOptional<z.ZodNumber>;
383
384
  requestTimeoutSeconds: z.ZodOptional<z.ZodNumber>;
385
+ summaryThreshold: z.ZodOptional<z.ZodNumber>;
384
386
  scripts: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodObject<{
385
387
  command: z.ZodString;
386
388
  description: z.ZodString;
@@ -1036,6 +1038,7 @@ declare class MockProvider implements ToolProvider {
1036
1038
  stdout: string;
1037
1039
  stderr: string;
1038
1040
  exitCode: number;
1041
+ summary?: string;
1039
1042
  }>;
1040
1043
  askFollowupQuestion(_question: string, _options?: string[]): Promise<string>;
1041
1044
  attemptCompletion(_result: string): Promise<string | undefined>;
@@ -1931,6 +1934,8 @@ declare class UsageMeter {
1931
1934
  cost: number;
1932
1935
  messageCount: number;
1933
1936
  };
1937
+ /** Merge another UsageMeter's totals into this one. */
1938
+ merge(other: UsageMeter): void;
1934
1939
  /** Print a concise usage summary to console. */
1935
1940
  printUsage(customConsole?: Console): void;
1936
1941
  onFinishHandler(llm: LanguageModelV2): (evt: {
package/dist/index.js CHANGED
@@ -266,14 +266,23 @@ var handler4 = async (provider, args) => {
266
266
  try {
267
267
  console.log("Executing command:", command2, "Requires approval:", requiresApproval);
268
268
  const result = await provider.executeCommand(command2, requiresApproval);
269
- const message = `<command>${command2}</command>
269
+ let message = `<command>${command2}</command>
270
270
  <command_exit_code>${result.exitCode}</command_exit_code>
271
- <command_stdout>
271
+ `;
272
+ if (result.summary) {
273
+ message += `<command_output_summary>
274
+ ${result.summary}
275
+ </command_output_summary>
276
+ `;
277
+ } else {
278
+ message += `<command_stdout>
272
279
  ${result.stdout}
273
280
  </command_stdout>
274
281
  <command_stderr>
275
282
  ${result.stderr}
276
- </command_stderr>`;
283
+ </command_stderr>
284
+ `;
285
+ }
277
286
  if (result.exitCode === 0) {
278
287
  return {
279
288
  type: "Reply" /* Reply */,
@@ -1322,10 +1331,10 @@ var UsageMeter = class {
1322
1331
  };
1323
1332
  const usage = "totalUsage" in resp ? resp.totalUsage : resp.usage;
1324
1333
  const result = this.#calculageUsage(usage, resp.providerMetadata, modelInfo);
1325
- this.#totals.input += result.input;
1326
- this.#totals.output += result.output;
1327
- this.#totals.cachedRead += result.cachedRead;
1328
- this.#totals.cost += result.cost;
1334
+ this.#totals.input += result.input || 0;
1335
+ this.#totals.output += result.output || 0;
1336
+ this.#totals.cachedRead += result.cachedRead || 0;
1337
+ this.#totals.cost += result.cost || 0;
1329
1338
  this.#totals.messageCount += 1;
1330
1339
  }
1331
1340
  /** Override the running totals (e.g., restore from saved state). */
@@ -1369,6 +1378,15 @@ var UsageMeter = class {
1369
1378
  get usage() {
1370
1379
  return { ...this.#totals };
1371
1380
  }
1381
+ /** Merge another UsageMeter's totals into this one. */
1382
+ merge(other) {
1383
+ const otherUsage = other.usage;
1384
+ this.#totals.input += otherUsage.input;
1385
+ this.#totals.output += otherUsage.output;
1386
+ this.#totals.cachedRead += otherUsage.cachedRead;
1387
+ this.#totals.cost += otherUsage.cost;
1388
+ this.#totals.messageCount += otherUsage.messageCount;
1389
+ }
1372
1390
  /** Print a concise usage summary to console. */
1373
1391
  printUsage(customConsole = console) {
1374
1392
  const u = this.usage;
@@ -3191,6 +3209,7 @@ var configSchema = z16.object({
3191
3209
  budget: z16.number().positive().optional(),
3192
3210
  retryCount: z16.number().int().min(0).optional(),
3193
3211
  requestTimeoutSeconds: z16.number().int().positive().optional(),
3212
+ summaryThreshold: z16.number().int().positive().optional(),
3194
3213
  scripts: z16.record(
3195
3214
  z16.string(),
3196
3215
  z16.string().or(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@polka-codes/core",
3
- "version": "0.9.34",
3
+ "version": "0.9.36",
4
4
  "license": "AGPL-3.0",
5
5
  "author": "github@polka.codes",
6
6
  "type": "module",