@getpaseo/cli 0.7.2 → 0.8.0-beta.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/dist/cli.js +4 -3
- package/dist/commands/agent/index.js +3 -3
- package/dist/commands/agent/run.js +2 -0
- package/dist/commands/plugin/index.d.ts +1 -1
- package/dist/commands/plugin/index.js +11 -20
- package/dist/commands/plugin/scaffold.js +92 -14
- package/dist/commands/schedule/shared.js +2 -2
- package/dist/commands/terminal/capture.js +3 -3
- package/dist/commands/terminal/create.d.ts +1 -0
- package/dist/commands/terminal/create.js +13 -22
- package/dist/commands/terminal/index.js +9 -7
- package/dist/commands/terminal/kill.js +5 -5
- package/dist/commands/terminal/ls.d.ts +1 -0
- package/dist/commands/terminal/ls.js +6 -6
- package/dist/commands/terminal/schema.d.ts +2 -10
- package/dist/commands/terminal/schema.js +1 -7
- package/dist/commands/terminal/send-keys.js +5 -36
- package/dist/commands/terminal/shared.d.ts +3 -3
- package/dist/commands/terminal/shared.js +4 -3
- package/dist/commands/workspace/index.js +5 -0
- package/dist/commands/workspace/setup.d.ts +11 -0
- package/dist/commands/workspace/setup.js +41 -0
- package/dist/output/render.js +2 -1
- package/dist/output/with-output.js +4 -6
- package/dist/utils/client.d.ts +1 -0
- package/dist/utils/client.js +6 -2
- package/dist/utils/command-options.d.ts +1 -0
- package/dist/utils/command-options.js +8 -0
- package/package.json +4 -4
package/dist/cli.js
CHANGED
|
@@ -32,7 +32,7 @@ import { addImportOptions, runImportCommand } from "./commands/agent/import.js";
|
|
|
32
32
|
import { withOutput } from "./output/index.js";
|
|
33
33
|
import { runCloneCommand } from "./commands/clone.js";
|
|
34
34
|
import { onboardCommand } from "./commands/onboard.js";
|
|
35
|
-
import { addDaemonHostOption, addJsonAndDaemonHostOptions, addJsonOption, } from "./utils/command-options.js";
|
|
35
|
+
import { addDaemonHostOption, addJsonAndDaemonHostOptions, addJsonOption, withGlobalOptions, } from "./utils/command-options.js";
|
|
36
36
|
import { resolveCliVersion } from "./version.js";
|
|
37
37
|
const VERSION = resolveCliVersion();
|
|
38
38
|
function resolveHostnamesOption(hostnames, allowedHosts) {
|
|
@@ -54,6 +54,7 @@ export function createCli() {
|
|
|
54
54
|
.option("-q, --quiet", "minimal output (IDs only)")
|
|
55
55
|
.option("--no-headers", "omit table headers")
|
|
56
56
|
.option("--no-color", "disable colored output");
|
|
57
|
+
addDaemonHostOption(program);
|
|
57
58
|
// Primary agent commands (top-level)
|
|
58
59
|
addJsonAndDaemonHostOptions(addLsOptions(program.command("ls"))).action(withOutput(runLsCommand));
|
|
59
60
|
addJsonAndDaemonHostOptions(addRunOptions(program.command("run"))).action(withOutput(runRunCommand));
|
|
@@ -65,8 +66,8 @@ export function createCli() {
|
|
|
65
66
|
.requiredOption("--dir <path>", "Parent directory to clone into (for example: ~/workspace)"))
|
|
66
67
|
.addOption(new Option("--protocol <protocol>", "Protocol for owner/repo shorthand repositories").choices(["https", "ssh"]))
|
|
67
68
|
.action(withOutput(runCloneCommand));
|
|
68
|
-
addDaemonHostOption(addAttachOptions(program.command("attach"))).action(runAttachCommand);
|
|
69
|
-
addDaemonHostOption(addLogsOptions(program.command("logs"))).action(runLogsCommand);
|
|
69
|
+
addDaemonHostOption(addAttachOptions(program.command("attach"))).action(withGlobalOptions(runAttachCommand));
|
|
70
|
+
addDaemonHostOption(addLogsOptions(program.command("logs"))).action(withGlobalOptions(runLogsCommand));
|
|
70
71
|
addJsonAndDaemonHostOptions(addStopOptions(program.command("stop"))).action(withOutput(runStopCommand));
|
|
71
72
|
addJsonAndDaemonHostOptions(addDeleteOptions(program.command("delete"))).action(withOutput(runDeleteCommand));
|
|
72
73
|
addJsonAndDaemonHostOptions(addSendOptions(program.command("send"))).action(withOutput(runSendCommand));
|
|
@@ -16,15 +16,15 @@ import { runUpdateCommand } from "./update.js";
|
|
|
16
16
|
import { runDetachCommand } from "./detach.js";
|
|
17
17
|
import { addOpenOptions, runOpenCommand } from "./open.js";
|
|
18
18
|
import { withOutput } from "../../output/index.js";
|
|
19
|
-
import { addDaemonHostOption, addJsonAndDaemonHostOptions, collectMultiple, } from "../../utils/command-options.js";
|
|
19
|
+
import { addDaemonHostOption, addJsonAndDaemonHostOptions, collectMultiple, withGlobalOptions, } from "../../utils/command-options.js";
|
|
20
20
|
export function createAgentCommand() {
|
|
21
21
|
const agent = new Command("agent").description("Manage agents (advanced operations)");
|
|
22
22
|
// Primary agent commands (same as top-level)
|
|
23
23
|
addJsonAndDaemonHostOptions(addLsOptions(agent.command("ls"))).action(withOutput(runLsCommand));
|
|
24
24
|
addJsonAndDaemonHostOptions(addRunOptions(agent.command("run"))).action(withOutput(runRunCommand));
|
|
25
25
|
addJsonAndDaemonHostOptions(addImportOptions(agent.command("import"))).action(withOutput(runImportCommand));
|
|
26
|
-
addDaemonHostOption(addAttachOptions(agent.command("attach"))).action(runAttachCommand);
|
|
27
|
-
addDaemonHostOption(addLogsOptions(agent.command("logs"))).action(runLogsCommand);
|
|
26
|
+
addDaemonHostOption(addAttachOptions(agent.command("attach"))).action(withGlobalOptions(runAttachCommand));
|
|
27
|
+
addDaemonHostOption(addLogsOptions(agent.command("logs"))).action(withGlobalOptions(runLogsCommand));
|
|
28
28
|
addJsonAndDaemonHostOptions(addOpenOptions(agent.command("open"))).action(withOutput(runOpenCommand));
|
|
29
29
|
addJsonAndDaemonHostOptions(addStopOptions(agent.command("stop"))).action(withOutput(runStopCommand));
|
|
30
30
|
addJsonAndDaemonHostOptions(addDeleteOptions(agent.command("delete"))).action(withOutput(runDeleteCommand));
|
|
@@ -410,6 +410,8 @@ async function resolveRunWorkspace(client, options, cwd) {
|
|
|
410
410
|
const branch = result.workspace.gitRuntime?.currentBranch;
|
|
411
411
|
const label = branch ? `${result.workspace.name} (${branch})` : result.workspace.name;
|
|
412
412
|
console.error(`Created workspace ${result.workspace.id} - ${label}`);
|
|
413
|
+
if (result.setupSkippedReason)
|
|
414
|
+
console.error(result.setupSkippedReason);
|
|
413
415
|
console.error("Tip: pass --workspace <id> (or set PASEO_WORKSPACE_ID) to run in an existing workspace.");
|
|
414
416
|
return { id: result.workspace.id, cwd: result.workspace.workspaceDirectory ?? cwd };
|
|
415
417
|
}
|
|
@@ -10,7 +10,7 @@ interface PluginOptions extends CommandOptions {
|
|
|
10
10
|
all?: boolean;
|
|
11
11
|
}
|
|
12
12
|
export declare function runPluginInitCommand(directory: string, options: PluginOptions, _command: Command): Promise<SingleResult<PluginScaffold>>;
|
|
13
|
-
export declare function runPluginListCommand(options: PluginOptions, _command: Command): Promise<ListResult<PluginListItem>>;
|
|
13
|
+
export declare function runPluginListCommand(pluginId: string | undefined, options: PluginOptions, _command: Command): Promise<ListResult<PluginListItem>>;
|
|
14
14
|
export declare function runPluginLogsCommand(pluginId: string, options: PluginOptions, _command: Command): Promise<ListResult<PluginLogEntry>>;
|
|
15
15
|
export declare function createPluginCommand(): Command;
|
|
16
16
|
export {};
|
|
@@ -11,6 +11,9 @@ const pluginSchema = {
|
|
|
11
11
|
{ header: "PLUGIN", field: "id", width: 20 },
|
|
12
12
|
{ header: "STATUS", field: "status", width: 10 },
|
|
13
13
|
{ header: "ENABLED", field: (plugin) => (plugin.enabled ? "yes" : "no"), width: 8 },
|
|
14
|
+
{ header: "SOURCE", field: (plugin) => plugin.source ?? "directory", width: 10 },
|
|
15
|
+
{ header: "COMMIT", field: (plugin) => shortCommit(plugin.commit), width: 14 },
|
|
16
|
+
{ header: "REF", field: (plugin) => plugin.ref ?? "-", width: 24 },
|
|
14
17
|
{ header: "DIRECTORY", field: "path", width: 40 },
|
|
15
18
|
{ header: "ERROR", field: (plugin) => plugin.error ?? "", width: 40 },
|
|
16
19
|
],
|
|
@@ -33,17 +36,6 @@ const pluginLogsSchema = {
|
|
|
33
36
|
function shortCommit(commit) {
|
|
34
37
|
return commit?.slice(0, 12) ?? "-";
|
|
35
38
|
}
|
|
36
|
-
const pluginStatusSchema = {
|
|
37
|
-
idField: "id",
|
|
38
|
-
columns: [
|
|
39
|
-
{ header: "PLUGIN", field: "id", width: 20 },
|
|
40
|
-
{ header: "SOURCE", field: "source", width: 10 },
|
|
41
|
-
{ header: "CURRENT", field: (plugin) => shortCommit(plugin.currentCommit), width: 14 },
|
|
42
|
-
{ header: "LATEST", field: (plugin) => shortCommit(plugin.latestCommit), width: 14 },
|
|
43
|
-
{ header: "COMMITS", field: (plugin) => String(plugin.commitsBehind ?? 0), width: 8 },
|
|
44
|
-
{ header: "REF", field: (plugin) => plugin.ref ?? "-", width: 24 },
|
|
45
|
-
],
|
|
46
|
-
};
|
|
47
39
|
const pluginUpdateSchema = {
|
|
48
40
|
idField: "id",
|
|
49
41
|
columns: [
|
|
@@ -61,8 +53,11 @@ export async function runPluginInitCommand(directory, options, _command) {
|
|
|
61
53
|
schema: scaffoldSchema,
|
|
62
54
|
};
|
|
63
55
|
}
|
|
64
|
-
export async function runPluginListCommand(options, _command) {
|
|
65
|
-
const
|
|
56
|
+
export async function runPluginListCommand(pluginId, options, _command) {
|
|
57
|
+
const plugins = await withPluginManagementClient(options.host, (client) => client.listPlugins());
|
|
58
|
+
const data = pluginId ? plugins.filter((plugin) => plugin.id === pluginId) : plugins;
|
|
59
|
+
if (pluginId && data.length === 0)
|
|
60
|
+
throw new Error(`Plugin is not configured: ${pluginId}`);
|
|
66
61
|
return { type: "list", data, schema: pluginSchema };
|
|
67
62
|
}
|
|
68
63
|
export async function runPluginLogsCommand(pluginId, options, _command) {
|
|
@@ -90,10 +85,6 @@ async function install(source, options, _command) {
|
|
|
90
85
|
}));
|
|
91
86
|
return { type: "single", data, schema: pluginSchema };
|
|
92
87
|
}
|
|
93
|
-
async function status(pluginId, options, _command) {
|
|
94
|
-
const data = await withPluginSourceClient(options.host, (client) => client.getPluginSourceStatus(pluginId));
|
|
95
|
-
return { type: "list", data, schema: pluginStatusSchema };
|
|
96
|
-
}
|
|
97
88
|
async function update(pluginId, options, _command) {
|
|
98
89
|
if ((pluginId === undefined) === (options.all !== true)) {
|
|
99
90
|
throw new Error("Choose one plugin ID or pass --all");
|
|
@@ -122,7 +113,8 @@ export function createPluginCommand() {
|
|
|
122
113
|
.description("Create a typecheckable local plugin")
|
|
123
114
|
.argument("<directory>")
|
|
124
115
|
.option("--id <id>", "Manifest plugin ID (defaults to the directory name)")).action(withOutput(runPluginInitCommand));
|
|
125
|
-
addJsonAndDaemonHostOptions(plugin.command("ls").description("List configured plugins")).action(withOutput(runPluginListCommand));
|
|
116
|
+
addJsonAndDaemonHostOptions(plugin.command("ls").description("List configured plugins").argument("[id]")).action(withOutput(runPluginListCommand));
|
|
117
|
+
addJsonAndDaemonHostOptions(plugin.command("status", { hidden: true }).argument("[id]")).action(withOutput(runPluginListCommand));
|
|
126
118
|
addJsonAndDaemonHostOptions(plugin.command("logs").description("Show recent plugin output").argument("<id>")).action(withOutput(runPluginLogsCommand));
|
|
127
119
|
addJsonAndDaemonHostOptions(plugin
|
|
128
120
|
.command("install")
|
|
@@ -132,10 +124,9 @@ export function createPluginCommand() {
|
|
|
132
124
|
.option("--id <id>", "Runtime plugin ID (defaults to paseo-plugin.json id)")
|
|
133
125
|
.option("--ref <ref>", "Git branch, tag, or commit")
|
|
134
126
|
.option("--path <path>", "Legacy form of the :plugin/path source suffix")).action(withOutput(install));
|
|
135
|
-
addJsonAndDaemonHostOptions(plugin.command("status").description("Check plugin source updates").argument("[id]")).action(withOutput(status));
|
|
136
127
|
addJsonAndDaemonHostOptions(plugin
|
|
137
128
|
.command("update")
|
|
138
|
-
.description("
|
|
129
|
+
.description("Fetch and install Git-managed plugin updates")
|
|
139
130
|
.argument("[id]")
|
|
140
131
|
.option("--all", "Update every Git-managed plugin")).action(withOutput(update));
|
|
141
132
|
for (const action of ["reload", "enable", "disable"]) {
|
|
@@ -7,7 +7,8 @@ const TSCONFIG = {
|
|
|
7
7
|
target: "ES2020",
|
|
8
8
|
module: "ESNext",
|
|
9
9
|
moduleResolution: "Bundler",
|
|
10
|
-
lib: ["ES2023"
|
|
10
|
+
lib: ["ES2023"],
|
|
11
|
+
types: ["react"],
|
|
11
12
|
jsx: "react-jsx",
|
|
12
13
|
strict: true,
|
|
13
14
|
skipLibCheck: true,
|
|
@@ -17,19 +18,56 @@ const TSCONFIG = {
|
|
|
17
18
|
},
|
|
18
19
|
include: ["**/*.ts", "**/*.tsx"],
|
|
19
20
|
};
|
|
20
|
-
const
|
|
21
|
-
import {
|
|
21
|
+
const CLIENT_ENTRY = `import type { PluginClientContext } from "@getpaseo/plugin/client";
|
|
22
|
+
import { GreetingSurface } from "./client/greeting";
|
|
22
23
|
|
|
23
|
-
export default function contribute(
|
|
24
|
-
|
|
24
|
+
export default function contribute(client: PluginClientContext) {
|
|
25
|
+
client.addSurface("greeting", GreetingSurface);
|
|
26
|
+
client.addSidebarItem({
|
|
27
|
+
id: "greeting",
|
|
28
|
+
title: "Greeting",
|
|
29
|
+
icon: "MessageCircle",
|
|
30
|
+
surface: "greeting",
|
|
31
|
+
});
|
|
25
32
|
return () => {};
|
|
26
33
|
}
|
|
27
34
|
`;
|
|
28
|
-
const
|
|
29
|
-
import
|
|
30
|
-
import {
|
|
35
|
+
const SERVER_ENTRY = `import type { PluginServerContext } from "@getpaseo/plugin/server";
|
|
36
|
+
import { createGreeting } from "./server/greeting";
|
|
37
|
+
import { greetingRpc } from "./shared/greeting";
|
|
31
38
|
|
|
32
|
-
export function
|
|
39
|
+
export default function contribute(server: PluginServerContext) {
|
|
40
|
+
server.handle(greetingRpc, createGreeting);
|
|
41
|
+
return () => {};
|
|
42
|
+
}
|
|
43
|
+
`;
|
|
44
|
+
const SHARED_GREETING = `import { defineRpc } from "@getpaseo/plugin";
|
|
45
|
+
import { z } from "zod";
|
|
46
|
+
|
|
47
|
+
export const greetingRpc = defineRpc({
|
|
48
|
+
name: "greeting.create",
|
|
49
|
+
input: z.object({ name: z.string() }),
|
|
50
|
+
output: z.object({ message: z.string() }),
|
|
51
|
+
});
|
|
52
|
+
`;
|
|
53
|
+
const SERVER_GREETING = `import type { RpcInput } from "@getpaseo/plugin";
|
|
54
|
+
import { greetingRpc } from "../shared/greeting";
|
|
55
|
+
|
|
56
|
+
export function createGreeting({ name }: RpcInput<typeof greetingRpc>) {
|
|
57
|
+
return { message: "Hello, " + name + "!" };
|
|
58
|
+
}
|
|
59
|
+
`;
|
|
60
|
+
const CLIENT_GREETING = `import type { PluginSurfaceProps } from "@getpaseo/plugin/client";
|
|
61
|
+
import { useRpc } from "@getpaseo/plugin/client";
|
|
62
|
+
import { useMutation } from "@tanstack/react-query";
|
|
63
|
+
import { useMemo } from "react";
|
|
64
|
+
import { Pressable, Text, View } from "react-native";
|
|
65
|
+
import { greetingRpc } from "../shared/greeting";
|
|
66
|
+
import { openExternal } from "./web";
|
|
67
|
+
|
|
68
|
+
export function GreetingSurface({ theme, layout }: PluginSurfaceProps) {
|
|
69
|
+
const createGreeting = useRpc(greetingRpc);
|
|
70
|
+
const greeting = useMutation({ mutationFn: createGreeting });
|
|
33
71
|
const styles = useMemo(
|
|
34
72
|
() => ({
|
|
35
73
|
screen: {
|
|
@@ -38,16 +76,47 @@ export function MainSurface({ theme, layout }: PluginSurfaceProps) {
|
|
|
38
76
|
backgroundColor: theme.colors.surface0,
|
|
39
77
|
},
|
|
40
78
|
text: { color: theme.colors.foreground },
|
|
79
|
+
button: { padding: 12, backgroundColor: theme.colors.accent },
|
|
80
|
+
buttonText: { color: theme.colors.accentForeground },
|
|
41
81
|
}),
|
|
42
82
|
[theme, layout.compact],
|
|
43
83
|
);
|
|
44
84
|
return (
|
|
45
85
|
<View style={styles.screen}>
|
|
46
|
-
<Text style={styles.text}>
|
|
86
|
+
<Text style={styles.text}>{greeting.data?.message ?? "Ask the daemon for a greeting."}</Text>
|
|
87
|
+
<Pressable
|
|
88
|
+
accessibilityRole="button"
|
|
89
|
+
accessibilityLabel="Create greeting"
|
|
90
|
+
style={styles.button}
|
|
91
|
+
onPress={() => greeting.mutate({ name: "Paseo" })}
|
|
92
|
+
>
|
|
93
|
+
<Text style={styles.buttonText}>Create greeting</Text>
|
|
94
|
+
</Pressable>
|
|
95
|
+
<Pressable
|
|
96
|
+
accessibilityRole="link"
|
|
97
|
+
accessibilityLabel="Open the Paseo website"
|
|
98
|
+
style={styles.button}
|
|
99
|
+
onPress={() => openExternal("https://paseo.sh")}
|
|
100
|
+
>
|
|
101
|
+
<Text style={styles.buttonText}>Open paseo.sh</Text>
|
|
102
|
+
</Pressable>
|
|
47
103
|
</View>
|
|
48
104
|
);
|
|
49
105
|
}
|
|
50
106
|
`;
|
|
107
|
+
const CLIENT_WEB = `import { Linking, Platform } from "react-native";
|
|
108
|
+
|
|
109
|
+
// This plugin typechecks without the DOM library. Declare only what this module uses.
|
|
110
|
+
declare const window: { open(url: string, target: string, features: string): unknown };
|
|
111
|
+
|
|
112
|
+
export async function openExternal(url: string): Promise<void> {
|
|
113
|
+
if (Platform.OS === "web") {
|
|
114
|
+
window.open(url, "_blank", "noopener,noreferrer");
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
await Linking.openURL(url);
|
|
118
|
+
}
|
|
119
|
+
`;
|
|
51
120
|
export async function scaffoldPluginDirectory(targetDirectory, requestedId) {
|
|
52
121
|
const directory = path.resolve(targetDirectory);
|
|
53
122
|
const id = PluginIdSchema.parse(requestedId ?? path.basename(directory));
|
|
@@ -56,13 +125,14 @@ export async function scaffoldPluginDirectory(targetDirectory, requestedId) {
|
|
|
56
125
|
if (existing.length > 0) {
|
|
57
126
|
throw new Error(`Plugin directory must be empty: ${directory}`);
|
|
58
127
|
}
|
|
128
|
+
const version = resolveCliVersion();
|
|
59
129
|
const packageJson = {
|
|
60
130
|
name: id,
|
|
61
131
|
private: true,
|
|
62
132
|
version: "0.0.0",
|
|
63
133
|
scripts: { typecheck: "tsc --noEmit" },
|
|
64
134
|
devDependencies: {
|
|
65
|
-
"@getpaseo/plugin":
|
|
135
|
+
"@getpaseo/plugin": version,
|
|
66
136
|
"@tanstack/react-query": "^5.90.11",
|
|
67
137
|
"@types/react": "~19.2.0",
|
|
68
138
|
react: "19.1.0",
|
|
@@ -72,12 +142,20 @@ export async function scaffoldPluginDirectory(targetDirectory, requestedId) {
|
|
|
72
142
|
},
|
|
73
143
|
};
|
|
74
144
|
const files = new Map([
|
|
75
|
-
[
|
|
145
|
+
[
|
|
146
|
+
"paseo-plugin.json",
|
|
147
|
+
`${JSON.stringify({ id, requirements: { paseo: `>=${version}` } }, null, 2)}\n`,
|
|
148
|
+
],
|
|
76
149
|
["package.json", `${JSON.stringify(packageJson, null, 2)}\n`],
|
|
77
150
|
["tsconfig.json", `${JSON.stringify(TSCONFIG, null, 2)}\n`],
|
|
78
|
-
["index.
|
|
79
|
-
["
|
|
151
|
+
["index.client.tsx", CLIENT_ENTRY],
|
|
152
|
+
["index.server.ts", SERVER_ENTRY],
|
|
153
|
+
["shared/greeting.ts", SHARED_GREETING],
|
|
154
|
+
["server/greeting.ts", SERVER_GREETING],
|
|
155
|
+
["client/greeting.tsx", CLIENT_GREETING],
|
|
156
|
+
["client/web.ts", CLIENT_WEB],
|
|
80
157
|
]);
|
|
158
|
+
await Promise.all(["shared", "server", "client"].map((name) => mkdir(path.join(directory, name))));
|
|
81
159
|
await Promise.all([...files].map(([filename, contents]) => writeFile(path.join(directory, filename), contents, { flag: "wx" })));
|
|
82
160
|
return { id, directory };
|
|
83
161
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { connectToDaemon, getDaemonHost } from "../../utils/client.js";
|
|
1
|
+
import { connectToDaemon, getDaemonHost, getExplicitDaemonHost } from "../../utils/client.js";
|
|
2
2
|
import { parseDuration } from "../../utils/duration.js";
|
|
3
3
|
import { resolveProviderAndModel } from "../../utils/provider-model.js";
|
|
4
4
|
import { everyMsToFiveFieldCron } from "@getpaseo/protocol/schedule/cadence";
|
|
@@ -116,7 +116,7 @@ export function parseScheduleCreateInput(options) {
|
|
|
116
116
|
};
|
|
117
117
|
}
|
|
118
118
|
const cwdInput = options.cwd?.trim();
|
|
119
|
-
if (options.host !== undefined && !cwdInput) {
|
|
119
|
+
if (getExplicitDaemonHost(options.host) !== undefined && !cwdInput) {
|
|
120
120
|
throw {
|
|
121
121
|
code: "MISSING_CWD",
|
|
122
122
|
message: "--cwd is required when --host is specified (the local working directory will not exist on the remote daemon)",
|
|
@@ -26,7 +26,7 @@ export async function runCaptureCommand(terminalId, _options, command) {
|
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
async function executeCaptureCommand(terminalId, options) {
|
|
29
|
-
const { client } = await connectTerminalClient(options.host);
|
|
29
|
+
const { client, close } = await connectTerminalClient(options.host);
|
|
30
30
|
try {
|
|
31
31
|
const resolvedId = await resolveTerminalId(client, terminalId);
|
|
32
32
|
if (!resolvedId) {
|
|
@@ -38,7 +38,7 @@ async function executeCaptureCommand(terminalId, options) {
|
|
|
38
38
|
}
|
|
39
39
|
const start = options.scrollback ? 0 : parseLineNumber("--start", options.start);
|
|
40
40
|
const end = parseLineNumber("--end", options.end);
|
|
41
|
-
return await client.
|
|
41
|
+
return await client.terminals.ref(resolvedId).capture({
|
|
42
42
|
...(start === undefined ? {} : { start }),
|
|
43
43
|
...(end === undefined ? {} : { end }),
|
|
44
44
|
stripAnsi: !options.ansi,
|
|
@@ -48,7 +48,7 @@ async function executeCaptureCommand(terminalId, options) {
|
|
|
48
48
|
throw toTerminalCommandError("TERMINAL_CAPTURE_FAILED", "capture terminal output", err);
|
|
49
49
|
}
|
|
50
50
|
finally {
|
|
51
|
-
await
|
|
51
|
+
await close().catch(() => { });
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
function parseLineNumber(flag, value) {
|
|
@@ -3,6 +3,7 @@ import type { SingleResult } from "../../output/index.js";
|
|
|
3
3
|
import { type TerminalCommandOptions } from "./shared.js";
|
|
4
4
|
import { type TerminalRow } from "./schema.js";
|
|
5
5
|
export interface TerminalCreateOptions extends TerminalCommandOptions {
|
|
6
|
+
workspace?: string;
|
|
6
7
|
cwd?: string;
|
|
7
8
|
name?: string;
|
|
8
9
|
}
|
|
@@ -1,30 +1,21 @@
|
|
|
1
1
|
import { connectTerminalClient, toTerminalCommandError, } from "./shared.js";
|
|
2
|
-
import { terminalSchema
|
|
2
|
+
import { terminalSchema } from "./schema.js";
|
|
3
3
|
export async function runCreateCommand(options, _command) {
|
|
4
|
-
const { client } = await connectTerminalClient(options.host);
|
|
5
|
-
const cwd = options.cwd ?? process.cwd();
|
|
4
|
+
const { client, close } = await connectTerminalClient(options.host);
|
|
6
5
|
try {
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
throw error;
|
|
14
|
-
}
|
|
15
|
-
const payload = await client.createTerminal(cwd, options.name, undefined, {
|
|
16
|
-
workspaceId: opened.workspace.id,
|
|
6
|
+
const cwd = options.cwd ?? (options.workspace ? undefined : process.cwd());
|
|
7
|
+
const workspaceId = options.workspace ?? (await client.workspaces.open(options.cwd ?? process.cwd())).id;
|
|
8
|
+
const terminal = await client.terminals.create({
|
|
9
|
+
workspaceId,
|
|
10
|
+
cwd,
|
|
11
|
+
name: options.name,
|
|
17
12
|
});
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
message: payload.error ?? "Failed to create terminal",
|
|
22
|
-
};
|
|
23
|
-
throw error;
|
|
24
|
-
}
|
|
13
|
+
const snapshot = terminal.current();
|
|
14
|
+
if (!snapshot)
|
|
15
|
+
throw new Error("The daemon did not create a terminal");
|
|
25
16
|
return {
|
|
26
17
|
type: "single",
|
|
27
|
-
data:
|
|
18
|
+
data: snapshot,
|
|
28
19
|
schema: terminalSchema,
|
|
29
20
|
};
|
|
30
21
|
}
|
|
@@ -32,7 +23,7 @@ export async function runCreateCommand(options, _command) {
|
|
|
32
23
|
throw toTerminalCommandError("TERMINAL_CREATE_FAILED", "create terminal", err);
|
|
33
24
|
}
|
|
34
25
|
finally {
|
|
35
|
-
await
|
|
26
|
+
await close().catch(() => { });
|
|
36
27
|
}
|
|
37
28
|
}
|
|
38
29
|
//# sourceMappingURL=create.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Command } from "commander";
|
|
1
|
+
import { Command, Option } from "commander";
|
|
2
2
|
import { withOutput } from "../../output/index.js";
|
|
3
|
-
import { addDaemonHostOption, addJsonAndDaemonHostOptions } from "../../utils/command-options.js";
|
|
3
|
+
import { addDaemonHostOption, addJsonAndDaemonHostOptions, withGlobalOptions, } from "../../utils/command-options.js";
|
|
4
4
|
import { runCaptureCommand } from "./capture.js";
|
|
5
5
|
import { runCreateCommand } from "./create.js";
|
|
6
6
|
import { runKillCommand } from "./kill.js";
|
|
@@ -11,12 +11,14 @@ export function createTerminalCommand() {
|
|
|
11
11
|
addJsonAndDaemonHostOptions(terminal
|
|
12
12
|
.command("ls")
|
|
13
13
|
.description("List terminals")
|
|
14
|
-
.
|
|
15
|
-
.option("--
|
|
14
|
+
.addOption(new Option("--all", "List terminals across all workspaces").conflicts(["cwd", "workspace"]))
|
|
15
|
+
.option("--workspace <id>", "Workspace ID")
|
|
16
|
+
.option("--cwd <path>", "Working directory")).action(withOutput(runLsCommand));
|
|
16
17
|
addJsonAndDaemonHostOptions(terminal
|
|
17
18
|
.command("create")
|
|
18
19
|
.description("Create a terminal")
|
|
19
|
-
.option("--
|
|
20
|
+
.option("--workspace <id>", "Workspace ID")
|
|
21
|
+
.option("--cwd <path>", "Working directory")
|
|
20
22
|
.option("--name <name>", "Terminal name")).action(withOutput(runCreateCommand));
|
|
21
23
|
addJsonAndDaemonHostOptions(terminal
|
|
22
24
|
.command("kill")
|
|
@@ -30,14 +32,14 @@ export function createTerminalCommand() {
|
|
|
30
32
|
.option("--end <n>", "Capture end line")
|
|
31
33
|
.option("-S, --scrollback", "Capture from the beginning of scrollback")
|
|
32
34
|
.option("--ansi", "Preserve ANSI escape codes")
|
|
33
|
-
.option("--json", "Output in JSON format")).action(runCaptureCommand);
|
|
35
|
+
.option("--json", "Output in JSON format")).action(withGlobalOptions(runCaptureCommand));
|
|
34
36
|
addDaemonHostOption(terminal
|
|
35
37
|
.command("send-keys")
|
|
36
38
|
.description("Send keys to a terminal")
|
|
37
39
|
.argument("<terminal-id>", "Terminal ID, ID prefix, or name")
|
|
38
40
|
.argument("<keys...>", "Keys to send")
|
|
39
41
|
.option("-l, --literal", "Send raw keys without interpreting special tokens")
|
|
40
|
-
.option("--json", "Output in JSON format")).action(runSendKeysCommand);
|
|
42
|
+
.option("--json", "Output in JSON format")).action(withGlobalOptions(runSendKeysCommand));
|
|
41
43
|
return terminal;
|
|
42
44
|
}
|
|
43
45
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { connectTerminalClient, resolveTerminalId, toTerminalCommandError, } from "./shared.js";
|
|
2
2
|
import { terminalKillSchema } from "./schema.js";
|
|
3
3
|
export async function runKillCommand(terminalId, options, _command) {
|
|
4
|
-
const { client } = await connectTerminalClient(options.host);
|
|
4
|
+
const { client, close } = await connectTerminalClient(options.host);
|
|
5
5
|
try {
|
|
6
6
|
const resolvedId = await requireTerminalId(client, terminalId);
|
|
7
|
-
|
|
7
|
+
await client.terminals.ref(resolvedId).kill();
|
|
8
8
|
return {
|
|
9
9
|
type: "single",
|
|
10
10
|
data: {
|
|
11
|
-
terminalId:
|
|
12
|
-
success:
|
|
11
|
+
terminalId: resolvedId,
|
|
12
|
+
success: true,
|
|
13
13
|
},
|
|
14
14
|
schema: terminalKillSchema,
|
|
15
15
|
};
|
|
@@ -18,7 +18,7 @@ export async function runKillCommand(terminalId, options, _command) {
|
|
|
18
18
|
throw toTerminalCommandError("TERMINAL_KILL_FAILED", "kill terminal", err);
|
|
19
19
|
}
|
|
20
20
|
finally {
|
|
21
|
-
await
|
|
21
|
+
await close().catch(() => { });
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
async function requireTerminalId(client, terminalId) {
|
|
@@ -3,6 +3,7 @@ import type { ListResult } from "../../output/index.js";
|
|
|
3
3
|
import { type TerminalCommandOptions } from "./shared.js";
|
|
4
4
|
import { type TerminalRow } from "./schema.js";
|
|
5
5
|
export interface TerminalLsOptions extends TerminalCommandOptions {
|
|
6
|
+
workspace?: string;
|
|
6
7
|
all?: boolean;
|
|
7
8
|
cwd?: string;
|
|
8
9
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { connectTerminalClient, toTerminalCommandError, } from "./shared.js";
|
|
2
|
-
import { terminalSchema
|
|
2
|
+
import { terminalSchema } from "./schema.js";
|
|
3
3
|
export async function runLsCommand(options, _command) {
|
|
4
|
-
const { client } = await connectTerminalClient(options.host);
|
|
5
|
-
const cwd = options.all ? undefined : (options.cwd ?? process.cwd());
|
|
4
|
+
const { client, close } = await connectTerminalClient(options.host);
|
|
5
|
+
const cwd = options.all || options.workspace ? undefined : (options.cwd ?? process.cwd());
|
|
6
6
|
try {
|
|
7
|
-
const payload =
|
|
7
|
+
const payload = await client.terminals.list({ cwd, workspaceId: options.workspace });
|
|
8
8
|
return {
|
|
9
9
|
type: "list",
|
|
10
|
-
data: payload.
|
|
10
|
+
data: payload.entries,
|
|
11
11
|
schema: terminalSchema,
|
|
12
12
|
};
|
|
13
13
|
}
|
|
@@ -15,7 +15,7 @@ export async function runLsCommand(options, _command) {
|
|
|
15
15
|
throw toTerminalCommandError("TERMINAL_LIST_FAILED", "list terminals", err);
|
|
16
16
|
}
|
|
17
17
|
finally {
|
|
18
|
-
await
|
|
18
|
+
await close().catch(() => { });
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
//# sourceMappingURL=ls.js.map
|
|
@@ -1,18 +1,10 @@
|
|
|
1
|
+
import type { PaseoTerminal } from "@getpaseo/client";
|
|
1
2
|
import type { OutputSchema } from "../../output/index.js";
|
|
2
|
-
export
|
|
3
|
-
id: string;
|
|
4
|
-
name: string;
|
|
5
|
-
cwd: string;
|
|
6
|
-
}
|
|
3
|
+
export type TerminalRow = PaseoTerminal;
|
|
7
4
|
export interface TerminalKillRow {
|
|
8
5
|
terminalId: string;
|
|
9
6
|
success: boolean;
|
|
10
7
|
}
|
|
11
8
|
export declare const terminalSchema: OutputSchema<TerminalRow>;
|
|
12
9
|
export declare const terminalKillSchema: OutputSchema<TerminalKillRow>;
|
|
13
|
-
export declare function toTerminalRow(terminal: {
|
|
14
|
-
id: string;
|
|
15
|
-
name: string;
|
|
16
|
-
cwd?: string;
|
|
17
|
-
}, cwd?: string): TerminalRow;
|
|
18
10
|
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -4,6 +4,7 @@ export const terminalSchema = {
|
|
|
4
4
|
{ header: "ID", field: (row) => row.id.slice(0, 8), width: 8 },
|
|
5
5
|
{ header: "NAME", field: "name", width: 24 },
|
|
6
6
|
{ header: "CWD", field: "cwd", width: 48 },
|
|
7
|
+
{ header: "WORKSPACE", field: "workspaceId", width: 24 },
|
|
7
8
|
],
|
|
8
9
|
};
|
|
9
10
|
export const terminalKillSchema = {
|
|
@@ -13,11 +14,4 @@ export const terminalKillSchema = {
|
|
|
13
14
|
{ header: "SUCCESS", field: "success", width: 8 },
|
|
14
15
|
],
|
|
15
16
|
};
|
|
16
|
-
export function toTerminalRow(terminal, cwd) {
|
|
17
|
-
return {
|
|
18
|
-
id: terminal.id,
|
|
19
|
-
name: terminal.name,
|
|
20
|
-
cwd: terminal.cwd ?? cwd ?? "-",
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
17
|
//# sourceMappingURL=schema.js.map
|
|
@@ -18,7 +18,7 @@ export async function runSendKeysCommand(terminalId, keys, _options, command) {
|
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
async function executeSendKeysCommand(terminalId, keys, options) {
|
|
21
|
-
const { client } = await connectTerminalClient(options.host);
|
|
21
|
+
const { client, close } = await connectTerminalClient(options.host);
|
|
22
22
|
try {
|
|
23
23
|
const resolvedId = await resolveTerminalId(client, terminalId);
|
|
24
24
|
if (!resolvedId) {
|
|
@@ -28,49 +28,18 @@ async function executeSendKeysCommand(terminalId, keys, options) {
|
|
|
28
28
|
details: "Use `paseo terminal ls --all` to list available terminals.",
|
|
29
29
|
};
|
|
30
30
|
}
|
|
31
|
-
const
|
|
32
|
-
|
|
31
|
+
const terminal = client.terminals.ref(resolvedId);
|
|
32
|
+
const keysSent = options.literal ? terminal.write(keys.join("")) : terminal.sendKeys(keys);
|
|
33
33
|
return {
|
|
34
34
|
terminalId: resolvedId,
|
|
35
|
-
keysSent
|
|
35
|
+
keysSent,
|
|
36
36
|
};
|
|
37
37
|
}
|
|
38
38
|
catch (err) {
|
|
39
39
|
throw toTerminalCommandError("TERMINAL_SEND_KEYS_FAILED", "send terminal keys", err);
|
|
40
40
|
}
|
|
41
41
|
finally {
|
|
42
|
-
await
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
function resolveKeyToken(key, literal) {
|
|
46
|
-
if (literal) {
|
|
47
|
-
return key;
|
|
48
|
-
}
|
|
49
|
-
switch (key) {
|
|
50
|
-
case "Enter":
|
|
51
|
-
return "\r";
|
|
52
|
-
case "Tab":
|
|
53
|
-
return "\t";
|
|
54
|
-
case "Escape":
|
|
55
|
-
return "\u001b";
|
|
56
|
-
case "Space":
|
|
57
|
-
return " ";
|
|
58
|
-
case "BSpace":
|
|
59
|
-
return "\u007f";
|
|
60
|
-
case "C-c":
|
|
61
|
-
return "\u0003";
|
|
62
|
-
case "C-d":
|
|
63
|
-
return "\u0004";
|
|
64
|
-
case "C-z":
|
|
65
|
-
return "\u001a";
|
|
66
|
-
case "C-l":
|
|
67
|
-
return "\u000c";
|
|
68
|
-
case "C-a":
|
|
69
|
-
return "\u0001";
|
|
70
|
-
case "C-e":
|
|
71
|
-
return "\u0005";
|
|
72
|
-
default:
|
|
73
|
-
return key;
|
|
42
|
+
await close().catch(() => { });
|
|
74
43
|
}
|
|
75
44
|
}
|
|
76
45
|
//# sourceMappingURL=send-keys.js.map
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { connectToDaemon } from "../../utils/client.js";
|
|
2
1
|
import type { CommandError, CommandOptions } from "../../output/index.js";
|
|
3
2
|
export interface TerminalCommandOptions extends CommandOptions {
|
|
4
3
|
host?: string;
|
|
5
4
|
}
|
|
6
5
|
export declare function connectTerminalClient(host?: string): Promise<{
|
|
7
|
-
client: import("@getpaseo/client
|
|
6
|
+
client: import("@getpaseo/client").PaseoApi;
|
|
8
7
|
daemonHost: string;
|
|
8
|
+
close: () => Promise<void>;
|
|
9
9
|
}>;
|
|
10
10
|
export declare function toTerminalCommandError(code: string, action: string, err: unknown): CommandError;
|
|
11
|
-
export declare function resolveTerminalId(client: Awaited<ReturnType<typeof
|
|
11
|
+
export declare function resolveTerminalId(client: Awaited<ReturnType<typeof connectTerminalClient>>["client"], idOrName: string): Promise<string | null>;
|
|
12
12
|
//# sourceMappingURL=shared.d.ts.map
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { createPaseoApi } from "@getpaseo/client";
|
|
1
2
|
import { connectToDaemon, getDaemonHost } from "../../utils/client.js";
|
|
2
3
|
export async function connectTerminalClient(host) {
|
|
3
4
|
const daemonHost = getDaemonHost({ host });
|
|
4
5
|
try {
|
|
5
6
|
const client = await connectToDaemon({ host });
|
|
6
|
-
return { client, daemonHost };
|
|
7
|
+
return { client: createPaseoApi(client), daemonHost, close: () => client.close() };
|
|
7
8
|
}
|
|
8
9
|
catch (err) {
|
|
9
10
|
const message = err instanceof Error ? err.message : String(err);
|
|
@@ -29,8 +30,8 @@ export function toTerminalCommandError(code, action, err) {
|
|
|
29
30
|
};
|
|
30
31
|
}
|
|
31
32
|
export async function resolveTerminalId(client, idOrName) {
|
|
32
|
-
const payload = await client.
|
|
33
|
-
return resolveTerminalIdentifier(idOrName, payload.
|
|
33
|
+
const payload = await client.terminals.list();
|
|
34
|
+
return resolveTerminalIdentifier(idOrName, payload.entries);
|
|
34
35
|
}
|
|
35
36
|
function resolveTerminalIdentifier(idOrName, terminals) {
|
|
36
37
|
if (!idOrName || terminals.length === 0) {
|
|
@@ -5,8 +5,13 @@ import { runArchiveCommand } from "./archive.js";
|
|
|
5
5
|
import { runCreateCommand } from "./create.js";
|
|
6
6
|
import { runLsCommand } from "./ls.js";
|
|
7
7
|
import { runRenameCommand } from "./rename.js";
|
|
8
|
+
import { runSetupCommand } from "./setup.js";
|
|
8
9
|
export function createWorkspaceCommand() {
|
|
9
10
|
const workspace = new Command("workspace").description("Manage workspaces");
|
|
11
|
+
addJsonAndDaemonHostOptions(workspace
|
|
12
|
+
.command("setup")
|
|
13
|
+
.description("Allow and run setup for a workspace")
|
|
14
|
+
.argument("<workspace-id>", "Workspace id")).action(withOutput(runSetupCommand));
|
|
10
15
|
addJsonAndDaemonHostOptions(workspace
|
|
11
16
|
.command("create")
|
|
12
17
|
.description("Create a workspace")
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Command } from "commander";
|
|
2
|
+
import type { SingleResult } from "../../output/index.js";
|
|
3
|
+
interface WorkspaceSetupResult {
|
|
4
|
+
workspaceId: string;
|
|
5
|
+
status: "started" | "already_allowed";
|
|
6
|
+
}
|
|
7
|
+
export declare function runSetupCommand(workspaceId: string, options: {
|
|
8
|
+
host?: string;
|
|
9
|
+
}, _command: Command): Promise<SingleResult<WorkspaceSetupResult>>;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=setup.d.ts.map
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { connectToDaemon, getDaemonHost } from "../../utils/client.js";
|
|
2
|
+
const workspaceSetupSchema = {
|
|
3
|
+
idField: "workspaceId",
|
|
4
|
+
columns: [
|
|
5
|
+
{ header: "WORKSPACE ID", field: "workspaceId", width: 20 },
|
|
6
|
+
{ header: "STATUS", field: "status", width: 18 },
|
|
7
|
+
],
|
|
8
|
+
};
|
|
9
|
+
export async function runSetupCommand(workspaceId, options, _command) {
|
|
10
|
+
const host = getDaemonHost({ host: options.host });
|
|
11
|
+
const client = await connectToDaemon({ host: options.host }).catch((error) => {
|
|
12
|
+
throw {
|
|
13
|
+
code: "DAEMON_NOT_RUNNING",
|
|
14
|
+
message: `Cannot connect to daemon at ${host}: ${error instanceof Error ? error.message : String(error)}`,
|
|
15
|
+
};
|
|
16
|
+
});
|
|
17
|
+
try {
|
|
18
|
+
// COMPAT(workspaceSetupRun): added in v0.7.3, remove gate after 2027-09-02.
|
|
19
|
+
if (!client.getLastServerInfoMessage()?.features?.workspaceSetupRun) {
|
|
20
|
+
throw { code: "DAEMON_UPDATE_REQUIRED", message: "Update the host to run workspace setup." };
|
|
21
|
+
}
|
|
22
|
+
const payload = await client.runWorkspaceSetup(workspaceId);
|
|
23
|
+
if (payload.error)
|
|
24
|
+
throw new Error(payload.error);
|
|
25
|
+
return {
|
|
26
|
+
type: "single",
|
|
27
|
+
data: { workspaceId, status: payload.started ? "started" : "already_allowed" },
|
|
28
|
+
schema: workspaceSetupSchema,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
if (error && typeof error === "object" && "code" in error)
|
|
33
|
+
throw error;
|
|
34
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
35
|
+
throw { code: "WORKSPACE_SETUP_FAILED", message };
|
|
36
|
+
}
|
|
37
|
+
finally {
|
|
38
|
+
await client.close().catch(() => undefined);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=setup.js.map
|
package/dist/output/render.js
CHANGED
|
@@ -40,7 +40,8 @@ export function render(result, options = {}) {
|
|
|
40
40
|
/** Convert an unknown error to a CommandError */
|
|
41
41
|
export function toCommandError(error) {
|
|
42
42
|
if (isCommandError(error)) {
|
|
43
|
-
|
|
43
|
+
// Error.message and class getters are not enumerable; materialize the output contract.
|
|
44
|
+
return { ...error, code: error.code, message: error.message, details: error.details };
|
|
44
45
|
}
|
|
45
46
|
if (error instanceof Error) {
|
|
46
47
|
return {
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* Wraps command handlers to automatically render results and handle errors.
|
|
5
5
|
*/
|
|
6
6
|
import { render, renderError, toCommandError, defaultOutputOptions } from "./render.js";
|
|
7
|
+
import { withGlobalOptions } from "../utils/command-options.js";
|
|
7
8
|
function normalizeFormat(raw) {
|
|
8
9
|
const value = typeof raw === "string" ? raw.trim().toLowerCase() : "";
|
|
9
10
|
// Common user expectation: "cli" means "table/human"
|
|
@@ -56,11 +57,8 @@ function extractOutputOptions(options) {
|
|
|
56
57
|
* ```
|
|
57
58
|
*/
|
|
58
59
|
export function withOutput(handler) {
|
|
59
|
-
return async (...args) => {
|
|
60
|
-
|
|
61
|
-
const command = args[args.length - 1];
|
|
62
|
-
// Use optsWithGlobals() to get both local and global options
|
|
63
|
-
const options = command.optsWithGlobals();
|
|
60
|
+
return withGlobalOptions(async (...args) => {
|
|
61
|
+
const options = args[args.length - 2];
|
|
64
62
|
const outputOptions = extractOutputOptions(options);
|
|
65
63
|
try {
|
|
66
64
|
const result = await handler(...args);
|
|
@@ -75,7 +73,7 @@ export function withOutput(handler) {
|
|
|
75
73
|
process.stderr.write(errorOutput + "\n");
|
|
76
74
|
process.exit(1);
|
|
77
75
|
}
|
|
78
|
-
};
|
|
76
|
+
});
|
|
79
77
|
}
|
|
80
78
|
/**
|
|
81
79
|
* Helper to create output options from partial input.
|
package/dist/utils/client.d.ts
CHANGED
|
@@ -27,6 +27,7 @@ export declare function buildDaemonConnectionCommandError(options: {
|
|
|
27
27
|
export declare function normalizeDaemonHost(raw: string): string | null;
|
|
28
28
|
export declare function resolveDefaultDaemonHost(env?: NodeJS.ProcessEnv): string;
|
|
29
29
|
export declare function resolveDefaultDaemonHosts(env?: NodeJS.ProcessEnv): string[];
|
|
30
|
+
export declare function getExplicitDaemonHost(host: string | undefined, env?: NodeJS.ProcessEnv): string | undefined;
|
|
30
31
|
export declare function resolveDaemonTarget(host: string): DaemonTarget;
|
|
31
32
|
export declare function resolveDaemonPassword(host: string): string | undefined;
|
|
32
33
|
export declare function connectToDaemon(options?: ConnectOptions): Promise<DaemonClient>;
|
package/dist/utils/client.js
CHANGED
|
@@ -131,12 +131,16 @@ export function resolveDefaultDaemonHosts(env = process.env) {
|
|
|
131
131
|
return Array.from(new Set(candidates));
|
|
132
132
|
}
|
|
133
133
|
function resolveDaemonHostCandidates(options) {
|
|
134
|
-
const explicitHost = options?.host
|
|
134
|
+
const explicitHost = getExplicitDaemonHost(options?.host);
|
|
135
135
|
if (explicitHost) {
|
|
136
136
|
return [explicitHost];
|
|
137
137
|
}
|
|
138
138
|
return resolveDefaultDaemonHosts();
|
|
139
139
|
}
|
|
140
|
+
export function getExplicitDaemonHost(host, env = process.env) {
|
|
141
|
+
const explicitHost = host ?? env.PASEO_HOST;
|
|
142
|
+
return explicitHost?.trim() ? explicitHost : undefined;
|
|
143
|
+
}
|
|
140
144
|
function stripIpcPrefix(trimmed) {
|
|
141
145
|
if (trimmed.startsWith("unix://"))
|
|
142
146
|
return trimmed.slice("unix://".length).trim();
|
|
@@ -269,7 +273,7 @@ export async function connectToDaemon(options) {
|
|
|
269
273
|
const timeout = options?.timeout ?? DEFAULT_TIMEOUT;
|
|
270
274
|
const clientId = await getOrCreateCliClientId();
|
|
271
275
|
const nodeWebSocketFactory = createNodeWebSocketFactory();
|
|
272
|
-
const explicitHost = options?.host
|
|
276
|
+
const explicitHost = getExplicitDaemonHost(options?.host);
|
|
273
277
|
if (explicitHost?.trim().startsWith("ssh://")) {
|
|
274
278
|
const target = parseSshTransportUri(explicitHost.trim());
|
|
275
279
|
const tunnel = await createSshTunnel(target);
|
|
@@ -3,4 +3,5 @@ export declare function collectMultiple(value: string, previous: string[]): stri
|
|
|
3
3
|
export declare function addJsonOption<T extends Command>(command: T): T;
|
|
4
4
|
export declare function addDaemonHostOption<T extends Command>(command: T): T;
|
|
5
5
|
export declare function addJsonAndDaemonHostOptions<T extends Command>(command: T): T;
|
|
6
|
+
export declare function withGlobalOptions<Args extends unknown[], Result>(handler: (...args: Args) => Result): (...args: Args) => Result;
|
|
6
7
|
//# sourceMappingURL=command-options.d.ts.map
|
|
@@ -14,4 +14,12 @@ export function addDaemonHostOption(command) {
|
|
|
14
14
|
export function addJsonAndDaemonHostOptions(command) {
|
|
15
15
|
return addDaemonHostOption(addJsonOption(command));
|
|
16
16
|
}
|
|
17
|
+
export function withGlobalOptions(handler) {
|
|
18
|
+
return (...args) => {
|
|
19
|
+
const command = args.at(-1);
|
|
20
|
+
const mergedArgs = [...args];
|
|
21
|
+
mergedArgs[mergedArgs.length - 2] = command.optsWithGlobals();
|
|
22
|
+
return handler(...mergedArgs);
|
|
23
|
+
};
|
|
24
|
+
}
|
|
17
25
|
//# sourceMappingURL=command-options.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getpaseo/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0-beta.1",
|
|
4
4
|
"description": "Paseo CLI - control your AI coding agents from the command line",
|
|
5
5
|
"bin": {
|
|
6
6
|
"paseo": "bin/paseo"
|
|
@@ -28,9 +28,9 @@
|
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@clack/prompts": "^1.0.0",
|
|
31
|
-
"@getpaseo/client": "0.
|
|
32
|
-
"@getpaseo/protocol": "0.
|
|
33
|
-
"@getpaseo/server": "0.
|
|
31
|
+
"@getpaseo/client": "0.8.0-beta.1",
|
|
32
|
+
"@getpaseo/protocol": "0.8.0-beta.1",
|
|
33
|
+
"@getpaseo/server": "0.8.0-beta.1",
|
|
34
34
|
"chalk": "^5.3.0",
|
|
35
35
|
"commander": "^12.0.0",
|
|
36
36
|
"mime-types": "^2.1.35",
|