@tiny-fish/cli 0.19.1-next.177 → 0.19.1-next.178

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.
@@ -2,8 +2,6 @@ import { Command } from "commander";
2
2
  import { type AgentClient } from "../lib/connect-runtime.js";
3
3
  export declare const DEFAULT_MCP_URL = "https://agent.tinyfish.ai/mcp";
4
4
  export declare const UPGRADE_HINT = "Run `tinyfish upgrade` any time to update the CLI and skill.";
5
- export declare const DEFAULT_ONBOARDING_PROMPT: string;
6
- export declare const OPENCLAW_ONBOARDING_PROMPT: string;
7
5
  interface NativeConnectOptions {
8
6
  apiKey?: string;
9
7
  mcpUrl: string;
@@ -1,52 +1,18 @@
1
1
  import * as path from "node:path";
2
2
  import spawn from "cross-spawn";
3
3
  import { CONNECT_SOURCE, loadConfig, persistApiKeyToEnvironment, saveConnectContext, validateKeyFormat, validatedApiKey, writeConfig, } from "../lib/auth.js";
4
+ import { CLAUDE_CODE, CODEX, HERMES, OPENCLAW, OPENCLAW_SKILL_INSTALL_ARGS, OPENCODE, launchNativeMcpClient, launchOpenClawWalkthrough, } from "../lib/connect-clients.js";
4
5
  import { commandNotFound, ConnectInterruptedError, createConnectTelemetry, requireCommandSupport, runGuarded, settle, throwIfInterrupted, NON_INTERACTIVE_TIMEOUT_MS, } from "../lib/connect-runtime.js";
5
6
  import { TINYFISH_CLI_PACKAGE } from "../lib/constants.js";
6
7
  import { cursorInstallDeeplink, cursorMcpPath, writeCursorMcpConfig, } from "../lib/cursor-config.js";
7
8
  import { runConnectAll } from "../lib/connect-all.js";
8
9
  import { detectHumanInitiated } from "../lib/harness.js";
9
10
  import { emitNotice } from "../lib/notice.js";
10
- import { errLine, sanitizeLine } from "../lib/output.js";
11
- import { codexOauthCompleted } from "../lib/registration-detect.js";
11
+ import { errLine } from "../lib/output.js";
12
12
  import { z } from "zod";
13
13
  import { verifyMcpAuth } from "../lib/verify.js";
14
14
  export const DEFAULT_MCP_URL = "https://agent.tinyfish.ai/mcp";
15
15
  const SKILL_INSTALL_TIMEOUT_MS = 120_000;
16
- const HERMES_SEED_TIMEOUT_MS = 120_000;
17
- // An old install is only one reason a flag can go unseen, so no message asserts the cause.
18
- const SUPPORT_CHECK_DEBUG_HINT = " Set TINYFISH_DEBUG=1 and retry to print the help output TinyFish read.";
19
- const MCP_ADD_UNAVAILABLE_MESSAGE = "Could not confirm this Claude Code installation exposes `claude mcp add`: `claude mcp " +
20
- "--help` did not list it. Update Claude Code with `claude update` and retry." +
21
- SUPPORT_CHECK_DEBUG_HINT;
22
- // `claude mcp login` only exists upstream from Claude Code 2.1.186; older installs still register.
23
- const CLAUDE_CODE_KEYED_FALLBACK_NOTE = "Using your stored TinyFish API key: this Claude Code predates one-command sign-in " +
24
- "(`claude mcp login`), so no browser sign-in is needed.";
25
- const CLAUDE_CODE_DEFERRED_AUTH_NOTE = "TinyFish is registered in Claude Code but not signed in: this Claude Code predates " +
26
- "one-command sign-in (`claude mcp login`). Open Claude Code and run `/mcp` to sign in to " +
27
- "TinyFish. `claude update` gets you one-command sign-in.";
28
- const CODEX_OAUTH_RESOURCE_UNAVAILABLE_MESSAGE = "Could not confirm this Codex installation supports one-command MCP authentication: `codex " +
29
- "mcp add --help` did not list `--oauth-resource`. Update Codex and retry, or add TinyFish " +
30
- "manually with `codex mcp add`." +
31
- SUPPORT_CHECK_DEBUG_HINT;
32
- const HERMES_OAUTH_UNAVAILABLE_MESSAGE = "Could not confirm this Hermes installation supports one-command MCP authentication: `hermes " +
33
- "mcp add --help` did not list `--auth oauth`. Update Hermes and retry, or add TinyFish " +
34
- "manually with `hermes mcp add`." +
35
- SUPPORT_CHECK_DEBUG_HINT;
36
- const OPENCLAW_SKILL_UNAVAILABLE_MESSAGE = "Could not confirm this OpenClaw installation supports global skill installation: `openclaw " +
37
- "skills install --help` did not list `--global` and `--acknowledge-clawhub-risk`. Update " +
38
- "OpenClaw and retry, or install manually with `openclaw skills install @tinyfish/tinyfish " +
39
- "--global --acknowledge-clawhub-risk`." +
40
- SUPPORT_CHECK_DEBUG_HINT;
41
- const OPENCODE_MCP_ADD_UNAVAILABLE_MESSAGE = "Could not confirm this OpenCode installation supports one-command MCP setup: `opencode mcp " +
42
- "add --help` did not list `--url`. Update OpenCode and retry, or add TinyFish manually with " +
43
- "`opencode mcp add`." +
44
- SUPPORT_CHECK_DEBUG_HINT;
45
- // OpenCode is model-agnostic (unlike Claude Code / Codex), so a fresh install can default to a
46
- // model with no tool support — TinyFish runs entirely on tool calls, so it would fail there.
47
- const OPENCODE_MODEL_NOTE = "Note: TinyFish runs on tool calls, so OpenCode needs a model that supports tool use. Image-only " +
48
- 'models (e.g. Nano Banana Pro) will show "No endpoints found that support tool use" — switch ' +
49
- "OpenCode's model if the walkthrough can't start.";
50
16
  const TINYFISH_CLI_NOT_FOUND_MESSAGE = "TinyFish CLI installed but is not available on PATH. Open a new terminal and retry.";
51
17
  const TINYFISH_CLI_INSTALL_SPEC = `${TINYFISH_CLI_PACKAGE}@latest`;
52
18
  export const UPGRADE_HINT = "Run `tinyfish upgrade` any time to update the CLI and skill.";
@@ -54,174 +20,6 @@ export const UPGRADE_HINT = "Run `tinyfish upgrade` any time to update the CLI a
54
20
  const SKILLS_CLI_PACKAGE = "skills@1.5.15";
55
21
  const TINYFISH_WEB_SKILL_SOURCE = "tinyfish-io/tinyfish-cookbook";
56
22
  const TINYFISH_WEB_SKILL = "use-tinyfish";
57
- const OPENCLAW_SKILL = "@tinyfish/tinyfish";
58
- // --force makes this an unconditional overwrite, so the same call installs and refreshes.
59
- const OPENCLAW_SKILL_INSTALL_ARGS = [
60
- "skills",
61
- "install",
62
- OPENCLAW_SKILL,
63
- "--global",
64
- "--force",
65
- "--acknowledge-clawhub-risk",
66
- ];
67
- export const DEFAULT_ONBOARDING_PROMPT = "I just connected TinyFish. Call the guide_next_step tool now to begin. Then follow its " +
68
- "instructions one step at a time. Ask for my input and wait for my reply before each subsequent " +
69
- "TinyFish tool call.";
70
- export const OPENCLAW_ONBOARDING_PROMPT = "I just installed the TinyFish skill. Guide me through it interactively: first ask what topic I " +
71
- "want to search and wait for my reply before using TinyFish Search. Show me the results, ask " +
72
- "which result I want to read, and wait before using TinyFish Fetch. Then ask what browser task " +
73
- "I want to complete and wait before using TinyFish Agent. Never skip ahead or choose for me.";
74
- const CLAUDE_CODE = {
75
- command: "claude",
76
- connectClient: "claude-code",
77
- skillAgent: "claude-code",
78
- displayName: "Claude Code",
79
- supportCheck: {
80
- args: ["mcp", "--help"],
81
- patterns: [/^\s*add(?:\s|\[)/m],
82
- optionalPatterns: [/^\s*login(?:\s|\[)/m],
83
- unavailableMessage: MCP_ADD_UNAVAILABLE_MESSAGE,
84
- },
85
- headerAuthSupported: true,
86
- loginArgs: ["mcp", "login", "tinyfish"],
87
- degradedAuthNotes: {
88
- keyed: CLAUDE_CODE_KEYED_FALLBACK_NOTE,
89
- deferred: CLAUDE_CODE_DEFERRED_AUTH_NOTE,
90
- },
91
- // Project scope is shared in .mcp.json; a user setup command must not rewrite it.
92
- removals: [
93
- { args: ["mcp", "remove", "tinyfish", "--scope", "user"], label: "user TinyFish registration" },
94
- {
95
- args: ["mcp", "remove", "tinyfish", "--scope", "local"],
96
- label: "local TinyFish registration",
97
- },
98
- ],
99
- addArgs: (mcpUrl) => ["mcp", "add", "--scope", "user", "--transport", "http", "tinyfish", mcpUrl],
100
- };
101
- function launchCodexWalkthrough() {
102
- const deepLink = new URL("codex://new");
103
- deepLink.searchParams.set("prompt", DEFAULT_ONBOARDING_PROMPT);
104
- deepLink.searchParams.set("path", process.cwd());
105
- const [command, args] = process.platform === "darwin"
106
- ? ["open", [deepLink.toString()]]
107
- : process.platform === "win32"
108
- ? ["cmd", ["/c", "start", "", deepLink.toString()]]
109
- : ["xdg-open", [deepLink.toString()]];
110
- const result = spawn.sync(command, args, { stdio: "ignore" });
111
- if (result.error || result.status !== 0) {
112
- throw new Error("Could not open Codex", { cause: result.error });
113
- }
114
- errLine("Codex opened with the TinyFish walkthrough ready. Send the prompt to start.");
115
- }
116
- const CODEX = {
117
- command: "codex",
118
- connectClient: "codex",
119
- skillAgent: "codex",
120
- displayName: "Codex",
121
- supportCheck: {
122
- args: ["mcp", "add", "--help"],
123
- patterns: [/--oauth-resource(?:\s|<)/],
124
- unavailableMessage: CODEX_OAUTH_RESOURCE_UNAVAILABLE_MESSAGE,
125
- },
126
- launchWalkthrough: launchCodexWalkthrough,
127
- probeAuthenticated: codexOauthCompleted,
128
- // Retry only: running it after a finished inline OAuth is a second browser hop.
129
- loginArgs: ["mcp", "login", "tinyfish"],
130
- removals: [{ args: ["mcp", "remove", "tinyfish"], label: "TinyFish registration from Codex" }],
131
- addArgs: (mcpUrl, oauthResource) => [
132
- "mcp",
133
- "add",
134
- "tinyfish",
135
- "--url",
136
- mcpUrl,
137
- "--oauth-resource",
138
- oauthResource,
139
- ],
140
- };
141
- function launchHermesWalkthrough() {
142
- const seedResult = spawn.sync("hermes", ["chat", "-Q", "-q", DEFAULT_ONBOARDING_PROMPT], {
143
- encoding: "utf8",
144
- timeout: HERMES_SEED_TIMEOUT_MS,
145
- });
146
- if (seedResult.error || seedResult.status !== 0) {
147
- throwIfInterrupted(seedResult);
148
- throw new Error("Could not start the TinyFish walkthrough in Hermes", {
149
- cause: seedResult.error,
150
- });
151
- }
152
- // A colourised id would carry its trailing escape sequence into `--resume` (PF-3452).
153
- const sessionId = sanitizeLine(seedResult.stderr ?? "").match(/session_id:\s*([^\s]+)/i)?.[1];
154
- if (!sessionId) {
155
- throw new Error("Hermes did not return a walkthrough session ID");
156
- }
157
- const result = spawn.sync("hermes", ["--resume", sessionId], { stdio: "inherit" });
158
- if (result.error) {
159
- throw new Error("Could not launch Hermes", { cause: result.error });
160
- }
161
- if (result.signal === "SIGINT" || result.signal === "SIGTERM")
162
- return;
163
- if (result.status !== 0) {
164
- throw new Error(`Hermes walkthrough exited with status ${result.status ?? "unknown"}`);
165
- }
166
- }
167
- const HERMES = {
168
- command: "hermes",
169
- connectClient: "hermes",
170
- skillAgent: "hermes-agent",
171
- displayName: "Hermes",
172
- supportCheck: {
173
- args: ["mcp", "add", "--help"],
174
- patterns: [/--auth\s+\{[^}]*oauth[^}]*\}/],
175
- unavailableMessage: HERMES_OAUTH_UNAVAILABLE_MESSAGE,
176
- },
177
- removals: [{ args: ["mcp", "remove", "tinyfish"], label: "TinyFish registration from Hermes" }],
178
- // Hermes completes OAuth while adding the server; a separate `mcp login` would authenticate twice.
179
- addArgs: (mcpUrl) => ["mcp", "add", "tinyfish", "--url", mcpUrl, "--auth", "oauth"],
180
- launchWalkthrough: launchHermesWalkthrough,
181
- };
182
- // OpenCode's TUI takes a positional as a project directory, so a bare `opencode "<prompt>"`
183
- // would be read as a folder. The `--prompt` flag seeds the interactive TUI with a first message
184
- // (opencode.ai/docs/cli), so the onboarding guide fires just like the other agents.
185
- function launchOpencode() {
186
- const result = spawn.sync("opencode", ["--prompt", DEFAULT_ONBOARDING_PROMPT], {
187
- stdio: "inherit",
188
- });
189
- if (result.error) {
190
- throw new Error("Could not launch OpenCode", { cause: result.error });
191
- }
192
- if (result.signal === "SIGINT" || result.signal === "SIGTERM")
193
- return;
194
- if (result.status !== 0) {
195
- throw new Error(`OpenCode exited with status ${result.status ?? "unknown"}`);
196
- }
197
- }
198
- const OPENCODE = {
199
- command: "opencode",
200
- connectClient: "opencode",
201
- skillAgent: "opencode",
202
- displayName: "OpenCode",
203
- supportCheck: {
204
- args: ["mcp", "add", "--help"],
205
- patterns: [/--url(?:\s|$)/m],
206
- unavailableMessage: OPENCODE_MCP_ADD_UNAVAILABLE_MESSAGE,
207
- },
208
- // `opencode mcp add` upserts by name and there is no `opencode mcp remove`, so no cleanup step.
209
- removals: [],
210
- // OpenCode writes ~/.config/opencode/opencode.jsonc itself; `mcp auth` is the separate OAuth step.
211
- addArgs: (mcpUrl) => ["mcp", "add", "tinyfish", "--url", mcpUrl],
212
- loginArgs: ["mcp", "auth", "tinyfish"],
213
- launchWalkthrough: launchOpencode,
214
- postConnectNote: OPENCODE_MODEL_NOTE,
215
- };
216
- const OPENCLAW = {
217
- command: "openclaw",
218
- displayName: "OpenClaw",
219
- supportCheck: {
220
- args: ["skills", "install", "--help"],
221
- patterns: [/--global(?:\s|$)/, /--acknowledge-clawhub-risk(?:\s|$)/],
222
- unavailableMessage: OPENCLAW_SKILL_UNAVAILABLE_MESSAGE,
223
- },
224
- };
225
23
  export function installTinyFishCli() {
226
24
  errLine("Installing the TinyFish CLI...");
227
25
  const result = spawn.sync("npm", ["install", "--global", TINYFISH_CLI_INSTALL_SPEC], {
@@ -407,38 +205,6 @@ function removeExistingRegistration(client, removal) {
407
205
  }
408
206
  throw new Error(`Could not remove existing ${removal.label}: ${details}`);
409
207
  }
410
- function launchNativeMcpClient(client) {
411
- errLine(`Starting the TinyFish walkthrough in ${client.displayName}...`);
412
- if (client.launchWalkthrough) {
413
- client.launchWalkthrough();
414
- return true;
415
- }
416
- const result = spawn.sync(client.command, [DEFAULT_ONBOARDING_PROMPT], { stdio: "inherit" });
417
- if (result.error) {
418
- throw new Error(`Could not launch ${client.displayName}`, { cause: result.error });
419
- }
420
- if (result.signal === "SIGINT" || result.signal === "SIGTERM")
421
- return false;
422
- if (result.status !== 0) {
423
- throw new Error(`${client.displayName} walkthrough exited with status ${result.status ?? "unknown"}`);
424
- }
425
- return true;
426
- }
427
- function launchOpenClawWalkthrough() {
428
- errLine("Starting the TinyFish walkthrough in OpenClaw...");
429
- const result = spawn.sync("openclaw", ["chat", "--message", OPENCLAW_ONBOARDING_PROMPT], {
430
- stdio: "inherit",
431
- });
432
- if (result.error) {
433
- throw new Error("Could not launch OpenClaw", { cause: result.error });
434
- }
435
- if (result.signal === "SIGINT" || result.signal === "SIGTERM")
436
- return false;
437
- if (result.status !== 0) {
438
- throw new Error(`OpenClaw walkthrough exited with status ${result.status ?? "unknown"}`);
439
- }
440
- return true;
441
- }
442
208
  async function connectNativeMcpClient(client, options) {
443
209
  const telemetry = createConnectTelemetry(options.mcpUrl, client.connectClient, options);
444
210
  const state = { stage: "prerequisite_check", settled: false };
@@ -0,0 +1,33 @@
1
+ import { type AgentClient, type SupportedCommand } from "./connect-runtime.js";
2
+ export declare const OPENCLAW_SKILL_INSTALL_ARGS: readonly string[];
3
+ export declare const DEFAULT_ONBOARDING_PROMPT: string;
4
+ export declare const OPENCLAW_ONBOARDING_PROMPT: string;
5
+ export interface NativeMcpClient extends SupportedCommand {
6
+ connectClient: Exclude<AgentClient, "openclaw">;
7
+ skillAgent: "claude-code" | "codex" | "hermes-agent" | "opencode";
8
+ /** `mcp add --header` support: a stored TinyFish key replaces the OAuth login. */
9
+ headerAuthSupported?: boolean;
10
+ loginArgs?: string[];
11
+ /** Replaces the `loginArgs` step when `supportCheck.optionalPatterns` miss. */
12
+ degradedAuthNotes?: {
13
+ keyed: string;
14
+ deferred: string;
15
+ };
16
+ /** Did the OAuth inside `mcp add` finish? undefined when the client cannot say. */
17
+ probeAuthenticated?: () => boolean | undefined;
18
+ removals: {
19
+ args: string[];
20
+ label: string;
21
+ }[];
22
+ addArgs: (mcpUrl: string, oauthResource: string) => string[];
23
+ launchWalkthrough?: () => void;
24
+ /** Printed after a successful connect, on both the launch and non-launch paths. */
25
+ postConnectNote?: string;
26
+ }
27
+ export declare const CLAUDE_CODE: NativeMcpClient;
28
+ export declare const CODEX: NativeMcpClient;
29
+ export declare const HERMES: NativeMcpClient;
30
+ export declare const OPENCODE: NativeMcpClient;
31
+ export declare const OPENCLAW: SupportedCommand;
32
+ export declare function launchNativeMcpClient(client: NativeMcpClient): boolean;
33
+ export declare function launchOpenClawWalkthrough(): boolean;
@@ -0,0 +1,238 @@
1
+ import spawn from "cross-spawn";
2
+ import { errLine, sanitizeLine } from "./output.js";
3
+ import { throwIfInterrupted } from "./connect-runtime.js";
4
+ import { codexOauthCompleted } from "./registration-detect.js";
5
+ const HERMES_SEED_TIMEOUT_MS = 120_000;
6
+ // An old install is only one reason a flag can go unseen, so no message asserts the cause.
7
+ const SUPPORT_CHECK_DEBUG_HINT = " Set TINYFISH_DEBUG=1 and retry to print the help output TinyFish read.";
8
+ const MCP_ADD_UNAVAILABLE_MESSAGE = "Could not confirm this Claude Code installation exposes `claude mcp add`: `claude mcp " +
9
+ "--help` did not list it. Update Claude Code with `claude update` and retry." +
10
+ SUPPORT_CHECK_DEBUG_HINT;
11
+ // `claude mcp login` only exists upstream from Claude Code 2.1.186; older installs still register.
12
+ const CLAUDE_CODE_KEYED_FALLBACK_NOTE = "Using your stored TinyFish API key: this Claude Code predates one-command sign-in " +
13
+ "(`claude mcp login`), so no browser sign-in is needed.";
14
+ const CLAUDE_CODE_DEFERRED_AUTH_NOTE = "TinyFish is registered in Claude Code but not signed in: this Claude Code predates " +
15
+ "one-command sign-in (`claude mcp login`). Open Claude Code and run `/mcp` to sign in to " +
16
+ "TinyFish. `claude update` gets you one-command sign-in.";
17
+ const CODEX_OAUTH_RESOURCE_UNAVAILABLE_MESSAGE = "Could not confirm this Codex installation supports one-command MCP authentication: `codex " +
18
+ "mcp add --help` did not list `--oauth-resource`. Update Codex and retry, or add TinyFish " +
19
+ "manually with `codex mcp add`." +
20
+ SUPPORT_CHECK_DEBUG_HINT;
21
+ const HERMES_OAUTH_UNAVAILABLE_MESSAGE = "Could not confirm this Hermes installation supports one-command MCP authentication: `hermes " +
22
+ "mcp add --help` did not list `--auth oauth`. Update Hermes and retry, or add TinyFish " +
23
+ "manually with `hermes mcp add`." +
24
+ SUPPORT_CHECK_DEBUG_HINT;
25
+ const OPENCLAW_SKILL_UNAVAILABLE_MESSAGE = "Could not confirm this OpenClaw installation supports global skill installation: `openclaw " +
26
+ "skills install --help` did not list `--global` and `--acknowledge-clawhub-risk`. Update " +
27
+ "OpenClaw and retry, or install manually with `openclaw skills install @tinyfish/tinyfish " +
28
+ "--global --acknowledge-clawhub-risk`." +
29
+ SUPPORT_CHECK_DEBUG_HINT;
30
+ const OPENCODE_MCP_ADD_UNAVAILABLE_MESSAGE = "Could not confirm this OpenCode installation supports one-command MCP setup: `opencode mcp " +
31
+ "add --help` did not list `--url`. Update OpenCode and retry, or add TinyFish manually with " +
32
+ "`opencode mcp add`." +
33
+ SUPPORT_CHECK_DEBUG_HINT;
34
+ // OpenCode is model-agnostic (unlike Claude Code / Codex), so a fresh install can default to a
35
+ // model with no tool support — TinyFish runs entirely on tool calls, so it would fail there.
36
+ const OPENCODE_MODEL_NOTE = "Note: TinyFish runs on tool calls, so OpenCode needs a model that supports tool use. Image-only " +
37
+ 'models (e.g. Nano Banana Pro) will show "No endpoints found that support tool use" — switch ' +
38
+ "OpenCode's model if the walkthrough can't start.";
39
+ const OPENCLAW_SKILL = "@tinyfish/tinyfish";
40
+ // --force makes this an unconditional overwrite, so the same call installs and refreshes.
41
+ export const OPENCLAW_SKILL_INSTALL_ARGS = [
42
+ "skills",
43
+ "install",
44
+ OPENCLAW_SKILL,
45
+ "--global",
46
+ "--force",
47
+ "--acknowledge-clawhub-risk",
48
+ ];
49
+ export const DEFAULT_ONBOARDING_PROMPT = "I just connected TinyFish. Call the guide_next_step tool now to begin. Then follow its " +
50
+ "instructions one step at a time. Ask for my input and wait for my reply before each subsequent " +
51
+ "TinyFish tool call.";
52
+ export const OPENCLAW_ONBOARDING_PROMPT = "I just installed the TinyFish skill. Guide me through it interactively: first ask what topic I " +
53
+ "want to search and wait for my reply before using TinyFish Search. Show me the results, ask " +
54
+ "which result I want to read, and wait before using TinyFish Fetch. Then ask what browser task " +
55
+ "I want to complete and wait before using TinyFish Agent. Never skip ahead or choose for me.";
56
+ export const CLAUDE_CODE = {
57
+ command: "claude",
58
+ connectClient: "claude-code",
59
+ skillAgent: "claude-code",
60
+ displayName: "Claude Code",
61
+ supportCheck: {
62
+ args: ["mcp", "--help"],
63
+ patterns: [/^\s*add(?:\s|\[)/m],
64
+ optionalPatterns: [/^\s*login(?:\s|\[)/m],
65
+ unavailableMessage: MCP_ADD_UNAVAILABLE_MESSAGE,
66
+ },
67
+ headerAuthSupported: true,
68
+ loginArgs: ["mcp", "login", "tinyfish"],
69
+ degradedAuthNotes: {
70
+ keyed: CLAUDE_CODE_KEYED_FALLBACK_NOTE,
71
+ deferred: CLAUDE_CODE_DEFERRED_AUTH_NOTE,
72
+ },
73
+ // Project scope is shared in .mcp.json; a user setup command must not rewrite it.
74
+ removals: [
75
+ { args: ["mcp", "remove", "tinyfish", "--scope", "user"], label: "user TinyFish registration" },
76
+ {
77
+ args: ["mcp", "remove", "tinyfish", "--scope", "local"],
78
+ label: "local TinyFish registration",
79
+ },
80
+ ],
81
+ addArgs: (mcpUrl) => ["mcp", "add", "--scope", "user", "--transport", "http", "tinyfish", mcpUrl],
82
+ };
83
+ function launchCodexWalkthrough() {
84
+ const deepLink = new URL("codex://new");
85
+ deepLink.searchParams.set("prompt", DEFAULT_ONBOARDING_PROMPT);
86
+ deepLink.searchParams.set("path", process.cwd());
87
+ const [command, args] = process.platform === "darwin"
88
+ ? ["open", [deepLink.toString()]]
89
+ : process.platform === "win32"
90
+ ? ["cmd", ["/c", "start", "", deepLink.toString()]]
91
+ : ["xdg-open", [deepLink.toString()]];
92
+ const result = spawn.sync(command, args, { stdio: "ignore" });
93
+ if (result.error || result.status !== 0) {
94
+ throw new Error("Could not open Codex", { cause: result.error });
95
+ }
96
+ errLine("Codex opened with the TinyFish walkthrough ready. Send the prompt to start.");
97
+ }
98
+ export const CODEX = {
99
+ command: "codex",
100
+ connectClient: "codex",
101
+ skillAgent: "codex",
102
+ displayName: "Codex",
103
+ supportCheck: {
104
+ args: ["mcp", "add", "--help"],
105
+ patterns: [/--oauth-resource(?:\s|<)/],
106
+ unavailableMessage: CODEX_OAUTH_RESOURCE_UNAVAILABLE_MESSAGE,
107
+ },
108
+ launchWalkthrough: launchCodexWalkthrough,
109
+ probeAuthenticated: codexOauthCompleted,
110
+ // Retry only: running it after a finished inline OAuth is a second browser hop.
111
+ loginArgs: ["mcp", "login", "tinyfish"],
112
+ removals: [{ args: ["mcp", "remove", "tinyfish"], label: "TinyFish registration from Codex" }],
113
+ addArgs: (mcpUrl, oauthResource) => [
114
+ "mcp",
115
+ "add",
116
+ "tinyfish",
117
+ "--url",
118
+ mcpUrl,
119
+ "--oauth-resource",
120
+ oauthResource,
121
+ ],
122
+ };
123
+ function launchHermesWalkthrough() {
124
+ const seedResult = spawn.sync("hermes", ["chat", "-Q", "-q", DEFAULT_ONBOARDING_PROMPT], {
125
+ encoding: "utf8",
126
+ timeout: HERMES_SEED_TIMEOUT_MS,
127
+ });
128
+ if (seedResult.error || seedResult.status !== 0) {
129
+ throwIfInterrupted(seedResult);
130
+ throw new Error("Could not start the TinyFish walkthrough in Hermes", {
131
+ cause: seedResult.error,
132
+ });
133
+ }
134
+ // A colourised id would carry its trailing escape sequence into `--resume` (PF-3452).
135
+ const sessionId = sanitizeLine(seedResult.stderr ?? "").match(/session_id:\s*([^\s]+)/i)?.[1];
136
+ if (!sessionId) {
137
+ throw new Error("Hermes did not return a walkthrough session ID");
138
+ }
139
+ const result = spawn.sync("hermes", ["--resume", sessionId], { stdio: "inherit" });
140
+ if (result.error) {
141
+ throw new Error("Could not launch Hermes", { cause: result.error });
142
+ }
143
+ if (result.signal === "SIGINT" || result.signal === "SIGTERM")
144
+ return;
145
+ if (result.status !== 0) {
146
+ throw new Error(`Hermes walkthrough exited with status ${result.status ?? "unknown"}`);
147
+ }
148
+ }
149
+ export const HERMES = {
150
+ command: "hermes",
151
+ connectClient: "hermes",
152
+ skillAgent: "hermes-agent",
153
+ displayName: "Hermes",
154
+ supportCheck: {
155
+ args: ["mcp", "add", "--help"],
156
+ patterns: [/--auth\s+\{[^}]*oauth[^}]*\}/],
157
+ unavailableMessage: HERMES_OAUTH_UNAVAILABLE_MESSAGE,
158
+ },
159
+ removals: [{ args: ["mcp", "remove", "tinyfish"], label: "TinyFish registration from Hermes" }],
160
+ // Hermes completes OAuth while adding the server; a separate `mcp login` would authenticate twice.
161
+ addArgs: (mcpUrl) => ["mcp", "add", "tinyfish", "--url", mcpUrl, "--auth", "oauth"],
162
+ launchWalkthrough: launchHermesWalkthrough,
163
+ };
164
+ // OpenCode's TUI takes a positional as a project directory, so a bare `opencode "<prompt>"`
165
+ // would be read as a folder. The `--prompt` flag seeds the interactive TUI with a first message
166
+ // (opencode.ai/docs/cli), so the onboarding guide fires just like the other agents.
167
+ function launchOpencode() {
168
+ const result = spawn.sync("opencode", ["--prompt", DEFAULT_ONBOARDING_PROMPT], {
169
+ stdio: "inherit",
170
+ });
171
+ if (result.error) {
172
+ throw new Error("Could not launch OpenCode", { cause: result.error });
173
+ }
174
+ if (result.signal === "SIGINT" || result.signal === "SIGTERM")
175
+ return;
176
+ if (result.status !== 0) {
177
+ throw new Error(`OpenCode exited with status ${result.status ?? "unknown"}`);
178
+ }
179
+ }
180
+ export const OPENCODE = {
181
+ command: "opencode",
182
+ connectClient: "opencode",
183
+ skillAgent: "opencode",
184
+ displayName: "OpenCode",
185
+ supportCheck: {
186
+ args: ["mcp", "add", "--help"],
187
+ patterns: [/--url(?:\s|$)/m],
188
+ unavailableMessage: OPENCODE_MCP_ADD_UNAVAILABLE_MESSAGE,
189
+ },
190
+ // `opencode mcp add` upserts by name and there is no `opencode mcp remove`, so no cleanup step.
191
+ removals: [],
192
+ // OpenCode writes ~/.config/opencode/opencode.jsonc itself; `mcp auth` is the separate OAuth step.
193
+ addArgs: (mcpUrl) => ["mcp", "add", "tinyfish", "--url", mcpUrl],
194
+ loginArgs: ["mcp", "auth", "tinyfish"],
195
+ launchWalkthrough: launchOpencode,
196
+ postConnectNote: OPENCODE_MODEL_NOTE,
197
+ };
198
+ export const OPENCLAW = {
199
+ command: "openclaw",
200
+ displayName: "OpenClaw",
201
+ supportCheck: {
202
+ args: ["skills", "install", "--help"],
203
+ patterns: [/--global(?:\s|$)/, /--acknowledge-clawhub-risk(?:\s|$)/],
204
+ unavailableMessage: OPENCLAW_SKILL_UNAVAILABLE_MESSAGE,
205
+ },
206
+ };
207
+ export function launchNativeMcpClient(client) {
208
+ errLine(`Starting the TinyFish walkthrough in ${client.displayName}...`);
209
+ if (client.launchWalkthrough) {
210
+ client.launchWalkthrough();
211
+ return true;
212
+ }
213
+ const result = spawn.sync(client.command, [DEFAULT_ONBOARDING_PROMPT], { stdio: "inherit" });
214
+ if (result.error) {
215
+ throw new Error(`Could not launch ${client.displayName}`, { cause: result.error });
216
+ }
217
+ if (result.signal === "SIGINT" || result.signal === "SIGTERM")
218
+ return false;
219
+ if (result.status !== 0) {
220
+ throw new Error(`${client.displayName} walkthrough exited with status ${result.status ?? "unknown"}`);
221
+ }
222
+ return true;
223
+ }
224
+ export function launchOpenClawWalkthrough() {
225
+ errLine("Starting the TinyFish walkthrough in OpenClaw...");
226
+ const result = spawn.sync("openclaw", ["chat", "--message", OPENCLAW_ONBOARDING_PROMPT], {
227
+ stdio: "inherit",
228
+ });
229
+ if (result.error) {
230
+ throw new Error("Could not launch OpenClaw", { cause: result.error });
231
+ }
232
+ if (result.signal === "SIGINT" || result.signal === "SIGTERM")
233
+ return false;
234
+ if (result.status !== 0) {
235
+ throw new Error(`OpenClaw walkthrough exited with status ${result.status ?? "unknown"}`);
236
+ }
237
+ return true;
238
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tiny-fish/cli",
3
- "version": "0.19.1-next.177",
3
+ "version": "0.19.1-next.178",
4
4
  "description": "TinyFish CLI — run web automations from your terminal",
5
5
  "type": "module",
6
6
  "bin": {