llmz 0.0.8 → 0.0.10

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.
Files changed (92) hide show
  1. package/package.json +3 -3
  2. package/dist/chat.d.ts +0 -17
  3. package/dist/chunk-276Q6EWP.cjs +0 -224
  4. package/dist/chunk-4L6D2A6O.cjs +0 -283
  5. package/dist/chunk-4MNIJGK6.js +0 -224
  6. package/dist/chunk-7WRN4E42.js +0 -3087
  7. package/dist/chunk-BEPRLBPK.cjs +0 -3123
  8. package/dist/chunk-C6WNNTEV.cjs +0 -212
  9. package/dist/chunk-D3ESDRLH.js +0 -3123
  10. package/dist/chunk-GGWM6X2K.js +0 -184
  11. package/dist/chunk-GWFYZDUR.cjs +0 -105
  12. package/dist/chunk-HJKOSEH2.cjs +0 -722
  13. package/dist/chunk-IH2WQFO5.js +0 -283
  14. package/dist/chunk-IKSIOIIP.cjs +0 -28
  15. package/dist/chunk-JAGB2AOU.js +0 -212
  16. package/dist/chunk-JDABP4SD.cjs +0 -161
  17. package/dist/chunk-JGVAZO4X.cjs +0 -152
  18. package/dist/chunk-JKVVQN2P.js +0 -161
  19. package/dist/chunk-JMSZKB4T.js +0 -105
  20. package/dist/chunk-JQBT7UWN.js +0 -28
  21. package/dist/chunk-KH6JQYQA.js +0 -796
  22. package/dist/chunk-KMZDFWYZ.cjs +0 -33
  23. package/dist/chunk-ORQP26SZ.js +0 -33
  24. package/dist/chunk-PRVFVXT4.js +0 -722
  25. package/dist/chunk-SHJDRZF5.cjs +0 -796
  26. package/dist/chunk-SNDVQU5A.js +0 -152
  27. package/dist/chunk-UQOBUJIQ.cjs +0 -3087
  28. package/dist/chunk-ZRCU35UV.cjs +0 -184
  29. package/dist/citations.d.ts +0 -63
  30. package/dist/compiler/compiler.d.ts +0 -28
  31. package/dist/compiler/index.d.ts +0 -2
  32. package/dist/compiler/plugins/async-iterator.d.ts +0 -4
  33. package/dist/compiler/plugins/braces-tsx.d.ts +0 -3
  34. package/dist/compiler/plugins/jsx-preserve-newlines.d.ts +0 -5
  35. package/dist/compiler/plugins/line-tracking.d.ts +0 -5
  36. package/dist/compiler/plugins/replace-comment.d.ts +0 -5
  37. package/dist/compiler/plugins/return-async.d.ts +0 -4
  38. package/dist/compiler/plugins/track-tool-calls.d.ts +0 -16
  39. package/dist/compiler/plugins/variable-extraction.d.ts +0 -5
  40. package/dist/component-R4WTW6DZ.cjs +0 -18
  41. package/dist/component-WFVDVSDK.js +0 -18
  42. package/dist/component.d.ts +0 -66
  43. package/dist/component.default.d.ts +0 -316
  44. package/dist/context.d.ts +0 -176
  45. package/dist/dual-modes-T53P72CH.js +0 -12
  46. package/dist/dual-modes-VLIGPIHX.cjs +0 -12
  47. package/dist/errors.d.ts +0 -64
  48. package/dist/exit-TRXEU4OU.cjs +0 -8
  49. package/dist/exit-YORW76T3.js +0 -8
  50. package/dist/exit.d.ts +0 -26
  51. package/dist/formatting.d.ts +0 -5
  52. package/dist/getter.d.ts +0 -2
  53. package/dist/handlers.d.ts +0 -10
  54. package/dist/hoist.d.ts +0 -2
  55. package/dist/index.cjs +0 -921
  56. package/dist/index.d.ts +0 -23
  57. package/dist/index.js +0 -921
  58. package/dist/inspect.d.ts +0 -6
  59. package/dist/jsx-AEHVFB3L.js +0 -13
  60. package/dist/jsx-AJAXBWFE.cjs +0 -13
  61. package/dist/jsx.d.ts +0 -11
  62. package/dist/llmz-QLZBDG2Z.cjs +0 -576
  63. package/dist/llmz-ROOX7RYI.js +0 -576
  64. package/dist/llmz.d.ts +0 -40
  65. package/dist/objects.d.ts +0 -24
  66. package/dist/prompts/chat-mode/system.md.d.ts +0 -2
  67. package/dist/prompts/chat-mode/user.md.d.ts +0 -2
  68. package/dist/prompts/common.d.ts +0 -6
  69. package/dist/prompts/dual-modes.d.ts +0 -2
  70. package/dist/prompts/prompt.d.ts +0 -55
  71. package/dist/prompts/worker-mode/system.md.d.ts +0 -2
  72. package/dist/prompts/worker-mode/user.md.d.ts +0 -2
  73. package/dist/result.d.ts +0 -33
  74. package/dist/snapshots.d.ts +0 -69
  75. package/dist/stack-traces.d.ts +0 -1
  76. package/dist/tool-N6ODRRGH.js +0 -11
  77. package/dist/tool-QP4MVRWI.cjs +0 -11
  78. package/dist/tool.d.ts +0 -56
  79. package/dist/transcript.d.ts +0 -36
  80. package/dist/truncator-DUMWEGQO.cjs +0 -10
  81. package/dist/truncator-IY2MXOMC.js +0 -10
  82. package/dist/truncator.d.ts +0 -20
  83. package/dist/types.d.ts +0 -105
  84. package/dist/typings-2CPHOFDN.cjs +0 -10
  85. package/dist/typings-GDMY6VY2.js +0 -10
  86. package/dist/typings.d.ts +0 -5
  87. package/dist/utils-A7WNEFTA.cjs +0 -39
  88. package/dist/utils-N24IHDFA.js +0 -39
  89. package/dist/utils.d.ts +0 -23
  90. package/dist/vm-2DLG7V4G.cjs +0 -12
  91. package/dist/vm-FLBMZUA2.js +0 -12
  92. package/dist/vm.d.ts +0 -3
