@usestatemachines/cli 0.0.0-stage → 0.1.0

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 (169) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +34 -2
  3. package/dist/agents/bundled.d.ts +5 -0
  4. package/dist/agents/bundled.js +6 -0
  5. package/dist/agents/destinations.d.ts +13 -0
  6. package/dist/agents/destinations.js +16 -0
  7. package/dist/api-internal.d.ts +62 -0
  8. package/dist/api-internal.js +348 -0
  9. package/dist/bin.d.ts +2 -0
  10. package/dist/bin.js +4 -0
  11. package/dist/command.d.ts +119 -0
  12. package/dist/command.js +195 -0
  13. package/dist/commands/api/command.d.ts +15 -0
  14. package/dist/commands/api/command.js +38 -0
  15. package/dist/commands/api/run.d.ts +4 -0
  16. package/dist/commands/api/run.js +24 -0
  17. package/dist/commands/apps/command.d.ts +19 -0
  18. package/dist/commands/apps/command.js +29 -0
  19. package/dist/commands/apps/list.d.ts +8 -0
  20. package/dist/commands/apps/list.js +10 -0
  21. package/dist/commands/connect/command.d.ts +34 -0
  22. package/dist/commands/connect/command.js +70 -0
  23. package/dist/commands/connect/run.d.ts +10 -0
  24. package/dist/commands/connect/run.js +71 -0
  25. package/dist/commands/doctor/command.d.ts +29 -0
  26. package/dist/commands/doctor/command.js +36 -0
  27. package/dist/commands/doctor/run.d.ts +13 -0
  28. package/dist/commands/doctor/run.js +12 -0
  29. package/dist/commands/env/command.d.ts +5 -0
  30. package/dist/commands/env/command.js +19 -0
  31. package/dist/commands/env/pull.d.ts +6 -0
  32. package/dist/commands/env/pull.js +6 -0
  33. package/dist/commands/environments/command.d.ts +121 -0
  34. package/dist/commands/environments/command.js +170 -0
  35. package/dist/commands/environments/create.d.ts +9 -0
  36. package/dist/commands/environments/create.js +42 -0
  37. package/dist/commands/environments/delete.d.ts +7 -0
  38. package/dist/commands/environments/delete.js +48 -0
  39. package/dist/commands/environments/get.d.ts +39 -0
  40. package/dist/commands/environments/get.js +5 -0
  41. package/dist/commands/environments/list.d.ts +41 -0
  42. package/dist/commands/environments/list.js +18 -0
  43. package/dist/commands/environments/wait.d.ts +39 -0
  44. package/dist/commands/environments/wait.js +21 -0
  45. package/dist/commands/init/command.d.ts +68 -0
  46. package/dist/commands/init/command.js +90 -0
  47. package/dist/commands/init/run.d.ts +8 -0
  48. package/dist/commands/init/run.js +422 -0
  49. package/dist/commands/link/command.d.ts +13 -0
  50. package/dist/commands/link/command.js +32 -0
  51. package/dist/commands/link/run.d.ts +12 -0
  52. package/dist/commands/link/run.js +7 -0
  53. package/dist/commands/login/command.d.ts +1 -0
  54. package/dist/commands/login/command.js +43 -0
  55. package/dist/commands/login/run.d.ts +30 -0
  56. package/dist/commands/login/run.js +43 -0
  57. package/dist/commands/login/schema.d.ts +33 -0
  58. package/dist/commands/login/schema.js +33 -0
  59. package/dist/commands/logout/command.d.ts +1 -0
  60. package/dist/commands/logout/command.js +24 -0
  61. package/dist/commands/logout/run.d.ts +10 -0
  62. package/dist/commands/logout/run.js +19 -0
  63. package/dist/commands/logout/schema.d.ts +10 -0
  64. package/dist/commands/logout/schema.js +10 -0
  65. package/dist/commands/profiles/command.d.ts +2 -0
  66. package/dist/commands/profiles/command.js +29 -0
  67. package/dist/commands/profiles/list.d.ts +20 -0
  68. package/dist/commands/profiles/list.js +10 -0
  69. package/dist/commands/profiles/schema.d.ts +24 -0
  70. package/dist/commands/profiles/schema.js +19 -0
  71. package/dist/commands/profiles/use.d.ts +7 -0
  72. package/dist/commands/profiles/use.js +7 -0
  73. package/dist/commands/requests/command.d.ts +39 -0
  74. package/dist/commands/requests/command.js +65 -0
  75. package/dist/commands/requests/get.d.ts +32 -0
  76. package/dist/commands/requests/get.js +15 -0
  77. package/dist/commands/requests/list.d.ts +27 -0
  78. package/dist/commands/requests/list.js +25 -0
  79. package/dist/commands/snapshots/command.d.ts +48 -0
  80. package/dist/commands/snapshots/command.js +80 -0
  81. package/dist/commands/snapshots/create.d.ts +7 -0
  82. package/dist/commands/snapshots/create.js +26 -0
  83. package/dist/commands/snapshots/delete.d.ts +34 -0
  84. package/dist/commands/snapshots/delete.js +8 -0
  85. package/dist/commands/snapshots/get.d.ts +35 -0
  86. package/dist/commands/snapshots/get.js +5 -0
  87. package/dist/commands/snapshots/list.d.ts +37 -0
  88. package/dist/commands/snapshots/list.js +10 -0
  89. package/dist/commands/unlink/command.d.ts +1 -0
  90. package/dist/commands/unlink/command.js +15 -0
  91. package/dist/commands/unlink/run.d.ts +7 -0
  92. package/dist/commands/unlink/run.js +8 -0
  93. package/dist/commands/whoami/command.d.ts +28 -0
  94. package/dist/commands/whoami/command.js +44 -0
  95. package/dist/commands/whoami/run.d.ts +5 -0
  96. package/dist/commands/whoami/run.js +39 -0
  97. package/dist/commands/workspaces/command.d.ts +33 -0
  98. package/dist/commands/workspaces/command.js +73 -0
  99. package/dist/commands/workspaces/list.d.ts +5 -0
  100. package/dist/commands/workspaces/list.js +42 -0
  101. package/dist/commands/workspaces/use.d.ts +5 -0
  102. package/dist/commands/workspaces/use.js +18 -0
  103. package/dist/config/project.d.ts +21 -0
  104. package/dist/config/project.js +105 -0
  105. package/dist/config/schema.d.ts +616 -0
  106. package/dist/config/schema.js +282 -0
  107. package/dist/context-types.d.ts +89 -0
  108. package/dist/context-types.js +56 -0
  109. package/dist/context.d.ts +13 -0
  110. package/dist/context.js +290 -0
  111. package/dist/credentials/sealing.d.ts +10 -0
  112. package/dist/credentials/sealing.js +72 -0
  113. package/dist/credentials/store.d.ts +17 -0
  114. package/dist/credentials/store.js +156 -0
  115. package/dist/doctor.d.ts +4 -0
  116. package/dist/doctor.js +239 -0
  117. package/dist/env-file.d.ts +10 -0
  118. package/dist/env-file.js +254 -0
  119. package/dist/errors.d.ts +784 -0
  120. package/dist/errors.js +459 -0
  121. package/dist/flags.d.ts +22 -0
  122. package/dist/flags.js +56 -0
  123. package/dist/generated/internal.d.ts +138 -0
  124. package/dist/generated/internal.js +2627 -0
  125. package/dist/generated/retry.d.ts +1 -0
  126. package/dist/generated/retry.js +11 -0
  127. package/dist/help.d.ts +408 -0
  128. package/dist/help.js +220 -0
  129. package/dist/io-types.d.ts +127 -0
  130. package/dist/io-types.js +1 -0
  131. package/dist/io.d.ts +13 -0
  132. package/dist/io.js +1017 -0
  133. package/dist/keys.d.ts +50 -0
  134. package/dist/keys.js +691 -0
  135. package/dist/link.d.ts +6 -0
  136. package/dist/link.js +58 -0
  137. package/dist/login.d.ts +92 -0
  138. package/dist/login.js +965 -0
  139. package/dist/main.d.ts +2 -0
  140. package/dist/main.js +126 -0
  141. package/dist/native-helper.d.ts +1 -0
  142. package/dist/native-helper.js +2 -0
  143. package/dist/output.d.ts +8 -0
  144. package/dist/output.js +135 -0
  145. package/dist/parser.d.ts +28 -0
  146. package/dist/parser.js +250 -0
  147. package/dist/program-types.d.ts +67 -0
  148. package/dist/program-types.js +14 -0
  149. package/dist/programs.d.ts +2 -0
  150. package/dist/programs.js +44 -0
  151. package/dist/project-roots.d.ts +3 -0
  152. package/dist/project-roots.js +26 -0
  153. package/dist/prompt.d.ts +3 -0
  154. package/dist/prompt.js +61 -0
  155. package/dist/registry.d.ts +2 -0
  156. package/dist/registry.js +44 -0
  157. package/dist/resources/create.d.ts +9 -0
  158. package/dist/resources/create.js +55 -0
  159. package/dist/resources/read.d.ts +15 -0
  160. package/dist/resources/read.js +69 -0
  161. package/dist/resources/schema.d.ts +177 -0
  162. package/dist/resources/schema.js +158 -0
  163. package/dist/text.d.ts +3 -0
  164. package/dist/text.js +19 -0
  165. package/dist/update.d.ts +22 -0
  166. package/dist/update.js +126 -0
  167. package/dist/version.d.ts +2 -0
  168. package/dist/version.js +2 -0
  169. package/package.json +52 -3
