@project-ajax/sdk 0.0.60 → 0.0.62

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.
Files changed (150) hide show
  1. package/dist/index.d.ts +0 -1
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +0 -2
  4. package/package.json +4 -16
  5. package/src/index.ts +0 -1
  6. package/dist/capabilities/slashCommand.d.ts +0 -56
  7. package/dist/capabilities/slashCommand.d.ts.map +0 -1
  8. package/dist/capabilities/slashCommand.js +0 -32
  9. package/dist/cli/api/client.d.ts +0 -212
  10. package/dist/cli/api/client.d.ts.map +0 -1
  11. package/dist/cli/api/client.js +0 -330
  12. package/dist/cli/api/result.d.ts +0 -43
  13. package/dist/cli/api/result.d.ts.map +0 -1
  14. package/dist/cli/api/result.js +0 -43
  15. package/dist/cli/bin/cli.d.ts +0 -3
  16. package/dist/cli/bin/cli.d.ts.map +0 -1
  17. package/dist/cli/bin/cli.js +0 -5
  18. package/dist/cli/commands/auth.d.ts +0 -2
  19. package/dist/cli/commands/auth.d.ts.map +0 -1
  20. package/dist/cli/commands/auth.impl.d.ts +0 -5
  21. package/dist/cli/commands/auth.impl.d.ts.map +0 -1
  22. package/dist/cli/commands/auth.impl.js +0 -45
  23. package/dist/cli/commands/auth.impl.test.d.ts +0 -2
  24. package/dist/cli/commands/auth.impl.test.d.ts.map +0 -1
  25. package/dist/cli/commands/auth.js +0 -56
  26. package/dist/cli/commands/bundle.d.ts +0 -2
  27. package/dist/cli/commands/bundle.d.ts.map +0 -1
  28. package/dist/cli/commands/bundle.impl.d.ts +0 -2
  29. package/dist/cli/commands/bundle.impl.d.ts.map +0 -1
  30. package/dist/cli/commands/bundle.impl.js +0 -21
  31. package/dist/cli/commands/bundle.impl.test.d.ts +0 -2
  32. package/dist/cli/commands/bundle.impl.test.d.ts.map +0 -1
  33. package/dist/cli/commands/bundle.js +0 -23
  34. package/dist/cli/commands/capabilities.d.ts +0 -2
  35. package/dist/cli/commands/capabilities.d.ts.map +0 -1
  36. package/dist/cli/commands/capabilities.impl.d.ts +0 -3
  37. package/dist/cli/commands/capabilities.impl.d.ts.map +0 -1
  38. package/dist/cli/commands/capabilities.impl.js +0 -40
  39. package/dist/cli/commands/capabilities.js +0 -24
  40. package/dist/cli/commands/connect.d.ts +0 -2
  41. package/dist/cli/commands/connect.d.ts.map +0 -1
  42. package/dist/cli/commands/connect.impl.d.ts +0 -6
  43. package/dist/cli/commands/connect.impl.d.ts.map +0 -1
  44. package/dist/cli/commands/connect.impl.js +0 -116
  45. package/dist/cli/commands/connect.js +0 -78
  46. package/dist/cli/commands/deploy.d.ts +0 -3
  47. package/dist/cli/commands/deploy.d.ts.map +0 -1
  48. package/dist/cli/commands/deploy.impl.d.ts +0 -6
  49. package/dist/cli/commands/deploy.impl.d.ts.map +0 -1
  50. package/dist/cli/commands/deploy.impl.js +0 -60
  51. package/dist/cli/commands/deploy.impl.test.d.ts +0 -2
  52. package/dist/cli/commands/deploy.impl.test.d.ts.map +0 -1
  53. package/dist/cli/commands/deploy.js +0 -22
  54. package/dist/cli/commands/env.d.ts +0 -2
  55. package/dist/cli/commands/env.d.ts.map +0 -1
  56. package/dist/cli/commands/env.impl.d.ts +0 -11
  57. package/dist/cli/commands/env.impl.d.ts.map +0 -1
  58. package/dist/cli/commands/env.impl.js +0 -62
  59. package/dist/cli/commands/env.js +0 -39
  60. package/dist/cli/commands/exec.d.ts +0 -3
  61. package/dist/cli/commands/exec.d.ts.map +0 -1
  62. package/dist/cli/commands/exec.impl.d.ts +0 -7
  63. package/dist/cli/commands/exec.impl.d.ts.map +0 -1
  64. package/dist/cli/commands/exec.impl.js +0 -123
  65. package/dist/cli/commands/exec.js +0 -30
  66. package/dist/cli/commands/runs.d.ts +0 -2
  67. package/dist/cli/commands/runs.d.ts.map +0 -1
  68. package/dist/cli/commands/runs.impl.d.ts +0 -4
  69. package/dist/cli/commands/runs.impl.d.ts.map +0 -1
  70. package/dist/cli/commands/runs.impl.js +0 -71
  71. package/dist/cli/commands/runs.js +0 -45
  72. package/dist/cli/commands/secrets.d.ts +0 -2
  73. package/dist/cli/commands/secrets.d.ts.map +0 -1
  74. package/dist/cli/commands/secrets.impl.d.ts +0 -5
  75. package/dist/cli/commands/secrets.impl.d.ts.map +0 -1
  76. package/dist/cli/commands/secrets.impl.js +0 -99
  77. package/dist/cli/commands/secrets.js +0 -64
  78. package/dist/cli/commands/utils/testing.d.ts +0 -13
  79. package/dist/cli/commands/utils/testing.d.ts.map +0 -1
  80. package/dist/cli/commands/utils/testing.js +0 -58
  81. package/dist/cli/config.d.ts +0 -63
  82. package/dist/cli/config.d.ts.map +0 -1
  83. package/dist/cli/config.js +0 -194
  84. package/dist/cli/config.test.d.ts +0 -2
  85. package/dist/cli/config.test.d.ts.map +0 -1
  86. package/dist/cli/context.d.ts +0 -15
  87. package/dist/cli/context.d.ts.map +0 -1
  88. package/dist/cli/context.js +0 -16
  89. package/dist/cli/deploy.d.ts +0 -37
  90. package/dist/cli/deploy.d.ts.map +0 -1
  91. package/dist/cli/deploy.js +0 -100
  92. package/dist/cli/flags.d.ts +0 -21
  93. package/dist/cli/flags.d.ts.map +0 -1
  94. package/dist/cli/flags.js +0 -49
  95. package/dist/cli/handler.d.ts +0 -14
  96. package/dist/cli/handler.d.ts.map +0 -1
  97. package/dist/cli/handler.js +0 -32
  98. package/dist/cli/io.d.ts +0 -55
  99. package/dist/cli/io.d.ts.map +0 -1
  100. package/dist/cli/io.js +0 -96
  101. package/dist/cli/routes.d.ts +0 -2
  102. package/dist/cli/routes.d.ts.map +0 -1
  103. package/dist/cli/routes.js +0 -62
  104. package/dist/cli/utils/array.d.ts +0 -2
  105. package/dist/cli/utils/array.d.ts.map +0 -1
  106. package/dist/cli/utils/array.js +0 -10
  107. package/dist/cli/utils/openUrl.d.ts +0 -4
  108. package/dist/cli/utils/openUrl.d.ts.map +0 -1
  109. package/dist/cli/utils/openUrl.js +0 -43
  110. package/dist/cli/utils/string.d.ts +0 -2
  111. package/dist/cli/utils/string.d.ts.map +0 -1
  112. package/dist/cli/utils/string.js +0 -12
  113. package/src/capabilities/slashCommand.ts +0 -71
  114. package/src/cli/api/client.ts +0 -628
  115. package/src/cli/api/result.ts +0 -71
  116. package/src/cli/bin/cli.ts +0 -7
  117. package/src/cli/commands/.cursor/rules/testing-commands.mdc +0 -212
  118. package/src/cli/commands/auth.impl.test.ts +0 -228
  119. package/src/cli/commands/auth.impl.ts +0 -56
  120. package/src/cli/commands/auth.ts +0 -63
  121. package/src/cli/commands/bundle.impl.test.ts +0 -143
  122. package/src/cli/commands/bundle.impl.ts +0 -21
  123. package/src/cli/commands/bundle.ts +0 -23
  124. package/src/cli/commands/capabilities.impl.ts +0 -47
  125. package/src/cli/commands/capabilities.ts +0 -25
  126. package/src/cli/commands/connect.impl.ts +0 -149
  127. package/src/cli/commands/connect.ts +0 -80
  128. package/src/cli/commands/deploy.impl.test.ts +0 -254
  129. package/src/cli/commands/deploy.impl.ts +0 -73
  130. package/src/cli/commands/deploy.ts +0 -22
  131. package/src/cli/commands/env.impl.ts +0 -88
  132. package/src/cli/commands/env.ts +0 -38
  133. package/src/cli/commands/exec.impl.ts +0 -171
  134. package/src/cli/commands/exec.ts +0 -32
  135. package/src/cli/commands/runs.impl.ts +0 -87
  136. package/src/cli/commands/runs.ts +0 -49
  137. package/src/cli/commands/secrets.impl.ts +0 -130
  138. package/src/cli/commands/secrets.ts +0 -73
  139. package/src/cli/commands/utils/testing.ts +0 -66
  140. package/src/cli/config.test.ts +0 -108
  141. package/src/cli/config.ts +0 -265
  142. package/src/cli/context.ts +0 -26
  143. package/src/cli/deploy.ts +0 -190
  144. package/src/cli/flags.ts +0 -72
  145. package/src/cli/handler.ts +0 -68
  146. package/src/cli/io.ts +0 -132
  147. package/src/cli/routes.ts +0 -61
  148. package/src/cli/utils/array.ts +0 -7
  149. package/src/cli/utils/openUrl.ts +0 -53
  150. package/src/cli/utils/string.ts +0 -9
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=config.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"config.test.d.ts","sourceRoot":"","sources":["../../src/cli/config.test.ts"],"names":[],"mappings":""}
@@ -1,15 +0,0 @@
1
- import * as fs from "node:fs";
2
- import * as os from "node:os";
3
- import * as path from "node:path";
4
- import type { StricliAutoCompleteContext } from "@stricli/auto-complete";
5
- import type { CommandContext } from "@stricli/core";
6
- import { IO } from "./io.js";
7
- export interface LocalContext extends CommandContext, StricliAutoCompleteContext {
8
- readonly fs: typeof fs;
9
- readonly io: IO;
10
- readonly os: typeof os;
11
- readonly path: typeof path;
12
- readonly process: NodeJS.Process;
13
- }
14
- export declare function buildContext(process: NodeJS.Process): LocalContext;
15
- //# sourceMappingURL=context.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/cli/context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AACzE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAC;AAE7B,MAAM,WAAW,YAChB,SAAQ,cAAc,EACrB,0BAA0B;IAC3B,QAAQ,CAAC,EAAE,EAAE,OAAO,EAAE,CAAC;IACvB,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC;IAChB,QAAQ,CAAC,EAAE,EAAE,OAAO,EAAE,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,OAAO,IAAI,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC;CACjC;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,OAAO,GAAG,YAAY,CAQlE"}
@@ -1,16 +0,0 @@
1
- import * as fs from "node:fs";
2
- import * as os from "node:os";
3
- import * as path from "node:path";
4
- import { IO } from "./io.js";
5
- function buildContext(process) {
6
- return {
7
- fs,
8
- io: new IO({ debugEnabled: false }),
9
- os,
10
- path,
11
- process
12
- };
13
- }
14
- export {
15
- buildContext
16
- };
@@ -1,37 +0,0 @@
1
- import type { ApiError, Environment } from "./api/client.js";
2
- import { Result } from "./api/result.js";
3
- import type { AuthedContext } from "./handler.js";
4
- export interface BaseDeployOptions {
5
- /**
6
- * Path to the worker directory to deploy
7
- */
8
- workerPath: string;
9
- /**
10
- * API token for authentication
11
- */
12
- token: string;
13
- /**
14
- * Environment to deploy to
15
- */
16
- environment: Environment;
17
- }
18
- export interface CreateDeployOptions extends BaseDeployOptions {
19
- /**
20
- * Name of the worker (if it has not yet been created)
21
- */
22
- name: string;
23
- }
24
- export interface UpdateDeployOptions extends BaseDeployOptions {
25
- /**
26
- * ID of the worker to update
27
- */
28
- workerId: string;
29
- }
30
- export type DeployOptions = CreateDeployOptions | UpdateDeployOptions;
31
- /**
32
- * Deploy a worker to the specified environment
33
- */
34
- export declare function deployWorker(context: AuthedContext, options: DeployOptions): Promise<Result<{
35
- workerId: string;
36
- }, ApiError>>;
37
- //# sourceMappingURL=deploy.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../src/cli/deploy.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC7D,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEzC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAElD,MAAM,WAAW,iBAAiB;IACjC;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,WAAW,EAAE,WAAW,CAAC;CACzB;AAED,MAAM,WAAW,mBAAoB,SAAQ,iBAAiB;IAC7D;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,mBAAoB,SAAQ,iBAAiB;IAC7D;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,MAAM,aAAa,GAAG,mBAAmB,GAAG,mBAAmB,CAAC;AAEtE;;GAEG;AACH,wBAAsB,YAAY,CACjC,OAAO,EAAE,aAAa,EACtB,OAAO,EAAE,aAAa,GACpB,OAAO,CAAC,MAAM,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,EAAE,QAAQ,CAAC,CAAC,CAkEjD"}
@@ -1,100 +0,0 @@
1
- import * as childProcess from "node:child_process";
2
- import * as fs from "node:fs";
3
- import * as path from "node:path";
4
- import * as esbuild from "esbuild";
5
- import { Result } from "./api/result.js";
6
- async function deployWorker(context, options) {
7
- const { workerPath } = options;
8
- const absPath = path.resolve(process.cwd(), workerPath);
9
- context.io.debug(`Deploying worker from: ${absPath}`);
10
- const client = context.apiClient;
11
- let uploadUrl;
12
- let uploadFields;
13
- let workerId;
14
- if ("workerId" in options) {
15
- context.io.writeErr(`Updating worker...`);
16
- workerId = options.workerId;
17
- const updateResult = await client.updateWorkerBundle(workerId);
18
- if (Result.isSuccess(updateResult)) {
19
- const res = Result.unwrap(updateResult);
20
- uploadUrl = res.url;
21
- uploadFields = res.fields;
22
- } else {
23
- context.io.writeErr(
24
- "Failed to generate pre-signed upload URL for worker bundle:"
25
- );
26
- throw new Error(updateResult.error.message);
27
- }
28
- } else {
29
- context.io.writeErr(`Creating worker...`);
30
- const createResult = await client.createWorker(options.name);
31
- if (Result.isSuccess(createResult)) {
32
- const res = Result.unwrap(createResult);
33
- uploadUrl = res.url;
34
- uploadFields = res.fields;
35
- workerId = res.worker.workerId;
36
- } else {
37
- console.error("Failed to create worker:");
38
- throw new Error(createResult.error.message);
39
- }
40
- }
41
- context.io.debug(`Generated upload URL: ${uploadUrl}`);
42
- context.io.writeErr("Building worker bundle...");
43
- const archivePath = await buildWorkerBundle(context, absPath);
44
- context.io.debug(`Created bundle at: ${archivePath}`);
45
- context.io.writeErr("Uploading bundle...");
46
- await uploadBundle(uploadUrl, uploadFields, archivePath);
47
- context.io.debug("Upload complete");
48
- context.io.writeErr("Fetching and saving worker capabilities...");
49
- const capabilitiesResult = await client.fetchAndSaveCapabilities(workerId);
50
- if (Result.isSuccess(capabilitiesResult)) {
51
- return Result.success({ workerId });
52
- } else {
53
- return capabilitiesResult;
54
- }
55
- }
56
- async function buildWorkerBundle(context, workerPath) {
57
- const entrypoint = "src/index.ts";
58
- if (!fs.existsSync(path.join(workerPath, entrypoint))) {
59
- throw new Error(`Entrypoint not found: ${entrypoint}`);
60
- }
61
- const outdir = fs.mkdtempSync("/tmp/workers-build-");
62
- esbuild.buildSync({
63
- entryPoints: [entrypoint],
64
- absWorkingDir: workerPath,
65
- bundle: true,
66
- outdir,
67
- platform: "node"
68
- });
69
- context.io.debug(`Built bundle to: ${outdir}`);
70
- const archiveDir = fs.mkdtempSync("/tmp/workers-archive-");
71
- const archivePath = path.join(archiveDir, "archive.tar.gz");
72
- childProcess.execSync(`tar -czf ${archivePath} -C ${outdir} .`);
73
- return archivePath;
74
- }
75
- async function uploadBundle(url, fields, archivePath) {
76
- const formData = new FormData();
77
- for (const [key, value] of Object.entries(fields)) {
78
- formData.append(key, value);
79
- }
80
- const fileBuffer = fs.readFileSync(archivePath);
81
- formData.append(
82
- "file",
83
- new Blob([new Uint8Array(fileBuffer)]),
84
- "archive.tar.gz"
85
- );
86
- const response = await fetch(url, {
87
- method: "POST",
88
- body: formData
89
- });
90
- if (!response.ok) {
91
- const errorText = await response.text();
92
- throw new Error(
93
- `Failed to upload bundle: ${response.status} ${response.statusText}
94
- ${errorText}`
95
- );
96
- }
97
- }
98
- export {
99
- deployWorker
100
- };
@@ -1,21 +0,0 @@
1
- import type { TypedFlagParameter } from "@stricli/core";
2
- import { type Environment } from "./config.js";
3
- import type { LocalContext } from "./context.js";
4
- export interface GlobalFlags {
5
- config?: string;
6
- debug: boolean;
7
- env?: Environment;
8
- "base-url"?: string;
9
- token?: string;
10
- "worker-id"?: string;
11
- }
12
- export declare const globalFlags: {
13
- [K in keyof Required<GlobalFlags>]: TypedFlagParameter<GlobalFlags[K], LocalContext>;
14
- };
15
- export interface FormatFlags {
16
- plain: boolean;
17
- }
18
- export declare const formatFlags: {
19
- [K in keyof Required<FormatFlags>]: TypedFlagParameter<FormatFlags[K], LocalContext>;
20
- };
21
- //# sourceMappingURL=flags.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"flags.d.ts","sourceRoot":"","sources":["../../src/cli/flags.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,KAAK,WAAW,EAAgB,MAAM,aAAa,CAAC;AAC7D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjD,MAAM,WAAW,WAAW;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,OAAO,CAAC;IACf,GAAG,CAAC,EAAE,WAAW,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,eAAO,MAAM,WAAW,EAAE;KACxB,CAAC,IAAI,MAAM,QAAQ,CAAC,WAAW,CAAC,GAAG,kBAAkB,CACrD,WAAW,CAAC,CAAC,CAAC,EACd,YAAY,CACZ;CAqCD,CAAC;AAEF,MAAM,WAAW,WAAW;IAC3B,KAAK,EAAE,OAAO,CAAC;CACf;AAED,eAAO,MAAM,WAAW,EAAE;KACxB,CAAC,IAAI,MAAM,QAAQ,CAAC,WAAW,CAAC,GAAG,kBAAkB,CACrD,WAAW,CAAC,CAAC,CAAC,EACd,YAAY,CACZ;CAOD,CAAC"}
package/dist/cli/flags.js DELETED
@@ -1,49 +0,0 @@
1
- import { Environments } from "./config.js";
2
- const globalFlags = {
3
- config: {
4
- kind: "parsed",
5
- parse: String,
6
- brief: "The path to the config file to use",
7
- optional: true
8
- },
9
- debug: {
10
- kind: "boolean",
11
- brief: "Enable debug logging",
12
- default: false
13
- },
14
- env: {
15
- kind: "enum",
16
- values: Environments,
17
- brief: "The environment to use for the command",
18
- optional: true
19
- },
20
- "base-url": {
21
- kind: "parsed",
22
- parse: String,
23
- brief: "The base URL to use for all API requests",
24
- optional: true
25
- },
26
- token: {
27
- kind: "parsed",
28
- parse: String,
29
- brief: "The token to use for authentication",
30
- optional: true
31
- },
32
- "worker-id": {
33
- kind: "parsed",
34
- parse: String,
35
- brief: "The ID of the worker to use for the command",
36
- optional: true
37
- }
38
- };
39
- const formatFlags = {
40
- plain: {
41
- kind: "boolean",
42
- brief: "Output the results in plain text format",
43
- default: false
44
- }
45
- };
46
- export {
47
- formatFlags,
48
- globalFlags
49
- };
@@ -1,14 +0,0 @@
1
- import type { BaseArgs } from "@stricli/core";
2
- import { ApiClient } from "./api/client.js";
3
- import { Config } from "./config.js";
4
- import type { LocalContext } from "./context.js";
5
- import type { GlobalFlags } from "./flags.js";
6
- export interface HandlerContext extends LocalContext {
7
- config: Config;
8
- }
9
- export interface AuthedContext extends HandlerContext {
10
- apiClient: ApiClient;
11
- }
12
- export declare function buildHandler<const FLAGS, const ARGS extends BaseArgs = []>(handler: (this: HandlerContext, flags: FLAGS, ...args: ARGS) => Promise<void> | void): (this: LocalContext, flags: GlobalFlags & FLAGS, ...args: ARGS) => Promise<void>;
13
- export declare function buildAuthedHandler<const FLAGS, const ARGS extends BaseArgs = []>(handler: (this: AuthedContext, flags: FLAGS, ...args: ARGS) => Promise<void> | void): (this: LocalContext, flags: GlobalFlags & FLAGS, ...args: ARGS) => Promise<void>;
14
- //# sourceMappingURL=handler.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../src/cli/handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,MAAM,WAAW,cAAe,SAAQ,YAAY;IACnD,MAAM,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,aAAc,SAAQ,cAAc;IACpD,SAAS,EAAE,SAAS,CAAC;CACrB;AAED,wBAAgB,YAAY,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,SAAS,QAAQ,GAAG,EAAE,EACzE,OAAO,EAAE,CACR,IAAI,EAAE,cAAc,EACpB,KAAK,EAAE,KAAK,EACZ,GAAG,IAAI,EAAE,IAAI,KACT,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,IAGxB,MAAM,YAAY,EAClB,OAAO,WAAW,GAAG,KAAK,EAC1B,GAAG,MAAM,IAAI,mBAiBd;AAED,wBAAgB,kBAAkB,CACjC,KAAK,CAAC,KAAK,EACX,KAAK,CAAC,IAAI,SAAS,QAAQ,GAAG,EAAE,EAEhC,OAAO,EAAE,CACR,IAAI,EAAE,aAAa,EACnB,KAAK,EAAE,KAAK,EACZ,GAAG,IAAI,EAAE,IAAI,KACT,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,UA7BlB,YAAY,8DA6CnB"}
@@ -1,32 +0,0 @@
1
- import { ApiClient } from "./api/client.js";
2
- import { Config } from "./config.js";
3
- function buildHandler(handler) {
4
- return async function(flags, ...args) {
5
- const configFilePath = flags.config ?? this.process.env.WORKERS_CONFIG_FILE_PATH ?? "./workers.json";
6
- const config = await Config.load({
7
- configFilePath,
8
- processEnv: process.env,
9
- flags
10
- });
11
- this.io.debugEnabled = flags.debug;
12
- await handler.call({ ...this, config }, flags, ...args);
13
- };
14
- }
15
- function buildAuthedHandler(handler) {
16
- return buildHandler(function(flags, ...args) {
17
- const { token, cellId } = this.config.tokenInfo;
18
- const environment = this.config.environment;
19
- const client = new ApiClient({
20
- token,
21
- environment,
22
- baseUrl: this.config.baseUrl,
23
- cellId,
24
- writer: this.io
25
- });
26
- return handler.call({ ...this, apiClient: client }, flags, ...args);
27
- });
28
- }
29
- export {
30
- buildAuthedHandler,
31
- buildHandler
32
- };
package/dist/cli/io.d.ts DELETED
@@ -1,55 +0,0 @@
1
- import * as prompts from "@inquirer/prompts";
2
- import { type TableCell } from "@visulima/tabular";
3
- export interface WriterOptions {
4
- debugEnabled: boolean;
5
- }
6
- export interface TableOptions {
7
- headers: TableCell[] | TableCell[][];
8
- rows: TableCell[][];
9
- plain: boolean;
10
- }
11
- type WithSafety<T> = T & {
12
- noTTY: string;
13
- };
14
- /**
15
- * IO manages safe, consistent, input and output patterns for the CLI.
16
- */
17
- export declare class IO {
18
- #private;
19
- debugEnabled: boolean;
20
- constructor(options: WriterOptions);
21
- /**
22
- * Writes a debug message to standard error.
23
- *
24
- * @param args The arguments to write.
25
- */
26
- debug(...args: Parameters<typeof console.log>): void;
27
- /**
28
- * Writes a message to standard out.
29
- *
30
- * @param args The arguments to write.
31
- */
32
- writeOut(...args: Parameters<typeof process.stdout.write>): void;
33
- /**
34
- * Writes a message to standard error.
35
- *
36
- * @param args The arguments to write.
37
- */
38
- writeErr(...args: Parameters<typeof process.stderr.write>): void;
39
- /**
40
- * Writes a table to standard out.
41
- *
42
- * @param tableConfig The table configuration.
43
- */
44
- writeTableOut(tableConfig: TableOptions): void;
45
- /**
46
- * Writes a table to standard error.
47
- *
48
- * @param tableConfig The table configuration.
49
- */
50
- writeTableErr(tableConfig: TableOptions): void;
51
- confirm(config: WithSafety<Parameters<typeof prompts.confirm>[0]>): Promise<boolean | void>;
52
- input(config: WithSafety<Parameters<typeof prompts.input>[0]>): Promise<string | void>;
53
- }
54
- export {};
55
- //# sourceMappingURL=io.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"io.d.ts","sourceRoot":"","sources":["../../src/cli/io.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,OAAO,MAAM,mBAAmB,CAAC;AAE7C,OAAO,EAAe,KAAK,SAAS,EAAkB,MAAM,mBAAmB,CAAC;AAEhF,MAAM,WAAW,aAAa;IAC7B,YAAY,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,WAAW,YAAY;IAC5B,OAAO,EAAE,SAAS,EAAE,GAAG,SAAS,EAAE,EAAE,CAAC;IACrC,IAAI,EAAE,SAAS,EAAE,EAAE,CAAC;IACpB,KAAK,EAAE,OAAO,CAAC;CACf;AAED,KAAK,UAAU,CAAC,CAAC,IAAI,CAAC,GAAG;IACxB,KAAK,EAAE,MAAM,CAAC;CACd,CAAC;AAEF;;GAEG;AACH,qBAAa,EAAE;;IACd,YAAY,EAAE,OAAO,CAAC;gBAEV,OAAO,EAAE,aAAa;IAIlC;;;;OAIG;IACH,KAAK,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,OAAO,OAAO,CAAC,GAAG,CAAC;IAW7C;;;;OAIG;IACH,QAAQ,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,OAAO,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC;IAIzD;;;;OAIG;IACH,QAAQ,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,OAAO,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC;IAIzD;;;;OAIG;IACH,aAAa,CAAC,WAAW,EAAE,YAAY;IAKvC;;;;OAIG;IACH,aAAa,CAAC,WAAW,EAAE,YAAY;IAKvC,OAAO,CAAC,MAAM,EAAE,UAAU,CAAC,UAAU,CAAC,OAAO,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;IAKjE,KAAK,CAAC,MAAM,EAAE,UAAU,CAAC,UAAU,CAAC,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;CAuC7D"}
package/dist/cli/io.js DELETED
@@ -1,96 +0,0 @@
1
- import * as prompts from "@inquirer/prompts";
2
- import { createTable } from "@visulima/tabular";
3
- class IO {
4
- debugEnabled;
5
- constructor(options) {
6
- this.debugEnabled = options.debugEnabled;
7
- }
8
- /**
9
- * Writes a debug message to standard error.
10
- *
11
- * @param args The arguments to write.
12
- */
13
- debug(...args) {
14
- if (this.debugEnabled) {
15
- args.join(" ").split("\n").forEach((line) => {
16
- this.writeErr(`[debug] ${line}`);
17
- });
18
- }
19
- }
20
- /**
21
- * Writes a message to standard out.
22
- *
23
- * @param args The arguments to write.
24
- */
25
- writeOut(...args) {
26
- process.stdout.write(`${args.join(" ")}
27
- `);
28
- }
29
- /**
30
- * Writes a message to standard error.
31
- *
32
- * @param args The arguments to write.
33
- */
34
- writeErr(...args) {
35
- process.stderr.write(`${args.join(" ")}
36
- `);
37
- }
38
- /**
39
- * Writes a table to standard out.
40
- *
41
- * @param tableConfig The table configuration.
42
- */
43
- writeTableOut(tableConfig) {
44
- const content = this.#buildTable(tableConfig);
45
- this.writeOut(content);
46
- }
47
- /**
48
- * Writes a table to standard error.
49
- *
50
- * @param tableConfig The table configuration.
51
- */
52
- writeTableErr(tableConfig) {
53
- const content = this.#buildTable(tableConfig);
54
- this.writeErr(content);
55
- }
56
- confirm(config) {
57
- this.#ensureTTY(config.noTTY);
58
- return prompts.confirm(config).catch(this.#handlePromptExit.bind(this));
59
- }
60
- input(config) {
61
- this.#ensureTTY(config.noTTY);
62
- return prompts.input(config).catch(this.#handlePromptExit.bind(this));
63
- }
64
- #ensureTTY(noTTY) {
65
- if (!process.stdin.isTTY) {
66
- this.writeErr(noTTY);
67
- process.exit(1);
68
- }
69
- return true;
70
- }
71
- #handlePromptExit(err) {
72
- if (err instanceof Error && err.name === "ExitPromptError") {
73
- this.writeErr("\u{1F44B} Prompt cancelled. Goodbye!");
74
- process.exit(1);
75
- }
76
- throw err;
77
- }
78
- #buildTable(tableConfig) {
79
- if (tableConfig.plain) {
80
- return tableConfig.rows.map((row) => {
81
- return row.map((cell) => isTableItem(cell) ? cell.content : cell).join(" ");
82
- }).join("\n");
83
- } else {
84
- const table = createTable();
85
- table.setHeaders(tableConfig.headers);
86
- table.addRows(...tableConfig.rows);
87
- return table.toString();
88
- }
89
- }
90
- }
91
- function isTableItem(cell) {
92
- return typeof cell === "object";
93
- }
94
- export {
95
- IO
96
- };
@@ -1,2 +0,0 @@
1
- export declare const app: import("@stricli/core").Application<import("./context.js").LocalContext>;
2
- //# sourceMappingURL=routes.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../../src/cli/routes.ts"],"names":[],"mappings":"AA4CA,eAAO,MAAM,GAAG,0EAgBd,CAAC"}
@@ -1,62 +0,0 @@
1
- import { buildApplication, buildRouteMap, text_en } from "@stricli/core";
2
- import packageJson from "../../package.json" with { type: "json" };
3
- import { authCommands } from "./commands/auth.js";
4
- import { bundleCommands } from "./commands/bundle.js";
5
- import { capabilitiesCommands } from "./commands/capabilities.js";
6
- import { connectCommands } from "./commands/connect.js";
7
- import deploy from "./commands/deploy.js";
8
- import { envCommands } from "./commands/env.js";
9
- import exec from "./commands/exec.js";
10
- import { runsCommands } from "./commands/runs.js";
11
- import { secretsCommands } from "./commands/secrets.js";
12
- import { TokenNotSetError } from "./config.js";
13
- const routes = buildRouteMap({
14
- docs: {
15
- brief: "A CLI for the Project Ajax platform",
16
- fullDescription: `
17
- The Project Ajax CLI is a tool for managing workers, which run code written by
18
- you, other developers, or AI agents to perform automation tasks, such as syncing
19
- data, adding slash commands, or performing other actions.
20
-
21
- Most flags are configured either with a config file or flags, but environment
22
- variables can also be provided:
23
-
24
- - WORKERS_CONFIG_FILE_PATH: The path to the config file to use (e.g. ./workers.dev.json)
25
- - WORKERS_TOKEN: The token to use for authentication
26
- - WORKERS_ENVIRONMENT: The environment to use
27
- - WORKERS_WORKER_ID: The worker ID to use
28
- - WORKERS_BASE_URL: The base API URL to use
29
- `.trim()
30
- },
31
- routes: {
32
- auth: authCommands,
33
- capabilities: capabilitiesCommands,
34
- deploy,
35
- exec,
36
- connect: connectCommands,
37
- env: envCommands,
38
- runs: runsCommands,
39
- secrets: secretsCommands,
40
- bundle: bundleCommands
41
- }
42
- });
43
- const app = buildApplication(routes, {
44
- name: "workers",
45
- versionInfo: {
46
- currentVersion: packageJson.version
47
- },
48
- localization: {
49
- loadText: () => ({
50
- ...text_en,
51
- exceptionWhileRunningCommand(exc, ansiColor) {
52
- if (exc instanceof TokenNotSetError) {
53
- return exc.message;
54
- }
55
- return text_en.exceptionWhileRunningCommand(exc, ansiColor);
56
- }
57
- })
58
- }
59
- });
60
- export {
61
- app
62
- };
@@ -1,2 +0,0 @@
1
- export declare function chunkEvery<T>(array: readonly T[], size: number): T[][];
2
- //# sourceMappingURL=array.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"array.d.ts","sourceRoot":"","sources":["../../../src/cli/utils/array.ts"],"names":[],"mappings":"AAAA,wBAAgB,UAAU,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,EAAE,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,EAAE,EAAE,CAMtE"}
@@ -1,10 +0,0 @@
1
- function chunkEvery(array, size) {
2
- const result = [];
3
- for (let i = 0; i < array.length; i += size) {
4
- result.push(array.slice(i, i + size));
5
- }
6
- return result;
7
- }
8
- export {
9
- chunkEvery
10
- };
@@ -1,4 +0,0 @@
1
- import type { Environment } from "../config.js";
2
- export declare function openBrowserUrl(url: string): Promise<void>;
3
- export declare function openNotionUrl(env: Environment, url: string): Promise<void>;
4
- //# sourceMappingURL=openUrl.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"openUrl.d.ts","sourceRoot":"","sources":["../../../src/cli/utils/openUrl.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhD,wBAAsB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAc/D;AAED,wBAAsB,aAAa,CAClC,GAAG,EAAE,WAAW,EAChB,GAAG,EAAE,MAAM,GACT,OAAO,CAAC,IAAI,CAAC,CAgBf"}
@@ -1,43 +0,0 @@
1
- import { exec } from "node:child_process";
2
- import { existsSync } from "node:fs";
3
- async function openBrowserUrl(url) {
4
- const platform = process.platform;
5
- try {
6
- if (platform === "darwin") {
7
- exec(`open "${url}"`);
8
- } else if (platform === "win32") {
9
- exec(`start "" "${url}"`);
10
- } else {
11
- exec(`xdg-open "${url}"`);
12
- }
13
- } catch (error) {
14
- throw new Error(`Failed to open browser: ${error}`);
15
- }
16
- }
17
- async function openNotionUrl(env, url) {
18
- const platform = process.platform;
19
- if (platform === "darwin") {
20
- const appName = preferredNotionApp(env);
21
- if (appName) {
22
- try {
23
- exec(`open -a "${appName}" "${url}"`);
24
- return;
25
- } catch {
26
- }
27
- }
28
- }
29
- await openBrowserUrl(url);
30
- }
31
- function preferredNotionApp(env) {
32
- if (env === "prod" && existsSync("/Applications/Notion.app")) {
33
- return "Notion";
34
- }
35
- if (env === "dev" && existsSync("/Applications/Notion Dev.app")) {
36
- return "Notion Dev";
37
- }
38
- return null;
39
- }
40
- export {
41
- openBrowserUrl,
42
- openNotionUrl
43
- };
@@ -1,2 +0,0 @@
1
- export declare function pluralize(count: number, word: string, pluralWord?: string): string;
2
- //# sourceMappingURL=string.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"string.d.ts","sourceRoot":"","sources":["../../../src/cli/utils/string.ts"],"names":[],"mappings":"AAAA,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,UAQzE"}
@@ -1,12 +0,0 @@
1
- function pluralize(count, word, pluralWord) {
2
- if (count === 1) {
3
- return `${count} ${word}`;
4
- }
5
- if (!pluralWord) {
6
- return `${count} ${word}s`;
7
- }
8
- return `${count} ${pluralWord}`;
9
- }
10
- export {
11
- pluralize
12
- };