@tangle-network/agent-app 0.44.11 → 0.44.13
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/assistant/index.d.ts +4 -4
- package/dist/assistant/index.js +6 -6
- package/dist/{attachment-validation-yJ6Id4pR.d.ts → attachment-validation-Zw8eslhN.d.ts} +1 -1
- package/dist/chat-routes/index.d.ts +4 -4
- package/dist/chat-routes/index.js +3 -3
- package/dist/chat-store/index.d.ts +3 -3
- package/dist/chat-store/index.js +2 -2
- package/dist/{chunk-J6TNPRQN.js → chunk-7SMPAAIT.js} +4 -4
- package/dist/{chunk-FEUW4G2L.js → chunk-DV2FA2PW.js} +2 -2
- package/dist/{chunk-ZRSUCTST.js → chunk-GEYACSFW.js} +2 -2
- package/dist/{chunk-5GA3MKOC.js → chunk-VM6VLJH6.js} +2 -2
- package/dist/{chunk-72TPRENZ.js → chunk-YTMKRL3L.js} +3 -3
- package/dist/{chunk-V3HO43PG.js → chunk-ZVEEWGDK.js} +14 -1
- package/dist/chunk-ZVEEWGDK.js.map +1 -0
- package/dist/{parts-DIKcC1p6.d.ts → parts-S1OINlRP.d.ts} +1 -1
- package/dist/{queue-DBkulxW1.d.ts → queue-vRI0Qx3X.d.ts} +1 -1
- package/dist/turn-health/index.d.ts +52 -4
- package/dist/turn-health/index.js +50 -6
- package/dist/turn-health/index.js.map +1 -1
- package/dist/{types-DeEOhQbv.d.ts → types-DB82fktc.d.ts} +12 -2
- package/dist/web-react/index.d.ts +6 -6
- package/dist/web-react/index.js +6 -6
- package/dist/work-product/index.d.ts +51 -4
- package/dist/work-product/index.js +93 -6
- package/dist/work-product/index.js.map +1 -1
- package/dist/work-product-react/index.d.ts +1 -1
- package/dist/work-product-react/index.js +3 -3
- package/package.json +1 -1
- package/dist/chunk-V3HO43PG.js.map +0 -1
- /package/dist/{chunk-J6TNPRQN.js.map → chunk-7SMPAAIT.js.map} +0 -0
- /package/dist/{chunk-FEUW4G2L.js.map → chunk-DV2FA2PW.js.map} +0 -0
- /package/dist/{chunk-ZRSUCTST.js.map → chunk-GEYACSFW.js.map} +0 -0
- /package/dist/{chunk-5GA3MKOC.js.map → chunk-VM6VLJH6.js.map} +0 -0
- /package/dist/{chunk-72TPRENZ.js.map → chunk-YTMKRL3L.js.map} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
parseReviewQueueItem,
|
|
3
3
|
projectReviewQueue
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-GEYACSFW.js";
|
|
5
5
|
import {
|
|
6
6
|
isWorkProductStatus,
|
|
7
7
|
parseAgentCheckInput,
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
persistedPartToWorkProduct,
|
|
12
12
|
unresolvedBlockingExceptions,
|
|
13
13
|
workProductToPersistedPart
|
|
14
|
-
} from "../chunk-
|
|
14
|
+
} from "../chunk-ZVEEWGDK.js";
|
|
15
15
|
import {
|
|
16
16
|
ToolInputError,
|
|
17
17
|
defineAppTool
|
|
@@ -403,6 +403,45 @@ function sourceContainsQuote(sourceText, quote) {
|
|
|
403
403
|
if (normalizedQuote.length === 0) return false;
|
|
404
404
|
return normalizeQuoteText(sourceText).includes(normalizedQuote);
|
|
405
405
|
}
|
|
406
|
+
function lineAround(text, index) {
|
|
407
|
+
let start = text.lastIndexOf("\n", index);
|
|
408
|
+
start = start < 0 ? 0 : start + 1;
|
|
409
|
+
let end = text.indexOf("\n", index);
|
|
410
|
+
if (end < 0) end = text.length;
|
|
411
|
+
if (end > start && text[end - 1] === "\r") end -= 1;
|
|
412
|
+
return { start, end };
|
|
413
|
+
}
|
|
414
|
+
function findSourceLine(sourceText, needle, occurrence = 1) {
|
|
415
|
+
const trimmed = needle.trim();
|
|
416
|
+
if (trimmed.length === 0) return { ok: false, failure: { reason: "blank_needle" } };
|
|
417
|
+
const positions = [];
|
|
418
|
+
for (let at = sourceText.indexOf(trimmed); at >= 0; at = sourceText.indexOf(trimmed, at + 1)) {
|
|
419
|
+
positions.push(at);
|
|
420
|
+
}
|
|
421
|
+
if (positions.length === 0) {
|
|
422
|
+
const wanted = normalizeQuoteText(trimmed);
|
|
423
|
+
if (wanted.length > 0) {
|
|
424
|
+
let cursor = 0;
|
|
425
|
+
while (cursor <= sourceText.length) {
|
|
426
|
+
const bound2 = lineAround(sourceText, cursor);
|
|
427
|
+
const line = sourceText.slice(bound2.start, bound2.end);
|
|
428
|
+
if (normalizeQuoteText(line).includes(wanted) || normalizeQuoteText(line.replace(/,/gu, "")).includes(wanted)) {
|
|
429
|
+
positions.push(bound2.start);
|
|
430
|
+
}
|
|
431
|
+
if (bound2.end >= sourceText.length) break;
|
|
432
|
+
cursor = bound2.end + 1;
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
if (positions.length === 0) return { ok: false, failure: { reason: "not_found" } };
|
|
437
|
+
if (occurrence < 1 || occurrence > positions.length) {
|
|
438
|
+
return { ok: false, failure: { reason: "occurrence_out_of_range", found: positions.length } };
|
|
439
|
+
}
|
|
440
|
+
const bound = lineAround(sourceText, positions[occurrence - 1]);
|
|
441
|
+
const quote = sourceText.slice(bound.start, bound.end);
|
|
442
|
+
if (quote.trim().length === 0) return { ok: false, failure: { reason: "not_found" } };
|
|
443
|
+
return { ok: true, span: bound, quote, occurrences: positions.length };
|
|
444
|
+
}
|
|
406
445
|
function sliceSourceSpan(sourceText, span) {
|
|
407
446
|
for (const field of ["start", "end"]) {
|
|
408
447
|
const value = span[field];
|
|
@@ -480,6 +519,16 @@ function spanErrorDetail(failure) {
|
|
|
480
519
|
return "that range is only whitespace. Widen it to the characters that carry the value.";
|
|
481
520
|
}
|
|
482
521
|
}
|
|
522
|
+
function findErrorDetail(failure, needle) {
|
|
523
|
+
switch (failure.reason) {
|
|
524
|
+
case "blank_needle":
|
|
525
|
+
return "the value to locate is empty.";
|
|
526
|
+
case "not_found":
|
|
527
|
+
return `${JSON.stringify(needle)} does not occur in that document. Read it again and cite a value it actually contains, or \u2014 if this figure is COMPUTED rather than read \u2014 omit the locator and state the computation in claim.`;
|
|
528
|
+
case "occurrence_out_of_range":
|
|
529
|
+
return `that value occurs ${failure.found} time(s) in the document; findOccurrence is out of range.`;
|
|
530
|
+
}
|
|
531
|
+
}
|
|
483
532
|
async function resolveEvidenceQuotes(config, entries, ctx) {
|
|
484
533
|
const readSourceText = config.readSourceText;
|
|
485
534
|
const texts = /* @__PURE__ */ new Map();
|
|
@@ -489,8 +538,36 @@ async function resolveEvidenceQuotes(config, entries, ctx) {
|
|
|
489
538
|
};
|
|
490
539
|
for (let index = 0; index < entries.length; index += 1) {
|
|
491
540
|
const entry = entries[index];
|
|
541
|
+
const find = entry.locator.find;
|
|
492
542
|
const span = entry.locator.span;
|
|
493
543
|
const quote = entry.locator.quote;
|
|
544
|
+
if (find !== void 0) {
|
|
545
|
+
if (!readSourceText) {
|
|
546
|
+
throw new ToolInputError(
|
|
547
|
+
"span_unsupported",
|
|
548
|
+
`entries[${index}].locator.find: this deployment cannot read source text, so a value cannot be located. Record the entry without locator.find.`,
|
|
549
|
+
500
|
|
550
|
+
);
|
|
551
|
+
}
|
|
552
|
+
const text2 = await readText(entry.sourceRef);
|
|
553
|
+
if (text2 === null) {
|
|
554
|
+
throw new ToolInputError(
|
|
555
|
+
"unverifiable_quote",
|
|
556
|
+
`entries[${index}].locator.find: "${entry.sourceRef}" has no readable text, so the value cannot be located. Record the entry without a locator and state the basis in claim.`
|
|
557
|
+
);
|
|
558
|
+
}
|
|
559
|
+
const located = findSourceLine(text2, find, entry.locator.findOccurrence ?? 1);
|
|
560
|
+
if (!located.ok) {
|
|
561
|
+
throw new ToolInputError(
|
|
562
|
+
"value_not_found",
|
|
563
|
+
`entries[${index}].locator.find into "${entry.sourceRef}": ${findErrorDetail(located.failure, find)}`
|
|
564
|
+
);
|
|
565
|
+
}
|
|
566
|
+
entry.locator.span = located.span;
|
|
567
|
+
entry.locator.quote = located.quote;
|
|
568
|
+
entry.locator.quoteBasis = "span";
|
|
569
|
+
continue;
|
|
570
|
+
}
|
|
494
571
|
if (span) {
|
|
495
572
|
if (!readSourceText) {
|
|
496
573
|
throw new ToolInputError(
|
|
@@ -529,7 +606,7 @@ async function resolveEvidenceQuotes(config, entries, ctx) {
|
|
|
529
606
|
if (!sourceContainsQuote(text, quote)) {
|
|
530
607
|
throw new ToolInputError(
|
|
531
608
|
"quote_not_found",
|
|
532
|
-
`entries[${index}].locator.quote: ${JSON.stringify(quote)} does not occur in "${entry.sourceRef}". Cite locator.
|
|
609
|
+
`entries[${index}].locator.quote: ${JSON.stringify(quote)} does not occur in "${entry.sourceRef}". Cite locator.find instead \u2014 the value as it appears in the document \u2014 and this platform locates it and writes the quote itself, so the text is right by construction. If the value is COMPUTED rather than read, omit both and state the computation in claim.`
|
|
533
610
|
);
|
|
534
611
|
}
|
|
535
612
|
entry.locator.quoteBasis = "model";
|
|
@@ -577,7 +654,7 @@ function buildWorkProductTools(config) {
|
|
|
577
654
|
});
|
|
578
655
|
const upsertEvidence = defineAppTool({
|
|
579
656
|
name: "upsert_evidence",
|
|
580
|
-
description: "Record source\u2192field lineage for the current work product, incrementally as you find it. Each entry links a source document (sourceRef + locator) to one artifact target and states the claim it supports. Cite by locator.
|
|
657
|
+
description: "Record source\u2192field lineage for the current work product, incrementally as you find it. Each entry links a source document (sourceRef + locator) to one artifact target and states the claim it supports. Cite by locator.find \u2014 the value exactly as it appears in the document \u2014 and the platform locates it and writes the supporting quote for you. Re-emitting an entry id replaces that entry. Address the work product by scopeKey; the first call creates the draft.",
|
|
581
658
|
parameters: {
|
|
582
659
|
type: "object",
|
|
583
660
|
properties: {
|
|
@@ -596,9 +673,18 @@ function buildWorkProductTools(config) {
|
|
|
596
673
|
properties: {
|
|
597
674
|
page: { type: "number" },
|
|
598
675
|
range: { type: "string", description: "Free-form location: 'L120-L134' | 'B7' | '\xB64'." },
|
|
676
|
+
find: {
|
|
677
|
+
type: "string",
|
|
678
|
+
description: 'PREFERRED \u2014 use this whenever the value was READ from a document. The value exactly as it appears in the source (for example "128,450.00"), or a short distinctive phrase from the supporting line. The platform LOCATES it, cites the whole line it sits on, and returns that line to you. You do not retype the quote and you do not compute character offsets \u2014 so the citation can neither be invented nor land on the wrong line. If the value is not in the document, the entry is refused.'
|
|
679
|
+
},
|
|
680
|
+
findOccurrence: {
|
|
681
|
+
type: "integer",
|
|
682
|
+
minimum: 1,
|
|
683
|
+
description: "Which occurrence of `find` to cite when the value appears more than once. Defaults to the first."
|
|
684
|
+
},
|
|
599
685
|
span: {
|
|
600
686
|
type: "object",
|
|
601
|
-
description: "
|
|
687
|
+
description: "Only when you have exact character offsets from a tool that computed them. Absolute offsets into the whole document: start is the first character, end is one past the last. Prefer `find` \u2014 offsets computed by hand land on the wrong line.",
|
|
602
688
|
properties: {
|
|
603
689
|
start: { type: "integer", minimum: 0 },
|
|
604
690
|
end: { type: "integer", minimum: 1 }
|
|
@@ -832,7 +918,7 @@ function buildWorkProductTools(config) {
|
|
|
832
918
|
await unwrap(() => service.recordChecks(draft.id, checks), "checks_rejected");
|
|
833
919
|
throw new ToolInputError(
|
|
834
920
|
"evidence_not_anchored",
|
|
835
|
-
`Cannot submit: these material targets have an evidence row but no source anchor: ${unanchored.join(", ")}. Re-emit each with locator.
|
|
921
|
+
`Cannot submit: these material targets have an evidence row but no source anchor: ${unanchored.join(", ")}. Re-emit each with locator.find \u2014 the value exactly as it appears in the document. The platform locates it and writes the quote itself, so you never retype source text or count characters.`
|
|
836
922
|
);
|
|
837
923
|
}
|
|
838
924
|
}
|
|
@@ -954,6 +1040,7 @@ export {
|
|
|
954
1040
|
createWorkProductRoutes,
|
|
955
1041
|
createWorkProductService,
|
|
956
1042
|
finalizeWorkProductProvenance,
|
|
1043
|
+
findSourceLine,
|
|
957
1044
|
isWorkProductStatus,
|
|
958
1045
|
isWorkProductTerminal,
|
|
959
1046
|
normalizeQuoteText,
|