@exulu/backend 5.11.0 → 5.12.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/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 z38 = new Float64Array(basis.length);
3709
+ const z39 = 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
- z38[b] = dot;
3713
+ z39[b] = dot;
3714
3714
  }
3715
3715
  for (const [b, target] of next.entries()) {
3716
- const scale = z38[b] ?? 0;
3716
+ const scale = z39[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
  }
@@ -3804,19 +3804,19 @@ function ridgeFit(Z, Y, lambda) {
3804
3804
  return w !== void 0 && Number.isFinite(w) ? w : 0;
3805
3805
  }));
3806
3806
  const intercept = [0, 1, 2].map((j) => {
3807
- const mapRow = map[j] ?? [];
3808
- const correction = mapRow.reduce((s, w, d) => s + w * (zMean[d] ?? 0), 0);
3807
+ const mapRow2 = map[j] ?? [];
3808
+ const correction = mapRow2.reduce((s, w, d) => s + w * (zMean[d] ?? 0), 0);
3809
3809
  const value = (yMean[j] ?? 0) - correction;
3810
3810
  return Number.isFinite(value) ? value : 0;
3811
3811
  });
3812
3812
  return { map, intercept };
3813
3813
  }
3814
- function applyMap(z38, map, intercept) {
3814
+ function applyMap(z39, 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) * (z38[d] ?? 0);
3819
+ for (let d = 0; d < row.length; d += 1) v += (row[d] ?? 0) * (z39[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, z38] = applyMap(zi, map, intercept);
3843
- total += Math.hypot(x - finite(yi[0]), y - finite(yi[1]), z38 - finite(yi[2]));
3842
+ const [x, y, z39] = applyMap(zi, map, intercept);
3843
+ total += Math.hypot(x - finite(yi[0]), y - finite(yi[1]), z39 - 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, z38] = applyMap(projectComponents(l2normalize(v), mean, basis), projection.map, projection.intercept);
3988
- return { x, y, z: z38 };
3987
+ const [x, y, z39] = applyMap(projectComponents(l2normalize(v), mean, basis), projection.map, projection.intercept);
3988
+ return { x, y, z: z39 };
3989
3989
  });
