@keystrokehq/cli 0.0.153 → 0.0.155

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 CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { $ as OrganizationSidebarBrandingPatchSchema, A as ErrorResponseSchema, At as UpdateCredentialRequestSchema, B as InviteProjectMembersRequestSchema, Bt as UpsertGatewayAttachmentBodySchema, C as CreateOrganizationResponseSchema, Ct as StartOAuthConnectionResultSchema, D as CredentialInstanceListResponseSchema, Dt as TriggerRunListResponseSchema, E as CreateProjectResponseSchema, Et as TriggerRunDetailResponseSchema, F as HistoryRunDetailResponseSchema, Ft as UpdateProjectMemberResponseSchema, G as ListOrganizationInvitationsResponseSchema, Gt as WorkflowRunDetailResponseSchema, H as ListApiKeysResponseSchema, Ht as UserAvatarSchema, I as HistoryRunListQuerySchema, It as UpdateProjectRequestSchema, J as ListProjectDeploymentsResponseSchema, Jt as WorkflowSummaryListResponseSchema, K as ListOrganizationMembersResponseSchema, Kt as WorkflowRunListResponseSchema, L as HistoryRunListResponseSchema, Lt as UpdateProjectSettingsRequestSchema, M as GetCredentialResponseSchema, Mt as UpdateOrganizationMemberResponseSchema, N as HealthResponseSchema, Nt as UpdateOrganizationRequestSchema, O as CredentialInstanceRecordSchema, Ot as UpdateChannelBindingBodySchema, P as HistoryRunCancelResponseSchema, Pt as UpdateProjectMemberRequestSchema, Q as ListProjectsResponseSchema, Qt as parseErrorResponse, R as InviteOrganizationMembersRequestSchema, Rt as UploadProjectSourceManifestRequestSchema, S as CreateOrganizationRequestSchema, St as StartOAuthConnectionInputSchema, T as CreateProjectRequestSchema, Tt as TriggerListResponseSchema, U as ListAppsResponseSchema, Ut as UserPreferencesPatchSchema, V as InviteProjectMembersResponseSchema, Vt as UserAvatarPatchSchema, W as ListCredentialsResponseSchema, Wt as UserPreferencesSchema, X as ListProjectMembersResponseSchema, Y as ListProjectFilesResponseSchema, Yt as listenPortFromPublicUrl, Z as ListProjectMetricsResponseSchema, Zt as originFromPublicUrl, _ as CreateApiKeyRequestSchema, _t as ROUTE_MANIFEST_REL_PATH, a as AgentSessionListResponseSchema, at as PresignProjectSourceRequestSchema, b as CreateCredentialsRequestSchema, bt as SkillSummaryListResponseSchema, c as BindChannelBodySchema, ct as PresignUserAvatarResponseSchema, d as ChannelConnectionSchema, dt as ProjectSettingsResponseSchema, et as OrganizationSidebarBrandingSchema, f as ChannelDirectoryListResponseSchema, ft as ProjectSlugAvailabilityResponseSchema, g as ConnectProvidersResponseSchema, gt as QueuedRunResponseSchema, h as ConnectAuthorizeUrlResponseSchema, ht as QueuedAgentPromptResponseSchema, i as AgentSessionDetailResponseSchema, it as PresignOrgLogoResponseSchema, j as GatewayAttachmentRecordSchema, jt as UpdateOrganizationMemberRequestSchema, k as DeclineOrganizationInvitationResponseSchema, kt as UpdateCredentialInstanceBodySchema, l as ChannelAccountListResponseSchema, lt as ProjectReachabilityResponseSchema, m as CompleteProjectArtifactResponseSchema, mt as PromptResponseSchema, n as AcceptOrganizationInvitationResponseSchema, nt as PollRunResponseSchema, o as AgentSummaryDetailResponseSchema, ot as PresignProjectSourceResponseSchema, p as ChannelPlatformSchema, pt as PromptInputSchema, q as ListOrganizationsResponseSchema, qt as WorkflowSummaryDetailResponseSchema, r as ActiveOrganizationResponseSchema, rt as PresignOrgLogoRequestSchema, s as AgentSummaryListResponseSchema, st as PresignUserAvatarRequestSchema, t as ACTIVE_ORG_HEADER, tt as PROJECT_REACHABILITY_REQUEST_TIMEOUT_MS, u as ChannelConnectionListResponseSchema, ut as ProjectResponseSchema, v as CreateApiKeyResponseSchema, vt as RecentResourceListResponseSchema, w as CreateProjectArtifactResponseSchema, wt as TriggerDetailResponseSchema, x as CreateCredentialsResponseSchema, xt as SlugAvailabilityResponseSchema, y as CreateCredentialInstanceBodySchema, yt as SkillSummaryDetailResponseSchema, z as InviteOrganizationMembersResponseSchema, zt as UploadProjectSourceResponseSchema } from "./dist-DqwV88tz.mjs";
2
+ import { $ as OrganizationSidebarBrandingPatchSchema, $t as parseErrorResponse, A as ErrorResponseSchema, At as UpdateCredentialInstanceBodySchema, B as InviteProjectMembersRequestSchema, Bt as UploadProjectSourceResponseSchema, C as CreateOrganizationResponseSchema, Ct as StartOAuthConnectionResultSchema, D as CredentialInstanceListResponseSchema, Dt as TriggerRunDetailResponseSchema, E as CreateProjectResponseSchema, Et as TriggerListResponseSchema, F as HistoryRunDetailResponseSchema, Ft as UpdateProjectMemberRequestSchema, G as ListOrganizationInvitationsResponseSchema, Gt as UserPreferencesSchema, H as ListApiKeysResponseSchema, Ht as UserAvatarPatchSchema, I as HistoryRunListQuerySchema, It as UpdateProjectMemberResponseSchema, J as ListProjectDeploymentsResponseSchema, Jt as WorkflowSummaryDetailResponseSchema, K as ListOrganizationMembersResponseSchema, Kt as WorkflowRunDetailResponseSchema, L as HistoryRunListResponseSchema, Lt as UpdateProjectRequestSchema, M as GetCredentialResponseSchema, Mt as UpdateOrganizationMemberRequestSchema, N as HealthResponseSchema, Nt as UpdateOrganizationMemberResponseSchema, O as CredentialInstanceRecordSchema, Ot as TriggerRunListResponseSchema, P as HistoryRunCancelResponseSchema, Pt as UpdateOrganizationRequestSchema, Q as ListProjectsResponseSchema, Qt as originFromPublicUrl, R as InviteOrganizationMembersRequestSchema, Rt as UpdateProjectSettingsRequestSchema, S as CreateOrganizationRequestSchema, St as StartOAuthConnectionInputSchema, T as CreateProjectRequestSchema, Tt as TriggerDetailResponseSchema, U as ListAppsResponseSchema, Ut as UserAvatarSchema, V as InviteProjectMembersResponseSchema, Vt as UpsertGatewayAttachmentBodySchema, W as ListCredentialsResponseSchema, Wt as UserPreferencesPatchSchema, X as ListProjectMembersResponseSchema, Xt as listenPortFromPublicUrl, Y as ListProjectFilesResponseSchema, Yt as WorkflowSummaryListResponseSchema, Z as ListProjectMetricsResponseSchema, _ as CreateApiKeyRequestSchema, _t as ROUTE_MANIFEST_REL_PATH, a as AgentSessionListResponseSchema, at as PresignProjectSourceRequestSchema, b as CreateCredentialsRequestSchema, bt as SkillSummaryListResponseSchema, c as BindChannelBodySchema, ct as PresignUserAvatarResponseSchema, d as ChannelConnectionSchema, dt as ProjectSettingsResponseSchema, et as OrganizationSidebarBrandingSchema, f as ChannelDirectoryListResponseSchema, ft as ProjectSlugAvailabilityResponseSchema, g as ConnectProvidersResponseSchema, gt as QueuedRunResponseSchema, h as ConnectAuthorizeUrlResponseSchema, ht as QueuedAgentPromptResponseSchema, i as AgentSessionDetailResponseSchema, it as PresignOrgLogoResponseSchema, j as GatewayAttachmentRecordSchema, jt as UpdateCredentialRequestSchema, k as DeclineOrganizationInvitationResponseSchema, kt as UpdateChannelBindingBodySchema, l as ChannelAccountListResponseSchema, lt as ProjectReachabilityResponseSchema, m as CompleteProjectArtifactResponseSchema, mt as PromptResponseSchema, n as AcceptOrganizationInvitationResponseSchema, nt as PollRunResponseSchema, o as AgentSummaryDetailResponseSchema, ot as PresignProjectSourceResponseSchema, p as ChannelPlatformSchema, pt as PromptInputSchema, q as ListOrganizationsResponseSchema, qt as WorkflowRunListResponseSchema, r as ActiveOrganizationResponseSchema, rt as PresignOrgLogoRequestSchema, s as AgentSummaryListResponseSchema, st as PresignUserAvatarRequestSchema, t as ACTIVE_ORG_HEADER, tt as PROJECT_REACHABILITY_REQUEST_TIMEOUT_MS, u as ChannelConnectionListResponseSchema, ut as ProjectResponseSchema, v as CreateApiKeyResponseSchema, vt as RecentResourceListResponseSchema, w as CreateProjectArtifactResponseSchema, wt as SubmitTeamRequestRequestSchema, x as CreateCredentialsResponseSchema, xt as SlugAvailabilityResponseSchema, y as CreateCredentialInstanceBodySchema, yt as SkillSummaryDetailResponseSchema, z as InviteOrganizationMembersResponseSchema, zt as UploadProjectSourceManifestRequestSchema } from "./dist-BQXd3jdL.mjs";
3
3
  import { t as walkProject } from "./walk-project-171B4cvO-DJy3qZKd.mjs";
