@getmateo/cli 0.0.0-stage → 0.19.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +211 -0
- package/bin/mateo +3 -0
- package/dist/classify.d.ts +19 -0
- package/dist/classify.js +49 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.js +143 -0
- package/dist/commands/agent/archive.d.ts +27 -0
- package/dist/commands/agent/archive.js +88 -0
- package/dist/commands/agent/attach.d.ts +8 -0
- package/dist/commands/agent/attach.js +160 -0
- package/dist/commands/agent/delete.d.ts +15 -0
- package/dist/commands/agent/delete.js +104 -0
- package/dist/commands/agent/detach.d.ts +16 -0
- package/dist/commands/agent/detach.js +44 -0
- package/dist/commands/agent/import.d.ts +14 -0
- package/dist/commands/agent/import.js +108 -0
- package/dist/commands/agent/index.d.ts +3 -0
- package/dist/commands/agent/index.js +56 -0
- package/dist/commands/agent/inspect.d.ts +15 -0
- package/dist/commands/agent/inspect.js +196 -0
- package/dist/commands/agent/logs.d.ts +39 -0
- package/dist/commands/agent/logs.js +369 -0
- package/dist/commands/agent/ls.d.ts +61 -0
- package/dist/commands/agent/ls.js +201 -0
- package/dist/commands/agent/mode.d.ts +18 -0
- package/dist/commands/agent/mode.js +100 -0
- package/dist/commands/agent/open.d.ts +11 -0
- package/dist/commands/agent/open.js +74 -0
- package/dist/commands/agent/reload.d.ts +25 -0
- package/dist/commands/agent/reload.js +64 -0
- package/dist/commands/agent/run.d.ts +77 -0
- package/dist/commands/agent/run.js +556 -0
- package/dist/commands/agent/send.d.ts +21 -0
- package/dist/commands/agent/send.js +187 -0
- package/dist/commands/agent/stop.d.ts +17 -0
- package/dist/commands/agent/stop.js +102 -0
- package/dist/commands/agent/update.d.ts +51 -0
- package/dist/commands/agent/update.js +173 -0
- package/dist/commands/agent/wait.d.ts +31 -0
- package/dist/commands/agent/wait.js +161 -0
- package/dist/commands/clone.d.ts +17 -0
- package/dist/commands/clone.js +59 -0
- package/dist/commands/daemon/config.d.ts +3 -0
- package/dist/commands/daemon/config.js +103 -0
- package/dist/commands/daemon/index.d.ts +3 -0
- package/dist/commands/daemon/index.js +28 -0
- package/dist/commands/daemon/local-daemon.d.ts +13 -0
- package/dist/commands/daemon/local-daemon.js +105 -0
- package/dist/commands/daemon/pair.d.ts +30 -0
- package/dist/commands/daemon/pair.js +145 -0
- package/dist/commands/daemon/reload.d.ts +12 -0
- package/dist/commands/daemon/reload.js +44 -0
- package/dist/commands/daemon/restart.d.ts +29 -0
- package/dist/commands/daemon/restart.js +169 -0
- package/dist/commands/daemon/runtime-toolchain.d.ts +6 -0
- package/dist/commands/daemon/runtime-toolchain.js +87 -0
- package/dist/commands/daemon/set-password.d.ts +17 -0
- package/dist/commands/daemon/set-password.js +89 -0
- package/dist/commands/daemon/start.d.ts +20 -0
- package/dist/commands/daemon/start.js +52 -0
- package/dist/commands/daemon/status.d.ts +13 -0
- package/dist/commands/daemon/status.js +119 -0
- package/dist/commands/daemon/stop.d.ts +20 -0
- package/dist/commands/daemon/stop.js +58 -0
- package/dist/commands/fleet/index.d.ts +4 -0
- package/dist/commands/fleet/index.js +57 -0
- package/dist/commands/heartbeat/index.d.ts +3 -0
- package/dist/commands/heartbeat/index.js +139 -0
- package/dist/commands/hooks.d.ts +19 -0
- package/dist/commands/hooks.js +89 -0
- package/dist/commands/hub/authority.d.ts +17 -0
- package/dist/commands/hub/authority.js +18 -0
- package/dist/commands/hub/connect.d.ts +24 -0
- package/dist/commands/hub/connect.js +44 -0
- package/dist/commands/hub/credentials.d.ts +21 -0
- package/dist/commands/hub/credentials.js +143 -0
- package/dist/commands/hub/daemon-client.d.ts +41 -0
- package/dist/commands/hub/daemon-client.js +14 -0
- package/dist/commands/hub/deploy-bundle.d.ts +16 -0
- package/dist/commands/hub/deploy-bundle.js +248 -0
- package/dist/commands/hub/deploy-triggers.d.ts +6 -0
- package/dist/commands/hub/deploy-triggers.js +116 -0
- package/dist/commands/hub/deploy.d.ts +50 -0
- package/dist/commands/hub/deploy.js +159 -0
- package/dist/commands/hub/disconnect.d.ts +17 -0
- package/dist/commands/hub/disconnect.js +24 -0
- package/dist/commands/hub/error.d.ts +6 -0
- package/dist/commands/hub/error.js +9 -0
- package/dist/commands/hub/export.d.ts +28 -0
- package/dist/commands/hub/export.js +80 -0
- package/dist/commands/hub/help.d.ts +3 -0
- package/dist/commands/hub/help.js +5 -0
- package/dist/commands/hub/hub-client/index.d.ts +22 -0
- package/dist/commands/hub/hub-client/index.js +135 -0
- package/dist/commands/hub/hub-client/internal/contracts.d.ts +126 -0
- package/dist/commands/hub/hub-client/internal/contracts.js +85 -0
- package/dist/commands/hub/hub-client/internal/problem.d.ts +3 -0
- package/dist/commands/hub/hub-client/internal/problem.js +85 -0
- package/dist/commands/hub/hub-client/internal/transport.d.ts +15 -0
- package/dist/commands/hub/hub-client/internal/transport.js +30 -0
- package/dist/commands/hub/index.d.ts +20 -0
- package/dist/commands/hub/index.js +94 -0
- package/dist/commands/hub/init-plan.d.ts +33 -0
- package/dist/commands/hub/init-plan.js +94 -0
- package/dist/commands/hub/init.d.ts +37 -0
- package/dist/commands/hub/init.js +525 -0
- package/dist/commands/hub/login-flow.d.ts +34 -0
- package/dist/commands/hub/login-flow.js +78 -0
- package/dist/commands/hub/login.d.ts +23 -0
- package/dist/commands/hub/login.js +40 -0
- package/dist/commands/hub/logout.d.ts +33 -0
- package/dist/commands/hub/logout.js +71 -0
- package/dist/commands/hub/origin.d.ts +2 -0
- package/dist/commands/hub/origin.js +27 -0
- package/dist/commands/hub/permissions.d.ts +22 -0
- package/dist/commands/hub/permissions.js +61 -0
- package/dist/commands/hub/projects.d.ts +24 -0
- package/dist/commands/hub/projects.js +49 -0
- package/dist/commands/hub/reporter.d.ts +10 -0
- package/dist/commands/hub/reporter.js +11 -0
- package/dist/commands/hub/starter-agent-runtime.d.ts +37 -0
- package/dist/commands/hub/starter-agent-runtime.js +49 -0
- package/dist/commands/hub/starter-trigger.d.ts +10 -0
- package/dist/commands/hub/starter-trigger.js +30 -0
- package/dist/commands/hub/status-output.d.ts +13 -0
- package/dist/commands/hub/status-output.js +30 -0
- package/dist/commands/onboard.d.ts +14 -0
- package/dist/commands/onboard.js +169 -0
- package/dist/commands/open.d.ts +4 -0
- package/dist/commands/open.js +91 -0
- package/dist/commands/permit/allow.d.ts +38 -0
- package/dist/commands/permit/allow.js +138 -0
- package/dist/commands/permit/deny.d.ts +13 -0
- package/dist/commands/permit/deny.js +100 -0
- package/dist/commands/permit/index.d.ts +3 -0
- package/dist/commands/permit/index.js +27 -0
- package/dist/commands/permit/ls.d.ts +21 -0
- package/dist/commands/permit/ls.js +54 -0
- package/dist/commands/plugin/index.d.ts +23 -0
- package/dist/commands/plugin/index.js +174 -0
- package/dist/commands/plugin/scaffold.d.ts +6 -0
- package/dist/commands/plugin/scaffold.js +212 -0
- package/dist/commands/plugin/shared.d.ts +7 -0
- package/dist/commands/plugin/shared.js +34 -0
- package/dist/commands/plugin/update.d.ts +37 -0
- package/dist/commands/plugin/update.js +58 -0
- package/dist/commands/project/create.d.ts +10 -0
- package/dist/commands/project/create.js +43 -0
- package/dist/commands/project/delete.d.ts +9 -0
- package/dist/commands/project/delete.js +35 -0
- package/dist/commands/project/index.d.ts +3 -0
- package/dist/commands/project/index.js +28 -0
- package/dist/commands/project/ls.d.ts +5 -0
- package/dist/commands/project/ls.js +19 -0
- package/dist/commands/project/rename.d.ts +15 -0
- package/dist/commands/project/rename.js +52 -0
- package/dist/commands/project/shared.d.ts +11 -0
- package/dist/commands/project/shared.js +18 -0
- package/dist/commands/provider/diagnostic.d.ts +12 -0
- package/dist/commands/provider/diagnostic.js +31 -0
- package/dist/commands/provider/index.d.ts +3 -0
- package/dist/commands/provider/index.js +21 -0
- package/dist/commands/provider/ls.d.ts +19 -0
- package/dist/commands/provider/ls.js +46 -0
- package/dist/commands/provider/models.d.ts +20 -0
- package/dist/commands/provider/models.js +53 -0
- package/dist/commands/schedule/create.d.ts +19 -0
- package/dist/commands/schedule/create.js +41 -0
- package/dist/commands/schedule/delete.d.ts +10 -0
- package/dist/commands/schedule/delete.js +32 -0
- package/dist/commands/schedule/index.d.ts +3 -0
- package/dist/commands/schedule/index.js +66 -0
- package/dist/commands/schedule/inspect.d.ts +6 -0
- package/dist/commands/schedule/inspect.js +27 -0
- package/dist/commands/schedule/logs.d.ts +6 -0
- package/dist/commands/schedule/logs.js +24 -0
- package/dist/commands/schedule/ls.d.ts +5 -0
- package/dist/commands/schedule/ls.js +25 -0
- package/dist/commands/schedule/pause.d.ts +5 -0
- package/dist/commands/schedule/pause.js +24 -0
- package/dist/commands/schedule/resume.d.ts +5 -0
- package/dist/commands/schedule/resume.js +24 -0
- package/dist/commands/schedule/run-once.d.ts +5 -0
- package/dist/commands/schedule/run-once.js +24 -0
- package/dist/commands/schedule/schema.d.ts +21 -0
- package/dist/commands/schedule/schema.js +67 -0
- package/dist/commands/schedule/shared.d.ts +61 -0
- package/dist/commands/schedule/shared.js +360 -0
- package/dist/commands/schedule/types.d.ts +165 -0
- package/dist/commands/schedule/types.js +2 -0
- package/dist/commands/schedule/update.d.ts +19 -0
- package/dist/commands/schedule/update.js +40 -0
- package/dist/commands/script/index.d.ts +3 -0
- package/dist/commands/script/index.js +19 -0
- package/dist/commands/script/ls.d.ts +6 -0
- package/dist/commands/script/ls.js +20 -0
- package/dist/commands/script/schema.d.ts +5 -0
- package/dist/commands/script/schema.js +13 -0
- package/dist/commands/script/shared.d.ts +12 -0
- package/dist/commands/script/shared.js +59 -0
- package/dist/commands/script/start.d.ts +6 -0
- package/dist/commands/script/start.js +23 -0
- package/dist/commands/script/stop.d.ts +6 -0
- package/dist/commands/script/stop.js +23 -0
- package/dist/commands/terminal/capture.d.ts +10 -0
- package/dist/commands/terminal/capture.js +67 -0
- package/dist/commands/terminal/create.d.ts +11 -0
- package/dist/commands/terminal/create.js +29 -0
- package/dist/commands/terminal/index.d.ts +3 -0
- package/dist/commands/terminal/index.js +51 -0
- package/dist/commands/terminal/kill.d.ts +6 -0
- package/dist/commands/terminal/kill.js +36 -0
- package/dist/commands/terminal/ls.d.ts +11 -0
- package/dist/commands/terminal/ls.js +21 -0
- package/dist/commands/terminal/schema.d.ts +10 -0
- package/dist/commands/terminal/schema.js +17 -0
- package/dist/commands/terminal/send-keys.d.ts +7 -0
- package/dist/commands/terminal/send-keys.js +44 -0
- package/dist/commands/terminal/shared.d.ts +13 -0
- package/dist/commands/terminal/shared.js +64 -0
- package/dist/commands/terminal/upgrade-hosts.d.ts +11 -0
- package/dist/commands/terminal/upgrade-hosts.js +46 -0
- package/dist/commands/usage/index.d.ts +29 -0
- package/dist/commands/usage/index.js +62 -0
- package/dist/commands/usage/presentation.d.ts +4 -0
- package/dist/commands/usage/presentation.js +146 -0
- package/dist/commands/workspace/archive.d.ts +13 -0
- package/dist/commands/workspace/archive.js +43 -0
- package/dist/commands/workspace/create.d.ts +50 -0
- package/dist/commands/workspace/create.js +132 -0
- package/dist/commands/workspace/index.d.ts +3 -0
- package/dist/commands/workspace/index.js +50 -0
- package/dist/commands/workspace/ls.d.ts +11 -0
- package/dist/commands/workspace/ls.js +33 -0
- package/dist/commands/workspace/rename.d.ts +23 -0
- package/dist/commands/workspace/rename.js +63 -0
- package/dist/commands/workspace/setup.d.ts +12 -0
- package/dist/commands/workspace/setup.js +41 -0
- package/dist/commands/workspace/shared.d.ts +15 -0
- package/dist/commands/workspace/shared.js +29 -0
- package/dist/commands/worktree/archive.d.ts +21 -0
- package/dist/commands/worktree/archive.js +108 -0
- package/dist/commands/worktree/create-input.d.ts +15 -0
- package/dist/commands/worktree/create-input.js +56 -0
- package/dist/commands/worktree/create.d.ts +11 -0
- package/dist/commands/worktree/create.js +50 -0
- package/dist/commands/worktree/index.d.ts +3 -0
- package/dist/commands/worktree/index.js +29 -0
- package/dist/commands/worktree/ls.d.ts +18 -0
- package/dist/commands/worktree/ls.js +73 -0
- package/dist/commands/worktree/repository-directory.d.ts +6 -0
- package/dist/commands/worktree/repository-directory.js +9 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +6 -0
- package/dist/output/index.d.ts +45 -0
- package/dist/output/index.js +47 -0
- package/dist/output/json.d.ts +11 -0
- package/dist/output/json.js +37 -0
- package/dist/output/pairing.d.ts +9 -0
- package/dist/output/pairing.js +36 -0
- package/dist/output/quiet.d.ts +9 -0
- package/dist/output/quiet.js +22 -0
- package/dist/output/render.d.ts +15 -0
- package/dist/output/render.js +84 -0
- package/dist/output/table.d.ts +13 -0
- package/dist/output/table.js +135 -0
- package/dist/output/types.d.ts +73 -0
- package/dist/output/types.js +8 -0
- package/dist/output/with-output.d.ts +43 -0
- package/dist/output/with-output.js +85 -0
- package/dist/output/yaml.d.ts +11 -0
- package/dist/output/yaml.js +38 -0
- package/dist/run.d.ts +14 -0
- package/dist/run.js +62 -0
- package/dist/ssh/ssh-tunnel.d.ts +2 -0
- package/dist/ssh/ssh-tunnel.js +3 -0
- package/dist/utils/agent-directory.d.ts +31 -0
- package/dist/utils/agent-directory.js +48 -0
- package/dist/utils/caller-agent.d.ts +14 -0
- package/dist/utils/caller-agent.js +16 -0
- package/dist/utils/client-id.d.ts +2 -0
- package/dist/utils/client-id.js +31 -0
- package/dist/utils/client.d.ts +57 -0
- package/dist/utils/client.js +360 -0
- package/dist/utils/command-options.d.ts +8 -0
- package/dist/utils/command-options.js +49 -0
- package/dist/utils/daemon-target.d.ts +13 -0
- package/dist/utils/daemon-target.js +51 -0
- package/dist/utils/duration.d.ts +7 -0
- package/dist/utils/duration.js +39 -0
- package/dist/utils/errors.d.ts +5 -0
- package/dist/utils/errors.js +10 -0
- package/dist/utils/paths.d.ts +12 -0
- package/dist/utils/paths.js +22 -0
- package/dist/utils/provider-model.d.ts +11 -0
- package/dist/utils/provider-model.js +49 -0
- package/dist/utils/timeline.d.ts +12 -0
- package/dist/utils/timeline.js +16 -0
- package/dist/utils/wait-for-stop.d.ts +2 -0
- package/dist/utils/wait-for-stop.js +28 -0
- package/dist/version.d.ts +5 -0
- package/dist/version.js +24 -0
- package/package.json +58 -4
- package/README.md +0 -3
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { scheduleSchema } from "./schema.js";
|
|
2
|
+
import { connectScheduleClient, toScheduleCommandError, toScheduleRow, } from "./shared.js";
|
|
3
|
+
export async function runLsCommand(options, _command) {
|
|
4
|
+
const { client } = await connectScheduleClient(options.daemonTarget);
|
|
5
|
+
try {
|
|
6
|
+
const payload = await client.scheduleList();
|
|
7
|
+
if (payload.error) {
|
|
8
|
+
throw new Error(payload.error);
|
|
9
|
+
}
|
|
10
|
+
return {
|
|
11
|
+
type: "list",
|
|
12
|
+
data: payload.schedules
|
|
13
|
+
.filter((schedule) => schedule.target.type === "new-agent")
|
|
14
|
+
.map(toScheduleRow),
|
|
15
|
+
schema: scheduleSchema,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
throw toScheduleCommandError("SCHEDULE_LIST_FAILED", "list schedules", error);
|
|
20
|
+
}
|
|
21
|
+
finally {
|
|
22
|
+
await client.close().catch(() => { });
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=ls.js.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Command } from "commander";
|
|
2
|
+
import type { SingleResult } from "../../output/index.js";
|
|
3
|
+
import { type ScheduleCommandOptions, type ScheduleRow } from "./shared.js";
|
|
4
|
+
export declare function runPauseCommand(id: string, options: ScheduleCommandOptions, _command: Command): Promise<SingleResult<ScheduleRow>>;
|
|
5
|
+
//# sourceMappingURL=pause.d.ts.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { scheduleSchema } from "./schema.js";
|
|
2
|
+
import { connectScheduleClient, requireNewAgentSchedule, toScheduleCommandError, toScheduleRow, } from "./shared.js";
|
|
3
|
+
export async function runPauseCommand(id, options, _command) {
|
|
4
|
+
const { client } = await connectScheduleClient(options.daemonTarget);
|
|
5
|
+
try {
|
|
6
|
+
await requireNewAgentSchedule(client, id);
|
|
7
|
+
const payload = await client.schedulePause({ id });
|
|
8
|
+
if (payload.error || !payload.schedule) {
|
|
9
|
+
throw new Error(payload.error ?? `Failed to pause schedule: ${id}`);
|
|
10
|
+
}
|
|
11
|
+
return {
|
|
12
|
+
type: "single",
|
|
13
|
+
data: toScheduleRow(payload.schedule),
|
|
14
|
+
schema: scheduleSchema,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
catch (error) {
|
|
18
|
+
throw toScheduleCommandError("SCHEDULE_PAUSE_FAILED", "pause schedule", error);
|
|
19
|
+
}
|
|
20
|
+
finally {
|
|
21
|
+
await client.close().catch(() => { });
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=pause.js.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Command } from "commander";
|
|
2
|
+
import type { SingleResult } from "../../output/index.js";
|
|
3
|
+
import { type ScheduleCommandOptions, type ScheduleRow } from "./shared.js";
|
|
4
|
+
export declare function runResumeCommand(id: string, options: ScheduleCommandOptions, _command: Command): Promise<SingleResult<ScheduleRow>>;
|
|
5
|
+
//# sourceMappingURL=resume.d.ts.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { scheduleSchema } from "./schema.js";
|
|
2
|
+
import { connectScheduleClient, requireNewAgentSchedule, toScheduleCommandError, toScheduleRow, } from "./shared.js";
|
|
3
|
+
export async function runResumeCommand(id, options, _command) {
|
|
4
|
+
const { client } = await connectScheduleClient(options.daemonTarget);
|
|
5
|
+
try {
|
|
6
|
+
await requireNewAgentSchedule(client, id);
|
|
7
|
+
const payload = await client.scheduleResume({ id });
|
|
8
|
+
if (payload.error || !payload.schedule) {
|
|
9
|
+
throw new Error(payload.error ?? `Failed to resume schedule: ${id}`);
|
|
10
|
+
}
|
|
11
|
+
return {
|
|
12
|
+
type: "single",
|
|
13
|
+
data: toScheduleRow(payload.schedule),
|
|
14
|
+
schema: scheduleSchema,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
catch (error) {
|
|
18
|
+
throw toScheduleCommandError("SCHEDULE_RESUME_FAILED", "resume schedule", error);
|
|
19
|
+
}
|
|
20
|
+
finally {
|
|
21
|
+
await client.close().catch(() => { });
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=resume.js.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Command } from "commander";
|
|
2
|
+
import type { SingleResult } from "../../output/index.js";
|
|
3
|
+
import { type ScheduleCommandOptions, type ScheduleRow } from "./shared.js";
|
|
4
|
+
export declare function runRunOnceCommand(id: string, options: ScheduleCommandOptions, _command: Command): Promise<SingleResult<ScheduleRow>>;
|
|
5
|
+
//# sourceMappingURL=run-once.d.ts.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { scheduleSchema } from "./schema.js";
|
|
2
|
+
import { connectScheduleClient, requireNewAgentSchedule, toScheduleCommandError, toScheduleRow, } from "./shared.js";
|
|
3
|
+
export async function runRunOnceCommand(id, options, _command) {
|
|
4
|
+
const { client } = await connectScheduleClient(options.daemonTarget);
|
|
5
|
+
try {
|
|
6
|
+
await requireNewAgentSchedule(client, id);
|
|
7
|
+
const payload = await client.scheduleRunOnce({ id });
|
|
8
|
+
if (payload.error || !payload.schedule) {
|
|
9
|
+
throw new Error(payload.error ?? `Failed to run schedule once: ${id}`);
|
|
10
|
+
}
|
|
11
|
+
return {
|
|
12
|
+
type: "single",
|
|
13
|
+
data: toScheduleRow(payload.schedule),
|
|
14
|
+
schema: scheduleSchema,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
catch (error) {
|
|
18
|
+
throw toScheduleCommandError("SCHEDULE_RUN_ONCE_FAILED", "run schedule once", error);
|
|
19
|
+
}
|
|
20
|
+
finally {
|
|
21
|
+
await client.close().catch(() => { });
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=run-once.js.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { OutputSchema } from "../../output/index.js";
|
|
2
|
+
import { type ScheduleRow } from "./shared.js";
|
|
3
|
+
import type { ScheduleRecord, ScheduleRunRecord } from "./types.js";
|
|
4
|
+
export declare const scheduleSchema: OutputSchema<ScheduleRow>;
|
|
5
|
+
export interface ScheduleInspectRow {
|
|
6
|
+
key: string;
|
|
7
|
+
value: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function createScheduleInspectSchema(record: ScheduleRecord): OutputSchema<ScheduleInspectRow>;
|
|
10
|
+
export interface ScheduleLogRow {
|
|
11
|
+
id: string;
|
|
12
|
+
status: string;
|
|
13
|
+
startedAt: string;
|
|
14
|
+
agentId: string | null;
|
|
15
|
+
output: string | null;
|
|
16
|
+
error: string | null;
|
|
17
|
+
}
|
|
18
|
+
export declare const scheduleLogSchema: OutputSchema<ScheduleLogRow>;
|
|
19
|
+
export declare function toScheduleLogRow(run: ScheduleRunRecord): ScheduleLogRow;
|
|
20
|
+
export declare function createScheduleInspectRows(schedule: ScheduleRecord): ScheduleInspectRow[];
|
|
21
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { formatCadence, formatTarget } from "./shared.js";
|
|
2
|
+
export const scheduleSchema = {
|
|
3
|
+
idField: "id",
|
|
4
|
+
columns: [
|
|
5
|
+
{ header: "ID", field: "id", width: 10 },
|
|
6
|
+
{ header: "NAME", field: "name", width: 20 },
|
|
7
|
+
{ header: "CADENCE", field: "cadence", width: 20 },
|
|
8
|
+
{ header: "TARGET", field: "target", width: 20 },
|
|
9
|
+
{ header: "STATUS", field: "status", width: 12 },
|
|
10
|
+
{ header: "NEXT RUN", field: "nextRunAt", width: 24 },
|
|
11
|
+
],
|
|
12
|
+
};
|
|
13
|
+
export function createScheduleInspectSchema(record) {
|
|
14
|
+
return {
|
|
15
|
+
idField: "key",
|
|
16
|
+
columns: [
|
|
17
|
+
{ header: "KEY", field: "key", width: 18 },
|
|
18
|
+
{ header: "VALUE", field: "value", width: 80 },
|
|
19
|
+
],
|
|
20
|
+
serialize: () => record,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export const scheduleLogSchema = {
|
|
24
|
+
idField: "id",
|
|
25
|
+
columns: [
|
|
26
|
+
{ header: "RUN ID", field: "id", width: 14 },
|
|
27
|
+
{ header: "STATUS", field: "status", width: 12 },
|
|
28
|
+
{ header: "STARTED", field: "startedAt", width: 24 },
|
|
29
|
+
{ header: "AGENT", field: "agentId", width: 12 },
|
|
30
|
+
{ header: "OUTPUT", field: "output", width: 40 },
|
|
31
|
+
{ header: "ERROR", field: "error", width: 40 },
|
|
32
|
+
],
|
|
33
|
+
};
|
|
34
|
+
export function toScheduleLogRow(run) {
|
|
35
|
+
return {
|
|
36
|
+
id: run.id,
|
|
37
|
+
status: run.status,
|
|
38
|
+
startedAt: run.startedAt,
|
|
39
|
+
agentId: run.agentId ? run.agentId.slice(0, 7) : null,
|
|
40
|
+
output: run.output,
|
|
41
|
+
error: run.error,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
export function createScheduleInspectRows(schedule) {
|
|
45
|
+
return [
|
|
46
|
+
{ key: "Id", value: schedule.id },
|
|
47
|
+
{ key: "Name", value: schedule.name ?? "null" },
|
|
48
|
+
{ key: "Prompt", value: schedule.prompt },
|
|
49
|
+
{
|
|
50
|
+
key: "Cadence",
|
|
51
|
+
value: schedule.cadence.type === "cron"
|
|
52
|
+
? formatCadence(schedule.cadence)
|
|
53
|
+
: `every:${schedule.cadence.everyMs}ms`,
|
|
54
|
+
},
|
|
55
|
+
{ key: "Target", value: formatTarget(schedule.target) },
|
|
56
|
+
{ key: "Status", value: schedule.status },
|
|
57
|
+
{ key: "CreatedAt", value: schedule.createdAt },
|
|
58
|
+
{ key: "UpdatedAt", value: schedule.updatedAt },
|
|
59
|
+
{ key: "NextRunAt", value: schedule.nextRunAt ?? "null" },
|
|
60
|
+
{ key: "LastRunAt", value: schedule.lastRunAt ?? "null" },
|
|
61
|
+
{ key: "PausedAt", value: schedule.pausedAt ?? "null" },
|
|
62
|
+
{ key: "ExpiresAt", value: schedule.expiresAt ?? "null" },
|
|
63
|
+
{ key: "MaxRuns", value: schedule.maxRuns == null ? "null" : `${schedule.maxRuns}` },
|
|
64
|
+
{ key: "RunCount", value: `${schedule.runs.length}` },
|
|
65
|
+
];
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { DaemonTarget } from "../../utils/daemon-target.js";
|
|
2
|
+
import type { CommandError, CommandOptions } from "../../output/index.js";
|
|
3
|
+
import type { CreateScheduleInput, ScheduleCadence, ScheduleDaemonClient, ScheduleListItem, ScheduleRecord, ScheduleTarget, UpdateScheduleInput } from "./types.js";
|
|
4
|
+
export interface ScheduleCommandOptions extends CommandOptions {
|
|
5
|
+
host?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function connectScheduleClient(target: DaemonTarget): Promise<{
|
|
8
|
+
client: ScheduleDaemonClient;
|
|
9
|
+
host: string;
|
|
10
|
+
}>;
|
|
11
|
+
export declare function toScheduleCommandError(code: string, action: string, error: unknown): CommandError;
|
|
12
|
+
export declare function requireNewAgentSchedule(client: ScheduleDaemonClient, id: string): Promise<void>;
|
|
13
|
+
export declare function formatCadence(cadence: ScheduleCadence): string;
|
|
14
|
+
export declare function formatTarget(target: ScheduleTarget | ScheduleListItem["target"]): string;
|
|
15
|
+
export declare function formatDurationMs(durationMs: number): string;
|
|
16
|
+
export declare function parseScheduleCreateInput(options: {
|
|
17
|
+
prompt: string;
|
|
18
|
+
every?: string;
|
|
19
|
+
cron?: string;
|
|
20
|
+
timezone?: string;
|
|
21
|
+
name?: string;
|
|
22
|
+
target?: string;
|
|
23
|
+
provider?: string;
|
|
24
|
+
mode?: string;
|
|
25
|
+
thinking?: string;
|
|
26
|
+
cwd?: string;
|
|
27
|
+
host?: string;
|
|
28
|
+
daemonTarget: import("../../utils/daemon-target.js").DaemonTarget;
|
|
29
|
+
maxRuns?: string;
|
|
30
|
+
expiresIn?: string;
|
|
31
|
+
runNow?: boolean;
|
|
32
|
+
}): CreateScheduleInput;
|
|
33
|
+
export interface ScheduleUpdateOptionsInput {
|
|
34
|
+
id: string;
|
|
35
|
+
every?: string;
|
|
36
|
+
cron?: string;
|
|
37
|
+
timezone?: string;
|
|
38
|
+
name?: string;
|
|
39
|
+
prompt?: string;
|
|
40
|
+
provider?: string;
|
|
41
|
+
model?: string;
|
|
42
|
+
mode?: string;
|
|
43
|
+
cwd?: string;
|
|
44
|
+
maxRuns?: string;
|
|
45
|
+
expiresIn?: string;
|
|
46
|
+
clearMaxRuns?: boolean;
|
|
47
|
+
clearExpires?: boolean;
|
|
48
|
+
}
|
|
49
|
+
export declare function parseScheduleUpdateInput(options: ScheduleUpdateOptionsInput): UpdateScheduleInput;
|
|
50
|
+
export declare function compileEveryPresetToCron(value: string): string;
|
|
51
|
+
export interface ScheduleRow {
|
|
52
|
+
id: string;
|
|
53
|
+
name: string | null;
|
|
54
|
+
cadence: string;
|
|
55
|
+
target: string;
|
|
56
|
+
status: string;
|
|
57
|
+
nextRunAt: string | null;
|
|
58
|
+
lastRunAt: string | null;
|
|
59
|
+
}
|
|
60
|
+
export declare function toScheduleRow(schedule: ScheduleListItem | ScheduleRecord): ScheduleRow;
|
|
61
|
+
//# sourceMappingURL=shared.d.ts.map
|
|
@@ -0,0 +1,360 @@
|
|
|
1
|
+
import { connectToDaemon, getDaemonHost } from "../../utils/client.js";
|
|
2
|
+
import { parseDuration } from "../../utils/duration.js";
|
|
3
|
+
import { resolveProviderAndModel } from "../../utils/provider-model.js";
|
|
4
|
+
import { everyMsToFiveFieldCron } from "@getmateo/protocol/schedule/cadence";
|
|
5
|
+
export async function connectScheduleClient(target) {
|
|
6
|
+
const resolvedHost = getDaemonHost({ target });
|
|
7
|
+
try {
|
|
8
|
+
const client = (await connectToDaemon({
|
|
9
|
+
target,
|
|
10
|
+
}));
|
|
11
|
+
return { client, host: resolvedHost };
|
|
12
|
+
}
|
|
13
|
+
catch (error) {
|
|
14
|
+
if (error && typeof error === "object" && "code" in error)
|
|
15
|
+
throw error;
|
|
16
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
17
|
+
throw {
|
|
18
|
+
code: "DAEMON_NOT_RUNNING",
|
|
19
|
+
message: `Cannot connect to daemon at ${resolvedHost}: ${message}`,
|
|
20
|
+
details: "Start the daemon with: mateo daemon start",
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export function toScheduleCommandError(code, action, error) {
|
|
25
|
+
if (error && typeof error === "object" && "code" in error) {
|
|
26
|
+
return error;
|
|
27
|
+
}
|
|
28
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
29
|
+
return {
|
|
30
|
+
code,
|
|
31
|
+
message: `Failed to ${action}: ${message}`,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
export async function requireNewAgentSchedule(client, id) {
|
|
35
|
+
const payload = await client.scheduleInspect({ id });
|
|
36
|
+
if (payload.error || !payload.schedule || payload.schedule.target.type !== "new-agent") {
|
|
37
|
+
throw new Error(payload.error ?? `Schedule not found: ${id}`);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
export function formatCadence(cadence) {
|
|
41
|
+
if (cadence.type === "cron") {
|
|
42
|
+
const timezoneSuffix = cadence.timezone ? ` (${cadence.timezone})` : "";
|
|
43
|
+
return `cron:${cadence.expression}${timezoneSuffix}`;
|
|
44
|
+
}
|
|
45
|
+
return `every:${formatDurationMs(cadence.everyMs)}`;
|
|
46
|
+
}
|
|
47
|
+
export function formatTarget(target) {
|
|
48
|
+
if (target.type === "self") {
|
|
49
|
+
return `self:${target.agentId.slice(0, 7)}`;
|
|
50
|
+
}
|
|
51
|
+
if (target.type === "agent") {
|
|
52
|
+
return `agent:${target.agentId.slice(0, 7)}`;
|
|
53
|
+
}
|
|
54
|
+
const modelSuffix = target.config.model ? `/${target.config.model}` : "";
|
|
55
|
+
return `new-agent:${target.config.provider}${modelSuffix}`;
|
|
56
|
+
}
|
|
57
|
+
export function formatDurationMs(durationMs) {
|
|
58
|
+
const parts = [];
|
|
59
|
+
let remainingMs = durationMs;
|
|
60
|
+
const hours = Math.floor(remainingMs / (60 * 60 * 1000));
|
|
61
|
+
if (hours > 0) {
|
|
62
|
+
parts.push(`${hours}h`);
|
|
63
|
+
remainingMs -= hours * 60 * 60 * 1000;
|
|
64
|
+
}
|
|
65
|
+
const minutes = Math.floor(remainingMs / (60 * 1000));
|
|
66
|
+
if (minutes > 0) {
|
|
67
|
+
parts.push(`${minutes}m`);
|
|
68
|
+
remainingMs -= minutes * 60 * 1000;
|
|
69
|
+
}
|
|
70
|
+
const seconds = Math.floor(remainingMs / 1000);
|
|
71
|
+
if (seconds > 0 || parts.length === 0) {
|
|
72
|
+
parts.push(`${seconds}s`);
|
|
73
|
+
}
|
|
74
|
+
return parts.join("");
|
|
75
|
+
}
|
|
76
|
+
function resolveScheduleTarget(args) {
|
|
77
|
+
const { targetValue, hasExplicitNewAgentOption, createNewAgentTarget } = args;
|
|
78
|
+
if (!targetValue) {
|
|
79
|
+
return createNewAgentTarget();
|
|
80
|
+
}
|
|
81
|
+
if (targetValue === "new-agent") {
|
|
82
|
+
return createNewAgentTarget();
|
|
83
|
+
}
|
|
84
|
+
if (hasExplicitNewAgentOption) {
|
|
85
|
+
throw {
|
|
86
|
+
code: "INVALID_TARGET",
|
|
87
|
+
message: "--provider/--mode/--thinking can only be used with a new-agent target",
|
|
88
|
+
details: "Use --target new-agent or omit --target to create a new agent schedule",
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
if (targetValue === "self") {
|
|
92
|
+
// COMPAT(scheduleSelfTarget): heartbeat creation moved to `mateo heartbeat create`.
|
|
93
|
+
// Added in v0.2.0; remove after 2027-01-17.
|
|
94
|
+
const currentAgentId = process.env.MATEO_AGENT_ID?.trim();
|
|
95
|
+
if (!currentAgentId) {
|
|
96
|
+
throw {
|
|
97
|
+
code: "INVALID_TARGET",
|
|
98
|
+
message: "--target self requires running inside a Mateo agent",
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
return { type: "self", agentId: currentAgentId };
|
|
102
|
+
}
|
|
103
|
+
return { type: "agent", agentId: targetValue };
|
|
104
|
+
}
|
|
105
|
+
export function parseScheduleCreateInput(options) {
|
|
106
|
+
const prompt = options.prompt.trim();
|
|
107
|
+
if (!prompt) {
|
|
108
|
+
throw {
|
|
109
|
+
code: "INVALID_PROMPT",
|
|
110
|
+
message: "Schedule prompt cannot be empty",
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
const cadence = parseCadenceFromFlags(options.every, options.cron, options.timezone);
|
|
114
|
+
if (!cadence) {
|
|
115
|
+
throw {
|
|
116
|
+
code: "INVALID_CADENCE",
|
|
117
|
+
message: "Specify exactly one of --every or --cron",
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
const cwdInput = options.cwd?.trim();
|
|
121
|
+
if (options.daemonTarget.kind === "endpoint" && !cwdInput) {
|
|
122
|
+
throw {
|
|
123
|
+
code: "MISSING_CWD",
|
|
124
|
+
message: "--cwd is required when --host is specified (the local working directory will not exist on the remote daemon)",
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
const runOnCreate = resolveRunOnCreate(options.runNow, cadence.type);
|
|
128
|
+
const targetValue = options.target?.trim();
|
|
129
|
+
const modeId = options.mode?.trim();
|
|
130
|
+
const thinkingOptionId = options.thinking?.trim();
|
|
131
|
+
if (options.thinking !== undefined && !thinkingOptionId) {
|
|
132
|
+
throw {
|
|
133
|
+
code: "INVALID_THINKING_OPTION",
|
|
134
|
+
message: "--thinking cannot be empty",
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
const hasExplicitNewAgentOption = options.provider !== undefined || options.mode !== undefined || options.thinking !== undefined;
|
|
138
|
+
const createNewAgentTarget = () => {
|
|
139
|
+
const resolvedProviderModel = resolveProviderAndModel({
|
|
140
|
+
provider: options.provider,
|
|
141
|
+
});
|
|
142
|
+
return {
|
|
143
|
+
type: "new-agent",
|
|
144
|
+
config: {
|
|
145
|
+
provider: resolvedProviderModel.provider,
|
|
146
|
+
cwd: cwdInput ?? process.cwd(),
|
|
147
|
+
...(resolvedProviderModel.model ? { model: resolvedProviderModel.model } : {}),
|
|
148
|
+
...(modeId ? { modeId } : {}),
|
|
149
|
+
...(thinkingOptionId ? { thinkingOptionId } : {}),
|
|
150
|
+
},
|
|
151
|
+
};
|
|
152
|
+
};
|
|
153
|
+
const target = resolveScheduleTarget({
|
|
154
|
+
targetValue,
|
|
155
|
+
hasExplicitNewAgentOption,
|
|
156
|
+
createNewAgentTarget,
|
|
157
|
+
});
|
|
158
|
+
const maxRuns = options.maxRuns === undefined ? undefined : parsePositiveInt(options.maxRuns, "--max-runs");
|
|
159
|
+
const expiresAt = options.expiresIn === undefined
|
|
160
|
+
? undefined
|
|
161
|
+
: new Date(Date.now() + parseDuration(options.expiresIn)).toISOString();
|
|
162
|
+
return {
|
|
163
|
+
prompt,
|
|
164
|
+
cadence,
|
|
165
|
+
target,
|
|
166
|
+
runOnCreate,
|
|
167
|
+
...(options.name?.trim() ? { name: options.name.trim() } : {}),
|
|
168
|
+
...(maxRuns !== undefined ? { maxRuns } : {}),
|
|
169
|
+
...(expiresAt ? { expiresAt } : {}),
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
function resolveRunOnCreate(runNow, _cadenceType) {
|
|
173
|
+
return runNow ?? false;
|
|
174
|
+
}
|
|
175
|
+
export function parseScheduleUpdateInput(options) {
|
|
176
|
+
const id = options.id.trim();
|
|
177
|
+
if (!id) {
|
|
178
|
+
throw {
|
|
179
|
+
code: "INVALID_SCHEDULE_ID",
|
|
180
|
+
message: "Schedule id cannot be empty",
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
const cadence = parseCadenceFromFlags(options.every, options.cron, options.timezone);
|
|
184
|
+
const newAgentConfig = buildNewAgentConfigPatch(options);
|
|
185
|
+
const maxRuns = parseUpdateMaxRuns(options);
|
|
186
|
+
const expiresAt = parseUpdateExpiresAt(options);
|
|
187
|
+
const name = parseUpdateName(options);
|
|
188
|
+
const prompt = parseUpdatePrompt(options);
|
|
189
|
+
if (name === undefined &&
|
|
190
|
+
prompt === undefined &&
|
|
191
|
+
cadence === undefined &&
|
|
192
|
+
newAgentConfig === undefined &&
|
|
193
|
+
maxRuns === undefined &&
|
|
194
|
+
expiresAt === undefined) {
|
|
195
|
+
throw {
|
|
196
|
+
code: "NO_UPDATES",
|
|
197
|
+
message: "Specify at least one field to update",
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
return {
|
|
201
|
+
id,
|
|
202
|
+
...(name !== undefined ? { name } : {}),
|
|
203
|
+
...(prompt !== undefined ? { prompt } : {}),
|
|
204
|
+
...(cadence !== undefined ? { cadence } : {}),
|
|
205
|
+
...(newAgentConfig !== undefined ? { newAgentConfig } : {}),
|
|
206
|
+
...(maxRuns !== undefined ? { maxRuns } : {}),
|
|
207
|
+
...(expiresAt !== undefined ? { expiresAt } : {}),
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
function parseCadenceFromFlags(every, cron, timezone) {
|
|
211
|
+
if (every !== undefined && cron !== undefined) {
|
|
212
|
+
throw {
|
|
213
|
+
code: "INVALID_CADENCE",
|
|
214
|
+
message: "Specify at most one of --every or --cron",
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
const trimmedTimeZone = parseTimeZoneFlag(timezone);
|
|
218
|
+
if (trimmedTimeZone !== undefined && cron === undefined) {
|
|
219
|
+
throw {
|
|
220
|
+
code: "INVALID_TIME_ZONE",
|
|
221
|
+
message: "--timezone can only be used with --cron",
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
if (every !== undefined) {
|
|
225
|
+
return { type: "cron", expression: compileEveryPresetToCron(every) };
|
|
226
|
+
}
|
|
227
|
+
if (cron !== undefined) {
|
|
228
|
+
return {
|
|
229
|
+
type: "cron",
|
|
230
|
+
expression: cron.trim(),
|
|
231
|
+
...(trimmedTimeZone ? { timezone: trimmedTimeZone } : {}),
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
return undefined;
|
|
235
|
+
}
|
|
236
|
+
export function compileEveryPresetToCron(value) {
|
|
237
|
+
const durationMs = parseDuration(value);
|
|
238
|
+
const cron = everyMsToFiveFieldCron(durationMs);
|
|
239
|
+
if (cron) {
|
|
240
|
+
return cron;
|
|
241
|
+
}
|
|
242
|
+
throw {
|
|
243
|
+
code: "UNREPRESENTABLE_CADENCE",
|
|
244
|
+
message: `${value} cannot be represented faithfully by five-field cron`,
|
|
245
|
+
details: "Use --cron for calendar schedules",
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
function parseTimeZoneFlag(timeZone) {
|
|
249
|
+
if (timeZone === undefined) {
|
|
250
|
+
return undefined;
|
|
251
|
+
}
|
|
252
|
+
const trimmed = timeZone.trim();
|
|
253
|
+
if (!trimmed) {
|
|
254
|
+
throw {
|
|
255
|
+
code: "INVALID_TIME_ZONE",
|
|
256
|
+
message: "--timezone cannot be empty",
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
return trimmed;
|
|
260
|
+
}
|
|
261
|
+
function parseUpdateMaxRuns(options) {
|
|
262
|
+
if (options.maxRuns !== undefined && options.clearMaxRuns) {
|
|
263
|
+
throw {
|
|
264
|
+
code: "CONFLICTING_MAX_RUNS",
|
|
265
|
+
message: "Use either --max-runs <n> or --no-max-runs, not both",
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
if (options.clearMaxRuns) {
|
|
269
|
+
return null;
|
|
270
|
+
}
|
|
271
|
+
if (options.maxRuns !== undefined) {
|
|
272
|
+
return parsePositiveInt(options.maxRuns, "--max-runs");
|
|
273
|
+
}
|
|
274
|
+
return undefined;
|
|
275
|
+
}
|
|
276
|
+
function parseUpdateExpiresAt(options) {
|
|
277
|
+
if (options.expiresIn !== undefined && options.clearExpires) {
|
|
278
|
+
throw {
|
|
279
|
+
code: "CONFLICTING_EXPIRES",
|
|
280
|
+
message: "Use either --expires-in <duration> or --no-expires-in, not both",
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
if (options.clearExpires) {
|
|
284
|
+
return null;
|
|
285
|
+
}
|
|
286
|
+
if (options.expiresIn !== undefined) {
|
|
287
|
+
return new Date(Date.now() + parseDuration(options.expiresIn)).toISOString();
|
|
288
|
+
}
|
|
289
|
+
return undefined;
|
|
290
|
+
}
|
|
291
|
+
function parseUpdateName(options) {
|
|
292
|
+
if (options.name === undefined) {
|
|
293
|
+
return undefined;
|
|
294
|
+
}
|
|
295
|
+
const trimmed = options.name.trim();
|
|
296
|
+
return trimmed.length > 0 ? trimmed : null;
|
|
297
|
+
}
|
|
298
|
+
function parseUpdatePrompt(options) {
|
|
299
|
+
if (options.prompt === undefined) {
|
|
300
|
+
return undefined;
|
|
301
|
+
}
|
|
302
|
+
const trimmed = options.prompt.trim();
|
|
303
|
+
if (!trimmed) {
|
|
304
|
+
throw {
|
|
305
|
+
code: "INVALID_PROMPT",
|
|
306
|
+
message: "--prompt cannot be empty",
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
return trimmed;
|
|
310
|
+
}
|
|
311
|
+
function buildNewAgentConfigPatch(options) {
|
|
312
|
+
const patch = {};
|
|
313
|
+
if (options.provider !== undefined || options.model !== undefined) {
|
|
314
|
+
const resolved = resolveProviderAndModel({
|
|
315
|
+
provider: options.provider,
|
|
316
|
+
model: options.model,
|
|
317
|
+
});
|
|
318
|
+
patch.provider = resolved.provider;
|
|
319
|
+
if (resolved.model !== undefined) {
|
|
320
|
+
patch.model = resolved.model;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
if (options.mode !== undefined) {
|
|
324
|
+
const trimmed = options.mode.trim();
|
|
325
|
+
patch.modeId = trimmed.length > 0 ? trimmed : null;
|
|
326
|
+
}
|
|
327
|
+
if (options.cwd !== undefined) {
|
|
328
|
+
const trimmed = options.cwd.trim();
|
|
329
|
+
if (!trimmed) {
|
|
330
|
+
throw {
|
|
331
|
+
code: "INVALID_CWD",
|
|
332
|
+
message: "--cwd cannot be empty",
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
patch.cwd = trimmed;
|
|
336
|
+
}
|
|
337
|
+
return Object.keys(patch).length > 0 ? patch : undefined;
|
|
338
|
+
}
|
|
339
|
+
function parsePositiveInt(value, flag) {
|
|
340
|
+
const parsed = Number.parseInt(value, 10);
|
|
341
|
+
if (!Number.isInteger(parsed) || parsed <= 0) {
|
|
342
|
+
throw {
|
|
343
|
+
code: "INVALID_INTEGER",
|
|
344
|
+
message: `${flag} must be a positive integer`,
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
return parsed;
|
|
348
|
+
}
|
|
349
|
+
export function toScheduleRow(schedule) {
|
|
350
|
+
return {
|
|
351
|
+
id: schedule.id,
|
|
352
|
+
name: schedule.name,
|
|
353
|
+
cadence: formatCadence(schedule.cadence),
|
|
354
|
+
target: formatTarget(schedule.target),
|
|
355
|
+
status: schedule.status,
|
|
356
|
+
nextRunAt: schedule.nextRunAt,
|
|
357
|
+
lastRunAt: schedule.lastRunAt,
|
|
358
|
+
};
|
|
359
|
+
}
|
|
360
|
+
//# sourceMappingURL=shared.js.map
|