@liberseek/boft-cli-win32-arm64 0.7.8 → 0.8.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/README.md +1 -1
- package/THIRD_PARTY_NOTICES.txt +8 -0
- package/app/codexhost-distribution.json +1 -1
- package/app/console-server.mjs +16801 -16440
- package/app/console-web.js +9774 -3685
- package/app/desktop-controller.mjs +16475 -374
- package/app/host-runtime.mjs +9052 -1793
- package/app/plugins/antigravity/manifest.json +18 -1
- package/app/plugins/antigravity/plugin.mjs +357 -42
- package/app/plugins/claude-code/manifest.json +28 -0
- package/app/plugins/claude-code/plugin.mjs +1448 -491
- package/app/plugins/codebuddy/manifest.json +17 -0
- package/app/plugins/codebuddy/plugin.mjs +6589 -5423
- package/app/plugins/codex-usage/manifest.json +9 -0
- package/app/plugins/codex-usage/plugin.mjs +16750 -0
- package/app/plugins/cursor-cli/manifest.json +18 -1
- package/app/plugins/cursor-cli/plugin.mjs +782 -197
- package/app/plugins/deepseek-harness/assets/icon.svg +1 -0
- package/app/plugins/deepseek-harness/manifest.json +35 -2
- package/app/plugins/deepseek-harness/plugin.mjs +879 -242
- package/app/plugins/enabled.json +3 -1
- package/app/plugins/grok/manifest.json +21 -1
- package/app/plugins/grok/plugin.mjs +1274 -241
- package/app/plugins/hermes/assets/icon.png +0 -0
- package/app/plugins/hermes/manifest.json +30 -2
- package/app/plugins/hermes/plugin.mjs +3493 -7686
- package/app/plugins/kimi-code/assets/icon.svg +5 -0
- package/app/plugins/kimi-code/manifest.json +25 -2
- package/app/plugins/kimi-code/plugin.mjs +922 -76
- package/app/plugins/kiro-cli/assets/kiro-agent.svg +11 -0
- package/app/plugins/kiro-cli/manifest.json +18 -1
- package/app/plugins/kiro-cli/plugin.mjs +658 -57
- package/app/plugins/muse/manifest.json +18 -1
- package/app/plugins/muse/plugin.mjs +332 -17
- package/app/plugins/omp/manifest.json +21 -1
- package/app/plugins/omp/plugin.mjs +2320 -1131
- package/app/plugins/opencode/manifest.json +18 -1
- package/app/plugins/opencode/plugin.mjs +979 -184
- package/app/plugins/pi/manifest.json +32 -0
- package/app/plugins/pi/plugin.mjs +2785 -2090
- package/app/plugins/qoder/manifest.json +18 -1
- package/app/plugins/qoder/plugin.mjs +832 -82
- package/app/plugins/qoder-cn/manifest.json +18 -1
- package/app/plugins/qoder-cn/plugin.mjs +832 -82
- package/app/plugins/workbuddy/manifest.json +18 -0
- package/app/plugins/workbuddy/plugin.mjs +6947 -5773
- package/app/plugins/zcode/assets/icon.svg +8 -0
- package/app/plugins/zcode/manifest.json +32 -0
- package/app/plugins/zcode/plugin.mjs +20110 -0
- package/app/renderer-extension.js +4762 -2470
- package/bin/boft.exe +0 -0
- package/libexec/boft-node-repl.exe +0 -0
- package/libexec/boft-shim.exe +0 -0
- package/libexec/boft-updater.exe +0 -0
- package/licenses/Cordis-LICENSE.txt +21 -0
- package/licenses/Cosmokit-LICENSE.txt +21 -0
- package/package.json +1 -1
- package/app/plugins/kiro-cli/assets/icon.svg +0 -5
|
@@ -408,530 +408,132 @@ function createHarnessInstaller(environment, source) {
|
|
|
408
408
|
};
|
|
409
409
|
}
|
|
410
410
|
|
|
411
|
-
//
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
const
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
if (!canRemove || canAdd && removePath.oldPos < addPath.oldPos) {
|
|
472
|
-
basePath = this.addToPath(addPath, true, false, 0, options);
|
|
473
|
-
} else {
|
|
474
|
-
basePath = this.addToPath(removePath, false, true, 1, options);
|
|
475
|
-
}
|
|
476
|
-
newPos = this.extractCommon(basePath, newTokens, oldTokens, diagonalPath, options);
|
|
477
|
-
if (basePath.oldPos + 1 >= oldLen && newPos + 1 >= newLen) {
|
|
478
|
-
return done(this.buildValues(basePath.lastComponent, newTokens, oldTokens)) || true;
|
|
479
|
-
} else {
|
|
480
|
-
bestPath[diagonalPath] = basePath;
|
|
481
|
-
if (basePath.oldPos + 1 >= oldLen) {
|
|
482
|
-
maxDiagonalToConsider = Math.min(maxDiagonalToConsider, diagonalPath - 1);
|
|
483
|
-
}
|
|
484
|
-
if (newPos + 1 >= newLen) {
|
|
485
|
-
minDiagonalToConsider = Math.max(minDiagonalToConsider, diagonalPath + 1);
|
|
486
|
-
}
|
|
487
|
-
}
|
|
488
|
-
}
|
|
489
|
-
editLength++;
|
|
490
|
-
};
|
|
491
|
-
if (callback) {
|
|
492
|
-
(function exec() {
|
|
493
|
-
setTimeout(function() {
|
|
494
|
-
if (editLength > maxEditLength || Date.now() > abortAfterTimestamp) {
|
|
495
|
-
return callback(void 0);
|
|
496
|
-
}
|
|
497
|
-
if (!execEditLength()) {
|
|
498
|
-
exec();
|
|
499
|
-
}
|
|
500
|
-
}, 0);
|
|
501
|
-
})();
|
|
502
|
-
} else {
|
|
503
|
-
while (editLength <= maxEditLength && Date.now() <= abortAfterTimestamp) {
|
|
504
|
-
const ret = execEditLength();
|
|
505
|
-
if (ret) {
|
|
506
|
-
return ret;
|
|
411
|
+
// ../../harness-adapter/dist/usage-statistics.js
|
|
412
|
+
import { createReadStream } from "node:fs";
|
|
413
|
+
import { lstat, opendir } from "node:fs/promises";
|
|
414
|
+
import path4 from "node:path";
|
|
415
|
+
import { createInterface } from "node:readline";
|
|
416
|
+
var MAX_SESSION_ID_LENGTH = 512;
|
|
417
|
+
var MAX_CWD_LENGTH = 4096;
|
|
418
|
+
function sessionIdOk(value) {
|
|
419
|
+
return typeof value === "string" && value.length > 0 && value.length <= MAX_SESSION_ID_LENGTH;
|
|
420
|
+
}
|
|
421
|
+
function cwdOk(value) {
|
|
422
|
+
return typeof value === "string" && value.length > 0 && value.length <= MAX_CWD_LENGTH && !value.includes("\0") && (value.startsWith("/") || /^[A-Za-z]:[\\/]/u.test(value) || value.startsWith("\\\\"));
|
|
423
|
+
}
|
|
424
|
+
function withUsageSession(entry, session) {
|
|
425
|
+
const sessionId = sessionIdOk(session.sessionId) ? session.sessionId : void 0;
|
|
426
|
+
const cwd = cwdOk(session.cwd) ? session.cwd : void 0;
|
|
427
|
+
if (sessionId === void 0 && cwd === void 0)
|
|
428
|
+
return entry;
|
|
429
|
+
return {
|
|
430
|
+
...entry,
|
|
431
|
+
...sessionId !== void 0 ? { sessionId } : {},
|
|
432
|
+
...cwd !== void 0 ? { cwd } : {}
|
|
433
|
+
};
|
|
434
|
+
}
|
|
435
|
+
function usageEntryFromRequest(request, occurredAtMs) {
|
|
436
|
+
if (!Number.isSafeInteger(occurredAtMs) || occurredAtMs <= 0)
|
|
437
|
+
return null;
|
|
438
|
+
return {
|
|
439
|
+
id: request.requestId,
|
|
440
|
+
occurredAtMs,
|
|
441
|
+
...request.model !== void 0 ? { model: request.model } : {},
|
|
442
|
+
inputTokens: request.inputTokens,
|
|
443
|
+
...request.cachedInputTokens !== void 0 ? { cachedInputTokens: request.cachedInputTokens } : {},
|
|
444
|
+
...request.cacheWriteInputTokens !== void 0 ? { cacheWriteInputTokens: request.cacheWriteInputTokens } : {},
|
|
445
|
+
...request.cacheWrite1hInputTokens !== void 0 ? { cacheWrite1hInputTokens: request.cacheWrite1hInputTokens } : {},
|
|
446
|
+
outputTokens: request.outputTokens,
|
|
447
|
+
...request.reasoningOutputTokens !== void 0 ? { reasoningOutputTokens: request.reasoningOutputTokens } : {}
|
|
448
|
+
};
|
|
449
|
+
}
|
|
450
|
+
async function jsonlUsageSources(root, maxDepth, signal) {
|
|
451
|
+
const sources = [];
|
|
452
|
+
const visit = async (directory, depth) => {
|
|
453
|
+
signal.throwIfAborted();
|
|
454
|
+
const entries = await opendir(directory).catch((error51) => {
|
|
455
|
+
if (error51.code === "ENOENT")
|
|
456
|
+
return null;
|
|
457
|
+
throw error51;
|
|
458
|
+
});
|
|
459
|
+
if (!entries)
|
|
460
|
+
return;
|
|
461
|
+
for await (const entry of entries) {
|
|
462
|
+
signal.throwIfAborted();
|
|
463
|
+
const file2 = path4.join(directory, entry.name);
|
|
464
|
+
if (entry.isDirectory()) {
|
|
465
|
+
if (depth < maxDepth)
|
|
466
|
+
await visit(file2, depth + 1);
|
|
467
|
+
} else if (entry.isFile() && entry.name.endsWith(".jsonl")) {
|
|
468
|
+
const info = await lstat(file2).catch(() => null);
|
|
469
|
+
if (info?.isFile() && info.size > 0) {
|
|
470
|
+
sources.push({ id: file2, fingerprint: `${info.ino}:${info.size}:${info.mtimeMs}` });
|
|
507
471
|
}
|
|
508
472
|
}
|
|
509
473
|
}
|
|
510
|
-
}
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
let oldPos = basePath.oldPos, newPos = oldPos - diagonalPath, commonCount = 0;
|
|
528
|
-
while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(oldTokens[oldPos + 1], newTokens[newPos + 1], options)) {
|
|
529
|
-
newPos++;
|
|
530
|
-
oldPos++;
|
|
531
|
-
commonCount++;
|
|
532
|
-
if (options.oneChangePerToken) {
|
|
533
|
-
basePath.lastComponent = { count: 1, previousComponent: basePath.lastComponent, added: false, removed: false };
|
|
534
|
-
}
|
|
535
|
-
}
|
|
536
|
-
if (commonCount && !options.oneChangePerToken) {
|
|
537
|
-
basePath.lastComponent = { count: commonCount, previousComponent: basePath.lastComponent, added: false, removed: false };
|
|
538
|
-
}
|
|
539
|
-
basePath.oldPos = oldPos;
|
|
540
|
-
return newPos;
|
|
541
|
-
}
|
|
542
|
-
equals(left, right, options) {
|
|
543
|
-
if (options.comparator) {
|
|
544
|
-
return options.comparator(left, right);
|
|
545
|
-
} else {
|
|
546
|
-
return left === right || !!options.ignoreCase && left.toLowerCase() === right.toLowerCase();
|
|
547
|
-
}
|
|
548
|
-
}
|
|
549
|
-
removeEmpty(array2) {
|
|
550
|
-
const ret = [];
|
|
551
|
-
for (let i = 0; i < array2.length; i++) {
|
|
552
|
-
if (array2[i]) {
|
|
553
|
-
ret.push(array2[i]);
|
|
554
|
-
}
|
|
555
|
-
}
|
|
556
|
-
return ret;
|
|
557
|
-
}
|
|
558
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
559
|
-
castInput(value, options) {
|
|
560
|
-
return value;
|
|
561
|
-
}
|
|
562
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
563
|
-
tokenize(value, options) {
|
|
564
|
-
return Array.from(value);
|
|
565
|
-
}
|
|
566
|
-
join(chars) {
|
|
567
|
-
return chars.join("");
|
|
568
|
-
}
|
|
569
|
-
postProcess(changeObjects, options) {
|
|
570
|
-
return changeObjects;
|
|
571
|
-
}
|
|
572
|
-
get useLongestToken() {
|
|
573
|
-
return false;
|
|
574
|
-
}
|
|
575
|
-
buildValues(lastComponent, newTokens, oldTokens) {
|
|
576
|
-
const components = [];
|
|
577
|
-
let nextComponent;
|
|
578
|
-
while (lastComponent) {
|
|
579
|
-
components.push(lastComponent);
|
|
580
|
-
nextComponent = lastComponent.previousComponent;
|
|
581
|
-
delete lastComponent.previousComponent;
|
|
582
|
-
lastComponent = nextComponent;
|
|
474
|
+
};
|
|
475
|
+
await visit(root, 0);
|
|
476
|
+
return sources;
|
|
477
|
+
}
|
|
478
|
+
async function* jsonlRecords(file2, marker, signal) {
|
|
479
|
+
const lines = createInterface({
|
|
480
|
+
input: createReadStream(file2, { encoding: "utf8", signal }),
|
|
481
|
+
crlfDelay: Infinity
|
|
482
|
+
});
|
|
483
|
+
for await (const line of lines) {
|
|
484
|
+
if (!line.includes(marker))
|
|
485
|
+
continue;
|
|
486
|
+
let value;
|
|
487
|
+
try {
|
|
488
|
+
value = JSON.parse(line);
|
|
489
|
+
} catch {
|
|
490
|
+
continue;
|
|
583
491
|
}
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
let componentPos = 0, newPos = 0, oldPos = 0;
|
|
587
|
-
for (; componentPos < componentLen; componentPos++) {
|
|
588
|
-
const component = components[componentPos];
|
|
589
|
-
if (!component.removed) {
|
|
590
|
-
if (!component.added && this.useLongestToken) {
|
|
591
|
-
let value = newTokens.slice(newPos, newPos + component.count);
|
|
592
|
-
value = value.map(function(value2, i) {
|
|
593
|
-
const oldValue = oldTokens[oldPos + i];
|
|
594
|
-
return oldValue.length > value2.length ? oldValue : value2;
|
|
595
|
-
});
|
|
596
|
-
component.value = this.join(value);
|
|
597
|
-
} else {
|
|
598
|
-
component.value = this.join(newTokens.slice(newPos, newPos + component.count));
|
|
599
|
-
}
|
|
600
|
-
newPos += component.count;
|
|
601
|
-
if (!component.added) {
|
|
602
|
-
oldPos += component.count;
|
|
603
|
-
}
|
|
604
|
-
} else {
|
|
605
|
-
component.value = this.join(oldTokens.slice(oldPos, oldPos + component.count));
|
|
606
|
-
oldPos += component.count;
|
|
607
|
-
}
|
|
492
|
+
if (typeof value === "object" && value !== null && !Array.isArray(value)) {
|
|
493
|
+
yield value;
|
|
608
494
|
}
|
|
609
|
-
return components;
|
|
610
|
-
}
|
|
611
|
-
};
|
|
612
|
-
|
|
613
|
-
// ../../../node_modules/diff/libesm/diff/line.js
|
|
614
|
-
var LineDiff = class extends Diff {
|
|
615
|
-
constructor() {
|
|
616
|
-
super(...arguments);
|
|
617
|
-
this.tokenize = tokenize;
|
|
618
495
|
}
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
496
|
+
}
|
|
497
|
+
async function jsonlHeader(file2, match, signal, maxLines = 4) {
|
|
498
|
+
const stream = createReadStream(file2, { encoding: "utf8", signal });
|
|
499
|
+
const lines = createInterface({ input: stream, crlfDelay: Infinity });
|
|
500
|
+
let seen = 0;
|
|
501
|
+
try {
|
|
502
|
+
for await (const line of lines) {
|
|
503
|
+
if (++seen > maxLines)
|
|
504
|
+
break;
|
|
505
|
+
let value;
|
|
506
|
+
try {
|
|
507
|
+
value = JSON.parse(line);
|
|
508
|
+
} catch {
|
|
509
|
+
continue;
|
|
630
510
|
}
|
|
631
|
-
if (
|
|
632
|
-
|
|
511
|
+
if (typeof value === "object" && value !== null && !Array.isArray(value)) {
|
|
512
|
+
const record2 = value;
|
|
513
|
+
if (match(record2))
|
|
514
|
+
return record2;
|
|
633
515
|
}
|
|
634
516
|
}
|
|
635
|
-
return
|
|
517
|
+
return null;
|
|
518
|
+
} finally {
|
|
519
|
+
lines.close();
|
|
520
|
+
stream.destroy();
|
|
636
521
|
}
|
|
637
|
-
};
|
|
638
|
-
var lineDiff = new LineDiff();
|
|
639
|
-
function diffLines(oldStr, newStr, options) {
|
|
640
|
-
return lineDiff.diff(oldStr, newStr, options);
|
|
641
522
|
}
|
|
642
|
-
function
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
}
|
|
646
|
-
const retLines = [], linesAndNewlines = value.split(/(\n|\r\n)/);
|
|
647
|
-
if (!linesAndNewlines[linesAndNewlines.length - 1]) {
|
|
648
|
-
linesAndNewlines.pop();
|
|
649
|
-
}
|
|
650
|
-
for (let i = 0; i < linesAndNewlines.length; i++) {
|
|
651
|
-
const line = linesAndNewlines[i];
|
|
652
|
-
if (i % 2 && !options.newlineIsToken) {
|
|
653
|
-
retLines[retLines.length - 1] += line;
|
|
654
|
-
} else {
|
|
655
|
-
retLines.push(line);
|
|
656
|
-
}
|
|
657
|
-
}
|
|
658
|
-
return retLines;
|
|
659
|
-
}
|
|
660
|
-
|
|
661
|
-
// ../../../node_modules/diff/libesm/patch/parse.js
|
|
662
|
-
function parsePatch(uniDiff) {
|
|
663
|
-
const diffstr = uniDiff.split(/\n/), list = [];
|
|
664
|
-
let i = 0;
|
|
665
|
-
function parseIndex() {
|
|
666
|
-
const index = {};
|
|
667
|
-
list.push(index);
|
|
668
|
-
while (i < diffstr.length) {
|
|
669
|
-
const line = diffstr[i];
|
|
670
|
-
if (/^(---|\+\+\+|@@)\s/.test(line)) {
|
|
671
|
-
break;
|
|
672
|
-
}
|
|
673
|
-
const header = /^(?:Index:|diff(?: -r \w+)+)\s+(.+?)\s*$/.exec(line);
|
|
674
|
-
if (header) {
|
|
675
|
-
index.index = header[1];
|
|
676
|
-
}
|
|
677
|
-
i++;
|
|
678
|
-
}
|
|
679
|
-
parseFileHeader(index);
|
|
680
|
-
parseFileHeader(index);
|
|
681
|
-
index.hunks = [];
|
|
682
|
-
while (i < diffstr.length) {
|
|
683
|
-
const line = diffstr[i];
|
|
684
|
-
if (/^(Index:\s|diff\s|---\s|\+\+\+\s|===================================================================)/.test(line)) {
|
|
685
|
-
break;
|
|
686
|
-
} else if (/^@@/.test(line)) {
|
|
687
|
-
index.hunks.push(parseHunk());
|
|
688
|
-
} else if (line) {
|
|
689
|
-
throw new Error("Unknown line " + (i + 1) + " " + JSON.stringify(line));
|
|
690
|
-
} else {
|
|
691
|
-
i++;
|
|
692
|
-
}
|
|
693
|
-
}
|
|
694
|
-
}
|
|
695
|
-
function parseFileHeader(index) {
|
|
696
|
-
const fileHeader = /^(---|\+\+\+)\s+(.*)\r?$/.exec(diffstr[i]);
|
|
697
|
-
if (fileHeader) {
|
|
698
|
-
const data = fileHeader[2].split(" ", 2), header = (data[1] || "").trim();
|
|
699
|
-
let fileName = data[0].replace(/\\\\/g, "\\");
|
|
700
|
-
if (/^".*"$/.test(fileName)) {
|
|
701
|
-
fileName = fileName.substr(1, fileName.length - 2);
|
|
702
|
-
}
|
|
703
|
-
if (fileHeader[1] === "---") {
|
|
704
|
-
index.oldFileName = fileName;
|
|
705
|
-
index.oldHeader = header;
|
|
706
|
-
} else {
|
|
707
|
-
index.newFileName = fileName;
|
|
708
|
-
index.newHeader = header;
|
|
709
|
-
}
|
|
710
|
-
i++;
|
|
711
|
-
}
|
|
712
|
-
}
|
|
713
|
-
function parseHunk() {
|
|
714
|
-
var _a3;
|
|
715
|
-
const chunkHeaderIndex = i, chunkHeaderLine = diffstr[i++], chunkHeader = chunkHeaderLine.split(/@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/);
|
|
716
|
-
const hunk = {
|
|
717
|
-
oldStart: +chunkHeader[1],
|
|
718
|
-
oldLines: typeof chunkHeader[2] === "undefined" ? 1 : +chunkHeader[2],
|
|
719
|
-
newStart: +chunkHeader[3],
|
|
720
|
-
newLines: typeof chunkHeader[4] === "undefined" ? 1 : +chunkHeader[4],
|
|
721
|
-
lines: []
|
|
722
|
-
};
|
|
723
|
-
if (hunk.oldLines === 0) {
|
|
724
|
-
hunk.oldStart += 1;
|
|
725
|
-
}
|
|
726
|
-
if (hunk.newLines === 0) {
|
|
727
|
-
hunk.newStart += 1;
|
|
728
|
-
}
|
|
729
|
-
let addCount = 0, removeCount = 0;
|
|
730
|
-
for (; i < diffstr.length && (removeCount < hunk.oldLines || addCount < hunk.newLines || ((_a3 = diffstr[i]) === null || _a3 === void 0 ? void 0 : _a3.startsWith("\\"))); i++) {
|
|
731
|
-
const operation = diffstr[i].length == 0 && i != diffstr.length - 1 ? " " : diffstr[i][0];
|
|
732
|
-
if (operation === "+" || operation === "-" || operation === " " || operation === "\\") {
|
|
733
|
-
hunk.lines.push(diffstr[i]);
|
|
734
|
-
if (operation === "+") {
|
|
735
|
-
addCount++;
|
|
736
|
-
} else if (operation === "-") {
|
|
737
|
-
removeCount++;
|
|
738
|
-
} else if (operation === " ") {
|
|
739
|
-
addCount++;
|
|
740
|
-
removeCount++;
|
|
741
|
-
}
|
|
742
|
-
} else {
|
|
743
|
-
throw new Error(`Hunk at line ${chunkHeaderIndex + 1} contained invalid line ${diffstr[i]}`);
|
|
744
|
-
}
|
|
745
|
-
}
|
|
746
|
-
if (!addCount && hunk.newLines === 1) {
|
|
747
|
-
hunk.newLines = 0;
|
|
748
|
-
}
|
|
749
|
-
if (!removeCount && hunk.oldLines === 1) {
|
|
750
|
-
hunk.oldLines = 0;
|
|
751
|
-
}
|
|
752
|
-
if (addCount !== hunk.newLines) {
|
|
753
|
-
throw new Error("Added line count did not match for hunk at line " + (chunkHeaderIndex + 1));
|
|
754
|
-
}
|
|
755
|
-
if (removeCount !== hunk.oldLines) {
|
|
756
|
-
throw new Error("Removed line count did not match for hunk at line " + (chunkHeaderIndex + 1));
|
|
757
|
-
}
|
|
758
|
-
return hunk;
|
|
759
|
-
}
|
|
760
|
-
while (i < diffstr.length) {
|
|
761
|
-
parseIndex();
|
|
762
|
-
}
|
|
763
|
-
return list;
|
|
764
|
-
}
|
|
765
|
-
|
|
766
|
-
// ../../../node_modules/diff/libesm/patch/create.js
|
|
767
|
-
function structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
|
|
768
|
-
let optionsObj;
|
|
769
|
-
if (!options) {
|
|
770
|
-
optionsObj = {};
|
|
771
|
-
} else if (typeof options === "function") {
|
|
772
|
-
optionsObj = { callback: options };
|
|
773
|
-
} else {
|
|
774
|
-
optionsObj = options;
|
|
775
|
-
}
|
|
776
|
-
if (typeof optionsObj.context === "undefined") {
|
|
777
|
-
optionsObj.context = 4;
|
|
778
|
-
}
|
|
779
|
-
const context = optionsObj.context;
|
|
780
|
-
if (optionsObj.newlineIsToken) {
|
|
781
|
-
throw new Error("newlineIsToken may not be used with patch-generation functions, only with diffing functions");
|
|
782
|
-
}
|
|
783
|
-
if (!optionsObj.callback) {
|
|
784
|
-
return diffLinesResultToPatch(diffLines(oldStr, newStr, optionsObj));
|
|
785
|
-
} else {
|
|
786
|
-
const { callback } = optionsObj;
|
|
787
|
-
diffLines(oldStr, newStr, Object.assign(Object.assign({}, optionsObj), { callback: (diff) => {
|
|
788
|
-
const patch = diffLinesResultToPatch(diff);
|
|
789
|
-
callback(patch);
|
|
790
|
-
} }));
|
|
791
|
-
}
|
|
792
|
-
function diffLinesResultToPatch(diff) {
|
|
793
|
-
if (!diff) {
|
|
794
|
-
return;
|
|
795
|
-
}
|
|
796
|
-
diff.push({ value: "", lines: [] });
|
|
797
|
-
function contextLines(lines) {
|
|
798
|
-
return lines.map(function(entry) {
|
|
799
|
-
return " " + entry;
|
|
800
|
-
});
|
|
801
|
-
}
|
|
802
|
-
const hunks = [];
|
|
803
|
-
let oldRangeStart = 0, newRangeStart = 0, curRange = [], oldLine = 1, newLine = 1;
|
|
804
|
-
for (let i = 0; i < diff.length; i++) {
|
|
805
|
-
const current = diff[i], lines = current.lines || splitLines(current.value);
|
|
806
|
-
current.lines = lines;
|
|
807
|
-
if (current.added || current.removed) {
|
|
808
|
-
if (!oldRangeStart) {
|
|
809
|
-
const prev = diff[i - 1];
|
|
810
|
-
oldRangeStart = oldLine;
|
|
811
|
-
newRangeStart = newLine;
|
|
812
|
-
if (prev) {
|
|
813
|
-
curRange = context > 0 ? contextLines(prev.lines.slice(-context)) : [];
|
|
814
|
-
oldRangeStart -= curRange.length;
|
|
815
|
-
newRangeStart -= curRange.length;
|
|
816
|
-
}
|
|
817
|
-
}
|
|
818
|
-
for (const line of lines) {
|
|
819
|
-
curRange.push((current.added ? "+" : "-") + line);
|
|
820
|
-
}
|
|
821
|
-
if (current.added) {
|
|
822
|
-
newLine += lines.length;
|
|
823
|
-
} else {
|
|
824
|
-
oldLine += lines.length;
|
|
825
|
-
}
|
|
826
|
-
} else {
|
|
827
|
-
if (oldRangeStart) {
|
|
828
|
-
if (lines.length <= context * 2 && i < diff.length - 2) {
|
|
829
|
-
for (const line of contextLines(lines)) {
|
|
830
|
-
curRange.push(line);
|
|
831
|
-
}
|
|
832
|
-
} else {
|
|
833
|
-
const contextSize = Math.min(lines.length, context);
|
|
834
|
-
for (const line of contextLines(lines.slice(0, contextSize))) {
|
|
835
|
-
curRange.push(line);
|
|
836
|
-
}
|
|
837
|
-
const hunk = {
|
|
838
|
-
oldStart: oldRangeStart,
|
|
839
|
-
oldLines: oldLine - oldRangeStart + contextSize,
|
|
840
|
-
newStart: newRangeStart,
|
|
841
|
-
newLines: newLine - newRangeStart + contextSize,
|
|
842
|
-
lines: curRange
|
|
843
|
-
};
|
|
844
|
-
hunks.push(hunk);
|
|
845
|
-
oldRangeStart = 0;
|
|
846
|
-
newRangeStart = 0;
|
|
847
|
-
curRange = [];
|
|
848
|
-
}
|
|
849
|
-
}
|
|
850
|
-
oldLine += lines.length;
|
|
851
|
-
newLine += lines.length;
|
|
852
|
-
}
|
|
853
|
-
}
|
|
854
|
-
for (const hunk of hunks) {
|
|
855
|
-
for (let i = 0; i < hunk.lines.length; i++) {
|
|
856
|
-
if (hunk.lines[i].endsWith("\n")) {
|
|
857
|
-
hunk.lines[i] = hunk.lines[i].slice(0, -1);
|
|
858
|
-
} else {
|
|
859
|
-
hunk.lines.splice(i + 1, 0, "\");
|
|
860
|
-
i++;
|
|
861
|
-
}
|
|
862
|
-
}
|
|
863
|
-
}
|
|
864
|
-
return {
|
|
865
|
-
oldFileName,
|
|
866
|
-
newFileName,
|
|
867
|
-
oldHeader,
|
|
868
|
-
newHeader,
|
|
869
|
-
hunks
|
|
870
|
-
};
|
|
871
|
-
}
|
|
872
|
-
}
|
|
873
|
-
function formatPatch(patch) {
|
|
874
|
-
if (Array.isArray(patch)) {
|
|
875
|
-
return patch.map(formatPatch).join("\n");
|
|
876
|
-
}
|
|
877
|
-
const ret = [];
|
|
878
|
-
if (patch.oldFileName == patch.newFileName) {
|
|
879
|
-
ret.push("Index: " + patch.oldFileName);
|
|
880
|
-
}
|
|
881
|
-
ret.push("===================================================================");
|
|
882
|
-
ret.push("--- " + patch.oldFileName + (typeof patch.oldHeader === "undefined" ? "" : " " + patch.oldHeader));
|
|
883
|
-
ret.push("+++ " + patch.newFileName + (typeof patch.newHeader === "undefined" ? "" : " " + patch.newHeader));
|
|
884
|
-
for (let i = 0; i < patch.hunks.length; i++) {
|
|
885
|
-
const hunk = patch.hunks[i];
|
|
886
|
-
if (hunk.oldLines === 0) {
|
|
887
|
-
hunk.oldStart -= 1;
|
|
888
|
-
}
|
|
889
|
-
if (hunk.newLines === 0) {
|
|
890
|
-
hunk.newStart -= 1;
|
|
891
|
-
}
|
|
892
|
-
ret.push("@@ -" + hunk.oldStart + "," + hunk.oldLines + " +" + hunk.newStart + "," + hunk.newLines + " @@");
|
|
893
|
-
for (const line of hunk.lines) {
|
|
894
|
-
ret.push(line);
|
|
895
|
-
}
|
|
896
|
-
}
|
|
897
|
-
return ret.join("\n") + "\n";
|
|
898
|
-
}
|
|
899
|
-
function createTwoFilesPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
|
|
900
|
-
if (typeof options === "function") {
|
|
901
|
-
options = { callback: options };
|
|
902
|
-
}
|
|
903
|
-
if (!(options === null || options === void 0 ? void 0 : options.callback)) {
|
|
904
|
-
const patchObj = structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options);
|
|
905
|
-
if (!patchObj) {
|
|
906
|
-
return;
|
|
907
|
-
}
|
|
908
|
-
return formatPatch(patchObj);
|
|
909
|
-
} else {
|
|
910
|
-
const { callback } = options;
|
|
911
|
-
structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, Object.assign(Object.assign({}, options), { callback: (patchObj) => {
|
|
912
|
-
if (!patchObj) {
|
|
913
|
-
callback(void 0);
|
|
914
|
-
} else {
|
|
915
|
-
callback(formatPatch(patchObj));
|
|
916
|
-
}
|
|
917
|
-
} }));
|
|
918
|
-
}
|
|
919
|
-
}
|
|
920
|
-
function splitLines(text) {
|
|
921
|
-
const hasTrailingNl = text.endsWith("\n");
|
|
922
|
-
const result = text.split("\n").map((line) => line + "\n");
|
|
923
|
-
if (hasTrailingNl) {
|
|
924
|
-
result.pop();
|
|
925
|
-
} else {
|
|
926
|
-
result.push(result.pop().slice(0, -1));
|
|
927
|
-
}
|
|
928
|
-
return result;
|
|
523
|
+
function nativeTimeMs(value) {
|
|
524
|
+
const time3 = typeof value === "number" ? value : typeof value === "string" ? Date.parse(value) : Number.NaN;
|
|
525
|
+
return Number.isFinite(time3) && time3 > 0 ? Math.floor(time3) : null;
|
|
929
526
|
}
|
|
930
527
|
|
|
931
|
-
// dist/
|
|
932
|
-
import {
|
|
933
|
-
import {
|
|
528
|
+
// dist/session-import.js
|
|
529
|
+
import { createReadStream as createReadStream2 } from "node:fs";
|
|
530
|
+
import { opendir as opendir2, realpath, stat } from "node:fs/promises";
|
|
531
|
+
import os2 from "node:os";
|
|
934
532
|
import path5 from "node:path";
|
|
533
|
+
import { createInterface as createInterface2 } from "node:readline";
|
|
534
|
+
|
|
535
|
+
// ../../harness-adapter/dist/session-import.js
|
|
536
|
+
import { lstat as lstat2 } from "node:fs/promises";
|
|
935
537
|
|
|
936
538
|
// ../../../node_modules/zod/v4/classic/external.js
|
|
937
539
|
var external_exports = {};
|
|
@@ -1699,10 +1301,10 @@ function mergeDefs(...defs) {
|
|
|
1699
1301
|
function cloneDef(schema) {
|
|
1700
1302
|
return mergeDefs(schema._zod.def);
|
|
1701
1303
|
}
|
|
1702
|
-
function getElementAtPath(obj,
|
|
1703
|
-
if (!
|
|
1304
|
+
function getElementAtPath(obj, path9) {
|
|
1305
|
+
if (!path9)
|
|
1704
1306
|
return obj;
|
|
1705
|
-
return
|
|
1307
|
+
return path9.reduce((acc, key) => acc?.[key], obj);
|
|
1706
1308
|
}
|
|
1707
1309
|
function promiseAllObject(promisesObj) {
|
|
1708
1310
|
const keys = Object.keys(promisesObj);
|
|
@@ -2111,11 +1713,11 @@ function explicitlyAborted(x, startIndex = 0) {
|
|
|
2111
1713
|
}
|
|
2112
1714
|
return false;
|
|
2113
1715
|
}
|
|
2114
|
-
function prefixIssues(
|
|
1716
|
+
function prefixIssues(path9, issues) {
|
|
2115
1717
|
return issues.map((iss) => {
|
|
2116
1718
|
var _a3;
|
|
2117
1719
|
(_a3 = iss).path ?? (_a3.path = []);
|
|
2118
|
-
iss.path.unshift(
|
|
1720
|
+
iss.path.unshift(path9);
|
|
2119
1721
|
return iss;
|
|
2120
1722
|
});
|
|
2121
1723
|
}
|
|
@@ -2262,16 +1864,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
|
|
|
2262
1864
|
}
|
|
2263
1865
|
function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
2264
1866
|
const fieldErrors = { _errors: [] };
|
|
2265
|
-
const processError = (error52,
|
|
1867
|
+
const processError = (error52, path9 = []) => {
|
|
2266
1868
|
for (const issue2 of error52.issues) {
|
|
2267
1869
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
2268
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
1870
|
+
issue2.errors.map((issues) => processError({ issues }, [...path9, ...issue2.path]));
|
|
2269
1871
|
} else if (issue2.code === "invalid_key") {
|
|
2270
|
-
processError({ issues: issue2.issues }, [...
|
|
1872
|
+
processError({ issues: issue2.issues }, [...path9, ...issue2.path]);
|
|
2271
1873
|
} else if (issue2.code === "invalid_element") {
|
|
2272
|
-
processError({ issues: issue2.issues }, [...
|
|
1874
|
+
processError({ issues: issue2.issues }, [...path9, ...issue2.path]);
|
|
2273
1875
|
} else {
|
|
2274
|
-
const fullpath = [...
|
|
1876
|
+
const fullpath = [...path9, ...issue2.path];
|
|
2275
1877
|
if (fullpath.length === 0) {
|
|
2276
1878
|
fieldErrors._errors.push(mapper(issue2));
|
|
2277
1879
|
} else {
|
|
@@ -2298,17 +1900,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
|
2298
1900
|
}
|
|
2299
1901
|
function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
2300
1902
|
const result = { errors: [] };
|
|
2301
|
-
const processError = (error52,
|
|
1903
|
+
const processError = (error52, path9 = []) => {
|
|
2302
1904
|
var _a3, _b;
|
|
2303
1905
|
for (const issue2 of error52.issues) {
|
|
2304
1906
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
2305
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
1907
|
+
issue2.errors.map((issues) => processError({ issues }, [...path9, ...issue2.path]));
|
|
2306
1908
|
} else if (issue2.code === "invalid_key") {
|
|
2307
|
-
processError({ issues: issue2.issues }, [...
|
|
1909
|
+
processError({ issues: issue2.issues }, [...path9, ...issue2.path]);
|
|
2308
1910
|
} else if (issue2.code === "invalid_element") {
|
|
2309
|
-
processError({ issues: issue2.issues }, [...
|
|
1911
|
+
processError({ issues: issue2.issues }, [...path9, ...issue2.path]);
|
|
2310
1912
|
} else {
|
|
2311
|
-
const fullpath = [...
|
|
1913
|
+
const fullpath = [...path9, ...issue2.path];
|
|
2312
1914
|
if (fullpath.length === 0) {
|
|
2313
1915
|
result.errors.push(mapper(issue2));
|
|
2314
1916
|
continue;
|
|
@@ -2340,8 +1942,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
|
2340
1942
|
}
|
|
2341
1943
|
function toDotPath(_path) {
|
|
2342
1944
|
const segs = [];
|
|
2343
|
-
const
|
|
2344
|
-
for (const seg of
|
|
1945
|
+
const path9 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
1946
|
+
for (const seg of path9) {
|
|
2345
1947
|
if (typeof seg === "number")
|
|
2346
1948
|
segs.push(`[${seg}]`);
|
|
2347
1949
|
else if (typeof seg === "symbol")
|
|
@@ -5569,8 +5171,8 @@ function az_default() {
|
|
|
5569
5171
|
}
|
|
5570
5172
|
|
|
5571
5173
|
// ../../../node_modules/zod/v4/locales/be.js
|
|
5572
|
-
function getBelarusianPlural(
|
|
5573
|
-
const absCount = Math.abs(
|
|
5174
|
+
function getBelarusianPlural(count2, one, few, many) {
|
|
5175
|
+
const absCount = Math.abs(count2);
|
|
5574
5176
|
const lastDigit = absCount % 10;
|
|
5575
5177
|
const lastTwoDigits = absCount % 100;
|
|
5576
5178
|
if (lastTwoDigits >= 11 && lastTwoDigits <= 19) {
|
|
@@ -7648,8 +7250,8 @@ function hu_default() {
|
|
|
7648
7250
|
}
|
|
7649
7251
|
|
|
7650
7252
|
// ../../../node_modules/zod/v4/locales/hy.js
|
|
7651
|
-
function getArmenianPlural(
|
|
7652
|
-
return Math.abs(
|
|
7253
|
+
function getArmenianPlural(count2, one, many) {
|
|
7254
|
+
return Math.abs(count2) === 1 ? one : many;
|
|
7653
7255
|
}
|
|
7654
7256
|
function withDefiniteArticle(word) {
|
|
7655
7257
|
if (!word)
|
|
@@ -9777,8 +9379,8 @@ function ro_default() {
|
|
|
9777
9379
|
}
|
|
9778
9380
|
|
|
9779
9381
|
// ../../../node_modules/zod/v4/locales/ru.js
|
|
9780
|
-
function getRussianPlural(
|
|
9781
|
-
const absCount = Math.abs(
|
|
9382
|
+
function getRussianPlural(count2, one, few, many) {
|
|
9383
|
+
const absCount = Math.abs(count2);
|
|
9782
9384
|
const lastDigit = absCount % 10;
|
|
9783
9385
|
const lastTwoDigits = absCount % 100;
|
|
9784
9386
|
if (lastTwoDigits >= 11 && lastTwoDigits <= 19) {
|
|
@@ -15033,13 +14635,13 @@ function resolveRef(ref, ctx) {
|
|
|
15033
14635
|
if (!ref.startsWith("#")) {
|
|
15034
14636
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
15035
14637
|
}
|
|
15036
|
-
const
|
|
15037
|
-
if (
|
|
14638
|
+
const path9 = ref.slice(1).split("/").filter(Boolean);
|
|
14639
|
+
if (path9.length === 0) {
|
|
15038
14640
|
return ctx.rootSchema;
|
|
15039
14641
|
}
|
|
15040
14642
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
15041
|
-
if (
|
|
15042
|
-
const key =
|
|
14643
|
+
if (path9[0] === defsKey) {
|
|
14644
|
+
const key = path9[1];
|
|
15043
14645
|
if (!key || !ctx.defs[key]) {
|
|
15044
14646
|
throw new Error(`Reference not found: ${ref}`);
|
|
15045
14647
|
}
|
|
@@ -15447,6 +15049,15 @@ function date4(params) {
|
|
|
15447
15049
|
// ../../../node_modules/zod/v4/classic/external.js
|
|
15448
15050
|
config(en_default());
|
|
15449
15051
|
|
|
15052
|
+
// ../../shared-contracts/dist/delegation-read.js
|
|
15053
|
+
var REMOTE_THREAD_REPLY_MAX_BYTES = 16 * 1024 * 1024;
|
|
15054
|
+
var delegationReadParamsSchema = external_exports.strictObject({
|
|
15055
|
+
threadId: external_exports.string().min(1).max(1024),
|
|
15056
|
+
view: external_exports.enum(["result", "messages"]),
|
|
15057
|
+
cursor: external_exports.string().min(1).max(8192).optional(),
|
|
15058
|
+
limit: external_exports.number().int().min(1).max(100).optional()
|
|
15059
|
+
});
|
|
15060
|
+
|
|
15450
15061
|
// ../../shared-contracts/dist/credential-imports.js
|
|
15451
15062
|
var credentialSourceSchema = external_exports.object({
|
|
15452
15063
|
id: external_exports.string().min(1).max(256),
|
|
@@ -15517,6 +15128,153 @@ var harnessDisplaySetSchema = external_exports.strictObject({
|
|
|
15517
15128
|
initializeOnly: external_exports.boolean().optional()
|
|
15518
15129
|
});
|
|
15519
15130
|
|
|
15131
|
+
// ../../shared-contracts/dist/model-price-overrides.js
|
|
15132
|
+
var usdPerMillionTokens = external_exports.number().finite().nonnegative();
|
|
15133
|
+
var modelPriceOverrideSchema = external_exports.strictObject({
|
|
15134
|
+
input: usdPerMillionTokens,
|
|
15135
|
+
output: usdPerMillionTokens,
|
|
15136
|
+
cacheRead: usdPerMillionTokens.optional(),
|
|
15137
|
+
cacheWrite: usdPerMillionTokens.optional(),
|
|
15138
|
+
cacheWrite1h: usdPerMillionTokens.optional()
|
|
15139
|
+
});
|
|
15140
|
+
var modelPriceKeySchema = external_exports.string().max(512).refine((key) => key.trim() === key && key.length > 0, "Model ID is required");
|
|
15141
|
+
var modelPriceOverridesSchema = external_exports.strictObject({
|
|
15142
|
+
/** Absolute path of the Host's `pricing.json`. */
|
|
15143
|
+
path: external_exports.string(),
|
|
15144
|
+
entries: external_exports.array(external_exports.strictObject({ key: external_exports.string(), price: modelPriceOverrideSchema })),
|
|
15145
|
+
/** Why the existing file is unusable; the Host then ignores it and refuses to overwrite it. */
|
|
15146
|
+
error: external_exports.string().nullable()
|
|
15147
|
+
});
|
|
15148
|
+
var modelPriceOverridesGetSchema = external_exports.strictObject({});
|
|
15149
|
+
var modelPriceOverridesSetSchema = external_exports.strictObject({
|
|
15150
|
+
key: modelPriceKeySchema,
|
|
15151
|
+
price: modelPriceOverrideSchema.nullable(),
|
|
15152
|
+
previousKey: modelPriceKeySchema.optional()
|
|
15153
|
+
});
|
|
15154
|
+
var modelPriceDefaultParamsSchema = external_exports.strictObject({
|
|
15155
|
+
model: modelPriceKeySchema
|
|
15156
|
+
});
|
|
15157
|
+
var modelPriceSuggestionSchema = external_exports.strictObject({
|
|
15158
|
+
/** Verified from catalog canonical links, not inferred from names or equal prices. */
|
|
15159
|
+
official: external_exports.boolean().optional(),
|
|
15160
|
+
canonicalModelId: external_exports.string().min(1).optional(),
|
|
15161
|
+
provider: external_exports.string().min(1).max(512),
|
|
15162
|
+
model: external_exports.string().min(1).max(512),
|
|
15163
|
+
price: modelPriceOverrideSchema
|
|
15164
|
+
});
|
|
15165
|
+
var modelPriceDefaultResultSchema = external_exports.strictObject({
|
|
15166
|
+
price: modelPriceOverrideSchema.nullable(),
|
|
15167
|
+
/** Local catalog suggestions only; never used automatically for pricing. */
|
|
15168
|
+
suggestions: external_exports.array(modelPriceSuggestionSchema).max(6).optional()
|
|
15169
|
+
});
|
|
15170
|
+
|
|
15171
|
+
// ../../shared-contracts/dist/usage-statistics.js
|
|
15172
|
+
var USAGE_STATISTICS_RANGES = ["today", "7d", "30d", "90d", "all"];
|
|
15173
|
+
var count = external_exports.number().int().min(0).max(Number.MAX_SAFE_INTEGER);
|
|
15174
|
+
var localDate = external_exports.string().regex(/^\d{4}-\d{2}-\d{2}$/u);
|
|
15175
|
+
var harness = external_exports.string().min(1).max(128);
|
|
15176
|
+
var model = external_exports.string().min(1).max(512);
|
|
15177
|
+
var project = external_exports.string().min(1).max(4096);
|
|
15178
|
+
var usageStatisticsParamsSchema = external_exports.strictObject({
|
|
15179
|
+
range: external_exports.enum(USAGE_STATISTICS_RANGES),
|
|
15180
|
+
harness: harness.optional(),
|
|
15181
|
+
model: model.nullable().optional(),
|
|
15182
|
+
project: project.nullable().optional(),
|
|
15183
|
+
/** One local date inside the range. */
|
|
15184
|
+
date: localDate.optional()
|
|
15185
|
+
});
|
|
15186
|
+
var usageStatisticsTotalsSchema = external_exports.strictObject({
|
|
15187
|
+
requests: count,
|
|
15188
|
+
inputTokens: count,
|
|
15189
|
+
cachedInputTokens: count,
|
|
15190
|
+
cacheWriteInputTokens: count,
|
|
15191
|
+
cacheKnownInputTokens: count,
|
|
15192
|
+
outputTokens: count,
|
|
15193
|
+
reasoningOutputTokens: count,
|
|
15194
|
+
/** USD at the public price, summed over the priced requests only. */
|
|
15195
|
+
costUsd: external_exports.number().finite().min(0),
|
|
15196
|
+
/** Requests without a price (or the cache data the price needs); not in `costUsd`. */
|
|
15197
|
+
unpricedRequests: count,
|
|
15198
|
+
/**
|
|
15199
|
+
* Requests whose storage gave no token counts: counted as requests, with neither tokens nor
|
|
15200
|
+
* cost, and not as unpriced.
|
|
15201
|
+
*/
|
|
15202
|
+
unmeteredRequests: count
|
|
15203
|
+
});
|
|
15204
|
+
var totals = usageStatisticsTotalsSchema.shape;
|
|
15205
|
+
var usageStatisticsSessionSchema = external_exports.strictObject({
|
|
15206
|
+
harness,
|
|
15207
|
+
sessionId: external_exports.string().min(1).max(512),
|
|
15208
|
+
project: project.nullable(),
|
|
15209
|
+
/** Models the session used, most requests first. */
|
|
15210
|
+
models: external_exports.array(model).max(16),
|
|
15211
|
+
firstAtMs: count,
|
|
15212
|
+
lastAtMs: count,
|
|
15213
|
+
...totals
|
|
15214
|
+
});
|
|
15215
|
+
var usageStatisticsResultSchema = external_exports.strictObject({
|
|
15216
|
+
range: external_exports.enum(USAGE_STATISTICS_RANGES),
|
|
15217
|
+
/** First local date of the range; null for all time. */
|
|
15218
|
+
from: localDate.nullable(),
|
|
15219
|
+
to: localDate,
|
|
15220
|
+
/** The filters these figures apply, echoed so a late answer to older filters is recognised. */
|
|
15221
|
+
filters: external_exports.strictObject({
|
|
15222
|
+
harness: harness.nullable(),
|
|
15223
|
+
model: model.nullable(),
|
|
15224
|
+
unknownModel: external_exports.boolean(),
|
|
15225
|
+
project: project.nullable(),
|
|
15226
|
+
unknownProject: external_exports.boolean(),
|
|
15227
|
+
date: localDate.nullable()
|
|
15228
|
+
}),
|
|
15229
|
+
/** Reading of native storage: incomplete while the first read, or a refresh, is under way. */
|
|
15230
|
+
reading: external_exports.strictObject({ complete: external_exports.boolean(), sources: count, read: count }),
|
|
15231
|
+
/** Harnesses whose storage could not be read; their part is missing, the rest is complete. */
|
|
15232
|
+
failures: external_exports.array(external_exports.strictObject({ harness, message: external_exports.string().max(2048) })).max(256),
|
|
15233
|
+
/** Every value seen in the range, ignoring the filters, to choose filters from. */
|
|
15234
|
+
options: external_exports.strictObject({
|
|
15235
|
+
harnesses: external_exports.array(harness).max(256),
|
|
15236
|
+
models: external_exports.array(model.nullable()).max(4096),
|
|
15237
|
+
projects: external_exports.array(project.nullable()).max(4096)
|
|
15238
|
+
}),
|
|
15239
|
+
/** Current display metadata, scoped by Harness. Never a pricing or filter identity.
|
|
15240
|
+
* Optional for older Hosts; missing/conflicting labels fall back to the native model ID.
|
|
15241
|
+
*/
|
|
15242
|
+
modelLabels: external_exports.array(external_exports.strictObject({ harness, model, label: model })).max(4096).optional(),
|
|
15243
|
+
/** Native credits, all filters applied, never combined across Harnesses or treated as USD.
|
|
15244
|
+
* Only groups with at least one reported value appear; reportedRequests exposes partial data.
|
|
15245
|
+
*/
|
|
15246
|
+
credits: external_exports.array(external_exports.strictObject({
|
|
15247
|
+
harness,
|
|
15248
|
+
model: model.nullable(),
|
|
15249
|
+
credits: external_exports.number().finite().min(0),
|
|
15250
|
+
reportedRequests: count,
|
|
15251
|
+
requests: count
|
|
15252
|
+
})).max(4096).optional(),
|
|
15253
|
+
/** All filters applied. */
|
|
15254
|
+
totals: usageStatisticsTotalsSchema,
|
|
15255
|
+
/** Each date and Harness of the range: every filter except the day. */
|
|
15256
|
+
daily: external_exports.array(external_exports.strictObject({ date: localDate, harness, ...totals })).max(2e5),
|
|
15257
|
+
/** Local weekday (0 = Sunday) and hour, all filters applied. */
|
|
15258
|
+
hourly: external_exports.array(external_exports.strictObject({
|
|
15259
|
+
weekday: external_exports.number().int().min(0).max(6),
|
|
15260
|
+
hour: external_exports.number().int().min(0).max(23),
|
|
15261
|
+
...totals
|
|
15262
|
+
})).max(168),
|
|
15263
|
+
byHarness: external_exports.array(external_exports.strictObject({ harness, ...totals })).max(256),
|
|
15264
|
+
byModel: external_exports.array(external_exports.strictObject({
|
|
15265
|
+
model: model.nullable(),
|
|
15266
|
+
...totals,
|
|
15267
|
+
/** Requests priced by what the Harness recorded they cost, not by a price list. */
|
|
15268
|
+
harnessPricedRequests: count
|
|
15269
|
+
})).max(4096),
|
|
15270
|
+
byProject: external_exports.array(external_exports.strictObject({ project: project.nullable(), ...totals })).max(4096),
|
|
15271
|
+
/**
|
|
15272
|
+
* The sessions that spent the most, by cost and by tokens without cache, all filters applied;
|
|
15273
|
+
* requests without a native session are not listed here but count everywhere else.
|
|
15274
|
+
*/
|
|
15275
|
+
sessions: external_exports.array(usageStatisticsSessionSchema).max(100)
|
|
15276
|
+
});
|
|
15277
|
+
|
|
15520
15278
|
// ../../shared-contracts/dist/ids.js
|
|
15521
15279
|
var opaqueIdSchema = external_exports.string().refine((value) => value.trim().length > 0, {
|
|
15522
15280
|
message: "Identifier must not be empty or whitespace"
|
|
@@ -15527,6 +15285,10 @@ var hostTurnIdSchema = opaqueIdSchema.brand();
|
|
|
15527
15285
|
var hostItemIdSchema = opaqueIdSchema.brand();
|
|
15528
15286
|
var hostInteractionIdSchema = opaqueIdSchema.brand();
|
|
15529
15287
|
|
|
15288
|
+
// ../../shared-contracts/dist/thread-prewarm.js
|
|
15289
|
+
var threadPrewarmDiscardParamsSchema = external_exports.object({ threadId: hostThreadIdSchema });
|
|
15290
|
+
var threadPrewarmDiscardResultSchema = external_exports.object({ discarded: external_exports.boolean() });
|
|
15291
|
+
|
|
15530
15292
|
// ../../shared-contracts/dist/harness-plugins.js
|
|
15531
15293
|
var HARNESS_PLUGIN_MANIFEST_MAX_BYTES = 32 * 1024;
|
|
15532
15294
|
var HARNESS_PLUGIN_ICON_MAX_BYTES = 128 * 1024;
|
|
@@ -15534,13 +15296,40 @@ var HARNESS_PLUGIN_LIMIT = 128;
|
|
|
15534
15296
|
var harnessPluginIdSchema = external_exports.string().min(1).max(128).regex(/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/u).refine((id) => id !== "codex", "The official Codex identity is reserved").pipe(harnessIdSchema);
|
|
15535
15297
|
var relativeResourceSchema = external_exports.string().min(1).max(512).refine((value) => !/[\\\u0000:#?]/u.test(value) && !value.startsWith("/") && !value.split("/").some((part) => part === ".." || part === ""), "Plugin resources must be relative paths inside the plugin");
|
|
15536
15298
|
var documentationUrlSchema = external_exports.url().refine((value) => /^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(value), "Plugin documentation links must be credential-free HTTPS URLs");
|
|
15299
|
+
var localizedTextSchema = external_exports.object({ en: external_exports.string().max(4096), "zh-CN": external_exports.string().max(4096).optional() }).strict();
|
|
15300
|
+
var harnessInstallationGuideSchema = external_exports.object({
|
|
15301
|
+
commands: external_exports.array(external_exports.object({ terminal: external_exports.string().max(256), command: external_exports.string().max(4096) }).strict()).max(8),
|
|
15302
|
+
before: localizedTextSchema.optional(),
|
|
15303
|
+
after: localizedTextSchema.optional(),
|
|
15304
|
+
downloads: external_exports.array(external_exports.object({ label: external_exports.string().max(128), url: documentationUrlSchema }).strict()).max(8).optional()
|
|
15305
|
+
}).strict();
|
|
15537
15306
|
var pluginPresentationShape = {
|
|
15538
15307
|
id: harnessPluginIdSchema,
|
|
15539
15308
|
name: external_exports.string().trim().min(1).max(128),
|
|
15540
15309
|
version: external_exports.string().min(1).max(128),
|
|
15310
|
+
/** Capability-only plugin; omitted for existing session-capable plugins. */
|
|
15311
|
+
kind: external_exports.literal("usage").optional(),
|
|
15312
|
+
/** Original image styling or bounded vector paths; never arbitrary CSS/SVG markup. */
|
|
15313
|
+
iconStyle: external_exports.object({
|
|
15314
|
+
vector: external_exports.object({
|
|
15315
|
+
viewBox: external_exports.string().max(128).regex(/^-?\d+(?:\.\d+)?(?: +-?\d+(?:\.\d+)?){3}$/u),
|
|
15316
|
+
color: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu),
|
|
15317
|
+
paths: external_exports.array(external_exports.object({
|
|
15318
|
+
d: external_exports.string().min(1).max(32768).regex(/^[MmLlHhVvCcSsQqTtAaZz\d.,+eE\s-]+$/u),
|
|
15319
|
+
fillRule: external_exports.enum(["evenodd", "nonzero"]).optional(),
|
|
15320
|
+
fill: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu).optional()
|
|
15321
|
+
}).strict()).min(1).max(32)
|
|
15322
|
+
}).strict().optional(),
|
|
15323
|
+
background: external_exports.string().regex(/^#[a-f0-9]{6}$/iu).optional(),
|
|
15324
|
+
borderRadius: external_exports.number().min(0).max(50).optional(),
|
|
15325
|
+
paddingRatio: external_exports.number().min(0).max(0.25).optional()
|
|
15326
|
+
}).strict().optional(),
|
|
15327
|
+
installation: harnessInstallationGuideSchema.optional(),
|
|
15328
|
+
notice: localizedTextSchema.optional(),
|
|
15541
15329
|
/** The factory accepts a persisted local entrypoint through its construction context. */
|
|
15542
15330
|
launchCommand: external_exports.literal(true).optional(),
|
|
15543
15331
|
links: external_exports.object({
|
|
15332
|
+
website: documentationUrlSchema.optional(),
|
|
15544
15333
|
documentation: documentationUrlSchema.optional(),
|
|
15545
15334
|
installation: documentationUrlSchema.optional()
|
|
15546
15335
|
}).strict().optional()
|
|
@@ -15594,6 +15383,9 @@ var consoleOpenResultSchema = external_exports.strictObject({
|
|
|
15594
15383
|
url: external_exports.string().max(2048).regex(/^http:\/\/(?:127\.0\.0\.1|localhost):\d{1,5}\/(?:\?.*)?$/u)
|
|
15595
15384
|
});
|
|
15596
15385
|
var CONSOLE_HOST_METHODS = Object.freeze([
|
|
15386
|
+
"codexhost/console/remote-connections",
|
|
15387
|
+
"codexhost/runtime/status",
|
|
15388
|
+
"codexhost/remote/ssh-setup",
|
|
15597
15389
|
"codexhost/harness/plugins/list",
|
|
15598
15390
|
"codexhost/harness/display-settings/get",
|
|
15599
15391
|
"codexhost/harness/display-settings/set",
|
|
@@ -15614,6 +15406,10 @@ var CONSOLE_HOST_METHODS = Object.freeze([
|
|
|
15614
15406
|
"codexhost/account/list",
|
|
15615
15407
|
"codexhost/account/refresh",
|
|
15616
15408
|
"codexhost/account/usage/inspect",
|
|
15409
|
+
"codexhost/usage/model-prices/get",
|
|
15410
|
+
"codexhost/usage/model-prices/set",
|
|
15411
|
+
"codexhost/usage/model-prices/default",
|
|
15412
|
+
"codexhost/usage/statistics/get",
|
|
15617
15413
|
"codexhost/update/check",
|
|
15618
15414
|
"codexhost/update/start",
|
|
15619
15415
|
"codexhost/update/status"
|
|
@@ -15678,6 +15474,7 @@ var threadUsageSnapshotSchema = external_exports.object({
|
|
|
15678
15474
|
cacheWriteInputTokens: nonNegativeSafeIntegerSchema.optional(),
|
|
15679
15475
|
outputTokens: nonNegativeSafeIntegerSchema.optional(),
|
|
15680
15476
|
outputTokensPerSecond: finiteNonNegativeNumberSchema.optional(),
|
|
15477
|
+
apiOutputTokensPerSecond: finiteNonNegativeNumberSchema.optional(),
|
|
15681
15478
|
reasoningOutputTokens: nonNegativeSafeIntegerSchema.optional(),
|
|
15682
15479
|
totalTokens: nonNegativeSafeIntegerSchema.optional(),
|
|
15683
15480
|
totalCostUsd: finiteNonNegativeNumberSchema.optional(),
|
|
@@ -15689,7 +15486,11 @@ var threadUsageSnapshotSchema = external_exports.object({
|
|
|
15689
15486
|
planFiveHourUsedPercent: cacheHitRatePercentSchema.optional(),
|
|
15690
15487
|
planFiveHourResetsAtUnix: nonNegativeSafeIntegerSchema.optional(),
|
|
15691
15488
|
planSevenDayUsedPercent: cacheHitRatePercentSchema.optional(),
|
|
15692
|
-
planSevenDayResetsAtUnix: nonNegativeSafeIntegerSchema.optional()
|
|
15489
|
+
planSevenDayResetsAtUnix: nonNegativeSafeIntegerSchema.optional(),
|
|
15490
|
+
sessionCacheHitRatePercent: cacheHitRatePercentSchema.optional(),
|
|
15491
|
+
timeToFirstOutputMs: nonNegativeSafeIntegerSchema.optional(),
|
|
15492
|
+
costSource: external_exports.enum(["publicPrice", "native"]).optional(),
|
|
15493
|
+
unpricedModels: external_exports.array(external_exports.string().min(1)).min(1).optional()
|
|
15693
15494
|
}).strict().superRefine((usage, context) => {
|
|
15694
15495
|
if (Object.keys(usage).length === 0) {
|
|
15695
15496
|
context.addIssue({ code: "custom", message: "Thread Usage must contain a reliable field" });
|
|
@@ -15710,6 +15511,20 @@ var threadUsageSnapshotSchema = external_exports.object({
|
|
|
15710
15511
|
path: ["contextWindowTokens"]
|
|
15711
15512
|
});
|
|
15712
15513
|
}
|
|
15514
|
+
if (usage.costSource !== void 0 && usage.totalCostUsd === void 0) {
|
|
15515
|
+
context.addIssue({
|
|
15516
|
+
code: "custom",
|
|
15517
|
+
message: "Thread Usage costSource must be provided with totalCostUsd",
|
|
15518
|
+
path: ["costSource"]
|
|
15519
|
+
});
|
|
15520
|
+
}
|
|
15521
|
+
if (usage.unpricedModels !== void 0 && usage.costSource !== "publicPrice") {
|
|
15522
|
+
context.addIssue({
|
|
15523
|
+
code: "custom",
|
|
15524
|
+
message: "Thread Usage unpricedModels must be provided with a publicPrice cost",
|
|
15525
|
+
path: ["unpricedModels"]
|
|
15526
|
+
});
|
|
15527
|
+
}
|
|
15713
15528
|
if (usage.planFiveHourResetsAtUnix !== void 0 && usage.planFiveHourUsedPercent === void 0) {
|
|
15714
15529
|
context.addIssue({
|
|
15715
15530
|
code: "custom",
|
|
@@ -15979,27 +15794,27 @@ var harnessModelCatalogSchema = external_exports.object({
|
|
|
15979
15794
|
}).strict().superRefine((catalog, context) => {
|
|
15980
15795
|
const refs = /* @__PURE__ */ new Set();
|
|
15981
15796
|
const thinkingIds = new Set(catalog.thinkingOptions.map(({ id }) => id));
|
|
15982
|
-
for (const [index,
|
|
15983
|
-
if (refs.has(
|
|
15797
|
+
for (const [index, model2] of catalog.models.entries()) {
|
|
15798
|
+
if (refs.has(model2.ref.id)) {
|
|
15984
15799
|
context.addIssue({
|
|
15985
15800
|
code: "custom",
|
|
15986
15801
|
message: "Model Catalog refs must be unique",
|
|
15987
15802
|
path: ["models", index, "ref", "id"]
|
|
15988
15803
|
});
|
|
15989
15804
|
}
|
|
15990
|
-
refs.add(
|
|
15991
|
-
if (
|
|
15992
|
-
if (refs.has(
|
|
15805
|
+
refs.add(model2.ref.id);
|
|
15806
|
+
if (model2.fastModel) {
|
|
15807
|
+
if (refs.has(model2.fastModel.id) || catalog.models.some((entry) => entry.ref.id === model2.fastModel?.id)) {
|
|
15993
15808
|
context.addIssue({
|
|
15994
15809
|
code: "custom",
|
|
15995
15810
|
message: "Fast Model refs must be distinct and unique",
|
|
15996
15811
|
path: ["models", index, "fastModel"]
|
|
15997
15812
|
});
|
|
15998
15813
|
}
|
|
15999
|
-
refs.add(
|
|
15814
|
+
refs.add(model2.fastModel.id);
|
|
16000
15815
|
}
|
|
16001
15816
|
const supportedThinkingIds = /* @__PURE__ */ new Set();
|
|
16002
|
-
for (const [optionIndex, optionId] of (
|
|
15817
|
+
for (const [optionIndex, optionId] of (model2.supportedThinkingOptionIds ?? []).entries()) {
|
|
16003
15818
|
if (supportedThinkingIds.has(optionId)) {
|
|
16004
15819
|
context.addIssue({
|
|
16005
15820
|
code: "custom",
|
|
@@ -16539,9 +16354,404 @@ var updateStatusResultSchema = external_exports.strictObject({
|
|
|
16539
16354
|
status: updateStatusSchema.nullable()
|
|
16540
16355
|
});
|
|
16541
16356
|
|
|
16357
|
+
// ../../shared-contracts/dist/remote-runtime.js
|
|
16358
|
+
var remoteUpdatePhaseSchema = external_exports.enum([
|
|
16359
|
+
"idle",
|
|
16360
|
+
"installing",
|
|
16361
|
+
"restarting",
|
|
16362
|
+
"succeeded",
|
|
16363
|
+
"failed"
|
|
16364
|
+
]);
|
|
16365
|
+
var runtimeStatusSchema = external_exports.object({
|
|
16366
|
+
runningVersion: external_exports.string().nullable(),
|
|
16367
|
+
installedVersion: external_exports.string().nullable(),
|
|
16368
|
+
restartRequired: external_exports.boolean(),
|
|
16369
|
+
remote: external_exports.boolean(),
|
|
16370
|
+
updateSupported: external_exports.boolean(),
|
|
16371
|
+
update: external_exports.object({
|
|
16372
|
+
phase: remoteUpdatePhaseSchema,
|
|
16373
|
+
targetVersion: external_exports.string().nullable(),
|
|
16374
|
+
error: external_exports.string().nullable()
|
|
16375
|
+
})
|
|
16376
|
+
});
|
|
16377
|
+
var remoteUpdateParamsSchema = external_exports.object({
|
|
16378
|
+
version: external_exports.string().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/u)
|
|
16379
|
+
}).strict();
|
|
16380
|
+
var remoteSshSetupParamsSchema = external_exports.object({
|
|
16381
|
+
hostname: external_exports.string().min(1).max(1024).refine((value) => !value.startsWith("-") && !/\s/u.test(value)),
|
|
16382
|
+
port: external_exports.number().int().min(1).max(65535).nullable(),
|
|
16383
|
+
identity: external_exports.string().max(4096).nullable(),
|
|
16384
|
+
action: external_exports.enum(["inspect", "install", "update", "repair", "uninstall"]),
|
|
16385
|
+
uninstallPackage: external_exports.boolean().optional(),
|
|
16386
|
+
version: external_exports.string().regex(/^\d+\.\d+\.\d+$/u).nullable()
|
|
16387
|
+
}).strict();
|
|
16388
|
+
var remoteSshSetupResultSchema = external_exports.object({ state: external_exports.enum(["installed", "not-installed"]) }).strict();
|
|
16389
|
+
|
|
16390
|
+
// ../../shared-contracts/dist/remote-connections.js
|
|
16391
|
+
var hostId = external_exports.string().min(1).max(1024);
|
|
16392
|
+
var codexSshConnectionSchema = external_exports.object({
|
|
16393
|
+
hostId,
|
|
16394
|
+
displayName: external_exports.string().min(1).max(1024),
|
|
16395
|
+
source: external_exports.enum(["codex-managed", "discovered"]),
|
|
16396
|
+
sshAlias: external_exports.string().max(1024).nullable(),
|
|
16397
|
+
sshHost: external_exports.string().min(1).max(1024),
|
|
16398
|
+
sshPort: external_exports.number().int().min(1).max(65535).nullable(),
|
|
16399
|
+
identity: external_exports.string().max(4096).nullable(),
|
|
16400
|
+
autoConnect: external_exports.boolean(),
|
|
16401
|
+
connectionAnalyticsId: external_exports.string().max(1024).optional()
|
|
16402
|
+
});
|
|
16403
|
+
var codexSshDraftSchema = external_exports.strictObject({
|
|
16404
|
+
displayName: external_exports.string().min(1).max(1024),
|
|
16405
|
+
hostname: external_exports.string().min(1).max(1024),
|
|
16406
|
+
sshPort: external_exports.number().int().min(1).max(65535).nullable(),
|
|
16407
|
+
identity: external_exports.string().max(4096).nullable()
|
|
16408
|
+
});
|
|
16409
|
+
var remoteConnectionsRequestSchema = external_exports.discriminatedUnion("action", [
|
|
16410
|
+
external_exports.strictObject({ action: external_exports.literal("list") }),
|
|
16411
|
+
external_exports.strictObject({
|
|
16412
|
+
action: external_exports.literal("read-thread"),
|
|
16413
|
+
hostId: hostId.refine((id) => id !== "local"),
|
|
16414
|
+
input: delegationReadParamsSchema
|
|
16415
|
+
}),
|
|
16416
|
+
external_exports.strictObject({
|
|
16417
|
+
action: external_exports.literal("save"),
|
|
16418
|
+
draft: codexSshDraftSchema,
|
|
16419
|
+
previous: codexSshConnectionSchema.nullable()
|
|
16420
|
+
}),
|
|
16421
|
+
external_exports.strictObject({ action: external_exports.literal("remove"), previous: codexSshConnectionSchema }),
|
|
16422
|
+
external_exports.strictObject({ action: external_exports.literal("connect"), hostId, enabled: external_exports.boolean() }),
|
|
16423
|
+
external_exports.strictObject({ action: external_exports.literal("state"), hostId }),
|
|
16424
|
+
external_exports.strictObject({ action: external_exports.literal("runtime"), hostId }),
|
|
16425
|
+
external_exports.strictObject({
|
|
16426
|
+
action: external_exports.literal("update"),
|
|
16427
|
+
hostId: hostId.refine((id) => id !== "local"),
|
|
16428
|
+
version: remoteUpdateParamsSchema.shape.version
|
|
16429
|
+
})
|
|
16430
|
+
]);
|
|
16431
|
+
var remoteConnectionsReplySchema = external_exports.union([
|
|
16432
|
+
external_exports.strictObject({ result: jsonValueSchema }),
|
|
16433
|
+
external_exports.strictObject({ error: external_exports.strictObject({ code: external_exports.number().int(), message: external_exports.string() }) })
|
|
16434
|
+
]);
|
|
16435
|
+
|
|
16542
16436
|
// ../../shared-contracts/dist/index.js
|
|
16543
16437
|
var workspaceContractVersionSchema = external_exports.literal(WORKSPACE_CONTRACT_VERSION);
|
|
16544
16438
|
|
|
16439
|
+
// ../../harness-adapter/dist/session-import.js
|
|
16440
|
+
var SessionImportChangedError = class extends Error {
|
|
16441
|
+
constructor(message3 = "Native Session changed during discovery; refresh and retry") {
|
|
16442
|
+
super(message3);
|
|
16443
|
+
this.name = "SessionImportChangedError";
|
|
16444
|
+
}
|
|
16445
|
+
};
|
|
16446
|
+
function isMissingFileError(error51) {
|
|
16447
|
+
return typeof error51 === "object" && error51 !== null && "code" in error51 && error51.code === "ENOENT";
|
|
16448
|
+
}
|
|
16449
|
+
function sameFileFingerprint(left, right) {
|
|
16450
|
+
return left === null || right === null ? left === right : left.dev === right.dev && left.ino === right.ino && left.size === right.size && left.mtimeMs === right.mtimeMs && left.ctimeMs === right.ctimeMs;
|
|
16451
|
+
}
|
|
16452
|
+
var STORAGE_ACCESS_ERRORS = /* @__PURE__ */ new Set(["EACCES", "EPERM", "EIO", "EMFILE", "ENFILE"]);
|
|
16453
|
+
function isStorageAccessError(error51) {
|
|
16454
|
+
return typeof error51 === "object" && error51 !== null && "code" in error51 && typeof error51.code === "string" && STORAGE_ACCESS_ERRORS.has(error51.code);
|
|
16455
|
+
}
|
|
16456
|
+
async function optionalLstat(file2) {
|
|
16457
|
+
try {
|
|
16458
|
+
return await lstat2(file2);
|
|
16459
|
+
} catch (error51) {
|
|
16460
|
+
if (isMissingFileError(error51))
|
|
16461
|
+
return null;
|
|
16462
|
+
throw error51;
|
|
16463
|
+
}
|
|
16464
|
+
}
|
|
16465
|
+
async function readStableFiles(files, read) {
|
|
16466
|
+
const before = await Promise.all(files.map(optionalLstat));
|
|
16467
|
+
const value = await read(before);
|
|
16468
|
+
const after = await Promise.all(files.map(optionalLstat));
|
|
16469
|
+
if (before.some((info, index) => !sameFileFingerprint(info, after[index] ?? null)))
|
|
16470
|
+
throw new SessionImportChangedError();
|
|
16471
|
+
return value;
|
|
16472
|
+
}
|
|
16473
|
+
function sessionImportTitle(value, maxLength = HARNESS_SESSION_IMPORT_TITLE_MAX_LENGTH) {
|
|
16474
|
+
if (typeof value !== "string")
|
|
16475
|
+
return null;
|
|
16476
|
+
const normalized = value.replaceAll("\0", "").replaceAll(/\s+/gu, " ").trim();
|
|
16477
|
+
if (!normalized)
|
|
16478
|
+
return null;
|
|
16479
|
+
if (normalized.length <= maxLength)
|
|
16480
|
+
return normalized;
|
|
16481
|
+
const characters = [...normalized];
|
|
16482
|
+
if (characters.length <= maxLength)
|
|
16483
|
+
return normalized;
|
|
16484
|
+
return `${characters.slice(0, maxLength - 1).join("").trimEnd()}…`;
|
|
16485
|
+
}
|
|
16486
|
+
function sessionImportCandidate(input) {
|
|
16487
|
+
const time3 = typeof input.updatedAt === "number" ? input.updatedAt : typeof input.updatedAt === "string" ? Date.parse(input.updatedAt) : Number.NaN;
|
|
16488
|
+
const parsed = harnessSessionImportCandidateSchema.safeParse({
|
|
16489
|
+
nativeSessionId: input.nativeSessionId,
|
|
16490
|
+
cwd: input.cwd,
|
|
16491
|
+
title: typeof input.title === "string" && input.title.trim().length > 0 ? input.title : null,
|
|
16492
|
+
updatedAt: Math.floor(time3),
|
|
16493
|
+
// Unknown must stay unknown; only an explicit boolean is a native statement.
|
|
16494
|
+
running: typeof input.running === "boolean" ? input.running : null
|
|
16495
|
+
});
|
|
16496
|
+
return parsed.success ? parsed.data : null;
|
|
16497
|
+
}
|
|
16498
|
+
var SessionImportScope = class {
|
|
16499
|
+
#abort = new AbortController();
|
|
16500
|
+
#options;
|
|
16501
|
+
#pending = /* @__PURE__ */ new Set();
|
|
16502
|
+
constructor(options) {
|
|
16503
|
+
this.#options = options;
|
|
16504
|
+
}
|
|
16505
|
+
#closed() {
|
|
16506
|
+
return {
|
|
16507
|
+
ok: false,
|
|
16508
|
+
error: { code: "invalidState", message: this.#options.closedMessage, retryable: false }
|
|
16509
|
+
};
|
|
16510
|
+
}
|
|
16511
|
+
read(operation) {
|
|
16512
|
+
const signal = this.#abort.signal;
|
|
16513
|
+
if (signal.aborted)
|
|
16514
|
+
return Promise.resolve(this.#closed());
|
|
16515
|
+
let started;
|
|
16516
|
+
try {
|
|
16517
|
+
started = operation(signal);
|
|
16518
|
+
} catch (error51) {
|
|
16519
|
+
started = Promise.reject(error51 instanceof Error ? error51 : new Error("Session read failed"));
|
|
16520
|
+
}
|
|
16521
|
+
const request = started.then((value) => signal.aborted ? this.#closed() : { ok: true, value }).catch(() => signal.aborted ? this.#closed() : {
|
|
16522
|
+
ok: false,
|
|
16523
|
+
error: {
|
|
16524
|
+
code: "unavailable",
|
|
16525
|
+
message: this.#options.unavailableMessage,
|
|
16526
|
+
retryable: true
|
|
16527
|
+
}
|
|
16528
|
+
}).finally(() => this.#pending.delete(request));
|
|
16529
|
+
this.#pending.add(request);
|
|
16530
|
+
return request;
|
|
16531
|
+
}
|
|
16532
|
+
/** `read` for `resolveCandidate`: a null source is the selected Session having disappeared. */
|
|
16533
|
+
async resolve(operation) {
|
|
16534
|
+
const result = await this.read(operation);
|
|
16535
|
+
if (!result.ok)
|
|
16536
|
+
return result;
|
|
16537
|
+
return result.value ? { ok: true, value: result.value } : {
|
|
16538
|
+
ok: false,
|
|
16539
|
+
error: {
|
|
16540
|
+
code: "sessionNotFound",
|
|
16541
|
+
message: this.#options.notFoundMessage,
|
|
16542
|
+
retryable: false
|
|
16543
|
+
}
|
|
16544
|
+
};
|
|
16545
|
+
}
|
|
16546
|
+
/** Idempotent. Resolves after every started read has settled. */
|
|
16547
|
+
async close() {
|
|
16548
|
+
this.#abort.abort();
|
|
16549
|
+
await Promise.allSettled(this.#pending);
|
|
16550
|
+
}
|
|
16551
|
+
};
|
|
16552
|
+
|
|
16553
|
+
// dist/session-import.js
|
|
16554
|
+
function isRecord(value) {
|
|
16555
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
16556
|
+
}
|
|
16557
|
+
function expandDirectory(value, home) {
|
|
16558
|
+
return path5.resolve(value === "~" ? home : value.startsWith(`~${path5.sep}`) || value.startsWith("~/") ? path5.join(home, value.slice(2)) : value);
|
|
16559
|
+
}
|
|
16560
|
+
function ompSessionImportDirectory(environment) {
|
|
16561
|
+
const home = (process.platform === "win32" ? environment.USERPROFILE : environment.HOME) || os2.homedir();
|
|
16562
|
+
const custom2 = environment.PI_CODING_AGENT_SESSION_DIR;
|
|
16563
|
+
if (custom2)
|
|
16564
|
+
return { directory: expandDirectory(custom2, home), flat: true };
|
|
16565
|
+
const agent = environment.PI_CODING_AGENT_DIR;
|
|
16566
|
+
return {
|
|
16567
|
+
directory: path5.join(agent ? expandDirectory(agent, home) : path5.join(home, ".omp", "agent"), "sessions"),
|
|
16568
|
+
flat: false
|
|
16569
|
+
};
|
|
16570
|
+
}
|
|
16571
|
+
function messageText(content) {
|
|
16572
|
+
if (typeof content === "string")
|
|
16573
|
+
return content;
|
|
16574
|
+
if (!Array.isArray(content))
|
|
16575
|
+
return "";
|
|
16576
|
+
return content.filter((part) => isRecord(part) && part.type === "text" && typeof part.text === "string").map((part) => String(part.text)).join(" ");
|
|
16577
|
+
}
|
|
16578
|
+
async function readFacts(file2, signal) {
|
|
16579
|
+
const stream = createReadStream2(file2, { encoding: "utf8", signal });
|
|
16580
|
+
const lines = createInterface2({ input: stream, crlfDelay: Infinity });
|
|
16581
|
+
let header = null;
|
|
16582
|
+
let nativeTitle = null;
|
|
16583
|
+
let firstPrompt = null;
|
|
16584
|
+
let updatedAt = null;
|
|
16585
|
+
let leafHasUser = false;
|
|
16586
|
+
const hasUserAncestry = /* @__PURE__ */ new Map();
|
|
16587
|
+
try {
|
|
16588
|
+
for await (const line of lines) {
|
|
16589
|
+
signal.throwIfAborted();
|
|
16590
|
+
if (!line.trim())
|
|
16591
|
+
continue;
|
|
16592
|
+
let entry;
|
|
16593
|
+
try {
|
|
16594
|
+
entry = JSON.parse(line);
|
|
16595
|
+
} catch {
|
|
16596
|
+
continue;
|
|
16597
|
+
}
|
|
16598
|
+
if (!isRecord(entry))
|
|
16599
|
+
continue;
|
|
16600
|
+
if (entry.type === "title") {
|
|
16601
|
+
nativeTitle = sessionImportTitle(entry.title);
|
|
16602
|
+
continue;
|
|
16603
|
+
}
|
|
16604
|
+
if (entry.type === "session") {
|
|
16605
|
+
if (header)
|
|
16606
|
+
return null;
|
|
16607
|
+
if (typeof entry.id !== "string" || entry.id.length === 0 || typeof entry.cwd !== "string" || !path5.isAbsolute(entry.cwd))
|
|
16608
|
+
return null;
|
|
16609
|
+
header = { id: entry.id, cwd: entry.cwd };
|
|
16610
|
+
continue;
|
|
16611
|
+
}
|
|
16612
|
+
if (typeof entry.id !== "string" || entry.id.length === 0)
|
|
16613
|
+
continue;
|
|
16614
|
+
const message3 = isRecord(entry.message) ? entry.message : null;
|
|
16615
|
+
const isUser = entry.type === "message" && message3?.role === "user";
|
|
16616
|
+
if (isUser)
|
|
16617
|
+
firstPrompt ??= sessionImportTitle(messageText(message3?.content));
|
|
16618
|
+
leafHasUser = isUser || typeof entry.parentId === "string" && hasUserAncestry.get(entry.parentId) === true;
|
|
16619
|
+
hasUserAncestry.set(entry.id, leafHasUser);
|
|
16620
|
+
if (entry.type === "message" && (message3?.role === "user" || message3?.role === "assistant")) {
|
|
16621
|
+
const time3 = typeof message3.timestamp === "number" ? message3.timestamp : typeof entry.timestamp === "string" ? Date.parse(entry.timestamp) : Number.NaN;
|
|
16622
|
+
if (Number.isFinite(time3) && time3 >= 0)
|
|
16623
|
+
updatedAt = time3;
|
|
16624
|
+
}
|
|
16625
|
+
}
|
|
16626
|
+
} finally {
|
|
16627
|
+
lines.close();
|
|
16628
|
+
stream.destroy();
|
|
16629
|
+
}
|
|
16630
|
+
if (!header || !leafHasUser)
|
|
16631
|
+
return null;
|
|
16632
|
+
return {
|
|
16633
|
+
nativeSessionId: header.id,
|
|
16634
|
+
cwd: header.cwd,
|
|
16635
|
+
title: nativeTitle ?? firstPrompt,
|
|
16636
|
+
updatedAt
|
|
16637
|
+
};
|
|
16638
|
+
}
|
|
16639
|
+
var OmpSessionImport = class {
|
|
16640
|
+
#location;
|
|
16641
|
+
#scope = new SessionImportScope({
|
|
16642
|
+
closedMessage: "Omp Session import is closed",
|
|
16643
|
+
unavailableMessage: "Omp sessions could not be read; close native clients, check storage access and retry",
|
|
16644
|
+
notFoundMessage: "Omp Session is no longer importable"
|
|
16645
|
+
});
|
|
16646
|
+
constructor(environment) {
|
|
16647
|
+
this.#location = ompSessionImportDirectory(environment);
|
|
16648
|
+
}
|
|
16649
|
+
listCandidates() {
|
|
16650
|
+
return this.#scope.read(async (signal) => [...(await this.#sources(signal)).values()].flatMap((sources) => (
|
|
16651
|
+
// One identity in two files cannot be resumed unambiguously.
|
|
16652
|
+
sources.length === 1 && sources[0] ? [sources[0].candidate] : []
|
|
16653
|
+
)));
|
|
16654
|
+
}
|
|
16655
|
+
resolveCandidate(nativeSessionId) {
|
|
16656
|
+
return this.#scope.resolve(async (signal) => {
|
|
16657
|
+
const sources = (await this.#sources(signal)).get(nativeSessionId);
|
|
16658
|
+
if (sources?.length !== 1 || !sources[0])
|
|
16659
|
+
return null;
|
|
16660
|
+
const source = await this.#source(sources[0].file, signal);
|
|
16661
|
+
return source?.nativeRef.nativeSessionId === nativeSessionId ? { candidate: source.candidate, nativeRef: source.nativeRef } : null;
|
|
16662
|
+
});
|
|
16663
|
+
}
|
|
16664
|
+
close() {
|
|
16665
|
+
return this.#scope.close();
|
|
16666
|
+
}
|
|
16667
|
+
async #sessionFiles(signal) {
|
|
16668
|
+
const { directory, flat } = this.#location;
|
|
16669
|
+
const info = await optionalLstat(directory);
|
|
16670
|
+
if (!info)
|
|
16671
|
+
return [];
|
|
16672
|
+
if (!info.isDirectory())
|
|
16673
|
+
throw new Error("Omp Session store is not a directory");
|
|
16674
|
+
const files = [];
|
|
16675
|
+
const visit = async (current, projectLevel) => {
|
|
16676
|
+
const entries = await opendir2(current).catch((error51) => {
|
|
16677
|
+
if (isMissingFileError(error51))
|
|
16678
|
+
return null;
|
|
16679
|
+
throw error51;
|
|
16680
|
+
});
|
|
16681
|
+
if (!entries)
|
|
16682
|
+
return;
|
|
16683
|
+
for await (const entry of entries) {
|
|
16684
|
+
signal.throwIfAborted();
|
|
16685
|
+
if (projectLevel && entry.isDirectory())
|
|
16686
|
+
await visit(path5.join(current, entry.name), false);
|
|
16687
|
+
else if (!projectLevel && entry.isFile() && entry.name.endsWith(".jsonl"))
|
|
16688
|
+
files.push(path5.join(current, entry.name));
|
|
16689
|
+
}
|
|
16690
|
+
};
|
|
16691
|
+
await visit(directory, !flat);
|
|
16692
|
+
return files;
|
|
16693
|
+
}
|
|
16694
|
+
/** Session ID to every readable file claiming it. Files changing under the read are skipped. */
|
|
16695
|
+
async #sources(signal) {
|
|
16696
|
+
const found = /* @__PURE__ */ new Map();
|
|
16697
|
+
for (const file2 of await this.#sessionFiles(signal)) {
|
|
16698
|
+
signal.throwIfAborted();
|
|
16699
|
+
try {
|
|
16700
|
+
const source = await this.#source(file2, signal);
|
|
16701
|
+
if (!source)
|
|
16702
|
+
continue;
|
|
16703
|
+
const sources = found.get(source.nativeRef.nativeSessionId) ?? [];
|
|
16704
|
+
sources.push(source);
|
|
16705
|
+
found.set(source.nativeRef.nativeSessionId, sources);
|
|
16706
|
+
} catch (error51) {
|
|
16707
|
+
if (!(error51 instanceof SessionImportChangedError))
|
|
16708
|
+
throw error51;
|
|
16709
|
+
}
|
|
16710
|
+
}
|
|
16711
|
+
return found;
|
|
16712
|
+
}
|
|
16713
|
+
async #source(file2, signal) {
|
|
16714
|
+
signal.throwIfAborted();
|
|
16715
|
+
return readStableFiles([file2], async ([info]) => {
|
|
16716
|
+
if (!info?.isFile() || info.size === 0)
|
|
16717
|
+
return null;
|
|
16718
|
+
try {
|
|
16719
|
+
const facts = await readFacts(file2, signal);
|
|
16720
|
+
if (!facts)
|
|
16721
|
+
return null;
|
|
16722
|
+
const cwd = await realpath(facts.cwd);
|
|
16723
|
+
if (!(await stat(cwd)).isDirectory())
|
|
16724
|
+
return null;
|
|
16725
|
+
const candidate = sessionImportCandidate({
|
|
16726
|
+
nativeSessionId: facts.nativeSessionId,
|
|
16727
|
+
cwd,
|
|
16728
|
+
title: facts.title,
|
|
16729
|
+
updatedAt: facts.updatedAt ?? info.mtimeMs
|
|
16730
|
+
// OMP has no cross-process activity marker: idleness cannot be established.
|
|
16731
|
+
});
|
|
16732
|
+
if (!candidate)
|
|
16733
|
+
return null;
|
|
16734
|
+
return {
|
|
16735
|
+
file: file2,
|
|
16736
|
+
candidate,
|
|
16737
|
+
// Resume needs the file itself: OMP is started with `--session <file>`.
|
|
16738
|
+
nativeRef: nativeSessionRefSchema.parse({
|
|
16739
|
+
harnessId: "omp",
|
|
16740
|
+
nativeSessionId: facts.nativeSessionId,
|
|
16741
|
+
locator: { sessionFile: await realpath(file2) },
|
|
16742
|
+
formatVersion: 1
|
|
16743
|
+
})
|
|
16744
|
+
};
|
|
16745
|
+
} catch (error51) {
|
|
16746
|
+
signal.throwIfAborted();
|
|
16747
|
+
if (isStorageAccessError(error51))
|
|
16748
|
+
throw error51;
|
|
16749
|
+
return null;
|
|
16750
|
+
}
|
|
16751
|
+
});
|
|
16752
|
+
}
|
|
16753
|
+
};
|
|
16754
|
+
|
|
16545
16755
|
// ../../harness-adapter/dist/approval.js
|
|
16546
16756
|
function invalidRequest(message3) {
|
|
16547
16757
|
return { code: "invalidRequest", message: message3, retryable: false };
|
|
@@ -16650,7 +16860,6 @@ var tokenFields = [
|
|
|
16650
16860
|
"cachedInputTokens",
|
|
16651
16861
|
"cacheWriteInputTokens",
|
|
16652
16862
|
"outputTokens",
|
|
16653
|
-
"outputTokensPerSecond",
|
|
16654
16863
|
"reasoningOutputTokens",
|
|
16655
16864
|
"totalTokens",
|
|
16656
16865
|
"contextWindowTokens",
|
|
@@ -16658,10 +16867,12 @@ var tokenFields = [
|
|
|
16658
16867
|
];
|
|
16659
16868
|
var safeIntegerFields = [
|
|
16660
16869
|
"planFiveHourResetsAtUnix",
|
|
16661
|
-
"planSevenDayResetsAtUnix"
|
|
16870
|
+
"planSevenDayResetsAtUnix",
|
|
16871
|
+
"timeToFirstOutputMs"
|
|
16662
16872
|
];
|
|
16663
16873
|
var percentFields = [
|
|
16664
16874
|
"cacheHitRatePercent",
|
|
16875
|
+
"sessionCacheHitRatePercent",
|
|
16665
16876
|
"planFiveHourUsedPercent",
|
|
16666
16877
|
"planSevenDayUsedPercent"
|
|
16667
16878
|
];
|
|
@@ -16669,15 +16880,20 @@ var usageFields = /* @__PURE__ */ new Set([
|
|
|
16669
16880
|
...tokenFields,
|
|
16670
16881
|
...safeIntegerFields,
|
|
16671
16882
|
...percentFields,
|
|
16883
|
+
"sessionCacheUsage",
|
|
16672
16884
|
"totalCostUsd",
|
|
16673
16885
|
"totalCredits",
|
|
16674
|
-
"contextUsagePercent"
|
|
16886
|
+
"contextUsagePercent",
|
|
16887
|
+
"outputTokensPerSecond",
|
|
16888
|
+
"apiOutputTokensPerSecond",
|
|
16889
|
+
"costSource",
|
|
16890
|
+
"unpricedModels"
|
|
16675
16891
|
]);
|
|
16676
|
-
function
|
|
16892
|
+
function isRecord2(value) {
|
|
16677
16893
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
16678
16894
|
}
|
|
16679
16895
|
function parseHostUsage(value) {
|
|
16680
|
-
if (!
|
|
16896
|
+
if (!isRecord2(value))
|
|
16681
16897
|
throw new Error("Harness Usage must be an object");
|
|
16682
16898
|
const keys = Object.keys(value);
|
|
16683
16899
|
if (keys.length === 0)
|
|
@@ -16687,7 +16903,11 @@ function parseHostUsage(value) {
|
|
|
16687
16903
|
throw new Error(`Harness Usage contains unknown field '${key}'`);
|
|
16688
16904
|
}
|
|
16689
16905
|
}
|
|
16690
|
-
for (const field of [
|
|
16906
|
+
for (const field of [
|
|
16907
|
+
"totalCredits",
|
|
16908
|
+
"contextUsagePercent",
|
|
16909
|
+
"apiOutputTokensPerSecond"
|
|
16910
|
+
]) {
|
|
16691
16911
|
const candidate = value[field];
|
|
16692
16912
|
if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isFinite(candidate) || candidate < 0)) {
|
|
16693
16913
|
throw new Error(`Harness Usage '${field}' must be a finite non-negative number`);
|
|
@@ -16723,6 +16943,12 @@ function parseHostUsage(value) {
|
|
|
16723
16943
|
throw new Error(`Harness Usage '${field}' must be between 0 and 100`);
|
|
16724
16944
|
}
|
|
16725
16945
|
}
|
|
16946
|
+
if (value.sessionCacheUsage !== void 0) {
|
|
16947
|
+
const totals2 = value.sessionCacheUsage;
|
|
16948
|
+
if (!isRecord2(totals2) || Object.keys(totals2).some((key) => key !== "inputTokens" && key !== "cachedInputTokens") || typeof totals2.inputTokens !== "number" || !Number.isSafeInteger(totals2.inputTokens) || totals2.inputTokens < 0 || typeof totals2.cachedInputTokens !== "number" || !Number.isSafeInteger(totals2.cachedInputTokens) || totals2.cachedInputTokens < 0 || totals2.cachedInputTokens > totals2.inputTokens) {
|
|
16949
|
+
throw new Error("Harness Usage 'sessionCacheUsage' must contain complete bounded token totals");
|
|
16950
|
+
}
|
|
16951
|
+
}
|
|
16726
16952
|
const hasContextUsed = value.contextUsedTokens !== void 0;
|
|
16727
16953
|
const hasContextWindow = value.contextWindowTokens !== void 0;
|
|
16728
16954
|
if (hasContextUsed !== hasContextWindow) {
|
|
@@ -16737,7 +16963,89 @@ function parseHostUsage(value) {
|
|
|
16737
16963
|
if (value.planSevenDayResetsAtUnix !== void 0 && value.planSevenDayUsedPercent === void 0) {
|
|
16738
16964
|
throw new Error("Harness Usage 'planSevenDayResetsAtUnix' must be provided with 'planSevenDayUsedPercent'");
|
|
16739
16965
|
}
|
|
16740
|
-
|
|
16966
|
+
if (value.costSource !== void 0) {
|
|
16967
|
+
if (value.costSource !== "publicPrice" && value.costSource !== "native") {
|
|
16968
|
+
throw new Error("Harness Usage 'costSource' must be 'publicPrice' or 'native'");
|
|
16969
|
+
}
|
|
16970
|
+
if (value.totalCostUsd === void 0) {
|
|
16971
|
+
throw new Error("Harness Usage 'costSource' must be provided with 'totalCostUsd'");
|
|
16972
|
+
}
|
|
16973
|
+
}
|
|
16974
|
+
if (value.unpricedModels !== void 0) {
|
|
16975
|
+
const models = value.unpricedModels;
|
|
16976
|
+
if (!Array.isArray(models) || models.length === 0 || !models.every((model2) => typeof model2 === "string" && model2.length > 0)) {
|
|
16977
|
+
throw new Error("Harness Usage 'unpricedModels' must be a non-empty list of Model IDs");
|
|
16978
|
+
}
|
|
16979
|
+
if (value.costSource !== "publicPrice") {
|
|
16980
|
+
throw new Error("Harness Usage 'unpricedModels' must be provided with a 'publicPrice' cost");
|
|
16981
|
+
}
|
|
16982
|
+
return { ...value, unpricedModels: [...models] };
|
|
16983
|
+
}
|
|
16984
|
+
return { ...value };
|
|
16985
|
+
}
|
|
16986
|
+
var requestTokenFields = [
|
|
16987
|
+
"inputTokens",
|
|
16988
|
+
"cachedInputTokens",
|
|
16989
|
+
"cacheWriteInputTokens",
|
|
16990
|
+
"cacheWrite1hInputTokens",
|
|
16991
|
+
"outputTokens",
|
|
16992
|
+
"reasoningOutputTokens",
|
|
16993
|
+
"startedAtMs",
|
|
16994
|
+
"completedAtMs"
|
|
16995
|
+
];
|
|
16996
|
+
var requestFields = /* @__PURE__ */ new Set([
|
|
16997
|
+
...requestTokenFields,
|
|
16998
|
+
"requestId",
|
|
16999
|
+
"historical",
|
|
17000
|
+
"model",
|
|
17001
|
+
"provider"
|
|
17002
|
+
]);
|
|
17003
|
+
function parseHostUsageRequest(value) {
|
|
17004
|
+
if (!isRecord2(value))
|
|
17005
|
+
throw new Error("Harness Usage request must be an object");
|
|
17006
|
+
for (const key of Object.keys(value)) {
|
|
17007
|
+
if (!requestFields.has(key)) {
|
|
17008
|
+
throw new Error(`Harness Usage request contains unknown field '${key}'`);
|
|
17009
|
+
}
|
|
17010
|
+
}
|
|
17011
|
+
if (typeof value.requestId !== "string" || value.requestId.length === 0) {
|
|
17012
|
+
throw new Error("Harness Usage request 'requestId' must be a non-empty string");
|
|
17013
|
+
}
|
|
17014
|
+
for (const field of ["model", "provider"]) {
|
|
17015
|
+
const candidate = value[field];
|
|
17016
|
+
if (candidate !== void 0 && (typeof candidate !== "string" || candidate.length === 0)) {
|
|
17017
|
+
throw new Error(`Harness Usage request '${field}' must be a non-empty string`);
|
|
17018
|
+
}
|
|
17019
|
+
}
|
|
17020
|
+
if (value.historical !== void 0 && typeof value.historical !== "boolean") {
|
|
17021
|
+
throw new Error("Harness Usage request 'historical' must be a boolean");
|
|
17022
|
+
}
|
|
17023
|
+
for (const field of requestTokenFields) {
|
|
17024
|
+
const candidate = value[field];
|
|
17025
|
+
if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isSafeInteger(candidate) || candidate < 0)) {
|
|
17026
|
+
throw new Error(`Harness Usage request '${field}' must be a non-negative safe integer`);
|
|
17027
|
+
}
|
|
17028
|
+
}
|
|
17029
|
+
if (value.inputTokens === void 0 || value.outputTokens === void 0) {
|
|
17030
|
+
throw new Error("Harness Usage request must contain 'inputTokens' and 'outputTokens'");
|
|
17031
|
+
}
|
|
17032
|
+
const request = value;
|
|
17033
|
+
if ((request.cachedInputTokens ?? 0) + (request.cacheWriteInputTokens ?? 0) > request.inputTokens) {
|
|
17034
|
+
throw new Error("Harness Usage request cache Tokens must not exceed 'inputTokens'");
|
|
17035
|
+
}
|
|
17036
|
+
if ((request.reasoningOutputTokens ?? 0) > request.outputTokens) {
|
|
17037
|
+
throw new Error("Harness Usage request 'reasoningOutputTokens' must not exceed 'outputTokens'");
|
|
17038
|
+
}
|
|
17039
|
+
if (request.cacheWrite1hInputTokens !== void 0 && request.cacheWrite1hInputTokens > (request.cacheWriteInputTokens ?? -1)) {
|
|
17040
|
+
throw new Error("Harness Usage request 'cacheWrite1hInputTokens' must not exceed 'cacheWriteInputTokens'");
|
|
17041
|
+
}
|
|
17042
|
+
if (request.startedAtMs === void 0 !== (request.completedAtMs === void 0)) {
|
|
17043
|
+
throw new Error("Harness Usage request timing fields must be provided together");
|
|
17044
|
+
}
|
|
17045
|
+
if (request.startedAtMs !== void 0 && request.completedAtMs !== void 0 && request.completedAtMs < request.startedAtMs) {
|
|
17046
|
+
throw new Error("Harness Usage request 'completedAtMs' must not precede 'startedAtMs'");
|
|
17047
|
+
}
|
|
17048
|
+
return { ...request };
|
|
16741
17049
|
}
|
|
16742
17050
|
|
|
16743
17051
|
// ../../harness-adapter/dist/live-command-catalog.js
|
|
@@ -16834,457 +17142,1137 @@ function mergeLiveHarnessCommands(builtIns, idPrefix, live, exclusions = {}) {
|
|
|
16834
17142
|
const name = command.name.trim().replace(/^\//u, "");
|
|
16835
17143
|
if (!name || /\s/u.test(name))
|
|
16836
17144
|
continue;
|
|
16837
|
-
if (isExcludedLiveCommand(name, command.kind, exclusions))
|
|
17145
|
+
if (isExcludedLiveCommand(name, command.kind, exclusions))
|
|
17146
|
+
continue;
|
|
17147
|
+
const invocation = `/${name}`;
|
|
17148
|
+
const id = `${idPrefix}${name.replace(/[^A-Za-z0-9._:-]/gu, "-")}`.slice(0, 128);
|
|
17149
|
+
if (invocations.has(invocation) || ids.has(id))
|
|
17150
|
+
continue;
|
|
17151
|
+
const description = command.description?.trim().slice(0, 512);
|
|
17152
|
+
const parsed = harnessCommandDescriptorSchema.safeParse({
|
|
17153
|
+
id,
|
|
17154
|
+
invocation,
|
|
17155
|
+
label: name.slice(0, 128),
|
|
17156
|
+
...description ? { description } : {},
|
|
17157
|
+
argumentMode: "text",
|
|
17158
|
+
kind: command.kind
|
|
17159
|
+
});
|
|
17160
|
+
if (!parsed.success)
|
|
17161
|
+
continue;
|
|
17162
|
+
invocations.add(invocation);
|
|
17163
|
+
ids.add(id);
|
|
17164
|
+
dynamic.push(parsed.data);
|
|
17165
|
+
}
|
|
17166
|
+
return harnessCommandCatalogSchema.parse({ commands: [...builtIns.commands, ...dynamic] });
|
|
17167
|
+
}
|
|
17168
|
+
|
|
17169
|
+
// dist/omp-model-catalog.js
|
|
17170
|
+
var OMP_MODEL_REF_PREFIX = "omp-model-v1.";
|
|
17171
|
+
var OMP_DRAFT_THINKING_OPTION_IDS = [
|
|
17172
|
+
"off",
|
|
17173
|
+
"minimal",
|
|
17174
|
+
"low",
|
|
17175
|
+
"medium",
|
|
17176
|
+
"high",
|
|
17177
|
+
"xhigh",
|
|
17178
|
+
"max"
|
|
17179
|
+
].map((id) => harnessThinkingOptionIdSchema.parse(id));
|
|
17180
|
+
var OMP_THINKING_LABELS = {
|
|
17181
|
+
off: "Off",
|
|
17182
|
+
minimal: "Minimal",
|
|
17183
|
+
low: "Low",
|
|
17184
|
+
medium: "Medium",
|
|
17185
|
+
high: "High",
|
|
17186
|
+
xhigh: "Extra High",
|
|
17187
|
+
max: "Max"
|
|
17188
|
+
};
|
|
17189
|
+
function compareText(left, right) {
|
|
17190
|
+
return left < right ? -1 : left > right ? 1 : 0;
|
|
17191
|
+
}
|
|
17192
|
+
function assertNativePart(value, name) {
|
|
17193
|
+
if (value.trim().length === 0)
|
|
17194
|
+
throw new Error(`Omp ${name} must not be empty`);
|
|
17195
|
+
}
|
|
17196
|
+
function encodeOmpModelRef(model2) {
|
|
17197
|
+
assertNativePart(model2.provider, "Model provider");
|
|
17198
|
+
assertNativePart(model2.id, "Model id");
|
|
17199
|
+
const encoded = Buffer.from(JSON.stringify([model2.provider, model2.id]), "utf8").toString("base64url");
|
|
17200
|
+
return harnessModelRefSchema.parse({ id: `${OMP_MODEL_REF_PREFIX}${encoded}` });
|
|
17201
|
+
}
|
|
17202
|
+
function decodeOmpModelRef(ref) {
|
|
17203
|
+
const parsedRef = harnessModelRefSchema.parse(ref);
|
|
17204
|
+
if (!parsedRef.id.startsWith(OMP_MODEL_REF_PREFIX)) {
|
|
17205
|
+
throw new Error("Model Ref does not belong to OmpAdapter");
|
|
17206
|
+
}
|
|
17207
|
+
const encoded = parsedRef.id.slice(OMP_MODEL_REF_PREFIX.length);
|
|
17208
|
+
let decoded;
|
|
17209
|
+
try {
|
|
17210
|
+
decoded = JSON.parse(Buffer.from(encoded, "base64url").toString("utf8"));
|
|
17211
|
+
} catch {
|
|
17212
|
+
throw new Error("Omp Model Ref is malformed");
|
|
17213
|
+
}
|
|
17214
|
+
if (!Array.isArray(decoded) || decoded.length !== 2 || typeof decoded[0] !== "string" || typeof decoded[1] !== "string") {
|
|
17215
|
+
throw new Error("Omp Model Ref has an invalid native identity");
|
|
17216
|
+
}
|
|
17217
|
+
const native = { provider: decoded[0], id: decoded[1] };
|
|
17218
|
+
assertNativePart(native.provider, "Model provider");
|
|
17219
|
+
assertNativePart(native.id, "Model id");
|
|
17220
|
+
if (encodeOmpModelRef(native).id !== parsedRef.id) {
|
|
17221
|
+
throw new Error("Omp Model Ref is not canonical");
|
|
17222
|
+
}
|
|
17223
|
+
return native;
|
|
17224
|
+
}
|
|
17225
|
+
function sameOmpModel(left, right) {
|
|
17226
|
+
return left === null ? right === null : right !== null && left.provider === right.provider && left.id === right.id;
|
|
17227
|
+
}
|
|
17228
|
+
function fallbackThinkingLabel(id) {
|
|
17229
|
+
const label = id.split(/[._~-]+/u).filter((part) => part.length > 0).map((part) => `${part[0]?.toUpperCase() ?? ""}${part.slice(1)}`).join(" ");
|
|
17230
|
+
return label || id;
|
|
17231
|
+
}
|
|
17232
|
+
function normalizeOmpThinkingOptions(levels) {
|
|
17233
|
+
return levels.map((id) => harnessThinkingOptionSchema.parse({
|
|
17234
|
+
id,
|
|
17235
|
+
label: OMP_THINKING_LABELS[id] ?? fallbackThinkingLabel(id)
|
|
17236
|
+
}));
|
|
17237
|
+
}
|
|
17238
|
+
function normalizeOmpModelCatalog(nativeModels, effectiveModel, thinkingLevels, effectiveThinkingOptionId) {
|
|
17239
|
+
const byRef = /* @__PURE__ */ new Map();
|
|
17240
|
+
for (const native of nativeModels) {
|
|
17241
|
+
const ref = encodeOmpModelRef(native);
|
|
17242
|
+
const existing = byRef.get(ref.id);
|
|
17243
|
+
if (existing) {
|
|
17244
|
+
if (existing.reasoning !== native.reasoning) {
|
|
17245
|
+
throw new Error("Omp duplicate Model entries disagree on reasoning capability");
|
|
17246
|
+
}
|
|
17247
|
+
continue;
|
|
17248
|
+
}
|
|
17249
|
+
byRef.set(ref.id, {
|
|
17250
|
+
model: {
|
|
17251
|
+
ref,
|
|
17252
|
+
label: `${native.provider} / ${native.id}`
|
|
17253
|
+
},
|
|
17254
|
+
reasoning: native.reasoning
|
|
17255
|
+
});
|
|
17256
|
+
}
|
|
17257
|
+
const defaultModel = effectiveModel ? encodeOmpModelRef(effectiveModel) : void 0;
|
|
17258
|
+
if (defaultModel && !byRef.has(defaultModel.id)) {
|
|
17259
|
+
throw new Error("Omp effective Model is absent from the available Model catalog");
|
|
17260
|
+
}
|
|
17261
|
+
if (thinkingLevels && effectiveThinkingOptionId && !thinkingLevels.includes(effectiveThinkingOptionId)) {
|
|
17262
|
+
throw new Error("Omp effective Thinking option is absent from the available option catalog");
|
|
17263
|
+
}
|
|
17264
|
+
if (thinkingLevels && !effectiveThinkingOptionId) {
|
|
17265
|
+
throw new Error("Omp did not report an effective Thinking option");
|
|
17266
|
+
}
|
|
17267
|
+
const thinkingOptions = thinkingLevels ? normalizeOmpThinkingOptions(OMP_DRAFT_THINKING_OPTION_IDS) : [];
|
|
17268
|
+
const allThinkingOptionIds = thinkingOptions.map(({ id }) => id);
|
|
17269
|
+
const offThinkingOptionId = thinkingOptions.find(({ id }) => id === "off")?.id;
|
|
17270
|
+
const models = [...byRef.values()].map(({ model: model2, reasoning }) => ({
|
|
17271
|
+
...model2,
|
|
17272
|
+
supportedThinkingOptionIds: reasoning ? allThinkingOptionIds : offThinkingOptionId ? [offThinkingOptionId] : []
|
|
17273
|
+
})).sort((left, right) => compareText(left.label, right.label) || compareText(left.ref.id, right.ref.id));
|
|
17274
|
+
const defaultThinkingOptionId = thinkingOptions.find(({ id }) => id === effectiveThinkingOptionId)?.id;
|
|
17275
|
+
return harnessModelCatalogSchema.parse({
|
|
17276
|
+
models,
|
|
17277
|
+
...defaultModel ? { defaultModel } : {},
|
|
17278
|
+
thinkingOptions,
|
|
17279
|
+
...defaultThinkingOptionId ? { defaultThinkingOptionId } : {}
|
|
17280
|
+
});
|
|
17281
|
+
}
|
|
17282
|
+
|
|
17283
|
+
// dist/omp-tool-presentation.js
|
|
17284
|
+
function isRecord3(value) {
|
|
17285
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
17286
|
+
}
|
|
17287
|
+
function stringField(value, key) {
|
|
17288
|
+
return isRecord3(value) && typeof value[key] === "string" ? value[key] : void 0;
|
|
17289
|
+
}
|
|
17290
|
+
function toolCommand(toolName, argumentsValue) {
|
|
17291
|
+
if (toolName === "bash") {
|
|
17292
|
+
const command = stringField(argumentsValue, "command");
|
|
17293
|
+
if (command)
|
|
17294
|
+
return command;
|
|
17295
|
+
}
|
|
17296
|
+
const serializedArguments = JSON.stringify(argumentsValue);
|
|
17297
|
+
return serializedArguments === "{}" ? toolName : `${toolName} ${serializedArguments}`;
|
|
17298
|
+
}
|
|
17299
|
+
function projectOmpToolItem(input) {
|
|
17300
|
+
return {
|
|
17301
|
+
type: "commandExecution",
|
|
17302
|
+
itemId: input.itemId,
|
|
17303
|
+
command: toolCommand(input.toolName, input.arguments),
|
|
17304
|
+
...input.cwd ? { cwd: input.cwd } : {}
|
|
17305
|
+
};
|
|
17306
|
+
}
|
|
17307
|
+
|
|
17308
|
+
// dist/omp-history.js
|
|
17309
|
+
var ompHarnessId = harnessIdSchema.parse("omp");
|
|
17310
|
+
function isRecord4(value) {
|
|
17311
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
17312
|
+
}
|
|
17313
|
+
function textContent(value) {
|
|
17314
|
+
if (typeof value === "string")
|
|
17315
|
+
return value;
|
|
17316
|
+
if (!Array.isArray(value))
|
|
17317
|
+
return "";
|
|
17318
|
+
return value.filter((part) => isRecord4(part) && part.type === "text" && typeof part.text === "string").map((part) => part.text).join("");
|
|
17319
|
+
}
|
|
17320
|
+
function thinkingContent(value) {
|
|
17321
|
+
if (!Array.isArray(value))
|
|
17322
|
+
return "";
|
|
17323
|
+
return value.filter((part) => isRecord4(part) && part.type === "thinking" && typeof part.thinking === "string").map((part) => part.thinking).join("");
|
|
17324
|
+
}
|
|
17325
|
+
function validatedEntry(value) {
|
|
17326
|
+
if (typeof value.id !== "string" || value.id.length === 0 || value.parentId !== null && typeof value.parentId !== "string" || typeof value.type !== "string") {
|
|
17327
|
+
throw new Error("Omp history contains an invalid Entry identity");
|
|
17328
|
+
}
|
|
17329
|
+
return value;
|
|
17330
|
+
}
|
|
17331
|
+
function activeOmpEntries(history) {
|
|
17332
|
+
if (history.leafId === null)
|
|
17333
|
+
return [];
|
|
17334
|
+
const byId = new Map(history.entries.map((value) => {
|
|
17335
|
+
const entry = validatedEntry(value);
|
|
17336
|
+
return [entry.id, entry];
|
|
17337
|
+
}));
|
|
17338
|
+
const reversed = [];
|
|
17339
|
+
const visited = /* @__PURE__ */ new Set();
|
|
17340
|
+
let current = history.leafId;
|
|
17341
|
+
while (current !== null) {
|
|
17342
|
+
if (visited.has(current))
|
|
17343
|
+
throw new Error("Omp history active branch contains a cycle");
|
|
17344
|
+
visited.add(current);
|
|
17345
|
+
const entry = byId.get(current);
|
|
17346
|
+
if (!entry)
|
|
17347
|
+
throw new Error("Omp history active branch references a missing Entry");
|
|
17348
|
+
reversed.push(entry);
|
|
17349
|
+
current = entry.parentId;
|
|
17350
|
+
}
|
|
17351
|
+
return reversed.reverse();
|
|
17352
|
+
}
|
|
17353
|
+
function message(entry) {
|
|
17354
|
+
return entry.type === "message" && isRecord4(entry.message) ? entry.message : null;
|
|
17355
|
+
}
|
|
17356
|
+
function messageRole(entry) {
|
|
17357
|
+
const value = message(entry)?.role;
|
|
17358
|
+
return typeof value === "string" ? value : null;
|
|
17359
|
+
}
|
|
17360
|
+
function itemId(entryId, kind, ordinal) {
|
|
17361
|
+
return hostItemIdSchema.parse(`omp-item-v1-${entryId}-${kind}-${ordinal}`);
|
|
17362
|
+
}
|
|
17363
|
+
function assistantOutcome(entries) {
|
|
17364
|
+
const assistants = entries.map((entry) => message(entry)).filter((value) => value?.role === "assistant");
|
|
17365
|
+
const final = assistants.at(-1);
|
|
17366
|
+
if (!final)
|
|
17367
|
+
return { status: "unknown", reason: "Omp history has no Assistant terminal" };
|
|
17368
|
+
const stopReason = final.stopReason;
|
|
17369
|
+
if (stopReason === "aborted") {
|
|
17370
|
+
return { status: "cancelled", reason: "Omp Assistant was aborted" };
|
|
17371
|
+
}
|
|
17372
|
+
if (stopReason === "error") {
|
|
17373
|
+
return {
|
|
17374
|
+
status: "failed",
|
|
17375
|
+
error: {
|
|
17376
|
+
code: "nativeFailure",
|
|
17377
|
+
message: typeof final.errorMessage === "string" && final.errorMessage.length > 0 ? final.errorMessage : "Omp Assistant failed",
|
|
17378
|
+
retryable: false
|
|
17379
|
+
}
|
|
17380
|
+
};
|
|
17381
|
+
}
|
|
17382
|
+
if (typeof stopReason === "string" || textContent(final.content).length > 0) {
|
|
17383
|
+
return { status: "succeeded" };
|
|
17384
|
+
}
|
|
17385
|
+
return { status: "unknown", reason: "Omp Assistant terminal is not classifiable" };
|
|
17386
|
+
}
|
|
17387
|
+
function itemOutcome(outcome) {
|
|
17388
|
+
if (outcome.status === "failed")
|
|
17389
|
+
return { status: "failed", error: outcome.error };
|
|
17390
|
+
if (outcome.status === "cancelled") {
|
|
17391
|
+
return {
|
|
17392
|
+
status: "cancelled",
|
|
17393
|
+
...outcome.reason ? { reason: outcome.reason } : {}
|
|
17394
|
+
};
|
|
17395
|
+
}
|
|
17396
|
+
return { status: "succeeded" };
|
|
17397
|
+
}
|
|
17398
|
+
function toolOutput(value) {
|
|
17399
|
+
const text = textContent(value);
|
|
17400
|
+
return text.length > 0 ? { content: [{ type: "text", text }] } : void 0;
|
|
17401
|
+
}
|
|
17402
|
+
function snapshotItems(entries, outcome) {
|
|
17403
|
+
const snapshots = [];
|
|
17404
|
+
const toolCalls = /* @__PURE__ */ new Map();
|
|
17405
|
+
for (const entry of entries) {
|
|
17406
|
+
const nativeMessage = message(entry);
|
|
17407
|
+
if (!nativeMessage)
|
|
17408
|
+
continue;
|
|
17409
|
+
const content = Array.isArray(nativeMessage.content) ? nativeMessage.content : [];
|
|
17410
|
+
if (nativeMessage.role === "assistant") {
|
|
17411
|
+
const text = textContent(content);
|
|
17412
|
+
const reasoning = thinkingContent(content);
|
|
17413
|
+
let projectedText = false;
|
|
17414
|
+
let projectedReasoning = false;
|
|
17415
|
+
for (const [ordinal, part] of content.entries()) {
|
|
17416
|
+
if (!isRecord4(part))
|
|
17417
|
+
continue;
|
|
17418
|
+
if (part.type === "thinking" && !projectedReasoning && reasoning.length > 0) {
|
|
17419
|
+
const item2 = {
|
|
17420
|
+
type: "reasoning",
|
|
17421
|
+
itemId: itemId(entry.id, "reasoning", 0),
|
|
17422
|
+
text: reasoning
|
|
17423
|
+
};
|
|
17424
|
+
snapshots.push({ item: item2, outcome: itemOutcome(outcome) });
|
|
17425
|
+
projectedReasoning = true;
|
|
17426
|
+
continue;
|
|
17427
|
+
}
|
|
17428
|
+
if (part.type === "text" && !projectedText && text.length > 0) {
|
|
17429
|
+
const item2 = {
|
|
17430
|
+
type: "agentMessage",
|
|
17431
|
+
itemId: itemId(entry.id, "assistant", 0),
|
|
17432
|
+
text
|
|
17433
|
+
};
|
|
17434
|
+
snapshots.push({ item: item2, outcome: itemOutcome(outcome) });
|
|
17435
|
+
projectedText = true;
|
|
17436
|
+
continue;
|
|
17437
|
+
}
|
|
17438
|
+
if (part.type !== "toolCall" || typeof part.id !== "string" || typeof part.name !== "string") {
|
|
17439
|
+
continue;
|
|
17440
|
+
}
|
|
17441
|
+
const parsedArguments = jsonValueSchema.safeParse(part.arguments);
|
|
17442
|
+
if (!parsedArguments.success)
|
|
17443
|
+
continue;
|
|
17444
|
+
toolCalls.set(part.id, {
|
|
17445
|
+
entryId: entry.id,
|
|
17446
|
+
ordinal,
|
|
17447
|
+
name: part.name,
|
|
17448
|
+
arguments: parsedArguments.data
|
|
17449
|
+
});
|
|
17450
|
+
}
|
|
16838
17451
|
continue;
|
|
16839
|
-
|
|
16840
|
-
|
|
16841
|
-
if (invocations.has(invocation) || ids.has(id))
|
|
17452
|
+
}
|
|
17453
|
+
if (nativeMessage.role !== "toolResult" || typeof nativeMessage.toolCallId !== "string" || typeof nativeMessage.toolName !== "string") {
|
|
16842
17454
|
continue;
|
|
16843
|
-
|
|
16844
|
-
const
|
|
16845
|
-
|
|
16846
|
-
|
|
16847
|
-
|
|
16848
|
-
|
|
16849
|
-
|
|
16850
|
-
|
|
17455
|
+
}
|
|
17456
|
+
const call = toolCalls.get(nativeMessage.toolCallId);
|
|
17457
|
+
if (!call || call.name !== nativeMessage.toolName)
|
|
17458
|
+
continue;
|
|
17459
|
+
const output = toolOutput(nativeMessage.content);
|
|
17460
|
+
const item = {
|
|
17461
|
+
...projectOmpToolItem({
|
|
17462
|
+
itemId: itemId(call.entryId, "tool", call.ordinal),
|
|
17463
|
+
toolName: call.name,
|
|
17464
|
+
arguments: call.arguments
|
|
17465
|
+
}),
|
|
17466
|
+
...output ? { output: textContent(output.content) } : {}
|
|
17467
|
+
};
|
|
17468
|
+
const toolFailed = nativeMessage.isError === true;
|
|
17469
|
+
snapshots.push({
|
|
17470
|
+
item,
|
|
17471
|
+
outcome: toolFailed ? {
|
|
17472
|
+
status: "failed",
|
|
17473
|
+
error: {
|
|
17474
|
+
code: "nativeFailure",
|
|
17475
|
+
message: `Omp Tool '${call.name}' failed`,
|
|
17476
|
+
retryable: false
|
|
17477
|
+
}
|
|
17478
|
+
} : { status: "succeeded" }
|
|
16851
17479
|
});
|
|
16852
|
-
|
|
17480
|
+
}
|
|
17481
|
+
return snapshots;
|
|
17482
|
+
}
|
|
17483
|
+
function modelChange(entry) {
|
|
17484
|
+
return entry.type === "model_change" && typeof entry.provider === "string" && typeof entry.modelId === "string" ? { provider: entry.provider, id: entry.modelId } : null;
|
|
17485
|
+
}
|
|
17486
|
+
function mapOmpSnapshot(history, state) {
|
|
17487
|
+
const active = activeOmpEntries(history);
|
|
17488
|
+
const turns = [];
|
|
17489
|
+
let effectiveModel = state.model;
|
|
17490
|
+
for (let index = 0; index < active.length; ) {
|
|
17491
|
+
const model2 = modelChange(active[index]);
|
|
17492
|
+
if (model2) {
|
|
17493
|
+
effectiveModel = model2;
|
|
17494
|
+
index += 1;
|
|
16853
17495
|
continue;
|
|
16854
|
-
|
|
16855
|
-
|
|
16856
|
-
|
|
17496
|
+
}
|
|
17497
|
+
const user = active[index];
|
|
17498
|
+
if (messageRole(user) !== "user") {
|
|
17499
|
+
index += 1;
|
|
17500
|
+
continue;
|
|
17501
|
+
}
|
|
17502
|
+
let end = index + 1;
|
|
17503
|
+
while (end < active.length && messageRole(active[end]) !== "user")
|
|
17504
|
+
end += 1;
|
|
17505
|
+
const entries = active.slice(index, end);
|
|
17506
|
+
const outcome = assistantOutcome(entries);
|
|
17507
|
+
const userText = textContent(message(user)?.content);
|
|
17508
|
+
const nativeTurnRef = nativeTurnRefSchema.parse({
|
|
17509
|
+
harnessId: ompHarnessId,
|
|
17510
|
+
nativeSessionId: state.sessionId,
|
|
17511
|
+
nativeTurnKey: user.id,
|
|
17512
|
+
formatVersion: 1
|
|
17513
|
+
});
|
|
17514
|
+
const checkpoint = nativeCheckpointRefSchema.parse({
|
|
17515
|
+
harnessId: ompHarnessId,
|
|
17516
|
+
nativeSessionId: state.sessionId,
|
|
17517
|
+
checkpointId: user.id,
|
|
17518
|
+
formatVersion: 1
|
|
17519
|
+
});
|
|
17520
|
+
turns.push({
|
|
17521
|
+
nativeTurnRef,
|
|
17522
|
+
checkpoint,
|
|
17523
|
+
input: [{ type: "text", text: userText }],
|
|
17524
|
+
items: snapshotItems(entries, outcome),
|
|
17525
|
+
outcome,
|
|
17526
|
+
...effectiveModel ? { model: encodeOmpModelRef(effectiveModel) } : {}
|
|
17527
|
+
});
|
|
17528
|
+
for (const entry of entries) {
|
|
17529
|
+
const changed = modelChange(entry);
|
|
17530
|
+
if (changed)
|
|
17531
|
+
effectiveModel = changed;
|
|
17532
|
+
}
|
|
17533
|
+
index = end;
|
|
16857
17534
|
}
|
|
16858
|
-
return
|
|
17535
|
+
return { turns };
|
|
17536
|
+
}
|
|
17537
|
+
function resolveOmpLastTurnBoundary(history) {
|
|
17538
|
+
const users = activeOmpEntries(history).filter((entry) => messageRole(entry) === "user");
|
|
17539
|
+
const last = users.at(-1);
|
|
17540
|
+
return last ? { lastUserEntryId: last.id, sourceTurnCount: users.length } : null;
|
|
17541
|
+
}
|
|
17542
|
+
function resolveOmpForkBoundary(history, checkpointId) {
|
|
17543
|
+
const active = activeOmpEntries(history);
|
|
17544
|
+
const users = active.filter((entry) => messageRole(entry) === "user");
|
|
17545
|
+
const targetTurnIndex = users.findIndex((entry) => entry.id === checkpointId);
|
|
17546
|
+
if (targetTurnIndex < 0)
|
|
17547
|
+
throw new Error("Omp Checkpoint is not on the active branch");
|
|
17548
|
+
return {
|
|
17549
|
+
targetTurnIndex,
|
|
17550
|
+
nextUserEntryId: users[targetTurnIndex + 1]?.id ?? null
|
|
17551
|
+
};
|
|
16859
17552
|
}
|
|
16860
17553
|
|
|
16861
|
-
// dist/omp-
|
|
16862
|
-
|
|
16863
|
-
function isRecord2(value) {
|
|
17554
|
+
// dist/omp-usage.js
|
|
17555
|
+
function isRecord5(value) {
|
|
16864
17556
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
16865
17557
|
}
|
|
16866
|
-
function
|
|
16867
|
-
|
|
16868
|
-
return [];
|
|
16869
|
-
return value.flatMap((entry) => {
|
|
16870
|
-
if (!isRecord2(entry))
|
|
16871
|
-
return [];
|
|
16872
|
-
const name = typeof entry.name === "string" ? entry.name.trim().replace(/^\//u, "") : "";
|
|
16873
|
-
if (!name)
|
|
16874
|
-
return [];
|
|
16875
|
-
return [
|
|
16876
|
-
{
|
|
16877
|
-
name,
|
|
16878
|
-
description: typeof entry.description === "string" ? entry.description : "",
|
|
16879
|
-
source: typeof entry.source === "string" ? entry.source : null
|
|
16880
|
-
}
|
|
16881
|
-
];
|
|
16882
|
-
});
|
|
17558
|
+
function nonNegativeSafeInteger(value) {
|
|
17559
|
+
return typeof value === "number" && Number.isSafeInteger(value) && value >= 0 ? value : null;
|
|
16883
17560
|
}
|
|
16884
|
-
function
|
|
16885
|
-
|
|
16886
|
-
|
|
16887
|
-
|
|
16888
|
-
|
|
16889
|
-
|
|
17561
|
+
function optionalOmpCacheHitRatePercent(value) {
|
|
17562
|
+
if (!isRecord5(value) || value.role !== "assistant" || !isRecord5(value.usage))
|
|
17563
|
+
return null;
|
|
17564
|
+
const input = nonNegativeSafeInteger(value.usage.input);
|
|
17565
|
+
const cacheRead = nonNegativeSafeInteger(value.usage.cacheRead);
|
|
17566
|
+
const cacheWrite = nonNegativeSafeInteger(value.usage.cacheWrite);
|
|
17567
|
+
if (input === null || cacheRead === null || cacheWrite === null)
|
|
17568
|
+
return null;
|
|
17569
|
+
const promptTokens = input + cacheRead + cacheWrite;
|
|
17570
|
+
return promptTokens > 0 ? cacheRead / promptTokens * 100 : null;
|
|
16890
17571
|
}
|
|
16891
|
-
|
|
16892
|
-
|
|
16893
|
-
|
|
16894
|
-
|
|
16895
|
-
|
|
16896
|
-
|
|
16897
|
-
|
|
16898
|
-
|
|
16899
|
-
"high",
|
|
16900
|
-
"xhigh",
|
|
16901
|
-
"max"
|
|
16902
|
-
].map((id) => harnessThinkingOptionIdSchema.parse(id));
|
|
16903
|
-
var OMP_THINKING_LABELS = {
|
|
16904
|
-
off: "Off",
|
|
16905
|
-
minimal: "Minimal",
|
|
16906
|
-
low: "Low",
|
|
16907
|
-
medium: "Medium",
|
|
16908
|
-
high: "High",
|
|
16909
|
-
xhigh: "Extra High",
|
|
16910
|
-
max: "Max"
|
|
16911
|
-
};
|
|
16912
|
-
function compareText(left, right) {
|
|
16913
|
-
return left < right ? -1 : left > right ? 1 : 0;
|
|
17572
|
+
function latestOmpCacheHitRatePercent(history) {
|
|
17573
|
+
let latest = null;
|
|
17574
|
+
for (const entry of activeOmpEntries(history)) {
|
|
17575
|
+
if (entry.type === "message" && isRecord5(entry.message) && entry.message.role === "assistant") {
|
|
17576
|
+
latest = optionalOmpCacheHitRatePercent(entry.message);
|
|
17577
|
+
}
|
|
17578
|
+
}
|
|
17579
|
+
return latest;
|
|
16914
17580
|
}
|
|
16915
|
-
function
|
|
16916
|
-
if (
|
|
16917
|
-
throw new Error(`Omp ${
|
|
17581
|
+
function responseData(response, operation) {
|
|
17582
|
+
if (!isRecord5(response.data)) {
|
|
17583
|
+
throw new Error(`Omp RPC ${operation} response has no data`);
|
|
17584
|
+
}
|
|
17585
|
+
return response.data;
|
|
16918
17586
|
}
|
|
16919
|
-
function
|
|
16920
|
-
|
|
16921
|
-
|
|
16922
|
-
|
|
16923
|
-
|
|
17587
|
+
function contextUsage(value) {
|
|
17588
|
+
if (!isRecord5(value))
|
|
17589
|
+
throw new Error("Omp RPC context Usage is invalid");
|
|
17590
|
+
return parseHostUsage({
|
|
17591
|
+
contextUsedTokens: value.tokens,
|
|
17592
|
+
contextWindowTokens: value.contextWindow
|
|
17593
|
+
});
|
|
16924
17594
|
}
|
|
16925
|
-
function
|
|
16926
|
-
const
|
|
16927
|
-
|
|
16928
|
-
|
|
17595
|
+
function parseOmpSessionUsage(response) {
|
|
17596
|
+
const data = responseData(response, "Session stats");
|
|
17597
|
+
const tokens = data.tokens;
|
|
17598
|
+
if (tokens !== void 0 && !isRecord5(tokens)) {
|
|
17599
|
+
throw new Error("Omp RPC Session stats tokens are invalid");
|
|
16929
17600
|
}
|
|
16930
|
-
|
|
16931
|
-
|
|
17601
|
+
return parseHostUsage({
|
|
17602
|
+
...isRecord5(tokens) && tokens.input !== void 0 ? { inputTokens: tokens.input } : {},
|
|
17603
|
+
...isRecord5(tokens) && tokens.cacheRead !== void 0 ? { cachedInputTokens: tokens.cacheRead } : {},
|
|
17604
|
+
...isRecord5(tokens) && tokens.cacheWrite !== void 0 ? { cacheWriteInputTokens: tokens.cacheWrite } : {},
|
|
17605
|
+
...isRecord5(tokens) && tokens.output !== void 0 ? { outputTokens: tokens.output } : {},
|
|
17606
|
+
...isRecord5(tokens) && tokens.total !== void 0 ? { totalTokens: tokens.total } : {},
|
|
17607
|
+
...data.cost !== void 0 ? { totalCostUsd: data.cost } : {},
|
|
17608
|
+
...data.contextUsage !== void 0 ? contextUsage(data.contextUsage) : {}
|
|
17609
|
+
});
|
|
17610
|
+
}
|
|
17611
|
+
function parseOmpStateContextUsage(response) {
|
|
17612
|
+
const data = responseData(response, "state");
|
|
17613
|
+
return data.contextUsage === void 0 ? null : contextUsage(data.contextUsage);
|
|
17614
|
+
}
|
|
17615
|
+
function optionalOmpStateContextUsage(value) {
|
|
17616
|
+
if (value === void 0)
|
|
17617
|
+
return null;
|
|
16932
17618
|
try {
|
|
16933
|
-
|
|
17619
|
+
return contextUsage(value);
|
|
16934
17620
|
} catch {
|
|
16935
|
-
|
|
16936
|
-
}
|
|
16937
|
-
if (!Array.isArray(decoded) || decoded.length !== 2 || typeof decoded[0] !== "string" || typeof decoded[1] !== "string") {
|
|
16938
|
-
throw new Error("Omp Model Ref has an invalid native identity");
|
|
17621
|
+
return null;
|
|
16939
17622
|
}
|
|
16940
|
-
|
|
16941
|
-
|
|
16942
|
-
|
|
16943
|
-
|
|
16944
|
-
|
|
17623
|
+
}
|
|
17624
|
+
function ompUsageRecord(message3, extra = {}) {
|
|
17625
|
+
if (!isRecord5(message3) || message3.role !== "assistant")
|
|
17626
|
+
return null;
|
|
17627
|
+
const usage = isRecord5(message3.usage) ? message3.usage : null;
|
|
17628
|
+
const input = nonNegativeSafeInteger(usage?.input);
|
|
17629
|
+
const output = nonNegativeSafeInteger(usage?.output);
|
|
17630
|
+
const requestId = typeof message3.responseId === "string" && message3.responseId.length > 0 ? message3.responseId : typeof message3.timestamp === "number" && Number.isSafeInteger(message3.timestamp) ? `t${message3.timestamp}` : null;
|
|
17631
|
+
if (!usage || input === null || output === null || requestId === null) {
|
|
17632
|
+
return { kind: "missing" };
|
|
17633
|
+
}
|
|
17634
|
+
const cacheRead = nonNegativeSafeInteger(usage.cacheRead);
|
|
17635
|
+
const cacheWrite = nonNegativeSafeInteger(usage.cacheWrite);
|
|
17636
|
+
const reasoning = nonNegativeSafeInteger(usage.reasoningTokens ?? usage.reasoning);
|
|
17637
|
+
const timed = extra.startedAtMs !== void 0 && extra.startedAtMs !== null && extra.completedAtMs !== void 0;
|
|
17638
|
+
try {
|
|
17639
|
+
return {
|
|
17640
|
+
kind: "request",
|
|
17641
|
+
request: parseHostUsageRequest({
|
|
17642
|
+
requestId,
|
|
17643
|
+
...extra.historical ? { historical: true } : {},
|
|
17644
|
+
// Omp's provider is a configurable name, not a standard provider ID.
|
|
17645
|
+
...typeof message3.model === "string" && message3.model.length > 0 ? { model: message3.model } : {},
|
|
17646
|
+
inputTokens: input + (cacheRead ?? 0) + (cacheWrite ?? 0),
|
|
17647
|
+
...cacheRead !== null ? { cachedInputTokens: cacheRead } : {},
|
|
17648
|
+
...cacheWrite !== null ? { cacheWriteInputTokens: cacheWrite } : {},
|
|
17649
|
+
outputTokens: output,
|
|
17650
|
+
...reasoning !== null && reasoning <= output ? { reasoningOutputTokens: reasoning } : {},
|
|
17651
|
+
...timed ? { startedAtMs: extra.startedAtMs, completedAtMs: extra.completedAtMs } : {}
|
|
17652
|
+
})
|
|
17653
|
+
};
|
|
17654
|
+
} catch {
|
|
17655
|
+
return { kind: "missing" };
|
|
16945
17656
|
}
|
|
16946
|
-
return native;
|
|
16947
17657
|
}
|
|
16948
|
-
function
|
|
16949
|
-
|
|
17658
|
+
function ompUsageHistory(history) {
|
|
17659
|
+
const requests = [];
|
|
17660
|
+
let complete = history.incomplete !== true;
|
|
17661
|
+
for (const entry of history.entries) {
|
|
17662
|
+
if (entry.type !== "message")
|
|
17663
|
+
continue;
|
|
17664
|
+
const record2 = ompUsageRecord(entry.message, { historical: true });
|
|
17665
|
+
if (record2?.kind === "request")
|
|
17666
|
+
requests.push(record2.request);
|
|
17667
|
+
else if (record2?.kind === "missing")
|
|
17668
|
+
complete = false;
|
|
17669
|
+
}
|
|
17670
|
+
return { requests, complete };
|
|
16950
17671
|
}
|
|
16951
|
-
|
|
16952
|
-
|
|
16953
|
-
|
|
17672
|
+
|
|
17673
|
+
// dist/omp-usage-statistics.js
|
|
17674
|
+
async function readOmpUsage(file2, signal) {
|
|
17675
|
+
const entries = [];
|
|
17676
|
+
const header = await jsonlHeader(file2, (record2) => record2.type === "session", signal);
|
|
17677
|
+
const session = {
|
|
17678
|
+
sessionId: typeof header?.id === "string" ? header.id : void 0,
|
|
17679
|
+
cwd: typeof header?.cwd === "string" ? header.cwd : void 0
|
|
17680
|
+
};
|
|
17681
|
+
for await (const line of jsonlRecords(file2, '"assistant"', signal)) {
|
|
17682
|
+
if (line.type !== "message")
|
|
17683
|
+
continue;
|
|
17684
|
+
const record2 = ompUsageRecord(line.message);
|
|
17685
|
+
if (record2?.kind !== "request")
|
|
17686
|
+
continue;
|
|
17687
|
+
const message3 = line.message;
|
|
17688
|
+
const at = nativeTimeMs(message3.timestamp) ?? nativeTimeMs(line.timestamp);
|
|
17689
|
+
const entry = at !== null && usageEntryFromRequest(record2.request, at);
|
|
17690
|
+
if (!entry)
|
|
17691
|
+
continue;
|
|
17692
|
+
if (!(typeof message3.responseId === "string" && message3.responseId.length > 0)) {
|
|
17693
|
+
if (typeof line.id !== "string" || line.id.length === 0)
|
|
17694
|
+
continue;
|
|
17695
|
+
entry.id = `entry:${line.id}:${entry.id}`;
|
|
17696
|
+
}
|
|
17697
|
+
entries.push(withUsageSession(entry, session));
|
|
17698
|
+
}
|
|
17699
|
+
return entries;
|
|
16954
17700
|
}
|
|
16955
|
-
function
|
|
16956
|
-
return
|
|
16957
|
-
|
|
16958
|
-
|
|
16959
|
-
|
|
17701
|
+
function createOmpUsageStatistics(environment) {
|
|
17702
|
+
return Object.freeze({
|
|
17703
|
+
// <project>/<session>.jsonl and its subagents' and advisor's in <session>/
|
|
17704
|
+
listSources: (signal) => jsonlUsageSources(ompSessionImportDirectory(environment).directory, 4, signal),
|
|
17705
|
+
readSource: (id, signal) => readOmpUsage(id, signal)
|
|
17706
|
+
});
|
|
16960
17707
|
}
|
|
16961
|
-
|
|
16962
|
-
|
|
16963
|
-
|
|
16964
|
-
|
|
16965
|
-
|
|
16966
|
-
if (
|
|
16967
|
-
|
|
16968
|
-
|
|
17708
|
+
|
|
17709
|
+
// ../../../node_modules/diff/libesm/diff/base.js
|
|
17710
|
+
var Diff = class {
|
|
17711
|
+
diff(oldStr, newStr, options = {}) {
|
|
17712
|
+
let callback;
|
|
17713
|
+
if (typeof options === "function") {
|
|
17714
|
+
callback = options;
|
|
17715
|
+
options = {};
|
|
17716
|
+
} else if ("callback" in options) {
|
|
17717
|
+
callback = options.callback;
|
|
17718
|
+
}
|
|
17719
|
+
const oldString = this.castInput(oldStr, options);
|
|
17720
|
+
const newString = this.castInput(newStr, options);
|
|
17721
|
+
const oldTokens = this.removeEmpty(this.tokenize(oldString, options));
|
|
17722
|
+
const newTokens = this.removeEmpty(this.tokenize(newString, options));
|
|
17723
|
+
return this.diffWithOptionsObj(oldTokens, newTokens, options, callback);
|
|
17724
|
+
}
|
|
17725
|
+
diffWithOptionsObj(oldTokens, newTokens, options, callback) {
|
|
17726
|
+
var _a3;
|
|
17727
|
+
const done = (value) => {
|
|
17728
|
+
value = this.postProcess(value, options);
|
|
17729
|
+
if (callback) {
|
|
17730
|
+
setTimeout(function() {
|
|
17731
|
+
callback(value);
|
|
17732
|
+
}, 0);
|
|
17733
|
+
return void 0;
|
|
17734
|
+
} else {
|
|
17735
|
+
return value;
|
|
17736
|
+
}
|
|
17737
|
+
};
|
|
17738
|
+
const newLen = newTokens.length, oldLen = oldTokens.length;
|
|
17739
|
+
let editLength = 1;
|
|
17740
|
+
let maxEditLength = newLen + oldLen;
|
|
17741
|
+
if (options.maxEditLength != null) {
|
|
17742
|
+
maxEditLength = Math.min(maxEditLength, options.maxEditLength);
|
|
17743
|
+
}
|
|
17744
|
+
const maxExecutionTime = (_a3 = options.timeout) !== null && _a3 !== void 0 ? _a3 : Infinity;
|
|
17745
|
+
const abortAfterTimestamp = Date.now() + maxExecutionTime;
|
|
17746
|
+
const bestPath = [{ oldPos: -1, lastComponent: void 0 }];
|
|
17747
|
+
let newPos = this.extractCommon(bestPath[0], newTokens, oldTokens, 0, options);
|
|
17748
|
+
if (bestPath[0].oldPos + 1 >= oldLen && newPos + 1 >= newLen) {
|
|
17749
|
+
return done(this.buildValues(bestPath[0].lastComponent, newTokens, oldTokens));
|
|
17750
|
+
}
|
|
17751
|
+
let minDiagonalToConsider = -Infinity, maxDiagonalToConsider = Infinity;
|
|
17752
|
+
const execEditLength = () => {
|
|
17753
|
+
for (let diagonalPath = Math.max(minDiagonalToConsider, -editLength); diagonalPath <= Math.min(maxDiagonalToConsider, editLength); diagonalPath += 2) {
|
|
17754
|
+
let basePath;
|
|
17755
|
+
const removePath = bestPath[diagonalPath - 1], addPath = bestPath[diagonalPath + 1];
|
|
17756
|
+
if (removePath) {
|
|
17757
|
+
bestPath[diagonalPath - 1] = void 0;
|
|
17758
|
+
}
|
|
17759
|
+
let canAdd = false;
|
|
17760
|
+
if (addPath) {
|
|
17761
|
+
const addPathNewPos = addPath.oldPos - diagonalPath;
|
|
17762
|
+
canAdd = addPath && 0 <= addPathNewPos && addPathNewPos < newLen;
|
|
17763
|
+
}
|
|
17764
|
+
const canRemove = removePath && removePath.oldPos + 1 < oldLen;
|
|
17765
|
+
if (!canAdd && !canRemove) {
|
|
17766
|
+
bestPath[diagonalPath] = void 0;
|
|
17767
|
+
continue;
|
|
17768
|
+
}
|
|
17769
|
+
if (!canRemove || canAdd && removePath.oldPos < addPath.oldPos) {
|
|
17770
|
+
basePath = this.addToPath(addPath, true, false, 0, options);
|
|
17771
|
+
} else {
|
|
17772
|
+
basePath = this.addToPath(removePath, false, true, 1, options);
|
|
17773
|
+
}
|
|
17774
|
+
newPos = this.extractCommon(basePath, newTokens, oldTokens, diagonalPath, options);
|
|
17775
|
+
if (basePath.oldPos + 1 >= oldLen && newPos + 1 >= newLen) {
|
|
17776
|
+
return done(this.buildValues(basePath.lastComponent, newTokens, oldTokens)) || true;
|
|
17777
|
+
} else {
|
|
17778
|
+
bestPath[diagonalPath] = basePath;
|
|
17779
|
+
if (basePath.oldPos + 1 >= oldLen) {
|
|
17780
|
+
maxDiagonalToConsider = Math.min(maxDiagonalToConsider, diagonalPath - 1);
|
|
17781
|
+
}
|
|
17782
|
+
if (newPos + 1 >= newLen) {
|
|
17783
|
+
minDiagonalToConsider = Math.max(minDiagonalToConsider, diagonalPath + 1);
|
|
17784
|
+
}
|
|
17785
|
+
}
|
|
17786
|
+
}
|
|
17787
|
+
editLength++;
|
|
17788
|
+
};
|
|
17789
|
+
if (callback) {
|
|
17790
|
+
(function exec() {
|
|
17791
|
+
setTimeout(function() {
|
|
17792
|
+
if (editLength > maxEditLength || Date.now() > abortAfterTimestamp) {
|
|
17793
|
+
return callback(void 0);
|
|
17794
|
+
}
|
|
17795
|
+
if (!execEditLength()) {
|
|
17796
|
+
exec();
|
|
17797
|
+
}
|
|
17798
|
+
}, 0);
|
|
17799
|
+
})();
|
|
17800
|
+
} else {
|
|
17801
|
+
while (editLength <= maxEditLength && Date.now() <= abortAfterTimestamp) {
|
|
17802
|
+
const ret = execEditLength();
|
|
17803
|
+
if (ret) {
|
|
17804
|
+
return ret;
|
|
17805
|
+
}
|
|
17806
|
+
}
|
|
17807
|
+
}
|
|
17808
|
+
}
|
|
17809
|
+
addToPath(path9, added, removed, oldPosInc, options) {
|
|
17810
|
+
const last = path9.lastComponent;
|
|
17811
|
+
if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) {
|
|
17812
|
+
return {
|
|
17813
|
+
oldPos: path9.oldPos + oldPosInc,
|
|
17814
|
+
lastComponent: { count: last.count + 1, added, removed, previousComponent: last.previousComponent }
|
|
17815
|
+
};
|
|
17816
|
+
} else {
|
|
17817
|
+
return {
|
|
17818
|
+
oldPos: path9.oldPos + oldPosInc,
|
|
17819
|
+
lastComponent: { count: 1, added, removed, previousComponent: last }
|
|
17820
|
+
};
|
|
17821
|
+
}
|
|
17822
|
+
}
|
|
17823
|
+
extractCommon(basePath, newTokens, oldTokens, diagonalPath, options) {
|
|
17824
|
+
const newLen = newTokens.length, oldLen = oldTokens.length;
|
|
17825
|
+
let oldPos = basePath.oldPos, newPos = oldPos - diagonalPath, commonCount = 0;
|
|
17826
|
+
while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(oldTokens[oldPos + 1], newTokens[newPos + 1], options)) {
|
|
17827
|
+
newPos++;
|
|
17828
|
+
oldPos++;
|
|
17829
|
+
commonCount++;
|
|
17830
|
+
if (options.oneChangePerToken) {
|
|
17831
|
+
basePath.lastComponent = { count: 1, previousComponent: basePath.lastComponent, added: false, removed: false };
|
|
17832
|
+
}
|
|
17833
|
+
}
|
|
17834
|
+
if (commonCount && !options.oneChangePerToken) {
|
|
17835
|
+
basePath.lastComponent = { count: commonCount, previousComponent: basePath.lastComponent, added: false, removed: false };
|
|
17836
|
+
}
|
|
17837
|
+
basePath.oldPos = oldPos;
|
|
17838
|
+
return newPos;
|
|
17839
|
+
}
|
|
17840
|
+
equals(left, right, options) {
|
|
17841
|
+
if (options.comparator) {
|
|
17842
|
+
return options.comparator(left, right);
|
|
17843
|
+
} else {
|
|
17844
|
+
return left === right || !!options.ignoreCase && left.toLowerCase() === right.toLowerCase();
|
|
17845
|
+
}
|
|
17846
|
+
}
|
|
17847
|
+
removeEmpty(array2) {
|
|
17848
|
+
const ret = [];
|
|
17849
|
+
for (let i = 0; i < array2.length; i++) {
|
|
17850
|
+
if (array2[i]) {
|
|
17851
|
+
ret.push(array2[i]);
|
|
17852
|
+
}
|
|
17853
|
+
}
|
|
17854
|
+
return ret;
|
|
17855
|
+
}
|
|
17856
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
17857
|
+
castInput(value, options) {
|
|
17858
|
+
return value;
|
|
17859
|
+
}
|
|
17860
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
17861
|
+
tokenize(value, options) {
|
|
17862
|
+
return Array.from(value);
|
|
17863
|
+
}
|
|
17864
|
+
join(chars) {
|
|
17865
|
+
return chars.join("");
|
|
17866
|
+
}
|
|
17867
|
+
postProcess(changeObjects, options) {
|
|
17868
|
+
return changeObjects;
|
|
17869
|
+
}
|
|
17870
|
+
get useLongestToken() {
|
|
17871
|
+
return false;
|
|
17872
|
+
}
|
|
17873
|
+
buildValues(lastComponent, newTokens, oldTokens) {
|
|
17874
|
+
const components = [];
|
|
17875
|
+
let nextComponent;
|
|
17876
|
+
while (lastComponent) {
|
|
17877
|
+
components.push(lastComponent);
|
|
17878
|
+
nextComponent = lastComponent.previousComponent;
|
|
17879
|
+
delete lastComponent.previousComponent;
|
|
17880
|
+
lastComponent = nextComponent;
|
|
17881
|
+
}
|
|
17882
|
+
components.reverse();
|
|
17883
|
+
const componentLen = components.length;
|
|
17884
|
+
let componentPos = 0, newPos = 0, oldPos = 0;
|
|
17885
|
+
for (; componentPos < componentLen; componentPos++) {
|
|
17886
|
+
const component = components[componentPos];
|
|
17887
|
+
if (!component.removed) {
|
|
17888
|
+
if (!component.added && this.useLongestToken) {
|
|
17889
|
+
let value = newTokens.slice(newPos, newPos + component.count);
|
|
17890
|
+
value = value.map(function(value2, i) {
|
|
17891
|
+
const oldValue = oldTokens[oldPos + i];
|
|
17892
|
+
return oldValue.length > value2.length ? oldValue : value2;
|
|
17893
|
+
});
|
|
17894
|
+
component.value = this.join(value);
|
|
17895
|
+
} else {
|
|
17896
|
+
component.value = this.join(newTokens.slice(newPos, newPos + component.count));
|
|
17897
|
+
}
|
|
17898
|
+
newPos += component.count;
|
|
17899
|
+
if (!component.added) {
|
|
17900
|
+
oldPos += component.count;
|
|
17901
|
+
}
|
|
17902
|
+
} else {
|
|
17903
|
+
component.value = this.join(oldTokens.slice(oldPos, oldPos + component.count));
|
|
17904
|
+
oldPos += component.count;
|
|
17905
|
+
}
|
|
17906
|
+
}
|
|
17907
|
+
return components;
|
|
17908
|
+
}
|
|
17909
|
+
};
|
|
17910
|
+
|
|
17911
|
+
// ../../../node_modules/diff/libesm/diff/line.js
|
|
17912
|
+
var LineDiff = class extends Diff {
|
|
17913
|
+
constructor() {
|
|
17914
|
+
super(...arguments);
|
|
17915
|
+
this.tokenize = tokenize;
|
|
17916
|
+
}
|
|
17917
|
+
equals(left, right, options) {
|
|
17918
|
+
if (options.ignoreWhitespace) {
|
|
17919
|
+
if (!options.newlineIsToken || !left.includes("\n")) {
|
|
17920
|
+
left = left.trim();
|
|
17921
|
+
}
|
|
17922
|
+
if (!options.newlineIsToken || !right.includes("\n")) {
|
|
17923
|
+
right = right.trim();
|
|
17924
|
+
}
|
|
17925
|
+
} else if (options.ignoreNewlineAtEof && !options.newlineIsToken) {
|
|
17926
|
+
if (left.endsWith("\n")) {
|
|
17927
|
+
left = left.slice(0, -1);
|
|
17928
|
+
}
|
|
17929
|
+
if (right.endsWith("\n")) {
|
|
17930
|
+
right = right.slice(0, -1);
|
|
16969
17931
|
}
|
|
16970
|
-
continue;
|
|
16971
17932
|
}
|
|
16972
|
-
|
|
16973
|
-
model: {
|
|
16974
|
-
ref,
|
|
16975
|
-
label: `${native.provider} / ${native.id}`
|
|
16976
|
-
},
|
|
16977
|
-
reasoning: native.reasoning
|
|
16978
|
-
});
|
|
17933
|
+
return super.equals(left, right, options);
|
|
16979
17934
|
}
|
|
16980
|
-
|
|
16981
|
-
|
|
16982
|
-
|
|
17935
|
+
};
|
|
17936
|
+
var lineDiff = new LineDiff();
|
|
17937
|
+
function diffLines(oldStr, newStr, options) {
|
|
17938
|
+
return lineDiff.diff(oldStr, newStr, options);
|
|
17939
|
+
}
|
|
17940
|
+
function tokenize(value, options) {
|
|
17941
|
+
if (options.stripTrailingCr) {
|
|
17942
|
+
value = value.replace(/\r\n/g, "\n");
|
|
16983
17943
|
}
|
|
16984
|
-
|
|
16985
|
-
|
|
17944
|
+
const retLines = [], linesAndNewlines = value.split(/(\n|\r\n)/);
|
|
17945
|
+
if (!linesAndNewlines[linesAndNewlines.length - 1]) {
|
|
17946
|
+
linesAndNewlines.pop();
|
|
16986
17947
|
}
|
|
16987
|
-
|
|
16988
|
-
|
|
17948
|
+
for (let i = 0; i < linesAndNewlines.length; i++) {
|
|
17949
|
+
const line = linesAndNewlines[i];
|
|
17950
|
+
if (i % 2 && !options.newlineIsToken) {
|
|
17951
|
+
retLines[retLines.length - 1] += line;
|
|
17952
|
+
} else {
|
|
17953
|
+
retLines.push(line);
|
|
17954
|
+
}
|
|
16989
17955
|
}
|
|
16990
|
-
|
|
16991
|
-
const allThinkingOptionIds = thinkingOptions.map(({ id }) => id);
|
|
16992
|
-
const offThinkingOptionId = thinkingOptions.find(({ id }) => id === "off")?.id;
|
|
16993
|
-
const models = [...byRef.values()].map(({ model, reasoning }) => ({
|
|
16994
|
-
...model,
|
|
16995
|
-
supportedThinkingOptionIds: reasoning ? allThinkingOptionIds : offThinkingOptionId ? [offThinkingOptionId] : []
|
|
16996
|
-
})).sort((left, right) => compareText(left.label, right.label) || compareText(left.ref.id, right.ref.id));
|
|
16997
|
-
const defaultThinkingOptionId = thinkingOptions.find(({ id }) => id === effectiveThinkingOptionId)?.id;
|
|
16998
|
-
return harnessModelCatalogSchema.parse({
|
|
16999
|
-
models,
|
|
17000
|
-
...defaultModel ? { defaultModel } : {},
|
|
17001
|
-
thinkingOptions,
|
|
17002
|
-
...defaultThinkingOptionId ? { defaultThinkingOptionId } : {}
|
|
17003
|
-
});
|
|
17956
|
+
return retLines;
|
|
17004
17957
|
}
|
|
17005
17958
|
|
|
17006
|
-
//
|
|
17007
|
-
function
|
|
17008
|
-
|
|
17009
|
-
|
|
17010
|
-
function
|
|
17011
|
-
|
|
17012
|
-
|
|
17013
|
-
|
|
17014
|
-
|
|
17015
|
-
|
|
17016
|
-
|
|
17017
|
-
|
|
17959
|
+
// ../../../node_modules/diff/libesm/patch/parse.js
|
|
17960
|
+
function parsePatch(uniDiff) {
|
|
17961
|
+
const diffstr = uniDiff.split(/\n/), list = [];
|
|
17962
|
+
let i = 0;
|
|
17963
|
+
function parseIndex() {
|
|
17964
|
+
const index = {};
|
|
17965
|
+
list.push(index);
|
|
17966
|
+
while (i < diffstr.length) {
|
|
17967
|
+
const line = diffstr[i];
|
|
17968
|
+
if (/^(---|\+\+\+|@@)\s/.test(line)) {
|
|
17969
|
+
break;
|
|
17970
|
+
}
|
|
17971
|
+
const header = /^(?:Index:|diff(?: -r \w+)+)\s+(.+?)\s*$/.exec(line);
|
|
17972
|
+
if (header) {
|
|
17973
|
+
index.index = header[1];
|
|
17974
|
+
}
|
|
17975
|
+
i++;
|
|
17976
|
+
}
|
|
17977
|
+
parseFileHeader(index);
|
|
17978
|
+
parseFileHeader(index);
|
|
17979
|
+
index.hunks = [];
|
|
17980
|
+
while (i < diffstr.length) {
|
|
17981
|
+
const line = diffstr[i];
|
|
17982
|
+
if (/^(Index:\s|diff\s|---\s|\+\+\+\s|===================================================================)/.test(line)) {
|
|
17983
|
+
break;
|
|
17984
|
+
} else if (/^@@/.test(line)) {
|
|
17985
|
+
index.hunks.push(parseHunk());
|
|
17986
|
+
} else if (line) {
|
|
17987
|
+
throw new Error("Unknown line " + (i + 1) + " " + JSON.stringify(line));
|
|
17988
|
+
} else {
|
|
17989
|
+
i++;
|
|
17990
|
+
}
|
|
17991
|
+
}
|
|
17018
17992
|
}
|
|
17019
|
-
|
|
17020
|
-
|
|
17021
|
-
|
|
17022
|
-
|
|
17023
|
-
|
|
17024
|
-
|
|
17025
|
-
|
|
17026
|
-
|
|
17027
|
-
|
|
17028
|
-
|
|
17029
|
-
|
|
17030
|
-
|
|
17031
|
-
|
|
17032
|
-
|
|
17033
|
-
|
|
17034
|
-
|
|
17035
|
-
}
|
|
17036
|
-
function textContent(value) {
|
|
17037
|
-
if (typeof value === "string")
|
|
17038
|
-
return value;
|
|
17039
|
-
if (!Array.isArray(value))
|
|
17040
|
-
return "";
|
|
17041
|
-
return value.filter((part) => isRecord4(part) && part.type === "text" && typeof part.text === "string").map((part) => part.text).join("");
|
|
17042
|
-
}
|
|
17043
|
-
function thinkingContent(value) {
|
|
17044
|
-
if (!Array.isArray(value))
|
|
17045
|
-
return "";
|
|
17046
|
-
return value.filter((part) => isRecord4(part) && part.type === "thinking" && typeof part.thinking === "string").map((part) => part.thinking).join("");
|
|
17047
|
-
}
|
|
17048
|
-
function validatedEntry(value) {
|
|
17049
|
-
if (typeof value.id !== "string" || value.id.length === 0 || value.parentId !== null && typeof value.parentId !== "string" || typeof value.type !== "string") {
|
|
17050
|
-
throw new Error("Omp history contains an invalid Entry identity");
|
|
17993
|
+
function parseFileHeader(index) {
|
|
17994
|
+
const fileHeader = /^(---|\+\+\+)\s+(.*)\r?$/.exec(diffstr[i]);
|
|
17995
|
+
if (fileHeader) {
|
|
17996
|
+
const data = fileHeader[2].split(" ", 2), header = (data[1] || "").trim();
|
|
17997
|
+
let fileName = data[0].replace(/\\\\/g, "\\");
|
|
17998
|
+
if (/^".*"$/.test(fileName)) {
|
|
17999
|
+
fileName = fileName.substr(1, fileName.length - 2);
|
|
18000
|
+
}
|
|
18001
|
+
if (fileHeader[1] === "---") {
|
|
18002
|
+
index.oldFileName = fileName;
|
|
18003
|
+
index.oldHeader = header;
|
|
18004
|
+
} else {
|
|
18005
|
+
index.newFileName = fileName;
|
|
18006
|
+
index.newHeader = header;
|
|
18007
|
+
}
|
|
18008
|
+
i++;
|
|
18009
|
+
}
|
|
17051
18010
|
}
|
|
17052
|
-
|
|
17053
|
-
|
|
17054
|
-
|
|
17055
|
-
|
|
17056
|
-
|
|
17057
|
-
|
|
17058
|
-
|
|
17059
|
-
|
|
17060
|
-
|
|
17061
|
-
|
|
17062
|
-
|
|
17063
|
-
|
|
17064
|
-
|
|
17065
|
-
if (
|
|
17066
|
-
|
|
17067
|
-
|
|
17068
|
-
|
|
17069
|
-
|
|
17070
|
-
|
|
17071
|
-
|
|
17072
|
-
|
|
18011
|
+
function parseHunk() {
|
|
18012
|
+
var _a3;
|
|
18013
|
+
const chunkHeaderIndex = i, chunkHeaderLine = diffstr[i++], chunkHeader = chunkHeaderLine.split(/@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/);
|
|
18014
|
+
const hunk = {
|
|
18015
|
+
oldStart: +chunkHeader[1],
|
|
18016
|
+
oldLines: typeof chunkHeader[2] === "undefined" ? 1 : +chunkHeader[2],
|
|
18017
|
+
newStart: +chunkHeader[3],
|
|
18018
|
+
newLines: typeof chunkHeader[4] === "undefined" ? 1 : +chunkHeader[4],
|
|
18019
|
+
lines: []
|
|
18020
|
+
};
|
|
18021
|
+
if (hunk.oldLines === 0) {
|
|
18022
|
+
hunk.oldStart += 1;
|
|
18023
|
+
}
|
|
18024
|
+
if (hunk.newLines === 0) {
|
|
18025
|
+
hunk.newStart += 1;
|
|
18026
|
+
}
|
|
18027
|
+
let addCount = 0, removeCount = 0;
|
|
18028
|
+
for (; i < diffstr.length && (removeCount < hunk.oldLines || addCount < hunk.newLines || ((_a3 = diffstr[i]) === null || _a3 === void 0 ? void 0 : _a3.startsWith("\\"))); i++) {
|
|
18029
|
+
const operation = diffstr[i].length == 0 && i != diffstr.length - 1 ? " " : diffstr[i][0];
|
|
18030
|
+
if (operation === "+" || operation === "-" || operation === " " || operation === "\\") {
|
|
18031
|
+
hunk.lines.push(diffstr[i]);
|
|
18032
|
+
if (operation === "+") {
|
|
18033
|
+
addCount++;
|
|
18034
|
+
} else if (operation === "-") {
|
|
18035
|
+
removeCount++;
|
|
18036
|
+
} else if (operation === " ") {
|
|
18037
|
+
addCount++;
|
|
18038
|
+
removeCount++;
|
|
18039
|
+
}
|
|
18040
|
+
} else {
|
|
18041
|
+
throw new Error(`Hunk at line ${chunkHeaderIndex + 1} contained invalid line ${diffstr[i]}`);
|
|
18042
|
+
}
|
|
18043
|
+
}
|
|
18044
|
+
if (!addCount && hunk.newLines === 1) {
|
|
18045
|
+
hunk.newLines = 0;
|
|
18046
|
+
}
|
|
18047
|
+
if (!removeCount && hunk.oldLines === 1) {
|
|
18048
|
+
hunk.oldLines = 0;
|
|
18049
|
+
}
|
|
18050
|
+
if (addCount !== hunk.newLines) {
|
|
18051
|
+
throw new Error("Added line count did not match for hunk at line " + (chunkHeaderIndex + 1));
|
|
18052
|
+
}
|
|
18053
|
+
if (removeCount !== hunk.oldLines) {
|
|
18054
|
+
throw new Error("Removed line count did not match for hunk at line " + (chunkHeaderIndex + 1));
|
|
18055
|
+
}
|
|
18056
|
+
return hunk;
|
|
17073
18057
|
}
|
|
17074
|
-
|
|
17075
|
-
|
|
17076
|
-
|
|
17077
|
-
return
|
|
17078
|
-
}
|
|
17079
|
-
function messageRole(entry) {
|
|
17080
|
-
const value = message(entry)?.role;
|
|
17081
|
-
return typeof value === "string" ? value : null;
|
|
17082
|
-
}
|
|
17083
|
-
function itemId(entryId, kind, ordinal) {
|
|
17084
|
-
return hostItemIdSchema.parse(`omp-item-v1-${entryId}-${kind}-${ordinal}`);
|
|
18058
|
+
while (i < diffstr.length) {
|
|
18059
|
+
parseIndex();
|
|
18060
|
+
}
|
|
18061
|
+
return list;
|
|
17085
18062
|
}
|
|
17086
|
-
|
|
17087
|
-
|
|
17088
|
-
|
|
17089
|
-
|
|
17090
|
-
|
|
17091
|
-
|
|
17092
|
-
if (
|
|
17093
|
-
|
|
18063
|
+
|
|
18064
|
+
// ../../../node_modules/diff/libesm/patch/create.js
|
|
18065
|
+
function structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
|
|
18066
|
+
let optionsObj;
|
|
18067
|
+
if (!options) {
|
|
18068
|
+
optionsObj = {};
|
|
18069
|
+
} else if (typeof options === "function") {
|
|
18070
|
+
optionsObj = { callback: options };
|
|
18071
|
+
} else {
|
|
18072
|
+
optionsObj = options;
|
|
17094
18073
|
}
|
|
17095
|
-
if (
|
|
17096
|
-
|
|
17097
|
-
status: "failed",
|
|
17098
|
-
error: {
|
|
17099
|
-
code: "nativeFailure",
|
|
17100
|
-
message: typeof final.errorMessage === "string" && final.errorMessage.length > 0 ? final.errorMessage : "Omp Assistant failed",
|
|
17101
|
-
retryable: false
|
|
17102
|
-
}
|
|
17103
|
-
};
|
|
18074
|
+
if (typeof optionsObj.context === "undefined") {
|
|
18075
|
+
optionsObj.context = 4;
|
|
17104
18076
|
}
|
|
17105
|
-
|
|
17106
|
-
|
|
18077
|
+
const context = optionsObj.context;
|
|
18078
|
+
if (optionsObj.newlineIsToken) {
|
|
18079
|
+
throw new Error("newlineIsToken may not be used with patch-generation functions, only with diffing functions");
|
|
17107
18080
|
}
|
|
17108
|
-
|
|
17109
|
-
|
|
17110
|
-
|
|
17111
|
-
|
|
17112
|
-
|
|
17113
|
-
|
|
17114
|
-
|
|
17115
|
-
|
|
17116
|
-
...outcome.reason ? { reason: outcome.reason } : {}
|
|
17117
|
-
};
|
|
18081
|
+
if (!optionsObj.callback) {
|
|
18082
|
+
return diffLinesResultToPatch(diffLines(oldStr, newStr, optionsObj));
|
|
18083
|
+
} else {
|
|
18084
|
+
const { callback } = optionsObj;
|
|
18085
|
+
diffLines(oldStr, newStr, Object.assign(Object.assign({}, optionsObj), { callback: (diff) => {
|
|
18086
|
+
const patch = diffLinesResultToPatch(diff);
|
|
18087
|
+
callback(patch);
|
|
18088
|
+
} }));
|
|
17118
18089
|
}
|
|
17119
|
-
|
|
17120
|
-
|
|
17121
|
-
|
|
17122
|
-
|
|
17123
|
-
|
|
17124
|
-
|
|
17125
|
-
|
|
17126
|
-
|
|
17127
|
-
|
|
17128
|
-
|
|
17129
|
-
const
|
|
17130
|
-
|
|
17131
|
-
|
|
17132
|
-
|
|
17133
|
-
|
|
17134
|
-
|
|
17135
|
-
|
|
17136
|
-
|
|
17137
|
-
|
|
17138
|
-
|
|
17139
|
-
|
|
17140
|
-
|
|
17141
|
-
|
|
17142
|
-
|
|
17143
|
-
|
|
17144
|
-
itemId: itemId(entry.id, "reasoning", 0),
|
|
17145
|
-
text: reasoning
|
|
17146
|
-
};
|
|
17147
|
-
snapshots.push({ item: item2, outcome: itemOutcome(outcome) });
|
|
17148
|
-
projectedReasoning = true;
|
|
17149
|
-
continue;
|
|
18090
|
+
function diffLinesResultToPatch(diff) {
|
|
18091
|
+
if (!diff) {
|
|
18092
|
+
return;
|
|
18093
|
+
}
|
|
18094
|
+
diff.push({ value: "", lines: [] });
|
|
18095
|
+
function contextLines(lines) {
|
|
18096
|
+
return lines.map(function(entry) {
|
|
18097
|
+
return " " + entry;
|
|
18098
|
+
});
|
|
18099
|
+
}
|
|
18100
|
+
const hunks = [];
|
|
18101
|
+
let oldRangeStart = 0, newRangeStart = 0, curRange = [], oldLine = 1, newLine = 1;
|
|
18102
|
+
for (let i = 0; i < diff.length; i++) {
|
|
18103
|
+
const current = diff[i], lines = current.lines || splitLines(current.value);
|
|
18104
|
+
current.lines = lines;
|
|
18105
|
+
if (current.added || current.removed) {
|
|
18106
|
+
if (!oldRangeStart) {
|
|
18107
|
+
const prev = diff[i - 1];
|
|
18108
|
+
oldRangeStart = oldLine;
|
|
18109
|
+
newRangeStart = newLine;
|
|
18110
|
+
if (prev) {
|
|
18111
|
+
curRange = context > 0 ? contextLines(prev.lines.slice(-context)) : [];
|
|
18112
|
+
oldRangeStart -= curRange.length;
|
|
18113
|
+
newRangeStart -= curRange.length;
|
|
18114
|
+
}
|
|
17150
18115
|
}
|
|
17151
|
-
|
|
17152
|
-
|
|
17153
|
-
type: "agentMessage",
|
|
17154
|
-
itemId: itemId(entry.id, "assistant", 0),
|
|
17155
|
-
text
|
|
17156
|
-
};
|
|
17157
|
-
snapshots.push({ item: item2, outcome: itemOutcome(outcome) });
|
|
17158
|
-
projectedText = true;
|
|
17159
|
-
continue;
|
|
18116
|
+
for (const line of lines) {
|
|
18117
|
+
curRange.push((current.added ? "+" : "-") + line);
|
|
17160
18118
|
}
|
|
17161
|
-
if (
|
|
17162
|
-
|
|
18119
|
+
if (current.added) {
|
|
18120
|
+
newLine += lines.length;
|
|
18121
|
+
} else {
|
|
18122
|
+
oldLine += lines.length;
|
|
17163
18123
|
}
|
|
17164
|
-
|
|
17165
|
-
if (
|
|
17166
|
-
|
|
17167
|
-
|
|
17168
|
-
|
|
17169
|
-
|
|
17170
|
-
|
|
17171
|
-
|
|
17172
|
-
|
|
18124
|
+
} else {
|
|
18125
|
+
if (oldRangeStart) {
|
|
18126
|
+
if (lines.length <= context * 2 && i < diff.length - 2) {
|
|
18127
|
+
for (const line of contextLines(lines)) {
|
|
18128
|
+
curRange.push(line);
|
|
18129
|
+
}
|
|
18130
|
+
} else {
|
|
18131
|
+
const contextSize = Math.min(lines.length, context);
|
|
18132
|
+
for (const line of contextLines(lines.slice(0, contextSize))) {
|
|
18133
|
+
curRange.push(line);
|
|
18134
|
+
}
|
|
18135
|
+
const hunk = {
|
|
18136
|
+
oldStart: oldRangeStart,
|
|
18137
|
+
oldLines: oldLine - oldRangeStart + contextSize,
|
|
18138
|
+
newStart: newRangeStart,
|
|
18139
|
+
newLines: newLine - newRangeStart + contextSize,
|
|
18140
|
+
lines: curRange
|
|
18141
|
+
};
|
|
18142
|
+
hunks.push(hunk);
|
|
18143
|
+
oldRangeStart = 0;
|
|
18144
|
+
newRangeStart = 0;
|
|
18145
|
+
curRange = [];
|
|
18146
|
+
}
|
|
18147
|
+
}
|
|
18148
|
+
oldLine += lines.length;
|
|
18149
|
+
newLine += lines.length;
|
|
17173
18150
|
}
|
|
17174
|
-
continue;
|
|
17175
18151
|
}
|
|
17176
|
-
|
|
17177
|
-
|
|
18152
|
+
for (const hunk of hunks) {
|
|
18153
|
+
for (let i = 0; i < hunk.lines.length; i++) {
|
|
18154
|
+
if (hunk.lines[i].endsWith("\n")) {
|
|
18155
|
+
hunk.lines[i] = hunk.lines[i].slice(0, -1);
|
|
18156
|
+
} else {
|
|
18157
|
+
hunk.lines.splice(i + 1, 0, "\");
|
|
18158
|
+
i++;
|
|
18159
|
+
}
|
|
18160
|
+
}
|
|
17178
18161
|
}
|
|
17179
|
-
|
|
17180
|
-
|
|
17181
|
-
|
|
17182
|
-
|
|
17183
|
-
|
|
17184
|
-
|
|
17185
|
-
itemId: itemId(call.entryId, "tool", call.ordinal),
|
|
17186
|
-
toolName: call.name,
|
|
17187
|
-
arguments: call.arguments
|
|
17188
|
-
}),
|
|
17189
|
-
...output ? { output: textContent(output.content) } : {}
|
|
18162
|
+
return {
|
|
18163
|
+
oldFileName,
|
|
18164
|
+
newFileName,
|
|
18165
|
+
oldHeader,
|
|
18166
|
+
newHeader,
|
|
18167
|
+
hunks
|
|
17190
18168
|
};
|
|
17191
|
-
const toolFailed = nativeMessage.isError === true;
|
|
17192
|
-
snapshots.push({
|
|
17193
|
-
item,
|
|
17194
|
-
outcome: toolFailed ? {
|
|
17195
|
-
status: "failed",
|
|
17196
|
-
error: {
|
|
17197
|
-
code: "nativeFailure",
|
|
17198
|
-
message: `Omp Tool '${call.name}' failed`,
|
|
17199
|
-
retryable: false
|
|
17200
|
-
}
|
|
17201
|
-
} : { status: "succeeded" }
|
|
17202
|
-
});
|
|
17203
18169
|
}
|
|
17204
|
-
return snapshots;
|
|
17205
|
-
}
|
|
17206
|
-
function modelChange(entry) {
|
|
17207
|
-
return entry.type === "model_change" && typeof entry.provider === "string" && typeof entry.modelId === "string" ? { provider: entry.provider, id: entry.modelId } : null;
|
|
17208
18170
|
}
|
|
17209
|
-
function
|
|
17210
|
-
|
|
17211
|
-
|
|
17212
|
-
|
|
17213
|
-
|
|
17214
|
-
|
|
17215
|
-
|
|
17216
|
-
|
|
17217
|
-
|
|
17218
|
-
|
|
18171
|
+
function formatPatch(patch) {
|
|
18172
|
+
if (Array.isArray(patch)) {
|
|
18173
|
+
return patch.map(formatPatch).join("\n");
|
|
18174
|
+
}
|
|
18175
|
+
const ret = [];
|
|
18176
|
+
if (patch.oldFileName == patch.newFileName) {
|
|
18177
|
+
ret.push("Index: " + patch.oldFileName);
|
|
18178
|
+
}
|
|
18179
|
+
ret.push("===================================================================");
|
|
18180
|
+
ret.push("--- " + patch.oldFileName + (typeof patch.oldHeader === "undefined" ? "" : " " + patch.oldHeader));
|
|
18181
|
+
ret.push("+++ " + patch.newFileName + (typeof patch.newHeader === "undefined" ? "" : " " + patch.newHeader));
|
|
18182
|
+
for (let i = 0; i < patch.hunks.length; i++) {
|
|
18183
|
+
const hunk = patch.hunks[i];
|
|
18184
|
+
if (hunk.oldLines === 0) {
|
|
18185
|
+
hunk.oldStart -= 1;
|
|
17219
18186
|
}
|
|
17220
|
-
|
|
17221
|
-
|
|
17222
|
-
index += 1;
|
|
17223
|
-
continue;
|
|
18187
|
+
if (hunk.newLines === 0) {
|
|
18188
|
+
hunk.newStart -= 1;
|
|
17224
18189
|
}
|
|
17225
|
-
|
|
17226
|
-
|
|
17227
|
-
|
|
17228
|
-
|
|
17229
|
-
|
|
17230
|
-
|
|
17231
|
-
|
|
17232
|
-
|
|
17233
|
-
|
|
17234
|
-
|
|
17235
|
-
|
|
17236
|
-
|
|
17237
|
-
const
|
|
17238
|
-
|
|
17239
|
-
|
|
17240
|
-
checkpointId: user.id,
|
|
17241
|
-
formatVersion: 1
|
|
17242
|
-
});
|
|
17243
|
-
turns.push({
|
|
17244
|
-
nativeTurnRef,
|
|
17245
|
-
checkpoint,
|
|
17246
|
-
input: [{ type: "text", text: userText }],
|
|
17247
|
-
items: snapshotItems(entries, outcome),
|
|
17248
|
-
outcome,
|
|
17249
|
-
...effectiveModel ? { model: encodeOmpModelRef(effectiveModel) } : {}
|
|
17250
|
-
});
|
|
17251
|
-
for (const entry of entries) {
|
|
17252
|
-
const changed = modelChange(entry);
|
|
17253
|
-
if (changed)
|
|
17254
|
-
effectiveModel = changed;
|
|
18190
|
+
ret.push("@@ -" + hunk.oldStart + "," + hunk.oldLines + " +" + hunk.newStart + "," + hunk.newLines + " @@");
|
|
18191
|
+
for (const line of hunk.lines) {
|
|
18192
|
+
ret.push(line);
|
|
18193
|
+
}
|
|
18194
|
+
}
|
|
18195
|
+
return ret.join("\n") + "\n";
|
|
18196
|
+
}
|
|
18197
|
+
function createTwoFilesPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
|
|
18198
|
+
if (typeof options === "function") {
|
|
18199
|
+
options = { callback: options };
|
|
18200
|
+
}
|
|
18201
|
+
if (!(options === null || options === void 0 ? void 0 : options.callback)) {
|
|
18202
|
+
const patchObj = structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options);
|
|
18203
|
+
if (!patchObj) {
|
|
18204
|
+
return;
|
|
17255
18205
|
}
|
|
17256
|
-
|
|
18206
|
+
return formatPatch(patchObj);
|
|
18207
|
+
} else {
|
|
18208
|
+
const { callback } = options;
|
|
18209
|
+
structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, Object.assign(Object.assign({}, options), { callback: (patchObj) => {
|
|
18210
|
+
if (!patchObj) {
|
|
18211
|
+
callback(void 0);
|
|
18212
|
+
} else {
|
|
18213
|
+
callback(formatPatch(patchObj));
|
|
18214
|
+
}
|
|
18215
|
+
} }));
|
|
17257
18216
|
}
|
|
17258
|
-
return { turns };
|
|
17259
18217
|
}
|
|
17260
|
-
function
|
|
17261
|
-
const
|
|
17262
|
-
const
|
|
17263
|
-
|
|
18218
|
+
function splitLines(text) {
|
|
18219
|
+
const hasTrailingNl = text.endsWith("\n");
|
|
18220
|
+
const result = text.split("\n").map((line) => line + "\n");
|
|
18221
|
+
if (hasTrailingNl) {
|
|
18222
|
+
result.pop();
|
|
18223
|
+
} else {
|
|
18224
|
+
result.push(result.pop().slice(0, -1));
|
|
18225
|
+
}
|
|
18226
|
+
return result;
|
|
17264
18227
|
}
|
|
17265
|
-
|
|
17266
|
-
|
|
17267
|
-
|
|
17268
|
-
|
|
17269
|
-
|
|
17270
|
-
|
|
17271
|
-
|
|
17272
|
-
|
|
17273
|
-
|
|
17274
|
-
|
|
18228
|
+
|
|
18229
|
+
// dist/omp-adapter.js
|
|
18230
|
+
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
18231
|
+
import { realpath as realpath3, stat as stat2 } from "node:fs/promises";
|
|
18232
|
+
import path7 from "node:path";
|
|
18233
|
+
|
|
18234
|
+
// dist/omp-slash-commands.js
|
|
18235
|
+
var OMP_LIVE_COMMAND_ID_PREFIX = "omp.slash.";
|
|
18236
|
+
function isRecord6(value) {
|
|
18237
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
18238
|
+
}
|
|
18239
|
+
function parseOmpAvailableCommands(value) {
|
|
18240
|
+
if (!Array.isArray(value))
|
|
18241
|
+
return [];
|
|
18242
|
+
return value.flatMap((entry) => {
|
|
18243
|
+
if (!isRecord6(entry))
|
|
18244
|
+
return [];
|
|
18245
|
+
const name = typeof entry.name === "string" ? entry.name.trim().replace(/^\//u, "") : "";
|
|
18246
|
+
if (!name)
|
|
18247
|
+
return [];
|
|
18248
|
+
return [
|
|
18249
|
+
{
|
|
18250
|
+
name,
|
|
18251
|
+
description: typeof entry.description === "string" ? entry.description : "",
|
|
18252
|
+
source: typeof entry.source === "string" ? entry.source : null
|
|
18253
|
+
}
|
|
18254
|
+
];
|
|
18255
|
+
});
|
|
18256
|
+
}
|
|
18257
|
+
function ompLiveCommands(native) {
|
|
18258
|
+
return native.filter(({ source, name }) => source !== "builtin" || name === "context").map((command) => ({
|
|
18259
|
+
name: command.name,
|
|
18260
|
+
description: command.description,
|
|
18261
|
+
kind: command.source === "skill" ? "skill" : "command"
|
|
18262
|
+
}));
|
|
17275
18263
|
}
|
|
17276
18264
|
|
|
17277
18265
|
// dist/omp-session-file.js
|
|
17278
|
-
import { createReadStream } from "node:fs";
|
|
17279
|
-
import { open, realpath } from "node:fs/promises";
|
|
18266
|
+
import { createReadStream as createReadStream3 } from "node:fs";
|
|
18267
|
+
import { open, realpath as realpath2 } from "node:fs/promises";
|
|
17280
18268
|
import readline from "node:readline";
|
|
17281
18269
|
var MAX_SESSION_HEADER_BYTES = 64 * 1024;
|
|
17282
18270
|
var utf8Decoder = new TextDecoder("utf-8", { fatal: true });
|
|
17283
|
-
function
|
|
18271
|
+
function isRecord7(value) {
|
|
17284
18272
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
17285
18273
|
}
|
|
17286
18274
|
function historyEntry(value) {
|
|
17287
|
-
if (!
|
|
18275
|
+
if (!isRecord7(value) || value.type === "title" || value.type === "session" || typeof value.id !== "string" || value.id.length === 0 || value.parentId !== null && typeof value.parentId !== "string" || typeof value.type !== "string") {
|
|
17288
18276
|
return null;
|
|
17289
18277
|
}
|
|
17290
18278
|
return value;
|
|
@@ -17292,8 +18280,9 @@ function historyEntry(value) {
|
|
|
17292
18280
|
async function readOmpSessionHistory(sessionFile, maxBytes) {
|
|
17293
18281
|
const entries = [];
|
|
17294
18282
|
let leafId = null;
|
|
18283
|
+
let incomplete = false;
|
|
17295
18284
|
const lines = readline.createInterface({
|
|
17296
|
-
input:
|
|
18285
|
+
input: createReadStream3(sessionFile, {
|
|
17297
18286
|
encoding: "utf8",
|
|
17298
18287
|
...maxBytes === void 0 ? {} : { end: maxBytes - 1 }
|
|
17299
18288
|
}),
|
|
@@ -17307,18 +18296,23 @@ async function readOmpSessionHistory(sessionFile, maxBytes) {
|
|
|
17307
18296
|
try {
|
|
17308
18297
|
parsed = JSON.parse(line);
|
|
17309
18298
|
} catch {
|
|
18299
|
+
incomplete = true;
|
|
17310
18300
|
continue;
|
|
17311
18301
|
}
|
|
17312
18302
|
const entry = historyEntry(parsed);
|
|
17313
|
-
if (!entry)
|
|
18303
|
+
if (!entry) {
|
|
18304
|
+
if (!isRecord7(parsed) || parsed.type !== "title" && parsed.type !== "session") {
|
|
18305
|
+
incomplete = true;
|
|
18306
|
+
}
|
|
17314
18307
|
continue;
|
|
18308
|
+
}
|
|
17315
18309
|
entries.push(entry);
|
|
17316
18310
|
leafId = entry.id;
|
|
17317
18311
|
}
|
|
17318
18312
|
} finally {
|
|
17319
18313
|
lines.close();
|
|
17320
18314
|
}
|
|
17321
|
-
return { entries, leafId };
|
|
18315
|
+
return { entries, leafId, ...incomplete ? { incomplete: true } : {} };
|
|
17322
18316
|
}
|
|
17323
18317
|
async function readOmpSessionHeader(sessionFile) {
|
|
17324
18318
|
const handle = await open(sessionFile, "r");
|
|
@@ -17340,7 +18334,7 @@ async function readOmpSessionHeader(sessionFile) {
|
|
|
17340
18334
|
} catch {
|
|
17341
18335
|
continue;
|
|
17342
18336
|
}
|
|
17343
|
-
if (!
|
|
18337
|
+
if (!isRecord7(parsed) || parsed.type !== "session")
|
|
17344
18338
|
continue;
|
|
17345
18339
|
if (typeof parsed.id !== "string" || parsed.id.length === 0 || typeof parsed.cwd !== "string" || parsed.cwd.length === 0) {
|
|
17346
18340
|
throw new Error("Omp Session header is invalid");
|
|
@@ -17360,8 +18354,8 @@ async function verifyOmpSessionCwd(input) {
|
|
|
17360
18354
|
throw new Error("Omp Fork Session header identity does not match RPC state");
|
|
17361
18355
|
}
|
|
17362
18356
|
const [actualCwd, expectedCwd] = await Promise.all([
|
|
17363
|
-
|
|
17364
|
-
|
|
18357
|
+
realpath2(header.cwd),
|
|
18358
|
+
realpath2(input.expectedCwd)
|
|
17365
18359
|
]);
|
|
17366
18360
|
if (actualCwd !== expectedCwd) {
|
|
17367
18361
|
throw new Error("Omp Fork Session did not bind the requested cwd");
|
|
@@ -17423,7 +18417,7 @@ async function rollbackOmpLastTurn(transport, sourceSessionId, cwd) {
|
|
|
17423
18417
|
// dist/omp-rpc-session.js
|
|
17424
18418
|
import { spawn, spawnSync } from "node:child_process";
|
|
17425
18419
|
import { randomUUID } from "node:crypto";
|
|
17426
|
-
import
|
|
18420
|
+
import path6 from "node:path";
|
|
17427
18421
|
|
|
17428
18422
|
// dist/command.js
|
|
17429
18423
|
var ompDiscoverySpec = {
|
|
@@ -17451,77 +18445,6 @@ function resolveOmpExecutable(input, dependencies = {}) {
|
|
|
17451
18445
|
return resolution?.executable ?? input.command ?? input.environment.OMP_COMMAND ?? "omp";
|
|
17452
18446
|
}
|
|
17453
18447
|
|
|
17454
|
-
// dist/omp-usage.js
|
|
17455
|
-
function isRecord6(value) {
|
|
17456
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
17457
|
-
}
|
|
17458
|
-
function nonNegativeSafeInteger(value) {
|
|
17459
|
-
return typeof value === "number" && Number.isSafeInteger(value) && value >= 0 ? value : null;
|
|
17460
|
-
}
|
|
17461
|
-
function optionalOmpCacheHitRatePercent(value) {
|
|
17462
|
-
if (!isRecord6(value) || value.role !== "assistant" || !isRecord6(value.usage))
|
|
17463
|
-
return null;
|
|
17464
|
-
const input = nonNegativeSafeInteger(value.usage.input);
|
|
17465
|
-
const cacheRead = nonNegativeSafeInteger(value.usage.cacheRead);
|
|
17466
|
-
const cacheWrite = nonNegativeSafeInteger(value.usage.cacheWrite);
|
|
17467
|
-
if (input === null || cacheRead === null || cacheWrite === null)
|
|
17468
|
-
return null;
|
|
17469
|
-
const promptTokens = input + cacheRead + cacheWrite;
|
|
17470
|
-
return promptTokens > 0 ? cacheRead / promptTokens * 100 : null;
|
|
17471
|
-
}
|
|
17472
|
-
function latestOmpCacheHitRatePercent(history) {
|
|
17473
|
-
let latest = null;
|
|
17474
|
-
for (const entry of activeOmpEntries(history)) {
|
|
17475
|
-
if (entry.type === "message" && isRecord6(entry.message) && entry.message.role === "assistant") {
|
|
17476
|
-
latest = optionalOmpCacheHitRatePercent(entry.message);
|
|
17477
|
-
}
|
|
17478
|
-
}
|
|
17479
|
-
return latest;
|
|
17480
|
-
}
|
|
17481
|
-
function responseData(response, operation) {
|
|
17482
|
-
if (!isRecord6(response.data)) {
|
|
17483
|
-
throw new Error(`Omp RPC ${operation} response has no data`);
|
|
17484
|
-
}
|
|
17485
|
-
return response.data;
|
|
17486
|
-
}
|
|
17487
|
-
function contextUsage(value) {
|
|
17488
|
-
if (!isRecord6(value))
|
|
17489
|
-
throw new Error("Omp RPC context Usage is invalid");
|
|
17490
|
-
return parseHostUsage({
|
|
17491
|
-
contextUsedTokens: value.tokens,
|
|
17492
|
-
contextWindowTokens: value.contextWindow
|
|
17493
|
-
});
|
|
17494
|
-
}
|
|
17495
|
-
function parseOmpSessionUsage(response) {
|
|
17496
|
-
const data = responseData(response, "Session stats");
|
|
17497
|
-
const tokens = data.tokens;
|
|
17498
|
-
if (tokens !== void 0 && !isRecord6(tokens)) {
|
|
17499
|
-
throw new Error("Omp RPC Session stats tokens are invalid");
|
|
17500
|
-
}
|
|
17501
|
-
return parseHostUsage({
|
|
17502
|
-
...isRecord6(tokens) && tokens.input !== void 0 ? { inputTokens: tokens.input } : {},
|
|
17503
|
-
...isRecord6(tokens) && tokens.cacheRead !== void 0 ? { cachedInputTokens: tokens.cacheRead } : {},
|
|
17504
|
-
...isRecord6(tokens) && tokens.cacheWrite !== void 0 ? { cacheWriteInputTokens: tokens.cacheWrite } : {},
|
|
17505
|
-
...isRecord6(tokens) && tokens.output !== void 0 ? { outputTokens: tokens.output } : {},
|
|
17506
|
-
...isRecord6(tokens) && tokens.total !== void 0 ? { totalTokens: tokens.total } : {},
|
|
17507
|
-
...data.cost !== void 0 ? { totalCostUsd: data.cost } : {},
|
|
17508
|
-
...data.contextUsage !== void 0 ? contextUsage(data.contextUsage) : {}
|
|
17509
|
-
});
|
|
17510
|
-
}
|
|
17511
|
-
function parseOmpStateContextUsage(response) {
|
|
17512
|
-
const data = responseData(response, "state");
|
|
17513
|
-
return data.contextUsage === void 0 ? null : contextUsage(data.contextUsage);
|
|
17514
|
-
}
|
|
17515
|
-
function optionalOmpStateContextUsage(value) {
|
|
17516
|
-
if (value === void 0)
|
|
17517
|
-
return null;
|
|
17518
|
-
try {
|
|
17519
|
-
return contextUsage(value);
|
|
17520
|
-
} catch {
|
|
17521
|
-
return null;
|
|
17522
|
-
}
|
|
17523
|
-
}
|
|
17524
|
-
|
|
17525
18448
|
// dist/omp-protocol.js
|
|
17526
18449
|
var MAX_FRAME_BYTES = 1024 * 1024;
|
|
17527
18450
|
var MAX_REASSEMBLED_BYTES = 64 * 1024 * 1024;
|
|
@@ -17541,10 +18464,10 @@ var OmpFrameDecoder = class {
|
|
|
17541
18464
|
}
|
|
17542
18465
|
const chunkId = value.chunkId;
|
|
17543
18466
|
const index = value.index;
|
|
17544
|
-
const
|
|
18467
|
+
const count2 = value.count;
|
|
17545
18468
|
const byteLength = value.byteLength;
|
|
17546
18469
|
const data = value.data;
|
|
17547
|
-
if (typeof chunkId !== "string" || chunkId.length === 0 || chunkId.length > 128 || !Number.isInteger(index) || !Number.isInteger(
|
|
18470
|
+
if (typeof chunkId !== "string" || chunkId.length === 0 || chunkId.length > 128 || !Number.isInteger(index) || !Number.isInteger(count2) || !Number.isInteger(byteLength) || index < 0 || count2 < 2 || index >= count2 || byteLength < MAX_FRAME_BYTES || byteLength > MAX_REASSEMBLED_BYTES || typeof data !== "string" || data.length === 0)
|
|
17548
18471
|
throw new Error("Invalid OMP RPC chunk metadata");
|
|
17549
18472
|
let bytes;
|
|
17550
18473
|
try {
|
|
@@ -17556,7 +18479,7 @@ var OmpFrameDecoder = class {
|
|
|
17556
18479
|
throw new Error("Invalid OMP RPC chunk data");
|
|
17557
18480
|
}
|
|
17558
18481
|
const chunkIndex = index;
|
|
17559
|
-
const chunkCount =
|
|
18482
|
+
const chunkCount = count2;
|
|
17560
18483
|
const declaredByteLength = byteLength;
|
|
17561
18484
|
if (!this.#pending) {
|
|
17562
18485
|
if (chunkIndex !== 0)
|
|
@@ -17618,7 +18541,7 @@ var OmpRpcUnsupportedCommandError = class extends Error {
|
|
|
17618
18541
|
}
|
|
17619
18542
|
};
|
|
17620
18543
|
var textDecoder = new TextDecoder("utf-8", { fatal: true });
|
|
17621
|
-
function
|
|
18544
|
+
function isRecord8(value) {
|
|
17622
18545
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
17623
18546
|
}
|
|
17624
18547
|
function message2(value) {
|
|
@@ -17630,20 +18553,20 @@ function nonBlankString(value) {
|
|
|
17630
18553
|
function parseNativeModel(value, context) {
|
|
17631
18554
|
if (value === null || value === void 0)
|
|
17632
18555
|
return null;
|
|
17633
|
-
if (!
|
|
18556
|
+
if (!isRecord8(value) || !nonBlankString(value.provider) || !nonBlankString(value.id)) {
|
|
17634
18557
|
throw new OmpRpcFaultError("protocolError", `Omp RPC returned an invalid ${context} Model`);
|
|
17635
18558
|
}
|
|
17636
18559
|
return { provider: value.provider, id: value.id };
|
|
17637
18560
|
}
|
|
17638
18561
|
function sessionStateData(response) {
|
|
17639
|
-
const data =
|
|
18562
|
+
const data = isRecord8(response.data) ? response.data : null;
|
|
17640
18563
|
if (!data)
|
|
17641
18564
|
throw new OmpRpcFaultError("protocolError", "Omp RPC state response has no data");
|
|
17642
18565
|
return data;
|
|
17643
18566
|
}
|
|
17644
18567
|
function parseSessionState(response) {
|
|
17645
18568
|
const data = sessionStateData(response);
|
|
17646
|
-
const
|
|
18569
|
+
const model2 = parseNativeModel(data.model, "state");
|
|
17647
18570
|
if (!nonBlankString(data.sessionId)) {
|
|
17648
18571
|
throw new OmpRpcFaultError("protocolError", "Omp RPC state has no stable Session identity");
|
|
17649
18572
|
}
|
|
@@ -17651,7 +18574,7 @@ function parseSessionState(response) {
|
|
|
17651
18574
|
if (thinkingLevel !== null && !thinkingLevel.success) {
|
|
17652
18575
|
throw new OmpRpcFaultError("protocolError", "Omp RPC state has an invalid Thinking level");
|
|
17653
18576
|
}
|
|
17654
|
-
const thinking =
|
|
18577
|
+
const thinking = isRecord8(data.model) && isRecord8(data.model.thinking) ? data.model.thinking : null;
|
|
17655
18578
|
const availableThinkingLevels = thinking && Array.isArray(thinking.efforts) ? thinking.efforts.flatMap((level) => {
|
|
17656
18579
|
const parsed = harnessThinkingOptionIdSchema.safeParse(level);
|
|
17657
18580
|
return parsed.success ? [parsed.data] : [];
|
|
@@ -17659,8 +18582,8 @@ function parseSessionState(response) {
|
|
|
17659
18582
|
return {
|
|
17660
18583
|
sessionId: data.sessionId,
|
|
17661
18584
|
sessionFile: typeof data.sessionFile === "string" ? data.sessionFile : null,
|
|
17662
|
-
provider:
|
|
17663
|
-
modelId:
|
|
18585
|
+
provider: model2?.provider ?? null,
|
|
18586
|
+
modelId: model2?.id ?? null,
|
|
17664
18587
|
thinkingLevel: thinkingLevel?.data ?? null,
|
|
17665
18588
|
contextUsage: optionalOmpStateContextUsage(data.contextUsage),
|
|
17666
18589
|
availableThinkingLevels
|
|
@@ -17673,26 +18596,30 @@ function parseSessionStreaming(response) {
|
|
|
17673
18596
|
}
|
|
17674
18597
|
return isStreaming;
|
|
17675
18598
|
}
|
|
18599
|
+
function cancellationSettled(response, terminalEnd) {
|
|
18600
|
+
const data = sessionStateData(response);
|
|
18601
|
+
return !parseSessionStreaming(response) && (data.isSettled === true || data.isSettled === void 0 && terminalEnd) && data.isCompacting !== true && data.hasPendingAsyncWork !== true && !(typeof data.queuedMessageCount === "number" && data.queuedMessageCount > 0);
|
|
18602
|
+
}
|
|
17676
18603
|
function parseAvailableModels(response) {
|
|
17677
|
-
const data =
|
|
18604
|
+
const data = isRecord8(response.data) ? response.data : null;
|
|
17678
18605
|
if (!data || !Array.isArray(data.models)) {
|
|
17679
18606
|
throw new OmpRpcFaultError("protocolError", "Omp RPC Model catalog response has no models");
|
|
17680
18607
|
}
|
|
17681
|
-
return data.models.map((
|
|
17682
|
-
const parsed = parseNativeModel(
|
|
17683
|
-
if (!parsed || !
|
|
18608
|
+
return data.models.map((model2) => {
|
|
18609
|
+
const parsed = parseNativeModel(model2, "catalog");
|
|
18610
|
+
if (!parsed || !isRecord8(model2) || typeof model2.reasoning !== "boolean") {
|
|
17684
18611
|
throw new OmpRpcFaultError("protocolError", "Omp RPC catalog contains a Model without reasoning capability");
|
|
17685
18612
|
}
|
|
17686
|
-
return { ...parsed, reasoning:
|
|
18613
|
+
return { ...parsed, reasoning: model2.reasoning };
|
|
17687
18614
|
});
|
|
17688
18615
|
}
|
|
17689
18616
|
function parseSubagentMessages(response) {
|
|
17690
|
-
const data =
|
|
18617
|
+
const data = isRecord8(response.data) ? response.data : null;
|
|
17691
18618
|
if (!data || !nonBlankString(data.sessionFile) || !Number.isSafeInteger(data.fromByte) || !Number.isSafeInteger(data.nextByte) || data.fromByte < 0 || data.nextByte < data.fromByte || typeof data.reset !== "boolean" || !Array.isArray(data.entries) || !Array.isArray(data.messages)) {
|
|
17692
18619
|
throw new OmpRpcFaultError("protocolError", "Omp RPC Subagent transcript response is invalid");
|
|
17693
18620
|
}
|
|
17694
|
-
const entries = data.entries.flatMap((value) =>
|
|
17695
|
-
const messages = data.messages.flatMap((value) =>
|
|
18621
|
+
const entries = data.entries.flatMap((value) => isRecord8(value) ? [value] : []);
|
|
18622
|
+
const messages = data.messages.flatMap((value) => isRecord8(value) ? [value] : []);
|
|
17696
18623
|
if (entries.length !== data.entries.length || messages.length !== data.messages.length) {
|
|
17697
18624
|
throw new OmpRpcFaultError("protocolError", "Omp RPC Subagent transcript contains invalid data");
|
|
17698
18625
|
}
|
|
@@ -17713,17 +18640,17 @@ function subagentStatus(value) {
|
|
|
17713
18640
|
throw new OmpRpcFaultError("protocolError", "Omp RPC Subagent status is invalid");
|
|
17714
18641
|
}
|
|
17715
18642
|
function assistantText(value) {
|
|
17716
|
-
if (!
|
|
18643
|
+
if (!isRecord8(value) || value.role !== "assistant" || !Array.isArray(value.content))
|
|
17717
18644
|
return null;
|
|
17718
|
-
return value.content.filter((content) =>
|
|
18645
|
+
return value.content.filter((content) => isRecord8(content) && content.type === "text" && typeof content.text === "string").map((content) => content.text).join("");
|
|
17719
18646
|
}
|
|
17720
18647
|
function assistantMessageId(value) {
|
|
17721
|
-
if (!
|
|
18648
|
+
if (!isRecord8(value) || value.role !== "assistant")
|
|
17722
18649
|
return null;
|
|
17723
18650
|
return nonBlankString(value.responseId) ? value.responseId : null;
|
|
17724
18651
|
}
|
|
17725
18652
|
function extractReasoningText(content) {
|
|
17726
|
-
if (!
|
|
18653
|
+
if (!isRecord8(content))
|
|
17727
18654
|
return null;
|
|
17728
18655
|
const type = String(content.type ?? "");
|
|
17729
18656
|
if (type === "thinking" || type === "reasoning" || type === "thought") {
|
|
@@ -17733,12 +18660,12 @@ function extractReasoningText(content) {
|
|
|
17733
18660
|
return null;
|
|
17734
18661
|
}
|
|
17735
18662
|
function assistantReasoning(value) {
|
|
17736
|
-
if (!
|
|
18663
|
+
if (!isRecord8(value) || value.role !== "assistant" || !Array.isArray(value.content))
|
|
17737
18664
|
return null;
|
|
17738
18665
|
return value.content.map(extractReasoningText).filter((text) => typeof text === "string").join("");
|
|
17739
18666
|
}
|
|
17740
18667
|
function assistantFailure(value) {
|
|
17741
|
-
if (!
|
|
18668
|
+
if (!isRecord8(value) || value.role !== "assistant")
|
|
17742
18669
|
return void 0;
|
|
17743
18670
|
if (value.stopReason !== "error" && value.stopReason !== "aborted")
|
|
17744
18671
|
return null;
|
|
@@ -17758,7 +18685,7 @@ function signalProcessTree(child, signal) {
|
|
|
17758
18685
|
try {
|
|
17759
18686
|
process.kill(-child.pid, signal);
|
|
17760
18687
|
} catch (error51) {
|
|
17761
|
-
if (!
|
|
18688
|
+
if (!isRecord8(error51) || error51.code !== "ESRCH")
|
|
17762
18689
|
throw error51;
|
|
17763
18690
|
}
|
|
17764
18691
|
}
|
|
@@ -17797,7 +18724,7 @@ function ompRpcProcessCommand(options, dependencies = {}) {
|
|
|
17797
18724
|
...modelArguments,
|
|
17798
18725
|
...sessionArguments
|
|
17799
18726
|
];
|
|
17800
|
-
const extension =
|
|
18727
|
+
const extension = path6.win32.extname(command).toLowerCase();
|
|
17801
18728
|
if (platform !== "win32" || ![".cmd", ".bat"].includes(extension)) {
|
|
17802
18729
|
return { command, arguments: arguments_, windowsVerbatimArguments: false };
|
|
17803
18730
|
}
|
|
@@ -17829,6 +18756,7 @@ var OmpRpcSession = class {
|
|
|
17829
18756
|
#buffer = Buffer.alloc(0);
|
|
17830
18757
|
#child = null;
|
|
17831
18758
|
#closed = false;
|
|
18759
|
+
#closePromise = null;
|
|
17832
18760
|
#compactionActive = false;
|
|
17833
18761
|
#compactionTurn = null;
|
|
17834
18762
|
#compactionTimeout = null;
|
|
@@ -17838,6 +18766,7 @@ var OmpRpcSession = class {
|
|
|
17838
18766
|
#availableCommands = null;
|
|
17839
18767
|
#latestCacheHitRatePercent;
|
|
17840
18768
|
#manualCompaction = null;
|
|
18769
|
+
#usageRequestStartedAtMs = null;
|
|
17841
18770
|
#stderrTail = "";
|
|
17842
18771
|
#frameDecoder = new OmpFrameDecoder();
|
|
17843
18772
|
#startupFaultResolve = null;
|
|
@@ -17858,7 +18787,9 @@ var OmpRpcSession = class {
|
|
|
17858
18787
|
this.#options = {
|
|
17859
18788
|
commandTimeoutMs: 3e4,
|
|
17860
18789
|
compactionTimeoutMs: 3e5,
|
|
17861
|
-
|
|
18790
|
+
// Native Abort waits for tools, persistence and deferred work to unwind.
|
|
18791
|
+
// Stable cancellation must outlast the Host's 20s steering wait.
|
|
18792
|
+
cancelTimeoutMs: 3e4,
|
|
17862
18793
|
closeTimeoutMs: 2e3,
|
|
17863
18794
|
...options
|
|
17864
18795
|
};
|
|
@@ -17900,7 +18831,7 @@ var OmpRpcSession = class {
|
|
|
17900
18831
|
this.#stderrTail = sanitizeDiagnosticTail(`${this.#stderrTail}${chunk.toString()}`);
|
|
17901
18832
|
});
|
|
17902
18833
|
child.once("error", (error51) => {
|
|
17903
|
-
const kind =
|
|
18834
|
+
const kind = isRecord8(error51) && error51.code === "ENOENT" ? "notInstalled" : "unavailable";
|
|
17904
18835
|
this.#fail(new OmpRpcFaultError(kind, `Omp RPC failed to start: ${error51.message}`, this.stderrTail));
|
|
17905
18836
|
});
|
|
17906
18837
|
child.once("exit", (code, signal) => {
|
|
@@ -17945,20 +18876,31 @@ var OmpRpcSession = class {
|
|
|
17945
18876
|
async getEntries() {
|
|
17946
18877
|
try {
|
|
17947
18878
|
if (this.state.sessionFile) {
|
|
17948
|
-
|
|
18879
|
+
try {
|
|
18880
|
+
return await readOmpSessionHistory(this.state.sessionFile);
|
|
18881
|
+
} catch (error51) {
|
|
18882
|
+
if (!isRecord8(error51) || error51.code !== "ENOENT" || this.#options.sessionFile || this.#options.forkSessionFile)
|
|
18883
|
+
throw error51;
|
|
18884
|
+
const response2 = await this.#send("get_messages", {});
|
|
18885
|
+
const data2 = isRecord8(response2.data) ? response2.data : null;
|
|
18886
|
+
if (data2 && Array.isArray(data2.messages) && data2.messages.length === 0) {
|
|
18887
|
+
return { entries: [], leafId: null };
|
|
18888
|
+
}
|
|
18889
|
+
throw error51;
|
|
18890
|
+
}
|
|
17949
18891
|
}
|
|
17950
18892
|
const response = await this.#send("get_messages", {});
|
|
17951
|
-
const data =
|
|
18893
|
+
const data = isRecord8(response.data) ? response.data : null;
|
|
17952
18894
|
if (!data || !Array.isArray(data.messages)) {
|
|
17953
18895
|
throw new OmpRpcFaultError("protocolError", "Omp RPC messages response has no messages");
|
|
17954
18896
|
}
|
|
17955
18897
|
let branchEntryIds = null;
|
|
17956
18898
|
try {
|
|
17957
18899
|
const branchResponse = await this.#send("get_branch_messages", {});
|
|
17958
|
-
const branchData =
|
|
18900
|
+
const branchData = isRecord8(branchResponse.data) ? branchResponse.data : null;
|
|
17959
18901
|
if (branchData && Array.isArray(branchData.messages)) {
|
|
17960
18902
|
const parsed = branchData.messages.flatMap((entry) => {
|
|
17961
|
-
if (!
|
|
18903
|
+
if (!isRecord8(entry) || !nonBlankString(entry.entryId))
|
|
17962
18904
|
return [];
|
|
17963
18905
|
return [entry.entryId];
|
|
17964
18906
|
});
|
|
@@ -17972,11 +18914,11 @@ var OmpRpcSession = class {
|
|
|
17972
18914
|
let userIndex = 0;
|
|
17973
18915
|
let parentId = null;
|
|
17974
18916
|
const entries = data.messages.map((nativeMessage, index) => {
|
|
17975
|
-
const role =
|
|
18917
|
+
const role = isRecord8(nativeMessage) ? nativeMessage.role : void 0;
|
|
17976
18918
|
const branchId = role === "user" ? branchEntryIds?.[userIndex] : void 0;
|
|
17977
18919
|
if (branchId)
|
|
17978
18920
|
userIndex += 1;
|
|
17979
|
-
const id = branchId ?? (
|
|
18921
|
+
const id = branchId ?? (isRecord8(nativeMessage) && nonBlankString(nativeMessage.id) ? nativeMessage.id : `omp-message-${index}`);
|
|
17980
18922
|
const entry = { id, parentId, type: "message", message: nativeMessage };
|
|
17981
18923
|
parentId = id;
|
|
17982
18924
|
return entry;
|
|
@@ -18056,7 +18998,7 @@ var OmpRpcSession = class {
|
|
|
18056
18998
|
throw new Error("Omp RPC Fork requires an Entry identity");
|
|
18057
18999
|
try {
|
|
18058
19000
|
const response = await this.#send("branch", { entryId });
|
|
18059
|
-
const data =
|
|
19001
|
+
const data = isRecord8(response.data) ? response.data : null;
|
|
18060
19002
|
if (!data || data.cancelled === true) {
|
|
18061
19003
|
throw new OmpRpcFaultError("unavailable", "Omp RPC Fork was cancelled");
|
|
18062
19004
|
}
|
|
@@ -18087,8 +19029,8 @@ var OmpRpcSession = class {
|
|
|
18087
19029
|
async getAvailableThinkingLevels() {
|
|
18088
19030
|
return this.state.availableThinkingLevels;
|
|
18089
19031
|
}
|
|
18090
|
-
async selectModel(
|
|
18091
|
-
await this.#send("set_model", { provider:
|
|
19032
|
+
async selectModel(model2) {
|
|
19033
|
+
await this.#send("set_model", { provider: model2.provider, modelId: model2.id });
|
|
18092
19034
|
return this.#refreshState("Model");
|
|
18093
19035
|
}
|
|
18094
19036
|
async selectThinkingOption(thinkingOptionId) {
|
|
@@ -18114,8 +19056,11 @@ var OmpRpcSession = class {
|
|
|
18114
19056
|
throw new Error("Omp RPC Session already has an active Turn");
|
|
18115
19057
|
if (text.length === 0)
|
|
18116
19058
|
throw new Error("Omp text Turn must not be empty");
|
|
19059
|
+
const promptId = `codexhost-${randomUUID()}`;
|
|
18117
19060
|
const settled = new Promise((resolve, reject) => {
|
|
18118
19061
|
this.#activeTurn = {
|
|
19062
|
+
promptId,
|
|
19063
|
+
localResult: null,
|
|
18119
19064
|
text: "",
|
|
18120
19065
|
assistantMessageId: null,
|
|
18121
19066
|
sawStreamedMessageText: false,
|
|
@@ -18131,13 +19076,17 @@ var OmpRpcSession = class {
|
|
|
18131
19076
|
tools: /* @__PURE__ */ new Map(),
|
|
18132
19077
|
interactions: /* @__PURE__ */ new Map(),
|
|
18133
19078
|
settlement: "pending",
|
|
19079
|
+
terminalEnd: false,
|
|
18134
19080
|
cancellation: "none",
|
|
18135
19081
|
cancellationTimeout: null,
|
|
19082
|
+
cancellationRecheck: null,
|
|
19083
|
+
cancellationChecking: false,
|
|
19084
|
+
cancellationReloaded: false,
|
|
18136
19085
|
abortPromise: null
|
|
18137
19086
|
};
|
|
18138
19087
|
});
|
|
18139
19088
|
try {
|
|
18140
|
-
await this.#send("prompt", { message: text });
|
|
19089
|
+
await this.#send("prompt", { message: text }, promptId);
|
|
18141
19090
|
} catch (error51) {
|
|
18142
19091
|
this.#rejectActiveTurn(error51 instanceof Error ? error51 : new Error(message2(error51)));
|
|
18143
19092
|
}
|
|
@@ -18189,11 +19138,11 @@ var OmpRpcSession = class {
|
|
|
18189
19138
|
active.cancellationTimeout = setTimeout(() => {
|
|
18190
19139
|
this.#terminateFailedCancellation(active, new OmpRpcFaultError("protocolError", "Omp Turn cancellation did not settle within its bound"));
|
|
18191
19140
|
}, this.#options.cancelTimeoutMs);
|
|
18192
|
-
const aborting = this.#send("abort", {}).then(() => {
|
|
19141
|
+
const aborting = this.#send("abort", {}).then(async () => {
|
|
18193
19142
|
if (this.#activeTurn !== active)
|
|
18194
19143
|
return;
|
|
18195
19144
|
active.cancellation = "accepted";
|
|
18196
|
-
this.#
|
|
19145
|
+
await this.#confirmCancelledTurn(active);
|
|
18197
19146
|
}).catch((error51) => {
|
|
18198
19147
|
if (this.#activeTurn !== active)
|
|
18199
19148
|
throw error51;
|
|
@@ -18213,12 +19162,13 @@ var OmpRpcSession = class {
|
|
|
18213
19162
|
this.#fail(fault);
|
|
18214
19163
|
void this.close().catch(() => void 0);
|
|
18215
19164
|
}
|
|
18216
|
-
|
|
18217
|
-
if (this.#closed)
|
|
18218
|
-
|
|
18219
|
-
|
|
18220
|
-
|
|
18221
|
-
|
|
19165
|
+
close() {
|
|
19166
|
+
if (!this.#closed) {
|
|
19167
|
+
this.#closed = true;
|
|
19168
|
+
this.#rejectAll(new Error("Omp RPC Session closed"));
|
|
19169
|
+
}
|
|
19170
|
+
this.#closePromise ??= this.#stopProcess();
|
|
19171
|
+
return this.#closePromise;
|
|
18222
19172
|
}
|
|
18223
19173
|
async #stopProcess() {
|
|
18224
19174
|
const child = this.#child;
|
|
@@ -18242,19 +19192,27 @@ var OmpRpcSession = class {
|
|
|
18242
19192
|
while (newline >= 0) {
|
|
18243
19193
|
const frame = this.#buffer.subarray(0, newline);
|
|
18244
19194
|
this.#buffer = this.#buffer.subarray(newline + 1);
|
|
19195
|
+
let parsed;
|
|
19196
|
+
try {
|
|
19197
|
+
parsed = JSON.parse(textDecoder.decode(frame));
|
|
19198
|
+
} catch (error51) {
|
|
19199
|
+
this.#fail(new OmpRpcFaultError("protocolError", `Omp RPC returned invalid JSONL: ${message2(error51)}`));
|
|
19200
|
+
newline = this.#buffer.indexOf(10);
|
|
19201
|
+
continue;
|
|
19202
|
+
}
|
|
18245
19203
|
try {
|
|
18246
|
-
const decoded = this.#frameDecoder.push(
|
|
19204
|
+
const decoded = this.#frameDecoder.push(parsed);
|
|
18247
19205
|
if (decoded === null) {
|
|
18248
19206
|
newline = this.#buffer.indexOf(10);
|
|
18249
19207
|
continue;
|
|
18250
19208
|
}
|
|
18251
19209
|
const value = decoded;
|
|
18252
|
-
if (!
|
|
19210
|
+
if (!isRecord8(value) || typeof value.type !== "string") {
|
|
18253
19211
|
throw new OmpRpcFaultError("protocolError", "Omp RPC returned an invalid envelope");
|
|
18254
19212
|
}
|
|
18255
19213
|
this.#handle(value);
|
|
18256
19214
|
} catch (error51) {
|
|
18257
|
-
this.#fail(error51 instanceof OmpRpcFaultError ? error51 : new OmpRpcFaultError("protocolError", `Omp RPC
|
|
19215
|
+
this.#fail(error51 instanceof OmpRpcFaultError ? error51 : new OmpRpcFaultError("protocolError", `Omp RPC frame handling failed: ${message2(error51)}`));
|
|
18258
19216
|
}
|
|
18259
19217
|
newline = this.#buffer.indexOf(10);
|
|
18260
19218
|
}
|
|
@@ -18308,7 +19266,7 @@ var OmpRpcSession = class {
|
|
|
18308
19266
|
this.#armCommandTimeout(id, pending);
|
|
18309
19267
|
}
|
|
18310
19268
|
}
|
|
18311
|
-
const outcome = value.aborted === true ? "cancelled" :
|
|
19269
|
+
const outcome = value.aborted === true ? "cancelled" : isRecord8(value.result) ? "succeeded" : "failed";
|
|
18312
19270
|
const event = {
|
|
18313
19271
|
type: "compaction.completed",
|
|
18314
19272
|
outcome,
|
|
@@ -18327,12 +19285,41 @@ var OmpRpcSession = class {
|
|
|
18327
19285
|
const active = this.#activeTurn;
|
|
18328
19286
|
if (this.#handleSubagentFrame(active, value))
|
|
18329
19287
|
return;
|
|
19288
|
+
this.#observeUsage(value);
|
|
19289
|
+
if (value.type === "agent_start" && active)
|
|
19290
|
+
active.terminalEnd = false;
|
|
19291
|
+
if ((value.type === "session_settled" || value.type === "agent_start") && active?.cancellation === "accepted") {
|
|
19292
|
+
void this.#confirmCancelledTurn(active);
|
|
19293
|
+
return;
|
|
19294
|
+
}
|
|
18330
19295
|
if (!active) {
|
|
18331
19296
|
if (value.type === "extension_ui_request" && this.#isBlockingInteraction(value)) {
|
|
18332
19297
|
this.#fail(new OmpRpcFaultError("protocolError", "Omp RPC requested blocking Extension UI outside an active Turn"));
|
|
18333
19298
|
}
|
|
18334
19299
|
return;
|
|
18335
19300
|
}
|
|
19301
|
+
if (value.type === "command_output") {
|
|
19302
|
+
if (active.settlement !== "pending")
|
|
19303
|
+
return;
|
|
19304
|
+
if (typeof value.text !== "string") {
|
|
19305
|
+
throw new OmpRpcFaultError("protocolError", "Omp RPC returned invalid command output");
|
|
19306
|
+
}
|
|
19307
|
+
active.text += value.text;
|
|
19308
|
+
active.onEvent({ type: "text.delta", messageId: active.promptId, delta: value.text });
|
|
19309
|
+
return;
|
|
19310
|
+
}
|
|
19311
|
+
if (value.type === "prompt_result") {
|
|
19312
|
+
if (value.id !== active.promptId || value.agentInvoked !== false)
|
|
19313
|
+
return;
|
|
19314
|
+
if (value.status === "completed" || value.status === "aborted") {
|
|
19315
|
+
this.#settleLocalTurn(active, { cancelled: value.status === "aborted" });
|
|
19316
|
+
} else if (value.status === "error" && isRecord8(value.error) && typeof value.error.message === "string") {
|
|
19317
|
+
this.#settleLocalTurn(active, { cancelled: false, error: value.error.message });
|
|
19318
|
+
} else {
|
|
19319
|
+
throw new OmpRpcFaultError("protocolError", "Omp RPC returned an invalid local prompt result");
|
|
19320
|
+
}
|
|
19321
|
+
return;
|
|
19322
|
+
}
|
|
18336
19323
|
if (value.type === "extension_ui_request") {
|
|
18337
19324
|
this.#startInteraction(active, value);
|
|
18338
19325
|
return;
|
|
@@ -18341,12 +19328,12 @@ var OmpRpcSession = class {
|
|
|
18341
19328
|
this.#startAssistantMessage(active, value.message);
|
|
18342
19329
|
return;
|
|
18343
19330
|
}
|
|
18344
|
-
if (value.type === "message_update" &&
|
|
19331
|
+
if (value.type === "message_update" && isRecord8(value.assistantMessageEvent)) {
|
|
18345
19332
|
const event = value.assistantMessageEvent;
|
|
18346
19333
|
const eventType = String(event.type ?? "");
|
|
18347
19334
|
const isThinking = eventType === "thinking_delta" || eventType === "reasoning_delta" || eventType === "thought_delta" || eventType === "thinking" || eventType === "reasoning";
|
|
18348
19335
|
const isText = eventType === "text_delta" || eventType === "text" || eventType === "content_block_delta";
|
|
18349
|
-
const delta = typeof event.delta === "string" ? event.delta : typeof event.thinking === "string" ? event.thinking : typeof event.reasoning === "string" ? event.reasoning : typeof event.text === "string" ? event.text :
|
|
19336
|
+
const delta = typeof event.delta === "string" ? event.delta : typeof event.thinking === "string" ? event.thinking : typeof event.reasoning === "string" ? event.reasoning : typeof event.text === "string" ? event.text : isRecord8(event.delta) && typeof event.delta.thinking === "string" ? event.delta.thinking : isRecord8(event.delta) && typeof event.delta.text === "string" ? event.delta.text : null;
|
|
18350
19337
|
if (isThinking && delta !== null && delta.length > 0) {
|
|
18351
19338
|
const messageId = this.#ensureAssistantMessage(active, value.message);
|
|
18352
19339
|
active.reasoningMessageOpen = true;
|
|
@@ -18386,31 +19373,62 @@ var OmpRpcSession = class {
|
|
|
18386
19373
|
if (value.type === "agent_end" && Array.isArray(value.messages)) {
|
|
18387
19374
|
for (let index = value.messages.length - 1; index >= 0; index -= 1) {
|
|
18388
19375
|
const message3 = value.messages[index];
|
|
18389
|
-
if (!
|
|
19376
|
+
if (!isRecord8(message3) || message3.role !== "assistant")
|
|
18390
19377
|
continue;
|
|
18391
19378
|
this.#finalizeAssistantMessage(active, message3);
|
|
18392
19379
|
break;
|
|
18393
19380
|
}
|
|
18394
19381
|
}
|
|
18395
19382
|
if (value.type === "agent_end" && value.isTerminal !== false) {
|
|
19383
|
+
active.terminalEnd = true;
|
|
19384
|
+
if (active.cancellation !== "none") {
|
|
19385
|
+
if (active.cancellation === "accepted")
|
|
19386
|
+
void this.#confirmCancelledTurn(active);
|
|
19387
|
+
return;
|
|
19388
|
+
}
|
|
18396
19389
|
if (active.settlement !== "pending")
|
|
18397
19390
|
return;
|
|
18398
19391
|
active.settlement = "confirming";
|
|
18399
19392
|
void this.#confirmSettledTurn(active);
|
|
18400
19393
|
}
|
|
18401
19394
|
}
|
|
19395
|
+
/** Every finished assistant message is one model request, with or without an active Turn. */
|
|
19396
|
+
#observeUsage(value) {
|
|
19397
|
+
if (value.type === "message_start") {
|
|
19398
|
+
this.#usageRequestStartedAtMs = null;
|
|
19399
|
+
return;
|
|
19400
|
+
}
|
|
19401
|
+
if (value.type === "message_update") {
|
|
19402
|
+
const event = value.assistantMessageEvent;
|
|
19403
|
+
if (this.#usageRequestStartedAtMs === null && isRecord8(event) && typeof event.type === "string" && /^(text|thinking|reasoning|thought|toolcall)_(start|delta)$/u.test(event.type)) {
|
|
19404
|
+
this.#usageRequestStartedAtMs = Date.now();
|
|
19405
|
+
}
|
|
19406
|
+
return;
|
|
19407
|
+
}
|
|
19408
|
+
if (value.type === "message_end" && isRecord8(value.message)) {
|
|
19409
|
+
if (value.message.role !== "assistant")
|
|
19410
|
+
return;
|
|
19411
|
+
const startedAtMs = this.#usageRequestStartedAtMs;
|
|
19412
|
+
this.#usageRequestStartedAtMs = null;
|
|
19413
|
+
this.#options.onUsage?.({
|
|
19414
|
+
message: value.message,
|
|
19415
|
+
startedAtMs,
|
|
19416
|
+
completedAtMs: Date.now()
|
|
19417
|
+
});
|
|
19418
|
+
}
|
|
19419
|
+
}
|
|
18402
19420
|
#handleSubagentFrame(active, value) {
|
|
18403
19421
|
if (value.type !== "subagent_lifecycle" && value.type !== "subagent_progress" && value.type !== "subagent_event") {
|
|
18404
19422
|
return false;
|
|
18405
19423
|
}
|
|
18406
|
-
const payload =
|
|
18407
|
-
const progressPayload = value.type === "subagent_progress" && payload &&
|
|
19424
|
+
const payload = isRecord8(value.payload) ? value.payload : null;
|
|
19425
|
+
const progressPayload = value.type === "subagent_progress" && payload && isRecord8(payload.progress) ? payload.progress : null;
|
|
18408
19426
|
const nativeIdValue = progressPayload?.id ?? payload?.id;
|
|
18409
19427
|
if (!payload || !nonBlankString(nativeIdValue)) {
|
|
18410
19428
|
throw new OmpRpcFaultError("protocolError", "Omp RPC Subagent frame has no stable ID");
|
|
18411
19429
|
}
|
|
18412
19430
|
const nativeSubagentId = nativeIdValue;
|
|
18413
|
-
const callId =
|
|
19431
|
+
const callId = nativeSubagentId;
|
|
18414
19432
|
const emit = active?.onEvent ?? this.#options.onSubagentEvent;
|
|
18415
19433
|
if (value.type === "subagent_event") {
|
|
18416
19434
|
emit?.({ type: "subagent.transcript.changed", callId, nativeSubagentId });
|
|
@@ -18552,16 +19570,24 @@ var OmpRpcSession = class {
|
|
|
18552
19570
|
return;
|
|
18553
19571
|
}
|
|
18554
19572
|
const pending = this.#pending.get(id);
|
|
19573
|
+
const active = this.#activeTurn;
|
|
18555
19574
|
if (!pending) {
|
|
19575
|
+
if (active?.promptId === id && value.command === "prompt" && value.success === false) {
|
|
19576
|
+
active.failure = new Error(typeof value.error === "string" ? value.error : "Omp RPC command failed");
|
|
19577
|
+
return;
|
|
19578
|
+
}
|
|
18556
19579
|
this.#fail(new OmpRpcFaultError("protocolError", "Omp RPC response id is not pending"));
|
|
18557
19580
|
return;
|
|
18558
19581
|
}
|
|
18559
19582
|
if (pending.timeout)
|
|
18560
19583
|
clearTimeout(pending.timeout);
|
|
18561
19584
|
this.#pending.delete(id);
|
|
18562
|
-
if (value.success === true)
|
|
19585
|
+
if (value.success === true) {
|
|
19586
|
+
if (pending.command === "prompt" && active?.promptId === id && isRecord8(value.data) && value.data.agentInvoked === false) {
|
|
19587
|
+
this.#settleLocalTurn(active, { cancelled: false });
|
|
19588
|
+
}
|
|
18563
19589
|
pending.resolve(value);
|
|
18564
|
-
else {
|
|
19590
|
+
} else {
|
|
18565
19591
|
const error51 = typeof value.error === "string" ? value.error : "Omp RPC command failed";
|
|
18566
19592
|
if (value.command === pending.command && error51 === `Unknown command: ${pending.command}`) {
|
|
18567
19593
|
pending.reject(new OmpRpcUnsupportedCommandError(pending.command));
|
|
@@ -18621,15 +19647,107 @@ var OmpRpcSession = class {
|
|
|
18621
19647
|
isError: value.isError === true
|
|
18622
19648
|
});
|
|
18623
19649
|
}
|
|
19650
|
+
async #confirmCancelledTurn(active) {
|
|
19651
|
+
if (this.#activeTurn !== active || active.cancellation !== "accepted" || active.settlement === "confirming" || active.cancellationChecking)
|
|
19652
|
+
return;
|
|
19653
|
+
active.cancellationChecking = true;
|
|
19654
|
+
if (active.cancellationRecheck)
|
|
19655
|
+
clearTimeout(active.cancellationRecheck);
|
|
19656
|
+
active.cancellationRecheck = null;
|
|
19657
|
+
try {
|
|
19658
|
+
let response = await this.#send("get_state", {});
|
|
19659
|
+
if (this.#activeTurn !== active)
|
|
19660
|
+
return;
|
|
19661
|
+
if (parseSessionStreaming(response)) {
|
|
19662
|
+
await this.#send("abort", {});
|
|
19663
|
+
if (this.#activeTurn !== active)
|
|
19664
|
+
return;
|
|
19665
|
+
response = await this.#send("get_state", {});
|
|
19666
|
+
}
|
|
19667
|
+
let state = parseSessionState(response);
|
|
19668
|
+
if (this.#activeTurn !== active || active.cancellation !== "accepted")
|
|
19669
|
+
return;
|
|
19670
|
+
const data = sessionStateData(response);
|
|
19671
|
+
if (!active.cancellationReloaded && state.sessionFile && state.sessionId === this.state.sessionId && state.sessionFile === this.state.sessionFile && data.isStreaming === false && data.isCompacting === false && data.queuedMessageCount === 0 && data.hasPendingAsyncWork === true && active.tools.size === 0) {
|
|
19672
|
+
await this.verifySessionCwd(this.#options.cwd);
|
|
19673
|
+
if (this.#activeTurn !== active)
|
|
19674
|
+
return;
|
|
19675
|
+
active.cancellationReloaded = true;
|
|
19676
|
+
const reset = await this.#send("new_session", {});
|
|
19677
|
+
if (this.#activeTurn !== active)
|
|
19678
|
+
return;
|
|
19679
|
+
if (!isRecord8(reset.data) || reset.data.cancelled !== false) {
|
|
19680
|
+
throw new OmpRpcFaultError("unavailable", "Omp cancelled Session reset was refused");
|
|
19681
|
+
}
|
|
19682
|
+
const reloaded = await this.#send("switch_session", { sessionPath: state.sessionFile });
|
|
19683
|
+
if (this.#activeTurn !== active)
|
|
19684
|
+
return;
|
|
19685
|
+
if (!isRecord8(reloaded.data) || reloaded.data.cancelled !== false) {
|
|
19686
|
+
throw new OmpRpcFaultError("unavailable", "Omp cancelled Session reload was refused");
|
|
19687
|
+
}
|
|
19688
|
+
const previous = state;
|
|
19689
|
+
response = await this.#send("get_state", {});
|
|
19690
|
+
state = parseSessionState(response);
|
|
19691
|
+
if (state.sessionId !== previous.sessionId || state.sessionFile !== previous.sessionFile) {
|
|
19692
|
+
throw new OmpRpcFaultError("protocolError", "Omp cancelled Session reload changed its identity");
|
|
19693
|
+
}
|
|
19694
|
+
if (state.provider !== previous.provider || state.modelId !== previous.modelId) {
|
|
19695
|
+
if (!previous.provider || !previous.modelId) {
|
|
19696
|
+
throw new OmpRpcFaultError("protocolError", "Omp cancelled Session has no restorable Model");
|
|
19697
|
+
}
|
|
19698
|
+
await this.#send("set_model", { provider: previous.provider, modelId: previous.modelId });
|
|
19699
|
+
}
|
|
19700
|
+
if (previous.thinkingLevel && state.thinkingLevel !== previous.thinkingLevel) {
|
|
19701
|
+
await this.#send("set_thinking_level", { level: previous.thinkingLevel });
|
|
19702
|
+
}
|
|
19703
|
+
response = await this.#send("get_state", {});
|
|
19704
|
+
state = parseSessionState(response);
|
|
19705
|
+
if (state.sessionId !== previous.sessionId || state.sessionFile !== previous.sessionFile || state.provider !== previous.provider || state.modelId !== previous.modelId || previous.thinkingLevel !== null && state.thinkingLevel !== previous.thinkingLevel) {
|
|
19706
|
+
throw new OmpRpcFaultError("protocolError", "Omp cancelled Session reload changed its identity or configuration");
|
|
19707
|
+
}
|
|
19708
|
+
}
|
|
19709
|
+
if (!cancellationSettled(response, active.terminalEnd)) {
|
|
19710
|
+
active.settlement = "pending";
|
|
19711
|
+
active.cancellationRecheck = setTimeout(() => {
|
|
19712
|
+
active.cancellationRecheck = null;
|
|
19713
|
+
void this.#confirmCancelledTurn(active);
|
|
19714
|
+
}, 250);
|
|
19715
|
+
return;
|
|
19716
|
+
}
|
|
19717
|
+
this.#state = state;
|
|
19718
|
+
active.settlement = "confirmed";
|
|
19719
|
+
this.#finishSettledTurn(active);
|
|
19720
|
+
} catch (error51) {
|
|
19721
|
+
if (this.#activeTurn !== active)
|
|
19722
|
+
return;
|
|
19723
|
+
const fault = error51 instanceof OmpRpcFaultError ? error51 : new OmpRpcFaultError("protocolError", `Omp RPC cancelled Turn state could not be confirmed: ${message2(error51)}`);
|
|
19724
|
+
this.#terminateFailedCancellation(active, fault);
|
|
19725
|
+
} finally {
|
|
19726
|
+
active.cancellationChecking = false;
|
|
19727
|
+
}
|
|
19728
|
+
}
|
|
19729
|
+
#settleLocalTurn(active, result) {
|
|
19730
|
+
if (this.#activeTurn !== active || active.settlement !== "pending")
|
|
19731
|
+
return;
|
|
19732
|
+
active.localResult = result;
|
|
19733
|
+
active.settlement = "confirming";
|
|
19734
|
+
void this.#confirmSettledTurn(active);
|
|
19735
|
+
}
|
|
18624
19736
|
async #confirmSettledTurn(active) {
|
|
18625
19737
|
try {
|
|
18626
19738
|
const response = await this.#send("get_state", {});
|
|
18627
19739
|
const state = parseSessionState(response);
|
|
18628
|
-
if (parseSessionStreaming(response)) {
|
|
18629
|
-
throw new OmpRpcFaultError("protocolError", "Omp RPC agent_end state is still Streaming");
|
|
18630
|
-
}
|
|
18631
19740
|
if (this.#activeTurn !== active)
|
|
18632
19741
|
return;
|
|
19742
|
+
if (active.cancellation !== "none") {
|
|
19743
|
+
active.settlement = "pending";
|
|
19744
|
+
if (active.cancellation === "accepted")
|
|
19745
|
+
void this.#confirmCancelledTurn(active);
|
|
19746
|
+
return;
|
|
19747
|
+
}
|
|
19748
|
+
if (parseSessionStreaming(response)) {
|
|
19749
|
+
throw new OmpRpcFaultError("protocolError", "Omp RPC completed Turn state is still Streaming");
|
|
19750
|
+
}
|
|
18633
19751
|
this.#state = state;
|
|
18634
19752
|
active.settlement = "confirmed";
|
|
18635
19753
|
this.#finishSettledTurn(active);
|
|
@@ -18647,20 +19765,30 @@ var OmpRpcSession = class {
|
|
|
18647
19765
|
if (active.cancellationTimeout)
|
|
18648
19766
|
clearTimeout(active.cancellationTimeout);
|
|
18649
19767
|
active.cancellationTimeout = null;
|
|
19768
|
+
if (active.cancellationRecheck)
|
|
19769
|
+
clearTimeout(active.cancellationRecheck);
|
|
19770
|
+
active.cancellationRecheck = null;
|
|
18650
19771
|
this.#closeInteractions(active, active.cancellation === "accepted" ? "cancelled" : "superseded");
|
|
18651
19772
|
if (active.tools.size > 0) {
|
|
18652
19773
|
this.#fail(new OmpRpcFaultError("protocolError", "Omp RPC settled with active Tool executions"));
|
|
18653
19774
|
return;
|
|
18654
19775
|
}
|
|
18655
19776
|
this.#activeTurn = null;
|
|
18656
|
-
if (active.
|
|
18657
|
-
active.resolve({
|
|
19777
|
+
if (active.localResult) {
|
|
19778
|
+
active.resolve({
|
|
19779
|
+
text: active.text,
|
|
19780
|
+
agentInvoked: false,
|
|
19781
|
+
...active.localResult,
|
|
19782
|
+
cancelled: active.localResult.cancelled || active.cancellation === "accepted"
|
|
19783
|
+
});
|
|
19784
|
+
} else if (active.cancellation === "accepted") {
|
|
19785
|
+
active.resolve({ text: active.text, cancelled: true, agentInvoked: true });
|
|
18658
19786
|
} else if (active.failure) {
|
|
18659
19787
|
active.reject(active.failure);
|
|
18660
19788
|
} else if (active.text.trim().length === 0 && !active.sawTool) {
|
|
18661
19789
|
active.reject(new Error("Omp RPC settled without displayable output"));
|
|
18662
19790
|
} else {
|
|
18663
|
-
active.resolve({ text: active.text, cancelled: false });
|
|
19791
|
+
active.resolve({ text: active.text, cancelled: false, agentInvoked: true });
|
|
18664
19792
|
}
|
|
18665
19793
|
}
|
|
18666
19794
|
#startAssistantMessage(active, value) {
|
|
@@ -18720,12 +19848,11 @@ var OmpRpcSession = class {
|
|
|
18720
19848
|
child.stdin.write(frame, (error51) => error51 ? reject(error51) : resolve());
|
|
18721
19849
|
});
|
|
18722
19850
|
}
|
|
18723
|
-
#send(type, payload) {
|
|
19851
|
+
#send(type, payload, id = `codexhost-${randomUUID()}`) {
|
|
18724
19852
|
const child = this.#child;
|
|
18725
19853
|
if (!child?.stdin.writable || this.#closed || this.#failed) {
|
|
18726
19854
|
return Promise.reject(new Error("Omp RPC stdin is unavailable"));
|
|
18727
19855
|
}
|
|
18728
|
-
const id = `codexhost-${randomUUID()}`;
|
|
18729
19856
|
return new Promise((resolve, reject) => {
|
|
18730
19857
|
const pending = {
|
|
18731
19858
|
command: type,
|
|
@@ -18777,7 +19904,7 @@ var OmpRpcSession = class {
|
|
|
18777
19904
|
}
|
|
18778
19905
|
let finalFault = fault;
|
|
18779
19906
|
try {
|
|
18780
|
-
await this
|
|
19907
|
+
await this.close();
|
|
18781
19908
|
} catch (error51) {
|
|
18782
19909
|
finalFault = new OmpRpcFaultError("processExited", `Omp RPC timed-out Prompt cleanup failed: ${message2(error51)}`);
|
|
18783
19910
|
}
|
|
@@ -18798,6 +19925,8 @@ var OmpRpcSession = class {
|
|
|
18798
19925
|
return;
|
|
18799
19926
|
if (active.cancellationTimeout)
|
|
18800
19927
|
clearTimeout(active.cancellationTimeout);
|
|
19928
|
+
if (active.cancellationRecheck)
|
|
19929
|
+
clearTimeout(active.cancellationRecheck);
|
|
18801
19930
|
this.#closeInteractions(active, "cancelled");
|
|
18802
19931
|
this.#activeTurn = null;
|
|
18803
19932
|
active.reject(error51);
|
|
@@ -18983,7 +20112,7 @@ var ompCommandCatalog = harnessCommandCatalogSchema.parse({
|
|
|
18983
20112
|
]
|
|
18984
20113
|
});
|
|
18985
20114
|
var DEFAULT_TOOL_OUTPUT_LIMIT = 64e3;
|
|
18986
|
-
function
|
|
20115
|
+
function isRecord9(value) {
|
|
18987
20116
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
18988
20117
|
}
|
|
18989
20118
|
function errorMessage(error51) {
|
|
@@ -18998,7 +20127,7 @@ var OmpAdapterFaultError = class extends Error {
|
|
|
18998
20127
|
}
|
|
18999
20128
|
};
|
|
19000
20129
|
function normalizedError(error51, fallbackCode) {
|
|
19001
|
-
if (
|
|
20130
|
+
if (isRecord9(error51) && error51.code === "ENOENT") {
|
|
19002
20131
|
return { code: "notInstalled", message: errorMessage(error51), retryable: false };
|
|
19003
20132
|
}
|
|
19004
20133
|
if (error51 instanceof OmpAdapterFaultError)
|
|
@@ -19036,8 +20165,8 @@ function nativeModelFromState(state) {
|
|
|
19036
20165
|
return { provider: state.provider, id: state.modelId };
|
|
19037
20166
|
}
|
|
19038
20167
|
function effectiveModelFromState(state) {
|
|
19039
|
-
const
|
|
19040
|
-
return
|
|
20168
|
+
const model2 = nativeModelFromState(state);
|
|
20169
|
+
return model2 ? encodeOmpModelRef(model2) : void 0;
|
|
19041
20170
|
}
|
|
19042
20171
|
function harnessStateFromOmp(state, thinkingLevels, permissionModeId) {
|
|
19043
20172
|
const effectiveModel = effectiveModelFromState(state);
|
|
@@ -19075,7 +20204,7 @@ function nativeModelForHistory(state) {
|
|
|
19075
20204
|
return nativeModelFromState(state);
|
|
19076
20205
|
}
|
|
19077
20206
|
function sessionFileFromRef(ref) {
|
|
19078
|
-
if (ref.harnessId !== ompHarnessId2 || !
|
|
20207
|
+
if (ref.harnessId !== ompHarnessId2 || !isRecord9(ref.locator) || typeof ref.locator.sessionFile !== "string" || ref.locator.sessionFile.length === 0) {
|
|
19079
20208
|
throw new Error("Omp Native Session Ref has no resumable Session file");
|
|
19080
20209
|
}
|
|
19081
20210
|
return ref.locator.sessionFile;
|
|
@@ -19085,7 +20214,7 @@ function subagentTranscriptPath(parentSessionFile, nativeSubagentId) {
|
|
|
19085
20214
|
if (nativeSubagentId.includes("/") || nativeSubagentId.includes("\\") || nativeSubagentId.includes("\0") || nativeSubagentId === "." || nativeSubagentId === "..") {
|
|
19086
20215
|
throw new Error("Omp Subagent ID is not a plain transcript file name");
|
|
19087
20216
|
}
|
|
19088
|
-
if (!parentSessionFile.endsWith(".jsonl") || !
|
|
20217
|
+
if (!parentSessionFile.endsWith(".jsonl") || !path7.isAbsolute(parentSessionFile)) {
|
|
19089
20218
|
return null;
|
|
19090
20219
|
}
|
|
19091
20220
|
return `${parentSessionFile.slice(0, -".jsonl".length)}/${nativeSubagentId}.jsonl`;
|
|
@@ -19094,10 +20223,10 @@ async function readSubagentTranscriptFile(parentSessionFile, nativeSubagentId) {
|
|
|
19094
20223
|
const transcriptFile = subagentTranscriptPath(parentSessionFile, nativeSubagentId);
|
|
19095
20224
|
if (transcriptFile === null)
|
|
19096
20225
|
return { status: "missing" };
|
|
19097
|
-
const parentDirectory =
|
|
20226
|
+
const parentDirectory = path7.dirname(transcriptFile);
|
|
19098
20227
|
let metadata;
|
|
19099
20228
|
try {
|
|
19100
|
-
metadata = await
|
|
20229
|
+
metadata = await stat2(transcriptFile);
|
|
19101
20230
|
} catch (error51) {
|
|
19102
20231
|
if (error51.code === "ENOENT")
|
|
19103
20232
|
return { status: "missing" };
|
|
@@ -19109,10 +20238,10 @@ async function readSubagentTranscriptFile(parentSessionFile, nativeSubagentId) {
|
|
|
19109
20238
|
throw new Error("Omp Subagent transcript exceeds the supported size");
|
|
19110
20239
|
}
|
|
19111
20240
|
const [resolvedTranscript, resolvedParentDirectory] = await Promise.all([
|
|
19112
|
-
|
|
19113
|
-
|
|
20241
|
+
realpath3(transcriptFile),
|
|
20242
|
+
realpath3(parentDirectory)
|
|
19114
20243
|
]);
|
|
19115
|
-
if (
|
|
20244
|
+
if (path7.dirname(resolvedTranscript) !== resolvedParentDirectory) {
|
|
19116
20245
|
throw new Error("Omp Subagent transcript resolves outside its parent Session directory");
|
|
19117
20246
|
}
|
|
19118
20247
|
return {
|
|
@@ -19130,9 +20259,9 @@ function toolFailure(toolName) {
|
|
|
19130
20259
|
function nativeText(value) {
|
|
19131
20260
|
if (typeof value === "string")
|
|
19132
20261
|
return value;
|
|
19133
|
-
if (!
|
|
20262
|
+
if (!isRecord9(value) || !Array.isArray(value.content))
|
|
19134
20263
|
return "";
|
|
19135
|
-
return value.content.filter((content) =>
|
|
20264
|
+
return value.content.filter((content) => isRecord9(content) && content.type === "text" && typeof content.text === "string").map(({ text }) => text).join("");
|
|
19136
20265
|
}
|
|
19137
20266
|
function boundedOutput(value, limit) {
|
|
19138
20267
|
const text = nativeText(value);
|
|
@@ -19148,17 +20277,17 @@ function outputText(output) {
|
|
|
19148
20277
|
return output?.content.filter((content) => content.type === "text").map(({ text }) => text).join("") ?? "";
|
|
19149
20278
|
}
|
|
19150
20279
|
function stringField2(value, key) {
|
|
19151
|
-
if (!
|
|
20280
|
+
if (!isRecord9(value))
|
|
19152
20281
|
return void 0;
|
|
19153
20282
|
const field = value[key];
|
|
19154
20283
|
if (typeof field === "string" && field.length > 0)
|
|
19155
20284
|
return field;
|
|
19156
|
-
if (
|
|
20285
|
+
if (isRecord9(value.input)) {
|
|
19157
20286
|
const nested = value.input[key];
|
|
19158
20287
|
if (typeof nested === "string" && nested.length > 0)
|
|
19159
20288
|
return nested;
|
|
19160
20289
|
}
|
|
19161
|
-
if (
|
|
20290
|
+
if (isRecord9(value.arguments)) {
|
|
19162
20291
|
const nested = value.arguments[key];
|
|
19163
20292
|
if (typeof nested === "string" && nested.length > 0)
|
|
19164
20293
|
return nested;
|
|
@@ -19166,7 +20295,7 @@ function stringField2(value, key) {
|
|
|
19166
20295
|
return void 0;
|
|
19167
20296
|
}
|
|
19168
20297
|
function numberField(value, key) {
|
|
19169
|
-
if (!
|
|
20298
|
+
if (!isRecord9(value))
|
|
19170
20299
|
return void 0;
|
|
19171
20300
|
const field = value[key];
|
|
19172
20301
|
return typeof field === "number" || field === null ? field : void 0;
|
|
@@ -19177,10 +20306,10 @@ function stripDiffPrefix(pathString) {
|
|
|
19177
20306
|
return pathString.startsWith("a/") || pathString.startsWith("b/") ? pathString.slice(2) : pathString;
|
|
19178
20307
|
}
|
|
19179
20308
|
function displayPath(nativePath, cwd) {
|
|
19180
|
-
const resolvedCwd =
|
|
19181
|
-
const resolvedPath =
|
|
19182
|
-
const relative =
|
|
19183
|
-
const inside = relative.length > 0 && relative !== ".." && !relative.startsWith(`..${
|
|
20309
|
+
const resolvedCwd = path7.resolve(cwd);
|
|
20310
|
+
const resolvedPath = path7.isAbsolute(nativePath) ? path7.resolve(nativePath) : path7.resolve(cwd, nativePath);
|
|
20311
|
+
const relative = path7.relative(resolvedCwd, resolvedPath);
|
|
20312
|
+
const inside = relative.length > 0 && relative !== ".." && !relative.startsWith(`..${path7.sep}`);
|
|
19184
20313
|
const selected = inside ? relative : resolvedPath;
|
|
19185
20314
|
const normalized = selected.replaceAll("\\", "/");
|
|
19186
20315
|
if (normalized.length === 0 || normalized === ".")
|
|
@@ -19205,7 +20334,7 @@ function fileMutatingKind(toolName) {
|
|
|
19205
20334
|
return null;
|
|
19206
20335
|
}
|
|
19207
20336
|
function nestedToolString(value, keys) {
|
|
19208
|
-
if (!
|
|
20337
|
+
if (!isRecord9(value))
|
|
19209
20338
|
return void 0;
|
|
19210
20339
|
for (const key of keys) {
|
|
19211
20340
|
const field = value[key];
|
|
@@ -19220,14 +20349,14 @@ function nestedToolString(value, keys) {
|
|
|
19220
20349
|
return void 0;
|
|
19221
20350
|
}
|
|
19222
20351
|
function patchFromResult(result) {
|
|
19223
|
-
if (!
|
|
20352
|
+
if (!isRecord9(result))
|
|
19224
20353
|
return void 0;
|
|
19225
20354
|
for (const key of ["patch", "diff", "unifiedDiff"]) {
|
|
19226
20355
|
const field = result[key];
|
|
19227
20356
|
if (typeof field === "string" && field.length > 0)
|
|
19228
20357
|
return field;
|
|
19229
20358
|
}
|
|
19230
|
-
if (
|
|
20359
|
+
if (isRecord9(result.details)) {
|
|
19231
20360
|
for (const key of ["patch", "diff", "unifiedDiff"]) {
|
|
19232
20361
|
const field = result.details[key];
|
|
19233
20362
|
if (typeof field === "string" && field.length > 0)
|
|
@@ -19387,6 +20516,19 @@ var OmpHarnessSession = class {
|
|
|
19387
20516
|
this.#usage = this.initialUsage;
|
|
19388
20517
|
this.#state = this.initialState;
|
|
19389
20518
|
this.outputs = this.#channel.outputs;
|
|
20519
|
+
const usageHistory = options.usageHistory ?? (options.startedTransport ? { requests: [], complete: false } : { requests: [], complete: true });
|
|
20520
|
+
for (const request of usageHistory.requests)
|
|
20521
|
+
this.#event({ type: "usage.request", request });
|
|
20522
|
+
this.#event({ type: "usage.history", complete: usageHistory.complete });
|
|
20523
|
+
}
|
|
20524
|
+
handleTransportUsage(observation) {
|
|
20525
|
+
if (this.#phase !== "open")
|
|
20526
|
+
return;
|
|
20527
|
+
const record2 = ompUsageRecord(observation.message, observation);
|
|
20528
|
+
if (record2?.kind === "request")
|
|
20529
|
+
this.#event({ type: "usage.request", request: record2.request });
|
|
20530
|
+
else if (record2?.kind === "missing")
|
|
20531
|
+
this.#event({ type: "usage.history", complete: false });
|
|
19390
20532
|
}
|
|
19391
20533
|
handleTransportFault(error51) {
|
|
19392
20534
|
queueMicrotask(() => this.#fault(error51));
|
|
@@ -19542,7 +20684,7 @@ var OmpHarnessSession = class {
|
|
|
19542
20684
|
}
|
|
19543
20685
|
}
|
|
19544
20686
|
async readSnapshot() {
|
|
19545
|
-
if (this.#phase !== "open") {
|
|
20687
|
+
if (this.#phase !== "open" && this.#phase !== "faulted") {
|
|
19546
20688
|
return { ok: false, error: invalidState("Omp Session is not open") };
|
|
19547
20689
|
}
|
|
19548
20690
|
if (this.#active || this.#acceptingTurn || this.#configuring) {
|
|
@@ -19556,8 +20698,24 @@ var OmpHarnessSession = class {
|
|
|
19556
20698
|
};
|
|
19557
20699
|
}
|
|
19558
20700
|
try {
|
|
19559
|
-
const transport = await this.#ensureTransport();
|
|
19560
|
-
|
|
20701
|
+
const transport = this.#phase === "faulted" ? this.#transport : await this.#ensureTransport();
|
|
20702
|
+
if (!transport)
|
|
20703
|
+
return { ok: false, error: invalidState("Omp Session has no history transport") };
|
|
20704
|
+
let history;
|
|
20705
|
+
if (this.#phase === "faulted") {
|
|
20706
|
+
await transport.close();
|
|
20707
|
+
const sessionFile = transport.state.sessionFile;
|
|
20708
|
+
if (!sessionFile)
|
|
20709
|
+
throw new Error("Omp faulted Session has no persisted history");
|
|
20710
|
+
await verifyOmpSessionCwd({
|
|
20711
|
+
sessionFile,
|
|
20712
|
+
sessionId: transport.state.sessionId,
|
|
20713
|
+
expectedCwd: this.#cwd
|
|
20714
|
+
});
|
|
20715
|
+
history = await readOmpSessionHistory(sessionFile);
|
|
20716
|
+
} else {
|
|
20717
|
+
history = await transport.getEntries();
|
|
20718
|
+
}
|
|
19561
20719
|
return {
|
|
19562
20720
|
ok: true,
|
|
19563
20721
|
value: {
|
|
@@ -19667,6 +20825,10 @@ var OmpHarnessSession = class {
|
|
|
19667
20825
|
this.#event({ type: "turn.started", turnId: command.turnId });
|
|
19668
20826
|
this.#event({ type: "item.started", turnId: command.turnId, item });
|
|
19669
20827
|
void transport.runTurn(text, (event) => this.#handleTurnEvent(active, event)).then(async (result) => {
|
|
20828
|
+
if (!result.agentInvoked) {
|
|
20829
|
+
this.#completeTurn(active, result.error !== void 0 ? { status: "failed", error: normalizedError(result.error, "nativeFailure") } : result.cancelled ? { status: "cancelled", reason: "Cancelled by user" } : { status: "succeeded" }, result.text, void 0, true);
|
|
20830
|
+
return;
|
|
20831
|
+
}
|
|
19670
20832
|
try {
|
|
19671
20833
|
const identity = await this.#completedTurnIdentity(active, transport);
|
|
19672
20834
|
this.#completeTurn(active, result.cancelled ? {
|
|
@@ -19883,7 +21045,8 @@ var OmpHarnessSession = class {
|
|
|
19883
21045
|
sessionFile,
|
|
19884
21046
|
permissionMode: mode,
|
|
19885
21047
|
onFault: (error51) => queueMicrotask(() => this.#fault(error51)),
|
|
19886
|
-
onSubagentEvent: (event) => this.handleTransportEvent(event)
|
|
21048
|
+
onSubagentEvent: (event) => this.handleTransportEvent(event),
|
|
21049
|
+
onUsage: (observation) => this.handleTransportUsage(observation)
|
|
19887
21050
|
});
|
|
19888
21051
|
try {
|
|
19889
21052
|
let replacement = null;
|
|
@@ -20165,6 +21328,7 @@ var OmpHarnessSession = class {
|
|
|
20165
21328
|
cwd: this.#cwd,
|
|
20166
21329
|
onFault: (error51) => queueMicrotask(() => this.#fault(error51)),
|
|
20167
21330
|
onSubagentEvent: (event) => this.handleTransportEvent(event),
|
|
21331
|
+
onUsage: (observation) => this.handleTransportUsage(observation),
|
|
20168
21332
|
permissionMode: this.#permissionMode
|
|
20169
21333
|
});
|
|
20170
21334
|
const starting = transport.start().then(async () => {
|
|
@@ -20185,14 +21349,19 @@ var OmpHarnessSession = class {
|
|
|
20185
21349
|
}
|
|
20186
21350
|
if (this.#requestedThinkingOptionId) {
|
|
20187
21351
|
if (!thinkingLevels) {
|
|
20188
|
-
|
|
20189
|
-
|
|
20190
|
-
|
|
20191
|
-
|
|
20192
|
-
|
|
21352
|
+
const current = nativeModelFromState(state);
|
|
21353
|
+
const thinkingAlreadyOff = this.#requestedThinkingOptionId === "off" && (state.thinkingLevel === "off" || current !== null && (await transport.getAvailableModels()).some((model2) => sameOmpModel(model2, current) && model2.reasoning === false));
|
|
21354
|
+
if (!thinkingAlreadyOff) {
|
|
21355
|
+
throw new OmpAdapterFaultError({
|
|
21356
|
+
code: "unsupported",
|
|
21357
|
+
message: "Installed Omp does not support Thinking selection",
|
|
21358
|
+
retryable: false
|
|
21359
|
+
});
|
|
21360
|
+
}
|
|
21361
|
+
} else {
|
|
21362
|
+
state = await transport.selectThinkingOption(this.#requestedThinkingOptionId);
|
|
21363
|
+
thinkingLevels = await transport.getAvailableThinkingLevels();
|
|
20193
21364
|
}
|
|
20194
|
-
state = await transport.selectThinkingOption(this.#requestedThinkingOptionId);
|
|
20195
|
-
thinkingLevels = await transport.getAvailableThinkingLevels();
|
|
20196
21365
|
} else {
|
|
20197
21366
|
const reconciled = await reconcileThinkingLevel(transport, state, thinkingLevels);
|
|
20198
21367
|
state = reconciled.state;
|
|
@@ -20231,14 +21400,14 @@ var OmpHarnessSession = class {
|
|
|
20231
21400
|
const generation = this.#usageGeneration;
|
|
20232
21401
|
const refreshSequence = ++this.#usageRefreshSequence;
|
|
20233
21402
|
const sessionId = transport.state.sessionId;
|
|
20234
|
-
const
|
|
21403
|
+
const model2 = `${transport.state.provider ?? ""}\0${transport.state.modelId ?? ""}`;
|
|
20235
21404
|
let usage;
|
|
20236
21405
|
try {
|
|
20237
21406
|
usage = await transport.getSessionUsage();
|
|
20238
21407
|
} catch {
|
|
20239
21408
|
return;
|
|
20240
21409
|
}
|
|
20241
|
-
if (usage === null || this.#phase !== "open" || this.#transport !== transport || this.#usageGeneration !== generation || this.#usageRefreshSequence !== refreshSequence || transport.state.sessionId !== sessionId || `${transport.state.provider ?? ""}\0${transport.state.modelId ?? ""}` !==
|
|
21410
|
+
if (usage === null || this.#phase !== "open" || this.#transport !== transport || this.#usageGeneration !== generation || this.#usageRefreshSequence !== refreshSequence || transport.state.sessionId !== sessionId || `${transport.state.provider ?? ""}\0${transport.state.modelId ?? ""}` !== model2) {
|
|
20242
21411
|
return;
|
|
20243
21412
|
}
|
|
20244
21413
|
if (JSON.stringify(usage) === JSON.stringify(this.#usage))
|
|
@@ -20621,7 +21790,7 @@ var OmpHarnessSession = class {
|
|
|
20621
21790
|
throw new Error("Omp Turn has no terminal Checkpoint identity");
|
|
20622
21791
|
return { nativeTurnRef: turn.nativeTurnRef, checkpoint: turn.checkpoint };
|
|
20623
21792
|
}
|
|
20624
|
-
#completeTurn(active, outcome, finalText, nativeTurnRef) {
|
|
21793
|
+
#completeTurn(active, outcome, finalText, nativeTurnRef, ephemeral) {
|
|
20625
21794
|
if (this.#active !== active)
|
|
20626
21795
|
return;
|
|
20627
21796
|
this.#active = null;
|
|
@@ -20653,7 +21822,8 @@ var OmpHarnessSession = class {
|
|
|
20653
21822
|
type: "turn.completed",
|
|
20654
21823
|
turnId: active.command.turnId,
|
|
20655
21824
|
outcome,
|
|
20656
|
-
...nativeTurnRef ? { nativeTurnRef } : {}
|
|
21825
|
+
...nativeTurnRef ? { nativeTurnRef } : {},
|
|
21826
|
+
...ephemeral ? { ephemeral } : {}
|
|
20657
21827
|
});
|
|
20658
21828
|
active.resolveCompletion();
|
|
20659
21829
|
queueMicrotask(() => {
|
|
@@ -20712,6 +21882,8 @@ var OmpAdapter = class {
|
|
|
20712
21882
|
commandCatalog = ompCommandCatalog;
|
|
20713
21883
|
liveCommandCatalog = true;
|
|
20714
21884
|
harnessId = ompHarnessId2;
|
|
21885
|
+
sessionImport;
|
|
21886
|
+
usageStatistics;
|
|
20715
21887
|
subagents = {
|
|
20716
21888
|
readSnapshot: async (input) => {
|
|
20717
21889
|
if (input.parent.harnessId !== this.harnessId || input.nativeSubagentId.trim().length === 0 || input.cwd.length === 0) {
|
|
@@ -20771,6 +21943,8 @@ var OmpAdapter = class {
|
|
|
20771
21943
|
createTransport: (sessionOptions) => new OmpRpcSession({ ...options, ...sessionOptions })
|
|
20772
21944
|
}) {
|
|
20773
21945
|
this.#createTransport = dependencies.createTransport;
|
|
21946
|
+
this.sessionImport = new OmpSessionImport({ ...process.env, ...options.environment });
|
|
21947
|
+
this.usageStatistics = createOmpUsageStatistics({ ...process.env, ...options.environment });
|
|
20774
21948
|
this.#closeTimeoutMs = options.closeTimeoutMs ?? 2e3;
|
|
20775
21949
|
this.#toolOutputLimit = options.toolOutputLimit ?? DEFAULT_TOOL_OUTPUT_LIMIT;
|
|
20776
21950
|
}
|
|
@@ -20942,7 +22116,8 @@ var OmpAdapter = class {
|
|
|
20942
22116
|
cwd: input.cwd,
|
|
20943
22117
|
...input.kind === "resume" ? { sessionFile: sourceSessionFile } : { forkSessionFile: sourceSessionFile },
|
|
20944
22118
|
onFault: (error51) => session?.handleTransportFault(error51),
|
|
20945
|
-
onSubagentEvent: (event) => session?.handleTransportEvent(event)
|
|
22119
|
+
onSubagentEvent: (event) => session?.handleTransportEvent(event),
|
|
22120
|
+
onUsage: (observation) => session?.handleTransportUsage(observation)
|
|
20946
22121
|
});
|
|
20947
22122
|
await transport.start();
|
|
20948
22123
|
if (input.kind === "resume") {
|
|
@@ -20998,7 +22173,9 @@ var OmpAdapter = class {
|
|
|
20998
22173
|
startedThinkingLevels = reconciled.thinkingLevels;
|
|
20999
22174
|
this.#thinkingSelectionSupported = startedThinkingLevels !== null;
|
|
21000
22175
|
const initialUsage = await transport.getSessionUsage().catch(() => null);
|
|
22176
|
+
const usageHistory = await transport.getEntries().then(ompUsageHistory).catch(() => ({ requests: [], complete: false }));
|
|
21001
22177
|
session = this.#trackSession(input.cwd, {
|
|
22178
|
+
usageHistory,
|
|
21002
22179
|
...input.environment ? { environment: input.environment } : {},
|
|
21003
22180
|
startedTransport: transport,
|
|
21004
22181
|
startedThinkingLevels,
|
|
@@ -21007,6 +22184,16 @@ var OmpAdapter = class {
|
|
|
21007
22184
|
permissionMode: "yolo",
|
|
21008
22185
|
permissionModeId: OMP_DEFAULT_PERMISSION_MODE_ID
|
|
21009
22186
|
});
|
|
22187
|
+
if (input.kind === "resume" && input.permissionModeId) {
|
|
22188
|
+
const restored = await session.execute({
|
|
22189
|
+
type: "permissionMode.select",
|
|
22190
|
+
permissionModeId: input.permissionModeId
|
|
22191
|
+
});
|
|
22192
|
+
if (!restored.ok) {
|
|
22193
|
+
await session.close();
|
|
22194
|
+
return restored;
|
|
22195
|
+
}
|
|
22196
|
+
}
|
|
21010
22197
|
return { ok: true, value: session };
|
|
21011
22198
|
} catch (error51) {
|
|
21012
22199
|
await transport?.close().catch(() => void 0);
|
|
@@ -21028,7 +22215,8 @@ var OmpAdapter = class {
|
|
|
21028
22215
|
permissionModeId: options.permissionModeId,
|
|
21029
22216
|
...options.startedTransport ? { startedTransport: options.startedTransport } : {},
|
|
21030
22217
|
...options.startedThinkingLevels !== void 0 ? { startedThinkingLevels: options.startedThinkingLevels } : {},
|
|
21031
|
-
...options.initialUsage !== void 0 ? { initialUsage: options.initialUsage } : {}
|
|
22218
|
+
...options.initialUsage !== void 0 ? { initialUsage: options.initialUsage } : {},
|
|
22219
|
+
...options.usageHistory ? { usageHistory: options.usageHistory } : {}
|
|
21032
22220
|
});
|
|
21033
22221
|
this.#sessions.add(session);
|
|
21034
22222
|
return session;
|
|
@@ -21036,6 +22224,7 @@ var OmpAdapter = class {
|
|
|
21036
22224
|
close() {
|
|
21037
22225
|
if (!this.#closePromise) {
|
|
21038
22226
|
this.#closePromise = Promise.all([
|
|
22227
|
+
this.sessionImport.close(),
|
|
21039
22228
|
...[...this.#inspections].map((transport) => transport.close()),
|
|
21040
22229
|
...[...this.#sessions].map((session) => session.close())
|
|
21041
22230
|
]).then(() => void 0);
|
|
@@ -21045,22 +22234,22 @@ var OmpAdapter = class {
|
|
|
21045
22234
|
};
|
|
21046
22235
|
|
|
21047
22236
|
// dist/installation.js
|
|
21048
|
-
import { realpath as
|
|
21049
|
-
import
|
|
22237
|
+
import { realpath as realpath4 } from "node:fs/promises";
|
|
22238
|
+
import path8 from "node:path";
|
|
21050
22239
|
function createOmpInstallation(environment, command) {
|
|
21051
22240
|
let executable;
|
|
21052
22241
|
let env;
|
|
21053
22242
|
return createInstallationManager({
|
|
21054
22243
|
async check() {
|
|
21055
22244
|
executable = resolveOmpExecutable({ environment, ...command ? { command } : {} });
|
|
21056
|
-
const selected = await
|
|
22245
|
+
const selected = await realpath4(executable);
|
|
21057
22246
|
const pathKey = Object.keys(environment).find((key) => key.toLowerCase() === "path") ?? "PATH";
|
|
21058
22247
|
env = {
|
|
21059
22248
|
...environment,
|
|
21060
|
-
[pathKey]: `${
|
|
22249
|
+
[pathKey]: `${path8.dirname(executable)}${path8.delimiter}${environment[pathKey] ?? ""}`
|
|
21061
22250
|
};
|
|
21062
22251
|
const target = resolveHarnessExecutable({ id: "omp", command: "omp", installRoots: { posix: [], windows: [] } }, { environment: env });
|
|
21063
|
-
const canUpdate = !selected.includes("/nix/store/") && !!target && await
|
|
22252
|
+
const canUpdate = !selected.includes("/nix/store/") && !!target && await realpath4(target.executable) === selected;
|
|
21064
22253
|
const output = await runInstallationCommand(executable, ["update", "--check"], env);
|
|
21065
22254
|
const currentVersion = versionFromOutput(output);
|
|
21066
22255
|
const available = output.match(/New version available:\s*(\S+)/i);
|