@getpaseo/cli 0.8.0-beta.1 → 0.9.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +44 -37
- package/dist/commands/agent/archive.js +2 -15
- package/dist/commands/agent/attach.d.ts +1 -0
- package/dist/commands/agent/attach.js +18 -20
- package/dist/commands/agent/delete.js +4 -15
- package/dist/commands/agent/detach.js +2 -13
- package/dist/commands/agent/import.js +2 -16
- package/dist/commands/agent/inspect.js +2 -15
- package/dist/commands/agent/logs.js +18 -18
- package/dist/commands/agent/ls.js +2 -23
- package/dist/commands/agent/mode.js +2 -2
- package/dist/commands/agent/open.js +2 -8
- package/dist/commands/agent/reload.js +2 -15
- package/dist/commands/agent/run.js +12 -17
- package/dist/commands/agent/send.js +6 -15
- package/dist/commands/agent/stop.js +2 -15
- package/dist/commands/agent/update.js +2 -15
- package/dist/commands/agent/wait.js +4 -15
- package/dist/commands/clone.js +2 -8
- package/dist/commands/daemon/config.d.ts +3 -0
- package/dist/commands/daemon/config.js +103 -0
- package/dist/commands/daemon/index.js +20 -52
- package/dist/commands/daemon/local-daemon.d.ts +10 -75
- package/dist/commands/daemon/local-daemon.js +61 -503
- package/dist/commands/daemon/pair.d.ts +3 -8
- package/dist/commands/daemon/pair.js +33 -61
- package/dist/commands/daemon/reload.d.ts +3 -1
- package/dist/commands/daemon/reload.js +10 -2
- package/dist/commands/daemon/restart.d.ts +19 -11
- package/dist/commands/daemon/restart.js +102 -88
- package/dist/commands/daemon/runtime-toolchain.js +1 -1
- package/dist/commands/daemon/set-password.js +8 -7
- package/dist/commands/daemon/start.d.ts +17 -3
- package/dist/commands/daemon/start.js +47 -52
- package/dist/commands/daemon/status.d.ts +12 -20
- package/dist/commands/daemon/status.js +91 -342
- package/dist/commands/daemon/stop.d.ts +19 -14
- package/dist/commands/daemon/stop.js +53 -55
- package/dist/commands/heartbeat/index.js +3 -3
- package/dist/commands/hub/connect.d.ts +1 -0
- package/dist/commands/hub/connect.js +1 -1
- package/dist/commands/hub/daemon-client.d.ts +3 -2
- package/dist/commands/hub/daemon-client.js +3 -3
- 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/disconnect.d.ts +1 -0
- package/dist/commands/hub/disconnect.js +1 -1
- 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/index.js +2 -2
- package/dist/commands/hub/init-plan.d.ts +5 -25
- package/dist/commands/hub/init-plan.js +39 -85
- package/dist/commands/hub/init.d.ts +3 -1
- package/dist/commands/hub/init.js +94 -124
- package/dist/commands/hub/login.d.ts +4 -4
- package/dist/commands/hub/login.js +1 -1
- package/dist/commands/hub/logout.d.ts +1 -0
- package/dist/commands/hub/logout.js +2 -2
- package/dist/commands/hub/permissions.d.ts +1 -0
- package/dist/commands/hub/permissions.js +2 -2
- package/dist/commands/hub/starter-trigger.d.ts +2 -2
- package/dist/commands/hub/starter-trigger.js +11 -9
- package/dist/commands/onboard.d.ts +7 -2
- package/dist/commands/onboard.js +59 -210
- package/dist/commands/open.js +3 -1
- package/dist/commands/permit/allow.js +2 -15
- package/dist/commands/permit/deny.js +2 -15
- package/dist/commands/permit/ls.js +2 -15
- package/dist/commands/plugin/index.d.ts +6 -0
- package/dist/commands/plugin/index.js +62 -46
- package/dist/commands/plugin/scaffold.js +10 -0
- package/dist/commands/plugin/shared.d.ts +5 -3
- package/dist/commands/plugin/shared.js +13 -9
- package/dist/commands/plugin/update.d.ts +37 -0
- package/dist/commands/plugin/update.js +58 -0
- package/dist/commands/project/create.js +5 -3
- package/dist/commands/project/delete.js +4 -2
- package/dist/commands/project/ls.js +2 -2
- package/dist/commands/project/rename.js +4 -2
- package/dist/commands/provider/diagnostic.js +1 -1
- package/dist/commands/provider/ls.js +2 -29
- package/dist/commands/provider/models.js +1 -1
- package/dist/commands/schedule/create.js +2 -2
- package/dist/commands/schedule/delete.js +1 -1
- package/dist/commands/schedule/inspect.js +1 -1
- package/dist/commands/schedule/logs.js +1 -1
- package/dist/commands/schedule/ls.js +1 -1
- package/dist/commands/schedule/pause.js +1 -1
- package/dist/commands/schedule/resume.js +1 -1
- package/dist/commands/schedule/run-once.js +1 -1
- package/dist/commands/schedule/shared.d.ts +3 -1
- package/dist/commands/schedule/shared.js +7 -5
- package/dist/commands/schedule/update.js +1 -1
- package/dist/commands/script/ls.js +1 -1
- package/dist/commands/script/shared.d.ts +2 -1
- package/dist/commands/script/shared.js +3 -3
- package/dist/commands/script/start.js +1 -1
- package/dist/commands/script/stop.js +1 -1
- package/dist/commands/terminal/capture.d.ts +1 -1
- package/dist/commands/terminal/capture.js +2 -3
- package/dist/commands/terminal/create.js +1 -1
- package/dist/commands/terminal/kill.js +1 -1
- package/dist/commands/terminal/ls.js +1 -1
- package/dist/commands/terminal/send-keys.d.ts +1 -1
- package/dist/commands/terminal/send-keys.js +2 -3
- package/dist/commands/terminal/shared.d.ts +2 -1
- package/dist/commands/terminal/shared.js +5 -3
- package/dist/commands/workspace/archive.d.ts +1 -0
- package/dist/commands/workspace/archive.js +4 -2
- package/dist/commands/workspace/create.js +4 -2
- package/dist/commands/workspace/ls.d.ts +1 -0
- package/dist/commands/workspace/ls.js +2 -2
- package/dist/commands/workspace/rename.d.ts +1 -0
- package/dist/commands/workspace/rename.js +4 -2
- package/dist/commands/workspace/setup.d.ts +1 -0
- package/dist/commands/workspace/setup.js +2 -2
- package/dist/commands/worktree/archive.js +4 -2
- package/dist/commands/worktree/create.js +2 -10
- package/dist/commands/worktree/ls.d.ts +0 -2
- package/dist/commands/worktree/ls.js +4 -30
- package/dist/output/with-output.d.ts +2 -0
- package/dist/run.js +11 -1
- package/dist/utils/client-id.d.ts +1 -1
- package/dist/utils/client-id.js +8 -14
- package/dist/utils/client.d.ts +16 -21
- package/dist/utils/client.js +57 -109
- package/dist/utils/command-options.d.ts +1 -0
- package/dist/utils/command-options.js +26 -2
- package/dist/utils/daemon-target.d.ts +13 -0
- package/dist/utils/daemon-target.js +51 -0
- package/package.json +4 -4
|
@@ -3,29 +3,6 @@ import YAML from "yaml";
|
|
|
3
3
|
export function hubLoginResumeCommand(step, origin) {
|
|
4
4
|
return step === "connect" ? `paseo hub connect ${origin}` : "paseo hub init";
|
|
5
5
|
}
|
|
6
|
-
export function planHubInitOpening(input) {
|
|
7
|
-
return {
|
|
8
|
-
replaceExisting: input.paseoDirectoryExists,
|
|
9
|
-
steps: [...(input.loggedIn ? [] : ["login"]), "connect", "project", "scaffold"],
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
export function createHubInitBundle(projectSlug, scaffold) {
|
|
13
|
-
return {
|
|
14
|
-
projectSlug,
|
|
15
|
-
workflowCount: 1,
|
|
16
|
-
files: [
|
|
17
|
-
{ path: ".paseo/hub.yml", content: scaffold.hub },
|
|
18
|
-
{ path: scaffold.workflowPath, content: scaffold.workflow },
|
|
19
|
-
],
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
export function resolveHubInitProjects(projects) {
|
|
23
|
-
if (projects.length === 0)
|
|
24
|
-
return { kind: "none" };
|
|
25
|
-
if (projects.length === 1)
|
|
26
|
-
return { kind: "selected", project: projects[0] };
|
|
27
|
-
return { kind: "choose", projects };
|
|
28
|
-
}
|
|
29
6
|
export function resolveHubInitConnection(status, origin) {
|
|
30
7
|
if (status.state === "connected" && status.hubOrigin === origin && status.daemonId !== null) {
|
|
31
8
|
return { kind: "connected", daemonId: status.daemonId };
|
|
@@ -40,95 +17,72 @@ export function resolveHubInitConnection(status, origin) {
|
|
|
40
17
|
return { kind: "connect" };
|
|
41
18
|
}
|
|
42
19
|
export function createHubInitScaffold(input) {
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
agents: {
|
|
53
|
-
starter: {
|
|
20
|
+
const provider = providerScaffold(input.provider, input.providerFilters);
|
|
21
|
+
return {
|
|
22
|
+
triggerPath: `.paseo/triggers/${input.provider}-help.yml`,
|
|
23
|
+
trigger: YAML.stringify(triggerDocument({
|
|
24
|
+
...provider,
|
|
25
|
+
target: { daemon: input.daemonSlug, cwd: path.resolve(input.cwd) },
|
|
26
|
+
agent: {
|
|
54
27
|
provider: input.agent.provider,
|
|
55
28
|
model: input.agent.model,
|
|
56
|
-
|
|
29
|
+
mode: input.agent.mode,
|
|
57
30
|
},
|
|
58
|
-
},
|
|
59
|
-
}, { lineWidth: 0 });
|
|
60
|
-
const provider = providerScaffold(input.provider, input.providerFilters, environmentName);
|
|
61
|
-
return {
|
|
62
|
-
hub,
|
|
63
|
-
workflowPath: `.paseo/workflows/${input.provider}-help.yml`,
|
|
64
|
-
workflow: YAML.stringify(provider.workflow, { lineWidth: 0 }),
|
|
31
|
+
}), { lineWidth: 0 }),
|
|
65
32
|
testAction: provider.testAction,
|
|
66
33
|
};
|
|
67
34
|
}
|
|
68
|
-
function providerScaffold(provider, filters
|
|
35
|
+
function providerScaffold(provider, filters) {
|
|
36
|
+
const connection = requireFilter(filters, "connection");
|
|
69
37
|
if (provider === "github") {
|
|
70
38
|
const repo = requireFilter(filters, "repo");
|
|
71
39
|
const user = requireFilter(filters, "user");
|
|
72
40
|
return {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
environment,
|
|
78
|
-
}),
|
|
41
|
+
name: "github-help",
|
|
42
|
+
event: "github.issue_comment",
|
|
43
|
+
connection,
|
|
44
|
+
filters: { repo, contains: "@paseo", from_users: [user] },
|
|
79
45
|
testAction: `Comment \`@paseo have a look\` on ${repo}.`,
|
|
80
46
|
};
|
|
81
47
|
}
|
|
82
48
|
const user = requireFilter(filters, "user");
|
|
83
49
|
if (provider === "slack") {
|
|
84
|
-
const workspace = requireFilter(filters, "workspace");
|
|
85
50
|
return {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
reply: "slack.reply",
|
|
92
|
-
}),
|
|
51
|
+
name: "slack-help",
|
|
52
|
+
event: "slack.mention",
|
|
53
|
+
connection,
|
|
54
|
+
filters: { from_users: [user] },
|
|
55
|
+
reply: "slack.reply",
|
|
93
56
|
testAction: "Mention `@Paseo have a look` in Slack.",
|
|
94
57
|
};
|
|
95
58
|
}
|
|
96
|
-
const guild = requireFilter(filters, "guild");
|
|
97
59
|
return {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
reply: "discord.reply",
|
|
104
|
-
}),
|
|
60
|
+
name: "discord-help",
|
|
61
|
+
event: "discord.mention",
|
|
62
|
+
connection,
|
|
63
|
+
filters: { from_users: [user] },
|
|
64
|
+
reply: "discord.reply",
|
|
105
65
|
testAction: "Mention `@Paseo have a look` in Discord.",
|
|
106
66
|
};
|
|
107
67
|
}
|
|
108
|
-
function
|
|
68
|
+
function triggerDocument(input) {
|
|
109
69
|
const replyInstruction = input.reply === undefined ? "" : "Answer with hub.reply, then ";
|
|
110
70
|
return {
|
|
111
71
|
name: input.name,
|
|
112
|
-
|
|
72
|
+
enabled: true,
|
|
73
|
+
on: { [input.event]: { connection: input.connection, filters: input.filters } },
|
|
113
74
|
max_runtime: "2h",
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
},
|
|
126
|
-
],
|
|
127
|
-
...(input.reply === undefined
|
|
128
|
-
? {}
|
|
129
|
-
: { allow_outputs: [{ type: input.reply, max: 1, required: true }] }),
|
|
130
|
-
},
|
|
131
|
-
],
|
|
75
|
+
run: {
|
|
76
|
+
target: input.target,
|
|
77
|
+
agent: input.agent,
|
|
78
|
+
continuation: { mode: "conversation" },
|
|
79
|
+
max_runtime: "90m",
|
|
80
|
+
idle_timeout: "10m",
|
|
81
|
+
prompt: `${replyInstruction}complete this request and call hub.finish_execution when done.\n\n<user-prompt>\n\${{ paseo.prompt }}\n</user-prompt>\n`,
|
|
82
|
+
...(input.reply === undefined
|
|
83
|
+
? {}
|
|
84
|
+
: { outputs: { [input.reply]: { max: 1, required: true } } }),
|
|
85
|
+
},
|
|
132
86
|
};
|
|
133
87
|
}
|
|
134
88
|
function requireFilter(filters, name) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { DaemonTarget } from "../../utils/daemon-target.js";
|
|
1
2
|
import { select, text } from "@clack/prompts";
|
|
2
3
|
import type { Command } from "commander";
|
|
3
4
|
import type { HubCredentialStore } from "./credentials.js";
|
|
@@ -6,6 +7,7 @@ import type { HubHttpClient } from "./hub-client/index.js";
|
|
|
6
7
|
import type { CliLoginFlow } from "./login-flow.js";
|
|
7
8
|
import type { HubReporter } from "./reporter.js";
|
|
8
9
|
export interface HubGuidedSetupEnvironment {
|
|
10
|
+
daemonTarget: DaemonTarget;
|
|
9
11
|
env: Readonly<Record<string, string | undefined>>;
|
|
10
12
|
credentials: HubCredentialStore;
|
|
11
13
|
hub: HubHttpClient;
|
|
@@ -26,7 +28,7 @@ interface HubGuidedSetupState {
|
|
|
26
28
|
daemonId?: string;
|
|
27
29
|
deploy?: boolean;
|
|
28
30
|
}
|
|
29
|
-
export declare function addHubInitCommand(parent: Command, environment: HubGuidedSetupEnvironment): void;
|
|
31
|
+
export declare function addHubInitCommand(parent: Command, environment: Omit<HubGuidedSetupEnvironment, "daemonTarget">): void;
|
|
30
32
|
export declare function runHubInit(environment: HubGuidedSetupEnvironment): Promise<void>;
|
|
31
33
|
export declare function runHubGuidedSetup(environment: HubGuidedSetupEnvironment, state?: HubGuidedSetupState): Promise<void>;
|
|
32
34
|
export declare function continueHubGuidedSetup(origin: string, environment: HubGuidedSetupEnvironment): Promise<void>;
|
|
@@ -1,16 +1,15 @@
|
|
|
1
|
+
import { withGlobalOptions } from "../../utils/command-options.js";
|
|
1
2
|
import { cancel, confirm, intro, isCancel, log, note, outro, select, spinner, text, } from "@clack/prompts";
|
|
2
3
|
import { execFile } from "node:child_process";
|
|
3
4
|
import { randomUUID } from "node:crypto";
|
|
4
|
-
import { lstat, mkdir, rename, rm, writeFile } from "node:fs/promises";
|
|
5
|
+
import { link, lstat, mkdir, rename, rm, writeFile } from "node:fs/promises";
|
|
5
6
|
import path from "node:path";
|
|
6
7
|
import { promisify } from "node:util";
|
|
7
8
|
import { DEFAULT_HUB_ORIGIN, resolveHubCredential } from "./authority.js";
|
|
8
9
|
import { withHubDaemon } from "./daemon-client.js";
|
|
9
10
|
import { HubCommandError } from "./error.js";
|
|
10
|
-
import {
|
|
11
|
+
import { createHubInitScaffold, hubLoginResumeCommand, resolveHubInitConnection, } from "./init-plan.js";
|
|
11
12
|
import { runHubConnect } from "./connect.js";
|
|
12
|
-
import { runHubDeployBundle } from "./deploy.js";
|
|
13
|
-
import { runHubProjects } from "./projects.js";
|
|
14
13
|
import { normalizeHubOrigin } from "./origin.js";
|
|
15
14
|
import { selectedStarterAgentRuntime, starterAgentProviderSnapshotState, suggestedStarterAgentChoice, } from "./starter-agent-runtime.js";
|
|
16
15
|
import { availableStarterTriggerConnections, } from "./starter-trigger.js";
|
|
@@ -29,10 +28,10 @@ function initErrorMessage(error) {
|
|
|
29
28
|
export function addHubInitCommand(parent, environment) {
|
|
30
29
|
parent
|
|
31
30
|
.command("init")
|
|
32
|
-
.description("Create and optionally deploy a safe starter Hub
|
|
33
|
-
.action(async () => {
|
|
31
|
+
.description("Create and optionally deploy a safe starter Hub trigger")
|
|
32
|
+
.action(withGlobalOptions(async (options) => {
|
|
34
33
|
try {
|
|
35
|
-
await runHubInit(environment);
|
|
34
|
+
await runHubInit({ ...environment, daemonTarget: options.daemonTarget });
|
|
36
35
|
}
|
|
37
36
|
catch (error) {
|
|
38
37
|
if (error instanceof HubInitCancelledError) {
|
|
@@ -42,7 +41,7 @@ export function addHubInitCommand(parent, environment) {
|
|
|
42
41
|
cancel(initErrorMessage(error));
|
|
43
42
|
process.exitCode = 1;
|
|
44
43
|
}
|
|
45
|
-
});
|
|
44
|
+
}));
|
|
46
45
|
}
|
|
47
46
|
export async function runHubInit(environment) {
|
|
48
47
|
await runHubGuidedSetup(environment);
|
|
@@ -52,22 +51,16 @@ export async function runHubGuidedSetup(environment, state = {}) {
|
|
|
52
51
|
intro("Set up Paseo Hub");
|
|
53
52
|
const cwd = environment.cwd();
|
|
54
53
|
const activeLogin = environment.credentials.active();
|
|
55
|
-
const opening = planHubInitOpening({
|
|
56
|
-
loggedIn: activeLogin !== null,
|
|
57
|
-
paseoDirectoryExists: await pathExists(path.join(cwd, ".paseo")),
|
|
58
|
-
});
|
|
59
|
-
if (opening.replaceExisting &&
|
|
60
|
-
!(await requiredConfirm(environment, "Replace the existing .paseo/ Hub bundle?", false))) {
|
|
61
|
-
throw new HubInitCancelledError("Existing .paseo/ bundle left unchanged.");
|
|
62
|
-
}
|
|
63
54
|
const origin = state.origin ?? (await ensureLogin(activeLogin?.origin, environment));
|
|
64
55
|
const daemonId = state.daemonId ?? (await ensureDaemonConnection(origin, environment));
|
|
65
|
-
const
|
|
66
|
-
const resources = await loadSetupResources(origin, environment);
|
|
56
|
+
const resources = await loadConfigurationResources(origin, environment);
|
|
67
57
|
const triggerConnections = await resolveStarterTriggerConnections(resources, cwd);
|
|
68
58
|
reportStarterTriggerConnections(environment, triggerConnections);
|
|
69
59
|
const trigger = await chooseStarterTriggerConnection(environment, triggerConnections);
|
|
70
|
-
const daemon =
|
|
60
|
+
const daemon = resources.daemons.find(({ id }) => id === daemonId);
|
|
61
|
+
if (daemon === undefined) {
|
|
62
|
+
throw new HubCommandError("HUB_DAEMON_RESOURCE_MISSING", "The connected daemon is not available in this Hub organization. Reconnect it and try again.");
|
|
63
|
+
}
|
|
71
64
|
log.success(`Connected as ${daemon.slug}`);
|
|
72
65
|
const agent = await chooseStarterAgentRuntime(environment, cwd);
|
|
73
66
|
const providerFilters = await collectProviderIdentity(trigger, environment);
|
|
@@ -78,47 +71,45 @@ export async function runHubGuidedSetup(environment, state = {}) {
|
|
|
78
71
|
provider: trigger.provider,
|
|
79
72
|
providerFilters,
|
|
80
73
|
});
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
});
|
|
74
|
+
const credential = resolveHubCredential({
|
|
75
|
+
options: { origin },
|
|
76
|
+
env: environment.env,
|
|
77
|
+
credentials: environment.credentials,
|
|
78
|
+
origin,
|
|
79
|
+
});
|
|
80
|
+
await withSpinner("Validating trigger", async () => {
|
|
81
|
+
await environment.hub.validateTrigger(origin, credential, scaffold.trigger);
|
|
90
82
|
});
|
|
91
83
|
log.success("Dry run passed");
|
|
92
|
-
await
|
|
93
|
-
|
|
84
|
+
const triggerExists = await prepareScaffoldDestination(cwd, scaffold.triggerPath);
|
|
85
|
+
if (triggerExists &&
|
|
86
|
+
!(await requiredConfirm(environment, `Replace the existing ${scaffold.triggerPath}?`, false))) {
|
|
87
|
+
throw new HubInitCancelledError(`${scaffold.triggerPath} left unchanged.`);
|
|
88
|
+
}
|
|
89
|
+
await writeScaffold(cwd, scaffold, triggerExists);
|
|
90
|
+
log.success(`Created ${scaffold.triggerPath}`);
|
|
94
91
|
const deploy = state.deploy ?? (await requiredConfirm(environment, "Deploy now?", true));
|
|
95
92
|
if (deploy) {
|
|
96
|
-
await withSpinner("Deploying
|
|
97
|
-
await
|
|
98
|
-
cwd,
|
|
99
|
-
env: environment.env,
|
|
100
|
-
credentials: environment.credentials,
|
|
101
|
-
hub: environment.hub,
|
|
102
|
-
reporter: { progress() { } },
|
|
103
|
-
});
|
|
93
|
+
await withSpinner("Deploying trigger", async () => {
|
|
94
|
+
await environment.hub.installTrigger(origin, credential, scaffold.trigger);
|
|
104
95
|
});
|
|
105
96
|
log.success("Deployed");
|
|
106
97
|
}
|
|
107
98
|
else {
|
|
108
|
-
reportMessage(environment,
|
|
99
|
+
reportMessage(environment, "Skipped deployment. Run `paseo hub deploy` when ready.");
|
|
109
100
|
}
|
|
110
|
-
const
|
|
111
|
-
note(`${scaffold.testAction}\
|
|
112
|
-
outro(deploy ? "Hub is ready" : "Hub
|
|
101
|
+
const triggersUrl = new URL("/triggers", origin).toString();
|
|
102
|
+
note(`${scaffold.testAction}\nManage it at ${triggersUrl}`, "Test your trigger");
|
|
103
|
+
outro(deploy ? "Hub is ready" : "Hub trigger is ready");
|
|
113
104
|
}
|
|
114
105
|
export async function continueHubGuidedSetup(origin, environment) {
|
|
115
|
-
const currentStatus = await withHubDaemon(environment.daemon,
|
|
106
|
+
const currentStatus = await withHubDaemon(environment.daemon, environment.daemonTarget, async (daemon) => daemon.getHubStatus().then((response) => response.status));
|
|
116
107
|
const current = resolveHubInitConnection(currentStatus, origin);
|
|
117
108
|
if (current.kind === "connected") {
|
|
118
109
|
reportMessage(environment, `This daemon is already connected to ${origin}. Permissions: ${currentStatus.permissions.join(", ") || "None"}.`);
|
|
119
110
|
}
|
|
120
111
|
else if (current.kind === "pending") {
|
|
121
|
-
await waitForDaemonReady(origin, environment
|
|
112
|
+
await waitForDaemonReady(origin, environment);
|
|
122
113
|
}
|
|
123
114
|
else if (current.kind === "conflict") {
|
|
124
115
|
reportMessage(environment, `This daemon is connected to ${current.origin}. Disconnect it before connecting to ${origin}.`);
|
|
@@ -173,7 +164,7 @@ async function ensureLogin(activeOrigin, environment) {
|
|
|
173
164
|
return normalizedOrigin;
|
|
174
165
|
}
|
|
175
166
|
async function ensureDaemonConnection(origin, environment, confirmed = false, permissions = ["hub.execute"]) {
|
|
176
|
-
const status = await withHubDaemon(environment.daemon,
|
|
167
|
+
const status = await withHubDaemon(environment.daemon, environment.daemonTarget, async (daemon) => daemon.getHubStatus().then((response) => response.status));
|
|
177
168
|
const connection = resolveHubInitConnection(status, origin);
|
|
178
169
|
if (connection.kind === "connected") {
|
|
179
170
|
if (permissions.includes("hub.execute") && !status.permissions.includes("hub.execute")) {
|
|
@@ -182,29 +173,29 @@ async function ensureDaemonConnection(origin, environment, confirmed = false, pe
|
|
|
182
173
|
return connection.daemonId;
|
|
183
174
|
}
|
|
184
175
|
if (connection.kind === "pending") {
|
|
185
|
-
return waitForDaemonReady(origin, environment
|
|
176
|
+
return waitForDaemonReady(origin, environment);
|
|
186
177
|
}
|
|
187
178
|
if (connection.kind === "conflict") {
|
|
188
179
|
throw new HubCommandError("HUB_DAEMON_ALREADY_CONNECTED", `This daemon is connected to ${connection.origin}. Disconnect it before running Hub init for ${origin}.`);
|
|
189
180
|
}
|
|
190
181
|
if (!confirmed &&
|
|
191
182
|
!(await requiredConfirm(environment, `Connect this daemon to ${origin} and allow Hub workflows to create and control workspaces and agents?`, true))) {
|
|
192
|
-
throw new HubInitCancelledError("A connected daemon is required to create the
|
|
183
|
+
throw new HubInitCancelledError("A connected daemon is required to create the trigger.");
|
|
193
184
|
}
|
|
194
185
|
return connectDaemon(origin, environment, permissions);
|
|
195
186
|
}
|
|
196
187
|
async function connectDaemon(origin, environment, permissions = ["hub.execute"]) {
|
|
197
|
-
await runHubConnect(origin, { permissions }, {
|
|
188
|
+
await runHubConnect(origin, { permissions, daemonTarget: environment.daemonTarget }, {
|
|
198
189
|
env: environment.env,
|
|
199
190
|
credentials: environment.credentials,
|
|
200
191
|
hub: environment.hub,
|
|
201
192
|
daemon: environment.daemon,
|
|
202
193
|
reporter: environment.reporter,
|
|
203
194
|
});
|
|
204
|
-
return waitForDaemonReady(origin, environment
|
|
195
|
+
return waitForDaemonReady(origin, environment);
|
|
205
196
|
}
|
|
206
|
-
async function waitForDaemonReady(origin,
|
|
207
|
-
return withSpinner("Waiting for the daemon to connect", async (reporter) => withHubDaemon(
|
|
197
|
+
async function waitForDaemonReady(origin, environment) {
|
|
198
|
+
return withSpinner("Waiting for the daemon to connect", async (reporter) => withHubDaemon(environment.daemon, environment.daemonTarget, async (daemon) => {
|
|
208
199
|
const deadline = Date.now() + DAEMON_READY_TIMEOUT_MS;
|
|
209
200
|
while (true) {
|
|
210
201
|
const status = (await daemon.getHubStatus()).status;
|
|
@@ -225,50 +216,22 @@ async function waitForDaemonReady(origin, connection) {
|
|
|
225
216
|
}
|
|
226
217
|
}));
|
|
227
218
|
}
|
|
228
|
-
async function chooseProject(origin, environment) {
|
|
229
|
-
const result = await runHubProjects({ hub: origin }, {
|
|
230
|
-
env: environment.env,
|
|
231
|
-
credentials: environment.credentials,
|
|
232
|
-
hub: environment.hub,
|
|
233
|
-
reporter: { progress() { } },
|
|
234
|
-
});
|
|
235
|
-
const resolution = resolveHubInitProjects(result.data.projects);
|
|
236
|
-
if (resolution.kind === "none") {
|
|
237
|
-
throw new HubInitCancelledError(`No Hub projects exist yet. Create one at ${new URL("/projects/new", origin).toString()}, then run paseo hub init again.`);
|
|
238
|
-
}
|
|
239
|
-
if (resolution.kind === "selected") {
|
|
240
|
-
return resolution.project;
|
|
241
|
-
}
|
|
242
|
-
const slug = await requiredSelect(environment, {
|
|
243
|
-
message: "Project",
|
|
244
|
-
options: resolution.projects.map((project) => ({
|
|
245
|
-
value: project.slug,
|
|
246
|
-
label: project.name,
|
|
247
|
-
hint: project.slug,
|
|
248
|
-
})),
|
|
249
|
-
});
|
|
250
|
-
const project = resolution.projects.find((candidate) => candidate.slug === slug);
|
|
251
|
-
if (project === undefined) {
|
|
252
|
-
throw new HubCommandError("HUB_PROJECT_SELECTION_INVALID", "The selected Hub project is unavailable.");
|
|
253
|
-
}
|
|
254
|
-
return project;
|
|
255
|
-
}
|
|
256
219
|
async function resolveStarterTriggerConnections(resources, cwd) {
|
|
257
220
|
const remote = await readCommandValue("git", ["remote", "get-url", "origin"], cwd);
|
|
258
221
|
const repository = remote === undefined ? undefined : githubRepositoryFromRemote(remote);
|
|
259
222
|
const connections = availableStarterTriggerConnections(resources, repository);
|
|
260
223
|
if (connections.length === 0) {
|
|
261
|
-
throw new HubInitCancelledError("No Hub app connection is ready for this
|
|
224
|
+
throw new HubInitCancelledError("No Hub app connection is ready for this trigger.\nConnect GitHub, Slack, or Discord in Hub → Apps, then run `paseo hub init` again.");
|
|
262
225
|
}
|
|
263
226
|
return connections;
|
|
264
227
|
}
|
|
265
228
|
function reportStarterTriggerConnections(environment, connections) {
|
|
266
229
|
const details = `${connections.map(({ label }) => label).join("\n")}\n\nOnly configured connections are shown. To add another, open Hub → Apps, then run \`paseo hub init\` again.`;
|
|
267
230
|
if (environment.prompts === undefined) {
|
|
268
|
-
note(details, "Hub app connections ready for this
|
|
231
|
+
note(details, "Hub app connections ready for this trigger");
|
|
269
232
|
return;
|
|
270
233
|
}
|
|
271
|
-
environment.prompts.message(`Hub app connections ready for this
|
|
234
|
+
environment.prompts.message(`Hub app connections ready for this trigger:\n${details}`);
|
|
272
235
|
}
|
|
273
236
|
async function chooseStarterTriggerConnection(environment, connections) {
|
|
274
237
|
if (connections.length === 1) {
|
|
@@ -292,19 +255,23 @@ async function chooseStarterAgentRuntime(environment, cwd) {
|
|
|
292
255
|
const model = await chooseStarterAgentModel(environment, provider);
|
|
293
256
|
const mode = await chooseStarterAgentMode(environment, provider);
|
|
294
257
|
const runtime = selectedStarterAgentRuntime(provider, model, mode);
|
|
295
|
-
if (runtime === undefined) {
|
|
258
|
+
if (runtime?.mode === undefined) {
|
|
296
259
|
throw new HubCommandError("HUB_AGENT_RUNTIME_SELECTION_INVALID", "The selected starter agent runtime is no longer available. Run paseo hub init again.");
|
|
297
260
|
}
|
|
298
|
-
return runtime;
|
|
261
|
+
return { ...runtime, mode: runtime.mode };
|
|
299
262
|
}
|
|
300
263
|
async function waitForStarterAgentProviders(environment, cwd) {
|
|
301
|
-
return withSpinner("Discovering agent runtimes", async (reporter) => withHubDaemon(environment.daemon,
|
|
264
|
+
return withSpinner("Discovering agent runtimes", async (reporter) => withHubDaemon(environment.daemon, environment.daemonTarget, async (daemon) => {
|
|
302
265
|
const deadline = Date.now() + PROVIDER_READY_TIMEOUT_MS;
|
|
303
266
|
while (true) {
|
|
304
267
|
const snapshot = await daemon.getProvidersSnapshot({ cwd });
|
|
305
268
|
const state = starterAgentProviderSnapshotState(snapshot.entries);
|
|
306
|
-
if (state.kind === "ready")
|
|
307
|
-
|
|
269
|
+
if (state.kind === "ready") {
|
|
270
|
+
const providers = state.providers.filter(({ modes }) => modes.length > 0);
|
|
271
|
+
if (providers.length > 0)
|
|
272
|
+
return providers;
|
|
273
|
+
throw new HubCommandError("HUB_AGENT_RUNTIME_REQUIRED", "No agent runtime with an execution mode is available from this daemon. Configure one, then run paseo hub init again.");
|
|
274
|
+
}
|
|
308
275
|
if (state.kind === "unavailable") {
|
|
309
276
|
throw new HubCommandError("HUB_AGENT_RUNTIME_REQUIRED", "No usable agent runtime is available from this daemon. Configure an enabled provider with a selectable model, then run paseo hub init again.");
|
|
310
277
|
}
|
|
@@ -390,9 +357,9 @@ async function collectProviderIdentity(trigger, environment) {
|
|
|
390
357
|
}),
|
|
391
358
|
};
|
|
392
359
|
}
|
|
393
|
-
async function
|
|
360
|
+
async function loadConfigurationResources(origin, environment) {
|
|
394
361
|
try {
|
|
395
|
-
return await withSpinner("Loading Hub connections", () => environment.hub.
|
|
362
|
+
return await withSpinner("Loading Hub connections", () => environment.hub.listConfigurationResources(origin, resolveHubCredential({
|
|
396
363
|
options: { origin },
|
|
397
364
|
env: environment.env,
|
|
398
365
|
credentials: environment.credentials,
|
|
@@ -400,55 +367,40 @@ async function loadSetupResources(origin, environment) {
|
|
|
400
367
|
})));
|
|
401
368
|
}
|
|
402
369
|
catch (error) {
|
|
403
|
-
if (error instanceof HubCommandError &&
|
|
404
|
-
|
|
370
|
+
if (error instanceof HubCommandError &&
|
|
371
|
+
(error.code === "HUB_NOT_FOUND" || error.code === "HUB_INVALID_RESPONSE")) {
|
|
372
|
+
throw new HubCommandError("HUB_UPDATE_REQUIRED", "This Hub needs an update before guided setup can use organization triggers. Update Hub and try again.");
|
|
405
373
|
}
|
|
406
374
|
throw error;
|
|
407
375
|
}
|
|
408
376
|
}
|
|
409
|
-
async function loadDaemonResource(origin, daemonId, environment) {
|
|
410
|
-
const resources = await environment.hub.listConfigurationResources(origin, resolveHubCredential({
|
|
411
|
-
options: { origin },
|
|
412
|
-
env: environment.env,
|
|
413
|
-
credentials: environment.credentials,
|
|
414
|
-
origin,
|
|
415
|
-
}));
|
|
416
|
-
const daemon = resources.daemons.find(({ id }) => id === daemonId);
|
|
417
|
-
if (daemon === undefined) {
|
|
418
|
-
throw new HubCommandError("HUB_DAEMON_RESOURCE_MISSING", "The connected daemon is not available in this Hub organization. Reconnect it and try again.");
|
|
419
|
-
}
|
|
420
|
-
return daemon;
|
|
421
|
-
}
|
|
422
377
|
async function writeScaffold(cwd, scaffold, replaceExisting) {
|
|
423
|
-
const
|
|
424
|
-
const
|
|
425
|
-
const backup = path.join(cwd, `.paseo-backup-${randomUUID()}`);
|
|
426
|
-
let movedExisting = false;
|
|
378
|
+
const destination = path.join(cwd, scaffold.triggerPath);
|
|
379
|
+
const temporary = path.join(path.dirname(destination), `.${path.basename(destination)}.${process.pid}.${randomUUID()}.tmp`);
|
|
427
380
|
try {
|
|
428
|
-
await
|
|
429
|
-
await writeFile(path.join(staging, "hub.yml"), scaffold.hub, { flag: "wx" });
|
|
430
|
-
await writeFile(path.join(staging, "workflows", path.basename(scaffold.workflowPath)), scaffold.workflow, {
|
|
431
|
-
flag: "wx",
|
|
432
|
-
});
|
|
381
|
+
await writeFile(temporary, scaffold.trigger, { flag: "wx" });
|
|
433
382
|
if (replaceExisting) {
|
|
434
|
-
await rename(
|
|
435
|
-
|
|
383
|
+
await rename(temporary, destination);
|
|
384
|
+
}
|
|
385
|
+
else {
|
|
386
|
+
await link(temporary, destination);
|
|
387
|
+
await rm(temporary);
|
|
436
388
|
}
|
|
437
|
-
await rename(staging, root);
|
|
438
|
-
if (movedExisting)
|
|
439
|
-
await rm(backup, { recursive: true, force: true });
|
|
440
389
|
}
|
|
441
390
|
catch (error) {
|
|
442
|
-
await rm(
|
|
443
|
-
if (movedExisting) {
|
|
444
|
-
await rename(backup, root).catch(() => undefined);
|
|
445
|
-
}
|
|
391
|
+
await rm(temporary, { force: true });
|
|
446
392
|
throw error;
|
|
447
393
|
}
|
|
448
394
|
}
|
|
449
|
-
async function
|
|
395
|
+
async function prepareScaffoldDestination(cwd, triggerPath) {
|
|
396
|
+
const root = path.resolve(cwd);
|
|
397
|
+
await requireSafeScaffoldDirectory(path.join(root, ".paseo"), ".paseo");
|
|
398
|
+
await requireSafeScaffoldDirectory(path.join(root, ".paseo", "triggers"), ".paseo/triggers");
|
|
399
|
+
const destination = path.join(root, triggerPath);
|
|
450
400
|
try {
|
|
451
|
-
await lstat(
|
|
401
|
+
const stats = await lstat(destination);
|
|
402
|
+
if (stats.isSymbolicLink())
|
|
403
|
+
throw unsafeScaffoldPath(triggerPath);
|
|
452
404
|
return true;
|
|
453
405
|
}
|
|
454
406
|
catch (error) {
|
|
@@ -457,6 +409,24 @@ async function pathExists(target) {
|
|
|
457
409
|
throw error;
|
|
458
410
|
}
|
|
459
411
|
}
|
|
412
|
+
async function requireSafeScaffoldDirectory(target, displayPath) {
|
|
413
|
+
try {
|
|
414
|
+
const stats = await lstat(target);
|
|
415
|
+
if (stats.isSymbolicLink())
|
|
416
|
+
throw unsafeScaffoldPath(displayPath);
|
|
417
|
+
if (!stats.isDirectory()) {
|
|
418
|
+
throw new HubCommandError("HUB_TRIGGER_DIRECTORY_INVALID", `${displayPath} must be a directory.`);
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
catch (error) {
|
|
422
|
+
if (errorCode(error) !== "ENOENT")
|
|
423
|
+
throw error;
|
|
424
|
+
await mkdir(target);
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
function unsafeScaffoldPath(triggerPath) {
|
|
428
|
+
return new HubCommandError("HUB_TRIGGER_UNSAFE_PATH", `${triggerPath} must not use a symlink.`);
|
|
429
|
+
}
|
|
460
430
|
function errorCode(error) {
|
|
461
431
|
return error instanceof Error && "code" in error && typeof error.code === "string"
|
|
462
432
|
? error.code
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { CommandOptions } from "../../output/index.js";
|
|
2
|
+
import type { DaemonTarget } from "../../utils/daemon-target.js";
|
|
1
3
|
import type { Command } from "commander";
|
|
2
4
|
import { type SingleResult } from "../../output/index.js";
|
|
3
5
|
import type { HubCredentialStore } from "./credentials.js";
|
|
@@ -13,11 +15,9 @@ interface HubLoginDependencies {
|
|
|
13
15
|
flow: Pick<CliLoginFlow, "authorize">;
|
|
14
16
|
reporter: HubReporter;
|
|
15
17
|
isInteractive?(): boolean;
|
|
16
|
-
continueGuidedSetup?(origin: string): Promise<void>;
|
|
18
|
+
continueGuidedSetup?(origin: string, daemonTarget: DaemonTarget): Promise<void>;
|
|
17
19
|
}
|
|
18
|
-
export declare function runHubLogin(originInput: string | undefined, options:
|
|
19
|
-
json?: boolean;
|
|
20
|
-
}, dependencies: HubLoginDependencies): Promise<SingleResult<HubLoginResult>>;
|
|
20
|
+
export declare function runHubLogin(originInput: string | undefined, options: Pick<CommandOptions, "json" | "daemonTarget">, dependencies: HubLoginDependencies): Promise<SingleResult<HubLoginResult>>;
|
|
21
21
|
export declare function addHubLoginCommand(parent: Command, dependencies: HubLoginDependencies): void;
|
|
22
22
|
export {};
|
|
23
23
|
//# sourceMappingURL=login.d.ts.map
|
|
@@ -23,7 +23,7 @@ export async function runHubLogin(originInput, options, dependencies) {
|
|
|
23
23
|
if (!options.json &&
|
|
24
24
|
dependencies.isInteractive?.() &&
|
|
25
25
|
dependencies.continueGuidedSetup !== undefined) {
|
|
26
|
-
await dependencies.continueGuidedSetup(origin);
|
|
26
|
+
await dependencies.continueGuidedSetup(origin, options.daemonTarget);
|
|
27
27
|
}
|
|
28
28
|
return { type: "single", data: { origin, status: "logged_in" }, schema };
|
|
29
29
|
}
|
|
@@ -22,7 +22,7 @@ export async function runHubLogout(options, dependencies) {
|
|
|
22
22
|
let daemonStatus = null;
|
|
23
23
|
const shouldInspectDaemon = options.disconnectDaemon === true || mayPrompt;
|
|
24
24
|
if (shouldInspectDaemon) {
|
|
25
|
-
daemonStatus = await withHubDaemon(dependencies.daemon, options.
|
|
25
|
+
daemonStatus = await withHubDaemon(dependencies.daemon, options.daemonTarget, async (daemon) => daemon.getHubStatus().then((response) => response.status));
|
|
26
26
|
}
|
|
27
27
|
const sameHub = daemonStatus?.hubOrigin === active.origin;
|
|
28
28
|
let shouldDisconnect = options.disconnectDaemon === true && sameHub;
|
|
@@ -34,7 +34,7 @@ export async function runHubLogout(options, dependencies) {
|
|
|
34
34
|
return logoutResult({ origin: active.origin, status: "logged_out", daemonDisconnected: false });
|
|
35
35
|
}
|
|
36
36
|
reportHubProgress(dependencies.reporter, options, `Disconnecting this daemon from ${active.origin}`);
|
|
37
|
-
const disconnect = await withHubDaemon(dependencies.daemon, options.
|
|
37
|
+
const disconnect = await withHubDaemon(dependencies.daemon, options.daemonTarget, async (daemon) => {
|
|
38
38
|
return daemon.disconnectHub(options.force ?? false);
|
|
39
39
|
});
|
|
40
40
|
dependencies.credentials.logoutActive();
|
|
@@ -4,6 +4,7 @@ import type { HubDaemonConnection } from "./daemon-client.js";
|
|
|
4
4
|
import { type HubReporter } from "./reporter.js";
|
|
5
5
|
interface HubPermissionsOptions {
|
|
6
6
|
host?: string;
|
|
7
|
+
daemonTarget: import("../../utils/daemon-target.js").DaemonTarget;
|
|
7
8
|
json?: boolean;
|
|
8
9
|
}
|
|
9
10
|
interface HubPermissionsDependencies {
|
|
@@ -11,7 +11,7 @@ const schema = {
|
|
|
11
11
|
],
|
|
12
12
|
};
|
|
13
13
|
export function runHubPermissionsList(options, dependencies) {
|
|
14
|
-
return withHubDaemon(dependencies.daemon, options.
|
|
14
|
+
return withHubDaemon(dependencies.daemon, options.daemonTarget, async (client) => {
|
|
15
15
|
const status = (await client.getHubStatus()).status;
|
|
16
16
|
requireConnectedHub(status);
|
|
17
17
|
return {
|
|
@@ -25,7 +25,7 @@ export function runHubPermissionsList(options, dependencies) {
|
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
27
|
export function runHubPermissionChange(operation, permission, options, dependencies) {
|
|
28
|
-
return withHubDaemon(dependencies.daemon, options.
|
|
28
|
+
return withHubDaemon(dependencies.daemon, options.daemonTarget, async (client) => {
|
|
29
29
|
const current = (await client.getHubStatus()).status;
|
|
30
30
|
requireConnectedHub(current);
|
|
31
31
|
const response = await client.updateHubPermissions(operation === "grant" ? { grant: [permission] } : { revoke: [permission] });
|