agent-orcha 0.0.4 → 0.0.7
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/README.md +216 -1323
- package/dist/lib/agents/agent-executor.d.ts +15 -4
- package/dist/lib/agents/agent-executor.d.ts.map +1 -1
- package/dist/lib/agents/agent-executor.js +337 -87
- package/dist/lib/agents/agent-executor.js.map +1 -1
- package/dist/lib/agents/agent-loader.d.ts +4 -1
- package/dist/lib/agents/agent-loader.d.ts.map +1 -1
- package/dist/lib/agents/agent-loader.js +20 -4
- package/dist/lib/agents/agent-loader.js.map +1 -1
- package/dist/lib/agents/index.d.ts +5 -5
- package/dist/lib/agents/index.js +4 -4
- package/dist/lib/agents/react-loop.d.ts +30 -0
- package/dist/lib/agents/react-loop.d.ts.map +1 -0
- package/dist/lib/agents/react-loop.js +193 -0
- package/dist/lib/agents/react-loop.js.map +1 -0
- package/dist/lib/agents/structured-output-wrapper.d.ts +3 -3
- package/dist/lib/agents/structured-output-wrapper.d.ts.map +1 -1
- package/dist/lib/agents/structured-output-wrapper.js +2 -2
- package/dist/lib/agents/structured-output-wrapper.js.map +1 -1
- package/dist/lib/agents/types.d.ts +306 -19
- package/dist/lib/agents/types.d.ts.map +1 -1
- package/dist/lib/agents/types.js +34 -4
- package/dist/lib/agents/types.js.map +1 -1
- package/dist/lib/functions/function-loader.d.ts +3 -1
- package/dist/lib/functions/function-loader.d.ts.map +1 -1
- package/dist/lib/functions/function-loader.js +23 -5
- package/dist/lib/functions/function-loader.js.map +1 -1
- package/dist/lib/functions/index.d.ts +2 -2
- package/dist/lib/functions/index.js +1 -1
- package/dist/lib/functions/simple-function-wrapper.d.ts +2 -11
- package/dist/lib/functions/simple-function-wrapper.d.ts.map +1 -1
- package/dist/lib/functions/simple-function-wrapper.js +3 -3
- package/dist/lib/functions/simple-function-wrapper.js.map +1 -1
- package/dist/lib/index.d.ts +29 -17
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js +21 -9
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/integrations/collabnook.d.ts +56 -0
- package/dist/lib/integrations/collabnook.d.ts.map +1 -0
- package/dist/lib/integrations/collabnook.js +307 -0
- package/dist/lib/integrations/collabnook.js.map +1 -0
- package/dist/lib/integrations/email.d.ts +38 -0
- package/dist/lib/integrations/email.d.ts.map +1 -0
- package/dist/lib/integrations/email.js +249 -0
- package/dist/lib/integrations/email.js.map +1 -0
- package/dist/lib/integrations/integration-manager.d.ts +19 -0
- package/dist/lib/integrations/integration-manager.d.ts.map +1 -0
- package/dist/lib/integrations/integration-manager.js +159 -0
- package/dist/lib/integrations/integration-manager.js.map +1 -0
- package/dist/lib/integrations/types.d.ts +232 -0
- package/dist/lib/integrations/types.d.ts.map +1 -0
- package/dist/lib/integrations/types.js +37 -0
- package/dist/lib/integrations/types.js.map +1 -0
- package/dist/lib/knowledge/direct-mapper.d.ts +21 -0
- package/dist/lib/knowledge/direct-mapper.d.ts.map +1 -0
- package/dist/lib/knowledge/direct-mapper.js +134 -0
- package/dist/lib/knowledge/direct-mapper.js.map +1 -0
- package/dist/lib/knowledge/index.d.ts +9 -8
- package/dist/lib/knowledge/index.d.ts.map +1 -1
- package/dist/lib/knowledge/index.js +9 -7
- package/dist/lib/knowledge/index.js.map +1 -1
- package/dist/lib/knowledge/knowledge-store-metadata.d.ts +40 -0
- package/dist/lib/knowledge/knowledge-store-metadata.d.ts.map +1 -0
- package/dist/lib/knowledge/knowledge-store-metadata.js +93 -0
- package/dist/lib/knowledge/knowledge-store-metadata.js.map +1 -0
- package/dist/lib/knowledge/knowledge-store.d.ts +49 -0
- package/dist/lib/knowledge/knowledge-store.d.ts.map +1 -0
- package/dist/lib/knowledge/knowledge-store.js +670 -0
- package/dist/lib/knowledge/knowledge-store.js.map +1 -0
- package/dist/lib/knowledge/loaders/database-loader.d.ts +5 -5
- package/dist/lib/knowledge/loaders/database-loader.d.ts.map +1 -1
- package/dist/lib/knowledge/loaders/database-loader.js +21 -10
- package/dist/lib/knowledge/loaders/database-loader.js.map +1 -1
- package/dist/lib/knowledge/loaders/file-loaders.d.ts +45 -0
- package/dist/lib/knowledge/loaders/file-loaders.d.ts.map +1 -0
- package/dist/lib/knowledge/loaders/file-loaders.js +160 -0
- package/dist/lib/knowledge/loaders/file-loaders.js.map +1 -0
- package/dist/lib/knowledge/loaders/index.d.ts +3 -3
- package/dist/lib/knowledge/loaders/index.d.ts.map +1 -1
- package/dist/lib/knowledge/loaders/index.js +3 -3
- package/dist/lib/knowledge/loaders/index.js.map +1 -1
- package/dist/lib/knowledge/loaders/web-loader.d.ts +14 -5
- package/dist/lib/knowledge/loaders/web-loader.d.ts.map +1 -1
- package/dist/lib/knowledge/loaders/web-loader.js +64 -29
- package/dist/lib/knowledge/loaders/web-loader.js.map +1 -1
- package/dist/lib/knowledge/sqlite-store.d.ts +107 -0
- package/dist/lib/knowledge/sqlite-store.d.ts.map +1 -0
- package/dist/lib/knowledge/sqlite-store.js +327 -0
- package/dist/lib/knowledge/sqlite-store.js.map +1 -0
- package/dist/lib/knowledge/types.d.ts +124 -1448
- package/dist/lib/knowledge/types.d.ts.map +1 -1
- package/dist/lib/knowledge/types.js +54 -60
- package/dist/lib/knowledge/types.js.map +1 -1
- package/dist/lib/knowledge/utils/connection-pool.d.ts +3 -2
- package/dist/lib/knowledge/utils/connection-pool.d.ts.map +1 -1
- package/dist/lib/knowledge/utils/connection-pool.js +20 -10
- package/dist/lib/knowledge/utils/connection-pool.js.map +1 -1
- package/dist/lib/knowledge/utils/index.d.ts +2 -2
- package/dist/lib/knowledge/utils/index.js +2 -2
- package/dist/lib/llm/index.d.ts +5 -5
- package/dist/lib/llm/index.d.ts.map +1 -1
- package/dist/lib/llm/index.js +3 -3
- package/dist/lib/llm/index.js.map +1 -1
- package/dist/lib/llm/llm-call-logger.d.ts +39 -0
- package/dist/lib/llm/llm-call-logger.d.ts.map +1 -0
- package/dist/lib/llm/llm-call-logger.js +110 -0
- package/dist/lib/llm/llm-call-logger.js.map +1 -0
- package/dist/lib/llm/llm-config.d.ts +30 -16
- package/dist/lib/llm/llm-config.d.ts.map +1 -1
- package/dist/lib/llm/llm-config.js +22 -4
- package/dist/lib/llm/llm-config.js.map +1 -1
- package/dist/lib/llm/llm-factory.d.ts +3 -16
- package/dist/lib/llm/llm-factory.d.ts.map +1 -1
- package/dist/lib/llm/llm-factory.js +33 -48
- package/dist/lib/llm/llm-factory.js.map +1 -1
- package/dist/lib/llm/provider-detector.d.ts +1 -1
- package/dist/lib/llm/providers/anthropic-chat-model.d.ts +31 -0
- package/dist/lib/llm/providers/anthropic-chat-model.d.ts.map +1 -0
- package/dist/lib/llm/providers/anthropic-chat-model.js +262 -0
- package/dist/lib/llm/providers/anthropic-chat-model.js.map +1 -0
- package/dist/lib/llm/providers/gemini-chat-model.d.ts +30 -0
- package/dist/lib/llm/providers/gemini-chat-model.d.ts.map +1 -0
- package/dist/lib/llm/providers/gemini-chat-model.js +300 -0
- package/dist/lib/llm/providers/gemini-chat-model.js.map +1 -0
- package/dist/lib/llm/providers/gemini-embeddings.d.ts +14 -0
- package/dist/lib/llm/providers/gemini-embeddings.d.ts.map +1 -0
- package/dist/lib/llm/providers/gemini-embeddings.js +20 -0
- package/dist/lib/llm/providers/gemini-embeddings.js.map +1 -0
- package/dist/lib/llm/providers/openai-chat-model.d.ts +39 -0
- package/dist/lib/llm/providers/openai-chat-model.d.ts.map +1 -0
- package/dist/lib/llm/providers/openai-chat-model.js +397 -0
- package/dist/lib/llm/providers/openai-chat-model.js.map +1 -0
- package/dist/lib/llm/providers/openai-embeddings.d.ts +17 -0
- package/dist/lib/llm/providers/openai-embeddings.d.ts.map +1 -0
- package/dist/lib/llm/providers/openai-embeddings.js +35 -0
- package/dist/lib/llm/providers/openai-embeddings.js.map +1 -0
- package/dist/lib/llm/types.d.ts +2 -2
- package/dist/lib/llm/types.js +1 -1
- package/dist/lib/logger.d.ts +7 -0
- package/dist/lib/logger.d.ts.map +1 -1
- package/dist/lib/logger.js +42 -4
- package/dist/lib/logger.js.map +1 -1
- package/dist/lib/mcp/index.d.ts +3 -3
- package/dist/lib/mcp/index.js +2 -2
- package/dist/lib/mcp/mcp-client.d.ts +3 -2
- package/dist/lib/mcp/mcp-client.d.ts.map +1 -1
- package/dist/lib/mcp/mcp-client.js +10 -5
- package/dist/lib/mcp/mcp-client.js.map +1 -1
- package/dist/lib/mcp/types.d.ts +26 -25
- package/dist/lib/mcp/types.d.ts.map +1 -1
- package/dist/lib/mcp/types.js +12 -4
- package/dist/lib/mcp/types.js.map +1 -1
- package/dist/lib/memory/conversation-store.d.ts +2 -2
- package/dist/lib/memory/conversation-store.d.ts.map +1 -1
- package/dist/lib/memory/conversation-store.js +1 -1
- package/dist/lib/memory/index.d.ts +3 -2
- package/dist/lib/memory/index.d.ts.map +1 -1
- package/dist/lib/memory/index.js +3 -2
- package/dist/lib/memory/index.js.map +1 -1
- package/dist/lib/memory/memory-manager.d.ts +10 -0
- package/dist/lib/memory/memory-manager.d.ts.map +1 -0
- package/dist/lib/memory/memory-manager.js +43 -0
- package/dist/lib/memory/memory-manager.js.map +1 -0
- package/dist/lib/memory/types.d.ts +1 -1
- package/dist/lib/memory/types.d.ts.map +1 -1
- package/dist/lib/orchestrator.d.ts +72 -18
- package/dist/lib/orchestrator.d.ts.map +1 -1
- package/dist/lib/orchestrator.js +341 -56
- package/dist/lib/orchestrator.js.map +1 -1
- package/dist/lib/sandbox/cdp-client.d.ts +14 -0
- package/dist/lib/sandbox/cdp-client.d.ts.map +1 -0
- package/dist/lib/sandbox/cdp-client.js +113 -0
- package/dist/lib/sandbox/cdp-client.js.map +1 -0
- package/dist/lib/sandbox/html-to-markdown.d.ts +10 -0
- package/dist/lib/sandbox/html-to-markdown.d.ts.map +1 -0
- package/dist/lib/sandbox/html-to-markdown.js +121 -0
- package/dist/lib/sandbox/html-to-markdown.js.map +1 -0
- package/dist/lib/sandbox/index.d.ts +12 -0
- package/dist/lib/sandbox/index.d.ts.map +1 -0
- package/dist/lib/sandbox/index.js +10 -0
- package/dist/lib/sandbox/index.js.map +1 -0
- package/dist/lib/sandbox/page-readiness.d.ts +37 -0
- package/dist/lib/sandbox/page-readiness.d.ts.map +1 -0
- package/dist/lib/sandbox/page-readiness.js +235 -0
- package/dist/lib/sandbox/page-readiness.js.map +1 -0
- package/dist/lib/sandbox/sandbox-browser.d.ts +4 -0
- package/dist/lib/sandbox/sandbox-browser.d.ts.map +1 -0
- package/dist/lib/sandbox/sandbox-browser.js +303 -0
- package/dist/lib/sandbox/sandbox-browser.js.map +1 -0
- package/dist/lib/sandbox/sandbox-exec.d.ts +5 -0
- package/dist/lib/sandbox/sandbox-exec.d.ts.map +1 -0
- package/dist/lib/sandbox/sandbox-exec.js +35 -0
- package/dist/lib/sandbox/sandbox-exec.js.map +1 -0
- package/dist/lib/sandbox/sandbox-file.d.ts +4 -0
- package/dist/lib/sandbox/sandbox-file.d.ts.map +1 -0
- package/dist/lib/sandbox/sandbox-file.js +168 -0
- package/dist/lib/sandbox/sandbox-file.js.map +1 -0
- package/dist/lib/sandbox/sandbox-shell.d.ts +4 -0
- package/dist/lib/sandbox/sandbox-shell.d.ts.map +1 -0
- package/dist/lib/sandbox/sandbox-shell.js +93 -0
- package/dist/lib/sandbox/sandbox-shell.js.map +1 -0
- package/dist/lib/sandbox/sandbox-web.d.ts +5 -0
- package/dist/lib/sandbox/sandbox-web.d.ts.map +1 -0
- package/dist/lib/sandbox/sandbox-web.js +226 -0
- package/dist/lib/sandbox/sandbox-web.js.map +1 -0
- package/dist/lib/sandbox/types.d.ts +30 -0
- package/dist/lib/sandbox/types.d.ts.map +1 -0
- package/dist/lib/sandbox/types.js +8 -0
- package/dist/lib/sandbox/types.js.map +1 -0
- package/dist/lib/sandbox/vision-browser.d.ts +4 -0
- package/dist/lib/sandbox/vision-browser.d.ts.map +1 -0
- package/dist/lib/sandbox/vision-browser.js +289 -0
- package/dist/lib/sandbox/vision-browser.js.map +1 -0
- package/dist/lib/sandbox/vm-executor.d.ts +12 -0
- package/dist/lib/sandbox/vm-executor.d.ts.map +1 -0
- package/dist/lib/sandbox/vm-executor.js +101 -0
- package/dist/lib/sandbox/vm-executor.js.map +1 -0
- package/dist/lib/skills/index.d.ts +4 -0
- package/dist/lib/skills/index.d.ts.map +1 -0
- package/dist/lib/skills/index.js +3 -0
- package/dist/lib/skills/index.js.map +1 -0
- package/dist/lib/skills/skill-loader.d.ts +21 -0
- package/dist/lib/skills/skill-loader.d.ts.map +1 -0
- package/dist/lib/skills/skill-loader.js +116 -0
- package/dist/lib/skills/skill-loader.js.map +1 -0
- package/dist/lib/skills/types.d.ts +17 -0
- package/dist/lib/skills/types.d.ts.map +1 -0
- package/dist/lib/skills/types.js +6 -0
- package/dist/lib/skills/types.js.map +1 -0
- package/dist/lib/tasks/index.d.ts +4 -0
- package/dist/lib/tasks/index.d.ts.map +1 -0
- package/dist/lib/tasks/index.js +4 -0
- package/dist/lib/tasks/index.js.map +1 -0
- package/dist/lib/tasks/task-manager.d.ts +27 -0
- package/dist/lib/tasks/task-manager.d.ts.map +1 -0
- package/dist/lib/tasks/task-manager.js +200 -0
- package/dist/lib/tasks/task-manager.js.map +1 -0
- package/dist/lib/tasks/task-store.d.ts +20 -0
- package/dist/lib/tasks/task-store.d.ts.map +1 -0
- package/dist/lib/tasks/task-store.js +102 -0
- package/dist/lib/tasks/task-store.js.map +1 -0
- package/dist/lib/tasks/types.d.ts +56 -0
- package/dist/lib/tasks/types.d.ts.map +1 -0
- package/dist/lib/tasks/types.js +2 -0
- package/dist/lib/tasks/types.js.map +1 -0
- package/dist/lib/templates/resource-templates.d.ts +6 -0
- package/dist/lib/templates/resource-templates.d.ts.map +1 -0
- package/dist/lib/templates/resource-templates.js +146 -0
- package/dist/lib/templates/resource-templates.js.map +1 -0
- package/dist/lib/tools/agent-tool-wrapper.d.ts +5 -5
- package/dist/lib/tools/agent-tool-wrapper.js +3 -3
- package/dist/lib/tools/agent-tool-wrapper.js.map +1 -1
- package/dist/lib/tools/built-in/ask-user.tool.d.ts +1 -1
- package/dist/lib/tools/built-in/ask-user.tool.d.ts.map +1 -1
- package/dist/lib/tools/built-in/ask-user.tool.js +2 -2
- package/dist/lib/tools/built-in/ask-user.tool.js.map +1 -1
- package/dist/lib/tools/built-in/index.d.ts +9 -2
- package/dist/lib/tools/built-in/index.d.ts.map +1 -1
- package/dist/lib/tools/built-in/index.js +9 -2
- package/dist/lib/tools/built-in/index.js.map +1 -1
- package/dist/lib/tools/built-in/integration-tools.d.ts +4 -0
- package/dist/lib/tools/built-in/integration-tools.d.ts.map +1 -0
- package/dist/lib/tools/built-in/integration-tools.js +47 -0
- package/dist/lib/tools/built-in/integration-tools.js.map +1 -0
- package/dist/lib/tools/built-in/knowledge-entity-lookup.tool.d.ts +9 -0
- package/dist/lib/tools/built-in/knowledge-entity-lookup.tool.d.ts.map +1 -0
- package/dist/lib/tools/built-in/knowledge-entity-lookup.tool.js +108 -0
- package/dist/lib/tools/built-in/knowledge-entity-lookup.tool.js.map +1 -0
- package/dist/lib/tools/built-in/knowledge-graph-schema.tool.d.ts +9 -0
- package/dist/lib/tools/built-in/knowledge-graph-schema.tool.d.ts.map +1 -0
- package/dist/lib/tools/built-in/knowledge-graph-schema.tool.js +96 -0
- package/dist/lib/tools/built-in/knowledge-graph-schema.tool.js.map +1 -0
- package/dist/lib/tools/built-in/knowledge-search.tool.d.ts +2 -2
- package/dist/lib/tools/built-in/knowledge-search.tool.d.ts.map +1 -1
- package/dist/lib/tools/built-in/knowledge-search.tool.js +1 -1
- package/dist/lib/tools/built-in/knowledge-search.tool.js.map +1 -1
- package/dist/lib/tools/built-in/knowledge-sql.tool.d.ts +7 -0
- package/dist/lib/tools/built-in/knowledge-sql.tool.d.ts.map +1 -0
- package/dist/lib/tools/built-in/knowledge-sql.tool.js +128 -0
- package/dist/lib/tools/built-in/knowledge-sql.tool.js.map +1 -0
- package/dist/lib/tools/built-in/knowledge-tools-factory.d.ts +17 -0
- package/dist/lib/tools/built-in/knowledge-tools-factory.d.ts.map +1 -0
- package/dist/lib/tools/built-in/knowledge-tools-factory.js +54 -0
- package/dist/lib/tools/built-in/knowledge-tools-factory.js.map +1 -0
- package/dist/lib/tools/built-in/knowledge-traverse.tool.d.ts +9 -0
- package/dist/lib/tools/built-in/knowledge-traverse.tool.d.ts.map +1 -0
- package/dist/lib/tools/built-in/knowledge-traverse.tool.js +91 -0
- package/dist/lib/tools/built-in/knowledge-traverse.tool.js.map +1 -0
- package/dist/lib/tools/built-in/memory-save.tool.d.ts +4 -0
- package/dist/lib/tools/built-in/memory-save.tool.d.ts.map +1 -0
- package/dist/lib/tools/built-in/memory-save.tool.js +21 -0
- package/dist/lib/tools/built-in/memory-save.tool.js.map +1 -0
- package/dist/lib/tools/built-in/query-validators.d.ts +18 -0
- package/dist/lib/tools/built-in/query-validators.d.ts.map +1 -0
- package/dist/lib/tools/built-in/query-validators.js +91 -0
- package/dist/lib/tools/built-in/query-validators.js.map +1 -0
- package/dist/lib/tools/index.d.ts +4 -4
- package/dist/lib/tools/index.js +4 -4
- package/dist/lib/tools/tool-discovery.d.ts +11 -33
- package/dist/lib/tools/tool-discovery.d.ts.map +1 -1
- package/dist/lib/tools/tool-discovery.js +16 -43
- package/dist/lib/tools/tool-discovery.js.map +1 -1
- package/dist/lib/tools/tool-registry.d.ts +10 -18
- package/dist/lib/tools/tool-registry.d.ts.map +1 -1
- package/dist/lib/tools/tool-registry.js +37 -23
- package/dist/lib/tools/tool-registry.js.map +1 -1
- package/dist/lib/tools/workspace/workspace-tools.d.ts +61 -0
- package/dist/lib/tools/workspace/workspace-tools.d.ts.map +1 -0
- package/dist/lib/tools/workspace/workspace-tools.js +179 -0
- package/dist/lib/tools/workspace/workspace-tools.js.map +1 -0
- package/dist/lib/triggers/cron-trigger.d.ts +12 -0
- package/dist/lib/triggers/cron-trigger.d.ts.map +1 -0
- package/dist/lib/triggers/cron-trigger.js +45 -0
- package/dist/lib/triggers/cron-trigger.js.map +1 -0
- package/dist/lib/triggers/index.d.ts +6 -0
- package/dist/lib/triggers/index.d.ts.map +1 -0
- package/dist/lib/triggers/index.js +5 -0
- package/dist/lib/triggers/index.js.map +1 -0
- package/dist/lib/triggers/trigger-manager.d.ts +12 -0
- package/dist/lib/triggers/trigger-manager.d.ts.map +1 -0
- package/dist/lib/triggers/trigger-manager.js +77 -0
- package/dist/lib/triggers/trigger-manager.js.map +1 -0
- package/dist/lib/triggers/types.d.ts +57 -0
- package/dist/lib/triggers/types.d.ts.map +1 -0
- package/dist/lib/triggers/types.js +16 -0
- package/dist/lib/triggers/types.js.map +1 -0
- package/dist/lib/triggers/webhook-trigger.d.ts +12 -0
- package/dist/lib/triggers/webhook-trigger.d.ts.map +1 -0
- package/dist/lib/triggers/webhook-trigger.js +34 -0
- package/dist/lib/triggers/webhook-trigger.js.map +1 -0
- package/dist/lib/types/llm-types.d.ts +72 -0
- package/dist/lib/types/llm-types.d.ts.map +1 -0
- package/dist/lib/types/llm-types.js +72 -0
- package/dist/lib/types/llm-types.js.map +1 -0
- package/dist/lib/types/text-splitters.d.ts +27 -0
- package/dist/lib/types/text-splitters.d.ts.map +1 -0
- package/dist/lib/types/text-splitters.js +114 -0
- package/dist/lib/types/text-splitters.js.map +1 -0
- package/dist/lib/types/tool-factory.d.ts +9 -0
- package/dist/lib/types/tool-factory.d.ts.map +1 -0
- package/dist/lib/types/tool-factory.js +12 -0
- package/dist/lib/types/tool-factory.js.map +1 -0
- package/dist/lib/utils/env-substitution.d.ts +6 -0
- package/dist/lib/utils/env-substitution.d.ts.map +1 -0
- package/dist/lib/utils/env-substitution.js +15 -0
- package/dist/lib/utils/env-substitution.js.map +1 -0
- package/dist/lib/utils/file-utils.d.ts +11 -0
- package/dist/lib/utils/file-utils.d.ts.map +1 -0
- package/dist/lib/utils/file-utils.js +86 -0
- package/dist/lib/utils/file-utils.js.map +1 -0
- package/dist/lib/workflows/index.d.ts +6 -6
- package/dist/lib/workflows/index.d.ts.map +1 -1
- package/dist/lib/workflows/index.js +5 -5
- package/dist/lib/workflows/index.js.map +1 -1
- package/dist/lib/workflows/interrupt-manager.d.ts +1 -1
- package/dist/lib/workflows/interrupt-manager.js +1 -1
- package/dist/lib/workflows/react-workflow-executor.d.ts +26 -0
- package/dist/lib/workflows/react-workflow-executor.d.ts.map +1 -0
- package/dist/lib/workflows/react-workflow-executor.js +333 -0
- package/dist/lib/workflows/react-workflow-executor.js.map +1 -0
- package/dist/lib/workflows/types.d.ts +106 -107
- package/dist/lib/workflows/types.d.ts.map +1 -1
- package/dist/lib/workflows/types.js +5 -5
- package/dist/lib/workflows/types.js.map +1 -1
- package/dist/lib/workflows/workflow-executor.d.ts +3 -3
- package/dist/lib/workflows/workflow-executor.js +2 -2
- package/dist/lib/workflows/workflow-executor.js.map +1 -1
- package/dist/lib/workflows/workflow-loader.d.ts +4 -1
- package/dist/lib/workflows/workflow-loader.d.ts.map +1 -1
- package/dist/lib/workflows/workflow-loader.js +20 -4
- package/dist/lib/workflows/workflow-loader.js.map +1 -1
- package/dist/public/chat.html +114 -0
- package/dist/public/index.html +189 -0
- package/dist/public/src/components/AgentComposer.js +807 -0
- package/dist/public/src/components/AgentsView.js +1021 -344
- package/dist/public/src/components/AppRoot.js +150 -5
- package/dist/public/src/components/GraphView.js +420 -0
- package/dist/public/src/components/IdeView.js +625 -14
- package/dist/public/src/components/KnowledgeView.js +443 -66
- package/dist/public/src/components/MonitorView.js +526 -0
- package/dist/public/src/components/NavBar.js +3 -0
- package/dist/public/src/components/SkillsView.js +137 -0
- package/dist/public/src/components/StandaloneChat.js +889 -0
- package/dist/public/src/components/WorkflowsView.js +454 -129
- package/dist/public/src/services/ApiService.js +170 -25
- package/dist/public/src/services/SessionStore.js +83 -0
- package/dist/public/src/store.js +3 -4
- package/dist/public/src/utils/markdown.js +14 -0
- package/dist/src/cli/commands/init.js +2 -2
- package/dist/src/cli/commands/init.js.map +1 -1
- package/dist/src/cli/commands/start.d.ts +0 -1
- package/dist/src/cli/commands/start.d.ts.map +1 -1
- package/dist/src/cli/commands/start.js +23 -14
- package/dist/src/cli/commands/start.js.map +1 -1
- package/dist/src/cli/index.js +8 -5
- package/dist/src/cli/index.js.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +23 -9
- package/dist/src/index.js.map +1 -1
- package/dist/src/middleware/auth.d.ts +3 -0
- package/dist/src/middleware/auth.d.ts.map +1 -0
- package/dist/src/middleware/auth.js +129 -0
- package/dist/src/middleware/auth.js.map +1 -0
- package/dist/src/middleware/rate-limit.d.ts +8 -0
- package/dist/src/middleware/rate-limit.d.ts.map +1 -0
- package/dist/src/middleware/rate-limit.js +21 -0
- package/dist/src/middleware/rate-limit.js.map +1 -0
- package/dist/src/routes/agents.route.d.ts.map +1 -1
- package/dist/src/routes/agents.route.js +167 -12
- package/dist/src/routes/agents.route.js.map +1 -1
- package/dist/src/routes/chat.route.d.ts +3 -0
- package/dist/src/routes/chat.route.d.ts.map +1 -0
- package/dist/src/routes/chat.route.js +155 -0
- package/dist/src/routes/chat.route.js.map +1 -0
- package/dist/src/routes/files.route.d.ts.map +1 -1
- package/dist/src/routes/files.route.js +163 -87
- package/dist/src/routes/files.route.js.map +1 -1
- package/dist/src/routes/functions.route.js +1 -1
- package/dist/src/routes/graph.route.d.ts +3 -0
- package/dist/src/routes/graph.route.d.ts.map +1 -0
- package/dist/src/routes/graph.route.js +173 -0
- package/dist/src/routes/graph.route.js.map +1 -0
- package/dist/src/routes/knowledge.route.d.ts.map +1 -1
- package/dist/src/routes/knowledge.route.js +172 -69
- package/dist/src/routes/knowledge.route.js.map +1 -1
- package/dist/src/routes/llm.route.d.ts.map +1 -1
- package/dist/src/routes/llm.route.js +85 -9
- package/dist/src/routes/llm.route.js.map +1 -1
- package/dist/src/routes/mcp.route.js +1 -1
- package/dist/src/routes/skills.route.d.ts +3 -0
- package/dist/src/routes/skills.route.d.ts.map +1 -0
- package/dist/src/routes/skills.route.js +23 -0
- package/dist/src/routes/skills.route.js.map +1 -0
- package/dist/src/routes/tasks.route.d.ts +3 -0
- package/dist/src/routes/tasks.route.d.ts.map +1 -0
- package/dist/src/routes/tasks.route.js +149 -0
- package/dist/src/routes/tasks.route.js.map +1 -0
- package/dist/src/routes/vnc.route.d.ts +3 -0
- package/dist/src/routes/vnc.route.d.ts.map +1 -0
- package/dist/src/routes/vnc.route.js +49 -0
- package/dist/src/routes/vnc.route.js.map +1 -0
- package/dist/src/routes/workflows.route.d.ts.map +1 -1
- package/dist/src/routes/workflows.route.js +9 -1
- package/dist/src/routes/workflows.route.js.map +1 -1
- package/dist/src/server.d.ts +1 -1
- package/dist/src/server.d.ts.map +1 -1
- package/dist/src/server.js +26 -9
- package/dist/src/server.js.map +1 -1
- package/dist/templates/.env.example +4 -19
- package/dist/templates/Demo.md +152 -0
- package/dist/templates/README.md +28 -11
- package/dist/templates/agents/architect.agent.yaml +57 -0
- package/dist/templates/agents/chatbot.agent.yaml +55 -0
- package/dist/templates/agents/corporate.agent.yaml +65 -0
- package/dist/templates/agents/investment-analyst.agent.yaml +80 -0
- package/dist/templates/agents/music-librarian.agent.yaml +70 -0
- package/dist/templates/agents/network-security.agent.yaml +82 -0
- package/dist/templates/agents/transport-security.agent.yaml +70 -0
- package/dist/templates/agents/web-engineer.agent.yaml +99 -0
- package/dist/templates/agents/web-pilot.agent.yaml +58 -0
- package/dist/templates/knowledge/music-store/LICENSE.md +11 -0
- package/dist/templates/knowledge/music-store/musicstore.sqlite +0 -0
- package/dist/templates/knowledge/music-store/tables.png +0 -0
- package/dist/templates/knowledge/music-store.knowledge.yaml +138 -0
- package/dist/templates/knowledge/org-chart/personnel.csv +21 -0
- package/dist/templates/knowledge/org-chart.knowledge.yaml +53 -0
- package/dist/templates/knowledge/pet-store/pet-store.db +0 -0
- package/dist/templates/knowledge/pet-store.knowledge.yaml +81 -0
- package/dist/templates/knowledge/security-incidents/incidents.json +55935 -0
- package/dist/templates/knowledge/security-incidents.knowledge.yaml +46 -0
- package/dist/templates/knowledge/transcripts.knowledge.yaml +29 -0
- package/dist/templates/knowledge/transport-ot/systems.csv +117 -0
- package/dist/templates/knowledge/transport-ot.knowledge.yaml +55 -0
- package/dist/templates/knowledge/web-docs.knowledge.yaml +20 -0
- package/dist/templates/llm.json +7 -30
- package/dist/templates/mcp.json +10 -4
- package/dist/templates/skills/orcha-builder/SKILL.md +219 -0
- package/dist/templates/skills/pii-guard/SKILL.md +22 -0
- package/dist/templates/skills/sandbox/SKILL.md +40 -0
- package/dist/templates/skills/web-pilot/SKILL.md +51 -0
- package/dist/templates/workflows/example.workflow.yaml +25 -30
- package/dist/templates/workflows/react-example.workflow.yaml +53 -0
- package/package.json +22 -20
- package/dist/lib/knowledge/graph-rag/community-detector.d.ts +0 -16
- package/dist/lib/knowledge/graph-rag/community-detector.d.ts.map +0 -1
- package/dist/lib/knowledge/graph-rag/community-detector.js +0 -81
- package/dist/lib/knowledge/graph-rag/community-detector.js.map +0 -1
- package/dist/lib/knowledge/graph-rag/community-summarizer.d.ts +0 -17
- package/dist/lib/knowledge/graph-rag/community-summarizer.d.ts.map +0 -1
- package/dist/lib/knowledge/graph-rag/community-summarizer.js +0 -87
- package/dist/lib/knowledge/graph-rag/community-summarizer.js.map +0 -1
- package/dist/lib/knowledge/graph-rag/entity-extractor.d.ts +0 -36
- package/dist/lib/knowledge/graph-rag/entity-extractor.d.ts.map +0 -1
- package/dist/lib/knowledge/graph-rag/entity-extractor.js +0 -192
- package/dist/lib/knowledge/graph-rag/entity-extractor.js.map +0 -1
- package/dist/lib/knowledge/graph-rag/extraction-cache.d.ts +0 -30
- package/dist/lib/knowledge/graph-rag/extraction-cache.d.ts.map +0 -1
- package/dist/lib/knowledge/graph-rag/extraction-cache.js +0 -88
- package/dist/lib/knowledge/graph-rag/extraction-cache.js.map +0 -1
- package/dist/lib/knowledge/graph-rag/global-search.d.ts +0 -19
- package/dist/lib/knowledge/graph-rag/global-search.d.ts.map +0 -1
- package/dist/lib/knowledge/graph-rag/global-search.js +0 -96
- package/dist/lib/knowledge/graph-rag/global-search.js.map +0 -1
- package/dist/lib/knowledge/graph-rag/graph-rag-factory.d.ts +0 -24
- package/dist/lib/knowledge/graph-rag/graph-rag-factory.d.ts.map +0 -1
- package/dist/lib/knowledge/graph-rag/graph-rag-factory.js +0 -239
- package/dist/lib/knowledge/graph-rag/graph-rag-factory.js.map +0 -1
- package/dist/lib/knowledge/graph-rag/index.d.ts +0 -14
- package/dist/lib/knowledge/graph-rag/index.d.ts.map +0 -1
- package/dist/lib/knowledge/graph-rag/index.js +0 -12
- package/dist/lib/knowledge/graph-rag/index.js.map +0 -1
- package/dist/lib/knowledge/graph-rag/local-search.d.ts +0 -20
- package/dist/lib/knowledge/graph-rag/local-search.d.ts.map +0 -1
- package/dist/lib/knowledge/graph-rag/local-search.js +0 -110
- package/dist/lib/knowledge/graph-rag/local-search.js.map +0 -1
- package/dist/lib/knowledge/graph-rag/memory-graph-store.d.ts +0 -31
- package/dist/lib/knowledge/graph-rag/memory-graph-store.d.ts.map +0 -1
- package/dist/lib/knowledge/graph-rag/memory-graph-store.js +0 -165
- package/dist/lib/knowledge/graph-rag/memory-graph-store.js.map +0 -1
- package/dist/lib/knowledge/graph-rag/neo4j-graph-store.d.ts +0 -38
- package/dist/lib/knowledge/graph-rag/neo4j-graph-store.d.ts.map +0 -1
- package/dist/lib/knowledge/graph-rag/neo4j-graph-store.js +0 -190
- package/dist/lib/knowledge/graph-rag/neo4j-graph-store.js.map +0 -1
- package/dist/lib/knowledge/graph-rag/search-mode-detector.d.ts +0 -11
- package/dist/lib/knowledge/graph-rag/search-mode-detector.d.ts.map +0 -1
- package/dist/lib/knowledge/graph-rag/search-mode-detector.js +0 -50
- package/dist/lib/knowledge/graph-rag/search-mode-detector.js.map +0 -1
- package/dist/lib/knowledge/graph-rag/types.d.ts +0 -368
- package/dist/lib/knowledge/graph-rag/types.d.ts.map +0 -1
- package/dist/lib/knowledge/graph-rag/types.js +0 -48
- package/dist/lib/knowledge/graph-rag/types.js.map +0 -1
- package/dist/lib/knowledge/knowledge-store-factory.d.ts +0 -16
- package/dist/lib/knowledge/knowledge-store-factory.d.ts.map +0 -1
- package/dist/lib/knowledge/knowledge-store-factory.js +0 -376
- package/dist/lib/knowledge/knowledge-store-factory.js.map +0 -1
- package/dist/lib/knowledge/knowledge-store-manager.d.ts +0 -18
- package/dist/lib/knowledge/knowledge-store-manager.d.ts.map +0 -1
- package/dist/lib/knowledge/knowledge-store-manager.js +0 -98
- package/dist/lib/knowledge/knowledge-store-manager.js.map +0 -1
- package/dist/lib/knowledge/loaders/s3-loader.d.ts +0 -17
- package/dist/lib/knowledge/loaders/s3-loader.d.ts.map +0 -1
- package/dist/lib/knowledge/loaders/s3-loader.js +0 -185
- package/dist/lib/knowledge/loaders/s3-loader.js.map +0 -1
- package/dist/lib/workflows/langgraph-executor.d.ts +0 -51
- package/dist/lib/workflows/langgraph-executor.d.ts.map +0 -1
- package/dist/lib/workflows/langgraph-executor.js +0 -297
- package/dist/lib/workflows/langgraph-executor.js.map +0 -1
- package/dist/templates/agents/call-center-analyst-simple.agent.yaml +0 -36
- package/dist/templates/agents/math.agent.yaml +0 -28
- package/dist/templates/agents/sentiment-structured.agent.yaml +0 -42
- package/dist/templates/knowledge/example.knowledge.yaml +0 -28
- package/dist/templates/llm.md +0 -1195
- package/dist/templates/workflows/langgraph-example.workflow.yaml +0 -84
|
@@ -1,18 +1,29 @@
|
|
|
1
|
-
import type { AgentDefinition, AgentInstance } from './types.
|
|
2
|
-
import type { ToolRegistry } from '../tools/tool-registry.
|
|
3
|
-
import type { ConversationStore } from '../memory/conversation-store.
|
|
1
|
+
import type { AgentDefinition, AgentInstance } from './types.ts';
|
|
2
|
+
import type { ToolRegistry } from '../tools/tool-registry.ts';
|
|
3
|
+
import type { ConversationStore } from '../memory/conversation-store.ts';
|
|
4
|
+
import type { SkillLoader } from '../skills/skill-loader.ts';
|
|
5
|
+
import type { MemoryManager } from '../memory/memory-manager.ts';
|
|
6
|
+
import type { IntegrationAccessor } from '../integrations/types.ts';
|
|
4
7
|
export declare class AgentExecutor {
|
|
5
8
|
private toolRegistry;
|
|
6
9
|
private conversationStore;
|
|
7
|
-
|
|
10
|
+
private skillLoader?;
|
|
11
|
+
private memoryManager?;
|
|
12
|
+
private integrations?;
|
|
13
|
+
constructor(toolRegistry: ToolRegistry, conversationStore: ConversationStore, skillLoader?: SkillLoader, memoryManager?: MemoryManager, integrations?: IntegrationAccessor);
|
|
8
14
|
createInstance(definition: AgentDefinition): Promise<AgentInstance>;
|
|
9
15
|
private invoke;
|
|
10
16
|
private parseInvokeOptions;
|
|
11
17
|
private invokeWithTools;
|
|
12
18
|
private invokeWithoutTools;
|
|
13
19
|
private formatUserMessage;
|
|
20
|
+
private buildUserContent;
|
|
14
21
|
private stream;
|
|
15
22
|
private buildMessagesWithHistory;
|
|
23
|
+
private buildStoredMessage;
|
|
24
|
+
private extractToolSummariesFromMessages;
|
|
25
|
+
private normalizeMemoryConfig;
|
|
26
|
+
private buildMemoryPrompt;
|
|
16
27
|
private extractStructuredOutput;
|
|
17
28
|
}
|
|
18
29
|
//# sourceMappingURL=agent-executor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-executor.d.ts","sourceRoot":"","sources":["../../../lib/agents/agent-executor.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"agent-executor.d.ts","sourceRoot":"","sources":["../../../lib/agents/agent-executor.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAsD,MAAM,YAAY,CAAC;AAErH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACzE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAapE,qBAAa,aAAa;IACxB,OAAO,CAAC,YAAY,CAAe;IACnC,OAAO,CAAC,iBAAiB,CAAoB;IAC7C,OAAO,CAAC,WAAW,CAAC,CAAc;IAClC,OAAO,CAAC,aAAa,CAAC,CAAgB;IACtC,OAAO,CAAC,YAAY,CAAC,CAAsB;gBAE/B,YAAY,EAAE,YAAY,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,WAAW,CAAC,EAAE,WAAW,EAAE,aAAa,CAAC,EAAE,aAAa,EAAE,YAAY,CAAC,EAAE,mBAAmB;IAQpK,cAAc,CAAC,UAAU,EAAE,eAAe,GAAG,OAAO,CAAC,aAAa,CAAC;YA8D3D,MAAM;IAgBpB,OAAO,CAAC,kBAAkB;YAkBZ,eAAe;YAmIf,kBAAkB;IAyEhC,OAAO,CAAC,iBAAiB;IAmBzB,OAAO,CAAC,gBAAgB;YAcT,MAAM;IAiNrB,OAAO,CAAC,wBAAwB;IAyBhC,OAAO,CAAC,kBAAkB;IAiB1B,OAAO,CAAC,gCAAgC;IA8BxC,OAAO,CAAC,qBAAqB;IAS7B,OAAO,CAAC,iBAAiB;IAwBzB,OAAO,CAAC,uBAAuB;CAyChC"}
|
|
@@ -1,24 +1,82 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { LLMFactory } from
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { createReActAgent } from "./react-loop.js";
|
|
2
|
+
import { humanMessage, aiMessage, contentToText } from "../types/llm-types.js";
|
|
3
|
+
import { LLMFactory } from "../llm/llm-factory.js";
|
|
4
|
+
import { createMemorySaveTool } from "../tools/built-in/memory-save.tool.js";
|
|
5
|
+
import { createIntegrationTools } from "../tools/built-in/integration-tools.js";
|
|
6
|
+
import { StructuredOutputWrapper } from "./structured-output-wrapper.js";
|
|
7
|
+
import { logLLMCallStart, logLLMCallEnd } from "../llm/llm-call-logger.js";
|
|
8
|
+
import { logger } from "../logger.js";
|
|
9
|
+
function isAbortError(err) {
|
|
10
|
+
if (err instanceof DOMException && err.name === 'AbortError')
|
|
11
|
+
return true;
|
|
12
|
+
if (err instanceof Error && err.name === 'AbortError')
|
|
13
|
+
return true;
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
6
16
|
export class AgentExecutor {
|
|
7
17
|
toolRegistry;
|
|
8
18
|
conversationStore;
|
|
9
|
-
|
|
19
|
+
skillLoader;
|
|
20
|
+
memoryManager;
|
|
21
|
+
integrations;
|
|
22
|
+
constructor(toolRegistry, conversationStore, skillLoader, memoryManager, integrations) {
|
|
10
23
|
this.toolRegistry = toolRegistry;
|
|
11
24
|
this.conversationStore = conversationStore;
|
|
25
|
+
this.skillLoader = skillLoader;
|
|
26
|
+
this.memoryManager = memoryManager;
|
|
27
|
+
this.integrations = integrations;
|
|
12
28
|
}
|
|
13
29
|
async createInstance(definition) {
|
|
14
|
-
|
|
30
|
+
// Resolve skills and augment system prompt if configured
|
|
31
|
+
let augmentedDefinition = definition;
|
|
32
|
+
if (definition.skills && this.skillLoader) {
|
|
33
|
+
const content = this.skillLoader.resolveForAgent(definition.skills);
|
|
34
|
+
if (content) {
|
|
35
|
+
augmentedDefinition = {
|
|
36
|
+
...definition,
|
|
37
|
+
prompt: {
|
|
38
|
+
...definition.prompt,
|
|
39
|
+
system: `${definition.prompt.system}\n\n${content}`,
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
// Resolve memory and augment system prompt if configured
|
|
45
|
+
const memoryConfig = this.normalizeMemoryConfig(definition.memory);
|
|
46
|
+
if (memoryConfig && this.memoryManager) {
|
|
47
|
+
const memoryContent = await this.memoryManager.load(definition.name);
|
|
48
|
+
const memoryPrompt = this.buildMemoryPrompt(memoryContent, memoryConfig.maxLines);
|
|
49
|
+
augmentedDefinition = {
|
|
50
|
+
...augmentedDefinition,
|
|
51
|
+
prompt: {
|
|
52
|
+
...augmentedDefinition.prompt,
|
|
53
|
+
system: `${augmentedDefinition.prompt.system}\n\n${memoryPrompt}`,
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
let llm = LLMFactory.create(augmentedDefinition.llm);
|
|
15
58
|
// Wrap LLM with structured output if configured
|
|
16
|
-
llm = StructuredOutputWrapper.wrapLLM(llm,
|
|
17
|
-
const tools = await this.toolRegistry.resolveTools(
|
|
59
|
+
llm = StructuredOutputWrapper.wrapLLM(llm, augmentedDefinition.output);
|
|
60
|
+
const tools = await this.toolRegistry.resolveTools(augmentedDefinition.tools);
|
|
61
|
+
// Auto-inject memory tool if configured
|
|
62
|
+
if (memoryConfig && this.memoryManager) {
|
|
63
|
+
tools.push(createMemorySaveTool(this.memoryManager, definition.name, memoryConfig.maxLines));
|
|
64
|
+
logger.info(`[AgentExecutor] Auto-injected save_memory tool for agent: ${definition.name}`);
|
|
65
|
+
}
|
|
66
|
+
// Auto-inject integration tools if agent has integrations configured
|
|
67
|
+
if (definition.integrations?.length && this.integrations) {
|
|
68
|
+
const existingNames = new Set(tools.map((t) => t.name));
|
|
69
|
+
const integrationTools = createIntegrationTools(this.integrations, definition.name)
|
|
70
|
+
.filter((t) => !existingNames.has(t.name));
|
|
71
|
+
if (integrationTools.length > 0) {
|
|
72
|
+
tools.push(...integrationTools);
|
|
73
|
+
logger.info(`[AgentExecutor] Auto-injected ${integrationTools.length} integration tools for agent: ${definition.name}`);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
18
76
|
return {
|
|
19
|
-
definition,
|
|
20
|
-
invoke: async (input) => this.invoke(
|
|
21
|
-
stream: (input) => this.stream(
|
|
77
|
+
definition: augmentedDefinition,
|
|
78
|
+
invoke: async (input) => this.invoke(augmentedDefinition, llm, tools, input),
|
|
79
|
+
stream: (input) => this.stream(augmentedDefinition, llm, tools, input),
|
|
22
80
|
};
|
|
23
81
|
}
|
|
24
82
|
async invoke(definition, llm, tools, input) {
|
|
@@ -36,6 +94,7 @@ export class AgentExecutor {
|
|
|
36
94
|
return {
|
|
37
95
|
input: options.input,
|
|
38
96
|
sessionId: options.sessionId,
|
|
97
|
+
signal: options.signal,
|
|
39
98
|
};
|
|
40
99
|
}
|
|
41
100
|
// Otherwise treat as direct input
|
|
@@ -43,26 +102,37 @@ export class AgentExecutor {
|
|
|
43
102
|
}
|
|
44
103
|
async invokeWithTools(definition, llm, tools, input, startTime, sessionId) {
|
|
45
104
|
try {
|
|
46
|
-
const agent =
|
|
105
|
+
const agent = createReActAgent({
|
|
47
106
|
model: llm,
|
|
48
107
|
tools,
|
|
49
108
|
systemPrompt: definition.prompt.system,
|
|
50
109
|
});
|
|
51
|
-
const
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
110
|
+
const userText = this.formatUserMessage(definition, input);
|
|
111
|
+
const userContent = this.buildUserContent(userText, input);
|
|
112
|
+
const messages = this.buildMessagesWithHistory(userContent, sessionId);
|
|
113
|
+
const caller = `Agent: ${definition.name}`;
|
|
55
114
|
if (sessionId) {
|
|
56
|
-
logger.info(`[
|
|
115
|
+
logger.info(`[${caller}] Using session: ${sessionId}`);
|
|
57
116
|
}
|
|
58
|
-
|
|
59
|
-
|
|
117
|
+
const { startTime: llmStart, stats } = logLLMCallStart({
|
|
118
|
+
caller,
|
|
119
|
+
systemPrompt: definition.prompt.system,
|
|
120
|
+
messages,
|
|
121
|
+
tools,
|
|
122
|
+
});
|
|
123
|
+
logger.info(`[${caller}] Reaching LLM provider...`);
|
|
60
124
|
const result = await agent.invoke({
|
|
61
125
|
messages,
|
|
62
126
|
}, {
|
|
63
|
-
recursionLimit:
|
|
127
|
+
recursionLimit: definition.maxIterations ?? 200,
|
|
128
|
+
signal: undefined,
|
|
129
|
+
});
|
|
130
|
+
const lastMsg = result.messages?.[result.messages.length - 1];
|
|
131
|
+
const responseContent = lastMsg && 'content' in lastMsg ? contentToText(lastMsg.content) : '';
|
|
132
|
+
logLLMCallEnd(caller, llmStart, stats, {
|
|
133
|
+
contentLength: responseContent.length,
|
|
134
|
+
messageCount: result.messages?.length ?? 0,
|
|
64
135
|
});
|
|
65
|
-
logger.info(`[Agent: ${definition.name}] Got ${result.messages?.length ?? 0} messages`);
|
|
66
136
|
if (!result.messages || result.messages.length === 0) {
|
|
67
137
|
logger.warn(`[Agent: ${definition.name}] No messages returned`);
|
|
68
138
|
return {
|
|
@@ -83,7 +153,7 @@ export class AgentExecutor {
|
|
|
83
153
|
}
|
|
84
154
|
else if (typeof lastMessage === 'object' && lastMessage !== null) {
|
|
85
155
|
if ('content' in lastMessage) {
|
|
86
|
-
output =
|
|
156
|
+
output = contentToText(lastMessage.content);
|
|
87
157
|
}
|
|
88
158
|
else {
|
|
89
159
|
output = JSON.stringify(lastMessage);
|
|
@@ -92,9 +162,11 @@ export class AgentExecutor {
|
|
|
92
162
|
else {
|
|
93
163
|
output = String(lastMessage);
|
|
94
164
|
}
|
|
95
|
-
//
|
|
165
|
+
// Extract tool call summaries from the message chain and store with response
|
|
96
166
|
if (sessionId && typeof output === 'string') {
|
|
97
|
-
this.
|
|
167
|
+
const toolSummaries = this.extractToolSummariesFromMessages(result.messages);
|
|
168
|
+
const storedMessage = this.buildStoredMessage(output, toolSummaries);
|
|
169
|
+
this.conversationStore.addMessage(sessionId, aiMessage(storedMessage));
|
|
98
170
|
}
|
|
99
171
|
if (typeof output === 'string' && (!output || output === 'null' || output === 'undefined')) {
|
|
100
172
|
logger.warn(`[Agent: ${definition.name}] Empty output, last message:`, lastMessage);
|
|
@@ -122,9 +194,12 @@ export class AgentExecutor {
|
|
|
122
194
|
};
|
|
123
195
|
}
|
|
124
196
|
catch (error) {
|
|
125
|
-
|
|
197
|
+
const errorMsg = isAbortError(error)
|
|
198
|
+
? 'Request was aborted'
|
|
199
|
+
: (error instanceof Error ? error.message : String(error));
|
|
200
|
+
logger.error(`[Agent: ${definition.name}] Error: ${errorMsg}`);
|
|
126
201
|
return {
|
|
127
|
-
output: `Agent error: ${
|
|
202
|
+
output: `Agent error: ${errorMsg}`,
|
|
128
203
|
metadata: {
|
|
129
204
|
duration: Date.now() - startTime,
|
|
130
205
|
toolCalls: [],
|
|
@@ -135,30 +210,41 @@ export class AgentExecutor {
|
|
|
135
210
|
}
|
|
136
211
|
}
|
|
137
212
|
async invokeWithoutTools(definition, llm, input, startTime, sessionId) {
|
|
138
|
-
const
|
|
213
|
+
const userText = this.formatUserMessage(definition, input);
|
|
214
|
+
const userContent = this.buildUserContent(userText, input);
|
|
139
215
|
// Build messages with history for session-based conversations
|
|
140
216
|
const messageHistory = sessionId ? this.conversationStore.getMessages(sessionId) : [];
|
|
141
217
|
const allMessages = [
|
|
142
|
-
|
|
218
|
+
{ role: 'system', content: definition.prompt.system },
|
|
143
219
|
...messageHistory,
|
|
144
|
-
|
|
220
|
+
humanMessage(userContent),
|
|
145
221
|
];
|
|
146
|
-
// Store user message in session before invoking
|
|
222
|
+
// Store user message in session before invoking (text only — no base64 in memory)
|
|
147
223
|
if (sessionId) {
|
|
148
|
-
this.conversationStore.addMessage(sessionId,
|
|
224
|
+
this.conversationStore.addMessage(sessionId, humanMessage(userText));
|
|
149
225
|
}
|
|
226
|
+
const caller = `Agent: ${definition.name}`;
|
|
227
|
+
const { startTime: llmStart, stats } = logLLMCallStart({
|
|
228
|
+
caller,
|
|
229
|
+
systemPrompt: definition.prompt.system,
|
|
230
|
+
messages: allMessages,
|
|
231
|
+
});
|
|
232
|
+
logger.info(`[${caller}] Reaching LLM provider...`);
|
|
150
233
|
const result = await llm.invoke(allMessages);
|
|
234
|
+
logLLMCallEnd(caller, llmStart, stats, {
|
|
235
|
+
contentLength: result.content.length,
|
|
236
|
+
});
|
|
151
237
|
let output;
|
|
152
238
|
// Handle structured output
|
|
153
239
|
if (definition.output?.format === 'structured') {
|
|
154
240
|
output = this.extractStructuredOutput(result);
|
|
155
241
|
}
|
|
156
242
|
else {
|
|
157
|
-
output =
|
|
243
|
+
output = contentToText(result.content);
|
|
158
244
|
}
|
|
159
245
|
// Store AI response in session
|
|
160
246
|
if (sessionId && typeof output === 'string') {
|
|
161
|
-
this.conversationStore.addMessage(sessionId,
|
|
247
|
+
this.conversationStore.addMessage(sessionId, aiMessage(output));
|
|
162
248
|
}
|
|
163
249
|
// Validate structured output if applicable
|
|
164
250
|
let structuredOutputValid;
|
|
@@ -195,122 +281,286 @@ export class AgentExecutor {
|
|
|
195
281
|
})
|
|
196
282
|
.join('\n');
|
|
197
283
|
}
|
|
284
|
+
buildUserContent(text, input) {
|
|
285
|
+
const attachments = input.attachments;
|
|
286
|
+
if (!Array.isArray(attachments) || attachments.length === 0)
|
|
287
|
+
return text;
|
|
288
|
+
const parts = [];
|
|
289
|
+
if (text)
|
|
290
|
+
parts.push({ type: 'text', text });
|
|
291
|
+
for (const att of attachments) {
|
|
292
|
+
if (att && typeof att.data === 'string' && typeof att.mediaType === 'string') {
|
|
293
|
+
parts.push({ type: 'image', data: att.data, mediaType: att.mediaType });
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
return parts.length > 0 ? parts : text;
|
|
297
|
+
}
|
|
198
298
|
async *stream(definition, llm, tools, input) {
|
|
199
|
-
const { input: actualInput, sessionId } = this.parseInvokeOptions(input);
|
|
299
|
+
const { input: actualInput, sessionId, signal } = this.parseInvokeOptions(input);
|
|
200
300
|
if (tools.length > 0) {
|
|
201
|
-
const agent =
|
|
301
|
+
const agent = createReActAgent({
|
|
202
302
|
model: llm,
|
|
203
303
|
tools,
|
|
204
304
|
systemPrompt: definition.prompt.system,
|
|
205
305
|
});
|
|
206
|
-
const
|
|
207
|
-
const
|
|
208
|
-
const
|
|
306
|
+
const userText = this.formatUserMessage(definition, actualInput);
|
|
307
|
+
const userContent = this.buildUserContent(userText, actualInput);
|
|
308
|
+
const messages = this.buildMessagesWithHistory(userContent, sessionId);
|
|
309
|
+
const caller = `Agent: ${definition.name}`;
|
|
310
|
+
const { startTime: llmStart, stats } = logLLMCallStart({
|
|
311
|
+
caller,
|
|
312
|
+
systemPrompt: definition.prompt.system,
|
|
313
|
+
messages,
|
|
314
|
+
tools,
|
|
315
|
+
});
|
|
316
|
+
logger.info(`[${caller}] Reaching LLM provider...`);
|
|
317
|
+
const eventStream = agent.streamEvents({ messages }, {
|
|
209
318
|
version: 'v2',
|
|
319
|
+
recursionLimit: definition.maxIterations ?? 200,
|
|
320
|
+
signal,
|
|
210
321
|
});
|
|
211
322
|
let accumulatedOutput = '';
|
|
212
323
|
let finalMessage = null;
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
324
|
+
let totalInputTokens = 0;
|
|
325
|
+
let totalOutputTokens = 0;
|
|
326
|
+
const toolCallSummaries = [];
|
|
327
|
+
const pendingToolCalls = new Map();
|
|
328
|
+
try {
|
|
329
|
+
for await (const event of eventStream) {
|
|
330
|
+
if (event.event === 'on_chat_model_stream') {
|
|
331
|
+
const chunk = event.data.chunk;
|
|
332
|
+
const text = contentToText(chunk.content ?? '');
|
|
333
|
+
if (text) {
|
|
334
|
+
accumulatedOutput += text;
|
|
335
|
+
yield { type: 'content', content: text };
|
|
336
|
+
}
|
|
337
|
+
if (chunk.reasoning) {
|
|
338
|
+
yield { type: 'thinking', content: chunk.reasoning };
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
else if (event.event === 'on_chat_model_end') {
|
|
342
|
+
finalMessage = event.data.output;
|
|
343
|
+
const um = event.data.output?.usage_metadata;
|
|
344
|
+
if (um) {
|
|
345
|
+
totalInputTokens += um.input_tokens || 0;
|
|
346
|
+
totalOutputTokens += um.output_tokens || 0;
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
else if (event.event === 'on_tool_start') {
|
|
350
|
+
pendingToolCalls.set(event.run_id, { tool: event.name, input: event.data.input });
|
|
351
|
+
yield {
|
|
352
|
+
type: 'tool_start',
|
|
353
|
+
tool: event.name,
|
|
354
|
+
input: event.data.input,
|
|
355
|
+
runId: event.run_id,
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
else if (event.event === 'on_tool_end') {
|
|
359
|
+
const pending = pendingToolCalls.get(event.run_id);
|
|
360
|
+
toolCallSummaries.push({
|
|
361
|
+
tool: event.name,
|
|
362
|
+
input: pending?.input ?? null,
|
|
363
|
+
output: event.data.output,
|
|
364
|
+
});
|
|
365
|
+
pendingToolCalls.delete(event.run_id);
|
|
366
|
+
yield {
|
|
367
|
+
type: 'tool_end',
|
|
368
|
+
tool: event.name,
|
|
369
|
+
output: event.data.output,
|
|
370
|
+
runId: event.run_id,
|
|
371
|
+
};
|
|
372
|
+
}
|
|
373
|
+
else if (event.event === 'on_react_iteration') {
|
|
374
|
+
yield { type: 'react_iteration', ...event.data };
|
|
219
375
|
}
|
|
220
376
|
}
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
}
|
|
233
|
-
else if (event.event === 'on_tool_end') {
|
|
234
|
-
yield {
|
|
235
|
-
type: 'tool_end',
|
|
236
|
-
tool: event.name,
|
|
237
|
-
output: event.data.output,
|
|
238
|
-
runId: event.run_id,
|
|
239
|
-
};
|
|
377
|
+
}
|
|
378
|
+
catch (streamError) {
|
|
379
|
+
const errorMsg = isAbortError(streamError)
|
|
380
|
+
? 'Request was aborted'
|
|
381
|
+
: (streamError instanceof Error ? streamError.message : String(streamError));
|
|
382
|
+
logger.error(`[Agent: ${definition.name}] Stream error: ${errorMsg}`);
|
|
383
|
+
yield { type: 'error', error: errorMsg };
|
|
384
|
+
// Still store what we have so far
|
|
385
|
+
if (sessionId && (accumulatedOutput || toolCallSummaries.length > 0)) {
|
|
386
|
+
const partialMessage = this.buildStoredMessage(accumulatedOutput || '(agent encountered an error)', toolCallSummaries);
|
|
387
|
+
this.conversationStore.addMessage(sessionId, aiMessage(partialMessage));
|
|
240
388
|
}
|
|
389
|
+
return;
|
|
241
390
|
}
|
|
391
|
+
logLLMCallEnd(caller, llmStart, stats, {
|
|
392
|
+
contentLength: accumulatedOutput.length,
|
|
393
|
+
});
|
|
394
|
+
// Build the message to store: text response + tool call summaries
|
|
395
|
+
const storedMessage = this.buildStoredMessage(accumulatedOutput, toolCallSummaries);
|
|
242
396
|
// Handle structured output
|
|
243
397
|
if (definition.output?.format === 'structured' && finalMessage) {
|
|
244
398
|
const structuredOutput = this.extractStructuredOutput(finalMessage);
|
|
245
399
|
yield { type: 'result', output: structuredOutput };
|
|
246
|
-
// Store structured output as JSON string in session
|
|
247
400
|
if (sessionId) {
|
|
248
|
-
this.conversationStore.addMessage(sessionId,
|
|
401
|
+
this.conversationStore.addMessage(sessionId, aiMessage(JSON.stringify(structuredOutput)));
|
|
249
402
|
}
|
|
250
403
|
}
|
|
251
|
-
else if (sessionId &&
|
|
252
|
-
|
|
253
|
-
|
|
404
|
+
else if (sessionId && storedMessage) {
|
|
405
|
+
this.conversationStore.addMessage(sessionId, aiMessage(storedMessage));
|
|
406
|
+
}
|
|
407
|
+
// Yield usage stats if available
|
|
408
|
+
if (totalInputTokens > 0 || totalOutputTokens > 0) {
|
|
409
|
+
yield {
|
|
410
|
+
type: 'usage',
|
|
411
|
+
input_tokens: totalInputTokens,
|
|
412
|
+
output_tokens: totalOutputTokens,
|
|
413
|
+
total_tokens: totalInputTokens + totalOutputTokens,
|
|
414
|
+
};
|
|
254
415
|
}
|
|
255
416
|
}
|
|
256
417
|
else {
|
|
257
|
-
const
|
|
418
|
+
const userText = this.formatUserMessage(definition, actualInput);
|
|
419
|
+
const userContent = this.buildUserContent(userText, actualInput);
|
|
258
420
|
// Build messages with history for session-based conversations
|
|
259
421
|
const messageHistory = sessionId ? this.conversationStore.getMessages(sessionId) : [];
|
|
260
422
|
const allMessages = [
|
|
261
|
-
|
|
423
|
+
{ role: 'system', content: definition.prompt.system },
|
|
262
424
|
...messageHistory,
|
|
263
|
-
|
|
425
|
+
humanMessage(userContent),
|
|
264
426
|
];
|
|
265
|
-
// Store user message in session before streaming
|
|
427
|
+
// Store user message in session before streaming (text only — no base64 in memory)
|
|
266
428
|
if (sessionId) {
|
|
267
|
-
this.conversationStore.addMessage(sessionId,
|
|
429
|
+
this.conversationStore.addMessage(sessionId, humanMessage(userText));
|
|
268
430
|
}
|
|
269
|
-
const
|
|
431
|
+
const caller = `Agent: ${definition.name}`;
|
|
432
|
+
const { startTime: llmStart, stats } = logLLMCallStart({
|
|
433
|
+
caller,
|
|
434
|
+
systemPrompt: definition.prompt.system,
|
|
435
|
+
messages: allMessages,
|
|
436
|
+
});
|
|
437
|
+
logger.info(`[${caller}] Reaching LLM provider...`);
|
|
438
|
+
const stream = llm.stream(allMessages, { signal });
|
|
270
439
|
let accumulatedOutput = '';
|
|
271
440
|
let finalChunk = null;
|
|
272
441
|
for await (const chunk of stream) {
|
|
273
442
|
finalChunk = chunk;
|
|
274
|
-
if (typeof chunk.content === 'string') {
|
|
443
|
+
if (typeof chunk.content === 'string' && chunk.content) {
|
|
275
444
|
accumulatedOutput += chunk.content;
|
|
276
445
|
yield { type: 'content', content: chunk.content };
|
|
277
446
|
}
|
|
447
|
+
if (chunk.reasoning) {
|
|
448
|
+
yield { type: 'thinking', content: chunk.reasoning };
|
|
449
|
+
}
|
|
278
450
|
}
|
|
451
|
+
logLLMCallEnd(caller, llmStart, stats, {
|
|
452
|
+
contentLength: accumulatedOutput.length,
|
|
453
|
+
});
|
|
279
454
|
// Handle structured output
|
|
280
455
|
if (definition.output?.format === 'structured' && finalChunk) {
|
|
281
456
|
const structuredOutput = this.extractStructuredOutput(finalChunk);
|
|
282
457
|
yield { type: 'result', output: structuredOutput };
|
|
283
458
|
// Store structured output as JSON string in session
|
|
284
459
|
if (sessionId) {
|
|
285
|
-
this.conversationStore.addMessage(sessionId,
|
|
460
|
+
this.conversationStore.addMessage(sessionId, aiMessage(JSON.stringify(structuredOutput)));
|
|
286
461
|
}
|
|
287
462
|
}
|
|
288
463
|
else if (sessionId && accumulatedOutput) {
|
|
289
464
|
// Store AI response in session after streaming completes
|
|
290
|
-
this.conversationStore.addMessage(sessionId,
|
|
465
|
+
this.conversationStore.addMessage(sessionId, aiMessage(accumulatedOutput));
|
|
466
|
+
}
|
|
467
|
+
// Yield usage stats from the final chunk if available
|
|
468
|
+
const um = finalChunk?.usage_metadata;
|
|
469
|
+
if (um) {
|
|
470
|
+
yield {
|
|
471
|
+
type: 'usage',
|
|
472
|
+
input_tokens: um.input_tokens ?? 0,
|
|
473
|
+
output_tokens: um.output_tokens ?? 0,
|
|
474
|
+
total_tokens: um.total_tokens ?? 0,
|
|
475
|
+
};
|
|
291
476
|
}
|
|
292
477
|
}
|
|
293
478
|
}
|
|
294
|
-
buildMessagesWithHistory(
|
|
479
|
+
buildMessagesWithHistory(userContent, sessionId) {
|
|
295
480
|
const messages = [];
|
|
296
481
|
// Add history from store
|
|
297
482
|
if (sessionId && this.conversationStore.hasSession(sessionId)) {
|
|
298
483
|
const history = this.conversationStore.getMessages(sessionId);
|
|
299
484
|
for (const msg of history) {
|
|
300
|
-
messages.push(
|
|
301
|
-
role: msg._getType() === 'human' ? 'user' : 'assistant',
|
|
302
|
-
content: String(msg.content),
|
|
303
|
-
});
|
|
485
|
+
messages.push(msg);
|
|
304
486
|
}
|
|
305
487
|
}
|
|
306
|
-
// Add current user message
|
|
307
|
-
messages.push(
|
|
308
|
-
// Store user message
|
|
488
|
+
// Add current user message (with attachments if present)
|
|
489
|
+
messages.push(humanMessage(userContent));
|
|
490
|
+
// Store user message (text only — no base64 in memory)
|
|
309
491
|
if (sessionId) {
|
|
310
|
-
this.conversationStore.addMessage(sessionId,
|
|
492
|
+
this.conversationStore.addMessage(sessionId, humanMessage(contentToText(userContent)));
|
|
311
493
|
}
|
|
312
494
|
return messages;
|
|
313
495
|
}
|
|
496
|
+
buildStoredMessage(textResponse, toolSummaries) {
|
|
497
|
+
if (toolSummaries.length === 0)
|
|
498
|
+
return textResponse;
|
|
499
|
+
const summaryLines = toolSummaries.map((tc) => {
|
|
500
|
+
const inputStr = typeof tc.input === 'string' ? tc.input : JSON.stringify(tc.input);
|
|
501
|
+
const outputStr = typeof tc.output === 'string' ? tc.output : JSON.stringify(tc.output);
|
|
502
|
+
// Truncate to keep token usage reasonable
|
|
503
|
+
const truncated = (s, max) => s.length > max ? s.slice(0, max) + '...' : s;
|
|
504
|
+
return `[Tool: ${tc.tool}] Input: ${truncated(inputStr, 200)} → Output: ${truncated(outputStr, 500)}`;
|
|
505
|
+
});
|
|
506
|
+
return `${textResponse}\n\n<tool_history>\n${summaryLines.join('\n')}\n</tool_history>`;
|
|
507
|
+
}
|
|
508
|
+
extractToolSummariesFromMessages(messages) {
|
|
509
|
+
const summaries = [];
|
|
510
|
+
if (!messages)
|
|
511
|
+
return summaries;
|
|
512
|
+
// Collect tool call inputs from AI messages (tool_calls array)
|
|
513
|
+
const toolCallInputs = new Map();
|
|
514
|
+
for (const msg of messages) {
|
|
515
|
+
if (msg.role === 'ai' && Array.isArray(msg.tool_calls)) {
|
|
516
|
+
for (const tc of msg.tool_calls) {
|
|
517
|
+
toolCallInputs.set(tc.id, { name: tc.name, args: tc.args });
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
// Match tool messages to their inputs
|
|
522
|
+
for (const msg of messages) {
|
|
523
|
+
if (msg.role === 'tool') {
|
|
524
|
+
const callInfo = toolCallInputs.get(msg.tool_call_id);
|
|
525
|
+
summaries.push({
|
|
526
|
+
tool: msg.name ?? callInfo?.name ?? 'unknown',
|
|
527
|
+
input: callInfo?.args ?? null,
|
|
528
|
+
output: msg.content ?? null,
|
|
529
|
+
});
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
return summaries;
|
|
533
|
+
}
|
|
534
|
+
normalizeMemoryConfig(raw) {
|
|
535
|
+
if (!raw)
|
|
536
|
+
return null;
|
|
537
|
+
if (typeof raw === 'boolean')
|
|
538
|
+
return raw ? { enabled: true, maxLines: 100 } : null;
|
|
539
|
+
if (!raw.enabled)
|
|
540
|
+
return null;
|
|
541
|
+
return { enabled: true, maxLines: raw.maxLines ?? 100 };
|
|
542
|
+
}
|
|
543
|
+
buildMemoryPrompt(content, maxLines) {
|
|
544
|
+
const memoryBlock = content
|
|
545
|
+
? `<long_term_memory>\n${content}\n</long_term_memory>`
|
|
546
|
+
: '<long_term_memory>\n(empty - no memories saved yet)\n</long_term_memory>';
|
|
547
|
+
const instructions = `<memory_instructions>
|
|
548
|
+
You have long-term memory that persists across conversations.
|
|
549
|
+
|
|
550
|
+
The content inside <long_term_memory> above is your current saved memory.
|
|
551
|
+
|
|
552
|
+
You have a "save_memory" tool to update your memory. When you call it, provide the COMPLETE updated memory content (it replaces the entire file, it does not append).
|
|
553
|
+
|
|
554
|
+
Guidelines for using your memory:
|
|
555
|
+
- Save important facts, user preferences, decisions, and key context worth remembering
|
|
556
|
+
- Keep entries concise: use short bullet points, not full paragraphs
|
|
557
|
+
- Remove outdated or irrelevant entries when saving to keep memory focused
|
|
558
|
+
- Do not save trivial or easily re-derivable information
|
|
559
|
+
- Organize entries by topic or category when it helps clarity
|
|
560
|
+
- Your memory is limited to approximately ${maxLines} lines, so prioritize what matters most
|
|
561
|
+
</memory_instructions>`;
|
|
562
|
+
return `${memoryBlock}\n\n${instructions}`;
|
|
563
|
+
}
|
|
314
564
|
extractStructuredOutput(message) {
|
|
315
565
|
try {
|
|
316
566
|
// If message is already an object, return it
|