ikanban-web 0.1.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/README.md +65 -0
- package/bin/cli.js +1055 -0
- package/dist/apple-touch-icon-120x120.png +0 -0
- package/dist/apple-touch-icon-152x152.png +0 -0
- package/dist/apple-touch-icon-167x167.png +0 -0
- package/dist/apple-touch-icon-180x180.png +0 -0
- package/dist/apple-touch-icon.png +0 -0
- package/dist/apple-touch-icon.svg +16 -0
- package/dist/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
- package/dist/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
- package/dist/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
- package/dist/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
- package/dist/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
- package/dist/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
- package/dist/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
- package/dist/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
- package/dist/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
- package/dist/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
- package/dist/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
- package/dist/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
- package/dist/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
- package/dist/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
- package/dist/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
- package/dist/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
- package/dist/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
- package/dist/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
- package/dist/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
- package/dist/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
- package/dist/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
- package/dist/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
- package/dist/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
- package/dist/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
- package/dist/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
- package/dist/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
- package/dist/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
- package/dist/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
- package/dist/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
- package/dist/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
- package/dist/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
- package/dist/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
- package/dist/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
- package/dist/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
- package/dist/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
- package/dist/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
- package/dist/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
- package/dist/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
- package/dist/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
- package/dist/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
- package/dist/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
- package/dist/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
- package/dist/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
- package/dist/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
- package/dist/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
- package/dist/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
- package/dist/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
- package/dist/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
- package/dist/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
- package/dist/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
- package/dist/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
- package/dist/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
- package/dist/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
- package/dist/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
- package/dist/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
- package/dist/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
- package/dist/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
- package/dist/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
- package/dist/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
- package/dist/assets/ToolOutputDialog-BgFj3J4u.js +5 -0
- package/dist/assets/ibm-plex-mono-latin-400-normal-CvHOgSBP.woff +0 -0
- package/dist/assets/ibm-plex-mono-latin-400-normal-DMJ8VG8y.woff2 +0 -0
- package/dist/assets/ibm-plex-mono-latin-500-normal-CB9ihrfo.woff +0 -0
- package/dist/assets/ibm-plex-mono-latin-500-normal-DSY6xOcd.woff2 +0 -0
- package/dist/assets/ibm-plex-mono-latin-600-normal-BgSNZQsw.woff2 +0 -0
- package/dist/assets/ibm-plex-mono-latin-600-normal-DWFSQ4vo.woff +0 -0
- package/dist/assets/ibm-plex-sans-latin-400-normal-CDDApCn2.woff2 +0 -0
- package/dist/assets/ibm-plex-sans-latin-400-normal-CYLoc0-x.woff +0 -0
- package/dist/assets/ibm-plex-sans-latin-500-normal-6ng42L7E.woff2 +0 -0
- package/dist/assets/ibm-plex-sans-latin-500-normal-BgVn5rGT.woff +0 -0
- package/dist/assets/ibm-plex-sans-latin-600-normal-Cu4Hd6ag.woff +0 -0
- package/dist/assets/ibm-plex-sans-latin-600-normal-CuJfVYMP.woff2 +0 -0
- package/dist/assets/index-BQJPAP5f.css +1 -0
- package/dist/assets/index-MBuF9PXk.js +2 -0
- package/dist/assets/main-C1GggQif.css +1 -0
- package/dist/assets/main-Dyy8WvPJ.js +311 -0
- package/dist/assets/vendor--DEobTDja.css +1 -0
- package/dist/assets/vendor-.bun-KwPUu5oc.js +4594 -0
- package/dist/assets/wasm-CG6Dc4jp.js +1 -0
- package/dist/assets/worker-suRQxAtO.js +155 -0
- package/dist/favicon-16.png +0 -0
- package/dist/favicon-32.png +0 -0
- package/dist/favicon.png +0 -0
- package/dist/favicon.svg +15 -0
- package/dist/index.html +325 -0
- package/dist/logo-dark-192x192.png +0 -0
- package/dist/logo-dark-512x512.svg +16 -0
- package/dist/logo-light-192x192.png +0 -0
- package/dist/logo-light-512x512.svg +16 -0
- package/dist/pwa-192.png +0 -0
- package/dist/pwa-512.png +0 -0
- package/dist/pwa-maskable-192.png +0 -0
- package/dist/pwa-maskable-512.png +0 -0
- package/dist/site.webmanifest +22 -0
- package/dist/sw.js +1 -0
- package/package.json +102 -0
- package/public/apple-touch-icon-120x120.png +0 -0
- package/public/apple-touch-icon-152x152.png +0 -0
- package/public/apple-touch-icon-167x167.png +0 -0
- package/public/apple-touch-icon-180x180.png +0 -0
- package/public/apple-touch-icon.png +0 -0
- package/public/apple-touch-icon.svg +16 -0
- package/public/favicon-16.png +0 -0
- package/public/favicon-32.png +0 -0
- package/public/favicon.png +0 -0
- package/public/favicon.svg +15 -0
- package/public/logo-dark-192x192.png +0 -0
- package/public/logo-dark-512x512.svg +16 -0
- package/public/logo-light-192x192.png +0 -0
- package/public/logo-light-512x512.svg +16 -0
- package/public/pwa-192.png +0 -0
- package/public/pwa-512.png +0 -0
- package/public/pwa-maskable-192.png +0 -0
- package/public/pwa-maskable-512.png +0 -0
- package/public/site.webmanifest +22 -0
- package/server/TERMINAL_INPUT_WS_PROTOCOL.md +44 -0
- package/server/index.d.ts +28 -0
- package/server/index.js +11181 -0
- package/server/lib/cloudflare-tunnel.js +196 -0
- package/server/lib/git-credentials.js +74 -0
- package/server/lib/git-identity-storage.js +110 -0
- package/server/lib/git-service.js +2690 -0
- package/server/lib/github-auth.js +307 -0
- package/server/lib/github-device-flow.js +50 -0
- package/server/lib/github-octokit.js +10 -0
- package/server/lib/github-repo.js +55 -0
- package/server/lib/notification-message.js +49 -0
- package/server/lib/notification-message.test.js +59 -0
- package/server/lib/opencode-auth.js +81 -0
- package/server/lib/opencode-config.js +1840 -0
- package/server/lib/opencode-config.js.d.ts +12 -0
- package/server/lib/package-manager.js +255 -0
- package/server/lib/quota/DOCUMENTATION.md +52 -0
- package/server/lib/quota/index.js +21 -0
- package/server/lib/quota/providers/claude.js +107 -0
- package/server/lib/quota/providers/codex.js +111 -0
- package/server/lib/quota/providers/copilot.js +165 -0
- package/server/lib/quota/providers/google/api.js +92 -0
- package/server/lib/quota/providers/google/auth.js +108 -0
- package/server/lib/quota/providers/google/index.js +124 -0
- package/server/lib/quota/providers/google/transforms.js +109 -0
- package/server/lib/quota/providers/index.js +128 -0
- package/server/lib/quota/providers/interface.js +55 -0
- package/server/lib/quota/providers/kimi.js +108 -0
- package/server/lib/quota/providers/nanogpt.js +124 -0
- package/server/lib/quota/providers/openai.js +91 -0
- package/server/lib/quota/providers/openrouter.js +92 -0
- package/server/lib/quota/providers/zai.js +91 -0
- package/server/lib/quota/utils/auth.js +46 -0
- package/server/lib/quota/utils/formatters.js +76 -0
- package/server/lib/quota/utils/index.js +10 -0
- package/server/lib/quota/utils/transformers.js +55 -0
- package/server/lib/skills-catalog/cache.js +29 -0
- package/server/lib/skills-catalog/clawdhub/api.js +158 -0
- package/server/lib/skills-catalog/clawdhub/index.js +30 -0
- package/server/lib/skills-catalog/clawdhub/install.js +223 -0
- package/server/lib/skills-catalog/clawdhub/scan.js +113 -0
- package/server/lib/skills-catalog/curated-sources.js +21 -0
- package/server/lib/skills-catalog/git.js +76 -0
- package/server/lib/skills-catalog/install.js +280 -0
- package/server/lib/skills-catalog/scan.js +221 -0
- package/server/lib/skills-catalog/source.js +85 -0
- package/server/lib/summarization-service.js +171 -0
- package/server/lib/terminal-input-ws-protocol.js +66 -0
- package/server/lib/terminal-input-ws-protocol.test.js +138 -0
- package/server/lib/tts-service.js +162 -0
- package/server/lib/ui-auth.js +518 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
declare module "../server/lib/opencode-config.js" {
|
|
2
|
+
export function getAgentSources(agentName: string): {
|
|
3
|
+
md: { exists: boolean; path: string | null; fields: string[] };
|
|
4
|
+
json: { exists: boolean; path: string | null; fields: string[] };
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
export function createAgent(agentName: string, config: Record<string, unknown>): void;
|
|
8
|
+
|
|
9
|
+
export function updateAgent(agentName: string, updates: Record<string, unknown>): void;
|
|
10
|
+
|
|
11
|
+
export function deleteAgent(agentName: string): void;
|
|
12
|
+
}
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
import { spawnSync } from 'child_process';
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import { fileURLToPath } from 'url';
|
|
5
|
+
|
|
6
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
7
|
+
const __dirname = path.dirname(__filename);
|
|
8
|
+
|
|
9
|
+
const PACKAGE_NAME = '@ikanban/web';
|
|
10
|
+
const NPM_REGISTRY_URL = `https://registry.npmjs.org/${PACKAGE_NAME}`;
|
|
11
|
+
const CHANGELOG_URL = 'https://raw.githubusercontent.com/btriapitsyn/ikanban/main/CHANGELOG.md';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Detect which package manager was used to install this package.
|
|
15
|
+
* Strategy:
|
|
16
|
+
* 1. Check npm_config_user_agent (set during npm/pnpm/yarn/bun install)
|
|
17
|
+
* 2. Check npm_execpath for PM binary path
|
|
18
|
+
* 3. Analyze package location path for PM-specific patterns
|
|
19
|
+
* 4. Fall back to npm
|
|
20
|
+
*/
|
|
21
|
+
export function detectPackageManager() {
|
|
22
|
+
// Strategy 1: Check user agent (most reliable during install)
|
|
23
|
+
const userAgent = process.env.npm_config_user_agent || '';
|
|
24
|
+
if (userAgent.startsWith('pnpm')) return 'pnpm';
|
|
25
|
+
if (userAgent.startsWith('yarn')) return 'yarn';
|
|
26
|
+
if (userAgent.startsWith('bun')) return 'bun';
|
|
27
|
+
if (userAgent.startsWith('npm')) return 'npm';
|
|
28
|
+
|
|
29
|
+
// Strategy 2: Check execpath
|
|
30
|
+
const execPath = process.env.npm_execpath || '';
|
|
31
|
+
if (execPath.includes('pnpm')) return 'pnpm';
|
|
32
|
+
if (execPath.includes('yarn')) return 'yarn';
|
|
33
|
+
if (execPath.includes('bun')) return 'bun';
|
|
34
|
+
|
|
35
|
+
// Strategy 3: Analyze package location for PM-specific patterns
|
|
36
|
+
try {
|
|
37
|
+
const pkgPath = path.resolve(__dirname, '..', '..');
|
|
38
|
+
if (pkgPath.includes('.pnpm')) return 'pnpm';
|
|
39
|
+
if (pkgPath.includes('/.yarn/') || pkgPath.includes('\\.yarn\\')) return 'yarn';
|
|
40
|
+
if (pkgPath.includes('/.bun/') || pkgPath.includes('\\.bun\\')) return 'bun';
|
|
41
|
+
} catch {
|
|
42
|
+
// Ignore path resolution errors
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Strategy 4: Check which PM binaries are available and preferred
|
|
46
|
+
const pmChecks = [
|
|
47
|
+
{ name: 'pnpm', check: () => isCommandAvailable('pnpm') },
|
|
48
|
+
{ name: 'yarn', check: () => isCommandAvailable('yarn') },
|
|
49
|
+
{ name: 'bun', check: () => isCommandAvailable('bun') },
|
|
50
|
+
];
|
|
51
|
+
|
|
52
|
+
for (const { name, check } of pmChecks) {
|
|
53
|
+
if (check()) {
|
|
54
|
+
// Verify this PM actually has the package installed globally
|
|
55
|
+
if (isPackageInstalledWith(name)) {
|
|
56
|
+
return name;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return 'npm';
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function isCommandAvailable(command) {
|
|
65
|
+
try {
|
|
66
|
+
const result = spawnSync(command, ['--version'], {
|
|
67
|
+
encoding: 'utf8',
|
|
68
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
69
|
+
timeout: 5000,
|
|
70
|
+
});
|
|
71
|
+
return result.status === 0;
|
|
72
|
+
} catch {
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function isPackageInstalledWith(pm) {
|
|
78
|
+
try {
|
|
79
|
+
let args;
|
|
80
|
+
switch (pm) {
|
|
81
|
+
case 'pnpm':
|
|
82
|
+
args = ['list', '-g', '--depth=0', PACKAGE_NAME];
|
|
83
|
+
break;
|
|
84
|
+
case 'yarn':
|
|
85
|
+
args = ['global', 'list', '--depth=0'];
|
|
86
|
+
break;
|
|
87
|
+
case 'bun':
|
|
88
|
+
args = ['pm', 'ls', '-g'];
|
|
89
|
+
break;
|
|
90
|
+
default:
|
|
91
|
+
args = ['list', '-g', '--depth=0', PACKAGE_NAME];
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const result = spawnSync(pm, args, {
|
|
95
|
+
encoding: 'utf8',
|
|
96
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
97
|
+
timeout: 10000,
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
if (result.status !== 0) return false;
|
|
101
|
+
return result.stdout.includes(PACKAGE_NAME) || result.stdout.includes('ikanban');
|
|
102
|
+
} catch {
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Get the update command for the detected package manager
|
|
109
|
+
*/
|
|
110
|
+
export function getUpdateCommand(pm = detectPackageManager()) {
|
|
111
|
+
switch (pm) {
|
|
112
|
+
case 'pnpm':
|
|
113
|
+
return `pnpm add -g ${PACKAGE_NAME}@latest`;
|
|
114
|
+
case 'yarn':
|
|
115
|
+
return `yarn global add ${PACKAGE_NAME}@latest`;
|
|
116
|
+
case 'bun':
|
|
117
|
+
return `bun add -g ${PACKAGE_NAME}@latest`;
|
|
118
|
+
default:
|
|
119
|
+
return `npm install -g ${PACKAGE_NAME}@latest`;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Get current installed version from package.json
|
|
125
|
+
*/
|
|
126
|
+
export function getCurrentVersion() {
|
|
127
|
+
try {
|
|
128
|
+
const pkgPath = path.resolve(__dirname, '..', '..', 'package.json');
|
|
129
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
|
|
130
|
+
return pkg.version || 'unknown';
|
|
131
|
+
} catch {
|
|
132
|
+
return 'unknown';
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Fetch latest version from npm registry
|
|
138
|
+
*/
|
|
139
|
+
export async function getLatestVersion() {
|
|
140
|
+
try {
|
|
141
|
+
const response = await fetch(NPM_REGISTRY_URL, {
|
|
142
|
+
headers: { Accept: 'application/json' },
|
|
143
|
+
signal: AbortSignal.timeout(10000),
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
if (!response.ok) {
|
|
147
|
+
throw new Error(`Registry responded with ${response.status}`);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const data = await response.json();
|
|
151
|
+
return data['dist-tags']?.latest || null;
|
|
152
|
+
} catch (error) {
|
|
153
|
+
console.warn('Failed to fetch latest version from npm:', error.message);
|
|
154
|
+
return null;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Parse semver version to numeric for comparison
|
|
160
|
+
*/
|
|
161
|
+
function parseVersion(version) {
|
|
162
|
+
const parts = version.replace(/^v/, '').split('.').map(Number);
|
|
163
|
+
return (parts[0] || 0) * 10000 + (parts[1] || 0) * 100 + (parts[2] || 0);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Fetch changelog notes between versions
|
|
168
|
+
*/
|
|
169
|
+
export async function fetchChangelogNotes(fromVersion, toVersion) {
|
|
170
|
+
try {
|
|
171
|
+
const response = await fetch(CHANGELOG_URL, {
|
|
172
|
+
signal: AbortSignal.timeout(10000),
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
if (!response.ok) return undefined;
|
|
176
|
+
|
|
177
|
+
const changelog = await response.text();
|
|
178
|
+
const sections = changelog.split(/^## /m).slice(1);
|
|
179
|
+
|
|
180
|
+
const fromNum = parseVersion(fromVersion);
|
|
181
|
+
const toNum = parseVersion(toVersion);
|
|
182
|
+
|
|
183
|
+
const relevantSections = sections.filter((section) => {
|
|
184
|
+
const match = section.match(/^\[(\d+\.\d+\.\d+)\]/);
|
|
185
|
+
if (!match) return false;
|
|
186
|
+
const ver = parseVersion(match[1]);
|
|
187
|
+
return ver > fromNum && ver <= toNum;
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
if (relevantSections.length === 0) return undefined;
|
|
191
|
+
|
|
192
|
+
return relevantSections
|
|
193
|
+
.map((s) => '## ' + s.trim())
|
|
194
|
+
.join('\n\n');
|
|
195
|
+
} catch {
|
|
196
|
+
return undefined;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Check for updates and return update info
|
|
202
|
+
*/
|
|
203
|
+
export async function checkForUpdates() {
|
|
204
|
+
const currentVersion = getCurrentVersion();
|
|
205
|
+
const latestVersion = await getLatestVersion();
|
|
206
|
+
|
|
207
|
+
if (!latestVersion || currentVersion === 'unknown') {
|
|
208
|
+
return {
|
|
209
|
+
available: false,
|
|
210
|
+
currentVersion,
|
|
211
|
+
error: 'Unable to determine versions',
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
const currentNum = parseVersion(currentVersion);
|
|
216
|
+
const latestNum = parseVersion(latestVersion);
|
|
217
|
+
const available = latestNum > currentNum;
|
|
218
|
+
|
|
219
|
+
const pm = detectPackageManager();
|
|
220
|
+
|
|
221
|
+
let changelog;
|
|
222
|
+
if (available) {
|
|
223
|
+
changelog = await fetchChangelogNotes(currentVersion, latestVersion);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
return {
|
|
227
|
+
available,
|
|
228
|
+
version: latestVersion,
|
|
229
|
+
currentVersion,
|
|
230
|
+
body: changelog,
|
|
231
|
+
packageManager: pm,
|
|
232
|
+
// Show our CLI command, not raw package manager command
|
|
233
|
+
updateCommand: 'ikanban update',
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* Execute the update (used by CLI)
|
|
239
|
+
*/
|
|
240
|
+
export function executeUpdate(pm = detectPackageManager()) {
|
|
241
|
+
const command = getUpdateCommand(pm);
|
|
242
|
+
console.log(`Updating ${PACKAGE_NAME} using ${pm}...`);
|
|
243
|
+
console.log(`Running: ${command}`);
|
|
244
|
+
|
|
245
|
+
const [cmd, ...args] = command.split(' ');
|
|
246
|
+
const result = spawnSync(cmd, args, {
|
|
247
|
+
stdio: 'inherit',
|
|
248
|
+
shell: true,
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
return {
|
|
252
|
+
success: result.status === 0,
|
|
253
|
+
exitCode: result.status,
|
|
254
|
+
};
|
|
255
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# Quota Module Documentation
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
This module fetches quota and usage signals for supported providers in the web server runtime.
|
|
5
|
+
|
|
6
|
+
## Entrypoints and structure
|
|
7
|
+
- `packages/web/server/lib/quota/index.js`: public entrypoint imported by `packages/web/server/index.js`.
|
|
8
|
+
- `packages/web/server/lib/quota/providers/index.js`: provider registry, configured-provider list, and provider dispatcher.
|
|
9
|
+
- `packages/web/server/lib/quota/providers/interface.js`: JSDoc provider contract used as implementation reference.
|
|
10
|
+
- `packages/web/server/lib/quota/providers/google/`: Google-specific auth, API, and transform modules.
|
|
11
|
+
- `packages/web/server/lib/quota/utils/`: shared auth, transform, and formatting helpers.
|
|
12
|
+
|
|
13
|
+
## Supported provider IDs (dispatcher)
|
|
14
|
+
|
|
15
|
+
These provider IDs are currently dispatchable via `fetchQuotaForProvider(providerId)` in `packages/web/server/lib/quota/providers/index.js`.
|
|
16
|
+
|
|
17
|
+
| Provider ID | Display name | Module | Auth aliases/keys |
|
|
18
|
+
| --- | --- | --- | --- |
|
|
19
|
+
| `claude` | Claude | `providers/claude.js` | `anthropic`, `claude` |
|
|
20
|
+
| `codex` | Codex | `providers/codex.js` | `openai`, `codex`, `chatgpt` |
|
|
21
|
+
| `google` | Google | `providers/google/index.js` | `google`, `google.oauth`, Antigravity accounts file |
|
|
22
|
+
| `github-copilot` | GitHub Copilot | `providers/copilot.js` | `github-copilot`, `copilot` |
|
|
23
|
+
| `github-copilot-addon` | GitHub Copilot Add-on | `providers/copilot.js` | `github-copilot`, `copilot` |
|
|
24
|
+
| `kimi-for-coding` | Kimi for Coding | `providers/kimi.js` | `kimi-for-coding`, `kimi` |
|
|
25
|
+
| `nano-gpt` | NanoGPT | `providers/nanogpt.js` | `nano-gpt`, `nanogpt`, `nano_gpt` |
|
|
26
|
+
| `openrouter` | OpenRouter | `providers/openrouter.js` | `openrouter` |
|
|
27
|
+
| `zai-coding-plan` | z.ai | `providers/zai.js` | `zai-coding-plan`, `zai`, `z.ai` |
|
|
28
|
+
|
|
29
|
+
## Internal-only provider module
|
|
30
|
+
- `providers/openai.js` exists for logic parity/reuse but is intentionally not registered for dispatcher ID routing.
|
|
31
|
+
|
|
32
|
+
## Response contract
|
|
33
|
+
All providers should return results via shared helpers to preserve API shape:
|
|
34
|
+
- Required fields: `providerId`, `providerName`, `ok`, `configured`, `usage`, `fetchedAt`
|
|
35
|
+
- Optional field: `error`
|
|
36
|
+
- Unsupported provider requests should return `ok: false`, `configured: false`, `error: Unsupported provider`
|
|
37
|
+
|
|
38
|
+
## Add a new provider (quick steps)
|
|
39
|
+
1. Choose module shape based on complexity:
|
|
40
|
+
- Simple providers: create `packages/web/server/lib/quota/providers/<provider>.js`.
|
|
41
|
+
- Complex providers (multi-source auth, multiple API calls, non-trivial transforms): create `packages/web/server/lib/quota/providers/<provider>/` with split modules like Google (`index.js`, `auth.js`, `api.js`, `transforms.js`).
|
|
42
|
+
2. Export `providerId`, `providerName`, `aliases`, `isConfigured`, and `fetchQuota`.
|
|
43
|
+
3. Use shared helpers from `packages/web/server/lib/quota/utils/index.js` (`buildResult`, `toUsageWindow`, auth/conversion helpers) to keep payload shape consistent.
|
|
44
|
+
4. Register the provider in `packages/web/server/lib/quota/providers/index.js`.
|
|
45
|
+
5. If needed for direct use, export a named fetcher from `packages/web/server/lib/quota/providers/index.js` and `packages/web/server/lib/quota/index.js`.
|
|
46
|
+
6. Update this file with the new provider ID, module path, and alias/auth details.
|
|
47
|
+
7. Validate with `bun run type-check`, `bun run lint`, and `bun run build`.
|
|
48
|
+
|
|
49
|
+
## Notes for contributors
|
|
50
|
+
- Keep provider IDs stable; clients use them directly.
|
|
51
|
+
- Avoid adding alias-based dispatch in `fetchQuotaForProvider`; dispatch currently expects exact provider IDs.
|
|
52
|
+
- Keep Google behavior changes isolated and review `providers/google/*` together.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Quota module
|
|
3
|
+
*
|
|
4
|
+
* Provides quota usage tracking for various AI provider services.
|
|
5
|
+
* @module quota
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export {
|
|
9
|
+
listConfiguredQuotaProviders,
|
|
10
|
+
fetchQuotaForProvider,
|
|
11
|
+
fetchClaudeQuota,
|
|
12
|
+
fetchOpenaiQuota,
|
|
13
|
+
fetchGoogleQuota,
|
|
14
|
+
fetchCodexQuota,
|
|
15
|
+
fetchCopilotQuota,
|
|
16
|
+
fetchCopilotAddonQuota,
|
|
17
|
+
fetchKimiQuota,
|
|
18
|
+
fetchOpenRouterQuota,
|
|
19
|
+
fetchZaiQuota,
|
|
20
|
+
fetchNanoGptQuota
|
|
21
|
+
} from './providers/index.js';
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { readAuthFile } from '../../opencode-auth.js';
|
|
2
|
+
import {
|
|
3
|
+
getAuthEntry,
|
|
4
|
+
normalizeAuthEntry,
|
|
5
|
+
buildResult,
|
|
6
|
+
toUsageWindow,
|
|
7
|
+
toNumber,
|
|
8
|
+
toTimestamp
|
|
9
|
+
} from '../utils/index.js';
|
|
10
|
+
|
|
11
|
+
export const providerId = 'claude';
|
|
12
|
+
export const providerName = 'Claude';
|
|
13
|
+
export const aliases = ['anthropic', 'claude'];
|
|
14
|
+
|
|
15
|
+
export const isConfigured = () => {
|
|
16
|
+
const auth = readAuthFile();
|
|
17
|
+
const entry = normalizeAuthEntry(getAuthEntry(auth, aliases));
|
|
18
|
+
return Boolean(entry?.access || entry?.token);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const fetchQuota = async () => {
|
|
22
|
+
const auth = readAuthFile();
|
|
23
|
+
const entry = normalizeAuthEntry(getAuthEntry(auth, aliases));
|
|
24
|
+
const accessToken = entry?.access ?? entry?.token;
|
|
25
|
+
|
|
26
|
+
if (!accessToken) {
|
|
27
|
+
return buildResult({
|
|
28
|
+
providerId,
|
|
29
|
+
providerName,
|
|
30
|
+
ok: false,
|
|
31
|
+
configured: false,
|
|
32
|
+
error: 'Not configured'
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
try {
|
|
37
|
+
const response = await fetch('https://api.anthropic.com/api/oauth/usage', {
|
|
38
|
+
method: 'GET',
|
|
39
|
+
headers: {
|
|
40
|
+
Authorization: `Bearer ${accessToken}`,
|
|
41
|
+
'anthropic-beta': 'oauth-2025-04-20'
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
if (!response.ok) {
|
|
46
|
+
return buildResult({
|
|
47
|
+
providerId,
|
|
48
|
+
providerName,
|
|
49
|
+
ok: false,
|
|
50
|
+
configured: true,
|
|
51
|
+
error: `API error: ${response.status}`
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const payload = await response.json();
|
|
56
|
+
const windows = {};
|
|
57
|
+
const fiveHour = payload?.five_hour ?? null;
|
|
58
|
+
const sevenDay = payload?.seven_day ?? null;
|
|
59
|
+
const sevenDaySonnet = payload?.seven_day_sonnet ?? null;
|
|
60
|
+
const sevenDayOpus = payload?.seven_day_opus ?? null;
|
|
61
|
+
|
|
62
|
+
if (fiveHour) {
|
|
63
|
+
windows['5h'] = toUsageWindow({
|
|
64
|
+
usedPercent: toNumber(fiveHour.utilization),
|
|
65
|
+
windowSeconds: null,
|
|
66
|
+
resetAt: toTimestamp(fiveHour.resets_at)
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
if (sevenDay) {
|
|
70
|
+
windows['7d'] = toUsageWindow({
|
|
71
|
+
usedPercent: toNumber(sevenDay.utilization),
|
|
72
|
+
windowSeconds: null,
|
|
73
|
+
resetAt: toTimestamp(sevenDay.resets_at)
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
if (sevenDaySonnet) {
|
|
77
|
+
windows['7d-sonnet'] = toUsageWindow({
|
|
78
|
+
usedPercent: toNumber(sevenDaySonnet.utilization),
|
|
79
|
+
windowSeconds: null,
|
|
80
|
+
resetAt: toTimestamp(sevenDaySonnet.resets_at)
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
if (sevenDayOpus) {
|
|
84
|
+
windows['7d-opus'] = toUsageWindow({
|
|
85
|
+
usedPercent: toNumber(sevenDayOpus.utilization),
|
|
86
|
+
windowSeconds: null,
|
|
87
|
+
resetAt: toTimestamp(sevenDayOpus.resets_at)
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return buildResult({
|
|
92
|
+
providerId,
|
|
93
|
+
providerName,
|
|
94
|
+
ok: true,
|
|
95
|
+
configured: true,
|
|
96
|
+
usage: { windows }
|
|
97
|
+
});
|
|
98
|
+
} catch (error) {
|
|
99
|
+
return buildResult({
|
|
100
|
+
providerId,
|
|
101
|
+
providerName,
|
|
102
|
+
ok: false,
|
|
103
|
+
configured: true,
|
|
104
|
+
error: error instanceof Error ? error.message : 'Request failed'
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
};
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { readAuthFile } from '../../opencode-auth.js';
|
|
2
|
+
import {
|
|
3
|
+
getAuthEntry,
|
|
4
|
+
normalizeAuthEntry,
|
|
5
|
+
buildResult,
|
|
6
|
+
toUsageWindow,
|
|
7
|
+
toNumber,
|
|
8
|
+
toTimestamp,
|
|
9
|
+
formatMoney
|
|
10
|
+
} from '../utils/index.js';
|
|
11
|
+
|
|
12
|
+
export const providerId = 'codex';
|
|
13
|
+
export const providerName = 'Codex';
|
|
14
|
+
export const aliases = ['openai', 'codex', 'chatgpt'];
|
|
15
|
+
|
|
16
|
+
export const isConfigured = () => {
|
|
17
|
+
const auth = readAuthFile();
|
|
18
|
+
const entry = normalizeAuthEntry(getAuthEntry(auth, aliases));
|
|
19
|
+
return Boolean(entry?.access || entry?.token);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const fetchQuota = async () => {
|
|
23
|
+
const auth = readAuthFile();
|
|
24
|
+
const entry = normalizeAuthEntry(getAuthEntry(auth, aliases));
|
|
25
|
+
const accessToken = entry?.access ?? entry?.token;
|
|
26
|
+
const accountId = entry?.accountId;
|
|
27
|
+
|
|
28
|
+
if (!accessToken) {
|
|
29
|
+
return buildResult({
|
|
30
|
+
providerId,
|
|
31
|
+
providerName,
|
|
32
|
+
ok: false,
|
|
33
|
+
configured: false,
|
|
34
|
+
error: 'Not configured'
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
try {
|
|
39
|
+
const headers = {
|
|
40
|
+
Authorization: `Bearer ${accessToken}`,
|
|
41
|
+
'Content-Type': 'application/json',
|
|
42
|
+
...(accountId ? { 'ChatGPT-Account-Id': accountId } : {})
|
|
43
|
+
};
|
|
44
|
+
const response = await fetch('https://chatgpt.com/backend-api/wham/usage', {
|
|
45
|
+
method: 'GET',
|
|
46
|
+
headers
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
if (!response.ok) {
|
|
50
|
+
return buildResult({
|
|
51
|
+
providerId,
|
|
52
|
+
providerName,
|
|
53
|
+
ok: false,
|
|
54
|
+
configured: true,
|
|
55
|
+
error: `API error: ${response.status}`
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const payload = await response.json();
|
|
60
|
+
const primary = payload?.rate_limit?.primary_window ?? null;
|
|
61
|
+
const secondary = payload?.rate_limit?.secondary_window ?? null;
|
|
62
|
+
const credits = payload?.credits ?? null;
|
|
63
|
+
|
|
64
|
+
const windows = {};
|
|
65
|
+
if (primary) {
|
|
66
|
+
windows['5h'] = toUsageWindow({
|
|
67
|
+
usedPercent: toNumber(primary.used_percent),
|
|
68
|
+
windowSeconds: toNumber(primary.limit_window_seconds),
|
|
69
|
+
resetAt: toTimestamp(primary.reset_at)
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
if (secondary) {
|
|
73
|
+
windows['weekly'] = toUsageWindow({
|
|
74
|
+
usedPercent: toNumber(secondary.used_percent),
|
|
75
|
+
windowSeconds: toNumber(secondary.limit_window_seconds),
|
|
76
|
+
resetAt: toTimestamp(secondary.reset_at)
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
if (credits) {
|
|
80
|
+
const balance = toNumber(credits.balance);
|
|
81
|
+
const unlimited = Boolean(credits.unlimited);
|
|
82
|
+
const label = unlimited
|
|
83
|
+
? 'Unlimited'
|
|
84
|
+
: balance !== null
|
|
85
|
+
? `$${formatMoney(balance)} remaining`
|
|
86
|
+
: null;
|
|
87
|
+
windows.credits = toUsageWindow({
|
|
88
|
+
usedPercent: null,
|
|
89
|
+
windowSeconds: null,
|
|
90
|
+
resetAt: null,
|
|
91
|
+
valueLabel: label
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return buildResult({
|
|
96
|
+
providerId,
|
|
97
|
+
providerName,
|
|
98
|
+
ok: true,
|
|
99
|
+
configured: true,
|
|
100
|
+
usage: { windows }
|
|
101
|
+
});
|
|
102
|
+
} catch (error) {
|
|
103
|
+
return buildResult({
|
|
104
|
+
providerId,
|
|
105
|
+
providerName,
|
|
106
|
+
ok: false,
|
|
107
|
+
configured: true,
|
|
108
|
+
error: error instanceof Error ? error.message : 'Request failed'
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
};
|