@corelayer-ai/cli 0.4.1 → 0.4.3

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.
@@ -1,5 +1,5 @@
1
- import { readConfig, resolveApiUrl, resolveToken } from "../lib/config.js";
2
- import { loadSharedSdk } from "../lib/shared-sdk-loader.js";
1
+ import { CorelayerClient } from "../lib/api-client.js";
2
+ import { resolveApiUrl, resolveToken } from "../lib/config.js";
3
3
  import { fail, printJson } from "../lib/output.js";
4
4
  function readFlag(args, flag) {
5
5
  const index = args.indexOf(flag);
@@ -11,21 +11,24 @@ function printHelp() {
11
11
  process.stdout.write(`corelayer api-keys - Manage Corelayer API keys
12
12
 
13
13
  USAGE:
14
- corelayer api-keys create --name <name> [--role <member|admin>] [--expires-at <iso8601>]
14
+ corelayer api-keys create --name <name> [--expires-at <iso8601>]
15
15
 
16
16
  SUBCOMMANDS:
17
17
  create Create a new API key and print the raw key once
18
18
 
19
19
  OPTIONS:
20
20
  --name <name> Display name for the API key
21
- --role <role> member or admin (default: member)
22
21
  --expires-at <value> Optional ISO timestamp for key expiry
23
22
  --json Output as JSON
24
23
  -h, --help Print help
25
24
 
25
+ NOTES:
26
+ The new key inherits your organization role. Admins get admin keys;
27
+ everyone else gets member keys. The role is not configurable.
28
+
26
29
  EXAMPLES:
27
30
  corelayer api-keys create --name "Claude Desktop MCP"
28
- corelayer api-keys create --name "Codex MCP" --role member --json
31
+ corelayer api-keys create --name "Codex MCP" --json
29
32
  `);
30
33
  }
31
34
  export async function runApiKeys(args, ctx) {
@@ -45,23 +48,11 @@ export async function runApiKeys(args, ctx) {
45
48
  if (!name) {
46
49
  fail("Usage: corelayer api-keys create --name <name> [options]");
47
50
  }
48
- const role = readFlag(args, "--role") || "member";
49
- if (role !== "member" && role !== "admin") {
50
- fail("role must be member or admin");
51
- }
52
51
  const expiresAt = readFlag(args, "--expires-at");
53
- const apiUrl = resolveApiUrl(ctx.apiUrlOverride || readConfig().apiUrl);
54
- const { CorelayerClient } = await loadSharedSdk();
55
- const client = new CorelayerClient({
56
- apiKey: token,
57
- apiUrl,
58
- timeoutMs: 30_000,
59
- }, {
60
- userAgent: "corelayer-cli/0.1.0",
61
- });
52
+ const apiUrl = resolveApiUrl(ctx.apiUrlOverride);
53
+ const client = new CorelayerClient(apiUrl, token);
62
54
  const created = await client.createApiKey({
63
- name,
64
- role,
55
+ name: name,
65
56
  expiresAt,
66
57
  });
67
58
  if (ctx.json) {
@@ -101,6 +101,27 @@ export class CorelayerClient {
101
101
  async listGroups() {
102
102
  return this.request("GET", "/api/v1/groups");
103
103
  }
104
+ async createApiKey(params) {
105
+ const data = await this.request("POST", "/api/v1/api-keys", {
106
+ name: params.name,
107
+ expires_at: params.expiresAt ?? null,
108
+ });
109
+ return {
110
+ apiKey: {
111
+ id: data.apiKey.id,
112
+ name: data.apiKey.name,
113
+ role: data.apiKey.role,
114
+ keyPrefix: data.apiKey.key_prefix,
115
+ lastUsedAt: data.apiKey.last_used_at ?? null,
116
+ expiresAt: data.apiKey.expires_at ?? null,
117
+ createdAt: data.apiKey.created_at,
118
+ createdBy: data.apiKey.created_by ?? null,
119
+ revokedAt: data.apiKey.revoked_at ?? null,
120
+ revokedBy: data.apiKey.revoked_by ?? null,
121
+ },
122
+ rawKey: data.rawKey,
123
+ };
124
+ }
104
125
  async listIntegrations(groupId) {
105
126
  const params = new URLSearchParams();
106
127
  if (groupId) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@corelayer-ai/cli",
3
- "version": "0.4.1",
3
+ "version": "0.4.3",
4
4
  "description": "Corelayer CLI",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,23 +0,0 @@
1
- import path from "node:path";
2
- import { fileURLToPath, pathToFileURL } from "node:url";
3
- let cachedModulePromise = null;
4
- function resolveSharedSdkPath() {
5
- const currentFilePath = fileURLToPath(import.meta.url);
6
- const currentDir = path.dirname(currentFilePath);
7
- const isBuiltCli = currentDir.includes(`${path.sep}dist${path.sep}`);
8
- const target = isBuiltCli
9
- ? path.resolve(currentDir, "../../../dist/src/lib/corelayer-sdk/index.js")
10
- : path.resolve(currentDir, "../../../src/lib/corelayer-sdk/index.js");
11
- return pathToFileURL(target).href;
12
- }
13
- export async function loadSharedSdk() {
14
- if (!cachedModulePromise) {
15
- const sdkPath = resolveSharedSdkPath();
16
- cachedModulePromise = import(sdkPath).catch(error => {
17
- throw new Error(`Could not load the Corelayer SDK from ${sdkPath}. ` +
18
- `Make sure the server has been built with npm run build. ` +
19
- `Original error: ${error instanceof Error ? error.message : String(error)}`);
20
- });
21
- }
22
- return cachedModulePromise;
23
- }