@keystrokehq/cli 0.0.155 → 0.0.156
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.mjs +80 -55
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -3605,11 +3605,38 @@ function createOrganizationsResource(http, options = {}) {
|
|
|
3605
3605
|
}
|
|
3606
3606
|
};
|
|
3607
3607
|
}
|
|
3608
|
+
function listSearchParams(options) {
|
|
3609
|
+
const params = {};
|
|
3610
|
+
const projectId = options?.projectId?.trim();
|
|
3611
|
+
if (projectId) params.projectId = projectId;
|
|
3612
|
+
if (options?.admin) params.admin = "true";
|
|
3613
|
+
return Object.keys(params).length > 0 ? params : void 0;
|
|
3614
|
+
}
|
|
3615
|
+
function createAgentsResource(http) {
|
|
3616
|
+
return {
|
|
3617
|
+
async list(options) {
|
|
3618
|
+
try {
|
|
3619
|
+
const data = await http.get("/api/agents", { searchParams: listSearchParams(options) }).json();
|
|
3620
|
+
return AgentSummaryListResponseSchema.parse(data);
|
|
3621
|
+
} catch (error) {
|
|
3622
|
+
throw await toPlatformError(error);
|
|
3623
|
+
}
|
|
3624
|
+
},
|
|
3625
|
+
async get(agentId) {
|
|
3626
|
+
try {
|
|
3627
|
+
const data = await http.get(`/api/agents/${encodeURIComponent(agentId)}`).json();
|
|
3628
|
+
return AgentSummaryDetailResponseSchema.parse(data);
|
|
3629
|
+
} catch (error) {
|
|
3630
|
+
throw await toPlatformError(error);
|
|
3631
|
+
}
|
|
3632
|
+
}
|
|
3633
|
+
};
|
|
3634
|
+
}
|
|
3608
3635
|
function createProjectsResource(http) {
|
|
3609
3636
|
return {
|
|
3610
|
-
async list() {
|
|
3637
|
+
async list(options) {
|
|
3611
3638
|
try {
|
|
3612
|
-
const data = await http.get("/api/projects").json();
|
|
3639
|
+
const data = await http.get("/api/projects", { searchParams: listSearchParams(options) }).json();
|
|
3613
3640
|
return ListProjectsResponseSchema.parse(data).projects;
|
|
3614
3641
|
} catch (error) {
|
|
3615
3642
|
throw await toPlatformError(error);
|
|
@@ -3669,48 +3696,20 @@ function createProjectsResource(http) {
|
|
|
3669
3696
|
};
|
|
3670
3697
|
}
|
|
3671
3698
|
function createProjectMetricsResource(http) {
|
|
3672
|
-
return { async list() {
|
|
3699
|
+
return { async list(options) {
|
|
3673
3700
|
try {
|
|
3674
|
-
const data = await http.get("/api/projects/metrics").json();
|
|
3701
|
+
const data = await http.get("/api/projects/metrics", { searchParams: listSearchParams(options) }).json();
|
|
3675
3702
|
return ListProjectMetricsResponseSchema.parse(data).metrics;
|
|
3676
3703
|
} catch (error) {
|
|
3677
3704
|
throw await toPlatformError(error);
|
|
3678
3705
|
}
|
|
3679
3706
|
} };
|
|
3680
3707
|
}
|
|
3681
|
-
function listSearchParams$2(options) {
|
|
3682
|
-
const projectId = options?.projectId?.trim();
|
|
3683
|
-
return projectId ? { projectId } : void 0;
|
|
3684
|
-
}
|
|
3685
|
-
function createAgentsResource(http) {
|
|
3686
|
-
return {
|
|
3687
|
-
async list(options) {
|
|
3688
|
-
try {
|
|
3689
|
-
const data = await http.get("/api/agents", { searchParams: listSearchParams$2(options) }).json();
|
|
3690
|
-
return AgentSummaryListResponseSchema.parse(data);
|
|
3691
|
-
} catch (error) {
|
|
3692
|
-
throw await toPlatformError(error);
|
|
3693
|
-
}
|
|
3694
|
-
},
|
|
3695
|
-
async get(agentId) {
|
|
3696
|
-
try {
|
|
3697
|
-
const data = await http.get(`/api/agents/${encodeURIComponent(agentId)}`).json();
|
|
3698
|
-
return AgentSummaryDetailResponseSchema.parse(data);
|
|
3699
|
-
} catch (error) {
|
|
3700
|
-
throw await toPlatformError(error);
|
|
3701
|
-
}
|
|
3702
|
-
}
|
|
3703
|
-
};
|
|
3704
|
-
}
|
|
3705
|
-
function listSearchParams$1(options) {
|
|
3706
|
-
const projectId = options?.projectId?.trim();
|
|
3707
|
-
return projectId ? { projectId } : void 0;
|
|
3708
|
-
}
|
|
3709
3708
|
function createWorkflowsResource(http) {
|
|
3710
3709
|
return {
|
|
3711
3710
|
async list(options) {
|
|
3712
3711
|
try {
|
|
3713
|
-
const data = await http.get("/api/workflows", { searchParams: listSearchParams
|
|
3712
|
+
const data = await http.get("/api/workflows", { searchParams: listSearchParams(options) }).json();
|
|
3714
3713
|
return WorkflowSummaryListResponseSchema.parse(data);
|
|
3715
3714
|
} catch (error) {
|
|
3716
3715
|
throw await toPlatformError(error);
|
|
@@ -3726,10 +3725,6 @@ function createWorkflowsResource(http) {
|
|
|
3726
3725
|
}
|
|
3727
3726
|
};
|
|
3728
3727
|
}
|
|
3729
|
-
function listSearchParams(options) {
|
|
3730
|
-
const projectId = options?.projectId?.trim();
|
|
3731
|
-
return projectId ? { projectId } : void 0;
|
|
3732
|
-
}
|
|
3733
3728
|
function createSkillsResource(http) {
|
|
3734
3729
|
return {
|
|
3735
3730
|
async list(options) {
|
|
@@ -3761,7 +3756,9 @@ function createTeamRequestsResource(http) {
|
|
|
3761
3756
|
} };
|
|
3762
3757
|
}
|
|
3763
3758
|
function createRecentsResource(http) {
|
|
3764
|
-
return {
|
|
3759
|
+
return {
|
|
3760
|
+
/** Always the viewer's own recents, scoped to their project memberships. */
|
|
3761
|
+
async list() {
|
|
3765
3762
|
try {
|
|
3766
3763
|
const data = await http.get("/api/recents").json();
|
|
3767
3764
|
return RecentResourceListResponseSchema.parse(data);
|
|
@@ -4010,11 +4007,13 @@ function createHistoryResource(http) {
|
|
|
4010
4007
|
/** Runs across projects the current user can access in the active org. */
|
|
4011
4008
|
async list(filters) {
|
|
4012
4009
|
try {
|
|
4013
|
-
const
|
|
4010
|
+
const { admin, ...queryFilters } = filters ?? {};
|
|
4011
|
+
const parsedFilters = Object.keys(queryFilters).length ? HistoryRunListQuerySchema.parse(queryFilters) : void 0;
|
|
4014
4012
|
const searchParams = new URLSearchParams();
|
|
4015
4013
|
if (parsedFilters?.project) searchParams.set("project", parsedFilters.project);
|
|
4016
4014
|
if (parsedFilters?.status) searchParams.set("status", parsedFilters.status);
|
|
4017
4015
|
if (parsedFilters?.kind) searchParams.set("kind", parsedFilters.kind);
|
|
4016
|
+
if (admin) searchParams.set("admin", "true");
|
|
4018
4017
|
const query = searchParams.toString();
|
|
4019
4018
|
const data = await http.get(query ? `api/history?${query}` : "api/history").json();
|
|
4020
4019
|
return HistoryRunListResponseSchema.parse(data);
|
|
@@ -4677,6 +4676,13 @@ function parseJsonOption(value, flag) {
|
|
|
4677
4676
|
}
|
|
4678
4677
|
}
|
|
4679
4678
|
//#endregion
|
|
4679
|
+
//#region src/organization/require-admin-role.ts
|
|
4680
|
+
async function requireAdminRole(config) {
|
|
4681
|
+
await ensureActiveOrganization(config);
|
|
4682
|
+
const active = await createCliPlatformClient(config).organizations.getActive();
|
|
4683
|
+
if (!active || active.role !== "owner" && active.role !== "admin") throw new Error("--admin requires org owner or admin");
|
|
4684
|
+
}
|
|
4685
|
+
//#endregion
|
|
4680
4686
|
//#region src/resolve-project-target.ts
|
|
4681
4687
|
async function resolveActiveProject(config, platform) {
|
|
4682
4688
|
const ref = getCliTargetOptions().projectId ?? config.get("activeProjectId");
|
|
@@ -4691,12 +4697,16 @@ async function resolveActiveProjectId(config) {
|
|
|
4691
4697
|
//#endregion
|
|
4692
4698
|
//#region src/commands/agent/list.ts
|
|
4693
4699
|
function registerAgentListCommand(agent) {
|
|
4694
|
-
agent.command("list").description("List agents in the active organization").action(() => runCliCommand("List agents failed", async () => {
|
|
4700
|
+
agent.command("list").description("List agents in the active organization").option("--admin", "List all org resources (org owner or admin only)").action((options) => runCliCommand("List agents failed", async () => {
|
|
4695
4701
|
const config = createCliConfig();
|
|
4696
4702
|
const client = createCliPlatformClient(config);
|
|
4697
4703
|
await ensureActiveOrganization(config);
|
|
4704
|
+
if (options.admin) await requireAdminRole(config);
|
|
4698
4705
|
const projectId = await resolveActiveProjectId(config);
|
|
4699
|
-
const result = await client.agents.list(
|
|
4706
|
+
const result = await client.agents.list({
|
|
4707
|
+
...projectId ? { projectId } : {},
|
|
4708
|
+
...options.admin ? { admin: true } : {}
|
|
4709
|
+
});
|
|
4700
4710
|
process.stdout.write(`${JSON.stringify(result, null, 2)}\n`);
|
|
4701
4711
|
}, void 0, { orgScoped: true }));
|
|
4702
4712
|
}
|
|
@@ -4753,9 +4763,10 @@ function writeInactiveDeployHints(projects) {
|
|
|
4753
4763
|
process.stderr.write(`Project ${formatProjectLabel(project)} is inactive. Deploy with: ${bin} deploy --project ${formatProjectLabel(project)}\n`);
|
|
4754
4764
|
}
|
|
4755
4765
|
}
|
|
4756
|
-
async function runProjectList(config) {
|
|
4766
|
+
async function runProjectList(config, options = {}) {
|
|
4767
|
+
if (options.admin) await requireAdminRole(config);
|
|
4757
4768
|
await withActivePlatformClient(config, async (platform) => {
|
|
4758
|
-
const projects = await platform.projects.list();
|
|
4769
|
+
const projects = await platform.projects.list(options.admin ? { admin: true } : void 0);
|
|
4759
4770
|
process.stdout.write(`${JSON.stringify({ projects }, null, 2)}\n`);
|
|
4760
4771
|
if (projects.length === 0) {
|
|
4761
4772
|
const bin = cliBinaryName();
|
|
@@ -4765,9 +4776,10 @@ async function runProjectList(config) {
|
|
|
4765
4776
|
writeInactiveDeployHints(projects);
|
|
4766
4777
|
});
|
|
4767
4778
|
}
|
|
4768
|
-
async function runProjectMetrics(config, options) {
|
|
4779
|
+
async function runProjectMetrics(config, options = {}) {
|
|
4780
|
+
if (options.admin) await requireAdminRole(config);
|
|
4769
4781
|
await withActivePlatformClient(config, async (platform) => {
|
|
4770
|
-
const metrics = await platform.projectMetrics.list();
|
|
4782
|
+
const metrics = await platform.projectMetrics.list(options.admin ? { admin: true } : void 0);
|
|
4771
4783
|
if (options.projectRef === void 0) {
|
|
4772
4784
|
process.stdout.write(`${JSON.stringify(metrics, null, 2)}\n`);
|
|
4773
4785
|
return;
|
|
@@ -5895,6 +5907,7 @@ function registerDevCommand(program) {
|
|
|
5895
5907
|
//#endregion
|
|
5896
5908
|
//#region src/commands/history/run-history.ts
|
|
5897
5909
|
async function runHistoryList(config, filters) {
|
|
5910
|
+
if (filters?.admin) await requireAdminRole(config);
|
|
5898
5911
|
await withActivePlatformClient(config, async (platform) => {
|
|
5899
5912
|
const runs = await platform.history.list(filters);
|
|
5900
5913
|
process.stdout.write(`${JSON.stringify(runs, null, 2)}\n`);
|
|
@@ -5916,13 +5929,14 @@ async function runHistoryCancel(config, runId) {
|
|
|
5916
5929
|
//#region src/commands/history/index.ts
|
|
5917
5930
|
function registerHistoryCommand(program) {
|
|
5918
5931
|
const history = program.command("history").description("List, inspect, and cancel platform run history");
|
|
5919
|
-
history.command("list").description("List runs across projects in the active organization").option("--project <id>", "Filter by project id").option("--status <status>", "Filter by status (pending, running, sleeping, waiting_hook, completed, failed, canceled)").option("--kind <kind>", "Filter by kind (workflow or agent)").action(async (options) => {
|
|
5932
|
+
history.command("list").description("List runs across projects in the active organization").option("--project <id>", "Filter by project id").option("--status <status>", "Filter by status (pending, running, sleeping, waiting_hook, completed, failed, canceled)").option("--kind <kind>", "Filter by kind (workflow or agent)").option("--admin", "List all org resources (org owner or admin only)").action(async (options) => {
|
|
5920
5933
|
const config = createCliConfig();
|
|
5921
5934
|
try {
|
|
5922
5935
|
await runHistoryList(config, {
|
|
5923
5936
|
...options.project ? { project: options.project } : {},
|
|
5924
5937
|
...options.status ? { status: options.status } : {},
|
|
5925
|
-
...options.kind ? { kind: options.kind } : {}
|
|
5938
|
+
...options.kind ? { kind: options.kind } : {},
|
|
5939
|
+
...options.admin ? { admin: true } : {}
|
|
5926
5940
|
});
|
|
5927
5941
|
} catch (error) {
|
|
5928
5942
|
process.stderr.write(`${formatCliError(error, "List history failed", {
|
|
@@ -6603,10 +6617,10 @@ function registerProjectSettingsCommand(project) {
|
|
|
6603
6617
|
//#region src/commands/project/index.ts
|
|
6604
6618
|
function registerProjectCommand(program) {
|
|
6605
6619
|
const project = program.command("project").description("List, create, update, and delete platform projects");
|
|
6606
|
-
project.command("list").description("List projects in the active organization").action(async () => {
|
|
6620
|
+
project.command("list").description("List projects in the active organization").option("--admin", "List all org resources (org owner or admin only)").action(async (options) => {
|
|
6607
6621
|
const config = createCliConfig();
|
|
6608
6622
|
try {
|
|
6609
|
-
await runProjectList(config);
|
|
6623
|
+
await runProjectList(config, { ...options.admin ? { admin: true } : {} });
|
|
6610
6624
|
} catch (error) {
|
|
6611
6625
|
process.stderr.write(`${formatCliError(error, "List projects failed", {
|
|
6612
6626
|
serverUrl: getPlatformUrl(config),
|
|
@@ -6615,10 +6629,13 @@ function registerProjectCommand(program) {
|
|
|
6615
6629
|
process.exitCode = 1;
|
|
6616
6630
|
}
|
|
6617
6631
|
});
|
|
6618
|
-
project.command("metrics").description("List rollup metrics for projects in the active organization").option("--project <slug>", "Return metrics for a single project").action(async (options) => {
|
|
6632
|
+
project.command("metrics").description("List rollup metrics for projects in the active organization").option("--project <slug>", "Return metrics for a single project").option("--admin", "List all org resources (org owner or admin only)").action(async (options) => {
|
|
6619
6633
|
const config = createCliConfig();
|
|
6620
6634
|
try {
|
|
6621
|
-
await runProjectMetrics(config,
|
|
6635
|
+
await runProjectMetrics(config, {
|
|
6636
|
+
...options.project ? { projectRef: options.project } : {},
|
|
6637
|
+
...options.admin ? { admin: true } : {}
|
|
6638
|
+
});
|
|
6622
6639
|
} catch (error) {
|
|
6623
6640
|
process.stderr.write(`${formatCliError(error, "List project metrics failed", {
|
|
6624
6641
|
serverUrl: getPlatformUrl(config),
|
|
@@ -6801,12 +6818,16 @@ function registerTriggerCommand(program) {
|
|
|
6801
6818
|
//#endregion
|
|
6802
6819
|
//#region src/commands/workflow/list.ts
|
|
6803
6820
|
function registerWorkflowListCommand(workflow) {
|
|
6804
|
-
workflow.command("list").description("List workflows in the active organization").action(() => runCliCommand("List workflows failed", async () => {
|
|
6821
|
+
workflow.command("list").description("List workflows in the active organization").option("--admin", "List all org resources (org owner or admin only)").action((options) => runCliCommand("List workflows failed", async () => {
|
|
6805
6822
|
const config = createCliConfig();
|
|
6806
6823
|
const client = createCliPlatformClient(config);
|
|
6807
6824
|
await ensureActiveOrganization(config);
|
|
6825
|
+
if (options.admin) await requireAdminRole(config);
|
|
6808
6826
|
const projectId = await resolveActiveProjectId(config);
|
|
6809
|
-
const result = await client.workflows.list(
|
|
6827
|
+
const result = await client.workflows.list({
|
|
6828
|
+
...projectId ? { projectId } : {},
|
|
6829
|
+
...options.admin ? { admin: true } : {}
|
|
6830
|
+
});
|
|
6810
6831
|
process.stdout.write(`${JSON.stringify(result, null, 2)}\n`);
|
|
6811
6832
|
}, void 0, { orgScoped: true }));
|
|
6812
6833
|
}
|
|
@@ -7109,12 +7130,16 @@ function registerConfigCommand(program) {
|
|
|
7109
7130
|
//#endregion
|
|
7110
7131
|
//#region src/commands/skill/index.ts
|
|
7111
7132
|
function registerSkillCommand(program) {
|
|
7112
|
-
program.command("skill").description("Inspect platform skills").command("list").description("List skills in the active organization").action(() => runCliCommand("List skills failed", async () => {
|
|
7133
|
+
program.command("skill").description("Inspect platform skills").command("list").description("List skills in the active organization").option("--admin", "List all org resources (org owner or admin only)").action((options) => runCliCommand("List skills failed", async () => {
|
|
7113
7134
|
const config = createCliConfig();
|
|
7114
7135
|
const client = createCliPlatformClient(config);
|
|
7115
7136
|
await ensureActiveOrganization(config);
|
|
7137
|
+
if (options.admin) await requireAdminRole(config);
|
|
7116
7138
|
const projectId = await resolveActiveProjectId(config);
|
|
7117
|
-
const result = await client.skills.list(
|
|
7139
|
+
const result = await client.skills.list({
|
|
7140
|
+
...projectId ? { projectId } : {},
|
|
7141
|
+
...options.admin ? { admin: true } : {}
|
|
7142
|
+
});
|
|
7118
7143
|
process.stdout.write(`${JSON.stringify(result, null, 2)}\n`);
|
|
7119
7144
|
}, void 0, { orgScoped: true }));
|
|
7120
7145
|
}
|