@sequenceholdings/studio-cli 0.5.4 → 0.5.5

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 (50) hide show
  1. package/README.md +151 -1
  2. package/dist/agents/source.js +2 -1
  3. package/dist/app/adapters.js +2 -1
  4. package/dist/app/commands.js +4 -4
  5. package/dist/artifact/delegate.js +16 -4
  6. package/dist/atlas-client.js +5 -1
  7. package/dist/auth-cmds/commands.d.ts +1 -1
  8. package/dist/auth-cmds/commands.js +3 -0
  9. package/dist/auth.d.ts +2 -1
  10. package/dist/auth.js +16 -0
  11. package/dist/command-contract.d.ts +8 -8
  12. package/dist/command-contract.js +6 -6
  13. package/dist/command-help.d.ts +3 -2
  14. package/dist/command-help.js +31 -3
  15. package/dist/command-input.js +2 -2
  16. package/dist/config.d.ts +5 -0
  17. package/dist/config.js +14 -1
  18. package/dist/env-flags.d.ts +6 -0
  19. package/dist/env-flags.js +9 -0
  20. package/dist/functions/commands.d.ts +4 -1
  21. package/dist/functions/commands.js +27 -5
  22. package/dist/functions/deploy-preflight.js +2 -2
  23. package/dist/functions/manifest.d.ts +43 -29
  24. package/dist/functions/manifest.js +37 -74
  25. package/dist/main.js +42 -2
  26. package/dist/orm/delegate.js +25 -4
  27. package/dist/orm/read.d.ts +54 -0
  28. package/dist/orm/read.js +308 -0
  29. package/dist/pipeline/commands.js +10 -0
  30. package/dist/pipeline/discovery.js +3 -16
  31. package/dist/pipeline/retirement.d.ts +3 -0
  32. package/dist/pipeline/retirement.js +34 -0
  33. package/dist/process/build.js +4 -0
  34. package/dist/process/codegen.js +2 -0
  35. package/dist/process/commands.js +57 -18
  36. package/dist/process/plan-diff.js +1 -0
  37. package/dist/process/runs.d.ts +14 -0
  38. package/dist/process/runs.js +238 -0
  39. package/dist/repos/ci-status.js +28 -0
  40. package/dist/repos/commands.js +6 -0
  41. package/dist/repos/git-credential.d.ts +3 -2
  42. package/dist/repos/git-credential.js +52 -3
  43. package/dist/repos/pulls.d.ts +7 -1
  44. package/dist/repos/pulls.js +162 -22
  45. package/dist/sandbox-auth.d.ts +52 -0
  46. package/dist/sandbox-auth.js +105 -0
  47. package/dist/storage/commands.js +6 -5
  48. package/dist/text-table.d.ts +7 -0
  49. package/dist/text-table.js +16 -0
  50. package/package.json +9 -9
@@ -6,12 +6,17 @@ export const ORM_HELP = `usage:
6
6
  seq-studio orm plan [dir] -e <env>
7
7
  seq-studio orm apply [dir] -e <env>
8
8
  seq-studio orm execute <operation> [dir] --variables-file <file> -e <env>
9
+ seq-studio orm read <namespace> <table> -e <env> [--where <column>=<op>.<value>]... [--select <cols>] [--order <col>[.desc]] [--limit N] [--offset N] [--json|--jsonl]
10
+ seq-studio orm sql <namespace> --query <sql> | --file <path> -e <env> [--param <name>[:<type>]=<value>]... | [--params <json-object>] [--json|--jsonl]
9
11
  seq-studio orm diff [dir] [--check] [--allow-destructive] [--rebase]
10
12
  seq-studio orm migrate-from-yaml <dir>
11
13
  seq-studio orm import [dir] --spec <file> | --table <table> --from <schema.table> --map <target=source,...>
12
14
 
13
15
  -e/--env is required for commands that contact Atlas. Use seq-studio envs list
14
16
  to discover environments and seq-studio login to authenticate.
17
+ read and sql query a v2 namespace as you through its built-in read-only SQL.
18
+ sql must name tables as <namespace>.<table> (FROM lending.loans, not FROM loans).
19
+ Run seq-studio orm read --help for the filter grammar, parameters, and output formats.
15
20
  `;
16
21
  export const ARTIFACT_HELP = `usage:
17
22
  seq-studio artifact init <dir> [--template react-vite|nextjs]
@@ -115,7 +120,8 @@ export const REPOS_USAGE = `usage:
115
120
  configures login for subsequent git pull/push
116
121
  seq-studio repos pull <ns>/<name> -e <env> [--ref r] [--out dir] [--force]
117
122
  materialize the tree at a ref (JSON API)
118
- seq-studio repos pulls <list|show|create|diff|merge> [args] review requests (see pulls --help)
123
+ seq-studio repos pulls <list|show|create|diff|merge|close|comment|comments|review|reviews|checks> [args]
124
+ review requests (see pulls --help)
119
125
  seq-studio repos delete <ns>/<name> -e <env> [--yes] delete a repo (confirm prompt)
120
126
  seq-studio repos ci init [--dir <repository>] create a native pipeline using platform defaults
121
127
  seq-studio repos ci show <ns>/<name> -e <env> --pr <number> [--json] inspect the server CI plan and runs
