@zapier/zapier-sdk 0.79.0 → 0.80.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.
@@ -51,18 +51,20 @@ function buildRegistry({
51
51
  sdk,
52
52
  meta,
53
53
  formatters,
54
+ boundResolvers,
55
+ positional,
54
56
  packageFilter
55
57
  }) {
56
58
  const definitionsByKey = /* @__PURE__ */ new Map();
57
59
  const objectDeclaredKeys = /* @__PURE__ */ new Set();
58
60
  for (const m of Object.values(meta)) {
59
61
  for (const ref of m.categories ?? []) {
60
- const key = typeof ref === "string" ? ref : ref.key;
62
+ const key2 = typeof ref === "string" ? ref : ref.key;
61
63
  if (typeof ref === "object") {
62
- objectDeclaredKeys.add(key);
63
- definitionsByKey.set(key, resolveCategoryDefinition(ref));
64
- } else if (!objectDeclaredKeys.has(key)) {
65
- definitionsByKey.set(key, resolveCategoryDefinition(ref));
64
+ objectDeclaredKeys.add(key2);
65
+ definitionsByKey.set(key2, resolveCategoryDefinition(ref));
66
+ } else if (!objectDeclaredKeys.has(key2)) {
67
+ definitionsByKey.set(key2, resolveCategoryDefinition(ref));
66
68
  }
67
69
  }
68
70
  }
@@ -70,16 +72,16 @@ function buildRegistry({
70
72
  definitionsByKey.set("other", resolveCategoryDefinition("other"));
71
73
  }
72
74
  const knownCategories = Array.from(definitionsByKey.keys());
73
- const functions = Object.keys(meta).filter((key) => {
74
- const property = sdk[key];
75
+ const functions = Object.keys(meta).filter((key2) => {
76
+ const property = sdk[key2];
75
77
  if (typeof property === "function") return true;
76
- const [rootKey] = key.split(".");
78
+ const [rootKey] = key2.split(".");
77
79
  const rootProperty = sdk[rootKey];
78
80
  return typeof rootProperty === "object" && rootProperty !== null;
79
- }).map((key) => {
80
- const m = meta[key];
81
+ }).map((key2) => {
82
+ const m = meta[key2];
81
83
  return {
82
- name: key,
84
+ name: key2,
83
85
  description: m.description,
84
86
  type: m.type,
85
87
  itemType: m.itemType,
@@ -87,11 +89,13 @@ function buildRegistry({
87
89
  inputSchema: canonicalInputSchema(m.inputSchema),
88
90
  inputParameters: m.inputParameters,
89
91
  outputSchema: m.outputSchema,
92
+ positional: positional?.[key2],
90
93
  categories: (m.categories ?? []).map(
91
94
  (c) => typeof c === "string" ? c : c.key
92
95
  ),
93
96
  resolvers: m.resolvers,
94
- formatter: formatters?.[key],
97
+ boundResolvers: boundResolvers?.[key2],
98
+ formatter: formatters?.[key2],
95
99
  experimental: m.experimental,
96
100
  packages: m.packages,
97
101
  confirm: m.confirm ?? (m.type === "delete" ? "delete" : void 0),
@@ -129,8 +133,8 @@ function composeVoid(existing, added) {
129
133
  }
130
134
  function buildHooks(existing, added) {
131
135
  const result = {};
132
- const start = composeVoid(existing.onMethodStart, added.onMethodStart);
133
- if (start) result.onMethodStart = start;
136
+ const start2 = composeVoid(existing.onMethodStart, added.onMethodStart);
137
+ if (start2) result.onMethodStart = start2;
134
138
  const end = composeVoid(existing.onMethodEnd, added.onMethodEnd);
135
139
  if (end) result.onMethodEnd = end;
136
140
  return result;
@@ -763,11 +767,11 @@ var RESERVED_ROOT_KEYS = /* @__PURE__ */ new Set([
763
767
  "context",
764
768
  "getRegistry"
765
769
  ]);
766
- function hasOwn(obj, key) {
767
- return Object.prototype.hasOwnProperty.call(obj, key);
770
+ function hasOwn(obj, key2) {
771
+ return Object.prototype.hasOwnProperty.call(obj, key2);
768
772
  }
769
- function setOwn(target, key, value) {
770
- Object.defineProperty(target, key, {
773
+ function setOwn(target, key2, value) {
774
+ Object.defineProperty(target, key2, {
771
775
  value,
772
776
  enumerable: true,
773
777
  configurable: true,
@@ -779,31 +783,31 @@ function checkCollisions(target, source, kind, callerLabel, override) {
779
783
  checkRootKeyCollisions(target, Object.keys(source), override, callerLabel);
780
784
  return;
781
785
  }
782
- for (const key of Object.keys(source)) {
783
- if (!override && hasOwn(target, key)) {
786
+ for (const key2 of Object.keys(source)) {
787
+ if (!override && hasOwn(target, key2)) {
784
788
  throw new Error(
785
- `${callerLabel}: duplicate ${kind} "${key}". If the override is intentional, pass { override: true } in the options.`
789
+ `${callerLabel}: duplicate ${kind} "${key2}". If the override is intentional, pass { override: true } in the options.`
786
790
  );
787
791
  }
788
792
  }
789
793
  }
790
794
  function checkRootKeyCollisions(target, keys, override, callerLabel) {
791
- for (const key of keys) {
792
- if (RESERVED_ROOT_KEYS.has(key)) {
795
+ for (const key2 of keys) {
796
+ if (RESERVED_ROOT_KEYS.has(key2)) {
793
797
  throw new Error(
794
- `${callerLabel}: plugin attempted to register reserved root key "${key}". The SDK uses this key for its own accessor; rename the plugin's method.`
798
+ `${callerLabel}: plugin attempted to register reserved root key "${key2}". The SDK uses this key for its own accessor; rename the plugin's method.`
795
799
  );
796
800
  }
797
- if (!override && hasOwn(target, key)) {
801
+ if (!override && hasOwn(target, key2)) {
798
802
  throw new Error(
799
- `${callerLabel}: duplicate root key "${key}". If the override is intentional, pass { override: true } in the options.`
803
+ `${callerLabel}: duplicate root key "${key2}". If the override is intentional, pass { override: true } in the options.`
800
804
  );
801
805
  }
802
806
  }
803
807
  }
804
808
  function applyOwnProperties(target, source) {
805
- for (const key of Object.keys(source)) {
806
- setOwn(target, key, source[key]);
809
+ for (const key2 of Object.keys(source)) {
810
+ setOwn(target, key2, source[key2]);
807
811
  }
808
812
  }
809
813
  function createPluginAccumulator(initialProperties = {}, initialContext = {}) {
@@ -1051,8 +1055,8 @@ function normalizeImports(deps) {
1051
1055
  }
1052
1056
  function collectLeafMeta(config) {
1053
1057
  let meta;
1054
- for (const key of LEAF_META_KEYS) {
1055
- if (config[key] !== void 0) (meta ?? (meta = {}))[key] = config[key];
1058
+ for (const key2 of LEAF_META_KEYS) {
1059
+ if (config[key2] !== void 0) (meta ?? (meta = {}))[key2] = config[key2];
1056
1060
  }
1057
1061
  return meta;
1058
1062
  }
@@ -1075,12 +1079,66 @@ function defineMethod(config) {
1075
1079
  run: config.run
1076
1080
  };
1077
1081
  }
1082
+ function defineResolver(config) {
1083
+ const deps = normalizeImports(config.imports);
1084
+ const base = { imports: deps.plugins, importBindings: deps.bindings };
1085
+ const gates = {
1086
+ requireParameters: config.requireParameters
1087
+ };
1088
+ switch (config.type) {
1089
+ case "static":
1090
+ return {
1091
+ ...base,
1092
+ ...gates,
1093
+ type: "static",
1094
+ inputType: config.inputType,
1095
+ placeholder: config.placeholder
1096
+ };
1097
+ case "constant":
1098
+ return { ...base, ...gates, type: "constant", value: config.value };
1099
+ case "info":
1100
+ return { ...base, type: "info", text: config.text ?? "" };
1101
+ case "object":
1102
+ return {
1103
+ ...base,
1104
+ ...gates,
1105
+ type: "object",
1106
+ properties: config.properties,
1107
+ definitions: config.definitions,
1108
+ getProperties: config.getProperties
1109
+ };
1110
+ case "array":
1111
+ return {
1112
+ ...base,
1113
+ ...gates,
1114
+ type: "array",
1115
+ items: config.items,
1116
+ minItems: config.minItems,
1117
+ maxItems: config.maxItems,
1118
+ itemValueType: config.itemValueType,
1119
+ definitions: config.definitions
1120
+ };
1121
+ default:
1122
+ return {
1123
+ ...base,
1124
+ ...gates,
1125
+ type: "dynamic",
1126
+ inputType: config.inputType,
1127
+ placeholder: config.placeholder,
1128
+ getContext: config.getContext,
1129
+ listItems: config.listItems,
1130
+ prompt: config.prompt,
1131
+ tryResolveWithoutPrompt: config.tryResolveWithoutPrompt,
1132
+ tryResolveFromSearch: config.tryResolveFromSearch
1133
+ };
1134
+ }
1135
+ }
1078
1136
  function defineFormatter(config) {
1079
1137
  const deps = normalizeImports(config.imports);
1080
1138
  return {
1081
1139
  imports: deps.plugins,
1082
1140
  importBindings: deps.bindings,
1083
- fetchContext: config.fetchContext,
1141
+ getContext: config.getContext,
1084
1142
  format: config.format
1085
1143
  };
1086
1144
  }
@@ -1209,7 +1267,7 @@ function legacyGraphEntry(name, value, pluginMeta) {
1209
1267
  function adaptLegacyFormatter(legacy, sdk) {
1210
1268
  const legacyFetch = legacy.fetch;
1211
1269
  return {
1212
- fetchContext: legacyFetch ? async ({ items, input, context }) => {
1270
+ getContext: legacyFetch ? async ({ items, input, context }) => {
1213
1271
  let ctx = context;
1214
1272
  for (const item of items) {
1215
1273
  ctx = await legacyFetch(sdk, input, item, ctx);
@@ -1225,6 +1283,14 @@ function normalizeFormatter(entry, sdk) {
1225
1283
  const legacy = entry.meta?.formatter;
1226
1284
  return legacy ? adaptLegacyFormatter(legacy, sdk) : void 0;
1227
1285
  }
1286
+ function normalizeBoundResolvers(entry) {
1287
+ if (entry.pluginType !== "method") return void 0;
1288
+ return entry.resolvers;
1289
+ }
1290
+ function methodPositional(entry) {
1291
+ if (entry.pluginType !== "method") return void 0;
1292
+ return entry.positional;
1293
+ }
1228
1294
  function pluginEntryMeta(entry) {
1229
1295
  if (entry.pluginType === "method" && entry.meta) {
1230
1296
  return entry.inputSchema ? { ...entry.meta, inputSchema: entry.inputSchema } : entry.meta;
@@ -1245,11 +1311,24 @@ function buildSurfaceRegistry(context, packageFilter) {
1245
1311
  if (m) meta[binding] = m;
1246
1312
  }
1247
1313
  const formatters = {};
1314
+ const boundResolvers = {};
1315
+ const positional = {};
1248
1316
  for (const [binding, entry] of Object.entries(entries)) {
1249
1317
  const f = normalizeFormatter(entry, surface);
1250
1318
  if (f) formatters[binding] = f;
1251
- }
1252
- return buildRegistry({ sdk: surface, meta, formatters, packageFilter });
1319
+ const r = normalizeBoundResolvers(entry);
1320
+ if (r) boundResolvers[binding] = r;
1321
+ const p = methodPositional(entry);
1322
+ if (p) positional[binding] = p;
1323
+ }
1324
+ return buildRegistry({
1325
+ sdk: surface,
1326
+ meta,
1327
+ formatters,
1328
+ boundResolvers,
1329
+ positional,
1330
+ packageFilter
1331
+ });
1253
1332
  }
1254
1333
  var dangerousContextPlugin = {
1255
1334
  pluginType: "property",
@@ -1366,15 +1445,15 @@ function collectPlugins(root, materialized = /* @__PURE__ */ new Set()) {
1366
1445
  }
1367
1446
  return byId;
1368
1447
  }
1369
- function bindValue(target, key, entry) {
1448
+ function bindValue(target, key2, entry) {
1370
1449
  if (entry.pluginType === "property" && entry.getValue) {
1371
- Object.defineProperty(target, key, {
1450
+ Object.defineProperty(target, key2, {
1372
1451
  get: entry.getValue,
1373
1452
  enumerable: true,
1374
1453
  configurable: true
1375
1454
  });
1376
1455
  } else {
1377
- Object.defineProperty(target, key, {
1456
+ Object.defineProperty(target, key2, {
1378
1457
  value: entry.value,
1379
1458
  writable: true,
1380
1459
  enumerable: true,
@@ -1426,8 +1505,7 @@ function bindResolver(resolver, plugins) {
1426
1505
  case "static":
1427
1506
  return {
1428
1507
  type: "static",
1429
- requireParams: resolver.requireParams,
1430
- requireCapabilities: resolver.requireCapabilities,
1508
+ requireParameters: resolver.requireParameters,
1431
1509
  inputType: resolver.inputType,
1432
1510
  placeholder: resolver.placeholder
1433
1511
  };
@@ -1435,8 +1513,7 @@ function bindResolver(resolver, plugins) {
1435
1513
  return {
1436
1514
  type: "constant",
1437
1515
  value: resolver.value,
1438
- requireParams: resolver.requireParams,
1439
- requireCapabilities: resolver.requireCapabilities
1516
+ requireParameters: resolver.requireParameters
1440
1517
  };
1441
1518
  case "info":
1442
1519
  return { type: "info", text: resolver.text };
@@ -1444,24 +1521,24 @@ function bindResolver(resolver, plugins) {
1444
1521
  const imports = buildImports(plugins, resolver.importBindings);
1445
1522
  const bound = {
1446
1523
  type: "object",
1447
- requireParams: resolver.requireParams,
1448
- requireCapabilities: resolver.requireCapabilities
1524
+ requireParameters: resolver.requireParameters
1449
1525
  };
1450
1526
  if (resolver.properties)
1451
1527
  bound.properties = bindFields(resolver.properties, plugins);
1452
1528
  if (resolver.definitions)
1453
1529
  bound.definitions = bindDefinitions(resolver.definitions, plugins);
1454
- const { fetch: fetch2 } = resolver;
1455
- if (fetch2) bound.fetch = ({ params }) => fetch2({ imports, params });
1530
+ const { getProperties } = resolver;
1531
+ if (getProperties)
1532
+ bound.getProperties = ({ input }) => getProperties({ imports, input });
1456
1533
  return bound;
1457
1534
  }
1458
1535
  case "array": {
1459
1536
  const bound = {
1460
1537
  type: "array",
1461
- requireParams: resolver.requireParams,
1462
- requireCapabilities: resolver.requireCapabilities,
1538
+ requireParameters: resolver.requireParameters,
1463
1539
  minItems: resolver.minItems,
1464
1540
  maxItems: resolver.maxItems,
1541
+ itemValueType: resolver.itemValueType,
1465
1542
  items: isResolverRef(resolver.items) ? resolver.items : bindResolver(resolver.items, plugins)
1466
1543
  };
1467
1544
  if (resolver.definitions)
@@ -1472,17 +1549,26 @@ function bindResolver(resolver, plugins) {
1472
1549
  const imports = buildImports(plugins, resolver.importBindings);
1473
1550
  const bound = {
1474
1551
  type: "dynamic",
1475
- requireParams: resolver.requireParams,
1476
- requireCapabilities: resolver.requireCapabilities,
1552
+ requireParameters: resolver.requireParameters,
1477
1553
  inputType: resolver.inputType,
1478
1554
  placeholder: resolver.placeholder,
1479
1555
  prompt: resolver.prompt
1480
1556
  };
1481
- const { fetch: fetch2, tryResolveWithoutPrompt } = resolver;
1482
- if (fetch2)
1483
- bound.fetch = ({ params, search }) => fetch2({ imports, params, search });
1557
+ const {
1558
+ getContext: getContext2,
1559
+ listItems,
1560
+ tryResolveWithoutPrompt,
1561
+ tryResolveFromSearch
1562
+ } = resolver;
1563
+ if (getContext2)
1564
+ bound.getContext = ({ input }) => getContext2({ imports, input });
1565
+ if (listItems)
1566
+ bound.listItems = ({ input, context, search, cursor }) => listItems({ imports, input, context, search, cursor });
1484
1567
  if (tryResolveWithoutPrompt) {
1485
- bound.tryResolveWithoutPrompt = ({ params }) => tryResolveWithoutPrompt({ imports, params });
1568
+ bound.tryResolveWithoutPrompt = ({ input }) => tryResolveWithoutPrompt({ imports, input });
1569
+ }
1570
+ if (tryResolveFromSearch) {
1571
+ bound.tryResolveFromSearch = ({ input, search }) => tryResolveFromSearch({ imports, input, search });
1486
1572
  }
1487
1573
  return bound;
1488
1574
  }
@@ -1490,8 +1576,8 @@ function bindResolver(resolver, plugins) {
1490
1576
  }
1491
1577
  function bindFields(fields, plugins) {
1492
1578
  const out = {};
1493
- for (const [key, field] of Object.entries(fields)) {
1494
- out[key] = {
1579
+ for (const [key2, field] of Object.entries(fields)) {
1580
+ out[key2] = {
1495
1581
  ...field,
1496
1582
  resolver: isResolverRef(field.resolver) ? field.resolver : bindResolver(field.resolver, plugins)
1497
1583
  };
@@ -1500,17 +1586,17 @@ function bindFields(fields, plugins) {
1500
1586
  }
1501
1587
  function bindDefinitions(definitions, plugins) {
1502
1588
  const out = {};
1503
- for (const [key, def] of Object.entries(definitions)) {
1504
- out[key] = bindResolver(def, plugins);
1589
+ for (const [key2, def] of Object.entries(definitions)) {
1590
+ out[key2] = bindResolver(def, plugins);
1505
1591
  }
1506
1592
  return out;
1507
1593
  }
1508
1594
  function bindFormatter(formatter, plugins) {
1509
1595
  const imports = buildImports(plugins, formatter.importBindings);
1510
1596
  const bound = { format: formatter.format };
1511
- const { fetchContext } = formatter;
1512
- if (fetchContext)
1513
- bound.fetchContext = ({ items, input, context }) => fetchContext({ imports, items, input, context });
1597
+ const { getContext: getContext2 } = formatter;
1598
+ if (getContext2)
1599
+ bound.getContext = ({ items, input, context }) => getContext2({ imports, items, input, context });
1514
1600
  return bound;
1515
1601
  }
1516
1602
  function bindAttachments(descriptors, context) {
@@ -1558,6 +1644,7 @@ function runLegacyPass(descriptors, context) {
1558
1644
  const sdk = this ?? exports;
1559
1645
  const meta2 = {};
1560
1646
  const formatters = {};
1647
+ const boundResolvers = {};
1561
1648
  for (const [binding, id2] of Object.entries(context.surface)) {
1562
1649
  const entry = context.plugins[id2];
1563
1650
  if (!entry || entry.pluginType === "aggregate") continue;
@@ -1565,12 +1652,15 @@ function runLegacyPass(descriptors, context) {
1565
1652
  if (m) meta2[binding] = m;
1566
1653
  const f = normalizeFormatter(entry, sdk);
1567
1654
  if (f) formatters[binding] = f;
1655
+ const r = normalizeBoundResolvers(entry);
1656
+ if (r) boundResolvers[binding] = r;
1568
1657
  }
1569
1658
  Object.assign(meta2, context.meta);
1570
1659
  return buildRegistry({
1571
1660
  sdk,
1572
1661
  meta: meta2,
1573
1662
  formatters,
1663
+ boundResolvers,
1574
1664
  packageFilter: options?.package
1575
1665
  });
1576
1666
  };
@@ -1786,7 +1876,7 @@ function createSdk(root) {
1786
1876
  pluginSurface = {};
1787
1877
  bindValue(pluginSurface, plugin.name, plugins2[plugin.id]);
1788
1878
  }
1789
- for (const key of Object.keys(legacyExports)) context.surface[key] = key;
1879
+ for (const key2 of Object.keys(legacyExports)) context.surface[key2] = key2;
1790
1880
  if (plugin.pluginType === "aggregate") {
1791
1881
  recordExportSurface(context, plugin.exports);
1792
1882
  } else {
@@ -1856,6 +1946,756 @@ function addPlugin(sdk, plugin, options) {
1856
1946
  options ?? {}
1857
1947
  );
1858
1948
  }
1949
+ var CORE_SIGNAL_SYMBOL = Symbol.for("kitcore.signal");
1950
+ var CoreSignal = class extends Error {
1951
+ constructor(message) {
1952
+ super(message);
1953
+ Object.setPrototypeOf(this, new.target.prototype);
1954
+ Object.defineProperty(this, CORE_SIGNAL_SYMBOL, {
1955
+ value: true,
1956
+ enumerable: false,
1957
+ configurable: true,
1958
+ writable: false
1959
+ });
1960
+ }
1961
+ };
1962
+ function isCoreSignal(value) {
1963
+ return Boolean(
1964
+ value && typeof value === "object" && value[CORE_SIGNAL_SYMBOL] === true
1965
+ );
1966
+ }
1967
+ var CoreCancelledSignal = class extends CoreSignal {
1968
+ constructor(message = "resolution cancelled") {
1969
+ super(message);
1970
+ this.name = "CoreCancelledSignal";
1971
+ this.code = "CANCELLED";
1972
+ }
1973
+ };
1974
+ function unwrap(schema) {
1975
+ let inner = schema;
1976
+ let required = true;
1977
+ for (; ; ) {
1978
+ if (inner instanceof z.ZodOptional) {
1979
+ required = false;
1980
+ inner = inner._zod.def.innerType;
1981
+ } else if (inner instanceof z.ZodDefault) {
1982
+ required = false;
1983
+ inner = inner._zod.def.innerType;
1984
+ } else if (inner instanceof z.ZodNullable) {
1985
+ inner = inner._zod.def.innerType;
1986
+ } else {
1987
+ break;
1988
+ }
1989
+ }
1990
+ return { inner, required };
1991
+ }
1992
+ function valueTypeOf(inner) {
1993
+ if (inner instanceof z.ZodString) return "string";
1994
+ if (inner instanceof z.ZodNumber) return "number";
1995
+ if (inner instanceof z.ZodBoolean) return "boolean";
1996
+ if (inner instanceof z.ZodEnum) return "string";
1997
+ if (inner instanceof z.ZodArray) return "array";
1998
+ if (inner instanceof z.ZodObject) return "object";
1999
+ return void 0;
2000
+ }
2001
+ function staticChoicesOf(inner) {
2002
+ if (inner instanceof z.ZodEnum) {
2003
+ const values = inner.options;
2004
+ return values.map((value) => ({ label: value, value }));
2005
+ }
2006
+ return void 0;
2007
+ }
2008
+ function objectShape(schema) {
2009
+ const { inner } = schema ? unwrap(schema) : { inner: void 0 };
2010
+ if (inner instanceof z.ZodObject) {
2011
+ return inner.shape;
2012
+ }
2013
+ return void 0;
2014
+ }
2015
+ function topoOrder2(specs) {
2016
+ const byName = new Map(specs.map((s) => [s.name, s]));
2017
+ const ordered = [];
2018
+ const placed = /* @__PURE__ */ new Set();
2019
+ let progressed = true;
2020
+ while (ordered.length < specs.length && progressed) {
2021
+ progressed = false;
2022
+ for (const spec of specs) {
2023
+ if (placed.has(spec.name)) continue;
2024
+ const ready = spec.requires.every((r) => !byName.has(r) || placed.has(r));
2025
+ if (ready) {
2026
+ ordered.push(spec);
2027
+ placed.add(spec.name);
2028
+ progressed = true;
2029
+ }
2030
+ }
2031
+ }
2032
+ for (const spec of specs) if (!placed.has(spec.name)) ordered.push(spec);
2033
+ return ordered;
2034
+ }
2035
+ function planParameters(entry) {
2036
+ const shape = objectShape(entry.inputSchema);
2037
+ const resolvers = entry.boundResolvers ?? {};
2038
+ const names = shape ? Object.keys(shape) : Object.keys(resolvers);
2039
+ const specs = names.map((name) => {
2040
+ const field = shape?.[name];
2041
+ const { inner, required } = field ? unwrap(field) : { inner: void 0, required: false };
2042
+ const resolver = resolvers[name];
2043
+ return {
2044
+ name,
2045
+ required,
2046
+ valueType: inner ? valueTypeOf(inner) : void 0,
2047
+ staticChoices: inner ? staticChoicesOf(inner) : void 0,
2048
+ resolver,
2049
+ requires: resolver?.requireParameters ?? []
2050
+ };
2051
+ });
2052
+ return { parameters: topoOrder2(specs) };
2053
+ }
2054
+ function getAtPath(root, path) {
2055
+ let node = root;
2056
+ for (const seg of path) {
2057
+ if (node == null || typeof node !== "object") return void 0;
2058
+ node = node[seg];
2059
+ }
2060
+ return node;
2061
+ }
2062
+ function setAtPath(root, path, value) {
2063
+ let node = root;
2064
+ for (let i = 0; i < path.length - 1; i++) {
2065
+ const seg = path[i];
2066
+ if (node[seg] == null || typeof node[seg] !== "object") node[seg] = {};
2067
+ node = node[seg];
2068
+ }
2069
+ node[path[path.length - 1]] = value;
2070
+ }
2071
+ var key = (path) => path.join(".");
2072
+ function isSettled(state, path) {
2073
+ return state.settled.includes(key(path));
2074
+ }
2075
+ function settle(state, path) {
2076
+ const k = key(path);
2077
+ if (!state.settled.includes(k)) state.settled.push(k);
2078
+ }
2079
+ function clone(state) {
2080
+ return JSON.parse(JSON.stringify(state));
2081
+ }
2082
+ function coerce(leaf, raw) {
2083
+ if (typeof raw !== "string") return raw;
2084
+ if (leaf.valueType === "number") {
2085
+ const n = Number(raw);
2086
+ return raw.trim() !== "" && !Number.isNaN(n) ? n : raw;
2087
+ }
2088
+ if (leaf.valueType === "boolean") {
2089
+ if (raw === "true") return true;
2090
+ if (raw === "false") return false;
2091
+ }
2092
+ return raw;
2093
+ }
2094
+ async function validationError(leaf, value, state) {
2095
+ const context = await resolveContext(leaf, state.resolved);
2096
+ const config = leaf.resolver?.prompt?.({
2097
+ items: state.listing?.items ?? [],
2098
+ input: mergeInput(state.resolved, leaf.extraInput),
2099
+ context
2100
+ });
2101
+ if (!config?.validate) return null;
2102
+ const verdict = config.validate(value);
2103
+ if (verdict === true) return null;
2104
+ return typeof verdict === "string" ? verdict : `${leaf.name}: invalid value`;
2105
+ }
2106
+ function toChoice(c) {
2107
+ const label = "label" in c ? c.label : c.name;
2108
+ const hint = Array.isArray(c.hint) ? c.hint.join(", ") : c.hint;
2109
+ return { label, value: String(c.value), hint };
2110
+ }
2111
+ function isRef(r) {
2112
+ return typeof r === "object" && r !== null && "ref" in r;
2113
+ }
2114
+ function toLeaf(name, field, definitions) {
2115
+ let resolver;
2116
+ let extraInput;
2117
+ if (isRef(field.resolver)) {
2118
+ resolver = definitions?.[field.resolver.ref];
2119
+ extraInput = field.resolver.input;
2120
+ } else {
2121
+ resolver = field.resolver;
2122
+ }
2123
+ return {
2124
+ name,
2125
+ required: field.required ?? false,
2126
+ resolver,
2127
+ extraInput,
2128
+ // Carry the field's value type so nested answers coerce (number/boolean)
2129
+ // the same way top-level params do. Without this a nested `z.number()`
2130
+ // field's typed answer stays a string and fails final validation.
2131
+ valueType: field.valueType,
2132
+ requires: resolver?.requireParameters ?? []
2133
+ };
2134
+ }
2135
+ async function objectChildren(resolver, input) {
2136
+ if (resolver.properties) {
2137
+ return Object.entries(resolver.properties).map(
2138
+ ([name, field]) => toLeaf(name, field, resolver.definitions)
2139
+ );
2140
+ }
2141
+ if (!resolver.getProperties) return [];
2142
+ const fields = await resolver.getProperties({ input });
2143
+ return Object.entries(fields).map(([name, field]) => {
2144
+ if (!isRef(field.resolver) && (field.resolver.imports?.length ?? 0) > 0) {
2145
+ throw new Error(
2146
+ `dynamic object field "${name}" inlines an import-bearing resolver; use { ref } into the object's definitions so its imports bind`
2147
+ );
2148
+ }
2149
+ return toLeaf(name, field, resolver.definitions);
2150
+ });
2151
+ }
2152
+ function arrayItem(resolver) {
2153
+ const items = resolver.items;
2154
+ const valueType = resolver.itemValueType;
2155
+ if (isRef(items)) {
2156
+ return {
2157
+ name: "",
2158
+ required: true,
2159
+ resolver: resolver.definitions?.[items.ref],
2160
+ extraInput: items.input,
2161
+ valueType,
2162
+ requires: []
2163
+ };
2164
+ }
2165
+ return {
2166
+ name: "",
2167
+ required: true,
2168
+ resolver: items,
2169
+ valueType,
2170
+ requires: []
2171
+ };
2172
+ }
2173
+ function mergeInput(input, extra) {
2174
+ return extra ? { ...input, ...extra } : input;
2175
+ }
2176
+ async function childrenAt(ctx, path, resolved) {
2177
+ if (path.length === 0) return ctx.parameters;
2178
+ const leaf = await leafAt(ctx, path, resolved);
2179
+ if (!leaf?.resolver || leaf.resolver.type !== "object") return [];
2180
+ return objectChildren(leaf.resolver, mergeInput(resolved, leaf.extraInput));
2181
+ }
2182
+ async function leafAt(ctx, path, resolved) {
2183
+ let children = ctx.parameters;
2184
+ let leaf;
2185
+ for (let i = 0; i < path.length; i++) {
2186
+ const seg = path[i];
2187
+ if (typeof seg === "number") {
2188
+ if (leaf?.resolver?.type !== "array") return void 0;
2189
+ leaf = arrayItem(leaf.resolver);
2190
+ } else {
2191
+ leaf = children.find((c) => c.name === seg);
2192
+ if (!leaf) return void 0;
2193
+ }
2194
+ if (i < path.length - 1 && typeof path[i + 1] === "string") {
2195
+ if (leaf?.resolver?.type !== "object") return void 0;
2196
+ children = await objectChildren(
2197
+ leaf.resolver,
2198
+ mergeInput(resolved, leaf.extraInput)
2199
+ );
2200
+ }
2201
+ }
2202
+ return leaf;
2203
+ }
2204
+ async function arrayInfoAt(ctx, path, resolved) {
2205
+ const leaf = await leafAt(ctx, path, resolved);
2206
+ const resolver = leaf?.resolver;
2207
+ if (resolver?.type !== "array") {
2208
+ throw new Error(`expected an array resolver at "${key(path)}"`);
2209
+ }
2210
+ return {
2211
+ min: resolver.minItems ?? 0,
2212
+ max: resolver.maxItems ?? Infinity,
2213
+ item: { ...arrayItem(resolver), name: String(path[path.length - 1]) }
2214
+ };
2215
+ }
2216
+ var AFFORDANCE = {
2217
+ choose: { action: "choose", description: "Pick one of the listed options" },
2218
+ custom: {
2219
+ action: "custom",
2220
+ description: "Provide a value directly",
2221
+ supply: "value"
2222
+ },
2223
+ search: {
2224
+ action: "search",
2225
+ description: "Filter the options by a search term",
2226
+ supply: "term"
2227
+ },
2228
+ more: { action: "more", description: "Load more options" },
2229
+ skip: { action: "skip", description: "Omit this optional parameter" },
2230
+ add: { action: "add", description: "Add another item" },
2231
+ done: { action: "done", description: "Finish the list" },
2232
+ retry: { action: "retry", description: "Retry loading the options" },
2233
+ cancel: { action: "cancel", description: "Cancel resolution" }
2234
+ };
2235
+ async function firstPage(result) {
2236
+ const page = await result;
2237
+ return {
2238
+ data: Array.isArray(page?.data) ? page.data : [],
2239
+ nextCursor: page?.nextCursor
2240
+ };
2241
+ }
2242
+ async function resolveContext(leaf, input) {
2243
+ return leaf.resolver?.getContext?.({
2244
+ input: mergeInput(input, leaf.extraInput)
2245
+ });
2246
+ }
2247
+ async function fetchListing(leaf, input, opts = {}) {
2248
+ const page = await firstPage(
2249
+ leaf.resolver?.listItems?.({
2250
+ input: mergeInput(input, leaf.extraInput),
2251
+ context: opts.context,
2252
+ search: opts.search,
2253
+ cursor: opts.cursor
2254
+ })
2255
+ );
2256
+ return {
2257
+ items: [...opts.priorItems ?? [], ...page.data],
2258
+ cursor: page.nextCursor,
2259
+ search: opts.search,
2260
+ exhausted: page.nextCursor == null
2261
+ };
2262
+ }
2263
+ function selectActions(leaf, listing, multiple) {
2264
+ const actions = multiple ? [AFFORDANCE.choose] : [AFFORDANCE.choose, AFFORDANCE.custom];
2265
+ if (leaf.resolver?.inputType === "search") actions.push(AFFORDANCE.search);
2266
+ if (listing.cursor) actions.push(AFFORDANCE.more);
2267
+ if (!leaf.required) actions.push(AFFORDANCE.skip);
2268
+ return actions;
2269
+ }
2270
+ function selectQuestion(leaf, input, listing, context) {
2271
+ const config = leaf.resolver?.prompt?.({
2272
+ items: listing.items,
2273
+ input: mergeInput(input, leaf.extraInput),
2274
+ context
2275
+ });
2276
+ const multiple = config?.type === "checkbox";
2277
+ return {
2278
+ type: "select",
2279
+ message: config?.message ?? `Select ${leaf.name}:`,
2280
+ choices: (config?.choices ?? []).map(toChoice),
2281
+ ...multiple ? { multiple: true } : {},
2282
+ ...config?.notes?.length ? { notes: config.notes } : {},
2283
+ actions: selectActions(leaf, listing, multiple)
2284
+ };
2285
+ }
2286
+ function toControllerError(error) {
2287
+ if (error instanceof Error) {
2288
+ const code = error.code;
2289
+ return {
2290
+ name: error.name,
2291
+ message: error.message,
2292
+ ...typeof code === "string" ? { code } : {}
2293
+ };
2294
+ }
2295
+ return { name: "Error", message: String(error) };
2296
+ }
2297
+ function failedResult(state, name, error) {
2298
+ return {
2299
+ state,
2300
+ result: {
2301
+ status: "failed",
2302
+ error: toControllerError(error),
2303
+ question: {
2304
+ type: "select",
2305
+ message: `Could not load options for ${name}.`,
2306
+ choices: [],
2307
+ actions: [AFFORDANCE.retry, AFFORDANCE.cancel]
2308
+ }
2309
+ }
2310
+ };
2311
+ }
2312
+ async function buildQuestion(leaf, input) {
2313
+ const optional = !leaf.required;
2314
+ const resolver = leaf.resolver;
2315
+ if (resolver?.listItems) {
2316
+ const context = await resolveContext(leaf, input);
2317
+ const listing = await fetchListing(leaf, input, { context });
2318
+ return {
2319
+ question: selectQuestion(leaf, input, listing, context),
2320
+ listing
2321
+ };
2322
+ }
2323
+ if (leaf.staticChoices) {
2324
+ const actions2 = [AFFORDANCE.choose];
2325
+ if (optional) actions2.push(AFFORDANCE.skip);
2326
+ return {
2327
+ question: {
2328
+ type: "select",
2329
+ message: `Select ${leaf.name}:`,
2330
+ choices: leaf.staticChoices,
2331
+ actions: actions2
2332
+ }
2333
+ };
2334
+ }
2335
+ const inputType = resolver?.inputType && resolver.inputType !== "search" ? resolver.inputType : "text";
2336
+ const actions = [AFFORDANCE.custom];
2337
+ if (optional) actions.push(AFFORDANCE.skip);
2338
+ return {
2339
+ question: {
2340
+ type: "input",
2341
+ message: `Enter ${leaf.name}:`,
2342
+ inputType,
2343
+ placeholder: resolver?.placeholder,
2344
+ actions
2345
+ }
2346
+ };
2347
+ }
2348
+ function finalize(ctx, resolved) {
2349
+ if (!ctx.schema) return { status: "done", value: resolved };
2350
+ const parsed = ctx.schema.safeParse(resolved);
2351
+ if (parsed.success) {
2352
+ return { status: "done", value: parsed.data };
2353
+ }
2354
+ const issues = parsed.error.issues.map((i) => ({
2355
+ parameter: i.path.map(String).join(".") || void 0,
2356
+ message: i.message
2357
+ }));
2358
+ return { status: "invalid", issues };
2359
+ }
2360
+ function collectionQuestion(t) {
2361
+ const actions = [AFFORDANCE.add];
2362
+ if (t.count >= t.min) actions.push(AFFORDANCE.done);
2363
+ return {
2364
+ type: "collection",
2365
+ message: `Add another ${t.path[t.path.length - 1]}? (${t.count} so far)`,
2366
+ count: t.count,
2367
+ min: t.min,
2368
+ // An unbounded array's max is Infinity, which JSON.stringify turns to null;
2369
+ // omit it so the question round-trips across the wall as plain data.
2370
+ ...Number.isFinite(t.max) ? { max: t.max } : {},
2371
+ actions
2372
+ };
2373
+ }
2374
+ async function findInArray(ctx, state, path) {
2375
+ if (isSettled(state, path)) return null;
2376
+ if (getAtPath(state.resolved, path) == null)
2377
+ setAtPath(state.resolved, path, []);
2378
+ if (!state.interactive) {
2379
+ settle(state, path);
2380
+ return null;
2381
+ }
2382
+ const { min, max, item } = await arrayInfoAt(ctx, path, state.resolved);
2383
+ const items = getAtPath(state.resolved, path);
2384
+ const len = items.length;
2385
+ const itemType = item.resolver?.type;
2386
+ if (len > 0 && (itemType === "object" || itemType === "array")) {
2387
+ const inner = await findNext(ctx, state, [...path, len - 1]);
2388
+ if (inner) return inner;
2389
+ }
2390
+ if (len < min) return descendItem(ctx, state, path, len, item);
2391
+ if (len < max) return { kind: "array", path, count: len, min, max };
2392
+ settle(state, path);
2393
+ return null;
2394
+ }
2395
+ function seedItemSlot(state, itemPath, item) {
2396
+ const type = item.resolver?.type;
2397
+ if (type === "object") {
2398
+ setAtPath(state.resolved, itemPath, {});
2399
+ return "object";
2400
+ }
2401
+ if (type === "array") {
2402
+ setAtPath(state.resolved, itemPath, []);
2403
+ return "array";
2404
+ }
2405
+ return "leaf";
2406
+ }
2407
+ async function descendItem(ctx, state, arrayPath, index, item) {
2408
+ const itemPath = [...arrayPath, index];
2409
+ const kind = seedItemSlot(state, itemPath, item);
2410
+ if (kind === "object") return findNext(ctx, state, itemPath);
2411
+ if (kind === "array") return findInArray(ctx, state, itemPath);
2412
+ return { kind: "leaf", path: itemPath, leaf: item };
2413
+ }
2414
+ async function findNext(ctx, state, path = []) {
2415
+ const container = getAtPath(state.resolved, path) ?? {};
2416
+ for (const leaf of await childrenAt(ctx, path, state.resolved)) {
2417
+ const childPath = [...path, leaf.name];
2418
+ if (!leaf.requires.every((r) => container[r] !== void 0)) continue;
2419
+ if (leaf.resolver?.type === "object") {
2420
+ if (getAtPath(state.resolved, childPath) == null)
2421
+ setAtPath(state.resolved, childPath, {});
2422
+ const inner = await findNext(ctx, state, childPath);
2423
+ if (inner) return inner;
2424
+ continue;
2425
+ }
2426
+ if (leaf.resolver?.type === "array") {
2427
+ const inner = await findInArray(ctx, state, childPath);
2428
+ if (inner) return inner;
2429
+ continue;
2430
+ }
2431
+ if (container[leaf.name] !== void 0 || isSettled(state, childPath))
2432
+ continue;
2433
+ return { kind: "leaf", path: childPath, leaf };
2434
+ }
2435
+ return null;
2436
+ }
2437
+ async function askLeaf(state, path, leaf, opts = {}) {
2438
+ state.current = path;
2439
+ try {
2440
+ const { question, listing } = await buildQuestion(leaf, state.resolved);
2441
+ state.listing = listing;
2442
+ return {
2443
+ state,
2444
+ result: {
2445
+ status: "ask",
2446
+ question,
2447
+ ...opts.error ? { error: opts.error } : {}
2448
+ }
2449
+ };
2450
+ } catch (error) {
2451
+ state.listing = { items: [], exhausted: false };
2452
+ return failedResult(state, leaf.name, error);
2453
+ }
2454
+ }
2455
+ async function advance(ctx, state) {
2456
+ for (; ; ) {
2457
+ const target = await findNext(ctx, state);
2458
+ if (!target) {
2459
+ delete state.current;
2460
+ delete state.listing;
2461
+ return { state, result: finalize(ctx, state.resolved) };
2462
+ }
2463
+ if (target.kind === "array") {
2464
+ state.current = target.path;
2465
+ delete state.listing;
2466
+ return {
2467
+ state,
2468
+ result: { status: "ask", question: collectionQuestion(target) }
2469
+ };
2470
+ }
2471
+ const { path, leaf } = target;
2472
+ const auto = await leaf.resolver?.tryResolveWithoutPrompt?.({
2473
+ input: mergeInput(state.resolved, leaf.extraInput)
2474
+ });
2475
+ if (auto) {
2476
+ if (auto.resolvedValue !== void 0)
2477
+ setAtPath(state.resolved, path, auto.resolvedValue);
2478
+ settle(state, path);
2479
+ continue;
2480
+ }
2481
+ if (!state.interactive) {
2482
+ if (!leaf.required) {
2483
+ settle(state, path);
2484
+ continue;
2485
+ }
2486
+ } else if (!leaf.required && !leaf.resolver) {
2487
+ settle(state, path);
2488
+ continue;
2489
+ }
2490
+ return askLeaf(state, path, leaf);
2491
+ }
2492
+ }
2493
+ async function start(ctx, input = {}, interactive = true) {
2494
+ const resolved = {};
2495
+ for (const spec of ctx.parameters) {
2496
+ if (spec.resolver?.type === "constant")
2497
+ resolved[spec.name] = spec.resolver.value;
2498
+ }
2499
+ Object.assign(resolved, input);
2500
+ return advance(ctx, {
2501
+ method: ctx.method,
2502
+ resolved,
2503
+ settled: [],
2504
+ interactive
2505
+ });
2506
+ }
2507
+ async function step(ctx, prior, action) {
2508
+ const state = clone(prior);
2509
+ if (action.type === "cancel") {
2510
+ delete state.current;
2511
+ delete state.listing;
2512
+ return { state, result: { status: "cancelled" } };
2513
+ }
2514
+ const path = state.current;
2515
+ if (!path) throw new Error("step called with no outstanding question");
2516
+ const leaf = await leafAt(ctx, path, state.resolved);
2517
+ if (leaf && (action.type === "search" || action.type === "more" || action.type === "retry")) {
2518
+ return refine(ctx, state, leaf, path, action);
2519
+ }
2520
+ if (action.type === "add" || action.type === "done") {
2521
+ delete state.current;
2522
+ delete state.listing;
2523
+ if (action.type === "done") {
2524
+ settle(state, path);
2525
+ return advance(ctx, state);
2526
+ }
2527
+ const items = getAtPath(state.resolved, path) ?? [];
2528
+ const { item } = await arrayInfoAt(ctx, path, state.resolved);
2529
+ const itemPath = [...path, items.length];
2530
+ if (seedItemSlot(state, itemPath, item) === "leaf")
2531
+ return askLeaf(state, itemPath, item);
2532
+ return advance(ctx, state);
2533
+ }
2534
+ switch (action.type) {
2535
+ case "choose":
2536
+ case "custom": {
2537
+ if (leaf) {
2538
+ const error = await validationError(leaf, action.value, state);
2539
+ if (error) return askLeaf(state, path, leaf, { error });
2540
+ }
2541
+ setAtPath(
2542
+ state.resolved,
2543
+ path,
2544
+ leaf ? coerce(leaf, action.value) : action.value
2545
+ );
2546
+ break;
2547
+ }
2548
+ case "skip":
2549
+ settle(state, path);
2550
+ break;
2551
+ default:
2552
+ throw new Error(`action "${action.type}" is not supported here`);
2553
+ }
2554
+ delete state.current;
2555
+ delete state.listing;
2556
+ return advance(ctx, state);
2557
+ }
2558
+ async function refine(ctx, state, leaf, path, action) {
2559
+ const attempt = action.type === "search" ? { search: action.term, cursor: void 0, priorItems: [] } : {
2560
+ search: state.listing?.search,
2561
+ cursor: state.listing?.cursor,
2562
+ priorItems: state.listing?.items ?? []
2563
+ };
2564
+ try {
2565
+ if (action.type === "search") {
2566
+ const exact = await leaf.resolver?.tryResolveFromSearch?.({
2567
+ input: mergeInput(state.resolved, leaf.extraInput),
2568
+ search: action.term
2569
+ });
2570
+ if (exact) {
2571
+ setAtPath(state.resolved, path, coerce(leaf, exact.resolvedValue));
2572
+ delete state.current;
2573
+ delete state.listing;
2574
+ return advance(ctx, state);
2575
+ }
2576
+ }
2577
+ const context = await resolveContext(leaf, state.resolved);
2578
+ state.listing = await fetchListing(leaf, state.resolved, {
2579
+ ...attempt,
2580
+ context
2581
+ });
2582
+ return {
2583
+ state,
2584
+ result: {
2585
+ status: "ask",
2586
+ question: selectQuestion(leaf, state.resolved, state.listing, context)
2587
+ }
2588
+ };
2589
+ } catch (error) {
2590
+ state.listing = {
2591
+ items: attempt.priorItems,
2592
+ search: attempt.search,
2593
+ cursor: attempt.cursor,
2594
+ exhausted: false
2595
+ };
2596
+ return failedResult(state, leaf.name, error);
2597
+ }
2598
+ }
2599
+ function toJsonSchema(schema) {
2600
+ if (!schema) return void 0;
2601
+ try {
2602
+ return z.toJSONSchema(schema);
2603
+ } catch {
2604
+ return void 0;
2605
+ }
2606
+ }
2607
+ function projectSummary(entry) {
2608
+ return {
2609
+ name: entry.name,
2610
+ ...entry.description ? { description: entry.description } : {},
2611
+ ...entry.categories?.length ? { categories: entry.categories } : {}
2612
+ };
2613
+ }
2614
+ function projectMethod(entry) {
2615
+ const inputProperties = toJsonSchema(entry.inputSchema)?.properties;
2616
+ const parameters = {};
2617
+ for (const spec of planParameters(entry).parameters) {
2618
+ parameters[spec.name] = {
2619
+ required: spec.required,
2620
+ dynamic: Boolean(spec.resolver?.listItems),
2621
+ ...spec.resolver?.inputType === "search" ? { searchable: true } : {},
2622
+ ...inputProperties?.[spec.name] ? { schema: inputProperties[spec.name] } : {},
2623
+ ...spec.staticChoices ? { choices: spec.staticChoices } : {},
2624
+ ...spec.requires.length ? { requireParameters: spec.requires } : {}
2625
+ };
2626
+ }
2627
+ const output = toJsonSchema(entry.outputSchema);
2628
+ return {
2629
+ name: entry.name,
2630
+ ...entry.description ? { description: entry.description } : {},
2631
+ ...entry.categories?.length ? { categories: entry.categories } : {},
2632
+ parameters,
2633
+ ...entry.positional?.length ? { positional: entry.positional } : {},
2634
+ ...output ? { output } : {}
2635
+ };
2636
+ }
2637
+ function createController(sdk) {
2638
+ function entryFor(method) {
2639
+ const entry = sdk.getRegistry().functions.find((f) => f.name === method);
2640
+ if (!entry) throw new Error(`unknown method "${method}"`);
2641
+ return entry;
2642
+ }
2643
+ function contextFor(method) {
2644
+ const entry = entryFor(method);
2645
+ return {
2646
+ method,
2647
+ schema: entry.inputSchema,
2648
+ parameters: planParameters(entry).parameters
2649
+ };
2650
+ }
2651
+ const start2 = ({ method, input, interactive }) => start(contextFor(method), input, interactive);
2652
+ const step2 = ({ state, action }) => step(contextFor(state.method), state, action);
2653
+ const resolve2 = async ({
2654
+ method,
2655
+ input,
2656
+ answer,
2657
+ interactive
2658
+ }) => {
2659
+ const ctx = contextFor(method);
2660
+ let { state, result } = await start(ctx, input, interactive);
2661
+ while (result.status === "ask" || result.status === "failed") {
2662
+ const action = await answer({ state, result });
2663
+ ({ state, result } = await step(ctx, state, action));
2664
+ }
2665
+ if (result.status === "done") return result.value;
2666
+ if (result.status === "cancelled") {
2667
+ throw new CoreCancelledSignal(`resolution cancelled for "${method}"`);
2668
+ }
2669
+ const detail = result.issues.map((i) => i.parameter ? `${i.parameter}: ${i.message}` : i.message).join("; ");
2670
+ throw new Error(`invalid input for "${method}": ${detail}`);
2671
+ };
2672
+ const listMethods = () => ({
2673
+ data: sdk.getRegistry().functions.map(projectSummary)
2674
+ });
2675
+ const getMethod = ({ method }) => ({
2676
+ data: projectMethod(entryFor(method))
2677
+ });
2678
+ const listChoices = async ({
2679
+ method,
2680
+ parameter,
2681
+ input = {},
2682
+ search,
2683
+ cursor
2684
+ }) => {
2685
+ const spec = contextFor(method).parameters.find(
2686
+ (p) => p.name === parameter
2687
+ );
2688
+ if (!spec?.resolver?.listItems) return { data: [] };
2689
+ const context = await spec.resolver.getContext?.({ input });
2690
+ const page = await firstPage(
2691
+ spec.resolver.listItems({ input, context, search, cursor })
2692
+ );
2693
+ const config = spec.resolver.prompt?.({ items: page.data, input, context });
2694
+ const data = (config?.choices ?? []).map(toChoice);
2695
+ return { data, nextCursor: page.nextCursor };
2696
+ };
2697
+ return { resolve: resolve2, start: start2, step: step2, listMethods, getMethod, listChoices };
2698
+ }
1859
2699
  function createCorePlugin(options) {
1860
2700
  return () => ({
1861
2701
  context: {
@@ -2823,8 +3663,8 @@ function normalizeHeaders(optionsHeaders) {
2823
3663
  return headers;
2824
3664
  }
2825
3665
  const headerEntries = optionsHeaders instanceof Headers ? Array.from(optionsHeaders.entries()) : Array.isArray(optionsHeaders) ? optionsHeaders : Object.entries(optionsHeaders);
2826
- for (const [key, value] of headerEntries) {
2827
- headers[key] = value;
3666
+ for (const [key2, value] of headerEntries) {
3667
+ headers[key2] = value;
2828
3668
  }
2829
3669
  return headers;
2830
3670
  }
@@ -3114,28 +3954,28 @@ function censorHeaders(headers) {
3114
3954
  if (!headers) return headers;
3115
3955
  const headersObj = new Headers(headers);
3116
3956
  const authKeys = ["authorization", "x-api-key"];
3117
- for (const [key, value] of headersObj.entries()) {
3118
- if (authKeys.some((authKey) => key.toLowerCase() === authKey)) {
3957
+ for (const [key2, value] of headersObj.entries()) {
3958
+ if (authKeys.some((authKey) => key2.toLowerCase() === authKey)) {
3119
3959
  const spaceIndex = value.indexOf(" ");
3120
3960
  if (spaceIndex > 0 && spaceIndex < value.length - 1) {
3121
3961
  const prefix = value.substring(0, spaceIndex + 1);
3122
3962
  const token = value.substring(spaceIndex + 1);
3123
3963
  if (token.length > 12) {
3124
- const start = token.substring(0, 4);
3964
+ const start2 = token.substring(0, 4);
3125
3965
  const end = token.substring(token.length - 4);
3126
- headersObj.set(key, `${prefix}${start}...${end}`);
3966
+ headersObj.set(key2, `${prefix}${start2}...${end}`);
3127
3967
  } else {
3128
3968
  const firstChar = token.charAt(0);
3129
- headersObj.set(key, `${prefix}${firstChar}...`);
3969
+ headersObj.set(key2, `${prefix}${firstChar}...`);
3130
3970
  }
3131
3971
  } else {
3132
3972
  if (value.length > 12) {
3133
- const start = value.substring(0, 4);
3973
+ const start2 = value.substring(0, 4);
3134
3974
  const end = value.substring(value.length - 4);
3135
- headersObj.set(key, `${start}...${end}`);
3975
+ headersObj.set(key2, `${start2}...${end}`);
3136
3976
  } else {
3137
3977
  const firstChar = value.charAt(0);
3138
- headersObj.set(key, `${firstChar}...`);
3978
+ headersObj.set(key2, `${firstChar}...`);
3139
3979
  }
3140
3980
  }
3141
3981
  }
@@ -3704,21 +4544,21 @@ function getClientIdFromCredentials(credentials) {
3704
4544
  function createMemoryCache() {
3705
4545
  const store = /* @__PURE__ */ new Map();
3706
4546
  return {
3707
- async get(key) {
3708
- const entry = store.get(key);
4547
+ async get(key2) {
4548
+ const entry = store.get(key2);
3709
4549
  if (!entry) return void 0;
3710
4550
  if (entry.expiresAt !== void 0 && entry.expiresAt <= Date.now()) {
3711
- store.delete(key);
4551
+ store.delete(key2);
3712
4552
  return void 0;
3713
4553
  }
3714
4554
  return { value: entry.value, expiresAt: entry.expiresAt };
3715
4555
  },
3716
- async set(key, value, options) {
4556
+ async set(key2, value, options) {
3717
4557
  const expiresAt = options?.ttl ? Date.now() + options.ttl * 1e3 : void 0;
3718
- store.set(key, { value, expiresAt });
4558
+ store.set(key2, { value, expiresAt });
3719
4559
  },
3720
- async delete(key) {
3721
- store.delete(key);
4560
+ async delete(key2) {
4561
+ store.delete(key2);
3722
4562
  }
3723
4563
  };
3724
4564
  }
@@ -4209,14 +5049,14 @@ function createSseParserStream() {
4209
5049
  transform(chunk, controller) {
4210
5050
  buffer += chunk;
4211
5051
  const newline = /\r\n|\r|\n/g;
4212
- let start = 0;
5052
+ let start2 = 0;
4213
5053
  let match;
4214
5054
  while ((match = newline.exec(buffer)) !== null) {
4215
5055
  if (match[0] === "\r" && match.index === buffer.length - 1) break;
4216
- processLine(buffer.slice(start, match.index), controller);
4217
- start = match.index + match[0].length;
5056
+ processLine(buffer.slice(start2, match.index), controller);
5057
+ start2 = match.index + match[0].length;
4218
5058
  }
4219
- buffer = buffer.slice(start);
5059
+ buffer = buffer.slice(start2);
4220
5060
  },
4221
5061
  flush(controller) {
4222
5062
  if (buffer.endsWith("\r")) {
@@ -4374,7 +5214,7 @@ function parseDeprecationDate(value) {
4374
5214
  }
4375
5215
 
4376
5216
  // src/sdk-version.ts
4377
- var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.79.0" : void 0) || "unknown";
5217
+ var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.80.0" : void 0) || "unknown";
4378
5218
 
4379
5219
  // src/utils/open-url.ts
4380
5220
  var nodePrefix = "node:";
@@ -4620,11 +5460,11 @@ var ZapierApiClient = class {
4620
5460
  );
4621
5461
  const inputHeaders = new Headers(init?.headers ?? {});
4622
5462
  const mergedHeaders = new Headers();
4623
- builtHeaders.forEach((value, key) => {
4624
- mergedHeaders.set(key, value);
5463
+ builtHeaders.forEach((value, key2) => {
5464
+ mergedHeaders.set(key2, value);
4625
5465
  });
4626
- inputHeaders.forEach((value, key) => {
4627
- mergedHeaders.set(key, value);
5466
+ inputHeaders.forEach((value, key2) => {
5467
+ mergedHeaders.set(key2, value);
4628
5468
  });
4629
5469
  this.applyTelemetryHeaders(mergedHeaders);
4630
5470
  let retries = 0;
@@ -5149,8 +5989,8 @@ var ZapierApiClient = class {
5149
5989
  canSendDeprecationMessaging
5150
5990
  } = this.applyPathConfiguration(path);
5151
5991
  if (searchParams) {
5152
- Object.entries(searchParams).forEach(([key, value]) => {
5153
- url.searchParams.set(key, value);
5992
+ Object.entries(searchParams).forEach(([key2, value]) => {
5993
+ url.searchParams.set(key2, value);
5154
5994
  });
5155
5995
  }
5156
5996
  return {
@@ -5801,7 +6641,7 @@ var listAppsPlugin = definePlugin(
5801
6641
  locator
5802
6642
  ];
5803
6643
  }
5804
- const duplicatedLookupAppKeys = Object.keys(implementationNameToLocator).filter((key) => implementationNameToLocator[key].length > 1).map((key) => implementationNameToLocator[key]).flat().map((locator) => locator.lookupAppKey);
6644
+ const duplicatedLookupAppKeys = Object.keys(implementationNameToLocator).filter((key2) => implementationNameToLocator[key2].length > 1).map((key2) => implementationNameToLocator[key2]).flat().map((locator) => locator.lookupAppKey);
5805
6645
  if (duplicatedLookupAppKeys.length > 0) {
5806
6646
  throw new Error(
5807
6647
  `Duplicate lookup app keys found: ${duplicatedLookupAppKeys.join(", ")}`
@@ -6294,7 +7134,7 @@ function formatRecordError(fieldId, err) {
6294
7134
  function formatResponseError(err) {
6295
7135
  const message = err.human_title || err.title || "Unknown error";
6296
7136
  if (err.meta && Object.keys(err.meta).length > 0) {
6297
- const metaParts = Object.entries(err.meta).map(([key, val]) => `${key}: ${JSON.stringify(val)}`).join(", ");
7137
+ const metaParts = Object.entries(err.meta).map(([key2, val]) => `${key2}: ${JSON.stringify(val)}`).join(", ");
6298
7138
  return `${message} (${metaParts})`;
6299
7139
  }
6300
7140
  return message;
@@ -6329,8 +7169,8 @@ var TrashSchema = z.enum(["exclude", "include", "only"]).optional().describe(
6329
7169
  'Control soft-deleted item visibility. "exclude" (default) returns active items only, "include" returns both active and soft-deleted, "only" returns soft-deleted items only.'
6330
7170
  );
6331
7171
  var FIELD_ID_PATTERN = /^f\d+$/;
6332
- function isFieldId(key) {
6333
- return FIELD_ID_PATTERN.test(key);
7172
+ function isFieldId(key2) {
7173
+ return FIELD_ID_PATTERN.test(key2);
6334
7174
  }
6335
7175
  var NESTED_COMPONENTS = {
6336
7176
  labeled_string: /* @__PURE__ */ new Set(["value"]),
@@ -6368,7 +7208,7 @@ async function resolveFieldKeys({
6368
7208
  fieldKeys
6369
7209
  }) {
6370
7210
  const allAreIds = fieldKeys.every(
6371
- (key) => typeof key === "number" || /^(f?\d+)$/.test(key)
7211
+ (key2) => typeof key2 === "number" || /^(f?\d+)$/.test(key2)
6372
7212
  );
6373
7213
  if (allAreIds) {
6374
7214
  return fieldKeys.map(toNumericFieldId);
@@ -6377,13 +7217,13 @@ async function resolveFieldKeys({
6377
7217
  if (!mapping) {
6378
7218
  return fieldKeys.map(toNumericFieldId);
6379
7219
  }
6380
- return fieldKeys.map((key) => {
6381
- if (typeof key === "number") return key;
6382
- if (FIELD_ID_PATTERN.test(key)) return toNumericFieldId(key);
6383
- const id = mapping.nameToId.get(key);
7220
+ return fieldKeys.map((key2) => {
7221
+ if (typeof key2 === "number") return key2;
7222
+ if (FIELD_ID_PATTERN.test(key2)) return toNumericFieldId(key2);
7223
+ const id = mapping.nameToId.get(key2);
6384
7224
  if (!id) {
6385
7225
  throw new ZapierValidationError(
6386
- `Unknown field name: "${key}". Use a valid field name or ID.`
7226
+ `Unknown field name: "${key2}". Use a valid field name or ID.`
6387
7227
  );
6388
7228
  }
6389
7229
  return toNumericFieldId(id);
@@ -6399,13 +7239,13 @@ async function createFieldKeyTranslator({
6399
7239
  translateInput(data) {
6400
7240
  if (!mapping) return data;
6401
7241
  const result = {};
6402
- for (const [key, value] of Object.entries(data)) {
6403
- if (FIELD_ID_PATTERN.test(key) && mapping.idToName.has(key)) {
6404
- result[key] = value;
6405
- } else if (mapping.nameToId.has(key)) {
6406
- result[mapping.nameToId.get(key)] = value;
7242
+ for (const [key2, value] of Object.entries(data)) {
7243
+ if (FIELD_ID_PATTERN.test(key2) && mapping.idToName.has(key2)) {
7244
+ result[key2] = value;
7245
+ } else if (mapping.nameToId.has(key2)) {
7246
+ result[mapping.nameToId.get(key2)] = value;
6407
7247
  } else {
6408
- result[key] = value;
7248
+ result[key2] = value;
6409
7249
  }
6410
7250
  }
6411
7251
  return result;
@@ -6413,29 +7253,29 @@ async function createFieldKeyTranslator({
6413
7253
  translateOutput(data) {
6414
7254
  if (!mapping) return data;
6415
7255
  const result = {};
6416
- for (const [key, value] of Object.entries(data)) {
6417
- if (mapping.idToName.has(key)) {
6418
- result[mapping.idToName.get(key)] = value;
7256
+ for (const [key2, value] of Object.entries(data)) {
7257
+ if (mapping.idToName.has(key2)) {
7258
+ result[mapping.idToName.get(key2)] = value;
6419
7259
  } else {
6420
- result[key] = value;
7260
+ result[key2] = value;
6421
7261
  }
6422
7262
  }
6423
7263
  return result;
6424
7264
  },
6425
- translateFieldKey(key) {
6426
- if (!mapping) return key;
6427
- if (FIELD_ID_PATTERN.test(key) && mapping.idToName.has(key)) {
6428
- const fieldType = mapping.idToType.get(key);
7265
+ translateFieldKey(key2) {
7266
+ if (!mapping) return key2;
7267
+ if (FIELD_ID_PATTERN.test(key2) && mapping.idToName.has(key2)) {
7268
+ const fieldType = mapping.idToType.get(key2);
6429
7269
  if (fieldType) {
6430
7270
  const components = NESTED_COMPONENTS[fieldType];
6431
7271
  if (components?.size === 1) {
6432
- return `${key}__${[...components][0]}`;
7272
+ return `${key2}__${[...components][0]}`;
6433
7273
  }
6434
7274
  }
6435
- return key;
7275
+ return key2;
6436
7276
  }
6437
- if (mapping.nameToId.has(key)) {
6438
- const fieldId = mapping.nameToId.get(key);
7277
+ if (mapping.nameToId.has(key2)) {
7278
+ const fieldId = mapping.nameToId.get(key2);
6439
7279
  const fieldType = mapping.idToType.get(fieldId);
6440
7280
  if (fieldType) {
6441
7281
  const components = NESTED_COMPONENTS[fieldType];
@@ -6445,10 +7285,10 @@ async function createFieldKeyTranslator({
6445
7285
  }
6446
7286
  return fieldId;
6447
7287
  }
6448
- const sepIndex = key.lastIndexOf("__");
7288
+ const sepIndex = key2.lastIndexOf("__");
6449
7289
  if (sepIndex > 0) {
6450
- const prefix = key.slice(0, sepIndex);
6451
- const component = key.slice(sepIndex + 2);
7290
+ const prefix = key2.slice(0, sepIndex);
7291
+ const component = key2.slice(sepIndex + 2);
6452
7292
  let fieldId;
6453
7293
  if (FIELD_ID_PATTERN.test(prefix) && mapping.idToName.has(prefix)) {
6454
7294
  fieldId = prefix;
@@ -6462,7 +7302,7 @@ async function createFieldKeyTranslator({
6462
7302
  }
6463
7303
  }
6464
7304
  }
6465
- return key;
7305
+ return key2;
6466
7306
  }
6467
7307
  };
6468
7308
  }
@@ -7379,9 +8219,9 @@ var RunActionSchemaDeprecated = z.object({
7379
8219
  var RunActionInputSchema = z.union([RunActionSchema, RunActionSchemaDeprecated]).describe(RunActionDescription);
7380
8220
 
7381
8221
  // src/formatters/actionResult.ts
7382
- function getStringProperty(obj, key) {
7383
- if (typeof obj === "object" && obj !== null && key in obj) {
7384
- const value = obj[key];
8222
+ function getStringProperty(obj, key2) {
8223
+ if (typeof obj === "object" && obj !== null && key2 in obj) {
8224
+ const value = obj[key2];
7385
8225
  return typeof value === "string" ? value : void 0;
7386
8226
  }
7387
8227
  return void 0;
@@ -7468,13 +8308,13 @@ var runActionPlugin = definePlugin(
7468
8308
  let oldestKey;
7469
8309
  let oldestExpiry = Infinity;
7470
8310
  let evictedAny = false;
7471
- for (const [key, entry] of runActionContextCache) {
8311
+ for (const [key2, entry] of runActionContextCache) {
7472
8312
  if (now >= entry.expiresAt) {
7473
- runActionContextCache.delete(key);
8313
+ runActionContextCache.delete(key2);
7474
8314
  evictedAny = true;
7475
8315
  } else if (entry.expiresAt < oldestExpiry) {
7476
8316
  oldestExpiry = entry.expiresAt;
7477
- oldestKey = key;
8317
+ oldestKey = key2;
7478
8318
  }
7479
8319
  }
7480
8320
  if (!evictedAny && oldestKey) {
@@ -8102,36 +8942,36 @@ var createConnectionPlugin = definePlugin(
8102
8942
  sdk: inner,
8103
8943
  options
8104
8944
  }) => {
8105
- const { data: start } = await inner.getConnectionStartUrl({
8945
+ const { data: start2 } = await inner.getConnectionStartUrl({
8106
8946
  app: options.app
8107
8947
  });
8108
- setMethodMetadata({ selectedApi: start.app });
8948
+ setMethodMetadata({ selectedApi: start2.app });
8109
8949
  console.error(
8110
8950
  `
8111
8951
  Open this URL to complete the connection:
8112
- ${start.url}
8952
+ ${start2.url}
8113
8953
  `
8114
8954
  );
8115
8955
  const shouldOpen = options.browser === "always" || options.browser === "auto" && shouldOpenBrowser();
8116
8956
  if (shouldOpen) {
8117
8957
  try {
8118
- await open_url_default(start.url);
8958
+ await open_url_default(start2.url);
8119
8959
  } catch {
8120
8960
  }
8121
8961
  }
8122
8962
  const { data: fresh } = await inner.waitForNewConnection({
8123
- app: start.app,
8963
+ app: start2.app,
8124
8964
  // Server-stamped mint time: measured on the same clock as a
8125
8965
  // connection's `date`, so the freshness check is immune to
8126
8966
  // client/server clock skew.
8127
- startedAt: start.startedAt,
8967
+ startedAt: start2.startedAt,
8128
8968
  timeoutMs: options.timeoutMs,
8129
8969
  pollIntervalMs: options.pollIntervalMs
8130
8970
  });
8131
8971
  return {
8132
8972
  data: CreateConnectionItemSchema.parse({
8133
8973
  id: fresh.id,
8134
- app: start.app,
8974
+ app: start2.app,
8135
8975
  title: fresh.title ?? null
8136
8976
  })
8137
8977
  };
@@ -10130,9 +10970,9 @@ function findManifestEntry({
10130
10970
  return [slug, manifest.apps[slug]];
10131
10971
  }
10132
10972
  }
10133
- for (const [key, entry] of Object.entries(manifest.apps)) {
10973
+ for (const [key2, entry] of Object.entries(manifest.apps)) {
10134
10974
  if (entry.implementationName === appKeyWithoutVersion) {
10135
- return [key, entry];
10975
+ return [key2, entry];
10136
10976
  }
10137
10977
  }
10138
10978
  return null;
@@ -10389,21 +11229,21 @@ var manifestPlugin = definePlugin(
10389
11229
  );
10390
11230
 
10391
11231
  // src/plugins/capabilities/index.ts
10392
- function toDescription(key) {
10393
- const words = key.replace(/^can/, "").replace(/([A-Z])/g, " $1").trim().toLowerCase();
11232
+ function toDescription(key2) {
11233
+ const words = key2.replace(/^can/, "").replace(/([A-Z])/g, " $1").trim().toLowerCase();
10394
11234
  return `To ${words}`;
10395
11235
  }
10396
- function toEnvVar(key) {
10397
- return "ZAPIER_" + key.replace(/([A-Z])/g, "_$1").toUpperCase();
11236
+ function toEnvVar(key2) {
11237
+ return "ZAPIER_" + key2.replace(/([A-Z])/g, "_$1").toUpperCase();
10398
11238
  }
10399
- function toCliFlag(key) {
10400
- return "--" + key.replace(/([A-Z])/g, "-$1").toLowerCase();
11239
+ function toCliFlag(key2) {
11240
+ return "--" + key2.replace(/([A-Z])/g, "-$1").toLowerCase();
10401
11241
  }
10402
- function buildCapabilityMessage(key) {
11242
+ function buildCapabilityMessage(key2) {
10403
11243
  return [
10404
- `${toDescription(key)}, use ${toCliFlag(key)} in the CLI,`,
10405
- `set ${key}: true in SDK options or .zapierrc,`,
10406
- `or set ${toEnvVar(key)}=true.`
11244
+ `${toDescription(key2)}, use ${toCliFlag(key2)} in the CLI,`,
11245
+ `set ${key2}: true in SDK options or .zapierrc,`,
11246
+ `or set ${toEnvVar(key2)}=true.`
10407
11247
  ].join(" ");
10408
11248
  }
10409
11249
  var GATED_FLAGS = [
@@ -10411,8 +11251,8 @@ var GATED_FLAGS = [
10411
11251
  "canIncludeSharedTables",
10412
11252
  "canDeleteTables"
10413
11253
  ];
10414
- function isEnabledByEnv(key) {
10415
- const value = globalThis.process?.env?.[toEnvVar(key)];
11254
+ function isEnabledByEnv(key2) {
11255
+ const value = globalThis.process?.env?.[toEnvVar(key2)];
10416
11256
  if (value === void 0) return void 0;
10417
11257
  if (value === "true" || value === "1") return true;
10418
11258
  if (value === "false" || value === "0") return false;
@@ -10435,17 +11275,17 @@ var capabilitiesPlugin = definePlugin(
10435
11275
  }
10436
11276
  return {
10437
11277
  context: {
10438
- checkCapability: async (key) => {
11278
+ checkCapability: async (key2) => {
10439
11279
  const flags = await resolveFlags();
10440
- if (flags[key]) return;
11280
+ if (flags[key2]) return;
10441
11281
  throw new ZapierConfigurationError(
10442
- buildCapabilityMessage(key) + " (If you are an AI agent, you MUST NOT retry. Ask the user if they want to enable this.)",
10443
- { configType: key }
11282
+ buildCapabilityMessage(key2) + " (If you are an AI agent, you MUST NOT retry. Ask the user if they want to enable this.)",
11283
+ { configType: key2 }
10444
11284
  );
10445
11285
  },
10446
- hasCapability: async (key) => {
11286
+ hasCapability: async (key2) => {
10447
11287
  const flags = await resolveFlags();
10448
- return flags[key];
11288
+ return flags[key2];
10449
11289
  }
10450
11290
  }
10451
11291
  };
@@ -10603,8 +11443,8 @@ function getOsInfo() {
10603
11443
  function getPlatformVersions() {
10604
11444
  const versions = {};
10605
11445
  if (typeof globalThis.process?.versions === "object") {
10606
- for (const [key, value] of Object.entries(globalThis.process.versions)) {
10607
- versions[key] = value || null;
11446
+ for (const [key2, value] of Object.entries(globalThis.process.versions)) {
11447
+ versions[key2] = value || null;
10608
11448
  }
10609
11449
  }
10610
11450
  return versions;
@@ -10846,9 +11686,9 @@ async function emitWithTimeout(transport, subject, event) {
10846
11686
  }
10847
11687
  function mergeUserContext(event, userContext) {
10848
11688
  const merged = { ...event };
10849
- for (const [key, value] of Object.entries(userContext)) {
10850
- if (merged[key] == null) {
10851
- merged[key] = value;
11689
+ for (const [key2, value] of Object.entries(userContext)) {
11690
+ if (merged[key2] == null) {
11691
+ merged[key2] = value;
10852
11692
  }
10853
11693
  }
10854
11694
  return merged;
@@ -12121,9 +12961,9 @@ function createWaiter() {
12121
12961
  }
12122
12962
  };
12123
12963
  }
12124
- function addToMap(m, key, value) {
12125
- const existing = m.get(key) ?? [];
12126
- m.set(key, [...existing, value]);
12964
+ function addToMap(m, key2, value) {
12965
+ const existing = m.get(key2) ?? [];
12966
+ m.set(key2, [...existing, value]);
12127
12967
  }
12128
12968
  async function runBatchedDrainPipeline(options) {
12129
12969
  const {
@@ -12926,14 +13766,14 @@ function toWireConnections(connections) {
12926
13766
  }
12927
13767
  function toWireAppVersions(appVersions) {
12928
13768
  const wire = {};
12929
- for (const [key, entry] of Object.entries(appVersions)) {
13769
+ for (const [key2, entry] of Object.entries(appVersions)) {
12930
13770
  const implementationName = entry.implementationName ?? entry.implementation_name;
12931
13771
  if (implementationName === void 0) {
12932
13772
  throw new ZapierValidationError(
12933
- `appVersions["${key}"] is missing implementationName`
13773
+ `appVersions["${key2}"] is missing implementationName`
12934
13774
  );
12935
13775
  }
12936
- wire[key] = {
13776
+ wire[key2] = {
12937
13777
  implementation_name: implementationName,
12938
13778
  ...entry.version !== void 0 ? { version: entry.version } : {}
12939
13779
  };
@@ -14342,4 +15182,4 @@ function createZapierSdk2(options = {}) {
14342
15182
  );
14343
15183
  }
14344
15184
 
14345
- export { ActionKeyPropertySchema, ActionPropertySchema, ActionTimeoutMsPropertySchema, ActionTypePropertySchema, AppKeyPropertySchema, AppPropertySchema, AppsPropertySchema, AuthMechanism, AuthenticationIdPropertySchema, BaseSdkOptionsSchema, CONTEXT_CACHE_MAX_SIZE, CONTEXT_CACHE_TTL_MS, CORE_ERROR_SYMBOL, ClientCredentialsObjectSchema, ConnectionEntrySchema, ConnectionIdPropertySchema, ConnectionPropertySchema, ConnectionsMapSchema, ConnectionsPropertySchema, CoreErrorCode, CredentialsFunctionSchema, CredentialsObjectSchema, CredentialsSchema, DEFAULT_ACTION_TIMEOUT_MS, DEFAULT_APPROVAL_TIMEOUT_MS, DEFAULT_CONFIG_PATH, DEFAULT_MAX_APPROVAL_RETRIES, DEFAULT_PAGE_SIZE, DEPRECATION_NOTICE_EVENT, DebugPropertySchema, FieldsPropertySchema, InputFieldPropertySchema, InputsPropertySchema, LeaseLimitPropertySchema, LeasePropertySchema, LeaseSecondsPropertySchema, LimitPropertySchema, MAX_CONCURRENCY_LIMIT, MAX_PAGE_LIMIT, OffsetPropertySchema, OutputPropertySchema, ParamsPropertySchema, PkceCredentialsObjectSchema, RecordPropertySchema, RecordsPropertySchema, RelayFetchSchema, RelayRequestSchema, ResolvedCredentialsSchema, TablePropertySchema, TablesPropertySchema, TriggerInboxNamePropertySchema, TriggerInboxPropertySchema, ZAPIER_BASE_URL, ZAPIER_MAX_CONCURRENT_REQUESTS, ZAPIER_MAX_NETWORK_RETRIES, ZAPIER_MAX_NETWORK_RETRY_DELAY_MS, ZapierAbortDrainSignal, ZapierActionError, ZapierApiError, ZapierAppNotFoundError, ZapierApprovalError, ZapierAuthenticationError, ZapierBundleError, ZapierConfigurationError, ZapierConflictError, ZapierError, ZapierNotFoundError, ZapierRateLimitError, ZapierRelayError, ZapierReleaseTriggerMessageSignal, ZapierResourceNotFoundError, ZapierSignal, ZapierTimeoutError, ZapierUnknownError, ZapierValidationError, actionKeyResolver, actionTypeResolver, addPlugin, apiPlugin, appKeyResolver, appsPlugin, connectionIdGenericResolver as authenticationIdGenericResolver, connectionIdResolver as authenticationIdResolver, batch, buildApplicationLifecycleEvent, buildCapabilityMessage, buildErrorEvent, buildErrorEventWithContext, buildMethodCalledEvent, cleanupEventListeners, clearTokenCache, clientCredentialsNameResolver, clientIdResolver, composePlugins, connectionIdGenericResolver, connectionIdResolver, connectionsPlugin, createBaseEvent, createClientCredentialsPlugin, createCorePlugin, createFunction, createMemoryCache, createOptionsPlugin, createPaginatedPluginMethod, createPluginMethod, createPluginStack, createSdk, createTableFieldsPlugin, createTablePlugin, createTableRecordsPlugin, createZapierApi, createZapierCoreStack, createZapierSdk2 as createZapierSdk, createZapierSdkStack2 as createZapierSdkStack, createZapierSdkWithoutRegistry, dangerousContextPlugin, declareMethod, declareProperty, defineLegacyMerge, defineMethod, definePlugin, defineProperty, deleteClientCredentialsPlugin, deleteTableFieldsPlugin, deleteTablePlugin, deleteTableRecordsPlugin, durableRunIdResolver, eventEmissionPlugin, fetchPlugin, findFirstConnectionPlugin, findManifestEntry, findUniqueConnectionPlugin, formatErrorMessage, fromFunctionPlugin, generateEventId, getActionInputFieldsSchemaPlugin, getActionPlugin, getAgent, getAppPlugin, getBaseUrlFromCredentials, getCallerContext, getCiPlatform, getClientIdFromCredentials, getConnectionPlugin, getContext, getCoreErrorCause, getCoreErrorCode, getCpuTime, getCurrentTimestamp, getMemoryUsage, getOrCreateApiClient, getOsInfo, getPlatformVersions, getPreferredManifestEntryKey, getProfilePlugin, getReleaseId, getTablePlugin, getTableRecordPlugin, getTokenFromCliLogin, getTtyContext, getZapierApprovalMode, getZapierDefaultApprovalMode, getZapierOpenAutoModeApprovalsInBrowser, getZapierSdkService, injectCliLogin, inputFieldKeyResolver, inputsAllOptionalResolver, inputsResolver, invalidateCachedToken, invalidateCredentialsToken, isCi, isCliLoginAvailable, isClientCredentials, isCoreError, isCredentialsFunction, isCredentialsObject, isPermanentHttpError, isPkceCredentials, isPositional, listActionInputFieldChoicesPlugin, listActionInputFieldsPlugin, listActionsPlugin, listAppsPlugin, listClientCredentialsPlugin, listConnectionsPlugin, listTableFieldsPlugin, listTableRecordsPlugin, listTablesPlugin, logDeprecation2 as logDeprecation, manifestPlugin, parseConcurrencyEnvVar, readManifestFromFile, registryPlugin, requestPlugin, resetDeprecationWarnings2 as resetDeprecationWarnings, resolveAuth, resolveAuthToken, resolveCredentials, resolveCredentialsFromEnv, runActionPlugin, runInMethodScope, runWithCallerContext, runWithTelemetryContext, tableFieldIdsResolver, tableFieldsResolver, tableFiltersResolver, tableIdResolver, tableNameResolver, tableRecordIdResolver, tableRecordIdsResolver, tableRecordsResolver, tableSortResolver, tableUpdateRecordsResolver, toSnakeCase, toTitleCase, triggerInboxResolver, triggerMessagesResolver, updateTableRecordsPlugin, workflowIdResolver, workflowRunIdResolver, workflowVersionIdResolver, zapierAdaptError, zapierSdkPlugin };
15185
+ export { ActionKeyPropertySchema, ActionPropertySchema, ActionTimeoutMsPropertySchema, ActionTypePropertySchema, AppKeyPropertySchema, AppPropertySchema, AppsPropertySchema, AuthMechanism, AuthenticationIdPropertySchema, BaseSdkOptionsSchema, CONTEXT_CACHE_MAX_SIZE, CONTEXT_CACHE_TTL_MS, CORE_ERROR_SYMBOL, CORE_SIGNAL_SYMBOL, ClientCredentialsObjectSchema, ConnectionEntrySchema, ConnectionIdPropertySchema, ConnectionPropertySchema, ConnectionsMapSchema, ConnectionsPropertySchema, CoreCancelledSignal, CoreErrorCode, CoreSignal, CredentialsFunctionSchema, CredentialsObjectSchema, CredentialsSchema, DEFAULT_ACTION_TIMEOUT_MS, DEFAULT_APPROVAL_TIMEOUT_MS, DEFAULT_CONFIG_PATH, DEFAULT_MAX_APPROVAL_RETRIES, DEFAULT_PAGE_SIZE, DEPRECATION_NOTICE_EVENT, DebugPropertySchema, FieldsPropertySchema, InputFieldPropertySchema, InputsPropertySchema, LeaseLimitPropertySchema, LeasePropertySchema, LeaseSecondsPropertySchema, LimitPropertySchema, MAX_CONCURRENCY_LIMIT, MAX_PAGE_LIMIT, OffsetPropertySchema, OutputPropertySchema, ParamsPropertySchema, PkceCredentialsObjectSchema, RecordPropertySchema, RecordsPropertySchema, RelayFetchSchema, RelayRequestSchema, ResolvedCredentialsSchema, TablePropertySchema, TablesPropertySchema, TriggerInboxNamePropertySchema, TriggerInboxPropertySchema, ZAPIER_BASE_URL, ZAPIER_MAX_CONCURRENT_REQUESTS, ZAPIER_MAX_NETWORK_RETRIES, ZAPIER_MAX_NETWORK_RETRY_DELAY_MS, ZapierAbortDrainSignal, ZapierActionError, ZapierApiError, ZapierAppNotFoundError, ZapierApprovalError, ZapierAuthenticationError, ZapierBundleError, ZapierConfigurationError, ZapierConflictError, ZapierError, ZapierNotFoundError, ZapierRateLimitError, ZapierRelayError, ZapierReleaseTriggerMessageSignal, ZapierResourceNotFoundError, ZapierSignal, ZapierTimeoutError, ZapierUnknownError, ZapierValidationError, actionKeyResolver, actionTypeResolver, addPlugin, apiPlugin, appKeyResolver, appsPlugin, connectionIdGenericResolver as authenticationIdGenericResolver, connectionIdResolver as authenticationIdResolver, batch, buildApplicationLifecycleEvent, buildCapabilityMessage, buildErrorEvent, buildErrorEventWithContext, buildMethodCalledEvent, cleanupEventListeners, clearTokenCache, clientCredentialsNameResolver, clientIdResolver, composePlugins, connectionIdGenericResolver, connectionIdResolver, connectionsPlugin, createBaseEvent, createClientCredentialsPlugin, createController, createCorePlugin, createFunction, createMemoryCache, createOptionsPlugin, createPaginatedPluginMethod, createPluginMethod, createPluginStack, createSdk, createTableFieldsPlugin, createTablePlugin, createTableRecordsPlugin, createZapierApi, createZapierCoreStack, createZapierSdk2 as createZapierSdk, createZapierSdkStack2 as createZapierSdkStack, createZapierSdkWithoutRegistry, dangerousContextPlugin, declareMethod, declareProperty, defineLegacyMerge, defineMethod, definePlugin, defineProperty, defineResolver, deleteClientCredentialsPlugin, deleteTableFieldsPlugin, deleteTablePlugin, deleteTableRecordsPlugin, durableRunIdResolver, eventEmissionPlugin, fetchPlugin, findFirstConnectionPlugin, findManifestEntry, findUniqueConnectionPlugin, formatErrorMessage, fromFunctionPlugin, generateEventId, getActionInputFieldsSchemaPlugin, getActionPlugin, getAgent, getAppPlugin, getBaseUrlFromCredentials, getCallerContext, getCiPlatform, getClientIdFromCredentials, getConnectionPlugin, getContext, getCoreErrorCause, getCoreErrorCode, getCpuTime, getCurrentTimestamp, getMemoryUsage, getOrCreateApiClient, getOsInfo, getPlatformVersions, getPreferredManifestEntryKey, getProfilePlugin, getReleaseId, getTablePlugin, getTableRecordPlugin, getTokenFromCliLogin, getTtyContext, getZapierApprovalMode, getZapierDefaultApprovalMode, getZapierOpenAutoModeApprovalsInBrowser, getZapierSdkService, injectCliLogin, inputFieldKeyResolver, inputsAllOptionalResolver, inputsResolver, invalidateCachedToken, invalidateCredentialsToken, isCi, isCliLoginAvailable, isClientCredentials, isCoreError, isCoreSignal, isCredentialsFunction, isCredentialsObject, isPermanentHttpError, isPkceCredentials, isPositional, listActionInputFieldChoicesPlugin, listActionInputFieldsPlugin, listActionsPlugin, listAppsPlugin, listClientCredentialsPlugin, listConnectionsPlugin, listTableFieldsPlugin, listTableRecordsPlugin, listTablesPlugin, logDeprecation2 as logDeprecation, manifestPlugin, parseConcurrencyEnvVar, readManifestFromFile, registryPlugin, requestPlugin, resetDeprecationWarnings2 as resetDeprecationWarnings, resolveAuth, resolveAuthToken, resolveCredentials, resolveCredentialsFromEnv, runActionPlugin, runInMethodScope, runWithCallerContext, runWithTelemetryContext, tableFieldIdsResolver, tableFieldsResolver, tableFiltersResolver, tableIdResolver, tableNameResolver, tableRecordIdResolver, tableRecordIdsResolver, tableRecordsResolver, tableSortResolver, tableUpdateRecordsResolver, toSnakeCase, toTitleCase, triggerInboxResolver, triggerMessagesResolver, updateTableRecordsPlugin, workflowIdResolver, workflowRunIdResolver, workflowVersionIdResolver, zapierAdaptError, zapierSdkPlugin };