@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
package/src/cli/io.ts DELETED
@@ -1,132 +0,0 @@
1
- // biome-ignore lint/style/noRestrictedImports: This file contains safe wrappers for prompts.
2
- import * as prompts from "@inquirer/prompts";
3
- // biome-ignore lint/style/noRestrictedImports: This is the one allowed location for this import.
4
- import { createTable, type TableCell, type TableItem } from "@visulima/tabular";
5
-
6
- export interface WriterOptions {
7
- debugEnabled: boolean;
8
- }
9
-
10
- export interface TableOptions {
11
- headers: TableCell[] | TableCell[][];
12
- rows: TableCell[][];
13
- plain: boolean;
14
- }
15
-
16
- type WithSafety<T> = T & {
17
- noTTY: string;
18
- };
19
-
20
- /**
21
- * IO manages safe, consistent, input and output patterns for the CLI.
22
- */
23
- export class IO {
24
- debugEnabled: boolean;
25
-
26
- constructor(options: WriterOptions) {
27
- this.debugEnabled = options.debugEnabled;
28
- }
29
-
30
- /**
31
- * Writes a debug message to standard error.
32
- *
33
- * @param args The arguments to write.
34
- */
35
- debug(...args: Parameters<typeof console.log>) {
36
- if (this.debugEnabled) {
37
- args
38
- .join(" ")
39
- .split("\n")
40
- .forEach((line) => {
41
- this.writeErr(`[debug] ${line}`);
42
- });
43
- }
44
- }
45
-
46
- /**
47
- * Writes a message to standard out.
48
- *
49
- * @param args The arguments to write.
50
- */
51
- writeOut(...args: Parameters<typeof process.stdout.write>) {
52
- process.stdout.write(`${args.join(" ")}\n`);
53
- }
54
-
55
- /**
56
- * Writes a message to standard error.
57
- *
58
- * @param args The arguments to write.
59
- */
60
- writeErr(...args: Parameters<typeof process.stderr.write>) {
61
- process.stderr.write(`${args.join(" ")}\n`);
62
- }
63
-
64
- /**
65
- * Writes a table to standard out.
66
- *
67
- * @param tableConfig The table configuration.
68
- */
69
- writeTableOut(tableConfig: TableOptions) {
70
- const content = this.#buildTable(tableConfig);
71
- this.writeOut(content);
72
- }
73
-
74
- /**
75
- * Writes a table to standard error.
76
- *
77
- * @param tableConfig The table configuration.
78
- */
79
- writeTableErr(tableConfig: TableOptions) {
80
- const content = this.#buildTable(tableConfig);
81
- this.writeErr(content);
82
- }
83
-
84
- confirm(config: WithSafety<Parameters<typeof prompts.confirm>[0]>) {
85
- this.#ensureTTY(config.noTTY);
86
- return prompts.confirm(config).catch(this.#handlePromptExit.bind(this));
87
- }
88
-
89
- input(config: WithSafety<Parameters<typeof prompts.input>[0]>) {
90
- this.#ensureTTY(config.noTTY);
91
- return prompts.input(config).catch(this.#handlePromptExit.bind(this));
92
- }
93
-
94
- #ensureTTY(noTTY: string): true | never {
95
- if (!process.stdin.isTTY) {
96
- this.writeErr(noTTY);
97
- process.exit(1);
98
- }
99
-
100
- return true;
101
- }
102
-
103
- #handlePromptExit(err: unknown) {
104
- if (err instanceof Error && err.name === "ExitPromptError") {
105
- this.writeErr("👋 Prompt cancelled. Goodbye!");
106
- process.exit(1);
107
- }
108
-
109
- throw err;
110
- }
111
-
112
- #buildTable(tableConfig: TableOptions) {
113
- if (tableConfig.plain) {
114
- return tableConfig.rows
115
- .map((row) => {
116
- return row
117
- .map((cell) => (isTableItem(cell) ? cell.content : cell))
118
- .join("\t");
119
- })
120
- .join("\n");
121
- } else {
122
- const table = createTable();
123
- table.setHeaders(tableConfig.headers);
124
- table.addRows(...tableConfig.rows);
125
- return table.toString();
126
- }
127
- }
128
- }
129
-
130
- function isTableItem(cell: TableCell): cell is TableItem {
131
- return typeof cell === "object";
132
- }
package/src/cli/routes.ts DELETED
@@ -1,61 +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
-
14
- const routes = buildRouteMap({
15
- docs: {
16
- brief: "A CLI for the Project Ajax platform",
17
- fullDescription: `
18
- The Project Ajax CLI is a tool for managing workers, which run code written by
19
- you, other developers, or AI agents to perform automation tasks, such as syncing
20
- data, adding slash commands, or performing other actions.
21
-
22
- Most flags are configured either with a config file or flags, but environment
23
- variables can also be provided:
24
-
25
- - WORKERS_CONFIG_FILE_PATH: The path to the config file to use (e.g. ./workers.dev.json)
26
- - WORKERS_TOKEN: The token to use for authentication
27
- - WORKERS_ENVIRONMENT: The environment to use
28
- - WORKERS_WORKER_ID: The worker ID to use
29
- - WORKERS_BASE_URL: The base API URL to use
30
- `.trim(),
31
- },
32
- routes: {
33
- auth: authCommands,
34
- capabilities: capabilitiesCommands,
35
- deploy: deploy,
36
- exec: exec,
37
- connect: connectCommands,
38
- env: envCommands,
39
- runs: runsCommands,
40
- secrets: secretsCommands,
41
- bundle: bundleCommands,
42
- },
43
- });
44
-
45
- export const app = buildApplication(routes, {
46
- name: "workers",
47
- versionInfo: {
48
- currentVersion: packageJson.version,
49
- },
50
- localization: {
51
- loadText: () => ({
52
- ...text_en,
53
- exceptionWhileRunningCommand(exc: unknown, ansiColor: boolean): string {
54
- if (exc instanceof TokenNotSetError) {
55
- return exc.message;
56
- }
57
- return text_en.exceptionWhileRunningCommand(exc, ansiColor);
58
- },
59
- }),
60
- },
61
- });
@@ -1,7 +0,0 @@
1
- export function chunkEvery<T>(array: readonly T[], size: number): T[][] {
2
- const result: T[][] = [];
3
- for (let i = 0; i < array.length; i += size) {
4
- result.push(array.slice(i, i + size));
5
- }
6
- return result;
7
- }
@@ -1,53 +0,0 @@
1
- import { exec } from "node:child_process";
2
- import { existsSync } from "node:fs";
3
-
4
- import type { Environment } from "../config.js";
5
-
6
- export async function openBrowserUrl(url: string): Promise<void> {
7
- const platform = process.platform;
8
-
9
- try {
10
- if (platform === "darwin") {
11
- exec(`open "${url}"`);
12
- } else if (platform === "win32") {
13
- exec(`start "" "${url}"`);
14
- } else {
15
- exec(`xdg-open "${url}"`);
16
- }
17
- } catch (error) {
18
- throw new Error(`Failed to open browser: ${error}`);
19
- }
20
- }
21
-
22
- export async function openNotionUrl(
23
- env: Environment,
24
- url: string,
25
- ): Promise<void> {
26
- const platform = process.platform;
27
-
28
- if (platform === "darwin") {
29
- const appName = preferredNotionApp(env);
30
- if (appName) {
31
- try {
32
- exec(`open -a "${appName}" "${url}"`);
33
- return;
34
- } catch {
35
- // Fall back to the default browser below.
36
- }
37
- }
38
- }
39
-
40
- await openBrowserUrl(url);
41
- }
42
-
43
- function preferredNotionApp(env: Environment): string | null {
44
- if (env === "prod" && existsSync("/Applications/Notion.app")) {
45
- return "Notion";
46
- }
47
-
48
- if (env === "dev" && existsSync("/Applications/Notion Dev.app")) {
49
- return "Notion Dev";
50
- }
51
-
52
- return null;
53
- }
@@ -1,9 +0,0 @@
1
- export function pluralize(count: number, word: string, pluralWord?: string) {
2
- if (count === 1) {
3
- return `${count} ${word}`;
4
- }
5
- if (!pluralWord) {
6
- return `${count} ${word}s`;
7
- }
8
- return `${count} ${pluralWord}`;
9
- }