oh-my-claude-sisyphus 1.11.2 → 2.0.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 (207) hide show
  1. package/README.md +37 -12
  2. package/dist/__tests__/example.test.d.ts +2 -0
  3. package/dist/__tests__/example.test.d.ts.map +1 -0
  4. package/dist/__tests__/example.test.js +20 -0
  5. package/dist/__tests__/example.test.js.map +1 -0
  6. package/dist/__tests__/hooks.test.d.ts +2 -0
  7. package/dist/__tests__/hooks.test.d.ts.map +1 -0
  8. package/dist/__tests__/hooks.test.js +644 -0
  9. package/dist/__tests__/hooks.test.js.map +1 -0
  10. package/dist/__tests__/installer.test.d.ts +2 -0
  11. package/dist/__tests__/installer.test.d.ts.map +1 -0
  12. package/dist/__tests__/installer.test.js +369 -0
  13. package/dist/__tests__/installer.test.js.map +1 -0
  14. package/dist/__tests__/model-routing.test.d.ts +2 -0
  15. package/dist/__tests__/model-routing.test.d.ts.map +1 -0
  16. package/dist/__tests__/model-routing.test.js +814 -0
  17. package/dist/__tests__/model-routing.test.js.map +1 -0
  18. package/dist/__tests__/skills.test.d.ts +2 -0
  19. package/dist/__tests__/skills.test.d.ts.map +1 -0
  20. package/dist/__tests__/skills.test.js +126 -0
  21. package/dist/__tests__/skills.test.js.map +1 -0
  22. package/dist/__tests__/types.test.d.ts +2 -0
  23. package/dist/__tests__/types.test.d.ts.map +1 -0
  24. package/dist/__tests__/types.test.js +77 -0
  25. package/dist/__tests__/types.test.js.map +1 -0
  26. package/dist/agents/definitions.d.ts +33 -1
  27. package/dist/agents/definitions.d.ts.map +1 -1
  28. package/dist/agents/definitions.js +254 -3
  29. package/dist/agents/definitions.js.map +1 -1
  30. package/dist/agents/index.d.ts +1 -1
  31. package/dist/agents/index.d.ts.map +1 -1
  32. package/dist/agents/index.js +3 -1
  33. package/dist/agents/index.js.map +1 -1
  34. package/dist/agents/oracle.d.ts.map +1 -1
  35. package/dist/agents/oracle.js +43 -1
  36. package/dist/agents/oracle.js.map +1 -1
  37. package/dist/agents/orchestrator-sisyphus.js +2 -2
  38. package/dist/agents/orchestrator-sisyphus.js.map +1 -1
  39. package/dist/cli/index.js +22 -11
  40. package/dist/cli/index.js.map +1 -1
  41. package/dist/config/loader.d.ts.map +1 -1
  42. package/dist/config/loader.js +49 -0
  43. package/dist/config/loader.js.map +1 -1
  44. package/dist/features/auto-update.d.ts.map +1 -1
  45. package/dist/features/auto-update.js +14 -3
  46. package/dist/features/auto-update.js.map +1 -1
  47. package/dist/features/builtin-skills/skills.d.ts.map +1 -1
  48. package/dist/features/builtin-skills/skills.js +0 -1351
  49. package/dist/features/builtin-skills/skills.js.map +1 -1
  50. package/dist/features/index.d.ts +1 -0
  51. package/dist/features/index.d.ts.map +1 -1
  52. package/dist/features/index.js +14 -0
  53. package/dist/features/index.js.map +1 -1
  54. package/dist/features/model-routing/index.d.ts +34 -0
  55. package/dist/features/model-routing/index.d.ts.map +1 -0
  56. package/dist/features/model-routing/index.js +48 -0
  57. package/dist/features/model-routing/index.js.map +1 -0
  58. package/dist/features/model-routing/prompts/haiku.d.ts +54 -0
  59. package/dist/features/model-routing/prompts/haiku.d.ts.map +1 -0
  60. package/dist/features/model-routing/prompts/haiku.js +141 -0
  61. package/dist/features/model-routing/prompts/haiku.js.map +1 -0
  62. package/dist/features/model-routing/prompts/index.d.ts +45 -0
  63. package/dist/features/model-routing/prompts/index.d.ts.map +1 -0
  64. package/dist/features/model-routing/prompts/index.js +116 -0
  65. package/dist/features/model-routing/prompts/index.js.map +1 -0
  66. package/dist/features/model-routing/prompts/opus.d.ts +34 -0
  67. package/dist/features/model-routing/prompts/opus.d.ts.map +1 -0
  68. package/dist/features/model-routing/prompts/opus.js +153 -0
  69. package/dist/features/model-routing/prompts/opus.js.map +1 -0
  70. package/dist/features/model-routing/prompts/sonnet.d.ts +38 -0
  71. package/dist/features/model-routing/prompts/sonnet.d.ts.map +1 -0
  72. package/dist/features/model-routing/prompts/sonnet.js +149 -0
  73. package/dist/features/model-routing/prompts/sonnet.js.map +1 -0
  74. package/dist/features/model-routing/router.d.ts +92 -0
  75. package/dist/features/model-routing/router.d.ts.map +1 -0
  76. package/dist/features/model-routing/router.js +267 -0
  77. package/dist/features/model-routing/router.js.map +1 -0
  78. package/dist/features/model-routing/rules.d.ts +32 -0
  79. package/dist/features/model-routing/rules.d.ts.map +1 -0
  80. package/dist/features/model-routing/rules.js +224 -0
  81. package/dist/features/model-routing/rules.js.map +1 -0
  82. package/dist/features/model-routing/scorer.d.ts +35 -0
  83. package/dist/features/model-routing/scorer.d.ts.map +1 -0
  84. package/dist/features/model-routing/scorer.js +241 -0
  85. package/dist/features/model-routing/scorer.js.map +1 -0
  86. package/dist/features/model-routing/signals.d.ts +26 -0
  87. package/dist/features/model-routing/signals.d.ts.map +1 -0
  88. package/dist/features/model-routing/signals.js +283 -0
  89. package/dist/features/model-routing/signals.js.map +1 -0
  90. package/dist/features/model-routing/types.d.ts +195 -0
  91. package/dist/features/model-routing/types.d.ts.map +1 -0
  92. package/dist/features/model-routing/types.js +86 -0
  93. package/dist/features/model-routing/types.js.map +1 -0
  94. package/dist/hooks/agent-usage-reminder/index.d.ts +1 -1
  95. package/dist/hooks/agent-usage-reminder/index.d.ts.map +1 -1
  96. package/dist/hooks/agent-usage-reminder/index.js +1 -1
  97. package/dist/hooks/agent-usage-reminder/index.js.map +1 -1
  98. package/dist/hooks/auto-slash-command/executor.js.map +1 -1
  99. package/dist/hooks/auto-slash-command/index.d.ts +3 -3
  100. package/dist/hooks/auto-slash-command/index.d.ts.map +1 -1
  101. package/dist/hooks/auto-slash-command/index.js.map +1 -1
  102. package/dist/hooks/background-notification/index.js +1 -1
  103. package/dist/hooks/background-notification/index.js.map +1 -1
  104. package/dist/hooks/bridge.d.ts.map +1 -1
  105. package/dist/hooks/bridge.js.map +1 -1
  106. package/dist/hooks/comment-checker/filters.d.ts +1 -1
  107. package/dist/hooks/comment-checker/filters.d.ts.map +1 -1
  108. package/dist/hooks/comment-checker/filters.js +1 -1
  109. package/dist/hooks/comment-checker/filters.js.map +1 -1
  110. package/dist/hooks/comment-checker/index.js +1 -1
  111. package/dist/hooks/comment-checker/index.js.map +1 -1
  112. package/dist/hooks/context-window-limit-recovery/index.d.ts.map +1 -1
  113. package/dist/hooks/context-window-limit-recovery/index.js.map +1 -1
  114. package/dist/hooks/index.d.ts +3 -3
  115. package/dist/hooks/index.d.ts.map +1 -1
  116. package/dist/hooks/index.js +3 -3
  117. package/dist/hooks/index.js.map +1 -1
  118. package/dist/hooks/keyword-detector/index.d.ts +1 -1
  119. package/dist/hooks/keyword-detector/index.d.ts.map +1 -1
  120. package/dist/hooks/keyword-detector/index.js +1 -1
  121. package/dist/hooks/keyword-detector/index.js.map +1 -1
  122. package/dist/hooks/persistent-mode/index.d.ts.map +1 -1
  123. package/dist/hooks/persistent-mode/index.js.map +1 -1
  124. package/dist/hooks/plugin-patterns/index.d.ts.map +1 -1
  125. package/dist/hooks/plugin-patterns/index.js +12 -22
  126. package/dist/hooks/plugin-patterns/index.js.map +1 -1
  127. package/dist/hooks/preemptive-compaction/index.d.ts +2 -2
  128. package/dist/hooks/preemptive-compaction/index.d.ts.map +1 -1
  129. package/dist/hooks/preemptive-compaction/index.js +1 -11
  130. package/dist/hooks/preemptive-compaction/index.js.map +1 -1
  131. package/dist/hooks/ralph-loop/index.js.map +1 -1
  132. package/dist/hooks/rules-injector/matcher.js +1 -1
  133. package/dist/hooks/rules-injector/matcher.js.map +1 -1
  134. package/dist/hooks/session-recovery/index.d.ts +1 -1
  135. package/dist/hooks/session-recovery/index.d.ts.map +1 -1
  136. package/dist/hooks/session-recovery/index.js +1 -1
  137. package/dist/hooks/session-recovery/index.js.map +1 -1
  138. package/dist/hooks/sisyphus-orchestrator/index.d.ts.map +1 -1
  139. package/dist/hooks/sisyphus-orchestrator/index.js.map +1 -1
  140. package/dist/hooks/ultrawork-state/index.js +1 -1
  141. package/dist/hooks/ultrawork-state/index.js.map +1 -1
  142. package/dist/index.d.ts +2 -2
  143. package/dist/index.d.ts.map +1 -1
  144. package/dist/index.js +4 -2
  145. package/dist/index.js.map +1 -1
  146. package/dist/installer/hooks.d.ts +1 -1
  147. package/dist/installer/hooks.js +1 -1
  148. package/dist/installer/index.d.ts +8 -7
  149. package/dist/installer/index.d.ts.map +1 -1
  150. package/dist/installer/index.js +648 -2141
  151. package/dist/installer/index.js.map +1 -1
  152. package/dist/shared/types.d.ts +25 -0
  153. package/dist/shared/types.d.ts.map +1 -1
  154. package/dist/tools/lsp/servers.d.ts.map +1 -1
  155. package/dist/tools/lsp/servers.js +2 -14
  156. package/dist/tools/lsp/servers.js.map +1 -1
  157. package/package.json +18 -10
  158. package/scripts/install.sh +236 -260
  159. package/scripts/test-pr25.sh +525 -0
  160. package/dist/agents/model-lists.d.ts +0 -26
  161. package/dist/agents/model-lists.d.ts.map +0 -1
  162. package/dist/agents/model-lists.js +0 -62
  163. package/dist/agents/model-lists.js.map +0 -1
  164. package/dist/auth/index.d.ts +0 -10
  165. package/dist/auth/index.d.ts.map +0 -1
  166. package/dist/auth/index.js +0 -13
  167. package/dist/auth/index.js.map +0 -1
  168. package/dist/auth/manager.d.ts +0 -54
  169. package/dist/auth/manager.d.ts.map +0 -1
  170. package/dist/auth/manager.js +0 -248
  171. package/dist/auth/manager.js.map +0 -1
  172. package/dist/auth/oauth-google.d.ts +0 -47
  173. package/dist/auth/oauth-google.d.ts.map +0 -1
  174. package/dist/auth/oauth-google.js +0 -280
  175. package/dist/auth/oauth-google.js.map +0 -1
  176. package/dist/auth/oauth-openai.d.ts +0 -46
  177. package/dist/auth/oauth-openai.d.ts.map +0 -1
  178. package/dist/auth/oauth-openai.js +0 -264
  179. package/dist/auth/oauth-openai.js.map +0 -1
  180. package/dist/auth/pkce.d.ts +0 -14
  181. package/dist/auth/pkce.d.ts.map +0 -1
  182. package/dist/auth/pkce.js +0 -35
  183. package/dist/auth/pkce.js.map +0 -1
  184. package/dist/auth/storage.d.ts +0 -52
  185. package/dist/auth/storage.d.ts.map +0 -1
  186. package/dist/auth/storage.js +0 -230
  187. package/dist/auth/storage.js.map +0 -1
  188. package/dist/auth/types.d.ts +0 -76
  189. package/dist/auth/types.d.ts.map +0 -1
  190. package/dist/auth/types.js +0 -5
  191. package/dist/auth/types.js.map +0 -1
  192. package/dist/providers/index.d.ts +0 -8
  193. package/dist/providers/index.d.ts.map +0 -1
  194. package/dist/providers/index.js +0 -10
  195. package/dist/providers/index.js.map +0 -1
  196. package/dist/providers/registry.d.ts +0 -29
  197. package/dist/providers/registry.d.ts.map +0 -1
  198. package/dist/providers/registry.js +0 -162
  199. package/dist/providers/registry.js.map +0 -1
  200. package/dist/providers/router.d.ts +0 -40
  201. package/dist/providers/router.d.ts.map +0 -1
  202. package/dist/providers/router.js +0 -88
  203. package/dist/providers/router.js.map +0 -1
  204. package/dist/providers/types.d.ts +0 -92
  205. package/dist/providers/types.d.ts.map +0 -1
  206. package/dist/providers/types.js +0 -27
  207. package/dist/providers/types.js.map +0 -1
