@dudousxd/nestjs-agent-store-drizzle 0.16.0 → 0.17.0
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/dist/index.cjs +5 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +5 -2
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.d.cts
CHANGED
|
@@ -4036,6 +4036,10 @@ declare class DrizzleAgentStore implements AgentStore, ThreadTurnReader {
|
|
|
4036
4036
|
usedTokens: number;
|
|
4037
4037
|
costUsd: number;
|
|
4038
4038
|
}>;
|
|
4039
|
+
usageBetween(actorRef: string, fromDay: string, toDay: string): Promise<{
|
|
4040
|
+
usedTokens: number;
|
|
4041
|
+
costUsd: number;
|
|
4042
|
+
}>;
|
|
4039
4043
|
private toSummary;
|
|
4040
4044
|
private toStoredMessage;
|
|
4041
4045
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -4036,6 +4036,10 @@ declare class DrizzleAgentStore implements AgentStore, ThreadTurnReader {
|
|
|
4036
4036
|
usedTokens: number;
|
|
4037
4037
|
costUsd: number;
|
|
4038
4038
|
}>;
|
|
4039
|
+
usageBetween(actorRef: string, fromDay: string, toDay: string): Promise<{
|
|
4040
|
+
usedTokens: number;
|
|
4041
|
+
costUsd: number;
|
|
4042
|
+
}>;
|
|
4039
4043
|
private toSummary;
|
|
4040
4044
|
private toStoredMessage;
|
|
4041
4045
|
}
|
package/dist/index.js
CHANGED
|
@@ -978,8 +978,11 @@ var DrizzleAgentStore = class {
|
|
|
978
978
|
});
|
|
979
979
|
}
|
|
980
980
|
async quotaToday(actorRef, day) {
|
|
981
|
-
|
|
982
|
-
|
|
981
|
+
return this.usageBetween(actorRef, day, day);
|
|
982
|
+
}
|
|
983
|
+
async usageBetween(actorRef, fromDay, toDay) {
|
|
984
|
+
const start = /* @__PURE__ */ new Date(`${fromDay}T00:00:00.000Z`);
|
|
985
|
+
const end = /* @__PURE__ */ new Date(`${toDay}T23:59:59.999Z`);
|
|
983
986
|
const rows = await this.db.select().from(agentTokenUsage).where(and(eq(agentTokenUsage.actorRef, actorRef), gte(agentTokenUsage.createdAt, start), lte(agentTokenUsage.createdAt, end)));
|
|
984
987
|
const usedTokens = rows.reduce((sum2, row) => sum2 + row.inputTokens + row.outputTokens, 0);
|
|
985
988
|
const costUsd = rows.reduce((sum2, row) => sum2 + (row.costUsd ?? 0), 0);
|