@zapier/zapier-sdk-cli 0.43.3 → 0.44.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # @zapier/zapier-sdk-cli
2
2
 
3
+ ## 0.44.0
4
+
5
+ ### Minor Changes
6
+
7
+ - c7cff63: Adds an extension mechanism that lets the CLI and MCP server load additional plugin packages at runtime. Set `ZAPIER_SDK_EXTENSIONS` to a comma-separated list of package specifiers, or pass them via the new `extensions` option — methods they contribute show up automatically as CLI commands and MCP tools, no per-project wiring required.
8
+
9
+ When a plugin tries to register a method, context field, or meta entry that's already registered by another plugin in the chain, `addPlugin` now logs a warning and skips the duplicate plugin's contribution rather than silently overwriting. This catches the common foot-gun of an extension accidentally shadowing a built-in SDK method. Intentional duplicates can be expressed via `composePlugins(...)`, and meta-only overrides (e.g. tagging a built-in method as deprecated) continue to work unchanged.
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies [c7cff63]
14
+ - @zapier/zapier-sdk-mcp@0.12.0
15
+ - @zapier/zapier-sdk@0.48.0
16
+
17
+ ## 0.43.4
18
+
19
+ ### Patch Changes
20
+
21
+ - Updated dependencies [4ab820a]
22
+ - @zapier/zapier-sdk@0.47.1
23
+ - @zapier/zapier-sdk-mcp@0.11.9
24
+
3
25
  ## 0.43.3
4
26
 
5
27
  ### Patch Changes
package/dist/cli.cjs CHANGED
@@ -176,14 +176,14 @@ var SchemaParameterResolver = class {
176
176
  this.spinner = null;
177
177
  }
178
178
  }
