lua-cli 3.39.4 → 3.41.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.
@@ -1,6 +1,193 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __name = (target, value3) => __defProp(target, "name", { value: value3, configurable: true });
3
3
 
4
+ // ../shared-types/dist/workflow-job-tools.mjs
5
+ var __defProp2 = Object.defineProperty;
6
+ var __name2 = /* @__PURE__ */ __name((target, value3) => __defProp2(target, "name", { value: value3, configurable: true }), "__name");
7
+ var WORKFLOW_JOB_TOOLS = [
8
+ "shell",
9
+ "read",
10
+ "write",
11
+ "edit",
12
+ "glob",
13
+ "grep",
14
+ "git",
15
+ "gh",
16
+ "fetch",
17
+ "ripwire"
18
+ ];
19
+ var WORKFLOW_JOB_READ_ONLY_DROPPED = [
20
+ "write",
21
+ "edit",
22
+ "git",
23
+ "shell"
24
+ ];
25
+ var WORKFLOW_JOB_DEFAULT_TOOLS = [
26
+ "shell",
27
+ "read",
28
+ "write",
29
+ "edit",
30
+ "glob",
31
+ "grep",
32
+ "git"
33
+ ];
34
+ function effectiveJobTools(jobTools, readOnly) {
35
+ const base = jobTools?.length ? jobTools : WORKFLOW_JOB_DEFAULT_TOOLS;
36
+ const out = [];
37
+ for (const id2 of base) {
38
+ if (readOnly && WORKFLOW_JOB_READ_ONLY_DROPPED.includes(id2)) continue;
39
+ if (!out.includes(id2)) out.push(id2);
40
+ }
41
+ return out;
42
+ }
43
+ __name(effectiveJobTools, "effectiveJobTools");
44
+ __name2(effectiveJobTools, "effectiveJobTools");
45
+ var WORKFLOW_JOB_PLUGINS = [
46
+ "lua-agent-builder"
47
+ ];
48
+ var WORKFLOW_JOB_PLUGIN_ROOT = "/opt/lua/plugins";
49
+ var WORKFLOW_JOB_PLUGINS_MAX = 4;
50
+ function isWorkflowJobPluginId(id2) {
51
+ return typeof id2 === "string" && WORKFLOW_JOB_PLUGINS.includes(id2);
52
+ }
53
+ __name(isWorkflowJobPluginId, "isWorkflowJobPluginId");
54
+ __name2(isWorkflowJobPluginId, "isWorkflowJobPluginId");
55
+ function workflowJobPluginDir(id2) {
56
+ return `${WORKFLOW_JOB_PLUGIN_ROOT}/${id2}`;
57
+ }
58
+ __name(workflowJobPluginDir, "workflowJobPluginDir");
59
+ __name2(workflowJobPluginDir, "workflowJobPluginDir");
60
+ function workflowJobPluginsProblem(plugins) {
61
+ if (plugins === void 0) return null;
62
+ if (!Array.isArray(plugins)) return "plugins must be an array of plugin ids";
63
+ if (plugins.length > WORKFLOW_JOB_PLUGINS_MAX) return `at most ${WORKFLOW_JOB_PLUGINS_MAX} plugins per step`;
64
+ const unknown = plugins.filter((p) => !isWorkflowJobPluginId(p));
65
+ if (unknown.length) return `unknown plugin ${unknown.map((u) => JSON.stringify(u)).join(", ")} (allowed: ${WORKFLOW_JOB_PLUGINS.join(", ")})`;
66
+ if (new Set(plugins).size !== plugins.length) return "plugins must not repeat";
67
+ return null;
68
+ }
69
+ __name(workflowJobPluginsProblem, "workflowJobPluginsProblem");
70
+ __name2(workflowJobPluginsProblem, "workflowJobPluginsProblem");
71
+ var WORKFLOW_JOB_TARGET_TEMPLATE_RE = /^\$\{\s*initData\.([A-Za-z0-9_.\-[\]]+)\s*\}$/;
72
+ var TARGET_PATH_SEGMENT_RE = /^[A-Za-z0-9_-]+(?:\[(?:0|[1-9]\d*)\])*$/;
73
+ function workflowJobTargetTemplatePath(binding) {
74
+ if (!binding || typeof binding !== "object" || Array.isArray(binding)) return null;
75
+ const keys = Object.keys(binding);
76
+ const tpl = binding.template;
77
+ if (keys.length !== 1 || typeof tpl !== "string" || tpl.length > 512) return null;
78
+ const m = WORKFLOW_JOB_TARGET_TEMPLATE_RE.exec(tpl.trim());
79
+ if (!m) return null;
80
+ const names = m[1].split(".").map((seg) => seg.replace(/\[(?:0|[1-9]\d*)\]/g, ""));
81
+ if (names.some((n2) => n2 === "__proto__" || n2 === "prototype" || n2 === "constructor")) return null;
82
+ return m[1].split(".").every((seg) => TARGET_PATH_SEGMENT_RE.test(seg)) ? m[1] : null;
83
+ }
84
+ __name(workflowJobTargetTemplatePath, "workflowJobTargetTemplatePath");
85
+ __name2(workflowJobTargetTemplatePath, "workflowJobTargetTemplatePath");
86
+ function isWorkflowJobTargetTemplate(target) {
87
+ const agentId = target?.agentId;
88
+ return !!agentId && typeof agentId === "object";
89
+ }
90
+ __name(isWorkflowJobTargetTemplate, "isWorkflowJobTargetTemplate");
91
+ __name2(isWorkflowJobTargetTemplate, "isWorkflowJobTargetTemplate");
92
+ function workflowJobLuaApiProblem(luaApi, nodeType, tier) {
93
+ if (luaApi === void 0) return null;
94
+ if (luaApi !== true) return "`luaApi` must be exactly true";
95
+ if (nodeType !== "code") return "`luaApi` is legal on code steps only (an agent step uses `plugins`)";
96
+ if (tier !== "job") return "`luaApi` requires tier:'job'";
97
+ return null;
98
+ }
99
+ __name(workflowJobLuaApiProblem, "workflowJobLuaApiProblem");
100
+ __name2(workflowJobLuaApiProblem, "workflowJobLuaApiProblem");
101
+ function workflowJobUsesLuaApi(step3) {
102
+ return Array.isArray(step3.plugins) && step3.plugins.length > 0 || step3.kind === "code" && step3.luaApi === true;
103
+ }
104
+ __name(workflowJobUsesLuaApi, "workflowJobUsesLuaApi");
105
+ __name2(workflowJobUsesLuaApi, "workflowJobUsesLuaApi");
106
+ function workflowJobTargetProblem(target, plugins, luaApi) {
107
+ if (target === void 0) return null;
108
+ if (!target || typeof target !== "object" || Array.isArray(target)) return "target must be { agentId }";
109
+ const keys = Object.keys(target);
110
+ const agentId = target.agentId;
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) {
116
+ return "target.agentId must be a static id or template('${initData.<path>}') \u2014 exactly one initData placeholder, no default";
117
+ }
118
+ const hasPlugins = Array.isArray(plugins) && plugins.length > 0;
119
+ if (!hasPlugins && luaApi !== true) return "`target` is legal only beside `plugins` or `luaApi: true`";
120
+ return null;
121
+ }
122
+ __name(workflowJobTargetProblem, "workflowJobTargetProblem");
123
+ __name2(workflowJobTargetProblem, "workflowJobTargetProblem");
124
+ function readInitDataPath(root, path) {
125
+ let cur = root;
126
+ for (const seg of path.split(".")) {
127
+ const name = seg.replace(/\[(?:0|[1-9]\d*)\]/g, "");
128
+ const indexes = [
129
+ ...seg.matchAll(/\[(0|[1-9]\d*)\]/g)
130
+ ].map((x) => Number(x[1]));
131
+ if (cur === null || typeof cur !== "object" || !Object.prototype.hasOwnProperty.call(cur, name)) return void 0;
132
+ cur = cur[name];
133
+ for (const i of indexes) {
134
+ if (!Array.isArray(cur) || i >= cur.length) return void 0;
135
+ cur = cur[i];
136
+ }
137
+ }
138
+ return cur;
139
+ }
140
+ __name(readInitDataPath, "readInitDataPath");
141
+ __name2(readInitDataPath, "readInitDataPath");
142
+ function renderWorkflowJobTarget(target, initData) {
143
+ const agentId = target?.agentId;
144
+ if (target === void 0 || target === null || agentId === void 0) return {
145
+ ok: true,
146
+ agentId: void 0,
147
+ templated: false
148
+ };
149
+ if (typeof agentId === "string") {
150
+ if (!agentId.trim() || agentId.includes("${")) return {
151
+ ok: false,
152
+ reason: "invalid",
153
+ message: "target.agentId is invalid"
154
+ };
155
+ return {
156
+ ok: true,
157
+ agentId,
158
+ templated: false
159
+ };
160
+ }
161
+ const path = workflowJobTargetTemplatePath(agentId);
162
+ if (path === null) return {
163
+ ok: false,
164
+ reason: "invalid",
165
+ message: "target.agentId is not a valid initData template"
166
+ };
167
+ const value3 = readInitDataPath(initData, path);
168
+ if (value3 === void 0 || value3 === null) {
169
+ return {
170
+ ok: false,
171
+ reason: "unbound",
172
+ message: `target_unresolved: the run input has no initData.${path}`
173
+ };
174
+ }
175
+ if (typeof value3 !== "string" || !value3.trim() || value3.length > 256 || /\s/.test(value3.trim())) {
176
+ return {
177
+ ok: false,
178
+ reason: "empty",
179
+ message: `target_unresolved: initData.${path} is not a non-empty agent id`
180
+ };
181
+ }
182
+ return {
183
+ ok: true,
184
+ agentId: value3.trim(),
185
+ templated: true
186
+ };
187
+ }
188
+ __name(renderWorkflowJobTarget, "renderWorkflowJobTarget");
189
+ __name2(renderWorkflowJobTarget, "renderWorkflowJobTarget");
190
+
4
191
  // src/types/workflow.ts
5
192
  import { zodToJsonSchema } from "zod-to-json-schema";
6
193
 
@@ -9,8 +196,8 @@ import { z } from "zod";
9
196
  import { z as z2 } from "zod";
10
197
  import { z as z3 } from "zod";
11
198
  import { z as z4 } from "zod";
