@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,358 @@
|
|
|
1
|
+
import { connectToDaemon, getDaemonHost, getExplicitDaemonHost } from "../../utils/client.js";
|
|
2
|
+
import { parseDuration } from "../../utils/duration.js";
|
|
3
|
+
import { resolveProviderAndModel } from "../../utils/provider-model.js";
|
|
4
|
+
import { everyMsToFiveFieldCron } from "@camerontaylor/paseo-protocol/schedule/cadence";
|
|
5
|
+
export async function connectScheduleClient(host) {
|
|
6
|
+
const resolvedHost = getDaemonHost({ host });
|
|
7
|
+
try {
|
|
8
|
+
const client = (await connectToDaemon({
|
|
9
|
+
host,
|
|
10
|
+
}));
|
|
11
|
+
return { client, host: resolvedHost };
|
|
12
|
+
}
|
|
13
|
+
catch (error) {
|
|
14
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
15
|
+
throw {
|
|
16
|
+
code: "DAEMON_NOT_RUNNING",
|
|
17
|
+
message: `Cannot connect to daemon at ${resolvedHost}: ${message}`,
|
|
18
|
+
details: "Start the daemon with: paseo daemon start",
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export function toScheduleCommandError(code, action, error) {
|
|
23
|
+
if (error && typeof error === "object" && "code" in error) {
|
|
24
|
+
return error;
|
|
25
|
+
}
|
|
26
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
27
|
+
return {
|
|
28
|
+
code,
|
|
29
|
+
message: `Failed to ${action}: ${message}`,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
export async function requireNewAgentSchedule(client, id) {
|
|
33
|
+
const payload = await client.scheduleInspect({ id });
|
|
34
|
+
if (payload.error || !payload.schedule || payload.schedule.target.type !== "new-agent") {
|
|
35
|
+
throw new Error(payload.error ?? `Schedule not found: ${id}`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
export function formatCadence(cadence) {
|
|
39
|
+
if (cadence.type === "cron") {
|
|
40
|
+
const timezoneSuffix = cadence.timezone ? ` (${cadence.timezone})` : "";
|
|
41
|
+
return `cron:${cadence.expression}${timezoneSuffix}`;
|
|
42
|
+
}
|
|
43
|
+
return `every:${formatDurationMs(cadence.everyMs)}`;
|
|
44
|
+
}
|
|
45
|
+
export function formatTarget(target) {
|
|
46
|
+
if (target.type === "self") {
|
|
47
|
+
return `self:${target.agentId.slice(0, 7)}`;
|
|
48
|
+
}
|
|
49
|
+
if (target.type === "agent") {
|
|
50
|
+
return `agent:${target.agentId.slice(0, 7)}`;
|
|
51
|
+
}
|
|
52
|
+
const modelSuffix = target.config.model ? `/${target.config.model}` : "";
|
|
53
|
+
return `new-agent:${target.config.provider}${modelSuffix}`;
|
|
54
|
+
}
|
|
55
|
+
export function formatDurationMs(durationMs) {
|
|
56
|
+
const parts = [];
|
|
57
|
+
let remainingMs = durationMs;
|
|
58
|
+
const hours = Math.floor(remainingMs / (60 * 60 * 1000));
|
|
59
|
+
if (hours > 0) {
|
|
60
|
+
parts.push(`${hours}h`);
|
|
61
|
+
remainingMs -= hours * 60 * 60 * 1000;
|
|
62
|
+
}
|
|
63
|
+
const minutes = Math.floor(remainingMs / (60 * 1000));
|
|
64
|
+
if (minutes > 0) {
|
|
65
|
+
parts.push(`${minutes}m`);
|
|
66
|
+
remainingMs -= minutes * 60 * 1000;
|
|
67
|
+
}
|
|
68
|
+
const seconds = Math.floor(remainingMs / 1000);
|
|
69
|
+
if (seconds > 0 || parts.length === 0) {
|
|
70
|
+
parts.push(`${seconds}s`);
|
|
71
|
+
}
|
|
72
|
+
return parts.join("");
|
|
73
|
+
}
|
|
74
|
+
function resolveScheduleTarget(args) {
|
|
75
|
+
const { targetValue, hasExplicitNewAgentOption, createNewAgentTarget } = args;
|
|
76
|
+
if (!targetValue) {
|
|
77
|
+
return createNewAgentTarget();
|
|
78
|
+
}
|
|
79
|
+
if (targetValue === "new-agent") {
|
|
80
|
+
return createNewAgentTarget();
|
|
81
|
+
}
|
|
82
|
+
if (hasExplicitNewAgentOption) {
|
|
83
|
+
throw {
|
|
84
|
+
code: "INVALID_TARGET",
|
|
85
|
+
message: "--provider/--mode/--thinking can only be used with a new-agent target",
|
|
86
|
+
details: "Use --target new-agent or omit --target to create a new agent schedule",
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
if (targetValue === "self") {
|
|
90
|
+
// COMPAT(scheduleSelfTarget): heartbeat creation moved to `paseo heartbeat create`.
|
|
91
|
+
// Added in v0.2.0; remove after 2027-01-17.
|
|
92
|
+
const currentAgentId = process.env.PASEO_AGENT_ID?.trim();
|
|
93
|
+
if (!currentAgentId) {
|
|
94
|
+
throw {
|
|
95
|
+
code: "INVALID_TARGET",
|
|
96
|
+
message: "--target self requires running inside a Paseo agent",
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
return { type: "self", agentId: currentAgentId };
|
|
100
|
+
}
|
|
101
|
+
return { type: "agent", agentId: targetValue };
|
|
102
|
+
}
|
|
103
|
+
export function parseScheduleCreateInput(options) {
|
|
104
|
+
const prompt = options.prompt.trim();
|
|
105
|
+
if (!prompt) {
|
|
106
|
+
throw {
|
|
107
|
+
code: "INVALID_PROMPT",
|
|
108
|
+
message: "Schedule prompt cannot be empty",
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
const cadence = parseCadenceFromFlags(options.every, options.cron, options.timezone);
|
|
112
|
+
if (!cadence) {
|
|
113
|
+
throw {
|
|
114
|
+
code: "INVALID_CADENCE",
|
|
115
|
+
message: "Specify exactly one of --every or --cron",
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
const cwdInput = options.cwd?.trim();
|
|
119
|
+
if (getExplicitDaemonHost(options.host) !== undefined && !cwdInput) {
|
|
120
|
+
throw {
|
|
121
|
+
code: "MISSING_CWD",
|
|
122
|
+
message: "--cwd is required when --host is specified (the local working directory will not exist on the remote daemon)",
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
const runOnCreate = resolveRunOnCreate(options.runNow, cadence.type);
|
|
126
|
+
const targetValue = options.target?.trim();
|
|
127
|
+
const modeId = options.mode?.trim();
|
|
128
|
+
const thinkingOptionId = options.thinking?.trim();
|
|
129
|
+
if (options.thinking !== undefined && !thinkingOptionId) {
|
|
130
|
+
throw {
|
|
131
|
+
code: "INVALID_THINKING_OPTION",
|
|
132
|
+
message: "--thinking cannot be empty",
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
const hasExplicitNewAgentOption = options.provider !== undefined || options.mode !== undefined || options.thinking !== undefined;
|
|
136
|
+
const createNewAgentTarget = () => {
|
|
137
|
+
const resolvedProviderModel = resolveProviderAndModel({
|
|
138
|
+
provider: options.provider,
|
|
139
|
+
});
|
|
140
|
+
return {
|
|
141
|
+
type: "new-agent",
|
|
142
|
+
config: {
|
|
143
|
+
provider: resolvedProviderModel.provider,
|
|
144
|
+
cwd: cwdInput ?? process.cwd(),
|
|
145
|
+
...(resolvedProviderModel.model ? { model: resolvedProviderModel.model } : {}),
|
|
146
|
+
...(modeId ? { modeId } : {}),
|
|
147
|
+
...(thinkingOptionId ? { thinkingOptionId } : {}),
|
|
148
|
+
},
|
|
149
|
+
};
|
|
150
|
+
};
|
|
151
|
+
const target = resolveScheduleTarget({
|
|
152
|
+
targetValue,
|
|
153
|
+
hasExplicitNewAgentOption,
|
|
154
|
+
createNewAgentTarget,
|
|
155
|
+
});
|
|
156
|
+
const maxRuns = options.maxRuns === undefined ? undefined : parsePositiveInt(options.maxRuns, "--max-runs");
|
|
157
|
+
const expiresAt = options.expiresIn === undefined
|
|
158
|
+
? undefined
|
|
159
|
+
: new Date(Date.now() + parseDuration(options.expiresIn)).toISOString();
|
|
160
|
+
return {
|
|
161
|
+
prompt,
|
|
162
|
+
cadence,
|
|
163
|
+
target,
|
|
164
|
+
runOnCreate,
|
|
165
|
+
...(options.name?.trim() ? { name: options.name.trim() } : {}),
|
|
166
|
+
...(maxRuns !== undefined ? { maxRuns } : {}),
|
|
167
|
+
...(expiresAt ? { expiresAt } : {}),
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
function resolveRunOnCreate(runNow, _cadenceType) {
|
|
171
|
+
return runNow ?? false;
|
|
172
|
+
}
|
|
173
|
+
export function parseScheduleUpdateInput(options) {
|
|
174
|
+
const id = options.id.trim();
|
|
175
|
+
if (!id) {
|
|
176
|
+
throw {
|
|
177
|
+
code: "INVALID_SCHEDULE_ID",
|
|
178
|
+
message: "Schedule id cannot be empty",
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
const cadence = parseCadenceFromFlags(options.every, options.cron, options.timezone);
|
|
182
|
+
const newAgentConfig = buildNewAgentConfigPatch(options);
|
|
183
|
+
const maxRuns = parseUpdateMaxRuns(options);
|
|
184
|
+
const expiresAt = parseUpdateExpiresAt(options);
|
|
185
|
+
const name = parseUpdateName(options);
|
|
186
|
+
const prompt = parseUpdatePrompt(options);
|
|
187
|
+
if (name === undefined &&
|
|
188
|
+
prompt === undefined &&
|
|
189
|
+
cadence === undefined &&
|
|
190
|
+
newAgentConfig === undefined &&
|
|
191
|
+
maxRuns === undefined &&
|
|
192
|
+
expiresAt === undefined) {
|
|
193
|
+
throw {
|
|
194
|
+
code: "NO_UPDATES",
|
|
195
|
+
message: "Specify at least one field to update",
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
return {
|
|
199
|
+
id,
|
|
200
|
+
...(name !== undefined ? { name } : {}),
|
|
201
|
+
...(prompt !== undefined ? { prompt } : {}),
|
|
202
|
+
...(cadence !== undefined ? { cadence } : {}),
|
|
203
|
+
...(newAgentConfig !== undefined ? { newAgentConfig } : {}),
|
|
204
|
+
...(maxRuns !== undefined ? { maxRuns } : {}),
|
|
205
|
+
...(expiresAt !== undefined ? { expiresAt } : {}),
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
function parseCadenceFromFlags(every, cron, timezone) {
|
|
209
|
+
if (every !== undefined && cron !== undefined) {
|
|
210
|
+
throw {
|
|
211
|
+
code: "INVALID_CADENCE",
|
|
212
|
+
message: "Specify at most one of --every or --cron",
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
const trimmedTimeZone = parseTimeZoneFlag(timezone);
|
|
216
|
+
if (trimmedTimeZone !== undefined && cron === undefined) {
|
|
217
|
+
throw {
|
|
218
|
+
code: "INVALID_TIME_ZONE",
|
|
219
|
+
message: "--timezone can only be used with --cron",
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
if (every !== undefined) {
|
|
223
|
+
return { type: "cron", expression: compileEveryPresetToCron(every) };
|
|
224
|
+
}
|
|
225
|
+
if (cron !== undefined) {
|
|
226
|
+
return {
|
|
227
|
+
type: "cron",
|
|
228
|
+
expression: cron.trim(),
|
|
229
|
+
...(trimmedTimeZone ? { timezone: trimmedTimeZone } : {}),
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
return undefined;
|
|
233
|
+
}
|
|
234
|
+
export function compileEveryPresetToCron(value) {
|
|
235
|
+
const durationMs = parseDuration(value);
|
|
236
|
+
const cron = everyMsToFiveFieldCron(durationMs);
|
|
237
|
+
if (cron) {
|
|
238
|
+
return cron;
|
|
239
|
+
}
|
|
240
|
+
throw {
|
|
241
|
+
code: "UNREPRESENTABLE_CADENCE",
|
|
242
|
+
message: `${value} cannot be represented faithfully by five-field cron`,
|
|
243
|
+
details: "Use --cron for calendar schedules",
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
function parseTimeZoneFlag(timeZone) {
|
|
247
|
+
if (timeZone === undefined) {
|
|
248
|
+
return undefined;
|
|
249
|
+
}
|
|
250
|
+
const trimmed = timeZone.trim();
|
|
251
|
+
if (!trimmed) {
|
|
252
|
+
throw {
|
|
253
|
+
code: "INVALID_TIME_ZONE",
|
|
254
|
+
message: "--timezone cannot be empty",
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
return trimmed;
|
|
258
|
+
}
|
|
259
|
+
function parseUpdateMaxRuns(options) {
|
|
260
|
+
if (options.maxRuns !== undefined && options.clearMaxRuns) {
|
|
261
|
+
throw {
|
|
262
|
+
code: "CONFLICTING_MAX_RUNS",
|
|
263
|
+
message: "Use either --max-runs <n> or --no-max-runs, not both",
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
if (options.clearMaxRuns) {
|
|
267
|
+
return null;
|
|
268
|
+
}
|
|
269
|
+
if (options.maxRuns !== undefined) {
|
|
270
|
+
return parsePositiveInt(options.maxRuns, "--max-runs");
|
|
271
|
+
}
|
|
272
|
+
return undefined;
|
|
273
|
+
}
|
|
274
|
+
function parseUpdateExpiresAt(options) {
|
|
275
|
+
if (options.expiresIn !== undefined && options.clearExpires) {
|
|
276
|
+
throw {
|
|
277
|
+
code: "CONFLICTING_EXPIRES",
|
|
278
|
+
message: "Use either --expires-in <duration> or --no-expires-in, not both",
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
if (options.clearExpires) {
|
|
282
|
+
return null;
|
|
283
|
+
}
|
|
284
|
+
if (options.expiresIn !== undefined) {
|
|
285
|
+
return new Date(Date.now() + parseDuration(options.expiresIn)).toISOString();
|
|
286
|
+
}
|
|
287
|
+
return undefined;
|
|
288
|
+
}
|
|
289
|
+
function parseUpdateName(options) {
|
|
290
|
+
if (options.name === undefined) {
|
|
291
|
+
return undefined;
|
|
292
|
+
}
|
|
293
|
+
const trimmed = options.name.trim();
|
|
294
|
+
return trimmed.length > 0 ? trimmed : null;
|
|
295
|
+
}
|
|
296
|
+
function parseUpdatePrompt(options) {
|
|
297
|
+
if (options.prompt === undefined) {
|
|
298
|
+
return undefined;
|
|
299
|
+
}
|
|
300
|
+
const trimmed = options.prompt.trim();
|
|
301
|
+
if (!trimmed) {
|
|
302
|
+
throw {
|
|
303
|
+
code: "INVALID_PROMPT",
|
|
304
|
+
message: "--prompt cannot be empty",
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
return trimmed;
|
|
308
|
+
}
|
|
309
|
+
function buildNewAgentConfigPatch(options) {
|
|
310
|
+
const patch = {};
|
|
311
|
+
if (options.provider !== undefined || options.model !== undefined) {
|
|
312
|
+
const resolved = resolveProviderAndModel({
|
|
313
|
+
provider: options.provider,
|
|
314
|
+
model: options.model,
|
|
315
|
+
});
|
|
316
|
+
patch.provider = resolved.provider;
|
|
317
|
+
if (resolved.model !== undefined) {
|
|
318
|
+
patch.model = resolved.model;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
if (options.mode !== undefined) {
|
|
322
|
+
const trimmed = options.mode.trim();
|
|
323
|
+
patch.modeId = trimmed.length > 0 ? trimmed : null;
|
|
324
|
+
}
|
|
325
|
+
if (options.cwd !== undefined) {
|
|
326
|
+
const trimmed = options.cwd.trim();
|
|
327
|
+
if (!trimmed) {
|
|
328
|
+
throw {
|
|
329
|
+
code: "INVALID_CWD",
|
|
330
|
+
message: "--cwd cannot be empty",
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
patch.cwd = trimmed;
|
|
334
|
+
}
|
|
335
|
+
return Object.keys(patch).length > 0 ? patch : undefined;
|
|
336
|
+
}
|
|
337
|
+
function parsePositiveInt(value, flag) {
|
|
338
|
+
const parsed = Number.parseInt(value, 10);
|
|
339
|
+
if (!Number.isInteger(parsed) || parsed <= 0) {
|
|
340
|
+
throw {
|
|
341
|
+
code: "INVALID_INTEGER",
|
|
342
|
+
message: `${flag} must be a positive integer`,
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
return parsed;
|
|
346
|
+
}
|
|
347
|
+
export function toScheduleRow(schedule) {
|
|
348
|
+
return {
|
|
349
|
+
id: schedule.id,
|
|
350
|
+
name: schedule.name,
|
|
351
|
+
cadence: formatCadence(schedule.cadence),
|
|
352
|
+
target: formatTarget(schedule.target),
|
|
353
|
+
status: schedule.status,
|
|
354
|
+
nextRunAt: schedule.nextRunAt,
|
|
355
|
+
lastRunAt: schedule.lastRunAt,
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
//# sourceMappingURL=shared.js.map
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
export type ScheduleStatus = "active" | "paused" | "completed";
|
|
2
|
+
export type ScheduleCadence = {
|
|
3
|
+
type: "every";
|
|
4
|
+
everyMs: number;
|
|
5
|
+
} | {
|
|
6
|
+
type: "cron";
|
|
7
|
+
expression: string;
|
|
8
|
+
timezone?: string;
|
|
9
|
+
};
|
|
10
|
+
export type ScheduleTarget = {
|
|
11
|
+
type: "self";
|
|
12
|
+
agentId: string;
|
|
13
|
+
} | {
|
|
14
|
+
type: "agent";
|
|
15
|
+
agentId: string;
|
|
16
|
+
} | {
|
|
17
|
+
type: "new-agent";
|
|
18
|
+
config: {
|
|
19
|
+
provider: string;
|
|
20
|
+
cwd: string;
|
|
21
|
+
modeId?: string;
|
|
22
|
+
model?: string;
|
|
23
|
+
thinkingOptionId?: string;
|
|
24
|
+
title?: string | null;
|
|
25
|
+
providerOptions?: Record<string, unknown>;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
export interface ScheduleRunRecord {
|
|
29
|
+
id: string;
|
|
30
|
+
scheduledFor: string;
|
|
31
|
+
startedAt: string;
|
|
32
|
+
endedAt: string | null;
|
|
33
|
+
status: "running" | "succeeded" | "failed";
|
|
34
|
+
agentId: string | null;
|
|
35
|
+
output: string | null;
|
|
36
|
+
error: string | null;
|
|
37
|
+
}
|
|
38
|
+
export interface ScheduleRecord {
|
|
39
|
+
id: string;
|
|
40
|
+
name: string | null;
|
|
41
|
+
prompt: string;
|
|
42
|
+
cadence: ScheduleCadence;
|
|
43
|
+
target: Exclude<ScheduleTarget, {
|
|
44
|
+
type: "self";
|
|
45
|
+
}>;
|
|
46
|
+
status: ScheduleStatus;
|
|
47
|
+
createdAt: string;
|
|
48
|
+
updatedAt: string;
|
|
49
|
+
nextRunAt: string | null;
|
|
50
|
+
lastRunAt: string | null;
|
|
51
|
+
pausedAt: string | null;
|
|
52
|
+
expiresAt: string | null;
|
|
53
|
+
maxRuns: number | null;
|
|
54
|
+
runs: ScheduleRunRecord[];
|
|
55
|
+
}
|
|
56
|
+
export interface ScheduleListItem {
|
|
57
|
+
id: string;
|
|
58
|
+
name: string | null;
|
|
59
|
+
cadence: ScheduleCadence;
|
|
60
|
+
target: Exclude<ScheduleTarget, {
|
|
61
|
+
type: "self";
|
|
62
|
+
}>;
|
|
63
|
+
status: ScheduleStatus;
|
|
64
|
+
nextRunAt: string | null;
|
|
65
|
+
lastRunAt: string | null;
|
|
66
|
+
createdAt: string;
|
|
67
|
+
updatedAt: string;
|
|
68
|
+
pausedAt: string | null;
|
|
69
|
+
expiresAt: string | null;
|
|
70
|
+
maxRuns: number | null;
|
|
71
|
+
}
|
|
72
|
+
export interface CreateScheduleInput {
|
|
73
|
+
prompt: string;
|
|
74
|
+
name?: string;
|
|
75
|
+
cadence: ScheduleCadence;
|
|
76
|
+
target: ScheduleTarget;
|
|
77
|
+
maxRuns?: number;
|
|
78
|
+
expiresAt?: string;
|
|
79
|
+
runOnCreate?: boolean;
|
|
80
|
+
}
|
|
81
|
+
export interface ScheduleCreatePayload {
|
|
82
|
+
requestId: string;
|
|
83
|
+
schedule: ScheduleListItem | null;
|
|
84
|
+
error: string | null;
|
|
85
|
+
}
|
|
86
|
+
export interface ScheduleListPayload {
|
|
87
|
+
requestId: string;
|
|
88
|
+
schedules: ScheduleListItem[];
|
|
89
|
+
error: string | null;
|
|
90
|
+
}
|
|
91
|
+
export interface ScheduleInspectPayload {
|
|
92
|
+
requestId: string;
|
|
93
|
+
schedule: ScheduleRecord | null;
|
|
94
|
+
error: string | null;
|
|
95
|
+
}
|
|
96
|
+
export interface ScheduleLogsPayload {
|
|
97
|
+
requestId: string;
|
|
98
|
+
runs: ScheduleRunRecord[];
|
|
99
|
+
error: string | null;
|
|
100
|
+
}
|
|
101
|
+
export interface SchedulePausePayload {
|
|
102
|
+
requestId: string;
|
|
103
|
+
schedule: ScheduleListItem | null;
|
|
104
|
+
error: string | null;
|
|
105
|
+
}
|
|
106
|
+
export interface ScheduleResumePayload {
|
|
107
|
+
requestId: string;
|
|
108
|
+
schedule: ScheduleListItem | null;
|
|
109
|
+
error: string | null;
|
|
110
|
+
}
|
|
111
|
+
export interface ScheduleDeletePayload {
|
|
112
|
+
requestId: string;
|
|
113
|
+
scheduleId: string;
|
|
114
|
+
error: string | null;
|
|
115
|
+
}
|
|
116
|
+
export interface ScheduleRunOncePayload {
|
|
117
|
+
requestId: string;
|
|
118
|
+
schedule: ScheduleRecord | null;
|
|
119
|
+
error: string | null;
|
|
120
|
+
}
|
|
121
|
+
export interface UpdateScheduleNewAgentConfig {
|
|
122
|
+
provider?: string;
|
|
123
|
+
model?: string | null;
|
|
124
|
+
modeId?: string | null;
|
|
125
|
+
cwd?: string;
|
|
126
|
+
}
|
|
127
|
+
export interface UpdateScheduleInput {
|
|
128
|
+
id: string;
|
|
129
|
+
name?: string | null;
|
|
130
|
+
prompt?: string;
|
|
131
|
+
cadence?: ScheduleCadence;
|
|
132
|
+
newAgentConfig?: UpdateScheduleNewAgentConfig;
|
|
133
|
+
maxRuns?: number | null;
|
|
134
|
+
expiresAt?: string | null;
|
|
135
|
+
}
|
|
136
|
+
export interface ScheduleUpdatePayload {
|
|
137
|
+
requestId: string;
|
|
138
|
+
schedule: ScheduleRecord | null;
|
|
139
|
+
error: string | null;
|
|
140
|
+
}
|
|
141
|
+
export interface ScheduleDaemonClient {
|
|
142
|
+
scheduleCreate(input: CreateScheduleInput): Promise<ScheduleCreatePayload>;
|
|
143
|
+
scheduleList(): Promise<ScheduleListPayload>;
|
|
144
|
+
scheduleInspect(input: {
|
|
145
|
+
id: string;
|
|
146
|
+
}): Promise<ScheduleInspectPayload>;
|
|
147
|
+
scheduleLogs(input: {
|
|
148
|
+
id: string;
|
|
149
|
+
}): Promise<ScheduleLogsPayload>;
|
|
150
|
+
schedulePause(input: {
|
|
151
|
+
id: string;
|
|
152
|
+
}): Promise<SchedulePausePayload>;
|
|
153
|
+
scheduleResume(input: {
|
|
154
|
+
id: string;
|
|
155
|
+
}): Promise<ScheduleResumePayload>;
|
|
156
|
+
scheduleDelete(input: {
|
|
157
|
+
id: string;
|
|
158
|
+
}): Promise<ScheduleDeletePayload>;
|
|
159
|
+
scheduleRunOnce(input: {
|
|
160
|
+
id: string;
|
|
161
|
+
}): Promise<ScheduleRunOncePayload>;
|
|
162
|
+
scheduleUpdate(input: UpdateScheduleInput): Promise<ScheduleUpdatePayload>;
|
|
163
|
+
close(): Promise<void>;
|
|
164
|
+
}
|
|
165
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Command } from "commander";
|
|
2
|
+
import type { ListResult } from "../../output/index.js";
|
|
3
|
+
import { type ScheduleInspectRow } from "./schema.js";
|
|
4
|
+
import { type ScheduleCommandOptions } from "./shared.js";
|
|
5
|
+
export interface ScheduleUpdateOptions extends ScheduleCommandOptions {
|
|
6
|
+
every?: string;
|
|
7
|
+
cron?: string;
|
|
8
|
+
timezone?: string;
|
|
9
|
+
name?: string;
|
|
10
|
+
prompt?: string;
|
|
11
|
+
provider?: string;
|
|
12
|
+
model?: string;
|
|
13
|
+
mode?: string;
|
|
14
|
+
cwd?: string;
|
|
15
|
+
maxRuns?: string;
|
|
16
|
+
noMaxRuns?: boolean;
|
|
17
|
+
expiresIn?: string;
|
|
18
|
+
noExpiresIn?: boolean;
|
|
19
|
+
}
|
|
20
|
+
export declare function runUpdateCommand(id: string, options: ScheduleUpdateOptions, _command: Command): Promise<ListResult<ScheduleInspectRow>>;
|
|
21
|
+
//# sourceMappingURL=update.d.ts.map
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { createScheduleInspectRows, createScheduleInspectSchema, } from "./schema.js";
|
|
2
|
+
import { connectScheduleClient, parseScheduleUpdateInput, requireNewAgentSchedule, toScheduleCommandError, } from "./shared.js";
|
|
3
|
+
export async function runUpdateCommand(id, options, _command) {
|
|
4
|
+
const input = parseScheduleUpdateInput({
|
|
5
|
+
id,
|
|
6
|
+
every: options.every,
|
|
7
|
+
cron: options.cron,
|
|
8
|
+
timezone: options.timezone,
|
|
9
|
+
name: options.name,
|
|
10
|
+
prompt: options.prompt,
|
|
11
|
+
provider: options.provider,
|
|
12
|
+
model: options.model,
|
|
13
|
+
mode: options.mode,
|
|
14
|
+
cwd: options.cwd,
|
|
15
|
+
maxRuns: options.maxRuns,
|
|
16
|
+
expiresIn: options.expiresIn,
|
|
17
|
+
clearMaxRuns: options.noMaxRuns,
|
|
18
|
+
clearExpires: options.noExpiresIn,
|
|
19
|
+
});
|
|
20
|
+
const { client } = await connectScheduleClient(options.host);
|
|
21
|
+
try {
|
|
22
|
+
await requireNewAgentSchedule(client, id);
|
|
23
|
+
const payload = await client.scheduleUpdate(input);
|
|
24
|
+
if (payload.error || !payload.schedule) {
|
|
25
|
+
throw new Error(payload.error ?? `Failed to update schedule: ${id}`);
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
type: "list",
|
|
29
|
+
data: createScheduleInspectRows(payload.schedule),
|
|
30
|
+
schema: createScheduleInspectSchema(payload.schedule),
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
throw toScheduleCommandError("SCHEDULE_UPDATE_FAILED", "update schedule", error);
|
|
35
|
+
}
|
|
36
|
+
finally {
|
|
37
|
+
await client.close().catch(() => { });
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=update.js.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import { withOutput } from "../../output/index.js";
|
|
3
|
+
import { addJsonAndDaemonHostOptions } from "../../utils/command-options.js";
|
|
4
|
+
import { runLsCommand } from "./ls.js";
|
|
5
|
+
import { runStartCommand } from "./start.js";
|
|
6
|
+
import { runStopCommand } from "./stop.js";
|
|
7
|
+
function addWorkspaceSelectionOptions(command) {
|
|
8
|
+
return command
|
|
9
|
+
.option("--cwd <path>", "Workspace directory (default: current directory)")
|
|
10
|
+
.option("--workspace <workspace-id>", "Workspace ID (required when a directory has multiple workspaces)");
|
|
11
|
+
}
|
|
12
|
+
export function createScriptCommand() {
|
|
13
|
+
const script = new Command("script").description("Manage configured workspace scripts");
|
|
14
|
+
addJsonAndDaemonHostOptions(addWorkspaceSelectionOptions(script.command("ls").description("List configured workspace scripts"))).action(withOutput(runLsCommand));
|
|
15
|
+
addJsonAndDaemonHostOptions(addWorkspaceSelectionOptions(script.command("start").description("Start a configured workspace script").argument("<name>"))).action(withOutput(runStartCommand));
|
|
16
|
+
addJsonAndDaemonHostOptions(addWorkspaceSelectionOptions(script.command("stop").description("Stop a running workspace script").argument("<name>"))).action(withOutput(runStopCommand));
|
|
17
|
+
return script;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Command } from "commander";
|
|
2
|
+
import type { ListResult } from "../../output/index.js";
|
|
3
|
+
import { type WorkspaceScriptCommandOptions } from "./shared.js";
|
|
4
|
+
import { type WorkspaceScriptRow } from "./schema.js";
|
|
5
|
+
export declare function runLsCommand(options: WorkspaceScriptCommandOptions, _command: Command): Promise<ListResult<WorkspaceScriptRow>>;
|
|
6
|
+
//# sourceMappingURL=ls.d.ts.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { connectWorkspaceScriptClient, resolveWorkspaceScriptWorkspaceId, toWorkspaceScriptCommandError, } from "./shared.js";
|
|
2
|
+
import { workspaceScriptSchema } from "./schema.js";
|
|
3
|
+
export async function runLsCommand(options, _command) {
|
|
4
|
+
const client = await connectWorkspaceScriptClient(options.host);
|
|
5
|
+
try {
|
|
6
|
+
const workspaceId = await resolveWorkspaceScriptWorkspaceId(client, options);
|
|
7
|
+
const payload = await client.listWorkspaceScripts(workspaceId);
|
|
8
|
+
if (payload.error) {
|
|
9
|
+
throw new Error(payload.error);
|
|
10
|
+
}
|
|
11
|
+
return { type: "list", data: payload.scripts ?? [], schema: workspaceScriptSchema };
|
|
12
|
+
}
|
|
13
|
+
catch (error) {
|
|
14
|
+
throw toWorkspaceScriptCommandError("WORKSPACE_SCRIPT_LIST_FAILED", "list workspace scripts", error);
|
|
15
|
+
}
|
|
16
|
+
finally {
|
|
17
|
+
await client.close().catch(() => { });
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=ls.js.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { WorkspaceScriptPayload } from "@camerontaylor/paseo-protocol/messages";
|
|
2
|
+
import type { OutputSchema } from "../../output/index.js";
|
|
3
|
+
export type WorkspaceScriptRow = WorkspaceScriptPayload;
|
|
4
|
+
export declare const workspaceScriptSchema: OutputSchema<WorkspaceScriptRow>;
|
|
5
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export const workspaceScriptSchema = {
|
|
2
|
+
idField: "scriptName",
|
|
3
|
+
columns: [
|
|
4
|
+
{ header: "NAME", field: "scriptName", width: 20 },
|
|
5
|
+
{ header: "TYPE", field: "type", width: 9 },
|
|
6
|
+
{ header: "LIFECYCLE", field: "lifecycle", width: 10 },
|
|
7
|
+
{ header: "HEALTH", field: (script) => script.health ?? "-", width: 10 },
|
|
8
|
+
{ header: "PORT", field: (script) => script.port ?? "-", width: 7 },
|
|
9
|
+
{ header: "PROXY URL", field: (script) => script.proxyUrl ?? "-", width: 42 },
|
|
10
|
+
{ header: "TERMINAL", field: (script) => script.terminalId ?? "-", width: 12 },
|
|
11
|
+
],
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { DaemonClient } from "@camerontaylor/paseo-client/internal/daemon-client";
|
|
2
|
+
import type { CommandError, CommandOptions } from "../../output/index.js";
|
|
3
|
+
export interface WorkspaceScriptCommandOptions extends CommandOptions {
|
|
4
|
+
host?: string;
|
|
5
|
+
cwd?: string;
|
|
6
|
+
workspace?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function connectWorkspaceScriptClient(host?: string): Promise<DaemonClient>;
|
|
9
|
+
export declare function resolveWorkspaceScriptWorkspaceId(client: DaemonClient, options: WorkspaceScriptCommandOptions): Promise<string>;
|
|
10
|
+
export declare function toWorkspaceScriptCommandError(code: string, action: string, error: unknown): CommandError;
|
|
11
|
+
//# sourceMappingURL=shared.d.ts.map
|