@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.
- package/dist/cli.js +4 -3
- package/dist/commands/agent/attach.js +10 -8
- package/dist/commands/agent/index.js +3 -3
- package/dist/commands/agent/logs.js +6 -6
- package/dist/commands/agent/run.js +2 -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 +15 -5
- package/dist/commands/hub/deploy.js +73 -4
- package/dist/commands/hub/hub-client/index.d.ts +4 -3
- package/dist/commands/hub/hub-client/index.js +23 -10
- package/dist/commands/hub/hub-client/internal/contracts.d.ts +15 -15
- package/dist/commands/hub/hub-client/internal/contracts.js +13 -14
- package/dist/commands/hub/init-plan.d.ts +5 -25
- package/dist/commands/hub/init-plan.js +39 -85
- package/dist/commands/hub/init.js +81 -112
- package/dist/commands/hub/starter-trigger.d.ts +2 -2
- package/dist/commands/hub/starter-trigger.js +11 -9
- package/dist/commands/plugin/index.d.ts +1 -1
- package/dist/commands/plugin/index.js +11 -20
- package/dist/commands/plugin/scaffold.js +92 -14
- package/dist/commands/schedule/shared.js +2 -2
- package/dist/commands/terminal/capture.js +3 -3
- package/dist/commands/terminal/create.d.ts +1 -0
- package/dist/commands/terminal/create.js +13 -22
- package/dist/commands/terminal/index.js +9 -7
- package/dist/commands/terminal/kill.js +5 -5
- package/dist/commands/terminal/ls.d.ts +1 -0
- package/dist/commands/terminal/ls.js +6 -6
- package/dist/commands/terminal/schema.d.ts +2 -10
- package/dist/commands/terminal/schema.js +1 -7
- package/dist/commands/terminal/send-keys.js +5 -36
- package/dist/commands/terminal/shared.d.ts +3 -3
- package/dist/commands/terminal/shared.js +4 -3
- package/dist/commands/workspace/index.js +5 -0
- package/dist/commands/workspace/setup.d.ts +11 -0
- package/dist/commands/workspace/setup.js +41 -0
- package/dist/output/render.js +2 -1
- package/dist/output/with-output.js +4 -6
- package/dist/utils/client.d.ts +1 -0
- package/dist/utils/client.js +6 -2
- package/dist/utils/command-options.d.ts +1 -0
- package/dist/utils/command-options.js +8 -0
- package/package.json +4 -4
package/dist/cli.js
CHANGED
|
@@ -32,7 +32,7 @@ import { addImportOptions, runImportCommand } from "./commands/agent/import.js";
|
|
|
32
32
|
import { withOutput } from "./output/index.js";
|
|
33
33
|
import { runCloneCommand } from "./commands/clone.js";
|
|
34
34
|
import { onboardCommand } from "./commands/onboard.js";
|
|
35
|
-
import { addDaemonHostOption, addJsonAndDaemonHostOptions, addJsonOption, } from "./utils/command-options.js";
|
|
35
|
+
import { addDaemonHostOption, addJsonAndDaemonHostOptions, addJsonOption, withGlobalOptions, } from "./utils/command-options.js";
|
|
36
36
|
import { resolveCliVersion } from "./version.js";
|
|
37
37
|
const VERSION = resolveCliVersion();
|
|
38
38
|
function resolveHostnamesOption(hostnames, allowedHosts) {
|
|
@@ -54,6 +54,7 @@ export function createCli() {
|
|
|
54
54
|
.option("-q, --quiet", "minimal output (IDs only)")
|
|
55
55
|
.option("--no-headers", "omit table headers")
|
|
56
56
|
.option("--no-color", "disable colored output");
|
|
57
|
+
addDaemonHostOption(program);
|
|
57
58
|
// Primary agent commands (top-level)
|
|
58
59
|
addJsonAndDaemonHostOptions(addLsOptions(program.command("ls"))).action(withOutput(runLsCommand));
|
|
59
60
|
addJsonAndDaemonHostOptions(addRunOptions(program.command("run"))).action(withOutput(runRunCommand));
|
|
@@ -65,8 +66,8 @@ export function createCli() {
|
|
|
65
66
|
.requiredOption("--dir <path>", "Parent directory to clone into (for example: ~/workspace)"))
|
|
66
67
|
.addOption(new Option("--protocol <protocol>", "Protocol for owner/repo shorthand repositories").choices(["https", "ssh"]))
|
|
67
68
|
.action(withOutput(runCloneCommand));
|
|
68
|
-
addDaemonHostOption(addAttachOptions(program.command("attach"))).action(runAttachCommand);
|
|
69
|
-
addDaemonHostOption(addLogsOptions(program.command("logs"))).action(runLogsCommand);
|
|
69
|
+
addDaemonHostOption(addAttachOptions(program.command("attach"))).action(withGlobalOptions(runAttachCommand));
|
|
70
|
+
addDaemonHostOption(addLogsOptions(program.command("logs"))).action(withGlobalOptions(runLogsCommand));
|
|
70
71
|
addJsonAndDaemonHostOptions(addStopOptions(program.command("stop"))).action(withOutput(runStopCommand));
|
|
71
72
|
addJsonAndDaemonHostOptions(addDeleteOptions(program.command("delete"))).action(withOutput(runDeleteCommand));
|
|
72
73
|
addJsonAndDaemonHostOptions(addSendOptions(program.command("send"))).action(withOutput(runSendCommand));
|
|
@@ -100,7 +100,7 @@ export async function runAttachCommand(id, options, _command) {
|
|
|
100
100
|
}
|
|
101
101
|
const resolvedId = fetchResult.agent.id;
|
|
102
102
|
// Print header
|
|
103
|
-
console.log(`
|
|
103
|
+
console.log(`Fetching history for agent ${resolvedId.substring(0, 7)}...`);
|
|
104
104
|
console.log(`(Press Ctrl+C to detach)\n`);
|
|
105
105
|
// Print existing output from timeline fetch.
|
|
106
106
|
try {
|
|
@@ -117,14 +117,16 @@ export async function runAttachCommand(id, options, _command) {
|
|
|
117
117
|
console.warn("Warning: failed to fetch existing timeline", error);
|
|
118
118
|
}
|
|
119
119
|
// Subscribe to new events
|
|
120
|
-
const unsubscribe = client.
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
120
|
+
const unsubscribe = client.subscribeAgentTimeline(resolvedId, (message) => {
|
|
121
|
+
if (message.type === "agent.timeline.replacement") {
|
|
122
|
+
console.log("\n[Timeline replaced; earlier output is no longer current]");
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
printStreamEvent(message.payload.event);
|
|
126
|
+
}
|
|
127
127
|
});
|
|
128
|
+
await unsubscribe.ready;
|
|
129
|
+
console.log(`Attached to agent ${resolvedId.substring(0, 7)}.`);
|
|
128
130
|
// Handle Ctrl+C to detach gracefully
|
|
129
131
|
let detached = false;
|
|
130
132
|
const detach = () => {
|
|
@@ -16,15 +16,15 @@ import { runUpdateCommand } from "./update.js";
|
|
|
16
16
|
import { runDetachCommand } from "./detach.js";
|
|
17
17
|
import { addOpenOptions, runOpenCommand } from "./open.js";
|
|
18
18
|
import { withOutput } from "../../output/index.js";
|
|
19
|
-
import { addDaemonHostOption, addJsonAndDaemonHostOptions, collectMultiple, } from "../../utils/command-options.js";
|
|
19
|
+
import { addDaemonHostOption, addJsonAndDaemonHostOptions, collectMultiple, withGlobalOptions, } from "../../utils/command-options.js";
|
|
20
20
|
export function createAgentCommand() {
|
|
21
21
|
const agent = new Command("agent").description("Manage agents (advanced operations)");
|
|
22
22
|
// Primary agent commands (same as top-level)
|
|
23
23
|
addJsonAndDaemonHostOptions(addLsOptions(agent.command("ls"))).action(withOutput(runLsCommand));
|
|
24
24
|
addJsonAndDaemonHostOptions(addRunOptions(agent.command("run"))).action(withOutput(runRunCommand));
|
|
25
25
|
addJsonAndDaemonHostOptions(addImportOptions(agent.command("import"))).action(withOutput(runImportCommand));
|
|
26
|
-
addDaemonHostOption(addAttachOptions(agent.command("attach"))).action(runAttachCommand);
|
|
27
|
-
addDaemonHostOption(addLogsOptions(agent.command("logs"))).action(runLogsCommand);
|
|
26
|
+
addDaemonHostOption(addAttachOptions(agent.command("attach"))).action(withGlobalOptions(runAttachCommand));
|
|
27
|
+
addDaemonHostOption(addLogsOptions(agent.command("logs"))).action(withGlobalOptions(runLogsCommand));
|
|
28
28
|
addJsonAndDaemonHostOptions(addOpenOptions(agent.command("open"))).action(withOutput(runOpenCommand));
|
|
29
29
|
addJsonAndDaemonHostOptions(addStopOptions(agent.command("stop"))).action(withOutput(runStopCommand));
|
|
30
30
|
addJsonAndDaemonHostOptions(addDeleteOptions(agent.command("delete"))).action(withOutput(runDeleteCommand));
|
|
@@ -146,13 +146,11 @@ async function runFollowMode(client, agentId, options) {
|
|
|
146
146
|
}
|
|
147
147
|
// Subscribe to new events
|
|
148
148
|
const tailLabel = tailCount === 0 ? "no history" : `last ${tailCount} entr${tailCount === 1 ? "y" : "ies"}`;
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
if (message.type !== "agent_stream")
|
|
153
|
-
return;
|
|
154
|
-
if (message.payload.agentId !== agentId)
|
|
149
|
+
const unsubscribe = client.subscribeAgentTimeline(agentId, (message) => {
|
|
150
|
+
if (message.type === "agent.timeline.replacement") {
|
|
151
|
+
console.log("\n[Timeline replaced; earlier output is no longer current]");
|
|
155
152
|
return;
|
|
153
|
+
}
|
|
156
154
|
if (message.payload.event.type === "timeline") {
|
|
157
155
|
const item = message.payload.event.item;
|
|
158
156
|
// Apply filter
|
|
@@ -166,6 +164,8 @@ async function runFollowMode(client, agentId, options) {
|
|
|
166
164
|
}
|
|
167
165
|
}
|
|
168
166
|
});
|
|
167
|
+
await unsubscribe.ready;
|
|
168
|
+
console.log(`\n--- Following logs (${tailLabel}; Ctrl+C to stop) ---\n`);
|
|
169
169
|
// Wait for interrupt
|
|
170
170
|
await new Promise((resolve) => {
|
|
171
171
|
const cleanup = () => {
|
|
@@ -410,6 +410,8 @@ async function resolveRunWorkspace(client, options, cwd) {
|
|
|
410
410
|
const branch = result.workspace.gitRuntime?.currentBranch;
|
|
411
411
|
const label = branch ? `${result.workspace.name} (${branch})` : result.workspace.name;
|
|
412
412
|
console.error(`Created workspace ${result.workspace.id} - ${label}`);
|
|
413
|
+
if (result.setupSkippedReason)
|
|
414
|
+
console.error(result.setupSkippedReason);
|
|
413
415
|
console.error("Tip: pass --workspace <id> (or set PASEO_WORKSPACE_ID) to run in an existing workspace.");
|
|
414
416
|
return { id: result.workspace.id, cwd: result.workspace.workspaceDirectory ?? cwd };
|
|
415
417
|
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { lstat, readFile, readdir } from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { HubCommandError } from "./error.js";
|
|
4
|
+
const TRIGGER_DIRECTORY = ".paseo/triggers";
|
|
5
|
+
export async function discoverHubTriggers(cwd) {
|
|
6
|
+
const root = path.resolve(cwd);
|
|
7
|
+
const directory = path.join(root, TRIGGER_DIRECTORY);
|
|
8
|
+
const paseoDirectory = await readStats(path.join(root, ".paseo"), {
|
|
9
|
+
code: "HUB_TRIGGER_DIRECTORY_MISSING",
|
|
10
|
+
message: `${TRIGGER_DIRECTORY} does not exist. Run this command from the project root.`,
|
|
11
|
+
});
|
|
12
|
+
if (paseoDirectory.isSymbolicLink())
|
|
13
|
+
throw unsafeTriggerPath(TRIGGER_DIRECTORY);
|
|
14
|
+
const directoryStats = await readTriggerDirectoryStats(root, directory);
|
|
15
|
+
if (directoryStats.isSymbolicLink())
|
|
16
|
+
throw unsafeTriggerPath(TRIGGER_DIRECTORY);
|
|
17
|
+
if (!directoryStats.isDirectory()) {
|
|
18
|
+
throw new HubCommandError("HUB_TRIGGER_DIRECTORY_INVALID", `${TRIGGER_DIRECTORY} must be a directory.`);
|
|
19
|
+
}
|
|
20
|
+
let entries;
|
|
21
|
+
try {
|
|
22
|
+
entries = await readdir(directory, { withFileTypes: true });
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
if (!isExpectedReadError(error))
|
|
26
|
+
throw error;
|
|
27
|
+
throw unreadableTriggerPath(TRIGGER_DIRECTORY);
|
|
28
|
+
}
|
|
29
|
+
const triggers = [];
|
|
30
|
+
for (const entry of entries.toSorted((left, right) => left.name.localeCompare(right.name))) {
|
|
31
|
+
const triggerPath = `${TRIGGER_DIRECTORY}/${entry.name}`;
|
|
32
|
+
if (entry.isSymbolicLink())
|
|
33
|
+
throw unsafeTriggerPath(triggerPath);
|
|
34
|
+
if (!entry.isFile() || !entry.name.endsWith(".yml")) {
|
|
35
|
+
throw new HubCommandError("HUB_TRIGGER_PATH_UNSUPPORTED", `${triggerPath} must be a direct-child .yml trigger.`);
|
|
36
|
+
}
|
|
37
|
+
try {
|
|
38
|
+
triggers.push({
|
|
39
|
+
path: triggerPath,
|
|
40
|
+
yaml: await readFile(path.join(root, triggerPath), "utf8"),
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
if (!isExpectedReadError(error))
|
|
45
|
+
throw error;
|
|
46
|
+
throw unreadableTriggerPath(triggerPath);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (triggers.length === 0) {
|
|
50
|
+
throw new HubCommandError("HUB_TRIGGER_MISSING", `${TRIGGER_DIRECTORY} must contain at least one direct-child .yml trigger.`);
|
|
51
|
+
}
|
|
52
|
+
return triggers;
|
|
53
|
+
}
|
|
54
|
+
async function readTriggerDirectoryStats(root, directory) {
|
|
55
|
+
try {
|
|
56
|
+
return await lstat(directory);
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
if (errorCode(error) !== "ENOENT") {
|
|
60
|
+
if (!isExpectedReadError(error))
|
|
61
|
+
throw error;
|
|
62
|
+
throw unreadableTriggerPath(TRIGGER_DIRECTORY);
|
|
63
|
+
}
|
|
64
|
+
if (await legacyBundleExists(root)) {
|
|
65
|
+
throw new HubCommandError("HUB_PROJECT_REQUIRED", "This directory contains a legacy .paseo/hub.yml bundle. Pass --project <slug> to deploy it.");
|
|
66
|
+
}
|
|
67
|
+
throw new HubCommandError("HUB_TRIGGER_DIRECTORY_MISSING", `${TRIGGER_DIRECTORY} does not exist. Run this command from the project root.`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
async function legacyBundleExists(root) {
|
|
71
|
+
try {
|
|
72
|
+
await lstat(path.join(root, ".paseo/hub.yml"));
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
if (errorCode(error) === "ENOENT")
|
|
77
|
+
return false;
|
|
78
|
+
if (!isExpectedReadError(error))
|
|
79
|
+
throw error;
|
|
80
|
+
throw unreadableTriggerPath(".paseo/hub.yml");
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
async function readStats(target, missing) {
|
|
84
|
+
try {
|
|
85
|
+
return await lstat(target);
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
if (errorCode(error) === "ENOENT")
|
|
89
|
+
throw new HubCommandError(missing.code, missing.message);
|
|
90
|
+
if (!isExpectedReadError(error))
|
|
91
|
+
throw error;
|
|
92
|
+
throw unreadableTriggerPath(TRIGGER_DIRECTORY);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
function unsafeTriggerPath(triggerPath) {
|
|
96
|
+
return new HubCommandError("HUB_TRIGGER_UNSAFE_PATH", `${triggerPath} must not use a symlink.`);
|
|
97
|
+
}
|
|
98
|
+
function unreadableTriggerPath(triggerPath) {
|
|
99
|
+
return new HubCommandError("HUB_TRIGGER_UNREADABLE", `Could not read ${triggerPath}. Check the file and permissions.`);
|
|
100
|
+
}
|
|
101
|
+
function errorCode(error) {
|
|
102
|
+
if (typeof error !== "object" || error === null)
|
|
103
|
+
return undefined;
|
|
104
|
+
const code = Reflect.get(error, "code");
|
|
105
|
+
return typeof code === "string" ? code : undefined;
|
|
106
|
+
}
|
|
107
|
+
function isExpectedReadError(error) {
|
|
108
|
+
const code = errorCode(error);
|
|
109
|
+
return (code === "EACCES" ||
|
|
110
|
+
code === "EPERM" ||
|
|
111
|
+
code === "ENOENT" ||
|
|
112
|
+
code === "ENOTDIR" ||
|
|
113
|
+
code === "ELOOP" ||
|
|
114
|
+
code === "EISDIR");
|
|
115
|
+
}
|
|
116
|
+
//# sourceMappingURL=deploy-triggers.js.map
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { Command } from "commander";
|
|
2
|
-
import { type SingleResult } from "../../output/index.js";
|
|
3
|
-
import { HubHttpClient, type HubInstallResult, type HubValidationResult } from "./hub-client/index.js";
|
|
2
|
+
import { type ListResult, type SingleResult } from "../../output/index.js";
|
|
3
|
+
import { HubHttpClient, type HubInstallResult, type HubTriggerInstallationResult, type HubTriggerValidationResult, type HubValidationResult } from "./hub-client/index.js";
|
|
4
4
|
import { type HubCredentialStore } from "./credentials.js";
|
|
5
5
|
import { type HubDeployBundle } from "./deploy-bundle.js";
|
|
6
|
+
import { type HubDeployTrigger } from "./deploy-triggers.js";
|
|
6
7
|
import { type HubReporter } from "./reporter.js";
|
|
7
8
|
export interface HubDeployOptions {
|
|
8
9
|
project?: string;
|
|
@@ -15,13 +16,13 @@ export interface HubDeployEnvironment {
|
|
|
15
16
|
cwd: string;
|
|
16
17
|
env: Readonly<Record<string, string | undefined>>;
|
|
17
18
|
credentials?: HubCredentialStore;
|
|
18
|
-
hub?: Pick<HubHttpClient, "installConfiguration" | "validateConfiguration">;
|
|
19
|
+
hub?: Pick<HubHttpClient, "installConfiguration" | "validateConfiguration" | "installTrigger" | "validateTrigger">;
|
|
19
20
|
reporter?: HubReporter;
|
|
20
21
|
}
|
|
21
22
|
export interface HubDeployCommandDependencies {
|
|
22
23
|
env: Readonly<Record<string, string | undefined>>;
|
|
23
24
|
credentials: HubCredentialStore;
|
|
24
|
-
hub: Pick<HubHttpClient, "installConfiguration" | "validateConfiguration">;
|
|
25
|
+
hub: Pick<HubHttpClient, "installConfiguration" | "validateConfiguration" | "installTrigger" | "validateTrigger">;
|
|
25
26
|
reporter: HubReporter;
|
|
26
27
|
cwd(): string;
|
|
27
28
|
}
|
|
@@ -33,7 +34,16 @@ interface HubDryRunResult extends HubValidationResult {
|
|
|
33
34
|
origin: string;
|
|
34
35
|
workflows: number;
|
|
35
36
|
}
|
|
36
|
-
|
|
37
|
+
interface HubTriggerDeployResult extends HubTriggerInstallationResult {
|
|
38
|
+
origin: string;
|
|
39
|
+
path: string;
|
|
40
|
+
}
|
|
41
|
+
interface HubTriggerDryRunResult extends HubTriggerValidationResult {
|
|
42
|
+
origin: string;
|
|
43
|
+
path: string;
|
|
44
|
+
}
|
|
45
|
+
export declare function runHubDeploy(options: HubDeployOptions, environment?: HubDeployEnvironment): Promise<SingleResult<HubDeployResult> | SingleResult<HubDryRunResult> | ListResult<HubTriggerDeployResult> | ListResult<HubTriggerDryRunResult>>;
|
|
46
|
+
export declare function runHubDeployTriggers(options: HubDeployOptions, triggers: readonly HubDeployTrigger[], environment: HubDeployEnvironment): Promise<ListResult<HubTriggerDeployResult> | ListResult<HubTriggerDryRunResult>>;
|
|
37
47
|
export declare function runHubDeployBundle(options: HubDeployOptions, deployInput: HubDeployBundle, environment: HubDeployEnvironment): Promise<SingleResult<HubDeployResult> | SingleResult<HubDryRunResult>>;
|
|
38
48
|
export declare function addHubDeployCommand(hub: Command, dependencies: HubDeployCommandDependencies): void;
|
|
39
49
|
export {};
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { withOutput } from "../../output/index.js";
|
|
1
|
+
import { withOutput, } from "../../output/index.js";
|
|
2
2
|
import { addJsonOption } from "../../utils/command-options.js";
|
|
3
3
|
import { resolveHubCredential, resolveHubOrigin } from "./authority.js";
|
|
4
4
|
import { HubHttpClient, } from "./hub-client/index.js";
|
|
5
5
|
import { PrivateHubCredentialStore } from "./credentials.js";
|
|
6
6
|
import { discoverHubBundle } from "./deploy-bundle.js";
|
|
7
|
+
import { discoverHubTriggers } from "./deploy-triggers.js";
|
|
8
|
+
import { HubCommandError } from "./error.js";
|
|
7
9
|
import { processHubReporter, reportHubProgress } from "./reporter.js";
|
|
8
10
|
import { addHubResolutionHelp } from "./help.js";
|
|
9
11
|
const resultSchema = {
|
|
@@ -26,18 +28,85 @@ const validationSchema = {
|
|
|
26
28
|
{ header: "HUB", field: "origin" },
|
|
27
29
|
],
|
|
28
30
|
};
|
|
31
|
+
const triggerResultSchema = {
|
|
32
|
+
idField: "triggerId",
|
|
33
|
+
columns: [
|
|
34
|
+
{ header: "TRIGGER", field: "name" },
|
|
35
|
+
{ header: "VERSION", field: "version" },
|
|
36
|
+
{ header: "REVISION ID", field: "revisionId" },
|
|
37
|
+
{ header: "ACTIVE", field: "active" },
|
|
38
|
+
{ header: "PATH", field: "path" },
|
|
39
|
+
{ header: "HUB", field: "origin" },
|
|
40
|
+
],
|
|
41
|
+
};
|
|
42
|
+
const triggerValidationSchema = {
|
|
43
|
+
idField: "name",
|
|
44
|
+
columns: [
|
|
45
|
+
{ header: "TRIGGER", field: "name" },
|
|
46
|
+
{ header: "VALID", field: "valid" },
|
|
47
|
+
{ header: "PATH", field: "path" },
|
|
48
|
+
{ header: "HUB", field: "origin" },
|
|
49
|
+
],
|
|
50
|
+
};
|
|
29
51
|
export async function runHubDeploy(options, environment = {
|
|
30
52
|
cwd: process.cwd(),
|
|
31
53
|
env: process.env,
|
|
32
54
|
credentials: new PrivateHubCredentialStore(),
|
|
33
55
|
hub: new HubHttpClient(),
|
|
34
56
|
}) {
|
|
57
|
+
if (options.project === undefined) {
|
|
58
|
+
return runHubDeployTriggers(options, await discoverHubTriggers(environment.cwd), environment);
|
|
59
|
+
}
|
|
35
60
|
const deployInput = await discoverHubBundle({
|
|
36
61
|
cwd: environment.cwd,
|
|
37
|
-
|
|
62
|
+
project: options.project,
|
|
38
63
|
});
|
|
39
64
|
return runHubDeployBundle(options, deployInput, environment);
|
|
40
65
|
}
|
|
66
|
+
export async function runHubDeployTriggers(options, triggers, environment) {
|
|
67
|
+
const credentials = environment.credentials ?? new PrivateHubCredentialStore(environment.env);
|
|
68
|
+
const resolution = {
|
|
69
|
+
options: { origin: options.hub, apiKey: options.apiKey },
|
|
70
|
+
env: environment.env,
|
|
71
|
+
credentials,
|
|
72
|
+
};
|
|
73
|
+
const origin = resolveHubOrigin(resolution);
|
|
74
|
+
const credential = resolveHubCredential({ ...resolution, origin });
|
|
75
|
+
const action = options.dryRun === true ? "Validating" : "Deploying";
|
|
76
|
+
reportHubProgress(environment.reporter ?? processHubReporter, options, `${action} ${String(triggers.length)} trigger${triggers.length === 1 ? "" : "s"} ${options.dryRun === true ? "against" : "to"} ${origin}`);
|
|
77
|
+
const hub = environment.hub ?? new HubHttpClient();
|
|
78
|
+
if (options.dryRun === true) {
|
|
79
|
+
const data = await Promise.all(triggers.map(async (trigger) => ({
|
|
80
|
+
...(await hub.validateTrigger(origin, credential, trigger.yaml)),
|
|
81
|
+
origin,
|
|
82
|
+
path: trigger.path,
|
|
83
|
+
})));
|
|
84
|
+
return { type: "list", data, schema: triggerValidationSchema };
|
|
85
|
+
}
|
|
86
|
+
await Promise.all(triggers.map((trigger) => hub.validateTrigger(origin, credential, trigger.yaml)));
|
|
87
|
+
const data = [];
|
|
88
|
+
for (const trigger of triggers) {
|
|
89
|
+
try {
|
|
90
|
+
data.push({
|
|
91
|
+
...(await hub.installTrigger(origin, credential, trigger.yaml)),
|
|
92
|
+
origin,
|
|
93
|
+
path: trigger.path,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
catch (error) {
|
|
97
|
+
if (data.length === 0)
|
|
98
|
+
throw error;
|
|
99
|
+
throw new HubCommandError("HUB_TRIGGER_DEPLOY_PARTIAL", `Could not deploy ${trigger.path} after ${String(data.length)} trigger${data.length === 1 ? "" : "s"} had been installed.`, `${errorMessage(error)}\nInstalled before the failure:\n${data.map(({ path: installedPath }) => `- ${installedPath}`).join("\n")}`);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return { type: "list", data, schema: triggerResultSchema };
|
|
103
|
+
}
|
|
104
|
+
function errorMessage(error) {
|
|
105
|
+
if (error instanceof HubCommandError) {
|
|
106
|
+
return error.details === undefined ? error.message : `${error.message}\n${error.details}`;
|
|
107
|
+
}
|
|
108
|
+
return error instanceof Error ? error.message : String(error);
|
|
109
|
+
}
|
|
41
110
|
export async function runHubDeployBundle(options, deployInput, environment) {
|
|
42
111
|
const credentials = environment.credentials ?? new PrivateHubCredentialStore(environment.env);
|
|
43
112
|
const resolution = {
|
|
@@ -72,8 +141,8 @@ export async function runHubDeployBundle(options, deployInput, environment) {
|
|
|
72
141
|
export function addHubDeployCommand(hub, dependencies) {
|
|
73
142
|
addJsonOption(addHubResolutionHelp(hub
|
|
74
143
|
.command("deploy")
|
|
75
|
-
.description("
|
|
76
|
-
.option("-p, --project <slug>", "
|
|
144
|
+
.description("Deploy .paseo organization triggers or a legacy project bundle")
|
|
145
|
+
.option("-p, --project <slug>", "Deploy a legacy bundle to this project slug")
|
|
77
146
|
.option("--hub <origin>", "Paseo Hub origin")
|
|
78
147
|
.option("--api-key <secret>", "Organization API key")
|
|
79
148
|
.option("--dry-run", "Validate without installing or activating"))).action(withOutput(async (...args) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { HubBundleFile } from "../deploy-bundle.js";
|
|
2
|
-
import { type CliAuthorization, type CliAuthorizationPoll, type HubInstallResult, type HubConfigurationResources, type
|
|
3
|
-
export type { CliAuthorization, CliAuthorizationPoll, HubInstallResult, HubConfigurationResources,
|
|
2
|
+
import { type CliAuthorization, type CliAuthorizationPoll, type HubInstallResult, type HubConfigurationResources, type HubProject, type HubTrigger, type HubTriggerInstallationResult, type HubTriggerValidationResult, type HubValidationResult } from "./internal/contracts.js";
|
|
3
|
+
export type { CliAuthorization, CliAuthorizationPoll, HubInstallResult, HubConfigurationResources, HubProject, HubTrigger, HubTriggerInstallationResult, HubTriggerValidationResult, HubValidationResult, } from "./internal/contracts.js";
|
|
4
4
|
interface HubConfigurationInput {
|
|
5
5
|
origin: string;
|
|
6
6
|
apiKey: string;
|
|
@@ -12,8 +12,9 @@ export declare class HubHttpClient {
|
|
|
12
12
|
pollCliAuthorization(origin: string, deviceCode: string, timeoutMilliseconds: number): Promise<CliAuthorizationPoll>;
|
|
13
13
|
listProjects(origin: string, apiKey: string): Promise<HubProject[]>;
|
|
14
14
|
listTriggers(origin: string, apiKey: string): Promise<HubTrigger[]>;
|
|
15
|
+
validateTrigger(origin: string, apiKey: string, yaml: string): Promise<HubTriggerValidationResult>;
|
|
16
|
+
installTrigger(origin: string, apiKey: string, yaml: string): Promise<HubTriggerInstallationResult>;
|
|
15
17
|
listConfigurationResources(origin: string, apiKey: string): Promise<HubConfigurationResources>;
|
|
16
|
-
listSetupResources(origin: string, apiKey: string): Promise<HubSetupResources>;
|
|
17
18
|
installConfiguration(input: HubConfigurationInput): Promise<HubInstallResult>;
|
|
18
19
|
validateConfiguration(input: HubConfigurationInput): Promise<HubValidationResult>;
|
|
19
20
|
issueEnrollmentToken(origin: string, apiKey: string): Promise<string>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { HubCommandError } from "../error.js";
|
|
2
|
-
import { authorizationPollSchema, authorizationSchema, configurationResourcesSchema, enrollmentTokenSchema, installResponseSchema, projectsResponseSchema, triggersResponseSchema,
|
|
2
|
+
import { authorizationPollSchema, authorizationSchema, configurationResourcesSchema, enrollmentTokenSchema, installResponseSchema, projectsResponseSchema, triggersResponseSchema, triggerInstallationResponseSchema, triggerValidationResponseSchema, validationResponseSchema, } from "./internal/contracts.js";
|
|
3
3
|
import { requestHub } from "./internal/transport.js";
|
|
4
4
|
export class HubHttpClient {
|
|
5
5
|
startCliAuthorization(origin) {
|
|
@@ -57,26 +57,39 @@ export class HubHttpClient {
|
|
|
57
57
|
});
|
|
58
58
|
return response.triggers;
|
|
59
59
|
}
|
|
60
|
-
|
|
60
|
+
validateTrigger(origin, apiKey, yaml) {
|
|
61
61
|
return requestHub({
|
|
62
62
|
origin,
|
|
63
|
-
path: "/api/v1/
|
|
64
|
-
method: "
|
|
63
|
+
path: "/api/v1/triggers/validate",
|
|
64
|
+
method: "POST",
|
|
65
65
|
apiKey,
|
|
66
|
+
body: { yaml },
|
|
66
67
|
successStatus: 200,
|
|
67
|
-
schema:
|
|
68
|
-
failureMessage: "Hub
|
|
68
|
+
schema: triggerValidationResponseSchema,
|
|
69
|
+
failureMessage: "Hub trigger validation failed",
|
|
69
70
|
});
|
|
70
71
|
}
|
|
71
|
-
|
|
72
|
+
installTrigger(origin, apiKey, yaml) {
|
|
72
73
|
return requestHub({
|
|
73
74
|
origin,
|
|
74
|
-
path: "/api/v1/
|
|
75
|
+
path: "/api/v1/triggers/install",
|
|
76
|
+
method: "POST",
|
|
77
|
+
apiKey,
|
|
78
|
+
body: { yaml },
|
|
79
|
+
successStatus: 201,
|
|
80
|
+
schema: triggerInstallationResponseSchema,
|
|
81
|
+
failureMessage: "Hub trigger deployment failed",
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
listConfigurationResources(origin, apiKey) {
|
|
85
|
+
return requestHub({
|
|
86
|
+
origin,
|
|
87
|
+
path: "/api/v1/configuration-resources",
|
|
75
88
|
method: "GET",
|
|
76
89
|
apiKey,
|
|
77
90
|
successStatus: 200,
|
|
78
|
-
schema:
|
|
79
|
-
failureMessage: "Hub
|
|
91
|
+
schema: configurationResourcesSchema,
|
|
92
|
+
failureMessage: "Hub configuration resource listing failed",
|
|
80
93
|
});
|
|
81
94
|
}
|
|
82
95
|
installConfiguration(input) {
|
|
@@ -64,6 +64,17 @@ export declare const triggersResponseSchema: z.ZodObject<{
|
|
|
64
64
|
yaml: z.ZodString;
|
|
65
65
|
}, z.core.$strict>>;
|
|
66
66
|
}, z.core.$strict>;
|
|
67
|
+
export declare const triggerValidationResponseSchema: z.ZodObject<{
|
|
68
|
+
name: z.ZodString;
|
|
69
|
+
valid: z.ZodLiteral<true>;
|
|
70
|
+
}, z.core.$strict>;
|
|
71
|
+
export declare const triggerInstallationResponseSchema: z.ZodObject<{
|
|
72
|
+
triggerId: z.ZodString;
|
|
73
|
+
name: z.ZodString;
|
|
74
|
+
revisionId: z.ZodString;
|
|
75
|
+
version: z.ZodNumber;
|
|
76
|
+
active: z.ZodLiteral<true>;
|
|
77
|
+
}, z.core.$strict>;
|
|
67
78
|
export declare const configurationResourcesSchema: z.ZodObject<{
|
|
68
79
|
daemons: z.ZodArray<z.ZodObject<{
|
|
69
80
|
id: z.ZodString;
|
|
@@ -83,21 +94,9 @@ export declare const configurationResourcesSchema: z.ZodObject<{
|
|
|
83
94
|
slug: z.ZodString;
|
|
84
95
|
teamName: z.ZodString;
|
|
85
96
|
}, z.core.$strict>>;
|
|
86
|
-
|
|
87
|
-
export declare const setupResourcesSchema: z.ZodObject<{
|
|
88
|
-
github: z.ZodArray<z.ZodObject<{
|
|
97
|
+
linear: z.ZodArray<z.ZodObject<{
|
|
89
98
|
slug: z.ZodString;
|
|
90
|
-
|
|
91
|
-
accountType: z.ZodString;
|
|
92
|
-
repositories: z.ZodArray<z.ZodString>;
|
|
93
|
-
}, z.core.$strict>>;
|
|
94
|
-
discord: z.ZodArray<z.ZodObject<{
|
|
95
|
-
guildId: z.ZodString;
|
|
96
|
-
guildName: z.ZodString;
|
|
97
|
-
}, z.core.$strict>>;
|
|
98
|
-
slack: z.ZodArray<z.ZodObject<{
|
|
99
|
-
teamId: z.ZodString;
|
|
100
|
-
teamName: z.ZodString;
|
|
99
|
+
organizationName: z.ZodString;
|
|
101
100
|
}, z.core.$strict>>;
|
|
102
101
|
}, z.core.$strict>;
|
|
103
102
|
export declare const installResponseSchema: z.ZodObject<{
|
|
@@ -118,8 +117,9 @@ export type CliAuthorization = z.infer<typeof authorizationSchema>;
|
|
|
118
117
|
export type CliAuthorizationPoll = z.infer<typeof authorizationPollSchema>;
|
|
119
118
|
export type HubProject = z.infer<typeof projectSchema>;
|
|
120
119
|
export type HubTrigger = z.infer<typeof triggerSchema>;
|
|
120
|
+
export type HubTriggerValidationResult = z.infer<typeof triggerValidationResponseSchema>;
|
|
121
|
+
export type HubTriggerInstallationResult = z.infer<typeof triggerInstallationResponseSchema>;
|
|
121
122
|
export type HubConfigurationResources = z.infer<typeof configurationResourcesSchema>;
|
|
122
|
-
export type HubSetupResources = z.infer<typeof setupResourcesSchema>;
|
|
123
123
|
export type HubInstallResult = z.infer<typeof installResponseSchema>;
|
|
124
124
|
export type HubValidationResult = z.infer<typeof validationResponseSchema>;
|
|
125
125
|
export {};
|
|
@@ -40,6 +40,18 @@ const triggerSchema = z
|
|
|
40
40
|
})
|
|
41
41
|
.strict();
|
|
42
42
|
export const triggersResponseSchema = z.object({ triggers: z.array(triggerSchema) }).strict();
|
|
43
|
+
export const triggerValidationResponseSchema = z
|
|
44
|
+
.object({ name: z.string().regex(/^[a-z][a-z0-9_-]*$/u), valid: z.literal(true) })
|
|
45
|
+
.strict();
|
|
46
|
+
export const triggerInstallationResponseSchema = z
|
|
47
|
+
.object({
|
|
48
|
+
triggerId: z.string().uuid(),
|
|
49
|
+
name: z.string().regex(/^[a-z][a-z0-9_-]*$/u),
|
|
50
|
+
revisionId: z.string().uuid(),
|
|
51
|
+
version: z.number().int().positive(),
|
|
52
|
+
active: z.literal(true),
|
|
53
|
+
})
|
|
54
|
+
.strict();
|
|
43
55
|
export const configurationResourcesSchema = z
|
|
44
56
|
.object({
|
|
45
57
|
daemons: z.array(z.object({ id: z.string().uuid(), slug: z.string().min(1) }).strict()),
|
|
@@ -53,20 +65,7 @@ export const configurationResourcesSchema = z
|
|
|
53
65
|
.strict()),
|
|
54
66
|
discord: z.array(z.object({ slug: z.string().min(1), guildName: z.string().min(1) }).strict()),
|
|
55
67
|
slack: z.array(z.object({ slug: z.string().min(1), teamName: z.string().min(1) }).strict()),
|
|
56
|
-
})
|
|
57
|
-
.strict();
|
|
58
|
-
export const setupResourcesSchema = z
|
|
59
|
-
.object({
|
|
60
|
-
github: z.array(z
|
|
61
|
-
.object({
|
|
62
|
-
slug: z.string().min(1),
|
|
63
|
-
accountLogin: z.string().min(1),
|
|
64
|
-
accountType: z.string().min(1),
|
|
65
|
-
repositories: z.array(z.string().min(1)),
|
|
66
|
-
})
|
|
67
|
-
.strict()),
|
|
68
|
-
discord: z.array(z.object({ guildId: z.string().min(1), guildName: z.string().min(1) }).strict()),
|
|
69
|
-
slack: z.array(z.object({ teamId: z.string().min(1), teamName: z.string().min(1) }).strict()),
|
|
68
|
+
linear: z.array(z.object({ slug: z.string().min(1), organizationName: z.string().min(1) }).strict()),
|
|
70
69
|
})
|
|
71
70
|
.strict();
|
|
72
71
|
export const installResponseSchema = z
|
|
@@ -1,17 +1,6 @@
|
|
|
1
|
-
import type { HubDeployBundle } from "./deploy-bundle.js";
|
|
2
|
-
import type { HubProject } from "./hub-client/index.js";
|
|
3
1
|
import type { HubStatus } from "./daemon-client.js";
|
|
4
2
|
import type { HubStarterAgentRuntime } from "./starter-agent-runtime.js";
|
|
5
3
|
export type HubInitProvider = "github" | "slack" | "discord";
|
|
6
|
-
export type HubInitProjectResolution = {
|
|
7
|
-
kind: "none";
|
|
8
|
-
} | {
|
|
9
|
-
kind: "selected";
|
|
10
|
-
project: HubProject;
|
|
11
|
-
} | {
|
|
12
|
-
kind: "choose";
|
|
13
|
-
projects: readonly HubProject[];
|
|
14
|
-
};
|
|
15
4
|
export type HubInitConnectionResolution = {
|
|
16
5
|
kind: "connected";
|
|
17
6
|
daemonId: string;
|
|
@@ -24,30 +13,21 @@ export type HubInitConnectionResolution = {
|
|
|
24
13
|
kind: "conflict";
|
|
25
14
|
origin: string;
|
|
26
15
|
};
|
|
27
|
-
export interface HubInitOpeningPlan {
|
|
28
|
-
replaceExisting: boolean;
|
|
29
|
-
steps: readonly ("login" | "connect" | "project" | "scaffold")[];
|
|
30
|
-
}
|
|
31
16
|
export interface HubInitScaffoldInput {
|
|
32
17
|
cwd: string;
|
|
33
18
|
daemonSlug: string;
|
|
34
|
-
agent: HubStarterAgentRuntime
|
|
19
|
+
agent: HubStarterAgentRuntime & {
|
|
20
|
+
mode: string;
|
|
21
|
+
};
|
|
35
22
|
provider: HubInitProvider;
|
|
36
23
|
providerFilters: Readonly<Record<string, string>>;
|
|
37
24
|
}
|
|
38
25
|
export interface HubInitScaffold {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
workflow: string;
|
|
26
|
+
triggerPath: string;
|
|
27
|
+
trigger: string;
|
|
42
28
|
testAction: string;
|
|
43
29
|
}
|
|
44
30
|
export declare function hubLoginResumeCommand(step: "connect" | "init", origin: string): string;
|
|
45
|
-
export declare function planHubInitOpening(input: {
|
|
46
|
-
loggedIn: boolean;
|
|
47
|
-
paseoDirectoryExists: boolean;
|
|
48
|
-
}): HubInitOpeningPlan;
|
|
49
|
-
export declare function createHubInitBundle(projectSlug: string, scaffold: HubInitScaffold): HubDeployBundle;
|
|
50
|
-
export declare function resolveHubInitProjects(projects: readonly HubProject[]): HubInitProjectResolution;
|
|
51
31
|
export declare function resolveHubInitConnection(status: HubStatus, origin: string): HubInitConnectionResolution;
|
|
52
32
|
export declare function createHubInitScaffold(input: HubInitScaffoldInput): HubInitScaffold;
|
|
53
33
|
//# sourceMappingURL=init-plan.d.ts.map
|