catence 0.2.0-beta.2 → 0.2.0-beta.3
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 +23 -0
- package/dist/contracts/release.d.ts +1 -1
- package/dist/contracts/release.js +1 -1
- package/dist/core/runtime/catalog.js +15 -6
- package/dist/core/runtime/self-update.d.ts +44 -0
- package/dist/core/runtime/self-update.js +138 -0
- package/dist/interfaces/cli/commands.js +59 -1
- package/dist/runtime/index.d.ts +2 -0
- package/dist/runtime/index.js +1 -0
- package/docs/llm-providers.md +76 -6
- package/package.json +3 -1
- package/scripts/discover-opencode-go.mjs +210 -0
package/README.md
CHANGED
|
@@ -93,11 +93,21 @@ catence-data --athlete alex retry --run <run-id>
|
|
|
93
93
|
catence-data --athlete alex auth strava --callback
|
|
94
94
|
catence-data --athlete alex disconnect strava
|
|
95
95
|
|
|
96
|
+
# Update the runtime and Console together on the tracked release channel
|
|
97
|
+
catence-data update --check
|
|
98
|
+
catence-data update
|
|
99
|
+
|
|
96
100
|
# Choose a non-default catalog location
|
|
97
101
|
catence-data --home /srv/catence setup --athlete alex --label "Alex"
|
|
98
102
|
catence --home /srv/catence
|
|
99
103
|
```
|
|
100
104
|
|
|
105
|
+
`catence-data update` follows the channel of the installed runtime: a beta
|
|
106
|
+
install tracks the npm `beta` tag and the matching PyPI prereleases, a stable
|
|
107
|
+
install tracks `latest`. Pass `--channel stable` to move off a beta. The command
|
|
108
|
+
replaces the global `catence` package and installs or upgrades
|
|
109
|
+
`catence-console` with `uv tool` when `uv` is available; `--check` only reports.
|
|
110
|
+
|
|
101
111
|
Register `http://127.0.0.1:8765/strava/callback` with the Strava application for the callback flow. The manual `auth strava --code <authorization-code>` flow remains available for headless environments.
|
|
102
112
|
|
|
103
113
|
## Safe demo and Glama
|
|
@@ -186,6 +196,19 @@ docker run --rm -it -v catence-data:/data --entrypoint catence-data catence-cons
|
|
|
186
196
|
|
|
187
197
|
Use the same `--entrypoint catence-data` pattern for `secret set` and `sync`. Route a Cloudflare Tunnel to `http://127.0.0.1:8000`; do not run a tunnel client in this image. Use HTTPS at the tunnel and retain the Console login—the dashboard is fetched through the authenticated Console origin rather than directly from port 8787.
|
|
188
198
|
|
|
199
|
+
[`scripts/deploy-console.sh`](scripts/deploy-console.sh) deploys this stack from
|
|
200
|
+
the public registries and seeds a starter `config.json` (the Console model
|
|
201
|
+
profiles from [`config.example.json`](config.example.json)) into the data
|
|
202
|
+
volume, so the settings panel works before the first chat. Edit
|
|
203
|
+
`/data/config.json` in the volume (or the bind-mounted `--home` directory) to
|
|
204
|
+
change models and defaults, or discover OpenCode Go profiles from the image:
|
|
205
|
+
|
|
206
|
+
```sh
|
|
207
|
+
docker compose -f catence-deploy/docker-compose.yml --env-file catence-deploy/.env run --rm \
|
|
208
|
+
--entrypoint node console \
|
|
209
|
+
/usr/local/lib/node_modules/catence/scripts/discover-opencode-go.mjs --write /data/config.json
|
|
210
|
+
```
|
|
211
|
+
|
|
189
212
|
## Configuration
|
|
190
213
|
|
|
191
214
|
[`config.example.json`](config.example.json) documents rate limits, Strava budgets, and Console model profiles. It intentionally contains environment-variable names rather than credential values. Keep per-athlete provider values in `catence-data secret set`, not in `.env` or `config.json`.
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Keep these values synchronized with release/manifest.json; release checks
|
|
4
4
|
* deliberately reject drift before a package can be published.
|
|
5
5
|
*/
|
|
6
|
-
export declare const CATENCE_RUNTIME_VERSION = "0.2.0-beta.
|
|
6
|
+
export declare const CATENCE_RUNTIME_VERSION = "0.2.0-beta.3";
|
|
7
7
|
export declare const CATENCE_PROTOCOL_VERSION = 1;
|
|
8
8
|
export type CatenceRuntimeCapabilities = {
|
|
9
9
|
mcp: true;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Keep these values synchronized with release/manifest.json; release checks
|
|
4
4
|
* deliberately reject drift before a package can be published.
|
|
5
5
|
*/
|
|
6
|
-
export const CATENCE_RUNTIME_VERSION = '0.2.0-beta.
|
|
6
|
+
export const CATENCE_RUNTIME_VERSION = '0.2.0-beta.3';
|
|
7
7
|
export const CATENCE_PROTOCOL_VERSION = 1;
|
|
8
8
|
export function catenceRuntimeHealth() {
|
|
9
9
|
return {
|
|
@@ -40,9 +40,8 @@ export function athleteStorePaths(catalogPaths, athleteId) {
|
|
|
40
40
|
function legacyStoreMessage(paths) {
|
|
41
41
|
return `Catence 0.2 uses a catalog at ${paths.root}. The existing directory looks like a 0.1 data store and cannot be migrated automatically. Create a fresh catalog and re-sync each athlete.`;
|
|
42
42
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
43
|
+
/** Home-directory entries the Console creates on its own and must not block catalog initialization. */
|
|
44
|
+
const CONSOLE_ARTIFACTS = new Set(['config.json', 'console']);
|
|
46
45
|
export async function loadCatalog(paths = resolveCatalogPaths()) {
|
|
47
46
|
const contents = await readFile(paths.catalog, 'utf8').catch((error) => {
|
|
48
47
|
if (error.code !== 'ENOENT')
|
|
@@ -68,9 +67,19 @@ async function writeCatalog(paths, catalog) {
|
|
|
68
67
|
export async function initializeCatalog(paths = resolveCatalogPaths(), athlete) {
|
|
69
68
|
if (existsSync(paths.catalog))
|
|
70
69
|
return loadCatalog(paths);
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
70
|
+
let entries;
|
|
71
|
+
try {
|
|
72
|
+
entries = await readdir(paths.root);
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
if (error.code === 'ENOENT')
|
|
76
|
+
entries = [];
|
|
77
|
+
else
|
|
78
|
+
throw error;
|
|
79
|
+
}
|
|
80
|
+
if (entries.includes('catence.duckdb'))
|
|
81
|
+
throw new Error(legacyStoreMessage(paths));
|
|
82
|
+
if (entries.some((entry) => !CONSOLE_ARTIFACTS.has(entry))) {
|
|
74
83
|
throw new Error(`Refusing to initialize ${paths.root}: choose an empty --home directory or remove its unrelated contents.`);
|
|
75
84
|
}
|
|
76
85
|
const id = athleteIdSchema.parse(athlete.id);
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export type UpdateChannel = 'stable' | 'beta';
|
|
2
|
+
export type ParsedRelease = {
|
|
3
|
+
major: number;
|
|
4
|
+
minor: number;
|
|
5
|
+
patch: number;
|
|
6
|
+
/** Present only for prerelease builds; a stable release beats every beta of the same tuple. */
|
|
7
|
+
beta?: number;
|
|
8
|
+
};
|
|
9
|
+
export type SelfUpdatePlan = {
|
|
10
|
+
channel: UpdateChannel;
|
|
11
|
+
runtime: {
|
|
12
|
+
current: string;
|
|
13
|
+
target?: string;
|
|
14
|
+
updateAvailable: boolean;
|
|
15
|
+
};
|
|
16
|
+
console: {
|
|
17
|
+
installed?: string;
|
|
18
|
+
target?: string;
|
|
19
|
+
updateAvailable: boolean;
|
|
20
|
+
};
|
|
21
|
+
/** True when neither component has anything to apply. */
|
|
22
|
+
ok: boolean;
|
|
23
|
+
};
|
|
24
|
+
export declare function parseReleaseVersion(version: string): ParsedRelease | null;
|
|
25
|
+
export declare function compareReleaseVersions(left: ParsedRelease, right: ParsedRelease): -1 | 0 | 1;
|
|
26
|
+
export declare function channelForVersion(version: string): UpdateChannel;
|
|
27
|
+
export declare function latestRelease(versions: string[], channel: UpdateChannel): string | undefined;
|
|
28
|
+
export declare function planSelfUpdate(options: {
|
|
29
|
+
runtimeVersion: string;
|
|
30
|
+
channel: UpdateChannel;
|
|
31
|
+
npmDistTags: Record<string, string>;
|
|
32
|
+
pypiReleases: string[];
|
|
33
|
+
consoleInstalled?: string;
|
|
34
|
+
}): SelfUpdatePlan;
|
|
35
|
+
export declare function fetchNpmDistTags(packageName: string, fetchImpl?: typeof fetch): Promise<Record<string, string>>;
|
|
36
|
+
export declare function fetchPypiReleases(packageName: string, fetchImpl?: typeof fetch): Promise<string[]>;
|
|
37
|
+
/** Run an update command (npm or uv) with the user's terminal attached. */
|
|
38
|
+
export declare function runSelfUpdateCommand(command: string, args: string[]): Promise<number>;
|
|
39
|
+
export declare function hasCommand(command: string): Promise<boolean>;
|
|
40
|
+
/** Read `catence-console --version` from PATH; undefined when the Console is not installed. */
|
|
41
|
+
export declare function readInstalledConsoleVersion(): Promise<string | undefined>;
|
|
42
|
+
/** Global npm package root, used to decide whether `catence` can update itself in place. */
|
|
43
|
+
export declare function npmGlobalPrefix(): Promise<string | undefined>;
|
|
44
|
+
export declare function isGlobalNpmInstall(moduleUrl: string, npmPrefix: string | undefined): boolean;
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Self-update support for the Catence runtime and its Console.
|
|
3
|
+
*
|
|
4
|
+
* The runtime tracks npm dist-tags on the `catence` package; the Console
|
|
5
|
+
* tracks PEP 440 releases on PyPI (`catence-console`). A release is "newer"
|
|
6
|
+
* only when it strictly dominates the installed version inside the tracked
|
|
7
|
+
* channel: `stable` for non-prerelease installs, or the beta prerelease
|
|
8
|
+
* channel for beta installs. Channel names match npm dist-tags, so a beta
|
|
9
|
+
* runtime consults the `beta` tag and an explicit `--channel stable` moves a
|
|
10
|
+
* beta install onto the `latest` tag.
|
|
11
|
+
*/
|
|
12
|
+
import { spawn } from 'node:child_process';
|
|
13
|
+
import { fileURLToPath } from 'node:url';
|
|
14
|
+
const NPM_VERSION = /^(\d+)\.(\d+)\.(\d+)(?:-beta\.(\d+))?$/;
|
|
15
|
+
const PEP440_BETA = /^(\d+)\.(\d+)\.(\d+)b(\d+)$/;
|
|
16
|
+
export function parseReleaseVersion(version) {
|
|
17
|
+
const npm = NPM_VERSION.exec(version.trim());
|
|
18
|
+
if (npm) {
|
|
19
|
+
return {
|
|
20
|
+
major: Number(npm[1]),
|
|
21
|
+
minor: Number(npm[2]),
|
|
22
|
+
patch: Number(npm[3]),
|
|
23
|
+
beta: npm[4] === undefined ? undefined : Number(npm[4]),
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
const pep440 = PEP440_BETA.exec(version.trim());
|
|
27
|
+
if (pep440) {
|
|
28
|
+
return { major: Number(pep440[1]), minor: Number(pep440[2]), patch: Number(pep440[3]), beta: Number(pep440[4]) };
|
|
29
|
+
}
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
export function compareReleaseVersions(left, right) {
|
|
33
|
+
for (const field of ['major', 'minor', 'patch']) {
|
|
34
|
+
if (left[field] !== right[field])
|
|
35
|
+
return left[field] < right[field] ? -1 : 1;
|
|
36
|
+
}
|
|
37
|
+
const leftBeta = left.beta ?? Number.POSITIVE_INFINITY;
|
|
38
|
+
const rightBeta = right.beta ?? Number.POSITIVE_INFINITY;
|
|
39
|
+
if (leftBeta === rightBeta)
|
|
40
|
+
return 0;
|
|
41
|
+
return leftBeta < rightBeta ? -1 : 1;
|
|
42
|
+
}
|
|
43
|
+
export function channelForVersion(version) {
|
|
44
|
+
return parseReleaseVersion(version)?.beta !== undefined ? 'beta' : 'stable';
|
|
45
|
+
}
|
|
46
|
+
export function latestRelease(versions, channel) {
|
|
47
|
+
let best;
|
|
48
|
+
for (const version of versions) {
|
|
49
|
+
const parsed = parseReleaseVersion(version);
|
|
50
|
+
if (!parsed)
|
|
51
|
+
continue;
|
|
52
|
+
const isBeta = parsed.beta !== undefined;
|
|
53
|
+
if (channel === 'beta' ? !isBeta : isBeta)
|
|
54
|
+
continue;
|
|
55
|
+
if (!best || compareReleaseVersions(parsed, best.parsed) > 0)
|
|
56
|
+
best = { version, parsed };
|
|
57
|
+
}
|
|
58
|
+
return best?.version;
|
|
59
|
+
}
|
|
60
|
+
export function planSelfUpdate(options) {
|
|
61
|
+
const distTag = options.channel === 'beta' ? 'beta' : 'latest';
|
|
62
|
+
const runtimeTarget = options.npmDistTags[distTag];
|
|
63
|
+
const consoleTarget = latestRelease(options.pypiReleases, options.channel);
|
|
64
|
+
const runtimeUpdateAvailable = isNewer(runtimeTarget, parseReleaseVersion(options.runtimeVersion));
|
|
65
|
+
const consoleUpdateAvailable = options.consoleInstalled
|
|
66
|
+
? isNewer(consoleTarget, parseReleaseVersion(options.consoleInstalled))
|
|
67
|
+
: consoleTarget !== undefined;
|
|
68
|
+
return {
|
|
69
|
+
channel: options.channel,
|
|
70
|
+
runtime: { current: options.runtimeVersion, target: runtimeTarget, updateAvailable: runtimeUpdateAvailable },
|
|
71
|
+
console: { installed: options.consoleInstalled, target: consoleTarget, updateAvailable: consoleUpdateAvailable },
|
|
72
|
+
ok: !runtimeUpdateAvailable && !consoleUpdateAvailable,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
function isNewer(target, current) {
|
|
76
|
+
if (!target || !current)
|
|
77
|
+
return false;
|
|
78
|
+
const parsed = parseReleaseVersion(target);
|
|
79
|
+
return parsed !== null && compareReleaseVersions(parsed, current) > 0;
|
|
80
|
+
}
|
|
81
|
+
export async function fetchNpmDistTags(packageName, fetchImpl = fetch) {
|
|
82
|
+
const response = await fetchImpl(`https://registry.npmjs.org/${packageName}`);
|
|
83
|
+
if (!response.ok)
|
|
84
|
+
throw new Error(`npm registry returned HTTP ${response.status} for ${packageName}.`);
|
|
85
|
+
const payload = (await response.json());
|
|
86
|
+
return payload['dist-tags'] ?? {};
|
|
87
|
+
}
|
|
88
|
+
export async function fetchPypiReleases(packageName, fetchImpl = fetch) {
|
|
89
|
+
const response = await fetchImpl(`https://pypi.org/pypi/${packageName}/json`);
|
|
90
|
+
if (!response.ok)
|
|
91
|
+
throw new Error(`PyPI returned HTTP ${response.status} for ${packageName}.`);
|
|
92
|
+
const payload = (await response.json());
|
|
93
|
+
return Object.keys(payload.releases ?? {});
|
|
94
|
+
}
|
|
95
|
+
/** Run an update command (npm or uv) with the user's terminal attached. */
|
|
96
|
+
export function runSelfUpdateCommand(command, args) {
|
|
97
|
+
return new Promise((resolve, reject) => {
|
|
98
|
+
const child = spawn(command, args, { stdio: 'inherit' });
|
|
99
|
+
child.once('error', reject);
|
|
100
|
+
child.once('close', (code) => resolve(code ?? 1));
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
export function hasCommand(command) {
|
|
104
|
+
return new Promise((resolve) => {
|
|
105
|
+
const child = spawn(command, ['--version'], { stdio: 'ignore' });
|
|
106
|
+
child.once('error', () => resolve(false));
|
|
107
|
+
child.once('close', (code) => resolve(code === 0));
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
/** Read `catence-console --version` from PATH; undefined when the Console is not installed. */
|
|
111
|
+
export function readInstalledConsoleVersion() {
|
|
112
|
+
return new Promise((resolve) => {
|
|
113
|
+
const child = spawn('catence-console', ['--version'], { stdio: ['ignore', 'pipe', 'inherit'] });
|
|
114
|
+
let stdout = '';
|
|
115
|
+
child.stdout?.on('data', (chunk) => (stdout += chunk.toString('utf8')));
|
|
116
|
+
child.once('error', () => resolve(undefined));
|
|
117
|
+
child.once('close', (code) => {
|
|
118
|
+
const match = /^catence-console (\S+)/.exec(stdout.trim());
|
|
119
|
+
resolve(code === 0 && match ? match[1] : undefined);
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
/** Global npm package root, used to decide whether `catence` can update itself in place. */
|
|
124
|
+
export function npmGlobalPrefix() {
|
|
125
|
+
return new Promise((resolve) => {
|
|
126
|
+
const child = spawn('npm', ['prefix', '-g'], { stdio: ['ignore', 'pipe', 'inherit'] });
|
|
127
|
+
let stdout = '';
|
|
128
|
+
child.stdout?.on('data', (chunk) => (stdout += chunk.toString('utf8')));
|
|
129
|
+
child.once('error', () => resolve(undefined));
|
|
130
|
+
child.once('close', (code) => resolve(code === 0 ? stdout.trim() : undefined));
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
export function isGlobalNpmInstall(moduleUrl, npmPrefix) {
|
|
134
|
+
if (!npmPrefix)
|
|
135
|
+
return false;
|
|
136
|
+
return fileURLToPath(moduleUrl).startsWith(`${npmPrefix}/lib/node_modules/`);
|
|
137
|
+
}
|
|
138
|
+
//# sourceMappingURL=self-update.js.map
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { createInterface } from 'node:readline/promises';
|
|
3
3
|
import { stdin as input, stdout as output } from 'node:process';
|
|
4
4
|
import { Command } from 'commander';
|
|
5
|
-
import { addAthlete, athleteStorePaths, createDemoStore, dataStatus, defaultCatalogHome, disconnectStravaAccount, initializeCatalog, linkActivity, loadCatalog, rebuildRetrievalIndex, resolveAthlete, resolveCatalogPaths, retryDataSync, setAthleteSecret, syncData, connectStrava, connectStravaWithCallback, unlinkActivity, } from '../../runtime/index.js';
|
|
5
|
+
import { addAthlete, athleteStorePaths, CATENCE_RUNTIME_VERSION, channelForVersion, createDemoStore, dataStatus, defaultCatalogHome, disconnectStravaAccount, fetchNpmDistTags, fetchPypiReleases, hasCommand, initializeCatalog, isGlobalNpmInstall, linkActivity, loadCatalog, npmGlobalPrefix, planSelfUpdate, readInstalledConsoleVersion, rebuildRetrievalIndex, resolveAthlete, resolveCatalogPaths, retryDataSync, runSelfUpdateCommand, setAthleteSecret, syncData, connectStrava, connectStravaWithCallback, unlinkActivity, } from '../../runtime/index.js';
|
|
6
6
|
const program = new Command()
|
|
7
7
|
.name('catence-data')
|
|
8
8
|
.description('Athlete-scoped Catence data setup, extraction, and normalization.')
|
|
@@ -158,6 +158,64 @@ program.command('status').action(async () => {
|
|
|
158
158
|
const { paths } = await currentAthlete();
|
|
159
159
|
process.stdout.write(`${JSON.stringify(await dataStatus(paths), null, 2)}\n`);
|
|
160
160
|
});
|
|
161
|
+
program.command('update')
|
|
162
|
+
.description('Check for and apply the newest Catence release on the tracked channel (runtime and Console).')
|
|
163
|
+
.option('--check', 'report available releases without changing anything')
|
|
164
|
+
.option('--channel <stable|beta>', 'release channel to track; defaults to the installed runtime channel')
|
|
165
|
+
.option('--runtime', 'only check or update the Catence runtime package')
|
|
166
|
+
.option('--console', 'only check or update the Catence Console package')
|
|
167
|
+
.action(async (options) => {
|
|
168
|
+
if (options.channel !== undefined && options.channel !== 'stable' && options.channel !== 'beta') {
|
|
169
|
+
throw new Error('--channel must be stable or beta.');
|
|
170
|
+
}
|
|
171
|
+
const channel = options.channel ?? channelForVersion(CATENCE_RUNTIME_VERSION);
|
|
172
|
+
const runtimeOnly = options.runtime ?? false;
|
|
173
|
+
const consoleOnly = options.console ?? false;
|
|
174
|
+
const updateRuntime = runtimeOnly || !consoleOnly;
|
|
175
|
+
const updateConsole = consoleOnly || !runtimeOnly;
|
|
176
|
+
const [npmDistTags, pypiReleases, consoleInstalled] = await Promise.all([
|
|
177
|
+
fetchNpmDistTags('catence'),
|
|
178
|
+
fetchPypiReleases('catence-console'),
|
|
179
|
+
readInstalledConsoleVersion(),
|
|
180
|
+
]);
|
|
181
|
+
const plan = planSelfUpdate({ runtimeVersion: CATENCE_RUNTIME_VERSION, channel, npmDistTags, pypiReleases, consoleInstalled });
|
|
182
|
+
const report = { channel, runtime: plan.runtime, console: plan.console };
|
|
183
|
+
if (options.check) {
|
|
184
|
+
process.stdout.write(`${JSON.stringify(report, null, 2)}\n`);
|
|
185
|
+
process.exit(plan.ok ? 0 : 1);
|
|
186
|
+
}
|
|
187
|
+
const applied = [];
|
|
188
|
+
if (plan.runtime.updateAvailable && updateRuntime) {
|
|
189
|
+
const runtimeTarget = plan.runtime.target;
|
|
190
|
+
if (runtimeTarget === undefined)
|
|
191
|
+
throw new Error('No runtime update target is available.');
|
|
192
|
+
const npmPrefix = await npmGlobalPrefix();
|
|
193
|
+
if (isGlobalNpmInstall(import.meta.url, npmPrefix)) {
|
|
194
|
+
const exitCode = await runSelfUpdateCommand('npm', ['install', '--global', `catence@${runtimeTarget}`]);
|
|
195
|
+
if (exitCode !== 0)
|
|
196
|
+
throw new Error(`npm failed to install catence@${runtimeTarget} (exit ${exitCode}).`);
|
|
197
|
+
applied.push(`runtime: catence@${runtimeTarget}`);
|
|
198
|
+
}
|
|
199
|
+
else {
|
|
200
|
+
process.stderr.write(`Runtime is not a global npm install; run: npm install --global catence@${runtimeTarget}\n`);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
if (plan.console.updateAvailable && updateConsole) {
|
|
204
|
+
const consoleTarget = plan.console.target;
|
|
205
|
+
if (consoleTarget === undefined)
|
|
206
|
+
throw new Error('No Console update target is available.');
|
|
207
|
+
if (await hasCommand('uv')) {
|
|
208
|
+
const exitCode = await runSelfUpdateCommand('uv', ['tool', 'install', '--upgrade', `catence-console==${consoleTarget}`]);
|
|
209
|
+
if (exitCode !== 0)
|
|
210
|
+
throw new Error(`uv failed to install catence-console==${consoleTarget} (exit ${exitCode}).`);
|
|
211
|
+
applied.push(`console: catence-console==${consoleTarget}`);
|
|
212
|
+
}
|
|
213
|
+
else {
|
|
214
|
+
process.stderr.write(`uv is not installed; run: pip install --upgrade 'catence-console==${consoleTarget}'\n`);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
process.stdout.write(`${JSON.stringify({ ...report, applied }, null, 2)}\n`);
|
|
218
|
+
});
|
|
161
219
|
program.command('build-retrieval-index').description('Build derived local retrieval context for one athlete.').action(async () => {
|
|
162
220
|
const { paths } = await currentAthlete();
|
|
163
221
|
process.stdout.write(`${JSON.stringify(await rebuildRetrievalIndex(paths), null, 2)}\n`);
|
package/dist/runtime/index.d.ts
CHANGED
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
* without changing the public product adapters.
|
|
8
8
|
*/
|
|
9
9
|
export type { CatencePaths } from '../contracts/runtime.js';
|
|
10
|
+
export { channelForVersion, compareReleaseVersions, fetchNpmDistTags, fetchPypiReleases, hasCommand, isGlobalNpmInstall, latestRelease, npmGlobalPrefix, parseReleaseVersion, planSelfUpdate, readInstalledConsoleVersion, runSelfUpdateCommand, } from '../core/runtime/self-update.js';
|
|
11
|
+
export type { SelfUpdatePlan, UpdateChannel } from '../core/runtime/self-update.js';
|
|
10
12
|
export { CATENCE_PROTOCOL_VERSION, CATENCE_RUNTIME_VERSION, catenceRuntimeHealth } from '../contracts/release.js';
|
|
11
13
|
export { configuredMcpRateLimit, loadCatenceConfig, resolvePaths } from '../core/runtime/configuration.js';
|
|
12
14
|
export { addAthlete, athleteStorePaths, defaultAthlete, defaultCatalogHome, initializeCatalog, loadCatalog, resolveAthlete, resolveCatalogPaths, } from '../core/runtime/catalog.js';
|
package/dist/runtime/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { channelForVersion, compareReleaseVersions, fetchNpmDistTags, fetchPypiReleases, hasCommand, isGlobalNpmInstall, latestRelease, npmGlobalPrefix, parseReleaseVersion, planSelfUpdate, readInstalledConsoleVersion, runSelfUpdateCommand, } from '../core/runtime/self-update.js';
|
|
1
2
|
export { CATENCE_PROTOCOL_VERSION, CATENCE_RUNTIME_VERSION, catenceRuntimeHealth } from '../contracts/release.js';
|
|
2
3
|
export { configuredMcpRateLimit, loadCatenceConfig, resolvePaths } from '../core/runtime/configuration.js';
|
|
3
4
|
export { addAthlete, athleteStorePaths, defaultAthlete, defaultCatalogHome, initializeCatalog, loadCatalog, resolveAthlete, resolveCatalogPaths, } from '../core/runtime/catalog.js';
|
package/docs/llm-providers.md
CHANGED
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
Catence Console talks to a model through [LiteLLM](https://docs.litellm.ai/).
|
|
4
4
|
There are exactly three provider shapes: **OpenAI**, **Anthropic**, and a
|
|
5
|
-
generic **OpenAI-compatible** profile. Azure
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
generic **OpenAI-compatible** profile. Azure is not a special case in the code:
|
|
6
|
+
it is reached through the OpenAI-compatible profile. OpenCode Go can be reached
|
|
7
|
+
the same way through a local gateway, or directly at its own OpenAI-compatible
|
|
8
|
+
endpoint with native `openai/…` and `anthropic/…` model names; the steps for
|
|
9
|
+
each are documented below.
|
|
8
10
|
|
|
9
11
|
## How configuration is split
|
|
10
12
|
|
|
@@ -166,9 +168,77 @@ Notes:
|
|
|
166
168
|
|
|
167
169
|
### Opencode
|
|
168
170
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
171
|
+
[OpenCode Go](https://opencode.ai) publishes an OpenAI-compatible API at
|
|
172
|
+
`https://opencode.ai/zen/go/v1`; its `GET /v1/models` listing is public and does
|
|
173
|
+
not require a key. The Console can use it directly, so most setups do not need a
|
|
174
|
+
local gateway.
|
|
175
|
+
|
|
176
|
+
The repository includes a discovery script that fetches the live model list and
|
|
177
|
+
merges ready-made Console profiles into `config.json`. From a Catence checkout:
|
|
178
|
+
|
|
179
|
+
```sh
|
|
180
|
+
npm run discover:opencode-go -- --write ~/.catence/config.json
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
The script adds two profiles, because OpenCode Go routes model families through
|
|
184
|
+
different API shapes:
|
|
185
|
+
|
|
186
|
+
- `opencode-go` — chat and responses models, base
|
|
187
|
+
`https://opencode.ai/zen/go/v1` (LiteLLM `openai/…` names).
|
|
188
|
+
- `opencode-go-messages` — messages models, base `https://opencode.ai/zen/go`
|
|
189
|
+
(LiteLLM `anthropic/…` names).
|
|
190
|
+
|
|
191
|
+
| Family | Profile prefix | Example |
|
|
192
|
+
| --- | --- | --- |
|
|
193
|
+
| Chat | `openai/<id>` | `openai/deepseek-v4-flash` |
|
|
194
|
+
| Responses | `openai/responses/<id>` | `openai/responses/grok-4.5` |
|
|
195
|
+
| Messages | `anthropic/<id>` | `anthropic/minimax-m2.5` |
|
|
196
|
+
|
|
197
|
+
The script warns on stderr and skips any model that does not fit one of these
|
|
198
|
+
families. Rerun it to refresh the model lists; existing profiles, limits, and
|
|
199
|
+
`defaultProfile` are preserved unless `--set-default` is passed.
|
|
200
|
+
|
|
201
|
+
```sh
|
|
202
|
+
export OPENCODE_GO_API_KEY='…' # any non-empty value satisfies the key check
|
|
203
|
+
export OPENCODE_GO_API_BASE='https://opencode.ai/zen/go/v1'
|
|
204
|
+
export OPENCODE_GO_MESSAGES_API_BASE='https://opencode.ai/zen/go'
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
```jsonc
|
|
208
|
+
{
|
|
209
|
+
"console": {
|
|
210
|
+
"defaultProfile": "opencode-go",
|
|
211
|
+
"profiles": {
|
|
212
|
+
"opencode-go": {
|
|
213
|
+
"label": "OpenCode Go",
|
|
214
|
+
"defaultModel": "flash",
|
|
215
|
+
"models": {
|
|
216
|
+
"flash": { "label": "DeepSeek V4 flash", "model": "openai/deepseek-v4-flash" },
|
|
217
|
+
"grok": { "label": "Grok 4.5", "model": "openai/responses/grok-4.5" }
|
|
218
|
+
},
|
|
219
|
+
"apiKeyEnv": "OPENCODE_GO_API_KEY",
|
|
220
|
+
"apiBaseEnv": "OPENCODE_GO_API_BASE"
|
|
221
|
+
},
|
|
222
|
+
"opencode-go-messages": {
|
|
223
|
+
"label": "OpenCode Go messages",
|
|
224
|
+
"defaultModel": "minimax",
|
|
225
|
+
"models": {
|
|
226
|
+
"minimax": { "label": "MiniMax M2.5", "model": "anthropic/minimax-m2.5" }
|
|
227
|
+
},
|
|
228
|
+
"apiKeyEnv": "OPENCODE_GO_API_KEY",
|
|
229
|
+
"apiBaseEnv": "OPENCODE_GO_MESSAGES_API_BASE"
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
Verify with `catence-console doctor`. The `responses` models
|
|
237
|
+
(`openai/responses/…`) go through LiteLLM's responses bridge and are the least
|
|
238
|
+
battle-tested path; smoke-test one chat turn before relying on them.
|
|
239
|
+
|
|
240
|
+
If you instead want to reuse the providers already configured in your local
|
|
241
|
+
Opencode CLI, run an OpenAI-compatible gateway such as the
|
|
172
242
|
[`opencode-llm-proxy`](https://github.com/KochC/opencode-llm-proxy) plugin, which
|
|
173
243
|
serves Chat Completions at `http://127.0.0.1:4010/v1` and lists every configured
|
|
174
244
|
model as `provider/model`.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "catence",
|
|
3
|
-
"version": "0.2.0-beta.
|
|
3
|
+
"version": "0.2.0-beta.3",
|
|
4
4
|
"description": "Local MCP access to normalized Garmin, Intervals.icu, and targeted Strava fitness data.",
|
|
5
5
|
"license": "AGPL-3.0-or-later",
|
|
6
6
|
"repository": {
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
"README.md",
|
|
29
29
|
"config.example.json",
|
|
30
30
|
"docs",
|
|
31
|
+
"scripts/discover-opencode-go.mjs",
|
|
31
32
|
"pyproject.toml",
|
|
32
33
|
"uv.lock",
|
|
33
34
|
"python/__init__.py",
|
|
@@ -55,6 +56,7 @@
|
|
|
55
56
|
"mcp": "tsx src/interfaces/mcp/main.ts",
|
|
56
57
|
"console": "uv run --project console catence-console serve",
|
|
57
58
|
"console:doctor": "uv run --project console catence-console doctor",
|
|
59
|
+
"discover:opencode-go": "node scripts/discover-opencode-go.mjs",
|
|
58
60
|
"package:check": "npm pack --dry-run",
|
|
59
61
|
"release:check": "node scripts/release-artifacts.mjs check",
|
|
60
62
|
"mcpb:validate": "npm exec --yes --package @anthropic-ai/mcpb -- mcpb validate mcpb/manifest.json",
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
// Discover OpenCode Go models and emit Catence Console profiles for them.
|
|
2
|
+
//
|
|
3
|
+
// OpenCode Go serves its catalog through three APIs: most models speak the
|
|
4
|
+
// OpenAI Chat Completions API, Grok and GPT-5.6 Luna speak the OpenAI
|
|
5
|
+
// Responses API, and MiniMax and Qwen speak the Anthropic Messages API. The
|
|
6
|
+
// public `GET /models` endpoint returns only model ids, not which API each
|
|
7
|
+
// model needs, so routing comes from the trusted table below and is intersected
|
|
8
|
+
// with the live list (the same "live discovery + trusted metadata" approach
|
|
9
|
+
// OpenClaw uses).
|
|
10
|
+
//
|
|
11
|
+
// Usage:
|
|
12
|
+
// node scripts/discover-opencode-go.mjs [--base-url <url>] [--write <config.json>] [--set-default]
|
|
13
|
+
//
|
|
14
|
+
// Flags:
|
|
15
|
+
// --base-url <url> Root of the OpenCode Go API (default https://opencode.ai/zen/go/v1).
|
|
16
|
+
// --write <path> Merge the two profiles into an existing config.json instead of printing to stdout.
|
|
17
|
+
// --set-default With --write, set console.defaultProfile to opencode-go even when one already exists.
|
|
18
|
+
|
|
19
|
+
import process from 'node:process';
|
|
20
|
+
import { readFile, writeFile } from 'node:fs/promises';
|
|
21
|
+
|
|
22
|
+
const DEFAULT_BASE_URL = 'https://opencode.ai/zen/go/v1';
|
|
23
|
+
const API_KEY_ENV = 'OPENCODE_GO_API_KEY';
|
|
24
|
+
const API_BASE_ENV = 'OPENCODE_GO_API_BASE';
|
|
25
|
+
const MESSAGES_BASE_ENV = 'OPENCODE_GO_MESSAGES_API_BASE';
|
|
26
|
+
|
|
27
|
+
// LiteLLM appends a fixed suffix to the profile base URL per provider, so the
|
|
28
|
+
// three APIs need different prefixes and two base URLs:
|
|
29
|
+
// openai/<id> -> {base}/chat/completions
|
|
30
|
+
// openai/responses/<id> -> {base}/responses
|
|
31
|
+
// anthropic/<id> -> {base minus /v1}/v1/messages
|
|
32
|
+
const RESPONSES_MODELS = new Set(['grok-4.5', 'gpt-5.6-luna']);
|
|
33
|
+
const MESSAGES_MODELS = new Set([
|
|
34
|
+
'minimax-m2.5',
|
|
35
|
+
'minimax-m2.7',
|
|
36
|
+
'minimax-m3',
|
|
37
|
+
'qwen3.5-plus',
|
|
38
|
+
'qwen3.6-plus',
|
|
39
|
+
'qwen3.7-plus',
|
|
40
|
+
'qwen3.7-max',
|
|
41
|
+
'qwen3.8-max',
|
|
42
|
+
]);
|
|
43
|
+
|
|
44
|
+
const BRAND_NAMES = new Map([
|
|
45
|
+
['deepseek', 'DeepSeek'],
|
|
46
|
+
['glm', 'GLM'],
|
|
47
|
+
['gpt', 'GPT'],
|
|
48
|
+
['grok', 'Grok'],
|
|
49
|
+
['hy3', 'Hy3'],
|
|
50
|
+
['kimi', 'Kimi'],
|
|
51
|
+
['mimo', 'MiMo'],
|
|
52
|
+
['minimax', 'MiniMax'],
|
|
53
|
+
['qwen', 'Qwen'],
|
|
54
|
+
]);
|
|
55
|
+
|
|
56
|
+
function classify(id) {
|
|
57
|
+
if (RESPONSES_MODELS.has(id)) return { route: 'responses', guessed: false };
|
|
58
|
+
if (MESSAGES_MODELS.has(id)) return { route: 'messages', guessed: false };
|
|
59
|
+
if (/^(grok-|gpt-)/.test(id)) return { route: 'responses', guessed: true };
|
|
60
|
+
if (/^(minimax-|qwen)/.test(id)) return { route: 'messages', guessed: true };
|
|
61
|
+
return { route: 'chat', guessed: false };
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function modelReference(id, route) {
|
|
65
|
+
if (route === 'responses') return `openai/responses/${id}`;
|
|
66
|
+
if (route === 'messages') return `anthropic/${id}`;
|
|
67
|
+
return `openai/${id}`;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function labelFor(id) {
|
|
71
|
+
return id
|
|
72
|
+
.split('-')
|
|
73
|
+
.map((segment) => BRAND_NAMES.get(segment) ?? segment.charAt(0).toUpperCase() + segment.slice(1))
|
|
74
|
+
.join(' ');
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function usage() {
|
|
78
|
+
process.stderr.write(
|
|
79
|
+
'Usage: node scripts/discover-opencode-go.mjs [--base-url <url>] [--write <config.json>] [--set-default]\n',
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
async function main() {
|
|
84
|
+
const args = process.argv.slice(2);
|
|
85
|
+
let baseUrl = DEFAULT_BASE_URL;
|
|
86
|
+
let writePath = null;
|
|
87
|
+
let setDefault = false;
|
|
88
|
+
for (let i = 0; i < args.length; i += 1) {
|
|
89
|
+
const arg = args[i];
|
|
90
|
+
if (arg === '--base-url') {
|
|
91
|
+
baseUrl = args[i + 1];
|
|
92
|
+
if (!baseUrl) throw new Error('--base-url requires a URL.');
|
|
93
|
+
i += 1;
|
|
94
|
+
} else if (arg === '--write') {
|
|
95
|
+
writePath = args[i + 1];
|
|
96
|
+
if (!writePath) throw new Error('--write requires a config.json path.');
|
|
97
|
+
i += 1;
|
|
98
|
+
} else if (arg === '--set-default') {
|
|
99
|
+
setDefault = true;
|
|
100
|
+
} else if (arg === '--help' || arg === '-h') {
|
|
101
|
+
usage();
|
|
102
|
+
return;
|
|
103
|
+
} else {
|
|
104
|
+
throw new Error(`Unknown argument: ${arg}`);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (!baseUrl.endsWith('/v1')) {
|
|
109
|
+
process.stderr.write(`Warning: --base-url ${baseUrl} does not end in /v1; chat and responses URLs may be wrong.\n`);
|
|
110
|
+
}
|
|
111
|
+
const modelsUrl = `${baseUrl.replace(/\/$/, '')}/models`;
|
|
112
|
+
const messagesBase = baseUrl.replace(/\/v1\/?$/, '');
|
|
113
|
+
|
|
114
|
+
let response;
|
|
115
|
+
try {
|
|
116
|
+
response = await fetch(modelsUrl, { headers: { accept: 'application/json' } });
|
|
117
|
+
} catch (error) {
|
|
118
|
+
throw new Error(`Could not reach ${modelsUrl}: ${error.message}`);
|
|
119
|
+
}
|
|
120
|
+
if (!response.ok) {
|
|
121
|
+
throw new Error(`GET ${modelsUrl} returned HTTP ${response.status}.`);
|
|
122
|
+
}
|
|
123
|
+
const payload = await response.json();
|
|
124
|
+
const ids = (payload.data ?? []).map((entry) => entry.id).filter((id) => typeof id === 'string' && id);
|
|
125
|
+
|
|
126
|
+
const groups = { chat: [], responses: [], messages: [] };
|
|
127
|
+
const guessed = [];
|
|
128
|
+
for (const id of ids) {
|
|
129
|
+
const { route, guessed: wasGuessed } = classify(id);
|
|
130
|
+
if (!(route in groups)) continue;
|
|
131
|
+
groups[route].push(id);
|
|
132
|
+
if (wasGuessed) guessed.push(`${id} -> ${route}`);
|
|
133
|
+
}
|
|
134
|
+
for (const route of Object.keys(groups)) groups[route].sort();
|
|
135
|
+
|
|
136
|
+
const chatProfileModels = {};
|
|
137
|
+
for (const id of groups.chat) {
|
|
138
|
+
chatProfileModels[id] = { label: labelFor(id), model: modelReference(id, 'chat') };
|
|
139
|
+
}
|
|
140
|
+
for (const id of groups.responses) {
|
|
141
|
+
chatProfileModels[id] = { label: labelFor(id), model: modelReference(id, 'responses') };
|
|
142
|
+
}
|
|
143
|
+
const messagesProfileModels = {};
|
|
144
|
+
for (const id of groups.messages) {
|
|
145
|
+
messagesProfileModels[id] = { label: labelFor(id), model: modelReference(id, 'messages') };
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
const chatDefault = groups.chat[0] ?? groups.responses[0];
|
|
149
|
+
const profiles = {};
|
|
150
|
+
profiles['opencode-go'] = {
|
|
151
|
+
label: 'OpenCode Go',
|
|
152
|
+
...(chatDefault ? { defaultModel: chatDefault } : {}),
|
|
153
|
+
models: chatProfileModels,
|
|
154
|
+
apiKeyEnv: API_KEY_ENV,
|
|
155
|
+
apiBaseEnv: API_BASE_ENV,
|
|
156
|
+
};
|
|
157
|
+
if (messagesProfileModels && groups.messages.length) {
|
|
158
|
+
profiles['opencode-go-messages'] = {
|
|
159
|
+
label: 'OpenCode Go (Anthropic)',
|
|
160
|
+
defaultModel: groups.messages[0],
|
|
161
|
+
models: messagesProfileModels,
|
|
162
|
+
apiKeyEnv: API_KEY_ENV,
|
|
163
|
+
apiBaseEnv: MESSAGES_BASE_ENV,
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
const consoleSection = { defaultProfile: 'opencode-go', profiles };
|
|
168
|
+
|
|
169
|
+
if (guessed.length) {
|
|
170
|
+
process.stderr.write('Routed by prefix heuristic (verify before use):\n');
|
|
171
|
+
for (const line of guessed) process.stderr.write(` ${line}\n`);
|
|
172
|
+
}
|
|
173
|
+
process.stderr.write(
|
|
174
|
+
`Discovered ${ids.length} models (${groups.chat.length} chat, ${groups.responses.length} responses, ${groups.messages.length} messages).\n`,
|
|
175
|
+
);
|
|
176
|
+
|
|
177
|
+
if (writePath) {
|
|
178
|
+
let root = {};
|
|
179
|
+
try {
|
|
180
|
+
root = JSON.parse(await readFile(writePath, 'utf8'));
|
|
181
|
+
} catch (error) {
|
|
182
|
+
if (error.code !== 'ENOENT') throw new Error(`Could not read ${writePath}: ${error.message}`);
|
|
183
|
+
}
|
|
184
|
+
if (typeof root !== 'object' || root === null || Array.isArray(root)) {
|
|
185
|
+
throw new Error(`${writePath} must contain a JSON object.`);
|
|
186
|
+
}
|
|
187
|
+
const existingConsole = typeof root.console === 'object' && root.console !== null ? root.console : {};
|
|
188
|
+
const mergedProfiles = { ...(existingConsole.profiles ?? {}), ...profiles };
|
|
189
|
+
const defaultProfile =
|
|
190
|
+
existingConsole.defaultProfile && !setDefault ? existingConsole.defaultProfile : 'opencode-go';
|
|
191
|
+
root.console = { ...existingConsole, defaultProfile, profiles: mergedProfiles };
|
|
192
|
+
await writeFile(writePath, `${JSON.stringify(root, null, 2)}\n`);
|
|
193
|
+
process.stderr.write(`Merged profiles into ${writePath} (defaultProfile: ${defaultProfile}).\n`);
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
process.stderr.write(
|
|
198
|
+
`Export the key and base URLs, then add the JSON below under "console" in config.json:\n` +
|
|
199
|
+
` export ${API_KEY_ENV}='sk-…'\n` +
|
|
200
|
+
` export ${API_BASE_ENV}='${baseUrl}'\n` +
|
|
201
|
+
` export ${MESSAGES_BASE_ENV}='${messagesBase}'\n` +
|
|
202
|
+
`(or rerun with --write ~/.catence/config.json to merge into an existing config.)\n`,
|
|
203
|
+
);
|
|
204
|
+
process.stdout.write(`${JSON.stringify(consoleSection, null, 2)}\n`);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
await main().catch((error) => {
|
|
208
|
+
process.stderr.write(`Error: ${error.message}\n`);
|
|
209
|
+
process.exit(1);
|
|
210
|
+
});
|