@talkpilot/core-db 1.3.35 → 1.3.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.
Files changed (80) hide show
  1. package/README.md +117 -1
  2. package/dist/configuration/index.d.ts +2 -0
  3. package/dist/configuration/index.d.ts.map +1 -1
  4. package/dist/configuration/index.js +2 -0
  5. package/dist/configuration/index.js.map +1 -1
  6. package/dist/configuration/internalModels/index.d.ts +4 -0
  7. package/dist/configuration/internalModels/index.d.ts.map +1 -0
  8. package/dist/configuration/internalModels/index.js +21 -0
  9. package/dist/configuration/internalModels/index.js.map +1 -0
  10. package/dist/configuration/internalModels/internalModels.constants.d.ts +2 -0
  11. package/dist/configuration/internalModels/internalModels.constants.d.ts.map +1 -0
  12. package/dist/configuration/internalModels/internalModels.constants.js +5 -0
  13. package/dist/configuration/internalModels/internalModels.constants.js.map +1 -0
  14. package/dist/configuration/internalModels/internalModels.getters.d.ts +16 -0
  15. package/dist/configuration/internalModels/internalModels.getters.d.ts.map +1 -0
  16. package/dist/configuration/internalModels/internalModels.getters.js +31 -0
  17. package/dist/configuration/internalModels/internalModels.getters.js.map +1 -0
  18. package/dist/configuration/internalModels/internalModels.types.d.ts +12 -0
  19. package/dist/configuration/internalModels/internalModels.types.d.ts.map +1 -0
  20. package/dist/configuration/internalModels/internalModels.types.js +3 -0
  21. package/dist/configuration/internalModels/internalModels.types.js.map +1 -0
  22. package/dist/configuration/models/index.d.ts +4 -0
  23. package/dist/configuration/models/index.d.ts.map +1 -0
  24. package/dist/configuration/models/index.js +16 -0
  25. package/dist/configuration/models/index.js.map +1 -0
  26. package/dist/configuration/models/models.constants.d.ts +5 -0
  27. package/dist/configuration/models/models.constants.d.ts.map +1 -0
  28. package/dist/configuration/models/models.constants.js +15 -0
  29. package/dist/configuration/models/models.constants.js.map +1 -0
  30. package/dist/configuration/models/models.getters.d.ts +21 -0
  31. package/dist/configuration/models/models.getters.d.ts.map +1 -0
  32. package/dist/configuration/models/models.getters.js +44 -0
  33. package/dist/configuration/models/models.getters.js.map +1 -0
  34. package/dist/configuration/models/models.types.d.ts +68 -0
  35. package/dist/configuration/models/models.types.d.ts.map +1 -0
  36. package/dist/configuration/models/models.types.js +3 -0
  37. package/dist/configuration/models/models.types.js.map +1 -0
  38. package/dist/index.d.ts +2 -0
  39. package/dist/index.d.ts.map +1 -1
  40. package/dist/index.js +2 -0
  41. package/dist/index.js.map +1 -1
  42. package/dist/talkpilot/clients/clients.quota.getters.d.ts +7 -0
  43. package/dist/talkpilot/clients/clients.quota.getters.d.ts.map +1 -0
  44. package/dist/talkpilot/clients/clients.quota.getters.js +80 -0
  45. package/dist/talkpilot/clients/clients.quota.getters.js.map +1 -0
  46. package/dist/talkpilot/clients/clients.quota.types.d.ts +24 -0
  47. package/dist/talkpilot/clients/clients.quota.types.d.ts.map +1 -0
  48. package/dist/talkpilot/clients/clients.quota.types.js +3 -0
  49. package/dist/talkpilot/clients/clients.quota.types.js.map +1 -0
  50. package/dist/talkpilot/clients/clients.types.d.ts +3 -0
  51. package/dist/talkpilot/clients/clients.types.d.ts.map +1 -1
  52. package/dist/talkpilot/clients/index.d.ts +2 -0
  53. package/dist/talkpilot/clients/index.d.ts.map +1 -1
  54. package/dist/talkpilot/clients/index.js +2 -0
  55. package/dist/talkpilot/clients/index.js.map +1 -1
  56. package/dist/talkpilot/clientsConfig/clientsConfig.getters.d.ts +5 -0
  57. package/dist/talkpilot/clientsConfig/clientsConfig.getters.d.ts.map +1 -1
  58. package/dist/talkpilot/clientsConfig/clientsConfig.getters.js +37 -1
  59. package/dist/talkpilot/clientsConfig/clientsConfig.getters.js.map +1 -1
  60. package/dist/talkpilot/clientsConfig/clientsConfig.types.d.ts +2 -0
  61. package/dist/talkpilot/clientsConfig/clientsConfig.types.d.ts.map +1 -1
  62. package/package.json +1 -1
  63. package/src/configuration/index.ts +2 -0
  64. package/src/configuration/internalModels/index.ts +3 -0
  65. package/src/configuration/internalModels/internalModels.constants.ts +1 -0
  66. package/src/configuration/internalModels/internalModels.getters.ts +33 -0
  67. package/src/configuration/internalModels/internalModels.types.ts +12 -0
  68. package/src/configuration/models/index.ts +25 -0
  69. package/src/configuration/models/models.constants.ts +13 -0
  70. package/src/configuration/models/models.getters.ts +53 -0
  71. package/src/configuration/models/models.types.ts +79 -0
  72. package/src/index.ts +2 -0
  73. package/src/talkpilot/clients/__tests__/clients.quota.spec.ts +123 -0
  74. package/src/talkpilot/clients/clients.quota.getters.ts +119 -0
  75. package/src/talkpilot/clients/clients.quota.types.ts +27 -0
  76. package/src/talkpilot/clients/clients.types.ts +4 -0
  77. package/src/talkpilot/clients/index.ts +2 -0
  78. package/src/talkpilot/clientsConfig/__tests__/clientsConfig.spec.ts +26 -0
  79. package/src/talkpilot/clientsConfig/clientsConfig.getters.ts +54 -0
  80. package/src/talkpilot/clientsConfig/clientsConfig.types.ts +3 -0
package/README.md CHANGED
@@ -17,6 +17,7 @@ L1:# @talkpilot/core-db
17
17
  - **Test helpers** – `src/test-utils/` plus `src/__tests__/` reuse `MongoMemoryServer` and shared factories so tests start with clean data regardless of the consuming repo.
18
18
  - **Utility layers** – `src/utils/` contains shared validation, pagination, and environment helpers that complement the getters.
19
19
  - **Bulk-write helpers** – `src/bulkWrite/` exposes small, domain-agnostic functions (`buildSetOp`, `buildUpsertOp`, `buildInsertOp`, `buildDeleteOp`) that construct correctly-shaped MongoDB bulk-write operations from a filter and field values — no collection- or domain-specific knowledge required.
20
+ - **Configuration domain** – `src/configuration/` hosts the `configuration` database (a `prompts` collection so far) — a place for cross-service settings that used to be hardcoded in consuming repos, editable without a deploy.
20
21
  - **Environment awareness** – Defaults, fallbacks, and `process.env` lookups ensure local, CI, and Cloud Run clients all connect using the right URI/DB names.
21
22
 
22
23
  ## Key Components