@@ -1,46 +0,0 @@
1
- /**
2
- * OpenAI OAuth 2.0 implementation for ChatGPT Plus/Pro subscriptions
3
- *
4
- * Uses the same OAuth flow as OpenAI's Codex CLI
5
- */
6
- import type { OAuthTokens, OAuthConfig } from '../providers/types.js';
7
- import type { OAuthResult, PKCEData } from './types.js';
8
- /**
9
- * OpenAI OAuth configuration
10
- * These are the same credentials used by OpenAI's Codex CLI
11
- */
12
- export declare const OPENAI_OAUTH_CONFIG: OAuthConfig;
13
- /**
14
- * OpenAI OAuth handler
15
- */
16
- export declare class OpenAIOAuth {
17
- private config;
18
- constructor(config?: OAuthConfig);
19
- /**
20
- * Generate the authorization URL for the OAuth flow
21
- */
22
- getAuthorizationUrl(pkce: PKCEData): string;
23
- /**
24
- * Exchange authorization code for tokens
25
- */
26
- exchangeCodeForTokens(code: string, codeVerifier: string): Promise<OAuthTokens>;
27
- /**
28
- * Refresh tokens using refresh token
29
- */
30
- refreshTokens(refreshToken: string): Promise<OAuthTokens>;
31
- /**
32
- * Exchange ID token for an API key (optional)
33
- * This can be used if you want a traditional API key instead of OAuth tokens
34
- */
35
- exchangeForApiKey(idToken: string): Promise<string>;
36
- /**
37
- * Run the full OAuth authentication flow
38
- * Opens a browser and waits for callback
39
- */
40
- authenticate(): Promise<OAuthResult>;
41
- }
42
- /**
43
- * Create OpenAI OAuth handler instance
44
- */
45
- export declare function createOpenAIOAuth(): OpenAIOAuth;
46
- //# sourceMappingURL=oauth-openai.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"oauth-openai.d.ts","sourceRoot":"","sources":["../../src/auth/oauth-openai.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AA2BxD;;;GAGG;AACH,eAAO,MAAM,mBAAmB,EAAE,WAMjC,CAAC;AAEF;;GAEG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,MAAM,CAAc;gBAEhB,MAAM,GAAE,WAAiC;IAIrD;;OAEG;IACH,mBAAmB,CAAC,IAAI,EAAE,QAAQ,GAAG,MAAM;IAgB3C;;OAEG;IACG,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAqCrF;;OAEG;IACG,aAAa,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAmC/D;;;OAGG;IACG,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAwBzD;;;OAGG;IACG,YAAY,IAAI,OAAO,CAAC,WAAW,CAAC;CA+G3C;AAED;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,WAAW,CAE/C"}
@@ -1,264 +0,0 @@
1
- /**
2
- * OpenAI OAuth 2.0 implementation for ChatGPT Plus/Pro subscriptions
3
- *
4
- * Uses the same OAuth flow as OpenAI's Codex CLI
5
- */
6
- import * as http from 'http';
7
- import { exec } from 'child_process';
8
- import { URL, URLSearchParams } from 'url';
9
- import { generatePKCE, verifyState } from './pkce.js';
10
- /**
11
- * Open URL in default browser (cross-platform)
12
- */
13
- function openBrowser(url) {
14
- const platform = process.platform;
15
- let command;
16
- if (platform === 'darwin') {
17
- command = `open "${url}"`;
18
- }
19
- else if (platform === 'win32') {
20
- command = `start "" "${url}"`;
21
- }
22
- else {
23
- // Linux and others
24
- command = `xdg-open "${url}"`;
25
- }
26
- exec(command, (error) => {
27
- if (error) {
28
- console.log('Could not open browser automatically.');
29
- console.log(`Please visit: ${url}`);
30
- }
31
- });
32
- }
33
- /**
34
- * OpenAI OAuth configuration
35
- * These are the same credentials used by OpenAI's Codex CLI
36
- */
37
- export const OPENAI_OAUTH_CONFIG = {
38
- clientId: 'app_EMoamEEZ73f0CkXaXp7hrann',
39
- authUrl: 'https://auth.openai.com/oauth/authorize',
40
- tokenUrl: 'https://auth.openai.com/oauth/token',
41
- redirectUri: 'http://localhost:1455/auth/callback',
42
- scopes: ['openid', 'profile', 'email', 'offline_access'],
43
- };
44
- /**
45
- * OpenAI OAuth handler
46
- */
47
- export class OpenAIOAuth {
48
- config;
49
- constructor(config = OPENAI_OAUTH_CONFIG) {
50
- this.config = config;
51
- }
52
- /**
53
- * Generate the authorization URL for the OAuth flow
54
- */
55
- getAuthorizationUrl(pkce) {
56
- const params = new URLSearchParams({
57
- response_type: 'code',
58
- client_id: this.config.clientId,
59
- redirect_uri: this.config.redirectUri,
60
- scope: this.config.scopes.join(' '),
61
- code_challenge: pkce.codeChallenge,
62
- code_challenge_method: 'S256',
63
- id_token_add_organizations: 'true',
64
- codex_cli_simplified_flow: 'true',
65
- state: pkce.state,
66
- });
67
- return `${this.config.authUrl}?${params.toString()}`;
68
- }
69
- /**
70
- * Exchange authorization code for tokens
71
- */
72
- async exchangeCodeForTokens(code, codeVerifier) {
73
- const response = await fetch(this.config.tokenUrl, {
74
- method: 'POST',
75
- headers: {
76
- 'Content-Type': 'application/x-www-form-urlencoded',
77
- },
78
- body: new URLSearchParams({
79
- grant_type: 'authorization_code',
80
- code,
81
- redirect_uri: this.config.redirectUri,
82
- client_id: this.config.clientId,
83
- code_verifier: codeVerifier,
84
- }),
85
- });
86
- if (!response.ok) {
87
- const error = await response.text();
88
- throw new Error(`Token exchange failed: ${error}`);
89
- }
90
- const data = await response.json();
91
- return {
92
- accessToken: data.access_token,
93
- refreshToken: data.refresh_token,
94
- idToken: data.id_token,
95
- expiresAt: Date.now() + (data.expires_in * 1000),
96
- tokenType: data.token_type,
97
- };
98
- }
99
- /**
100
- * Refresh tokens using refresh token
101
- */
102
- async refreshTokens(refreshToken) {
103
- const response = await fetch(this.config.tokenUrl, {
104
- method: 'POST',
105
- headers: {
106
- 'Content-Type': 'application/x-www-form-urlencoded',
107
- },
108
- body: new URLSearchParams({
109
- grant_type: 'refresh_token',
110
- refresh_token: refreshToken,
111
- client_id: this.config.clientId,
112
- }),
113
- });
114
- if (!response.ok) {
115
- const error = await response.text();
116
- throw new Error(`Token refresh failed: ${error}`);
117
- }
118
- const data = await response.json();
119
- return {
120
- accessToken: data.access_token,
121
- refreshToken: data.refresh_token || refreshToken,
122
- idToken: data.id_token,
123
- expiresAt: Date.now() + (data.expires_in * 1000),
124
- tokenType: data.token_type,
125
- };
126
- }
127
- /**
128
- * Exchange ID token for an API key (optional)
129
- * This can be used if you want a traditional API key instead of OAuth tokens
130
- */
131
- async exchangeForApiKey(idToken) {
132
- const response = await fetch(this.config.tokenUrl, {
133
- method: 'POST',
134
- headers: {
135
- 'Content-Type': 'application/x-www-form-urlencoded',
136
- },
137
- body: new URLSearchParams({
138
- grant_type: 'urn:ietf:params:oauth:grant-type:token-exchange',
139
- requested_token: 'openai-api-key',
140
- subject_token: idToken,
141
- subject_token_type: 'urn:ietf:params:oauth:token-type:id_token',
142
- client_id: this.config.clientId,
143
- }),
144
- });
145
- if (!response.ok) {
146
- const error = await response.text();
147
- throw new Error(`API key exchange failed: ${error}`);
148
- }
149
- const data = await response.json();
150
- return data.access_token;
151
- }
152
- /**
153
- * Run the full OAuth authentication flow
154
- * Opens a browser and waits for callback
155
- */
156
- async authenticate() {
157
- const pkce = generatePKCE();
158
- const authUrl = this.getAuthorizationUrl(pkce);
159
- return new Promise((resolve) => {
160
- const server = http.createServer(async (req, res) => {
161
- const url = new URL(req.url, `http://localhost:1455`);
162
- if (url.pathname === '/auth/callback') {
163
- const code = url.searchParams.get('code');
164
- const returnedState = url.searchParams.get('state');
165
- const error = url.searchParams.get('error');
166
- // Handle errors
167
- if (error) {
168
- res.writeHead(400, { 'Content-Type': 'text/html' });
169
- res.end(`
170
- <html>
171
- <body style="font-family: system-ui; padding: 40px; text-align: center;">
172
- <h1>Authentication Failed</h1>
173
- <p>Error: ${error}</p>
174
- <p>You can close this window.</p>
175
- </body>
176
- </html>
177
- `);
178
- server.close();
179
- resolve({ success: false, error });
180
- return;
181
- }
182
- // Verify state
183
- if (!returnedState || !verifyState(pkce.state, returnedState)) {
184
- res.writeHead(400, { 'Content-Type': 'text/html' });
185
- res.end(`
186
- <html>
187
- <body style="font-family: system-ui; padding: 40px; text-align: center;">
188
- <h1>Authentication Failed</h1>
189
- <p>State mismatch - possible CSRF attack.</p>
190
- <p>You can close this window.</p>
191
- </body>
192
- </html>
193
- `);
194
- server.close();
195
- resolve({ success: false, error: 'State mismatch' });
196
- return;
197
- }
198
- // Exchange code for tokens
199
- if (code) {
200
- try {
201
- const tokens = await this.exchangeCodeForTokens(code, pkce.codeVerifier);
202
- // Extract email from ID token if available
203
- let email;
204
- if (tokens.idToken) {
205
- try {
206
- const payload = JSON.parse(Buffer.from(tokens.idToken.split('.')[1], 'base64').toString());
207
- email = payload.email;
208
- }
209
- catch {
210
- // Ignore ID token parsing errors
211
- }
212
- }
213
- res.writeHead(200, { 'Content-Type': 'text/html' });
214
- res.end(`
215
- <html>
216
- <body style="font-family: system-ui; padding: 40px; text-align: center;">
217
- <h1>Authentication Successful!</h1>
218
- <p>You are now connected to OpenAI${email ? ` as ${email}` : ''}.</p>
219
- <p>You can close this window and return to the terminal.</p>
220
- </body>
221
- </html>
222
- `);
223
- server.close();
224
- resolve({ success: true, tokens, email });
225
- }
226
- catch (err) {
227
- res.writeHead(500, { 'Content-Type': 'text/html' });
228
- res.end(`
229
- <html>
230
- <body style="font-family: system-ui; padding: 40px; text-align: center;">
231
- <h1>Authentication Failed</h1>
232
- <p>Error: ${err instanceof Error ? err.message : 'Unknown error'}</p>
233
- <p>You can close this window.</p>
234
- </body>
235
- </html>
236
- `);
237
- server.close();
238
- resolve({ success: false, error: err instanceof Error ? err.message : 'Unknown error' });
239
- }
240
- }
241
- }
242
- });
243
- // Start server
244
- server.listen(1455, '127.0.0.1', () => {
245
- console.log('\nOpening browser for OpenAI authentication...');
246
- console.log(`If the browser doesn't open, visit: ${authUrl}\n`);
247
- // Try to open browser
248
- openBrowser(authUrl);
249
- });
250
- // Timeout after 5 minutes
251
- setTimeout(() => {
252
- server.close();
253
- resolve({ success: false, error: 'Authentication timeout (5 minutes)' });
254
- }, 5 * 60 * 1000);
255
- });
256
- }
257
- }
258
- /**
259
- * Create OpenAI OAuth handler instance
260
- */
261
- export function createOpenAIOAuth() {
262
- return new OpenAIOAuth();
263
- }
264
- //# sourceMappingURL=oauth-openai.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"oauth-openai.js","sourceRoot":"","sources":["../../src/auth/oauth-openai.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,GAAG,EAAE,eAAe,EAAE,MAAM,KAAK,CAAC;AAG3C,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAEtD;;GAEG;AACH,SAAS,WAAW,CAAC,GAAW;I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AE,KAAK,EAAE,oCAAoC,EAAE,CAAC,CAAC;YAC3E,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC;QACpB,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB;IAC/B,OAAO,IAAI,WAAW,EAAE,CAAC;AAC3B,CAAC"}
@@ -1,14 +0,0 @@
1
- /**
2
- * PKCE (Proof Key for Code Exchange) utilities for OAuth 2.0
3
- */
4
- import type { PKCEData } from './types.js';
5
- /**
6
- * Generate PKCE code verifier and challenge
7
- * RFC 7636: https://datatracker.ietf.org/doc/html/rfc7636
8
- */
9
- export declare function generatePKCE(): PKCEData;
10
- /**
11
- * Verify that a state matches the expected state
12
- */
13
- export declare function verifyState(expected: string, received: string): boolean;
14
- //# sourceMappingURL=pkce.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"pkce.d.ts","sourceRoot":"","sources":["../../src/auth/pkce.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C;;;GAGG;AACH,wBAAgB,YAAY,IAAI,QAAQ,CAkBvC;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CASvE"}
package/dist/auth/pkce.js DELETED
@@ -1,35 +0,0 @@
1
- /**
2
- * PKCE (Proof Key for Code Exchange) utilities for OAuth 2.0
3
- */
4
- import * as crypto from 'crypto';
5
- /**
6
- * Generate PKCE code verifier and challenge
7
- * RFC 7636: https://datatracker.ietf.org/doc/html/rfc7636
8
- */
9
- export function generatePKCE() {
10
- // Generate random code verifier (43-128 characters, URL-safe)
11
- const codeVerifier = crypto.randomBytes(32).toString('base64url');
12
- // Generate code challenge using S256 method
13
- const codeChallenge = crypto
14
- .createHash('sha256')
15
- .update(codeVerifier)
16
- .digest('base64url');
17
- // Generate state for CSRF protection
18
- const state = crypto.randomBytes(16).toString('hex');
19
- return {
20
- codeVerifier,
21
- codeChallenge,
22
- state,
23
- };
24
- }
25
- /**
26
- * Verify that a state matches the expected state
27
- */
28
- export function verifyState(expected, received) {
29
- // Use timing-safe comparison to prevent timing attacks
30
- if (expected.length !== received.length) {
31
- return false;
32
- }
33
- return crypto.timingSafeEqual(Buffer.from(expected), Buffer.from(received));
34
- }
35
- //# sourceMappingURL=pkce.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"pkce.js","sourceRoot":"","sources":["../../src/auth/pkce.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AAGjC;;;GAGG;AACH,MAAM,UAAU,YAAY;IAC1B,8DAA8D;IAC9D,MAAM,YAAY,GAAG,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;IAElE,4CAA4C;IAC5C,MAAM,aAAa,GAAG,MAAM;SACzB,UAAU,CAAC,QAAQ,CAAC;SACpB,MAAM,CAAC,YAAY,CAAC;SACpB,MAAM,CAAC,WAAW,CAAC,CAAC;IAEvB,qCAAqC;IACrC,MAAM,KAAK,GAAG,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAErD,OAAO;QACL,YAAY;QACZ,aAAa;QACb,KAAK;KACN,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,WAAW,CAAC,QAAgB,EAAE,QAAgB;IAC5D,uDAAuD;IACvD,IAAI,QAAQ,CAAC,MAAM,KAAK,QAAQ,CAAC,MAAM,EAAE,CAAC;QACxC,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,MAAM,CAAC,eAAe,CAC3B,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,EACrB,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CACtB,CAAC;AACJ,CAAC"}
@@ -1,52 +0,0 @@
1
- /**
2
- * Secure credential storage for OAuth tokens and API keys
3
- *
4
- * Storage locations:
5
- * - ~/.config/claude-sisyphus/auth/openai.json - OpenAI OAuth tokens
6
- * - ~/.config/claude-sisyphus/auth/google.json - Google OAuth tokens
7
- * - ~/.config/claude-sisyphus/auth/api-keys.enc - Encrypted API keys
8
- */
9
- import type { ProviderType, OAuthTokens } from '../providers/types.js';
10
- import type { StoredCredential } from './types.js';
11
- /**
12
- * Credential storage class
13
- */
14
- export declare class CredentialStorage {
15
- /**
16
- * Store OAuth tokens for a provider
17
- */
18
- storeOAuthTokens(provider: 'openai' | 'google', tokens: OAuthTokens, email?: string): Promise<void>;
19
- /**
20
- * Get OAuth tokens for a provider
21
- */
22
- getOAuthTokens(provider: 'openai' | 'google'): Promise<StoredCredential | null>;
23
- /**
24
- * Store an API key for a provider (encrypted)
25
- */
26
- storeApiKey(provider: 'anthropic' | 'openrouter', apiKey: string): Promise<void>;
27
- /**
28
- * Get an API key for a provider
29
- */
30
- getApiKey(provider: 'anthropic' | 'openrouter'): Promise<StoredCredential | null>;
31
- /**
32
- * Get stored credential for any provider
33
- */
34
- getCredential(provider: ProviderType): Promise<StoredCredential | null>;
35
- /**
36
- * Delete credentials for a provider
37
- */
38
- delete(provider: ProviderType): Promise<void>;
39
- /**
40
- * Check if credentials exist for a provider
41
- */
42
- hasCredentials(provider: ProviderType): Promise<boolean>;
43
- /**
44
- * Get all stored provider credentials (for auth-status)
45
- */
46
- getAllCredentials(): Promise<StoredCredential[]>;
47
- }
48
- /**
49
- * Get the credential storage instance
50
- */
51
- export declare function getCredentialStorage(): CredentialStorage;
52
- //# sourceMappingURL=storage.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../src/auth/storage.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAMH,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AA6EnD;;GAEG;AACH,qBAAa,iBAAiB;IAC5B;;OAEG;IACG,gBAAgB,CACpB,QAAQ,EAAE,QAAQ,GAAG,QAAQ,EAC7B,MAAM,EAAE,WAAW,EACnB,KAAK,CAAC,EAAE,MAAM,GACb,OAAO,CAAC,IAAI,CAAC;IAoBhB;;OAEG;IACG,cAAc,CAAC,QAAQ,EAAE,QAAQ,GAAG,QAAQ,GAAG,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;IAUrF;;OAEG;IACG,WAAW,CAAC,QAAQ,EAAE,WAAW,GAAG,YAAY,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAyBtF;;OAEG;IACG,SAAS,CAAC,QAAQ,EAAE,WAAW,GAAG,YAAY,GAAG,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;IAUvF;;OAEG;IACG,aAAa,CAAC,QAAQ,EAAE,YAAY,GAAG,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;IAQ7E;;OAEG;IACG,MAAM,CAAC,QAAQ,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IA0BnD;;OAEG;IACG,cAAc,CAAC,QAAQ,EAAE,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC;IAK9D;;OAEG;IACG,iBAAiB,IAAI,OAAO,CAAC,gBAAgB,EAAE,CAAC;CAqBvD;AAOD;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,iBAAiB,CAKxD"}
@@ -1,230 +0,0 @@
1
- /**
2
- * Secure credential storage for OAuth tokens and API keys
3
- *
4
- * Storage locations:
5
- * - ~/.config/claude-sisyphus/auth/openai.json - OpenAI OAuth tokens
6
- * - ~/.config/claude-sisyphus/auth/google.json - Google OAuth tokens
7
- * - ~/.config/claude-sisyphus/auth/api-keys.enc - Encrypted API keys
8
- */
9
- import { promises as fs } from 'fs';
10
- import * as path from 'path';
11
- import * as os from 'os';
12
- import * as crypto from 'crypto';
13
- /**
14
- * Base directory for auth storage
15
- */
16
- const AUTH_DIR = path.join(os.homedir(), '.config', 'claude-sisyphus', 'auth');
17
- /**
18
- * Get the path for OAuth token storage
19
- */
20
- function getOAuthPath(provider) {
21
- return path.join(AUTH_DIR, `${provider}.json`);
22
- }
23
- /**
24
- * Get the path for encrypted API keys
25
- */
26
- function getApiKeysPath() {
27
- return path.join(AUTH_DIR, 'api-keys.enc');
28
- }
29
- /**
30
- * Derive encryption key from machine-specific data
31
- * This provides basic protection for stored API keys
32
- */
33
- function deriveEncryptionKey() {
34
- const machineId = `${os.hostname()}-${os.userInfo().username}-${os.homedir()}`;
35
- return crypto.scryptSync(machineId, 'claude-sisyphus-salt', 32);
36
- }
37
- /**
38
- * Encrypt data with AES-256-GCM
39
- */
40
- function encrypt(data) {
41
- const key = deriveEncryptionKey();
42
- const iv = crypto.randomBytes(16);
43
- const cipher = crypto.createCipheriv('aes-256-gcm', key, iv);
44
- let encrypted = cipher.update(data, 'utf8', 'hex');
45
- encrypted += cipher.final('hex');
46
- const authTag = cipher.getAuthTag();
47
- return JSON.stringify({
48
- iv: iv.toString('hex'),
49
- data: encrypted,
50
- tag: authTag.toString('hex'),
51
- });
52
- }
53
- /**
54
- * Decrypt data with AES-256-GCM
55
- */
56
- function decrypt(encryptedData) {
57
- const key = deriveEncryptionKey();
58
- const { iv, data, tag } = JSON.parse(encryptedData);
59
- const decipher = crypto.createDecipheriv('aes-256-gcm', key, Buffer.from(iv, 'hex'));
60
- decipher.setAuthTag(Buffer.from(tag, 'hex'));
61
- let decrypted = decipher.update(data, 'hex', 'utf8');
62
- decrypted += decipher.final('utf8');
63
- return decrypted;
64
- }
65
- /**
66
- * Ensure the auth directory exists with proper permissions
67
- */
68
- async function ensureAuthDir() {
69
- await fs.mkdir(AUTH_DIR, { recursive: true, mode: 0o700 });
70
- }
71
- /**
72
- * Credential storage class
73
- */
74
- export class CredentialStorage {
75
- /**
76
- * Store OAuth tokens for a provider
77
- */
78
- async storeOAuthTokens(provider, tokens, email) {
79
- await ensureAuthDir();
80
- const credential = {
81
- provider,
82
- type: 'oauth',
83
- accessToken: tokens.accessToken,
84
- refreshToken: tokens.refreshToken,
85
- idToken: tokens.idToken,
86
- expiresAt: tokens.expiresAt,
87
- createdAt: Date.now(),
88
- email,
89
- };
90
- const filePath = getOAuthPath(provider);
91
- await fs.writeFile(filePath, JSON.stringify(credential, null, 2), {
92
- mode: 0o600,
93
- });
94
- }
95
- /**
96
- * Get OAuth tokens for a provider
97
- */
98
- async getOAuthTokens(provider) {
99
- try {
100
- const filePath = getOAuthPath(provider);
101
- const content = await fs.readFile(filePath, 'utf-8');
102
- return JSON.parse(content);
103
- }
104
- catch {
105
- return null;
106
- }
107
- }
108
- /**
109
- * Store an API key for a provider (encrypted)
110
- */
111
- async storeApiKey(provider, apiKey) {
112
- await ensureAuthDir();
113
- // Load existing keys
114
- let keys = {};
115
- try {
116
- const content = await fs.readFile(getApiKeysPath(), 'utf-8');
117
- keys = JSON.parse(decrypt(content));
118
- }
119
- catch {
120
- // No existing keys file
121
- }
122
- // Add/update the key
123
- keys[provider] = {
124
- provider,
125
- type: 'api_key',
126
- accessToken: apiKey,
127
- createdAt: Date.now(),
128
- };
129
- // Write encrypted
130
- const encrypted = encrypt(JSON.stringify(keys));
131
- await fs.writeFile(getApiKeysPath(), encrypted, { mode: 0o600 });
132
- }
133
- /**
134
- * Get an API key for a provider
135
- */
136
- async getApiKey(provider) {
137
- try {
138
- const content = await fs.readFile(getApiKeysPath(), 'utf-8');
139
- const keys = JSON.parse(decrypt(content));
140
- return keys[provider] || null;
141
- }
142
- catch {
143
- return null;
144
- }
145
- }
146
- /**
147
- * Get stored credential for any provider
148
- */
149
- async getCredential(provider) {
150
- if (provider === 'openai' || provider === 'google') {
151
- return this.getOAuthTokens(provider);
152
- }
153
- else {
154
- return this.getApiKey(provider);
155
- }
156
- }
157
- /**
158
- * Delete credentials for a provider
159
- */
160
- async delete(provider) {
161
- if (provider === 'openai' || provider === 'google') {
162
- try {
163
- await fs.unlink(getOAuthPath(provider));
164
- }
165
- catch {
166
- // File might not exist
167
- }
168
- }
169
- else {
170
- // Remove from encrypted API keys
171
- try {
172
- const content = await fs.readFile(getApiKeysPath(), 'utf-8');
173
- const keys = JSON.parse(decrypt(content));
174
- delete keys[provider];
175
- if (Object.keys(keys).length === 0) {
176
- await fs.unlink(getApiKeysPath());
177
- }
178
- else {
179
- const encrypted = encrypt(JSON.stringify(keys));
180
- await fs.writeFile(getApiKeysPath(), encrypted, { mode: 0o600 });
181
- }
182
- }
183
- catch {
184
- // File might not exist
185
- }
186
- }
187
- }
188
- /**
189
- * Check if credentials exist for a provider
190
- */
191
- async hasCredentials(provider) {
192
- const credential = await this.getCredential(provider);
193
- return credential !== null;
194
- }
195
- /**
196
- * Get all stored provider credentials (for auth-status)
197
- */
198
- async getAllCredentials() {
199
- const credentials = [];
200
- // Check OAuth providers
201
- for (const provider of ['openai', 'google']) {
202
- const cred = await this.getOAuthTokens(provider);
203
- if (cred) {
204
- credentials.push(cred);
205
- }
206
- }
207
- // Check API key providers
208
- for (const provider of ['anthropic', 'openrouter']) {
209
- const cred = await this.getApiKey(provider);
210
- if (cred) {
211
- credentials.push(cred);
212
- }
213
- }
214
- return credentials;
215
- }
216
- }
217
- /**
218
- * Singleton storage instance
219
- */
220
- let storageInstance = null;
221
- /**
222
- * Get the credential storage instance
223
- */
224
- export function getCredentialStorage() {
225
- if (!storageInstance) {
226
- storageInstance = new CredentialStorage();
227
- }
228
- return storageInstance;
229
- }
230
- //# sourceMappingURL=storage.js.map