@openagentpack/sdk 0.3.0 → 0.3.1

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.
@@ -118,13 +118,19 @@ function isSensitiveQueryKey(key) {
118
118
  // src/internal/core/session-event-sanitizer.ts
119
119
  var DEFAULT_TEXT_LIMIT = 4e3;
120
120
  var TOOL_TEXT_LIMIT = 8e3;
121
+ var DOCUMENT_TEXT_LIMIT = 32e3;
122
+ function hasDocumentContent(text) {
123
+ if (/```(?:html|htm|svg|mermaid)\s*\n/i.test(text)) return true;
124
+ if (/<(?:!DOCTYPE\s+)?html[\s>]/i.test(text)) return true;
125
+ return false;
126
+ }
121
127
  function sanitizeSessionEvents(events, options = {}) {
122
128
  return events.map((event) => sanitizeSessionEvent(event, options));
123
129
  }
124
130
  function sanitizeSessionEvent(event, options = {}) {
125
131
  const isToolEvent = event.type === "tool_result" || event.type === "tool_use";
126
- const textLimit = isToolEvent ? TOOL_TEXT_LIMIT : DEFAULT_TEXT_LIMIT;
127
132
  const primarySource = event.content ?? (event.type === "tool_use" ? event.tool_input : void 0);
133
+ const textLimit = isToolEvent ? TOOL_TEXT_LIMIT : typeof primarySource === "string" && hasDocumentContent(primarySource) ? DOCUMENT_TEXT_LIMIT : DEFAULT_TEXT_LIMIT;
128
134
  const primary = sanitizeOptionalText(primarySource, textLimit);
129
135
  const raw = options.includeRaw ? sanitizeUnknown(event.raw, TOOL_TEXT_LIMIT * 2) : void 0;
130
136
  const redacted = Boolean(primary?.redacted || raw?.redacted);
@@ -173,12 +179,22 @@ function sanitizeUnknown(value, limit) {
173
179
  }
174
180
  function sanitizeText(value, limit) {
175
181
  const redacted = redactSensitiveText(value);
176
- const truncated = redacted.length > limit;
182
+ if (redacted.length <= limit) {
183
+ return { value: redacted, redacted: redacted !== value, truncated: false };
184
+ }
185
+ let cut = limit;
186
+ if (/<[a-z][\s\S]*>/i.test(redacted)) {
187
+ const lastLt = redacted.lastIndexOf("<", cut);
188
+ const lastGt = redacted.lastIndexOf(">", cut);
189
+ if (lastLt > lastGt) {
190
+ cut = lastLt;
191
+ }
192
+ }
177
193
  return {
178
- value: truncated ? `${redacted.slice(0, limit)}
179
- ...[truncated ${redacted.length - limit} chars]` : redacted,
194
+ value: `${redacted.slice(0, cut)}
195
+ ...[truncated ${redacted.length - cut} chars]`,
180
196
  redacted: redacted !== value,
181
- truncated
197
+ truncated: true
182
198
  };
183
199
  }
184
200
  function safeStringify(value) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openagentpack/sdk",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "OpenAgentPack SDK (Node-compatible runtime)",
5
5
  "license": "Apache-2.0",
6
6
  "keywords": [
@@ -20,7 +20,7 @@
20
20
  "url": "https://github.com/modelstudioai/OpenAgentPack/issues"
21
21
  },
22
22
  "engines": {
23
- "node": ">=22"
23
+ "node": ">=18.17.0"
24
24
  },
25
25
  "type": "module",
26
26
  "main": "./dist/index.js",