@@ -1,152 +0,0 @@
1
- import {
2
- getTokenizer
3
- } from "./chunk-4MNIJGK6.js";
4
-
5
- // src/truncator.ts
6
- var DEFAULT_REMOVE_CHUNK = 250;
7
- var WRAP_OPEN_TAG_1 = "\u3010TRUNCATE";
8
- var WRAP_OPEN_TAG_2 = "\u3011";
9
- var WRAP_CLOSE_TAG = "\u3010/TRUNCATE\u3011";
10
- var getRegex = () => new RegExp(`(${WRAP_OPEN_TAG_1}(?:\\s+[\\w:]+)*\\s*${WRAP_OPEN_TAG_2})([\\s\\S]*?)(${WRAP_CLOSE_TAG})`, "g");
11
- var DEFAULT_TRUNCATE_OPTIONS = {
12
- preserve: "top",
13
- flex: 1,
14
- minTokens: 0
15
- };
16
- function wrapContent(content, options) {
17
- const preserve = (options == null ? void 0 : options.preserve) ?? DEFAULT_TRUNCATE_OPTIONS.preserve;
18
- const flex = (options == null ? void 0 : options.flex) ?? DEFAULT_TRUNCATE_OPTIONS.flex;
19
- const minTokens = (options == null ? void 0 : options.minTokens) ?? DEFAULT_TRUNCATE_OPTIONS.minTokens;
20
- return `${WRAP_OPEN_TAG_1} preserve:${preserve} flex:${flex} min:${minTokens} ${WRAP_OPEN_TAG_2}${content}${WRAP_CLOSE_TAG}`;
21
- }
22
- function truncateWrappedContent({
23
- messages,
24
- tokenLimit,
25
- throwOnFailure = true
26
- }) {
27
- var _a, _b, _c;
28
- const tokenizer = getTokenizer();
29
- const parts = [];
30
- for (const msg of messages) {
31
- const current = [];
32
- const content = typeof msg.content === "string" ? msg.content : "";
33
- let match;
34
- const regex = getRegex();
35
- let lastIndex = 0;
36
- while ((match = regex.exec(content)) !== null) {
37
- const attributes = match[1].split(/\s+/).slice(1).filter((x) => x !== WRAP_OPEN_TAG_2).map((x) => x.split(":")).reduce((acc, [key, value]) => ({ ...acc, [key]: value }), {});
38
- if (match.index > lastIndex) {
39
- const nonTruncatableContent = content.slice(lastIndex, match.index);
40
- current.push({
41
- content: nonTruncatableContent,
42
- tokens: tokenizer.count(nonTruncatableContent),
43
- truncatable: false
44
- });
45
- }
46
- const wrappedContent = match[2];
47
- current.push({
48
- content: wrappedContent,
49
- tokens: tokenizer.count(wrappedContent),
50
- truncatable: true,
51
- attributes: {
52
- preserve: attributes.preserve,
53
- flex: Number(attributes.flex) || DEFAULT_TRUNCATE_OPTIONS.flex,
54
- minTokens: Number(attributes.min) || DEFAULT_TRUNCATE_OPTIONS.minTokens
55
- }
56
- });
57
- lastIndex = regex.lastIndex;
58
- }
59
- if (lastIndex < content.length) {
60
- const remainingContent = content.slice(lastIndex);
61
- current.push({
62
- content: remainingContent,
63
- tokens: tokenizer.count(remainingContent),
64
- truncatable: false
65
- });
66
- }
67
- parts.push(current);
68
- }
69
- const getCount = () => parts.reduce((acc, x) => acc + x.reduce((acc2, y) => acc2 + y.tokens, 0), 0);
70
- const getTwoBiggestTruncatables = () => {
71
- var _a2, _b2;
72
- let biggest = null;
73
- let secondBiggest = null;
74
- for (const part of parts.flat()) {
75
- if (part.truncatable) {
76
- const flex = ((_a2 = part.attributes) == null ? void 0 : _a2.flex) ?? DEFAULT_TRUNCATE_OPTIONS.flex;
77
- const tokens = part.tokens * flex;
78
- if (part.tokens <= (((_b2 = part.attributes) == null ? void 0 : _b2.minTokens) ?? 0)) {
79
- continue;
80
- }
81
- if (!biggest || tokens > biggest.tokens) {
82
- secondBiggest = biggest;
83
- biggest = part;
84
- } else if (!secondBiggest || tokens > secondBiggest.tokens) {
85
- secondBiggest = part;
86
- }
87
- }
88
- }
89
- return { biggest, secondBiggest };
90
- };
91
- let currentCount = getCount();
92
- while (currentCount > tokenLimit) {
93
- const { biggest, secondBiggest } = getTwoBiggestTruncatables();
94
- if (!biggest || !biggest.truncatable || biggest.tokens <= 0) {
95
- if (throwOnFailure) {
96
- throw new Error(`Cannot truncate further, current count: ${getCount()}`);
97
- } else {
98
- break;
99
- }
100
- }
101
- const delta = Math.max(biggest.tokens - ((secondBiggest == null ? void 0 : secondBiggest.tokens) ?? 0), DEFAULT_REMOVE_CHUNK);
102
- const room = Math.min(delta, biggest.tokens);
103
- let toRemove = Math.min(room, currentCount - tokenLimit);
104
- if (toRemove <= 0) {
105
- if (throwOnFailure) {
106
- throw new Error(`Cannot truncate further, current count: ${getCount()}`);
107
- } else {
108
- break;
109
- }
110
- }
111
- if (biggest.tokens - toRemove < (((_a = biggest.attributes) == null ? void 0 : _a.minTokens) ?? 0)) {
112
- toRemove = biggest.tokens - (((_b = biggest.attributes) == null ? void 0 : _b.minTokens) ?? 0);
113
- }
114
- const preserve = ((_c = biggest.attributes) == null ? void 0 : _c.preserve) ?? DEFAULT_TRUNCATE_OPTIONS.preserve;
115
- const split = tokenizer.split(biggest.content);
116
- if (preserve === "bottom") {
117
- biggest.content = split.slice(toRemove).join("");
118
- } else if (preserve === "top") {
119
- biggest.content = split.slice(0, -toRemove).join("");
120
- } else {
121
- const anchor = Math.ceil(split.length / 2);
122
- const radius = Math.ceil(toRemove / 2);
123
- const left = anchor - radius;
124
- const right = anchor + radius;
125
- biggest.content = split.slice(0, left).join("") + split.slice(right).join("");
126
- }
127
- biggest.tokens -= toRemove;
128
- currentCount -= toRemove;
129
- }
130
- const removeRedundantWrappers = (content) => {
131
- return content.replace(getRegex(), "$2");
132
- };
133
- return messages.map((msg, i) => {
134
- const p = parts[i];
135
- return {
136
- ...msg,
137
- content: typeof msg.content === "string" ? removeRedundantWrappers(
138
- p.map((part) => {
139
- if (part.truncatable) {
140
- return part.content;
141
- }
142
- return part.content;
143
- }).join("")
144
- ) : msg.content
145
- };
146
- });
147
- }
148
-
149
- export {
150
- wrapContent,
151
- truncateWrappedContent
152
- };