@2en/clawly-plugins 1.19.1 → 1.19.2
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/model-gateway-setup.ts +14 -11
- package/package.json +1 -1
package/model-gateway-setup.ts
CHANGED
|
@@ -78,16 +78,6 @@ export function writeOpenclawConfig(configPath: string, config: Record<string, u
|
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
export function setupModelGateway(api: PluginApi): void {
|
|
81
|
-
const cfg = api.pluginConfig as Record<string, unknown> | undefined
|
|
82
|
-
const baseUrl =
|
|
83
|
-
typeof cfg?.modelGatewayBaseUrl === 'string' ? cfg.modelGatewayBaseUrl.replace(/\/$/, '') : ''
|
|
84
|
-
const token = typeof cfg?.modelGatewayToken === 'string' ? cfg.modelGatewayToken : ''
|
|
85
|
-
|
|
86
|
-
if (!baseUrl || !token) {
|
|
87
|
-
api.logger.info('Model gateway not configured (missing baseUrl or token), skipping.')
|
|
88
|
-
return
|
|
89
|
-
}
|
|
90
|
-
|
|
91
81
|
const stateDir = resolveStateDir(api)
|
|
92
82
|
if (!stateDir) {
|
|
93
83
|
api.logger.warn('Cannot resolve state dir — model gateway setup skipped.')
|
|
@@ -97,7 +87,9 @@ export function setupModelGateway(api: PluginApi): void {
|
|
|
97
87
|
const configPath = path.join(stateDir, 'openclaw.json')
|
|
98
88
|
const config = readOpenclawConfig(configPath)
|
|
99
89
|
|
|
100
|
-
// If provider already exists, check if extra models or aliases need updating
|
|
90
|
+
// If provider already exists, check if extra models or aliases need updating.
|
|
91
|
+
// This runs before the credentials check because provisioned sprites have
|
|
92
|
+
// credentials in openclaw.json directly, not in pluginConfig.
|
|
101
93
|
const existingProvider = (config.models as any)?.providers?.[PROVIDER_NAME]
|
|
102
94
|
if (existingProvider) {
|
|
103
95
|
let dirty = false
|
|
@@ -141,6 +133,17 @@ export function setupModelGateway(api: PluginApi): void {
|
|
|
141
133
|
return
|
|
142
134
|
}
|
|
143
135
|
|
|
136
|
+
// No existing provider — need pluginConfig credentials to create one
|
|
137
|
+
const cfg = api.pluginConfig as Record<string, unknown> | undefined
|
|
138
|
+
const baseUrl =
|
|
139
|
+
typeof cfg?.modelGatewayBaseUrl === 'string' ? cfg.modelGatewayBaseUrl.replace(/\/$/, '') : ''
|
|
140
|
+
const token = typeof cfg?.modelGatewayToken === 'string' ? cfg.modelGatewayToken : ''
|
|
141
|
+
|
|
142
|
+
if (!baseUrl || !token) {
|
|
143
|
+
api.logger.info('Model gateway not configured (missing baseUrl or token), skipping.')
|
|
144
|
+
return
|
|
145
|
+
}
|
|
146
|
+
|
|
144
147
|
// Derive model IDs from agents.defaults
|
|
145
148
|
const defaultModelFull: string = (config.agents as any)?.defaults?.model?.primary ?? ''
|
|
146
149
|
const imageModelFull: string = (config.agents as any)?.defaults?.imageModel?.primary ?? ''
|