squidclaw 0.7.1 → 0.7.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/lib/features/self-config.js +30 -23
- package/package.json +1 -1
|
@@ -112,33 +112,40 @@ export function getKeyRequestMessage(skill) {
|
|
|
112
112
|
return lines.join('\n');
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
-
// Detect if a message
|
|
115
|
+
// Detect if a message contains an API key
|
|
116
116
|
export function detectApiKey(message) {
|
|
117
117
|
const trimmed = message.trim();
|
|
118
118
|
|
|
119
|
-
//
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
119
|
+
// Split by whitespace and newlines — check each token
|
|
120
|
+
const tokens = trimmed.split(/[\s\n]+/);
|
|
121
|
+
|
|
122
|
+
for (const token of tokens) {
|
|
123
|
+
const t = token.trim();
|
|
124
|
+
if (t.length < 10) continue;
|
|
125
|
+
|
|
126
|
+
// Anthropic
|
|
127
|
+
if (t.startsWith('sk-ant-')) {
|
|
128
|
+
return { provider: 'anthropic', key: t };
|
|
129
|
+
}
|
|
130
|
+
// OpenAI
|
|
131
|
+
if (t.startsWith('sk-') && !t.startsWith('sk-ant-') && t.length > 20) {
|
|
132
|
+
return { provider: 'openai', key: t };
|
|
133
|
+
}
|
|
134
|
+
// Groq
|
|
135
|
+
if (t.startsWith('gsk_') && t.length > 15) {
|
|
136
|
+
return { provider: 'groq', key: t };
|
|
137
|
+
}
|
|
138
|
+
// Google (AIza...)
|
|
139
|
+
if (t.startsWith('AIza') && t.length > 20) {
|
|
140
|
+
return { provider: 'google', key: t };
|
|
141
|
+
}
|
|
138
142
|
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
143
|
+
|
|
144
|
+
// Check full message for long unbroken tokens (generic key)
|
|
145
|
+
for (const token of tokens) {
|
|
146
|
+
if (token.length > 30 && !/\s/.test(token) && /^[A-Za-z0-9_\-]+$/.test(token)) {
|
|
147
|
+
return { provider: 'unknown', key: token };
|
|
148
|
+
}
|
|
142
149
|
}
|
|
143
150
|
|
|
144
151
|
return null;
|