@getmagical/cli 0.2.1 → 0.2.3

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
@@ -7245,9 +7245,12 @@ function resolveApiDetails({ appError, statusCode }) {
7245
7245
  if (!shouldExposeMessage({ appError, statusCode })) {
7246
7246
  return void 0;
7247
7247
  }
7248
+ const rawDetails = toUserFacingDetailsValue(appError.details, 4);
7249
+ const serializedDetails = rawDetails && typeof rawDetails === "object" && !Array.isArray(rawDetails) && Object.keys(rawDetails).length > 0 ? rawDetails : void 0;
7248
7250
  const zodIssues = getZodIssuesFromCause(appError.cause);
7249
7251
  if (zodIssues && zodIssues.length > 0) {
7250
7252
  return {
7253
+ ...serializedDetails,
7251
7254
  validationErrors: zodIssues.map((issue) => ({
7252
7255
  path: Array.isArray(issue.path) ? issue.path.map(String).join(".") : "",
7253
7256
  message: typeof issue.message === "string" ? issue.message : "Invalid value",
@@ -7255,11 +7258,7 @@ function resolveApiDetails({ appError, statusCode }) {
7255
7258
  }))
7256
7259
  };
7257
7260
  }
7258
- const rawDetails = toUserFacingDetailsValue(appError.details, 4);
7259
- if (rawDetails && typeof rawDetails === "object" && !Array.isArray(rawDetails) && Object.keys(rawDetails).length > 0) {
7260
- return rawDetails;
7261
- }
7262
- return void 0;
7261
+ return serializedDetails;
7263
7262
  }
7264
7263
  function getGraphQLErrorCodeFromAppErrorCode(code) {
7265
7264
  if (code === 400) {
@@ -12663,15 +12662,15 @@ var baseToolDeclarations = {
12663
12662
  },
12664
12663
  updateStoreValues: {
12665
12664
  id: "updateStoreValues",
12666
- description: "Update values in the automation store. Set scalar leaf paths, append one item or a list of items to array paths, replace complete arrays, and clear scalar or array paths in a single mutation.",
12665
+ description: "Update values in the automation store. Set complete scalar or Object values, append one item or a list of items to array paths, replace complete arrays, and clear supported scalar, Object, or array paths in a single mutation.",
12667
12666
  parameters: z12.object({
12668
12667
  [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS,
12669
12668
  updates: z12.array(z12.object({
12670
- path: z12.string().min(1).describe("Scalar leaf path to set or array path to append to or replace, such as patient.name or documents."),
12671
- arrayMode: z12.enum(["append", "appendList", "replace"]).optional().describe("Array mutation behavior. Omit or use append to add one item, use appendList to add every item in the supplied list, or use replace to set the complete array. Do not use this for scalar paths."),
12672
- value: z12.json().describe("Concrete JSON value for this update. Scalar paths receive this value. Array append updates receive one item, appendList updates receive a list of items, and replacements receive the complete list.")
12669
+ path: z12.string().min(1).describe("Scalar or Object path to set, or array path to append to or replace, such as patient.name, patient, or documents. The root Store path is not supported."),
12670
+ arrayMode: z12.enum(["append", "appendList", "replace"]).optional().describe("Array mutation behavior. Omit or use append to add one item, use appendList to add every item in the supplied list, or use replace to set the complete array. Do not use this for scalar or Object paths."),
12671
+ value: z12.json().describe("Concrete JSON value for this update. Scalar and Object paths receive the complete value. Array append updates receive one item, appendList updates receive a list of items, and replacements receive the complete list.")
12673
12672
  })).optional().describe("Store values to update. Omit or pass an empty array when only clearing values."),
12674
- clears: z12.array(z12.string().min(1)).optional().describe("Scalar leaf or array store paths to clear. Clearing an array writes an empty list. Omit or pass an empty array when only updating values.")
12673
+ clears: z12.array(z12.string().min(1)).optional().describe("Optional scalar or Object paths, or array Store paths, to clear. Clearing an array writes an empty list. Omit or pass an empty array when only updating values.")
12675
12674
  }).superRefine((value, context) => {
12676
12675
  const updates = value.updates ?? [];
12677
12676
  const clears = value.clears ?? [];
@@ -13440,7 +13439,7 @@ import { z as z16 } from "zod";
13440
13439
 
13441
13440
  // ../common/dist/src/zod-schemas/output-store-binding.schema.js
13442
13441
  import { z as z15 } from "zod";
13443
- var outputStorePathSchema = z15.string().regex(/^store\.[$A-Z_a-z][\w$]*(?:\.[$A-Z_a-z][\w$]*)*$/u, "Data Store destination must be a fully qualified path such as store.patient.name.");
13442
+ var outputStorePathSchema = z15.string().regex(/^store\.[^\s.]+(?:\.[^\s.]+)*$/u, "Data Store destination must be a fully qualified path such as store.patient.name.");
13444
13443
 
13445
13444
  // ../common/dist/src/zod-schemas/api-tool.schema.js
13446
13445
  var methodsWithBody = new Set(ApiMethodsWithBody);
@@ -13481,7 +13480,7 @@ var apiOutputStorePathSchema = outputStorePathSchema.describe("Fully qualified D
13481
13480
  var apiOutputStoreBindingShape = {
13482
13481
  jmesPath: z16.string().trim().min(1, "JMESPath is required. Use @ to select the entire response.").describe("JMESPath expression evaluated against the raw API response. Use @ to select the entire response."),
13483
13482
  storePath: apiOutputStorePathSchema,
13484
- arrayMode: z16.enum(["append", "appendList", "replace"]).optional().describe("Required for newly authored array destinations: append adds exactly one item, appendList adds multiple items, and replace sets the complete list. Omit for scalar destinations. Legacy omitted array modes still append at runtime.")
13483
+ arrayMode: z16.enum(["append", "appendList", "replace"]).optional().describe("Required for newly authored array destinations: append adds exactly one item, appendList adds multiple items, and replace sets the complete list. Omit for scalar and Object destinations; Object values replace the complete object. Legacy omitted array modes still append at runtime.")
13485
13484
  };
13486
13485
  var apiOutputStoreBindingObjectSchema = z16.object(apiOutputStoreBindingShape);
13487
13486
  var apiOutputStoreBindingAuthoringSchema = z16.object(apiOutputStoreBindingShape).strict();
@@ -13824,7 +13823,7 @@ var outputStoreSourcePathRegex = /^[$A-Z_a-z][\w$]*(?:\.[$A-Z_a-z][\w$]*)*$/u;
13824
13823
  var outputStoreBindingSchema = z19.object({
13825
13824
  sourcePath: z19.string().refine((sourcePath) => sourcePath === "$" || outputStoreSourcePathRegex.test(sourcePath), 'Output source path must be "$" or a dot path such as patient.name.').describe("Dot path of the node output value to write."),
13826
13825
  storePath: outputStorePathSchema.describe("Fully qualified Data Store path that receives the output."),
13827
- arrayMode: z19.enum(["append", "appendList", "replace"]).optional().describe("Required for newly authored array destinations: append adds exactly one item, appendList adds multiple items, and replace sets the complete list. Omit for scalar destinations. Legacy omitted array modes still append at runtime.")
13826
+ arrayMode: z19.enum(["append", "appendList", "replace"]).optional().describe("Required for newly authored array destinations: append adds exactly one item, appendList adds multiple items, and replace sets the complete list. Omit for scalar and Object destinations; Object values replace the complete object. Legacy omitted array modes still append at runtime.")
13828
13827
  }).describe("Maps one node output value to one Data Store destination.");
13829
13828
  function validateUniqueOutputStoreBindings(bindings, ctx) {
13830
13829
  const sourcePaths = /* @__PURE__ */ new Set();
@@ -13976,12 +13975,67 @@ var draftAgentConfigSchema = z19.preprocess((data) => {
13976
13975
  }, draftAgentConfigSchemaUnion).describe("Draft agent configuration. Matches authored validation for most agent types, but allows incomplete decision agents during draft saves.");
13977
13976
  var DEFAULT_AGENT_CONFIG = agentConfigSchema.parse({});
13978
13977
 
13979
- // ../common/dist/src/zod-schemas/automation-run-config.schema.js
13978
+ // ../common/dist/src/zod-schemas/automation-store-migration-analyzer.schema.js
13980
13979
  import { z as z20 } from "zod";
13981
- var automationRunResolvedRunSettingsSchema = z20.object({
13980
+ var automationStoreMigrationMappingSchema = z20.object({
13981
+ sourceAutomationId: z20.string().uuid(),
13982
+ sourceAgentId: z20.string().uuid().optional(),
13983
+ sourceKind: z20.enum(["input", "output", "sharedInput"]),
13984
+ sourceKey: z20.string().min(1),
13985
+ logicalValueId: z20.string().min(1).optional(),
13986
+ outputBindingSourcePath: z20.string().min(1).optional(),
13987
+ handling: z20.enum(["store", "keepLocal", "remove"]),
13988
+ reason: z20.string().min(1),
13989
+ targetStorePath: z20.string().min(1).optional(),
13990
+ population: z20.enum([
13991
+ "default",
13992
+ "initialStore",
13993
+ "outputStoreBinding",
13994
+ "updateStoreValues"
13995
+ ]).optional(),
13996
+ writerAgentId: z20.string().uuid().optional(),
13997
+ isWorkItemIdentity: z20.boolean().optional(),
13998
+ conversion: z20.string().min(1).optional()
13999
+ });
14000
+ var automationStoreMigrationWritePolicySchema = z20.object({
14001
+ automationId: z20.string().uuid(),
14002
+ path: z20.string().min(1),
14003
+ writerAgentIds: z20.array(z20.string().uuid()).min(1),
14004
+ coordination: z20.enum([
14005
+ "singleWriter",
14006
+ "mutuallyExclusiveBranches",
14007
+ "orderedScalarOverwrite",
14008
+ "disjointArrayItems"
14009
+ ]),
14010
+ arrayRetryStrategy: z20.enum(["notApplicable", "readBeforeAppend"]),
14011
+ rationale: z20.string().min(1)
14012
+ });
14013
+ var automationStoreMigrationComparisonVersionSchema = z20.object({
14014
+ automationId: z20.string().uuid(),
14015
+ automationVersionId: z20.string().uuid(),
14016
+ role: z20.enum(["beforeMigration", "afterMigration"]),
14017
+ slotLifecycle: z20.enum(["existing", "introduced"]).default("existing"),
14018
+ slot: z20.string().min(1)
14019
+ });
14020
+ var automationStoreMigrationComparisonSchema = z20.object({
14021
+ versions: z20.array(automationStoreMigrationComparisonVersionSchema).min(1).max(40)
14022
+ });
14023
+ var automationStoreMigrationAnalyzerInputSchema = z20.object({
14024
+ mode: z20.enum(["audit", "compare", "auditRuntimeEvidence"]).describe("audit reads current drafts; compare reads exact saved versions; auditRuntimeEvidence reads only caller-supplied existing runs and their exact saved versions."),
14025
+ automationIds: z20.array(z20.string().uuid()).max(20).default([]).describe("Starting draft automation IDs for audit. The analyzer follows authored queue targets within a bounded organization-scoped traversal."),
14026
+ comparison: automationStoreMigrationComparisonSchema.nullable().default(null).describe("Exact before/after saved-version pairs for compare. Introduced slots require only an afterMigration version."),
14027
+ mappings: z20.array(automationStoreMigrationMappingSchema).default([]),
14028
+ storeWritePolicies: z20.array(automationStoreMigrationWritePolicySchema).max(100).default([]),
14029
+ runIds: z20.array(z20.string().uuid()).max(20).default([]).describe("Existing run IDs to inspect only in auditRuntimeEvidence mode. The analyzer never creates or starts runs."),
14030
+ workItem: z20.string().default("").describe("Optional name for the business work item being migrated.")
14031
+ });
14032
+
14033
+ // ../common/dist/src/zod-schemas/automation-run-config.schema.js
14034
+ import { z as z21 } from "zod";
14035
+ var automationRunResolvedRunSettingsSchema = z21.object({
13982
14036
  environmentOptions: runSettingsEnvironmentOptionsSchema.describe("Canonical run-settings-owned environment settings snapshotted onto the automation run when it starts in runSettings mode. Agent-owned fields such as startingUrl and maxMediaToIncludeInMemory are intentionally ignored at runtime."),
13983
14037
  resourcePools: resourcePoolsSchema.describe("Canonical run-settings-owned resource pools snapshotted onto the automation run when it starts in runSettings mode. Slot assignment and queue status use this only when resolvedRunSettingsSource is runSettings."),
13984
- skipBrowserDebuggerPauses: z20.boolean().optional().describe("Canonical run-settings-owned browser session startup setting snapshotted onto the automation run when it starts in runSettings mode.")
14038
+ skipBrowserDebuggerPauses: z21.boolean().optional().describe("Canonical run-settings-owned browser session startup setting snapshotted onto the automation run when it starts in runSettings mode.")
13985
14039
  });
13986
14040
  var CONSISTENCY_CHECK_COUNT_MAX = 50;
13987
14041
  var NETWORK_TRAFFIC_CAPTURE_RECORD_MODES = [
@@ -13989,18 +14043,18 @@ var NETWORK_TRAFFIC_CAPTURE_RECORD_MODES = [
13989
14043
  "explicit"
13990
14044
  ];
13991
14045
  var DEFAULT_NETWORK_TRAFFIC_CAPTURE_RECORD_MODE = "implicit";
13992
- var networkTrafficCaptureSchema = z20.discriminatedUnion("mode", [
13993
- z20.object({
13994
- mode: z20.literal("record"),
13995
- recordMode: z20.enum(NETWORK_TRAFFIC_CAPTURE_RECORD_MODES).optional().default(DEFAULT_NETWORK_TRAFFIC_CAPTURE_RECORD_MODE).describe("Whether this recording was created implicitly by automation infrastructure or explicitly requested by the user. Explicit recordings are retained longer.")
14046
+ var networkTrafficCaptureSchema = z21.discriminatedUnion("mode", [
14047
+ z21.object({
14048
+ mode: z21.literal("record"),
14049
+ recordMode: z21.enum(NETWORK_TRAFFIC_CAPTURE_RECORD_MODES).optional().default(DEFAULT_NETWORK_TRAFFIC_CAPTURE_RECORD_MODE).describe("Whether this recording was created implicitly by automation infrastructure or explicitly requested by the user. Explicit recordings are retained longer.")
13996
14050
  }).describe("Record network traffic for this run. The recording ID is generated from the automation run ID."),
13997
- z20.object({
13998
- mode: z20.literal("replay"),
13999
- recordingId: z20.uuid().describe("Recording ID from a previous record run in the same organization.")
14051
+ z21.object({
14052
+ mode: z21.literal("replay"),
14053
+ recordingId: z21.uuid().describe("Recording ID from a previous record run in the same organization.")
14000
14054
  }).describe("Replay network traffic from a previous recording.")
14001
14055
  ]).describe("Optional network traffic capture mode for this run. Applies to browser provider traffic and supported agent tool HTTP traffic, including API tool calls and provider-authenticated helper requests.");
14002
- var automationRunSlaTypeSchema = z20.enum(["all"]);
14003
- var automationRunSlaTimestampSchema = z20.iso.datetime();
14056
+ var automationRunSlaTypeSchema = z21.enum(["all"]);
14057
+ var automationRunSlaTimestampSchema = z21.iso.datetime();
14004
14058
  function refineAutomationRunSlaTimestampOrder(sla, ctx) {
14005
14059
  const startedAtMs = Date.parse(sla.startedAt);
14006
14060
  const breachesAtMs = Date.parse(sla.breachesAt);
@@ -14030,31 +14084,31 @@ function refineAutomationRunSlaTimestampOrder(sla, ctx) {
14030
14084
  });
14031
14085
  }
14032
14086
  }
14033
- var automationRunSlaSchema = z20.object({
14087
+ var automationRunSlaSchema = z21.object({
14034
14088
  startedAt: automationRunSlaTimestampSchema.describe("ISO timestamp when SLA tracking started for this run."),
14035
14089
  highRiskAt: automationRunSlaTimestampSchema.optional().describe("Optional ISO timestamp when this run should be considered at high risk of breaching its SLA."),
14036
14090
  breachesAt: automationRunSlaTimestampSchema.describe("ISO timestamp when this run breaches its SLA."),
14037
14091
  type: automationRunSlaTypeSchema.optional().default("all").describe("SLA policy type that applies to this automation run.")
14038
14092
  }).superRefine(refineAutomationRunSlaTimestampOrder).describe("Optional service-level timing metadata for queueing and runtime consumers of this automation run.");
14039
- var automationRunConfigBaseSchema = z20.object({
14040
- approvalMode: z20.enum(["HUMAN_APPROVAL", "OFF"]).default("OFF"),
14041
- consistencyCheckCount: z20.number().int().nonnegative().max(CONSISTENCY_CHECK_COUNT_MAX).nullable().default(null),
14042
- settingsSourceAgentId: z20.uuid().nullable().optional().describe("Optional provenance/debug field recording which top-level agent supplied canonical run settings when the run started. Runtime consumers must not use this as a live pointer once resolvedRunSettingsSource has been decided."),
14043
- startInTakeOverMode: z20.boolean().default(false).describe("When true, create and prepare the remote session, then pause until a human manually starts the agent."),
14044
- captureActions: z20.boolean().default(false).describe("When true, attach an action recording while a draft run is paused in takeover mode."),
14045
- runDraftQueuedAgents: z20.boolean().optional().describe("Draft-run-only option. When false, queue-agent actions in the draft run report success without starting downstream queued draft child runs. Omit or true preserves queueing."),
14046
- allowPointOfNoReturnOverride: z20.boolean().optional().describe("Internal rerun authorization. When true, the rerun and its queued descendants may proceed past a point-of-no-return crossing owned by an earlier run."),
14047
- pointOfNoReturnGateEnabled: z20.literal(true).optional().describe("Infrastructure-owned rollout marker. PONR is enforced only for run trees created after the gate rollout."),
14093
+ var automationRunConfigBaseSchema = z21.object({
14094
+ approvalMode: z21.enum(["HUMAN_APPROVAL", "OFF"]).default("OFF"),
14095
+ consistencyCheckCount: z21.number().int().nonnegative().max(CONSISTENCY_CHECK_COUNT_MAX).nullable().default(null),
14096
+ settingsSourceAgentId: z21.uuid().nullable().optional().describe("Optional provenance/debug field recording which top-level agent supplied canonical run settings when the run started. Runtime consumers must not use this as a live pointer once resolvedRunSettingsSource has been decided."),
14097
+ startInTakeOverMode: z21.boolean().default(false).describe("When true, create and prepare the remote session, then pause until a human manually starts the agent."),
14098
+ captureActions: z21.boolean().default(false).describe("When true, attach an action recording while a draft run is paused in takeover mode."),
14099
+ runDraftQueuedAgents: z21.boolean().optional().describe("Draft-run-only option. When false, queue-agent actions in the draft run report success without starting downstream queued draft child runs. Omit or true preserves queueing."),
14100
+ allowPointOfNoReturnOverride: z21.boolean().optional().describe("Internal rerun authorization. When true, the rerun and its queued descendants may proceed past a point-of-no-return crossing owned by an earlier run."),
14101
+ pointOfNoReturnGateEnabled: z21.literal(true).optional().describe("Infrastructure-owned rollout marker. PONR is enforced only for run trees created after the gate rollout."),
14048
14102
  sla: automationRunSlaSchema.optional(),
14049
14103
  networkTrafficCapture: networkTrafficCaptureSchema.optional(),
14050
- networkTrafficCaptureExplicitlyDisabled: z20.literal(true).optional().describe("Infrastructure-owned marker indicating that network traffic capture was explicitly disabled for this run. When present, runtime policy resolution must not enable capture."),
14051
- implicitNetworkTrafficRecordingDecision: z20.object({
14052
- enabled: z20.boolean()
14104
+ networkTrafficCaptureExplicitlyDisabled: z21.literal(true).optional().describe("Infrastructure-owned marker indicating that network traffic capture was explicitly disabled for this run. When present, runtime policy resolution must not enable capture."),
14105
+ implicitNetworkTrafficRecordingDecision: z21.object({
14106
+ enabled: z21.boolean()
14053
14107
  }).optional().describe("Infrastructure-owned snapshot of the implicit network traffic recording flag decision. Runtime retries use this to avoid re-evaluating LaunchDarkly for the same run."),
14054
14108
  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."),
14055
14109
  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."),
14056
14110
  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."),
14057
- resolvedRunSettingsSource: z20.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.")
14111
+ resolvedRunSettingsSource: z21.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.")
14058
14112
  });
14059
14113
  var automationRunConfigSchema = automationRunConfigBaseSchema.superRefine((config, ctx) => {
14060
14114
  if (config.networkTrafficCaptureExplicitlyDisabled === true && config.networkTrafficCapture !== void 0) {
@@ -14080,7 +14134,7 @@ var automationRunStartConfigSchema = automationRunConfigBaseSchema.omit({
14080
14134
  });
14081
14135
 
14082
14136
  // ../mcp-registry/src/operation-specs.ts
14083
- import { z as z21 } from "zod";
14137
+ import { z as z23 } from "zod";
14084
14138
 
14085
14139
  // ../mcp-registry/src/operation-spec.ts
14086
14140
  function stripLeadingGraphqlComments(document) {
@@ -14184,7 +14238,7 @@ function jsonOption({
14184
14238
  valueType: "json"
14185
14239
  };
14186
14240
  }
14187
- var jsonObjectSchema = z21.record(z21.string(), z21.unknown());
14241
+ var jsonObjectSchema = z23.record(z23.string(), z23.unknown());
14188
14242
  var agentBrowserProviderOptionsSelection = ` browserbase {
14189
14243
  advancedStealth
14190
14244
  contextId
@@ -14280,8 +14334,8 @@ var operationSpecs = [
14280
14334
  createOperationSpec({
14281
14335
  operationName: "GetAgents",
14282
14336
  kind: "query",
14283
- inputSchema: z21.object({
14284
- ids: z21.array(z21.string().min(1)).min(1)
14337
+ inputSchema: z23.object({
14338
+ ids: z23.array(z23.string().min(1)).min(1)
14285
14339
  }),
14286
14340
  cli: {
14287
14341
  name: "get-agents",
@@ -14342,9 +14396,9 @@ ${agentLimitationsSelection}
14342
14396
  createOperationSpec({
14343
14397
  operationName: "GetAgentVersion",
14344
14398
  kind: "query",
14345
- inputSchema: z21.object({
14346
- agentId: z21.string().min(1),
14347
- versionId: z21.string().min(1)
14399
+ inputSchema: z23.object({
14400
+ agentId: z23.string().min(1),
14401
+ versionId: z23.string().min(1)
14348
14402
  }),
14349
14403
  cli: {
14350
14404
  name: "get-agent-version",
@@ -14407,8 +14461,8 @@ ${agentLimitationsSelection}
14407
14461
  createOperationSpec({
14408
14462
  operationName: "GetAgentVersions",
14409
14463
  kind: "query",
14410
- inputSchema: z21.object({
14411
- agentId: z21.string().min(1)
14464
+ inputSchema: z23.object({
14465
+ agentId: z23.string().min(1)
14412
14466
  }),
14413
14467
  cli: {
14414
14468
  name: "get-agent-versions",
@@ -14442,10 +14496,10 @@ query GetAgentVersions($agentId: ID!) {
14442
14496
  createOperationSpec({
14443
14497
  operationName: "DiffAgentVersion",
14444
14498
  kind: "query",
14445
- inputSchema: z21.object({
14446
- agentId: z21.string().min(1),
14447
- versionId: z21.string().min(1),
14448
- compareVersionId: z21.string().min(1).optional()
14499
+ inputSchema: z23.object({
14500
+ agentId: z23.string().min(1),
14501
+ versionId: z23.string().min(1),
14502
+ compareVersionId: z23.string().min(1).optional()
14449
14503
  }),
14450
14504
  cli: {
14451
14505
  name: "diff-agent-version",
@@ -14499,8 +14553,8 @@ query DiffAgentVersion(
14499
14553
  createOperationSpec({
14500
14554
  operationName: "GetAgentRun",
14501
14555
  kind: "query",
14502
- inputSchema: z21.object({
14503
- id: z21.string().min(1)
14556
+ inputSchema: z23.object({
14557
+ id: z23.string().min(1)
14504
14558
  }),
14505
14559
  cli: {
14506
14560
  name: "get-agent-run",
@@ -14536,8 +14590,8 @@ query GetAgentRun($id: ID!) {
14536
14590
  createOperationSpec({
14537
14591
  operationName: "GetAutomationAgents",
14538
14592
  kind: "query",
14539
- inputSchema: z21.object({
14540
- ids: z21.array(z21.string().min(1)).min(1)
14593
+ inputSchema: z23.object({
14594
+ ids: z23.array(z23.string().min(1)).min(1)
14541
14595
  }),
14542
14596
  cli: {
14543
14597
  name: "get-automation-agents",
@@ -14580,8 +14634,8 @@ query GetAutomationAgents($ids: [ID!]!) {
14580
14634
  createOperationSpec({
14581
14635
  operationName: "GetAutomationDiffFromPublished",
14582
14636
  kind: "query",
14583
- inputSchema: z21.object({
14584
- automationId: z21.string().min(1)
14637
+ inputSchema: z23.object({
14638
+ automationId: z23.string().min(1)
14585
14639
  }),
14586
14640
  cli: {
14587
14641
  name: "get-automation-diff-from-published",
@@ -14614,9 +14668,9 @@ query GetAutomationDiffFromPublished($automationId: ID!) {
14614
14668
  createOperationSpec({
14615
14669
  operationName: "GetAutomationDiffVersions",
14616
14670
  kind: "query",
14617
- inputSchema: z21.object({
14618
- baseVersionId: z21.string().min(1),
14619
- targetVersionId: z21.string().min(1)
14671
+ inputSchema: z23.object({
14672
+ baseVersionId: z23.string().min(1),
14673
+ targetVersionId: z23.string().min(1)
14620
14674
  }),
14621
14675
  cli: {
14622
14676
  name: "get-automation-diff-versions",
@@ -14657,10 +14711,10 @@ query GetAutomationDiffVersions($baseVersionId: ID!, $targetVersionId: ID!) {
14657
14711
  createOperationSpec({
14658
14712
  operationName: "GetAutomationVersionJson",
14659
14713
  kind: "query",
14660
- inputSchema: z21.object({
14661
- versionId: z21.string().min(1),
14662
- paths: z21.array(z21.string().min(1)).optional(),
14663
- format: z21.enum(["normalized", "full", "export"]).optional()
14714
+ inputSchema: z23.object({
14715
+ versionId: z23.string().min(1),
14716
+ paths: z23.array(z23.string().min(1)).optional(),
14717
+ format: z23.enum(["normalized", "full", "export"]).optional()
14664
14718
  }),
14665
14719
  cli: {
14666
14720
  name: "get-automation-version-json",
@@ -14695,8 +14749,8 @@ query GetAutomationVersionJson($versionId: ID!, $paths: [String!], $format: Stri
14695
14749
  createOperationSpec({
14696
14750
  operationName: "GetAutomationVersionJsonSkeleton",
14697
14751
  kind: "query",
14698
- inputSchema: z21.object({
14699
- versionId: z21.string().min(1)
14752
+ inputSchema: z23.object({
14753
+ versionId: z23.string().min(1)
14700
14754
  }),
14701
14755
  cli: {
14702
14756
  name: "get-automation-version-json-skeleton",
@@ -14721,8 +14775,8 @@ query GetAutomationVersionJsonSkeleton($versionId: ID!) {
14721
14775
  createOperationSpec({
14722
14776
  operationName: "GetAutomationRun",
14723
14777
  kind: "query",
14724
- inputSchema: z21.object({
14725
- id: z21.string().min(1)
14778
+ inputSchema: z23.object({
14779
+ id: z23.string().min(1)
14726
14780
  }),
14727
14781
  cli: {
14728
14782
  name: "get-automation-run",
@@ -14762,8 +14816,8 @@ query GetAutomationRun($id: ID!) {
14762
14816
  createOperationSpec({
14763
14817
  operationName: "GetAutomationRunAgentRuns",
14764
14818
  kind: "query",
14765
- inputSchema: z21.object({
14766
- automationRunId: z21.string().min(1)
14819
+ inputSchema: z23.object({
14820
+ automationRunId: z23.string().min(1)
14767
14821
  }),
14768
14822
  cli: {
14769
14823
  name: "get-automation-run-agent-runs",
@@ -14799,11 +14853,11 @@ query GetAutomationRunAgentRuns($automationRunId: ID!) {
14799
14853
  createOperationSpec({
14800
14854
  operationName: "GetAutomationRunIterations",
14801
14855
  kind: "query",
14802
- inputSchema: z21.object({
14803
- automationRunId: z21.string().min(1),
14804
- agentRunId: z21.string().min(1).optional(),
14805
- limit: z21.number().int().positive().optional(),
14806
- reverse: z21.boolean().optional()
14856
+ inputSchema: z23.object({
14857
+ automationRunId: z23.string().min(1),
14858
+ agentRunId: z23.string().min(1).optional(),
14859
+ limit: z23.number().int().positive().optional(),
14860
+ reverse: z23.boolean().optional()
14807
14861
  }),
14808
14862
  cli: {
14809
14863
  name: "get-automation-run-iterations",
@@ -14872,14 +14926,14 @@ query GetAutomationRunIterations(
14872
14926
  createOperationSpec({
14873
14927
  operationName: "GetAutomationRuns",
14874
14928
  kind: "query",
14875
- inputSchema: z21.object({
14876
- automationId: z21.string().min(1).optional(),
14877
- from: z21.string().min(1).optional(),
14878
- status: z21.array(z21.string().min(1)).optional(),
14879
- invocationType: z21.array(z21.string().min(1)).optional(),
14880
- limit: z21.number().int().positive().optional(),
14881
- page: z21.number().int().nonnegative().optional(),
14882
- to: z21.string().min(1).optional()
14929
+ inputSchema: z23.object({
14930
+ automationId: z23.string().min(1).optional(),
14931
+ from: z23.string().min(1).optional(),
14932
+ status: z23.array(z23.string().min(1)).optional(),
14933
+ invocationType: z23.array(z23.string().min(1)).optional(),
14934
+ limit: z23.number().int().positive().optional(),
14935
+ page: z23.number().int().nonnegative().optional(),
14936
+ to: z23.string().min(1).optional()
14883
14937
  }),
14884
14938
  cli: {
14885
14939
  name: "get-automation-runs",
@@ -14961,8 +15015,8 @@ query GetAutomationRuns(
14961
15015
  createOperationSpec({
14962
15016
  operationName: "ListAutomations",
14963
15017
  kind: "query",
14964
- inputSchema: z21.object({
14965
- limit: z21.number().positive().optional(),
15018
+ inputSchema: z23.object({
15019
+ limit: z23.number().positive().optional(),
14966
15020
  order: jsonObjectSchema.optional(),
14967
15021
  where: jsonObjectSchema.optional()
14968
15022
  }),
@@ -15013,8 +15067,8 @@ query ListAutomations(
15013
15067
  createOperationSpec({
15014
15068
  operationName: "GetAutomations",
15015
15069
  kind: "query",
15016
- inputSchema: z21.object({
15017
- ids: z21.array(z21.string().min(1)).min(1)
15070
+ inputSchema: z23.object({
15071
+ ids: z23.array(z23.string().min(1)).min(1)
15018
15072
  }),
15019
15073
  cli: {
15020
15074
  name: "get-automations",
@@ -15057,13 +15111,83 @@ query GetAutomations($ids: [ID!]!) {
15057
15111
  }
15058
15112
  }
15059
15113
  }
15114
+ }`
15115
+ }),
15116
+ createOperationSpec({
15117
+ operationName: "AnalyzeAutomationStoreMigration",
15118
+ kind: "query",
15119
+ inputSchema: automationStoreMigrationAnalyzerInputSchema,
15120
+ cli: {
15121
+ name: "analyze-automation-store-migration",
15122
+ path: ["automations", "store-migration", "analyze"],
15123
+ description: "Run read-only deterministic Store migration analysis over drafts, saved versions, or existing runs.",
15124
+ resultKey: "automationStoreMigrationAnalysis",
15125
+ options: [
15126
+ stringOption({
15127
+ inputKey: "mode",
15128
+ flagName: "mode",
15129
+ description: "Analysis mode: audit, compare, or auditRuntimeEvidence.",
15130
+ required: true
15131
+ }),
15132
+ stringArrayOption({
15133
+ inputKey: "automationIds",
15134
+ flagName: "automation-ids",
15135
+ description: "Starting draft automation IDs for audit mode."
15136
+ }),
15137
+ jsonOption({
15138
+ inputKey: "comparison",
15139
+ flagName: "comparison-json",
15140
+ description: "Exact saved-version declaration for compare mode."
15141
+ }),
15142
+ jsonOption({
15143
+ inputKey: "mappings",
15144
+ flagName: "mappings-json",
15145
+ description: "Legacy-value migration mapping declarations."
15146
+ }),
15147
+ jsonOption({
15148
+ inputKey: "storeWritePolicies",
15149
+ flagName: "store-write-policies-json",
15150
+ description: "Store writer coordination policy declarations."
15151
+ }),
15152
+ stringArrayOption({
15153
+ inputKey: "runIds",
15154
+ flagName: "run-ids",
15155
+ description: "Existing run IDs for auditRuntimeEvidence mode; no runs are created."
15156
+ }),
15157
+ stringOption({
15158
+ inputKey: "workItem",
15159
+ flagName: "work-item",
15160
+ description: "Optional business work-item label."
15161
+ })
15162
+ ]
15163
+ },
15164
+ mcp: { fileName: "analyzeAutomationStoreMigration.graphql" },
15165
+ document: `# Read-only deterministic analysis for Automation Store migrations.
15166
+ query AnalyzeAutomationStoreMigration(
15167
+ $mode: String!
15168
+ $automationIds: [ID!]!
15169
+ $comparison: JSON
15170
+ $mappings: JSON!
15171
+ $storeWritePolicies: JSON!
15172
+ $runIds: [ID!]!
15173
+ $workItem: String!
15174
+ ) {
15175
+ automationStoreMigrationAnalysis(
15176
+ mode: $mode
15177
+ automationIds: $automationIds
15178
+ comparison: $comparison
15179
+ mappings: $mappings
15180
+ storeWritePolicies: $storeWritePolicies
15181
+ runIds: $runIds
15182
+ workItem: $workItem
15183
+ )
15060
15184
  }`
15061
15185
  }),
15062
15186
  createOperationSpec({
15063
15187
  operationName: "GetAvailableCommands",
15064
15188
  kind: "query",
15065
- inputSchema: z21.object({
15066
- env: z21.string().min(1)
15189
+ inputSchema: z23.object({
15190
+ env: z23.string().min(1)
15067
15191
  }),
15068
15192
  cli: {
15069
15193
  name: "get-available-commands",
@@ -15093,8 +15217,8 @@ query GetAvailableCommands($env: AvailableCommandsEnv!) {
15093
15217
  createOperationSpec({
15094
15218
  operationName: "GetAvailableModels",
15095
15219
  kind: "query",
15096
- inputSchema: z21.object({
15097
- agentId: z21.string().min(1)
15220
+ inputSchema: z23.object({
15221
+ agentId: z23.string().min(1)
15098
15222
  }),
15099
15223
  cli: {
15100
15224
  name: "get-available-models",
@@ -15138,9 +15262,9 @@ query GetAvailableModels($agentId: String!) {
15138
15262
  createOperationSpec({
15139
15263
  operationName: "GetAvailableTools",
15140
15264
  kind: "query",
15141
- inputSchema: z21.object({
15142
- env: z21.string().min(1),
15143
- automationId: z21.string().min(1).optional()
15265
+ inputSchema: z23.object({
15266
+ env: z23.string().min(1),
15267
+ automationId: z23.string().min(1).optional()
15144
15268
  }),
15145
15269
  cli: {
15146
15270
  name: "get-available-tools",
@@ -15174,8 +15298,8 @@ query GetAvailableTools($env: AvailableCommandsEnv!, $automationId: String) {
15174
15298
  createOperationSpec({
15175
15299
  operationName: "GetFeatureFlagsContext",
15176
15300
  kind: "query",
15177
- inputSchema: z21.object({
15178
- flagKeys: z21.array(z21.string().min(1)).min(1).max(100).optional()
15301
+ inputSchema: z23.object({
15302
+ flagKeys: z23.array(z23.string().min(1)).min(1).max(100).optional()
15179
15303
  }),
15180
15304
  cli: {
15181
15305
  name: "get-feature-flags-context",
@@ -15212,7 +15336,7 @@ query GetFeatureFlagsContext($flagKeys: [String!]) {
15212
15336
  createOperationSpec({
15213
15337
  operationName: "GetAutomationWorkbenchCredentials",
15214
15338
  kind: "query",
15215
- inputSchema: z21.object({}),
15339
+ inputSchema: z23.object({}),
15216
15340
  cli: {
15217
15341
  name: "get-automation-workbench-credentials",
15218
15342
  path: ["workbench", "credentials"],
@@ -15237,8 +15361,8 @@ query GetAutomationWorkbenchCredentials {
15237
15361
  createOperationSpec({
15238
15362
  operationName: "GetAutomationWorkbenchDiagnostics",
15239
15363
  kind: "query",
15240
- inputSchema: z21.object({
15241
- draftAutomationId: z21.string().min(1)
15364
+ inputSchema: z23.object({
15365
+ draftAutomationId: z23.string().min(1)
15242
15366
  }),
15243
15367
  cli: {
15244
15368
  name: "get-automation-workbench-diagnostics",
@@ -15303,11 +15427,11 @@ query GetAutomationWorkbenchDiagnostics($draftAutomationId: ID!) {
15303
15427
  createOperationSpec({
15304
15428
  operationName: "GetAutomationWorkbenchRunTrace",
15305
15429
  kind: "query",
15306
- inputSchema: z21.object({
15307
- automationRunId: z21.string().min(1),
15308
- agentRunId: z21.string().min(1).optional(),
15309
- limit: z21.number().int().positive().optional(),
15310
- reverse: z21.boolean().optional()
15430
+ inputSchema: z23.object({
15431
+ automationRunId: z23.string().min(1),
15432
+ agentRunId: z23.string().min(1).optional(),
15433
+ limit: z23.number().int().positive().optional(),
15434
+ reverse: z23.boolean().optional()
15311
15435
  }),
15312
15436
  cli: {
15313
15437
  name: "get-automation-workbench-run-trace",
@@ -15439,13 +15563,13 @@ query GetAutomationWorkbenchRunTrace(
15439
15563
  createOperationSpec({
15440
15564
  operationName: "GetAutomationWorkbenchAwaitRunCompletion",
15441
15565
  kind: "query",
15442
- inputSchema: z21.object({
15443
- automationRunId: z21.string().min(1),
15444
- timeoutMs: z21.number().int().min(1e3).max(6e4).optional(),
15445
- sinceSequence: z21.number().int().min(0).optional(),
15446
- agentRunId: z21.string().min(1).optional(),
15447
- limit: z21.number().int().positive().optional(),
15448
- reverse: z21.boolean().optional()
15566
+ inputSchema: z23.object({
15567
+ automationRunId: z23.string().min(1),
15568
+ timeoutMs: z23.number().int().min(1e3).max(6e4).optional(),
15569
+ sinceSequence: z23.number().int().min(0).optional(),
15570
+ agentRunId: z23.string().min(1).optional(),
15571
+ limit: z23.number().int().positive().optional(),
15572
+ reverse: z23.boolean().optional()
15449
15573
  }),
15450
15574
  cli: {
15451
15575
  name: "await-automation-workbench-run-completion",
@@ -15599,11 +15723,11 @@ query GetAutomationWorkbenchAwaitRunCompletion(
15599
15723
  createOperationSpec({
15600
15724
  operationName: "GetAutomationWorkbenchSchemaSuggestions",
15601
15725
  kind: "query",
15602
- inputSchema: z21.object({
15603
- automationRunId: z21.string().min(1),
15604
- draftAutomationId: z21.string().min(1).optional(),
15605
- minConfidence: z21.number().min(0).max(1).optional(),
15606
- includeSensitive: z21.boolean().optional()
15726
+ inputSchema: z23.object({
15727
+ automationRunId: z23.string().min(1),
15728
+ draftAutomationId: z23.string().min(1).optional(),
15729
+ minConfidence: z23.number().min(0).max(1).optional(),
15730
+ includeSensitive: z23.boolean().optional()
15607
15731
  }),
15608
15732
  cli: {
15609
15733
  name: "get-automation-workbench-schema-suggestions",
@@ -15671,7 +15795,7 @@ query GetAutomationWorkbenchSchemaSuggestions(
15671
15795
  createOperationSpec({
15672
15796
  operationName: "CreateAutomation",
15673
15797
  kind: "mutation",
15674
- inputSchema: z21.object({
15798
+ inputSchema: z23.object({
15675
15799
  input: jsonObjectSchema
15676
15800
  }),
15677
15801
  cli: {
@@ -15708,7 +15832,7 @@ mutation CreateAutomation($input: CreateAutomationInput!) {
15708
15832
  createOperationSpec({
15709
15833
  operationName: "GetGraphqlSchema",
15710
15834
  kind: "query",
15711
- inputSchema: z21.object({}),
15835
+ inputSchema: z23.object({}),
15712
15836
  cli: {
15713
15837
  name: "get-graphql-schema",
15714
15838
  path: ["graphql", "schema"],
@@ -15729,8 +15853,8 @@ query GetGraphqlSchema {
15729
15853
  createOperationSpec({
15730
15854
  operationName: "PauseAutomationRun",
15731
15855
  kind: "mutation",
15732
- inputSchema: z21.object({
15733
- automationRunId: z21.string().min(1)
15856
+ inputSchema: z23.object({
15857
+ automationRunId: z23.string().min(1)
15734
15858
  }),
15735
15859
  cli: {
15736
15860
  name: "pause-automation-run",
@@ -15755,11 +15879,11 @@ mutation PauseAutomationRun($automationRunId: ID!) {
15755
15879
  createOperationSpec({
15756
15880
  operationName: "RerunAutomation",
15757
15881
  kind: "mutation",
15758
- inputSchema: z21.object({
15759
- automationRunId: z21.string().min(1),
15760
- additionalPrompt: z21.string().min(1).optional(),
15761
- idempotencyKey: z21.string().min(1),
15762
- allowPointOfNoReturnOverride: z21.boolean().optional()
15882
+ inputSchema: z23.object({
15883
+ automationRunId: z23.string().min(1),
15884
+ additionalPrompt: z23.string().min(1).optional(),
15885
+ idempotencyKey: z23.string().min(1),
15886
+ allowPointOfNoReturnOverride: z23.boolean().optional()
15763
15887
  }),
15764
15888
  cli: {
15765
15889
  name: "rerun-automation",
@@ -15814,9 +15938,9 @@ mutation RerunAutomation(
15814
15938
  createOperationSpec({
15815
15939
  operationName: "ResumeAutomationRun",
15816
15940
  kind: "mutation",
15817
- inputSchema: z21.object({
15818
- automationRunId: z21.string().min(1),
15819
- message: z21.string().min(1).optional()
15941
+ inputSchema: z23.object({
15942
+ automationRunId: z23.string().min(1),
15943
+ message: z23.string().min(1).optional()
15820
15944
  }),
15821
15945
  cli: {
15822
15946
  name: "resume-automation-run",
@@ -15846,15 +15970,15 @@ mutation ResumeAutomationRun($automationRunId: ID!, $message: String) {
15846
15970
  createOperationSpec({
15847
15971
  operationName: "RunDraftAutomation",
15848
15972
  kind: "mutation",
15849
- inputSchema: z21.object({
15850
- draftAutomationId: z21.string().min(1),
15851
- agentId: z21.string().min(1),
15852
- idempotencyKey: z21.string().min(1),
15853
- input: z21.unknown().optional(),
15854
- initialStore: z21.record(z21.string(), z21.unknown()).optional(),
15973
+ inputSchema: z23.object({
15974
+ draftAutomationId: z23.string().min(1),
15975
+ agentId: z23.string().min(1),
15976
+ idempotencyKey: z23.string().min(1),
15977
+ input: z23.unknown().optional(),
15978
+ initialStore: z23.record(z23.string(), z23.unknown()).optional(),
15855
15979
  config: automationRunStartConfigSchema.partial().passthrough().optional(),
15856
- additionalPrompt: z21.string().min(1).optional(),
15857
- consistencyCheckCount: z21.number().int().optional()
15980
+ additionalPrompt: z23.string().min(1).optional(),
15981
+ consistencyCheckCount: z23.number().int().optional()
15858
15982
  }),
15859
15983
  cli: {
15860
15984
  name: "run-draft-automation",
@@ -15939,8 +16063,8 @@ mutation RunDraftAutomation(
15939
16063
  createOperationSpec({
15940
16064
  operationName: "StopAutomationRun",
15941
16065
  kind: "mutation",
15942
- inputSchema: z21.object({
15943
- automationRunId: z21.string().min(1)
16066
+ inputSchema: z23.object({
16067
+ automationRunId: z23.string().min(1)
15944
16068
  }),
15945
16069
  cli: {
15946
16070
  name: "stop-automation-run",
@@ -15965,10 +16089,10 @@ mutation StopAutomationRun($automationRunId: ID!) {
15965
16089
  createOperationSpec({
15966
16090
  operationName: "PreviewAutomationPatch",
15967
16091
  kind: "mutation",
15968
- inputSchema: z21.object({
15969
- draftAutomationId: z21.string().min(1),
15970
- expectedLastSavedAt: z21.string().optional(),
15971
- operations: z21.array(z21.unknown()).min(1)
16092
+ inputSchema: z23.object({
16093
+ draftAutomationId: z23.string().min(1),
16094
+ expectedLastSavedAt: z23.string().optional(),
16095
+ operations: z23.array(z23.unknown()).min(1)
15972
16096
  }),
15973
16097
  cli: {
15974
16098
  name: "preview-automation-patch",
@@ -16077,9 +16201,9 @@ mutation PreviewAutomationPatch(
16077
16201
  createOperationSpec({
16078
16202
  operationName: "ApplyAutomationPatch",
16079
16203
  kind: "mutation",
16080
- inputSchema: z21.object({
16081
- draftAutomationId: z21.string().min(1),
16082
- operations: z21.array(z21.unknown()).min(1)
16204
+ inputSchema: z23.object({
16205
+ draftAutomationId: z23.string().min(1),
16206
+ operations: z23.array(z23.unknown()).min(1)
16083
16207
  }),
16084
16208
  cli: {
16085
16209
  name: "apply-automation-patch",
@@ -16195,8 +16319,8 @@ mutation ApplyAutomationPatch(
16195
16319
  createOperationSpec({
16196
16320
  operationName: "UpdateAutomationById",
16197
16321
  kind: "mutation",
16198
- inputSchema: z21.object({
16199
- id: z21.string().min(1),
16322
+ inputSchema: z23.object({
16323
+ id: z23.string().min(1),
16200
16324
  input: jsonObjectSchema
16201
16325
  }),
16202
16326
  cli: {
@@ -16239,58 +16363,82 @@ mutation UpdateAutomationById($id: ID!, $input: UpdateAutomationInput!) {
16239
16363
  import { Command as Command2, InvalidArgumentError as InvalidArgumentError2, Option as Option2 } from "commander";
16240
16364
 
16241
16365
  // src/api.ts
16242
- import { z as z23 } from "zod";
16366
+ import { z as z24 } from "zod";
16367
+
16368
+ // src/version.ts
16369
+ import fs from "node:fs";
16370
+ import path from "node:path";
16371
+ import { fileURLToPath } from "node:url";
16372
+ var packageManifestPath = path.resolve(
16373
+ path.dirname(fileURLToPath(import.meta.url)),
16374
+ "../package.json"
16375
+ );
16376
+ var packageManifestResult = safeJsonParse(
16377
+ fs.readFileSync(packageManifestPath, "utf8")
16378
+ );
16379
+ if (isErr(packageManifestResult)) {
16380
+ throw new Error(`Failed to parse ${packageManifestPath}.`, {
16381
+ cause: packageManifestResult.error.cause
16382
+ });
16383
+ }
16384
+ var cliPackageVersion = packageManifestResult.value.version;
16385
+ if (typeof cliPackageVersion !== "string" || cliPackageVersion.length === 0) {
16386
+ throw new Error(`Expected a version in ${packageManifestPath}.`);
16387
+ }
16388
+ var CLI_VERSION = cliPackageVersion;
16389
+
16390
+ // src/api.ts
16243
16391
  var OTTO_AUTHORIZATION_HEADER_NAME = "X-Otto-Authorization";
16244
16392
  var OTTO_AUTHORIZATION_ISSUER = "magical:otto";
16245
- var workosOrganizationsResponseSchema = z23.object({
16246
- organizations: z23.array(
16247
- z23.object({
16248
- id: z23.string().min(1),
16249
- name: z23.string().min(1),
16250
- primaryDomain: z23.string().nullable().optional()
16393
+ var workosOrganizationsResponseSchema = z24.object({
16394
+ organizations: z24.array(
16395
+ z24.object({
16396
+ id: z24.string().min(1),
16397
+ name: z24.string().min(1),
16398
+ primaryDomain: z24.string().nullable().optional()
16251
16399
  })
16252
16400
  ),
16253
- success: z23.boolean()
16401
+ success: z24.boolean()
16254
16402
  });
16255
- var workosUserSchema = z23.object({
16256
- email: z23.string().nullable(),
16257
- id: z23.string().min(1)
16403
+ var workosUserSchema = z24.object({
16404
+ email: z24.string().nullable(),
16405
+ id: z24.string().min(1)
16258
16406
  });
16259
- var nangoIntegrationWireSchema = z23.object({
16407
+ var nangoIntegrationWireSchema = z24.object({
16260
16408
  // eslint-disable-next-line @typescript-eslint/naming-convention -- mirrors Nango REST payload
16261
- unique_key: z23.string().min(1)
16409
+ unique_key: z24.string().min(1)
16262
16410
  }).passthrough().transform((data) => ({
16263
16411
  ...data,
16264
16412
  uniqueKey: data.unique_key
16265
16413
  }));
16266
- var nangoIntegrationsResponseSchema = z23.array(nangoIntegrationWireSchema);
16267
- var organizationAuthenticationSchema = z23.object({
16268
- id: z23.string().min(1),
16269
- type: z23.string().min(1),
16270
- connectionId: z23.string().nullable().optional(),
16271
- providerConfigKey: z23.string().nullable().optional(),
16272
- description: z23.string().nullable().optional(),
16273
- hostname: z23.string().nullable().optional()
16414
+ var nangoIntegrationsResponseSchema = z24.array(nangoIntegrationWireSchema);
16415
+ var organizationAuthenticationSchema = z24.object({
16416
+ id: z24.string().min(1),
16417
+ type: z24.string().min(1),
16418
+ connectionId: z24.string().nullable().optional(),
16419
+ providerConfigKey: z24.string().nullable().optional(),
16420
+ description: z24.string().nullable().optional(),
16421
+ hostname: z24.string().nullable().optional()
16274
16422
  }).passthrough();
16275
- var organizationAuthenticationsResponseSchema = z23.object({
16276
- authentications: z23.array(organizationAuthenticationSchema),
16277
- success: z23.boolean()
16423
+ var organizationAuthenticationsResponseSchema = z24.object({
16424
+ authentications: z24.array(organizationAuthenticationSchema),
16425
+ success: z24.boolean()
16278
16426
  });
16279
- var graphQlResponseSchema = z23.object({
16280
- data: z23.record(z23.string(), z23.unknown()).optional(),
16281
- errors: z23.array(
16282
- z23.object({
16283
- message: z23.string().min(1)
16427
+ var graphQlResponseSchema = z24.object({
16428
+ data: z24.record(z24.string(), z24.unknown()).optional(),
16429
+ errors: z24.array(
16430
+ z24.object({
16431
+ message: z24.string().min(1)
16284
16432
  })
16285
16433
  ).optional()
16286
16434
  });
16287
- var apiErrorResponseSchema = z23.object({
16288
- errors: z23.array(
16289
- z23.object({
16290
- message: z23.string().min(1)
16435
+ var apiErrorResponseSchema = z24.object({
16436
+ errors: z24.array(
16437
+ z24.object({
16438
+ message: z24.string().min(1)
16291
16439
  })
16292
16440
  ).optional(),
16293
- message: z23.string().min(1).optional()
16441
+ message: z24.string().min(1).optional()
16294
16442
  });
16295
16443
  function getApiErrorDetail(responseBody) {
16296
16444
  const parsedResponse = apiErrorResponseSchema.safeParse(responseBody);
@@ -16375,6 +16523,7 @@ function createMagicalApiClient({
16375
16523
  ...organizationId ? { organizationId } : {}
16376
16524
  });
16377
16525
  headers.set("x-magical-client", "mgcl");
16526
+ headers.set("x-magical-client-version", CLI_VERSION);
16378
16527
  const response = await fetchFn(url, {
16379
16528
  ...init,
16380
16529
  headers
@@ -16520,7 +16669,7 @@ function createMagicalApiClient({
16520
16669
 
16521
16670
  // src/config.ts
16522
16671
  import os from "node:os";
16523
- import path from "node:path";
16672
+ import path2 from "node:path";
16524
16673
  var DEFAULT_MAGICAL_API_URL = "https://api-agt.getmagical.io";
16525
16674
  var DEFAULT_WORKOS_API_URL = "https://api.workos.com";
16526
16675
  var DEFAULT_WORKOS_CLIENT_ID = "client_01JJZ6XJ1RF248P20WF63M4VAM";
@@ -16539,33 +16688,33 @@ function resolvePlatformConfigDirectory() {
16539
16688
  return customConfigDirectory;
16540
16689
  }
16541
16690
  if (process.platform === "darwin") {
16542
- return path.join(os.homedir(), "Library", "Application Support");
16691
+ return path2.join(os.homedir(), "Library", "Application Support");
16543
16692
  }
16544
16693
  if (process.platform === "win32") {
16545
16694
  const appDataDirectory = process.env["APPDATA"];
16546
- return appDataDirectory ?? path.join(os.homedir(), "AppData", "Roaming");
16695
+ return appDataDirectory ?? path2.join(os.homedir(), "AppData", "Roaming");
16547
16696
  }
16548
- return process.env["XDG_CONFIG_HOME"] ?? path.join(os.homedir(), ".config");
16697
+ return process.env["XDG_CONFIG_HOME"] ?? path2.join(os.homedir(), ".config");
16549
16698
  }
16550
16699
  function resolveRefreshTokenStoreKind() {
16551
16700
  return process.env["MAGICAL_CLI_REFRESH_TOKEN_STORE"] === "file" ? "file" : "keytar";
16552
16701
  }
16553
16702
  function getRuntimeConfig() {
16554
- const configDirectory = path.join(
16703
+ const configDirectory = path2.join(
16555
16704
  resolvePlatformConfigDirectory(),
16556
16705
  CLI_CONFIG_DIRECTORY_NAME
16557
16706
  );
16558
16707
  return {
16559
- accessTokenFilePath: path.join(configDirectory, CLI_ACCESS_TOKEN_FILE_NAME),
16708
+ accessTokenFilePath: path2.join(configDirectory, CLI_ACCESS_TOKEN_FILE_NAME),
16560
16709
  cliDistTag: process.env["MAGICAL_CLI_DIST_TAG"] ?? DEFAULT_CLI_DIST_TAG,
16561
16710
  magicalApiUrl: DEFAULT_MAGICAL_API_URL,
16562
16711
  npmRegistryUrl: process.env["MAGICAL_CLI_NPM_REGISTRY_URL"] ?? DEFAULT_CLI_NPM_REGISTRY_URL,
16563
- refreshTokenFilePath: path.join(
16712
+ refreshTokenFilePath: path2.join(
16564
16713
  configDirectory,
16565
16714
  CLI_REFRESH_TOKEN_FILE_NAME
16566
16715
  ),
16567
16716
  refreshTokenStoreKind: resolveRefreshTokenStoreKind(),
16568
- stateFilePath: path.join(configDirectory, CLI_STATE_FILE_NAME),
16717
+ stateFilePath: path2.join(configDirectory, CLI_STATE_FILE_NAME),
16569
16718
  workosApiUrl: DEFAULT_WORKOS_API_URL,
16570
16719
  workosClientId: DEFAULT_WORKOS_CLIENT_ID,
16571
16720
  keychainServiceName: DEFAULT_KEYCHAIN_SERVICE_NAME
@@ -16577,11 +16726,11 @@ function requireWorkosClientId(config) {
16577
16726
 
16578
16727
  // src/settings.ts
16579
16728
  import { mkdir, readFile, rm, writeFile } from "node:fs/promises";
16580
- import path2 from "node:path";
16581
- import { z as z24 } from "zod";
16582
- var cliSettingsSchema = z24.object({
16583
- env: z24.object({
16584
- baseUrl: z24.url().optional()
16729
+ import path3 from "node:path";
16730
+ import { z as z25 } from "zod";
16731
+ var cliSettingsSchema = z25.object({
16732
+ env: z25.object({
16733
+ baseUrl: z25.url().optional()
16585
16734
  }).default({})
16586
16735
  });
16587
16736
  function createEmptyCliSettings() {
@@ -16593,7 +16742,7 @@ function hasCliSettingsOverrides(settings) {
16593
16742
  return settings.env.baseUrl !== void 0;
16594
16743
  }
16595
16744
  function resolveSettingsFilePath(stateFilePath) {
16596
- return path2.join(path2.dirname(stateFilePath), CLI_SETTINGS_FILE_NAME);
16745
+ return path3.join(path3.dirname(stateFilePath), CLI_SETTINGS_FILE_NAME);
16597
16746
  }
16598
16747
  function resolveConfiguredApiBaseUrl({
16599
16748
  defaultApiBaseUrl,
@@ -16638,7 +16787,7 @@ function createFileSettingsStore(stateFilePath) {
16638
16787
  await rm(settingsFilePath, { force: true });
16639
16788
  return;
16640
16789
  }
16641
- await mkdir(path2.dirname(settingsFilePath), { recursive: true });
16790
+ await mkdir(path3.dirname(settingsFilePath), { recursive: true });
16642
16791
  await writeFile(
16643
16792
  settingsFilePath,
16644
16793
  `${JSON.stringify(settings, null, 2)}
@@ -16920,9 +17069,9 @@ function isExpiredAccessTokenClaims(claims) {
16920
17069
 
16921
17070
  // src/self-update.ts
16922
17071
  import { spawn as spawn2 } from "node:child_process";
16923
- import fs from "node:fs";
16924
- import path3 from "node:path";
16925
- import { fileURLToPath } from "node:url";
17072
+ import fs2 from "node:fs";
17073
+ import path4 from "node:path";
17074
+ import { fileURLToPath as fileURLToPath2 } from "node:url";
16926
17075
  var CLI_PACKAGE_NAME = "@getmagical/cli";
16927
17076
  var DEFAULT_CLI_DIST_TAG2 = "latest";
16928
17077
  var DEFAULT_NPM_REGISTRY_URL = "https://registry.npmjs.org/";
@@ -16932,9 +17081,9 @@ function resolveInstalledPackageRoot({
16932
17081
  packageName
16933
17082
  }) {
16934
17083
  const packagePathSegments = packageName.split("/");
16935
- let currentPath = path3.dirname(entryFilePath);
17084
+ let currentPath = path4.dirname(entryFilePath);
16936
17085
  for (; ; ) {
16937
- const currentPathSegments = currentPath.split(path3.sep).filter(Boolean);
17086
+ const currentPathSegments = currentPath.split(path4.sep).filter(Boolean);
16938
17087
  const currentPackageSegments = currentPathSegments.slice(
16939
17088
  -packagePathSegments.length
16940
17089
  );
@@ -16943,7 +17092,7 @@ function resolveInstalledPackageRoot({
16943
17092
  )) {
16944
17093
  return currentPath;
16945
17094
  }
16946
- const parentPath = path3.dirname(currentPath);
17095
+ const parentPath = path4.dirname(currentPath);
16947
17096
  if (parentPath === currentPath) {
16948
17097
  return null;
16949
17098
  }
@@ -16953,14 +17102,14 @@ function resolveInstalledPackageRoot({
16953
17102
  function resolveInstallPrefixFromPackageRoot(packageRootPath) {
16954
17103
  let currentPath = packageRootPath;
16955
17104
  for (; ; ) {
16956
- if (path3.basename(currentPath) === "node_modules") {
16957
- const nodeModulesParentPath = path3.dirname(currentPath);
16958
- if (path3.basename(nodeModulesParentPath) === "lib") {
16959
- return path3.dirname(nodeModulesParentPath);
17105
+ if (path4.basename(currentPath) === "node_modules") {
17106
+ const nodeModulesParentPath = path4.dirname(currentPath);
17107
+ if (path4.basename(nodeModulesParentPath) === "lib") {
17108
+ return path4.dirname(nodeModulesParentPath);
16960
17109
  }
16961
17110
  return nodeModulesParentPath;
16962
17111
  }
16963
- const parentPath = path3.dirname(currentPath);
17112
+ const parentPath = path4.dirname(currentPath);
16964
17113
  if (parentPath === currentPath) {
16965
17114
  return null;
16966
17115
  }
@@ -16977,13 +17126,13 @@ function resolveManagedNpmCommand(installPrefix) {
16977
17126
  if (process.platform === "win32") {
16978
17127
  return null;
16979
17128
  }
16980
- const managedNodeExecutable = path3.join(
17129
+ const managedNodeExecutable = path4.join(
16981
17130
  installPrefix,
16982
17131
  MANAGED_NODE_SUBPATH,
16983
17132
  "bin",
16984
17133
  "node"
16985
17134
  );
16986
- const managedNpmCli = path3.join(
17135
+ const managedNpmCli = path4.join(
16987
17136
  installPrefix,
16988
17137
  MANAGED_NODE_SUBPATH,
16989
17138
  "lib",
@@ -16992,7 +17141,7 @@ function resolveManagedNpmCommand(installPrefix) {
16992
17141
  "bin",
16993
17142
  "npm-cli.js"
16994
17143
  );
16995
- if (!fs.existsSync(managedNodeExecutable) || !fs.existsSync(managedNpmCli)) {
17144
+ if (!fs2.existsSync(managedNodeExecutable) || !fs2.existsSync(managedNpmCli)) {
16996
17145
  return null;
16997
17146
  }
16998
17147
  return {
@@ -17054,7 +17203,7 @@ async function installPublishedCli({
17054
17203
  }
17055
17204
  async function selfUpdateInstalledCli({
17056
17205
  distTag = DEFAULT_CLI_DIST_TAG2,
17057
- entryFilePath = fileURLToPath(import.meta.url),
17206
+ entryFilePath = fileURLToPath2(import.meta.url),
17058
17207
  packageName = CLI_PACKAGE_NAME,
17059
17208
  registryUrl = DEFAULT_NPM_REGISTRY_URL
17060
17209
  } = {}) {
@@ -17182,25 +17331,25 @@ ${formatExamples("Examples", [
17182
17331
 
17183
17332
  // src/state.ts
17184
17333
  import { mkdir as mkdir2, readFile as readFile3, rm as rm3, writeFile as writeFile2 } from "node:fs/promises";
17185
- import path4 from "node:path";
17186
- import { z as z25 } from "zod";
17187
- var cliAccountSchema = z25.object({
17188
- clientId: z25.string().min(1),
17189
- email: z25.string().nullable(),
17190
- userId: z25.string().min(1)
17334
+ import path5 from "node:path";
17335
+ import { z as z26 } from "zod";
17336
+ var cliAccountSchema = z26.object({
17337
+ clientId: z26.string().min(1),
17338
+ email: z26.string().nullable(),
17339
+ userId: z26.string().min(1)
17191
17340
  });
17192
- var cliOrganizationSchema = z25.object({
17193
- id: z25.string().min(1),
17194
- name: z25.string().min(1),
17195
- primaryDomain: z25.string().nullable().default(null)
17341
+ var cliOrganizationSchema = z26.object({
17342
+ id: z26.string().min(1),
17343
+ name: z26.string().min(1),
17344
+ primaryDomain: z26.string().nullable().default(null)
17196
17345
  });
17197
- var cliStateSchema = z25.object({
17346
+ var cliStateSchema = z26.object({
17198
17347
  account: cliAccountSchema,
17199
- defaultOrgId: z25.string().nullable(),
17200
- lastUsedOrgId: z25.string().nullable(),
17201
- organizations: z25.array(cliOrganizationSchema)
17348
+ defaultOrgId: z26.string().nullable(),
17349
+ lastUsedOrgId: z26.string().nullable(),
17350
+ organizations: z26.array(cliOrganizationSchema)
17202
17351
  });
17203
- var refreshTokenFileSchema = z25.record(z25.string(), z25.string());
17352
+ var refreshTokenFileSchema = z26.record(z26.string(), z26.string());
17204
17353
  function createFileStateStore(stateFilePath) {
17205
17354
  return {
17206
17355
  async clear() {
@@ -17225,7 +17374,7 @@ function createFileStateStore(stateFilePath) {
17225
17374
  }
17226
17375
  },
17227
17376
  async save(state) {
17228
- await mkdir2(path4.dirname(stateFilePath), { recursive: true });
17377
+ await mkdir2(path5.dirname(stateFilePath), { recursive: true });
17229
17378
  await writeFile2(stateFilePath, `${JSON.stringify(state, null, 2)}
17230
17379
  `);
17231
17380
  }
@@ -17253,7 +17402,7 @@ function createFileRefreshTokenStore(refreshTokenFilePath) {
17253
17402
  }
17254
17403
  }
17255
17404
  async function saveRefreshTokens(refreshTokens) {
17256
- await mkdir2(path4.dirname(refreshTokenFilePath), { recursive: true });
17405
+ await mkdir2(path5.dirname(refreshTokenFilePath), { recursive: true });
17257
17406
  await writeFile2(
17258
17407
  refreshTokenFilePath,
17259
17408
  `${JSON.stringify(refreshTokens, null, 2)}
@@ -17290,60 +17439,38 @@ function buildRefreshTokenKey(account) {
17290
17439
  return `${account.clientId}:${account.userId}`;
17291
17440
  }
17292
17441
 
17293
- // src/version.ts
17294
- import fs2 from "node:fs";
17295
- import path5 from "node:path";
17296
- import { fileURLToPath as fileURLToPath2 } from "node:url";
17297
- var packageManifestPath = path5.resolve(
17298
- path5.dirname(fileURLToPath2(import.meta.url)),
17299
- "../package.json"
17300
- );
17301
- var packageManifestResult = safeJsonParse(
17302
- fs2.readFileSync(packageManifestPath, "utf8")
17303
- );
17304
- if (isErr(packageManifestResult)) {
17305
- throw new Error(`Failed to parse ${packageManifestPath}.`, {
17306
- cause: packageManifestResult.error.cause
17307
- });
17308
- }
17309
- var cliPackageVersion = packageManifestResult.value.version;
17310
- if (typeof cliPackageVersion !== "string" || cliPackageVersion.length === 0) {
17311
- throw new Error(`Expected a version in ${packageManifestPath}.`);
17312
- }
17313
- var CLI_VERSION = cliPackageVersion;
17314
-
17315
17442
  // src/workos-auth.ts
17316
- import { z as z26 } from "zod";
17443
+ import { z as z27 } from "zod";
17317
17444
  var DEFAULT_DEVICE_POLL_INTERVAL_SECONDS = 5;
17318
17445
  function buildFormHeaders() {
17319
17446
  const headers = new Headers();
17320
17447
  headers.set("content-type", "application/x-www-form-urlencoded");
17321
17448
  return headers;
17322
17449
  }
17323
- var deviceAuthorizationSchema = z26.object({
17324
- device_code: z26.string().min(1),
17325
- expires_in: z26.number().int().positive().optional(),
17326
- interval: z26.number().int().positive().optional(),
17327
- user_code: z26.string().min(1),
17328
- verification_uri: z26.url(),
17329
- verification_uri_complete: z26.url().optional()
17450
+ var deviceAuthorizationSchema = z27.object({
17451
+ device_code: z27.string().min(1),
17452
+ expires_in: z27.number().int().positive().optional(),
17453
+ interval: z27.number().int().positive().optional(),
17454
+ user_code: z27.string().min(1),
17455
+ verification_uri: z27.url(),
17456
+ verification_uri_complete: z27.url().optional()
17330
17457
  });
17331
- var tokenResponseSchema = z26.object({
17332
- access_token: z26.string().min(1),
17333
- expires_in: z26.number().int().positive().optional(),
17334
- refresh_token: z26.string().min(1),
17335
- token_type: z26.string().optional()
17458
+ var tokenResponseSchema = z27.object({
17459
+ access_token: z27.string().min(1),
17460
+ expires_in: z27.number().int().positive().optional(),
17461
+ refresh_token: z27.string().min(1),
17462
+ token_type: z27.string().optional()
17336
17463
  });
17337
- var tokenErrorSchema = z26.object({
17338
- error: z26.string().min(1),
17339
- error_description: z26.string().optional()
17464
+ var tokenErrorSchema = z27.object({
17465
+ error: z27.string().min(1),
17466
+ error_description: z27.string().optional()
17340
17467
  });
17341
- var accessTokenClaimsSchema = z26.object({
17342
- exp: z26.number().int().positive().optional(),
17343
- iss: z26.string().min(1).optional(),
17344
- org_id: z26.string().min(1).optional(),
17345
- sid: z26.string().min(1).optional(),
17346
- sub: z26.string().min(1)
17468
+ var accessTokenClaimsSchema = z27.object({
17469
+ exp: z27.number().int().positive().optional(),
17470
+ iss: z27.string().min(1).optional(),
17471
+ org_id: z27.string().min(1).optional(),
17472
+ sid: z27.string().min(1).optional(),
17473
+ sub: z27.string().min(1)
17347
17474
  });
17348
17475
  function createWorkosAuthClient({
17349
17476
  fetchFn = fetch,