@supacloud/cli 0.76.0 → 0.78.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 (121) hide show
  1. package/README.md +101 -4
  2. package/dist/index.d.ts +2 -0
  3. package/dist/index.js +19399 -73398
  4. package/dist/index.test.d.ts +1 -0
  5. package/dist/migration-inventory.integration.test.d.ts +1 -0
  6. package/dist/project-read-process.test.d.ts +1 -0
  7. package/dist/shared/cli.d.ts +18 -0
  8. package/dist/shared/context.d.ts +26 -0
  9. package/dist/shared/context.test.d.ts +1 -0
  10. package/dist/shared/execution-policy.d.ts +14 -0
  11. package/dist/shared/execution-policy.test.d.ts +1 -0
  12. package/dist/shared/global-options.d.ts +8 -0
  13. package/dist/shared/global-options.test.d.ts +1 -0
  14. package/dist/shared/mutation-protocol.d.ts +45 -0
  15. package/dist/shared/mutation-protocol.test.d.ts +1 -0
  16. package/dist/shared/outcome-guidance.d.ts +1 -0
  17. package/dist/shared/project-ref.d.ts +1 -0
  18. package/dist/shared/schema.d.ts +13 -0
  19. package/dist/shared/schema.test.d.ts +1 -0
  20. package/dist/shared/tool-server.d.ts +15 -0
  21. package/dist/shared/tool-server.test.d.ts +1 -0
  22. package/dist/shared/tools/advanced-tools.d.ts +5 -0
  23. package/dist/shared/tools/advanced-tools.test.d.ts +1 -0
  24. package/dist/shared/tools/ai-tools.d.ts +28 -0
  25. package/dist/shared/tools/ai-tools.test.d.ts +1 -0
  26. package/dist/shared/tools/app-database-check.d.ts +7 -0
  27. package/dist/shared/tools/app-database-check.test.d.ts +1 -0
  28. package/dist/shared/tools/app-delivery.test.d.ts +1 -0
  29. package/dist/shared/tools/app-dev-regressions.test.d.ts +1 -0
  30. package/dist/shared/tools/app-dev.test.d.ts +1 -0
  31. package/dist/shared/tools/app-local-dev.d.ts +15 -0
  32. package/dist/shared/tools/app-local-dev.test.d.ts +1 -0
  33. package/dist/shared/tools/app-minimal-starter.test.d.ts +1 -0
  34. package/dist/shared/tools/app-resource-generation.test.d.ts +1 -0
  35. package/dist/shared/tools/app-resource.d.ts +5 -0
  36. package/dist/shared/tools/app-scaffold-writes.d.ts +33 -0
  37. package/dist/shared/tools/app-scaffold-writes.test.d.ts +1 -0
  38. package/dist/shared/tools/app-starter-attachment-worker.d.ts +2 -0
  39. package/dist/shared/tools/app-starter-attachments.d.ts +2 -0
  40. package/dist/shared/tools/app-starter-composition.test.d.ts +1 -0
  41. package/dist/shared/tools/app-starter-database.d.ts +14 -0
  42. package/dist/shared/tools/app-starter-environment.d.ts +2 -0
  43. package/dist/shared/tools/app-starter-postgres.d.ts +4 -0
  44. package/dist/shared/tools/app-starter-reactive.d.ts +4 -0
  45. package/dist/shared/tools/app-starter-reactive.test.d.ts +1 -0
  46. package/dist/shared/tools/app-starter-review-job.d.ts +2 -0
  47. package/dist/shared/tools/app-starter-roles.d.ts +2 -0
  48. package/dist/shared/tools/app-starter-roles.test.d.ts +1 -0
  49. package/dist/shared/tools/app-starter-templates.d.ts +7 -0
  50. package/dist/shared/tools/app-starter-upload.d.ts +3 -0
  51. package/dist/shared/tools/app-starter.d.ts +12 -0
  52. package/dist/shared/tools/app-starter.test.d.ts +1 -0
  53. package/dist/shared/tools/app-tool-export.d.ts +42 -0
  54. package/dist/shared/tools/app-tools.d.ts +105 -0
  55. package/dist/shared/tools/app-tools.test.d.ts +1 -0
  56. package/dist/shared/tools/app-verification-plan.d.ts +14 -0
  57. package/dist/shared/tools/app-verification-plan.test.d.ts +1 -0
  58. package/dist/shared/tools/application-preview-tools.d.ts +74 -0
  59. package/dist/shared/tools/application-preview-tools.test.d.ts +1 -0
  60. package/dist/shared/tools/application-schemas.d.ts +75 -0
  61. package/dist/shared/tools/application-tools.d.ts +30 -0
  62. package/dist/shared/tools/application-tools.test.d.ts +1 -0
  63. package/dist/shared/tools/auth-tools.d.ts +3 -0
  64. package/dist/shared/tools/auth-tools.test.d.ts +1 -0
  65. package/dist/shared/tools/branch-promotion-http-status.test.d.ts +1 -0
  66. package/dist/shared/tools/branch-tools.d.ts +7 -0
  67. package/dist/shared/tools/branch-tools.test.d.ts +1 -0
  68. package/dist/shared/tools/database-tools.d.ts +13 -0
  69. package/dist/shared/tools/database-tools.test.d.ts +1 -0
  70. package/dist/shared/tools/db-governance-tools.d.ts +80 -0
  71. package/dist/shared/tools/db-governance-tools.test.d.ts +1 -0
  72. package/dist/shared/tools/db-workflow.d.ts +37 -0
  73. package/dist/shared/tools/db-workflow.test.d.ts +1 -0
  74. package/dist/shared/tools/deploy-tools.d.ts +36 -0
  75. package/dist/shared/tools/deploy-tools.test.d.ts +1 -0
  76. package/dist/shared/tools/edge-function-response.d.ts +55 -0
  77. package/dist/shared/tools/edge-function-response.test.d.ts +1 -0
  78. package/dist/shared/tools/frontend-release-control.d.ts +54 -0
  79. package/dist/shared/tools/frontend-release-control.test.d.ts +1 -0
  80. package/dist/shared/tools/frontend-tools.d.ts +3 -0
  81. package/dist/shared/tools/gateway-tools.d.ts +6 -0
  82. package/dist/shared/tools/gateway-tools.test.d.ts +1 -0
  83. package/dist/shared/tools/lite-cli-command.d.ts +2 -0
  84. package/dist/shared/tools/lite-cli-tools.d.ts +46 -0
  85. package/dist/shared/tools/lite-cli-tools.test.d.ts +1 -0
  86. package/dist/shared/tools/migration-import.d.ts +22 -0
  87. package/dist/shared/tools/migration-import.test.d.ts +1 -0
  88. package/dist/shared/tools/migration-risk.d.ts +36 -0
  89. package/dist/shared/tools/migration-risk.test.d.ts +1 -0
  90. package/dist/shared/tools/mutation-tools.d.ts +3 -0
  91. package/dist/shared/tools/mutation-tools.test.d.ts +1 -0
  92. package/dist/shared/tools/oauth-client-tools.d.ts +3 -0
  93. package/dist/shared/tools/oauth-client-tools.test.d.ts +1 -0
  94. package/dist/shared/tools/project-cli-tools.d.ts +6 -0
  95. package/dist/shared/tools/project-cli-tools.test.d.ts +1 -0
  96. package/dist/shared/tools/project-endpoint-read.d.ts +10 -0
  97. package/dist/shared/tools/project-endpoint-tools.test.d.ts +1 -0
  98. package/dist/shared/tools/project-read-projection.d.ts +8 -0
  99. package/dist/shared/tools/project-read-projection.test.d.ts +1 -0
  100. package/dist/shared/tools/queue-tools.d.ts +6 -0
  101. package/dist/shared/tools/queue-tools.test.d.ts +1 -0
  102. package/dist/shared/tools/release-control-response.d.ts +12 -0
  103. package/dist/shared/tools/release-control-response.test.d.ts +1 -0
  104. package/dist/shared/tools/release-tools.d.ts +8 -0
  105. package/dist/shared/tools/release-tools.test.d.ts +1 -0
  106. package/dist/shared/tools/remote-dev-tools.d.ts +41 -0
  107. package/dist/shared/tools/remote-dev-tools.test.d.ts +1 -0
  108. package/dist/shared/tools/scheduled-function-tools.d.ts +7 -0
  109. package/dist/shared/tools/scheduled-function-tools.test.d.ts +1 -0
  110. package/dist/shared/tools/storage-tools.d.ts +3 -0
  111. package/dist/shared/tools/storage-tools.test.d.ts +1 -0
  112. package/dist/shared/tools/supabase-cli-tools.d.ts +49 -0
  113. package/dist/shared/tools/supabase-cli-tools.test.d.ts +1 -0
  114. package/dist/shared/transports/http.d.ts +68 -0
  115. package/dist/shared/transports/http.test.d.ts +1 -0
  116. package/dist/supabase-cli.integration.test.d.ts +1 -0
  117. package/dist/test-helpers.d.ts +1 -0
  118. package/dist/tool-runtime.d.ts +2 -0
  119. package/dist/tool-runtime.js +154 -0
  120. package/dist/tool-runtime.test.d.ts +1 -0
  121. package/package.json +19 -4
