@commonlyai/cli 0.1.92 → 0.1.93

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commonlyai/cli",
3
- "version": "0.1.92",
3
+ "version": "0.1.93",
4
4
  "license": "Apache-2.0",
5
5
  "description": "The Commonly CLI — connect agents, manage pods, iterate fast",
6
6
  "type": "module",
@@ -342,6 +342,18 @@ const startProviderProxy = async ({ provider, keyFile, tokenFile }) => {
342
342
  await writeFile(tokenFile, proxyToken, { encoding: 'utf8', mode: 0o600 });
343
343
  await chmod(tokenFile, 0o600);
344
344
 
345
+ const logRefusedRequest = (method, requestPath) => {
346
+ let normalizedPath = '/';
347
+ try {
348
+ normalizedPath = new URL(requestPath || '/', 'http://127.0.0.1').pathname || '/';
349
+ } catch {
350
+ // Do not include an unparseable raw request target in logs.
351
+ }
352
+ const safeMethod = typeof method === 'string' && /^[A-Z]+$/.test(method)
353
+ ? method : 'UNKNOWN';
354
+ process.stderr.write(`[opencode] provider proxy refused ${safeMethod} ${normalizedPath}\n`);
355
+ };
356
+
345
357
  const server = createServer((incoming, outgoing) => {
346
358
  const supplied = Buffer.from(incoming.headers.authorization || '');
347
359
  const expected = Buffer.from(`Bearer ${proxyToken}`);
@@ -356,22 +368,26 @@ const startProviderProxy = async ({ provider, keyFile, tokenFile }) => {
356
368
  return;
357
369
  }
358
370
  const rejectRoute = (path) => {
371
+ logRefusedRequest(incoming.method, path);
359
372
  incoming.resume();
360
373
  outgoing.writeHead(403, { 'content-type': 'text/plain; charset=utf-8' });
361
374
  outgoing.end(`Unsupported provider request: ${incoming.method || 'UNKNOWN'} ${path}`);
362
375
  };
376
+ const rejectBadRequest = () => {
377
+ logRefusedRequest(incoming.method, incoming.url);
378
+ incoming.resume();
379
+ outgoing.writeHead(400).end();
380
+ };
363
381
 
364
382
  let target;
365
383
  try {
366
384
  const requestPath = incoming.url || '/';
367
385
  if (!requestPath.startsWith('/') || requestPath.startsWith('//')) {
368
- incoming.resume();
369
- outgoing.writeHead(400).end();
386
+ rejectBadRequest();
370
387
  return;
371
388
  }
372
389
  if (/%(?:2f|5c|2e)/i.test(requestPath)) {
373
- incoming.resume();
374
- outgoing.writeHead(400).end();
390
+ rejectBadRequest();
375
391
  return;
376
392
  }
377
393
  // OpenCode owns this local request path, so never use it as an outbound
@@ -405,8 +421,7 @@ const startProviderProxy = async ({ provider, keyFile, tokenFile }) => {
405
421
  host: upstream.host,
406
422
  };
407
423
  } catch {
408
- incoming.resume();
409
- outgoing.writeHead(400).end();
424
+ rejectBadRequest();
410
425
  return;
411
426
  }
412
427