bopodev-db 0.1.30 → 0.1.32

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,5 +1,5 @@
1
1
 
2
2
  
3
- > bopodev-db@0.1.30 build /Users/danielkrusenstrahle/Documents/Projects/Monorepo/bopohq/packages/db
3
+ > bopodev-db@0.1.32 build /Users/danielkrusenstrahle/Documents/Projects/Monorepo/bopohq/packages/db
4
4
  > tsc -p tsconfig.json --emitDeclarationOnly
5
5
 
@@ -1,4 +1,4 @@
1
1
 
2
- > bopodev-db@0.1.29 typecheck /Users/danielkrusenstrahle/Documents/Projects/Monorepo/bopohq/packages/db
2
+ > bopodev-db@0.1.30 typecheck /Users/danielkrusenstrahle/Documents/Projects/Monorepo/bopohq/packages/db
3
3
  > tsc -p tsconfig.json --noEmit
4
4
 
@@ -0,0 +1,56 @@
1
+ import type { BopoDb } from "../client";
2
+ export type AssistantMessageRole = "user" | "assistant" | "system";
3
+ export declare function getOrCreateAssistantThread(db: BopoDb, companyId: string): Promise<{
4
+ id: string;
5
+ companyId: string;
6
+ createdAt: Date;
7
+ updatedAt: Date;
8
+ }>;
9
+ /** New empty thread; previous threads and messages remain in the database. */
10
+ export declare function createAssistantThread(db: BopoDb, companyId: string): Promise<{
11
+ id: string;
12
+ companyId: string;
13
+ createdAt: Date;
14
+ updatedAt: Date;
15
+ }>;
16
+ export declare function getAssistantThreadById(db: BopoDb, companyId: string, threadId: string): Promise<{
17
+ id: string;
18
+ companyId: string;
19
+ createdAt: Date;
20
+ updatedAt: Date;
21
+ } | null>;
22
+ export declare function touchAssistantThread(db: BopoDb, threadId: string): Promise<void>;
23
+ export declare function insertAssistantMessage(db: BopoDb, input: {
24
+ threadId: string;
25
+ companyId: string;
26
+ role: AssistantMessageRole;
27
+ body: string;
28
+ metadataJson?: string | null;
29
+ }): Promise<{
30
+ id: string;
31
+ threadId: string;
32
+ companyId: string;
33
+ role: string;
34
+ body: string;
35
+ metadataJson: string | null;
36
+ createdAt: Date;
37
+ }>;
38
+ export declare function listAssistantMessages(db: BopoDb, threadId: string, limit?: number): Promise<{
39
+ id: string;
40
+ threadId: string;
41
+ companyId: string;
42
+ role: string;
43
+ body: string;
44
+ metadataJson: string | null;
45
+ createdAt: Date;
46
+ }[]>;
47
+ /** Threads with at least one message in `[startInclusive, endExclusive)` on `created_at`. */
48
+ export declare function listAssistantChatThreadStatsInCreatedAtRange(db: BopoDb, companyId: string, startInclusive: Date, endExclusive: Date): Promise<Array<{
49
+ threadId: string;
50
+ messageCount: number;
51
+ }>>;
52
+ /** Threads with at least one message in the UTC calendar month (for callers without local bounds). */
53
+ export declare function listAssistantChatThreadStatsInUtcMonth(db: BopoDb, companyId: string, year: number, month1Based: number): Promise<Array<{
54
+ threadId: string;
55
+ messageCount: number;
56
+ }>>;
@@ -1,3 +1,4 @@
1
1
  export * from "./helpers";
2
2
  export * from "./companies";
3
+ export * from "./company-assistant-chat";
3
4
  export * from "./legacy";
@@ -263,6 +263,8 @@ export declare function listIssues(db: BopoDb, companyId: string, projectId?: st
263
263
  externalLink: string | null;
264
264
  isClaimed: boolean;
265
265
  claimedByHeartbeatRunId: string | null;
266
+ loopId: string | null;
267
+ loopRunId: string | null;
266
268
  createdAt: Date;
267
269
  updatedAt: Date;
268
270
  }[]>;
