@exulu/backend 5.10.1 → 5.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-TFWF6WKM.js → chunk-3AEINUGF.js} +543 -171
- package/dist/{convert-exulu-tools-to-ai-sdk-tools-LL7R3VTK.js → convert-exulu-tools-to-ai-sdk-tools-FX6KTVPQ.js} +1 -1
- package/dist/index.cjs +763 -377
- package/dist/index.d.cts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +8 -16
- package/ee/agentic-retrieval/pipeline/routing.ts +24 -1
- package/package.json +3 -3
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
|
|
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
|
-
|
|
3713
|
+
z38[b] = dot;
|
|
3714
3714
|
}
|
|
3715
3715
|
for (const [b, target] of next.entries()) {
|
|
3716
|
-
const scale =
|
|
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(
|
|
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) * (
|
|
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,
|
|
3843
|
-
total += Math.hypot(x - finite(yi[0]), y - finite(yi[1]),
|
|
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,
|
|
3988
|
-
return { x, y, z:
|
|
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.
|
|
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
|
-
|
|
8742
|
-
|
|
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 =
|
|
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
|
|
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
|
-
|
|
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"] =
|
|
10711
|
-
shape["external_id"] =
|
|
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",
|
|
10714
|
-
addContent("description",
|
|
10715
|
-
addContent("tags",
|
|
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
|
-
|
|
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
|
|
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" ?
|
|
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 =
|
|
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.`) :
|
|
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 =
|
|
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 =
|
|
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 =
|
|
11137
|
+
schema7 = import_zod7.z.number().describe(`The ${field.name} of the item.`);
|
|
10758
11138
|
break;
|
|
10759
11139
|
case "boolean":
|
|
10760
|
-
schema7 =
|
|
11140
|
+
schema7 = import_zod7.z.boolean().describe(`The ${field.name} of the item.`);
|
|
10761
11141
|
break;
|
|
10762
11142
|
default:
|
|
10763
|
-
schema7 =
|
|
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"] =
|
|
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 =
|
|
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:
|
|
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 (
|
|
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 =
|
|
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:
|
|
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 (
|
|
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:
|
|
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
|
|
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,
|
|
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
|
-
|
|
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:
|
|
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:
|
|
11306
|
-
skill:
|
|
11307
|
-
path:
|
|
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:
|
|
11353
|
-
name:
|
|
11354
|
-
description:
|
|
11355
|
-
files:
|
|
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:
|
|
11422
|
-
skill:
|
|
11423
|
-
files:
|
|
11424
|
-
deletePaths:
|
|
11425
|
-
description:
|
|
11426
|
-
label:
|
|
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:
|
|
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:
|
|
13283
|
-
path:
|
|
13284
|
-
content:
|
|
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:
|
|
13304
|
-
path:
|
|
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:
|
|
13322
|
-
command:
|
|
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,
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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:
|
|
13769
|
-
filename:
|
|
13770
|
-
offset:
|
|
13771
|
-
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:
|
|
14376
|
-
needs_correction:
|
|
14377
|
-
corrected_text:
|
|
14378
|
-
current_page_table:
|
|
14379
|
-
headers:
|
|
14380
|
-
is_continuation:
|
|
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:
|
|
14383
|
-
reasoning:
|
|
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,
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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:
|
|
15161
|
-
filename:
|
|
15162
|
-
pages:
|
|
15163
|
-
offset:
|
|
15164
|
-
limit:
|
|
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
|
|
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
|
-
|
|
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:
|
|
15570
|
-
filename:
|
|
15571
|
-
page:
|
|
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
|
|
15802
|
-
let rawItems =
|
|
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 (
|
|
16191
|
+
if (projectRow2 && Array.isArray(rawItems) && rawItems.length > 0) {
|
|
15811
16192
|
projectScope = {
|
|
15812
|
-
id:
|
|
15813
|
-
name:
|
|
15814
|
-
description:
|
|
15815
|
-
customInstructions:
|
|
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,
|
|
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
|
-
|
|
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 ||
|
|
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
|
|
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
|
-
|
|
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 =
|
|
16579
|
-
enabled:
|
|
16580
|
-
kind:
|
|
16581
|
-
instructions:
|
|
16582
|
-
overrides:
|
|
16583
|
-
limit:
|
|
16584
|
-
expand:
|
|
16585
|
-
multiQuery:
|
|
16586
|
-
hyde:
|
|
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 =
|
|
16590
|
-
routingRuleSchema =
|
|
16591
|
-
id:
|
|
16592
|
-
label:
|
|
16593
|
-
description:
|
|
16594
|
-
main:
|
|
16595
|
-
fallback:
|
|
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 =
|
|
16598
|
-
identifierSetSchema =
|
|
16599
|
-
name:
|
|
16600
|
-
description:
|
|
16601
|
-
examples:
|
|
16602
|
-
strategy:
|
|
16603
|
-
contexts:
|
|
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 =
|
|
16606
|
-
glossary:
|
|
16607
|
-
identifiers:
|
|
16608
|
-
rewrites:
|
|
16609
|
-
styleHint:
|
|
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 =
|
|
16612
|
-
enabled:
|
|
16613
|
-
override:
|
|
16614
|
-
filePrioritization:
|
|
16615
|
-
queryAugmentation:
|
|
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 =
|
|
16618
|
-
topK:
|
|
16619
|
-
fallbackThreshold:
|
|
16620
|
-
pinBoost:
|
|
16621
|
-
identifierBoost:
|
|
16622
|
-
pageWindow:
|
|
16623
|
-
maxQueriesPerContext:
|
|
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:
|
|
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:
|
|
16632
|
-
mergedMemoryCall:
|
|
16633
|
-
mergedRoutingCall:
|
|
16634
|
-
parallelPins:
|
|
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 =
|
|
16638
|
-
enabled:
|
|
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:
|
|
16641
|
-
fidelity:
|
|
16642
|
-
completions:
|
|
16643
|
-
reRetrieve:
|
|
16644
|
-
thresholds:
|
|
16645
|
-
warn:
|
|
16646
|
-
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:
|
|
16649
|
-
caps:
|
|
16650
|
-
maxSentences:
|
|
16651
|
-
maxClaims:
|
|
16652
|
-
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:
|
|
16989
|
-
hasMatches:
|
|
16990
|
-
matches:
|
|
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,
|
|
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
|
-
|
|
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 =
|
|
17129
|
-
docPage:
|
|
17130
|
-
hasFilenameHint:
|
|
17131
|
-
filenameHints:
|
|
17132
|
-
hasPageHint:
|
|
17133
|
-
pageNumber:
|
|
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:
|
|
17516
|
+
explicitlyRequestedKnowledgeBases: import_zod17.z.array(import_zod17.z.enum(ids)),
|
|
17136
17517
|
...routingRules.length ? {
|
|
17137
|
-
classification:
|
|
17138
|
-
ruleId:
|
|
17139
|
-
reason:
|
|
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:
|
|
17199
|
-
hasFilenameHint:
|
|
17200
|
-
filenameHints:
|
|
17201
|
-
hasPageHint:
|
|
17202
|
-
pageNumber:
|
|
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:
|
|
17223
|
-
explicitlyRequestedKnowledgeBases:
|
|
17224
|
-
|
|
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:
|
|
17316
|
-
ruleId:
|
|
17317
|
-
reason:
|
|
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
|
|
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
|
-
|
|
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:
|
|
17483
|
-
relevantChunkIds:
|
|
17484
|
-
override:
|
|
17485
|
-
overrides:
|
|
17486
|
-
confidence:
|
|
17487
|
-
authoritativeChunkIds:
|
|
17488
|
-
reason:
|
|
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:
|
|
17491
|
-
shouldPrioritizeFiles:
|
|
17492
|
-
fileNameHints:
|
|
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:
|
|
17495
|
-
updatedUserQuestion:
|
|
17496
|
-
updatedRelevantKeywords:
|
|
17497
|
-
updatedImportantKeyword:
|
|
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:
|
|
17581
|
-
relevantChunkIds:
|
|
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:
|
|
17691
|
-
overrides:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
17725
|
-
shouldPrioritizeFiles:
|
|
17726
|
-
fileNameHints:
|
|
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:
|
|
17739
|
-
updatedUserQuestion:
|
|
17740
|
-
updatedRelevantKeywords:
|
|
17741
|
-
updatedImportantKeyword:
|
|
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
|
|
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
|
-
|
|
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:
|
|
18681
|
-
userQuery:
|
|
18682
|
-
relevantKeywords:
|
|
18683
|
-
importantKeyword:
|
|
18684
|
-
confirmedContextIds:
|
|
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
|
|
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
|
-
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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
|
|
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:
|
|
24675
|
-
prompt:
|
|
24676
|
-
information:
|
|
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: [],
|
|
@@ -30060,12 +30442,12 @@ async function runScan({ db: db2, context, user, judge, now = /* @__PURE__ */ ne
|
|
|
30060
30442
|
// src/exulu/memory/conflicts/judge.ts
|
|
30061
30443
|
init_cjs_shims();
|
|
30062
30444
|
var import_ai10 = require("ai");
|
|
30063
|
-
var
|
|
30445
|
+
var import_zod21 = require("zod");
|
|
30064
30446
|
init_resolve_model();
|
|
30065
|
-
var schema =
|
|
30066
|
-
verdict:
|
|
30447
|
+
var schema = import_zod21.z.object({
|
|
30448
|
+
verdict: import_zod21.z.enum(["same", "contradict", "compatible"]),
|
|
30067
30449
|
// No .max(160) here: an over-long reason must not fail the whole call — truncate after.
|
|
30068
|
-
reason:
|
|
30450
|
+
reason: import_zod21.z.string()
|
|
30069
30451
|
});
|
|
30070
30452
|
var SYSTEM = `You compare two short memories an assistant saved from conversations.
|
|
30071
30453
|
Answer with JSON: verdict = "same" when both state the same fact or instruction (wording may differ),
|
|
@@ -30100,7 +30482,7 @@ async function makeMergeSuggester({ modelId, agent, user }) {
|
|
|
30100
30482
|
prompt: members.map((m, i) => `Memory ${i + 1}:
|
|
30101
30483
|
${m.information}`).join("\n\n"),
|
|
30102
30484
|
maxRetries: 1,
|
|
30103
|
-
output: import_ai10.Output.object({ schema:
|
|
30485
|
+
output: import_ai10.Output.object({ schema: import_zod21.z.object({ information: import_zod21.z.string().min(1).max(400) }) })
|
|
30104
30486
|
});
|
|
30105
30487
|
const types = members.map((m) => m.type).filter((t) => !!t);
|
|
30106
30488
|
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 +33535,12 @@ init_statistics2();
|
|
|
33153
33535
|
// src/exulu/suggestions.ts
|
|
33154
33536
|
init_cjs_shims();
|
|
33155
33537
|
var import_ai11 = require("ai");
|
|
33156
|
-
var
|
|
33538
|
+
var import_zod22 = require("zod");
|
|
33157
33539
|
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
33540
|
var submitSuggestionsTool = (0, import_ai11.tool)({
|
|
33159
33541
|
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:
|
|
33161
|
-
suggestions:
|
|
33542
|
+
inputSchema: import_zod22.z.object({
|
|
33543
|
+
suggestions: import_zod22.z.array(import_zod22.z.string()).max(3)
|
|
33162
33544
|
})
|
|
33163
33545
|
});
|
|
33164
33546
|
var MAX_CHARS_PER_MESSAGE = 1e4;
|
|
@@ -33389,16 +33771,16 @@ init_view_document_page_tool();
|
|
|
33389
33771
|
// src/templates/tools/perplexity.ts
|
|
33390
33772
|
init_cjs_shims();
|
|
33391
33773
|
init_tool();
|
|
33392
|
-
var
|
|
33774
|
+
var import_zod23 = __toESM(require("zod"), 1);
|
|
33393
33775
|
var import_perplexity_ai = __toESM(require("@perplexity-ai/perplexity_ai"), 1);
|
|
33394
33776
|
var INTERNET_SEARCH_TOOL_NAME = "Internet Search";
|
|
33395
33777
|
var internetSearchTool = new ExuluTool({
|
|
33396
33778
|
id: "internet_search",
|
|
33397
33779
|
name: INTERNET_SEARCH_TOOL_NAME,
|
|
33398
33780
|
description: "Search the internet for information.",
|
|
33399
|
-
inputSchema:
|
|
33400
|
-
query:
|
|
33401
|
-
search_recency_filter:
|
|
33781
|
+
inputSchema: import_zod23.default.object({
|
|
33782
|
+
query: import_zod23.default.string().describe("The query to the tool."),
|
|
33783
|
+
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
33784
|
}),
|
|
33403
33785
|
category: "internet_search",
|
|
33404
33786
|
type: "web_search",
|
|
@@ -33670,6 +34052,9 @@ function claimCheckStreamMetadata(ctx) {
|
|
|
33670
34052
|
};
|
|
33671
34053
|
}
|
|
33672
34054
|
|
|
34055
|
+
// src/exulu/routes.ts
|
|
34056
|
+
init_public_surface();
|
|
34057
|
+
|
|
33673
34058
|
// src/exulu/transcribe.ts
|
|
33674
34059
|
init_cjs_shims();
|
|
33675
34060
|
init_env();
|
|
@@ -34156,8 +34541,9 @@ function registerViewerIdentityRoutes(app, deps) {
|
|
|
34156
34541
|
|
|
34157
34542
|
// ee/claim-check/routes.ts
|
|
34158
34543
|
init_cjs_shims();
|
|
34159
|
-
var
|
|
34544
|
+
var import_zod24 = require("zod");
|
|
34160
34545
|
init_resolve_max_steps();
|
|
34546
|
+
init_public_surface();
|
|
34161
34547
|
init_types2();
|
|
34162
34548
|
|
|
34163
34549
|
// ee/claim-check/agent-config.ts
|
|
@@ -34219,13 +34605,13 @@ var SOURCE_TYPES = [
|
|
|
34219
34605
|
"session_item",
|
|
34220
34606
|
"other"
|
|
34221
34607
|
];
|
|
34222
|
-
var requestSchema =
|
|
34223
|
-
question:
|
|
34224
|
-
answer:
|
|
34225
|
-
sources:
|
|
34226
|
-
|
|
34227
|
-
content:
|
|
34228
|
-
name:
|
|
34608
|
+
var requestSchema = import_zod24.z.object({
|
|
34609
|
+
question: import_zod24.z.string().min(1),
|
|
34610
|
+
answer: import_zod24.z.string().min(1),
|
|
34611
|
+
sources: import_zod24.z.array(
|
|
34612
|
+
import_zod24.z.object({
|
|
34613
|
+
content: import_zod24.z.string(),
|
|
34614
|
+
name: import_zod24.z.string().optional(),
|
|
34229
34615
|
// Purely informational (spec §2: no trust tiers, dropped before the
|
|
34230
34616
|
// engine sees it — see assignSourceIds below), so an unrecognised
|
|
34231
34617
|
// value is IGNORED, not rejected: `.catch(undefined)` keeps the enum
|
|
@@ -34237,24 +34623,24 @@ var requestSchema = import_zod23.z.object({
|
|
|
34237
34623
|
// `.catch`) would turn that pre-existing 200 into a 400, which is a
|
|
34238
34624
|
// tightening this loosening-only task must not make. Do not remove
|
|
34239
34625
|
// the `.catch` to "validate properly": that is the bug this guards.
|
|
34240
|
-
type:
|
|
34241
|
-
id:
|
|
34626
|
+
type: import_zod24.z.enum(SOURCE_TYPES).optional().catch(void 0),
|
|
34627
|
+
id: import_zod24.z.string().min(1).optional()
|
|
34242
34628
|
})
|
|
34243
34629
|
).default([]),
|
|
34244
|
-
agent:
|
|
34245
|
-
session:
|
|
34246
|
-
messageId:
|
|
34247
|
-
model:
|
|
34248
|
-
locale:
|
|
34249
|
-
options:
|
|
34250
|
-
fidelity:
|
|
34251
|
-
completions:
|
|
34252
|
-
reRetrieve:
|
|
34253
|
-
thresholds:
|
|
34254
|
-
caps:
|
|
34255
|
-
maxSentences:
|
|
34256
|
-
maxClaims:
|
|
34257
|
-
maxReRetrievals:
|
|
34630
|
+
agent: import_zod24.z.string().optional(),
|
|
34631
|
+
session: import_zod24.z.string().optional(),
|
|
34632
|
+
messageId: import_zod24.z.string().optional(),
|
|
34633
|
+
model: import_zod24.z.string().optional(),
|
|
34634
|
+
locale: import_zod24.z.string().refine(localeIsUsable, { message: "locale is not a usable BCP 47 language tag" }).optional(),
|
|
34635
|
+
options: import_zod24.z.object({
|
|
34636
|
+
fidelity: import_zod24.z.enum(["fast", "paper"]).optional(),
|
|
34637
|
+
completions: import_zod24.z.number().int().min(1).max(3).optional(),
|
|
34638
|
+
reRetrieve: import_zod24.z.boolean().optional(),
|
|
34639
|
+
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(),
|
|
34640
|
+
caps: import_zod24.z.object({
|
|
34641
|
+
maxSentences: import_zod24.z.number().int().positive(),
|
|
34642
|
+
maxClaims: import_zod24.z.number().int().positive(),
|
|
34643
|
+
maxReRetrievals: import_zod24.z.number().int().min(0)
|
|
34258
34644
|
}).partial().optional()
|
|
34259
34645
|
}).optional()
|
|
34260
34646
|
});
|
|
@@ -34848,7 +35234,7 @@ function selectEvidence(claimTexts, index, topK = 4) {
|
|
|
34848
35234
|
|
|
34849
35235
|
// ee/claim-check/stages/select-disambiguate.ts
|
|
34850
35236
|
init_cjs_shims();
|
|
34851
|
-
var
|
|
35237
|
+
var import_zod26 = require("zod");
|
|
34852
35238
|
init_micro_call();
|
|
34853
35239
|
init_types2();
|
|
34854
35240
|
|
|
@@ -34985,16 +35371,16 @@ resolvable=false and clarified=null for it.`;
|
|
|
34985
35371
|
|
|
34986
35372
|
// ee/claim-check/stages/select.ts
|
|
34987
35373
|
init_cjs_shims();
|
|
34988
|
-
var
|
|
35374
|
+
var import_zod25 = require("zod");
|
|
34989
35375
|
init_micro_call();
|
|
34990
35376
|
init_types2();
|
|
34991
|
-
var schema2 =
|
|
34992
|
-
sentences:
|
|
34993
|
-
|
|
34994
|
-
index:
|
|
34995
|
-
verifiable:
|
|
34996
|
-
rewritten:
|
|
34997
|
-
reason:
|
|
35377
|
+
var schema2 = import_zod25.z.object({
|
|
35378
|
+
sentences: import_zod25.z.array(
|
|
35379
|
+
import_zod25.z.object({
|
|
35380
|
+
index: import_zod25.z.number().int(),
|
|
35381
|
+
verifiable: import_zod25.z.boolean(),
|
|
35382
|
+
rewritten: import_zod25.z.string().nullable(),
|
|
35383
|
+
reason: import_zod25.z.string()
|
|
34998
35384
|
})
|
|
34999
35385
|
)
|
|
35000
35386
|
});
|
|
@@ -35052,15 +35438,15 @@ async function runSelection(args) {
|
|
|
35052
35438
|
}
|
|
35053
35439
|
|
|
35054
35440
|
// ee/claim-check/stages/select-disambiguate.ts
|
|
35055
|
-
var schema3 =
|
|
35056
|
-
sentences:
|
|
35057
|
-
|
|
35058
|
-
index:
|
|
35059
|
-
verifiable:
|
|
35060
|
-
rewritten:
|
|
35061
|
-
resolvable:
|
|
35062
|
-
clarified:
|
|
35063
|
-
reason:
|
|
35441
|
+
var schema3 = import_zod26.z.object({
|
|
35442
|
+
sentences: import_zod26.z.array(
|
|
35443
|
+
import_zod26.z.object({
|
|
35444
|
+
index: import_zod26.z.number().int(),
|
|
35445
|
+
verifiable: import_zod26.z.boolean(),
|
|
35446
|
+
rewritten: import_zod26.z.string().nullable(),
|
|
35447
|
+
resolvable: import_zod26.z.boolean(),
|
|
35448
|
+
clarified: import_zod26.z.string().nullable(),
|
|
35449
|
+
reason: import_zod26.z.string()
|
|
35064
35450
|
})
|
|
35065
35451
|
)
|
|
35066
35452
|
});
|
|
@@ -35111,16 +35497,16 @@ async function runSelectAndDisambiguate(args) {
|
|
|
35111
35497
|
|
|
35112
35498
|
// ee/claim-check/stages/disambiguate.ts
|
|
35113
35499
|
init_cjs_shims();
|
|
35114
|
-
var
|
|
35500
|
+
var import_zod27 = require("zod");
|
|
35115
35501
|
init_micro_call();
|
|
35116
35502
|
init_types2();
|
|
35117
|
-
var schema4 =
|
|
35118
|
-
sentences:
|
|
35119
|
-
|
|
35120
|
-
index:
|
|
35121
|
-
resolvable:
|
|
35122
|
-
clarified:
|
|
35123
|
-
reason:
|
|
35503
|
+
var schema4 = import_zod27.z.object({
|
|
35504
|
+
sentences: import_zod27.z.array(
|
|
35505
|
+
import_zod27.z.object({
|
|
35506
|
+
index: import_zod27.z.number().int(),
|
|
35507
|
+
resolvable: import_zod27.z.boolean(),
|
|
35508
|
+
clarified: import_zod27.z.string().nullable(),
|
|
35509
|
+
reason: import_zod27.z.string()
|
|
35124
35510
|
})
|
|
35125
35511
|
)
|
|
35126
35512
|
});
|
|
@@ -35167,7 +35553,7 @@ async function runDisambiguation(args) {
|
|
|
35167
35553
|
|
|
35168
35554
|
// ee/claim-check/stages/decompose.ts
|
|
35169
35555
|
init_cjs_shims();
|
|
35170
|
-
var
|
|
35556
|
+
var import_zod28 = require("zod");
|
|
35171
35557
|
init_micro_call();
|
|
35172
35558
|
init_types2();
|
|
35173
35559
|
|
|
@@ -35218,11 +35604,11 @@ function decomposeUserPrompt(args) {
|
|
|
35218
35604
|
}
|
|
35219
35605
|
|
|
35220
35606
|
// ee/claim-check/stages/decompose.ts
|
|
35221
|
-
var schema5 =
|
|
35222
|
-
sentences:
|
|
35223
|
-
|
|
35224
|
-
index:
|
|
35225
|
-
claims:
|
|
35607
|
+
var schema5 = import_zod28.z.object({
|
|
35608
|
+
sentences: import_zod28.z.array(
|
|
35609
|
+
import_zod28.z.object({
|
|
35610
|
+
index: import_zod28.z.number().int(),
|
|
35611
|
+
claims: import_zod28.z.array(import_zod28.z.object({ text: import_zod28.z.string(), inferred: import_zod28.z.boolean() }))
|
|
35226
35612
|
})
|
|
35227
35613
|
)
|
|
35228
35614
|
});
|
|
@@ -35258,7 +35644,7 @@ async function runDecomposition(args) {
|
|
|
35258
35644
|
|
|
35259
35645
|
// ee/claim-check/stages/verify.ts
|
|
35260
35646
|
init_cjs_shims();
|
|
35261
|
-
var
|
|
35647
|
+
var import_zod29 = require("zod");
|
|
35262
35648
|
init_micro_call();
|
|
35263
35649
|
init_types2();
|
|
35264
35650
|
|
|
@@ -35320,13 +35706,13 @@ function addUsage(a, b) {
|
|
|
35320
35706
|
}
|
|
35321
35707
|
|
|
35322
35708
|
// ee/claim-check/stages/verify.ts
|
|
35323
|
-
var schema6 =
|
|
35324
|
-
claims:
|
|
35325
|
-
|
|
35326
|
-
claimId:
|
|
35327
|
-
verdict:
|
|
35328
|
-
evidence:
|
|
35329
|
-
rationale:
|
|
35709
|
+
var schema6 = import_zod29.z.object({
|
|
35710
|
+
claims: import_zod29.z.array(
|
|
35711
|
+
import_zod29.z.object({
|
|
35712
|
+
claimId: import_zod29.z.string(),
|
|
35713
|
+
verdict: import_zod29.z.enum(["supported", "contradicted", "unsupported"]),
|
|
35714
|
+
evidence: import_zod29.z.array(import_zod29.z.object({ sourceId: import_zod29.z.string(), quote: import_zod29.z.string() })),
|
|
35715
|
+
rationale: import_zod29.z.string()
|
|
35330
35716
|
})
|
|
35331
35717
|
)
|
|
35332
35718
|
});
|
|
@@ -36581,13 +36967,13 @@ var handleOauthCallback = async (req, res) => {
|
|
|
36581
36967
|
|
|
36582
36968
|
// src/exulu/auth/submit-handler.ts
|
|
36583
36969
|
init_cjs_shims();
|
|
36584
|
-
var
|
|
36970
|
+
var import_zod30 = require("zod");
|
|
36585
36971
|
init_registry();
|
|
36586
36972
|
init_credential_store();
|
|
36587
36973
|
init_credentials_request();
|
|
36588
|
-
var bodySchema =
|
|
36589
|
-
nonce:
|
|
36590
|
-
values:
|
|
36974
|
+
var bodySchema = import_zod30.z.object({
|
|
36975
|
+
nonce: import_zod30.z.string().min(1),
|
|
36976
|
+
values: import_zod30.z.record(import_zod30.z.string(), import_zod30.z.string())
|
|
36591
36977
|
});
|
|
36592
36978
|
async function handleCredentialSubmit(req, res) {
|
|
36593
36979
|
const authResult = await requestValidators.authenticate(req);
|
|
@@ -41379,7 +41765,7 @@ init_check_record_access();
|
|
|
41379
41765
|
init_resolve_model();
|
|
41380
41766
|
init_supervisor();
|
|
41381
41767
|
init_client();
|
|
41382
|
-
var
|
|
41768
|
+
var import_zod31 = require("zod");
|
|
41383
41769
|
init_convert_exulu_tools_to_ai_sdk_tools();
|
|
41384
41770
|
init_singleton();
|
|
41385
41771
|
var SESSION_ID_HEADER = "mcp-session-id";
|
|
@@ -41443,7 +41829,7 @@ var ExuluMCP = class {
|
|
|
41443
41829
|
title: tool4.name + " agent",
|
|
41444
41830
|
description: tool4.description,
|
|
41445
41831
|
inputSchema: {
|
|
41446
|
-
inputs: tool4.inputSchema ||
|
|
41832
|
+
inputs: tool4.inputSchema || import_zod31.z.object({})
|
|
41447
41833
|
}
|
|
41448
41834
|
},
|
|
41449
41835
|
async ({ inputs }, args) => {
|
|
@@ -41494,7 +41880,7 @@ var ExuluMCP = class {
|
|
|
41494
41880
|
title: "Get List of Prompt Templates",
|
|
41495
41881
|
description: "Retrieves a list of prompt templates available for this agent. Returns the name, description, and ID of each template.",
|
|
41496
41882
|
inputSchema: {
|
|
41497
|
-
inputs:
|
|
41883
|
+
inputs: import_zod31.z.object({})
|
|
41498
41884
|
}
|
|
41499
41885
|
},
|
|
41500
41886
|
async ({ inputs }, args) => {
|
|
@@ -41540,8 +41926,8 @@ var ExuluMCP = class {
|
|
|
41540
41926
|
title: "Get Prompt Template Details",
|
|
41541
41927
|
description: "Retrieves the full details of a specific prompt template by ID, including the actual template content with variables.",
|
|
41542
41928
|
inputSchema: {
|
|
41543
|
-
inputs:
|
|
41544
|
-
id:
|
|
41929
|
+
inputs: import_zod31.z.object({
|
|
41930
|
+
id: import_zod31.z.string().describe("The ID of the prompt template to retrieve")
|
|
41545
41931
|
})
|
|
41546
41932
|
}
|
|
41547
41933
|
},
|
|
@@ -41782,7 +42168,7 @@ var ExuluEval = class {
|
|
|
41782
42168
|
// src/templates/evals/index.ts
|
|
41783
42169
|
init_resolve_model();
|
|
41784
42170
|
init_singleton();
|
|
41785
|
-
var
|
|
42171
|
+
var import_zod32 = require("zod");
|
|
41786
42172
|
var import_ai17 = require("ai");
|
|
41787
42173
|
var llmAsJudgeEval = () => {
|
|
41788
42174
|
if (process.env.REDIS_HOST?.length && process.env.REDIS_PORT?.length) {
|
|
@@ -41833,8 +42219,8 @@ var llmAsJudgeEval = () => {
|
|
|
41833
42219
|
prompt,
|
|
41834
42220
|
maxRetries: 2,
|
|
41835
42221
|
output: import_ai17.Output.object({
|
|
41836
|
-
schema:
|
|
41837
|
-
score:
|
|
42222
|
+
schema: import_zod32.z.object({
|
|
42223
|
+
score: import_zod32.z.number().min(0).max(100).describe("The score between 0 and 100.")
|
|
41838
42224
|
})
|
|
41839
42225
|
})
|
|
41840
42226
|
});
|
|
@@ -42065,15 +42451,15 @@ Usage:
|
|
|
42065
42451
|
- If no todos exist yet, an empty list will be returned`;
|
|
42066
42452
|
|
|
42067
42453
|
// src/templates/tools/todo/todo.ts
|
|
42068
|
-
var
|
|
42454
|
+
var import_zod33 = __toESM(require("zod"), 1);
|
|
42069
42455
|
init_tool();
|
|
42070
42456
|
init_check_record_access();
|
|
42071
42457
|
init_client();
|
|
42072
|
-
var TodoSchema =
|
|
42073
|
-
content:
|
|
42074
|
-
status:
|
|
42075
|
-
priority:
|
|
42076
|
-
id:
|
|
42458
|
+
var TodoSchema = import_zod33.default.object({
|
|
42459
|
+
content: import_zod33.default.string().describe("Brief description of the task"),
|
|
42460
|
+
status: import_zod33.default.string().describe("Current status of the task: pending, in_progress, completed, cancelled"),
|
|
42461
|
+
priority: import_zod33.default.string().describe("Priority level of the task: high, medium, low"),
|
|
42462
|
+
id: import_zod33.default.string().describe("Unique identifier for the todo item")
|
|
42077
42463
|
});
|
|
42078
42464
|
var TodoWriteTool = new ExuluTool({
|
|
42079
42465
|
id: "todo_write",
|
|
@@ -42089,8 +42475,8 @@ var TodoWriteTool = new ExuluTool({
|
|
|
42089
42475
|
default: todowrite_default
|
|
42090
42476
|
}
|
|
42091
42477
|
],
|
|
42092
|
-
inputSchema:
|
|
42093
|
-
todos:
|
|
42478
|
+
inputSchema: import_zod33.default.object({
|
|
42479
|
+
todos: import_zod33.default.array(TodoSchema).describe("The updated todo list")
|
|
42094
42480
|
}),
|
|
42095
42481
|
execute: async (inputs) => {
|
|
42096
42482
|
const { sessionID, todos, user } = inputs;
|
|
@@ -42125,7 +42511,7 @@ var TodoReadTool = new ExuluTool({
|
|
|
42125
42511
|
id: "todo_read",
|
|
42126
42512
|
name: "Todo Read",
|
|
42127
42513
|
description: "Use this tool to read your todo list",
|
|
42128
|
-
inputSchema:
|
|
42514
|
+
inputSchema: import_zod33.default.object({}),
|
|
42129
42515
|
type: "function",
|
|
42130
42516
|
category: "todo",
|
|
42131
42517
|
config: [
|
|
@@ -42170,7 +42556,7 @@ init_cjs_shims();
|
|
|
42170
42556
|
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
42557
|
|
|
42172
42558
|
// src/templates/tools/question/question.ts
|
|
42173
|
-
var
|
|
42559
|
+
var import_zod35 = __toESM(require("zod"), 1);
|
|
42174
42560
|
init_tool();
|
|
42175
42561
|
init_client();
|
|
42176
42562
|
|
|
@@ -42262,21 +42648,21 @@ After asking a question, use the Question Read tool to check if the user has ans
|
|
|
42262
42648
|
`;
|
|
42263
42649
|
|
|
42264
42650
|
// src/templates/tools/question/question-ask.ts
|
|
42265
|
-
var
|
|
42651
|
+
var import_zod34 = __toESM(require("zod"), 1);
|
|
42266
42652
|
init_tool();
|
|
42267
42653
|
init_check_record_access();
|
|
42268
42654
|
init_client();
|
|
42269
42655
|
var import_node_crypto22 = require("crypto");
|
|
42270
|
-
var AnswerOptionSchema =
|
|
42271
|
-
id:
|
|
42272
|
-
text:
|
|
42656
|
+
var AnswerOptionSchema = import_zod34.default.object({
|
|
42657
|
+
id: import_zod34.default.string().describe("Unique identifier for the answer option"),
|
|
42658
|
+
text: import_zod34.default.string().describe("The text of the answer option")
|
|
42273
42659
|
});
|
|
42274
|
-
var _QuestionSchema =
|
|
42275
|
-
id:
|
|
42276
|
-
question:
|
|
42277
|
-
answerOptions:
|
|
42278
|
-
selectedAnswerId:
|
|
42279
|
-
status:
|
|
42660
|
+
var _QuestionSchema = import_zod34.default.object({
|
|
42661
|
+
id: import_zod34.default.string().describe("Unique identifier for the question"),
|
|
42662
|
+
question: import_zod34.default.string().describe("The question to ask the user"),
|
|
42663
|
+
answerOptions: import_zod34.default.array(AnswerOptionSchema).describe("Array of possible answer options"),
|
|
42664
|
+
selectedAnswerId: import_zod34.default.string().optional().describe("The ID of the answer option selected by the user"),
|
|
42665
|
+
status: import_zod34.default.enum(["pending", "answered"]).describe("Status of the question: pending or answered")
|
|
42280
42666
|
});
|
|
42281
42667
|
var QuestionAskTool = new ExuluTool({
|
|
42282
42668
|
id: "question_ask",
|
|
@@ -42293,9 +42679,9 @@ var QuestionAskTool = new ExuluTool({
|
|
|
42293
42679
|
default: questionask_default
|
|
42294
42680
|
}
|
|
42295
42681
|
],
|
|
42296
|
-
inputSchema:
|
|
42297
|
-
question:
|
|
42298
|
-
answerOptions:
|
|
42682
|
+
inputSchema: import_zod34.default.object({
|
|
42683
|
+
question: import_zod34.default.string().describe("The question to ask the user"),
|
|
42684
|
+
answerOptions: import_zod34.default.array(import_zod34.default.string()).describe("Array of possible answer options (strings)")
|
|
42299
42685
|
}),
|
|
42300
42686
|
execute: async (inputs) => {
|
|
42301
42687
|
const { sessionID, question, answerOptions, user } = inputs;
|
|
@@ -42368,7 +42754,7 @@ var QuestionReadTool = new ExuluTool({
|
|
|
42368
42754
|
name: "Question Read",
|
|
42369
42755
|
needsApproval: false,
|
|
42370
42756
|
description: "Use this tool to read questions and their answers",
|
|
42371
|
-
inputSchema:
|
|
42757
|
+
inputSchema: import_zod35.default.object({}),
|
|
42372
42758
|
type: "function",
|
|
42373
42759
|
category: "question",
|
|
42374
42760
|
config: [
|
|
@@ -42401,7 +42787,7 @@ var questionTools = [QuestionAskTool, QuestionReadTool];
|
|
|
42401
42787
|
init_cjs_shims();
|
|
42402
42788
|
init_tool();
|
|
42403
42789
|
var nodemailer = __toESM(require("nodemailer"), 1);
|
|
42404
|
-
var
|
|
42790
|
+
var import_zod36 = require("zod");
|
|
42405
42791
|
var transporter = null;
|
|
42406
42792
|
function getTransporter(config) {
|
|
42407
42793
|
if (!transporter) {
|
|
@@ -42425,11 +42811,11 @@ var emailTool = new ExuluTool({
|
|
|
42425
42811
|
id: "email",
|
|
42426
42812
|
name: "Email",
|
|
42427
42813
|
description: "Send an email.",
|
|
42428
|
-
inputSchema:
|
|
42429
|
-
recipient:
|
|
42430
|
-
subject:
|
|
42431
|
-
html:
|
|
42432
|
-
text:
|
|
42814
|
+
inputSchema: import_zod36.z.object({
|
|
42815
|
+
recipient: import_zod36.z.string().describe("The recipient of the email."),
|
|
42816
|
+
subject: import_zod36.z.string().describe("The subject of the email."),
|
|
42817
|
+
html: import_zod36.z.string().describe("The HTML body of the email."),
|
|
42818
|
+
text: import_zod36.z.string().describe("The text body of the email.")
|
|
42433
42819
|
}),
|
|
42434
42820
|
type: "function",
|
|
42435
42821
|
config: [{
|
|
@@ -42501,7 +42887,7 @@ init_supervisor();
|
|
|
42501
42887
|
init_client();
|
|
42502
42888
|
init_rbac_resolver();
|
|
42503
42889
|
init_check_record_access();
|
|
42504
|
-
var
|
|
42890
|
+
var import_zod37 = require("zod");
|
|
42505
42891
|
var _cachedImageModels;
|
|
42506
42892
|
var setCachedImageModels = (models2) => {
|
|
42507
42893
|
_cachedImageModels = models2;
|
|
@@ -42562,8 +42948,8 @@ var createImageGenerationWidgetTool = (models2) => {
|
|
|
42562
42948
|
needsApproval: false,
|
|
42563
42949
|
type: "function",
|
|
42564
42950
|
config: [],
|
|
42565
|
-
inputSchema:
|
|
42566
|
-
prompt:
|
|
42951
|
+
inputSchema: import_zod37.z.object({
|
|
42952
|
+
prompt: import_zod37.z.string().describe(
|
|
42567
42953
|
"Initial image prompt. The user can edit it before generating."
|
|
42568
42954
|
)
|
|
42569
42955
|
}),
|
|
@@ -45740,12 +46126,12 @@ async function fitContextProjection({
|
|
|
45740
46126
|
const basis = randomizedPCA(vectors, dims, Math.min(budget, dims, vectors.length - 1), seed, POWER_ITERATIONS);
|
|
45741
46127
|
if (basis.length === 0) return empty(`${contextId} has no variance in its embeddings`);
|
|
45742
46128
|
const reduced = vectors.map((v) => projectComponents(v, mean, basis));
|
|
45743
|
-
const spread = reduced.reduce((s,
|
|
46129
|
+
const spread = reduced.reduce((s, z38) => s + Math.hypot(...Array.from(z38)), 0) / reduced.length;
|
|
45744
46130
|
if (!Number.isFinite(spread) || spread < 1e-8) return empty(`${contextId} has no variance in its embeddings`);
|
|
45745
46131
|
log7(`fitting ${contextId}: ${vectors.length} vectors, ${dims} dims \u2192 ${basis.length} components`);
|
|
45746
46132
|
log7(`${contextId}: laying out ${reduced.length} points in 3d (the slow phase)`);
|
|
45747
46133
|
const umap = (umapFactory ?? defaultUmap)(seed, reduced.length);
|
|
45748
|
-
const raw = umap.fit(reduced.map((
|
|
46134
|
+
const raw = umap.fit(reduced.map((z38) => Array.from(z38)));
|
|
45749
46135
|
const oriented = rotateLayout(raw, principalRotation(raw, seed));
|
|
45750
46136
|
const { points: layout, scale } = normalizeLayout(oriented);
|
|
45751
46137
|
if (!Number.isFinite(scale) || scale <= 0) return empty(`${contextId} produced a degenerate layout (every point in one place)`);
|
|
@@ -45830,13 +46216,13 @@ async function backfillCoordinates({
|
|
|
45830
46216
|
const raw = parseVector(row.embedding);
|
|
45831
46217
|
if (raw.length !== projection.dims) continue;
|
|
45832
46218
|
const known = layout?.get(String(row.id));
|
|
45833
|
-
const [x, y,
|
|
46219
|
+
const [x, y, z38] = known ?? applyMap(
|
|
45834
46220
|
projectComponents(l2normalize(raw), mean, basis),
|
|
45835
46221
|
projection.map,
|
|
45836
46222
|
projection.intercept
|
|
45837
46223
|
);
|
|
45838
46224
|
values.push("(?::uuid, ?::real, ?::real, ?::real)");
|
|
45839
|
-
bindings.push(row.id, x, y,
|
|
46225
|
+
bindings.push(row.id, x, y, z38);
|
|
45840
46226
|
}
|
|
45841
46227
|
if (values.length) {
|
|
45842
46228
|
await db2.raw(
|