179
- async resolveParameters(schema, providedParams, sdk2, functionName, options) {
179
+ async resolveParameters(schema, providedParams, sdk, functionName, options) {
180
180
  return zapierSdk.runWithTelemetryContext(async () => {
181
181
  this.debug = options?.debug ?? false;
182
182
  const interactiveMode = (options?.interactiveMode ?? true) && !!process.stdin.isTTY;
183
183
  const parseResult = schema.safeParse(providedParams);
184
184
  const allParams = this.extractParametersFromSchema(schema);
185
185
  const resolvableParams = allParams.filter(
186
- (param) => this.hasResolver(param.name, sdk2, functionName)
186
+ (param) => this.hasResolver(param.name, sdk, functionName)
187
187
  );
188
188
  const missingResolvable = resolvableParams.filter((param) => {
189
189
  const hasValue = this.getNestedValue(providedParams, param.path) !== void 0;
@@ -208,12 +208,12 @@ var SchemaParameterResolver = class {
208
208
  }
209
209
  const resolvedParams = { ...providedParams };
210
210
  const context = {
211
- sdk: sdk2,
211
+ sdk,
212
212
  currentParams: providedParams,
213
213
  resolvedParams,
214
214
  functionName
215
215
  };
216
- const localResolvers = this.getLocalResolvers(sdk2, functionName);
216
+ const localResolvers = this.getLocalResolvers(sdk, functionName);
217
217
  if (required.length > 0) {
218
218
  const requiredParamNames = required.map((p) => p.name);
219
219
  const requiredResolutionOrder = getLocalResolutionOrderForParams(
@@ -1047,9 +1047,9 @@ Optional fields${pathContext}:`));
1047
1047
  const errorObj = error;
1048
1048
  return errorObj?.name === "ExitPromptError" || errorObj?.message?.includes("User force closed") || errorObj?.isTTYError === true;
1049
1049
  }
1050
- hasResolver(paramName, sdk2, functionName) {
1051
- if (functionName && typeof sdk2.getRegistry === "function") {
1052
- const registry = sdk2.getRegistry({ package: "cli" });
1050
+ hasResolver(paramName, sdk, functionName) {
1051
+ if (functionName && typeof sdk.getRegistry === "function") {
1052
+ const registry = sdk.getRegistry({ package: "cli" });
1053
1053
  const functionInfo = registry.functions.find(
1054
1054
  (f) => f.name === functionName
1055
1055
  );
@@ -1059,9 +1059,9 @@ Optional fields${pathContext}:`));
1059
1059
  }
1060
1060
  return false;
1061
1061
  }
1062
- getResolver(paramName, sdk2, functionName) {
1063
- if (functionName && typeof sdk2.getRegistry === "function") {
1064
- const registry = sdk2.getRegistry({ package: "cli" });
1062
+ getResolver(paramName, sdk, functionName) {
1063
+ if (functionName && typeof sdk.getRegistry === "function") {
1064
+ const registry = sdk.getRegistry({ package: "cli" });
1065
1065
  const functionInfo = registry.functions.find(
1066
1066
  (f) => f.name === functionName
1067
1067
  );
@@ -1071,11 +1071,11 @@ Optional fields${pathContext}:`));
1071
1071
  }
1072
1072
  return null;
1073
1073
  }
1074
- getLocalResolvers(sdk2, functionName) {
1075
- if (!functionName || typeof sdk2.getRegistry !== "function") {
1074
+ getLocalResolvers(sdk, functionName) {
1075
+ if (!functionName || typeof sdk.getRegistry !== "function") {
1076
1076
  return {};
1077
1077
  }
1078
- const registry = sdk2.getRegistry();
1078
+ const registry = sdk.getRegistry();
1079
1079
  const functionInfo = registry.functions.find(
1080
1080
  (f) => f.name === functionName
1081
1081
  );
@@ -1113,7 +1113,7 @@ var SHARED_COMMAND_CLI_OPTIONS = [
1113
1113
 
1114
1114
  // package.json
1115
1115
  var package_default = {
1116
- version: "0.43.3"};
1116
+ version: "0.44.0"};
1117
1117
 
1118
1118
  // src/telemetry/builders.ts
1119
1119
  function createCliBaseEvent(context = {}) {
@@ -1831,19 +1831,19 @@ function reconstructPositionalArgs(inputParameters, flatParams) {
1831
1831
  function methodNameToCliCommand(methodName) {
1832
1832
  return toKebabCase(methodName);
1833
1833
  }
1834
- function generateCliCommands(program2, sdk2) {
1835
- if (typeof sdk2.getRegistry !== "function") {
1834
+ function generateCliCommands(program2, sdk) {
1835
+ if (typeof sdk.getRegistry !== "function") {
1836
1836
  console.error("SDK registry not available");
1837
1837
  return;
1838
1838
  }
1839
- const registry = sdk2.getRegistry({ package: "cli" });
1839
+ const registry = sdk.getRegistry({ package: "cli" });
1840
1840
  registry.functions.forEach((fnInfo) => {
1841
1841
  if (!fnInfo.inputSchema && !fnInfo.inputParameters) {
1842
1842
  console.warn(`Schema not found for ${fnInfo.name}`);
1843
1843
  return;
1844
1844
  }
1845
1845
  const cliCommandName = methodNameToCliCommand(fnInfo.name);
1846
- const config2 = createCommandConfig(cliCommandName, fnInfo, sdk2);
1846
+ const config2 = createCommandConfig(cliCommandName, fnInfo, sdk);
1847
1847
  addCommand(program2, cliCommandName, config2);
1848
1848
  });
1849
1849
  program2.configureHelp({
@@ -1907,7 +1907,7 @@ function generateCliCommands(program2, sdk2) {
1907
1907
  }
1908
1908
  });
1909
1909
  }
1910
- function createCommandConfig(cliCommandName, functionInfo, sdk2) {
1910
+ function createCommandConfig(cliCommandName, functionInfo, sdk) {
1911
1911
  const usesInputParameters = !functionInfo.inputSchema && !!functionInfo.inputParameters;
1912
1912
  const schema = functionInfo.inputSchema;
1913
1913
  const parameters = usesInputParameters ? analyzeInputParameters(functionInfo.inputParameters, functionInfo) : analyzeZodSchema(schema, functionInfo);
@@ -1965,7 +1965,7 @@ function createCommandConfig(cliCommandName, functionInfo, sdk2) {
1965
1965
  resolvedParams = await resolver.resolveParameters(
1966
1966
  schema,
1967
1967
  rawParams,
1968
- sdk2,
1968
+ sdk,
1969
1969
  functionInfo.name,
1970
1970
  {
1971
1971
  interactiveMode,
@@ -1988,7 +1988,7 @@ function createCommandConfig(cliCommandName, functionInfo, sdk2) {
1988
1988
  }
1989
1989
  confirmMessageAfter = confirmResult.messageAfter;
1990
1990
  }
1991
- const sdkMethod = sdk2[functionInfo.name];
1991
+ const sdkMethod = sdk[functionInfo.name];
1992
1992
  switch (outputMode) {
1993
1993
  case "paginate": {
1994
1994
  const source = sdkMethod(resolvedParams);
@@ -2080,7 +2080,7 @@ ${confirmMessageAfter}`));
2080
2080
  selected_api: resolvedParams.app ?? null
2081
2081
  }
2082
2082
  });
2083
- sdk2.context.eventEmission.emit(
2083
+ sdk.context.eventEmission.emit(
2084
2084
  CLI_COMMAND_EXECUTED_EVENT_SUBJECT,
2085
2085
  event
2086
2086
  );
@@ -3099,24 +3099,24 @@ function toPkceCredentials(credentials2) {
3099
3099
  return void 0;
3100
3100
  }
3101
3101
  var loginPlugin = zapierSdk.definePlugin(
3102
- (sdk2) => zapierSdk.createPluginMethod(sdk2, {
3102
+ (sdk) => zapierSdk.createPluginMethod(sdk, {
3103
3103
  name: "login",
3104
3104
  categories: ["account"],
3105
3105
  inputSchema: LoginSchema,
3106
3106
  supportsJsonOutput: false,
3107
- handler: async ({ sdk: sdk3, options }) => {
3107
+ handler: async ({ sdk: sdk2, options }) => {
3108
3108
  const timeoutSeconds = options.timeout ? parseInt(options.timeout, 10) : 300;
3109
3109
  if (isNaN(timeoutSeconds) || timeoutSeconds <= 0) {
3110
3110
  throw new Error("Timeout must be a positive number");
3111
3111
  }
3112
- const resolvedCredentials = await sdk3.context.resolveCredentials();
3112
+ const resolvedCredentials = await sdk2.context.resolveCredentials();
3113
3113
  const pkceCredentials = toPkceCredentials(resolvedCredentials);
3114
3114
  await login_default({
3115
3115
  timeoutMs: timeoutSeconds * 1e3,
3116
3116
  credentials: pkceCredentials
3117
3117
  });
3118
3118
  const user = await getLoggedInUser();
3119
- sdk3.context.eventEmission.emit(
3119
+ sdk2.context.eventEmission.emit(
3120
3120
  "platform.sdk.ApplicationLifecycleEvent",
3121
3121
  zapierSdk.buildApplicationLifecycleEvent(
3122
3122
  { lifecycle_event_type: "login_success" },
@@ -3131,7 +3131,7 @@ var LogoutSchema = zod.z.object({}).describe("Log out of your Zapier account");
3131
3131
 
3132
3132
  // src/plugins/logout/index.ts
3133
3133
  var logoutPlugin = zapierSdk.definePlugin(
3134
- (sdk2) => zapierSdk.createPluginMethod(sdk2, {
3134
+ (sdk) => zapierSdk.createPluginMethod(sdk, {
3135
3135
  name: "logout",
3136
3136
  categories: ["account"],
3137
3137
  inputSchema: LogoutSchema,
@@ -3148,12 +3148,16 @@ var McpSchema = zod.z.object({
3148
3148
 
3149
3149
  // src/plugins/mcp/index.ts
3150
3150
  var mcpPlugin = zapierSdk.definePlugin(
3151
- (sdk2) => zapierSdk.createPluginMethod(sdk2, {
3151
+ (sdk) => zapierSdk.createPluginMethod(sdk, {
3152
3152
  name: "mcp",
3153
3153
  categories: ["utility"],
3154
3154
  inputSchema: McpSchema,
3155
- handler: async ({ sdk: sdk3, options }) => {
3156
- await zapierSdkMcp.startMcpServer({ ...options, debug: sdk3.context.options?.debug });
3155
+ handler: async ({ sdk: sdk2, options }) => {
3156
+ await zapierSdkMcp.startMcpServer({
3157
+ ...options,
3158
+ debug: sdk2.context.options?.debug,
3159
+ extensions: sdk2.context.extensions
3160
+ });
3157
3161
  }
3158
3162
  })
3159
3163
  );
@@ -3168,7 +3172,7 @@ var BundleCodeSchema = zod.z.object({
3168
3172
  cjs: zod.z.boolean().optional().describe("Output CommonJS format instead of ESM")
3169
3173
  }).describe("Bundle TypeScript code into executable JavaScript");
3170
3174
  var bundleCodePlugin = zapierSdk.definePlugin(
3171
- (sdk2) => zapierSdk.createPluginMethod(sdk2, {
3175
+ (sdk) => zapierSdk.createPluginMethod(sdk, {
3172
3176
  name: "bundleCode",
3173
3177
  categories: ["utility", "deprecated"],
3174
3178
  inputSchema: BundleCodeSchema,
@@ -3242,7 +3246,7 @@ async function bundleCode(options) {
3242
3246
  }
3243
3247
  var GetLoginConfigPathSchema = zod.z.object({}).describe("Show the path to the login configuration file");
3244
3248
  var getLoginConfigPathPlugin = zapierSdk.definePlugin(
3245
- (sdk2) => zapierSdk.createPluginMethod(sdk2, {
3249
+ (sdk) => zapierSdk.createPluginMethod(sdk, {
3246
3250
  name: "getLoginConfigPath",
3247
3251
  categories: ["utility"],
3248
3252
  inputSchema: GetLoginConfigPathSchema,
@@ -3277,11 +3281,11 @@ async function detectTypesOutputDirectory() {
3277
3281
  return "./zapier/apps/";
3278
3282
  }
3279
3283
  var addPlugin = zapierSdk.definePlugin(
3280
- (sdk2) => zapierSdk.createPluginMethod(sdk2, {
3284
+ (sdk) => zapierSdk.createPluginMethod(sdk, {
3281
3285
  name: "add",
3282
3286
  categories: ["utility"],
3283
3287
  inputSchema: AddSchema,
3284
- handler: async ({ sdk: sdk3, options }) => {
3288
+ handler: async ({ sdk: sdk2, options }) => {
3285
3289
  const {
3286
3290
  apps: appKeys,
3287
3291
  connections: connectionIds,
@@ -3352,13 +3356,13 @@ var addPlugin = zapierSdk.definePlugin(
3352
3356
  break;
3353
3357
  }
3354
3358
  };
3355
- const manifestResult = await sdk3.buildManifest({
3359
+ const manifestResult = await sdk2.buildManifest({
3356
3360
  apps: appKeys,
3357
3361
  skipWrite: false,
3358
3362
  configPath,
3359
3363
  onProgress: handleManifestProgress
3360
3364
  });
3361
- const typesResult = await sdk3.generateAppTypes({
3365
+ const typesResult = await sdk2.generateAppTypes({
3362
3366
  apps: appKeys,
3363
3367
  connections: connectionIds,
3364
3368
  skipWrite: false,
@@ -3404,14 +3408,14 @@ var AstTypeGenerator = class {
3404
3408
  * Generate TypeScript types using AST for a specific app
3405
3409
  */
3406
3410
  async generateTypes(options) {
3407
- const { app, connectionId, sdk: sdk2 } = options;
3408
- const actionsResult = await sdk2.listActions({
3411
+ const { app, connectionId, sdk } = options;
3412
+ const actionsResult = await sdk.listActions({
3409
3413
  appKey: app.implementation_id
3410
3414
  });
3411
3415
  const actions = actionsResult.data;
3412
3416
  const actionsWithFields = [];
3413
3417
  const inputFieldsTasks = actions.map(
3414
- (action) => () => sdk2.listInputFields({
3418
+ (action) => () => sdk.listInputFields({
3415
3419
  appKey: app.implementation_id,
3416
3420
  actionKey: action.key,
3417
3421
  actionType: action.action_type,
@@ -3982,13 +3986,13 @@ function createManifestEntry(app) {
3982
3986
  };
3983
3987
  }
3984
3988
  var generateAppTypesPlugin = zapierSdk.definePlugin(
3985
- (sdk2) => zapierSdk.createPluginMethod(sdk2, {
3989
+ (sdk) => zapierSdk.createPluginMethod(sdk, {
3986
3990
  name: "generateAppTypes",
3987
3991
  categories: ["utility"],
3988
3992
  // Cast: schema validates JSON fields only; GenerateAppTypesOptions adds
3989
3993
  // the runtime-only `onProgress` callback (passthrough via createFunction).
3990
3994
  inputSchema: GenerateAppTypesSchema,
3991
- handler: async ({ sdk: sdk3, options }) => {
3995
+ handler: async ({ sdk: sdk2, options }) => {
3992
3996
  const {
3993
3997
  apps: appKeys,
3994
3998
  connections: connectionIds,
@@ -3999,7 +4003,7 @@ var generateAppTypesPlugin = zapierSdk.definePlugin(
3999
4003
  const resolvedTypesOutput = path.resolve(typesOutputDirectory);
4000
4004
  const result = { typeDefinitions: {} };
4001
4005
  onProgress?.({ type: "apps_lookup_start", count: appKeys.length });
4002
- const appsIterable = sdk3.listApps({ apps: appKeys }).items();
4006
+ const appsIterable = sdk2.listApps({ apps: appKeys }).items();
4003
4007
  const apps = [];
4004
4008
  for await (const app of appsIterable) {
4005
4009
  apps.push(app);
@@ -4015,7 +4019,7 @@ var generateAppTypesPlugin = zapierSdk.definePlugin(
4015
4019
  type: "connections_lookup_start",
4016
4020
  count: connectionIds.length
4017
4021
  });
4018
- const connectionsIterable = sdk3.listConnections({ connections: connectionIds }).items();
4022
+ const connectionsIterable = sdk2.listConnections({ connections: connectionIds }).items();
4019
4023
  for await (const connection of connectionsIterable) {
4020
4024
  connections.push(connection);
4021
4025
  }
@@ -4076,7 +4080,7 @@ var generateAppTypesPlugin = zapierSdk.definePlugin(
4076
4080
  const typeDefinitionString = await generator.generateTypes({
4077
4081
  app,
4078
4082
  connectionId,
4079
- sdk: sdk3
4083
+ sdk: sdk2
4080
4084
  });
4081
4085
  result.typeDefinitions[manifestKey] = typeDefinitionString;
4082
4086
  onProgress?.({
@@ -4124,7 +4128,7 @@ var BuildManifestSchema = zod.z.object({
4124
4128
 
4125
4129
  // src/plugins/buildManifest/index.ts
4126
4130
  var buildManifestPlugin = zapierSdk.definePlugin(
4127
- (sdk2) => zapierSdk.createPluginMethod(sdk2, {
4131
+ (sdk) => zapierSdk.createPluginMethod(sdk, {
4128
4132
  name: "buildManifest",
4129
4133
  categories: ["utility"],
4130
4134
  // Cast: BuildManifestSchema validates JSON-serializable fields only.
@@ -4132,7 +4136,7 @@ var buildManifestPlugin = zapierSdk.definePlugin(
4132
4136
  // `createFunction`'s passthrough spread at runtime; this widens TInput
4133
4137
  // so the handler can read it.
4134
4138
  inputSchema: BuildManifestSchema,
4135
- handler: async ({ sdk: sdk3, options }) => {
4139
+ handler: async ({ sdk: sdk2, options }) => {
4136
4140
  const {
4137
4141
  apps: appKeys,
4138
4142
  skipWrite = false,
@@ -4140,7 +4144,7 @@ var buildManifestPlugin = zapierSdk.definePlugin(
4140
4144
  onProgress
4141
4145
  } = options;
4142
4146
  onProgress?.({ type: "apps_lookup_start", count: appKeys.length });
4143
- const appsIterable = sdk3.listApps({ apps: appKeys }).items();
4147
+ const appsIterable = sdk2.listApps({ apps: appKeys }).items();
4144
4148
  const apps = [];
4145
4149
  for await (const app of appsIterable) {
4146
4150
  apps.push(app);
@@ -4165,7 +4169,7 @@ var buildManifestPlugin = zapierSdk.definePlugin(
4165
4169
  manifestKey: manifestEntry.implementationName,
4166
4170
  version: manifestEntry.version || ""
4167
4171
  });
4168
- const { key: updatedManifestKey, manifest } = await sdk3.context.updateManifestEntry({
4172
+ const { key: updatedManifestKey, manifest } = await sdk2.context.updateManifestEntry({
4169
4173
  appKey: app.key,
4170
4174
  entry: manifestEntry,
4171
4175
  configPath,
@@ -4231,12 +4235,12 @@ async function postWithRetry({
4231
4235
  return response;
4232
4236
  }
4233
4237
  var feedbackPlugin = zapierSdk.definePlugin(
4234
- (sdk2) => zapierSdk.createPluginMethod(sdk2, {
4238
+ (sdk) => zapierSdk.createPluginMethod(sdk, {
4235
4239
  name: "feedback",
4236
4240
  categories: ["utility"],
4237
4241
  inputSchema: FeedbackSchema,
4238
4242
  resolvers: { feedback: feedbackResolver },
4239
- handler: async ({ sdk: sdk3, options }) => {
4243
+ handler: async ({ sdk: sdk2, options }) => {
4240
4244
  const user = await getLoggedInUser();
4241
4245
  const body = JSON.stringify({
4242
4246
  email: user.email,
@@ -4247,7 +4251,7 @@ var feedbackPlugin = zapierSdk.definePlugin(
4247
4251
  body,
4248
4252
  attemptsLeft: MAX_RETRIES
4249
4253
  });
4250
- if (sdk3.context.options?.debug) {
4254
+ if (sdk2.context.options?.debug) {
4251
4255
  const text = await response.text();
4252
4256
  console.error("[debug] Webhook response:", text);
4253
4257
  }
@@ -4430,7 +4434,7 @@ async function buildFormData(formArgs, formStringArgs) {
4430
4434
  }
4431
4435
 
4432
4436
  // src/plugins/curl/index.ts
4433
- var curlPlugin = zapierSdk.definePlugin((sdk2) => {
4437
+ var curlPlugin = zapierSdk.definePlugin((sdk) => {
4434
4438
  async function curl(options) {
4435
4439
  const {
4436
4440
  url: rawUrl,
@@ -4563,7 +4567,7 @@ var curlPlugin = zapierSdk.definePlugin((sdk2) => {
4563
4567
  process.stderr.write(">\n");
4564
4568
  }
4565
4569
  const start = performance.now();
4566
- const response = await sdk2.fetch(effectiveUrl.toString(), {
4570
+ const response = await sdk.fetch(effectiveUrl.toString(), {
4567
4571
  method,
4568
4572
  headers,
4569
4573
  body,
@@ -4675,13 +4679,13 @@ ${Array.from(
4675
4679
  };
4676
4680
  });
4677
4681
  var cliOverridesPlugin = zapierSdk.definePlugin(
4678
- (sdk2) => {
4682
+ (sdk) => {
4679
4683
  const meta = {};
4680
- if (sdk2.context.meta.fetch) {
4684
+ if (sdk.context.meta.fetch) {
4681
4685
  meta.fetch = {
4682
- ...sdk2.context.meta.fetch,
4686
+ ...sdk.context.meta.fetch,
4683
4687
  categories: [
4684
- ...sdk2.context.meta.fetch.categories || [],
4688
+ ...sdk.context.meta.fetch.categories || [],
4685
4689
  "deprecated"
4686
4690
  ],
4687
4691
  deprecation: {
@@ -5131,7 +5135,7 @@ function displaySummaryAndNextSteps({
5131
5135
 
5132
5136
  // src/plugins/init/index.ts
5133
5137
  var initPlugin = zapierSdk.definePlugin(
5134
- (sdk2) => zapierSdk.createPluginMethod(sdk2, {
5138
+ (sdk) => zapierSdk.createPluginMethod(sdk, {
5135
5139
  name: "init",
5136
5140
  categories: ["utility"],
5137
5141
  inputSchema: InitSchema,
@@ -5188,16 +5192,78 @@ var initPlugin = zapierSdk.definePlugin(
5188
5192
  // package.json with { type: 'json' }
5189
5193
  var package_default2 = {
5190
5194
  name: "@zapier/zapier-sdk-cli",
5191
- version: "0.43.3"};
5195
+ version: "0.44.0"};
5192
5196
 
5193
5197
  // src/sdk.ts
5194
5198
  zapierSdk.injectCliLogin(login_exports);
5195
5199
  function createZapierCliSdk(options = {}) {
5196
- return zapierSdk.createZapierSdk({
5197
- ...options,
5198
- eventEmission: { ...options.eventEmission, callContext: "cli" },
5200
+ const { extensions = [], ...sdkOptions } = options;
5201
+ const extensionsContextPlugin = () => ({
5202
+ context: { extensions }
5203
+ });
5204
+ let chain = zapierSdk.createZapierSdk({
5205
+ ...sdkOptions,
5206
+ eventEmission: { ...sdkOptions.eventEmission, callContext: "cli" },
5199
5207
  callerPackage: { name: package_default2.name, version: package_default2.version }
5200
- }).addPlugin(generateAppTypesPlugin).addPlugin(buildManifestPlugin).addPlugin(bundleCodePlugin).addPlugin(getLoginConfigPathPlugin).addPlugin(addPlugin).addPlugin(feedbackPlugin).addPlugin(curlPlugin).addPlugin(initPlugin).addPlugin(mcpPlugin).addPlugin(loginPlugin).addPlugin(logoutPlugin).addPlugin(cliOverridesPlugin);
5208
+ }).addPlugin(extensionsContextPlugin).addPlugin(generateAppTypesPlugin).addPlugin(buildManifestPlugin).addPlugin(bundleCodePlugin).addPlugin(getLoginConfigPathPlugin).addPlugin(addPlugin).addPlugin(feedbackPlugin).addPlugin(curlPlugin).addPlugin(initPlugin).addPlugin(mcpPlugin).addPlugin(loginPlugin).addPlugin(logoutPlugin).addPlugin(cliOverridesPlugin);
5209
+ for (const ext of extensions) {
5210
+ try {
5211
+ chain = chain.addPlugin(ext);
5212
+ } catch (err) {
5213
+ console.warn(
5214
+ `Extension plugin failed to construct: ${err.message}; skipping.`
5215
+ );
5216
+ }
5217
+ }
5218
+ return chain;
5219
+ }
5220
+
5221
+ // src/utils/extensions.ts
5222
+ var ENV_VAR = "ZAPIER_SDK_EXTENSIONS";
5223
+ async function resolveExtensions() {
5224
+ const seen = /* @__PURE__ */ new Set();
5225
+ const specs = readEnvSpecs().filter((spec) => {
5226
+ if (seen.has(spec)) return false;
5227
+ seen.add(spec);
5228
+ return true;
5229
+ });
5230
+ const plugins = [];
5231
+ for (const spec of specs) {
5232
+ try {
5233
+ const mod = await import(spec);
5234
+ const exported = mod.default ?? mod;
5235
+ const got = normalizeExtension(exported);
5236
+ if (got) {
5237
+ plugins.push(...got);
5238
+ } else {
5239
+ console.warn(
5240
+ `Extension '${spec}': unrecognized default export shape; skipping.`
5241
+ );
5242
+ }
5243
+ } catch (err) {
5244
+ console.warn(
5245
+ `Extension '${spec}' failed to load: ${err.message}`
5246
+ );
5247
+ }
5248
+ }
5249
+ return plugins;
5250
+ }
5251
+ function normalizeExtension(exported) {
5252
+ if (typeof exported === "function") {
5253
+ return [exported];
5254
+ }
5255
+ if (Array.isArray(exported)) {
5256
+ if (exported.every((e) => typeof e === "function")) {
5257
+ return exported;
5258
+ }
5259
+ return null;
5260
+ }
5261
+ return null;
5262
+ }
5263
+ function readEnvSpecs() {
5264
+ const raw = process.env[ENV_VAR];
5265
+ if (!raw) return [];
5266
+ return raw.split(",").map((s) => s.trim()).filter((s) => s.length > 0);
5201
5267
  }
5202
5268
  var ONE_DAY_MS = 24 * 60 * 60 * 1e3;
5203
5269
  var CACHE_RESET_INTERVAL_MS = (() => {
@@ -5428,19 +5494,21 @@ for (const { camelName, kebabFlag } of booleanFlags) {
5428
5494
  flagOverrides[camelName] = true;
5429
5495
  }
5430
5496
  }
5431
- var sdk = createZapierCliSdk({
5432
- debug: isDebugMode,
5433
- credentials,
5434
- baseUrl,
5435
- trackingBaseUrl,
5436
- maxNetworkRetries,
5437
- maxNetworkRetryDelayMs,
5438
- ...flagOverrides
5439
- });
5440
- generateCliCommands(program, sdk);
5441
5497
  program.exitOverride();
5442
5498
  (async () => {
5443
5499
  let exitCode = 0;
5500
+ const extensions = await resolveExtensions();
5501
+ const sdk = createZapierCliSdk({
5502
+ debug: isDebugMode,
5503
+ credentials,
5504
+ baseUrl,
5505
+ trackingBaseUrl,
5506
+ maxNetworkRetries,
5507
+ maxNetworkRetryDelayMs,
5508
+ ...flagOverrides,
5509
+ extensions
5510
+ });
5511
+ generateCliCommands(program, sdk);
5444
5512
  const versionCheckPromise = checkAndNotifyUpdates({
5445
5513
  packageName: package_default2.name,
5446
5514
  currentVersion: package_default2.version