@dudousxd/nestjs-agent-store-drizzle 0.28.6 → 0.29.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 +9 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +81 -9
- package/dist/index.d.ts +81 -9
- package/dist/index.js +10 -8
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _dudousxd_nestjs_agent_core from '@dudousxd/nestjs-agent-core';
|
|
2
|
-
import { MessageRole, ToolCallRequest, ToolResult, MessageAttachment, MessageUsage, AgentUiComponent, MessageFeedback, AgentHostContext, Actor, PageContext, QueuePause, ActionProposal, ToolKind, ToolCallStatus, ToolConfirmation, UsagePurpose, AgentStore, ThreadTurnReader, ChatQueueStore, ActionProposalStore, ActionProposalWorkerStore, ActionProposalDiscoveryIndexStore, ActionProposalOutcomeStore, ActionProposalStoreOptions, ActionProposalSupersessionStore, CreateThreadInput, ThreadSummary, ThreadDetail, ThreadTurnQuery, ThreadTurnPage, ToolCallApprovalState, EnqueueMessageInput, QueuedMessage, QueuedMessagePatch, UpdateThreadInput, RecordRunStartInput, AppendMessageInput, StoredMessage, RecordToolCallInput, UpdateToolCallInput, ToolCallOutcome, RecordUsageInput, CreateActionProposal, CreateActionProposalResult, ActionProposalScope, ActionProposalMutationResult, ListActionProposals, ActionProposalDecisionCommand, ClaimActionProposal, ExtendActionProposalLease, SettleActionProposal, ActionProposalOutcomeLease, AgentGovernanceQueries, AgentPricingStore, GovernanceRange, ModelSpendRow, ActorSpendRow, ThreadSpendRow, UsageTrendPoint, ToolCallActivityRow, ThreadActivityRow, RunMetrics, RunAgentBreakdownRow, RunErrorBreakdownRow, RunTrendPoint, RecentRunRow, PendingApprovalRow, ToolStatRow, GovernancePageQuery, ToolCallWhere, GovernancePage, ThreadWhere, RunWhere, ApprovalWhere, GovernanceRunDetail, GovernanceThreadDetailQuery, GovernanceThreadDetail, MemoryProvider, ListMemoriesInput, MemoryRecord, ForgetMemoryInput, StoreMemoryInput, ModelPriceInput, CurrentModelPrice, StreamFrameTable, StreamFrameRow, SqlTokenStreamSink, SqlTokenStreamSinkOptions, ConfirmTokenStore, ConfirmTokenClaim, ChannelStore } from '@dudousxd/nestjs-agent-core';
|
|
2
|
+
import { MessageRole, ToolCallRequest, ToolResult, MessageAttachment, MessageUsage, AgentUiComponent, MessageFeedback, AgentHostContext, Actor, PageContext, QueuePause, ActionProposal, ToolKind, ToolCallStatus, ToolConfirmation, UsagePurpose, CostSource, AgentStore, ThreadTurnReader, ChatQueueStore, ActionProposalStore, ActionProposalWorkerStore, ActionProposalDiscoveryIndexStore, ActionProposalOutcomeStore, ActionProposalStoreOptions, ActionProposalSupersessionStore, CreateThreadInput, ThreadSummary, ThreadDetail, ThreadTurnQuery, ThreadTurnPage, ToolCallApprovalState, EnqueueMessageInput, QueuedMessage, QueuedMessagePatch, UpdateThreadInput, RecordRunStartInput, AppendMessageInput, StoredMessage, RecordToolCallInput, UpdateToolCallInput, ToolCallOutcome, RecordUsageInput, UsageTotals, CreateActionProposal, CreateActionProposalResult, ActionProposalScope, ActionProposalMutationResult, ListActionProposals, ActionProposalDecisionCommand, ClaimActionProposal, ExtendActionProposalLease, SettleActionProposal, ActionProposalOutcomeLease, AgentGovernanceQueries, AgentPricingStore, GovernanceRange, ModelSpendRow, ActorSpendRow, ThreadSpendRow, UsageTrendPoint, ToolCallActivityRow, ThreadActivityRow, RunMetrics, RunAgentBreakdownRow, RunErrorBreakdownRow, RunTrendPoint, RecentRunRow, PendingApprovalRow, ToolStatRow, GovernancePageQuery, ToolCallWhere, GovernancePage, ThreadWhere, RunWhere, ApprovalWhere, GovernanceRunDetail, GovernanceThreadDetailQuery, GovernanceThreadDetail, MemoryProvider, ListMemoriesInput, MemoryRecord, ForgetMemoryInput, StoreMemoryInput, ModelPriceInput, CurrentModelPrice, StreamFrameTable, StreamFrameRow, SqlTokenStreamSink, SqlTokenStreamSinkOptions, ConfirmTokenStore, ConfirmTokenClaim, ChannelStore } from '@dudousxd/nestjs-agent-core';
|
|
3
3
|
export { ThreadTurnPage, ThreadTurnQuery } from '@dudousxd/nestjs-agent-core';
|
|
4
4
|
import * as drizzle_orm_sqlite_core from 'drizzle-orm/sqlite-core';
|
|
5
5
|
import { BaseSQLiteDatabase } from 'drizzle-orm/sqlite-core';
|
|
@@ -1514,6 +1514,26 @@ declare const agentTokenUsage: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
|
|
|
1514
1514
|
identity: undefined;
|
|
1515
1515
|
generated: undefined;
|
|
1516
1516
|
}, {}, {}>;
|
|
1517
|
+
costSource: drizzle_orm_sqlite_core.SQLiteColumn<{
|
|
1518
|
+
name: "cost_source";
|
|
1519
|
+
tableName: "agent_token_usage";
|
|
1520
|
+
dataType: "string";
|
|
1521
|
+
columnType: "SQLiteText";
|
|
1522
|
+
data: CostSource;
|
|
1523
|
+
driverParam: string;
|
|
1524
|
+
notNull: false;
|
|
1525
|
+
hasDefault: false;
|
|
1526
|
+
isPrimaryKey: false;
|
|
1527
|
+
isAutoincrement: false;
|
|
1528
|
+
hasRuntimeDefault: false;
|
|
1529
|
+
enumValues: [string, ...string[]];
|
|
1530
|
+
baseColumn: never;
|
|
1531
|
+
identity: undefined;
|
|
1532
|
+
generated: undefined;
|
|
1533
|
+
}, {}, {
|
|
1534
|
+
length: number | undefined;
|
|
1535
|
+
$type: CostSource;
|
|
1536
|
+
}>;
|
|
1517
1537
|
createdAt: drizzle_orm_sqlite_core.SQLiteColumn<{
|
|
1518
1538
|
name: "created_at";
|
|
1519
1539
|
tableName: "agent_token_usage";
|
|
@@ -4787,6 +4807,26 @@ declare const agentSchema: {
|
|
|
4787
4807
|
identity: undefined;
|
|
4788
4808
|
generated: undefined;
|
|
4789
4809
|
}, {}, {}>;
|
|
4810
|
+
costSource: drizzle_orm_sqlite_core.SQLiteColumn<{
|
|
4811
|
+
name: "cost_source";
|
|
4812
|
+
tableName: "agent_token_usage";
|
|
4813
|
+
dataType: "string";
|
|
4814
|
+
columnType: "SQLiteText";
|
|
4815
|
+
data: CostSource;
|
|
4816
|
+
driverParam: string;
|
|
4817
|
+
notNull: false;
|
|
4818
|
+
hasDefault: false;
|
|
4819
|
+
isPrimaryKey: false;
|
|
4820
|
+
isAutoincrement: false;
|
|
4821
|
+
hasRuntimeDefault: false;
|
|
4822
|
+
enumValues: [string, ...string[]];
|
|
4823
|
+
baseColumn: never;
|
|
4824
|
+
identity: undefined;
|
|
4825
|
+
generated: undefined;
|
|
4826
|
+
}, {}, {
|
|
4827
|
+
length: number | undefined;
|
|
4828
|
+
$type: CostSource;
|
|
4829
|
+
}>;
|
|
4790
4830
|
createdAt: drizzle_orm_sqlite_core.SQLiteColumn<{
|
|
4791
4831
|
name: "created_at";
|
|
4792
4832
|
tableName: "agent_token_usage";
|
|
@@ -6152,14 +6192,8 @@ declare class DrizzleAgentStore implements AgentStore, ThreadTurnReader, ChatQue
|
|
|
6152
6192
|
*/
|
|
6153
6193
|
referencedMediaIds(actorRef: string, mediaIds: readonly string[]): Promise<string[]>;
|
|
6154
6194
|
recordUsage(input: RecordUsageInput): Promise<void>;
|
|
6155
|
-
quotaToday(actorRef: string, day: string): Promise<
|
|
6156
|
-
|
|
6157
|
-
costUsd: number;
|
|
6158
|
-
}>;
|
|
6159
|
-
usageBetween(actorRef: string, fromDay: string, toDay: string): Promise<{
|
|
6160
|
-
usedTokens: number;
|
|
6161
|
-
costUsd: number;
|
|
6162
|
-
}>;
|
|
6195
|
+
quotaToday(actorRef: string, day: string): Promise<UsageTotals>;
|
|
6196
|
+
usageBetween(actorRef: string, fromDay: string, toDay: string): Promise<UsageTotals>;
|
|
6163
6197
|
private toSummary;
|
|
6164
6198
|
private toStoredMessage;
|
|
6165
6199
|
}
|
|
@@ -8390,6 +8424,25 @@ declare const pgAgentSchema: {
|
|
|
8390
8424
|
identity: undefined;
|
|
8391
8425
|
generated: undefined;
|
|
8392
8426
|
}, {}, {}>;
|
|
8427
|
+
costSource: drizzle_orm_pg_core.PgColumn<{
|
|
8428
|
+
name: "cost_source";
|
|
8429
|
+
tableName: "agent_token_usage";
|
|
8430
|
+
dataType: "string";
|
|
8431
|
+
columnType: "PgText";
|
|
8432
|
+
data: CostSource;
|
|
8433
|
+
driverParam: string;
|
|
8434
|
+
notNull: false;
|
|
8435
|
+
hasDefault: false;
|
|
8436
|
+
isPrimaryKey: false;
|
|
8437
|
+
isAutoincrement: false;
|
|
8438
|
+
hasRuntimeDefault: false;
|
|
8439
|
+
enumValues: [string, ...string[]];
|
|
8440
|
+
baseColumn: never;
|
|
8441
|
+
identity: undefined;
|
|
8442
|
+
generated: undefined;
|
|
8443
|
+
}, {}, {
|
|
8444
|
+
$type: CostSource;
|
|
8445
|
+
}>;
|
|
8393
8446
|
createdAt: drizzle_orm_pg_core.PgColumn<{
|
|
8394
8447
|
name: string;
|
|
8395
8448
|
tableName: "agent_token_usage";
|
|
@@ -11132,6 +11185,25 @@ declare const mysqlAgentSchema: {
|
|
|
11132
11185
|
identity: undefined;
|
|
11133
11186
|
generated: undefined;
|
|
11134
11187
|
}, {}, {}>;
|
|
11188
|
+
costSource: drizzle_orm_mysql_core.MySqlColumn<{
|
|
11189
|
+
name: string;
|
|
11190
|
+
tableName: "agent_token_usage";
|
|
11191
|
+
dataType: "string";
|
|
11192
|
+
columnType: "MySqlVarChar";
|
|
11193
|
+
data: CostSource;
|
|
11194
|
+
driverParam: string | number;
|
|
11195
|
+
notNull: false;
|
|
11196
|
+
hasDefault: false;
|
|
11197
|
+
isPrimaryKey: false;
|
|
11198
|
+
isAutoincrement: false;
|
|
11199
|
+
hasRuntimeDefault: false;
|
|
11200
|
+
enumValues: [string, ...string[]];
|
|
11201
|
+
baseColumn: never;
|
|
11202
|
+
identity: undefined;
|
|
11203
|
+
generated: undefined;
|
|
11204
|
+
}, {}, {
|
|
11205
|
+
$type: CostSource;
|
|
11206
|
+
}>;
|
|
11135
11207
|
createdAt: drizzle_orm_mysql_core.MySqlColumn<{
|
|
11136
11208
|
name: string;
|
|
11137
11209
|
tableName: "agent_token_usage";
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _dudousxd_nestjs_agent_core from '@dudousxd/nestjs-agent-core';
|
|
2
|
-
import { MessageRole, ToolCallRequest, ToolResult, MessageAttachment, MessageUsage, AgentUiComponent, MessageFeedback, AgentHostContext, Actor, PageContext, QueuePause, ActionProposal, ToolKind, ToolCallStatus, ToolConfirmation, UsagePurpose, AgentStore, ThreadTurnReader, ChatQueueStore, ActionProposalStore, ActionProposalWorkerStore, ActionProposalDiscoveryIndexStore, ActionProposalOutcomeStore, ActionProposalStoreOptions, ActionProposalSupersessionStore, CreateThreadInput, ThreadSummary, ThreadDetail, ThreadTurnQuery, ThreadTurnPage, ToolCallApprovalState, EnqueueMessageInput, QueuedMessage, QueuedMessagePatch, UpdateThreadInput, RecordRunStartInput, AppendMessageInput, StoredMessage, RecordToolCallInput, UpdateToolCallInput, ToolCallOutcome, RecordUsageInput, CreateActionProposal, CreateActionProposalResult, ActionProposalScope, ActionProposalMutationResult, ListActionProposals, ActionProposalDecisionCommand, ClaimActionProposal, ExtendActionProposalLease, SettleActionProposal, ActionProposalOutcomeLease, AgentGovernanceQueries, AgentPricingStore, GovernanceRange, ModelSpendRow, ActorSpendRow, ThreadSpendRow, UsageTrendPoint, ToolCallActivityRow, ThreadActivityRow, RunMetrics, RunAgentBreakdownRow, RunErrorBreakdownRow, RunTrendPoint, RecentRunRow, PendingApprovalRow, ToolStatRow, GovernancePageQuery, ToolCallWhere, GovernancePage, ThreadWhere, RunWhere, ApprovalWhere, GovernanceRunDetail, GovernanceThreadDetailQuery, GovernanceThreadDetail, MemoryProvider, ListMemoriesInput, MemoryRecord, ForgetMemoryInput, StoreMemoryInput, ModelPriceInput, CurrentModelPrice, StreamFrameTable, StreamFrameRow, SqlTokenStreamSink, SqlTokenStreamSinkOptions, ConfirmTokenStore, ConfirmTokenClaim, ChannelStore } from '@dudousxd/nestjs-agent-core';
|
|
2
|
+
import { MessageRole, ToolCallRequest, ToolResult, MessageAttachment, MessageUsage, AgentUiComponent, MessageFeedback, AgentHostContext, Actor, PageContext, QueuePause, ActionProposal, ToolKind, ToolCallStatus, ToolConfirmation, UsagePurpose, CostSource, AgentStore, ThreadTurnReader, ChatQueueStore, ActionProposalStore, ActionProposalWorkerStore, ActionProposalDiscoveryIndexStore, ActionProposalOutcomeStore, ActionProposalStoreOptions, ActionProposalSupersessionStore, CreateThreadInput, ThreadSummary, ThreadDetail, ThreadTurnQuery, ThreadTurnPage, ToolCallApprovalState, EnqueueMessageInput, QueuedMessage, QueuedMessagePatch, UpdateThreadInput, RecordRunStartInput, AppendMessageInput, StoredMessage, RecordToolCallInput, UpdateToolCallInput, ToolCallOutcome, RecordUsageInput, UsageTotals, CreateActionProposal, CreateActionProposalResult, ActionProposalScope, ActionProposalMutationResult, ListActionProposals, ActionProposalDecisionCommand, ClaimActionProposal, ExtendActionProposalLease, SettleActionProposal, ActionProposalOutcomeLease, AgentGovernanceQueries, AgentPricingStore, GovernanceRange, ModelSpendRow, ActorSpendRow, ThreadSpendRow, UsageTrendPoint, ToolCallActivityRow, ThreadActivityRow, RunMetrics, RunAgentBreakdownRow, RunErrorBreakdownRow, RunTrendPoint, RecentRunRow, PendingApprovalRow, ToolStatRow, GovernancePageQuery, ToolCallWhere, GovernancePage, ThreadWhere, RunWhere, ApprovalWhere, GovernanceRunDetail, GovernanceThreadDetailQuery, GovernanceThreadDetail, MemoryProvider, ListMemoriesInput, MemoryRecord, ForgetMemoryInput, StoreMemoryInput, ModelPriceInput, CurrentModelPrice, StreamFrameTable, StreamFrameRow, SqlTokenStreamSink, SqlTokenStreamSinkOptions, ConfirmTokenStore, ConfirmTokenClaim, ChannelStore } from '@dudousxd/nestjs-agent-core';
|
|
3
3
|
export { ThreadTurnPage, ThreadTurnQuery } from '@dudousxd/nestjs-agent-core';
|
|
4
4
|
import * as drizzle_orm_sqlite_core from 'drizzle-orm/sqlite-core';
|
|
5
5
|
import { BaseSQLiteDatabase } from 'drizzle-orm/sqlite-core';
|
|
@@ -1514,6 +1514,26 @@ declare const agentTokenUsage: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
|
|
|
1514
1514
|
identity: undefined;
|
|
1515
1515
|
generated: undefined;
|
|
1516
1516
|
}, {}, {}>;
|
|
1517
|
+
costSource: drizzle_orm_sqlite_core.SQLiteColumn<{
|
|
1518
|
+
name: "cost_source";
|
|
1519
|
+
tableName: "agent_token_usage";
|
|
1520
|
+
dataType: "string";
|
|
1521
|
+
columnType: "SQLiteText";
|
|
1522
|
+
data: CostSource;
|
|
1523
|
+
driverParam: string;
|
|
1524
|
+
notNull: false;
|
|
1525
|
+
hasDefault: false;
|
|
1526
|
+
isPrimaryKey: false;
|
|
1527
|
+
isAutoincrement: false;
|
|
1528
|
+
hasRuntimeDefault: false;
|
|
1529
|
+
enumValues: [string, ...string[]];
|
|
1530
|
+
baseColumn: never;
|
|
1531
|
+
identity: undefined;
|
|
1532
|
+
generated: undefined;
|
|
1533
|
+
}, {}, {
|
|
1534
|
+
length: number | undefined;
|
|
1535
|
+
$type: CostSource;
|
|
1536
|
+
}>;
|
|
1517
1537
|
createdAt: drizzle_orm_sqlite_core.SQLiteColumn<{
|
|
1518
1538
|
name: "created_at";
|
|
1519
1539
|
tableName: "agent_token_usage";
|
|
@@ -4787,6 +4807,26 @@ declare const agentSchema: {
|
|
|
4787
4807
|
identity: undefined;
|
|
4788
4808
|
generated: undefined;
|
|
4789
4809
|
}, {}, {}>;
|
|
4810
|
+
costSource: drizzle_orm_sqlite_core.SQLiteColumn<{
|
|
4811
|
+
name: "cost_source";
|
|
4812
|
+
tableName: "agent_token_usage";
|
|
4813
|
+
dataType: "string";
|
|
4814
|
+
columnType: "SQLiteText";
|
|
4815
|
+
data: CostSource;
|
|
4816
|
+
driverParam: string;
|
|
4817
|
+
notNull: false;
|
|
4818
|
+
hasDefault: false;
|
|
4819
|
+
isPrimaryKey: false;
|
|
4820
|
+
isAutoincrement: false;
|
|
4821
|
+
hasRuntimeDefault: false;
|
|
4822
|
+
enumValues: [string, ...string[]];
|
|
4823
|
+
baseColumn: never;
|
|
4824
|
+
identity: undefined;
|
|
4825
|
+
generated: undefined;
|
|
4826
|
+
}, {}, {
|
|
4827
|
+
length: number | undefined;
|
|
4828
|
+
$type: CostSource;
|
|
4829
|
+
}>;
|
|
4790
4830
|
createdAt: drizzle_orm_sqlite_core.SQLiteColumn<{
|
|
4791
4831
|
name: "created_at";
|
|
4792
4832
|
tableName: "agent_token_usage";
|
|
@@ -6152,14 +6192,8 @@ declare class DrizzleAgentStore implements AgentStore, ThreadTurnReader, ChatQue
|
|
|
6152
6192
|
*/
|
|
6153
6193
|
referencedMediaIds(actorRef: string, mediaIds: readonly string[]): Promise<string[]>;
|
|
6154
6194
|
recordUsage(input: RecordUsageInput): Promise<void>;
|
|
6155
|
-
quotaToday(actorRef: string, day: string): Promise<
|
|
6156
|
-
|
|
6157
|
-
costUsd: number;
|
|
6158
|
-
}>;
|
|
6159
|
-
usageBetween(actorRef: string, fromDay: string, toDay: string): Promise<{
|
|
6160
|
-
usedTokens: number;
|
|
6161
|
-
costUsd: number;
|
|
6162
|
-
}>;
|
|
6195
|
+
quotaToday(actorRef: string, day: string): Promise<UsageTotals>;
|
|
6196
|
+
usageBetween(actorRef: string, fromDay: string, toDay: string): Promise<UsageTotals>;
|
|
6163
6197
|
private toSummary;
|
|
6164
6198
|
private toStoredMessage;
|
|
6165
6199
|
}
|
|
@@ -8390,6 +8424,25 @@ declare const pgAgentSchema: {
|
|
|
8390
8424
|
identity: undefined;
|
|
8391
8425
|
generated: undefined;
|
|
8392
8426
|
}, {}, {}>;
|
|
8427
|
+
costSource: drizzle_orm_pg_core.PgColumn<{
|
|
8428
|
+
name: "cost_source";
|
|
8429
|
+
tableName: "agent_token_usage";
|
|
8430
|
+
dataType: "string";
|
|
8431
|
+
columnType: "PgText";
|
|
8432
|
+
data: CostSource;
|
|
8433
|
+
driverParam: string;
|
|
8434
|
+
notNull: false;
|
|
8435
|
+
hasDefault: false;
|
|
8436
|
+
isPrimaryKey: false;
|
|
8437
|
+
isAutoincrement: false;
|
|
8438
|
+
hasRuntimeDefault: false;
|
|
8439
|
+
enumValues: [string, ...string[]];
|
|
8440
|
+
baseColumn: never;
|
|
8441
|
+
identity: undefined;
|
|
8442
|
+
generated: undefined;
|
|
8443
|
+
}, {}, {
|
|
8444
|
+
$type: CostSource;
|
|
8445
|
+
}>;
|
|
8393
8446
|
createdAt: drizzle_orm_pg_core.PgColumn<{
|
|
8394
8447
|
name: string;
|
|
8395
8448
|
tableName: "agent_token_usage";
|
|
@@ -11132,6 +11185,25 @@ declare const mysqlAgentSchema: {
|
|
|
11132
11185
|
identity: undefined;
|
|
11133
11186
|
generated: undefined;
|
|
11134
11187
|
}, {}, {}>;
|
|
11188
|
+
costSource: drizzle_orm_mysql_core.MySqlColumn<{
|
|
11189
|
+
name: string;
|
|
11190
|
+
tableName: "agent_token_usage";
|
|
11191
|
+
dataType: "string";
|
|
11192
|
+
columnType: "MySqlVarChar";
|
|
11193
|
+
data: CostSource;
|
|
11194
|
+
driverParam: string | number;
|
|
11195
|
+
notNull: false;
|
|
11196
|
+
hasDefault: false;
|
|
11197
|
+
isPrimaryKey: false;
|
|
11198
|
+
isAutoincrement: false;
|
|
11199
|
+
hasRuntimeDefault: false;
|
|
11200
|
+
enumValues: [string, ...string[]];
|
|
11201
|
+
baseColumn: never;
|
|
11202
|
+
identity: undefined;
|
|
11203
|
+
generated: undefined;
|
|
11204
|
+
}, {}, {
|
|
11205
|
+
$type: CostSource;
|
|
11206
|
+
}>;
|
|
11135
11207
|
createdAt: drizzle_orm_mysql_core.MySqlColumn<{
|
|
11136
11208
|
name: string;
|
|
11137
11209
|
tableName: "agent_token_usage";
|
package/dist/index.js
CHANGED
|
@@ -183,8 +183,10 @@ var agentTokenUsage = sqliteTable("agent_token_usage", {
|
|
|
183
183
|
cacheWriteTokens: integer("cache_write_tokens"),
|
|
184
184
|
/** Subset of `inputTokens` served from the prompt cache this turn; null when not reported. */
|
|
185
185
|
cacheReadTokens: integer("cache_read_tokens"),
|
|
186
|
-
/**
|
|
186
|
+
/** The turn's USD cost: provider-reported, or estimated from the price row (see `costSource`); null when unpriced. */
|
|
187
187
|
costUsd: real("cost_usd"),
|
|
188
|
+
/** Where `cost_usd` came from: `'provider'` (reported) or `'estimate'` (tokens × the price row); null on rows from before it existed (reported). */
|
|
189
|
+
costSource: text("cost_source").$type(),
|
|
188
190
|
createdAt: integer("created_at", {
|
|
189
191
|
mode: "timestamp_ms"
|
|
190
192
|
}).notNull()
|
|
@@ -490,6 +492,8 @@ var agentTokenUsage2 = mysqlTable("agent_token_usage", {
|
|
|
490
492
|
cacheWriteTokens: int("cache_write_tokens"),
|
|
491
493
|
cacheReadTokens: int("cache_read_tokens"),
|
|
492
494
|
costUsd: double("cost_usd"),
|
|
495
|
+
/** Where `cost_usd` came from: `'provider'` (reported) or `'estimate'` (tokens × the price row); null on rows from before it existed (reported). */
|
|
496
|
+
costSource: key("cost_source").$type(),
|
|
493
497
|
createdAt: ts("created_at").notNull()
|
|
494
498
|
}, (table) => [
|
|
495
499
|
index2("agent_token_usage_actor_created_idx").on(table.actorRef, table.createdAt)
|
|
@@ -771,6 +775,8 @@ var agentTokenUsage3 = pgTable("agent_token_usage", {
|
|
|
771
775
|
cacheWriteTokens: integer2("cache_write_tokens"),
|
|
772
776
|
cacheReadTokens: integer2("cache_read_tokens"),
|
|
773
777
|
costUsd: doublePrecision("cost_usd"),
|
|
778
|
+
/** Where `cost_usd` came from: `'provider'` (reported) or `'estimate'` (tokens × the price row); null on rows from before it existed (reported). */
|
|
779
|
+
costSource: text2("cost_source").$type(),
|
|
774
780
|
createdAt: ts2("created_at").notNull()
|
|
775
781
|
}, (table) => [
|
|
776
782
|
index3("agent_token_usage_actor_created_idx").on(table.actorRef, table.createdAt)
|
|
@@ -1175,7 +1181,7 @@ async function heal(db, dialect) {
|
|
|
1175
1181
|
__name(heal, "heal");
|
|
1176
1182
|
|
|
1177
1183
|
// src/drizzle-agent-store.ts
|
|
1178
|
-
import { canonicalActionProposalJson as canonicalActionProposalJson4, toolCallApprovalFromRow } from "@dudousxd/nestjs-agent-core";
|
|
1184
|
+
import { canonicalActionProposalJson as canonicalActionProposalJson4, sumUsage, toolCallApprovalFromRow } from "@dudousxd/nestjs-agent-core";
|
|
1179
1185
|
import { and as and2, asc as asc2, desc, eq as eq2, gte, inArray, isNotNull, isNull as isNull2, lte as lte2, max as max2, min, or as or2, sql as sql3 } from "drizzle-orm";
|
|
1180
1186
|
|
|
1181
1187
|
// src/drizzle-action-proposal-store.ts
|
|
@@ -2528,6 +2534,7 @@ var DrizzleAgentStore = class {
|
|
|
2528
2534
|
cacheWriteTokens: input.usage.cacheWriteTokens ?? null,
|
|
2529
2535
|
cacheReadTokens: input.usage.cacheReadTokens ?? null,
|
|
2530
2536
|
costUsd: input.costUsd ?? null,
|
|
2537
|
+
costSource: input.costUsd !== void 0 ? input.costSource ?? "provider" : null,
|
|
2531
2538
|
createdAt: /* @__PURE__ */ new Date()
|
|
2532
2539
|
});
|
|
2533
2540
|
}
|
|
@@ -2538,12 +2545,7 @@ var DrizzleAgentStore = class {
|
|
|
2538
2545
|
const start = /* @__PURE__ */ new Date(`${fromDay}T00:00:00.000Z`);
|
|
2539
2546
|
const end = /* @__PURE__ */ new Date(`${toDay}T23:59:59.999Z`);
|
|
2540
2547
|
const rows = await this.db.select().from(this.t.agentTokenUsage).where(and2(eq2(this.t.agentTokenUsage.actorRef, actorRef), gte(this.t.agentTokenUsage.createdAt, start), lte2(this.t.agentTokenUsage.createdAt, end)));
|
|
2541
|
-
|
|
2542
|
-
const costUsd = rows.reduce((sum2, row) => sum2 + (row.costUsd ?? 0), 0);
|
|
2543
|
-
return {
|
|
2544
|
-
usedTokens,
|
|
2545
|
-
costUsd
|
|
2546
|
-
};
|
|
2548
|
+
return sumUsage(rows);
|
|
2547
2549
|
}
|
|
2548
2550
|
toSummary(thread, lastContent) {
|
|
2549
2551
|
return {
|