@sequenceholdings/studio-cli 0.3.0 → 0.4.2

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 (111) hide show
  1. package/README.md +506 -32
  2. package/dist/agents/commands.d.ts +1 -1
  3. package/dist/agents/commands.js +5 -0
  4. package/dist/agents/scaffold.js +5 -7
  5. package/dist/agents/voice-authoring.d.ts +5 -0
  6. package/dist/agents/voice-authoring.js +75 -0
  7. package/dist/agents/voice-publication.d.ts +5 -0
  8. package/dist/agents/voice-publication.js +63 -0
  9. package/dist/agents/voice-shared.d.ts +20 -0
  10. package/dist/agents/voice-shared.js +112 -0
  11. package/dist/agents/voice.d.ts +3 -0
  12. package/dist/agents/voice.js +57 -0
  13. package/dist/app/adapters.d.ts +6 -0
  14. package/dist/app/adapters.js +17 -2
  15. package/dist/app/agent-refs.d.ts +16 -0
  16. package/dist/app/agent-refs.js +36 -0
  17. package/dist/app/application-registration.d.ts +45 -8
  18. package/dist/app/application-registration.js +112 -22
  19. package/dist/app/commands.js +19 -2
  20. package/dist/app/deploy.d.ts +3 -0
  21. package/dist/app/deploy.js +18 -4
  22. package/dist/app/env-bindings.d.ts +21 -0
  23. package/dist/app/env-bindings.js +184 -0
  24. package/dist/app/manifest-validation.d.ts +8 -0
  25. package/dist/app/manifest-validation.js +97 -5
  26. package/dist/app/manifest.d.ts +45 -9
  27. package/dist/app/manifest.js +27 -1
  28. package/dist/app/primitive-scaffold.d.ts +4 -1
  29. package/dist/app/primitive-scaffold.js +4 -4
  30. package/dist/app/readme.js +11 -0
  31. package/dist/app/scaffold-files.js +1 -1
  32. package/dist/app/scaffold.d.ts +6 -4
  33. package/dist/app/scaffold.js +7 -4
  34. package/dist/app/workspace-scaffold.js +12 -7
  35. package/dist/argv.d.ts +7 -0
  36. package/dist/argv.js +56 -0
  37. package/dist/artifact/delegate.js +8 -4
  38. package/dist/atlas-client.d.ts +6 -0
  39. package/dist/atlas-client.js +39 -2
  40. package/dist/auth.d.ts +32 -0
  41. package/dist/auth.js +170 -33
  42. package/dist/bin.js +23 -4
  43. package/dist/command-contract.d.ts +137 -0
  44. package/dist/command-contract.js +43 -0
  45. package/dist/command-help.d.ts +8 -0
  46. package/dist/command-help.js +71 -0
  47. package/dist/functions/commands.d.ts +1 -1
  48. package/dist/functions/commands.js +19 -3
  49. package/dist/functions/deploy-preflight.d.ts +21 -0
  50. package/dist/functions/deploy-preflight.js +58 -0
  51. package/dist/functions/egress-postgres.d.ts +7 -0
  52. package/dist/functions/egress-postgres.js +36 -0
  53. package/dist/functions/manifest.d.ts +8 -0
  54. package/dist/functions/manifest.js +9 -0
  55. package/dist/functions/source-selection.js +4 -1
  56. package/dist/main.js +58 -20
  57. package/dist/orm/delegate.d.ts +16 -0
  58. package/dist/orm/delegate.js +140 -7
  59. package/dist/pipeline/clone-deploy.d.ts +37 -0
  60. package/dist/pipeline/clone-deploy.js +125 -0
  61. package/dist/pipeline/codegen.js +6 -2
  62. package/dist/pipeline/commands.js +21 -5
  63. package/dist/pipeline/lifecycle.d.ts +1 -0
  64. package/dist/pipeline/lifecycle.js +95 -44
  65. package/dist/pipeline/repin-orm.js +6 -2
  66. package/dist/pipeline/stage-secrets.js +1 -1
  67. package/dist/process/build.js +17 -0
  68. package/dist/process/codegen.js +16 -0
  69. package/dist/process/commands.d.ts +15 -7
  70. package/dist/process/commands.js +291 -99
  71. package/dist/process/lint.js +35 -0
  72. package/dist/process/plan-diff.js +9 -0
  73. package/dist/process/simulate.js +8 -0
  74. package/dist/release-age.d.ts +12 -0
  75. package/dist/release-age.js +24 -0
  76. package/dist/repos/commands.d.ts +1 -1
  77. package/dist/repos/commands.js +36 -7
  78. package/dist/scaffold-guidance.d.ts +4 -0
  79. package/dist/scaffold-guidance.js +15 -0
  80. package/dist/storage/commands.js +23 -1
  81. package/dist/storage/gcs-download.d.ts +13 -0
  82. package/dist/storage/gcs-download.js +41 -0
  83. package/dist/storage/import-cycle.d.ts +41 -0
  84. package/dist/storage/import-cycle.js +123 -0
  85. package/dist/storage/import-files.d.ts +30 -0
  86. package/dist/storage/import-files.js +133 -0
  87. package/dist/storage/import-gcloud.d.ts +12 -0
  88. package/dist/storage/import-gcloud.js +54 -0
  89. package/dist/storage/import-identity.d.ts +12 -0
  90. package/dist/storage/import-identity.js +15 -0
  91. package/dist/storage/import-plan.d.ts +120 -0
  92. package/dist/storage/import-plan.js +189 -0
  93. package/dist/storage/import-preflight.d.ts +36 -0
  94. package/dist/storage/import-preflight.js +62 -0
  95. package/dist/storage/import-progress-map.d.ts +5 -0
  96. package/dist/storage/import-progress-map.js +22 -0
  97. package/dist/storage/import-recover.d.ts +97 -0
  98. package/dist/storage/import-recover.js +186 -0
  99. package/dist/storage/import-run.d.ts +14 -0
  100. package/dist/storage/import-run.js +140 -0
  101. package/dist/templates/guidance/AGENTS.md +10 -0
  102. package/dist/templates/guidance/CLAUDE.md +1 -0
  103. package/dist/templates/process/package.json +2 -2
  104. package/dist/templates/process/pnpm-workspace.yaml +7 -4
  105. package/dist/validation-detail.d.ts +2 -0
  106. package/dist/validation-detail.js +20 -0
  107. package/package.json +10 -10
  108. package/templates/guidance/AGENTS.md +10 -0
  109. package/templates/guidance/CLAUDE.md +1 -0
  110. package/templates/process/package.json +2 -2
  111. package/templates/process/pnpm-workspace.yaml +7 -4
