@simonfestl/husky-cli 1.21.1 → 1.22.0

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.
@@ -1,6 +1,7 @@
1
1
  import { Command } from "commander";
2
2
  import { getConfig, setSessionConfig, clearSessionConfig, getSessionConfig, fetchAndCacheRole } from "./config.js";
3
3
  import { getPermissions, clearPermissionsCache, getCacheStatus, hasPermission, canAccessKnowledgeBase } from "../lib/permissions-cache.js";
4
+ import { apiRequest as hybridApiRequest } from "../lib/api-client.js";
4
5
  const API_KEY_ROLES = [
5
6
  "admin", "supervisor", "worker", "reviewer", "support",
6
7
  "purchasing", "ops", "e2e_agent", "pr_agent"
@@ -164,7 +165,7 @@ authCommand
164
165
  .option("--json", "Output as JSON")
165
166
  .action(async (options) => {
166
167
  try {
167
- const data = await apiRequest("/api/auth/whoami");
168
+ const data = await hybridApiRequest("/api/auth/whoami");
168
169
  if (options.json) {
169
170
  console.log(JSON.stringify(data, null, 2));
170
171
  return;
@@ -172,7 +173,12 @@ authCommand
172
173
  console.log("\nšŸ” Authentication Info");
173
174
  console.log("─".repeat(40));
174
175
  console.log(`Role: ${data.role}`);
175
- console.log(`Key ID: ${data.keyId}`);
176
+ if (data.keyId) {
177
+ console.log(`Key ID: ${data.keyId}`);
178
+ }
179
+ if (data.agent) {
180
+ console.log(`Agent: ${data.agent}`);
181
+ }
176
182
  console.log(`Source: ${data.source}`);
177
183
  if (data.scopes && data.scopes.length > 0) {
178
184
  console.log(`Scopes: ${data.scopes.join(", ")}`);
@@ -61,16 +61,21 @@ async function doFetch(url, method, authHeader, body) {
61
61
  });
62
62
  }
63
63
  async function getAuthHeader(session, apiKey) {
64
+ // DEBUG: console.log('DEBUG session:', session?.token ? 'exists' : 'missing', session?.expiresAt);
64
65
  if (session?.token && session.expiresAt) {
66
+ // DEBUG: console.log('DEBUG: Checking expiration...');
65
67
  if (isSessionExpired(session.expiresAt)) {
68
+ // DEBUG: console.log('DEBUG: Session expired, refreshing...');
66
69
  if (session.agent) {
67
70
  const newSession = await refreshSession(session.agent);
68
71
  if (newSession) {
72
+ // DEBUG: console.log('DEBUG: Refresh successful, using Bearer token');
69
73
  return { "Authorization": `Bearer ${newSession.token}` };
70
74
  }
71
75
  }
72
76
  clearSessionConfig();
73
77
  if (apiKey) {
78
+ // DEBUG: console.log('DEBUG: Refresh failed, falling back to API key');
74
79
  return { "x-api-key": apiKey };
75
80
  }
76
81
  throw new Error("Session expired and no API key available for refresh");
@@ -78,9 +83,11 @@ async function getAuthHeader(session, apiKey) {
78
83
  if (isSessionExpiringSoon(session.expiresAt) && session.agent) {
79
84
  refreshSession(session.agent).catch(() => { });
80
85
  }
86
+ // DEBUG: console.log('DEBUG: Using existing Bearer token');
81
87
  return { "Authorization": `Bearer ${session.token}` };
82
88
  }
83
89
  if (apiKey) {
90
+ // DEBUG: console.log('DEBUG: No session, using API key');
84
91
  return { "x-api-key": apiKey };
85
92
  }
86
93
  throw new Error("No authentication configured. Run: husky auth login --agent <name> or husky config set api-key <key>");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simonfestl/husky-cli",
3
- "version": "1.21.1",
3
+ "version": "1.22.0",
4
4
  "description": "CLI for Huskyv0 Task Orchestration with Claude Agent SDK",
5
5
  "type": "module",
6
6
  "bin": {