@frontmcp/sdk 1.11.2 → 1.11.3
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 +9 -0
- package/agent/adapters/anthropic.adapter.d.ts +4 -4
- package/agent/adapters/anthropic.adapter.d.ts.map +1 -1
- package/agent/adapters/base.adapter.d.ts +12 -2
- package/agent/adapters/base.adapter.d.ts.map +1 -1
- package/agent/adapters/index.d.ts +1 -1
- package/agent/adapters/index.d.ts.map +1 -1
- package/agent/adapters/openai.adapter.d.ts +7 -7
- package/agent/adapters/openai.adapter.d.ts.map +1 -1
- package/agent/agent-execution-loop.d.ts +27 -14
- package/agent/agent-execution-loop.d.ts.map +1 -1
- package/agent/agent.registry.d.ts +9 -0
- package/agent/agent.registry.d.ts.map +1 -1
- package/agent/flows/call-agent.flow.d.ts.map +1 -1
- package/app/instances/app.esm.instance.d.ts +27 -5
- package/app/instances/app.esm.instance.d.ts.map +1 -1
- package/app/instances/app.remote.instance.d.ts.map +1 -1
- package/app/instances/esm-normalize.utils.d.ts +3 -1
- package/app/instances/esm-normalize.utils.d.ts.map +1 -1
- package/app/instances/esm-package-version.d.ts +48 -0
- package/app/instances/esm-package-version.d.ts.map +1 -0
- package/auth/auth-ui/auth-ui.contract.d.ts +27 -0
- package/auth/auth-ui/auth-ui.contract.d.ts.map +1 -1
- package/auth/auth-ui/auth-ui.state.d.ts +2 -1
- package/auth/auth-ui/auth-ui.state.d.ts.map +1 -1
- package/auth/auth-ui/index.d.ts +1 -1
- package/auth/auth-ui/index.d.ts.map +1 -1
- package/auth/authorization/orchestrated.context-extension.d.ts +1 -1
- package/auth/authorization/orchestrated.context-extension.d.ts.map +1 -1
- package/auth/authorized-apps.utils.d.ts +22 -0
- package/auth/authorized-apps.utils.d.ts.map +1 -1
- package/auth/federated-steps.d.ts +66 -0
- package/auth/federated-steps.d.ts.map +1 -0
- package/auth/flows/oauth.authorize.flow.d.ts +2 -2
- package/auth/flows/oauth.authorize.flow.d.ts.map +1 -1
- package/auth/flows/oauth.callback.flow.d.ts +17 -6
- package/auth/flows/oauth.callback.flow.d.ts.map +1 -1
- package/auth/flows/oauth.provider-callback.flow.d.ts.map +1 -1
- package/auth/flows/oauth.register.flow.d.ts +1 -1
- package/auth/flows/oauth.register.flow.d.ts.map +1 -1
- package/auth/flows/oauth.token.flow.d.ts +9 -0
- package/auth/flows/oauth.token.flow.d.ts.map +1 -1
- package/auth/flows/oauth.userinfo.flow.d.ts +1 -1
- package/auth/flows/well-known.oauth-authorization-server.flow.d.ts +3 -0
- package/auth/flows/well-known.oauth-authorization-server.flow.d.ts.map +1 -1
- package/auth/flows/well-known.prm.flow.d.ts.map +1 -1
- package/auth/instances/instance.local-primary-auth.d.ts +38 -7
- package/auth/instances/instance.local-primary-auth.d.ts.map +1 -1
- package/auth/required-providers.utils.d.ts +19 -0
- package/auth/required-providers.utils.d.ts.map +1 -0
- package/browser/agent/adapters/anthropic.adapter.mjs +14 -10
- package/browser/agent/adapters/base.adapter.mjs +10 -3
- package/browser/agent/adapters/openai.adapter.mjs +39 -25
- package/browser/agent/agent-execution-loop.mjs +102 -70
- package/browser/agent/agent.registry.mjs +56 -20
- package/browser/agent/flows/call-agent.flow.mjs +2 -1
- package/browser/agent/index.mjs +1 -1
- package/browser/app/instances/app.esm.instance.mjs +120 -154
- package/browser/app/instances/app.remote.instance.mjs +3 -4
- package/browser/app/instances/esm-normalize.utils.mjs +10 -5
- package/browser/app/instances/esm-package-version.mjs +118 -0
- package/browser/auth/auth-ui/auth-ui.state.mjs +1 -1
- package/browser/auth/authorization/orchestrated.context-extension.mjs +2 -2
- package/browser/auth/authorized-apps.utils.mjs +24 -2
- package/browser/auth/federated-steps.mjs +199 -0
- package/browser/auth/flows/oauth.authorize.flow.mjs +61 -76
- package/browser/auth/flows/oauth.callback.flow.mjs +112 -42
- package/browser/auth/flows/oauth.provider-callback.flow.mjs +14 -2
- package/browser/auth/flows/oauth.register.flow.mjs +3 -3
- package/browser/auth/flows/oauth.token.flow.mjs +33 -3
- package/browser/auth/flows/session.verify.flow.mjs +1 -1
- package/browser/auth/flows/well-known.oauth-authorization-server.flow.mjs +11 -6
- package/browser/auth/flows/well-known.prm.flow.mjs +2 -1
- package/browser/auth/instances/instance.local-primary-auth.mjs +131 -37
- package/browser/auth/required-providers.utils.mjs +16 -0
- package/browser/channel/channel-scope.helper.mjs +2 -2
- package/browser/channel/flows/send-channel-notification.flow.mjs +1 -1
- package/browser/common/entries/tool.entry.mjs +21 -4
- package/browser/common/index.mjs +2 -2
- package/browser/common/interfaces/agent.interface.mjs +25 -4
- package/browser/common/interfaces/tool.interface.mjs +31 -5
- package/browser/common/metadata/app.metadata.mjs +8 -2
- package/browser/common/metadata/index.mjs +1 -1
- package/browser/common/metadata/output-policy.mjs +4 -0
- package/browser/common/metadata/workflow.metadata.mjs +3 -1
- package/browser/common/tokens/workflow.tokens.mjs +1 -0
- package/browser/common/types/options/transport/schema.mjs +3 -0
- package/browser/common/utils/auth-info.utils.mjs +1 -2
- package/browser/common/utils/index.mjs +1 -1
- package/browser/common/utils/principal.utils.mjs +25 -1
- package/browser/context/frontmcp-context-storage.mjs +14 -3
- package/browser/context/frontmcp-context.mjs +24 -2
- package/browser/elicitation/helpers/checked-elicit-answer.mjs +18 -0
- package/browser/elicitation/helpers/elicit.helper.mjs +5 -21
- package/browser/elicitation/store/elicitation-encryption.mjs +6 -6
- package/browser/elicitation/store/encrypted-elicitation.store.mjs +2 -2
- package/browser/elicitation/store/storage-elicitation.store.mjs +1 -2
- package/browser/errors/auth-internal.errors.mjs +2 -0
- package/browser/errors/index.mjs +6 -1
- package/browser/errors/mcp.error.mjs +22 -3
- package/browser/errors/misconfiguration.mjs +2 -0
- package/browser/errors/remote.errors.mjs +1 -1
- package/browser/errors/tool-ui.errors.mjs +22 -0
- package/browser/errors/workflow.errors.mjs +7 -1
- package/browser/esm-loader/esm-cache.mjs +2 -2
- package/browser/esm-loader/esm-entries.mjs +15 -1
- package/browser/esm-loader/esm-manifest.mjs +32 -25
- package/browser/esm-loader/esm-module-loader.mjs +22 -4
- package/browser/esm-loader/factories/esm-context-factories.mjs +3 -3
- package/browser/esm-loader/factories/esm-instance-factories.mjs +7 -3
- package/browser/esm-loader/factories/esm-record-builders.mjs +27 -2
- package/browser/esm-loader/semver.utils.mjs +3 -5
- package/browser/esm-loader/version-poller.mjs +1 -1
- package/browser/esm-loader/version-resolver.mjs +5 -1
- package/browser/ext-apps/ext-apps.handler.mjs +6 -1
- package/browser/flows/flow.http-path.mjs +5 -1
- package/browser/flows/flow.instance.mjs +42 -9
- package/browser/front-mcp/front-mcp.mjs +19 -2
- package/browser/front-mcp/session-secret.check.mjs +22 -0
- package/browser/http-route/http-route.table.mjs +23 -3
- package/browser/index.cjs +30225 -27807
- package/browser/index.mjs +8 -4
- package/browser/job/execution/job-execution.manager.mjs +20 -17
- package/browser/job/flows/execute-job.flow.mjs +5 -3
- package/browser/job/index.mjs +2 -2
- package/browser/job/job-attempt.mjs +15 -10
- package/browser/job/job-context-providers.mjs +2 -1
- package/browser/job/job-scope.helper.mjs +76 -4
- package/browser/job/job.registry.mjs +30 -0
- package/browser/job/tools/index.mjs +3 -1
- package/browser/job/tools/list-jobs.tool.mjs +7 -5
- package/browser/job/tools/update-job.tool.mjs +75 -0
- package/browser/logger/instances/instance.logger.mjs +31 -6
- package/browser/notification/notification.service.mjs +26 -5
- package/browser/prompt/flows/get-prompt.flow.mjs +3 -3
- package/browser/prompt/flows/prompts-list.flow.mjs +11 -4
- package/browser/provider/provider.registry.mjs +1 -1
- package/browser/remote-mcp/factories/instance-factories.mjs +4 -4
- package/browser/remote-mcp/factories/record-builders.mjs +5 -0
- package/browser/remote-mcp/mcp-client.service.mjs +113 -68
- package/browser/remote-mcp/mcp-stateless-client.adapter.mjs +2 -2
- package/browser/remote-mcp/remote-entries.mjs +2 -1
- package/browser/remote-mcp/remote-oauth.mjs +102 -0
- package/browser/remote-mcp/remote-request-headers.mjs +42 -12
- package/browser/remote-mcp/resilience/circuit-breaker.mjs +3 -2
- package/browser/resource/flows/read-resource.flow.mjs +6 -4
- package/browser/resource/flows/resource-templates-list.flow.mjs +24 -9
- package/browser/resource/flows/resources-list.flow.mjs +11 -4
- package/browser/scope/flows/http.request.flow.mjs +1 -1
- package/browser/scope/observability-scope.helper.mjs +6 -1
- package/browser/scope/scope.instance.mjs +284 -81
- package/browser/skill/errors/tool-not-allowed.error.mjs +2 -2
- package/browser/skill/flows/filter-skills.flow.mjs +1 -1
- package/browser/skill/flows/load-skill.flow.mjs +27 -15
- package/browser/skill/guards/tool-authorization.guard.mjs +1 -1
- package/browser/skill/hooks/skill-tool.hook.mjs +32 -24
- package/browser/skill/providers/external-skill.provider.mjs +4 -2
- package/browser/skill/session/skill-session-store.interface.mjs +10 -0
- package/browser/skill/session/skill-session.manager.mjs +8 -0
- package/browser/skill/skill-authorities.helper.mjs +9 -3
- package/browser/skill/skill-scope.helper.mjs +7 -2
- package/browser/skill/skill.registry.mjs +21 -2
- package/browser/subsystems.mjs +6 -2
- package/browser/surface/entry-authorized.mjs +15 -0
- package/browser/tool/flows/call-tool.flow.mjs +59 -13
- package/browser/tool/flows/tools-list.flow.mjs +11 -4
- package/browser/tool/tool.utils.mjs +46 -61
- package/browser/tool/ui/serving-mode-default.mjs +11 -2
- package/browser/tool/ui/template-detection.mjs +1 -1
- package/browser/tool/ui/ui-option-warnings.mjs +1 -28
- package/browser/tool/ui/ui-render.mjs +6 -0
- package/browser/tool/ui/ui-resource.handler.mjs +50 -6
- package/browser/tool/ui/ui-shared.mjs +61 -7
- package/browser/tool/ui/widget-routes.mjs +73 -0
- package/browser/tool/ui/widget-serving.mjs +112 -0
- package/browser/transport/flows/handle.mcp-20260728.flow.mjs +1 -1
- package/browser/transport/flows/handle.stateless-http.flow.mjs +1 -2
- package/browser/transport/mcp-20260728/client/index.mjs +1 -1
- package/browser/transport/mcp-20260728/client/mcp-stateless.client.mjs +2 -1
- package/browser/transport/mcp-20260728/index.mjs +1 -1
- package/browser/transport/web-fetch-handler.mjs +5 -1
- package/browser/utils/abort.utils.mjs +7 -2
- package/browser/utils/content.utils.mjs +1 -1
- package/browser/workflow/engine/workflow-step.executor.mjs +1 -1
- package/browser/workflow/engine/workflow.engine.mjs +13 -10
- package/browser/workflow/index.mjs +2 -2
- package/browser/workflow/tools/execute-workflow.tool.mjs +1 -1
- package/browser/workflow/tools/index.mjs +3 -1
- package/browser/workflow/tools/list-workflows.tool.mjs +4 -2
- package/browser/workflow/tools/register-workflow.tool.mjs +11 -2
- package/browser/workflow/tools/update-workflow.tool.mjs +80 -0
- package/browser/workflow/trigger/workflow-events.mjs +39 -0
- package/browser/workflow/trigger/workflow-triggers.mjs +80 -0
- package/browser/workflow/trigger/workflow-webhook.routes.mjs +104 -0
- package/browser/workflow/trigger/workflow-webhook.signature.mjs +59 -0
- package/browser/workflow/workflow.registry.mjs +27 -0
- package/browser/workflow/workflow.utils.mjs +13 -2
- package/builtin/authorities/authorities.plugin.d.ts +1 -1
- package/builtin/authorities/authorities.plugin.d.ts.map +1 -1
- package/builtin/authorities/authorities.plugin.options.d.ts +1 -1
- package/builtin/authorities/authorities.plugin.options.d.ts.map +1 -1
- package/builtin/config/config-resolver.d.ts.map +1 -1
- package/channel/channel-scope.helper.d.ts +2 -0
- package/channel/channel-scope.helper.d.ts.map +1 -1
- package/channel/channel.types.d.ts +1 -1
- package/channel/channel.types.d.ts.map +1 -1
- package/channel/sources/agent-completion.source.d.ts +1 -1
- package/channel/sources/agent-completion.source.d.ts.map +1 -1
- package/common/decorators/app.decorator.d.ts +1 -1
- package/common/decorators/app.decorator.d.ts.map +1 -1
- package/common/entries/provider.entry.d.ts +2 -2
- package/common/entries/provider.entry.d.ts.map +1 -1
- package/common/entries/scope.entry.d.ts +25 -3
- package/common/entries/scope.entry.d.ts.map +1 -1
- package/common/entries/tool.entry.d.ts +5 -3
- package/common/entries/tool.entry.d.ts.map +1 -1
- package/common/interfaces/agent.interface.d.ts +4 -2
- package/common/interfaces/agent.interface.d.ts.map +1 -1
- package/common/interfaces/llm-adapter.interface.d.ts +5 -0
- package/common/interfaces/llm-adapter.interface.d.ts.map +1 -1
- package/common/interfaces/logger.interface.d.ts +2 -1
- package/common/interfaces/logger.interface.d.ts.map +1 -1
- package/common/interfaces/tool.interface.d.ts +12 -2
- package/common/interfaces/tool.interface.d.ts.map +1 -1
- package/common/metadata/agent.metadata.d.ts +7 -2
- package/common/metadata/agent.metadata.d.ts.map +1 -1
- package/common/metadata/app.metadata.d.ts +35 -11
- package/common/metadata/app.metadata.d.ts.map +1 -1
- package/common/metadata/flow.metadata.d.ts +14 -0
- package/common/metadata/flow.metadata.d.ts.map +1 -1
- package/common/metadata/front-mcp.metadata.d.ts +2 -1
- package/common/metadata/front-mcp.metadata.d.ts.map +1 -1
- package/common/metadata/job.metadata.d.ts +11 -0
- package/common/metadata/job.metadata.d.ts.map +1 -1
- package/common/metadata/output-policy.d.ts +2 -0
- package/common/metadata/output-policy.d.ts.map +1 -1
- package/common/metadata/remote-primitive.metadata.d.ts +6 -3
- package/common/metadata/remote-primitive.metadata.d.ts.map +1 -1
- package/common/metadata/resource.metadata.d.ts +1 -1
- package/common/metadata/workflow.metadata.d.ts +50 -14
- package/common/metadata/workflow.metadata.d.ts.map +1 -1
- package/common/tokens/workflow.tokens.d.ts +1 -0
- package/common/tokens/workflow.tokens.d.ts.map +1 -1
- package/common/types/options/logging/interfaces.d.ts +3 -1
- package/common/types/options/logging/interfaces.d.ts.map +1 -1
- package/common/types/options/observability/interfaces.d.ts +4 -2
- package/common/types/options/observability/interfaces.d.ts.map +1 -1
- package/common/types/options/transport/interfaces.d.ts +3 -0
- package/common/types/options/transport/interfaces.d.ts.map +1 -1
- package/common/types/options/transport/schema.d.ts.map +1 -1
- package/common/utils/auth-info.utils.d.ts +1 -0
- package/common/utils/auth-info.utils.d.ts.map +1 -1
- package/common/utils/global-config.utils.d.ts.map +1 -1
- package/common/utils/principal.utils.d.ts +24 -0
- package/common/utils/principal.utils.d.ts.map +1 -1
- package/context/frontmcp-context-storage.d.ts +3 -1
- package/context/frontmcp-context-storage.d.ts.map +1 -1
- package/context/frontmcp-context.d.ts +9 -1
- package/context/frontmcp-context.d.ts.map +1 -1
- package/elicitation/helpers/checked-elicit-answer.d.ts +10 -0
- package/elicitation/helpers/checked-elicit-answer.d.ts.map +1 -0
- package/elicitation/helpers/elicit.helper.d.ts.map +1 -1
- package/elicitation/store/elicitation-encryption.d.ts.map +1 -1
- package/elicitation/store/encrypted-elicitation.store.d.ts +2 -2
- package/elicitation/store/encrypted-elicitation.store.d.ts.map +1 -1
- package/elicitation/store/storage-elicitation.store.d.ts +3 -3
- package/elicitation/store/storage-elicitation.store.d.ts.map +1 -1
- package/errors/auth-internal.errors.d.ts +1 -1
- package/errors/auth-internal.errors.d.ts.map +1 -1
- package/errors/error-handler.d.ts.map +1 -1
- package/errors/index.d.ts +3 -2
- package/errors/index.d.ts.map +1 -1
- package/errors/mcp.error.d.ts +6 -1
- package/errors/mcp.error.d.ts.map +1 -1
- package/errors/misconfiguration.d.ts.map +1 -1
- package/errors/remote.errors.d.ts +1 -1
- package/errors/remote.errors.d.ts.map +1 -1
- package/errors/tool-ui.errors.d.ts +13 -0
- package/errors/tool-ui.errors.d.ts.map +1 -0
- package/errors/workflow.errors.d.ts +4 -0
- package/errors/workflow.errors.d.ts.map +1 -1
- package/esm/index.mjs +46 -45
- package/esm/job/tools/index.mjs +3 -2
- package/esm/workflow/tools/index.mjs +3 -2
- package/esm-loader/app-helpers.d.ts +4 -4
- package/esm-loader/app-helpers.d.ts.map +1 -1
- package/esm-loader/esm-entries.d.ts +11 -1
- package/esm-loader/esm-entries.d.ts.map +1 -1
- package/esm-loader/esm-manifest.d.ts +11 -8
- package/esm-loader/esm-manifest.d.ts.map +1 -1
- package/esm-loader/esm-module-loader.d.ts +6 -1
- package/esm-loader/esm-module-loader.d.ts.map +1 -1
- package/esm-loader/factories/esm-context-factories.d.ts +6 -3
- package/esm-loader/factories/esm-context-factories.d.ts.map +1 -1
- package/esm-loader/factories/esm-instance-factories.d.ts +3 -3
- package/esm-loader/factories/esm-instance-factories.d.ts.map +1 -1
- package/esm-loader/factories/esm-record-builders.d.ts.map +1 -1
- package/esm-loader/semver.utils.d.ts +8 -0
- package/esm-loader/semver.utils.d.ts.map +1 -1
- package/esm-loader/version-resolver.d.ts.map +1 -1
- package/ext-apps/ext-apps.handler.d.ts +2 -1
- package/ext-apps/ext-apps.handler.d.ts.map +1 -1
- package/flows/flow.http-path.d.ts +8 -0
- package/flows/flow.http-path.d.ts.map +1 -1
- package/flows/flow.instance.d.ts +9 -0
- package/flows/flow.instance.d.ts.map +1 -1
- package/front-mcp/front-mcp.d.ts +2 -0
- package/front-mcp/front-mcp.d.ts.map +1 -1
- package/front-mcp/session-secret.check.d.ts +19 -0
- package/front-mcp/session-secret.check.d.ts.map +1 -0
- package/http-route/http-route.table.d.ts.map +1 -1
- package/index.d.ts +4 -4
- package/index.d.ts.map +1 -1
- package/index.js +53 -52
- package/job/execution/job-execution.manager.d.ts +8 -3
- package/job/execution/job-execution.manager.d.ts.map +1 -1
- package/job/flows/execute-job.flow.d.ts +1 -0
- package/job/flows/execute-job.flow.d.ts.map +1 -1
- package/job/job-attempt.d.ts +7 -2
- package/job/job-attempt.d.ts.map +1 -1
- package/job/job-context-providers.d.ts +2 -2
- package/job/job-context-providers.d.ts.map +1 -1
- package/job/job-scope.helper.d.ts +26 -0
- package/job/job-scope.helper.d.ts.map +1 -1
- package/job/job.registry.d.ts +11 -0
- package/job/job.registry.d.ts.map +1 -1
- package/job/tools/index.d.ts +1 -0
- package/job/tools/index.d.ts.map +1 -1
- package/job/tools/index.js +4 -2
- package/job/tools/list-jobs.tool.d.ts +3 -3
- package/job/tools/list-jobs.tool.d.ts.map +1 -1
- package/job/tools/update-job.tool.d.ts +16 -0
- package/job/tools/update-job.tool.d.ts.map +1 -0
- package/logger/instances/instance.logger.d.ts +1 -0
- package/logger/instances/instance.logger.d.ts.map +1 -1
- package/notification/notification.service.d.ts +10 -3
- package/notification/notification.service.d.ts.map +1 -1
- package/package.json +10 -10
- package/prompt/flows/prompts-list.flow.d.ts.map +1 -1
- package/provider/provider.registry.d.ts.map +1 -1
- package/remote-mcp/factories/instance-factories.d.ts +4 -4
- package/remote-mcp/factories/instance-factories.d.ts.map +1 -1
- package/remote-mcp/factories/record-builders.d.ts.map +1 -1
- package/remote-mcp/mcp-client.service.d.ts +11 -0
- package/remote-mcp/mcp-client.service.d.ts.map +1 -1
- package/remote-mcp/mcp-client.types.d.ts +15 -2
- package/remote-mcp/mcp-client.types.d.ts.map +1 -1
- package/remote-mcp/mcp-stateless-client.adapter.d.ts +1 -1
- package/remote-mcp/mcp-stateless-client.adapter.d.ts.map +1 -1
- package/remote-mcp/remote-entries.d.ts +2 -1
- package/remote-mcp/remote-entries.d.ts.map +1 -1
- package/remote-mcp/remote-oauth.d.ts +27 -0
- package/remote-mcp/remote-oauth.d.ts.map +1 -0
- package/remote-mcp/remote-request-headers.d.ts +8 -2
- package/remote-mcp/remote-request-headers.d.ts.map +1 -1
- package/remote-mcp/resilience/circuit-breaker.d.ts +3 -2
- package/remote-mcp/resilience/circuit-breaker.d.ts.map +1 -1
- package/resource/flows/read-resource.flow.d.ts.map +1 -1
- package/resource/flows/resource-templates-list.flow.d.ts.map +1 -1
- package/resource/flows/resources-list.flow.d.ts.map +1 -1
- package/scope/observability-scope.helper.d.ts.map +1 -1
- package/scope/scope.instance.d.ts +35 -1
- package/scope/scope.instance.d.ts.map +1 -1
- package/skill/errors/tool-not-allowed.error.d.ts.map +1 -1
- package/skill/flows/load-skill.flow.d.ts.map +1 -1
- package/skill/guards/tool-authorization.guard.d.ts +1 -1
- package/skill/guards/tool-authorization.guard.d.ts.map +1 -1
- package/skill/hooks/skill-tool.hook.d.ts +2 -0
- package/skill/hooks/skill-tool.hook.d.ts.map +1 -1
- package/skill/providers/external-skill.provider.d.ts +2 -2
- package/skill/providers/external-skill.provider.d.ts.map +1 -1
- package/skill/session/skill-session-store.interface.d.ts +5 -0
- package/skill/session/skill-session-store.interface.d.ts.map +1 -1
- package/skill/session/skill-session.manager.d.ts +4 -0
- package/skill/session/skill-session.manager.d.ts.map +1 -1
- package/skill/session/skill-session.types.d.ts +1 -1
- package/skill/skill-authorities.helper.d.ts +6 -3
- package/skill/skill-authorities.helper.d.ts.map +1 -1
- package/skill/skill-scope.helper.d.ts +5 -0
- package/skill/skill-scope.helper.d.ts.map +1 -1
- package/skill/skill.registry.d.ts +7 -0
- package/skill/skill.registry.d.ts.map +1 -1
- package/subsystems.d.ts +2 -2
- package/subsystems.d.ts.map +1 -1
- package/surface/entry-authorized.d.ts +5 -0
- package/surface/entry-authorized.d.ts.map +1 -0
- package/tool/flows/call-tool.flow.d.ts +6 -0
- package/tool/flows/call-tool.flow.d.ts.map +1 -1
- package/tool/flows/tools-list.flow.d.ts +1 -1
- package/tool/flows/tools-list.flow.d.ts.map +1 -1
- package/tool/tool.utils.d.ts.map +1 -1
- package/tool/ui/serving-mode-default.d.ts +6 -2
- package/tool/ui/serving-mode-default.d.ts.map +1 -1
- package/tool/ui/ui-option-warnings.d.ts.map +1 -1
- package/tool/ui/ui-render.d.ts +2 -2
- package/tool/ui/ui-render.d.ts.map +1 -1
- package/tool/ui/ui-resource.handler.d.ts +10 -2
- package/tool/ui/ui-resource.handler.d.ts.map +1 -1
- package/tool/ui/ui-shared.d.ts +31 -5
- package/tool/ui/ui-shared.d.ts.map +1 -1
- package/tool/ui/widget-routes.d.ts +38 -0
- package/tool/ui/widget-routes.d.ts.map +1 -0
- package/tool/ui/widget-serving.d.ts +37 -0
- package/tool/ui/widget-serving.d.ts.map +1 -0
- package/transport/mcp-20260728/client/mcp-stateless.client.d.ts +2 -0
- package/transport/mcp-20260728/client/mcp-stateless.client.d.ts.map +1 -1
- package/transport/web-fetch-handler.d.ts.map +1 -1
- package/utils/abort.utils.d.ts +5 -0
- package/utils/abort.utils.d.ts.map +1 -1
- package/workflow/engine/workflow.engine.d.ts +8 -1
- package/workflow/engine/workflow.engine.d.ts.map +1 -1
- package/workflow/tools/execute-workflow.tool.d.ts.map +1 -1
- package/workflow/tools/index.d.ts +1 -0
- package/workflow/tools/index.d.ts.map +1 -1
- package/workflow/tools/index.js +4 -2
- package/workflow/tools/list-workflows.tool.d.ts.map +1 -1
- package/workflow/tools/register-workflow.tool.d.ts.map +1 -1
- package/workflow/tools/update-workflow.tool.d.ts +21 -0
- package/workflow/tools/update-workflow.tool.d.ts.map +1 -0
- package/workflow/trigger/workflow-events.d.ts +22 -0
- package/workflow/trigger/workflow-events.d.ts.map +1 -0
- package/workflow/trigger/workflow-triggers.d.ts +34 -0
- package/workflow/trigger/workflow-triggers.d.ts.map +1 -0
- package/workflow/trigger/workflow-webhook.routes.d.ts +16 -0
- package/workflow/trigger/workflow-webhook.routes.d.ts.map +1 -0
- package/workflow/trigger/workflow-webhook.signature.d.ts +41 -0
- package/workflow/trigger/workflow-webhook.signature.d.ts.map +1 -0
- package/workflow/workflow.registry.d.ts +11 -0
- package/workflow/workflow.registry.d.ts.map +1 -1
- package/workflow/workflow.utils.d.ts +7 -0
- package/workflow/workflow.utils.d.ts.map +1 -1
|
@@ -40,21 +40,22 @@ var BaseLlmAdapter = class {
|
|
|
40
40
|
return messages.map((msg) => this.formatMessage(msg));
|
|
41
41
|
}
|
|
42
42
|
/**
|
|
43
|
-
* Execute with retry logic.
|
|
43
|
+
* Execute with retry logic. Nothing is retried once `signal` aborts.
|
|
44
44
|
*/
|
|
45
|
-
async withRetry(fn, retries = this.config.maxRetries) {
|
|
45
|
+
async withRetry(fn, retries = this.config.maxRetries, signal) {
|
|
46
46
|
let lastError;
|
|
47
47
|
for (let attempt = 0; attempt <= retries; attempt++) {
|
|
48
48
|
try {
|
|
49
49
|
return await fn();
|
|
50
50
|
} catch (error) {
|
|
51
51
|
lastError = error instanceof Error ? error : new Error(String(error));
|
|
52
|
-
if (this.isNonRetryableError(lastError)) {
|
|
52
|
+
if (signal?.aborted || this.isNonRetryableError(lastError)) {
|
|
53
53
|
throw lastError;
|
|
54
54
|
}
|
|
55
55
|
if (attempt < retries) {
|
|
56
56
|
const delay = Math.min(1e3 * Math.pow(2, attempt), 1e4);
|
|
57
57
|
await this.sleep(delay);
|
|
58
|
+
if (signal?.aborted) throw lastError;
|
|
58
59
|
}
|
|
59
60
|
}
|
|
60
61
|
}
|
|
@@ -73,6 +74,12 @@ var BaseLlmAdapter = class {
|
|
|
73
74
|
sleep(ms) {
|
|
74
75
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
75
76
|
}
|
|
77
|
+
/**
|
|
78
|
+
* The request options to pass the provider SDK: the agent loop's `signal`, so a stopped run cancels its request.
|
|
79
|
+
*/
|
|
80
|
+
requestOptions(options) {
|
|
81
|
+
return options.signal ? { signal: options.signal } : void 0;
|
|
82
|
+
}
|
|
76
83
|
/**
|
|
77
84
|
* Merge options with defaults.
|
|
78
85
|
*/
|
|
@@ -70,15 +70,22 @@ var OpenAIAdapter = class extends BaseLlmAdapter {
|
|
|
70
70
|
// ============================================================================
|
|
71
71
|
async completionViaChat(prompt, tools, options) {
|
|
72
72
|
const params = this.buildChatParams(prompt, tools, options, false);
|
|
73
|
-
return this.withRetry(
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
73
|
+
return this.withRetry(
|
|
74
|
+
async () => {
|
|
75
|
+
try {
|
|
76
|
+
const client = await this.getClient();
|
|
77
|
+
const response = await client.chat.completions.create(
|
|
78
|
+
params,
|
|
79
|
+
this.requestOptions(options)
|
|
80
|
+
);
|
|
81
|
+
return this.parseChatResponse(response);
|
|
82
|
+
} catch (error) {
|
|
83
|
+
throw this.wrapError(error);
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
this.config.maxRetries,
|
|
87
|
+
options.signal
|
|
88
|
+
);
|
|
82
89
|
}
|
|
83
90
|
async *streamViaChat(prompt, tools, options) {
|
|
84
91
|
const params = this.buildChatParams(prompt, tools, options, true);
|
|
@@ -88,7 +95,7 @@ var OpenAIAdapter = class extends BaseLlmAdapter {
|
|
|
88
95
|
let usage;
|
|
89
96
|
try {
|
|
90
97
|
const client = await this.getClient();
|
|
91
|
-
const stream = await client.chat.completions.create(params);
|
|
98
|
+
const stream = await client.chat.completions.create(params, this.requestOptions(options));
|
|
92
99
|
for await (const chunk of stream) {
|
|
93
100
|
if (chunk.usage) {
|
|
94
101
|
usage = {
|
|
@@ -143,23 +150,30 @@ var OpenAIAdapter = class extends BaseLlmAdapter {
|
|
|
143
150
|
// ============================================================================
|
|
144
151
|
async completionViaResponses(prompt, tools, options) {
|
|
145
152
|
const params = this.buildResponsesParams(prompt, tools, options, false);
|
|
146
|
-
return this.withRetry(
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
153
|
+
return this.withRetry(
|
|
154
|
+
async () => {
|
|
155
|
+
try {
|
|
156
|
+
const client = await this.getClient();
|
|
157
|
+
if (!client.responses) {
|
|
158
|
+
throw new LlmAdapterError(
|
|
159
|
+
`The OpenAI client does not support the Responses API.
|
|
152
160
|
Upgrade the "openai" package to v4.85+ or use api: 'chat' instead.`,
|
|
153
|
-
|
|
154
|
-
|
|
161
|
+
"openai",
|
|
162
|
+
"unsupported_api"
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
const response = await client.responses.create(
|
|
166
|
+
params,
|
|
167
|
+
this.requestOptions(options)
|
|
155
168
|
);
|
|
169
|
+
return this.parseResponsesResponse(response);
|
|
170
|
+
} catch (error) {
|
|
171
|
+
throw this.wrapError(error);
|
|
156
172
|
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
}
|
|
162
|
-
});
|
|
173
|
+
},
|
|
174
|
+
this.config.maxRetries,
|
|
175
|
+
options.signal
|
|
176
|
+
);
|
|
163
177
|
}
|
|
164
178
|
async *streamViaResponses(prompt, tools, options) {
|
|
165
179
|
const params = this.buildResponsesParams(prompt, tools, options, true);
|
|
@@ -177,7 +191,7 @@ Upgrade the "openai" package to v4.85+ or use api: 'chat' instead.`,
|
|
|
177
191
|
"unsupported_api"
|
|
178
192
|
);
|
|
179
193
|
}
|
|
180
|
-
const stream = await client.responses.create(params);
|
|
194
|
+
const stream = await client.responses.create(params, this.requestOptions(options));
|
|
181
195
|
for await (const event of stream) {
|
|
182
196
|
switch (event.type) {
|
|
183
197
|
case "response.output_text.delta":
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
import {
|
|
3
3
|
supportsStreaming
|
|
4
4
|
} from "../common/index.mjs";
|
|
5
|
+
import { AgentLlmError, AgentLoopExceededError, AgentTimeoutError, McpError } from "../errors/index.mjs";
|
|
6
|
+
import { detachableAbortController } from "../utils/abort.utils.mjs";
|
|
5
7
|
var AgentExecutionLoop = class {
|
|
6
8
|
config;
|
|
7
9
|
constructor(config) {
|
|
@@ -25,16 +27,10 @@ var AgentExecutionLoop = class {
|
|
|
25
27
|
let iterations = 0;
|
|
26
28
|
let totalPromptTokens = 0;
|
|
27
29
|
let totalCompletionTokens = 0;
|
|
28
|
-
|
|
30
|
+
const stop = this.startStopSignal();
|
|
29
31
|
try {
|
|
30
|
-
const timeoutPromise = new Promise((_, reject) => {
|
|
31
|
-
timeout = setTimeout(
|
|
32
|
-
() => reject(new Error(`Agent execution timed out after ${this.config.timeout}ms`)),
|
|
33
|
-
this.config.timeout
|
|
34
|
-
);
|
|
35
|
-
});
|
|
36
32
|
const result = await Promise.race([
|
|
37
|
-
this.executeLoop(messages, toolExecutor, {
|
|
33
|
+
this.executeLoop(messages, toolExecutor, stop.signal, {
|
|
38
34
|
onIteration: (iter, msg) => {
|
|
39
35
|
iterations = iter;
|
|
40
36
|
this.config.onIteration?.(iter, msg);
|
|
@@ -44,7 +40,7 @@ var AgentExecutionLoop = class {
|
|
|
44
40
|
totalCompletionTokens += completion;
|
|
45
41
|
}
|
|
46
42
|
}),
|
|
47
|
-
|
|
43
|
+
stop.stopped
|
|
48
44
|
]);
|
|
49
45
|
return {
|
|
50
46
|
content: result.content,
|
|
@@ -58,7 +54,9 @@ var AgentExecutionLoop = class {
|
|
|
58
54
|
success: true,
|
|
59
55
|
durationMs: Date.now() - startTime
|
|
60
56
|
};
|
|
61
|
-
} catch (
|
|
57
|
+
} catch (caught) {
|
|
58
|
+
const error = caught;
|
|
59
|
+
this.config.onComplete?.(null, error);
|
|
62
60
|
return {
|
|
63
61
|
content: null,
|
|
64
62
|
messages,
|
|
@@ -73,7 +71,7 @@ var AgentExecutionLoop = class {
|
|
|
73
71
|
durationMs: Date.now() - startTime
|
|
74
72
|
};
|
|
75
73
|
} finally {
|
|
76
|
-
|
|
74
|
+
stop.end();
|
|
77
75
|
}
|
|
78
76
|
}
|
|
79
77
|
/**
|
|
@@ -87,7 +85,7 @@ var AgentExecutionLoop = class {
|
|
|
87
85
|
* The model is streamed through the adapter's `streamCompletion()` when it has one, and called
|
|
88
86
|
* through `completion()` otherwise. Tool calls are taken from the completion the stream ends with
|
|
89
87
|
* (its `done` chunk), which holds their complete arguments; the `tool_call` chunks before it only
|
|
90
|
-
* announce them. The whole run is bounded by `timeout`, as {@link run} is.
|
|
88
|
+
* announce them. The whole run is bounded by `timeout` and `signal`, as {@link run} is.
|
|
91
89
|
*
|
|
92
90
|
* @param userMessage - The user's input message
|
|
93
91
|
* @param toolExecutor - Function to execute tools
|
|
@@ -96,7 +94,6 @@ var AgentExecutionLoop = class {
|
|
|
96
94
|
*/
|
|
97
95
|
async *runStreaming(userMessage, toolExecutor, existingMessages = []) {
|
|
98
96
|
const startTime = Date.now();
|
|
99
|
-
const deadline = startTime + this.config.timeout;
|
|
100
97
|
const messages = [...existingMessages, { role: "user", content: userMessage }];
|
|
101
98
|
let iterations = 0;
|
|
102
99
|
let totalPromptTokens = 0;
|
|
@@ -114,10 +111,11 @@ var AgentExecutionLoop = class {
|
|
|
114
111
|
...error && { error },
|
|
115
112
|
durationMs: Date.now() - startTime
|
|
116
113
|
});
|
|
117
|
-
const
|
|
114
|
+
const stop = this.startStopSignal();
|
|
115
|
+
const events = this.executeLoopStreaming(messages, toolExecutor, stop.signal);
|
|
118
116
|
try {
|
|
119
117
|
for (; ; ) {
|
|
120
|
-
const step = await
|
|
118
|
+
const step = await Promise.race([events.next(), stop.stopped]);
|
|
121
119
|
if (step.done) {
|
|
122
120
|
const done = result(step.value.content);
|
|
123
121
|
yield { type: "done", result: done };
|
|
@@ -134,46 +132,82 @@ var AgentExecutionLoop = class {
|
|
|
134
132
|
} catch (caught) {
|
|
135
133
|
void events.return({ content: null }).catch(() => void 0);
|
|
136
134
|
const error = caught;
|
|
135
|
+
this.config.onComplete?.(null, error);
|
|
137
136
|
const failed = result(null, error);
|
|
138
137
|
yield { type: "error", error };
|
|
139
138
|
yield { type: "done", result: failed };
|
|
140
139
|
return failed;
|
|
140
|
+
} finally {
|
|
141
|
+
stop.end();
|
|
141
142
|
}
|
|
142
143
|
}
|
|
143
144
|
/**
|
|
144
|
-
*
|
|
145
|
-
*
|
|
145
|
+
* The signal that stops a run: it aborts with `AgentTimeoutError` when the timeout passes, or with the
|
|
146
|
+
* reason of the config's `signal`. `stopped` rejects with that reason; `end()` clears the timer and stops
|
|
147
|
+
* following the config's `signal`.
|
|
146
148
|
*/
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
const
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
149
|
+
startStopSignal() {
|
|
150
|
+
const { controller, unlink } = detachableAbortController(this.config.signal);
|
|
151
|
+
const timer = setTimeout(
|
|
152
|
+
() => controller.abort(new AgentTimeoutError(this.agentId, this.config.timeout)),
|
|
153
|
+
this.config.timeout
|
|
154
|
+
);
|
|
155
|
+
const stopped = new Promise((_, reject) => {
|
|
156
|
+
if (controller.signal.aborted) reject(controller.signal.reason);
|
|
157
|
+
controller.signal.addEventListener("abort", () => reject(controller.signal.reason), { once: true });
|
|
154
158
|
});
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
} finally {
|
|
159
|
+
stopped.catch(() => void 0);
|
|
160
|
+
const end = () => {
|
|
158
161
|
clearTimeout(timer);
|
|
162
|
+
unlink();
|
|
163
|
+
};
|
|
164
|
+
return { signal: controller.signal, stopped, end };
|
|
165
|
+
}
|
|
166
|
+
get agentId() {
|
|
167
|
+
return this.config.agentId ?? "agent";
|
|
168
|
+
}
|
|
169
|
+
/** A model request, which the stop signal aborts: it fails with `AgentLlmError` unless the run was stopped. */
|
|
170
|
+
async requestCompletion(prompt, signal) {
|
|
171
|
+
try {
|
|
172
|
+
const completion = await this.config.adapter.completion(
|
|
173
|
+
prompt,
|
|
174
|
+
this.toolsForModel(),
|
|
175
|
+
this.completionOptions(signal)
|
|
176
|
+
);
|
|
177
|
+
signal.throwIfAborted();
|
|
178
|
+
return completion;
|
|
179
|
+
} catch (error) {
|
|
180
|
+
throw this.modelError(error, signal);
|
|
159
181
|
}
|
|
160
182
|
}
|
|
183
|
+
toolsForModel() {
|
|
184
|
+
return this.config.tools.length > 0 ? this.config.tools : void 0;
|
|
185
|
+
}
|
|
186
|
+
completionOptions(signal) {
|
|
187
|
+
return { ...this.config.completionOptions, signal };
|
|
188
|
+
}
|
|
189
|
+
/** What a failed model request fails the run with: the stop reason, a FrontMCP error as it is, or `AgentLlmError`. */
|
|
190
|
+
modelError(error, signal) {
|
|
191
|
+
if (signal.aborted) return signal.reason;
|
|
192
|
+
if (error instanceof McpError) return error;
|
|
193
|
+
return new AgentLlmError(this.agentId, error instanceof Error ? error : new Error(String(error)));
|
|
194
|
+
}
|
|
195
|
+
loopExceededError() {
|
|
196
|
+
return new AgentLoopExceededError(this.agentId, this.config.maxIterations);
|
|
197
|
+
}
|
|
161
198
|
// ============================================================================
|
|
162
199
|
// Private Methods
|
|
163
200
|
// ============================================================================
|
|
164
|
-
async executeLoop(messages, toolExecutor, callbacks) {
|
|
201
|
+
async executeLoop(messages, toolExecutor, signal, callbacks) {
|
|
165
202
|
for (let iteration = 1; iteration <= this.config.maxIterations; iteration++) {
|
|
203
|
+
signal.throwIfAborted();
|
|
166
204
|
this.config.logger?.debug(`Agent loop iteration ${iteration}/${this.config.maxIterations}`);
|
|
167
205
|
this.config.onLlmStart?.(iteration, this.config.maxIterations);
|
|
168
206
|
const prompt = {
|
|
169
207
|
system: this.config.systemInstructions,
|
|
170
208
|
messages
|
|
171
209
|
};
|
|
172
|
-
const completion = await this.
|
|
173
|
-
prompt,
|
|
174
|
-
this.config.tools.length > 0 ? this.config.tools : void 0,
|
|
175
|
-
this.config.completionOptions
|
|
176
|
-
);
|
|
210
|
+
const completion = await this.requestCompletion(prompt, signal);
|
|
177
211
|
this.config.onLlmComplete?.(iteration, completion.usage);
|
|
178
212
|
if (completion.usage) {
|
|
179
213
|
callbacks.onUsage(completion.usage.promptTokens, completion.usage.completionTokens);
|
|
@@ -192,18 +226,21 @@ var AgentExecutionLoop = class {
|
|
|
192
226
|
callbacks.onIteration(iteration, assistantMessage);
|
|
193
227
|
const totalTools = completion.toolCalls.length;
|
|
194
228
|
for (let toolIndex = 0; toolIndex < totalTools; toolIndex++) {
|
|
229
|
+
signal.throwIfAborted();
|
|
195
230
|
const toolCall = completion.toolCalls[toolIndex];
|
|
196
231
|
this.config.onToolStart?.(toolCall, toolIndex, totalTools);
|
|
197
232
|
this.config.onToolCall?.(toolCall);
|
|
233
|
+
signal.throwIfAborted();
|
|
198
234
|
let result;
|
|
199
|
-
let
|
|
235
|
+
let error;
|
|
200
236
|
try {
|
|
201
237
|
result = await toolExecutor(toolCall.name, toolCall.arguments);
|
|
202
238
|
} catch (e) {
|
|
203
|
-
|
|
204
|
-
result = { error:
|
|
239
|
+
error = e;
|
|
240
|
+
result = { error: error.message };
|
|
205
241
|
}
|
|
206
|
-
|
|
242
|
+
signal.throwIfAborted();
|
|
243
|
+
this.config.onToolResult?.(toolCall, result, error);
|
|
207
244
|
const toolMessage = {
|
|
208
245
|
role: "tool",
|
|
209
246
|
content: typeof result === "string" ? result : JSON.stringify(result),
|
|
@@ -224,15 +261,11 @@ var AgentExecutionLoop = class {
|
|
|
224
261
|
return { content: completion.content };
|
|
225
262
|
}
|
|
226
263
|
}
|
|
227
|
-
|
|
228
|
-
`Agent reached maximum iterations (${this.config.maxIterations}) without completing`,
|
|
229
|
-
this.config.maxIterations
|
|
230
|
-
);
|
|
231
|
-
this.config.onComplete?.(null, error);
|
|
232
|
-
throw error;
|
|
264
|
+
throw this.loopExceededError();
|
|
233
265
|
}
|
|
234
|
-
async *executeLoopStreaming(messages, toolExecutor) {
|
|
266
|
+
async *executeLoopStreaming(messages, toolExecutor, signal) {
|
|
235
267
|
for (let iteration = 1; iteration <= this.config.maxIterations; iteration++) {
|
|
268
|
+
signal.throwIfAborted();
|
|
236
269
|
this.config.logger?.debug(`Agent loop iteration ${iteration}/${this.config.maxIterations}`);
|
|
237
270
|
this.config.onLlmStart?.(iteration, this.config.maxIterations);
|
|
238
271
|
yield { type: "iteration", iteration };
|
|
@@ -240,7 +273,7 @@ var AgentExecutionLoop = class {
|
|
|
240
273
|
system: this.config.systemInstructions,
|
|
241
274
|
messages
|
|
242
275
|
};
|
|
243
|
-
const completion = yield* this.streamCompletion(prompt);
|
|
276
|
+
const completion = yield* this.streamCompletion(prompt, signal);
|
|
244
277
|
this.config.onLlmComplete?.(iteration, completion.usage);
|
|
245
278
|
if (completion.finishReason === "tool_calls" && completion.toolCalls?.length) {
|
|
246
279
|
const toolCalls = completion.toolCalls;
|
|
@@ -257,20 +290,23 @@ var AgentExecutionLoop = class {
|
|
|
257
290
|
this.config.onIteration?.(iteration, assistantMessage);
|
|
258
291
|
const totalTools = toolCalls.length;
|
|
259
292
|
for (let toolIndex = 0; toolIndex < totalTools; toolIndex++) {
|
|
293
|
+
signal.throwIfAborted();
|
|
260
294
|
const toolCall = toolCalls[toolIndex];
|
|
261
295
|
this.config.onToolStart?.(toolCall, toolIndex, totalTools);
|
|
262
296
|
this.config.onToolCall?.(toolCall);
|
|
263
297
|
yield { type: "tool_start", toolCall };
|
|
298
|
+
signal.throwIfAborted();
|
|
264
299
|
let result;
|
|
265
|
-
let
|
|
300
|
+
let error;
|
|
266
301
|
try {
|
|
267
302
|
result = await toolExecutor(toolCall.name, toolCall.arguments);
|
|
268
303
|
} catch (e) {
|
|
269
|
-
|
|
270
|
-
result = { error:
|
|
304
|
+
error = e;
|
|
305
|
+
result = { error: error.message };
|
|
271
306
|
}
|
|
272
|
-
|
|
273
|
-
|
|
307
|
+
signal.throwIfAborted();
|
|
308
|
+
this.config.onToolResult?.(toolCall, result, error);
|
|
309
|
+
yield { type: "tool_end", toolCall, result, error };
|
|
274
310
|
const toolMessage = {
|
|
275
311
|
role: "tool",
|
|
276
312
|
content: typeof result === "string" ? result : JSON.stringify(result),
|
|
@@ -290,12 +326,7 @@ var AgentExecutionLoop = class {
|
|
|
290
326
|
return { content: completion.content };
|
|
291
327
|
}
|
|
292
328
|
}
|
|
293
|
-
|
|
294
|
-
`Agent reached maximum iterations (${this.config.maxIterations}) without completing`,
|
|
295
|
-
this.config.maxIterations
|
|
296
|
-
);
|
|
297
|
-
this.config.onComplete?.(null, error);
|
|
298
|
-
throw error;
|
|
329
|
+
throw this.loopExceededError();
|
|
299
330
|
}
|
|
300
331
|
/**
|
|
301
332
|
* One reply of the model, streamed: yields its text as it arrives, the tool calls it announces and its
|
|
@@ -304,15 +335,24 @@ var AgentExecutionLoop = class {
|
|
|
304
335
|
* announce before they are known. A reply that arrives in one piece (an adapter without
|
|
305
336
|
* `streamCompletion()`, or one whose stream only ends with `done`) yields its text as one chunk.
|
|
306
337
|
*/
|
|
307
|
-
async *streamCompletion(prompt) {
|
|
338
|
+
async *streamCompletion(prompt, signal) {
|
|
339
|
+
try {
|
|
340
|
+
return yield* this.streamModelReply(prompt, signal);
|
|
341
|
+
} catch (error) {
|
|
342
|
+
throw this.modelError(error, signal);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
async *streamModelReply(prompt, signal) {
|
|
308
346
|
const adapter = this.config.adapter;
|
|
309
|
-
const tools = this.
|
|
347
|
+
const tools = this.toolsForModel();
|
|
348
|
+
const options = this.completionOptions(signal);
|
|
310
349
|
let streamedText = "";
|
|
311
350
|
let completion;
|
|
312
351
|
if (supportsStreaming(adapter)) {
|
|
313
352
|
const announced = /* @__PURE__ */ new Map();
|
|
314
353
|
let done;
|
|
315
|
-
for await (const chunk of adapter.streamCompletion(prompt, tools,
|
|
354
|
+
for await (const chunk of adapter.streamCompletion(prompt, tools, options)) {
|
|
355
|
+
signal.throwIfAborted();
|
|
316
356
|
if (chunk.type === "content" && chunk.content) {
|
|
317
357
|
streamedText += chunk.content;
|
|
318
358
|
yield { type: "content", content: chunk.content };
|
|
@@ -336,8 +376,9 @@ var AgentExecutionLoop = class {
|
|
|
336
376
|
...done?.usage && { usage: done.usage }
|
|
337
377
|
};
|
|
338
378
|
} else {
|
|
339
|
-
completion = await adapter.completion(prompt, tools,
|
|
379
|
+
completion = await adapter.completion(prompt, tools, options);
|
|
340
380
|
}
|
|
381
|
+
signal.throwIfAborted();
|
|
341
382
|
if (!streamedText && completion.content) {
|
|
342
383
|
yield { type: "content", content: completion.content };
|
|
343
384
|
this.config.onContent?.(completion.content);
|
|
@@ -357,15 +398,6 @@ function definedFields(toolCall) {
|
|
|
357
398
|
Object.entries(toolCall).filter(([, value]) => value !== void 0)
|
|
358
399
|
);
|
|
359
400
|
}
|
|
360
|
-
var AgentMaxIterationsError = class extends Error {
|
|
361
|
-
constructor(message, maxIterations) {
|
|
362
|
-
super(message);
|
|
363
|
-
this.maxIterations = maxIterations;
|
|
364
|
-
this.name = "AgentMaxIterationsError";
|
|
365
|
-
}
|
|
366
|
-
maxIterations;
|
|
367
|
-
};
|
|
368
401
|
export {
|
|
369
|
-
AgentExecutionLoop
|
|
370
|
-
AgentMaxIterationsError
|
|
402
|
+
AgentExecutionLoop
|
|
371
403
|
};
|
|
@@ -17,6 +17,10 @@ var AgentRegistry = class extends RegistryAbstract {
|
|
|
17
17
|
children = /* @__PURE__ */ new Set();
|
|
18
18
|
/** Unsubscribe functions for child registry subscriptions */
|
|
19
19
|
childSubscriptions = /* @__PURE__ */ new Map();
|
|
20
|
+
/** Whether this registry registers its agents' entries in its parent scope, and has begun to. */
|
|
21
|
+
servesParentScope = false;
|
|
22
|
+
/** The agents whose tool, and exported resources and prompts, this registry registered in its parent scope. */
|
|
23
|
+
servedInParentScope = /* @__PURE__ */ new Set();
|
|
20
24
|
// ---- O(1) indexes over EFFECTIVE set (local + adopted) ----
|
|
21
25
|
byQualifiedId = /* @__PURE__ */ new Map();
|
|
22
26
|
byName = /* @__PURE__ */ new Map();
|
|
@@ -124,28 +128,29 @@ var AgentRegistry = class extends RegistryAbstract {
|
|
|
124
128
|
*/
|
|
125
129
|
async registerAgentToolsInParentScope() {
|
|
126
130
|
const scope = this.providers.getActiveScope();
|
|
127
|
-
|
|
128
|
-
if (!toolRegistry) {
|
|
131
|
+
if (!scope.tools) {
|
|
129
132
|
return;
|
|
130
133
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
134
|
+
this.servesParentScope = true;
|
|
135
|
+
this.syncParentScope();
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Register in the parent scope the agents this registry gained since it last did, and take out the entries of
|
|
139
|
+
* those it no longer has (an ESM app's agents, replaced by a new version of its package).
|
|
140
|
+
*/
|
|
141
|
+
syncParentScope() {
|
|
142
|
+
if (!this.servesParentScope) return;
|
|
143
|
+
const scope = this.providers.getActiveScope();
|
|
144
|
+
const live = new Set(this.listAllInstances());
|
|
145
|
+
for (const agent of [...this.servedInParentScope]) {
|
|
146
|
+
if (live.has(agent)) continue;
|
|
147
|
+
this.servedInParentScope.delete(agent);
|
|
148
|
+
withdrawAgentFromScope(scope, agent);
|
|
149
|
+
}
|
|
150
|
+
for (const agent of live) {
|
|
151
|
+
if (this.servedInParentScope.has(agent)) continue;
|
|
152
|
+
this.servedInParentScope.add(agent);
|
|
153
|
+
serveAgentInScope(scope, agent);
|
|
149
154
|
}
|
|
150
155
|
}
|
|
151
156
|
// ============================================================================
|
|
@@ -165,6 +170,7 @@ var AgentRegistry = class extends RegistryAbstract {
|
|
|
165
170
|
const latest = child.listAllIndexed().map((r) => this.relineage(r, prepend));
|
|
166
171
|
this.adopted.set(child, latest);
|
|
167
172
|
this.reindex();
|
|
173
|
+
this.syncParentScope();
|
|
168
174
|
this.bump("reset");
|
|
169
175
|
});
|
|
170
176
|
this.childSubscriptions.set(child, unsubscribe);
|
|
@@ -184,6 +190,7 @@ var AgentRegistry = class extends RegistryAbstract {
|
|
|
184
190
|
this.adopted.delete(child);
|
|
185
191
|
this.children.delete(child);
|
|
186
192
|
this.reindex();
|
|
193
|
+
this.syncParentScope();
|
|
187
194
|
this.bump("reset");
|
|
188
195
|
}
|
|
189
196
|
/**
|
|
@@ -393,6 +400,35 @@ function dedupLineage(l) {
|
|
|
393
400
|
}
|
|
394
401
|
return out;
|
|
395
402
|
}
|
|
403
|
+
function serveAgentInScope(scope, agent) {
|
|
404
|
+
const toolInstance = agent.getToolInstance();
|
|
405
|
+
if (toolInstance) {
|
|
406
|
+
try {
|
|
407
|
+
scope.tools.registerToolInstance(toolInstance);
|
|
408
|
+
scope.logger.debug(`Registered agent tool ${toolInstance.name} in parent ToolRegistry`);
|
|
409
|
+
} catch (error) {
|
|
410
|
+
scope.logger.warn(
|
|
411
|
+
`Failed to register agent tool for ${agent.name}: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
412
|
+
);
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
for (const resource of agent.getExportedResources()) {
|
|
416
|
+
scope.resources?.registerResourceInstance(resource);
|
|
417
|
+
}
|
|
418
|
+
for (const prompt of agent.getExportedPrompts()) {
|
|
419
|
+
scope.prompts?.registerPromptInstance(prompt);
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
function withdrawAgentFromScope(scope, agent) {
|
|
423
|
+
const toolInstance = agent.getToolInstance();
|
|
424
|
+
if (toolInstance) scope.tools.unregisterToolInstance(toolInstance.record.provide);
|
|
425
|
+
for (const resource of agent.getExportedResources()) {
|
|
426
|
+
scope.resources?.unregisterResourceInstance(resource.record.provide);
|
|
427
|
+
}
|
|
428
|
+
for (const prompt of agent.getExportedPrompts()) {
|
|
429
|
+
scope.prompts?.unregisterPromptInstance(prompt.record.provide);
|
|
430
|
+
}
|
|
431
|
+
}
|
|
396
432
|
export {
|
|
397
433
|
AgentRegistry as default
|
|
398
434
|
};
|
|
@@ -284,6 +284,7 @@ var CallAgentFlow = class extends FlowBase {
|
|
|
284
284
|
const frontmcpContext = context.tryGetContext();
|
|
285
285
|
const sdkAuthInfo = authInfo;
|
|
286
286
|
const jsonRpcRequestId = this.state.jsonRpcRequestId;
|
|
287
|
+
context._jsonRpcRequestIdInternal = jsonRpcRequestId;
|
|
287
288
|
if (frontmcpContext && sdkAuthInfo?.transport?.sendElicitRequest && jsonRpcRequestId !== void 0) {
|
|
288
289
|
const transport = sdkAuthInfo.transport;
|
|
289
290
|
frontmcpContext.setTransport({
|
|
@@ -562,7 +563,7 @@ CallAgentFlow = __decorateClass([
|
|
|
562
563
|
plan,
|
|
563
564
|
inputSchema,
|
|
564
565
|
outputSchema,
|
|
565
|
-
access: "
|
|
566
|
+
access: "public"
|
|
566
567
|
})
|
|
567
568
|
], CallAgentFlow);
|
|
568
569
|
export {
|
package/browser/agent/index.mjs
CHANGED
|
@@ -3,7 +3,7 @@ export { AgentEmitter, agentEmitter } from "./agent.events.mjs";
|
|
|
3
3
|
export { agentDiscoveryDeps, agentFullName, agentToolName, canAgentSeeSwarm, extractAgentClassMetadata, extractAgentFunctionMetadata, getVisibleAgentIds, isAgentClass, isAgentFunction, isAgentVisibleToSwarm, normalizeAgent, validateAgentMetadata } from "./agent.utils.mjs";
|
|
4
4
|
import { AgentInstance } from "./agent.instance.mjs";
|
|
5
5
|
import { default as default2 } from "./agent.registry.mjs";
|
|
6
|
-
export { AgentExecutionLoop
|
|
6
|
+
export { AgentExecutionLoop } from "./agent-execution-loop.mjs";
|
|
7
7
|
export { CallAgentFlow } from "./flows/index.mjs";
|
|
8
8
|
export { AgentHook, DidAgentStage, OnAgentStage, WillAgentStage } from "./hooks/index.mjs";
|
|
9
9
|
export { AnthropicAdapter, BaseLlmAdapter, LLM_ADAPTER, LlmAdapterError, LlmContextLengthError, LlmRateLimitError, OpenAIAdapter, createAdapter, isAdapterConfig, isAdapterInstance, isBuiltinConfig, isTokenConfig, resolveApiKey, resolveStringValue } from "./adapters/index.mjs";
|