@claritylabs/cl-sdk 3.1.21 → 3.1.22
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/README.md +2 -2
- package/dist/application.js +2 -2
- package/dist/application.js.map +1 -1
- package/dist/application.mjs +2 -2
- package/dist/application.mjs.map +1 -1
- package/dist/index.js +21 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +21 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -619,8 +619,8 @@ function resolveModelBudget(params) {
|
|
|
619
619
|
const schemaTokens = estimateTokens(params.schemaSizeBytes) ?? 0;
|
|
620
620
|
const expectedListLength = positiveInteger(params.expectedListLength) ?? 0;
|
|
621
621
|
const warnings = [];
|
|
622
|
-
const preferredOutputTokens = constrainedPreference ?? taskCapability ?? longListCapability ??
|
|
623
|
-
let maxTokens =
|
|
622
|
+
const preferredOutputTokens = constrainedPreference ?? taskCapability ?? longListCapability ?? hintTokens ?? defaultCapability;
|
|
623
|
+
let maxTokens = preferredOutputTokens;
|
|
624
624
|
if (minOutputTokens) {
|
|
625
625
|
maxTokens = Math.max(maxTokens, minOutputTokens);
|
|
626
626
|
}
|
|
@@ -9756,9 +9756,9 @@ var ORGANIZABLE_KINDS = [
|
|
|
9756
9756
|
"schedule",
|
|
9757
9757
|
"clause"
|
|
9758
9758
|
];
|
|
9759
|
-
var ORGANIZATION_TOP_LEVEL_BATCH_SIZE =
|
|
9759
|
+
var ORGANIZATION_TOP_LEVEL_BATCH_SIZE = 4;
|
|
9760
9760
|
var ORGANIZER_MAX_TOP_LEVEL_NODES = 120;
|
|
9761
|
-
var ORGANIZER_MAX_BATCH_NODES =
|
|
9761
|
+
var ORGANIZER_MAX_BATCH_NODES = 80;
|
|
9762
9762
|
var OUTLINE_CLEANUP_MAX_TOP_LEVEL_NODES = 80;
|
|
9763
9763
|
var SourceTreeOrganizationSchema = import_zod42.z.object({
|
|
9764
9764
|
labels: import_zod42.z.array(import_zod42.z.object({
|
|
@@ -10944,10 +10944,10 @@ function organizationCandidateText(node) {
|
|
|
10944
10944
|
}
|
|
10945
10945
|
function isHighSignalOrganizationNode(node) {
|
|
10946
10946
|
if (node.kind === "document") return false;
|
|
10947
|
-
if (["page", "page_group", "form", "endorsement", "section", "schedule", "clause", "table"
|
|
10947
|
+
if (["page", "page_group", "form", "endorsement", "section", "schedule", "clause", "table"].includes(node.kind)) {
|
|
10948
10948
|
return true;
|
|
10949
10949
|
}
|
|
10950
|
-
if (node.kind !== "text" && node.kind !== "table_cell") return false;
|
|
10950
|
+
if (node.kind !== "text" && node.kind !== "table_cell" && node.kind !== "table_row") return false;
|
|
10951
10951
|
const text = organizationCandidateText(node);
|
|
10952
10952
|
return /\b(SECTION|PART|ARTICLE|SCHEDULE)\s+[IVXLCDM0-9]+/i.test(text) || /\bItem\s+\d+[\.:]/i.test(text) || /^[A-Z]\.\s+\S/.test(cleanText(node.textExcerpt ?? node.title, "")) || /\b(forms? and endorsements?|coverage parts?|limits? of liability|extended reporting period|producer|premium|aggregate|retroactive date|endorsement no\.?)\b/i.test(text);
|
|
10953
10953
|
}
|
|
@@ -10970,7 +10970,7 @@ function organizationBatches(sourceTree) {
|
|
|
10970
10970
|
const rootId = sourceTreeRootId(sourceTree);
|
|
10971
10971
|
const topLevelNodes = (byParent.get(rootId) ?? []).filter((node) => node.kind !== "document");
|
|
10972
10972
|
if (topLevelNodes.length === 0) {
|
|
10973
|
-
const nodes = sourceTree.filter((node) => node.kind !== "document").slice(0,
|
|
10973
|
+
const nodes = sourceTree.filter((node) => node.kind !== "document").slice(0, ORGANIZER_MAX_BATCH_NODES);
|
|
10974
10974
|
return [{
|
|
10975
10975
|
label: "fallback node prefix because no document root children were found",
|
|
10976
10976
|
topLevelNodeIds: nodes.map((node) => node.id),
|
|
@@ -10988,6 +10988,17 @@ function organizationBatches(sourceTree) {
|
|
|
10988
10988
|
}
|
|
10989
10989
|
return batches;
|
|
10990
10990
|
}
|
|
10991
|
+
function pageRangeOverlaps(leftStart, leftEnd, rightStart, rightEnd) {
|
|
10992
|
+
if (leftStart === void 0 || rightStart === void 0) return true;
|
|
10993
|
+
const leftLast = leftEnd ?? leftStart;
|
|
10994
|
+
const rightLast = rightEnd ?? rightStart;
|
|
10995
|
+
return leftStart <= rightLast && rightStart <= leftLast;
|
|
10996
|
+
}
|
|
10997
|
+
function formHintsForBatch(batch, formHints) {
|
|
10998
|
+
const batchStart = batch.nodes.map((node) => node.pageStart).filter((page) => typeof page === "number").reduce((min, page) => min === void 0 ? page : Math.min(min, page), void 0);
|
|
10999
|
+
const batchEnd = batch.nodes.map((node) => node.pageEnd ?? node.pageStart).filter((page) => typeof page === "number").reduce((max, page) => max === void 0 ? page : Math.max(max, page), void 0);
|
|
11000
|
+
return formHints.filter((form) => pageRangeOverlaps(batchStart, batchEnd, form.pageStart, form.pageEnd)).slice(0, 24);
|
|
11001
|
+
}
|
|
10991
11002
|
function mergeOrganizationResults(results) {
|
|
10992
11003
|
const labels = /* @__PURE__ */ new Map();
|
|
10993
11004
|
const groups = /* @__PURE__ */ new Map();
|
|
@@ -11006,7 +11017,8 @@ function mergeOrganizationResults(results) {
|
|
|
11006
11017
|
};
|
|
11007
11018
|
}
|
|
11008
11019
|
function buildOrganizationPrompt(batch, formHints) {
|
|
11009
|
-
const nodes = batch.nodes.map((node) => compactNode2(node, node.kind === "page" ?
|
|
11020
|
+
const nodes = batch.nodes.map((node) => compactNode2(node, node.kind === "page" ? 520 : 260));
|
|
11021
|
+
const localFormHints = formHintsForBatch(batch, formHints);
|
|
11010
11022
|
return `You organize an insurance document source tree.
|
|
11011
11023
|
|
|
11012
11024
|
Scope:
|
|
@@ -11015,7 +11027,7 @@ Scope:
|
|
|
11015
11027
|
- Top-level page/form candidates in this batch: ${JSON.stringify(batch.topLevelNodeIds)}
|
|
11016
11028
|
|
|
11017
11029
|
Expected form inventory / page ranges:
|
|
11018
|
-
${formatFormHintsForPrompt(
|
|
11030
|
+
${formatFormHintsForPrompt(localFormHints)}
|
|
11019
11031
|
|
|
11020
11032
|
Rules:
|
|
11021
11033
|
- Use only node IDs from the provided list.
|