@exulu/backend 5.10.0 → 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-H6TI5MQL.js → chunk-3AEINUGF.js} +583 -174
- package/dist/{convert-exulu-tools-to-ai-sdk-tools-56EULD5M.js → convert-exulu-tools-to-ai-sdk-tools-FX6KTVPQ.js} +1 -1
- package/dist/index.cjs +810 -380
- 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
|
};
|
|
@@ -9826,6 +9839,40 @@ var init_session_items_retrieval_tool = __esm({
|
|
|
9826
9839
|
}
|
|
9827
9840
|
});
|
|
9828
9841
|
|
|
9842
|
+
// src/exulu/approval-revalidation.ts
|
|
9843
|
+
function answeredApprovalToolCallIds(messages) {
|
|
9844
|
+
const toolCallByApproval = /* @__PURE__ */ new Map();
|
|
9845
|
+
for (const message of messages ?? []) {
|
|
9846
|
+
if (message.role !== "assistant" || typeof message.content === "string") continue;
|
|
9847
|
+
for (const part of message.content) {
|
|
9848
|
+
if (part?.type === "tool-approval-request" && typeof part.approvalId === "string" && typeof part.toolCallId === "string") {
|
|
9849
|
+
toolCallByApproval.set(part.approvalId, part.toolCallId);
|
|
9850
|
+
}
|
|
9851
|
+
}
|
|
9852
|
+
}
|
|
9853
|
+
const answered = /* @__PURE__ */ new Set();
|
|
9854
|
+
for (const message of messages ?? []) {
|
|
9855
|
+
if (message.role !== "tool" || typeof message.content === "string") continue;
|
|
9856
|
+
for (const part of message.content) {
|
|
9857
|
+
if (part?.type !== "tool-approval-response" || typeof part.approvalId !== "string") continue;
|
|
9858
|
+
const toolCallId = toolCallByApproval.get(part.approvalId);
|
|
9859
|
+
if (toolCallId) answered.add(toolCallId);
|
|
9860
|
+
}
|
|
9861
|
+
}
|
|
9862
|
+
return answered;
|
|
9863
|
+
}
|
|
9864
|
+
function needsApprovalForCall(args) {
|
|
9865
|
+
if (!args.requiresApproval) return false;
|
|
9866
|
+
if (answeredApprovalToolCallIds(args.messages).has(args.toolCallId)) return true;
|
|
9867
|
+
return !args.approvedForSession;
|
|
9868
|
+
}
|
|
9869
|
+
var init_approval_revalidation = __esm({
|
|
9870
|
+
"src/exulu/approval-revalidation.ts"() {
|
|
9871
|
+
"use strict";
|
|
9872
|
+
init_cjs_shims();
|
|
9873
|
+
}
|
|
9874
|
+
});
|
|
9875
|
+
|
|
9829
9876
|
// ee/agentic-retrieval/pipeline/global-ids.ts
|
|
9830
9877
|
function parsePreselectedItems(globalIds) {
|
|
9831
9878
|
const map = /* @__PURE__ */ new Map();
|
|
@@ -10570,6 +10617,24 @@ var init_check_item_write_access = __esm({
|
|
|
10570
10617
|
}
|
|
10571
10618
|
});
|
|
10572
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
|
+
|
|
10573
10638
|
// src/templates/tools/kb-editor-config.ts
|
|
10574
10639
|
var import_zod5, KB_EDITOR_TOOL_ID, permissionsSchema, emptyConfig, parseKbEditorConfig;
|
|
10575
10640
|
var init_kb_editor_config = __esm({
|
|
@@ -10631,22 +10696,371 @@ var init_kb_editor_config = __esm({
|
|
|
10631
10696
|
}
|
|
10632
10697
|
});
|
|
10633
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
|
+
|
|
10634
11043
|
// src/templates/tools/context-write-tools.ts
|
|
10635
|
-
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;
|
|
10636
11045
|
var init_context_write_tools = __esm({
|
|
10637
11046
|
"src/templates/tools/context-write-tools.ts"() {
|
|
10638
11047
|
"use strict";
|
|
10639
11048
|
init_cjs_shims();
|
|
10640
11049
|
init_tool();
|
|
10641
|
-
|
|
11050
|
+
import_zod7 = require("zod");
|
|
10642
11051
|
import_node_crypto3 = require("crypto");
|
|
10643
11052
|
init_session_files();
|
|
10644
11053
|
init_uppy();
|
|
10645
11054
|
init_sanitize_name();
|
|
10646
11055
|
init_check_item_write_access();
|
|
11056
|
+
init_public_surface();
|
|
10647
11057
|
init_kb_editor_config();
|
|
10648
11058
|
init_json_field_schema();
|
|
11059
|
+
init_context_read_tools();
|
|
10649
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;
|
|
10650
11064
|
RESERVED_INPUT_KEYS = /* @__PURE__ */ new Set([
|
|
10651
11065
|
"model",
|
|
10652
11066
|
"user",
|
|
@@ -10673,29 +11087,29 @@ var init_context_write_tools = __esm({
|
|
|
10673
11087
|
contentKeys.push(key);
|
|
10674
11088
|
};
|
|
10675
11089
|
if (mode === "update") {
|
|
10676
|
-
shape["id"] =
|
|
10677
|
-
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.");
|
|
10678
11092
|
}
|
|
10679
|
-
addContent("name",
|
|
10680
|
-
addContent("description",
|
|
10681
|
-
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);
|
|
10682
11096
|
if (mode === "create") {
|
|
10683
11097
|
addContent(
|
|
10684
11098
|
"external_id",
|
|
10685
|
-
|
|
11099
|
+
import_zod7.z.string().describe("An optional external identifier for the item, e.g. an id from a source system."),
|
|
10686
11100
|
false
|
|
10687
11101
|
);
|
|
10688
11102
|
}
|
|
10689
11103
|
for (const field of context.fields ?? []) {
|
|
10690
11104
|
if (field.type === "uuid") continue;
|
|
10691
11105
|
if (field.calculated === true || field.editable === false) continue;
|
|
10692
|
-
if (field
|
|
11106
|
+
if (isHiddenField(field)) continue;
|
|
10693
11107
|
if (RESERVED_INPUT_KEYS.has(field.name)) continue;
|
|
10694
11108
|
if (field.type === "file") {
|
|
10695
11109
|
const allowed = (field.allowedFileTypes ?? []).map((ext) => ext.toLowerCase());
|
|
10696
11110
|
const column = `${field.name}_s3key`;
|
|
10697
11111
|
const allowedNote = allowed.length ? ` Allowed types: ${allowed.join(", ")}.` : "";
|
|
10698
|
-
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(
|
|
10699
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." : "")
|
|
10700
11114
|
);
|
|
10701
11115
|
contentKeys.push(column);
|
|
@@ -10705,34 +11119,34 @@ var init_context_write_tools = __esm({
|
|
|
10705
11119
|
let schema7;
|
|
10706
11120
|
switch (field.type) {
|
|
10707
11121
|
case "enum":
|
|
10708
|
-
schema7 =
|
|
11122
|
+
schema7 = import_zod7.z.string().describe(
|
|
10709
11123
|
`The ${field.name} of the item. Must be one of: ${(field.enumValues ?? []).join(", ")}`
|
|
10710
11124
|
);
|
|
10711
11125
|
break;
|
|
10712
11126
|
case "json":
|
|
10713
11127
|
jsonFieldNames.push(field.name);
|
|
10714
|
-
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.`);
|
|
10715
11129
|
break;
|
|
10716
11130
|
case "markdown":
|
|
10717
|
-
schema7 =
|
|
11131
|
+
schema7 = import_zod7.z.string().describe(`The ${field.name} of the item, as a valid Markdown string.`);
|
|
10718
11132
|
break;
|
|
10719
11133
|
case "date":
|
|
10720
|
-
schema7 =
|
|
11134
|
+
schema7 = import_zod7.z.string().describe(`The ${field.name} of the item, as an ISO-8601 date string.`);
|
|
10721
11135
|
break;
|
|
10722
11136
|
case "number":
|
|
10723
|
-
schema7 =
|
|
11137
|
+
schema7 = import_zod7.z.number().describe(`The ${field.name} of the item.`);
|
|
10724
11138
|
break;
|
|
10725
11139
|
case "boolean":
|
|
10726
|
-
schema7 =
|
|
11140
|
+
schema7 = import_zod7.z.boolean().describe(`The ${field.name} of the item.`);
|
|
10727
11141
|
break;
|
|
10728
11142
|
default:
|
|
10729
|
-
schema7 =
|
|
11143
|
+
schema7 = import_zod7.z.string().describe(`The ${field.name} of the item.`);
|
|
10730
11144
|
break;
|
|
10731
11145
|
}
|
|
10732
11146
|
addContent(field.name, schema7, field.required === true);
|
|
10733
11147
|
}
|
|
10734
11148
|
if (mode === "update" && jsonFieldNames.length > 0 && !shape["merge"]) {
|
|
10735
|
-
shape["merge"] =
|
|
11149
|
+
shape["merge"] = import_zod7.z.array(import_zod7.z.string()).optional().describe(
|
|
10736
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.`
|
|
10737
11151
|
);
|
|
10738
11152
|
}
|
|
@@ -10802,7 +11216,7 @@ var init_context_write_tools = __esm({
|
|
|
10802
11216
|
jobNote = (job) => job ? ` Processing/embeddings queued (job: ${job}); changes become searchable when the job completes.` : "";
|
|
10803
11217
|
createContextWriteTools = (context, perms, skipApproval, deps = {}) => {
|
|
10804
11218
|
const tools = [];
|
|
10805
|
-
const segment =
|
|
11219
|
+
const segment = contextToolSegment(context);
|
|
10806
11220
|
const contextLabel = context.description ? ` ${context.description}` : "";
|
|
10807
11221
|
if (perms.create) {
|
|
10808
11222
|
const { shape, contentKeys, fileFields } = buildWriteSchema(context, "create");
|
|
@@ -10814,12 +11228,12 @@ var init_context_write_tools = __esm({
|
|
|
10814
11228
|
category: "knowledge_base_editing",
|
|
10815
11229
|
description: `Create a new item in the "${context.name}" knowledge base.${contextLabel}${fileNote}`,
|
|
10816
11230
|
type: "function",
|
|
10817
|
-
inputSchema:
|
|
11231
|
+
inputSchema: import_zod7.z.object(shape),
|
|
10818
11232
|
config: [],
|
|
10819
11233
|
needsApproval: !skipApproval,
|
|
10820
11234
|
execute: async (params) => {
|
|
10821
11235
|
const { user, exuluConfig } = params;
|
|
10822
|
-
if (
|
|
11236
|
+
if (treatAsGuest(params.req, user)) {
|
|
10823
11237
|
return { result: "Knowledge base writes require an authenticated user." };
|
|
10824
11238
|
}
|
|
10825
11239
|
try {
|
|
@@ -10859,7 +11273,7 @@ var init_context_write_tools = __esm({
|
|
|
10859
11273
|
if (perms.update) {
|
|
10860
11274
|
const { shape, contentKeys, fileFields } = buildWriteSchema(context, "update");
|
|
10861
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." : "";
|
|
10862
|
-
const NOT_FOUND =
|
|
11276
|
+
const NOT_FOUND = itemNotFoundMessage(context, "write");
|
|
10863
11277
|
tools.push(
|
|
10864
11278
|
new ExuluTool({
|
|
10865
11279
|
id: `update_${segment}_item`,
|
|
@@ -10867,12 +11281,12 @@ var init_context_write_tools = __esm({
|
|
|
10867
11281
|
category: "knowledge_base_editing",
|
|
10868
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}`,
|
|
10869
11283
|
type: "function",
|
|
10870
|
-
inputSchema:
|
|
11284
|
+
inputSchema: import_zod7.z.object(shape),
|
|
10871
11285
|
config: [],
|
|
10872
11286
|
needsApproval: !skipApproval,
|
|
10873
11287
|
execute: async (params) => {
|
|
10874
11288
|
const { user, exuluConfig } = params;
|
|
10875
|
-
if (
|
|
11289
|
+
if (treatAsGuest(params.req, user)) {
|
|
10876
11290
|
return { result: "Knowledge base writes require an authenticated user." };
|
|
10877
11291
|
}
|
|
10878
11292
|
try {
|
|
@@ -10939,9 +11353,9 @@ Current item: ${JSON.stringify(summary)}`
|
|
|
10939
11353
|
id: KB_EDITOR_TOOL_ID,
|
|
10940
11354
|
name: "Knowledge base editor",
|
|
10941
11355
|
category: "default",
|
|
10942
|
-
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.",
|
|
10943
11357
|
type: "function",
|
|
10944
|
-
inputSchema:
|
|
11358
|
+
inputSchema: import_zod7.z.object({}),
|
|
10945
11359
|
config: [
|
|
10946
11360
|
{
|
|
10947
11361
|
name: "knowledge_bases",
|
|
@@ -10956,7 +11370,7 @@ Current item: ${JSON.stringify(summary)}`
|
|
|
10956
11370
|
}
|
|
10957
11371
|
],
|
|
10958
11372
|
execute: async () => ({
|
|
10959
|
-
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."
|
|
10960
11374
|
})
|
|
10961
11375
|
});
|
|
10962
11376
|
collectKbWriteTools = (agent, contexts, deps = {}) => {
|
|
@@ -10974,6 +11388,7 @@ Current item: ${JSON.stringify(summary)}`
|
|
|
10974
11388
|
continue;
|
|
10975
11389
|
}
|
|
10976
11390
|
tools.push(...createContextWriteTools(context, perms, config.skipApproval, deps));
|
|
11391
|
+
tools.push(...createContextReadTools(context));
|
|
10977
11392
|
}
|
|
10978
11393
|
return tools;
|
|
10979
11394
|
};
|
|
@@ -11149,13 +11564,13 @@ async function resolveSkill(db2, ref) {
|
|
|
11149
11564
|
const byId = /^[0-9a-f-]{36}$/i.test(value) ? await db2("skills").where({ id: value }).first() : null;
|
|
11150
11565
|
return byId ?? await resolveSkillByName(db2, value);
|
|
11151
11566
|
}
|
|
11152
|
-
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;
|
|
11153
11568
|
var init_skill_author_tools = __esm({
|
|
11154
11569
|
"src/templates/tools/skill-author-tools.ts"() {
|
|
11155
11570
|
"use strict";
|
|
11156
11571
|
init_cjs_shims();
|
|
11157
11572
|
import_node_crypto4 = require("crypto");
|
|
11158
|
-
|
|
11573
|
+
import_zod8 = require("zod");
|
|
11159
11574
|
init_tool();
|
|
11160
11575
|
init_client();
|
|
11161
11576
|
init_skill_access();
|
|
@@ -11242,7 +11657,7 @@ ${content.replace(/^\s+/, "")}`;
|
|
|
11242
11657
|
config: [],
|
|
11243
11658
|
needsApproval: false,
|
|
11244
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.",
|
|
11245
|
-
inputSchema:
|
|
11660
|
+
inputSchema: import_zod8.z.object({ query: import_zod8.z.string().optional().describe("Optional substring to filter by name or description") }),
|
|
11246
11661
|
execute: async (params) => {
|
|
11247
11662
|
const { user } = params;
|
|
11248
11663
|
if (!user?.id) return err2("Skills require a signed-in user.");
|
|
@@ -11268,9 +11683,9 @@ ${content.replace(/^\s+/, "")}`;
|
|
|
11268
11683
|
config: [],
|
|
11269
11684
|
needsApproval: false,
|
|
11270
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.",
|
|
11271
|
-
inputSchema:
|
|
11272
|
-
skill:
|
|
11273
|
-
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")
|
|
11274
11689
|
}),
|
|
11275
11690
|
execute: async (params) => {
|
|
11276
11691
|
const { user, exuluConfig } = params;
|
|
@@ -11315,10 +11730,10 @@ ${content}`
|
|
|
11315
11730
|
needsApproval: !config.skipApproval,
|
|
11316
11731
|
needsApprovalFn: approvalFn,
|
|
11317
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.",
|
|
11318
|
-
inputSchema:
|
|
11319
|
-
name:
|
|
11320
|
-
description:
|
|
11321
|
-
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")
|
|
11322
11737
|
}),
|
|
11323
11738
|
execute: async (params) => {
|
|
11324
11739
|
const { user, exuluConfig } = params;
|
|
@@ -11384,12 +11799,12 @@ ${content}`
|
|
|
11384
11799
|
needsApproval: !config.skipApproval,
|
|
11385
11800
|
needsApprovalFn: approvalFn,
|
|
11386
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.",
|
|
11387
|
-
inputSchema:
|
|
11388
|
-
skill:
|
|
11389
|
-
files:
|
|
11390
|
-
deletePaths:
|
|
11391
|
-
description:
|
|
11392
|
-
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'")
|
|
11393
11808
|
}),
|
|
11394
11809
|
execute: async (params) => {
|
|
11395
11810
|
const { user, exuluConfig } = params;
|
|
@@ -11466,7 +11881,7 @@ ${content}`
|
|
|
11466
11881
|
category: "default",
|
|
11467
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.",
|
|
11468
11883
|
type: "function",
|
|
11469
|
-
inputSchema:
|
|
11884
|
+
inputSchema: import_zod8.z.object({}),
|
|
11470
11885
|
config: [
|
|
11471
11886
|
{ name: "create", description: "The agent may propose new skills.", type: "boolean", default: true },
|
|
11472
11887
|
{ name: "update", description: "The agent may publish new versions of skills the user can write.", type: "boolean", default: true },
|
|
@@ -13245,9 +13660,9 @@ Probe error: ${probe.reason ?? "(no detail)"}`
|
|
|
13245
13660
|
});
|
|
13246
13661
|
const writeFileTool = (0, import_ai2.tool)({
|
|
13247
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.',
|
|
13248
|
-
inputSchema:
|
|
13249
|
-
path:
|
|
13250
|
-
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")
|
|
13251
13666
|
}),
|
|
13252
13667
|
execute: async ({ path: path4, content }) => {
|
|
13253
13668
|
const resolvedPath = resolveSessionPath(path4, sessionDir);
|
|
@@ -13266,8 +13681,8 @@ Probe error: ${probe.reason ?? "(no detail)"}`
|
|
|
13266
13681
|
});
|
|
13267
13682
|
const readFileTool = (0, import_ai2.tool)({
|
|
13268
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.',
|
|
13269
|
-
inputSchema:
|
|
13270
|
-
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.")
|
|
13271
13686
|
}),
|
|
13272
13687
|
execute: async ({ path: path4 }) => {
|
|
13273
13688
|
const resolvedPath = resolveSessionPath(path4, sessionDir);
|
|
@@ -13284,8 +13699,8 @@ Probe error: ${probe.reason ?? "(no detail)"}`
|
|
|
13284
13699
|
const originalBashTool = tools.bash;
|
|
13285
13700
|
const bashTool = (0, import_ai2.tool)({
|
|
13286
13701
|
description: originalBashTool.description ?? "",
|
|
13287
|
-
inputSchema:
|
|
13288
|
-
command:
|
|
13702
|
+
inputSchema: import_zod9.z.object({
|
|
13703
|
+
command: import_zod9.z.string().describe("The bash command to execute.")
|
|
13289
13704
|
}),
|
|
13290
13705
|
execute: async (args, opts) => {
|
|
13291
13706
|
const before = persistenceEnabled ? await snapshotSessionArtifacts() : null;
|
|
@@ -13360,7 +13775,7 @@ ${lines.join("\n")}`;
|
|
|
13360
13775
|
sandboxCache.set(sessionId, { handle, installedSkills });
|
|
13361
13776
|
return handle;
|
|
13362
13777
|
}
|
|
13363
|
-
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;
|
|
13364
13779
|
var init_create_sandbox = __esm({
|
|
13365
13780
|
"ee/invoke-skills/create-sandbox.ts"() {
|
|
13366
13781
|
"use strict";
|
|
@@ -13382,7 +13797,7 @@ var init_create_sandbox = __esm({
|
|
|
13382
13797
|
init_skill_sandbox();
|
|
13383
13798
|
import_bash_tool = require("bash-tool");
|
|
13384
13799
|
import_ai2 = require("ai");
|
|
13385
|
-
|
|
13800
|
+
import_zod9 = require("zod");
|
|
13386
13801
|
init_variable();
|
|
13387
13802
|
import_crypto_js3 = __toESM(require("crypto-js"), 1);
|
|
13388
13803
|
init_client();
|
|
@@ -13670,12 +14085,12 @@ var init_auth_tool_model_output = __esm({
|
|
|
13670
14085
|
});
|
|
13671
14086
|
|
|
13672
14087
|
// src/templates/tools/session-file-read-tool.ts
|
|
13673
|
-
var
|
|
14088
|
+
var import_zod10, DEFAULT_LIMIT, MAX_CONTENT_CHARS, SESSION_FILE_READ_TOOL_NAME, createSessionFileReadTool;
|
|
13674
14089
|
var init_session_file_read_tool = __esm({
|
|
13675
14090
|
"src/templates/tools/session-file-read-tool.ts"() {
|
|
13676
14091
|
"use strict";
|
|
13677
14092
|
init_cjs_shims();
|
|
13678
|
-
|
|
14093
|
+
import_zod10 = require("zod");
|
|
13679
14094
|
init_session_files();
|
|
13680
14095
|
init_tool();
|
|
13681
14096
|
init_uppy();
|
|
@@ -13731,10 +14146,10 @@ var init_session_file_read_tool = __esm({
|
|
|
13731
14146
|
name: SESSION_FILE_READ_TOOL_NAME,
|
|
13732
14147
|
needsApproval: false,
|
|
13733
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.",
|
|
13734
|
-
inputSchema:
|
|
13735
|
-
filename:
|
|
13736
|
-
offset:
|
|
13737
|
-
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})`)
|
|
13738
14153
|
}),
|
|
13739
14154
|
type: "function",
|
|
13740
14155
|
category: "session",
|
|
@@ -14338,15 +14753,15 @@ If the page contains a flow-chart, schematic, technical drawing or control board
|
|
|
14338
14753
|
const result = await (0, import_ai3.generateText)({
|
|
14339
14754
|
model,
|
|
14340
14755
|
output: import_ai3.Output.object({
|
|
14341
|
-
schema:
|
|
14342
|
-
needs_correction:
|
|
14343
|
-
corrected_text:
|
|
14344
|
-
current_page_table:
|
|
14345
|
-
headers:
|
|
14346
|
-
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()
|
|
14347
14762
|
}).nullable(),
|
|
14348
|
-
confidence:
|
|
14349
|
-
reasoning:
|
|
14763
|
+
confidence: import_zod11.z.enum(["high", "medium", "low"]),
|
|
14764
|
+
reasoning: import_zod11.z.string()
|
|
14350
14765
|
})
|
|
14351
14766
|
}),
|
|
14352
14767
|
messages: [
|
|
@@ -14783,7 +15198,7 @@ async function documentProcessor({
|
|
|
14783
15198
|
}
|
|
14784
15199
|
}
|
|
14785
15200
|
}
|
|
14786
|
-
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;
|
|
14787
15202
|
var init_doc_processor = __esm({
|
|
14788
15203
|
"ee/python/documents/processing/doc_processor.ts"() {
|
|
14789
15204
|
"use strict";
|
|
@@ -14791,7 +15206,7 @@ var init_doc_processor = __esm({
|
|
|
14791
15206
|
fs2 = __toESM(require("fs"), 1);
|
|
14792
15207
|
path3 = __toESM(require("path"), 1);
|
|
14793
15208
|
import_ai3 = require("ai");
|
|
14794
|
-
|
|
15209
|
+
import_zod11 = require("zod");
|
|
14795
15210
|
import_p_limit = __toESM(require("p-limit"), 1);
|
|
14796
15211
|
import_crypto3 = require("crypto");
|
|
14797
15212
|
init_with_retry();
|
|
@@ -14982,12 +15397,12 @@ function binaryDocumentBashHint(command, stdout, stderr) {
|
|
|
14982
15397
|
const [, file] = match;
|
|
14983
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.`;
|
|
14984
15399
|
}
|
|
14985
|
-
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;
|
|
14986
15401
|
var init_parse_document_tool = __esm({
|
|
14987
15402
|
"src/templates/tools/parse-document-tool.ts"() {
|
|
14988
15403
|
"use strict";
|
|
14989
15404
|
init_cjs_shims();
|
|
14990
|
-
|
|
15405
|
+
import_zod12 = require("zod");
|
|
14991
15406
|
import_node_path7 = require("path");
|
|
14992
15407
|
import_officeparser3 = require("officeparser");
|
|
14993
15408
|
init_tool();
|
|
@@ -15123,11 +15538,11 @@ ${text.trim()}`).join("\n");
|
|
|
15123
15538
|
name: PARSE_DOCUMENT_TOOL_NAME,
|
|
15124
15539
|
needsApproval: false,
|
|
15125
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.`,
|
|
15126
|
-
inputSchema:
|
|
15127
|
-
filename:
|
|
15128
|
-
pages:
|
|
15129
|
-
offset:
|
|
15130
|
-
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})`)
|
|
15131
15546
|
}),
|
|
15132
15547
|
type: "function",
|
|
15133
15548
|
category: "session",
|
|
@@ -15399,12 +15814,12 @@ var init_tool_image_attachments = __esm({
|
|
|
15399
15814
|
});
|
|
15400
15815
|
|
|
15401
15816
|
// src/templates/tools/view-document-page-tool.ts
|
|
15402
|
-
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;
|
|
15403
15818
|
var init_view_document_page_tool = __esm({
|
|
15404
15819
|
"src/templates/tools/view-document-page-tool.ts"() {
|
|
15405
15820
|
"use strict";
|
|
15406
15821
|
init_cjs_shims();
|
|
15407
|
-
|
|
15822
|
+
import_zod13 = require("zod");
|
|
15408
15823
|
init_session_files();
|
|
15409
15824
|
import_node_path9 = require("path");
|
|
15410
15825
|
init_tool();
|
|
@@ -15532,9 +15947,9 @@ var init_view_document_page_tool = __esm({
|
|
|
15532
15947
|
name: VIEW_DOCUMENT_PAGE_TOOL_NAME,
|
|
15533
15948
|
needsApproval: false,
|
|
15534
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.",
|
|
15535
|
-
inputSchema:
|
|
15536
|
-
filename:
|
|
15537
|
-
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)")
|
|
15538
15953
|
}),
|
|
15539
15954
|
type: "function",
|
|
15540
15955
|
category: "session",
|
|
@@ -15610,6 +16025,7 @@ var init_convert_exulu_tools_to_ai_sdk_tools = __esm({
|
|
|
15610
16025
|
init_client();
|
|
15611
16026
|
import_crypto_js4 = __toESM(require("crypto-js"), 1);
|
|
15612
16027
|
init_session_items_retrieval_tool();
|
|
16028
|
+
init_approval_revalidation();
|
|
15613
16029
|
init_pipeline();
|
|
15614
16030
|
init_project_scope();
|
|
15615
16031
|
init_sanitize_tool_name();
|
|
@@ -15763,8 +16179,8 @@ var init_convert_exulu_tools_to_ai_sdk_tools = __esm({
|
|
|
15763
16179
|
let projectScope;
|
|
15764
16180
|
if (project && !disabled.has("agentic_context_search")) {
|
|
15765
16181
|
const { db: db2 } = await postgresClient();
|
|
15766
|
-
const
|
|
15767
|
-
let rawItems =
|
|
16182
|
+
const projectRow2 = await db2.from("projects").where("id", project).first();
|
|
16183
|
+
let rawItems = projectRow2?.project_items;
|
|
15768
16184
|
if (typeof rawItems === "string") {
|
|
15769
16185
|
try {
|
|
15770
16186
|
rawItems = JSON.parse(rawItems);
|
|
@@ -15772,12 +16188,12 @@ var init_convert_exulu_tools_to_ai_sdk_tools = __esm({
|
|
|
15772
16188
|
rawItems = void 0;
|
|
15773
16189
|
}
|
|
15774
16190
|
}
|
|
15775
|
-
if (
|
|
16191
|
+
if (projectRow2 && Array.isArray(rawItems) && rawItems.length > 0) {
|
|
15776
16192
|
projectScope = {
|
|
15777
|
-
id:
|
|
15778
|
-
name:
|
|
15779
|
-
description:
|
|
15780
|
-
customInstructions:
|
|
16193
|
+
id: projectRow2.id,
|
|
16194
|
+
name: projectRow2.name,
|
|
16195
|
+
description: projectRow2.description ?? void 0,
|
|
16196
|
+
customInstructions: projectRow2.custom_instructions ?? void 0,
|
|
15781
16197
|
items: rawItems,
|
|
15782
16198
|
kbProfileDefaults: buildProjectKbProfileDefaults(rawItems)
|
|
15783
16199
|
};
|
|
@@ -15956,11 +16372,12 @@ var init_convert_exulu_tools_to_ai_sdk_tools = __esm({
|
|
|
15956
16372
|
)?.default;
|
|
15957
16373
|
const toolDescription = cur.description;
|
|
15958
16374
|
const description = userDefinedConfigDescription || defaultConfigDescription || toolDescription;
|
|
16375
|
+
const approvedForSession = approvedTools?.includes("tool-" + cur.name) ?? false;
|
|
15959
16376
|
console.log(
|
|
15960
16377
|
"[EXULU] Tool",
|
|
15961
16378
|
cur.name,
|
|
15962
16379
|
"needs approval",
|
|
15963
|
-
|
|
16380
|
+
cur.needsApprovalFn ? "per call" : isMemoryToolId(cur.id) ? true : approvedForSession ? "only answered calls" : !!cur.needsApproval
|
|
15964
16381
|
);
|
|
15965
16382
|
return {
|
|
15966
16383
|
...prev,
|
|
@@ -15969,8 +16386,16 @@ var init_convert_exulu_tools_to_ai_sdk_tools = __esm({
|
|
|
15969
16386
|
description,
|
|
15970
16387
|
// The approvedTools array uses the tool.name lookup as the frontend
|
|
15971
16388
|
// Vercel AI SDK uses the sanitized tool name as the key, so this matches.
|
|
15972
|
-
|
|
15973
|
-
//
|
|
16389
|
+
// Never a plain `false` for a tool the user allowed for this chat: the
|
|
16390
|
+
// SDK re-validates an ANSWERED approval by calling needsApproval again
|
|
16391
|
+
// and reads `false` as "deny" — see approval-revalidation.ts.
|
|
16392
|
+
needsApproval: cur.needsApprovalFn ? (input, opts) => cur.needsApprovalFn(input, opts) : isMemoryToolId(cur.id) ? true : (_input, opts) => needsApprovalForCall({
|
|
16393
|
+
toolCallId: opts.toolCallId,
|
|
16394
|
+
messages: opts.messages,
|
|
16395
|
+
approvedForSession,
|
|
16396
|
+
requiresApproval: !!cur.needsApproval
|
|
16397
|
+
// todo make configurable
|
|
16398
|
+
}),
|
|
15974
16399
|
// Auth-wrapped tools: the model sees scrub text instead of the
|
|
15975
16400
|
// credentialRequest/oauth payload; the UI stream keeps the raw
|
|
15976
16401
|
// output (spec 2026-07-22 §1.2).
|
|
@@ -16155,13 +16580,13 @@ var init_convert_exulu_tools_to_ai_sdk_tools = __esm({
|
|
|
16155
16580
|
});
|
|
16156
16581
|
|
|
16157
16582
|
// src/exulu/tool.ts
|
|
16158
|
-
var import_ai4,
|
|
16583
|
+
var import_ai4, import_zod14, import_node_crypto7, PUBLIC_TOOL_TYPES, ExuluTool;
|
|
16159
16584
|
var init_tool = __esm({
|
|
16160
16585
|
"src/exulu/tool.ts"() {
|
|
16161
16586
|
"use strict";
|
|
16162
16587
|
init_cjs_shims();
|
|
16163
16588
|
import_ai4 = require("ai");
|
|
16164
|
-
|
|
16589
|
+
import_zod14 = require("zod");
|
|
16165
16590
|
init_sanitize_name();
|
|
16166
16591
|
import_node_crypto7 = require("crypto");
|
|
16167
16592
|
init_singleton();
|
|
@@ -16226,7 +16651,7 @@ var init_tool = __esm({
|
|
|
16226
16651
|
this.type = type;
|
|
16227
16652
|
this.tool = (0, import_ai4.tool)({
|
|
16228
16653
|
description,
|
|
16229
|
-
inputSchema: inputSchema ||
|
|
16654
|
+
inputSchema: inputSchema || import_zod14.z.object({}),
|
|
16230
16655
|
execute: authentication2 ? wrapExecuteWithAuth(id, authentication2, execute2) : execute2
|
|
16231
16656
|
});
|
|
16232
16657
|
}
|
|
@@ -16520,92 +16945,92 @@ function effectiveKbSettings(profile, ctx) {
|
|
|
16520
16945
|
keywordPrefilter: preset.keywordPrefilter
|
|
16521
16946
|
};
|
|
16522
16947
|
}
|
|
16523
|
-
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;
|
|
16524
16949
|
var init_config3 = __esm({
|
|
16525
16950
|
"ee/agentic-retrieval/pipeline/config.ts"() {
|
|
16526
16951
|
"use strict";
|
|
16527
16952
|
init_cjs_shims();
|
|
16528
|
-
|
|
16953
|
+
import_zod15 = require("zod");
|
|
16529
16954
|
init_types2();
|
|
16530
16955
|
KB_KINDS = ["documents", "conversations", "records"];
|
|
16531
16956
|
DEFAULT_PREFILTER_CUTOFF = 2.5;
|
|
16532
16957
|
RRF_K = 60;
|
|
16533
16958
|
CHUNK_GROUP_MAX = 10;
|
|
16534
|
-
kbProfileSchema =
|
|
16535
|
-
enabled:
|
|
16536
|
-
kind:
|
|
16537
|
-
instructions:
|
|
16538
|
-
overrides:
|
|
16539
|
-
limit:
|
|
16540
|
-
expand:
|
|
16541
|
-
multiQuery:
|
|
16542
|
-
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()
|
|
16543
16968
|
}).default({})
|
|
16544
16969
|
});
|
|
16545
|
-
knowledgeBasesSchema =
|
|
16546
|
-
routingRuleSchema =
|
|
16547
|
-
id:
|
|
16548
|
-
label:
|
|
16549
|
-
description:
|
|
16550
|
-
main:
|
|
16551
|
-
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([])
|
|
16552
16977
|
});
|
|
16553
|
-
routingSchema =
|
|
16554
|
-
identifierSetSchema =
|
|
16555
|
-
name:
|
|
16556
|
-
description:
|
|
16557
|
-
examples:
|
|
16558
|
-
strategy:
|
|
16559
|
-
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([])
|
|
16560
16985
|
});
|
|
16561
|
-
vocabularySchema =
|
|
16562
|
-
glossary:
|
|
16563
|
-
identifiers:
|
|
16564
|
-
rewrites:
|
|
16565
|
-
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("")
|
|
16566
16991
|
});
|
|
16567
|
-
memorySchema =
|
|
16568
|
-
enabled:
|
|
16569
|
-
override:
|
|
16570
|
-
filePrioritization:
|
|
16571
|
-
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)
|
|
16572
16997
|
});
|
|
16573
|
-
tuningSchema =
|
|
16574
|
-
topK:
|
|
16575
|
-
fallbackThreshold:
|
|
16576
|
-
pinBoost:
|
|
16577
|
-
identifierBoost:
|
|
16578
|
-
pageWindow:
|
|
16579
|
-
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),
|
|
16580
17005
|
/**
|
|
16581
17006
|
* Orchestration engine. "v1" is the sequential flow every agent ran before 2026-09;
|
|
16582
17007
|
* "v2" merges the phase-1 LLM hops and runs identifier pins in parallel. Per agent,
|
|
16583
17008
|
* so a candidate agent can run v2 while the production agent stays on v1.
|
|
16584
17009
|
*/
|
|
16585
|
-
engine:
|
|
17010
|
+
engine: import_zod15.z.enum(["v1", "v2"]).default("v1"),
|
|
16586
17011
|
/** v2 sub-features; each can be switched off on its own to bisect a regression. */
|
|
16587
|
-
v2:
|
|
16588
|
-
mergedMemoryCall:
|
|
16589
|
-
mergedRoutingCall:
|
|
16590
|
-
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)
|
|
16591
17016
|
}).default({ mergedMemoryCall: true, mergedRoutingCall: true, parallelPins: true })
|
|
16592
17017
|
});
|
|
16593
|
-
claimCheckSchema =
|
|
16594
|
-
enabled:
|
|
17018
|
+
claimCheckSchema = import_zod15.z.object({
|
|
17019
|
+
enabled: import_zod15.z.boolean().default(false),
|
|
16595
17020
|
/** Empty = fall back to the agent's utility model, then the agent's model. */
|
|
16596
|
-
model:
|
|
16597
|
-
fidelity:
|
|
16598
|
-
completions:
|
|
16599
|
-
reRetrieve:
|
|
16600
|
-
thresholds:
|
|
16601
|
-
warn:
|
|
16602
|
-
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)
|
|
16603
17028
|
}).default(CLAIM_CHECK_DEFAULTS.thresholds),
|
|
16604
|
-
showToExternalUsers:
|
|
16605
|
-
caps:
|
|
16606
|
-
maxSentences:
|
|
16607
|
-
maxClaims:
|
|
16608
|
-
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)
|
|
16609
17034
|
}).default(CLAIM_CHECK_DEFAULTS.caps)
|
|
16610
17035
|
});
|
|
16611
17036
|
boolVal = (v) => v === true || v === "true" || v === 1;
|
|
@@ -16941,9 +17366,9 @@ async function resolveIdentifierPins({
|
|
|
16941
17366
|
model,
|
|
16942
17367
|
system: set.strategy === "exact" ? EXACT_EXTRACTION_PROMPT(set) : FUZZY_EXTRACTION_PROMPT(set),
|
|
16943
17368
|
messages: [{ role: "user", content: question }],
|
|
16944
|
-
schema:
|
|
16945
|
-
hasMatches:
|
|
16946
|
-
matches:
|
|
17369
|
+
schema: import_zod16.z.object({
|
|
17370
|
+
hasMatches: import_zod16.z.boolean(),
|
|
17371
|
+
matches: import_zod16.z.array(import_zod16.z.string()).optional()
|
|
16947
17372
|
})
|
|
16948
17373
|
});
|
|
16949
17374
|
if (!output?.hasMatches || !output.matches?.length) return;
|
|
@@ -16991,13 +17416,13 @@ async function resolveIdentifierPins({
|
|
|
16991
17416
|
);
|
|
16992
17417
|
return { pinsByContext, exactPinsByContext, steps };
|
|
16993
17418
|
}
|
|
16994
|
-
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;
|
|
16995
17420
|
var init_prefilter = __esm({
|
|
16996
17421
|
"ee/agentic-retrieval/pipeline/prefilter.ts"() {
|
|
16997
17422
|
"use strict";
|
|
16998
17423
|
init_cjs_shims();
|
|
16999
17424
|
import_fuse = __toESM(require("fuse.js"), 1);
|
|
17000
|
-
|
|
17425
|
+
import_zod16 = require("zod");
|
|
17001
17426
|
init_micro_call();
|
|
17002
17427
|
init_text_utils();
|
|
17003
17428
|
init_config3();
|
|
@@ -17081,18 +17506,18 @@ ${rulesLines}` + (extraInstructions ? `
|
|
|
17081
17506
|
${extraInstructions}
|
|
17082
17507
|
</instructions>` : "") : "");
|
|
17083
17508
|
const ids = enabledContexts.map((c) => c.id);
|
|
17084
|
-
const schema7 =
|
|
17085
|
-
docPage:
|
|
17086
|
-
hasFilenameHint:
|
|
17087
|
-
filenameHints:
|
|
17088
|
-
hasPageHint:
|
|
17089
|
-
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()
|
|
17090
17515
|
}),
|
|
17091
|
-
explicitlyRequestedKnowledgeBases:
|
|
17516
|
+
explicitlyRequestedKnowledgeBases: import_zod17.z.array(import_zod17.z.enum(ids)),
|
|
17092
17517
|
...routingRules.length ? {
|
|
17093
|
-
classification:
|
|
17094
|
-
ruleId:
|
|
17095
|
-
reason:
|
|
17518
|
+
classification: import_zod17.z.object({
|
|
17519
|
+
ruleId: import_zod17.z.enum(routingRules.map((r) => r.id)),
|
|
17520
|
+
reason: import_zod17.z.string()
|
|
17096
17521
|
})
|
|
17097
17522
|
} : {}
|
|
17098
17523
|
});
|
|
@@ -17151,14 +17576,18 @@ If explicit, return the knowledge base ids. If not, return an empty array.`;
|
|
|
17151
17576
|
model,
|
|
17152
17577
|
system: buildDocPagePrompt(knownIdentifiers),
|
|
17153
17578
|
messages: [{ role: "user", content: question }],
|
|
17154
|
-
schema:
|
|
17155
|
-
hasFilenameHint:
|
|
17156
|
-
filenameHints:
|
|
17157
|
-
hasPageHint:
|
|
17158
|
-
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()
|
|
17159
17584
|
})
|
|
17160
17585
|
});
|
|
17161
17586
|
} catch (err4) {
|
|
17587
|
+
console.warn(
|
|
17588
|
+
"[EXULU pipeline] doc/page detection failed \u2014 skipping filename and page hints.",
|
|
17589
|
+
err4
|
|
17590
|
+
);
|
|
17162
17591
|
steps.push({ text: "Doc/page detection failed \u2014 skipping filename and page hints." });
|
|
17163
17592
|
return {
|
|
17164
17593
|
output: {
|
|
@@ -17175,14 +17604,18 @@ If explicit, return the knowledge base ids. If not, return an empty array.`;
|
|
|
17175
17604
|
return await microCall({
|
|
17176
17605
|
model,
|
|
17177
17606
|
system: kbSystemPrompt,
|
|
17178
|
-
schema:
|
|
17179
|
-
explicitlyRequestedKnowledgeBases:
|
|
17180
|
-
|
|
17607
|
+
schema: import_zod17.z.object({
|
|
17608
|
+
explicitlyRequestedKnowledgeBases: import_zod17.z.array(
|
|
17609
|
+
import_zod17.z.enum(enabledContexts.map((c) => c.id))
|
|
17181
17610
|
)
|
|
17182
17611
|
}),
|
|
17183
17612
|
messages: [{ role: "user", content: question }]
|
|
17184
17613
|
});
|
|
17185
17614
|
} catch (err4) {
|
|
17615
|
+
console.warn(
|
|
17616
|
+
"[EXULU pipeline] explicit knowledge base detection failed \u2014 treating the question as naming none.",
|
|
17617
|
+
err4
|
|
17618
|
+
);
|
|
17186
17619
|
return { output: { explicitlyRequestedKnowledgeBases: [] } };
|
|
17187
17620
|
}
|
|
17188
17621
|
})()
|
|
@@ -17268,9 +17701,9 @@ ${extraInstructions}
|
|
|
17268
17701
|
model,
|
|
17269
17702
|
system: classifyPrompt,
|
|
17270
17703
|
messages: [{ role: "user", content: question }],
|
|
17271
|
-
schema:
|
|
17272
|
-
ruleId:
|
|
17273
|
-
reason:
|
|
17704
|
+
schema: import_zod17.z.object({
|
|
17705
|
+
ruleId: import_zod17.z.enum(ruleIds),
|
|
17706
|
+
reason: import_zod17.z.string()
|
|
17274
17707
|
})
|
|
17275
17708
|
}));
|
|
17276
17709
|
const matchedRule = routingRules.find((r) => r.id === classified.ruleId);
|
|
@@ -17295,6 +17728,10 @@ ${extraInstructions}
|
|
|
17295
17728
|
});
|
|
17296
17729
|
}
|
|
17297
17730
|
} catch (err4) {
|
|
17731
|
+
console.warn(
|
|
17732
|
+
"[EXULU pipeline] classification failed \u2014 using the implicit all-main rule.",
|
|
17733
|
+
err4
|
|
17734
|
+
);
|
|
17298
17735
|
mainContexts = enabledContexts.map((c) => c.id);
|
|
17299
17736
|
fallbackContexts = [];
|
|
17300
17737
|
steps.push({
|
|
@@ -17325,12 +17762,12 @@ ${extraInstructions}
|
|
|
17325
17762
|
};
|
|
17326
17763
|
}
|
|
17327
17764
|
}
|
|
17328
|
-
var
|
|
17765
|
+
var import_zod17, MAX_USER_PIN_MATCHES, buildDocPagePrompt;
|
|
17329
17766
|
var init_routing = __esm({
|
|
17330
17767
|
"ee/agentic-retrieval/pipeline/routing.ts"() {
|
|
17331
17768
|
"use strict";
|
|
17332
17769
|
init_cjs_shims();
|
|
17333
|
-
|
|
17770
|
+
import_zod17 = require("zod");
|
|
17334
17771
|
init_micro_call();
|
|
17335
17772
|
init_timing();
|
|
17336
17773
|
init_prefilter();
|
|
@@ -17435,22 +17872,22 @@ ${glossary.map((g) => `${g.term} : ${g.meaning}`).join("\n")}` : "";
|
|
|
17435
17872
|
`
|
|
17436
17873
|
}
|
|
17437
17874
|
],
|
|
17438
|
-
schema:
|
|
17439
|
-
relevantChunkIds:
|
|
17440
|
-
override:
|
|
17441
|
-
overrides:
|
|
17442
|
-
confidence:
|
|
17443
|
-
authoritativeChunkIds:
|
|
17444
|
-
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.")
|
|
17445
17882
|
}),
|
|
17446
|
-
filePrioritization:
|
|
17447
|
-
shouldPrioritizeFiles:
|
|
17448
|
-
fileNameHints:
|
|
17883
|
+
filePrioritization: import_zod18.z.object({
|
|
17884
|
+
shouldPrioritizeFiles: import_zod18.z.boolean(),
|
|
17885
|
+
fileNameHints: import_zod18.z.array(import_zod18.z.string()).optional()
|
|
17449
17886
|
}),
|
|
17450
|
-
augmentation:
|
|
17451
|
-
updatedUserQuestion:
|
|
17452
|
-
updatedRelevantKeywords:
|
|
17453
|
-
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()
|
|
17454
17891
|
})
|
|
17455
17892
|
})
|
|
17456
17893
|
});
|
|
@@ -17533,8 +17970,8 @@ async function runMemoryPhase({
|
|
|
17533
17970
|
`
|
|
17534
17971
|
}
|
|
17535
17972
|
],
|
|
17536
|
-
schema:
|
|
17537
|
-
relevantChunkIds:
|
|
17973
|
+
schema: import_zod18.z.object({
|
|
17974
|
+
relevantChunkIds: import_zod18.z.array(import_zod18.z.string()).describe(
|
|
17538
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."
|
|
17539
17976
|
)
|
|
17540
17977
|
})
|
|
@@ -17643,17 +18080,17 @@ ${glossary.map((g) => `${g.term} : ${g.meaning}`).join("\n")}` : "";
|
|
|
17643
18080
|
`
|
|
17644
18081
|
}
|
|
17645
18082
|
],
|
|
17646
|
-
schema:
|
|
17647
|
-
overrides:
|
|
18083
|
+
schema: import_zod18.z.object({
|
|
18084
|
+
overrides: import_zod18.z.boolean().describe(
|
|
17648
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."
|
|
17649
18086
|
),
|
|
17650
|
-
confidence:
|
|
18087
|
+
confidence: import_zod18.z.enum(["high", "medium", "low"]).describe(
|
|
17651
18088
|
"Confidence that the selected memory chunk(s) fully and directly answer the question."
|
|
17652
18089
|
),
|
|
17653
|
-
authoritativeChunkIds:
|
|
18090
|
+
authoritativeChunkIds: import_zod18.z.array(import_zod18.z.string()).describe(
|
|
17654
18091
|
"The chunk_ids of the memory chunk(s) that directly answer the question. Empty if overrides is false."
|
|
17655
18092
|
),
|
|
17656
|
-
reason:
|
|
18093
|
+
reason: import_zod18.z.string().describe(
|
|
17657
18094
|
"One short sentence: why this memory does or does not directly answer the question."
|
|
17658
18095
|
)
|
|
17659
18096
|
})
|
|
@@ -17677,9 +18114,9 @@ ${glossary.map((g) => `${g.term} : ${g.meaning}`).join("\n")}` : "";
|
|
|
17677
18114
|
model,
|
|
17678
18115
|
system: "You are a helpful assistant that will strictly follow the user's instructions.",
|
|
17679
18116
|
messages: [{ role: "user", content: PROMPT_EXTRACT_PRIORITIZED_FILES }],
|
|
17680
|
-
schema:
|
|
17681
|
-
shouldPrioritizeFiles:
|
|
17682
|
-
fileNameHints:
|
|
18117
|
+
schema: import_zod18.z.object({
|
|
18118
|
+
shouldPrioritizeFiles: import_zod18.z.boolean(),
|
|
18119
|
+
fileNameHints: import_zod18.z.array(import_zod18.z.string()).optional()
|
|
17683
18120
|
})
|
|
17684
18121
|
}).catch(() => ({
|
|
17685
18122
|
output: { shouldPrioritizeFiles: false, fileNameHints: [] }
|
|
@@ -17691,10 +18128,10 @@ ${glossary.map((g) => `${g.term} : ${g.meaning}`).join("\n")}` : "";
|
|
|
17691
18128
|
model,
|
|
17692
18129
|
system: "You are a helpful assistant that will strictly follow the user's instructions.",
|
|
17693
18130
|
messages: [{ role: "user", content: QUERY_AUGMENTATION_PROMPT }],
|
|
17694
|
-
schema:
|
|
17695
|
-
updatedUserQuestion:
|
|
17696
|
-
updatedRelevantKeywords:
|
|
17697
|
-
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()
|
|
17698
18135
|
})
|
|
17699
18136
|
}).catch(() => ({
|
|
17700
18137
|
output: {
|
|
@@ -17781,12 +18218,12 @@ ${glossary.map((g) => `${g.term} : ${g.meaning}`).join("\n")}` : "";
|
|
|
17781
18218
|
return neutralResult(question, keywords, importantKeyword);
|
|
17782
18219
|
}
|
|
17783
18220
|
}
|
|
17784
|
-
var
|
|
18221
|
+
var import_zod18, MEMORY_OVERRIDE_MIN_CONFIDENCE, MEMORY_SYNTHETIC_RERANK_SCORE;
|
|
17785
18222
|
var init_memory = __esm({
|
|
17786
18223
|
"ee/agentic-retrieval/pipeline/memory.ts"() {
|
|
17787
18224
|
"use strict";
|
|
17788
18225
|
init_cjs_shims();
|
|
17789
|
-
|
|
18226
|
+
import_zod18 = require("zod");
|
|
17790
18227
|
init_micro_call();
|
|
17791
18228
|
init_timing();
|
|
17792
18229
|
init_prefilter();
|
|
@@ -18633,11 +19070,11 @@ function createAgenticRetrievalTool(opts) {
|
|
|
18633
19070
|
default: '{"enabled":false,"model":"","fidelity":"fast","thresholds":{"warn":0.1,"alert":0.3}}'
|
|
18634
19071
|
}
|
|
18635
19072
|
],
|
|
18636
|
-
inputSchema:
|
|
18637
|
-
userQuery:
|
|
18638
|
-
relevantKeywords:
|
|
18639
|
-
importantKeyword:
|
|
18640
|
-
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(
|
|
18641
19078
|
"Knowledge base IDs explicitly confirmed by the user to be used in the retrieval. When present, only searches these contexts."
|
|
18642
19079
|
)
|
|
18643
19080
|
}),
|
|
@@ -19081,12 +19518,12 @@ Verified answer:
|
|
|
19081
19518
|
}
|
|
19082
19519
|
});
|
|
19083
19520
|
}
|
|
19084
|
-
var
|
|
19521
|
+
var import_zod19, AGENTIC_RETRIEVAL_TOOL_NAME;
|
|
19085
19522
|
var init_pipeline = __esm({
|
|
19086
19523
|
"ee/agentic-retrieval/pipeline/index.ts"() {
|
|
19087
19524
|
"use strict";
|
|
19088
19525
|
init_cjs_shims();
|
|
19089
|
-
|
|
19526
|
+
import_zod19 = require("zod");
|
|
19090
19527
|
init_tool();
|
|
19091
19528
|
init_entitlements();
|
|
19092
19529
|
init_resolve_reranker();
|
|
@@ -20153,7 +20590,7 @@ var itemsPaginationRequest = async ({
|
|
|
20153
20590
|
}
|
|
20154
20591
|
const tableName = table.name.plural.toLowerCase();
|
|
20155
20592
|
let countQuery = db2(tableName);
|
|
20156
|
-
countQuery =
|
|
20593
|
+
countQuery = applyFiltersGrouped(countQuery, filters, table);
|
|
20157
20594
|
countQuery = applyAccessControl(table, countQuery, user);
|
|
20158
20595
|
const countResult = await countQuery.count("* as count");
|
|
20159
20596
|
const itemCount = Number(countResult[0]?.count || 0);
|
|
@@ -20162,7 +20599,7 @@ var itemsPaginationRequest = async ({
|
|
|
20162
20599
|
const hasPreviousPage = currentPage > 1;
|
|
20163
20600
|
const hasNextPage = currentPage <= pageCount - 1;
|
|
20164
20601
|
let dataQuery = db2(tableName);
|
|
20165
|
-
dataQuery =
|
|
20602
|
+
dataQuery = applyFiltersGrouped(dataQuery, filters, table);
|
|
20166
20603
|
dataQuery = applyAccessControl(table, dataQuery, user);
|
|
20167
20604
|
dataQuery = applySorting(dataQuery, sort, void 0, table);
|
|
20168
20605
|
if (page > 1) {
|
|
@@ -20303,7 +20740,7 @@ function createQueries(table, tools, contexts) {
|
|
|
20303
20740
|
const requestedFields = getRequestedFields(info);
|
|
20304
20741
|
const sanitizedFields = sanitizeRequestedFields(table, requestedFields);
|
|
20305
20742
|
let query = db2.from(tableNamePlural).select(sanitizedFields);
|
|
20306
|
-
query =
|
|
20743
|
+
query = applyFiltersGrouped(query, filters, table);
|
|
20307
20744
|
query = applyAccessControl(table, query, context.user);
|
|
20308
20745
|
query = applySorting(query, sort, void 0, table);
|
|
20309
20746
|
let result = await query.first();
|
|
@@ -20350,7 +20787,7 @@ function createQueries(table, tools, contexts) {
|
|
|
20350
20787
|
const { filters = [], groupBy, limit = 10 } = args;
|
|
20351
20788
|
const { db: db2 } = context;
|
|
20352
20789
|
let query = db2(tableNamePlural);
|
|
20353
|
-
query =
|
|
20790
|
+
query = applyFiltersGrouped(query, filters, table);
|
|
20354
20791
|
query = applyAccessControl(table, query, context.user);
|
|
20355
20792
|
query = query.limit(limit);
|
|
20356
20793
|
if (groupBy) {
|
|
@@ -23147,7 +23584,7 @@ init_cjs_shims();
|
|
|
23147
23584
|
init_entitlements();
|
|
23148
23585
|
init_singleton();
|
|
23149
23586
|
init_tool();
|
|
23150
|
-
var
|
|
23587
|
+
var import_zod20 = require("zod");
|
|
23151
23588
|
init_check_record_access();
|
|
23152
23589
|
init_resolve_model();
|
|
23153
23590
|
init_statistics2();
|
|
@@ -23679,19 +24116,8 @@ async function recallMemories({ agent, contexts, query, user, db: db2, previousU
|
|
|
23679
24116
|
return { collector, memoryItems: chunks, promptBlock: buildMemoryPromptBlock(collector.list()) };
|
|
23680
24117
|
}
|
|
23681
24118
|
|
|
23682
|
-
// src/exulu/public-surface.ts
|
|
23683
|
-
init_cjs_shims();
|
|
23684
|
-
var PUBLIC_SURFACE_HEADER = "x-public-surface";
|
|
23685
|
-
function isPublicSurface(req) {
|
|
23686
|
-
const raw = req?.headers?.[PUBLIC_SURFACE_HEADER];
|
|
23687
|
-
const value = Array.isArray(raw) ? raw[0] : raw;
|
|
23688
|
-
return value === "1" || value === "true";
|
|
23689
|
-
}
|
|
23690
|
-
function treatAsGuest(req, user) {
|
|
23691
|
-
return isPublicSurface(req) || !user?.id;
|
|
23692
|
-
}
|
|
23693
|
-
|
|
23694
24119
|
// src/exulu/generate-stream.ts
|
|
24120
|
+
init_public_surface();
|
|
23695
24121
|
init_decisions();
|
|
23696
24122
|
|
|
23697
24123
|
// src/exulu/skills/decisions.ts
|
|
@@ -24627,9 +25053,9 @@ var createAgentTool = async (instance2, contexts) => {
|
|
|
24627
25053
|
name: `${agent.name}`,
|
|
24628
25054
|
type: "agent",
|
|
24629
25055
|
category: "agents",
|
|
24630
|
-
inputSchema:
|
|
24631
|
-
prompt:
|
|
24632
|
-
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")
|
|
24633
25059
|
}),
|
|
24634
25060
|
description: `This tool calls an agent named: ${agent.name}. The agent does the following: ${agent.description}.`,
|
|
24635
25061
|
config: [],
|
|
@@ -30016,12 +30442,12 @@ async function runScan({ db: db2, context, user, judge, now = /* @__PURE__ */ ne
|
|
|
30016
30442
|
// src/exulu/memory/conflicts/judge.ts
|
|
30017
30443
|
init_cjs_shims();
|
|
30018
30444
|
var import_ai10 = require("ai");
|
|
30019
|
-
var
|
|
30445
|
+
var import_zod21 = require("zod");
|
|
30020
30446
|
init_resolve_model();
|
|
30021
|
-
var schema =
|
|
30022
|
-
verdict:
|
|
30447
|
+
var schema = import_zod21.z.object({
|
|
30448
|
+
verdict: import_zod21.z.enum(["same", "contradict", "compatible"]),
|
|
30023
30449
|
// No .max(160) here: an over-long reason must not fail the whole call — truncate after.
|
|
30024
|
-
reason:
|
|
30450
|
+
reason: import_zod21.z.string()
|
|
30025
30451
|
});
|
|
30026
30452
|
var SYSTEM = `You compare two short memories an assistant saved from conversations.
|
|
30027
30453
|
Answer with JSON: verdict = "same" when both state the same fact or instruction (wording may differ),
|
|
@@ -30056,7 +30482,7 @@ async function makeMergeSuggester({ modelId, agent, user }) {
|
|
|
30056
30482
|
prompt: members.map((m, i) => `Memory ${i + 1}:
|
|
30057
30483
|
${m.information}`).join("\n\n"),
|
|
30058
30484
|
maxRetries: 1,
|
|
30059
|
-
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) }) })
|
|
30060
30486
|
});
|
|
30061
30487
|
const types = members.map((m) => m.type).filter((t) => !!t);
|
|
30062
30488
|
const type = types.length ? [...types].sort((x, y) => types.filter((t) => t === y).length - types.filter((t) => t === x).length)[0] ?? null : null;
|
|
@@ -33109,12 +33535,12 @@ init_statistics2();
|
|
|
33109
33535
|
// src/exulu/suggestions.ts
|
|
33110
33536
|
init_cjs_shims();
|
|
33111
33537
|
var import_ai11 = require("ai");
|
|
33112
|
-
var
|
|
33538
|
+
var import_zod22 = require("zod");
|
|
33113
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.";
|
|
33114
33540
|
var submitSuggestionsTool = (0, import_ai11.tool)({
|
|
33115
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.",
|
|
33116
|
-
inputSchema:
|
|
33117
|
-
suggestions:
|
|
33542
|
+
inputSchema: import_zod22.z.object({
|
|
33543
|
+
suggestions: import_zod22.z.array(import_zod22.z.string()).max(3)
|
|
33118
33544
|
})
|
|
33119
33545
|
});
|
|
33120
33546
|
var MAX_CHARS_PER_MESSAGE = 1e4;
|
|
@@ -33345,16 +33771,16 @@ init_view_document_page_tool();
|
|
|
33345
33771
|
// src/templates/tools/perplexity.ts
|
|
33346
33772
|
init_cjs_shims();
|
|
33347
33773
|
init_tool();
|
|
33348
|
-
var
|
|
33774
|
+
var import_zod23 = __toESM(require("zod"), 1);
|
|
33349
33775
|
var import_perplexity_ai = __toESM(require("@perplexity-ai/perplexity_ai"), 1);
|
|
33350
33776
|
var INTERNET_SEARCH_TOOL_NAME = "Internet Search";
|
|
33351
33777
|
var internetSearchTool = new ExuluTool({
|
|
33352
33778
|
id: "internet_search",
|
|
33353
33779
|
name: INTERNET_SEARCH_TOOL_NAME,
|
|
33354
33780
|
description: "Search the internet for information.",
|
|
33355
|
-
inputSchema:
|
|
33356
|
-
query:
|
|
33357
|
-
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.")
|
|
33358
33784
|
}),
|
|
33359
33785
|
category: "internet_search",
|
|
33360
33786
|
type: "web_search",
|
|
@@ -33626,6 +34052,9 @@ function claimCheckStreamMetadata(ctx) {
|
|
|
33626
34052
|
};
|
|
33627
34053
|
}
|
|
33628
34054
|
|
|
34055
|
+
// src/exulu/routes.ts
|
|
34056
|
+
init_public_surface();
|
|
34057
|
+
|
|
33629
34058
|
// src/exulu/transcribe.ts
|
|
33630
34059
|
init_cjs_shims();
|
|
33631
34060
|
init_env();
|
|
@@ -34112,8 +34541,9 @@ function registerViewerIdentityRoutes(app, deps) {
|
|
|
34112
34541
|
|
|
34113
34542
|
// ee/claim-check/routes.ts
|
|
34114
34543
|
init_cjs_shims();
|
|
34115
|
-
var
|
|
34544
|
+
var import_zod24 = require("zod");
|
|
34116
34545
|
init_resolve_max_steps();
|
|
34546
|
+
init_public_surface();
|
|
34117
34547
|
init_types2();
|
|
34118
34548
|
|
|
34119
34549
|
// ee/claim-check/agent-config.ts
|
|
@@ -34175,13 +34605,13 @@ var SOURCE_TYPES = [
|
|
|
34175
34605
|
"session_item",
|
|
34176
34606
|
"other"
|
|
34177
34607
|
];
|
|
34178
|
-
var requestSchema =
|
|
34179
|
-
question:
|
|
34180
|
-
answer:
|
|
34181
|
-
sources:
|
|
34182
|
-
|
|
34183
|
-
content:
|
|
34184
|
-
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(),
|
|
34185
34615
|
// Purely informational (spec §2: no trust tiers, dropped before the
|
|
34186
34616
|
// engine sees it — see assignSourceIds below), so an unrecognised
|
|
34187
34617
|
// value is IGNORED, not rejected: `.catch(undefined)` keeps the enum
|
|
@@ -34193,24 +34623,24 @@ var requestSchema = import_zod23.z.object({
|
|
|
34193
34623
|
// `.catch`) would turn that pre-existing 200 into a 400, which is a
|
|
34194
34624
|
// tightening this loosening-only task must not make. Do not remove
|
|
34195
34625
|
// the `.catch` to "validate properly": that is the bug this guards.
|
|
34196
|
-
type:
|
|
34197
|
-
id:
|
|
34626
|
+
type: import_zod24.z.enum(SOURCE_TYPES).optional().catch(void 0),
|
|
34627
|
+
id: import_zod24.z.string().min(1).optional()
|
|
34198
34628
|
})
|
|
34199
34629
|
).default([]),
|
|
34200
|
-
agent:
|
|
34201
|
-
session:
|
|
34202
|
-
messageId:
|
|
34203
|
-
model:
|
|
34204
|
-
locale:
|
|
34205
|
-
options:
|
|
34206
|
-
fidelity:
|
|
34207
|
-
completions:
|
|
34208
|
-
reRetrieve:
|
|
34209
|
-
thresholds:
|
|
34210
|
-
caps:
|
|
34211
|
-
maxSentences:
|
|
34212
|
-
maxClaims:
|
|
34213
|
-
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)
|
|
34214
34644
|
}).partial().optional()
|
|
34215
34645
|
}).optional()
|
|
34216
34646
|
});
|
|
@@ -34804,7 +35234,7 @@ function selectEvidence(claimTexts, index, topK = 4) {
|
|
|
34804
35234
|
|
|
34805
35235
|
// ee/claim-check/stages/select-disambiguate.ts
|
|
34806
35236
|
init_cjs_shims();
|
|
34807
|
-
var
|
|
35237
|
+
var import_zod26 = require("zod");
|
|
34808
35238
|
init_micro_call();
|
|
34809
35239
|
init_types2();
|
|
34810
35240
|
|
|
@@ -34941,16 +35371,16 @@ resolvable=false and clarified=null for it.`;
|
|
|
34941
35371
|
|
|
34942
35372
|
// ee/claim-check/stages/select.ts
|
|
34943
35373
|
init_cjs_shims();
|
|
34944
|
-
var
|
|
35374
|
+
var import_zod25 = require("zod");
|
|
34945
35375
|
init_micro_call();
|
|
34946
35376
|
init_types2();
|
|
34947
|
-
var schema2 =
|
|
34948
|
-
sentences:
|
|
34949
|
-
|
|
34950
|
-
index:
|
|
34951
|
-
verifiable:
|
|
34952
|
-
rewritten:
|
|
34953
|
-
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()
|
|
34954
35384
|
})
|
|
34955
35385
|
)
|
|
34956
35386
|
});
|
|
@@ -35008,15 +35438,15 @@ async function runSelection(args) {
|
|
|
35008
35438
|
}
|
|
35009
35439
|
|
|
35010
35440
|
// ee/claim-check/stages/select-disambiguate.ts
|
|
35011
|
-
var schema3 =
|
|
35012
|
-
sentences:
|
|
35013
|
-
|
|
35014
|
-
index:
|
|
35015
|
-
verifiable:
|
|
35016
|
-
rewritten:
|
|
35017
|
-
resolvable:
|
|
35018
|
-
clarified:
|
|
35019
|
-
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()
|
|
35020
35450
|
})
|
|
35021
35451
|
)
|
|
35022
35452
|
});
|
|
@@ -35067,16 +35497,16 @@ async function runSelectAndDisambiguate(args) {
|
|
|
35067
35497
|
|
|
35068
35498
|
// ee/claim-check/stages/disambiguate.ts
|
|
35069
35499
|
init_cjs_shims();
|
|
35070
|
-
var
|
|
35500
|
+
var import_zod27 = require("zod");
|
|
35071
35501
|
init_micro_call();
|
|
35072
35502
|
init_types2();
|
|
35073
|
-
var schema4 =
|
|
35074
|
-
sentences:
|
|
35075
|
-
|
|
35076
|
-
index:
|
|
35077
|
-
resolvable:
|
|
35078
|
-
clarified:
|
|
35079
|
-
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()
|
|
35080
35510
|
})
|
|
35081
35511
|
)
|
|
35082
35512
|
});
|
|
@@ -35123,7 +35553,7 @@ async function runDisambiguation(args) {
|
|
|
35123
35553
|
|
|
35124
35554
|
// ee/claim-check/stages/decompose.ts
|
|
35125
35555
|
init_cjs_shims();
|
|
35126
|
-
var
|
|
35556
|
+
var import_zod28 = require("zod");
|
|
35127
35557
|
init_micro_call();
|
|
35128
35558
|
init_types2();
|
|
35129
35559
|
|
|
@@ -35174,11 +35604,11 @@ function decomposeUserPrompt(args) {
|
|
|
35174
35604
|
}
|
|
35175
35605
|
|
|
35176
35606
|
// ee/claim-check/stages/decompose.ts
|
|
35177
|
-
var schema5 =
|
|
35178
|
-
sentences:
|
|
35179
|
-
|
|
35180
|
-
index:
|
|
35181
|
-
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() }))
|
|
35182
35612
|
})
|
|
35183
35613
|
)
|
|
35184
35614
|
});
|
|
@@ -35214,7 +35644,7 @@ async function runDecomposition(args) {
|
|
|
35214
35644
|
|
|
35215
35645
|
// ee/claim-check/stages/verify.ts
|
|
35216
35646
|
init_cjs_shims();
|
|
35217
|
-
var
|
|
35647
|
+
var import_zod29 = require("zod");
|
|
35218
35648
|
init_micro_call();
|
|
35219
35649
|
init_types2();
|
|
35220
35650
|
|
|
@@ -35276,13 +35706,13 @@ function addUsage(a, b) {
|
|
|
35276
35706
|
}
|
|
35277
35707
|
|
|
35278
35708
|
// ee/claim-check/stages/verify.ts
|
|
35279
|
-
var schema6 =
|
|
35280
|
-
claims:
|
|
35281
|
-
|
|
35282
|
-
claimId:
|
|
35283
|
-
verdict:
|
|
35284
|
-
evidence:
|
|
35285
|
-
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()
|
|
35286
35716
|
})
|
|
35287
35717
|
)
|
|
35288
35718
|
});
|
|
@@ -36537,13 +36967,13 @@ var handleOauthCallback = async (req, res) => {
|
|
|
36537
36967
|
|
|
36538
36968
|
// src/exulu/auth/submit-handler.ts
|
|
36539
36969
|
init_cjs_shims();
|
|
36540
|
-
var
|
|
36970
|
+
var import_zod30 = require("zod");
|
|
36541
36971
|
init_registry();
|
|
36542
36972
|
init_credential_store();
|
|
36543
36973
|
init_credentials_request();
|
|
36544
|
-
var bodySchema =
|
|
36545
|
-
nonce:
|
|
36546
|
-
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())
|
|
36547
36977
|
});
|
|
36548
36978
|
async function handleCredentialSubmit(req, res) {
|
|
36549
36979
|
const authResult = await requestValidators.authenticate(req);
|
|
@@ -41335,7 +41765,7 @@ init_check_record_access();
|
|
|
41335
41765
|
init_resolve_model();
|
|
41336
41766
|
init_supervisor();
|
|
41337
41767
|
init_client();
|
|
41338
|
-
var
|
|
41768
|
+
var import_zod31 = require("zod");
|
|
41339
41769
|
init_convert_exulu_tools_to_ai_sdk_tools();
|
|
41340
41770
|
init_singleton();
|
|
41341
41771
|
var SESSION_ID_HEADER = "mcp-session-id";
|
|
@@ -41399,7 +41829,7 @@ var ExuluMCP = class {
|
|
|
41399
41829
|
title: tool4.name + " agent",
|
|
41400
41830
|
description: tool4.description,
|
|
41401
41831
|
inputSchema: {
|
|
41402
|
-
inputs: tool4.inputSchema ||
|
|
41832
|
+
inputs: tool4.inputSchema || import_zod31.z.object({})
|
|
41403
41833
|
}
|
|
41404
41834
|
},
|
|
41405
41835
|
async ({ inputs }, args) => {
|
|
@@ -41450,7 +41880,7 @@ var ExuluMCP = class {
|
|
|
41450
41880
|
title: "Get List of Prompt Templates",
|
|
41451
41881
|
description: "Retrieves a list of prompt templates available for this agent. Returns the name, description, and ID of each template.",
|
|
41452
41882
|
inputSchema: {
|
|
41453
|
-
inputs:
|
|
41883
|
+
inputs: import_zod31.z.object({})
|
|
41454
41884
|
}
|
|
41455
41885
|
},
|
|
41456
41886
|
async ({ inputs }, args) => {
|
|
@@ -41496,8 +41926,8 @@ var ExuluMCP = class {
|
|
|
41496
41926
|
title: "Get Prompt Template Details",
|
|
41497
41927
|
description: "Retrieves the full details of a specific prompt template by ID, including the actual template content with variables.",
|
|
41498
41928
|
inputSchema: {
|
|
41499
|
-
inputs:
|
|
41500
|
-
id:
|
|
41929
|
+
inputs: import_zod31.z.object({
|
|
41930
|
+
id: import_zod31.z.string().describe("The ID of the prompt template to retrieve")
|
|
41501
41931
|
})
|
|
41502
41932
|
}
|
|
41503
41933
|
},
|
|
@@ -41738,7 +42168,7 @@ var ExuluEval = class {
|
|
|
41738
42168
|
// src/templates/evals/index.ts
|
|
41739
42169
|
init_resolve_model();
|
|
41740
42170
|
init_singleton();
|
|
41741
|
-
var
|
|
42171
|
+
var import_zod32 = require("zod");
|
|
41742
42172
|
var import_ai17 = require("ai");
|
|
41743
42173
|
var llmAsJudgeEval = () => {
|
|
41744
42174
|
if (process.env.REDIS_HOST?.length && process.env.REDIS_PORT?.length) {
|
|
@@ -41789,8 +42219,8 @@ var llmAsJudgeEval = () => {
|
|
|
41789
42219
|
prompt,
|
|
41790
42220
|
maxRetries: 2,
|
|
41791
42221
|
output: import_ai17.Output.object({
|
|
41792
|
-
schema:
|
|
41793
|
-
score:
|
|
42222
|
+
schema: import_zod32.z.object({
|
|
42223
|
+
score: import_zod32.z.number().min(0).max(100).describe("The score between 0 and 100.")
|
|
41794
42224
|
})
|
|
41795
42225
|
})
|
|
41796
42226
|
});
|
|
@@ -42021,15 +42451,15 @@ Usage:
|
|
|
42021
42451
|
- If no todos exist yet, an empty list will be returned`;
|
|
42022
42452
|
|
|
42023
42453
|
// src/templates/tools/todo/todo.ts
|
|
42024
|
-
var
|
|
42454
|
+
var import_zod33 = __toESM(require("zod"), 1);
|
|
42025
42455
|
init_tool();
|
|
42026
42456
|
init_check_record_access();
|
|
42027
42457
|
init_client();
|
|
42028
|
-
var TodoSchema =
|
|
42029
|
-
content:
|
|
42030
|
-
status:
|
|
42031
|
-
priority:
|
|
42032
|
-
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")
|
|
42033
42463
|
});
|
|
42034
42464
|
var TodoWriteTool = new ExuluTool({
|
|
42035
42465
|
id: "todo_write",
|
|
@@ -42045,8 +42475,8 @@ var TodoWriteTool = new ExuluTool({
|
|
|
42045
42475
|
default: todowrite_default
|
|
42046
42476
|
}
|
|
42047
42477
|
],
|
|
42048
|
-
inputSchema:
|
|
42049
|
-
todos:
|
|
42478
|
+
inputSchema: import_zod33.default.object({
|
|
42479
|
+
todos: import_zod33.default.array(TodoSchema).describe("The updated todo list")
|
|
42050
42480
|
}),
|
|
42051
42481
|
execute: async (inputs) => {
|
|
42052
42482
|
const { sessionID, todos, user } = inputs;
|
|
@@ -42081,7 +42511,7 @@ var TodoReadTool = new ExuluTool({
|
|
|
42081
42511
|
id: "todo_read",
|
|
42082
42512
|
name: "Todo Read",
|
|
42083
42513
|
description: "Use this tool to read your todo list",
|
|
42084
|
-
inputSchema:
|
|
42514
|
+
inputSchema: import_zod33.default.object({}),
|
|
42085
42515
|
type: "function",
|
|
42086
42516
|
category: "todo",
|
|
42087
42517
|
config: [
|
|
@@ -42126,7 +42556,7 @@ init_cjs_shims();
|
|
|
42126
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';
|
|
42127
42557
|
|
|
42128
42558
|
// src/templates/tools/question/question.ts
|
|
42129
|
-
var
|
|
42559
|
+
var import_zod35 = __toESM(require("zod"), 1);
|
|
42130
42560
|
init_tool();
|
|
42131
42561
|
init_client();
|
|
42132
42562
|
|
|
@@ -42218,21 +42648,21 @@ After asking a question, use the Question Read tool to check if the user has ans
|
|
|
42218
42648
|
`;
|
|
42219
42649
|
|
|
42220
42650
|
// src/templates/tools/question/question-ask.ts
|
|
42221
|
-
var
|
|
42651
|
+
var import_zod34 = __toESM(require("zod"), 1);
|
|
42222
42652
|
init_tool();
|
|
42223
42653
|
init_check_record_access();
|
|
42224
42654
|
init_client();
|
|
42225
42655
|
var import_node_crypto22 = require("crypto");
|
|
42226
|
-
var AnswerOptionSchema =
|
|
42227
|
-
id:
|
|
42228
|
-
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")
|
|
42229
42659
|
});
|
|
42230
|
-
var _QuestionSchema =
|
|
42231
|
-
id:
|
|
42232
|
-
question:
|
|
42233
|
-
answerOptions:
|
|
42234
|
-
selectedAnswerId:
|
|
42235
|
-
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")
|
|
42236
42666
|
});
|
|
42237
42667
|
var QuestionAskTool = new ExuluTool({
|
|
42238
42668
|
id: "question_ask",
|
|
@@ -42249,9 +42679,9 @@ var QuestionAskTool = new ExuluTool({
|
|
|
42249
42679
|
default: questionask_default
|
|
42250
42680
|
}
|
|
42251
42681
|
],
|
|
42252
|
-
inputSchema:
|
|
42253
|
-
question:
|
|
42254
|
-
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)")
|
|
42255
42685
|
}),
|
|
42256
42686
|
execute: async (inputs) => {
|
|
42257
42687
|
const { sessionID, question, answerOptions, user } = inputs;
|
|
@@ -42324,7 +42754,7 @@ var QuestionReadTool = new ExuluTool({
|
|
|
42324
42754
|
name: "Question Read",
|
|
42325
42755
|
needsApproval: false,
|
|
42326
42756
|
description: "Use this tool to read questions and their answers",
|
|
42327
|
-
inputSchema:
|
|
42757
|
+
inputSchema: import_zod35.default.object({}),
|
|
42328
42758
|
type: "function",
|
|
42329
42759
|
category: "question",
|
|
42330
42760
|
config: [
|
|
@@ -42357,7 +42787,7 @@ var questionTools = [QuestionAskTool, QuestionReadTool];
|
|
|
42357
42787
|
init_cjs_shims();
|
|
42358
42788
|
init_tool();
|
|
42359
42789
|
var nodemailer = __toESM(require("nodemailer"), 1);
|
|
42360
|
-
var
|
|
42790
|
+
var import_zod36 = require("zod");
|
|
42361
42791
|
var transporter = null;
|
|
42362
42792
|
function getTransporter(config) {
|
|
42363
42793
|
if (!transporter) {
|
|
@@ -42381,11 +42811,11 @@ var emailTool = new ExuluTool({
|
|
|
42381
42811
|
id: "email",
|
|
42382
42812
|
name: "Email",
|
|
42383
42813
|
description: "Send an email.",
|
|
42384
|
-
inputSchema:
|
|
42385
|
-
recipient:
|
|
42386
|
-
subject:
|
|
42387
|
-
html:
|
|
42388
|
-
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.")
|
|
42389
42819
|
}),
|
|
42390
42820
|
type: "function",
|
|
42391
42821
|
config: [{
|
|
@@ -42457,7 +42887,7 @@ init_supervisor();
|
|
|
42457
42887
|
init_client();
|
|
42458
42888
|
init_rbac_resolver();
|
|
42459
42889
|
init_check_record_access();
|
|
42460
|
-
var
|
|
42890
|
+
var import_zod37 = require("zod");
|
|
42461
42891
|
var _cachedImageModels;
|
|
42462
42892
|
var setCachedImageModels = (models2) => {
|
|
42463
42893
|
_cachedImageModels = models2;
|
|
@@ -42518,8 +42948,8 @@ var createImageGenerationWidgetTool = (models2) => {
|
|
|
42518
42948
|
needsApproval: false,
|
|
42519
42949
|
type: "function",
|
|
42520
42950
|
config: [],
|
|
42521
|
-
inputSchema:
|
|
42522
|
-
prompt:
|
|
42951
|
+
inputSchema: import_zod37.z.object({
|
|
42952
|
+
prompt: import_zod37.z.string().describe(
|
|
42523
42953
|
"Initial image prompt. The user can edit it before generating."
|
|
42524
42954
|
)
|
|
42525
42955
|
}),
|
|
@@ -45696,12 +46126,12 @@ async function fitContextProjection({
|
|
|
45696
46126
|
const basis = randomizedPCA(vectors, dims, Math.min(budget, dims, vectors.length - 1), seed, POWER_ITERATIONS);
|
|
45697
46127
|
if (basis.length === 0) return empty(`${contextId} has no variance in its embeddings`);
|
|
45698
46128
|
const reduced = vectors.map((v) => projectComponents(v, mean, basis));
|
|
45699
|
-
const spread = reduced.reduce((s,
|
|
46129
|
+
const spread = reduced.reduce((s, z38) => s + Math.hypot(...Array.from(z38)), 0) / reduced.length;
|
|
45700
46130
|
if (!Number.isFinite(spread) || spread < 1e-8) return empty(`${contextId} has no variance in its embeddings`);
|
|
45701
46131
|
log7(`fitting ${contextId}: ${vectors.length} vectors, ${dims} dims \u2192 ${basis.length} components`);
|
|
45702
46132
|
log7(`${contextId}: laying out ${reduced.length} points in 3d (the slow phase)`);
|
|
45703
46133
|
const umap = (umapFactory ?? defaultUmap)(seed, reduced.length);
|
|
45704
|
-
const raw = umap.fit(reduced.map((
|
|
46134
|
+
const raw = umap.fit(reduced.map((z38) => Array.from(z38)));
|
|
45705
46135
|
const oriented = rotateLayout(raw, principalRotation(raw, seed));
|
|
45706
46136
|
const { points: layout, scale } = normalizeLayout(oriented);
|
|
45707
46137
|
if (!Number.isFinite(scale) || scale <= 0) return empty(`${contextId} produced a degenerate layout (every point in one place)`);
|
|
@@ -45786,13 +46216,13 @@ async function backfillCoordinates({
|
|
|
45786
46216
|
const raw = parseVector(row.embedding);
|
|
45787
46217
|
if (raw.length !== projection.dims) continue;
|
|
45788
46218
|
const known = layout?.get(String(row.id));
|
|
45789
|
-
const [x, y,
|
|
46219
|
+
const [x, y, z38] = known ?? applyMap(
|
|
45790
46220
|
projectComponents(l2normalize(raw), mean, basis),
|
|
45791
46221
|
projection.map,
|
|
45792
46222
|
projection.intercept
|
|
45793
46223
|
);
|
|
45794
46224
|
values.push("(?::uuid, ?::real, ?::real, ?::real)");
|
|
45795
|
-
bindings.push(row.id, x, y,
|
|
46225
|
+
bindings.push(row.id, x, y, z38);
|
|
45796
46226
|
}
|
|
45797
46227
|
if (values.length) {
|
|
45798
46228
|
await db2.raw(
|