@exulu/backend 5.10.1 → 5.11.1

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.cjs CHANGED
@@ -3706,14 +3706,14 @@ function randomizedPCA(rows, dims, k, seed, iterations) {
3706
3706
  for (const row of rows) {
3707
3707
  const centered = new Float64Array(dims);
3708
3708
  for (let d = 0; d < dims; d += 1) centered[d] = (row[d] ?? 0) - (mean[d] ?? 0);
3709
- const z37 = new Float64Array(basis.length);
3709
+ const z38 = new Float64Array(basis.length);
3710
3710
  for (const [b, vec] of basis.entries()) {
3711
3711
  let dot = 0;
3712
3712
  for (let d = 0; d < dims; d += 1) dot += (centered[d] ?? 0) * (vec[d] ?? 0);
3713
- z37[b] = dot;
3713
+ z38[b] = dot;
3714
3714
  }
3715
3715
  for (const [b, target] of next.entries()) {
3716
- const scale = z37[b] ?? 0;
3716
+ const scale = z38[b] ?? 0;
3717
3717
  if (scale === 0) continue;
3718
3718
  for (let d = 0; d < dims; d += 1) target[d] = (target[d] ?? 0) + (centered[d] ?? 0) * scale;
3719
3719
  }
@@ -3811,12 +3811,12 @@ function ridgeFit(Z, Y, lambda) {
3811
3811
  });
3812
3812
  return { map, intercept };
3813
3813
  }
3814
- function applyMap(z37, map, intercept) {
3814
+ function applyMap(z38, map, intercept) {
3815
3815
  const out = [];
3816
3816
  for (let j = 0; j < 3; j += 1) {
3817
3817
  let v = intercept[j] ?? 0;
3818
3818
  const row = map[j] ?? [];
3819
- for (let d = 0; d < row.length; d += 1) v += (row[d] ?? 0) * (z37[d] ?? 0);
3819
+ for (let d = 0; d < row.length; d += 1) v += (row[d] ?? 0) * (z38[d] ?? 0);
3820
3820
  out.push(Number.isFinite(v) ? v : 0);
3821
3821
  }
3822
3822
  return [out[0] ?? 0, out[1] ?? 0, out[2] ?? 0];
@@ -3839,8 +3839,8 @@ function fitResidual(Z, Y, map, intercept) {
3839
3839
  for (let i = 0; i < Z.length; i += 1) {
3840
3840
  const zi = Z[i] ?? [];
3841
3841
  const yi = Y[i] ?? [];
3842
- const [x, y, z37] = applyMap(zi, map, intercept);
3843
- total += Math.hypot(x - finite(yi[0]), y - finite(yi[1]), z37 - finite(yi[2]));
3842
+ const [x, y, z38] = applyMap(zi, map, intercept);
3843
+ total += Math.hypot(x - finite(yi[0]), y - finite(yi[1]), z38 - finite(yi[2]));
3844
3844
  }
3845
3845
  return finite(total / Z.length);
3846
3846
  }
@@ -3984,8 +3984,8 @@ async function chunkCoordinates({
3984
3984
  }
3985
3985
  return null;
3986
3986
  }
3987
- const [x, y, z37] = applyMap(projectComponents(l2normalize(v), mean, basis), projection.map, projection.intercept);
3988
- return { x, y, z: z37 };
3987
+ const [x, y, z38] = applyMap(projectComponents(l2normalize(v), mean, basis), projection.map, projection.intercept);
3988
+ return { x, y, z: z38 };
3989
3989
  });