@@ -0,0 +1,2 @@
1
+ /** Resolve the installed package's declared bin, not an internal file suffix. */
2
+ export declare function resolveLiteCommand(workdir: string, environment?: NodeJS.ProcessEnv): string[];
@@ -0,0 +1,46 @@
1
+ export { resolveLiteCommand } from "./lite-cli-command";
2
+ import { type ToolServer } from "../tool-server";
3
+ export type LiteCliAction = "version" | "start" | "migrate" | "status" | "keys" | "gen_types" | "db_reset" | "db_diff" | "db_pull" | "snapshot_create" | "snapshot_restore" | "upgrade" | "inspect" | "doctor";
4
+ export interface LiteCliArgs {
5
+ action: LiteCliAction;
6
+ workdir?: string;
7
+ project_dir?: string;
8
+ state_dir?: string;
9
+ data_dir?: string;
10
+ storage_dir?: string;
11
+ storage_backend?: "fs" | "memory" | "s3";
12
+ s3_prefix?: string;
13
+ engine?: "pglite" | "native";
14
+ host?: string;
15
+ port?: number;
16
+ api_url?: string;
17
+ site_url?: string;
18
+ replication_profile?: "powersync";
19
+ replication_host?: string;
20
+ replication_port?: number;
21
+ replication_allow_cidrs?: string;
22
+ powersync_tables?: string;
23
+ replication_tls_cert?: string;
24
+ replication_tls_key?: string;
25
+ output?: string;
26
+ file?: string;
27
+ snapshot_file?: string;
28
+ service_role?: boolean;
29
+ force?: boolean;
30
+ memory?: boolean;
31
+ json?: boolean;
32
+ baseline?: boolean;
33
+ }
34
+ export interface LiteCliExecutionResult {
35
+ exitCode: number;
36
+ stdout: string;
37
+ stderr: string;
38
+ }
39
+ type LiteCliExecutor = (request: LiteCliArgs) => Promise<LiteCliExecutionResult>;
40
+ export interface LiteCliToolOptions {
41
+ executeLiteCli?: LiteCliExecutor;
42
+ environment?: NodeJS.ProcessEnv;
43
+ currentWorkingDirectory?: string;
44
+ }
45
+ export declare function buildLiteArgs(request: LiteCliArgs): string[];
46
+ export declare function registerLiteCliTools(server: ToolServer, options?: LiteCliToolOptions): void;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,22 @@
1
+ export interface MigrationImportFile {
2
+ file: string;
3
+ name: string;
4
+ sql: string;
5
+ source: "sql" | "hasura-metadata" | "hasura-application-review" | "nhost";
6
+ }
7
+ export interface MigrationImportPlan {
8
+ source: "hasura" | "nhost";
9
+ files: MigrationImportFile[];
10
+ warnings: string[];
11
+ compatibility: {
12
+ supabase_migrations: true;
13
+ pg_graphql: "preserved";
14
+ rls: "manual_review";
15
+ };
16
+ }
17
+ export declare function writeMigrationImportPlan(plan: MigrationImportPlan, outputDirectory: string): Promise<string[]>;
18
+ export declare function createMigrationImportPlan(input: {
19
+ source: "hasura" | "nhost";
20
+ directory?: string;
21
+ metadata?: unknown;
22
+ }): MigrationImportPlan;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Migration Risk Analysis Engine
3
+ *
4
+ * Statically analyzes SQL migrations for Expand-Contract violations, destructive DDL,
5
+ * and lock-heavy operations (e.g. non-concurrent index creation, non-null additions without default).
6
+ */
7
+ export type MigrationRiskLevel = "HIGH" | "MEDIUM" | "LOW";
8
+ export interface MigrationRiskItem {
9
+ level: MigrationRiskLevel;
10
+ type: string;
11
+ description: string;
12
+ recommendation: string;
13
+ statementSnippet?: string;
14
+ blocksTransactionalPush?: true;
15
+ }
16
+ export interface MigrationFileRisk {
17
+ file: string;
18
+ overallRisk: MigrationRiskLevel;
19
+ risks: MigrationRiskItem[];
20
+ }
21
+ export interface MigrationRiskAnalysis {
22
+ overallRisk: MigrationRiskLevel;
23
+ highRiskCount: number;
24
+ mediumRiskCount: number;
25
+ lowRiskCount: number;
26
+ transactionalPushBlockerCount: number;
27
+ files: MigrationFileRisk[];
28
+ }
29
+ export declare function maskSqlNoise(sql: string): string;
30
+ export declare function splitSqlStatements(sql: string): string[];
31
+ export declare function analyzeMigrationSql(sql: string): MigrationRiskItem[];
32
+ export declare function analyzeMigrationFiles(files: Array<{
33
+ file: string;
34
+ sql: string;
35
+ }>): MigrationRiskAnalysis;
36
+ export declare function formatMigrationRiskReport(analysis: MigrationRiskAnalysis): string;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ import type { HttpTransport } from "../transports/http";
2
+ import { type ToolServer } from "../tool-server";
3
+ export declare function registerMutationTools(server: ToolServer, http: HttpTransport): void;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ import type { HttpTransport } from "../transports/http";
2
+ import { type ToolServer } from "../tool-server";
3
+ export declare function registerOAuthClientTools(server: ToolServer, http: HttpTransport): void;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ import type { HttpTransport } from "../transports/http";
2
+ import { type ToolServer } from "../tool-server";
3
+ export declare function registerUserProjectCliTools(server: ToolServer, http: HttpTransport, options?: {
4
+ projectRef?: string;
5
+ }): void;
6
+ export declare function registerAdminProjectCliTools(server: ToolServer, http: HttpTransport): void;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,10 @@
1
+ import type { HttpResult } from "../transports/http";
2
+ export declare const PROJECT_ENDPOINT_RESPONSE_MAX_BYTES: number;
3
+ export declare const PROJECT_ENDPOINT_LIST_RESPONSE_MAX_BYTES: number;
4
+ export type ProjectEndpointReadResult = {
5
+ text: string;
6
+ isError: boolean;
7
+ };
8
+ export declare function projectEndpointRead(response: HttpResult<unknown>, expectedRef: string): ProjectEndpointReadResult;
9
+ export declare function projectApiOrigins(response: HttpResult<unknown>, expectedRef: string): string[] | null;
10
+ export declare function projectEndpointListRead(response: HttpResult<unknown>): ProjectEndpointReadResult;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,8 @@
1
+ import type { HttpResult } from "../transports/http";
2
+ export declare const PROJECT_READ_RESPONSE_MAX_BYTES = 1048576;
3
+ export type ProjectReadResult = {
4
+ text: string;
5
+ isError: boolean;
6
+ };
7
+ export declare function projectListRead(response: HttpResult<unknown>): ProjectReadResult;
8
+ export declare function projectGetRead(response: HttpResult<unknown>, expectedRef: string): ProjectReadResult;
@@ -0,0 +1,6 @@
1
+ import type { HttpTransport } from "../transports/http";
2
+ import { type ToolServer } from "../tool-server";
3
+ export interface QueueToolsConfig {
4
+ projectRef?: string;
5
+ }
6
+ export declare function registerQueueTools(server: ToolServer, http: HttpTransport, options?: QueueToolsConfig): void;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,12 @@
1
+ import type { HttpResult } from "../transports/http";
2
+ export declare const RELEASE_CONTROL_RESPONSE_SCHEMA = "supacloud.cli.release-control.v1";
3
+ export interface ReleaseControlToolResponse {
4
+ content: Array<{
5
+ type: "text";
6
+ text: string;
7
+ }>;
8
+ isError?: boolean;
9
+ }
10
+ export declare function releaseControlSuccess(operation: string, payload: Record<string, unknown>): ReleaseControlToolResponse;
11
+ export declare function releaseControlFailure(operation: string, code: "HTTP_ERROR" | "INVALID_RESPONSE" | "MUTATION_NOT_SUCCEEDED" | "OUTCOME_UNKNOWN" | "PARTIAL_SUCCESS", httpStatus: number | null, safeState?: Record<string, unknown>): ReleaseControlToolResponse;
12
+ export declare function releaseControlMutationFailure(operation: string, response: HttpResult<unknown>, safeState?: Record<string, unknown>): ReleaseControlToolResponse;
@@ -0,0 +1,8 @@
1
+ import type { HttpTransport } from "../transports/http";
2
+ import { type ToolServer } from "../tool-server";
3
+ export declare function registerReleaseTools(server: ToolServer, http?: HttpTransport, options?: {
4
+ localOnly?: boolean;
5
+ projectRef?: string;
6
+ applicationHttp?: HttpTransport;
7
+ applicationOrigin?: string;
8
+ }): void;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,41 @@
1
+ import { Type } from "typebox";
2
+ import { type ToolServer } from "../tool-server";
3
+ type CommandResult = {
4
+ exitCode: number;
5
+ stdout: string;
6
+ stderr: string;
7
+ };
8
+ type CommandExecutor = (command: string, args: string[], cwd: string) => Promise<CommandResult>;
9
+ type DatabaseCallback = (args: Record<string, unknown>) => Promise<unknown>;
10
+ export interface RemoteDevToolOptions {
11
+ cwd?: string;
12
+ host?: string;
13
+ sshUser?: string;
14
+ sshPort?: number;
15
+ sshKey?: string;
16
+ projectRef?: string;
17
+ environment?: string;
18
+ execute?: CommandExecutor;
19
+ runDatabase?: DatabaseCallback;
20
+ }
21
+ export declare const remoteDevToolSchema: {
22
+ action: Type.TEnum<("status" | "migrate" | "watch" | "sync")[]>;
23
+ target: Type.TOptional<Type.TEnum<("project" | "frontend" | "db" | "functions")[]>>;
24
+ project_dir: Type.TOptional<Type.TString>;
25
+ remote_root: Type.TOptional<Type.TString>;
26
+ remote_host: Type.TOptional<Type.TString>;
27
+ remote_user: Type.TOptional<Type.TString>;
28
+ remote_port: Type.TOptional<Type.TNumber>;
29
+ remote_key: Type.TOptional<Type.TString>;
30
+ function: Type.TOptional<Type.TString>;
31
+ delete: Type.TOptional<Type.TBoolean>;
32
+ reload: Type.TOptional<Type.TBoolean>;
33
+ interval_ms: Type.TOptional<Type.TNumber>;
34
+ json: Type.TOptional<Type.TBoolean>;
35
+ apply: Type.TOptional<Type.TBoolean>;
36
+ drizzle_config: Type.TOptional<Type.TString>;
37
+ migrations_dir: Type.TOptional<Type.TString>;
38
+ drizzle_bin: Type.TOptional<Type.TString>;
39
+ };
40
+ export declare function registerRemoteDevTools(server: ToolServer, options?: RemoteDevToolOptions): void;
41
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,7 @@
1
+ import type { HttpTransport } from "../transports/http";
2
+ import { type ToolServer } from "../tool-server";
3
+ interface ScheduledFunctionToolsOptions {
4
+ readOnly?: boolean;
5
+ }
6
+ export declare function registerScheduledFunctionTools(server: ToolServer, http: HttpTransport, environment?: NodeJS.ProcessEnv, options?: ScheduledFunctionToolsOptions): void;
7
+ export {};
@@ -0,0 +1,3 @@
1
+ import type { HttpTransport } from "../transports/http";
2
+ import { type ToolServer } from "../tool-server";
3
+ export declare function registerStorageTools(server: ToolServer, http: HttpTransport): void;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,49 @@
1
+ import { type ToolInvocation, type ToolServer } from "../tool-server";
2
+ export type SupabaseCliAction = "version" | "init" | "migration_new" | "db_diff" | "db_reset" | "db_pull" | "db_schema_declarative_sync" | "db_schema_declarative_generate" | "db_dump" | "config_pull" | "stack_start" | "stack_prepare" | "stack_status" | "stack_stop" | "stack_destroy" | "migration_list" | "gen_types" | "push";
3
+ export interface SupabaseCliArgs {
4
+ action: SupabaseCliAction;
5
+ workdir?: string;
6
+ ref?: string;
7
+ name?: string;
8
+ schema?: string;
9
+ db_url?: string;
10
+ file?: string;
11
+ dir?: string;
12
+ dry_run?: boolean;
13
+ declarative?: boolean;
14
+ apply?: boolean;
15
+ experimental?: boolean;
16
+ strict_coverage?: boolean;
17
+ overwrite?: boolean;
18
+ runtime?: "docker" | "podman" | "native";
19
+ eager?: boolean;
20
+ preparation?: "background" | "on-demand";
21
+ force?: boolean;
22
+ yes?: boolean;
23
+ confirm_destroy?: boolean;
24
+ no_seed?: boolean;
25
+ diff_engine?: "migra" | "pg-delta" | "pgadmin" | "pg-schema";
26
+ dump_mode?: "schema" | "data" | "roles";
27
+ language?: "typescript" | "go" | "swift" | "python";
28
+ }
29
+ export interface OfficialCliExecutionResult {
30
+ exitCode: number;
31
+ stdout: string;
32
+ stderr: string;
33
+ }
34
+ type MigrationPushCallback = ToolInvocation;
35
+ type OfficialCliExecutor = (request: SupabaseCliArgs) => Promise<OfficialCliExecutionResult>;
36
+ export interface SupabaseCliToolOptions {
37
+ getPushMigrations?: () => MigrationPushCallback | undefined;
38
+ executeOfficialCli?: OfficialCliExecutor;
39
+ environment?: NodeJS.ProcessEnv;
40
+ currentWorkingDirectory?: string;
41
+ projectRef?: string;
42
+ readOnly?: boolean;
43
+ }
44
+ export declare function buildOfficialSupabaseArgs(request: SupabaseCliArgs): string[];
45
+ export declare function createOfficialSupabaseEnvironment(environment: NodeJS.ProcessEnv): Record<string, string>;
46
+ export declare function redactOfficialSupabaseOutput(commandOutput: string, secrets?: string[]): string;
47
+ export declare function resolveOfficialSupabaseCommand(workdir: string, environment?: NodeJS.ProcessEnv): string[];
48
+ export declare function registerSupabaseCliTools(server: ToolServer, options?: SupabaseCliToolOptions): void;
49
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,68 @@
1
+ /**
2
+ * SupaCloud CLI HTTP transport layer.
3
+ *
4
+ * After SupaCloud is installed, manage projects via Management API (HTTP).
5
+ * Includes request timeout, retry with exponential backoff, and proper error handling.
6
+ */
7
+ export interface HttpConfig {
8
+ baseUrl: string;
9
+ token: string;
10
+ apiKey?: string;
11
+ insecureTls?: boolean;
12
+ }
13
+ export interface HttpResult<T = unknown> {
14
+ ok: boolean;
15
+ status: number;
16
+ data: T;
17
+ transportError?: boolean;
18
+ responseReadError?: true;
19
+ }
20
+ export interface HttpGetOptions {
21
+ timeoutMs?: number;
22
+ retry?: boolean;
23
+ /** Complete header/body budget for a bounded JSON GET with retries disabled. */
24
+ totalTimeoutMs?: number;
25
+ maxResponseBytes?: number;
26
+ maxJsonBytes?: number;
27
+ responseTimeoutMs?: number;
28
+ }
29
+ export interface HttpPostOptions {
30
+ timeoutMs?: number;
31
+ maxJsonBytes?: number;
32
+ responseTimeoutMs?: number;
33
+ }
34
+ export interface HttpReleaseMutationOptions {
35
+ timeoutMs?: number;
36
+ }
37
+ export interface HttpBinaryPostOptions {
38
+ contentType: string;
39
+ contentLength: number;
40
+ contentSha256: string;
41
+ maxJsonBytes: number;
42
+ timeoutMs?: number;
43
+ responseTimeoutMs?: number;
44
+ }
45
+ export interface HttpBinaryBody {
46
+ stream: ReadableStream<Uint8Array>;
47
+ byteLength: number;
48
+ }
49
+ export declare class HttpTransport {
50
+ private baseUrl;
51
+ private token;
52
+ private apiKey;
53
+ private insecureTls;
54
+ constructor(config: HttpConfig);
55
+ private headers;
56
+ private mutationWithResponseReader;
57
+ get<T = unknown>(path: string, options?: HttpGetOptions): Promise<HttpResult<T>>;
58
+ post<T = unknown>(path: string, body?: unknown, options?: HttpPostOptions): Promise<HttpResult<T>>;
59
+ postReleaseMutation<T = unknown>(path: string, body?: unknown, options?: HttpReleaseMutationOptions): Promise<HttpResult<T>>;
60
+ postBinary<T = unknown>(path: string, body: HttpBinaryBody, options: HttpBinaryPostOptions): Promise<HttpResult<T>>;
61
+ patchReleaseMutation<T = unknown>(path: string, body?: unknown): Promise<HttpResult<T>>;
62
+ deleteReleaseMutation<T = unknown>(path: string, body?: unknown): Promise<HttpResult<T>>;
63
+ postMultipart<T = unknown>(path: string, formData: FormData, options?: HttpPostOptions): Promise<HttpResult<T>>;
64
+ patch<T = unknown>(path: string, body?: unknown): Promise<HttpResult<T>>;
65
+ put<T = unknown>(path: string, body?: unknown, options?: HttpPostOptions): Promise<HttpResult<T>>;
66
+ delete<T = unknown>(path: string, body?: unknown): Promise<HttpResult<T>>;
67
+ ping(): Promise<boolean>;
68
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export declare function requireValue<T>(value: T | null | undefined): T;
@@ -0,0 +1,2 @@
1
+ export { decodedSchema, optional, parseToolArguments, schemaDescription, schemaEnumValues, schemaProperties, stringEnum, validateToolArguments, withDescription, type ToolArguments, type ToolSchema, } from "./shared/schema.js";
2
+ export { registerTool, type ToolCallback, type ToolInvocation, type ToolResult, type ToolServer, type ToolTextContent, } from "./shared/tool-server.js";
@@ -0,0 +1,154 @@
1
+ // src/shared/schema.ts
2
+ import { Type } from "typebox";
3
+ import { Value } from "typebox/value";
4
+ var DECODE_ID = "~supacloudDecodeId";
5
+
6
+ class OutputDecodeError extends Error {
7
+ decodeId;
8
+ issues;
9
+ constructor(decodeId, issues) {
10
+ super(issues.map((issue) => `- ${issue.path}: ${issue.message}`).join(`
11
+ `));
12
+ this.decodeId = decodeId;
13
+ this.issues = issues;
14
+ }
15
+ }
16
+ function decodeIdOf(schema) {
17
+ const value = Object.getOwnPropertyDescriptor(schema, DECODE_ID)?.value;
18
+ return typeof value === "symbol" ? value : undefined;
19
+ }
20
+ function schemaErrorPath(path) {
21
+ return path.replace(/^\//, "").replaceAll("/", ".") || "args";
22
+ }
23
+ function schemaErrorLines(schema, input) {
24
+ return [...Value.Errors(schema, input)].map((issue) => `- ${schemaErrorPath(issue.instancePath)}: ${issue.message}`);
25
+ }
26
+ function transformErrorLine(error) {
27
+ const message = error instanceof Error ? error.message : String(error);
28
+ const path = typeof error === "object" && error !== null && "instancePath" in error && typeof error.instancePath === "string" ? schemaErrorPath(error.instancePath) : "args";
29
+ return `- ${path}: ${message}`;
30
+ }
31
+ function validateToolArguments(schema, input) {
32
+ const issues = schemaErrorLines(Type.Object(schema, { additionalProperties: false }), input);
33
+ if (issues.length > 0)
34
+ throw new Error(`Invalid arguments:
35
+ ${issues.join(`
36
+ `)}`);
37
+ }
38
+ function isRecord(value) {
39
+ return value !== null && typeof value === "object" && !Array.isArray(value);
40
+ }
41
+ function parseToolArguments(schema, input) {
42
+ const objectSchema = Type.Object(schema, { additionalProperties: false });
43
+ validateToolArguments(schema, input);
44
+ let decoded;
45
+ try {
46
+ decoded = Value.Decode(objectSchema, input);
47
+ } catch (error) {
48
+ if (error instanceof OutputDecodeError) {
49
+ const entry = Object.entries(schema).find(([, property]) => decodeIdOf(property) === error.decodeId);
50
+ const path = entry?.[0] ?? "args";
51
+ const issues = error.issues.map((issue) => `- ${issue.path === "args" ? path : `${path}.${issue.path}`}: ${issue.message}`);
52
+ throw new Error(`Invalid arguments:
53
+ ${issues.join(`
54
+ `)}`);
55
+ }
56
+ throw new Error(`Invalid arguments:
57
+ ${transformErrorLine(error)}`);
58
+ }
59
+ const decodedFields = decoded;
60
+ if (!isRecord(decodedFields)) {
61
+ throw new Error("Invalid arguments: decoded value must be an object");
62
+ }
63
+ return decoded;
64
+ }
65
+ function stringEnum(values, options) {
66
+ return Type.Enum([...values], options);
67
+ }
68
+ function mergeSchemaOptions(schema, options) {
69
+ const result = { ...schema };
70
+ Object.setPrototypeOf(result, Object.getPrototypeOf(schema));
71
+ Object.defineProperties(result, Object.getOwnPropertyDescriptors(schema));
72
+ for (const [key, value] of Object.entries(options)) {
73
+ Object.defineProperty(result, key, { value, enumerable: true, writable: true, configurable: true });
74
+ }
75
+ return result;
76
+ }
77
+ function withDescription(schema, description) {
78
+ return mergeSchemaOptions(schema, { description });
79
+ }
80
+ function optional(schema, description) {
81
+ return Type.Optional(description ? withDescription(schema, description) : schema);
82
+ }
83
+ function decodedSchema(inputSchema, outputSchema, decode, options) {
84
+ const decodeId = Symbol("decodedSchema");
85
+ const transform = Type.Decode(inputSchema, (input) => {
86
+ const value = decode(input);
87
+ const issues = [...Value.Errors(outputSchema, value)].map((issue) => ({
88
+ path: schemaErrorPath(issue.instancePath),
89
+ message: issue.message
90
+ }));
91
+ if (issues.length > 0)
92
+ throw new OutputDecodeError(decodeId, issues);
93
+ return Value.Decode(outputSchema, value);
94
+ });
95
+ const result = options ? mergeSchemaOptions(transform, options) : transform;
96
+ Object.defineProperty(result, DECODE_ID, { value: decodeId, enumerable: false, configurable: true });
97
+ return result;
98
+ }
99
+ function schemaEnumValues(schema) {
100
+ const view = schema;
101
+ if (Array.isArray(view.enum)) {
102
+ return view.enum.filter((value) => typeof value === "string" || typeof value === "number").map((value) => String(value));
103
+ }
104
+ if (typeof view.const === "string" || typeof view.const === "number") {
105
+ return [String(view.const)];
106
+ }
107
+ if (!Array.isArray(view.anyOf))
108
+ return [];
109
+ return view.anyOf.flatMap((branch) => {
110
+ if (typeof branch !== "object" || branch === null || !("const" in branch))
111
+ return [];
112
+ const enumValue = branch.const;
113
+ return typeof enumValue === "string" || typeof enumValue === "number" ? [String(enumValue)] : [];
114
+ });
115
+ }
116
+ function schemaDescription(schema) {
117
+ const description = schema.description;
118
+ return typeof description === "string" ? description : "";
119
+ }
120
+ function schemaProperties(schema) {
121
+ const properties = schema && typeof schema === "object" ? schema.properties : undefined;
122
+ if (typeof properties === "object" && properties !== null) {
123
+ return properties;
124
+ }
125
+ return schema;
126
+ }
127
+ // src/shared/tool-server.ts
128
+ import { Type as Type2 } from "typebox";
129
+ import { Value as Value2 } from "typebox/value";
130
+ var resultSchema = Type2.Object({
131
+ content: Type2.Array(Type2.Object({ type: Type2.Literal("text"), text: Type2.String() })),
132
+ isError: Type2.Optional(Type2.Boolean())
133
+ });
134
+ function registerTool(server, name, description, schema, callback) {
135
+ server.tool(name, description, schema, async (input) => {
136
+ const args = parseToolArguments(schema, input);
137
+ const result = await callback(args);
138
+ if (!Value2.Check(resultSchema, result))
139
+ throw new Error(`Invalid result from tool '${name}'`);
140
+ return result;
141
+ });
142
+ }
143
+ export {
144
+ decodedSchema,
145
+ optional,
146
+ parseToolArguments,
147
+ registerTool,
148
+ schemaDescription,
149
+ schemaEnumValues,
150
+ schemaProperties,
151
+ stringEnum,
152
+ validateToolArguments,
153
+ withDescription
154
+ };
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,9 +1,22 @@
1
1
  {
2
2
  "name": "@supacloud/cli",
3
- "version": "0.76.0",
3
+ "version": "0.78.0",
4
4
  "description": "Project-scoped CLI for SupaCloud users",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js",
12
+ "default": "./dist/index.js"
13
+ },
14
+ "./tool-runtime": {
15
+ "types": "./dist/tool-runtime.d.ts",
16
+ "import": "./dist/tool-runtime.js",
17
+ "default": "./dist/tool-runtime.js"
18
+ }
19
+ },
7
20
  "bin": {
8
21
  "supacloud-cli": "dist/index.js"
9
22
  },
@@ -18,7 +31,9 @@
18
31
  "dev": "bun run --watch src/index.ts",
19
32
  "prepare:db": "bun install --cwd ../contracts --frozen-lockfile && bun run --cwd ../contracts build && bun install --cwd ../db --force --frozen-lockfile && bun run --cwd ../db build && bun install --force --frozen-lockfile",
20
33
  "prebuild": "bun run prepare:db",
21
- "build": "bun build src/index.ts --outdir dist --target node --conditions=supacloud-source",
34
+ "build": "bun build src/index.ts --outdir dist --target node --conditions=supacloud-source --external @supacloud/compiler && bun run build:tool-runtime && bun run build:types",
35
+ "build:tool-runtime": "bun build src/tool-runtime.ts --outdir dist --target node --external typebox && tsc -p tsconfig.tool-runtime.json --emitDeclarationOnly",
36
+ "build:types": "tsc --emitDeclarationOnly",
22
37
  "pretypecheck": "bun install --cwd ../delivery --frozen-lockfile && bun install --cwd ../compiler --frozen-lockfile && bun run --cwd ../compiler build && bun run prepare:db",
23
38
  "prepublishOnly": "bun run build",
24
39
  "typecheck": "tsc --noEmit"
@@ -36,9 +51,9 @@
36
51
  "directory": "packages/cli"
37
52
  },
38
53
  "dependencies": {
39
- "@supacloud/compiler": "^0.42.1",
54
+ "@supacloud/compiler": "^0.43.0",
40
55
  "@supacloud/delivery": "0.8.0",
41
- "@supacloud/db": "0.15.0",
56
+ "@supacloud/db": "0.16.0",
42
57
  "fflate": "^0.8.3",
43
58
  "typebox": "1.3.34"
44
59
  },