@cereworker/cerebrum 26.325.33 → 26.325.34
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/oauth/pi-auth.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* Converts pi-ai credential format to CereWorker OAuthTokens.
|
|
2
|
+
* OAuth login wrappers for OpenAI and Google.
|
|
4
3
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* OpenAI: Uses CereWorker's own PKCE flow with the correct scopes
|
|
5
|
+
* (including api.responses.write for GPT-5.4 Responses API).
|
|
6
|
+
*
|
|
7
|
+
* Google: Falls back to @mariozechner/pi-ai for Gemini CLI OAuth.
|
|
7
8
|
*/
|
|
8
|
-
import type
|
|
9
|
+
import { type OAuthTokens } from './types.js';
|
|
9
10
|
export interface PiAuthCallbacks {
|
|
10
11
|
onAuth: (url: string, instructions?: string) => void;
|
|
11
12
|
onPrompt?: (message: string) => Promise<string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pi-auth.d.ts","sourceRoot":"","sources":["../../src/oauth/pi-auth.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"pi-auth.d.ts","sourceRoot":"","sources":["../../src/oauth/pi-auth.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAmB,KAAK,WAAW,EAAE,MAAM,YAAY,CAAC;AA4B/D,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACrD,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IAChD,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,iBAAiB,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;CAC3C;AAED,wBAAsB,WAAW,CAAC,SAAS,EAAE,eAAe,GAAG,OAAO,CAAC,WAAW,CAAC,CAKlF;AAED,wBAAsB,WAAW,CAAC,SAAS,EAAE,eAAe,GAAG,OAAO,CAAC,WAAW,CAAC,CAQlF;AAED,wBAAsB,kBAAkB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAsBnF;AAED,wBAAsB,kBAAkB,CACtC,YAAY,EAAE,MAAM,EACpB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,WAAW,CAAC,CAGtB"}
|
package/dist/oauth/pi-auth.js
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OAuth login wrappers for OpenAI and Google.
|
|
3
|
+
*
|
|
4
|
+
* OpenAI: Uses CereWorker's own PKCE flow with the correct scopes
|
|
5
|
+
* (including api.responses.write for GPT-5.4 Responses API).
|
|
6
|
+
*
|
|
7
|
+
* Google: Falls back to @mariozechner/pi-ai for Gemini CLI OAuth.
|
|
8
|
+
*/
|
|
9
|
+
import { OAUTH_PROVIDERS } from './types.js';
|
|
10
|
+
import { runOAuthFlow } from './flow.js';
|
|
1
11
|
function toTokens(creds) {
|
|
2
12
|
return {
|
|
3
13
|
accessToken: creds.access,
|
|
@@ -9,7 +19,7 @@ function toTokens(creds) {
|
|
|
9
19
|
};
|
|
10
20
|
}
|
|
11
21
|
const PI_AI_MODULE = '@mariozechner/pi-ai/oauth';
|
|
12
|
-
const INSTALL_HINT = 'OAuth requires @mariozechner/pi-ai. Install it:\n npm install -g @mariozechner/pi-ai';
|
|
22
|
+
const INSTALL_HINT = 'Google OAuth requires @mariozechner/pi-ai. Install it:\n npm install -g @mariozechner/pi-ai';
|
|
13
23
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
14
24
|
async function loadPiAuth() {
|
|
15
25
|
try {
|
|
@@ -20,18 +30,10 @@ async function loadPiAuth() {
|
|
|
20
30
|
}
|
|
21
31
|
}
|
|
22
32
|
export async function loginOpenAI(callbacks) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
onPrompt: async (prompt) => {
|
|
27
|
-
if (!callbacks.onPrompt)
|
|
28
|
-
throw new Error('Manual input required but no prompt handler');
|
|
29
|
-
return callbacks.onPrompt(prompt.message);
|
|
30
|
-
},
|
|
31
|
-
onProgress: callbacks.onProgress,
|
|
32
|
-
onManualCodeInput: callbacks.onManualCodeInput,
|
|
33
|
+
// Use CereWorker's own PKCE flow with correct scopes (api.responses.write)
|
|
34
|
+
return runOAuthFlow('openai', {
|
|
35
|
+
onReady: (url) => callbacks.onAuth(url),
|
|
33
36
|
});
|
|
34
|
-
return toTokens(creds);
|
|
35
37
|
}
|
|
36
38
|
export async function loginGoogle(callbacks) {
|
|
37
39
|
const { loginGeminiCli } = await loadPiAuth();
|
|
@@ -39,8 +41,27 @@ export async function loginGoogle(callbacks) {
|
|
|
39
41
|
return toTokens(creds);
|
|
40
42
|
}
|
|
41
43
|
export async function refreshOpenAIToken(refreshToken) {
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
+
const config = OAUTH_PROVIDERS.openai;
|
|
45
|
+
const res = await fetch(config.tokenUrl, {
|
|
46
|
+
method: 'POST',
|
|
47
|
+
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
|
48
|
+
body: new URLSearchParams({
|
|
49
|
+
grant_type: 'refresh_token',
|
|
50
|
+
refresh_token: refreshToken,
|
|
51
|
+
client_id: config.clientId,
|
|
52
|
+
}),
|
|
53
|
+
});
|
|
54
|
+
if (!res.ok) {
|
|
55
|
+
const body = await res.text();
|
|
56
|
+
throw new Error(`Token refresh failed: ${res.status} ${body}`);
|
|
57
|
+
}
|
|
58
|
+
const data = (await res.json());
|
|
59
|
+
return {
|
|
60
|
+
accessToken: data.access_token,
|
|
61
|
+
refreshToken: data.refresh_token ?? refreshToken,
|
|
62
|
+
expiresAt: Date.now() + (data.expires_in ?? 3600) * 1000,
|
|
63
|
+
tokenType: data.token_type ?? 'bearer',
|
|
64
|
+
};
|
|
44
65
|
}
|
|
45
66
|
export async function refreshGoogleToken(refreshToken, projectId) {
|
|
46
67
|
const { refreshGoogleCloudToken } = await loadPiAuth();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pi-auth.js","sourceRoot":"","sources":["../../src/oauth/pi-auth.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pi-auth.js","sourceRoot":"","sources":["../../src/oauth/pi-auth.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,eAAe,EAAoB,MAAM,YAAY,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAIzC,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO;QACL,WAAW,EAAE,KAAK,CAAC,MAAM;QACzB,YAAY,EAAE,KAAK,CAAC,OAAO;QAC3B,SAAS,EAAE,KAAK,CAAC,OAAO;QACxB,SAAS,EAAE,QAAQ;QACnB,KAAK,EAAE,KAAK,CAAC,KAA2B;QACxC,SAAS,EAAE,KAAK,CAAC,SAA+B;KACjD,CAAC;AACJ,CAAC;AAED,MAAM,YAAY,GAAG,2BAA2B,CAAC;AACjD,MAAM,YAAY,GAAG,8FAA8F,CAAC;AAEpH,8DAA8D;AAC9D,KAAK,UAAU,UAAU;IACvB,IAAI,CAAC;QACH,OAAO,MAAM,MAAM,CAAC,YAAY,CAAC,CAAC;IACpC,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC;IAChC,CAAC;AACH,CAAC;AASD,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,SAA0B;IAC1D,2EAA2E;IAC3E,OAAO,YAAY,CAAC,QAAQ,EAAE;QAC5B,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC;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IAAI,CAAC,UAAqB,IAAI,IAAI,CAAC,GAAG,IAAI;QACpE,SAAS,EAAG,IAAI,CAAC,UAAqB,IAAI,QAAQ;KACnD,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,YAAoB,EACpB,SAAiB;IAEjB,MAAM,EAAE,uBAAuB,EAAE,GAAG,MAAM,UAAU,EAAE,CAAC;IACvD,OAAO,QAAQ,CAAC,MAAM,uBAAuB,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC,CAAC;AAC1E,CAAC"}
|
package/dist/oauth/types.js
CHANGED
|
@@ -4,12 +4,12 @@
|
|
|
4
4
|
*/
|
|
5
5
|
export const OAUTH_PROVIDERS = {
|
|
6
6
|
openai: {
|
|
7
|
-
authorizationUrl: 'https://
|
|
8
|
-
tokenUrl: 'https://
|
|
9
|
-
clientId: '',
|
|
10
|
-
scopes: ['
|
|
11
|
-
callbackPort:
|
|
12
|
-
callbackPath: '/callback',
|
|
7
|
+
authorizationUrl: 'https://auth.openai.com/oauth/authorize',
|
|
8
|
+
tokenUrl: 'https://auth.openai.com/oauth/token',
|
|
9
|
+
clientId: 'app_EGHCdX7rkVuFnqAqtCp6L',
|
|
10
|
+
scopes: ['openid', 'profile', 'email', 'offline_access', 'api.responses.write'],
|
|
11
|
+
callbackPort: 1455,
|
|
12
|
+
callbackPath: '/auth/callback',
|
|
13
13
|
},
|
|
14
14
|
google: {
|
|
15
15
|
authorizationUrl: 'https://accounts.google.com/o/oauth2/v2/auth',
|
package/dist/oauth/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/oauth/types.ts"],"names":[],"mappings":"AAsBA;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAwC;IAClE,MAAM,EAAE;QACN,gBAAgB,EAAE,
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/oauth/types.ts"],"names":[],"mappings":"AAsBA;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAwC;IAClE,MAAM,EAAE;QACN,gBAAgB,EAAE,yCAAyC;QAC3D,QAAQ,EAAE,qCAAqC;QAC/C,QAAQ,EAAE,2BAA2B;QACrC,MAAM,EAAE,CAAC,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,CAAC;QAC/E,YAAY,EAAE,IAAI;QAClB,YAAY,EAAE,gBAAgB;KAC/B;IACD,MAAM,EAAE;QACN,gBAAgB,EAAE,8CAA8C;QAChE,QAAQ,EAAE,qCAAqC;QAC/C,QAAQ,EAAE,EAAE;QACZ,aAAa,EAAE,2CAA2C;QAC1D,MAAM,EAAE;YACN,gDAAgD;YAChD,gDAAgD;YAChD,kDAAkD;SACnD;QACD,YAAY,EAAE,KAAK;QACnB,YAAY,EAAE,WAAW;KAC1B;CACF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cereworker/cerebrum",
|
|
3
|
-
"version": "26.325.
|
|
3
|
+
"version": "26.325.34",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
"@ai-sdk/openai": "^3.0.47",
|
|
22
22
|
"ai": "^6.0.134",
|
|
23
23
|
"zod": "^3.24.0",
|
|
24
|
-
"@cereworker/config": "26.325.
|
|
25
|
-
"@cereworker/core": "26.325.
|
|
24
|
+
"@cereworker/config": "26.325.34",
|
|
25
|
+
"@cereworker/core": "26.325.34"
|
|
26
26
|
},
|
|
27
27
|
"optionalDependencies": {
|
|
28
28
|
"@mariozechner/pi-ai": "*"
|