@sequenceholdings/studio-cli 0.4.3 → 0.4.6

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 (45) hide show
  1. package/README.md +92 -19
  2. package/dist/app/agent-refs.d.ts +16 -0
  3. package/dist/app/agent-refs.js +18 -6
  4. package/dist/app/application-registration.d.ts +11 -3
  5. package/dist/app/application-registration.js +20 -6
  6. package/dist/app/application-suggestions.d.ts +58 -0
  7. package/dist/app/application-suggestions.js +164 -0
  8. package/dist/app/deploy.js +7 -4
  9. package/dist/app/env-bindings.js +2 -2
  10. package/dist/app/manifest-validation.d.ts +5 -0
  11. package/dist/app/manifest-validation.js +60 -22
  12. package/dist/app/manifest.d.ts +33 -0
  13. package/dist/app/manifest.js +16 -0
  14. package/dist/app/readme.d.ts +6 -3
  15. package/dist/app/readme.js +36 -6
  16. package/dist/app/scaffold.js +2 -1
  17. package/dist/artifact/delegate.js +6 -34
  18. package/dist/auth-cmds/commands.js +2 -2
  19. package/dist/auth.d.ts +0 -9
  20. package/dist/auth.js +2 -29
  21. package/dist/command-help.d.ts +2 -0
  22. package/dist/command-help.js +89 -0
  23. package/dist/config.d.ts +7 -20
  24. package/dist/config.js +22 -64
  25. package/dist/envs/commands.js +17 -67
  26. package/dist/functions/commands.d.ts +0 -1
  27. package/dist/functions/commands.js +3 -49
  28. package/dist/functions/deploy-preflight.d.ts +1 -1
  29. package/dist/functions/deploy-preflight.js +2 -1
  30. package/dist/functions/manifest.d.ts +3 -0
  31. package/dist/functions/manifest.js +27 -17
  32. package/dist/login.d.ts +0 -6
  33. package/dist/login.js +3 -34
  34. package/dist/main.js +2 -2
  35. package/dist/orm/delegate.js +2 -2
  36. package/dist/pipeline/discovery.js +2 -2
  37. package/dist/pipeline/lifecycle.js +2 -2
  38. package/dist/pipeline/repin-orm.js +3 -3
  39. package/dist/process/commands.js +4 -8
  40. package/dist/repos/commands.d.ts +0 -1
  41. package/dist/repos/commands.js +3 -40
  42. package/dist/storage/commands.js +2 -2
  43. package/package.json +9 -9
  44. package/dist/env-catalog.d.ts +0 -63
  45. package/dist/env-catalog.js +0 -121
@@ -54,6 +54,91 @@ export const PIPELINE_HELP = `usage:
54
54
  --target chooses a logical target when the environment has more than one.
55
55
  Help is available offline.
56
56
  `;
