@datalayer/agent-runtimes 1.5.25 → 1.5.27
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-embed/datalayer-app-main.js +89 -89
- package/lib/chat/base/ChatBase.js +375 -437
- package/lib/chat/base/conversationItems.d.ts +55 -0
- package/lib/chat/base/conversationItems.js +126 -0
- package/lib/portable/adapterEvents.d.ts +107 -0
- package/lib/portable/adapterEvents.js +239 -0
- package/lib/portable/approvalCard.d.ts +56 -0
- package/lib/portable/approvalCard.js +56 -0
- package/lib/portable/conversation.d.ts +71 -18
- package/lib/portable/conversation.js +330 -74
- package/lib/portable/fixtures.js +12 -0
- package/lib/portable/index.d.ts +6 -1
- package/lib/portable/index.js +11 -1
- package/lib/portable/presence.js +4 -1
- package/lib/portable/protectedInput.d.ts +93 -0
- package/lib/portable/protectedInput.js +186 -0
- package/lib/portable/runMeasures.d.ts +46 -0
- package/lib/portable/runMeasures.js +156 -0
- package/lib/portable/signInStatus.d.ts +37 -0
- package/lib/portable/signInStatus.js +74 -0
- package/lib/protocols/ACPAdapter.js +13 -8
- package/lib/utils/utils.d.ts +2 -8
- package/lib/utils/utils.js +3 -26
- package/package.json +1 -1
package/lib/utils/utils.js
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* @module chat/utils
|
|
9
9
|
*/
|
|
10
10
|
import { QueryClient } from '@tanstack/react-query';
|
|
11
|
+
import { sanitizeAssistantContent } from '../portable/adapterEvents';
|
|
11
12
|
import { AGUIAdapter, A2AAdapter, VercelAIAdapter, ACPAdapter, BrowserAgentAdapter, } from '../protocols';
|
|
12
13
|
// ---------------------------------------------------------------------------
|
|
13
14
|
// Constants
|
|
@@ -32,32 +33,8 @@ export const PRIMER_PORTAL_ROOT_ID = '__primerPortalRoot__';
|
|
|
32
33
|
export function isToolCallMessage(item) {
|
|
33
34
|
return 'type' in item && item.type === 'tool-call';
|
|
34
35
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
*
|
|
38
|
-
* Some models occasionally leak internal call formats (for example,
|
|
39
|
-
* <calls>...</calls> or <tml:invoke ...>) into natural-language responses.
|
|
40
|
-
* Keep user/system text untouched and sanitize assistant-visible text only.
|
|
41
|
-
*/
|
|
42
|
-
export function sanitizeAssistantContent(content) {
|
|
43
|
-
if (!content || !content.includes('<')) {
|
|
44
|
-
return content;
|
|
45
|
-
}
|
|
46
|
-
let sanitized = content;
|
|
47
|
-
// Remove complete blocks first.
|
|
48
|
-
sanitized = sanitized
|
|
49
|
-
.replace(/<\s*calls\b[\s\S]*?<\s*\/\s*calls\s*>/gi, '')
|
|
50
|
-
.replace(/<\s*(?:an:)?tml:invoke\b[\s\S]*?<\s*\/\s*(?:an:)?tml:invoke\s*>/gi, '')
|
|
51
|
-
.replace(/<\s*(?:an:)?tml:parameter\b[\s\S]*?<\s*\/\s*(?:an:)?tml:parameter\s*>/gi, '');
|
|
52
|
-
// Remove standalone/open/close tags and malformed tag fragments.
|
|
53
|
-
sanitized = sanitized
|
|
54
|
-
.replace(/<\s*\/?\s*(?:an:[a-z_]+|tml:[a-z_]+|calls)\b[^>]*>?/gi, '')
|
|
55
|
-
.replace(/<\s*\/\s*>/g, '')
|
|
56
|
-
.replace(/^[ \t]+$/gm, '')
|
|
57
|
-
.replace(/\n{3,}/g, '\n\n')
|
|
58
|
-
.trim();
|
|
59
|
-
return sanitized;
|
|
60
|
-
}
|
|
36
|
+
// What a model leaked of its call markup, taken out: one rule for every client.
|
|
37
|
+
export { sanitizeAssistantContent };
|
|
61
38
|
/**
|
|
62
39
|
* Extract text content from a ChatMessage
|
|
63
40
|
*/
|