@sequenceholdings/studio-cli 0.5.4 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/README.md +226 -7
  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 +32 -12
  6. package/dist/atlas-client.d.ts +2 -1
  7. package/dist/atlas-client.js +7 -3
  8. package/dist/auth-cmds/commands.d.ts +1 -1
  9. package/dist/auth-cmds/commands.js +3 -0
  10. package/dist/auth.d.ts +2 -1
  11. package/dist/auth.js +16 -0
  12. package/dist/command-contract.d.ts +8 -8
  13. package/dist/command-contract.js +6 -6
  14. package/dist/command-help.d.ts +5 -4
  15. package/dist/command-help.js +41 -4
  16. package/dist/command-input.js +2 -2
  17. package/dist/config.d.ts +5 -0
  18. package/dist/config.js +14 -1
  19. package/dist/env-flags.d.ts +6 -0
  20. package/dist/env-flags.js +9 -0
  21. package/dist/functions/commands.d.ts +4 -1
  22. package/dist/functions/commands.js +63 -5
  23. package/dist/functions/deploy-preflight.js +2 -2
  24. package/dist/functions/manifest.d.ts +43 -29
  25. package/dist/functions/manifest.js +37 -74
  26. package/dist/main.js +42 -2
  27. package/dist/orm/delegate.js +25 -4
  28. package/dist/orm/read.d.ts +54 -0
  29. package/dist/orm/read.js +308 -0
  30. package/dist/pipeline/commands.js +30 -5
  31. package/dist/pipeline/discovery.js +3 -16
  32. package/dist/pipeline/lifecycle.js +37 -6
  33. package/dist/pipeline/retirement.d.ts +3 -0
  34. package/dist/pipeline/retirement.js +34 -0
  35. package/dist/pipeline/source.d.ts +21 -0
  36. package/dist/pipeline/source.js +76 -0
  37. package/dist/process/build.js +4 -0
  38. package/dist/process/codegen.js +2 -0
  39. package/dist/process/commands.js +57 -18
  40. package/dist/process/plan-diff.js +1 -0
  41. package/dist/process/runs.d.ts +14 -0
  42. package/dist/process/runs.js +238 -0
  43. package/dist/repos/ci-status.js +28 -0
  44. package/dist/repos/commands.js +11 -1
  45. package/dist/repos/git-credential.d.ts +3 -2
  46. package/dist/repos/git-credential.js +52 -3
  47. package/dist/repos/pulls.d.ts +7 -1
  48. package/dist/repos/pulls.js +162 -22
  49. package/dist/sandbox-auth.d.ts +52 -0
  50. package/dist/sandbox-auth.js +105 -0
  51. package/dist/storage/commands.js +6 -5
  52. package/dist/text-table.d.ts +7 -0
  53. package/dist/text-table.js +16 -0
  54. package/package.json +9 -9
@@ -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
  });
package/dist/main.js CHANGED
@@ -25,13 +25,14 @@
25
25
  import { parseArgs } from './argv.js';
26
26
  import { renderCapabilities } from './command-contract.js';
27
27
  import { staticHelp } from './command-help.js';
28
+ import { SANDBOX_BASE_URL_ENV, SANDBOX_TOKEN_FILE_ENV } from './sandbox-auth.js';
28
29
  // Lazy-load artifact delegate: published @sequenceholdings/artifact-studio/cli
29
30
  // still auto-runs runCli() at module load; importing it here breaks doctor/process.
30
31
  const TOP_LEVEL_USAGE = `usage:
31
32
  seq-studio init <dir> [options] scaffold an app or use a published template
32
33
  seq-studio add <kind> <name> [internal] add a primitive to the current app monorepo
33
34
  seq-studio deploy -e <env> [internal] deploy primitives from sequence.app.yml
34
- seq-studio process <sub> [args] lint | plan | apply | test | simulate | bundle | init
35
+ seq-studio process <sub> [args] lint | plan | apply | runs | test | simulate | bundle | init
35
36
  seq-studio artifact <sub> [args] init | whoami | link | env | status | list | show | validate | build | plan | deploy | dev | promote | pull | rollback
36
37
  seq-studio functions <sub> [args] init | build | deploy | list | show | limits | invoke | logs | promote | rollback | delete
37
38
  seq-studio storage <sub> [args] init | validate | apply | list | show | mkdir | upload | download | access | trash | restore | purge | operations | abort | delete
@@ -41,7 +42,7 @@ const TOP_LEVEL_USAGE = `usage:
41
42
  seq-studio templates <sub> [args] publish | sync | list
