@camerontaylor/paseo-cli 0.8.0-fork.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/bin/paseo +3 -0
- package/dist/classify.d.ts +19 -0
- package/dist/classify.js +49 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.js +135 -0
- package/dist/commands/agent/archive.d.ts +18 -0
- package/dist/commands/agent/archive.js +102 -0
- package/dist/commands/agent/attach.d.ts +11 -0
- package/dist/commands/agent/attach.js +161 -0
- package/dist/commands/agent/delete.d.ts +15 -0
- package/dist/commands/agent/delete.js +107 -0
- package/dist/commands/agent/detach.d.ts +9 -0
- package/dist/commands/agent/detach.js +38 -0
- package/dist/commands/agent/import.d.ts +14 -0
- package/dist/commands/agent/import.js +122 -0
- package/dist/commands/agent/index.d.ts +3 -0
- package/dist/commands/agent/index.js +56 -0
- package/dist/commands/agent/inspect.d.ts +15 -0
- package/dist/commands/agent/inspect.js +209 -0
- package/dist/commands/agent/logs.d.ts +19 -0
- package/dist/commands/agent/logs.js +180 -0
- package/dist/commands/agent/ls.d.ts +44 -0
- package/dist/commands/agent/ls.js +212 -0
- package/dist/commands/agent/mode.d.ts +18 -0
- package/dist/commands/agent/mode.js +100 -0
- package/dist/commands/agent/open.d.ts +11 -0
- package/dist/commands/agent/open.js +61 -0
- package/dist/commands/agent/reload.d.ts +15 -0
- package/dist/commands/agent/reload.js +75 -0
- package/dist/commands/agent/run.d.ts +78 -0
- package/dist/commands/agent/run.js +554 -0
- package/dist/commands/agent/send.d.ts +19 -0
- package/dist/commands/agent/send.js +187 -0
- package/dist/commands/agent/stop.d.ts +17 -0
- package/dist/commands/agent/stop.js +115 -0
- package/dist/commands/agent/update.d.ts +51 -0
- package/dist/commands/agent/update.js +186 -0
- package/dist/commands/agent/wait.d.ts +17 -0
- package/dist/commands/agent/wait.js +158 -0
- package/dist/commands/clone.d.ts +17 -0
- package/dist/commands/clone.js +65 -0
- package/dist/commands/daemon/index.d.ts +3 -0
- package/dist/commands/daemon/index.js +60 -0
- package/dist/commands/daemon/local-daemon.d.ts +78 -0
- package/dist/commands/daemon/local-daemon.js +547 -0
- package/dist/commands/daemon/pair.d.ts +35 -0
- package/dist/commands/daemon/pair.js +167 -0
- package/dist/commands/daemon/reload.d.ts +10 -0
- package/dist/commands/daemon/reload.js +36 -0
- package/dist/commands/daemon/restart.d.ts +12 -0
- package/dist/commands/daemon/restart.js +99 -0
- package/dist/commands/daemon/runtime-toolchain.d.ts +6 -0
- package/dist/commands/daemon/runtime-toolchain.js +87 -0
- package/dist/commands/daemon/set-password.d.ts +17 -0
- package/dist/commands/daemon/set-password.js +82 -0
- package/dist/commands/daemon/start.d.ts +6 -0
- package/dist/commands/daemon/start.js +57 -0
- package/dist/commands/daemon/status.d.ts +21 -0
- package/dist/commands/daemon/status.js +363 -0
- package/dist/commands/daemon/stop.d.ts +15 -0
- package/dist/commands/daemon/stop.js +60 -0
- package/dist/commands/heartbeat/index.d.ts +3 -0
- package/dist/commands/heartbeat/index.js +139 -0
- package/dist/commands/hooks.d.ts +19 -0
- package/dist/commands/hooks.js +89 -0
- package/dist/commands/hub/authority.d.ts +17 -0
- package/dist/commands/hub/authority.js +18 -0
- package/dist/commands/hub/connect.d.ts +23 -0
- package/dist/commands/hub/connect.js +44 -0
- package/dist/commands/hub/credentials.d.ts +21 -0
- package/dist/commands/hub/credentials.js +143 -0
- package/dist/commands/hub/daemon-client.d.ts +40 -0
- package/dist/commands/hub/daemon-client.js +14 -0
- package/dist/commands/hub/deploy-bundle.d.ts +16 -0
- package/dist/commands/hub/deploy-bundle.js +248 -0
- package/dist/commands/hub/deploy-triggers.d.ts +6 -0
- package/dist/commands/hub/deploy-triggers.js +116 -0
- package/dist/commands/hub/deploy.d.ts +50 -0
- package/dist/commands/hub/deploy.js +159 -0
- package/dist/commands/hub/disconnect.d.ts +16 -0
- package/dist/commands/hub/disconnect.js +24 -0
- package/dist/commands/hub/error.d.ts +6 -0
- package/dist/commands/hub/error.js +9 -0
- package/dist/commands/hub/export.d.ts +28 -0
- package/dist/commands/hub/export.js +80 -0
- package/dist/commands/hub/help.d.ts +3 -0
- package/dist/commands/hub/help.js +5 -0
- package/dist/commands/hub/hub-client/index.d.ts +22 -0
- package/dist/commands/hub/hub-client/index.js +135 -0
- package/dist/commands/hub/hub-client/internal/contracts.d.ts +126 -0
- package/dist/commands/hub/hub-client/internal/contracts.js +85 -0
- package/dist/commands/hub/hub-client/internal/problem.d.ts +3 -0
- package/dist/commands/hub/hub-client/internal/problem.js +85 -0
- package/dist/commands/hub/hub-client/internal/transport.d.ts +15 -0
- package/dist/commands/hub/hub-client/internal/transport.js +30 -0
- package/dist/commands/hub/index.d.ts +20 -0
- package/dist/commands/hub/index.js +94 -0
- package/dist/commands/hub/init-plan.d.ts +33 -0
- package/dist/commands/hub/init-plan.js +94 -0
- package/dist/commands/hub/init.d.ts +35 -0
- package/dist/commands/hub/init.js +524 -0
- package/dist/commands/hub/login-flow.d.ts +34 -0
- package/dist/commands/hub/login-flow.js +78 -0
- package/dist/commands/hub/login.d.ts +23 -0
- package/dist/commands/hub/login.js +40 -0
- package/dist/commands/hub/logout.d.ts +32 -0
- package/dist/commands/hub/logout.js +71 -0
- package/dist/commands/hub/origin.d.ts +2 -0
- package/dist/commands/hub/origin.js +27 -0
- package/dist/commands/hub/permissions.d.ts +21 -0
- package/dist/commands/hub/permissions.js +61 -0
- package/dist/commands/hub/projects.d.ts +24 -0
- package/dist/commands/hub/projects.js +49 -0
- package/dist/commands/hub/reporter.d.ts +10 -0
- package/dist/commands/hub/reporter.js +11 -0
- package/dist/commands/hub/starter-agent-runtime.d.ts +37 -0
- package/dist/commands/hub/starter-agent-runtime.js +49 -0
- package/dist/commands/hub/starter-trigger.d.ts +10 -0
- package/dist/commands/hub/starter-trigger.js +30 -0
- package/dist/commands/hub/status-output.d.ts +13 -0
- package/dist/commands/hub/status-output.js +30 -0
- package/dist/commands/onboard.d.ts +10 -0
- package/dist/commands/onboard.js +400 -0
- package/dist/commands/open.d.ts +4 -0
- package/dist/commands/open.js +89 -0
- package/dist/commands/permit/allow.d.ts +20 -0
- package/dist/commands/permit/allow.js +133 -0
- package/dist/commands/permit/deny.d.ts +12 -0
- package/dist/commands/permit/deny.js +105 -0
- package/dist/commands/permit/index.d.ts +3 -0
- package/dist/commands/permit/index.js +27 -0
- package/dist/commands/permit/ls.d.ts +18 -0
- package/dist/commands/permit/ls.js +66 -0
- package/dist/commands/plugin/index.d.ts +17 -0
- package/dist/commands/plugin/index.js +138 -0
- package/dist/commands/plugin/scaffold.d.ts +6 -0
- package/dist/commands/plugin/scaffold.js +162 -0
- package/dist/commands/plugin/shared.d.ts +5 -0
- package/dist/commands/plugin/shared.js +30 -0
- package/dist/commands/project/create.d.ts +10 -0
- package/dist/commands/project/create.js +41 -0
- package/dist/commands/project/delete.d.ts +9 -0
- package/dist/commands/project/delete.js +33 -0
- package/dist/commands/project/index.d.ts +3 -0
- package/dist/commands/project/index.js +28 -0
- package/dist/commands/project/ls.d.ts +5 -0
- package/dist/commands/project/ls.js +19 -0
- package/dist/commands/project/rename.d.ts +15 -0
- package/dist/commands/project/rename.js +50 -0
- package/dist/commands/project/shared.d.ts +11 -0
- package/dist/commands/project/shared.js +18 -0
- package/dist/commands/provider/add.d.ts +30 -0
- package/dist/commands/provider/add.js +123 -0
- package/dist/commands/provider/diagnostic.d.ts +12 -0
- package/dist/commands/provider/diagnostic.js +31 -0
- package/dist/commands/provider/index.d.ts +3 -0
- package/dist/commands/provider/index.js +38 -0
- package/dist/commands/provider/ls.d.ts +20 -0
- package/dist/commands/provider/ls.js +76 -0
- package/dist/commands/provider/models.d.ts +20 -0
- package/dist/commands/provider/models.js +53 -0
- package/dist/commands/provider/rm.d.ts +10 -0
- package/dist/commands/provider/rm.js +45 -0
- package/dist/commands/provider/shared.d.ts +7 -0
- package/dist/commands/provider/shared.js +10 -0
- package/dist/commands/schedule/create.d.ts +19 -0
- package/dist/commands/schedule/create.js +41 -0
- package/dist/commands/schedule/delete.d.ts +10 -0
- package/dist/commands/schedule/delete.js +32 -0
- package/dist/commands/schedule/index.d.ts +3 -0
- package/dist/commands/schedule/index.js +66 -0
- package/dist/commands/schedule/inspect.d.ts +6 -0
- package/dist/commands/schedule/inspect.js +27 -0
- package/dist/commands/schedule/logs.d.ts +6 -0
- package/dist/commands/schedule/logs.js +24 -0
- package/dist/commands/schedule/ls.d.ts +5 -0
- package/dist/commands/schedule/ls.js +25 -0
- package/dist/commands/schedule/pause.d.ts +5 -0
- package/dist/commands/schedule/pause.js +24 -0
- package/dist/commands/schedule/resume.d.ts +5 -0
- package/dist/commands/schedule/resume.js +24 -0
- package/dist/commands/schedule/run-once.d.ts +5 -0
- package/dist/commands/schedule/run-once.js +24 -0
- package/dist/commands/schedule/schema.d.ts +21 -0
- package/dist/commands/schedule/schema.js +67 -0
- package/dist/commands/schedule/shared.d.ts +59 -0
- package/dist/commands/schedule/shared.js +358 -0
- package/dist/commands/schedule/types.d.ts +165 -0
- package/dist/commands/schedule/types.js +2 -0
- package/dist/commands/schedule/update.d.ts +21 -0
- package/dist/commands/schedule/update.js +40 -0
- package/dist/commands/script/index.d.ts +3 -0
- package/dist/commands/script/index.js +19 -0
- package/dist/commands/script/ls.d.ts +6 -0
- package/dist/commands/script/ls.js +20 -0
- package/dist/commands/script/schema.d.ts +5 -0
- package/dist/commands/script/schema.js +13 -0
- package/dist/commands/script/shared.d.ts +11 -0
- package/dist/commands/script/shared.js +59 -0
- package/dist/commands/script/start.d.ts +6 -0
- package/dist/commands/script/start.js +23 -0
- package/dist/commands/script/stop.d.ts +6 -0
- package/dist/commands/script/stop.js +23 -0
- package/dist/commands/speech/index.d.ts +3 -0
- package/dist/commands/speech/index.js +5 -0
- package/dist/commands/terminal/capture.d.ts +10 -0
- package/dist/commands/terminal/capture.js +68 -0
- package/dist/commands/terminal/create.d.ts +11 -0
- package/dist/commands/terminal/create.js +29 -0
- package/dist/commands/terminal/index.d.ts +3 -0
- package/dist/commands/terminal/index.js +45 -0
- package/dist/commands/terminal/kill.d.ts +6 -0
- package/dist/commands/terminal/kill.js +36 -0
- package/dist/commands/terminal/ls.d.ts +11 -0
- package/dist/commands/terminal/ls.js +21 -0
- package/dist/commands/terminal/schema.d.ts +10 -0
- package/dist/commands/terminal/schema.js +17 -0
- package/dist/commands/terminal/send-keys.d.ts +7 -0
- package/dist/commands/terminal/send-keys.js +45 -0
- package/dist/commands/terminal/shared.d.ts +12 -0
- package/dist/commands/terminal/shared.js +62 -0
- package/dist/commands/workspace/archive.d.ts +12 -0
- package/dist/commands/workspace/archive.js +41 -0
- package/dist/commands/workspace/create.d.ts +49 -0
- package/dist/commands/workspace/create.js +114 -0
- package/dist/commands/workspace/index.d.ts +3 -0
- package/dist/commands/workspace/index.js +45 -0
- package/dist/commands/workspace/ls.d.ts +7 -0
- package/dist/commands/workspace/ls.js +28 -0
- package/dist/commands/workspace/rename.d.ts +22 -0
- package/dist/commands/workspace/rename.js +61 -0
- package/dist/commands/workspace/setup.d.ts +11 -0
- package/dist/commands/workspace/setup.js +41 -0
- package/dist/commands/workspace/shared.d.ts +12 -0
- package/dist/commands/workspace/shared.js +20 -0
- package/dist/commands/worktree/archive.d.ts +20 -0
- package/dist/commands/worktree/archive.js +104 -0
- package/dist/commands/worktree/create-input.d.ts +15 -0
- package/dist/commands/worktree/create-input.js +56 -0
- package/dist/commands/worktree/create.d.ts +11 -0
- package/dist/commands/worktree/create.js +58 -0
- package/dist/commands/worktree/index.d.ts +3 -0
- package/dist/commands/worktree/index.js +25 -0
- package/dist/commands/worktree/ls.d.ts +19 -0
- package/dist/commands/worktree/ls.js +97 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +6 -0
- package/dist/output/index.d.ts +45 -0
- package/dist/output/index.js +47 -0
- package/dist/output/json.d.ts +11 -0
- package/dist/output/json.js +37 -0
- package/dist/output/pairing.d.ts +8 -0
- package/dist/output/pairing.js +24 -0
- package/dist/output/quiet.d.ts +9 -0
- package/dist/output/quiet.js +22 -0
- package/dist/output/render.d.ts +15 -0
- package/dist/output/render.js +84 -0
- package/dist/output/table.d.ts +13 -0
- package/dist/output/table.js +135 -0
- package/dist/output/types.d.ts +73 -0
- package/dist/output/types.js +8 -0
- package/dist/output/with-output.d.ts +41 -0
- package/dist/output/with-output.js +85 -0
- package/dist/output/yaml.d.ts +11 -0
- package/dist/output/yaml.js +38 -0
- package/dist/run.d.ts +14 -0
- package/dist/run.js +40 -0
- package/dist/ssh/ssh-tunnel.d.ts +9 -0
- package/dist/ssh/ssh-tunnel.js +79 -0
- package/dist/utils/client-id.d.ts +2 -0
- package/dist/utils/client-id.js +37 -0
- package/dist/utils/client.d.ts +54 -0
- package/dist/utils/client.js +363 -0
- package/dist/utils/command-options.d.ts +7 -0
- package/dist/utils/command-options.js +25 -0
- package/dist/utils/duration.d.ts +7 -0
- package/dist/utils/duration.js +39 -0
- package/dist/utils/errors.d.ts +5 -0
- package/dist/utils/errors.js +10 -0
- package/dist/utils/paths.d.ts +12 -0
- package/dist/utils/paths.js +22 -0
- package/dist/utils/provider-model.d.ts +11 -0
- package/dist/utils/provider-model.js +49 -0
- package/dist/utils/timeline.d.ts +11 -0
- package/dist/utils/timeline.js +11 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.js +10 -0
- package/package.json +50 -0
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { resolve } from "node:path";
|
|
2
|
+
import { connectToDaemon, getDaemonHost } from "../../utils/client.js";
|
|
3
|
+
export async function connectWorkspaceScriptClient(host) {
|
|
4
|
+
const daemonHost = getDaemonHost({ host });
|
|
5
|
+
try {
|
|
6
|
+
const client = await connectToDaemon({ host });
|
|
7
|
+
// COMPAT(workspaceScriptManagement): added in v0.1.105, remove gate after 2027-01-10.
|
|
8
|
+
if (!client.getLastServerInfoMessage()?.features?.workspaceScriptManagement) {
|
|
9
|
+
await client.close().catch(() => { });
|
|
10
|
+
throw {
|
|
11
|
+
code: "DAEMON_UPDATE_REQUIRED",
|
|
12
|
+
message: "Update the host to use workspace script management.",
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
return client;
|
|
16
|
+
}
|
|
17
|
+
catch (error) {
|
|
18
|
+
if (error && typeof error === "object" && "code" in error && "message" in error) {
|
|
19
|
+
throw error;
|
|
20
|
+
}
|
|
21
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
22
|
+
throw {
|
|
23
|
+
code: "DAEMON_NOT_RUNNING",
|
|
24
|
+
message: `Cannot connect to daemon at ${daemonHost}: ${message}`,
|
|
25
|
+
details: "Start the daemon with: paseo daemon start",
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export async function resolveWorkspaceScriptWorkspaceId(client, options) {
|
|
30
|
+
if (options.workspace) {
|
|
31
|
+
return options.workspace;
|
|
32
|
+
}
|
|
33
|
+
const cwd = resolve(options.cwd ?? process.cwd());
|
|
34
|
+
const payload = await client.fetchWorkspaces({ page: { limit: 200 } });
|
|
35
|
+
const matches = payload.entries.filter((workspace) => resolve(workspace.workspaceDirectory) === cwd);
|
|
36
|
+
if (matches.length === 1) {
|
|
37
|
+
return matches[0].id;
|
|
38
|
+
}
|
|
39
|
+
if (matches.length > 1) {
|
|
40
|
+
throw {
|
|
41
|
+
code: "WORKSPACE_AMBIGUOUS",
|
|
42
|
+
message: `Multiple workspaces use ${cwd}`,
|
|
43
|
+
details: "Pass --workspace <workspace-id> to select one.",
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
throw {
|
|
47
|
+
code: "WORKSPACE_NOT_FOUND",
|
|
48
|
+
message: `No Paseo workspace found for ${cwd}`,
|
|
49
|
+
details: "Open the directory in Paseo first, or pass --workspace <workspace-id>.",
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
export function toWorkspaceScriptCommandError(code, action, error) {
|
|
53
|
+
if (error && typeof error === "object" && "code" in error && "message" in error) {
|
|
54
|
+
return error;
|
|
55
|
+
}
|
|
56
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
57
|
+
return { code, message: `Failed to ${action}: ${message}` };
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=shared.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Command } from "commander";
|
|
2
|
+
import type { SingleResult } from "../../output/index.js";
|
|
3
|
+
import { type WorkspaceScriptCommandOptions } from "./shared.js";
|
|
4
|
+
import { type WorkspaceScriptRow } from "./schema.js";
|
|
5
|
+
export declare function runStartCommand(scriptName: string, options: WorkspaceScriptCommandOptions, _command: Command): Promise<SingleResult<WorkspaceScriptRow>>;
|
|
6
|
+
//# sourceMappingURL=start.d.ts.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { connectWorkspaceScriptClient, resolveWorkspaceScriptWorkspaceId, toWorkspaceScriptCommandError, } from "./shared.js";
|
|
2
|
+
import { workspaceScriptSchema } from "./schema.js";
|
|
3
|
+
export async function runStartCommand(scriptName, options, _command) {
|
|
4
|
+
const client = await connectWorkspaceScriptClient(options.host);
|
|
5
|
+
try {
|
|
6
|
+
const workspaceId = await resolveWorkspaceScriptWorkspaceId(client, options);
|
|
7
|
+
const payload = await client.startWorkspaceScriptWithStatus(workspaceId, scriptName);
|
|
8
|
+
if (payload.error || !payload.script) {
|
|
9
|
+
throw {
|
|
10
|
+
code: "WORKSPACE_SCRIPT_START_FAILED",
|
|
11
|
+
message: payload.error ?? `Script '${scriptName}' did not return status metadata`,
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
return { type: "single", data: payload.script, schema: workspaceScriptSchema };
|
|
15
|
+
}
|
|
16
|
+
catch (error) {
|
|
17
|
+
throw toWorkspaceScriptCommandError("WORKSPACE_SCRIPT_START_FAILED", "start workspace script", error);
|
|
18
|
+
}
|
|
19
|
+
finally {
|
|
20
|
+
await client.close().catch(() => { });
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=start.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Command } from "commander";
|
|
2
|
+
import type { SingleResult } from "../../output/index.js";
|
|
3
|
+
import { type WorkspaceScriptCommandOptions } from "./shared.js";
|
|
4
|
+
import { type WorkspaceScriptRow } from "./schema.js";
|
|
5
|
+
export declare function runStopCommand(scriptName: string, options: WorkspaceScriptCommandOptions, _command: Command): Promise<SingleResult<WorkspaceScriptRow>>;
|
|
6
|
+
//# sourceMappingURL=stop.d.ts.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { connectWorkspaceScriptClient, resolveWorkspaceScriptWorkspaceId, toWorkspaceScriptCommandError, } from "./shared.js";
|
|
2
|
+
import { workspaceScriptSchema } from "./schema.js";
|
|
3
|
+
export async function runStopCommand(scriptName, options, _command) {
|
|
4
|
+
const client = await connectWorkspaceScriptClient(options.host);
|
|
5
|
+
try {
|
|
6
|
+
const workspaceId = await resolveWorkspaceScriptWorkspaceId(client, options);
|
|
7
|
+
const payload = await client.stopWorkspaceScript(workspaceId, scriptName);
|
|
8
|
+
if (payload.error || !payload.script) {
|
|
9
|
+
throw {
|
|
10
|
+
code: "WORKSPACE_SCRIPT_STOP_FAILED",
|
|
11
|
+
message: payload.error ?? `Script '${scriptName}' did not return status metadata`,
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
return { type: "single", data: payload.script, schema: workspaceScriptSchema };
|
|
15
|
+
}
|
|
16
|
+
catch (error) {
|
|
17
|
+
throw toWorkspaceScriptCommandError("WORKSPACE_SCRIPT_STOP_FAILED", "stop workspace script", error);
|
|
18
|
+
}
|
|
19
|
+
finally {
|
|
20
|
+
await client.close().catch(() => { });
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=stop.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Command } from "commander";
|
|
2
|
+
import { type TerminalCommandOptions } from "./shared.js";
|
|
3
|
+
export interface TerminalCaptureOptions extends TerminalCommandOptions {
|
|
4
|
+
start?: string;
|
|
5
|
+
end?: string;
|
|
6
|
+
scrollback?: boolean;
|
|
7
|
+
ansi?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare function runCaptureCommand(terminalId: string, _options: TerminalCaptureOptions, command: Command): Promise<void>;
|
|
10
|
+
//# sourceMappingURL=capture.d.ts.map
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { renderError, toCommandError } from "../../output/render.js";
|
|
2
|
+
import { connectTerminalClient, resolveTerminalId, toTerminalCommandError, } from "./shared.js";
|
|
3
|
+
export async function runCaptureCommand(terminalId, _options, command) {
|
|
4
|
+
const options = command.optsWithGlobals();
|
|
5
|
+
try {
|
|
6
|
+
const payload = await executeCaptureCommand(terminalId, options);
|
|
7
|
+
if (options.json) {
|
|
8
|
+
process.stdout.write(JSON.stringify({
|
|
9
|
+
terminalId: payload.terminalId,
|
|
10
|
+
lines: payload.lines,
|
|
11
|
+
totalLines: payload.totalLines,
|
|
12
|
+
}, null, 2) + "\n");
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
if (payload.lines.length > 0) {
|
|
16
|
+
process.stdout.write(payload.lines.join("\n") + "\n");
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
catch (err) {
|
|
20
|
+
const output = renderError(toCommandError(err), {
|
|
21
|
+
format: options.json ? "json" : "table",
|
|
22
|
+
noColor: options.color === false,
|
|
23
|
+
});
|
|
24
|
+
process.stderr.write(output + "\n");
|
|
25
|
+
process.exit(1);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
async function executeCaptureCommand(terminalId, options) {
|
|
29
|
+
const { client, close } = await connectTerminalClient(options.host);
|
|
30
|
+
try {
|
|
31
|
+
const resolvedId = await resolveTerminalId(client, terminalId);
|
|
32
|
+
if (!resolvedId) {
|
|
33
|
+
throw {
|
|
34
|
+
code: "TERMINAL_NOT_FOUND",
|
|
35
|
+
message: `No terminal found matching: ${terminalId}`,
|
|
36
|
+
details: "Use `paseo terminal ls --all` to list available terminals.",
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
const start = options.scrollback ? 0 : parseLineNumber("--start", options.start);
|
|
40
|
+
const end = parseLineNumber("--end", options.end);
|
|
41
|
+
return await client.terminals.ref(resolvedId).capture({
|
|
42
|
+
...(start === undefined ? {} : { start }),
|
|
43
|
+
...(end === undefined ? {} : { end }),
|
|
44
|
+
stripAnsi: !options.ansi,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
catch (err) {
|
|
48
|
+
throw toTerminalCommandError("TERMINAL_CAPTURE_FAILED", "capture terminal output", err);
|
|
49
|
+
}
|
|
50
|
+
finally {
|
|
51
|
+
await close().catch(() => { });
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function parseLineNumber(flag, value) {
|
|
55
|
+
if (value === undefined) {
|
|
56
|
+
return undefined;
|
|
57
|
+
}
|
|
58
|
+
const parsed = Number.parseInt(value, 10);
|
|
59
|
+
if (!Number.isInteger(parsed)) {
|
|
60
|
+
throw {
|
|
61
|
+
code: "INVALID_LINE_NUMBER",
|
|
62
|
+
message: `Invalid ${flag} value: ${value}`,
|
|
63
|
+
details: "Use an integer line number.",
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
return parsed;
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=capture.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Command } from "commander";
|
|
2
|
+
import type { SingleResult } from "../../output/index.js";
|
|
3
|
+
import { type TerminalCommandOptions } from "./shared.js";
|
|
4
|
+
import { type TerminalRow } from "./schema.js";
|
|
5
|
+
export interface TerminalCreateOptions extends TerminalCommandOptions {
|
|
6
|
+
workspace?: string;
|
|
7
|
+
cwd?: string;
|
|
8
|
+
name?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function runCreateCommand(options: TerminalCreateOptions, _command: Command): Promise<SingleResult<TerminalRow>>;
|
|
11
|
+
//# sourceMappingURL=create.d.ts.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { connectTerminalClient, toTerminalCommandError, } from "./shared.js";
|
|
2
|
+
import { terminalSchema } from "./schema.js";
|
|
3
|
+
export async function runCreateCommand(options, _command) {
|
|
4
|
+
const { client, close } = await connectTerminalClient(options.host);
|
|
5
|
+
try {
|
|
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,
|
|
12
|
+
});
|
|
13
|
+
const snapshot = terminal.current();
|
|
14
|
+
if (!snapshot)
|
|
15
|
+
throw new Error("The daemon did not create a terminal");
|
|
16
|
+
return {
|
|
17
|
+
type: "single",
|
|
18
|
+
data: snapshot,
|
|
19
|
+
schema: terminalSchema,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
catch (err) {
|
|
23
|
+
throw toTerminalCommandError("TERMINAL_CREATE_FAILED", "create terminal", err);
|
|
24
|
+
}
|
|
25
|
+
finally {
|
|
26
|
+
await close().catch(() => { });
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=create.js.map
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Command, Option } from "commander";
|
|
2
|
+
import { withOutput } from "../../output/index.js";
|
|
3
|
+
import { addDaemonHostOption, addJsonAndDaemonHostOptions, withGlobalOptions, } from "../../utils/command-options.js";
|
|
4
|
+
import { runCaptureCommand } from "./capture.js";
|
|
5
|
+
import { runCreateCommand } from "./create.js";
|
|
6
|
+
import { runKillCommand } from "./kill.js";
|
|
7
|
+
import { runLsCommand } from "./ls.js";
|
|
8
|
+
import { runSendKeysCommand } from "./send-keys.js";
|
|
9
|
+
export function createTerminalCommand() {
|
|
10
|
+
const terminal = new Command("terminal").description("Manage workspace terminals");
|
|
11
|
+
addJsonAndDaemonHostOptions(terminal
|
|
12
|
+
.command("ls")
|
|
13
|
+
.description("List terminals")
|
|
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));
|
|
17
|
+
addJsonAndDaemonHostOptions(terminal
|
|
18
|
+
.command("create")
|
|
19
|
+
.description("Create a terminal")
|
|
20
|
+
.option("--workspace <id>", "Workspace ID")
|
|
21
|
+
.option("--cwd <path>", "Working directory")
|
|
22
|
+
.option("--name <name>", "Terminal name")).action(withOutput(runCreateCommand));
|
|
23
|
+
addJsonAndDaemonHostOptions(terminal
|
|
24
|
+
.command("kill")
|
|
25
|
+
.description("Kill a terminal")
|
|
26
|
+
.argument("<terminal-id>", "Terminal ID, ID prefix, or name")).action(withOutput(runKillCommand));
|
|
27
|
+
addDaemonHostOption(terminal
|
|
28
|
+
.command("capture")
|
|
29
|
+
.description("Capture terminal output")
|
|
30
|
+
.argument("<terminal-id>", "Terminal ID, ID prefix, or name")
|
|
31
|
+
.option("--start <n>", "Capture start line")
|
|
32
|
+
.option("--end <n>", "Capture end line")
|
|
33
|
+
.option("-S, --scrollback", "Capture from the beginning of scrollback")
|
|
34
|
+
.option("--ansi", "Preserve ANSI escape codes")
|
|
35
|
+
.option("--json", "Output in JSON format")).action(withGlobalOptions(runCaptureCommand));
|
|
36
|
+
addDaemonHostOption(terminal
|
|
37
|
+
.command("send-keys")
|
|
38
|
+
.description("Send keys to a terminal")
|
|
39
|
+
.argument("<terminal-id>", "Terminal ID, ID prefix, or name")
|
|
40
|
+
.argument("<keys...>", "Keys to send")
|
|
41
|
+
.option("-l, --literal", "Send raw keys without interpreting special tokens")
|
|
42
|
+
.option("--json", "Output in JSON format")).action(withGlobalOptions(runSendKeysCommand));
|
|
43
|
+
return terminal;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Command } from "commander";
|
|
2
|
+
import type { SingleResult } from "../../output/index.js";
|
|
3
|
+
import { type TerminalCommandOptions } from "./shared.js";
|
|
4
|
+
import { type TerminalKillRow } from "./schema.js";
|
|
5
|
+
export declare function runKillCommand(terminalId: string, options: TerminalCommandOptions, _command: Command): Promise<SingleResult<TerminalKillRow>>;
|
|
6
|
+
//# sourceMappingURL=kill.d.ts.map
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { connectTerminalClient, resolveTerminalId, toTerminalCommandError, } from "./shared.js";
|
|
2
|
+
import { terminalKillSchema } from "./schema.js";
|
|
3
|
+
export async function runKillCommand(terminalId, options, _command) {
|
|
4
|
+
const { client, close } = await connectTerminalClient(options.host);
|
|
5
|
+
try {
|
|
6
|
+
const resolvedId = await requireTerminalId(client, terminalId);
|
|
7
|
+
await client.terminals.ref(resolvedId).kill();
|
|
8
|
+
return {
|
|
9
|
+
type: "single",
|
|
10
|
+
data: {
|
|
11
|
+
terminalId: resolvedId,
|
|
12
|
+
success: true,
|
|
13
|
+
},
|
|
14
|
+
schema: terminalKillSchema,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
catch (err) {
|
|
18
|
+
throw toTerminalCommandError("TERMINAL_KILL_FAILED", "kill terminal", err);
|
|
19
|
+
}
|
|
20
|
+
finally {
|
|
21
|
+
await close().catch(() => { });
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
async function requireTerminalId(client, terminalId) {
|
|
25
|
+
const resolvedId = await resolveTerminalId(client, terminalId);
|
|
26
|
+
if (resolvedId) {
|
|
27
|
+
return resolvedId;
|
|
28
|
+
}
|
|
29
|
+
const error = {
|
|
30
|
+
code: "TERMINAL_NOT_FOUND",
|
|
31
|
+
message: `No terminal found matching: ${terminalId}`,
|
|
32
|
+
details: "Use `paseo terminal ls --all` to list available terminals.",
|
|
33
|
+
};
|
|
34
|
+
throw error;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=kill.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Command } from "commander";
|
|
2
|
+
import type { ListResult } from "../../output/index.js";
|
|
3
|
+
import { type TerminalCommandOptions } from "./shared.js";
|
|
4
|
+
import { type TerminalRow } from "./schema.js";
|
|
5
|
+
export interface TerminalLsOptions extends TerminalCommandOptions {
|
|
6
|
+
workspace?: string;
|
|
7
|
+
all?: boolean;
|
|
8
|
+
cwd?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function runLsCommand(options: TerminalLsOptions, _command: Command): Promise<ListResult<TerminalRow>>;
|
|
11
|
+
//# sourceMappingURL=ls.d.ts.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { connectTerminalClient, toTerminalCommandError, } from "./shared.js";
|
|
2
|
+
import { terminalSchema } from "./schema.js";
|
|
3
|
+
export async function runLsCommand(options, _command) {
|
|
4
|
+
const { client, close } = await connectTerminalClient(options.host);
|
|
5
|
+
const cwd = options.all || options.workspace ? undefined : (options.cwd ?? process.cwd());
|
|
6
|
+
try {
|
|
7
|
+
const payload = await client.terminals.list({ cwd, workspaceId: options.workspace });
|
|
8
|
+
return {
|
|
9
|
+
type: "list",
|
|
10
|
+
data: payload.entries,
|
|
11
|
+
schema: terminalSchema,
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
catch (err) {
|
|
15
|
+
throw toTerminalCommandError("TERMINAL_LIST_FAILED", "list terminals", err);
|
|
16
|
+
}
|
|
17
|
+
finally {
|
|
18
|
+
await close().catch(() => { });
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=ls.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { PaseoTerminal } from "@camerontaylor/paseo-client";
|
|
2
|
+
import type { OutputSchema } from "../../output/index.js";
|
|
3
|
+
export type TerminalRow = PaseoTerminal;
|
|
4
|
+
export interface TerminalKillRow {
|
|
5
|
+
terminalId: string;
|
|
6
|
+
success: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare const terminalSchema: OutputSchema<TerminalRow>;
|
|
9
|
+
export declare const terminalKillSchema: OutputSchema<TerminalKillRow>;
|
|
10
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export const terminalSchema = {
|
|
2
|
+
idField: "id",
|
|
3
|
+
columns: [
|
|
4
|
+
{ header: "ID", field: (row) => row.id.slice(0, 8), width: 8 },
|
|
5
|
+
{ header: "NAME", field: "name", width: 24 },
|
|
6
|
+
{ header: "CWD", field: "cwd", width: 48 },
|
|
7
|
+
{ header: "WORKSPACE", field: "workspaceId", width: 24 },
|
|
8
|
+
],
|
|
9
|
+
};
|
|
10
|
+
export const terminalKillSchema = {
|
|
11
|
+
idField: "terminalId",
|
|
12
|
+
columns: [
|
|
13
|
+
{ header: "ID", field: (row) => row.terminalId.slice(0, 8), width: 8 },
|
|
14
|
+
{ header: "SUCCESS", field: "success", width: 8 },
|
|
15
|
+
],
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Command } from "commander";
|
|
2
|
+
import { type TerminalCommandOptions } from "./shared.js";
|
|
3
|
+
export interface TerminalSendKeysOptions extends TerminalCommandOptions {
|
|
4
|
+
literal?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare function runSendKeysCommand(terminalId: string, keys: string[], _options: TerminalSendKeysOptions, command: Command): Promise<void>;
|
|
7
|
+
//# sourceMappingURL=send-keys.d.ts.map
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { renderError, toCommandError } from "../../output/render.js";
|
|
2
|
+
import { connectTerminalClient, resolveTerminalId, toTerminalCommandError, } from "./shared.js";
|
|
3
|
+
export async function runSendKeysCommand(terminalId, keys, _options, command) {
|
|
4
|
+
const options = command.optsWithGlobals();
|
|
5
|
+
try {
|
|
6
|
+
const payload = await executeSendKeysCommand(terminalId, keys, options);
|
|
7
|
+
if (options.json) {
|
|
8
|
+
process.stdout.write(JSON.stringify(payload, null, 2) + "\n");
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
catch (err) {
|
|
12
|
+
const output = renderError(toCommandError(err), {
|
|
13
|
+
format: options.json ? "json" : "table",
|
|
14
|
+
noColor: options.color === false,
|
|
15
|
+
});
|
|
16
|
+
process.stderr.write(output + "\n");
|
|
17
|
+
process.exit(1);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
async function executeSendKeysCommand(terminalId, keys, options) {
|
|
21
|
+
const { client, close } = await connectTerminalClient(options.host);
|
|
22
|
+
try {
|
|
23
|
+
const resolvedId = await resolveTerminalId(client, terminalId);
|
|
24
|
+
if (!resolvedId) {
|
|
25
|
+
throw {
|
|
26
|
+
code: "TERMINAL_NOT_FOUND",
|
|
27
|
+
message: `No terminal found matching: ${terminalId}`,
|
|
28
|
+
details: "Use `paseo terminal ls --all` to list available terminals.",
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
const terminal = client.terminals.ref(resolvedId);
|
|
32
|
+
const keysSent = options.literal ? terminal.write(keys.join("")) : terminal.sendKeys(keys);
|
|
33
|
+
return {
|
|
34
|
+
terminalId: resolvedId,
|
|
35
|
+
keysSent,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
catch (err) {
|
|
39
|
+
throw toTerminalCommandError("TERMINAL_SEND_KEYS_FAILED", "send terminal keys", err);
|
|
40
|
+
}
|
|
41
|
+
finally {
|
|
42
|
+
await close().catch(() => { });
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=send-keys.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { CommandError, CommandOptions } from "../../output/index.js";
|
|
2
|
+
export interface TerminalCommandOptions extends CommandOptions {
|
|
3
|
+
host?: string;
|
|
4
|
+
}
|
|
5
|
+
export declare function connectTerminalClient(host?: string): Promise<{
|
|
6
|
+
client: import("@camerontaylor/paseo-client").PaseoApi;
|
|
7
|
+
daemonHost: string;
|
|
8
|
+
close: () => Promise<void>;
|
|
9
|
+
}>;
|
|
10
|
+
export declare function toTerminalCommandError(code: string, action: string, err: unknown): CommandError;
|
|
11
|
+
export declare function resolveTerminalId(client: Awaited<ReturnType<typeof connectTerminalClient>>["client"], idOrName: string): Promise<string | null>;
|
|
12
|
+
//# sourceMappingURL=shared.d.ts.map
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { createPaseoApi } from "@camerontaylor/paseo-client";
|
|
2
|
+
import { connectToDaemon, getDaemonHost } from "../../utils/client.js";
|
|
3
|
+
export async function connectTerminalClient(host) {
|
|
4
|
+
const daemonHost = getDaemonHost({ host });
|
|
5
|
+
try {
|
|
6
|
+
const client = await connectToDaemon({ host });
|
|
7
|
+
return { client: createPaseoApi(client), daemonHost, close: () => client.close() };
|
|
8
|
+
}
|
|
9
|
+
catch (err) {
|
|
10
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
11
|
+
const error = {
|
|
12
|
+
code: "DAEMON_NOT_RUNNING",
|
|
13
|
+
message: `Cannot connect to daemon at ${daemonHost}: ${message}`,
|
|
14
|
+
details: "Start the daemon with: paseo daemon start",
|
|
15
|
+
};
|
|
16
|
+
throw error;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export function toTerminalCommandError(code, action, err) {
|
|
20
|
+
if (err && typeof err === "object" && "code" in err && "message" in err) {
|
|
21
|
+
return err;
|
|
22
|
+
}
|
|
23
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
24
|
+
const rpcCode = typeof err === "object" && err !== null && "code" in err && typeof err.code === "string"
|
|
25
|
+
? err.code
|
|
26
|
+
: undefined;
|
|
27
|
+
return {
|
|
28
|
+
code: rpcCode ?? code,
|
|
29
|
+
message: `Failed to ${action}: ${message}`,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
export async function resolveTerminalId(client, idOrName) {
|
|
33
|
+
const payload = await client.terminals.list();
|
|
34
|
+
return resolveTerminalIdentifier(idOrName, payload.entries);
|
|
35
|
+
}
|
|
36
|
+
function resolveTerminalIdentifier(idOrName, terminals) {
|
|
37
|
+
if (!idOrName || terminals.length === 0) {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
const query = idOrName.toLowerCase();
|
|
41
|
+
const exactMatch = terminals.find((terminal) => terminal.id === idOrName);
|
|
42
|
+
if (exactMatch) {
|
|
43
|
+
return exactMatch.id;
|
|
44
|
+
}
|
|
45
|
+
const prefixMatches = terminals.filter((terminal) => terminal.id.toLowerCase().startsWith(query));
|
|
46
|
+
if (prefixMatches.length === 1 && prefixMatches[0]) {
|
|
47
|
+
return prefixMatches[0].id;
|
|
48
|
+
}
|
|
49
|
+
if (prefixMatches.length > 1) {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
const nameMatches = terminals.filter((terminal) => terminal.name?.toLowerCase() === query);
|
|
53
|
+
if (nameMatches.length === 1 && nameMatches[0]) {
|
|
54
|
+
return nameMatches[0].id;
|
|
55
|
+
}
|
|
56
|
+
const partialNameMatches = terminals.filter((terminal) => terminal.name?.toLowerCase().includes(query));
|
|
57
|
+
if (partialNameMatches.length === 1 && partialNameMatches[0]) {
|
|
58
|
+
return partialNameMatches[0].id;
|
|
59
|
+
}
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=shared.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Command } from "commander";
|
|
2
|
+
import type { SingleResult } from "../../output/index.js";
|
|
3
|
+
interface WorkspaceArchiveResult {
|
|
4
|
+
workspaceId: string;
|
|
5
|
+
status: "archived";
|
|
6
|
+
archivedAt: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function runArchiveCommand(workspaceId: string, options: {
|
|
9
|
+
host?: string;
|
|
10
|
+
}, _command: Command): Promise<SingleResult<WorkspaceArchiveResult>>;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=archive.d.ts.map
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { connectToDaemon, getDaemonHost } from "../../utils/client.js";
|
|
2
|
+
const workspaceArchiveSchema = {
|
|
3
|
+
idField: "workspaceId",
|
|
4
|
+
columns: [
|
|
5
|
+
{ header: "WORKSPACE ID", field: "workspaceId", width: 20 },
|
|
6
|
+
{ header: "STATUS", field: "status", width: 10 },
|
|
7
|
+
{ header: "ARCHIVED AT", field: "archivedAt", width: 26 },
|
|
8
|
+
],
|
|
9
|
+
};
|
|
10
|
+
export async function runArchiveCommand(workspaceId, options, _command) {
|
|
11
|
+
const host = getDaemonHost({ host: options.host });
|
|
12
|
+
const client = await connectToDaemon({ host: options.host }).catch((error) => {
|
|
13
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
14
|
+
throw {
|
|
15
|
+
code: "DAEMON_NOT_RUNNING",
|
|
16
|
+
message: `Cannot connect to daemon at ${host}: ${message}`,
|
|
17
|
+
};
|
|
18
|
+
});
|
|
19
|
+
try {
|
|
20
|
+
const payload = await client.archiveWorkspace(workspaceId);
|
|
21
|
+
if (payload.error) {
|
|
22
|
+
throw new Error(payload.error);
|
|
23
|
+
}
|
|
24
|
+
if (!payload.archivedAt) {
|
|
25
|
+
throw new Error("Workspace archive did not return an archive timestamp");
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
type: "single",
|
|
29
|
+
data: { workspaceId, status: "archived", archivedAt: payload.archivedAt },
|
|
30
|
+
schema: workspaceArchiveSchema,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
35
|
+
throw { code: "WORKSPACE_ARCHIVE_FAILED", message };
|
|
36
|
+
}
|
|
37
|
+
finally {
|
|
38
|
+
await client.close().catch(() => undefined);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=archive.js.map
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { Command } from "commander";
|
|
2
|
+
import type { CommandOptions, SingleResult } from "../../output/index.js";
|
|
3
|
+
import { type WorkspaceRow } from "./shared.js";
|
|
4
|
+
export interface WorkspaceCreateOptions extends CommandOptions {
|
|
5
|
+
isolation?: string;
|
|
6
|
+
path?: string;
|
|
7
|
+
project?: string;
|
|
8
|
+
title?: string;
|
|
9
|
+
mode?: string;
|
|
10
|
+
worktreeSlug?: string;
|
|
11
|
+
newBranch?: string;
|
|
12
|
+
base?: string;
|
|
13
|
+
branch?: string;
|
|
14
|
+
prNumber?: string;
|
|
15
|
+
forge?: string;
|
|
16
|
+
}
|
|
17
|
+
export declare function buildWorkspaceSource(options: WorkspaceCreateOptions): {
|
|
18
|
+
projectId?: string | undefined;
|
|
19
|
+
kind: "directory";
|
|
20
|
+
path: string;
|
|
21
|
+
} | {
|
|
22
|
+
baseBranch?: string | undefined;
|
|
23
|
+
branchName?: string | undefined;
|
|
24
|
+
action: "branch-off";
|
|
25
|
+
kind: "worktree";
|
|
26
|
+
cwd?: string;
|
|
27
|
+
projectId?: string;
|
|
28
|
+
worktreeSlug?: string;
|
|
29
|
+
} | {
|
|
30
|
+
action: "checkout";
|
|
31
|
+
refName: string;
|
|
32
|
+
kind: "worktree";
|
|
33
|
+
cwd?: string;
|
|
34
|
+
projectId?: string;
|
|
35
|
+
worktreeSlug?: string;
|
|
36
|
+
} | {
|
|
37
|
+
action: "checkout";
|
|
38
|
+
checkoutSource: {
|
|
39
|
+
number: number;
|
|
40
|
+
forge?: string | undefined;
|
|
41
|
+
kind: "change_request";
|
|
42
|
+
};
|
|
43
|
+
kind: "worktree";
|
|
44
|
+
cwd?: string;
|
|
45
|
+
projectId?: string;
|
|
46
|
+
worktreeSlug?: string;
|
|
47
|
+
};
|
|
48
|
+
export declare function runCreateCommand(options: WorkspaceCreateOptions, _command: Command): Promise<SingleResult<WorkspaceRow>>;
|
|
49
|
+
//# sourceMappingURL=create.d.ts.map
|