12
- var __defProp2 = Object.defineProperty;
13
- var __name2 = /* @__PURE__ */ __name((target, value3) => __defProp2(target, "name", { value: value3, configurable: true }), "__name");
199
+ var __defProp3 = Object.defineProperty;
200
+ var __name3 = /* @__PURE__ */ __name((target, value3) => __defProp3(target, "name", { value: value3, configurable: true }), "__name");
14
201
  var PLUMBING_THREAD_CHANNELS = [
15
202
  "trigger",
16
203
  "template-install",
@@ -38,12 +225,12 @@ function isChannelConversationChannel(channel) {
38
225
  return !!channel && CHANNEL_CONVERSATION_CHANNELS.includes(channel);
39
226
  }
40
227
  __name(isChannelConversationChannel, "isChannelConversationChannel");
41
- __name2(isChannelConversationChannel, "isChannelConversationChannel");
228
+ __name3(isChannelConversationChannel, "isChannelConversationChannel");
42
229
  function isChannelConversationThread(threadId, channel) {
43
230
  return !!threadId && isChannelConversationChannel(channel);
44
231
  }
45
232
  __name(isChannelConversationThread, "isChannelConversationThread");
46
- __name2(isChannelConversationThread, "isChannelConversationThread");
233
+ __name3(isChannelConversationThread, "isChannelConversationThread");
47
234
  function isPersonaTextObject(value3) {
48
235
  if (value3 === null || typeof value3 !== "object" || Array.isArray(value3)) return false;
49
236
  const obj = value3;
@@ -54,7 +241,7 @@ function isPersonaTextObject(value3) {
54
241
  return true;
55
242
  }
56
243
  __name(isPersonaTextObject, "isPersonaTextObject");
57
- __name2(isPersonaTextObject, "isPersonaTextObject");
244
+ __name3(isPersonaTextObject, "isPersonaTextObject");
58
245
  function flattenPersonaText(input, isVoice = false) {
59
246
  if (input == null) return "";
60
247
  if (typeof input === "string") return input;
@@ -65,7 +252,7 @@ function flattenPersonaText(input, isVoice = false) {
65
252
  return parts.join("\n\n");
66
253
  }
67
254
  __name(flattenPersonaText, "flattenPersonaText");
68
- __name2(flattenPersonaText, "flattenPersonaText");
255
+ __name3(flattenPersonaText, "flattenPersonaText");
69
256
  function flattenPersonaTextAll(input) {
70
257
  if (input == null) return "";
71
258
  if (typeof input === "string") return input;
@@ -76,16 +263,16 @@ function flattenPersonaTextAll(input) {
76
263
  return parts.join("\n\n");
77
264
  }
78
265
  __name(flattenPersonaTextAll, "flattenPersonaTextAll");
79
- __name2(flattenPersonaTextAll, "flattenPersonaTextAll");
266
+ __name3(flattenPersonaTextAll, "flattenPersonaTextAll");
80
267
  function hasPersonaTextContent(input) {
81
268
  if (input == null) return false;
82
269
  if (typeof input === "string") return input.trim().length > 0;
83
270
  return Boolean(input.base?.trim() || input.voice?.trim() || input.text?.trim());
84
271
  }
85
272
  __name(hasPersonaTextContent, "hasPersonaTextContent");
86
- __name2(hasPersonaTextContent, "hasPersonaTextContent");
273
+ __name3(hasPersonaTextContent, "hasPersonaTextContent");
87
274
  function personaToLiteral(persona) {
88
- const formatValue = /* @__PURE__ */ __name2((v) => {
275
+ const formatValue = /* @__PURE__ */ __name3((v) => {
89
276
  if (v.includes("\n")) {
90
277
  return "`" + v.replace(/\\/g, "\\\\").replace(/`/g, "\\`").replace(/\$/g, "\\$") + "`";
91
278
  }
@@ -99,7 +286,7 @@ function personaToLiteral(persona) {
99
286
  return `{ ${parts.join(", ")} }`;
100
287
  }
101
288
  __name(personaToLiteral, "personaToLiteral");
102
- __name2(personaToLiteral, "personaToLiteral");
289
+ __name3(personaToLiteral, "personaToLiteral");
103
290
  function aiGenerateInputFromSimplified(prompt, content) {
104
291
  if (content === void 0) {
105
292
  return {
@@ -117,7 +304,45 @@ function aiGenerateInputFromSimplified(prompt, content) {
117
304
  };
118
305
  }
119
306
  __name(aiGenerateInputFromSimplified, "aiGenerateInputFromSimplified");
120
- __name2(aiGenerateInputFromSimplified, "aiGenerateInputFromSimplified");
307
+ __name3(aiGenerateInputFromSimplified, "aiGenerateInputFromSimplified");
308
+ var PLATFORM_INVOCATION_CALLERS = [
309
+ "workflow-step",
310
+ "supervision-preview"
311
+ ];
312
+ function isPlatformInvocationCaller(v) {
313
+ return typeof v === "string" && PLATFORM_INVOCATION_CALLERS.includes(v);
314
+ }
315
+ __name(isPlatformInvocationCaller, "isPlatformInvocationCaller");
316
+ __name3(isPlatformInvocationCaller, "isPlatformInvocationCaller");
317
+ function supervisionSubjectId(agentId) {
318
+ return `agent:${agentId}`;
319
+ }
320
+ __name(supervisionSubjectId, "supervisionSubjectId");
321
+ __name3(supervisionSubjectId, "supervisionSubjectId");
322
+ var SUPERVISION_OPS = {
323
+ "agents.list": "discover",
324
+ "agents.get": "discover",
325
+ logs: "observe",
326
+ "runs.list": "observe",
327
+ "runs.get": "observe",
328
+ "data.get": "observe",
329
+ "data.query": "observe",
330
+ "versions.list": "observe",
331
+ "versions.get": "observe",
332
+ "versions.diff": "observe",
333
+ "versions.preview": "preview",
334
+ "versions.promote": "release",
335
+ "persona.versions": "observe",
336
+ "persona.activate": "release",
337
+ "source.list": "observe",
338
+ "source.get": "observe",
339
+ "env.keys": "observe"
340
+ };
341
+ function isSupervisionOp(op) {
342
+ return typeof op === "string" && Object.prototype.hasOwnProperty.call(SUPERVISION_OPS, op);
343
+ }
344
+ __name(isSupervisionOp, "isSupervisionOp");
345
+ __name3(isSupervisionOp, "isSupervisionOp");
121
346
  var REVIEWABLE_ACTION_EXECUTE_TOOL_ALLOWLIST = [
122
347
  "sendChannelMessage",
123
348
  "sendWhatsappTemplate",
@@ -133,7 +358,7 @@ function isAllowedReviewableExecuteTool(tool) {
133
358
  return REVIEWABLE_ACTION_EXECUTE_TOOL_ALLOWLIST.includes(tool);
134
359
  }
135
360
  __name(isAllowedReviewableExecuteTool, "isAllowedReviewableExecuteTool");
136
- __name2(isAllowedReviewableExecuteTool, "isAllowedReviewableExecuteTool");
361
+ __name3(isAllowedReviewableExecuteTool, "isAllowedReviewableExecuteTool");
137
362
  var REVIEWABLE_STANDING_START_TOOLS = [
138
363
  "scheduleWorkflow"
139
364
  ];
@@ -141,19 +366,19 @@ function isReviewableStandingStartTool(tool) {
141
366
  return REVIEWABLE_STANDING_START_TOOLS.includes(tool);
142
367
  }
143
368
  __name(isReviewableStandingStartTool, "isReviewableStandingStartTool");
144
- __name2(isReviewableStandingStartTool, "isReviewableStandingStartTool");
369
+ __name3(isReviewableStandingStartTool, "isReviewableStandingStartTool");
145
370
  var REVIEWABLE_MCP_SEND_TOOL_SUFFIX = "_create_messaging_message";
146
371
  function isReviewableMcpSendTool(tool) {
147
372
  return tool.length > REVIEWABLE_MCP_SEND_TOOL_SUFFIX.length && tool.endsWith(REVIEWABLE_MCP_SEND_TOOL_SUFFIX);
148
373
  }
149
374
  __name(isReviewableMcpSendTool, "isReviewableMcpSendTool");
150
- __name2(isReviewableMcpSendTool, "isReviewableMcpSendTool");
375
+ __name3(isReviewableMcpSendTool, "isReviewableMcpSendTool");
151
376
  var MCP_TOOL_READ_VERB_RE = /(?:^|_)(list|get|search|read|fetch|find|query|describe|count|retrieve|lookup|show|view)(_|[A-Z0-9]|$)/;
152
377
  function mcpActionTokens(action) {
153
378
  return action.replace(/([a-z0-9])([A-Z])/g, "$1 $2").toLowerCase().split(/[^a-z0-9]+/).filter(Boolean);
154
379
  }
155
380
  __name(mcpActionTokens, "mcpActionTokens");
156
- __name2(mcpActionTokens, "mcpActionTokens");
381
+ __name3(mcpActionTokens, "mcpActionTokens");
157
382
  function isReviewableMcpDraftTool(tool) {
158
383
  const sep = tool.indexOf("_");
159
384
  if (sep <= 0 || sep >= tool.length - 1) return false;
@@ -163,7 +388,7 @@ function isReviewableMcpDraftTool(tool) {
163
388
  return !MCP_TOOL_READ_VERB_RE.test(action);
164
389
  }
165
390
  __name(isReviewableMcpDraftTool, "isReviewableMcpDraftTool");
166
- __name2(isReviewableMcpDraftTool, "isReviewableMcpDraftTool");
391
+ __name3(isReviewableMcpDraftTool, "isReviewableMcpDraftTool");
167
392
  var MCP_DRAFT_CREATE_VERBS = /* @__PURE__ */ new Set([
168
393
  "create",
169
394
  "compose",
@@ -181,7 +406,7 @@ function isMcpDraftCreateTool(tool) {
181
406
  return tokens[0] === "draft" || tokens.some((t) => MCP_DRAFT_CREATE_VERBS.has(t));
182
407
  }
183
408
  __name(isMcpDraftCreateTool, "isMcpDraftCreateTool");
184
- __name2(isMcpDraftCreateTool, "isMcpDraftCreateTool");
409
+ __name3(isMcpDraftCreateTool, "isMcpDraftCreateTool");
185
410
  function mcpSendSiblingForDraftTool(tool, availableToolIds) {
186
411
  const candidates = [
187
412
  ...availableToolIds
@@ -192,12 +417,12 @@ function mcpSendSiblingForDraftTool(tool, availableToolIds) {
192
417
  return candidates[0]?.id;
193
418
  }
194
419
  __name(mcpSendSiblingForDraftTool, "mcpSendSiblingForDraftTool");
195
- __name2(mcpSendSiblingForDraftTool, "mcpSendSiblingForDraftTool");
420
+ __name3(mcpSendSiblingForDraftTool, "mcpSendSiblingForDraftTool");
196
421
  function isReviewableExecuteTool(tool) {
197
422
  return isAllowedReviewableExecuteTool(tool) || isReviewableMcpSendTool(tool) || isReviewableStandingStartTool(tool);
198
423
  }
199
424
  __name(isReviewableExecuteTool, "isReviewableExecuteTool");
200
- __name2(isReviewableExecuteTool, "isReviewableExecuteTool");
425
+ __name3(isReviewableExecuteTool, "isReviewableExecuteTool");
201
426
  var NON_INTERACTIVE_CHANNELS = [
202
427
  "trigger",
203
428
  "agent-invocation",
@@ -209,23 +434,23 @@ function isInteractiveChannel(channel) {
209
434
  return !NON_INTERACTIVE_CHANNELS.includes(channel);
210
435
  }
211
436
  __name(isInteractiveChannel, "isInteractiveChannel");
212
- __name2(isInteractiveChannel, "isInteractiveChannel");
437
+ __name3(isInteractiveChannel, "isInteractiveChannel");
213
438
  function isInteractiveTurn(turn) {
214
439
  if (typeof turn.interactive === "boolean") return turn.interactive;
215
440
  return isInteractiveChannel(turn.channel);
216
441
  }
217
442
  __name(isInteractiveTurn, "isInteractiveTurn");
218
- __name2(isInteractiveTurn, "isInteractiveTurn");
443
+ __name3(isInteractiveTurn, "isInteractiveTurn");
219
444
  function removeNavigateBlock(input) {
220
445
  return input.replace(/::: navigate[\s\S]*?:::/g, "").trim();
221
446
  }
222
447
  __name(removeNavigateBlock, "removeNavigateBlock");
223
- __name2(removeNavigateBlock, "removeNavigateBlock");
448
+ __name3(removeNavigateBlock, "removeNavigateBlock");
224
449
  function removeHiddenBlocks(input) {
225
450
  return input.replace(/::: hide\b[\s\S]*?:::/gi, "").replace(/::: hide\b[\s\S]*$/gi, "").trim();
226
451
  }
227
452
  __name(removeHiddenBlocks, "removeHiddenBlocks");
228
- __name2(removeHiddenBlocks, "removeHiddenBlocks");
453
+ __name3(removeHiddenBlocks, "removeHiddenBlocks");
229
454
  function transformChatHistoryContentParts(parts) {
230
455
  const content = [];
231
456
  for (const rawPart of parts ?? []) {
@@ -370,14 +595,14 @@ function transformChatHistoryContentParts(parts) {
370
595
  return content;
371
596
  }
372
597
  __name(transformChatHistoryContentParts, "transformChatHistoryContentParts");
373
- __name2(transformChatHistoryContentParts, "transformChatHistoryContentParts");
598
+ __name3(transformChatHistoryContentParts, "transformChatHistoryContentParts");
374
599
  var RICH_PARTS_MESSAGE_ID_PREFIX = "rich-parts:";
375
600
  var SCREENSHOT_MESSAGE_ID_PREFIX = "screenshot:";
376
601
  function isSyntheticSideRow(id2) {
377
602
  return id2.startsWith(SCREENSHOT_MESSAGE_ID_PREFIX) || id2.startsWith(RICH_PARTS_MESSAGE_ID_PREFIX);
378
603
  }
379
604
  __name(isSyntheticSideRow, "isSyntheticSideRow");
380
- __name2(isSyntheticSideRow, "isSyntheticSideRow");
605
+ __name3(isSyntheticSideRow, "isSyntheticSideRow");
381
606
  function mergeRichPartMirrorMessages(messages, sameTurnGroup) {
382
607
  const merged = [];
383
608
  for (const message of messages) {
@@ -416,7 +641,7 @@ function mergeRichPartMirrorMessages(messages, sameTurnGroup) {
416
641
  return merged;
417
642
  }
418
643
  __name(mergeRichPartMirrorMessages, "mergeRichPartMirrorMessages");
419
- __name2(mergeRichPartMirrorMessages, "mergeRichPartMirrorMessages");
644
+ __name3(mergeRichPartMirrorMessages, "mergeRichPartMirrorMessages");
420
645
  function citationDedupeKeys(part) {
421
646
  if (part.type !== "source-url" && part.type !== "source-document") return [];
422
647
  const keys = [];
@@ -425,10 +650,10 @@ function citationDedupeKeys(part) {
425
650
  return keys;
426
651
  }
427
652
  __name(citationDedupeKeys, "citationDedupeKeys");
428
- __name2(citationDedupeKeys, "citationDedupeKeys");
653
+ __name3(citationDedupeKeys, "citationDedupeKeys");
429
654
  function foldRichPartsIntoMessages(messages, records, makeMessage, sameTurnGroup) {
430
655
  if (messages.length === 0 || records.length === 0) return messages;
431
- const messageTime = /* @__PURE__ */ __name2((m) => m.createdAt ? new Date(m.createdAt).getTime() : Number.NEGATIVE_INFINITY, "messageTime");
656
+ const messageTime = /* @__PURE__ */ __name3((m) => m.createdAt ? new Date(m.createdAt).getTime() : Number.NEGATIVE_INFINITY, "messageTime");
432
657
  const finiteTimes = messages.map(messageTime).filter(Number.isFinite);
433
658
  const oldest = finiteTimes.length > 0 ? Math.min(...finiteTimes) : Number.NEGATIVE_INFINITY;
434
659
  const synthetic = [];
@@ -462,7 +687,7 @@ function foldRichPartsIntoMessages(messages, records, makeMessage, sameTurnGroup
462
687
  return mergeRichPartMirrorMessages(combined, sameTurnGroup);
463
688
  }
464
689
  __name(foldRichPartsIntoMessages, "foldRichPartsIntoMessages");
465
- __name2(foldRichPartsIntoMessages, "foldRichPartsIntoMessages");
690
+ __name3(foldRichPartsIntoMessages, "foldRichPartsIntoMessages");
466
691
  var BROWSER_COMMANDS = [
467
692
  // health + lifecycle / navigation
468
693
  {
@@ -688,7 +913,7 @@ var LuaLogFieldsError = class _LuaLogFieldsError extends Error {
688
913
  __name(this, "_LuaLogFieldsError");
689
914
  }
690
915
  static {
691
- __name2(this, "LuaLogFieldsError");
916
+ __name3(this, "LuaLogFieldsError");
692
917
  }
693
918
  constructor(message) {
694
919
  super(message);
@@ -719,7 +944,7 @@ function utf8WidthAt(value3, index) {
719
944
  };
720
945
  }
721
946
  __name(utf8WidthAt, "utf8WidthAt");
722
- __name2(utf8WidthAt, "utf8WidthAt");
947
+ __name3(utf8WidthAt, "utf8WidthAt");
723
948
  function utf8ByteLength(value3) {
724
949
  let bytes = 0;
725
950
  for (let i = 0; i < value3.length; ) {
@@ -730,7 +955,7 @@ function utf8ByteLength(value3) {
730
955
  return bytes;
731
956
  }
732
957
  __name(utf8ByteLength, "utf8ByteLength");
733
- __name2(utf8ByteLength, "utf8ByteLength");
958
+ __name3(utf8ByteLength, "utf8ByteLength");
734
959
  function clampUtf8(value3, maxBytes) {
735
960
  let bytes = 0;
736
961
  for (let i = 0; i < value3.length; ) {
@@ -742,7 +967,7 @@ function clampUtf8(value3, maxBytes) {
742
967
  return value3;
743
968
  }
744
969
  __name(clampUtf8, "clampUtf8");
745
- __name2(clampUtf8, "clampUtf8");
970
+ __name3(clampUtf8, "clampUtf8");
746
971
  function mapBytes(fields, withMark) {
747
972
  return utf8ByteLength(JSON.stringify(withMark ? {
748
973
  ...fields,
@@ -750,7 +975,7 @@ function mapBytes(fields, withMark) {
750
975
  } : fields));
751
976
  }
752
977
  __name(mapBytes, "mapBytes");
753
- __name2(mapBytes, "mapBytes");
978
+ __name3(mapBytes, "mapBytes");
754
979
  function withValueCap(fields, capBytes) {
755
980
  const out = {};
756
981
  for (const [key, value3] of Object.entries(fields)) {
@@ -759,7 +984,7 @@ function withValueCap(fields, capBytes) {
759
984
  return out;
760
985
  }
761
986
  __name(withValueCap, "withValueCap");
762
- __name2(withValueCap, "withValueCap");
987
+ __name3(withValueCap, "withValueCap");
763
988
  function describeValue(value3) {
764
989
  if (value3 === null) return "null";
765
990
  if (value3 === void 0) return "undefined";
@@ -767,7 +992,7 @@ function describeValue(value3) {
767
992
  return typeof value3 === "object" ? "an object" : `a ${typeof value3}`;
768
993
  }
769
994
  __name(describeValue, "describeValue");
770
- __name2(describeValue, "describeValue");
995
+ __name3(describeValue, "describeValue");
771
996
  function assertValidLogFieldKey(key) {
772
997
  if (!LOG_FIELD_KEY_PATTERN.test(key)) {
773
998
  throw new LuaLogFieldsError(`log fields: key \`${key}\` is not allowed \u2014 a key must match ${LOG_FIELD_KEY_PATTERN.source} (lower-case, starts with a letter, then letters/digits/underscore, at most 64 characters)`);
@@ -780,7 +1005,7 @@ function assertValidLogFieldKey(key) {
780
1005
  }
781
1006
  }
782
1007
  __name(assertValidLogFieldKey, "assertValidLogFieldKey");
783
- __name2(assertValidLogFieldKey, "assertValidLogFieldKey");
1008
+ __name3(assertValidLogFieldKey, "assertValidLogFieldKey");
784
1009
  function normalizeLogFields(fields) {
785
1010
  if (fields === void 0 || fields === null) return void 0;
786
1011
  if (typeof fields !== "object" || Array.isArray(fields)) {
@@ -830,7 +1055,7 @@ function normalizeLogFields(fields) {
830
1055
  return out;
831
1056
  }
832
1057
  __name(normalizeLogFields, "normalizeLogFields");
833
- __name2(normalizeLogFields, "normalizeLogFields");
1058
+ __name3(normalizeLogFields, "normalizeLogFields");
834
1059
  function clampLogFields(out) {
835
1060
  let clamped = false;
836
1061
  for (const [key, value3] of Object.entries(out)) {
@@ -862,7 +1087,7 @@ function clampLogFields(out) {
862
1087
  return true;
863
1088
  }
864
1089
  __name(clampLogFields, "clampLogFields");
865
- __name2(clampLogFields, "clampLogFields");
1090
+ __name3(clampLogFields, "clampLogFields");
866
1091
  var DESKTOP_FILE_COMMANDS = [
867
1092
  "files_roots",
868
1093
  "files_stat",
@@ -884,12 +1109,12 @@ function isDesktopFileCommandName(value3) {
884
1109
  return typeof value3 === "string" && DESKTOP_FILE_COMMAND_SET.has(value3);
885
1110
  }
886
1111
  __name(isDesktopFileCommandName, "isDesktopFileCommandName");
887
- __name2(isDesktopFileCommandName, "isDesktopFileCommandName");
1112
+ __name3(isDesktopFileCommandName, "isDesktopFileCommandName");
888
1113
  function isDesktopFileSessionId(value3) {
889
1114
  return typeof value3 === "string" && /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(value3);
890
1115
  }
891
1116
  __name(isDesktopFileSessionId, "isDesktopFileSessionId");
892
- __name2(isDesktopFileSessionId, "isDesktopFileSessionId");
1117
+ __name3(isDesktopFileSessionId, "isDesktopFileSessionId");
893
1118
  var WORKFLOW_RETRY_BACKOFFS = [
894
1119
  "fixed",
895
1120
  "exponential"
@@ -907,12 +1132,12 @@ function workflowRetryMaxAttemptsMessage(got) {
907
1132
  return `\`retry.maxAttempts\` must be an integer ${WORKFLOW_RETRY_MIN_ATTEMPTS}..${WORKFLOW_RETRY_MAX_ATTEMPTS}${tail}`;
908
1133
  }
909
1134
  __name(workflowRetryMaxAttemptsMessage, "workflowRetryMaxAttemptsMessage");
910
- __name2(workflowRetryMaxAttemptsMessage, "workflowRetryMaxAttemptsMessage");
1135
+ __name3(workflowRetryMaxAttemptsMessage, "workflowRetryMaxAttemptsMessage");
911
1136
  function isWithinWorkflowRetryAttempts(value3) {
912
1137
  return typeof value3 === "number" && Number.isInteger(value3) && value3 >= WORKFLOW_RETRY_MIN_ATTEMPTS && value3 <= WORKFLOW_RETRY_MAX_ATTEMPTS;
913
1138
  }
914
1139
  __name(isWithinWorkflowRetryAttempts, "isWithinWorkflowRetryAttempts");
915
- __name2(isWithinWorkflowRetryAttempts, "isWithinWorkflowRetryAttempts");
1140
+ __name3(isWithinWorkflowRetryAttempts, "isWithinWorkflowRetryAttempts");
916
1141
  var WORKFLOW_RETRY_ENGINE_KEYS = [
917
1142
  "budgetBaseAttempt"
918
1143
  ];
@@ -924,13 +1149,13 @@ function workflowRetryUnknownMembersMessage(keys) {
924
1149
  return `\`retry\` has no member ${named.join(", ")}; members: ${WORKFLOW_RETRY_POLICY_KEYS.join(", ")}`;
925
1150
  }
926
1151
  __name(workflowRetryUnknownMembersMessage, "workflowRetryUnknownMembersMessage");
927
- __name2(workflowRetryUnknownMembersMessage, "workflowRetryUnknownMembersMessage");
1152
+ __name3(workflowRetryUnknownMembersMessage, "workflowRetryUnknownMembersMessage");
928
1153
  function unknownWorkflowRetryMembers(retry) {
929
1154
  if (!retry || typeof retry !== "object" || Array.isArray(retry)) return [];
930
1155
  return Object.keys(retry).filter((k) => !WORKFLOW_RETRY_POLICY_KEYS.includes(k));
931
1156
  }
932
1157
  __name(unknownWorkflowRetryMembers, "unknownWorkflowRetryMembers");
933
- __name2(unknownWorkflowRetryMembers, "unknownWorkflowRetryMembers");
1158
+ __name3(unknownWorkflowRetryMembers, "unknownWorkflowRetryMembers");
934
1159
  function authoredRetryPolicy(retry) {
935
1160
  if (!retry || typeof retry !== "object" || Array.isArray(retry)) return void 0;
936
1161
  const src = retry;
@@ -939,34 +1164,34 @@ function authoredRetryPolicy(retry) {
939
1164
  return Object.keys(out).length ? out : void 0;
940
1165
  }
941
1166
  __name(authoredRetryPolicy, "authoredRetryPolicy");
942
- __name2(authoredRetryPolicy, "authoredRetryPolicy");
1167
+ __name3(authoredRetryPolicy, "authoredRetryPolicy");
943
1168
  function retryBudgetBaseAttempt(row) {
944
1169
  const base = row.retry?.budgetBaseAttempt;
945
1170
  return typeof base === "number" && Number.isSafeInteger(base) && base > 0 ? base : 0;
946
1171
  }
947
1172
  __name(retryBudgetBaseAttempt, "retryBudgetBaseAttempt");
948
- __name2(retryBudgetBaseAttempt, "retryBudgetBaseAttempt");
1173
+ __name3(retryBudgetBaseAttempt, "retryBudgetBaseAttempt");
949
1174
  function retryBudgetAttempt(row) {
950
1175
  return Math.max(0, row.attempt - retryBudgetBaseAttempt(row));
951
1176
  }
952
1177
  __name(retryBudgetAttempt, "retryBudgetAttempt");
953
- __name2(retryBudgetAttempt, "retryBudgetAttempt");
1178
+ __name3(retryBudgetAttempt, "retryBudgetAttempt");
954
1179
  function retryBudgetMaxAttempts(row) {
955
1180
  const max = row.retry?.maxAttempts;
956
1181
  return typeof max === "number" && Number.isFinite(max) && max >= 1 ? max : 1;
957
1182
  }
958
1183
  __name(retryBudgetMaxAttempts, "retryBudgetMaxAttempts");
959
- __name2(retryBudgetMaxAttempts, "retryBudgetMaxAttempts");
1184
+ __name3(retryBudgetMaxAttempts, "retryBudgetMaxAttempts");
960
1185
  function retryBudgetRemaining(row) {
961
1186
  return retryBudgetAttempt(row) < retryBudgetMaxAttempts(row);
962
1187
  }
963
1188
  __name(retryBudgetRemaining, "retryBudgetRemaining");
964
- __name2(retryBudgetRemaining, "retryBudgetRemaining");
1189
+ __name3(retryBudgetRemaining, "retryBudgetRemaining");
965
1190
  function retriesRemaining(row) {
966
1191
  return Math.max(0, retryBudgetMaxAttempts(row) - retryBudgetAttempt(row));
967
1192
  }
968
1193
  __name(retriesRemaining, "retriesRemaining");
969
- __name2(retriesRemaining, "retriesRemaining");
1194
+ __name3(retriesRemaining, "retriesRemaining");
970
1195
  var WORKFLOW_JOB_RESOURCES = [
971
1196
  "small",
972
1197
  "medium",
@@ -987,7 +1212,7 @@ function workflowModelCostComparison(estimate, onAgentModel, agentModel) {
987
1212
  return `\u2248 ${ratio}\xD7 the cost of running every step on ${agentModel}`;
988
1213
  }
989
1214
  __name(workflowModelCostComparison, "workflowModelCostComparison");
990
- __name2(workflowModelCostComparison, "workflowModelCostComparison");
1215
+ __name3(workflowModelCostComparison, "workflowModelCostComparison");
991
1216
  var WORKFLOW_DEFAULT_TASK_CLASS_MAP = Object.freeze({
992
1217
  classify: "fast",
993
1218
  extract: "fast",
@@ -1003,13 +1228,13 @@ function modelClassRank(modelClass) {
1003
1228
  return WORKFLOW_MODEL_CLASSES.indexOf(modelClass);
1004
1229
  }
1005
1230
  __name(modelClassRank, "modelClassRank");
1006
- __name2(modelClassRank, "modelClassRank");
1231
+ __name3(modelClassRank, "modelClassRank");
1007
1232
  function modelClassesAtOrBelow(maxClass) {
1008
1233
  const ceiling = modelClassRank(maxClass);
1009
1234
  return WORKFLOW_MODEL_CLASSES.filter((c) => modelClassRank(c) <= ceiling);
1010
1235
  }
1011
1236
  __name(modelClassesAtOrBelow, "modelClassesAtOrBelow");
1012
- __name2(modelClassesAtOrBelow, "modelClassesAtOrBelow");
1237
+ __name3(modelClassesAtOrBelow, "modelClassesAtOrBelow");
1013
1238
  var WORKFLOW_AUTONOMY_NUMERIC_KEYS = [
1014
1239
  "maxCredits",
1015
1240
  "maxSteps",
@@ -1039,7 +1264,7 @@ function workflowAutonomyMaxRunsPerHourCeiling(env) {
1039
1264
  return Number.isFinite(raw) && raw > 0 ? raw : WORKFLOW_AUTONOMY_MAX_RUNS_PER_HOUR_CEILING;
1040
1265
  }
1041
1266
  __name(workflowAutonomyMaxRunsPerHourCeiling, "workflowAutonomyMaxRunsPerHourCeiling");
1042
- __name2(workflowAutonomyMaxRunsPerHourCeiling, "workflowAutonomyMaxRunsPerHourCeiling");
1267
+ __name3(workflowAutonomyMaxRunsPerHourCeiling, "workflowAutonomyMaxRunsPerHourCeiling");
1043
1268
  var WORKFLOW_AUTONOMY_FORMS_DEFAULT = Object.freeze([
1044
1269
  "graph",
1045
1270
  "static"
@@ -1049,12 +1274,12 @@ function isWithinWorkflowAutonomyRange(value3, ceiling) {
1049
1274
  return typeof value3 === "number" && Number.isInteger(value3) && value3 >= WORKFLOW_AUTONOMY_MIN_VALUE && value3 <= ceiling;
1050
1275
  }
1051
1276
  __name(isWithinWorkflowAutonomyRange, "isWithinWorkflowAutonomyRange");
1052
- __name2(isWithinWorkflowAutonomyRange, "isWithinWorkflowAutonomyRange");
1277
+ __name3(isWithinWorkflowAutonomyRange, "isWithinWorkflowAutonomyRange");
1053
1278
  function workflowAutonomyRangeMessage(key, ceiling) {
1054
1279
  return `\`${key}\` must be an integer ${WORKFLOW_AUTONOMY_MIN_VALUE}..${ceiling}`;
1055
1280
  }
1056
1281
  __name(workflowAutonomyRangeMessage, "workflowAutonomyRangeMessage");
1057
- __name2(workflowAutonomyRangeMessage, "workflowAutonomyRangeMessage");
1282
+ __name3(workflowAutonomyRangeMessage, "workflowAutonomyRangeMessage");
1058
1283
  var WORKFLOW_JOB_RANGES = Object.freeze({
1059
1284
  /** Coding-turn cap (`claude -p --max-turns`); absent ⇒ the cluster default (LUA_WF_JOB_MAX_TURNS). */
1060
1285
  maxTurns: Object.freeze({
@@ -1078,13 +1303,13 @@ function isWithinWorkflowJobRange(member, value3) {
1078
1303
  return typeof value3 === "number" && Number.isInteger(value3) && value3 >= min && value3 <= max;
1079
1304
  }
1080
1305
  __name(isWithinWorkflowJobRange, "isWithinWorkflowJobRange");
1081
- __name2(isWithinWorkflowJobRange, "isWithinWorkflowJobRange");
1306
+ __name3(isWithinWorkflowJobRange, "isWithinWorkflowJobRange");
1082
1307
  function workflowJobRangeMessage(member) {
1083
1308
  const { min, max } = WORKFLOW_JOB_RANGES[member];
1084
1309
  return `\`${member}\` must be an integer ${min}..${max}`;
1085
1310
  }
1086
1311
  __name(workflowJobRangeMessage, "workflowJobRangeMessage");
1087
- __name2(workflowJobRangeMessage, "workflowJobRangeMessage");
1312
+ __name3(workflowJobRangeMessage, "workflowJobRangeMessage");
1088
1313
  var WORKFLOW_SINGLE_STEP_TYPES = [
1089
1314
  "agent",
1090
1315
  "tool",
@@ -1108,33 +1333,33 @@ function isWorkflowSingleStepType(type) {
1108
1333
  return typeof type === "string" && WORKFLOW_SINGLE_STEP_TYPES.includes(type);
1109
1334
  }
1110
1335
  __name(isWorkflowSingleStepType, "isWorkflowSingleStepType");
1111
- __name2(isWorkflowSingleStepType, "isWorkflowSingleStepType");
1336
+ __name3(isWorkflowSingleStepType, "isWorkflowSingleStepType");
1112
1337
  function isWorkflowHitlEntryType(type) {
1113
1338
  return typeof type === "string" && WORKFLOW_HITL_ENTRY_TYPES.includes(type);
1114
1339
  }
1115
1340
  __name(isWorkflowHitlEntryType, "isWorkflowHitlEntryType");
1116
- __name2(isWorkflowHitlEntryType, "isWorkflowHitlEntryType");
1341
+ __name3(isWorkflowHitlEntryType, "isWorkflowHitlEntryType");
1117
1342
  function isWorkflowArmEntryType(type) {
1118
1343
  return typeof type === "string" && WORKFLOW_ARM_ENTRY_TYPES.includes(type);
1119
1344
  }
1120
1345
  __name(isWorkflowArmEntryType, "isWorkflowArmEntryType");
1121
- __name2(isWorkflowArmEntryType, "isWorkflowArmEntryType");
1346
+ __name3(isWorkflowArmEntryType, "isWorkflowArmEntryType");
1122
1347
  function workflowContainerRunsHitlArm(container) {
1123
1348
  return typeof container === "string" && WORKFLOW_HITL_ARM_CONTAINERS.includes(container);
1124
1349
  }
1125
1350
  __name(workflowContainerRunsHitlArm, "workflowContainerRunsHitlArm");
1126
- __name2(workflowContainerRunsHitlArm, "workflowContainerRunsHitlArm");
1351
+ __name3(workflowContainerRunsHitlArm, "workflowContainerRunsHitlArm");
1127
1352
  function workflowHitlArmUnsupportedMessage(type, id2, container) {
1128
1353
  const legal = WORKFLOW_HITL_ARM_CONTAINERS.map((c) => `\`${c}\``).join(" / ");
1129
1354
  return `the engine does not run \`${type}\` inside a \`${container}\` yet (node "${id2}") \u2014 place it at the top level, as a ${legal} arm, or inside a child \`workflow\``;
1130
1355
  }
1131
1356
  __name(workflowHitlArmUnsupportedMessage, "workflowHitlArmUnsupportedMessage");
1132
- __name2(workflowHitlArmUnsupportedMessage, "workflowHitlArmUnsupportedMessage");
1357
+ __name3(workflowHitlArmUnsupportedMessage, "workflowHitlArmUnsupportedMessage");
1133
1358
  function workflowHitlArmShapeMessage(type, id2, shape) {
1134
1359
  return shape === "mapped-arm" ? `\`${type}\` arm "${id2}" takes the previous output as its payload \u2014 it cannot head a [mapping, step] chain; map before the container instead` : `a chunked foreach hands each child a slice of items, not one \u2014 \`${type}\` body "${id2}" takes one item; drop \`chunk\``;
1135
1360
  }
1136
1361
  __name(workflowHitlArmShapeMessage, "workflowHitlArmShapeMessage");
1137
- __name2(workflowHitlArmShapeMessage, "workflowHitlArmShapeMessage");
1362
+ __name3(workflowHitlArmShapeMessage, "workflowHitlArmShapeMessage");
1138
1363
  var WORKFLOW_GRAPH_ENTRY_STEP_KINDS = Object.freeze({
1139
1364
  agent: "agent",
1140
1365
  tool: "tool",
@@ -1167,13 +1392,13 @@ function isModelIdSentinel(input) {
1167
1392
  return lower === "auto" || lower.startsWith("auto/");
1168
1393
  }
1169
1394
  __name(isModelIdSentinel, "isModelIdSentinel");
1170
- __name2(isModelIdSentinel, "isModelIdSentinel");
1395
+ __name3(isModelIdSentinel, "isModelIdSentinel");
1171
1396
  var MODEL_CLASS_REF_PREFIX = "class/";
1172
1397
  function isModelClassRef(input) {
1173
1398
  return modelClassOf(input) !== void 0;
1174
1399
  }
1175
1400
  __name(isModelClassRef, "isModelClassRef");
1176
- __name2(isModelClassRef, "isModelClassRef");
1401
+ __name3(isModelClassRef, "isModelClassRef");
1177
1402
  function modelClassOf(input) {
1178
1403
  const lower = (input ?? "").trim().toLowerCase();
1179
1404
  if (!lower.startsWith(MODEL_CLASS_REF_PREFIX)) return void 0;
@@ -1181,12 +1406,12 @@ function modelClassOf(input) {
1181
1406
  return WORKFLOW_MODEL_CLASSES.includes(c) ? c : void 0;
1182
1407
  }
1183
1408
  __name(modelClassOf, "modelClassOf");
1184
- __name2(modelClassOf, "modelClassOf");
1409
+ __name3(modelClassOf, "modelClassOf");
1185
1410
  function modelClassRef(modelClass) {
1186
1411
  return `${MODEL_CLASS_REF_PREFIX}${modelClass}`;
1187
1412
  }
1188
1413
  __name(modelClassRef, "modelClassRef");
1189
- __name2(modelClassRef, "modelClassRef");
1414
+ __name3(modelClassRef, "modelClassRef");
1190
1415
  function normalizeModelId(input, registry) {
1191
1416
  const requested = typeof input === "string" ? input.trim() : "";
1192
1417
  if (!requested) return {
@@ -1260,7 +1485,7 @@ function normalizeModelId(input, registry) {
1260
1485
  };
1261
1486
  }
1262
1487
  __name(normalizeModelId, "normalizeModelId");
1263
- __name2(normalizeModelId, "normalizeModelId");
1488
+ __name3(normalizeModelId, "normalizeModelId");
1264
1489
  function modelUnresolvedMessage(r) {
1265
1490
  if (r.reason === "empty") return "model pin is empty \u2014 pin an approved model (provider/model) or omit `model`";
1266
1491
  if (r.reason === "ambiguous") {
@@ -1269,12 +1494,12 @@ function modelUnresolvedMessage(r) {
1269
1494
  return r.candidates.length ? `model "${r.requested}" does not resolve to an approved model \u2014 accepted forms: ${r.candidates.join(", ")}` : `model "${r.requested}" does not resolve to an approved model \u2014 accepted forms are the registry's provider-prefixed ids (provider/model) or a bare id that names exactly one of them`;
1270
1495
  }
1271
1496
  __name(modelUnresolvedMessage, "modelUnresolvedMessage");
1272
- __name2(modelUnresolvedMessage, "modelUnresolvedMessage");
1497
+ __name3(modelUnresolvedMessage, "modelUnresolvedMessage");
1273
1498
  function modelClassUnresolvedMessage(ref) {
1274
1499
  return `model "${ref.trim()}" is a model-class request that was not resolved before dispatch \u2014 a class is resolved to a concrete approved model by the class map at dispatch, and is never sent to a provider as written; this step refuses rather than run on a substituted model`;
1275
1500
  }
1276
1501
  __name(modelClassUnresolvedMessage, "modelClassUnresolvedMessage");
1277
- __name2(modelClassUnresolvedMessage, "modelClassUnresolvedMessage");
1502
+ __name3(modelClassUnresolvedMessage, "modelClassUnresolvedMessage");
1278
1503
  function providerModelId(code) {
1279
1504
  const requested = typeof code === "string" ? code.trim() : "";
1280
1505
  if (!requested || isModelIdSentinel(requested)) return requested;
@@ -1285,13 +1510,13 @@ function providerModelId(code) {
1285
1510
  return requested.slice(slash + 1);
1286
1511
  }
1287
1512
  __name(providerModelId, "providerModelId");
1288
- __name2(providerModelId, "providerModelId");
1513
+ __name3(providerModelId, "providerModelId");
1289
1514
  var MODEL_SNAPSHOT_SUFFIX = /(?:[-@](?:19|20)\d{2}(?:0[1-9]|1[0-2])(?:0[1-9]|[12]\d|3[01])|-(?:19|20)\d{2}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01]))$/;
1290
1515
  function providerModelFamily(code) {
1291
1516
  return providerModelId(code).toLowerCase().replace(MODEL_SNAPSHOT_SUFFIX, "");
1292
1517
  }
1293
1518
  __name(providerModelFamily, "providerModelFamily");
1294
- __name2(providerModelFamily, "providerModelFamily");
1519
+ __name3(providerModelFamily, "providerModelFamily");
1295
1520
  var IMPLICIT_MODEL_SELECTION_SOURCES = [
1296
1521
  "workspace-default",
1297
1522
  "platform-default"
@@ -1300,13 +1525,13 @@ function isImplicitModelSelectionSource(source) {
1300
1525
  return source !== void 0 && IMPLICIT_MODEL_SELECTION_SOURCES.includes(source);
1301
1526
  }
1302
1527
  __name(isImplicitModelSelectionSource, "isImplicitModelSelectionSource");
1303
- __name2(isImplicitModelSelectionSource, "isImplicitModelSelectionSource");
1528
+ __name3(isImplicitModelSelectionSource, "isImplicitModelSelectionSource");
1304
1529
  var PLATFORM_FALLBACK_MODEL_SOURCE = "platform-fallback";
1305
1530
  function isPlatformFallbackModelSource(source) {
1306
1531
  return source === PLATFORM_FALLBACK_MODEL_SOURCE;
1307
1532
  }
1308
1533
  __name(isPlatformFallbackModelSource, "isPlatformFallbackModelSource");
1309
- __name2(isPlatformFallbackModelSource, "isPlatformFallbackModelSource");
1534
+ __name3(isPlatformFallbackModelSource, "isPlatformFallbackModelSource");
1310
1535
  function resolveRequireToolApproval(rules) {
1311
1536
  const raw = rules?.requireToolApproval ?? rules?.requireApproval;
1312
1537
  if (raw === void 0 || raw === null) return void 0;
@@ -1316,7 +1541,7 @@ function resolveRequireToolApproval(rules) {
1316
1541
  return list.filter((t) => typeof t === "string");
1317
1542
  }
1318
1543
  __name(resolveRequireToolApproval, "resolveRequireToolApproval");
1319
- __name2(resolveRequireToolApproval, "resolveRequireToolApproval");
1544
+ __name3(resolveRequireToolApproval, "resolveRequireToolApproval");
1320
1545
  var AGENT_NAME_TOKEN = "[Your Agent Name]";
1321
1546
  var DEFAULT_PERSONA_GUIDE = `# ${AGENT_NAME_TOKEN} - Persona
1322
1547
 
@@ -1368,7 +1593,7 @@ function buildDefaultPersona(agentName) {
1368
1593
  return DEFAULT_PERSONA_GUIDE.replace(AGENT_NAME_TOKEN, () => agentName || "My Agent");
1369
1594
  }
1370
1595
  __name(buildDefaultPersona, "buildDefaultPersona");
1371
- __name2(buildDefaultPersona, "buildDefaultPersona");
1596
+ __name3(buildDefaultPersona, "buildDefaultPersona");
1372
1597
  var PERSONAL_SPACE_STARTING_PERSONA = `# ${AGENT_NAME_TOKEN}
1373
1598
 
1374
1599
  You are ${AGENT_NAME_TOKEN}, the assistant for whoever is chatting with you here. Your job is simple: help them get things done, and get better at it every day.
@@ -1405,7 +1630,7 @@ function buildPersonalSpaceStartingPersona(agentName) {
1405
1630
  return PERSONAL_SPACE_STARTING_PERSONA.replace(new RegExp(AGENT_NAME_TOKEN.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), "g"), () => agentName || "Your assistant");
1406
1631
  }
1407
1632
  __name(buildPersonalSpaceStartingPersona, "buildPersonalSpaceStartingPersona");
1408
- __name2(buildPersonalSpaceStartingPersona, "buildPersonalSpaceStartingPersona");
1633
+ __name3(buildPersonalSpaceStartingPersona, "buildPersonalSpaceStartingPersona");
1409
1634
  var AGENT_LOG_SOURCES = [
1410
1635
  "skill",
1411
1636
  "job",
@@ -1425,7 +1650,8 @@ var AGENT_LOG_SOURCES = [
1425
1650
  "model-resolver",
1426
1651
  "workflow-step",
1427
1652
  "workflow-script",
1428
- "workflow"
1653
+ "workflow",
1654
+ "supervision"
1429
1655
  ];
1430
1656
  var AGENT_LOG_FIELDS_MAX_WIRE_KEYS = LOG_FIELDS_MAX_KEYS + 1;
1431
1657
  function utf8Bytes(value3) {
@@ -1455,14 +1681,14 @@ function utf8Bytes(value3) {
1455
1681
  return bytes;
1456
1682
  }
1457
1683
  __name(utf8Bytes, "utf8Bytes");
1458
- __name2(utf8Bytes, "utf8Bytes");
1684
+ __name3(utf8Bytes, "utf8Bytes");
1459
1685
  function isPlainFieldKey(key) {
1460
1686
  if (!LOG_FIELD_KEY_PATTERN.test(key)) return false;
1461
1687
  if (key === LOG_FIELDS_CLAMPED_KEY) return false;
1462
1688
  return !LOG_FIELD_SECRET_SHAPED_KEY_PATTERNS.some((pattern) => pattern.test(key));
1463
1689
  }
1464
1690
  __name(isPlainFieldKey, "isPlainFieldKey");
1465
- __name2(isPlainFieldKey, "isPlainFieldKey");
1691
+ __name3(isPlainFieldKey, "isPlainFieldKey");
1466
1692
  function describeAgentLogFieldsViolation(value3) {
1467
1693
  if (typeof value3 !== "object" || value3 === null || Array.isArray(value3)) {
1468
1694
  return "fields must be an object";
@@ -1506,12 +1732,12 @@ function describeAgentLogFieldsViolation(value3) {
1506
1732
  return void 0;
1507
1733
  }
1508
1734
  __name(describeAgentLogFieldsViolation, "describeAgentLogFieldsViolation");
1509
- __name2(describeAgentLogFieldsViolation, "describeAgentLogFieldsViolation");
1735
+ __name3(describeAgentLogFieldsViolation, "describeAgentLogFieldsViolation");
1510
1736
  function isAgentLogFields(value3) {
1511
1737
  return describeAgentLogFieldsViolation(value3) === void 0;
1512
1738
  }
1513
1739
  __name(isAgentLogFields, "isAgentLogFields");
1514
- __name2(isAgentLogFields, "isAgentLogFields");
1740
+ __name3(isAgentLogFields, "isAgentLogFields");
1515
1741
  var LOG_DRAIN_TYPES_PHASE1 = [
1516
1742
  "http",
1517
1743
  "otlp",
@@ -1553,7 +1779,7 @@ function maxDrainsForTier(tier) {
1553
1779
  return tier === "enterprise" ? LOG_DRAIN_MAX_PER_ORG_ENTERPRISE : LOG_DRAIN_MAX_PER_ORG;
1554
1780
  }
1555
1781
  __name(maxDrainsForTier, "maxDrainsForTier");
1556
- __name2(maxDrainsForTier, "maxDrainsForTier");
1782
+ __name3(maxDrainsForTier, "maxDrainsForTier");
1557
1783
  var LOG_DRAIN_DATADOG_SITES = [
1558
1784
  "datadoghq.com",
1559
1785
  "datadoghq.eu",
@@ -1581,7 +1807,7 @@ function resolvePresetEndpoint(type, site) {
1581
1807
  return template3.replace("{site}", site);
1582
1808
  }
1583
1809
  __name(resolvePresetEndpoint, "resolvePresetEndpoint");
1584
- __name2(resolvePresetEndpoint, "resolvePresetEndpoint");
1810
+ __name3(resolvePresetEndpoint, "resolvePresetEndpoint");
1585
1811
  var LOG_DRAIN_BUCKET_NAME_PATTERN = /^[a-z0-9][a-z0-9-]{1,61}[a-z0-9]$/;
1586
1812
  var LOG_DRAIN_BUCKET_HOST_PATTERNS = Object.freeze({
1587
1813
  aws: [
@@ -1603,7 +1829,7 @@ function isLogDrainBucketHostAllowed(provider, host) {
1603
1829
  return (LOG_DRAIN_BUCKET_HOST_PATTERNS[provider] ?? []).some((pattern) => pattern.test(normalized));
1604
1830
  }
1605
1831
  __name(isLogDrainBucketHostAllowed, "isLogDrainBucketHostAllowed");
1606
- __name2(isLogDrainBucketHostAllowed, "isLogDrainBucketHostAllowed");
1832
+ __name3(isLogDrainBucketHostAllowed, "isLogDrainBucketHostAllowed");
1607
1833
  function resolveDrainBucketEndpoint(bucket) {
1608
1834
  if (!LOG_DRAIN_BUCKET_NAME_PATTERN.test(bucket.bucket)) {
1609
1835
  throw new Error("log drain bucket name is not a valid S3 bucket label");
@@ -1624,12 +1850,12 @@ function resolveDrainBucketEndpoint(bucket) {
1624
1850
  return `https://${url.host}/${bucket.bucket}`;
1625
1851
  }
1626
1852
  __name(resolveDrainBucketEndpoint, "resolveDrainBucketEndpoint");
1627
- __name2(resolveDrainBucketEndpoint, "resolveDrainBucketEndpoint");
1853
+ __name3(resolveDrainBucketEndpoint, "resolveDrainBucketEndpoint");
1628
1854
  function drainBucketUsesPathStyle(provider) {
1629
1855
  return provider !== "aws";
1630
1856
  }
1631
1857
  __name(drainBucketUsesPathStyle, "drainBucketUsesPathStyle");
1632
- __name2(drainBucketUsesPathStyle, "drainBucketUsesPathStyle");
1858
+ __name3(drainBucketUsesPathStyle, "drainBucketUsesPathStyle");
1633
1859
  function presetIntakeHosts(type) {
1634
1860
  const template3 = LOG_DRAIN_ENDPOINT_TEMPLATES[type];
1635
1861
  const sites = LOG_DRAIN_PRESET_SITES[type];
@@ -1644,7 +1870,7 @@ function presetIntakeHosts(type) {
1644
1870
  return hosts;
1645
1871
  }
1646
1872
  __name(presetIntakeHosts, "presetIntakeHosts");
1647
- __name2(presetIntakeHosts, "presetIntakeHosts");
1873
+ __name3(presetIntakeHosts, "presetIntakeHosts");
1648
1874
  var LOG_DRAIN_PRESET_HOST_SUFFIXES = {
1649
1875
  axiom: [
1650
1876
  ".axiom.co"
@@ -1660,7 +1886,7 @@ function presetHostAllowlist(type) {
1660
1886
  ];
1661
1887
  }
1662
1888
  __name(presetHostAllowlist, "presetHostAllowlist");
1663
- __name2(presetHostAllowlist, "presetHostAllowlist");
1889
+ __name3(presetHostAllowlist, "presetHostAllowlist");
1664
1890
  function drainHostAllowlistAllows(allowlist, host) {
1665
1891
  const needle = host.toLowerCase();
1666
1892
  return allowlist.some((raw) => {
@@ -1670,25 +1896,25 @@ function drainHostAllowlistAllows(allowlist, host) {
1670
1896
  });
1671
1897
  }
1672
1898
  __name(drainHostAllowlistAllows, "drainHostAllowlistAllows");
1673
- __name2(drainHostAllowlistAllows, "drainHostAllowlistAllows");
1899
+ __name3(drainHostAllowlistAllows, "drainHostAllowlistAllows");
1674
1900
  function drainDestinationIsVendorPinned(type) {
1675
1901
  if (LOG_DRAIN_ENDPOINT_TEMPLATES[type]) return true;
1676
1902
  return presetHostAllowlist(type).length > 0;
1677
1903
  }
1678
1904
  __name(drainDestinationIsVendorPinned, "drainDestinationIsVendorPinned");
1679
- __name2(drainDestinationIsVendorPinned, "drainDestinationIsVendorPinned");
1905
+ __name3(drainDestinationIsVendorPinned, "drainDestinationIsVendorPinned");
1680
1906
  function drainVerificationOwnership(input) {
1681
1907
  if (input.proved === true) return "verified";
1682
1908
  if (input.mode === "test-post" && drainDestinationIsVendorPinned(input.type)) return "verified";
1683
1909
  return "reachability-only";
1684
1910
  }
1685
1911
  __name(drainVerificationOwnership, "drainVerificationOwnership");
1686
- __name2(drainVerificationOwnership, "drainVerificationOwnership");
1912
+ __name3(drainVerificationOwnership, "drainVerificationOwnership");
1687
1913
  function drainOwnershipOrDefault(ownership) {
1688
1914
  return ownership === "verified" ? "verified" : "reachability-only";
1689
1915
  }
1690
1916
  __name(drainOwnershipOrDefault, "drainOwnershipOrDefault");
1691
- __name2(drainOwnershipOrDefault, "drainOwnershipOrDefault");
1917
+ __name3(drainOwnershipOrDefault, "drainOwnershipOrDefault");
1692
1918
  var DRAIN_CONTENT_ACK_ERROR_CODE = "DRAIN_CONTENT_ACK_REQUIRED";
1693
1919
  var DRAIN_CONTENT_ACK_FIELD = "includeContentAck";
1694
1920
  var DrainContentAckRequiredError = class extends Error {
@@ -1696,7 +1922,7 @@ var DrainContentAckRequiredError = class extends Error {
1696
1922
  __name(this, "DrainContentAckRequiredError");
1697
1923
  }
1698
1924
  static {
1699
- __name2(this, "DrainContentAckRequiredError");
1925
+ __name3(this, "DrainContentAckRequiredError");
1700
1926
  }
1701
1927
  code = DRAIN_CONTENT_ACK_ERROR_CODE;
1702
1928
  field = DRAIN_CONTENT_ACK_FIELD;
@@ -1719,7 +1945,7 @@ function assertDrainContentAck(input) {
1719
1945
  };
1720
1946
  }
1721
1947
  __name(assertDrainContentAck, "assertDrainContentAck");
1722
- __name2(assertDrainContentAck, "assertDrainContentAck");
1948
+ __name3(assertDrainContentAck, "assertDrainContentAck");
1723
1949
  var LOG_DRAIN_PRESET_PATHS = {
1724
1950
  // https://docs.splunk.com/Documentation/Splunk/latest/Data/HECExamples
1725
1951
  splunk: {
@@ -1802,13 +2028,13 @@ function composePresetEndpoint(type, endpoint) {
1802
2028
  };
1803
2029
  }
1804
2030
  __name(composePresetEndpoint, "composePresetEndpoint");
1805
- __name2(composePresetEndpoint, "composePresetEndpoint");
2031
+ __name3(composePresetEndpoint, "composePresetEndpoint");
1806
2032
  function joinPresetEndpointToken(endpoint, token) {
1807
2033
  if (typeof token !== "string" || !PRESET_SEGMENT_RE.test(token)) return endpoint;
1808
2034
  return endpoint.endsWith("/") ? `${endpoint}${token}` : `${endpoint}/${token}`;
1809
2035
  }
1810
2036
  __name(joinPresetEndpointToken, "joinPresetEndpointToken");
1811
- __name2(joinPresetEndpointToken, "joinPresetEndpointToken");
2037
+ __name3(joinPresetEndpointToken, "joinPresetEndpointToken");
1812
2038
  var LOG_DRAIN_QUOTAS = {
1813
2039
  team: {
1814
2040
  eventsPerDay: 1e6,
@@ -1831,18 +2057,18 @@ function nextLogDrainQuotaResetAt(now) {
1831
2057
  return new Date(Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate() + 1)).toISOString();
1832
2058
  }
1833
2059
  __name(nextLogDrainQuotaResetAt, "nextLogDrainQuotaResetAt");
1834
- __name2(nextLogDrainQuotaResetAt, "nextLogDrainQuotaResetAt");
2060
+ __name3(nextLogDrainQuotaResetAt, "nextLogDrainQuotaResetAt");
1835
2061
  function logDrainQuotaWindowExpired(usage, now) {
1836
2062
  const resetsAt = Date.parse(usage?.resetsAt ?? "");
1837
2063
  if (!Number.isFinite(resetsAt)) return true;
1838
2064
  return now.getTime() >= resetsAt;
1839
2065
  }
1840
2066
  __name(logDrainQuotaWindowExpired, "logDrainQuotaWindowExpired");
1841
- __name2(logDrainQuotaWindowExpired, "logDrainQuotaWindowExpired");
2067
+ __name3(logDrainQuotaWindowExpired, "logDrainQuotaWindowExpired");
1842
2068
  function logDrainQuotaRatio(usage, now) {
1843
2069
  if (!usage) return 0;
1844
2070
  if (now && logDrainQuotaWindowExpired(usage, now)) return 0;
1845
- const dimension = /* @__PURE__ */ __name2((used, limit) => {
2071
+ const dimension = /* @__PURE__ */ __name3((used, limit) => {
1846
2072
  if (!Number.isFinite(limit) || limit <= 0) return 0;
1847
2073
  if (!Number.isFinite(used) || used <= 0) return 0;
1848
2074
  return used / limit;
@@ -1850,7 +2076,7 @@ function logDrainQuotaRatio(usage, now) {
1850
2076
  return Math.max(dimension(usage.usedEvents, usage.eventsPerDay), dimension(usage.usedBytes, usage.bytesPerDay));
1851
2077
  }
1852
2078
  __name(logDrainQuotaRatio, "logDrainQuotaRatio");
1853
- __name2(logDrainQuotaRatio, "logDrainQuotaRatio");
2079
+ __name3(logDrainQuotaRatio, "logDrainQuotaRatio");
1854
2080
  function logDrainQuotaDegradationForRatio(ratio) {
1855
2081
  if (!Number.isFinite(ratio)) return "none";
1856
2082
  if (ratio >= LOG_DRAIN_QUOTA_PAUSE_RATIO) return "paused";
@@ -1859,17 +2085,17 @@ function logDrainQuotaDegradationForRatio(ratio) {
1859
2085
  return "none";
1860
2086
  }
1861
2087
  __name(logDrainQuotaDegradationForRatio, "logDrainQuotaDegradationForRatio");
1862
- __name2(logDrainQuotaDegradationForRatio, "logDrainQuotaDegradationForRatio");
2088
+ __name3(logDrainQuotaDegradationForRatio, "logDrainQuotaDegradationForRatio");
1863
2089
  function logDrainQuotaDegradation(usage, now) {
1864
2090
  return logDrainQuotaDegradationForRatio(logDrainQuotaRatio(usage, now));
1865
2091
  }
1866
2092
  __name(logDrainQuotaDegradation, "logDrainQuotaDegradation");
1867
- __name2(logDrainQuotaDegradation, "logDrainQuotaDegradation");
2093
+ __name3(logDrainQuotaDegradation, "logDrainQuotaDegradation");
1868
2094
  function logDrainQuotaWarned(usage, now) {
1869
2095
  return logDrainQuotaRatio(usage, now) >= LOG_DRAIN_QUOTA_WARN_RATIO;
1870
2096
  }
1871
2097
  __name(logDrainQuotaWarned, "logDrainQuotaWarned");
1872
- __name2(logDrainQuotaWarned, "logDrainQuotaWarned");
2098
+ __name3(logDrainQuotaWarned, "logDrainQuotaWarned");
1873
2099
  function logDrainQuotaDroppedSeverities(degradation) {
1874
2100
  switch (degradation) {
1875
2101
  case "debug_dropped":
@@ -1886,7 +2112,7 @@ function logDrainQuotaDroppedSeverities(degradation) {
1886
2112
  }
1887
2113
  }
1888
2114
  __name(logDrainQuotaDroppedSeverities, "logDrainQuotaDroppedSeverities");
1889
- __name2(logDrainQuotaDroppedSeverities, "logDrainQuotaDroppedSeverities");
2115
+ __name3(logDrainQuotaDroppedSeverities, "logDrainQuotaDroppedSeverities");
1890
2116
  var LOG_EXPORT_SOURCES = [
1891
2117
  ...AGENT_LOG_SOURCES,
1892
2118
  "execution"
@@ -1901,7 +2127,7 @@ function isLogExportSource(source) {
1901
2127
  return LOG_EXPORT_SOURCES.includes(source);
1902
2128
  }
1903
2129
  __name(isLogExportSource, "isLogExportSource");
1904
- __name2(isLogExportSource, "isLogExportSource");
2130
+ __name3(isLogExportSource, "isLogExportSource");
1905
2131
  var LOG_DRAIN_NOTICE_RATE_LIMIT_MS = 60 * 6e4;
1906
2132
  var LOG_DRAIN_VERIFICATION_STALE_MS = 24 * 60 * 6e4;
1907
2133
  var LOG_DRAIN_DIGEST_INTERVAL_MS = 24 * 60 * 6e4;
@@ -1914,17 +2140,17 @@ function clamp(value3, max) {
1914
2140
  return trimmed.length <= max ? trimmed : `${trimmed.slice(0, max - 1)}\u2026`;
1915
2141
  }
1916
2142
  __name(clamp, "clamp");
1917
- __name2(clamp, "clamp");
2143
+ __name3(clamp, "clamp");
1918
2144
  function numberOr(value3, fallback) {
1919
2145
  return typeof value3 === "number" && Number.isFinite(value3) ? value3 : fallback;
1920
2146
  }
1921
2147
  __name(numberOr, "numberOr");
1922
- __name2(numberOr, "numberOr");
2148
+ __name3(numberOr, "numberOr");
1923
2149
  function isoOr(value3) {
1924
2150
  return typeof value3 === "string" && value3.length > 0 ? value3 : void 0;
1925
2151
  }
1926
2152
  __name(isoOr, "isoOr");
1927
- __name2(isoOr, "isoOr");
2153
+ __name3(isoOr, "isoOr");
1928
2154
  function logDrainNoticeView(drain, now) {
1929
2155
  const health = drain.health ?? {};
1930
2156
  const quota = drain.quota;
@@ -1952,18 +2178,18 @@ function logDrainNoticeView(drain, now) {
1952
2178
  return view;
1953
2179
  }
1954
2180
  __name(logDrainNoticeView, "logDrainNoticeView");
1955
- __name2(logDrainNoticeView, "logDrainNoticeView");
2181
+ __name3(logDrainNoticeView, "logDrainNoticeView");
1956
2182
  function logDrainHealthCardPath(orgId, drainId) {
1957
2183
  return `/orgs/${encodeURIComponent(orgId)}/log-drains/${encodeURIComponent(drainId)}`;
1958
2184
  }
1959
2185
  __name(logDrainHealthCardPath, "logDrainHealthCardPath");
1960
- __name2(logDrainHealthCardPath, "logDrainHealthCardPath");
2186
+ __name3(logDrainHealthCardPath, "logDrainHealthCardPath");
1961
2187
  function percent(ratio) {
1962
2188
  if (!Number.isFinite(ratio) || ratio <= 0) return "0%";
1963
2189
  return `${Math.round(ratio * 100)}%`;
1964
2190
  }
1965
2191
  __name(percent, "percent");
1966
- __name2(percent, "percent");
2192
+ __name3(percent, "percent");
1967
2193
  function becauseClause(view) {
1968
2194
  const bits = [];
1969
2195
  if (view.lastStatusCode) bits.push(`HTTP ${view.lastStatusCode}`);
@@ -1971,7 +2197,7 @@ function becauseClause(view) {
1971
2197
  return bits.length ? ` Last error: ${bits.join(" \u2014 ")}.` : "";
1972
2198
  }
1973
2199
  __name(becauseClause, "becauseClause");
1974
- __name2(becauseClause, "becauseClause");
2200
+ __name3(becauseClause, "becauseClause");
1975
2201
  function logDrainNoticeCopy(payload) {
1976
2202
  const view = payload.drain;
1977
2203
  const name = view.name || view.id;
@@ -2040,7 +2266,7 @@ function logDrainNoticeCopy(payload) {
2040
2266
  }
2041
2267
  }
2042
2268
  __name(logDrainNoticeCopy, "logDrainNoticeCopy");
2043
- __name2(logDrainNoticeCopy, "logDrainNoticeCopy");
2269
+ __name3(logDrainNoticeCopy, "logDrainNoticeCopy");
2044
2270
  function logDrainNoticeLabel(kind) {
2045
2271
  switch (kind) {
2046
2272
  case "failing":
@@ -2062,7 +2288,7 @@ function logDrainNoticeLabel(kind) {
2062
2288
  }
2063
2289
  }
2064
2290
  __name(logDrainNoticeLabel, "logDrainNoticeLabel");
2065
- __name2(logDrainNoticeLabel, "logDrainNoticeLabel");
2291
+ __name3(logDrainNoticeLabel, "logDrainNoticeLabel");
2066
2292
  function logDrainNoticeDigestCopy(payload) {
2067
2293
  const entries = [
2068
2294
  ...payload.entries ?? []
@@ -2081,7 +2307,7 @@ function logDrainNoticeDigestCopy(payload) {
2081
2307
  };
2082
2308
  }
2083
2309
  __name(logDrainNoticeDigestCopy, "logDrainNoticeDigestCopy");
2084
- __name2(logDrainNoticeDigestCopy, "logDrainNoticeDigestCopy");
2310
+ __name3(logDrainNoticeDigestCopy, "logDrainNoticeDigestCopy");
2085
2311
  var LOG_DRAIN_USAGE_LINE_ITEM = "log_drain_events";
2086
2312
  var LOG_DRAIN_BYTES_PER_GIB = 1024 ** 3;
2087
2313
  var DEFAULT_LOG_DRAIN_PLAN_CONFIG = {
@@ -2127,7 +2353,7 @@ function finiteNonNegative(value3) {
2127
2353
  return typeof value3 === "number" && Number.isFinite(value3) && value3 >= 0 ? value3 : void 0;
2128
2354
  }
2129
2355
  __name(finiteNonNegative, "finiteNonNegative");
2130
- __name2(finiteNonNegative, "finiteNonNegative");
2356
+ __name3(finiteNonNegative, "finiteNonNegative");
2131
2357
  function mergeLimits(base, stored) {
2132
2358
  const patch = stored ?? {};
2133
2359
  return {
@@ -2136,7 +2362,7 @@ function mergeLimits(base, stored) {
2136
2362
  };
2137
2363
  }
2138
2364
  __name(mergeLimits, "mergeLimits");
2139
- __name2(mergeLimits, "mergeLimits");
2365
+ __name3(mergeLimits, "mergeLimits");
2140
2366
  function mergeCard(base, stored) {
2141
2367
  const patch = stored ?? {};
2142
2368
  return {
@@ -2147,7 +2373,7 @@ function mergeCard(base, stored) {
2147
2373
  };
2148
2374
  }
2149
2375
  __name(mergeCard, "mergeCard");
2150
- __name2(mergeCard, "mergeCard");
2376
+ __name3(mergeCard, "mergeCard");
2151
2377
  function resolveStoredLogDrainPlanConfig(stored) {
2152
2378
  const values = stored;
2153
2379
  if (!values || typeof values.version !== "number" || !Number.isFinite(values.version)) {
@@ -2183,12 +2409,12 @@ function resolveStoredLogDrainPlanConfig(stored) {
2183
2409
  };
2184
2410
  }
2185
2411
  __name(resolveStoredLogDrainPlanConfig, "resolveStoredLogDrainPlanConfig");
2186
- __name2(resolveStoredLogDrainPlanConfig, "resolveStoredLogDrainPlanConfig");
2412
+ __name3(resolveStoredLogDrainPlanConfig, "resolveStoredLogDrainPlanConfig");
2187
2413
  function logDrainPlanTierOverride(config, orgId) {
2188
2414
  return orgId ? config.orgs?.[orgId]?.tier : void 0;
2189
2415
  }
2190
2416
  __name(logDrainPlanTierOverride, "logDrainPlanTierOverride");
2191
- __name2(logDrainPlanTierOverride, "logDrainPlanTierOverride");
2417
+ __name3(logDrainPlanTierOverride, "logDrainPlanTierOverride");
2192
2418
  function logDrainQuotaLimitsFor(config, orgId, tier) {
2193
2419
  const base = config.tiers[tier] ?? config.tiers.team ?? LOG_DRAIN_QUOTAS.team;
2194
2420
  const override = orgId ? config.orgs?.[orgId] : void 0;
@@ -2201,7 +2427,7 @@ function logDrainQuotaLimitsFor(config, orgId, tier) {
2201
2427
  };
2202
2428
  }
2203
2429
  __name(logDrainQuotaLimitsFor, "logDrainQuotaLimitsFor");
2204
- __name2(logDrainQuotaLimitsFor, "logDrainQuotaLimitsFor");
2430
+ __name3(logDrainQuotaLimitsFor, "logDrainQuotaLimitsFor");
2205
2431
  function logDrainPriceCardFor(config, orgId, tier) {
2206
2432
  const base = config.pricing[tier] ?? config.pricing.team ?? DEFAULT_LOG_DRAIN_PLAN_CONFIG.pricing.team;
2207
2433
  const override = orgId ? config.orgs?.[orgId]?.pricing : void 0;
@@ -2210,7 +2436,7 @@ function logDrainPriceCardFor(config, orgId, tier) {
2210
2436
  };
2211
2437
  }
2212
2438
  __name(logDrainPriceCardFor, "logDrainPriceCardFor");
2213
- __name2(logDrainPriceCardFor, "logDrainPriceCardFor");
2439
+ __name3(logDrainPriceCardFor, "logDrainPriceCardFor");
2214
2440
  function priceDrainUsage(totals, card, tier) {
2215
2441
  const billableRecords = Math.max(0, Math.floor(finiteNonNegative(totals?.billableRecords) ?? 0));
2216
2442
  const billableBytes = Math.max(0, Math.floor(finiteNonNegative(totals?.billableBytes) ?? 0));
@@ -2221,7 +2447,7 @@ function priceDrainUsage(totals, card, tier) {
2221
2447
  const eventsUsd = overageEvents / 1e6 * card.usdPerMillionEvents;
2222
2448
  const bytesUsd = overageBytes / LOG_DRAIN_BYTES_PER_GIB * card.usdPerGiB;
2223
2449
  const unpriced = card.usdPerMillionEvents === 0 && card.usdPerGiB === 0;
2224
- const round = /* @__PURE__ */ __name2((usd) => Math.round(usd * 100) / 100, "round");
2450
+ const round = /* @__PURE__ */ __name3((usd) => Math.round(usd * 100) / 100, "round");
2225
2451
  return {
2226
2452
  lineItem: LOG_DRAIN_USAGE_LINE_ITEM,
2227
2453
  tier,
@@ -2238,7 +2464,7 @@ function priceDrainUsage(totals, card, tier) {
2238
2464
  };
2239
2465
  }
2240
2466
  __name(priceDrainUsage, "priceDrainUsage");
2241
- __name2(priceDrainUsage, "priceDrainUsage");
2467
+ __name3(priceDrainUsage, "priceDrainUsage");
2242
2468
  var LOG_CURSOR_MAX_LENGTH = 512;
2243
2469
  var LOG_CURSOR_MAX_ID_LENGTH = 128;
2244
2470
  var LOG_RELATIVE_TIME_PATTERN = /^(\d{1,9})([smhd])$/;
@@ -2256,7 +2482,7 @@ function encodeLogCursor(c) {
2256
2482
  }), "utf8").toString("base64url");
2257
2483
  }
2258
2484
  __name(encodeLogCursor, "encodeLogCursor");
2259
- __name2(encodeLogCursor, "encodeLogCursor");
2485
+ __name3(encodeLogCursor, "encodeLogCursor");
2260
2486
  function decodeLogCursor(raw) {
2261
2487
  if (typeof raw !== "string") return null;
2262
2488
  const trimmed = raw.trim();
@@ -2277,7 +2503,7 @@ function decodeLogCursor(raw) {
2277
2503
  };
2278
2504
  }
2279
2505
  __name(decodeLogCursor, "decodeLogCursor");
2280
- __name2(decodeLogCursor, "decodeLogCursor");
2506
+ __name3(decodeLogCursor, "decodeLogCursor");
2281
2507
  function parseLogTimeBound(raw, now = /* @__PURE__ */ new Date()) {
2282
2508
  if (typeof raw !== "string") return null;
2283
2509
  const value3 = raw.trim();
@@ -2295,7 +2521,7 @@ function parseLogTimeBound(raw, now = /* @__PURE__ */ new Date()) {
2295
2521
  return Number.isNaN(at) ? null : new Date(at);
2296
2522
  }
2297
2523
  __name(parseLogTimeBound, "parseLogTimeBound");
2298
- __name2(parseLogTimeBound, "parseLogTimeBound");
2524
+ __name3(parseLogTimeBound, "parseLogTimeBound");
2299
2525
  var CORE_DRAINING_CODE = "CORE_DRAINING";
2300
2526
  var CORE_DRAINING_DEFAULT_RETRY_MS = 1e3;
2301
2527
  var CORE_DRAINING_MAX_RETRY_MS = 5e3;
@@ -2303,13 +2529,13 @@ function isRecord(value3) {
2303
2529
  return typeof value3 === "object" && value3 !== null;
2304
2530
  }
2305
2531
  __name(isRecord, "isRecord");
2306
- __name2(isRecord, "isRecord");
2532
+ __name3(isRecord, "isRecord");
2307
2533
  function isCoreDrainingErrorResponse(value3) {
2308
2534
  if (!isRecord(value3) || !isRecord(value3.error)) return false;
2309
2535
  return value3.error.code === CORE_DRAINING_CODE && typeof value3.error.message === "string" && value3.error.retryable === true;
2310
2536
  }
2311
2537
  __name(isCoreDrainingErrorResponse, "isCoreDrainingErrorResponse");
2312
- __name2(isCoreDrainingErrorResponse, "isCoreDrainingErrorResponse");
2538
+ __name3(isCoreDrainingErrorResponse, "isCoreDrainingErrorResponse");
2313
2539
  function coreDrainingRetryDelayMs(retryAfter, nowMs = Date.now()) {
2314
2540
  if (retryAfter === null) return CORE_DRAINING_DEFAULT_RETRY_MS;
2315
2541
  const seconds = /^\d+$/.test(retryAfter.trim()) ? Number(retryAfter) : Number.NaN;
@@ -2318,7 +2544,7 @@ function coreDrainingRetryDelayMs(retryAfter, nowMs = Date.now()) {
2318
2544
  return Math.min(Math.max(0, delayMs), CORE_DRAINING_MAX_RETRY_MS);
2319
2545
  }
2320
2546
  __name(coreDrainingRetryDelayMs, "coreDrainingRetryDelayMs");
2321
- __name2(coreDrainingRetryDelayMs, "coreDrainingRetryDelayMs");
2547
+ __name3(coreDrainingRetryDelayMs, "coreDrainingRetryDelayMs");
2322
2548
  async function readCoreDrainingRetryDelayMs(response) {
2323
2549
  if (response.status !== 503) return null;
2324
2550
  try {
@@ -2330,7 +2556,7 @@ async function readCoreDrainingRetryDelayMs(response) {
2330
2556
  return coreDrainingRetryDelayMs(response.headers.get("Retry-After"));
2331
2557
  }
2332
2558
  __name(readCoreDrainingRetryDelayMs, "readCoreDrainingRetryDelayMs");
2333
- __name2(readCoreDrainingRetryDelayMs, "readCoreDrainingRetryDelayMs");
2559
+ __name3(readCoreDrainingRetryDelayMs, "readCoreDrainingRetryDelayMs");
2334
2560
  function waitForCoreDrain(delayMs, signal) {
2335
2561
  return new Promise((resolve, reject) => {
2336
2562
  if (signal?.aborted) {
@@ -2346,14 +2572,14 @@ function waitForCoreDrain(delayMs, signal) {
2346
2572
  reject(signal?.reason ?? new DOMException("Aborted", "AbortError"));
2347
2573
  }
2348
2574
  __name(onAbort, "onAbort");
2349
- __name2(onAbort, "onAbort");
2575
+ __name3(onAbort, "onAbort");
2350
2576
  signal?.addEventListener("abort", onAbort, {
2351
2577
  once: true
2352
2578
  });
2353
2579
  });
2354
2580
  }
2355
2581
  __name(waitForCoreDrain, "waitForCoreDrain");
2356
- __name2(waitForCoreDrain, "waitForCoreDrain");
2582
+ __name3(waitForCoreDrain, "waitForCoreDrain");
2357
2583
  async function fetchWithCoreDrainRetry(run, options = {}) {
2358
2584
  const first = await run();
2359
2585
  const delayMs = await readCoreDrainingRetryDelayMs(first);
@@ -2368,7 +2594,7 @@ async function fetchWithCoreDrainRetry(run, options = {}) {
2368
2594
  return run();
2369
2595
  }
2370
2596
  __name(fetchWithCoreDrainRetry, "fetchWithCoreDrainRetry");
2371
- __name2(fetchWithCoreDrainRetry, "fetchWithCoreDrainRetry");
2597
+ __name3(fetchWithCoreDrainRetry, "fetchWithCoreDrainRetry");
2372
2598
  var VoiceNameSchema = z.string().regex(/^[a-zA-Z0-9_-]+$/, "Voice name must contain only alphanumeric characters, underscores, or hyphens").min(1).max(64);
2373
2599
  var PluginProviderSchema = z.enum([
2374
2600
  "deepgram",
@@ -2627,7 +2853,7 @@ function resolveLuaJobTimeoutSeconds(timeout) {
2627
2853
  return resolved;
2628
2854
  }
2629
2855
  __name(resolveLuaJobTimeoutSeconds, "resolveLuaJobTimeoutSeconds");
2630
- __name2(resolveLuaJobTimeoutSeconds, "resolveLuaJobTimeoutSeconds");
2856
+ __name3(resolveLuaJobTimeoutSeconds, "resolveLuaJobTimeoutSeconds");
2631
2857
  function normalizeLuaJobExecutionTimeoutSeconds(timeout) {
2632
2858
  if (typeof timeout !== "number" || !Number.isFinite(timeout)) {
2633
2859
  return LUA_JOB_DEFAULT_TIMEOUT_SECONDS;
@@ -2635,7 +2861,7 @@ function normalizeLuaJobExecutionTimeoutSeconds(timeout) {
2635
2861
  return Math.min(Math.max(timeout, LUA_JOB_MIN_TIMEOUT_SECONDS), LUA_JOB_MAX_TIMEOUT_SECONDS);
2636
2862
  }
2637
2863
  __name(normalizeLuaJobExecutionTimeoutSeconds, "normalizeLuaJobExecutionTimeoutSeconds");
2638
- __name2(normalizeLuaJobExecutionTimeoutSeconds, "normalizeLuaJobExecutionTimeoutSeconds");
2864
+ __name3(normalizeLuaJobExecutionTimeoutSeconds, "normalizeLuaJobExecutionTimeoutSeconds");
2639
2865
  var KEYS = /* @__PURE__ */ new Set([
2640
2866
  "v",
2641
2867
  "kind",
@@ -2651,7 +2877,7 @@ function isId(value3) {
2651
2877
  return typeof value3 === "string" && value3.length > 0 && value3.length <= MAX_ID_LENGTH;
2652
2878
  }
2653
2879
  __name(isId, "isId");
2654
- __name2(isId, "isId");
2880
+ __name3(isId, "isId");
2655
2881
  function parseScheduledJobFire(raw) {
2656
2882
  if (new TextEncoder().encode(raw).byteLength > MAX_BODY_BYTES) {
2657
2883
  throw new Error("Invalid scheduled job fire: body is too large");
@@ -2699,14 +2925,14 @@ function parseScheduledJobFire(raw) {
2699
2925
  };
2700
2926
  }
2701
2927
  __name(parseScheduledJobFire, "parseScheduledJobFire");
2702
- __name2(parseScheduledJobFire, "parseScheduledJobFire");
2928
+ __name3(parseScheduledJobFire, "parseScheduledJobFire");
2703
2929
  var TEMPLATE_TRIGGER_URL_ENV_PREFIX = "LUA_TRIGGER_URL__";
2704
2930
  function triggerUrlEnvKey(triggerKey) {
2705
2931
  const upper = triggerKey.trim().replace(/[^A-Za-z0-9]+/g, "_").replace(/^_+|_+$/g, "").toUpperCase();
2706
2932
  return `${TEMPLATE_TRIGGER_URL_ENV_PREFIX}${upper}`;
2707
2933
  }
2708
2934
  __name(triggerUrlEnvKey, "triggerUrlEnvKey");
2709
- __name2(triggerUrlEnvKey, "triggerUrlEnvKey");
2935
+ __name3(triggerUrlEnvKey, "triggerUrlEnvKey");
2710
2936
  var TEMPLATE_INSTALL_POLICY_PER_WORKSPACE_VALUES = Object.freeze([
2711
2937
  "single",
2712
2938
  "multiple"
@@ -2746,7 +2972,7 @@ function deviceCredentialScopes(operations) {
2746
2972
  ];
2747
2973
  }
2748
2974
  __name(deviceCredentialScopes, "deviceCredentialScopes");
2749
- __name2(deviceCredentialScopes, "deviceCredentialScopes");
2975
+ __name3(deviceCredentialScopes, "deviceCredentialScopes");
2750
2976
  var DeviceBindingSchema = z2.object({
2751
2977
  agentId: z2.string().min(1).max(256),
2752
2978
  deviceName: z2.string().min(1).max(256),
@@ -2863,12 +3089,12 @@ function parsePrincipalContext(value3) {
2863
3089
  return parsed.success ? parsed.data : void 0;
2864
3090
  }
2865
3091
  __name(parsePrincipalContext, "parsePrincipalContext");
2866
- __name2(parsePrincipalContext, "parsePrincipalContext");
3092
+ __name3(parsePrincipalContext, "parsePrincipalContext");
2867
3093
  function isDeviceCredentialPrincipal(context) {
2868
3094
  return context?.credential.type === "deviceCredential";
2869
3095
  }
2870
3096
  __name(isDeviceCredentialPrincipal, "isDeviceCredentialPrincipal");
2871
- __name2(isDeviceCredentialPrincipal, "isDeviceCredentialPrincipal");
3097
+ __name3(isDeviceCredentialPrincipal, "isDeviceCredentialPrincipal");
2872
3098
  var DeviceCredentialClaimSchema = z2.object({
2873
3099
  credential: z2.object({
2874
3100
  type: z2.literal("deviceCredential")
@@ -2878,19 +3104,19 @@ function hasDeviceCredentialType(value3) {
2878
3104
  return DeviceCredentialClaimSchema.safeParse(value3).success;
2879
3105
  }
2880
3106
  __name(hasDeviceCredentialType, "hasDeviceCredentialType");
2881
- __name2(hasDeviceCredentialType, "hasDeviceCredentialType");
3107
+ __name3(hasDeviceCredentialType, "hasDeviceCredentialType");
2882
3108
  function sessionAuthTime(context) {
2883
3109
  if (!context || context.credential.type !== "firstPartySession") return void 0;
2884
3110
  const authTime = context.authTime;
2885
3111
  return typeof authTime === "number" && Number.isInteger(authTime) && authTime >= 0 && authTime <= SESSION_AUTH_TIME_MAX_S ? authTime : void 0;
2886
3112
  }
2887
3113
  __name(sessionAuthTime, "sessionAuthTime");
2888
- __name2(sessionAuthTime, "sessionAuthTime");
3114
+ __name3(sessionAuthTime, "sessionAuthTime");
2889
3115
  function isTypedApiKeyPrincipal(context) {
2890
3116
  return context?.subject.subjectType === "apiKey" && context.credential.type === "apiKey" && !context.compatibility;
2891
3117
  }
2892
3118
  __name(isTypedApiKeyPrincipal, "isTypedApiKeyPrincipal");
2893
- __name2(isTypedApiKeyPrincipal, "isTypedApiKeyPrincipal");
3119
+ __name3(isTypedApiKeyPrincipal, "isTypedApiKeyPrincipal");
2894
3120
  function typedApiKeyPrincipalId(context) {
2895
3121
  if (!context || !isTypedApiKeyPrincipal(context) || !context.subject.subjectId || context.credential.id !== context.subject.subjectId || context.actor?.actorType !== "apiKey" || context.actor.actorId !== context.subject.subjectId || context.owner?.type !== "user" || !context.owner.id) {
2896
3122
  return void 0;
@@ -2898,7 +3124,7 @@ function typedApiKeyPrincipalId(context) {
2898
3124
  return context.subject.subjectId;
2899
3125
  }
2900
3126
  __name(typedApiKeyPrincipalId, "typedApiKeyPrincipalId");
2901
- __name2(typedApiKeyPrincipalId, "typedApiKeyPrincipalId");
3127
+ __name3(typedApiKeyPrincipalId, "typedApiKeyPrincipalId");
2902
3128
  var LUA_CLIENT_APPS = [
2903
3129
  "desktop",
2904
3130
  "web",
@@ -2943,13 +3169,13 @@ function parseLuaClientHeader(value3) {
2943
3169
  return void 0;
2944
3170
  }
2945
3171
  __name(parseLuaClientHeader, "parseLuaClientHeader");
2946
- __name2(parseLuaClientHeader, "parseLuaClientHeader");
3172
+ __name3(parseLuaClientHeader, "parseLuaClientHeader");
2947
3173
  function serializeLuaClientHeader(client) {
2948
3174
  if (!client) return void 0;
2949
3175
  return `${client.app}/${client.version === "unknown" ? "unversioned" : client.version}`;
2950
3176
  }
2951
3177
  __name(serializeLuaClientHeader, "serializeLuaClientHeader");
2952
- __name2(serializeLuaClientHeader, "serializeLuaClientHeader");
3178
+ __name3(serializeLuaClientHeader, "serializeLuaClientHeader");
2953
3179
  function formatLuaClientHeader(app, version) {
2954
3180
  if (typeof version !== "string") return `${app}/unversioned`;
2955
3181
  const normalized = version.trim();
@@ -2958,7 +3184,7 @@ function formatLuaClientHeader(app, version) {
2958
3184
  return `${app}/unversioned`;
2959
3185
  }
2960
3186
  __name(formatLuaClientHeader, "formatLuaClientHeader");
2961
- __name2(formatLuaClientHeader, "formatLuaClientHeader");
3187
+ __name3(formatLuaClientHeader, "formatLuaClientHeader");
2962
3188
  function luaClientMetricLabels(client) {
2963
3189
  const canonical2 = parseLuaClientHeader(serializeLuaClientHeader(client));
2964
3190
  return {
@@ -2967,7 +3193,7 @@ function luaClientMetricLabels(client) {
2967
3193
  };
2968
3194
  }
2969
3195
  __name(luaClientMetricLabels, "luaClientMetricLabels");
2970
- __name2(luaClientMetricLabels, "luaClientMetricLabels");
3196
+ __name3(luaClientMetricLabels, "luaClientMetricLabels");
2971
3197
  var AUTHZ_PROJECTION_VERSION = 1;
2972
3198
  var ProjectedScopeSchema = z3.string().min(1).max(128);
2973
3199
  var DisplayRoleSchema = z3.object({
@@ -3116,29 +3342,29 @@ function parseEffectiveAuthorization(value3) {
3116
3342
  return parsed.success ? parsed.data : void 0;
3117
3343
  }
3118
3344
  __name(parseEffectiveAuthorization, "parseEffectiveAuthorization");
3119
- __name2(parseEffectiveAuthorization, "parseEffectiveAuthorization");
3345
+ __name3(parseEffectiveAuthorization, "parseEffectiveAuthorization");
3120
3346
  function parseResourcePage(value3) {
3121
3347
  const parsed = ResourcePageSchema.safeParse(value3);
3122
3348
  return parsed.success ? parsed.data : void 0;
3123
3349
  }
3124
3350
  __name(parseResourcePage, "parseResourcePage");
3125
- __name2(parseResourcePage, "parseResourcePage");
3351
+ __name3(parseResourcePage, "parseResourcePage");
3126
3352
  function capabilitiesFor(profiles, profileId) {
3127
3353
  if (!profileId) return [];
3128
3354
  return profiles[profileId] ?? [];
3129
3355
  }
3130
3356
  __name(capabilitiesFor, "capabilitiesFor");
3131
- __name2(capabilitiesFor, "capabilitiesFor");
3357
+ __name3(capabilitiesFor, "capabilitiesFor");
3132
3358
  function isKnownProfile(profiles, profileId) {
3133
3359
  return profileId !== void 0 && Object.prototype.hasOwnProperty.call(profiles, profileId);
3134
3360
  }
3135
3361
  __name(isKnownProfile, "isKnownProfile");
3136
- __name2(isKnownProfile, "isKnownProfile");
3362
+ __name3(isKnownProfile, "isKnownProfile");
3137
3363
  function hasCapability(profiles, profileId, required) {
3138
3364
  return capabilitiesFor(profiles, profileId).includes(required);
3139
3365
  }
3140
3366
  __name(hasCapability, "hasCapability");
3141
- __name2(hasCapability, "hasCapability");
3367
+ __name3(hasCapability, "hasCapability");
3142
3368
  function workflowJobId(id2) {
3143
3369
  switch (id2.kind) {
3144
3370
  case "start":
@@ -3194,48 +3420,48 @@ function workflowJobId(id2) {
3194
3420
  }
3195
3421
  }
3196
3422
  __name(workflowJobId, "workflowJobId");
3197
- __name2(workflowJobId, "workflowJobId");
3423
+ __name3(workflowJobId, "workflowJobId");
3198
3424
  function assertNever(id2) {
3199
3425
  throw new Error(`workflowJobId: unknown wake kind ${JSON.stringify(id2)}`);
3200
3426
  }
3201
3427
  __name(assertNever, "assertNever");
3202
- __name2(assertNever, "assertNever");
3428
+ __name3(assertNever, "assertNever");
3203
3429
  function agentStepJobId(msg) {
3204
3430
  return `${msg.runId}_${msg.stepId}_${msg.attempt}_x${msg.executionId}`;
3205
3431
  }
3206
3432
  __name(agentStepJobId, "agentStepJobId");
3207
- __name2(agentStepJobId, "agentStepJobId");
3433
+ __name3(agentStepJobId, "agentStepJobId");
3208
3434
  function heavyStepJobId(msg) {
3209
3435
  return `${msg.runId}_${msg.stepId}_${msg.attempt}_x${msg.executionId}`;
3210
3436
  }
3211
3437
  __name(heavyStepJobId, "heavyStepJobId");
3212
- __name2(heavyStepJobId, "heavyStepJobId");
3438
+ __name3(heavyStepJobId, "heavyStepJobId");
3213
3439
  function jobSpawnJobId(msg) {
3214
3440
  return `${msg.runId}_${msg.stepId}_${msg.attempt}_s${msg.segment}_${msg.executionId}`;
3215
3441
  }
3216
3442
  __name(jobSpawnJobId, "jobSpawnJobId");
3217
- __name2(jobSpawnJobId, "jobSpawnJobId");
3443
+ __name3(jobSpawnJobId, "jobSpawnJobId");
3218
3444
  function exportAutoJobId(exportId, suffix) {
3219
3445
  return suffix ? `${exportId}:${suffix}` : exportId;
3220
3446
  }
3221
3447
  __name(exportAutoJobId, "exportAutoJobId");
3222
- __name2(exportAutoJobId, "exportAutoJobId");
3448
+ __name3(exportAutoJobId, "exportAutoJobId");
3223
3449
  var SYSTEM_USER_PREFIX = "system:";
3224
3450
  function isSystemRun(identity) {
3225
3451
  return identity.userId.startsWith(SYSTEM_USER_PREFIX);
3226
3452
  }
3227
3453
  __name(isSystemRun, "isSystemRun");
3228
- __name2(isSystemRun, "isSystemRun");
3454
+ __name3(isSystemRun, "isSystemRun");
3229
3455
  function creatorUserId(identity) {
3230
3456
  return isSystemRun(identity) ? void 0 : identity.userId;
3231
3457
  }
3232
3458
  __name(creatorUserId, "creatorUserId");
3233
- __name2(creatorUserId, "creatorUserId");
3459
+ __name3(creatorUserId, "creatorUserId");
3234
3460
  function actingUserId(identity) {
3235
3461
  return creatorUserId(identity);
3236
3462
  }
3237
3463
  __name(actingUserId, "actingUserId");
3238
- __name2(actingUserId, "actingUserId");
3464
+ __name3(actingUserId, "actingUserId");
3239
3465
  var WORKFLOW_RUN_IN_FLIGHT = [
3240
3466
  "queued",
3241
3467
  "running",
@@ -3298,27 +3524,27 @@ function isWorkflowSignalEventSite(value3) {
3298
3524
  return typeof value3 === "string" && WORKFLOW_SIGNAL_EVENT_SITES.includes(value3);
3299
3525
  }
3300
3526
  __name(isWorkflowSignalEventSite, "isWorkflowSignalEventSite");
3301
- __name2(isWorkflowSignalEventSite, "isWorkflowSignalEventSite");
3527
+ __name3(isWorkflowSignalEventSite, "isWorkflowSignalEventSite");
3302
3528
  var ARCHIVE_WINDOW_MARGIN_DAYS = 7;
3303
3529
  function shouldSkipArchive(run, manifestSha256, sinkSha256) {
3304
3530
  if (!run.completedAt || !run.exportedAt || run.exportedAt < run.completedAt) return false;
3305
3531
  return !!manifestSha256 && manifestSha256 === sinkSha256;
3306
3532
  }
3307
3533
  __name(shouldSkipArchive, "shouldSkipArchive");
3308
- __name2(shouldSkipArchive, "shouldSkipArchive");
3534
+ __name3(shouldSkipArchive, "shouldSkipArchive");
3309
3535
  function isArchiveWindowTooOld(run, retentionDays, now = Date.now(), marginDays = ARCHIVE_WINDOW_MARGIN_DAYS) {
3310
3536
  if (!run.completedAt) return false;
3311
3537
  const cutoff = now - Math.max(retentionDays - marginDays, 0) * 864e5;
3312
3538
  return run.completedAt < cutoff;
3313
3539
  }
3314
3540
  __name(isArchiveWindowTooOld, "isArchiveWindowTooOld");
3315
- __name2(isArchiveWindowTooOld, "isArchiveWindowTooOld");
3541
+ __name3(isArchiveWindowTooOld, "isArchiveWindowTooOld");
3316
3542
  var WORKFLOW_ORG_PURGING_TTL_S = 7 * 86400;
3317
3543
  function workflowOrgPurgingKey(orgId) {
3318
3544
  return `wf:org:${orgId}:purging`;
3319
3545
  }
3320
3546
  __name(workflowOrgPurgingKey, "workflowOrgPurgingKey");
3321
- __name2(workflowOrgPurgingKey, "workflowOrgPurgingKey");
3547
+ __name3(workflowOrgPurgingKey, "workflowOrgPurgingKey");
3322
3548
  var WORKFLOW_ORG_PURGE_FORCE_AFTER_MS = 10 * 6e4;
3323
3549
  var IDEMPOTENCY_HOLDING_STATUSES = [
3324
3550
  ...WORKFLOW_RUN_IN_FLIGHT,
@@ -3331,22 +3557,22 @@ function isCloudTaskRunId(id2) {
3331
3557
  return id2.startsWith(CLOUD_TASK_RUN_ID_PREFIX);
3332
3558
  }
3333
3559
  __name(isCloudTaskRunId, "isCloudTaskRunId");
3334
- __name2(isCloudTaskRunId, "isCloudTaskRunId");
3560
+ __name3(isCloudTaskRunId, "isCloudTaskRunId");
3335
3561
  function isScheduledWorkflowRunId(id2) {
3336
3562
  return id2.startsWith(WORKFLOW_SCHEDULED_RUN_ID_PREFIX);
3337
3563
  }
3338
3564
  __name(isScheduledWorkflowRunId, "isScheduledWorkflowRunId");
3339
- __name2(isScheduledWorkflowRunId, "isScheduledWorkflowRunId");
3565
+ __name3(isScheduledWorkflowRunId, "isScheduledWorkflowRunId");
3340
3566
  function scheduledWorkflowRunId(jobId, scheduledTime) {
3341
3567
  const key = typeof scheduledTime === "number" ? String(scheduledTime) : scheduledTimeKey(scheduledTime);
3342
3568
  return `${WORKFLOW_SCHEDULED_RUN_ID_PREFIX}${jobId}_${key}`;
3343
3569
  }
3344
3570
  __name(scheduledWorkflowRunId, "scheduledWorkflowRunId");
3345
- __name2(scheduledWorkflowRunId, "scheduledWorkflowRunId");
3571
+ __name3(scheduledWorkflowRunId, "scheduledWorkflowRunId");
3346
3572
  var WORKFLOW_SCHEDULE_KEY_MAX = 128;
3347
3573
  function renderWorkflowScheduleKeyTemplate(template3, ctx) {
3348
3574
  if (!template3) return void 0;
3349
- const read = /* @__PURE__ */ __name2((path) => path.split(".").reduce((o, k) => o && typeof o === "object" ? o[k] : void 0, ctx.input), "read");
3575
+ const read = /* @__PURE__ */ __name3((path) => path.split(".").reduce((o, k) => o && typeof o === "object" ? o[k] : void 0, ctx.input), "read");
3350
3576
  let unresolved = false;
3351
3577
  const out = template3.replace(/\$\{\s*([a-zA-Z0-9_.]+)\s*\}/g, (_m, expr) => {
3352
3578
  let v = "";
@@ -3361,7 +3587,7 @@ function renderWorkflowScheduleKeyTemplate(template3, ctx) {
3361
3587
  return key && /^[A-Za-z0-9:_\-.\/]+$/.test(key) ? key : void 0;
3362
3588
  }
3363
3589
  __name(renderWorkflowScheduleKeyTemplate, "renderWorkflowScheduleKeyTemplate");
3364
- __name2(renderWorkflowScheduleKeyTemplate, "renderWorkflowScheduleKeyTemplate");
3590
+ __name3(renderWorkflowScheduleKeyTemplate, "renderWorkflowScheduleKeyTemplate");
3365
3591
  var WORKFLOW_SCHEDULE_IDEMPOTENCY_KEY_PREFIX = "sched:";
3366
3592
  function scheduledWorkflowIdempotencyKey(jobId, rendered) {
3367
3593
  const head = `${WORKFLOW_SCHEDULE_IDEMPOTENCY_KEY_PREFIX}${jobId}:`;
@@ -3371,7 +3597,7 @@ function scheduledWorkflowIdempotencyKey(jobId, rendered) {
3371
3597
  return `${head}${rendered.slice(0, Math.max(0, room))}~${digest}`;
3372
3598
  }
3373
3599
  __name(scheduledWorkflowIdempotencyKey, "scheduledWorkflowIdempotencyKey");
3374
- __name2(scheduledWorkflowIdempotencyKey, "scheduledWorkflowIdempotencyKey");
3600
+ __name3(scheduledWorkflowIdempotencyKey, "scheduledWorkflowIdempotencyKey");
3375
3601
  function stableKeyDigest(s) {
3376
3602
  let a = 2166136261;
3377
3603
  let b = 84696351;
@@ -3383,23 +3609,23 @@ function stableKeyDigest(s) {
3383
3609
  return (a >>> 0).toString(16).padStart(8, "0") + (b >>> 0).toString(16).padStart(8, "0");
3384
3610
  }
3385
3611
  __name(stableKeyDigest, "stableKeyDigest");
3386
- __name2(stableKeyDigest, "stableKeyDigest");
3612
+ __name3(stableKeyDigest, "stableKeyDigest");
3387
3613
  var WORKFLOW_OPERATION_ID_PREFIX = "wf:";
3388
3614
  function workflowOperationId(runId, stepId, billingEpoch) {
3389
3615
  return `${WORKFLOW_OPERATION_ID_PREFIX}${runId}:${stepId}:${billingEpoch}`;
3390
3616
  }
3391
3617
  __name(workflowOperationId, "workflowOperationId");
3392
- __name2(workflowOperationId, "workflowOperationId");
3618
+ __name3(workflowOperationId, "workflowOperationId");
3393
3619
  function workflowOccurrenceId(lineageId, stepId) {
3394
3620
  return `${lineageId}:${stepId}`;
3395
3621
  }
3396
3622
  __name(workflowOccurrenceId, "workflowOccurrenceId");
3397
- __name2(workflowOccurrenceId, "workflowOccurrenceId");
3623
+ __name3(workflowOccurrenceId, "workflowOccurrenceId");
3398
3624
  function workflowOrgSlotKey(orgId, kind) {
3399
3625
  return `wf:org:${orgId}:${kind}`;
3400
3626
  }
3401
3627
  __name(workflowOrgSlotKey, "workflowOrgSlotKey");
3402
- __name2(workflowOrgSlotKey, "workflowOrgSlotKey");
3628
+ __name3(workflowOrgSlotKey, "workflowOrgSlotKey");
3403
3629
  var WORKFLOW_CONNECTION_KEY_RE = /^[a-z][a-z0-9_-]{0,63}$/;
3404
3630
  var WORKFLOW_JOB_MODEL_SOURCE_LABELS = {
3405
3631
  stamp: "lease stamp",
@@ -3413,17 +3639,17 @@ function workflowJobModelSourceLabel(source) {
3413
3639
  return WORKFLOW_JOB_MODEL_SOURCE_LABELS[source];
3414
3640
  }
3415
3641
  __name(workflowJobModelSourceLabel, "workflowJobModelSourceLabel");
3416
- __name2(workflowJobModelSourceLabel, "workflowJobModelSourceLabel");
3642
+ __name3(workflowJobModelSourceLabel, "workflowJobModelSourceLabel");
3417
3643
  function scheduledTimeKey(scheduledTime) {
3418
3644
  return scheduledTime.replace(/[^0-9TZ]/g, "");
3419
3645
  }
3420
3646
  __name(scheduledTimeKey, "scheduledTimeKey");
3421
- __name2(scheduledTimeKey, "scheduledTimeKey");
3647
+ __name3(scheduledTimeKey, "scheduledTimeKey");
3422
3648
  function scheduledWorkflowRunIdForTime(jobId, scheduledTime) {
3423
3649
  return scheduledWorkflowRunId(jobId, scheduledTime);
3424
3650
  }
3425
3651
  __name(scheduledWorkflowRunIdForTime, "scheduledWorkflowRunIdForTime");
3426
- __name2(scheduledWorkflowRunIdForTime, "scheduledWorkflowRunIdForTime");
3652
+ __name3(scheduledWorkflowRunIdForTime, "scheduledWorkflowRunIdForTime");
3427
3653
  var WORKFLOW_SUSPEND_KINDS = [
3428
3654
  "input",
3429
3655
  "approval",
@@ -3436,18 +3662,227 @@ var WORKFLOW_RUN_NOTIFICATION_SUSPENDED_KINDS = [
3436
3662
  ];
3437
3663
  var WORKFLOW_SIGNAL_PAYLOAD_MAX_BYTES = 64 * 1024;
3438
3664
  var WORKFLOW_RESOLVE_OUTPUT_MAX_BYTES = 256 * 1024;
3665
+ var SCHEDULE_HEALTH_NOTIFY_CHANNELS = [
3666
+ "app",
3667
+ "email",
3668
+ "emailApp"
3669
+ ];
3670
+ var SCHEDULE_HEALTH_DEFAULT_NOTIFY = "emailApp";
3671
+ var SCHEDULE_HEALTH_LIMITS = {
3672
+ maxSilenceMinutes: {
3673
+ min: 5,
3674
+ max: 43200
3675
+ },
3676
+ alertAfterConsecutiveFailures: {
3677
+ min: 1,
3678
+ max: 50
3679
+ },
3680
+ /** The platform's auto-disable trip (PRO-726 / 07 §7.1.6): a streak can never pass it on these kinds. */
3681
+ parkedKindsMaxFailures: 3
3682
+ };
3683
+ var KNOWN_KEYS = /* @__PURE__ */ new Set([
3684
+ "maxSilenceMinutes",
3685
+ "alertAfterConsecutiveFailures",
3686
+ "notify"
3687
+ ]);
3688
+ function isInt(v) {
3689
+ return typeof v === "number" && Number.isInteger(v);
3690
+ }
3691
+ __name(isInt, "isInt");
3692
+ __name3(isInt, "isInt");
3693
+ function validateScheduleHealth(health, opts) {
3694
+ const base = opts.path ?? "health";
3695
+ const issues = [];
3696
+ if (health === null || typeof health !== "object" || Array.isArray(health)) {
3697
+ return [
3698
+ {
3699
+ code: "health-not-object",
3700
+ path: base,
3701
+ message: `${base} must be an object`
3702
+ }
3703
+ ];
3704
+ }
3705
+ const h = health;
3706
+ for (const key of Object.keys(h)) {
3707
+ if (!KNOWN_KEYS.has(key)) {
3708
+ issues.push({
3709
+ code: "health-unknown-field",
3710
+ path: `${base}.${key}`,
3711
+ message: `${base}.${key} is not a health field (maxSilenceMinutes, alertAfterConsecutiveFailures, notify)`
3712
+ });
3713
+ }
3714
+ }
3715
+ const silence = h.maxSilenceMinutes;
3716
+ const failures = h.alertAfterConsecutiveFailures;
3717
+ if (silence === void 0 && failures === void 0) {
3718
+ issues.push({
3719
+ code: "health-empty",
3720
+ path: base,
3721
+ message: `${base} needs maxSilenceMinutes and/or alertAfterConsecutiveFailures`
3722
+ });
3723
+ }
3724
+ const { min: sMin, max: sMax } = SCHEDULE_HEALTH_LIMITS.maxSilenceMinutes;
3725
+ if (silence !== void 0 && (!isInt(silence) || silence < sMin || silence > sMax)) {
3726
+ issues.push({
3727
+ code: "health-silence-invalid",
3728
+ path: `${base}.maxSilenceMinutes`,
3729
+ message: `${base}.maxSilenceMinutes must be an integer in ${sMin}..${sMax}`
3730
+ });
3731
+ }
3732
+ const fMin = SCHEDULE_HEALTH_LIMITS.alertAfterConsecutiveFailures.min;
3733
+ const fMax = opts.target === "workflow" ? SCHEDULE_HEALTH_LIMITS.parkedKindsMaxFailures : SCHEDULE_HEALTH_LIMITS.alertAfterConsecutiveFailures.max;
3734
+ if (failures !== void 0) {
3735
+ if (!isInt(failures) || failures < fMin) {
3736
+ issues.push({
3737
+ code: "health-failures-invalid",
3738
+ path: `${base}.alertAfterConsecutiveFailures`,
3739
+ message: `${base}.alertAfterConsecutiveFailures must be an integer in ${fMin}..${fMax}`
3740
+ });
3741
+ } else if (failures > fMax) {
3742
+ issues.push({
3743
+ code: opts.target === "workflow" ? "health-failures-unreachable" : "health-failures-invalid",
3744
+ path: `${base}.alertAfterConsecutiveFailures`,
3745
+ message: opts.target === "workflow" ? `${base}.alertAfterConsecutiveFailures must be \u2264 ${fMax}: a workflow schedule is turned off after ${fMax} consecutive failures, so a longer streak can never happen (the turn-off itself always alerts)` : `${base}.alertAfterConsecutiveFailures must be an integer in ${fMin}..${fMax}`
3746
+ });
3747
+ }
3748
+ }
3749
+ if (h.notify !== void 0 && !SCHEDULE_HEALTH_NOTIFY_CHANNELS.includes(h.notify)) {
3750
+ issues.push({
3751
+ code: "health-notify-invalid",
3752
+ path: `${base}.notify`,
3753
+ message: `${base}.notify must be one of ${SCHEDULE_HEALTH_NOTIFY_CHANNELS.join(", ")}`
3754
+ });
3755
+ }
3756
+ const triggers = (opts.triggers ?? []).filter((t) => !!t && typeof t === "object");
3757
+ if (opts.triggers !== void 0 && triggers.length === 0) {
3758
+ issues.push({
3759
+ code: "health-requires-schedule",
3760
+ path: base,
3761
+ message: `${base} needs a schedule to watch`
3762
+ });
3763
+ }
3764
+ if (isInt(silence) && triggers.length > 0) {
3765
+ if (triggers.every((t) => t.type === "once")) {
3766
+ issues.push({
3767
+ code: "health-silence-on-once",
3768
+ path: `${base}.maxSilenceMinutes`,
3769
+ message: `${base}.maxSilenceMinutes needs a recurring schedule; a one-time schedule has no cadence to fall silent against`
3770
+ });
3771
+ } else {
3772
+ const intervals = triggers.filter((t) => t.type === "interval" && isInt(t.seconds)).map((t) => t.seconds);
3773
+ const onlyIntervals = intervals.length === triggers.filter((t) => t.type !== "once").length;
3774
+ if (onlyIntervals && intervals.length > 0) {
3775
+ const fastest = Math.min(...intervals);
3776
+ if (silence * 60 <= fastest) {
3777
+ issues.push({
3778
+ code: "health-silence-shorter-than-interval",
3779
+ path: `${base}.maxSilenceMinutes`,
3780
+ message: `${base}.maxSilenceMinutes (${silence} min) must be longer than the schedule's interval (${fastest}s), or every healthy gap alerts`
3781
+ });
3782
+ }
3783
+ }
3784
+ }
3785
+ }
3786
+ return issues;
3787
+ }
3788
+ __name(validateScheduleHealth, "validateScheduleHealth");
3789
+ __name3(validateScheduleHealth, "validateScheduleHealth");
3790
+ function normalizeScheduleHealth(health) {
3791
+ return {
3792
+ ...health.maxSilenceMinutes !== void 0 ? {
3793
+ maxSilenceMinutes: health.maxSilenceMinutes
3794
+ } : {},
3795
+ ...health.alertAfterConsecutiveFailures !== void 0 ? {
3796
+ alertAfterConsecutiveFailures: health.alertAfterConsecutiveFailures
3797
+ } : {},
3798
+ notify: health.notify ?? SCHEDULE_HEALTH_DEFAULT_NOTIFY
3799
+ };
3800
+ }
3801
+ __name(normalizeScheduleHealth, "normalizeScheduleHealth");
3802
+ __name3(normalizeScheduleHealth, "normalizeScheduleHealth");
3803
+ function evaluateScheduleHealth(subject, now) {
3804
+ const parked = subject.status === "failed";
3805
+ if (parked) return {
3806
+ watched: true,
3807
+ condition: "auto_disabled"
3808
+ };
3809
+ if (subject.active === false || subject.status !== "active") return {
3810
+ watched: false,
3811
+ condition: null
3812
+ };
3813
+ const threshold = subject.health.alertAfterConsecutiveFailures;
3814
+ if (threshold !== void 0 && subject.consecutiveFailures >= threshold) {
3815
+ return {
3816
+ watched: true,
3817
+ condition: "failures"
3818
+ };
3819
+ }
3820
+ const window = subject.health.maxSilenceMinutes;
3821
+ if (window !== void 0) {
3822
+ const baseline = Math.max(subject.lastSucceededAt ?? 0, subject.state?.watchFrom ?? now);
3823
+ const silentMs = now - baseline;
3824
+ if (silentMs > window * 6e4) {
3825
+ return {
3826
+ watched: true,
3827
+ condition: "silence",
3828
+ silentForMinutes: Math.floor(silentMs / 6e4)
3829
+ };
3830
+ }
3831
+ }
3832
+ return {
3833
+ watched: true,
3834
+ condition: null
3835
+ };
3836
+ }
3837
+ __name(evaluateScheduleHealth, "evaluateScheduleHealth");
3838
+ __name3(evaluateScheduleHealth, "evaluateScheduleHealth");
3839
+ function scheduleHealthView(health, state3) {
3840
+ if (!health) return void 0;
3841
+ const incident = state3?.incident;
3842
+ return {
3843
+ config: {
3844
+ ...health.maxSilenceMinutes !== void 0 ? {
3845
+ maxSilenceMinutes: health.maxSilenceMinutes
3846
+ } : {},
3847
+ ...health.alertAfterConsecutiveFailures !== void 0 ? {
3848
+ alertAfterConsecutiveFailures: health.alertAfterConsecutiveFailures
3849
+ } : {},
3850
+ ...health.notify ? {
3851
+ notify: health.notify
3852
+ } : {}
3853
+ },
3854
+ state: incident ? "alerting" : state3?.watchFrom !== void 0 ? "ok" : "unwatched",
3855
+ ...incident ? {
3856
+ condition: incident.condition,
3857
+ since: incident.openedAt
3858
+ } : {},
3859
+ ...state3?.lastSucceededAt !== void 0 ? {
3860
+ lastSucceededAt: state3.lastSucceededAt
3861
+ } : {},
3862
+ ...state3?.checkedAt !== void 0 ? {
3863
+ checkedAt: state3.checkedAt
3864
+ } : {}
3865
+ };
3866
+ }
3867
+ __name(scheduleHealthView, "scheduleHealthView");
3868
+ __name3(scheduleHealthView, "scheduleHealthView");
3869
+ function scheduleHealthSourceId(agentId, jobId) {
3870
+ return `schedule-health:${agentId}:${jobId}`;
3871
+ }
3872
+ __name(scheduleHealthSourceId, "scheduleHealthSourceId");
3873
+ __name3(scheduleHealthSourceId, "scheduleHealthSourceId");
3439
3874
  var WORKFLOW_GOAL_JUDGE_SELF = "$self";
3440
3875
  function workflowGoalJudgeKind(judge) {
3441
3876
  return judge && typeof judge === "object" && judge.predicate !== void 0 ? "predicate" : "agent";
3442
3877
  }
3443
3878
  __name(workflowGoalJudgeKind, "workflowGoalJudgeKind");
3444
- __name2(workflowGoalJudgeKind, "workflowGoalJudgeKind");
3879
+ __name3(workflowGoalJudgeKind, "workflowGoalJudgeKind");
3445
3880
  function isWorkflowGoalJudgeComplete(judge) {
3446
3881
  if (workflowGoalJudgeKind(judge) === "predicate") return true;
3447
3882
  return typeof judge.agentId === "string" && judge.agentId.length > 0 && !!judge.schema && typeof judge.schema === "object" && !Array.isArray(judge.schema);
3448
3883
  }
3449
3884
  __name(isWorkflowGoalJudgeComplete, "isWorkflowGoalJudgeComplete");
3450
- __name2(isWorkflowGoalJudgeComplete, "isWorkflowGoalJudgeComplete");
3885
+ __name3(isWorkflowGoalJudgeComplete, "isWorkflowGoalJudgeComplete");
3451
3886
  function normalizeWorkflowGoalJudge(judge) {
3452
3887
  if (workflowGoalJudgeKind(judge) === "agent") return judge;
3453
3888
  return {
@@ -3459,7 +3894,7 @@ function normalizeWorkflowGoalJudge(judge) {
3459
3894
  };
3460
3895
  }
3461
3896
  __name(normalizeWorkflowGoalJudge, "normalizeWorkflowGoalJudge");
3462
- __name2(normalizeWorkflowGoalJudge, "normalizeWorkflowGoalJudge");
3897
+ __name3(normalizeWorkflowGoalJudge, "normalizeWorkflowGoalJudge");
3463
3898
  var REDACTED_PLACEHOLDER = "[REDACTED]";
3464
3899
  var PROVIDER_MESSAGE_MAX_CHARS = 300;
3465
3900
  var ERROR_MESSAGE_MAX_CHARS = 2e3;
@@ -3547,7 +3982,7 @@ function groupCount(re) {
3547
3982
  return n2;
3548
3983
  }
3549
3984
  __name(groupCount, "groupCount");
3550
- __name2(groupCount, "groupCount");
3985
+ __name3(groupCount, "groupCount");
3551
3986
  var WORKFLOW_SECRET_KEY_RE = /(^|[_\-.\s])(secret|token|password|passwd|pwd|passphrase|api[_-]?key|apikey|access[_-]?key|secret[_-]?key|private[_-]?key|client[_-]?secret|authorization|auth[_-]?token|access[_-]?token|id[_-]?token|refresh[_-]?token|session[_-]?key|credential(s)?)([_\-.\s]|$)|^(secret|token|password|passwd|pwd|passphrase|apikey|authorization|credentials?)$/i;
3552
3987
  var WORKFLOW_RESERVED_SECRET_KEYS = Object.freeze([
3553
3988
  "secret",
@@ -3575,7 +4010,7 @@ function isWorkflowSecretKey(key) {
3575
4010
  return WORKFLOW_SECRET_KEY_RE.test(key);
3576
4011
  }
3577
4012
  __name(isWorkflowSecretKey, "isWorkflowSecretKey");
3578
- __name2(isWorkflowSecretKey, "isWorkflowSecretKey");
4013
+ __name3(isWorkflowSecretKey, "isWorkflowSecretKey");
3579
4014
  function applyPatterns(text, patterns) {
3580
4015
  let out = text;
3581
4016
  for (const { re, suffix } of patterns) {
@@ -3595,13 +4030,13 @@ function applyPatterns(text, patterns) {
3595
4030
  return out;
3596
4031
  }
3597
4032
  __name(applyPatterns, "applyPatterns");
3598
- __name2(applyPatterns, "applyPatterns");
4033
+ __name3(applyPatterns, "applyPatterns");
3599
4034
  function scrubSecretText(text) {
3600
4035
  if (typeof text !== "string" || text.length < 4) return text;
3601
4036
  return applyPatterns(applyPatterns(text, SECRET_LITERAL_PATTERNS), SECRET_PAIR_PATTERNS);
3602
4037
  }
3603
4038
  __name(scrubSecretText, "scrubSecretText");
3604
- __name2(scrubSecretText, "scrubSecretText");
4039
+ __name3(scrubSecretText, "scrubSecretText");
3605
4040
  var SCRUB_INPUT_MAX_CHARS = 16 * 1024;
3606
4041
  var SCRUB_CUT_BACKOFF_CHARS = 256;
3607
4042
  function boundScrubInput(text, max = SCRUB_INPUT_MAX_CHARS) {
@@ -3612,12 +4047,12 @@ function boundScrubInput(text, max = SCRUB_INPUT_MAX_CHARS) {
3612
4047
  return `${text.slice(0, cut)}\u2026`;
3613
4048
  }
3614
4049
  __name(boundScrubInput, "boundScrubInput");
3615
- __name2(boundScrubInput, "boundScrubInput");
4050
+ __name3(boundScrubInput, "boundScrubInput");
3616
4051
  function scrubSecretLines(lines) {
3617
4052
  return lines.map((l) => typeof l === "string" ? scrubSecretText(boundScrubInput(l)) : l);
3618
4053
  }
3619
4054
  __name(scrubSecretLines, "scrubSecretLines");
3620
- __name2(scrubSecretLines, "scrubSecretLines");
4055
+ __name3(scrubSecretLines, "scrubSecretLines");
3621
4056
  function messageText(value3) {
3622
4057
  if (typeof value3 === "string") return value3;
3623
4058
  if (value3 instanceof Error) return value3.message;
@@ -3633,7 +4068,7 @@ function messageText(value3) {
3633
4068
  return value3 === void 0 || value3 === null ? "" : String(value3);
3634
4069
  }
3635
4070
  __name(messageText, "messageText");
3636
- __name2(messageText, "messageText");
4071
+ __name3(messageText, "messageText");
3637
4072
  function scrubProviderMessage(raw, max = PROVIDER_MESSAGE_MAX_CHARS) {
3638
4073
  const text = boundScrubInput(messageText(raw)).replace(/\s+/g, " ").trim();
3639
4074
  if (!text) return void 0;
@@ -3641,12 +4076,12 @@ function scrubProviderMessage(raw, max = PROVIDER_MESSAGE_MAX_CHARS) {
3641
4076
  return out.length > max ? `${out.slice(0, max - 1)}\u2026` : out;
3642
4077
  }
3643
4078
  __name(scrubProviderMessage, "scrubProviderMessage");
3644
- __name2(scrubProviderMessage, "scrubProviderMessage");
4079
+ __name3(scrubProviderMessage, "scrubProviderMessage");
3645
4080
  function scrubStepErrorMessage(raw) {
3646
4081
  return scrubProviderMessage(raw, ERROR_MESSAGE_MAX_CHARS);
3647
4082
  }
3648
4083
  __name(scrubStepErrorMessage, "scrubStepErrorMessage");
3649
- __name2(scrubStepErrorMessage, "scrubStepErrorMessage");
4084
+ __name3(scrubStepErrorMessage, "scrubStepErrorMessage");
3650
4085
  var WORKFLOW_AUDIT_EVENTS = [
3651
4086
  // --- definitions / versions / templates (13, 11 §11.11.5) ---
3652
4087
  "workflow.published",
@@ -3759,7 +4194,7 @@ function isWorkflowAuditEvent(action) {
3759
4194
  return typeof action === "string" && WORKFLOW_AUDIT_EVENTS.includes(action);
3760
4195
  }
3761
4196
  __name(isWorkflowAuditEvent, "isWorkflowAuditEvent");
3762
- __name2(isWorkflowAuditEvent, "isWorkflowAuditEvent");
4197
+ __name3(isWorkflowAuditEvent, "isWorkflowAuditEvent");
3763
4198
  function emptyRetentionCounts() {
3764
4199
  return {
3765
4200
  runs: 0,
@@ -3772,7 +4207,7 @@ function emptyRetentionCounts() {
3772
4207
  };
3773
4208
  }
3774
4209
  __name(emptyRetentionCounts, "emptyRetentionCounts");
3775
- __name2(emptyRetentionCounts, "emptyRetentionCounts");
4210
+ __name3(emptyRetentionCounts, "emptyRetentionCounts");
3776
4211
  var INDENT = " ";
3777
4212
  var WRAP_WIDTH = 78;
3778
4213
  var NOUNS = {
@@ -3816,7 +4251,7 @@ function wrap(tokens, indent, width) {
3816
4251
  return lines.join("\n");
3817
4252
  }
3818
4253
  __name(wrap, "wrap");
3819
- __name2(wrap, "wrap");
4254
+ __name3(wrap, "wrap");
3820
4255
  function passthroughPath(target) {
3821
4256
  const { owner, repo, number } = target.address;
3822
4257
  const base = `repos/${owner}/${repo}`;
@@ -3826,7 +4261,7 @@ function passthroughPath(target) {
3826
4261
  return base;
3827
4262
  }
3828
4263
  __name(passthroughPath, "passthroughPath");
3829
- __name2(passthroughPath, "passthroughPath");
4264
+ __name3(passthroughPath, "passthroughPath");
3830
4265
  function headerLine(target, position) {
3831
4266
  const { owner, repo, number, key, container } = target.address;
3832
4267
  const slug = owner && repo ? `${owner}/${repo}` : void 0;
@@ -3846,7 +4281,7 @@ function headerLine(target, position) {
3846
4281
  return `${position}. ${parts.join(" ")}`;
3847
4282
  }
3848
4283
  __name(headerLine, "headerLine");
3849
- __name2(headerLine, "headerLine");
4284
+ __name3(headerLine, "headerLine");
3850
4285
  function reachingIt(target) {
3851
4286
  const { owner, repo, key } = target.address;
3852
4287
  const toolName = GET_TOOL_NAMES[`${target.integrationType}:${target.kind}`];
@@ -3868,7 +4303,7 @@ function reachingIt(target) {
3868
4303
  return wrap(tokens, INDENT, WRAP_WIDTH);
3869
4304
  }
3870
4305
  __name(reachingIt, "reachingIt");
3871
- __name2(reachingIt, "reachingIt");
4306
+ __name3(reachingIt, "reachingIt");
3872
4307
  function renderTargetsBlock(targets) {
3873
4308
  if (!targets.length) return "";
3874
4309
  const items = targets.map((target, i) => [
@@ -3886,7 +4321,7 @@ ${PREAMBLE}
3886
4321
  ${items.join("\n\n")}`;
3887
4322
  }
3888
4323
  __name(renderTargetsBlock, "renderTargetsBlock");
3889
- __name2(renderTargetsBlock, "renderTargetsBlock");
4324
+ __name3(renderTargetsBlock, "renderTargetsBlock");
3890
4325
  var WORKFLOW_APPROVAL_OUTPUT_DECISIONS = [
3891
4326
  "approved",
3892
4327
  "denied",
@@ -3956,7 +4391,7 @@ function workflowApprovalDecisionOf(resumeData) {
3956
4391
  return resumeData.approved === true ? "approved" : "denied";
3957
4392
  }
3958
4393
  __name(workflowApprovalDecisionOf, "workflowApprovalDecisionOf");
3959
- __name2(workflowApprovalDecisionOf, "workflowApprovalDecisionOf");
4394
+ __name3(workflowApprovalDecisionOf, "workflowApprovalDecisionOf");
3960
4395
  function workflowApprovalOutput(resumeData) {
3961
4396
  const decision = typeof resumeData.decision === "string" ? resumeData.decision : workflowApprovalDecisionOf(resumeData);
3962
4397
  const note = typeof resumeData.note === "string" && resumeData.note.trim() !== "" ? resumeData.note : void 0;
@@ -3968,14 +4403,14 @@ function workflowApprovalOutput(resumeData) {
3968
4403
  };
3969
4404
  }
3970
4405
  __name(workflowApprovalOutput, "workflowApprovalOutput");
3971
- __name2(workflowApprovalOutput, "workflowApprovalOutput");
4406
+ __name3(workflowApprovalOutput, "workflowApprovalOutput");
3972
4407
  function isWorkflowApprovalOutput(value3) {
3973
4408
  if (typeof value3 !== "object" || value3 === null || Array.isArray(value3)) return false;
3974
4409
  const v = value3;
3975
4410
  return typeof v.approved === "boolean" && WORKFLOW_APPROVAL_OUTPUT_DECISIONS.includes(v.decision) && typeof v.text === "string";
3976
4411
  }
3977
4412
  __name(isWorkflowApprovalOutput, "isWorkflowApprovalOutput");
3978
- __name2(isWorkflowApprovalOutput, "isWorkflowApprovalOutput");
4413
+ __name3(isWorkflowApprovalOutput, "isWorkflowApprovalOutput");
3979
4414
  var JSON_FENCE_RE = /```(?:json)?[ \t]*\r?\n([\s\S]*?)\r?\n?```/g;
3980
4415
  function extractSingleJsonValue(text) {
3981
4416
  const trimmed = (text ?? "").trim();
@@ -4018,7 +4453,7 @@ function extractSingleJsonValue(text) {
4018
4453
  }
4019
4454
  }
4020
4455
  __name(extractSingleJsonValue, "extractSingleJsonValue");
4021
- __name2(extractSingleJsonValue, "extractSingleJsonValue");
4456
+ __name3(extractSingleJsonValue, "extractSingleJsonValue");
4022
4457
  var DEFAULT_ON_AGENT_FEATURES = [
4023
4458
  "workflows",
4024
4459
  "workflowCompose",
@@ -4028,17 +4463,17 @@ function agentFeatureCatalogDefault(featureName) {
4028
4463
  return DEFAULT_ON_AGENT_FEATURES.includes(featureName);
4029
4464
  }
4030
4465
  __name(agentFeatureCatalogDefault, "agentFeatureCatalogDefault");
4031
- __name2(agentFeatureCatalogDefault, "agentFeatureCatalogDefault");
4466
+ __name3(agentFeatureCatalogDefault, "agentFeatureCatalogDefault");
4032
4467
  function hasExplicitFeatureActive(row) {
4033
4468
  return typeof row?.active === "boolean";
4034
4469
  }
4035
4470
  __name(hasExplicitFeatureActive, "hasExplicitFeatureActive");
4036
- __name2(hasExplicitFeatureActive, "hasExplicitFeatureActive");
4471
+ __name3(hasExplicitFeatureActive, "hasExplicitFeatureActive");
4037
4472
  function effectiveFeatureActive(row, catalogDefault) {
4038
4473
  return hasExplicitFeatureActive(row) ? row.active : catalogDefault;
4039
4474
  }
4040
4475
  __name(effectiveFeatureActive, "effectiveFeatureActive");
4041
- __name2(effectiveFeatureActive, "effectiveFeatureActive");
4476
+ __name3(effectiveFeatureActive, "effectiveFeatureActive");
4042
4477
  function resolveEffectiveFeature(row, catalogDefault) {
4043
4478
  return hasExplicitFeatureActive(row) ? {
4044
4479
  active: row.active,
@@ -4051,7 +4486,7 @@ function resolveEffectiveFeature(row, catalogDefault) {
4051
4486
  };
4052
4487
  }
4053
4488
  __name(resolveEffectiveFeature, "resolveEffectiveFeature");
4054
- __name2(resolveEffectiveFeature, "resolveEffectiveFeature");
4489
+ __name3(resolveEffectiveFeature, "resolveEffectiveFeature");
4055
4490
  function asFeatureRow(value3) {
4056
4491
  if (value3 === false) return {
4057
4492
  active: false
@@ -4059,12 +4494,12 @@ function asFeatureRow(value3) {
4059
4494
  return typeof value3 === "object" && value3 !== null && !Array.isArray(value3) ? value3 : void 0;
4060
4495
  }
4061
4496
  __name(asFeatureRow, "asFeatureRow");
4062
- __name2(asFeatureRow, "asFeatureRow");
4497
+ __name3(asFeatureRow, "asFeatureRow");
4063
4498
  function agentFeatureBagCarries(bag, name) {
4064
4499
  return bag != null && Object.prototype.hasOwnProperty.call(bag, name) && asFeatureRow(bag[name]) !== void 0;
4065
4500
  }
4066
4501
  __name(agentFeatureBagCarries, "agentFeatureBagCarries");
4067
- __name2(agentFeatureBagCarries, "agentFeatureBagCarries");
4502
+ __name3(agentFeatureBagCarries, "agentFeatureBagCarries");
4068
4503
  function effectiveAgentFeatureRows(base, override) {
4069
4504
  const merged = /* @__PURE__ */ new Map();
4070
4505
  for (const [name, value3] of Object.entries(base ?? {})) {
@@ -4097,7 +4532,7 @@ function effectiveAgentFeatureRows(base, override) {
4097
4532
  };
4098
4533
  }
4099
4534
  __name(effectiveAgentFeatureRows, "effectiveAgentFeatureRows");
4100
- __name2(effectiveAgentFeatureRows, "effectiveAgentFeatureRows");
4535
+ __name3(effectiveAgentFeatureRows, "effectiveAgentFeatureRows");
4101
4536
  var SUBAGENT_PER_KEY_FLAG_ENV = "LUA_SUBAGENT_FEATURES_PER_KEY";
4102
4537
  var PER_KEY_FLAG_VALUES = /* @__PURE__ */ new Set([
4103
4538
  "1",
@@ -4110,17 +4545,17 @@ function agentFeatureMergeRuleFromEnv(env) {
4110
4545
  return typeof raw === "string" && PER_KEY_FLAG_VALUES.has(raw.trim().toLowerCase()) ? "per-key" : "wholesale";
4111
4546
  }
4112
4547
  __name(agentFeatureMergeRuleFromEnv, "agentFeatureMergeRuleFromEnv");
4113
- __name2(agentFeatureMergeRuleFromEnv, "agentFeatureMergeRuleFromEnv");
4548
+ __name3(agentFeatureMergeRuleFromEnv, "agentFeatureMergeRuleFromEnv");
4114
4549
  function effectiveAgentFeatures(base, override, rule) {
4115
4550
  if (rule === "wholesale") return override || base || void 0;
4116
4551
  return effectiveAgentFeatureRows(base, override).rows;
4117
4552
  }
4118
4553
  __name(effectiveAgentFeatures, "effectiveAgentFeatures");
4119
- __name2(effectiveAgentFeatures, "effectiveAgentFeatures");
4554
+ __name3(effectiveAgentFeatures, "effectiveAgentFeatures");
4120
4555
  var ONBOARDING_FLOW_KEY = "alpha-choose-meet";
4121
4556
  var ONBOARDING_SCHEMA_VERSION = 1;
4122
4557
  var id = z4.string().min(1).max(80).regex(/^[A-Za-z0-9][A-Za-z0-9_-]*$/);
4123
- var copy = /* @__PURE__ */ __name2((max) => z4.string().max(max), "copy");
4558
+ var copy = /* @__PURE__ */ __name3((max) => z4.string().max(max), "copy");
4124
4559
  var onboardingHeadingSchema = z4.discriminatedUnion("kind", [
4125
4560
  z4.object({
4126
4561
  kind: z4.literal("plain"),
@@ -4347,12 +4782,12 @@ function parseOnboardingFlow(value3) {
4347
4782
  return onboardingFlowSchema.parse(value3);
4348
4783
  }
4349
4784
  __name(parseOnboardingFlow, "parseOnboardingFlow");
4350
- __name2(parseOnboardingFlow, "parseOnboardingFlow");
4785
+ __name3(parseOnboardingFlow, "parseOnboardingFlow");
4351
4786
  function parsePublishedOnboardingResponse(value3) {
4352
4787
  return getPublishedOnboardingResponseSchema.parse(value3);
4353
4788
  }
4354
4789
  __name(parsePublishedOnboardingResponse, "parsePublishedOnboardingResponse");
4355
- __name2(parsePublishedOnboardingResponse, "parsePublishedOnboardingResponse");
4790
+ __name3(parsePublishedOnboardingResponse, "parsePublishedOnboardingResponse");
4356
4791
  var WEB_ROUTE_PROTOCOL_VERSION = 1;
4357
4792
  var WEB_ROUTE_METHODS = [
4358
4793
  "GET",
@@ -4381,14 +4816,14 @@ function isForwardableWebRouteRequestHeader(name) {
4381
4816
  return WEB_ROUTE_REQUEST_HEADER_ALLOWLIST.includes(n2) || n2.startsWith("x-lua-");
4382
4817
  }
4383
4818
  __name(isForwardableWebRouteRequestHeader, "isForwardableWebRouteRequestHeader");
4384
- __name2(isForwardableWebRouteRequestHeader, "isForwardableWebRouteRequestHeader");
4819
+ __name3(isForwardableWebRouteRequestHeader, "isForwardableWebRouteRequestHeader");
4385
4820
  function isForwardableWebRouteResponseHeader(name) {
4386
4821
  const n2 = name.toLowerCase();
4387
4822
  if (n2 === "set-cookie") return false;
4388
4823
  return WEB_ROUTE_RESPONSE_HEADER_ALLOWLIST.includes(n2) || n2.startsWith("x-lua-");
4389
4824
  }
4390
4825
  __name(isForwardableWebRouteResponseHeader, "isForwardableWebRouteResponseHeader");
4391
- __name2(isForwardableWebRouteResponseHeader, "isForwardableWebRouteResponseHeader");
4826
+ __name3(isForwardableWebRouteResponseHeader, "isForwardableWebRouteResponseHeader");
4392
4827
  var WEB_ROUTE_MAX_REQUEST_BODY_BYTES = 1 * 1024 * 1024;
4393
4828
  var WEB_ROUTE_MAX_RESPONSE_BYTES = 4 * 1024 * 1024;
4394
4829
  function isWebRouteBody(value3) {
@@ -4399,7 +4834,19 @@ function isWebRouteBody(value3) {
4399
4834
  return false;
4400
4835
  }
4401
4836
  __name(isWebRouteBody, "isWebRouteBody");
4402
- __name2(isWebRouteBody, "isWebRouteBody");
4837
+ __name3(isWebRouteBody, "isWebRouteBody");
4838
+ function isStringRecord(value3) {
4839
+ if (!value3 || typeof value3 !== "object" || Array.isArray(value3)) return false;
4840
+ return Object.values(value3).every((v) => typeof v === "string");
4841
+ }
4842
+ __name(isStringRecord, "isStringRecord");
4843
+ __name3(isStringRecord, "isStringRecord");
4844
+ function isQueryRecord(value3) {
4845
+ if (!value3 || typeof value3 !== "object" || Array.isArray(value3)) return false;
4846
+ return Object.values(value3).every((v) => typeof v === "string" || Array.isArray(v) && v.every((one) => typeof one === "string"));
4847
+ }
4848
+ __name(isQueryRecord, "isQueryRecord");
4849
+ __name3(isQueryRecord, "isQueryRecord");
4403
4850
  function isWebRouteInput(value3) {
4404
4851
  if (!value3 || typeof value3 !== "object") return false;
4405
4852
  const v = value3;
@@ -4408,9 +4855,9 @@ function isWebRouteInput(value3) {
4408
4855
  if (!r || typeof r !== "object") return false;
4409
4856
  if (!WEB_ROUTE_METHODS.includes(String(r.method))) return false;
4410
4857
  if (typeof r.path !== "string" || !r.path.startsWith("/")) return false;
4411
- if (!r.params || typeof r.params !== "object") return false;
4412
- if (!r.query || typeof r.query !== "object") return false;
4413
- if (!r.headers || typeof r.headers !== "object") return false;
4858
+ if (!isStringRecord(r.params)) return false;
4859
+ if (!isQueryRecord(r.query)) return false;
4860
+ if (!isStringRecord(r.headers)) return false;
4414
4861
  if (r.body !== void 0) {
4415
4862
  if (r.method === "GET") return false;
4416
4863
  if (!isWebRouteBody(r.body)) return false;
@@ -4422,56 +4869,422 @@ function isWebRouteInput(value3) {
4422
4869
  return true;
4423
4870
  }
4424
4871
  __name(isWebRouteInput, "isWebRouteInput");
4425
- __name2(isWebRouteInput, "isWebRouteInput");
4426
-
4427
- // ../workflow-graph/dist/index.mjs
4428
- import { createHash } from "crypto";
4429
- import { z as z5 } from "zod";
4430
- import { z as z22 } from "zod";
4431
-
4432
- // ../shared-types/dist/workflow-job-tools.mjs
4433
- var __defProp3 = Object.defineProperty;
4434
- var __name3 = /* @__PURE__ */ __name((target, value3) => __defProp3(target, "name", { value: value3, configurable: true }), "__name");
4435
- var WORKFLOW_JOB_TOOLS = [
4436
- "shell",
4437
- "read",
4438
- "write",
4439
- "edit",
4440
- "glob",
4441
- "grep",
4442
- "git",
4443
- "gh",
4444
- "fetch",
4445
- "ripwire"
4872
+ __name3(isWebRouteInput, "isWebRouteInput");
4873
+ var EVIDENCE_SESSION_IDLE_MS = 30 * 6e4;
4874
+ var EVIDENCE_MIN_CONVERSATIONS = 20;
4875
+ var EVIDENCE_LOW_CONFIDENCE_N = 5;
4876
+ var EVIDENCE_SNIPPET_MAX_CHARS = 160;
4877
+ var EVIDENCE_EXAMPLES_PER_ITEM = 5;
4878
+ var EVIDENCE_SHOWN_ITEMS = 5;
4879
+ var EVIDENCE_LATENCY_BOUNDS_MS = [
4880
+ 500,
4881
+ 1e3,
4882
+ 2e3,
4883
+ 3e3,
4884
+ 5e3,
4885
+ 8e3,
4886
+ 13e3,
4887
+ 2e4,
4888
+ 3e4,
4889
+ 6e4,
4890
+ 12e4
4446
4891
  ];
4447
- var WORKFLOW_JOB_READ_ONLY_DROPPED = [
4448
- "write",
4449
- "edit",
4450
- "git",
4451
- "shell"
4892
+ var EVIDENCE_WORD_BOUNDS = [
4893
+ 4,
4894
+ 10,
4895
+ 20,
4896
+ 40,
4897
+ 80,
4898
+ 150,
4899
+ 300,
4900
+ 600
4452
4901
  ];
4453
- var WORKFLOW_JOB_DEFAULT_TOOLS = [
4454
- "shell",
4455
- "read",
4456
- "write",
4457
- "edit",
4458
- "glob",
4459
- "grep",
4460
- "git"
4902
+ var BAD_CONVERSATION_REASONS = [
4903
+ "thumbs_down",
4904
+ "unfinished",
4905
+ "asked_for_human"
4461
4906
  ];
4462
- function effectiveJobTools(jobTools, readOnly) {
4463
- const base = jobTools?.length ? jobTools : WORKFLOW_JOB_DEFAULT_TOOLS;
4907
+ var ATTACHMENT_LINES = [
4908
+ // Audio / video / document lines carry a URL; a reply like "Audio: terrible" is the user's words.
4909
+ [
4910
+ /^\[?audio:\s*https?:\/\/\S+\]?$/i,
4911
+ () => "[Voice message]"
4912
+ ],
4913
+ [
4914
+ /^\[?video:\s*https?:\/\/\S+\]?$/i,
4915
+ () => "[Video]"
4916
+ ],
4917
+ [
4918
+ /^\[?document:\s*https?:\/\/\S+\]?$/i,
4919
+ () => "[Document]"
4920
+ ],
4921
+ // Image lines carry a file name with an extension (spaces allowed): "Image: my photo.jpg".
4922
+ [
4923
+ /^\[?image:\s*(?:https?:\/\/\S+|[^\s][^\n]{0,200}\.[a-z0-9]{2,5})\]?$/i,
4924
+ () => "[Image]"
4925
+ ],
4926
+ // "File: name (url)" — bounded classes, no backtracking between the name and the URL.
4927
+ [
4928
+ /^file:\s*([^()]{1,200}?)\s*\(https?:\/\/[^\s)]+\)$/i,
4929
+ (m) => `[File: ${m[1]}]`
4930
+ ]
4931
+ ];
4932
+ function evidenceDisplayText(text) {
4933
+ const raw = typeof text === "string" ? text : "";
4934
+ if (!raw.trim()) return "";
4935
+ const lines = removeHiddenBlocks(raw).split(/\r?\n/).map((line) => {
4936
+ const t = line.trim();
4937
+ for (const [re, label] of ATTACHMENT_LINES) {
4938
+ const m = t.match(re);
4939
+ if (m) return label(m);
4940
+ }
4941
+ return t.replace(/https?:\/\/cdn\.heylua\.ai\/\S+/gi, "[attachment]");
4942
+ }).filter(Boolean);
4943
+ const out = lines.join(" ").replace(/\s+/g, " ").trim();
4944
+ return out || "[Attachment]";
4945
+ }
4946
+ __name(evidenceDisplayText, "evidenceDisplayText");
4947
+ __name3(evidenceDisplayText, "evidenceDisplayText");
4948
+ function evidenceSnippet(text) {
4949
+ const flat = evidenceDisplayText(text);
4950
+ return flat.length <= EVIDENCE_SNIPPET_MAX_CHARS ? flat : `${flat.slice(0, EVIDENCE_SNIPPET_MAX_CHARS - 1)}\u2026`;
4951
+ }
4952
+ __name(evidenceSnippet, "evidenceSnippet");
4953
+ __name3(evidenceSnippet, "evidenceSnippet");
4954
+ function evidenceWordCount(text) {
4955
+ if (typeof text !== "string") return 0;
4956
+ const t = text.trim();
4957
+ return t ? t.split(/\s+/).length : 0;
4958
+ }
4959
+ __name(evidenceWordCount, "evidenceWordCount");
4960
+ __name3(evidenceWordCount, "evidenceWordCount");
4961
+ function evidenceKey(label) {
4962
+ return label.toLowerCase().replace(/[_\-\s]+/g, " ").trim();
4963
+ }
4964
+ __name(evidenceKey, "evidenceKey");
4965
+ __name3(evidenceKey, "evidenceKey");
4966
+ function evidenceOpaqueKey(text) {
4967
+ let h = 0xcbf29ce484222325n;
4968
+ const prime = 0x100000001b3n;
4969
+ for (const ch of evidenceKey(text)) {
4970
+ h ^= BigInt(ch.codePointAt(0) ?? 0);
4971
+ h = h * prime & 0xffffffffffffffffn;
4972
+ }
4973
+ return `q_${h.toString(16).padStart(16, "0")}`;
4974
+ }
4975
+ __name(evidenceOpaqueKey, "evidenceOpaqueKey");
4976
+ __name3(evidenceOpaqueKey, "evidenceOpaqueKey");
4977
+ function evidenceToolKey(name) {
4978
+ const i = name.indexOf("__");
4979
+ return (i >= 0 ? name.slice(i + 2) : name).toLowerCase();
4980
+ }
4981
+ __name(evidenceToolKey, "evidenceToolKey");
4982
+ __name3(evidenceToolKey, "evidenceToolKey");
4983
+ function evidenceToolSlug(name) {
4984
+ const i = name.indexOf("__");
4985
+ return i >= 0 ? name.slice(0, i).toLowerCase() : "";
4986
+ }
4987
+ __name(evidenceToolSlug, "evidenceToolSlug");
4988
+ __name3(evidenceToolSlug, "evidenceToolSlug");
4989
+ function skillSlugBase(skill) {
4990
+ return skill.toLowerCase().replace(/[^a-z0-9]+/g, "_").replace(/^_+|_+$/g, "");
4991
+ }
4992
+ __name(skillSlugBase, "skillSlugBase");
4993
+ __name3(skillSlugBase, "skillSlugBase");
4994
+ function matchDefinedTool(calledName, defined2) {
4995
+ const key = evidenceToolKey(calledName);
4996
+ const candidates = [];
4997
+ defined2.forEach((d, i) => {
4998
+ if (d.name.toLowerCase() === key) candidates.push(i);
4999
+ });
5000
+ if (candidates.length <= 1) return candidates[0] ?? -1;
5001
+ const slug = evidenceToolSlug(calledName);
5002
+ const bySkill = candidates.find((i) => {
5003
+ const base = skillSlugBase(defined2[i].skill);
5004
+ return base !== "" && (slug === base || slug.startsWith(`${base}_`) || base.startsWith(slug));
5005
+ });
5006
+ return bySkill ?? candidates[0];
5007
+ }
5008
+ __name(matchDefinedTool, "matchDefinedTool");
5009
+ __name3(matchDefinedTool, "matchDefinedTool");
5010
+ function isMisunderstoodReason(reason) {
5011
+ return typeof reason === "string" && /misunderst/i.test(reason);
5012
+ }
5013
+ __name(isMisunderstoodReason, "isMisunderstoodReason");
5014
+ __name3(isMisunderstoodReason, "isMisunderstoodReason");
5015
+ function emptyHistogram(bounds) {
5016
+ return {
5017
+ count: 0,
5018
+ sum: 0,
5019
+ buckets: new Array(bounds.length + 1).fill(0)
5020
+ };
5021
+ }
5022
+ __name(emptyHistogram, "emptyHistogram");
5023
+ __name3(emptyHistogram, "emptyHistogram");
5024
+ function addToHistogram(h, bounds, value3) {
5025
+ if (!Number.isFinite(value3) || value3 < 0) return;
5026
+ let i = bounds.findIndex((b) => value3 <= b);
5027
+ if (i < 0) i = bounds.length;
5028
+ h.buckets[i] += 1;
5029
+ h.count += 1;
5030
+ h.sum += value3;
5031
+ }
5032
+ __name(addToHistogram, "addToHistogram");
5033
+ __name3(addToHistogram, "addToHistogram");
5034
+ function mergeHistograms(hs, bounds) {
5035
+ if (hs.length === 0) return null;
5036
+ const out = emptyHistogram(bounds);
5037
+ for (const h of hs) {
5038
+ out.count += h.count;
5039
+ out.sum += h.sum;
5040
+ for (let i = 0; i < out.buckets.length; i++) out.buckets[i] += h.buckets[i] ?? 0;
5041
+ }
5042
+ return out.count > 0 ? out : null;
5043
+ }
5044
+ __name(mergeHistograms, "mergeHistograms");
5045
+ __name3(mergeHistograms, "mergeHistograms");
5046
+ function histogramQuantile(h, bounds, q) {
5047
+ if (h.count === 0) return 0;
5048
+ const target = q * h.count;
5049
+ let seen = 0;
5050
+ for (let i = 0; i < h.buckets.length; i++) {
5051
+ const n2 = h.buckets[i];
5052
+ if (n2 > 0 && seen + n2 >= target) {
5053
+ const lo = i === 0 ? 0 : bounds[i - 1];
5054
+ if (i >= bounds.length) return lo;
5055
+ const hi = bounds[i];
5056
+ return lo + (target - seen) / n2 * (hi - lo);
5057
+ }
5058
+ seen += n2;
5059
+ }
5060
+ return bounds[bounds.length - 1];
5061
+ }
5062
+ __name(histogramQuantile, "histogramQuantile");
5063
+ __name3(histogramQuantile, "histogramQuantile");
5064
+ function mergeCounted(lists) {
5065
+ const byKey = /* @__PURE__ */ new Map();
5066
+ for (const list of [
5067
+ ...lists
5068
+ ].reverse()) {
5069
+ for (const item of list) {
5070
+ const cur = byKey.get(item.key);
5071
+ if (!cur) {
5072
+ byKey.set(item.key, {
5073
+ ...item,
5074
+ examples: item.examples.slice(0, EVIDENCE_EXAMPLES_PER_ITEM)
5075
+ });
5076
+ } else {
5077
+ cur.count += item.count;
5078
+ if (cur.examples.length < EVIDENCE_EXAMPLES_PER_ITEM) {
5079
+ cur.examples.push(...item.examples.slice(0, EVIDENCE_EXAMPLES_PER_ITEM - cur.examples.length));
5080
+ }
5081
+ }
5082
+ }
5083
+ }
5084
+ return [
5085
+ ...byKey.values()
5086
+ ].sort((a, b) => b.count - a.count || a.key.localeCompare(b.key));
5087
+ }
5088
+ __name(mergeCounted, "mergeCounted");
5089
+ __name3(mergeCounted, "mergeCounted");
5090
+ function recentRefs(lists) {
5091
+ return lists.flat().sort((a, b) => b.createdAt - a.createdAt).slice(0, EVIDENCE_EXAMPLES_PER_ITEM);
5092
+ }
5093
+ __name(recentRefs, "recentRefs");
5094
+ __name3(recentRefs, "recentRefs");
5095
+ function confidenceOf(n2) {
5096
+ return n2 < EVIDENCE_LOW_CONFIDENCE_N ? "low" : "ok";
5097
+ }
5098
+ __name(confidenceOf, "confidenceOf");
5099
+ __name3(confidenceOf, "confidenceOf");
5100
+ function rateOf(count, conversations) {
5101
+ return {
5102
+ count,
5103
+ rate: conversations > 0 ? count / conversations : null,
5104
+ confidence: confidenceOf(count)
5105
+ };
5106
+ }
5107
+ __name(rateOf, "rateOf");
5108
+ __name3(rateOf, "rateOf");
5109
+ function evidenceDays(from, to) {
4464
5110
  const out = [];
4465
- for (const id2 of base) {
4466
- if (readOnly && WORKFLOW_JOB_READ_ONLY_DROPPED.includes(id2)) continue;
4467
- if (!out.includes(id2)) out.push(id2);
5111
+ const end = Date.parse(`${to}T00:00:00Z`);
5112
+ for (let t = Date.parse(`${from}T00:00:00Z`); t <= end; t += 864e5) {
5113
+ out.push(new Date(t).toISOString().slice(0, 10));
4468
5114
  }
4469
5115
  return out;
4470
5116
  }
4471
- __name(effectiveJobTools, "effectiveJobTools");
4472
- __name3(effectiveJobTools, "effectiveJobTools");
5117
+ __name(evidenceDays, "evidenceDays");
5118
+ __name3(evidenceDays, "evidenceDays");
5119
+ function summarizeEvidence(input) {
5120
+ const { agentId, from, to } = input;
5121
+ const windowDays = evidenceDays(from, to);
5122
+ const readable = /* @__PURE__ */ __name3((s) => s === "ok" || s === "empty", "readable");
5123
+ const covered = /* @__PURE__ */ __name3((d) => readable(d.sources?.messages) && readable(d.sources?.analyses), "covered");
5124
+ const inWindow = input.days.filter((d) => d.date >= from && d.date <= to && covered(d)).sort((a, b) => a.date.localeCompare(b.date));
5125
+ const trackedSince = [
5126
+ ...input.days,
5127
+ ...input.previous ?? []
5128
+ ].filter(covered).map((d) => d.date).sort()[0] ?? null;
5129
+ const sum = /* @__PURE__ */ __name3((f) => inWindow.reduce((acc, d) => acc + (f(d) || 0), 0), "sum");
5130
+ const conversations = sum((d) => d.conversations);
5131
+ const byReason = Object.fromEntries(BAD_CONVERSATION_REASONS.map((r) => [
5132
+ r,
5133
+ sum((d) => d.bad.byReason[r])
5134
+ ]));
5135
+ const badTotal = sum((d) => d.bad.total);
5136
+ const prevDays = (input.previous ?? []).filter(covered);
5137
+ const comparable = prevDays.length > 0;
5138
+ const prevReasons = mergeCounted(prevDays.map((d) => d.themes.failureReasons));
5139
+ const prevTopics = mergeCounted(prevDays.map((d) => d.themes.topics));
5140
+ const toThemes = /* @__PURE__ */ __name3((lists, prev) => mergeCounted(lists).slice(0, EVIDENCE_SHOWN_ITEMS).map((t) => ({
5141
+ ...t,
5142
+ share: badTotal > 0 ? t.count / badTotal : 0,
5143
+ previousCount: comparable ? prev.find((p) => p.key === t.key)?.count ?? 0 : null,
5144
+ confidence: confidenceOf(t.count)
5145
+ })), "toThemes");
5146
+ const usage = /* @__PURE__ */ new Map();
5147
+ for (const d of inWindow) {
5148
+ for (const t of d.tools) {
5149
+ const cur = usage.get(t.name) ?? {
5150
+ name: t.name,
5151
+ calls: 0,
5152
+ conversations: 0,
5153
+ errors: 0
5154
+ };
5155
+ cur.calls += t.calls;
5156
+ cur.conversations += t.conversations;
5157
+ cur.errors += t.errors;
5158
+ usage.set(t.name, cur);
5159
+ }
5160
+ }
5161
+ const latestDefined = [
5162
+ ...inWindow
5163
+ ].reverse().find((d) => d.definedTools)?.definedTools ?? null;
5164
+ const defined2 = input.definedTools !== void 0 ? input.definedTools : latestDefined;
5165
+ const definedKnown = Array.isArray(defined2);
5166
+ const enoughData = conversations >= EVIDENCE_MIN_CONVERSATIONS;
5167
+ const definedList = defined2 ?? [];
5168
+ const definedRows = definedList.map((dt) => ({
5169
+ name: dt.name,
5170
+ skill: dt.skill,
5171
+ calls: 0,
5172
+ conversations: 0,
5173
+ errors: 0
5174
+ }));
5175
+ const matched = /* @__PURE__ */ new Set();
5176
+ for (const u of usage.values()) {
5177
+ const i = matchDefinedTool(u.name, definedList);
5178
+ if (i < 0) continue;
5179
+ matched.add(u.name);
5180
+ definedRows[i].calls += u.calls;
5181
+ definedRows[i].conversations += u.conversations;
5182
+ definedRows[i].errors += u.errors;
5183
+ }
5184
+ definedRows.sort((a, b) => b.calls - a.calls || a.name.localeCompare(b.name));
5185
+ const other = [
5186
+ ...usage.values()
5187
+ ].filter((u) => !matched.has(u.name)).sort((a, b) => b.calls - a.calls);
5188
+ const rt = mergeHistograms(inWindow.map((d) => d.responseTimeMs).filter((h) => !!h), EVIDENCE_LATENCY_BOUNDS_MS);
5189
+ const wordRows = inWindow.map((d) => d.responseWords).filter((h) => !!h);
5190
+ const rw = mergeHistograms(wordRows, EVIDENCE_WORD_BOUNDS);
5191
+ const short = wordRows.reduce((a, h) => a + h.short, 0);
5192
+ const long = wordRows.reduce((a, h) => a + h.long, 0);
5193
+ return {
5194
+ agentId,
5195
+ window: {
5196
+ from,
5197
+ to,
5198
+ days: windowDays.length
5199
+ },
5200
+ coverage: {
5201
+ daysWithData: inWindow.length,
5202
+ trackedSince,
5203
+ complete: inWindow.length === windowDays.length
5204
+ },
5205
+ conversations,
5206
+ exchanges: sum((d) => d.exchanges),
5207
+ bad: {
5208
+ ...rateOf(badTotal, conversations),
5209
+ byReason,
5210
+ examples: recentRefs(inWindow.map((d) => d.examples.bad))
5211
+ },
5212
+ misunderstood: {
5213
+ ...rateOf(sum((d) => d.misunderstood), conversations),
5214
+ examples: recentRefs(inWindow.map((d) => d.examples.misunderstood))
5215
+ },
5216
+ unmetIntent: {
5217
+ ...rateOf(sum((d) => d.unmetIntent), conversations),
5218
+ questions: mergeCounted(inWindow.map((d) => d.unmetQuestions)).slice(0, EVIDENCE_SHOWN_ITEMS)
5219
+ },
5220
+ loops: {
5221
+ ...rateOf(sum((d) => d.loops), conversations),
5222
+ examples: recentRefs(inWindow.map((d) => d.examples.loops))
5223
+ },
5224
+ themes: {
5225
+ failureReasons: toThemes(inWindow.map((d) => d.themes.failureReasons), prevReasons),
5226
+ topics: toThemes(inWindow.map((d) => d.themes.topics), prevTopics),
5227
+ comparable
5228
+ },
5229
+ tools: {
5230
+ enoughData,
5231
+ definedKnown,
5232
+ definedCount: definedRows.length,
5233
+ usedDefinedCount: definedRows.filter((r) => r.calls > 0).length,
5234
+ calledCount: definedRows.filter((r) => r.calls > 0).length + other.filter((u) => u.calls > 0).length,
5235
+ defined: definedRows,
5236
+ unused: enoughData && definedKnown ? definedRows.filter((r) => r.calls === 0).map(({ name, skill }) => ({
5237
+ name,
5238
+ skill
5239
+ })) : [],
5240
+ other
5241
+ },
5242
+ responseTime: rt ? {
5243
+ count: rt.count,
5244
+ avgMs: Math.round(rt.sum / rt.count),
5245
+ medianMs: Math.round(histogramQuantile(rt, EVIDENCE_LATENCY_BOUNDS_MS, 0.5)),
5246
+ p90Ms: Math.round(histogramQuantile(rt, EVIDENCE_LATENCY_BOUNDS_MS, 0.9))
5247
+ } : null,
5248
+ responseLength: rw ? {
5249
+ count: rw.count,
5250
+ avgWords: Math.round(rw.sum / rw.count),
5251
+ medianWords: Math.round(histogramQuantile(rw, EVIDENCE_WORD_BOUNDS, 0.5)),
5252
+ shortRate: short / rw.count,
5253
+ longRate: long / rw.count
5254
+ } : null
5255
+ };
5256
+ }
5257
+ __name(summarizeEvidence, "summarizeEvidence");
5258
+ __name3(summarizeEvidence, "summarizeEvidence");
5259
+ var REVIEW_VERDICT_REASON_ORDER = [
5260
+ "overall_below",
5261
+ "dimension_below",
5262
+ "critical_issues",
5263
+ "issue_count"
5264
+ ];
5265
+ function sortVerdictReasons(reasons) {
5266
+ return [
5267
+ ...reasons
5268
+ ].sort((a, b) => REVIEW_VERDICT_REASON_ORDER.indexOf(a.kind) - REVIEW_VERDICT_REASON_ORDER.indexOf(b.kind));
5269
+ }
5270
+ __name(sortVerdictReasons, "sortVerdictReasons");
5271
+ __name3(sortVerdictReasons, "sortVerdictReasons");
5272
+ var ENV_TEMPLATE_SECRET_KEY_RE = /(SECRET|TOKEN|KEY|PASSWORD)$/;
5273
+ function envTemplatePlaceholder(key) {
5274
+ if (ENV_TEMPLATE_SECRET_KEY_RE.test(key)) {
5275
+ throw new Error(`env-template-secret-key: \`${key}\` looks like a secret \u2014 read it with env('${key}') inside execute instead`);
5276
+ }
5277
+ return {
5278
+ __envRef: key
5279
+ };
5280
+ }
5281
+ __name(envTemplatePlaceholder, "envTemplatePlaceholder");
5282
+ __name3(envTemplatePlaceholder, "envTemplatePlaceholder");
4473
5283
 
4474
5284
  // ../workflow-graph/dist/index.mjs
5285
+ import { createHash } from "crypto";
5286
+ import { z as z5 } from "zod";
5287
+ import { z as z22 } from "zod";
4475
5288
  import { createHash as createHash2 } from "crypto";
4476
5289
  var __defProp4 = Object.defineProperty;
4477
5290
  var __name4 = /* @__PURE__ */ __name((target, value22) => __defProp4(target, "name", { value: value22, configurable: true }), "__name");
@@ -5135,6 +5948,17 @@ function liftRenderedApprover(row, rendered) {
5135
5948
  }
5136
5949
  __name(liftRenderedApprover, "liftRenderedApprover");
5137
5950
  __name4(liftRenderedApprover, "liftRenderedApprover");
5951
+ function approverUsersOf(users) {
5952
+ if (Array.isArray(users)) {
5953
+ if (users.length === 0 || users.length > APPROVER_SPEC_MAX_USERS) return null;
5954
+ return users.every((m) => typeof m === "string" && m.length > 0 && m.length <= 128) ? users : null;
5955
+ }
5956
+ if (typeof users !== "string") return null;
5957
+ const lifted = liftRenderedApprover("users", users);
5958
+ return lifted && "users" in lifted ? lifted.users : null;
5959
+ }
5960
+ __name(approverUsersOf, "approverUsersOf");
5961
+ __name4(approverUsersOf, "approverUsersOf");
5138
5962
  var WORKSPACE_TEMPLATE_EXPR_RE = /^\$\{\s*(?:initData|input)\.([^}]+?)\s*\}$/;
5139
5963
  function workspaceTemplatePath(template22) {
5140
5964
  const key = template22.trim();
@@ -5699,6 +6523,31 @@ function validateLuaExtensions(g, caps = WORKFLOW_CAPS_DEFAULT, opts = {
5699
6523
  warn("gh-on-coding-turn", `"${id2}" grants the gh tool on a coding turn \u2014 the pod can open/merge PRs on the workspace repo (purpose:'gh' token, pull_requests:write + contents:write)`, `${path}.jobTools`, id2);
5700
6524
  }
5701
6525
  }
6526
+ const plugins = node.plugins;
6527
+ const target = node.target;
6528
+ const luaApi = node.luaApi;
6529
+ if (luaApi !== void 0) {
6530
+ const problem = workflowJobLuaApiProblem(luaApi, node.type === "step" ? "code" : node.type, isJobTier(node) ? "job" : node.tier);
6531
+ if (problem) err("lua-api-invalid", problem, `${path}.luaApi`, id2);
6532
+ }
6533
+ if (target !== void 0) {
6534
+ const problem = workflowJobTargetProblem(target, plugins, luaApi);
6535
+ if (problem) err("target-invalid", problem, `${path}.target`, id2);
6536
+ }
6537
+ if (plugins !== void 0) {
6538
+ const problem = workflowJobPluginsProblem(plugins);
6539
+ if (problem) err("plugins-invalid", problem, `${path}.plugins`, id2);
6540
+ if (node.type !== "agent") err("plugins-invalid", "`plugins` is legal on agent steps only", `${path}.plugins`, id2);
6541
+ else {
6542
+ if (!isJobTier(node)) err("plugins-invalid", "`plugins` needs tier:'job'", `${path}.plugins`, id2);
6543
+ const provider = classifyModelProvider(jobClassifiablePin(node.model));
6544
+ if (node.harness === "generic" || provider !== null && provider !== "anthropic") err("plugins-invalid", "`plugins` run on the claude-code harness only (an Anthropic model, no `harness:'generic'`)", `${path}.plugins`, id2);
6545
+ const w = workspaceOf(node);
6546
+ const ro = w !== void 0 && w !== "inherit" && w.mount === "ro";
6547
+ const declared = Array.isArray(tools) ? tools : void 0;
6548
+ if (!effectiveJobTools(declared, ro).includes("shell")) err("plugins-invalid", "`plugins` need the `shell` job tool (the plugin drives lua-cli) \u2014 keep it in jobTools and mount rw", `${path}.plugins`, id2);
6549
+ }
6550
+ }
5702
6551
  if (node.type === "agent" && ws && ws !== "inherit" && ws.mount === "ro" && Array.isArray(tools) && effectiveJobTools(tools, true).length === 0) {
5703
6552
  warn("ro-step-has-no-tools", `"${id2}" mounts the workspace read-only and every jobTool it declares (${JSON.stringify(tools)}) is one the ro mount drops [${WORKFLOW_JOB_READ_ONLY_DROPPED.join(", ")}] \u2014 the coding turn would run with no tools at all; keep a read-only tool (read/glob/grep, gh) or mount rw`, `${path}.jobTools`, id2);
5704
6553
  }
@@ -9015,7 +9864,9 @@ function stepNodeOf(s) {
9015
9864
  tier,
9016
9865
  workspace: s.workspace,
9017
9866
  jobResources: s.jobResources,
9018
- jobTools: s.jobTools
9867
+ jobTools: s.jobTools,
9868
+ luaApi: s.luaApi,
9869
+ target: s.target
9019
9870
  });
9020
9871
  }
9021
9872
  __name(stepNodeOf, "stepNodeOf");
@@ -9100,6 +9951,14 @@ var WorkflowBuilderImpl = class WorkflowBuilderImpl2 {
9100
9951
  const tier = s.tier ?? (s.workspace ? "job" : void 0);
9101
9952
  if (s.workspace && s.tier !== void 0 && s.tier !== "job") throw new LuaWorkflowBuildError("workspace-requires-job-tier", `"${s.id}": a step mounting a workspace must be tier:'job'`);
9102
9953
  if (s.jobTools && tier !== "job") throw new LuaWorkflowBuildError("cap-exceeded", `"${s.id}": jobTools require tier:'job' (job-tools-require-job-tier)`);
9954
+ if (s.luaApi !== void 0) {
9955
+ const problem = workflowJobLuaApiProblem(s.luaApi, "code", tier);
9956
+ if (problem) throw new LuaWorkflowBuildError("lua-api-invalid", `"${s.id}": ${problem}`);
9957
+ }
9958
+ if (s.target !== void 0) {
9959
+ const problem = workflowJobTargetProblem(s.target, void 0, s.luaApi);
9960
+ if (problem) throw new LuaWorkflowBuildError("target-invalid", `"${s.id}": ${problem}`);
9961
+ }
9103
9962
  assertTimeout({
9104
9963
  id: s.id,
9105
9964
  timeoutSeconds: s.timeoutSeconds,
@@ -9349,6 +10208,15 @@ var WorkflowBuilderImpl = class WorkflowBuilderImpl2 {
9349
10208
  throw new LuaWorkflowBuildError("max-turns-invalid", `"${id2}": ${m} must be an integer ${min}..${max}`);
9350
10209
  }
9351
10210
  }
10211
+ if (opts.plugins !== void 0) {
10212
+ if (tier !== "job") throw new LuaWorkflowBuildError("plugins-invalid", `"${id2}": plugins are only legal on a tier:'job' agent step`);
10213
+ const problem = workflowJobPluginsProblem(opts.plugins);
10214
+ if (problem) throw new LuaWorkflowBuildError("plugins-invalid", `"${id2}": ${problem}`);
10215
+ }
10216
+ if (opts.target !== void 0) {
10217
+ const problem = workflowJobTargetProblem(opts.target, opts.plugins);
10218
+ if (problem) throw new LuaWorkflowBuildError("target-invalid", `"${id2}": ${problem}`);
10219
+ }
9352
10220
  assertTimeout({
9353
10221
  id: id2,
9354
10222
  timeoutSeconds: opts.timeoutSeconds,
@@ -9381,7 +10249,9 @@ var WorkflowBuilderImpl = class WorkflowBuilderImpl2 {
9381
10249
  harness: opts.harness,
9382
10250
  maxTurns: opts.maxTurns,
9383
10251
  maxMessages: opts.maxMessages,
9384
- maxInputTokens: opts.maxInputTokens
10252
+ maxInputTokens: opts.maxInputTokens,
10253
+ plugins: opts.plugins,
10254
+ target: opts.target
9385
10255
  });
9386
10256
  return this.push({
9387
10257
  kind: "declare",
@@ -9648,6 +10518,15 @@ function createWorkflow(cfg) {
9648
10518
  const n2 = cfg.backfillOnEnable.maxOccurrences;
9649
10519
  if (!Number.isInteger(n2) || n2 < 1 || n2 > 200) throw new LuaWorkflowBuildError("invalid-envelope", "backfillOnEnable.maxOccurrences must be an integer in 1..200 (backfill-max-occurrences-out-of-range; the org maxBatchItems twin is checked at publish/R56)");
9650
10520
  }
10521
+ if (cfg.health !== void 0) {
10522
+ const issues = validateScheduleHealth(cfg.health, {
10523
+ target: "workflow",
10524
+ triggers: cfg.schedule && typeof cfg.schedule === "object" ? [
10525
+ cfg.schedule
10526
+ ] : []
10527
+ });
10528
+ if (issues.length > 0) throw new LuaWorkflowBuildError("invalid-envelope", issues.map((i) => `${i.message} (${i.code})`).join("; "));
10529
+ }
9651
10530
  const keys = /* @__PURE__ */ new Set();
9652
10531
  envRefKeys(cfg.schedule, keys);
9653
10532
  envRefKeys(cfg.workspace, keys);