@@ -26,6 +27,8 @@ L1:# @talkpilot/core-db
26
27
  - `src/municipal/` – Municipal-specific collections (`cities`, `streets`, `departmentsSubjects`, `tickets`, etc.) plus vector search helpers and Ash Bina helpers used by MIS.
27
28
  - `src/utils/` – Shared helpers such as `resolveConnection`, pagination utilities, and schema validation helper functions.
28
29
  - `src/bulkWrite/` – Generic bulk-write op constructors (`buildSetOp`, `buildUpsertOp`, `buildInsertOp`, `buildDeleteOp`) usable with any collection's document type.
30
+ - `src/configuration/` – `configurationMongodbClient` plus the `prompts` collection (`Prompt` type, `getPromptByName`, `findPrompts`, `getAllPrompts`, `getPromptsByProduct`).
31
+ - `src/config.ts` – Centralized `process.env` reads for the configuration domain — add new env-backed fields here instead of reading `process.env` inline elsewhere.
29
32
  - `src/test-utils/` and `src/__tests__/` – Utilities that bootstrap `MongoMemoryServer`, expose factories, and make sure Jest environments can stub database calls predictably.
30
33
  - `dist/` – Compiled output consumed by downstream repos (CJS + ESM + type defs).
31
34
 
@@ -33,6 +36,7 @@ L1:# @talkpilot/core-db
33
36
 
34
37
  - **TalkPilot domain** – Imports like `findAgents`, `getFlows`, `findCalls`, and `vectorSearchCalls` live in `src/talkpilot`. These functions are the canonical access pattern for call history, session metadata, and provider configs.
35
38
  - **Municipal domain** – Helpers such as `findStreets`, `getMunicipalCities`, `findDepartmentSubjects`, and `createTicket` live under `src/municipal` and feed MIS workflows (street hints, subject matching, Ash Bina tickets).
39
+ - **Configuration domain** – `getPromptByName`, `findPrompts`, `getAllPrompts`, and `getPromptsByProduct` live under `src/configuration` and back MIS's `moked_106` prompt lookups (defaults, overridable per-client via `clientConfig.toolsPrompts`).
36
40
 
37
41
  ## Environment variables
38
42
 
@@ -42,6 +46,7 @@ L1:# @talkpilot/core-db
42
46
  | `MONGODB_URI` | Alternate connection string used when Mongo needs a second URI parameter. | ✅ |
43
47
  | `TALKPILOT_DB_NAME` | Optional override for the TalkPilot database name (defaults from URI path). | ❌ |
44
48
  | `MUNICIPAL_DB_NAME` | Optional override for the municipal database name (defaults to `municipal-data`). | ❌ |
49
+ | `CONFIGURATION_DB_NAME` | Optional override for the configuration database name (defaults to `configuration`). | ❌ |
45
50
  | `ENV` | Free-form label used in logs/validators (defaults to `unknown`). | ❌ |
46
51
 
47
52
  If you pass a `uri` directly to `mongodbClient.connect()` or `municipalDataMongodbClient.connect()`, the client will prefer that value over the env vars.
@@ -78,10 +83,11 @@ If you pass a `uri` directly to `mongodbClient.connect()` or `municipalDataMongo
78
83
  MONGO_URI=mongodb://localhost:27017
79
84
  TALKPILOT_DB_NAME=talkpilot-dev
80
85
  MUNICIPAL_DB_NAME=municipal-dev
86
+ CONFIGURATION_DB_NAME=configuration-dev
81
87
  ENV=development
82
88
  ```
83
89
 
84
- Adjust `MONGO_URI` to match the running Mongo instance and configure `talkpilot`/`municipal` DB names if you want to keep them separate.
90
+ Adjust `MONGO_URI` to match the running Mongo instance and configure `talkpilot`/`municipal`/`configuration` DB names if you want to keep them separate.
85
91
 
86
92
  ## Local development
87
93
 
@@ -160,6 +166,12 @@ Refer to `DEVELOPMENT.md` for the full walkthrough, token instructions, and fact
160
166
  | 1.3.24 | **Breaking:** removed `flowId` from `WebsiteTalkProduct` — flow source of truth is `phone_numbers.flow_id`. Added `getPrimaryPhoneFlowId(clientId)`. |
161
167
  | 1.3.25 | Added `disconnectDb()` to close all MongoDB clients opened by `ensureDbConnected()` — for one-shot scripts that must exit cleanly. |
162
168
  | 1.3.28 | Soft-delete (`isActive`) on Streets/DepartmentSubjects, new bulk-write getters, MongoDB type re-exports, and the generic `bulkWrite` op-builder module. |
169
+ | 1.3.29 | Added client call-quota module (CP-1500): `ClientConfig.quota` for usage limits (`totalQuota`, `usedQuota`, `expiresAt`), alert settings on `clients`, and getters for state, increment/reset, threshold alerts, and expiry notification tracking. |
170
+ | 1.3.32 | `clientDisplayName` lives on `clientsConfig.quota` (not top-level). `getClientDisplayName` returns `"-"` when unset; never exposes `clientId`. |
171
+ | 1.3.33 | Added `configuration` database module (CP-1560): `configurationMongodbClient` + a read-only `Prompts`-style collection for prompts previously hardcoded in consuming repos (e.g. MIS). |
172
+ | 1.3.35 | Fixed the configuration collection name (`Prompts` → `prompts`, matches the lowercase convention used elsewhere). **Breaking** if you inserted documents into a collection literally named `Prompts`. Added `Prompt.productName` (required) + `getPromptsByProduct`. Centralized configuration-DB env var reads into `src/config.ts`. |
173
+ | 1.3.36 | Publish combining the 1.3.33/1.3.35 configuration-DB work with the latest `main` (client quota + `clientDisplayName` + bulk-write/streets/departmentSubjects updates — see 1.3.28/1.3.29/1.3.32). No new code of its own. |
174
+
163
175
  ### 1.1.9
164
176
 
165
177
  1. `npm run build`.
@@ -544,6 +556,110 @@ Adds an `isActive` soft-delete convention, bulk-write getters for Streets/Depart
544
556
 
545
557
  No — purely additive.
546
558
 
