@tiny-fish/cli 0.30.2-next.265 → 0.30.2-next.266
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/connect.js +46 -17
- package/dist/lib/client.d.ts +1 -1
- package/dist/lib/client.js +6 -4
- package/dist/lib/connect-all.js +4 -1
- package/dist/lib/connect-clients.d.ts +17 -3
- package/dist/lib/connect-clients.js +1 -3
- package/dist/lib/mcp-endpoint.d.ts +3 -1
- package/dist/lib/mcp-endpoint.js +10 -1
- package/dist/lib/verify.d.ts +1 -1
- package/dist/lib/verify.js +2 -2
- package/package.json +1 -1
package/dist/commands/connect.js
CHANGED
|
@@ -16,7 +16,7 @@ import { SIGN_IN_PROBES } from '../lib/registration-detect.js';
|
|
|
16
16
|
import { errLine, warnLine } from '../lib/output.js';
|
|
17
17
|
import { z } from 'zod';
|
|
18
18
|
import { verifyMcpAuth } from '../lib/verify.js';
|
|
19
|
-
import {
|
|
19
|
+
import { apiBaseFromMcpUrl, DEFAULT_MCP_URL } from '../lib/mcp-endpoint.js';
|
|
20
20
|
function removeExistingRegistration(client, removal, verbose) {
|
|
21
21
|
const result = spawnRemoval(client.command, removal.args);
|
|
22
22
|
if (result.status === 0)
|
|
@@ -48,9 +48,43 @@ function exportApiKey(apiKey, displayName, deferOutro) {
|
|
|
48
48
|
}
|
|
49
49
|
return true;
|
|
50
50
|
}
|
|
51
|
+
/** Undefined leaves the client on its keyless path, if any. */
|
|
52
|
+
function resolveKeyedAdd(client, storedKey, keyAuthSupported, deferOutro) {
|
|
53
|
+
if (!storedKey || !keyAuthSupported || !client.keyAuth)
|
|
54
|
+
return undefined;
|
|
55
|
+
const keyed = { key: storedKey, spec: client.keyAuth };
|
|
56
|
+
// Before the removals: a failed export must not strand the old registration.
|
|
57
|
+
if (keyed.spec.envVar && !exportApiKey(keyed.key, client.displayName, deferOutro)) {
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
return keyed;
|
|
61
|
+
}
|
|
62
|
+
/** No sign-in to degrade to, so the install stops. */
|
|
63
|
+
function refuseKeylessInstall(client, keyAuthSupported) {
|
|
64
|
+
const noSignIn = `TinyFish does not sign in to ${client.displayName} any other way`;
|
|
65
|
+
const rerun = `re-run: tinyfish connect ${client.connectClient}`;
|
|
66
|
+
if (!client.keyAuth) {
|
|
67
|
+
throw new ConnectStepError(`${client.displayName} cannot take a TinyFish API key, and ${noSignIn}. ` +
|
|
68
|
+
`Run: tinyfish connect ${client.connectClient}`, 'key_auth_unsupported');
|
|
69
|
+
}
|
|
70
|
+
if (!keyAuthSupported) {
|
|
71
|
+
throw new ConnectStepError(`This ${client.displayName} install cannot take a TinyFish API key, and ${noSignIn}. ` +
|
|
72
|
+
`Update it, then ${rerun}`, 'harness_too_old');
|
|
73
|
+
}
|
|
74
|
+
throw new ConnectStepError(`Connecting ${client.displayName} needs a TinyFish API key, and ${noSignIn}. ` +
|
|
75
|
+
`Run: tinyfish auth login, then ${rerun}`, 'invalid_config');
|
|
76
|
+
}
|
|
77
|
+
/** Resolved before the removals, so a refusal strands no registration. */
|
|
78
|
+
function keylessAddArgs(client, keyAuthSupported, oauthResource) {
|
|
79
|
+
if (!client.addArgs)
|
|
80
|
+
refuseKeylessInstall(client, keyAuthSupported);
|
|
81
|
+
const addArgs = client.addArgs;
|
|
82
|
+
return (mcpUrl) => addArgs(mcpUrl, oauthResource);
|
|
83
|
+
}
|
|
51
84
|
/** Runs before any write: a refused key strands nothing. */
|
|
52
|
-
async function verifyKeyBeforeSeeding(apiKey, displayName) {
|
|
53
|
-
|
|
85
|
+
async function verifyKeyBeforeSeeding(apiKey, displayName, mcpUrl) {
|
|
86
|
+
// One host serves `/mcp` and `/v1`, so `--url` decides where the key is checked.
|
|
87
|
+
const verified = await verifyMcpAuth(apiKey, apiBaseFromMcpUrl(mcpUrl));
|
|
54
88
|
if (verified.ok)
|
|
55
89
|
return;
|
|
56
90
|
// No status means the network failed, not the key.
|
|
@@ -128,15 +162,12 @@ async function connectNativeMcpClient(client, options) {
|
|
|
128
162
|
state.harnessDegraded = !!client.loginArgs && !optionalSupported;
|
|
129
163
|
// Prod MCP accepts X-API-Key, so a stored key replaces the browser OAuth hop.
|
|
130
164
|
const storedKey = validatedApiKey(options.apiKey);
|
|
131
|
-
|
|
132
|
-
? { key: storedKey, spec: client.keyAuth }
|
|
133
|
-
: undefined;
|
|
134
|
-
// Before the removals: a failed export must not strand the old registration.
|
|
135
|
-
if (keyedAdd?.spec.envVar &&
|
|
136
|
-
!exportApiKey(keyedAdd.key, client.displayName, options.deferOutro)) {
|
|
137
|
-
keyedAdd = undefined;
|
|
138
|
-
}
|
|
165
|
+
const keyedAdd = resolveKeyedAdd(client, storedKey, keyAuthSupported, options.deferOutro);
|
|
139
166
|
const useKeyAuth = !!keyedAdd;
|
|
167
|
+
// Refuses here when key-required; others keep their OAuth argv.
|
|
168
|
+
const buildAddArgs = keyedAdd
|
|
169
|
+
? (mcpUrl) => keyedAdd.spec.addArgs(mcpUrl, keyedAdd.key)
|
|
170
|
+
: keylessAddArgs(client, keyAuthSupported, options.mcpUrl);
|
|
140
171
|
if (options.keyAuthOnly && !useKeyAuth) {
|
|
141
172
|
// All native clients have keyAuth; missing flags mean an old install.
|
|
142
173
|
if (client.keyAuth) {
|
|
@@ -146,9 +177,9 @@ async function connectNativeMcpClient(client, options) {
|
|
|
146
177
|
throw new ConnectStepError(`${client.displayName} cannot take a TinyFish API key, and signing in needs a ` +
|
|
147
178
|
`terminal. Run: tinyfish connect ${client.connectClient}`, 'key_auth_unsupported');
|
|
148
179
|
}
|
|
149
|
-
//
|
|
150
|
-
if (keyedAdd?.spec.seedKey
|
|
151
|
-
await verifyKeyBeforeSeeding(keyedAdd.key, client.displayName);
|
|
180
|
+
// Verify first: a revoked key in a foreign .env is unrecoverable.
|
|
181
|
+
if (keyedAdd?.spec.seedKey) {
|
|
182
|
+
await verifyKeyBeforeSeeding(keyedAdd.key, client.displayName, options.mcpUrl);
|
|
152
183
|
}
|
|
153
184
|
telemetry.track('checkpoint', { phase: 'prerequisite_ok' });
|
|
154
185
|
state.stage = 'registration_cleanup';
|
|
@@ -166,9 +197,7 @@ async function connectNativeMcpClient(client, options) {
|
|
|
166
197
|
loginArgs && !probeAuthenticated ? 'registration' : 'registration_or_authentication';
|
|
167
198
|
errLine(`Adding TinyFish to ${client.displayName}...`);
|
|
168
199
|
// Header keys ride argv (/proc/<pid>/cmdline); these CLIs take headers no other way.
|
|
169
|
-
const addArgs =
|
|
170
|
-
? keyedAdd.spec.addArgs(mcpUrl.toString(), keyedAdd.key)
|
|
171
|
-
: client.addArgs(mcpUrl.toString(), options.mcpUrl);
|
|
200
|
+
const addArgs = buildAddArgs(mcpUrl.toString());
|
|
172
201
|
// Capturing an inline-OAuth add hides the sign-in URL and hangs.
|
|
173
202
|
const interactiveAdd = !(client.nonInteractiveAdd || keyedAdd);
|
|
174
203
|
// After the removals: an interrupt there leaves no key behind.
|
package/dist/lib/client.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export declare function buildConnectHeaders(connect: ConnectMap, caller: string
|
|
|
7
7
|
export declare function runSync(req: CliAgentRunParams, apiKey: string): Promise<AgentRunResponse>;
|
|
8
8
|
export declare function runAsync(req: CliAgentRunParams, apiKey: string): Promise<AgentRunAsyncResponse>;
|
|
9
9
|
export declare function runStream(req: CliAgentRunParams, apiKey: string, signal?: AbortSignal): AsyncGenerator<AgentRunWithStreamingResponse>;
|
|
10
|
-
export declare function listRuns(opts: RunListParams, apiKey: string, timeout?: number): Promise<RunListResponse>;
|
|
10
|
+
export declare function listRuns(opts: RunListParams, apiKey: string, timeout?: number, baseUrl?: string): Promise<RunListResponse>;
|
|
11
11
|
export declare function getRun(runId: string, apiKey: string): Promise<Run>;
|
|
12
12
|
export declare function getRunSteps(runId: string, apiKey: string): Promise<RunStepsResponse>;
|
|
13
13
|
export declare function searchQuery(params: SearchQueryParams, apiKey: string): Promise<SearchQueryResponse>;
|
package/dist/lib/client.js
CHANGED
|
@@ -93,10 +93,12 @@ class TinyFishCliClient extends TinyFish {
|
|
|
93
93
|
return (await response.json());
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
|
-
function createSdkClient(apiKey, timeout) {
|
|
96
|
+
function createSdkClient(apiKey, timeout, baseUrl) {
|
|
97
|
+
// An explicit base outranks the env default.
|
|
98
|
+
const resolvedBase = baseUrl ?? API_URL_OVERRIDE;
|
|
97
99
|
return new TinyFishCliClient({
|
|
98
100
|
apiKey,
|
|
99
|
-
...(
|
|
101
|
+
...(resolvedBase !== undefined ? { baseURL: resolvedBase } : {}),
|
|
100
102
|
maxRetries: 0,
|
|
101
103
|
// Fires per HTTP attempt, but maxRetries is 0 and the notice latches once per invocation.
|
|
102
104
|
onResponse: ({ headers }) => captureNotice(headers),
|
|
@@ -263,9 +265,9 @@ export async function* runStream(req, apiKey, signal) {
|
|
|
263
265
|
}
|
|
264
266
|
}
|
|
265
267
|
}
|
|
266
|
-
export async function listRuns(opts, apiKey, timeout) {
|
|
268
|
+
export async function listRuns(opts, apiKey, timeout, baseUrl) {
|
|
267
269
|
try {
|
|
268
|
-
return await createSdkClient(apiKey, timeout).runs.list(opts);
|
|
270
|
+
return await createSdkClient(apiKey, timeout, baseUrl).runs.list(opts);
|
|
269
271
|
}
|
|
270
272
|
catch (error) {
|
|
271
273
|
rethrowSdkError(error);
|
package/dist/lib/connect-all.js
CHANGED
|
@@ -40,6 +40,8 @@ const BROWSER_SIGN_IN = new Set(ALL_HARNESSES.filter((harness) => {
|
|
|
40
40
|
const native = NATIVE_BY_HARNESS.get(harness);
|
|
41
41
|
return !!native?.loginArgs || !!native?.oauthInAdd;
|
|
42
42
|
}));
|
|
43
|
+
// Derived: these refuse a keyless install, so no sign-in helps.
|
|
44
|
+
const KEY_REQUIRED = new Set(ALL_HARNESSES.filter((harness) => !!NATIVE_BY_HARNESS.get(harness)?.keyRequired));
|
|
43
45
|
// Derived: a native add carries the key, or the CLI holds it itself.
|
|
44
46
|
const KEY_AUTH_CAPABLE = new Set(ALL_HARNESSES.filter((harness) => !!NATIVE_BY_HARNESS.get(harness)?.keyAuth || HARNESS_CAPABILITIES[harness].keyHeldByCli));
|
|
45
47
|
// OpenCode ships no `mcp remove`, so the only removal is editing the config it wrote.
|
|
@@ -311,7 +313,8 @@ async function processHarness(detection, opts, prompt, oauthBudget, hoistedCliIn
|
|
|
311
313
|
}
|
|
312
314
|
headlessAuth = true;
|
|
313
315
|
}
|
|
314
|
-
|
|
316
|
+
// Key-required harnesses refuse below; offering a browser sign-in would mislead.
|
|
317
|
+
if (isTTY && !keyed && prompt && !KEY_REQUIRED.has(harness)) {
|
|
315
318
|
errLine(`step: waiting for browser sign-in to TinyFish for ${DISPLAY_NAMES[harness]}`);
|
|
316
319
|
try {
|
|
317
320
|
await prompt(`Press enter to open the browser and sign in to TinyFish for ${DISPLAY_NAMES[harness]}... `);
|
|
@@ -34,7 +34,7 @@ export interface SeededInstall {
|
|
|
34
34
|
detail?: string;
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
|
-
|
|
37
|
+
interface BaseMcpClient extends SupportedCommand {
|
|
38
38
|
connectClient: Exclude<AgentClient, 'openclaw'>;
|
|
39
39
|
/** Omitted where the `skills` CLI has no agent for this harness (Grok ships its own plugin). */
|
|
40
40
|
skillAgent?: SkillAgent;
|
|
@@ -62,7 +62,6 @@ export interface NativeMcpClient extends SupportedCommand {
|
|
|
62
62
|
args: string[];
|
|
63
63
|
label: string;
|
|
64
64
|
}[];
|
|
65
|
-
addArgs: (mcpUrl: string, oauthResource: string) => string[];
|
|
66
65
|
/** Blocking terminal walkthrough; runs only behind the TTY gate. */
|
|
67
66
|
launchWalkthrough?: () => void;
|
|
68
67
|
/** Own window, never inherits stdio; reports its own outcome. */
|
|
@@ -70,6 +69,21 @@ export interface NativeMcpClient extends SupportedCommand {
|
|
|
70
69
|
/** Printed after a successful connect, on both the launch and non-launch paths. */
|
|
71
70
|
postConnectNote?: string;
|
|
72
71
|
}
|
|
72
|
+
/** Keyless installs use this argv; the harness signs itself in. */
|
|
73
|
+
export interface OauthCapableMcpClient extends BaseMcpClient {
|
|
74
|
+
keyRequired?: false;
|
|
75
|
+
addArgs: (mcpUrl: string, oauthResource: string) => string[];
|
|
76
|
+
}
|
|
77
|
+
/** No sign-in exists here, so connect refuses a keyless install (Hermes). */
|
|
78
|
+
export interface KeyRequiredMcpClient extends BaseMcpClient {
|
|
79
|
+
keyRequired: true;
|
|
80
|
+
keyAuth: NonNullable<BaseMcpClient['keyAuth']>;
|
|
81
|
+
/** Restoring any of these three would restore the OAuth fallback. */
|
|
82
|
+
addArgs?: never;
|
|
83
|
+
oauthInAdd?: never;
|
|
84
|
+
loginArgs?: never;
|
|
85
|
+
}
|
|
86
|
+
export type NativeMcpClient = OauthCapableMcpClient | KeyRequiredMcpClient;
|
|
73
87
|
export declare const CLAUDE_CODE: NativeMcpClient;
|
|
74
88
|
/**
|
|
75
89
|
* `cmd` re-parses its command line after `/c`, so an unquoted `&` in the query string ends the
|
|
@@ -84,7 +98,7 @@ export declare function hermesRegistrationEnabled(home: string): {
|
|
|
84
98
|
ok: boolean;
|
|
85
99
|
detail?: string;
|
|
86
100
|
};
|
|
87
|
-
export declare const HERMES:
|
|
101
|
+
export declare const HERMES: KeyRequiredMcpClient;
|
|
88
102
|
export declare const OPENCODE: NativeMcpClient;
|
|
89
103
|
/** Every native MCP client. Derive from this, so a new harness cannot be missed. */
|
|
90
104
|
export declare const NATIVE_MCP_CLIENTS: readonly NativeMcpClient[];
|
|
@@ -291,6 +291,7 @@ export const HERMES = {
|
|
|
291
291
|
connectClient: 'hermes',
|
|
292
292
|
skillAgent: 'hermes-agent',
|
|
293
293
|
displayName: 'Hermes',
|
|
294
|
+
keyRequired: true,
|
|
294
295
|
supportCheck: {
|
|
295
296
|
args: ['mcp', 'add', '--help'],
|
|
296
297
|
patterns: [/--auth\s+\{[^}]*oauth[^}]*\}/],
|
|
@@ -303,9 +304,6 @@ export const HERMES = {
|
|
|
303
304
|
seedKey: seedHermesKey,
|
|
304
305
|
},
|
|
305
306
|
removals: [{ args: ['mcp', 'remove', 'tinyfish'], label: 'TinyFish registration from Hermes' }],
|
|
306
|
-
// Hermes completes OAuth while adding the server; a separate `mcp login` would authenticate twice.
|
|
307
|
-
oauthInAdd: true,
|
|
308
|
-
addArgs: (mcpUrl) => [...urlAddArgs(mcpUrl), '--auth', 'oauth'],
|
|
309
307
|
launchWalkthrough: launchHermesWalkthrough,
|
|
310
308
|
postConnectNote: 'Restart your Hermes session to pick up TinyFish — Hermes discovers MCP servers at startup.',
|
|
311
309
|
};
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export declare const DEFAULT_MCP_URL = "https://agent.tinyfish.ai/mcp";
|
|
2
2
|
export declare function endpointOf(url: string): string;
|
|
3
|
-
/** `
|
|
3
|
+
/** One host serves `/mcp` and `/v1`, so origin is the API base. */
|
|
4
|
+
export declare function apiBaseFromMcpUrl(mcpUrl: string): string | undefined;
|
|
5
|
+
/** doctor reuses the CLI's own BASE_URL check; off-default endpoints cannot. */
|
|
4
6
|
export declare function isDefaultEndpoint(mcpUrl: string): boolean;
|
package/dist/lib/mcp-endpoint.js
CHANGED
|
@@ -4,7 +4,16 @@ export function endpointOf(url) {
|
|
|
4
4
|
const parsed = new URL(url);
|
|
5
5
|
return `${parsed.origin}${parsed.pathname.replace(/\/$/, '')}`;
|
|
6
6
|
}
|
|
7
|
-
/** `
|
|
7
|
+
/** One host serves `/mcp` and `/v1`, so origin is the API base. */
|
|
8
|
+
export function apiBaseFromMcpUrl(mcpUrl) {
|
|
9
|
+
try {
|
|
10
|
+
return new URL(mcpUrl).origin;
|
|
11
|
+
}
|
|
12
|
+
catch {
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
/** doctor reuses the CLI's own BASE_URL check; off-default endpoints cannot. */
|
|
8
17
|
export function isDefaultEndpoint(mcpUrl) {
|
|
9
18
|
try {
|
|
10
19
|
return endpointOf(mcpUrl) === endpointOf(DEFAULT_MCP_URL);
|
package/dist/lib/verify.d.ts
CHANGED
|
@@ -11,4 +11,4 @@ export interface VerifyResult {
|
|
|
11
11
|
/** Reachability check. Verify failure is a warning, never install failure. */
|
|
12
12
|
export declare function verifyMcpHealth(mcpUrl: string): Promise<VerifyResult>;
|
|
13
13
|
/** Authenticated check — where the CLI holds the key (Cursor, OpenClaw, Hermes). */
|
|
14
|
-
export declare function verifyMcpAuth(apiKey: string): Promise<VerifyResult>;
|
|
14
|
+
export declare function verifyMcpAuth(apiKey: string, apiBaseUrl?: string): Promise<VerifyResult>;
|
package/dist/lib/verify.js
CHANGED
|
@@ -62,10 +62,10 @@ export async function verifyMcpHealth(mcpUrl) {
|
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
/** Authenticated check — where the CLI holds the key (Cursor, OpenClaw, Hermes). */
|
|
65
|
-
export async function verifyMcpAuth(apiKey) {
|
|
65
|
+
export async function verifyMcpAuth(apiKey, apiBaseUrl) {
|
|
66
66
|
try {
|
|
67
67
|
// Bound it: the SDK default is 600s, and a warning-only check must never hang an install.
|
|
68
|
-
await listRuns({ limit: 1 }, apiKey, VERIFY_TIMEOUT_MS);
|
|
68
|
+
await listRuns({ limit: 1 }, apiKey, VERIFY_TIMEOUT_MS, apiBaseUrl);
|
|
69
69
|
return { depth: 'health+auth', ok: true };
|
|
70
70
|
}
|
|
71
71
|
catch (e) {
|