@aigne/core 1.72.0 → 1.74.0-beta
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 +11 -11
- package/dist/_virtual/rolldown_runtime.cjs +29 -0
- package/dist/agents/agent.cjs +874 -0
- package/dist/agents/agent.d.cts +967 -0
- package/dist/agents/agent.d.cts.map +1 -0
- package/dist/agents/agent.d.mts +967 -0
- package/dist/agents/agent.d.mts.map +1 -0
- package/dist/agents/agent.mjs +863 -0
- package/dist/agents/agent.mjs.map +1 -0
- package/dist/agents/ai-agent.cjs +524 -0
- package/dist/agents/ai-agent.d.cts +401 -0
- package/dist/agents/ai-agent.d.cts.map +1 -0
- package/dist/agents/ai-agent.d.mts +401 -0
- package/dist/agents/ai-agent.d.mts.map +1 -0
- package/dist/agents/ai-agent.mjs +519 -0
- package/dist/agents/ai-agent.mjs.map +1 -0
- package/dist/agents/chat-model.cjs +397 -0
- package/dist/agents/chat-model.d.cts +674 -0
- package/dist/agents/chat-model.d.cts.map +1 -0
- package/dist/agents/chat-model.d.mts +674 -0
- package/dist/agents/chat-model.d.mts.map +1 -0
- package/dist/agents/chat-model.mjs +391 -0
- package/dist/agents/chat-model.mjs.map +1 -0
- package/dist/agents/guide-rail-agent.cjs +17 -0
- package/dist/agents/guide-rail-agent.d.cts +67 -0
- package/dist/agents/guide-rail-agent.d.cts.map +1 -0
- package/dist/agents/guide-rail-agent.d.mts +67 -0
- package/dist/agents/guide-rail-agent.d.mts.map +1 -0
- package/dist/agents/guide-rail-agent.mjs +17 -0
- package/dist/agents/guide-rail-agent.mjs.map +1 -0
- package/dist/agents/image-agent.cjs +74 -0
- package/dist/agents/image-agent.d.cts +44 -0
- package/dist/agents/image-agent.d.cts.map +1 -0
- package/dist/agents/image-agent.d.mts +44 -0
- package/dist/agents/image-agent.d.mts.map +1 -0
- package/dist/agents/image-agent.mjs +72 -0
- package/dist/agents/image-agent.mjs.map +1 -0
- package/dist/agents/image-model.cjs +83 -0
- package/dist/agents/image-model.d.cts +276 -0
- package/dist/agents/image-model.d.cts.map +1 -0
- package/dist/agents/image-model.d.mts +276 -0
- package/dist/agents/image-model.d.mts.map +1 -0
- package/dist/agents/image-model.mjs +81 -0
- package/dist/agents/image-model.mjs.map +1 -0
- package/dist/agents/mcp-agent.cjs +307 -0
- package/dist/agents/mcp-agent.d.cts +235 -0
- package/dist/agents/mcp-agent.d.cts.map +1 -0
- package/dist/agents/mcp-agent.d.mts +235 -0
- package/dist/agents/mcp-agent.d.mts.map +1 -0
- package/dist/agents/mcp-agent.mjs +303 -0
- package/dist/agents/mcp-agent.mjs.map +1 -0
- package/dist/agents/model.cjs +143 -0
- package/dist/agents/model.d.cts +257 -0
- package/dist/agents/model.d.cts.map +1 -0
- package/dist/agents/model.d.mts +257 -0
- package/dist/agents/model.d.mts.map +1 -0
- package/dist/agents/model.mjs +136 -0
- package/dist/agents/model.mjs.map +1 -0
- package/dist/agents/team-agent.cjs +342 -0
- package/dist/agents/team-agent.d.cts +390 -0
- package/dist/agents/team-agent.d.cts.map +1 -0
- package/dist/agents/team-agent.d.mts +390 -0
- package/dist/agents/team-agent.d.mts.map +1 -0
- package/dist/agents/team-agent.mjs +339 -0
- package/dist/agents/team-agent.mjs.map +1 -0
- package/dist/agents/transform-agent.cjs +77 -0
- package/dist/agents/transform-agent.d.cts +99 -0
- package/dist/agents/transform-agent.d.cts.map +1 -0
- package/dist/agents/transform-agent.d.mts +99 -0
- package/dist/agents/transform-agent.d.mts.map +1 -0
- package/dist/agents/transform-agent.mjs +76 -0
- package/dist/agents/transform-agent.mjs.map +1 -0
- package/dist/agents/types.cjs +30 -0
- package/dist/agents/types.d.cts +34 -0
- package/dist/agents/types.d.cts.map +1 -0
- package/dist/agents/types.d.mts +34 -0
- package/dist/agents/types.d.mts.map +1 -0
- package/dist/agents/types.mjs +25 -0
- package/dist/agents/types.mjs.map +1 -0
- package/dist/agents/user-agent.cjs +87 -0
- package/dist/agents/user-agent.d.cts +32 -0
- package/dist/agents/user-agent.d.cts.map +1 -0
- package/dist/agents/user-agent.d.mts +32 -0
- package/dist/agents/user-agent.d.mts.map +1 -0
- package/dist/agents/user-agent.mjs +88 -0
- package/dist/agents/user-agent.mjs.map +1 -0
- package/dist/agents/video-model.cjs +66 -0
- package/dist/agents/video-model.d.cts +286 -0
- package/dist/agents/video-model.d.cts.map +1 -0
- package/dist/agents/video-model.d.mts +286 -0
- package/dist/agents/video-model.d.mts.map +1 -0
- package/dist/agents/video-model.mjs +64 -0
- package/dist/agents/video-model.mjs.map +1 -0
- package/dist/aigne/aigne.cjs +235 -0
- package/dist/aigne/aigne.d.cts +340 -0
- package/dist/aigne/aigne.d.cts.map +1 -0
- package/dist/aigne/aigne.d.mts +340 -0
- package/dist/aigne/aigne.d.mts.map +1 -0
- package/dist/aigne/aigne.mjs +235 -0
- package/dist/aigne/aigne.mjs.map +1 -0
- package/dist/aigne/context.cjs +377 -0
- package/dist/aigne/context.d.cts +226 -0
- package/dist/aigne/context.d.cts.map +1 -0
- package/dist/aigne/context.d.mts +226 -0
- package/dist/aigne/context.d.mts.map +1 -0
- package/dist/aigne/context.mjs +376 -0
- package/dist/aigne/context.mjs.map +1 -0
- package/dist/aigne/index.cjs +4 -0
- package/dist/aigne/index.d.mts +5 -0
- package/dist/aigne/index.mjs +6 -0
- package/dist/aigne/message-queue.cjs +102 -0
- package/dist/aigne/message-queue.d.cts +52 -0
- package/dist/aigne/message-queue.d.cts.map +1 -0
- package/dist/aigne/message-queue.d.mts +52 -0
- package/dist/aigne/message-queue.d.mts.map +1 -0
- package/dist/aigne/message-queue.mjs +99 -0
- package/dist/aigne/message-queue.mjs.map +1 -0
- package/dist/aigne/type.d.cts +32 -0
- package/dist/aigne/type.d.cts.map +1 -0
- package/dist/aigne/type.d.mts +32 -0
- package/dist/aigne/type.d.mts.map +1 -0
- package/dist/aigne/usage.cjs +29 -0
- package/dist/aigne/usage.d.cts +32 -0
- package/dist/aigne/usage.d.cts.map +1 -0
- package/dist/aigne/usage.d.mts +32 -0
- package/dist/aigne/usage.d.mts.map +1 -0
- package/dist/aigne/usage.mjs +28 -0
- package/dist/aigne/usage.mjs.map +1 -0
- package/dist/index.cjs +142 -0
- package/dist/index.d.cts +29 -0
- package/dist/index.d.mts +31 -0
- package/dist/index.mjs +31 -0
- package/dist/loader/agent-js.cjs +23 -0
- package/dist/loader/agent-js.d.cts +9 -0
- package/dist/loader/agent-js.d.cts.map +1 -0
- package/dist/loader/agent-js.d.mts +10 -0
- package/dist/loader/agent-js.d.mts.map +1 -0
- package/dist/loader/agent-js.mjs +23 -0
- package/dist/loader/agent-js.mjs.map +1 -0
- package/dist/loader/agent-yaml.cjs +109 -0
- package/dist/loader/agent-yaml.d.cts +87 -0
- package/dist/loader/agent-yaml.d.cts.map +1 -0
- package/dist/loader/agent-yaml.d.mts +87 -0
- package/dist/loader/agent-yaml.d.mts.map +1 -0
- package/dist/loader/agent-yaml.mjs +106 -0
- package/dist/loader/agent-yaml.mjs.map +1 -0
- package/dist/loader/agents.cjs +19 -0
- package/dist/loader/agents.d.cts +9 -0
- package/dist/loader/agents.d.cts.map +1 -0
- package/dist/loader/agents.d.mts +9 -0
- package/dist/loader/agents.d.mts.map +1 -0
- package/dist/loader/agents.mjs +20 -0
- package/dist/loader/agents.mjs.map +1 -0
- package/dist/loader/error.cjs +6 -0
- package/dist/loader/error.d.cts +5 -0
- package/dist/loader/error.d.cts.map +1 -0
- package/dist/loader/error.d.mts +5 -0
- package/dist/loader/error.d.mts.map +1 -0
- package/dist/loader/error.mjs +6 -0
- package/dist/loader/error.mjs.map +1 -0
- package/dist/loader/function-agent.cjs +9 -0
- package/dist/loader/function-agent.d.cts +7 -0
- package/dist/loader/function-agent.d.cts.map +1 -0
- package/dist/loader/function-agent.d.mts +7 -0
- package/dist/loader/function-agent.d.mts.map +1 -0
- package/dist/loader/function-agent.mjs +9 -0
- package/dist/loader/function-agent.mjs.map +1 -0
- package/dist/loader/index.cjs +233 -0
- package/dist/loader/index.d.cts +255 -0
- package/dist/loader/index.d.cts.map +1 -0
- package/dist/loader/index.d.mts +255 -0
- package/dist/loader/index.d.mts.map +1 -0
- package/dist/loader/index.mjs +228 -0
- package/dist/loader/index.mjs.map +1 -0
- package/dist/loader/schema.cjs +135 -0
- package/dist/loader/schema.d.cts +177 -0
- package/dist/loader/schema.d.cts.map +1 -0
- package/dist/loader/schema.d.mts +177 -0
- package/dist/loader/schema.d.mts.map +1 -0
- package/dist/loader/schema.mjs +127 -0
- package/dist/loader/schema.mjs.map +1 -0
- package/dist/memory/index.cjs +3 -0
- package/dist/memory/index.d.mts +3 -0
- package/dist/memory/index.mjs +5 -0
- package/dist/memory/memory.cjs +134 -0
- package/dist/memory/memory.d.cts +103 -0
- package/dist/memory/memory.d.cts.map +1 -0
- package/dist/memory/memory.d.mts +103 -0
- package/dist/memory/memory.d.mts.map +1 -0
- package/dist/memory/memory.mjs +133 -0
- package/dist/memory/memory.mjs.map +1 -0
- package/dist/memory/recorder.cjs +61 -0
- package/dist/memory/recorder.d.cts +98 -0
- package/dist/memory/recorder.d.cts.map +1 -0
- package/dist/memory/recorder.d.mts +98 -0
- package/dist/memory/recorder.d.mts.map +1 -0
- package/dist/memory/recorder.mjs +59 -0
- package/dist/memory/recorder.mjs.map +1 -0
- package/dist/memory/retriever.cjs +60 -0
- package/dist/memory/retriever.d.cts +111 -0
- package/dist/memory/retriever.d.cts.map +1 -0
- package/dist/memory/retriever.d.mts +111 -0
- package/dist/memory/retriever.d.mts.map +1 -0
- package/dist/memory/retriever.mjs +58 -0
- package/dist/memory/retriever.mjs.map +1 -0
- package/dist/prompt/agent-session.cjs +700 -0
- package/dist/prompt/agent-session.d.cts +167 -0
- package/dist/prompt/agent-session.d.cts.map +1 -0
- package/dist/prompt/agent-session.d.mts +167 -0
- package/dist/prompt/agent-session.d.mts.map +1 -0
- package/dist/prompt/agent-session.mjs +700 -0
- package/dist/prompt/agent-session.mjs.map +1 -0
- package/dist/prompt/compact/compactor.cjs +50 -0
- package/dist/prompt/compact/compactor.mjs +50 -0
- package/dist/prompt/compact/compactor.mjs.map +1 -0
- package/dist/prompt/compact/session-memory-extractor.cjs +137 -0
- package/dist/prompt/compact/session-memory-extractor.mjs +137 -0
- package/dist/prompt/compact/session-memory-extractor.mjs.map +1 -0
- package/dist/prompt/compact/types.cjs +59 -0
- package/dist/prompt/compact/types.d.cts +341 -0
- package/dist/prompt/compact/types.d.cts.map +1 -0
- package/dist/prompt/compact/types.d.mts +341 -0
- package/dist/prompt/compact/types.d.mts.map +1 -0
- package/dist/prompt/compact/types.mjs +49 -0
- package/dist/prompt/compact/types.mjs.map +1 -0
- package/dist/prompt/compact/user-memory-extractor.cjs +118 -0
- package/dist/prompt/compact/user-memory-extractor.mjs +118 -0
- package/dist/prompt/compact/user-memory-extractor.mjs.map +1 -0
- package/dist/prompt/context/afs/history.cjs +30 -0
- package/dist/prompt/context/afs/history.mjs +30 -0
- package/dist/prompt/context/afs/history.mjs.map +1 -0
- package/dist/prompt/context/afs/index.cjs +60 -0
- package/dist/prompt/context/afs/index.mjs +61 -0
- package/dist/prompt/context/afs/index.mjs.map +1 -0
- package/dist/prompt/context/index.cjs +18 -0
- package/dist/prompt/context/index.mjs +19 -0
- package/dist/prompt/context/index.mjs.map +1 -0
- package/dist/prompt/filters/index.cjs +22 -0
- package/dist/prompt/filters/index.mjs +21 -0
- package/dist/prompt/filters/index.mjs.map +1 -0
- package/dist/prompt/prompt-builder.cjs +291 -0
- package/dist/prompt/prompt-builder.d.cts +57 -0
- package/dist/prompt/prompt-builder.d.cts.map +1 -0
- package/dist/prompt/prompt-builder.d.mts +57 -0
- package/dist/prompt/prompt-builder.d.mts.map +1 -0
- package/dist/prompt/prompt-builder.mjs +291 -0
- package/dist/prompt/prompt-builder.mjs.map +1 -0
- package/dist/prompt/prompts/afs-builtin-prompt.cjs +12 -0
- package/dist/prompt/prompts/afs-builtin-prompt.mjs +13 -0
- package/dist/prompt/prompts/afs-builtin-prompt.mjs.map +1 -0
- package/dist/prompt/prompts/memory-message-template.cjs +10 -0
- package/dist/prompt/prompts/memory-message-template.mjs +10 -0
- package/dist/prompt/prompts/memory-message-template.mjs.map +1 -0
- package/dist/prompt/prompts/structured-stream-instructions.cjs +30 -0
- package/dist/prompt/prompts/structured-stream-instructions.mjs +30 -0
- package/dist/prompt/prompts/structured-stream-instructions.mjs.map +1 -0
- package/dist/prompt/skills/afs/agent-skill/agent-skill.cjs +66 -0
- package/dist/prompt/skills/afs/agent-skill/agent-skill.mjs +66 -0
- package/dist/prompt/skills/afs/agent-skill/agent-skill.mjs.map +1 -0
- package/dist/prompt/skills/afs/agent-skill/skill-loader.cjs +42 -0
- package/dist/prompt/skills/afs/agent-skill/skill-loader.mjs +41 -0
- package/dist/prompt/skills/afs/agent-skill/skill-loader.mjs.map +1 -0
- package/dist/prompt/skills/afs/base.cjs +9 -0
- package/dist/prompt/skills/afs/base.mjs +10 -0
- package/dist/prompt/skills/afs/base.mjs.map +1 -0
- package/dist/prompt/skills/afs/delete.cjs +50 -0
- package/dist/prompt/skills/afs/delete.mjs +50 -0
- package/dist/prompt/skills/afs/delete.mjs.map +1 -0
- package/dist/prompt/skills/afs/edit.cjs +92 -0
- package/dist/prompt/skills/afs/edit.mjs +92 -0
- package/dist/prompt/skills/afs/edit.mjs.map +1 -0
- package/dist/prompt/skills/afs/exec.cjs +36 -0
- package/dist/prompt/skills/afs/exec.mjs +36 -0
- package/dist/prompt/skills/afs/exec.mjs.map +1 -0
- package/dist/prompt/skills/afs/index.cjs +28 -0
- package/dist/prompt/skills/afs/index.mjs +29 -0
- package/dist/prompt/skills/afs/index.mjs.map +1 -0
- package/dist/prompt/skills/afs/list.cjs +69 -0
- package/dist/prompt/skills/afs/list.mjs +69 -0
- package/dist/prompt/skills/afs/list.mjs.map +1 -0
- package/dist/prompt/skills/afs/read.cjs +86 -0
- package/dist/prompt/skills/afs/read.mjs +86 -0
- package/dist/prompt/skills/afs/read.mjs.map +1 -0
- package/dist/prompt/skills/afs/rename.cjs +53 -0
- package/dist/prompt/skills/afs/rename.mjs +53 -0
- package/dist/prompt/skills/afs/rename.mjs.map +1 -0
- package/dist/prompt/skills/afs/search.cjs +63 -0
- package/dist/prompt/skills/afs/search.mjs +63 -0
- package/dist/prompt/skills/afs/search.mjs.map +1 -0
- package/dist/prompt/skills/afs/write.cjs +51 -0
- package/dist/prompt/skills/afs/write.mjs +51 -0
- package/dist/prompt/skills/afs/write.mjs.map +1 -0
- package/dist/prompt/template.cjs +229 -0
- package/dist/prompt/template.d.cts +247 -0
- package/dist/prompt/template.d.cts.map +1 -0
- package/dist/prompt/template.d.mts +247 -0
- package/dist/prompt/template.d.mts.map +1 -0
- package/dist/prompt/template.mjs +219 -0
- package/dist/prompt/template.mjs.map +1 -0
- package/dist/utils/agent-utils.cjs +49 -0
- package/dist/utils/agent-utils.d.cts +22 -0
- package/dist/utils/agent-utils.d.cts.map +1 -0
- package/dist/utils/agent-utils.d.mts +22 -0
- package/dist/utils/agent-utils.d.mts.map +1 -0
- package/dist/utils/agent-utils.mjs +46 -0
- package/dist/utils/agent-utils.mjs.map +1 -0
- package/dist/utils/camelize.cjs +34 -0
- package/dist/utils/camelize.d.cts +9 -0
- package/dist/utils/camelize.d.cts.map +1 -0
- package/dist/utils/camelize.d.mts +9 -0
- package/dist/utils/camelize.d.mts.map +1 -0
- package/dist/utils/camelize.mjs +33 -0
- package/dist/utils/camelize.mjs.map +1 -0
- package/dist/utils/event-stream.cjs +136 -0
- package/dist/utils/event-stream.d.cts +20 -0
- package/dist/utils/event-stream.d.cts.map +1 -0
- package/dist/utils/event-stream.d.mts +20 -0
- package/dist/utils/event-stream.d.mts.map +1 -0
- package/dist/utils/event-stream.mjs +133 -0
- package/dist/utils/event-stream.mjs.map +1 -0
- package/dist/utils/fetch.cjs +32 -0
- package/dist/utils/fetch.d.cts +8 -0
- package/dist/utils/fetch.d.cts.map +1 -0
- package/dist/utils/fetch.d.mts +8 -0
- package/dist/utils/fetch.d.mts.map +1 -0
- package/dist/utils/fetch.mjs +32 -0
- package/dist/utils/fetch.mjs.map +1 -0
- package/dist/utils/json-schema.cjs +107 -0
- package/dist/utils/json-schema.d.cts +20 -0
- package/dist/utils/json-schema.d.cts.map +1 -0
- package/dist/utils/json-schema.d.mts +20 -0
- package/dist/utils/json-schema.d.mts.map +1 -0
- package/dist/utils/json-schema.mjs +102 -0
- package/dist/utils/json-schema.mjs.map +1 -0
- package/dist/utils/json-utils.cjs +46 -0
- package/dist/utils/json-utils.d.cts +28 -0
- package/dist/utils/json-utils.d.cts.map +1 -0
- package/dist/utils/json-utils.d.mts +28 -0
- package/dist/utils/json-utils.d.mts.map +1 -0
- package/dist/utils/json-utils.mjs +44 -0
- package/dist/utils/json-utils.mjs.map +1 -0
- package/dist/utils/logger.cjs +72 -0
- package/dist/utils/logger.d.cts +41 -0
- package/dist/utils/logger.d.cts.map +1 -0
- package/dist/utils/logger.d.mts +41 -0
- package/dist/utils/logger.d.mts.map +1 -0
- package/dist/utils/logger.mjs +68 -0
- package/dist/utils/logger.mjs.map +1 -0
- package/dist/utils/mcp-utils.cjs +53 -0
- package/dist/utils/mcp-utils.d.cts +10 -0
- package/dist/utils/mcp-utils.d.cts.map +1 -0
- package/dist/utils/mcp-utils.d.mts +10 -0
- package/dist/utils/mcp-utils.d.mts.map +1 -0
- package/dist/utils/mcp-utils.mjs +51 -0
- package/dist/utils/mcp-utils.mjs.map +1 -0
- package/dist/utils/model-utils.cjs +12 -0
- package/dist/utils/model-utils.d.cts +8 -0
- package/dist/utils/model-utils.d.cts.map +1 -0
- package/dist/utils/model-utils.d.mts +8 -0
- package/dist/utils/model-utils.d.mts.map +1 -0
- package/dist/utils/model-utils.mjs +12 -0
- package/dist/utils/model-utils.mjs.map +1 -0
- package/dist/utils/promise.cjs +17 -0
- package/dist/utils/promise.d.cts +10 -0
- package/dist/utils/promise.d.cts.map +1 -0
- package/dist/utils/promise.d.mts +10 -0
- package/dist/utils/promise.d.mts.map +1 -0
- package/dist/utils/promise.mjs +17 -0
- package/dist/utils/promise.mjs.map +1 -0
- package/dist/utils/prompts.cjs +19 -0
- package/dist/utils/prompts.d.cts +6 -0
- package/dist/utils/prompts.d.cts.map +1 -0
- package/dist/utils/prompts.d.mts +6 -0
- package/dist/utils/prompts.d.mts.map +1 -0
- package/dist/utils/prompts.mjs +18 -0
- package/dist/utils/prompts.mjs.map +1 -0
- package/dist/utils/queue.cjs +273 -0
- package/dist/utils/queue.d.cts +60 -0
- package/dist/utils/queue.d.cts.map +1 -0
- package/dist/utils/queue.d.mts +60 -0
- package/dist/utils/queue.d.mts.map +1 -0
- package/dist/utils/queue.mjs +271 -0
- package/dist/utils/queue.mjs.map +1 -0
- package/dist/utils/role-utils.cjs +40 -0
- package/dist/utils/role-utils.d.cts +32 -0
- package/dist/utils/role-utils.d.cts.map +1 -0
- package/dist/utils/role-utils.d.mts +32 -0
- package/dist/utils/role-utils.d.mts.map +1 -0
- package/dist/utils/role-utils.mjs +38 -0
- package/dist/utils/role-utils.mjs.map +1 -0
- package/dist/utils/stream-polyfill.cjs +37 -0
- package/dist/utils/stream-polyfill.d.cts +1 -0
- package/dist/utils/stream-polyfill.d.mts +1 -0
- package/dist/utils/stream-polyfill.mjs +38 -0
- package/dist/utils/stream-polyfill.mjs.map +1 -0
- package/dist/utils/stream-utils.cjs +187 -0
- package/dist/utils/stream-utils.d.cts +30 -0
- package/dist/utils/stream-utils.d.cts.map +1 -0
- package/dist/utils/stream-utils.d.mts +30 -0
- package/dist/utils/stream-utils.d.mts.map +1 -0
- package/dist/utils/stream-utils.mjs +174 -0
- package/dist/utils/stream-utils.mjs.map +1 -0
- package/dist/utils/structured-stream-extractor.cjs +63 -0
- package/dist/utils/structured-stream-extractor.d.cts +23 -0
- package/dist/utils/structured-stream-extractor.d.cts.map +1 -0
- package/dist/utils/structured-stream-extractor.d.mts +23 -0
- package/dist/utils/structured-stream-extractor.d.mts.map +1 -0
- package/dist/utils/structured-stream-extractor.mjs +64 -0
- package/dist/utils/structured-stream-extractor.mjs.map +1 -0
- package/dist/utils/test/agent-response.cjs +16 -0
- package/dist/utils/test/agent-response.d.cts +12 -0
- package/dist/utils/test/agent-response.d.cts.map +1 -0
- package/dist/utils/test/agent-response.d.mts +13 -0
- package/dist/utils/test/agent-response.d.mts.map +1 -0
- package/dist/utils/test/agent-response.mjs +17 -0
- package/dist/utils/test/agent-response.mjs.map +1 -0
- package/dist/utils/test/openai-like-utils.cjs +73 -0
- package/dist/utils/test/openai-like-utils.d.cts +13 -0
- package/dist/utils/test/openai-like-utils.d.cts.map +1 -0
- package/dist/utils/test/openai-like-utils.d.mts +14 -0
- package/dist/utils/test/openai-like-utils.d.mts.map +1 -0
- package/dist/utils/test/openai-like-utils.mjs +68 -0
- package/dist/utils/test/openai-like-utils.mjs.map +1 -0
- package/dist/utils/token-estimator.cjs +57 -0
- package/dist/utils/token-estimator.d.cts +13 -0
- package/dist/utils/token-estimator.d.cts.map +1 -0
- package/dist/utils/token-estimator.d.mts +13 -0
- package/dist/utils/token-estimator.d.mts.map +1 -0
- package/dist/utils/token-estimator.mjs +57 -0
- package/dist/utils/token-estimator.mjs.map +1 -0
- package/dist/utils/type-utils.cjs +159 -0
- package/dist/utils/type-utils.d.cts +32 -0
- package/dist/utils/type-utils.d.cts.map +1 -0
- package/dist/utils/type-utils.d.mts +32 -0
- package/dist/utils/type-utils.d.mts.map +1 -0
- package/dist/utils/type-utils.mjs +141 -0
- package/dist/utils/type-utils.mjs.map +1 -0
- package/dist/utils/typed-event-emitter.cjs +0 -0
- package/dist/utils/typed-event-emitter.d.cts +13 -0
- package/dist/utils/typed-event-emitter.d.cts.map +1 -0
- package/dist/utils/typed-event-emitter.d.mts +13 -0
- package/dist/utils/typed-event-emitter.d.mts.map +1 -0
- package/dist/utils/typed-event-emitter.mjs +1 -0
- package/package.json +143 -62
- package/CHANGELOG.md +0 -2584
- package/lib/cjs/agents/agent.d.ts +0 -961
- package/lib/cjs/agents/agent.js +0 -961
- package/lib/cjs/agents/ai-agent.d.ts +0 -395
- package/lib/cjs/agents/ai-agent.js +0 -572
- package/lib/cjs/agents/chat-model.d.ts +0 -672
- package/lib/cjs/agents/chat-model.js +0 -457
- package/lib/cjs/agents/guide-rail-agent.d.ts +0 -62
- package/lib/cjs/agents/guide-rail-agent.js +0 -14
- package/lib/cjs/agents/image-agent.d.ts +0 -38
- package/lib/cjs/agents/image-agent.js +0 -71
- package/lib/cjs/agents/image-model.d.ts +0 -270
- package/lib/cjs/agents/image-model.js +0 -91
- package/lib/cjs/agents/mcp-agent.d.ts +0 -231
- package/lib/cjs/agents/mcp-agent.js +0 -366
- package/lib/cjs/agents/model.d.ts +0 -252
- package/lib/cjs/agents/model.js +0 -180
- package/lib/cjs/agents/team-agent.d.ts +0 -382
- package/lib/cjs/agents/team-agent.js +0 -386
- package/lib/cjs/agents/transform-agent.d.ts +0 -94
- package/lib/cjs/agents/transform-agent.js +0 -80
- package/lib/cjs/agents/types.d.ts +0 -31
- package/lib/cjs/agents/types.js +0 -40
- package/lib/cjs/agents/user-agent.d.ts +0 -27
- package/lib/cjs/agents/user-agent.js +0 -90
- package/lib/cjs/agents/video-model.d.ts +0 -280
- package/lib/cjs/agents/video-model.js +0 -67
- package/lib/cjs/aigne/aigne.d.ts +0 -335
- package/lib/cjs/aigne/aigne.js +0 -248
- package/lib/cjs/aigne/context.d.ts +0 -220
- package/lib/cjs/aigne/context.js +0 -423
- package/lib/cjs/aigne/index.d.ts +0 -4
- package/lib/cjs/aigne/index.js +0 -20
- package/lib/cjs/aigne/message-queue.d.ts +0 -48
- package/lib/cjs/aigne/message-queue.js +0 -109
- package/lib/cjs/aigne/type.d.ts +0 -26
- package/lib/cjs/aigne/type.js +0 -2
- package/lib/cjs/aigne/usage.d.ts +0 -28
- package/lib/cjs/aigne/usage.js +0 -34
- package/lib/cjs/index.d.ts +0 -21
- package/lib/cjs/index.js +0 -37
- package/lib/cjs/loader/agent-js.d.ts +0 -2
- package/lib/cjs/loader/agent-js.js +0 -21
- package/lib/cjs/loader/agent-yaml.d.ts +0 -78
- package/lib/cjs/loader/agent-yaml.js +0 -120
- package/lib/cjs/loader/agents.d.ts +0 -4
- package/lib/cjs/loader/agents.js +0 -17
- package/lib/cjs/loader/error.d.ts +0 -2
- package/lib/cjs/loader/error.js +0 -6
- package/lib/cjs/loader/function-agent.d.ts +0 -2
- package/lib/cjs/loader/function-agent.js +0 -7
- package/lib/cjs/loader/index.d.ts +0 -247
- package/lib/cjs/loader/index.js +0 -266
- package/lib/cjs/loader/schema.d.ts +0 -167
- package/lib/cjs/loader/schema.js +0 -162
- package/lib/cjs/memory/index.d.ts +0 -3
- package/lib/cjs/memory/index.js +0 -19
- package/lib/cjs/memory/memory.d.ts +0 -93
- package/lib/cjs/memory/memory.js +0 -147
- package/lib/cjs/memory/recorder.d.ts +0 -93
- package/lib/cjs/memory/recorder.js +0 -63
- package/lib/cjs/memory/retriever.d.ts +0 -106
- package/lib/cjs/memory/retriever.js +0 -60
- package/lib/cjs/package.json +0 -3
- package/lib/cjs/prompt/agent-session.d.ts +0 -163
- package/lib/cjs/prompt/agent-session.js +0 -1008
- package/lib/cjs/prompt/compact/compactor.d.ts +0 -7
- package/lib/cjs/prompt/compact/compactor.js +0 -52
- package/lib/cjs/prompt/compact/session-memory-extractor.d.ts +0 -7
- package/lib/cjs/prompt/compact/session-memory-extractor.js +0 -143
- package/lib/cjs/prompt/compact/types.d.ts +0 -336
- package/lib/cjs/prompt/compact/types.js +0 -53
- package/lib/cjs/prompt/compact/user-memory-extractor.d.ts +0 -7
- package/lib/cjs/prompt/compact/user-memory-extractor.js +0 -124
- package/lib/cjs/prompt/context/afs/history.d.ts +0 -9
- package/lib/cjs/prompt/context/afs/history.js +0 -33
- package/lib/cjs/prompt/context/afs/index.d.ts +0 -20
- package/lib/cjs/prompt/context/afs/index.js +0 -54
- package/lib/cjs/prompt/context/index.d.ts +0 -31
- package/lib/cjs/prompt/context/index.js +0 -18
- package/lib/cjs/prompt/filters/index.d.ts +0 -2
- package/lib/cjs/prompt/filters/index.js +0 -51
- package/lib/cjs/prompt/prompt-builder.d.ts +0 -50
- package/lib/cjs/prompt/prompt-builder.js +0 -352
- package/lib/cjs/prompt/prompts/afs-builtin-prompt.d.ts +0 -4
- package/lib/cjs/prompt/prompts/afs-builtin-prompt.js +0 -36
- package/lib/cjs/prompt/prompts/memory-message-template.d.ts +0 -1
- package/lib/cjs/prompt/prompts/memory-message-template.js +0 -8
- package/lib/cjs/prompt/prompts/structured-stream-instructions.d.ts +0 -7
- package/lib/cjs/prompt/prompts/structured-stream-instructions.js +0 -27
- package/lib/cjs/prompt/skills/afs/agent-skill/agent-skill.d.ts +0 -19
- package/lib/cjs/prompt/skills/afs/agent-skill/agent-skill.js +0 -69
- package/lib/cjs/prompt/skills/afs/agent-skill/skill-loader.d.ts +0 -12
- package/lib/cjs/prompt/skills/afs/agent-skill/skill-loader.js +0 -50
- package/lib/cjs/prompt/skills/afs/base.d.ts +0 -4
- package/lib/cjs/prompt/skills/afs/base.js +0 -8
- package/lib/cjs/prompt/skills/afs/delete.d.ts +0 -19
- package/lib/cjs/prompt/skills/afs/delete.js +0 -54
- package/lib/cjs/prompt/skills/afs/edit.d.ts +0 -24
- package/lib/cjs/prompt/skills/afs/edit.js +0 -124
- package/lib/cjs/prompt/skills/afs/exec.d.ts +0 -16
- package/lib/cjs/prompt/skills/afs/exec.js +0 -43
- package/lib/cjs/prompt/skills/afs/index.d.ts +0 -3
- package/lib/cjs/prompt/skills/afs/index.js +0 -26
- package/lib/cjs/prompt/skills/afs/list.d.ts +0 -24
- package/lib/cjs/prompt/skills/afs/list.js +0 -81
- package/lib/cjs/prompt/skills/afs/read.d.ts +0 -28
- package/lib/cjs/prompt/skills/afs/read.js +0 -105
- package/lib/cjs/prompt/skills/afs/rename.d.ts +0 -21
- package/lib/cjs/prompt/skills/afs/rename.js +0 -59
- package/lib/cjs/prompt/skills/afs/search.d.ts +0 -24
- package/lib/cjs/prompt/skills/afs/search.js +0 -71
- package/lib/cjs/prompt/skills/afs/write.d.ts +0 -20
- package/lib/cjs/prompt/skills/afs/write.js +0 -59
- package/lib/cjs/prompt/template.d.ts +0 -243
- package/lib/cjs/prompt/template.js +0 -265
- package/lib/cjs/utils/agent-utils.d.ts +0 -13
- package/lib/cjs/utils/agent-utils.js +0 -60
- package/lib/cjs/utils/camelize.d.ts +0 -7
- package/lib/cjs/utils/camelize.js +0 -38
- package/lib/cjs/utils/event-stream.d.ts +0 -15
- package/lib/cjs/utils/event-stream.js +0 -158
- package/lib/cjs/utils/fetch.d.ts +0 -4
- package/lib/cjs/utils/fetch.js +0 -36
- package/lib/cjs/utils/json-schema.d.ts +0 -15
- package/lib/cjs/utils/json-schema.js +0 -123
- package/lib/cjs/utils/json-utils.d.ts +0 -24
- package/lib/cjs/utils/json-utils.js +0 -48
- package/lib/cjs/utils/logger.d.ts +0 -39
- package/lib/cjs/utils/logger.js +0 -81
- package/lib/cjs/utils/mcp-utils.d.ts +0 -5
- package/lib/cjs/utils/mcp-utils.js +0 -52
- package/lib/cjs/utils/model-utils.d.ts +0 -3
- package/lib/cjs/utils/model-utils.js +0 -10
- package/lib/cjs/utils/promise.d.ts +0 -6
- package/lib/cjs/utils/promise.js +0 -12
- package/lib/cjs/utils/prompts.d.ts +0 -2
- package/lib/cjs/utils/prompts.js +0 -22
- package/lib/cjs/utils/queue.d.ts +0 -57
- package/lib/cjs/utils/queue.js +0 -318
- package/lib/cjs/utils/role-utils.d.ts +0 -31
- package/lib/cjs/utils/role-utils.js +0 -37
- package/lib/cjs/utils/stream-polyfill.d.ts +0 -1
- package/lib/cjs/utils/stream-polyfill.js +0 -38
- package/lib/cjs/utils/stream-utils.d.ts +0 -26
- package/lib/cjs/utils/stream-utils.js +0 -235
- package/lib/cjs/utils/structured-stream-extractor.d.ts +0 -14
- package/lib/cjs/utils/structured-stream-extractor.js +0 -68
- package/lib/cjs/utils/token-estimator.d.ts +0 -9
- package/lib/cjs/utils/token-estimator.js +0 -66
- package/lib/cjs/utils/type-utils.d.ts +0 -31
- package/lib/cjs/utils/type-utils.js +0 -202
- package/lib/cjs/utils/typed-event-emitter.d.ts +0 -10
- package/lib/cjs/utils/typed-event-emitter.js +0 -2
- package/lib/dts/agents/agent.d.ts +0 -961
- package/lib/dts/agents/ai-agent.d.ts +0 -395
- package/lib/dts/agents/chat-model.d.ts +0 -672
- package/lib/dts/agents/guide-rail-agent.d.ts +0 -62
- package/lib/dts/agents/image-agent.d.ts +0 -38
- package/lib/dts/agents/image-model.d.ts +0 -270
- package/lib/dts/agents/mcp-agent.d.ts +0 -231
- package/lib/dts/agents/model.d.ts +0 -252
- package/lib/dts/agents/team-agent.d.ts +0 -382
- package/lib/dts/agents/transform-agent.d.ts +0 -94
- package/lib/dts/agents/types.d.ts +0 -31
- package/lib/dts/agents/user-agent.d.ts +0 -27
- package/lib/dts/agents/video-model.d.ts +0 -280
- package/lib/dts/aigne/aigne.d.ts +0 -335
- package/lib/dts/aigne/context.d.ts +0 -220
- package/lib/dts/aigne/index.d.ts +0 -4
- package/lib/dts/aigne/message-queue.d.ts +0 -48
- package/lib/dts/aigne/type.d.ts +0 -26
- package/lib/dts/aigne/usage.d.ts +0 -28
- package/lib/dts/index.d.ts +0 -21
- package/lib/dts/loader/agent-js.d.ts +0 -2
- package/lib/dts/loader/agent-yaml.d.ts +0 -78
- package/lib/dts/loader/agents.d.ts +0 -4
- package/lib/dts/loader/error.d.ts +0 -2
- package/lib/dts/loader/function-agent.d.ts +0 -2
- package/lib/dts/loader/index.d.ts +0 -247
- package/lib/dts/loader/schema.d.ts +0 -167
- package/lib/dts/memory/index.d.ts +0 -3
- package/lib/dts/memory/memory.d.ts +0 -93
- package/lib/dts/memory/recorder.d.ts +0 -93
- package/lib/dts/memory/retriever.d.ts +0 -106
- package/lib/dts/prompt/agent-session.d.ts +0 -163
- package/lib/dts/prompt/compact/compactor.d.ts +0 -7
- package/lib/dts/prompt/compact/session-memory-extractor.d.ts +0 -7
- package/lib/dts/prompt/compact/types.d.ts +0 -336
- package/lib/dts/prompt/compact/user-memory-extractor.d.ts +0 -7
- package/lib/dts/prompt/context/afs/history.d.ts +0 -9
- package/lib/dts/prompt/context/afs/index.d.ts +0 -20
- package/lib/dts/prompt/context/index.d.ts +0 -31
- package/lib/dts/prompt/filters/index.d.ts +0 -2
- package/lib/dts/prompt/prompt-builder.d.ts +0 -50
- package/lib/dts/prompt/prompts/afs-builtin-prompt.d.ts +0 -4
- package/lib/dts/prompt/prompts/memory-message-template.d.ts +0 -1
- package/lib/dts/prompt/prompts/structured-stream-instructions.d.ts +0 -7
- package/lib/dts/prompt/skills/afs/agent-skill/agent-skill.d.ts +0 -19
- package/lib/dts/prompt/skills/afs/agent-skill/skill-loader.d.ts +0 -12
- package/lib/dts/prompt/skills/afs/base.d.ts +0 -4
- package/lib/dts/prompt/skills/afs/delete.d.ts +0 -19
- package/lib/dts/prompt/skills/afs/edit.d.ts +0 -24
- package/lib/dts/prompt/skills/afs/exec.d.ts +0 -16
- package/lib/dts/prompt/skills/afs/index.d.ts +0 -3
- package/lib/dts/prompt/skills/afs/list.d.ts +0 -24
- package/lib/dts/prompt/skills/afs/read.d.ts +0 -28
- package/lib/dts/prompt/skills/afs/rename.d.ts +0 -21
- package/lib/dts/prompt/skills/afs/search.d.ts +0 -24
- package/lib/dts/prompt/skills/afs/write.d.ts +0 -20
- package/lib/dts/prompt/template.d.ts +0 -243
- package/lib/dts/utils/agent-utils.d.ts +0 -13
- package/lib/dts/utils/camelize.d.ts +0 -7
- package/lib/dts/utils/event-stream.d.ts +0 -15
- package/lib/dts/utils/fetch.d.ts +0 -4
- package/lib/dts/utils/json-schema.d.ts +0 -15
- package/lib/dts/utils/json-utils.d.ts +0 -24
- package/lib/dts/utils/logger.d.ts +0 -39
- package/lib/dts/utils/mcp-utils.d.ts +0 -5
- package/lib/dts/utils/model-utils.d.ts +0 -3
- package/lib/dts/utils/promise.d.ts +0 -6
- package/lib/dts/utils/prompts.d.ts +0 -2
- package/lib/dts/utils/queue.d.ts +0 -57
- package/lib/dts/utils/role-utils.d.ts +0 -31
- package/lib/dts/utils/stream-polyfill.d.ts +0 -1
- package/lib/dts/utils/stream-utils.d.ts +0 -26
- package/lib/dts/utils/structured-stream-extractor.d.ts +0 -14
- package/lib/dts/utils/token-estimator.d.ts +0 -9
- package/lib/dts/utils/type-utils.d.ts +0 -31
- package/lib/dts/utils/typed-event-emitter.d.ts +0 -10
- package/lib/esm/agents/agent.d.ts +0 -961
- package/lib/esm/agents/agent.js +0 -911
- package/lib/esm/agents/ai-agent.d.ts +0 -395
- package/lib/esm/agents/ai-agent.js +0 -535
- package/lib/esm/agents/chat-model.d.ts +0 -672
- package/lib/esm/agents/chat-model.js +0 -419
- package/lib/esm/agents/guide-rail-agent.d.ts +0 -62
- package/lib/esm/agents/guide-rail-agent.js +0 -11
- package/lib/esm/agents/image-agent.d.ts +0 -38
- package/lib/esm/agents/image-agent.js +0 -64
- package/lib/esm/agents/image-model.d.ts +0 -270
- package/lib/esm/agents/image-model.js +0 -87
- package/lib/esm/agents/mcp-agent.d.ts +0 -231
- package/lib/esm/agents/mcp-agent.js +0 -325
- package/lib/esm/agents/model.d.ts +0 -252
- package/lib/esm/agents/model.js +0 -143
- package/lib/esm/agents/team-agent.d.ts +0 -382
- package/lib/esm/agents/team-agent.js +0 -346
- package/lib/esm/agents/transform-agent.d.ts +0 -94
- package/lib/esm/agents/transform-agent.js +0 -73
- package/lib/esm/agents/types.d.ts +0 -31
- package/lib/esm/agents/types.js +0 -30
- package/lib/esm/agents/user-agent.d.ts +0 -27
- package/lib/esm/agents/user-agent.js +0 -86
- package/lib/esm/agents/video-model.d.ts +0 -280
- package/lib/esm/agents/video-model.js +0 -63
- package/lib/esm/aigne/aigne.d.ts +0 -335
- package/lib/esm/aigne/aigne.js +0 -244
- package/lib/esm/aigne/context.d.ts +0 -220
- package/lib/esm/aigne/context.js +0 -416
- package/lib/esm/aigne/index.d.ts +0 -4
- package/lib/esm/aigne/index.js +0 -4
- package/lib/esm/aigne/message-queue.d.ts +0 -48
- package/lib/esm/aigne/message-queue.js +0 -104
- package/lib/esm/aigne/type.d.ts +0 -26
- package/lib/esm/aigne/type.js +0 -1
- package/lib/esm/aigne/usage.d.ts +0 -28
- package/lib/esm/aigne/usage.js +0 -30
- package/lib/esm/index.d.ts +0 -21
- package/lib/esm/index.js +0 -21
- package/lib/esm/loader/agent-js.d.ts +0 -2
- package/lib/esm/loader/agent-js.js +0 -18
- package/lib/esm/loader/agent-yaml.d.ts +0 -78
- package/lib/esm/loader/agent-yaml.js +0 -113
- package/lib/esm/loader/agents.d.ts +0 -4
- package/lib/esm/loader/agents.js +0 -14
- package/lib/esm/loader/error.d.ts +0 -2
- package/lib/esm/loader/error.js +0 -2
- package/lib/esm/loader/function-agent.d.ts +0 -2
- package/lib/esm/loader/function-agent.js +0 -4
- package/lib/esm/loader/index.d.ts +0 -247
- package/lib/esm/loader/index.js +0 -258
- package/lib/esm/loader/schema.d.ts +0 -167
- package/lib/esm/loader/schema.js +0 -153
- package/lib/esm/memory/index.d.ts +0 -3
- package/lib/esm/memory/index.js +0 -3
- package/lib/esm/memory/memory.d.ts +0 -93
- package/lib/esm/memory/memory.js +0 -142
- package/lib/esm/memory/recorder.d.ts +0 -93
- package/lib/esm/memory/recorder.js +0 -59
- package/lib/esm/memory/retriever.d.ts +0 -106
- package/lib/esm/memory/retriever.js +0 -56
- package/lib/esm/package.json +0 -3
- package/lib/esm/prompt/agent-session.d.ts +0 -163
- package/lib/esm/prompt/agent-session.js +0 -968
- package/lib/esm/prompt/compact/compactor.d.ts +0 -7
- package/lib/esm/prompt/compact/compactor.js +0 -48
- package/lib/esm/prompt/compact/session-memory-extractor.d.ts +0 -7
- package/lib/esm/prompt/compact/session-memory-extractor.js +0 -139
- package/lib/esm/prompt/compact/types.d.ts +0 -336
- package/lib/esm/prompt/compact/types.js +0 -50
- package/lib/esm/prompt/compact/user-memory-extractor.d.ts +0 -7
- package/lib/esm/prompt/compact/user-memory-extractor.js +0 -120
- package/lib/esm/prompt/context/afs/history.d.ts +0 -9
- package/lib/esm/prompt/context/afs/history.js +0 -30
- package/lib/esm/prompt/context/afs/index.d.ts +0 -20
- package/lib/esm/prompt/context/afs/index.js +0 -51
- package/lib/esm/prompt/context/index.d.ts +0 -31
- package/lib/esm/prompt/context/index.js +0 -15
- package/lib/esm/prompt/filters/index.d.ts +0 -2
- package/lib/esm/prompt/filters/index.js +0 -15
- package/lib/esm/prompt/prompt-builder.d.ts +0 -50
- package/lib/esm/prompt/prompt-builder.js +0 -348
- package/lib/esm/prompt/prompts/afs-builtin-prompt.d.ts +0 -4
- package/lib/esm/prompt/prompts/afs-builtin-prompt.js +0 -32
- package/lib/esm/prompt/prompts/memory-message-template.d.ts +0 -1
- package/lib/esm/prompt/prompts/memory-message-template.js +0 -5
- package/lib/esm/prompt/prompts/structured-stream-instructions.d.ts +0 -7
- package/lib/esm/prompt/prompts/structured-stream-instructions.js +0 -24
- package/lib/esm/prompt/skills/afs/agent-skill/agent-skill.d.ts +0 -19
- package/lib/esm/prompt/skills/afs/agent-skill/agent-skill.js +0 -65
- package/lib/esm/prompt/skills/afs/agent-skill/skill-loader.d.ts +0 -12
- package/lib/esm/prompt/skills/afs/agent-skill/skill-loader.js +0 -43
- package/lib/esm/prompt/skills/afs/base.d.ts +0 -4
- package/lib/esm/prompt/skills/afs/base.js +0 -4
- package/lib/esm/prompt/skills/afs/delete.d.ts +0 -19
- package/lib/esm/prompt/skills/afs/delete.js +0 -50
- package/lib/esm/prompt/skills/afs/edit.d.ts +0 -24
- package/lib/esm/prompt/skills/afs/edit.js +0 -120
- package/lib/esm/prompt/skills/afs/exec.d.ts +0 -16
- package/lib/esm/prompt/skills/afs/exec.js +0 -39
- package/lib/esm/prompt/skills/afs/index.d.ts +0 -3
- package/lib/esm/prompt/skills/afs/index.js +0 -23
- package/lib/esm/prompt/skills/afs/list.d.ts +0 -24
- package/lib/esm/prompt/skills/afs/list.js +0 -77
- package/lib/esm/prompt/skills/afs/read.d.ts +0 -28
- package/lib/esm/prompt/skills/afs/read.js +0 -101
- package/lib/esm/prompt/skills/afs/rename.d.ts +0 -21
- package/lib/esm/prompt/skills/afs/rename.js +0 -55
- package/lib/esm/prompt/skills/afs/search.d.ts +0 -24
- package/lib/esm/prompt/skills/afs/search.js +0 -67
- package/lib/esm/prompt/skills/afs/write.d.ts +0 -20
- package/lib/esm/prompt/skills/afs/write.js +0 -55
- package/lib/esm/prompt/template.d.ts +0 -243
- package/lib/esm/prompt/template.js +0 -249
- package/lib/esm/utils/agent-utils.d.ts +0 -13
- package/lib/esm/utils/agent-utils.js +0 -54
- package/lib/esm/utils/camelize.d.ts +0 -7
- package/lib/esm/utils/camelize.js +0 -34
- package/lib/esm/utils/event-stream.d.ts +0 -15
- package/lib/esm/utils/event-stream.js +0 -151
- package/lib/esm/utils/fetch.d.ts +0 -4
- package/lib/esm/utils/fetch.js +0 -33
- package/lib/esm/utils/json-schema.d.ts +0 -15
- package/lib/esm/utils/json-schema.js +0 -114
- package/lib/esm/utils/json-utils.d.ts +0 -24
- package/lib/esm/utils/json-utils.js +0 -41
- package/lib/esm/utils/logger.d.ts +0 -39
- package/lib/esm/utils/logger.js +0 -73
- package/lib/esm/utils/mcp-utils.d.ts +0 -5
- package/lib/esm/utils/mcp-utils.js +0 -47
- package/lib/esm/utils/model-utils.d.ts +0 -3
- package/lib/esm/utils/model-utils.js +0 -7
- package/lib/esm/utils/promise.d.ts +0 -6
- package/lib/esm/utils/promise.js +0 -9
- package/lib/esm/utils/prompts.d.ts +0 -2
- package/lib/esm/utils/prompts.js +0 -18
- package/lib/esm/utils/queue.d.ts +0 -57
- package/lib/esm/utils/queue.js +0 -315
- package/lib/esm/utils/role-utils.d.ts +0 -31
- package/lib/esm/utils/role-utils.js +0 -33
- package/lib/esm/utils/stream-polyfill.d.ts +0 -1
- package/lib/esm/utils/stream-polyfill.js +0 -37
- package/lib/esm/utils/stream-utils.d.ts +0 -26
- package/lib/esm/utils/stream-utils.js +0 -217
- package/lib/esm/utils/structured-stream-extractor.d.ts +0 -14
- package/lib/esm/utils/structured-stream-extractor.js +0 -64
- package/lib/esm/utils/token-estimator.d.ts +0 -9
- package/lib/esm/utils/token-estimator.js +0 -63
- package/lib/esm/utils/type-utils.d.ts +0 -31
- package/lib/esm/utils/type-utils.js +0 -181
- package/lib/esm/utils/typed-event-emitter.d.ts +0 -10
- package/lib/esm/utils/typed-event-emitter.js +0 -1
|
@@ -0,0 +1,967 @@
|
|
|
1
|
+
import { Nullish, PromiseOrValue, XOr } from "../utils/type-utils.mjs";
|
|
2
|
+
import { ChatModel, ChatModelInputMessage } from "./chat-model.mjs";
|
|
3
|
+
import { ImageModel } from "./image-model.mjs";
|
|
4
|
+
import { MessagePayload } from "../aigne/message-queue.mjs";
|
|
5
|
+
import { MemoryRecorderInput } from "../memory/recorder.mjs";
|
|
6
|
+
import { MemoryRetrieverInput } from "../memory/retriever.mjs";
|
|
7
|
+
import { Memory, MemoryAgent } from "../memory/memory.mjs";
|
|
8
|
+
import { ContextUsage } from "../aigne/usage.mjs";
|
|
9
|
+
import { AgentEvent, Context, UserContext } from "../aigne/context.mjs";
|
|
10
|
+
import { GuideRailAgent, GuideRailAgentOutput } from "./guide-rail-agent.mjs";
|
|
11
|
+
import { AgentClass, GetterSchema, TransferAgentOutput, getterSchema, isTransferAgentOutput, replaceTransferAgentToName, transferAgentOutputKey, transferToAgentOutput } from "./types.mjs";
|
|
12
|
+
import { AFS, AFSExecOptions, AFSExecResult, AFSListOptions, AFSListResult, AFSModule, AFSOptions, AFSReadResult, AFSSearchOptions } from "@aigne/afs";
|
|
13
|
+
import { nodejs } from "@aigne/utils/nodejs";
|
|
14
|
+
import { ZodObject, ZodType, z as z$1 } from "zod";
|
|
15
|
+
import * as prompts from "@inquirer/prompts";
|
|
16
|
+
|
|
17
|
+
//#region src/agents/agent.d.ts
|
|
18
|
+
declare const DEFAULT_INPUT_ACTION_GET = "$get";
|
|
19
|
+
/**
|
|
20
|
+
* Basic message type that can contain any key-value pairs
|
|
21
|
+
*/
|
|
22
|
+
interface Message extends Record<string, unknown> {
|
|
23
|
+
$meta?: {
|
|
24
|
+
usage?: ContextUsage;
|
|
25
|
+
[key: string]: unknown;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Topics the agent subscribes to, can be a single topic string or an array of topic strings
|
|
30
|
+
*/
|
|
31
|
+
type SubscribeTopic = string | string[];
|
|
32
|
+
/**
|
|
33
|
+
* Topics the agent publishes to, can be:
|
|
34
|
+
* - A single topic string
|
|
35
|
+
* - An array of topic strings
|
|
36
|
+
* - A function that receives the output and returns topic(s)
|
|
37
|
+
*
|
|
38
|
+
* @template O The agent output message type
|
|
39
|
+
*/
|
|
40
|
+
type PublishTopic<O extends Message> = string | string[] | ((output: O) => PromiseOrValue<Nullish<string | string[]>>);
|
|
41
|
+
type TaskRenderMode = "hide" | "collapse";
|
|
42
|
+
/**
|
|
43
|
+
* Configuration options for an agent
|
|
44
|
+
*
|
|
45
|
+
* @template I The agent input message type
|
|
46
|
+
* @template O The agent output message type
|
|
47
|
+
*/
|
|
48
|
+
interface AgentOptions<I extends Message = Message, O extends Message = Message> extends Partial<Pick<Agent, "guideRails">> {
|
|
49
|
+
/**
|
|
50
|
+
* Topics the agent should subscribe to
|
|
51
|
+
*
|
|
52
|
+
* These topics determine which messages the agent will receive
|
|
53
|
+
* from the system
|
|
54
|
+
*/
|
|
55
|
+
subscribeTopic?: SubscribeTopic;
|
|
56
|
+
/**
|
|
57
|
+
* Topics the agent should publish to
|
|
58
|
+
*
|
|
59
|
+
* These topics determine where the agent's output messages
|
|
60
|
+
* will be sent in the system
|
|
61
|
+
*/
|
|
62
|
+
publishTopic?: PublishTopic<O>;
|
|
63
|
+
/**
|
|
64
|
+
* Name of the agent
|
|
65
|
+
*
|
|
66
|
+
* Used for identification and logging. Defaults to the constructor name
|
|
67
|
+
* if not specified
|
|
68
|
+
*/
|
|
69
|
+
name?: string;
|
|
70
|
+
/**
|
|
71
|
+
* Alias for the agent, can be used to refer to the agent by multiple names, especially in AIGNE CLI
|
|
72
|
+
*/
|
|
73
|
+
alias?: string[];
|
|
74
|
+
/**
|
|
75
|
+
* Description of the agent
|
|
76
|
+
*
|
|
77
|
+
* A human-readable description of what the agent does, useful
|
|
78
|
+
* for documentation and debugging
|
|
79
|
+
*/
|
|
80
|
+
description?: string;
|
|
81
|
+
model?: ChatModel;
|
|
82
|
+
imageModel?: ImageModel;
|
|
83
|
+
taskTitle?: string | ((input: I) => PromiseOrValue<string | undefined>);
|
|
84
|
+
taskRenderMode?: TaskRenderMode;
|
|
85
|
+
/**
|
|
86
|
+
* Zod schema defining the input message structure
|
|
87
|
+
*
|
|
88
|
+
* Used to validate that input messages conform to the expected format
|
|
89
|
+
*/
|
|
90
|
+
inputSchema?: AgentInputOutputSchema<I>;
|
|
91
|
+
/**
|
|
92
|
+
* Default input message for the agent, it can be used to provide partial input
|
|
93
|
+
* or default values for the agent's input schema.
|
|
94
|
+
*/
|
|
95
|
+
defaultInput?: Agent<I, O>["defaultInput"];
|
|
96
|
+
/**
|
|
97
|
+
* Zod schema defining the output message structure
|
|
98
|
+
*
|
|
99
|
+
* Used to validate that output messages conform to the expected format
|
|
100
|
+
*/
|
|
101
|
+
outputSchema?: AgentInputOutputSchema<O>;
|
|
102
|
+
/**
|
|
103
|
+
* Whether to include input in the output
|
|
104
|
+
*
|
|
105
|
+
* When true, the agent will merge input fields into the output object
|
|
106
|
+
*/
|
|
107
|
+
includeInputInOutput?: boolean;
|
|
108
|
+
/**
|
|
109
|
+
* List of skills (other agents or functions) this agent has
|
|
110
|
+
*
|
|
111
|
+
* These skills can be used by the agent to delegate tasks or
|
|
112
|
+
* extend its capabilities
|
|
113
|
+
*/
|
|
114
|
+
skills?: (Agent | FunctionAgentFn)[];
|
|
115
|
+
/**
|
|
116
|
+
* Whether to disable emitting events for agent actions
|
|
117
|
+
*
|
|
118
|
+
* When true, the agent won't emit events like agentStarted,
|
|
119
|
+
* agentSucceed, or agentFailed
|
|
120
|
+
*/
|
|
121
|
+
disableEvents?: boolean;
|
|
122
|
+
/**
|
|
123
|
+
* One or more memory agents this agent can use
|
|
124
|
+
*/
|
|
125
|
+
memory?: MemoryAgent | MemoryAgent[];
|
|
126
|
+
afs?: true | AFSOptions | AFS | ((afs: AFS) => AFS);
|
|
127
|
+
asyncMemoryRecord?: boolean;
|
|
128
|
+
/**
|
|
129
|
+
* Maximum number of memory items to retrieve
|
|
130
|
+
*/
|
|
131
|
+
maxRetrieveMemoryCount?: number;
|
|
132
|
+
hooks?: AgentHooks<I, O> | AgentHooks<I, O>[];
|
|
133
|
+
retryOnError?: Agent<I, O>["retryOnError"] | boolean;
|
|
134
|
+
}
|
|
135
|
+
declare const agentOptionsSchema: ZodObject<{ [key in keyof AgentOptions]: ZodType<AgentOptions[key]> }>;
|
|
136
|
+
interface AgentInvokeOptions<U extends UserContext = UserContext> {
|
|
137
|
+
/**
|
|
138
|
+
* The execution context for the agent
|
|
139
|
+
*
|
|
140
|
+
* The context provides the runtime environment for agent execution, including:
|
|
141
|
+
* - Event emission and subscription management
|
|
142
|
+
* - Inter-agent communication and message passing
|
|
143
|
+
* - Resource usage tracking and limits enforcement
|
|
144
|
+
* - Timeout and status management
|
|
145
|
+
* - Memory and state management across agent invocations
|
|
146
|
+
*
|
|
147
|
+
* Each agent invocation requires a context to coordinate with the broader
|
|
148
|
+
* agent system and maintain proper isolation and resource control.
|
|
149
|
+
*/
|
|
150
|
+
context: Context<U>;
|
|
151
|
+
model?: ChatModel;
|
|
152
|
+
imageModel?: ImageModel;
|
|
153
|
+
/**
|
|
154
|
+
* Whether to enable streaming response
|
|
155
|
+
*
|
|
156
|
+
* When true, the invoke method returns a ReadableStream that emits
|
|
157
|
+
* chunks of the response as they become available, allowing for
|
|
158
|
+
* real-time display of results
|
|
159
|
+
*
|
|
160
|
+
* When false or undefined, the invoke method waits for full completion
|
|
161
|
+
* and returns the final JSON result
|
|
162
|
+
*/
|
|
163
|
+
streaming?: boolean;
|
|
164
|
+
/**
|
|
165
|
+
* Optional hooks for agent invocation
|
|
166
|
+
*/
|
|
167
|
+
hooks?: AgentHooks<any, any> | AgentHooks<any, any>[];
|
|
168
|
+
/**
|
|
169
|
+
* @inquirer/prompts used for collecting user input during agent execution
|
|
170
|
+
*
|
|
171
|
+
* This property only exists in the CLI context by command `aigne run`
|
|
172
|
+
*/
|
|
173
|
+
prompts?: typeof prompts;
|
|
174
|
+
/**
|
|
175
|
+
* The caller agent that invoked this agent
|
|
176
|
+
*/
|
|
177
|
+
caller?: Agent;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Agent is the base class for all agents.
|
|
181
|
+
* It provides a mechanism for defining input/output schemas and implementing processing logic,
|
|
182
|
+
* serving as the foundation of the entire agent system.
|
|
183
|
+
*
|
|
184
|
+
* By extending the Agent class and implementing the process method, you can create custom agents
|
|
185
|
+
* with various capabilities:
|
|
186
|
+
* - Process structured input and output data
|
|
187
|
+
* - Validate data formats using schemas
|
|
188
|
+
* - Communicate between agents through contexts
|
|
189
|
+
* - Support streaming or non-streaming responses
|
|
190
|
+
* - Maintain memory of past interactions
|
|
191
|
+
* - Output in multiple formats (JSON/text)
|
|
192
|
+
* - Forward tasks to other agents
|
|
193
|
+
*
|
|
194
|
+
* @template I The input message type the agent accepts
|
|
195
|
+
* @template O The output message type the agent returns
|
|
196
|
+
*
|
|
197
|
+
* @example
|
|
198
|
+
* Here's an example of how to create a custom agent:
|
|
199
|
+
* {@includeCode ../../test/agents/agent.test.ts#example-custom-agent}
|
|
200
|
+
*/
|
|
201
|
+
declare abstract class Agent<I extends Message = any, O extends Message = any> implements AFSModule {
|
|
202
|
+
/**
|
|
203
|
+
* Custom object inspection behavior
|
|
204
|
+
*
|
|
205
|
+
* When using Node.js's util.inspect function to inspect an agent,
|
|
206
|
+
* only the agent's name will be shown, making output more concise
|
|
207
|
+
*
|
|
208
|
+
* @returns Agent name
|
|
209
|
+
*/
|
|
210
|
+
[nodejs.customInspect]: () => string;
|
|
211
|
+
static load<I extends Message = any, O extends Message = any>(_options: {
|
|
212
|
+
filepath: string;
|
|
213
|
+
parsed: object;
|
|
214
|
+
}): Promise<Agent<I, O>>;
|
|
215
|
+
constructor(options?: AgentOptions<I, O>);
|
|
216
|
+
afs?: AFS;
|
|
217
|
+
tag?: string;
|
|
218
|
+
/**
|
|
219
|
+
* List of memories this agent can use
|
|
220
|
+
*
|
|
221
|
+
* @deprecated use afs instead
|
|
222
|
+
*/
|
|
223
|
+
readonly memories: MemoryAgent[];
|
|
224
|
+
asyncMemoryRecord?: boolean;
|
|
225
|
+
/**
|
|
226
|
+
* Maximum number of memory items to retrieve
|
|
227
|
+
*/
|
|
228
|
+
maxRetrieveMemoryCount?: number;
|
|
229
|
+
/**
|
|
230
|
+
* Lifecycle hooks for agent processing.
|
|
231
|
+
*
|
|
232
|
+
* Hooks enable tracing, logging, monitoring, and custom behavior
|
|
233
|
+
* without modifying the core agent implementation
|
|
234
|
+
*
|
|
235
|
+
* @example
|
|
236
|
+
* Here's an example of using hooks:
|
|
237
|
+
* {@includeCode ../../test/agents/agent.test.ts#example-agent-hooks}
|
|
238
|
+
*/
|
|
239
|
+
readonly hooks: AgentHooks<I, O>[];
|
|
240
|
+
retryOnError?: {
|
|
241
|
+
retries?: number;
|
|
242
|
+
minTimeout?: number;
|
|
243
|
+
factor?: number;
|
|
244
|
+
randomize?: boolean;
|
|
245
|
+
shouldRetry?: (error: Error) => boolean | Promise<boolean>;
|
|
246
|
+
};
|
|
247
|
+
/**
|
|
248
|
+
* List of GuideRail agents applied to this agent
|
|
249
|
+
*
|
|
250
|
+
* GuideRail agents validate, transform, or control the message flow by:
|
|
251
|
+
* - Enforcing rules and safety policies
|
|
252
|
+
* - Validating inputs/outputs against specific criteria
|
|
253
|
+
* - Implementing business logic validations
|
|
254
|
+
* - Monitoring and auditing agent behavior
|
|
255
|
+
*
|
|
256
|
+
* Each GuideRail agent can examine both input and expected output,
|
|
257
|
+
* and has the ability to abort the process with an explanation
|
|
258
|
+
*
|
|
259
|
+
* @example
|
|
260
|
+
* Here's an example of using GuideRail agents:
|
|
261
|
+
*
|
|
262
|
+
* {@includeCode ../../test/agents/agent.test.ts#example-agent-guide-rails}
|
|
263
|
+
*/
|
|
264
|
+
readonly guideRails?: GuideRailAgent[];
|
|
265
|
+
/**
|
|
266
|
+
* Name of the agent, used for identification and logging
|
|
267
|
+
*
|
|
268
|
+
* Defaults to the class constructor name if not specified in options
|
|
269
|
+
*/
|
|
270
|
+
readonly name: string;
|
|
271
|
+
/**
|
|
272
|
+
* Alias for the agent, can be used to refer to the agent by multiple names, especially in AIGNE CLI
|
|
273
|
+
*/
|
|
274
|
+
readonly alias?: string[];
|
|
275
|
+
/**
|
|
276
|
+
* Default topic this agent subscribes to
|
|
277
|
+
*
|
|
278
|
+
* Each agent has a default topic in the format "$agent_[agent name]"
|
|
279
|
+
* The agent automatically subscribes to this topic to receive messages
|
|
280
|
+
*
|
|
281
|
+
* @returns The default topic string
|
|
282
|
+
*/
|
|
283
|
+
get topic(): string;
|
|
284
|
+
/**
|
|
285
|
+
* Description of the agent's purpose and capabilities
|
|
286
|
+
*
|
|
287
|
+
* Useful for documentation and when agents need to understand
|
|
288
|
+
* each other's roles in a multi-agent system
|
|
289
|
+
*/
|
|
290
|
+
readonly description?: string;
|
|
291
|
+
model?: ChatModel;
|
|
292
|
+
imageModel?: ImageModel;
|
|
293
|
+
taskTitle?: string | ((input: Message) => PromiseOrValue<string | undefined>);
|
|
294
|
+
renderTaskTitle(input: I): Promise<string | undefined>;
|
|
295
|
+
taskRenderMode?: TaskRenderMode;
|
|
296
|
+
private readonly _inputSchema?;
|
|
297
|
+
defaultInput?: GetterSchema<I>;
|
|
298
|
+
private readonly _outputSchema?;
|
|
299
|
+
/**
|
|
300
|
+
* Get the input data schema for this agent
|
|
301
|
+
*
|
|
302
|
+
* Used to validate that input messages conform to required format
|
|
303
|
+
* If no input schema is set, returns an empty object schema by default
|
|
304
|
+
*
|
|
305
|
+
* @returns The Zod type definition for input data
|
|
306
|
+
*/
|
|
307
|
+
get inputSchema(): ZodType<I>;
|
|
308
|
+
get inputKeys(): string[];
|
|
309
|
+
/**
|
|
310
|
+
* Get the output data schema for this agent
|
|
311
|
+
*
|
|
312
|
+
* Used to validate that output messages conform to required format
|
|
313
|
+
* If no output schema is set, returns an empty object schema by default
|
|
314
|
+
*
|
|
315
|
+
* @returns The Zod type definition for output data
|
|
316
|
+
*/
|
|
317
|
+
get outputSchema(): ZodType<O>;
|
|
318
|
+
get outputKeys(): string[];
|
|
319
|
+
/**
|
|
320
|
+
* Whether to include the original input in the output
|
|
321
|
+
*
|
|
322
|
+
* When true, the agent will merge input fields into the output object
|
|
323
|
+
*/
|
|
324
|
+
readonly includeInputInOutput?: boolean;
|
|
325
|
+
/**
|
|
326
|
+
* Topics the agent subscribes to for receiving messages
|
|
327
|
+
*
|
|
328
|
+
* Can be a single topic string or an array of topic strings
|
|
329
|
+
*/
|
|
330
|
+
readonly subscribeTopic?: SubscribeTopic;
|
|
331
|
+
/**
|
|
332
|
+
* Topics the agent publishes to for sending messages
|
|
333
|
+
*
|
|
334
|
+
* Can be a string, array of strings, or a function that determines
|
|
335
|
+
* topics based on the output
|
|
336
|
+
*/
|
|
337
|
+
readonly publishTopic?: PublishTopic<Message>;
|
|
338
|
+
/**
|
|
339
|
+
* Collection of skills (other agents) this agent can use
|
|
340
|
+
*
|
|
341
|
+
* Skills can be accessed by name or by array index, allowing
|
|
342
|
+
* the agent to delegate tasks to specialized sub-agents
|
|
343
|
+
*/
|
|
344
|
+
readonly skills: Agent<any, any>[] & {
|
|
345
|
+
[key: string]: Agent<any, any>;
|
|
346
|
+
};
|
|
347
|
+
/**
|
|
348
|
+
* Whether to disable emitting events for agent actions
|
|
349
|
+
*
|
|
350
|
+
* When true, the agent won't emit events like agentStarted,
|
|
351
|
+
* agentSucceed, or agentFailed
|
|
352
|
+
*/
|
|
353
|
+
private disableEvents?;
|
|
354
|
+
private subscriptions;
|
|
355
|
+
/**
|
|
356
|
+
* Attach agent to context:
|
|
357
|
+
* - Subscribe to topics and invoke process method when messages are received
|
|
358
|
+
* - Subscribe to memory topics if memory is enabled
|
|
359
|
+
*
|
|
360
|
+
* Agents can receive messages and respond through the topic subscription system,
|
|
361
|
+
* enabling inter-agent communication.
|
|
362
|
+
*
|
|
363
|
+
* @param context Context to attach to
|
|
364
|
+
*/
|
|
365
|
+
attach(context: Pick<Context, "subscribe">): void;
|
|
366
|
+
protected subscribeToTopics(context: Pick<Context, "subscribe">): void;
|
|
367
|
+
onMessage({
|
|
368
|
+
message,
|
|
369
|
+
context
|
|
370
|
+
}: MessagePayload): Promise<void>;
|
|
371
|
+
/**
|
|
372
|
+
* Add skills (other agents or functions) to this agent
|
|
373
|
+
*
|
|
374
|
+
* Skills allow agents to reuse functionality from other agents,
|
|
375
|
+
* building more complex behaviors.
|
|
376
|
+
*
|
|
377
|
+
* @param skills List of skills to add, can be Agent instances or functions
|
|
378
|
+
*/
|
|
379
|
+
addSkill(...skills: (Agent | FunctionAgentFn)[]): void;
|
|
380
|
+
/**
|
|
381
|
+
* Check if the agent is invokable
|
|
382
|
+
*
|
|
383
|
+
* An agent is invokable if it has implemented the process method
|
|
384
|
+
*/
|
|
385
|
+
get isInvokable(): boolean;
|
|
386
|
+
/**
|
|
387
|
+
* Check context status to ensure it hasn't timed out
|
|
388
|
+
*
|
|
389
|
+
* @param options Invocation options containing context
|
|
390
|
+
* @throws Error if the context has timed out
|
|
391
|
+
*/
|
|
392
|
+
private checkContextStatus;
|
|
393
|
+
private newDefaultContext;
|
|
394
|
+
retrieveMemories(input: Pick<MemoryRetrieverInput, "limit"> & {
|
|
395
|
+
search?: Message | string;
|
|
396
|
+
}, options: Pick<AgentInvokeOptions, "context">): Promise<Pick<Memory, "content">[]>;
|
|
397
|
+
recordMemories(input: MemoryRecorderInput, options: Pick<AgentInvokeOptions, "context">): Promise<void>;
|
|
398
|
+
/**
|
|
399
|
+
* Invoke the agent with regular (non-streaming) response
|
|
400
|
+
*
|
|
401
|
+
* Regular mode waits for the agent to complete processing and return the final result,
|
|
402
|
+
* suitable for scenarios where a complete result is needed at once.
|
|
403
|
+
*
|
|
404
|
+
* @param input Input message to the agent
|
|
405
|
+
* @param options Invocation options, must set streaming to false or leave unset
|
|
406
|
+
* @returns Final JSON response
|
|
407
|
+
*
|
|
408
|
+
* @example
|
|
409
|
+
* Here's an example of invoking an agent with regular mode:
|
|
410
|
+
* {@includeCode ../../test/agents/agent.test.ts#example-invoke}
|
|
411
|
+
*/
|
|
412
|
+
invoke(input: I & Message, options?: Partial<AgentInvokeOptions> & {
|
|
413
|
+
streaming?: false;
|
|
414
|
+
}): Promise<O>;
|
|
415
|
+
/**
|
|
416
|
+
* Invoke the agent with streaming response
|
|
417
|
+
*
|
|
418
|
+
* Streaming responses allow the agent to return results incrementally,
|
|
419
|
+
* suitable for scenarios requiring real-time progress updates, such as
|
|
420
|
+
* chat bot typing effects.
|
|
421
|
+
*
|
|
422
|
+
* @param input Input message to the agent
|
|
423
|
+
* @param options Invocation options, must set streaming to true for this overload
|
|
424
|
+
* @returns Streaming response object
|
|
425
|
+
*
|
|
426
|
+
* @example
|
|
427
|
+
* Here's an example of invoking an agent with streaming response:
|
|
428
|
+
* {@includeCode ../../test/agents/agent.test.ts#example-invoke-streaming}
|
|
429
|
+
*/
|
|
430
|
+
invoke(input: I & Message, options: Partial<AgentInvokeOptions> & {
|
|
431
|
+
streaming: true;
|
|
432
|
+
}): Promise<AgentResponseStream<O>>;
|
|
433
|
+
/**
|
|
434
|
+
* General signature for invoking the agent
|
|
435
|
+
*
|
|
436
|
+
* Returns either streaming or regular response based on the streaming parameter in options
|
|
437
|
+
*
|
|
438
|
+
* @param input Input message to the agent
|
|
439
|
+
* @param options Invocation options
|
|
440
|
+
* @returns Agent response (streaming or regular)
|
|
441
|
+
*/
|
|
442
|
+
invoke(input: I & Message, options?: Partial<AgentInvokeOptions>): Promise<AgentResponse<O>>;
|
|
443
|
+
private processStreamingAndRetry;
|
|
444
|
+
private callHooks;
|
|
445
|
+
private mergeDefaultInput;
|
|
446
|
+
protected invokeSkill<I extends Message, O extends Message>(skill: Agent<I, O>, input: I & Message, options: AgentInvokeOptions): Promise<O>;
|
|
447
|
+
protected invokeChildAgent: Context["invoke"];
|
|
448
|
+
/**
|
|
449
|
+
* Process agent output
|
|
450
|
+
*
|
|
451
|
+
* Validates output format, applies post-processing operations, and triggers success events
|
|
452
|
+
*
|
|
453
|
+
* @param input Original input message
|
|
454
|
+
* @param output Raw output produced by the agent
|
|
455
|
+
* @param options Invocation options
|
|
456
|
+
* @returns Final processed output
|
|
457
|
+
*/
|
|
458
|
+
protected processAgentOutput(input: I, output: Exclude<AgentResponse<O>, AgentResponseStream<O>>, {
|
|
459
|
+
messages,
|
|
460
|
+
...options
|
|
461
|
+
}: AgentInvokeOptions & {
|
|
462
|
+
messages?: ChatModelInputMessage[];
|
|
463
|
+
}): Promise<O>;
|
|
464
|
+
/**
|
|
465
|
+
* Process errors that occur during agent execution
|
|
466
|
+
*
|
|
467
|
+
* Logs error information, triggers failure events, and re-throws the error
|
|
468
|
+
*
|
|
469
|
+
* @param error Caught error
|
|
470
|
+
* @param options Invocation options
|
|
471
|
+
*/
|
|
472
|
+
private processAgentError;
|
|
473
|
+
/**
|
|
474
|
+
* Check agent invocation usage to prevent exceeding limits
|
|
475
|
+
*
|
|
476
|
+
* If the context has a maximum invocation limit set, checks if the limit
|
|
477
|
+
* has been exceeded and increments the invocation counter
|
|
478
|
+
*
|
|
479
|
+
* @param options Invocation options containing context and limits
|
|
480
|
+
* @throws Error if maximum invocation limit is exceeded
|
|
481
|
+
*/
|
|
482
|
+
protected checkAgentInvokesUsage(options: AgentInvokeOptions): void;
|
|
483
|
+
/**
|
|
484
|
+
* Pre-processing operations before handling input
|
|
485
|
+
*
|
|
486
|
+
* Preparatory work done before executing the agent's main processing logic, including:
|
|
487
|
+
* - Checking context status
|
|
488
|
+
* - Verifying invocation limits
|
|
489
|
+
*
|
|
490
|
+
* @param _ Input message (unused)
|
|
491
|
+
* @param options Options for agent invocation
|
|
492
|
+
*/
|
|
493
|
+
protected preprocess(_: I, options: AgentInvokeOptions): Promise<void>;
|
|
494
|
+
private checkResponseByGuideRails;
|
|
495
|
+
private runGuideRails;
|
|
496
|
+
/**
|
|
497
|
+
* Handle errors detected by GuideRail agents
|
|
498
|
+
*
|
|
499
|
+
* This method is called when a GuideRail agent aborts the process, providing
|
|
500
|
+
* a way for agents to customize error handling behavior. By default, it simply
|
|
501
|
+
* returns the original error, but subclasses can override this method to:
|
|
502
|
+
* - Transform the error into a more specific response
|
|
503
|
+
* - Apply recovery strategies
|
|
504
|
+
* - Log or report the error in a custom format
|
|
505
|
+
* - Return a fallback output instead of an error
|
|
506
|
+
*
|
|
507
|
+
* @param error The GuideRail agent output containing abort=true and a reason
|
|
508
|
+
* @returns Either the original/modified error or a substitute output object
|
|
509
|
+
* which will be tagged with $status: "GuideRailError"
|
|
510
|
+
*/
|
|
511
|
+
protected onGuideRailError(error: GuideRailAgentOutput): Promise<O | GuideRailAgentOutput>;
|
|
512
|
+
/**
|
|
513
|
+
* Post-processing operations after handling output
|
|
514
|
+
*
|
|
515
|
+
* Operations performed after the agent produces output, including:
|
|
516
|
+
* - Checking context status
|
|
517
|
+
* - Adding interaction records to memory
|
|
518
|
+
*
|
|
519
|
+
* @param input Input message
|
|
520
|
+
* @param output Output message
|
|
521
|
+
* @param options Options for agent invocation
|
|
522
|
+
*/
|
|
523
|
+
protected postprocess(input: I, output: O, options: AgentInvokeOptions): Promise<void>;
|
|
524
|
+
protected publishToTopics(output: Message, options: AgentInvokeOptions): Promise<void>;
|
|
525
|
+
formatOutput(output: O): PromiseOrValue<string>;
|
|
526
|
+
/**
|
|
527
|
+
* Core processing method of the agent, must be implemented in subclasses
|
|
528
|
+
*
|
|
529
|
+
* This is the main functionality implementation of the agent, processing input and
|
|
530
|
+
* generating output. Can return various types of results:
|
|
531
|
+
* - Regular object response
|
|
532
|
+
* - Streaming response
|
|
533
|
+
* - Async generator
|
|
534
|
+
* - Another agent instance (transfer agent)
|
|
535
|
+
*
|
|
536
|
+
* @param input Input message
|
|
537
|
+
* @param options Options for agent invocation
|
|
538
|
+
* @returns Processing result
|
|
539
|
+
*
|
|
540
|
+
* @example
|
|
541
|
+
* Example of returning a direct object:
|
|
542
|
+
* {@includeCode ../../test/agents/agent.test.ts#example-process-direct-response}
|
|
543
|
+
*
|
|
544
|
+
* @example
|
|
545
|
+
* Example of returning a streaming response:
|
|
546
|
+
* {@includeCode ../../test/agents/agent.test.ts#example-process-streaming-response}
|
|
547
|
+
*
|
|
548
|
+
* @example
|
|
549
|
+
* Example of using an async generator:
|
|
550
|
+
* {@includeCode ../../test/agents/agent.test.ts#example-process-async-generator}
|
|
551
|
+
*
|
|
552
|
+
* @example
|
|
553
|
+
* Example of transfer to another agent:
|
|
554
|
+
* {@includeCode ../../test/agents/agent.test.ts#example-process-transfer}
|
|
555
|
+
*/
|
|
556
|
+
abstract process(input: I, options: AgentInvokeOptions): PromiseOrValue<AgentProcessResult<O>>;
|
|
557
|
+
/**
|
|
558
|
+
* Shut down the agent and clean up resources
|
|
559
|
+
*
|
|
560
|
+
* Primarily used to clean up memory and other resources to prevent memory leaks
|
|
561
|
+
*
|
|
562
|
+
* @example
|
|
563
|
+
* Here's an example of shutting down an agent:
|
|
564
|
+
* {@includeCode ../../test/agents/agent.test.ts#example-agent-shutdown}
|
|
565
|
+
*
|
|
566
|
+
* @example
|
|
567
|
+
* Here's an example of shutting down an agent by using statement:
|
|
568
|
+
* {@includeCode ../../test/agents/agent.test.ts#example-agent-shutdown-by-using}
|
|
569
|
+
*/
|
|
570
|
+
shutdown(): Promise<void>;
|
|
571
|
+
/**
|
|
572
|
+
* Async dispose method for shutdown the agent
|
|
573
|
+
*
|
|
574
|
+
* @example
|
|
575
|
+
* Here's an example of shutting down an agent by using statement:
|
|
576
|
+
* {@includeCode ../../test/agents/agent.test.ts#example-agent-shutdown-by-using}
|
|
577
|
+
*/
|
|
578
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
579
|
+
/** For AFSModule interface **/
|
|
580
|
+
private agentToAFSEntry;
|
|
581
|
+
private findAgentByAFSPath;
|
|
582
|
+
list(_path: string, _options?: AFSListOptions): Promise<AFSListResult>;
|
|
583
|
+
read(path: string): Promise<AFSReadResult>;
|
|
584
|
+
search(path: string, _query: string, options?: AFSSearchOptions): Promise<AFSListResult>;
|
|
585
|
+
exec(path: string, args: Record<string, any>, options: AFSExecOptions): Promise<AFSExecResult>;
|
|
586
|
+
}
|
|
587
|
+
type AgentInput<T extends Agent> = T extends Agent<infer I, any> ? I : never;
|
|
588
|
+
type AgentOutput<T extends Agent> = T extends Agent<any, infer O> ? O : never;
|
|
589
|
+
/**
|
|
590
|
+
* Lifecycle hooks for agent execution
|
|
591
|
+
*
|
|
592
|
+
* Hooks provide a way to intercept and extend agent behavior at key points during
|
|
593
|
+
* the agent's lifecycle, enabling custom functionality like logging, monitoring,
|
|
594
|
+
* tracing, error handling, and more.
|
|
595
|
+
*/
|
|
596
|
+
interface AgentHooks<I extends Message = Message, O extends Message = Message> {
|
|
597
|
+
priority?: "low" | "medium" | "high";
|
|
598
|
+
/**
|
|
599
|
+
* Called when agent processing begins
|
|
600
|
+
*
|
|
601
|
+
* This hook runs before the agent processes input, allowing for
|
|
602
|
+
* setup operations, logging, or input transformations.
|
|
603
|
+
*
|
|
604
|
+
* @param event Object containing the input message
|
|
605
|
+
*/
|
|
606
|
+
onStart?: ((event: {
|
|
607
|
+
context: Context;
|
|
608
|
+
agent: Agent;
|
|
609
|
+
input: I;
|
|
610
|
+
}) => PromiseOrValue<void | {
|
|
611
|
+
input?: I;
|
|
612
|
+
options?: any;
|
|
613
|
+
}>) | Agent<{
|
|
614
|
+
input: I;
|
|
615
|
+
}, {
|
|
616
|
+
input?: I;
|
|
617
|
+
options?: any;
|
|
618
|
+
}>;
|
|
619
|
+
/**
|
|
620
|
+
* Called when agent processing completes or fails
|
|
621
|
+
*
|
|
622
|
+
* This hook runs after processing finishes, receiving either the output
|
|
623
|
+
* or an error if processing failed. Useful for cleanup operations,
|
|
624
|
+
* logging results, or error handling.
|
|
625
|
+
*
|
|
626
|
+
* @param event Object containing the input message and either output or error
|
|
627
|
+
*/
|
|
628
|
+
onEnd?: ((event: XOr<{
|
|
629
|
+
context: Context;
|
|
630
|
+
agent: Agent;
|
|
631
|
+
input: I;
|
|
632
|
+
output: O;
|
|
633
|
+
error: Error;
|
|
634
|
+
}, "output", "error">) => PromiseOrValue<void | {
|
|
635
|
+
output?: O;
|
|
636
|
+
retry?: boolean;
|
|
637
|
+
}>) | Agent<XOr<{
|
|
638
|
+
input: I;
|
|
639
|
+
output: O;
|
|
640
|
+
error: Error;
|
|
641
|
+
}, "output", "error">, {
|
|
642
|
+
output?: O;
|
|
643
|
+
retry?: boolean;
|
|
644
|
+
}>;
|
|
645
|
+
onSuccess?: ((event: {
|
|
646
|
+
context: Context;
|
|
647
|
+
agent: Agent;
|
|
648
|
+
input: I;
|
|
649
|
+
output: O;
|
|
650
|
+
}) => PromiseOrValue<void | {
|
|
651
|
+
output?: O;
|
|
652
|
+
}>) | Agent<{
|
|
653
|
+
input: I;
|
|
654
|
+
output: O;
|
|
655
|
+
}, {
|
|
656
|
+
output?: O;
|
|
657
|
+
}>;
|
|
658
|
+
onError?: ((event: {
|
|
659
|
+
context: Context;
|
|
660
|
+
agent: Agent;
|
|
661
|
+
input: I;
|
|
662
|
+
error: Error;
|
|
663
|
+
}) => PromiseOrValue<void | {
|
|
664
|
+
retry?: boolean;
|
|
665
|
+
}>) | Agent<{
|
|
666
|
+
input: I;
|
|
667
|
+
error: Error;
|
|
668
|
+
}, {
|
|
669
|
+
retry?: boolean;
|
|
670
|
+
}>;
|
|
671
|
+
/**
|
|
672
|
+
* Called before a skill (sub-agent) is invoked
|
|
673
|
+
*
|
|
674
|
+
* This hook runs when the agent delegates work to a skill,
|
|
675
|
+
* allowing for tracking skill usage or transforming input to the skill.
|
|
676
|
+
*
|
|
677
|
+
* @param event Object containing the skill being used and input message
|
|
678
|
+
*/
|
|
679
|
+
onSkillStart?: ((event: {
|
|
680
|
+
context: Context;
|
|
681
|
+
agent: Agent;
|
|
682
|
+
skill: Agent;
|
|
683
|
+
input: Message;
|
|
684
|
+
}) => PromiseOrValue<void>) | Agent<{
|
|
685
|
+
skill: Agent;
|
|
686
|
+
input: Message;
|
|
687
|
+
}>;
|
|
688
|
+
/**
|
|
689
|
+
* Called after a skill (sub-agent) completes or fails
|
|
690
|
+
*
|
|
691
|
+
* This hook runs when a skill finishes execution, receiving either the output
|
|
692
|
+
* or an error if the skill failed. Useful for monitoring skill performance
|
|
693
|
+
* or handling skill-specific errors.
|
|
694
|
+
*
|
|
695
|
+
* @param event Object containing the skill used, input message, and either output or error
|
|
696
|
+
*/
|
|
697
|
+
onSkillEnd?: ((event: XOr<{
|
|
698
|
+
context: Context;
|
|
699
|
+
agent: Agent;
|
|
700
|
+
skill: Agent;
|
|
701
|
+
input: Message;
|
|
702
|
+
output: Message;
|
|
703
|
+
error: Error;
|
|
704
|
+
}, "output", "error">) => PromiseOrValue<void>) | Agent<XOr<{
|
|
705
|
+
skill: Agent;
|
|
706
|
+
input: Message;
|
|
707
|
+
output: Message;
|
|
708
|
+
error: Error;
|
|
709
|
+
}, "output", "error">>;
|
|
710
|
+
/**
|
|
711
|
+
* Called when an agent hands off processing to another agent
|
|
712
|
+
*
|
|
713
|
+
* This hook runs when a source agent transfers control to a target agent,
|
|
714
|
+
* allowing for tracking of handoffs between agents and monitoring the flow
|
|
715
|
+
* of processing in multi-agent systems.
|
|
716
|
+
*
|
|
717
|
+
* @param event Object containing the source agent, target agent, and input message
|
|
718
|
+
*/
|
|
719
|
+
onHandoff?: ((event: {
|
|
720
|
+
context: Context;
|
|
721
|
+
source: Agent;
|
|
722
|
+
target: Agent;
|
|
723
|
+
input: I;
|
|
724
|
+
}) => PromiseOrValue<void>) | Agent<{
|
|
725
|
+
source: Agent;
|
|
726
|
+
target: Agent;
|
|
727
|
+
input: I;
|
|
728
|
+
}>;
|
|
729
|
+
}
|
|
730
|
+
type AgentHookInput<H extends keyof AgentHooks, Hook extends AgentHooks[H] = AgentHooks[H]> = Hook extends ((input: infer I) => any) ? Omit<I, "context" | "agent"> : never;
|
|
731
|
+
type AgentHookOutput<H extends keyof AgentHooks, Hook extends AgentHooks[H] = AgentHooks[H]> = Hook extends ((...args: any[]) => any) ? Exclude<Awaited<ReturnType<Hook>>, void> | undefined : never;
|
|
732
|
+
/**
|
|
733
|
+
* Response type for an agent, can be:
|
|
734
|
+
* - Direct response object
|
|
735
|
+
* - Output transferred to another agent
|
|
736
|
+
* - Streaming response
|
|
737
|
+
*
|
|
738
|
+
* @template T Response data type
|
|
739
|
+
*/
|
|
740
|
+
type AgentResponse<T> = T | AgentResponseStream<T> | TransferAgentOutput | GuideRailAgentOutput;
|
|
741
|
+
/**
|
|
742
|
+
* Streaming response type for an agent
|
|
743
|
+
*
|
|
744
|
+
* @template T Response data type
|
|
745
|
+
*/
|
|
746
|
+
type AgentResponseStream<T> = ReadableStream<AgentResponseChunk<T>>;
|
|
747
|
+
/**
|
|
748
|
+
* Data chunk type for streaming responses
|
|
749
|
+
*
|
|
750
|
+
* @template T Response data type
|
|
751
|
+
*/
|
|
752
|
+
type AgentResponseChunk<T> = AgentResponseDelta<T> | AgentResponseProgress;
|
|
753
|
+
/**
|
|
754
|
+
* Check if a response chunk is empty
|
|
755
|
+
*
|
|
756
|
+
* @template T Response data type
|
|
757
|
+
* @param chunk The response chunk to check
|
|
758
|
+
* @returns True if the chunk is empty
|
|
759
|
+
*/
|
|
760
|
+
declare function isEmptyChunk<T>(chunk: AgentResponseChunk<T>): boolean;
|
|
761
|
+
/**
|
|
762
|
+
* Incremental data structure for agent responses
|
|
763
|
+
*
|
|
764
|
+
* Used to represent a single incremental update in a streaming response
|
|
765
|
+
*
|
|
766
|
+
* @template T Response data type
|
|
767
|
+
* @property delta.text - Text format incremental update
|
|
768
|
+
* @property delta.json - JSON format incremental update
|
|
769
|
+
*/
|
|
770
|
+
interface AgentResponseDelta<T> {
|
|
771
|
+
delta: {
|
|
772
|
+
text?: Partial<{ [key in keyof T as Extract<T[key], string> extends string ? key : never]: string }> | Partial<{
|
|
773
|
+
[key: string]: string;
|
|
774
|
+
}>;
|
|
775
|
+
json?: Partial<T> | TransferAgentOutput;
|
|
776
|
+
};
|
|
777
|
+
}
|
|
778
|
+
declare function isAgentResponseDelta<T>(chunk: AgentResponseChunk<T>): chunk is AgentResponseDelta<T>;
|
|
779
|
+
interface AgentResponseProgress {
|
|
780
|
+
progress: ({
|
|
781
|
+
event: "agentStarted";
|
|
782
|
+
input: Message;
|
|
783
|
+
taskTitle?: string;
|
|
784
|
+
} | {
|
|
785
|
+
event: "agentSucceed";
|
|
786
|
+
output: Message;
|
|
787
|
+
} | {
|
|
788
|
+
event: "agentFailed";
|
|
789
|
+
error: Error;
|
|
790
|
+
} | {
|
|
791
|
+
event: "message";
|
|
792
|
+
message: ChatModelInputMessage;
|
|
793
|
+
}) & Omit<AgentEvent, "agent"> & {
|
|
794
|
+
agent: {
|
|
795
|
+
name: string;
|
|
796
|
+
};
|
|
797
|
+
};
|
|
798
|
+
}
|
|
799
|
+
type AgentResponseProgressMessageItem = {
|
|
800
|
+
type: "text";
|
|
801
|
+
content: string;
|
|
802
|
+
} | {
|
|
803
|
+
type: "thinking";
|
|
804
|
+
thoughts: string;
|
|
805
|
+
} | {
|
|
806
|
+
type: "tool_use";
|
|
807
|
+
toolUseId: string;
|
|
808
|
+
name: string;
|
|
809
|
+
input: unknown;
|
|
810
|
+
} | {
|
|
811
|
+
type: "tool_result";
|
|
812
|
+
toolUseId: string;
|
|
813
|
+
content: unknown;
|
|
814
|
+
};
|
|
815
|
+
declare function isAgentResponseProgress<T>(chunk: AgentResponseChunk<T>): chunk is AgentResponseProgress;
|
|
816
|
+
/**
|
|
817
|
+
* Creates a text delta for streaming responses
|
|
818
|
+
*
|
|
819
|
+
* This utility function creates an AgentResponseDelta object with only the text part,
|
|
820
|
+
* useful for incrementally building streaming text responses in agents.
|
|
821
|
+
*
|
|
822
|
+
* @template T Agent message type extending Message
|
|
823
|
+
* @param textDelta The text content to include in the delta update
|
|
824
|
+
* @returns An AgentResponseDelta with the text delta wrapped in the expected structure
|
|
825
|
+
*/
|
|
826
|
+
declare function textDelta<T extends Message>(textDelta: NonNullable<AgentResponseDelta<T>["delta"]["text"]>): AgentResponseDelta<T>;
|
|
827
|
+
/**
|
|
828
|
+
* Creates a JSON delta for streaming responses
|
|
829
|
+
*
|
|
830
|
+
* This utility function creates an AgentResponseDelta object with only the JSON part,
|
|
831
|
+
* useful for incrementally building structured data responses in streaming mode.
|
|
832
|
+
*
|
|
833
|
+
* @template T Agent message type extending Message
|
|
834
|
+
* @param jsonDelta The JSON data to include in the delta update
|
|
835
|
+
* @returns An AgentResponseDelta with the JSON delta wrapped in the expected structure
|
|
836
|
+
*/
|
|
837
|
+
declare function jsonDelta<T extends Message>(jsonDelta: NonNullable<AgentResponseDelta<T>["delta"]["json"]>): AgentResponseDelta<T>;
|
|
838
|
+
/**
|
|
839
|
+
* Async generator type for agent processing
|
|
840
|
+
*
|
|
841
|
+
* Used to generate streaming response data
|
|
842
|
+
*
|
|
843
|
+
* @template O Agent output message type
|
|
844
|
+
*/
|
|
845
|
+
type AgentProcessAsyncGenerator<O extends Message> = AsyncGenerator<AgentResponseChunk<O>, Partial<O> | TransferAgentOutput | undefined | void>;
|
|
846
|
+
/**
|
|
847
|
+
* Result type for agent processing method, can be:
|
|
848
|
+
* - Direct or streaming response
|
|
849
|
+
* - Async generator
|
|
850
|
+
* - Another agent instance (for task forwarding)
|
|
851
|
+
*
|
|
852
|
+
* @template O Agent output message type
|
|
853
|
+
*/
|
|
854
|
+
type AgentProcessResult<O extends Message> = AgentResponse<O> | AgentProcessAsyncGenerator<O> | Agent;
|
|
855
|
+
declare function agentProcessResultToObject<O extends Message>(response: AgentProcessResult<O>): Promise<O>;
|
|
856
|
+
/**
|
|
857
|
+
* Schema definition type for agent input/output
|
|
858
|
+
*
|
|
859
|
+
* Can be a Zod type definition or a function that returns a Zod type
|
|
860
|
+
*
|
|
861
|
+
* @template I Agent input/output message type
|
|
862
|
+
*/
|
|
863
|
+
type AgentInputOutputSchema<I extends Message = Message> = ZodType<I> | ((agent: Agent) => ZodType<I>);
|
|
864
|
+
/**
|
|
865
|
+
* Configuration options for a function agent
|
|
866
|
+
*
|
|
867
|
+
* Extends the base agent options and adds function implementation
|
|
868
|
+
*
|
|
869
|
+
* @template I Agent input message type
|
|
870
|
+
* @template O Agent output message type
|
|
871
|
+
*/
|
|
872
|
+
interface FunctionAgentOptions<I extends Message = Message, O extends Message = Message> extends AgentOptions<I, O> {
|
|
873
|
+
/**
|
|
874
|
+
* Function implementing the agent's processing logic
|
|
875
|
+
*
|
|
876
|
+
* This function is called by the process method to handle input
|
|
877
|
+
* and generate output
|
|
878
|
+
*/
|
|
879
|
+
process: FunctionAgentFn<I, O>;
|
|
880
|
+
}
|
|
881
|
+
/**
|
|
882
|
+
* Function agent class, implements agent logic through a function
|
|
883
|
+
*
|
|
884
|
+
* Provides a convenient way to create agents using functions without
|
|
885
|
+
* needing to extend the Agent class
|
|
886
|
+
*
|
|
887
|
+
* @template I Agent input message type
|
|
888
|
+
* @template O Agent output message type
|
|
889
|
+
*
|
|
890
|
+
* @example
|
|
891
|
+
* Here's an example of creating a function agent:
|
|
892
|
+
* {@includeCode ../../test/agents/agent.test.ts#example-function-agent}
|
|
893
|
+
*/
|
|
894
|
+
declare class FunctionAgent<I extends Message = Message, O extends Message = Message> extends Agent<I, O> {
|
|
895
|
+
tag: string;
|
|
896
|
+
static schema(): ZodObject<{
|
|
897
|
+
process: ZodType<FunctionAgentFn>;
|
|
898
|
+
}, "strip", z$1.ZodTypeAny, {
|
|
899
|
+
process: FunctionAgentFn<any, any, FunctionAgent<any, any>>;
|
|
900
|
+
}, {
|
|
901
|
+
process: FunctionAgentFn<any, any, FunctionAgent<any, any>>;
|
|
902
|
+
}>;
|
|
903
|
+
static load<I extends Message = any, O extends Message = any>(options: {
|
|
904
|
+
filepath: string;
|
|
905
|
+
parsed: object;
|
|
906
|
+
}): Promise<Agent<I, O>>;
|
|
907
|
+
/**
|
|
908
|
+
* Create a function agent from a function or options
|
|
909
|
+
*
|
|
910
|
+
* Provides a convenient factory method to create an agent directly from a function
|
|
911
|
+
*
|
|
912
|
+
* @param options Function agent options or function
|
|
913
|
+
* @returns New function agent instance
|
|
914
|
+
*
|
|
915
|
+
* @example
|
|
916
|
+
* Here's an example of creating a function agent from a function:
|
|
917
|
+
* {@includeCode ../../test/agents/agent.test.ts#example-function-agent-from-function}
|
|
918
|
+
*
|
|
919
|
+
* @example
|
|
920
|
+
* Here's an example of creating a function agent without basic agent options:
|
|
921
|
+
* {@includeCode ../../test/agents/agent.test.ts#example-function-agent}
|
|
922
|
+
*
|
|
923
|
+
* @example
|
|
924
|
+
* Here's an example of creating a function agent from a function returning a stream:
|
|
925
|
+
* {@includeCode ../../test/agents/agent.test.ts#example-function-agent-stream}
|
|
926
|
+
*
|
|
927
|
+
* @example
|
|
928
|
+
* Here's an example of creating a function agent from a function returning an async generator:
|
|
929
|
+
* {@includeCode ../../test/agents/agent.test.ts#example-function-agent-async-generator}
|
|
930
|
+
*/
|
|
931
|
+
static from<I extends Message, O extends Message>(options: FunctionAgentOptions<I, O> | FunctionAgentFn<I, O>): FunctionAgent<I, O>;
|
|
932
|
+
/**
|
|
933
|
+
* Create a function agent instance
|
|
934
|
+
*
|
|
935
|
+
* @param options Function agent configuration options
|
|
936
|
+
*/
|
|
937
|
+
constructor(options: FunctionAgentOptions<I, O>);
|
|
938
|
+
/**
|
|
939
|
+
* Stores the function used to process agent input and generate output
|
|
940
|
+
*
|
|
941
|
+
* @private
|
|
942
|
+
*/
|
|
943
|
+
_process: FunctionAgentFn<I, O>;
|
|
944
|
+
/**
|
|
945
|
+
* Process input implementation, calls the configured processing function
|
|
946
|
+
*
|
|
947
|
+
* @param input Input message
|
|
948
|
+
* @param options Invocation options
|
|
949
|
+
* @returns Processing result
|
|
950
|
+
*/
|
|
951
|
+
process(input: I, options: AgentInvokeOptions): PromiseOrValue<AgentProcessResult<O>>;
|
|
952
|
+
}
|
|
953
|
+
/**
|
|
954
|
+
* Function type for function agents
|
|
955
|
+
*
|
|
956
|
+
* Defines the function signature for processing messages in a function agent
|
|
957
|
+
*
|
|
958
|
+
* @template I Agent input message type
|
|
959
|
+
* @template O Agent output message type
|
|
960
|
+
* @param input Input message
|
|
961
|
+
* @param context Execution context
|
|
962
|
+
* @returns Processing result, can be synchronous or asynchronous
|
|
963
|
+
*/
|
|
964
|
+
type FunctionAgentFn<I extends Message = any, O extends Message = any, A extends FunctionAgent<I, O> = FunctionAgent<I, O>> = (this: A, input: I, options: AgentInvokeOptions) => PromiseOrValue<AgentProcessResult<O>>;
|
|
965
|
+
//#endregion
|
|
966
|
+
export { Agent, AgentHookInput, AgentHookOutput, AgentHooks, AgentInput, AgentInputOutputSchema, AgentInvokeOptions, AgentOptions, AgentOutput, AgentProcessAsyncGenerator, AgentProcessResult, AgentResponse, AgentResponseChunk, AgentResponseDelta, AgentResponseProgress, AgentResponseProgressMessageItem, AgentResponseStream, DEFAULT_INPUT_ACTION_GET, FunctionAgent, FunctionAgentFn, FunctionAgentOptions, Message, PublishTopic, SubscribeTopic, TaskRenderMode, agentOptionsSchema, agentProcessResultToObject, isAgentResponseDelta, isAgentResponseProgress, isEmptyChunk, jsonDelta, textDelta };
|
|
967
|
+
//# sourceMappingURL=agent.d.mts.map
|