berget 2.1.1 → 2.1.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.
- package/dist/package.json +1 -1
- package/dist/src/commands/code.js +3 -2
- package/dist/src/services/api-key-service.js +7 -4
- package/dist/src/services/auth-service.js +3 -0
- package/dist/src/services/registration-service.js +163 -0
- package/opencode.json +5 -1
- package/package.json +1 -1
- package/src/commands/code.ts +3 -2
- package/src/services/api-key-service.ts +6 -0
- package/src/services/auth-service.ts +4 -0
package/dist/package.json
CHANGED
|
@@ -717,12 +717,13 @@ function registerCodeCommands(program) {
|
|
|
717
717
|
models: {
|
|
718
718
|
'glm-4.7': {
|
|
719
719
|
name: 'GLM-4.7',
|
|
720
|
-
limit: { output: 4000, context:
|
|
720
|
+
limit: { output: 4000, context: 200000 },
|
|
721
|
+
modalities: { input: ['text'], output: ['text'] },
|
|
721
722
|
},
|
|
722
723
|
'gpt-oss': {
|
|
723
724
|
name: 'GPT-OSS',
|
|
724
725
|
limit: { output: 4000, context: 128000 },
|
|
725
|
-
modalities: ['text', 'image'],
|
|
726
|
+
modalities: { input: ['text', 'image'], output: ['text'] },
|
|
726
727
|
},
|
|
727
728
|
'llama-8b': {
|
|
728
729
|
name: 'llama-3.1-8b',
|
|
@@ -50,7 +50,7 @@ class ApiKeyService {
|
|
|
50
50
|
* Command: berget api-keys create
|
|
51
51
|
*/
|
|
52
52
|
create(options) {
|
|
53
|
-
var _a, _b, _c, _d;
|
|
53
|
+
var _a, _b, _c, _d, _e;
|
|
54
54
|
return __awaiter(this, void 0, void 0, function* () {
|
|
55
55
|
try {
|
|
56
56
|
// Validate input before sending request
|
|
@@ -89,13 +89,16 @@ class ApiKeyService {
|
|
|
89
89
|
detailedMessage += '5. Contact support if the problem persists';
|
|
90
90
|
throw new Error(detailedMessage);
|
|
91
91
|
}
|
|
92
|
-
if (((_b = errorObj.error) === null || _b === void 0 ? void 0 : _b.code) === '
|
|
92
|
+
if (((_b = errorObj.error) === null || _b === void 0 ? void 0 : _b.code) === 'USER_NOT_FOUND') {
|
|
93
|
+
throw new Error('Your account is still being set up. Please wait a moment and try again.\n\nIf this issue persists, please contact support at support@berget.ai');
|
|
94
|
+
}
|
|
95
|
+
if (((_c = errorObj.error) === null || _c === void 0 ? void 0 : _c.code) === 'QUOTA_EXCEEDED') {
|
|
93
96
|
throw new Error('You have reached your API key limit. Please delete existing keys or contact support to increase your quota.');
|
|
94
97
|
}
|
|
95
|
-
if (((
|
|
98
|
+
if (((_d = errorObj.error) === null || _d === void 0 ? void 0 : _d.code) === 'INSUFFICIENT_PERMISSIONS') {
|
|
96
99
|
throw new Error('Your account does not have permission to create API keys. Please contact your administrator.');
|
|
97
100
|
}
|
|
98
|
-
if (((
|
|
101
|
+
if (((_e = errorObj.error) === null || _e === void 0 ? void 0 : _e.code) === 'BILLING_REQUIRED') {
|
|
99
102
|
throw new Error('A valid billing method is required to create API keys. Please add a payment method.');
|
|
100
103
|
}
|
|
101
104
|
}
|
|
@@ -186,6 +186,9 @@ class AuthService {
|
|
|
186
186
|
const user = typedTokenData.user;
|
|
187
187
|
console.log(chalk_1.default.green(`Logged in as ${user.name || user.email || 'User'}`));
|
|
188
188
|
}
|
|
189
|
+
console.log(chalk_1.default.cyan('\nNext steps:'));
|
|
190
|
+
console.log(chalk_1.default.cyan(' • Create an API key: berget api-keys create'));
|
|
191
|
+
console.log(chalk_1.default.cyan(' • Setup OpenCode: berget code init'));
|
|
189
192
|
return true;
|
|
190
193
|
}
|
|
191
194
|
}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
|
+
};
|
|
37
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
+
exports.RegistrationService = void 0;
|
|
39
|
+
const client_1 = require("../client");
|
|
40
|
+
const error_handler_1 = require("../utils/error-handler");
|
|
41
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
42
|
+
const readline = __importStar(require("readline"));
|
|
43
|
+
/**
|
|
44
|
+
* Service for handling user registration and account completion
|
|
45
|
+
*/
|
|
46
|
+
class RegistrationService {
|
|
47
|
+
constructor() {
|
|
48
|
+
this.client = (0, client_1.createAuthenticatedClient)();
|
|
49
|
+
}
|
|
50
|
+
static getInstance() {
|
|
51
|
+
if (!RegistrationService.instance) {
|
|
52
|
+
RegistrationService.instance = new RegistrationService();
|
|
53
|
+
}
|
|
54
|
+
return RegistrationService.instance;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Check authentication status to see if user has completed registration
|
|
58
|
+
*/
|
|
59
|
+
checkAuthStatus() {
|
|
60
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
61
|
+
try {
|
|
62
|
+
const { data, error } = yield this.client.GET('/v1/auth/status');
|
|
63
|
+
if (error)
|
|
64
|
+
throw error;
|
|
65
|
+
return data;
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
(0, error_handler_1.handleError)('Failed to check authentication status', error);
|
|
69
|
+
throw error;
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Complete registration for a new user
|
|
75
|
+
*/
|
|
76
|
+
completeRegistration(request) {
|
|
77
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
78
|
+
try {
|
|
79
|
+
const { data, error } = yield this.client.POST('/v1/users/me/complete-registration', {
|
|
80
|
+
body: request,
|
|
81
|
+
});
|
|
82
|
+
if (error) {
|
|
83
|
+
throw new Error(JSON.stringify(error));
|
|
84
|
+
}
|
|
85
|
+
return data;
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
console.error('Failed to complete registration:', error);
|
|
89
|
+
throw error;
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Check if registration is needed based on auth status
|
|
95
|
+
*/
|
|
96
|
+
isRegistrationNeeded() {
|
|
97
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
98
|
+
try {
|
|
99
|
+
const status = yield this.checkAuthStatus();
|
|
100
|
+
return !status.hasOdooAccount;
|
|
101
|
+
}
|
|
102
|
+
catch (error) {
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Prompt user for registration information
|
|
109
|
+
*/
|
|
110
|
+
collectRegistrationInfo() {
|
|
111
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
112
|
+
const rl = readline.createInterface({
|
|
113
|
+
input: process.stdin,
|
|
114
|
+
output: process.stdout,
|
|
115
|
+
});
|
|
116
|
+
const question = (prompt) => {
|
|
117
|
+
return new Promise((resolve) => {
|
|
118
|
+
rl.question(prompt, (answer) => {
|
|
119
|
+
resolve(answer.trim());
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
};
|
|
123
|
+
console.log(chalk_1.default.cyan('\n📝 Complete your registration\n'));
|
|
124
|
+
console.log(chalk_1.default.dim('─'.repeat(50)));
|
|
125
|
+
const companyName = yield question(chalk_1.default.blue('Company name: '));
|
|
126
|
+
const companyEmail = yield question(chalk_1.default.blue('Company email: '));
|
|
127
|
+
const vatNumber = yield question(chalk_1.default.blue('VAT number (optional): '));
|
|
128
|
+
console.log(chalk_1.default.cyan('\n📋 Plan Selection'));
|
|
129
|
+
console.log(chalk_1.default.dim('─'.repeat(50)));
|
|
130
|
+
console.log(chalk_1.default.yellow('You will start with a trial plan (ID: 142). To add a credit card,'));
|
|
131
|
+
console.log(chalk_1.default.yellow('please visit https://console.berget.ai\n'));
|
|
132
|
+
const marketingConsent = yield question(chalk_1.default.blue('Subscribe to marketing emails? (Y/n): '));
|
|
133
|
+
console.log(chalk_1.default.cyan('\n📄 Terms of Service'));
|
|
134
|
+
console.log(chalk_1.default.dim('─'.repeat(50)));
|
|
135
|
+
console.log(chalk_1.default.cyan('Please review our terms:'));
|
|
136
|
+
console.log(chalk_1.default.dim(' • https://berget.ai/terms'));
|
|
137
|
+
console.log(chalk_1.default.dim(' • https://berget.ai/acceptable-use'));
|
|
138
|
+
console.log(chalk_1.default.dim(' • https://berget.ai/dpa\n'));
|
|
139
|
+
const termsAccepted = yield question(chalk_1.default.blue('Do you accept the terms? (Y/n): '));
|
|
140
|
+
rl.close();
|
|
141
|
+
return {
|
|
142
|
+
company: {
|
|
143
|
+
name: companyName,
|
|
144
|
+
email: companyEmail,
|
|
145
|
+
vatNumber: vatNumber || '',
|
|
146
|
+
},
|
|
147
|
+
plans: [
|
|
148
|
+
{
|
|
149
|
+
id: '142',
|
|
150
|
+
quantity: 1,
|
|
151
|
+
},
|
|
152
|
+
],
|
|
153
|
+
paymentMethodId: '',
|
|
154
|
+
stripeCustomerId: '',
|
|
155
|
+
marketingConsent: marketingConsent.toLowerCase() !== 'n' &&
|
|
156
|
+
marketingConsent.toLowerCase() !== 'no',
|
|
157
|
+
termsAccepted: termsAccepted.toLowerCase() !== 'n' &&
|
|
158
|
+
termsAccepted.toLowerCase() !== 'no',
|
|
159
|
+
};
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
exports.RegistrationService = RegistrationService;
|
package/opencode.json
CHANGED
package/package.json
CHANGED
package/src/commands/code.ts
CHANGED
|
@@ -835,12 +835,13 @@ export function registerCodeCommands(program: Command): void {
|
|
|
835
835
|
models: {
|
|
836
836
|
'glm-4.7': {
|
|
837
837
|
name: 'GLM-4.7',
|
|
838
|
-
limit: { output: 4000, context:
|
|
838
|
+
limit: { output: 4000, context: 200000 },
|
|
839
|
+
modalities: { input: ['text'], output: ['text'] },
|
|
839
840
|
},
|
|
840
841
|
'gpt-oss': {
|
|
841
842
|
name: 'GPT-OSS',
|
|
842
843
|
limit: { output: 4000, context: 128000 },
|
|
843
|
-
modalities: ['text', 'image'],
|
|
844
|
+
modalities: { input: ['text', 'image'], output: ['text'] },
|
|
844
845
|
},
|
|
845
846
|
'llama-8b': {
|
|
846
847
|
name: 'llama-3.1-8b',
|
|
@@ -115,6 +115,12 @@ export class ApiKeyService {
|
|
|
115
115
|
throw new Error(detailedMessage)
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
+
if (errorObj.error?.code === 'USER_NOT_FOUND') {
|
|
119
|
+
throw new Error(
|
|
120
|
+
'Your account is still being set up. Please wait a moment and try again.\n\nIf this issue persists, please contact support at support@berget.ai',
|
|
121
|
+
)
|
|
122
|
+
}
|
|
123
|
+
|
|
118
124
|
if (errorObj.error?.code === 'QUOTA_EXCEEDED') {
|
|
119
125
|
throw new Error(
|
|
120
126
|
'You have reached your API key limit. Please delete existing keys or contact support to increase your quota.',
|
|
@@ -247,6 +247,10 @@ export class AuthService {
|
|
|
247
247
|
)
|
|
248
248
|
}
|
|
249
249
|
|
|
250
|
+
console.log(chalk.cyan('\nNext steps:'))
|
|
251
|
+
console.log(chalk.cyan(' • Create an API key: berget api-keys create'))
|
|
252
|
+
console.log(chalk.cyan(' • Setup OpenCode: berget code init'))
|
|
253
|
+
|
|
250
254
|
return true
|
|
251
255
|
}
|
|
252
256
|
}
|