@getmagical/cli 0.2.6 → 0.2.7

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.
package/dist/index.js CHANGED
@@ -13882,9 +13882,16 @@ function normalizeRepoPath(path9) {
13882
13882
  return path9.replaceAll(/\/+$/gu, "");
13883
13883
  }
13884
13884
  var skillPathPattern = /^(?:skills\/.+|automations\/[^/]+\/skills\/.+|automations\/[^/]+\/agents\/[^/]+\/skills\/.+)$/u;
13885
+ var skillRootPathPattern = /^(?:skills\/[^/]+|automations\/[^/]+\/skills\/[^/]+|automations\/[^/]+\/agents\/[^/]+\/skills\/[^/]+)$/u;
13885
13886
  var repoPathSchema = z21.string().min(1).transform(normalizeRepoPath).refine(isNormalizedRepoPath, {
13886
13887
  message: "Path must be a normalized repository-relative path."
13887
13888
  });
13889
+ var registeredSkillPathSchema = repoPathSchema.refine((path9) => skillPathPattern.test(path9), {
13890
+ message: "Skill paths must be under root, automation, or automation-agent skills."
13891
+ });
13892
+ var registeredSkillRootPathSchema = registeredSkillPathSchema.refine((path9) => skillRootPathPattern.test(path9) && !path9.endsWith("/SKILL.md"), {
13893
+ message: "Registered skill paths must identify a skill root directory."
13894
+ });
13888
13895
  var knowledgeBasePluginPermissionSchema = z21.object({
13889
13896
  path: repoPathSchema.refine(getIsKnowledgeBaseAssetPathAllowed, {
13890
13897
  message: "Knowledge Base paths must be under org, automation, or automation-agent assets."
@@ -13900,9 +13907,7 @@ var memoryConfigSchema = z21.object({
13900
13907
  }).strict().describe("Configuration for the memory runtime plugin.");
13901
13908
  var skillsConfigSchema = z21.object({
13902
13909
  enabled: z21.boolean().default(false).describe("Explicit rollout switch for the skills runtime plugin."),
13903
- registeredSkills: z21.array(repoPathSchema.refine((path9) => skillPathPattern.test(path9), {
13904
- message: "Skill paths must be under root, automation, or automation-agent skills."
13905
- })).default(() => []).describe("Repository skill root paths available to the skills plugin."),
13910
+ registeredSkills: z21.array(registeredSkillPathSchema).default(() => []).describe("Repository skill root paths available to the skills plugin."),
13906
13911
  canEdit: z21.boolean().default(false).describe("Allows the skills runtime plugin to edit repo skills under the root skills folder.")
13907
13912
  }).describe("Configuration for the skills runtime plugin.");
13908
13913
  var agentPluginsConfigSchema = z21.object({
@@ -14270,7 +14275,8 @@ var automationRunConfigBaseSchema = z24.object({
14270
14275
  resolvedRunSettings: automationRunResolvedRunSettingsSchema.optional().describe("Canonical run settings snapshotted onto the automation run at creation time. Present only for runSettings mode; legacyConfig mode intentionally resolves runtime settings from each current agent config instead of storing a misleading snapshot."),
14271
14276
  queueResourcePools: resourcePoolsSchema.optional().describe("Canonical deduped resource-pool requirements snapshotted for queue and slot assignment. Present on new runs so assignment does not recompute requirements from mutable agent config."),
14272
14277
  credentialVariableResourcePools: resourcePoolsSchema.optional().describe("Additional resource pools selected through credential-valued automation variables. These are additive queue requirements and do not change whether the run uses runSettings or legacyConfig as its runtime settings source."),
14273
- resolvedRunSettingsSource: z24.enum(["runSettings", "legacyConfig"]).optional().describe("Runtime mode decided at run creation. runSettings means resolvedRunSettings is canonical for browser/session/resource-pool behaviour; legacyConfig means runtime consumers must use current agent legacy config fields.")
14278
+ resolvedRunSettingsSource: z24.enum(["runSettings", "legacyConfig"]).optional().describe("Runtime mode decided at run creation. runSettings means resolvedRunSettings is canonical for browser/session/resource-pool behaviour; legacyConfig means runtime consumers must use current agent legacy config fields."),
14279
+ automationVersionPinned: z24.literal(true).optional().describe("Infrastructure-owned marker set when the run was explicitly pinned to an automation version (e.g. a branch head draft run). Draft-scoped prompt rendering must keep the pinned agent version instead of re-resolving the latest draft instructions.")
14274
14280
  });
14275
14281
  var automationRunConfigSchema = automationRunConfigBaseSchema.superRefine((config, ctx) => {
14276
14282
  if (config.networkTrafficCaptureExplicitlyDisabled === true && config.networkTrafficCapture !== void 0) {
@@ -14283,6 +14289,7 @@ var automationRunConfigSchema = automationRunConfigBaseSchema.superRefine((confi
14283
14289
  });
14284
14290
  var automationRunStartConfigSchema = automationRunConfigBaseSchema.omit({
14285
14291
  allowPointOfNoReturnOverride: true,
14292
+ automationVersionPinned: true,
14286
14293
  credentialVariableResourcePools: true,
14287
14294
  implicitNetworkTrafficRecordingDecision: true,
14288
14295
  networkTrafficCapture: true,
@@ -14391,6 +14398,8 @@ function createOperationSpec(spec) {
14391
14398
  }
14392
14399
 
14393
14400
  // ../mcp-registry/src/operation-specs.ts
14401
+ var AUTOMATION_BRANCH_NAME_PATTERN = /^[\da-z]+(?:-[\da-z]+)*$/u;
14402
+ var AUTOMATION_BRANCH_NAME_MESSAGE = 'Branch name must use lowercase letters or numbers separated by single dashes (for example, "release-2").';
14394
14403
  function stringOption({
14395
14404
  clientOnly = false,
14396
14405
  description,
@@ -15573,6 +15582,193 @@ query GetAutomations($ids: [ID!]!) {
15573
15582
  }
15574
15583
  }
15575
15584
  }
15585
+ }`
15586
+ }),
15587
+ createOperationSpec({
15588
+ operationName: "ListAutomationBranches",
15589
+ kind: "query",
15590
+ inputSchema: z25.object({
15591
+ automationId: z25.string().min(1)
15592
+ }),
15593
+ cli: {
15594
+ name: "list-automation-branches",
15595
+ path: ["automations", "branches", "list"],
15596
+ description: "List active branches for an automation.",
15597
+ resultKey: "automationBranches",
15598
+ options: [
15599
+ stringOption({
15600
+ inputKey: "automationId",
15601
+ flagName: "automation-id",
15602
+ description: "Automation ID.",
15603
+ required: true
15604
+ })
15605
+ ]
15606
+ },
15607
+ mcp: { fileName: "automationBranches.graphql" },
15608
+ document: `# List active automation branches. Deleted branches are excluded.
15609
+ query ListAutomationBranches($automationId: ID!) {
15610
+ automationBranches(automationId: $automationId) {
15611
+ branchId
15612
+ automationId
15613
+ name
15614
+ headVersionId
15615
+ forkedFromBranchId
15616
+ forkedFromVersionId
15617
+ createdAt
15618
+ updatedAt
15619
+ }
15620
+ }`
15621
+ }),
15622
+ createOperationSpec({
15623
+ operationName: "CreateAutomationBranch",
15624
+ kind: "mutation",
15625
+ inputSchema: z25.object({
15626
+ automationId: z25.string().min(1),
15627
+ name: z25.string().regex(AUTOMATION_BRANCH_NAME_PATTERN, AUTOMATION_BRANCH_NAME_MESSAGE),
15628
+ sourceBranchId: z25.string().min(1).optional(),
15629
+ sourceVersionId: z25.string().min(1).optional()
15630
+ }),
15631
+ cli: {
15632
+ name: "create-automation-branch",
15633
+ path: ["automations", "branches", "create"],
15634
+ description: "Create an automation branch. The source defaults to the current main head.",
15635
+ resultKey: "createAutomationBranch",
15636
+ options: [
15637
+ stringOption({
15638
+ inputKey: "automationId",
15639
+ flagName: "automation-id",
15640
+ description: "Automation ID.",
15641
+ required: true
15642
+ }),
15643
+ stringOption({
15644
+ inputKey: "name",
15645
+ flagName: "name",
15646
+ description: 'Lowercase branch name with single dashes between words or numbers (for example, "release-2").',
15647
+ required: true
15648
+ }),
15649
+ stringOption({
15650
+ inputKey: "sourceBranchId",
15651
+ flagName: "source-branch-id",
15652
+ description: "Optional source branch ID. Omit to branch from main."
15653
+ }),
15654
+ stringOption({
15655
+ inputKey: "sourceVersionId",
15656
+ flagName: "source-version-id",
15657
+ description: "Optional version in the selected source history. Omit to use its head."
15658
+ })
15659
+ ]
15660
+ },
15661
+ mcp: { fileName: "createAutomationBranch.graphql" },
15662
+ document: `# Create an automation branch from main or another branch.
15663
+ mutation CreateAutomationBranch(
15664
+ $automationId: ID!
15665
+ $name: String!
15666
+ $sourceBranchId: ID
15667
+ $sourceVersionId: ID
15668
+ ) {
15669
+ createAutomationBranch(
15670
+ automationId: $automationId
15671
+ name: $name
15672
+ sourceBranchId: $sourceBranchId
15673
+ sourceVersionId: $sourceVersionId
15674
+ ) {
15675
+ branchId
15676
+ automationId
15677
+ name
15678
+ headVersionId
15679
+ forkedFromBranchId
15680
+ forkedFromVersionId
15681
+ createdAt
15682
+ updatedAt
15683
+ }
15684
+ }`
15685
+ }),
15686
+ createOperationSpec({
15687
+ operationName: "GetAutomationBranch",
15688
+ kind: "query",
15689
+ inputSchema: z25.object({
15690
+ automationId: z25.string().min(1),
15691
+ branchId: z25.string().min(1)
15692
+ }),
15693
+ cli: {
15694
+ branchContext: "required",
15695
+ name: "get-automation-branch",
15696
+ path: ["automations", "branches", "get"],
15697
+ description: "Get the hydrated snapshot at an automation branch head without authentication secrets.",
15698
+ resultKey: "automationBranchHead",
15699
+ options: [
15700
+ stringOption({
15701
+ inputKey: "automationId",
15702
+ flagName: "automation-id",
15703
+ description: "Automation ID.",
15704
+ required: true
15705
+ })
15706
+ ]
15707
+ },
15708
+ mcp: { fileName: "automationBranchHead.graphql" },
15709
+ document: `# Get the hydrated snapshot at an active branch head. Authentication secrets are excluded.
15710
+ query GetAutomationBranch($automationId: ID!, $branchId: ID!) {
15711
+ automationBranchHead(automationId: $automationId, branchId: $branchId) {
15712
+ branchId
15713
+ headVersionId
15714
+ automation
15715
+ }
15716
+ }`
15717
+ }),
15718
+ createOperationSpec({
15719
+ operationName: "MergeAutomationBranch",
15720
+ kind: "mutation",
15721
+ inputSchema: z25.object({
15722
+ automationId: z25.string().min(1),
15723
+ branchId: z25.string().min(1)
15724
+ }),
15725
+ cli: {
15726
+ branchContext: "required",
15727
+ name: "merge-automation-branch",
15728
+ path: ["automations", "branches", "merge"],
15729
+ description: "Preview and merge a branch into main when every change is conflict-free.",
15730
+ resultKey: "mergeAutomationBranch",
15731
+ options: [
15732
+ stringOption({
15733
+ inputKey: "automationId",
15734
+ flagName: "automation-id",
15735
+ description: "Automation ID.",
15736
+ required: true
15737
+ })
15738
+ ]
15739
+ },
15740
+ mcp: { fileName: "mergeAutomationBranch.graphql" },
15741
+ document: `# Preview a branch merge and apply it only when there are no conflicts.
15742
+ mutation MergeAutomationBranch($automationId: ID!, $branchId: ID!) {
15743
+ mergeAutomationBranch(automationId: $automationId, branchId: $branchId) {
15744
+ automationId
15745
+ branchId
15746
+ status
15747
+ sourceBranchDeleted
15748
+ preview {
15749
+ baseVersionId
15750
+ sourceVersionId
15751
+ targetVersionId
15752
+ changes {
15753
+ id
15754
+ group
15755
+ label
15756
+ status
15757
+ }
15758
+ }
15759
+ conflicts {
15760
+ id
15761
+ group
15762
+ label
15763
+ status
15764
+ }
15765
+ applyResult {
15766
+ draftVersionId
15767
+ lastSavedAt
15768
+ publishedVersionId
15769
+ wasRebased
15770
+ }
15771
+ }
15576
15772
  }`
15577
15773
  }),
15578
15774
  createOperationSpec({
@@ -15827,9 +16023,11 @@ query GetAutomationWorkbenchCredentials {
15827
16023
  operationName: "GetAutomationWorkbenchDiagnostics",
15828
16024
  kind: "query",
15829
16025
  inputSchema: z25.object({
15830
- draftAutomationId: z25.string().min(1)
16026
+ draftAutomationId: z25.string().min(1),
16027
+ branchId: z25.string().min(1).optional()
15831
16028
  }),
15832
16029
  cli: {
16030
+ branchContext: "optional",
15833
16031
  name: "get-automation-workbench-diagnostics",
15834
16032
  path: ["workbench", "diagnostics"],
15835
16033
  description: "Fetch a compact draft automation graph plus workbench diagnostics.",
@@ -15845,8 +16043,10 @@ query GetAutomationWorkbenchCredentials {
15845
16043
  },
15846
16044
  mcp: { fileName: "automationWorkbenchDiagnostics.graphql" },
15847
16045
  document: `# Query automation workbench diagnostics for a draft automation.
15848
- query GetAutomationWorkbenchDiagnostics($draftAutomationId: ID!) {
15849
- automationWorkbenchDiagnostics(draftAutomationId: $draftAutomationId) {
16046
+ query GetAutomationWorkbenchDiagnostics($draftAutomationId: ID!, $branchId: ID) {
16047
+ automationWorkbenchDiagnostics(draftAutomationId: $draftAutomationId, branchId: $branchId) {
16048
+ branchId
16049
+ headVersionId
15850
16050
  summary {
15851
16051
  draftAutomationId
15852
16052
  name
@@ -16191,10 +16391,19 @@ query GetAutomationWorkbenchAwaitRunCompletion(
16191
16391
  inputSchema: z25.object({
16192
16392
  automationRunId: z25.string().min(1),
16193
16393
  draftAutomationId: z25.string().min(1).optional(),
16394
+ branchId: z25.string().min(1).optional(),
16194
16395
  minConfidence: z25.number().min(0).max(1).optional(),
16195
16396
  includeSensitive: z25.boolean().optional()
16397
+ }).superRefine((input, ctx) => {
16398
+ if (input.branchId && !input.draftAutomationId) {
16399
+ ctx.addIssue({
16400
+ code: z25.ZodIssueCode.custom,
16401
+ message: "--branch-id requires --draft-automation-id."
16402
+ });
16403
+ }
16196
16404
  }),
16197
16405
  cli: {
16406
+ branchContext: "optional",
16198
16407
  name: "get-automation-workbench-schema-suggestions",
16199
16408
  path: ["workbench", "schema-suggestions"],
16200
16409
  description: "Heuristic suggestions for schema fields the agent observed on browser pages but were not declared in the input schema.",
@@ -16229,15 +16438,19 @@ query GetAutomationWorkbenchAwaitRunCompletion(
16229
16438
  query GetAutomationWorkbenchSchemaSuggestions(
16230
16439
  $automationRunId: ID!
16231
16440
  $draftAutomationId: ID
16441
+ $branchId: ID
16232
16442
  $minConfidence: Float
16233
16443
  $includeSensitive: Boolean
16234
16444
  ) {
16235
16445
  automationWorkbenchSchemaSuggestions(
16236
16446
  automationRunId: $automationRunId
16237
16447
  draftAutomationId: $draftAutomationId
16448
+ branchId: $branchId
16238
16449
  minConfidence: $minConfidence
16239
16450
  includeSensitive: $includeSensitive
16240
16451
  ) {
16452
+ branchId
16453
+ headVersionId
16241
16454
  kind
16242
16455
  fieldName
16243
16456
  fieldLabel
@@ -16676,6 +16889,7 @@ mutation ResumeAutomationRun($automationRunId: ID!, $message: String) {
16676
16889
  kind: "mutation",
16677
16890
  inputSchema: z25.object({
16678
16891
  draftAutomationId: z25.string().min(1),
16892
+ branchId: z25.string().min(1).optional(),
16679
16893
  agentId: z25.string().min(1),
16680
16894
  idempotencyKey: z25.string().min(1),
16681
16895
  input: z25.unknown().optional(),
@@ -16685,6 +16899,7 @@ mutation ResumeAutomationRun($automationRunId: ID!, $message: String) {
16685
16899
  consistencyCheckCount: z25.number().int().optional()
16686
16900
  }),
16687
16901
  cli: {
16902
+ branchContext: "optional",
16688
16903
  name: "run-draft-automation",
16689
16904
  path: ["automations", "run-draft"],
16690
16905
  description: "Run a draft automation with an explicit trigger agent.",
@@ -16740,6 +16955,7 @@ mutation ResumeAutomationRun($automationRunId: ID!, $message: String) {
16740
16955
  # \`draftAutomationId\` is the draft automation entity ID (\`Automation.id\`), not \`draftVersionId\`.
16741
16956
  mutation RunDraftAutomation(
16742
16957
  $draftAutomationId: ID!
16958
+ $branchId: ID
16743
16959
  $agentId: ID!
16744
16960
  $idempotencyKey: String!
16745
16961
  $input: JSON
@@ -16750,6 +16966,7 @@ mutation RunDraftAutomation(
16750
16966
  ) {
16751
16967
  runDraftAutomation(
16752
16968
  draftAutomationId: $draftAutomationId
16969
+ branchId: $branchId
16753
16970
  agentId: $agentId
16754
16971
  idempotencyKey: $idempotencyKey
16755
16972
  input: $input
@@ -16759,6 +16976,9 @@ mutation RunDraftAutomation(
16759
16976
  consistencyCheckCount: $consistencyCheckCount
16760
16977
  ) {
16761
16978
  automationRunId
16979
+ automationVersionId
16980
+ branchId
16981
+ headVersionId
16762
16982
  workflowId
16763
16983
  workflowRunId
16764
16984
  }
@@ -16795,10 +17015,12 @@ mutation StopAutomationRun($automationRunId: ID!) {
16795
17015
  kind: "mutation",
16796
17016
  inputSchema: z25.object({
16797
17017
  draftAutomationId: z25.string().min(1),
17018
+ branchId: z25.string().min(1).optional(),
16798
17019
  expectedLastSavedAt: z25.string().optional(),
16799
17020
  operations: automationPatchOperationsSchema
16800
17021
  }),
16801
17022
  cli: {
17023
+ branchContext: "optional",
16802
17024
  name: "preview-automation-patch",
16803
17025
  path: ["workbench", "patch", "preview"],
16804
17026
  description: "Preview semantic workbench patch operations without saving the draft.",
@@ -16822,13 +17044,17 @@ mutation StopAutomationRun($automationRunId: ID!) {
16822
17044
  document: `# Preview semantic automation patch operations without writing.
16823
17045
  mutation PreviewAutomationPatch(
16824
17046
  $draftAutomationId: ID!
17047
+ $branchId: ID
16825
17048
  $operations: [AutomationWorkbenchPatchOperationInput!]!
16826
17049
  ) {
16827
17050
  previewAutomationPatch(
16828
17051
  draftAutomationId: $draftAutomationId
17052
+ branchId: $branchId
16829
17053
  operations: $operations
16830
17054
  ) {
16831
17055
  draftAutomationId
17056
+ branchId
17057
+ headVersionId
16832
17058
  applied
16833
17059
  updateInput
16834
17060
  before {
@@ -16900,6 +17126,83 @@ mutation PreviewAutomationPatch(
16900
17126
  name
16901
17127
  }
16902
17128
  }
17129
+ }`
17130
+ }),
17131
+ createOperationSpec({
17132
+ operationName: "ValidateAutomationPatchReadiness",
17133
+ kind: "mutation",
17134
+ inputSchema: z25.object({
17135
+ targetDraftAutomationId: z25.string().min(1).optional(),
17136
+ newAutomationName: z25.string().min(1).optional(),
17137
+ branchId: z25.string().min(1).optional(),
17138
+ operations: automationPatchOperationsSchema
17139
+ }).superRefine((input, ctx) => {
17140
+ if (input.branchId && !input.targetDraftAutomationId) {
17141
+ ctx.addIssue({
17142
+ code: z25.ZodIssueCode.custom,
17143
+ message: "--branch-id requires --target-draft-automation-id."
17144
+ });
17145
+ }
17146
+ }),
17147
+ cli: {
17148
+ branchContext: "optional",
17149
+ name: "validate-automation-patch-readiness",
17150
+ path: ["workbench", "patch", "readiness"],
17151
+ description: "Validate workbench patch readiness without changing an automation.",
17152
+ resultKey: "validateAutomationPatchReadiness",
17153
+ options: [
17154
+ stringOption({
17155
+ inputKey: "targetDraftAutomationId",
17156
+ flagName: "target-draft-automation-id",
17157
+ description: "Existing draft automation ID to validate."
17158
+ }),
17159
+ stringOption({
17160
+ inputKey: "newAutomationName",
17161
+ flagName: "new-automation-name",
17162
+ description: "New automation name when validating without an existing target."
17163
+ }),
17164
+ jsonOption({
17165
+ inputKey: "operations",
17166
+ flagName: "operations-json",
17167
+ description: `Automation patch operations array. ${COMMAND_CATALOG_HELP}`,
17168
+ required: true
17169
+ })
17170
+ ]
17171
+ },
17172
+ mcp: { fileName: "validateAutomationPatchReadiness.graphql" },
17173
+ document: `# Validate automation patch readiness without writing.
17174
+ mutation ValidateAutomationPatchReadiness(
17175
+ $targetDraftAutomationId: ID
17176
+ $newAutomationName: String
17177
+ $branchId: ID
17178
+ $operations: [AutomationWorkbenchPatchOperationInput!]!
17179
+ ) {
17180
+ validateAutomationPatchReadiness(
17181
+ targetDraftAutomationId: $targetDraftAutomationId
17182
+ newAutomationName: $newAutomationName
17183
+ branchId: $branchId
17184
+ operations: $operations
17185
+ ) {
17186
+ targetDraftAutomationId
17187
+ branchId
17188
+ headVersionId
17189
+ issues {
17190
+ severity
17191
+ code
17192
+ message
17193
+ agentId
17194
+ localId
17195
+ path
17196
+ repair
17197
+ relatedAgentIds
17198
+ relatedLocalIds
17199
+ }
17200
+ createdAgents {
17201
+ localId
17202
+ id
17203
+ name
17204
+ }
17205
+ }
16903
17206
  }`
16904
17207
  }),
16905
17208
  createOperationSpec({
@@ -16907,9 +17210,12 @@ mutation PreviewAutomationPatch(
16907
17210
  kind: "mutation",
16908
17211
  inputSchema: z25.object({
16909
17212
  draftAutomationId: z25.string().min(1),
17213
+ branchId: z25.string().min(1).optional(),
17214
+ expectedLastSavedAt: z25.string().optional(),
16910
17215
  operations: automationPatchOperationsSchema
16911
17216
  }),
16912
17217
  cli: {
17218
+ branchContext: "optional",
16913
17219
  name: "apply-automation-patch",
16914
17220
  path: ["workbench", "patch", "apply"],
16915
17221
  description: "Apply semantic workbench patch operations through the versioned save path.",
@@ -16938,15 +17244,19 @@ mutation PreviewAutomationPatch(
16938
17244
  document: `# Apply semantic automation patch operations through the versioned save path.
16939
17245
  mutation ApplyAutomationPatch(
16940
17246
  $draftAutomationId: ID!
17247
+ $branchId: ID
16941
17248
  $operations: [AutomationWorkbenchPatchOperationInput!]!
16942
17249
  $expectedLastSavedAt: String
16943
17250
  ) {
16944
17251
  applyAutomationPatch(
16945
17252
  draftAutomationId: $draftAutomationId
17253
+ branchId: $branchId
16946
17254
  operations: $operations
16947
17255
  expectedLastSavedAt: $expectedLastSavedAt
16948
17256
  ) {
16949
17257
  draftAutomationId
17258
+ branchId
17259
+ headVersionId
16950
17260
  applied
16951
17261
  updateInput
16952
17262
  before {
@@ -17025,9 +17335,11 @@ mutation ApplyAutomationPatch(
17025
17335
  kind: "mutation",
17026
17336
  inputSchema: z25.object({
17027
17337
  id: z25.string().min(1),
17338
+ branchId: z25.string().min(1).optional(),
17028
17339
  input: updateAutomationInputSchema
17029
17340
  }),
17030
17341
  cli: {
17342
+ branchContext: "optional",
17031
17343
  name: "update-automation-by-id",
17032
17344
  path: ["automations", "update"],
17033
17345
  description: "Update an automation.",
@@ -17054,9 +17366,11 @@ mutation ApplyAutomationPatch(
17054
17366
  # config.storeSchema remains additive. Use removeStoreSchemaPaths to delete named properties (and combine it with config.storeSchema for an atomic rename), or replaceStoreSchema for an exact replacement. replaceStoreSchema cannot be combined with either of those fields.
17055
17367
  # Destructive Store schema changes are rejected when the final agent set still references a removed property. Rewrite those agent references in the same update or leave the property in place.
17056
17368
  # Returns only id and lastSavedAt for MCP tool simplicity
17057
- mutation UpdateAutomationById($id: ID!, $input: UpdateAutomationInput!) {
17058
- updateAutomation(id: $id, input: $input) {
17369
+ mutation UpdateAutomationById($id: ID!, $branchId: ID, $input: UpdateAutomationInput!) {
17370
+ updateAutomation(id: $id, branchId: $branchId, input: $input) {
17059
17371
  id
17372
+ branchId
17373
+ headVersionId
17060
17374
  lastSavedAt
17061
17375
  }
17062
17376
  }`
@@ -17707,6 +18021,185 @@ var organizationAuthenticationsResponseSchema = z26.object({
17707
18021
  authentications: z26.array(organizationAuthenticationSchema),
17708
18022
  success: z26.boolean()
17709
18023
  });
18024
+ var pathwayRegressionRunStatusSchema = z26.enum([
18025
+ "queued",
18026
+ "running",
18027
+ "passed",
18028
+ "failed",
18029
+ "inconclusive",
18030
+ "errored"
18031
+ ]);
18032
+ var pathwayRegressionReplayIterationStatusSchema = z26.enum([
18033
+ "running",
18034
+ "passed",
18035
+ "failed",
18036
+ "inconclusive",
18037
+ "errored"
18038
+ ]);
18039
+ var pathwayRegressionMatchingRunSchema = z26.object({
18040
+ agentRunId: z26.string().min(1),
18041
+ agentVersionId: z26.string().min(1),
18042
+ automationRunId: z26.string().min(1),
18043
+ contractPathHash: z26.string().min(1),
18044
+ finishedAt: z26.string().min(1),
18045
+ signatureId: z26.string().min(1),
18046
+ stepCount: z26.number().nullable()
18047
+ });
18048
+ var pathwayRegressionMatchingRunsPathSchema = z26.object({
18049
+ contractPathId: z26.string().min(1),
18050
+ executablePathHash: z26.string().min(1),
18051
+ label: z26.string().min(1),
18052
+ pathwayKey: z26.string().min(1),
18053
+ runs: z26.array(pathwayRegressionMatchingRunSchema),
18054
+ sortOrder: z26.number()
18055
+ });
18056
+ var pathwayRegressionMatchingRunsResponseSchema = z26.object({
18057
+ agentVersionId: z26.string().min(1),
18058
+ automationId: z26.string().min(1),
18059
+ automationVersionId: z26.string().min(1),
18060
+ contractId: z26.string().min(1),
18061
+ paths: z26.array(pathwayRegressionMatchingRunsPathSchema)
18062
+ });
18063
+ var pathwayRegressionAgentVersionRunPathStatusSchema = z26.enum([
18064
+ "historical_path_missing_after_change",
18065
+ "missing_after_change",
18066
+ "new_pathway",
18067
+ "no_matching_runs",
18068
+ "queued"
18069
+ ]);
18070
+ var pathwayRegressionAgentVersionRunStatusSchema = z26.enum([
18071
+ "queued",
18072
+ "running",
18073
+ "passed",
18074
+ "failed",
18075
+ "inconclusive",
18076
+ "errored",
18077
+ "contract_generation_queued",
18078
+ "not_started"
18079
+ ]);
18080
+ var pathwayRegressionAgentVersionRunPathSideSchema = z26.object({
18081
+ contractPathId: z26.string().min(1),
18082
+ executablePathHash: z26.string().min(1),
18083
+ label: z26.string().min(1),
18084
+ sortOrder: z26.number()
18085
+ });
18086
+ var pathwayRegressionAgentVersionRunPathSchema = z26.object({
18087
+ baseline: pathwayRegressionAgentVersionRunPathSideSchema.nullable(),
18088
+ candidate: pathwayRegressionAgentVersionRunPathSideSchema.nullable(),
18089
+ isInLatestPublishedBaseline: z26.boolean().optional(),
18090
+ lastSeenPublishedAgentVersionId: z26.string().min(1).optional(),
18091
+ lastSeenPublishedAt: z26.string().min(1).nullable().optional(),
18092
+ lastSeenPublishedAutomationVersionId: z26.string().min(1).optional(),
18093
+ lastSeenPublishedSequence: z26.number().optional(),
18094
+ pathwayKey: z26.string().min(1),
18095
+ selectedRunCount: z26.number(),
18096
+ status: pathwayRegressionAgentVersionRunPathStatusSchema
18097
+ });
18098
+ var pathwayRegressionContractGenerationStatusSchema = z26.enum([
18099
+ "failed",
18100
+ "queued",
18101
+ "running",
18102
+ "succeeded"
18103
+ ]);
18104
+ var pathwayRegressionAgentVersionContractQueuedResponseSchema = z26.object({
18105
+ agentVersionId: z26.string().min(1),
18106
+ automationId: z26.string().min(1),
18107
+ automationVersionId: z26.string().min(1),
18108
+ contractGenerationStatus: pathwayRegressionContractGenerationStatusSchema,
18109
+ contractWorkflowId: z26.string().min(1),
18110
+ regressionRunId: z26.null(),
18111
+ selectedReplayCount: z26.literal(0),
18112
+ status: z26.literal("contract_generation_queued"),
18113
+ workflowId: z26.null()
18114
+ });
18115
+ var pathwayRegressionAgentVersionRegressionRunResponseSchema = z26.object({
18116
+ agentVersionId: z26.string().min(1),
18117
+ automationId: z26.string().min(1),
18118
+ automationVersionId: z26.string().min(1),
18119
+ baselineAgentVersionId: z26.string().min(1),
18120
+ baselineAutomationVersionId: z26.string().min(1),
18121
+ baselineContractId: z26.string().min(1),
18122
+ candidateContractId: z26.string().min(1),
18123
+ contractId: z26.string().min(1),
18124
+ paths: z26.array(pathwayRegressionAgentVersionRunPathSchema),
18125
+ regressionRunId: z26.string().min(1).nullable(),
18126
+ selectedReplayCount: z26.number(),
18127
+ status: pathwayRegressionAgentVersionRunStatusSchema,
18128
+ workflowId: z26.string().min(1).nullable()
18129
+ });
18130
+ var pathwayRegressionAgentVersionRunResponseSchema = z26.union([
18131
+ pathwayRegressionAgentVersionContractQueuedResponseSchema,
18132
+ pathwayRegressionAgentVersionRegressionRunResponseSchema
18133
+ ]);
18134
+ var pathwayRegressionCheckSummarySchema = z26.object({
18135
+ errored: z26.number(),
18136
+ failed: z26.number(),
18137
+ inconclusive: z26.number(),
18138
+ passed: z26.number(),
18139
+ total: z26.number()
18140
+ });
18141
+ var pathwayRegressionRunResultIterationSchema = z26.object({
18142
+ baselineIterationId: z26.string().min(1),
18143
+ createdAt: z26.string().min(1),
18144
+ expectedToolName: z26.string().min(1),
18145
+ id: z26.string().min(1),
18146
+ observedToolName: z26.string().min(1).nullable(),
18147
+ outputResult: z26.unknown().nullable(),
18148
+ sequence: z26.number(),
18149
+ status: pathwayRegressionReplayIterationStatusSchema,
18150
+ updatedAt: z26.string().min(1)
18151
+ });
18152
+ var pathwayRegressionReplayCheckResultSchema = z26.object({
18153
+ actualToolName: z26.string().min(1).nullable(),
18154
+ attemptIndex: z26.number(),
18155
+ createdAt: z26.string().min(1),
18156
+ expectedActionAssessment: z26.unknown().nullable(),
18157
+ expectedToolName: z26.string().min(1),
18158
+ id: z26.string().min(1),
18159
+ llmRequestId: z26.string().min(1).nullable(),
18160
+ modelId: z26.string().min(1).nullable(),
18161
+ outputResult: z26.unknown().nullable(),
18162
+ status: z26.enum(["passed", "failed", "errored"]),
18163
+ strictExactMatch: z26.boolean().nullable()
18164
+ });
18165
+ var pathwayRegressionReplayIterationCheckResultsResponseSchema = z26.object({
18166
+ regressionReplayIteration: pathwayRegressionRunResultIterationSchema.extend({
18167
+ checkResults: z26.array(pathwayRegressionReplayCheckResultSchema),
18168
+ regressionReplayId: z26.string().min(1)
18169
+ })
18170
+ });
18171
+ var pathwayRegressionRunResultReplaySchema = z26.object({
18172
+ baselineAgentRunId: z26.string().min(1),
18173
+ baselineAutomationRunId: z26.string().min(1),
18174
+ checks: pathwayRegressionCheckSummarySchema,
18175
+ createdAt: z26.string().min(1),
18176
+ finishedAt: z26.string().min(1).nullable(),
18177
+ id: z26.string().min(1),
18178
+ iterations: z26.array(pathwayRegressionRunResultIterationSchema),
18179
+ status: pathwayRegressionRunStatusSchema
18180
+ });
18181
+ var pathwayRegressionRunResultPathwaySchema = z26.object({
18182
+ contractId: z26.string().min(1),
18183
+ contractPathId: z26.string().min(1).nullable(),
18184
+ label: z26.string().min(1).nullable(),
18185
+ pathwayKey: z26.string().min(1),
18186
+ replays: z26.array(pathwayRegressionRunResultReplaySchema),
18187
+ sortOrder: z26.number().nullable()
18188
+ });
18189
+ var pathwayRegressionRunResultResponseSchema = z26.object({
18190
+ pathways: z26.array(pathwayRegressionRunResultPathwaySchema),
18191
+ regressionRun: z26.object({
18192
+ automationId: z26.string().min(1),
18193
+ candidateAgentVersionId: z26.string().min(1).nullable(),
18194
+ candidateAutomationVersionId: z26.string().min(1),
18195
+ createdAt: z26.string().min(1),
18196
+ finishedAt: z26.string().min(1).nullable(),
18197
+ id: z26.string().min(1),
18198
+ scope: z26.enum(["single_run", "contract_batch", "automation_version"]),
18199
+ status: pathwayRegressionRunStatusSchema,
18200
+ workflowId: z26.string().min(1)
18201
+ })
18202
+ });
17710
18203
  var graphQlResponseSchema = z26.object({
17711
18204
  data: z26.record(z26.string(), z26.unknown()).nullable().optional(),
17712
18205
  errors: z26.array(
@@ -17809,6 +18302,23 @@ function decodeJwtPayload(token) {
17809
18302
  function isOttoAuthorizationToken(token) {
17810
18303
  return decodeJwtPayload(token)?.["iss"] === OTTO_AUTHORIZATION_ISSUER;
17811
18304
  }
18305
+ function buildPathwayRegressionAgentVersionPath({
18306
+ agentVersionId,
18307
+ automationVersionId,
18308
+ leafPath,
18309
+ runsPerPath
18310
+ }) {
18311
+ const path9 = `/pathway-regression/automation-versions/${encodeURIComponent(
18312
+ automationVersionId
18313
+ )}/agent-versions/${encodeURIComponent(agentVersionId)}/${leafPath}`;
18314
+ if (runsPerPath === void 0) {
18315
+ return path9;
18316
+ }
18317
+ const queryParams = new URLSearchParams({
18318
+ runsPerPath: String(runsPerPath)
18319
+ });
18320
+ return `${path9}?${queryParams.toString()}`;
18321
+ }
17812
18322
  function applyAuthenticationHeaders({
17813
18323
  accessToken,
17814
18324
  allowOttoAuthorization,
@@ -18049,6 +18559,111 @@ function createMagicalApiClient({
18049
18559
  throw new CliError("Organization authentications payload was invalid.");
18050
18560
  }
18051
18561
  return parsedResponse.data.authentications;
18562
+ },
18563
+ async previewPathwayRegressionMatchingRuns({
18564
+ accessToken,
18565
+ agentVersionId,
18566
+ automationVersionId,
18567
+ impersonatedOrganizationId,
18568
+ organizationId,
18569
+ runsPerPath
18570
+ }) {
18571
+ const parsedResponse = pathwayRegressionMatchingRunsResponseSchema.safeParse(
18572
+ await fetchJson({
18573
+ accessToken,
18574
+ allowOttoAuthorization: true,
18575
+ ...impersonatedOrganizationId ? { impersonatedOrganizationId } : {},
18576
+ ...organizationId ? { organizationId } : {},
18577
+ path: buildPathwayRegressionAgentVersionPath({
18578
+ agentVersionId,
18579
+ automationVersionId,
18580
+ leafPath: "matching-runs",
18581
+ ...runsPerPath === void 0 ? {} : { runsPerPath }
18582
+ })
18583
+ })
18584
+ );
18585
+ if (!parsedResponse.success) {
18586
+ throw new CliError(
18587
+ "Pathway regression matching-runs payload was invalid."
18588
+ );
18589
+ }
18590
+ return parsedResponse.data;
18591
+ },
18592
+ async startPathwayRegressionAgentVersionRun({
18593
+ accessToken,
18594
+ agentVersionId,
18595
+ automationVersionId,
18596
+ impersonatedOrganizationId,
18597
+ organizationId,
18598
+ runsPerPath
18599
+ }) {
18600
+ const parsedResponse = pathwayRegressionAgentVersionRunResponseSchema.safeParse(
18601
+ await fetchJson({
18602
+ accessToken,
18603
+ allowOttoAuthorization: true,
18604
+ ...impersonatedOrganizationId ? { impersonatedOrganizationId } : {},
18605
+ ...organizationId ? { organizationId } : {},
18606
+ path: buildPathwayRegressionAgentVersionPath({
18607
+ agentVersionId,
18608
+ automationVersionId,
18609
+ leafPath: "run",
18610
+ ...runsPerPath === void 0 ? {} : { runsPerPath }
18611
+ }),
18612
+ init: {
18613
+ method: "POST"
18614
+ }
18615
+ })
18616
+ );
18617
+ if (!parsedResponse.success) {
18618
+ throw new CliError("Pathway regression kickoff payload was invalid.");
18619
+ }
18620
+ return parsedResponse.data;
18621
+ },
18622
+ async getPathwayRegressionRunResult({
18623
+ accessToken,
18624
+ impersonatedOrganizationId,
18625
+ organizationId,
18626
+ regressionRunId
18627
+ }) {
18628
+ const parsedResponse = pathwayRegressionRunResultResponseSchema.safeParse(
18629
+ await fetchJson({
18630
+ accessToken,
18631
+ allowOttoAuthorization: true,
18632
+ ...impersonatedOrganizationId ? { impersonatedOrganizationId } : {},
18633
+ ...organizationId ? { organizationId } : {},
18634
+ path: `/pathway-regression/runs/${encodeURIComponent(
18635
+ regressionRunId
18636
+ )}`
18637
+ })
18638
+ );
18639
+ if (!parsedResponse.success) {
18640
+ throw new CliError("Pathway regression run payload was invalid.");
18641
+ }
18642
+ return parsedResponse.data;
18643
+ },
18644
+ async getPathwayRegressionReplayIterationCheckResults({
18645
+ accessToken,
18646
+ impersonatedOrganizationId,
18647
+ organizationId,
18648
+ regressionReplayIterationId
18649
+ }) {
18650
+ const parsedResponse = pathwayRegressionReplayIterationCheckResultsResponseSchema.safeParse(
18651
+ await fetchJson({
18652
+ accessToken,
18653
+ allowOttoAuthorization: true,
18654
+ ...impersonatedOrganizationId ? { impersonatedOrganizationId } : {},
18655
+ ...organizationId ? { organizationId } : {},
18656
+ path: `/pathway-regression/replay-iterations/${encodeURIComponent(
18657
+ regressionReplayIterationId
18658
+ )}/check-results`
18659
+ })
18660
+ );
18661
+ if (!parsedResponse.success) {
18662
+ throw new CliError(
18663
+ "Pathway regression replay iteration check-results payload was invalid."
18664
+ );
18665
+ }
18666
+ return parsedResponse.data;
18052
18667
  }
18053
18668
  };
18054
18669
  }
@@ -18293,7 +18908,8 @@ function configureCommandPresentation(command) {
18293
18908
  return command;
18294
18909
  }
18295
18910
  function createOperationHelpExamples(operationSpec) {
18296
- const baseCommand = `mgcl ${operationSpec.cli.path.join(" ")}`;
18911
+ const commandPath = operationSpec.cli.path.join(" ");
18912
+ const baseCommand = operationSpec.cli.branchContext === "required" ? `mgcl --branch-id <branch-id> ${commandPath}` : `mgcl ${commandPath}`;
18297
18913
  const requiredOptions = operationSpec.cli.options.filter((optionSpec) => optionSpec.required).map((optionSpec) => {
18298
18914
  if (optionSpec.valueType === "boolean") {
18299
18915
  return `--${optionSpec.flagName}`;
@@ -18313,7 +18929,15 @@ function createOperationHelpExamples(operationSpec) {
18313
18929
  return [
18314
18930
  baseInvocation,
18315
18931
  ...operationSpec.scope === "global" ? [] : [`${baseInvocation} --org <org>`],
18316
- `${baseInvocation} --json`
18932
+ `${baseInvocation} --json`,
18933
+ ...operationSpec.cli.branchContext === "optional" ? [
18934
+ [
18935
+ "mgcl --branch-id <branch-id>",
18936
+ commandPath,
18937
+ ...requiredOptions,
18938
+ "--json"
18939
+ ].join(" ")
18940
+ ] : []
18317
18941
  ];
18318
18942
  }
18319
18943
 
@@ -20213,6 +20837,7 @@ function createWorkosAuthClient({
20213
20837
  }
20214
20838
 
20215
20839
  // src/program.ts
20840
+ var commandBranchContexts = /* @__PURE__ */ new WeakMap();
20216
20841
  function buildCommandOptionProperty(flagName) {
20217
20842
  const [firstSegment, ...remainingSegments] = flagName.split("-");
20218
20843
  return [
@@ -20269,6 +20894,13 @@ function createCliCommanderOption(optionSpec, helpGroup) {
20269
20894
  }
20270
20895
  return nextOption;
20271
20896
  }
20897
+ function parsePositiveIntegerOption(rawValue) {
20898
+ const parsedValue = Number(rawValue);
20899
+ if (!Number.isInteger(parsedValue) || parsedValue < 1) {
20900
+ throw new InvalidArgumentError2("Expected a positive integer.");
20901
+ }
20902
+ return parsedValue;
20903
+ }
20272
20904
  function isRecord5(value) {
20273
20905
  return typeof value === "object" && value !== null && !Array.isArray(value);
20274
20906
  }
@@ -20333,6 +20965,10 @@ function collectOperationVariables(operationSpec, options) {
20333
20965
  return [[optionSpec.inputKey, optionValue]];
20334
20966
  })
20335
20967
  );
20968
+ const { branchId } = options;
20969
+ if (operationSpec.cli.branchContext !== void 0 && typeof branchId === "string") {
20970
+ variables["branchId"] = branchId;
20971
+ }
20336
20972
  return parseOperationVariables(operationSpec, variables);
20337
20973
  }
20338
20974
  function parseOperationVariables(operationSpec, variables) {
@@ -20779,6 +21415,217 @@ async function handleNangoAuthsListCommand(dependencies, options) {
20779
21415
  result: authentications
20780
21416
  });
20781
21417
  }
21418
+ function summarizePathwayRegressionPreview(result) {
21419
+ return {
21420
+ automationVersionId: result.automationVersionId,
21421
+ agentVersionId: result.agentVersionId,
21422
+ contractId: result.contractId,
21423
+ pathwayCount: result.paths.length,
21424
+ selectedReplayCount: result.paths.reduce(
21425
+ (sum, pathway) => sum + pathway.runs.length,
21426
+ 0
21427
+ ),
21428
+ paths: result.paths.map((pathway) => ({
21429
+ sortOrder: pathway.sortOrder,
21430
+ label: pathway.label,
21431
+ pathwayKey: pathway.pathwayKey,
21432
+ matchingRunCount: pathway.runs.length,
21433
+ runs: pathway.runs.map((run) => ({
21434
+ agentRunId: run.agentRunId,
21435
+ automationRunId: run.automationRunId,
21436
+ finishedAt: run.finishedAt,
21437
+ stepCount: run.stepCount
21438
+ }))
21439
+ }))
21440
+ };
21441
+ }
21442
+ function summarizePathwayRegressionKickoff(result) {
21443
+ if ("contractWorkflowId" in result) {
21444
+ return {
21445
+ status: result.status,
21446
+ contractGenerationStatus: result.contractGenerationStatus,
21447
+ contractWorkflowId: result.contractWorkflowId,
21448
+ regressionRunId: result.regressionRunId,
21449
+ workflowId: result.workflowId,
21450
+ selectedReplayCount: result.selectedReplayCount,
21451
+ automationVersionId: result.automationVersionId,
21452
+ agentVersionId: result.agentVersionId
21453
+ };
21454
+ }
21455
+ return {
21456
+ regressionRunId: result.regressionRunId,
21457
+ workflowId: result.workflowId,
21458
+ status: result.status,
21459
+ selectedReplayCount: result.selectedReplayCount,
21460
+ automationVersionId: result.automationVersionId,
21461
+ agentVersionId: result.agentVersionId,
21462
+ contractId: result.contractId,
21463
+ baselineAutomationVersionId: result.baselineAutomationVersionId,
21464
+ baselineAgentVersionId: result.baselineAgentVersionId,
21465
+ baselineContractId: result.baselineContractId,
21466
+ candidateContractId: result.candidateContractId,
21467
+ paths: result.paths.map((pathway) => ({
21468
+ sortOrder: pathway.candidate?.sortOrder ?? pathway.baseline?.sortOrder ?? null,
21469
+ baselineLabel: pathway.baseline?.label ?? null,
21470
+ candidateLabel: pathway.candidate?.label ?? null,
21471
+ pathwayKey: pathway.pathwayKey,
21472
+ selectedRunCount: pathway.selectedRunCount,
21473
+ status: pathway.status,
21474
+ isInLatestPublishedBaseline: pathway.isInLatestPublishedBaseline ?? null,
21475
+ lastSeenPublishedAutomationVersionId: pathway.lastSeenPublishedAutomationVersionId ?? null,
21476
+ lastSeenPublishedAgentVersionId: pathway.lastSeenPublishedAgentVersionId ?? null,
21477
+ lastSeenPublishedSequence: pathway.lastSeenPublishedSequence ?? null
21478
+ }))
21479
+ };
21480
+ }
21481
+ function summarizePathwayRegressionResult(result) {
21482
+ const replayCount = result.pathways.reduce(
21483
+ (sum, pathway) => sum + pathway.replays.length,
21484
+ 0
21485
+ );
21486
+ return {
21487
+ regressionRunId: result.regressionRun.id,
21488
+ workflowId: result.regressionRun.workflowId,
21489
+ scope: result.regressionRun.scope,
21490
+ status: result.regressionRun.status,
21491
+ finishedAt: result.regressionRun.finishedAt,
21492
+ pathwayCount: result.pathways.length,
21493
+ replayCount,
21494
+ pathways: result.pathways.map((pathway) => ({
21495
+ sortOrder: pathway.sortOrder,
21496
+ label: pathway.label ?? pathway.pathwayKey,
21497
+ pathwayKey: pathway.pathwayKey,
21498
+ replays: pathway.replays.map((replay) => ({
21499
+ regressionReplayId: replay.id,
21500
+ baselineAgentRunId: replay.baselineAgentRunId,
21501
+ baselineAutomationRunId: replay.baselineAutomationRunId,
21502
+ status: replay.status,
21503
+ checks: replay.checks,
21504
+ nonPassingIterations: replay.iterations.filter((iteration) => iteration.status !== "passed").map((iteration) => ({
21505
+ regressionReplayIterationId: iteration.id,
21506
+ sequence: iteration.sequence,
21507
+ status: iteration.status,
21508
+ expectedToolName: iteration.expectedToolName,
21509
+ observedToolName: iteration.observedToolName
21510
+ }))
21511
+ }))
21512
+ }))
21513
+ };
21514
+ }
21515
+ function summarizePathwayRegressionReplayIterationCheckResults(result) {
21516
+ const { regressionReplayIteration } = result;
21517
+ return {
21518
+ regressionReplayId: regressionReplayIteration.regressionReplayId,
21519
+ regressionReplayIterationId: regressionReplayIteration.id,
21520
+ sequence: regressionReplayIteration.sequence,
21521
+ status: regressionReplayIteration.status,
21522
+ expectedToolName: regressionReplayIteration.expectedToolName,
21523
+ observedToolName: regressionReplayIteration.observedToolName,
21524
+ checkCount: regressionReplayIteration.checkResults.length,
21525
+ checks: regressionReplayIteration.checkResults.map((checkResult) => ({
21526
+ attemptIndex: checkResult.attemptIndex,
21527
+ status: checkResult.status,
21528
+ expectedToolName: checkResult.expectedToolName,
21529
+ actualToolName: checkResult.actualToolName,
21530
+ outputResult: checkResult.outputResult
21531
+ }))
21532
+ };
21533
+ }
21534
+ async function handlePathwayRegressionPreviewCommand(dependencies, options) {
21535
+ const { accessToken, impersonatedOrganizationId, organization, state } = await withSelectedOrganizationAndAccessToken({ dependencies, options });
21536
+ const previewPathwayRegressionMatchingRuns = requireApiClientMethod(
21537
+ dependencies.apiClient,
21538
+ "previewPathwayRegressionMatchingRuns"
21539
+ );
21540
+ const result = await previewPathwayRegressionMatchingRuns({
21541
+ accessToken,
21542
+ agentVersionId: options.agentVersionId,
21543
+ automationVersionId: options.automationVersionId,
21544
+ ...impersonatedOrganizationId ? { impersonatedOrganizationId } : {},
21545
+ organizationId: organization.id,
21546
+ ...options.runsPerPath === void 0 ? {} : { runsPerPath: options.runsPerPath }
21547
+ });
21548
+ await saveLastUsedOrganization({
21549
+ dependencies,
21550
+ organizationId: organization.id,
21551
+ state
21552
+ });
21553
+ writeCommandOutput({
21554
+ dependencies,
21555
+ json: options.json,
21556
+ result: options.json ? result : summarizePathwayRegressionPreview(result)
21557
+ });
21558
+ }
21559
+ async function handlePathwayRegressionRunCommand(dependencies, options) {
21560
+ const { accessToken, impersonatedOrganizationId, organization, state } = await withSelectedOrganizationAndAccessToken({ dependencies, options });
21561
+ const startPathwayRegressionAgentVersionRun = requireApiClientMethod(
21562
+ dependencies.apiClient,
21563
+ "startPathwayRegressionAgentVersionRun"
21564
+ );
21565
+ const result = await startPathwayRegressionAgentVersionRun({
21566
+ accessToken,
21567
+ agentVersionId: options.agentVersionId,
21568
+ automationVersionId: options.automationVersionId,
21569
+ ...impersonatedOrganizationId ? { impersonatedOrganizationId } : {},
21570
+ organizationId: organization.id
21571
+ });
21572
+ await saveLastUsedOrganization({
21573
+ dependencies,
21574
+ organizationId: organization.id,
21575
+ state
21576
+ });
21577
+ writeCommandOutput({
21578
+ dependencies,
21579
+ json: options.json,
21580
+ result: options.json ? result : summarizePathwayRegressionKickoff(result)
21581
+ });
21582
+ }
21583
+ async function handlePathwayRegressionResultsCommand(dependencies, options) {
21584
+ const { accessToken, impersonatedOrganizationId, organization, state } = await withSelectedOrganizationAndAccessToken({ dependencies, options });
21585
+ const getPathwayRegressionRunResult = requireApiClientMethod(
21586
+ dependencies.apiClient,
21587
+ "getPathwayRegressionRunResult"
21588
+ );
21589
+ const result = await getPathwayRegressionRunResult({
21590
+ accessToken,
21591
+ regressionRunId: options.regressionRunId,
21592
+ ...impersonatedOrganizationId ? { impersonatedOrganizationId } : {},
21593
+ organizationId: organization.id
21594
+ });
21595
+ await saveLastUsedOrganization({
21596
+ dependencies,
21597
+ organizationId: organization.id,
21598
+ state
21599
+ });
21600
+ writeCommandOutput({
21601
+ dependencies,
21602
+ json: options.json,
21603
+ result: options.json ? result : summarizePathwayRegressionResult(result)
21604
+ });
21605
+ }
21606
+ async function handlePathwayRegressionCheckResultsCommand(dependencies, options) {
21607
+ const { accessToken, impersonatedOrganizationId, organization, state } = await withSelectedOrganizationAndAccessToken({ dependencies, options });
21608
+ const getPathwayRegressionReplayIterationCheckResults = requireApiClientMethod(
21609
+ dependencies.apiClient,
21610
+ "getPathwayRegressionReplayIterationCheckResults"
21611
+ );
21612
+ const result = await getPathwayRegressionReplayIterationCheckResults({
21613
+ accessToken,
21614
+ regressionReplayIterationId: options.regressionReplayIterationId,
21615
+ ...impersonatedOrganizationId ? { impersonatedOrganizationId } : {},
21616
+ organizationId: organization.id
21617
+ });
21618
+ await saveLastUsedOrganization({
21619
+ dependencies,
21620
+ organizationId: organization.id,
21621
+ state
21622
+ });
21623
+ writeCommandOutput({
21624
+ dependencies,
21625
+ json: options.json,
21626
+ result: options.json ? result : summarizePathwayRegressionReplayIterationCheckResults(result)
21627
+ });
21628
+ }
20782
21629
  async function resolveDirectAccessTokenOrganizationId({
20783
21630
  dependencies
20784
21631
  }) {
@@ -20857,6 +21704,7 @@ function addRegistryOperationCommand({
20857
21704
  configureOperationalCommand(legacyAliasCommand, dependencies, operationSpec);
20858
21705
  }
20859
21706
  function configureOperationalCommand(command, dependencies, operationSpec) {
21707
+ commandBranchContexts.set(command, operationSpec.cli.branchContext);
20860
21708
  command.description(operationSpec.cli.description);
20861
21709
  if (operationSpec.scope !== "global") {
20862
21710
  command.addOption(
@@ -20942,7 +21790,12 @@ function createDefaultDependencies() {
20942
21790
  function buildProgram(dependencies) {
20943
21791
  const program2 = configureCommandPresentation(
20944
21792
  new Command2().name("mgcl").description("Run Magical operations from the command line.")
20945
- ).addOption(new Option2("--json", "Render JSON output.")).version(CLI_VERSION, "--version", `Display mgcl version (${CLI_VERSION}).`).addOption(
21793
+ ).addOption(new Option2("--json", "Render JSON output.")).addOption(
21794
+ new Option2(
21795
+ "--branch-id <id>",
21796
+ "Target a supported automation command at one branch; omit it to target main."
21797
+ )
21798
+ ).version(CLI_VERSION, "--version", `Display mgcl version (${CLI_VERSION}).`).addOption(
20946
21799
  new Option2(
20947
21800
  "--update",
20948
21801
  "Update mgcl to the latest published npm release."
@@ -20960,6 +21813,18 @@ ${formatExamples("Quick start", [
20960
21813
 
20961
21814
  ${formatOutputModesNote()}`
20962
21815
  );
21816
+ program2.hook("preAction", (_thisCommand, actionCommand) => {
21817
+ const options = actionCommand.optsWithGlobals();
21818
+ const branchContext = commandBranchContexts.get(actionCommand);
21819
+ if (options.branchId && branchContext === void 0) {
21820
+ throw new CliError(
21821
+ `Command "${actionCommand.name()}" does not support --branch-id.`
21822
+ );
21823
+ }
21824
+ if (!options.branchId && branchContext === "required") {
21825
+ throw new CliError("--branch-id is required for this command.");
21826
+ }
21827
+ });
20963
21828
  program2.action(async function() {
20964
21829
  const options = this.optsWithGlobals();
20965
21830
  if (options.update) {
@@ -21004,6 +21869,88 @@ ${formatExamples("Examples", [
21004
21869
  );
21005
21870
  });
21006
21871
  program2.addCommand(orgCommand);
21872
+ const pathwayRegressionCommand = configureCommandPresentation(
21873
+ new Command2("pathway-regression").description(
21874
+ "Preview, start, and inspect pathway regression runs."
21875
+ )
21876
+ ).helpGroup("Workspace:").addHelpText(
21877
+ "after",
21878
+ `
21879
+ ${formatExamples("Examples", [
21880
+ "mgcl pathway-regression preview --automation-version-id <id> --agent-version-id <id>",
21881
+ "mgcl pathway-regression run --automation-version-id <id> --agent-version-id <id>",
21882
+ "mgcl pathway-regression results --regression-run-id <id>",
21883
+ "mgcl pathway-regression check-results --regression-replay-iteration-id <id>"
21884
+ ])}`
21885
+ );
21886
+ const addPathwayRegressionAgentVersionOptions = (command) => command.addOption(
21887
+ new Option2(
21888
+ "--org <org>",
21889
+ "Organization ID or exact organization name to use."
21890
+ ).helpGroup("Shared options:")
21891
+ ).addOption(
21892
+ new Option2(
21893
+ "--automation-version-id <id>",
21894
+ "Automation version to test against."
21895
+ ).helpGroup("Pathway regression options:").makeOptionMandatory(true)
21896
+ ).addOption(
21897
+ new Option2("--agent-version-id <id>", "Agent version to test.").helpGroup("Pathway regression options:").makeOptionMandatory(true)
21898
+ );
21899
+ const addPathwayRegressionPreviewOptions = (command) => addPathwayRegressionAgentVersionOptions(command).addOption(
21900
+ new Option2(
21901
+ "--runs-per-path <count>",
21902
+ "Number of historical runs to use per pathway. Defaults to the service value."
21903
+ ).helpGroup("Pathway regression options:").argParser(parsePositiveIntegerOption)
21904
+ );
21905
+ addPathwayRegressionPreviewOptions(
21906
+ pathwayRegressionCommand.command("preview").description("Show which historical runs are available per pathway.")
21907
+ ).action(async function() {
21908
+ await handlePathwayRegressionPreviewCommand(
21909
+ dependencies,
21910
+ this.optsWithGlobals()
21911
+ );
21912
+ });
21913
+ addPathwayRegressionAgentVersionOptions(
21914
+ pathwayRegressionCommand.command("run").description("Start regression replay for an agent version.")
21915
+ ).action(async function() {
21916
+ await handlePathwayRegressionRunCommand(
21917
+ dependencies,
21918
+ this.optsWithGlobals()
21919
+ );
21920
+ });
21921
+ pathwayRegressionCommand.command("results").description("Read a pathway regression run result.").addOption(
21922
+ new Option2(
21923
+ "--org <org>",
21924
+ "Organization ID or exact organization name to use."
21925
+ ).helpGroup("Shared options:")
21926
+ ).addOption(
21927
+ new Option2(
21928
+ "--regression-run-id <id>",
21929
+ "Pathway regression run ID to inspect."
21930
+ ).helpGroup("Pathway regression options:").makeOptionMandatory(true)
21931
+ ).action(async function() {
21932
+ await handlePathwayRegressionResultsCommand(
21933
+ dependencies,
21934
+ this.optsWithGlobals()
21935
+ );
21936
+ });
21937
+ pathwayRegressionCommand.command("check-results").description("Read detailed check attempts for one replay iteration.").addOption(
21938
+ new Option2(
21939
+ "--org <org>",
21940
+ "Organization ID or exact organization name to use."
21941
+ ).helpGroup("Shared options:")
21942
+ ).addOption(
21943
+ new Option2(
21944
+ "--regression-replay-iteration-id <id>",
21945
+ "Pathway regression replay iteration ID to inspect."
21946
+ ).helpGroup("Pathway regression options:").makeOptionMandatory(true)
21947
+ ).action(async function() {
21948
+ await handlePathwayRegressionCheckResultsCommand(
21949
+ dependencies,
21950
+ this.optsWithGlobals()
21951
+ );
21952
+ });
21953
+ program2.addCommand(pathwayRegressionCommand);
21007
21954
  const nangoCommand = configureCommandPresentation(
21008
21955
  new Command2("nango").description(
21009
21956
  "Inspect Nango integrations and org-scoped authentications."