@certalis/agent-smith 0.1.17 → 0.1.19

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.
@@ -1679,7 +1679,7 @@ function sanitizeProviderPools(value) {
1679
1679
  return pools;
1680
1680
  }
1681
1681
  function wireForStrategy(strategy3) {
1682
- return strategy3 === "anthropic-api" || strategy3 === "claude-code" ? "anthropic-messages" : "openai-responses";
1682
+ return strategy3 === "anthropic-api" || strategy3 === "model-studio-anthropic-api" || strategy3 === "claude-code" ? "anthropic-messages" : "openai-responses";
1683
1683
  }
1684
1684
  function isNonNegativeFiniteNumber(value) {
1685
1685
  return isFiniteNumber(value) && value >= 0;
@@ -1712,6 +1712,18 @@ function sanitizeTeamRouting(value) {
1712
1712
  result.weekly_max_usage_by_email = Object.fromEntries(normalized);
1713
1713
  }
1714
1714
  }
1715
+ if (isRecord(value.caller_weekly_max_usage)) {
1716
+ const entries = Object.entries(value.caller_weekly_max_usage);
1717
+ if (entries.length <= MAX_CALLERS && entries.every(([caller, cap]) => CALLER_ID_PATTERN.test(caller) && isFiniteNumber(cap) && cap > 0 && cap <= 0.95)) {
1718
+ result.caller_weekly_max_usage = Object.fromEntries(entries);
1719
+ }
1720
+ }
1721
+ if (isRecord(value.caller_provider_fallback)) {
1722
+ const entries = Object.entries(value.caller_provider_fallback);
1723
+ if (entries.length <= MAX_CALLERS && entries.every(([caller, fallback]) => CALLER_ID_PATTERN.test(caller) && fallback === "ordered")) {
1724
+ result.caller_provider_fallback = Object.fromEntries(entries);
1725
+ }
1726
+ }
1715
1727
  if (isNonNegativeFiniteNumber(value.admission_cap)) {
1716
1728
  result.admission_cap = Math.floor(value.admission_cap);
1717
1729
  }
@@ -1753,7 +1765,7 @@ function clientRouting(client) {
1753
1765
  ...client?.pool_ssh_host && { poolSshHost: client.pool_ssh_host }
1754
1766
  };
1755
1767
  }
