@getmateo/cli 0.0.0-stage → 0.19.8
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/LICENSE +211 -0
- package/bin/mateo +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 +143 -0
- package/dist/commands/agent/archive.d.ts +27 -0
- package/dist/commands/agent/archive.js +88 -0
- package/dist/commands/agent/attach.d.ts +8 -0
- package/dist/commands/agent/attach.js +160 -0
- package/dist/commands/agent/delete.d.ts +15 -0
- package/dist/commands/agent/delete.js +104 -0
- package/dist/commands/agent/detach.d.ts +16 -0
- package/dist/commands/agent/detach.js +44 -0
- package/dist/commands/agent/import.d.ts +14 -0
- package/dist/commands/agent/import.js +108 -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 +196 -0
- package/dist/commands/agent/logs.d.ts +39 -0
- package/dist/commands/agent/logs.js +369 -0
- package/dist/commands/agent/ls.d.ts +61 -0
- package/dist/commands/agent/ls.js +201 -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 +74 -0
- package/dist/commands/agent/reload.d.ts +25 -0
- package/dist/commands/agent/reload.js +64 -0
- package/dist/commands/agent/run.d.ts +77 -0
- package/dist/commands/agent/run.js +556 -0
- package/dist/commands/agent/send.d.ts +21 -0
- package/dist/commands/agent/send.js +187 -0
- package/dist/commands/agent/stop.d.ts +17 -0
- package/dist/commands/agent/stop.js +102 -0
- package/dist/commands/agent/update.d.ts +51 -0
- package/dist/commands/agent/update.js +173 -0
- package/dist/commands/agent/wait.d.ts +31 -0
- package/dist/commands/agent/wait.js +161 -0
- package/dist/commands/clone.d.ts +17 -0
- package/dist/commands/clone.js +59 -0
- package/dist/commands/daemon/config.d.ts +3 -0
- package/dist/commands/daemon/config.js +103 -0
- package/dist/commands/daemon/index.d.ts +3 -0
- package/dist/commands/daemon/index.js +28 -0
- package/dist/commands/daemon/local-daemon.d.ts +13 -0
- package/dist/commands/daemon/local-daemon.js +105 -0
- package/dist/commands/daemon/pair.d.ts +30 -0
- package/dist/commands/daemon/pair.js +145 -0
- package/dist/commands/daemon/reload.d.ts +12 -0
- package/dist/commands/daemon/reload.js +44 -0
- package/dist/commands/daemon/restart.d.ts +29 -0
- package/dist/commands/daemon/restart.js +169 -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 +89 -0
- package/dist/commands/daemon/start.d.ts +20 -0
- package/dist/commands/daemon/start.js +52 -0
- package/dist/commands/daemon/status.d.ts +13 -0
- package/dist/commands/daemon/status.js +119 -0
- package/dist/commands/daemon/stop.d.ts +20 -0
- package/dist/commands/daemon/stop.js +58 -0
- package/dist/commands/fleet/index.d.ts +4 -0
- package/dist/commands/fleet/index.js +57 -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 +24 -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 +41 -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 +17 -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 +37 -0
- package/dist/commands/hub/init.js +525 -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 +33 -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 +22 -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 +14 -0
- package/dist/commands/onboard.js +169 -0
- package/dist/commands/open.d.ts +4 -0
- package/dist/commands/open.js +91 -0
- package/dist/commands/permit/allow.d.ts +38 -0
- package/dist/commands/permit/allow.js +138 -0
- package/dist/commands/permit/deny.d.ts +13 -0
- package/dist/commands/permit/deny.js +100 -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 +21 -0
- package/dist/commands/permit/ls.js +54 -0
- package/dist/commands/plugin/index.d.ts +23 -0
- package/dist/commands/plugin/index.js +174 -0
- package/dist/commands/plugin/scaffold.d.ts +6 -0
- package/dist/commands/plugin/scaffold.js +212 -0
- package/dist/commands/plugin/shared.d.ts +7 -0
- package/dist/commands/plugin/shared.js +34 -0
- package/dist/commands/plugin/update.d.ts +37 -0
- package/dist/commands/plugin/update.js +58 -0
- package/dist/commands/project/create.d.ts +10 -0
- package/dist/commands/project/create.js +43 -0
- package/dist/commands/project/delete.d.ts +9 -0
- package/dist/commands/project/delete.js +35 -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 +52 -0
- package/dist/commands/project/shared.d.ts +11 -0
- package/dist/commands/project/shared.js +18 -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 +21 -0
- package/dist/commands/provider/ls.d.ts +19 -0
- package/dist/commands/provider/ls.js +46 -0
- package/dist/commands/provider/models.d.ts +20 -0
- package/dist/commands/provider/models.js +53 -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 +61 -0
- package/dist/commands/schedule/shared.js +360 -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 +19 -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 +12 -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/terminal/capture.d.ts +10 -0
- package/dist/commands/terminal/capture.js +67 -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 +51 -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 +44 -0
- package/dist/commands/terminal/shared.d.ts +13 -0
- package/dist/commands/terminal/shared.js +64 -0
- package/dist/commands/terminal/upgrade-hosts.d.ts +11 -0
- package/dist/commands/terminal/upgrade-hosts.js +46 -0
- package/dist/commands/usage/index.d.ts +29 -0
- package/dist/commands/usage/index.js +62 -0
- package/dist/commands/usage/presentation.d.ts +4 -0
- package/dist/commands/usage/presentation.js +146 -0
- package/dist/commands/workspace/archive.d.ts +13 -0
- package/dist/commands/workspace/archive.js +43 -0
- package/dist/commands/workspace/create.d.ts +50 -0
- package/dist/commands/workspace/create.js +132 -0
- package/dist/commands/workspace/index.d.ts +3 -0
- package/dist/commands/workspace/index.js +50 -0
- package/dist/commands/workspace/ls.d.ts +11 -0
- package/dist/commands/workspace/ls.js +33 -0
- package/dist/commands/workspace/rename.d.ts +23 -0
- package/dist/commands/workspace/rename.js +63 -0
- package/dist/commands/workspace/setup.d.ts +12 -0
- package/dist/commands/workspace/setup.js +41 -0
- package/dist/commands/workspace/shared.d.ts +15 -0
- package/dist/commands/workspace/shared.js +29 -0
- package/dist/commands/worktree/archive.d.ts +21 -0
- package/dist/commands/worktree/archive.js +108 -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 +50 -0
- package/dist/commands/worktree/index.d.ts +3 -0
- package/dist/commands/worktree/index.js +29 -0
- package/dist/commands/worktree/ls.d.ts +18 -0
- package/dist/commands/worktree/ls.js +73 -0
- package/dist/commands/worktree/repository-directory.d.ts +6 -0
- package/dist/commands/worktree/repository-directory.js +9 -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 +9 -0
- package/dist/output/pairing.js +36 -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 +43 -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 +62 -0
- package/dist/ssh/ssh-tunnel.d.ts +2 -0
- package/dist/ssh/ssh-tunnel.js +3 -0
- package/dist/utils/agent-directory.d.ts +31 -0
- package/dist/utils/agent-directory.js +48 -0
- package/dist/utils/caller-agent.d.ts +14 -0
- package/dist/utils/caller-agent.js +16 -0
- package/dist/utils/client-id.d.ts +2 -0
- package/dist/utils/client-id.js +31 -0
- package/dist/utils/client.d.ts +57 -0
- package/dist/utils/client.js +360 -0
- package/dist/utils/command-options.d.ts +8 -0
- package/dist/utils/command-options.js +49 -0
- package/dist/utils/daemon-target.d.ts +13 -0
- package/dist/utils/daemon-target.js +51 -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 +12 -0
- package/dist/utils/timeline.js +16 -0
- package/dist/utils/wait-for-stop.d.ts +2 -0
- package/dist/utils/wait-for-stop.js +28 -0
- package/dist/version.d.ts +5 -0
- package/dist/version.js +24 -0
- package/package.json +63 -4
- package/README.md +0 -3
|
@@ -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.daemonTarget);
|
|
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 `mateo 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.daemonTarget);
|
|
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 { MateoTerminal } from "@getmateo/client";
|
|
2
|
+
import type { OutputSchema } from "../../output/index.js";
|
|
3
|
+
export type TerminalRow = MateoTerminal;
|
|
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,44 @@
|
|
|
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
|
+
try {
|
|
5
|
+
const payload = await executeSendKeysCommand(terminalId, keys, options);
|
|
6
|
+
if (options.json) {
|
|
7
|
+
process.stdout.write(JSON.stringify(payload, null, 2) + "\n");
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
catch (err) {
|
|
11
|
+
const output = renderError(toCommandError(err), {
|
|
12
|
+
format: options.json ? "json" : "table",
|
|
13
|
+
noColor: options.color === false,
|
|
14
|
+
});
|
|
15
|
+
process.stderr.write(output + "\n");
|
|
16
|
+
process.exit(1);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
async function executeSendKeysCommand(terminalId, keys, options) {
|
|
20
|
+
const { client, close } = await connectTerminalClient(options.daemonTarget);
|
|
21
|
+
try {
|
|
22
|
+
const resolvedId = await resolveTerminalId(client, terminalId);
|
|
23
|
+
if (!resolvedId) {
|
|
24
|
+
throw {
|
|
25
|
+
code: "TERMINAL_NOT_FOUND",
|
|
26
|
+
message: `No terminal found matching: ${terminalId}`,
|
|
27
|
+
details: "Use `mateo terminal ls --all` to list available terminals.",
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
const terminal = client.terminals.ref(resolvedId);
|
|
31
|
+
const keysSent = options.literal ? terminal.write(keys.join("")) : terminal.sendKeys(keys);
|
|
32
|
+
return {
|
|
33
|
+
terminalId: resolvedId,
|
|
34
|
+
keysSent,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
catch (err) {
|
|
38
|
+
throw toTerminalCommandError("TERMINAL_SEND_KEYS_FAILED", "send terminal keys", err);
|
|
39
|
+
}
|
|
40
|
+
finally {
|
|
41
|
+
await close().catch(() => { });
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=send-keys.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { DaemonTarget } from "../../utils/daemon-target.js";
|
|
2
|
+
import type { CommandError, CommandOptions } from "../../output/index.js";
|
|
3
|
+
export interface TerminalCommandOptions extends CommandOptions {
|
|
4
|
+
host?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function connectTerminalClient(target: DaemonTarget): Promise<{
|
|
7
|
+
client: import("@getmateo/client").MateoApi;
|
|
8
|
+
daemonHost: string;
|
|
9
|
+
close: () => Promise<void>;
|
|
10
|
+
}>;
|
|
11
|
+
export declare function toTerminalCommandError(code: string, action: string, err: unknown): CommandError;
|
|
12
|
+
export declare function resolveTerminalId(client: Awaited<ReturnType<typeof connectTerminalClient>>["client"], idOrName: string): Promise<string | null>;
|
|
13
|
+
//# sourceMappingURL=shared.d.ts.map
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { createMateoApi } from "@getmateo/client";
|
|
2
|
+
import { connectToDaemon, getDaemonHost } from "../../utils/client.js";
|
|
3
|
+
export async function connectTerminalClient(target) {
|
|
4
|
+
const daemonHost = getDaemonHost({ target });
|
|
5
|
+
try {
|
|
6
|
+
const client = await connectToDaemon({ target });
|
|
7
|
+
return { client: createMateoApi(client), daemonHost, close: () => client.close() };
|
|
8
|
+
}
|
|
9
|
+
catch (err) {
|
|
10
|
+
if (err && typeof err === "object" && "code" in err)
|
|
11
|
+
throw err;
|
|
12
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
13
|
+
const error = {
|
|
14
|
+
code: "DAEMON_NOT_RUNNING",
|
|
15
|
+
message: `Cannot connect to daemon at ${daemonHost}: ${message}`,
|
|
16
|
+
details: "Start the daemon with: mateo daemon start",
|
|
17
|
+
};
|
|
18
|
+
throw error;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export function toTerminalCommandError(code, action, err) {
|
|
22
|
+
if (err && typeof err === "object" && "code" in err && "message" in err) {
|
|
23
|
+
return err;
|
|
24
|
+
}
|
|
25
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
26
|
+
const rpcCode = typeof err === "object" && err !== null && "code" in err && typeof err.code === "string"
|
|
27
|
+
? err.code
|
|
28
|
+
: undefined;
|
|
29
|
+
return {
|
|
30
|
+
code: rpcCode ?? code,
|
|
31
|
+
message: `Failed to ${action}: ${message}`,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
export async function resolveTerminalId(client, idOrName) {
|
|
35
|
+
const payload = await client.terminals.list();
|
|
36
|
+
return resolveTerminalIdentifier(idOrName, payload.entries);
|
|
37
|
+
}
|
|
38
|
+
function resolveTerminalIdentifier(idOrName, terminals) {
|
|
39
|
+
if (!idOrName || terminals.length === 0) {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
const query = idOrName.toLowerCase();
|
|
43
|
+
const exactMatch = terminals.find((terminal) => terminal.id === idOrName);
|
|
44
|
+
if (exactMatch) {
|
|
45
|
+
return exactMatch.id;
|
|
46
|
+
}
|
|
47
|
+
const prefixMatches = terminals.filter((terminal) => terminal.id.toLowerCase().startsWith(query));
|
|
48
|
+
if (prefixMatches.length === 1 && prefixMatches[0]) {
|
|
49
|
+
return prefixMatches[0].id;
|
|
50
|
+
}
|
|
51
|
+
if (prefixMatches.length > 1) {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
const nameMatches = terminals.filter((terminal) => terminal.name?.toLowerCase() === query);
|
|
55
|
+
if (nameMatches.length === 1 && nameMatches[0]) {
|
|
56
|
+
return nameMatches[0].id;
|
|
57
|
+
}
|
|
58
|
+
const partialNameMatches = terminals.filter((terminal) => terminal.name?.toLowerCase().includes(query));
|
|
59
|
+
if (partialNameMatches.length === 1 && partialNameMatches[0]) {
|
|
60
|
+
return partialNameMatches[0].id;
|
|
61
|
+
}
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=shared.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Command } from "commander";
|
|
2
|
+
import type { TerminalHostRetirement, retireLegacyTerminalHosts } from "@getmateo/server/terminal-host-control";
|
|
3
|
+
import type { CommandOptions, SingleResult } from "../../output/index.js";
|
|
4
|
+
interface TerminalHostRetirementReport {
|
|
5
|
+
home: string;
|
|
6
|
+
force: boolean;
|
|
7
|
+
hosts: TerminalHostRetirement[];
|
|
8
|
+
}
|
|
9
|
+
export declare function runRetireOldHostsCommand(options: CommandOptions, _command: Command, retireHosts?: typeof retireLegacyTerminalHosts): Promise<SingleResult<TerminalHostRetirementReport>>;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=upgrade-hosts.d.ts.map
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { parseTimeoutMs } from "../daemon/local-daemon.js";
|
|
2
|
+
export async function runRetireOldHostsCommand(options, _command, retireHosts) {
|
|
3
|
+
if (options.daemonTarget.kind !== "instance") {
|
|
4
|
+
throw {
|
|
5
|
+
code: "INVALID_OPTIONS",
|
|
6
|
+
message: "Terminal host retirement requires a local --home, not a daemon endpoint.",
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
const control = retireHosts ??
|
|
10
|
+
(await import("@getmateo/server/terminal-host-control")).retireLegacyTerminalHosts;
|
|
11
|
+
const home = options.daemonTarget.home;
|
|
12
|
+
const force = options.force === true;
|
|
13
|
+
const hosts = await control({
|
|
14
|
+
mateoHome: home,
|
|
15
|
+
force,
|
|
16
|
+
timeoutMs: parseTimeoutMs(options.timeout, 15000),
|
|
17
|
+
});
|
|
18
|
+
if (hosts.some((host) => host.outcome === "failed"))
|
|
19
|
+
process.exitCode = 1;
|
|
20
|
+
return {
|
|
21
|
+
type: "single",
|
|
22
|
+
data: { home, force, hosts },
|
|
23
|
+
schema: {
|
|
24
|
+
idField: "home",
|
|
25
|
+
columns: [],
|
|
26
|
+
renderHuman: () => renderRetirementReport({ home, force, hosts }),
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function renderRetirementReport(report) {
|
|
31
|
+
const lines = [`Home: ${report.home}`, "Scope: terminal-host with protocol.max < 2 only"];
|
|
32
|
+
if (!report.force) {
|
|
33
|
+
lines.push("Report only. --force stops the listed hosts and all their terminal tasks.");
|
|
34
|
+
}
|
|
35
|
+
if (report.hosts.length === 0)
|
|
36
|
+
lines.push("No legacy terminal hosts found.");
|
|
37
|
+
for (const host of report.hosts) {
|
|
38
|
+
const ids = host.terminalIds === null ? "unknown" : host.terminalIds.join(", ") || "none";
|
|
39
|
+
const count = host.terminalCount === null ? "unknown" : String(host.terminalCount);
|
|
40
|
+
lines.push(`${host.hostId}: ${host.outcome}`, ` PID ${host.pid}; start ${host.processStartedAt ?? "unknown"}; protocol ${host.protocol.min}-${host.protocol.max}`, ` Running terminals (${count}): ${ids}`, " Reason: processor handover unavailable");
|
|
41
|
+
if (host.error)
|
|
42
|
+
lines.push(` Error: ${host.error}`);
|
|
43
|
+
}
|
|
44
|
+
return lines.join("\n");
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=upgrade-hosts.js.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import type { DaemonClient } from "@getmateo/client/internal/daemon-client";
|
|
3
|
+
import type { UsageReportEntry } from "@getmateo/protocol/messages";
|
|
4
|
+
import { type ConnectOptions } from "../../utils/client.js";
|
|
5
|
+
import { type CommandOptions, type CommandResult } from "../../output/index.js";
|
|
6
|
+
interface UsageOptions extends CommandOptions {
|
|
7
|
+
agent?: string;
|
|
8
|
+
refresh?: boolean;
|
|
9
|
+
}
|
|
10
|
+
type UsageSelection = {
|
|
11
|
+
kind: "list";
|
|
12
|
+
} | {
|
|
13
|
+
kind: "inspect";
|
|
14
|
+
id: string;
|
|
15
|
+
};
|
|
16
|
+
interface UsageClient {
|
|
17
|
+
getLastServerInfoMessage(): {
|
|
18
|
+
features?: {
|
|
19
|
+
usageSources?: boolean;
|
|
20
|
+
};
|
|
21
|
+
} | null;
|
|
22
|
+
listUsageReports: DaemonClient["listUsageReports"];
|
|
23
|
+
close: DaemonClient["close"];
|
|
24
|
+
}
|
|
25
|
+
type ConnectUsage = (options: ConnectOptions) => Promise<UsageClient>;
|
|
26
|
+
export declare function runUsageCommand(options: UsageOptions, selection: UsageSelection, connect?: ConnectUsage): Promise<CommandResult<UsageReportEntry>>;
|
|
27
|
+
export declare function createUsageCommand(): Command;
|
|
28
|
+
export {};
|
|
29
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import { connectToDaemon } from "../../utils/client.js";
|
|
3
|
+
import { addJsonAndDaemonHostOptions } from "../../utils/command-options.js";
|
|
4
|
+
import { withOutput } from "../../output/index.js";
|
|
5
|
+
import { usageSchema } from "./presentation.js";
|
|
6
|
+
export async function runUsageCommand(options, selection, connect = connectToDaemon) {
|
|
7
|
+
const conflictingSelectors = selection.kind === "inspect" && options.agent !== undefined;
|
|
8
|
+
if (conflictingSelectors) {
|
|
9
|
+
throw {
|
|
10
|
+
code: "INVALID_OPTIONS",
|
|
11
|
+
message: "--agent cannot be combined with usage inspect. Use usage ls --agent <id> for agent account usage, or usage inspect <report-id> for an exact report.",
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
const client = await connect({ target: options.daemonTarget });
|
|
15
|
+
try {
|
|
16
|
+
if (client.getLastServerInfoMessage()?.features?.usageSources !== true) {
|
|
17
|
+
throw { code: "UNSUPPORTED_HOST", message: "Update the host to use usage reports." };
|
|
18
|
+
}
|
|
19
|
+
if (selection.kind === "list") {
|
|
20
|
+
const { reports } = await client.listUsageReports({
|
|
21
|
+
agentId: options.agent,
|
|
22
|
+
forceRefresh: options.refresh,
|
|
23
|
+
});
|
|
24
|
+
return { type: "list", data: reports, schema: usageSchema };
|
|
25
|
+
}
|
|
26
|
+
// Report-ID queries only select known accounts. Discover before selecting, including on cold hosts.
|
|
27
|
+
const { reports } = await client.listUsageReports();
|
|
28
|
+
let entry = reports.find((report) => report.id === selection.id);
|
|
29
|
+
if (entry && options.refresh) {
|
|
30
|
+
const refreshed = await client.listUsageReports({
|
|
31
|
+
reportIds: [selection.id],
|
|
32
|
+
forceRefresh: true,
|
|
33
|
+
});
|
|
34
|
+
entry = refreshed.reports.find((report) => report.id === selection.id);
|
|
35
|
+
}
|
|
36
|
+
if (!entry) {
|
|
37
|
+
throw { code: "REPORT_NOT_FOUND", message: `Unknown usage report: ${selection.id}` };
|
|
38
|
+
}
|
|
39
|
+
return { type: "single", data: entry, schema: usageSchema };
|
|
40
|
+
}
|
|
41
|
+
finally {
|
|
42
|
+
await client.close().catch(() => { });
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
function addListOptions(command) {
|
|
46
|
+
return addJsonAndDaemonHostOptions(command)
|
|
47
|
+
.option("--agent <id>", "Show account quota associated with this agent (not agent token consumption)")
|
|
48
|
+
.option("--refresh", "Refresh usage instead of using the host cache");
|
|
49
|
+
}
|
|
50
|
+
export function createUsageCommand() {
|
|
51
|
+
const usage = addListOptions(new Command("usage").description("Show account usage reports"));
|
|
52
|
+
const list = (options, _command) => runUsageCommand(options, { kind: "list" });
|
|
53
|
+
usage.action(withOutput(list));
|
|
54
|
+
addListOptions(usage.command("ls").description("List account quotas and balances")).action(withOutput(list));
|
|
55
|
+
addJsonAndDaemonHostOptions(usage
|
|
56
|
+
.command("inspect")
|
|
57
|
+
.description("Show a complete account usage report")
|
|
58
|
+
.argument("<report-id>", "Exact opaque Report ID")
|
|
59
|
+
.option("--refresh", "Refresh the selected report instead of using the host cache")).action(withOutput((id, options, _command) => runUsageCommand(options, { kind: "inspect", id })));
|
|
60
|
+
return usage;
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { renderTable } from "../../output/index.js";
|
|
2
|
+
function value(input) {
|
|
3
|
+
return input == null ? "-" : String(input);
|
|
4
|
+
}
|
|
5
|
+
function percent(input) {
|
|
6
|
+
return input == null ? "-" : `${input}%`;
|
|
7
|
+
}
|
|
8
|
+
function problemText(problem) {
|
|
9
|
+
if (problem.kind === "no_quota")
|
|
10
|
+
return problem.detail;
|
|
11
|
+
const remedy = problem.refreshedBy
|
|
12
|
+
? `Run ${problem.refreshedBy} to refresh login.`
|
|
13
|
+
: "Sign in again.";
|
|
14
|
+
if (problem.kind === "expired")
|
|
15
|
+
return `Login expired at ${problem.expiresAt}. ${remedy}`;
|
|
16
|
+
return `Login rejected (HTTP ${problem.status}). ${remedy}`;
|
|
17
|
+
}
|
|
18
|
+
function failureText(report) {
|
|
19
|
+
if (report.status === "error")
|
|
20
|
+
return report.error;
|
|
21
|
+
if (report.status === "unavailable")
|
|
22
|
+
return problemText(report.problem);
|
|
23
|
+
return "-";
|
|
24
|
+
}
|
|
25
|
+
function windowText(window) {
|
|
26
|
+
return `${window.label}: ${percent(window.usedPct)} used, ${percent(window.remainingPct)} remaining`;
|
|
27
|
+
}
|
|
28
|
+
function balanceText(balance) {
|
|
29
|
+
return `${balance.label}: ${value(balance.used)} used, ${value(balance.remaining)} remaining, ${value(balance.limit)} limit (${balance.unit})`;
|
|
30
|
+
}
|
|
31
|
+
function summary(entry) {
|
|
32
|
+
const { report } = entry;
|
|
33
|
+
if (report.status !== "available") {
|
|
34
|
+
const lines = [failureText(report)];
|
|
35
|
+
for (const login of entry.loginErrors ?? [])
|
|
36
|
+
lines.push(`${login.harness}: ${failureText(login.report)}`);
|
|
37
|
+
if (entry.lastSuccessful) {
|
|
38
|
+
lines.push(`Last successful: ${entry.lastSuccessful.fetchedAt}`);
|
|
39
|
+
lines.push(...availableSummary(entry.lastSuccessful.report).map((line) => `Retained: ${line}`));
|
|
40
|
+
}
|
|
41
|
+
else
|
|
42
|
+
lines.push("No successful update");
|
|
43
|
+
return lines;
|
|
44
|
+
}
|
|
45
|
+
return [...availableSummary(report), `Last successful: ${successfulTime(entry)}`];
|
|
46
|
+
}
|
|
47
|
+
function availableSummary(report) {
|
|
48
|
+
const lines = report.windows.map(windowText);
|
|
49
|
+
lines.push(...(report.balances ?? []).map(balanceText));
|
|
50
|
+
return lines.length ? lines : ["-"];
|
|
51
|
+
}
|
|
52
|
+
const summarySchema = {
|
|
53
|
+
idField: "id",
|
|
54
|
+
columns: [
|
|
55
|
+
{ header: "REPORT ID", field: "id" },
|
|
56
|
+
{ header: "SOURCE", field: "source" },
|
|
57
|
+
{ header: "ACCOUNT", field: "account" },
|
|
58
|
+
{ header: "STATUS", field: "status" },
|
|
59
|
+
{ header: "USAGE", field: "usage" },
|
|
60
|
+
{ header: "FETCHED (LATEST ATTEMPT)", field: "fetched" },
|
|
61
|
+
],
|
|
62
|
+
};
|
|
63
|
+
function inspect(entry) {
|
|
64
|
+
const lines = [
|
|
65
|
+
`Report ID: ${entry.id}`,
|
|
66
|
+
`Source: ${entry.sourceLabel}`,
|
|
67
|
+
`Source ID: ${entry.sourceId}`,
|
|
68
|
+
`Account: ${value(entry.account.label)}`,
|
|
69
|
+
`Status: ${entry.report.status}`,
|
|
70
|
+
`Latest attempt: ${value(entry.fetchedAt)}`,
|
|
71
|
+
];
|
|
72
|
+
const report = entry.report.status === "available" ? entry.report : entry.lastSuccessful?.report;
|
|
73
|
+
const successfulAt = successfulTime(entry);
|
|
74
|
+
lines.push(successfulAt ? `Last successful: ${successfulAt}` : "No successful update");
|
|
75
|
+
if (entry.report.status !== "available")
|
|
76
|
+
lines.push(`Reason: ${failureText(entry.report)}`);
|
|
77
|
+
if (report) {
|
|
78
|
+
if (entry.report.status !== "available")
|
|
79
|
+
lines.push("Retained usage:");
|
|
80
|
+
lines.push(...availableDetails(report));
|
|
81
|
+
}
|
|
82
|
+
if (entry.loginErrors?.length) {
|
|
83
|
+
lines.push("Login failures:");
|
|
84
|
+
for (const login of entry.loginErrors)
|
|
85
|
+
lines.push(` ${login.harness}: ${failureText(login.report)}`);
|
|
86
|
+
}
|
|
87
|
+
return lines.join("\n");
|
|
88
|
+
}
|
|
89
|
+
export const usageSchema = {
|
|
90
|
+
idField: "id",
|
|
91
|
+
columns: [],
|
|
92
|
+
renderHuman(result, options) {
|
|
93
|
+
if (result.type === "single")
|
|
94
|
+
return inspect(result.data);
|
|
95
|
+
if (!result.data.length)
|
|
96
|
+
return "No usage reports returned";
|
|
97
|
+
const rows = [];
|
|
98
|
+
for (const entry of result.data) {
|
|
99
|
+
for (const [index, usage] of summary(entry).entries()) {
|
|
100
|
+
const first = index === 0;
|
|
101
|
+
rows.push({
|
|
102
|
+
id: first ? entry.id : "",
|
|
103
|
+
source: first ? entry.sourceLabel : "",
|
|
104
|
+
account: first ? value(entry.account.label) : "",
|
|
105
|
+
status: first ? entry.report.status : "",
|
|
106
|
+
usage,
|
|
107
|
+
fetched: first ? value(entry.fetchedAt) : "",
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return renderTable({ type: "list", data: rows, schema: summarySchema }, options);
|
|
112
|
+
},
|
|
113
|
+
};
|
|
114
|
+
function availableDetails(report) {
|
|
115
|
+
const lines = [];
|
|
116
|
+
lines.push(`Plan: ${value(report.planLabel)}`, "Windows:");
|
|
117
|
+
if (!report.windows.length)
|
|
118
|
+
lines.push(" -");
|
|
119
|
+
for (const window of report.windows) {
|
|
120
|
+
lines.push(` ${windowText(window)} [${window.id}]`, ` Resets: ${value(window.resetsAt)}`);
|
|
121
|
+
if (window.runsOutAt != null)
|
|
122
|
+
lines.push(` Runs out: ${window.runsOutAt}`);
|
|
123
|
+
if (window.shortfallPct != null)
|
|
124
|
+
lines.push(` Shortfall: ${percent(window.shortfallPct)}`);
|
|
125
|
+
}
|
|
126
|
+
lines.push("Balances:");
|
|
127
|
+
if (!report.balances?.length)
|
|
128
|
+
lines.push(" -");
|
|
129
|
+
for (const balance of report.balances ?? []) {
|
|
130
|
+
lines.push(` ${balanceText(balance)} [${balance.id}]`, ` Resets: ${value(balance.resetsAt)}`);
|
|
131
|
+
}
|
|
132
|
+
lines.push("Details:");
|
|
133
|
+
if (!report.details?.length)
|
|
134
|
+
lines.push(" -");
|
|
135
|
+
for (const detail of report.details ?? [])
|
|
136
|
+
lines.push(` ${detail.label}: ${detail.value}`);
|
|
137
|
+
return lines;
|
|
138
|
+
}
|
|
139
|
+
function successfulTime(entry) {
|
|
140
|
+
// COMPAT(usageSuccessfulAt): added in v0.12.0, remove after 2027-04-17 once daemon floor >= v0.12.0.
|
|
141
|
+
// Only available reports from older daemons can use their attempt timestamp as freshness.
|
|
142
|
+
if (entry.report.status === "available")
|
|
143
|
+
return entry.successfulAt ?? entry.fetchedAt;
|
|
144
|
+
return entry.lastSuccessful?.fetchedAt;
|
|
145
|
+
}
|
|
146
|
+
//# sourceMappingURL=presentation.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
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
|
+
daemonTarget: import("../../utils/daemon-target.js").DaemonTarget;
|
|
11
|
+
}, _command: Command): Promise<SingleResult<WorkspaceArchiveResult>>;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=archive.d.ts.map
|
|
@@ -0,0 +1,43 @@
|
|
|
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({ target: options.daemonTarget });
|
|
12
|
+
const client = await connectToDaemon({ target: options.daemonTarget }).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
|
+
if (error && typeof error === "object" && "code" in error)
|
|
35
|
+
throw error;
|
|
36
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
37
|
+
throw { code: "WORKSPACE_ARCHIVE_FAILED", message };
|
|
38
|
+
}
|
|
39
|
+
finally {
|
|
40
|
+
await client.close().catch(() => undefined);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=archive.js.map
|
|
@@ -0,0 +1,50 @@
|
|
|
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
|
+
background?: boolean;
|
|
17
|
+
}
|
|
18
|
+
export declare function buildWorkspaceSource(options: WorkspaceCreateOptions): {
|
|
19
|
+
projectId?: string | undefined;
|
|
20
|
+
kind: "directory";
|
|
21
|
+
path: string;
|
|
22
|
+
} | {
|
|
23
|
+
baseBranch?: string | undefined;
|
|
24
|
+
branchName?: string | undefined;
|
|
25
|
+
action: "branch-off";
|
|
26
|
+
kind: "worktree";
|
|
27
|
+
cwd?: string;
|
|
28
|
+
projectId?: string;
|
|
29
|
+
worktreeSlug?: string;
|
|
30
|
+
} | {
|
|
31
|
+
action: "checkout";
|
|
32
|
+
refName: string;
|
|
33
|
+
kind: "worktree";
|
|
34
|
+
cwd?: string;
|
|
35
|
+
projectId?: string;
|
|
36
|
+
worktreeSlug?: string;
|
|
37
|
+
} | {
|
|
38
|
+
action: "checkout";
|
|
39
|
+
checkoutSource: {
|
|
40
|
+
number: number;
|
|
41
|
+
forge?: string | undefined;
|
|
42
|
+
kind: "change_request";
|
|
43
|
+
};
|
|
44
|
+
kind: "worktree";
|
|
45
|
+
cwd?: string;
|
|
46
|
+
projectId?: string;
|
|
47
|
+
worktreeSlug?: string;
|
|
48
|
+
};
|
|
49
|
+
export declare function runCreateCommand(options: WorkspaceCreateOptions, _command: Command): Promise<SingleResult<WorkspaceRow>>;
|
|
50
|
+
//# sourceMappingURL=create.d.ts.map
|