@camerontaylor/paseo-cli 0.8.0-fork.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/paseo +3 -0
- package/dist/classify.d.ts +19 -0
- package/dist/classify.js +49 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.js +135 -0
- package/dist/commands/agent/archive.d.ts +18 -0
- package/dist/commands/agent/archive.js +102 -0
- package/dist/commands/agent/attach.d.ts +11 -0
- package/dist/commands/agent/attach.js +161 -0
- package/dist/commands/agent/delete.d.ts +15 -0
- package/dist/commands/agent/delete.js +107 -0
- package/dist/commands/agent/detach.d.ts +9 -0
- package/dist/commands/agent/detach.js +38 -0
- package/dist/commands/agent/import.d.ts +14 -0
- package/dist/commands/agent/import.js +122 -0
- package/dist/commands/agent/index.d.ts +3 -0
- package/dist/commands/agent/index.js +56 -0
- package/dist/commands/agent/inspect.d.ts +15 -0
- package/dist/commands/agent/inspect.js +209 -0
- package/dist/commands/agent/logs.d.ts +19 -0
- package/dist/commands/agent/logs.js +180 -0
- package/dist/commands/agent/ls.d.ts +44 -0
- package/dist/commands/agent/ls.js +212 -0
- package/dist/commands/agent/mode.d.ts +18 -0
- package/dist/commands/agent/mode.js +100 -0
- package/dist/commands/agent/open.d.ts +11 -0
- package/dist/commands/agent/open.js +61 -0
- package/dist/commands/agent/reload.d.ts +15 -0
- package/dist/commands/agent/reload.js +75 -0
- package/dist/commands/agent/run.d.ts +78 -0
- package/dist/commands/agent/run.js +554 -0
- package/dist/commands/agent/send.d.ts +19 -0
- package/dist/commands/agent/send.js +187 -0
- package/dist/commands/agent/stop.d.ts +17 -0
- package/dist/commands/agent/stop.js +115 -0
- package/dist/commands/agent/update.d.ts +51 -0
- package/dist/commands/agent/update.js +186 -0
- package/dist/commands/agent/wait.d.ts +17 -0
- package/dist/commands/agent/wait.js +158 -0
- package/dist/commands/clone.d.ts +17 -0
- package/dist/commands/clone.js +65 -0
- package/dist/commands/daemon/index.d.ts +3 -0
- package/dist/commands/daemon/index.js +60 -0
- package/dist/commands/daemon/local-daemon.d.ts +78 -0
- package/dist/commands/daemon/local-daemon.js +547 -0
- package/dist/commands/daemon/pair.d.ts +35 -0
- package/dist/commands/daemon/pair.js +167 -0
- package/dist/commands/daemon/reload.d.ts +10 -0
- package/dist/commands/daemon/reload.js +36 -0
- package/dist/commands/daemon/restart.d.ts +12 -0
- package/dist/commands/daemon/restart.js +99 -0
- package/dist/commands/daemon/runtime-toolchain.d.ts +6 -0
- package/dist/commands/daemon/runtime-toolchain.js +87 -0
- package/dist/commands/daemon/set-password.d.ts +17 -0
- package/dist/commands/daemon/set-password.js +82 -0
- package/dist/commands/daemon/start.d.ts +6 -0
- package/dist/commands/daemon/start.js +57 -0
- package/dist/commands/daemon/status.d.ts +21 -0
- package/dist/commands/daemon/status.js +363 -0
- package/dist/commands/daemon/stop.d.ts +15 -0
- package/dist/commands/daemon/stop.js +60 -0
- package/dist/commands/heartbeat/index.d.ts +3 -0
- package/dist/commands/heartbeat/index.js +139 -0
- package/dist/commands/hooks.d.ts +19 -0
- package/dist/commands/hooks.js +89 -0
- package/dist/commands/hub/authority.d.ts +17 -0
- package/dist/commands/hub/authority.js +18 -0
- package/dist/commands/hub/connect.d.ts +23 -0
- package/dist/commands/hub/connect.js +44 -0
- package/dist/commands/hub/credentials.d.ts +21 -0
- package/dist/commands/hub/credentials.js +143 -0
- package/dist/commands/hub/daemon-client.d.ts +40 -0
- package/dist/commands/hub/daemon-client.js +14 -0
- package/dist/commands/hub/deploy-bundle.d.ts +16 -0
- package/dist/commands/hub/deploy-bundle.js +248 -0
- package/dist/commands/hub/deploy-triggers.d.ts +6 -0
- package/dist/commands/hub/deploy-triggers.js +116 -0
- package/dist/commands/hub/deploy.d.ts +50 -0
- package/dist/commands/hub/deploy.js +159 -0
- package/dist/commands/hub/disconnect.d.ts +16 -0
- package/dist/commands/hub/disconnect.js +24 -0
- package/dist/commands/hub/error.d.ts +6 -0
- package/dist/commands/hub/error.js +9 -0
- package/dist/commands/hub/export.d.ts +28 -0
- package/dist/commands/hub/export.js +80 -0
- package/dist/commands/hub/help.d.ts +3 -0
- package/dist/commands/hub/help.js +5 -0
- package/dist/commands/hub/hub-client/index.d.ts +22 -0
- package/dist/commands/hub/hub-client/index.js +135 -0
- package/dist/commands/hub/hub-client/internal/contracts.d.ts +126 -0
- package/dist/commands/hub/hub-client/internal/contracts.js +85 -0
- package/dist/commands/hub/hub-client/internal/problem.d.ts +3 -0
- package/dist/commands/hub/hub-client/internal/problem.js +85 -0
- package/dist/commands/hub/hub-client/internal/transport.d.ts +15 -0
- package/dist/commands/hub/hub-client/internal/transport.js +30 -0
- package/dist/commands/hub/index.d.ts +20 -0
- package/dist/commands/hub/index.js +94 -0
- package/dist/commands/hub/init-plan.d.ts +33 -0
- package/dist/commands/hub/init-plan.js +94 -0
- package/dist/commands/hub/init.d.ts +35 -0
- package/dist/commands/hub/init.js +524 -0
- package/dist/commands/hub/login-flow.d.ts +34 -0
- package/dist/commands/hub/login-flow.js +78 -0
- package/dist/commands/hub/login.d.ts +23 -0
- package/dist/commands/hub/login.js +40 -0
- package/dist/commands/hub/logout.d.ts +32 -0
- package/dist/commands/hub/logout.js +71 -0
- package/dist/commands/hub/origin.d.ts +2 -0
- package/dist/commands/hub/origin.js +27 -0
- package/dist/commands/hub/permissions.d.ts +21 -0
- package/dist/commands/hub/permissions.js +61 -0
- package/dist/commands/hub/projects.d.ts +24 -0
- package/dist/commands/hub/projects.js +49 -0
- package/dist/commands/hub/reporter.d.ts +10 -0
- package/dist/commands/hub/reporter.js +11 -0
- package/dist/commands/hub/starter-agent-runtime.d.ts +37 -0
- package/dist/commands/hub/starter-agent-runtime.js +49 -0
- package/dist/commands/hub/starter-trigger.d.ts +10 -0
- package/dist/commands/hub/starter-trigger.js +30 -0
- package/dist/commands/hub/status-output.d.ts +13 -0
- package/dist/commands/hub/status-output.js +30 -0
- package/dist/commands/onboard.d.ts +10 -0
- package/dist/commands/onboard.js +400 -0
- package/dist/commands/open.d.ts +4 -0
- package/dist/commands/open.js +89 -0
- package/dist/commands/permit/allow.d.ts +20 -0
- package/dist/commands/permit/allow.js +133 -0
- package/dist/commands/permit/deny.d.ts +12 -0
- package/dist/commands/permit/deny.js +105 -0
- package/dist/commands/permit/index.d.ts +3 -0
- package/dist/commands/permit/index.js +27 -0
- package/dist/commands/permit/ls.d.ts +18 -0
- package/dist/commands/permit/ls.js +66 -0
- package/dist/commands/plugin/index.d.ts +17 -0
- package/dist/commands/plugin/index.js +138 -0
- package/dist/commands/plugin/scaffold.d.ts +6 -0
- package/dist/commands/plugin/scaffold.js +162 -0
- package/dist/commands/plugin/shared.d.ts +5 -0
- package/dist/commands/plugin/shared.js +30 -0
- package/dist/commands/project/create.d.ts +10 -0
- package/dist/commands/project/create.js +41 -0
- package/dist/commands/project/delete.d.ts +9 -0
- package/dist/commands/project/delete.js +33 -0
- package/dist/commands/project/index.d.ts +3 -0
- package/dist/commands/project/index.js +28 -0
- package/dist/commands/project/ls.d.ts +5 -0
- package/dist/commands/project/ls.js +19 -0
- package/dist/commands/project/rename.d.ts +15 -0
- package/dist/commands/project/rename.js +50 -0
- package/dist/commands/project/shared.d.ts +11 -0
- package/dist/commands/project/shared.js +18 -0
- package/dist/commands/provider/add.d.ts +30 -0
- package/dist/commands/provider/add.js +123 -0
- package/dist/commands/provider/diagnostic.d.ts +12 -0
- package/dist/commands/provider/diagnostic.js +31 -0
- package/dist/commands/provider/index.d.ts +3 -0
- package/dist/commands/provider/index.js +38 -0
- package/dist/commands/provider/ls.d.ts +20 -0
- package/dist/commands/provider/ls.js +76 -0
- package/dist/commands/provider/models.d.ts +20 -0
- package/dist/commands/provider/models.js +53 -0
- package/dist/commands/provider/rm.d.ts +10 -0
- package/dist/commands/provider/rm.js +45 -0
- package/dist/commands/provider/shared.d.ts +7 -0
- package/dist/commands/provider/shared.js +10 -0
- package/dist/commands/schedule/create.d.ts +19 -0
- package/dist/commands/schedule/create.js +41 -0
- package/dist/commands/schedule/delete.d.ts +10 -0
- package/dist/commands/schedule/delete.js +32 -0
- package/dist/commands/schedule/index.d.ts +3 -0
- package/dist/commands/schedule/index.js +66 -0
- package/dist/commands/schedule/inspect.d.ts +6 -0
- package/dist/commands/schedule/inspect.js +27 -0
- package/dist/commands/schedule/logs.d.ts +6 -0
- package/dist/commands/schedule/logs.js +24 -0
- package/dist/commands/schedule/ls.d.ts +5 -0
- package/dist/commands/schedule/ls.js +25 -0
- package/dist/commands/schedule/pause.d.ts +5 -0
- package/dist/commands/schedule/pause.js +24 -0
- package/dist/commands/schedule/resume.d.ts +5 -0
- package/dist/commands/schedule/resume.js +24 -0
- package/dist/commands/schedule/run-once.d.ts +5 -0
- package/dist/commands/schedule/run-once.js +24 -0
- package/dist/commands/schedule/schema.d.ts +21 -0
- package/dist/commands/schedule/schema.js +67 -0
- package/dist/commands/schedule/shared.d.ts +59 -0
- package/dist/commands/schedule/shared.js +358 -0
- package/dist/commands/schedule/types.d.ts +165 -0
- package/dist/commands/schedule/types.js +2 -0
- package/dist/commands/schedule/update.d.ts +21 -0
- package/dist/commands/schedule/update.js +40 -0
- package/dist/commands/script/index.d.ts +3 -0
- package/dist/commands/script/index.js +19 -0
- package/dist/commands/script/ls.d.ts +6 -0
- package/dist/commands/script/ls.js +20 -0
- package/dist/commands/script/schema.d.ts +5 -0
- package/dist/commands/script/schema.js +13 -0
- package/dist/commands/script/shared.d.ts +11 -0
- package/dist/commands/script/shared.js +59 -0
- package/dist/commands/script/start.d.ts +6 -0
- package/dist/commands/script/start.js +23 -0
- package/dist/commands/script/stop.d.ts +6 -0
- package/dist/commands/script/stop.js +23 -0
- package/dist/commands/speech/index.d.ts +3 -0
- package/dist/commands/speech/index.js +5 -0
- package/dist/commands/terminal/capture.d.ts +10 -0
- package/dist/commands/terminal/capture.js +68 -0
- package/dist/commands/terminal/create.d.ts +11 -0
- package/dist/commands/terminal/create.js +29 -0
- package/dist/commands/terminal/index.d.ts +3 -0
- package/dist/commands/terminal/index.js +45 -0
- package/dist/commands/terminal/kill.d.ts +6 -0
- package/dist/commands/terminal/kill.js +36 -0
- package/dist/commands/terminal/ls.d.ts +11 -0
- package/dist/commands/terminal/ls.js +21 -0
- package/dist/commands/terminal/schema.d.ts +10 -0
- package/dist/commands/terminal/schema.js +17 -0
- package/dist/commands/terminal/send-keys.d.ts +7 -0
- package/dist/commands/terminal/send-keys.js +45 -0
- package/dist/commands/terminal/shared.d.ts +12 -0
- package/dist/commands/terminal/shared.js +62 -0
- package/dist/commands/workspace/archive.d.ts +12 -0
- package/dist/commands/workspace/archive.js +41 -0
- package/dist/commands/workspace/create.d.ts +49 -0
- package/dist/commands/workspace/create.js +114 -0
- package/dist/commands/workspace/index.d.ts +3 -0
- package/dist/commands/workspace/index.js +45 -0
- package/dist/commands/workspace/ls.d.ts +7 -0
- package/dist/commands/workspace/ls.js +28 -0
- package/dist/commands/workspace/rename.d.ts +22 -0
- package/dist/commands/workspace/rename.js +61 -0
- package/dist/commands/workspace/setup.d.ts +11 -0
- package/dist/commands/workspace/setup.js +41 -0
- package/dist/commands/workspace/shared.d.ts +12 -0
- package/dist/commands/workspace/shared.js +20 -0
- package/dist/commands/worktree/archive.d.ts +20 -0
- package/dist/commands/worktree/archive.js +104 -0
- package/dist/commands/worktree/create-input.d.ts +15 -0
- package/dist/commands/worktree/create-input.js +56 -0
- package/dist/commands/worktree/create.d.ts +11 -0
- package/dist/commands/worktree/create.js +58 -0
- package/dist/commands/worktree/index.d.ts +3 -0
- package/dist/commands/worktree/index.js +25 -0
- package/dist/commands/worktree/ls.d.ts +19 -0
- package/dist/commands/worktree/ls.js +97 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +6 -0
- package/dist/output/index.d.ts +45 -0
- package/dist/output/index.js +47 -0
- package/dist/output/json.d.ts +11 -0
- package/dist/output/json.js +37 -0
- package/dist/output/pairing.d.ts +8 -0
- package/dist/output/pairing.js +24 -0
- package/dist/output/quiet.d.ts +9 -0
- package/dist/output/quiet.js +22 -0
- package/dist/output/render.d.ts +15 -0
- package/dist/output/render.js +84 -0
- package/dist/output/table.d.ts +13 -0
- package/dist/output/table.js +135 -0
- package/dist/output/types.d.ts +73 -0
- package/dist/output/types.js +8 -0
- package/dist/output/with-output.d.ts +41 -0
- package/dist/output/with-output.js +85 -0
- package/dist/output/yaml.d.ts +11 -0
- package/dist/output/yaml.js +38 -0
- package/dist/run.d.ts +14 -0
- package/dist/run.js +40 -0
- package/dist/ssh/ssh-tunnel.d.ts +9 -0
- package/dist/ssh/ssh-tunnel.js +79 -0
- package/dist/utils/client-id.d.ts +2 -0
- package/dist/utils/client-id.js +37 -0
- package/dist/utils/client.d.ts +54 -0
- package/dist/utils/client.js +363 -0
- package/dist/utils/command-options.d.ts +7 -0
- package/dist/utils/command-options.js +25 -0
- package/dist/utils/duration.d.ts +7 -0
- package/dist/utils/duration.js +39 -0
- package/dist/utils/errors.d.ts +5 -0
- package/dist/utils/errors.js +10 -0
- package/dist/utils/paths.d.ts +12 -0
- package/dist/utils/paths.js +22 -0
- package/dist/utils/provider-model.d.ts +11 -0
- package/dist/utils/provider-model.js +49 -0
- package/dist/utils/timeline.d.ts +11 -0
- package/dist/utils/timeline.js +11 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.js +10 -0
- package/package.json +50 -0
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { connectToDaemon, getDaemonHost } from "../../utils/client.js";
|
|
2
|
+
import { fetchAgentTimelineItems, formatAgentActivityTranscript } from "./logs.js";
|
|
3
|
+
import { parseDuration } from "../../utils/duration.js";
|
|
4
|
+
/** Schema for agent wait output */
|
|
5
|
+
export const agentWaitSchema = {
|
|
6
|
+
idField: "agentId",
|
|
7
|
+
columns: [
|
|
8
|
+
{ header: "AGENT ID", field: "agentId", width: 12 },
|
|
9
|
+
{ header: "STATUS", field: "status", width: 12 },
|
|
10
|
+
{ header: "MESSAGE", field: "message", width: 40 },
|
|
11
|
+
],
|
|
12
|
+
};
|
|
13
|
+
const WAIT_ACTIVITY_PREVIEW_COUNT = 5;
|
|
14
|
+
const WAIT_ACTIVITY_PREVIEW_TIMEOUT_MS = 2000;
|
|
15
|
+
function appendRecentActivity(message, transcript) {
|
|
16
|
+
if (!transcript || transcript.trim().length === 0) {
|
|
17
|
+
return message;
|
|
18
|
+
}
|
|
19
|
+
return `${message}\nLast ${WAIT_ACTIVITY_PREVIEW_COUNT} activity items:\n${transcript}`;
|
|
20
|
+
}
|
|
21
|
+
async function getRecentActivityTranscript(client, agentId) {
|
|
22
|
+
try {
|
|
23
|
+
const timelineItems = await fetchAgentTimelineItems(client, agentId, {
|
|
24
|
+
timeoutMs: WAIT_ACTIVITY_PREVIEW_TIMEOUT_MS,
|
|
25
|
+
});
|
|
26
|
+
return formatAgentActivityTranscript(timelineItems, WAIT_ACTIVITY_PREVIEW_COUNT);
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
function parseWaitTimeout(timeout) {
|
|
33
|
+
if (!timeout)
|
|
34
|
+
return { timeoutMs: 0, timeoutLabel: null };
|
|
35
|
+
try {
|
|
36
|
+
const ms = parseDuration(timeout);
|
|
37
|
+
if (ms <= 0) {
|
|
38
|
+
throw new Error("Timeout must be positive");
|
|
39
|
+
}
|
|
40
|
+
const timeoutSeconds = Math.floor(ms / 1000);
|
|
41
|
+
return {
|
|
42
|
+
timeoutMs: ms,
|
|
43
|
+
timeoutLabel: `${timeoutSeconds} second${timeoutSeconds === 1 ? "" : "s"}`,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
catch (err) {
|
|
47
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
48
|
+
throw {
|
|
49
|
+
code: "INVALID_TIMEOUT",
|
|
50
|
+
message: "Invalid timeout value",
|
|
51
|
+
details: message,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
function buildWaitResult(args) {
|
|
56
|
+
const { state, resolvedAgentId, recentActivity, timeoutLabel } = args;
|
|
57
|
+
if (state.status === "timeout") {
|
|
58
|
+
const timeoutMessage = timeoutLabel
|
|
59
|
+
? `Agent did not finish within ${timeoutLabel}. Run \`paseo wait ${resolvedAgentId}\` again to keep waiting.`
|
|
60
|
+
: `Agent wait timed out. Run \`paseo wait ${resolvedAgentId}\` again to keep waiting.`;
|
|
61
|
+
return {
|
|
62
|
+
agentId: resolvedAgentId,
|
|
63
|
+
status: "timeout",
|
|
64
|
+
message: appendRecentActivity(timeoutMessage, recentActivity),
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
if (state.status === "permission") {
|
|
68
|
+
const permission = state.final?.pendingPermissions?.[0];
|
|
69
|
+
return {
|
|
70
|
+
agentId: resolvedAgentId,
|
|
71
|
+
status: "permission",
|
|
72
|
+
message: permission
|
|
73
|
+
? `Agent is waiting for permission: ${permission.kind}`
|
|
74
|
+
: "Agent is waiting for permission",
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
if (state.status === "error") {
|
|
78
|
+
return {
|
|
79
|
+
agentId: resolvedAgentId,
|
|
80
|
+
status: "error",
|
|
81
|
+
message: state.error ?? "Agent finished with error",
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
return {
|
|
85
|
+
agentId: resolvedAgentId,
|
|
86
|
+
status: "idle",
|
|
87
|
+
message: appendRecentActivity("Agent is idle.", recentActivity),
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
export function addWaitOptions(cmd) {
|
|
91
|
+
return cmd
|
|
92
|
+
.description("Wait for an agent to become idle")
|
|
93
|
+
.argument("<id>", "Agent ID (or prefix)")
|
|
94
|
+
.option("--timeout <seconds>", "Maximum wait time (default: no limit)");
|
|
95
|
+
}
|
|
96
|
+
export async function runWaitCommand(agentIdArg, options, _command) {
|
|
97
|
+
const host = getDaemonHost({ host: options.host });
|
|
98
|
+
if (!agentIdArg || agentIdArg.trim().length === 0) {
|
|
99
|
+
throw {
|
|
100
|
+
code: "MISSING_AGENT_ID",
|
|
101
|
+
message: "Agent ID is required",
|
|
102
|
+
details: "Usage: paseo agent wait <id>",
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
const { timeoutMs, timeoutLabel } = parseWaitTimeout(options.timeout);
|
|
106
|
+
let client;
|
|
107
|
+
try {
|
|
108
|
+
client = await connectToDaemon({ host: options.host });
|
|
109
|
+
}
|
|
110
|
+
catch (err) {
|
|
111
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
112
|
+
const error = {
|
|
113
|
+
code: "DAEMON_NOT_RUNNING",
|
|
114
|
+
message: `Cannot connect to daemon at ${host}: ${message}`,
|
|
115
|
+
details: "Start the daemon with: paseo daemon start",
|
|
116
|
+
};
|
|
117
|
+
throw error;
|
|
118
|
+
}
|
|
119
|
+
try {
|
|
120
|
+
try {
|
|
121
|
+
const state = await client.waitForFinish(agentIdArg, timeoutMs);
|
|
122
|
+
const resolvedAgentId = state.final?.id ?? agentIdArg;
|
|
123
|
+
const recentActivity = state.status === "timeout" || state.status === "idle"
|
|
124
|
+
? await getRecentActivityTranscript(client, resolvedAgentId)
|
|
125
|
+
: null;
|
|
126
|
+
await client.close();
|
|
127
|
+
return {
|
|
128
|
+
type: "single",
|
|
129
|
+
data: buildWaitResult({ state, resolvedAgentId, recentActivity, timeoutLabel }),
|
|
130
|
+
schema: agentWaitSchema,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
catch (waitErr) {
|
|
134
|
+
await client.close().catch(() => { });
|
|
135
|
+
const waitMessage = waitErr instanceof Error ? waitErr.message : String(waitErr);
|
|
136
|
+
// Other errors
|
|
137
|
+
const error = {
|
|
138
|
+
code: "WAIT_FAILED",
|
|
139
|
+
message: `Failed to wait for agent: ${waitMessage}`,
|
|
140
|
+
};
|
|
141
|
+
throw error;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
catch (err) {
|
|
145
|
+
await client.close().catch(() => { });
|
|
146
|
+
// Re-throw CommandError as-is
|
|
147
|
+
if (err && typeof err === "object" && "code" in err) {
|
|
148
|
+
throw err;
|
|
149
|
+
}
|
|
150
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
151
|
+
const error = {
|
|
152
|
+
code: "WAIT_FAILED",
|
|
153
|
+
message: `Failed to wait for agent: ${message}`,
|
|
154
|
+
};
|
|
155
|
+
throw error;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
//# sourceMappingURL=wait.js.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Command } from "commander";
|
|
2
|
+
import type { OutputSchema, SingleResult } from "../output/index.js";
|
|
3
|
+
import type { CommandOptions } from "../output/with-output.js";
|
|
4
|
+
type CloneProtocol = "https" | "ssh";
|
|
5
|
+
interface CloneCommandOptions extends CommandOptions {
|
|
6
|
+
protocol?: CloneProtocol;
|
|
7
|
+
}
|
|
8
|
+
export interface CloneResult {
|
|
9
|
+
repo: string;
|
|
10
|
+
checkoutPath: string;
|
|
11
|
+
projectId: string;
|
|
12
|
+
projectName: string;
|
|
13
|
+
}
|
|
14
|
+
export declare const cloneSchema: OutputSchema<CloneResult>;
|
|
15
|
+
export declare function runCloneCommand(repo: string, options: CloneCommandOptions, _command: Command): Promise<SingleResult<CloneResult>>;
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=clone.d.ts.map
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { isCompleteGitRemote } from "@camerontaylor/paseo-protocol/git-remote";
|
|
2
|
+
import { buildDaemonConnectionCommandError, connectToDaemon } from "../utils/client.js";
|
|
3
|
+
export const cloneSchema = {
|
|
4
|
+
idField: "projectId",
|
|
5
|
+
columns: [
|
|
6
|
+
{ header: "REPO", field: "repo", width: 28 },
|
|
7
|
+
{ header: "PROJECT", field: "projectName", width: 28 },
|
|
8
|
+
{ header: "PATH", field: "checkoutPath", width: 56 },
|
|
9
|
+
],
|
|
10
|
+
};
|
|
11
|
+
function cmdError(code, message, details) {
|
|
12
|
+
return details ? { code, message, details } : { code, message };
|
|
13
|
+
}
|
|
14
|
+
export async function runCloneCommand(repo, options, _command) {
|
|
15
|
+
const targetDirectory = typeof options.dir === "string" ? options.dir.trim() : "";
|
|
16
|
+
if (!targetDirectory) {
|
|
17
|
+
throw cmdError("INVALID_ARGUMENT", "--dir is required");
|
|
18
|
+
}
|
|
19
|
+
const repoIsCompleteRemote = isCompleteGitRemote(repo);
|
|
20
|
+
if (!repoIsCompleteRemote && !options.protocol) {
|
|
21
|
+
throw cmdError("INVALID_ARGUMENT", "--protocol is required for owner/repo repository names");
|
|
22
|
+
}
|
|
23
|
+
let client;
|
|
24
|
+
try {
|
|
25
|
+
client = await connectToDaemon({ host: options.host });
|
|
26
|
+
}
|
|
27
|
+
catch (err) {
|
|
28
|
+
throw buildDaemonConnectionCommandError({ host: options.host, error: err });
|
|
29
|
+
}
|
|
30
|
+
if (client.getLastServerInfoMessage()?.features?.projectGithubClone !== true) {
|
|
31
|
+
await client.close().catch(() => { });
|
|
32
|
+
throw cmdError("UNSUPPORTED_BY_HOST", "This daemon does not support cloning GitHub repos.", "Update the host to a newer Paseo version.");
|
|
33
|
+
}
|
|
34
|
+
try {
|
|
35
|
+
const response = await client.cloneGithubProject({
|
|
36
|
+
repo,
|
|
37
|
+
targetDirectory,
|
|
38
|
+
...(repoIsCompleteRemote ? {} : { cloneProtocol: options.protocol }),
|
|
39
|
+
});
|
|
40
|
+
if (response.error || !response.project || !response.checkoutPath) {
|
|
41
|
+
throw cmdError("CLONE_FAILED", `Failed to clone GitHub repo: ${response.error ?? "no project returned"}`);
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
type: "single",
|
|
45
|
+
data: {
|
|
46
|
+
repo: response.repo,
|
|
47
|
+
checkoutPath: response.checkoutPath,
|
|
48
|
+
projectId: response.project.projectId,
|
|
49
|
+
projectName: response.project.projectDisplayName,
|
|
50
|
+
},
|
|
51
|
+
schema: cloneSchema,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
catch (err) {
|
|
55
|
+
if (err && typeof err === "object" && "code" in err) {
|
|
56
|
+
throw err;
|
|
57
|
+
}
|
|
58
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
59
|
+
throw cmdError("CLONE_FAILED", `Failed to clone GitHub repo: ${message}`);
|
|
60
|
+
}
|
|
61
|
+
finally {
|
|
62
|
+
await client.close().catch(() => { });
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=clone.js.map
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { Command, Option } from "commander";
|
|
2
|
+
import { startCommand } from "./start.js";
|
|
3
|
+
import { runStatusCommand } from "./status.js";
|
|
4
|
+
import { runStopCommand } from "./stop.js";
|
|
5
|
+
import { runRestartCommand } from "./restart.js";
|
|
6
|
+
import { runSetPasswordCommand } from "./set-password.js";
|
|
7
|
+
import { pairCommand } from "./pair.js";
|
|
8
|
+
import { runDaemonReloadCommand } from "./reload.js";
|
|
9
|
+
import { withOutput } from "../../output/index.js";
|
|
10
|
+
import { addJsonAndDaemonHostOptions, addJsonOption } from "../../utils/command-options.js";
|
|
11
|
+
function resolveHostnamesOption(hostnames, allowedHosts) {
|
|
12
|
+
if (typeof hostnames === "string")
|
|
13
|
+
return hostnames;
|
|
14
|
+
if (typeof allowedHosts === "string")
|
|
15
|
+
return allowedHosts;
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
export function createDaemonCommand() {
|
|
19
|
+
const daemon = new Command("daemon").description("Manage the Paseo daemon");
|
|
20
|
+
daemon.addCommand(startCommand());
|
|
21
|
+
daemon.addCommand(pairCommand());
|
|
22
|
+
addJsonAndDaemonHostOptions(daemon.command("reload").description("Reload config.json without restarting the daemon")).action(withOutput(runDaemonReloadCommand));
|
|
23
|
+
addJsonOption(daemon.command("status").description("Show local daemon status"))
|
|
24
|
+
.option("--home <path>", "Paseo home directory (default: ~/.paseo)")
|
|
25
|
+
.action(withOutput(runStatusCommand));
|
|
26
|
+
addJsonOption(daemon.command("stop").description("Stop the local daemon"))
|
|
27
|
+
.option("--home <path>", "Paseo home directory (default: ~/.paseo)")
|
|
28
|
+
.option("--timeout <seconds>", "Wait timeout before failing (default: 15)")
|
|
29
|
+
.option("--force", "Send SIGKILL if graceful stop times out")
|
|
30
|
+
.option("--kill-timeout <seconds>", "Wait after SIGKILL before failing (default: 3)")
|
|
31
|
+
.action(withOutput(runStopCommand));
|
|
32
|
+
addJsonOption(daemon.command("restart").description("Restart the local daemon"))
|
|
33
|
+
.option("--home <path>", "Paseo home directory (default: ~/.paseo)")
|
|
34
|
+
.option("--timeout <seconds>", "Wait timeout before force step (default: 15)")
|
|
35
|
+
.option("--force", "Send SIGKILL if graceful stop times out")
|
|
36
|
+
.option("--listen <listen>", "Listen target for restarted daemon (host:port, port, or unix socket)")
|
|
37
|
+
.option("--port <port>", "Port for restarted daemon listen target")
|
|
38
|
+
.option("--relay", "Enable relay on restarted daemon")
|
|
39
|
+
.option("--no-relay", "Disable relay on restarted daemon")
|
|
40
|
+
.option("--no-mcp", "Disable Agent MCP on restarted daemon")
|
|
41
|
+
.option("--no-inject-mcp", "Disable auto-injecting the Paseo MCP into created agents")
|
|
42
|
+
.option("--web-ui", "Enable the bundled daemon web UI on restarted daemon")
|
|
43
|
+
.option("--no-web-ui", "Disable the bundled daemon web UI on restarted daemon")
|
|
44
|
+
.option("--hostnames <hosts>", 'Daemon hostnames (comma-separated, e.g. "myhost,.example.com" or "true" for any)')
|
|
45
|
+
.addOption(new Option("--allowed-hosts <hosts>").hideHelp())
|
|
46
|
+
.action(withOutput((...args) => {
|
|
47
|
+
const [options, command] = args.slice(-2);
|
|
48
|
+
return runRestartCommand({
|
|
49
|
+
...options,
|
|
50
|
+
hostnames: resolveHostnamesOption(options.hostnames, options.allowedHosts),
|
|
51
|
+
}, command);
|
|
52
|
+
}));
|
|
53
|
+
addJsonOption(daemon
|
|
54
|
+
.command("set-password")
|
|
55
|
+
.description("Prompt for and save a hashed daemon password to config.json"))
|
|
56
|
+
.option("--home <path>", "Paseo home directory (default: ~/.paseo)")
|
|
57
|
+
.action(withOutput(runSetPasswordCommand));
|
|
58
|
+
return daemon;
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { spawnSync, type ChildProcess } from "node:child_process";
|
|
2
|
+
import { spawnProcess } from "@camerontaylor/paseo-server";
|
|
3
|
+
export interface DaemonStartOptions {
|
|
4
|
+
port?: string;
|
|
5
|
+
listen?: string;
|
|
6
|
+
home?: string;
|
|
7
|
+
foreground?: boolean;
|
|
8
|
+
relay?: boolean;
|
|
9
|
+
relayUseTls?: boolean;
|
|
10
|
+
mcp?: boolean;
|
|
11
|
+
injectMcp?: boolean;
|
|
12
|
+
webUi?: boolean;
|
|
13
|
+
hostnames?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface LocalDaemonPidInfo {
|
|
16
|
+
pid: number;
|
|
17
|
+
startedAt?: string;
|
|
18
|
+
hostname?: string;
|
|
19
|
+
uid?: number;
|
|
20
|
+
listen?: string;
|
|
21
|
+
desktopManaged?: boolean;
|
|
22
|
+
}
|
|
23
|
+
export interface LocalDaemonState {
|
|
24
|
+
home: string;
|
|
25
|
+
listen: string;
|
|
26
|
+
relayEnabled: boolean;
|
|
27
|
+
relayEndpoint: string;
|
|
28
|
+
relayUseTls: boolean;
|
|
29
|
+
relayPublicUseTls: boolean;
|
|
30
|
+
logPath: string;
|
|
31
|
+
pidPath: string;
|
|
32
|
+
pidInfo: LocalDaemonPidInfo | null;
|
|
33
|
+
running: boolean;
|
|
34
|
+
stalePidFile: boolean;
|
|
35
|
+
}
|
|
36
|
+
export interface DetachedStartResult {
|
|
37
|
+
pid: number | null;
|
|
38
|
+
logPath: string;
|
|
39
|
+
}
|
|
40
|
+
export interface StopLocalDaemonOptions {
|
|
41
|
+
home?: string;
|
|
42
|
+
timeoutMs?: number;
|
|
43
|
+
killTimeoutMs?: number;
|
|
44
|
+
force?: boolean;
|
|
45
|
+
}
|
|
46
|
+
export interface StopLocalDaemonResult {
|
|
47
|
+
action: "stopped" | "not_running";
|
|
48
|
+
home: string;
|
|
49
|
+
pid: number | null;
|
|
50
|
+
forced: boolean;
|
|
51
|
+
usedLifecycleRpc: boolean;
|
|
52
|
+
reason: "not_running" | "lifecycle_shutdown_rpc" | "owner_pid_signal" | "owner_pid_sigkill";
|
|
53
|
+
message: string;
|
|
54
|
+
}
|
|
55
|
+
export interface DetachedDaemonProcess extends Pick<ChildProcess, "once" | "pid" | "unref"> {
|
|
56
|
+
}
|
|
57
|
+
export interface ForegroundDaemonProcessResult {
|
|
58
|
+
status: number | null;
|
|
59
|
+
error?: Error;
|
|
60
|
+
}
|
|
61
|
+
export interface DaemonLaunchRuntime {
|
|
62
|
+
resolveRunnerEntry(): string;
|
|
63
|
+
resolveHome(env: NodeJS.ProcessEnv): string;
|
|
64
|
+
spawnDetached(command: string, args: string[], options: Parameters<typeof spawnProcess>[2]): DetachedDaemonProcess;
|
|
65
|
+
spawnForeground(command: string, args: string[], options: Parameters<typeof spawnSync>[2]): ForegroundDaemonProcessResult;
|
|
66
|
+
}
|
|
67
|
+
export declare const DEFAULT_STOP_TIMEOUT_MS = 15000;
|
|
68
|
+
export declare const DEFAULT_KILL_TIMEOUT_MS = 3000;
|
|
69
|
+
export declare function resolveLocalPaseoHome(home?: string): string;
|
|
70
|
+
export declare function resolveTcpHostFromListen(listen: string): string | null;
|
|
71
|
+
export declare function resolveLocalDaemonState(options?: {
|
|
72
|
+
home?: string;
|
|
73
|
+
}): LocalDaemonState;
|
|
74
|
+
export declare function tailDaemonLog(home?: string, lines?: number): string | null;
|
|
75
|
+
export declare function startLocalDaemonDetached(options: DaemonStartOptions, runtime?: DaemonLaunchRuntime): Promise<DetachedStartResult>;
|
|
76
|
+
export declare function startLocalDaemonForeground(options: DaemonStartOptions, runtime?: DaemonLaunchRuntime): number;
|
|
77
|
+
export declare function stopLocalDaemon(options?: StopLocalDaemonOptions): Promise<StopLocalDaemonResult>;
|
|
78
|
+
//# sourceMappingURL=local-daemon.d.ts.map
|