@clipit-ai/cli 0.2.1 → 0.2.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.
Files changed (2) hide show
  1. package/bin/clipit.mjs +28 -9
  2. package/package.json +1 -1
package/bin/clipit.mjs CHANGED
@@ -9,7 +9,7 @@ import path from 'node:path';
9
9
  import process from 'node:process';
10
10
  import { fileURLToPath } from 'node:url';
11
11
 
12
- const VERSION = '0.2.1';
12
+ const VERSION = '0.2.2';
13
13
  const DEFAULT_BASE_URL = 'https://clipit.dev';
14
14
  const DEFAULT_SCOPES = [
15
15
  'clippy_agent',
@@ -724,14 +724,33 @@ async function enforceRunMaxCredits(config, options, functionName) {
724
724
  async function login(config, options) {
725
725
  const { verifier, challenge } = pkcePair();
726
726
  const baseUrl = getBaseUrl(config, options);
727
- const started = await apiFetch(config, options, 'POST', '/api/v1/cli-auth/start', {
728
- codeChallenge: challenge,
729
- codeChallengeMethod: 'S256',
730
- requestedScopes: DEFAULT_SCOPES,
731
- deviceName: os.hostname(),
732
- cliVersion: VERSION,
733
- platform: `${process.platform}/${process.arch}`,
734
- }, { noAuth: true });
727
+ let started;
728
+ try {
729
+ started = await apiFetch(config, options, 'POST', '/api/v1/cli-auth/start', {
730
+ codeChallenge: challenge,
731
+ codeChallengeMethod: 'S256',
732
+ requestedScopes: DEFAULT_SCOPES,
733
+ deviceName: os.hostname(),
734
+ cliVersion: VERSION,
735
+ platform: `${process.platform}/${process.arch}`,
736
+ }, { noAuth: true });
737
+ } catch (error) {
738
+ // A login start should never need credentials — a 401/404 here means the
739
+ // server predates the CLI auth API entirely.
740
+ if (error.status === 401 || error.status === 404) {
741
+ throw Object.assign(
742
+ new Error([
743
+ `${baseUrl} does not support browser login yet (its API layer predates this CLI).`,
744
+ 'Use an API key instead:',
745
+ ` 1. Create one at ${baseUrl} -> Settings -> API Keys -> Connect an Agent`,
746
+ " 2. Store it: printf '%s' \"$CLIPPER_API_KEY\" | clipit auth set-key --stdin",
747
+ ' 3. Verify: clipit videos list',
748
+ ].join('\n')),
749
+ { exitCode: EXIT.AUTH, status: error.status, requestId: error.requestId },
750
+ );
751
+ }
752
+ throw error;
753
+ }
735
754
 
736
755
  if (!options['no-browser']) {
737
756
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clipit-ai/cli",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "ClipIt CLI for connecting shell-capable agents to ClipIt.",
5
5
  "type": "module",
6
6
  "bin": {