@getmagical/cli 0.2.6 → 0.2.8

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,228 @@ query GetAutomations($ids: [ID!]!) {
15573
15582
  }
15574
15583
  }
15575
15584
  }
15585
+ }`
15586
+ }),
15587
+ createOperationSpec({
15588
+ operationName: "ViewAutomationReview",
15589
+ kind: "query",
15590
+ inputSchema: z25.object({
15591
+ automationId: z25.string().min(1)
15592
+ }),
15593
+ cli: {
15594
+ name: "view-automation-review",
15595
+ path: ["automations", "view-review"],
15596
+ description: "View the successful review for the current automation version.",
15597
+ resultKey: "automationReviewReport",
15598
+ options: [
15599
+ stringOption({
15600
+ inputKey: "automationId",
15601
+ flagName: "automation-id",
15602
+ description: "Automation ID.",
15603
+ required: true
15604
+ }),
15605
+ booleanOption({
15606
+ clientOnly: true,
15607
+ inputKey: "open",
15608
+ flagName: "open",
15609
+ description: "Open the signed report URL in the default browser."
15610
+ })
15611
+ ]
15612
+ },
15613
+ mcp: { fileName: "automationReviewReport.graphql" },
15614
+ document: `# View the successful review for the exact current automation version
15615
+ query ViewAutomationReview($automationId: ID!) {
15616
+ automationReviewReport(automationId: $automationId) {
15617
+ reportUrl
15618
+ html
15619
+ }
15620
+ }`
15621
+ }),
15622
+ createOperationSpec({
15623
+ operationName: "ListAutomationBranches",
15624
+ kind: "query",
15625
+ inputSchema: z25.object({
15626
+ automationId: z25.string().min(1)
15627
+ }),
15628
+ cli: {
15629
+ name: "list-automation-branches",
15630
+ path: ["automations", "branches", "list"],
15631
+ description: "List active branches for an automation.",
15632
+ resultKey: "automationBranches",
15633
+ options: [
15634
+ stringOption({
15635
+ inputKey: "automationId",
15636
+ flagName: "automation-id",
15637
+ description: "Automation ID.",
15638
+ required: true
15639
+ })
15640
+ ]
15641
+ },
15642
+ mcp: { fileName: "automationBranches.graphql" },
15643
+ document: `# List active automation branches. Deleted branches are excluded.
15644
+ query ListAutomationBranches($automationId: ID!) {
15645
+ automationBranches(automationId: $automationId) {
15646
+ branchId
15647
+ automationId
15648
+ name
15649
+ headVersionId
15650
+ forkedFromBranchId
15651
+ forkedFromVersionId
15652
+ createdAt
15653
+ updatedAt
15654
+ }
15655
+ }`
15656
+ }),
15657
+ createOperationSpec({
15658
+ operationName: "CreateAutomationBranch",
15659
+ kind: "mutation",
15660
+ inputSchema: z25.object({
15661
+ automationId: z25.string().min(1),
15662
+ name: z25.string().regex(AUTOMATION_BRANCH_NAME_PATTERN, AUTOMATION_BRANCH_NAME_MESSAGE),
15663
+ sourceBranchId: z25.string().min(1).optional(),
15664
+ sourceVersionId: z25.string().min(1).optional()
15665
+ }),
15666
+ cli: {
15667
+ name: "create-automation-branch",
15668
+ path: ["automations", "branches", "create"],
15669
+ description: "Create an automation branch. The source defaults to the current main head.",
15670
+ resultKey: "createAutomationBranch",
15671
+ options: [
15672
+ stringOption({
15673
+ inputKey: "automationId",
15674
+ flagName: "automation-id",
15675
+ description: "Automation ID.",
15676
+ required: true
15677
+ }),
15678
+ stringOption({
15679
+ inputKey: "name",
15680
+ flagName: "name",
15681
+ description: 'Lowercase branch name with single dashes between words or numbers (for example, "release-2").',
15682
+ required: true
15683
+ }),
15684
+ stringOption({
15685
+ inputKey: "sourceBranchId",
15686
+ flagName: "source-branch-id",
15687
+ description: "Optional source branch ID. Omit to branch from main."
15688
+ }),
15689
+ stringOption({
15690
+ inputKey: "sourceVersionId",
15691
+ flagName: "source-version-id",
15692
+ description: "Optional version in the selected source history. Omit to use its head."
15693
+ })
15694
+ ]
15695
+ },
15696
+ mcp: { fileName: "createAutomationBranch.graphql" },
15697
+ document: `# Create an automation branch from main or another branch.
15698
+ mutation CreateAutomationBranch(
15699
+ $automationId: ID!
15700
+ $name: String!
15701
+ $sourceBranchId: ID
15702
+ $sourceVersionId: ID
15703
+ ) {
15704
+ createAutomationBranch(
15705
+ automationId: $automationId
15706
+ name: $name
15707
+ sourceBranchId: $sourceBranchId
15708
+ sourceVersionId: $sourceVersionId
15709
+ ) {
15710
+ branchId
15711
+ automationId
15712
+ name
15713
+ headVersionId
15714
+ forkedFromBranchId
15715
+ forkedFromVersionId
15716
+ createdAt
15717
+ updatedAt
15718
+ }
15719
+ }`
15720
+ }),
15721
+ createOperationSpec({
15722
+ operationName: "GetAutomationBranch",
15723
+ kind: "query",
15724
+ inputSchema: z25.object({
15725
+ automationId: z25.string().min(1),
15726
+ branchId: z25.string().min(1)
15727
+ }),
15728
+ cli: {
15729
+ branchContext: "required",
15730
+ name: "get-automation-branch",
15731
+ path: ["automations", "branches", "get"],
15732
+ description: "Get the hydrated snapshot at an automation branch head without authentication secrets.",
15733
+ resultKey: "automationBranchHead",
15734
+ options: [
15735
+ stringOption({
15736
+ inputKey: "automationId",
15737
+ flagName: "automation-id",
15738
+ description: "Automation ID.",
15739
+ required: true
15740
+ })
15741
+ ]
15742
+ },
15743
+ mcp: { fileName: "automationBranchHead.graphql" },
15744
+ document: `# Get the hydrated snapshot at an active branch head. Authentication secrets are excluded.
15745
+ query GetAutomationBranch($automationId: ID!, $branchId: ID!) {
15746
+ automationBranchHead(automationId: $automationId, branchId: $branchId) {
15747
+ branchId
15748
+ headVersionId
15749
+ automation
15750
+ }
15751
+ }`
15752
+ }),
15753
+ createOperationSpec({
15754
+ operationName: "MergeAutomationBranch",
15755
+ kind: "mutation",
15756
+ inputSchema: z25.object({
15757
+ automationId: z25.string().min(1),
15758
+ branchId: z25.string().min(1)
15759
+ }),
15760
+ cli: {
15761
+ branchContext: "required",
15762
+ name: "merge-automation-branch",
15763
+ path: ["automations", "branches", "merge"],
15764
+ description: "Preview and merge a branch into main when every change is conflict-free.",
15765
+ resultKey: "mergeAutomationBranch",
15766
+ options: [
15767
+ stringOption({
15768
+ inputKey: "automationId",
15769
+ flagName: "automation-id",
15770
+ description: "Automation ID.",
15771
+ required: true
15772
+ })
15773
+ ]
15774
+ },
15775
+ mcp: { fileName: "mergeAutomationBranch.graphql" },
15776
+ document: `# Preview a branch merge and apply it only when there are no conflicts.
15777
+ mutation MergeAutomationBranch($automationId: ID!, $branchId: ID!) {
15778
+ mergeAutomationBranch(automationId: $automationId, branchId: $branchId) {
15779
+ automationId
15780
+ branchId
15781
+ status
15782
+ sourceBranchDeleted
15783
+ preview {
15784
+ baseVersionId
15785
+ sourceVersionId
15786
+ targetVersionId
15787
+ changes {
15788
+ id
15789
+ group
15790
+ label
15791
+ status
15792
+ }
15793
+ }
15794
+ conflicts {
15795
+ id
15796
+ group
15797
+ label
15798
+ status
15799
+ }
15800
+ applyResult {
15801
+ draftVersionId
15802
+ lastSavedAt
15803
+ publishedVersionId
15804
+ wasRebased
15805
+ }
15806
+ }
15576
15807
  }`
15577
15808
  }),
15578
15809
  createOperationSpec({
@@ -15827,9 +16058,11 @@ query GetAutomationWorkbenchCredentials {
15827
16058
  operationName: "GetAutomationWorkbenchDiagnostics",
15828
16059
  kind: "query",
15829
16060
  inputSchema: z25.object({
15830
- draftAutomationId: z25.string().min(1)
16061
+ draftAutomationId: z25.string().min(1),
16062
+ branchId: z25.string().min(1).optional()
15831
16063
  }),
15832
16064
  cli: {
16065
+ branchContext: "optional",
15833
16066
  name: "get-automation-workbench-diagnostics",
15834
16067
  path: ["workbench", "diagnostics"],
15835
16068
  description: "Fetch a compact draft automation graph plus workbench diagnostics.",
@@ -15845,8 +16078,10 @@ query GetAutomationWorkbenchCredentials {
15845
16078
  },
15846
16079
  mcp: { fileName: "automationWorkbenchDiagnostics.graphql" },
15847
16080
  document: `# Query automation workbench diagnostics for a draft automation.
