@deepagents/context 0.27.0 → 0.28.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/dist/browser.js +57 -44
- package/dist/browser.js.map +3 -3
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2881 -2731
- package/dist/index.js.map +4 -4
- package/dist/lib/agent.d.ts +1 -0
- package/dist/lib/agent.d.ts.map +1 -1
- package/dist/lib/chat.d.ts +3 -0
- package/dist/lib/chat.d.ts.map +1 -1
- package/dist/lib/codec/serialized-fragments.d.ts +1 -1
- package/dist/lib/codec/serialized-fragments.d.ts.map +1 -1
- package/dist/lib/engine.d.ts +7 -0
- package/dist/lib/engine.d.ts.map +1 -1
- package/dist/lib/fragments/message/user.d.ts +27 -4
- package/dist/lib/fragments/message/user.d.ts.map +1 -1
- package/dist/lib/skills/classifier.d.ts.map +1 -1
- package/dist/lib/title.d.ts +10 -0
- package/dist/lib/title.d.ts.map +1 -0
- package/package.json +4 -3
package/dist/browser.js
CHANGED
|
@@ -581,44 +581,38 @@ function toFragmentData(value, options) {
|
|
|
581
581
|
}
|
|
582
582
|
var builtInSerializedRegistry = {
|
|
583
583
|
term: {
|
|
584
|
-
toFragment: (input) => term(input.name, input.definition)
|
|
585
|
-
fromFragment: () => void 0
|
|
584
|
+
toFragment: (input) => term(input.name, input.definition)
|
|
586
585
|
},
|
|
587
586
|
hint: {
|
|
588
|
-
toFragment: (input) => hint(input.text)
|
|
589
|
-
fromFragment: () => void 0
|
|
587
|
+
toFragment: (input) => hint(input.text)
|
|
590
588
|
},
|
|
591
589
|
guardrail: {
|
|
592
590
|
toFragment: (input) => guardrail({
|
|
593
591
|
rule: input.rule,
|
|
594
592
|
reason: input.reason,
|
|
595
593
|
action: input.action
|
|
596
|
-
})
|
|
597
|
-
fromFragment: () => void 0
|
|
594
|
+
})
|
|
598
595
|
},
|
|
599
596
|
explain: {
|
|
600
597
|
toFragment: (input) => explain({
|
|
601
598
|
concept: input.concept,
|
|
602
599
|
explanation: input.explanation,
|
|
603
600
|
therefore: input.therefore
|
|
604
|
-
})
|
|
605
|
-
fromFragment: () => void 0
|
|
601
|
+
})
|
|
606
602
|
},
|
|
607
603
|
example: {
|
|
608
604
|
toFragment: (input) => example({
|
|
609
605
|
question: input.question,
|
|
610
606
|
answer: input.answer,
|
|
611
607
|
note: input.note
|
|
612
|
-
})
|
|
613
|
-
fromFragment: () => void 0
|
|
608
|
+
})
|
|
614
609
|
},
|
|
615
610
|
clarification: {
|
|
616
611
|
toFragment: (input) => clarification({
|
|
617
612
|
when: input.when,
|
|
618
613
|
ask: input.ask,
|
|
619
614
|
reason: input.reason
|
|
620
|
-
})
|
|
621
|
-
fromFragment: () => void 0
|
|
615
|
+
})
|
|
622
616
|
},
|
|
623
617
|
workflow: {
|
|
624
618
|
toFragment: (input) => workflow({
|
|
@@ -626,23 +620,20 @@ var builtInSerializedRegistry = {
|
|
|
626
620
|
steps: input.steps,
|
|
627
621
|
triggers: input.triggers,
|
|
628
622
|
notes: input.notes
|
|
629
|
-
})
|
|
630
|
-
fromFragment: () => void 0
|
|
623
|
+
})
|
|
631
624
|
},
|
|
632
625
|
quirk: {
|
|
633
626
|
toFragment: (input) => quirk({
|
|
634
627
|
issue: input.issue,
|
|
635
628
|
workaround: input.workaround
|
|
636
|
-
})
|
|
637
|
-
fromFragment: () => void 0
|
|
629
|
+
})
|
|
638
630
|
},
|
|
639
631
|
styleGuide: {
|
|
640
632
|
toFragment: (input) => styleGuide({
|
|
641
633
|
prefer: input.prefer,
|
|
642
634
|
never: input.never,
|
|
643
635
|
always: input.always
|
|
644
|
-
})
|
|
645
|
-
fromFragment: () => void 0
|
|
636
|
+
})
|
|
646
637
|
},
|
|
647
638
|
analogy: {
|
|
648
639
|
toFragment: (input) => analogy({
|
|
@@ -651,24 +642,20 @@ var builtInSerializedRegistry = {
|
|
|
651
642
|
insight: input.insight,
|
|
652
643
|
therefore: input.therefore,
|
|
653
644
|
pitfall: input.pitfall
|
|
654
|
-
})
|
|
655
|
-
fromFragment: () => void 0
|
|
645
|
+
})
|
|
656
646
|
},
|
|
657
647
|
glossary: {
|
|
658
|
-
toFragment: (input) => glossary(input.entries)
|
|
659
|
-
fromFragment: () => void 0
|
|
648
|
+
toFragment: (input) => glossary(input.entries)
|
|
660
649
|
},
|
|
661
650
|
role: {
|
|
662
|
-
toFragment: (input) => role(input.content)
|
|
663
|
-
fromFragment: () => void 0
|
|
651
|
+
toFragment: (input) => role(input.content)
|
|
664
652
|
},
|
|
665
653
|
principle: {
|
|
666
654
|
toFragment: (input, options) => principle({
|
|
667
655
|
title: input.title,
|
|
668
656
|
description: input.description,
|
|
669
657
|
policies: input.policies?.map((item) => toFragmentData(item, options))
|
|
670
|
-
})
|
|
671
|
-
fromFragment: () => void 0
|
|
658
|
+
})
|
|
672
659
|
},
|
|
673
660
|
policy: {
|
|
674
661
|
toFragment: (input, options) => policy({
|
|
@@ -676,15 +663,13 @@ var builtInSerializedRegistry = {
|
|
|
676
663
|
before: input.before,
|
|
677
664
|
reason: input.reason,
|
|
678
665
|
policies: input.policies?.map((item) => toFragmentData(item, options))
|
|
679
|
-
})
|
|
680
|
-
fromFragment: () => void 0
|
|
666
|
+
})
|
|
681
667
|
},
|
|
682
668
|
identity: {
|
|
683
669
|
toFragment: (input) => identity({
|
|
684
670
|
name: input.name,
|
|
685
671
|
role: input.role
|
|
686
|
-
})
|
|
687
|
-
fromFragment: () => void 0
|
|
672
|
+
})
|
|
688
673
|
},
|
|
689
674
|
persona: {
|
|
690
675
|
toFragment: (input) => persona({
|
|
@@ -692,20 +677,16 @@ var builtInSerializedRegistry = {
|
|
|
692
677
|
role: input.role,
|
|
693
678
|
objective: input.objective,
|
|
694
679
|
tone: input.tone
|
|
695
|
-
})
|
|
696
|
-
fromFragment: () => void 0
|
|
680
|
+
})
|
|
697
681
|
},
|
|
698
682
|
alias: {
|
|
699
|
-
toFragment: (input) => alias(input.term, input.meaning)
|
|
700
|
-
fromFragment: () => void 0
|
|
683
|
+
toFragment: (input) => alias(input.term, input.meaning)
|
|
701
684
|
},
|
|
702
685
|
preference: {
|
|
703
|
-
toFragment: (input) => preference(input.aspect, input.value)
|
|
704
|
-
fromFragment: () => void 0
|
|
686
|
+
toFragment: (input) => preference(input.aspect, input.value)
|
|
705
687
|
},
|
|
706
688
|
correction: {
|
|
707
|
-
toFragment: (input) => correction(input.subject, input.clarification)
|
|
708
|
-
fromFragment: () => void 0
|
|
689
|
+
toFragment: (input) => correction(input.subject, input.clarification)
|
|
709
690
|
}
|
|
710
691
|
};
|
|
711
692
|
var messageLikeTypes = /* @__PURE__ */ new Set(["user", "assistant", "message"]);
|
|
@@ -714,7 +695,7 @@ function findCustomSerializedFragment(fragment2, options) {
|
|
|
714
695
|
return void 0;
|
|
715
696
|
}
|
|
716
697
|
for (const entry of Object.values(options.registry)) {
|
|
717
|
-
const serialized = entry.fromFragment(fragment2, options);
|
|
698
|
+
const serialized = entry.fromFragment?.(fragment2, options);
|
|
718
699
|
if (serialized !== void 0) {
|
|
719
700
|
return serialized;
|
|
720
701
|
}
|
|
@@ -1054,26 +1035,51 @@ function applyPartReminder(message2, value) {
|
|
|
1054
1035
|
mode: "part"
|
|
1055
1036
|
};
|
|
1056
1037
|
}
|
|
1038
|
+
function hasSchedule(reminder2) {
|
|
1039
|
+
return reminder2.everyNTurns !== void 0 || reminder2.once !== void 0 || reminder2.firstN !== void 0 || reminder2.afterTurn !== void 0 || reminder2.when !== void 0;
|
|
1040
|
+
}
|
|
1041
|
+
function shouldIncludeReminder(reminder2, turn) {
|
|
1042
|
+
if (reminder2.once && turn !== 1) return false;
|
|
1043
|
+
if (reminder2.firstN !== void 0 && turn > reminder2.firstN) return false;
|
|
1044
|
+
if (reminder2.afterTurn !== void 0 && turn <= reminder2.afterTurn)
|
|
1045
|
+
return false;
|
|
1046
|
+
if (reminder2.everyNTurns !== void 0 && turn % reminder2.everyNTurns !== 0)
|
|
1047
|
+
return false;
|
|
1048
|
+
if (reminder2.when && !reminder2.when(turn)) return false;
|
|
1049
|
+
return true;
|
|
1050
|
+
}
|
|
1057
1051
|
function reminder(text, options) {
|
|
1058
1052
|
if (typeof text === "string") {
|
|
1059
1053
|
assertReminderText(text);
|
|
1060
1054
|
}
|
|
1061
1055
|
return {
|
|
1062
1056
|
text,
|
|
1063
|
-
asPart: options?.asPart ?? false
|
|
1057
|
+
asPart: options?.asPart ?? false,
|
|
1058
|
+
...options?.everyNTurns !== void 0 && {
|
|
1059
|
+
everyNTurns: options.everyNTurns
|
|
1060
|
+
},
|
|
1061
|
+
...options?.once !== void 0 && { once: options.once },
|
|
1062
|
+
...options?.firstN !== void 0 && { firstN: options.firstN },
|
|
1063
|
+
...options?.afterTurn !== void 0 && { afterTurn: options.afterTurn },
|
|
1064
|
+
...options?.when !== void 0 && { when: options.when }
|
|
1064
1065
|
};
|
|
1065
1066
|
}
|
|
1067
|
+
function resolveReminderText(item, ctx) {
|
|
1068
|
+
return typeof item.text === "function" ? item.text(ctx) : item.text;
|
|
1069
|
+
}
|
|
1066
1070
|
function user(content, ...reminders) {
|
|
1067
1071
|
const message2 = typeof content === "string" ? {
|
|
1068
1072
|
id: generateId2(),
|
|
1069
1073
|
role: "user",
|
|
1070
1074
|
parts: [{ type: "text", text: content }]
|
|
1071
1075
|
} : { ...content, role: "user", parts: [...content.parts] };
|
|
1072
|
-
|
|
1076
|
+
const immediateReminders = reminders.filter((r) => !hasSchedule(r));
|
|
1077
|
+
const scheduledReminders = reminders.filter((r) => hasSchedule(r));
|
|
1078
|
+
if (immediateReminders.length > 0) {
|
|
1073
1079
|
const addedReminders = [];
|
|
1074
1080
|
const plainText = extractPlainText(message2);
|
|
1075
|
-
for (const item of
|
|
1076
|
-
const resolvedText =
|
|
1081
|
+
for (const item of immediateReminders) {
|
|
1082
|
+
const resolvedText = resolveReminderText(item, { content: plainText });
|
|
1077
1083
|
if (resolvedText.trim().length === 0) {
|
|
1078
1084
|
continue;
|
|
1079
1085
|
}
|
|
@@ -1088,6 +1094,7 @@ function user(content, ...reminders) {
|
|
|
1088
1094
|
message2.metadata = metadata;
|
|
1089
1095
|
}
|
|
1090
1096
|
}
|
|
1097
|
+
const fragmentMetadata = scheduledReminders.length > 0 ? { scheduledReminders } : void 0;
|
|
1091
1098
|
return {
|
|
1092
1099
|
id: message2.id,
|
|
1093
1100
|
name: "user",
|
|
@@ -1100,7 +1107,8 @@ function user(content, ...reminders) {
|
|
|
1100
1107
|
encode() {
|
|
1101
1108
|
return message2;
|
|
1102
1109
|
}
|
|
1103
|
-
}
|
|
1110
|
+
},
|
|
1111
|
+
metadata: fragmentMetadata
|
|
1104
1112
|
};
|
|
1105
1113
|
}
|
|
1106
1114
|
|
|
@@ -2168,6 +2176,8 @@ export {
|
|
|
2168
2176
|
XmlRenderer,
|
|
2169
2177
|
alias,
|
|
2170
2178
|
analogy,
|
|
2179
|
+
applyInlineReminder,
|
|
2180
|
+
applyPartReminder,
|
|
2171
2181
|
assistant,
|
|
2172
2182
|
assistantText,
|
|
2173
2183
|
clarification,
|
|
@@ -2184,6 +2194,7 @@ export {
|
|
|
2184
2194
|
getReminderRanges,
|
|
2185
2195
|
glossary,
|
|
2186
2196
|
guardrail,
|
|
2197
|
+
hasSchedule,
|
|
2187
2198
|
hint,
|
|
2188
2199
|
identity,
|
|
2189
2200
|
isFragment,
|
|
@@ -2201,8 +2212,10 @@ export {
|
|
|
2201
2212
|
quirk,
|
|
2202
2213
|
reminder,
|
|
2203
2214
|
render,
|
|
2215
|
+
resolveReminderText,
|
|
2204
2216
|
role,
|
|
2205
2217
|
runGuardrailChain,
|
|
2218
|
+
shouldIncludeReminder,
|
|
2206
2219
|
soul,
|
|
2207
2220
|
stop,
|
|
2208
2221
|
stripReminders,
|