57
+ export const FUNCTIONS_USAGE = `usage:
58
+ seq-studio functions init <dir> scaffold manifest, TypeScript handler, and docs pointers
59
+ seq-studio functions build [--dir d] local pre-flight (manifest, lockfile, SDK timeout cap)
60
+ seq-studio functions register -e <env> [--dir d] register a function shell without deploying
61
+ seq-studio functions deploy -e <env> [-m msg] preflight deployed capabilities, then upload and deploy
62
+ seq-studio functions list -e <env> [--match-local] functions visible on the environment
63
+ seq-studio functions show -e <env> [--fn slug] detail for one function (versions, secrets)
64
+ seq-studio functions limits [-e <env>] [--json] bundled defaults/caps, or deployed policy
65
+ [--fn slug] also show effective runtime limits (requires -e)
66
+ seq-studio functions dev [--dir path] [--port 8080] local HTTP server with cache context
67
+ seq-studio functions invoke -e <env> [--data JSON | --data @file | --stdin]
68
+ invoke a function and print its response
69
+ seq-studio functions logs -e <env> [--limit N] [--since t] function logs (reader-gated)
70
+ seq-studio functions promote <version> -e <env> make a version live
71
+ seq-studio functions rollback [<version>] -e <env> redeploy a prior version
72
+ seq-studio functions delete -e <env> [--yes] archive function + tear down its runtime
73
+ (version history is retained)
74
+
75
+ Flags: -e/--env <env|preview:<slug>> (required for network commands; see: seq-studio envs list) · --fn <slug> · --dir <path>
76
+ --path <repo-subdirectory> (remote build/deploy only) select one function in a multi-function repo
77
+ --from-env-file <path> (default: .env) source file for secret values
78
+ --no-wait · --yes
79
+ --no-provision (deploy) update-only: error instead of registering a new
80
+ shell, writing secret values, or attaching secrets (CI sweep)
81
+
82
+ Local Atlas builds and runs deployed functions on this computer, including teardown.
83
+ "functions dev" runs a standalone handler without Atlas registration.
84
+
85
+ Configure per-function CPU and concurrency in managed-function.yml under limits.
86
+ Run "functions limits" for valid settings; redeploy to apply manifest changes.
87
+ Invocation rates are shared across Atlas replicas; 429 includes Retry-After.
88
+ If the shared rate limiter is unavailable, invocation fails closed with 503.
89
+
90
+ Source for build/deploy: a local --dir (default .), a platform git-service
91
+ repo (--repo <ns>/<name>), or a public HTTPS git URL (--git-url <url>). --path selects
92
+ a function directory within a remote repo; omit it for the existing root-manifest
93
+ layout. --ref selects a branch/tag/commit (default: the repo's default branch).
94
+ Remote sources record the pinned commit as provenance (never dirty) and NEVER
95
+ read a repo-committed .env for secret values — provision secrets server-side
96
+ or pass a local --from-env-file (resolved against your cwd).
97
+
98
+ Interactive --repo builds clone over smart-HTTP and require a repo:read git
99
+ PAT in ATLAS_GIT_PAT (\`seq-studio auth pat create --scopes repo:read\`, or
100
+ Atlas → Settings → Tokens). Headless M2M builds use JSON materialize and
101
+ accept only platform-managed --repo sources. Interactive builds also need
102
+ --env + seq-studio login to resolve the repo and deploy.
103
+ `;
104
+ export const REPOS_USAGE = `usage:
105
+ seq-studio repos list -e <env> [--namespace <slug>] [--mine] repos visible on the environment
106
+ seq-studio repos namespaces [create <slug>] -e <env> list or create namespaces
107
+ seq-studio repos show <ns>/<name> -e <env> repo detail (branches, clone URL)
108
+ seq-studio repos create <ns>/<name> -e <env> [--default-branch b] [--git-backend walgit]
109
+ create a repo seeded with a README; --git-backend
110
+ walgit creates it empty (for pushing existing
111
+ history); needs namespace write
112
+ seq-studio repos clone <ns>/<name> -e <env> [--ref r] [--output dir] [--force] [--full] [--transport auto|git|json]
113
+ seq-studio repos clone --url <https://…/repos/<id>/git> -e <env> [--ref r] [--output dir] [--full]
114
+ seq-studio repos clone --id <uuid> -e <env> [--ref r] [--output dir] [--full]
115
+ smart-HTTP when ATLAS_GIT_PAT is set;
116
+ otherwise JSON materialize (<ns>/<name>)
117
+ seq-studio repos pull <ns>/<name> -e <env> [--ref r] [--out dir] [--force]
118
+ materialize the tree at a ref (JSON API)
119
+ seq-studio repos pulls <list|show|create|diff|merge> [args] review requests (see pulls --help)
120
+ seq-studio repos delete <ns>/<name> -e <env> [--yes] delete a repo (confirm prompt)
121
+ seq-studio repos ci show <ns>/<name> -e <env> [--ref r] preview discovered CI checks
122
+ seq-studio repos ci require <ns>/<name> --check <name> -e <env> reserved (refuses write until sandboxed runner)
123
+ seq-studio repos ci import <ns>/<name> -e <env> [--ref r] reserved (refuses write until sandboxed runner)
124
+
125
+ Flags: -e/--env <env> (required; see: seq-studio envs list)
126
+
127
+ clone prefers real git clone (PAT via askpass — never written into the remote
128
+ URL). --transport auto (default) uses Git when ATLAS_GIT_PAT is set and JSON
129
+ materialization otherwise; --transport git requires a repo:read PAT; --transport
130
+ json ignores ATLAS_GIT_PAT and uses the signed-in Atlas identity (<ns>/<name>
131
+ only; no .git directory). Authentication failures explain this retry path.
132
+ JSON materialization requires repo read access and prints how to create a PAT.
133
+ PAT without Auth0 login: use --id from Repositories → Clone
134
+ (or --url with the environment's canonical HTTPS origin).
135
+ --ref accepts a branch, tag, or commit SHA (SHA → full clone, then checkout).
136
+ Branch and tag clones are shallow (--depth 1). Pass --full for history.
137
+ --output selects the clone directory (--out remains an alias).
138
+
139
+ Authenticate JSON API calls with: seq-studio login
140
+ Authenticate git clone/push with: ATLAS_GIT_PAT (from Atlas Settings → Tokens)
141
+ `;
57
142
  export function staticHelp({ namespace, sub }) {
58
143
  if (namespace === 'artifact')
59
144
  return ARTIFACT_HELP;
@@ -61,6 +146,10 @@ export function staticHelp({ namespace, sub }) {
61
146
  return ORM_HELP;
62
147
  if (namespace === 'pipeline')
63
148
  return PIPELINE_HELP;
149
+ if (namespace === 'functions')
150
+ return FUNCTIONS_USAGE;
151
+ if (namespace === 'repos' && sub !== 'pulls' && sub !== 'ci')
152
+ return REPOS_USAGE;
64
153
  if (namespace === 'doctor') {
65
154
  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
155
  }
package/dist/config.d.ts CHANGED
@@ -1,11 +1,8 @@
1
- import { type EnvTier } from './env-catalog.js';
2
1
  /**
3
2
  * `--env preview:<branch-or-slug>` targets a per-PR Vercel preview deployment
4
3
  * without a config.toml entry. The slug after the prefix is run through the
5
4
  * canonical branch→slug transform (see `preview.ts`). PR-number resolution and
6
5
  * the Cloudflare WAF bypass header live in `artifact/delegate.ts`.
7
- * Preview targeting is a Sequence-staff surface — resolveEnv gates it on the
8
- * discovered tier.
9
6
  */
10
7
  export declare const PREVIEW_ENV_PREFIX = "preview:";
11
8
  export declare const ENV_NAMES: string[];
@@ -14,8 +11,6 @@ export interface LatticeConfig {
14
11
  url: string;
15
12
  }>;
16
13
  defaultEnv: string;
17
- /** Discovered identity tier; `anonymous` when no catalog is cached. */
18
- tier: EnvTier;
19
14
  }
20
15
  export declare function globalConfigDir(): string;
21
16
  export declare function configPath(): string;
@@ -25,9 +20,8 @@ export declare function defaultConfig(): LatticeConfig;
25
20
  *
26
21
  * 1. built-in `local`
27
22
  * 2. local worktrees discovered from `.wt.env`
28
- * 3. the cached discovered catalog (`~/.config/lattice/environments.json`)
29
- * 4. user entries in config.toml (an override for `local`, or net-new envs)
30
- * 5. OpCo registrations shared with seqapi (`~/.config/sequence-api/config.json`)
23
+ * 3. user entries in config.toml (an override for `local`, or net-new envs)
24
+ * 4. OpCo registrations shared with seqapi (`~/.config/sequence-api/config.json`)
31
25
  *
32
26
  * Registered OpCo routes are authoritative for their names so a lower-trust
33
27
  * config.toml override cannot send a tenant token to another origin.
@@ -43,7 +37,7 @@ export interface ResolvedEnv {
43
37
  url: string;
44
38
  }
45
39
  /**
46
- * Copy-pasteable fallback when the discovery catalog is unavailable.
40
+ * Copy-pasteable snippet for adding an environment by hand.
47
41
  *
48
42
  * The `[env.*]` table is safe to append to an existing config.toml. We
49
43
  * intentionally omit `default_env` from the snippet — appending it after
@@ -54,21 +48,14 @@ export interface ResolvedEnv {
54
48
  export declare function manualEnvConfigHint(): string;
55
49
  /**
56
50
  * Resolve `--env <name>` against the effective config. Falls back to the
57
- * config's `defaultEnv` when no name is passed. Throws a clear error when
58
- * the name does not resolve at the caller's tier, listing only the envs
59
- * that are actually visible.
51
+ * config's `defaultEnv` when no name is passed. Throws a clear error listing
52
+ * the configured envs when the name does not resolve.
60
53
  */
61
54
  export declare function resolveEnv({ config, requested, }: {
62
55
  config: LatticeConfig;
63
56
  requested?: string;
64
57
  }): ResolvedEnv;
65
- /**
66
- * Async resolveEnv with lazy discovery: when the requested name doesn't
67
- * resolve from the current config (built-ins + cached catalog + toml),
68
- * refresh the catalog once — a logged-in identity that never ran
69
- * `seq-studio envs refresh` (or fresh CI with AUTH0_M2M_CLIENT_SECRET)
70
- * gets its environments on first use — then retry.
71
- */
72
- export declare function resolveEnvWithDiscovery({ requested, }: {
58
+ /** Resolve `--env <name>` against the config on disk. */
59
+ export declare function resolveConfiguredEnv({ requested, }: {
73
60
  requested?: string;
74
61
  }): Promise<ResolvedEnv>;
package/dist/config.js CHANGED
@@ -5,8 +5,7 @@ import { homedir } from 'node:os';
5
5
  import { basename, dirname, join } from 'node:path';
6
6
  import { promisify } from 'node:util';
7
7
  import { parse as parseToml, stringify as stringifyToml } from 'smol-toml';
8
- import { M2mTokenError } from './auth.js';
9
- import { fetchCatalog, readCachedCatalog, } from './env-catalog.js';
8
+ import { isSequenceAuthEnvName } from './auth.js';
10
9
  import { readRegisteredEnvironmentUrls } from './env-registry.js';
11
10
  import { resolvePreviewFromSlug } from './preview.js';
12
11
  /**
@@ -14,16 +13,15 @@ import { resolvePreviewFromSlug } from './preview.js';
14
13
  * without a config.toml entry. The slug after the prefix is run through the
15
14
  * canonical branch→slug transform (see `preview.ts`). PR-number resolution and
16
15
  * the Cloudflare WAF bypass header live in `artifact/delegate.ts`.
17
- * Preview targeting is a Sequence-staff surface — resolveEnv gates it on the
18
- * discovered tier.
19
16
  */
20
17
  export const PREVIEW_ENV_PREFIX = 'preview:';
21
18
  /**
22
- * Only `local` ships in the published package. Additional environments are
23
- * discovered per-identity from the authenticated catalog endpoint (see
24
- * `env-catalog.ts`) or added by the user in config.toml. `local` is the
25
- * dev / `make dev-all` URL — kept named `local` (not `dev`) so it lines up
26
- * with `seqapi -e local` and `artifact-studio --env local`.
19
+ * Only `local` ships in the published package. Every other environment is
20
+ * one the user configures: `seq-studio envs add <name> <url>` for an OpCo
21
+ * deployment, or a `[env.<name>]` entry in config.toml. The CLI never carries
22
+ * or fetches a list of deployments. `local` is the dev / `make dev-all`
23
+ * URL — kept named `local` (not `dev`) so it lines up with `seqapi -e local`
24
+ * and `artifact-studio --env local`.
27
25
  */
28
26
  const BUILT_IN_ENV_URLS = {
29
27
  local: 'http://localhost:5001',
@@ -102,16 +100,15 @@ export function defaultConfig() {
102
100
  for (const [name, url] of Object.entries(BUILT_IN_ENV_URLS)) {
103
101
  envs[name] = { url };
104
102
  }
105
- return { envs, defaultEnv: 'local', tier: 'anonymous' };
103
+ return { envs, defaultEnv: 'local' };
106
104
  }
107
105
  /**
108
106
  * Read the effective config. Merge precedence (later wins):
109
107
  *
110
108
  * 1. built-in `local`
111
109
  * 2. local worktrees discovered from `.wt.env`
112
- * 3. the cached discovered catalog (`~/.config/lattice/environments.json`)
113
- * 4. user entries in config.toml (an override for `local`, or net-new envs)
114
- * 5. OpCo registrations shared with seqapi (`~/.config/sequence-api/config.json`)
110
+ * 3. user entries in config.toml (an override for `local`, or net-new envs)
111
+ * 4. OpCo registrations shared with seqapi (`~/.config/sequence-api/config.json`)
115
112
  *
116
113
  * Registered OpCo routes are authoritative for their names so a lower-trust
117
114
  * config.toml override cannot send a tenant token to another origin.
@@ -119,13 +116,6 @@ export function defaultConfig() {
119
116
  export async function readConfig() {
120
117
  const merged = defaultConfig();
121
118
  Object.assign(merged.envs, await worktreeEnvironmentUrls());
122
- const catalog = await readCachedCatalog();
123
- if (catalog) {
124
- merged.tier = catalog.tier;
125
- for (const env of catalog.environments) {
126
- merged.envs[env.name] = { url: env.url };
127
- }
128
- }
129
119
  const path = configPath();
130
120
  if (existsSync(path)) {
131
121
  const raw = parseToml(await readFile(path, 'utf8'));
@@ -172,11 +162,8 @@ export async function writeConfig(config) {
172
162
  }
173
163
  await writeFile(path, lines.join('\n') + '\n', { encoding: 'utf8', mode: 0o600 });
174
164
  }
175
- /** Shared hint appended to visibility errors at the anonymous/partner tiers. */
176
- const DISCOVERY_HINT = 'If you expect more environments, authenticate (seq-studio login, or set ' +
177
- 'AUTH0_M2M_CLIENT_SECRET) and run: seq-studio envs refresh';
178
165
  /**
179
- * Copy-pasteable fallback when the discovery catalog is unavailable.
166
+ * Copy-pasteable snippet for adding an environment by hand.
180
167
  *
181
168
  * The `[env.*]` table is safe to append to an existing config.toml. We
182
169
  * intentionally omit `default_env` from the snippet — appending it after
@@ -195,58 +182,29 @@ export function manualEnvConfigHint() {
195
182
  }
196
183
  /**
197
184
  * Resolve `--env <name>` against the effective config. Falls back to the
198
- * config's `defaultEnv` when no name is passed. Throws a clear error when
199
- * the name does not resolve at the caller's tier, listing only the envs
200
- * that are actually visible.
185
+ * config's `defaultEnv` when no name is passed. Throws a clear error listing
186
+ * the configured envs when the name does not resolve.
201
187
  */
202
188
  export function resolveEnv({ config, requested, }) {
203
189
  const name = requested ?? config.defaultEnv;
204
190
  if (name.startsWith(PREVIEW_ENV_PREFIX)) {
205
- if (config.tier !== 'sequence') {
206
- throw new Error(`Preview environments (${PREVIEW_ENV_PREFIX}<branch>) are a Sequence-staff ` +
207
- `surface. ${DISCOVERY_HINT}`);
208
- }
209
191
  const { slug, url } = resolvePreviewFromSlug(name.slice(PREVIEW_ENV_PREFIX.length));
210
192
  return { name: `${PREVIEW_ENV_PREFIX}${slug}`, url };
211
193
  }
212
194
  const env = config.envs[name];
213
195
  if (!env) {
214
196
  const known = Object.keys(config.envs).join(', ');
197
+ // Reserved names use the shared Sequence login, so `envs add` rejects
198
+ // them; point those at config.toml instead.
199
+ const addHint = isSequenceAuthEnvName(name)
200
+ ? `add an [env.${name}] entry to ${configPath()}`
201
+ : `register the deployment with: seq-studio envs add ${name} <url>`;
215
202
  throw new Error(`Unknown env "${name}". Known envs: ${known}. ` +
216
- `Pass --env <name> or set default_env in ${configPath()}. ${DISCOVERY_HINT}`);
203
+ `Pass --env <name>, set default_env in ${configPath()}, or ${addHint}`);
217
204
  }
218
205
  return { name, url: env.url };
219
206
  }
220
- /**
221
- * Async resolveEnv with lazy discovery: when the requested name doesn't
222
- * resolve from the current config (built-ins + cached catalog + toml),
223
- * refresh the catalog once — a logged-in identity that never ran
224
- * `seq-studio envs refresh` (or fresh CI with AUTH0_M2M_CLIENT_SECRET)
225
- * gets its environments on first use — then retry.
226
- */
227
- export async function resolveEnvWithDiscovery({ requested, }) {
228
- const config = await readConfig();
229
- try {
230
- return resolveEnv({ config, requested });
231
- }
232
- catch (err) {
233
- let catalog;
234
- try {
235
- catalog = await fetchCatalog();
236
- }
237
- catch (fetchErr) {
238
- // A configured-but-broken M2M credential is the real failure — CI must
239
- // see the Auth0 error, not a misleading "unknown env" message.
240
- if (fetchErr instanceof M2mTokenError)
241
- throw fetchErr;
242
- // Network/server errors: fall back to whatever is cached, else
243
- // surface the original resolve error.
244
- catalog = await readCachedCatalog();
245
- }
246
- if (!catalog)
247
- throw err;
248
- // Retry against the refreshed catalog; if the name still doesn't
249
- // resolve, the retry throws an error rendered from the fresh state.
250
- return resolveEnv({ config: await readConfig(), requested });
251
- }
207
+ /** Resolve `--env <name>` against the config on disk. */
208
+ export async function resolveConfiguredEnv({ requested, }) {
209
+ return resolveEnv({ config: await readConfig(), requested });
252
210
  }
@@ -1,21 +1,16 @@
1
- import { tryGetAccessToken } from '../auth.js';
2
1
  import { readConfig, configPath, manualEnvConfigHint } from '../config.js';
3
2
  import { readRegisteredEnvironmentUrls, registerEnvironment, } from '../env-registry.js';
4
- import { bootstrapUrl, fetchCatalog, readCachedCatalog, } from '../env-catalog.js';
5
3
  const ENVS_USAGE = `usage:
6
- seq-studio envs list show the environments visible to your identity
7
- seq-studio envs refresh re-fetch the environment catalog for your identity
4
+ seq-studio envs list show the configured environments
8
5
  seq-studio envs add <name> <url>
9
- register an OpCo deployment from public discovery
6
+ register your organization's deployment
10
7
 
11
- The published CLI ships with only the "local" environment. After you
12
- authenticate (seq-studio login, or AUTH0_M2M_CLIENT_SECRET for headless use),
13
- "envs refresh" discovers the environments your identity may target; the
14
- catalog is cached at ~/.config/lattice/environments.json and also refreshes
15
- lazily the first time you pass an -e <env> that isn't cached yet.
8
+ The CLI ships with only the "local" environment. Add your organization's
9
+ deployment with "envs add"; it reads the deployment's public sign-in
10
+ settings, then "seq-studio login --env <name>" signs you in to it.
16
11
 
17
- Local worktrees are discovered from their .wt.env files. Custom entries in
18
- ${configPath()} are always honored on top.
12
+ Local worktrees are discovered from their .wt.env files. Entries in
13
+ ${configPath()} are also honored.
19
14
  `;
20
15
  export async function runEnvsCommand(sub, rest) {
21
16
  switch (sub) {
@@ -23,8 +18,6 @@ export async function runEnvsCommand(sub, rest) {
23
18
  return addCommand(rest);
24
19
  case 'list':
25
20
  return listCommand();
26
- case 'refresh':
27
- return refreshCommand();
28
21
  case undefined:
29
22
  case 'help':
30
23
  case '--help':
@@ -63,70 +56,27 @@ async function addCommand(rest) {
63
56
  return 1;
64
57
  }
65
58
  }
66
- /**
67
- * Tier `anonymous` means "no catalog cached", not necessarily "no token".
68
- * Shared by list + refresh so they don't contradict each other.
69
- */
70
- async function printNoCatalogGuidance(log = console.log) {
71
- const token = await tryGetAccessToken();
72
- log('');
73
- if (token) {
74
- log(`Logged in, but no environment catalog is cached against ${bootstrapUrl()} — ` +
75
- 'only "local" (plus any config.toml entries) is visible. Run: seq-studio envs refresh');
76
- }
77
- else {
78
- log('Not authenticated — only "local" is visible. Authenticate with ' +
79
- '`seq-studio login` (or set AUTH0_M2M_CLIENT_SECRET), then run: seq-studio envs refresh');
80
- }
81
- log('');
82
- log(manualEnvConfigHint());
83
- }
84
59
  async function listCommand() {
85
- const [config, catalog, registered] = await Promise.all([
60
+ const [config, registered] = await Promise.all([
86
61
  readConfig(),
87
- readCachedCatalog(),
88
62
  readRegisteredEnvironmentUrls(),
89
63
  ]);
90
- const discovered = new Set(catalog?.environments.map((env) => env.name) ?? []);
91
64
  const registeredNames = new Set(Object.keys(registered));
92
- console.log(`tier: ${config.tier}`);
93
- if (catalog) {
94
- console.log(`catalog fetched: ${new Date(catalog.fetchedAt).toISOString()}`);
95
- }
96
- console.log('');
97
65
  const width = Math.max(...Object.keys(config.envs).map((name) => name.length));
98
66
  for (const [name, { url }] of Object.entries(config.envs)) {
99
- const source = name === 'local' && !discovered.has(name)
100
- ? 'built-in'
67
+ const source = registeredNames.has(name)
68
+ ? 'registered'
101
69
  : name.startsWith('local:')
102
70
  ? 'worktree'
103
- : discovered.has(name)
104
- ? 'discovered'
105
- : registeredNames.has(name)
106
- ? 'registered'
107
- : 'config.toml';
71
+ : name === 'local'
72
+ ? 'built-in'
73
+ : 'config.toml';
108
74
  console.log(` ${name.padEnd(width)} ${url} (${source})`);
109
75
  }
110
- if (config.tier === 'anonymous') {
111
- await printNoCatalogGuidance();
76
+ if (Object.keys(config.envs).every((name) => name === 'local' || name.startsWith('local:'))) {
77
+ console.log('');
78
+ console.log('Register your organization\'s deployment with: seq-studio envs add <name> <url>');
79
+ console.log(manualEnvConfigHint());
112
80
  }
113
81
  return 0;
114
82
  }
115
- async function refreshCommand() {
116
- let catalog;
117
- try {
118
- catalog = await fetchCatalog();
119
- }
120
- catch (err) {
121
- console.error(`envs refresh: FAIL — ${err instanceof Error ? err.message : String(err)}`);
122
- console.error('');
123
- console.error(manualEnvConfigHint());
124
- return 1;
125
- }
126
- if (!catalog) {
127
- await printNoCatalogGuidance();
128
- return 0;
129
- }
130
- console.log(`tier: ${catalog.tier} — ${catalog.environments.length} environment(s) cached.`);
131
- return listCommand();
132
- }
@@ -93,5 +93,4 @@ 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 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
96
  export declare function runFunctionsCommand(sub: string | undefined, args: ParsedArgs): Promise<number>;
@@ -1,3 +1,4 @@
1
+ import { FUNCTIONS_USAGE } from '../command-help.js';
1
2
  import { execFile } from 'node:child_process';
2
3
  import { mkdir, readFile, writeFile } from 'node:fs/promises';
3
4
  import { existsSync } from 'node:fs';
@@ -8,7 +9,7 @@ import { Writable } from 'node:stream';
8
9
  import { load as parseYaml } from 'js-yaml';
9
10
  import { MANAGED_FUNCTION_LIMITS, MF_LIMITS_DEFAULTS } from '@sequenceholdings/managed-functions/config';
10
11
  import { getAccessTokenWithMode, tryGetAccessTokenWithMode } from '../auth.js';
11
- import { resolveEnvWithDiscovery } from '../config.js';
12
+ import { resolveConfiguredEnv } from '../config.js';
12
13
  import { AtlasApiError, deleteJson, getJson, postJson, postJsonResponse, } from '../atlas-client.js';
13
14
  import { clarifyApplyFailureReason, printCliError } from '../cli-errors.js';
14
15
  import { currentVersion } from '../update-check.js';
@@ -45,7 +46,7 @@ export async function buildContext(args) {
45
46
  if (!requested) {
46
47
  throw new Error(REQUIRE_EXPLICIT_ENV_MESSAGE);
47
48
  }
48
- const env = await resolveEnvWithDiscovery({ requested });
49
+ const env = await resolveConfiguredEnv({ requested });
49
50
  const auth = await getAccessTokenWithMode({ env: env.name, targetUrl: env.url });
50
51
  return { authMode: auth.authMode, env, token: auth.token };
51
52
  }
@@ -1165,53 +1166,6 @@ export async function functionsDeleteCommand(args) {
1165
1166
  // ---------------------------------------------------------------------------
1166
1167
  // dispatcher
1167
1168
  // ---------------------------------------------------------------------------
1168
- export const FUNCTIONS_USAGE = `usage:
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)
1171
- seq-studio functions register -e <env> [--dir d] register a function shell without deploying
1172
- seq-studio functions deploy -e <env> [-m msg] preflight deployed capabilities, then upload and deploy
1173
- seq-studio functions list -e <env> [--match-local] functions visible on the environment
1174
- seq-studio functions show -e <env> [--fn slug] detail for one function (versions, secrets)
1175
- seq-studio functions limits [-e <env>] [--json] bundled defaults/caps, or deployed policy
1176
- [--fn slug] also show effective runtime limits (requires -e)
1177
- seq-studio functions dev [--dir path] [--port 8080] local HTTP server with cache context
1178
- seq-studio functions invoke -e <env> [--data JSON | --data @file | --stdin]
1179
- invoke a function and print its response
1180
- seq-studio functions logs -e <env> [--limit N] [--since t] function logs (reader-gated)
1181
- seq-studio functions promote <version> -e <env> make a version live
1182
- seq-studio functions rollback [<version>] -e <env> redeploy a prior version
1183
- seq-studio functions delete -e <env> [--yes] archive function + tear down its runtime
1184
- (version history is retained)
1185
-
1186
- Flags: -e/--env <env|preview:<slug>> (required for network commands; see: seq-studio envs list) · --fn <slug> · --dir <path>
1187
- --path <repo-subdirectory> (remote build/deploy only) select one function in a multi-function repo
1188
- --from-env-file <path> (default: .env) source file for secret values
1189
- --no-wait · --yes
1190
- --no-provision (deploy) update-only: error instead of registering a new
1191
- shell, writing secret values, or attaching secrets (CI sweep)
1192
-
1193
- Local Atlas builds and runs deployed functions on this computer, including teardown.
1194
- "functions dev" runs a standalone handler without Atlas registration.
1195
-
1196
- Configure per-function CPU and concurrency in managed-function.yml under limits.
1197
- Run "functions limits" for valid settings; redeploy to apply manifest changes.
1198
- Invocation rates are shared across Atlas replicas; 429 includes Retry-After.
1199
- If the shared rate limiter is unavailable, invocation fails closed with 503.
1200
-
1201
- Source for build/deploy: a local --dir (default .), a platform git-service
1202
- repo (--repo <ns>/<name>), or a public HTTPS git URL (--git-url <url>). --path selects
1203
- a function directory within a remote repo; omit it for the existing root-manifest
1204
- layout. --ref selects a branch/tag/commit (default: the repo's default branch).
1205
- Remote sources record the pinned commit as provenance (never dirty) and NEVER
1206
- read a repo-committed .env for secret values — provision secrets server-side
1207
- or pass a local --from-env-file (resolved against your cwd).
1208
-
1209
- Interactive --repo builds clone over smart-HTTP and require a repo:read git
1210
- PAT in ATLAS_GIT_PAT (\`seq-studio auth pat create --scopes repo:read\`, or
1211
- Atlas → Settings → Tokens). Headless M2M builds use JSON materialize and
1212
- accept only platform-managed --repo sources. Interactive builds also need
1213
- --env + seq-studio login to resolve the repo and deploy.
1214
- `;
1215
1169
  export async function runFunctionsCommand(sub, args) {
1216
1170
  try {
1217
1171
  switch (sub) {
@@ -12,7 +12,7 @@ export declare function preflightBeforeUpload({ client, rootDir, manifest, cliVe
12
12
  manifest: PreflightManifest;
13
13
  cliVersion: string;
14
14
  }): Promise<PreflightIssue[]>;
15
- /** Offline check for an SDK pin whose client timeout sits behind the platform. */
15
+ /** Offline schema and tooling checks; deployment feature support is checked before upload. */
16
16
  export declare function localSdkPreflight({ rootDir, manifest, cliVersion, }: {
17
17
  rootDir: string;
18
18
  manifest: PreflightManifest;
@@ -25,12 +25,13 @@ export async function preflightBeforeUpload({ client, rootDir, manifest, cliVers
25
25
  sdkVersion: await declaredSdkVersion(rootDir),
26
26
  });
27
27
  }
28
- /** Offline check for an SDK pin whose client timeout sits behind the platform. */
28
+ /** Offline schema and tooling checks; deployment feature support is checked before upload. */
29
29
  export async function localSdkPreflight({ rootDir, manifest, cliVersion, }) {
30
30
  return preflightManagedFunction({
31
31
  manifest,
32
32
  limits: null,
33
33
  capabilities: null,
34
+ checkDeployment: false,
34
35
  cliVersion,
35
36
  sdkVersion: await declaredSdkVersion(rootDir),
36
37
  });
@@ -133,6 +133,9 @@ export declare const managedFunctionManifestSchema: z.ZodObject<{
133
133
  editor: "editor";
134
134
  admin: "admin";
135
135
  }>>>;
136
+ processes: z.ZodOptional<z.ZodObject<{
137
+ read: z.ZodArray<z.ZodString>;
138
+ }, z.core.$strict>>;
136
139
  roles: z.ZodOptional<z.ZodObject<{
137
140
  definitions: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
138
141
  description: z.ZodOptional<z.ZodString>;
@@ -1,6 +1,7 @@
1
1
  import { storageScopesSchema, readStorageScopes } from '@sequenceholdings/storage';
2
2
  import { postgresEgressError } from './egress-postgres.js';
3
3
  import { cacheManifestSchema, managedFunctionWorkloadLimitsSchema } from '@sequenceholdings/managed-functions/config';
4
+ import { functionProcessReadScopesSchema } from '@sequenceholdings/managed-functions/config';
4
5
  import { isIP } from 'node:net';
5
6
  import { z } from 'zod';
6
7
  import { ontologyContractSchema } from '@sequenceholdings/orm/canonical';
@@ -592,6 +593,23 @@ const invocationIpRangeSchema = z
592
593
  });
593
594
  }
594
595
  });
596
+ function refineServiceAccountAttachment({ requiresServiceAccount, serviceAccount, ctx }) {
597
+ if (requiresServiceAccount && serviceAccount === undefined) {
598
+ ctx.addIssue({
599
+ code: 'custom',
600
+ message: 'Data, storage or process capabilities require a top-level service_account — the platform service ' +
601
+ 'account this function acts as for service access (the deployer needs the actor role on it)',
602
+ path: ['service_account'],
603
+ });
604
+ }
605
+ if (!requiresServiceAccount && serviceAccount !== undefined) {
606
+ ctx.addIssue({
607
+ code: 'custom',
608
+ message: 'service_account requires capabilities.data or capabilities.storage or capabilities.processes',
609
+ path: ['service_account'],
610
+ });
611
+ }
612
+ }
595
613
  export const managedFunctionManifestSchema = z.object({
596
614
  ontology: ontologyContractSchema.optional(),
597
615
  cache: cacheManifestSchema.optional(),
@@ -649,8 +667,8 @@ export const managedFunctionManifestSchema = z.object({
649
667
  })
650
668
  .default([]),
651
669
  /**
652
- * The platform service account available for explicit service-mode data or storage access
653
- * (slug or id). Required whenever data or storage capabilities are declared,
670
+ * The platform service account available for explicit service-mode data, storage or process access
671
+ * (slug or id). Required whenever data, storage or process capabilities are declared,
654
672
  * rejected otherwise. Resolved and authorized server-side at activation —
655
673
  * the deploy actor must hold `actor` on the account when the attachment
656
674
  * changes. Mirrors atlas/src/server/services/managed-functions/manifest.ts.
@@ -673,6 +691,7 @@ export const managedFunctionManifestSchema = z.object({
673
691
  */
674
692
  capabilities: z.object({
675
693
  storage: storageScopesSchema.optional(),
694
+ processes: functionProcessReadScopesSchema.optional(),
676
695
  roles: customRolesBlockSchema.optional(),
677
696
  uses: capabilityPinsSchema,
678
697
  gates: capabilityGatesSchema,
@@ -774,21 +793,12 @@ export const managedFunctionManifestSchema = z.object({
774
793
  // action, operation, or raw query — the same rule the server's floor
775
794
  // reconciliation uses (readManifestDataNamespaces).
776
795
  const reachesData = Object.keys(readStorageScopes(manifest)).length > 0 || Object.values(manifest.capabilities.data).some((block) => block.tables.length > 0 || block.actions.length > 0 || block.operations.length > 0 || block.query);
777
- if (reachesData && manifest.service_account === undefined) {
778
- ctx.addIssue({
779
- code: 'custom',
780
- message: 'Data or storage capabilities require a top-level service_account — the platform service ' +
781
- 'account this function acts as for ORM data access (the deployer needs the actor role on it)',
782
- path: ['service_account'],
783
- });
784
- }
785
- if (!reachesData && manifest.service_account !== undefined) {
786
- ctx.addIssue({
787
- code: 'custom',
788
- message: 'service_account requires capabilities.data or capabilities.storage',
789
- path: ['service_account'],
790
- });
791
- }
796
+ const reachesProcesses = (manifest.capabilities.processes?.read.length ?? 0) > 0;
797
+ refineServiceAccountAttachment({
798
+ requiresServiceAccount: reachesData || reachesProcesses,
799
+ serviceAccount: manifest.service_account,
800
+ ctx,
801
+ });
792
802
  });
793
803
  export function manifestSecretNames(value) {
794
804
  return value.secrets.flatMap((entry) => typeof entry === 'string'