@polka-codes/core 0.9.36 → 0.9.37

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.
@@ -1,6 +1,7 @@
1
1
  import type { FilePart } from 'ai';
2
2
  import type { ImagePart } from 'ai';
3
3
  import type { JSONValue } from '@ai-sdk/provider';
4
+ import { LanguageModelUsage } from 'ai';
4
5
  import type { LanguageModelV2 } from '@ai-sdk/provider';
5
6
  import type { LanguageModelV2ToolResultOutput } from '@ai-sdk/provider';
6
7
  import type { LanguageModelV2Usage } from '@ai-sdk/provider';
@@ -1509,6 +1510,7 @@ export { TaskEventToolUse as TaskEventToolUse_alias_2 }
1509
1510
  */
1510
1511
  declare interface TaskEventUsage extends TaskEventBase {
1511
1512
  kind: TaskEventKind.Usage;
1513
+ usage: LanguageModelUsage;
1512
1514
  }
1513
1515
  export { TaskEventUsage }
1514
1516
  export { TaskEventUsage as TaskEventUsage_alias_1 }
package/dist/index.js CHANGED
@@ -2065,6 +2065,7 @@ Request timeout after ${requestTimeoutSeconds} seconds. Canceling current reques
2065
2065
  };
2066
2066
  try {
2067
2067
  resetTimeout();
2068
+ const usageMeterOnFinishHandler = this.config.usageMeter.onFinishHandler(this.ai);
2068
2069
  const streamTextOptions = {
2069
2070
  model: this.ai,
2070
2071
  temperature: 0,
@@ -2083,7 +2084,10 @@ Request timeout after ${requestTimeoutSeconds} seconds. Canceling current reques
2083
2084
  break;
2084
2085
  }
2085
2086
  },
2086
- onFinish: this.config.usageMeter.onFinishHandler(this.ai),
2087
+ onFinish: (evt) => {
2088
+ usageMeterOnFinishHandler(evt);
2089
+ this.#callback({ kind: "Usage" /* Usage */, agent: this, usage: evt.totalUsage });
2090
+ },
2087
2091
  onError: async (error) => {
2088
2092
  console.error("Error in stream:", error);
2089
2093
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@polka-codes/core",
3
- "version": "0.9.36",
3
+ "version": "0.9.37",
4
4
  "license": "AGPL-3.0",
5
5
  "author": "github@polka.codes",
6
6
  "type": "module",