@sequenceholdings/studio-cli 0.2.0 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,6 +8,19 @@ import { resolveEnvWithDiscovery } from '../config.js';
8
8
  import { parseDurationMs } from '@sequenceholdings/lattice';
9
9
  import { printReconcileResult, reconcileStageCredentials } from './stage-secrets.js';
10
10
  const LOG = '[seq-studio]';
11
+ function rootOption(root) {
12
+ return root ? { root } : {};
13
+ }
14
+ function releaseUnitRepo({ repo, root }) {
15
+ if (!root)
16
+ return repo;
17
+ if (!repo)
18
+ throw new Error('--root requires --repo');
19
+ if (!/^(?!.*(?:^|\/)\.{1,2}(?:\/|$))[A-Za-z0-9._-]+(?:\/[A-Za-z0-9._-]+)*$/.test(root)) {
20
+ throw new Error('--root must be a contained relative directory');
21
+ }
22
+ return `${repo}@${root}`;
23
+ }
11
24
  const TERMINAL = new Set(['active', 'failed', 'retired']);
12
25
  const POLL_INTERVAL_MS = 2000;
13
26
  const HEARTBEAT_INTERVAL_MS = 20_000;
@@ -109,6 +122,7 @@ export async function resolvePipelineTarget({ args, env, token, }) {
109
122
  export async function pipelinePlanCommand(args) {
110
123
  const repo = flagString(args.flags, 'repo');
111
124
  const ref = flagString(args.flags, 'ref');
125
+ const root = flagString(args.flags, 'root');
112
126
  const migrationId = flagString(args.flags, 'migration');
113
127
  const inPlace = flagOn(args.flags, 'in-place');
114
128
  if (inPlace && !migrationId) {
@@ -116,7 +130,7 @@ export async function pipelinePlanCommand(args) {
116
130
  return 1;
117
131
  }
118
132
  if (!repo || !ref) {
119
- console.error('usage: seq-studio pipeline plan --repo <namespace>/<slug> --ref <sha|branch> -e <env> [--migration <id> [--in-place]] [--json]');
133
+ console.error('usage: seq-studio pipeline plan --repo <namespace>/<slug> --ref <sha|branch> [--root <directory>] -e <env> [--migration <id> [--in-place]] [--json]');
120
134
  return 1;
121
135
  }
122
136
  const { env, token } = await envAndToken(args);
@@ -137,6 +151,7 @@ export async function pipelinePlanCommand(args) {
137
151
  token,
138
152
  repo,
139
153
  ref,
154
+ ...rootOption(root),
140
155
  environment: target.id,
141
156
  ...(migrationId ? { migrationId } : {}),
142
157
  ...(inPlace ? { executionMode: 'in_place' } : {}),
@@ -170,6 +185,7 @@ export async function pipelineDeployCommand(args) {
170
185
  }
171
186
  const repo = flagString(args.flags, 'repo');
172
187
  const ref = flagString(args.flags, 'ref');
188
+ const root = flagString(args.flags, 'root');
173
189
  const deploymentId = flagString(args.flags, 'deployment-id');
174
190
  const approvedBy = flagString(args.flags, 'approved-by');
175
191
  const runNow = flagOn(args.flags, 'run-now');
@@ -210,12 +226,12 @@ export async function pipelineDeployCommand(args) {
210
226
  }
211
227
  else {
212
228
  if (!repo || !ref) {
213
- console.error('usage: seq-studio pipeline deploy --repo <namespace>/<slug> --ref <sha|branch> -e <env> [--target <id>] [--approved-by <sub>] [--allow-destructive <resource-key> ...] [--run-now] [--wait-timeout <duration>] [--no-wait]');
229
+ console.error('usage: seq-studio pipeline deploy --repo <namespace>/<slug> --ref <sha|branch> [--root <directory>] -e <env> [--target <id>] [--approved-by <sub>] [--allow-destructive <resource-key> ...] [--run-now] [--wait-timeout <duration>] [--no-wait]');
214
230
  return 1;
215
231
  }
216
232
  // Plan then deploy the first planning deployment.
217
233
  const plan = await planAttachingCredentials({
218
- request: { baseUrl: env.url, token, repo, ref, environment: target.id },
234
+ request: { baseUrl: env.url, token, repo, ref, environment: target.id, ...rootOption(root) },
219
235
  provision: !flagOn(args.flags, 'no-provision'),
220
236
  });
221
237
  if (plan.plan.hasDestructive && allowDestructiveResourceKeys.length === 0) {
@@ -562,9 +578,12 @@ async function attachUnattachedCredentials({ request, stageIds, }) {
562
578
  try {
563
579
  const client = { baseUrl: request.baseUrl, token: request.token };
564
580
  const { secrets } = await getJson({ ...client, path: '/api/managed-secrets' });
581
+ const repo = releaseUnitRepo({ repo: request.repo, root: request.root });
582
+ if (!repo)
583
+ throw new Error('pipeline credential reconciliation requires a repository');
565
584
  const result = await reconcileStageCredentials({
566
585
  client,
567
- repo: request.repo,
586
+ repo,
568
587
  stageIds,
569
588
  deployTarget: request.environment,
570
589
  secrets,
@@ -589,12 +608,12 @@ class PlanRequestFailedError extends Error {
589
608
  this.stageIds = stageIds;
590
609
  }
591
610
  }
592
- async function enqueueAndWaitForPlan({ baseUrl, token, repo, ref, environment, migrationId, executionMode, }) {
611
+ async function enqueueAndWaitForPlan({ baseUrl, token, repo, ref, root, environment, migrationId, executionMode, }) {
593
612
  const enqueue = await postJson({
594
613
  baseUrl,
595
614
  token,
596
615
  path: '/api/data-pipelines/pipelines/plan',
597
- body: { repo, ref, environment, ...(migrationId ? { migration_id: migrationId } : {}), ...(executionMode ? { execution_mode: executionMode } : {}) },
616
+ body: { repo, ref, environment, ...rootOption(root), ...(migrationId ? { migration_id: migrationId } : {}), ...(executionMode ? { execution_mode: executionMode } : {}) },
598
617
  });
599
618
  console.log(`${LOG} enqueued plan ${enqueue.planRequestId} (trigger=${enqueue.triggerRunId ?? 'n/a'})`);
600
619
  const detail = await waitForPlanRequest({
@@ -653,7 +672,7 @@ export async function pipelineAdoptCommand(args) {
653
672
  const nativeId = flagString(args.flags, 'native-id');
654
673
  const approvedBy = flagString(args.flags, 'approved-by');
655
674
  if (!stage || !ref || !nativeId || !approvedBy) {
656
- console.error('usage: seq-studio pipeline adopt --stage <slug> --ref <sha|branch> -e <env> ' +
675
+ console.error('usage: seq-studio pipeline adopt --stage <slug> --ref <sha|branch> [--root <directory>] -e <env> ' +
657
676
  '--native-id <id> --approved-by <you> [--resource-key <key>] [--kind job|dlt_pipeline] ' +
658
677
  '[--old-source-removal-pr <url>] [--repo <namespace>/<slug>] [--json]');
659
678
  return 1;
@@ -668,7 +687,10 @@ export async function pipelineAdoptCommand(args) {
668
687
  console.error(`${LOG} adopt failed: ${error instanceof Error ? error.message : String(error)}`);
669
688
  return 1;
670
689
  }
671
- const repo = flagString(args.flags, 'repo');
690
+ const repo = releaseUnitRepo({
691
+ repo: flagString(args.flags, 'repo'),
692
+ root: flagString(args.flags, 'root'),
693
+ });
672
694
  const resourceKey = flagString(args.flags, 'resource-key') ?? stage.replace(/-/g, '_');
673
695
  const kind = flagString(args.flags, 'kind') ?? 'job';
674
696
  if (kind !== 'job' && kind !== 'dlt_pipeline') {
@@ -718,7 +740,7 @@ export async function pipelineUnbindCommand(args) {
718
740
  const ref = flagString(args.flags, 'ref');
719
741
  const approvedBy = flagString(args.flags, 'approved-by');
720
742
  if (!stage || !ref || !approvedBy) {
721
- console.error('usage: seq-studio pipeline unbind --stage <slug> --ref <sha|branch> -e <env> ' +
743
+ console.error('usage: seq-studio pipeline unbind --stage <slug> --ref <sha|branch> [--root <directory>] -e <env> ' +
722
744
  '--approved-by <you> [--resource-key <key>] [--repo <namespace>/<slug>] [--json]');
723
745
  return 1;
724
746
  }
@@ -732,7 +754,10 @@ export async function pipelineUnbindCommand(args) {
732
754
  console.error(`${LOG} unbind failed: ${error instanceof Error ? error.message : String(error)}`);
733
755
  return 1;
734
756
  }
735
- const repo = flagString(args.flags, 'repo');
757
+ const repo = releaseUnitRepo({
758
+ repo: flagString(args.flags, 'repo'),
759
+ root: flagString(args.flags, 'root'),
760
+ });
736
761
  const resourceKey = flagString(args.flags, 'resource-key');
737
762
  const stageId = await resolveStageIdBySlug({
738
763
  baseUrl: env.url,
@@ -191,6 +191,10 @@ function serializeNodeMetadata(node) {
191
191
  }
192
192
  if (agent.timeout !== undefined)
193
193
  meta.timeout = agent.timeout;
194
+ if (agent.allowedTools !== undefined)
195
+ meta.allowed_tools = [...agent.allowedTools];
196
+ if (agent.outputMode !== undefined)
197
+ meta.output_mode = agent.outputMode;
194
198
  if (agent.workflowId !== undefined)
195
199
  meta.workflow_id = agent.workflowId;
196
200
  if (agent.on_reset_edge_id)
@@ -102,6 +102,8 @@ function emitNode(node, ctx) {
102
102
  ` agent: { id: ${lit(String(m.agent_id))}${m.agent_version !== undefined
103
103
  ? `, version: ${value(m.agent_version)}`
104
104
  : ''} },`,
105
+ m.allowed_tools !== undefined ? ` allowedTools: ${JSON.stringify(m.allowed_tools)},` : null,
106
+ m.output_mode !== undefined ? ` outputMode: ${value(m.output_mode)},` : null,
105
107
  m.workflow_id != null ? ` workflowId: ${lit(String(m.workflow_id))},` : null,
106
108
  m.on_reset_edge_id != null ? ` on_reset_edge_id: ${lit(String(m.on_reset_edge_id))},` : null,
107
109
  m.timeout !== undefined ? ` timeout: ${value(m.timeout)},` : null,
@@ -500,6 +500,9 @@ function serializedAgentContract(node) {
500
500
  const onResetEdgeId = node.metadata.on_reset_edge_id;
501
501
  return {
502
502
  agentId,
503
+ workflowId: node.metadata.workflow_id,
504
+ outputMode: node.metadata.output_mode,
505
+ allowedTools: node.metadata.allowed_tools,
503
506
  ...(typeof agentVersion === 'number' ? { agentVersion } : {}),
504
507
  allEdgeIds: node.outgoing_edges.map((edge) => edge.id),
505
508
  ...(typeof onResetEdgeId === 'string' ? { onResetEdgeId } : {}),
@@ -514,6 +517,9 @@ async function lintAgent(processId, node, errors, warnings, loadAgentSchemaEdgeI
514
517
  nodeId: node.id,
515
518
  agentId: node.agent.id,
516
519
  agentVersion: node.agent.version,
520
+ workflowId: node.workflowId,
521
+ outputMode: node.outputMode,
522
+ allowedTools: node.allowedTools,
517
523
  allEdgeIds: node.outgoing_edges.map((edge) => edge.id),
518
524
  onResetEdgeId: node.on_reset_edge_id,
519
525
  errors,
@@ -523,7 +529,7 @@ async function lintAgent(processId, node, errors, warnings, loadAgentSchemaEdgeI
523
529
  includeStaticValidation: true,
524
530
  });
525
531
  }
526
- async function lintAgentContract({ processId, nodeId, agentId, agentVersion, allEdgeIds, onResetEdgeId, errors, warnings, loadAgentSchemaEdgeIdEnum, suppressUnavailableAgentWarnings, includeStaticValidation, }) {
532
+ async function lintAgentContract({ processId, nodeId, agentId, agentVersion, workflowId, outputMode, allowedTools, allEdgeIds, onResetEdgeId, errors, warnings, loadAgentSchemaEdgeIdEnum, suppressUnavailableAgentWarnings, includeStaticValidation, }) {
527
533
  if (includeStaticValidation && onResetEdgeId && !allEdgeIds.includes(onResetEdgeId)) {
528
534
  errors.push({
529
535
  process_id: processId,
@@ -531,9 +537,38 @@ async function lintAgentContract({ processId, nodeId, agentId, agentVersion, all
531
537
  message: `on_reset_edge_id "${onResetEdgeId}" is not in outgoing_edges`,
532
538
  });
533
539
  }
540
+ if (workflowId !== undefined && (allowedTools !== undefined || outputMode !== undefined)) {
541
+ errors.push({
542
+ process_id: processId,
543
+ node_id: nodeId,
544
+ message: 'allowedTools and outputMode cannot be used with workflowId',
545
+ });
546
+ }
534
547
  const outgoingIds = allEdgeIds.filter((id) => id !== onResetEdgeId);
548
+ if (allowedTools !== undefined && (!Array.isArray(allowedTools) || allowedTools.length === 0 ||
549
+ allowedTools.some((tool) => typeof tool !== 'string' || tool.trim().length === 0))) {
550
+ errors.push({
551
+ process_id: processId,
552
+ node_id: nodeId,
553
+ message: 'allowedTools must be a nonempty array of nonempty strings',
554
+ });
555
+ }
556
+ if (outputMode !== undefined && outputMode !== 'payload') {
557
+ errors.push({
558
+ process_id: processId,
559
+ node_id: nodeId,
560
+ message: 'unsupported agent outputMode',
561
+ });
562
+ }
563
+ if (outputMode === 'payload' && outgoingIds.length > 1) {
564
+ errors.push({
565
+ process_id: processId,
566
+ node_id: nodeId,
567
+ message: 'payload mode permits at most one normal outgoing edge',
568
+ });
569
+ }
535
570
  if (agentVersion !== undefined) {
536
- if (outgoingIds.length > 1) {
571
+ if (outputMode !== 'payload' && outgoingIds.length > 1) {
537
572
  warnings.push({
538
573
  process_id: processId,
539
574
  node_id: nodeId,
@@ -543,7 +578,7 @@ async function lintAgentContract({ processId, nodeId, agentId, agentVersion, all
543
578
  return;
544
579
  }
545
580
  if (!loadAgentSchemaEdgeIdEnum) {
546
- if (outgoingIds.length > 1 && !suppressUnavailableAgentWarnings) {
581
+ if (outputMode !== 'payload' && outgoingIds.length > 1 && !suppressUnavailableAgentWarnings) {
547
582
  warnings.push({
548
583
  process_id: processId,
549
584
  node_id: nodeId,
@@ -572,7 +607,7 @@ async function lintAgentContract({ processId, nodeId, agentId, agentVersion, all
572
607
  });
573
608
  return;
574
609
  }
575
- if (outgoingIds.length === 0)
610
+ if (outputMode === 'payload' || outgoingIds.length === 0)
576
611
  return;
577
612
  if (enumValues === null) {
578
613
  // No edge_id enum is the generic-agent contract: one agent serving nodes
@@ -173,6 +173,8 @@ const BEHAVIORAL_METADATA_FIELDS = {
173
173
  ],
174
174
  agent: [
175
175
  'agent_version',
176
+ 'allowed_tools',
177
+ 'output_mode',
176
178
  'input_mapper_source',
177
179
  'input_mapper_expr',
178
180
  'timeout',
@@ -106,6 +106,6 @@ export declare function reposCiRequireCommand(args: ParsedArgs): Promise<number>
106
106
  export declare function reposCiImportCommand(args: ParsedArgs): Promise<number>;
107
107
  export declare function reposCiCommand(args: ParsedArgs): Promise<number>;
108
108
  export declare function reposDeleteCommand(args: ParsedArgs): Promise<number>;
109
- export declare const REPOS_USAGE = "usage:\n seq-studio repos list -e <env> [--namespace <slug>] [--mine] repos visible on the environment\n seq-studio repos namespaces [create <slug>] -e <env> list or create namespaces\n seq-studio repos show <ns>/<name> -e <env> repo detail (branches, clone URL)\n seq-studio repos create <ns>/<name> -e <env> [--default-branch b] [--git-backend gcs_isomorphic|walgit]\n create a repo (GCS default, seed README;\n walgit starts empty on main; needs namespace write)\n seq-studio repos clone <ns>/<name> -e <env> [--ref r] [--output dir] [--force] [--full]\n seq-studio repos clone --url <https://\u2026/repos/<id>/git> -e <env> [--ref r] [--output dir] [--full]\n seq-studio repos clone --id <uuid> -e <env> [--ref r] [--output dir] [--full]\n smart-HTTP when ATLAS_GIT_PAT is set;\n otherwise JSON materialize (<ns>/<name>)\n seq-studio repos pull <ns>/<name> -e <env> [--ref r] [--out dir] [--force]\n materialize the tree at a ref (JSON API)\n seq-studio repos delete <ns>/<name> -e <env> [--yes] delete a repo (confirm prompt)\n seq-studio repos ci show <ns>/<name> -e <env> [--ref r] preview discovered CI checks\n seq-studio repos ci require <ns>/<name> --check <name> -e <env> reserved (refuses write until sandboxed runner)\n seq-studio repos ci import <ns>/<name> -e <env> [--ref r] reserved (refuses write until sandboxed runner)\n\n Flags: -e/--env <env> (required; see: seq-studio envs list)\n\n clone prefers real git clone (PAT via askpass \u2014 never written into the remote\n URL). Without ATLAS_GIT_PAT, <ns>/<name> falls back to the JSON API and prints\n how to get a PAT (seq-studio or Atlas UI /settings/tokens).\n PAT without Auth0 login: use --id from Repositories \u2192 Clone\n (or --url with the environment's canonical HTTPS origin).\n --ref accepts a branch, tag, or commit SHA (SHA \u2192 full clone, then checkout).\n Branch and tag clones are shallow (--depth 1). Pass --full for history.\n --output selects the clone directory (--out remains an alias).\n\n Authenticate JSON API calls with: seq-studio login\n Authenticate git clone/push with: ATLAS_GIT_PAT (from Atlas Settings \u2192 Tokens)\n";
109
+ export declare const REPOS_USAGE = "usage:\n seq-studio repos list -e <env> [--namespace <slug>] [--mine] repos visible on the environment\n seq-studio repos namespaces [create <slug>] -e <env> list or create namespaces\n seq-studio repos show <ns>/<name> -e <env> repo detail (branches, clone URL)\n seq-studio repos create <ns>/<name> -e <env> [--default-branch b] [--git-backend walgit]\n create a repo seeded with a README; --git-backend\n walgit creates it empty (for pushing existing\n history); needs namespace write\n seq-studio repos clone <ns>/<name> -e <env> [--ref r] [--output dir] [--force] [--full]\n seq-studio repos clone --url <https://\u2026/repos/<id>/git> -e <env> [--ref r] [--output dir] [--full]\n seq-studio repos clone --id <uuid> -e <env> [--ref r] [--output dir] [--full]\n smart-HTTP when ATLAS_GIT_PAT is set;\n otherwise JSON materialize (<ns>/<name>)\n seq-studio repos pull <ns>/<name> -e <env> [--ref r] [--out dir] [--force]\n materialize the tree at a ref (JSON API)\n seq-studio repos delete <ns>/<name> -e <env> [--yes] delete a repo (confirm prompt)\n seq-studio repos ci show <ns>/<name> -e <env> [--ref r] preview discovered CI checks\n seq-studio repos ci require <ns>/<name> --check <name> -e <env> reserved (refuses write until sandboxed runner)\n seq-studio repos ci import <ns>/<name> -e <env> [--ref r] reserved (refuses write until sandboxed runner)\n\n Flags: -e/--env <env> (required; see: seq-studio envs list)\n\n clone prefers real git clone (PAT via askpass \u2014 never written into the remote\n URL). Without ATLAS_GIT_PAT, <ns>/<name> falls back to the JSON API and prints\n how to get a PAT (seq-studio or Atlas UI /settings/tokens).\n PAT without Auth0 login: use --id from Repositories \u2192 Clone\n (or --url with the environment's canonical HTTPS origin).\n --ref accepts a branch, tag, or commit SHA (SHA \u2192 full clone, then checkout).\n Branch and tag clones are shallow (--depth 1). Pass --full for history.\n --output selects the clone directory (--out remains an alias).\n\n Authenticate JSON API calls with: seq-studio login\n Authenticate git clone/push with: ATLAS_GIT_PAT (from Atlas Settings \u2192 Tokens)\n";
110
110
  export declare function runReposCommand(sub: string | undefined, args: ParsedArgs): Promise<number>;
111
111
  export {};
@@ -278,14 +278,16 @@ export async function reposShowCommand(args) {
278
278
  }
279
279
  return 0;
280
280
  }
281
- const GIT_BACKEND_KINDS = ['gcs_isomorphic', 'walgit'];
282
- const GIT_BACKEND_KIND_SET = new Set(GIT_BACKEND_KINDS);
283
281
  function parseGitBackendFlag(args) {
284
282
  const gitBackend = stringFlag(args.flags, 'git-backend');
285
283
  if (gitBackend === undefined)
286
284
  return undefined;
287
- if (!GIT_BACKEND_KIND_SET.has(gitBackend)) {
288
- throw new Error(`--git-backend must be ${GIT_BACKEND_KINDS.join(' or ')} (got "${gitBackend}").`);
285
+ if (gitBackend === 'gcs_isomorphic') {
286
+ throw new Error('--git-backend gcs_isomorphic is retired. Omit --git-backend for a repo seeded with a README, ' +
287
+ 'or pass --git-backend walgit for an empty repo.');
288
+ }
289
+ if (gitBackend !== 'walgit') {
290
+ throw new Error(`--git-backend must be walgit (got "${gitBackend}").`);
289
291
  }
290
292
  return gitBackend;
291
293
  }
@@ -795,9 +797,10 @@ export const REPOS_USAGE = `usage:
795
797
  seq-studio repos list -e <env> [--namespace <slug>] [--mine] repos visible on the environment
796
798
  seq-studio repos namespaces [create <slug>] -e <env> list or create namespaces
797
799
  seq-studio repos show <ns>/<name> -e <env> repo detail (branches, clone URL)
798
- seq-studio repos create <ns>/<name> -e <env> [--default-branch b] [--git-backend gcs_isomorphic|walgit]
799
- create a repo (GCS default, seed README;
800
- walgit starts empty on main; needs namespace write)
800
+ seq-studio repos create <ns>/<name> -e <env> [--default-branch b] [--git-backend walgit]
801
+ create a repo seeded with a README; --git-backend
802
+ walgit creates it empty (for pushing existing
803
+ history); needs namespace write
801
804
  seq-studio repos clone <ns>/<name> -e <env> [--ref r] [--output dir] [--force] [--full]
802
805
  seq-studio repos clone --url <https://…/repos/<id>/git> -e <env> [--ref r] [--output dir] [--full]
803
806
  seq-studio repos clone --id <uuid> -e <env> [--ref r] [--output dir] [--full]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sequenceholdings/studio-cli",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "Unified Sequence Studio CLI — `seq-studio init` / `add` / `deploy` (app monorepos), `seq-studio agents`, `seq-studio process` (Lattice), `seq-studio artifact`, `seq-studio functions` / `secrets`, `seq-studio repos`, and `seq-studio auth pat`. Includes Auth0 browser login shared with seqapi.",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {
@@ -42,10 +42,10 @@
42
42
  "tsx": "^4.20.3",
43
43
  "zod": "^4.1.13",
44
44
  "@sequenceholdings/agent-spec": "0.1.2",
45
- "@sequenceholdings/artifact-studio": "0.3.0",
45
+ "@sequenceholdings/artifact-studio": "0.3.1",
46
+ "@sequenceholdings/lattice": "0.1.4",
46
47
  "@sequenceholdings/managed-functions": "0.1.1",
47
- "@sequenceholdings/storage": "0.1.0",
48
- "@sequenceholdings/lattice": "0.1.3"
48
+ "@sequenceholdings/storage": "0.1.0"
49
49
  },
50
50
  "peerDependencies": {
51
51
  "@sequenceholdings/orm": "2.1.0",