559
+ ### 1.3.29 — Client call quota (CP-1500)
560
+
561
+ Per-client call quota with usage counters, optional expiration, and configurable threshold/expiry email alerts. Usage lives on clientsConfig; alert config and send-tracking live on clients. TalkPilot Server consumes these getters to block calls when quota is exceeded or expired and to send notification emails.
562
+
563
+ **Data model**
564
+
565
+ | Location | Field | Purpose |
566
+ | --- | --- | --- |
567
+ | `clientsConfig.quota` | `totalQuota`, `usedQuota`, `expiresAt?` | Call allowance and consumption. `getClientQuotaState` returns `null` when `totalQuota` is unset (quota disabled for that client). |
568
+ | `clients.quota` | `alerts?`, `expiredSent?` | Up to 3 threshold alerts (each with up to 3 recipient emails) and a flag set after the expiry email is sent. |
569
+
570
+ **Added**
571
+
572
+ | Export | Purpose |
573
+ | --- | --- |
574
+ | `ClientQuotaUsage` | Usage shape: `totalQuota`, `usedQuota`, optional `expiresAt`. |
575
+ | `ClientQuotaSettings` | Alert settings on the `clients` doc: `alerts`, `expiredSent`. |
576
+ | `ClientQuotaState` | Merged view returned by `getClientQuotaState` (usage + settings). |
577
+ | `QuotaThresholdAlert` / `QuotaAlertInput` | Threshold alert with `thresholdPct`, `recipientEmails`, and optional `thresholdSent` send-tracking. |
578
+ | `getClientQuotaState(clientId)` | Read combined quota state; `null` when no quota is configured. |
579
+ | `incrementClientQuotaUsage(clientId, amount?)` | Atomically increment `clientsConfig.quota.usedQuota` (default `amount = 1`). No-op when `quota.totalQuota` is absent. |
580
+ | `resetClientQuotaUsage(clientId)` | Reset `usedQuota` to `0` and clear alert/expiry send flags via `resetClientQuotaSettings`. |
581
+ | `updateQuotaAlertsConfig(clientId, alerts)` | Replace threshold alert config; preserves `thresholdSent` for unchanged thresholds. |
582
+ | `markQuotaAlertSent(clientId, alertIndex)` | Idempotently mark a threshold alert as sent; returns whether the update applied. |
583
+ | `markQuotaExpiredSent(clientId)` | Idempotently mark the expiry notification as sent; returns whether the update applied. |
584
+ | `resetClientQuotaSettings(clientId)` | Clear `expiredSent` and strip `thresholdSent` from alerts (keeps alert definitions). |
585
+
586
+ **Do I need to update my app?**
587
+
588
+ No — purely additive. TalkPilot Server should upgrade to 1.3.29 (or later) to enforce quota on inbound/outbound calls and to drive threshold/expiry emails via the new getters.
589
+
590
+ ### 1.3.32 — Quota `clientDisplayName`
591
+
592
+ Optional human-readable account label stored on `clientsConfig.quota` for quota notification emails. TalkPilot Server uses `getClientDisplayName` instead of exposing raw `clientId` in alert/expiry email copy.
593
+
594
+ **Changed**
595
+
596
+ | Area | What |
597
+ | --- | --- |
598
+ | `ClientQuotaUsage.clientDisplayName?` | Optional display name on `clientsConfig.quota` — e.g. `"Acme Corp"`. Included in `ClientQuotaState` via `getClientQuotaState`. |
599
+
600
+ **Added**
601
+
602
+ | Export | Purpose |
603
+ | --- | --- |
604
+ | `getClientDisplayName(clientId)` | Returns trimmed `quota.clientDisplayName`, or `"-"` when unset, missing, or blank. Never falls back to `clientId`. |
605
+
606
+ **Do I need to update my app?**
607
+
608
+ No — purely additive. Set `clientsConfig.quota.clientDisplayName` when provisioning quota for a client. **TalkPilot Server** should upgrade to **1.3.32** (or later) to use the label in quota emails.
609
+
610
+ ### 1.3.33 — Configuration database & Prompts collection (CP-1560)
611
+
612
+ New `configuration` database with a prompts collection, so prompts previously hardcoded in consuming repos (e.g. MIS's `moked_106` street/subject search and transcription prompts) can be stored centrally and edited without a deploy. Ships the **read** path only — documents are seeded/managed manually (e.g. via Compass), not through this package.
613
+
614
+ **Added**
615
+
616
+ | Export | Purpose |
617
+ | --- | --- |
618
+ | `configurationMongodbClient` | MongoDB client for the `configuration` database (default name `configuration`, override with `CONFIGURATION_DB_NAME`). |
619
+ | `getConfigurationDb` / `setConfigurationDb` / `ConfigurationObjectId` | DB handle accessors and `ObjectId`, matching the other domains. |
620
+ | `Prompt` | Document type: `{ _id, name, content, createdAt, updatedAt }`, keyed by unique `name`. |
621
+ | `getPromptByName(name)` | Fetch a single prompt by its unique `name`. Returns `null` if absent. |
622
+ | `findPrompts(filter?)` | Flexible query over the collection. |
623
+ | `getAllPrompts()` | Fetch every prompt. |
624
+ | `getPromptsCollection()` | Raw collection access. |
625
+
626
+ `ensureDbConnected()` / `disconnectDb()` now also connect/disconnect the configuration client alongside talkpilot/municipal/websitalk.
627
+
628
+ **Do I need to update my app?**
629
+
630
+ No — purely additive. Consumers opt in by importing the getters above.
631
+
632
+ ### 1.3.35 — Prompts fixes: collection name, `productName`, centralized config
633
+
634
+ **Breaking**
635
+
636
+ | Changed | What |
637
+ | --- | --- |
638
+ | Collection name | `"Prompts"` → `"prompts"` (lowercase, matching every other collection in core-db). MongoDB collection names are case-sensitive — if you inserted documents into a collection literally named `Prompts` under 1.3.33, move them to `prompts`. |
639
+
640
+ **Added**
641
+
642
+ | Export | Purpose |
643
+ | --- | --- |
644
+ | `Prompt.productName` | Required `KnownProductKey` (`"municipal" \| "clinics" \| "websiteTalk"`). Existing documents need this field backfilled. |
645
+ | `getPromptsByProduct(productName)` | Fetch all prompts for a given product. |
646
+
647
+ **Internal**
648
+
649
+ - Configuration-DB env var reads (`MONGO_URI`, `MONGODB_URI`, `CONFIGURATION_DB_NAME`) centralized into `src/config.ts` (`configurationDbConfig`) — no consumer-facing change.
650
+
651
+ **Do I need to update my app?**
652
+
653
+ Only if you inserted documents into the old `Prompts` (capital P) collection — move them to `prompts`. Also backfill `productName` on any existing prompt documents (e.g. `"municipal"`), since it's now a required field on the type.
654
+
655
+ ### 1.3.36 — Merge with `main`
656
+
657
+ Publishes the 1.3.33/1.3.35 configuration-DB work alongside the latest `main` — client call-quota, `clientDisplayName`, and bulk-write/streets/departmentSubjects updates (see 1.3.28, 1.3.29, 1.3.32). No new code of its own; this version exists to ship both branches' work together.
658
+
659
+ **Do I need to update my app?**
660
+
661
+ No — purely additive, same as the versions it combines.
662
+
547
663
  ## 🛠 CI/CD & deployment
548
664
 
549
665
  - This package is consumed by Cloud Build-based services (TalkPilot Server, MIS, CIS) as a dependency when Docker images are built. Keep `dist/` in sync with your builds because the compiled artifact is what downstream services install.
@@ -1,5 +1,7 @@
1
1
  import { Db, ObjectId as MongoObjectId } from "mongodb";
2
2
  export * from "./prompts";
3
+ export * from "./models";
4
+ export * from "./internalModels";
3
5
  export { configurationMongodbClient } from "./mongodb-client";
4
6
  export declare const setDb: (d: Db) => void;
5
7
  export declare const getDb: () => Db;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/configuration/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,QAAQ,IAAI,aAAa,EAAE,MAAM,SAAS,CAAC;AAExD,cAAc,WAAW,CAAC;AAC1B,OAAO,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAC;AAG9D,eAAO,MAAM,KAAK,GAAI,GAAG,EAAE,SAE1B,CAAC;AAEF,eAAO,MAAM,KAAK,QAAO,EAGxB,CAAC;AACF,eAAO,MAAM,QAAQ,sBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/configuration/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,QAAQ,IAAI,aAAa,EAAE,MAAM,SAAS,CAAC;AAExD,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,kBAAkB,CAAC;AACjC,OAAO,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAC;AAG9D,eAAO,MAAM,KAAK,GAAI,GAAG,EAAE,SAE1B,CAAC;AAEF,eAAO,MAAM,KAAK,QAAO,EAGxB,CAAC;AACF,eAAO,MAAM,QAAQ,sBAAgB,CAAC"}
@@ -17,6 +17,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  exports.ObjectId = exports.getDb = exports.setDb = exports.configurationMongodbClient = void 0;
18
18
  const mongodb_1 = require("mongodb");
19
19
  __exportStar(require("./prompts"), exports);
20
+ __exportStar(require("./models"), exports);
21
+ __exportStar(require("./internalModels"), exports);
20
22
  var mongodb_client_1 = require("./mongodb-client");
21
23
  Object.defineProperty(exports, "configurationMongodbClient", { enumerable: true, get: function () { return mongodb_client_1.configurationMongodbClient; } });
22
24
  let db;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/configuration/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,qCAAwD;AAExD,4CAA0B;AAC1B,mDAA8D;AAArD,4HAAA,0BAA0B,OAAA;AAEnC,IAAI,EAAM,CAAC;AACJ,MAAM,KAAK,GAAG,CAAC,CAAK,EAAE,EAAE;IAC7B,EAAE,GAAG,CAAC,CAAC;AACT,CAAC,CAAC;AAFW,QAAA,KAAK,SAEhB;AAEK,MAAM,KAAK,GAAG,GAAO,EAAE;IAC5B,IAAI,CAAC,EAAE;QAAE,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;IAC7D,OAAO,EAAE,CAAC;AACZ,CAAC,CAAC;AAHW,QAAA,KAAK,SAGhB;AACW,QAAA,QAAQ,GAAG,kBAAa,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/configuration/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,qCAAwD;AAExD,4CAA0B;AAC1B,2CAAyB;AACzB,mDAAiC;AACjC,mDAA8D;AAArD,4HAAA,0BAA0B,OAAA;AAEnC,IAAI,EAAM,CAAC;AACJ,MAAM,KAAK,GAAG,CAAC,CAAK,EAAE,EAAE;IAC7B,EAAE,GAAG,CAAC,CAAC;AACT,CAAC,CAAC;AAFW,QAAA,KAAK,SAEhB;AAEK,MAAM,KAAK,GAAG,GAAO,EAAE;IAC5B,IAAI,CAAC,EAAE;QAAE,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;IAC7D,OAAO,EAAE,CAAC;AACZ,CAAC,CAAC;AAHW,QAAA,KAAK,SAGhB;AACW,QAAA,QAAQ,GAAG,kBAAa,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { INTERNAL_MODELS_COLLECTION } from "./internalModels.constants";
2
+ export * from "./internalModels.getters";
3
+ export type { InternalModel } from "./internalModels.types";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/configuration/internalModels/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,4BAA4B,CAAC;AACxE,cAAc,0BAA0B,CAAC;AACzC,YAAY,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC"}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.INTERNAL_MODELS_COLLECTION = void 0;
18
+ var internalModels_constants_1 = require("./internalModels.constants");
19
+ Object.defineProperty(exports, "INTERNAL_MODELS_COLLECTION", { enumerable: true, get: function () { return internalModels_constants_1.INTERNAL_MODELS_COLLECTION; } });
20
+ __exportStar(require("./internalModels.getters"), exports);
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/configuration/internalModels/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,uEAAwE;AAA/D,sIAAA,0BAA0B,OAAA;AACnC,2DAAyC"}
@@ -0,0 +1,2 @@
1
+ export declare const INTERNAL_MODELS_COLLECTION = "internal-models";
2
+ //# sourceMappingURL=internalModels.constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"internalModels.constants.d.ts","sourceRoot":"","sources":["../../../src/configuration/internalModels/internalModels.constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,0BAA0B,oBAAoB,CAAC"}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.INTERNAL_MODELS_COLLECTION = void 0;
4
+ exports.INTERNAL_MODELS_COLLECTION = "internal-models";
5
+ //# sourceMappingURL=internalModels.constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"internalModels.constants.js","sourceRoot":"","sources":["../../../src/configuration/internalModels/internalModels.constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,0BAA0B,GAAG,iBAAiB,CAAC"}
@@ -0,0 +1,16 @@
1
+ import { Collection, Filter } from "mongodb";
2
+ import { InternalModel } from "./internalModels.types";
3
+ export declare const getInternalModelsCollection: () => Collection<InternalModel>;
4
+ /**
5
+ * Get an internal model config by its unique name
6
+ */
7
+ export declare const getInternalModelByName: (name: string) => Promise<InternalModel | null>;
8
+ /**
9
+ * Find internal models by filter.
10
+ */
11
+ export declare const findInternalModels: (filter?: Filter<InternalModel>) => Promise<InternalModel[]>;
12
+ /**
13
+ * Get all internal models.
14
+ */
15
+ export declare const getAllInternalModels: () => Promise<InternalModel[]>;
16
+ //# sourceMappingURL=internalModels.getters.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"internalModels.getters.d.ts","sourceRoot":"","sources":["../../../src/configuration/internalModels/internalModels.getters.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAGvD,eAAO,MAAM,2BAA2B,QAAO,UAAU,CAAC,aAAa,CAEtE,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,sBAAsB,GACjC,MAAM,MAAM,KACX,OAAO,CAAC,aAAa,GAAG,IAAI,CAE9B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,kBAAkB,GAC7B,SAAQ,MAAM,CAAC,aAAa,CAAM,KACjC,OAAO,CAAC,aAAa,EAAE,CAEzB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,oBAAoB,QAAa,OAAO,CAAC,aAAa,EAAE,CAEpE,CAAC"}
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getAllInternalModels = exports.findInternalModels = exports.getInternalModelByName = exports.getInternalModelsCollection = void 0;
4
+ const index_1 = require("../index");
5
+ const internalModels_constants_1 = require("./internalModels.constants");
6
+ const getInternalModelsCollection = () => {
7
+ return (0, index_1.getDb)().collection(internalModels_constants_1.INTERNAL_MODELS_COLLECTION);
8
+ };
9
+ exports.getInternalModelsCollection = getInternalModelsCollection;
10
+ /**
11
+ * Get an internal model config by its unique name
12
+ */
13
+ const getInternalModelByName = async (name) => {
14
+ return await (0, exports.getInternalModelsCollection)().findOne({ name });
15
+ };
16
+ exports.getInternalModelByName = getInternalModelByName;
17
+ /**
18
+ * Find internal models by filter.
19
+ */
20
+ const findInternalModels = async (filter = {}) => {
21
+ return await (0, exports.getInternalModelsCollection)().find(filter).toArray();
22
+ };
23
+ exports.findInternalModels = findInternalModels;
24
+ /**
25
+ * Get all internal models.
26
+ */
27
+ const getAllInternalModels = async () => {
28
+ return await (0, exports.findInternalModels)();
29
+ };
30
+ exports.getAllInternalModels = getAllInternalModels;
31
+ //# sourceMappingURL=internalModels.getters.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"internalModels.getters.js","sourceRoot":"","sources":["../../../src/configuration/internalModels/internalModels.getters.ts"],"names":[],"mappings":";;;AAAA,oCAAiC;AAGjC,yEAAwE;AAEjE,MAAM,2BAA2B,GAAG,GAA8B,EAAE;IACzE,OAAO,IAAA,aAAK,GAAE,CAAC,UAAU,CAAgB,qDAA0B,CAAC,CAAC;AACvE,CAAC,CAAC;AAFW,QAAA,2BAA2B,+BAEtC;AAEF;;GAEG;AACI,MAAM,sBAAsB,GAAG,KAAK,EACzC,IAAY,EACmB,EAAE;IACjC,OAAO,MAAM,IAAA,mCAA2B,GAAE,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;AAC/D,CAAC,CAAC;AAJW,QAAA,sBAAsB,0BAIjC;AAEF;;GAEG;AACI,MAAM,kBAAkB,GAAG,KAAK,EACrC,SAAgC,EAAE,EACR,EAAE;IAC5B,OAAO,MAAM,IAAA,mCAA2B,GAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,CAAC;AACpE,CAAC,CAAC;AAJW,QAAA,kBAAkB,sBAI7B;AAEF;;GAEG;AACI,MAAM,oBAAoB,GAAG,KAAK,IAA8B,EAAE;IACvE,OAAO,MAAM,IAAA,0BAAkB,GAAE,CAAC;AACpC,CAAC,CAAC;AAFW,QAAA,oBAAoB,wBAE/B"}
@@ -0,0 +1,12 @@
1
+ import { ObjectId } from "mongodb";
2
+ export type InternalModel = {
3
+ _id: ObjectId;
4
+ /** Has to be unique between other names in collection */
5
+ name: string;
6
+ provider: string;
7
+ model: string;
8
+ config?: Record<string, unknown>;
9
+ createdAt: Date;
10
+ updatedAt: Date;
11
+ };
12
+ //# sourceMappingURL=internalModels.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"internalModels.types.d.ts","sourceRoot":"","sources":["../../../src/configuration/internalModels/internalModels.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEnC,MAAM,MAAM,aAAa,GAAG;IAC1B,GAAG,EAAE,QAAQ,CAAC;IACd,yDAAyD;IACzD,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;CACjB,CAAC"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=internalModels.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"internalModels.types.js","sourceRoot":"","sources":["../../../src/configuration/internalModels/internalModels.types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,4 @@
1
+ export { MODELS_COLLECTION, MODEL_TYPES, REALTIME_MODEL_PROVIDERS, STT_MODEL_PROVIDERS, } from "./models.constants";
2
+ export { getModelsCollection, findModels, getModelByModelId, getModelsByProvider, getModelsByType, getAvailableModelsByType, } from "./models.getters";
3
+ export type { ModelType, RealtimeModelProvider, SttModelProvider, SemanticVad, ServerVad, TurnDetection, RealtimeModelDoc, SttModelDoc, ModelDoc, } from "./models.types";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/configuration/models/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,WAAW,EACX,wBAAwB,EACxB,mBAAmB,GACpB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,mBAAmB,EACnB,UAAU,EACV,iBAAiB,EACjB,mBAAmB,EACnB,eAAe,EACf,wBAAwB,GACzB,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EACV,SAAS,EACT,qBAAqB,EACrB,gBAAgB,EAChB,WAAW,EACX,SAAS,EACT,aAAa,EACb,gBAAgB,EAChB,WAAW,EACX,QAAQ,GACT,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getAvailableModelsByType = exports.getModelsByType = exports.getModelsByProvider = exports.getModelByModelId = exports.findModels = exports.getModelsCollection = exports.STT_MODEL_PROVIDERS = exports.REALTIME_MODEL_PROVIDERS = exports.MODEL_TYPES = exports.MODELS_COLLECTION = void 0;
4
+ var models_constants_1 = require("./models.constants");
5
+ Object.defineProperty(exports, "MODELS_COLLECTION", { enumerable: true, get: function () { return models_constants_1.MODELS_COLLECTION; } });
6
+ Object.defineProperty(exports, "MODEL_TYPES", { enumerable: true, get: function () { return models_constants_1.MODEL_TYPES; } });
7
+ Object.defineProperty(exports, "REALTIME_MODEL_PROVIDERS", { enumerable: true, get: function () { return models_constants_1.REALTIME_MODEL_PROVIDERS; } });
8
+ Object.defineProperty(exports, "STT_MODEL_PROVIDERS", { enumerable: true, get: function () { return models_constants_1.STT_MODEL_PROVIDERS; } });
9
+ var models_getters_1 = require("./models.getters");
10
+ Object.defineProperty(exports, "getModelsCollection", { enumerable: true, get: function () { return models_getters_1.getModelsCollection; } });
11
+ Object.defineProperty(exports, "findModels", { enumerable: true, get: function () { return models_getters_1.findModels; } });
12
+ Object.defineProperty(exports, "getModelByModelId", { enumerable: true, get: function () { return models_getters_1.getModelByModelId; } });
13
+ Object.defineProperty(exports, "getModelsByProvider", { enumerable: true, get: function () { return models_getters_1.getModelsByProvider; } });
14
+ Object.defineProperty(exports, "getModelsByType", { enumerable: true, get: function () { return models_getters_1.getModelsByType; } });
15
+ Object.defineProperty(exports, "getAvailableModelsByType", { enumerable: true, get: function () { return models_getters_1.getAvailableModelsByType; } });
16
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/configuration/models/index.ts"],"names":[],"mappings":";;;AAAA,uDAK4B;AAJ1B,qHAAA,iBAAiB,OAAA;AACjB,+GAAA,WAAW,OAAA;AACX,4HAAA,wBAAwB,OAAA;AACxB,uHAAA,mBAAmB,OAAA;AAErB,mDAO0B;AANxB,qHAAA,mBAAmB,OAAA;AACnB,4GAAA,UAAU,OAAA;AACV,mHAAA,iBAAiB,OAAA;AACjB,qHAAA,mBAAmB,OAAA;AACnB,iHAAA,eAAe,OAAA;AACf,0HAAA,wBAAwB,OAAA"}
@@ -0,0 +1,5 @@
1
+ export declare const MODELS_COLLECTION = "models";
2
+ export declare const MODEL_TYPES: readonly ["realtime", "stt"];
3
+ export declare const REALTIME_MODEL_PROVIDERS: readonly ["openai", "gemini"];
4
+ export declare const STT_MODEL_PROVIDERS: readonly ["openai-stt", "google-stt", "deepgram-stt", "deepgram-flux", "elevenlabs-scribe", "gladia-stt"];
5
+ //# sourceMappingURL=models.constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"models.constants.d.ts","sourceRoot":"","sources":["../../../src/configuration/models/models.constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,iBAAiB,WAAW,CAAC;AAE1C,eAAO,MAAM,WAAW,8BAA+B,CAAC;AAExD,eAAO,MAAM,wBAAwB,+BAAgC,CAAC;AACtE,eAAO,MAAM,mBAAmB,2GAOtB,CAAC"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.STT_MODEL_PROVIDERS = exports.REALTIME_MODEL_PROVIDERS = exports.MODEL_TYPES = exports.MODELS_COLLECTION = void 0;
4
+ exports.MODELS_COLLECTION = "models";
5
+ exports.MODEL_TYPES = ["realtime", "stt"];
6
+ exports.REALTIME_MODEL_PROVIDERS = ["openai", "gemini"];
7
+ exports.STT_MODEL_PROVIDERS = [
8
+ "openai-stt",
9
+ "google-stt",
10
+ "deepgram-stt",
11
+ "deepgram-flux",
12
+ "elevenlabs-scribe",
13
+ "gladia-stt",
14
+ ];
15
+ //# sourceMappingURL=models.constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"models.constants.js","sourceRoot":"","sources":["../../../src/configuration/models/models.constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,iBAAiB,GAAG,QAAQ,CAAC;AAE7B,QAAA,WAAW,GAAG,CAAC,UAAU,EAAE,KAAK,CAAU,CAAC;AAE3C,QAAA,wBAAwB,GAAG,CAAC,QAAQ,EAAE,QAAQ,CAAU,CAAC;AACzD,QAAA,mBAAmB,GAAG;IACjC,YAAY;IACZ,YAAY;IACZ,cAAc;IACd,eAAe;IACf,mBAAmB;IACnB,YAAY;CACJ,CAAC"}
@@ -0,0 +1,21 @@
1
+ import { Collection, Filter } from "mongodb";
2
+ import { ModelDoc, ModelType } from "./models.types";
3
+ /** Raw typed handle to the `models` collection. */
4
+ export declare const getModelsCollection: () => Collection<ModelDoc>;
5
+ /** Find models by an arbitrary filter. */
6
+ export declare const findModels: (filter?: Filter<ModelDoc>) => Promise<ModelDoc[]>;
7
+ /**
8
+ * Get a single model by its `modelId`, optionally scoped to a `type`.
9
+ * @param modelId e.g. "deepgram-stt-phonecall"
10
+ * @param type optional narrowing filter, since `modelId` isn't guaranteed unique across types
11
+ */
12
+ export declare const getModelByModelId: (modelId: string, type?: ModelType) => Promise<ModelDoc | null>;
13
+ /**
14
+ * Get all models for a given `provider`, optionally scoped to a `type`.
15
+ */
16
+ export declare const getModelsByProvider: (provider: string, type?: ModelType) => Promise<ModelDoc[]>;
17
+ /** Get all models of a given `type`. */
18
+ export declare const getModelsByType: (type: ModelType) => Promise<ModelDoc[]>;
19
+ /** Get all models of a given `type` where `available` is true. */
20
+ export declare const getAvailableModelsByType: (type: ModelType) => Promise<ModelDoc[]>;
21
+ //# sourceMappingURL=models.getters.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"models.getters.d.ts","sourceRoot":"","sources":["../../../src/configuration/models/models.getters.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAI7C,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAErD,mDAAmD;AACnD,eAAO,MAAM,mBAAmB,QAAO,UAAU,CAAC,QAAQ,CAEzD,CAAC;AAEF,0CAA0C;AAC1C,eAAO,MAAM,UAAU,GACrB,SAAQ,MAAM,CAAC,QAAQ,CAAM,KAC5B,OAAO,CAAC,QAAQ,EAAE,CAEpB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAC5B,SAAS,MAAM,EACf,OAAO,SAAS,KACf,OAAO,CAAC,QAAQ,GAAG,IAAI,CAGzB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,mBAAmB,GAC9B,UAAU,MAAM,EAChB,OAAO,SAAS,KACf,OAAO,CAAC,QAAQ,EAAE,CAGpB,CAAC;AAEF,wCAAwC;AACxC,eAAO,MAAM,eAAe,GAAU,MAAM,SAAS,KAAG,OAAO,CAAC,QAAQ,EAAE,CAEzE,CAAC;AAEF,kEAAkE;AAClE,eAAO,MAAM,wBAAwB,GACnC,MAAM,SAAS,KACd,OAAO,CAAC,QAAQ,EAAE,CAEpB,CAAC"}
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getAvailableModelsByType = exports.getModelsByType = exports.getModelsByProvider = exports.getModelByModelId = exports.findModels = exports.getModelsCollection = void 0;
4
+ const index_1 = require("../index");
5
+ const models_constants_1 = require("./models.constants");
6
+ /** Raw typed handle to the `models` collection. */
7
+ const getModelsCollection = () => {
8
+ return (0, index_1.getDb)().collection(models_constants_1.MODELS_COLLECTION);
9
+ };
10
+ exports.getModelsCollection = getModelsCollection;
11
+ /** Find models by an arbitrary filter. */
12
+ const findModels = async (filter = {}) => {
13
+ return await (0, exports.getModelsCollection)().find(filter).toArray();
14
+ };
15
+ exports.findModels = findModels;
16
+ /**
17
+ * Get a single model by its `modelId`, optionally scoped to a `type`.
18
+ * @param modelId e.g. "deepgram-stt-phonecall"
19
+ * @param type optional narrowing filter, since `modelId` isn't guaranteed unique across types
20
+ */
21
+ const getModelByModelId = async (modelId, type) => {
22
+ const filter = (type ? { modelId, type } : { modelId });
23
+ return await (0, exports.getModelsCollection)().findOne(filter);
24
+ };
25
+ exports.getModelByModelId = getModelByModelId;
26
+ /**
27
+ * Get all models for a given `provider`, optionally scoped to a `type`.
28
+ */
29
+ const getModelsByProvider = async (provider, type) => {
30
+ const filter = (type ? { provider, type } : { provider });
31
+ return await (0, exports.findModels)(filter);
32
+ };
33
+ exports.getModelsByProvider = getModelsByProvider;
34
+ /** Get all models of a given `type`. */
35
+ const getModelsByType = async (type) => {
36
+ return await (0, exports.findModels)({ type });
37
+ };
38
+ exports.getModelsByType = getModelsByType;
39
+ /** Get all models of a given `type` where `available` is true. */
40
+ const getAvailableModelsByType = async (type) => {
41
+ return await (0, exports.findModels)({ type, available: true });
42
+ };
43
+ exports.getAvailableModelsByType = getAvailableModelsByType;
44
+ //# sourceMappingURL=models.getters.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"models.getters.js","sourceRoot":"","sources":["../../../src/configuration/models/models.getters.ts"],"names":[],"mappings":";;;AAEA,oCAAiC;AACjC,yDAAuD;AAGvD,mDAAmD;AAC5C,MAAM,mBAAmB,GAAG,GAAyB,EAAE;IAC5D,OAAO,IAAA,aAAK,GAAE,CAAC,UAAU,CAAW,oCAAiB,CAAC,CAAC;AACzD,CAAC,CAAC;AAFW,QAAA,mBAAmB,uBAE9B;AAEF,0CAA0C;AACnC,MAAM,UAAU,GAAG,KAAK,EAC7B,SAA2B,EAAE,EACR,EAAE;IACvB,OAAO,MAAM,IAAA,2BAAmB,GAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,CAAC;AAC5D,CAAC,CAAC;AAJW,QAAA,UAAU,cAIrB;AAEF;;;;GAIG;AACI,MAAM,iBAAiB,GAAG,KAAK,EACpC,OAAe,EACf,IAAgB,EACU,EAAE;IAC5B,MAAM,MAAM,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAqB,CAAC;IAC5E,OAAO,MAAM,IAAA,2BAAmB,GAAE,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;AACrD,CAAC,CAAC;AANW,QAAA,iBAAiB,qBAM5B;AAEF;;GAEG;AACI,MAAM,mBAAmB,GAAG,KAAK,EACtC,QAAgB,EAChB,IAAgB,EACK,EAAE;IACvB,MAAM,MAAM,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAqB,CAAC;IAC9E,OAAO,MAAM,IAAA,kBAAU,EAAC,MAAM,CAAC,CAAC;AAClC,CAAC,CAAC;AANW,QAAA,mBAAmB,uBAM9B;AAEF,wCAAwC;AACjC,MAAM,eAAe,GAAG,KAAK,EAAE,IAAe,EAAuB,EAAE;IAC5E,OAAO,MAAM,IAAA,kBAAU,EAAC,EAAE,IAAI,EAAsB,CAAC,CAAC;AACxD,CAAC,CAAC;AAFW,QAAA,eAAe,mBAE1B;AAEF,kEAAkE;AAC3D,MAAM,wBAAwB,GAAG,KAAK,EAC3C,IAAe,EACM,EAAE;IACvB,OAAO,MAAM,IAAA,kBAAU,EAAC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAsB,CAAC,CAAC;AACzE,CAAC,CAAC;AAJW,QAAA,wBAAwB,4BAInC"}
@@ -0,0 +1,68 @@
1
+ import { ObjectId } from "mongodb";
2
+ import { MODEL_TYPES, REALTIME_MODEL_PROVIDERS, STT_MODEL_PROVIDERS } from "./models.constants";
3
+ export type ModelType = (typeof MODEL_TYPES)[number];
4
+ export type RealtimeModelProvider = (typeof REALTIME_MODEL_PROVIDERS)[number];
5
+ export type SttModelProvider = (typeof STT_MODEL_PROVIDERS)[number];
6
+ export type SemanticVad = {
7
+ type: "semantic_vad";
8
+ eagerness?: "low" | "medium" | "high" | "auto";
9
+ create_response?: boolean;
10
+ interrupt_response?: boolean;
11
+ };
12
+ export type ServerVad = {
13
+ type: "server_vad";
14
+ threshold: number;
15
+ prefix_padding_ms: number;
16
+ silence_duration_ms: number;
17
+ create_response?: boolean;
18
+ interrupt_response?: boolean;
19
+ };
20
+ export type TurnDetection = SemanticVad | ServerVad;
21
+ type BaseModelDoc = {
22
+ _id: ObjectId;
23
+ /** Public identifier used by the provider, not to be confused with mongo id */
24
+ modelId: string;
25
+ name: string;
26
+ description?: string;
27
+ available: boolean;
28
+ configDefaults?: Record<string, unknown>;
29
+ createdAt: Date;
30
+ updatedAt: Date;
31
+ };
32
+ /** Realtime speech-to-speech model (OpenAI/Gemini). `features.vad` is turn-detection config. */
33
+ export type RealtimeModelDoc = BaseModelDoc & {
34
+ type: "realtime";
35
+ provider: RealtimeModelProvider;
36
+ features?: {
37
+ supportsAudio?: boolean;
38
+ supportsText?: boolean;
39
+ vad?: TurnDetection;
40
+ };
41
+ };
42
+ /** STT engine/preset (openai-stt, google-stt, deepgram-stt/-flux, elevenlabs-scribe, gladia-stt). */
43
+ export type SttModelDoc = BaseModelDoc & {
44
+ type: "stt";
45
+ provider: SttModelProvider;
46
+ features?: {
47
+ supportsAudio?: boolean;
48
+ supportsText?: boolean;
49
+ };
50
+ };
51
+ /**
52
+ * A document in the `models` collection (configuration db). Discriminated by `type`.
53
+ *
54
+ * Common fields (all variants):
55
+ * - `_id` — Mongo-managed ObjectId
56
+ * - `modelId` — model's public identifier
57
+ * - `name` — display name
58
+ * - `description?` — display description
59
+ * - `available` — whether the model should be offered/selectable right now
60
+ * - `configDefaults?` — free-form provider-specific config, e.g. the literal vendor
61
+ * model string, VAD tuning, language, barge-in timings — shape varies per `provider`
62
+ * - `createdAt` / `updatedAt`
63
+ *
64
+ * Type-specific fields: see {@link RealtimeModelDoc}, {@link SttModelDoc}.
65
+ */
66
+ export type ModelDoc = RealtimeModelDoc | SttModelDoc;
67
+ export {};
68
+ //# sourceMappingURL=models.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"models.types.d.ts","sourceRoot":"","sources":["../../../src/configuration/models/models.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEnC,OAAO,EACL,WAAW,EACX,wBAAwB,EACxB,mBAAmB,EACpB,MAAM,oBAAoB,CAAC;AAE5B,MAAM,MAAM,SAAS,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC;AACrD,MAAM,MAAM,qBAAqB,GAAG,CAAC,OAAO,wBAAwB,CAAC,CAAC,MAAM,CAAC,CAAC;AAC9E,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,mBAAmB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEpE,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,cAAc,CAAC;IACrB,SAAS,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,MAAM,CAAC;IAC/C,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACtB,IAAI,EAAE,YAAY,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,mBAAmB,EAAE,MAAM,CAAC;IAC5B,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,WAAW,GAAG,SAAS,CAAC;AAEpD,KAAK,YAAY,GAAG;IAClB,GAAG,EAAE,QAAQ,CAAC;IACd,+EAA+E;IAC/E,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,OAAO,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACzC,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;CACjB,CAAC;AAEF,gGAAgG;AAChG,MAAM,MAAM,gBAAgB,GAAG,YAAY,GAAG;IAC5C,IAAI,EAAE,UAAU,CAAC;IACjB,QAAQ,EAAE,qBAAqB,CAAC;IAChC,QAAQ,CAAC,EAAE;QACT,aAAa,CAAC,EAAE,OAAO,CAAC;QACxB,YAAY,CAAC,EAAE,OAAO,CAAC;QACvB,GAAG,CAAC,EAAE,aAAa,CAAC;KACrB,CAAC;CACH,CAAC;AAEF,qGAAqG;AACrG,MAAM,MAAM,WAAW,GAAG,YAAY,GAAG;IACvC,IAAI,EAAE,KAAK,CAAC;IACZ,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,QAAQ,CAAC,EAAE;QACT,aAAa,CAAC,EAAE,OAAO,CAAC;QACxB,YAAY,CAAC,EAAE,OAAO,CAAC;KACxB,CAAC;CACH,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,QAAQ,GAAG,gBAAgB,GAAG,WAAW,CAAC"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=models.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"models.types.js","sourceRoot":"","sources":["../../../src/configuration/models/models.types.ts"],"names":[],"mappings":""}
package/dist/index.d.ts CHANGED
@@ -15,6 +15,8 @@ export type * from "./websitalk/scans/scans.types";
15
15
  export * from "./websitalk/websiteUrls";
16
16
  export { configurationMongodbClient, getDb as getConfigurationDb, setDb as setConfigurationDb, } from "./configuration";
17
17
  export * from "./configuration/prompts";
18
+ export * from "./configuration/models";
19
+ export * from "./configuration/internalModels";
18
20
  export { ObjectId } from "mongodb";
19
21
  export type { Filter } from "mongodb";
20
22
  export type { AnyBulkWriteOperation as BulkWriteOp } from "mongodb";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAE5B,OAAO,EACL,0BAA0B,EAC1B,KAAK,IAAI,kBAAkB,EAC3B,KAAK,IAAI,kBAAkB,EAC3B,QAAQ,IAAI,qBAAqB,GAClC,MAAM,aAAa,CAAC;AACrB,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iCAAiC,CAAC;AAChD,cAAc,qBAAqB,CAAC;AACpC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AAExC,OAAO,EACL,sBAAsB,EACtB,KAAK,IAAI,cAAc,EACvB,KAAK,IAAI,cAAc,EACvB,QAAQ,IAAI,iBAAiB,GAC9B,MAAM,aAAa,CAAC;AACrB,cAAc,iCAAiC,CAAC;AAChD,mBAAmB,+BAA+B,CAAC;AACnD,cAAc,yBAAyB,CAAC;AAExC,OAAO,EACL,0BAA0B,EAC1B,KAAK,IAAI,kBAAkB,EAC3B,KAAK,IAAI,kBAAkB,GAC5B,MAAM,iBAAiB,CAAC;AACzB,cAAc,yBAAyB,CAAC;AAExC,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,YAAY,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACtC,YAAY,EAAE,qBAAqB,IAAI,WAAW,EAAE,MAAM,SAAS,CAAC;AACpE,OAAO,EAAE,mBAAmB,IAAI,cAAc,EAAE,MAAM,SAAS,CAAC;AAChE,YAAY,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAE5B,OAAO,EACL,0BAA0B,EAC1B,KAAK,IAAI,kBAAkB,EAC3B,KAAK,IAAI,kBAAkB,EAC3B,QAAQ,IAAI,qBAAqB,GAClC,MAAM,aAAa,CAAC;AACrB,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iCAAiC,CAAC;AAChD,cAAc,qBAAqB,CAAC;AACpC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AAExC,OAAO,EACL,sBAAsB,EACtB,KAAK,IAAI,cAAc,EACvB,KAAK,IAAI,cAAc,EACvB,QAAQ,IAAI,iBAAiB,GAC9B,MAAM,aAAa,CAAC;AACrB,cAAc,iCAAiC,CAAC;AAChD,mBAAmB,+BAA+B,CAAC;AACnD,cAAc,yBAAyB,CAAC;AAExC,OAAO,EACL,0BAA0B,EAC1B,KAAK,IAAI,kBAAkB,EAC3B,KAAK,IAAI,kBAAkB,GAC5B,MAAM,iBAAiB,CAAC;AACzB,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,gCAAgC,CAAC;AAE/C,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,YAAY,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACtC,YAAY,EAAE,qBAAqB,IAAI,WAAW,EAAE,MAAM,SAAS,CAAC;AACpE,OAAO,EAAE,mBAAmB,IAAI,cAAc,EAAE,MAAM,SAAS,CAAC;AAChE,YAAY,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC"}
package/dist/index.js CHANGED
@@ -43,6 +43,8 @@ Object.defineProperty(exports, "configurationMongodbClient", { enumerable: true,
43
43
  Object.defineProperty(exports, "getConfigurationDb", { enumerable: true, get: function () { return configuration_1.getDb; } });
44
44
  Object.defineProperty(exports, "setConfigurationDb", { enumerable: true, get: function () { return configuration_1.setDb; } });
45
45
  __exportStar(require("./configuration/prompts"), exports);
46
+ __exportStar(require("./configuration/models"), exports);
47
+ __exportStar(require("./configuration/internalModels"), exports);
46
48
  var mongodb_1 = require("mongodb");
47
49
  Object.defineProperty(exports, "ObjectId", { enumerable: true, get: function () { return mongodb_1.ObjectId; } });
48
50
  var mongodb_2 = require("mongodb");
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,uBAAuB;AACvB,8CAA4B;AAC5B,+CAA6B;AAC7B,8CAA4B;AAE5B,yCAKqB;AAJnB,uHAAA,0BAA0B,OAAA;AAC1B,+GAAA,KAAK,OAAsB;AAC3B,+GAAA,KAAK,OAAsB;AAC3B,kHAAA,QAAQ,OAAyB;AAEnC,qDAAmC;AACnC,sDAAoC;AACpC,kEAAgD;AAChD,sDAAoC;AACpC,iEAA+C;AAC/C,yDAAuC;AACvC,0DAAwC;AAExC,yCAKqB;AAJnB,mHAAA,sBAAsB,OAAA;AACtB,2GAAA,KAAK,OAAkB;AACvB,2GAAA,KAAK,OAAkB;AACvB,8GAAA,QAAQ,OAAqB;AAE/B,kEAAgD;AAEhD,0DAAwC;AAExC,iDAIyB;AAHvB,2HAAA,0BAA0B,OAAA;AAC1B,mHAAA,KAAK,OAAsB;AAC3B,mHAAA,KAAK,OAAsB;AAE7B,0DAAwC;AAExC,mCAAmC;AAA1B,mGAAA,QAAQ,OAAA;AAGjB,mCAAgE;AAAvD,yGAAA,mBAAmB,OAAkB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,uBAAuB;AACvB,8CAA4B;AAC5B,+CAA6B;AAC7B,8CAA4B;AAE5B,yCAKqB;AAJnB,uHAAA,0BAA0B,OAAA;AAC1B,+GAAA,KAAK,OAAsB;AAC3B,+GAAA,KAAK,OAAsB;AAC3B,kHAAA,QAAQ,OAAyB;AAEnC,qDAAmC;AACnC,sDAAoC;AACpC,kEAAgD;AAChD,sDAAoC;AACpC,iEAA+C;AAC/C,yDAAuC;AACvC,0DAAwC;AAExC,yCAKqB;AAJnB,mHAAA,sBAAsB,OAAA;AACtB,2GAAA,KAAK,OAAkB;AACvB,2GAAA,KAAK,OAAkB;AACvB,8GAAA,QAAQ,OAAqB;AAE/B,kEAAgD;AAEhD,0DAAwC;AAExC,iDAIyB;AAHvB,2HAAA,0BAA0B,OAAA;AAC1B,mHAAA,KAAK,OAAsB;AAC3B,mHAAA,KAAK,OAAsB;AAE7B,0DAAwC;AACxC,yDAAuC;AACvC,iEAA+C;AAE/C,mCAAmC;AAA1B,mGAAA,QAAQ,OAAA;AAGjB,mCAAgE;AAAvD,yGAAA,mBAAmB,OAAkB"}
@@ -0,0 +1,7 @@
1
+ import type { ClientQuotaState, QuotaAlertInput } from "./clients.quota.types";
2
+ export declare function getClientQuotaState(clientId: string): Promise<ClientQuotaState | null>;
3
+ export declare function updateQuotaAlertsConfig(clientId: string, alerts: QuotaAlertInput[]): Promise<void>;
4
+ export declare function markQuotaAlertSent(clientId: string, alertIndex: number): Promise<boolean>;
5
+ export declare function markQuotaExpiredSent(clientId: string): Promise<boolean>;
6
+ export declare function resetClientQuotaSettings(clientId: string): Promise<void>;
7
+ //# sourceMappingURL=clients.quota.getters.d.ts.map