@@ -0,0 +1,8 @@
1
+ /** Help text reachable before command implementations, auth, optional SDKs, or Atlas clients load. */
2
+ export declare const ORM_HELP = "usage:\n seq-studio orm init <dir>\n seq-studio orm generate [dir] [--migration-export] [--check]\n seq-studio orm validate [dir]\n seq-studio orm plan [dir] -e <env>\n seq-studio orm apply [dir] -e <env>\n seq-studio orm execute <operation> [dir] --variables-file <file> -e <env>\n seq-studio orm diff [dir] [--check] [--allow-destructive] [--rebase]\n seq-studio orm migrate-from-yaml <dir>\n seq-studio orm import [dir] --spec <file> | --table <table> --from <schema.table> --map <target=source,...>\n\n -e/--env is required for commands that contact Atlas. Use seq-studio envs list\n to discover environments and seq-studio login to authenticate.\n";
3
+ export declare const ARTIFACT_HELP = "usage:\n seq-studio artifact init <dir> [--template react-vite|nextjs]\n seq-studio artifact whoami -e <env>\n seq-studio artifact link [dir] -e <env> [--project <id>]\n seq-studio artifact env list|use <env>\n seq-studio artifact status [-e <env>]\n seq-studio artifact list -e <env> [--json]\n seq-studio artifact show <slug-or-id> -e <env> [--json]\n seq-studio artifact validate [dir]\n seq-studio artifact build|plan|deploy [dir | --repo <namespace>/<name> | --git-url <url>] [--ref <ref>] -e <env>\n seq-studio artifact dev [dir] -e <env> [--once] [--key <name>] [--link <package-dir>] [--port <port>]\n seq-studio artifact pull <project-id> -e <env> --out <dir>\n seq-studio artifact promote|rollback <deployment-id> -e <env>\n\n Help is available offline. Authenticate with seq-studio login. Build and deploy\n sources may be local, a platform git-service repo, or a public HTTPS Git URL;\n deployments target a named environment with -e. Local, preview, and official\n deployment workflows have different source and approval rules; see the public\n CLI README.\n";
4
+ export declare const PIPELINE_HELP = "usage:\n seq-studio pipeline list -e <env> [--limit 1..200] [--offset N] [--json]\n list pipeline repository rollups (not assets)\n seq-studio pipeline assets -e <env> [--repo <namespace>/<slug>] [--json]\n list asset declarations, including assets that may not be deployed\n seq-studio pipeline search <query> -e <env> [--target <id>] [--repo <namespace>/<slug>] [--limit N] [--offset N] [--json]\n seq-studio pipeline describe <asset-id> -e <env> [--target <id>] [--repo <namespace>/<slug>] [--json]\n seq-studio pipeline schema|sample <asset-id> -e <env> [--target <id>] [--limit N] [--json]\n seq-studio pipeline query <asset-id> --sql <read-only-sql> -e <env> [--target <id>] [--limit N] [--json]\n seq-studio pipeline init|validate|plan|deploy|status|migrate|adopt|unbind|run-now|promote|rollback ...\n seq-studio pipeline plan --plan-request-id <id> -e <env> [--json]\n poll an existing durable plan without enqueueing or attaching credentials\n Lifecycle --json results use stdout; progress uses stderr. Deploy --run-now\n executes producers in the managed worker; local polling may disconnect.\n\n Discovery requires staff access. Use list for pipeline repositories, assets\n for declared assets, and search/describe for active deployment metadata;\n use schema to verify physical columns. -e chooses the environment and\n --target chooses a logical target when the environment has more than one.\n Help is available offline.\n";
5
+ export declare function staticHelp({ namespace, sub }: {
6
+ namespace: string;
7
+ sub?: string;
8
+ }): string | undefined;
@@ -0,0 +1,71 @@
1
+ /** Help text reachable before command implementations, auth, optional SDKs, or Atlas clients load. */
2
+ export const ORM_HELP = `usage:
3
+ seq-studio orm init <dir>
4
+ seq-studio orm generate [dir] [--migration-export] [--check]
5
+ seq-studio orm validate [dir]
6
+ seq-studio orm plan [dir] -e <env>
7
+ seq-studio orm apply [dir] -e <env>
8
+ seq-studio orm execute <operation> [dir] --variables-file <file> -e <env>
9
+ seq-studio orm diff [dir] [--check] [--allow-destructive] [--rebase]
10
+ seq-studio orm migrate-from-yaml <dir>
11
+ seq-studio orm import [dir] --spec <file> | --table <table> --from <schema.table> --map <target=source,...>
12
+
13
+ -e/--env is required for commands that contact Atlas. Use seq-studio envs list
14
+ to discover environments and seq-studio login to authenticate.
15
+ `;
16
+ export const ARTIFACT_HELP = `usage:
17
+ seq-studio artifact init <dir> [--template react-vite|nextjs]
18
+ seq-studio artifact whoami -e <env>
19
+ seq-studio artifact link [dir] -e <env> [--project <id>]
20
+ seq-studio artifact env list|use <env>
21
+ seq-studio artifact status [-e <env>]
22
+ seq-studio artifact list -e <env> [--json]
23
+ seq-studio artifact show <slug-or-id> -e <env> [--json]
24
+ seq-studio artifact validate [dir]
25
+ seq-studio artifact build|plan|deploy [dir | --repo <namespace>/<name> | --git-url <url>] [--ref <ref>] -e <env>
26
+ seq-studio artifact dev [dir] -e <env> [--once] [--key <name>] [--link <package-dir>] [--port <port>]
27
+ seq-studio artifact pull <project-id> -e <env> --out <dir>
28
+ seq-studio artifact promote|rollback <deployment-id> -e <env>
29
+
30
+ Help is available offline. Authenticate with seq-studio login. Build and deploy
31
+ sources may be local, a platform git-service repo, or a public HTTPS Git URL;
32
+ deployments target a named environment with -e. Local, preview, and official
33
+ deployment workflows have different source and approval rules; see the public
34
+ CLI README.
35
+ `;
36
+ export const PIPELINE_HELP = `usage:
37
+ seq-studio pipeline list -e <env> [--limit 1..200] [--offset N] [--json]
38
+ list pipeline repository rollups (not assets)
39
+ seq-studio pipeline assets -e <env> [--repo <namespace>/<slug>] [--json]
40
+ list asset declarations, including assets that may not be deployed
41
+ seq-studio pipeline search <query> -e <env> [--target <id>] [--repo <namespace>/<slug>] [--limit N] [--offset N] [--json]
42
+ seq-studio pipeline describe <asset-id> -e <env> [--target <id>] [--repo <namespace>/<slug>] [--json]
43
+ seq-studio pipeline schema|sample <asset-id> -e <env> [--target <id>] [--limit N] [--json]
44
+ seq-studio pipeline query <asset-id> --sql <read-only-sql> -e <env> [--target <id>] [--limit N] [--json]
45
+ seq-studio pipeline init|validate|plan|deploy|status|migrate|adopt|unbind|run-now|promote|rollback ...
46
+ seq-studio pipeline plan --plan-request-id <id> -e <env> [--json]
47
+ poll an existing durable plan without enqueueing or attaching credentials
48
+ Lifecycle --json results use stdout; progress uses stderr. Deploy --run-now
49
+ executes producers in the managed worker; local polling may disconnect.
50
+
51
+ Discovery requires staff access. Use list for pipeline repositories, assets
52
+ for declared assets, and search/describe for active deployment metadata;
53
+ use schema to verify physical columns. -e chooses the environment and
54
+ --target chooses a logical target when the environment has more than one.
55
+ Help is available offline.
56
+ `;
57
+ export function staticHelp({ namespace, sub }) {
58
+ if (namespace === 'artifact')
59
+ return ARTIFACT_HELP;
60
+ if (namespace === 'orm')
61
+ return ORM_HELP;
62
+ if (namespace === 'pipeline')
63
+ return PIPELINE_HELP;
64
+ if (namespace === 'doctor') {
65
+ return `usage: seq-studio doctor [-e <env>] [--json] [--offline]\n\nDiagnose config, auth, local service availability, CLI/SDK resolution, and deployment access. --offline reads local metadata without discovery or HTTP requests. Help is available offline.\n`;
66
+ }
67
+ if (namespace === 'process' && (!sub || sub === 'help' || sub === '--help' || sub === '-h')) {
68
+ return `usage: seq-studio process <init|lint|plan|apply|promote|pull|test|simulate|bundle> [args]\n\nHelp is available offline.\n`;
69
+ }
70
+ return undefined;
71
+ }
@@ -93,5 +93,5 @@ export declare function functionsRollbackCommand(args: ParsedArgs): Promise<numb
93
93
  /** Minimal dotenv parser — KEY=VALUE lines, quotes stripped, comments skipped. */