1756
- var log2, PROVIDER_STRATEGIES, BUILTIN_PROVIDER_CONFIGS, BUILTIN_PROVIDER_CONFIG_BY_NAME, PROVIDER_NAME_PATTERN, POOL_SSH_HOST_PATTERN, TEAM_ROUTING_DEFAULTS, MAX_ENROLLMENT_EMAILS = 200, MAX_ALERT_VALUE_LENGTH = 512, Config;
1768
+ var log2, PROVIDER_STRATEGIES, BUILTIN_PROVIDER_CONFIGS, BUILTIN_PROVIDER_CONFIG_BY_NAME, PROVIDER_NAME_PATTERN, POOL_SSH_HOST_PATTERN, CALLER_ID_PATTERN, MAX_CALLERS = 128, TEAM_ROUTING_DEFAULTS, MAX_ENROLLMENT_EMAILS = 200, MAX_ALERT_VALUE_LENGTH = 512, Config;
1757
1769
  var init_src4 = __esm(() => {
1758
1770
  init_src2();
1759
1771
  init_src3();
@@ -1766,6 +1778,7 @@ var init_src4 = __esm(() => {
1766
1778
  log2 = new Logger("Config");
1767
1779
  PROVIDER_STRATEGIES = [
1768
1780
  "anthropic-api",
1781
+ "model-studio-anthropic-api",
1769
1782
  "openai-api",
1770
1783
  "claude-code",
1771
1784
  "codex"
@@ -1779,6 +1792,7 @@ var init_src4 = __esm(() => {
1779
1792
  BUILTIN_PROVIDER_CONFIG_BY_NAME = new Map(BUILTIN_PROVIDER_CONFIGS.map((provider) => [provider.name, provider]));
1780
1793
  PROVIDER_NAME_PATTERN = /^[a-z][a-z0-9-]{0,63}$/;
1781
1794
  POOL_SSH_HOST_PATTERN = /^\w[\w.-]{0,127}(@\w[\w.-]{0,127})?$/;
1795
+ CALLER_ID_PATTERN = /^[-a-zA-Z0-9_]{1,64}$/;
1782
1796
  TEAM_ROUTING_DEFAULTS = {
1783
1797
  enabled: false,
1784
1798
  distributionEnabled: true,
@@ -1787,6 +1801,8 @@ var init_src4 = __esm(() => {
1787
1801
  maxUsage: 0.9,
1788
1802
  weeklyMaxUsage: 0.95,
1789
1803
  weeklyMaxUsageByEmail: {},
1804
+ callerWeeklyMaxUsage: {},
1805
+ callerProviderFallback: {},
1790
1806
  admissionCap: 5,
1791
1807
  admissionQueueLimit: 25,
1792
1808
  admissionWaitMs: 30000,
@@ -1949,6 +1965,8 @@ var init_src4 = __esm(() => {
1949
1965
  maxUsage: file?.max_usage ?? TEAM_ROUTING_DEFAULTS.maxUsage,
1950
1966
  weeklyMaxUsage: file?.weekly_max_usage ?? TEAM_ROUTING_DEFAULTS.weeklyMaxUsage,
1951
1967
  weeklyMaxUsageByEmail: { ...file?.weekly_max_usage_by_email },
1968
+ callerWeeklyMaxUsage: { ...file?.caller_weekly_max_usage },
1969
+ callerProviderFallback: { ...file?.caller_provider_fallback },
1952
1970
  admissionCap: file?.admission_cap ?? TEAM_ROUTING_DEFAULTS.admissionCap,
1953
1971
  admissionQueueLimit: file?.admission_queue_limit ?? TEAM_ROUTING_DEFAULTS.admissionQueueLimit,
1954
1972
  admissionWaitMs: file?.admission_wait_ms ?? TEAM_ROUTING_DEFAULTS.admissionWaitMs,
@@ -2018,6 +2036,8 @@ var init_src4 = __esm(() => {
2018
2036
  "max_usage",
2019
2037
  "weekly_max_usage",
2020
2038
  "weekly_max_usage_by_email",
2039
+ "caller_weekly_max_usage",
2040
+ "caller_provider_fallback",
2021
2041
  "admission_cap",
2022
2042
  "admission_queue_limit",
2023
2043
  "admission_wait_ms",
@@ -2043,6 +2063,16 @@ var init_src4 = __esm(() => {
2043
2063
  ...oldValue.weekly_max_usage_by_email
2044
2064
  };
2045
2065
  }
2066
+ if (!("caller_weekly_max_usage" in value) && oldValue?.caller_weekly_max_usage) {
2067
+ sanitized.caller_weekly_max_usage = {
2068
+ ...oldValue.caller_weekly_max_usage
2069
+ };
2070
+ }
2071
+ if (!("caller_provider_fallback" in value) && oldValue?.caller_provider_fallback) {
2072
+ sanitized.caller_provider_fallback = {
2073
+ ...oldValue.caller_provider_fallback
2074
+ };
2075
+ }
2046
2076
  this.persistStrictly("team_routing", sanitized);
2047
2077
  }
2048
2078
  allowAccountUuid(accountUuid) {
@@ -2868,6 +2898,30 @@ function ensureConversationPinsTable(db) {
2868
2898
  db.run(`CREATE INDEX IF NOT EXISTS idx_conversation_pins_account ON conversation_pins(account_id)`);
2869
2899
  db.run(`CREATE INDEX IF NOT EXISTS idx_conversation_pins_last_seen ON conversation_pins(last_seen_at)`);
2870
2900
  }
2901
+ function ensureConversationProviderPreferencesTable(db) {
2902
+ db.run(`
2903
+ CREATE TABLE IF NOT EXISTS conversation_provider_preferences (
2904
+ pin_key TEXT PRIMARY KEY,
2905
+ provider TEXT NOT NULL,
2906
+ promotion_declined INTEGER NOT NULL DEFAULT 0,
2907
+ last_seen_at INTEGER NOT NULL
2908
+ )
2909
+ `);
2910
+ db.run(`CREATE INDEX IF NOT EXISTS idx_conversation_provider_preferences_last_seen ON conversation_provider_preferences(last_seen_at)`);
2911
+ }
2912
+ function ensureConversationProviderBlocksTable(db) {
2913
+ db.run(`
2914
+ CREATE TABLE IF NOT EXISTS conversation_provider_blocks (
2915
+ pin_key TEXT NOT NULL,
2916
+ provider TEXT NOT NULL,
2917
+ category TEXT NOT NULL DEFAULT 'unknown',
2918
+ retry_at INTEGER,
2919
+ last_seen_at INTEGER NOT NULL,
2920
+ PRIMARY KEY (pin_key, provider)
2921
+ )
2922
+ `);
2923
+ db.run(`CREATE INDEX IF NOT EXISTS idx_conversation_provider_blocks_last_seen ON conversation_provider_blocks(last_seen_at)`);
2924
+ }
2871
2925
  function remediateDuplicateAccountNames(db) {
2872
2926
  const accounts = db.query(`
2873
2927
  SELECT id, name, created_at
@@ -2993,6 +3047,8 @@ function ensureSchema(db) {
2993
3047
  `);
2994
3048
  ensureAuthSessionsTable(db);
2995
3049
  ensureConversationPinsTable(db);
3050
+ ensureConversationProviderPreferencesTable(db);
3051
+ ensureConversationProviderBlocksTable(db);
2996
3052
  }
2997
3053
  function runMigrations(db) {
2998
3054
  ensureSchema(db);
@@ -3012,6 +3068,8 @@ function runMigrations(db) {
3012
3068
  db.run("DROP INDEX IF EXISTS idx_oauth_sessions_expires");
3013
3069
  ensureAuthSessionsTable(db);
3014
3070
  ensureConversationPinsTable(db);
3071
+ ensureConversationProviderPreferencesTable(db);
3072
+ ensureConversationProviderBlocksTable(db);
3015
3073
  ensureAccountsNameUniqueness(db);
3016
3074
  db.run(`CREATE TABLE IF NOT EXISTS enrollment_contacts (
3017
3075
  account_id TEXT PRIMARY KEY REFERENCES accounts(id) ON DELETE CASCADE,
@@ -3707,6 +3765,85 @@ var init_conversation_pin_repository = __esm(() => {
3707
3765
  };
3708
3766
  });
3709
3767
 
3768
+ // ../../packages/database/src/repositories/conversation-provider-block.repository.ts
3769
+ var ConversationProviderBlockRepository;
3770
+ var init_conversation_provider_block_repository = __esm(() => {
3771
+ ConversationProviderBlockRepository = class ConversationProviderBlockRepository extends BaseRepository {
3772
+ find(pinKey, provider) {
3773
+ const row = this.get(`SELECT category, retry_at, last_seen_at FROM conversation_provider_blocks WHERE pin_key = ? AND provider = ?`, [pinKey, provider]);
3774
+ return row ? {
3775
+ category: row.category,
3776
+ lastSeenAt: row.last_seen_at,
3777
+ retryAt: row.retry_at ?? undefined
3778
+ } : null;
3779
+ }
3780
+ upsert(pinKey, provider, category, retryAt, lastSeenAt) {
3781
+ this.run(`
3782
+ INSERT INTO conversation_provider_blocks (
3783
+ pin_key, provider, category, retry_at, last_seen_at
3784
+ )
3785
+ VALUES (?, ?, ?, ?, ?)
3786
+ ON CONFLICT(pin_key, provider) DO UPDATE SET
3787
+ category = excluded.category,
3788
+ retry_at = excluded.retry_at,
3789
+ last_seen_at = excluded.last_seen_at
3790
+ `, [pinKey, provider, category, retryAt ?? null, lastSeenAt]);
3791
+ }
3792
+ delete(pinKey, provider) {
3793
+ this.run(`DELETE FROM conversation_provider_blocks WHERE pin_key = ? AND provider = ?`, [pinKey, provider]);
3794
+ }
3795
+ deleteExpired(before) {
3796
+ this.run(`DELETE FROM conversation_provider_blocks WHERE last_seen_at < ?`, [before]);
3797
+ }
3798
+ deleteForAccount(accountId) {
3799
+ this.run(`
3800
+ DELETE FROM conversation_provider_blocks
3801
+ WHERE pin_key IN (
3802
+ SELECT pin_key FROM conversation_pins WHERE account_id = ?
3803
+ )
3804
+ `, [accountId]);
3805
+ }
3806
+ };
3807
+ });
3808
+
3809
+ // ../../packages/database/src/repositories/conversation-provider-preference.repository.ts
3810
+ var ConversationProviderPreferenceRepository;
3811
+ var init_conversation_provider_preference_repository = __esm(() => {
3812
+ ConversationProviderPreferenceRepository = class ConversationProviderPreferenceRepository extends BaseRepository {
3813
+ find(pinKey) {
3814
+ const row = this.get(`SELECT provider, promotion_declined, last_seen_at FROM conversation_provider_preferences WHERE pin_key = ?`, [pinKey]);
3815
+ return row ? {
3816
+ provider: row.provider,
3817
+ promotionDeclined: row.promotion_declined === 1,
3818
+ lastSeenAt: row.last_seen_at
3819
+ } : null;
3820
+ }
3821
+ upsert(pinKey, provider, promotionDeclined, lastSeenAt) {
3822
+ this.run(`
3823
+ INSERT INTO conversation_provider_preferences (
3824
+ pin_key, provider, promotion_declined, last_seen_at
3825
+ )
3826
+ VALUES (?, ?, ?, ?)
3827
+ ON CONFLICT(pin_key) DO UPDATE SET
3828
+ provider = excluded.provider,
3829
+ promotion_declined = excluded.promotion_declined,
3830
+ last_seen_at = excluded.last_seen_at
3831
+ `, [pinKey, provider, promotionDeclined ? 1 : 0, lastSeenAt]);
3832
+ }
3833
+ deleteExpired(before) {
3834
+ this.run(`DELETE FROM conversation_provider_preferences WHERE last_seen_at < ?`, [before]);
3835
+ }
3836
+ deleteForAccount(accountId) {
3837
+ this.run(`
3838
+ DELETE FROM conversation_provider_preferences
3839
+ WHERE pin_key IN (
3840
+ SELECT pin_key FROM conversation_pins WHERE account_id = ?
3841
+ )
3842
+ `, [accountId]);
3843
+ }
3844
+ };
3845
+ });
3846
+
3710
3847
  // ../../packages/database/src/models/request-row.ts
3711
3848
  function toRequest(row) {
3712
3849
  return {
@@ -4317,6 +4454,8 @@ class DatabaseOperations {
4317
4454
  requests;
4318
4455
  authSessions;
4319
4456
  conversationPins;
4457
+ conversationProviderBlocks;
4458
+ conversationProviderPreferences;
4320
4459
  strategy;
4321
4460
  stats;
4322
4461
  constructor(dbPath) {
@@ -4336,6 +4475,8 @@ class DatabaseOperations {
4336
4475
  this.requests = new RequestRepository(this.db);
4337
4476
  this.authSessions = new AuthSessionRepository(this.db);
4338
4477
  this.conversationPins = new ConversationPinRepository(this.db);
4478
+ this.conversationProviderBlocks = new ConversationProviderBlockRepository(this.db);
4479
+ this.conversationProviderPreferences = new ConversationProviderPreferenceRepository(this.db);
4339
4480
  this.strategy = new StrategyRepository(this.db);
4340
4481
  this.stats = new StatsRepository(this.db);
4341
4482
  }
@@ -4379,6 +4520,8 @@ class DatabaseOperations {
4379
4520
  return this.accounts.update(accountId, data);
4380
4521
  }
4381
4522
  deleteAccount(accountId) {
4523
+ this.conversationProviderBlocks.deleteForAccount(accountId);
4524
+ this.conversationProviderPreferences.deleteForAccount(accountId);
4382
4525
  this.conversationPins.deleteForAccount(accountId);
4383
4526
  return this.accounts.delete(accountId);
4384
4527
  }
@@ -4393,6 +4536,23 @@ class DatabaseOperations {
4393
4536
  }
4394
4537
  deleteExpiredConversationPins(before) {
4395
4538
  this.conversationPins.deleteExpired(before);
4539
+ this.conversationProviderBlocks.deleteExpired(before);
4540
+ this.conversationProviderPreferences.deleteExpired(before);
4541
+ }
4542
+ getConversationProviderPreference(pinKey) {
4543
+ return this.conversationProviderPreferences.find(pinKey);
4544
+ }
4545
+ upsertConversationProviderPreference(pinKey, provider, promotionDeclined, lastSeenAt) {
4546
+ this.conversationProviderPreferences.upsert(pinKey, provider, promotionDeclined, lastSeenAt);
4547
+ }
4548
+ getConversationProviderBlock(pinKey, provider) {
4549
+ return this.conversationProviderBlocks.find(pinKey, provider);
4550
+ }
4551
+ upsertConversationProviderBlock(pinKey, provider, category, retryAt, lastSeenAt) {
4552
+ this.conversationProviderBlocks.upsert(pinKey, provider, category, retryAt, lastSeenAt);
4553
+ }
4554
+ deleteConversationProviderBlock(pinKey, provider) {
4555
+ this.conversationProviderBlocks.delete(pinKey, provider);
4396
4556
  }
4397
4557
  countAccounts() {
4398
4558
  return this.accounts.count();
@@ -4578,6 +4738,8 @@ var init_database_operations = __esm(() => {
4578
4738
  init_analytics_repository();
4579
4739
  init_auth_session_repository();
4580
4740
  init_conversation_pin_repository();
4741
+ init_conversation_provider_block_repository();
4742
+ init_conversation_provider_preference_repository();
4581
4743
  init_request_repository();
4582
4744
  init_stats_repository();
4583
4745
  init_strategy_repository();