@certalis/agent-smith 0.1.18 → 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.
- package/README.md +14 -8
- package/dist/bin.js +1060 -144
- package/dist/claude-companion/.claude-plugin/plugin.json +8 -0
- package/dist/claude-companion/hooks/hooks.json +4 -0
- package/dist/claude-companion/hooks/provider-choice.js +320 -0
- package/dist/claude-companion/hooks/register.js +74 -0
- package/dist/client-launcher.js +70 -11
- package/dist/edge.js +13 -2
- package/dist/https.js +13 -2
- package/dist/pool.js +985 -114
- package/dist/post-processor.worker.js +148 -1
- package/dist/server.js +985 -114
- package/package.json +1 -1
|
@@ -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;
|
|
@@ -1718,6 +1718,12 @@ function sanitizeTeamRouting(value) {
|
|
|
1718
1718
|
result.caller_weekly_max_usage = Object.fromEntries(entries);
|
|
1719
1719
|
}
|
|
1720
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
|
+
}
|
|
1721
1727
|
if (isNonNegativeFiniteNumber(value.admission_cap)) {
|
|
1722
1728
|
result.admission_cap = Math.floor(value.admission_cap);
|
|
1723
1729
|
}
|
|
@@ -1772,6 +1778,7 @@ var init_src4 = __esm(() => {
|
|
|
1772
1778
|
log2 = new Logger("Config");
|
|
1773
1779
|
PROVIDER_STRATEGIES = [
|
|
1774
1780
|
"anthropic-api",
|
|
1781
|
+
"model-studio-anthropic-api",
|
|
1775
1782
|
"openai-api",
|
|
1776
1783
|
"claude-code",
|
|
1777
1784
|
"codex"
|
|
@@ -1795,6 +1802,7 @@ var init_src4 = __esm(() => {
|
|
|
1795
1802
|
weeklyMaxUsage: 0.95,
|
|
1796
1803
|
weeklyMaxUsageByEmail: {},
|
|
1797
1804
|
callerWeeklyMaxUsage: {},
|
|
1805
|
+
callerProviderFallback: {},
|
|
1798
1806
|
admissionCap: 5,
|
|
1799
1807
|
admissionQueueLimit: 25,
|
|
1800
1808
|
admissionWaitMs: 30000,
|
|
@@ -1958,6 +1966,7 @@ var init_src4 = __esm(() => {
|
|
|
1958
1966
|
weeklyMaxUsage: file?.weekly_max_usage ?? TEAM_ROUTING_DEFAULTS.weeklyMaxUsage,
|
|
1959
1967
|
weeklyMaxUsageByEmail: { ...file?.weekly_max_usage_by_email },
|
|
1960
1968
|
callerWeeklyMaxUsage: { ...file?.caller_weekly_max_usage },
|
|
1969
|
+
callerProviderFallback: { ...file?.caller_provider_fallback },
|
|
1961
1970
|
admissionCap: file?.admission_cap ?? TEAM_ROUTING_DEFAULTS.admissionCap,
|
|
1962
1971
|
admissionQueueLimit: file?.admission_queue_limit ?? TEAM_ROUTING_DEFAULTS.admissionQueueLimit,
|
|
1963
1972
|
admissionWaitMs: file?.admission_wait_ms ?? TEAM_ROUTING_DEFAULTS.admissionWaitMs,
|
|
@@ -2028,6 +2037,7 @@ var init_src4 = __esm(() => {
|
|
|
2028
2037
|
"weekly_max_usage",
|
|
2029
2038
|
"weekly_max_usage_by_email",
|
|
2030
2039
|
"caller_weekly_max_usage",
|
|
2040
|
+
"caller_provider_fallback",
|
|
2031
2041
|
"admission_cap",
|
|
2032
2042
|
"admission_queue_limit",
|
|
2033
2043
|
"admission_wait_ms",
|
|
@@ -2058,6 +2068,11 @@ var init_src4 = __esm(() => {
|
|
|
2058
2068
|
...oldValue.caller_weekly_max_usage
|
|
2059
2069
|
};
|
|
2060
2070
|
}
|
|
2071
|
+
if (!("caller_provider_fallback" in value) && oldValue?.caller_provider_fallback) {
|
|
2072
|
+
sanitized.caller_provider_fallback = {
|
|
2073
|
+
...oldValue.caller_provider_fallback
|
|
2074
|
+
};
|
|
2075
|
+
}
|
|
2061
2076
|
this.persistStrictly("team_routing", sanitized);
|
|
2062
2077
|
}
|
|
2063
2078
|
allowAccountUuid(accountUuid) {
|
|
@@ -2883,6 +2898,30 @@ function ensureConversationPinsTable(db) {
|
|
|
2883
2898
|
db.run(`CREATE INDEX IF NOT EXISTS idx_conversation_pins_account ON conversation_pins(account_id)`);
|
|
2884
2899
|
db.run(`CREATE INDEX IF NOT EXISTS idx_conversation_pins_last_seen ON conversation_pins(last_seen_at)`);
|
|
2885
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
|
+
}
|
|
2886
2925
|
function remediateDuplicateAccountNames(db) {
|
|
2887
2926
|
const accounts = db.query(`
|
|
2888
2927
|
SELECT id, name, created_at
|
|
@@ -3008,6 +3047,8 @@ function ensureSchema(db) {
|
|
|
3008
3047
|
`);
|
|
3009
3048
|
ensureAuthSessionsTable(db);
|
|
3010
3049
|
ensureConversationPinsTable(db);
|
|
3050
|
+
ensureConversationProviderPreferencesTable(db);
|
|
3051
|
+
ensureConversationProviderBlocksTable(db);
|
|
3011
3052
|
}
|
|
3012
3053
|
function runMigrations(db) {
|
|
3013
3054
|
ensureSchema(db);
|
|
@@ -3027,6 +3068,8 @@ function runMigrations(db) {
|
|
|
3027
3068
|
db.run("DROP INDEX IF EXISTS idx_oauth_sessions_expires");
|
|
3028
3069
|
ensureAuthSessionsTable(db);
|
|
3029
3070
|
ensureConversationPinsTable(db);
|
|
3071
|
+
ensureConversationProviderPreferencesTable(db);
|
|
3072
|
+
ensureConversationProviderBlocksTable(db);
|
|
3030
3073
|
ensureAccountsNameUniqueness(db);
|
|
3031
3074
|
db.run(`CREATE TABLE IF NOT EXISTS enrollment_contacts (
|
|
3032
3075
|
account_id TEXT PRIMARY KEY REFERENCES accounts(id) ON DELETE CASCADE,
|
|
@@ -3722,6 +3765,85 @@ var init_conversation_pin_repository = __esm(() => {
|
|
|
3722
3765
|
};
|
|
3723
3766
|
});
|
|
3724
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
|
+
|
|
3725
3847
|
// ../../packages/database/src/models/request-row.ts
|
|
3726
3848
|
function toRequest(row) {
|
|
3727
3849
|
return {
|
|
@@ -4332,6 +4454,8 @@ class DatabaseOperations {
|
|
|
4332
4454
|
requests;
|
|
4333
4455
|
authSessions;
|
|
4334
4456
|
conversationPins;
|
|
4457
|
+
conversationProviderBlocks;
|
|
4458
|
+
conversationProviderPreferences;
|
|
4335
4459
|
strategy;
|
|
4336
4460
|
stats;
|
|
4337
4461
|
constructor(dbPath) {
|
|
@@ -4351,6 +4475,8 @@ class DatabaseOperations {
|
|
|
4351
4475
|
this.requests = new RequestRepository(this.db);
|
|
4352
4476
|
this.authSessions = new AuthSessionRepository(this.db);
|
|
4353
4477
|
this.conversationPins = new ConversationPinRepository(this.db);
|
|
4478
|
+
this.conversationProviderBlocks = new ConversationProviderBlockRepository(this.db);
|
|
4479
|
+
this.conversationProviderPreferences = new ConversationProviderPreferenceRepository(this.db);
|
|
4354
4480
|
this.strategy = new StrategyRepository(this.db);
|
|
4355
4481
|
this.stats = new StatsRepository(this.db);
|
|
4356
4482
|
}
|
|
@@ -4394,6 +4520,8 @@ class DatabaseOperations {
|
|
|
4394
4520
|
return this.accounts.update(accountId, data);
|
|
4395
4521
|
}
|
|
4396
4522
|
deleteAccount(accountId) {
|
|
4523
|
+
this.conversationProviderBlocks.deleteForAccount(accountId);
|
|
4524
|
+
this.conversationProviderPreferences.deleteForAccount(accountId);
|
|
4397
4525
|
this.conversationPins.deleteForAccount(accountId);
|
|
4398
4526
|
return this.accounts.delete(accountId);
|
|
4399
4527
|
}
|
|
@@ -4408,6 +4536,23 @@ class DatabaseOperations {
|
|
|
4408
4536
|
}
|
|
4409
4537
|
deleteExpiredConversationPins(before) {
|
|
4410
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);
|
|
4411
4556
|
}
|
|
4412
4557
|
countAccounts() {
|
|
4413
4558
|
return this.accounts.count();
|
|
@@ -4593,6 +4738,8 @@ var init_database_operations = __esm(() => {
|
|
|
4593
4738
|
init_analytics_repository();
|
|
4594
4739
|
init_auth_session_repository();
|
|
4595
4740
|
init_conversation_pin_repository();
|
|
4741
|
+
init_conversation_provider_block_repository();
|
|
4742
|
+
init_conversation_provider_preference_repository();
|
|
4596
4743
|
init_request_repository();
|
|
4597
4744
|
init_stats_repository();
|
|
4598
4745
|
init_strategy_repository();
|