@getpaseo/cli 0.7.2 → 0.8.0

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.
Files changed (44) hide show
  1. package/dist/cli.js +4 -3
  2. package/dist/commands/agent/attach.js +10 -8
  3. package/dist/commands/agent/index.js +3 -3
  4. package/dist/commands/agent/logs.js +6 -6
  5. package/dist/commands/agent/run.js +2 -0
  6. package/dist/commands/hub/deploy-triggers.d.ts +6 -0
  7. package/dist/commands/hub/deploy-triggers.js +116 -0
  8. package/dist/commands/hub/deploy.d.ts +15 -5
  9. package/dist/commands/hub/deploy.js +73 -4
  10. package/dist/commands/hub/hub-client/index.d.ts +4 -3
  11. package/dist/commands/hub/hub-client/index.js +23 -10
  12. package/dist/commands/hub/hub-client/internal/contracts.d.ts +15 -15
  13. package/dist/commands/hub/hub-client/internal/contracts.js +13 -14
  14. package/dist/commands/hub/init-plan.d.ts +5 -25
  15. package/dist/commands/hub/init-plan.js +39 -85
  16. package/dist/commands/hub/init.js +81 -112
  17. package/dist/commands/hub/starter-trigger.d.ts +2 -2
  18. package/dist/commands/hub/starter-trigger.js +11 -9
  19. package/dist/commands/plugin/index.d.ts +1 -1
  20. package/dist/commands/plugin/index.js +11 -20
  21. package/dist/commands/plugin/scaffold.js +92 -14
  22. package/dist/commands/schedule/shared.js +2 -2
  23. package/dist/commands/terminal/capture.js +3 -3
  24. package/dist/commands/terminal/create.d.ts +1 -0
  25. package/dist/commands/terminal/create.js +13 -22
  26. package/dist/commands/terminal/index.js +9 -7
  27. package/dist/commands/terminal/kill.js +5 -5
  28. package/dist/commands/terminal/ls.d.ts +1 -0
  29. package/dist/commands/terminal/ls.js +6 -6
  30. package/dist/commands/terminal/schema.d.ts +2 -10
  31. package/dist/commands/terminal/schema.js +1 -7
  32. package/dist/commands/terminal/send-keys.js +5 -36
  33. package/dist/commands/terminal/shared.d.ts +3 -3
  34. package/dist/commands/terminal/shared.js +4 -3
  35. package/dist/commands/workspace/index.js +5 -0
  36. package/dist/commands/workspace/setup.d.ts +11 -0
  37. package/dist/commands/workspace/setup.js +41 -0
  38. package/dist/output/render.js +2 -1
  39. package/dist/output/with-output.js +4 -6
  40. package/dist/utils/client.d.ts +1 -0
  41. package/dist/utils/client.js +6 -2
  42. package/dist/utils/command-options.d.ts +1 -0
  43. package/dist/utils/command-options.js +8 -0
  44. package/package.json +4 -4
@@ -7,7 +7,8 @@ const TSCONFIG = {
7
7
  target: "ES2020",
8
8
  module: "ESNext",
9
9
  moduleResolution: "Bundler",
10
- lib: ["ES2023", "DOM"],
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 ENTRY = `import type { PluginContext } from "@getpaseo/plugin";
21
- import { MainSurface } from "./main.client";
21
+ const CLIENT_ENTRY = `import type { PluginClientContext } from "@getpaseo/plugin/client";
22
+ import { GreetingSurface } from "./client/greeting";
22
23
 
23
- export default function contribute(plugin: PluginContext) {
24
- plugin.addSurface("main", MainSurface);
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 CLIENT_SURFACE = `import type { PluginSurfaceProps } from "@getpaseo/plugin";
29
- import React, { useMemo } from "react";
30
- import { Text, View } from "react-native";
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 MainSurface({ theme, layout }: PluginSurfaceProps) {
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}>Hello from my plugin</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": resolveCliVersion(),
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
- ["paseo-plugin.json", `${JSON.stringify({ id }, null, 2)}\n`],
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.ts", ENTRY],
79
- ["main.client.tsx", CLIENT_SURFACE],
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.captureTerminal(resolvedId, {
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 client.close().catch(() => { });
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, toTerminalRow } from "./schema.js";
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 opened = await client.openProject(cwd);
8
- if (!opened.workspace) {
9
- const error = {
10
- code: "WORKSPACE_OPEN_FAILED",
11
- message: opened.error ?? "Failed to open workspace",
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
- if (!payload.terminal) {
19
- const error = {
20
- code: "TERMINAL_CREATE_FAILED",
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: toTerminalRow(payload.terminal),
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 client.close().catch(() => { });
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
- .option("--all", "List terminals across all workspaces")
15
- .option("--cwd <path>", "Workspace directory")).action(withOutput(runLsCommand));
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("--cwd <path>", "Workspace directory")
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
- const payload = await client.killTerminal(resolvedId);
7
+ await client.terminals.ref(resolvedId).kill();
8
8
  return {
9
9
  type: "single",
10
10
  data: {
11
- terminalId: payload.terminalId,
12
- success: payload.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 client.close().catch(() => { });
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, toTerminalRow } from "./schema.js";
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 = cwd === undefined ? await client.listTerminals() : await client.listTerminals(cwd);
7
+ const payload = await client.terminals.list({ cwd, workspaceId: options.workspace });
8
8
  return {
9
9
  type: "list",
10
- data: payload.terminals.map((terminal) => toTerminalRow(terminal, payload.cwd ?? cwd)),
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 client.close().catch(() => { });
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 interface TerminalRow {
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 data = keys.map((key) => resolveKeyToken(key, options.literal === true)).join("");
32
- client.sendTerminalInput(resolvedId, { type: "input", data });
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: data.length,
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 client.close().catch(() => { });
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/internal/daemon-client").DaemonClient;
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 connectToDaemon>>, idOrName: string): Promise<string | null>;
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.listTerminals();
33
- return resolveTerminalIdentifier(idOrName, payload.terminals);
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
@@ -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
- return error;
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
- // Last two args are options and command
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.
@@ -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>;