3990
3990
  } catch (e) {
3991
3991
  console.error("[EXULU] could not compute chunk coordinates", e instanceof Error ? e.message : String(e));
@@ -4641,7 +4641,9 @@ var init_convert_graphql_filter_operator_to_pg_query = __esm({
4641
4641
  console.log("[EXULU] operators.lte", operators.lte);
4642
4642
  console.log("[EXULU] fieldName", fieldName);
4643
4643
  if (operators.lte === 0 || operators.lte === "0") {
4644
- query = query.whereNull(fieldName).orWhere(fieldName, "=", 0);
4644
+ query = query.where(function() {
4645
+ this.whereNull(fieldName).orWhere(fieldName, "=", 0);
4646
+ });
4645
4647
  } else {
4646
4648
  query = query.where(fieldName, "<=", operators.lte);
4647
4649
  }
@@ -4655,12 +4657,15 @@ var init_convert_graphql_filter_operator_to_pg_query = __esm({
4655
4657
  });
4656
4658
 
4657
4659
  // src/graphql/resolvers/apply-filters.ts
4658
- var applyFilters;
4660
+ var applyFiltersGrouped, applyFilters;
4659
4661
  var init_apply_filters = __esm({
4660
4662
  "src/graphql/resolvers/apply-filters.ts"() {
4661
4663
  "use strict";
4662
4664
  init_cjs_shims();
4663
4665
  init_convert_graphql_filter_operator_to_pg_query();
4666
+ applyFiltersGrouped = (query, filters, table, field_prefix) => query.where(function() {
4667
+ applyFilters(this, filters, table, field_prefix);
4668
+ });
4664
4669
  applyFilters = (query, filters, table, field_prefix) => {
4665
4670
  if (!filters) {
4666
4671
  return query;
@@ -8738,8 +8743,12 @@ var init_context = __esm({
8738
8743
  ...item.external_id ? { external_id: item.external_id } : {}
8739
8744
  }).first();
8740
8745
  if (result) {
8741
- const chunksCount = await db2.from(getChunksTableName(this.id)).where({ source: result.id }).count("id");
8742
- result.chunksCount = Number(chunksCount[0].count) || 0;
8746
+ if (this.embedder) {
8747
+ const chunksCount = await db2.from(getChunksTableName(this.id)).where({ source: result.id }).count("id");
8748
+ result.chunksCount = Number(chunksCount[0].count) || 0;
8749
+ } else {
8750
+ result.chunksCount = 0;
8751
+ }
8743
8752
  }
8744
8753
  return result;
8745
8754
  };
@@ -8747,16 +8756,20 @@ var init_context = __esm({
8747
8756
  filters,
8748
8757
  fields,
8749
8758
  user,
8750
- role
8759
+ role,
8760
+ limit
8751
8761
  }) => {
8752
8762
  const { db: db2 } = await postgresClient();
8753
8763
  const tableDefinition = convertContextToTableDefinition(this);
8754
8764
  let query = db2.from(getTableName(this.id)).select(fields || "*");
8755
- query = applyFilters(query, filters || [], tableDefinition);
8765
+ query = applyFiltersGrouped(query, filters || [], tableDefinition);
8756
8766
  if (user) {
8757
8767
  const acUser = role && (!user.role || user.role.id !== role) ? { ...user, role: { ...user.role ?? {}, id: role } } : user;
8758
8768
  query = applyAccessControl(tableDefinition, query, acUser);
8759
8769
  }
8770
+ if (typeof limit === "number" && Number.isFinite(limit) && limit > 0) {
8771
+ query = query.limit(Math.floor(limit));
8772
+ }
8760
8773
  const items = await query;
8761
8774
  return items;
8762
8775
  };
@@ -10604,6 +10617,24 @@ var init_check_item_write_access = __esm({
10604
10617
  }
10605
10618
  });
10606
10619
 
10620
+ // src/exulu/public-surface.ts
10621
+ function isPublicSurface(req) {
10622
+ const raw = req?.headers?.[PUBLIC_SURFACE_HEADER];
10623
+ const value = Array.isArray(raw) ? raw[0] : raw;
10624
+ return value === "1" || value === "true";
10625
+ }
10626
+ function treatAsGuest(req, user) {
10627
+ return isPublicSurface(req) || !user?.id;
10628
+ }
10629
+ var PUBLIC_SURFACE_HEADER;
10630
+ var init_public_surface = __esm({
10631
+ "src/exulu/public-surface.ts"() {
10632
+ "use strict";
10633
+ init_cjs_shims();
10634
+ PUBLIC_SURFACE_HEADER = "x-public-surface";
10635
+ }
10636
+ });
10637
+
10607
10638
  // src/templates/tools/kb-editor-config.ts
10608
10639
  var import_zod5, KB_EDITOR_TOOL_ID, permissionsSchema, emptyConfig, parseKbEditorConfig;
10609
10640
  var init_kb_editor_config = __esm({
@@ -10665,22 +10696,371 @@ var init_kb_editor_config = __esm({
10665
10696
  }
10666
10697
  });
10667
10698
 
10699
+ // src/templates/tools/context-read-tools.ts
10700
+ var import_zod6, FIND_DEFAULT_LIMIT, FIND_MAX_LIMIT, SUPPORTED_OPERATORS, CONTAINS_UNSUPPORTED_TYPES, RANGE_UNSUPPORTED_TYPES, operatorsForField, SYSTEM_FIELDS, CORE_CONTENT_FIELDS, readableContextFields, nameList, resolveFields, selectList, whereByColumn, projectRow, clampLimit, validateWhere, JSON_FILTER_VALUE, filterValueSchema, operatorsSchema, whereSchema, checkItemReadAccess, createContextReadTools;
10701
+ var init_context_read_tools = __esm({
10702
+ "src/templates/tools/context-read-tools.ts"() {
10703
+ "use strict";
10704
+ init_cjs_shims();
10705
+ init_table_names();
10706
+ init_tool();
10707
+ init_convert_graphql_filter_operator_to_pg_query();
10708
+ init_client();
10709
+ init_public_surface();
10710
+ init_check_record_access();
10711
+ init_sanitize_name();
10712
+ import_zod6 = require("zod");
10713
+ init_context_write_tools();
10714
+ FIND_DEFAULT_LIMIT = 20;
10715
+ FIND_MAX_LIMIT = 50;
10716
+ SUPPORTED_OPERATORS = ["eq", "ne", "in", "contains", "gte", "lte"];
10717
+ CONTAINS_UNSUPPORTED_TYPES = /* @__PURE__ */ new Set(["number", "boolean", "date", "uuid"]);
10718
+ RANGE_UNSUPPORTED_TYPES = /* @__PURE__ */ new Set(["json", "uuid"]);
10719
+ operatorsForField = (field) => SUPPORTED_OPERATORS.filter((operator) => {
10720
+ if (operator === "contains") return !CONTAINS_UNSUPPORTED_TYPES.has(field.type);
10721
+ if (operator === "gte" || operator === "lte") return !RANGE_UNSUPPORTED_TYPES.has(field.type);
10722
+ return true;
10723
+ });
10724
+ SYSTEM_FIELDS = [
10725
+ // `id` is a uuid column, not text: `contains` would compile to
10726
+ // `"id" ilike $1` and Postgres refuses that outright (42883).
10727
+ { name: "id", type: "uuid", findDefault: true },
10728
+ { name: "createdAt", type: "date", findDefault: false },
10729
+ { name: "updatedAt", type: "date", findDefault: true },
10730
+ { name: "rights_mode", type: "text", findDefault: false },
10731
+ { name: "archived", type: "boolean", findDefault: false }
10732
+ ];
10733
+ CORE_CONTENT_FIELDS = [
10734
+ { name: "name", type: "text" },
10735
+ { name: "description", type: "text" },
10736
+ { name: "tags", type: "text" },
10737
+ { name: "external_id", type: "text" }
10738
+ ];
10739
+ readableContextFields = (context) => {
10740
+ const fields = [];
10741
+ const seen = /* @__PURE__ */ new Set();
10742
+ const add = (field) => {
10743
+ if (seen.has(field.name)) return;
10744
+ seen.add(field.name);
10745
+ fields.push(field);
10746
+ };
10747
+ for (const system of SYSTEM_FIELDS) {
10748
+ add({ ...system, column: system.name, isFile: false });
10749
+ }
10750
+ for (const core of CORE_CONTENT_FIELDS) {
10751
+ add({ ...core, column: core.name, isFile: false, findDefault: true });
10752
+ }
10753
+ for (const field of context.fields ?? []) {
10754
+ if (!field?.name || !field.type) continue;
10755
+ if (isHiddenField(field)) continue;
10756
+ const isFile = field.type === "file";
10757
+ add({
10758
+ name: field.name,
10759
+ column: sanitizeName(isFile ? `${field.name}_s3key` : field.name),
10760
+ type: field.type,
10761
+ isFile,
10762
+ // A file column holds an opaque storage key, which is noise in a list —
10763
+ // asked for by name it is still returned.
10764
+ findDefault: !isFile
10765
+ });
10766
+ }
10767
+ return fields;
10768
+ };
10769
+ nameList = (fields) => fields.map((f) => f.name).join(", ");
10770
+ resolveFields = (readable, requested, contextName) => {
10771
+ if (!Array.isArray(requested) || requested.length === 0) {
10772
+ return { fields: readable };
10773
+ }
10774
+ const byName = new Map(readable.map((f) => [f.name, f]));
10775
+ const picked = [];
10776
+ const unknown = [];
10777
+ for (const raw of requested) {
10778
+ const name = String(raw);
10779
+ const field = byName.get(name);
10780
+ if (!field) {
10781
+ unknown.push(name);
10782
+ continue;
10783
+ }
10784
+ if (!picked.includes(field)) picked.push(field);
10785
+ }
10786
+ if (unknown.length > 0) {
10787
+ return {
10788
+ error: `Unknown field name${unknown.length > 1 ? "s" : ""} ${unknown.map((n) => `"${n}"`).join(", ")} for "${contextName}". Valid field names: ${nameList(readable)}.`
10789
+ };
10790
+ }
10791
+ const id = readable.find((f) => f.name === "id");
10792
+ if (id && !picked.includes(id)) picked.unshift(id);
10793
+ return { fields: picked };
10794
+ };
10795
+ selectList = (fields) => fields.map((field) => field.column === field.name ? field.column : `${field.column} as ${field.name}`);
10796
+ whereByColumn = (filterable, where) => {
10797
+ const byName = new Map(filterable.map((f) => [f.name, f]));
10798
+ const mapped = {};
10799
+ for (const [name, operators] of Object.entries(where)) {
10800
+ mapped[byName.get(name)?.column ?? name] = operators;
10801
+ }
10802
+ return mapped;
10803
+ };
10804
+ projectRow = (record, fields, explicit) => {
10805
+ const out = {};
10806
+ for (const field of fields) {
10807
+ const value = record[field.column];
10808
+ if (value === void 0 || value === null) {
10809
+ if (explicit) out[field.name] = null;
10810
+ continue;
10811
+ }
10812
+ out[field.name] = value;
10813
+ }
10814
+ return out;
10815
+ };
10816
+ clampLimit = (raw) => {
10817
+ const asNumber = typeof raw === "number" || typeof raw === "string" && raw.trim() !== "" ? Math.floor(Number(raw)) : Number.NaN;
10818
+ if (!Number.isFinite(asNumber) || asNumber <= 0) return FIND_DEFAULT_LIMIT;
10819
+ return Math.min(asNumber, FIND_MAX_LIMIT);
10820
+ };
10821
+ validateWhere = (filterable, where, contextName) => {
10822
+ const names = new Set(filterable.map((f) => f.name));
10823
+ const unknown = Object.keys(where).filter((key) => !names.has(key));
10824
+ if (unknown.length > 0) {
10825
+ return `Unknown filter field${unknown.length > 1 ? "s" : ""} ${unknown.map((n) => `"${n}"`).join(", ")} for "${contextName}". Valid filter fields: ${nameList(filterable)}.`;
10826
+ }
10827
+ const byName = new Map(filterable.map((f) => [f.name, f]));
10828
+ for (const [name, operators] of Object.entries(where)) {
10829
+ if (!operators || typeof operators !== "object" || Array.isArray(operators)) {
10830
+ return `The filter on "${name}" must be an object of operators, e.g. { "${name}": { "eq": \u2026 } }.`;
10831
+ }
10832
+ const allowed = operatorsForField(byName.get(name));
10833
+ const keys = Object.keys(operators);
10834
+ const inValue = operators["in"];
10835
+ if (Array.isArray(inValue) && inValue.length === 0) {
10836
+ return `The "in" filter on "${name}" is an empty list, which matches nothing. Give at least one value, or drop the filter.`;
10837
+ }
10838
+ const badOperators = keys.filter((key) => !allowed.includes(key));
10839
+ if (keys.length === 0 || badOperators.length > 0) {
10840
+ return `The filter on "${name}" uses ${keys.length === 0 ? "no operator" : `unsupported operator(s) ${badOperators.map((k) => `"${k}"`).join(", ")}`}. Supported operators for "${name}": ${allowed.join(", ")}.`;
10841
+ }
10842
+ }
10843
+ return void 0;
10844
+ };
10845
+ JSON_FILTER_VALUE = import_zod6.z.union([
10846
+ import_zod6.z.string(),
10847
+ import_zod6.z.number(),
10848
+ import_zod6.z.boolean(),
10849
+ import_zod6.z.record(import_zod6.z.string(), import_zod6.z.any()),
10850
+ import_zod6.z.array(import_zod6.z.any())
10851
+ ]);
10852
+ filterValueSchema = (type) => {
10853
+ switch (type) {
10854
+ case "json":
10855
+ return JSON_FILTER_VALUE;
10856
+ case "number":
10857
+ return import_zod6.z.number();
10858
+ case "boolean":
10859
+ return import_zod6.z.boolean();
10860
+ default:
10861
+ return import_zod6.z.string();
10862
+ }
10863
+ };
10864
+ operatorsSchema = (field) => {
10865
+ const value = filterValueSchema(field.type);
10866
+ const allowed = operatorsForField(field);
10867
+ const shape = {
10868
+ eq: value.optional(),
10869
+ ne: value.optional(),
10870
+ // An empty list is not a filter: `whereIn(col, [])` matches no row at all,
10871
+ // which the model reads as "there are none" (final wave, Minor 6).
10872
+ in: import_zod6.z.array(value).min(1).optional()
10873
+ };
10874
+ if (allowed.includes("contains")) {
10875
+ shape["contains"] = value.optional();
10876
+ }
10877
+ if (allowed.includes("gte")) {
10878
+ shape["gte"] = value.optional();
10879
+ shape["lte"] = value.optional();
10880
+ }
10881
+ return import_zod6.z.looseObject(shape).optional().describe(
10882
+ `Filter on ${field.name} (${allowed.join(", ")})` + (field.type === "json" ? ": eq/ne/in match the whole stored value, contains does json containment." : ".") + // The platform's own semantics, disclosed because nothing else does:
10883
+ // `lte: 0` deliberately matches NULL as well (final wave, Minor 4).
10884
+ (allowed.includes("lte") ? " `lte` with `0` also matches items where the field is empty." : "")
10885
+ );
10886
+ };
10887
+ whereSchema = (filterable) => {
10888
+ const shape = {};
10889
+ for (const field of filterable) {
10890
+ shape[field.name] = operatorsSchema(field);
10891
+ }
10892
+ return import_zod6.z.looseObject(shape).optional().describe(
10893
+ `Filter: an object of field name to operators, e.g. { "name": { "contains": "widget" } }. Several fields are combined with AND. Operators: ${SUPPORTED_OPERATORS.join(", ")} \u2014 "contains" only on text, enum and json fields (each field's own list is on its filter).`
10894
+ );
10895
+ };
10896
+ checkItemReadAccess = async (context, record, user) => {
10897
+ if (!user) return false;
10898
+ if (await checkRecordAccess(record, "read", user)) return true;
10899
+ const mode = record?.rights_mode;
10900
+ if (mode !== "users" && mode !== "roles" && mode !== "teams") return false;
10901
+ const entity = getTableName(context.id);
10902
+ const { db: db2 } = await postgresClient();
10903
+ if (mode === "users") {
10904
+ const grant2 = await db2.from("rbac").where({ entity, target_resource_id: record.id, access_type: "User", user_id: user.id }).first();
10905
+ return !!grant2;
10906
+ }
10907
+ if (mode === "roles") {
10908
+ const roleId = typeof user.role === "string" ? user.role : user.role?.id;
10909
+ if (!roleId) return false;
10910
+ const grant2 = await db2.from("rbac").where({ entity, target_resource_id: record.id, access_type: "Role", role_id: roleId }).first();
10911
+ return !!grant2;
10912
+ }
10913
+ const teamId = typeof user.team === "string" ? user.team : user.team?.id;
10914
+ if (!teamId) return false;
10915
+ const grant = await db2.from("rbac").where({ entity, target_resource_id: record.id, access_type: "Team", team_id: teamId }).first();
10916
+ return !!grant;
10917
+ };
10918
+ createContextReadTools = (context, deps = {}) => {
10919
+ const segment = contextToolSegment(context);
10920
+ const contextLabel = context.description ? ` ${context.description}` : "";
10921
+ const readable = readableContextFields(context);
10922
+ const filterable = readable.filter((field) => !field.isFile);
10923
+ const findDefaults = readable.filter((field) => field.findDefault);
10924
+ const NOT_FOUND = itemNotFoundMessage(context, "read");
10925
+ const checkAccess = deps.checkAccess ?? checkItemReadAccess;
10926
+ const fieldsInput = (defaults) => import_zod6.z.array(import_zod6.z.string()).optional().describe(
10927
+ `Which fields to return \u2014 "id" is always returned whether you name it or not. Omitted, ${defaults}. Available: ${nameList(readable)}.`
10928
+ );
10929
+ const getTool = new ExuluTool({
10930
+ id: `get_${segment}_item`,
10931
+ name: `Get ${context.name} item`,
10932
+ category: "knowledge_base_reading",
10933
+ description: `Read one item from the "${context.name}" knowledge base by id or external_id.${contextLabel} Returns the item's fields as JSON. Reading changes nothing and needs no approval.`,
10934
+ type: "function",
10935
+ inputSchema: import_zod6.z.object({
10936
+ id: import_zod6.z.string().optional().describe("The id of the item to read."),
10937
+ external_id: import_zod6.z.string().optional().describe("The external_id of the item to read, if the id is unknown."),
10938
+ fields: fieldsInput("every readable field of the item is returned")
10939
+ }),
10940
+ config: [],
10941
+ needsApproval: false,
10942
+ execute: async (params) => {
10943
+ const { user } = params;
10944
+ if (treatAsGuest(params.req, user)) {
10945
+ return { result: NOT_FOUND };
10946
+ }
10947
+ if (!params.id && !params.external_id) {
10948
+ return { result: "Provide the id or external_id of the item to read." };
10949
+ }
10950
+ const selection = resolveFields(readable, params.fields, context.name);
10951
+ if ("error" in selection) {
10952
+ return { result: selection.error };
10953
+ }
10954
+ try {
10955
+ const record = await context.getItem({
10956
+ item: { id: params.id, external_id: params.external_id }
10957
+ });
10958
+ if (!record?.id) {
10959
+ return { result: NOT_FOUND };
10960
+ }
10961
+ if (!await checkAccess(context, record, user)) {
10962
+ return { result: NOT_FOUND };
10963
+ }
10964
+ const explicit = Array.isArray(params.fields) && params.fields.length > 0;
10965
+ return {
10966
+ result: `Item: ${JSON.stringify(projectRow(record, selection.fields, explicit))}`
10967
+ };
10968
+ } catch (error) {
10969
+ console.error(`[EXULU] Error reading item in context ${context.id}`, error);
10970
+ return {
10971
+ result: `Failed to read the item in "${context.name}": ${error instanceof Error ? error.message : String(error)}`
10972
+ };
10973
+ }
10974
+ }
10975
+ });
10976
+ const findTool = new ExuluTool({
10977
+ id: `find_${segment}_items`,
10978
+ name: `Find ${context.name} items`,
10979
+ category: "knowledge_base_reading",
10980
+ description: `Find items in the "${context.name}" knowledge base with a structured filter over their fields.${contextLabel} Exact, field-by-field lookup \u2014 for a meaning-based search use the knowledge base search tool instead. Returns up to ${FIND_MAX_LIMIT} items (${FIND_DEFAULT_LIMIT} by default). Archived items are included unless you filter them out with { "archived": { "eq": false } }. Reading changes nothing and needs no approval.`,
10981
+ type: "function",
10982
+ inputSchema: import_zod6.z.object({
10983
+ where: whereSchema(filterable),
10984
+ limit: import_zod6.z.coerce.number().optional().describe(
10985
+ `How many items to return at most. Default ${FIND_DEFAULT_LIMIT}, maximum ${FIND_MAX_LIMIT} (a larger number is clamped).`
10986
+ ),
10987
+ fields: fieldsInput(
10988
+ `${findDefaults.map((f) => f.name).join(", ")} are returned`
10989
+ )
10990
+ }),
10991
+ config: [],
10992
+ needsApproval: false,
10993
+ execute: async (params) => {
10994
+ const { user } = params;
10995
+ const limit = clampLimit(params.limit);
10996
+ if (treatAsGuest(params.req, user)) {
10997
+ return { result: "Found 0 item(s): []" };
10998
+ }
10999
+ const requested = Array.isArray(params.fields) && params.fields.length > 0 ? params.fields : void 0;
11000
+ const selection = resolveFields(requested ? readable : findDefaults, requested, context.name);
11001
+ if ("error" in selection) {
11002
+ return { result: selection.error };
11003
+ }
11004
+ const where = params.where && typeof params.where === "object" && !Array.isArray(params.where) ? params.where : void 0;
11005
+ if (where && Object.keys(where).length > 0) {
11006
+ const whereError = validateWhere(filterable, where, context.name);
11007
+ if (whereError) {
11008
+ return { result: whereError };
11009
+ }
11010
+ }
11011
+ try {
11012
+ const items = await context.getItems({
11013
+ filters: where && Object.keys(where).length > 0 ? [whereByColumn(filterable, where)] : [],
11014
+ fields: selectList(selection.fields),
11015
+ user,
11016
+ // A user's role can be the bare id string as well as an object;
11017
+ // `user.role?.id` on a string silently yields undefined, which knex
11018
+ // then refuses as an undefined binding (fix round 1, F3).
11019
+ role: typeof user.role === "string" ? user.role : user.role?.id,
11020
+ limit
11021
+ });
11022
+ return { result: `Found ${items.length} item(s): ${JSON.stringify(items)}` };
11023
+ } catch (error) {
11024
+ if (error instanceof UnknownFilterPathError) {
11025
+ console.warn(`[EXULU] ${findTool.id} refused an unknown json filter path:`, error.message);
11026
+ const field = filterable.find((candidate) => candidate.column === error.field);
11027
+ return {
11028
+ result: field && field.name !== error.field ? new UnknownFilterPathError(field.name, error.offendingPaths, error.validPaths).message : error.message
11029
+ };
11030
+ }
11031
+ console.error(`[EXULU] Error finding items in context ${context.id}`, error);
11032
+ return {
11033
+ result: `Failed to find items in "${context.name}": ${error instanceof Error ? error.message : String(error)}`
11034
+ };
11035
+ }
11036
+ }
11037
+ });
11038
+ return [getTool, findTool];
11039
+ };
11040
+ }
11041
+ });
11042
+
10668
11043
  // src/templates/tools/context-write-tools.ts
10669
- var import_zod6, import_node_crypto3, MAX_CONTEXT_SEGMENT, RESERVED_INPUT_KEYS, buildWriteSchema, BARE_FILENAME, attachSessionFiles, canonicalizeEnumFields, pickContent, jobNote, createContextWriteTools, createKbEditorPickerTool, collectKbWriteTools;
11044
+ var import_zod7, import_node_crypto3, MAX_CONTEXT_SEGMENT, contextToolSegment, itemNotFoundMessage, isHiddenField, RESERVED_INPUT_KEYS, buildWriteSchema, BARE_FILENAME, attachSessionFiles, canonicalizeEnumFields, pickContent, jobNote, createContextWriteTools, createKbEditorPickerTool, collectKbWriteTools;
10670
11045
  var init_context_write_tools = __esm({
10671
11046
  "src/templates/tools/context-write-tools.ts"() {
10672
11047
  "use strict";
10673
11048
  init_cjs_shims();
10674
11049
  init_tool();
10675
- import_zod6 = require("zod");
11050
+ import_zod7 = require("zod");
10676
11051
  import_node_crypto3 = require("crypto");
10677
11052
  init_session_files();
10678
11053
  init_uppy();
10679
11054
  init_sanitize_name();
10680
11055
  init_check_item_write_access();
11056
+ init_public_surface();
10681
11057
  init_kb_editor_config();
10682
11058
  init_json_field_schema();
11059
+ init_context_read_tools();
10683
11060
  MAX_CONTEXT_SEGMENT = 68;
11061
+ contextToolSegment = (context) => sanitizeName(context.id).slice(0, MAX_CONTEXT_SEGMENT);
11062
+ itemNotFoundMessage = (context, access) => `Item not found in "${context.name}" or you don't have ${access} access to it.`;
11063
+ isHiddenField = (field) => field.hidden === true;
10684
11064
  RESERVED_INPUT_KEYS = /* @__PURE__ */ new Set([
10685
11065
  "model",
10686
11066
  "user",
@@ -10707,29 +11087,29 @@ var init_context_write_tools = __esm({
10707
11087
  contentKeys.push(key);
10708
11088
  };
10709
11089
  if (mode === "update") {
10710
- shape["id"] = import_zod6.z.string().optional().describe("The id of the item to update.");
10711
- shape["external_id"] = import_zod6.z.string().optional().describe("The external_id of the item to update, if the id is unknown. Lookup only \u2014 it is never changed.");
11090
+ shape["id"] = import_zod7.z.string().optional().describe("The id of the item to update.");
11091
+ shape["external_id"] = import_zod7.z.string().optional().describe("The external_id of the item to update, if the id is unknown. Lookup only \u2014 it is never changed.");
10712
11092
  }
10713
- addContent("name", import_zod6.z.string().describe("The name of the item."), true);
10714
- addContent("description", import_zod6.z.string().describe("A description of the item."), false);
10715
- addContent("tags", import_zod6.z.array(import_zod6.z.string()).describe("Tags for the item."), false);
11093
+ addContent("name", import_zod7.z.string().describe("The name of the item."), true);
11094
+ addContent("description", import_zod7.z.string().describe("A description of the item."), false);
11095
+ addContent("tags", import_zod7.z.array(import_zod7.z.string()).describe("Tags for the item."), false);
10716
11096
  if (mode === "create") {
10717
11097
  addContent(
10718
11098
  "external_id",
10719
- import_zod6.z.string().describe("An optional external identifier for the item, e.g. an id from a source system."),
11099
+ import_zod7.z.string().describe("An optional external identifier for the item, e.g. an id from a source system."),
10720
11100
  false
10721
11101
  );
10722
11102
  }
10723
11103
  for (const field of context.fields ?? []) {
10724
11104
  if (field.type === "uuid") continue;
10725
11105
  if (field.calculated === true || field.editable === false) continue;
10726
- if (field.hidden === true) continue;
11106
+ if (isHiddenField(field)) continue;
10727
11107
  if (RESERVED_INPUT_KEYS.has(field.name)) continue;
10728
11108
  if (field.type === "file") {
10729
11109
  const allowed = (field.allowedFileTypes ?? []).map((ext) => ext.toLowerCase());
10730
11110
  const column = `${field.name}_s3key`;
10731
11111
  const allowedNote = allowed.length ? ` Allowed types: ${allowed.join(", ")}.` : "";
10732
- shape[field.name] = (field.required === true && mode === "create" ? import_zod6.z.string() : import_zod6.z.string().optional()).describe(
11112
+ shape[field.name] = (field.required === true && mode === "create" ? import_zod7.z.string() : import_zod7.z.string().optional()).describe(
10733
11113
  `The ${field.name} file: the bare name of a file from this session's files (as listed there, no path).${allowedNote}` + (mode === "update" ? " Omit to keep the current file." : "")
10734
11114
  );
10735
11115
  contentKeys.push(column);
@@ -10739,34 +11119,34 @@ var init_context_write_tools = __esm({
10739
11119
  let schema7;
10740
11120
  switch (field.type) {
10741
11121
  case "enum":
10742
- schema7 = import_zod6.z.string().describe(
11122
+ schema7 = import_zod7.z.string().describe(
10743
11123
  `The ${field.name} of the item. Must be one of: ${(field.enumValues ?? []).join(", ")}`
10744
11124
  );
10745
11125
  break;
10746
11126
  case "json":
10747
11127
  jsonFieldNames.push(field.name);
10748
- schema7 = field.schema ? loosenForTransport(field.schema).describe(`The ${field.name} of the item.`) : import_zod6.z.string().describe(`The ${field.name} of the item, as a valid JSON string.`);
11128
+ schema7 = field.schema ? loosenForTransport(field.schema).describe(`The ${field.name} of the item.`) : import_zod7.z.string().describe(`The ${field.name} of the item, as a valid JSON string.`);
10749
11129
  break;
10750
11130
  case "markdown":
10751
- schema7 = import_zod6.z.string().describe(`The ${field.name} of the item, as a valid Markdown string.`);
11131
+ schema7 = import_zod7.z.string().describe(`The ${field.name} of the item, as a valid Markdown string.`);
10752
11132
  break;
10753
11133
  case "date":
10754
- schema7 = import_zod6.z.string().describe(`The ${field.name} of the item, as an ISO-8601 date string.`);
11134
+ schema7 = import_zod7.z.string().describe(`The ${field.name} of the item, as an ISO-8601 date string.`);
10755
11135
  break;
10756
11136
  case "number":
10757
- schema7 = import_zod6.z.number().describe(`The ${field.name} of the item.`);
11137
+ schema7 = import_zod7.z.number().describe(`The ${field.name} of the item.`);
10758
11138
  break;
10759
11139
  case "boolean":
10760
- schema7 = import_zod6.z.boolean().describe(`The ${field.name} of the item.`);
11140
+ schema7 = import_zod7.z.boolean().describe(`The ${field.name} of the item.`);
10761
11141
  break;
10762
11142
  default:
10763
- schema7 = import_zod6.z.string().describe(`The ${field.name} of the item.`);
11143
+ schema7 = import_zod7.z.string().describe(`The ${field.name} of the item.`);
10764
11144
  break;
10765
11145
  }
10766
11146
  addContent(field.name, schema7, field.required === true);
10767
11147
  }
10768
11148
  if (mode === "update" && jsonFieldNames.length > 0 && !shape["merge"]) {
10769
- shape["merge"] = import_zod6.z.array(import_zod6.z.string()).optional().describe(
11149
+ shape["merge"] = import_zod7.z.array(import_zod7.z.string()).optional().describe(
10770
11150
  `Names of json fields in THIS call (choose from: ${jsonFieldNames.join(", ")}) whose given value should be merged into the stored value instead of replacing it: only the keys given are changed, every other stored key is kept, and giving a key an explicit null value deletes just that key. Omit a field's name here (or omit "merge" entirely) to replace its whole value, as normal. Every name must be spelled exactly as listed above AND be a field you are sending a value for in this same call; a name that is neither is refused, not ignored. Do not run two merges on the same item at once: a merge reads the stored value and writes the combined result in two steps with no lock, so overlapping merges can lose one of them.`
10771
11151
  );
10772
11152
  }
@@ -10836,7 +11216,7 @@ var init_context_write_tools = __esm({
10836
11216
  jobNote = (job) => job ? ` Processing/embeddings queued (job: ${job}); changes become searchable when the job completes.` : "";
10837
11217
  createContextWriteTools = (context, perms, skipApproval, deps = {}) => {
10838
11218
  const tools = [];
10839
- const segment = sanitizeName(context.id).slice(0, MAX_CONTEXT_SEGMENT);
11219
+ const segment = contextToolSegment(context);
10840
11220
  const contextLabel = context.description ? ` ${context.description}` : "";
10841
11221
  if (perms.create) {
10842
11222
  const { shape, contentKeys, fileFields } = buildWriteSchema(context, "create");
@@ -10848,12 +11228,12 @@ var init_context_write_tools = __esm({
10848
11228
  category: "knowledge_base_editing",
10849
11229
  description: `Create a new item in the "${context.name}" knowledge base.${contextLabel}${fileNote}`,
10850
11230
  type: "function",
10851
- inputSchema: import_zod6.z.object(shape),
11231
+ inputSchema: import_zod7.z.object(shape),
10852
11232
  config: [],
10853
11233
  needsApproval: !skipApproval,
10854
11234
  execute: async (params) => {
10855
11235
  const { user, exuluConfig } = params;
10856
- if (!user?.id) {
11236
+ if (treatAsGuest(params.req, user)) {
10857
11237
  return { result: "Knowledge base writes require an authenticated user." };
10858
11238
  }
10859
11239
  try {
@@ -10893,7 +11273,7 @@ var init_context_write_tools = __esm({
10893
11273
  if (perms.update) {
10894
11274
  const { shape, contentKeys, fileFields } = buildWriteSchema(context, "update");
10895
11275
  const fileNote = fileFields.length ? " File fields take the name of a file from this session's files; omit them to keep the current file." : "";
10896
- const NOT_FOUND = `Item not found in "${context.name}" or you don't have write access to it.`;
11276
+ const NOT_FOUND = itemNotFoundMessage(context, "write");
10897
11277
  tools.push(
10898
11278
  new ExuluTool({
10899
11279
  id: `update_${segment}_item`,
@@ -10901,12 +11281,12 @@ var init_context_write_tools = __esm({
10901
11281
  category: "knowledge_base_editing",
10902
11282
  description: `Update an existing item in the "${context.name}" knowledge base. Provide the item's id (or external_id) plus only the fields to change; omitted fields keep their values.${fileNote}`,
10903
11283
  type: "function",
10904
- inputSchema: import_zod6.z.object(shape),
11284
+ inputSchema: import_zod7.z.object(shape),
10905
11285
  config: [],
10906
11286
  needsApproval: !skipApproval,
10907
11287
  execute: async (params) => {
10908
11288
  const { user, exuluConfig } = params;
10909
- if (!user?.id) {
11289
+ if (treatAsGuest(params.req, user)) {
10910
11290
  return { result: "Knowledge base writes require an authenticated user." };
10911
11291
  }
10912
11292
  try {
@@ -10973,9 +11353,9 @@ Current item: ${JSON.stringify(summary)}`
10973
11353
  id: KB_EDITOR_TOOL_ID,
10974
11354
  name: "Knowledge base editor",
10975
11355
  category: "default",
10976
- description: "Let this agent create or update items in selected knowledge bases during chat, including attaching files from the session's files to file fields. Configure per knowledge base whether the agent may create and/or update items.",
11356
+ description: "Let this agent create or update items in selected knowledge bases during chat, including attaching files from the session's files to file fields. Configure per knowledge base whether the agent may create and/or update items. Per selected knowledge base the entry expands into create, update, get and find tools \u2014 writing implies reading, and the read tools never ask for approval.",
10977
11357
  type: "function",
10978
- inputSchema: import_zod6.z.object({}),
11358
+ inputSchema: import_zod7.z.object({}),
10979
11359
  config: [
10980
11360
  {
10981
11361
  name: "knowledge_bases",
@@ -10990,7 +11370,7 @@ Current item: ${JSON.stringify(summary)}`
10990
11370
  }
10991
11371
  ],
10992
11372
  execute: async () => ({
10993
- result: "This entry is configuration-only; Exulu expands it into per-context create/update tools at runtime."
11373
+ result: "This entry is configuration-only; Exulu expands it into per-context create, update, get and find tools at runtime."
10994
11374
  })
10995
11375
  });
10996
11376
  collectKbWriteTools = (agent, contexts, deps = {}) => {
@@ -11008,6 +11388,7 @@ Current item: ${JSON.stringify(summary)}`
11008
11388
  continue;
11009
11389
  }
11010
11390
  tools.push(...createContextWriteTools(context, perms, config.skipApproval, deps));
11391
+ tools.push(...createContextReadTools(context));
11011
11392
  }
11012
11393
  return tools;
11013
11394
  };
@@ -11183,13 +11564,13 @@ async function resolveSkill(db2, ref) {
11183
11564
  const byId = /^[0-9a-f-]{36}$/i.test(value) ? await db2("skills").where({ id: value }).first() : null;
11184
11565
  return byId ?? await resolveSkillByName(db2, value);
11185
11566
  }
11186
- var import_node_crypto4, import_zod7, MAX_FILES, MAX_FILE_BYTES, MAX_READ_BYTES, defaultIo, err2, safeSkillPath, contentTypeFor, yamlString, ensureFrontmatter, generalPrefix, relativePaths, normalizeFiles, createSkillAuthorTools, createSkillAuthorPickerTool, collectSkillAuthorTools;
11567
+ var import_node_crypto4, import_zod8, MAX_FILES, MAX_FILE_BYTES, MAX_READ_BYTES, defaultIo, err2, safeSkillPath, contentTypeFor, yamlString, ensureFrontmatter, generalPrefix, relativePaths, normalizeFiles, createSkillAuthorTools, createSkillAuthorPickerTool, collectSkillAuthorTools;
11187
11568
  var init_skill_author_tools = __esm({
11188
11569
  "src/templates/tools/skill-author-tools.ts"() {
11189
11570
  "use strict";
11190
11571
  init_cjs_shims();
11191
11572
  import_node_crypto4 = require("crypto");
11192
- import_zod7 = require("zod");
11573
+ import_zod8 = require("zod");
11193
11574
  init_tool();
11194
11575
  init_client();
11195
11576
  init_skill_access();
@@ -11276,7 +11657,7 @@ ${content.replace(/^\s+/, "")}`;
11276
11657
  config: [],
11277
11658
  needsApproval: false,
11278
11659
  description: "List the skills in this instance's library that the current user may read: name, description and current version. Use it before creating a skill to avoid duplicates, and before updating one.",
11279
- inputSchema: import_zod7.z.object({ query: import_zod7.z.string().optional().describe("Optional substring to filter by name or description") }),
11660
+ inputSchema: import_zod8.z.object({ query: import_zod8.z.string().optional().describe("Optional substring to filter by name or description") }),
11280
11661
  execute: async (params) => {
11281
11662
  const { user } = params;
11282
11663
  if (!user?.id) return err2("Skills require a signed-in user.");
@@ -11302,9 +11683,9 @@ ${content.replace(/^\s+/, "")}`;
11302
11683
  config: [],
11303
11684
  needsApproval: false,
11304
11685
  description: "Read a skill the user may access: its file list and the content of SKILL.md, or of one file by path. Use it before updating a skill so you change only what must change.",
11305
- inputSchema: import_zod7.z.object({
11306
- skill: import_zod7.z.string().describe("The skill's name or id"),
11307
- path: import_zod7.z.string().optional().describe("A file path inside the skill to read instead of SKILL.md")
11686
+ inputSchema: import_zod8.z.object({
11687
+ skill: import_zod8.z.string().describe("The skill's name or id"),
11688
+ path: import_zod8.z.string().optional().describe("A file path inside the skill to read instead of SKILL.md")
11308
11689
  }),
11309
11690
  execute: async (params) => {
11310
11691
  const { user, exuluConfig } = params;
@@ -11349,10 +11730,10 @@ ${content}`
11349
11730
  needsApproval: !config.skipApproval,
11350
11731
  needsApprovalFn: approvalFn,
11351
11732
  description: "Propose a NEW skill from a procedure the user just completed. Give it a short name, a one-line description, and its files: a SKILL.md with frontmatter and clear steps, plus reference files only where useful. The user confirms name, description and visibility on a card before anything is created; never claim it exists until this tool returns skill_created.",
11352
- inputSchema: import_zod7.z.object({
11353
- name: import_zod7.z.string().describe("Short, specific skill name (e.g. 'quarterly-report-from-crm')"),
11354
- description: import_zod7.z.string().describe("One line: what the skill does and when to use it"),
11355
- files: import_zod7.z.array(import_zod7.z.object({ path: import_zod7.z.string().describe("Relative path inside the skill, e.g. SKILL.md or references/checklist.md"), content: import_zod7.z.string() })).min(1).describe("The skill's files; SKILL.md is required")
11733
+ inputSchema: import_zod8.z.object({
11734
+ name: import_zod8.z.string().describe("Short, specific skill name (e.g. 'quarterly-report-from-crm')"),
11735
+ description: import_zod8.z.string().describe("One line: what the skill does and when to use it"),
11736
+ files: import_zod8.z.array(import_zod8.z.object({ path: import_zod8.z.string().describe("Relative path inside the skill, e.g. SKILL.md or references/checklist.md"), content: import_zod8.z.string() })).min(1).describe("The skill's files; SKILL.md is required")
11356
11737
  }),
11357
11738
  execute: async (params) => {
11358
11739
  const { user, exuluConfig } = params;
@@ -11418,12 +11799,12 @@ ${content}`
11418
11799
  needsApproval: !config.skipApproval,
11419
11800
  needsApprovalFn: approvalFn,
11420
11801
  description: "Publish a new version of an existing skill the user may write: pass only the files to add or replace (full content each) and, optionally, paths to remove. Unchanged files carry over. Read the skill first with skill_read. The user confirms on a card; never claim the change happened until this tool returns skill_updated.",
11421
- inputSchema: import_zod7.z.object({
11422
- skill: import_zod7.z.string().describe("The skill's name or id"),
11423
- files: import_zod7.z.array(import_zod7.z.object({ path: import_zod7.z.string(), content: import_zod7.z.string() })).optional().describe("Files to add or replace, full content each"),
11424
- deletePaths: import_zod7.z.array(import_zod7.z.string()).optional().describe("Paths to remove in the new version"),
11425
- description: import_zod7.z.string().optional().describe("A new one-line description, if it changed"),
11426
- label: import_zod7.z.string().optional().describe("A short label for this version, e.g. 'Added the review checklist'")
11802
+ inputSchema: import_zod8.z.object({
11803
+ skill: import_zod8.z.string().describe("The skill's name or id"),
11804
+ files: import_zod8.z.array(import_zod8.z.object({ path: import_zod8.z.string(), content: import_zod8.z.string() })).optional().describe("Files to add or replace, full content each"),
11805
+ deletePaths: import_zod8.z.array(import_zod8.z.string()).optional().describe("Paths to remove in the new version"),
11806
+ description: import_zod8.z.string().optional().describe("A new one-line description, if it changed"),
11807
+ label: import_zod8.z.string().optional().describe("A short label for this version, e.g. 'Added the review checklist'")
11427
11808
  }),
11428
11809
  execute: async (params) => {
11429
11810
  const { user, exuluConfig } = params;
@@ -11500,7 +11881,7 @@ ${content}`
11500
11881
  category: "default",
11501
11882
  description: "Let this agent create skills and publish new versions of existing ones from the chat, with the user's consent on a card. Adds a system-prompt hint to offer a skill only after complex, recurring, multi-step work \u2014 never for a single question or correction.",
11502
11883
  type: "function",
11503
- inputSchema: import_zod7.z.object({}),
11884
+ inputSchema: import_zod8.z.object({}),
11504
11885
  config: [
11505
11886
  { name: "create", description: "The agent may propose new skills.", type: "boolean", default: true },
11506
11887
  { name: "update", description: "The agent may publish new versions of skills the user can write.", type: "boolean", default: true },
@@ -13279,9 +13660,9 @@ Probe error: ${probe.reason ?? "(no detail)"}`
13279
13660
  });
13280
13661
  const writeFileTool = (0, import_ai2.tool)({
13281
13662
  description: 'Write content to a file in the sandbox. Creates parent directories if needed. Paths are always resolved against the session sandbox root \u2014 both relative paths ("skills/<Skill name>/SKILL.md") and leading-slash paths ("/skills/<Skill name>/SKILL.md") work and reach the same file. When the path is under the session artifact tree, the file is also uploaded to S3 and a short-lived presigned URL is returned in the tool output.',
13282
- inputSchema: import_zod8.z.object({
13283
- path: import_zod8.z.string().describe("The path where the file should be written. Relative paths and leading-slash paths are both resolved against the session sandbox root."),
13284
- content: import_zod8.z.string().describe("The content to write to the file")
13663
+ inputSchema: import_zod9.z.object({
13664
+ path: import_zod9.z.string().describe("The path where the file should be written. Relative paths and leading-slash paths are both resolved against the session sandbox root."),
13665
+ content: import_zod9.z.string().describe("The content to write to the file")
13285
13666
  }),
13286
13667
  execute: async ({ path: path4, content }) => {
13287
13668
  const resolvedPath = resolveSessionPath(path4, sessionDir);
@@ -13300,8 +13681,8 @@ Probe error: ${probe.reason ?? "(no detail)"}`
13300
13681
  });
13301
13682
  const readFileTool = (0, import_ai2.tool)({
13302
13683
  description: 'Read the contents of a file from the sandbox. Paths are always resolved against the session sandbox root \u2014 both relative paths ("skills/<Skill name>/SKILL.md") and leading-slash paths ("/skills/<Skill name>/SKILL.md") work and reach the same file. Skills live in a folder per skill: "skills/<Skill name>/SKILL.md", never "skills/<Skill name>.md". If the file does not exist, the error message is surfaced verbatim.',
13303
- inputSchema: import_zod8.z.object({
13304
- path: import_zod8.z.string().describe("The path of the file to read. Relative paths and leading-slash paths are both resolved against the session sandbox root.")
13684
+ inputSchema: import_zod9.z.object({
13685
+ path: import_zod9.z.string().describe("The path of the file to read. Relative paths and leading-slash paths are both resolved against the session sandbox root.")
13305
13686
  }),
13306
13687
  execute: async ({ path: path4 }) => {
13307
13688
  const resolvedPath = resolveSessionPath(path4, sessionDir);
@@ -13318,8 +13699,8 @@ Probe error: ${probe.reason ?? "(no detail)"}`
13318
13699
  const originalBashTool = tools.bash;
13319
13700
  const bashTool = (0, import_ai2.tool)({
13320
13701
  description: originalBashTool.description ?? "",
13321
- inputSchema: import_zod8.z.object({
13322
- command: import_zod8.z.string().describe("The bash command to execute.")
13702
+ inputSchema: import_zod9.z.object({
13703
+ command: import_zod9.z.string().describe("The bash command to execute.")
13323
13704
  }),
13324
13705
  execute: async (args, opts) => {
13325
13706
  const before = persistenceEnabled ? await snapshotSessionArtifacts() : null;
@@ -13394,7 +13775,7 @@ ${lines.join("\n")}`;
13394
13775
  sandboxCache.set(sessionId, { handle, installedSkills });
13395
13776
  return handle;
13396
13777
  }
13397
- var import_sandbox_runtime, import_promises2, import_node_fs6, import_node_path5, import_node_child_process4, import_node_util3, import_bash_tool, import_ai2, import_zod8, import_crypto_js3, getAllExuluVariables, execAsync3, backendSecretFiles, EXEC_MAX_BUFFER, litellmSecretNamesCache, litellmConfigSecretNames, sandboxProbePromise, SANDBOX_FALLBACK_INSTRUCTIONS, degradedModeLogged, sandboxCache;
13778
+ var import_sandbox_runtime, import_promises2, import_node_fs6, import_node_path5, import_node_child_process4, import_node_util3, import_bash_tool, import_ai2, import_zod9, import_crypto_js3, getAllExuluVariables, execAsync3, backendSecretFiles, EXEC_MAX_BUFFER, litellmSecretNamesCache, litellmConfigSecretNames, sandboxProbePromise, SANDBOX_FALLBACK_INSTRUCTIONS, degradedModeLogged, sandboxCache;
13398
13779
  var init_create_sandbox = __esm({
13399
13780
  "ee/invoke-skills/create-sandbox.ts"() {
13400
13781
  "use strict";
@@ -13416,7 +13797,7 @@ var init_create_sandbox = __esm({
13416
13797
  init_skill_sandbox();
13417
13798
  import_bash_tool = require("bash-tool");
13418
13799
  import_ai2 = require("ai");
13419
- import_zod8 = require("zod");
13800
+ import_zod9 = require("zod");
13420
13801
  init_variable();
13421
13802
  import_crypto_js3 = __toESM(require("crypto-js"), 1);
13422
13803
  init_client();
@@ -13704,12 +14085,12 @@ var init_auth_tool_model_output = __esm({
13704
14085
  });
13705
14086
 
13706
14087
  // src/templates/tools/session-file-read-tool.ts
13707
- var import_zod9, DEFAULT_LIMIT, MAX_CONTENT_CHARS, SESSION_FILE_READ_TOOL_NAME, createSessionFileReadTool;
14088
+ var import_zod10, DEFAULT_LIMIT, MAX_CONTENT_CHARS, SESSION_FILE_READ_TOOL_NAME, createSessionFileReadTool;
13708
14089
  var init_session_file_read_tool = __esm({
13709
14090
  "src/templates/tools/session-file-read-tool.ts"() {
13710
14091
  "use strict";
13711
14092
  init_cjs_shims();
13712
- import_zod9 = require("zod");
14093
+ import_zod10 = require("zod");
13713
14094
  init_session_files();
13714
14095
  init_tool();
13715
14096
  init_uppy();
@@ -13765,10 +14146,10 @@ var init_session_file_read_tool = __esm({
13765
14146
  name: SESSION_FILE_READ_TOOL_NAME,
13766
14147
  needsApproval: false,
13767
14148
  description: "Read a line range from a file stored in this session's files \u2014 including offloaded tool outputs (tool-output-*.txt) and uploaded documents. Use offset (1-based line number) and limit to page through large files instead of reading everything at once.",
13768
- inputSchema: import_zod9.z.object({
13769
- filename: import_zod9.z.string().describe('Exact session file name as referenced in a truncation notice, e.g. "tool-output-web_search-a1b2c3d4.txt"'),
13770
- offset: import_zod9.z.number().int().min(1).optional().describe("1-based first line to read (default 1)"),
13771
- limit: import_zod9.z.number().int().min(1).max(1e3).optional().describe(`Number of lines to read (default ${DEFAULT_LIMIT})`)
14149
+ inputSchema: import_zod10.z.object({
14150
+ filename: import_zod10.z.string().describe('Exact session file name as referenced in a truncation notice, e.g. "tool-output-web_search-a1b2c3d4.txt"'),
14151
+ offset: import_zod10.z.number().int().min(1).optional().describe("1-based first line to read (default 1)"),
14152
+ limit: import_zod10.z.number().int().min(1).max(1e3).optional().describe(`Number of lines to read (default ${DEFAULT_LIMIT})`)
13772
14153
  }),
13773
14154
  type: "function",
13774
14155
  category: "session",
@@ -14372,15 +14753,15 @@ If the page contains a flow-chart, schematic, technical drawing or control board
14372
14753
  const result = await (0, import_ai3.generateText)({
14373
14754
  model,
14374
14755
  output: import_ai3.Output.object({
14375
- schema: import_zod10.z.object({
14376
- needs_correction: import_zod10.z.boolean(),
14377
- corrected_text: import_zod10.z.string().nullable(),
14378
- current_page_table: import_zod10.z.object({
14379
- headers: import_zod10.z.array(import_zod10.z.string()),
14380
- is_continuation: import_zod10.z.boolean()
14756
+ schema: import_zod11.z.object({
14757
+ needs_correction: import_zod11.z.boolean(),
14758
+ corrected_text: import_zod11.z.string().nullable(),
14759
+ current_page_table: import_zod11.z.object({
14760
+ headers: import_zod11.z.array(import_zod11.z.string()),
14761
+ is_continuation: import_zod11.z.boolean()
14381
14762
  }).nullable(),
14382
- confidence: import_zod10.z.enum(["high", "medium", "low"]),
14383
- reasoning: import_zod10.z.string()
14763
+ confidence: import_zod11.z.enum(["high", "medium", "low"]),
14764
+ reasoning: import_zod11.z.string()
14384
14765
  })
14385
14766
  }),
14386
14767
  messages: [
@@ -14817,7 +15198,7 @@ async function documentProcessor({
14817
15198
  }
14818
15199
  }
14819
15200
  }
14820
- var fs2, path3, import_ai3, import_zod10, import_p_limit, import_crypto3, mammoth, import_turndown, import_word_extractor, import_officeparser, import_liteparse, loadFile;
15201
+ var fs2, path3, import_ai3, import_zod11, import_p_limit, import_crypto3, mammoth, import_turndown, import_word_extractor, import_officeparser, import_liteparse, loadFile;
14821
15202
  var init_doc_processor = __esm({
14822
15203
  "ee/python/documents/processing/doc_processor.ts"() {
14823
15204
  "use strict";
@@ -14825,7 +15206,7 @@ var init_doc_processor = __esm({
14825
15206
  fs2 = __toESM(require("fs"), 1);
14826
15207
  path3 = __toESM(require("path"), 1);
14827
15208
  import_ai3 = require("ai");
14828
- import_zod10 = require("zod");
15209
+ import_zod11 = require("zod");
14829
15210
  import_p_limit = __toESM(require("p-limit"), 1);
14830
15211
  import_crypto3 = require("crypto");
14831
15212
  init_with_retry();
@@ -15016,12 +15397,12 @@ function binaryDocumentBashHint(command, stdout, stderr) {
15016
15397
  const [, file] = match;
15017
15398
  return `Note: "${file}" is a binary document \u2014 grep/cat/text tools cannot read the text inside it, so a silent or garbled result does not mean the content isn't there. Use parse_document to extract its text first, then search or read within that extracted text instead of the original file.`;
15018
15399
  }
15019
- var import_zod11, import_node_path7, import_officeparser3, DEFAULT_LIMIT2, MAX_CONTENT_CHARS2, PARSE_DOCUMENT_TOOL_NAME, MIN_CHARS_PER_PAGE, OFFICE_EXTENSIONS, pagesPattern, BINARY_DOCUMENT_EXTENSION_PATTERN, createParseDocumentTool;
15400
+ var import_zod12, import_node_path7, import_officeparser3, DEFAULT_LIMIT2, MAX_CONTENT_CHARS2, PARSE_DOCUMENT_TOOL_NAME, MIN_CHARS_PER_PAGE, OFFICE_EXTENSIONS, pagesPattern, BINARY_DOCUMENT_EXTENSION_PATTERN, createParseDocumentTool;
15020
15401
  var init_parse_document_tool = __esm({
15021
15402
  "src/templates/tools/parse-document-tool.ts"() {
15022
15403
  "use strict";
15023
15404
  init_cjs_shims();
15024
- import_zod11 = require("zod");
15405
+ import_zod12 = require("zod");
15025
15406
  import_node_path7 = require("path");
15026
15407
  import_officeparser3 = require("officeparser");
15027
15408
  init_tool();
@@ -15157,11 +15538,11 @@ ${text.trim()}`).join("\n");
15157
15538
  name: PARSE_DOCUMENT_TOOL_NAME,
15158
15539
  needsApproval: false,
15159
15540
  description: `Extract the text of an uploaded PDF or Office document from this session's files, with "--- page N ---" markers for PDFs so you can locate content by page. Free and fast (no OCR): works only on documents with a real text layer. To SEE a page or an image inside a document, use view_document_page.`,
15160
- inputSchema: import_zod11.z.object({
15161
- filename: import_zod11.z.string().describe('Exact session file name, e.g. "report.pdf"'),
15162
- pages: import_zod11.z.string().optional().describe('PDF page or range to extract, e.g. "2" or "1-5" (default: all pages) (PDF only)'),
15163
- offset: import_zod11.z.number().int().min(1).optional().describe("1-based first output line to read (default 1)"),
15164
- limit: import_zod11.z.number().int().min(1).max(1e3).optional().describe(`Number of lines to read (default ${DEFAULT_LIMIT2})`)
15541
+ inputSchema: import_zod12.z.object({
15542
+ filename: import_zod12.z.string().describe('Exact session file name, e.g. "report.pdf"'),
15543
+ pages: import_zod12.z.string().optional().describe('PDF page or range to extract, e.g. "2" or "1-5" (default: all pages) (PDF only)'),
15544
+ offset: import_zod12.z.number().int().min(1).optional().describe("1-based first output line to read (default 1)"),
15545
+ limit: import_zod12.z.number().int().min(1).max(1e3).optional().describe(`Number of lines to read (default ${DEFAULT_LIMIT2})`)
15165
15546
  }),
15166
15547
  type: "function",
15167
15548
  category: "session",
@@ -15433,12 +15814,12 @@ var init_tool_image_attachments = __esm({
15433
15814
  });
15434
15815
 
15435
15816
  // src/templates/tools/view-document-page-tool.ts
15436
- var import_zod12, import_node_path9, VIEW_DOCUMENT_PAGE_TOOL_NAME, MAX_IMAGE_BYTES, SCALE_PRIMARY, SCALE_FALLBACK, IMAGE_MEDIA_TYPES, OFFICE_EXTENSIONS2, createViewDocumentPageTool;
15817
+ var import_zod13, import_node_path9, VIEW_DOCUMENT_PAGE_TOOL_NAME, MAX_IMAGE_BYTES, SCALE_PRIMARY, SCALE_FALLBACK, IMAGE_MEDIA_TYPES, OFFICE_EXTENSIONS2, createViewDocumentPageTool;
15437
15818
  var init_view_document_page_tool = __esm({
15438
15819
  "src/templates/tools/view-document-page-tool.ts"() {
15439
15820
  "use strict";
15440
15821
  init_cjs_shims();
15441
- import_zod12 = require("zod");
15822
+ import_zod13 = require("zod");
15442
15823
  init_session_files();
15443
15824
  import_node_path9 = require("path");
15444
15825
  init_tool();
@@ -15566,9 +15947,9 @@ var init_view_document_page_tool = __esm({
15566
15947
  name: VIEW_DOCUMENT_PAGE_TOOL_NAME,
15567
15948
  needsApproval: false,
15568
15949
  description: "LOOK at a page of an uploaded PDF/Office document, or at an uploaded image, from this session's files. The rendered image is attached as a user message directly after this tool result so you can visually analyze photos, charts, scans, and layouts. Use parse_document first to find which page you need. Requires a vision-capable model.",
15569
- inputSchema: import_zod12.z.object({
15570
- filename: import_zod12.z.string().describe('Exact session file name, e.g. "report.pdf" or "screenshot.png"'),
15571
- page: import_zod12.z.number().int().min(1).optional().describe("Page number to render (default 1; ignored for image files)")
15950
+ inputSchema: import_zod13.z.object({
15951
+ filename: import_zod13.z.string().describe('Exact session file name, e.g. "report.pdf" or "screenshot.png"'),
15952
+ page: import_zod13.z.number().int().min(1).optional().describe("Page number to render (default 1; ignored for image files)")
15572
15953
  }),
15573
15954
  type: "function",
15574
15955
  category: "session",
@@ -15798,8 +16179,8 @@ var init_convert_exulu_tools_to_ai_sdk_tools = __esm({
15798
16179
  let projectScope;
15799
16180
  if (project && !disabled.has("agentic_context_search")) {
15800
16181
  const { db: db2 } = await postgresClient();
15801
- const projectRow = await db2.from("projects").where("id", project).first();
15802
- let rawItems = projectRow?.project_items;
16182
+ const projectRow2 = await db2.from("projects").where("id", project).first();
16183
+ let rawItems = projectRow2?.project_items;
15803
16184
  if (typeof rawItems === "string") {
15804
16185
  try {
15805
16186
  rawItems = JSON.parse(rawItems);
@@ -15807,12 +16188,12 @@ var init_convert_exulu_tools_to_ai_sdk_tools = __esm({
15807
16188
  rawItems = void 0;
15808
16189
  }
15809
16190
  }
15810
- if (projectRow && Array.isArray(rawItems) && rawItems.length > 0) {
16191
+ if (projectRow2 && Array.isArray(rawItems) && rawItems.length > 0) {
15811
16192
  projectScope = {
15812
- id: projectRow.id,
15813
- name: projectRow.name,
15814
- description: projectRow.description ?? void 0,
15815
- customInstructions: projectRow.custom_instructions ?? void 0,
16193
+ id: projectRow2.id,
16194
+ name: projectRow2.name,
16195
+ description: projectRow2.description ?? void 0,
16196
+ customInstructions: projectRow2.custom_instructions ?? void 0,
15816
16197
  items: rawItems,
15817
16198
  kbProfileDefaults: buildProjectKbProfileDefaults(rawItems)
15818
16199
  };
@@ -16199,13 +16580,13 @@ var init_convert_exulu_tools_to_ai_sdk_tools = __esm({
16199
16580
  });
16200
16581
 
16201
16582
  // src/exulu/tool.ts
16202
- var import_ai4, import_zod13, import_node_crypto7, PUBLIC_TOOL_TYPES, ExuluTool;
16583
+ var import_ai4, import_zod14, import_node_crypto7, PUBLIC_TOOL_TYPES, ExuluTool;
16203
16584
  var init_tool = __esm({
16204
16585
  "src/exulu/tool.ts"() {
16205
16586
  "use strict";
16206
16587
  init_cjs_shims();
16207
16588
  import_ai4 = require("ai");
16208
- import_zod13 = require("zod");
16589
+ import_zod14 = require("zod");
16209
16590
  init_sanitize_name();
16210
16591
  import_node_crypto7 = require("crypto");
16211
16592
  init_singleton();
@@ -16270,7 +16651,7 @@ var init_tool = __esm({
16270
16651
  this.type = type;
16271
16652
  this.tool = (0, import_ai4.tool)({
16272
16653
  description,
16273
- inputSchema: inputSchema || import_zod13.z.object({}),
16654
+ inputSchema: inputSchema || import_zod14.z.object({}),
16274
16655
  execute: authentication2 ? wrapExecuteWithAuth(id, authentication2, execute2) : execute2
16275
16656
  });
16276
16657
  }
@@ -16564,92 +16945,92 @@ function effectiveKbSettings(profile, ctx) {
16564
16945
  keywordPrefilter: preset.keywordPrefilter
16565
16946
  };
16566
16947
  }
16567
- var import_zod14, KB_KINDS, DEFAULT_PREFILTER_CUTOFF, RRF_K, CHUNK_GROUP_MAX, kbProfileSchema, knowledgeBasesSchema, routingRuleSchema, routingSchema, identifierSetSchema, vocabularySchema, memorySchema, tuningSchema, claimCheckSchema, boolVal, strVal, KIND_PRESETS;
16948
+ var import_zod15, KB_KINDS, DEFAULT_PREFILTER_CUTOFF, RRF_K, CHUNK_GROUP_MAX, kbProfileSchema, knowledgeBasesSchema, routingRuleSchema, routingSchema, identifierSetSchema, vocabularySchema, memorySchema, tuningSchema, claimCheckSchema, boolVal, strVal, KIND_PRESETS;
16568
16949
  var init_config3 = __esm({
16569
16950
  "ee/agentic-retrieval/pipeline/config.ts"() {
16570
16951
  "use strict";
16571
16952
  init_cjs_shims();
16572
- import_zod14 = require("zod");
16953
+ import_zod15 = require("zod");
16573
16954
  init_types2();
16574
16955
  KB_KINDS = ["documents", "conversations", "records"];
16575
16956
  DEFAULT_PREFILTER_CUTOFF = 2.5;
16576
16957
  RRF_K = 60;
16577
16958
  CHUNK_GROUP_MAX = 10;
16578
- kbProfileSchema = import_zod14.z.object({
16579
- enabled: import_zod14.z.boolean().default(true),
16580
- kind: import_zod14.z.enum(KB_KINDS).default("documents"),
16581
- instructions: import_zod14.z.string().default(""),
16582
- overrides: import_zod14.z.object({
16583
- limit: import_zod14.z.number().int().positive().optional(),
16584
- expand: import_zod14.z.number().int().min(0).optional(),
16585
- multiQuery: import_zod14.z.boolean().optional(),
16586
- hyde: import_zod14.z.boolean().optional()
16959
+ kbProfileSchema = import_zod15.z.object({
16960
+ enabled: import_zod15.z.boolean().default(true),
16961
+ kind: import_zod15.z.enum(KB_KINDS).default("documents"),
16962
+ instructions: import_zod15.z.string().default(""),
16963
+ overrides: import_zod15.z.object({
16964
+ limit: import_zod15.z.number().int().positive().optional(),
16965
+ expand: import_zod15.z.number().int().min(0).optional(),
16966
+ multiQuery: import_zod15.z.boolean().optional(),
16967
+ hyde: import_zod15.z.boolean().optional()
16587
16968
  }).default({})
16588
16969
  });
16589
- knowledgeBasesSchema = import_zod14.z.record(import_zod14.z.string(), kbProfileSchema);
16590
- routingRuleSchema = import_zod14.z.object({
16591
- id: import_zod14.z.string(),
16592
- label: import_zod14.z.string(),
16593
- description: import_zod14.z.string(),
16594
- main: import_zod14.z.array(import_zod14.z.string()),
16595
- fallback: import_zod14.z.array(import_zod14.z.string()).default([])
16970
+ knowledgeBasesSchema = import_zod15.z.record(import_zod15.z.string(), kbProfileSchema);
16971
+ routingRuleSchema = import_zod15.z.object({
16972
+ id: import_zod15.z.string(),
16973
+ label: import_zod15.z.string(),
16974
+ description: import_zod15.z.string(),
16975
+ main: import_zod15.z.array(import_zod15.z.string()),
16976
+ fallback: import_zod15.z.array(import_zod15.z.string()).default([])
16596
16977
  });
16597
- routingSchema = import_zod14.z.object({ rules: import_zod14.z.array(routingRuleSchema).default([]) });
16598
- identifierSetSchema = import_zod14.z.object({
16599
- name: import_zod14.z.string(),
16600
- description: import_zod14.z.string().default(""),
16601
- examples: import_zod14.z.array(import_zod14.z.string()).default([]),
16602
- strategy: import_zod14.z.enum(["fuzzy", "exact"]),
16603
- contexts: import_zod14.z.array(import_zod14.z.string()).default([])
16978
+ routingSchema = import_zod15.z.object({ rules: import_zod15.z.array(routingRuleSchema).default([]) });
16979
+ identifierSetSchema = import_zod15.z.object({
16980
+ name: import_zod15.z.string(),
16981
+ description: import_zod15.z.string().default(""),
16982
+ examples: import_zod15.z.array(import_zod15.z.string()).default([]),
16983
+ strategy: import_zod15.z.enum(["fuzzy", "exact"]),
16984
+ contexts: import_zod15.z.array(import_zod15.z.string()).default([])
16604
16985
  });
16605
- vocabularySchema = import_zod14.z.object({
16606
- glossary: import_zod14.z.array(import_zod14.z.object({ term: import_zod14.z.string(), meaning: import_zod14.z.string() })).default([]),
16607
- identifiers: import_zod14.z.array(identifierSetSchema).default([]),
16608
- rewrites: import_zod14.z.array(import_zod14.z.object({ find: import_zod14.z.string(), replace: import_zod14.z.string() })).default([]),
16609
- styleHint: import_zod14.z.string().default("")
16986
+ vocabularySchema = import_zod15.z.object({
16987
+ glossary: import_zod15.z.array(import_zod15.z.object({ term: import_zod15.z.string(), meaning: import_zod15.z.string() })).default([]),
16988
+ identifiers: import_zod15.z.array(identifierSetSchema).default([]),
16989
+ rewrites: import_zod15.z.array(import_zod15.z.object({ find: import_zod15.z.string(), replace: import_zod15.z.string() })).default([]),
16990
+ styleHint: import_zod15.z.string().default("")
16610
16991
  });
16611
- memorySchema = import_zod14.z.object({
16612
- enabled: import_zod14.z.boolean().default(true),
16613
- override: import_zod14.z.boolean().default(false),
16614
- filePrioritization: import_zod14.z.boolean().default(false),
16615
- queryAugmentation: import_zod14.z.boolean().default(true)
16992
+ memorySchema = import_zod15.z.object({
16993
+ enabled: import_zod15.z.boolean().default(true),
16994
+ override: import_zod15.z.boolean().default(false),
16995
+ filePrioritization: import_zod15.z.boolean().default(false),
16996
+ queryAugmentation: import_zod15.z.boolean().default(true)
16616
16997
  });
16617
- tuningSchema = import_zod14.z.object({
16618
- topK: import_zod14.z.number().int().positive().default(5),
16619
- fallbackThreshold: import_zod14.z.number().min(0).max(1).default(0.95),
16620
- pinBoost: import_zod14.z.number().min(0).max(1).default(0.15),
16621
- identifierBoost: import_zod14.z.number().min(0).max(1).default(0.15),
16622
- pageWindow: import_zod14.z.number().int().min(0).default(1),
16623
- maxQueriesPerContext: import_zod14.z.number().int().positive().default(5),
16998
+ tuningSchema = import_zod15.z.object({
16999
+ topK: import_zod15.z.number().int().positive().default(5),
17000
+ fallbackThreshold: import_zod15.z.number().min(0).max(1).default(0.95),
17001
+ pinBoost: import_zod15.z.number().min(0).max(1).default(0.15),
17002
+ identifierBoost: import_zod15.z.number().min(0).max(1).default(0.15),
17003
+ pageWindow: import_zod15.z.number().int().min(0).default(1),
17004
+ maxQueriesPerContext: import_zod15.z.number().int().positive().default(5),
16624
17005
  /**
16625
17006
  * Orchestration engine. "v1" is the sequential flow every agent ran before 2026-09;
16626
17007
  * "v2" merges the phase-1 LLM hops and runs identifier pins in parallel. Per agent,
16627
17008
  * so a candidate agent can run v2 while the production agent stays on v1.
16628
17009
  */
16629
- engine: import_zod14.z.enum(["v1", "v2"]).default("v1"),
17010
+ engine: import_zod15.z.enum(["v1", "v2"]).default("v1"),
16630
17011
  /** v2 sub-features; each can be switched off on its own to bisect a regression. */
16631
- v2: import_zod14.z.object({
16632
- mergedMemoryCall: import_zod14.z.boolean().default(true),
16633
- mergedRoutingCall: import_zod14.z.boolean().default(true),
16634
- parallelPins: import_zod14.z.boolean().default(true)
17012
+ v2: import_zod15.z.object({
17013
+ mergedMemoryCall: import_zod15.z.boolean().default(true),
17014
+ mergedRoutingCall: import_zod15.z.boolean().default(true),
17015
+ parallelPins: import_zod15.z.boolean().default(true)
16635
17016
  }).default({ mergedMemoryCall: true, mergedRoutingCall: true, parallelPins: true })
16636
17017
  });
16637
- claimCheckSchema = import_zod14.z.object({
16638
- enabled: import_zod14.z.boolean().default(false),
17018
+ claimCheckSchema = import_zod15.z.object({
17019
+ enabled: import_zod15.z.boolean().default(false),
16639
17020
  /** Empty = fall back to the agent's utility model, then the agent's model. */
16640
- model: import_zod14.z.string().default(""),
16641
- fidelity: import_zod14.z.enum(["fast", "paper"]).default(CLAIM_CHECK_DEFAULTS.fidelity),
16642
- completions: import_zod14.z.number().int().min(1).max(3).default(CLAIM_CHECK_DEFAULTS.completions),
16643
- reRetrieve: import_zod14.z.boolean().default(CLAIM_CHECK_DEFAULTS.reRetrieve),
16644
- thresholds: import_zod14.z.object({
16645
- warn: import_zod14.z.number().min(0).max(1).default(CLAIM_CHECK_DEFAULTS.thresholds.warn),
16646
- alert: import_zod14.z.number().min(0).max(1).default(CLAIM_CHECK_DEFAULTS.thresholds.alert)
17021
+ model: import_zod15.z.string().default(""),
17022
+ fidelity: import_zod15.z.enum(["fast", "paper"]).default(CLAIM_CHECK_DEFAULTS.fidelity),
17023
+ completions: import_zod15.z.number().int().min(1).max(3).default(CLAIM_CHECK_DEFAULTS.completions),
17024
+ reRetrieve: import_zod15.z.boolean().default(CLAIM_CHECK_DEFAULTS.reRetrieve),
17025
+ thresholds: import_zod15.z.object({
17026
+ warn: import_zod15.z.number().min(0).max(1).default(CLAIM_CHECK_DEFAULTS.thresholds.warn),
17027
+ alert: import_zod15.z.number().min(0).max(1).default(CLAIM_CHECK_DEFAULTS.thresholds.alert)
16647
17028
  }).default(CLAIM_CHECK_DEFAULTS.thresholds),
16648
- showToExternalUsers: import_zod14.z.boolean().default(false),
16649
- caps: import_zod14.z.object({
16650
- maxSentences: import_zod14.z.number().int().positive().default(CLAIM_CHECK_DEFAULTS.caps.maxSentences),
16651
- maxClaims: import_zod14.z.number().int().positive().default(CLAIM_CHECK_DEFAULTS.caps.maxClaims),
16652
- maxReRetrievals: import_zod14.z.number().int().min(0).default(CLAIM_CHECK_DEFAULTS.caps.maxReRetrievals)
17029
+ showToExternalUsers: import_zod15.z.boolean().default(false),
17030
+ caps: import_zod15.z.object({
17031
+ maxSentences: import_zod15.z.number().int().positive().default(CLAIM_CHECK_DEFAULTS.caps.maxSentences),
17032
+ maxClaims: import_zod15.z.number().int().positive().default(CLAIM_CHECK_DEFAULTS.caps.maxClaims),
17033
+ maxReRetrievals: import_zod15.z.number().int().min(0).default(CLAIM_CHECK_DEFAULTS.caps.maxReRetrievals)
16653
17034
  }).default(CLAIM_CHECK_DEFAULTS.caps)
16654
17035
  });
16655
17036
  boolVal = (v) => v === true || v === "true" || v === 1;
@@ -16985,9 +17366,9 @@ async function resolveIdentifierPins({
16985
17366
  model,
16986
17367
  system: set.strategy === "exact" ? EXACT_EXTRACTION_PROMPT(set) : FUZZY_EXTRACTION_PROMPT(set),
16987
17368
  messages: [{ role: "user", content: question }],
16988
- schema: import_zod15.z.object({
16989
- hasMatches: import_zod15.z.boolean(),
16990
- matches: import_zod15.z.array(import_zod15.z.string()).optional()
17369
+ schema: import_zod16.z.object({
17370
+ hasMatches: import_zod16.z.boolean(),
17371
+ matches: import_zod16.z.array(import_zod16.z.string()).optional()
16991
17372
  })
16992
17373
  });
16993
17374
  if (!output?.hasMatches || !output.matches?.length) return;
@@ -17035,13 +17416,13 @@ async function resolveIdentifierPins({
17035
17416
  );
17036
17417
  return { pinsByContext, exactPinsByContext, steps };
17037
17418
  }
17038
- var import_fuse, import_zod15, SUPPLEMENT_MIN_TOKEN_LENGTH, SUPPLEMENT_BUDGET, SUPPLEMENT_BUDGET_WIDE, itemCaches, ensureItemsCache, FUZZY_EXTRACTION_PROMPT, EXACT_EXTRACTION_PROMPT;
17419
+ var import_fuse, import_zod16, SUPPLEMENT_MIN_TOKEN_LENGTH, SUPPLEMENT_BUDGET, SUPPLEMENT_BUDGET_WIDE, itemCaches, ensureItemsCache, FUZZY_EXTRACTION_PROMPT, EXACT_EXTRACTION_PROMPT;
17039
17420
  var init_prefilter = __esm({
17040
17421
  "ee/agentic-retrieval/pipeline/prefilter.ts"() {
17041
17422
  "use strict";
17042
17423
  init_cjs_shims();
17043
17424
  import_fuse = __toESM(require("fuse.js"), 1);
17044
- import_zod15 = require("zod");
17425
+ import_zod16 = require("zod");
17045
17426
  init_micro_call();
17046
17427
  init_text_utils();
17047
17428
  init_config3();
@@ -17125,18 +17506,18 @@ ${rulesLines}` + (extraInstructions ? `
17125
17506
  ${extraInstructions}
17126
17507
  </instructions>` : "") : "");
17127
17508
  const ids = enabledContexts.map((c) => c.id);
17128
- const schema7 = import_zod16.z.object({
17129
- docPage: import_zod16.z.object({
17130
- hasFilenameHint: import_zod16.z.boolean(),
17131
- filenameHints: import_zod16.z.array(import_zod16.z.string()).optional(),
17132
- hasPageHint: import_zod16.z.boolean(),
17133
- pageNumber: import_zod16.z.number().int().nullable().optional()
17509
+ const schema7 = import_zod17.z.object({
17510
+ docPage: import_zod17.z.object({
17511
+ hasFilenameHint: import_zod17.z.boolean(),
17512
+ filenameHints: import_zod17.z.array(import_zod17.z.string()).optional(),
17513
+ hasPageHint: import_zod17.z.boolean(),
17514
+ pageNumber: import_zod17.z.number().int().nullable().optional()
17134
17515
  }),
17135
- explicitlyRequestedKnowledgeBases: import_zod16.z.array(import_zod16.z.enum(ids)),
17516
+ explicitlyRequestedKnowledgeBases: import_zod17.z.array(import_zod17.z.enum(ids)),
17136
17517
  ...routingRules.length ? {
17137
- classification: import_zod16.z.object({
17138
- ruleId: import_zod16.z.enum(routingRules.map((r) => r.id)),
17139
- reason: import_zod16.z.string()
17518
+ classification: import_zod17.z.object({
17519
+ ruleId: import_zod17.z.enum(routingRules.map((r) => r.id)),
17520
+ reason: import_zod17.z.string()
17140
17521
  })
17141
17522
  } : {}
17142
17523
  });
@@ -17195,14 +17576,18 @@ If explicit, return the knowledge base ids. If not, return an empty array.`;
17195
17576
  model,
17196
17577
  system: buildDocPagePrompt(knownIdentifiers),
17197
17578
  messages: [{ role: "user", content: question }],
17198
- schema: import_zod16.z.object({
17199
- hasFilenameHint: import_zod16.z.boolean(),
17200
- filenameHints: import_zod16.z.array(import_zod16.z.string()).optional(),
17201
- hasPageHint: import_zod16.z.boolean(),
17202
- pageNumber: import_zod16.z.number().int().nullable().optional()
17579
+ schema: import_zod17.z.object({
17580
+ hasFilenameHint: import_zod17.z.boolean(),
17581
+ filenameHints: import_zod17.z.array(import_zod17.z.string()).optional(),
17582
+ hasPageHint: import_zod17.z.boolean(),
17583
+ pageNumber: import_zod17.z.number().int().nullable().optional()
17203
17584
  })
17204
17585
  });
17205
17586
  } catch (err4) {
17587
+ console.warn(
17588
+ "[EXULU pipeline] doc/page detection failed \u2014 skipping filename and page hints.",
17589
+ err4
17590
+ );
17206
17591
  steps.push({ text: "Doc/page detection failed \u2014 skipping filename and page hints." });
17207
17592
  return {
17208
17593
  output: {
@@ -17219,14 +17604,18 @@ If explicit, return the knowledge base ids. If not, return an empty array.`;
17219
17604
  return await microCall({
17220
17605
  model,
17221
17606
  system: kbSystemPrompt,
17222
- schema: import_zod16.z.object({
17223
- explicitlyRequestedKnowledgeBases: import_zod16.z.array(
17224
- import_zod16.z.enum(enabledContexts.map((c) => c.id))
17607
+ schema: import_zod17.z.object({
17608
+ explicitlyRequestedKnowledgeBases: import_zod17.z.array(
17609
+ import_zod17.z.enum(enabledContexts.map((c) => c.id))
17225
17610
  )
17226
17611
  }),
17227
17612
  messages: [{ role: "user", content: question }]
17228
17613
  });
17229
17614
  } catch (err4) {
17615
+ console.warn(
17616
+ "[EXULU pipeline] explicit knowledge base detection failed \u2014 treating the question as naming none.",
17617
+ err4
17618
+ );
17230
17619
  return { output: { explicitlyRequestedKnowledgeBases: [] } };
17231
17620
  }
17232
17621
  })()
@@ -17312,9 +17701,9 @@ ${extraInstructions}
17312
17701
  model,
17313
17702
  system: classifyPrompt,
17314
17703
  messages: [{ role: "user", content: question }],
17315
- schema: import_zod16.z.object({
17316
- ruleId: import_zod16.z.enum(ruleIds),
17317
- reason: import_zod16.z.string()
17704
+ schema: import_zod17.z.object({
17705
+ ruleId: import_zod17.z.enum(ruleIds),
17706
+ reason: import_zod17.z.string()
17318
17707
  })
17319
17708
  }));
17320
17709
  const matchedRule = routingRules.find((r) => r.id === classified.ruleId);
@@ -17339,6 +17728,10 @@ ${extraInstructions}
17339
17728
  });
17340
17729
  }
17341
17730
  } catch (err4) {
17731
+ console.warn(
17732
+ "[EXULU pipeline] classification failed \u2014 using the implicit all-main rule.",
17733
+ err4
17734
+ );
17342
17735
  mainContexts = enabledContexts.map((c) => c.id);
17343
17736
  fallbackContexts = [];
17344
17737
  steps.push({
@@ -17369,12 +17762,12 @@ ${extraInstructions}
17369
17762
  };
17370
17763
  }
17371
17764
  }
17372
- var import_zod16, MAX_USER_PIN_MATCHES, buildDocPagePrompt;
17765
+ var import_zod17, MAX_USER_PIN_MATCHES, buildDocPagePrompt;
17373
17766
  var init_routing = __esm({
17374
17767
  "ee/agentic-retrieval/pipeline/routing.ts"() {
17375
17768
  "use strict";
17376
17769
  init_cjs_shims();
17377
- import_zod16 = require("zod");
17770
+ import_zod17 = require("zod");
17378
17771
  init_micro_call();
17379
17772
  init_timing();
17380
17773
  init_prefilter();
@@ -17479,22 +17872,22 @@ ${glossary.map((g) => `${g.term} : ${g.meaning}`).join("\n")}` : "";
17479
17872
  `
17480
17873
  }
17481
17874
  ],
17482
- schema: import_zod17.z.object({
17483
- relevantChunkIds: import_zod17.z.array(import_zod17.z.string()).describe("chunk_ids (UUIDs at the start of each bullet) of relevant chunks; empty array if none."),
17484
- override: import_zod17.z.object({
17485
- overrides: import_zod17.z.boolean().describe("True ONLY if a chunk directly and sufficiently answers the question."),
17486
- confidence: import_zod17.z.enum(["high", "medium", "low"]),
17487
- authoritativeChunkIds: import_zod17.z.array(import_zod17.z.string()).describe("chunk_ids that directly answer the question; empty if overrides is false."),
17488
- reason: import_zod17.z.string().describe("One short sentence.")
17875
+ schema: import_zod18.z.object({
17876
+ relevantChunkIds: import_zod18.z.array(import_zod18.z.string()).describe("chunk_ids (UUIDs at the start of each bullet) of relevant chunks; empty array if none."),
17877
+ override: import_zod18.z.object({
17878
+ overrides: import_zod18.z.boolean().describe("True ONLY if a chunk directly and sufficiently answers the question."),
17879
+ confidence: import_zod18.z.enum(["high", "medium", "low"]),
17880
+ authoritativeChunkIds: import_zod18.z.array(import_zod18.z.string()).describe("chunk_ids that directly answer the question; empty if overrides is false."),
17881
+ reason: import_zod18.z.string().describe("One short sentence.")
17489
17882
  }),
17490
- filePrioritization: import_zod17.z.object({
17491
- shouldPrioritizeFiles: import_zod17.z.boolean(),
17492
- fileNameHints: import_zod17.z.array(import_zod17.z.string()).optional()
17883
+ filePrioritization: import_zod18.z.object({
17884
+ shouldPrioritizeFiles: import_zod18.z.boolean(),
17885
+ fileNameHints: import_zod18.z.array(import_zod18.z.string()).optional()
17493
17886
  }),
17494
- augmentation: import_zod17.z.object({
17495
- updatedUserQuestion: import_zod17.z.string(),
17496
- updatedRelevantKeywords: import_zod17.z.array(import_zod17.z.string()),
17497
- updatedImportantKeyword: import_zod17.z.string()
17887
+ augmentation: import_zod18.z.object({
17888
+ updatedUserQuestion: import_zod18.z.string(),
17889
+ updatedRelevantKeywords: import_zod18.z.array(import_zod18.z.string()),
17890
+ updatedImportantKeyword: import_zod18.z.string()
17498
17891
  })
17499
17892
  })
17500
17893
  });
@@ -17577,8 +17970,8 @@ async function runMemoryPhase({
17577
17970
  `
17578
17971
  }
17579
17972
  ],
17580
- schema: import_zod17.z.object({
17581
- relevantChunkIds: import_zod17.z.array(import_zod17.z.string()).describe(
17973
+ schema: import_zod18.z.object({
17974
+ relevantChunkIds: import_zod18.z.array(import_zod18.z.string()).describe(
17582
17975
  "The chunk_ids (UUIDs at the start of each bullet) of chunks containing information relevant to the user's question. Empty array if none are relevant."
17583
17976
  )
17584
17977
  })
@@ -17687,17 +18080,17 @@ ${glossary.map((g) => `${g.term} : ${g.meaning}`).join("\n")}` : "";
17687
18080
  `
17688
18081
  }
17689
18082
  ],
17690
- schema: import_zod17.z.object({
17691
- overrides: import_zod17.z.boolean().describe(
18083
+ schema: import_zod18.z.object({
18084
+ overrides: import_zod18.z.boolean().describe(
17692
18085
  "True ONLY if a memory chunk directly and sufficiently answers the user's question and should be authoritative over the documents. Be strict; when unsure, false."
17693
18086
  ),
17694
- confidence: import_zod17.z.enum(["high", "medium", "low"]).describe(
18087
+ confidence: import_zod18.z.enum(["high", "medium", "low"]).describe(
17695
18088
  "Confidence that the selected memory chunk(s) fully and directly answer the question."
17696
18089
  ),
17697
- authoritativeChunkIds: import_zod17.z.array(import_zod17.z.string()).describe(
18090
+ authoritativeChunkIds: import_zod18.z.array(import_zod18.z.string()).describe(
17698
18091
  "The chunk_ids of the memory chunk(s) that directly answer the question. Empty if overrides is false."
17699
18092
  ),
17700
- reason: import_zod17.z.string().describe(
18093
+ reason: import_zod18.z.string().describe(
17701
18094
  "One short sentence: why this memory does or does not directly answer the question."
17702
18095
  )
17703
18096
  })
@@ -17721,9 +18114,9 @@ ${glossary.map((g) => `${g.term} : ${g.meaning}`).join("\n")}` : "";
17721
18114
  model,
17722
18115
  system: "You are a helpful assistant that will strictly follow the user's instructions.",
17723
18116
  messages: [{ role: "user", content: PROMPT_EXTRACT_PRIORITIZED_FILES }],
17724
- schema: import_zod17.z.object({
17725
- shouldPrioritizeFiles: import_zod17.z.boolean(),
17726
- fileNameHints: import_zod17.z.array(import_zod17.z.string()).optional()
18117
+ schema: import_zod18.z.object({
18118
+ shouldPrioritizeFiles: import_zod18.z.boolean(),
18119
+ fileNameHints: import_zod18.z.array(import_zod18.z.string()).optional()
17727
18120
  })
17728
18121
  }).catch(() => ({
17729
18122
  output: { shouldPrioritizeFiles: false, fileNameHints: [] }
@@ -17735,10 +18128,10 @@ ${glossary.map((g) => `${g.term} : ${g.meaning}`).join("\n")}` : "";
17735
18128
  model,
17736
18129
  system: "You are a helpful assistant that will strictly follow the user's instructions.",
17737
18130
  messages: [{ role: "user", content: QUERY_AUGMENTATION_PROMPT }],
17738
- schema: import_zod17.z.object({
17739
- updatedUserQuestion: import_zod17.z.string(),
17740
- updatedRelevantKeywords: import_zod17.z.array(import_zod17.z.string()),
17741
- updatedImportantKeyword: import_zod17.z.string()
18131
+ schema: import_zod18.z.object({
18132
+ updatedUserQuestion: import_zod18.z.string(),
18133
+ updatedRelevantKeywords: import_zod18.z.array(import_zod18.z.string()),
18134
+ updatedImportantKeyword: import_zod18.z.string()
17742
18135
  })
17743
18136
  }).catch(() => ({
17744
18137
  output: {
@@ -17825,12 +18218,12 @@ ${glossary.map((g) => `${g.term} : ${g.meaning}`).join("\n")}` : "";
17825
18218
  return neutralResult(question, keywords, importantKeyword);
17826
18219
  }
17827
18220
  }
17828
- var import_zod17, MEMORY_OVERRIDE_MIN_CONFIDENCE, MEMORY_SYNTHETIC_RERANK_SCORE;
18221
+ var import_zod18, MEMORY_OVERRIDE_MIN_CONFIDENCE, MEMORY_SYNTHETIC_RERANK_SCORE;
17829
18222
  var init_memory = __esm({
17830
18223
  "ee/agentic-retrieval/pipeline/memory.ts"() {
17831
18224
  "use strict";
17832
18225
  init_cjs_shims();
17833
- import_zod17 = require("zod");
18226
+ import_zod18 = require("zod");
17834
18227
  init_micro_call();
17835
18228
  init_timing();
17836
18229
  init_prefilter();
@@ -18677,11 +19070,11 @@ function createAgenticRetrievalTool(opts) {
18677
19070
  default: '{"enabled":false,"model":"","fidelity":"fast","thresholds":{"warn":0.1,"alert":0.3}}'
18678
19071
  }
18679
19072
  ],
18680
- inputSchema: import_zod18.z.object({
18681
- userQuery: import_zod18.z.string().describe("The original unaltered question from the user"),
18682
- relevantKeywords: import_zod18.z.array(import_zod18.z.string()).describe("Keywords extracted from the user's question relevant to the search"),
18683
- importantKeyword: import_zod18.z.string().describe("The single most important keyword from the user's question"),
18684
- confirmedContextIds: import_zod18.z.array(import_zod18.z.string()).optional().describe(
19073
+ inputSchema: import_zod19.z.object({
19074
+ userQuery: import_zod19.z.string().describe("The original unaltered question from the user"),
19075
+ relevantKeywords: import_zod19.z.array(import_zod19.z.string()).describe("Keywords extracted from the user's question relevant to the search"),
19076
+ importantKeyword: import_zod19.z.string().describe("The single most important keyword from the user's question"),
19077
+ confirmedContextIds: import_zod19.z.array(import_zod19.z.string()).optional().describe(
18685
19078
  "Knowledge base IDs explicitly confirmed by the user to be used in the retrieval. When present, only searches these contexts."
18686
19079
  )
18687
19080
  }),
@@ -19125,12 +19518,12 @@ Verified answer:
19125
19518
  }
19126
19519
  });
19127
19520
  }
19128
- var import_zod18, AGENTIC_RETRIEVAL_TOOL_NAME;
19521
+ var import_zod19, AGENTIC_RETRIEVAL_TOOL_NAME;
19129
19522
  var init_pipeline = __esm({
19130
19523
  "ee/agentic-retrieval/pipeline/index.ts"() {
19131
19524
  "use strict";
19132
19525
  init_cjs_shims();
19133
- import_zod18 = require("zod");
19526
+ import_zod19 = require("zod");
19134
19527
  init_tool();
19135
19528
  init_entitlements();
19136
19529
  init_resolve_reranker();
@@ -20197,7 +20590,7 @@ var itemsPaginationRequest = async ({
20197
20590
  }
20198
20591
  const tableName = table.name.plural.toLowerCase();
20199
20592
  let countQuery = db2(tableName);
20200
- countQuery = applyFilters(countQuery, filters, table);
20593
+ countQuery = applyFiltersGrouped(countQuery, filters, table);
20201
20594
  countQuery = applyAccessControl(table, countQuery, user);
20202
20595
  const countResult = await countQuery.count("* as count");
20203
20596
  const itemCount = Number(countResult[0]?.count || 0);
@@ -20206,7 +20599,7 @@ var itemsPaginationRequest = async ({
20206
20599
  const hasPreviousPage = currentPage > 1;
20207
20600
  const hasNextPage = currentPage <= pageCount - 1;
20208
20601
  let dataQuery = db2(tableName);
20209
- dataQuery = applyFilters(dataQuery, filters, table);
20602
+ dataQuery = applyFiltersGrouped(dataQuery, filters, table);
20210
20603
  dataQuery = applyAccessControl(table, dataQuery, user);
20211
20604
  dataQuery = applySorting(dataQuery, sort, void 0, table);
20212
20605
  if (page > 1) {
@@ -20347,7 +20740,7 @@ function createQueries(table, tools, contexts) {
20347
20740
  const requestedFields = getRequestedFields(info);
20348
20741
  const sanitizedFields = sanitizeRequestedFields(table, requestedFields);
20349
20742
  let query = db2.from(tableNamePlural).select(sanitizedFields);
20350
- query = applyFilters(query, filters, table);
20743
+ query = applyFiltersGrouped(query, filters, table);
20351
20744
  query = applyAccessControl(table, query, context.user);
20352
20745
  query = applySorting(query, sort, void 0, table);
20353
20746
  let result = await query.first();
@@ -20394,7 +20787,7 @@ function createQueries(table, tools, contexts) {
20394
20787
  const { filters = [], groupBy, limit = 10 } = args;
20395
20788
  const { db: db2 } = context;
20396
20789
  let query = db2(tableNamePlural);
20397
- query = applyFilters(query, filters, table);
20790
+ query = applyFiltersGrouped(query, filters, table);
20398
20791
  query = applyAccessControl(table, query, context.user);
20399
20792
  query = query.limit(limit);
20400
20793
  if (groupBy) {
@@ -23191,7 +23584,7 @@ init_cjs_shims();
23191
23584
  init_entitlements();
23192
23585
  init_singleton();
23193
23586
  init_tool();
23194
- var import_zod19 = require("zod");
23587
+ var import_zod20 = require("zod");
23195
23588
  init_check_record_access();
23196
23589
  init_resolve_model();
23197
23590
  init_statistics2();
@@ -23723,19 +24116,8 @@ async function recallMemories({ agent, contexts, query, user, db: db2, previousU
23723
24116
  return { collector, memoryItems: chunks, promptBlock: buildMemoryPromptBlock(collector.list()) };
23724
24117
  }
23725
24118
 
23726
- // src/exulu/public-surface.ts
23727
- init_cjs_shims();
23728
- var PUBLIC_SURFACE_HEADER = "x-public-surface";
23729
- function isPublicSurface(req) {
23730
- const raw = req?.headers?.[PUBLIC_SURFACE_HEADER];
23731
- const value = Array.isArray(raw) ? raw[0] : raw;
23732
- return value === "1" || value === "true";
23733
- }
23734
- function treatAsGuest(req, user) {
23735
- return isPublicSurface(req) || !user?.id;
23736
- }
23737
-
23738
24119
  // src/exulu/generate-stream.ts
24120
+ init_public_surface();
23739
24121
  init_decisions();
23740
24122
 
23741
24123
  // src/exulu/skills/decisions.ts
@@ -24671,9 +25053,9 @@ var createAgentTool = async (instance2, contexts) => {
24671
25053
  name: `${agent.name}`,
24672
25054
  type: "agent",
24673
25055
  category: "agents",
24674
- inputSchema: import_zod19.z.object({
24675
- prompt: import_zod19.z.string().describe("The prompt (usually a question for the agent) to send to the agent."),
24676
- information: import_zod19.z.string().describe("A summary of relevant context / information from the current session")
25056
+ inputSchema: import_zod20.z.object({
25057
+ prompt: import_zod20.z.string().describe("The prompt (usually a question for the agent) to send to the agent."),
25058
+ information: import_zod20.z.string().describe("A summary of relevant context / information from the current session")
24677
25059
  }),
24678
25060
  description: `This tool calls an agent named: ${agent.name}. The agent does the following: ${agent.description}.`,
24679
25061
  config: [],
@@ -24794,6 +25176,25 @@ var getEnabledTools = async (agent, allExuluTools, allContexts, disabledTools =
24794
25176
  return enabledTools;
24795
25177
  };
24796
25178
 
25179
+ // src/utils/enabled-skills.ts
25180
+ init_cjs_shims();
25181
+ init_client();
25182
+ var getEnabledSkills = async (agent, disabledSkills = []) => {
25183
+ const refs = (agent.skills?.filter(Boolean) ?? []).filter(
25184
+ (skill) => !disabledSkills.includes(skill.id)
25185
+ );
25186
+ if (refs.length === 0) return [];
25187
+ const { db: db2 } = await postgresClient();
25188
+ const rows = await db2.from("skills").whereIn(
25189
+ "id",
25190
+ refs.map((skill) => skill.id)
25191
+ );
25192
+ const rowById = new Map(rows.map((row) => [row.id, row]));
25193
+ console.log("[EXULU] available skills", refs.length, "resolved", rows.length);
25194
+ console.log("[EXULU] disabled skills", disabledSkills?.length);
25195
+ return refs.map((ref) => rowById.get(ref.id)).filter((row) => row != null);
25196
+ };
25197
+
24797
25198
  // ee/workers.ts
24798
25199
  init_storage();
24799
25200
  init_context();
@@ -27015,6 +27416,11 @@ var processUiMessagesFlow = async ({
27015
27416
  "[EXULU] enabled tools",
27016
27417
  enabledTools?.map((x) => x.name + " (" + x.id + ")")
27017
27418
  );
27419
+ const enabledSkills = await getEnabledSkills(agent, []);
27420
+ console.log(
27421
+ "[EXULU] enabled skills",
27422
+ enabledSkills.map((x) => `${x.name} v${x.current_version ?? "?"}`)
27423
+ );
27018
27424
  if (!agent.model) {
27019
27425
  throw new Error(
27020
27426
  `Agent ${agent.name} (${agent.id}) has no model configured.`
@@ -27093,6 +27499,7 @@ var processUiMessagesFlow = async ({
27093
27499
  previousMessages: messageHistory.messages,
27094
27500
  message: currentMessage,
27095
27501
  currentTools: enabledTools,
27502
+ currentSkills: enabledSkills,
27096
27503
  allExuluTools: tools,
27097
27504
  languageModel: resolvedLanguageModel,
27098
27505
  toolConfigs: agent.tools,
@@ -30060,12 +30467,12 @@ async function runScan({ db: db2, context, user, judge, now = /* @__PURE__ */ ne
30060
30467
  // src/exulu/memory/conflicts/judge.ts
30061
30468
  init_cjs_shims();
30062
30469
  var import_ai10 = require("ai");
30063
- var import_zod20 = require("zod");
30470
+ var import_zod21 = require("zod");
30064
30471
  init_resolve_model();
30065
- var schema = import_zod20.z.object({
30066
- verdict: import_zod20.z.enum(["same", "contradict", "compatible"]),
30472
+ var schema = import_zod21.z.object({
30473
+ verdict: import_zod21.z.enum(["same", "contradict", "compatible"]),
30067
30474
  // No .max(160) here: an over-long reason must not fail the whole call — truncate after.
30068
- reason: import_zod20.z.string()
30475
+ reason: import_zod21.z.string()
30069
30476
  });
30070
30477
  var SYSTEM = `You compare two short memories an assistant saved from conversations.
30071
30478
  Answer with JSON: verdict = "same" when both state the same fact or instruction (wording may differ),
@@ -30100,7 +30507,7 @@ async function makeMergeSuggester({ modelId, agent, user }) {
30100
30507
  prompt: members.map((m, i) => `Memory ${i + 1}:
30101
30508
  ${m.information}`).join("\n\n"),
30102
30509
  maxRetries: 1,
30103
- output: import_ai10.Output.object({ schema: import_zod20.z.object({ information: import_zod20.z.string().min(1).max(400) }) })
30510
+ output: import_ai10.Output.object({ schema: import_zod21.z.object({ information: import_zod21.z.string().min(1).max(400) }) })
30104
30511
  });
30105
30512
  const types = members.map((m) => m.type).filter((t) => !!t);
30106
30513
  const type = types.length ? [...types].sort((x, y) => types.filter((t) => t === y).length - types.filter((t) => t === x).length)[0] ?? null : null;
@@ -33153,12 +33560,12 @@ init_statistics2();
33153
33560
  // src/exulu/suggestions.ts
33154
33561
  init_cjs_shims();
33155
33562
  var import_ai11 = require("ai");
33156
- var import_zod21 = require("zod");
33563
+ var import_zod22 = require("zod");
33157
33564
  var SUGGESTIONS_SYSTEM_PROMPT = "You generate short follow-up message suggestions for the user. You are NOT continuing the conversation as the assistant \u2014 you are predicting what the user might want to say next. Suggest up to 3 short follow-up questions or messages the user might want to send next. Each suggestion must be written from the user's perspective (first person) and be 12 words or fewer. You MUST submit your answer by calling the `submit_suggestions` tool exactly once. Do not emit any plain text \u2014 only the tool call.";
33158
33565
  var submitSuggestionsTool = (0, import_ai11.tool)({
33159
33566
  description: "Submit the final list of follow-up message suggestions for the user. Must be called exactly once. Each suggestion is written from the user's perspective (first person) and is 12 words or fewer.",
33160
- inputSchema: import_zod21.z.object({
33161
- suggestions: import_zod21.z.array(import_zod21.z.string()).max(3)
33567
+ inputSchema: import_zod22.z.object({
33568
+ suggestions: import_zod22.z.array(import_zod22.z.string()).max(3)
33162
33569
  })
33163
33570
  });
33164
33571
  var MAX_CHARS_PER_MESSAGE = 1e4;
@@ -33389,16 +33796,16 @@ init_view_document_page_tool();
33389
33796
  // src/templates/tools/perplexity.ts
33390
33797
  init_cjs_shims();
33391
33798
  init_tool();
33392
- var import_zod22 = __toESM(require("zod"), 1);
33799
+ var import_zod23 = __toESM(require("zod"), 1);
33393
33800
  var import_perplexity_ai = __toESM(require("@perplexity-ai/perplexity_ai"), 1);
33394
33801
  var INTERNET_SEARCH_TOOL_NAME = "Internet Search";
33395
33802
  var internetSearchTool = new ExuluTool({
33396
33803
  id: "internet_search",
33397
33804
  name: INTERNET_SEARCH_TOOL_NAME,
33398
33805
  description: "Search the internet for information.",
33399
- inputSchema: import_zod22.default.object({
33400
- query: import_zod22.default.string().describe("The query to the tool."),
33401
- search_recency_filter: import_zod22.default.enum(["day", "week", "month", "year"]).optional().describe("The recency filter for the search, can be day, week, month or year.")
33806
+ inputSchema: import_zod23.default.object({
33807
+ query: import_zod23.default.string().describe("The query to the tool."),
33808
+ search_recency_filter: import_zod23.default.enum(["day", "week", "month", "year"]).optional().describe("The recency filter for the search, can be day, week, month or year.")
33402
33809
  }),
33403
33810
  category: "internet_search",
33404
33811
  type: "web_search",
@@ -33670,6 +34077,9 @@ function claimCheckStreamMetadata(ctx) {
33670
34077
  };
33671
34078
  }
33672
34079
 
34080
+ // src/exulu/routes.ts
34081
+ init_public_surface();
34082
+
33673
34083
  // src/exulu/transcribe.ts
33674
34084
  init_cjs_shims();
33675
34085
  init_env();
@@ -34156,8 +34566,9 @@ function registerViewerIdentityRoutes(app, deps) {
34156
34566
 
34157
34567
  // ee/claim-check/routes.ts
34158
34568
  init_cjs_shims();
34159
- var import_zod23 = require("zod");
34569
+ var import_zod24 = require("zod");
34160
34570
  init_resolve_max_steps();
34571
+ init_public_surface();
34161
34572
  init_types2();
34162
34573
 
34163
34574
  // ee/claim-check/agent-config.ts
@@ -34219,13 +34630,13 @@ var SOURCE_TYPES = [
34219
34630
  "session_item",
34220
34631
  "other"
34221
34632
  ];
34222
- var requestSchema = import_zod23.z.object({
34223
- question: import_zod23.z.string().min(1),
34224
- answer: import_zod23.z.string().min(1),
34225
- sources: import_zod23.z.array(
34226
- import_zod23.z.object({
34227
- content: import_zod23.z.string(),
34228
- name: import_zod23.z.string().optional(),
34633
+ var requestSchema = import_zod24.z.object({
34634
+ question: import_zod24.z.string().min(1),
34635
+ answer: import_zod24.z.string().min(1),
34636
+ sources: import_zod24.z.array(
34637
+ import_zod24.z.object({
34638
+ content: import_zod24.z.string(),
34639
+ name: import_zod24.z.string().optional(),
34229
34640
  // Purely informational (spec §2: no trust tiers, dropped before the
34230
34641
  // engine sees it — see assignSourceIds below), so an unrecognised
34231
34642
  // value is IGNORED, not rejected: `.catch(undefined)` keeps the enum
@@ -34237,24 +34648,24 @@ var requestSchema = import_zod23.z.object({
34237
34648
  // `.catch`) would turn that pre-existing 200 into a 400, which is a
34238
34649
  // tightening this loosening-only task must not make. Do not remove
34239
34650
  // the `.catch` to "validate properly": that is the bug this guards.
34240
- type: import_zod23.z.enum(SOURCE_TYPES).optional().catch(void 0),
34241
- id: import_zod23.z.string().min(1).optional()
34651
+ type: import_zod24.z.enum(SOURCE_TYPES).optional().catch(void 0),
34652
+ id: import_zod24.z.string().min(1).optional()
34242
34653
  })
34243
34654
  ).default([]),
34244
- agent: import_zod23.z.string().optional(),
34245
- session: import_zod23.z.string().optional(),
34246
- messageId: import_zod23.z.string().optional(),
34247
- model: import_zod23.z.string().optional(),
34248
- locale: import_zod23.z.string().refine(localeIsUsable, { message: "locale is not a usable BCP 47 language tag" }).optional(),
34249
- options: import_zod23.z.object({
34250
- fidelity: import_zod23.z.enum(["fast", "paper"]).optional(),
34251
- completions: import_zod23.z.number().int().min(1).max(3).optional(),
34252
- reRetrieve: import_zod23.z.boolean().optional(),
34253
- thresholds: import_zod23.z.object({ warn: import_zod23.z.number().min(0).max(1), alert: import_zod23.z.number().min(0).max(1) }).partial().optional(),
34254
- caps: import_zod23.z.object({
34255
- maxSentences: import_zod23.z.number().int().positive(),
34256
- maxClaims: import_zod23.z.number().int().positive(),
34257
- maxReRetrievals: import_zod23.z.number().int().min(0)
34655
+ agent: import_zod24.z.string().optional(),
34656
+ session: import_zod24.z.string().optional(),
34657
+ messageId: import_zod24.z.string().optional(),
34658
+ model: import_zod24.z.string().optional(),
34659
+ locale: import_zod24.z.string().refine(localeIsUsable, { message: "locale is not a usable BCP 47 language tag" }).optional(),
34660
+ options: import_zod24.z.object({
34661
+ fidelity: import_zod24.z.enum(["fast", "paper"]).optional(),
34662
+ completions: import_zod24.z.number().int().min(1).max(3).optional(),
34663
+ reRetrieve: import_zod24.z.boolean().optional(),
34664
+ thresholds: import_zod24.z.object({ warn: import_zod24.z.number().min(0).max(1), alert: import_zod24.z.number().min(0).max(1) }).partial().optional(),
34665
+ caps: import_zod24.z.object({
34666
+ maxSentences: import_zod24.z.number().int().positive(),
34667
+ maxClaims: import_zod24.z.number().int().positive(),
34668
+ maxReRetrievals: import_zod24.z.number().int().min(0)
34258
34669
  }).partial().optional()
34259
34670
  }).optional()
34260
34671
  });
@@ -34848,7 +35259,7 @@ function selectEvidence(claimTexts, index, topK = 4) {
34848
35259
 
34849
35260
  // ee/claim-check/stages/select-disambiguate.ts
34850
35261
  init_cjs_shims();
34851
- var import_zod25 = require("zod");
35262
+ var import_zod26 = require("zod");
34852
35263
  init_micro_call();
34853
35264
  init_types2();
34854
35265
 
@@ -34985,16 +35396,16 @@ resolvable=false and clarified=null for it.`;
34985
35396
 
34986
35397
  // ee/claim-check/stages/select.ts
34987
35398
  init_cjs_shims();
34988
- var import_zod24 = require("zod");
35399
+ var import_zod25 = require("zod");
34989
35400
  init_micro_call();
34990
35401
  init_types2();
34991
- var schema2 = import_zod24.z.object({
34992
- sentences: import_zod24.z.array(
34993
- import_zod24.z.object({
34994
- index: import_zod24.z.number().int(),
34995
- verifiable: import_zod24.z.boolean(),
34996
- rewritten: import_zod24.z.string().nullable(),
34997
- reason: import_zod24.z.string()
35402
+ var schema2 = import_zod25.z.object({
35403
+ sentences: import_zod25.z.array(
35404
+ import_zod25.z.object({
35405
+ index: import_zod25.z.number().int(),
35406
+ verifiable: import_zod25.z.boolean(),
35407
+ rewritten: import_zod25.z.string().nullable(),
35408
+ reason: import_zod25.z.string()
34998
35409
  })
34999
35410
  )
35000
35411
  });
@@ -35052,15 +35463,15 @@ async function runSelection(args) {
35052
35463
  }
35053
35464
 
35054
35465
  // ee/claim-check/stages/select-disambiguate.ts
35055
- var schema3 = import_zod25.z.object({
35056
- sentences: import_zod25.z.array(
35057
- import_zod25.z.object({
35058
- index: import_zod25.z.number().int(),
35059
- verifiable: import_zod25.z.boolean(),
35060
- rewritten: import_zod25.z.string().nullable(),
35061
- resolvable: import_zod25.z.boolean(),
35062
- clarified: import_zod25.z.string().nullable(),
35063
- reason: import_zod25.z.string()
35466
+ var schema3 = import_zod26.z.object({
35467
+ sentences: import_zod26.z.array(
35468
+ import_zod26.z.object({
35469
+ index: import_zod26.z.number().int(),
35470
+ verifiable: import_zod26.z.boolean(),
35471
+ rewritten: import_zod26.z.string().nullable(),
35472
+ resolvable: import_zod26.z.boolean(),
35473
+ clarified: import_zod26.z.string().nullable(),
35474
+ reason: import_zod26.z.string()
35064
35475
  })
35065
35476
  )
35066
35477
  });
@@ -35111,16 +35522,16 @@ async function runSelectAndDisambiguate(args) {
35111
35522
 
35112
35523
  // ee/claim-check/stages/disambiguate.ts
35113
35524
  init_cjs_shims();
35114
- var import_zod26 = require("zod");
35525
+ var import_zod27 = require("zod");
35115
35526
  init_micro_call();
35116
35527
  init_types2();
35117
- var schema4 = import_zod26.z.object({
35118
- sentences: import_zod26.z.array(
35119
- import_zod26.z.object({
35120
- index: import_zod26.z.number().int(),
35121
- resolvable: import_zod26.z.boolean(),
35122
- clarified: import_zod26.z.string().nullable(),
35123
- reason: import_zod26.z.string()
35528
+ var schema4 = import_zod27.z.object({
35529
+ sentences: import_zod27.z.array(
35530
+ import_zod27.z.object({
35531
+ index: import_zod27.z.number().int(),
35532
+ resolvable: import_zod27.z.boolean(),
35533
+ clarified: import_zod27.z.string().nullable(),
35534
+ reason: import_zod27.z.string()
35124
35535
  })
35125
35536
  )
35126
35537
  });
@@ -35167,7 +35578,7 @@ async function runDisambiguation(args) {
35167
35578
 
35168
35579
  // ee/claim-check/stages/decompose.ts
35169
35580
  init_cjs_shims();
35170
- var import_zod27 = require("zod");
35581
+ var import_zod28 = require("zod");
35171
35582
  init_micro_call();
35172
35583
  init_types2();
35173
35584
 
@@ -35218,11 +35629,11 @@ function decomposeUserPrompt(args) {
35218
35629
  }
35219
35630
 
35220
35631
  // ee/claim-check/stages/decompose.ts
35221
- var schema5 = import_zod27.z.object({
35222
- sentences: import_zod27.z.array(
35223
- import_zod27.z.object({
35224
- index: import_zod27.z.number().int(),
35225
- claims: import_zod27.z.array(import_zod27.z.object({ text: import_zod27.z.string(), inferred: import_zod27.z.boolean() }))
35632
+ var schema5 = import_zod28.z.object({
35633
+ sentences: import_zod28.z.array(
35634
+ import_zod28.z.object({
35635
+ index: import_zod28.z.number().int(),
35636
+ claims: import_zod28.z.array(import_zod28.z.object({ text: import_zod28.z.string(), inferred: import_zod28.z.boolean() }))
35226
35637
  })
35227
35638
  )
35228
35639
  });
@@ -35258,7 +35669,7 @@ async function runDecomposition(args) {
35258
35669
 
35259
35670
  // ee/claim-check/stages/verify.ts
35260
35671
  init_cjs_shims();
35261
- var import_zod28 = require("zod");
35672
+ var import_zod29 = require("zod");
35262
35673
  init_micro_call();
35263
35674
  init_types2();
35264
35675
 
@@ -35320,13 +35731,13 @@ function addUsage(a, b) {
35320
35731
  }
35321
35732
 
35322
35733
  // ee/claim-check/stages/verify.ts
35323
- var schema6 = import_zod28.z.object({
35324
- claims: import_zod28.z.array(
35325
- import_zod28.z.object({
35326
- claimId: import_zod28.z.string(),
35327
- verdict: import_zod28.z.enum(["supported", "contradicted", "unsupported"]),
35328
- evidence: import_zod28.z.array(import_zod28.z.object({ sourceId: import_zod28.z.string(), quote: import_zod28.z.string() })),
35329
- rationale: import_zod28.z.string()
35734
+ var schema6 = import_zod29.z.object({
35735
+ claims: import_zod29.z.array(
35736
+ import_zod29.z.object({
35737
+ claimId: import_zod29.z.string(),
35738
+ verdict: import_zod29.z.enum(["supported", "contradicted", "unsupported"]),
35739
+ evidence: import_zod29.z.array(import_zod29.z.object({ sourceId: import_zod29.z.string(), quote: import_zod29.z.string() })),
35740
+ rationale: import_zod29.z.string()
35330
35741
  })
35331
35742
  )
35332
35743
  });
@@ -36456,27 +36867,6 @@ function checkApiKeyScope(user, agentId) {
36456
36867
  // src/exulu/routes.ts
36457
36868
  init_singleton();
36458
36869
  init_entitlements();
36459
-
36460
- // src/utils/enabled-skills.ts
36461
- init_cjs_shims();
36462
- init_client();
36463
- var getEnabledSkills = async (agent, disabledSkills = []) => {
36464
- const refs = (agent.skills?.filter(Boolean) ?? []).filter(
36465
- (skill) => !disabledSkills.includes(skill.id)
36466
- );
36467
- if (refs.length === 0) return [];
36468
- const { db: db2 } = await postgresClient();
36469
- const rows = await db2.from("skills").whereIn(
36470
- "id",
36471
- refs.map((skill) => skill.id)
36472
- );
36473
- const rowById = new Map(rows.map((row) => [row.id, row]));
36474
- console.log("[EXULU] available skills", refs.length, "resolved", rows.length);
36475
- console.log("[EXULU] disabled skills", disabledSkills?.length);
36476
- return refs.map((ref) => rowById.get(ref.id)).filter((row) => row != null);
36477
- };
36478
-
36479
- // src/exulu/routes.ts
36480
36870
  init_create_sandbox();
36481
36871
 
36482
36872
  // src/exulu/auth/callback-handler.ts
@@ -36581,13 +36971,13 @@ var handleOauthCallback = async (req, res) => {
36581
36971
 
36582
36972
  // src/exulu/auth/submit-handler.ts
36583
36973
  init_cjs_shims();
36584
- var import_zod29 = require("zod");
36974
+ var import_zod30 = require("zod");
36585
36975
  init_registry();
36586
36976
  init_credential_store();
36587
36977
  init_credentials_request();
36588
- var bodySchema = import_zod29.z.object({
36589
- nonce: import_zod29.z.string().min(1),
36590
- values: import_zod29.z.record(import_zod29.z.string(), import_zod29.z.string())
36978
+ var bodySchema = import_zod30.z.object({
36979
+ nonce: import_zod30.z.string().min(1),
36980
+ values: import_zod30.z.record(import_zod30.z.string(), import_zod30.z.string())
36591
36981
  });
36592
36982
  async function handleCredentialSubmit(req, res) {
36593
36983
  const authResult = await requestValidators.authenticate(req);
@@ -41379,7 +41769,7 @@ init_check_record_access();
41379
41769
  init_resolve_model();
41380
41770
  init_supervisor();
41381
41771
  init_client();
41382
- var import_zod30 = require("zod");
41772
+ var import_zod31 = require("zod");
41383
41773
  init_convert_exulu_tools_to_ai_sdk_tools();
41384
41774
  init_singleton();
41385
41775
  var SESSION_ID_HEADER = "mcp-session-id";
@@ -41443,7 +41833,7 @@ var ExuluMCP = class {
41443
41833
  title: tool4.name + " agent",
41444
41834
  description: tool4.description,
41445
41835
  inputSchema: {
41446
- inputs: tool4.inputSchema || import_zod30.z.object({})
41836
+ inputs: tool4.inputSchema || import_zod31.z.object({})
41447
41837
  }
41448
41838
  },
41449
41839
  async ({ inputs }, args) => {
@@ -41494,7 +41884,7 @@ var ExuluMCP = class {
41494
41884
  title: "Get List of Prompt Templates",
41495
41885
  description: "Retrieves a list of prompt templates available for this agent. Returns the name, description, and ID of each template.",
41496
41886
  inputSchema: {
41497
- inputs: import_zod30.z.object({})
41887
+ inputs: import_zod31.z.object({})
41498
41888
  }
41499
41889
  },
41500
41890
  async ({ inputs }, args) => {
@@ -41540,8 +41930,8 @@ var ExuluMCP = class {
41540
41930
  title: "Get Prompt Template Details",
41541
41931
  description: "Retrieves the full details of a specific prompt template by ID, including the actual template content with variables.",
41542
41932
  inputSchema: {
41543
- inputs: import_zod30.z.object({
41544
- id: import_zod30.z.string().describe("The ID of the prompt template to retrieve")
41933
+ inputs: import_zod31.z.object({
41934
+ id: import_zod31.z.string().describe("The ID of the prompt template to retrieve")
41545
41935
  })
41546
41936
  }
41547
41937
  },
@@ -41782,7 +42172,7 @@ var ExuluEval = class {
41782
42172
  // src/templates/evals/index.ts
41783
42173
  init_resolve_model();
41784
42174
  init_singleton();
41785
- var import_zod31 = require("zod");
42175
+ var import_zod32 = require("zod");
41786
42176
  var import_ai17 = require("ai");
41787
42177
  var llmAsJudgeEval = () => {
41788
42178
  if (process.env.REDIS_HOST?.length && process.env.REDIS_PORT?.length) {
@@ -41833,8 +42223,8 @@ var llmAsJudgeEval = () => {
41833
42223
  prompt,
41834
42224
  maxRetries: 2,
41835
42225
  output: import_ai17.Output.object({
41836
- schema: import_zod31.z.object({
41837
- score: import_zod31.z.number().min(0).max(100).describe("The score between 0 and 100.")
42226
+ schema: import_zod32.z.object({
42227
+ score: import_zod32.z.number().min(0).max(100).describe("The score between 0 and 100.")
41838
42228
  })
41839
42229
  })
41840
42230
  });
@@ -42065,15 +42455,15 @@ Usage:
42065
42455
  - If no todos exist yet, an empty list will be returned`;
42066
42456
 
42067
42457
  // src/templates/tools/todo/todo.ts
42068
- var import_zod32 = __toESM(require("zod"), 1);
42458
+ var import_zod33 = __toESM(require("zod"), 1);
42069
42459
  init_tool();
42070
42460
  init_check_record_access();
42071
42461
  init_client();
42072
- var TodoSchema = import_zod32.default.object({
42073
- content: import_zod32.default.string().describe("Brief description of the task"),
42074
- status: import_zod32.default.string().describe("Current status of the task: pending, in_progress, completed, cancelled"),
42075
- priority: import_zod32.default.string().describe("Priority level of the task: high, medium, low"),
42076
- id: import_zod32.default.string().describe("Unique identifier for the todo item")
42462
+ var TodoSchema = import_zod33.default.object({
42463
+ content: import_zod33.default.string().describe("Brief description of the task"),
42464
+ status: import_zod33.default.string().describe("Current status of the task: pending, in_progress, completed, cancelled"),
42465
+ priority: import_zod33.default.string().describe("Priority level of the task: high, medium, low"),
42466
+ id: import_zod33.default.string().describe("Unique identifier for the todo item")
42077
42467
  });
42078
42468
  var TodoWriteTool = new ExuluTool({
42079
42469
  id: "todo_write",
@@ -42089,8 +42479,8 @@ var TodoWriteTool = new ExuluTool({
42089
42479
  default: todowrite_default
42090
42480
  }
42091
42481
  ],
42092
- inputSchema: import_zod32.default.object({
42093
- todos: import_zod32.default.array(TodoSchema).describe("The updated todo list")
42482
+ inputSchema: import_zod33.default.object({
42483
+ todos: import_zod33.default.array(TodoSchema).describe("The updated todo list")
42094
42484
  }),
42095
42485
  execute: async (inputs) => {
42096
42486
  const { sessionID, todos, user } = inputs;
@@ -42125,7 +42515,7 @@ var TodoReadTool = new ExuluTool({
42125
42515
  id: "todo_read",
42126
42516
  name: "Todo Read",
42127
42517
  description: "Use this tool to read your todo list",
42128
- inputSchema: import_zod32.default.object({}),
42518
+ inputSchema: import_zod33.default.object({}),
42129
42519
  type: "function",
42130
42520
  category: "todo",
42131
42521
  config: [
@@ -42170,7 +42560,7 @@ init_cjs_shims();
42170
42560
  var questionread_default = 'Use this tool to read questions you\'ve asked and check if they\'ve been answered by the user. This tool helps you track the status of questions and retrieve the user\'s selected answers.\n\n## When to Use This Tool\n\nUse this tool proactively in these situations:\n- After asking a question to check if the user has responded\n- To retrieve the user\'s answer before proceeding with implementation\n- To review all questions and answers in the current session\n- When you need to reference a previous answer\n\n## How It Works\n\n- This tool takes no parameters (leave the input blank or empty)\n- Returns an array of all questions in the session\n- Each question includes:\n - `id`: Unique identifier for the question\n - `question`: The question text\n - `answerOptions`: Array of answer options with their IDs and text\n - `status`: Either "pending" (not answered) or "answered"\n - `selectedAnswerId`: The ID of the chosen answer (only present if answered)\n\n## Usage Pattern\n\nTypically you\'ll:\n1. Use Question Ask to pose a question\n2. Wait for the user to respond\n3. Use Question Read to check the answer\n4. Find the selected answer by matching the `selectedAnswerId` with an option in `answerOptions`\n5. Proceed with implementation based on the user\'s choice\n\n## Example Response\n\n```json\n[\n {\n "id": "question123",\n "question": "Which authentication method would you like to implement?",\n "answerOptions": [\n { "id": "ans1", "text": "JWT tokens" },\n { "id": "ans2", "text": "OAuth 2.0" },\n { "id": "ans3", "text": "Session-based auth" },\n { "id": "ans4", "text": "None of the above..." }\n ],\n "status": "answered",\n "selectedAnswerId": "ans1"\n }\n]\n```\n\nIn this example, the user selected "JWT tokens" (id: ans1).\n\n## Important Notes\n\n- If no questions exist in the session, an empty array will be returned\n- Questions remain in the session even after being answered for reference\n- Use the `selectedAnswerId` to find which answer option the user chose by matching it against the `id` field in `answerOptions`\n';
42171
42561
 
42172
42562
  // src/templates/tools/question/question.ts
42173
- var import_zod34 = __toESM(require("zod"), 1);
42563
+ var import_zod35 = __toESM(require("zod"), 1);
42174
42564
  init_tool();
42175
42565
  init_client();
42176
42566
 
@@ -42262,21 +42652,21 @@ After asking a question, use the Question Read tool to check if the user has ans
42262
42652
  `;
42263
42653
 
42264
42654
  // src/templates/tools/question/question-ask.ts
42265
- var import_zod33 = __toESM(require("zod"), 1);
42655
+ var import_zod34 = __toESM(require("zod"), 1);
42266
42656
  init_tool();
42267
42657
  init_check_record_access();
42268
42658
  init_client();
42269
42659
  var import_node_crypto22 = require("crypto");
42270
- var AnswerOptionSchema = import_zod33.default.object({
42271
- id: import_zod33.default.string().describe("Unique identifier for the answer option"),
42272
- text: import_zod33.default.string().describe("The text of the answer option")
42660
+ var AnswerOptionSchema = import_zod34.default.object({
42661
+ id: import_zod34.default.string().describe("Unique identifier for the answer option"),
42662
+ text: import_zod34.default.string().describe("The text of the answer option")
42273
42663
  });
42274
- var _QuestionSchema = import_zod33.default.object({
42275
- id: import_zod33.default.string().describe("Unique identifier for the question"),
42276
- question: import_zod33.default.string().describe("The question to ask the user"),
42277
- answerOptions: import_zod33.default.array(AnswerOptionSchema).describe("Array of possible answer options"),
42278
- selectedAnswerId: import_zod33.default.string().optional().describe("The ID of the answer option selected by the user"),
42279
- status: import_zod33.default.enum(["pending", "answered"]).describe("Status of the question: pending or answered")
42664
+ var _QuestionSchema = import_zod34.default.object({
42665
+ id: import_zod34.default.string().describe("Unique identifier for the question"),
42666
+ question: import_zod34.default.string().describe("The question to ask the user"),
42667
+ answerOptions: import_zod34.default.array(AnswerOptionSchema).describe("Array of possible answer options"),
42668
+ selectedAnswerId: import_zod34.default.string().optional().describe("The ID of the answer option selected by the user"),
42669
+ status: import_zod34.default.enum(["pending", "answered"]).describe("Status of the question: pending or answered")
42280
42670
  });
42281
42671
  var QuestionAskTool = new ExuluTool({
42282
42672
  id: "question_ask",
@@ -42293,9 +42683,9 @@ var QuestionAskTool = new ExuluTool({
42293
42683
  default: questionask_default
42294
42684
  }
42295
42685
  ],
42296
- inputSchema: import_zod33.default.object({
42297
- question: import_zod33.default.string().describe("The question to ask the user"),
42298
- answerOptions: import_zod33.default.array(import_zod33.default.string()).describe("Array of possible answer options (strings)")
42686
+ inputSchema: import_zod34.default.object({
42687
+ question: import_zod34.default.string().describe("The question to ask the user"),
42688
+ answerOptions: import_zod34.default.array(import_zod34.default.string()).describe("Array of possible answer options (strings)")
42299
42689
  }),
42300
42690
  execute: async (inputs) => {
42301
42691
  const { sessionID, question, answerOptions, user } = inputs;
@@ -42368,7 +42758,7 @@ var QuestionReadTool = new ExuluTool({
42368
42758
  name: "Question Read",
42369
42759
  needsApproval: false,
42370
42760
  description: "Use this tool to read questions and their answers",
42371
- inputSchema: import_zod34.default.object({}),
42761
+ inputSchema: import_zod35.default.object({}),
42372
42762
  type: "function",
42373
42763
  category: "question",
42374
42764
  config: [
@@ -42401,7 +42791,7 @@ var questionTools = [QuestionAskTool, QuestionReadTool];
42401
42791
  init_cjs_shims();
42402
42792
  init_tool();
42403
42793
  var nodemailer = __toESM(require("nodemailer"), 1);
42404
- var import_zod35 = require("zod");
42794
+ var import_zod36 = require("zod");
42405
42795
  var transporter = null;
42406
42796
  function getTransporter(config) {
42407
42797
  if (!transporter) {
@@ -42425,11 +42815,11 @@ var emailTool = new ExuluTool({
42425
42815
  id: "email",
42426
42816
  name: "Email",
42427
42817
  description: "Send an email.",
42428
- inputSchema: import_zod35.z.object({
42429
- recipient: import_zod35.z.string().describe("The recipient of the email."),
42430
- subject: import_zod35.z.string().describe("The subject of the email."),
42431
- html: import_zod35.z.string().describe("The HTML body of the email."),
42432
- text: import_zod35.z.string().describe("The text body of the email.")
42818
+ inputSchema: import_zod36.z.object({
42819
+ recipient: import_zod36.z.string().describe("The recipient of the email."),
42820
+ subject: import_zod36.z.string().describe("The subject of the email."),
42821
+ html: import_zod36.z.string().describe("The HTML body of the email."),
42822
+ text: import_zod36.z.string().describe("The text body of the email.")
42433
42823
  }),
42434
42824
  type: "function",
42435
42825
  config: [{
@@ -42501,7 +42891,7 @@ init_supervisor();
42501
42891
  init_client();
42502
42892
  init_rbac_resolver();
42503
42893
  init_check_record_access();
42504
- var import_zod36 = require("zod");
42894
+ var import_zod37 = require("zod");
42505
42895
  var _cachedImageModels;
42506
42896
  var setCachedImageModels = (models2) => {
42507
42897
  _cachedImageModels = models2;
@@ -42562,8 +42952,8 @@ var createImageGenerationWidgetTool = (models2) => {
42562
42952
  needsApproval: false,
42563
42953
  type: "function",
42564
42954
  config: [],
42565
- inputSchema: import_zod36.z.object({
42566
- prompt: import_zod36.z.string().describe(
42955
+ inputSchema: import_zod37.z.object({
42956
+ prompt: import_zod37.z.string().describe(
42567
42957
  "Initial image prompt. The user can edit it before generating."
42568
42958
  )
42569
42959
  }),
@@ -45740,12 +46130,12 @@ async function fitContextProjection({
45740
46130
  const basis = randomizedPCA(vectors, dims, Math.min(budget, dims, vectors.length - 1), seed, POWER_ITERATIONS);
45741
46131
  if (basis.length === 0) return empty(`${contextId} has no variance in its embeddings`);
45742
46132
  const reduced = vectors.map((v) => projectComponents(v, mean, basis));
45743
- const spread = reduced.reduce((s, z37) => s + Math.hypot(...Array.from(z37)), 0) / reduced.length;
46133
+ const spread = reduced.reduce((s, z38) => s + Math.hypot(...Array.from(z38)), 0) / reduced.length;
45744
46134
  if (!Number.isFinite(spread) || spread < 1e-8) return empty(`${contextId} has no variance in its embeddings`);
45745
46135
  log7(`fitting ${contextId}: ${vectors.length} vectors, ${dims} dims \u2192 ${basis.length} components`);
45746
46136
  log7(`${contextId}: laying out ${reduced.length} points in 3d (the slow phase)`);
45747
46137
  const umap = (umapFactory ?? defaultUmap)(seed, reduced.length);
45748
- const raw = umap.fit(reduced.map((z37) => Array.from(z37)));
46138
+ const raw = umap.fit(reduced.map((z38) => Array.from(z38)));
45749
46139
  const oriented = rotateLayout(raw, principalRotation(raw, seed));
45750
46140
  const { points: layout, scale } = normalizeLayout(oriented);
45751
46141
  if (!Number.isFinite(scale) || scale <= 0) return empty(`${contextId} produced a degenerate layout (every point in one place)`);
@@ -45830,13 +46220,13 @@ async function backfillCoordinates({
45830
46220
  const raw = parseVector(row.embedding);
45831
46221
  if (raw.length !== projection.dims) continue;
45832
46222
  const known = layout?.get(String(row.id));
45833
- const [x, y, z37] = known ?? applyMap(
46223
+ const [x, y, z38] = known ?? applyMap(
45834
46224
  projectComponents(l2normalize(raw), mean, basis),
45835
46225
  projection.map,
45836
46226
  projection.intercept
45837
46227
  );
45838
46228
  values.push("(?::uuid, ?::real, ?::real, ?::real)");
45839
- bindings.push(row.id, x, y, z37);
46229
+ bindings.push(row.id, x, y, z38);
45840
46230
  }
45841
46231
  if (values.length) {
45842
46232
  await db2.raw(