@livekit/agents 1.0.47 → 1.0.48
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/beta/index.cjs +29 -0
- package/dist/beta/index.cjs.map +1 -0
- package/dist/beta/index.d.cts +2 -0
- package/dist/beta/index.d.ts +2 -0
- package/dist/beta/index.d.ts.map +1 -0
- package/dist/beta/index.js +7 -0
- package/dist/beta/index.js.map +1 -0
- package/dist/beta/workflows/index.cjs +29 -0
- package/dist/beta/workflows/index.cjs.map +1 -0
- package/dist/beta/workflows/index.d.cts +2 -0
- package/dist/beta/workflows/index.d.ts +2 -0
- package/dist/beta/workflows/index.d.ts.map +1 -0
- package/dist/beta/workflows/index.js +7 -0
- package/dist/beta/workflows/index.js.map +1 -0
- package/dist/beta/workflows/task_group.cjs +162 -0
- package/dist/beta/workflows/task_group.cjs.map +1 -0
- package/dist/beta/workflows/task_group.d.cts +32 -0
- package/dist/beta/workflows/task_group.d.ts +32 -0
- package/dist/beta/workflows/task_group.d.ts.map +1 -0
- package/dist/beta/workflows/task_group.js +138 -0
- package/dist/beta/workflows/task_group.js.map +1 -0
- package/dist/index.cjs +3 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/inference/api_protos.d.cts +59 -59
- package/dist/inference/api_protos.d.ts +59 -59
- package/dist/llm/chat_context.cjs +89 -1
- package/dist/llm/chat_context.cjs.map +1 -1
- package/dist/llm/chat_context.d.cts +10 -1
- package/dist/llm/chat_context.d.ts +10 -1
- package/dist/llm/chat_context.d.ts.map +1 -1
- package/dist/llm/chat_context.js +89 -1
- package/dist/llm/chat_context.js.map +1 -1
- package/dist/llm/chat_context.test.cjs +43 -0
- package/dist/llm/chat_context.test.cjs.map +1 -1
- package/dist/llm/chat_context.test.js +43 -0
- package/dist/llm/chat_context.test.js.map +1 -1
- package/dist/llm/index.cjs +2 -0
- package/dist/llm/index.cjs.map +1 -1
- package/dist/llm/index.d.cts +1 -1
- package/dist/llm/index.d.ts +1 -1
- package/dist/llm/index.d.ts.map +1 -1
- package/dist/llm/index.js +3 -1
- package/dist/llm/index.js.map +1 -1
- package/dist/llm/provider_format/index.d.cts +1 -1
- package/dist/llm/provider_format/index.d.ts +1 -1
- package/dist/llm/tool_context.cjs +7 -0
- package/dist/llm/tool_context.cjs.map +1 -1
- package/dist/llm/tool_context.d.cts +10 -2
- package/dist/llm/tool_context.d.ts +10 -2
- package/dist/llm/tool_context.d.ts.map +1 -1
- package/dist/llm/tool_context.js +6 -0
- package/dist/llm/tool_context.js.map +1 -1
- package/dist/utils.cjs +1 -0
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +1 -0
- package/dist/utils.js.map +1 -1
- package/dist/version.cjs +1 -1
- package/dist/version.js +1 -1
- package/dist/voice/agent.cjs +9 -0
- package/dist/voice/agent.cjs.map +1 -1
- package/dist/voice/agent.d.cts +1 -0
- package/dist/voice/agent.d.ts +1 -0
- package/dist/voice/agent.d.ts.map +1 -1
- package/dist/voice/agent.js +9 -0
- package/dist/voice/agent.js.map +1 -1
- package/dist/voice/agent_activity.cjs +31 -8
- package/dist/voice/agent_activity.cjs.map +1 -1
- package/dist/voice/agent_activity.d.cts +7 -0
- package/dist/voice/agent_activity.d.ts +7 -0
- package/dist/voice/agent_activity.d.ts.map +1 -1
- package/dist/voice/agent_activity.js +31 -8
- package/dist/voice/agent_activity.js.map +1 -1
- package/dist/voice/room_io/room_io.cjs +11 -2
- package/dist/voice/room_io/room_io.cjs.map +1 -1
- package/dist/voice/room_io/room_io.d.ts.map +1 -1
- package/dist/voice/room_io/room_io.js +12 -3
- package/dist/voice/room_io/room_io.js.map +1 -1
- package/dist/voice/testing/fake_llm.cjs +127 -0
- package/dist/voice/testing/fake_llm.cjs.map +1 -0
- package/dist/voice/testing/fake_llm.d.cts +30 -0
- package/dist/voice/testing/fake_llm.d.ts +30 -0
- package/dist/voice/testing/fake_llm.d.ts.map +1 -0
- package/dist/voice/testing/fake_llm.js +103 -0
- package/dist/voice/testing/fake_llm.js.map +1 -0
- package/dist/voice/testing/index.cjs +3 -0
- package/dist/voice/testing/index.cjs.map +1 -1
- package/dist/voice/testing/index.d.cts +1 -0
- package/dist/voice/testing/index.d.ts +1 -0
- package/dist/voice/testing/index.d.ts.map +1 -1
- package/dist/voice/testing/index.js +2 -0
- package/dist/voice/testing/index.js.map +1 -1
- package/package.json +1 -1
- package/src/beta/index.ts +9 -0
- package/src/beta/workflows/index.ts +9 -0
- package/src/beta/workflows/task_group.ts +194 -0
- package/src/index.ts +2 -1
- package/src/llm/chat_context.test.ts +48 -0
- package/src/llm/chat_context.ts +123 -0
- package/src/llm/index.ts +1 -0
- package/src/llm/tool_context.ts +14 -0
- package/src/utils.ts +5 -0
- package/src/voice/agent.ts +11 -0
- package/src/voice/agent_activity.ts +44 -6
- package/src/voice/room_io/room_io.ts +14 -3
- package/src/voice/testing/fake_llm.ts +138 -0
- package/src/voice/testing/index.ts +2 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/llm/chat_context.test.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2025 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport { describe, expect, it } from 'vitest';\nimport {\n type AudioContent,\n ChatContext,\n type ChatItem,\n ChatMessage,\n FunctionCall,\n FunctionCallOutput,\n type ImageContent,\n ReadonlyChatContext,\n} from './chat_context.js';\n\ndescribe('ChatContext.toJSON', () => {\n it('should match snapshot for empty context', () => {\n const context = new ChatContext();\n expect(context.toJSON()).toMatchSnapshot();\n });\n\n it('should match snapshot for simple conversation', () => {\n const context = new ChatContext();\n\n context.addMessage({\n id: 'msg_system_1',\n role: 'system',\n content: 'You are a helpful assistant.',\n createdAt: 1000000000,\n });\n\n context.addMessage({\n id: 'msg_user_1',\n role: 'user',\n content: 'Hello, how are you?',\n createdAt: 1000000001,\n });\n\n context.addMessage({\n id: 'msg_assistant_1',\n role: 'assistant',\n content: \"I'm doing well, thank you! How can I help you today?\",\n createdAt: 1000000002,\n });\n\n expect(context.toJSON()).toMatchSnapshot('simple-conversation-no-timestamps');\n\n expect(context.toJSON({ excludeTimestamp: false })).toMatchSnapshot(\n 'simple-conversation-with-timestamps',\n );\n });\n\n it('should match snapshot for multimodal content', () => {\n const context = new ChatContext();\n\n const imageContent: ImageContent = {\n id: 'img_test_1',\n type: 'image_content',\n image: 'https://example.com/test-image.jpg',\n inferenceDetail: 'high',\n inferenceWidth: 1024,\n inferenceHeight: 768,\n mimeType: 'image/jpeg',\n _cache: {},\n };\n\n const audioContent: AudioContent = {\n type: 'audio_content',\n frame: [], // This won't be included in JSON\n transcript: 'This is a test audio transcript',\n };\n\n context.addMessage({\n id: 'msg_user_2',\n role: 'user',\n content: [\n 'Check out this image and audio:',\n imageContent,\n audioContent,\n 'What do you think?',\n ],\n createdAt: 2000000000,\n });\n\n expect(context.toJSON()).toMatchSnapshot('multimodal-default-exclusions');\n\n expect(\n context.toJSON({\n excludeImage: false,\n excludeAudio: true,\n }),\n ).toMatchSnapshot('multimodal-with-images-only');\n\n expect(\n context.toJSON({\n excludeImage: true,\n excludeAudio: false,\n }),\n ).toMatchSnapshot('multimodal-with-audio-only');\n\n expect(\n context.toJSON({\n excludeImage: false,\n excludeAudio: false,\n excludeTimestamp: false,\n }),\n ).toMatchSnapshot('multimodal-full-content');\n });\n\n it('should match snapshot for function calls', () => {\n const context = new ChatContext();\n\n context.addMessage({\n id: 'msg_user_3',\n role: 'user',\n content: \"What's the weather in Paris?\",\n createdAt: 3000000000,\n });\n\n const functionCall = new FunctionCall({\n id: 'func_call_1',\n callId: 'call_weather_123',\n name: 'get_weather',\n args: '{\"location\": \"Paris, France\", \"unit\": \"celsius\"}',\n createdAt: 3000000001,\n });\n context.insert(functionCall);\n\n const functionOutput = new FunctionCallOutput({\n id: 'func_output_1',\n callId: 'call_weather_123',\n name: 'get_weather',\n output: '{\"temperature\": 22, \"condition\": \"partly cloudy\", \"humidity\": 65}',\n isError: false,\n createdAt: 3000000002,\n });\n context.insert(functionOutput);\n\n context.addMessage({\n id: 'msg_assistant_2',\n role: 'assistant',\n content: 'The weather in Paris is currently 22°C and partly cloudy with 65% humidity.',\n createdAt: 3000000003,\n });\n\n expect(context.toJSON()).toMatchSnapshot('conversation-with-function-calls');\n\n expect(\n context.toJSON({\n excludeFunctionCall: true,\n }),\n ).toMatchSnapshot('conversation-without-function-calls');\n\n expect(\n context.toJSON({\n excludeTimestamp: false,\n }),\n ).toMatchSnapshot('conversation-with-function-calls-and-timestamps');\n });\n\n it('should match snapshot for edge cases', () => {\n const context = new ChatContext();\n\n context.addMessage({\n id: 'msg_empty_1',\n role: 'user',\n content: [],\n createdAt: 5000000000,\n });\n\n const silentAudio: AudioContent = {\n type: 'audio_content',\n frame: [],\n transcript: undefined,\n };\n\n context.addMessage({\n id: 'msg_silent_audio',\n role: 'user',\n content: [silentAudio],\n createdAt: 5000000001,\n });\n\n context.addMessage({\n id: 'msg_multi_text',\n role: 'assistant',\n content: ['Part 1. ', 'Part 2. ', 'Part 3.'],\n createdAt: 5000000002,\n });\n\n const minimalCall = new FunctionCall({\n id: 'func_minimal',\n callId: 'minimal',\n name: 'test',\n args: '{}',\n createdAt: 5000000003,\n });\n context.insert(minimalCall);\n\n const namelessOutput = new FunctionCallOutput({\n id: 'func_output_nameless',\n callId: 'minimal',\n output: 'OK',\n isError: false,\n createdAt: 5000000004,\n });\n context.insert(namelessOutput);\n\n context.addMessage({\n id: 'msg_special_chars',\n role: 'user',\n content:\n 'Test with special chars: \\n\\t\\r \"quotes\" \\'apostrophes\\' \\\\backslashes\\\\ {braces} [brackets]',\n createdAt: 5000000005,\n });\n\n expect(context.toJSON()).toMatchSnapshot('edge-cases-default');\n expect(\n context.toJSON({\n excludeTimestamp: false,\n excludeAudio: false,\n }),\n ).toMatchSnapshot('edge-cases-with-details');\n });\n\n it('should match snapshot for message property variations', () => {\n const context = new ChatContext();\n\n context.addMessage({\n id: 'custom-message-id-123',\n role: 'user',\n content: 'Message with custom ID',\n createdAt: 6000000000,\n });\n\n context.addMessage({\n id: 'msg_interrupted',\n role: 'assistant',\n content: 'This response was interrupted...',\n interrupted: true,\n createdAt: 6000000001,\n });\n\n context.addMessage({\n id: 'msg_dev_2',\n role: 'developer',\n content: 'Developer message',\n createdAt: 6000000002,\n });\n\n context.addMessage({\n id: 'msg_system_3',\n role: 'system',\n content: 'System message',\n createdAt: 6000000003,\n });\n\n const detailedImage: ImageContent = {\n id: 'img_detailed',\n type: 'image_content',\n image: 'https://example.com/image.jpg',\n inferenceDetail: 'low',\n inferenceWidth: 512,\n inferenceHeight: 512,\n mimeType: 'image/png',\n _cache: { cached: true },\n };\n\n context.addMessage({\n id: 'msg_with_image',\n role: 'user',\n content: ['Image with all properties:', detailedImage],\n createdAt: 6000000004,\n });\n\n expect(context.toJSON()).toMatchSnapshot('message-properties-default');\n expect(\n context.toJSON({\n excludeImage: false,\n excludeTimestamp: false,\n }),\n ).toMatchSnapshot('message-properties-full');\n });\n});\n\ndescribe('ReadonlyChatContext with immutable array', () => {\n it('should have readonly property set to true', () => {\n const items: ChatItem[] = [\n new ChatMessage({\n id: 'msg_1',\n role: 'user',\n content: ['Test'],\n interrupted: false,\n createdAt: Date.now(),\n }),\n ];\n const readonlyContext = new ReadonlyChatContext(items);\n\n expect(readonlyContext.readonly).toBe(true);\n });\n\n it('should prevent setting items property', () => {\n const items: ChatItem[] = [\n new ChatMessage({\n id: 'msg_1',\n role: 'user',\n content: ['Test'],\n interrupted: false,\n createdAt: Date.now(),\n }),\n ];\n const readonlyContext = new ReadonlyChatContext(items);\n expect(() => {\n readonlyContext.items = [];\n }).toThrow(\n `Cannot set items on a read-only chat context. Please use .copy() and agent.update_chat_ctx() to modify the chat context.`,\n );\n });\n\n it('should prevent modifications through array methods', () => {\n const items: ChatItem[] = [\n new ChatMessage({\n id: 'msg_1',\n role: 'user',\n content: ['Test'],\n interrupted: false,\n createdAt: Date.now(),\n }),\n ];\n const readonlyContext = new ReadonlyChatContext(items);\n const newItem = new ChatMessage({\n id: 'msg_2',\n role: 'assistant',\n content: ['Response'],\n interrupted: false,\n createdAt: Date.now(),\n });\n\n const mutableItems = readonlyContext.items;\n expect(() => mutableItems.push(newItem)).toThrow(\n 'Cannot call push() on a read-only array. Please use .copy() and agent.update_chat_ctx() to modify the chat context.',\n );\n\n expect(() => mutableItems.pop()).toThrow(\n 'Cannot call pop() on a read-only array. Please use .copy() and agent.update_chat_ctx() to modify the chat context.',\n );\n\n expect(() => mutableItems.shift()).toThrow(\n 'Cannot call shift() on a read-only array. Please use .copy() and agent.update_chat_ctx() to modify the chat context.',\n );\n\n expect(() => mutableItems.unshift(newItem)).toThrow(\n 'Cannot call unshift() on a read-only array. Please use .copy() and agent.update_chat_ctx() to modify the chat context.',\n );\n\n expect(() => mutableItems.splice(0, 1)).toThrow(\n 'Cannot call splice() on a read-only array. Please use .copy() and agent.update_chat_ctx() to modify the chat context.',\n );\n\n expect(() => mutableItems.sort()).toThrow(\n 'Cannot call sort() on a read-only array. Please use .copy() and agent.update_chat_ctx() to modify the chat context.',\n );\n\n expect(() => mutableItems.reverse()).toThrow(\n 'Cannot call reverse() on a read-only array. Please use .copy() and agent.update_chat_ctx() to modify the chat context.',\n );\n\n expect(() => mutableItems.fill(newItem)).toThrow(\n 'Cannot call fill() on a read-only array. Please use .copy() and agent.update_chat_ctx() to modify the chat context.',\n );\n\n expect(() => mutableItems.copyWithin(0, 1)).toThrow(\n 'Cannot call copyWithin() on a read-only array. Please use .copy() and agent.update_chat_ctx() to modify the chat context.',\n );\n });\n\n it('should prevent bracket notation assignment and deletion', () => {\n const items: ChatItem[] = [\n new ChatMessage({\n id: 'msg_1',\n role: 'user',\n content: ['Test'],\n interrupted: false,\n createdAt: Date.now(),\n }),\n ];\n const readonlyContext = new ReadonlyChatContext(items);\n const newItem = new ChatMessage({\n id: 'msg_2',\n role: 'assistant',\n content: ['Response'],\n interrupted: false,\n createdAt: Date.now(),\n });\n\n expect(() => {\n readonlyContext.items[0] = newItem;\n }).toThrow(\n 'Cannot assign to read-only array index \"0\". Please use .copy() and agent.update_chat_ctx() to modify the chat context.',\n );\n\n expect(() => {\n delete readonlyContext.items[0];\n }).toThrow(\n 'Cannot delete read-only array index \"0\". Please use .copy() and agent.update_chat_ctx() to modify the chat context.',\n );\n\n expect(() => {\n readonlyContext.items[99] = newItem;\n }).toThrow(\n 'Cannot assign to read-only array index \"99\". Please use .copy() and agent.update_chat_ctx() to modify the chat context.',\n );\n });\n\n it('should allow read operations on the immutable array', () => {\n const items: ChatItem[] = [\n new ChatMessage({\n id: 'msg_1',\n role: 'user',\n content: ['Test 1'],\n interrupted: false,\n createdAt: 1000,\n }),\n new ChatMessage({\n id: 'msg_2',\n role: 'assistant',\n content: ['Test 2'],\n interrupted: false,\n createdAt: 2000,\n }),\n ];\n const readonlyContext = new ReadonlyChatContext(items);\n\n expect(readonlyContext.items.length).toBe(2);\n expect(readonlyContext.items[0]).toEqual(items[0]);\n expect(readonlyContext.items[1]).toEqual(items[1]);\n expect(readonlyContext.items.find((item: ChatItem) => item.id === 'msg_2')).toEqual(items[1]);\n expect(readonlyContext.items.map((item: ChatItem) => item.id)).toEqual(['msg_1', 'msg_2']);\n expect(\n readonlyContext.items.filter(\n (item: ChatItem) => item.type === 'message' && item.role === 'user',\n ),\n ).toHaveLength(1);\n\n // forEach should work for reading\n const ids: string[] = [];\n readonlyContext.items.forEach((item) => ids.push(item.id));\n expect(ids).toEqual(['msg_1', 'msg_2']);\n });\n});\n\ndescribe('ChatContext.isEquivalent', () => {\n it('should return true for same reference', () => {\n const ctx = new ChatContext();\n ctx.addMessage({\n id: 'msg_1',\n role: 'user',\n content: 'Hello',\n });\n\n expect(ctx.isEquivalent(ctx)).toBe(true);\n });\n\n it('should return true for identical empty contexts', () => {\n const ctx1 = new ChatContext();\n const ctx2 = new ChatContext();\n\n expect(ctx1.isEquivalent(ctx2)).toBe(true);\n });\n\n it('should return false for contexts with different lengths', () => {\n const ctx1 = new ChatContext();\n ctx1.addMessage({\n id: 'msg_1',\n role: 'user',\n content: 'Hello',\n });\n\n const ctx2 = new ChatContext();\n ctx2.addMessage({\n id: 'msg_1',\n role: 'user',\n content: 'Hello',\n });\n ctx2.addMessage({\n id: 'msg_2',\n role: 'assistant',\n content: 'Hi',\n });\n\n expect(ctx1.isEquivalent(ctx2)).toBe(false);\n });\n\n it('should return false for contexts with different item IDs', () => {\n const ctx1 = new ChatContext();\n ctx1.addMessage({\n id: 'msg_1',\n role: 'user',\n content: 'Hello',\n });\n\n const ctx2 = new ChatContext();\n ctx2.addMessage({\n id: 'msg_2',\n role: 'user',\n content: 'Hello',\n });\n\n expect(ctx1.isEquivalent(ctx2)).toBe(false);\n });\n\n it('should return false for contexts with different item types', () => {\n const ctx1 = new ChatContext();\n ctx1.addMessage({\n id: 'msg_1',\n role: 'user',\n content: 'Hello',\n });\n\n const ctx2 = new ChatContext();\n ctx2.insert(\n new FunctionCall({\n id: 'msg_1',\n callId: 'call_1',\n name: 'test',\n args: '{}',\n }),\n );\n\n expect(ctx1.isEquivalent(ctx2)).toBe(false);\n });\n\n describe('message comparison', () => {\n it('should return true for identical messages', () => {\n const ctx1 = new ChatContext();\n ctx1.addMessage({\n id: 'msg_1',\n role: 'user',\n content: 'Hello',\n interrupted: false,\n });\n\n const ctx2 = new ChatContext();\n ctx2.addMessage({\n id: 'msg_1',\n role: 'user',\n content: 'Hello',\n interrupted: false,\n });\n\n expect(ctx1.isEquivalent(ctx2)).toBe(true);\n });\n\n it('should return false for messages with different roles', () => {\n const ctx1 = new ChatContext();\n ctx1.addMessage({\n id: 'msg_1',\n role: 'user',\n content: 'Hello',\n });\n\n const ctx2 = new ChatContext();\n ctx2.addMessage({\n id: 'msg_1',\n role: 'assistant',\n content: 'Hello',\n });\n\n expect(ctx1.isEquivalent(ctx2)).toBe(false);\n });\n\n it('should return false for messages with different interrupted flags', () => {\n const ctx1 = new ChatContext();\n ctx1.addMessage({\n id: 'msg_1',\n role: 'user',\n content: 'Hello',\n interrupted: false,\n });\n\n const ctx2 = new ChatContext();\n ctx2.addMessage({\n id: 'msg_1',\n role: 'user',\n content: 'Hello',\n interrupted: true,\n });\n\n expect(ctx1.isEquivalent(ctx2)).toBe(false);\n });\n\n it('should return false for messages with different content', () => {\n const ctx1 = new ChatContext();\n ctx1.addMessage({\n id: 'msg_1',\n role: 'user',\n content: 'Hello',\n });\n\n const ctx2 = new ChatContext();\n ctx2.addMessage({\n id: 'msg_1',\n role: 'user',\n content: 'World',\n });\n\n expect(ctx1.isEquivalent(ctx2)).toBe(false);\n });\n\n it('should return true for messages with identical array content', () => {\n const ctx1 = new ChatContext();\n ctx1.addMessage({\n id: 'msg_1',\n role: 'user',\n content: ['Hello', 'World'],\n });\n\n const ctx2 = new ChatContext();\n ctx2.addMessage({\n id: 'msg_1',\n role: 'user',\n content: ['Hello', 'World'],\n });\n\n expect(ctx1.isEquivalent(ctx2)).toBe(true);\n });\n\n it('should return false for messages with different array content', () => {\n const ctx1 = new ChatContext();\n ctx1.addMessage({\n id: 'msg_1',\n role: 'user',\n content: ['Hello', 'World'],\n });\n\n const ctx2 = new ChatContext();\n ctx2.addMessage({\n id: 'msg_1',\n role: 'user',\n content: ['Hello'],\n });\n\n expect(ctx1.isEquivalent(ctx2)).toBe(false);\n });\n\n it('should return true for messages with identical image content', () => {\n const imageContent: ImageContent = {\n id: 'img_1',\n type: 'image_content',\n image: 'https://example.com/image.jpg',\n inferenceDetail: 'high',\n inferenceWidth: 1024,\n inferenceHeight: 768,\n mimeType: 'image/jpeg',\n _cache: {},\n };\n\n const ctx1 = new ChatContext();\n ctx1.addMessage({\n id: 'msg_1',\n role: 'user',\n content: ['Check this:', imageContent],\n });\n\n const ctx2 = new ChatContext();\n ctx2.addMessage({\n id: 'msg_1',\n role: 'user',\n content: ['Check this:', { ...imageContent }],\n });\n\n expect(ctx1.isEquivalent(ctx2)).toBe(true);\n });\n\n it('should return false for messages with different image content', () => {\n const imageContent1: ImageContent = {\n id: 'img_1',\n type: 'image_content',\n image: 'https://example.com/image1.jpg',\n inferenceDetail: 'high',\n _cache: {},\n };\n\n const imageContent2: ImageContent = {\n id: 'img_2',\n type: 'image_content',\n image: 'https://example.com/image2.jpg',\n inferenceDetail: 'high',\n _cache: {},\n };\n\n const ctx1 = new ChatContext();\n ctx1.addMessage({\n id: 'msg_1',\n role: 'user',\n content: ['Check this:', imageContent1],\n });\n\n const ctx2 = new ChatContext();\n ctx2.addMessage({\n id: 'msg_1',\n role: 'user',\n content: ['Check this:', imageContent2],\n });\n\n expect(ctx1.isEquivalent(ctx2)).toBe(false);\n });\n });\n\n describe('function call comparison', () => {\n it('should return true for identical function calls', () => {\n const ctx1 = new ChatContext();\n ctx1.insert(\n new FunctionCall({\n id: 'func_1',\n callId: 'call_1',\n name: 'get_weather',\n args: '{\"location\": \"Paris\"}',\n }),\n );\n\n const ctx2 = new ChatContext();\n ctx2.insert(\n new FunctionCall({\n id: 'func_1',\n callId: 'call_1',\n name: 'get_weather',\n args: '{\"location\": \"Paris\"}',\n }),\n );\n\n expect(ctx1.isEquivalent(ctx2)).toBe(true);\n });\n\n it('should return false for function calls with different names', () => {\n const ctx1 = new ChatContext();\n ctx1.insert(\n new FunctionCall({\n id: 'func_1',\n callId: 'call_1',\n name: 'get_weather',\n args: '{}',\n }),\n );\n\n const ctx2 = new ChatContext();\n ctx2.insert(\n new FunctionCall({\n id: 'func_1',\n callId: 'call_1',\n name: 'get_time',\n args: '{}',\n }),\n );\n\n expect(ctx1.isEquivalent(ctx2)).toBe(false);\n });\n\n it('should return false for function calls with different call IDs', () => {\n const ctx1 = new ChatContext();\n ctx1.insert(\n new FunctionCall({\n id: 'func_1',\n callId: 'call_1',\n name: 'get_weather',\n args: '{}',\n }),\n );\n\n const ctx2 = new ChatContext();\n ctx2.insert(\n new FunctionCall({\n id: 'func_1',\n callId: 'call_2',\n name: 'get_weather',\n args: '{}',\n }),\n );\n\n expect(ctx1.isEquivalent(ctx2)).toBe(false);\n });\n\n it('should return false for function calls with different arguments', () => {\n const ctx1 = new ChatContext();\n ctx1.insert(\n new FunctionCall({\n id: 'func_1',\n callId: 'call_1',\n name: 'get_weather',\n args: '{\"location\": \"Paris\"}',\n }),\n );\n\n const ctx2 = new ChatContext();\n ctx2.insert(\n new FunctionCall({\n id: 'func_1',\n callId: 'call_1',\n name: 'get_weather',\n args: '{\"location\": \"London\"}',\n }),\n );\n\n expect(ctx1.isEquivalent(ctx2)).toBe(false);\n });\n\n it('should ignore timestamps', () => {\n const ctx1 = new ChatContext();\n ctx1.insert(\n new FunctionCall({\n id: 'func_1',\n callId: 'call_1',\n name: 'get_weather',\n args: '{}',\n createdAt: 1000,\n }),\n );\n\n const ctx2 = new ChatContext();\n ctx2.insert(\n new FunctionCall({\n id: 'func_1',\n callId: 'call_1',\n name: 'get_weather',\n args: '{}',\n createdAt: 2000,\n }),\n );\n\n expect(ctx1.isEquivalent(ctx2)).toBe(true);\n });\n });\n\n describe('function call output comparison', () => {\n it('should return true for identical function call outputs', () => {\n const ctx1 = new ChatContext();\n ctx1.insert(\n new FunctionCallOutput({\n id: 'output_1',\n callId: 'call_1',\n name: 'get_weather',\n output: '{\"temperature\": 22}',\n isError: false,\n }),\n );\n\n const ctx2 = new ChatContext();\n ctx2.insert(\n new FunctionCallOutput({\n id: 'output_1',\n callId: 'call_1',\n name: 'get_weather',\n output: '{\"temperature\": 22}',\n isError: false,\n }),\n );\n\n expect(ctx1.isEquivalent(ctx2)).toBe(true);\n });\n\n it('should return false for function call outputs with different names', () => {\n const ctx1 = new ChatContext();\n ctx1.insert(\n new FunctionCallOutput({\n id: 'output_1',\n callId: 'call_1',\n name: 'get_weather',\n output: '{}',\n isError: false,\n }),\n );\n\n const ctx2 = new ChatContext();\n ctx2.insert(\n new FunctionCallOutput({\n id: 'output_1',\n callId: 'call_1',\n name: 'get_time',\n output: '{}',\n isError: false,\n }),\n );\n\n expect(ctx1.isEquivalent(ctx2)).toBe(false);\n });\n\n it('should return false for function call outputs with different call IDs', () => {\n const ctx1 = new ChatContext();\n ctx1.insert(\n new FunctionCallOutput({\n id: 'output_1',\n callId: 'call_1',\n name: 'get_weather',\n output: '{}',\n isError: false,\n }),\n );\n\n const ctx2 = new ChatContext();\n ctx2.insert(\n new FunctionCallOutput({\n id: 'output_1',\n callId: 'call_2',\n name: 'get_weather',\n output: '{}',\n isError: false,\n }),\n );\n\n expect(ctx1.isEquivalent(ctx2)).toBe(false);\n });\n\n it('should return false for function call outputs with different output values', () => {\n const ctx1 = new ChatContext();\n ctx1.insert(\n new FunctionCallOutput({\n id: 'output_1',\n callId: 'call_1',\n name: 'get_weather',\n output: '{\"temperature\": 22}',\n isError: false,\n }),\n );\n\n const ctx2 = new ChatContext();\n ctx2.insert(\n new FunctionCallOutput({\n id: 'output_1',\n callId: 'call_1',\n name: 'get_weather',\n output: '{\"temperature\": 25}',\n isError: false,\n }),\n );\n\n expect(ctx1.isEquivalent(ctx2)).toBe(false);\n });\n\n it('should return false for function call outputs with different error flags', () => {\n const ctx1 = new ChatContext();\n ctx1.insert(\n new FunctionCallOutput({\n id: 'output_1',\n callId: 'call_1',\n name: 'get_weather',\n output: 'Error occurred',\n isError: false,\n }),\n );\n\n const ctx2 = new ChatContext();\n ctx2.insert(\n new FunctionCallOutput({\n id: 'output_1',\n callId: 'call_1',\n name: 'get_weather',\n output: 'Error occurred',\n isError: true,\n }),\n );\n\n expect(ctx1.isEquivalent(ctx2)).toBe(false);\n });\n\n it('should ignore timestamps', () => {\n const ctx1 = new ChatContext();\n ctx1.insert(\n new FunctionCallOutput({\n id: 'output_1',\n callId: 'call_1',\n name: 'get_weather',\n output: '{}',\n isError: false,\n createdAt: 1000,\n }),\n );\n\n const ctx2 = new ChatContext();\n ctx2.insert(\n new FunctionCallOutput({\n id: 'output_1',\n callId: 'call_1',\n name: 'get_weather',\n output: '{}',\n isError: false,\n createdAt: 2000,\n }),\n );\n\n expect(ctx1.isEquivalent(ctx2)).toBe(true);\n });\n });\n\n describe('complex context comparison', () => {\n it('should return true for identical complex contexts', () => {\n const ctx1 = new ChatContext();\n ctx1.addMessage({\n id: 'msg_1',\n role: 'user',\n content: 'What is the weather?',\n });\n ctx1.insert(\n new FunctionCall({\n id: 'func_1',\n callId: 'call_1',\n name: 'get_weather',\n args: '{\"location\": \"Paris\"}',\n }),\n );\n ctx1.insert(\n new FunctionCallOutput({\n id: 'output_1',\n callId: 'call_1',\n name: 'get_weather',\n output: '{\"temperature\": 22}',\n isError: false,\n }),\n );\n ctx1.addMessage({\n id: 'msg_2',\n role: 'assistant',\n content: 'The weather is 22°C',\n });\n\n const ctx2 = new ChatContext();\n ctx2.addMessage({\n id: 'msg_1',\n role: 'user',\n content: 'What is the weather?',\n });\n ctx2.insert(\n new FunctionCall({\n id: 'func_1',\n callId: 'call_1',\n name: 'get_weather',\n args: '{\"location\": \"Paris\"}',\n }),\n );\n ctx2.insert(\n new FunctionCallOutput({\n id: 'output_1',\n callId: 'call_1',\n name: 'get_weather',\n output: '{\"temperature\": 22}',\n isError: false,\n }),\n );\n ctx2.addMessage({\n id: 'msg_2',\n role: 'assistant',\n content: 'The weather is 22°C',\n });\n\n expect(ctx1.isEquivalent(ctx2)).toBe(true);\n });\n });\n});\n"],"mappings":"AAGA,SAAS,UAAU,QAAQ,UAAU;AACrC;AAAA,EAEE;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,OACK;AAEP,SAAS,sBAAsB,MAAM;AACnC,KAAG,2CAA2C,MAAM;AAClD,UAAM,UAAU,IAAI,YAAY;AAChC,WAAO,QAAQ,OAAO,CAAC,EAAE,gBAAgB;AAAA,EAC3C,CAAC;AAED,KAAG,iDAAiD,MAAM;AACxD,UAAM,UAAU,IAAI,YAAY;AAEhC,YAAQ,WAAW;AAAA,MACjB,IAAI;AAAA,MAC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IAAI;AAAA,QACJ,MAAM;AAAA,QACN,SAAS;AAAA,MACX,CAAC;AAED,YAAM,OAAO,IAAI,YAAY;AAC7B,WAAK,WAAW;AAAA,QACd,IAAI;AAAA,QACJ,MAAM;AAAA,QACN,SAAS;AAAA,MACX,CAAC;AACD,WAAK;AAAA,QACH,IAAI,aAAa;AAAA,UACf,IAAI;AAAA,UACJ,QAAQ;AAAA,UACR,MAAM;AAAA,UACN,MAAM;AAAA,QACR,CAAC;AAAA,MACH;AACA,WAAK;AAAA,QACH,IAAI,mBAAmB;AAAA,UACrB,IAAI;AAAA,UACJ,QAAQ;AAAA,UACR,MAAM;AAAA,UACN,QAAQ;AAAA,UACR,SAAS;AAAA,QACX,CAAC;AAAA,MACH;AACA,WAAK,WAAW;AAAA,QACd,IAAI;AAAA,QACJ,MAAM;AAAA,QACN,SAAS;AAAA,MACX,CAAC;AAED,aAAO,KAAK,aAAa,IAAI,CAAC,EAAE,KAAK,IAAI;AAAA,IAC3C,CAAC;AAAA,EACH,CAAC;AACH,CAAC;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/llm/chat_context.test.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2025 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport { describe, expect, it } from 'vitest';\nimport { initializeLogger } from '../log.js';\nimport { FakeLLM } from '../voice/testing/fake_llm.js';\nimport {\n type AudioContent,\n ChatContext,\n type ChatItem,\n ChatMessage,\n FunctionCall,\n FunctionCallOutput,\n type ImageContent,\n ReadonlyChatContext,\n} from './chat_context.js';\n\ninitializeLogger({ pretty: false, level: 'error' });\n\ndescribe('ChatContext.toJSON', () => {\n it('should match snapshot for empty context', () => {\n const context = new ChatContext();\n expect(context.toJSON()).toMatchSnapshot();\n });\n\n it('should match snapshot for simple conversation', () => {\n const context = new ChatContext();\n\n context.addMessage({\n id: 'msg_system_1',\n role: 'system',\n content: 'You are a helpful assistant.',\n createdAt: 1000000000,\n });\n\n context.addMessage({\n id: 'msg_user_1',\n role: 'user',\n content: 'Hello, how are you?',\n createdAt: 1000000001,\n });\n\n context.addMessage({\n id: 'msg_assistant_1',\n role: 'assistant',\n content: \"I'm doing well, thank you! How can I help you today?\",\n createdAt: 1000000002,\n });\n\n expect(context.toJSON()).toMatchSnapshot('simple-conversation-no-timestamps');\n\n expect(context.toJSON({ excludeTimestamp: false })).toMatchSnapshot(\n 'simple-conversation-with-timestamps',\n );\n });\n\n it('should match snapshot for multimodal content', () => {\n const context = new ChatContext();\n\n const imageContent: ImageContent = {\n id: 'img_test_1',\n type: 'image_content',\n image: 'https://example.com/test-image.jpg',\n inferenceDetail: 'high',\n inferenceWidth: 1024,\n inferenceHeight: 768,\n mimeType: 'image/jpeg',\n _cache: {},\n };\n\n const audioContent: AudioContent = {\n type: 'audio_content',\n frame: [], // This won't be included in JSON\n transcript: 'This is a test audio transcript',\n };\n\n context.addMessage({\n id: 'msg_user_2',\n role: 'user',\n content: [\n 'Check out this image and audio:',\n imageContent,\n audioContent,\n 'What do you think?',\n ],\n createdAt: 2000000000,\n });\n\n expect(context.toJSON()).toMatchSnapshot('multimodal-default-exclusions');\n\n expect(\n context.toJSON({\n excludeImage: false,\n excludeAudio: true,\n }),\n ).toMatchSnapshot('multimodal-with-images-only');\n\n expect(\n context.toJSON({\n excludeImage: true,\n excludeAudio: false,\n }),\n ).toMatchSnapshot('multimodal-with-audio-only');\n\n expect(\n context.toJSON({\n excludeImage: false,\n excludeAudio: false,\n excludeTimestamp: false,\n }),\n ).toMatchSnapshot('multimodal-full-content');\n });\n\n it('should match snapshot for function calls', () => {\n const context = new ChatContext();\n\n context.addMessage({\n id: 'msg_user_3',\n role: 'user',\n content: \"What's the weather in Paris?\",\n createdAt: 3000000000,\n });\n\n const functionCall = new FunctionCall({\n id: 'func_call_1',\n callId: 'call_weather_123',\n name: 'get_weather',\n args: '{\"location\": \"Paris, France\", \"unit\": \"celsius\"}',\n createdAt: 3000000001,\n });\n context.insert(functionCall);\n\n const functionOutput = new FunctionCallOutput({\n id: 'func_output_1',\n callId: 'call_weather_123',\n name: 'get_weather',\n output: '{\"temperature\": 22, \"condition\": \"partly cloudy\", \"humidity\": 65}',\n isError: false,\n createdAt: 3000000002,\n });\n context.insert(functionOutput);\n\n context.addMessage({\n id: 'msg_assistant_2',\n role: 'assistant',\n content: 'The weather in Paris is currently 22°C and partly cloudy with 65% humidity.',\n createdAt: 3000000003,\n });\n\n expect(context.toJSON()).toMatchSnapshot('conversation-with-function-calls');\n\n expect(\n context.toJSON({\n excludeFunctionCall: true,\n }),\n ).toMatchSnapshot('conversation-without-function-calls');\n\n expect(\n context.toJSON({\n excludeTimestamp: false,\n }),\n ).toMatchSnapshot('conversation-with-function-calls-and-timestamps');\n });\n\n it('should match snapshot for edge cases', () => {\n const context = new ChatContext();\n\n context.addMessage({\n id: 'msg_empty_1',\n role: 'user',\n content: [],\n createdAt: 5000000000,\n });\n\n const silentAudio: AudioContent = {\n type: 'audio_content',\n frame: [],\n transcript: undefined,\n };\n\n context.addMessage({\n id: 'msg_silent_audio',\n role: 'user',\n content: [silentAudio],\n createdAt: 5000000001,\n });\n\n context.addMessage({\n id: 'msg_multi_text',\n role: 'assistant',\n content: ['Part 1. ', 'Part 2. ', 'Part 3.'],\n createdAt: 5000000002,\n });\n\n const minimalCall = new FunctionCall({\n id: 'func_minimal',\n callId: 'minimal',\n name: 'test',\n args: '{}',\n createdAt: 5000000003,\n });\n context.insert(minimalCall);\n\n const namelessOutput = new FunctionCallOutput({\n id: 'func_output_nameless',\n callId: 'minimal',\n output: 'OK',\n isError: false,\n createdAt: 5000000004,\n });\n context.insert(namelessOutput);\n\n context.addMessage({\n id: 'msg_special_chars',\n role: 'user',\n content:\n 'Test with special chars: \\n\\t\\r \"quotes\" \\'apostrophes\\' \\\\backslashes\\\\ {braces} [brackets]',\n createdAt: 5000000005,\n });\n\n expect(context.toJSON()).toMatchSnapshot('edge-cases-default');\n expect(\n context.toJSON({\n excludeTimestamp: false,\n excludeAudio: false,\n }),\n ).toMatchSnapshot('edge-cases-with-details');\n });\n\n it('should match snapshot for message property variations', () => {\n const context = new ChatContext();\n\n context.addMessage({\n id: 'custom-message-id-123',\n role: 'user',\n content: 'Message with custom ID',\n createdAt: 6000000000,\n });\n\n context.addMessage({\n id: 'msg_interrupted',\n role: 'assistant',\n content: 'This response was interrupted...',\n interrupted: true,\n createdAt: 6000000001,\n });\n\n context.addMessage({\n id: 'msg_dev_2',\n role: 'developer',\n content: 'Developer message',\n createdAt: 6000000002,\n });\n\n context.addMessage({\n id: 'msg_system_3',\n role: 'system',\n content: 'System message',\n createdAt: 6000000003,\n });\n\n const detailedImage: ImageContent = {\n id: 'img_detailed',\n type: 'image_content',\n image: 'https://example.com/image.jpg',\n inferenceDetail: 'low',\n inferenceWidth: 512,\n inferenceHeight: 512,\n mimeType: 'image/png',\n _cache: { cached: true },\n };\n\n context.addMessage({\n id: 'msg_with_image',\n role: 'user',\n content: ['Image with all properties:', detailedImage],\n createdAt: 6000000004,\n });\n\n expect(context.toJSON()).toMatchSnapshot('message-properties-default');\n expect(\n context.toJSON({\n excludeImage: false,\n excludeTimestamp: false,\n }),\n ).toMatchSnapshot('message-properties-full');\n });\n});\n\ndescribe('ChatContext._summarize', () => {\n it('keeps chronological timestamps with summary + tail', async () => {\n const ctx = new ChatContext();\n ctx.addMessage({ role: 'system', content: 'System prompt', createdAt: 0 });\n ctx.addMessage({ role: 'user', content: 'hello', createdAt: 1000 });\n ctx.addMessage({ role: 'assistant', content: 'hi there', createdAt: 2000 });\n ctx.insert(\n new FunctionCallOutput({\n callId: 'call_1',\n name: 'lookup',\n output: '{\"ok\":true}',\n isError: false,\n createdAt: 3500,\n }),\n );\n ctx.addMessage({ role: 'user', content: 'my color is blue', createdAt: 3000 });\n ctx.addMessage({ role: 'assistant', content: 'noted', createdAt: 4000 });\n\n const fake = new FakeLLM([\n {\n input: 'Conversation to summarize:\\n\\nuser: hello\\nassistant: hi there',\n content: 'condensed head',\n },\n ]);\n\n await ctx._summarize(fake, { keepLastTurns: 1 });\n\n const summary = ctx.items.find(\n (item) =>\n item.type === 'message' && item.role === 'assistant' && item.extra?.is_summary === true,\n );\n expect(summary).toBeDefined();\n if (!summary || summary.type !== 'message') {\n throw new Error('summary message is missing');\n }\n\n expect(summary.createdAt).toBeCloseTo(2999.999, 6);\n\n const createdAts = ctx.items.map((item) => item.createdAt);\n const sorted = [...createdAts].sort((a, b) => a - b);\n expect(createdAts).toEqual(sorted);\n });\n});\n\ndescribe('ReadonlyChatContext with immutable array', () => {\n it('should have readonly property set to true', () => {\n const items: ChatItem[] = [\n new ChatMessage({\n id: 'msg_1',\n role: 'user',\n content: ['Test'],\n interrupted: false,\n createdAt: Date.now(),\n }),\n ];\n const readonlyContext = new ReadonlyChatContext(items);\n\n expect(readonlyContext.readonly).toBe(true);\n });\n\n it('should prevent setting items property', () => {\n const items: ChatItem[] = [\n new ChatMessage({\n id: 'msg_1',\n role: 'user',\n content: ['Test'],\n interrupted: false,\n createdAt: Date.now(),\n }),\n ];\n const readonlyContext = new ReadonlyChatContext(items);\n expect(() => {\n readonlyContext.items = [];\n }).toThrow(\n `Cannot set items on a read-only chat context. Please use .copy() and agent.update_chat_ctx() to modify the chat context.`,\n );\n });\n\n it('should prevent modifications through array methods', () => {\n const items: ChatItem[] = [\n new ChatMessage({\n id: 'msg_1',\n role: 'user',\n content: ['Test'],\n interrupted: false,\n createdAt: Date.now(),\n }),\n ];\n const readonlyContext = new ReadonlyChatContext(items);\n const newItem = new ChatMessage({\n id: 'msg_2',\n role: 'assistant',\n content: ['Response'],\n interrupted: false,\n createdAt: Date.now(),\n });\n\n const mutableItems = readonlyContext.items;\n expect(() => mutableItems.push(newItem)).toThrow(\n 'Cannot call push() on a read-only array. Please use .copy() and agent.update_chat_ctx() to modify the chat context.',\n );\n\n expect(() => mutableItems.pop()).toThrow(\n 'Cannot call pop() on a read-only array. Please use .copy() and agent.update_chat_ctx() to modify the chat context.',\n );\n\n expect(() => mutableItems.shift()).toThrow(\n 'Cannot call shift() on a read-only array. Please use .copy() and agent.update_chat_ctx() to modify the chat context.',\n );\n\n expect(() => mutableItems.unshift(newItem)).toThrow(\n 'Cannot call unshift() on a read-only array. Please use .copy() and agent.update_chat_ctx() to modify the chat context.',\n );\n\n expect(() => mutableItems.splice(0, 1)).toThrow(\n 'Cannot call splice() on a read-only array. Please use .copy() and agent.update_chat_ctx() to modify the chat context.',\n );\n\n expect(() => mutableItems.sort()).toThrow(\n 'Cannot call sort() on a read-only array. Please use .copy() and agent.update_chat_ctx() to modify the chat context.',\n );\n\n expect(() => mutableItems.reverse()).toThrow(\n 'Cannot call reverse() on a read-only array. Please use .copy() and agent.update_chat_ctx() to modify the chat context.',\n );\n\n expect(() => mutableItems.fill(newItem)).toThrow(\n 'Cannot call fill() on a read-only array. Please use .copy() and agent.update_chat_ctx() to modify the chat context.',\n );\n\n expect(() => mutableItems.copyWithin(0, 1)).toThrow(\n 'Cannot call copyWithin() on a read-only array. Please use .copy() and agent.update_chat_ctx() to modify the chat context.',\n );\n });\n\n it('should prevent bracket notation assignment and deletion', () => {\n const items: ChatItem[] = [\n new ChatMessage({\n id: 'msg_1',\n role: 'user',\n content: ['Test'],\n interrupted: false,\n createdAt: Date.now(),\n }),\n ];\n const readonlyContext = new ReadonlyChatContext(items);\n const newItem = new ChatMessage({\n id: 'msg_2',\n role: 'assistant',\n content: ['Response'],\n interrupted: false,\n createdAt: Date.now(),\n });\n\n expect(() => {\n readonlyContext.items[0] = newItem;\n }).toThrow(\n 'Cannot assign to read-only array index \"0\". Please use .copy() and agent.update_chat_ctx() to modify the chat context.',\n );\n\n expect(() => {\n delete readonlyContext.items[0];\n }).toThrow(\n 'Cannot delete read-only array index \"0\". Please use .copy() and agent.update_chat_ctx() to modify the chat context.',\n );\n\n expect(() => {\n readonlyContext.items[99] = newItem;\n }).toThrow(\n 'Cannot assign to read-only array index \"99\". Please use .copy() and agent.update_chat_ctx() to modify the chat context.',\n );\n });\n\n it('should allow read operations on the immutable array', () => {\n const items: ChatItem[] = [\n new ChatMessage({\n id: 'msg_1',\n role: 'user',\n content: ['Test 1'],\n interrupted: false,\n createdAt: 1000,\n }),\n new ChatMessage({\n id: 'msg_2',\n role: 'assistant',\n content: ['Test 2'],\n interrupted: false,\n createdAt: 2000,\n }),\n ];\n const readonlyContext = new ReadonlyChatContext(items);\n\n expect(readonlyContext.items.length).toBe(2);\n expect(readonlyContext.items[0]).toEqual(items[0]);\n expect(readonlyContext.items[1]).toEqual(items[1]);\n expect(readonlyContext.items.find((item: ChatItem) => item.id === 'msg_2')).toEqual(items[1]);\n expect(readonlyContext.items.map((item: ChatItem) => item.id)).toEqual(['msg_1', 'msg_2']);\n expect(\n readonlyContext.items.filter(\n (item: ChatItem) => item.type === 'message' && item.role === 'user',\n ),\n ).toHaveLength(1);\n\n // forEach should work for reading\n const ids: string[] = [];\n readonlyContext.items.forEach((item) => ids.push(item.id));\n expect(ids).toEqual(['msg_1', 'msg_2']);\n });\n});\n\ndescribe('ChatContext.isEquivalent', () => {\n it('should return true for same reference', () => {\n const ctx = new ChatContext();\n ctx.addMessage({\n id: 'msg_1',\n role: 'user',\n content: 'Hello',\n });\n\n expect(ctx.isEquivalent(ctx)).toBe(true);\n });\n\n it('should return true for identical empty contexts', () => {\n const ctx1 = new ChatContext();\n const ctx2 = new ChatContext();\n\n expect(ctx1.isEquivalent(ctx2)).toBe(true);\n });\n\n it('should return false for contexts with different lengths', () => {\n const ctx1 = new ChatContext();\n ctx1.addMessage({\n id: 'msg_1',\n role: 'user',\n content: 'Hello',\n });\n\n const ctx2 = new ChatContext();\n ctx2.addMessage({\n id: 'msg_1',\n role: 'user',\n content: 'Hello',\n });\n ctx2.addMessage({\n id: 'msg_2',\n role: 'assistant',\n content: 'Hi',\n });\n\n expect(ctx1.isEquivalent(ctx2)).toBe(false);\n });\n\n it('should return false for contexts with different item IDs', () => {\n const ctx1 = new ChatContext();\n ctx1.addMessage({\n id: 'msg_1',\n role: 'user',\n content: 'Hello',\n });\n\n const ctx2 = new ChatContext();\n ctx2.addMessage({\n id: 'msg_2',\n role: 'user',\n content: 'Hello',\n });\n\n expect(ctx1.isEquivalent(ctx2)).toBe(false);\n });\n\n it('should return false for contexts with different item types', () => {\n const ctx1 = new ChatContext();\n ctx1.addMessage({\n id: 'msg_1',\n role: 'user',\n content: 'Hello',\n });\n\n const ctx2 = new ChatContext();\n ctx2.insert(\n new FunctionCall({\n id: 'msg_1',\n callId: 'call_1',\n name: 'test',\n args: '{}',\n }),\n );\n\n expect(ctx1.isEquivalent(ctx2)).toBe(false);\n });\n\n describe('message comparison', () => {\n it('should return true for identical messages', () => {\n const ctx1 = new ChatContext();\n ctx1.addMessage({\n id: 'msg_1',\n role: 'user',\n content: 'Hello',\n interrupted: false,\n });\n\n const ctx2 = new ChatContext();\n ctx2.addMessage({\n id: 'msg_1',\n role: 'user',\n content: 'Hello',\n interrupted: false,\n });\n\n expect(ctx1.isEquivalent(ctx2)).toBe(true);\n });\n\n it('should return false for messages with different roles', () => {\n const ctx1 = new ChatContext();\n ctx1.addMessage({\n id: 'msg_1',\n role: 'user',\n content: 'Hello',\n });\n\n const ctx2 = new ChatContext();\n ctx2.addMessage({\n id: 'msg_1',\n role: 'assistant',\n content: 'Hello',\n });\n\n expect(ctx1.isEquivalent(ctx2)).toBe(false);\n });\n\n it('should return false for messages with different interrupted flags', () => {\n const ctx1 = new ChatContext();\n ctx1.addMessage({\n id: 'msg_1',\n role: 'user',\n content: 'Hello',\n interrupted: false,\n });\n\n const ctx2 = new ChatContext();\n ctx2.addMessage({\n id: 'msg_1',\n role: 'user',\n content: 'Hello',\n interrupted: true,\n });\n\n expect(ctx1.isEquivalent(ctx2)).toBe(false);\n });\n\n it('should return false for messages with different content', () => {\n const ctx1 = new ChatContext();\n ctx1.addMessage({\n id: 'msg_1',\n role: 'user',\n content: 'Hello',\n });\n\n const ctx2 = new ChatContext();\n ctx2.addMessage({\n id: 'msg_1',\n role: 'user',\n content: 'World',\n });\n\n expect(ctx1.isEquivalent(ctx2)).toBe(false);\n });\n\n it('should return true for messages with identical array content', () => {\n const ctx1 = new ChatContext();\n ctx1.addMessage({\n id: 'msg_1',\n role: 'user',\n content: ['Hello', 'World'],\n });\n\n const ctx2 = new ChatContext();\n ctx2.addMessage({\n id: 'msg_1',\n role: 'user',\n content: ['Hello', 'World'],\n });\n\n expect(ctx1.isEquivalent(ctx2)).toBe(true);\n });\n\n it('should return false for messages with different array content', () => {\n const ctx1 = new ChatContext();\n ctx1.addMessage({\n id: 'msg_1',\n role: 'user',\n content: ['Hello', 'World'],\n });\n\n const ctx2 = new ChatContext();\n ctx2.addMessage({\n id: 'msg_1',\n role: 'user',\n content: ['Hello'],\n });\n\n expect(ctx1.isEquivalent(ctx2)).toBe(false);\n });\n\n it('should return true for messages with identical image content', () => {\n const imageContent: ImageContent = {\n id: 'img_1',\n type: 'image_content',\n image: 'https://example.com/image.jpg',\n inferenceDetail: 'high',\n inferenceWidth: 1024,\n inferenceHeight: 768,\n mimeType: 'image/jpeg',\n _cache: {},\n };\n\n const ctx1 = new ChatContext();\n ctx1.addMessage({\n id: 'msg_1',\n role: 'user',\n content: ['Check this:', imageContent],\n });\n\n const ctx2 = new ChatContext();\n ctx2.addMessage({\n id: 'msg_1',\n role: 'user',\n content: ['Check this:', { ...imageContent }],\n });\n\n expect(ctx1.isEquivalent(ctx2)).toBe(true);\n });\n\n it('should return false for messages with different image content', () => {\n const imageContent1: ImageContent = {\n id: 'img_1',\n type: 'image_content',\n image: 'https://example.com/image1.jpg',\n inferenceDetail: 'high',\n _cache: {},\n };\n\n const imageContent2: ImageContent = {\n id: 'img_2',\n type: 'image_content',\n image: 'https://example.com/image2.jpg',\n inferenceDetail: 'high',\n _cache: {},\n };\n\n const ctx1 = new ChatContext();\n ctx1.addMessage({\n id: 'msg_1',\n role: 'user',\n content: ['Check this:', imageContent1],\n });\n\n const ctx2 = new ChatContext();\n ctx2.addMessage({\n id: 'msg_1',\n role: 'user',\n content: ['Check this:', imageContent2],\n });\n\n expect(ctx1.isEquivalent(ctx2)).toBe(false);\n });\n });\n\n describe('function call comparison', () => {\n it('should return true for identical function calls', () => {\n const ctx1 = new ChatContext();\n ctx1.insert(\n new FunctionCall({\n id: 'func_1',\n callId: 'call_1',\n name: 'get_weather',\n args: '{\"location\": \"Paris\"}',\n }),\n );\n\n const ctx2 = new ChatContext();\n ctx2.insert(\n new FunctionCall({\n id: 'func_1',\n callId: 'call_1',\n name: 'get_weather',\n args: '{\"location\": \"Paris\"}',\n }),\n );\n\n expect(ctx1.isEquivalent(ctx2)).toBe(true);\n });\n\n it('should return false for function calls with different names', () => {\n const ctx1 = new ChatContext();\n ctx1.insert(\n new FunctionCall({\n id: 'func_1',\n callId: 'call_1',\n name: 'get_weather',\n args: '{}',\n }),\n );\n\n const ctx2 = new ChatContext();\n ctx2.insert(\n new FunctionCall({\n id: 'func_1',\n callId: 'call_1',\n name: 'get_time',\n args: '{}',\n }),\n );\n\n expect(ctx1.isEquivalent(ctx2)).toBe(false);\n });\n\n it('should return false for function calls with different call IDs', () => {\n const ctx1 = new ChatContext();\n ctx1.insert(\n new FunctionCall({\n id: 'func_1',\n callId: 'call_1',\n name: 'get_weather',\n args: '{}',\n }),\n );\n\n const ctx2 = new ChatContext();\n ctx2.insert(\n new FunctionCall({\n id: 'func_1',\n callId: 'call_2',\n name: 'get_weather',\n args: '{}',\n }),\n );\n\n expect(ctx1.isEquivalent(ctx2)).toBe(false);\n });\n\n it('should return false for function calls with different arguments', () => {\n const ctx1 = new ChatContext();\n ctx1.insert(\n new FunctionCall({\n id: 'func_1',\n callId: 'call_1',\n name: 'get_weather',\n args: '{\"location\": \"Paris\"}',\n }),\n );\n\n const ctx2 = new ChatContext();\n ctx2.insert(\n new FunctionCall({\n id: 'func_1',\n callId: 'call_1',\n name: 'get_weather',\n args: '{\"location\": \"London\"}',\n }),\n );\n\n expect(ctx1.isEquivalent(ctx2)).toBe(false);\n });\n\n it('should ignore timestamps', () => {\n const ctx1 = new ChatContext();\n ctx1.insert(\n new FunctionCall({\n id: 'func_1',\n callId: 'call_1',\n name: 'get_weather',\n args: '{}',\n createdAt: 1000,\n }),\n );\n\n const ctx2 = new ChatContext();\n ctx2.insert(\n new FunctionCall({\n id: 'func_1',\n callId: 'call_1',\n name: 'get_weather',\n args: '{}',\n createdAt: 2000,\n }),\n );\n\n expect(ctx1.isEquivalent(ctx2)).toBe(true);\n });\n });\n\n describe('function call output comparison', () => {\n it('should return true for identical function call outputs', () => {\n const ctx1 = new ChatContext();\n ctx1.insert(\n new FunctionCallOutput({\n id: 'output_1',\n callId: 'call_1',\n name: 'get_weather',\n output: '{\"temperature\": 22}',\n isError: false,\n }),\n );\n\n const ctx2 = new ChatContext();\n ctx2.insert(\n new FunctionCallOutput({\n id: 'output_1',\n callId: 'call_1',\n name: 'get_weather',\n output: '{\"temperature\": 22}',\n isError: false,\n }),\n );\n\n expect(ctx1.isEquivalent(ctx2)).toBe(true);\n });\n\n it('should return false for function call outputs with different names', () => {\n const ctx1 = new ChatContext();\n ctx1.insert(\n new FunctionCallOutput({\n id: 'output_1',\n callId: 'call_1',\n name: 'get_weather',\n output: '{}',\n isError: false,\n }),\n );\n\n const ctx2 = new ChatContext();\n ctx2.insert(\n new FunctionCallOutput({\n id: 'output_1',\n callId: 'call_1',\n name: 'get_time',\n output: '{}',\n isError: false,\n }),\n );\n\n expect(ctx1.isEquivalent(ctx2)).toBe(false);\n });\n\n it('should return false for function call outputs with different call IDs', () => {\n const ctx1 = new ChatContext();\n ctx1.insert(\n new FunctionCallOutput({\n id: 'output_1',\n callId: 'call_1',\n name: 'get_weather',\n output: '{}',\n isError: false,\n }),\n );\n\n const ctx2 = new ChatContext();\n ctx2.insert(\n new FunctionCallOutput({\n id: 'output_1',\n callId: 'call_2',\n name: 'get_weather',\n output: '{}',\n isError: false,\n }),\n );\n\n expect(ctx1.isEquivalent(ctx2)).toBe(false);\n });\n\n it('should return false for function call outputs with different output values', () => {\n const ctx1 = new ChatContext();\n ctx1.insert(\n new FunctionCallOutput({\n id: 'output_1',\n callId: 'call_1',\n name: 'get_weather',\n output: '{\"temperature\": 22}',\n isError: false,\n }),\n );\n\n const ctx2 = new ChatContext();\n ctx2.insert(\n new FunctionCallOutput({\n id: 'output_1',\n callId: 'call_1',\n name: 'get_weather',\n output: '{\"temperature\": 25}',\n isError: false,\n }),\n );\n\n expect(ctx1.isEquivalent(ctx2)).toBe(false);\n });\n\n it('should return false for function call outputs with different error flags', () => {\n const ctx1 = new ChatContext();\n ctx1.insert(\n new FunctionCallOutput({\n id: 'output_1',\n callId: 'call_1',\n name: 'get_weather',\n output: 'Error occurred',\n isError: false,\n }),\n );\n\n const ctx2 = new ChatContext();\n ctx2.insert(\n new FunctionCallOutput({\n id: 'output_1',\n callId: 'call_1',\n name: 'get_weather',\n output: 'Error occurred',\n isError: true,\n }),\n );\n\n expect(ctx1.isEquivalent(ctx2)).toBe(false);\n });\n\n it('should ignore timestamps', () => {\n const ctx1 = new ChatContext();\n ctx1.insert(\n new FunctionCallOutput({\n id: 'output_1',\n callId: 'call_1',\n name: 'get_weather',\n output: '{}',\n isError: false,\n createdAt: 1000,\n }),\n );\n\n const ctx2 = new ChatContext();\n ctx2.insert(\n new FunctionCallOutput({\n id: 'output_1',\n callId: 'call_1',\n name: 'get_weather',\n output: '{}',\n isError: false,\n createdAt: 2000,\n }),\n );\n\n expect(ctx1.isEquivalent(ctx2)).toBe(true);\n });\n });\n\n describe('complex context comparison', () => {\n it('should return true for identical complex contexts', () => {\n const ctx1 = new ChatContext();\n ctx1.addMessage({\n id: 'msg_1',\n role: 'user',\n content: 'What is the weather?',\n });\n ctx1.insert(\n new FunctionCall({\n id: 'func_1',\n callId: 'call_1',\n name: 'get_weather',\n args: '{\"location\": \"Paris\"}',\n }),\n );\n ctx1.insert(\n new FunctionCallOutput({\n id: 'output_1',\n callId: 'call_1',\n name: 'get_weather',\n output: '{\"temperature\": 22}',\n isError: false,\n }),\n );\n ctx1.addMessage({\n id: 'msg_2',\n role: 'assistant',\n content: 'The weather is 22°C',\n });\n\n const ctx2 = new ChatContext();\n ctx2.addMessage({\n id: 'msg_1',\n role: 'user',\n content: 'What is the weather?',\n });\n ctx2.insert(\n new FunctionCall({\n id: 'func_1',\n callId: 'call_1',\n name: 'get_weather',\n args: '{\"location\": \"Paris\"}',\n }),\n );\n ctx2.insert(\n new FunctionCallOutput({\n id: 'output_1',\n callId: 'call_1',\n name: 'get_weather',\n output: '{\"temperature\": 22}',\n isError: false,\n }),\n );\n ctx2.addMessage({\n id: 'msg_2',\n role: 'assistant',\n content: 'The weather is 22°C',\n });\n\n expect(ctx1.isEquivalent(ctx2)).toBe(true);\n });\n });\n});\n"],"mappings":"AAGA,SAAS,UAAU,QAAQ,UAAU;AACrC,SAAS,wBAAwB;AACjC,SAAS,eAAe;AACxB;AAAA,EAEE;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,OACK;AAEP,iBAAiB,EAAE,QAAQ,OAAO,OAAO,QAAQ,CAAC;AAElD,SAAS,sBAAsB,MAAM;AACnC,KAAG,2CAA2C,MAAM;AAClD,UAAM,UAAU,IAAI,YAAY;AAChC,WAAO,QAAQ,OAAO,CAAC,EAAE,gBAAgB;AAAA,EAC3C,CAAC;AAED,KAAG,iDAAiD,MAAM;AACxD,UAAM,UAAU,IAAI,YAAY;AAEhC,YAAQ,WAAW;AAAA,MACjB,IAAI;AAAA,MACJ,MAAM;AAAA,MACN,SAAS;AAAA,MACT,WAAW;AAAA,IACb,CAAC;AAED,YAAQ,WAAW;AAAA,MACjB,IAAI;AAAA,MACJ,MAAM;AAAA,MACN,SAAS;AAAA,MACT,WAAW;AAAA,IACb,CAAC;AAED,YAAQ,WAAW;AAAA,MACjB,IAAI;AAAA,MACJ,MAAM;AAAA,MACN,SAAS;AAAA,MACT,WAAW;AAAA,IACb,CAAC;AAED,WAAO,QAAQ,OAAO,CAAC,EAAE,gBAAgB,mCAAmC;AAE5E,WAAO,QAAQ,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WAAK;AAAA,QACH,IAAI,mBAAmB;AAAA,UACrB,IAAI;AAAA,UACJ,QAAQ;AAAA,UACR,MAAM;AAAA,UACN,QAAQ;AAAA,UACR,SAAS;AAAA,QACX,CAAC;AAAA,MACH;AACA,WAAK,WAAW;AAAA,QACd,IAAI;AAAA,QACJ,MAAM;AAAA,QACN,SAAS;AAAA,MACX,CAAC;AAED,aAAO,KAAK,aAAa,IAAI,CAAC,EAAE,KAAK,IAAI;AAAA,IAC3C,CAAC;AAAA,EACH,CAAC;AACH,CAAC;","names":[]}
|
package/dist/llm/index.cjs
CHANGED
|
@@ -30,6 +30,7 @@ __export(llm_exports, {
|
|
|
30
30
|
RealtimeSession: () => import_realtime.RealtimeSession,
|
|
31
31
|
RemoteChatContext: () => import_remote_chat_context.RemoteChatContext,
|
|
32
32
|
ToolError: () => import_tool_context.ToolError,
|
|
33
|
+
ToolFlag: () => import_tool_context.ToolFlag,
|
|
33
34
|
computeChatCtxDiff: () => import_utils.computeChatCtxDiff,
|
|
34
35
|
createAudioContent: () => import_chat_context.createAudioContent,
|
|
35
36
|
createImageContent: () => import_chat_context.createImageContent,
|
|
@@ -64,6 +65,7 @@ var import_fallback_adapter = require("./fallback_adapter.cjs");
|
|
|
64
65
|
RealtimeSession,
|
|
65
66
|
RemoteChatContext,
|
|
66
67
|
ToolError,
|
|
68
|
+
ToolFlag,
|
|
67
69
|
computeChatCtxDiff,
|
|
68
70
|
createAudioContent,
|
|
69
71
|
createImageContent,
|
package/dist/llm/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/llm/index.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nexport {\n handoff,\n isFunctionTool,\n tool,\n ToolError,\n type AgentHandoff,\n type FunctionTool,\n type ProviderDefinedTool,\n type Tool,\n type ToolChoice,\n type ToolContext,\n type ToolOptions,\n type ToolType,\n} from './tool_context.js';\n\nexport {\n AgentHandoffItem,\n ChatContext,\n ChatMessage,\n createAudioContent,\n createImageContent,\n FunctionCall,\n FunctionCallOutput,\n type AudioContent,\n type ChatContent,\n type ChatItem,\n type ChatRole,\n type ImageContent,\n} from './chat_context.js';\n\nexport type { ProviderFormat } from './provider_format/index.js';\n\nexport {\n LLM,\n LLMStream,\n type ChatChunk,\n type ChoiceDelta,\n type CompletionUsage,\n type LLMCallbacks,\n} from './llm.js';\n\nexport {\n RealtimeModel,\n RealtimeSession,\n type GenerationCreatedEvent,\n type InputSpeechStartedEvent,\n type InputSpeechStoppedEvent,\n type InputTranscriptionCompleted,\n type MessageGeneration,\n type RealtimeCapabilities,\n type RealtimeModelError,\n type RealtimeSessionReconnectedEvent,\n} from './realtime.js';\n\nexport { RemoteChatContext } from './remote_chat_context.js';\n\nexport {\n computeChatCtxDiff,\n createToolOptions,\n executeToolCall,\n oaiBuildFunctionInfo,\n oaiParams,\n toJsonSchema,\n type OpenAIFunctionParameters,\n} from './utils.js';\n\nexport {\n FallbackAdapter,\n type AvailabilityChangedEvent,\n type FallbackAdapterOptions,\n} from './fallback_adapter.js';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,
|
|
1
|
+
{"version":3,"sources":["../../src/llm/index.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nexport {\n handoff,\n isFunctionTool,\n tool,\n ToolError,\n ToolFlag,\n type AgentHandoff,\n type FunctionTool,\n type ProviderDefinedTool,\n type Tool,\n type ToolChoice,\n type ToolContext,\n type ToolOptions,\n type ToolType,\n} from './tool_context.js';\n\nexport {\n AgentHandoffItem,\n ChatContext,\n ChatMessage,\n createAudioContent,\n createImageContent,\n FunctionCall,\n FunctionCallOutput,\n type AudioContent,\n type ChatContent,\n type ChatItem,\n type ChatRole,\n type ImageContent,\n} from './chat_context.js';\n\nexport type { ProviderFormat } from './provider_format/index.js';\n\nexport {\n LLM,\n LLMStream,\n type ChatChunk,\n type ChoiceDelta,\n type CompletionUsage,\n type LLMCallbacks,\n} from './llm.js';\n\nexport {\n RealtimeModel,\n RealtimeSession,\n type GenerationCreatedEvent,\n type InputSpeechStartedEvent,\n type InputSpeechStoppedEvent,\n type InputTranscriptionCompleted,\n type MessageGeneration,\n type RealtimeCapabilities,\n type RealtimeModelError,\n type RealtimeSessionReconnectedEvent,\n} from './realtime.js';\n\nexport { RemoteChatContext } from './remote_chat_context.js';\n\nexport {\n computeChatCtxDiff,\n createToolOptions,\n executeToolCall,\n oaiBuildFunctionInfo,\n oaiParams,\n toJsonSchema,\n type OpenAIFunctionParameters,\n} from './utils.js';\n\nexport {\n FallbackAdapter,\n type AvailabilityChangedEvent,\n type FallbackAdapterOptions,\n} from './fallback_adapter.js';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,0BAcO;AAEP,0BAaO;AAIP,iBAOO;AAEP,sBAWO;AAEP,iCAAkC;AAElC,mBAQO;AAEP,8BAIO;","names":[]}
|
package/dist/llm/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { handoff, isFunctionTool, tool, ToolError, type AgentHandoff, type FunctionTool, type ProviderDefinedTool, type Tool, type ToolChoice, type ToolContext, type ToolOptions, type ToolType, } from './tool_context.js';
|
|
1
|
+
export { handoff, isFunctionTool, tool, ToolError, ToolFlag, type AgentHandoff, type FunctionTool, type ProviderDefinedTool, type Tool, type ToolChoice, type ToolContext, type ToolOptions, type ToolType, } from './tool_context.js';
|
|
2
2
|
export { AgentHandoffItem, ChatContext, ChatMessage, createAudioContent, createImageContent, FunctionCall, FunctionCallOutput, type AudioContent, type ChatContent, type ChatItem, type ChatRole, type ImageContent, } from './chat_context.js';
|
|
3
3
|
export type { ProviderFormat } from './provider_format/index.js';
|
|
4
4
|
export { LLM, LLMStream, type ChatChunk, type ChoiceDelta, type CompletionUsage, type LLMCallbacks, } from './llm.js';
|
package/dist/llm/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { handoff, isFunctionTool, tool, ToolError, type AgentHandoff, type FunctionTool, type ProviderDefinedTool, type Tool, type ToolChoice, type ToolContext, type ToolOptions, type ToolType, } from './tool_context.js';
|
|
1
|
+
export { handoff, isFunctionTool, tool, ToolError, ToolFlag, type AgentHandoff, type FunctionTool, type ProviderDefinedTool, type Tool, type ToolChoice, type ToolContext, type ToolOptions, type ToolType, } from './tool_context.js';
|
|
2
2
|
export { AgentHandoffItem, ChatContext, ChatMessage, createAudioContent, createImageContent, FunctionCall, FunctionCallOutput, type AudioContent, type ChatContent, type ChatItem, type ChatRole, type ImageContent, } from './chat_context.js';
|
|
3
3
|
export type { ProviderFormat } from './provider_format/index.js';
|
|
4
4
|
export { LLM, LLMStream, type ChatChunk, type ChoiceDelta, type CompletionUsage, type LLMCallbacks, } from './llm.js';
|
package/dist/llm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/llm/index.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,OAAO,EACP,cAAc,EACd,IAAI,EACJ,SAAS,EACT,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,mBAAmB,EACxB,KAAK,IAAI,EACT,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,QAAQ,GACd,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,g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AChB,WAAW,EACX,WAAW,EACX,kBAAkB,EAClB,kBAAkB,EAClB,YAAY,EACZ,kBAAkB,EAClB,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,QAAQ,EACb,KAAK,QAAQ,EACb,KAAK,YAAY,GAClB,MAAM,mBAAmB,CAAC;AAE3B,YAAY,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAEjE,OAAO,EACL,GAAG,EACH,SAAS,EACT,KAAK,SAAS,EACd,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,KAAK,YAAY,GAClB,MAAM,UAAU,CAAC;AAElB,OAAO,EACL,aAAa,EACb,eAAe,EACf,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAC5B,KAAK,uBAAuB,EAC5B,KAAK,2BAA2B,EAChC,KAAK,iBAAiB,EACtB,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EACvB,KAAK,+BAA+B,GACrC,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAE7D,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,eAAe,EACf,oBAAoB,EACpB,SAAS,EACT,YAAY,EACZ,KAAK,wBAAwB,GAC9B,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,eAAe,EACf,KAAK,wBAAwB,EAC7B,KAAK,sBAAsB,GAC5B,MAAM,uBAAuB,CAAC"}
|
package/dist/llm/index.js
CHANGED
|
@@ -2,7 +2,8 @@ import {
|
|
|
2
2
|
handoff,
|
|
3
3
|
isFunctionTool,
|
|
4
4
|
tool,
|
|
5
|
-
ToolError
|
|
5
|
+
ToolError,
|
|
6
|
+
ToolFlag
|
|
6
7
|
} from "./tool_context.js";
|
|
7
8
|
import {
|
|
8
9
|
AgentHandoffItem,
|
|
@@ -46,6 +47,7 @@ export {
|
|
|
46
47
|
RealtimeSession,
|
|
47
48
|
RemoteChatContext,
|
|
48
49
|
ToolError,
|
|
50
|
+
ToolFlag,
|
|
49
51
|
computeChatCtxDiff,
|
|
50
52
|
createAudioContent,
|
|
51
53
|
createImageContent,
|
package/dist/llm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/llm/index.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nexport {\n handoff,\n isFunctionTool,\n tool,\n ToolError,\n type AgentHandoff,\n type FunctionTool,\n type ProviderDefinedTool,\n type Tool,\n type ToolChoice,\n type ToolContext,\n type ToolOptions,\n type ToolType,\n} from './tool_context.js';\n\nexport {\n AgentHandoffItem,\n ChatContext,\n ChatMessage,\n createAudioContent,\n createImageContent,\n FunctionCall,\n FunctionCallOutput,\n type AudioContent,\n type ChatContent,\n type ChatItem,\n type ChatRole,\n type ImageContent,\n} from './chat_context.js';\n\nexport type { ProviderFormat } from './provider_format/index.js';\n\nexport {\n LLM,\n LLMStream,\n type ChatChunk,\n type ChoiceDelta,\n type CompletionUsage,\n type LLMCallbacks,\n} from './llm.js';\n\nexport {\n RealtimeModel,\n RealtimeSession,\n type GenerationCreatedEvent,\n type InputSpeechStartedEvent,\n type InputSpeechStoppedEvent,\n type InputTranscriptionCompleted,\n type MessageGeneration,\n type RealtimeCapabilities,\n type RealtimeModelError,\n type RealtimeSessionReconnectedEvent,\n} from './realtime.js';\n\nexport { RemoteChatContext } from './remote_chat_context.js';\n\nexport {\n computeChatCtxDiff,\n createToolOptions,\n executeToolCall,\n oaiBuildFunctionInfo,\n oaiParams,\n toJsonSchema,\n type OpenAIFunctionParameters,\n} from './utils.js';\n\nexport {\n FallbackAdapter,\n type AvailabilityChangedEvent,\n type FallbackAdapterOptions,\n} from './fallback_adapter.js';\n"],"mappings":"AAGA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OASK;AAEP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAMK;AAIP;AAAA,EACE;AAAA,EACA;AAAA,OAKK;AAEP;AAAA,EACE;AAAA,EACA;AAAA,OASK;AAEP,SAAS,yBAAyB;AAElC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AAEP;AAAA,EACE;AAAA,OAGK;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/llm/index.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nexport {\n handoff,\n isFunctionTool,\n tool,\n ToolError,\n ToolFlag,\n type AgentHandoff,\n type FunctionTool,\n type ProviderDefinedTool,\n type Tool,\n type ToolChoice,\n type ToolContext,\n type ToolOptions,\n type ToolType,\n} from './tool_context.js';\n\nexport {\n AgentHandoffItem,\n ChatContext,\n ChatMessage,\n createAudioContent,\n createImageContent,\n FunctionCall,\n FunctionCallOutput,\n type AudioContent,\n type ChatContent,\n type ChatItem,\n type ChatRole,\n type ImageContent,\n} from './chat_context.js';\n\nexport type { ProviderFormat } from './provider_format/index.js';\n\nexport {\n LLM,\n LLMStream,\n type ChatChunk,\n type ChoiceDelta,\n type CompletionUsage,\n type LLMCallbacks,\n} from './llm.js';\n\nexport {\n RealtimeModel,\n RealtimeSession,\n type GenerationCreatedEvent,\n type InputSpeechStartedEvent,\n type InputSpeechStoppedEvent,\n type InputTranscriptionCompleted,\n type MessageGeneration,\n type RealtimeCapabilities,\n type RealtimeModelError,\n type RealtimeSessionReconnectedEvent,\n} from './realtime.js';\n\nexport { RemoteChatContext } from './remote_chat_context.js';\n\nexport {\n computeChatCtxDiff,\n createToolOptions,\n executeToolCall,\n oaiBuildFunctionInfo,\n oaiParams,\n toJsonSchema,\n type OpenAIFunctionParameters,\n} from './utils.js';\n\nexport {\n FallbackAdapter,\n type AvailabilityChangedEvent,\n type FallbackAdapterOptions,\n} from './fallback_adapter.js';\n"],"mappings":"AAGA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OASK;AAEP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAMK;AAIP;AAAA,EACE;AAAA,EACA;AAAA,OAKK;AAEP;AAAA,EACE;AAAA,EACA;AAAA,OASK;AAEP,SAAS,yBAAyB;AAElC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AAEP;AAAA,EACE;AAAA,OAGK;","names":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { ChatContext } from '../chat_context.js';
|
|
2
2
|
export type ProviderFormat = 'openai' | 'openai.responses' | 'google';
|
|
3
|
-
export declare function toChatCtx(format: ProviderFormat, chatCtx: ChatContext, injectDummyUserMessage?: boolean): Promise<[Record<string, unknown>[], import("./google.js").GoogleFormatData]
|
|
3
|
+
export declare function toChatCtx(format: ProviderFormat, chatCtx: ChatContext, injectDummyUserMessage?: boolean): Promise<Record<string, any>[] | [Record<string, unknown>[], import("./google.js").GoogleFormatData]>;
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { ChatContext } from '../chat_context.js';
|
|
2
2
|
export type ProviderFormat = 'openai' | 'openai.responses' | 'google';
|
|
3
|
-
export declare function toChatCtx(format: ProviderFormat, chatCtx: ChatContext, injectDummyUserMessage?: boolean): Promise<[Record<string, unknown>[], import("./google.js").GoogleFormatData]
|
|
3
|
+
export declare function toChatCtx(format: ProviderFormat, chatCtx: ChatContext, injectDummyUserMessage?: boolean): Promise<Record<string, any>[] | [Record<string, unknown>[], import("./google.js").GoogleFormatData]>;
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -19,6 +19,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
19
19
|
var tool_context_exports = {};
|
|
20
20
|
__export(tool_context_exports, {
|
|
21
21
|
ToolError: () => ToolError,
|
|
22
|
+
ToolFlag: () => ToolFlag,
|
|
22
23
|
handoff: () => handoff,
|
|
23
24
|
isAgentHandoff: () => isAgentHandoff,
|
|
24
25
|
isFunctionTool: () => isFunctionTool,
|
|
@@ -45,6 +46,10 @@ class ToolError extends Error {
|
|
|
45
46
|
});
|
|
46
47
|
}
|
|
47
48
|
}
|
|
49
|
+
const ToolFlag = {
|
|
50
|
+
NONE: 0,
|
|
51
|
+
IGNORE_ON_ENTER: 1 << 0
|
|
52
|
+
};
|
|
48
53
|
function handoff(options) {
|
|
49
54
|
return {
|
|
50
55
|
agent: options.agent,
|
|
@@ -102,6 +107,7 @@ function tool(tool2) {
|
|
|
102
107
|
description: tool2.description,
|
|
103
108
|
parameters,
|
|
104
109
|
execute: tool2.execute,
|
|
110
|
+
flags: tool2.flags ?? ToolFlag.NONE,
|
|
105
111
|
[TOOL_SYMBOL]: true,
|
|
106
112
|
[FUNCTION_TOOL_SYMBOL]: true
|
|
107
113
|
};
|
|
@@ -139,6 +145,7 @@ function isAgentHandoff(handoff2) {
|
|
|
139
145
|
// Annotate the CommonJS export names for ESM import in node:
|
|
140
146
|
0 && (module.exports = {
|
|
141
147
|
ToolError,
|
|
148
|
+
ToolFlag,
|
|
142
149
|
handoff,
|
|
143
150
|
isAgentHandoff,
|
|
144
151
|
isFunctionTool,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/llm/tool_context.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport type { JSONSchema7 } from 'json-schema';\nimport { z } from 'zod';\nimport type { Agent } from '../voice/agent.js';\nimport type { RunContext, UnknownUserData } from '../voice/run_context.js';\nimport { isZodObjectSchema, isZodSchema } from './zod-utils.js';\n\n// heavily inspired by Vercel AI's `tool()`:\n// https://github.com/vercel/ai/blob/3b0983b/packages/ai/core/tool/tool.ts\n\nconst TOOL_SYMBOL = Symbol('tool');\nconst FUNCTION_TOOL_SYMBOL = Symbol('function_tool');\nconst PROVIDER_DEFINED_TOOL_SYMBOL = Symbol('provider_defined_tool');\nconst TOOL_ERROR_SYMBOL = Symbol('tool_error');\nconst HANDOFF_SYMBOL = Symbol('handoff');\n\nexport type JSONValue = null | string | number | boolean | JSONObject | JSONArray;\n\nexport type JSONArray = JSONValue[];\n\nexport type JSONObject = {\n [key: string]: JSONValue;\n};\n\n// Supports both Zod v3 and v4 schemas, as well as raw JSON schema\n// Adapted from Vercel AI SDK's FlexibleSchema approach\n// Source: https://github.com/vercel/ai/blob/main/packages/provider-utils/src/schema.ts#L67-L70\n//\n// Vercel uses StandardSchemaV1 from @standard-schema/spec package.\n// We use a simpler approach by directly checking for schema properties:\n// - Zod v3: Has `_output` property\n// - Zod v4: Implements Standard Schema spec with `~standard` property\n// - JSON Schema: Plain object fallback\nexport type ToolInputSchema<T = JSONObject> =\n | {\n // Zod v3 schema - has _output property for type inference\n _output: T;\n }\n | {\n // Zod v4 schema (Standard Schema) - has ~standard property\n '~standard': {\n types?: { output: T };\n };\n }\n | JSONSchema7;\n\n/**\n * Infer the output type from a ToolInputSchema.\n * Adapted from Vercel AI SDK's InferSchema type.\n * Source: https://github.com/vercel/ai/blob/main/packages/provider-utils/src/schema.ts#L72-L79\n */\nexport type InferToolInput<T> = T extends { _output: infer O }\n ? O\n : T extends { '~standard': { types?: { output: infer O } } }\n ? O\n : any; // eslint-disable-line @typescript-eslint/no-explicit-any -- Fallback type for JSON Schema objects without type inference\n\nexport type ToolType = 'function' | 'provider-defined';\n\nexport type ToolChoice =\n | 'auto'\n | 'none'\n | 'required'\n | {\n type: 'function';\n function: {\n name: string;\n };\n };\n\nexport class ToolError extends Error {\n constructor(message: string) {\n super(message);\n\n Object.defineProperty(this, TOOL_ERROR_SYMBOL, {\n value: true,\n });\n }\n}\n\nexport interface AgentHandoff {\n /**\n * The agent to handoff to.\n */\n agent: Agent;\n\n /**\n * The return value of the tool.\n */\n returns?: any; // eslint-disable-line @typescript-eslint/no-explicit-any\n\n [HANDOFF_SYMBOL]: true;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function handoff(options: { agent: Agent; returns?: any }): AgentHandoff {\n return {\n agent: options.agent,\n returns: options.returns,\n [HANDOFF_SYMBOL]: true,\n };\n}\n\nexport interface ToolOptions<UserData = UnknownUserData> {\n /**\n * RunContext for the current agent session.\n */\n ctx: RunContext<UserData>;\n\n /**\n * The ID of the tool call.\n */\n toolCallId: string;\n\n /**\n * An optional abort signal that indicates that the overall operation should be aborted.\n */\n abortSignal?: AbortSignal;\n}\n\nexport type ToolExecuteFunction<\n Parameters extends JSONObject,\n UserData = UnknownUserData,\n Result = unknown,\n> = (args: Parameters, opts: ToolOptions<UserData>) => Promise<Result>;\n\nexport interface Tool {\n /**\n * The type of the tool.\n * @internal Either user-defined core tool or provider-defined tool.\n */\n type: ToolType;\n\n [TOOL_SYMBOL]: true;\n}\n\n// TODO(AJS-112): support provider-defined tools\nexport interface ProviderDefinedTool extends Tool {\n type: 'provider-defined';\n\n /**\n * The ID of the tool.\n */\n id: string;\n\n /**\n * The configuration of the tool.\n */\n config: Record<string, unknown>;\n\n [PROVIDER_DEFINED_TOOL_SYMBOL]: true;\n}\n\nexport interface FunctionTool<\n Parameters extends JSONObject,\n UserData = UnknownUserData,\n Result = unknown,\n> extends Tool {\n type: 'function';\n\n /**\n * The description of the tool. Will be used by the language model to decide whether to use the tool.\n */\n description: string;\n\n /**\n * The schema of the input that the tool expects. The language model will use this to generate the input.\n * It is also used to validate the output of the language model.\n * Use descriptions to make the input understandable for the language model.\n */\n parameters: ToolInputSchema<Parameters>;\n\n /**\n * An async function that is called with the arguments from the tool call and produces a result.\n * It also carries context about current session, user-defined data, and the tool call id, etc.\n */\n execute: ToolExecuteFunction<Parameters, UserData, Result>;\n\n [FUNCTION_TOOL_SYMBOL]: true;\n}\n\n// TODO(AJS-112): support provider-defined tools in the future)\nexport type ToolContext<UserData = UnknownUserData> = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- Generic tool registry needs to accept any parameter/result types\n [name: string]: FunctionTool<any, UserData, any>;\n};\n\nexport function isSameToolContext(ctx1: ToolContext, ctx2: ToolContext): boolean {\n const toolNames = new Set(Object.keys(ctx1));\n const toolNames2 = new Set(Object.keys(ctx2));\n\n if (toolNames.size !== toolNames2.size) {\n return false;\n }\n\n for (const name of toolNames) {\n if (!toolNames2.has(name)) {\n return false;\n }\n\n const tool1 = ctx1[name];\n const tool2 = ctx2[name];\n\n if (!tool1 || !tool2) {\n return false;\n }\n\n if (tool1.description !== tool2.description) {\n return false;\n }\n }\n\n return true;\n}\n\nexport function isSameToolChoice(choice1: ToolChoice | null, choice2: ToolChoice | null): boolean {\n if (choice1 === choice2) {\n return true;\n }\n if (choice1 === null || choice2 === null) {\n return false;\n }\n if (typeof choice1 === 'string' && typeof choice2 === 'string') {\n return choice1 === choice2;\n }\n if (typeof choice1 === 'object' && typeof choice2 === 'object') {\n return choice1.type === choice2.type && choice1.function.name === choice2.function.name;\n }\n return false;\n}\n\n/**\n * Create a function tool with inferred parameters from the schema.\n */\nexport function tool<\n Schema extends ToolInputSchema<any>, // eslint-disable-line @typescript-eslint/no-explicit-any -- Generic constraint needs to accept any JSONObject type\n UserData = UnknownUserData,\n Result = unknown,\n>({\n description,\n parameters,\n execute,\n}: {\n description: string;\n parameters: Schema;\n execute: ToolExecuteFunction<InferToolInput<Schema>, UserData, Result>;\n}): FunctionTool<InferToolInput<Schema>, UserData, Result>;\n\n/**\n * Create a function tool without parameters.\n */\nexport function tool<UserData = UnknownUserData, Result = unknown>({\n description,\n execute,\n}: {\n description: string;\n parameters?: never;\n execute: ToolExecuteFunction<Record<string, never>, UserData, Result>;\n}): FunctionTool<Record<string, never>, UserData, Result>;\n\n/**\n * Create a provider-defined tool.\n *\n * @param id - The ID of the tool.\n * @param config - The configuration of the tool.\n */\nexport function tool({\n id,\n config,\n}: {\n id: string;\n config: Record<string, unknown>;\n}): ProviderDefinedTool;\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function tool(tool: any): any {\n if (tool.execute !== undefined) {\n // Default parameters to z.object({}) if not provided\n const parameters = tool.parameters ?? z.object({});\n\n // if parameters is a Zod schema, ensure it's an object schema\n if (isZodSchema(parameters) && !isZodObjectSchema(parameters)) {\n throw new Error('Tool parameters must be a Zod object schema (z.object(...))');\n }\n\n // Ensure parameters is either a Zod schema or a plain object (JSON schema)\n if (!isZodSchema(parameters) && !(typeof parameters === 'object')) {\n throw new Error('Tool parameters must be a Zod object schema or a raw JSON schema');\n }\n\n return {\n type: 'function',\n description: tool.description,\n parameters,\n execute: tool.execute,\n [TOOL_SYMBOL]: true,\n [FUNCTION_TOOL_SYMBOL]: true,\n };\n }\n\n if (tool.config !== undefined && tool.id !== undefined) {\n return {\n type: 'provider-defined',\n id: tool.id,\n config: tool.config,\n [TOOL_SYMBOL]: true,\n [PROVIDER_DEFINED_TOOL_SYMBOL]: true,\n };\n }\n\n throw new Error('Invalid tool');\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function isTool(tool: any): tool is Tool {\n return tool && tool[TOOL_SYMBOL] === true;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function isFunctionTool(tool: any): tool is FunctionTool<any, any, any> {\n const isTool = tool && tool[TOOL_SYMBOL] === true;\n const isFunctionTool = tool[FUNCTION_TOOL_SYMBOL] === true;\n return isTool && isFunctionTool;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function isProviderDefinedTool(tool: any): tool is ProviderDefinedTool {\n const isTool = tool && tool[TOOL_SYMBOL] === true;\n const isProviderDefinedTool = tool[PROVIDER_DEFINED_TOOL_SYMBOL] === true;\n return isTool && isProviderDefinedTool;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function isToolError(error: any): error is ToolError {\n return error && error[TOOL_ERROR_SYMBOL] === true;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function isAgentHandoff(handoff: any): handoff is AgentHandoff {\n return handoff && handoff[HANDOFF_SYMBOL] === true;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,iBAAkB;AAGlB,uBAA+C;AAK/C,MAAM,cAAc,OAAO,MAAM;AACjC,MAAM,uBAAuB,OAAO,eAAe;AACnD,MAAM,+BAA+B,OAAO,uBAAuB;AACnE,MAAM,oBAAoB,OAAO,YAAY;AAC7C,MAAM,iBAAiB,OAAO,SAAS;AAwDhC,MAAM,kBAAkB,MAAM;AAAA,EACnC,YAAY,SAAiB;AAC3B,UAAM,OAAO;AAEb,WAAO,eAAe,MAAM,mBAAmB;AAAA,MAC7C,OAAO;AAAA,IACT,CAAC;AAAA,EACH;AACF;AAiBO,SAAS,QAAQ,SAAwD;AAC9E,SAAO;AAAA,IACL,OAAO,QAAQ;AAAA,IACf,SAAS,QAAQ;AAAA,IACjB,CAAC,cAAc,GAAG;AAAA,EACpB;AACF;AAsFO,SAAS,kBAAkB,MAAmB,MAA4B;AAC/E,QAAM,YAAY,IAAI,IAAI,OAAO,KAAK,IAAI,CAAC;AAC3C,QAAM,aAAa,IAAI,IAAI,OAAO,KAAK,IAAI,CAAC;AAE5C,MAAI,UAAU,SAAS,WAAW,MAAM;AACtC,WAAO;AAAA,EACT;AAEA,aAAW,QAAQ,WAAW;AAC5B,QAAI,CAAC,WAAW,IAAI,IAAI,GAAG;AACzB,aAAO;AAAA,IACT;AAEA,UAAM,QAAQ,KAAK,IAAI;AACvB,UAAM,QAAQ,KAAK,IAAI;AAEvB,QAAI,CAAC,SAAS,CAAC,OAAO;AACpB,aAAO;AAAA,IACT;AAEA,QAAI,MAAM,gBAAgB,MAAM,aAAa;AAC3C,aAAO;AAAA,IACT;AAAA,EACF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C7E,QAAMC,UAASD,SAAQA,MAAK,WAAW,MAAM;AAC7C,QAAME,kBAAiBF,MAAK,oBAAoB,MAAM;AACtD,SAAOC,WAAUC;AACnB;AAGO,SAAS,sBAAsBF,OAAwC;AAC5E,QAAMC,UAASD,SAAQA,MAAK,WAAW,MAAM;AAC7C,QAAMG,yBAAwBH,MAAK,4BAA4B,MAAM;AACrE,SAAOC,WAAUE;AACnB;AAGO,SAAS,YAAY,OAAgC;AAC1D,SAAO,SAAS,MAAM,iBAAiB,MAAM;AAC/C;AAGO,SAAS,eAAeC,UAAuC;AACpE,SAAOA,YAAWA,SAAQ,cAAc,MAAM;AAChD;","names":["tool","isTool","isFunctionTool","isProviderDefinedTool","handoff"]}
|
|
1
|
+
{"version":3,"sources":["../../src/llm/tool_context.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport type { JSONSchema7 } from 'json-schema';\nimport { z } from 'zod';\nimport type { Agent } from '../voice/agent.js';\nimport type { RunContext, UnknownUserData } from '../voice/run_context.js';\nimport { isZodObjectSchema, isZodSchema } from './zod-utils.js';\n\n// heavily inspired by Vercel AI's `tool()`:\n// https://github.com/vercel/ai/blob/3b0983b/packages/ai/core/tool/tool.ts\n\nconst TOOL_SYMBOL = Symbol('tool');\nconst FUNCTION_TOOL_SYMBOL = Symbol('function_tool');\nconst PROVIDER_DEFINED_TOOL_SYMBOL = Symbol('provider_defined_tool');\nconst TOOL_ERROR_SYMBOL = Symbol('tool_error');\nconst HANDOFF_SYMBOL = Symbol('handoff');\n\nexport type JSONValue = null | string | number | boolean | JSONObject | JSONArray;\n\nexport type JSONArray = JSONValue[];\n\nexport type JSONObject = {\n [key: string]: JSONValue;\n};\n\n// Supports both Zod v3 and v4 schemas, as well as raw JSON schema\n// Adapted from Vercel AI SDK's FlexibleSchema approach\n// Source: https://github.com/vercel/ai/blob/main/packages/provider-utils/src/schema.ts#L67-L70\n//\n// Vercel uses StandardSchemaV1 from @standard-schema/spec package.\n// We use a simpler approach by directly checking for schema properties:\n// - Zod v3: Has `_output` property\n// - Zod v4: Implements Standard Schema spec with `~standard` property\n// - JSON Schema: Plain object fallback\nexport type ToolInputSchema<T = JSONObject> =\n | {\n // Zod v3 schema - has _output property for type inference\n _output: T;\n }\n | {\n // Zod v4 schema (Standard Schema) - has ~standard property\n '~standard': {\n types?: { output: T };\n };\n }\n | JSONSchema7;\n\n/**\n * Infer the output type from a ToolInputSchema.\n * Adapted from Vercel AI SDK's InferSchema type.\n * Source: https://github.com/vercel/ai/blob/main/packages/provider-utils/src/schema.ts#L72-L79\n */\nexport type InferToolInput<T> = T extends { _output: infer O }\n ? O\n : T extends { '~standard': { types?: { output: infer O } } }\n ? O\n : any; // eslint-disable-line @typescript-eslint/no-explicit-any -- Fallback type for JSON Schema objects without type inference\n\nexport type ToolType = 'function' | 'provider-defined';\n\nexport type ToolChoice =\n | 'auto'\n | 'none'\n | 'required'\n | {\n type: 'function';\n function: {\n name: string;\n };\n };\n\nexport class ToolError extends Error {\n constructor(message: string) {\n super(message);\n\n Object.defineProperty(this, TOOL_ERROR_SYMBOL, {\n value: true,\n });\n }\n}\n\nexport const ToolFlag = {\n NONE: 0,\n IGNORE_ON_ENTER: 1 << 0,\n} as const;\n\nexport type ToolFlag = (typeof ToolFlag)[keyof typeof ToolFlag];\n\nexport interface AgentHandoff {\n /**\n * The agent to handoff to.\n */\n agent: Agent;\n\n /**\n * The return value of the tool.\n */\n returns?: any; // eslint-disable-line @typescript-eslint/no-explicit-any\n\n [HANDOFF_SYMBOL]: true;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function handoff(options: { agent: Agent; returns?: any }): AgentHandoff {\n return {\n agent: options.agent,\n returns: options.returns,\n [HANDOFF_SYMBOL]: true,\n };\n}\n\nexport interface ToolOptions<UserData = UnknownUserData> {\n /**\n * RunContext for the current agent session.\n */\n ctx: RunContext<UserData>;\n\n /**\n * The ID of the tool call.\n */\n toolCallId: string;\n\n /**\n * An optional abort signal that indicates that the overall operation should be aborted.\n */\n abortSignal?: AbortSignal;\n}\n\nexport type ToolExecuteFunction<\n Parameters extends JSONObject,\n UserData = UnknownUserData,\n Result = unknown,\n> = (args: Parameters, opts: ToolOptions<UserData>) => Promise<Result>;\n\nexport interface Tool {\n /**\n * The type of the tool.\n * @internal Either user-defined core tool or provider-defined tool.\n */\n type: ToolType;\n\n [TOOL_SYMBOL]: true;\n}\n\n// TODO(AJS-112): support provider-defined tools\nexport interface ProviderDefinedTool extends Tool {\n type: 'provider-defined';\n\n /**\n * The ID of the tool.\n */\n id: string;\n\n /**\n * The configuration of the tool.\n */\n config: Record<string, unknown>;\n\n [PROVIDER_DEFINED_TOOL_SYMBOL]: true;\n}\n\nexport interface FunctionTool<\n Parameters extends JSONObject,\n UserData = UnknownUserData,\n Result = unknown,\n> extends Tool {\n type: 'function';\n\n /**\n * The description of the tool. Will be used by the language model to decide whether to use the tool.\n */\n description: string;\n\n /**\n * The schema of the input that the tool expects. The language model will use this to generate the input.\n * It is also used to validate the output of the language model.\n * Use descriptions to make the input understandable for the language model.\n */\n parameters: ToolInputSchema<Parameters>;\n\n /**\n * An async function that is called with the arguments from the tool call and produces a result.\n * It also carries context about current session, user-defined data, and the tool call id, etc.\n */\n execute: ToolExecuteFunction<Parameters, UserData, Result>;\n\n flags: number;\n\n [FUNCTION_TOOL_SYMBOL]: true;\n}\n\n// TODO(AJS-112): support provider-defined tools in the future)\nexport type ToolContext<UserData = UnknownUserData> = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- Generic tool registry needs to accept any parameter/result types\n [name: string]: FunctionTool<any, UserData, any>;\n};\n\nexport function isSameToolContext(ctx1: ToolContext, ctx2: ToolContext): boolean {\n const toolNames = new Set(Object.keys(ctx1));\n const toolNames2 = new Set(Object.keys(ctx2));\n\n if (toolNames.size !== toolNames2.size) {\n return false;\n }\n\n for (const name of toolNames) {\n if (!toolNames2.has(name)) {\n return false;\n }\n\n const tool1 = ctx1[name];\n const tool2 = ctx2[name];\n\n if (!tool1 || !tool2) {\n return false;\n }\n\n if (tool1.description !== tool2.description) {\n return false;\n }\n }\n\n return true;\n}\n\nexport function isSameToolChoice(choice1: ToolChoice | null, choice2: ToolChoice | null): boolean {\n if (choice1 === choice2) {\n return true;\n }\n if (choice1 === null || choice2 === null) {\n return false;\n }\n if (typeof choice1 === 'string' && typeof choice2 === 'string') {\n return choice1 === choice2;\n }\n if (typeof choice1 === 'object' && typeof choice2 === 'object') {\n return choice1.type === choice2.type && choice1.function.name === choice2.function.name;\n }\n return false;\n}\n\n/**\n * Create a function tool with inferred parameters from the schema.\n */\nexport function tool<\n Schema extends ToolInputSchema<any>, // eslint-disable-line @typescript-eslint/no-explicit-any -- Generic constraint needs to accept any JSONObject type\n UserData = UnknownUserData,\n Result = unknown,\n>({\n description,\n parameters,\n execute,\n flags,\n}: {\n description: string;\n parameters: Schema;\n execute: ToolExecuteFunction<InferToolInput<Schema>, UserData, Result>;\n flags?: number;\n}): FunctionTool<InferToolInput<Schema>, UserData, Result>;\n\n/**\n * Create a function tool without parameters.\n */\nexport function tool<UserData = UnknownUserData, Result = unknown>({\n description,\n execute,\n flags,\n}: {\n description: string;\n parameters?: never;\n execute: ToolExecuteFunction<Record<string, never>, UserData, Result>;\n flags?: number;\n}): FunctionTool<Record<string, never>, UserData, Result>;\n\n/**\n * Create a provider-defined tool.\n *\n * @param id - The ID of the tool.\n * @param config - The configuration of the tool.\n */\nexport function tool({\n id,\n config,\n}: {\n id: string;\n config: Record<string, unknown>;\n}): ProviderDefinedTool;\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function tool(tool: any): any {\n if (tool.execute !== undefined) {\n // Default parameters to z.object({}) if not provided\n const parameters = tool.parameters ?? z.object({});\n\n // if parameters is a Zod schema, ensure it's an object schema\n if (isZodSchema(parameters) && !isZodObjectSchema(parameters)) {\n throw new Error('Tool parameters must be a Zod object schema (z.object(...))');\n }\n\n // Ensure parameters is either a Zod schema or a plain object (JSON schema)\n if (!isZodSchema(parameters) && !(typeof parameters === 'object')) {\n throw new Error('Tool parameters must be a Zod object schema or a raw JSON schema');\n }\n\n return {\n type: 'function',\n description: tool.description,\n parameters,\n execute: tool.execute,\n flags: tool.flags ?? ToolFlag.NONE,\n [TOOL_SYMBOL]: true,\n [FUNCTION_TOOL_SYMBOL]: true,\n };\n }\n\n if (tool.config !== undefined && tool.id !== undefined) {\n return {\n type: 'provider-defined',\n id: tool.id,\n config: tool.config,\n [TOOL_SYMBOL]: true,\n [PROVIDER_DEFINED_TOOL_SYMBOL]: true,\n };\n }\n\n throw new Error('Invalid tool');\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function isTool(tool: any): tool is Tool {\n return tool && tool[TOOL_SYMBOL] === true;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function isFunctionTool(tool: any): tool is FunctionTool<any, any, any> {\n const isTool = tool && tool[TOOL_SYMBOL] === true;\n const isFunctionTool = tool[FUNCTION_TOOL_SYMBOL] === true;\n return isTool && isFunctionTool;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function isProviderDefinedTool(tool: any): tool is ProviderDefinedTool {\n const isTool = tool && tool[TOOL_SYMBOL] === true;\n const isProviderDefinedTool = tool[PROVIDER_DEFINED_TOOL_SYMBOL] === true;\n return isTool && isProviderDefinedTool;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function isToolError(error: any): error is ToolError {\n return error && error[TOOL_ERROR_SYMBOL] === true;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function isAgentHandoff(handoff: any): handoff is AgentHandoff {\n return handoff && handoff[HANDOFF_SYMBOL] === true;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,iBAAkB;AAGlB,u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A,MAAK,WAAW,MAAM;AAC7C,QAAMG,yBAAwBH,MAAK,4BAA4B,MAAM;AACrE,SAAOC,WAAUE;AACnB;AAGO,SAAS,YAAY,OAAgC;AAC1D,SAAO,SAAS,MAAM,iBAAiB,MAAM;AAC/C;AAGO,SAAS,eAAeC,UAAuC;AACpE,SAAOA,YAAWA,SAAQ,cAAc,MAAM;AAChD;","names":["tool","isTool","isFunctionTool","isProviderDefinedTool","handoff"]}
|
|
@@ -43,6 +43,11 @@ export type ToolChoice = 'auto' | 'none' | 'required' | {
|
|
|
43
43
|
export declare class ToolError extends Error {
|
|
44
44
|
constructor(message: string);
|
|
45
45
|
}
|
|
46
|
+
export declare const ToolFlag: {
|
|
47
|
+
readonly NONE: 0;
|
|
48
|
+
readonly IGNORE_ON_ENTER: number;
|
|
49
|
+
};
|
|
50
|
+
export type ToolFlag = (typeof ToolFlag)[keyof typeof ToolFlag];
|
|
46
51
|
export interface AgentHandoff {
|
|
47
52
|
/**
|
|
48
53
|
* The agent to handoff to.
|
|
@@ -110,6 +115,7 @@ export interface FunctionTool<Parameters extends JSONObject, UserData = UnknownU
|
|
|
110
115
|
* It also carries context about current session, user-defined data, and the tool call id, etc.
|
|
111
116
|
*/
|
|
112
117
|
execute: ToolExecuteFunction<Parameters, UserData, Result>;
|
|
118
|
+
flags: number;
|
|
113
119
|
[FUNCTION_TOOL_SYMBOL]: true;
|
|
114
120
|
}
|
|
115
121
|
export type ToolContext<UserData = UnknownUserData> = {
|
|
@@ -121,18 +127,20 @@ export declare function isSameToolChoice(choice1: ToolChoice | null, choice2: To
|
|
|
121
127
|
* Create a function tool with inferred parameters from the schema.
|
|
122
128
|
*/
|
|
123
129
|
export declare function tool<Schema extends ToolInputSchema<any>, // eslint-disable-line @typescript-eslint/no-explicit-any -- Generic constraint needs to accept any JSONObject type
|
|
124
|
-
UserData = UnknownUserData, Result = unknown>({ description, parameters, execute, }: {
|
|
130
|
+
UserData = UnknownUserData, Result = unknown>({ description, parameters, execute, flags, }: {
|
|
125
131
|
description: string;
|
|
126
132
|
parameters: Schema;
|
|
127
133
|
execute: ToolExecuteFunction<InferToolInput<Schema>, UserData, Result>;
|
|
134
|
+
flags?: number;
|
|
128
135
|
}): FunctionTool<InferToolInput<Schema>, UserData, Result>;
|
|
129
136
|
/**
|
|
130
137
|
* Create a function tool without parameters.
|
|
131
138
|
*/
|
|
132
|
-
export declare function tool<UserData = UnknownUserData, Result = unknown>({ description, execute, }: {
|
|
139
|
+
export declare function tool<UserData = UnknownUserData, Result = unknown>({ description, execute, flags, }: {
|
|
133
140
|
description: string;
|
|
134
141
|
parameters?: never;
|
|
135
142
|
execute: ToolExecuteFunction<Record<string, never>, UserData, Result>;
|
|
143
|
+
flags?: number;
|
|
136
144
|
}): FunctionTool<Record<string, never>, UserData, Result>;
|
|
137
145
|
/**
|
|
138
146
|
* Create a provider-defined tool.
|
|
@@ -43,6 +43,11 @@ export type ToolChoice = 'auto' | 'none' | 'required' | {
|
|
|
43
43
|
export declare class ToolError extends Error {
|
|
44
44
|
constructor(message: string);
|
|
45
45
|
}
|
|
46
|
+
export declare const ToolFlag: {
|
|
47
|
+
readonly NONE: 0;
|
|
48
|
+
readonly IGNORE_ON_ENTER: number;
|
|
49
|
+
};
|
|
50
|
+
export type ToolFlag = (typeof ToolFlag)[keyof typeof ToolFlag];
|
|
46
51
|
export interface AgentHandoff {
|
|
47
52
|
/**
|
|
48
53
|
* The agent to handoff to.
|
|
@@ -110,6 +115,7 @@ export interface FunctionTool<Parameters extends JSONObject, UserData = UnknownU
|
|
|
110
115
|
* It also carries context about current session, user-defined data, and the tool call id, etc.
|
|
111
116
|
*/
|
|
112
117
|
execute: ToolExecuteFunction<Parameters, UserData, Result>;
|
|
118
|
+
flags: number;
|
|
113
119
|
[FUNCTION_TOOL_SYMBOL]: true;
|
|
114
120
|
}
|
|
115
121
|
export type ToolContext<UserData = UnknownUserData> = {
|
|
@@ -121,18 +127,20 @@ export declare function isSameToolChoice(choice1: ToolChoice | null, choice2: To
|
|
|
121
127
|
* Create a function tool with inferred parameters from the schema.
|
|
122
128
|
*/
|
|
123
129
|
export declare function tool<Schema extends ToolInputSchema<any>, // eslint-disable-line @typescript-eslint/no-explicit-any -- Generic constraint needs to accept any JSONObject type
|
|
124
|
-
UserData = UnknownUserData, Result = unknown>({ description, parameters, execute, }: {
|
|
130
|
+
UserData = UnknownUserData, Result = unknown>({ description, parameters, execute, flags, }: {
|
|
125
131
|
description: string;
|
|
126
132
|
parameters: Schema;
|
|
127
133
|
execute: ToolExecuteFunction<InferToolInput<Schema>, UserData, Result>;
|
|
134
|
+
flags?: number;
|
|
128
135
|
}): FunctionTool<InferToolInput<Schema>, UserData, Result>;
|
|
129
136
|
/**
|
|
130
137
|
* Create a function tool without parameters.
|
|
131
138
|
*/
|
|
132
|
-
export declare function tool<UserData = UnknownUserData, Result = unknown>({ description, execute, }: {
|
|
139
|
+
export declare function tool<UserData = UnknownUserData, Result = unknown>({ description, execute, flags, }: {
|
|
133
140
|
description: string;
|
|
134
141
|
parameters?: never;
|
|
135
142
|
execute: ToolExecuteFunction<Record<string, never>, UserData, Result>;
|
|
143
|
+
flags?: number;
|
|
136
144
|
}): FunctionTool<Record<string, never>, UserData, Result>;
|
|
137
145
|
/**
|
|
138
146
|
* Create a provider-defined tool.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool_context.d.ts","sourceRoot":"","sources":["../../src/llm/tool_context.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAM3E,QAAA,MAAM,WAAW,eAAiB,CAAC;AACnC,QAAA,MAAM,oBAAoB,eAA0B,CAAC;AACrD,QAAA,MAAM,4BAA4B,eAAkC,CAAC;AAErE,QAAA,MAAM,cAAc,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AC;AAE1D;;;;;GAKG;AACH,wBAAgB,IAAI,CAAC,EACnB,EAAE,EACF,MAAM,GACP,EAAE;IACD,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC,GAAG,mBAAmB,CAAC;AA2CxB,wBAAgB,MAAM,CAAC,IAAI,EAAE,GAAG,GAAG,IAAI,IAAI,IAAI,CAE9C;AAGD,wBAAgB,cAAc,CAAC,IAAI,EAAE,GAAG,GAAG,IAAI,IAAI,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAI7E;AAGD,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,GAAG,GAAG,IAAI,IAAI,mBAAmB,CAI5E;AAGD,wBAAgB,WAAW,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,SAAS,CAE1D;AAGD,wBAAgB,cAAc,CAAC,OAAO,EAAE,GAAG,GAAG,OAAO,IAAI,YAAY,CAEpE"}
|
package/dist/llm/tool_context.js
CHANGED
|
@@ -13,6 +13,10 @@ class ToolError extends Error {
|
|
|
13
13
|
});
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
|
+
const ToolFlag = {
|
|
17
|
+
NONE: 0,
|
|
18
|
+
IGNORE_ON_ENTER: 1 << 0
|
|
19
|
+
};
|
|
16
20
|
function handoff(options) {
|
|
17
21
|
return {
|
|
18
22
|
agent: options.agent,
|
|
@@ -70,6 +74,7 @@ function tool(tool2) {
|
|
|
70
74
|
description: tool2.description,
|
|
71
75
|
parameters,
|
|
72
76
|
execute: tool2.execute,
|
|
77
|
+
flags: tool2.flags ?? ToolFlag.NONE,
|
|
73
78
|
[TOOL_SYMBOL]: true,
|
|
74
79
|
[FUNCTION_TOOL_SYMBOL]: true
|
|
75
80
|
};
|
|
@@ -106,6 +111,7 @@ function isAgentHandoff(handoff2) {
|
|
|
106
111
|
}
|
|
107
112
|
export {
|
|
108
113
|
ToolError,
|
|
114
|
+
ToolFlag,
|
|
109
115
|
handoff,
|
|
110
116
|
isAgentHandoff,
|
|
111
117
|
isFunctionTool,
|