lua-cli 3.45.0 → 3.47.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.
@@ -84,8 +84,8 @@ function workflowJobTargetTemplatePath(binding) {
84
84
  __name(workflowJobTargetTemplatePath, "workflowJobTargetTemplatePath");
85
85
  __name2(workflowJobTargetTemplatePath, "workflowJobTargetTemplatePath");
86
86
  function isWorkflowJobTargetTemplate(target) {
87
- const agentId = target?.agentId;
88
- return !!agentId && typeof agentId === "object";
87
+ const agentId2 = target?.agentId;
88
+ return !!agentId2 && typeof agentId2 === "object";
89
89
  }
90
90
  __name(isWorkflowJobTargetTemplate, "isWorkflowJobTargetTemplate");
91
91
  __name2(isWorkflowJobTargetTemplate, "isWorkflowJobTargetTemplate");
@@ -107,12 +107,12 @@ function workflowJobTargetProblem(target, plugins, luaApi) {
107
107
  if (target === void 0) return null;
108
108
  if (!target || typeof target !== "object" || Array.isArray(target)) return "target must be { agentId }";
109
109
  const keys = Object.keys(target);
110
- const agentId = target.agentId;
110
+ const agentId2 = target.agentId;
111
111
  if (keys.length !== 1 || !("agentId" in target)) return "target must be exactly { agentId }";
112
- if (typeof agentId === "string") {
113
- if (!agentId.trim() || agentId.length > 256) return "target must be exactly { agentId: <non-empty string> }";
114
- if (agentId.includes("${")) return "a run-input target is written template('${initData.<path>}'), never a string with ${\u2026}";
115
- } else if (workflowJobTargetTemplatePath(agentId) === null) {
112
+ if (typeof agentId2 === "string") {
113
+ if (!agentId2.trim() || agentId2.length > 256) return "target must be exactly { agentId: <non-empty string> }";
114
+ if (agentId2.includes("${")) return "a run-input target is written template('${initData.<path>}'), never a string with ${\u2026}";
115
+ } else if (workflowJobTargetTemplatePath(agentId2) === null) {
116
116
  return "target.agentId must be a static id or template('${initData.<path>}') \u2014 exactly one initData placeholder, no default";
117
117
  }
118
118
  const hasPlugins = Array.isArray(plugins) && plugins.length > 0;
@@ -140,25 +140,25 @@ function readInitDataPath(root, path) {
140
140
  __name(readInitDataPath, "readInitDataPath");
141
141
  __name2(readInitDataPath, "readInitDataPath");
142
142
  function renderWorkflowJobTarget(target, initData) {
143
- const agentId = target?.agentId;
144
- if (target === void 0 || target === null || agentId === void 0) return {
143
+ const agentId2 = target?.agentId;
144
+ if (target === void 0 || target === null || agentId2 === void 0) return {
145
145
  ok: true,
146
146
  agentId: void 0,
147
147
  templated: false
148
148
  };
149
- if (typeof agentId === "string") {
150
- if (!agentId.trim() || agentId.includes("${")) return {
149
+ if (typeof agentId2 === "string") {
150
+ if (!agentId2.trim() || agentId2.includes("${")) return {
151
151
  ok: false,
152
152
  reason: "invalid",
153
153
  message: "target.agentId is invalid"
154
154
  };
155
155
  return {
156
156
  ok: true,
157
- agentId,
157
+ agentId: agentId2,
158
158
  templated: false
159
159
  };
160
160
  }
161
- const path = workflowJobTargetTemplatePath(agentId);
161
+ const path = workflowJobTargetTemplatePath(agentId2);
162
162
  if (path === null) return {
163
163
  ok: false,
164
164
  reason: "invalid",
@@ -196,6 +196,7 @@ import { z } from "zod";
196
196
  import { z as z2 } from "zod";
197
197
  import { z as z3 } from "zod";
198
198
  import { z as z4 } from "zod";
199
+ import { z as z5 } from "zod";
199
200
  var __defProp3 = Object.defineProperty;
200
201
  var __name3 = /* @__PURE__ */ __name((target, value3) => __defProp3(target, "name", { value: value3, configurable: true }), "__name");
201
202
  var PLUMBING_THREAD_CHANNELS = [
@@ -433,8 +434,8 @@ function isPlatformInvocationCaller(v) {
433
434
  }
434
435
  __name(isPlatformInvocationCaller, "isPlatformInvocationCaller");
435
436
  __name3(isPlatformInvocationCaller, "isPlatformInvocationCaller");
436
- function supervisionSubjectId(agentId) {
437
- return `agent:${agentId}`;
437
+ function supervisionSubjectId(agentId2) {
438
+ return `agent:${agentId2}`;
438
439
  }
439
440
  __name(supervisionSubjectId, "supervisionSubjectId");
440
441
  __name3(supervisionSubjectId, "supervisionSubjectId");
@@ -561,7 +562,14 @@ var SUPERVISION_OPS = {
561
562
  * that was ACTIVE before, is OLDER than the active one and was active within the last 7 days. CAS on the active
562
563
  * version; only from a workflow step the watchdog grant names. Held only by a watchdog grant.
563
564
  */
564
- "versions.rollback": "rollback"
565
+ "versions.rollback": "rollback",
566
+ // [JR]
567
+ /**
568
+ * JR (BAC-2011) — `Agents.jobs(id).register({ versionId, jobId })`: register a job that is pinned in a STAGED version of
569
+ * the target (`snapshot.jobs[]`) so the promote activates and schedules it. Mongo-only marker write; EventBridge stays
570
+ * on the post-promote reconcile. Release-class: needs `register-job` AND `release` on the grant, from a signed step.
571
+ */
572
+ "jobs.register": "register-job"
565
573
  };
566
574
  function isSupervisionOp(op) {
567
575
  return typeof op === "string" && Object.prototype.hasOwnProperty.call(SUPERVISION_OPS, op);
@@ -754,6 +762,12 @@ var SUPERVISION_OPS_WAVE2 = {
754
762
  gate: "rollback",
755
763
  targeted: true,
756
764
  item: "WD"
765
+ },
766
+ /** JR (BAC-2011) — `Agents.jobs(id).register({ versionId, jobId })`: a job pinned in a STAGED version (`register-job`). */
767
+ "jobs.register": {
768
+ gate: "register-job",
769
+ targeted: true,
770
+ item: "JR"
757
771
  }
758
772
  };
759
773
  var SUPERVISION_WATCHDOG_OPS = {
@@ -1686,9 +1700,9 @@ function isAgentConnectionMountMode(value3) {
1686
1700
  }
1687
1701
  __name(isAgentConnectionMountMode, "isAgentConnectionMountMode");
1688
1702
  __name3(isAgentConnectionMountMode, "isAgentConnectionMountMode");
1689
- function agentConnectionBindingFor(bindings, agentId) {
1690
- if (!Array.isArray(bindings) || !agentId) return void 0;
1691
- return bindings.find((entry) => !!entry && typeof entry === "object" && entry.agentId === agentId);
1703
+ function agentConnectionBindingFor(bindings, agentId2) {
1704
+ if (!Array.isArray(bindings) || !agentId2) return void 0;
1705
+ return bindings.find((entry) => !!entry && typeof entry === "object" && entry.agentId === agentId2);
1692
1706
  }
1693
1707
  __name(agentConnectionBindingFor, "agentConnectionBindingFor");
1694
1708
  __name3(agentConnectionBindingFor, "agentConnectionBindingFor");
@@ -2104,9 +2118,9 @@ function formatClientOutcomeTurns(outcomes) {
2104
2118
  }
2105
2119
  __name(formatClientOutcomeTurns, "formatClientOutcomeTurns");
2106
2120
  __name3(formatClientOutcomeTurns, "formatClientOutcomeTurns");
2107
- function parseClientOutcomeTurns(text) {
2108
- if (typeof text !== "string") return null;
2109
- const lines = text.split("\n").map((line) => line.trim()).filter(Boolean);
2121
+ function parseClientOutcomeTurns(text2) {
2122
+ if (typeof text2 !== "string") return null;
2123
+ const lines = text2.split("\n").map((line) => line.trim()).filter(Boolean);
2110
2124
  if (lines.length === 0 || lines.length > CLIENT_OUTCOME_TURNS_MAX) return null;
2111
2125
  const out = [];
2112
2126
  for (const line of lines) {
@@ -2260,8 +2274,8 @@ function describeConnectionRequest(input) {
2260
2274
  }
2261
2275
  __name(describeConnectionRequest, "describeConnectionRequest");
2262
2276
  __name3(describeConnectionRequest, "describeConnectionRequest");
2263
- function operationDailyCapKey(agentId, connectionId, currency, utcDay) {
2264
- return `opcap:${agentId}:${connectionId}:${currency.toUpperCase()}:${utcDay}`;
2277
+ function operationDailyCapKey(agentId2, connectionId, currency, utcDay) {
2278
+ return `opcap:${agentId2}:${connectionId}:${currency.toUpperCase()}:${utcDay}`;
2265
2279
  }
2266
2280
  __name(operationDailyCapKey, "operationDailyCapKey");
2267
2281
  __name3(operationDailyCapKey, "operationDailyCapKey");
@@ -2318,7 +2332,7 @@ function parseCapAmount(value3) {
2318
2332
  }
2319
2333
  __name(parseCapAmount, "parseCapAmount");
2320
2334
  __name3(parseCapAmount, "parseCapAmount");
2321
- function parseAgentConnectionOperationLimits(agentId, value3) {
2335
+ function parseAgentConnectionOperationLimits(agentId2, value3) {
2322
2336
  if (!isPlainObject(value3)) return {
2323
2337
  ok: false,
2324
2338
  error: "limits must be an object"
@@ -2331,7 +2345,7 @@ function parseAgentConnectionOperationLimits(agentId, value3) {
2331
2345
  };
2332
2346
  }
2333
2347
  const limits = {
2334
- agentId
2348
+ agentId: agentId2
2335
2349
  };
2336
2350
  if (value3.caps !== void 0 && value3.caps !== null) {
2337
2351
  const caps = value3.caps;
@@ -2419,17 +2433,17 @@ function parseAgentConnectionOperationLimits(agentId, value3) {
2419
2433
  }
2420
2434
  __name(parseAgentConnectionOperationLimits, "parseAgentConnectionOperationLimits");
2421
2435
  __name3(parseAgentConnectionOperationLimits, "parseAgentConnectionOperationLimits");
2422
- function findAgentConnectionOperationLimits(stored, agentId) {
2423
- if (!agentId || stored === void 0 || stored === null) return void 0;
2436
+ function findAgentConnectionOperationLimits(stored, agentId2) {
2437
+ if (!agentId2 || stored === void 0 || stored === null) return void 0;
2424
2438
  if (!Array.isArray(stored)) return {
2425
- agentId,
2439
+ agentId: agentId2,
2426
2440
  unreadable: true
2427
2441
  };
2428
- const entry = stored.find((row) => isPlainObject(row) && row.agentId === agentId);
2442
+ const entry = stored.find((row) => isPlainObject(row) && row.agentId === agentId2);
2429
2443
  if (!entry) return void 0;
2430
- const parsed = parseAgentConnectionOperationLimits(agentId, entry);
2444
+ const parsed = parseAgentConnectionOperationLimits(agentId2, entry);
2431
2445
  return parsed.ok ? parsed.limits : {
2432
- agentId,
2446
+ agentId: agentId2,
2433
2447
  unreadable: true
2434
2448
  };
2435
2449
  }
@@ -2495,9 +2509,9 @@ function idOrName(value3) {
2495
2509
  }
2496
2510
  __name(idOrName, "idOrName");
2497
2511
  __name3(idOrName, "idOrName");
2498
- function addresses(text) {
2499
- if (typeof text !== "string") return [];
2500
- return (text.match(EMAIL_IN_TEXT) ?? []).map((address) => address.toLowerCase());
2512
+ function addresses(text2) {
2513
+ if (typeof text2 !== "string") return [];
2514
+ return (text2.match(EMAIL_IN_TEXT) ?? []).map((address) => address.toLowerCase());
2501
2515
  }
2502
2516
  __name(addresses, "addresses");
2503
2517
  __name3(addresses, "addresses");
@@ -2651,8 +2665,8 @@ __name3(contentRecordExcluded, "contentRecordExcluded");
2651
2665
  var MAX_EXCLUSION_DEPTH = 32;
2652
2666
  function jsonLookingString(value3) {
2653
2667
  if (typeof value3 !== "string") return false;
2654
- const text = value3.trim();
2655
- return text.startsWith("{") && text.endsWith("}") || text.startsWith("[") && text.endsWith("]");
2668
+ const text2 = value3.trim();
2669
+ return text2.startsWith("{") && text2.endsWith("}") || text2.startsWith("[") && text2.endsWith("]");
2656
2670
  }
2657
2671
  __name(jsonLookingString, "jsonLookingString");
2658
2672
  __name3(jsonLookingString, "jsonLookingString");
@@ -2676,11 +2690,11 @@ function applyContentExclusions(value3, exclusions) {
2676
2690
  };
2677
2691
  let removed = 0;
2678
2692
  let blocked = false;
2679
- const walkString = /* @__PURE__ */ __name3((text, depth) => {
2680
- const parsed = parseEmbeddedJson(text);
2681
- if (!parsed) return text;
2693
+ const walkString = /* @__PURE__ */ __name3((text2, depth) => {
2694
+ const parsed = parseEmbeddedJson(text2);
2695
+ if (!parsed) return text2;
2682
2696
  const next2 = walk22(parsed.value, depth);
2683
- return next2 === parsed.value ? text : JSON.stringify(next2);
2697
+ return next2 === parsed.value ? text2 : JSON.stringify(next2);
2684
2698
  }, "walkString");
2685
2699
  const walk22 = /* @__PURE__ */ __name3((node, depth) => {
2686
2700
  if (blocked) return node;
@@ -2786,8 +2800,8 @@ function contentProjectionParameters(params) {
2786
2800
  if (PROJECTION_PARAMETER_KEYS.has(name)) {
2787
2801
  found.push(key);
2788
2802
  } else if (name === "expand") {
2789
- const text = typeof value3 === "string" ? value3 : JSON.stringify(value3 ?? "");
2790
- if (/select/i.test(normaliseRequestParameterKey(text))) found.push(key);
2803
+ const text2 = typeof value3 === "string" ? value3 : JSON.stringify(value3 ?? "");
2804
+ if (/select/i.test(normaliseRequestParameterKey(text2))) found.push(key);
2791
2805
  }
2792
2806
  }
2793
2807
  return found;
@@ -2876,9 +2890,9 @@ __name(currencyMinorUnitExponent, "currencyMinorUnitExponent");
2876
2890
  __name3(currencyMinorUnitExponent, "currencyMinorUnitExponent");
2877
2891
  var DECIMAL_AMOUNT = /^(\d+)(?:\.(\d+))?$/;
2878
2892
  function majorToMinorUnits(amount, currency) {
2879
- const text = typeof amount === "number" ? Number.isFinite(amount) ? String(amount) : "" : typeof amount === "string" ? amount.trim() : "";
2880
- if (/e/i.test(text)) return void 0;
2881
- const match = DECIMAL_AMOUNT.exec(text);
2893
+ const text2 = typeof amount === "number" ? Number.isFinite(amount) ? String(amount) : "" : typeof amount === "string" ? amount.trim() : "";
2894
+ if (/e/i.test(text2)) return void 0;
2895
+ const match = DECIMAL_AMOUNT.exec(text2);
2882
2896
  if (!match) return void 0;
2883
2897
  const exponent = currencyMinorUnitExponent(currency);
2884
2898
  const whole = match[1];
@@ -2892,9 +2906,9 @@ function majorToMinorUnits(amount, currency) {
2892
2906
  __name(majorToMinorUnits, "majorToMinorUnits");
2893
2907
  __name3(majorToMinorUnits, "majorToMinorUnits");
2894
2908
  function readMinorUnits(amount) {
2895
- const text = typeof amount === "number" ? String(amount) : typeof amount === "string" ? amount.trim() : "";
2896
- if (!/^\d+$/.test(text)) return void 0;
2897
- const minor = Number(text);
2909
+ const text2 = typeof amount === "number" ? String(amount) : typeof amount === "string" ? amount.trim() : "";
2910
+ if (!/^\d+$/.test(text2)) return void 0;
2911
+ const minor = Number(text2);
2898
2912
  return Number.isSafeInteger(minor) ? minor : void 0;
2899
2913
  }
2900
2914
  __name(readMinorUnits, "readMinorUnits");
@@ -3020,8 +3034,8 @@ function isWorkflowSecretKey(key) {
3020
3034
  }
3021
3035
  __name(isWorkflowSecretKey, "isWorkflowSecretKey");
3022
3036
  __name3(isWorkflowSecretKey, "isWorkflowSecretKey");
3023
- function applyPatterns(text, patterns, counter) {
3024
- let out = text;
3037
+ function applyPatterns(text2, patterns, counter) {
3038
+ let out = text2;
3025
3039
  for (const { re, suffix } of patterns) {
3026
3040
  re.lastIndex = 0;
3027
3041
  if (!re.test(out)) continue;
@@ -3043,21 +3057,21 @@ function applyPatterns(text, patterns, counter) {
3043
3057
  }
3044
3058
  __name(applyPatterns, "applyPatterns");
3045
3059
  __name3(applyPatterns, "applyPatterns");
3046
- function scrubSecretText(text) {
3047
- if (typeof text !== "string" || text.length < 4) return text;
3048
- return applyPatterns(applyPatterns(text, SECRET_LITERAL_PATTERNS), SECRET_PAIR_PATTERNS);
3060
+ function scrubSecretText(text2) {
3061
+ if (typeof text2 !== "string" || text2.length < 4) return text2;
3062
+ return applyPatterns(applyPatterns(text2, SECRET_LITERAL_PATTERNS), SECRET_PAIR_PATTERNS);
3049
3063
  }
3050
3064
  __name(scrubSecretText, "scrubSecretText");
3051
3065
  __name3(scrubSecretText, "scrubSecretText");
3052
- function scrubSecretTextCounted(text) {
3053
- if (typeof text !== "string" || text.length < 4) return {
3054
- text,
3066
+ function scrubSecretTextCounted(text2) {
3067
+ if (typeof text2 !== "string" || text2.length < 4) return {
3068
+ text: text2,
3055
3069
  redactions: 0
3056
3070
  };
3057
3071
  const counter = {
3058
3072
  redactions: 0
3059
3073
  };
3060
- const out = applyPatterns(applyPatterns(text, SECRET_LITERAL_PATTERNS, counter), SECRET_PAIR_PATTERNS, counter);
3074
+ const out = applyPatterns(applyPatterns(text2, SECRET_LITERAL_PATTERNS, counter), SECRET_PAIR_PATTERNS, counter);
3061
3075
  return {
3062
3076
  text: out,
3063
3077
  redactions: counter.redactions
@@ -3067,12 +3081,12 @@ __name(scrubSecretTextCounted, "scrubSecretTextCounted");
3067
3081
  __name3(scrubSecretTextCounted, "scrubSecretTextCounted");
3068
3082
  var SCRUB_INPUT_MAX_CHARS = 16 * 1024;
3069
3083
  var SCRUB_CUT_BACKOFF_CHARS = 256;
3070
- function boundScrubInput(text, max = SCRUB_INPUT_MAX_CHARS) {
3071
- if (typeof text !== "string" || text.length <= max) return text;
3072
- const window = text.slice(Math.max(0, max - SCRUB_CUT_BACKOFF_CHARS), max);
3084
+ function boundScrubInput(text2, max = SCRUB_INPUT_MAX_CHARS) {
3085
+ if (typeof text2 !== "string" || text2.length <= max) return text2;
3086
+ const window = text2.slice(Math.max(0, max - SCRUB_CUT_BACKOFF_CHARS), max);
3073
3087
  const ws = window.search(/\s\S*$/);
3074
3088
  const cut2 = ws >= 0 ? max - window.length + ws : max;
3075
- return `${text.slice(0, cut2)}\u2026`;
3089
+ return `${text2.slice(0, cut2)}\u2026`;
3076
3090
  }
3077
3091
  __name(boundScrubInput, "boundScrubInput");
3078
3092
  __name3(boundScrubInput, "boundScrubInput");
@@ -3098,9 +3112,9 @@ function messageText(value3) {
3098
3112
  __name(messageText, "messageText");
3099
3113
  __name3(messageText, "messageText");
3100
3114
  function scrubProviderMessage(raw, max = PROVIDER_MESSAGE_MAX_CHARS) {
3101
- const text = boundScrubInput(messageText(raw)).replace(/\s+/g, " ").trim();
3102
- if (!text) return void 0;
3103
- const out = scrubSecretText(text);
3115
+ const text2 = boundScrubInput(messageText(raw)).replace(/\s+/g, " ").trim();
3116
+ if (!text2) return void 0;
3117
+ const out = scrubSecretText(text2);
3104
3118
  return out.length > max ? `${out.slice(0, max - 1)}\u2026` : out;
3105
3119
  }
3106
3120
  __name(scrubProviderMessage, "scrubProviderMessage");
@@ -3206,9 +3220,9 @@ function evalCaseThreadId(runId, caseId) {
3206
3220
  }
3207
3221
  __name(evalCaseThreadId, "evalCaseThreadId");
3208
3222
  __name3(evalCaseThreadId, "evalCaseThreadId");
3209
- function evalMonthlyCapKey(agentId, at = /* @__PURE__ */ new Date()) {
3223
+ function evalMonthlyCapKey(agentId2, at = /* @__PURE__ */ new Date()) {
3210
3224
  const yyyymm = `${at.getUTCFullYear()}${String(at.getUTCMonth() + 1).padStart(2, "0")}`;
3211
- return `evalcap:${agentId}:${yyyymm}`;
3225
+ return `evalcap:${agentId2}:${yyyymm}`;
3212
3226
  }
3213
3227
  __name(evalMonthlyCapKey, "evalMonthlyCapKey");
3214
3228
  __name3(evalMonthlyCapKey, "evalMonthlyCapKey");
@@ -3302,19 +3316,19 @@ var MEMBERS = [
3302
3316
  "account"
3303
3317
  ];
3304
3318
  var FORMAT_CHARS = /[\p{Cf}\u200b-\u200d\u202a-\u202e\u2066-\u2069\ufeff]/u;
3305
- function hasFormatCharacters(text) {
3306
- return FORMAT_CHARS.test(text);
3319
+ function hasFormatCharacters(text2) {
3320
+ return FORMAT_CHARS.test(text2);
3307
3321
  }
3308
3322
  __name(hasFormatCharacters, "hasFormatCharacters");
3309
3323
  __name3(hasFormatCharacters, "hasFormatCharacters");
3310
- var oneLine = /* @__PURE__ */ __name3((text) => text.replace(/[\u0000-\u001f\u007f-\u009f\u2028\u2029"\u201c\u201d]/g, " ").replace(/\s+/g, " ").trim(), "oneLine");
3324
+ var oneLine = /* @__PURE__ */ __name3((text2) => text2.replace(/[\u0000-\u001f\u007f-\u009f\u2028\u2029"\u201c\u201d]/g, " ").replace(/\s+/g, " ").trim(), "oneLine");
3311
3325
  function normalizedHandoverName(name) {
3312
3326
  return oneLine(name.normalize("NFKC")).toLowerCase();
3313
3327
  }
3314
3328
  __name(normalizedHandoverName, "normalizedHandoverName");
3315
3329
  __name3(normalizedHandoverName, "normalizedHandoverName");
3316
- function handoverAgentIdSuffix(agentId) {
3317
- return agentId.slice(-6);
3330
+ function handoverAgentIdSuffix(agentId2) {
3331
+ return agentId2.slice(-6);
3318
3332
  }
3319
3333
  __name(handoverAgentIdSuffix, "handoverAgentIdSuffix");
3320
3334
  __name3(handoverAgentIdSuffix, "handoverAgentIdSuffix");
@@ -3382,8 +3396,8 @@ __name3(normalizeConnectionHandoverArgs, "normalizeConnectionHandoverArgs");
3382
3396
  function approvalPayloadCoversConnectionHandover(payload, stored) {
3383
3397
  const p = parseConnectionHandoverApprovalPayload(payload);
3384
3398
  if (!p) return false;
3385
- const text = describeConnectionHandoverApproval(payload) ?? "";
3386
- if (text.length > CONNECTION_HANDOVER_APPROVAL_CARD_MAX_CHARS || scrubSecretText(text) !== text) return false;
3399
+ const text2 = describeConnectionHandoverApproval(payload) ?? "";
3400
+ if (text2.length > CONNECTION_HANDOVER_APPROVAL_CARD_MAX_CHARS || scrubSecretText(text2) !== text2) return false;
3387
3401
  const storedAccount = stored.account?.trim() || void 0;
3388
3402
  return p.connectionId === stored.connectionId && p.agentId === stored.agentId && p.agentName === stored.agentName.trim() && p.supervisorName === stored.supervisorName.trim() && p.integration === stored.integration && p.account === storedAccount;
3389
3403
  }
@@ -3747,13 +3761,13 @@ function parseThreadFollowUpInput(input) {
3747
3761
  if (hasPrompt === hasMessage) return null;
3748
3762
  const raw = hasPrompt ? o.prompt : o.message;
3749
3763
  if (typeof raw !== "string") return null;
3750
- const text = raw.trim();
3764
+ const text2 = raw.trim();
3751
3765
  const max = hasPrompt ? THREAD_FOLLOW_UP_LIMITS.promptMax : THREAD_FOLLOW_UP_LIMITS.messageMax;
3752
- if (text.length === 0 || text.length > max) return null;
3766
+ if (text2.length === 0 || text2.length > max) return null;
3753
3767
  if (o.idempotencyKey !== void 0 && !isValidCallerDedupeKey(o.idempotencyKey)) return null;
3754
3768
  return {
3755
3769
  mode: hasPrompt ? "turn" : "message",
3756
- text,
3770
+ text: text2,
3757
3771
  ...o.idempotencyKey !== void 0 ? {
3758
3772
  idempotencyKey: o.idempotencyKey
3759
3773
  } : {}
@@ -3761,11 +3775,11 @@ function parseThreadFollowUpInput(input) {
3761
3775
  }
3762
3776
  __name(parseThreadFollowUpInput, "parseThreadFollowUpInput");
3763
3777
  __name3(parseThreadFollowUpInput, "parseThreadFollowUpInput");
3764
- function threadFollowUpRateKeys(agentId, threadId, nowMs) {
3778
+ function threadFollowUpRateKeys(agentId2, threadId, nowMs) {
3765
3779
  const hour = Math.floor(nowMs / 36e5);
3766
3780
  return {
3767
- perThread: `thread-followup:${agentId}:${threadId}:${hour}`,
3768
- perAgent: `thread-followup:${agentId}:${hour}`
3781
+ perThread: `thread-followup:${agentId2}:${threadId}:${hour}`,
3782
+ perAgent: `thread-followup:${agentId2}:${hour}`
3769
3783
  };
3770
3784
  }
3771
3785
  __name(threadFollowUpRateKeys, "threadFollowUpRateKeys");
@@ -4696,8 +4710,8 @@ function withOverride(def, override) {
4696
4710
  "effect",
4697
4711
  "confirm"
4698
4712
  ]) {
4699
- const text = stored[field];
4700
- if (typeof text === "string" && text.trim()) next[field] = text;
4713
+ const text2 = stored[field];
4714
+ if (typeof text2 === "string" && text2.trim()) next[field] = text2;
4701
4715
  }
4702
4716
  if (def.tunableDefault && stored.default !== void 0) {
4703
4717
  const check = validateChannelSettingValue(def, stored.default);
@@ -4822,26 +4836,26 @@ function validateChannelSettingValue(def, value3, channel) {
4822
4836
  ok: false,
4823
4837
  error: "Must not be empty"
4824
4838
  };
4825
- const text = value3.trim();
4826
- if (rules.maxLength !== void 0 && text.length > rules.maxLength) {
4839
+ const text2 = value3.trim();
4840
+ if (rules.maxLength !== void 0 && text2.length > rules.maxLength) {
4827
4841
  return {
4828
4842
  ok: false,
4829
4843
  error: `Must be at most ${rules.maxLength} characters`
4830
4844
  };
4831
4845
  }
4832
- if (UNSAFE_TEXT.test(text)) return {
4846
+ if (UNSAFE_TEXT.test(text2)) return {
4833
4847
  ok: false,
4834
4848
  error: 'Must not contain <, > or " characters'
4835
4849
  };
4836
- if (rules.format === "slackReaction" && resolveSlackReactionName(text) === void 0) {
4850
+ if (rules.format === "slackReaction" && resolveSlackReactionName(text2) === void 0) {
4837
4851
  return {
4838
4852
  ok: false,
4839
- error: `${text} is not an emoji Slack can react with; use a common emoji or a :shortcode:`
4853
+ error: `${text2} is not an emoji Slack can react with; use a common emoji or a :shortcode:`
4840
4854
  };
4841
4855
  }
4842
4856
  return {
4843
4857
  ok: true,
4844
- value: text
4858
+ value: text2
4845
4859
  };
4846
4860
  }
4847
4861
  case "enum": {
@@ -5276,11 +5290,11 @@ function transformChatHistoryContentParts(parts) {
5276
5290
  mediaType: videoMatch[1]
5277
5291
  });
5278
5292
  } else {
5279
- let text = rawText.replace(/\\\\\\n/g, "\n");
5280
- text = removeNavigateBlock(text);
5293
+ let text2 = rawText.replace(/\\\\\\n/g, "\n");
5294
+ text2 = removeNavigateBlock(text2);
5281
5295
  content.push({
5282
5296
  type: "text",
5283
- text
5297
+ text: text2
5284
5298
  });
5285
5299
  }
5286
5300
  } else if (part.type === "file") {
@@ -5411,6 +5425,102 @@ function foldRichPartsIntoMessages(messages, records, makeMessage, sameTurnGroup
5411
5425
  }
5412
5426
  __name(foldRichPartsIntoMessages, "foldRichPartsIntoMessages");
5413
5427
  __name3(foldRichPartsIntoMessages, "foldRichPartsIntoMessages");
5428
+ var WORK_ITEMS_KEY = "_luaWorkItems";
5429
+ var MAX_WORK_ITEMS = 100;
5430
+ var LIMITS = {
5431
+ id: 200,
5432
+ title: 120,
5433
+ group: 40,
5434
+ status: 40,
5435
+ action: 200
5436
+ };
5437
+ function text(item, field, index, required) {
5438
+ const value3 = item[field];
5439
+ if (value3 === void 0 && !required) return void 0;
5440
+ if (typeof value3 !== "string" || required && value3.trim().length === 0) {
5441
+ throw new Error(`Work item ${index}: \`${field}\` must be a ${required ? "non-empty " : ""}string`);
5442
+ }
5443
+ if ([
5444
+ ...value3
5445
+ ].length > LIMITS[field]) {
5446
+ throw new Error(`Work item ${index}: \`${field}\` is longer than ${LIMITS[field]} characters`);
5447
+ }
5448
+ return value3;
5449
+ }
5450
+ __name(text, "text");
5451
+ __name3(text, "text");
5452
+ function normalizeWorkItems(items) {
5453
+ if (!Array.isArray(items)) throw new Error("Work items must be an array");
5454
+ if (items.length > MAX_WORK_ITEMS) {
5455
+ throw new Error(`At most ${MAX_WORK_ITEMS} work items can be published (got ${items.length})`);
5456
+ }
5457
+ const seen = /* @__PURE__ */ new Set();
5458
+ return items.map((raw, index) => {
5459
+ if (!raw || typeof raw !== "object" || Array.isArray(raw)) {
5460
+ throw new Error(`Work item ${index} must be an object`);
5461
+ }
5462
+ const item = raw;
5463
+ const id2 = text(item, "id", index, true);
5464
+ if (seen.has(id2)) throw new Error(`Work item ${index}: \`id\` "${id2}" is used more than once`);
5465
+ seen.add(id2);
5466
+ const title = text(item, "title", index, true);
5467
+ const group = text(item, "group", index, true);
5468
+ const action = text(item, "action", index, true);
5469
+ const status = text(item, "status", index, false);
5470
+ if (item.needsAction !== void 0 && typeof item.needsAction !== "boolean") {
5471
+ throw new Error(`Work item ${index}: \`needsAction\` must be a boolean`);
5472
+ }
5473
+ const when = item.updatedAt;
5474
+ const date = when instanceof Date ? when : typeof when === "string" ? new Date(when) : null;
5475
+ if (!date || Number.isNaN(date.getTime())) {
5476
+ throw new Error(`Work item ${index}: \`updatedAt\` must be a valid date`);
5477
+ }
5478
+ return {
5479
+ id: id2,
5480
+ title,
5481
+ group,
5482
+ ...item.needsAction !== void 0 ? {
5483
+ needsAction: item.needsAction
5484
+ } : {},
5485
+ ...status !== void 0 ? {
5486
+ status
5487
+ } : {},
5488
+ updatedAt: date.toISOString(),
5489
+ action
5490
+ };
5491
+ });
5492
+ }
5493
+ __name(normalizeWorkItems, "normalizeWorkItems");
5494
+ __name3(normalizeWorkItems, "normalizeWorkItems");
5495
+ function workItemsRecord(items, now = /* @__PURE__ */ new Date()) {
5496
+ return {
5497
+ v: 1,
5498
+ items: normalizeWorkItems(items),
5499
+ updatedAt: now.toISOString()
5500
+ };
5501
+ }
5502
+ __name(workItemsRecord, "workItemsRecord");
5503
+ __name3(workItemsRecord, "workItemsRecord");
5504
+ function withoutWorkItems(data) {
5505
+ if (!data || typeof data !== "object" || !(WORK_ITEMS_KEY in data)) return data;
5506
+ const { [WORK_ITEMS_KEY]: _list, ...rest } = data;
5507
+ return rest;
5508
+ }
5509
+ __name(withoutWorkItems, "withoutWorkItems");
5510
+ __name3(withoutWorkItems, "withoutWorkItems");
5511
+ function mutationWithoutWorkItems(mutation) {
5512
+ return {
5513
+ ...mutation,
5514
+ ...mutation.set ? {
5515
+ set: withoutWorkItems(mutation.set)
5516
+ } : {},
5517
+ ...mutation.unset ? {
5518
+ unset: mutation.unset.filter((field) => field !== WORK_ITEMS_KEY)
5519
+ } : {}
5520
+ };
5521
+ }
5522
+ __name(mutationWithoutWorkItems, "mutationWithoutWorkItems");
5523
+ __name3(mutationWithoutWorkItems, "mutationWithoutWorkItems");
5414
5524
  var BROWSER_COMMANDS = [
5415
5525
  // health + lifecycle / navigation
5416
5526
  {
@@ -8587,8 +8697,8 @@ function scheduleHealthView(health, state3) {
8587
8697
  }
8588
8698
  __name(scheduleHealthView, "scheduleHealthView");
8589
8699
  __name3(scheduleHealthView, "scheduleHealthView");
8590
- function scheduleHealthSourceId(agentId, jobId) {
8591
- return `schedule-health:${agentId}:${jobId}`;
8700
+ function scheduleHealthSourceId(agentId2, jobId) {
8701
+ return `schedule-health:${agentId2}:${jobId}`;
8592
8702
  }
8593
8703
  __name(scheduleHealthSourceId, "scheduleHealthSourceId");
8594
8704
  __name3(scheduleHealthSourceId, "scheduleHealthSourceId");
@@ -8627,17 +8737,17 @@ var MAX_KEY_CHARS = 64;
8627
8737
  var KEY_SCRUB_INPUT_MAX_CHARS = 256;
8628
8738
  var STRING_SCRUB_INPUT_MAX_CHARS = 4 * APPROVAL_ARG_STRING_MAX_CHARS;
8629
8739
  var ELLIPSIS = "\u2026";
8630
- function cut(text, max) {
8631
- if (text.length <= max) return text;
8740
+ function cut(text2, max) {
8741
+ if (text2.length <= max) return text2;
8632
8742
  let end = Math.max(0, max - 1);
8633
- const last = text.charCodeAt(end - 1);
8743
+ const last = text2.charCodeAt(end - 1);
8634
8744
  if (last >= 55296 && last <= 56319) end -= 1;
8635
- return `${text.slice(0, end)}${ELLIPSIS}`;
8745
+ return `${text2.slice(0, end)}${ELLIPSIS}`;
8636
8746
  }
8637
8747
  __name(cut, "cut");
8638
8748
  __name3(cut, "cut");
8639
- function scrubString(text, state3) {
8640
- const scrubbed = scrubSecretText(boundScrubInput(text, STRING_SCRUB_INPUT_MAX_CHARS));
8749
+ function scrubString(text2, state3) {
8750
+ const scrubbed = scrubSecretText(boundScrubInput(text2, STRING_SCRUB_INPUT_MAX_CHARS));
8641
8751
  if (scrubbed.length > APPROVAL_ARG_STRING_MAX_CHARS) state3.truncated = true;
8642
8752
  return cut(scrubbed, APPROVAL_ARG_STRING_MAX_CHARS);
8643
8753
  }
@@ -8729,10 +8839,10 @@ function walkObject(obj, depth, state3) {
8729
8839
  }
8730
8840
  __name(walkObject, "walkObject");
8731
8841
  __name3(walkObject, "walkObject");
8732
- function fitString(text, room) {
8733
- let n2 = Math.min(text.length, room - 3);
8842
+ function fitString(text2, room) {
8843
+ let n2 = Math.min(text2.length, room - 3);
8734
8844
  while (n2 >= 16) {
8735
- const candidate = cut(text, n2);
8845
+ const candidate = cut(text2, n2);
8736
8846
  if (JSON.stringify(candidate).length <= room) return candidate;
8737
8847
  n2 = Math.floor(n2 * 0.8);
8738
8848
  }
@@ -8831,9 +8941,9 @@ function createPersistScrubber(maxChars = PERSIST_SCRUB_MAX_CHARS) {
8831
8941
  const bounded = boundScrubInput(value3, remaining);
8832
8942
  if (bounded !== value3) state3.truncated = true;
8833
8943
  remaining -= bounded.length;
8834
- const { text, redactions } = scrubSecretTextCounted(bounded);
8944
+ const { text: text2, redactions } = scrubSecretTextCounted(bounded);
8835
8945
  state3.redactions += redactions;
8836
- return text;
8946
+ return text2;
8837
8947
  }, "scrub");
8838
8948
  return {
8839
8949
  scrub,
@@ -8845,9 +8955,9 @@ __name3(createPersistScrubber, "createPersistScrubber");
8845
8955
  function scrubMessageContentForPersist(content, maxChars = PERSIST_SCRUB_MAX_CHARS) {
8846
8956
  const { scrub, state: state3 } = createPersistScrubber(maxChars);
8847
8957
  if (typeof content === "string") {
8848
- const text = scrub(content);
8958
+ const text2 = scrub(content);
8849
8959
  return {
8850
- content: text !== content ? text : content,
8960
+ content: text2 !== content ? text2 : content,
8851
8961
  ...state3
8852
8962
  };
8853
8963
  }
@@ -8859,19 +8969,19 @@ function scrubMessageContentForPersist(content, maxChars = PERSIST_SCRUB_MAX_CHA
8859
8969
  let changed = false;
8860
8970
  const parts = content.map((part) => {
8861
8971
  if (typeof part === "string") {
8862
- const text = scrub(part);
8863
- if (text === part) return part;
8972
+ const text2 = scrub(part);
8973
+ if (text2 === part) return part;
8864
8974
  changed = true;
8865
- return text;
8975
+ return text2;
8866
8976
  }
8867
8977
  if (part && typeof part === "object" && part.type === "text" && typeof part.text === "string") {
8868
8978
  const original = part.text;
8869
- const text = scrub(original);
8870
- if (text === original) return part;
8979
+ const text2 = scrub(original);
8980
+ if (text2 === original) return part;
8871
8981
  changed = true;
8872
8982
  return {
8873
8983
  ...part,
8874
- text
8984
+ text: text2
8875
8985
  };
8876
8986
  }
8877
8987
  return part;
@@ -9196,11 +9306,11 @@ __name3(workflowApprovalDecisionOf, "workflowApprovalDecisionOf");
9196
9306
  function workflowApprovalOutput(resumeData) {
9197
9307
  const decision = typeof resumeData.decision === "string" ? resumeData.decision : workflowApprovalDecisionOf(resumeData);
9198
9308
  const note = typeof resumeData.note === "string" && resumeData.note.trim() !== "" ? resumeData.note : void 0;
9199
- const text = typeof resumeData.text === "string" ? resumeData.text : note ?? decision;
9309
+ const text2 = typeof resumeData.text === "string" ? resumeData.text : note ?? decision;
9200
9310
  return {
9201
9311
  ...resumeData,
9202
9312
  decision,
9203
- text
9313
+ text: text2
9204
9314
  };
9205
9315
  }
9206
9316
  __name(workflowApprovalOutput, "workflowApprovalOutput");
@@ -9213,8 +9323,8 @@ function isWorkflowApprovalOutput(value3) {
9213
9323
  __name(isWorkflowApprovalOutput, "isWorkflowApprovalOutput");
9214
9324
  __name3(isWorkflowApprovalOutput, "isWorkflowApprovalOutput");
9215
9325
  var JSON_FENCE_RE = /```(?:json)?[ \t]*\r?\n([\s\S]*?)\r?\n?```/g;
9216
- function extractSingleJsonValue(text) {
9217
- const trimmed = (text ?? "").trim();
9326
+ function extractSingleJsonValue(text2) {
9327
+ const trimmed = (text2 ?? "").trim();
9218
9328
  if (!trimmed) return {
9219
9329
  reason: "reply is empty"
9220
9330
  };
@@ -9759,8 +9869,8 @@ var ATTACHMENT_LINES = [
9759
9869
  (m) => `[File: ${m[1]}]`
9760
9870
  ]
9761
9871
  ];
9762
- function evidenceDisplayText(text) {
9763
- const raw = typeof text === "string" ? text : "";
9872
+ function evidenceDisplayText(text2) {
9873
+ const raw = typeof text2 === "string" ? text2 : "";
9764
9874
  if (!raw.trim()) return "";
9765
9875
  const lines = removeHiddenBlocks(raw).split(/\r?\n/).map((line) => {
9766
9876
  const t = line.trim();
@@ -9775,15 +9885,15 @@ function evidenceDisplayText(text) {
9775
9885
  }
9776
9886
  __name(evidenceDisplayText, "evidenceDisplayText");
9777
9887
  __name3(evidenceDisplayText, "evidenceDisplayText");
9778
- function evidenceSnippet(text) {
9779
- const flat = evidenceDisplayText(text);
9888
+ function evidenceSnippet(text2) {
9889
+ const flat = evidenceDisplayText(text2);
9780
9890
  return flat.length <= EVIDENCE_SNIPPET_MAX_CHARS ? flat : `${flat.slice(0, EVIDENCE_SNIPPET_MAX_CHARS - 1)}\u2026`;
9781
9891
  }
9782
9892
  __name(evidenceSnippet, "evidenceSnippet");
9783
9893
  __name3(evidenceSnippet, "evidenceSnippet");
9784
- function evidenceWordCount(text) {
9785
- if (typeof text !== "string") return 0;
9786
- const t = text.trim();
9894
+ function evidenceWordCount(text2) {
9895
+ if (typeof text2 !== "string") return 0;
9896
+ const t = text2.trim();
9787
9897
  return t ? t.split(/\s+/).length : 0;
9788
9898
  }
9789
9899
  __name(evidenceWordCount, "evidenceWordCount");
@@ -9793,10 +9903,10 @@ function evidenceKey(label) {
9793
9903
  }
9794
9904
  __name(evidenceKey, "evidenceKey");
9795
9905
  __name3(evidenceKey, "evidenceKey");
9796
- function evidenceOpaqueKey(text) {
9906
+ function evidenceOpaqueKey(text2) {
9797
9907
  let h = 0xcbf29ce484222325n;
9798
9908
  const prime = 0x100000001b3n;
9799
- for (const ch of evidenceKey(text)) {
9909
+ for (const ch of evidenceKey(text2)) {
9800
9910
  h ^= BigInt(ch.codePointAt(0) ?? 0);
9801
9911
  h = h * prime & 0xffffffffffffffffn;
9802
9912
  }
@@ -9947,7 +10057,7 @@ function evidenceDays(from, to) {
9947
10057
  __name(evidenceDays, "evidenceDays");
9948
10058
  __name3(evidenceDays, "evidenceDays");
9949
10059
  function summarizeEvidence(input) {
9950
- const { agentId, from, to } = input;
10060
+ const { agentId: agentId2, from, to } = input;
9951
10061
  const windowDays = evidenceDays(from, to);
9952
10062
  const readable = /* @__PURE__ */ __name3((s) => s === "ok" || s === "empty", "readable");
9953
10063
  const covered = /* @__PURE__ */ __name3((d) => readable(d.sources?.messages) && readable(d.sources?.analyses), "covered");
@@ -10021,7 +10131,7 @@ function summarizeEvidence(input) {
10021
10131
  const short = wordRows.reduce((a, h) => a + h.short, 0);
10022
10132
  const long = wordRows.reduce((a, h) => a + h.long, 0);
10023
10133
  return {
10024
- agentId,
10134
+ agentId: agentId2,
10025
10135
  window: {
10026
10136
  from,
10027
10137
  to,
@@ -10676,16 +10786,16 @@ function slashDecodedPath(path) {
10676
10786
  }
10677
10787
  __name(slashDecodedPath, "slashDecodedPath");
10678
10788
  __name3(slashDecodedPath, "slashDecodedPath");
10679
- function jsonHasDuplicateKey(text) {
10789
+ function jsonHasDuplicateKey(text2) {
10680
10790
  const stack = [];
10681
- for (let i = 0; i < text.length; i++) {
10682
- const c = text[i];
10791
+ for (let i = 0; i < text2.length; i++) {
10792
+ const c = text2[i];
10683
10793
  if (c === '"') {
10684
10794
  let j = i + 1;
10685
- while (j < text.length && text[j] !== '"') j += text[j] === "\\" ? 2 : 1;
10795
+ while (j < text2.length && text2[j] !== '"') j += text2[j] === "\\" ? 2 : 1;
10686
10796
  const top = stack[stack.length - 1];
10687
10797
  if (top && top.expectKey) {
10688
- const key = JSON.parse(text.slice(i, j + 1));
10798
+ const key = JSON.parse(text2.slice(i, j + 1));
10689
10799
  if (top.keys.has(key)) return true;
10690
10800
  top.keys.add(key);
10691
10801
  top.expectKey = false;
@@ -10779,7 +10889,7 @@ function classifyConnectionOperation(op) {
10779
10889
  __name(classifyConnectionOperation, "classifyConnectionOperation");
10780
10890
  __name3(classifyConnectionOperation, "classifyConnectionOperation");
10781
10891
  function connectionSendPolicyIsActive(policy) {
10782
- return Boolean(policy) && (policy.allowSend === false || Array.isArray(policy.recipientAllowlist));
10892
+ return !!policy && (policy.allowSend === false || Array.isArray(policy.recipientAllowlist));
10783
10893
  }
10784
10894
  __name(connectionSendPolicyIsActive, "connectionSendPolicyIsActive");
10785
10895
  __name3(connectionSendPolicyIsActive, "connectionSendPolicyIsActive");
@@ -10815,8 +10925,9 @@ function evaluateConnectionSendPolicy(policy, op) {
10815
10925
  classification
10816
10926
  };
10817
10927
  }
10818
- if (Array.isArray(policy.recipientAllowlist)) {
10819
- const denied = classification.recipients.filter((email) => !allowlistAdmits(policy.recipientAllowlist, email));
10928
+ const allowlist = policy.recipientAllowlist;
10929
+ if (Array.isArray(allowlist)) {
10930
+ const denied = classification.recipients.filter((email) => !allowlistAdmits(allowlist, email));
10820
10931
  if (denied.length > 0 || classification.recipientsUnknown) {
10821
10932
  return {
10822
10933
  allowed: false,
@@ -10870,10 +10981,605 @@ function isPaymentRequiredChatErrorEnvelope(data) {
10870
10981
  }
10871
10982
  __name(isPaymentRequiredChatErrorEnvelope, "isPaymentRequiredChatErrorEnvelope");
10872
10983
  __name3(isPaymentRequiredChatErrorEnvelope, "isPaymentRequiredChatErrorEnvelope");
10984
+ var CUSTOM_MCP_CONNECTION_ID_PREFIX = "mcp_";
10985
+ var CUSTOM_MCP_SOURCE = "custom";
10986
+ var CUSTOM_MCP_TRANSPORT = "streamable-http";
10987
+ var CUSTOM_MCP_CONNECTION_ID_PATTERN = /^mcp_[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;
10988
+ function isCustomMcpConnectionId(id2) {
10989
+ return typeof id2 === "string" && id2.startsWith(CUSTOM_MCP_CONNECTION_ID_PREFIX);
10990
+ }
10991
+ __name(isCustomMcpConnectionId, "isCustomMcpConnectionId");
10992
+ __name3(isCustomMcpConnectionId, "isCustomMcpConnectionId");
10993
+ var customMcpConnectionIdSchema = z5.string().regex(CUSTOM_MCP_CONNECTION_ID_PATTERN);
10994
+ var CONNECTION_BACKED_MCP_SOURCES = [
10995
+ "unifiedto",
10996
+ CUSTOM_MCP_SOURCE
10997
+ ];
10998
+ function isConnectionBackedMcpSource(source) {
10999
+ return typeof source === "string" && CONNECTION_BACKED_MCP_SOURCES.includes(source);
11000
+ }
11001
+ __name(isConnectionBackedMcpSource, "isConnectionBackedMcpSource");
11002
+ __name3(isConnectionBackedMcpSource, "isConnectionBackedMcpSource");
11003
+ var CUSTOM_MCP_REFERENCE_ID_PATTERN = /^mcpx_[0-9a-f]{12}$/;
11004
+ var customMcpReferenceIdSchema = z5.string().regex(CUSTOM_MCP_REFERENCE_ID_PATTERN);
11005
+ function newCustomMcpReferenceId() {
11006
+ const bytes = globalThis.crypto.getRandomValues(new Uint8Array(6));
11007
+ return `mcpx_${Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0")).join("")}`;
11008
+ }
11009
+ __name(newCustomMcpReferenceId, "newCustomMcpReferenceId");
11010
+ __name3(newCustomMcpReferenceId, "newCustomMcpReferenceId");
11011
+ var CUSTOM_MCP_AUTH_KINDS = [
11012
+ "none",
11013
+ "headers",
11014
+ "oauth"
11015
+ ];
11016
+ var customMcpAuthKindSchema = z5.enum(CUSTOM_MCP_AUTH_KINDS);
11017
+ var CUSTOM_MCP_OAUTH_REGISTRATIONS = [
11018
+ "cimd",
11019
+ "dcr",
11020
+ "manual"
11021
+ ];
11022
+ var customMcpOAuthRegistrationSchema = z5.enum(CUSTOM_MCP_OAUTH_REGISTRATIONS);
11023
+ var CUSTOM_MCP_HEALTH_STATES = [
11024
+ "ok",
11025
+ "failing",
11026
+ "needs_sign_in",
11027
+ "auth_rejected"
11028
+ ];
11029
+ var customMcpHealthStateSchema = z5.enum(CUSTOM_MCP_HEALTH_STATES);
11030
+ var CUSTOM_MCP_FAILURE_STEPS = [
11031
+ "url",
11032
+ "reach",
11033
+ "auth_challenge",
11034
+ "resource_metadata",
11035
+ "authorization_server_metadata",
11036
+ "pkce",
11037
+ "client_registration",
11038
+ "authorize",
11039
+ "token_exchange",
11040
+ "list_tools"
11041
+ ];
11042
+ var customMcpFailureStepSchema = z5.enum(CUSTOM_MCP_FAILURE_STEPS);
11043
+ var CUSTOM_MCP_CONNECT_STEPS = [
11044
+ "url",
11045
+ "reach",
11046
+ "auth_challenge",
11047
+ "list_tools"
11048
+ ];
11049
+ var customMcpConnectStepSchema = z5.enum(CUSTOM_MCP_CONNECT_STEPS);
11050
+ var customMcpFailureCodeSchema = z5.string().regex(/^[a-z0-9_]{1,64}$/);
11051
+ var WORKFLOW_KEY_MAX_LENGTH = 64;
11052
+ function customMcpWorkflowKey(displayName) {
11053
+ const slug = displayName.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
11054
+ if (!slug) return `s-${fnv1a32(displayName.trim())}`;
11055
+ return (/^[a-z]/.test(slug) ? slug : `s-${slug}`).slice(0, WORKFLOW_KEY_MAX_LENGTH);
11056
+ }
11057
+ __name(customMcpWorkflowKey, "customMcpWorkflowKey");
11058
+ __name3(customMcpWorkflowKey, "customMcpWorkflowKey");
11059
+ function fnv1a32(value3) {
11060
+ let hash = 2166136261;
11061
+ for (const char of value3) {
11062
+ hash ^= char.codePointAt(0) ?? 0;
11063
+ hash = Math.imul(hash, 16777619) >>> 0;
11064
+ }
11065
+ return hash.toString(16).padStart(8, "0");
11066
+ }
11067
+ __name(fnv1a32, "fnv1a32");
11068
+ __name3(fnv1a32, "fnv1a32");
11069
+ var CUSTOM_MCP_URL_MAX_LENGTH = 2048;
11070
+ var CUSTOM_MCP_DISPLAY_NAME_MAX_LENGTH = 120;
11071
+ var CUSTOM_MCP_MAX_HEADERS = 20;
11072
+ var CUSTOM_MCP_HEADER_NAME_MAX_LENGTH = 128;
11073
+ var CUSTOM_MCP_HEADER_VALUE_MAX_LENGTH = 8192;
11074
+ var CUSTOM_MCP_MAX_TOOLS = 500;
11075
+ var CUSTOM_MCP_TOOL_NAME_MAX_LENGTH = 256;
11076
+ var CUSTOM_MCP_TOOL_TEXT_MAX_LENGTH = 1024;
11077
+ var CUSTOM_MCP_MIN_TIMEOUT_MS = 1e3;
11078
+ var CUSTOM_MCP_MAX_TIMEOUT_MS = 12e4;
11079
+ var CUSTOM_MCP_OAUTH_PENDING_TTL_MS = 15 * 6e4;
11080
+ var isoDateTime = z5.string().datetime({
11081
+ offset: true
11082
+ });
11083
+ var agentId = z5.string().min(1).max(128);
11084
+ var nonNegativeInt = z5.number().int().min(0);
11085
+ var customMcpUrlInputSchema = z5.string().trim().min(1).max(CUSTOM_MCP_URL_MAX_LENGTH);
11086
+ var customMcpDisplayNameSchema = z5.string().trim().min(1).max(CUSTOM_MCP_DISPLAY_NAME_MAX_LENGTH);
11087
+ var customMcpTimeoutSchema = z5.number().int().min(CUSTOM_MCP_MIN_TIMEOUT_MS).max(CUSTOM_MCP_MAX_TIMEOUT_MS);
11088
+ var CUSTOM_MCP_RESERVED_HEADER_NAMES = [
11089
+ "accept",
11090
+ "connection",
11091
+ "content-length",
11092
+ "content-type",
11093
+ "host",
11094
+ "keep-alive",
11095
+ "last-event-id",
11096
+ "mcp-protocol-version",
11097
+ "mcp-session-id",
11098
+ "proxy-authorization",
11099
+ "te",
11100
+ "trailer",
11101
+ "transfer-encoding",
11102
+ "upgrade"
11103
+ ];
11104
+ var HEADER_NAME = /^[A-Za-z][A-Za-z0-9!#$%&'*+.^_`|~-]*$/;
11105
+ var HEADER_VALUE_FORBIDDEN = /[\u0000-\u0008\u000a-\u001f\u007f]/;
11106
+ var customMcpHeaderNameSchema = z5.string().min(1).max(CUSTOM_MCP_HEADER_NAME_MAX_LENGTH).regex(HEADER_NAME, "Not a valid HTTP header name").refine((name) => !CUSTOM_MCP_RESERVED_HEADER_NAMES.includes(name.toLowerCase()), "This header is set by Lua");
11107
+ var headerValue = z5.string().min(1).max(CUSTOM_MCP_HEADER_VALUE_MAX_LENGTH).refine((value3) => !HEADER_VALUE_FORBIDDEN.test(value3), "Header values cannot contain line breaks");
11108
+ function addCaseDuplicateIssues(names, ctx, path) {
11109
+ const seen = /* @__PURE__ */ new Set();
11110
+ for (const name of names) {
11111
+ const lower2 = name.toLowerCase();
11112
+ if (seen.has(lower2)) {
11113
+ ctx.addIssue({
11114
+ code: z5.ZodIssueCode.custom,
11115
+ path,
11116
+ message: `Header "${name}" is listed twice`
11117
+ });
11118
+ }
11119
+ seen.add(lower2);
11120
+ }
11121
+ }
11122
+ __name(addCaseDuplicateIssues, "addCaseDuplicateIssues");
11123
+ __name3(addCaseDuplicateIssues, "addCaseDuplicateIssues");
11124
+ var customMcpHeadersSchema = z5.record(customMcpHeaderNameSchema, headerValue).superRefine((headers, ctx) => {
11125
+ const names = Object.keys(headers);
11126
+ if (names.length > CUSTOM_MCP_MAX_HEADERS) {
11127
+ ctx.addIssue({
11128
+ code: z5.ZodIssueCode.custom,
11129
+ message: `At most ${CUSTOM_MCP_MAX_HEADERS} headers`
11130
+ });
11131
+ }
11132
+ addCaseDuplicateIssues(names, ctx, []);
11133
+ });
11134
+ var customMcpHeadersPatchSchema = z5.object({
11135
+ set: customMcpHeadersSchema.optional(),
11136
+ remove: z5.array(customMcpHeaderNameSchema).max(CUSTOM_MCP_MAX_HEADERS).optional()
11137
+ }).strict().superRefine((patch, ctx) => {
11138
+ const set = Object.keys(patch.set ?? {});
11139
+ const remove = patch.remove ?? [];
11140
+ if (!set.length && !remove.length) {
11141
+ ctx.addIssue({
11142
+ code: z5.ZodIssueCode.custom,
11143
+ message: "Nothing to change"
11144
+ });
11145
+ }
11146
+ addCaseDuplicateIssues(remove, ctx, [
11147
+ "remove"
11148
+ ]);
11149
+ const setLower = new Set(set.map((name) => name.toLowerCase()));
11150
+ for (const name of remove) {
11151
+ if (setLower.has(name.toLowerCase())) {
11152
+ ctx.addIssue({
11153
+ code: z5.ZodIssueCode.custom,
11154
+ path: [
11155
+ "remove"
11156
+ ],
11157
+ message: `Header "${name}" is both set and removed`
11158
+ });
11159
+ }
11160
+ }
11161
+ });
11162
+ var customMcpToolNameSchema = z5.string().min(1).max(CUSTOM_MCP_TOOL_NAME_MAX_LENGTH);
11163
+ var customMcpToolSchema = z5.object({
11164
+ name: customMcpToolNameSchema,
11165
+ title: z5.string().max(CUSTOM_MCP_TOOL_TEXT_MAX_LENGTH).optional(),
11166
+ description: z5.string().max(CUSTOM_MCP_TOOL_TEXT_MAX_LENGTH).optional()
11167
+ });
11168
+ var customMcpServerInfoSchema = z5.object({
11169
+ name: z5.string().max(CUSTOM_MCP_TOOL_NAME_MAX_LENGTH),
11170
+ version: z5.string().max(128).optional(),
11171
+ title: z5.string().max(CUSTOM_MCP_TOOL_NAME_MAX_LENGTH).optional()
11172
+ });
11173
+ function toCustomMcpToolSnapshot(tools) {
11174
+ const snapshot = [];
11175
+ const seen = /* @__PURE__ */ new Set();
11176
+ for (const tool of tools) {
11177
+ if (snapshot.length >= CUSTOM_MCP_MAX_TOOLS) break;
11178
+ const name = tool.name;
11179
+ if (typeof name !== "string" || !name || name.length > CUSTOM_MCP_TOOL_NAME_MAX_LENGTH || seen.has(name)) continue;
11180
+ seen.add(name);
11181
+ snapshot.push({
11182
+ name,
11183
+ ...typeof tool.title === "string" && tool.title ? {
11184
+ title: tool.title.slice(0, CUSTOM_MCP_TOOL_TEXT_MAX_LENGTH)
11185
+ } : {},
11186
+ ...typeof tool.description === "string" && tool.description ? {
11187
+ description: tool.description.slice(0, CUSTOM_MCP_TOOL_TEXT_MAX_LENGTH)
11188
+ } : {}
11189
+ });
11190
+ }
11191
+ return snapshot;
11192
+ }
11193
+ __name(toCustomMcpToolSnapshot, "toCustomMcpToolSnapshot");
11194
+ __name3(toCustomMcpToolSnapshot, "toCustomMcpToolSnapshot");
11195
+ var customMcpToolSelectionSchema = z5.object({
11196
+ allowAll: z5.boolean(),
11197
+ enabled: z5.array(customMcpToolNameSchema).max(CUSTOM_MCP_MAX_TOOLS)
11198
+ }).strict().refine((selection) => new Set(selection.enabled).size === selection.enabled.length, {
11199
+ path: [
11200
+ "enabled"
11201
+ ],
11202
+ message: "Tool names must be unique"
11203
+ });
11204
+ function customMcpRuntimeToolFilter(selection) {
11205
+ return selection.allowAll ? void 0 : {
11206
+ allow: [
11207
+ ...selection.enabled
11208
+ ]
11209
+ };
11210
+ }
11211
+ __name(customMcpRuntimeToolFilter, "customMcpRuntimeToolFilter");
11212
+ __name3(customMcpRuntimeToolFilter, "customMcpRuntimeToolFilter");
11213
+ var customMcpToolsResponseSchema = z5.object({
11214
+ allowAll: z5.boolean(),
11215
+ tools: z5.array(customMcpToolSchema.extend({
11216
+ enabled: z5.boolean()
11217
+ })),
11218
+ serverInfo: customMcpServerInfoSchema.optional(),
11219
+ refreshedAt: isoDateTime.optional()
11220
+ });
11221
+ var customMcpFailureSchema = z5.object({
11222
+ step: customMcpFailureStepSchema,
11223
+ code: customMcpFailureCodeSchema,
11224
+ /** Plain words for the person connecting. */
11225
+ message: z5.string().max(500),
11226
+ httpStatus: z5.number().int().min(100).max(599).optional(),
11227
+ referenceId: customMcpReferenceIdSchema
11228
+ });
11229
+ var customMcpHealthSchema = z5.object({
11230
+ state: customMcpHealthStateSchema,
11231
+ checkedAt: isoDateTime.optional(),
11232
+ lastOkAt: isoDateTime.optional(),
11233
+ lastFailureAt: isoDateTime.optional(),
11234
+ consecutiveFailures: nonNegativeInt,
11235
+ lastFailure: customMcpFailureSchema.omit({
11236
+ message: true
11237
+ }).optional()
11238
+ });
11239
+ var customMcpErrorBodySchema = z5.object({
11240
+ code: z5.string(),
11241
+ message: z5.string(),
11242
+ failure: customMcpFailureSchema.optional(),
11243
+ callbackUrl: z5.string().url().optional(),
11244
+ retryAfterSeconds: z5.number().int().positive().optional()
11245
+ });
11246
+ var customMcpConnectionBlockSchema = z5.object({
11247
+ authKind: customMcpAuthKindSchema,
11248
+ /** `URL.host`, port included. */
11249
+ host: z5.string(),
11250
+ /** Host plus a masked path; never the URL. */
11251
+ urlDisplay: z5.string(),
11252
+ /** Names only, for the edit form. Present on `headers` connections. */
11253
+ headerNames: z5.array(z5.string()).optional(),
11254
+ /** The workflow connection key that names this server: {@link customMcpWorkflowKey} of its display name. */
11255
+ workflowKey: z5.string().regex(WORKFLOW_CONNECTION_KEY_RE).optional(),
11256
+ health: customMcpHealthSchema,
11257
+ toolCount: nonNegativeInt,
11258
+ enabledToolCount: nonNegativeInt
11259
+ });
11260
+ var customMcpConnectionViewSchema = z5.object({
11261
+ id: customMcpConnectionIdSchema,
11262
+ displayName: z5.string(),
11263
+ ownerType: z5.enum([
11264
+ "user",
11265
+ "agent"
11266
+ ]),
11267
+ agentId: z5.string().optional(),
11268
+ customMcp: customMcpConnectionBlockSchema
11269
+ });
11270
+ var customMcpConnectionResponseSchema = z5.object({
11271
+ connection: customMcpConnectionViewSchema
11272
+ });
11273
+ var customMcpProbeBodySchema = z5.object({
11274
+ url: customMcpUrlInputSchema,
11275
+ headers: customMcpHeadersSchema.optional()
11276
+ }).strict();
11277
+ var customMcpOAuthDiscoverySchema = z5.object({
11278
+ issuer: z5.string().url(),
11279
+ scopes: z5.array(z5.string()),
11280
+ /** `manual_required`: neither CIMD nor DCR; the person registers a client with `callbackUrl`. */
11281
+ registration: z5.enum([
11282
+ "cimd",
11283
+ "dcr",
11284
+ "manual_required"
11285
+ ]),
11286
+ callbackUrl: z5.string().url()
11287
+ });
11288
+ var customMcpProbeResponseSchema = z5.discriminatedUnion("outcome", [
11289
+ z5.object({
11290
+ outcome: z5.literal("connected"),
11291
+ authKind: z5.enum([
11292
+ "none",
11293
+ "headers"
11294
+ ]),
11295
+ serverInfo: customMcpServerInfoSchema,
11296
+ tools: z5.array(customMcpToolSchema)
11297
+ }),
11298
+ /** The server challenged and publishes usable OAuth metadata. */
11299
+ z5.object({
11300
+ outcome: z5.literal("sign_in_required"),
11301
+ oauth: customMcpOAuthDiscoverySchema
11302
+ }),
11303
+ /** The server challenged without usable OAuth and no headers were sent. */
11304
+ z5.object({
11305
+ outcome: z5.literal("credentials_required"),
11306
+ httpStatus: z5.number().int()
11307
+ })
11308
+ ]);
11309
+ var createFields = {
11310
+ url: customMcpUrlInputSchema,
11311
+ displayName: customMcpDisplayNameSchema,
11312
+ timeout: customMcpTimeoutSchema.optional(),
11313
+ /** Defaults to allow-all. */
11314
+ tools: customMcpToolSelectionSchema.optional()
11315
+ };
11316
+ var mountAgentField = {
11317
+ mountAgentId: agentId.optional()
11318
+ };
11319
+ function createBody(extra) {
11320
+ return z5.discriminatedUnion("authKind", [
11321
+ z5.object({
11322
+ authKind: z5.literal("none"),
11323
+ ...createFields,
11324
+ ...extra
11325
+ }).strict(),
11326
+ z5.object({
11327
+ authKind: z5.literal("headers"),
11328
+ headers: customMcpHeadersSchema.refine((headers) => Object.keys(headers).length > 0, "Add a header"),
11329
+ ...createFields,
11330
+ ...extra
11331
+ }).strict()
11332
+ ]);
11333
+ }
11334
+ __name(createBody, "createBody");
11335
+ __name3(createBody, "createBody");
11336
+ var customMcpCreateAgentBodySchema = createBody({});
11337
+ var customMcpCreateUserBodySchema = createBody(mountAgentField);
11338
+ var customMcpOAuthClientSchema = z5.object({
11339
+ clientId: z5.string().trim().min(1).max(512),
11340
+ clientSecret: z5.string().min(1).max(2048).optional()
11341
+ }).strict();
11342
+ var startFields = {
11343
+ successRedirect: z5.string().max(CUSTOM_MCP_URL_MAX_LENGTH),
11344
+ failureRedirect: z5.string().max(CUSTOM_MCP_URL_MAX_LENGTH),
11345
+ state: z5.string().max(256),
11346
+ client: customMcpOAuthClientSchema.optional()
11347
+ };
11348
+ function startBody(extra) {
11349
+ return z5.union([
11350
+ z5.object({
11351
+ url: customMcpUrlInputSchema,
11352
+ displayName: customMcpDisplayNameSchema,
11353
+ ...startFields,
11354
+ ...extra
11355
+ }).strict(),
11356
+ /** Sign in again. `url` only after `REAUTH_REQUIRED`; otherwise the stored URL is used. */
11357
+ z5.object({
11358
+ targetConnectionId: customMcpConnectionIdSchema,
11359
+ url: customMcpUrlInputSchema.optional(),
11360
+ ...startFields
11361
+ }).strict()
11362
+ ]);
11363
+ }
11364
+ __name(startBody, "startBody");
11365
+ __name3(startBody, "startBody");
11366
+ var customMcpOAuthStartAgentBodySchema = startBody({});
11367
+ var customMcpOAuthStartUserBodySchema = startBody(mountAgentField);
11368
+ var customMcpOAuthStartResponseSchema = z5.object({
11369
+ authUrl: z5.string().url(),
11370
+ pendingId: z5.string().min(1),
11371
+ expiresAt: isoDateTime,
11372
+ registration: customMcpOAuthRegistrationSchema
11373
+ });
11374
+ var nonce = z5.string().regex(/^[A-Za-z0-9_-]{32,128}$/);
11375
+ var customMcpOAuthSuccessRedirectQuerySchema = z5.object({
11376
+ state: z5.string(),
11377
+ id: z5.string().min(1),
11378
+ nonce
11379
+ });
11380
+ var CUSTOM_MCP_OAUTH_CALLBACK_ERRORS = [
11381
+ "access_denied",
11382
+ "authorize",
11383
+ "token_exchange",
11384
+ "expired"
11385
+ ];
11386
+ var customMcpOAuthFailureRedirectQuerySchema = z5.object({
11387
+ state: z5.string(),
11388
+ error: z5.enum(CUSTOM_MCP_OAUTH_CALLBACK_ERRORS),
11389
+ ref: customMcpReferenceIdSchema
11390
+ });
11391
+ var customMcpOAuthFinalizeBodySchema = z5.object({
11392
+ pendingId: z5.string().min(1).max(128),
11393
+ nonce,
11394
+ tools: customMcpToolSelectionSchema.optional()
11395
+ }).strict();
11396
+ var customMcpCimdDocumentSchema = z5.object({
11397
+ client_id: z5.string().url(),
11398
+ client_name: z5.string(),
11399
+ client_uri: z5.string().url().optional(),
11400
+ logo_uri: z5.string().url().optional(),
11401
+ redirect_uris: z5.array(z5.string().url()).min(1),
11402
+ grant_types: z5.array(z5.enum([
11403
+ "authorization_code",
11404
+ "refresh_token"
11405
+ ])),
11406
+ response_types: z5.array(z5.literal("code")),
11407
+ token_endpoint_auth_method: z5.literal("none")
11408
+ });
11409
+ var customMcpPatchBodySchema = z5.object({
11410
+ displayName: customMcpDisplayNameSchema.optional(),
11411
+ url: customMcpUrlInputSchema.optional(),
11412
+ headers: customMcpHeadersPatchSchema.optional(),
11413
+ timeout: customMcpTimeoutSchema.optional()
11414
+ }).strict().refine((body) => Object.values(body).some((value3) => value3 !== void 0), {
11415
+ message: "Nothing to change"
11416
+ });
11417
+ var customMcpCredentialRequestSchema = z5.object({
11418
+ mode: z5.enum([
11419
+ "mount",
11420
+ "room_personal"
11421
+ ]),
11422
+ connectionId: customMcpConnectionIdSchema,
11423
+ agentId,
11424
+ /** The server rejected this token version: refresh unless it is already stale. */
11425
+ rejectedTokenVersion: nonNegativeInt.optional()
11426
+ }).strict();
11427
+ var customMcpCredentialAuthSchema = z5.discriminatedUnion("kind", [
11428
+ z5.object({
11429
+ kind: z5.literal("none")
11430
+ }),
11431
+ z5.object({
11432
+ kind: z5.literal("headers"),
11433
+ headers: z5.record(z5.string(), z5.string())
11434
+ }),
11435
+ z5.object({
11436
+ kind: z5.literal("oauth"),
11437
+ accessToken: z5.string().min(1),
11438
+ tokenVersion: nonNegativeInt,
11439
+ /** At least {@link CUSTOM_MCP_ACCESS_TOKEN_MIN_REMAINING_MS} away. */
11440
+ expiresAt: isoDateTime
11441
+ })
11442
+ ]);
11443
+ var customMcpCredentialResponseSchema = z5.object({
11444
+ connectionId: customMcpConnectionIdSchema,
11445
+ credentialGeneration: nonNegativeInt,
11446
+ url: z5.string().url(),
11447
+ auth: customMcpCredentialAuthSchema
11448
+ });
11449
+ var CUSTOM_MCP_CREDENTIAL_ERRORS = {
11450
+ /** 403. Not mounted on this agent, or the room grant is no longer current. */
11451
+ NOT_MOUNTED: "NOT_MOUNTED",
11452
+ /** 404. */
11453
+ NOT_FOUND: "NOT_FOUND",
11454
+ /** 409. Paused by its owner. */
11455
+ PAUSED: "PAUSED",
11456
+ /** 409. The refresh token is gone or was refused; the owner must sign in again. */
11457
+ NEEDS_SIGN_IN: "NEEDS_SIGN_IN",
11458
+ /** 503. The token endpoint failed; retry later. */
11459
+ REFRESH_UNAVAILABLE: "REFRESH_UNAVAILABLE"
11460
+ };
11461
+ var customMcpCredentialErrorBodySchema = z5.object({
11462
+ code: z5.nativeEnum(CUSTOM_MCP_CREDENTIAL_ERRORS),
11463
+ message: z5.string()
11464
+ });
11465
+ var customMcpHealthReportSchema = z5.object({
11466
+ reports: z5.array(z5.object({
11467
+ connectionId: customMcpConnectionIdSchema,
11468
+ agentId,
11469
+ credentialGeneration: nonNegativeInt,
11470
+ tokenVersion: nonNegativeInt.optional(),
11471
+ outcome: z5.enum([
11472
+ "ok",
11473
+ "failure"
11474
+ ]),
11475
+ failure: z5.object({
11476
+ step: customMcpConnectStepSchema,
11477
+ code: customMcpFailureCodeSchema,
11478
+ httpStatus: z5.number().int().min(100).max(599).optional(),
11479
+ referenceId: customMcpReferenceIdSchema
11480
+ }).strict().optional(),
11481
+ observedAt: isoDateTime
11482
+ }).strict().refine((report) => report.outcome === "failure" === (report.failure !== void 0), {
11483
+ path: [
11484
+ "failure"
11485
+ ],
11486
+ message: "A failure report carries `failure`; an ok report does not"
11487
+ })).min(1).max(50)
11488
+ }).strict();
11489
+ var customMcpProbeRequestSchema = z5.object({
11490
+ url: z5.string().url().max(CUSTOM_MCP_URL_MAX_LENGTH),
11491
+ auth: z5.discriminatedUnion("kind", [
11492
+ z5.object({
11493
+ kind: z5.literal("none")
11494
+ }).strict(),
11495
+ z5.object({
11496
+ kind: z5.literal("headers"),
11497
+ headers: customMcpHeadersSchema
11498
+ }).strict(),
11499
+ z5.object({
11500
+ kind: z5.literal("bearer"),
11501
+ accessToken: z5.string().min(1)
11502
+ }).strict()
11503
+ ]),
11504
+ timeout: customMcpTimeoutSchema.optional(),
11505
+ referenceId: customMcpReferenceIdSchema
11506
+ }).strict();
11507
+ var customMcpProbeResultSchema = z5.discriminatedUnion("ok", [
11508
+ z5.object({
11509
+ ok: z5.literal(true),
11510
+ serverInfo: customMcpServerInfoSchema,
11511
+ tools: z5.array(customMcpToolSchema).max(CUSTOM_MCP_MAX_TOOLS),
11512
+ protocolVersion: z5.string().optional()
11513
+ }),
11514
+ z5.object({
11515
+ ok: z5.literal(false),
11516
+ step: customMcpConnectStepSchema,
11517
+ code: customMcpFailureCodeSchema,
11518
+ httpStatus: z5.number().int().min(100).max(599).optional(),
11519
+ /** The 401/403 challenge, raw, for lua-api's OAuth discovery. */
11520
+ wwwAuthenticate: z5.string().max(4096).optional()
11521
+ })
11522
+ ]);
11523
+ var customMcpOriginUrlSchema = z5.string().url().refine((value3) => {
11524
+ try {
11525
+ const url = new URL(value3);
11526
+ return url.protocol === "https:" && url.pathname === "/" && !url.search && !url.hash && !url.username && !url.password;
11527
+ } catch {
11528
+ return false;
11529
+ }
11530
+ }, "Origin only");
11531
+ var customMcpServerProjectionSchema = z5.object({
11532
+ name: z5.string().min(1),
11533
+ runtimeKey: z5.string().min(1),
11534
+ transport: z5.literal(CUSTOM_MCP_TRANSPORT),
11535
+ source: z5.literal(CUSTOM_MCP_SOURCE),
11536
+ url: customMcpOriginUrlSchema,
11537
+ connectionId: customMcpConnectionIdSchema,
11538
+ connectionLabel: z5.string(),
11539
+ /** The connection's owner kind, for the dashboard's "Personal" label. */
11540
+ ownerType: z5.enum([
11541
+ "user",
11542
+ "agent"
11543
+ ]),
11544
+ authKind: customMcpAuthKindSchema,
11545
+ credentialGeneration: nonNegativeInt,
11546
+ tools: z5.object({
11547
+ allow: z5.array(z5.string())
11548
+ }).optional(),
11549
+ timeout: z5.number().int().positive()
11550
+ });
11551
+ var customMcpMountUpsertBodySchema = z5.object({
11552
+ source: z5.literal(CUSTOM_MCP_SOURCE),
11553
+ transport: z5.literal(CUSTOM_MCP_TRANSPORT),
11554
+ url: customMcpOriginUrlSchema,
11555
+ connectionId: customMcpConnectionIdSchema,
11556
+ connectionLabel: z5.string(),
11557
+ ownerType: z5.enum([
11558
+ "user",
11559
+ "agent"
11560
+ ]),
11561
+ authKind: customMcpAuthKindSchema,
11562
+ credentialGeneration: nonNegativeInt,
11563
+ tools: z5.object({
11564
+ allow: z5.array(customMcpToolNameSchema).max(CUSTOM_MCP_MAX_TOOLS)
11565
+ }).strict().optional(),
11566
+ timeout: customMcpTimeoutSchema.optional()
11567
+ }).strict();
11568
+ function maskMcpServerHeaders(server) {
11569
+ const { headers, ...rest } = server;
11570
+ const headerNames = Object.keys(headers ?? {});
11571
+ return {
11572
+ ...rest,
11573
+ headerNames,
11574
+ headersSet: headerNames.length > 0
11575
+ };
11576
+ }
11577
+ __name(maskMcpServerHeaders, "maskMcpServerHeaders");
11578
+ __name3(maskMcpServerHeaders, "maskMcpServerHeaders");
10873
11579
 
10874
11580
  // ../workflow-graph/dist/index.mjs
10875
11581
  import { createHash } from "crypto";
10876
- import { z as z5 } from "zod";
11582
+ import { z as z6 } from "zod";
10877
11583
  import { z as z22 } from "zod";
10878
11584
  import { createHash as createHash2 } from "crypto";
10879
11585
  var __defProp4 = Object.defineProperty;
@@ -11168,8 +11874,8 @@ var rows = /* @__PURE__ */ __name4((s, path, page) => ({
11168
11874
  var fromKnowledge = /* @__PURE__ */ __name4((k) => ({
11169
11875
  knowledge: k
11170
11876
  }), "fromKnowledge");
11171
- var SideEffectsSchema = z5.enum(WORKFLOW_SIDE_EFFECTS);
11172
- var JobResourcesSchema = z5.enum(WORKFLOW_JOB_RESOURCES);
11877
+ var SideEffectsSchema = z6.enum(WORKFLOW_SIDE_EFFECTS);
11878
+ var JobResourcesSchema = z6.enum(WORKFLOW_JOB_RESOURCES);
11173
11879
  var WORKFLOW_MODEL_TEMPLATE_ROOT = "initData";
11174
11880
  var WORKFLOW_MODEL_TEMPLATE_RE = /^\$\{\s*initData\.([A-Za-z0-9_.\-[\]]+)\s*(?:\|([^}]*))?\}$/;
11175
11881
  var PATH_SEGMENT_RE = /^[A-Za-z0-9_-]+(?:\[(?:0|[1-9]\d*)\])*$/;
@@ -11579,17 +12285,17 @@ function firstAskDeadline(node) {
11579
12285
  __name(firstAskDeadline, "firstAskDeadline");
11580
12286
  __name4(firstAskDeadline, "firstAskDeadline");
11581
12287
  function liftRenderedApprover(row, rendered) {
11582
- const text = (rendered ?? "").trim();
11583
- if (!text) return null;
12288
+ const text2 = (rendered ?? "").trim();
12289
+ if (!text2) return null;
11584
12290
  if (row === "users") {
11585
12291
  let members = null;
11586
- if (text.startsWith("[")) {
12292
+ if (text2.startsWith("[")) {
11587
12293
  try {
11588
- members = JSON.parse(text);
12294
+ members = JSON.parse(text2);
11589
12295
  } catch {
11590
12296
  return null;
11591
12297
  }
11592
- } else members = text.split(",").map((s) => s.trim());
12298
+ } else members = text2.split(",").map((s) => s.trim());
11593
12299
  if (!Array.isArray(members) || members.length === 0 || members.length > APPROVER_SPEC_MAX_USERS) return null;
11594
12300
  if (!members.every((m) => typeof m === "string" && m.length > 0 && m.length <= 128)) return null;
11595
12301
  return {
@@ -11598,11 +12304,11 @@ function liftRenderedApprover(row, rendered) {
11598
12304
  ].sort()
11599
12305
  };
11600
12306
  }
11601
- if (text.length > 128 || text.startsWith("[") || text.startsWith("{")) return null;
12307
+ if (text2.length > 128 || text2.startsWith("[") || text2.startsWith("{")) return null;
11602
12308
  return row === "role" ? {
11603
- role: text
12309
+ role: text2
11604
12310
  } : {
11605
- group: text
12311
+ group: text2
11606
12312
  };
11607
12313
  }
11608
12314
  __name(liftRenderedApprover, "liftRenderedApprover");
@@ -11849,9 +12555,9 @@ var isSingleStep = /* @__PURE__ */ __name4((n2) => !isHitlNode(n2), "isSingleSte
11849
12555
  var singleId = /* @__PURE__ */ __name4((s) => s.type === "step" ? s.step.id : s.id, "singleId");
11850
12556
  var armId = /* @__PURE__ */ __name4((a) => a.type === "mapping" ? a.id : singleId(a), "armId");
11851
12557
  var TEMPLATE_STEP_REF = /\$\{\s*stepResults\.([A-Za-z0-9_\-]+)/g;
11852
- function templateStepRefs(text) {
12558
+ function templateStepRefs(text2) {
11853
12559
  const ids = [];
11854
- for (const m of text.matchAll(TEMPLATE_STEP_REF)) ids.push(m[1]);
12560
+ for (const m of text2.matchAll(TEMPLATE_STEP_REF)) ids.push(m[1]);
11855
12561
  return ids;
11856
12562
  }
11857
12563
  __name(templateStepRefs, "templateStepRefs");