heyiam 0.2.24 → 0.2.26

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/dist/llm/index.js CHANGED
@@ -1,24 +1,15 @@
1
1
  import { AnthropicProvider } from './anthropic-provider.js';
2
- import { ProxyProvider } from './proxy-provider.js';
3
2
  import { getAnthropicApiKey } from '../settings.js';
4
- export { ProxyError } from './proxy-provider.js';
5
3
  /**
6
- * Returns the appropriate LLM provider based on environment.
7
- *
8
- * Resolution priority:
9
- * 1. If ANTHROPIC_API_KEY env var is set → AnthropicProvider (BYOK)
10
- * 2. If API key saved in ~/.config/heyiam/settings.json → AnthropicProvider (BYOK)
11
- * 3. Otherwise → ProxyProvider (server-side, requires auth)
4
+ * Returns the Anthropic LLM provider.
5
+ * Requires ANTHROPIC_API_KEY (env var or saved in settings).
12
6
  */
13
7
  export function getProvider() {
14
- if (getAnthropicApiKey()) {
15
- return new AnthropicProvider();
16
- }
17
- return new ProxyProvider();
8
+ return new AnthropicProvider();
18
9
  }
19
10
  /**
20
- * Returns the current enhancement mode for display purposes.
11
+ * Returns whether AI enhancement is available.
21
12
  */
22
- export function getEnhanceMode() {
23
- return getAnthropicApiKey() ? 'local' : 'proxy';
13
+ export function hasApiKey() {
14
+ return !!getAnthropicApiKey();
24
15
  }
@@ -1,6 +1,6 @@
1
1
  import { Router } from 'express';
2
2
  import { saveAnthropicApiKey, clearAnthropicApiKey, getAnthropicApiKey } from '../settings.js';
3
- import { getEnhanceMode } from '../llm/index.js';
3
+ import { hasApiKey } from '../llm/index.js';
4
4
  export function createSettingsRouter(_ctx) {
5
5
  const router = Router();
6
6
  // Save or clear the Anthropic API key
@@ -9,12 +9,12 @@ export function createSettingsRouter(_ctx) {
9
9
  if (apiKey && typeof apiKey === 'string' && apiKey.trim()) {
10
10
  saveAnthropicApiKey(apiKey.trim());
11
11
  console.log('[settings] API key saved');
12
- res.json({ ok: true, mode: getEnhanceMode() });
12
+ res.json({ ok: true, hasKey: hasApiKey() });
13
13
  }
14
14
  else {
15
15
  clearAnthropicApiKey();
16
16
  console.log('[settings] API key cleared');
17
- res.json({ ok: true, mode: getEnhanceMode() });
17
+ res.json({ ok: true, hasKey: hasApiKey() });
18
18
  }
19
19
  });
20
20
  // Get current API key status (masked)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "heyiam",
3
- "version": "0.2.24",
3
+ "version": "0.2.26",
4
4
  "description": "Turn AI coding sessions into portfolio case studies",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -1,59 +0,0 @@
1
- import { getAuthToken } from '../auth.js';
2
- import { API_URL } from '../config.js';
3
- /**
4
- * Proxy provider — sends session data to Phoenix backend for server-side enhancement.
5
- * Used when user has no local ANTHROPIC_API_KEY but is authenticated.
6
- */
7
- export class ProxyProvider {
8
- name = 'proxy';
9
- async enhance(session) {
10
- const auth = getAuthToken();
11
- if (!auth?.token) {
12
- throw new ProxyError('AUTH_EXPIRED', 'Not authenticated. Run: heyiam login');
13
- }
14
- const response = await fetch(`${API_URL}/api/enhance`, {
15
- method: 'POST',
16
- headers: {
17
- 'Content-Type': 'application/json',
18
- 'Authorization': `Bearer ${auth.token}`,
19
- },
20
- body: JSON.stringify({ session: sessionToPayload(session) }),
21
- });
22
- if (!response.ok) {
23
- const errorBody = await response.json().catch(() => ({
24
- error: { code: 'PROXY_UNREACHABLE', message: 'Could not reach enhancement server' },
25
- }));
26
- throw new ProxyError(errorBody.error?.code ?? 'PROXY_ERROR', errorBody.error?.message ?? 'Enhancement failed', errorBody.error?.resets_at);
27
- }
28
- const data = await response.json();
29
- return data.result;
30
- }
31
- }
32
- export class ProxyError extends Error {
33
- code;
34
- resetsAt;
35
- constructor(code, message, resetsAt) {
36
- super(message);
37
- this.name = 'ProxyError';
38
- this.code = code;
39
- this.resetsAt = resetsAt;
40
- }
41
- }
42
- /**
43
- * Extracts the session fields that Phoenix expects for enhancement.
44
- */
45
- function sessionToPayload(session) {
46
- return {
47
- title: session.title,
48
- projectName: session.projectName,
49
- durationMinutes: session.durationMinutes,
50
- turns: session.turns,
51
- linesOfCode: session.linesOfCode,
52
- skills: session.skills,
53
- toolBreakdown: session.toolBreakdown,
54
- filesChanged: session.filesChanged,
55
- executionPath: session.executionPath,
56
- turnTimeline: session.turnTimeline,
57
- rawLog: session.rawLog,
58
- };
59
- }