ikie-cli 0.1.44 → 0.1.46

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.
Files changed (2) hide show
  1. package/dist/index.js +23 -13
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -164,22 +164,28 @@ async function main() {
164
164
  config.requestsPerMinute = Math.floor(rpm);
165
165
  }
166
166
  // If user hasn't explicitly chosen a model, fetch the server's default.
167
+ // Retry once: the server can be slow on a cold start / right after a deploy,
168
+ // and a single timeout would otherwise silently strand us on the stale
169
+ // config default instead of the current server default.
167
170
  if (!argv.model && !hasExplicitModel()) {
168
- try {
169
- const modelsUrl = (config.baseURL ?? IKIE_API_BASE).includes('/api/v1')
170
- ? (config.baseURL ?? IKIE_API_BASE).replace('/api/v1', '/api/models')
171
- : `${IKIE_HOST}/api/models`;
172
- const res = await fetch(modelsUrl, { signal: AbortSignal.timeout(4000) });
173
- if (res.ok) {
174
- const data = await res.json();
175
- const serverDefault = data.models?.find(m => m.is_default);
176
- if (serverDefault) {
177
- config.model = serverDefault.name;
171
+ const modelsUrl = (config.baseURL ?? IKIE_API_BASE).includes('/api/v1')
172
+ ? (config.baseURL ?? IKIE_API_BASE).replace('/api/v1', '/api/models')
173
+ : `${IKIE_HOST}/api/models`;
174
+ for (let attempt = 0; attempt < 2; attempt++) {
175
+ try {
176
+ const res = await fetch(modelsUrl, { signal: AbortSignal.timeout(8000) });
177
+ if (res.ok) {
178
+ const data = await res.json();
179
+ const serverDefault = data.models?.find(m => m.is_default);
180
+ if (serverDefault) {
181
+ config.model = serverDefault.name;
182
+ }
183
+ break;
178
184
  }
179
185
  }
180
- }
181
- catch {
182
- // Silently fall back to DEFAULT_MODEL
186
+ catch {
187
+ // Retry once, then silently fall back to DEFAULT_MODEL.
188
+ }
183
189
  }
184
190
  }
185
191
  const oneShot = argv._.length > 0 ? argv._.join(' ') : undefined;
@@ -203,6 +209,10 @@ ${errorLine('Not signed in.')}
203
209
  apiKey,
204
210
  baseURL: config.baseURL ?? IKIE_API_BASE,
205
211
  timeout: 60000, // 60 seconds timeout to prevent indefinite hangs
212
+ // Override the SDK's default "User-Agent: OpenAI/JS x.y.z". Cloudflare's
213
+ // bot/WAF rules block any UA matching "OpenAI/…" with a 403 "Your request
214
+ // was blocked." — which would 403 every CLI request. Identify as ikie-cli.
215
+ defaultHeaders: { 'User-Agent': 'ikie-cli' },
206
216
  });
207
217
  const projectRoot = findProjectRoot(process.cwd());
208
218
  const projectCtx = detectProjectContext(projectRoot);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ikie-cli",
3
- "version": "0.1.44",
3
+ "version": "0.1.46",
4
4
  "description": "Agentic coding CLI — your terminal AI pair programmer",
5
5
  "type": "module",
6
6
  "bin": {