15848
- query GetAutomationWorkbenchDiagnostics($draftAutomationId: ID!) {
15849
- automationWorkbenchDiagnostics(draftAutomationId: $draftAutomationId) {
16081
+ query GetAutomationWorkbenchDiagnostics($draftAutomationId: ID!, $branchId: ID) {
16082
+ automationWorkbenchDiagnostics(draftAutomationId: $draftAutomationId, branchId: $branchId) {
16083
+ branchId
16084
+ headVersionId
15850
16085
  summary {
15851
16086
  draftAutomationId
15852
16087
  name
@@ -16191,10 +16426,19 @@ query GetAutomationWorkbenchAwaitRunCompletion(
16191
16426
  inputSchema: z25.object({
16192
16427
  automationRunId: z25.string().min(1),
16193
16428
  draftAutomationId: z25.string().min(1).optional(),
16429
+ branchId: z25.string().min(1).optional(),
16194
16430
  minConfidence: z25.number().min(0).max(1).optional(),
16195
16431
  includeSensitive: z25.boolean().optional()
16432
+ }).superRefine((input, ctx) => {
16433
+ if (input.branchId && !input.draftAutomationId) {
16434
+ ctx.addIssue({
16435
+ code: z25.ZodIssueCode.custom,
16436
+ message: "--branch-id requires --draft-automation-id."
16437
+ });
16438
+ }
16196
16439
  }),
16197
16440
  cli: {
16441
+ branchContext: "optional",
16198
16442
  name: "get-automation-workbench-schema-suggestions",
16199
16443
  path: ["workbench", "schema-suggestions"],
16200
16444
  description: "Heuristic suggestions for schema fields the agent observed on browser pages but were not declared in the input schema.",
@@ -16229,15 +16473,19 @@ query GetAutomationWorkbenchAwaitRunCompletion(
16229
16473
  query GetAutomationWorkbenchSchemaSuggestions(
16230
16474
  $automationRunId: ID!
16231
16475
  $draftAutomationId: ID
16476
+ $branchId: ID
16232
16477
  $minConfidence: Float
16233
16478
  $includeSensitive: Boolean
16234
16479
  ) {
16235
16480
  automationWorkbenchSchemaSuggestions(
16236
16481
  automationRunId: $automationRunId
16237
16482
  draftAutomationId: $draftAutomationId
16483
+ branchId: $branchId
16238
16484
  minConfidence: $minConfidence
16239
16485
  includeSensitive: $includeSensitive
16240
16486
  ) {
16487
+ branchId
16488
+ headVersionId
16241
16489
  kind
16242
16490
  fieldName
16243
16491
  fieldLabel
@@ -16676,6 +16924,7 @@ mutation ResumeAutomationRun($automationRunId: ID!, $message: String) {
16676
16924
  kind: "mutation",
16677
16925
  inputSchema: z25.object({
16678
16926
  draftAutomationId: z25.string().min(1),
16927
+ branchId: z25.string().min(1).optional(),
16679
16928
  agentId: z25.string().min(1),
16680
16929
  idempotencyKey: z25.string().min(1),
16681
16930
  input: z25.unknown().optional(),
@@ -16685,6 +16934,7 @@ mutation ResumeAutomationRun($automationRunId: ID!, $message: String) {
16685
16934
  consistencyCheckCount: z25.number().int().optional()
16686
16935
  }),
16687
16936
  cli: {
16937
+ branchContext: "optional",
16688
16938
  name: "run-draft-automation",
16689
16939
  path: ["automations", "run-draft"],
16690
16940
  description: "Run a draft automation with an explicit trigger agent.",
@@ -16740,6 +16990,7 @@ mutation ResumeAutomationRun($automationRunId: ID!, $message: String) {
16740
16990
  # \`draftAutomationId\` is the draft automation entity ID (\`Automation.id\`), not \`draftVersionId\`.
16741
16991
  mutation RunDraftAutomation(
16742
16992
  $draftAutomationId: ID!
16993
+ $branchId: ID
16743
16994
  $agentId: ID!
16744
16995
  $idempotencyKey: String!
16745
16996
  $input: JSON
@@ -16750,6 +17001,7 @@ mutation RunDraftAutomation(
16750
17001
  ) {
16751
17002
  runDraftAutomation(
16752
17003
  draftAutomationId: $draftAutomationId
17004
+ branchId: $branchId
16753
17005
  agentId: $agentId
16754
17006
  idempotencyKey: $idempotencyKey
16755
17007
  input: $input
@@ -16759,6 +17011,9 @@ mutation RunDraftAutomation(
16759
17011
  consistencyCheckCount: $consistencyCheckCount
16760
17012
  ) {
16761
17013
  automationRunId
17014
+ automationVersionId
17015
+ branchId
17016
+ headVersionId
16762
17017
  workflowId
16763
17018
  workflowRunId
16764
17019
  }
@@ -16795,10 +17050,12 @@ mutation StopAutomationRun($automationRunId: ID!) {
16795
17050
  kind: "mutation",
16796
17051
  inputSchema: z25.object({
16797
17052
  draftAutomationId: z25.string().min(1),
17053
+ branchId: z25.string().min(1).optional(),
16798
17054
  expectedLastSavedAt: z25.string().optional(),
16799
17055
  operations: automationPatchOperationsSchema
16800
17056
  }),
16801
17057
  cli: {
17058
+ branchContext: "optional",
16802
17059
  name: "preview-automation-patch",
16803
17060
  path: ["workbench", "patch", "preview"],
16804
17061
  description: "Preview semantic workbench patch operations without saving the draft.",
@@ -16822,13 +17079,17 @@ mutation StopAutomationRun($automationRunId: ID!) {
16822
17079
  document: `# Preview semantic automation patch operations without writing.
16823
17080
  mutation PreviewAutomationPatch(
16824
17081
  $draftAutomationId: ID!
17082
+ $branchId: ID
16825
17083
  $operations: [AutomationWorkbenchPatchOperationInput!]!
16826
17084
  ) {
16827
17085
  previewAutomationPatch(
16828
17086
  draftAutomationId: $draftAutomationId
17087
+ branchId: $branchId
16829
17088
  operations: $operations
16830
17089
  ) {
16831
17090
  draftAutomationId
17091
+ branchId
17092
+ headVersionId
16832
17093
  applied
16833
17094
  updateInput
16834
17095
  before {
@@ -16900,6 +17161,83 @@ mutation PreviewAutomationPatch(
16900
17161
  name
16901
17162
  }
16902
17163
  }
17164
+ }`
17165
+ }),
17166
+ createOperationSpec({
17167
+ operationName: "ValidateAutomationPatchReadiness",
17168
+ kind: "mutation",
17169
+ inputSchema: z25.object({
17170
+ targetDraftAutomationId: z25.string().min(1).optional(),
17171
+ newAutomationName: z25.string().min(1).optional(),
17172
+ branchId: z25.string().min(1).optional(),
17173
+ operations: automationPatchOperationsSchema
17174
+ }).superRefine((input, ctx) => {
17175
+ if (input.branchId && !input.targetDraftAutomationId) {
17176
+ ctx.addIssue({
17177
+ code: z25.ZodIssueCode.custom,
17178
+ message: "--branch-id requires --target-draft-automation-id."
17179
+ });
17180
+ }
17181
+ }),
17182
+ cli: {
17183
+ branchContext: "optional",
17184
+ name: "validate-automation-patch-readiness",
17185
+ path: ["workbench", "patch", "readiness"],
17186
+ description: "Validate workbench patch readiness without changing an automation.",
17187
+ resultKey: "validateAutomationPatchReadiness",
17188
+ options: [
17189
+ stringOption({
17190
+ inputKey: "targetDraftAutomationId",
17191
+ flagName: "target-draft-automation-id",
17192
+ description: "Existing draft automation ID to validate."
17193
+ }),
17194
+ stringOption({
17195
+ inputKey: "newAutomationName",
17196
+ flagName: "new-automation-name",
17197
+ description: "New automation name when validating without an existing target."
17198
+ }),
17199
+ jsonOption({
17200
+ inputKey: "operations",
17201
+ flagName: "operations-json",
17202
+ description: `Automation patch operations array. ${COMMAND_CATALOG_HELP}`,
17203
+ required: true
17204
+ })
17205
+ ]
17206
+ },
17207
+ mcp: { fileName: "validateAutomationPatchReadiness.graphql" },
17208
+ document: `# Validate automation patch readiness without writing.
17209
+ mutation ValidateAutomationPatchReadiness(
17210
+ $targetDraftAutomationId: ID
17211
+ $newAutomationName: String
17212
+ $branchId: ID
17213
+ $operations: [AutomationWorkbenchPatchOperationInput!]!
17214
+ ) {
17215
+ validateAutomationPatchReadiness(
17216
+ targetDraftAutomationId: $targetDraftAutomationId
17217
+ newAutomationName: $newAutomationName
17218
+ branchId: $branchId
17219
+ operations: $operations
17220
+ ) {
17221
+ targetDraftAutomationId
17222
+ branchId
17223
+ headVersionId
17224
+ issues {
17225
+ severity
17226
+ code
17227
+ message
17228
+ agentId
17229
+ localId
17230
+ path
17231
+ repair
17232
+ relatedAgentIds
17233
+ relatedLocalIds
17234
+ }
17235
+ createdAgents {
17236
+ localId
17237
+ id
17238
+ name
17239
+ }
17240
+ }
16903
17241
  }`
16904
17242
  }),
16905
17243
  createOperationSpec({
@@ -16907,9 +17245,12 @@ mutation PreviewAutomationPatch(
16907
17245
  kind: "mutation",
16908
17246
  inputSchema: z25.object({
16909
17247
  draftAutomationId: z25.string().min(1),
17248
+ branchId: z25.string().min(1).optional(),
17249
+ expectedLastSavedAt: z25.string().optional(),
16910
17250
  operations: automationPatchOperationsSchema
16911
17251
  }),
16912
17252
  cli: {
17253
+ branchContext: "optional",
16913
17254
  name: "apply-automation-patch",
16914
17255
  path: ["workbench", "patch", "apply"],
16915
17256
  description: "Apply semantic workbench patch operations through the versioned save path.",
@@ -16938,15 +17279,19 @@ mutation PreviewAutomationPatch(
16938
17279
  document: `# Apply semantic automation patch operations through the versioned save path.
16939
17280
  mutation ApplyAutomationPatch(
16940
17281
  $draftAutomationId: ID!
17282
+ $branchId: ID
16941
17283
  $operations: [AutomationWorkbenchPatchOperationInput!]!
16942
17284
  $expectedLastSavedAt: String
16943
17285
  ) {
16944
17286
  applyAutomationPatch(
16945
17287
  draftAutomationId: $draftAutomationId
17288
+ branchId: $branchId
16946
17289
  operations: $operations
16947
17290
  expectedLastSavedAt: $expectedLastSavedAt
16948
17291
  ) {
16949
17292
  draftAutomationId
17293
+ branchId
17294
+ headVersionId
16950
17295
  applied
16951
17296
  updateInput
16952
17297
  before {
@@ -17025,9 +17370,11 @@ mutation ApplyAutomationPatch(
17025
17370
  kind: "mutation",
17026
17371
  inputSchema: z25.object({
17027
17372
  id: z25.string().min(1),
17373
+ branchId: z25.string().min(1).optional(),
17028
17374
  input: updateAutomationInputSchema
17029
17375
  }),
17030
17376
  cli: {
17377
+ branchContext: "optional",
17031
17378
  name: "update-automation-by-id",
17032
17379
  path: ["automations", "update"],
17033
17380
  description: "Update an automation.",
@@ -17054,9 +17401,11 @@ mutation ApplyAutomationPatch(
17054
17401
  # 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
17402
  # 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
17403
  # Returns only id and lastSavedAt for MCP tool simplicity
17057
- mutation UpdateAutomationById($id: ID!, $input: UpdateAutomationInput!) {
17058
- updateAutomation(id: $id, input: $input) {
17404
+ mutation UpdateAutomationById($id: ID!, $branchId: ID, $input: UpdateAutomationInput!) {
17405
+ updateAutomation(id: $id, branchId: $branchId, input: $input) {
17059
17406
  id
17407
+ branchId
17408
+ headVersionId
17060
17409
  lastSavedAt
17061
17410
  }
17062
17411
  }`
@@ -17707,6 +18056,185 @@ var organizationAuthenticationsResponseSchema = z26.object({
17707
18056
  authentications: z26.array(organizationAuthenticationSchema),
17708
18057
  success: z26.boolean()
17709
18058
  });
18059
+ var pathwayRegressionRunStatusSchema = z26.enum([
18060
+ "queued",
18061
+ "running",
18062
+ "passed",
18063
+ "failed",
18064
+ "inconclusive",
18065
+ "errored"
18066
+ ]);
18067
+ var pathwayRegressionReplayIterationStatusSchema = z26.enum([
18068
+ "running",
18069
+ "passed",
18070
+ "failed",
18071
+ "inconclusive",
18072
+ "errored"
18073
+ ]);
18074
+ var pathwayRegressionMatchingRunSchema = z26.object({
18075
+ agentRunId: z26.string().min(1),
18076
+ agentVersionId: z26.string().min(1),
18077
+ automationRunId: z26.string().min(1),
18078
+ contractPathHash: z26.string().min(1),
18079
+ finishedAt: z26.string().min(1),
18080
+ signatureId: z26.string().min(1),
18081
+ stepCount: z26.number().nullable()
18082
+ });
18083
+ var pathwayRegressionMatchingRunsPathSchema = z26.object({
18084
+ contractPathId: z26.string().min(1),
18085
+ executablePathHash: z26.string().min(1),
18086
+ label: z26.string().min(1),
18087
+ pathwayKey: z26.string().min(1),
18088
+ runs: z26.array(pathwayRegressionMatchingRunSchema),
18089
+ sortOrder: z26.number()
18090
+ });
18091
+ var pathwayRegressionMatchingRunsResponseSchema = z26.object({
18092
+ agentVersionId: z26.string().min(1),
18093
+ automationId: z26.string().min(1),
18094
+ automationVersionId: z26.string().min(1),
18095
+ contractId: z26.string().min(1),
18096
+ paths: z26.array(pathwayRegressionMatchingRunsPathSchema)
18097
+ });
18098
+ var pathwayRegressionAgentVersionRunPathStatusSchema = z26.enum([
18099
+ "historical_path_missing_after_change",
18100
+ "missing_after_change",
18101
+ "new_pathway",
18102
+ "no_matching_runs",
18103
+ "queued"
18104
+ ]);
18105
+ var pathwayRegressionAgentVersionRunStatusSchema = z26.enum([
18106
+ "queued",
18107
+ "running",
18108
+ "passed",
18109
+ "failed",
18110
+ "inconclusive",
18111
+ "errored",
18112
+ "contract_generation_queued",
18113
+ "not_started"
18114
+ ]);
18115
+ var pathwayRegressionAgentVersionRunPathSideSchema = z26.object({
18116
+ contractPathId: z26.string().min(1),
18117
+ executablePathHash: z26.string().min(1),
18118
+ label: z26.string().min(1),
18119
+ sortOrder: z26.number()
18120
+ });
18121
+ var pathwayRegressionAgentVersionRunPathSchema = z26.object({
18122
+ baseline: pathwayRegressionAgentVersionRunPathSideSchema.nullable(),
18123
+ candidate: pathwayRegressionAgentVersionRunPathSideSchema.nullable(),
18124
+ isInLatestPublishedBaseline: z26.boolean().optional(),
18125
+ lastSeenPublishedAgentVersionId: z26.string().min(1).optional(),
18126
+ lastSeenPublishedAt: z26.string().min(1).nullable().optional(),
18127
+ lastSeenPublishedAutomationVersionId: z26.string().min(1).optional(),
18128
+ lastSeenPublishedSequence: z26.number().optional(),
18129
+ pathwayKey: z26.string().min(1),
18130
+ selectedRunCount: z26.number(),
18131
+ status: pathwayRegressionAgentVersionRunPathStatusSchema
18132
+ });
18133
+ var pathwayRegressionContractGenerationStatusSchema = z26.enum([
18134
+ "failed",
18135
+ "queued",
18136
+ "running",
18137
+ "succeeded"
18138
+ ]);
18139
+ var pathwayRegressionAgentVersionContractQueuedResponseSchema = z26.object({
18140
+ agentVersionId: z26.string().min(1),
18141
+ automationId: z26.string().min(1),
18142
+ automationVersionId: z26.string().min(1),
18143
+ contractGenerationStatus: pathwayRegressionContractGenerationStatusSchema,
18144
+ contractWorkflowId: z26.string().min(1),
18145
+ regressionRunId: z26.null(),
18146
+ selectedReplayCount: z26.literal(0),
18147
+ status: z26.literal("contract_generation_queued"),
18148
+ workflowId: z26.null()
18149
+ });
18150
+ var pathwayRegressionAgentVersionRegressionRunResponseSchema = z26.object({
18151
+ agentVersionId: z26.string().min(1),
18152
+ automationId: z26.string().min(1),
18153
+ automationVersionId: z26.string().min(1),
18154
+ baselineAgentVersionId: z26.string().min(1),
18155
+ baselineAutomationVersionId: z26.string().min(1),
18156
+ baselineContractId: z26.string().min(1),
18157
+ candidateContractId: z26.string().min(1),
18158
+ contractId: z26.string().min(1),
18159
+ paths: z26.array(pathwayRegressionAgentVersionRunPathSchema),
18160
+ regressionRunId: z26.string().min(1).nullable(),
18161
+ selectedReplayCount: z26.number(),
18162
+ status: pathwayRegressionAgentVersionRunStatusSchema,
18163
+ workflowId: z26.string().min(1).nullable()
18164
+ });
18165
+ var pathwayRegressionAgentVersionRunResponseSchema = z26.union([
18166
+ pathwayRegressionAgentVersionContractQueuedResponseSchema,
18167
+ pathwayRegressionAgentVersionRegressionRunResponseSchema
18168
+ ]);
18169
+ var pathwayRegressionCheckSummarySchema = z26.object({
18170
+ errored: z26.number(),
18171
+ failed: z26.number(),
18172
+ inconclusive: z26.number(),
18173
+ passed: z26.number(),
18174
+ total: z26.number()
18175
+ });
18176
+ var pathwayRegressionRunResultIterationSchema = z26.object({
18177
+ baselineIterationId: z26.string().min(1),
18178
+ createdAt: z26.string().min(1),
18179
+ expectedToolName: z26.string().min(1),
18180
+ id: z26.string().min(1),
18181
+ observedToolName: z26.string().min(1).nullable(),
18182
+ outputResult: z26.unknown().nullable(),
18183
+ sequence: z26.number(),
18184
+ status: pathwayRegressionReplayIterationStatusSchema,
18185
+ updatedAt: z26.string().min(1)
18186
+ });
18187
+ var pathwayRegressionReplayCheckResultSchema = z26.object({
18188
+ actualToolName: z26.string().min(1).nullable(),
18189
+ attemptIndex: z26.number(),
18190
+ createdAt: z26.string().min(1),
18191
+ expectedActionAssessment: z26.unknown().nullable(),
18192
+ expectedToolName: z26.string().min(1),
18193
+ id: z26.string().min(1),
18194
+ llmRequestId: z26.string().min(1).nullable(),
18195
+ modelId: z26.string().min(1).nullable(),
18196
+ outputResult: z26.unknown().nullable(),
18197
+ status: z26.enum(["passed", "failed", "errored"]),
18198
+ strictExactMatch: z26.boolean().nullable()
18199
+ });
18200
+ var pathwayRegressionReplayIterationCheckResultsResponseSchema = z26.object({
18201
+ regressionReplayIteration: pathwayRegressionRunResultIterationSchema.extend({
18202
+ checkResults: z26.array(pathwayRegressionReplayCheckResultSchema),
18203
+ regressionReplayId: z26.string().min(1)
18204
+ })
18205
+ });
18206
+ var pathwayRegressionRunResultReplaySchema = z26.object({
18207
+ baselineAgentRunId: z26.string().min(1),
18208
+ baselineAutomationRunId: z26.string().min(1),
18209
+ checks: pathwayRegressionCheckSummarySchema,
18210
+ createdAt: z26.string().min(1),
18211
+ finishedAt: z26.string().min(1).nullable(),
18212
+ id: z26.string().min(1),
18213
+ iterations: z26.array(pathwayRegressionRunResultIterationSchema),
18214
+ status: pathwayRegressionRunStatusSchema
18215
+ });
18216
+ var pathwayRegressionRunResultPathwaySchema = z26.object({
18217
+ contractId: z26.string().min(1),
18218
+ contractPathId: z26.string().min(1).nullable(),
18219
+ label: z26.string().min(1).nullable(),
18220
+ pathwayKey: z26.string().min(1),
18221
+ replays: z26.array(pathwayRegressionRunResultReplaySchema),
18222
+ sortOrder: z26.number().nullable()
18223
+ });
18224
+ var pathwayRegressionRunResultResponseSchema = z26.object({
18225
+ pathways: z26.array(pathwayRegressionRunResultPathwaySchema),
18226
+ regressionRun: z26.object({
18227
+ automationId: z26.string().min(1),
18228
+ candidateAgentVersionId: z26.string().min(1).nullable(),
18229
+ candidateAutomationVersionId: z26.string().min(1),
18230
+ createdAt: z26.string().min(1),
18231
+ finishedAt: z26.string().min(1).nullable(),
18232
+ id: z26.string().min(1),
18233
+ scope: z26.enum(["single_run", "contract_batch", "automation_version"]),
18234
+ status: pathwayRegressionRunStatusSchema,
18235
+ workflowId: z26.string().min(1)
18236
+ })
18237
+ });
17710
18238
  var graphQlResponseSchema = z26.object({
17711
18239
  data: z26.record(z26.string(), z26.unknown()).nullable().optional(),
17712
18240
  errors: z26.array(
@@ -17809,6 +18337,23 @@ function decodeJwtPayload(token) {
17809
18337
  function isOttoAuthorizationToken(token) {
17810
18338
  return decodeJwtPayload(token)?.["iss"] === OTTO_AUTHORIZATION_ISSUER;
17811
18339
  }
18340
+ function buildPathwayRegressionAgentVersionPath({
18341
+ agentVersionId,
18342
+ automationVersionId,
18343
+ leafPath,
18344
+ runsPerPath
18345
+ }) {
18346
+ const path9 = `/pathway-regression/automation-versions/${encodeURIComponent(
18347
+ automationVersionId
18348
+ )}/agent-versions/${encodeURIComponent(agentVersionId)}/${leafPath}`;
18349
+ if (runsPerPath === void 0) {
18350
+ return path9;
18351
+ }
18352
+ const queryParams = new URLSearchParams({
18353
+ runsPerPath: String(runsPerPath)
18354
+ });
18355
+ return `${path9}?${queryParams.toString()}`;
18356
+ }
17812
18357
  function applyAuthenticationHeaders({
17813
18358
  accessToken,
17814
18359
  allowOttoAuthorization,
@@ -18049,6 +18594,111 @@ function createMagicalApiClient({
18049
18594
  throw new CliError("Organization authentications payload was invalid.");
18050
18595
  }
18051
18596
  return parsedResponse.data.authentications;
18597
+ },
18598
+ async previewPathwayRegressionMatchingRuns({
18599
+ accessToken,
18600
+ agentVersionId,
18601
+ automationVersionId,
18602
+ impersonatedOrganizationId,
18603
+ organizationId,
18604
+ runsPerPath
18605
+ }) {
18606
+ const parsedResponse = pathwayRegressionMatchingRunsResponseSchema.safeParse(
18607
+ await fetchJson({
18608
+ accessToken,
18609
+ allowOttoAuthorization: true,
18610
+ ...impersonatedOrganizationId ? { impersonatedOrganizationId } : {},
18611
+ ...organizationId ? { organizationId } : {},
18612
+ path: buildPathwayRegressionAgentVersionPath({
18613
+ agentVersionId,
18614
+ automationVersionId,
18615
+ leafPath: "matching-runs",
18616
+ ...runsPerPath === void 0 ? {} : { runsPerPath }
18617
+ })
18618
+ })
18619
+ );
18620
+ if (!parsedResponse.success) {
18621
+ throw new CliError(
18622
+ "Pathway regression matching-runs payload was invalid."
18623
+ );
18624
+ }
18625
+ return parsedResponse.data;
18626
+ },
18627
+ async startPathwayRegressionAgentVersionRun({
18628
+ accessToken,
18629
+ agentVersionId,
18630
+ automationVersionId,
18631
+ impersonatedOrganizationId,
18632
+ organizationId,
18633
+ runsPerPath
18634
+ }) {
18635
+ const parsedResponse = pathwayRegressionAgentVersionRunResponseSchema.safeParse(
18636
+ await fetchJson({
18637
+ accessToken,
18638
+ allowOttoAuthorization: true,
18639
+ ...impersonatedOrganizationId ? { impersonatedOrganizationId } : {},
18640
+ ...organizationId ? { organizationId } : {},
18641
+ path: buildPathwayRegressionAgentVersionPath({
18642
+ agentVersionId,
18643
+ automationVersionId,
18644
+ leafPath: "run",
18645
+ ...runsPerPath === void 0 ? {} : { runsPerPath }
18646
+ }),
18647
+ init: {
18648
+ method: "POST"
18649
+ }
18650
+ })
18651
+ );
18652
+ if (!parsedResponse.success) {
18653
+ throw new CliError("Pathway regression kickoff payload was invalid.");
18654
+ }
18655
+ return parsedResponse.data;
18656
+ },
18657
+ async getPathwayRegressionRunResult({
18658
+ accessToken,
18659
+ impersonatedOrganizationId,
18660
+ organizationId,
18661
+ regressionRunId
18662
+ }) {
18663
+ const parsedResponse = pathwayRegressionRunResultResponseSchema.safeParse(
18664
+ await fetchJson({
18665
+ accessToken,
18666
+ allowOttoAuthorization: true,
18667
+ ...impersonatedOrganizationId ? { impersonatedOrganizationId } : {},
18668
+ ...organizationId ? { organizationId } : {},
18669
+ path: `/pathway-regression/runs/${encodeURIComponent(
18670
+ regressionRunId
18671
+ )}`
18672
+ })
18673
+ );
18674
+ if (!parsedResponse.success) {
18675
+ throw new CliError("Pathway regression run payload was invalid.");
18676
+ }
18677
+ return parsedResponse.data;
18678
+ },
18679
+ async getPathwayRegressionReplayIterationCheckResults({
18680
+ accessToken,
18681
+ impersonatedOrganizationId,
18682
+ organizationId,
18683
+ regressionReplayIterationId
18684
+ }) {
18685
+ const parsedResponse = pathwayRegressionReplayIterationCheckResultsResponseSchema.safeParse(
18686
+ await fetchJson({
18687
+ accessToken,
18688
+ allowOttoAuthorization: true,
18689
+ ...impersonatedOrganizationId ? { impersonatedOrganizationId } : {},
18690
+ ...organizationId ? { organizationId } : {},
18691
+ path: `/pathway-regression/replay-iterations/${encodeURIComponent(
18692
+ regressionReplayIterationId
18693
+ )}/check-results`
18694
+ })
18695
+ );
18696
+ if (!parsedResponse.success) {
18697
+ throw new CliError(
18698
+ "Pathway regression replay iteration check-results payload was invalid."
18699
+ );
18700
+ }
18701
+ return parsedResponse.data;
18052
18702
  }
18053
18703
  };
18054
18704
  }
@@ -18293,7 +18943,8 @@ function configureCommandPresentation(command) {
18293
18943
  return command;
18294
18944
  }
18295
18945
  function createOperationHelpExamples(operationSpec) {
18296
- const baseCommand = `mgcl ${operationSpec.cli.path.join(" ")}`;
18946
+ const commandPath = operationSpec.cli.path.join(" ");
18947
+ const baseCommand = operationSpec.cli.branchContext === "required" ? `mgcl --branch-id <branch-id> ${commandPath}` : `mgcl ${commandPath}`;
18297
18948
  const requiredOptions = operationSpec.cli.options.filter((optionSpec) => optionSpec.required).map((optionSpec) => {
18298
18949
  if (optionSpec.valueType === "boolean") {
18299
18950
  return `--${optionSpec.flagName}`;
@@ -18313,7 +18964,15 @@ function createOperationHelpExamples(operationSpec) {
18313
18964
  return [
18314
18965
  baseInvocation,
18315
18966
  ...operationSpec.scope === "global" ? [] : [`${baseInvocation} --org <org>`],
18316
- `${baseInvocation} --json`
18967
+ `${baseInvocation} --json`,
18968
+ ...operationSpec.cli.branchContext === "optional" ? [
18969
+ [
18970
+ "mgcl --branch-id <branch-id>",
18971
+ commandPath,
18972
+ ...requiredOptions,
18973
+ "--json"
18974
+ ].join(" ")
18975
+ ] : []
18317
18976
  ];
18318
18977
  }
18319
18978
 
@@ -20213,6 +20872,7 @@ function createWorkosAuthClient({
20213
20872
  }
20214
20873
 
20215
20874
  // src/program.ts
20875
+ var commandBranchContexts = /* @__PURE__ */ new WeakMap();
20216
20876
  function buildCommandOptionProperty(flagName) {
20217
20877
  const [firstSegment, ...remainingSegments] = flagName.split("-");
20218
20878
  return [
@@ -20269,6 +20929,13 @@ function createCliCommanderOption(optionSpec, helpGroup) {
20269
20929
  }
20270
20930
  return nextOption;
20271
20931
  }
20932
+ function parsePositiveIntegerOption(rawValue) {
20933
+ const parsedValue = Number(rawValue);
20934
+ if (!Number.isInteger(parsedValue) || parsedValue < 1) {
20935
+ throw new InvalidArgumentError2("Expected a positive integer.");
20936
+ }
20937
+ return parsedValue;
20938
+ }
20272
20939
  function isRecord5(value) {
20273
20940
  return typeof value === "object" && value !== null && !Array.isArray(value);
20274
20941
  }
@@ -20333,6 +21000,10 @@ function collectOperationVariables(operationSpec, options) {
20333
21000
  return [[optionSpec.inputKey, optionValue]];
20334
21001
  })
20335
21002
  );
21003
+ const { branchId } = options;
21004
+ if (operationSpec.cli.branchContext !== void 0 && typeof branchId === "string") {
21005
+ variables["branchId"] = branchId;
21006
+ }
20336
21007
  return parseOperationVariables(operationSpec, variables);
20337
21008
  }
20338
21009
  function parseOperationVariables(operationSpec, variables) {
@@ -20440,11 +21111,18 @@ async function handleOperationCommand(dependencies, operationSpec, commandOption
20440
21111
  ...state,
20441
21112
  lastUsedOrgId: organization.id
20442
21113
  });
20443
- if (commandOptions.json) {
20444
- writeJsonOutput3(dependencies.io, result);
20445
- return;
21114
+ writeCommandOutput({
21115
+ dependencies,
21116
+ json: commandOptions.json,
21117
+ result
21118
+ });
21119
+ if (operationSpec.operationName === "ViewAutomationReview" && commandOptions["open"] && isRecord5(result) && typeof result["reportUrl"] === "string") {
21120
+ await dependencies.openExternalUrl(result["reportUrl"]).catch((error) => {
21121
+ dependencies.io.error(
21122
+ `Warning: Failed to open the automation review in the default browser: ${getErrorMessage(error)}`
21123
+ );
21124
+ });
20446
21125
  }
20447
- dependencies.io.info(formatHumanReadableOutput(result));
20448
21126
  }
20449
21127
  function getOperation(operationName) {
20450
21128
  const operationSpec = operationSpecs.find(
@@ -20779,6 +21457,217 @@ async function handleNangoAuthsListCommand(dependencies, options) {
20779
21457
  result: authentications
20780
21458
  });
20781
21459
  }
21460
+ function summarizePathwayRegressionPreview(result) {
21461
+ return {
21462
+ automationVersionId: result.automationVersionId,
21463
+ agentVersionId: result.agentVersionId,
21464
+ contractId: result.contractId,
21465
+ pathwayCount: result.paths.length,
21466
+ selectedReplayCount: result.paths.reduce(
21467
+ (sum, pathway) => sum + pathway.runs.length,
21468
+ 0
21469
+ ),
21470
+ paths: result.paths.map((pathway) => ({
21471
+ sortOrder: pathway.sortOrder,
21472
+ label: pathway.label,
21473
+ pathwayKey: pathway.pathwayKey,
21474
+ matchingRunCount: pathway.runs.length,
21475
+ runs: pathway.runs.map((run) => ({
21476
+ agentRunId: run.agentRunId,
21477
+ automationRunId: run.automationRunId,
21478
+ finishedAt: run.finishedAt,
21479
+ stepCount: run.stepCount
21480
+ }))
21481
+ }))
21482
+ };
21483
+ }
21484
+ function summarizePathwayRegressionKickoff(result) {
21485
+ if ("contractWorkflowId" in result) {
21486
+ return {
21487
+ status: result.status,
21488
+ contractGenerationStatus: result.contractGenerationStatus,
21489
+ contractWorkflowId: result.contractWorkflowId,
21490
+ regressionRunId: result.regressionRunId,
21491
+ workflowId: result.workflowId,
21492
+ selectedReplayCount: result.selectedReplayCount,
21493
+ automationVersionId: result.automationVersionId,
21494
+ agentVersionId: result.agentVersionId
21495
+ };
21496
+ }
21497
+ return {
21498
+ regressionRunId: result.regressionRunId,
21499
+ workflowId: result.workflowId,
21500
+ status: result.status,
21501
+ selectedReplayCount: result.selectedReplayCount,
21502
+ automationVersionId: result.automationVersionId,
21503
+ agentVersionId: result.agentVersionId,
21504
+ contractId: result.contractId,
21505
+ baselineAutomationVersionId: result.baselineAutomationVersionId,
21506
+ baselineAgentVersionId: result.baselineAgentVersionId,
21507
+ baselineContractId: result.baselineContractId,
21508
+ candidateContractId: result.candidateContractId,
21509
+ paths: result.paths.map((pathway) => ({
21510
+ sortOrder: pathway.candidate?.sortOrder ?? pathway.baseline?.sortOrder ?? null,
21511
+ baselineLabel: pathway.baseline?.label ?? null,
21512
+ candidateLabel: pathway.candidate?.label ?? null,
21513
+ pathwayKey: pathway.pathwayKey,
21514
+ selectedRunCount: pathway.selectedRunCount,
21515
+ status: pathway.status,
21516
+ isInLatestPublishedBaseline: pathway.isInLatestPublishedBaseline ?? null,
21517
+ lastSeenPublishedAutomationVersionId: pathway.lastSeenPublishedAutomationVersionId ?? null,
21518
+ lastSeenPublishedAgentVersionId: pathway.lastSeenPublishedAgentVersionId ?? null,
21519
+ lastSeenPublishedSequence: pathway.lastSeenPublishedSequence ?? null
21520
+ }))
21521
+ };
21522
+ }
21523
+ function summarizePathwayRegressionResult(result) {
21524
+ const replayCount = result.pathways.reduce(
21525
+ (sum, pathway) => sum + pathway.replays.length,
21526
+ 0
21527
+ );
21528
+ return {
21529
+ regressionRunId: result.regressionRun.id,
21530
+ workflowId: result.regressionRun.workflowId,
21531
+ scope: result.regressionRun.scope,
21532
+ status: result.regressionRun.status,
21533
+ finishedAt: result.regressionRun.finishedAt,
21534
+ pathwayCount: result.pathways.length,
21535
+ replayCount,
21536
+ pathways: result.pathways.map((pathway) => ({
21537
+ sortOrder: pathway.sortOrder,
21538
+ label: pathway.label ?? pathway.pathwayKey,
21539
+ pathwayKey: pathway.pathwayKey,
21540
+ replays: pathway.replays.map((replay) => ({
21541
+ regressionReplayId: replay.id,
21542
+ baselineAgentRunId: replay.baselineAgentRunId,
21543
+ baselineAutomationRunId: replay.baselineAutomationRunId,
21544
+ status: replay.status,
21545
+ checks: replay.checks,
21546
+ nonPassingIterations: replay.iterations.filter((iteration) => iteration.status !== "passed").map((iteration) => ({
21547
+ regressionReplayIterationId: iteration.id,
21548
+ sequence: iteration.sequence,
21549
+ status: iteration.status,
21550
+ expectedToolName: iteration.expectedToolName,
21551
+ observedToolName: iteration.observedToolName
21552
+ }))
21553
+ }))
21554
+ }))
21555
+ };
21556
+ }
21557
+ function summarizePathwayRegressionReplayIterationCheckResults(result) {
21558
+ const { regressionReplayIteration } = result;
21559
+ return {
21560
+ regressionReplayId: regressionReplayIteration.regressionReplayId,
21561
+ regressionReplayIterationId: regressionReplayIteration.id,
21562
+ sequence: regressionReplayIteration.sequence,
21563
+ status: regressionReplayIteration.status,
21564
+ expectedToolName: regressionReplayIteration.expectedToolName,
21565
+ observedToolName: regressionReplayIteration.observedToolName,
21566
+ checkCount: regressionReplayIteration.checkResults.length,
21567
+ checks: regressionReplayIteration.checkResults.map((checkResult) => ({
21568
+ attemptIndex: checkResult.attemptIndex,
21569
+ status: checkResult.status,
21570
+ expectedToolName: checkResult.expectedToolName,
21571
+ actualToolName: checkResult.actualToolName,
21572
+ outputResult: checkResult.outputResult
21573
+ }))
21574
+ };
21575
+ }
21576
+ async function handlePathwayRegressionPreviewCommand(dependencies, options) {
21577
+ const { accessToken, impersonatedOrganizationId, organization, state } = await withSelectedOrganizationAndAccessToken({ dependencies, options });
21578
+ const previewPathwayRegressionMatchingRuns = requireApiClientMethod(
21579
+ dependencies.apiClient,
21580
+ "previewPathwayRegressionMatchingRuns"
21581
+ );
21582
+ const result = await previewPathwayRegressionMatchingRuns({
21583
+ accessToken,
21584
+ agentVersionId: options.agentVersionId,
21585
+ automationVersionId: options.automationVersionId,
21586
+ ...impersonatedOrganizationId ? { impersonatedOrganizationId } : {},
21587
+ organizationId: organization.id,
21588
+ ...options.runsPerPath === void 0 ? {} : { runsPerPath: options.runsPerPath }
21589
+ });
21590
+ await saveLastUsedOrganization({
21591
+ dependencies,
21592
+ organizationId: organization.id,
21593
+ state
21594
+ });
21595
+ writeCommandOutput({
21596
+ dependencies,
21597
+ json: options.json,
21598
+ result: options.json ? result : summarizePathwayRegressionPreview(result)
21599
+ });
21600
+ }
21601
+ async function handlePathwayRegressionRunCommand(dependencies, options) {
21602
+ const { accessToken, impersonatedOrganizationId, organization, state } = await withSelectedOrganizationAndAccessToken({ dependencies, options });
21603
+ const startPathwayRegressionAgentVersionRun = requireApiClientMethod(
21604
+ dependencies.apiClient,
21605
+ "startPathwayRegressionAgentVersionRun"
21606
+ );
21607
+ const result = await startPathwayRegressionAgentVersionRun({
21608
+ accessToken,
21609
+ agentVersionId: options.agentVersionId,
21610
+ automationVersionId: options.automationVersionId,
21611
+ ...impersonatedOrganizationId ? { impersonatedOrganizationId } : {},
21612
+ organizationId: organization.id
21613
+ });
21614
+ await saveLastUsedOrganization({
21615
+ dependencies,
21616
+ organizationId: organization.id,
21617
+ state
21618
+ });
21619
+ writeCommandOutput({
21620
+ dependencies,
21621
+ json: options.json,
21622
+ result: options.json ? result : summarizePathwayRegressionKickoff(result)
21623
+ });
21624
+ }
21625
+ async function handlePathwayRegressionResultsCommand(dependencies, options) {
21626
+ const { accessToken, impersonatedOrganizationId, organization, state } = await withSelectedOrganizationAndAccessToken({ dependencies, options });
21627
+ const getPathwayRegressionRunResult = requireApiClientMethod(
21628
+ dependencies.apiClient,
21629
+ "getPathwayRegressionRunResult"
21630
+ );
21631
+ const result = await getPathwayRegressionRunResult({
21632
+ accessToken,
21633
+ regressionRunId: options.regressionRunId,
21634
+ ...impersonatedOrganizationId ? { impersonatedOrganizationId } : {},
21635
+ organizationId: organization.id
21636
+ });
21637
+ await saveLastUsedOrganization({
21638
+ dependencies,
21639
+ organizationId: organization.id,
21640
+ state
21641
+ });
21642
+ writeCommandOutput({
21643
+ dependencies,
21644
+ json: options.json,
21645
+ result: options.json ? result : summarizePathwayRegressionResult(result)
21646
+ });
21647
+ }
21648
+ async function handlePathwayRegressionCheckResultsCommand(dependencies, options) {
21649
+ const { accessToken, impersonatedOrganizationId, organization, state } = await withSelectedOrganizationAndAccessToken({ dependencies, options });
21650
+ const getPathwayRegressionReplayIterationCheckResults = requireApiClientMethod(
21651
+ dependencies.apiClient,
21652
+ "getPathwayRegressionReplayIterationCheckResults"
21653
+ );
21654
+ const result = await getPathwayRegressionReplayIterationCheckResults({
21655
+ accessToken,
21656
+ regressionReplayIterationId: options.regressionReplayIterationId,
21657
+ ...impersonatedOrganizationId ? { impersonatedOrganizationId } : {},
21658
+ organizationId: organization.id
21659
+ });
21660
+ await saveLastUsedOrganization({
21661
+ dependencies,
21662
+ organizationId: organization.id,
21663
+ state
21664
+ });
21665
+ writeCommandOutput({
21666
+ dependencies,
21667
+ json: options.json,
21668
+ result: options.json ? result : summarizePathwayRegressionReplayIterationCheckResults(result)
21669
+ });
21670
+ }
20782
21671
  async function resolveDirectAccessTokenOrganizationId({
20783
21672
  dependencies
20784
21673
  }) {
@@ -20857,6 +21746,7 @@ function addRegistryOperationCommand({
20857
21746
  configureOperationalCommand(legacyAliasCommand, dependencies, operationSpec);
20858
21747
  }
20859
21748
  function configureOperationalCommand(command, dependencies, operationSpec) {
21749
+ commandBranchContexts.set(command, operationSpec.cli.branchContext);
20860
21750
  command.description(operationSpec.cli.description);
20861
21751
  if (operationSpec.scope !== "global") {
20862
21752
  command.addOption(
@@ -20942,7 +21832,12 @@ function createDefaultDependencies() {
20942
21832
  function buildProgram(dependencies) {
20943
21833
  const program2 = configureCommandPresentation(
20944
21834
  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(
21835
+ ).addOption(new Option2("--json", "Render JSON output.")).addOption(
21836
+ new Option2(
21837
+ "--branch-id <id>",
21838
+ "Target a supported automation command at one branch; omit it to target main."
21839
+ )
21840
+ ).version(CLI_VERSION, "--version", `Display mgcl version (${CLI_VERSION}).`).addOption(
20946
21841
  new Option2(
20947
21842
  "--update",
20948
21843
  "Update mgcl to the latest published npm release."
@@ -20960,6 +21855,18 @@ ${formatExamples("Quick start", [
20960
21855
 
20961
21856
  ${formatOutputModesNote()}`
20962
21857
  );
21858
+ program2.hook("preAction", (_thisCommand, actionCommand) => {
21859
+ const options = actionCommand.optsWithGlobals();
21860
+ const branchContext = commandBranchContexts.get(actionCommand);
21861
+ if (options.branchId && branchContext === void 0) {
21862
+ throw new CliError(
21863
+ `Command "${actionCommand.name()}" does not support --branch-id.`
21864
+ );
21865
+ }
21866
+ if (!options.branchId && branchContext === "required") {
21867
+ throw new CliError("--branch-id is required for this command.");
21868
+ }
21869
+ });
20963
21870
  program2.action(async function() {
20964
21871
  const options = this.optsWithGlobals();
20965
21872
  if (options.update) {
@@ -21004,6 +21911,88 @@ ${formatExamples("Examples", [
21004
21911
  );
21005
21912
  });
21006
21913
  program2.addCommand(orgCommand);
21914
+ const pathwayRegressionCommand = configureCommandPresentation(
21915
+ new Command2("pathway-regression").description(
21916
+ "Preview, start, and inspect pathway regression runs."
21917
+ )
21918
+ ).helpGroup("Workspace:").addHelpText(
21919
+ "after",
21920
+ `
21921
+ ${formatExamples("Examples", [
21922
+ "mgcl pathway-regression preview --automation-version-id <id> --agent-version-id <id>",
21923
+ "mgcl pathway-regression run --automation-version-id <id> --agent-version-id <id>",
21924
+ "mgcl pathway-regression results --regression-run-id <id>",
21925
+ "mgcl pathway-regression check-results --regression-replay-iteration-id <id>"
21926
+ ])}`
21927
+ );
21928
+ const addPathwayRegressionAgentVersionOptions = (command) => command.addOption(
21929
+ new Option2(
21930
+ "--org <org>",
21931
+ "Organization ID or exact organization name to use."
21932
+ ).helpGroup("Shared options:")
21933
+ ).addOption(
21934
+ new Option2(
21935
+ "--automation-version-id <id>",
21936
+ "Automation version to test against."
21937
+ ).helpGroup("Pathway regression options:").makeOptionMandatory(true)
21938
+ ).addOption(
21939
+ new Option2("--agent-version-id <id>", "Agent version to test.").helpGroup("Pathway regression options:").makeOptionMandatory(true)
21940
+ );
21941
+ const addPathwayRegressionPreviewOptions = (command) => addPathwayRegressionAgentVersionOptions(command).addOption(
21942
+ new Option2(
21943
+ "--runs-per-path <count>",
21944
+ "Number of historical runs to use per pathway. Defaults to the service value."
21945
+ ).helpGroup("Pathway regression options:").argParser(parsePositiveIntegerOption)
21946
+ );
21947
+ addPathwayRegressionPreviewOptions(
21948
+ pathwayRegressionCommand.command("preview").description("Show which historical runs are available per pathway.")
21949
+ ).action(async function() {
21950
+ await handlePathwayRegressionPreviewCommand(
21951
+ dependencies,
21952
+ this.optsWithGlobals()
21953
+ );
21954
+ });
21955
+ addPathwayRegressionAgentVersionOptions(
21956
+ pathwayRegressionCommand.command("run").description("Start regression replay for an agent version.")
21957
+ ).action(async function() {
21958
+ await handlePathwayRegressionRunCommand(
21959
+ dependencies,
21960
+ this.optsWithGlobals()
21961
+ );
21962
+ });
21963
+ pathwayRegressionCommand.command("results").description("Read a pathway regression run result.").addOption(
21964
+ new Option2(
21965
+ "--org <org>",
21966
+ "Organization ID or exact organization name to use."
21967
+ ).helpGroup("Shared options:")
21968
+ ).addOption(
21969
+ new Option2(
21970
+ "--regression-run-id <id>",
21971
+ "Pathway regression run ID to inspect."
21972
+ ).helpGroup("Pathway regression options:").makeOptionMandatory(true)
21973
+ ).action(async function() {
21974
+ await handlePathwayRegressionResultsCommand(
21975
+ dependencies,
21976
+ this.optsWithGlobals()
21977
+ );
21978
+ });
21979
+ pathwayRegressionCommand.command("check-results").description("Read detailed check attempts for one replay iteration.").addOption(
21980
+ new Option2(
21981
+ "--org <org>",
21982
+ "Organization ID or exact organization name to use."
21983
+ ).helpGroup("Shared options:")
21984
+ ).addOption(
21985
+ new Option2(
21986
+ "--regression-replay-iteration-id <id>",
21987
+ "Pathway regression replay iteration ID to inspect."
21988
+ ).helpGroup("Pathway regression options:").makeOptionMandatory(true)
21989
+ ).action(async function() {
21990
+ await handlePathwayRegressionCheckResultsCommand(
21991
+ dependencies,
21992
+ this.optsWithGlobals()
21993
+ );
21994
+ });
21995
+ program2.addCommand(pathwayRegressionCommand);
21007
21996
  const nangoCommand = configureCommandPresentation(
21008
21997
  new Command2("nango").description(
21009
21998
  "Inspect Nango integrations and org-scoped authentications."