@2en/clawly-plugins 1.24.0 → 1.24.2-beta.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/config-setup.ts CHANGED
@@ -32,7 +32,8 @@ export interface ConfigPluginConfig {
32
32
  sessionMainKey?: string
33
33
  elevenlabsApiKey?: string
34
34
  elevenlabsVoiceId?: string
35
- braveSearchApiKey?: string
35
+ modelGatewayBaseUrl?: string
36
+ modelGatewayToken?: string
36
37
  }
37
38
 
38
39
  function toPC(api: PluginApi): ConfigPluginConfig {
@@ -190,7 +191,14 @@ export function patchSessionMainKey(
190
191
  }
191
192
 
192
193
  export function patchTts(config: Record<string, unknown>, pc: ConfigPluginConfig): boolean {
193
- if (!pc.elevenlabsApiKey) return false
194
+ const useProxy = !!(pc.modelGatewayBaseUrl && pc.modelGatewayToken)
195
+ const hasDirectKey = !!pc.elevenlabsApiKey
196
+ if (!useProxy && !hasDirectKey) return false
197
+
198
+ const targetApiKey = useProxy ? pc.modelGatewayToken! : pc.elevenlabsApiKey!
199
+ const targetBaseUrl = useProxy
200
+ ? `${pc.modelGatewayBaseUrl}/elevenlabs`
201
+ : 'https://api.elevenlabs.io'
194
202
 
195
203
  let dirty = false
196
204
  const messages = (config.messages ?? {}) as Record<string, unknown>
@@ -198,12 +206,12 @@ export function patchTts(config: Record<string, unknown>, pc: ConfigPluginConfig
198
206
  const elevenlabs = (tts.elevenlabs ?? {}) as Record<string, unknown>
199
207
 
200
208
  // Credentials: enforce
201
- if (elevenlabs.apiKey !== pc.elevenlabsApiKey) {
202
- elevenlabs.apiKey = pc.elevenlabsApiKey
209
+ if (elevenlabs.apiKey !== targetApiKey) {
210
+ elevenlabs.apiKey = targetApiKey
203
211
  dirty = true
204
212
  }
205
- if (elevenlabs.baseUrl !== 'https://api.elevenlabs.io') {
206
- elevenlabs.baseUrl = 'https://api.elevenlabs.io'
213
+ if (elevenlabs.baseUrl !== targetBaseUrl) {
214
+ elevenlabs.baseUrl = targetBaseUrl
207
215
  dirty = true
208
216
  }
209
217
  const voiceId = pc.elevenlabsVoiceId ?? ''
@@ -284,20 +292,33 @@ export function patchTts(config: Record<string, unknown>, pc: ConfigPluginConfig
284
292
  }
285
293
 
286
294
  export function patchWebSearch(config: Record<string, unknown>, pc: ConfigPluginConfig): boolean {
287
- if (!pc.braveSearchApiKey) return false
295
+ if (!pc.modelGatewayBaseUrl || !pc.modelGatewayToken) return false
288
296
 
289
297
  let dirty = false
290
298
  const tools = (config.tools ?? {}) as Record<string, unknown>
291
299
  const web = (tools.web ?? {}) as Record<string, unknown>
292
300
  const search = (web.search ?? {}) as Record<string, unknown>
301
+ const perplexity = (search.perplexity ?? {}) as Record<string, unknown>
293
302
 
294
- // Credentials: enforce
295
- if (search.provider !== 'brave') {
296
- search.provider = 'brave'
303
+ // Provider: enforce
304
+ if (search.provider !== 'perplexity') {
305
+ search.provider = 'perplexity'
306
+ dirty = true
307
+ }
308
+
309
+ // Perplexity credentials: enforce (nested under search.perplexity)
310
+ if (perplexity.apiKey !== pc.modelGatewayToken) {
311
+ perplexity.apiKey = pc.modelGatewayToken
312
+ dirty = true
313
+ }
314
+ if (perplexity.baseUrl !== pc.modelGatewayBaseUrl) {
315
+ perplexity.baseUrl = pc.modelGatewayBaseUrl
297
316
  dirty = true
298
317
  }
299
- if (search.apiKey !== pc.braveSearchApiKey) {
300
- search.apiKey = pc.braveSearchApiKey
318
+
319
+ // Perplexity model: set-if-missing
320
+ if (perplexity.model === undefined) {
321
+ perplexity.model = 'perplexity/sonar-pro'
301
322
  dirty = true
302
323
  }
303
324
 
@@ -312,6 +333,7 @@ export function patchWebSearch(config: Record<string, unknown>, pc: ConfigPlugin
312
333
  }
313
334
 
314
335
  if (dirty) {
336
+ search.perplexity = perplexity
315
337
  web.search = search
316
338
  tools.web = web
317
339
  config.tools = tools
@@ -57,8 +57,7 @@
57
57
  "defaultImageModel": { "type": "string" },
58
58
  "sessionMainKey": { "type": "string" },
59
59
  "elevenlabsApiKey": { "type": "string" },
60
- "elevenlabsVoiceId": { "type": "string" },
61
- "braveSearchApiKey": { "type": "string" }
60
+ "elevenlabsVoiceId": { "type": "string" }
62
61
  },
63
62
  "required": []
64
63
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@2en/clawly-plugins",
3
- "version": "1.24.0",
3
+ "version": "1.24.2-beta.0",
4
4
  "module": "index.ts",
5
5
  "type": "module",
6
6
  "repository": {