@linghun/tui 0.1.2 → 0.1.3
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/background-control-runtime.js +31 -31
- package/dist/capability-runtime.js +19 -19
- package/dist/{chunk-AGI6GFFL.js → chunk-5OZEJQBH.js} +1 -1
- package/dist/{chunk-42ZZUF7P.js → chunk-6C32YAB5.js} +17 -5
- package/dist/{chunk-PPUOHBAK.js → chunk-6JPUBF7B.js} +11 -11
- package/dist/{chunk-CJRJR7TP.js → chunk-7XAOTGHZ.js} +2 -2
- package/dist/{chunk-YLOJWSHB.js → chunk-BEDD7OFL.js} +2 -2
- package/dist/{chunk-HPQ2IHOW.js → chunk-CQCJGMXG.js} +3 -3
- package/dist/{chunk-NK4NMYF5.js → chunk-DEIYY6NI.js} +276 -10
- package/dist/{chunk-5IFNLTOF.js → chunk-EGHM55EV.js} +2 -2
- package/dist/{chunk-EKYXI6C7.js → chunk-ESAACKVG.js} +1 -1
- package/dist/{chunk-YMEMN5FG.js → chunk-G7O26P5X.js} +1 -1
- package/dist/{chunk-FGGY5KNM.js → chunk-GYHEUVR2.js} +2 -2
- package/dist/{chunk-HZ5XNKWS.js → chunk-HMGYFENJ.js} +1 -1
- package/dist/{chunk-ZJDPYOTK.js → chunk-IQS34W5A.js} +2 -2
- package/dist/{chunk-7BHMBWG2.js → chunk-J7AAPUTV.js} +1 -1
- package/dist/{chunk-YDTJ7UBG.js → chunk-JMUAQUQQ.js} +1 -1
- package/dist/{chunk-NL4M3V5D.js → chunk-KKZBBCHK.js} +1 -1
- package/dist/{chunk-UIKN3CDF.js → chunk-NMOVU75L.js} +1 -1
- package/dist/{chunk-YKOXJQGX.js → chunk-NWZ44SFI.js} +78 -3
- package/dist/{chunk-HPIHFENG.js → chunk-OH35XDD4.js} +1 -1
- package/dist/{chunk-WXTHKLNH.js → chunk-OI5TZ37D.js} +27 -0
- package/dist/{chunk-DIDRFIIW.js → chunk-OMWSM2DA.js} +1 -1
- package/dist/{chunk-X7E34LKV.js → chunk-OV5OT66G.js} +5 -5
- package/dist/{chunk-HGCTHBUY.js → chunk-PHPEPZAA.js} +1 -1
- package/dist/{chunk-ZF36LULR.js → chunk-Q57WS7YZ.js} +2 -2
- package/dist/{chunk-3PG7I3LA.js → chunk-QXV2N4F2.js} +1 -1
- package/dist/{chunk-7R4YXN7Z.js → chunk-RDTVAQBD.js} +86 -61
- package/dist/{chunk-LBC75QAB.js → chunk-TO6IN4LA.js} +201 -5
- package/dist/{chunk-O2U4XQVM.js → chunk-UYU4QN3P.js} +1 -1
- package/dist/{chunk-J6CYFWSW.js → chunk-VDQTNA4W.js} +20 -1
- package/dist/{chunk-3MRYQO7X.js → chunk-XYY5LRSF.js} +3 -3
- package/dist/{chunk-OSFBVVEP.js → chunk-YBTXLLO5.js} +1 -1
- package/dist/{chunk-JY3LI63F.js → chunk-YGXPS5F2.js} +1 -1
- package/dist/{chunk-4UER2AKI.js → chunk-ZPFOP557.js} +190 -0
- package/dist/command-panel-runtime.js +18 -18
- package/dist/compact-cache-command-runtime.js +31 -31
- package/dist/compact-preflight-runtime.js +7 -7
- package/dist/connector-runtime.js +20 -20
- package/dist/details-status-runtime.js +18 -18
- package/dist/evidence-runtime.d.ts.map +1 -1
- package/dist/evidence-runtime.js +3 -2
- package/dist/extension-command-runtime.js +3 -3
- package/dist/extension-slash-runtime.js +19 -19
- package/dist/failure-learning-command-runtime.js +19 -19
- package/dist/final-answer-gate.d.ts +1 -0
- package/dist/final-answer-gate.d.ts.map +1 -1
- package/dist/final-answer-gate.js +4 -2
- package/dist/git-command-runtime.js +19 -19
- package/dist/headless-bench-runtime.d.ts +19 -1
- package/dist/headless-bench-runtime.d.ts.map +1 -1
- package/dist/headless-bench-runtime.js +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +108 -40
- package/dist/job-agent-command-runtime.js +18 -18
- package/dist/job-runtime.js +4 -4
- package/dist/mcp-index-command-runtime.js +3 -3
- package/dist/mcp-index-runtime.js +21 -21
- package/dist/mcp-stdio-runtime.js +2 -2
- package/dist/memory-command-runtime.js +19 -19
- package/dist/meta-scheduler-runtime.js +2 -2
- package/dist/model-command-runtime.js +19 -19
- package/dist/model-loop-runtime.d.ts.map +1 -1
- package/dist/model-loop-runtime.js +1 -1
- package/dist/model-prompt-runtime.js +4 -4
- package/dist/model-stream-runtime.d.ts.map +1 -1
- package/dist/model-stream-runtime.js +31 -31
- package/dist/model-tool-runtime.d.ts.map +1 -1
- package/dist/model-tool-runtime.js +31 -31
- package/dist/permission-approval-runtime.js +31 -31
- package/dist/permission-continuation-runtime.d.ts.map +1 -1
- package/dist/permission-continuation-runtime.js +2 -2
- package/dist/process-command-runtime.js +2 -2
- package/dist/process-guard.d.ts +3 -0
- package/dist/process-guard.d.ts.map +1 -1
- package/dist/process-guard.js +5 -1
- package/dist/remote-command-runtime.js +19 -19
- package/dist/runner-runtime.js +3 -3
- package/dist/shell/view-model.js +5 -5
- package/dist/slash-command-runtime.js +31 -31
- package/dist/tool-output-presenter.d.ts +1 -0
- package/dist/tool-output-presenter.d.ts.map +1 -1
- package/dist/tool-output-presenter.js +3 -1
- package/dist/tui-agent-job-runtime.js +5 -5
- package/dist/tui-context-runtime.d.ts +2 -0
- package/dist/tui-context-runtime.d.ts.map +1 -1
- package/dist/tui-data-types.d.ts +1 -0
- package/dist/tui-data-types.d.ts.map +1 -1
- package/dist/tui-details-runtime.js +5 -5
- package/dist/tui-output-surface.js +6 -6
- package/dist/tui-permission-runtime.js +3 -3
- package/dist/verification-command-runtime.js +6 -6
- package/dist/workflow-command-runtime.js +18 -18
- package/package.json +5 -5
|
@@ -6,6 +6,9 @@ import {
|
|
|
6
6
|
formatToolResultBudgetEvidenceSummary,
|
|
7
7
|
formatToolResultBudgetSystemEvent
|
|
8
8
|
} from "./chunk-O7S3HYE6.js";
|
|
9
|
+
import {
|
|
10
|
+
formatToolDiagnosticsSummary
|
|
11
|
+
} from "./chunk-OI5TZ37D.js";
|
|
9
12
|
import {
|
|
10
13
|
LINGHUN_DEFAULT_TOOL_RESULT_CHARS,
|
|
11
14
|
LINGHUN_MAX_TOOL_RESULT_BYTES
|
|
@@ -15,7 +18,7 @@ import {
|
|
|
15
18
|
} from "./chunk-7ZMDQZ22.js";
|
|
16
19
|
import {
|
|
17
20
|
deriveToolSupportsClaims
|
|
18
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-NWZ44SFI.js";
|
|
19
22
|
import {
|
|
20
23
|
mergeFailureRecord,
|
|
21
24
|
writeFailureRecord
|
|
@@ -37,6 +40,7 @@ var TRANSCRIPT_TOOL_OUTPUT_MAX_CHARS = 8e3;
|
|
|
37
40
|
var MAX_ROUND_ASSISTANT_CHARS_FOR_PROVIDER = 16e3;
|
|
38
41
|
var ROUND_ASSISTANT_HEAD_CHARS = 4e3;
|
|
39
42
|
var ROUND_ASSISTANT_TAIL_CHARS = 4e3;
|
|
43
|
+
var RECENT_DIAGNOSTICS_LIMIT = 20;
|
|
40
44
|
function createEvidenceRecord(kind, summary, source, supportsClaims) {
|
|
41
45
|
return {
|
|
42
46
|
id: randomUUID(),
|
|
@@ -220,15 +224,20 @@ async function recordToolEvidence(context, sessionId, name, output, input) {
|
|
|
220
224
|
return null;
|
|
221
225
|
}
|
|
222
226
|
const readOnlyEvidence = name === "Read" || name === "ReadSnippets" || name === "SourcePack" || name === "Grep" || name === "Glob";
|
|
227
|
+
const supportsClaims = [
|
|
228
|
+
...deriveToolSupportsClaims(name, input, output),
|
|
229
|
+
...readOnlyEvidence ? ["readonly_low_noise_evidence"] : []
|
|
230
|
+
];
|
|
223
231
|
const evidence = createEvidenceRecord(
|
|
224
232
|
kind,
|
|
225
233
|
readOnlyEvidence ? formatReadOnlyToolEvidenceSummary(name, output, input) : `${name}: ${truncateDisplay(output.text.replace(/\s+/g, " "), 120)}`,
|
|
226
234
|
output.fullOutputPath ?? name,
|
|
227
|
-
|
|
228
|
-
...deriveToolSupportsClaims(name, input, output),
|
|
229
|
-
...readOnlyEvidence ? ["readonly_low_noise_evidence"] : []
|
|
230
|
-
]
|
|
235
|
+
supportsClaims
|
|
231
236
|
);
|
|
237
|
+
const semanticProbe = supportsClaims.includes("bash_exit_0") ? compactSemanticProbeEvidence(context, output, input) : void 0;
|
|
238
|
+
if (semanticProbe) {
|
|
239
|
+
evidence.data = { ...typeof evidence.data === "object" && evidence.data ? evidence.data : {}, semanticProbe };
|
|
240
|
+
}
|
|
232
241
|
rememberEvidence(context, evidence);
|
|
233
242
|
await context.store.appendEvent(sessionId, {
|
|
234
243
|
type: "evidence_record",
|
|
@@ -420,8 +429,12 @@ function createToolEndEvent(id, output) {
|
|
|
420
429
|
};
|
|
421
430
|
}
|
|
422
431
|
function summarizeToolEndOutputForTranscript(output) {
|
|
432
|
+
const diagnostics = formatToolDiagnosticsSummary(output);
|
|
423
433
|
const text = compactToolEndTextForTranscript(
|
|
424
|
-
|
|
434
|
+
appendCompactDiagnostics(
|
|
435
|
+
output.summary || output.preview || output.text || "tool call completed",
|
|
436
|
+
diagnostics
|
|
437
|
+
),
|
|
425
438
|
output.fullOutputPath
|
|
426
439
|
);
|
|
427
440
|
return {
|
|
@@ -431,9 +444,15 @@ function summarizeToolEndOutputForTranscript(output) {
|
|
|
431
444
|
truncated: output.truncated,
|
|
432
445
|
fullOutputPath: output.fullOutputPath,
|
|
433
446
|
evidenceId: output.evidenceId,
|
|
434
|
-
changedFiles: output.changedFiles
|
|
447
|
+
changedFiles: output.changedFiles,
|
|
448
|
+
data: compactToolStructuredDataForTranscript(output.data)
|
|
435
449
|
};
|
|
436
450
|
}
|
|
451
|
+
function appendCompactDiagnostics(text, diagnostics) {
|
|
452
|
+
if (!diagnostics || text.includes("Linghun diagnostics:")) return text;
|
|
453
|
+
return `${diagnostics}
|
|
454
|
+
${text}`;
|
|
455
|
+
}
|
|
437
456
|
function compactToolEndTextForTranscript(text, fullOutputPath) {
|
|
438
457
|
const bytes = Buffer.byteLength(text, "utf8");
|
|
439
458
|
if (text.length <= TRANSCRIPT_TOOL_OUTPUT_MAX_CHARS && bytes <= TRANSCRIPT_TOOL_OUTPUT_MAX_CHARS) {
|
|
@@ -474,12 +493,69 @@ function compactToolOutputDataForTranscript(data) {
|
|
|
474
493
|
return {
|
|
475
494
|
truncated: true,
|
|
476
495
|
originalChars: serialized.length,
|
|
477
|
-
preview: serialized.slice(0, TRANSCRIPT_TOOL_OUTPUT_PREVIEW_CHARS)
|
|
496
|
+
preview: serialized.slice(0, TRANSCRIPT_TOOL_OUTPUT_PREVIEW_CHARS),
|
|
497
|
+
...compactToolStructuredDataForTranscript(data)
|
|
498
|
+
};
|
|
499
|
+
}
|
|
500
|
+
function compactToolStructuredDataForTranscript(data) {
|
|
501
|
+
const compact = {};
|
|
502
|
+
const diagnostics = compactDiagnosticsDataForTranscript(data);
|
|
503
|
+
const validationEvidence = compactValidationEvidenceDataForTranscript(data);
|
|
504
|
+
if (diagnostics) Object.assign(compact, diagnostics);
|
|
505
|
+
if (validationEvidence) Object.assign(compact, validationEvidence);
|
|
506
|
+
return Object.keys(compact).length > 0 ? compact : void 0;
|
|
507
|
+
}
|
|
508
|
+
function compactDiagnosticsDataForTranscript(data) {
|
|
509
|
+
const diagnostics = readDiagnosticsForTranscript(data);
|
|
510
|
+
if (!diagnostics) return void 0;
|
|
511
|
+
return { diagnostics };
|
|
512
|
+
}
|
|
513
|
+
function compactValidationEvidenceDataForTranscript(data) {
|
|
514
|
+
const validationEvidence = readValidationEvidenceForTranscript(data);
|
|
515
|
+
if (!validationEvidence) return void 0;
|
|
516
|
+
return { validationEvidence };
|
|
517
|
+
}
|
|
518
|
+
function readDiagnosticsForTranscript(data) {
|
|
519
|
+
if (!data || typeof data !== "object") return void 0;
|
|
520
|
+
const diagnostics = data.diagnostics;
|
|
521
|
+
if (!Array.isArray(diagnostics) || diagnostics.length === 0) return void 0;
|
|
522
|
+
return diagnostics.slice(0, 5).map(compactDiagnosticForTranscript).filter((diagnostic) => Boolean(diagnostic));
|
|
523
|
+
}
|
|
524
|
+
function compactDiagnosticForTranscript(value) {
|
|
525
|
+
if (!value || typeof value !== "object") return void 0;
|
|
526
|
+
const record = value;
|
|
527
|
+
const type = typeof record.type === "string" ? record.type : void 0;
|
|
528
|
+
const severity = typeof record.severity === "string" ? record.severity : void 0;
|
|
529
|
+
const evidence = typeof record.evidence === "string" ? truncateDisplay(record.evidence.replace(/\s+/g, " "), 160) : void 0;
|
|
530
|
+
if (!type || !evidence) return void 0;
|
|
531
|
+
return {
|
|
532
|
+
type,
|
|
533
|
+
severity,
|
|
534
|
+
evidence,
|
|
535
|
+
...readCompactDiagnosticTargetFields(record)
|
|
536
|
+
};
|
|
537
|
+
}
|
|
538
|
+
function readCompactDiagnosticTargetFields(record) {
|
|
539
|
+
const target = typeof record.target === "string" ? record.target : void 0;
|
|
540
|
+
const path = typeof record.path === "string" ? record.path : void 0;
|
|
541
|
+
const command = typeof record.command === "string" ? record.command : void 0;
|
|
542
|
+
const fallback = typeof record.fallback === "string" ? record.fallback : void 0;
|
|
543
|
+
const targetHost = typeof record.targetHost === "string" ? record.targetHost : void 0;
|
|
544
|
+
const targetPort = typeof record.targetPort === "number" ? record.targetPort : void 0;
|
|
545
|
+
return {
|
|
546
|
+
...command ? { command } : {},
|
|
547
|
+
...fallback ? { fallback } : {},
|
|
548
|
+
...target ? { target } : {},
|
|
549
|
+
...path ? { path } : {},
|
|
550
|
+
...targetHost ? { targetHost } : {},
|
|
551
|
+
...targetPort !== void 0 ? { targetPort } : {}
|
|
478
552
|
};
|
|
479
553
|
}
|
|
480
554
|
function isToolOutputFailure(name, output) {
|
|
481
555
|
if (name === "Bash") {
|
|
482
|
-
const
|
|
556
|
+
const data = output.data;
|
|
557
|
+
if (data?.isError === false) return false;
|
|
558
|
+
const exitCode = data?.exitCode;
|
|
483
559
|
return typeof exitCode === "number" && exitCode !== 0;
|
|
484
560
|
}
|
|
485
561
|
return false;
|
|
@@ -525,11 +601,14 @@ async function appendDeferredToolResultEvent(context, sessionId, toolUseId, disp
|
|
|
525
601
|
});
|
|
526
602
|
}
|
|
527
603
|
async function appendToolResultEvent(context, sessionId, toolUseId, toolName, content, isError, evidenceId) {
|
|
604
|
+
rememberRecentDiagnostics(context, toolName, content, toolUseId, evidenceId);
|
|
605
|
+
rememberToolEvidenceData(context, evidenceId, content);
|
|
606
|
+
const contentWithDiagnostics = appendToolResultContentDiagnostics(content);
|
|
528
607
|
const budgetedContent = await budgetToolResultTranscriptContent(
|
|
529
608
|
context,
|
|
530
609
|
sessionId,
|
|
531
610
|
toolUseId,
|
|
532
|
-
|
|
611
|
+
contentWithDiagnostics
|
|
533
612
|
);
|
|
534
613
|
await context.store.appendEvent(sessionId, {
|
|
535
614
|
type: "tool_result",
|
|
@@ -541,6 +620,193 @@ async function appendToolResultEvent(context, sessionId, toolUseId, toolName, co
|
|
|
541
620
|
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
542
621
|
});
|
|
543
622
|
}
|
|
623
|
+
function rememberToolEvidenceData(context, evidenceId, content) {
|
|
624
|
+
if (!evidenceId || !content || typeof content !== "object") return;
|
|
625
|
+
if (!Array.isArray(context.evidence)) return;
|
|
626
|
+
const output = content;
|
|
627
|
+
const compact = compactToolEvidenceData(output.data);
|
|
628
|
+
if (!compact) return;
|
|
629
|
+
const evidence = context.evidence.find((item) => item.id === evidenceId);
|
|
630
|
+
if (evidence) {
|
|
631
|
+
evidence.data = { ...typeof evidence.data === "object" && evidence.data ? evidence.data : {}, ...compact };
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
function compactToolEvidenceData(data) {
|
|
635
|
+
if (!data || typeof data !== "object") return void 0;
|
|
636
|
+
const record = data;
|
|
637
|
+
const compact = {};
|
|
638
|
+
for (const key of ["service", "serviceHint", "artifactHint", "binaryHint", "binaryPreflight"]) {
|
|
639
|
+
if (record[key] !== void 0) compact[key] = record[key];
|
|
640
|
+
}
|
|
641
|
+
const validationEvidence = readValidationEvidenceForTranscript(data);
|
|
642
|
+
if (validationEvidence) compact.validationEvidence = validationEvidence;
|
|
643
|
+
return Object.keys(compact).length > 0 ? compact : void 0;
|
|
644
|
+
}
|
|
645
|
+
function compactSemanticProbeEvidence(context, output, input) {
|
|
646
|
+
const tokens = collectSemanticContractTokens(context);
|
|
647
|
+
if (tokens.length === 0) return void 0;
|
|
648
|
+
if (!looksLikeServiceProbeCommand(input)) return void 0;
|
|
649
|
+
const haystack = [output.text, output.summary, output.preview].filter((item) => typeof item === "string" && item.length > 0).join("\n").toLowerCase();
|
|
650
|
+
if (!haystack) return void 0;
|
|
651
|
+
const matched = tokens.filter((token) => haystack.includes(token.toLowerCase()));
|
|
652
|
+
const required = Math.min(2, tokens.length);
|
|
653
|
+
if (matched.length < required) return void 0;
|
|
654
|
+
return { tokens: matched.slice(0, 12) };
|
|
655
|
+
}
|
|
656
|
+
function looksLikeServiceProbeCommand(input) {
|
|
657
|
+
if (!input || typeof input !== "object" || Array.isArray(input)) return false;
|
|
658
|
+
const command = input.command;
|
|
659
|
+
if (typeof command !== "string") return false;
|
|
660
|
+
return /\b(?:curl|wget|http|httpie|python|python3|node|deno|ruby|perl|php)\b|(?:requests|fetch|urllib|http\.client|axios|localhost|127\.0\.0\.1)/iu.test(
|
|
661
|
+
command
|
|
662
|
+
);
|
|
663
|
+
}
|
|
664
|
+
function collectSemanticContractTokens(context) {
|
|
665
|
+
const tools = context.tools;
|
|
666
|
+
if (tools.headlessBench?.enabled !== true) return [];
|
|
667
|
+
const tokens = /* @__PURE__ */ new Set();
|
|
668
|
+
for (const item of tools.validationContract?.items ?? []) {
|
|
669
|
+
if (item.kind !== "service" || item.validation !== "semantic" || !Array.isArray(item.semanticTokens)) {
|
|
670
|
+
continue;
|
|
671
|
+
}
|
|
672
|
+
for (const token of item.semanticTokens) {
|
|
673
|
+
if (typeof token === "string" && token.trim()) {
|
|
674
|
+
tokens.add(token.trim());
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
return [...tokens];
|
|
679
|
+
}
|
|
680
|
+
function rememberRecentDiagnostics(context, source, content, toolUseId, evidenceId) {
|
|
681
|
+
const diagnostics = readDiagnosticsForTranscript(content?.data);
|
|
682
|
+
if (!diagnostics || diagnostics.length === 0) return;
|
|
683
|
+
const createdAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
684
|
+
const entries = diagnostics.map((diagnostic) => ({
|
|
685
|
+
source,
|
|
686
|
+
...diagnostic,
|
|
687
|
+
createdAt,
|
|
688
|
+
toolUseId,
|
|
689
|
+
evidenceId
|
|
690
|
+
}));
|
|
691
|
+
context.tools.recentDiagnostics = [
|
|
692
|
+
...entries,
|
|
693
|
+
...context.tools.recentDiagnostics ?? []
|
|
694
|
+
].slice(0, RECENT_DIAGNOSTICS_LIMIT);
|
|
695
|
+
}
|
|
696
|
+
function appendToolResultContentDiagnostics(content) {
|
|
697
|
+
if (!content || typeof content !== "object") return content;
|
|
698
|
+
const output = content;
|
|
699
|
+
if (typeof output.text !== "string") return content;
|
|
700
|
+
const diagnostics = formatToolDiagnosticsSummary(output);
|
|
701
|
+
const compactData = compactToolStructuredDataForTranscript(output.data);
|
|
702
|
+
if (!diagnostics && !compactData) return content;
|
|
703
|
+
return {
|
|
704
|
+
...output,
|
|
705
|
+
data: compactData,
|
|
706
|
+
text: diagnostics ? appendCompactDiagnostics(output.text, diagnostics) : output.text
|
|
707
|
+
};
|
|
708
|
+
}
|
|
709
|
+
function readValidationEvidenceForTranscript(data) {
|
|
710
|
+
if (!data || typeof data !== "object") return void 0;
|
|
711
|
+
const record = data;
|
|
712
|
+
const entries = [
|
|
713
|
+
readArtifactValidationEvidence(record),
|
|
714
|
+
readPreservationValidationEvidence(record),
|
|
715
|
+
readServiceValidationEvidence(record),
|
|
716
|
+
readBinaryValidationEvidence(record)
|
|
717
|
+
].filter((item) => Boolean(item));
|
|
718
|
+
return entries.length > 0 ? entries : void 0;
|
|
719
|
+
}
|
|
720
|
+
function readArtifactValidationEvidence(record) {
|
|
721
|
+
const artifact = readRecord(record.artifact);
|
|
722
|
+
if (!artifact) return void 0;
|
|
723
|
+
const path = readString(artifact.path);
|
|
724
|
+
if (!path) return void 0;
|
|
725
|
+
return {
|
|
726
|
+
kind: "artifact",
|
|
727
|
+
path,
|
|
728
|
+
tool: "Bash.artifact",
|
|
729
|
+
ok: record.exitCode === 0 && artifact.exists === true && checksOk(readRecord(artifact.checks)),
|
|
730
|
+
...artifact.checks && typeof artifact.checks === "object" ? { checks: compactArtifactChecks(artifact.checks) } : {}
|
|
731
|
+
};
|
|
732
|
+
}
|
|
733
|
+
function readPreservationValidationEvidence(record) {
|
|
734
|
+
const artifact = readRecord(record.artifact);
|
|
735
|
+
const checks = readRecord(artifact?.checks);
|
|
736
|
+
const preserve = readRecord(checks?.preserve);
|
|
737
|
+
const path = readString(artifact?.path);
|
|
738
|
+
if (!artifact || !checks || !preserve || !path) return void 0;
|
|
739
|
+
return {
|
|
740
|
+
kind: "preservation",
|
|
741
|
+
path,
|
|
742
|
+
tool: "Bash.artifact",
|
|
743
|
+
ok: record.exitCode === 0 && preserve.ok === true,
|
|
744
|
+
checks: { preserve: compactCheckRecord(preserve) }
|
|
745
|
+
};
|
|
746
|
+
}
|
|
747
|
+
function readServiceValidationEvidence(record) {
|
|
748
|
+
const service = readRecord(record.service);
|
|
749
|
+
if (!service) return void 0;
|
|
750
|
+
const target = readString(service.target) ?? readServiceTargetFromHostPort(service);
|
|
751
|
+
if (!target) return void 0;
|
|
752
|
+
const readiness = readRecord(service.readiness);
|
|
753
|
+
const fetch = readRecord(service.fetch);
|
|
754
|
+
return {
|
|
755
|
+
kind: "service",
|
|
756
|
+
target,
|
|
757
|
+
tool: "Bash.service",
|
|
758
|
+
ok: record.exitCode === 0 && (service.ready === true || readiness?.ok === true),
|
|
759
|
+
...readiness || fetch ? { checks: { ...readiness ? { readiness: compactCheckRecord(readiness) } : {}, ...fetch ? { fetch: compactCheckRecord(fetch) } : {} } } : {}
|
|
760
|
+
};
|
|
761
|
+
}
|
|
762
|
+
function readBinaryValidationEvidence(record) {
|
|
763
|
+
const binary = readRecord(record.binary);
|
|
764
|
+
if (!binary) return void 0;
|
|
765
|
+
const path = readString(binary.path);
|
|
766
|
+
if (!path) return void 0;
|
|
767
|
+
return {
|
|
768
|
+
kind: "binary",
|
|
769
|
+
path,
|
|
770
|
+
tool: "Bash.binary",
|
|
771
|
+
ok: record.exitCode === 0,
|
|
772
|
+
checks: compactCheckRecord(binary)
|
|
773
|
+
};
|
|
774
|
+
}
|
|
775
|
+
function readRecord(value) {
|
|
776
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
|
|
777
|
+
}
|
|
778
|
+
function readString(value) {
|
|
779
|
+
return typeof value === "string" && value.trim() ? value : void 0;
|
|
780
|
+
}
|
|
781
|
+
function readServiceTargetFromHostPort(service) {
|
|
782
|
+
const host = readString(service.targetHost);
|
|
783
|
+
const port = typeof service.targetPort === "number" ? service.targetPort : void 0;
|
|
784
|
+
return host && port !== void 0 ? `${host}:${port}` : void 0;
|
|
785
|
+
}
|
|
786
|
+
function checksOk(checks) {
|
|
787
|
+
if (!checks) return true;
|
|
788
|
+
return Object.values(checks).every((value) => {
|
|
789
|
+
const check = readRecord(value);
|
|
790
|
+
return !check || check.ok !== false;
|
|
791
|
+
});
|
|
792
|
+
}
|
|
793
|
+
function compactArtifactChecks(value) {
|
|
794
|
+
const checks = readRecord(value);
|
|
795
|
+
if (!checks) return {};
|
|
796
|
+
const compact = {};
|
|
797
|
+
for (const key of ["header", "json", "executable", "text", "preserve"]) {
|
|
798
|
+
const check = readRecord(checks[key]);
|
|
799
|
+
if (check) compact[key] = compactCheckRecord(check);
|
|
800
|
+
}
|
|
801
|
+
return compact;
|
|
802
|
+
}
|
|
803
|
+
function compactCheckRecord(record) {
|
|
804
|
+
const compact = {};
|
|
805
|
+
for (const key of ["ok", "mode", "status", "expectedStatus", "missingBody", "contains", "lineSet", "exact", "magic", "size"]) {
|
|
806
|
+
if (record[key] !== void 0) compact[key] = record[key];
|
|
807
|
+
}
|
|
808
|
+
return compact;
|
|
809
|
+
}
|
|
544
810
|
async function budgetToolResultTranscriptContent(context, sessionId, toolUseId, content) {
|
|
545
811
|
const contentText = stringifyToolResultContentForBudget(content);
|
|
546
812
|
if (!contentText || contentText.startsWith("<persisted-tool-result>")) return content;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createCompactBoundaryBlock
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-ESAACKVG.js";
|
|
4
4
|
import {
|
|
5
5
|
createEvidenceRecord,
|
|
6
6
|
rememberEvidence
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-DEIYY6NI.js";
|
|
8
8
|
import {
|
|
9
9
|
applyToolResultBudgetToMessages
|
|
10
10
|
} from "./chunk-O7S3HYE6.js";
|
|
@@ -6,10 +6,10 @@ import {
|
|
|
6
6
|
} from "./chunk-TVNWAEJR.js";
|
|
7
7
|
import {
|
|
8
8
|
showCommandPanel
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-6JPUBF7B.js";
|
|
10
10
|
import {
|
|
11
11
|
writeErrorLine
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-OH35XDD4.js";
|
|
13
13
|
import {
|
|
14
14
|
createHandoffPacket,
|
|
15
15
|
formatResumePacket,
|
|
@@ -27,11 +27,11 @@ import {
|
|
|
27
27
|
} from "./chunk-CFXB5SE5.js";
|
|
28
28
|
import {
|
|
29
29
|
showCommandPanel
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-6JPUBF7B.js";
|
|
31
31
|
import {
|
|
32
32
|
redactRemoteSummary,
|
|
33
33
|
remoteTranscriptSummary
|
|
34
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-6C32YAB5.js";
|
|
35
35
|
import {
|
|
36
36
|
applyRemoteSessionDisables,
|
|
37
37
|
createRemoteState
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
detectEngineeringArtifactTargets,
|
|
6
6
|
formatEngineeringFailureBoundaryHint,
|
|
7
7
|
formatEngineeringProfileStrategyHint
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-ZPFOP557.js";
|
|
9
9
|
import {
|
|
10
10
|
LINGHUN_AGENT_CHILD_TURNS_AGENT,
|
|
11
11
|
LINGHUN_AGENT_CHILD_TURNS_BASE,
|
|
@@ -123,9 +123,84 @@ function createToolInputSchema(name) {
|
|
|
123
123
|
...base,
|
|
124
124
|
properties: {
|
|
125
125
|
command: { type: "string" },
|
|
126
|
-
timeoutMs: { type: "number" }
|
|
127
|
-
|
|
128
|
-
|
|
126
|
+
timeoutMs: { type: "number" },
|
|
127
|
+
runInBackground: { type: "boolean" },
|
|
128
|
+
run_in_background: { type: "boolean" },
|
|
129
|
+
service: {
|
|
130
|
+
type: "object",
|
|
131
|
+
additionalProperties: false,
|
|
132
|
+
anyOf: [
|
|
133
|
+
{ required: ["action", "url"] },
|
|
134
|
+
{ required: ["action", "serviceId"] },
|
|
135
|
+
{ required: ["type", "port"] },
|
|
136
|
+
{ required: ["type", "url"] }
|
|
137
|
+
],
|
|
138
|
+
properties: {
|
|
139
|
+
action: { type: "string", enum: ["status", "probe", "logs", "stop", "fetch"] },
|
|
140
|
+
serviceId: { type: "string" },
|
|
141
|
+
type: { type: "string", enum: ["tcp", "http"] },
|
|
142
|
+
host: { type: "string" },
|
|
143
|
+
port: { type: "number" },
|
|
144
|
+
url: { type: "string" },
|
|
145
|
+
expectStatus: { type: "number" },
|
|
146
|
+
bodyContains: {
|
|
147
|
+
anyOf: [
|
|
148
|
+
{ type: "string" },
|
|
149
|
+
{ type: "array", items: { type: "string" } }
|
|
150
|
+
]
|
|
151
|
+
},
|
|
152
|
+
timeoutMs: { type: "number" },
|
|
153
|
+
intervalMs: { type: "number" },
|
|
154
|
+
retry: { type: "number" },
|
|
155
|
+
tailBytes: { type: "number" }
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
artifact: {
|
|
159
|
+
type: "object",
|
|
160
|
+
additionalProperties: false,
|
|
161
|
+
required: ["path"],
|
|
162
|
+
properties: {
|
|
163
|
+
path: { type: "string" },
|
|
164
|
+
expectHeader: { type: "string" },
|
|
165
|
+
expectMagic: { type: "string" },
|
|
166
|
+
json: { type: "boolean" },
|
|
167
|
+
executable: { type: "boolean" },
|
|
168
|
+
protectPaths: { type: "array", items: { type: "string" } },
|
|
169
|
+
text: {
|
|
170
|
+
type: "object",
|
|
171
|
+
additionalProperties: false,
|
|
172
|
+
properties: {
|
|
173
|
+
exact: { type: "string" },
|
|
174
|
+
contains: {
|
|
175
|
+
anyOf: [
|
|
176
|
+
{ type: "string" },
|
|
177
|
+
{ type: "array", items: { type: "string" } }
|
|
178
|
+
]
|
|
179
|
+
},
|
|
180
|
+
lineSet: { type: "array", items: { type: "string" } }
|
|
181
|
+
}
|
|
182
|
+
},
|
|
183
|
+
preserve: {
|
|
184
|
+
type: "object",
|
|
185
|
+
additionalProperties: false,
|
|
186
|
+
properties: {
|
|
187
|
+
mode: { type: "string", enum: ["rawPreserve", "compareNormalizedHtml"] },
|
|
188
|
+
expectedPath: { type: "string" },
|
|
189
|
+
expectedText: { type: "string" }
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
},
|
|
194
|
+
binary: {
|
|
195
|
+
type: "object",
|
|
196
|
+
additionalProperties: false,
|
|
197
|
+
required: ["path"],
|
|
198
|
+
properties: {
|
|
199
|
+
path: { type: "string" },
|
|
200
|
+
previewBytes: { type: "number" }
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
129
204
|
};
|
|
130
205
|
}
|
|
131
206
|
if (name === "Todo") {
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
var TODO_OUTPUT_ITEM_LIMIT = 8;
|
|
3
3
|
var BASH_TAIL_LINE_LIMIT = 0;
|
|
4
4
|
var PRIMARY_PREVIEW_LINE_CAP = 5;
|
|
5
|
+
var DIAGNOSTICS_SUMMARY_LIMIT = 3;
|
|
6
|
+
var DIAGNOSTICS_EVIDENCE_LIMIT = 120;
|
|
5
7
|
var RAW_TOOL_USE_PATTERNS = [
|
|
6
8
|
/<tool_use(?:_error)?\b[\s\S]*?<\/tool_use(?:_error)?>/giu,
|
|
7
9
|
/<tool_use(?:_error)?\b[^>]*\/>/giu,
|
|
@@ -62,12 +64,36 @@ function formatToolOutput(name, output, language, evidenceId) {
|
|
|
62
64
|
if (layered.preview) {
|
|
63
65
|
lines.push(layered.preview);
|
|
64
66
|
}
|
|
67
|
+
const diagnostics = formatToolDiagnosticsSummary(output);
|
|
68
|
+
if (diagnostics) {
|
|
69
|
+
lines.push(diagnostics);
|
|
70
|
+
}
|
|
65
71
|
const bashEnd = formatBashEndSummary(name, output, language);
|
|
66
72
|
if (bashEnd) {
|
|
67
73
|
lines.push(bashEnd);
|
|
68
74
|
}
|
|
69
75
|
return lines.join("\n");
|
|
70
76
|
}
|
|
77
|
+
function formatToolDiagnosticsSummary(output) {
|
|
78
|
+
const metadata = output.data && typeof output.data === "object" ? output.data : void 0;
|
|
79
|
+
const diagnostics = Array.isArray(metadata?.diagnostics) ? metadata.diagnostics : [];
|
|
80
|
+
const lines = diagnostics.map(formatCompactDiagnosticLine).filter((line) => Boolean(line)).slice(0, DIAGNOSTICS_SUMMARY_LIMIT);
|
|
81
|
+
if (lines.length === 0) return void 0;
|
|
82
|
+
return ["Linghun diagnostics:", ...lines].join("\n");
|
|
83
|
+
}
|
|
84
|
+
function formatCompactDiagnosticLine(value) {
|
|
85
|
+
if (!value || typeof value !== "object") return void 0;
|
|
86
|
+
const record = value;
|
|
87
|
+
const type = typeof record.type === "string" ? record.type.trim() : "";
|
|
88
|
+
const evidence = typeof record.evidence === "string" ? record.evidence.trim() : "";
|
|
89
|
+
if (!type || !evidence) return void 0;
|
|
90
|
+
return `- ${type}: ${compactDiagnosticEvidence(evidence)}`;
|
|
91
|
+
}
|
|
92
|
+
function compactDiagnosticEvidence(value) {
|
|
93
|
+
const singleLine = value.replace(/\s+/gu, " ").trim();
|
|
94
|
+
if (singleLine.length <= DIAGNOSTICS_EVIDENCE_LIMIT) return singleLine;
|
|
95
|
+
return `${singleLine.slice(0, DIAGNOSTICS_EVIDENCE_LIMIT - 3)}...`;
|
|
96
|
+
}
|
|
71
97
|
function formatPrimaryToolLead(name, output, layered, language) {
|
|
72
98
|
const metadata = output.data && typeof output.data === "object" ? output.data : void 0;
|
|
73
99
|
const count = readNumber(metadata, "count");
|
|
@@ -589,6 +615,7 @@ function looksLikeMojibake(text) {
|
|
|
589
615
|
export {
|
|
590
616
|
createLayeredToolOutput,
|
|
591
617
|
formatToolOutput,
|
|
618
|
+
formatToolDiagnosticsSummary,
|
|
592
619
|
formatToolStart,
|
|
593
620
|
sanitizeAssistantPrimaryText,
|
|
594
621
|
sanitizeAssistantPrimaryTextWithMetadata,
|
|
@@ -5,14 +5,14 @@ import {
|
|
|
5
5
|
isPotentiallyMutatingMcpTool,
|
|
6
6
|
runMcpStdioToolCall,
|
|
7
7
|
runMcpStdioToolList
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-OMWSM2DA.js";
|
|
9
9
|
import {
|
|
10
10
|
buildIndexStatusPanel,
|
|
11
11
|
buildMcpStatusPanel,
|
|
12
12
|
formatIndexRefreshSummary,
|
|
13
13
|
formatIndexStatus,
|
|
14
14
|
formatMcpStatus
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-UYU4QN3P.js";
|
|
16
16
|
import {
|
|
17
17
|
runMcpSseToolCall
|
|
18
18
|
} from "./chunk-BNC4F63N.js";
|
|
@@ -26,14 +26,14 @@ import {
|
|
|
26
26
|
} from "./chunk-6CHUZ2NF.js";
|
|
27
27
|
import {
|
|
28
28
|
showCommandPanel
|
|
29
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-6JPUBF7B.js";
|
|
30
30
|
import {
|
|
31
31
|
writeDiagnosticLine
|
|
32
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-OH35XDD4.js";
|
|
33
33
|
import {
|
|
34
34
|
redactedPath,
|
|
35
35
|
runCommandCapture
|
|
36
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-HMGYFENJ.js";
|
|
37
37
|
import {
|
|
38
38
|
findDeferredTool,
|
|
39
39
|
getCodebaseMemoryToolRisk,
|