@wayai/cli 0.3.230 → 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({
@@ -6231,15 +6232,18 @@ var init_chunk_BEOHBREG = __esm({
6231
6232
  }
6232
6233
  });
6233
6234
 
6234
- // ../../packages/core/dist/chunk-4MRBBR5L.js
6235
+ // ../../packages/core/dist/chunk-OWAAYKPB.js
6236
+ function declaresReview(schema) {
6237
+ return typeof schema === "object" && schema !== null && schema[REVIEW_DECLARATION_KEY] !== void 0;
6238
+ }
6235
6239
  function toolsetFileToolName(entry, op) {
6236
6240
  const names = entry.names;
6237
6241
  const stated = names?.[op];
6238
6242
  return stated !== void 0 && stated !== null ? String(stated) : `${op}_${entry.name ?? entry.file_type}`;
6239
6243
  }
6240
- var TOOLSET_SLUG_SETTING, TOOLSET_SLUG_PATTERN, REKOR_STRUCTURAL_ID_PATTERN, baseEnvironmentSchema, TOOLSET_FILE_OPERATIONS, toolsetFileToolSchema, toolsetSurfaceSchema, toolsetConnectionBindingSchema, rekorToolsetToolsSchema, rekorBoundAttestation, rekorResolvedToolsetSchema, resolvedFileToolSchema, rekorToolsetFileSchema, rekorToolsetFileListSchema, rekorToolsetFileGetSchema, rekorToolsetFilePutSchema, TOOLSET_CUSTOMER_FACING_REFUSAL_MARK, TOOLSET_CUSTOMER_FACING_REFUSAL;
6241
- var init_chunk_4MRBBR5L = __esm({
6242
- "../../packages/core/dist/chunk-4MRBBR5L.js"() {
6244
+ var TOOLSET_SLUG_SETTING, TOOLSET_SLUG_PATTERN, REKOR_STRUCTURAL_ID_PATTERN, baseEnvironmentSchema, TOOLSET_FILE_OPERATIONS, toolsetFileToolSchema, toolsetSurfaceSchema, toolsetConnectionBindingSchema, rekorToolsetToolsSchema, rekorBoundAttestation, rekorResolvedToolsetSchema, REVIEW_DECLARATION_KEY, resolvedRecordTypeSchema, reviewWritersSchema, sharedScopeSchema, resolvedFileToolSchema, rekorToolsetFileSchema, rekorToolsetFileListSchema, rekorToolsetFileGetSchema, rekorToolsetFilePutSchema, TOOLSET_CUSTOMER_FACING_REFUSAL_MARK, TOOLSET_CUSTOMER_FACING_REFUSAL;
6245
+ var init_chunk_OWAAYKPB = __esm({
6246
+ "../../packages/core/dist/chunk-OWAAYKPB.js"() {
6243
6247
  "use strict";
6244
6248
  init_chunk_BEOHBREG();
6245
6249
  init_chunk_DHPUPI4Y();
@@ -6287,6 +6291,22 @@ var init_chunk_4MRBBR5L = __esm({
6287
6291
  * sync or token save records it.
6288
6292
  */
6289
6293
  file_writes: external_exports.boolean().optional(),
6294
+ /**
6295
+ * A record type the toolset's actions or composite steps reach (the resolve's `record_types`) names it
6296
+ * among its writers (`x-review.writers`, #5083 RK4): the toolset writes the type's drafts and reads its
6297
+ * every record, drafts included. Or such a type's declaration this side cannot read, or a resolve
6298
+ * reaching records that carries no record types. A type only its relationship tools reach is not
6299
+ * judged: the resolve does not carry that type's declaration. Absent
6300
+ * on a surface recorded before it was, which the customer-facing rule reads as writing, for a toolset
6301
+ * reaching records, until the connection's next tool sync or token save records it.
6302
+ */
6303
+ review_writes: external_exports.boolean().optional(),
6304
+ /**
6305
+ * Every record type the toolset reaches, at least one, is reviewed (`x-review`), holds no customer data
6306
+ * (`shared`), and does not name it among its writers: each call reads only that type's approved
6307
+ * records (#5083 decision 182, Q9). Absent on a surface recorded before it was, which reads as false.
6308
+ */
6309
+ approved_reads_only: external_exports.boolean().optional(),
6290
6310
  /**
6291
6311
  * The toolset's file tools. Absent when it has none, and on a surface recorded before they were.
6292
6312
  * A list this side cannot read is dropped rather than failing the binding, which every call and
@@ -6369,9 +6389,23 @@ var init_chunk_4MRBBR5L = __esm({
6369
6389
  batch: external_exports.object({ enabled: external_exports.boolean().optional() }).passthrough().nullable().optional(),
6370
6390
  sql_query: external_exports.boolean().optional(),
6371
6391
  /** The toolset serves one customer per call (#5083 RK2). Absent reads as not scoped. */
6372
- customer_scope: external_exports.boolean().optional()
6392
+ customer_scope: external_exports.boolean().optional(),
6393
+ /**
6394
+ * Each record type the toolset's actions and composite steps reach, by id, as the data product
6395
+ * stores it (`json_schema` included). A reviewed type's `x-review` names its writers (#5083 RK4).
6396
+ */
6397
+ record_types: external_exports.record(external_exports.unknown()).optional(),
6398
+ /**
6399
+ * What each record type the toolset can reach is to a customer scope (`{ role }`, or null), by id:
6400
+ * those `record_types` holds, and those only its relationship tools and steps reach (#5083 RK2).
6401
+ */
6402
+ record_type_scopes: external_exports.record(external_exports.unknown()).optional()
6373
6403
  }).passthrough()
6374
6404
  });
6405
+ REVIEW_DECLARATION_KEY = "x-review";
6406
+ resolvedRecordTypeSchema = external_exports.object({ json_schema: external_exports.record(external_exports.unknown()) });
6407
+ reviewWritersSchema = external_exports.object({ writers: external_exports.array(external_exports.string()).optional() });
6408
+ sharedScopeSchema = external_exports.object({ role: external_exports.literal("shared") });
6375
6409
  resolvedFileToolSchema = external_exports.object({
6376
6410
  file_type: external_exports.string().min(1),
6377
6411
  path_prefix: external_exports.string().nullish(),
@@ -6394,7 +6428,7 @@ var init_chunk_4MRBBR5L = __esm({
6394
6428
  });
6395
6429
  rekorToolsetFilePutSchema = external_exports.object({ data: rekorToolsetFileSchema });
6396
6430
  TOOLSET_CUSTOMER_FACING_REFUSAL_MARK = "A customer-facing agent (a pilot, pilot specialist or pilot advisor) can use a toolset only when it exposes files alone: no record, composite or relationship tools, and neither sql_query nor batch";
6397
- TOOLSET_CUSTOMER_FACING_REFUSAL = `${TOOLSET_CUSTOMER_FACING_REFUSAL_MARK}, nor a file put or delete \u2014 unless the toolset is customer-scoped, which admits its record, composite and relationship tools, since each of their calls reaches only the conversation's customer and shared records`;
6431
+ TOOLSET_CUSTOMER_FACING_REFUSAL = `${TOOLSET_CUSTOMER_FACING_REFUSAL_MARK}, nor a file put or delete, nor a write of a reviewed record type \u2014 unless the toolset is customer-scoped, which admits its record, composite and relationship tools, since each of their calls reaches only the conversation's customer and shared records, or they only read approved records of reviewed shared record types`;
6398
6432
  }
6399
6433
  });
6400
6434
 
@@ -6823,7 +6857,7 @@ var init_chunk_A4JC7DXB = __esm({
6823
6857
  }
6824
6858
  });
6825
6859
 
6826
- // ../../packages/core/dist/chunk-23UZ2IKU.js
6860
+ // ../../packages/core/dist/chunk-VMAX5YRT.js
6827
6861
  function spokenLineField(label, description2) {
6828
6862
  return { type: "text", label, maxLength: SPOKEN_LINE_MAX_CHARS, default: "", description: description2 };
6829
6863
  }
@@ -6833,8 +6867,8 @@ function byLowercaseName(a, b) {
6833
6867
  return x < y ? -1 : x > y ? 1 : 0;
6834
6868
  }
6835
6869
  var CALLER_LANGUAGE, TTS_VOICE_REPLY_ENABLED_FIELD, COPILOT_TRIGGER_FIELD, SANDBOX_AGENT_FIELDS, AUDIO_LANGUAGE_OPTIONS, whatsapp, instagram, resend, telegram, API_CHANNEL_DELIVERY_EVENTS, apiChannel, OPENAI_REASONING_MODELS, openai, anthropic, googleAiStudio, openRouter, xai, groqStt, openaiStt, elevenLabsStt, openaiTts, groqTts, elevenLabsTts, GEMINI_TTS_VOICES, googleTts, wayai, externalResources, restApiTool, mcpServer, REKOR_TOOLSET_SERVICE_NAME, rekorToolset, CLAUDE_HARNESS_MODELS, CLAUDE_HARNESS_MODEL_OPTIONS, HARNESS_MCP_SERVERS_FIELD, HARNESS_EGRESS_FIELDS, claudeManagedAgents, SPOKEN_LINE_MAX_CHARS, gptLive, CONNECTORS;
6836
- var init_chunk_23UZ2IKU = __esm({
6837
- "../../packages/core/dist/chunk-23UZ2IKU.js"() {
6870
+ var init_chunk_VMAX5YRT = __esm({
6871
+ "../../packages/core/dist/chunk-VMAX5YRT.js"() {
6838
6872
  "use strict";
6839
6873
  init_chunk_A4JC7DXB();
6840
6874
  CALLER_LANGUAGE = "caller";
@@ -7801,13 +7835,13 @@ var init_chunk_23UZ2IKU = __esm({
7801
7835
  }
7802
7836
  });
7803
7837
 
7804
- // ../../packages/core/dist/chunk-23ESQLLF.js
7838
+ // ../../packages/core/dist/chunk-C4TPQN6Z.js
7805
7839
  var evalCallInstant, EVAL_CALL_MIN_SECONDS, EVAL_CALL_MAX_SECONDS, EVAL_CALL_SPOKEN_LINE_MAX_CHARS, hubScoped2, createEvalCallBody, createEvalCallResponse, evalCallConversationQuery, evalCallRecordQuery, evalCallSpeaker, evalCallUtterance, evalCallTurn, evalCallRecording, evalCallRecordResponse, evalCallFinishResponse;
7806
- var init_chunk_23ESQLLF = __esm({
7807
- "../../packages/core/dist/chunk-23ESQLLF.js"() {
7840
+ var init_chunk_C4TPQN6Z = __esm({
7841
+ "../../packages/core/dist/chunk-C4TPQN6Z.js"() {
7808
7842
  "use strict";
7809
7843
  init_chunk_E4DIIOOE();
7810
- init_chunk_23UZ2IKU();
7844
+ init_chunk_VMAX5YRT();
7811
7845
  init_chunk_HZ6CADSY();
7812
7846
  init_chunk_MIWZOSPI();
7813
7847
  init_zod();
@@ -8174,15 +8208,15 @@ var init_chunk_MH4O3YEX = __esm({
8174
8208
  }
8175
8209
  });
8176
8210
 
8177
- // ../../packages/core/dist/chunk-UFYIBL66.js
8211
+ // ../../packages/core/dist/chunk-GWMNV3N4.js
8178
8212
  function catalogToolSideEffects(toolName) {
8179
8213
  const sideEffects = CATALOG_SIDE_EFFECTS.get(toolName);
8180
8214
  if (sideEffects === void 0) return "unknown";
8181
8215
  return sideEffects ? "side_effects" : "none";
8182
8216
  }
8183
8217
  var NATIVE_TOOL_SCHEMAS, WAYAI_CONNECTOR, SANDBOX_AGENT_ROLES, BASE_NATIVE_TOOLS, NATIVE_TOOLS, CATALOG_SIDE_EFFECTS;
8184
- var init_chunk_UFYIBL66 = __esm({
8185
- "../../packages/core/dist/chunk-UFYIBL66.js"() {
8218
+ var init_chunk_GWMNV3N4 = __esm({
8219
+ "../../packages/core/dist/chunk-GWMNV3N4.js"() {
8186
8220
  "use strict";
8187
8221
  init_chunk_DHPUPI4Y();
8188
8222
  NATIVE_TOOL_SCHEMAS = {
@@ -8660,83 +8694,6 @@ var init_chunk_UFYIBL66 = __esm({
8660
8694
  },
8661
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).'
8662
8696
  },
8663
- "list_resource_folders": {
8664
- "tool_config": {
8665
- "name": "list_resource_folders",
8666
- "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.",
8667
- "strict": false,
8668
- "parameters": {
8669
- "type": "object",
8670
- "properties": {
8671
- "resource_id": {
8672
- "type": "string",
8673
- "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."
8674
- },
8675
- "search_query": {
8676
- "type": "string",
8677
- "description": "Search folders by name"
8678
- },
8679
- "metadata_filter": {
8680
- "type": "object",
8681
- "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.'
8682
- }
8683
- },
8684
- "required": [
8685
- "resource_id"
8686
- ],
8687
- "additionalProperties": false
8688
- }
8689
- },
8690
- "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."
8691
- },
8692
- "list_resource_files": {
8693
- "tool_config": {
8694
- "name": "list_resource_files",
8695
- "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.",
8696
- "strict": false,
8697
- "parameters": {
8698
- "type": "object",
8699
- "properties": {
8700
- "resource_id": {
8701
- "type": "string",
8702
- "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."
8703
- },
8704
- "folder_id": {
8705
- "type": "string",
8706
- "description": "Filter by folder ID. Omit to return ALL files. Use 00000000-0000-0000-0000-000000000000 for root-level files only."
8707
- },
8708
- "search_query": {
8709
- "type": "string",
8710
- "description": "Search files by title or file name"
8711
- },
8712
- "tags": {
8713
- "type": "array",
8714
- "items": {
8715
- "type": "string"
8716
- },
8717
- "description": "Filter by tags (matches files with any of the specified tags)"
8718
- },
8719
- "metadata_filter": {
8720
- "type": "object",
8721
- "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.'
8722
- },
8723
- "limit": {
8724
- "type": "integer",
8725
- "description": "Maximum number of files to return (default: 50, max: 100)"
8726
- },
8727
- "offset": {
8728
- "type": "integer",
8729
- "description": "Number of files to skip for pagination (default: 0)"
8730
- }
8731
- },
8732
- "required": [
8733
- "resource_id"
8734
- ],
8735
- "additionalProperties": false
8736
- }
8737
- },
8738
- "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."
8739
- },
8740
8697
  "get_tool_schema": {
8741
8698
  "tool_config": {
8742
8699
  "name": "get_tool_schema",
@@ -9084,21 +9041,6 @@ var init_chunk_UFYIBL66 = __esm({
9084
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 },
9085
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 },
9086
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 },
9087
- // Superseded by `list_files` (nt-027), which browses the same resource files
9088
- // by PATH plus this conversation's attachments.
9089
- //
9090
- // `ui_assignable: false` — DEPRECATED, not withdrawn. Hiding the Add grid entry
9091
- // stops a NEW agent from being wired to a tool that addresses files by an id a
9092
- // publish re-mints and that cannot see a conversation attachment at all (the id
9093
- // itself is discoverable — `RESOURCE_TOOL_INJECTIONS` still writes the linked
9094
- // ids into their `resource_id` description every turn), while every hub that
9095
- // already assigns one keeps
9096
- // working: the handler still dispatches, CI name resolution still resolves the
9097
- // name, and `wayai pull` / `push` still round-trips the YAML. There is no
9098
- // auto-provisioning anywhere in the platform, so an existing agent is never
9099
- // migrated for free — an author swaps the tool deliberately.
9100
- { 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 },
9101
- { 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 },
9102
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 },
9103
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 },
9104
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 },
@@ -9129,8 +9071,9 @@ var init_chunk_UFYIBL66 = __esm({
9129
9071
  // live button that only ever errors is worse than no button. Assign via `wayai push`
9130
9072
  // until the picker ships.
9131
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 },
9132
- // One drill-down listing for every file namespace, replacing `list_resource_files`
9133
- // (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
9134
9077
  // configuration the Add dialog cannot collect — the mounts an agent may browse
9135
9078
  // come from its existing resource links and its own conversation, and the only
9136
9079
  // model-supplied input is a path.
@@ -9213,7 +9156,16 @@ var init_chunk_IBL7FANV = __esm({
9213
9156
  }
9214
9157
  });
9215
9158
 
9216
- // ../../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
9217
9169
  function parseExpr(expr) {
9218
9170
  const fnMatch = expr.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\s*\((.*?)\)\s*(?:\.(.*))?$/);
9219
9171
  if (!fnMatch) return null;
@@ -9240,87 +9192,36 @@ function stripQuotes(s) {
9240
9192
  }
9241
9193
  return s;
9242
9194
  }
9243
- function parseCatalogArgs(args2) {
9244
- let kind = null;
9245
- let tree = false;
9246
- for (const token of args2) {
9247
- if (token === "tree") tree = true;
9248
- else if ((token === "kb" || token === "skill") && kind === null) kind = token;
9249
- }
9250
- return { kind, tree };
9251
- }
9252
- function widenKinds(kinds) {
9253
- if (kinds.has("all") || kinds.size > 1) return "all";
9254
- return [...kinds][0] ?? null;
9255
- }
9256
9195
  function* parseCalls(template) {
9257
9196
  for (const match of template.matchAll(PLACEHOLDER_RE)) {
9258
9197
  const parsed = parseExpr(match[1].trim());
9259
9198
  if (parsed) yield parsed;
9260
9199
  }
9261
9200
  }
9262
- function scanTemplateResources(template) {
9263
- if (!template || !template.includes("{{")) return EMPTY_SCAN;
9264
- const scan = { ...EMPTY_SCAN };
9265
- const names = /* @__PURE__ */ new Set();
9266
- const paths = /* @__PURE__ */ new Set();
9267
- const treeKinds = /* @__PURE__ */ new Set();
9268
- 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;
9269
9208
  for (const { fn, args: args2 } of parseCalls(template)) {
9270
- switch (fn) {
9271
- case CATALOG_FN:
9272
- case LEGACY_CATALOG_FN: {
9273
- scan.needs_catalog = true;
9274
- scan.has_catalog_call = true;
9275
- const { kind, tree } = parseCatalogArgs(args2);
9276
- if (fn === LEGACY_CATALOG_FN) legacyKinds.add(kind ?? "all");
9277
- if (tree) treeKinds.add(kind ?? "all");
9278
- break;
9279
- }
9280
- case "agent_skills":
9281
- scan.needs_catalog = true;
9282
- break;
9283
- case "resource_content":
9284
- if (args2[0]) names.add(args2[0]);
9285
- break;
9286
- case "file_content":
9287
- if (args2[0]) paths.add(args2[0]);
9288
- break;
9289
- default:
9290
- break;
9291
- }
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]);
9292
9214
  }
9293
- scan.tree_kinds = widenKinds(treeKinds);
9294
- scan.legacy_kinds = widenKinds(legacyKinds);
9295
- scan.resource_content_names = [...names];
9296
- scan.file_content_paths = [...paths];
9297
- return scan;
9215
+ return calls;
9298
9216
  }
9299
- var PREVIOUS_CONVERSATIONS_MAX, PLACEHOLDER_RE, CATALOG_FN, LEGACY_CATALOG_FN, EMPTY_SCAN;
9300
- var init_chunk_Z22T2ASG = __esm({
9301
- "../../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"() {
9302
9220
  "use strict";
9303
9221
  PREVIOUS_CONVERSATIONS_MAX = 20;
9304
9222
  PLACEHOLDER_RE = /\{\{\s*([^{}]+?)\s*\}\}/g;
9305
9223
  CATALOG_FN = "files";
9306
- LEGACY_CATALOG_FN = "resources";
9307
- EMPTY_SCAN = {
9308
- needs_catalog: false,
9309
- has_catalog_call: false,
9310
- legacy_kinds: null,
9311
- tree_kinds: null,
9312
- resource_content_names: [],
9313
- file_content_paths: []
9314
- };
9315
- }
9316
- });
9317
-
9318
- // ../../packages/core/dist/chunk-C2UEA2KW.js
9319
- var FLAG_CONDITION_OPERATORS;
9320
- var init_chunk_C2UEA2KW = __esm({
9321
- "../../packages/core/dist/chunk-C2UEA2KW.js"() {
9322
- "use strict";
9323
- FLAG_CONDITION_OPERATORS = ["=", "!=", ">=", "<=", ">", "<"];
9224
+ RETIRED_CATALOG_FN = "resources";
9324
9225
  }
9325
9226
  });
9326
9227
 
@@ -9502,7 +9403,7 @@ var init_chunk_T7KQKDET = __esm({
9502
9403
  }
9503
9404
  });
9504
9405
 
9505
- // ../../packages/core/dist/chunk-2LZYS6YX.js
9406
+ // ../../packages/core/dist/chunk-BV6U4HXF.js
9506
9407
  function resolveMonitorTrigger(monitorConfig) {
9507
9408
  if (!monitorConfig || typeof monitorConfig !== "object") return "idle";
9508
9409
  const raw = monitorConfig.trigger;
@@ -9808,14 +9709,14 @@ function refineMonitorRulesStructuredOutput(body, ctx) {
9808
9709
  if (refusal2) ctx.addIssue({ code: external_exports.ZodIssueCode.custom, path: ["response_format"], message: refusal2 });
9809
9710
  }
9810
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;
9811
- var init_chunk_2LZYS6YX = __esm({
9812
- "../../packages/core/dist/chunk-2LZYS6YX.js"() {
9712
+ var init_chunk_BV6U4HXF = __esm({
9713
+ "../../packages/core/dist/chunk-BV6U4HXF.js"() {
9813
9714
  "use strict";
9814
- init_chunk_UFYIBL66();
9715
+ init_chunk_GWMNV3N4();
9815
9716
  init_chunk_IBL7FANV();
9816
- init_chunk_Z22T2ASG();
9817
9717
  init_chunk_HZ6CADSY();
9818
9718
  init_chunk_C2UEA2KW();
9719
+ init_chunk_D4AWK26E();
9819
9720
  init_chunk_DHPUPI4Y();
9820
9721
  init_chunk_T7KQKDET();
9821
9722
  init_chunk_L5F7ZOUJ();
@@ -10034,12 +9935,12 @@ var init_chunk_2LZYS6YX = __esm({
10034
9935
  }
10035
9936
  });
10036
9937
 
10037
- // ../../packages/core/dist/chunk-XR36MYEY.js
9938
+ // ../../packages/core/dist/chunk-MUG3LWPZ.js
10038
9939
  var conversationIdParam, conversationHubQuery, claimBody, releaseBody, transferBody, closeBody, additionalContextPayloadSchema, kanbanUpdateBody, annotateConversationBody, observabilityParams, observabilityListParams, deleteUserConversationsBody, deleteUserConversationsResponse, sendMessageBody, listConversationsQuery, flagSourceSchema, getConversationsResponse, getConversationDetailParams, getConversationDetailQuery, getConversationDetailResponse, listWhatsAppTemplatesQuery, sendWhatsAppTemplateBody;
10039
- var init_chunk_XR36MYEY = __esm({
10040
- "../../packages/core/dist/chunk-XR36MYEY.js"() {
9940
+ var init_chunk_MUG3LWPZ = __esm({
9941
+ "../../packages/core/dist/chunk-MUG3LWPZ.js"() {
10041
9942
  "use strict";
10042
- init_chunk_2LZYS6YX();
9943
+ init_chunk_BV6U4HXF();
10043
9944
  init_chunk_HZ6CADSY();
10044
9945
  init_chunk_DHPUPI4Y();
10045
9946
  init_zod();
@@ -10495,7 +10396,7 @@ var init_chunk_BPCNB5RT = __esm({
10495
10396
  }
10496
10397
  });
10497
10398
 
10498
- // ../../packages/core/dist/chunk-MCSEEMGN.js
10399
+ // ../../packages/core/dist/chunk-HWB3MFZT.js
10499
10400
  function idempotencyHeaderRefusal(value) {
10500
10401
  if (typeof value !== "string" || !/^[A-Za-z0-9][A-Za-z0-9-]{0,63}$/.test(value)) {
10501
10402
  return "idempotency_header must be a header name: letters, digits and dashes, at most 64";
@@ -10506,10 +10407,10 @@ function idempotencyHeaderRefusal(value) {
10506
10407
  return null;
10507
10408
  }
10508
10409
  var CATALOG_REPLAY, REPLAY_OVERRIDES, RESERVED_HEADERS;
10509
- var init_chunk_MCSEEMGN = __esm({
10510
- "../../packages/core/dist/chunk-MCSEEMGN.js"() {
10410
+ var init_chunk_HWB3MFZT = __esm({
10411
+ "../../packages/core/dist/chunk-HWB3MFZT.js"() {
10511
10412
  "use strict";
10512
- init_chunk_UFYIBL66();
10413
+ init_chunk_GWMNV3N4();
10513
10414
  CATALOG_REPLAY = new Map(
10514
10415
  NATIVE_TOOLS.map((tool) => [tool.tool_name, tool.replay])
10515
10416
  );
@@ -10742,7 +10643,7 @@ var init_chunk_WEXVYJ5H = __esm({
10742
10643
  }
10743
10644
  });
10744
10645
 
10745
- // ../../packages/core/dist/chunk-4S4FBSBE.js
10646
+ // ../../packages/core/dist/chunk-VHQED53I.js
10746
10647
  function refineToolConfig(value, ctx) {
10747
10648
  const raw = value.tool_config;
10748
10649
  if (raw == null) return;
@@ -10778,10 +10679,10 @@ function refineToolConfig(value, ctx) {
10778
10679
  }
10779
10680
  }
10780
10681
  var toolIdParam, listToolsQuery, toolAgentQuery, deleteToolQuery, toolConnectionsQuery, nativeToolIdSchema, CONTEXT_BOUNDARIES, contextBoundarySchema, addNativeToolBody, addMcpToolBody, toolReplaySettingsFields, toolReplaySettingsSchema, createCustomToolBody, updateCustomToolBody, updateToolExecutionConfigBody;
10781
- var init_chunk_4S4FBSBE = __esm({
10782
- "../../packages/core/dist/chunk-4S4FBSBE.js"() {
10682
+ var init_chunk_VHQED53I = __esm({
10683
+ "../../packages/core/dist/chunk-VHQED53I.js"() {
10783
10684
  "use strict";
10784
- init_chunk_MCSEEMGN();
10685
+ init_chunk_HWB3MFZT();
10785
10686
  init_chunk_WEXVYJ5H();
10786
10687
  init_chunk_HZ6CADSY();
10787
10688
  init_zod();
@@ -10803,11 +10704,9 @@ var init_chunk_4S4FBSBE = __esm({
10803
10704
  /** Only meaningful for a `hub` delegation (`delegate_to_hub`); ignored otherwise.
10804
10705
  * Defaults to `summary` when omitted. Admin-set — the link and boundary require
10805
10706
  * hub-admin (`hub:write`), never derived from any end user's grants. */
10806
- delegation_context_boundary: contextBoundarySchema.optional(),
10807
- resource_config: external_exports.object({
10808
- access_mode: external_exports.enum(["all", "selected", "none"]),
10809
- enabled_resources: external_exports.array(external_exports.string()).optional()
10810
- }).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.
10811
10710
  });
10812
10711
  addMcpToolBody = external_exports.object({
10813
10712
  agent_id: uuidSchema,
@@ -10852,7 +10751,7 @@ var init_chunk_4LXDRTO4 = __esm({
10852
10751
  }
10853
10752
  });
10854
10753
 
10855
- // ../../packages/core/dist/chunk-6Y7XMRWF.js
10754
+ // ../../packages/core/dist/chunk-2FQVW3O7.js
10856
10755
  function isIanaTimezone(timezone) {
10857
10756
  try {
10858
10757
  new Intl.DateTimeFormat("en-US", { timeZone: timezone }).format(0);
@@ -10862,12 +10761,12 @@ function isIanaTimezone(timezone) {
10862
10761
  }
10863
10762
  }
10864
10763
  var evalDateContextSchema;
10865
- var init_chunk_6Y7XMRWF = __esm({
10866
- "../../packages/core/dist/chunk-6Y7XMRWF.js"() {
10764
+ var init_chunk_2FQVW3O7 = __esm({
10765
+ "../../packages/core/dist/chunk-2FQVW3O7.js"() {
10867
10766
  "use strict";
10868
- init_chunk_Z22T2ASG();
10869
10767
  init_chunk_HZ6CADSY();
10870
10768
  init_chunk_MIWZOSPI();
10769
+ init_chunk_D4AWK26E();
10871
10770
  init_chunk_DHPUPI4Y();
10872
10771
  init_zod();
10873
10772
  evalDateContextSchema = external_exports.object({
@@ -10892,7 +10791,7 @@ var init_chunk_2ISUBJG7 = __esm({
10892
10791
  }
10893
10792
  });
10894
10793
 
10895
- // ../../packages/core/dist/chunk-RCTKQTJH.js
10794
+ // ../../packages/core/dist/chunk-TY6K2EWO.js
10896
10795
  function describeRole(role) {
10897
10796
  if (typeof role === "string") {
10898
10797
  return JSON.stringify(role.length > ROLE_ECHO_MAX ? `${role.slice(0, ROLE_ECHO_MAX)}\u2026` : role);
@@ -11066,11 +10965,11 @@ function terminalRunCount(counts) {
11066
10965
  return counts.successful_runs + counts.failed_runs;
11067
10966
  }
11068
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;
11069
- var init_chunk_RCTKQTJH = __esm({
11070
- "../../packages/core/dist/chunk-RCTKQTJH.js"() {
10968
+ var init_chunk_TY6K2EWO = __esm({
10969
+ "../../packages/core/dist/chunk-TY6K2EWO.js"() {
11071
10970
  "use strict";
11072
10971
  init_chunk_4LXDRTO4();
11073
- init_chunk_6Y7XMRWF();
10972
+ init_chunk_2FQVW3O7();
11074
10973
  init_chunk_HZ6CADSY();
11075
10974
  init_chunk_2ISUBJG7();
11076
10975
  init_zod();
@@ -12153,7 +12052,7 @@ var init_chunk_6NI5RAM4 = __esm({
12153
12052
  }
12154
12053
  });
12155
12054
 
12156
- // ../../packages/core/dist/chunk-FJ5K57CB.js
12055
+ // ../../packages/core/dist/chunk-EYZBTMVU.js
12157
12056
  function refineHubAsCodeCustomTools(config, ctx) {
12158
12057
  const agents = config.agents;
12159
12058
  if (!Array.isArray(agents)) return;
@@ -12689,12 +12588,12 @@ function refineHubAsCodeMonitorRulesOutput(config, ctx) {
12689
12588
  });
12690
12589
  }
12691
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;
12692
- var init_chunk_FJ5K57CB = __esm({
12693
- "../../packages/core/dist/chunk-FJ5K57CB.js"() {
12591
+ var init_chunk_EYZBTMVU = __esm({
12592
+ "../../packages/core/dist/chunk-EYZBTMVU.js"() {
12694
12593
  "use strict";
12695
- init_chunk_4S4FBSBE();
12696
- init_chunk_RCTKQTJH();
12697
- init_chunk_2LZYS6YX();
12594
+ init_chunk_VHQED53I();
12595
+ init_chunk_TY6K2EWO();
12596
+ init_chunk_BV6U4HXF();
12698
12597
  init_chunk_LBDH7LCG();
12699
12598
  init_chunk_4LXDRTO4();
12700
12599
  init_chunk_T4Q5COKJ();
@@ -13704,13 +13603,13 @@ var init_chunk_LQY2OCQL = __esm({
13704
13603
  }
13705
13604
  });
13706
13605
 
13707
- // ../../packages/core/dist/chunk-EA6XOOL2.js
13606
+ // ../../packages/core/dist/chunk-H6TTCXPL.js
13708
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;
13709
- var init_chunk_EA6XOOL2 = __esm({
13710
- "../../packages/core/dist/chunk-EA6XOOL2.js"() {
13608
+ var init_chunk_H6TTCXPL = __esm({
13609
+ "../../packages/core/dist/chunk-H6TTCXPL.js"() {
13711
13610
  "use strict";
13712
13611
  init_chunk_LQY2OCQL();
13713
- init_chunk_2LZYS6YX();
13612
+ init_chunk_BV6U4HXF();
13714
13613
  init_chunk_3HSB6J4J();
13715
13614
  init_chunk_5XEJSR22();
13716
13615
  init_chunk_DHPUPI4Y();
@@ -14236,7 +14135,7 @@ var init_chunk_OMPT4ZHR = __esm({
14236
14135
  }
14237
14136
  });
14238
14137
 
14239
- // ../../packages/core/dist/chunk-3ACHWKFV.js
14138
+ // ../../packages/core/dist/chunk-RUFVP7Q3.js
14240
14139
  function refineScopedTarget(data, ctx) {
14241
14140
  if (data.scope === "org") {
14242
14141
  if (!data.org_id) {
@@ -14261,9 +14160,9 @@ function refineScopedTarget(data, ctx) {
14261
14160
  }
14262
14161
  }
14263
14162
  }
14264
- 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;
14265
- var init_chunk_3ACHWKFV = __esm({
14266
- "../../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"() {
14267
14166
  "use strict";
14268
14167
  init_chunk_FECLIZTY();
14269
14168
  init_chunk_BFG4ZWR4();
@@ -14430,6 +14329,7 @@ var init_chunk_3ACHWKFV = __esm({
14430
14329
  dry_run: external_exports.boolean().optional().default(false)
14431
14330
  });
14432
14331
  adminScopedTargetBody = adminScopedTargetShape.strict().superRefine(refineScopedTarget);
14332
+ adminRepairKnowledgeBlobsBody = adminScopedTargetShape.extend({ dry_run: external_exports.boolean().optional().default(true) }).strict().superRefine(refineScopedTarget);
14433
14333
  BRANCHING_ORPHAN_ENTITY_TYPES = [
14434
14334
  "agent",
14435
14335
  "agent_parameter",
@@ -14964,7 +14864,7 @@ var init_contracts = __esm({
14964
14864
  init_chunk_SXDX4GHS();
14965
14865
  init_chunk_HENF6YTF();
14966
14866
  init_chunk_VXEAR36B();
14967
- init_chunk_DYI3BRJ3();
14867
+ init_chunk_6VCHIFJT();
14968
14868
  init_chunk_Q7KIQHAZ();
14969
14869
  init_chunk_WBFLPPDI();
14970
14870
  init_chunk_IPXBFWUU();
@@ -14975,15 +14875,15 @@ var init_contracts = __esm({
14975
14875
  init_chunk_ZXK6N2HN();
14976
14876
  init_chunk_Y7CFCYX4();
14977
14877
  init_chunk_5DGHIY7L();
14978
- init_chunk_4QBKRQMM();
14979
- init_chunk_4MRBBR5L();
14878
+ init_chunk_4QU6WS7I();
14879
+ init_chunk_OWAAYKPB();
14980
14880
  init_chunk_BEOHBREG();
14981
14881
  init_chunk_IPDOHAZ5();
14982
14882
  init_chunk_YUZFHVB2();
14983
14883
  init_chunk_I3O2RACG();
14984
14884
  init_chunk_34LE6P7E();
14985
14885
  init_chunk_FPSDNS2E();
14986
- init_chunk_23ESQLLF();
14886
+ init_chunk_C4TPQN6Z();
14987
14887
  init_chunk_C4HEZ7ZI();
14988
14888
  init_chunk_IR2NOSI3();
14989
14889
  init_chunk_EA23LSDS();
@@ -14991,13 +14891,13 @@ var init_contracts = __esm({
14991
14891
  init_chunk_LWMLR2WI();
14992
14892
  init_chunk_ACGAI25T();
14993
14893
  init_chunk_MH4O3YEX();
14994
- init_chunk_XR36MYEY();
14894
+ init_chunk_MUG3LWPZ();
14995
14895
  init_chunk_KSTYTQ7I();
14996
14896
  init_chunk_LKBSHANA();
14997
14897
  init_chunk_BPCNB5RT();
14998
- init_chunk_FJ5K57CB();
14999
- init_chunk_4S4FBSBE();
15000
- init_chunk_RCTKQTJH();
14898
+ init_chunk_EYZBTMVU();
14899
+ init_chunk_VHQED53I();
14900
+ init_chunk_TY6K2EWO();
15001
14901
  init_chunk_JDJ4EUOL();
15002
14902
  init_chunk_3KYTITOR();
15003
14903
  init_chunk_XCDUP42J();
@@ -15006,9 +14906,9 @@ var init_contracts = __esm({
15006
14906
  init_chunk_YULHXJ5M();
15007
14907
  init_chunk_V4FRPRH5();
15008
14908
  init_chunk_ZHJEQBXJ();
15009
- init_chunk_EA6XOOL2();
14909
+ init_chunk_H6TTCXPL();
15010
14910
  init_chunk_LQY2OCQL();
15011
- init_chunk_2LZYS6YX();
14911
+ init_chunk_BV6U4HXF();
15012
14912
  init_chunk_3HSB6J4J();
15013
14913
  init_chunk_IG6QBZMA();
15014
14914
  init_chunk_ZJJ5ODOD();
@@ -15017,11 +14917,11 @@ var init_contracts = __esm({
15017
14917
  init_chunk_4LXDRTO4();
15018
14918
  init_chunk_E4DIIOOE();
15019
14919
  init_chunk_7CYHPF35();
15020
- init_chunk_23UZ2IKU();
15021
- init_chunk_MCSEEMGN();
15022
- init_chunk_UFYIBL66();
14920
+ init_chunk_VMAX5YRT();
14921
+ init_chunk_HWB3MFZT();
14922
+ init_chunk_GWMNV3N4();
15023
14923
  init_chunk_NVKU5PPQ();
15024
- init_chunk_3ACHWKFV();
14924
+ init_chunk_RUFVP7Q3();
15025
14925
  init_chunk_FECLIZTY();
15026
14926
  init_chunk_BFG4ZWR4();
15027
14927
  init_chunk_6QXCHNFQ();
@@ -15032,13 +14932,12 @@ var init_contracts = __esm({
15032
14932
  init_chunk_OMPT4ZHR();
15033
14933
  init_chunk_2PZIF56U();
15034
14934
  init_chunk_UEJOG2Q7();
15035
- init_chunk_KJXJKAYT();
14935
+ init_chunk_QUKTIJKE();
15036
14936
  init_chunk_SOJMWM63();
15037
14937
  init_chunk_WEXVYJ5H();
15038
- init_chunk_6Y7XMRWF();
14938
+ init_chunk_2FQVW3O7();
15039
14939
  init_chunk_5XEJSR22();
15040
14940
  init_chunk_IBL7FANV();
15041
- init_chunk_Z22T2ASG();
15042
14941
  init_chunk_VORPHGDT();
15043
14942
  init_chunk_A4JC7DXB();
15044
14943
  init_chunk_HZ6CADSY();
@@ -15046,6 +14945,7 @@ var init_contracts = __esm({
15046
14945
  init_chunk_2ISUBJG7();
15047
14946
  init_chunk_C2UEA2KW();
15048
14947
  init_chunk_6NI5RAM4();
14948
+ init_chunk_D4AWK26E();
15049
14949
  init_chunk_CJ3L46X6();
15050
14950
  init_chunk_6TSQ5HXC();
15051
14951
  init_chunk_DHPUPI4Y();
@@ -15191,6 +15091,11 @@ var init_api_client = __esm({
15191
15091
  async adminRepairTeamOrphans(body) {
15192
15092
  return this.request("POST", "/api/admin/hubs/repair-team-orphans", body);
15193
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
+ }
15194
15099
  // Report twin candidates, or delete named production rows no preview maps (#4577).
15195
15100
  // Used by `wayai admin hubs repair-branching-orphans` (platform-admin gated).
15196
15101
  async adminRepairBranchingOrphans(body) {
@@ -16365,13 +16270,12 @@ var UUID_RE2, WAYAI_WORKSPACE_LAYOUT;
16365
16270
  var init_dist = __esm({
16366
16271
  "../../packages/core/dist/index.js"() {
16367
16272
  "use strict";
16368
- init_chunk_KJXJKAYT();
16273
+ init_chunk_QUKTIJKE();
16369
16274
  init_chunk_SOJMWM63();
16370
16275
  init_chunk_WEXVYJ5H();
16371
- init_chunk_6Y7XMRWF();
16276
+ init_chunk_2FQVW3O7();
16372
16277
  init_chunk_5XEJSR22();
16373
16278
  init_chunk_IBL7FANV();
16374
- init_chunk_Z22T2ASG();
16375
16279
  init_chunk_P3AWZG3N();
16376
16280
  init_chunk_VORPHGDT();
16377
16281
  init_chunk_A4JC7DXB();
@@ -16383,6 +16287,7 @@ var init_dist = __esm({
16383
16287
  init_chunk_RPGBR5IN();
16384
16288
  init_chunk_C2UEA2KW();
16385
16289
  init_chunk_6NI5RAM4();
16290
+ init_chunk_D4AWK26E();
16386
16291
  init_chunk_CJ3L46X6();
16387
16292
  init_chunk_6TSQ5HXC();
16388
16293
  init_chunk_DHPUPI4Y();
@@ -17789,6 +17694,7 @@ var init_utils = __esm({
17789
17694
  ["admin skill install", { positionals: 1 }],
17790
17695
  ["admin hubs repair-team-orphans", { positionals: 0, values: ["--org", "--hub"], dryRun: true }],
17791
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 }],
17792
17698
  ["admin orgs repair-legacy-grants", { positionals: 0, values: ["--org"], dryRun: true }],
17793
17699
  ["admin harness mass-destroy", { positionals: 0, values: ["--org", "--hub"], dryRun: true }],
17794
17700
  ["admin harness disable", { positionals: 0 }],
@@ -33561,7 +33467,7 @@ token (\`wayai login --token\`, or WAYAI_TOKEN) is refused.
33561
33467
  var init_rekor_toolset = __esm({
33562
33468
  "../../packages/core/dist/contracts/rekor-toolset.js"() {
33563
33469
  "use strict";
33564
- init_chunk_4MRBBR5L();
33470
+ init_chunk_OWAAYKPB();
33565
33471
  init_chunk_BEOHBREG();
33566
33472
  init_chunk_DHPUPI4Y();
33567
33473
  }
@@ -33793,6 +33699,7 @@ var init_resource_paths = __esm({
33793
33699
  "../../packages/core/dist/resource-paths.js"() {
33794
33700
  "use strict";
33795
33701
  init_chunk_6NI5RAM4();
33702
+ init_chunk_D4AWK26E();
33796
33703
  init_chunk_CJ3L46X6();
33797
33704
  init_chunk_6TSQ5HXC();
33798
33705
  RESOURCE_NAMESPACE = "resources";
@@ -35432,9 +35339,9 @@ var COUNTER_KEYS, STT_PRICING, CONTAINER_PRICING, connectorById, nativeToolById;
35432
35339
  var init_catalog = __esm({
35433
35340
  "../../packages/core/dist/catalog/index.js"() {
35434
35341
  "use strict";
35435
- init_chunk_23UZ2IKU();
35436
- init_chunk_MCSEEMGN();
35437
- init_chunk_UFYIBL66();
35342
+ init_chunk_VMAX5YRT();
35343
+ init_chunk_HWB3MFZT();
35344
+ init_chunk_GWMNV3N4();
35438
35345
  init_chunk_A4JC7DXB();
35439
35346
  init_chunk_MIWZOSPI();
35440
35347
  init_chunk_DHPUPI4Y();
@@ -35484,14 +35391,13 @@ function rewriteCitations(text, fileTypeBySlug) {
35484
35391
  }
35485
35392
  function knowledgePlaceholders(template, losing) {
35486
35393
  if (losing.length === 0 || !template.includes("{{")) return [];
35487
- const scan = scanTemplateResources(template);
35488
- const kinds = scanTemplateResources(template.replace(/\{\{(\s*)files(\s*\()/g, "{{$1resources$2")).legacy_kinds;
35394
+ const calls = countResourcePlaceholders(template);
35489
35395
  const uses = [];
35490
- 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");
35491
35397
  const names = new Set(losing.map((r) => r.name));
35492
- 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})}}`);
35493
35399
  const slugs = new Set(losing.map((r) => r.slug));
35494
- for (const path42 of scan.file_content_paths) {
35400
+ for (const path42 of new Set(calls.file_content_paths)) {
35495
35401
  const [namespace, slug] = cleanRelativePath(path42).split("/");
35496
35402
  if (namespace?.toLowerCase() === RESOURCE_NAMESPACE && slug && slugs.has(slug.toLowerCase())) {
35497
35403
  uses.push(`{{file_content(${path42})}}`);
@@ -36285,6 +36191,9 @@ async function adminCommand(args2) {
36285
36191
  case "repair-branching-orphans":
36286
36192
  await runRepairBranchingOrphans(flagArgs);
36287
36193
  return;
36194
+ case "repair-knowledge-blobs":
36195
+ await runRepairKnowledgeBlobs(flagArgs);
36196
+ return;
36288
36197
  default:
36289
36198
  printHelp2();
36290
36199
  process.exit(1);
@@ -36794,6 +36703,64 @@ async function runRepairTeamOrphans(flagArgs) {
36794
36703
  console.log(`${d.hub_id} | ${d.dangling_team_ids.join(",")} | ${d.team_users_removed}`);
36795
36704
  }
36796
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
+ }
36797
36764
  async function runRepairBranchingOrphans(flagArgs) {
36798
36765
  const USAGE5 = "wayai admin hubs repair-branching-orphans --all | --org <org_id> | --hub <hub_id> [--id <type>:<id> ...] [--dry-run] [--yes] [--json]";
36799
36766
  const targets = [];
@@ -37908,6 +37875,9 @@ Usage:
37908
37875
  wayai admin hubs repair-branching-orphans --all | --org <org_id> | --hub <hub_id> [--id <type>:<id> ...] [--dry-run] [--yes] [--json]
37909
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
37910
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
+
37911
37881
  wayai admin orgs repair-legacy-grants --all | --org <org_id> [--dry-run] [--yes] [--json]
37912
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
37913
37883
 
@@ -37990,6 +37960,9 @@ Sources:
37990
37960
  diff sees them. It never picks rows itself \u2014 a deleted preview leaves live
37991
37961
  rows unmapped too \u2014 so without --id it only reports candidates, and with
37992
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.
37993
37966
  orgs Org roster repair. \`repair-legacy-grants\` fixes member_grant rows the
37994
37967
  platform-admin org-admin add wrote before #3922: the email landed in the
37995
37968
  user_id column with user_email NULL. Auth reads UserDO, never member_grant,
@@ -38052,6 +38025,8 @@ Examples:
38052
38025
  wayai admin observability <hub-id> <conv-id> --message-id <msg-id> --json
38053
38026
  wayai admin hubs repair-branching-orphans --hub <prod-hub-id>
38054
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
38055
38030
  wayai admin orgs repair-legacy-grants --all --dry-run
38056
38031
  wayai admin orgs repair-legacy-grants --org <org-id> --yes
38057
38032
  wayai admin harness disable
@@ -39007,8 +38982,10 @@ Stopped at chunk ${nextIndex}. To resume, re-run the SAME command with:
39007
38982
  if (n === 0) {
39008
38983
  console.error("No rows left to undo \u2014 closing the import session.");
39009
38984
  } else {
38985
+ const reviewed = await recordTypeIsReviewed(client, base, plan.record_type);
38986
+ const count = `${reviewed ? "up to " : ""}${n} record${n === 1 ? "" : "s"}`;
39010
38987
  const ok = await confirm(
39011
- `Delete ${n} record${n === 1 ? "" : "s"} created by this import into "${sanitizeTerminalText(String(plan.record_type))}", plus every relationship pointing at them?`
38988
+ `Delete ${count} created by this import into "${sanitizeTerminalText(String(plan.record_type))}"${reviewed ? " (those approved now stay unless you are signed in to WayAI as a person)" : ""}, plus every relationship pointing at them?`
39012
38989
  );
39013
38990
  if (!ok) {
39014
38991
  console.error("Aborted.");
@@ -39018,6 +38995,7 @@ Stopped at chunk ${nextIndex}. To resume, re-run the SAME command with:
39018
38995
  }
39019
38996
  let records = 0;
39020
38997
  let relationships = 0;
38998
+ let kept = 0;
39021
38999
  let calls = 0;
39022
39000
  let incomplete = false;
39023
39001
  for (let sweep = 0; ; sweep++) {
@@ -39029,7 +39007,10 @@ Stopped at chunk ${nextIndex}. To resume, re-run the SAME command with:
39029
39007
  records += res.swept.records;
39030
39008
  relationships += res.swept.relationships;
39031
39009
  calls++;
39032
- if (res.complete) break;
39010
+ if (res.complete) {
39011
+ kept = res.kept?.records ?? 0;
39012
+ break;
39013
+ }
39033
39014
  const sweptNothing = res.swept.records === 0 && res.swept.relationships === 0;
39034
39015
  if (sweptNothing || sweep + 1 >= MAX_ROLLBACK_SWEEPS) {
39035
39016
  incomplete = true;
@@ -39047,10 +39028,16 @@ Stopped at chunk ${nextIndex}. To resume, re-run the SAME command with:
39047
39028
  "Note: a request was re-sent after its outcome was unknown, so the counts below are a lower bound \u2014 a page that committed before its response was lost is not included."
39048
39029
  );
39049
39030
  }
39031
+ if (kept > 0) {
39032
+ console.error(
39033
+ `Kept ${kept} record${kept === 1 ? "" : "s"} of this import that ${kept === 1 ? "is" : "are"} approved: only a person signed in to WayAI removes an approved record. A rollback of this import by one removes them.`
39034
+ );
39035
+ }
39050
39036
  printOutput(
39051
39037
  {
39052
39038
  import_id: importId,
39053
39039
  swept: { records, relationships },
39040
+ ...kept > 0 ? { kept: { records: kept } } : {},
39054
39041
  requests: calls,
39055
39042
  // The server's own completion claim, carried so a script can tell an
39056
39043
  // undo that FINISHED from one that stopped early and needs re-running.
@@ -39063,10 +39050,23 @@ Stopped at chunk ${nextIndex}. To resume, re-run the SAME command with:
39063
39050
  });
39064
39051
  return importCmd;
39065
39052
  }
39053
+ async function recordTypeIsReviewed(client, base, recordType2) {
39054
+ if (recordType2 === null) return false;
39055
+ try {
39056
+ const type = await client.request(
39057
+ "GET",
39058
+ `/v1/${base}/record-types/${pathSegment(recordType2, "record_type")}`
39059
+ );
39060
+ return declaresReview(type?.json_schema);
39061
+ } catch {
39062
+ return true;
39063
+ }
39064
+ }
39066
39065
  var MAX_CHUNK_ROWS, MAX_ATTEMPTS, MAX_ROLLBACK_SWEEPS, BASE_BACKOFF_MS, RETRYABLE_CODES, sleep2;
39067
39066
  var init_import = __esm({
39068
39067
  "src/data/commands/import.ts"() {
39069
39068
  "use strict";
39069
+ init_rekor_toolset();
39070
39070
  init_client();
39071
39071
  init_output();
39072
39072
  init_helpers();