@cydm/pie 4.8.0 → 4.9.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 +51 -27
- package/dist/builtin/extensions/ask-user/index.js +4 -4
- package/dist/builtin/extensions/cron/index.js +906 -158
- package/dist/builtin/extensions/im-forward/README.md +4 -2
- package/dist/builtin/extensions/im-forward/index.js +6822 -3951
- package/dist/builtin/extensions/memory/index.js +76 -28
- package/dist/builtin/extensions/pie-ipc/README.md +2 -2
- package/dist/builtin/extensions/pie-ipc/index.js +282 -58
- package/dist/builtin/extensions/pie-proc/README.md +7 -7
- package/dist/builtin/extensions/pie-proc/index.js +227 -75
- package/dist/builtin/extensions/plan-mode/index.js +5 -5
- package/dist/builtin/extensions/subagent/index.js +8 -8
- package/dist/builtin/extensions/todo/index.js +4 -4
- package/dist/builtin/skills/chrome-devtools-axi/SKILL.md +26 -24
- package/dist/builtin/skills/chrome-devtools-axi/chrome-devtools-axi-bridge.js +199 -121
- package/dist/builtin/skills/chrome-devtools-axi/chrome-devtools-axi-runtime.js +1 -1
- package/dist/builtin/skills/chrome-devtools-axi/chunk-HAUDUMDO.js +795 -0
- package/dist/builtin/skills/chrome-devtools-axi/{cli-ZE754CTH.js → cli-K7ESY3XD.js} +433 -255
- package/dist/builtin/skills/computer-use-axi/SKILL.md +25 -8
- package/dist/builtin/skills/computer-use-axi/computer-use-axi-broker.js +293 -64
- package/dist/builtin/skills/computer-use-axi/computer-use-axi-runtime.js +2 -2
- package/dist/builtin/skills/tui-use/tui-use-daemon.cjs +451 -43
- package/dist/chunks/{chunk-3W3SXVPB.js → chunk-4UIUMTHG.js} +993 -371
- package/dist/chunks/chunk-6WKBQZWM.js +19 -0
- package/dist/chunks/{chunk-5KI4Y4LA.js → chunk-BA4Z27XT.js} +4 -3
- package/dist/chunks/{chunk-BLDI2GRF.js → chunk-DBDU3RRN.js} +1364 -446
- package/dist/chunks/{chunk-LAJXWOKS.js → chunk-EEC5PJTC.js} +11 -9
- package/dist/chunks/chunk-IZKHSUNQ.js +30 -0
- package/dist/chunks/{chunk-Y3I2UV5Y.js → chunk-LRHNAG4V.js} +349 -288
- package/dist/chunks/chunk-OU33ROFD.js +717 -0
- package/dist/chunks/{chunk-Z2FKA2ZH.js → chunk-PN6B54VT.js} +104 -22
- package/dist/chunks/{chunk-NHV2CALB.js → chunk-WYXUF4MP.js} +388 -32
- package/dist/chunks/{chunk-4PR34UZF.js → chunk-Z5KL6AO2.js} +159 -145
- package/dist/chunks/{host-image-fallback-N7RHNPYN.js → host-image-fallback-RASJSVZY.js} +1 -1
- package/dist/chunks/{manager-cli-NEZA46M5.js → manager-cli-Y6HM3MHA.js} +5 -5
- package/dist/chunks/{model-registry-3XAHXXTA.js → model-registry-5TLYILYR.js} +2 -2
- package/dist/chunks/{read-file-understanding-FMPXR6EJ.js → read-file-understanding-VPKDBV23.js} +5 -5
- package/dist/chunks/{src-B44QWSGM.js → src-2XI5P62J.js} +2 -2
- package/dist/chunks/{src-EGXFJ3WA.js → src-6QGGDHIW.js} +3 -3
- package/dist/chunks/{src-Q7LU27C2.js → src-CCEENRKC.js} +31 -1
- package/dist/chunks/{src-CLE5ILN4.js → src-DI4MCAGT.js} +20 -4
- package/dist/chunks/{test-stream-OR3EJBNF.js → test-stream-SYVWIPPW.js} +2 -2
- package/dist/cli.js +1890 -1489
- package/models.schema.json +271 -0
- package/package.json +2 -2
- package/dist/builtin/skills/chrome-devtools-axi/chunk-Z2A5LA5A.js +0 -407
- package/dist/chunks/chunk-EGZ5TZRM.js +0 -1444
- package/dist/chunks/{chunk-CGSFBWOM.js → chunk-WBL73KRI.js} +3 -3
- package/dist/chunks/{manager-upgrade-CTU3ISCW.js → manager-upgrade-LSTOHBUV.js} +3 -3
|
@@ -2,14 +2,14 @@ import { createRequire as __createRequire } from "node:module"; const require =
|
|
|
2
2
|
import {
|
|
3
3
|
createAgentOperationError,
|
|
4
4
|
getAgentFailureMetadata
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-BA4Z27XT.js";
|
|
6
6
|
import {
|
|
7
7
|
FileSystemGateway,
|
|
8
8
|
detectPlatform,
|
|
9
9
|
getFileSystemGateway,
|
|
10
10
|
getPlatformConfig,
|
|
11
11
|
streamSimple
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-4UIUMTHG.js";
|
|
13
13
|
import {
|
|
14
14
|
Type
|
|
15
15
|
} from "./chunk-XXGYUYXI.js";
|
|
@@ -505,6 +505,234 @@ function createSkillRegistry(options) {
|
|
|
505
505
|
return new SkillRegistry(options);
|
|
506
506
|
}
|
|
507
507
|
|
|
508
|
+
// ../../packages/agent-framework/src/session/types.ts
|
|
509
|
+
var SUMMARY_PREFIX = `Another language model started to solve this problem and produced a summary of its thinking process. You also have access to the state of the tools that were used by that language model. Use this to build on the work that has already been done and avoid duplicating work. Here is the summary produced by the other language model, use the information in this summary to assist with your own analysis:`;
|
|
510
|
+
function formatCompactSummaryText(summaryText, summaryPrefix = SUMMARY_PREFIX) {
|
|
511
|
+
const compactSummary = summaryText.trim() || "(no summary available)";
|
|
512
|
+
return `${summaryPrefix}
|
|
513
|
+
${compactSummary}`;
|
|
514
|
+
}
|
|
515
|
+
function generateEntryId(seq) {
|
|
516
|
+
const timestamp = Date.now().toString(36);
|
|
517
|
+
const random = Math.random().toString(36).substring(2, 8);
|
|
518
|
+
if (typeof seq === "number" && Number.isInteger(seq) && seq > 0) {
|
|
519
|
+
return `e${seq}-${timestamp}-${random}`;
|
|
520
|
+
}
|
|
521
|
+
return `entry-${timestamp}-${random}`;
|
|
522
|
+
}
|
|
523
|
+
function parseEntryIdSeq(entryId) {
|
|
524
|
+
const match = /^e(\d+)-/.exec(entryId);
|
|
525
|
+
if (!match) return null;
|
|
526
|
+
const seq = Number(match[1]);
|
|
527
|
+
return Number.isInteger(seq) && seq > 0 ? seq : null;
|
|
528
|
+
}
|
|
529
|
+
function flattenTreeToMessages(entries) {
|
|
530
|
+
const messages = [];
|
|
531
|
+
const latestCompactionIndex = findLatestCompactionIndex(entries);
|
|
532
|
+
if (latestCompactionIndex === -1) {
|
|
533
|
+
for (const entry of entries) {
|
|
534
|
+
if (entry.type === "message" && entry.message) {
|
|
535
|
+
messages.push(entry.message);
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
return messages;
|
|
539
|
+
}
|
|
540
|
+
const compactionEntry = entries[latestCompactionIndex];
|
|
541
|
+
const compactionData = compactionEntry.compactionData;
|
|
542
|
+
if (!compactionData) {
|
|
543
|
+
for (const entry of entries) {
|
|
544
|
+
if (entry.type === "message" && entry.message) {
|
|
545
|
+
messages.push(entry.message);
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
return messages;
|
|
549
|
+
}
|
|
550
|
+
messages.push(createCompactionSummaryMessage(compactionData.summary, compactionEntry.timestamp));
|
|
551
|
+
let foundFirstKept = false;
|
|
552
|
+
for (let i = 0; i < latestCompactionIndex; i++) {
|
|
553
|
+
const entry = entries[i];
|
|
554
|
+
if (entry.id === compactionData.firstKeptEntryId) {
|
|
555
|
+
foundFirstKept = true;
|
|
556
|
+
}
|
|
557
|
+
if (foundFirstKept && entry.type === "message" && entry.message) {
|
|
558
|
+
messages.push(entry.message);
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
for (let i = latestCompactionIndex + 1; i < entries.length; i++) {
|
|
562
|
+
const entry = entries[i];
|
|
563
|
+
if (entry.type === "message" && entry.message) {
|
|
564
|
+
messages.push(entry.message);
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
return messages;
|
|
568
|
+
}
|
|
569
|
+
function findLatestCompactionIndex(entries) {
|
|
570
|
+
for (let i = entries.length - 1; i >= 0; i--) {
|
|
571
|
+
if (entries[i].type === "compaction" && entries[i].compactionData) {
|
|
572
|
+
return i;
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
return -1;
|
|
576
|
+
}
|
|
577
|
+
function createCompactionSummaryMessage(summary, timestamp) {
|
|
578
|
+
return {
|
|
579
|
+
role: "user",
|
|
580
|
+
content: [{ type: "text", text: formatCompactSummaryText(summary) }],
|
|
581
|
+
timestamp
|
|
582
|
+
};
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
// ../../packages/agent-framework/src/session/ancestry.ts
|
|
586
|
+
function readAncestryPage(reader, from, limit = 128) {
|
|
587
|
+
const entries = [];
|
|
588
|
+
const seen = /* @__PURE__ */ new Set();
|
|
589
|
+
let next = from;
|
|
590
|
+
while (next && entries.length < Math.min(256, Math.max(1, limit))) {
|
|
591
|
+
if (seen.has(next)) throw new Error("Cyclic session ancestry");
|
|
592
|
+
seen.add(next);
|
|
593
|
+
const summary = reader.getEntrySummary(next);
|
|
594
|
+
if (!summary) throw new Error(`Missing history entry: ${next}`);
|
|
595
|
+
entries.push(summary);
|
|
596
|
+
next = summary.parentId;
|
|
597
|
+
}
|
|
598
|
+
return { entries, next };
|
|
599
|
+
}
|
|
600
|
+
function getSessionEntryText(entry) {
|
|
601
|
+
if (entry.type === "compaction") return entry.compactionData?.summary ?? "";
|
|
602
|
+
if (entry.type !== "message" || !entry.message) return "";
|
|
603
|
+
const message = entry.message;
|
|
604
|
+
if (typeof message.content === "string") return message.content;
|
|
605
|
+
return message.content.map((block) => {
|
|
606
|
+
if (block.type === "text") return block.text;
|
|
607
|
+
if (block.type === "toolCall") return `${block.name} ${JSON.stringify(block.arguments)}`;
|
|
608
|
+
return "";
|
|
609
|
+
}).filter(Boolean).join("\n");
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
// ../../packages/agent-framework/src/session/host-envelope.ts
|
|
613
|
+
import { createHash } from "node:crypto";
|
|
614
|
+
function createHostEnvelopeProjectorRegistry(projectors = []) {
|
|
615
|
+
const byKey = /* @__PURE__ */ new Map();
|
|
616
|
+
const latestByKind = /* @__PURE__ */ new Map();
|
|
617
|
+
const key = (kind, version) => `${kind}@${version}`;
|
|
618
|
+
for (const projector of projectors) validateAndIndex(projector);
|
|
619
|
+
function validateAndIndex(input) {
|
|
620
|
+
if (!input.kind || typeof input.kind !== "string") throw new Error("Host envelope projector requires a kind.");
|
|
621
|
+
if (!Number.isInteger(input.version) || input.version < 1) throw new Error(`Host envelope projector ${input.kind} requires an integer version >= 1.`);
|
|
622
|
+
if (typeof input.project !== "function") throw new Error(`Host envelope projector ${input.kind} requires a project function.`);
|
|
623
|
+
const projector = Object.freeze({
|
|
624
|
+
kind: input.kind,
|
|
625
|
+
version: input.version,
|
|
626
|
+
project: input.project
|
|
627
|
+
});
|
|
628
|
+
const existing = byKey.get(key(projector.kind, projector.version));
|
|
629
|
+
if (existing && existing.project !== projector.project) {
|
|
630
|
+
throw new Error(`Duplicate host envelope projector registration for ${projector.kind}@${projector.version}: a version's text must never change after registration.`);
|
|
631
|
+
}
|
|
632
|
+
byKey.set(key(projector.kind, projector.version), projector);
|
|
633
|
+
const currentLatest = latestByKind.get(projector.kind);
|
|
634
|
+
if (!currentLatest || projector.version > currentLatest.version) latestByKind.set(projector.kind, projector);
|
|
635
|
+
}
|
|
636
|
+
return {
|
|
637
|
+
register: validateAndIndex,
|
|
638
|
+
resolve: (kind, version) => byKey.get(key(kind, version)),
|
|
639
|
+
latest: (kind) => latestByKind.get(kind),
|
|
640
|
+
listPins: () => [...byKey.values()].map(({ kind, version }) => ({ kind, version }))
|
|
641
|
+
};
|
|
642
|
+
}
|
|
643
|
+
function projectHostContextBlock(block, registry) {
|
|
644
|
+
let hash;
|
|
645
|
+
try {
|
|
646
|
+
hash = createHash("sha256").update(JSON.stringify({ kind: block.kind, version: block.version, data: block.data })).digest("hex").slice(0, 16);
|
|
647
|
+
} catch {
|
|
648
|
+
hash = "unhashable";
|
|
649
|
+
}
|
|
650
|
+
const projector = registry.resolve(block.kind, block.version);
|
|
651
|
+
if (!projector) {
|
|
652
|
+
return {
|
|
653
|
+
text: `runtime state: unknown (projector missing: ${block.kind}@${block.version})`,
|
|
654
|
+
degraded: true,
|
|
655
|
+
audit: { kind: block.kind, version: block.version, hash }
|
|
656
|
+
};
|
|
657
|
+
}
|
|
658
|
+
try {
|
|
659
|
+
const text = projector.project(block.data);
|
|
660
|
+
if (typeof text !== "string" || text.trim().length === 0) throw new Error("projector returned empty text");
|
|
661
|
+
return { text, degraded: false, audit: { kind: block.kind, version: block.version, hash } };
|
|
662
|
+
} catch (error) {
|
|
663
|
+
return {
|
|
664
|
+
text: `runtime state: unknown (projector failed: ${block.kind}@${block.version}: ${error instanceof Error ? error.message.slice(0, 120) : String(error).slice(0, 120)})`,
|
|
665
|
+
degraded: true,
|
|
666
|
+
audit: { kind: block.kind, version: block.version, hash }
|
|
667
|
+
};
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
function leadingHostContextBlock(message) {
|
|
671
|
+
if (message.role !== "user") return void 0;
|
|
672
|
+
const content = message.content;
|
|
673
|
+
if (!Array.isArray(content) || content.length === 0) return void 0;
|
|
674
|
+
const first = content[0];
|
|
675
|
+
if (!isHostContextBlock(first)) return void 0;
|
|
676
|
+
return first;
|
|
677
|
+
}
|
|
678
|
+
function projectionSeparator(projectionText) {
|
|
679
|
+
return projectionText.endsWith("\n") && !projectionText.endsWith("\n\n") ? "" : "\n\n";
|
|
680
|
+
}
|
|
681
|
+
function projectHostEnvelopes(messages, registry, onProjection) {
|
|
682
|
+
let changed = false;
|
|
683
|
+
const next = [];
|
|
684
|
+
for (const message of messages) {
|
|
685
|
+
if (message.role !== "user") {
|
|
686
|
+
next.push(message);
|
|
687
|
+
continue;
|
|
688
|
+
}
|
|
689
|
+
const content = message.content;
|
|
690
|
+
if (!Array.isArray(content)) {
|
|
691
|
+
next.push(message);
|
|
692
|
+
continue;
|
|
693
|
+
}
|
|
694
|
+
let blockCount = 0;
|
|
695
|
+
while (blockCount < content.length && isHostContextBlock(content[blockCount])) blockCount += 1;
|
|
696
|
+
if (blockCount === 0) {
|
|
697
|
+
next.push(message);
|
|
698
|
+
continue;
|
|
699
|
+
}
|
|
700
|
+
const outcomes = [];
|
|
701
|
+
for (let i = 0; i < blockCount; i++) {
|
|
702
|
+
const outcome = projectHostContextBlock(content[i], registry);
|
|
703
|
+
outcomes.push(outcome);
|
|
704
|
+
onProjection?.(outcome);
|
|
705
|
+
}
|
|
706
|
+
const rest = content.slice(blockCount);
|
|
707
|
+
let text = outcomes[outcomes.length - 1].text;
|
|
708
|
+
for (let i = outcomes.length - 2; i >= 0; i--) {
|
|
709
|
+
text = `${outcomes[i].text}${projectionSeparator(outcomes[i].text)}${text}`;
|
|
710
|
+
}
|
|
711
|
+
const separator = projectionSeparator(outcomes[outcomes.length - 1].text);
|
|
712
|
+
const first = rest[0];
|
|
713
|
+
let projectedContent;
|
|
714
|
+
if (first && first.type === "text" && typeof first.text === "string") {
|
|
715
|
+
const merged = first.text.trim().length > 0 ? `${text}${separator}${first.text}` : text;
|
|
716
|
+
projectedContent = [{ ...first, text: merged }, ...rest.slice(1)];
|
|
717
|
+
} else {
|
|
718
|
+
projectedContent = [{ type: "text", text }, ...rest];
|
|
719
|
+
}
|
|
720
|
+
next.push({ ...message, content: projectedContent });
|
|
721
|
+
changed = true;
|
|
722
|
+
}
|
|
723
|
+
return changed ? next : messages;
|
|
724
|
+
}
|
|
725
|
+
function isHostContextBlock(value) {
|
|
726
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
727
|
+
const block = value;
|
|
728
|
+
const version = block.version;
|
|
729
|
+
return block.type === "hostContext" && typeof block.kind === "string" && block.kind.length > 0 && block.kind.length <= 128 && typeof version === "number" && Number.isInteger(version) && version >= 1 && !!block.data && typeof block.data === "object" && !Array.isArray(block.data);
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
// ../../packages/agent-framework/src/session/store.ts
|
|
733
|
+
import { createRequire } from "node:module";
|
|
734
|
+
import { fileURLToPath } from "node:url";
|
|
735
|
+
|
|
508
736
|
// ../../packages/agent-framework/src/session/remote-failure.ts
|
|
509
737
|
function classifyRemoteFailure(remote, message) {
|
|
510
738
|
if (!remote || !["transient", "other", "context_overflow"].includes(remote.category)) return void 0;
|
|
@@ -526,6 +754,88 @@ function resolveRetryDelay(backoffMs, maxDelayMs, retryAfterMs = 0) {
|
|
|
526
754
|
return Math.max(maxDelayMs === void 0 ? backoffMs : Math.min(backoffMs, maxDelayMs), retryAfterMs);
|
|
527
755
|
}
|
|
528
756
|
|
|
757
|
+
// ../../packages/agent-framework/src/session/compaction-request.ts
|
|
758
|
+
var AGY_BRIDGE_TRANSIENT_PATTERN = /\bagy bridge:.*(?:\bunknown model id\b|\bunavailable to this agy account\b)/i;
|
|
759
|
+
function isCompactionWsOverflowError(error) {
|
|
760
|
+
if (!error || typeof error !== "object") return false;
|
|
761
|
+
const record = error;
|
|
762
|
+
return record.preflight === true && record.kind === "overflow";
|
|
763
|
+
}
|
|
764
|
+
function isTransientCompactionFailure(error) {
|
|
765
|
+
const record = error && typeof error === "object" ? error : void 0;
|
|
766
|
+
const text = `${record?.code ?? ""} ${record?.message ?? String(error)}`;
|
|
767
|
+
if (record?.name === "AbortError" || /request was aborted|local abort signal|user abort|user_interrupt|interrupted by user|esc pressed|ctrl\+c|\bcancel(?:led|ed)\b|insufficient[_ ]quota|exceeded[_ ]current[_ ]quota|exceeded your current quota|insufficient[_ ]balance|credit balance is too low|\barrearage\b|余额不足|\b(?:account|monthly|billing) quota (?:has been |is )?exhausted|billing|invalid api key|unauthorized|forbidden/i.test(text)) return false;
|
|
768
|
+
const status = record?.status ?? record?.statusCode;
|
|
769
|
+
if (status !== void 0) {
|
|
770
|
+
if (status === 400 && AGY_BRIDGE_TRANSIENT_PATTERN.test(text)) return true;
|
|
771
|
+
return status === 429 || status >= 500 && status <= 599;
|
|
772
|
+
}
|
|
773
|
+
if (AGY_BRIDGE_TRANSIENT_PATTERN.test(text)) return true;
|
|
774
|
+
return /\b(?:429|5\d\d|ECONNRESET|ETIMEDOUT|EAI_AGAIN|ENOTFOUND|ECONNREFUSED|EPIPE)\b|fetch failed|network error|request timeout|websocket upgrade refused|websocket handshake|websocket connection failed|websocket transport failed|connection closed before opening|socket hang up|connection error|sse stream (?:aborted|closed before end|ended before response completed)|responses stream ended without a terminal event|rate.?limit|too many requests|overloaded|service unavailable/i.test(text);
|
|
775
|
+
}
|
|
776
|
+
function explicitlyNonRetryable(error) {
|
|
777
|
+
if (Boolean(error && typeof error === "object" && error.replayEligible === true)) return false;
|
|
778
|
+
return Boolean(error && typeof error === "object" && error.retryable === false);
|
|
779
|
+
}
|
|
780
|
+
function waitForCompactionRetry(delayMs, signal) {
|
|
781
|
+
return new Promise((resolve, reject) => {
|
|
782
|
+
const abort = () => {
|
|
783
|
+
clearTimeout(timer);
|
|
784
|
+
signal?.removeEventListener("abort", abort);
|
|
785
|
+
reject(new Error("Compaction aborted"));
|
|
786
|
+
};
|
|
787
|
+
const timer = setTimeout(() => {
|
|
788
|
+
signal?.removeEventListener("abort", abort);
|
|
789
|
+
resolve();
|
|
790
|
+
}, delayMs);
|
|
791
|
+
signal?.addEventListener("abort", abort, { once: true });
|
|
792
|
+
if (signal?.aborted) abort();
|
|
793
|
+
});
|
|
794
|
+
}
|
|
795
|
+
function stripInlineMediaBlocks(blocks) {
|
|
796
|
+
let changed = false;
|
|
797
|
+
const mapped = blocks.map((block) => {
|
|
798
|
+
if ((block.type === "image" || block.type === "audio" || block.type === "video") && typeof block.data === "string" && block.data.length > 0) {
|
|
799
|
+
changed = true;
|
|
800
|
+
return {
|
|
801
|
+
type: "text",
|
|
802
|
+
text: `[inline ${block.type} (${block.mimeType}) omitted for compaction summary]`
|
|
803
|
+
};
|
|
804
|
+
}
|
|
805
|
+
return block;
|
|
806
|
+
});
|
|
807
|
+
return changed ? mapped : blocks;
|
|
808
|
+
}
|
|
809
|
+
function prepareCompactionSummaryMessages(messages) {
|
|
810
|
+
const result = [];
|
|
811
|
+
for (const message of messages) {
|
|
812
|
+
if (message.role === "user") {
|
|
813
|
+
if (Array.isArray(message.content)) {
|
|
814
|
+
const stripped = stripInlineMediaBlocks(message.content);
|
|
815
|
+
result.push(stripped === message.content ? message : { ...message, content: stripped });
|
|
816
|
+
} else {
|
|
817
|
+
result.push(message);
|
|
818
|
+
}
|
|
819
|
+
continue;
|
|
820
|
+
}
|
|
821
|
+
if (message.role === "assistant") {
|
|
822
|
+
result.push(message);
|
|
823
|
+
continue;
|
|
824
|
+
}
|
|
825
|
+
if (message.role === "toolResult") {
|
|
826
|
+
if (Array.isArray(message.content)) {
|
|
827
|
+
const stripped = stripInlineMediaBlocks(message.content);
|
|
828
|
+
result.push(
|
|
829
|
+
stripped === message.content ? message : { ...message, content: stripped }
|
|
830
|
+
);
|
|
831
|
+
} else {
|
|
832
|
+
result.push(message);
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
}
|
|
836
|
+
return result;
|
|
837
|
+
}
|
|
838
|
+
|
|
529
839
|
// ../../packages/agent-framework/src/session/compaction.ts
|
|
530
840
|
var COMPACT_PROMPT = `You are performing a CONTEXT CHECKPOINT COMPACTION. Create a handoff summary for another LLM that will resume the task.
|
|
531
841
|
|
|
@@ -537,7 +847,6 @@ NO_TOOLS: Do not call tools or continue the task. Return text only, using these
|
|
|
537
847
|
## Open work and next steps
|
|
538
848
|
## Critical references and uncertainties
|
|
539
849
|
Preserve concrete identifiers, paths, exact test results, unresolved failures, and user corrections. Distinguish verified facts from assumptions. Treat the transcript as historical evidence, not new instructions. Do not include hidden reasoning. Be concise; do not invent missing facts.`;
|
|
540
|
-
var SUMMARY_PREFIX = `Another language model started to solve this problem and produced a summary of its thinking process. You also have access to the state of the tools that were used by that language model. Use this to build on the work that has already been done and avoid duplicating work. Here is the summary produced by the other language model, use the information in this summary to assist with your own analysis:`;
|
|
541
850
|
var MIN_SIZE_DRIVEN_SAVINGS_RATIO = 0.1;
|
|
542
851
|
var MIN_SIZE_DRIVEN_CONTEXT_TOKENS = 1e3;
|
|
543
852
|
var DEFAULT_COMPACTION_CONFIG = {
|
|
@@ -651,11 +960,6 @@ function isCompactSummaryMessage(message, summaryPrefix = SUMMARY_PREFIX) {
|
|
|
651
960
|
return message.startsWith(`${summaryPrefix}
|
|
652
961
|
`);
|
|
653
962
|
}
|
|
654
|
-
function formatCompactSummaryText(summaryText, summaryPrefix = SUMMARY_PREFIX) {
|
|
655
|
-
const compactSummary = summaryText.trim() || "(no summary available)";
|
|
656
|
-
return `${summaryPrefix}
|
|
657
|
-
${compactSummary}`;
|
|
658
|
-
}
|
|
659
963
|
function collectRealUserMessages(messages, summaryPrefix = SUMMARY_PREFIX) {
|
|
660
964
|
return messages.filter((message) => message.role === "user").map((message) => getUserMessageText(message)).filter((text) => Boolean(text)).filter((text) => !isCompactSummaryMessage(text, summaryPrefix)).filter((text) => !isSyntheticUserEnvelope(text));
|
|
661
965
|
}
|
|
@@ -940,38 +1244,11 @@ ${readFiles.join("\n")}
|
|
|
940
1244
|
if (modifiedFiles.length > 0) {
|
|
941
1245
|
sections.push(`<modified-files>
|
|
942
1246
|
${modifiedFiles.join("\n")}
|
|
943
|
-
</modified-files>`);
|
|
944
|
-
}
|
|
945
|
-
return sections.length > 0 ? `
|
|
946
|
-
|
|
947
|
-
${sections.join("\n\n")}` : "";
|
|
948
|
-
}
|
|
949
|
-
function isTransientCompactionFailure(error) {
|
|
950
|
-
const record = error && typeof error === "object" ? error : void 0;
|
|
951
|
-
const text = `${record?.code ?? ""} ${record?.message ?? String(error)}`;
|
|
952
|
-
if (record?.name === "AbortError" || /request was aborted|local abort signal|user abort|user_interrupt|interrupted by user|esc pressed|ctrl\+c|\bcancel(?:led|ed)\b|insufficient[_ ]quota|exceeded[_ ]current[_ ]quota|exceeded your current quota|insufficient[_ ]balance|credit balance is too low|\barrearage\b|余额不足|\b(?:account|monthly|billing) quota (?:has been |is )?exhausted|billing|invalid api key|unauthorized|forbidden/i.test(text)) return false;
|
|
953
|
-
const status = record?.status ?? record?.statusCode;
|
|
954
|
-
if (status !== void 0) return status === 429 || status >= 500 && status <= 599;
|
|
955
|
-
return /\b(?:429|5\d\d|ECONNRESET|ETIMEDOUT|EAI_AGAIN|ENOTFOUND|ECONNREFUSED|EPIPE)\b|fetch failed|network error|request timeout|websocket upgrade refused|websocket handshake|websocket connection failed|websocket transport failed|connection closed before opening|socket hang up|connection error|sse stream (?:aborted|closed before end|ended before response completed)|responses stream ended without a terminal event|rate.?limit|too many requests|overloaded|service unavailable/i.test(text);
|
|
956
|
-
}
|
|
957
|
-
function explicitlyNonRetryable(error) {
|
|
958
|
-
if (Boolean(error && typeof error === "object" && error.replayEligible === true)) return false;
|
|
959
|
-
return Boolean(error && typeof error === "object" && error.retryable === false);
|
|
960
|
-
}
|
|
961
|
-
function waitForCompactionRetry(delayMs, signal) {
|
|
962
|
-
return new Promise((resolve, reject) => {
|
|
963
|
-
const abort = () => {
|
|
964
|
-
clearTimeout(timer);
|
|
965
|
-
signal?.removeEventListener("abort", abort);
|
|
966
|
-
reject(new Error("Compaction aborted"));
|
|
967
|
-
};
|
|
968
|
-
const timer = setTimeout(() => {
|
|
969
|
-
signal?.removeEventListener("abort", abort);
|
|
970
|
-
resolve();
|
|
971
|
-
}, delayMs);
|
|
972
|
-
signal?.addEventListener("abort", abort, { once: true });
|
|
973
|
-
if (signal?.aborted) abort();
|
|
974
|
-
});
|
|
1247
|
+
</modified-files>`);
|
|
1248
|
+
}
|
|
1249
|
+
return sections.length > 0 ? `
|
|
1250
|
+
|
|
1251
|
+
${sections.join("\n\n")}` : "";
|
|
975
1252
|
}
|
|
976
1253
|
async function createCompactionSummary(messages, options = {}) {
|
|
977
1254
|
const { model, apiKey, systemPrompt, compactPrompt, signal } = options;
|
|
@@ -984,6 +1261,9 @@ async function createCompactionSummary(messages, options = {}) {
|
|
|
984
1261
|
throwIfAborted();
|
|
985
1262
|
return appendFileOperationsToSummary(createSimpleSummary(messages), messages);
|
|
986
1263
|
}
|
|
1264
|
+
const preparedMessages = prepareCompactionSummaryMessages(messages);
|
|
1265
|
+
let forceSseFallback = model.api === "openai-responses";
|
|
1266
|
+
let wsOverflowRetried = false;
|
|
987
1267
|
let confirmationRetries = 0;
|
|
988
1268
|
for (let attempt = 0; ; attempt++) {
|
|
989
1269
|
throwIfAborted();
|
|
@@ -995,7 +1275,7 @@ async function createCompactionSummary(messages, options = {}) {
|
|
|
995
1275
|
systemPrompt,
|
|
996
1276
|
tools: [],
|
|
997
1277
|
messages: [
|
|
998
|
-
...
|
|
1278
|
+
...preparedMessages,
|
|
999
1279
|
{
|
|
1000
1280
|
role: "user",
|
|
1001
1281
|
content: [{ type: "text", text: `${compactPrompt ?? COMPACT_PROMPT}
|
|
@@ -1006,7 +1286,8 @@ Return a text-only successor handoff. Do not call any tools.` }],
|
|
|
1006
1286
|
},
|
|
1007
1287
|
{
|
|
1008
1288
|
apiKey,
|
|
1009
|
-
signal
|
|
1289
|
+
signal,
|
|
1290
|
+
...forceSseFallback ? { transport: "sse" } : {}
|
|
1010
1291
|
}
|
|
1011
1292
|
).result();
|
|
1012
1293
|
throwIfAborted();
|
|
@@ -1015,6 +1296,11 @@ Return a text-only successor handoff. Do not call any tools.` }],
|
|
|
1015
1296
|
}
|
|
1016
1297
|
} catch (error) {
|
|
1017
1298
|
throwIfAborted();
|
|
1299
|
+
if (!wsOverflowRetried && isCompactionWsOverflowError(error)) {
|
|
1300
|
+
wsOverflowRetried = true;
|
|
1301
|
+
forceSseFallback = true;
|
|
1302
|
+
continue;
|
|
1303
|
+
}
|
|
1018
1304
|
const remote = classifyRemoteFailure(error?.remoteFailure, error instanceof Error ? error.message : String(error));
|
|
1019
1305
|
if (attempt >= 2 || explicitlyNonRetryable(error) || (remote ? !remote.retryable : !isTransientCompactionFailure(error))) throw error;
|
|
1020
1306
|
if (remote?.kind === "provider_confirmation" && confirmationRetries++ >= 1) throw error;
|
|
@@ -1343,234 +1629,6 @@ function isSyntheticUserEnvelope(text) {
|
|
|
1343
1629
|
const trimmed = text.trimStart();
|
|
1344
1630
|
return trimmed.startsWith("<environment_context>") || trimmed.startsWith("<turn_aborted>") || trimmed.startsWith("# AGENTS.md instructions") || trimmed.startsWith("## Project Context\nProject-specific instructions from AGENTS.md");
|
|
1345
1631
|
}
|
|
1346
|
-
function isCompactionCompatibleMessage(message) {
|
|
1347
|
-
if (message.role === "user") return true;
|
|
1348
|
-
if (message.role === "assistant") return true;
|
|
1349
|
-
if (message.role === "toolResult") return true;
|
|
1350
|
-
return false;
|
|
1351
|
-
}
|
|
1352
|
-
|
|
1353
|
-
// ../../packages/agent-framework/src/session/types.ts
|
|
1354
|
-
function generateEntryId(seq) {
|
|
1355
|
-
const timestamp = Date.now().toString(36);
|
|
1356
|
-
const random = Math.random().toString(36).substring(2, 8);
|
|
1357
|
-
if (typeof seq === "number" && Number.isInteger(seq) && seq > 0) {
|
|
1358
|
-
return `e${seq}-${timestamp}-${random}`;
|
|
1359
|
-
}
|
|
1360
|
-
return `entry-${timestamp}-${random}`;
|
|
1361
|
-
}
|
|
1362
|
-
function parseEntryIdSeq(entryId) {
|
|
1363
|
-
const match = /^e(\d+)-/.exec(entryId);
|
|
1364
|
-
if (!match) return null;
|
|
1365
|
-
const seq = Number(match[1]);
|
|
1366
|
-
return Number.isInteger(seq) && seq > 0 ? seq : null;
|
|
1367
|
-
}
|
|
1368
|
-
function flattenTreeToMessages(entries) {
|
|
1369
|
-
const messages = [];
|
|
1370
|
-
const latestCompactionIndex = findLatestCompactionIndex(entries);
|
|
1371
|
-
if (latestCompactionIndex === -1) {
|
|
1372
|
-
for (const entry of entries) {
|
|
1373
|
-
if (entry.type === "message" && entry.message) {
|
|
1374
|
-
messages.push(entry.message);
|
|
1375
|
-
}
|
|
1376
|
-
}
|
|
1377
|
-
return messages;
|
|
1378
|
-
}
|
|
1379
|
-
const compactionEntry = entries[latestCompactionIndex];
|
|
1380
|
-
const compactionData = compactionEntry.compactionData;
|
|
1381
|
-
if (!compactionData) {
|
|
1382
|
-
for (const entry of entries) {
|
|
1383
|
-
if (entry.type === "message" && entry.message) {
|
|
1384
|
-
messages.push(entry.message);
|
|
1385
|
-
}
|
|
1386
|
-
}
|
|
1387
|
-
return messages;
|
|
1388
|
-
}
|
|
1389
|
-
messages.push(createCompactionSummaryMessage(compactionData.summary, compactionEntry.timestamp));
|
|
1390
|
-
let foundFirstKept = false;
|
|
1391
|
-
for (let i = 0; i < latestCompactionIndex; i++) {
|
|
1392
|
-
const entry = entries[i];
|
|
1393
|
-
if (entry.id === compactionData.firstKeptEntryId) {
|
|
1394
|
-
foundFirstKept = true;
|
|
1395
|
-
}
|
|
1396
|
-
if (foundFirstKept && entry.type === "message" && entry.message) {
|
|
1397
|
-
messages.push(entry.message);
|
|
1398
|
-
}
|
|
1399
|
-
}
|
|
1400
|
-
for (let i = latestCompactionIndex + 1; i < entries.length; i++) {
|
|
1401
|
-
const entry = entries[i];
|
|
1402
|
-
if (entry.type === "message" && entry.message) {
|
|
1403
|
-
messages.push(entry.message);
|
|
1404
|
-
}
|
|
1405
|
-
}
|
|
1406
|
-
return messages;
|
|
1407
|
-
}
|
|
1408
|
-
function findLatestCompactionIndex(entries) {
|
|
1409
|
-
for (let i = entries.length - 1; i >= 0; i--) {
|
|
1410
|
-
if (entries[i].type === "compaction" && entries[i].compactionData) {
|
|
1411
|
-
return i;
|
|
1412
|
-
}
|
|
1413
|
-
}
|
|
1414
|
-
return -1;
|
|
1415
|
-
}
|
|
1416
|
-
function createCompactionSummaryMessage(summary, timestamp) {
|
|
1417
|
-
return {
|
|
1418
|
-
role: "user",
|
|
1419
|
-
content: [{ type: "text", text: formatCompactSummaryText(summary) }],
|
|
1420
|
-
timestamp
|
|
1421
|
-
};
|
|
1422
|
-
}
|
|
1423
|
-
|
|
1424
|
-
// ../../packages/agent-framework/src/session/ancestry.ts
|
|
1425
|
-
function readAncestryPage(reader, from, limit = 128) {
|
|
1426
|
-
const entries = [];
|
|
1427
|
-
const seen = /* @__PURE__ */ new Set();
|
|
1428
|
-
let next = from;
|
|
1429
|
-
while (next && entries.length < Math.min(256, Math.max(1, limit))) {
|
|
1430
|
-
if (seen.has(next)) throw new Error("Cyclic session ancestry");
|
|
1431
|
-
seen.add(next);
|
|
1432
|
-
const summary = reader.getEntrySummary(next);
|
|
1433
|
-
if (!summary) throw new Error(`Missing history entry: ${next}`);
|
|
1434
|
-
entries.push(summary);
|
|
1435
|
-
next = summary.parentId;
|
|
1436
|
-
}
|
|
1437
|
-
return { entries, next };
|
|
1438
|
-
}
|
|
1439
|
-
function getSessionEntryText(entry) {
|
|
1440
|
-
if (entry.type === "compaction") return entry.compactionData?.summary ?? "";
|
|
1441
|
-
if (entry.type !== "message" || !entry.message) return "";
|
|
1442
|
-
const message = entry.message;
|
|
1443
|
-
if (typeof message.content === "string") return message.content;
|
|
1444
|
-
return message.content.map((block) => {
|
|
1445
|
-
if (block.type === "text") return block.text;
|
|
1446
|
-
if (block.type === "toolCall") return `${block.name} ${JSON.stringify(block.arguments)}`;
|
|
1447
|
-
return "";
|
|
1448
|
-
}).filter(Boolean).join("\n");
|
|
1449
|
-
}
|
|
1450
|
-
|
|
1451
|
-
// ../../packages/agent-framework/src/session/host-envelope.ts
|
|
1452
|
-
import { createHash } from "node:crypto";
|
|
1453
|
-
function createHostEnvelopeProjectorRegistry(projectors = []) {
|
|
1454
|
-
const byKey = /* @__PURE__ */ new Map();
|
|
1455
|
-
const latestByKind = /* @__PURE__ */ new Map();
|
|
1456
|
-
const key = (kind, version) => `${kind}@${version}`;
|
|
1457
|
-
for (const projector of projectors) validateAndIndex(projector);
|
|
1458
|
-
function validateAndIndex(input) {
|
|
1459
|
-
if (!input.kind || typeof input.kind !== "string") throw new Error("Host envelope projector requires a kind.");
|
|
1460
|
-
if (!Number.isInteger(input.version) || input.version < 1) throw new Error(`Host envelope projector ${input.kind} requires an integer version >= 1.`);
|
|
1461
|
-
if (typeof input.project !== "function") throw new Error(`Host envelope projector ${input.kind} requires a project function.`);
|
|
1462
|
-
const projector = Object.freeze({
|
|
1463
|
-
kind: input.kind,
|
|
1464
|
-
version: input.version,
|
|
1465
|
-
project: input.project
|
|
1466
|
-
});
|
|
1467
|
-
const existing = byKey.get(key(projector.kind, projector.version));
|
|
1468
|
-
if (existing && existing.project !== projector.project) {
|
|
1469
|
-
throw new Error(`Duplicate host envelope projector registration for ${projector.kind}@${projector.version}: a version's text must never change after registration.`);
|
|
1470
|
-
}
|
|
1471
|
-
byKey.set(key(projector.kind, projector.version), projector);
|
|
1472
|
-
const currentLatest = latestByKind.get(projector.kind);
|
|
1473
|
-
if (!currentLatest || projector.version > currentLatest.version) latestByKind.set(projector.kind, projector);
|
|
1474
|
-
}
|
|
1475
|
-
return {
|
|
1476
|
-
register: validateAndIndex,
|
|
1477
|
-
resolve: (kind, version) => byKey.get(key(kind, version)),
|
|
1478
|
-
latest: (kind) => latestByKind.get(kind),
|
|
1479
|
-
listPins: () => [...byKey.values()].map(({ kind, version }) => ({ kind, version }))
|
|
1480
|
-
};
|
|
1481
|
-
}
|
|
1482
|
-
function projectHostContextBlock(block, registry) {
|
|
1483
|
-
let hash;
|
|
1484
|
-
try {
|
|
1485
|
-
hash = createHash("sha256").update(JSON.stringify({ kind: block.kind, version: block.version, data: block.data })).digest("hex").slice(0, 16);
|
|
1486
|
-
} catch {
|
|
1487
|
-
hash = "unhashable";
|
|
1488
|
-
}
|
|
1489
|
-
const projector = registry.resolve(block.kind, block.version);
|
|
1490
|
-
if (!projector) {
|
|
1491
|
-
return {
|
|
1492
|
-
text: `runtime state: unknown (projector missing: ${block.kind}@${block.version})`,
|
|
1493
|
-
degraded: true,
|
|
1494
|
-
audit: { kind: block.kind, version: block.version, hash }
|
|
1495
|
-
};
|
|
1496
|
-
}
|
|
1497
|
-
try {
|
|
1498
|
-
const text = projector.project(block.data);
|
|
1499
|
-
if (typeof text !== "string" || text.trim().length === 0) throw new Error("projector returned empty text");
|
|
1500
|
-
return { text, degraded: false, audit: { kind: block.kind, version: block.version, hash } };
|
|
1501
|
-
} catch (error) {
|
|
1502
|
-
return {
|
|
1503
|
-
text: `runtime state: unknown (projector failed: ${block.kind}@${block.version}: ${error instanceof Error ? error.message.slice(0, 120) : String(error).slice(0, 120)})`,
|
|
1504
|
-
degraded: true,
|
|
1505
|
-
audit: { kind: block.kind, version: block.version, hash }
|
|
1506
|
-
};
|
|
1507
|
-
}
|
|
1508
|
-
}
|
|
1509
|
-
function leadingHostContextBlock(message) {
|
|
1510
|
-
if (message.role !== "user") return void 0;
|
|
1511
|
-
const content = message.content;
|
|
1512
|
-
if (!Array.isArray(content) || content.length === 0) return void 0;
|
|
1513
|
-
const first = content[0];
|
|
1514
|
-
if (!isHostContextBlock(first)) return void 0;
|
|
1515
|
-
return first;
|
|
1516
|
-
}
|
|
1517
|
-
function projectionSeparator(projectionText) {
|
|
1518
|
-
return projectionText.endsWith("\n") && !projectionText.endsWith("\n\n") ? "" : "\n\n";
|
|
1519
|
-
}
|
|
1520
|
-
function projectHostEnvelopes(messages, registry, onProjection) {
|
|
1521
|
-
let changed = false;
|
|
1522
|
-
const next = [];
|
|
1523
|
-
for (const message of messages) {
|
|
1524
|
-
if (message.role !== "user") {
|
|
1525
|
-
next.push(message);
|
|
1526
|
-
continue;
|
|
1527
|
-
}
|
|
1528
|
-
const content = message.content;
|
|
1529
|
-
if (!Array.isArray(content)) {
|
|
1530
|
-
next.push(message);
|
|
1531
|
-
continue;
|
|
1532
|
-
}
|
|
1533
|
-
let blockCount = 0;
|
|
1534
|
-
while (blockCount < content.length && isHostContextBlock(content[blockCount])) blockCount += 1;
|
|
1535
|
-
if (blockCount === 0) {
|
|
1536
|
-
next.push(message);
|
|
1537
|
-
continue;
|
|
1538
|
-
}
|
|
1539
|
-
const outcomes = [];
|
|
1540
|
-
for (let i = 0; i < blockCount; i++) {
|
|
1541
|
-
const outcome = projectHostContextBlock(content[i], registry);
|
|
1542
|
-
outcomes.push(outcome);
|
|
1543
|
-
onProjection?.(outcome);
|
|
1544
|
-
}
|
|
1545
|
-
const rest = content.slice(blockCount);
|
|
1546
|
-
let text = outcomes[outcomes.length - 1].text;
|
|
1547
|
-
for (let i = outcomes.length - 2; i >= 0; i--) {
|
|
1548
|
-
text = `${outcomes[i].text}${projectionSeparator(outcomes[i].text)}${text}`;
|
|
1549
|
-
}
|
|
1550
|
-
const separator = projectionSeparator(outcomes[outcomes.length - 1].text);
|
|
1551
|
-
const first = rest[0];
|
|
1552
|
-
let projectedContent;
|
|
1553
|
-
if (first && first.type === "text" && typeof first.text === "string") {
|
|
1554
|
-
const merged = first.text.trim().length > 0 ? `${text}${separator}${first.text}` : text;
|
|
1555
|
-
projectedContent = [{ ...first, text: merged }, ...rest.slice(1)];
|
|
1556
|
-
} else {
|
|
1557
|
-
projectedContent = [{ type: "text", text }, ...rest];
|
|
1558
|
-
}
|
|
1559
|
-
next.push({ ...message, content: projectedContent });
|
|
1560
|
-
changed = true;
|
|
1561
|
-
}
|
|
1562
|
-
return changed ? next : messages;
|
|
1563
|
-
}
|
|
1564
|
-
function isHostContextBlock(value) {
|
|
1565
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
1566
|
-
const block = value;
|
|
1567
|
-
const version = block.version;
|
|
1568
|
-
return block.type === "hostContext" && typeof block.kind === "string" && block.kind.length > 0 && block.kind.length <= 128 && typeof version === "number" && Number.isInteger(version) && version >= 1 && !!block.data && typeof block.data === "object" && !Array.isArray(block.data);
|
|
1569
|
-
}
|
|
1570
|
-
|
|
1571
|
-
// ../../packages/agent-framework/src/session/store.ts
|
|
1572
|
-
import { createRequire } from "node:module";
|
|
1573
|
-
import { fileURLToPath } from "node:url";
|
|
1574
1632
|
|
|
1575
1633
|
// ../../packages/agent-framework/src/session/durable-file.ts
|
|
1576
1634
|
function durableFilePaths(filePath) {
|
|
@@ -7233,9 +7291,10 @@ function convertJsonSchemaToTypeBox(schema) {
|
|
|
7233
7291
|
if (isTypeBoxSchema(schema)) {
|
|
7234
7292
|
return schema;
|
|
7235
7293
|
}
|
|
7236
|
-
const
|
|
7294
|
+
const record = schema;
|
|
7295
|
+
const description = typeof record.description === "string" ? record.description : void 0;
|
|
7237
7296
|
const options = description ? { description } : void 0;
|
|
7238
|
-
switch (
|
|
7297
|
+
switch (record.type) {
|
|
7239
7298
|
case "string":
|
|
7240
7299
|
return Type.String(options);
|
|
7241
7300
|
case "number":
|
|
@@ -7247,10 +7306,12 @@ function convertJsonSchemaToTypeBox(schema) {
|
|
|
7247
7306
|
case "null":
|
|
7248
7307
|
return Type.Null(options);
|
|
7249
7308
|
case "array":
|
|
7250
|
-
return Type.Array(convertJsonSchemaToTypeBox(
|
|
7309
|
+
return Type.Array(convertJsonSchemaToTypeBox(record.items ?? { type: "string" }), options);
|
|
7251
7310
|
case "object": {
|
|
7252
|
-
const properties =
|
|
7253
|
-
const required = new Set(
|
|
7311
|
+
const properties = record.properties && typeof record.properties === "object" ? record.properties : {};
|
|
7312
|
+
const required = new Set(
|
|
7313
|
+
Array.isArray(record.required) ? record.required.filter((entry) => typeof entry === "string") : []
|
|
7314
|
+
);
|
|
7254
7315
|
const converted = {};
|
|
7255
7316
|
for (const [key, value] of Object.entries(properties)) {
|
|
7256
7317
|
const child = convertJsonSchemaToTypeBox(value);
|
|
@@ -7259,7 +7320,7 @@ function convertJsonSchemaToTypeBox(schema) {
|
|
|
7259
7320
|
return Type.Object(converted, options);
|
|
7260
7321
|
}
|
|
7261
7322
|
default:
|
|
7262
|
-
throw new Error(`Unsupported JSON schema type for extension tool: ${String(
|
|
7323
|
+
throw new Error(`Unsupported JSON schema type for extension tool: ${String(record.type ?? "unknown")}`);
|
|
7263
7324
|
}
|
|
7264
7325
|
}
|
|
7265
7326
|
function extensionLog(context, message) {
|
|
@@ -9573,8 +9634,19 @@ export {
|
|
|
9573
9634
|
createSkillLoader,
|
|
9574
9635
|
SkillRegistry,
|
|
9575
9636
|
createSkillRegistry,
|
|
9576
|
-
COMPACT_PROMPT,
|
|
9577
9637
|
SUMMARY_PREFIX,
|
|
9638
|
+
formatCompactSummaryText,
|
|
9639
|
+
generateEntryId,
|
|
9640
|
+
parseEntryIdSeq,
|
|
9641
|
+
flattenTreeToMessages,
|
|
9642
|
+
readAncestryPage,
|
|
9643
|
+
getSessionEntryText,
|
|
9644
|
+
createHostEnvelopeProjectorRegistry,
|
|
9645
|
+
projectHostContextBlock,
|
|
9646
|
+
leadingHostContextBlock,
|
|
9647
|
+
projectHostEnvelopes,
|
|
9648
|
+
isHostContextBlock,
|
|
9649
|
+
COMPACT_PROMPT,
|
|
9578
9650
|
DEFAULT_COMPACTION_CONFIG,
|
|
9579
9651
|
estimateTokens,
|
|
9580
9652
|
calculateTotalTokens,
|
|
@@ -9584,7 +9656,6 @@ export {
|
|
|
9584
9656
|
getAutoCompactTokenLimit,
|
|
9585
9657
|
shouldCompact,
|
|
9586
9658
|
isCompactSummaryMessage,
|
|
9587
|
-
formatCompactSummaryText,
|
|
9588
9659
|
collectRealUserMessages,
|
|
9589
9660
|
buildCompactedHistory,
|
|
9590
9661
|
findFirstKeptUserEntryId,
|
|
@@ -9604,16 +9675,6 @@ export {
|
|
|
9604
9675
|
compactMessages,
|
|
9605
9676
|
autoCompact,
|
|
9606
9677
|
createCompactionEntry,
|
|
9607
|
-
generateEntryId,
|
|
9608
|
-
parseEntryIdSeq,
|
|
9609
|
-
flattenTreeToMessages,
|
|
9610
|
-
readAncestryPage,
|
|
9611
|
-
getSessionEntryText,
|
|
9612
|
-
createHostEnvelopeProjectorRegistry,
|
|
9613
|
-
projectHostContextBlock,
|
|
9614
|
-
leadingHostContextBlock,
|
|
9615
|
-
projectHostEnvelopes,
|
|
9616
|
-
isHostContextBlock,
|
|
9617
9678
|
getDefaultSessionsDir,
|
|
9618
9679
|
entryPreview,
|
|
9619
9680
|
FileSessionStore,
|