42
43
  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
43
44
  seq-studio auth <sub> [args] whoami | git-credential
44
- seq-studio orm <sub> [args] init | generate | validate | plan | apply | execute | diff | migrate-from-yaml | import
45
+ seq-studio orm <sub> [args] init | generate | validate | plan | apply | execute | read | sql | diff | migrate-from-yaml | import
45
46
  seq-studio service-accounts <sub> list | show | create (requires provisioning authority)
46
47
  seq-studio access <sub> definitions | list | grant | revoke | resolve
47
48
  seq-studio envs <sub> add | list environments
@@ -53,6 +54,8 @@ const TOP_LEVEL_USAGE = `usage:
53
54
  seq-studio help show this message
54
55
 
55
56
  Authenticate with: seq-studio login
57
+ In an agent sandbox, SEQ_STUDIO_BASE_URL + SEQ_STUDIO_TOKEN_FILE select the
58
+ deployment and token instead (no login; -e optional).
56
59
  Where supported, --json writes structured stdout; check exit status and pagination.
57
60
  Built-in env: local. Add your organization's deployment with
58
61
  \`seq-studio envs add <name> <url>\`; custom entries live in ~/.config/lattice/config.toml.
@@ -70,6 +73,7 @@ const PROCESS_USAGE = `usage:
70
73
  seq-studio process apply --repo <namespace>/<name> [--ref <r>] -e <env> [--only <id1,id2,...>] [--platform-managed]
71
74
  seq-studio process promote <processId> --version <v> [-e <env>]
72
75
  seq-studio process pull <processId> [--version <v>] [-e <env>] [--out <dir>] [--no-children]
76
+ seq-studio process runs start|list|show|cancel [args] -e <env> (see process runs --help)
73
77
  seq-studio process test [-e <env>] [--offline]
74
78
  seq-studio process simulate <process-id>
75
79
  seq-studio process bundle build [-o file.json]
@@ -80,6 +84,24 @@ const PROCESS_USAGE = `usage:
80
84
  seq-studio process bundle publish <hash|bundle.json> [-e <env>]
81
85
  seq-studio process safety-baseline [--repo-root <dir>] [--write]
82
86
  `;