@@ -139,10 +145,30 @@ export const REPOS_USAGE = `usage:
139
145
  Authenticate JSON API calls with: seq-studio login
140
146
  Authenticate git clone/push with: seq-studio login --env <env>
141
147
  `;
148
+ export const PROCESS_RUNS_USAGE = `usage:
149
+ seq-studio process runs start <process-id> -e <env> [--version <v>] [--run-id <id>]
150
+ [--metadata-file <file.json>] [--title <text>] [--entity <type>:<id>] [--json]
151
+ seq-studio process runs list -e <env> [--process <id>] [--status <status>]
152
+ [--entity-type <type>] [--entity-id <id>] [--archived] [--limit 1..500] [--json]
153
+ seq-studio process runs show <run-id> -e <env> [--wait [--timeout <seconds>]] [--json]
154
+ seq-studio process runs cancel <run-id> -e <env> [--json]
155
+
156
+ Runs start and are read as you: start needs invoker on the process, show and
157
+ list return only runs you can view, and cancel needs invoker on the process.
158
+ --version pins a published process version; omitted, the active version runs.
159
+ --run-id makes start idempotent: repeating it for the same process returns the
160
+ existing run instead of starting another. --metadata-file is a JSON object
161
+ stored on the run.
162
+ list returns the newest runs first, up to --limit (default 50, max 500); the run
163
+ API has no cursor, so narrow with filters to reach older runs.
164
+ --status: pending, running, completed, failed, cancelled, timed_out.
165
+ show --wait polls until the run finishes (default timeout 600s); the run keeps
166
+ going if the wait times out.
167
+ `;
142
168
  export function staticHelp({ namespace, sub }) {
143
169
  if (namespace === 'artifact')
144
170
  return ARTIFACT_HELP;
145
- if (namespace === 'orm')
171
+ if (namespace === 'orm' && sub !== 'read' && sub !== 'sql')
146
172
  return ORM_HELP;
147
173
  if (namespace === 'pipeline')
148
174
  return PIPELINE_HELP;
@@ -153,8 +179,10 @@ export function staticHelp({ namespace, sub }) {
153
179
  if (namespace === 'doctor') {
154
180
  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`;
155
181
  }
182
+ if (namespace === 'process' && sub === 'runs')
183
+ return PROCESS_RUNS_USAGE;
156
184
  if (namespace === 'process' && (!sub || sub === 'help' || sub === '--help' || sub === '-h')) {
157
- return `usage: seq-studio process <init|lint|plan|apply|promote|pull|test|simulate|bundle> [args]\n\nHelp is available offline.\n`;
185
+ return `usage: seq-studio process <init|lint|plan|apply|promote|pull|runs|test|simulate|bundle> [args]\n\nHelp is available offline.\n`;
158
186
  }
159
187
  return undefined;
160
188
  }
@@ -1,4 +1,4 @@
1
- import { REQUIRE_EXPLICIT_ENV_MESSAGE } from './env-flags.js';
1
+ import { REQUIRE_EXPLICIT_ENV_MESSAGE, explicitOrSandboxEnv } from './env-flags.js';
2
2
  /** Validate before authentication: a typo must never silently widen a mutation. */
3
3
  export function validateCommandInput({ args, flags, positional, }) {
4
4
  const allowed = { ...flags, env: 'string', e: 'string', json: 'boolean' };
@@ -16,7 +16,7 @@ export function validateCommandInput({ args, flags, positional, }) {
16
16
  .filter((value) => typeof value === 'string');
17
17
  if (new Set(envs).size > 1)
18
18
  throw new Error('Specify only one environment per command.');
19
- if (envs.length === 0)
19
+ if (envs.length === 0 && !explicitOrSandboxEnv(undefined))
20
20
  throw new Error(REQUIRE_EXPLICIT_ENV_MESSAGE);
21
21
  if (args.positional.length !== positional) {
22
22
  throw new Error(`Expected ${positional} positional argument(s). See --help.`);
package/dist/config.d.ts CHANGED
@@ -75,3 +75,8 @@ export declare function addSharedLoginEnvironment({ name, baseUrl: rawBaseUrl, f
75
75
  export declare function resolveConfiguredEnv({ requested, }: {
76
76
  requested?: string;
77
77
  }): Promise<ResolvedEnv>;
78
+ /**
79
+ * In sandbox token mode the deployment comes from SEQ_STUDIO_BASE_URL and any
80
+ * `-e` value is ignored: the sandbox can reach no other origin.
81
+ */
82
+ export declare function resolveSandboxEnv(): ResolvedEnv | null;
package/dist/config.js CHANGED
@@ -9,6 +9,7 @@ import { validateDeploymentBaseUrl } from '@sequenceholdings/artifact-studio/dep
9
9
  import { isSequenceAuthEnvName, isSharedLoginDeploymentName, usesSharedSequenceLogin } from './auth.js';
10
10
  import { fetchDeploymentLogin, readRegisteredEnvironmentUrls } from './env-registry.js';
11
11
  import { resolvePreviewFromSlug } from './preview.js';
12
+ import { SANDBOX_ENV_NAME, sandboxTarget } from './sandbox-auth.js';
12
13
  /**
13
14
  * `--env preview:<branch-or-slug>` targets a per-PR Vercel preview deployment
14
15
  * without a config.toml entry. The slug after the prefix is run through the
@@ -187,6 +188,9 @@ export function manualEnvConfigHint() {
187
188
  * the configured envs when the name does not resolve.
188
189
  */
189
190
  export function resolveEnv({ config, requested, }) {
191
+ const sandbox = resolveSandboxEnv();
192
+ if (sandbox)
193
+ return sandbox;
190
194
  const name = requested ?? config.defaultEnv;
191
195
  if (name.startsWith(PREVIEW_ENV_PREFIX)) {
192
196
  const { slug, url } = resolvePreviewFromSlug(name.slice(PREVIEW_ENV_PREFIX.length));
@@ -239,5 +243,14 @@ export async function addSharedLoginEnvironment({ name, baseUrl: rawBaseUrl, fet
239
243
  }
240
244
  /** Resolve `--env <name>` against the config on disk. */
241
245
  export async function resolveConfiguredEnv({ requested, }) {
242
- return resolveEnv({ config: await readConfig(), requested });
246
+ // Checked before readConfig so a sandbox never reads ~/.config or the registry.
247
+ return resolveSandboxEnv() ?? resolveEnv({ config: await readConfig(), requested });
248
+ }
249
+ /**
250
+ * In sandbox token mode the deployment comes from SEQ_STUDIO_BASE_URL and any
251
+ * `-e` value is ignored: the sandbox can reach no other origin.
252
+ */
253
+ export function resolveSandboxEnv() {
254
+ const sandbox = sandboxTarget();
255
+ return sandbox ? { name: SANDBOX_ENV_NAME, url: sandbox.baseUrl } : null;
243
256
  }
@@ -8,3 +8,9 @@ export declare const REQUIRE_EXPLICIT_ENV_MESSAGE = "You must specify an environ
8
8
  export declare function normalizeShortEnvFlag(argv: readonly string[]): string[];
9
9
  /** Only valid AFTER normalizeShortEnvFlag — recognizes the two-token form. */
10
10
  export declare function readEnvFromArgv(rest: readonly string[]): string | undefined;
11
+ /**
12
+ * The environment a network command targets: the explicit `-e` value, or the
13
+ * sandbox in sandbox token mode, where SEQ_STUDIO_BASE_URL already names the
14
+ * deployment and `-e` is optional (and ignored).
15
+ */
16
+ export declare function explicitOrSandboxEnv(requested: string | undefined): string | undefined;
package/dist/env-flags.js CHANGED
@@ -3,6 +3,7 @@
3
3
  * CLIs only recognize the two-token `--env <value>` form, so every `-e value`
4
4
  * / `-e=value` / `--env=value` spelling is rewritten before forwarding.
5
5
  */
6
+ import { SANDBOX_ENV_NAME, isSandboxTokenMode } from './sandbox-auth.js';
6
7
  /** Shared copy for network commands that must not silently fall back to `local`. */
7
8
  export const REQUIRE_EXPLICIT_ENV_MESSAGE = 'You must specify an environment you have access to with `-e <env>`. Run `seq-studio envs list` to see available environments.';
8
9
  export function normalizeShortEnvFlag(argv) {
@@ -47,3 +48,11 @@ export function readEnvFromArgv(rest) {
47
48
  }
48
49
  return undefined;
49
50
  }
51
+ /**
52
+ * The environment a network command targets: the explicit `-e` value, or the
53
+ * sandbox in sandbox token mode, where SEQ_STUDIO_BASE_URL already names the
54
+ * deployment and `-e` is optional (and ignored).
55
+ */
56
+ export function explicitOrSandboxEnv(requested) {
57
+ return isSandboxTokenMode() ? SANDBOX_ENV_NAME : requested;
58
+ }
@@ -11,6 +11,7 @@ export interface FunctionSummary {
11
11
  description: string | null;
12
12
  runtime: string;
13
13
  activeVersionId?: string | null;
14
+ immutableRelease?: boolean;
14
15
  deployed: boolean;
15
16
  secretsNeedDeploy?: boolean;
16
17
  currentUserAccess: string | null;
@@ -69,12 +70,14 @@ export declare function printError(error: unknown): void;
69
70
  export declare function functionsInitCommand(args: ParsedArgs): Promise<number>;
70
71
  export declare function functionsBuildCommand(args: ParsedArgs): Promise<number>;
71
72
  export declare function functionsDeployCommand(args: ParsedArgs): Promise<number>;
72
- export declare function pollVersion({ ctx, functionId, versionId, egressNote, }: {
73
+ export declare function pollVersion({ ctx, functionId, versionId, egressNote, immutableRelease, }: {
73
74
  ctx: CommandContext;
74
75
  functionId: string;
75
76
  versionId: string;
76
77
  /** Print the egress-propagation hint once the version is live. */
77
78
  egressNote?: boolean;
79
+ /** Require platform-recorded immutable activation rather than authored YAML alone. */
80
+ immutableRelease?: boolean;
78
81
  }): Promise<number>;
79
82
  export declare function functionsListCommand(args: ParsedArgs): Promise<number>;
80
83
  export declare function functionsShowCommand(args: ParsedArgs): Promise<number>;
@@ -9,12 +9,13 @@ import { Writable } from 'node:stream';
9
9
  import { load as parseYaml } from 'js-yaml';
10
10
  import { MANAGED_FUNCTION_LIMITS, MF_LIMITS_DEFAULTS } from '@sequenceholdings/managed-functions/config';
11
11
  import { getAccessTokenWithMode, tryGetAccessTokenWithMode } from '../auth.js';
12
+ import { sourceAuthMode } from '../sandbox-auth.js';
12
13
  import { resolveConfiguredEnv } from '../config.js';
13
14
  import { AtlasApiError, deleteJson, getJson, postJson, postJsonResponse, } from '../atlas-client.js';
14
15
  import { clarifyApplyFailureReason, printCliError } from '../cli-errors.js';
15
16
  import { currentVersion } from '../update-check.js';
16
17
  import { localSdkPreflight, preflightBeforeUpload, reportPreflight } from './deploy-preflight.js';
17
- import { REQUIRE_EXPLICIT_ENV_MESSAGE } from '../env-flags.js';
18
+ import { REQUIRE_EXPLICIT_ENV_MESSAGE, explicitOrSandboxEnv } from '../env-flags.js';
18
19
  import { confirmYes } from '../prompt.js';
19
20
  import { writeScaffoldGuidance } from '../scaffold-guidance.js';
20
21
  import { collectBundleFiles, isDirectory, validateLocalBundle, } from './bundle.js';
@@ -33,7 +34,7 @@ export function flagBool(flags, ...keys) {
33
34
  return keys.some((key) => flags[key] === true || flags[key] === 'true');
34
35
  }
35
36
  export function requestedEnvironment(args) {
36
- return ((typeof args.flags.env === 'string' ? args.flags.env : undefined) ??
37
+ return explicitOrSandboxEnv((typeof args.flags.env === 'string' ? args.flags.env : undefined) ??
37
38
  (typeof args.flags.e === 'string' ? args.flags.e : undefined));
38
39
  }
39
40
  /**
@@ -58,7 +59,7 @@ export function clientOptions(ctx) {
58
59
  }
59
60
  function sourceClientOptions(ctx) {
60
61
  return {
61
- ...(ctx.authMode ? { authMode: ctx.authMode } : {}),
62
+ ...(ctx.authMode ? { authMode: sourceAuthMode(ctx.authMode) } : {}),
62
63
  ...clientOptions(ctx),
63
64
  };
64
65
  }
@@ -71,7 +72,7 @@ async function buildSourceOptions({ args, spec, }) {
71
72
  failClosedForM2m: true,
72
73
  env: requestedEnvironment(args),
73
74
  });
74
- return auth ? { authMode: auth.authMode } : {};
75
+ return auth ? { authMode: sourceAuthMode(auth.authMode) } : {};
75
76
  }
76
77
  return {};
77
78
  }
@@ -540,6 +541,14 @@ async function deployFromResolvedSource({ args, spec, ctx: earlyCtx, source, })
540
541
  path: `/api/managed-functions?slug=${encodeURIComponent(slug)}`,
541
542
  });
542
543
  const existingShell = functions.find((f) => f.slug === slug) ?? null;
544
+ if (existingShell?.immutableRelease === true) {
545
+ console.error(`${LOG} this function is an immutable release. Create a new function ID; this identity cannot be redeployed.`);
546
+ return 1;
547
+ }
548
+ if (manifest.function.immutable_release === true && existingShell?.activeVersionId) {
549
+ console.error(`${LOG} immutable release opt-in must precede first activation. Create a new function ID.`);
550
+ return 1;
551
+ }
543
552
  const shellAction = existingShell
544
553
  ? `existing shell on ${ctx.env.name}`
545
554
  : `will register new shell on ${ctx.env.name}`;
@@ -755,6 +764,11 @@ async function deployFromResolvedSource({ args, spec, ctx: earlyCtx, source, })
755
764
  }
756
765
  catch (error) {
757
766
  if (error instanceof AtlasApiError && error.status === 409) {
767
+ if (typeof error.body === 'object' && error.body !== null &&
768
+ Reflect.get(error.body, 'code') === 'IMMUTABLE_FUNCTION_RELEASE') {
769
+ console.error(`${LOG} ${error.message}`);
770
+ return 1;
771
+ }
758
772
  console.error(`${LOG} version ${nextVersion} already exists — another deploy may have raced. Re-run deploy to allocate the next version.`);
759
773
  return 1;
760
774
  }
@@ -772,11 +786,12 @@ async function deployFromResolvedSource({ args, spec, ctx: earlyCtx, source, })
772
786
  ctx,
773
787
  functionId: fn.id,
774
788
  versionId: version.id,
789
+ immutableRelease: manifest.function.immutable_release === true,
775
790
  egressNote: manifestEgressHosts(manifest.egress).length > 0 ||
776
791
  manifestEgressIpRanges(manifest.egress).length > 0,
777
792
  });
778
793
  }
779
- export async function pollVersion({ ctx, functionId, versionId, egressNote = false, }) {
794
+ export async function pollVersion({ ctx, functionId, versionId, egressNote = false, immutableRelease = false, }) {
780
795
  const deadline = Date.now() + POLL_TIMEOUT_MS;
781
796
  let lastStatus = '';
782
797
  for (;;) {
@@ -789,6 +804,13 @@ export async function pollVersion({ ctx, functionId, versionId, egressNote = fal
789
804
  console.log(`${LOG} status: ${version.status}`);
790
805
  }
791
806
  if (version.status === 'deployed') {
807
+ if (immutableRelease) {
808
+ const detail = await getFunctionDetail(ctx, functionId);
809
+ if (detail?.function.immutableRelease !== true || detail.function.activeVersionId !== versionId) {
810
+ console.error(`${LOG} the platform did not confirm immutable activation of this exact version. Verify the full runtime rollout before using this release; an already active mutable identity needs a new function ID.`);
811
+ return 1;
812
+ }
813
+ }
792
814
  console.log(`${LOG} ✓ ${version.version} is live`);
793
815
  if (egressNote) {
794
816
  console.log(egressPropagationNote(LOG));
@@ -1,6 +1,6 @@
1
1
  import { readFile } from 'node:fs/promises';
2
2
  import { join } from 'node:path';
3
- import { parseDeployedPolicy, preflightManagedFunction, sdkVersionFromPackageJson, } from '@sequenceholdings/managed-functions/config';
3
+ import { parseDeployedPolicy, preflightManagedFunction, sdkSpecFromPackageJson, } from '@sequenceholdings/managed-functions/config';
4
4
  import { AtlasApiError, getJson } from '../atlas-client.js';
5
5
  import { LOG } from '../cli-errors.js';
6
6
  /**
@@ -46,7 +46,7 @@ export function reportPreflight(issues) {
46
46
  }
47
47
  async function declaredSdkVersion(rootDir) {
48
48
  try {
49
- return sdkVersionFromPackageJson(await readFile(join(rootDir, 'package.json'), 'utf8'));
49
+ return sdkSpecFromPackageJson(await readFile(join(rootDir, 'package.json'), 'utf8'));
50
50
  }
51
51
  catch (error) {
52
52
  if (isMissingFile(error))
@@ -6,29 +6,13 @@ import { z } from 'zod';
6
6
  */
7
7
  export declare const MF_MANIFEST_FILENAME = "managed-function.yml";
8
8
  export declare const managedFunctionAuthorizationAdapterSchema: z.ZodEnum<{
9
- "encompass.global-metadata-read": "encompass.global-metadata-read";
10
- "encompass.loan-attachment-read": "encompass.loan-attachment-read";
11
- "encompass.loan-document-read": "encompass.loan-document-read";
12
- "encompass.loan-fields-read": "encompass.loan-fields-read";
13
- "encompass.loan-folder-read": "encompass.loan-folder-read";
14
- "encompass.loan-read-by-guid": "encompass.loan-read-by-guid";
15
- "encompass.loan-read-by-number": "encompass.loan-read-by-number";
16
- "encompass.loan-read-full": "encompass.loan-read-full";
17
- "encompass.loan-search": "encompass.loan-search";
9
+ "platform.human": "platform.human";
18
10
  }>;
19
11
  export type ManagedFunctionAuthorizationAdapter = z.infer<typeof managedFunctionAuthorizationAdapterSchema>;
20
12
  export declare const managedFunctionAuthorizationSchema: z.ZodObject<{
21
13
  version: z.ZodLiteral<1>;
22
14
  adapter: z.ZodEnum<{
23
- "encompass.global-metadata-read": "encompass.global-metadata-read";
24
- "encompass.loan-attachment-read": "encompass.loan-attachment-read";
25
- "encompass.loan-document-read": "encompass.loan-document-read";
26
- "encompass.loan-fields-read": "encompass.loan-fields-read";
27
- "encompass.loan-folder-read": "encompass.loan-folder-read";
28
- "encompass.loan-read-by-guid": "encompass.loan-read-by-guid";
29
- "encompass.loan-read-by-number": "encompass.loan-read-by-number";
30
- "encompass.loan-read-full": "encompass.loan-read-full";
31
- "encompass.loan-search": "encompass.loan-search";
15
+ "platform.human": "platform.human";
32
16
  }>;
33
17
  }, z.core.$strict>;
34
18
  /**
@@ -85,12 +69,17 @@ export declare const managedFunctionManifestSchema: z.ZodObject<{
85
69
  default_ttl_seconds: z.ZodDefault<z.ZodNumber>;
86
70
  }, z.core.$strict>>;
87
71
  schema_version: z.ZodDefault<z.ZodLiteral<1>>;
72
+ product_dependencies: z.ZodDefault<z.ZodArray<z.ZodString>>;
88
73
  function: z.ZodObject<{
89
74
  id: z.ZodString;
90
75
  title: z.ZodString;
91
76
  description: z.ZodOptional<z.ZodString>;
77
+ immutable_release: z.ZodOptional<z.ZodBoolean>;
92
78
  }, z.core.$strip>;
93
- runtime: z.ZodDefault<z.ZodLiteral<"nodejs20">>;
79
+ runtime: z.ZodDefault<z.ZodEnum<{
80
+ nodejs20: "nodejs20";
81
+ nodejs24: "nodejs24";
82
+ }>>;
94
83
  entrypoint: z.ZodDefault<z.ZodString>;
95
84
  limits: z.ZodPrefault<z.ZodObject<{
96
85
  memory_mb: z.ZodDefault<z.ZodNumber>;
@@ -114,15 +103,7 @@ export declare const managedFunctionManifestSchema: z.ZodObject<{
114
103
  authorization: z.ZodOptional<z.ZodObject<{
115
104
  version: z.ZodLiteral<1>;
116
105
  adapter: z.ZodEnum<{
117
- "encompass.global-metadata-read": "encompass.global-metadata-read";
118
- "encompass.loan-attachment-read": "encompass.loan-attachment-read";
119
- "encompass.loan-document-read": "encompass.loan-document-read";
120
- "encompass.loan-fields-read": "encompass.loan-fields-read";
121
- "encompass.loan-folder-read": "encompass.loan-folder-read";
122
- "encompass.loan-read-by-guid": "encompass.loan-read-by-guid";
123
- "encompass.loan-read-by-number": "encompass.loan-read-by-number";
124
- "encompass.loan-read-full": "encompass.loan-read-full";
125
- "encompass.loan-search": "encompass.loan-search";
106
+ "platform.human": "platform.human";
126
107
  }>;
127
108
  }, z.core.$strict>>;
128
109
  input_schema: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
@@ -136,8 +117,41 @@ export declare const managedFunctionManifestSchema: z.ZodObject<{
136
117
  processes: z.ZodOptional<z.ZodObject<{
137
118
  read: z.ZodArray<z.ZodString>;
138
119
  }, z.core.$strict>>;
120
+ agents: z.ZodOptional<z.ZodObject<{
121
+ read: z.ZodOptional<z.ZodArray<z.ZodString>>;
122
+ evidence: z.ZodOptional<z.ZodArray<z.ZodString>>;
123
+ }, z.core.$strict>>;
124
+ workflows: z.ZodOptional<z.ZodObject<{
125
+ read: z.ZodOptional<z.ZodArray<z.ZodString>>;
126
+ evidence: z.ZodOptional<z.ZodArray<z.ZodString>>;
127
+ }, z.core.$strict>>;
128
+ abrigo: z.ZodOptional<z.ZodObject<{
129
+ read: z.ZodArray<z.ZodEnum<{
130
+ workflow: "workflow";
131
+ entity: "entity";
132
+ entityGroupSummary: "entityGroupSummary";
133
+ loanRoles: "loanRoles";
134
+ relatedLoanRoles: "relatedLoanRoles";
135
+ workflowLoanMappings: "workflowLoanMappings";
136
+ workflowDocuments: "workflowDocuments";
137
+ customerDocuments: "customerDocuments";
138
+ reviewWorkflow: "reviewWorkflow";
139
+ reviewWorkflowDocuments: "reviewWorkflowDocuments";
140
+ reviewWorkflowCustomerDocuments: "reviewWorkflowCustomerDocuments";
141
+ }>>;
142
+ }, z.core.$strict>>;
143
+ monitoring: z.ZodOptional<z.ZodObject<{
144
+ producers: z.ZodArray<z.ZodString>;
145
+ }, z.core.$strict>>;
146
+ lattice: z.ZodOptional<z.ZodObject<{
147
+ context: z.ZodLiteral<true>;
148
+ }, z.core.$strict>>;
139
149
  directory: z.ZodOptional<z.ZodObject<{
140
- groups: z.ZodArray<z.ZodString>;
150
+ groups: z.ZodOptional<z.ZodArray<z.ZodString>>;
151
+ resolve: z.ZodOptional<z.ZodArray<z.ZodString>>;
152
+ }, z.core.$strict>>;
153
+ invocation: z.ZodOptional<z.ZodObject<{
154
+ identity: z.ZodLiteral<true>;
141
155
  }, z.core.$strict>>;
142
156
  roles: z.ZodOptional<z.ZodObject<{
143
157
  definitions: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
@@ -1,7 +1,13 @@
1
1
  import { storageScopesSchema, readStorageScopes } from '@sequenceholdings/storage';
2
2
  import { postgresEgressError } from './egress-postgres.js';
3
- import { cacheManifestSchema, directoryScopesSchema, managedFunctionWorkloadLimitsSchema } from '@sequenceholdings/managed-functions/config';
3
+ import { cacheManifestSchema, managedFunctionWorkloadLimitsSchema, functionImmutableReleaseSchema } from '@sequenceholdings/managed-functions/config';
4
4
  import { functionProcessReadScopesSchema } from '@sequenceholdings/managed-functions/config';
5
+ import { functionAgentReadScopesSchema } from '@sequenceholdings/managed-functions/config';
6
+ import { functionWorkflowScopesSchema } from '@sequenceholdings/managed-functions/config';
7
+ import { functionAbrigoReadScopesSchema } from '@sequenceholdings/managed-functions/config';
8
+ import { functionMonitoringScopesSchema } from '@sequenceholdings/managed-functions/config';
9
+ import { functionLatticeContextCapabilitySchema } from '@sequenceholdings/managed-functions/config';
10
+ import { functionDirectoryManifestSchema, functionInvocationIdentityCapabilitySchema } from '@sequenceholdings/managed-functions/config';
5
11
  import { isIP } from 'node:net';
6
12
  import { z } from 'zod';
7
13
  import { ontologyContractSchema } from '@sequenceholdings/orm/canonical';
@@ -12,48 +18,13 @@ import { ontologyContractSchema } from '@sequenceholdings/orm/canonical';
12
18
  */
13
19
  export const MF_MANIFEST_FILENAME = 'managed-function.yml';
14
20
  const SECRET_NAME_RE = /^[A-Z][A-Z0-9_]*$/;
15
- export const managedFunctionAuthorizationAdapterSchema = z.enum([
16
- 'encompass.global-metadata-read',
17
- 'encompass.loan-attachment-read',
18
- 'encompass.loan-document-read',
19
- 'encompass.loan-fields-read',
20
- 'encompass.loan-folder-read',
21
- 'encompass.loan-read-by-guid',
22
- 'encompass.loan-read-by-number',
23
- 'encompass.loan-read-full',
24
- 'encompass.loan-search',
25
- ]);
21
+ export const managedFunctionAuthorizationAdapterSchema = z.enum(['platform.human']);
26
22
  export const managedFunctionAuthorizationSchema = z
27
23
  .object({
28
24
  version: z.literal(1),
29
25
  adapter: managedFunctionAuthorizationAdapterSchema,
30
26
  })
31
27
  .strict();
32
- const AUTHORIZATION_ADAPTER_BY_FUNCTION_ID = {
33
- 'encompass-get-attachment': 'encompass.loan-attachment-read',
34
- 'encompass-get-attachments-for-document': 'encompass.loan-attachment-read',
35
- 'encompass-get-common-loan-fields': 'encompass.loan-read-by-guid',
36
- 'encompass-get-document': 'encompass.loan-document-read',
37
- 'encompass-get-document-by-name': 'encompass.loan-document-read',
38
- 'encompass-get-document-folder': 'encompass.loan-document-read',
39
- 'encompass-get-field-info': 'encompass.global-metadata-read',
40
- 'encompass-get-loan': 'encompass.loan-read-full',
41
- 'encompass-get-loan-by-number': 'encompass.loan-read-by-number',
42
- 'encompass-get-loan-fields': 'encompass.loan-fields-read',
43
- 'encompass-get-loan-folder': 'encompass.loan-folder-read',
44
- 'encompass-get-loan-folder-settings': 'encompass.global-metadata-read',
45
- 'encompass-get-pipeline-canonical-names': 'encompass.global-metadata-read',
46
- 'encompass-get-schema-status': 'encompass.global-metadata-read',
47
- 'encompass-get-stacking-template': 'encompass.global-metadata-read',
48
- 'encompass-get-stacking-template-by-name': 'encompass.global-metadata-read',
49
- 'encompass-list-attachments': 'encompass.loan-attachment-read',
50
- 'encompass-list-documents': 'encompass.loan-document-read',
51
- 'encompass-list-loan-folder-settings': 'encompass.global-metadata-read',
52
- 'encompass-list-stacking-templates': 'encompass.global-metadata-read',
53
- 'encompass-search-fields': 'encompass.global-metadata-read',
54
- 'encompass-search-pipeline': 'encompass.loan-search',
55
- 'encompass-validate-field': 'encompass.global-metadata-read',
56
- };
57
28
  /** RFC 1035 label: alnum, optional inner dashes, max 63 chars. */
58
29
  const DNS_LABEL_RE = /^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/;
59
30
  /**
@@ -597,7 +568,7 @@ function refineServiceAccountAttachment({ requiresServiceAccount, serviceAccount
597
568
  if (requiresServiceAccount && serviceAccount === undefined) {
598
569
  ctx.addIssue({
599
570
  code: 'custom',
600
- message: 'Data, storage or process capabilities require a top-level service_account — the platform service ' +
571
+ message: 'Service access capabilities require a top-level service_account — the platform service ' +
601
572
  'account this function acts as for service access (the deployer needs the actor role on it)',
602
573
  path: ['service_account'],
603
574
  });
@@ -605,7 +576,7 @@ function refineServiceAccountAttachment({ requiresServiceAccount, serviceAccount
605
576
  if (!requiresServiceAccount && serviceAccount !== undefined) {
606
577
  ctx.addIssue({
607
578
  code: 'custom',
608
- message: 'service_account requires capabilities.data or capabilities.storage or capabilities.processes',
579
+ message: 'service_account requires at least one declared service access capability',
609
580
  path: ['service_account'],
610
581
  });
611
582
  }
@@ -614,6 +585,8 @@ export const managedFunctionManifestSchema = z.object({
614
585
  ontology: ontologyContractSchema.optional(),
615
586
  cache: cacheManifestSchema.optional(),
616
587
  schema_version: z.literal(1).default(1),
588
+ /** Product discovery metadata; never grants invocation access. */
589
+ product_dependencies: z.array(z.string().regex(/^[a-z][a-z0-9-]{0,63}$/)).max(16).default([]),
617
590
  function: z.object({
618
591
  id: z
619
592
  .string()
@@ -622,8 +595,9 @@ export const managedFunctionManifestSchema = z.object({
622
595
  .regex(/^[a-z][a-z0-9-]*$/, 'function id must be lowercase letters, digits, and dashes'),
623
596
  title: z.string().min(1).max(255),
624
597
  description: z.string().max(2000).optional(),
598
+ immutable_release: functionImmutableReleaseSchema.optional(),
625
599
  }),
626
- runtime: z.literal('nodejs20').default('nodejs20'),
600
+ runtime: z.enum(['nodejs20', 'nodejs24']).default('nodejs20'),
627
601
  entrypoint: z.string().min(1).max(255).default('handler'),
628
602
  limits: managedFunctionWorkloadLimitsSchema,
629
603
  /**
@@ -678,8 +652,7 @@ export const managedFunctionManifestSchema = z.object({
678
652
  .regex(SERVICE_ACCOUNT_REF_RE, 'service_account must be a platform service-account slug (lowercase alphanumeric with hyphens) or uuid')
679
653
  .optional(),
680
654
  /**
681
- * Server-owned resource authorization. Authors select a reviewed adapter;
682
- * they cannot provide input/output paths or executable policy.
655
+ * Platform enforces caller type; functions enforce vendor resource access.
683
656
  */
684
657
  authorization: managedFunctionAuthorizationSchema.optional(),
685
658
  input_schema: z.record(z.string(), z.unknown()).optional(),
@@ -692,7 +665,13 @@ export const managedFunctionManifestSchema = z.object({
692
665
  capabilities: z.object({
693
666
  storage: storageScopesSchema.optional(),
694
667
  processes: functionProcessReadScopesSchema.optional(),
695
- directory: directoryScopesSchema.optional(),
668
+ agents: functionAgentReadScopesSchema.optional(),
669
+ workflows: functionWorkflowScopesSchema.optional(),
670
+ abrigo: functionAbrigoReadScopesSchema.optional(),
671
+ monitoring: functionMonitoringScopesSchema.optional(),
672
+ lattice: functionLatticeContextCapabilitySchema.optional(),
673
+ directory: functionDirectoryManifestSchema.optional(),
674
+ invocation: functionInvocationIdentityCapabilitySchema.optional(),
696
675
  roles: customRolesBlockSchema.optional(),
697
676
  uses: capabilityPinsSchema,
698
677
  gates: capabilityGatesSchema,
@@ -711,12 +690,7 @@ export const managedFunctionManifestSchema = z.object({
711
690
  */
712
691
  data: z
713
692
  .record(z.string().regex(/^[a-z][a-z0-9_]{0,40}$/, 'capabilities.data keys are ORM namespace names'), z.object({
714
- // ORM emits this exact logical key for toPlatformUser joins; it is
715
- // not a physical SQL table name or a general camelCase exception.
716
- tables: z.array(z.union([
717
- z.literal('platformUsers'),
718
- z.string().regex(/^[a-z_][a-z0-9_]*$/, 'table names'),
719
- ])).max(64).default([]),
693
+ tables: z.array(z.union([z.literal('platformUsers'), z.string().regex(/^[a-z_][a-z0-9_]*$/, 'table names')])).max(64).default([]),
720
694
  actions: z.array(z.string().regex(/^[a-z_][a-z0-9_]*$/, 'action names')).max(64).default([]),
721
695
  /**
722
696
  * ORM v2 persisted operations (GraphQL mutations/actions by name)
@@ -758,30 +732,6 @@ export const managedFunctionManifestSchema = z.object({
758
732
  });
759
733
  });
760
734
  }
761
- const expectedAdapter = AUTHORIZATION_ADAPTER_BY_FUNCTION_ID[manifest.function.id];
762
- if (expectedAdapter !== undefined && manifest.authorization === undefined) {
763
- ctx.addIssue({
764
- code: 'custom',
765
- message: `function "${manifest.function.id}" requires authorization adapter "${expectedAdapter}"`,
766
- path: ['authorization'],
767
- });
768
- }
769
- else if (expectedAdapter !== undefined &&
770
- manifest.authorization?.adapter !== expectedAdapter) {
771
- ctx.addIssue({
772
- code: 'custom',
773
- message: `function "${manifest.function.id}" must use authorization adapter "${expectedAdapter}"`,
774
- path: ['authorization', 'adapter'],
775
- });
776
- }
777
- else if (expectedAdapter === undefined &&
778
- manifest.authorization !== undefined) {
779
- ctx.addIssue({
780
- code: 'custom',
781
- message: `function "${manifest.function.id}" is not registered for a server-owned authorization adapter`,
782
- path: ['authorization'],
783
- });
784
- }
785
735
  for (const message of validateCapabilityPins({
786
736
  uses: manifest.capabilities.uses,
787
737
  roles: manifest.capabilities.roles,
@@ -800,8 +750,21 @@ export const managedFunctionManifestSchema = z.object({
800
750
  // reconciliation uses (readManifestDataNamespaces).
801
751
  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);
802
752
  const reachesProcesses = (manifest.capabilities.processes?.read.length ?? 0) > 0;
753
+ const reachesAgents = (manifest.capabilities.agents?.read?.length ?? 0) > 0 || (manifest.capabilities.agents?.evidence?.length ?? 0) > 0;
754
+ const reachesWorkflows = (manifest.capabilities.workflows?.read?.length ?? 0) > 0 || (manifest.capabilities.workflows?.evidence?.length ?? 0) > 0;
755
+ const receivesLatticeContext = manifest.capabilities.lattice?.context === true;
803
756
  refineServiceAccountAttachment({
804
- requiresServiceAccount: reachesData || reachesProcesses,
757
+ requiresServiceAccount: [
758
+ reachesData,
759
+ reachesProcesses,
760
+ reachesAgents,
761
+ reachesWorkflows,
762
+ (manifest.capabilities.abrigo?.read.length ?? 0) > 0,
763
+ receivesLatticeContext,
764
+ manifest.capabilities.invocation?.identity === true,
765
+ (manifest.capabilities.directory?.resolve?.length ?? 0) > 0,
766
+ (manifest.capabilities.monitoring?.producers.length ?? 0) > 0,
767
+ ].includes(true),
805
768
  serviceAccount: manifest.service_account,
806
769
  ctx,
807
770
  });