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.
@@ -112,33 +112,40 @@ export function getKeyRequestMessage(skill) {
112
112
  return lines.join('\n');
113
113
  }
114
114
 
115
- // Detect if a message is an API key
115
+ // Detect if a message contains an API key
116
116
  export function detectApiKey(message) {
117
117
  const trimmed = message.trim();
118
118
 
119
- // Anthropic
120
- if (trimmed.startsWith('sk-ant-')) {
121
- return { provider: 'anthropic', key: trimmed };
122
- }
123
- // OpenAI
124
- if (trimmed.startsWith('sk-') && !trimmed.startsWith('sk-ant-') && trimmed.length > 20) {
125
- return { provider: 'openai', key: trimmed };
126
- }
127
- // Groq
128
- if (trimmed.startsWith('gsk_')) {
129
- return { provider: 'groq', key: trimmed };
130
- }
131
- // Google
132
- if (trimmed.startsWith('AI') && trimmed.length > 20 && !trimmed.includes(' ')) {
133
- return { provider: 'google', key: trimmed };
134
- }
135
- // Together
136
- if (trimmed.length > 40 && !trimmed.includes(' ') && /^[a-f0-9]+$/.test(trimmed)) {
137
- return { provider: 'together', key: trimmed };
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
- // Generic long token
140
- if (trimmed.length > 30 && !trimmed.includes(' ') && !trimmed.includes('\n')) {
141
- return { provider: 'unknown', key: trimmed };
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "squidclaw",
3
- "version": "0.7.1",
3
+ "version": "0.7.2",
4
4
  "description": "\ud83e\udd91 AI agent platform \u2014 human-like agents for WhatsApp, Telegram & more",
5
5
  "main": "lib/engine.js",
6
6
  "bin": {