berget 2.1.2 → 2.2.1
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/.github/workflows/publish.yml +20 -6
- package/dist/index.js +2 -1
- package/dist/package.json +1 -1
- package/dist/src/client.js +22 -6
- package/dist/src/commands/code.js +33 -427
- package/dist/src/services/auth-service.js +280 -113
- package/dist/src/utils/token-manager.js +11 -6
- package/index.ts +3 -2
- package/package.json +1 -1
- package/src/client.ts +29 -9
- package/src/commands/code.ts +33 -519
- package/src/services/auth-service.ts +318 -187
- package/src/utils/token-manager.ts +13 -7
- package/dist/src/schemas/opencode-schema.json +0 -1121
- package/dist/src/services/registration-service.js +0 -163
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
name: Publish to NPM
|
|
2
2
|
|
|
3
3
|
on:
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
workflow_dispatch:
|
|
5
|
+
inputs:
|
|
6
|
+
bump:
|
|
7
|
+
description: 'Version bump type'
|
|
8
|
+
required: true
|
|
9
|
+
type: choice
|
|
10
|
+
options:
|
|
11
|
+
- patch
|
|
12
|
+
- minor
|
|
13
|
+
- major
|
|
9
14
|
|
|
10
15
|
jobs:
|
|
11
16
|
test:
|
|
@@ -32,10 +37,12 @@ jobs:
|
|
|
32
37
|
publish:
|
|
33
38
|
needs: test
|
|
34
39
|
runs-on: ubuntu-latest
|
|
35
|
-
if: github.ref == 'refs/heads/main' || github.event_name == 'release'
|
|
36
40
|
steps:
|
|
37
41
|
- name: Checkout code
|
|
38
42
|
uses: actions/checkout@v4
|
|
43
|
+
with:
|
|
44
|
+
fetch-depth: 0
|
|
45
|
+
ref: main
|
|
39
46
|
|
|
40
47
|
- name: Setup Node.js
|
|
41
48
|
uses: actions/setup-node@v4
|
|
@@ -50,6 +57,13 @@ jobs:
|
|
|
50
57
|
- name: Build project
|
|
51
58
|
run: npm run build
|
|
52
59
|
|
|
60
|
+
- name: Bump version
|
|
61
|
+
run: |
|
|
62
|
+
git config user.name "github-actions[bot]"
|
|
63
|
+
git config user.email "github-actions[bot]@users.noreply.github.com"
|
|
64
|
+
npm version ${{ inputs.bump }} -m "release: %s"
|
|
65
|
+
git push --follow-tags
|
|
66
|
+
|
|
53
67
|
- name: Publish to NPM
|
|
54
68
|
run: npm publish
|
|
55
69
|
env:
|
package/dist/index.js
CHANGED
|
@@ -24,7 +24,8 @@ commander_1.program
|
|
|
24
24
|
|___/ AI on European terms
|
|
25
25
|
Version: ${package_json_1.version}`)
|
|
26
26
|
.version(package_json_1.version, '-v, --version')
|
|
27
|
-
.
|
|
27
|
+
.addOption(new commander_1.Option('--local').default(false).hideHelp())
|
|
28
|
+
.addOption(new commander_1.Option('--stage').default(false).hideHelp())
|
|
28
29
|
.option('--debug', 'Enable debug output', false);
|
|
29
30
|
// Register all commands
|
|
30
31
|
(0, commands_1.registerCommands)(commander_1.program);
|
package/dist/package.json
CHANGED
package/dist/src/client.js
CHANGED
|
@@ -19,12 +19,19 @@ const token_manager_1 = require("./utils/token-manager");
|
|
|
19
19
|
const logger_1 = require("./utils/logger");
|
|
20
20
|
// API Base URL
|
|
21
21
|
// Use --local flag to test against local API
|
|
22
|
+
// Use --stage flag to test against stage API
|
|
22
23
|
const isLocalMode = process.argv.includes('--local');
|
|
24
|
+
const isStageMode = process.argv.includes('--stage');
|
|
23
25
|
exports.API_BASE_URL = process.env.BERGET_API_URL ||
|
|
24
|
-
(isLocalMode ? 'http://localhost:3000' :
|
|
26
|
+
(isLocalMode ? 'http://localhost:3000' :
|
|
27
|
+
isStageMode ? 'https://api.stage.berget.ai' :
|
|
28
|
+
'https://api.berget.ai'); // production default
|
|
25
29
|
if (isLocalMode && !process.env.BERGET_API_URL) {
|
|
26
30
|
logger_1.logger.debug('Using local API endpoint: http://localhost:3000');
|
|
27
31
|
}
|
|
32
|
+
else if (isStageMode && !process.env.BERGET_API_URL) {
|
|
33
|
+
logger_1.logger.debug('Using stage API endpoint: https://api.stage.berget.ai');
|
|
34
|
+
}
|
|
28
35
|
// Create a typed client for the Berget API
|
|
29
36
|
exports.apiClient = (0, openapi_fetch_1.default)({
|
|
30
37
|
baseUrl: exports.API_BASE_URL,
|
|
@@ -177,6 +184,12 @@ const createAuthenticatedClient = () => {
|
|
|
177
184
|
});
|
|
178
185
|
};
|
|
179
186
|
exports.createAuthenticatedClient = createAuthenticatedClient;
|
|
187
|
+
// Keycloak configuration for token refresh (must match auth-service.ts)
|
|
188
|
+
const KEYCLOAK_URL = (isStageMode || isLocalMode)
|
|
189
|
+
? 'https://keycloak.stage.berget.ai'
|
|
190
|
+
: 'https://keycloak.berget.ai';
|
|
191
|
+
const KEYCLOAK_REALM = 'berget';
|
|
192
|
+
const KEYCLOAK_CLIENT_ID = 'berget-code';
|
|
180
193
|
// Helper function to refresh the access token
|
|
181
194
|
function refreshAccessToken(tokenManager) {
|
|
182
195
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -185,15 +198,18 @@ function refreshAccessToken(tokenManager) {
|
|
|
185
198
|
if (!refreshToken)
|
|
186
199
|
return false;
|
|
187
200
|
logger_1.logger.debug('Attempting to refresh access token');
|
|
188
|
-
//
|
|
201
|
+
// Refresh directly against Keycloak (berget-code is a public PKCE client)
|
|
189
202
|
try {
|
|
190
|
-
const response = yield fetch(`${
|
|
203
|
+
const response = yield fetch(`${KEYCLOAK_URL}/realms/${KEYCLOAK_REALM}/protocol/openid-connect/token`, {
|
|
191
204
|
method: 'POST',
|
|
192
205
|
headers: {
|
|
193
|
-
'Content-Type': 'application/
|
|
194
|
-
Accept: 'application/json',
|
|
206
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
195
207
|
},
|
|
196
|
-
body:
|
|
208
|
+
body: new URLSearchParams({
|
|
209
|
+
grant_type: 'refresh_token',
|
|
210
|
+
client_id: KEYCLOAK_CLIENT_ID,
|
|
211
|
+
refresh_token: refreshToken,
|
|
212
|
+
}),
|
|
197
213
|
});
|
|
198
214
|
// Handle HTTP errors
|
|
199
215
|
if (!response.ok) {
|