94
94
  export declare function parseDotenv(content: string): Record<string, string>;
95
95
  export declare function functionsDeleteCommand(args: ParsedArgs): Promise<number>;
96
- export declare const FUNCTIONS_USAGE = "usage:\n seq-studio functions init <dir> scaffold manifest + TypeScript hello-world handler\n seq-studio functions build [--dir d] local pre-flight (manifest, lockfile, size)\n seq-studio functions register -e <env> [--dir d] register a function shell without deploying\n seq-studio functions deploy -e <env> [-m msg] preview + confirm secrets + upload and deploy\n seq-studio functions list -e <env> [--match-local] functions visible on the environment\n seq-studio functions show -e <env> [--fn slug] detail for one function (versions, secrets)\n seq-studio functions limits [-e <env>] [--json] bundled defaults/caps, or deployed policy\n [--fn slug] also show effective runtime limits (requires -e)\n seq-studio functions dev [--dir path] [--port 8080] local HTTP server with cache context\n seq-studio functions invoke -e <env> [--data JSON | --data @file | --stdin]\n invoke a function and print its response\n seq-studio functions logs -e <env> [--limit N] [--since t] function logs (reader-gated)\n seq-studio functions promote <version> -e <env> make a version live\n seq-studio functions rollback [<version>] -e <env> redeploy a prior version\n seq-studio functions delete -e <env> [--yes] archive function + tear down its runtime\n (version history is retained)\n\n Flags: -e/--env <env|preview:<slug>> (required for network commands; see: seq-studio envs list) \u00B7 --fn <slug> \u00B7 --dir <path>\n --path <repo-subdirectory> (remote build/deploy only) select one function in a multi-function repo\n --from-env-file <path> (default: .env) source file for secret values\n --no-wait \u00B7 --yes\n --no-provision (deploy) update-only: error instead of registering a new\n shell, writing secret values, or attaching secrets (CI sweep)\n\n Local Atlas builds and runs deployed functions on this computer, including teardown.\n \"functions dev\" runs a standalone handler without Atlas registration.\n\n Configure per-function CPU and concurrency in managed-function.yml under limits.\n Run \"functions limits\" for valid settings; redeploy to apply manifest changes.\n Invocation rates are shared across Atlas replicas; 429 includes Retry-After.\n If the shared rate limiter is unavailable, invocation fails closed with 503.\n\n Source for build/deploy: a local --dir (default .), a platform git-service\n repo (--repo <ns>/<name>), or a public HTTPS git URL (--git-url <url>). --path selects\n a function directory within a remote repo; omit it for the existing root-manifest\n layout. --ref selects a branch/tag/commit (default: the repo's default branch).\n Remote sources record the pinned commit as provenance (never dirty) and NEVER\n read a repo-committed .env for secret values \u2014 provision secrets server-side\n or pass a local --from-env-file (resolved against your cwd).\n\n Interactive --repo builds clone over smart-HTTP and require a repo:read git\n PAT in ATLAS_GIT_PAT (`seq-studio auth pat create --scopes repo:read`, or\n Atlas \u2192 Settings \u2192 Tokens). Headless M2M builds use JSON materialize and\n accept only platform-managed --repo sources. Interactive builds also need\n --env + seq-studio login to resolve the repo and deploy.\n";
96
+ export declare const FUNCTIONS_USAGE = "usage:\n seq-studio functions init <dir> scaffold manifest, TypeScript handler, and docs pointers\n seq-studio functions build [--dir d] local pre-flight (manifest, lockfile, SDK timeout cap)\n seq-studio functions register -e <env> [--dir d] register a function shell without deploying\n seq-studio functions deploy -e <env> [-m msg] preflight deployed capabilities, then upload and deploy\n seq-studio functions list -e <env> [--match-local] functions visible on the environment\n seq-studio functions show -e <env> [--fn slug] detail for one function (versions, secrets)\n seq-studio functions limits [-e <env>] [--json] bundled defaults/caps, or deployed policy\n [--fn slug] also show effective runtime limits (requires -e)\n seq-studio functions dev [--dir path] [--port 8080] local HTTP server with cache context\n seq-studio functions invoke -e <env> [--data JSON | --data @file | --stdin]\n invoke a function and print its response\n seq-studio functions logs -e <env> [--limit N] [--since t] function logs (reader-gated)\n seq-studio functions promote <version> -e <env> make a version live\n seq-studio functions rollback [<version>] -e <env> redeploy a prior version\n seq-studio functions delete -e <env> [--yes] archive function + tear down its runtime\n (version history is retained)\n\n Flags: -e/--env <env|preview:<slug>> (required for network commands; see: seq-studio envs list) \u00B7 --fn <slug> \u00B7 --dir <path>\n --path <repo-subdirectory> (remote build/deploy only) select one function in a multi-function repo\n --from-env-file <path> (default: .env) source file for secret values\n --no-wait \u00B7 --yes\n --no-provision (deploy) update-only: error instead of registering a new\n shell, writing secret values, or attaching secrets (CI sweep)\n\n Local Atlas builds and runs deployed functions on this computer, including teardown.\n \"functions dev\" runs a standalone handler without Atlas registration.\n\n Configure per-function CPU and concurrency in managed-function.yml under limits.\n Run \"functions limits\" for valid settings; redeploy to apply manifest changes.\n Invocation rates are shared across Atlas replicas; 429 includes Retry-After.\n If the shared rate limiter is unavailable, invocation fails closed with 503.\n\n Source for build/deploy: a local --dir (default .), a platform git-service\n repo (--repo <ns>/<name>), or a public HTTPS git URL (--git-url <url>). --path selects\n a function directory within a remote repo; omit it for the existing root-manifest\n layout. --ref selects a branch/tag/commit (default: the repo's default branch).\n Remote sources record the pinned commit as provenance (never dirty) and NEVER\n read a repo-committed .env for secret values \u2014 provision secrets server-side\n or pass a local --from-env-file (resolved against your cwd).\n\n Interactive --repo builds clone over smart-HTTP and require a repo:read git\n PAT in ATLAS_GIT_PAT (`seq-studio auth pat create --scopes repo:read`, or\n Atlas \u2192 Settings \u2192 Tokens). Headless M2M builds use JSON materialize and\n accept only platform-managed --repo sources. Interactive builds also need\n --env + seq-studio login to resolve the repo and deploy.\n";
97
97
  export declare function runFunctionsCommand(sub: string | undefined, args: ParsedArgs): Promise<number>;