@@ -0,0 +1,32 @@
1
+ import { z } from 'zod';
2
+ import { defineCommand } from '../../command.js';
3
+ export const linkInputSchema = z.strictObject({
4
+ force: z.boolean().default(false),
5
+ });
6
+ export const linkResultSchema = z.strictObject({
7
+ path: z.string(),
8
+ organizationId: z.string(),
9
+ workspace: z.strictObject({ id: z.string(), name: z.string() }),
10
+ });
11
+ export const linkCommand = defineCommand({
12
+ name: ['link'],
13
+ summary: 'Link this repository to a workspace.',
14
+ need: 'account',
15
+ workspace: true,
16
+ destructive: false,
17
+ streams: false,
18
+ arguments: [],
19
+ flags: [
20
+ {
21
+ name: 'force',
22
+ key: 'force',
23
+ type: 'boolean',
24
+ negatedName: null,
25
+ description: 'Replace an existing repository link.',
26
+ },
27
+ ],
28
+ input: linkInputSchema,
29
+ result: linkResultSchema,
30
+ progress: z.never(),
31
+ load: () => import('./run.js'),
32
+ });
@@ -0,0 +1,12 @@
1
+ import type { z } from 'zod';
2
+ import type { AccountContext } from '../../context-types.js';
3
+ import type { linkInputSchema, linkResultSchema } from './command.js';
4
+ export declare function run(input: z.infer<typeof linkInputSchema>, context: AccountContext): Promise<{
5
+ path: string;
6
+ organizationId: string;
7
+ workspace: {
8
+ id: string;
9
+ name: string;
10
+ };
11
+ }>;
12
+ export declare function text(result: z.infer<typeof linkResultSchema>): string;
@@ -0,0 +1,7 @@
1
+ import { linkWorkspace } from '../../link.js';
2
+ export function run(input, context) {
3
+ return linkWorkspace(context, input);
4
+ }
5
+ export function text(result) {
6
+ return `Linked to ${result.workspace.name}.\n`;
7
+ }
@@ -0,0 +1 @@
1
+ export declare const loginCommand: import("../../command.js").RegisteredCommand;
@@ -0,0 +1,43 @@
1
+ import { defineCommand } from '../../command.js';
2
+ import { loginInputSchema, loginProgressSchema, loginResultSchema, } from './schema.js';
3
+ export const loginCommand = defineCommand({
4
+ name: ['login'],
5
+ summary: 'Sign in through the dashboard.',
6
+ need: 'public',
7
+ destructive: false,
8
+ streams: true,
9
+ arguments: [],
10
+ flags: [
11
+ {
12
+ name: 'base-url',
13
+ key: 'baseUrl',
14
+ type: 'string',
15
+ description: 'Choose the API origin.',
16
+ },
17
+ {
18
+ name: 'browser',
19
+ negatedName: 'no-browser',
20
+ key: 'browser',
21
+ type: 'boolean',
22
+ description: 'Open the dashboard in a browser.',
23
+ },
24
+ {
25
+ name: 'wait',
26
+ negatedName: 'no-wait',
27
+ key: 'wait',
28
+ type: 'boolean',
29
+ description: 'Wait for dashboard approval.',
30
+ },
31
+ {
32
+ name: 'resume',
33
+ negatedName: null,
34
+ key: 'resume',
35
+ type: 'boolean',
36
+ description: 'Continue a saved login.',
37
+ },
38
+ ],
39
+ input: loginInputSchema,
40
+ result: loginResultSchema,
41
+ progress: loginProgressSchema,
42
+ load: () => import('./run.js'),
43
+ });
@@ -0,0 +1,30 @@
1
+ import type { z } from 'zod';
2
+ import { type PublicContext } from '../../context-types.js';
3
+ import type { loginInputSchema, loginProgressSchema, loginResultSchema } from './schema.js';
4
+ export declare function run(input: z.infer<typeof loginInputSchema>, context: PublicContext): AsyncIterable<import("../../command.js").CommandEvent<{
5
+ status: "signed-in";
6
+ profile: string;
7
+ organization: {
8
+ id: string;
9
+ name: string;
10
+ };
11
+ email: string;
12
+ idleExpiresAt: string;
13
+ expiresAt: string;
14
+ userActionRequired: false;
15
+ } | {
16
+ status: "awaiting-approval";
17
+ profile: string;
18
+ loginId: string;
19
+ userCode: string;
20
+ verificationUrl: string;
21
+ expiresAt: string;
22
+ userActionRequired: true;
23
+ }, {
24
+ status: "waiting";
25
+ userCode: string;
26
+ verificationUrl: string;
27
+ expiresAt: string;
28
+ }>>;
29
+ export declare function text(result: z.infer<typeof loginResultSchema>): string;
30
+ export declare function progressText(progress: z.infer<typeof loginProgressSchema>): string;
@@ -0,0 +1,43 @@
1
+ import { apiOriginSchema } from '../../context-types.js';
2
+ import { CliError } from '../../errors.js';
3
+ export function run(input, context) {
4
+ if (input.wait &&
5
+ !input.resume &&
6
+ context.presentation.mode === 'non-interactive' &&
7
+ !context.presentation.stream) {
8
+ throw new CliError('cli.input_required', {
9
+ message: 'Use --no-wait to receive the approval URL and code, or --json --stream to wait with progress.',
10
+ next: [
11
+ {
12
+ command: 'statemachines login --no-wait --json',
13
+ reason: 'Start a login that can be approved in the dashboard.',
14
+ },
15
+ ],
16
+ });
17
+ }
18
+ if (input.resume && !input.wait) {
19
+ throw new CliError('cli.invalid_arguments');
20
+ }
21
+ const origin = input.baseUrl === undefined
22
+ ? null
23
+ : apiOriginSchema.safeParse(input.baseUrl);
24
+ if (origin !== null && !origin.success) {
25
+ throw new CliError('cli.invalid_arguments');
26
+ }
27
+ return context.accounts.login({
28
+ profile: context.globals.profile,
29
+ origin: origin?.data ?? null,
30
+ mode: input.resume ? 'resume' : input.wait ? 'wait' : 'no-wait',
31
+ browser: input.browser,
32
+ replace: context.globals.yes,
33
+ interactive: context.presentation.mode === 'interactive',
34
+ });
35
+ }
36
+ export function text(result) {
37
+ return result.status === 'signed-in'
38
+ ? `Signed in as ${result.email} to ${result.organization.name}.\nIdle expiry: ${result.idleExpiresAt}\nExpiry: ${result.expiresAt}`
39
+ : `Open ${result.verificationUrl} and approve code ${result.userCode}.\nProfile: ${result.profile}\nContinue with statemachines login --profile <profile> --resume`;
40
+ }
41
+ export function progressText(progress) {
42
+ return `Open ${progress.verificationUrl} and approve code ${progress.userCode}.`;
43
+ }
@@ -0,0 +1,33 @@
1
+ import { z } from 'zod';
2
+ export declare const loginInputSchema: z.ZodObject<{
3
+ baseUrl: z.ZodOptional<z.ZodString>;
4
+ browser: z.ZodDefault<z.ZodBoolean>;
5
+ wait: z.ZodDefault<z.ZodBoolean>;
6
+ resume: z.ZodDefault<z.ZodBoolean>;
7
+ }, z.core.$strict>;
8
+ export declare const loginResultSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
9
+ status: z.ZodLiteral<"signed-in">;
10
+ profile: z.ZodString;
11
+ organization: z.ZodObject<{
12
+ id: z.ZodString;
13
+ name: z.ZodString;
14
+ }, z.core.$strict>;
15
+ email: z.ZodString;
16
+ idleExpiresAt: z.ZodString;
17
+ expiresAt: z.ZodString;
18
+ userActionRequired: z.ZodLiteral<false>;
19
+ }, z.core.$strict>, z.ZodObject<{
20
+ status: z.ZodLiteral<"awaiting-approval">;
21
+ profile: z.ZodString;
22
+ loginId: z.ZodString;
23
+ userCode: z.ZodString;
24
+ verificationUrl: z.ZodString;
25
+ expiresAt: z.ZodString;
26
+ userActionRequired: z.ZodLiteral<true>;
27
+ }, z.core.$strict>], "status">;
28
+ export declare const loginProgressSchema: z.ZodObject<{
29
+ status: z.ZodLiteral<"waiting">;
30
+ userCode: z.ZodString;
31
+ verificationUrl: z.ZodString;
32
+ expiresAt: z.ZodString;
33
+ }, z.core.$strict>;
@@ -0,0 +1,33 @@
1
+ import { z } from 'zod';
2
+ export const loginInputSchema = z.strictObject({
3
+ baseUrl: z.string().optional(),
4
+ browser: z.boolean().default(true),
5
+ wait: z.boolean().default(true),
6
+ resume: z.boolean().default(false),
7
+ });
8
+ export const loginResultSchema = z.discriminatedUnion('status', [
9
+ z.strictObject({
10
+ status: z.literal('signed-in'),
11
+ profile: z.string(),
12
+ organization: z.strictObject({ id: z.string(), name: z.string() }),
13
+ email: z.string(),
14
+ idleExpiresAt: z.string(),
15
+ expiresAt: z.string(),
16
+ userActionRequired: z.literal(false),
17
+ }),
18
+ z.strictObject({
19
+ status: z.literal('awaiting-approval'),
20
+ profile: z.string(),
21
+ loginId: z.string(),
22
+ userCode: z.string(),
23
+ verificationUrl: z.string(),
24
+ expiresAt: z.string(),
25
+ userActionRequired: z.literal(true),
26
+ }),
27
+ ]);
28
+ export const loginProgressSchema = z.strictObject({
29
+ status: z.literal('waiting'),
30
+ userCode: z.string(),
31
+ verificationUrl: z.string(),
32
+ expiresAt: z.string(),
33
+ });
@@ -0,0 +1 @@
1
+ export declare const logoutCommand: import("../../command.js").RegisteredCommand;
@@ -0,0 +1,24 @@
1
+ import { z } from 'zod';
2
+ import { defineCommand } from '../../command.js';
3
+ import { logoutInputSchema, logoutResultSchema } from './schema.js';
4
+ export const logoutCommand = defineCommand({
5
+ name: ['logout'],
6
+ summary: 'Revoke the saved session and remove local credentials.',
7
+ need: 'public',
8
+ destructive: true,
9
+ streams: false,
10
+ arguments: [],
11
+ flags: [
12
+ {
13
+ name: 'all',
14
+ key: 'all',
15
+ type: 'boolean',
16
+ negatedName: null,
17
+ description: 'Sign out of every profile.',
18
+ },
19
+ ],
20
+ input: logoutInputSchema,
21
+ result: logoutResultSchema,
22
+ progress: z.never(),
23
+ load: () => import('./run.js'),
24
+ });
@@ -0,0 +1,10 @@
1
+ import type { z } from 'zod';
2
+ import type { PublicContext } from '../../context-types.js';
3
+ import type { logoutInputSchema, logoutResultSchema } from './schema.js';
4
+ export declare function run(input: z.infer<typeof logoutInputSchema>, context: PublicContext): Promise<{
5
+ profiles: string[];
6
+ pendingRevocations: string[];
7
+ unconfirmedRevocations: string[];
8
+ environmentCredentialUnchanged: boolean;
9
+ }>;
10
+ export declare function text(result: z.infer<typeof logoutResultSchema>): string;
@@ -0,0 +1,19 @@
1
+ import { unconfirmedRevocations } from '../../errors.js';
2
+ export function run(input, context) {
3
+ return context.accounts.logout({
4
+ profiles: input.all ? 'all' : context.globals.profile,
5
+ });
6
+ }
7
+ export function text(result) {
8
+ const unconfirmed = result.unconfirmedRevocations.length;
9
+ const { problem, remedy } = unconfirmedRevocations(unconfirmed);
10
+ return [
11
+ result.profiles.length === 0
12
+ ? 'No saved session.'
13
+ : `Signed out of ${result.profiles.join(', ')}.`,
14
+ ...(unconfirmed === 0 ? [] : [`${problem} ${remedy}`]),
15
+ ...(result.environmentCredentialUnchanged
16
+ ? ['STATEMACHINES_API_KEY is still set and remains active.']
17
+ : []),
18
+ ].join('\n');
19
+ }
@@ -0,0 +1,10 @@
1
+ import { z } from 'zod';
2
+ export declare const logoutInputSchema: z.ZodObject<{
3
+ all: z.ZodDefault<z.ZodBoolean>;
4
+ }, z.core.$strict>;
5
+ export declare const logoutResultSchema: z.ZodObject<{
6
+ profiles: z.ZodArray<z.ZodString>;
7
+ pendingRevocations: z.ZodArray<z.ZodString>;
8
+ unconfirmedRevocations: z.ZodArray<z.ZodString>;
9
+ environmentCredentialUnchanged: z.ZodBoolean;
10
+ }, z.core.$strict>;
@@ -0,0 +1,10 @@
1
+ import { z } from 'zod';
2
+ export const logoutInputSchema = z.strictObject({
3
+ all: z.boolean().default(false),
4
+ });
5
+ export const logoutResultSchema = z.strictObject({
6
+ profiles: z.array(z.string()),
7
+ pendingRevocations: z.array(z.string()),
8
+ unconfirmedRevocations: z.array(z.string()),
9
+ environmentCredentialUnchanged: z.boolean(),
10
+ });
@@ -0,0 +1,2 @@
1
+ export declare const profilesListCommand: import("../../command.js").RegisteredCommand;
2
+ export declare const profilesUseCommand: import("../../command.js").RegisteredCommand;
@@ -0,0 +1,29 @@
1
+ import { z } from 'zod';
2
+ import { defineCommand } from '../../command.js';
3
+ import { profilesListInputSchema, profilesResultSchema, profilesUseInputSchema, profilesUseResultSchema, } from './schema.js';
4
+ export const profilesListCommand = defineCommand({
5
+ name: ['profiles', 'list'],
6
+ summary: 'List saved profiles.',
7
+ need: 'public',
8
+ destructive: false,
9
+ streams: false,
10
+ arguments: [],
11
+ flags: [],
12
+ input: profilesListInputSchema,
13
+ result: profilesResultSchema,
14
+ progress: z.never(),
15
+ load: () => import('./list.js'),
16
+ });
17
+ export const profilesUseCommand = defineCommand({
18
+ name: ['profiles', 'use'],
19
+ summary: 'Choose the default profile.',
20
+ need: 'public',
21
+ destructive: false,
22
+ streams: false,
23
+ arguments: [{ name: 'name', key: 'name', required: true, many: false }],
24
+ flags: [],
25
+ input: profilesUseInputSchema,
26
+ result: profilesUseResultSchema,
27
+ progress: z.never(),
28
+ load: () => import('./use.js'),
29
+ });
@@ -0,0 +1,20 @@
1
+ import type { z } from 'zod';
2
+ import type { PublicContext } from '../../context-types.js';
3
+ import type { profilesListInputSchema, profilesResultSchema } from './schema.js';
4
+ export declare function run(_input: z.infer<typeof profilesListInputSchema>, context: PublicContext): Promise<{
5
+ defaultProfile: string | null;
6
+ profiles: {
7
+ name: string;
8
+ origin: string;
9
+ organization: {
10
+ id: string;
11
+ name: string;
12
+ };
13
+ email: string;
14
+ tokenId: string;
15
+ idleExpiresAt: string;
16
+ expiresAt: string;
17
+ defaultWorkspace: string | null;
18
+ }[];
19
+ }>;
20
+ export declare function text(result: z.infer<typeof profilesResultSchema>): string;
@@ -0,0 +1,10 @@
1
+ export function run(_input, context) {
2
+ return context.accounts.list();
3
+ }
4
+ export function text(result) {
5
+ return result.profiles.length === 0
6
+ ? 'No saved profiles. Run statemachines login to sign in.'
7
+ : result.profiles
8
+ .map((profile) => `${profile.name === result.defaultProfile ? '* ' : ' '}${profile.name}\t${profile.organization.name}\t${profile.email}`)
9
+ .join('\n');
10
+ }
@@ -0,0 +1,24 @@
1
+ import { z } from 'zod';
2
+ export declare const profilesListInputSchema: z.ZodObject<{}, z.core.$strict>;
3
+ export declare const profilesUseInputSchema: z.ZodObject<{
4
+ name: z.ZodString;
5
+ }, z.core.$strict>;
6
+ export declare const profilesUseResultSchema: z.ZodObject<{
7
+ profile: z.ZodString;
8
+ }, z.core.$strict>;
9
+ export declare const profilesResultSchema: z.ZodObject<{
10
+ defaultProfile: z.ZodNullable<z.ZodString>;
11
+ profiles: z.ZodArray<z.ZodObject<{
12
+ name: z.ZodString;
13
+ origin: z.ZodString;
14
+ organization: z.ZodObject<{
15
+ id: z.ZodString;
16
+ name: z.ZodString;
17
+ }, z.core.$strict>;
18
+ email: z.ZodString;
19
+ tokenId: z.ZodString;
20
+ idleExpiresAt: z.ZodString;
21
+ expiresAt: z.ZodString;
22
+ defaultWorkspace: z.ZodNullable<z.ZodString>;
23
+ }, z.core.$strict>>;
24
+ }, z.core.$strict>;
@@ -0,0 +1,19 @@
1
+ import { z } from 'zod';
2
+ export const profilesListInputSchema = z.strictObject({});
3
+ export const profilesUseInputSchema = z.strictObject({
4
+ name: z.string().min(1),
5
+ });
6
+ export const profilesUseResultSchema = z.strictObject({ profile: z.string() });
7
+ export const profilesResultSchema = z.strictObject({
8
+ defaultProfile: z.string().nullable(),
9
+ profiles: z.array(z.strictObject({
10
+ name: z.string(),
11
+ origin: z.string(),
12
+ organization: z.strictObject({ id: z.string(), name: z.string() }),
13
+ email: z.string(),
14
+ tokenId: z.string(),
15
+ idleExpiresAt: z.string(),
16
+ expiresAt: z.string(),
17
+ defaultWorkspace: z.string().nullable(),
18
+ })),
19
+ });
@@ -0,0 +1,7 @@
1
+ import type { z } from 'zod';
2
+ import { type PublicContext } from '../../context-types.js';
3
+ import type { profilesUseInputSchema, profilesUseResultSchema } from './schema.js';
4
+ export declare function run(input: z.infer<typeof profilesUseInputSchema>, context: PublicContext): Promise<{
5
+ profile: string;
6
+ }>;
7
+ export declare function text(result: z.infer<typeof profilesUseResultSchema>): string;
@@ -0,0 +1,7 @@
1
+ import { profileNameSchema } from '../../context-types.js';
2
+ export function run(input, context) {
3
+ return context.accounts.use(profileNameSchema.parse(input.name));
4
+ }
5
+ export function text(result) {
6
+ return `Using profile ${result.profile}.`;
7
+ }
@@ -0,0 +1,39 @@
1
+ import { z } from 'zod';
2
+ export declare const listInputSchema: z.ZodObject<{
3
+ limit: z.ZodOptional<z.ZodString>;
4
+ cursor: z.ZodOptional<z.ZodString>;
5
+ all: z.ZodDefault<z.ZodBoolean>;
6
+ environmentId: z.ZodString;
7
+ app: z.ZodOptional<z.ZodString>;
8
+ status: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
9
+ "2xx": "2xx";
10
+ "3xx": "3xx";
11
+ "4xx": "4xx";
12
+ "5xx": "5xx";
13
+ }>, z.ZodString]>>;
14
+ }, z.core.$strict>;
15
+ export declare const listResultSchema: z.ZodObject<{
16
+ data: z.ZodArray<z.ZodObject<{
17
+ id: z.ZodString;
18
+ environmentId: z.ZodString;
19
+ appName: z.ZodString;
20
+ method: z.ZodString;
21
+ path: z.ZodString;
22
+ query: z.ZodString;
23
+ service: z.ZodNullable<z.ZodString>;
24
+ mcpServer: z.ZodNullable<z.ZodString>;
25
+ tool: z.ZodNullable<z.ZodString>;
26
+ operation: z.ZodNullable<z.ZodString>;
27
+ responseStatus: z.ZodNumber;
28
+ respondedBy: z.ZodString;
29
+ errorCode: z.ZodNullable<z.ZodString>;
30
+ durationMs: z.ZodNumber;
31
+ requestBytes: z.ZodNullable<z.ZodNumber>;
32
+ responseBytes: z.ZodNullable<z.ZodNumber>;
33
+ receivedAt: z.ZodString;
34
+ completedAt: z.ZodString;
35
+ }, z.core.$strict>>;
36
+ nextCursor: z.ZodNullable<z.ZodString>;
37
+ }, z.core.$strict>;
38
+ export declare const requestsListCommand: import("../../command.js").RegisteredCommand;
39
+ export declare const requestsGetCommand: import("../../command.js").RegisteredCommand;
@@ -0,0 +1,65 @@
1
+ import { z } from 'zod';
2
+ import { defineCommand } from '../../command.js';
3
+ import { idArgument, idInputSchema, pageFlags, pageInput, requestDetailResultSchema, requestResultSchema, } from '../../resources/schema.js';
4
+ export const listInputSchema = z.strictObject({
5
+ ...pageInput,
6
+ environmentId: z.string().min(1),
7
+ app: z.string().min(1).optional(),
8
+ status: z
9
+ .union([
10
+ z.enum(['2xx', '3xx', '4xx', '5xx']),
11
+ z.string().regex(/^[1-5]\d{2}$/),
12
+ ])
13
+ .optional(),
14
+ });
15
+ export const listResultSchema = z.strictObject({
16
+ data: z.array(requestResultSchema),
17
+ nextCursor: z.string().nullable(),
18
+ });
19
+ export const requestsListCommand = defineCommand({
20
+ name: ['requests', 'list'],
21
+ summary: 'List gateway requests for an environment.',
22
+ need: 'workspace',
23
+ destructive: false,
24
+ streams: false,
25
+ arguments: [
26
+ {
27
+ name: 'environment-id',
28
+ key: 'environmentId',
29
+ required: true,
30
+ many: false,
31
+ },
32
+ ],
33
+ flags: [
34
+ ...pageFlags,
35
+ {
36
+ name: 'app',
37
+ key: 'app',
38
+ type: 'string',
39
+ description: 'Match requests for this app.',
40
+ },
41
+ {
42
+ name: 'status',
43
+ key: 'status',
44
+ type: 'string',
45
+ description: 'Match an HTTP status or status class, such as 404 or 4xx.',
46
+ },
47
+ ],
48
+ input: listInputSchema,
49
+ result: listResultSchema,
50
+ progress: z.never(),
51
+ load: () => import('./list.js'),
52
+ });
53
+ export const requestsGetCommand = defineCommand({
54
+ name: ['requests', 'get'],
55
+ summary: 'Show a gateway request.',
56
+ need: 'workspace',
57
+ destructive: false,
58
+ streams: false,
59
+ arguments: [idArgument],
60
+ flags: [],
61
+ input: idInputSchema,
62
+ result: requestDetailResultSchema,
63
+ progress: z.never(),
64
+ load: () => import('./get.js'),
65
+ });
@@ -0,0 +1,32 @@
1
+ import type { z } from 'zod';
2
+ import type { WorkspaceContext } from '../../context-types.js';
3
+ import type { idInputSchema, requestDetailResultSchema } from '../../resources/schema.js';
4
+ export declare function run(input: z.infer<typeof idInputSchema>, context: WorkspaceContext): Promise<{
5
+ id: string;
6
+ environmentId: string;
7
+ appName: string;
8
+ method: string;
9
+ path: string;
10
+ query: string;
11
+ service: string | null;
12
+ mcpServer: string | null;
13
+ tool: string | null;
14
+ operation: string | null;
15
+ responseStatus: number;
16
+ respondedBy: string;
17
+ errorCode: string | null;
18
+ durationMs: number;
19
+ requestBytes: number | null;
20
+ responseBytes: number | null;
21
+ receivedAt: string;
22
+ completedAt: string;
23
+ requestBody: import("@usestatemachines/sdk").BodyPreview;
24
+ requestHeaders: {
25
+ [k: string]: string;
26
+ };
27
+ responseBody: import("@usestatemachines/sdk").BodyPreview;
28
+ responseHeaders: {
29
+ [k: string]: string;
30
+ };
31
+ }>;
32
+ export declare function text(result: z.infer<typeof requestDetailResultSchema>): string;
@@ -0,0 +1,15 @@
1
+ import { environment, requestResult } from '../../resources/read.js';
2
+ export async function run(input, context) {
3
+ const value = await context.sdk.requests.get(input.id);
4
+ await environment(context, value.environmentId);
5
+ return {
6
+ ...requestResult(value),
7
+ requestBody: value.requestBody,
8
+ requestHeaders: value.requestHeaders,
9
+ responseBody: value.responseBody,
10
+ responseHeaders: value.responseHeaders,
11
+ };
12
+ }
13
+ export function text(result) {
14
+ return `${result.id}\t${result.method}\t${result.path}\t${result.responseStatus}\t${result.durationMs} ms\n`;
15
+ }
@@ -0,0 +1,27 @@
1
+ import type { z } from 'zod';
2
+ import type { WorkspaceContext } from '../../context-types.js';
3
+ import type { listInputSchema, listResultSchema } from './command.js';
4
+ export declare function run(input: z.infer<typeof listInputSchema>, context: WorkspaceContext): Promise<{
5
+ data: {
6
+ id: string;
7
+ environmentId: string;
8
+ appName: string;
9
+ method: string;
10
+ path: string;
11
+ query: string;
12
+ service: string | null;
13
+ mcpServer: string | null;
14
+ tool: string | null;
15
+ operation: string | null;
16
+ responseStatus: number;
17
+ respondedBy: string;
18
+ errorCode: string | null;
19
+ durationMs: number;
20
+ requestBytes: number | null;
21
+ responseBytes: number | null;
22
+ receivedAt: string;
23
+ completedAt: string;
24
+ }[];
25
+ nextCursor: string | null;
26
+ }>;
27
+ export declare function text(result: z.infer<typeof listResultSchema>): string;