3990
3990
  } catch (e) {
3991
3991
  console.error("[EXULU] could not compute chunk coordinates", e instanceof Error ? e.message : String(e));
@@ -5044,6 +5044,23 @@ var init_schemas = __esm({
5044
5044
  {
5045
5045
  name: "workflow",
5046
5046
  type: "text"
5047
+ },
5048
+ // Work status of a routine run — the fachliche status people work
5049
+ // with (spec 2026-11-16-routine-work-status-design), separate from
5050
+ // the technical `state`. A key from the routine's work_statuses.
5051
+ {
5052
+ name: "work_status",
5053
+ type: "text",
5054
+ index: true
5055
+ },
5056
+ {
5057
+ name: "work_status_updated_at",
5058
+ type: "date"
5059
+ },
5060
+ // { kind: "user" | "tool" | "agent" | "default", id?, user? }
5061
+ {
5062
+ name: "work_status_updated_by",
5063
+ type: "json"
5047
5064
  }
5048
5065
  ]
5049
5066
  };
@@ -5180,6 +5197,12 @@ var init_schemas = __esm({
5180
5197
  type: "boolean",
5181
5198
  default: false
5182
5199
  },
5200
+ // Per-routine work statuses: { statuses: [{ key, label, color?, done? }], default }.
5201
+ // null / empty list = feature off for this routine.
5202
+ {
5203
+ name: "work_statuses",
5204
+ type: "json"
5205
+ },
5183
5206
  {
5184
5207
  name: "queue",
5185
5208
  type: "text"
@@ -13853,6 +13876,45 @@ var init_create_sandbox = __esm({
13853
13876
  }
13854
13877
  });
13855
13878
 
13879
+ // src/templates/tools/routine-status-tool.ts
13880
+ function createRoutineStatusTool(handle) {
13881
+ if (!handle || handle.statuses.length === 0) return void 0;
13882
+ const keys = handle.statuses.map((status) => status.key);
13883
+ const labelOf = (key) => handle.statuses.find((status) => status.key === key)?.label ?? key;
13884
+ return new ExuluTool({
13885
+ id: SET_ROUTINE_STATUS_TOOL_ID,
13886
+ name: "Set routine status",
13887
+ description: `Sets the work status of this run of the routine "${handle.name}" for the people working the run list. Use it when the step instructions tell you to, with exactly one of these values: ` + handle.statuses.map((status) => `${status.key} \u2014 ${status.label}`).join("; ") + ".",
13888
+ category: "routines",
13889
+ type: "function",
13890
+ needsApproval: false,
13891
+ inputSchema: import_zod10.z.object({
13892
+ status: import_zod10.z.enum(keys).describe("The work status key to set.")
13893
+ }),
13894
+ config: [],
13895
+ execute: async ({ status }) => {
13896
+ const decision = await handle.runs.current.updateWithResult({ status });
13897
+ if (decision?.action === "skip" && decision.reason === "human_set") {
13898
+ return {
13899
+ result: `A person already set the status to "${labelOf(handle.runs.current.status ?? "")}"; left unchanged.`
13900
+ };
13901
+ }
13902
+ if (decision?.action === "skip") return { result: `Status is already "${labelOf(status)}".` };
13903
+ return { result: `Status set to "${labelOf(status)}".` };
13904
+ }
13905
+ });
13906
+ }
13907
+ var import_zod10, SET_ROUTINE_STATUS_TOOL_ID;
13908
+ var init_routine_status_tool = __esm({
13909
+ "src/templates/tools/routine-status-tool.ts"() {
13910
+ "use strict";
13911
+ init_cjs_shims();
13912
+ import_zod10 = require("zod");
13913
+ init_tool();
13914
+ SET_ROUTINE_STATUS_TOOL_ID = "set_routine_status";
13915
+ }
13916
+ });
13917
+
13856
13918
  // src/utils/truncate-tool-output.ts
13857
13919
  var truncateToolOutput;
13858
13920
  var init_truncate_tool_output = __esm({
@@ -14085,12 +14147,12 @@ var init_auth_tool_model_output = __esm({
14085
14147
  });
14086
14148
 
14087
14149
  // src/templates/tools/session-file-read-tool.ts
14088
- var import_zod10, DEFAULT_LIMIT, MAX_CONTENT_CHARS, SESSION_FILE_READ_TOOL_NAME, createSessionFileReadTool;
14150
+ var import_zod11, DEFAULT_LIMIT, MAX_CONTENT_CHARS, SESSION_FILE_READ_TOOL_NAME, createSessionFileReadTool;
14089
14151
  var init_session_file_read_tool = __esm({
14090
14152
  "src/templates/tools/session-file-read-tool.ts"() {
14091
14153
  "use strict";
14092
14154
  init_cjs_shims();
14093
- import_zod10 = require("zod");
14155
+ import_zod11 = require("zod");
14094
14156
  init_session_files();
14095
14157
  init_tool();
14096
14158
  init_uppy();
@@ -14146,10 +14208,10 @@ var init_session_file_read_tool = __esm({
14146
14208
  name: SESSION_FILE_READ_TOOL_NAME,
14147
14209
  needsApproval: false,
14148
14210
  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.",
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})`)
14211
+ inputSchema: import_zod11.z.object({
14212
+ filename: import_zod11.z.string().describe('Exact session file name as referenced in a truncation notice, e.g. "tool-output-web_search-a1b2c3d4.txt"'),
14213
+ offset: import_zod11.z.number().int().min(1).optional().describe("1-based first line to read (default 1)"),
14214
+ limit: import_zod11.z.number().int().min(1).max(1e3).optional().describe(`Number of lines to read (default ${DEFAULT_LIMIT})`)
14153
14215
  }),
14154
14216
  type: "function",
14155
14217
  category: "session",
@@ -14753,15 +14815,15 @@ If the page contains a flow-chart, schematic, technical drawing or control board
14753
14815
  const result = await (0, import_ai3.generateText)({
14754
14816
  model,
14755
14817
  output: import_ai3.Output.object({
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()
14818
+ schema: import_zod12.z.object({
14819
+ needs_correction: import_zod12.z.boolean(),
14820
+ corrected_text: import_zod12.z.string().nullable(),
14821
+ current_page_table: import_zod12.z.object({
14822
+ headers: import_zod12.z.array(import_zod12.z.string()),
14823
+ is_continuation: import_zod12.z.boolean()
14762
14824
  }).nullable(),
14763
- confidence: import_zod11.z.enum(["high", "medium", "low"]),
14764
- reasoning: import_zod11.z.string()
14825
+ confidence: import_zod12.z.enum(["high", "medium", "low"]),
14826
+ reasoning: import_zod12.z.string()
14765
14827
  })
14766
14828
  }),
14767
14829
  messages: [
@@ -15198,7 +15260,7 @@ async function documentProcessor({
15198
15260
  }
15199
15261
  }
15200
15262
  }
15201
- var fs2, path3, import_ai3, import_zod11, import_p_limit, import_crypto3, mammoth, import_turndown, import_word_extractor, import_officeparser, import_liteparse, loadFile;
15263
+ var fs2, path3, import_ai3, import_zod12, import_p_limit, import_crypto3, mammoth, import_turndown, import_word_extractor, import_officeparser, import_liteparse, loadFile;
15202
15264
  var init_doc_processor = __esm({
15203
15265
  "ee/python/documents/processing/doc_processor.ts"() {
15204
15266
  "use strict";
@@ -15206,7 +15268,7 @@ var init_doc_processor = __esm({
15206
15268
  fs2 = __toESM(require("fs"), 1);
15207
15269
  path3 = __toESM(require("path"), 1);
15208
15270
  import_ai3 = require("ai");
15209
- import_zod11 = require("zod");
15271
+ import_zod12 = require("zod");
15210
15272
  import_p_limit = __toESM(require("p-limit"), 1);
15211
15273
  import_crypto3 = require("crypto");
15212
15274
  init_with_retry();
@@ -15397,12 +15459,12 @@ function binaryDocumentBashHint(command, stdout, stderr) {
15397
15459
  const [, file] = match;
15398
15460
  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.`;
15399
15461
  }
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;
15462
+ var import_zod13, 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;
15401
15463
  var init_parse_document_tool = __esm({
15402
15464
  "src/templates/tools/parse-document-tool.ts"() {
15403
15465
  "use strict";
15404
15466
  init_cjs_shims();
15405
- import_zod12 = require("zod");
15467
+ import_zod13 = require("zod");
15406
15468
  import_node_path7 = require("path");
15407
15469
  import_officeparser3 = require("officeparser");
15408
15470
  init_tool();
@@ -15538,11 +15600,11 @@ ${text.trim()}`).join("\n");
15538
15600
  name: PARSE_DOCUMENT_TOOL_NAME,
15539
15601
  needsApproval: false,
15540
15602
  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.`,
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})`)
15603
+ inputSchema: import_zod13.z.object({
15604
+ filename: import_zod13.z.string().describe('Exact session file name, e.g. "report.pdf"'),
15605
+ pages: import_zod13.z.string().optional().describe('PDF page or range to extract, e.g. "2" or "1-5" (default: all pages) (PDF only)'),
15606
+ offset: import_zod13.z.number().int().min(1).optional().describe("1-based first output line to read (default 1)"),
15607
+ limit: import_zod13.z.number().int().min(1).max(1e3).optional().describe(`Number of lines to read (default ${DEFAULT_LIMIT2})`)
15546
15608
  }),
15547
15609
  type: "function",
15548
15610
  category: "session",
@@ -15814,12 +15876,12 @@ var init_tool_image_attachments = __esm({
15814
15876
  });
15815
15877
 
15816
15878
  // src/templates/tools/view-document-page-tool.ts
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;
15879
+ var import_zod14, import_node_path9, VIEW_DOCUMENT_PAGE_TOOL_NAME, MAX_IMAGE_BYTES, SCALE_PRIMARY, SCALE_FALLBACK, IMAGE_MEDIA_TYPES, OFFICE_EXTENSIONS2, createViewDocumentPageTool;
15818
15880
  var init_view_document_page_tool = __esm({
15819
15881
  "src/templates/tools/view-document-page-tool.ts"() {
15820
15882
  "use strict";
15821
15883
  init_cjs_shims();
15822
- import_zod13 = require("zod");
15884
+ import_zod14 = require("zod");
15823
15885
  init_session_files();
15824
15886
  import_node_path9 = require("path");
15825
15887
  init_tool();
@@ -15947,9 +16009,9 @@ var init_view_document_page_tool = __esm({
15947
16009
  name: VIEW_DOCUMENT_PAGE_TOOL_NAME,
15948
16010
  needsApproval: false,
15949
16011
  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.",
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)")
16012
+ inputSchema: import_zod14.z.object({
16013
+ filename: import_zod14.z.string().describe('Exact session file name, e.g. "report.pdf" or "screenshot.png"'),
16014
+ page: import_zod14.z.number().int().min(1).optional().describe("Page number to render (default 1; ignored for image files)")
15953
16015
  }),
15954
16016
  type: "function",
15955
16017
  category: "session",
@@ -16037,6 +16099,7 @@ var init_convert_exulu_tools_to_ai_sdk_tools = __esm({
16037
16099
  init_context_write_tools();
16038
16100
  init_skill_author_tools();
16039
16101
  init_create_sandbox();
16102
+ init_routine_status_tool();
16040
16103
  init_uppy();
16041
16104
  init_truncate_tool_output();
16042
16105
  init_tool_output_offload();
@@ -16146,7 +16209,7 @@ var init_convert_exulu_tools_to_ai_sdk_tools = __esm({
16146
16209
  await Promise.all(promises2);
16147
16210
  return tool4;
16148
16211
  };
16149
- convertExuluToolsToAiSdkTools = async (currentTools, currentSkills, approvedTools, allExuluTools, configs, contexts, user, exuluConfig, sessionID, req, project, sessionItems, model, agent, memoryItems, contextWindow, disabledTools, sessionOwnerId, memoryDecisions, skillDecisions) => {
16212
+ convertExuluToolsToAiSdkTools = async (currentTools, currentSkills, approvedTools, allExuluTools, configs, contexts, user, exuluConfig, sessionID, req, project, sessionItems, model, agent, memoryItems, contextWindow, disabledTools, sessionOwnerId, memoryDecisions, skillDecisions, routineHandleFactory) => {
16150
16213
  if (!currentTools) return {};
16151
16214
  if (!allExuluTools) {
16152
16215
  allExuluTools = [];
@@ -16251,6 +16314,10 @@ var init_convert_exulu_tools_to_ai_sdk_tools = __esm({
16251
16314
  if (parseDocumentTool && !disabled.has(parseDocumentTool.id)) {
16252
16315
  currentTools.push(parseDocumentTool);
16253
16316
  }
16317
+ const routineStatusTool = createRoutineStatusTool(routineHandleFactory?.({ kind: "agent" }));
16318
+ if (routineStatusTool && !disabled.has(routineStatusTool.id)) {
16319
+ currentTools.push(routineStatusTool);
16320
+ }
16254
16321
  const viewDocumentPageTool = createViewDocumentPageTool({ sessionID, user, exuluConfig, ownerId: sessionOwnerId });
16255
16322
  if (viewDocumentPageTool && !disabled.has(viewDocumentPageTool.id)) {
16256
16323
  currentTools.push(viewDocumentPageTool);
@@ -16496,7 +16563,9 @@ var init_convert_exulu_tools_to_ai_sdk_tools = __esm({
16496
16563
  contexts: contextsMap,
16497
16564
  upload,
16498
16565
  exuluConfig,
16499
- toolVariablesConfig: toolVariablesConfigData
16566
+ toolVariablesConfig: toolVariablesConfigData,
16567
+ // Present only inside a routine run: routine.runs.current.update({ status }).
16568
+ routine: routineHandleFactory?.({ kind: "tool", id: cur.id })
16500
16569
  },
16501
16570
  options
16502
16571
  );
@@ -16580,13 +16649,13 @@ var init_convert_exulu_tools_to_ai_sdk_tools = __esm({
16580
16649
  });
16581
16650
 
16582
16651
  // src/exulu/tool.ts
16583
- var import_ai4, import_zod14, import_node_crypto7, PUBLIC_TOOL_TYPES, ExuluTool;
16652
+ var import_ai4, import_zod15, import_node_crypto7, PUBLIC_TOOL_TYPES, ExuluTool;
16584
16653
  var init_tool = __esm({
16585
16654
  "src/exulu/tool.ts"() {
16586
16655
  "use strict";
16587
16656
  init_cjs_shims();
16588
16657
  import_ai4 = require("ai");
16589
- import_zod14 = require("zod");
16658
+ import_zod15 = require("zod");
16590
16659
  init_sanitize_name();
16591
16660
  import_node_crypto7 = require("crypto");
16592
16661
  init_singleton();
@@ -16651,7 +16720,7 @@ var init_tool = __esm({
16651
16720
  this.type = type;
16652
16721
  this.tool = (0, import_ai4.tool)({
16653
16722
  description,
16654
- inputSchema: inputSchema || import_zod14.z.object({}),
16723
+ inputSchema: inputSchema || import_zod15.z.object({}),
16655
16724
  execute: authentication2 ? wrapExecuteWithAuth(id, authentication2, execute2) : execute2
16656
16725
  });
16657
16726
  }
@@ -16945,92 +17014,92 @@ function effectiveKbSettings(profile, ctx) {
16945
17014
  keywordPrefilter: preset.keywordPrefilter
16946
17015
  };
16947
17016
  }
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;
17017
+ var import_zod16, KB_KINDS, DEFAULT_PREFILTER_CUTOFF, RRF_K, CHUNK_GROUP_MAX, kbProfileSchema, knowledgeBasesSchema, routingRuleSchema, routingSchema, identifierSetSchema, vocabularySchema, memorySchema, tuningSchema, claimCheckSchema, boolVal, strVal, KIND_PRESETS;
16949
17018
  var init_config3 = __esm({
16950
17019
  "ee/agentic-retrieval/pipeline/config.ts"() {
16951
17020
  "use strict";
16952
17021
  init_cjs_shims();
16953
- import_zod15 = require("zod");
17022
+ import_zod16 = require("zod");
16954
17023
  init_types2();
16955
17024
  KB_KINDS = ["documents", "conversations", "records"];
16956
17025
  DEFAULT_PREFILTER_CUTOFF = 2.5;
16957
17026
  RRF_K = 60;
16958
17027
  CHUNK_GROUP_MAX = 10;
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()
17028
+ kbProfileSchema = import_zod16.z.object({
17029
+ enabled: import_zod16.z.boolean().default(true),
17030
+ kind: import_zod16.z.enum(KB_KINDS).default("documents"),
17031
+ instructions: import_zod16.z.string().default(""),
17032
+ overrides: import_zod16.z.object({
17033
+ limit: import_zod16.z.number().int().positive().optional(),
17034
+ expand: import_zod16.z.number().int().min(0).optional(),
17035
+ multiQuery: import_zod16.z.boolean().optional(),
17036
+ hyde: import_zod16.z.boolean().optional()
16968
17037
  }).default({})
16969
17038
  });
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([])
17039
+ knowledgeBasesSchema = import_zod16.z.record(import_zod16.z.string(), kbProfileSchema);
17040
+ routingRuleSchema = import_zod16.z.object({
17041
+ id: import_zod16.z.string(),
17042
+ label: import_zod16.z.string(),
17043
+ description: import_zod16.z.string(),
17044
+ main: import_zod16.z.array(import_zod16.z.string()),
17045
+ fallback: import_zod16.z.array(import_zod16.z.string()).default([])
16977
17046
  });
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([])
17047
+ routingSchema = import_zod16.z.object({ rules: import_zod16.z.array(routingRuleSchema).default([]) });
17048
+ identifierSetSchema = import_zod16.z.object({
17049
+ name: import_zod16.z.string(),
17050
+ description: import_zod16.z.string().default(""),
17051
+ examples: import_zod16.z.array(import_zod16.z.string()).default([]),
17052
+ strategy: import_zod16.z.enum(["fuzzy", "exact"]),
17053
+ contexts: import_zod16.z.array(import_zod16.z.string()).default([])
16985
17054
  });
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("")
17055
+ vocabularySchema = import_zod16.z.object({
17056
+ glossary: import_zod16.z.array(import_zod16.z.object({ term: import_zod16.z.string(), meaning: import_zod16.z.string() })).default([]),
17057
+ identifiers: import_zod16.z.array(identifierSetSchema).default([]),
17058
+ rewrites: import_zod16.z.array(import_zod16.z.object({ find: import_zod16.z.string(), replace: import_zod16.z.string() })).default([]),
17059
+ styleHint: import_zod16.z.string().default("")
16991
17060
  });
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)
17061
+ memorySchema = import_zod16.z.object({
17062
+ enabled: import_zod16.z.boolean().default(true),
17063
+ override: import_zod16.z.boolean().default(false),
17064
+ filePrioritization: import_zod16.z.boolean().default(false),
17065
+ queryAugmentation: import_zod16.z.boolean().default(true)
16997
17066
  });
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),
17067
+ tuningSchema = import_zod16.z.object({
17068
+ topK: import_zod16.z.number().int().positive().default(5),
17069
+ fallbackThreshold: import_zod16.z.number().min(0).max(1).default(0.95),
17070
+ pinBoost: import_zod16.z.number().min(0).max(1).default(0.15),
17071
+ identifierBoost: import_zod16.z.number().min(0).max(1).default(0.15),
17072
+ pageWindow: import_zod16.z.number().int().min(0).default(1),
17073
+ maxQueriesPerContext: import_zod16.z.number().int().positive().default(5),
17005
17074
  /**
17006
17075
  * Orchestration engine. "v1" is the sequential flow every agent ran before 2026-09;
17007
17076
  * "v2" merges the phase-1 LLM hops and runs identifier pins in parallel. Per agent,
17008
17077
  * so a candidate agent can run v2 while the production agent stays on v1.
17009
17078
  */
17010
- engine: import_zod15.z.enum(["v1", "v2"]).default("v1"),
17079
+ engine: import_zod16.z.enum(["v1", "v2"]).default("v1"),
17011
17080
  /** v2 sub-features; each can be switched off on its own to bisect a regression. */
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)
17081
+ v2: import_zod16.z.object({
17082
+ mergedMemoryCall: import_zod16.z.boolean().default(true),
17083
+ mergedRoutingCall: import_zod16.z.boolean().default(true),
17084
+ parallelPins: import_zod16.z.boolean().default(true)
17016
17085
  }).default({ mergedMemoryCall: true, mergedRoutingCall: true, parallelPins: true })
17017
17086
  });
17018
- claimCheckSchema = import_zod15.z.object({
17019
- enabled: import_zod15.z.boolean().default(false),
17087
+ claimCheckSchema = import_zod16.z.object({
17088
+ enabled: import_zod16.z.boolean().default(false),
17020
17089
  /** Empty = fall back to the agent's utility model, then the agent's model. */
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)
17090
+ model: import_zod16.z.string().default(""),
17091
+ fidelity: import_zod16.z.enum(["fast", "paper"]).default(CLAIM_CHECK_DEFAULTS.fidelity),
17092
+ completions: import_zod16.z.number().int().min(1).max(3).default(CLAIM_CHECK_DEFAULTS.completions),
17093
+ reRetrieve: import_zod16.z.boolean().default(CLAIM_CHECK_DEFAULTS.reRetrieve),
17094
+ thresholds: import_zod16.z.object({
17095
+ warn: import_zod16.z.number().min(0).max(1).default(CLAIM_CHECK_DEFAULTS.thresholds.warn),
17096
+ alert: import_zod16.z.number().min(0).max(1).default(CLAIM_CHECK_DEFAULTS.thresholds.alert)
17028
17097
  }).default(CLAIM_CHECK_DEFAULTS.thresholds),
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)
17098
+ showToExternalUsers: import_zod16.z.boolean().default(false),
17099
+ caps: import_zod16.z.object({
17100
+ maxSentences: import_zod16.z.number().int().positive().default(CLAIM_CHECK_DEFAULTS.caps.maxSentences),
17101
+ maxClaims: import_zod16.z.number().int().positive().default(CLAIM_CHECK_DEFAULTS.caps.maxClaims),
17102
+ maxReRetrievals: import_zod16.z.number().int().min(0).default(CLAIM_CHECK_DEFAULTS.caps.maxReRetrievals)
17034
17103
  }).default(CLAIM_CHECK_DEFAULTS.caps)
17035
17104
  });
17036
17105
  boolVal = (v) => v === true || v === "true" || v === 1;
@@ -17366,9 +17435,9 @@ async function resolveIdentifierPins({
17366
17435
  model,
17367
17436
  system: set.strategy === "exact" ? EXACT_EXTRACTION_PROMPT(set) : FUZZY_EXTRACTION_PROMPT(set),
17368
17437
  messages: [{ role: "user", content: question }],
17369
- schema: import_zod16.z.object({
17370
- hasMatches: import_zod16.z.boolean(),
17371
- matches: import_zod16.z.array(import_zod16.z.string()).optional()
17438
+ schema: import_zod17.z.object({
17439
+ hasMatches: import_zod17.z.boolean(),
17440
+ matches: import_zod17.z.array(import_zod17.z.string()).optional()
17372
17441
  })
17373
17442
  });
17374
17443
  if (!output?.hasMatches || !output.matches?.length) return;
@@ -17416,13 +17485,13 @@ async function resolveIdentifierPins({
17416
17485
  );
17417
17486
  return { pinsByContext, exactPinsByContext, steps };
17418
17487
  }
17419
- var import_fuse, import_zod16, SUPPLEMENT_MIN_TOKEN_LENGTH, SUPPLEMENT_BUDGET, SUPPLEMENT_BUDGET_WIDE, itemCaches, ensureItemsCache, FUZZY_EXTRACTION_PROMPT, EXACT_EXTRACTION_PROMPT;
17488
+ var import_fuse, import_zod17, SUPPLEMENT_MIN_TOKEN_LENGTH, SUPPLEMENT_BUDGET, SUPPLEMENT_BUDGET_WIDE, itemCaches, ensureItemsCache, FUZZY_EXTRACTION_PROMPT, EXACT_EXTRACTION_PROMPT;
17420
17489
  var init_prefilter = __esm({
17421
17490
  "ee/agentic-retrieval/pipeline/prefilter.ts"() {
17422
17491
  "use strict";
17423
17492
  init_cjs_shims();
17424
17493
  import_fuse = __toESM(require("fuse.js"), 1);
17425
- import_zod16 = require("zod");
17494
+ import_zod17 = require("zod");
17426
17495
  init_micro_call();
17427
17496
  init_text_utils();
17428
17497
  init_config3();
@@ -17506,18 +17575,18 @@ ${rulesLines}` + (extraInstructions ? `
17506
17575
  ${extraInstructions}
17507
17576
  </instructions>` : "") : "");
17508
17577
  const ids = enabledContexts.map((c) => c.id);
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()
17578
+ const schema7 = import_zod18.z.object({
17579
+ docPage: import_zod18.z.object({
17580
+ hasFilenameHint: import_zod18.z.boolean(),
17581
+ filenameHints: import_zod18.z.array(import_zod18.z.string()).optional(),
17582
+ hasPageHint: import_zod18.z.boolean(),
17583
+ pageNumber: import_zod18.z.number().int().nullable().optional()
17515
17584
  }),
17516
- explicitlyRequestedKnowledgeBases: import_zod17.z.array(import_zod17.z.enum(ids)),
17585
+ explicitlyRequestedKnowledgeBases: import_zod18.z.array(import_zod18.z.enum(ids)),
17517
17586
  ...routingRules.length ? {
17518
- classification: import_zod17.z.object({
17519
- ruleId: import_zod17.z.enum(routingRules.map((r) => r.id)),
17520
- reason: import_zod17.z.string()
17587
+ classification: import_zod18.z.object({
17588
+ ruleId: import_zod18.z.enum(routingRules.map((r) => r.id)),
17589
+ reason: import_zod18.z.string()
17521
17590
  })
17522
17591
  } : {}
17523
17592
  });
@@ -17576,11 +17645,11 @@ If explicit, return the knowledge base ids. If not, return an empty array.`;
17576
17645
  model,
17577
17646
  system: buildDocPagePrompt(knownIdentifiers),
17578
17647
  messages: [{ role: "user", content: question }],
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()
17648
+ schema: import_zod18.z.object({
17649
+ hasFilenameHint: import_zod18.z.boolean(),
17650
+ filenameHints: import_zod18.z.array(import_zod18.z.string()).optional(),
17651
+ hasPageHint: import_zod18.z.boolean(),
17652
+ pageNumber: import_zod18.z.number().int().nullable().optional()
17584
17653
  })
17585
17654
  });
17586
17655
  } catch (err4) {
@@ -17604,9 +17673,9 @@ If explicit, return the knowledge base ids. If not, return an empty array.`;
17604
17673
  return await microCall({
17605
17674
  model,
17606
17675
  system: kbSystemPrompt,
17607
- schema: import_zod17.z.object({
17608
- explicitlyRequestedKnowledgeBases: import_zod17.z.array(
17609
- import_zod17.z.enum(enabledContexts.map((c) => c.id))
17676
+ schema: import_zod18.z.object({
17677
+ explicitlyRequestedKnowledgeBases: import_zod18.z.array(
17678
+ import_zod18.z.enum(enabledContexts.map((c) => c.id))
17610
17679
  )
17611
17680
  }),
17612
17681
  messages: [{ role: "user", content: question }]
@@ -17701,9 +17770,9 @@ ${extraInstructions}
17701
17770
  model,
17702
17771
  system: classifyPrompt,
17703
17772
  messages: [{ role: "user", content: question }],
17704
- schema: import_zod17.z.object({
17705
- ruleId: import_zod17.z.enum(ruleIds),
17706
- reason: import_zod17.z.string()
17773
+ schema: import_zod18.z.object({
17774
+ ruleId: import_zod18.z.enum(ruleIds),
17775
+ reason: import_zod18.z.string()
17707
17776
  })
17708
17777
  }));
17709
17778
  const matchedRule = routingRules.find((r) => r.id === classified.ruleId);
@@ -17762,12 +17831,12 @@ ${extraInstructions}
17762
17831
  };
17763
17832
  }
17764
17833
  }
17765
- var import_zod17, MAX_USER_PIN_MATCHES, buildDocPagePrompt;
17834
+ var import_zod18, MAX_USER_PIN_MATCHES, buildDocPagePrompt;
17766
17835
  var init_routing = __esm({
17767
17836
  "ee/agentic-retrieval/pipeline/routing.ts"() {
17768
17837
  "use strict";
17769
17838
  init_cjs_shims();
17770
- import_zod17 = require("zod");
17839
+ import_zod18 = require("zod");
17771
17840
  init_micro_call();
17772
17841
  init_timing();
17773
17842
  init_prefilter();
@@ -17872,22 +17941,22 @@ ${glossary.map((g) => `${g.term} : ${g.meaning}`).join("\n")}` : "";
17872
17941
  `
17873
17942
  }
17874
17943
  ],
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.")
17944
+ schema: import_zod19.z.object({
17945
+ relevantChunkIds: import_zod19.z.array(import_zod19.z.string()).describe("chunk_ids (UUIDs at the start of each bullet) of relevant chunks; empty array if none."),
17946
+ override: import_zod19.z.object({
17947
+ overrides: import_zod19.z.boolean().describe("True ONLY if a chunk directly and sufficiently answers the question."),
17948
+ confidence: import_zod19.z.enum(["high", "medium", "low"]),
17949
+ authoritativeChunkIds: import_zod19.z.array(import_zod19.z.string()).describe("chunk_ids that directly answer the question; empty if overrides is false."),
17950
+ reason: import_zod19.z.string().describe("One short sentence.")
17882
17951
  }),
17883
- filePrioritization: import_zod18.z.object({
17884
- shouldPrioritizeFiles: import_zod18.z.boolean(),
17885
- fileNameHints: import_zod18.z.array(import_zod18.z.string()).optional()
17952
+ filePrioritization: import_zod19.z.object({
17953
+ shouldPrioritizeFiles: import_zod19.z.boolean(),
17954
+ fileNameHints: import_zod19.z.array(import_zod19.z.string()).optional()
17886
17955
  }),
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()
17956
+ augmentation: import_zod19.z.object({
17957
+ updatedUserQuestion: import_zod19.z.string(),
17958
+ updatedRelevantKeywords: import_zod19.z.array(import_zod19.z.string()),
17959
+ updatedImportantKeyword: import_zod19.z.string()
17891
17960
  })
17892
17961
  })
17893
17962
  });
@@ -17970,8 +18039,8 @@ async function runMemoryPhase({
17970
18039
  `
17971
18040
  }
17972
18041
  ],
17973
- schema: import_zod18.z.object({
17974
- relevantChunkIds: import_zod18.z.array(import_zod18.z.string()).describe(
18042
+ schema: import_zod19.z.object({
18043
+ relevantChunkIds: import_zod19.z.array(import_zod19.z.string()).describe(
17975
18044
  "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."
17976
18045
  )
17977
18046
  })
@@ -18080,17 +18149,17 @@ ${glossary.map((g) => `${g.term} : ${g.meaning}`).join("\n")}` : "";
18080
18149
  `
18081
18150
  }
18082
18151
  ],
18083
- schema: import_zod18.z.object({
18084
- overrides: import_zod18.z.boolean().describe(
18152
+ schema: import_zod19.z.object({
18153
+ overrides: import_zod19.z.boolean().describe(
18085
18154
  "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."
18086
18155
  ),
18087
- confidence: import_zod18.z.enum(["high", "medium", "low"]).describe(
18156
+ confidence: import_zod19.z.enum(["high", "medium", "low"]).describe(
18088
18157
  "Confidence that the selected memory chunk(s) fully and directly answer the question."
18089
18158
  ),
18090
- authoritativeChunkIds: import_zod18.z.array(import_zod18.z.string()).describe(
18159
+ authoritativeChunkIds: import_zod19.z.array(import_zod19.z.string()).describe(
18091
18160
  "The chunk_ids of the memory chunk(s) that directly answer the question. Empty if overrides is false."
18092
18161
  ),
18093
- reason: import_zod18.z.string().describe(
18162
+ reason: import_zod19.z.string().describe(
18094
18163
  "One short sentence: why this memory does or does not directly answer the question."
18095
18164
  )
18096
18165
  })
@@ -18114,9 +18183,9 @@ ${glossary.map((g) => `${g.term} : ${g.meaning}`).join("\n")}` : "";
18114
18183
  model,
18115
18184
  system: "You are a helpful assistant that will strictly follow the user's instructions.",
18116
18185
  messages: [{ role: "user", content: PROMPT_EXTRACT_PRIORITIZED_FILES }],
18117
- schema: import_zod18.z.object({
18118
- shouldPrioritizeFiles: import_zod18.z.boolean(),
18119
- fileNameHints: import_zod18.z.array(import_zod18.z.string()).optional()
18186
+ schema: import_zod19.z.object({
18187
+ shouldPrioritizeFiles: import_zod19.z.boolean(),
18188
+ fileNameHints: import_zod19.z.array(import_zod19.z.string()).optional()
18120
18189
  })
18121
18190
  }).catch(() => ({
18122
18191
  output: { shouldPrioritizeFiles: false, fileNameHints: [] }
@@ -18128,10 +18197,10 @@ ${glossary.map((g) => `${g.term} : ${g.meaning}`).join("\n")}` : "";
18128
18197
  model,
18129
18198
  system: "You are a helpful assistant that will strictly follow the user's instructions.",
18130
18199
  messages: [{ role: "user", content: QUERY_AUGMENTATION_PROMPT }],
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()
18200
+ schema: import_zod19.z.object({
18201
+ updatedUserQuestion: import_zod19.z.string(),
18202
+ updatedRelevantKeywords: import_zod19.z.array(import_zod19.z.string()),
18203
+ updatedImportantKeyword: import_zod19.z.string()
18135
18204
  })
18136
18205
  }).catch(() => ({
18137
18206
  output: {
@@ -18218,12 +18287,12 @@ ${glossary.map((g) => `${g.term} : ${g.meaning}`).join("\n")}` : "";
18218
18287
  return neutralResult(question, keywords, importantKeyword);
18219
18288
  }
18220
18289
  }
18221
- var import_zod18, MEMORY_OVERRIDE_MIN_CONFIDENCE, MEMORY_SYNTHETIC_RERANK_SCORE;
18290
+ var import_zod19, MEMORY_OVERRIDE_MIN_CONFIDENCE, MEMORY_SYNTHETIC_RERANK_SCORE;
18222
18291
  var init_memory = __esm({
18223
18292
  "ee/agentic-retrieval/pipeline/memory.ts"() {
18224
18293
  "use strict";
18225
18294
  init_cjs_shims();
18226
- import_zod18 = require("zod");
18295
+ import_zod19 = require("zod");
18227
18296
  init_micro_call();
18228
18297
  init_timing();
18229
18298
  init_prefilter();
@@ -19070,11 +19139,11 @@ function createAgenticRetrievalTool(opts) {
19070
19139
  default: '{"enabled":false,"model":"","fidelity":"fast","thresholds":{"warn":0.1,"alert":0.3}}'
19071
19140
  }
19072
19141
  ],
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(
19142
+ inputSchema: import_zod20.z.object({
19143
+ userQuery: import_zod20.z.string().describe("The original unaltered question from the user"),
19144
+ relevantKeywords: import_zod20.z.array(import_zod20.z.string()).describe("Keywords extracted from the user's question relevant to the search"),
19145
+ importantKeyword: import_zod20.z.string().describe("The single most important keyword from the user's question"),
19146
+ confirmedContextIds: import_zod20.z.array(import_zod20.z.string()).optional().describe(
19078
19147
  "Knowledge base IDs explicitly confirmed by the user to be used in the retrieval. When present, only searches these contexts."
19079
19148
  )
19080
19149
  }),
@@ -19518,12 +19587,12 @@ Verified answer:
19518
19587
  }
19519
19588
  });
19520
19589
  }
19521
- var import_zod19, AGENTIC_RETRIEVAL_TOOL_NAME;
19590
+ var import_zod20, AGENTIC_RETRIEVAL_TOOL_NAME;
19522
19591
  var init_pipeline = __esm({
19523
19592
  "ee/agentic-retrieval/pipeline/index.ts"() {
19524
19593
  "use strict";
19525
19594
  init_cjs_shims();
19526
- import_zod19 = require("zod");
19595
+ import_zod20 = require("zod");
19527
19596
  init_tool();
19528
19597
  init_entitlements();
19529
19598
  init_resolve_reranker();
@@ -21086,6 +21155,181 @@ var clearStreamActive = (sessionID) => {
21086
21155
  };
21087
21156
  var isStreamActive = (sessionID) => active.has(sessionID);
21088
21157
 
21158
+ // src/exulu/routines/work-status-store.ts
21159
+ init_cjs_shims();
21160
+
21161
+ // src/exulu/routines/work-status.ts
21162
+ init_cjs_shims();
21163
+ var WORK_STATUS_KEY_PATTERN = /^[a-z][a-z0-9_]{1,39}$/;
21164
+ var EMPTY = { statuses: [], default: null };
21165
+ var toObject = (raw) => {
21166
+ let value = raw;
21167
+ if (typeof value === "string") {
21168
+ try {
21169
+ value = JSON.parse(value);
21170
+ } catch {
21171
+ return void 0;
21172
+ }
21173
+ }
21174
+ return value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
21175
+ };
21176
+ function parseWorkStatusConfig(raw) {
21177
+ const obj = toObject(raw);
21178
+ if (!obj || !Array.isArray(obj.statuses)) return { ...EMPTY, statuses: [] };
21179
+ const seen = /* @__PURE__ */ new Set();
21180
+ const statuses = [];
21181
+ for (const entry of obj.statuses) {
21182
+ if (!entry || typeof entry !== "object") continue;
21183
+ const { key, label, color, done } = entry;
21184
+ if (typeof key !== "string" || !WORK_STATUS_KEY_PATTERN.test(key) || seen.has(key)) continue;
21185
+ seen.add(key);
21186
+ statuses.push({
21187
+ key,
21188
+ label: typeof label === "string" && label.trim() ? label : key,
21189
+ ...typeof color === "string" ? { color } : {},
21190
+ ...typeof done === "boolean" ? { done } : {}
21191
+ });
21192
+ }
21193
+ const def = typeof obj.default === "string" && seen.has(obj.default) ? obj.default : null;
21194
+ return { statuses, default: def };
21195
+ }
21196
+ function validateWorkStatusConfig(next, _previous) {
21197
+ if (next === null || next === void 0) return [];
21198
+ const obj = toObject(next);
21199
+ if (!obj) return ["work_statuses must be an object { statuses, default }"];
21200
+ if (!Array.isArray(obj.statuses)) return ["work_statuses.statuses must be a list"];
21201
+ const problems = [];
21202
+ const keys = /* @__PURE__ */ new Set();
21203
+ const doneKeys = /* @__PURE__ */ new Set();
21204
+ obj.statuses.forEach((entry, index) => {
21205
+ const { key, label, done } = entry ?? {};
21206
+ if (typeof key !== "string" || !WORK_STATUS_KEY_PATTERN.test(key)) {
21207
+ problems.push(`status ${index + 1}: key ${JSON.stringify(key)} must match ${WORK_STATUS_KEY_PATTERN}`);
21208
+ return;
21209
+ }
21210
+ if (keys.has(key)) problems.push(`duplicate status key "${key}"`);
21211
+ keys.add(key);
21212
+ if (typeof label !== "string" || !label.trim()) problems.push(`status "${key}": label must not be empty`);
21213
+ if (done === true) doneKeys.add(key);
21214
+ });
21215
+ if (obj.statuses.length === 0) return problems;
21216
+ if (typeof obj.default !== "string" || !keys.has(obj.default)) {
21217
+ problems.push(`default ${JSON.stringify(obj.default ?? null)} must be one of the status keys`);
21218
+ } else if (doneKeys.has(obj.default)) {
21219
+ problems.push(`default "${obj.default}" must not be a done status`);
21220
+ }
21221
+ return problems;
21222
+ }
21223
+ function decideWorkStatusWrite(input) {
21224
+ const { config, routineName, current, next, origin } = input;
21225
+ if (next === null) {
21226
+ if (origin !== "manual") {
21227
+ return { action: "reject", message: "A work status can only be cleared by a person in the runs list." };
21228
+ }
21229
+ return current.status === null ? { action: "skip", reason: "unchanged" } : { action: "write", status: null };
21230
+ }
21231
+ if (config.statuses.length === 0) {
21232
+ return { action: "reject", message: `Routine "${routineName}" has no work statuses configured.` };
21233
+ }
21234
+ if (!config.statuses.some((status) => status.key === next)) {
21235
+ return {
21236
+ action: "reject",
21237
+ message: `Unknown work status "${next}" for routine "${routineName}". Allowed: ${config.statuses.map((s) => s.key).join(", ")}`
21238
+ };
21239
+ }
21240
+ if (origin === "worker" && current.updatedBy?.kind === "user") {
21241
+ return { action: "skip", reason: "human_set" };
21242
+ }
21243
+ if (current.status === next) return { action: "skip", reason: "unchanged" };
21244
+ return { action: "write", status: next };
21245
+ }
21246
+
21247
+ // src/exulu/routines/work-status-store.ts
21248
+ var parseActor = (raw) => {
21249
+ let value = raw;
21250
+ if (typeof value === "string") {
21251
+ try {
21252
+ value = JSON.parse(value);
21253
+ } catch {
21254
+ return null;
21255
+ }
21256
+ }
21257
+ return value && typeof value === "object" && typeof value.kind === "string" ? value : null;
21258
+ };
21259
+ var mapRow = (row) => row ? {
21260
+ id: row.id,
21261
+ workflow: row.workflow,
21262
+ work_status: row.work_status ?? null,
21263
+ work_status_updated_at: row.work_status_updated_at ?? null,
21264
+ work_status_updated_by: parseActor(row.work_status_updated_by)
21265
+ } : void 0;
21266
+ async function loadRunWorkStatus(db2, jobResultId) {
21267
+ return mapRow(await db2("job_results").where({ id: jobResultId }).first());
21268
+ }
21269
+ async function loadRoutineWorkStatusConfig(db2, workflowId) {
21270
+ const row = await db2("workflow_templates").where({ id: workflowId }).select("id", "name", "work_statuses").first();
21271
+ if (!row) return void 0;
21272
+ return { id: row.id, name: row.name, config: parseWorkStatusConfig(row.work_statuses) };
21273
+ }
21274
+ async function setRunWorkStatus(db2, args) {
21275
+ const run = await loadRunWorkStatus(db2, args.jobResultId);
21276
+ if (!run) throw new Error(`Run ${args.jobResultId} not found`);
21277
+ const routine = await loadRoutineWorkStatusConfig(db2, run.workflow);
21278
+ if (!routine) throw new Error(`The routine of run ${args.jobResultId} was not found`);
21279
+ const decision = decideWorkStatusWrite({
21280
+ config: routine.config,
21281
+ routineName: routine.name,
21282
+ current: { status: run.work_status, updatedBy: run.work_status_updated_by },
21283
+ next: args.status,
21284
+ origin: args.origin
21285
+ });
21286
+ if (decision.action === "reject") throw new Error(decision.message);
21287
+ if (decision.action === "write") {
21288
+ let query = db2("job_results").where({ id: args.jobResultId });
21289
+ if (args.origin === "worker") {
21290
+ query = query.whereRaw("(work_status_updated_by::jsonb)->>'kind' IS DISTINCT FROM 'user'");
21291
+ }
21292
+ const written = await query.update({
21293
+ work_status: decision.status,
21294
+ work_status_updated_at: /* @__PURE__ */ new Date(),
21295
+ work_status_updated_by: JSON.stringify(args.actor)
21296
+ });
21297
+ if (args.origin === "worker" && written === 0) {
21298
+ console.log(`[EXULU] work status of run ${args.jobResultId} left unchanged: a person set it.`);
21299
+ return { action: "skip", reason: "human_set" };
21300
+ }
21301
+ } else if (decision.reason === "human_set") {
21302
+ console.log(`[EXULU] work status of run ${args.jobResultId} left unchanged: a person set it.`);
21303
+ }
21304
+ return decision;
21305
+ }
21306
+ async function defaultWorkStatusColumns(db2, workflowId) {
21307
+ try {
21308
+ const routine = await loadRoutineWorkStatusConfig(db2, workflowId);
21309
+ if (!routine?.config.default) return {};
21310
+ return {
21311
+ work_status: routine.config.default,
21312
+ work_status_updated_at: /* @__PURE__ */ new Date(),
21313
+ work_status_updated_by: JSON.stringify({ kind: "default" })
21314
+ };
21315
+ } catch (error) {
21316
+ console.warn(`[EXULU] could not resolve the default work status of routine ${workflowId}:`, error);
21317
+ return {};
21318
+ }
21319
+ }
21320
+ async function setRunWorkStatusManually(db2, args) {
21321
+ const row = await db2("job_results").where({ id: args.id }).first();
21322
+ if (!row || row.type !== "workflow" || !row.workflow || !args.readableRoutineIds.includes(row.workflow)) {
21323
+ throw new Error("Routine run not found.");
21324
+ }
21325
+ await setRunWorkStatus(db2, {
21326
+ jobResultId: args.id,
21327
+ status: args.status,
21328
+ actor: { kind: "user", id: args.userId },
21329
+ origin: "manual"
21330
+ });
21331
+ }
21332
+
21089
21333
  // src/exulu/routines/run-state.ts
21090
21334
  var parseRunMetadata = (value) => {
21091
21335
  if (value == null) {
@@ -21108,6 +21352,10 @@ async function casJobResultState(db2, jobResultId, from, to) {
21108
21352
  async function upsertWorkflowRunStart(db2, opts) {
21109
21353
  const triggerMetadataJson = opts.triggerMetadata ? JSON.stringify(opts.triggerMetadata) : null;
21110
21354
  const metadataJson = (currentStepIndex) => JSON.stringify({ ...opts.bookkeeping, current_step_index: currentStepIndex });
21355
+ const defaultStatusFor = async (row) => {
21356
+ if (row && (row.work_status != null || row.work_status_updated_by != null)) return {};
21357
+ return defaultWorkStatusColumns(db2, opts.workflow);
21358
+ };
21111
21359
  if (opts.jobResultId) {
21112
21360
  const currentRow = await db2.from("job_results").where({ id: opts.jobResultId }).first();
21113
21361
  const priorMetadata = parseRunMetadata(currentRow?.metadata);
@@ -21118,6 +21366,7 @@ async function upsertWorkflowRunStart(db2, opts) {
21118
21366
  trigger: opts.trigger,
21119
21367
  trigger_metadata: triggerMetadataJson,
21120
21368
  ...opts.session ? { session: opts.session } : {},
21369
+ ...await defaultStatusFor(currentRow),
21121
21370
  metadata: JSON.stringify({
21122
21371
  ...priorMetadata,
21123
21372
  ...opts.bookkeeping,
@@ -21140,7 +21389,8 @@ async function upsertWorkflowRunStart(db2, opts) {
21140
21389
  trigger: opts.trigger,
21141
21390
  trigger_metadata: triggerMetadataJson,
21142
21391
  metadata: metadataJson(resumeFromIndex),
21143
- tries: (existing.tries ?? 0) + 1
21392
+ tries: (existing.tries ?? 0) + 1,
21393
+ ...await defaultStatusFor(existing)
21144
21394
  });
21145
21395
  return {
21146
21396
  jobResultId: existing.id,
@@ -21159,7 +21409,8 @@ async function upsertWorkflowRunStart(db2, opts) {
21159
21409
  workflow: opts.workflow,
21160
21410
  session: opts.session,
21161
21411
  trigger: opts.trigger,
21162
- trigger_metadata: triggerMetadataJson
21412
+ trigger_metadata: triggerMetadataJson,
21413
+ ...await defaultStatusFor(void 0)
21163
21414
  }).returning("id");
21164
21415
  return {
21165
21416
  jobResultId: inserted[0].id,
@@ -22126,7 +22377,7 @@ function resolveSetting(stored, envValue, codeDefault) {
22126
22377
  // src/exulu/transcripts-settings.ts
22127
22378
  var TRANSCRIPTS_SETTINGS_KEY = "transcripts_settings";
22128
22379
  var DEFAULT_BOT_NAME = "IMP Notetaker";
22129
- var EMPTY = {
22380
+ var EMPTY2 = {
22130
22381
  botName: null,
22131
22382
  notifyChat: null,
22132
22383
  recordersMayOverrideBot: null,
@@ -22155,13 +22406,13 @@ var getTranscriptsSettings = async () => {
22155
22406
  try {
22156
22407
  const { db: db2 } = await postgresClient();
22157
22408
  const row = await db2.from("platform_configurations").where({ config_key: TRANSCRIPTS_SETTINGS_KEY }).first();
22158
- return { ...EMPTY, ...parseStoredSettings(row) ?? {} };
22409
+ return { ...EMPTY2, ...parseStoredSettings(row) ?? {} };
22159
22410
  } catch (err4) {
22160
22411
  console.warn(
22161
22412
  "[EXULU] Could not read the Transcripts settings:",
22162
22413
  err4.message
22163
22414
  );
22164
- return { ...EMPTY };
22415
+ return { ...EMPTY2 };
22165
22416
  }
22166
22417
  };
22167
22418
  var saveTranscriptsSettings = async (patch) => {
@@ -23584,7 +23835,7 @@ init_cjs_shims();
23584
23835
  init_entitlements();
23585
23836
  init_singleton();
23586
23837
  init_tool();
23587
- var import_zod20 = require("zod");
23838
+ var import_zod21 = require("zod");
23588
23839
  init_check_record_access();
23589
23840
  init_resolve_model();
23590
23841
  init_statistics2();
@@ -23866,6 +24117,70 @@ var isRunSessionMetadata = (metadata) => {
23866
24117
  return typeof parsed === "object" && parsed !== null && !!parsed.job_result_id;
23867
24118
  };
23868
24119
 
24120
+ // src/exulu/routines/routine-handle.ts
24121
+ init_cjs_shims();
24122
+ var runIdFromSessionMetadata = (metadata) => {
24123
+ try {
24124
+ const parsed = typeof metadata === "string" ? JSON.parse(metadata) : metadata;
24125
+ const id = parsed?.job_result_id;
24126
+ return typeof id === "string" && id ? id : void 0;
24127
+ } catch {
24128
+ return void 0;
24129
+ }
24130
+ };
24131
+ var PATCH_FIELDS = ["status"];
24132
+ async function resolveRoutineHandleFactory(db2, args) {
24133
+ const origin = args.jobResultId ? "worker" : "chat";
24134
+ try {
24135
+ const jobResultId = args.jobResultId ?? (isRunSessionMetadata(args.sessionMetadata) ? runIdFromSessionMetadata(args.sessionMetadata) : void 0);
24136
+ if (!jobResultId) return void 0;
24137
+ const run = await loadRunWorkStatus(db2, jobResultId);
24138
+ if (!run) return void 0;
24139
+ const routine = await loadRoutineWorkStatusConfig(db2, run.workflow);
24140
+ if (!routine) return void 0;
24141
+ const runId = run.id;
24142
+ const statuses = routine.config.statuses.map(({ key, label, done }) => ({
24143
+ key,
24144
+ label,
24145
+ ...done !== void 0 ? { done } : {}
24146
+ }));
24147
+ const state = { status: run.work_status };
24148
+ return (actor) => {
24149
+ const fullActor = origin === "chat" && args.actingUser !== void 0 ? { ...actor, user: args.actingUser } : actor;
24150
+ const updateWithResult = async (patch) => {
24151
+ const unknown = Object.keys(patch ?? {}).filter((key) => !PATCH_FIELDS.includes(key));
24152
+ if (unknown.length > 0) {
24153
+ throw new Error(`Unknown routine run field(s): ${unknown.join(", ")}. Allowed: ${PATCH_FIELDS.join(", ")}`);
24154
+ }
24155
+ if (patch?.status === void 0) return void 0;
24156
+ const decision = await setRunWorkStatus(db2, { jobResultId: runId, status: patch.status, actor: fullActor, origin });
24157
+ if (decision.action === "write") state.status = decision.status;
24158
+ return decision;
24159
+ };
24160
+ return {
24161
+ id: routine.id,
24162
+ name: routine.name,
24163
+ statuses,
24164
+ runs: {
24165
+ current: {
24166
+ id: runId,
24167
+ get status() {
24168
+ return state.status;
24169
+ },
24170
+ update: async (patch) => {
24171
+ await updateWithResult(patch);
24172
+ },
24173
+ updateWithResult
24174
+ }
24175
+ }
24176
+ };
24177
+ };
24178
+ } catch (error) {
24179
+ console.warn("[EXULU] could not resolve the routine handle for this turn:", error);
24180
+ return void 0;
24181
+ }
24182
+ }
24183
+
23869
24184
  // src/exulu/task-description.ts
23870
24185
  init_cjs_shims();
23871
24186
  var import_ai6 = require("ai");
@@ -24081,13 +24396,13 @@ function previousUserTexts(messages) {
24081
24396
  }
24082
24397
 
24083
24398
  // src/exulu/memory/recall.ts
24084
- var EMPTY2 = { collector: void 0, memoryItems: void 0, promptBlock: "" };
24399
+ var EMPTY3 = { collector: void 0, memoryItems: void 0, promptBlock: "" };
24085
24400
  async function recallMemories({ agent, contexts, query, user, db: db2, previousUserTurns }) {
24086
- if (!agent?.memory || !query) return { ...EMPTY2 };
24401
+ if (!agent?.memory || !query) return { ...EMPTY3 };
24087
24402
  const context = contexts?.find((c) => c.id === agent.memory);
24088
24403
  if (!context) {
24089
24404
  console.warn(`[EXULU] memory: context "${agent.memory}" configured on agent "${agent.id}" was not found; memory off for this turn.`);
24090
- return { ...EMPTY2 };
24405
+ return { ...EMPTY3 };
24091
24406
  }
24092
24407
  const config = resolveMemoryConfig(agent.memory_config);
24093
24408
  const collector = createRecallCollector(context, user, db2);
@@ -24725,7 +25040,8 @@ var generateStream = async ({
24725
25040
  req,
24726
25041
  maxStepCount,
24727
25042
  contextWindow,
24728
- disabledTools
25043
+ disabledTools,
25044
+ routineRun
24729
25045
  }) => {
24730
25046
  if (!message) {
24731
25047
  console.error("[EXULU] Message is required for streaming.");
@@ -24736,12 +25052,14 @@ var generateStream = async ({
24736
25052
  let project;
24737
25053
  let sessionItems;
24738
25054
  let sessionOwnerId;
25055
+ let sessionMetadata;
24739
25056
  let lastTurnAt;
24740
25057
  if (session) {
24741
25058
  const sessionData = await getSession({ sessionID: session });
24742
25059
  project = sessionData.project;
24743
25060
  sessionItems = sessionData.session_items;
24744
25061
  sessionOwnerId = sessionData.user ?? void 0;
25062
+ sessionMetadata = sessionData.metadata;
24745
25063
  console.log("[EXULU] loading previous messages from session: " + session);
24746
25064
  const previousMessages2 = await getAgentMessages({
24747
25065
  session,
@@ -24887,6 +25205,12 @@ When a tool execution is not approved by the user, do not retry it unless explic
24887
25205
  console.log("[EXULU] Skills", currentSkills?.map((x) => x.name));
24888
25206
  const memoryDecisions = collectMemoryDecisions(messages);
24889
25207
  const skillDecisions = collectSkillDecisions(messages);
25208
+ const routineHandleFactory = routineRun || session ? await resolveRoutineHandleFactory((await postgresClient()).db, {
25209
+ sessionId: session,
25210
+ sessionMetadata,
25211
+ jobResultId: routineRun?.jobResultId,
25212
+ actingUser: user?.id
25213
+ }) : void 0;
24890
25214
  const tools = await convertExuluToolsToAiSdkTools(
24891
25215
  currentTools,
24892
25216
  currentSkills,
@@ -24907,7 +25231,8 @@ When a tool execution is not approved by the user, do not retry it unless explic
24907
25231
  disabledTools,
24908
25232
  sessionOwnerId,
24909
25233
  memoryDecisions,
24910
- skillDecisions
25234
+ skillDecisions,
25235
+ routineHandleFactory
24911
25236
  );
24912
25237
  console.log("[EXULU] Converted tools", Object.keys(tools));
24913
25238
  const includesContextSearchTool = currentTools?.some(
@@ -25053,9 +25378,9 @@ var createAgentTool = async (instance2, contexts) => {
25053
25378
  name: `${agent.name}`,
25054
25379
  type: "agent",
25055
25380
  category: "agents",
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")
25381
+ inputSchema: import_zod21.z.object({
25382
+ prompt: import_zod21.z.string().describe("The prompt (usually a question for the agent) to send to the agent."),
25383
+ information: import_zod21.z.string().describe("A summary of relevant context / information from the current session")
25059
25384
  }),
25060
25385
  description: `This tool calls an agent named: ${agent.name}. The agent does the following: ${agent.description}.`,
25061
25386
  config: [],
@@ -25176,6 +25501,25 @@ var getEnabledTools = async (agent, allExuluTools, allContexts, disabledTools =
25176
25501
  return enabledTools;
25177
25502
  };
25178
25503
 
25504
+ // src/utils/enabled-skills.ts
25505
+ init_cjs_shims();
25506
+ init_client();
25507
+ var getEnabledSkills = async (agent, disabledSkills = []) => {
25508
+ const refs = (agent.skills?.filter(Boolean) ?? []).filter(
25509
+ (skill) => !disabledSkills.includes(skill.id)
25510
+ );
25511
+ if (refs.length === 0) return [];
25512
+ const { db: db2 } = await postgresClient();
25513
+ const rows = await db2.from("skills").whereIn(
25514
+ "id",
25515
+ refs.map((skill) => skill.id)
25516
+ );
25517
+ const rowById = new Map(rows.map((row) => [row.id, row]));
25518
+ console.log("[EXULU] available skills", refs.length, "resolved", rows.length);
25519
+ console.log("[EXULU] disabled skills", disabledSkills?.length);
25520
+ return refs.map((ref) => rowById.get(ref.id)).filter((row) => row != null);
25521
+ };
25522
+
25179
25523
  // ee/workers.ts
25180
25524
  init_storage();
25181
25525
  init_context();
@@ -26603,6 +26947,7 @@ var createWorkers = async (queues2, config, contexts, evals, tools, tracer) => {
26603
26947
  variables: data.inputs,
26604
26948
  // Tag LLM spend to this routine (cron + ad-hoc share this path).
26605
26949
  routine: { id: workflow.id, name: workflow.name },
26950
+ jobResultId,
26606
26951
  sessionId,
26607
26952
  resumeFromIndex,
26608
26953
  // Approval-gated tools pause unless the routine opted
@@ -27375,6 +27720,7 @@ var processUiMessagesFlow = async ({
27375
27720
  config,
27376
27721
  variables,
27377
27722
  routine,
27723
+ jobResultId,
27378
27724
  sessionId,
27379
27725
  resumeFromIndex,
27380
27726
  respectToolApprovals
@@ -27397,6 +27743,11 @@ var processUiMessagesFlow = async ({
27397
27743
  "[EXULU] enabled tools",
27398
27744
  enabledTools?.map((x) => x.name + " (" + x.id + ")")
27399
27745
  );
27746
+ const enabledSkills = await getEnabledSkills(agent, []);
27747
+ console.log(
27748
+ "[EXULU] enabled skills",
27749
+ enabledSkills.map((x) => `${x.name} v${x.current_version ?? "?"}`)
27750
+ );
27400
27751
  if (!agent.model) {
27401
27752
  throw new Error(
27402
27753
  `Agent ${agent.name} (${agent.id}) has no model configured.`
@@ -27475,7 +27826,9 @@ var processUiMessagesFlow = async ({
27475
27826
  previousMessages: messageHistory.messages,
27476
27827
  message: currentMessage,
27477
27828
  currentTools: enabledTools,
27829
+ currentSkills: enabledSkills,
27478
27830
  allExuluTools: tools,
27831
+ routineRun: jobResultId ? { jobResultId } : void 0,
27479
27832
  languageModel: resolvedLanguageModel,
27480
27833
  toolConfigs: agent.tools,
27481
27834
  exuluConfig: config,
@@ -27635,10 +27988,31 @@ async function upsertJobStart(db2, bullmqJob, label, fallbackType) {
27635
27988
  }
27636
27989
  }
27637
27990
 
27991
+ // src/exulu/routines/work-status-save.ts
27992
+ init_cjs_shims();
27993
+ function assertWorkStatusConfigSavable(next, previous) {
27994
+ if (next === void 0) return;
27995
+ const problems = validateWorkStatusConfig(next, previous);
27996
+ if (problems.length > 0) {
27997
+ throw new Error(`Invalid work statuses: ${problems.join("; ")}`);
27998
+ }
27999
+ }
28000
+ var GUARDED = ["workflow_templatesCreateOne", "workflow_templatesUpdateOne", "workflow_templatesUpdateOneById"];
28001
+ function guardRoutineWorkStatusWrites(mutations) {
28002
+ for (const name of GUARDED) {
28003
+ const original = mutations[name];
28004
+ if (typeof original !== "function") continue;
28005
+ mutations[name] = async (parent, args, context, info) => {
28006
+ assertWorkStatusConfigSavable(args?.input?.work_statuses);
28007
+ return original(parent, args, context, info);
28008
+ };
28009
+ }
28010
+ }
28011
+
27638
28012
  // src/exulu/routines/runs-query.ts
27639
28013
  init_cjs_shims();
27640
28014
  init_jobs();
27641
- var applyRoutineRunFilters = (query, args, allowedWorkflowIds) => {
28015
+ var applyRoutineRunFilters = (query, args, allowedWorkflowIds, doneKeys) => {
27642
28016
  let q = query.where("job_results.type", "workflow").whereIn("job_results.workflow", allowedWorkflowIds);
27643
28017
  if (args.states?.length) {
27644
28018
  q = q.whereIn("job_results.state", args.states);
@@ -27655,6 +28029,22 @@ var applyRoutineRunFilters = (query, args, allowedWorkflowIds) => {
27655
28029
  if (args.to) {
27656
28030
  q = q.where("job_results.createdAt", "<=", args.to);
27657
28031
  }
28032
+ if (args.workStatuses?.length) {
28033
+ q = q.whereIn("job_results.work_status", args.workStatuses);
28034
+ }
28035
+ if (typeof args.workStatusOpen === "boolean" && doneKeys) {
28036
+ if (args.workStatusOpen) {
28037
+ if (doneKeys.length > 0) {
28038
+ q = q.where((group) => {
28039
+ group.whereNull("job_results.work_status").orWhereNotIn("job_results.work_status", doneKeys);
28040
+ });
28041
+ }
28042
+ } else if (doneKeys.length > 0) {
28043
+ q = q.whereIn("job_results.work_status", doneKeys);
28044
+ } else {
28045
+ q = q.whereRaw("1 = 0");
28046
+ }
28047
+ }
27658
28048
  if (args.search) {
27659
28049
  q = q.leftJoin("agent_sessions", "job_results.session", "agent_sessions.id").where("agent_sessions.title", "ilike", `%${args.search}%`);
27660
28050
  }
@@ -27692,7 +28082,10 @@ var mapRoutineRunRow = (row, routineById) => {
27692
28082
  updatedAt: row.updatedAt,
27693
28083
  inputTokens: tokens?.inputTokens ?? null,
27694
28084
  outputTokens: tokens?.outputTokens ?? null,
27695
- costUsd: tokens?.costUsd ?? null
28085
+ costUsd: tokens?.costUsd ?? null,
28086
+ work_status: row.work_status ?? null,
28087
+ work_status_updated_at: row.work_status_updated_at ?? null,
28088
+ work_status_updated_by: parseMaybeJson(row.work_status_updated_by)
27696
28089
  };
27697
28090
  };
27698
28091
 
@@ -29553,10 +29946,10 @@ init_access_control();
29553
29946
  init_convert_context_to_table_definition();
29554
29947
  init_recall_collector();
29555
29948
  var num = (v) => typeof v === "number" ? v : Number(v) || 0;
29556
- var EMPTY3 = { total: 0, public: 0, private: 0, contributors: 0, visible: 0, lastSavedAt: null, lastSavedBy: null };
29949
+ var EMPTY4 = { total: 0, public: 0, private: 0, contributors: 0, visible: 0, lastSavedAt: null, lastSavedBy: null };
29557
29950
  async function memoryBaseStats({ context, user, db: db2 }) {
29558
29951
  const tableName = getTableName(context.id);
29559
- if (!await db2.schema.hasTable(tableName)) return { ...EMPTY3 };
29952
+ if (!await db2.schema.hasTable(tableName)) return { ...EMPTY4 };
29560
29953
  try {
29561
29954
  const table = convertContextToTableDefinition(context);
29562
29955
  const all = () => db2(tableName).whereNot("archived", true);
@@ -29585,7 +29978,7 @@ async function memoryBaseStats({ context, user, db: db2 }) {
29585
29978
  };
29586
29979
  } catch (error) {
29587
29980
  console.error(`[EXULU] memoryBaseStats failed for context "${context.id}":`, error instanceof Error ? error.message : error);
29588
- return { ...EMPTY3 };
29981
+ return { ...EMPTY4 };
29589
29982
  }
29590
29983
  }
29591
29984
 
@@ -30442,12 +30835,12 @@ async function runScan({ db: db2, context, user, judge, now = /* @__PURE__ */ ne
30442
30835
  // src/exulu/memory/conflicts/judge.ts
30443
30836
  init_cjs_shims();
30444
30837
  var import_ai10 = require("ai");
30445
- var import_zod21 = require("zod");
30838
+ var import_zod22 = require("zod");
30446
30839
  init_resolve_model();
30447
- var schema = import_zod21.z.object({
30448
- verdict: import_zod21.z.enum(["same", "contradict", "compatible"]),
30840
+ var schema = import_zod22.z.object({
30841
+ verdict: import_zod22.z.enum(["same", "contradict", "compatible"]),
30449
30842
  // No .max(160) here: an over-long reason must not fail the whole call — truncate after.
30450
- reason: import_zod21.z.string()
30843
+ reason: import_zod22.z.string()
30451
30844
  });
30452
30845
  var SYSTEM = `You compare two short memories an assistant saved from conversations.
30453
30846
  Answer with JSON: verdict = "same" when both state the same fact or instruction (wording may differ),
@@ -30482,7 +30875,7 @@ async function makeMergeSuggester({ modelId, agent, user }) {
30482
30875
  prompt: members.map((m, i) => `Memory ${i + 1}:
30483
30876
  ${m.information}`).join("\n\n"),
30484
30877
  maxRetries: 1,
30485
- output: import_ai10.Output.object({ schema: import_zod21.z.object({ information: import_zod21.z.string().min(1).max(400) }) })
30878
+ output: import_ai10.Output.object({ schema: import_zod22.z.object({ information: import_zod22.z.string().min(1).max(400) }) })
30486
30879
  });
30487
30880
  const types = members.map((m) => m.type).filter((t) => !!t);
30488
30881
  const type = types.length ? [...types].sort((x, y) => types.filter((t) => t === y).length - types.filter((t) => t === x).length)[0] ?? null : null;
@@ -31395,7 +31788,7 @@ type PageInfo {
31395
31788
  workflowSchedule(workflow: ID!): WorkflowScheduleResult
31396
31789
  `;
31397
31790
  typeDefs += `
31398
- routineRuns(page: Int, limit: Int, workflow: ID, states: [String!], triggers: [String!], from: Date, to: Date, search: String, needsAttention: Boolean): RoutineRunPage
31791
+ routineRuns(page: Int, limit: Int, workflow: ID, states: [String!], triggers: [String!], from: Date, to: Date, search: String, needsAttention: Boolean, workStatuses: [String!], workStatusOpen: Boolean): RoutineRunPage
31399
31792
  routineRunsNeedingAttentionCount: Float!
31400
31793
  `;
31401
31794
  typeDefs += `
@@ -31512,6 +31905,7 @@ type PageInfo {
31512
31905
  `;
31513
31906
  mutationDefs += `
31514
31907
  cancelRoutineRun(id: ID!): RoutineRun
31908
+ setRoutineRunWorkStatus(id: ID!, status: String): RoutineRun
31515
31909
  retryRoutineRun(id: ID!): RoutineRun
31516
31910
  deleteRoutineRun(id: ID!): ID
31517
31911
  `;
@@ -31676,6 +32070,9 @@ type RoutineRun {
31676
32070
  inputTokens: Float
31677
32071
  outputTokens: Float
31678
32072
  costUsd: Float
32073
+ work_status: String
32074
+ work_status_updated_at: Date
32075
+ work_status_updated_by: JSON
31679
32076
  }
31680
32077
 
31681
32078
  type RoutineRunPage {
@@ -32143,7 +32540,10 @@ type EmbeddingModelOption {
32143
32540
  tries: 1,
32144
32541
  type: "workflow",
32145
32542
  workflow: workflow_template_id,
32146
- trigger: jobData.triggerSource ?? null
32543
+ trigger: jobData.triggerSource ?? null,
32544
+ // This path never passes upsertWorkflowRunStart, which gives
32545
+ // queued runs the routine's default work status.
32546
+ ...await defaultWorkStatusColumns(db2, workflow_template_id)
32147
32547
  }).returning("id");
32148
32548
  const jobResultId = jobResult[0].id;
32149
32549
  try {
@@ -32182,7 +32582,10 @@ type EmbeddingModelOption {
32182
32582
  variables: args.variables,
32183
32583
  // Tag LLM spend to this routine (direct one-shot path mirrors the queued path).
32184
32584
  routine: { id: workflow.id, name: workflow.name },
32185
- sessionId
32585
+ sessionId,
32586
+ // Marks tool writes of the work status as the run's own
32587
+ // (never overriding a person), not as a chat continuation.
32588
+ jobResultId
32186
32589
  });
32187
32590
  resolve8(messages2);
32188
32591
  break;
@@ -32274,11 +32677,12 @@ type EmbeddingModelOption {
32274
32677
  }
32275
32678
  const page = Math.max(1, args.page ?? 1);
32276
32679
  const limit = Math.min(100, Math.max(1, args.limit ?? 20));
32277
- const countRows = await applyRoutineRunFilters(db2("job_results"), args, allowedIds).count(
32680
+ const doneKeys = args.workflow && typeof args.workStatusOpen === "boolean" ? ((await loadRoutineWorkStatusConfig(db2, args.workflow))?.config.statuses ?? []).filter((status) => status.done === true).map((status) => status.key) : void 0;
32681
+ const countRows = await applyRoutineRunFilters(db2("job_results"), args, allowedIds, doneKeys).count(
32278
32682
  "* as count"
32279
32683
  );
32280
32684
  const total = Number(countRows[0]?.count ?? 0);
32281
- const rows = await applyRoutineRunFilters(db2("job_results"), args, allowedIds).select("job_results.*").orderBy("job_results.createdAt", "desc").offset((page - 1) * limit).limit(limit);
32685
+ const rows = await applyRoutineRunFilters(db2("job_results"), args, allowedIds, doneKeys).select("job_results.*").orderBy("job_results.createdAt", "desc").offset((page - 1) * limit).limit(limit);
32282
32686
  return {
32283
32687
  items: rows.map((row) => mapRoutineRunRow(row, routineById)),
32284
32688
  total
@@ -32294,6 +32698,20 @@ type EmbeddingModelOption {
32294
32698
  const rows = await db2("job_results").where({ type: "workflow", state: JOB_STATUS_ENUM.waiting_approval }).whereIn("workflow", [...routineById.keys()]).count("* as count");
32295
32699
  return Number(rows[0]?.count ?? 0);
32296
32700
  };
32701
+ resolvers.Mutation["setRoutineRunWorkStatus"] = async (_, args, context) => {
32702
+ const user = context.user;
32703
+ const { db: db2 } = await postgresClient();
32704
+ const routineById = await readableRoutines(db2, user);
32705
+ await setRunWorkStatusManually(db2, {
32706
+ id: args.id,
32707
+ status: args.status ?? null,
32708
+ userId: user.id,
32709
+ readableRoutineIds: [...routineById.keys()]
32710
+ });
32711
+ const updated = await db2.from("job_results").where({ id: args.id }).first();
32712
+ return mapRoutineRunRow(updated, routineById);
32713
+ };
32714
+ guardRoutineWorkStatusWrites(resolvers.Mutation);
32297
32715
  resolvers.Mutation["cancelRoutineRun"] = async (_, args, context) => {
32298
32716
  const user = context.user;
32299
32717
  const { db: db2 } = await postgresClient();
@@ -33535,12 +33953,12 @@ init_statistics2();
33535
33953
  // src/exulu/suggestions.ts
33536
33954
  init_cjs_shims();
33537
33955
  var import_ai11 = require("ai");
33538
- var import_zod22 = require("zod");
33956
+ var import_zod23 = require("zod");
33539
33957
  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.";
33540
33958
  var submitSuggestionsTool = (0, import_ai11.tool)({
33541
33959
  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.",
33542
- inputSchema: import_zod22.z.object({
33543
- suggestions: import_zod22.z.array(import_zod22.z.string()).max(3)
33960
+ inputSchema: import_zod23.z.object({
33961
+ suggestions: import_zod23.z.array(import_zod23.z.string()).max(3)
33544
33962
  })
33545
33963
  });
33546
33964
  var MAX_CHARS_PER_MESSAGE = 1e4;
@@ -33771,16 +34189,16 @@ init_view_document_page_tool();
33771
34189
  // src/templates/tools/perplexity.ts
33772
34190
  init_cjs_shims();
33773
34191
  init_tool();
33774
- var import_zod23 = __toESM(require("zod"), 1);
34192
+ var import_zod24 = __toESM(require("zod"), 1);
33775
34193
  var import_perplexity_ai = __toESM(require("@perplexity-ai/perplexity_ai"), 1);
33776
34194
  var INTERNET_SEARCH_TOOL_NAME = "Internet Search";
33777
34195
  var internetSearchTool = new ExuluTool({
33778
34196
  id: "internet_search",
33779
34197
  name: INTERNET_SEARCH_TOOL_NAME,
33780
34198
  description: "Search the internet for information.",
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.")
34199
+ inputSchema: import_zod24.default.object({
34200
+ query: import_zod24.default.string().describe("The query to the tool."),
34201
+ search_recency_filter: import_zod24.default.enum(["day", "week", "month", "year"]).optional().describe("The recency filter for the search, can be day, week, month or year.")
33784
34202
  }),
33785
34203
  category: "internet_search",
33786
34204
  type: "web_search",
@@ -34541,7 +34959,7 @@ function registerViewerIdentityRoutes(app, deps) {
34541
34959
 
34542
34960
  // ee/claim-check/routes.ts
34543
34961
  init_cjs_shims();
34544
- var import_zod24 = require("zod");
34962
+ var import_zod25 = require("zod");
34545
34963
  init_resolve_max_steps();
34546
34964
  init_public_surface();
34547
34965
  init_types2();
@@ -34605,13 +35023,13 @@ var SOURCE_TYPES = [
34605
35023
  "session_item",
34606
35024
  "other"
34607
35025
  ];
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(),
35026
+ var requestSchema = import_zod25.z.object({
35027
+ question: import_zod25.z.string().min(1),
35028
+ answer: import_zod25.z.string().min(1),
35029
+ sources: import_zod25.z.array(
35030
+ import_zod25.z.object({
35031
+ content: import_zod25.z.string(),
35032
+ name: import_zod25.z.string().optional(),
34615
35033
  // Purely informational (spec §2: no trust tiers, dropped before the
34616
35034
  // engine sees it — see assignSourceIds below), so an unrecognised
34617
35035
  // value is IGNORED, not rejected: `.catch(undefined)` keeps the enum
@@ -34623,24 +35041,24 @@ var requestSchema = import_zod24.z.object({
34623
35041
  // `.catch`) would turn that pre-existing 200 into a 400, which is a
34624
35042
  // tightening this loosening-only task must not make. Do not remove
34625
35043
  // the `.catch` to "validate properly": that is the bug this guards.
34626
- type: import_zod24.z.enum(SOURCE_TYPES).optional().catch(void 0),
34627
- id: import_zod24.z.string().min(1).optional()
35044
+ type: import_zod25.z.enum(SOURCE_TYPES).optional().catch(void 0),
35045
+ id: import_zod25.z.string().min(1).optional()
34628
35046
  })
34629
35047
  ).default([]),
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)
35048
+ agent: import_zod25.z.string().optional(),
35049
+ session: import_zod25.z.string().optional(),
35050
+ messageId: import_zod25.z.string().optional(),
35051
+ model: import_zod25.z.string().optional(),
35052
+ locale: import_zod25.z.string().refine(localeIsUsable, { message: "locale is not a usable BCP 47 language tag" }).optional(),
35053
+ options: import_zod25.z.object({
35054
+ fidelity: import_zod25.z.enum(["fast", "paper"]).optional(),
35055
+ completions: import_zod25.z.number().int().min(1).max(3).optional(),
35056
+ reRetrieve: import_zod25.z.boolean().optional(),
35057
+ thresholds: import_zod25.z.object({ warn: import_zod25.z.number().min(0).max(1), alert: import_zod25.z.number().min(0).max(1) }).partial().optional(),
35058
+ caps: import_zod25.z.object({
35059
+ maxSentences: import_zod25.z.number().int().positive(),
35060
+ maxClaims: import_zod25.z.number().int().positive(),
35061
+ maxReRetrievals: import_zod25.z.number().int().min(0)
34644
35062
  }).partial().optional()
34645
35063
  }).optional()
34646
35064
  });
@@ -35234,7 +35652,7 @@ function selectEvidence(claimTexts, index, topK = 4) {
35234
35652
 
35235
35653
  // ee/claim-check/stages/select-disambiguate.ts
35236
35654
  init_cjs_shims();
35237
- var import_zod26 = require("zod");
35655
+ var import_zod27 = require("zod");
35238
35656
  init_micro_call();
35239
35657
  init_types2();
35240
35658
 
@@ -35371,16 +35789,16 @@ resolvable=false and clarified=null for it.`;
35371
35789
 
35372
35790
  // ee/claim-check/stages/select.ts
35373
35791
  init_cjs_shims();
35374
- var import_zod25 = require("zod");
35792
+ var import_zod26 = require("zod");
35375
35793
  init_micro_call();
35376
35794
  init_types2();
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()
35795
+ var schema2 = import_zod26.z.object({
35796
+ sentences: import_zod26.z.array(
35797
+ import_zod26.z.object({
35798
+ index: import_zod26.z.number().int(),
35799
+ verifiable: import_zod26.z.boolean(),
35800
+ rewritten: import_zod26.z.string().nullable(),
35801
+ reason: import_zod26.z.string()
35384
35802
  })
35385
35803
  )
35386
35804
  });
@@ -35438,15 +35856,15 @@ async function runSelection(args) {
35438
35856
  }
35439
35857
 
35440
35858
  // ee/claim-check/stages/select-disambiguate.ts
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()
35859
+ var schema3 = import_zod27.z.object({
35860
+ sentences: import_zod27.z.array(
35861
+ import_zod27.z.object({
35862
+ index: import_zod27.z.number().int(),
35863
+ verifiable: import_zod27.z.boolean(),
35864
+ rewritten: import_zod27.z.string().nullable(),
35865
+ resolvable: import_zod27.z.boolean(),
35866
+ clarified: import_zod27.z.string().nullable(),
35867
+ reason: import_zod27.z.string()
35450
35868
  })
35451
35869
  )
35452
35870
  });
@@ -35497,16 +35915,16 @@ async function runSelectAndDisambiguate(args) {
35497
35915
 
35498
35916
  // ee/claim-check/stages/disambiguate.ts
35499
35917
  init_cjs_shims();
35500
- var import_zod27 = require("zod");
35918
+ var import_zod28 = require("zod");
35501
35919
  init_micro_call();
35502
35920
  init_types2();
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()
35921
+ var schema4 = import_zod28.z.object({
35922
+ sentences: import_zod28.z.array(
35923
+ import_zod28.z.object({
35924
+ index: import_zod28.z.number().int(),
35925
+ resolvable: import_zod28.z.boolean(),
35926
+ clarified: import_zod28.z.string().nullable(),
35927
+ reason: import_zod28.z.string()
35510
35928
  })
35511
35929
  )
35512
35930
  });
@@ -35553,7 +35971,7 @@ async function runDisambiguation(args) {
35553
35971
 
35554
35972
  // ee/claim-check/stages/decompose.ts
35555
35973
  init_cjs_shims();
35556
- var import_zod28 = require("zod");
35974
+ var import_zod29 = require("zod");
35557
35975
  init_micro_call();
35558
35976
  init_types2();
35559
35977
 
@@ -35604,11 +36022,11 @@ function decomposeUserPrompt(args) {
35604
36022
  }
35605
36023
 
35606
36024
  // ee/claim-check/stages/decompose.ts
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() }))
36025
+ var schema5 = import_zod29.z.object({
36026
+ sentences: import_zod29.z.array(
36027
+ import_zod29.z.object({
36028
+ index: import_zod29.z.number().int(),
36029
+ claims: import_zod29.z.array(import_zod29.z.object({ text: import_zod29.z.string(), inferred: import_zod29.z.boolean() }))
35612
36030
  })
35613
36031
  )
35614
36032
  });
@@ -35644,7 +36062,7 @@ async function runDecomposition(args) {
35644
36062
 
35645
36063
  // ee/claim-check/stages/verify.ts
35646
36064
  init_cjs_shims();
35647
- var import_zod29 = require("zod");
36065
+ var import_zod30 = require("zod");
35648
36066
  init_micro_call();
35649
36067
  init_types2();
35650
36068
 
@@ -35706,13 +36124,13 @@ function addUsage(a, b) {
35706
36124
  }
35707
36125
 
35708
36126
  // ee/claim-check/stages/verify.ts
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()
36127
+ var schema6 = import_zod30.z.object({
36128
+ claims: import_zod30.z.array(
36129
+ import_zod30.z.object({
36130
+ claimId: import_zod30.z.string(),
36131
+ verdict: import_zod30.z.enum(["supported", "contradicted", "unsupported"]),
36132
+ evidence: import_zod30.z.array(import_zod30.z.object({ sourceId: import_zod30.z.string(), quote: import_zod30.z.string() })),
36133
+ rationale: import_zod30.z.string()
35716
36134
  })
35717
36135
  )
35718
36136
  });
@@ -36842,27 +37260,6 @@ function checkApiKeyScope(user, agentId) {
36842
37260
  // src/exulu/routes.ts
36843
37261
  init_singleton();
36844
37262
  init_entitlements();
36845
-
36846
- // src/utils/enabled-skills.ts
36847
- init_cjs_shims();
36848
- init_client();
36849
- var getEnabledSkills = async (agent, disabledSkills = []) => {
36850
- const refs = (agent.skills?.filter(Boolean) ?? []).filter(
36851
- (skill) => !disabledSkills.includes(skill.id)
36852
- );
36853
- if (refs.length === 0) return [];
36854
- const { db: db2 } = await postgresClient();
36855
- const rows = await db2.from("skills").whereIn(
36856
- "id",
36857
- refs.map((skill) => skill.id)
36858
- );
36859
- const rowById = new Map(rows.map((row) => [row.id, row]));
36860
- console.log("[EXULU] available skills", refs.length, "resolved", rows.length);
36861
- console.log("[EXULU] disabled skills", disabledSkills?.length);
36862
- return refs.map((ref) => rowById.get(ref.id)).filter((row) => row != null);
36863
- };
36864
-
36865
- // src/exulu/routes.ts
36866
37263
  init_create_sandbox();
36867
37264
 
36868
37265
  // src/exulu/auth/callback-handler.ts
@@ -36967,13 +37364,13 @@ var handleOauthCallback = async (req, res) => {
36967
37364
 
36968
37365
  // src/exulu/auth/submit-handler.ts
36969
37366
  init_cjs_shims();
36970
- var import_zod30 = require("zod");
37367
+ var import_zod31 = require("zod");
36971
37368
  init_registry();
36972
37369
  init_credential_store();
36973
37370
  init_credentials_request();
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())
37371
+ var bodySchema = import_zod31.z.object({
37372
+ nonce: import_zod31.z.string().min(1),
37373
+ values: import_zod31.z.record(import_zod31.z.string(), import_zod31.z.string())
36977
37374
  });
36978
37375
  async function handleCredentialSubmit(req, res) {
36979
37376
  const authResult = await requestValidators.authenticate(req);
@@ -41765,7 +42162,7 @@ init_check_record_access();
41765
42162
  init_resolve_model();
41766
42163
  init_supervisor();
41767
42164
  init_client();
41768
- var import_zod31 = require("zod");
42165
+ var import_zod32 = require("zod");
41769
42166
  init_convert_exulu_tools_to_ai_sdk_tools();
41770
42167
  init_singleton();
41771
42168
  var SESSION_ID_HEADER = "mcp-session-id";
@@ -41829,7 +42226,7 @@ var ExuluMCP = class {
41829
42226
  title: tool4.name + " agent",
41830
42227
  description: tool4.description,
41831
42228
  inputSchema: {
41832
- inputs: tool4.inputSchema || import_zod31.z.object({})
42229
+ inputs: tool4.inputSchema || import_zod32.z.object({})
41833
42230
  }
41834
42231
  },
41835
42232
  async ({ inputs }, args) => {
@@ -41880,7 +42277,7 @@ var ExuluMCP = class {
41880
42277
  title: "Get List of Prompt Templates",
41881
42278
  description: "Retrieves a list of prompt templates available for this agent. Returns the name, description, and ID of each template.",
41882
42279
  inputSchema: {
41883
- inputs: import_zod31.z.object({})
42280
+ inputs: import_zod32.z.object({})
41884
42281
  }
41885
42282
  },
41886
42283
  async ({ inputs }, args) => {
@@ -41926,8 +42323,8 @@ var ExuluMCP = class {
41926
42323
  title: "Get Prompt Template Details",
41927
42324
  description: "Retrieves the full details of a specific prompt template by ID, including the actual template content with variables.",
41928
42325
  inputSchema: {
41929
- inputs: import_zod31.z.object({
41930
- id: import_zod31.z.string().describe("The ID of the prompt template to retrieve")
42326
+ inputs: import_zod32.z.object({
42327
+ id: import_zod32.z.string().describe("The ID of the prompt template to retrieve")
41931
42328
  })
41932
42329
  }
41933
42330
  },
@@ -42168,7 +42565,7 @@ var ExuluEval = class {
42168
42565
  // src/templates/evals/index.ts
42169
42566
  init_resolve_model();
42170
42567
  init_singleton();
42171
- var import_zod32 = require("zod");
42568
+ var import_zod33 = require("zod");
42172
42569
  var import_ai17 = require("ai");
42173
42570
  var llmAsJudgeEval = () => {
42174
42571
  if (process.env.REDIS_HOST?.length && process.env.REDIS_PORT?.length) {
@@ -42219,8 +42616,8 @@ var llmAsJudgeEval = () => {
42219
42616
  prompt,
42220
42617
  maxRetries: 2,
42221
42618
  output: import_ai17.Output.object({
42222
- schema: import_zod32.z.object({
42223
- score: import_zod32.z.number().min(0).max(100).describe("The score between 0 and 100.")
42619
+ schema: import_zod33.z.object({
42620
+ score: import_zod33.z.number().min(0).max(100).describe("The score between 0 and 100.")
42224
42621
  })
42225
42622
  })
42226
42623
  });
@@ -42451,15 +42848,15 @@ Usage:
42451
42848
  - If no todos exist yet, an empty list will be returned`;
42452
42849
 
42453
42850
  // src/templates/tools/todo/todo.ts
42454
- var import_zod33 = __toESM(require("zod"), 1);
42851
+ var import_zod34 = __toESM(require("zod"), 1);
42455
42852
  init_tool();
42456
42853
  init_check_record_access();
42457
42854
  init_client();
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")
42855
+ var TodoSchema = import_zod34.default.object({
42856
+ content: import_zod34.default.string().describe("Brief description of the task"),
42857
+ status: import_zod34.default.string().describe("Current status of the task: pending, in_progress, completed, cancelled"),
42858
+ priority: import_zod34.default.string().describe("Priority level of the task: high, medium, low"),
42859
+ id: import_zod34.default.string().describe("Unique identifier for the todo item")
42463
42860
  });
42464
42861
  var TodoWriteTool = new ExuluTool({
42465
42862
  id: "todo_write",
@@ -42475,8 +42872,8 @@ var TodoWriteTool = new ExuluTool({
42475
42872
  default: todowrite_default
42476
42873
  }
42477
42874
  ],
42478
- inputSchema: import_zod33.default.object({
42479
- todos: import_zod33.default.array(TodoSchema).describe("The updated todo list")
42875
+ inputSchema: import_zod34.default.object({
42876
+ todos: import_zod34.default.array(TodoSchema).describe("The updated todo list")
42480
42877
  }),
42481
42878
  execute: async (inputs) => {
42482
42879
  const { sessionID, todos, user } = inputs;
@@ -42511,7 +42908,7 @@ var TodoReadTool = new ExuluTool({
42511
42908
  id: "todo_read",
42512
42909
  name: "Todo Read",
42513
42910
  description: "Use this tool to read your todo list",
42514
- inputSchema: import_zod33.default.object({}),
42911
+ inputSchema: import_zod34.default.object({}),
42515
42912
  type: "function",
42516
42913
  category: "todo",
42517
42914
  config: [
@@ -42556,7 +42953,7 @@ init_cjs_shims();
42556
42953
  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';
42557
42954
 
42558
42955
  // src/templates/tools/question/question.ts
42559
- var import_zod35 = __toESM(require("zod"), 1);
42956
+ var import_zod36 = __toESM(require("zod"), 1);
42560
42957
  init_tool();
42561
42958
  init_client();
42562
42959
 
@@ -42648,21 +43045,21 @@ After asking a question, use the Question Read tool to check if the user has ans
42648
43045
  `;
42649
43046
 
42650
43047
  // src/templates/tools/question/question-ask.ts
42651
- var import_zod34 = __toESM(require("zod"), 1);
43048
+ var import_zod35 = __toESM(require("zod"), 1);
42652
43049
  init_tool();
42653
43050
  init_check_record_access();
42654
43051
  init_client();
42655
43052
  var import_node_crypto22 = require("crypto");
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")
43053
+ var AnswerOptionSchema = import_zod35.default.object({
43054
+ id: import_zod35.default.string().describe("Unique identifier for the answer option"),
43055
+ text: import_zod35.default.string().describe("The text of the answer option")
42659
43056
  });
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")
43057
+ var _QuestionSchema = import_zod35.default.object({
43058
+ id: import_zod35.default.string().describe("Unique identifier for the question"),
43059
+ question: import_zod35.default.string().describe("The question to ask the user"),
43060
+ answerOptions: import_zod35.default.array(AnswerOptionSchema).describe("Array of possible answer options"),
43061
+ selectedAnswerId: import_zod35.default.string().optional().describe("The ID of the answer option selected by the user"),
43062
+ status: import_zod35.default.enum(["pending", "answered"]).describe("Status of the question: pending or answered")
42666
43063
  });
42667
43064
  var QuestionAskTool = new ExuluTool({
42668
43065
  id: "question_ask",
@@ -42679,9 +43076,9 @@ var QuestionAskTool = new ExuluTool({
42679
43076
  default: questionask_default
42680
43077
  }
42681
43078
  ],
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)")
43079
+ inputSchema: import_zod35.default.object({
43080
+ question: import_zod35.default.string().describe("The question to ask the user"),
43081
+ answerOptions: import_zod35.default.array(import_zod35.default.string()).describe("Array of possible answer options (strings)")
42685
43082
  }),
42686
43083
  execute: async (inputs) => {
42687
43084
  const { sessionID, question, answerOptions, user } = inputs;
@@ -42754,7 +43151,7 @@ var QuestionReadTool = new ExuluTool({
42754
43151
  name: "Question Read",
42755
43152
  needsApproval: false,
42756
43153
  description: "Use this tool to read questions and their answers",
42757
- inputSchema: import_zod35.default.object({}),
43154
+ inputSchema: import_zod36.default.object({}),
42758
43155
  type: "function",
42759
43156
  category: "question",
42760
43157
  config: [
@@ -42787,7 +43184,7 @@ var questionTools = [QuestionAskTool, QuestionReadTool];
42787
43184
  init_cjs_shims();
42788
43185
  init_tool();
42789
43186
  var nodemailer = __toESM(require("nodemailer"), 1);
42790
- var import_zod36 = require("zod");
43187
+ var import_zod37 = require("zod");
42791
43188
  var transporter = null;
42792
43189
  function getTransporter(config) {
42793
43190
  if (!transporter) {
@@ -42811,11 +43208,11 @@ var emailTool = new ExuluTool({
42811
43208
  id: "email",
42812
43209
  name: "Email",
42813
43210
  description: "Send an email.",
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.")
43211
+ inputSchema: import_zod37.z.object({
43212
+ recipient: import_zod37.z.string().describe("The recipient of the email."),
43213
+ subject: import_zod37.z.string().describe("The subject of the email."),
43214
+ html: import_zod37.z.string().describe("The HTML body of the email."),
43215
+ text: import_zod37.z.string().describe("The text body of the email.")
42819
43216
  }),
42820
43217
  type: "function",
42821
43218
  config: [{
@@ -42887,7 +43284,7 @@ init_supervisor();
42887
43284
  init_client();
42888
43285
  init_rbac_resolver();
42889
43286
  init_check_record_access();
42890
- var import_zod37 = require("zod");
43287
+ var import_zod38 = require("zod");
42891
43288
  var _cachedImageModels;
42892
43289
  var setCachedImageModels = (models2) => {
42893
43290
  _cachedImageModels = models2;
@@ -42948,8 +43345,8 @@ var createImageGenerationWidgetTool = (models2) => {
42948
43345
  needsApproval: false,
42949
43346
  type: "function",
42950
43347
  config: [],
42951
- inputSchema: import_zod37.z.object({
42952
- prompt: import_zod37.z.string().describe(
43348
+ inputSchema: import_zod38.z.object({
43349
+ prompt: import_zod38.z.string().describe(
42953
43350
  "Initial image prompt. The user can edit it before generating."
42954
43351
  )
42955
43352
  }),
@@ -44780,6 +45177,10 @@ var up = async function(knex) {
44780
45177
  `CREATE INDEX IF NOT EXISTS job_results_workflow_state_trigger_created_idx
44781
45178
  ON job_results (workflow, state, trigger, "createdAt")`
44782
45179
  );
45180
+ await knex.raw(
45181
+ `CREATE INDEX IF NOT EXISTS job_results_workflow_work_status_created_idx
45182
+ ON job_results (workflow, work_status, "createdAt")`
45183
+ );
44783
45184
  await knex.raw(
44784
45185
  `CREATE INDEX IF NOT EXISTS job_results_session_waiting_idx
44785
45186
  ON job_results (session) WHERE state = 'waiting_approval'`
@@ -46126,12 +46527,12 @@ async function fitContextProjection({
46126
46527
  const basis = randomizedPCA(vectors, dims, Math.min(budget, dims, vectors.length - 1), seed, POWER_ITERATIONS);
46127
46528
  if (basis.length === 0) return empty(`${contextId} has no variance in its embeddings`);
46128
46529
  const reduced = vectors.map((v) => projectComponents(v, mean, basis));
46129
- const spread = reduced.reduce((s, z38) => s + Math.hypot(...Array.from(z38)), 0) / reduced.length;
46530
+ const spread = reduced.reduce((s, z39) => s + Math.hypot(...Array.from(z39)), 0) / reduced.length;
46130
46531
  if (!Number.isFinite(spread) || spread < 1e-8) return empty(`${contextId} has no variance in its embeddings`);
46131
46532
  log7(`fitting ${contextId}: ${vectors.length} vectors, ${dims} dims \u2192 ${basis.length} components`);
46132
46533
  log7(`${contextId}: laying out ${reduced.length} points in 3d (the slow phase)`);
46133
46534
  const umap = (umapFactory ?? defaultUmap)(seed, reduced.length);
46134
- const raw = umap.fit(reduced.map((z38) => Array.from(z38)));
46535
+ const raw = umap.fit(reduced.map((z39) => Array.from(z39)));
46135
46536
  const oriented = rotateLayout(raw, principalRotation(raw, seed));
46136
46537
  const { points: layout, scale } = normalizeLayout(oriented);
46137
46538
  if (!Number.isFinite(scale) || scale <= 0) return empty(`${contextId} produced a degenerate layout (every point in one place)`);
@@ -46216,13 +46617,13 @@ async function backfillCoordinates({
46216
46617
  const raw = parseVector(row.embedding);
46217
46618
  if (raw.length !== projection.dims) continue;
46218
46619
  const known = layout?.get(String(row.id));
46219
- const [x, y, z38] = known ?? applyMap(
46620
+ const [x, y, z39] = known ?? applyMap(
46220
46621
  projectComponents(l2normalize(raw), mean, basis),
46221
46622
  projection.map,
46222
46623
  projection.intercept
46223
46624
  );
46224
46625
  values.push("(?::uuid, ?::real, ?::real, ?::real)");
46225
- bindings.push(row.id, x, y, z38);
46626
+ bindings.push(row.id, x, y, z39);
46226
46627
  }
46227
46628
  if (values.length) {
46228
46629
  await db2.raw(