bkper 4.18.4 → 4.20.0
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/README.md +7 -3
- package/lib/agent/auth-commands.d.ts +34 -0
- package/lib/agent/auth-commands.d.ts.map +1 -0
- package/lib/agent/auth-commands.js +389 -0
- package/lib/agent/auth-commands.js.map +1 -0
- package/lib/agent/bkper-ai-provider.d.ts +9 -0
- package/lib/agent/bkper-ai-provider.d.ts.map +1 -0
- package/lib/agent/bkper-ai-provider.js +148 -0
- package/lib/agent/bkper-ai-provider.js.map +1 -0
- package/lib/agent/run-agent-mode.d.ts +7 -2
- package/lib/agent/run-agent-mode.d.ts.map +1 -1
- package/lib/agent/run-agent-mode.js +98 -14
- package/lib/agent/run-agent-mode.js.map +1 -1
- package/lib/auth/local-auth-service.d.ts +23 -4
- package/lib/auth/local-auth-service.d.ts.map +1 -1
- package/lib/auth/local-auth-service.js +97 -27
- package/lib/auth/local-auth-service.js.map +1 -1
- package/lib/cli.js +2 -0
- package/lib/cli.js.map +1 -1
- package/lib/commands/events/index.d.ts +3 -0
- package/lib/commands/events/index.d.ts.map +1 -0
- package/lib/commands/events/index.js +3 -0
- package/lib/commands/events/index.js.map +1 -0
- package/lib/commands/events/list.d.ts +36 -0
- package/lib/commands/events/list.d.ts.map +1 -0
- package/lib/commands/events/list.js +160 -0
- package/lib/commands/events/list.js.map +1 -0
- package/lib/commands/events/register.d.ts +8 -0
- package/lib/commands/events/register.d.ts.map +1 -0
- package/lib/commands/events/register.js +66 -0
- package/lib/commands/events/register.js.map +1 -0
- package/lib/commands/events/replay.d.ts +11 -0
- package/lib/commands/events/replay.d.ts.map +1 -0
- package/lib/commands/events/replay.js +30 -0
- package/lib/commands/events/replay.js.map +1 -0
- package/lib/docs/cli/app-management.md +6 -1
- package/lib/docs/cli/data-management.md +44 -1
- package/lib/docs/sdk/bkper-api-types.md +5 -2
- package/lib/docs/sdk/bkper-js.md +40 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -16,6 +16,7 @@ With one tool, you can work with Bkper from your terminal, built-in agent, or ex
|
|
|
16
16
|
### Prerequisites
|
|
17
17
|
|
|
18
18
|
- [Node.js](https://nodejs.org/) >= 22.19.0
|
|
19
|
+
- **Windows:** use [WSL](https://learn.microsoft.com/en-us/windows/wsl/install) — the agent relies on Linux tooling that doesn't work reliably in PowerShell
|
|
19
20
|
|
|
20
21
|
### Install (choose one)
|
|
21
22
|
|
|
@@ -57,9 +58,11 @@ Run `bkper` to open the built-in Bkper Agent in your terminal.
|
|
|
57
58
|
|
|
58
59
|

|
|
59
60
|
|
|
60
|
-
|
|
61
|
+
`bkper auth login` and `/login` inside the agent both connect to your Bkper account and enable the included Bkper AI models. Both flows show which account email is authenticated.
|
|
61
62
|
|
|
62
|
-
|
|
63
|
+
To use another model provider, type `/connect` and choose a subscription or API-key provider. You can also target one directly, such as `/connect openai` or `/connect anthropic`. Use `/disconnect` for external providers; `/logout` signs out of Bkper.
|
|
64
|
+
|
|
65
|
+
For external frontier models, an existing [ChatGPT Plus/Pro subscription](https://chatgpt.com/pricing/) with Codex works very well. [Claude subscriptions](https://claude.com/pricing) are also supported if Claude is your preferred frontier model. For open-weights models, [OpenCode Go](https://opencode.ai/go) is a great option.
|
|
63
66
|
|
|
64
67
|
### Safe starting prompts:
|
|
65
68
|
|
|
@@ -164,13 +167,14 @@ bkper agent --help
|
|
|
164
167
|
|
|
165
168
|
## Data Management
|
|
166
169
|
|
|
167
|
-
Manage books, files, accounts, transactions, and balances.
|
|
170
|
+
Manage books, files, accounts, transactions, events, and balances.
|
|
168
171
|
|
|
169
172
|
```bash
|
|
170
173
|
bkper book list
|
|
171
174
|
bkper account list -b <bookId>
|
|
172
175
|
bkper file list -b <bookId> --limit 100
|
|
173
176
|
bkper transaction list -b <bookId> -q 'on:2026' --format csv
|
|
177
|
+
bkper event list -b <bookId> --error --json
|
|
174
178
|
bkper balance list -b <bookId> -q 'on:2026-12-31' --format csv
|
|
175
179
|
```
|
|
176
180
|
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { type ExtensionAPI, type ProviderConfig } from '@earendil-works/pi-coding-agent';
|
|
2
|
+
import { type BkperAuthenticationResult, type BkperLogoutResult, type OAuthInteractionOptions } from '../auth/local-auth-service.js';
|
|
3
|
+
export declare const BKPER_AGENT_LOGIN_COMMAND = "bkper-agent-login";
|
|
4
|
+
export declare const BKPER_AGENT_LOGOUT_COMMAND = "bkper-agent-logout";
|
|
5
|
+
export declare const BKPER_AGENT_DISCONNECT_COMMAND = "bkper-agent-disconnect";
|
|
6
|
+
interface AuthCommandEditor {
|
|
7
|
+
onSubmit?: (text: string) => void | Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
interface ProviderRegistry {
|
|
10
|
+
unregisterProvider(name: string): void;
|
|
11
|
+
registerProvider(name: string, config: ProviderConfig): void;
|
|
12
|
+
}
|
|
13
|
+
interface ModelLike {
|
|
14
|
+
provider: string;
|
|
15
|
+
id: string;
|
|
16
|
+
}
|
|
17
|
+
export declare function installBkperAuthCommandRouting(editor: AuthCommandEditor, modelRegistry: ProviderRegistry): void;
|
|
18
|
+
export declare function findStoredProvider(providerRef: string, storedProviders: string[], getDisplayName: (provider: string) => string): string | undefined;
|
|
19
|
+
export declare function selectAuthFallbackModel<TModel extends ModelLike>(availableModels: TModel[], bkperLoggedIn: boolean, excludedProvider?: string): TModel | undefined;
|
|
20
|
+
export interface BkperAuthCommandDependencies {
|
|
21
|
+
authenticateBkper(options?: OAuthInteractionOptions): Promise<BkperAuthenticationResult>;
|
|
22
|
+
logoutBkper(): Promise<BkperLogoutResult>;
|
|
23
|
+
isBkperLoggedIn(): boolean;
|
|
24
|
+
openBrowser(url: string): void;
|
|
25
|
+
}
|
|
26
|
+
export interface ProviderCredentialManager {
|
|
27
|
+
listCredentials(): Promise<readonly {
|
|
28
|
+
providerId: string;
|
|
29
|
+
}[]>;
|
|
30
|
+
logout(providerId: string): Promise<void>;
|
|
31
|
+
}
|
|
32
|
+
export declare function registerBkperAgentAuthExtension(pi: ExtensionAPI, dependencies?: BkperAuthCommandDependencies, credentialManager?: ProviderCredentialManager): void;
|
|
33
|
+
export {};
|
|
34
|
+
//# sourceMappingURL=auth-commands.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-commands.d.ts","sourceRoot":"","sources":["../../src/agent/auth-commands.ts"],"names":[],"mappings":"AACA,OAAO,EAEH,KAAK,YAAY,EAEjB,KAAK,cAAc,EACtB,MAAM,iCAAiC,CAAC;AAMzC,OAAO,EAIH,KAAK,yBAAyB,EAC9B,KAAK,iBAAiB,EACtB,KAAK,uBAAuB,EAC/B,MAAM,+BAA+B,CAAC;AAOvC,eAAO,MAAM,yBAAyB,sBAAsB,CAAC;AAC7D,eAAO,MAAM,0BAA0B,uBAAuB,CAAC;AAC/D,eAAO,MAAM,8BAA8B,2BAA2B,CAAC;AAEvE,UAAU,iBAAiB;IACvB,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACrD;AAED,UAAU,gBAAgB;IACtB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACvC,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc,GAAG,IAAI,CAAC;CAChE;AAED,UAAU,SAAS;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,EAAE,EAAE,MAAM,CAAC;CACd;AAkBD,wBAAgB,8BAA8B,CAC1C,MAAM,EAAE,iBAAiB,EACzB,aAAa,EAAE,gBAAgB,GAChC,IAAI,CAqEN;AAED,wBAAgB,kBAAkB,CAC9B,WAAW,EAAE,MAAM,EACnB,eAAe,EAAE,MAAM,EAAE,EACzB,cAAc,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,MAAM,GAC7C,MAAM,GAAG,SAAS,CAOpB;AAED,wBAAgB,uBAAuB,CAAC,MAAM,SAAS,SAAS,EAC5D,eAAe,EAAE,MAAM,EAAE,EACzB,aAAa,EAAE,OAAO,EACtB,gBAAgB,CAAC,EAAE,MAAM,GAC1B,MAAM,GAAG,SAAS,CAepB;AAED,MAAM,WAAW,4BAA4B;IACzC,iBAAiB,CACb,OAAO,CAAC,EAAE,uBAAuB,GAClC,OAAO,CAAC,yBAAyB,CAAC,CAAC;IACtC,WAAW,IAAI,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAC1C,eAAe,IAAI,OAAO,CAAC;IAC3B,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;CAClC;AAED,MAAM,WAAW,yBAAyB;IACtC,eAAe,IAAI,OAAO,CAAC,SAAS;QAAC,UAAU,EAAE,MAAM,CAAA;KAAC,EAAE,CAAC,CAAC;IAC5D,MAAM,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC7C;AAuWD,wBAAgB,+BAA+B,CAC3C,EAAE,EAAE,YAAY,EAChB,YAAY,GAAE,4BAA6D,EAC3E,iBAAiB,CAAC,EAAE,yBAAyB,GAC9C,IAAI,CAgBN"}
|
|
@@ -0,0 +1,389 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { spawn } from 'node:child_process';
|
|
11
|
+
import { LoginDialogComponent, } from '@earendil-works/pi-coding-agent';
|
|
12
|
+
import { authenticateBkper, isLoggedIn, logoutBkper, } from '../auth/local-auth-service.js';
|
|
13
|
+
import { BKPER_AI_PROVIDER_ID, BKPER_AI_STARTUP_DEFAULT_MODEL_ID, getBkperAiProviderConfig, } from './bkper-ai-provider.js';
|
|
14
|
+
export const BKPER_AGENT_LOGIN_COMMAND = 'bkper-agent-login';
|
|
15
|
+
export const BKPER_AGENT_LOGOUT_COMMAND = 'bkper-agent-logout';
|
|
16
|
+
export const BKPER_AGENT_DISCONNECT_COMMAND = 'bkper-agent-disconnect';
|
|
17
|
+
function parseCommand(text) {
|
|
18
|
+
var _a, _b;
|
|
19
|
+
const match = /^\/(\S+)(?:\s+(.*))?$/.exec(text.trim());
|
|
20
|
+
if (!(match === null || match === void 0 ? void 0 : match[1])) {
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
return {
|
|
24
|
+
command: match[1],
|
|
25
|
+
args: (_b = (_a = match[2]) === null || _a === void 0 ? void 0 : _a.trim()) !== null && _b !== void 0 ? _b : '',
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
function isBkperProviderReference(providerRef) {
|
|
29
|
+
const normalized = providerRef.trim().toLowerCase();
|
|
30
|
+
return normalized === BKPER_AI_PROVIDER_ID || normalized === 'bkper ai';
|
|
31
|
+
}
|
|
32
|
+
export function installBkperAuthCommandRouting(editor, modelRegistry) {
|
|
33
|
+
const submit = editor.onSubmit;
|
|
34
|
+
if (!submit) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
let bkperProviderSuspended = false;
|
|
38
|
+
const restoreBkperProvider = () => {
|
|
39
|
+
if (!bkperProviderSuspended) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
modelRegistry.registerProvider(BKPER_AI_PROVIDER_ID, getBkperAiProviderConfig());
|
|
43
|
+
bkperProviderSuspended = false;
|
|
44
|
+
};
|
|
45
|
+
editor.onSubmit = (text) => __awaiter(this, void 0, void 0, function* () {
|
|
46
|
+
restoreBkperProvider();
|
|
47
|
+
const parsed = parseCommand(text);
|
|
48
|
+
if (!parsed) {
|
|
49
|
+
yield submit(text);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
if (parsed.command === 'login') {
|
|
53
|
+
const suffix = parsed.args ? ` ${parsed.args}` : '';
|
|
54
|
+
yield submit(`/${BKPER_AGENT_LOGIN_COMMAND}${suffix}`);
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
if (parsed.command === 'logout') {
|
|
58
|
+
const suffix = parsed.args ? ` ${parsed.args}` : '';
|
|
59
|
+
yield submit(`/${BKPER_AGENT_LOGOUT_COMMAND}${suffix}`);
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
if (parsed.command === 'disconnect') {
|
|
63
|
+
const suffix = parsed.args ? ` ${parsed.args}` : '';
|
|
64
|
+
yield submit(`/${BKPER_AGENT_DISCONNECT_COMMAND}${suffix}`);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
if (parsed.command !== 'connect') {
|
|
68
|
+
yield submit(text);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
if (parsed.args && isBkperProviderReference(parsed.args)) {
|
|
72
|
+
yield submit(`/${BKPER_AGENT_LOGIN_COMMAND} ${parsed.args}`);
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
modelRegistry.unregisterProvider(BKPER_AI_PROVIDER_ID);
|
|
76
|
+
if (!parsed.args) {
|
|
77
|
+
bkperProviderSuspended = true;
|
|
78
|
+
try {
|
|
79
|
+
yield submit('/login');
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
restoreBkperProvider();
|
|
83
|
+
throw error;
|
|
84
|
+
}
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
try {
|
|
88
|
+
yield submit(`/login ${parsed.args}`);
|
|
89
|
+
}
|
|
90
|
+
finally {
|
|
91
|
+
modelRegistry.registerProvider(BKPER_AI_PROVIDER_ID, getBkperAiProviderConfig());
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
export function findStoredProvider(providerRef, storedProviders, getDisplayName) {
|
|
96
|
+
const normalized = providerRef.trim().toLowerCase();
|
|
97
|
+
return storedProviders.find(provider => provider.toLowerCase() === normalized ||
|
|
98
|
+
getDisplayName(provider).toLowerCase() === normalized);
|
|
99
|
+
}
|
|
100
|
+
export function selectAuthFallbackModel(availableModels, bkperLoggedIn, excludedProvider) {
|
|
101
|
+
const candidates = availableModels.filter(model => model.provider !== excludedProvider);
|
|
102
|
+
if (bkperLoggedIn) {
|
|
103
|
+
const defaultBkperModel = candidates.find(model => model.provider === BKPER_AI_PROVIDER_ID &&
|
|
104
|
+
model.id === BKPER_AI_STARTUP_DEFAULT_MODEL_ID);
|
|
105
|
+
if (defaultBkperModel) {
|
|
106
|
+
return defaultBkperModel;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return candidates.find(model => model.provider !== BKPER_AI_PROVIDER_ID);
|
|
110
|
+
}
|
|
111
|
+
const defaultAuthCommandDependencies = {
|
|
112
|
+
authenticateBkper,
|
|
113
|
+
logoutBkper,
|
|
114
|
+
isBkperLoggedIn: isLoggedIn,
|
|
115
|
+
openBrowser: openBrowserUrl,
|
|
116
|
+
};
|
|
117
|
+
function openBrowserUrl(url) {
|
|
118
|
+
const command = process.platform === 'darwin'
|
|
119
|
+
? { file: 'open', args: [url] }
|
|
120
|
+
: process.platform === 'win32'
|
|
121
|
+
? { file: 'cmd', args: ['/c', 'start', '', url] }
|
|
122
|
+
: { file: 'xdg-open', args: [url] };
|
|
123
|
+
try {
|
|
124
|
+
const child = spawn(command.file, command.args, {
|
|
125
|
+
detached: true,
|
|
126
|
+
stdio: 'ignore',
|
|
127
|
+
});
|
|
128
|
+
child.on('error', () => { });
|
|
129
|
+
child.unref();
|
|
130
|
+
}
|
|
131
|
+
catch (_a) {
|
|
132
|
+
// The login panel retains a clickable URL when no local browser is available.
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
function switchToAuthFallback(pi, ctx, dependencies, excludedProvider) {
|
|
136
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
137
|
+
const fallback = selectAuthFallbackModel(ctx.modelRegistry.getAvailable(), dependencies.isBkperLoggedIn(), excludedProvider);
|
|
138
|
+
if (!fallback) {
|
|
139
|
+
return false;
|
|
140
|
+
}
|
|
141
|
+
const changed = yield pi.setModel(fallback);
|
|
142
|
+
if (changed &&
|
|
143
|
+
fallback.provider === BKPER_AI_PROVIDER_ID &&
|
|
144
|
+
fallback.id === BKPER_AI_STARTUP_DEFAULT_MODEL_ID) {
|
|
145
|
+
pi.setThinkingLevel('high');
|
|
146
|
+
}
|
|
147
|
+
return changed;
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
function handleBkperLogin(args, pi, ctx, dependencies) {
|
|
151
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
152
|
+
if (args.trim()) {
|
|
153
|
+
ctx.ui.notify('Use /login without arguments for Bkper. Use /connect <provider> for other models.', 'warning');
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
if (ctx.mode !== 'tui') {
|
|
157
|
+
ctx.ui.notify('Run bkper auth login to log in to Bkper.', 'warning');
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
yield ctx.ui.custom((tui, _theme, _keybindings, done) => {
|
|
161
|
+
let completed = false;
|
|
162
|
+
const finish = () => {
|
|
163
|
+
if (completed) {
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
completed = true;
|
|
167
|
+
done(undefined);
|
|
168
|
+
};
|
|
169
|
+
const dialog = new LoginDialogComponent(tui, BKPER_AI_PROVIDER_ID, () => finish(), 'Bkper', 'Login to Bkper');
|
|
170
|
+
dialog.showProgress('Checking Bkper authentication...');
|
|
171
|
+
void dependencies
|
|
172
|
+
.authenticateBkper({
|
|
173
|
+
signal: dialog.signal,
|
|
174
|
+
onStatus: message => dialog.showProgress(message),
|
|
175
|
+
onDeviceCode: info => {
|
|
176
|
+
dialog.showDeviceCode({
|
|
177
|
+
userCode: info.userCode,
|
|
178
|
+
verificationUri: info.verificationUrl,
|
|
179
|
+
expiresInSeconds: info.expiresIn,
|
|
180
|
+
intervalSeconds: info.interval,
|
|
181
|
+
});
|
|
182
|
+
dialog.showWaiting('Waiting for Bkper authorization...');
|
|
183
|
+
dependencies.openBrowser(info.verificationUrl);
|
|
184
|
+
},
|
|
185
|
+
})
|
|
186
|
+
.then((result) => __awaiter(this, void 0, void 0, function* () {
|
|
187
|
+
if (dialog.signal.aborted) {
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
yield ctx.modelRegistry.refresh();
|
|
191
|
+
const currentModel = ctx.model;
|
|
192
|
+
const currentModelAvailable = currentModel
|
|
193
|
+
? ctx.modelRegistry
|
|
194
|
+
.getAvailable()
|
|
195
|
+
.some(model => model.provider === currentModel.provider &&
|
|
196
|
+
model.id === currentModel.id)
|
|
197
|
+
: false;
|
|
198
|
+
if (!currentModelAvailable) {
|
|
199
|
+
yield switchToAuthFallback(pi, ctx, dependencies);
|
|
200
|
+
}
|
|
201
|
+
const state = result.alreadyLoggedIn ? 'Already logged in' : 'Logged in';
|
|
202
|
+
const identity = result.email ? ` as ${result.email}` : '';
|
|
203
|
+
finish();
|
|
204
|
+
ctx.ui.notify(`${state} to Bkper${identity}.`, 'info');
|
|
205
|
+
}))
|
|
206
|
+
.catch(error => {
|
|
207
|
+
if (dialog.signal.aborted) {
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
finish();
|
|
211
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
212
|
+
ctx.ui.notify(`Bkper login failed: ${message}`, 'error');
|
|
213
|
+
});
|
|
214
|
+
return dialog;
|
|
215
|
+
});
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
function handleBkperLogout(args, pi, ctx, dependencies) {
|
|
219
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
220
|
+
var _a;
|
|
221
|
+
if (args.trim()) {
|
|
222
|
+
ctx.ui.notify('Use /logout without arguments for Bkper. Use /disconnect <provider> for other models.', 'warning');
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
const result = yield dependencies.logoutBkper();
|
|
226
|
+
yield ctx.modelRegistry.refresh();
|
|
227
|
+
const switched = ((_a = ctx.model) === null || _a === void 0 ? void 0 : _a.provider) === BKPER_AI_PROVIDER_ID
|
|
228
|
+
? yield switchToAuthFallback(pi, ctx, dependencies, BKPER_AI_PROVIDER_ID)
|
|
229
|
+
: true;
|
|
230
|
+
if (result.warning) {
|
|
231
|
+
ctx.ui.notify(`Logged out of Bkper locally. ${result.warning}`, 'warning');
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
const guidance = switched ? '' : ' Use /login or /connect to continue.';
|
|
235
|
+
ctx.ui.notify(`Logged out of Bkper.${guidance}`, 'info');
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
function resolveProviderToDisconnect(providerRef, ctx, credentialManager) {
|
|
239
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
240
|
+
var _a;
|
|
241
|
+
const storedProviders = ((_a = yield (credentialManager === null || credentialManager === void 0 ? void 0 : credentialManager.listCredentials())) !== null && _a !== void 0 ? _a : [])
|
|
242
|
+
.map(credential => credential.providerId)
|
|
243
|
+
.filter(provider => provider !== BKPER_AI_PROVIDER_ID);
|
|
244
|
+
if (providerRef.trim()) {
|
|
245
|
+
return findStoredProvider(providerRef, storedProviders, provider => ctx.modelRegistry.getProviderDisplayName(provider));
|
|
246
|
+
}
|
|
247
|
+
if (storedProviders.length === 0) {
|
|
248
|
+
return undefined;
|
|
249
|
+
}
|
|
250
|
+
const labels = storedProviders.map(provider => {
|
|
251
|
+
const name = ctx.modelRegistry.getProviderDisplayName(provider);
|
|
252
|
+
return name === provider ? provider : `${name} (${provider})`;
|
|
253
|
+
});
|
|
254
|
+
const selected = yield ctx.ui.select('Select model provider to disconnect:', labels);
|
|
255
|
+
const selectedIndex = selected ? labels.indexOf(selected) : -1;
|
|
256
|
+
return selectedIndex >= 0 ? storedProviders[selectedIndex] : undefined;
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
function handleProviderDisconnect(args, pi, ctx, dependencies, credentialManager) {
|
|
260
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
261
|
+
var _a;
|
|
262
|
+
if (isBkperProviderReference(args)) {
|
|
263
|
+
ctx.ui.notify('Use /logout for Bkper.', 'warning');
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
const provider = yield resolveProviderToDisconnect(args, ctx, credentialManager);
|
|
267
|
+
if (!provider) {
|
|
268
|
+
const message = args.trim()
|
|
269
|
+
? `No credentials saved by /connect for "${args.trim()}".`
|
|
270
|
+
: 'No model provider credentials saved by /connect.';
|
|
271
|
+
ctx.ui.notify(message, 'info');
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
const displayName = ctx.modelRegistry.getProviderDisplayName(provider);
|
|
275
|
+
yield (credentialManager === null || credentialManager === void 0 ? void 0 : credentialManager.logout(provider));
|
|
276
|
+
yield ctx.modelRegistry.refresh();
|
|
277
|
+
const remainingKey = yield ctx.modelRegistry.getApiKeyForProvider(provider);
|
|
278
|
+
if (remainingKey) {
|
|
279
|
+
ctx.ui.notify(`Removed stored credentials for ${displayName}. Environment or model configuration remains active.`, 'info');
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
const switched = ((_a = ctx.model) === null || _a === void 0 ? void 0 : _a.provider) === provider
|
|
283
|
+
? yield switchToAuthFallback(pi, ctx, dependencies, provider)
|
|
284
|
+
: true;
|
|
285
|
+
const guidance = switched ? '' : ' Use /login or /connect to continue.';
|
|
286
|
+
ctx.ui.notify(`Disconnected ${displayName}.${guidance}`, 'info');
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
function isInternalAuthCommand(item) {
|
|
290
|
+
return [
|
|
291
|
+
BKPER_AGENT_LOGIN_COMMAND,
|
|
292
|
+
BKPER_AGENT_LOGOUT_COMMAND,
|
|
293
|
+
BKPER_AGENT_DISCONNECT_COMMAND,
|
|
294
|
+
].includes(item.value);
|
|
295
|
+
}
|
|
296
|
+
function matchesCommandPrefix(command, prefix) {
|
|
297
|
+
return command.toLowerCase().includes(prefix.toLowerCase());
|
|
298
|
+
}
|
|
299
|
+
function createAuthAutocompleteProvider(current, ctx, credentialManager) {
|
|
300
|
+
const getSuggestions = (lines, cursorLine, cursorCol, options) => __awaiter(this, void 0, void 0, function* () {
|
|
301
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
302
|
+
const line = (_a = lines[cursorLine]) !== null && _a !== void 0 ? _a : '';
|
|
303
|
+
const beforeCursor = line.slice(0, cursorCol);
|
|
304
|
+
if (/^\/login\s/.test(beforeCursor) || /^\/logout\s/.test(beforeCursor)) {
|
|
305
|
+
return null;
|
|
306
|
+
}
|
|
307
|
+
const connectMatch = /^\/connect\s(.*)$/.exec(beforeCursor);
|
|
308
|
+
if (connectMatch) {
|
|
309
|
+
const argument = (_b = connectMatch[1]) !== null && _b !== void 0 ? _b : '';
|
|
310
|
+
const syntheticLines = [...lines];
|
|
311
|
+
syntheticLines[cursorLine] = `/login ${argument}${line.slice(cursorCol)}`;
|
|
312
|
+
const suggestions = yield current.getSuggestions(syntheticLines, cursorLine, `/login ${argument}`.length, options);
|
|
313
|
+
if (!suggestions) {
|
|
314
|
+
return null;
|
|
315
|
+
}
|
|
316
|
+
return Object.assign(Object.assign({}, suggestions), { items: suggestions.items.filter(item => !isBkperProviderReference(item.value) &&
|
|
317
|
+
!isBkperProviderReference(item.label)) });
|
|
318
|
+
}
|
|
319
|
+
const disconnectMatch = /^\/disconnect\s(.*)$/.exec(beforeCursor);
|
|
320
|
+
if (disconnectMatch) {
|
|
321
|
+
const argument = ((_c = disconnectMatch[1]) !== null && _c !== void 0 ? _c : '').toLowerCase();
|
|
322
|
+
const items = ((_d = yield (credentialManager === null || credentialManager === void 0 ? void 0 : credentialManager.listCredentials())) !== null && _d !== void 0 ? _d : [])
|
|
323
|
+
.map(credential => credential.providerId)
|
|
324
|
+
.filter(provider => provider !== BKPER_AI_PROVIDER_ID)
|
|
325
|
+
.map(provider => ({
|
|
326
|
+
value: provider,
|
|
327
|
+
label: provider,
|
|
328
|
+
description: ctx.modelRegistry.getProviderDisplayName(provider),
|
|
329
|
+
}))
|
|
330
|
+
.filter(item => `${item.value} ${item.description}`.toLowerCase().includes(argument));
|
|
331
|
+
return items.length > 0 ? { items, prefix: (_e = disconnectMatch[1]) !== null && _e !== void 0 ? _e : '' } : null;
|
|
332
|
+
}
|
|
333
|
+
if (/^\/[^\s]*$/.test(beforeCursor)) {
|
|
334
|
+
const prefix = beforeCursor.slice(1);
|
|
335
|
+
const base = yield current.getSuggestions(lines, cursorLine, cursorCol, options);
|
|
336
|
+
const items = ((_f = base === null || base === void 0 ? void 0 : base.items) !== null && _f !== void 0 ? _f : [])
|
|
337
|
+
.filter(item => !isInternalAuthCommand(item))
|
|
338
|
+
.map(item => {
|
|
339
|
+
if (item.value === 'login') {
|
|
340
|
+
return Object.assign(Object.assign({}, item), { description: 'Log in to Bkper' });
|
|
341
|
+
}
|
|
342
|
+
if (item.value === 'logout') {
|
|
343
|
+
return Object.assign(Object.assign({}, item), { description: 'Log out of Bkper' });
|
|
344
|
+
}
|
|
345
|
+
return item;
|
|
346
|
+
});
|
|
347
|
+
const additional = [
|
|
348
|
+
{ value: 'connect', label: 'connect', description: 'Connect an AI model provider' },
|
|
349
|
+
{
|
|
350
|
+
value: 'disconnect',
|
|
351
|
+
label: 'disconnect',
|
|
352
|
+
description: 'Disconnect an AI model provider',
|
|
353
|
+
},
|
|
354
|
+
].filter(item => matchesCommandPrefix(item.value, prefix));
|
|
355
|
+
for (const item of additional) {
|
|
356
|
+
if (!items.some(existing => existing.value === item.value)) {
|
|
357
|
+
items.push(item);
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
return items.length > 0
|
|
361
|
+
? { items, prefix: (_g = base === null || base === void 0 ? void 0 : base.prefix) !== null && _g !== void 0 ? _g : beforeCursor }
|
|
362
|
+
: null;
|
|
363
|
+
}
|
|
364
|
+
return current.getSuggestions(lines, cursorLine, cursorCol, options);
|
|
365
|
+
});
|
|
366
|
+
return {
|
|
367
|
+
triggerCharacters: current.triggerCharacters,
|
|
368
|
+
getSuggestions,
|
|
369
|
+
applyCompletion: (lines, cursorLine, cursorCol, item, prefix) => current.applyCompletion(lines, cursorLine, cursorCol, item, prefix),
|
|
370
|
+
shouldTriggerFileCompletion: current.shouldTriggerFileCompletion
|
|
371
|
+
? (lines, cursorLine, cursorCol) => { var _a, _b; return (_b = (_a = current.shouldTriggerFileCompletion) === null || _a === void 0 ? void 0 : _a.call(current, lines, cursorLine, cursorCol)) !== null && _b !== void 0 ? _b : false; }
|
|
372
|
+
: undefined,
|
|
373
|
+
};
|
|
374
|
+
}
|
|
375
|
+
export function registerBkperAgentAuthExtension(pi, dependencies = defaultAuthCommandDependencies, credentialManager) {
|
|
376
|
+
pi.registerCommand(BKPER_AGENT_LOGIN_COMMAND, {
|
|
377
|
+
handler: (args, ctx) => handleBkperLogin(args, pi, ctx, dependencies),
|
|
378
|
+
});
|
|
379
|
+
pi.registerCommand(BKPER_AGENT_LOGOUT_COMMAND, {
|
|
380
|
+
handler: (args, ctx) => handleBkperLogout(args, pi, ctx, dependencies),
|
|
381
|
+
});
|
|
382
|
+
pi.registerCommand(BKPER_AGENT_DISCONNECT_COMMAND, {
|
|
383
|
+
handler: (args, ctx) => handleProviderDisconnect(args, pi, ctx, dependencies, credentialManager),
|
|
384
|
+
});
|
|
385
|
+
pi.on('session_start', (_event, ctx) => {
|
|
386
|
+
ctx.ui.addAutocompleteProvider(current => createAuthAutocompleteProvider(current, ctx, credentialManager));
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
//# sourceMappingURL=auth-commands.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"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C,iBAAiB,CAAC,IAAI,EAAE,EAAE,EAAE,GAAG,EAAE,YAAY,CAAC;KACzE,CAAC,CAAC;IACH,EAAE,CAAC,eAAe,CAAC,8BAA8B,EAAE;QAC/C,OAAO,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,CACnB,wBAAwB,CAAC,IAAI,EAAE,EAAE,EAAE,GAAG,EAAE,YAAY,EAAE,iBAAiB,CAAC;KAC/E,CAAC,CAAC;IACH,EAAE,CAAC,EAAE,CAAC,eAAe,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE,EAAE;QACnC,GAAG,CAAC,EAAE,CAAC,uBAAuB,CAAC,OAAO,CAAC,EAAE,CACrC,8BAA8B,CAAC,OAAO,EAAE,GAAG,EAAE,iBAAiB,CAAC,CAClE,CAAC;IACN,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ExtensionAPI, ProviderConfig } from '@earendil-works/pi-coding-agent';
|
|
2
|
+
export declare const BKPER_AI_PROVIDER_ID = "bkper";
|
|
3
|
+
export declare const BKPER_AI_STARTUP_DEFAULT_MODEL_ID = "openai/gpt-5.6-terra";
|
|
4
|
+
export declare const BKPER_AI_PRODUCTION_BASE_URL = "https://ai.bkper.app/v1";
|
|
5
|
+
export declare const BKPER_AI_PROVIDER_CONFIG: ProviderConfig;
|
|
6
|
+
export declare function getBkperAiBaseUrlOverride(env?: Record<string, string | undefined>): string | undefined;
|
|
7
|
+
export declare function getBkperAiProviderConfig(env?: Record<string, string | undefined>): ProviderConfig;
|
|
8
|
+
export declare function registerBkperAiProvider(pi: Pick<ExtensionAPI, 'registerProvider'>, env?: Record<string, string | undefined>): void;
|
|
9
|
+
//# sourceMappingURL=bkper-ai-provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bkper-ai-provider.d.ts","sourceRoot":"","sources":["../../src/agent/bkper-ai-provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAEpF,eAAO,MAAM,oBAAoB,UAAU,CAAC;AAC5C,eAAO,MAAM,iCAAiC,yBAAyB,CAAC;AACxE,eAAO,MAAM,4BAA4B,4BAA4B,CAAC;AAKtE,eAAO,MAAM,wBAAwB,EAAE,cAwGtC,CAAC;AASF,wBAAgB,yBAAyB,CACrC,GAAG,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAe,GACtD,MAAM,GAAG,SAAS,CA0BpB;AAED,wBAAgB,wBAAwB,CACpC,GAAG,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAe,GACtD,cAAc,CAUhB;AAED,wBAAgB,uBAAuB,CACnC,EAAE,EAAE,IAAI,CAAC,YAAY,EAAE,kBAAkB,CAAC,EAC1C,GAAG,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAe,GACtD,IAAI,CAEN"}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
export const BKPER_AI_PROVIDER_ID = 'bkper';
|
|
2
|
+
export const BKPER_AI_STARTUP_DEFAULT_MODEL_ID = 'openai/gpt-5.6-terra';
|
|
3
|
+
export const BKPER_AI_PRODUCTION_BASE_URL = 'https://ai.bkper.app/v1';
|
|
4
|
+
const BKPER_AI_BASE_URL_ENV_VAR = 'BKPER_AI_BASE_URL';
|
|
5
|
+
const BKPER_AI_DEVELOPMENT_ORIGIN = 'https://ai-dev.bkper.app';
|
|
6
|
+
export const BKPER_AI_PROVIDER_CONFIG = {
|
|
7
|
+
name: 'Bkper AI',
|
|
8
|
+
baseUrl: BKPER_AI_PRODUCTION_BASE_URL,
|
|
9
|
+
apiKey: '!bkper auth token',
|
|
10
|
+
authHeader: true,
|
|
11
|
+
headers: {
|
|
12
|
+
'bkper-agent-id': 'bkper-cli',
|
|
13
|
+
'User-Agent': 'bkper-cli',
|
|
14
|
+
},
|
|
15
|
+
api: 'openai-responses',
|
|
16
|
+
models: [
|
|
17
|
+
{
|
|
18
|
+
id: 'openai/gpt-5.6-luna',
|
|
19
|
+
name: 'GPT-5.6 Luna',
|
|
20
|
+
reasoning: true,
|
|
21
|
+
thinkingLevelMap: {
|
|
22
|
+
off: null,
|
|
23
|
+
minimal: null,
|
|
24
|
+
low: null,
|
|
25
|
+
medium: null,
|
|
26
|
+
high: 'high',
|
|
27
|
+
xhigh: null,
|
|
28
|
+
max: null,
|
|
29
|
+
},
|
|
30
|
+
input: ['text', 'image'],
|
|
31
|
+
contextWindow: 200000,
|
|
32
|
+
maxTokens: 32000,
|
|
33
|
+
cost: { input: 1, output: 6, cacheRead: 0.1, cacheWrite: 1.25 },
|
|
34
|
+
compat: {
|
|
35
|
+
supportsDeveloperRole: false,
|
|
36
|
+
sessionAffinityFormat: 'openai',
|
|
37
|
+
supportsLongCacheRetention: false,
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
id: 'openai/gpt-5.6-terra',
|
|
42
|
+
name: 'GPT-5.6 Terra',
|
|
43
|
+
reasoning: true,
|
|
44
|
+
thinkingLevelMap: {
|
|
45
|
+
off: null,
|
|
46
|
+
minimal: null,
|
|
47
|
+
low: null,
|
|
48
|
+
medium: null,
|
|
49
|
+
high: 'high',
|
|
50
|
+
xhigh: null,
|
|
51
|
+
max: null,
|
|
52
|
+
},
|
|
53
|
+
input: ['text', 'image'],
|
|
54
|
+
contextWindow: 200000,
|
|
55
|
+
maxTokens: 32000,
|
|
56
|
+
cost: { input: 2.5, output: 15, cacheRead: 0.25, cacheWrite: 3.125 },
|
|
57
|
+
compat: {
|
|
58
|
+
supportsDeveloperRole: false,
|
|
59
|
+
sessionAffinityFormat: 'openai',
|
|
60
|
+
supportsLongCacheRetention: false,
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
id: 'openai/gpt-5.6-sol',
|
|
65
|
+
name: 'GPT-5.6 Sol',
|
|
66
|
+
reasoning: true,
|
|
67
|
+
thinkingLevelMap: {
|
|
68
|
+
off: null,
|
|
69
|
+
minimal: null,
|
|
70
|
+
low: null,
|
|
71
|
+
medium: 'medium',
|
|
72
|
+
high: null,
|
|
73
|
+
xhigh: null,
|
|
74
|
+
max: null,
|
|
75
|
+
},
|
|
76
|
+
input: ['text', 'image'],
|
|
77
|
+
contextWindow: 200000,
|
|
78
|
+
maxTokens: 32000,
|
|
79
|
+
cost: { input: 5, output: 30, cacheRead: 0.5, cacheWrite: 6.25 },
|
|
80
|
+
compat: {
|
|
81
|
+
supportsDeveloperRole: false,
|
|
82
|
+
sessionAffinityFormat: 'openai',
|
|
83
|
+
supportsLongCacheRetention: false,
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
id: 'xai/grok-4.5',
|
|
88
|
+
name: 'Grok 4.5',
|
|
89
|
+
reasoning: true,
|
|
90
|
+
thinkingLevelMap: {
|
|
91
|
+
off: null,
|
|
92
|
+
minimal: null,
|
|
93
|
+
low: null,
|
|
94
|
+
medium: null,
|
|
95
|
+
high: 'high',
|
|
96
|
+
xhigh: null,
|
|
97
|
+
max: null,
|
|
98
|
+
},
|
|
99
|
+
input: ['text', 'image'],
|
|
100
|
+
contextWindow: 200000,
|
|
101
|
+
maxTokens: 32000,
|
|
102
|
+
cost: { input: 2, output: 6, cacheRead: 0.5, cacheWrite: 0 },
|
|
103
|
+
compat: {
|
|
104
|
+
supportsDeveloperRole: false,
|
|
105
|
+
sessionAffinityFormat: 'openai',
|
|
106
|
+
supportsLongCacheRetention: false,
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
],
|
|
110
|
+
};
|
|
111
|
+
function invalidBkperAiBaseUrlError() {
|
|
112
|
+
return new Error(`${BKPER_AI_BASE_URL_ENV_VAR} must be an HTTPS URL on ai-dev.bkper.app ` +
|
|
113
|
+
'without credentials, a custom port, query parameters, or a fragment.');
|
|
114
|
+
}
|
|
115
|
+
export function getBkperAiBaseUrlOverride(env = process.env) {
|
|
116
|
+
const configuredBaseUrl = env[BKPER_AI_BASE_URL_ENV_VAR];
|
|
117
|
+
if (configuredBaseUrl === undefined) {
|
|
118
|
+
return undefined;
|
|
119
|
+
}
|
|
120
|
+
let url;
|
|
121
|
+
try {
|
|
122
|
+
url = new URL(configuredBaseUrl);
|
|
123
|
+
}
|
|
124
|
+
catch (_a) {
|
|
125
|
+
throw invalidBkperAiBaseUrlError();
|
|
126
|
+
}
|
|
127
|
+
if (configuredBaseUrl.trim() !== configuredBaseUrl ||
|
|
128
|
+
url.origin !== BKPER_AI_DEVELOPMENT_ORIGIN ||
|
|
129
|
+
url.username !== '' ||
|
|
130
|
+
url.password !== '' ||
|
|
131
|
+
url.search !== '' ||
|
|
132
|
+
url.hash !== '') {
|
|
133
|
+
throw invalidBkperAiBaseUrlError();
|
|
134
|
+
}
|
|
135
|
+
const path = url.pathname.replace(/\/+$/, '');
|
|
136
|
+
return `${url.origin}${path}`;
|
|
137
|
+
}
|
|
138
|
+
export function getBkperAiProviderConfig(env = process.env) {
|
|
139
|
+
const baseUrlOverride = getBkperAiBaseUrlOverride(env);
|
|
140
|
+
if (!baseUrlOverride) {
|
|
141
|
+
return BKPER_AI_PROVIDER_CONFIG;
|
|
142
|
+
}
|
|
143
|
+
return Object.assign(Object.assign({}, BKPER_AI_PROVIDER_CONFIG), { baseUrl: baseUrlOverride });
|
|
144
|
+
}
|
|
145
|
+
export function registerBkperAiProvider(pi, env = process.env) {
|
|
146
|
+
pi.registerProvider(BKPER_AI_PROVIDER_ID, getBkperAiProviderConfig(env));
|
|
147
|
+
}
|
|
148
|
+
//# sourceMappingURL=bkper-ai-provider.js.map
|