@@ -11,8 +11,11 @@ import { getAccessTokenWithMode, tryGetAccessTokenWithMode } from '../auth.js';
11
11
  import { resolveEnvWithDiscovery } from '../config.js';
12
12
  import { AtlasApiError, deleteJson, getJson, postJson, postJsonResponse, } from '../atlas-client.js';
13
13
  import { clarifyApplyFailureReason, printCliError } from '../cli-errors.js';
14
+ import { currentVersion } from '../update-check.js';
15
+ import { localSdkPreflight, preflightBeforeUpload, reportPreflight } from './deploy-preflight.js';
14
16
  import { REQUIRE_EXPLICIT_ENV_MESSAGE } from '../env-flags.js';
15
17
  import { confirmYes } from '../prompt.js';
18
+ import { writeScaffoldGuidance } from '../scaffold-guidance.js';
16
19
  import { collectBundleFiles, isDirectory, validateLocalBundle, } from './bundle.js';
17
20
  import { managedFunctionManifestSchema, MF_MANIFEST_FILENAME, manifestEgressHosts, manifestEgressIpRanges, manifestSecretNames, } from './manifest.js';
18
21
  import { buildEgressPreviewLines, egressPropagationNote, formatEgressSummary, printFunctionEgressHosts, } from './egress-preview.js';