@@ -288,6 +290,8 @@ export declare function getIssue(db: BopoDb, companyId: string, issueId: string)
288
290
  externalLink: string | null;
289
291
  isClaimed: boolean;
290
292
  claimedByHeartbeatRunId: string | null;
293
+ loopId: string | null;
294
+ loopRunId: string | null;
291
295
  createdAt: Date;
292
296
  updatedAt: Date;
293
297
  } | null>;
@@ -304,6 +308,8 @@ export declare function createIssue(db: BopoDb, input: {
304
308
  assigneeAgentId?: string | null;
305
309
  labels?: string[];
306
310
  tags?: string[];
311
+ loopId?: string | null;
312
+ loopRunId?: string | null;
307
313
  }): Promise<{
308
314
  id: string;
309
315
  createdAt: Date;
@@ -321,6 +327,8 @@ export declare function createIssue(db: BopoDb, input: {
321
327
  externalLink: string | null;
322
328
  isClaimed: boolean;
323
329
  claimedByHeartbeatRunId: string | null;
330
+ loopId: string | null;
331
+ loopRunId: string | null;
324
332
  }>;
325
333
  export declare function updateIssue(db: BopoDb, input: {
326
334
  companyId: string;
@@ -350,6 +358,8 @@ export declare function updateIssue(db: BopoDb, input: {
350
358
  externalLink: string | null;
351
359
  isClaimed: boolean;
352
360
  claimedByHeartbeatRunId: string | null;
361
+ loopId: string | null;
362
+ loopRunId: string | null;
353
363
  createdAt: Date;
354
364
  updatedAt: Date;
355
365
  } | null>;
@@ -870,6 +880,10 @@ export declare function appendCost(db: BopoDb, input: {
870
880
  projectId?: string | null;
871
881
  issueId?: string | null;
872
882
  agentId?: string | null;
883
+ /** Discriminator for reporting (e.g. `company_assistant`); null for heartbeat / legacy */
884
+ costCategory?: string | null;
885
+ assistantThreadId?: string | null;
886
+ assistantMessageId?: string | null;
873
887
  }): Promise<string>;
874
888
  export declare function listCostEntries(db: BopoDb, companyId: string, limit?: number): Promise<{
875
889
  id: string;
@@ -878,6 +892,9 @@ export declare function listCostEntries(db: BopoDb, companyId: string, limit?: n
878
892
  projectId: string | null;
879
893
  issueId: string | null;
880
894
  agentId: string | null;
895
+ costCategory: string | null;
896
+ assistantThreadId: string | null;
897
+ assistantMessageId: string | null;
881
898
  providerType: string;
882
899
  runtimeModelId: string | null;
883
900
  pricingProviderType: string | null;
@@ -889,6 +906,16 @@ export declare function listCostEntries(db: BopoDb, companyId: string, limit?: n
889
906
  usdCostStatus: string | null;
890
907
  createdAt: Date;
891
908
  }[]>;
909
+ export type CostLedgerAggregate = {
910
+ rowCount: number;
911
+ tokenInput: number;
912
+ tokenOutput: number;
913
+ /** Sum of `usd_cost` as a decimal string (full precision from DB). */
914
+ usdTotal: string;
915
+ };
916
+ /** Sum every ledger row for the company in `[startInclusive, endExclusive)` (typically UTC month). */
917
+ export declare function aggregateCompanyCostLedgerInRange(db: BopoDb, companyId: string, startInclusive: Date, endExclusive: Date): Promise<CostLedgerAggregate>;
918
+ export declare function aggregateCompanyCostLedgerAllTime(db: BopoDb, companyId: string): Promise<CostLedgerAggregate>;
892
919
  export declare function listHeartbeatRuns(db: BopoDb, companyId: string, limit?: number): Promise<{
893
920
  id: string;
894
921
  companyId: string;