4
4
  import { a as installPlaygroundDependencies, i as installDependencies, n as buildPlaygroundWorkspace, o as resolvePackageManager, s as resolveCliRoot, t as readCliVersion } from "./version-DESgLEkE.mjs";
5
5
  import { createRequire } from "node:module";
@@ -3750,6 +3750,16 @@ function createSkillsResource(http) {
3750
3750
  }
3751
3751
  };
3752
3752
  }
3753
+ function createTeamRequestsResource(http) {
3754
+ return { async submit(input) {
3755
+ const body = SubmitTeamRequestRequestSchema.parse(input);
3756
+ try {
3757
+ await http.post("/api/team-requests", { json: body }).json();
3758
+ } catch (error) {
3759
+ throw await toPlatformError(error);
3760
+ }
3761
+ } };
3762
+ }
3753
3763
  function createRecentsResource(http) {
3754
3764
  return { async list() {
3755
3765
  try {
@@ -4310,6 +4320,7 @@ function createPlatformClient(options) {
4310
4320
  userPreferences: createUserPreferencesResource(http),
4311
4321
  userAvatar: createUserAvatarResource(http),
4312
4322
  organizationSidebarBranding: createOrganizationSidebarBrandingResource(http, { getActiveOrganizationId: () => activeOrganizationId }),
4323
+ teamRequests: createTeamRequestsResource(http),
4313
4324
  getActiveOrganizationId: () => activeOrganizationId,
4314
4325
  setActiveOrganizationId
4315
4326
  };
@@ -4727,6 +4738,129 @@ function registerAgentCommand(program) {
4727
4738
  registerAgentSessionsCommand(agent);
4728
4739
  }
4729
4740
  //#endregion
4741
+ //#region src/commands/project/run-project.ts
4742
+ async function withActivePlatformClient(config, fn) {
4743
+ const platform = createCliPlatformClient(config);
4744
+ let active = await platform.organizations.getActive();
4745
+ if (!active) active = await selectActiveOrganization(config);
4746
+ platform.setActiveOrganizationId(active.organization.id);
4747
+ await fn(platform);
4748
+ }
4749
+ function writeInactiveDeployHints(projects) {
4750
+ const bin = cliBinaryName();
4751
+ for (const project of projects) {
4752
+ if (project.status !== "inactive") continue;
4753
+ process.stderr.write(`Project ${formatProjectLabel(project)} is inactive. Deploy with: ${bin} deploy --project ${formatProjectLabel(project)}\n`);
4754
+ }
4755
+ }
4756
+ async function runProjectList(config) {
4757
+ await withActivePlatformClient(config, async (platform) => {
4758
+ const projects = await platform.projects.list();
4759
+ process.stdout.write(`${JSON.stringify({ projects }, null, 2)}\n`);
4760
+ if (projects.length === 0) {
4761
+ const bin = cliBinaryName();
4762
+ process.stderr.write(`No projects yet. Create one with: ${bin} project create --name "My project"\n`);
4763
+ return;
4764
+ }
4765
+ writeInactiveDeployHints(projects);
4766
+ });
4767
+ }
4768
+ async function runProjectMetrics(config, options) {
4769
+ await withActivePlatformClient(config, async (platform) => {
4770
+ const metrics = await platform.projectMetrics.list();
4771
+ if (options.projectRef === void 0) {
4772
+ process.stdout.write(`${JSON.stringify(metrics, null, 2)}\n`);
4773
+ return;
4774
+ }
4775
+ const project = await resolveProjectRef(platform, options.projectRef);
4776
+ const output = Object.fromEntries(Object.entries(metrics).filter(([projectId]) => projectId === project.id));
4777
+ process.stdout.write(`${JSON.stringify(output, null, 2)}\n`);
4778
+ });
4779
+ }
4780
+ async function runProjectDeploymentsList(config, options) {
4781
+ await withActivePlatformClient(config, async (platform) => {
4782
+ const project = await resolveProjectRef(platform, options.projectRef);
4783
+ const deployments = await platform.deployments.listForProject(project.id);
4784
+ process.stdout.write(`${JSON.stringify({ deployments }, null, 2)}\n`);
4785
+ });
4786
+ }
4787
+ async function runProjectCreate(config, input) {
4788
+ await withActivePlatformClient(config, async (platform) => {
4789
+ const project = await platform.projects.create(input);
4790
+ process.stdout.write(`${JSON.stringify({ project }, null, 2)}\n`);
4791
+ writeInactiveDeployHints([project]);
4792
+ });
4793
+ }
4794
+ async function runProjectUpdate(config, input) {
4795
+ await withActivePlatformClient(config, async (platform) => {
4796
+ const { projectId, ...patch } = input;
4797
+ const project = await platform.projects.update(projectId, patch);
4798
+ process.stdout.write(`${JSON.stringify({ project }, null, 2)}\n`);
4799
+ });
4800
+ }
4801
+ async function runProjectDelete(config, projectId) {
4802
+ await withActivePlatformClient(config, async (platform) => {
4803
+ await platform.projects.delete(projectId);
4804
+ process.stdout.write(`${JSON.stringify({ deleted: projectId }, null, 2)}\n`);
4805
+ });
4806
+ }
4807
+ //#endregion
4808
+ //#region src/commands/api-key/run-api-key.ts
4809
+ async function runApiKeyList(config) {
4810
+ await withActivePlatformClient(config, async (platform) => {
4811
+ const apiKeys = await platform.apiKeys.list();
4812
+ process.stdout.write(`${JSON.stringify({ apiKeys }, null, 2)}\n`);
4813
+ });
4814
+ }
4815
+ async function runApiKeyCreate(config, input) {
4816
+ await withActivePlatformClient(config, async (platform) => {
4817
+ const apiKey = await platform.apiKeys.create(input);
4818
+ process.stdout.write(`${JSON.stringify({ apiKey }, null, 2)}\n`);
4819
+ });
4820
+ }
4821
+ async function runApiKeyRevoke(config, apiKeyId) {
4822
+ await withActivePlatformClient(config, async (platform) => {
4823
+ await platform.apiKeys.revoke(apiKeyId);
4824
+ process.stdout.write(`${JSON.stringify({ revoked: apiKeyId }, null, 2)}\n`);
4825
+ });
4826
+ }
4827
+ //#endregion
4828
+ //#region src/commands/api-key/index.ts
4829
+ async function handleApiKeyError(fallback, action) {
4830
+ const config = createCliConfig();
4831
+ try {
4832
+ await action();
4833
+ } catch (error) {
4834
+ process.stderr.write(`${formatCliError(error, fallback, {
4835
+ serverUrl: getPlatformUrl(config),
4836
+ webUrl: getWebUrl(config)
4837
+ })}\n`);
4838
+ process.exitCode = 1;
4839
+ }
4840
+ }
4841
+ function registerApiKeyCommand(program) {
4842
+ const apiKey = program.command("api-key").description("Manage org-scoped platform API keys");
4843
+ apiKey.command("list").description("List API keys in the active organization").action(async () => {
4844
+ const config = createCliConfig();
4845
+ await handleApiKeyError("List API keys failed", async () => {
4846
+ await runApiKeyList(config);
4847
+ });
4848
+ });
4849
+ apiKey.command("create").description("Create an API key in the active organization").requiredOption("--name <name>", "API key name").action(async (options) => {
4850
+ const config = createCliConfig();
4851
+ await handleApiKeyError("Create API key failed", async () => {
4852
+ await runApiKeyCreate(config, { name: options.name });
4853
+ });
4854
+ });
4855
+ apiKey.command("revoke").description("Revoke an API key").argument("<apiKeyId>", "API key id").option("-y, --yes", "Skip confirmation prompt").action(async (apiKeyId, options) => {
4856
+ const config = createCliConfig();
4857
+ await handleApiKeyError("Revoke API key failed", async () => {
4858
+ if (!options.yes) throw new Error("Pass --yes to confirm API key revocation");
4859
+ await runApiKeyRevoke(config, apiKeyId);
4860
+ });
4861
+ });
4862
+ }
4863
+ //#endregion
4730
4864
  //#region src/commands/app/run-app-list.ts
4731
4865
  async function runAppList(client) {
4732
4866
  return client.apps.listCatalog();
@@ -4872,73 +5006,6 @@ function registerConnectCommand(program) {
4872
5006
  }, void 0, resolveConnectTargetOptions()));
4873
5007
  }
4874
5008
  //#endregion
4875
- //#region src/commands/project/run-project.ts
4876
- async function withActivePlatformClient(config, fn) {
4877
- const platform = createCliPlatformClient(config);
4878
- let active = await platform.organizations.getActive();
4879
- if (!active) active = await selectActiveOrganization(config);
4880
- platform.setActiveOrganizationId(active.organization.id);
4881
- await fn(platform);
4882
- }
4883
- function writeInactiveDeployHints(projects) {
4884
- const bin = cliBinaryName();
4885
- for (const project of projects) {
4886
- if (project.status !== "inactive") continue;
4887
- process.stderr.write(`Project ${formatProjectLabel(project)} is inactive. Deploy with: ${bin} deploy --project ${formatProjectLabel(project)}\n`);
4888
- }
4889
- }
4890
- async function runProjectList(config) {
4891
- await withActivePlatformClient(config, async (platform) => {
4892
- const projects = await platform.projects.list();
4893
- process.stdout.write(`${JSON.stringify({ projects }, null, 2)}\n`);
4894
- if (projects.length === 0) {
4895
- const bin = cliBinaryName();
4896
- process.stderr.write(`No projects yet. Create one with: ${bin} project create --name "My project"\n`);
4897
- return;
4898
- }
4899
- writeInactiveDeployHints(projects);
4900
- });
4901
- }
4902
- async function runProjectMetrics(config, options) {
4903
- await withActivePlatformClient(config, async (platform) => {
4904
- const metrics = await platform.projectMetrics.list();
4905
- if (options.projectRef === void 0) {
4906
- process.stdout.write(`${JSON.stringify(metrics, null, 2)}\n`);
4907
- return;
4908
- }
4909
- const project = await resolveProjectRef(platform, options.projectRef);
4910
- const output = Object.fromEntries(Object.entries(metrics).filter(([projectId]) => projectId === project.id));
4911
- process.stdout.write(`${JSON.stringify(output, null, 2)}\n`);
4912
- });
4913
- }
4914
- async function runProjectDeploymentsList(config, options) {
4915
- await withActivePlatformClient(config, async (platform) => {
4916
- const project = await resolveProjectRef(platform, options.projectRef);
4917
- const deployments = await platform.deployments.listForProject(project.id);
4918
- process.stdout.write(`${JSON.stringify({ deployments }, null, 2)}\n`);
4919
- });
4920
- }
4921
- async function runProjectCreate(config, input) {
4922
- await withActivePlatformClient(config, async (platform) => {
4923
- const project = await platform.projects.create(input);
4924
- process.stdout.write(`${JSON.stringify({ project }, null, 2)}\n`);
4925
- writeInactiveDeployHints([project]);
4926
- });
4927
- }
4928
- async function runProjectUpdate(config, input) {
4929
- await withActivePlatformClient(config, async (platform) => {
4930
- const { projectId, ...patch } = input;
4931
- const project = await platform.projects.update(projectId, patch);
4932
- process.stdout.write(`${JSON.stringify({ project }, null, 2)}\n`);
4933
- });
4934
- }
4935
- async function runProjectDelete(config, projectId) {
4936
- await withActivePlatformClient(config, async (platform) => {
4937
- await platform.projects.delete(projectId);
4938
- process.stdout.write(`${JSON.stringify({ deleted: projectId }, null, 2)}\n`);
4939
- });
4940
- }
4941
- //#endregion
4942
5009
  //#region src/commands/credentials/target-options.ts
4943
5010
  function resolveCredentialsTargetOptions(options = {}) {
4944
5011
  if (options.scopeType === "project") return {
@@ -5451,7 +5518,7 @@ function registerBuildCommand(program) {
5451
5518
  program.command("build").description("Build the keystroke project for production").option("--dir <path>", "Project directory", process.cwd()).action(async (options) => {
5452
5519
  try {
5453
5520
  const root = resolveProjectRoot(options.dir);
5454
- const { buildApp } = await import("./dist-SAPlw0EN.mjs");
5521
+ const { buildApp } = await import("./dist-BQ0CIkZY.mjs");
5455
5522
  await buildApp({ root });
5456
5523
  process.stdout.write(`Built ${root}\n`);
5457
5524
  } catch (error) {
@@ -5548,7 +5615,7 @@ async function runDeploy(options) {
5548
5615
  const client = createCliPlatformClient(config);
5549
5616
  let source;
5550
5617
  if (!options.skipBuild) {
5551
- const { buildApp } = await import("./dist-SAPlw0EN.mjs");
5618
+ const { buildApp } = await import("./dist-BQ0CIkZY.mjs");
5552
5619
  source = { files: (await buildApp({
5553
5620
  root,
5554
5621
  collectSources: true,
@@ -5648,7 +5715,7 @@ function runtimeChildEnv(parentEnv, overrides) {
5648
5715
  //#region src/project/bootstrap-run.ts
5649
5716
  /** Node args + env for `@keystrokehq/build` bootstrap (shared by start + dev). */
5650
5717
  async function resolveBootstrapRun(options) {
5651
- const { resolveRuntimeBuildArtifact } = await import("./dist-SAPlw0EN.mjs");
5718
+ const { resolveRuntimeBuildArtifact } = await import("./dist-BQ0CIkZY.mjs");
5652
5719
  const loader = pathToFileURL(resolveRuntimeBuildArtifact(options.runtimeNodeModules, "dist/runtime-loader.mjs")).href;
5653
5720
  const bootstrap = resolveRuntimeBuildArtifact(options.runtimeNodeModules, "dist/bootstrap.mjs");
5654
5721
  const args = [`--import=${loader}`];
@@ -5798,7 +5865,7 @@ async function runDev(options) {
5798
5865
  process.on("SIGINT", shutdown);
5799
5866
  process.on("SIGTERM", shutdown);
5800
5867
  try {
5801
- const { watchApp } = await import("./dist-SAPlw0EN.mjs");
5868
+ const { watchApp } = await import("./dist-BQ0CIkZY.mjs");
5802
5869
  await watchApp({
5803
5870
  root,
5804
5871
  clean: false,
@@ -6218,6 +6285,15 @@ function registerInitCommand(program) {
6218
6285
  });
6219
6286
  }
6220
6287
  //#endregion
6288
+ //#region src/active-project.ts
6289
+ function clearActiveProjectIfMatches(config, project) {
6290
+ const activeProjectId = config.get("activeProjectId");
6291
+ if (activeProjectId === project.id || activeProjectId === project.slug) config.delete("activeProjectId");
6292
+ }
6293
+ function clearActiveProject(config) {
6294
+ if (config.get("activeProjectId") !== void 0) config.delete("activeProjectId");
6295
+ }
6296
+ //#endregion
6221
6297
  //#region src/commands/organization/run-organization.ts
6222
6298
  async function runOrganizationUpdate(config, input) {
6223
6299
  await withActivePlatformClient(config, async (platform) => {
@@ -6225,20 +6301,302 @@ async function runOrganizationUpdate(config, input) {
6225
6301
  process.stdout.write(`${JSON.stringify({ organization }, null, 2)}\n`);
6226
6302
  });
6227
6303
  }
6304
+ async function runOrganizationMembersList(config) {
6305
+ await withActivePlatformClient(config, async (platform) => {
6306
+ const members = await platform.members.listOrganizationMembers();
6307
+ process.stdout.write(`${JSON.stringify({ members }, null, 2)}\n`);
6308
+ });
6309
+ }
6310
+ async function runOrganizationMembersInvite(config, input) {
6311
+ await withActivePlatformClient(config, async (platform) => {
6312
+ const result = await platform.members.inviteOrganizationMembers(input);
6313
+ process.stdout.write(`${JSON.stringify(result, null, 2)}\n`);
6314
+ });
6315
+ }
6316
+ async function runOrganizationMembersRole(config, input) {
6317
+ await withActivePlatformClient(config, async (platform) => {
6318
+ const member = await platform.members.updateOrganizationMember(input.userId, { role: input.role });
6319
+ process.stdout.write(`${JSON.stringify({ member }, null, 2)}\n`);
6320
+ });
6321
+ }
6322
+ async function runOrganizationMembersRemove(config, userId) {
6323
+ await withActivePlatformClient(config, async (platform) => {
6324
+ await platform.members.removeOrganizationMember(userId);
6325
+ process.stdout.write(`${JSON.stringify({ removed: userId }, null, 2)}\n`);
6326
+ });
6327
+ }
6328
+ async function runOrganizationLeave(config) {
6329
+ const platformUrl = getPlatformUrl(config);
6330
+ const token = getAccessToken(platformUrl);
6331
+ if (!token) throw new Error("Not authenticated. Run `keystroke auth login` first.");
6332
+ const user = await getSessionWithBearer(platformUrl, token);
6333
+ if (!user) throw new Error("Session expired. Run `keystroke auth login` again.");
6334
+ await withActivePlatformClient(config, async (platform) => {
6335
+ await platform.members.removeOrganizationMember(user.id);
6336
+ platform.setActiveOrganizationId(null);
6337
+ config.delete("activeOrganizationId");
6338
+ clearActiveProject(config);
6339
+ process.stdout.write(`${JSON.stringify({ left: user.id }, null, 2)}\n`);
6340
+ });
6341
+ }
6228
6342
  //#endregion
6229
6343
  //#region src/commands/organization/index.ts
6344
+ function collectEmails$1(value, previous) {
6345
+ return [...previous, value];
6346
+ }
6347
+ function parseInvitableRole(role) {
6348
+ if (role === "admin" || role === "builder") return role;
6349
+ throw new Error("Role must be admin or builder");
6350
+ }
6351
+ async function handleOrganizationError(fallback, action) {
6352
+ const config = createCliConfig();
6353
+ try {
6354
+ await action();
6355
+ } catch (error) {
6356
+ process.stderr.write(`${formatCliError(error, fallback, {
6357
+ serverUrl: getPlatformUrl(config),
6358
+ webUrl: getWebUrl(config)
6359
+ })}\n`);
6360
+ process.exitCode = 1;
6361
+ }
6362
+ }
6230
6363
  function registerOrganizationCommand(program) {
6231
- program.command("organization").description("Manage the active organization").command("update").description("Update the active organization's display name").requiredOption("--name <name>", "Organization display name").action(async (options) => {
6364
+ const organization = program.command("organization").alias("org").description("Manage the active organization");
6365
+ organization.command("update").description("Update the active organization's display name").requiredOption("--name <name>", "Organization display name").action(async (options) => {
6232
6366
  const config = createCliConfig();
6233
- try {
6367
+ await handleOrganizationError("Update organization failed", async () => {
6234
6368
  await runOrganizationUpdate(config, { name: options.name });
6235
- } catch (error) {
6236
- process.stderr.write(`${formatCliError(error, "Update organization failed", {
6237
- serverUrl: getPlatformUrl(config),
6238
- webUrl: getWebUrl(config)
6239
- })}\n`);
6240
- process.exitCode = 1;
6241
- }
6369
+ });
6370
+ });
6371
+ organization.command("leave").description("Leave the active organization").option("-y, --yes", "Skip confirmation prompt").action(async (options) => {
6372
+ const config = createCliConfig();
6373
+ await handleOrganizationError("Leave organization failed", async () => {
6374
+ if (!options.yes) throw new Error("Pass --yes to confirm leaving the active organization");
6375
+ await runOrganizationLeave(config);
6376
+ });
6377
+ });
6378
+ const members = organization.command("members").description("Manage organization members in the active organization");
6379
+ members.command("list").description("List members in the active organization").action(async () => {
6380
+ const config = createCliConfig();
6381
+ await handleOrganizationError("List organization members failed", async () => {
6382
+ await runOrganizationMembersList(config);
6383
+ });
6384
+ });
6385
+ members.command("invite").description("Invite people to the active organization").requiredOption("--email <email>", "Email address (repeat for multiple)", collectEmails$1, []).requiredOption("--role <role>", "Member role (admin or builder)").action(async (options) => {
6386
+ const config = createCliConfig();
6387
+ await handleOrganizationError("Invite organization members failed", async () => {
6388
+ await runOrganizationMembersInvite(config, {
6389
+ emails: options.email,
6390
+ role: parseInvitableRole(options.role)
6391
+ });
6392
+ });
6393
+ });
6394
+ members.command("role").description("Update a member's role in the active organization").argument("<userId>", "Member user id").requiredOption("--role <role>", "Member role (admin or builder)").action(async (userId, options) => {
6395
+ const config = createCliConfig();
6396
+ await handleOrganizationError("Update organization member role failed", async () => {
6397
+ await runOrganizationMembersRole(config, {
6398
+ userId,
6399
+ role: parseInvitableRole(options.role)
6400
+ });
6401
+ });
6402
+ });
6403
+ members.command("remove").description("Remove a member from the active organization").argument("<userId>", "Member user id").action(async (userId) => {
6404
+ const config = createCliConfig();
6405
+ await handleOrganizationError("Remove organization member failed", async () => {
6406
+ await runOrganizationMembersRemove(config, userId);
6407
+ });
6408
+ });
6409
+ }
6410
+ //#endregion
6411
+ //#region src/commands/project/run-project-members.ts
6412
+ async function resolveMembersProject(platform, config, projectRef) {
6413
+ const ref = projectRef ?? getCliTargetOptions().projectId ?? config.get("activeProjectId");
6414
+ if (!ref) throw new Error("Usage: keystroke --project <slug> project members <command>");
6415
+ return resolveProjectRef(platform, ref);
6416
+ }
6417
+ async function runProjectMembersList(config, options) {
6418
+ await withActivePlatformClient(config, async (platform) => {
6419
+ const project = await resolveMembersProject(platform, config, options.projectRef);
6420
+ const members = await platform.members.listForProject(project.id);
6421
+ process.stdout.write(`${JSON.stringify({ members }, null, 2)}\n`);
6422
+ });
6423
+ }
6424
+ async function runProjectMembersInvite(config, input) {
6425
+ await withActivePlatformClient(config, async (platform) => {
6426
+ const project = await resolveMembersProject(platform, config, input.projectRef);
6427
+ const result = await platform.members.inviteToProject({
6428
+ projectId: project.id,
6429
+ emails: input.emails,
6430
+ role: input.role
6431
+ });
6432
+ process.stdout.write(`${JSON.stringify(result, null, 2)}\n`);
6433
+ });
6434
+ }
6435
+ async function runProjectMembersRole(config, input) {
6436
+ await withActivePlatformClient(config, async (platform) => {
6437
+ const project = await resolveMembersProject(platform, config, input.projectRef);
6438
+ const member = await platform.members.updateProjectMember(project.id, input.userId, { role: input.role });
6439
+ process.stdout.write(`${JSON.stringify({ member }, null, 2)}\n`);
6440
+ });
6441
+ }
6442
+ async function runProjectMembersRemove(config, input) {
6443
+ await withActivePlatformClient(config, async (platform) => {
6444
+ const project = await resolveMembersProject(platform, config, input.projectRef);
6445
+ await platform.members.removeProjectMember(project.id, input.userId);
6446
+ process.stdout.write(`${JSON.stringify({ removed: input.userId }, null, 2)}\n`);
6447
+ });
6448
+ }
6449
+ async function runProjectMembersLeave(config, options) {
6450
+ await withActivePlatformClient(config, async (platform) => {
6451
+ const project = await resolveMembersProject(platform, config, options.projectRef);
6452
+ await platform.members.leaveProject(project.id);
6453
+ clearActiveProjectIfMatches(config, project);
6454
+ process.stdout.write(`${JSON.stringify({ left: project.id }, null, 2)}\n`);
6455
+ });
6456
+ }
6457
+ //#endregion
6458
+ //#region src/commands/project/members.ts
6459
+ function collectEmails(value, previous) {
6460
+ return [...previous, value];
6461
+ }
6462
+ function parseProjectRole$1(role) {
6463
+ if (role === "admin" || role === "builder") return role;
6464
+ throw new Error("Role must be admin or builder");
6465
+ }
6466
+ function resolveProjectRefOption$1(config, optionsProject) {
6467
+ return optionsProject ?? getCliTargetOptions().projectId ?? config.get("activeProjectId");
6468
+ }
6469
+ function projectRefInput$1(config, optionsProject) {
6470
+ const projectRef = resolveProjectRefOption$1(config, optionsProject);
6471
+ return projectRef ? { projectRef } : {};
6472
+ }
6473
+ async function handleProjectMembersError(fallback, action) {
6474
+ const config = createCliConfig();
6475
+ try {
6476
+ await action();
6477
+ } catch (error) {
6478
+ process.stderr.write(`${formatCliError(error, fallback, {
6479
+ serverUrl: getPlatformUrl(config),
6480
+ webUrl: getWebUrl(config)
6481
+ })}\n`);
6482
+ process.exitCode = 1;
6483
+ }
6484
+ }
6485
+ function registerProjectMembersCommand(project) {
6486
+ const members = project.command("members").description("Manage members for a platform project");
6487
+ members.command("list").description("List members for a project").option("--project <slug>", "Project slug").action(async (options) => {
6488
+ const config = createCliConfig();
6489
+ await handleProjectMembersError("List project members failed", async () => {
6490
+ await runProjectMembersList(config, projectRefInput$1(config, options.project));
6491
+ });
6492
+ });
6493
+ members.command("invite").description("Invite people to a project").option("--project <slug>", "Project slug").requiredOption("--email <email>", "Email address (repeat for multiple)", collectEmails, []).requiredOption("--role <role>", "Project role (admin or builder)").action(async (options) => {
6494
+ const config = createCliConfig();
6495
+ await handleProjectMembersError("Invite project members failed", async () => {
6496
+ await runProjectMembersInvite(config, {
6497
+ ...projectRefInput$1(config, options.project),
6498
+ emails: options.email,
6499
+ role: parseProjectRole$1(options.role)
6500
+ });
6501
+ });
6502
+ });
6503
+ members.command("role").description("Update a project member role").argument("<userId>", "Member user id").option("--project <slug>", "Project slug").requiredOption("--role <role>", "Project role (admin or builder)").action(async (userId, options) => {
6504
+ const config = createCliConfig();
6505
+ await handleProjectMembersError("Update project member role failed", async () => {
6506
+ await runProjectMembersRole(config, {
6507
+ ...projectRefInput$1(config, options.project),
6508
+ userId,
6509
+ role: parseProjectRole$1(options.role)
6510
+ });
6511
+ });
6512
+ });
6513
+ members.command("remove").description("Remove a member from a project").argument("<userId>", "Member user id").option("--project <slug>", "Project slug").action(async (userId, options) => {
6514
+ const config = createCliConfig();
6515
+ await handleProjectMembersError("Remove project member failed", async () => {
6516
+ await runProjectMembersRemove(config, {
6517
+ ...projectRefInput$1(config, options.project),
6518
+ userId
6519
+ });
6520
+ });
6521
+ });
6522
+ members.command("leave").description("Leave a project as the current user").option("--project <slug>", "Project slug").option("-y, --yes", "Skip confirmation prompt").action(async (options) => {
6523
+ const config = createCliConfig();
6524
+ await handleProjectMembersError("Leave project failed", async () => {
6525
+ if (!options.yes) throw new Error("Pass --yes to confirm leaving the project");
6526
+ await runProjectMembersLeave(config, projectRefInput$1(config, options.project));
6527
+ });
6528
+ });
6529
+ }
6530
+ //#endregion
6531
+ //#region src/commands/project/run-project-settings.ts
6532
+ async function resolveSettingsProject(platform, config, projectRef) {
6533
+ const ref = projectRef ?? getCliTargetOptions().projectId ?? config.get("activeProjectId");
6534
+ if (!ref) throw new Error("Usage: keystroke --project <slug> project settings <command>");
6535
+ return resolveProjectRef(platform, ref);
6536
+ }
6537
+ async function runProjectSettingsGet(config, options) {
6538
+ await withActivePlatformClient(config, async (platform) => {
6539
+ const project = await resolveSettingsProject(platform, config, options.projectRef);
6540
+ const settings = await platform.projectSettings.get(project.id);
6541
+ process.stdout.write(`${JSON.stringify({ settings }, null, 2)}\n`);
6542
+ });
6543
+ }
6544
+ async function runProjectSettingsUpdate(config, input) {
6545
+ await withActivePlatformClient(config, async (platform) => {
6546
+ const project = await resolveSettingsProject(platform, config, input.projectRef);
6547
+ const { projectRef: _projectRef, ...patch } = input;
6548
+ const settings = await platform.projectSettings.update(project.id, patch);
6549
+ process.stdout.write(`${JSON.stringify({ settings }, null, 2)}\n`);
6550
+ });
6551
+ }
6552
+ //#endregion
6553
+ //#region src/commands/project/settings.ts
6554
+ function resolveProjectRefOption(config, optionsProject) {
6555
+ return optionsProject ?? getCliTargetOptions().projectId ?? config.get("activeProjectId");
6556
+ }
6557
+ function projectRefInput(config, optionsProject) {
6558
+ const projectRef = resolveProjectRefOption(config, optionsProject);
6559
+ return projectRef ? { projectRef } : {};
6560
+ }
6561
+ function parseProjectRole(role) {
6562
+ if (role === "admin" || role === "builder") return role;
6563
+ throw new Error("Default role must be admin or builder");
6564
+ }
6565
+ function parseInvitePermission(permission) {
6566
+ if (permission === "admin" || permission === "all") return permission;
6567
+ throw new Error("Invite permission must be admin or all");
6568
+ }
6569
+ async function handleProjectSettingsError(fallback, action) {
6570
+ const config = createCliConfig();
6571
+ try {
6572
+ await action();
6573
+ } catch (error) {
6574
+ process.stderr.write(`${formatCliError(error, fallback, {
6575
+ serverUrl: getPlatformUrl(config),
6576
+ webUrl: getWebUrl(config)
6577
+ })}\n`);
6578
+ process.exitCode = 1;
6579
+ }
6580
+ }
6581
+ function registerProjectSettingsCommand(project) {
6582
+ const settings = project.command("settings").description("View and update project governance settings");
6583
+ settings.command("get").description("Get settings for a project").option("--project <slug>", "Project slug").action(async (options) => {
6584
+ const config = createCliConfig();
6585
+ await handleProjectSettingsError("Get project settings failed", async () => {
6586
+ await runProjectSettingsGet(config, projectRefInput(config, options.project));
6587
+ });
6588
+ });
6589
+ settings.command("update").description("Update settings for a project").option("--project <slug>", "Project slug").option("--description <description>", "Project description").option("--default-role <role>", "Default role for new members (admin or builder)").option("--invite-permission <permission>", "Who can invite members (admin or all)").action(async (options) => {
6590
+ const config = createCliConfig();
6591
+ await handleProjectSettingsError("Update project settings failed", async () => {
6592
+ if (options.description === void 0 && options.defaultRole === void 0 && options.invitePermission === void 0) throw new Error("At least one of --description, --default-role, or --invite-permission is required");
6593
+ await runProjectSettingsUpdate(config, {
6594
+ ...projectRefInput(config, options.project),
6595
+ ...options.description !== void 0 ? { description: options.description } : {},
6596
+ ...options.defaultRole !== void 0 ? { defaultRole: parseProjectRole(options.defaultRole) } : {},
6597
+ ...options.invitePermission !== void 0 ? { invitePermission: parseInvitePermission(options.invitePermission) } : {}
6598
+ });
6599
+ });
6242
6600
  });
6243
6601
  }
6244
6602
  //#endregion
@@ -6260,7 +6618,7 @@ function registerProjectCommand(program) {
6260
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) => {
6261
6619
  const config = createCliConfig();
6262
6620
  try {
6263
- await runProjectMetrics(config, { ...options.project ? { projectRef: options.project } : {} });
6621
+ await runProjectMetrics(config, options.project ? { projectRef: options.project } : {});
6264
6622
  } catch (error) {
6265
6623
  process.stderr.write(`${formatCliError(error, "List project metrics failed", {
6266
6624
  serverUrl: getPlatformUrl(config),
@@ -6332,6 +6690,8 @@ function registerProjectCommand(program) {
6332
6690
  process.exitCode = 1;
6333
6691
  }
6334
6692
  });
6693
+ registerProjectMembersCommand(project);
6694
+ registerProjectSettingsCommand(project);
6335
6695
  }
6336
6696
  //#endregion
6337
6697
  //#region src/commands/start.ts
@@ -6346,7 +6706,7 @@ async function runStart(options) {
6346
6706
  const apiPort = Number(new URL(serverUrl).port || 80);
6347
6707
  const runtimeNodeModules = resolveCliRuntimeNodeModules(resolveCliRoot(import.meta.url));
6348
6708
  ensureNativeDeps(runtimeNodeModules);
6349
- const { buildApp } = await import("./dist-SAPlw0EN.mjs");
6709
+ const { buildApp } = await import("./dist-BQ0CIkZY.mjs");
6350
6710
  await buildApp({
6351
6711
  root,
6352
6712
  clean: false
@@ -6834,6 +7194,7 @@ function createProgram() {
6834
7194
  registerConnectCommand(program);
6835
7195
  registerConfigCommand(program);
6836
7196
  registerOrganizationCommand(program);
7197
+ registerApiKeyCommand(program);
6837
7198
  registerProjectCommand(program);
6838
7199
  registerHistoryCommand(program);
6839
7200
  registerCredentialsCommand(program);