87
+ // Validate command names before the offline help shortcut. Otherwise a typo such
88
+ // as `repos creat --help` appears successful without ever reaching the router.
89
+ const SUBCOMMANDS = {
90
+ process: new Set(['init', 'lint', 'plan', 'apply', 'promote', 'pull', 'runs', 'test', 'simulate', 'bundle', 'safety-baseline']),
91
+ artifact: new Set(['init', 'whoami', 'link', 'env', 'status', 'list', 'show', 'validate', 'build', 'plan', 'deploy', 'dev', 'promote', 'pull', 'rollback', 'login', 'logout']),
92
+ functions: new Set(['init', 'dev', 'build', 'register', 'deploy', 'list', 'show', 'limits', 'invoke', 'logs', 'promote', 'rollback', 'delete']),
93
+ storage: new Set(['init', 'validate', 'apply', 'list', 'show', 'mkdir', 'upload', 'import', 'uploads', 'reconcile', 'download', 'access', 'trash', 'restore', 'purge', 'operations', 'abort', 'delete']),
94
+ agents: new Set(['init', 'validate', 'bundle', 'plan', 'apply', 'list', 'show', 'voice']),
95
+ secrets: new Set(['create', 'set', 'list', 'attach', 'detach', 'apply', 'versions', 'set-default', 'pin']),
96
+ repos: new Set(['list', 'namespaces', 'show', 'create', 'clone', 'pull', 'pulls', 'delete', 'ci']),
97
+ templates: new Set(['publish', 'sync', 'list']),
98
+ 'service-accounts': new Set(['list', 'show', 'create']),
99
+ access: new Set(['definitions', 'resolve', 'list', 'grant', 'revoke']),
100
+ auth: new Set(['whoami', 'git-credential', 'pat']),
101
+ orm: new Set(['init', 'generate', 'validate', 'plan', 'apply', 'execute', 'read', 'sql', 'diff', 'migrate-from-yaml', 'import']),
102
+ pipeline: new Set(['list', 'assets', 'search', 'describe', 'schema', 'sample', 'query', 'init', 'validate', 'repin-orm', 'codegen', 'adopt', 'unbind', 'plan', 'deploy', 'status', 'migrate', 'promote', 'rollback', 'run-now']),
103
+ envs: new Set(['add', 'list']),
104
+ };
83
105
  export async function run(argv = process.argv.slice(2)) {
84
106
  const [namespace, sub, ...rest] = argv;
85
107
  if (!namespace || namespace === 'help' || namespace === '--help' || namespace === '-h') {
@@ -94,6 +116,20 @@ export async function run(argv = process.argv.slice(2)) {
94
116
  console.error('Artifact Studio does not accept --token bearer injection. Authenticate with seq-studio login.');
95
117
  return 1;
96
118
  }
119
+ // Same rule as --token: Artifact Studio uses only credentials the CLI obtained
120
+ // and realm-checked itself, never an injected bearer, so sandbox token mode
121
+ // does not reach it. Help stays available.
122
+ if (namespace === 'artifact' && !hasHelpFlag(sub, rest) &&
123
+ (process.env[SANDBOX_BASE_URL_ENV]?.trim() || process.env[SANDBOX_TOKEN_FILE_ENV]?.trim())) {
124
+ console.error(`Artifact Studio commands are not available in sandbox token mode (${SANDBOX_BASE_URL_ENV} / ${SANDBOX_TOKEN_FILE_ENV}). ` +
125
+ 'Deploy artifacts from a signed-in seq-studio session.');
126
+ return 1;
127
+ }
128
+ if (hasHelpFlag(sub, rest) && sub && !['help', '--help', '-h'].includes(sub) &&
129
+ SUBCOMMANDS[namespace] && !SUBCOMMANDS[namespace].has(sub)) {
130
+ console.error(`unknown ${namespace} command: ${sub}. See seq-studio ${namespace} --help.`);
131
+ return 1;
132
+ }
97
133
  if (hasHelpFlag(sub, rest)) {
98
134
  const help = staticHelp({ namespace, sub });
99
135
  if (help) {
@@ -232,6 +268,10 @@ async function runSessionCommand({ args, command, }) {
232
268
  return 0;
233
269
  }
234
270
  async function runProcessNamespace(sub, rest) {
271
+ if (sub === 'runs') {
272
+ const { processRunsCommand } = await import('./process/runs.js');
273
+ return processRunsCommand(parseArgs(rest));
274
+ }
235
275
  if (hasHelpFlag(sub, rest)) {
236
276
  console.log(PROCESS_USAGE);
237
277
  return 0;
@@ -6,10 +6,12 @@
6
6
  * SEQUENCE_ORM_BASE_URL, share the seqapi token, forward argv.
7
7
  */
8
8
  import { fileURLToPath } from 'node:url';
9
+ import { parseArgs } from '../argv.js';
9
10
  import { parseSourceSpec, resolveArtifactSource, } from '@sequenceholdings/artifact-studio/source-resolver';
10
11
  import { getAccessToken, tryGetAccessTokenWithMode } from '../auth.js';
12
+ import { sourceAuthMode } from '../sandbox-auth.js';
11
13
  import { resolveConfiguredEnv } from '../config.js';
12
- import { normalizeShortEnvFlag, readEnvFromArgv } from '../env-flags.js';
14
+ import { explicitOrSandboxEnv, normalizeShortEnvFlag, readEnvFromArgv } from '../env-flags.js';
13
15
  import { REQUIRE_EXPLICIT_ENV_MESSAGE } from '../env-flags.js';
14
16
  import { resolveFunctionSourceDir } from '../functions/source-selection.js';
15
17
  import { warnBeforeHostDeploy } from '../manifest-roles-notice.js';
@@ -35,6 +37,10 @@ const ORM_USAGE = `usage:
35
37
  authors migrations: the committed ledger must already match the definitions.
36
38
  seq-studio orm execute <operation> [dir] --variables-file <file> -e <env>
37
39
  execute one named persisted operation as the signed-in caller
40
+ seq-studio orm read <namespace> <table> -e <env> [--where c=op.v]... [--select c,...] [--order c.desc] [--limit N] [--offset N] [--json|--jsonl]
41
+ read rows of a deployed v2 namespace as the caller (row-level security applies)
42
+ seq-studio orm sql <namespace> --query <sql> | --file <path> -e <env> [--param name[:type]=v]... | [--params <json-object>] [--json|--jsonl]
43
+ run read-only SQL against a deployed v2 namespace as the caller
38
44
  seq-studio orm diff [dir] write/verify the committed migration standalone (--check is the offline CI gate; --allow-destructive consents; --rebase records a v1 -> v2 conversion)
39
45
  seq-studio orm migrate-from-yaml <dir> convert a v1 YAML namespace to the v2 TypeScript format (offline; migrations/ preserved)
40
46
  seq-studio orm import [dir] --spec <file> | --table <t> --from <schema.table> --map <target=source,...>
@@ -137,7 +143,7 @@ async function runOrmFromRepo({ sub, selection, auth, targetUrl, ormCli, }) {
137
143
  return 1;
138
144
  }
139
145
  const source = await resolveArtifactSource(selection.spec, {
140
- authMode: auth.authMode,
146
+ authMode: sourceAuthMode(auth.authMode),
141
147
  baseUrl: targetUrl,
142
148
  token: auth.token,
143
149
  });
@@ -190,6 +196,16 @@ export async function runOrmCommand(sub, rest) {
190
196
  console.log(ORM_USAGE);
191
197
  return sub ? 0 : 1;
192
198
  }
199
+ // Ad-hoc reads are seq-studio commands over the ORM client, not the ORM CLI.
200
+ if (sub === 'read' || sub === 'sql') {
201
+ const { ORM_READ_USAGE, ormReadCommand, ormSqlCommand } = await import('./read.js');
202
+ if (rest.includes('--help') || rest.includes('-h')) {
203
+ console.log(ORM_READ_USAGE);
204
+ return 0;
205
+ }
206
+ const args = parseArgs(rest);
207
+ return sub === 'read' ? ormReadCommand(args) : ormSqlCommand(args);
208
+ }
193
209
  const normalized = normalizeShortEnvFlag(rest);
194
210
  if (normalized.includes('--help') || normalized.includes('-h')) {
195
211
  console.log(ORM_HELP);
@@ -207,7 +223,7 @@ export async function runOrmCommand(sub, rest) {
207
223
  console.error(`[seq-studio] --repo applies only to: ${[...ORM_REPO_SUBS].join(', ')}`);
208
224
  return 1;
209
225
  }
210
- const requested = readEnvFromArgv(normalized);
226
+ const requested = explicitOrSandboxEnv(readEnvFromArgv(normalized));
211
227
  if (ORM_NETWORK_SUBS.has(sub) && !requested) {
212
228
  console.error(`[seq-studio] ${REQUIRE_EXPLICIT_ENV_MESSAGE}`);
213
229
  return 1;
@@ -223,7 +239,12 @@ export async function runOrmCommand(sub, rest) {
223
239
  env: requested,
224
240
  targetUrl,
225
241
  });
226
- if (auth)
242
+ // The ORM CLI prefers SEQUENCE_ORM_TOKEN over the provider below. A sandbox
243
+ // token rotates mid-command, so it must come from the provider on each call:
244
+ // clear any inherited value rather than let a stale credential win.
245
+ if (auth?.authMode === 'sandbox')
246
+ delete process.env['SEQUENCE_ORM_TOKEN'];
247
+ else if (auth)
227
248
  process.env['SEQUENCE_ORM_TOKEN'] = auth.token;
228
249
  // Lazy import keeps `process`/`doctor` from pulling in the optional ORM package.
229
250
  const ormCli = await loadOrmCli();
@@ -0,0 +1,54 @@
1
+ /**
2
+ * `seq-studio orm read` / `orm sql` — ad-hoc reads of a deployed ORM v2
3
+ * namespace as the caller.
4
+ *
5
+ * Both run the namespace's built-in read-only SQL operation through the
6
+ * published ORM client (`createOperationExecutorWithTransport(...).sql()`),
7
+ * which owns the `{ op, variables }` wire format. Requests go through the CLI's
8
+ * Atlas client so environment resolution, sandbox tokens, and edge headers
9
+ * behave like every other command. The server compiles the SQL in its closed
10
+ * read-only grammar and enforces grants, row-level security, and its row,
11
+ * size, and time bounds.
12
+ */
13
+ import type { SqlQueryParameter, SqlQueryVariables } from '@sequenceholdings/orm/client';
14
+ import type { ParsedArgs } from '../process/commands.js';
15
+ export declare const ORM_READ_USAGE = "usage:\n seq-studio orm read <namespace> <table> -e <env> [--where <column>=<op>.<value>]...\n [--select <col,...>] [--order <column>[.asc|.desc]]... [--limit N] [--offset N] [--json | --jsonl]\n seq-studio orm sql <namespace> (--query <sql> | --file <path>) -e <env>\n [--param <name>[:<type>]=<value>]... | [--params <json-object>] [--json | --jsonl]\n\n Reads run as you against an ORM v2 namespace: its grants, row-level security,\n and a read-only SQL grammar apply on the server, which returns at most 1,000 rows.\n\n --where operators: eq, ne, gt, gte, lt, lte, in, is\n --where status=eq.open --where balance=gte.1000 --where id=in.(a,b,c) --where closed_at=is.null\n sql binds :name placeholders. --param types: text (default), uuid, date, timestamptz,\n numeric, bigint, integer, double, boolean. --params takes the wire shape, e.g.\n '{\"limit\": {\"type\": \"integer\", \"value\": 5}}', and allows null values.\n sql must reference every table as <namespace>.<table> (SELECT id FROM lending.loans, not\n FROM loans); unqualified names and queries without a table (SELECT 1) are rejected.\n The grammar is read-only SELECT with joins, CTEs, UNION, aggregates, and comparison\n operators (no LIKE or IN).\n --json prints a JSON array of row objects; --jsonl prints one row object per line.\n Without either, rows print as a table. Counts, truncation, and paging hints go to stderr.\n";
16
+ export interface ReadFilter {
17
+ column: string;
18
+ op: string;
19
+ value: string;
20
+ }
21
+ interface ReadPlan {
22
+ namespace: string;
23
+ table: string;
24
+ select: string[];
25
+ filters: ReadFilter[];
26
+ orderings: Array<{
27
+ column: string;
28
+ direction: 'asc' | 'desc';
29
+ }>;
30
+ limit?: number;
31
+ offset?: number;
32
+ }
33
+ /** Parse `<column>=<op>.<value>`, the PostgREST spelling. */
34
+ export declare function parseFilter(raw: string): ReadFilter;
35
+ /** A typed SQL parameter from text, as the server's parameter schema expects. */
36
+ export declare function sqlParameter({ type, raw, label }: {
37
+ type: string;
38
+ raw: string;
39
+ label: string;
40
+ }): SqlQueryParameter;
41
+ /** `--param name[:type]=value` (repeatable) or `--params '<json object>'` in the wire shape. */
42
+ export declare function parseSqlParams(args: ParsedArgs): Record<string, SqlQueryParameter> | undefined;
43
+ /**
44
+ * Lower a read into the server's SQL grammar. Values are always bound
45
+ * parameters typed from the table's column types, never spliced into the SQL.
46
+ */
47
+ export declare function buildReadSql({ plan, columnTypes }: {
48
+ plan: ReadPlan;
49
+ columnTypes: ReadonlyMap<string, string>;
50
+ }): SqlQueryVariables;
51
+ export declare function ormReadCommand(args: ParsedArgs): Promise<number>;
52
+ export declare function ormSqlCommand(args: ParsedArgs): Promise<number>;
53
+ export declare function sqlGrammarHint(namespace: string): string;
54
+ export {};