@wayai/cli 0.3.231 → 0.3.232

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -4929,10 +4929,10 @@ var init_chunk_HZ6CADSY = __esm({
4929
4929
  }
4930
4930
  });
4931
4931
 
4932
- // ../../packages/core/dist/chunk-DYI3BRJ3.js
4932
+ // ../../packages/core/dist/chunk-6VCHIFJT.js
4933
4933
  var resourceIdParam, listResourcesQuery, createResourceBody, updateResourceBody, syncSkillsBody, resourceFileIdParam, listResourceFilesQuery, createResourceFileBody, updateResourceFileBody, uploadResourceFileBody, uploadSkillZipBody, resourceFolderIdParam, listResourceFoldersQuery, createResourceFolderBody, updateResourceFolderBody, agentResourceQuery, hubResourceQuery, linkAgentResourceBody, updateAgentResourceBody, unlinkAgentResourceQuery;
4934
- var init_chunk_DYI3BRJ3 = __esm({
4935
- "../../packages/core/dist/chunk-DYI3BRJ3.js"() {
4934
+ var init_chunk_6VCHIFJT = __esm({
4935
+ "../../packages/core/dist/chunk-6VCHIFJT.js"() {
4936
4936
  "use strict";
4937
4937
  init_chunk_HZ6CADSY();
4938
4938
  init_zod();
@@ -5060,8 +5060,7 @@ var init_chunk_DYI3BRJ3 = __esm({
5060
5060
  resource_id: uuidSchema,
5061
5061
  agent_id: uuidSchema,
5062
5062
  priority: external_exports.number().optional(),
5063
- use_native_integration: external_exports.boolean().optional(),
5064
- write_enabled: external_exports.boolean().optional()
5063
+ use_native_integration: external_exports.boolean().optional()
5065
5064
  });
5066
5065
  updateAgentResourceBody = external_exports.object({
5067
5066
  hub_id: uuidSchema,
@@ -5069,8 +5068,7 @@ var init_chunk_DYI3BRJ3 = __esm({
5069
5068
  agent_id: uuidSchema,
5070
5069
  use_native_integration: external_exports.boolean().optional(),
5071
5070
  enabled: external_exports.boolean().optional(),
5072
- priority: external_exports.number().optional(),
5073
- write_enabled: external_exports.boolean().optional()
5071
+ priority: external_exports.number().optional()
5074
5072
  });
5075
5073
  unlinkAgentResourceQuery = external_exports.object({
5076
5074
  hub_id: uuidSchema,
@@ -5623,7 +5621,7 @@ var init_chunk_5XEJSR22 = __esm({
5623
5621
  }
5624
5622
  });
5625
5623
 
5626
- // ../../packages/core/dist/chunk-KJXJKAYT.js
5624
+ // ../../packages/core/dist/chunk-QUKTIJKE.js
5627
5625
  function matchPath(pattern, path42) {
5628
5626
  const normalizedPath = path42.replace(/\/$/, "");
5629
5627
  if (pattern.endsWith("/*")) {
@@ -5651,8 +5649,8 @@ function getEndpointConfig(path42) {
5651
5649
  return { tier: "STANDARD" };
5652
5650
  }
5653
5651
  var ENDPOINT_CONFIGS, EXCLUDED_PATHS;
5654
- var init_chunk_KJXJKAYT = __esm({
5655
- "../../packages/core/dist/chunk-KJXJKAYT.js"() {
5652
+ var init_chunk_QUKTIJKE = __esm({
5653
+ "../../packages/core/dist/chunk-QUKTIJKE.js"() {
5656
5654
  "use strict";
5657
5655
  init_chunk_5XEJSR22();
5658
5656
  ENDPOINT_CONFIGS = {
@@ -5971,6 +5969,9 @@ var init_chunk_KJXJKAYT = __esm({
5971
5969
  // fans out over every production hub of every org, so it takes the same strict,
5972
5970
  // fail-closed budget as the team-orphan repair. Exact path, for the same reason.
5973
5971
  "/api/admin/hubs/repair-branching-orphans": { tier: "STRICT", userLimit: 10, userWindow: 3600, failClosed: true },
5972
+ // Knowledge-blob repair (#5142 step 5 C1) — deletes R2 objects across every hub of a scope, so it
5973
+ // takes the same strict, fail-closed budget as the other hub repairs. Exact path, for the same reason.
5974
+ "/api/admin/hubs/repair-knowledge-blobs": { tier: "STRICT", userLimit: 10, userWindow: 3600, failClosed: true },
5974
5975
  // CI/GitOps endpoints - standard with user limits. 500 because `wayai push` makes four requests
5975
5976
  // (pull, diff, push, pull) and a GitOps job may push every hub at once with one token; when
5976
5977
  // each path held its own 100, that ran to 100 hubs a minute.
@@ -6121,7 +6122,7 @@ var init_chunk_KJXJKAYT = __esm({
6121
6122
  }
6122
6123
  });
6123
6124
 
6124
- // ../../packages/core/dist/chunk-4QBKRQMM.js
6125
+ // ../../packages/core/dist/chunk-4QU6WS7I.js
6125
6126
  function fileSnapshotChanged(run) {
6126
6127
  return run.written + run.removed > 0;
6127
6128
  }
@@ -6162,10 +6163,10 @@ async function sendWithRetry(opts, cursor) {
6162
6163
  }
6163
6164
  }
6164
6165
  var rekorFileSnapshotAnswerSchema, FILE_SNAPSHOT_MAX_PAGES, FILE_SNAPSHOT_CONFLICT_ATTEMPTS, FILE_SNAPSHOT_PAGE_SPACING_MS, FILE_SNAPSHOT_CONFLICT_STATUS;
6165
- var init_chunk_4QBKRQMM = __esm({
6166
- "../../packages/core/dist/chunk-4QBKRQMM.js"() {
6166
+ var init_chunk_4QU6WS7I = __esm({
6167
+ "../../packages/core/dist/chunk-4QU6WS7I.js"() {
6167
6168
  "use strict";
6168
- init_chunk_KJXJKAYT();
6169
+ init_chunk_QUKTIJKE();
6169
6170
  init_chunk_5XEJSR22();
6170
6171
  init_zod();
6171
6172
  rekorFileSnapshotAnswerSchema = external_exports.object({
@@ -8207,15 +8208,15 @@ var init_chunk_MH4O3YEX = __esm({
8207
8208
  }
8208
8209
  });
8209
8210
 
8210
- // ../../packages/core/dist/chunk-UFYIBL66.js
8211
+ // ../../packages/core/dist/chunk-GWMNV3N4.js
8211
8212
  function catalogToolSideEffects(toolName) {
8212
8213
  const sideEffects = CATALOG_SIDE_EFFECTS.get(toolName);
8213
8214
  if (sideEffects === void 0) return "unknown";
8214
8215
  return sideEffects ? "side_effects" : "none";
8215
8216
  }
8216
8217
  var NATIVE_TOOL_SCHEMAS, WAYAI_CONNECTOR, SANDBOX_AGENT_ROLES, BASE_NATIVE_TOOLS, NATIVE_TOOLS, CATALOG_SIDE_EFFECTS;
8217
- var init_chunk_UFYIBL66 = __esm({
8218
- "../../packages/core/dist/chunk-UFYIBL66.js"() {
8218
+ var init_chunk_GWMNV3N4 = __esm({
8219
+ "../../packages/core/dist/chunk-GWMNV3N4.js"() {
8219
8220
  "use strict";
8220
8221
  init_chunk_DHPUPI4Y();
8221
8222
  NATIVE_TOOL_SCHEMAS = {
@@ -8693,83 +8694,6 @@ var init_chunk_UFYIBL66 = __esm({
8693
8694
  },
8694
8695
  "tool_instructions": 'Use to find out which files exist before reading one. Call it with no path first: that returns the mounts \u2014 "conversation" for what the user attached here, one "skills/<slug>" per skill and one "resources/<slug>" per knowledge resource linked to you. Then pass a mount or folder path back to list its contents. Every row carries a `path`; pass that path to read_file to open the file, or (outside "data/") to send_files to deliver it. Pass query, tags or metadata_filter to search a whole skill, resource or data/ file type at once instead of walking it folder by folder. Files from EARLIER conversations are not listed here \u2014 the transcript of each past conversation announces its own files by path (get_conversation).'
8695
8696
  },
8696
- "list_resource_folders": {
8697
- "tool_config": {
8698
- "name": "list_resource_folders",
8699
- "description": "(deprecated \u2014 use list_files) List all folders in resources that this agent has access to. Returns all folders with parent_folder_id for hierarchy reconstruction.",
8700
- "strict": false,
8701
- "parameters": {
8702
- "type": "object",
8703
- "properties": {
8704
- "resource_id": {
8705
- "type": "string",
8706
- "description": "Resource ID to query folders from. Must be one of the knowledge resources linked to this agent (the available ids are listed here at runtime). Required for access control and performance."
8707
- },
8708
- "search_query": {
8709
- "type": "string",
8710
- "description": "Search folders by name"
8711
- },
8712
- "metadata_filter": {
8713
- "type": "object",
8714
- "description": 'Filter by metadata using MongoDB-style operators. Supported: $eq (equal), $ne (not equal), $gt/$gte/$lt/$lte (comparisons), $in/$nin (in/not in array), $contains (contains value), $and/$or/$not (logical). Supports nested paths like "location.city". Returns clear errors for type mismatches. Examples: {"status": "active"} for simple equality, {"priority": {"$gte": 5}} for comparison, {"location.city": "Miami"} for nested path, {"$and": [{"status": "active"}, {"priority": {"$gt": 3}}]} for complex logic, {"$not": {"status": "archived"}} for negation. Schema from resource.folder_metadata_schema.'
8715
- }
8716
- },
8717
- "required": [
8718
- "resource_id"
8719
- ],
8720
- "additionalProperties": false
8721
- }
8722
- },
8723
- "tool_instructions": "Deprecated: prefer list_files, which walks the same folders by path and needs no resource_id. Still works \u2014 lists all folders in a resource, filtered by search_query or metadata, returning folder info with parent_folder_id, file counts, and subfolder counts."
8724
- },
8725
- "list_resource_files": {
8726
- "tool_config": {
8727
- "name": "list_resource_files",
8728
- "description": "(deprecated \u2014 use list_files) List files in resources that this agent has access to. Each file is returned with its path \u2014 the address read_file accepts \u2014 plus metadata.",
8729
- "strict": false,
8730
- "parameters": {
8731
- "type": "object",
8732
- "properties": {
8733
- "resource_id": {
8734
- "type": "string",
8735
- "description": "Resource ID to query files from. Must be one of the knowledge resources linked to this agent (the available ids are listed here at runtime). Required for access control and performance."
8736
- },
8737
- "folder_id": {
8738
- "type": "string",
8739
- "description": "Filter by folder ID. Omit to return ALL files. Use 00000000-0000-0000-0000-000000000000 for root-level files only."
8740
- },
8741
- "search_query": {
8742
- "type": "string",
8743
- "description": "Search files by title or file name"
8744
- },
8745
- "tags": {
8746
- "type": "array",
8747
- "items": {
8748
- "type": "string"
8749
- },
8750
- "description": "Filter by tags (matches files with any of the specified tags)"
8751
- },
8752
- "metadata_filter": {
8753
- "type": "object",
8754
- "description": 'Filter by metadata using MongoDB-style operators. Supported: $eq (equal), $ne (not equal), $gt/$gte/$lt/$lte (comparisons), $in/$nin (in/not in array), $contains (contains value), $and/$or/$not (logical). Supports nested paths like "location.city". Returns clear errors for type mismatches. Examples: {"status": "active"} for simple equality, {"priority": {"$gte": 5}} for comparison, {"location.city": "Miami"} for nested path, {"$and": [{"status": "active"}, {"priority": {"$gt": 3}}]} for complex logic, {"$not": {"status": "archived"}} for negation. Schema from resource.file_metadata_schema.'
8755
- },
8756
- "limit": {
8757
- "type": "integer",
8758
- "description": "Maximum number of files to return (default: 50, max: 100)"
8759
- },
8760
- "offset": {
8761
- "type": "integer",
8762
- "description": "Number of files to skip for pagination (default: 0)"
8763
- }
8764
- },
8765
- "required": [
8766
- "resource_id"
8767
- ],
8768
- "additionalProperties": false
8769
- }
8770
- },
8771
- "tool_instructions": "Deprecated: prefer list_files, which lists the same files by path, needs no resource_id, and also sees this conversation's attachments. Still works \u2014 each row carries a `path`; pass that path to read_file to retrieve the file's content for AI analysis. `file_id` is also returned and still accepted."
8772
- },
8773
8697
  "get_tool_schema": {
8774
8698
  "tool_config": {
8775
8699
  "name": "get_tool_schema",
@@ -9117,21 +9041,6 @@ var init_chunk_UFYIBL66 = __esm({
9117
9041
  { tool_native_id: "nt-013", tool_name: "read_skill", tool_display_name: "Read Skill", tool_description: "Read the full specification of a skill", connector_id: WAYAI_CONNECTOR, operation: "read_skill", tool_method: "internal", tool_group: "Native Tools", is_delegation: false, is_auto_set: false, execution_config: null, side_effects: false, replay: "rerun", hosted: false },
9118
9042
  { tool_native_id: "nt-014", tool_name: "read_skill_file", tool_display_name: "Read Skill File", tool_description: "Read a specific file within a skill", connector_id: WAYAI_CONNECTOR, operation: "read_skill_file", tool_method: "internal", tool_group: "Native Tools", is_delegation: false, is_auto_set: false, execution_config: null, side_effects: false, replay: "rerun", hosted: false },
9119
9043
  { tool_native_id: "nt-015", tool_name: "read_file", tool_display_name: "Read File", tool_description: "Read the contents of a resource file", connector_id: WAYAI_CONNECTOR, operation: "read_file", tool_method: "internal", tool_group: "Native Tools", is_delegation: false, is_auto_set: false, execution_config: null, side_effects: false, replay: "rerun", hosted: false },
9120
- // Superseded by `list_files` (nt-027), which browses the same resource files
9121
- // by PATH plus this conversation's attachments.
9122
- //
9123
- // `ui_assignable: false` — DEPRECATED, not withdrawn. Hiding the Add grid entry
9124
- // stops a NEW agent from being wired to a tool that addresses files by an id a
9125
- // publish re-mints and that cannot see a conversation attachment at all (the id
9126
- // itself is discoverable — `RESOURCE_TOOL_INJECTIONS` still writes the linked
9127
- // ids into their `resource_id` description every turn), while every hub that
9128
- // already assigns one keeps
9129
- // working: the handler still dispatches, CI name resolution still resolves the
9130
- // name, and `wayai pull` / `push` still round-trips the YAML. There is no
9131
- // auto-provisioning anywhere in the platform, so an existing agent is never
9132
- // migrated for free — an author swaps the tool deliberately.
9133
- { tool_native_id: "nt-016", tool_name: "list_resource_files", tool_display_name: "List Resource Files", tool_description: "(deprecated \u2014 use list_files) List files in a resource folder", connector_id: WAYAI_CONNECTOR, operation: "list_resource_files", tool_method: "internal", tool_group: "Native Tools", is_delegation: false, is_auto_set: false, execution_config: null, side_effects: false, replay: "rerun", hosted: false, ui_assignable: false },
9134
- { tool_native_id: "nt-017", tool_name: "list_resource_folders", tool_display_name: "List Resource Folders", tool_description: "(deprecated \u2014 use list_files) List all resource folders", connector_id: WAYAI_CONNECTOR, operation: "list_resource_folders", tool_method: "internal", tool_group: "Native Tools", is_delegation: false, is_auto_set: false, execution_config: null, side_effects: false, replay: "rerun", hosted: false, ui_assignable: false },
9135
9044
  { tool_native_id: "nt-018", tool_name: "get_conversations_summary", tool_display_name: "Get Conversations Summary", tool_description: "Get a summary of recent conversations", connector_id: WAYAI_CONNECTOR, operation: "get_conversations_summary", tool_method: "internal", tool_group: "Native Tools", is_delegation: false, is_auto_set: false, execution_config: null, side_effects: false, replay: "rerun", hosted: true },
9136
9045
  { tool_native_id: "nt-019", tool_name: "get_conversation", tool_display_name: "Get Conversation", tool_description: "Retrieve full conversation history", connector_id: WAYAI_CONNECTOR, operation: "get_conversation", tool_method: "internal", tool_group: "Native Tools", is_delegation: false, is_auto_set: false, execution_config: null, side_effects: false, replay: "rerun", hosted: true },
9137
9046
  { tool_native_id: "nt-020", tool_name: "get_tool_schema", tool_display_name: "Get Tool Schema", tool_description: "Retrieve the JSON schema for a tool", connector_id: WAYAI_CONNECTOR, operation: "get_tool_schema", tool_method: "internal", tool_group: "Native Tools", is_delegation: false, is_auto_set: false, execution_config: null, side_effects: false, replay: "rerun", hosted: false },
@@ -9162,8 +9071,9 @@ var init_chunk_UFYIBL66 = __esm({
9162
9071
  // live button that only ever errors is worse than no button. Assign via `wayai push`
9163
9072
  // until the picker ships.
9164
9073
  { tool_native_id: "nt-026", tool_name: "start_consult_thread", tool_display_name: "Start Consult Thread", tool_description: "Ask a configured consultant (or partner hub) a question in a visible consult thread", connector_id: WAYAI_CONNECTOR, operation: "start_consult_thread", tool_method: "internal", tool_group: "Native Tools", is_delegation: true, is_auto_set: false, execution_config: null, side_effects: true, replay: "keyed", hosted: false, ui_assignable: false },
9165
- // One drill-down listing for every file namespace, replacing `list_resource_files`
9166
- // (nt-016) and `list_resource_folders` (nt-017). Fully visible: it needs no
9074
+ // One drill-down listing for every file namespace, which replaced `list_resource_files`
9075
+ // (nt-016) and `list_resource_folders` (nt-017), both retired with knowledge (HubDO v105,
9076
+ // #5142 step 5 C1; ids never reused). Fully visible: it needs no
9167
9077
  // configuration the Add dialog cannot collect — the mounts an agent may browse
9168
9078
  // come from its existing resource links and its own conversation, and the only
9169
9079
  // model-supplied input is a path.
@@ -9246,7 +9156,16 @@ var init_chunk_IBL7FANV = __esm({
9246
9156
  }
9247
9157
  });
9248
9158
 
9249
- // ../../packages/core/dist/chunk-Z22T2ASG.js
9159
+ // ../../packages/core/dist/chunk-C2UEA2KW.js
9160
+ var FLAG_CONDITION_OPERATORS;
9161
+ var init_chunk_C2UEA2KW = __esm({
9162
+ "../../packages/core/dist/chunk-C2UEA2KW.js"() {
9163
+ "use strict";
9164
+ FLAG_CONDITION_OPERATORS = ["=", "!=", ">=", "<=", ">", "<"];
9165
+ }
9166
+ });
9167
+
9168
+ // ../../packages/core/dist/chunk-D4AWK26E.js
9250
9169
  function parseExpr(expr) {
9251
9170
  const fnMatch = expr.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\s*\((.*?)\)\s*(?:\.(.*))?$/);
9252
9171
  if (!fnMatch) return null;
@@ -9273,87 +9192,36 @@ function stripQuotes(s) {
9273
9192
  }
9274
9193
  return s;
9275
9194
  }
9276
- function parseCatalogArgs(args2) {
9277
- let kind = null;
9278
- let tree = false;
9279
- for (const token of args2) {
9280
- if (token === "tree") tree = true;
9281
- else if ((token === "kb" || token === "skill") && kind === null) kind = token;
9282
- }
9283
- return { kind, tree };
9284
- }
9285
- function widenKinds(kinds) {
9286
- if (kinds.has("all") || kinds.size > 1) return "all";
9287
- return [...kinds][0] ?? null;
9288
- }
9289
9195
  function* parseCalls(template) {
9290
9196
  for (const match of template.matchAll(PLACEHOLDER_RE)) {
9291
9197
  const parsed = parseExpr(match[1].trim());
9292
9198
  if (parsed) yield parsed;
9293
9199
  }
9294
9200
  }
9295
- function scanTemplateResources(template) {
9296
- if (!template || !template.includes("{{")) return EMPTY_SCAN;
9297
- const scan = { ...EMPTY_SCAN };
9298
- const names = /* @__PURE__ */ new Set();
9299
- const paths = /* @__PURE__ */ new Set();
9300
- const treeKinds = /* @__PURE__ */ new Set();
9301
- const legacyKinds = /* @__PURE__ */ new Set();
9201
+ function countResourcePlaceholders(template) {
9202
+ const calls = {
9203
+ catalog: { kb: 0, skill: 0, all: 0 },
9204
+ file_content_paths: [],
9205
+ resource_content_names: []
9206
+ };
9207
+ if (!template || !template.includes("{{")) return calls;
9302
9208
  for (const { fn, args: args2 } of parseCalls(template)) {
9303
- switch (fn) {
9304
- case CATALOG_FN:
9305
- case LEGACY_CATALOG_FN: {
9306
- scan.needs_catalog = true;
9307
- scan.has_catalog_call = true;
9308
- const { kind, tree } = parseCatalogArgs(args2);
9309
- if (fn === LEGACY_CATALOG_FN) legacyKinds.add(kind ?? "all");
9310
- if (tree) treeKinds.add(kind ?? "all");
9311
- break;
9312
- }
9313
- case "agent_skills":
9314
- scan.needs_catalog = true;
9315
- break;
9316
- case "resource_content":
9317
- if (args2[0]) names.add(args2[0]);
9318
- break;
9319
- case "file_content":
9320
- if (args2[0]) paths.add(args2[0]);
9321
- break;
9322
- default:
9323
- break;
9324
- }
9209
+ if (fn === CATALOG_FN || fn === RETIRED_CATALOG_FN) {
9210
+ const kind = args2.find((token) => token === "kb" || token === "skill");
9211
+ calls.catalog[kind ?? "all"] += 1;
9212
+ } else if (fn === "file_content" && args2[0]) calls.file_content_paths.push(args2[0]);
9213
+ else if (fn === "resource_content" && args2[0]) calls.resource_content_names.push(args2[0]);
9325
9214
  }
9326
- scan.tree_kinds = widenKinds(treeKinds);
9327
- scan.legacy_kinds = widenKinds(legacyKinds);
9328
- scan.resource_content_names = [...names];
9329
- scan.file_content_paths = [...paths];
9330
- return scan;
9215
+ return calls;
9331
9216
  }
9332
- var PREVIOUS_CONVERSATIONS_MAX, PLACEHOLDER_RE, CATALOG_FN, LEGACY_CATALOG_FN, EMPTY_SCAN;
9333
- var init_chunk_Z22T2ASG = __esm({
9334
- "../../packages/core/dist/chunk-Z22T2ASG.js"() {
9217
+ var PREVIOUS_CONVERSATIONS_MAX, PLACEHOLDER_RE, CATALOG_FN, RETIRED_CATALOG_FN;
9218
+ var init_chunk_D4AWK26E = __esm({
9219
+ "../../packages/core/dist/chunk-D4AWK26E.js"() {
9335
9220
  "use strict";
9336
9221
  PREVIOUS_CONVERSATIONS_MAX = 20;
9337
9222
  PLACEHOLDER_RE = /\{\{\s*([^{}]+?)\s*\}\}/g;
9338
9223
  CATALOG_FN = "files";
9339
- LEGACY_CATALOG_FN = "resources";
9340
- EMPTY_SCAN = {
9341
- needs_catalog: false,
9342
- has_catalog_call: false,
9343
- legacy_kinds: null,
9344
- tree_kinds: null,
9345
- resource_content_names: [],
9346
- file_content_paths: []
9347
- };
9348
- }
9349
- });
9350
-
9351
- // ../../packages/core/dist/chunk-C2UEA2KW.js
9352
- var FLAG_CONDITION_OPERATORS;
9353
- var init_chunk_C2UEA2KW = __esm({
9354
- "../../packages/core/dist/chunk-C2UEA2KW.js"() {
9355
- "use strict";
9356
- FLAG_CONDITION_OPERATORS = ["=", "!=", ">=", "<=", ">", "<"];
9224
+ RETIRED_CATALOG_FN = "resources";
9357
9225
  }
9358
9226
  });
9359
9227
 
@@ -9535,7 +9403,7 @@ var init_chunk_T7KQKDET = __esm({
9535
9403
  }
9536
9404
  });
9537
9405
 
9538
- // ../../packages/core/dist/chunk-2LZYS6YX.js
9406
+ // ../../packages/core/dist/chunk-BV6U4HXF.js
9539
9407
  function resolveMonitorTrigger(monitorConfig) {
9540
9408
  if (!monitorConfig || typeof monitorConfig !== "object") return "idle";
9541
9409
  const raw = monitorConfig.trigger;
@@ -9841,14 +9709,14 @@ function refineMonitorRulesStructuredOutput(body, ctx) {
9841
9709
  if (refusal2) ctx.addIssue({ code: external_exports.ZodIssueCode.custom, path: ["response_format"], message: refusal2 });
9842
9710
  }
9843
9711
  var NATIVE_TOOL_NAMES, previousConversationsCountField, summarizationThresholdField, flagConditionSchema, MONITOR_TRIGGERS, monitorTriggerSchema, AUTOMATION_GATE_TRIGGERS, NON_FIRING_TRIGGERS, MONITOR_FIRING_TRIGGERS, MONITOR_DELAY_SECONDS_MIN, MONITOR_IDLE_DELAY_REQUIRED_MESSAGE, MONITOR_HISTORY_MESSAGES_MAX, monitorHistoryMessagesSchema, monitorIncludeToolResultsSchema, MONITOR_INPUT_SHAPING_KEYS, MONITOR_INPUT_SHAPING_SCHEMAS, MONITOR_INPUT_SHAPING_IDLE_MESSAGE, monitorArgumentSourceSchema, MONITOR_NOTE_TEMPLATE_MAX, MONITOR_STEER_NOTE_MAX, MONITOR_GATE_AGENT_NAME_MAX, monitorActionSchema, monitorRuleSchema, MONITOR_RULE_KEYS, MONITOR_RULE_SCHEMAS, MONITOR_RULE_TRIGGERS, MONITOR_RULE_TRIGGER_MESSAGE, CALL_UTTERANCE_SPEAKERS, callUtteranceSpeakerSchema, MONITOR_CALL_KEYS, MONITOR_CALL_SCHEMAS, MONITOR_CALL_KEY_MESSAGE, CALL_STEERING_MIN_CONFIDENCE, CALL_UTTERANCE_RULE_NOT_CONFIDENT_MESSAGE, CALL_UTTERANCE_FALLBACK_MESSAGE, CALL_UTTERANCE_FLAG_CONDITIONS_MESSAGE, CALL_STEER_NOTE_BLANK_MESSAGE, MONITOR_USER_MESSAGE_ACTION_KINDS, MONITOR_ASSISTANT_REPLY_ACTION_KINDS, MONITOR_CALL_UTTERANCE_ACTION_KINDS, MONITOR_AUTOMATION_FIRE_ACTION_KINDS, MONITOR_AUTOMATION_ITEM_ACTION_KINDS, INSERT_NOTE_TOOL_NAME, RUN_MONITOR_TOOL_NAME, MONITOR_RULE_ALLOWED_NATIVE_TOOLS, MONITOR_RULE_REENTRY_TOOLS, MONITOR_RULE_REENTRY_TRACKS, AUTOMATION_FIRE_FLAG_CONDITIONS_MESSAGE, AUTOMATION_FIRE_INPUT_SHAPING_MESSAGE, AUTOMATION_ITEM_FLAG_CONDITIONS_MESSAGE, AUTOMATION_ITEM_INPUT_SHAPING_MESSAGE, AUTOMATION_GATE_KEY_MESSAGES, monitorConfigField, flagConditionsField, agentIdParam, listAgentsQuery, agentConnectionsQuery, createAgentBody, updateAgentBody, AGENT_PARAMETER_TYPES, AGENT_PARAMETER_NAME_REGEX, agentParameterCreateSchema, MAX_AGENT_PARAMETERS_PER_REQUEST, createAgentParametersBody;
9844
- var init_chunk_2LZYS6YX = __esm({
9845
- "../../packages/core/dist/chunk-2LZYS6YX.js"() {
9712
+ var init_chunk_BV6U4HXF = __esm({
9713
+ "../../packages/core/dist/chunk-BV6U4HXF.js"() {
9846
9714
  "use strict";
9847
- init_chunk_UFYIBL66();
9715
+ init_chunk_GWMNV3N4();
9848
9716
  init_chunk_IBL7FANV();
9849
- init_chunk_Z22T2ASG();
9850
9717
  init_chunk_HZ6CADSY();
9851
9718
  init_chunk_C2UEA2KW();
9719
+ init_chunk_D4AWK26E();
9852
9720
  init_chunk_DHPUPI4Y();
9853
9721
  init_chunk_T7KQKDET();
9854
9722
  init_chunk_L5F7ZOUJ();
@@ -10067,12 +9935,12 @@ var init_chunk_2LZYS6YX = __esm({
10067
9935
  }
10068
9936
  });
10069
9937
 
10070
- // ../../packages/core/dist/chunk-XR36MYEY.js
9938
+ // ../../packages/core/dist/chunk-MUG3LWPZ.js
10071
9939
  var conversationIdParam, conversationHubQuery, claimBody, releaseBody, transferBody, closeBody, additionalContextPayloadSchema, kanbanUpdateBody, annotateConversationBody, observabilityParams, observabilityListParams, deleteUserConversationsBody, deleteUserConversationsResponse, sendMessageBody, listConversationsQuery, flagSourceSchema, getConversationsResponse, getConversationDetailParams, getConversationDetailQuery, getConversationDetailResponse, listWhatsAppTemplatesQuery, sendWhatsAppTemplateBody;
10072
- var init_chunk_XR36MYEY = __esm({
10073
- "../../packages/core/dist/chunk-XR36MYEY.js"() {
9940
+ var init_chunk_MUG3LWPZ = __esm({
9941
+ "../../packages/core/dist/chunk-MUG3LWPZ.js"() {
10074
9942
  "use strict";
10075
- init_chunk_2LZYS6YX();
9943
+ init_chunk_BV6U4HXF();
10076
9944
  init_chunk_HZ6CADSY();
10077
9945
  init_chunk_DHPUPI4Y();
10078
9946
  init_zod();
@@ -10528,7 +10396,7 @@ var init_chunk_BPCNB5RT = __esm({
10528
10396
  }
10529
10397
  });
10530
10398
 
10531
- // ../../packages/core/dist/chunk-MCSEEMGN.js
10399
+ // ../../packages/core/dist/chunk-HWB3MFZT.js
10532
10400
  function idempotencyHeaderRefusal(value) {
10533
10401
  if (typeof value !== "string" || !/^[A-Za-z0-9][A-Za-z0-9-]{0,63}$/.test(value)) {
10534
10402
  return "idempotency_header must be a header name: letters, digits and dashes, at most 64";
@@ -10539,10 +10407,10 @@ function idempotencyHeaderRefusal(value) {
10539
10407
  return null;
10540
10408
  }
10541
10409
  var CATALOG_REPLAY, REPLAY_OVERRIDES, RESERVED_HEADERS;
10542
- var init_chunk_MCSEEMGN = __esm({
10543
- "../../packages/core/dist/chunk-MCSEEMGN.js"() {
10410
+ var init_chunk_HWB3MFZT = __esm({
10411
+ "../../packages/core/dist/chunk-HWB3MFZT.js"() {
10544
10412
  "use strict";
10545
- init_chunk_UFYIBL66();
10413
+ init_chunk_GWMNV3N4();
10546
10414
  CATALOG_REPLAY = new Map(
10547
10415
  NATIVE_TOOLS.map((tool) => [tool.tool_name, tool.replay])
10548
10416
  );
@@ -10775,7 +10643,7 @@ var init_chunk_WEXVYJ5H = __esm({
10775
10643
  }
10776
10644
  });
10777
10645
 
10778
- // ../../packages/core/dist/chunk-4S4FBSBE.js
10646
+ // ../../packages/core/dist/chunk-VHQED53I.js
10779
10647
  function refineToolConfig(value, ctx) {
10780
10648
  const raw = value.tool_config;
10781
10649
  if (raw == null) return;
@@ -10811,10 +10679,10 @@ function refineToolConfig(value, ctx) {
10811
10679
  }
10812
10680
  }
10813
10681
  var toolIdParam, listToolsQuery, toolAgentQuery, deleteToolQuery, toolConnectionsQuery, nativeToolIdSchema, CONTEXT_BOUNDARIES, contextBoundarySchema, addNativeToolBody, addMcpToolBody, toolReplaySettingsFields, toolReplaySettingsSchema, createCustomToolBody, updateCustomToolBody, updateToolExecutionConfigBody;
10814
- var init_chunk_4S4FBSBE = __esm({
10815
- "../../packages/core/dist/chunk-4S4FBSBE.js"() {
10682
+ var init_chunk_VHQED53I = __esm({
10683
+ "../../packages/core/dist/chunk-VHQED53I.js"() {
10816
10684
  "use strict";
10817
- init_chunk_MCSEEMGN();
10685
+ init_chunk_HWB3MFZT();
10818
10686
  init_chunk_WEXVYJ5H();
10819
10687
  init_chunk_HZ6CADSY();
10820
10688
  init_zod();
@@ -10836,11 +10704,9 @@ var init_chunk_4S4FBSBE = __esm({
10836
10704
  /** Only meaningful for a `hub` delegation (`delegate_to_hub`); ignored otherwise.
10837
10705
  * Defaults to `summary` when omitted. Admin-set — the link and boundary require
10838
10706
  * hub-admin (`hub:write`), never derived from any end user's grants. */
10839
- delegation_context_boundary: contextBoundarySchema.optional(),
10840
- resource_config: external_exports.object({
10841
- access_mode: external_exports.enum(["all", "selected", "none"]),
10842
- enabled_resources: external_exports.array(external_exports.string()).optional()
10843
- }).optional()
10707
+ delegation_context_boundary: contextBoundarySchema.optional()
10708
+ // `resource_config` was retired with knowledge (wayai-pro/wayai#5142 step 5 C1): written and never
10709
+ // read. A body that still sends it is accepted, the key stripped; the column goes at step 5's E.
10844
10710
  });
10845
10711
  addMcpToolBody = external_exports.object({
10846
10712
  agent_id: uuidSchema,
@@ -10885,7 +10751,7 @@ var init_chunk_4LXDRTO4 = __esm({
10885
10751
  }
10886
10752
  });
10887
10753
 
10888
- // ../../packages/core/dist/chunk-6Y7XMRWF.js
10754
+ // ../../packages/core/dist/chunk-2FQVW3O7.js
10889
10755
  function isIanaTimezone(timezone) {
10890
10756
  try {
10891
10757
  new Intl.DateTimeFormat("en-US", { timeZone: timezone }).format(0);
@@ -10895,12 +10761,12 @@ function isIanaTimezone(timezone) {
10895
10761
  }
10896
10762
  }
10897
10763
  var evalDateContextSchema;
10898
- var init_chunk_6Y7XMRWF = __esm({
10899
- "../../packages/core/dist/chunk-6Y7XMRWF.js"() {
10764
+ var init_chunk_2FQVW3O7 = __esm({
10765
+ "../../packages/core/dist/chunk-2FQVW3O7.js"() {
10900
10766
  "use strict";
10901
- init_chunk_Z22T2ASG();
10902
10767
  init_chunk_HZ6CADSY();
10903
10768
  init_chunk_MIWZOSPI();
10769
+ init_chunk_D4AWK26E();
10904
10770
  init_chunk_DHPUPI4Y();
10905
10771
  init_zod();
10906
10772
  evalDateContextSchema = external_exports.object({
@@ -10925,7 +10791,7 @@ var init_chunk_2ISUBJG7 = __esm({
10925
10791
  }
10926
10792
  });
10927
10793
 
10928
- // ../../packages/core/dist/chunk-RCTKQTJH.js
10794
+ // ../../packages/core/dist/chunk-TY6K2EWO.js
10929
10795
  function describeRole(role) {
10930
10796
  if (typeof role === "string") {
10931
10797
  return JSON.stringify(role.length > ROLE_ECHO_MAX ? `${role.slice(0, ROLE_ECHO_MAX)}\u2026` : role);
@@ -11099,11 +10965,11 @@ function terminalRunCount(counts) {
11099
10965
  return counts.successful_runs + counts.failed_runs;
11100
10966
  }
11101
10967
  var evalIdParam, sessionIdParam, scenarioSetIdParam, hubIdQuery, EVAL_FIXTURE_NAME_MAX_LENGTH, evalFixtureOverrideSchema, runSessionQuery, runJourneyQuery, EVAL_INPUT_ROLES, EVAL_INPUT_ROLE_LIST, ROLE_ECHO_MAX, EVAL_INITIAL_STATE_SCOPES, MAX_INITIAL_STATE_ENTRIES, evalInitialStateEntry, evalCustomerContactIdSchema, evalBody, EVAL_LIST_MAX_LIMIT, evalListLimit, getEvalsQuery, toggleEvalBody, bulkToggleEvalsBody, pacingConfigSchema, EVAL_MAX_SELECTED_SCENARIOS, evalScenarioSelectionEntrySchema, evalScenarioSelectionSchema, sessionConfigSchema, createSessionBody, getSessionsQuery, getSessionResultsQuery, getSessionRunsQuery, evalAnalyticsQuery, getSessionCostQuery, compareSessionsQuery, evalsSqlBody, evalsSqlSchemaQuery, exportResultsQuery, validateEvalBody, hubAgentsQuery, createScenarioSetBody, updateScenarioSetBody, scenarioSetsHubQuery, createScenarioFromConversationBody, createJourneyFromConversationBody, evalAttachmentRef, turnMayCarryAttachments, ATTACHMENTS_USER_ONLY_MESSAGE, journeyIdParam, journeyToolCallSchema, journeyTurnSchema, journeyStepOverrideSchema, fixtureField, createJourneyBody, updateJourneyBody, evalSessionConfigResponseSchema, evalSessionResponseSchema, evalSessionListConfigSchema, evalSessionListItemSchema, seedReleaseStatusSchema, EVAL_SESSION_NOT_QUIESCENT;
11102
- var init_chunk_RCTKQTJH = __esm({
11103
- "../../packages/core/dist/chunk-RCTKQTJH.js"() {
10968
+ var init_chunk_TY6K2EWO = __esm({
10969
+ "../../packages/core/dist/chunk-TY6K2EWO.js"() {
11104
10970
  "use strict";
11105
10971
  init_chunk_4LXDRTO4();
11106
- init_chunk_6Y7XMRWF();
10972
+ init_chunk_2FQVW3O7();
11107
10973
  init_chunk_HZ6CADSY();
11108
10974
  init_chunk_2ISUBJG7();
11109
10975
  init_zod();
@@ -12186,7 +12052,7 @@ var init_chunk_6NI5RAM4 = __esm({
12186
12052
  }
12187
12053
  });
12188
12054
 
12189
- // ../../packages/core/dist/chunk-FJ5K57CB.js
12055
+ // ../../packages/core/dist/chunk-EYZBTMVU.js
12190
12056
  function refineHubAsCodeCustomTools(config, ctx) {
12191
12057
  const agents = config.agents;
12192
12058
  if (!Array.isArray(agents)) return;
@@ -12722,12 +12588,12 @@ function refineHubAsCodeMonitorRulesOutput(config, ctx) {
12722
12588
  });
12723
12589
  }
12724
12590
  var MAX_10MB_BASE64_ENCODED_BYTES, MAX_EVAL_ATTACHMENT_ENCODED_BYTES, MAX_EVAL_ATTACHMENT_CARRIERS, MAX_EVAL_ATTACHMENT_AGGREGATE_ENCODED_BYTES, MAX_RESOURCE_ENCODED_BYTES, MAX_HUB_AS_CODE_RESOURCES, MAX_HUB_AS_CODE_RESOURCE_FILES, MAX_RESOURCE_AGGREGATE_ENCODED_BYTES, MAX_CI_CONFIG_BODY_BYTES, MAX_CALL_OPENING_CARRIERS, MAX_CALL_OPENING_AGGREGATE_ENCODED_BYTES, hubAsCodeStateSchema, hubAsCodeResourceFileSchema, hubAsCodeResourceSchema, uuidPattern, ciUuidSchema, boundedHubAsCodeResourcesSchema, hubAsCodeConfigSchema, ciPullHubIdParam, ciBranchParam, ciPullQuery, ciHubsQuery, ciLookupQuery, ciBranchesQuery, ciSyncBody, ciPushBody, ciDiffBody, ciPublishBody, ciPublishPreviewBody, ciSyncMcpBody, ciOrgResourcesParam, orgResourcesConfigSchema, ciOrgResourcesPushBody, ciOrgResourcesDiffBody, CI_APPLY_ENTITY_KINDS, CI_APPLY_OPERATIONS, ciApplyErrorBaseSchema, ciApplyErrorSchema, ciSyncCountSchema, ciSyncChangesSchema, ciSyncWarningSchema, ciSyncResponseSchema;
12725
- var init_chunk_FJ5K57CB = __esm({
12726
- "../../packages/core/dist/chunk-FJ5K57CB.js"() {
12591
+ var init_chunk_EYZBTMVU = __esm({
12592
+ "../../packages/core/dist/chunk-EYZBTMVU.js"() {
12727
12593
  "use strict";
12728
- init_chunk_4S4FBSBE();
12729
- init_chunk_RCTKQTJH();
12730
- init_chunk_2LZYS6YX();
12594
+ init_chunk_VHQED53I();
12595
+ init_chunk_TY6K2EWO();
12596
+ init_chunk_BV6U4HXF();
12731
12597
  init_chunk_LBDH7LCG();
12732
12598
  init_chunk_4LXDRTO4();
12733
12599
  init_chunk_T4Q5COKJ();
@@ -13737,13 +13603,13 @@ var init_chunk_LQY2OCQL = __esm({
13737
13603
  }
13738
13604
  });
13739
13605
 
13740
- // ../../packages/core/dist/chunk-EA6XOOL2.js
13606
+ // ../../packages/core/dist/chunk-H6TTCXPL.js
13741
13607
  var AUTOMATION_TRIGGER_TYPES, AUTOMATION_EVENT_TYPES, AUTOMATION_TARGET_TYPES, AUTOMATION_ACTION_TYPES, AUTOMATION_CHANNEL_TYPES, AUTOMATION_PURPOSES, AUTOMATION_NAME_MAX, AUTOMATION_DESCRIPTION_MAX, AUTOMATION_INSTRUCTIONS_MAX, AUTOMATION_TEXT_MAX, AUTOMATION_CRON_MAX, AUTOMATION_WEBHOOK_AUTHS, AUTOMATION_WEBHOOK_HEADERS, AUTOMATION_WEBHOOK_BODY_MAX_BYTES, AUTOMATION_WEBHOOK_HEADER_NAME_MAX, WEBHOOK_RESERVED_HEADERS, automationTriggerSchema, automationTargetSchema, automationActionSchema, automationGateSchema, automationName, automationDescription, automationIdParam, automationHubQuery, automationWebhookParams, AUTOMATION_RUNS_PAGE_MAX, listAutomationRunsQuery, createAutomationBody, updateAutomationBody, AUTOMATION_ALERT_CATEGORIES, AUTOMATION_BLOCKED_ALERT_CATEGORY, automationEventSubscriberParam;
13742
- var init_chunk_EA6XOOL2 = __esm({
13743
- "../../packages/core/dist/chunk-EA6XOOL2.js"() {
13608
+ var init_chunk_H6TTCXPL = __esm({
13609
+ "../../packages/core/dist/chunk-H6TTCXPL.js"() {
13744
13610
  "use strict";
13745
13611
  init_chunk_LQY2OCQL();
13746
- init_chunk_2LZYS6YX();
13612
+ init_chunk_BV6U4HXF();
13747
13613
  init_chunk_3HSB6J4J();
13748
13614
  init_chunk_5XEJSR22();
13749
13615
  init_chunk_DHPUPI4Y();
@@ -14269,7 +14135,7 @@ var init_chunk_OMPT4ZHR = __esm({
14269
14135
  }
14270
14136
  });
14271
14137
 
14272
- // ../../packages/core/dist/chunk-3ACHWKFV.js
14138
+ // ../../packages/core/dist/chunk-RUFVP7Q3.js
14273
14139
  function refineScopedTarget(data, ctx) {
14274
14140
  if (data.scope === "org") {
14275
14141
  if (!data.org_id) {
@@ -14294,9 +14160,9 @@ function refineScopedTarget(data, ctx) {
14294
14160
  }
14295
14161
  }
14296
14162
  }
14297
- var adminOrgIdParam, adminOrgAdminIdParam, adminUserIdParam, PRICING_PLAN_ID_RE, adminPlanIdParam, adminOrganizationsQuery, adminUserSearchQuery, kanbanSlugMigrationQuery, adjustQuotaBody, updatePlanBody, addAdminUserBody, MAX_VOICE_CALL_MINUTE_OPS, voiceCallMinuteOps, AUTOMATION_GATE_EVALUATIONS_PER_OPERATION_BOUND, automationGateEvaluationsPerOperation, AUTOMATION_RUN_RETENTION_DAYS_MAX, automationRunRetentionDays, turnDeadlineSeconds, updatePlatformConfigBody, updateFreeOrgLimitBody, adminScopedTargetShape, adminScopedTargetBody, BRANCHING_ORPHAN_ENTITY_TYPES, BRANCHING_ORPHAN_MAX_TARGETS, adminRepairBranchingOrphansBody, adminRepairLegacyOrgGrantsBody, adminRepairCompedPlansBody, updatePricingPlanBody, dataExplorerSearchQuery, dataExplorerOrgIdParam, dataExplorerHubIdParam, dataExplorerConvIdParam, dataExplorerDoInstancesQuery, dataExplorerNsIdParam, dataExplorerKvKeysBody, dataExplorerKvKeyBody, uuidOrHexId, dataExplorerDeleteOrgParam, dataExplorerDeleteHubParam, dataExplorerDeleteConvParam, dataExplorerDeleteUserParam, dataExplorerDeleteQuery, dataExplorerKvDeleteBody, pitrDoNamespace, pitrBookmarkParam, pitrRestoreBody, healthSamplingTriggerBody, DEBUG_DO_HEX_PREFIX, debugDoEntityId, debugTableName, dataExplorerDebugTablesParam, dataExplorerDebugRowsParam, dataExplorerDebugRowsQuery, dataExplorerDebugAnalyticsTable, debugUuid, dataExplorerDebugAnalyticsRowsParam, dataExplorerDebugAnalyticsRowsQuery, dataExplorerDebugCountsDoType, dataExplorerDebugCountsParam, debugHubConvParam, debugMessageIdQuery;
14298
- var init_chunk_3ACHWKFV = __esm({
14299
- "../../packages/core/dist/chunk-3ACHWKFV.js"() {
14163
+ var adminOrgIdParam, adminOrgAdminIdParam, adminUserIdParam, PRICING_PLAN_ID_RE, adminPlanIdParam, adminOrganizationsQuery, adminUserSearchQuery, kanbanSlugMigrationQuery, adjustQuotaBody, updatePlanBody, addAdminUserBody, MAX_VOICE_CALL_MINUTE_OPS, voiceCallMinuteOps, AUTOMATION_GATE_EVALUATIONS_PER_OPERATION_BOUND, automationGateEvaluationsPerOperation, AUTOMATION_RUN_RETENTION_DAYS_MAX, automationRunRetentionDays, turnDeadlineSeconds, updatePlatformConfigBody, updateFreeOrgLimitBody, adminScopedTargetShape, adminScopedTargetBody, adminRepairKnowledgeBlobsBody, BRANCHING_ORPHAN_ENTITY_TYPES, BRANCHING_ORPHAN_MAX_TARGETS, adminRepairBranchingOrphansBody, adminRepairLegacyOrgGrantsBody, adminRepairCompedPlansBody, updatePricingPlanBody, dataExplorerSearchQuery, dataExplorerOrgIdParam, dataExplorerHubIdParam, dataExplorerConvIdParam, dataExplorerDoInstancesQuery, dataExplorerNsIdParam, dataExplorerKvKeysBody, dataExplorerKvKeyBody, uuidOrHexId, dataExplorerDeleteOrgParam, dataExplorerDeleteHubParam, dataExplorerDeleteConvParam, dataExplorerDeleteUserParam, dataExplorerDeleteQuery, dataExplorerKvDeleteBody, pitrDoNamespace, pitrBookmarkParam, pitrRestoreBody, healthSamplingTriggerBody, DEBUG_DO_HEX_PREFIX, debugDoEntityId, debugTableName, dataExplorerDebugTablesParam, dataExplorerDebugRowsParam, dataExplorerDebugRowsQuery, dataExplorerDebugAnalyticsTable, debugUuid, dataExplorerDebugAnalyticsRowsParam, dataExplorerDebugAnalyticsRowsQuery, dataExplorerDebugCountsDoType, dataExplorerDebugCountsParam, debugHubConvParam, debugMessageIdQuery;
14164
+ var init_chunk_RUFVP7Q3 = __esm({
14165
+ "../../packages/core/dist/chunk-RUFVP7Q3.js"() {
14300
14166
  "use strict";
14301
14167
  init_chunk_FECLIZTY();
14302
14168
  init_chunk_BFG4ZWR4();
@@ -14463,6 +14329,7 @@ var init_chunk_3ACHWKFV = __esm({
14463
14329
  dry_run: external_exports.boolean().optional().default(false)
14464
14330
  });
14465
14331
  adminScopedTargetBody = adminScopedTargetShape.strict().superRefine(refineScopedTarget);
14332
+ adminRepairKnowledgeBlobsBody = adminScopedTargetShape.extend({ dry_run: external_exports.boolean().optional().default(true) }).strict().superRefine(refineScopedTarget);
14466
14333
  BRANCHING_ORPHAN_ENTITY_TYPES = [
14467
14334
  "agent",
14468
14335
  "agent_parameter",
@@ -14997,7 +14864,7 @@ var init_contracts = __esm({
14997
14864
  init_chunk_SXDX4GHS();
14998
14865
  init_chunk_HENF6YTF();
14999
14866
  init_chunk_VXEAR36B();
15000
- init_chunk_DYI3BRJ3();
14867
+ init_chunk_6VCHIFJT();
15001
14868
  init_chunk_Q7KIQHAZ();
15002
14869
  init_chunk_WBFLPPDI();
15003
14870
  init_chunk_IPXBFWUU();
@@ -15008,7 +14875,7 @@ var init_contracts = __esm({
15008
14875
  init_chunk_ZXK6N2HN();
15009
14876
  init_chunk_Y7CFCYX4();
15010
14877
  init_chunk_5DGHIY7L();
15011
- init_chunk_4QBKRQMM();
14878
+ init_chunk_4QU6WS7I();
15012
14879
  init_chunk_OWAAYKPB();
15013
14880
  init_chunk_BEOHBREG();
15014
14881
  init_chunk_IPDOHAZ5();
@@ -15024,13 +14891,13 @@ var init_contracts = __esm({
15024
14891
  init_chunk_LWMLR2WI();
15025
14892
  init_chunk_ACGAI25T();
15026
14893
  init_chunk_MH4O3YEX();
15027
- init_chunk_XR36MYEY();
14894
+ init_chunk_MUG3LWPZ();
15028
14895
  init_chunk_KSTYTQ7I();
15029
14896
  init_chunk_LKBSHANA();
15030
14897
  init_chunk_BPCNB5RT();
15031
- init_chunk_FJ5K57CB();
15032
- init_chunk_4S4FBSBE();
15033
- init_chunk_RCTKQTJH();
14898
+ init_chunk_EYZBTMVU();
14899
+ init_chunk_VHQED53I();
14900
+ init_chunk_TY6K2EWO();
15034
14901
  init_chunk_JDJ4EUOL();
15035
14902
  init_chunk_3KYTITOR();
15036
14903
  init_chunk_XCDUP42J();
@@ -15039,9 +14906,9 @@ var init_contracts = __esm({
15039
14906
  init_chunk_YULHXJ5M();
15040
14907
  init_chunk_V4FRPRH5();
15041
14908
  init_chunk_ZHJEQBXJ();
15042
- init_chunk_EA6XOOL2();
14909
+ init_chunk_H6TTCXPL();
15043
14910
  init_chunk_LQY2OCQL();
15044
- init_chunk_2LZYS6YX();
14911
+ init_chunk_BV6U4HXF();
15045
14912
  init_chunk_3HSB6J4J();
15046
14913
  init_chunk_IG6QBZMA();
15047
14914
  init_chunk_ZJJ5ODOD();
@@ -15051,10 +14918,10 @@ var init_contracts = __esm({
15051
14918
  init_chunk_E4DIIOOE();
15052
14919
  init_chunk_7CYHPF35();
15053
14920
  init_chunk_VMAX5YRT();
15054
- init_chunk_MCSEEMGN();
15055
- init_chunk_UFYIBL66();
14921
+ init_chunk_HWB3MFZT();
14922
+ init_chunk_GWMNV3N4();
15056
14923
  init_chunk_NVKU5PPQ();
15057
- init_chunk_3ACHWKFV();
14924
+ init_chunk_RUFVP7Q3();
15058
14925
  init_chunk_FECLIZTY();
15059
14926
  init_chunk_BFG4ZWR4();
15060
14927
  init_chunk_6QXCHNFQ();
@@ -15065,13 +14932,12 @@ var init_contracts = __esm({
15065
14932
  init_chunk_OMPT4ZHR();
15066
14933
  init_chunk_2PZIF56U();
15067
14934
  init_chunk_UEJOG2Q7();
15068
- init_chunk_KJXJKAYT();
14935
+ init_chunk_QUKTIJKE();
15069
14936
  init_chunk_SOJMWM63();
15070
14937
  init_chunk_WEXVYJ5H();
15071
- init_chunk_6Y7XMRWF();
14938
+ init_chunk_2FQVW3O7();
15072
14939
  init_chunk_5XEJSR22();
15073
14940
  init_chunk_IBL7FANV();
15074
- init_chunk_Z22T2ASG();
15075
14941
  init_chunk_VORPHGDT();
15076
14942
  init_chunk_A4JC7DXB();
15077
14943
  init_chunk_HZ6CADSY();
@@ -15079,6 +14945,7 @@ var init_contracts = __esm({
15079
14945
  init_chunk_2ISUBJG7();
15080
14946
  init_chunk_C2UEA2KW();
15081
14947
  init_chunk_6NI5RAM4();
14948
+ init_chunk_D4AWK26E();
15082
14949
  init_chunk_CJ3L46X6();
15083
14950
  init_chunk_6TSQ5HXC();
15084
14951
  init_chunk_DHPUPI4Y();
@@ -15224,6 +15091,11 @@ var init_api_client = __esm({
15224
15091
  async adminRepairTeamOrphans(body) {
15225
15092
  return this.request("POST", "/api/admin/hubs/repair-team-orphans", body);
15226
15093
  }
15094
+ // Report, or delete, the R2 objects retired hub knowledge left behind (#5142 step 5 C1).
15095
+ // Used by `wayai admin hubs repair-knowledge-blobs` (platform-admin gated).
15096
+ async adminRepairKnowledgeBlobs(body) {
15097
+ return this.request("POST", "/api/admin/hubs/repair-knowledge-blobs", body);
15098
+ }
15227
15099
  // Report twin candidates, or delete named production rows no preview maps (#4577).
15228
15100
  // Used by `wayai admin hubs repair-branching-orphans` (platform-admin gated).
15229
15101
  async adminRepairBranchingOrphans(body) {
@@ -16398,13 +16270,12 @@ var UUID_RE2, WAYAI_WORKSPACE_LAYOUT;
16398
16270
  var init_dist = __esm({
16399
16271
  "../../packages/core/dist/index.js"() {
16400
16272
  "use strict";
16401
- init_chunk_KJXJKAYT();
16273
+ init_chunk_QUKTIJKE();
16402
16274
  init_chunk_SOJMWM63();
16403
16275
  init_chunk_WEXVYJ5H();
16404
- init_chunk_6Y7XMRWF();
16276
+ init_chunk_2FQVW3O7();
16405
16277
  init_chunk_5XEJSR22();
16406
16278
  init_chunk_IBL7FANV();
16407
- init_chunk_Z22T2ASG();
16408
16279
  init_chunk_P3AWZG3N();
16409
16280
  init_chunk_VORPHGDT();
16410
16281
  init_chunk_A4JC7DXB();
@@ -16416,6 +16287,7 @@ var init_dist = __esm({
16416
16287
  init_chunk_RPGBR5IN();
16417
16288
  init_chunk_C2UEA2KW();
16418
16289
  init_chunk_6NI5RAM4();
16290
+ init_chunk_D4AWK26E();
16419
16291
  init_chunk_CJ3L46X6();
16420
16292
  init_chunk_6TSQ5HXC();
16421
16293
  init_chunk_DHPUPI4Y();
@@ -17822,6 +17694,7 @@ var init_utils = __esm({
17822
17694
  ["admin skill install", { positionals: 1 }],
17823
17695
  ["admin hubs repair-team-orphans", { positionals: 0, values: ["--org", "--hub"], dryRun: true }],
17824
17696
  ["admin hubs repair-branching-orphans", { positionals: 0, values: ["--org", "--hub", "--id"], dryRun: true }],
17697
+ ["admin hubs repair-knowledge-blobs", { positionals: 0, values: ["--org", "--hub"], dryRun: true }],
17825
17698
  ["admin orgs repair-legacy-grants", { positionals: 0, values: ["--org"], dryRun: true }],
17826
17699
  ["admin harness mass-destroy", { positionals: 0, values: ["--org", "--hub"], dryRun: true }],
17827
17700
  ["admin harness disable", { positionals: 0 }],
@@ -33826,6 +33699,7 @@ var init_resource_paths = __esm({
33826
33699
  "../../packages/core/dist/resource-paths.js"() {
33827
33700
  "use strict";
33828
33701
  init_chunk_6NI5RAM4();
33702
+ init_chunk_D4AWK26E();
33829
33703
  init_chunk_CJ3L46X6();
33830
33704
  init_chunk_6TSQ5HXC();
33831
33705
  RESOURCE_NAMESPACE = "resources";
@@ -35466,8 +35340,8 @@ var init_catalog = __esm({
35466
35340
  "../../packages/core/dist/catalog/index.js"() {
35467
35341
  "use strict";
35468
35342
  init_chunk_VMAX5YRT();
35469
- init_chunk_MCSEEMGN();
35470
- init_chunk_UFYIBL66();
35343
+ init_chunk_HWB3MFZT();
35344
+ init_chunk_GWMNV3N4();
35471
35345
  init_chunk_A4JC7DXB();
35472
35346
  init_chunk_MIWZOSPI();
35473
35347
  init_chunk_DHPUPI4Y();
@@ -35517,14 +35391,13 @@ function rewriteCitations(text, fileTypeBySlug) {
35517
35391
  }
35518
35392
  function knowledgePlaceholders(template, losing) {
35519
35393
  if (losing.length === 0 || !template.includes("{{")) return [];
35520
- const scan = scanTemplateResources(template);
35521
- const kinds = scanTemplateResources(template.replace(/\{\{(\s*)files(\s*\()/g, "{{$1resources$2")).legacy_kinds;
35394
+ const calls = countResourcePlaceholders(template);
35522
35395
  const uses = [];
35523
- if (kinds === "all" || kinds === "kb") uses.push("a {{files()}} catalog that lists knowledge");
35396
+ if (calls.catalog.all > 0 || calls.catalog.kb > 0) uses.push("a {{files()}} catalog that lists knowledge");
35524
35397
  const names = new Set(losing.map((r) => r.name));
35525
- for (const name of scan.resource_content_names) if (names.has(name)) uses.push(`{{resource_content(${name})}}`);
35398
+ for (const name of new Set(calls.resource_content_names)) if (names.has(name)) uses.push(`{{resource_content(${name})}}`);
35526
35399
  const slugs = new Set(losing.map((r) => r.slug));
35527
- for (const path42 of scan.file_content_paths) {
35400
+ for (const path42 of new Set(calls.file_content_paths)) {
35528
35401
  const [namespace, slug] = cleanRelativePath(path42).split("/");
35529
35402
  if (namespace?.toLowerCase() === RESOURCE_NAMESPACE && slug && slugs.has(slug.toLowerCase())) {
35530
35403
  uses.push(`{{file_content(${path42})}}`);
@@ -36318,6 +36191,9 @@ async function adminCommand(args2) {
36318
36191
  case "repair-branching-orphans":
36319
36192
  await runRepairBranchingOrphans(flagArgs);
36320
36193
  return;
36194
+ case "repair-knowledge-blobs":
36195
+ await runRepairKnowledgeBlobs(flagArgs);
36196
+ return;
36321
36197
  default:
36322
36198
  printHelp2();
36323
36199
  process.exit(1);
@@ -36827,6 +36703,64 @@ async function runRepairTeamOrphans(flagArgs) {
36827
36703
  console.log(`${d.hub_id} | ${d.dangling_team_ids.join(",")} | ${d.team_users_removed}`);
36828
36704
  }
36829
36705
  }
36706
+ async function runRepairKnowledgeBlobs(flagArgs) {
36707
+ const USAGE5 = "wayai admin hubs repair-knowledge-blobs --all | --org <org_id> | --hub <hub_id> [--apply] [--yes] [--json]";
36708
+ const apply = flagArgs.includes("--apply");
36709
+ const { body, targetLabel, dryRun, yes, jsonOutput } = parseScopedTargetFlags(
36710
+ flagArgs.filter((arg) => arg !== "--apply"),
36711
+ USAGE5
36712
+ );
36713
+ if (apply && dryRun) {
36714
+ console.error("--apply and --dry-run contradict each other: a run is a dry run unless --apply is given.");
36715
+ console.error(USAGE5);
36716
+ process.exit(1);
36717
+ }
36718
+ const input = { ...body, dry_run: !apply };
36719
+ if (apply && !yes && !jsonOutput) {
36720
+ console.log(`About to DELETE the R2 objects no file row holds in: ${targetLabel}.`);
36721
+ console.log("Run without --apply first to see what would go.");
36722
+ const ok = await confirm("Proceed?");
36723
+ if (!ok) {
36724
+ console.log("Aborted.");
36725
+ return;
36726
+ }
36727
+ }
36728
+ const { config, accessToken } = await requireAuth();
36729
+ const client = new ApiClient({ apiUrl: config.api_url, accessToken });
36730
+ let response;
36731
+ try {
36732
+ response = await client.adminRepairKnowledgeBlobs(input);
36733
+ } catch (err) {
36734
+ exitOnApiError(err);
36735
+ throw err;
36736
+ }
36737
+ const data = response.data;
36738
+ if (jsonOutput) {
36739
+ console.log(JSON.stringify(data, null, 2));
36740
+ return;
36741
+ }
36742
+ const mode = data.dry_run ? "DRY RUN \u2014 nothing deleted" : "deleted";
36743
+ console.log(
36744
+ `repair-knowledge-blobs (${data.scope}) \u2014 ${mode}: hubs_scanned=${data.hubs_scanned} keys_listed=${data.keys_listed} keys_unreferenced=${data.keys_unreferenced} keys_deleted=${data.keys_deleted}`
36745
+ );
36746
+ if (data.hubs_errored > 0 || data.orgs_errored > 0) {
36747
+ console.log(
36748
+ `WARNING: ${data.orgs_errored} org(s) errored and were skipped, and ${data.hubs_errored} hub(s) stopped part-way (their finished pages are counted below) \u2014 re-run to finish them.`
36749
+ );
36750
+ }
36751
+ if (data.details.length === 0) {
36752
+ console.log("(no unreferenced keys in scope)");
36753
+ return;
36754
+ }
36755
+ console.log("");
36756
+ console.log("hub_id | listed | unreferenced | too_recent | deleted");
36757
+ console.log("-------+--------+--------------+------------+--------");
36758
+ for (const d of data.details) {
36759
+ const stopped = d.errored ? " (stopped part-way: re-run to finish)" : "";
36760
+ console.log(`${d.hub_id} | ${d.keys_listed} | ${d.keys_unreferenced} | ${d.keys_too_recent} | ${d.keys_deleted}${stopped}`);
36761
+ for (const key of d.keys) console.log(` ${key}`);
36762
+ }
36763
+ }
36830
36764
  async function runRepairBranchingOrphans(flagArgs) {
36831
36765
  const USAGE5 = "wayai admin hubs repair-branching-orphans --all | --org <org_id> | --hub <hub_id> [--id <type>:<id> ...] [--dry-run] [--yes] [--json]";
36832
36766
  const targets = [];
@@ -37941,6 +37875,9 @@ Usage:
37941
37875
  wayai admin hubs repair-branching-orphans --all | --org <org_id> | --hub <hub_id> [--id <type>:<id> ...] [--dry-run] [--yes] [--json]
37942
37876
  Without --id: report unmapped production rows that duplicate a mapped one (#4577). With --id: delete exactly those rows of one production hub, each only if no live preview maps it and nothing references it
37943
37877
 
37878
+ wayai admin hubs repair-knowledge-blobs --all | --org <org_id> | --hub <hub_id> [--apply] [--yes] [--json]
37879
+ Report, or with --apply delete, the R2 objects under each hub no file row holds (retired knowledge's, #5142), older than a day; never eval attachments or call openings. A dry run by default. Run it once the deploy that retired knowledge is fully live: a hub on older code stops on its first page, as errored
37880
+
37944
37881
  wayai admin orgs repair-legacy-grants --all | --org <org_id> [--dry-run] [--yes] [--json]
37945
37882
  Repair org-admin roster rows keyed by email with a NULL user_email (pre-#3922 platform-admin adds): grant the real access they never conferred, or drop the phantom seat. Idempotent \u2014 run --dry-run first
37946
37883
 
@@ -38023,6 +37960,9 @@ Sources:
38023
37960
  diff sees them. It never picks rows itself \u2014 a deleted preview leaves live
38024
37961
  rows unmapped too \u2014 so without --id it only reports candidates, and with
38025
37962
  --id it deletes the named rows that pass its checks.
37963
+ \`repair-knowledge-blobs\` sweeps the R2 objects retired hub knowledge left
37964
+ behind once its rows were deleted: keys no file row holds, older than a
37965
+ day. It reports by default and deletes only with --apply.
38026
37966
  orgs Org roster repair. \`repair-legacy-grants\` fixes member_grant rows the
38027
37967
  platform-admin org-admin add wrote before #3922: the email landed in the
38028
37968
  user_id column with user_email NULL. Auth reads UserDO, never member_grant,
@@ -38085,6 +38025,8 @@ Examples:
38085
38025
  wayai admin observability <hub-id> <conv-id> --message-id <msg-id> --json
38086
38026
  wayai admin hubs repair-branching-orphans --hub <prod-hub-id>
38087
38027
  wayai admin hubs repair-branching-orphans --hub <prod-hub-id> --id connection:<id> --dry-run
38028
+ wayai admin hubs repair-knowledge-blobs --all
38029
+ wayai admin hubs repair-knowledge-blobs --hub <hub-id> --apply
38088
38030
  wayai admin orgs repair-legacy-grants --all --dry-run
38089
38031
  wayai admin orgs repair-legacy-grants --org <org-id> --yes
38090
38032
  wayai admin harness disable