@@ -360,7 +363,9 @@ export async function functionsInitCommand(args) {
360
363
  await writeFile(join(dir, 'package.json'), TEMPLATE_PACKAGE_JSON(id));
361
364
  await writeFile(join(dir, '.gitignore'), TEMPLATE_GITIGNORE);
362
365
  await writeFile(join(dir, '.npmrc'), TEMPLATE_NPMRC);
366
+ await writeScaffoldGuidance({ directory: dir });
363
367
  console.log(`${LOG} scaffolded managed function "${id}" (TypeScript) in ${dir}`);
368
+ console.log(`${LOG} AGENTS.md points to your environment's live docs; CLAUDE.md imports it`);
364
369
  console.log('');
365
370
  console.log('Next steps (init is only needed when creating a function from scratch):');
366
371
  console.log(` cd ${target}`);
@@ -412,6 +417,9 @@ async function buildFromResolvedSource({ spec, source, }) {
412
417
  log(`${LOG} ${issue.level}: ${issue.message}`);
413
418
  }
414
419
  const errors = issues.filter((i) => i.level === 'error');
420
+ const sdkIssues = await localSdkPreflight({ rootDir: dir, manifest, cliVersion: currentVersion() });
421
+ if (reportPreflight(sdkIssues))
422
+ return 1;
415
423
  if (errors.length > 0) {
416
424
  console.error(`${LOG} build check failed (${errors.length} error${errors.length === 1 ? '' : 's'})`);
417
425
  return 1;
@@ -510,6 +518,14 @@ async function deployFromResolvedSource({ args, spec, ctx: earlyCtx, source, })
510
518
  // A --repo source authenticated before materialization; local / git-url
511
519
  // sources authenticate only now, after local validation passed.
512
520
  const ctx = earlyCtx ?? (await buildContext(args));
521
+ const capabilityIssues = await preflightBeforeUpload({
522
+ client: clientOptions(ctx),
523
+ rootDir: dir,
524
+ manifest,
525
+ cliVersion: currentVersion(),
526
+ });
527
+ if (reportPreflight(capabilityIssues))
528
+ return 1;
513
529
  const slug = manifest.function.id;
514
530
  const singleSecrets = manifest.secrets.filter((entry) => typeof entry === 'string');
515
531
  const declaredSecretNames = manifestSecretNames(manifest);
@@ -1150,10 +1166,10 @@ export async function functionsDeleteCommand(args) {
1150
1166
  // dispatcher
1151
1167
  // ---------------------------------------------------------------------------
1152
1168
  export const FUNCTIONS_USAGE = `usage:
1153
- seq-studio functions init <dir> scaffold manifest + TypeScript hello-world handler
1154
- seq-studio functions build [--dir d] local pre-flight (manifest, lockfile, size)
1169
+ seq-studio functions init <dir> scaffold manifest, TypeScript handler, and docs pointers
1170
+ seq-studio functions build [--dir d] local pre-flight (manifest, lockfile, SDK timeout cap)
1155
1171
  seq-studio functions register -e <env> [--dir d] register a function shell without deploying
1156
- seq-studio functions deploy -e <env> [-m msg] preview + confirm secrets + upload and deploy
1172
+ seq-studio functions deploy -e <env> [-m msg] preflight deployed capabilities, then upload and deploy
1157
1173
  seq-studio functions list -e <env> [--match-local] functions visible on the environment
1158
1174
  seq-studio functions show -e <env> [--fn slug] detail for one function (versions, secrets)
1159
1175
  seq-studio functions limits [-e <env>] [--json] bundled defaults/caps, or deployed policy
@@ -0,0 +1,21 @@
1
+ import { type PreflightIssue, type PreflightManifest } from '@sequenceholdings/managed-functions/config';
2
+ /**
3
+ * Compare the manifest with the environment's published limits and features.
4
+ * A 404 means that deployment has no policy route yet; local SDK checks still run.
5
+ */
6
+ export declare function preflightBeforeUpload({ client, rootDir, manifest, cliVersion, }: {
7
+ client: {
8
+ baseUrl: string;
9
+ token: string;
10
+ };
11
+ rootDir: string;
12
+ manifest: PreflightManifest;
13
+ cliVersion: string;
14
+ }): Promise<PreflightIssue[]>;
15
+ /** Offline check for an SDK pin whose client timeout sits behind the platform. */
16
+ export declare function localSdkPreflight({ rootDir, manifest, cliVersion, }: {
17
+ rootDir: string;
18
+ manifest: PreflightManifest;
19
+ cliVersion: string;
20
+ }): Promise<PreflightIssue[]>;
21
+ export declare function reportPreflight(issues: readonly PreflightIssue[]): boolean;
@@ -0,0 +1,58 @@
1
+ import { readFile } from 'node:fs/promises';
2
+ import { join } from 'node:path';
3
+ import { parseDeployedPolicy, preflightManagedFunction, sdkVersionFromPackageJson, } from '@sequenceholdings/managed-functions/config';
4
+ import { AtlasApiError, getJson } from '../atlas-client.js';
5
+ import { LOG } from '../cli-errors.js';
6
+ /**
7
+ * Compare the manifest with the environment's published limits and features.
8
+ * A 404 means that deployment has no policy route yet; local SDK checks still run.
9
+ */
10
+ export async function preflightBeforeUpload({ client, rootDir, manifest, cliVersion, }) {
11
+ let body = null;
12
+ try {
13
+ body = await getJson({ ...client, path: '/api/managed-functions/limits' });
14
+ }
15
+ catch (error) {
16
+ if (!(error instanceof AtlasApiError) || error.status !== 404)
17
+ throw error;
18
+ }
19
+ const policy = parseDeployedPolicy(body);
20
+ return preflightManagedFunction({
21
+ manifest,
22
+ limits: policy.limits,
23
+ capabilities: policy.capabilities,
24
+ cliVersion,
25
+ sdkVersion: await declaredSdkVersion(rootDir),
26
+ });
27
+ }
28
+ /** Offline check for an SDK pin whose client timeout sits behind the platform. */
29
+ export async function localSdkPreflight({ rootDir, manifest, cliVersion, }) {
30
+ return preflightManagedFunction({
31
+ manifest,
32
+ limits: null,
33
+ capabilities: null,
34
+ cliVersion,
35
+ sdkVersion: await declaredSdkVersion(rootDir),
36
+ });
37
+ }
38
+ export function reportPreflight(issues) {
39
+ if (issues.length === 0)
40
+ return false;
41
+ for (const issue of issues)
42
+ console.error(`${LOG} ${issue.message}`);
43
+ console.error(`${LOG} fix the above before deploying`);
44
+ return true;
45
+ }
46
+ async function declaredSdkVersion(rootDir) {
47
+ try {
48
+ return sdkVersionFromPackageJson(await readFile(join(rootDir, 'package.json'), 'utf8'));
49
+ }
50
+ catch (error) {
51
+ if (isMissingFile(error))
52
+ return null;
53
+ throw error;
54
+ }
55
+ }
56
+ function isMissingFile(error) {
57
+ return !!error && typeof error === 'object' && Reflect.get(error, 'code') === 'ENOENT';
58
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * CLI-side copy of atlas/.../managed-functions/egress-postgres.ts. Authors
3
+ * usually do not have the deployment pin, so this checks shape only: Lakebase
4
+ * hostname class, port 5432, and sslmode=verify-full. The server checks the
5
+ * pin at upload.
6
+ */
7
+ export declare function postgresEgressError(input: string): string | null;
@@ -0,0 +1,36 @@
1
+ /**
2
+ * CLI-side copy of atlas/.../managed-functions/egress-postgres.ts. Authors
3
+ * usually do not have the deployment pin, so this checks shape only: Lakebase
4
+ * hostname class, port 5432, and sslmode=verify-full. The server checks the
5
+ * pin at upload.
6
+ */
7
+ const LAKEBASE_POSTGRES_HOST_RE = /^ep-[a-z0-9-]+\.database\.[a-z0-9-]+\.cloud\.databricks\.com$/;
8
+ export function postgresEgressError(input) {
9
+ let url;
10
+ try {
11
+ url = new URL(input.trim());
12
+ }
13
+ catch {
14
+ return `egress entry is not a valid PostgreSQL URL: ${input}`;
15
+ }
16
+ if (url.protocol !== 'postgres:' && url.protocol !== 'postgresql:') {
17
+ return `PostgreSQL egress URLs must use the postgres:// scheme: ${input}`;
18
+ }
19
+ if (url.username !== '' || url.password !== '') {
20
+ return `PostgreSQL egress URLs must not embed credentials: ${input}`;
21
+ }
22
+ if (url.hash !== '')
23
+ return `PostgreSQL egress URLs must not include a fragment: ${input}`;
24
+ if (url.port !== '' && url.port !== '5432') {
25
+ return `PostgreSQL egress is restricted to port 5432: ${input}`;
26
+ }
27
+ const params = [...url.searchParams.entries()];
28
+ if (params.length !== 1 || params[0]?.[0] !== 'sslmode' || params[0]?.[1] !== 'verify-full') {
29
+ return `PostgreSQL egress requires exactly sslmode=verify-full: ${input}`;
30
+ }
31
+ const host = url.hostname.toLowerCase().replace(/\.$/, '');
32
+ if (!LAKEBASE_POSTGRES_HOST_RE.test(host)) {
33
+ return `PostgreSQL egress is restricted to the approved Lakebase database destination: ${input}`;
34
+ }
35
+ return null;
36
+ }
@@ -67,6 +67,13 @@ export declare function manifestEgressIpRanges(entries: readonly string[]): stri
67
67
  */
68
68
  export declare function egressBudgetError(entries: string[]): string | null;
69
69
  export declare const managedFunctionManifestSchema: z.ZodObject<{
70
+ ontology: z.ZodOptional<z.ZodObject<{
71
+ version: z.ZodLiteral<1>;
72
+ read: z.ZodDefault<z.ZodArray<z.ZodString>>;
73
+ write: z.ZodDefault<z.ZodArray<z.ZodString>>;
74
+ produce: z.ZodDefault<z.ZodArray<z.ZodString>>;
75
+ invoke: z.ZodDefault<z.ZodArray<z.ZodString>>;
76
+ }, z.core.$strict>>;
70
77
  cache: z.ZodOptional<z.ZodObject<{
71
78
  enabled: z.ZodDefault<z.ZodBoolean>;
72
79
  tier: z.ZodDefault<z.ZodEnum<{
@@ -90,6 +97,7 @@ export declare const managedFunctionManifestSchema: z.ZodObject<{
90
97
  cpu: z.ZodDefault<z.ZodUnion<readonly [z.ZodLiteral<"auto">, z.ZodNumber]>>;
91
98
  concurrency: z.ZodDefault<z.ZodNumber>;
92
99
  timeout_seconds: z.ZodDefault<z.ZodNumber>;
100
+ max_response_bytes: z.ZodDefault<z.ZodNumber>;
93
101
  min_instances: z.ZodDefault<z.ZodNumber>;
94
102
  max_instances: z.ZodDefault<z.ZodNumber>;
95
103
  invoke_rate_per_minute: z.ZodDefault<z.ZodNumber>;
@@ -1,7 +1,9 @@
1
1
  import { storageScopesSchema, readStorageScopes } from '@sequenceholdings/storage';
2
+ import { postgresEgressError } from './egress-postgres.js';
2
3
  import { cacheManifestSchema, managedFunctionWorkloadLimitsSchema } from '@sequenceholdings/managed-functions/config';
3
4
  import { isIP } from 'node:net';
4
5
  import { z } from 'zod';
6
+ import { ontologyContractSchema } from '@sequenceholdings/orm/canonical';
5
7
  /**
6
8
  * CLI-side mirror of the server manifest schema at
7
9
  * atlas/src/server/services/managed-functions/manifest.ts — same pattern
@@ -62,6 +64,10 @@ export function egressEntryError(input) {
62
64
  const raw = input.trim();
63
65
  if (!raw)
64
66
  return 'egress entry is empty';
67
+ // Before the IPv4 check: a postgres URL whose host is an address is still
68
+ // a database entry, not an IP bypass.
69
+ if (/^postgres(ql)?:/i.test(raw))
70
+ return postgresEgressError(raw);
65
71
  if (looksLikeIpv4EntryCli(raw)) {
66
72
  return egressIpError(raw);
67
73
  }
@@ -306,6 +312,8 @@ function partitionEgressEntries(entries) {
306
312
  for (const entry of entries) {
307
313
  if (egressEntryError(entry) !== null)
308
314
  continue;
315
+ if (/^postgres(ql)?:/i.test(entry.trim()))
316
+ continue;
309
317
  if (looksLikeIpv4EntryCli(entry.trim())) {
310
318
  const normalized = normalizeEgressIpCli(entry);
311
319
  if (!('error' in normalized))
@@ -585,6 +593,7 @@ const invocationIpRangeSchema = z
585
593
  }
586
594
  });
587
595
  export const managedFunctionManifestSchema = z.object({
596
+ ontology: ontologyContractSchema.optional(),
588
597
  cache: cacheManifestSchema.optional(),
589
598
  schema_version: z.literal(1).default(1),
590
599
  function: z.object({
@@ -11,7 +11,10 @@ export function parseFunctionsSourceSpec(args) {
11
11
  if (dir !== undefined && (args.flags.repo !== undefined || args.flags['git-url'] !== undefined)) {
12
12
  throw new Error('--dir cannot be combined with --repo / --git-url.');
13
13
  }
14
- return parseSourceSpec({ positional: dir === undefined ? [] : [dir], flags: args.flags });
14
+ // Functions select --path themselves after materializing (parseFunctionsSourceSelection /
15
+ // resolveFunctionSourceDir); the shared parser would otherwise apply it a second time.
16
+ const { path: _functionPath, ...flags } = args.flags;
17
+ return parseSourceSpec({ positional: dir === undefined ? [] : [dir], flags });
15
18
  }
16
19
  function validateFunctionRepoPath(path) {
17
20
  const segments = path.split('/');
package/dist/main.js CHANGED
@@ -21,8 +21,9 @@
21
21
  * seq-studio doctor check token + env + writer gate
22
22
  * seq-studio help show usage
23
23
  */
24
- import { parseArgs } from './process/commands.js';
25
- import { applyCommand, bundleCommand, doctorCommand, initCommand, lintCommand, planCommand, promoteCommand, pullCommand, simulateCommand, testCommand, } from './process/commands.js';
24
+ import { parseArgs } from './argv.js';
25
+ import { renderCapabilities } from './command-contract.js';
26
+ import { staticHelp } from './command-help.js';
26
27
  // Lazy-load artifact delegate: published @sequenceholdings/artifact-studio/cli
27
28
  // still auto-runs runCli() at module load; importing it here breaks doctor/process.
28
29
  const TOP_LEVEL_USAGE = `usage:
@@ -30,25 +31,27 @@ const TOP_LEVEL_USAGE = `usage:
30
31
  seq-studio add <kind> <name> [internal] add a primitive to the current app monorepo
31
32
  seq-studio deploy -e <env> [internal] deploy primitives from sequence.app.yml
32
33
  seq-studio process <sub> [args] lint | plan | apply | test | simulate | bundle | init
33
- seq-studio artifact <sub> [args] init | build | plan | deploy | dev | list | show | pull | promote | rollback
34
+ seq-studio artifact <sub> [args] init | whoami | link | env | status | list | show | validate | build | plan | deploy | dev | promote | pull | rollback
34
35
  seq-studio functions <sub> [args] init | build | deploy | list | show | limits | invoke | logs | promote | rollback | delete
35
36
  seq-studio storage <sub> [args] init | validate | apply | list | show | mkdir | upload | download | access | trash | restore | purge | operations | abort | delete
36
- seq-studio agents <sub> [args] init | validate | plan | apply | list | show
37
+ seq-studio agents <sub> [args] init | validate | plan | apply | list | show | voice (internal)
37
38
  seq-studio secrets <sub> [args] create | set | list | attach | detach | apply
38
39
  seq-studio repos <sub> [args] list | namespaces | show | create | clone | pull | pulls | delete
39
- seq-studio pipeline <sub> [args] search | describe | schema | sample | query | list | assets | init | validate | plan | deploy | status
40
+ seq-studio pipeline <sub> [args] list | assets | search | describe | schema | sample | query | init | validate | repin-orm | codegen | plan | adopt | unbind | deploy | status | migrate | promote | rollback | run-now
40
41
  seq-studio auth <sub> [args] whoami | pat create | pat list | pat revoke
41
- seq-studio orm <sub> [args] init | generate | validate | plan | apply | execute | diff | migrate-from-yaml
42
+ seq-studio orm <sub> [args] init | generate | validate | plan | apply | execute | diff | migrate-from-yaml | import
42
43
  seq-studio service-accounts <sub> list | show | create (requires provisioning authority)
43
44
  seq-studio access <sub> definitions | list | grant | revoke | resolve
44
45
  seq-studio envs <sub> add | list | refresh environments
45
46
  seq-studio login [--env <name>] authenticate in the browser
46
47
  seq-studio logout [--env <name>] remove one realm's cached user tokens
47
- seq-studio doctor [-e <env>] diagnose config, auth, and writer gate
48
+ seq-studio doctor [-e <env>] [--json] [--offline] diagnose config, auth, toolchain, and writer gate
48
49
  seq-studio version print the installed version
50
+ seq-studio capabilities [--json] describe command availability and access
49
51
  seq-studio help show this message
50
52
 
51
53
  Authenticate with: seq-studio login
54
+ Where supported, --json writes structured stdout; check exit status and pagination.
52
55
  Built-in env: local. Authenticated identities discover more via
53
56
  \`seq-studio envs refresh\`; custom entries live in ~/.config/lattice/config.toml.
54
57
  `;
@@ -56,8 +59,8 @@ const PROCESS_USAGE = `usage:
56
59
  seq-studio process init <dir>
57
60
  seq-studio process lint [--dir <path>] [--offline]
58
61
  seq-studio process plan [--dir <path>] [-e <env>]
59
- seq-studio process apply [--dir <path>] [-e <env>] [--only <id1,id2,...>]
60
- seq-studio process apply --repo processes/<name> [--ref <r>] -e <env> [--only <id1,id2,...>]
62
+ seq-studio process apply [--dir <path>] [-e <env>] [--only <id1,id2,...>] [--platform-managed]
63
+ seq-studio process apply --repo processes/<name> [--ref <r>] -e <env> [--only <id1,id2,...>] [--platform-managed]
61
64
  seq-studio process promote <processId> --version <v> [-e <env>]
62
65
  seq-studio process pull <processId> [--version <v>] [-e <env>] [--out <dir>] [--no-children]
63
66
  seq-studio process test [-e <env>] [--offline]
@@ -76,6 +79,21 @@ export async function run(argv = process.argv.slice(2)) {
76
79
  console.log(TOP_LEVEL_USAGE);
77
80
  return namespace ? 0 : 1;
78
81
  }
82
+ if (namespace === 'capabilities' && hasHelpFlag(sub, rest)) {
83
+ console.log('usage: seq-studio capabilities [--json]');
84
+ return 0;
85
+ }
86
+ if (namespace === 'artifact' && [sub, ...rest].some((arg) => arg === '--token' || arg?.startsWith('--token='))) {
87
+ console.error('Artifact Studio does not accept --token bearer injection. Authenticate with seq-studio login.');
88
+ return 1;
89
+ }
90
+ if (hasHelpFlag(sub, rest)) {
91
+ const help = staticHelp({ namespace, sub });
92
+ if (help) {
93
+ console.log(help);
94
+ return 0;
95
+ }
96
+ }
79
97
  switch (namespace) {
80
98
  case 'init': {
81
99
  const { runAppInitCommand } = await import('./app/commands.js');
@@ -154,14 +172,26 @@ export async function run(argv = process.argv.slice(2)) {
154
172
  console.log(currentVersion());
155
173
  return 0;
156
174
  }
175
+ case 'capabilities':
176
+ return runCapabilities([sub, ...rest].filter((value) => Boolean(value)));
157
177
  case 'doctor':
158
- return doctorCommand(parseArgs([sub, ...rest].filter(Boolean)));
178
+ return (await import('./process/commands.js')).doctorCommand(parseArgs([sub, ...rest].filter(Boolean)));
159
179
  default:
160
180
  console.error(`unknown command: ${namespace}`);
161
181
  console.error(TOP_LEVEL_USAGE);
162
182
  return 1;
163
183
  }
164
184
  }
185
+ function runCapabilities(argv) {
186
+ const args = parseArgs(argv);
187
+ const unknown = Object.keys(args.flags).find((flag) => flag !== 'json');
188
+ if (unknown || args.positional.length > 0 || (args.flags.json !== undefined && args.flags.json !== true)) {
189
+ console.error('usage: seq-studio capabilities [--json]');
190
+ return 1;
191
+ }
192
+ console.log(renderCapabilities({ json: args.flags.json === true }));
193
+ return 0;
194
+ }
165
195
  async function runSessionCommand({ args, command, }) {
166
196
  const usage = `usage: seq-studio ${command} [--env <name>]`;
167
197
  if (args[0] === 'help' || args[0] === '--help' || args[0] === '-h') {
@@ -191,32 +221,37 @@ async function runSessionCommand({ args, command, }) {
191
221
  return 0;
192
222
  }
193
223
  async function runProcessNamespace(sub, rest) {
224
+ if (hasHelpFlag(sub, rest)) {
225
+ console.log(PROCESS_USAGE);
226
+ return 0;
227
+ }
194
228
  if (!sub) {
195
229
  console.error(PROCESS_USAGE);
196
230
  return 1;
197
231
  }
198
- const args = parseArgs(sub === 'bundle' ? [sub, ...rest] : rest);
232
+ const processCommands = await import('./process/commands.js');
233
+ const args = processCommands.parseArgs(sub === 'bundle' ? [sub, ...rest] : rest);
199
234
  switch (sub) {
200
235
  case 'init':
201
- return initCommand(args);
236
+ return processCommands.initCommand(args);
202
237
  case 'lint':
203
- return lintCommand(args);
238
+ return processCommands.lintCommand(args);
204
239
  case 'plan':
205
- return planCommand(args);
240
+ return processCommands.planCommand(args);
206
241
  case 'apply':
207
- return applyCommand(args);
242
+ return processCommands.applyCommand(args);
208
243
  case 'promote':
209
- return promoteCommand(args);
244
+ return processCommands.promoteCommand(args);
210
245
  case 'pull':
211
- return pullCommand(args);
246
+ return processCommands.pullCommand(args);
212
247
  case 'test':
213
- return testCommand(args);
248
+ return processCommands.testCommand(args);
214
249
  case 'simulate':
215
- return simulateCommand(args);
250
+ return processCommands.simulateCommand(args);
216
251
  case 'bundle':
217
252
  // bundle command needs the subcommand (build/pull/inspect) in positional[0].
218
253
  // parseArgs already includes it because we threaded sub into args.
219
- return bundleCommand({
254
+ return processCommands.bundleCommand({
220
255
  positional: args.positional.slice(1),
221
256
  flags: args.flags,
222
257
  });
@@ -235,3 +270,6 @@ async function runProcessNamespace(sub, rest) {
235
270
  return 1;
236
271
  }
237
272
  }
273
+ function hasHelpFlag(sub, rest) {
274
+ return sub === 'help' || sub === '--help' || sub === '-h' || rest.some((arg) => arg === '--help' || arg === '-h');
275
+ }
@@ -5,6 +5,7 @@
5
5
  * `artifact`): resolve `--env` from `~/.config/lattice/config.toml`, set
6
6
  * SEQUENCE_ORM_BASE_URL, share the seqapi token, forward argv.
7
7
  */
8
+ import { type SourceSpec } from '@sequenceholdings/artifact-studio/source-resolver';
8
9
  /**
9
10
  * Classify an ERR_MODULE_NOT_FOUND from importing `@sequenceholdings/orm/cli`:
10
11
  * is the orm package itself absent, or is it present but a dependency (e.g.
@@ -14,4 +15,19 @@
14
15
  * so a substring check would misread a missing dep as the orm package itself.
15
16
  */
16
17
  export declare function isOrmPackageMissing(message: string): boolean;
18
+ export interface OrmRepoSelection {
19
+ spec: Extract<SourceSpec, {
20
+ kind: 'git-service';
21
+ }>;
22
+ path?: string;
23
+ /** argv with `--repo` / `--ref` / `--path` (and their values) removed. */
24
+ rest: string[];
25
+ }
26
+ /**
27
+ * Pull `--repo <ns>/<name>`, `--ref <ref>`, and `--path <dir>` off the argv.
28
+ * Returns null when `--repo` is absent (the local-directory path, unchanged).
29
+ * The ORM CLI's own parser treats every non-flag token as the namespace dir,
30
+ * so these values must never be forwarded to it.
31
+ */
32
+ export declare function extractOrmRepoSelection(argv: readonly string[]): OrmRepoSelection | null;
17
33
  export declare function runOrmCommand(sub: string | undefined, rest: string[]): Promise<number>;