@adonis-agora/agent 0.60.1 → 0.62.0
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/CHANGELOG.md +96 -0
- package/README.md +12 -7
- package/dist/configure.d.ts +7 -5
- package/dist/configure.d.ts.map +1 -1
- package/dist/configure.js +9 -5
- package/dist/configure.js.map +1 -1
- package/dist/providers/a2a_provider.d.ts +14 -0
- package/dist/providers/a2a_provider.d.ts.map +1 -0
- package/dist/providers/a2a_provider.js +136 -0
- package/dist/providers/a2a_provider.js.map +1 -0
- package/dist/providers/agent_provider.d.ts.map +1 -1
- package/dist/providers/agent_provider.js +195 -11
- package/dist/providers/agent_provider.js.map +1 -1
- package/dist/providers/mcp_provider.d.ts +3 -0
- package/dist/providers/mcp_provider.d.ts.map +1 -1
- package/dist/providers/mcp_provider.js +147 -62
- package/dist/providers/mcp_provider.js.map +1 -1
- package/dist/src/a2a/auth.d.ts +67 -0
- package/dist/src/a2a/auth.d.ts.map +1 -0
- package/dist/src/a2a/auth.js +47 -0
- package/dist/src/a2a/auth.js.map +1 -0
- package/dist/src/a2a/define_config.d.ts +74 -0
- package/dist/src/a2a/define_config.d.ts.map +1 -0
- package/dist/src/a2a/define_config.js +5 -0
- package/dist/src/a2a/define_config.js.map +1 -0
- package/dist/src/a2a/gate.d.ts +23 -0
- package/dist/src/a2a/gate.d.ts.map +1 -0
- package/dist/src/a2a/gate.js +56 -0
- package/dist/src/a2a/gate.js.map +1 -0
- package/dist/src/a2a/handler.d.ts +65 -0
- package/dist/src/a2a/handler.d.ts.map +1 -0
- package/dist/src/a2a/handler.js +322 -0
- package/dist/src/a2a/handler.js.map +1 -0
- package/dist/src/a2a/index.d.ts +15 -0
- package/dist/src/a2a/index.d.ts.map +1 -0
- package/dist/src/a2a/index.js +9 -0
- package/dist/src/a2a/index.js.map +1 -0
- package/dist/src/a2a/permission-tool.d.ts +17 -0
- package/dist/src/a2a/permission-tool.d.ts.map +1 -0
- package/dist/src/a2a/permission-tool.js +70 -0
- package/dist/src/a2a/permission-tool.js.map +1 -0
- package/dist/src/a2a/protocol.d.ts +100 -0
- package/dist/src/a2a/protocol.d.ts.map +1 -0
- package/dist/src/a2a/protocol.js +106 -0
- package/dist/src/a2a/protocol.js.map +1 -0
- package/dist/src/a2a/runtime.d.ts +6 -0
- package/dist/src/a2a/runtime.d.ts.map +1 -0
- package/dist/src/a2a/runtime.js +13 -0
- package/dist/src/a2a/runtime.js.map +1 -0
- package/dist/src/a2a/server_middleware.d.ts +13 -0
- package/dist/src/a2a/server_middleware.d.ts.map +1 -0
- package/dist/src/a2a/server_middleware.js +18 -0
- package/dist/src/a2a/server_middleware.js.map +1 -0
- package/dist/src/a2a/store.d.ts +79 -0
- package/dist/src/a2a/store.d.ts.map +1 -0
- package/dist/src/a2a/store.js +151 -0
- package/dist/src/a2a/store.js.map +1 -0
- package/dist/src/a2a/turn.d.ts +80 -0
- package/dist/src/a2a/turn.d.ts.map +1 -0
- package/dist/src/a2a/turn.js +211 -0
- package/dist/src/a2a/turn.js.map +1 -0
- package/dist/src/action-proposal-approval.d.ts +26 -0
- package/dist/src/action-proposal-approval.d.ts.map +1 -0
- package/dist/src/action-proposal-approval.js +28 -0
- package/dist/src/action-proposal-approval.js.map +1 -0
- package/dist/src/action-proposal-discovery.d.ts +9 -0
- package/dist/src/action-proposal-discovery.d.ts.map +1 -0
- package/dist/src/action-proposal-discovery.js +20 -0
- package/dist/src/action-proposal-discovery.js.map +1 -0
- package/dist/src/action-proposal-executor.d.ts +40 -0
- package/dist/src/action-proposal-executor.d.ts.map +1 -0
- package/dist/src/action-proposal-executor.js +80 -0
- package/dist/src/action-proposal-executor.js.map +1 -0
- package/dist/src/action-proposal-outcome.d.ts +12 -0
- package/dist/src/action-proposal-outcome.d.ts.map +1 -0
- package/dist/src/action-proposal-outcome.js +86 -0
- package/dist/src/action-proposal-outcome.js.map +1 -0
- package/dist/src/action-proposal-preparation.d.ts +20 -0
- package/dist/src/action-proposal-preparation.d.ts.map +1 -0
- package/dist/src/action-proposal-preparation.js +27 -0
- package/dist/src/action-proposal-preparation.js.map +1 -0
- package/dist/src/action-proposal-receipt.d.ts +12 -0
- package/dist/src/action-proposal-receipt.d.ts.map +1 -0
- package/dist/src/action-proposal-receipt.js +4 -0
- package/dist/src/action-proposal-receipt.js.map +1 -0
- package/dist/src/action-proposal-runtime.d.ts +9 -0
- package/dist/src/action-proposal-runtime.d.ts.map +1 -0
- package/dist/src/action-proposal-runtime.js +34 -0
- package/dist/src/action-proposal-runtime.js.map +1 -0
- package/dist/src/action-proposal-service.d.ts +47 -0
- package/dist/src/action-proposal-service.d.ts.map +1 -0
- package/dist/src/action-proposal-service.js +136 -0
- package/dist/src/action-proposal-service.js.map +1 -0
- package/dist/src/action-proposal-text.d.ts +72 -0
- package/dist/src/action-proposal-text.d.ts.map +1 -0
- package/dist/src/action-proposal-text.js +119 -0
- package/dist/src/action-proposal-text.js.map +1 -0
- package/dist/src/action-proposal-transitions.d.ts +20 -0
- package/dist/src/action-proposal-transitions.d.ts.map +1 -0
- package/dist/src/action-proposal-transitions.js +311 -0
- package/dist/src/action-proposal-transitions.js.map +1 -0
- package/dist/src/action-proposal-worker.d.ts +32 -0
- package/dist/src/action-proposal-worker.d.ts.map +1 -0
- package/dist/src/action-proposal-worker.js +140 -0
- package/dist/src/action-proposal-worker.js.map +1 -0
- package/dist/src/ag-ui/adapter.d.ts.map +1 -1
- package/dist/src/ag-ui/adapter.js +106 -1
- package/dist/src/ag-ui/adapter.js.map +1 -1
- package/dist/src/ag-ui/core/encoder.d.ts +105 -0
- package/dist/src/ag-ui/core/encoder.d.ts.map +1 -0
- package/dist/src/ag-ui/core/encoder.js +523 -0
- package/dist/src/ag-ui/core/encoder.js.map +1 -0
- package/dist/src/ag-ui/core/index.d.ts +12 -0
- package/dist/src/ag-ui/core/index.d.ts.map +1 -0
- package/dist/src/ag-ui/core/index.js +12 -0
- package/dist/src/ag-ui/core/index.js.map +1 -0
- package/dist/src/ag-ui/core/input.d.ts +74 -0
- package/dist/src/ag-ui/core/input.d.ts.map +1 -0
- package/dist/src/ag-ui/core/input.js +228 -0
- package/dist/src/ag-ui/core/input.js.map +1 -0
- package/dist/src/ag-ui/core/interrupt-id.d.ts +31 -0
- package/dist/src/ag-ui/core/interrupt-id.d.ts.map +1 -0
- package/dist/src/ag-ui/core/interrupt-id.js +48 -0
- package/dist/src/ag-ui/core/interrupt-id.js.map +1 -0
- package/dist/src/ag-ui/core/proposal-decision.d.ts +9 -0
- package/dist/src/ag-ui/core/proposal-decision.d.ts.map +1 -0
- package/dist/src/ag-ui/core/proposal-decision.js +20 -0
- package/dist/src/ag-ui/core/proposal-decision.js.map +1 -0
- package/dist/src/ag-ui/core/stream.d.ts +27 -0
- package/dist/src/ag-ui/core/stream.d.ts.map +1 -0
- package/dist/src/ag-ui/core/stream.js +68 -0
- package/dist/src/ag-ui/core/stream.js.map +1 -0
- package/dist/src/ag-ui/core/types.d.ts +249 -0
- package/dist/src/ag-ui/core/types.d.ts.map +1 -0
- package/dist/src/ag-ui/core/types.js +35 -0
- package/dist/src/ag-ui/core/types.js.map +1 -0
- package/dist/src/ag-ui/encoder.d.ts +3 -4
- package/dist/src/ag-ui/encoder.d.ts.map +1 -1
- package/dist/src/ag-ui/encoder.js +10 -11
- package/dist/src/ag-ui/encoder.js.map +1 -1
- package/dist/src/ag-ui/frames.d.ts +4 -5
- package/dist/src/ag-ui/frames.d.ts.map +1 -1
- package/dist/src/ag-ui/frames.js +9 -4
- package/dist/src/ag-ui/frames.js.map +1 -1
- package/dist/src/ag-ui/index.d.ts +3 -5
- package/dist/src/ag-ui/index.d.ts.map +1 -1
- package/dist/src/ag-ui/index.js +3 -5
- package/dist/src/ag-ui/index.js.map +1 -1
- package/dist/src/ag-ui/stream.d.ts +3 -4
- package/dist/src/ag-ui/stream.d.ts.map +1 -1
- package/dist/src/ag-ui/stream.js +4 -5
- package/dist/src/ag-ui/stream.js.map +1 -1
- package/dist/src/agent-deps-factory.d.ts +8 -0
- package/dist/src/agent-deps-factory.d.ts.map +1 -1
- package/dist/src/agent-deps-factory.js +12 -0
- package/dist/src/agent-deps-factory.js.map +1 -1
- package/dist/src/agent-deps.d.ts +7 -0
- package/dist/src/agent-deps.d.ts.map +1 -1
- package/dist/src/agent-deps.js.map +1 -1
- package/dist/src/agent-loop.d.ts +8 -3
- package/dist/src/agent-loop.d.ts.map +1 -1
- package/dist/src/agent-loop.js +398 -63
- package/dist/src/agent-loop.js.map +1 -1
- package/dist/src/agent-service.d.ts +52 -2
- package/dist/src/agent-service.d.ts.map +1 -1
- package/dist/src/agent-service.js +62 -2
- package/dist/src/agent-service.js.map +1 -1
- package/dist/src/ai-sdk/ai-sdk-model.js +4 -1
- package/dist/src/ai-sdk/ai-sdk-model.js.map +1 -1
- package/dist/src/ai-tool-ref.d.ts +6 -1
- package/dist/src/ai-tool-ref.d.ts.map +1 -1
- package/dist/src/ai-tool-ref.js +32 -16
- package/dist/src/ai-tool-ref.js.map +1 -1
- package/dist/src/chat-queue-service.d.ts.map +1 -1
- package/dist/src/chat-queue-service.js +4 -0
- package/dist/src/chat-queue-service.js.map +1 -1
- package/dist/src/client/chat-client.d.ts +12 -0
- package/dist/src/client/chat-client.d.ts.map +1 -1
- package/dist/src/client/chat-client.js +69 -1
- package/dist/src/client/chat-client.js.map +1 -1
- package/dist/src/client/sse.d.ts +15 -0
- package/dist/src/client/sse.d.ts.map +1 -1
- package/dist/src/client/sse.js +45 -0
- package/dist/src/client/sse.js.map +1 -1
- package/dist/src/define_config.d.ts +70 -12
- package/dist/src/define_config.d.ts.map +1 -1
- package/dist/src/define_config.js.map +1 -1
- package/dist/src/engine.d.ts +77 -0
- package/dist/src/engine.d.ts.map +1 -0
- package/dist/src/engine.js +27 -0
- package/dist/src/engine.js.map +1 -0
- package/dist/src/genui/builtins.d.ts +73 -3
- package/dist/src/genui/builtins.d.ts.map +1 -1
- package/dist/src/genui/builtins.js +298 -3
- package/dist/src/genui/builtins.js.map +1 -1
- package/dist/src/genui/capabilities.d.ts +24 -0
- package/dist/src/genui/capabilities.d.ts.map +1 -0
- package/dist/src/genui/capabilities.js +81 -0
- package/dist/src/genui/capabilities.js.map +1 -0
- package/dist/src/genui/catalog.d.ts +77 -0
- package/dist/src/genui/catalog.d.ts.map +1 -0
- package/dist/src/genui/catalog.js +88 -0
- package/dist/src/genui/catalog.js.map +1 -0
- package/dist/src/genui/factory.d.ts +8 -8
- package/dist/src/genui/factory.d.ts.map +1 -1
- package/dist/src/genui/factory.js +3 -1
- package/dist/src/genui/factory.js.map +1 -1
- package/dist/src/genui/index.d.ts +4 -12
- package/dist/src/genui/index.d.ts.map +1 -1
- package/dist/src/genui/index.js +6 -18
- package/dist/src/genui/index.js.map +1 -1
- package/dist/src/genui/public.d.ts +9 -0
- package/dist/src/genui/public.d.ts.map +1 -0
- package/dist/src/genui/public.js +9 -0
- package/dist/src/genui/public.js.map +1 -0
- package/dist/src/genui/registry.d.ts +65 -0
- package/dist/src/genui/registry.d.ts.map +1 -0
- package/dist/src/genui/registry.js +151 -0
- package/dist/src/genui/registry.js.map +1 -0
- package/dist/src/genui/schema.d.ts +71 -0
- package/dist/src/genui/schema.d.ts.map +1 -0
- package/dist/src/genui/schema.js +304 -0
- package/dist/src/genui/schema.js.map +1 -0
- package/dist/src/genui/text.d.ts +35 -0
- package/dist/src/genui/text.d.ts.map +1 -0
- package/dist/src/genui/text.js +156 -0
- package/dist/src/genui/text.js.map +1 -0
- package/dist/src/genui/tools.d.ts +91 -0
- package/dist/src/genui/tools.d.ts.map +1 -0
- package/dist/src/genui/tools.js +292 -0
- package/dist/src/genui/tools.js.map +1 -0
- package/dist/src/genui/tree.d.ts +56 -0
- package/dist/src/genui/tree.d.ts.map +1 -0
- package/dist/src/genui/tree.js +188 -0
- package/dist/src/genui/tree.js.map +1 -0
- package/dist/src/index.d.ts +21 -3
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +19 -2
- package/dist/src/index.js.map +1 -1
- package/dist/src/mcp/auth.d.ts +17 -1
- package/dist/src/mcp/auth.d.ts.map +1 -1
- package/dist/src/mcp/auth.js +14 -3
- package/dist/src/mcp/auth.js.map +1 -1
- package/dist/src/mcp/define_config.d.ts +81 -2
- package/dist/src/mcp/define_config.d.ts.map +1 -1
- package/dist/src/mcp/define_config.js.map +1 -1
- package/dist/src/mcp/index.d.ts +1 -1
- package/dist/src/mcp/index.d.ts.map +1 -1
- package/dist/src/mcp/index.js.map +1 -1
- package/dist/src/mcp/oauth-resource.d.ts +9 -0
- package/dist/src/mcp/oauth-resource.d.ts.map +1 -0
- package/dist/src/mcp/oauth-resource.js +16 -0
- package/dist/src/mcp/oauth-resource.js.map +1 -0
- package/dist/src/mcp/server.d.ts +5 -0
- package/dist/src/mcp/server.d.ts.map +1 -1
- package/dist/src/mcp/server.js +48 -16
- package/dist/src/mcp/server.js.map +1 -1
- package/dist/src/negotiated-tool-ui.d.ts +10 -0
- package/dist/src/negotiated-tool-ui.d.ts.map +1 -0
- package/dist/src/negotiated-tool-ui.js +57 -0
- package/dist/src/negotiated-tool-ui.js.map +1 -0
- package/dist/src/opencode/client.d.ts +202 -0
- package/dist/src/opencode/client.d.ts.map +1 -0
- package/dist/src/opencode/client.js +2 -0
- package/dist/src/opencode/client.js.map +1 -0
- package/dist/src/opencode/durable/index.d.ts +33 -0
- package/dist/src/opencode/durable/index.d.ts.map +1 -0
- package/dist/src/opencode/durable/index.js +38 -0
- package/dist/src/opencode/durable/index.js.map +1 -0
- package/dist/src/opencode/durable/runner.d.ts +36 -0
- package/dist/src/opencode/durable/runner.d.ts.map +1 -0
- package/dist/src/opencode/durable/runner.js +88 -0
- package/dist/src/opencode/durable/runner.js.map +1 -0
- package/dist/src/opencode/durable/workflow.d.ts +40 -0
- package/dist/src/opencode/durable/workflow.d.ts.map +1 -0
- package/dist/src/opencode/durable/workflow.js +106 -0
- package/dist/src/opencode/durable/workflow.js.map +1 -0
- package/dist/src/opencode/engine.d.ts +48 -0
- package/dist/src/opencode/engine.d.ts.map +1 -0
- package/dist/src/opencode/engine.js +98 -0
- package/dist/src/opencode/engine.js.map +1 -0
- package/dist/src/opencode/event-hub.d.ts +23 -0
- package/dist/src/opencode/event-hub.d.ts.map +1 -0
- package/dist/src/opencode/event-hub.js +99 -0
- package/dist/src/opencode/event-hub.js.map +1 -0
- package/dist/src/opencode/forms.d.ts +19 -0
- package/dist/src/opencode/forms.d.ts.map +1 -0
- package/dist/src/opencode/forms.js +82 -0
- package/dist/src/opencode/forms.js.map +1 -0
- package/dist/src/opencode/host.d.ts +179 -0
- package/dist/src/opencode/host.d.ts.map +1 -0
- package/dist/src/opencode/host.js +34 -0
- package/dist/src/opencode/host.js.map +1 -0
- package/dist/src/opencode/index.d.ts +15 -0
- package/dist/src/opencode/index.d.ts.map +1 -0
- package/dist/src/opencode/index.js +9 -0
- package/dist/src/opencode/index.js.map +1 -0
- package/dist/src/opencode/log.d.ts +9 -0
- package/dist/src/opencode/log.d.ts.map +1 -0
- package/dist/src/opencode/log.js +15 -0
- package/dist/src/opencode/log.js.map +1 -0
- package/dist/src/opencode/mcp.d.ts +60 -0
- package/dist/src/opencode/mcp.d.ts.map +1 -0
- package/dist/src/opencode/mcp.js +258 -0
- package/dist/src/opencode/mcp.js.map +1 -0
- package/dist/src/opencode/runner.d.ts +40 -0
- package/dist/src/opencode/runner.d.ts.map +1 -0
- package/dist/src/opencode/runner.js +125 -0
- package/dist/src/opencode/runner.js.map +1 -0
- package/dist/src/opencode/turn.d.ts +167 -0
- package/dist/src/opencode/turn.d.ts.map +1 -0
- package/dist/src/opencode/turn.js +761 -0
- package/dist/src/opencode/turn.js.map +1 -0
- package/dist/src/opencode/turns.d.ts +245 -0
- package/dist/src/opencode/turns.d.ts.map +1 -0
- package/dist/src/opencode/turns.js +867 -0
- package/dist/src/opencode/turns.js.map +1 -0
- package/dist/src/personas.d.ts.map +1 -1
- package/dist/src/personas.js +4 -1
- package/dist/src/personas.js.map +1 -1
- package/dist/src/react/ag-ui.d.ts +4 -2
- package/dist/src/react/ag-ui.d.ts.map +1 -1
- package/dist/src/react/ag-ui.js +2 -2
- package/dist/src/react/ag-ui.js.map +1 -1
- package/dist/src/react/client.d.ts +1 -1
- package/dist/src/react/client.d.ts.map +1 -1
- package/dist/src/react/client.js +1 -1
- package/dist/src/react/client.js.map +1 -1
- package/dist/src/react/core/ag-ui-backend.d.ts +85 -0
- package/dist/src/react/core/ag-ui-backend.d.ts.map +1 -0
- package/dist/src/react/core/ag-ui-backend.js +409 -0
- package/dist/src/react/core/ag-ui-backend.js.map +1 -0
- package/dist/src/react/core/agent-chat-transport.d.ts +187 -0
- package/dist/src/react/core/agent-chat-transport.d.ts.map +1 -0
- package/dist/src/react/core/agent-chat-transport.js +796 -0
- package/dist/src/react/core/agent-chat-transport.js.map +1 -0
- package/dist/src/react/core/approvals/countdown.d.ts +22 -0
- package/dist/src/react/core/approvals/countdown.d.ts.map +1 -0
- package/dist/src/react/core/approvals/countdown.js +39 -0
- package/dist/src/react/core/approvals/countdown.js.map +1 -0
- package/dist/src/react/core/approvals/proposals.d.ts +15 -0
- package/dist/src/react/core/approvals/proposals.d.ts.map +1 -0
- package/dist/src/react/core/approvals/proposals.js +82 -0
- package/dist/src/react/core/approvals/proposals.js.map +1 -0
- package/dist/src/react/core/approvals/use-action-proposals.d.ts +10 -0
- package/dist/src/react/core/approvals/use-action-proposals.d.ts.map +1 -0
- package/dist/src/react/core/approvals/use-action-proposals.js +86 -0
- package/dist/src/react/core/approvals/use-action-proposals.js.map +1 -0
- package/dist/src/react/core/attachments/files.d.ts +39 -0
- package/dist/src/react/core/attachments/files.d.ts.map +1 -0
- package/dist/src/react/core/attachments/files.js +89 -0
- package/dist/src/react/core/attachments/files.js.map +1 -0
- package/dist/src/react/core/attachments/use-attachments.d.ts +106 -0
- package/dist/src/react/core/attachments/use-attachments.d.ts.map +1 -0
- package/dist/src/react/core/attachments/use-attachments.js +217 -0
- package/dist/src/react/core/attachments/use-attachments.js.map +1 -0
- package/dist/src/react/core/backend.d.ts +234 -0
- package/dist/src/react/core/backend.d.ts.map +1 -0
- package/dist/src/react/core/backend.js +21 -0
- package/dist/src/react/core/backend.js.map +1 -0
- package/dist/src/react/core/background-runs.d.ts +32 -0
- package/dist/src/react/core/background-runs.d.ts.map +1 -0
- package/dist/src/react/core/background-runs.js +47 -0
- package/dist/src/react/core/background-runs.js.map +1 -0
- package/dist/src/react/core/catalog/use-agents.d.ts +31 -0
- package/dist/src/react/core/catalog/use-agents.d.ts.map +1 -0
- package/dist/src/react/core/catalog/use-agents.js +28 -0
- package/dist/src/react/core/catalog/use-agents.js.map +1 -0
- package/dist/src/react/core/catalog/use-models.d.ts +41 -0
- package/dist/src/react/core/catalog/use-models.d.ts.map +1 -0
- package/dist/src/react/core/catalog/use-models.js +35 -0
- package/dist/src/react/core/catalog/use-models.js.map +1 -0
- package/dist/src/react/core/catalog/use-resource.d.ts +12 -0
- package/dist/src/react/core/catalog/use-resource.d.ts.map +1 -0
- package/dist/src/react/core/catalog/use-resource.js +41 -0
- package/dist/src/react/core/catalog/use-resource.js.map +1 -0
- package/dist/src/react/core/client-wire.d.ts +14 -0
- package/dist/src/react/core/client-wire.d.ts.map +1 -0
- package/dist/src/react/core/client-wire.js +2 -0
- package/dist/src/react/core/client-wire.js.map +1 -0
- package/dist/src/react/core/client.d.ts +222 -0
- package/dist/src/react/core/client.d.ts.map +1 -0
- package/dist/src/react/core/client.js +435 -0
- package/dist/src/react/core/client.js.map +1 -0
- package/dist/src/react/core/components/ambient-ui.d.ts +22 -0
- package/dist/src/react/core/components/ambient-ui.d.ts.map +1 -0
- package/dist/src/react/core/components/ambient-ui.js +30 -0
- package/dist/src/react/core/components/ambient-ui.js.map +1 -0
- package/dist/src/react/core/components/chat-input.d.ts +44 -0
- package/dist/src/react/core/components/chat-input.d.ts.map +1 -0
- package/dist/src/react/core/components/chat-input.js +69 -0
- package/dist/src/react/core/components/chat-input.js.map +1 -0
- package/dist/src/react/core/components/index.d.ts +7 -0
- package/dist/src/react/core/components/index.d.ts.map +1 -0
- package/dist/src/react/core/components/index.js +7 -0
- package/dist/src/react/core/components/index.js.map +1 -0
- package/dist/src/react/core/components/message-item.d.ts +101 -0
- package/dist/src/react/core/components/message-item.d.ts.map +1 -0
- package/dist/src/react/core/components/message-item.js +118 -0
- package/dist/src/react/core/components/message-item.js.map +1 -0
- package/dist/src/react/core/components/message-list.d.ts +85 -0
- package/dist/src/react/core/components/message-list.d.ts.map +1 -0
- package/dist/src/react/core/components/message-list.js +45 -0
- package/dist/src/react/core/components/message-list.js.map +1 -0
- package/dist/src/react/core/components/speech-languages.d.ts +22 -0
- package/dist/src/react/core/components/speech-languages.d.ts.map +1 -0
- package/dist/src/react/core/components/speech-languages.js +38 -0
- package/dist/src/react/core/components/speech-languages.js.map +1 -0
- package/dist/src/react/core/components/use-speech-recognition.d.ts +19 -0
- package/dist/src/react/core/components/use-speech-recognition.d.ts.map +1 -0
- package/dist/src/react/core/components/use-speech-recognition.js +92 -0
- package/dist/src/react/core/components/use-speech-recognition.js.map +1 -0
- package/dist/src/react/core/composer/index.d.ts +4 -0
- package/dist/src/react/core/composer/index.d.ts.map +1 -0
- package/dist/src/react/core/composer/index.js +4 -0
- package/dist/src/react/core/composer/index.js.map +1 -0
- package/dist/src/react/core/composer/model.d.ts +83 -0
- package/dist/src/react/core/composer/model.d.ts.map +1 -0
- package/dist/src/react/core/composer/model.js +53 -0
- package/dist/src/react/core/composer/model.js.map +1 -0
- package/dist/src/react/core/composer/skills-source.d.ts +29 -0
- package/dist/src/react/core/composer/skills-source.d.ts.map +1 -0
- package/dist/src/react/core/composer/skills-source.js +61 -0
- package/dist/src/react/core/composer/skills-source.js.map +1 -0
- package/dist/src/react/core/composer/use-composer-autocomplete.d.ts +78 -0
- package/dist/src/react/core/composer/use-composer-autocomplete.d.ts.map +1 -0
- package/dist/src/react/core/composer/use-composer-autocomplete.js +244 -0
- package/dist/src/react/core/composer/use-composer-autocomplete.js.map +1 -0
- package/dist/src/react/core/config/use-agent-config.d.ts +21 -0
- package/dist/src/react/core/config/use-agent-config.d.ts.map +1 -0
- package/dist/src/react/core/config/use-agent-config.js +57 -0
- package/dist/src/react/core/config/use-agent-config.js.map +1 -0
- package/dist/src/react/core/elicitation/answers.d.ts +22 -0
- package/dist/src/react/core/elicitation/answers.d.ts.map +1 -0
- package/dist/src/react/core/elicitation/answers.js +65 -0
- package/dist/src/react/core/elicitation/answers.js.map +1 -0
- package/dist/src/react/core/feedback/use-message-feedback.d.ts +32 -0
- package/dist/src/react/core/feedback/use-message-feedback.d.ts.map +1 -0
- package/dist/src/react/core/feedback/use-message-feedback.js +106 -0
- package/dist/src/react/core/feedback/use-message-feedback.js.map +1 -0
- package/dist/src/react/core/genui/generative-ui.d.ts +76 -0
- package/dist/src/react/core/genui/generative-ui.d.ts.map +1 -0
- package/dist/src/react/core/genui/generative-ui.js +210 -0
- package/dist/src/react/core/genui/generative-ui.js.map +1 -0
- package/dist/src/react/core/genui/index.d.ts +5 -0
- package/dist/src/react/core/genui/index.d.ts.map +1 -0
- package/dist/src/react/core/genui/index.js +5 -0
- package/dist/src/react/core/genui/index.js.map +1 -0
- package/dist/src/react/core/genui/json-render.d.ts +54 -0
- package/dist/src/react/core/genui/json-render.d.ts.map +1 -0
- package/dist/src/react/core/genui/json-render.js +64 -0
- package/dist/src/react/core/genui/json-render.js.map +1 -0
- package/dist/src/react/core/genui/playwright.d.ts +12 -0
- package/dist/src/react/core/genui/playwright.d.ts.map +1 -0
- package/dist/src/react/core/genui/playwright.js +141 -0
- package/dist/src/react/core/genui/playwright.js.map +1 -0
- package/dist/src/react/core/genui/react-registry.d.ts +22 -0
- package/dist/src/react/core/genui/react-registry.d.ts.map +1 -0
- package/dist/src/react/core/genui/react-registry.js +72 -0
- package/dist/src/react/core/genui/react-registry.js.map +1 -0
- package/dist/src/react/core/genui/server.d.ts +32 -0
- package/dist/src/react/core/genui/server.d.ts.map +1 -0
- package/dist/src/react/core/genui/server.js +66 -0
- package/dist/src/react/core/genui/server.js.map +1 -0
- package/dist/src/react/core/genui/types.d.ts +98 -0
- package/dist/src/react/core/genui/types.d.ts.map +1 -0
- package/dist/src/react/core/genui/types.js +3 -0
- package/dist/src/react/core/genui/types.js.map +1 -0
- package/dist/src/react/core/genui/use-generative-ui.d.ts +42 -0
- package/dist/src/react/core/genui/use-generative-ui.d.ts.map +1 -0
- package/dist/src/react/core/genui/use-generative-ui.js +186 -0
- package/dist/src/react/core/genui/use-generative-ui.js.map +1 -0
- package/dist/src/react/core/http-error.d.ts +33 -0
- package/dist/src/react/core/http-error.d.ts.map +1 -0
- package/dist/src/react/core/http-error.js +47 -0
- package/dist/src/react/core/http-error.js.map +1 -0
- package/dist/src/react/core/index.d.ts +35 -0
- package/dist/src/react/core/index.d.ts.map +1 -0
- package/dist/src/react/core/index.js +34 -0
- package/dist/src/react/core/index.js.map +1 -0
- package/dist/src/react/core/markdown/agent-markdown.d.ts +39 -0
- package/dist/src/react/core/markdown/agent-markdown.d.ts.map +1 -0
- package/dist/src/react/core/markdown/agent-markdown.js +22 -0
- package/dist/src/react/core/markdown/agent-markdown.js.map +1 -0
- package/dist/src/react/core/markdown/index.d.ts +2 -0
- package/dist/src/react/core/markdown/index.d.ts.map +1 -0
- package/dist/src/react/core/markdown/index.js +2 -0
- package/dist/src/react/core/markdown/index.js.map +1 -0
- package/dist/src/react/core/media/index.d.ts +64 -0
- package/dist/src/react/core/media/index.d.ts.map +1 -0
- package/dist/src/react/core/media/index.js +135 -0
- package/dist/src/react/core/media/index.js.map +1 -0
- package/dist/src/react/core/media/tus.d.ts +13 -0
- package/dist/src/react/core/media/tus.d.ts.map +1 -0
- package/dist/src/react/core/media/tus.js +59 -0
- package/dist/src/react/core/media/tus.js.map +1 -0
- package/dist/src/react/core/presentation/phrasing.d.ts +25 -0
- package/dist/src/react/core/presentation/phrasing.d.ts.map +1 -0
- package/dist/src/react/core/presentation/phrasing.js +58 -0
- package/dist/src/react/core/presentation/phrasing.js.map +1 -0
- package/dist/src/react/core/presentation/result-view.d.ts +43 -0
- package/dist/src/react/core/presentation/result-view.d.ts.map +1 -0
- package/dist/src/react/core/presentation/result-view.js +90 -0
- package/dist/src/react/core/presentation/result-view.js.map +1 -0
- package/dist/src/react/core/presentation/tool-activity.d.ts +106 -0
- package/dist/src/react/core/presentation/tool-activity.d.ts.map +1 -0
- package/dist/src/react/core/presentation/tool-activity.js +165 -0
- package/dist/src/react/core/presentation/tool-activity.js.map +1 -0
- package/dist/src/react/core/presentation/use-tool-catalog.d.ts +39 -0
- package/dist/src/react/core/presentation/use-tool-catalog.d.ts.map +1 -0
- package/dist/src/react/core/presentation/use-tool-catalog.js +77 -0
- package/dist/src/react/core/presentation/use-tool-catalog.js.map +1 -0
- package/dist/src/react/core/provider.d.ts +68 -0
- package/dist/src/react/core/provider.d.ts.map +1 -0
- package/dist/src/react/core/provider.js +61 -0
- package/dist/src/react/core/provider.js.map +1 -0
- package/dist/src/react/core/queue/model.d.ts +73 -0
- package/dist/src/react/core/queue/model.d.ts.map +1 -0
- package/dist/src/react/core/queue/model.js +2 -0
- package/dist/src/react/core/queue/model.js.map +1 -0
- package/dist/src/react/core/quota/use-quota.d.ts +35 -0
- package/dist/src/react/core/quota/use-quota.d.ts.map +1 -0
- package/dist/src/react/core/quota/use-quota.js +47 -0
- package/dist/src/react/core/quota/use-quota.js.map +1 -0
- package/dist/src/react/core/reasoning/timing.d.ts +38 -0
- package/dist/src/react/core/reasoning/timing.d.ts.map +1 -0
- package/dist/src/react/core/reasoning/timing.js +73 -0
- package/dist/src/react/core/reasoning/timing.js.map +1 -0
- package/dist/src/react/core/run-errors.d.ts +37 -0
- package/dist/src/react/core/run-errors.d.ts.map +1 -0
- package/dist/src/react/core/run-errors.js +37 -0
- package/dist/src/react/core/run-errors.js.map +1 -0
- package/dist/src/react/core/stored-message-to-ui-message.d.ts +4 -0
- package/dist/src/react/core/stored-message-to-ui-message.d.ts.map +1 -0
- package/dist/src/react/core/stored-message-to-ui-message.js +216 -0
- package/dist/src/react/core/stored-message-to-ui-message.js.map +1 -0
- package/dist/src/react/core/stored-thread-to-ui-messages.d.ts +82 -0
- package/dist/src/react/core/stored-thread-to-ui-messages.d.ts.map +1 -0
- package/dist/src/react/core/stored-thread-to-ui-messages.js +116 -0
- package/dist/src/react/core/stored-thread-to-ui-messages.js.map +1 -0
- package/dist/src/react/core/threads/threads-events.d.ts +22 -0
- package/dist/src/react/core/threads/threads-events.d.ts.map +1 -0
- package/dist/src/react/core/threads/threads-events.js +21 -0
- package/dist/src/react/core/threads/threads-events.js.map +1 -0
- package/dist/src/react/core/threads/use-threads.d.ts +31 -0
- package/dist/src/react/core/threads/use-threads.d.ts.map +1 -0
- package/dist/src/react/core/threads/use-threads.js +81 -0
- package/dist/src/react/core/threads/use-threads.js.map +1 -0
- package/dist/src/react/core/transcript/index.d.ts +4 -0
- package/dist/src/react/core/transcript/index.d.ts.map +1 -0
- package/dist/src/react/core/transcript/index.js +4 -0
- package/dist/src/react/core/transcript/index.js.map +1 -0
- package/dist/src/react/core/transcript/model.d.ts +399 -0
- package/dist/src/react/core/transcript/model.d.ts.map +1 -0
- package/dist/src/react/core/transcript/model.js +725 -0
- package/dist/src/react/core/transcript/model.js.map +1 -0
- package/dist/src/react/core/transcript/use-chat-transcript.d.ts +254 -0
- package/dist/src/react/core/transcript/use-chat-transcript.d.ts.map +1 -0
- package/dist/src/react/core/transcript/use-chat-transcript.js +572 -0
- package/dist/src/react/core/transcript/use-chat-transcript.js.map +1 -0
- package/dist/src/react/core/transcript/use-stick-to-bottom.d.ts +33 -0
- package/dist/src/react/core/transcript/use-stick-to-bottom.d.ts.map +1 -0
- package/dist/src/react/core/transcript/use-stick-to-bottom.js +48 -0
- package/dist/src/react/core/transcript/use-stick-to-bottom.js.map +1 -0
- package/dist/src/react/core/use-agent-chat.d.ts +341 -0
- package/dist/src/react/core/use-agent-chat.d.ts.map +1 -0
- package/dist/src/react/core/use-agent-chat.js +1118 -0
- package/dist/src/react/core/use-agent-chat.js.map +1 -0
- package/dist/src/react/genui/index.d.ts +1 -7
- package/dist/src/react/genui/index.d.ts.map +1 -1
- package/dist/src/react/genui/index.js +1 -7
- package/dist/src/react/genui/index.js.map +1 -1
- package/dist/src/react/genui/json-render.d.ts +1 -5
- package/dist/src/react/genui/json-render.d.ts.map +1 -1
- package/dist/src/react/genui/json-render.js +1 -5
- package/dist/src/react/genui/json-render.js.map +1 -1
- package/dist/src/react/genui/server.d.ts +2 -0
- package/dist/src/react/genui/server.d.ts.map +1 -0
- package/dist/src/react/genui/server.js +2 -0
- package/dist/src/react/genui/server.js.map +1 -0
- package/dist/src/react/genui/server_playwright.d.ts +2 -0
- package/dist/src/react/genui/server_playwright.d.ts.map +1 -0
- package/dist/src/react/genui/server_playwright.js +2 -0
- package/dist/src/react/genui/server_playwright.js.map +1 -0
- package/dist/src/react/index.d.ts +5 -7
- package/dist/src/react/index.d.ts.map +1 -1
- package/dist/src/react/index.js +5 -7
- package/dist/src/react/index.js.map +1 -1
- package/dist/src/react/markdown.d.ts +1 -6
- package/dist/src/react/markdown.d.ts.map +1 -1
- package/dist/src/react/markdown.js +1 -6
- package/dist/src/react/markdown.js.map +1 -1
- package/dist/src/react/media.d.ts +1 -17
- package/dist/src/react/media.d.ts.map +1 -1
- package/dist/src/react/media.js +1 -17
- package/dist/src/react/media.js.map +1 -1
- package/dist/src/refusal.d.ts +3 -0
- package/dist/src/refusal.d.ts.map +1 -0
- package/dist/src/refusal.js +3 -0
- package/dist/src/refusal.js.map +1 -0
- package/dist/src/spi/action-proposal-outcome-store.d.ts +43 -0
- package/dist/src/spi/action-proposal-outcome-store.d.ts.map +1 -0
- package/dist/src/spi/action-proposal-outcome-store.js +2 -0
- package/dist/src/spi/action-proposal-outcome-store.js.map +1 -0
- package/dist/src/spi/action-proposal-store.d.ts +152 -0
- package/dist/src/spi/action-proposal-store.d.ts.map +1 -0
- package/dist/src/spi/action-proposal-store.js +2 -0
- package/dist/src/spi/action-proposal-store.js.map +1 -0
- package/dist/src/spi/action-proposal-worker-store.d.ts +17 -0
- package/dist/src/spi/action-proposal-worker-store.d.ts.map +1 -0
- package/dist/src/spi/action-proposal-worker-store.js +2 -0
- package/dist/src/spi/action-proposal-worker-store.js.map +1 -0
- package/dist/src/spi/agent-runner.d.ts +6 -0
- package/dist/src/spi/agent-runner.d.ts.map +1 -1
- package/dist/src/spi/agent-store.d.ts +5 -0
- package/dist/src/spi/agent-store.d.ts.map +1 -1
- package/dist/src/spi/agent-store.js.map +1 -1
- package/dist/src/spi/approval-policy.d.ts +3 -0
- package/dist/src/spi/approval-policy.d.ts.map +1 -1
- package/dist/src/spi/approval-policy.js +8 -1
- package/dist/src/spi/approval-policy.js.map +1 -1
- package/dist/src/spi/background-actor-resolver.d.ts +9 -0
- package/dist/src/spi/background-actor-resolver.d.ts.map +1 -0
- package/dist/src/spi/background-actor-resolver.js +2 -0
- package/dist/src/spi/background-actor-resolver.js.map +1 -0
- package/dist/src/spi/chat-queue.d.ts +7 -1
- package/dist/src/spi/chat-queue.d.ts.map +1 -1
- package/dist/src/spi/chat-queue.js.map +1 -1
- package/dist/src/spi/protocol-adapter.d.ts +3 -3
- package/dist/src/spi/roles-policy.d.ts +7 -0
- package/dist/src/spi/roles-policy.d.ts.map +1 -1
- package/dist/src/spi/token-stream-sink.d.ts +9 -0
- package/dist/src/spi/token-stream-sink.d.ts.map +1 -1
- package/dist/src/spi/token-stream-sink.js.map +1 -1
- package/dist/src/spi/tool.d.ts +40 -3
- package/dist/src/spi/tool.d.ts.map +1 -1
- package/dist/src/sse.d.ts.map +1 -1
- package/dist/src/sse.js +6 -0
- package/dist/src/sse.js.map +1 -1
- package/dist/src/stores/lucid-action-proposal-store.d.ts +55 -0
- package/dist/src/stores/lucid-action-proposal-store.d.ts.map +1 -0
- package/dist/src/stores/lucid-action-proposal-store.js +465 -0
- package/dist/src/stores/lucid-action-proposal-store.js.map +1 -0
- package/dist/src/stores/lucid-schema.d.ts +8 -6
- package/dist/src/stores/lucid-schema.d.ts.map +1 -1
- package/dist/src/stores/lucid-schema.js +61 -6
- package/dist/src/stores/lucid-schema.js.map +1 -1
- package/dist/src/stores/lucid.d.ts +4 -2
- package/dist/src/stores/lucid.d.ts.map +1 -1
- package/dist/src/stores/lucid.js +46 -14
- package/dist/src/stores/lucid.js.map +1 -1
- package/dist/src/stores/sqlite-transactions.d.ts +8 -0
- package/dist/src/stores/sqlite-transactions.d.ts.map +1 -0
- package/dist/src/stores/sqlite-transactions.js +24 -0
- package/dist/src/stores/sqlite-transactions.js.map +1 -0
- package/dist/src/stream-events.d.ts +4 -0
- package/dist/src/stream-events.d.ts.map +1 -1
- package/dist/src/testing/chat-queue-store-contract.d.ts.map +1 -1
- package/dist/src/testing/chat-queue-store-contract.js +4 -0
- package/dist/src/testing/chat-queue-store-contract.js.map +1 -1
- package/dist/src/testing/in-memory-action-proposal-store.d.ts +32 -0
- package/dist/src/testing/in-memory-action-proposal-store.d.ts.map +1 -0
- package/dist/src/testing/in-memory-action-proposal-store.js +159 -0
- package/dist/src/testing/in-memory-action-proposal-store.js.map +1 -0
- package/dist/src/testing/in-memory-store.d.ts +9 -1
- package/dist/src/testing/in-memory-store.d.ts.map +1 -1
- package/dist/src/testing/in-memory-store.js +80 -1
- package/dist/src/testing/in-memory-store.js.map +1 -1
- package/dist/src/testing/index.d.ts +1 -0
- package/dist/src/testing/index.d.ts.map +1 -1
- package/dist/src/testing/index.js +1 -0
- package/dist/src/testing/index.js.map +1 -1
- package/dist/src/tool-discovery.d.ts +1 -1
- package/dist/src/tool-discovery.d.ts.map +1 -1
- package/dist/src/tool-discovery.js +12 -1
- package/dist/src/tool-discovery.js.map +1 -1
- package/dist/src/tool-registry.d.ts +28 -1
- package/dist/src/tool-registry.d.ts.map +1 -1
- package/dist/src/tool-registry.js +85 -3
- package/dist/src/tool-registry.js.map +1 -1
- package/dist/src/tool-result-presentation.d.ts +12 -0
- package/dist/src/tool-result-presentation.d.ts.map +1 -0
- package/dist/src/tool-result-presentation.js +44 -0
- package/dist/src/tool-result-presentation.js.map +1 -0
- package/dist/src/tool-retry.d.ts +0 -11
- package/dist/src/tool-retry.d.ts.map +1 -1
- package/dist/src/tool-retry.js +5 -1
- package/dist/src/tool-retry.js.map +1 -1
- package/dist/src/tool-ui.d.ts +4 -1
- package/dist/src/tool-ui.d.ts.map +1 -1
- package/dist/src/tool-ui.js +32 -4
- package/dist/src/tool-ui.js.map +1 -1
- package/dist/src/types.d.ts +48 -2
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/ui-capabilities.d.ts +2 -0
- package/dist/src/ui-capabilities.d.ts.map +1 -0
- package/dist/src/ui-capabilities.js +4 -0
- package/dist/src/ui-capabilities.js.map +1 -0
- package/dist/stubs/database/migrations/add_action_proposal_discovery.stub +24 -0
- package/dist/stubs/database/migrations/add_action_proposal_runtime.stub +19 -0
- package/dist/stubs/database/migrations/create_agent_tables.stub +3 -3
- package/package.json +123 -22
- package/skills/agent-governance/SKILL.md +12 -4
- package/skills/agent-personas-agents/SKILL.md +2 -1
- package/skills/agent-setup/SKILL.md +36 -13
- package/skills/agent-testing/SKILL.md +22 -0
- package/skills/agent-tools/SKILL.md +54 -9
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { normalizeAgentPath } from '../client.js';
|
|
2
|
+
import { readErrorResponse, reportHttpError, } from '../http-error.js';
|
|
3
|
+
import { streamChunks } from './tus.js';
|
|
4
|
+
/**
|
|
5
|
+
* Resumable attachment uploads through `@adonis-agora/media`, in one line:
|
|
6
|
+
*
|
|
7
|
+
* ```tsx
|
|
8
|
+
* <AgentProvider attachments={{ upload: mediaAttachments() }}>
|
|
9
|
+
* ```
|
|
10
|
+
*
|
|
11
|
+
* Reuses the client's own connection (origin, path, headers, credentials), so it needs no
|
|
12
|
+
* configuration. Also takes `new AgentClient({ attachments: { upload: mediaAttachments() } })`.
|
|
13
|
+
*/
|
|
14
|
+
export function mediaAttachments(options = {}) {
|
|
15
|
+
return (file, uploadOptions, connection) => createMediaUpload({
|
|
16
|
+
...options,
|
|
17
|
+
baseUrl: connection.baseUrl,
|
|
18
|
+
path: connection.path,
|
|
19
|
+
getHeaders: connection.headers,
|
|
20
|
+
fetch: connection.fetch,
|
|
21
|
+
...(connection.credentials !== undefined ? { credentials: connection.credentials } : {}),
|
|
22
|
+
...(connection.onHttpError !== undefined ? { onHttpError: connection.onHttpError } : {}),
|
|
23
|
+
})(file, uploadOptions);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* A non-2xx answer from the agent's upload routes. Carries what `AgentHttpError` does — `status`
|
|
27
|
+
* (413 too large, 415 type refused, 404 not yours), the server's `message`, `code` and `body` —
|
|
28
|
+
* as its own class because this subpath is bundled apart from the root entry, where an
|
|
29
|
+
* `instanceof AgentHttpError` would not match a copy. Both satisfy `AgentRequestError`.
|
|
30
|
+
*/
|
|
31
|
+
export class MediaUploadError extends Error {
|
|
32
|
+
status;
|
|
33
|
+
method;
|
|
34
|
+
path;
|
|
35
|
+
body;
|
|
36
|
+
code;
|
|
37
|
+
constructor(status, method, path, statusText, answer = { body: undefined, message: undefined, code: undefined }) {
|
|
38
|
+
super(answer.message ?? `Attachment upload failed: ${method} ${path} → ${status} ${statusText}`);
|
|
39
|
+
this.status = status;
|
|
40
|
+
this.method = method;
|
|
41
|
+
this.path = path;
|
|
42
|
+
this.name = 'MediaUploadError';
|
|
43
|
+
this.body = answer.body;
|
|
44
|
+
this.code = answer.code;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* A resumable `upload` for `useAttachments`, backed by `@adonis-agora/media` on the server
|
|
49
|
+
* (`MediaAttachmentStaging` from `@adonis-agora/agent/media`):
|
|
50
|
+
*
|
|
51
|
+
* 1. `POST <path>/attachments/uploads` — the agent validates the file and opens a tus session the
|
|
52
|
+
* actor owns;
|
|
53
|
+
* 2. the bytes stream to the media adapter’s own tus endpoint in chunks (`streamChunks`), reporting
|
|
54
|
+
* progress and honouring the abort signal;
|
|
55
|
+
* 3. `POST <path>/attachments/uploads/:mediaId/complete` — the agent confirms the bytes landed and
|
|
56
|
+
* answers the `MessageAttachment` the turn will reference by `mediaId`.
|
|
57
|
+
*
|
|
58
|
+
* An aborted or failed upload is discarded server-side (`DELETE`), best effort.
|
|
59
|
+
*/
|
|
60
|
+
export function createMediaUpload(options = {}) {
|
|
61
|
+
const origin = (options.baseUrl ?? '').replace(/\/$/, '');
|
|
62
|
+
const base = `${origin}${normalizeAgentPath(options.path)}/attachments/uploads`;
|
|
63
|
+
const baseFetch = () => options.fetch ?? fetch;
|
|
64
|
+
// Every request — the agent's and media's tus PATCHes — rides the same credentials mode.
|
|
65
|
+
const fetchWithCredentials = (input, init) => baseFetch()(input, {
|
|
66
|
+
...init,
|
|
67
|
+
...(options.credentials !== undefined ? { credentials: options.credentials } : {}),
|
|
68
|
+
});
|
|
69
|
+
const headers = async () => ({
|
|
70
|
+
...options.headers,
|
|
71
|
+
...((await options.getHeaders?.()) ?? {}),
|
|
72
|
+
});
|
|
73
|
+
const discard = (mediaId) => {
|
|
74
|
+
void (async () => {
|
|
75
|
+
await fetchWithCredentials(`${base}/${encodeURIComponent(mediaId)}`, {
|
|
76
|
+
method: 'DELETE',
|
|
77
|
+
headers: await headers(),
|
|
78
|
+
});
|
|
79
|
+
})().catch(() => undefined);
|
|
80
|
+
};
|
|
81
|
+
const call = async (method, url, body) => {
|
|
82
|
+
const response = await fetchWithCredentials(url, {
|
|
83
|
+
method,
|
|
84
|
+
headers: {
|
|
85
|
+
accept: 'application/json',
|
|
86
|
+
...(body !== undefined ? { 'content-type': 'application/json' } : {}),
|
|
87
|
+
...(await headers()),
|
|
88
|
+
},
|
|
89
|
+
...(body !== undefined ? { body: JSON.stringify(body) } : {}),
|
|
90
|
+
});
|
|
91
|
+
if (!response.ok) {
|
|
92
|
+
const error = new MediaUploadError(response.status, method, url, response.statusText, await readErrorResponse(response));
|
|
93
|
+
reportHttpError(options.onHttpError, error);
|
|
94
|
+
throw error;
|
|
95
|
+
}
|
|
96
|
+
return (await response.json());
|
|
97
|
+
};
|
|
98
|
+
return async (file, { signal, onProgress } = {}) => {
|
|
99
|
+
signal?.throwIfAborted();
|
|
100
|
+
const begun = await call('POST', base, {
|
|
101
|
+
filename: file.name,
|
|
102
|
+
contentType: file.type,
|
|
103
|
+
size: file.size,
|
|
104
|
+
});
|
|
105
|
+
const onAbort = () => discard(begun.mediaId);
|
|
106
|
+
signal?.addEventListener('abort', onAbort, { once: true });
|
|
107
|
+
try {
|
|
108
|
+
const location = /^https?:\/\//.test(begun.location)
|
|
109
|
+
? begun.location
|
|
110
|
+
: `${origin}${begun.location}`;
|
|
111
|
+
await streamChunks(location, file, {
|
|
112
|
+
resume: false,
|
|
113
|
+
fetchImpl: fetchWithCredentials,
|
|
114
|
+
getHeaders: headers,
|
|
115
|
+
...(options.chunkSize !== undefined ? { chunkSize: options.chunkSize } : {}),
|
|
116
|
+
...(options.retries !== undefined ? { retries: options.retries } : {}),
|
|
117
|
+
...(signal !== undefined ? { signal } : {}),
|
|
118
|
+
onProgress: (sent, total) => onProgress?.(total > 0 ? sent / total : 1),
|
|
119
|
+
});
|
|
120
|
+
signal?.throwIfAborted();
|
|
121
|
+
const attachment = await call('POST', `${base}/${encodeURIComponent(begun.mediaId)}/complete`);
|
|
122
|
+
onProgress?.(1);
|
|
123
|
+
return attachment;
|
|
124
|
+
}
|
|
125
|
+
catch (error) {
|
|
126
|
+
if (!signal?.aborted)
|
|
127
|
+
discard(begun.mediaId);
|
|
128
|
+
throw error;
|
|
129
|
+
}
|
|
130
|
+
finally {
|
|
131
|
+
signal?.removeEventListener('abort', onAbort);
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/react/core/media/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAA2B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B,MAAM,UAAU,GAAG,MAAM,IAAI,CAC3B,MAAM,EACN,GAAG,IAAI,IAAI,kBAAkB,CAAC,KAAK,CAAC,OAAO,CAAC,WAAW,CACxD,CAAC;YACF,UAAU,EAAE,CAAC,CAAC,CAAC,CAAC;YAChB,OAAO,UAAU,CAAC;QACpB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,MAAM,EAAE,OAAO;gBAAE,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YAC7C,MAAM,KAAK,CAAC;QACd,CAAC;gBAAS,CAAC;YACT,MAAM,EAAE,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAChD,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
interface StreamChunksOptions {
|
|
2
|
+
chunkSize?: number;
|
|
3
|
+
retries?: number;
|
|
4
|
+
resume?: boolean;
|
|
5
|
+
fetchImpl?: typeof fetch;
|
|
6
|
+
getHeaders?: () => Record<string, string> | Promise<Record<string, string>>;
|
|
7
|
+
signal?: AbortSignal;
|
|
8
|
+
onProgress?: (sent: number, total: number) => void;
|
|
9
|
+
}
|
|
10
|
+
/** Browser-only sequential tus uploads; connection headers refresh on every request. */
|
|
11
|
+
export declare function streamChunks(location: string, data: Blob, options?: StreamChunksOptions): Promise<void>;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=tus.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tus.d.ts","sourceRoot":"","sources":["../../../../../src/react/core/media/tus.ts"],"names":[],"mappings":"AAAA,UAAU,mBAAmB;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,OAAO,KAAK,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC5E,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACpD;AAED,wFAAwF;AACxF,wBAAsB,YAAY,CAChC,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,IAAI,EACV,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,IAAI,CAAC,CAwDf"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/** Browser-only sequential tus uploads; connection headers refresh on every request. */
|
|
2
|
+
export async function streamChunks(location, data, options = {}) {
|
|
3
|
+
const chunkSize = options.chunkSize ?? 5 * 1024 * 1024;
|
|
4
|
+
const retries = options.retries ?? 3;
|
|
5
|
+
if (!Number.isSafeInteger(chunkSize) || chunkSize < 1)
|
|
6
|
+
throw new RangeError('chunkSize must be a positive safe integer');
|
|
7
|
+
if (!Number.isSafeInteger(retries) || retries < 1 || retries > 20)
|
|
8
|
+
throw new RangeError('retries must be 1–20');
|
|
9
|
+
const fetchImpl = options.fetchImpl ?? fetch;
|
|
10
|
+
const headers = async () => ({ 'Tus-Resumable': '1.0.0', ...(await options.getHeaders?.()) });
|
|
11
|
+
let offset = 0;
|
|
12
|
+
options.signal?.throwIfAborted();
|
|
13
|
+
if (options.resume !== false) {
|
|
14
|
+
const response = await fetchImpl(location, {
|
|
15
|
+
method: 'HEAD',
|
|
16
|
+
headers: await headers(),
|
|
17
|
+
...(options.signal ? { signal: options.signal } : {}),
|
|
18
|
+
});
|
|
19
|
+
if (response.ok) {
|
|
20
|
+
const reported = Number(response.headers.get('Upload-Offset') ?? 0);
|
|
21
|
+
if (!Number.isSafeInteger(reported) || reported < 0 || reported > data.size)
|
|
22
|
+
throw new Error('Invalid tus Upload-Offset');
|
|
23
|
+
offset = reported;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
options.onProgress?.(offset, data.size);
|
|
27
|
+
while (offset < data.size) {
|
|
28
|
+
options.signal?.throwIfAborted();
|
|
29
|
+
const end = Math.min(offset + chunkSize, data.size);
|
|
30
|
+
for (let attempt = 0; attempt < retries; attempt++) {
|
|
31
|
+
try {
|
|
32
|
+
const response = await fetchImpl(location, {
|
|
33
|
+
method: 'PATCH',
|
|
34
|
+
headers: {
|
|
35
|
+
...(await headers()),
|
|
36
|
+
'Content-Type': 'application/offset+octet-stream',
|
|
37
|
+
'Upload-Offset': String(offset),
|
|
38
|
+
},
|
|
39
|
+
body: data.slice(offset, end),
|
|
40
|
+
...(options.signal ? { signal: options.signal } : {}),
|
|
41
|
+
});
|
|
42
|
+
if (!response.ok)
|
|
43
|
+
throw new Error(`Media upload PATCH failed at offset ${offset}: ${response.status} ${response.statusText}`);
|
|
44
|
+
const reported = Number(response.headers.get('Upload-Offset') ?? end);
|
|
45
|
+
if (!Number.isSafeInteger(reported) || reported <= offset || reported > data.size)
|
|
46
|
+
throw new Error('Invalid tus Upload-Offset');
|
|
47
|
+
offset = reported;
|
|
48
|
+
options.onProgress?.(offset, data.size);
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
options.signal?.throwIfAborted();
|
|
53
|
+
if (attempt === retries - 1)
|
|
54
|
+
throw error;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=tus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tus.js","sourceRoot":"","sources":["../../../../../src/react/core/media/tus.ts"],"names":[],"mappings":"AAUA,wFAAwF;AACxF,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,QAAgB,EAChB,IAAU,EACV,OAAO,GAAwB,EAAE;IAEjC,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,CAAC,GAAG,I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AAC,MAAM,CAAC,aAAa,CAAC,QAAQ,CAAC,IAAI,QAAQ,IAAI,MAAM,IAAI,QAAQ,GAAG,IAAI,CAAC,IAAI;oBAC/E,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;gBAC/C,MAAM,GAAG,QAAQ,CAAC;gBAClB,OAAO,CAAC,UAAU,EAAE,CAAC,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;gBACxC,MAAM;YACR,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO,CAAC,MAAM,EAAE,cAAc,EAAE,CAAC;gBACjC,IAAI,OAAO,KAAK,OAAO,GAAG,CAAC;oBAAE,MAAM,KAAK,CAAC;YAC3C,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ToolCatalogEntry, ToolPresentation } from '../../../index.js';
|
|
2
|
+
/** Tool name → how the server said it is spoken about. */
|
|
3
|
+
export type ToolCatalog = Record<string, ToolPresentation>;
|
|
4
|
+
/** Index `GET <base>/tools` by tool name, keeping only the tools that declared a presentation. */
|
|
5
|
+
export declare function toolCatalogFrom(entries: readonly ToolCatalogEntry[]): ToolCatalog;
|
|
6
|
+
/** Dotted-path read. `undefined` rather than a throw, so a template can outlive a field. */
|
|
7
|
+
export declare function readPath(value: unknown, path: string): unknown;
|
|
8
|
+
/**
|
|
9
|
+
* Fill `{dotted.path}` placeholders from `context`. A placeholder with nothing behind it collapses
|
|
10
|
+
* along with the whitespace in front of it, so "Reading {key}" degrades to "Reading" rather than
|
|
11
|
+
* printing braces at a person; a filled one keeps the whitespace the author wrote ("({n} files)").
|
|
12
|
+
*/
|
|
13
|
+
export declare function fillTemplate(template: string, context: unknown): string;
|
|
14
|
+
/**
|
|
15
|
+
* The sentence for one call: the presentation's `running` or `done` template over the call's input.
|
|
16
|
+
*
|
|
17
|
+
* Nothing here reads the tool's name. A tool the catalog does not describe — added since the catalog
|
|
18
|
+
* loaded, or declared without a presentation — is narrated generically (`fallback`), because the only
|
|
19
|
+
* other thing available to say is its identifier.
|
|
20
|
+
*/
|
|
21
|
+
export declare function phraseFor(presentation: ToolPresentation | undefined, input: unknown, isSettled: boolean, fallback?: {
|
|
22
|
+
running: string;
|
|
23
|
+
done: string;
|
|
24
|
+
}): string;
|
|
25
|
+
//# sourceMappingURL=phrasing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"phrasing.d.ts","sourceRoot":"","sources":["../../../../../src/react/core/presentation/phrasing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAE5E,0DAA0D;AAC1D,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;AAE3D,kGAAkG;AAClG,wBAAgB,eAAe,CAAC,OAAO,EAAE,SAAS,gBAAgB,EAAE,GAAG,WAAW,CAMjF;AAED,4FAA4F;AAC5F,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAK9D;AAUD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,MAAM,CAQvE;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CACvB,YAAY,EAAE,gBAAgB,GAAG,SAAS,EAC1C,KAAK,EAAE,OAAO,EACd,SAAS,EAAE,OAAO,EAClB,QAAQ,GAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAyC,GACjF,MAAM,CAMR"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/** Index `GET <base>/tools` by tool name, keeping only the tools that declared a presentation. */
|
|
2
|
+
export function toolCatalogFrom(entries) {
|
|
3
|
+
const catalog = {};
|
|
4
|
+
for (const entry of entries) {
|
|
5
|
+
if (entry.presentation !== undefined)
|
|
6
|
+
catalog[entry.name] = entry.presentation;
|
|
7
|
+
}
|
|
8
|
+
return catalog;
|
|
9
|
+
}
|
|
10
|
+
/** Dotted-path read. `undefined` rather than a throw, so a template can outlive a field. */
|
|
11
|
+
export function readPath(value, path) {
|
|
12
|
+
return path.split('.').reduce((current, key) => {
|
|
13
|
+
if (current === null || typeof current !== 'object')
|
|
14
|
+
return undefined;
|
|
15
|
+
return current[key];
|
|
16
|
+
}, value);
|
|
17
|
+
}
|
|
18
|
+
function renderValue(value) {
|
|
19
|
+
if (value === null || value === undefined)
|
|
20
|
+
return '';
|
|
21
|
+
if (typeof value === 'string')
|
|
22
|
+
return value;
|
|
23
|
+
if (typeof value === 'number' || typeof value === 'boolean')
|
|
24
|
+
return String(value);
|
|
25
|
+
if (Array.isArray(value))
|
|
26
|
+
return value.map(renderValue).filter(Boolean).join(', ');
|
|
27
|
+
return '';
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Fill `{dotted.path}` placeholders from `context`. A placeholder with nothing behind it collapses
|
|
31
|
+
* along with the whitespace in front of it, so "Reading {key}" degrades to "Reading" rather than
|
|
32
|
+
* printing braces at a person; a filled one keeps the whitespace the author wrote ("({n} files)").
|
|
33
|
+
*/
|
|
34
|
+
export function fillTemplate(template, context) {
|
|
35
|
+
return template
|
|
36
|
+
.replace(/(\s*)\{([\w.]+)\}/g, (_match, space, path) => {
|
|
37
|
+
const rendered = renderValue(readPath(context, path));
|
|
38
|
+
return rendered === '' ? '' : `${space}${rendered}`;
|
|
39
|
+
})
|
|
40
|
+
.replace(/\s{2,}/g, ' ')
|
|
41
|
+
.trim();
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* The sentence for one call: the presentation's `running` or `done` template over the call's input.
|
|
45
|
+
*
|
|
46
|
+
* Nothing here reads the tool's name. A tool the catalog does not describe — added since the catalog
|
|
47
|
+
* loaded, or declared without a presentation — is narrated generically (`fallback`), because the only
|
|
48
|
+
* other thing available to say is its identifier.
|
|
49
|
+
*/
|
|
50
|
+
export function phraseFor(presentation, input, isSettled, fallback = { running: 'Working', done: 'Done' }) {
|
|
51
|
+
if (presentation === undefined)
|
|
52
|
+
return isSettled ? fallback.done : fallback.running;
|
|
53
|
+
const filled = fillTemplate(isSettled ? presentation.done : presentation.running, input);
|
|
54
|
+
// A sentence made only of slots, called before those fields have streamed, leaves nothing. The
|
|
55
|
+
// label is still the server's word for this tool, and a blank line reads as nothing happening.
|
|
56
|
+
return filled === '' ? presentation.label : filled;
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=phrasing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"phrasing.js","sourceRoot":"","sources":["../../../../../src/react/core/presentation/phrasing.ts"],"names":[],"mappings":"AAKA,kGAAkG;AAClG,MAAM,UAAU,eAAe,CAAC,OAAoC;IAClE,MAAM,OAAO,GAAgB,EAAE,CAAC;IAChC,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;QAC5B,IAAI,KAAK,CAAC,YAAY,KAAK,SAAS;YAAE,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,YAAY,CAAC;IACjF,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,4FAA4F;AAC5F,MAAM,UAAU,QAAQ,CAAC,KAAc,EAAE,IAAY;IACnD,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAU,CAAC,OAAO,EAAE,GAAG,EAAE,EAAE;QACtD,IAAI,OAAO,KAAK,IAAI,IAAI,OAAO,OAAO,KAAK,QAAQ;YAAE,OAAO,SAAS,CAAC;QACtE,OAAQ,OAAmC,CAAC,GAAG,CAAC,CAAC;IACnD,CAAC,EAAE,KAAK,CAAC,CAAC;AACZ,CAAC;AAED,SAAS,WAAW,CAAC,KAAc;IACjC,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS;QAA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CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IACzF,+FAA+F;IAC/F,+FAA+F;IAC/F,OAAO,MAAM,KAAK,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC;AACrD,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { ToolResultField, ToolResultView } from '../../../index.js';
|
|
2
|
+
/** One labelled reading of a `metrics` view. */
|
|
3
|
+
export interface ResolvedReading {
|
|
4
|
+
label: string;
|
|
5
|
+
/** The value as text (`—` for nothing). */
|
|
6
|
+
value: string;
|
|
7
|
+
unit: string | null;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* A tool's output resolved through its view into plain data a renderer draws — never the payload
|
|
11
|
+
* itself. `null` from {@link resolveResultView} means "draw nothing".
|
|
12
|
+
*/
|
|
13
|
+
export type ResolvedResultView = {
|
|
14
|
+
kind: 'metrics';
|
|
15
|
+
readings: ResolvedReading[];
|
|
16
|
+
} | {
|
|
17
|
+
kind: 'table';
|
|
18
|
+
columns: ToolResultField[];
|
|
19
|
+
rows: string[][];
|
|
20
|
+
empty: string | null;
|
|
21
|
+
} | {
|
|
22
|
+
kind: 'log';
|
|
23
|
+
lines: string[];
|
|
24
|
+
} | {
|
|
25
|
+
kind: 'note';
|
|
26
|
+
text: string;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* A view for an output whose tool declared none, from its shape: an array of flat records is a
|
|
30
|
+
* table, an array of strings a log, a flat record a set of readings. `undefined` when nothing fits —
|
|
31
|
+
* a serialized payload is what a person-facing surface exists to avoid, so failing to infer must not
|
|
32
|
+
* fall back to one.
|
|
33
|
+
*/
|
|
34
|
+
export declare function inferResultView(output: unknown): ToolResultView | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* Read `output` through `view` (or one inferred from its shape when `view` is omitted and `infer` is
|
|
37
|
+
* on). `null` when there is nothing to draw: an `elsewhere` view, an empty reading set, a missing
|
|
38
|
+
* array. A table whose rows array is present but empty resolves with no rows and its `empty` line.
|
|
39
|
+
*/
|
|
40
|
+
export declare function resolveResultView(output: unknown, view: ToolResultView | undefined, options?: {
|
|
41
|
+
infer?: boolean;
|
|
42
|
+
}): ResolvedResultView | null;
|
|
43
|
+
//# sourceMappingURL=result-view.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"result-view.d.ts","sourceRoot":"","sources":["../../../../../src/react/core/presentation/result-view.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAGzE,gDAAgD;AAChD,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,2CAA2C;IAC3C,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CACrB;AAED;;;GAGG;AACH,MAAM,MAAM,kBAAkB,GAC1B;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,QAAQ,EAAE,eAAe,EAAE,CAAA;CAAE,GAChD;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,eAAe,EAAE,CAAC;IAAC,IAAI,EAAE,MAAM,EAAE,EAAE,CAAC;IAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,GACrF;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,EAAE,CAAA;CAAE,GAChC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAenC;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,OAAO,GAAG,cAAc,GAAG,SAAS,CAsB3E;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,OAAO,EACf,IAAI,EAAE,cAAc,GAAG,SAAS,EAChC,OAAO,GAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAA;CAAO,GAChC,kBAAkB,GAAG,IAAI,CAqC3B"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { fillTemplate, readPath } from './phrasing.js';
|
|
2
|
+
function isRecord(value) {
|
|
3
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
4
|
+
}
|
|
5
|
+
function toText(value) {
|
|
6
|
+
if (value === null || value === undefined)
|
|
7
|
+
return '—';
|
|
8
|
+
if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
|
|
9
|
+
return String(value);
|
|
10
|
+
}
|
|
11
|
+
if (Array.isArray(value))
|
|
12
|
+
return value.map(toText).join(', ');
|
|
13
|
+
return '—';
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* A view for an output whose tool declared none, from its shape: an array of flat records is a
|
|
17
|
+
* table, an array of strings a log, a flat record a set of readings. `undefined` when nothing fits —
|
|
18
|
+
* a serialized payload is what a person-facing surface exists to avoid, so failing to infer must not
|
|
19
|
+
* fall back to one.
|
|
20
|
+
*/
|
|
21
|
+
export function inferResultView(output) {
|
|
22
|
+
if (!isRecord(output))
|
|
23
|
+
return undefined;
|
|
24
|
+
for (const [key, value] of Object.entries(output)) {
|
|
25
|
+
if (!Array.isArray(value) || value.length === 0)
|
|
26
|
+
continue;
|
|
27
|
+
if (value.every((entry) => typeof entry === 'string')) {
|
|
28
|
+
return { kind: 'log', lines: key };
|
|
29
|
+
}
|
|
30
|
+
if (value.every(isRecord)) {
|
|
31
|
+
const first = value[0];
|
|
32
|
+
return {
|
|
33
|
+
kind: 'table',
|
|
34
|
+
rows: key,
|
|
35
|
+
columns: Object.keys(first)
|
|
36
|
+
.filter((column) => !isRecord(first[column]))
|
|
37
|
+
.map((column) => ({ path: column, label: column })),
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
const fields = Object.entries(output)
|
|
42
|
+
.filter(([, value]) => ['string', 'number', 'boolean'].includes(typeof value))
|
|
43
|
+
.map(([key]) => ({ path: key, label: key }));
|
|
44
|
+
return fields.length > 0 ? { kind: 'metrics', fields } : undefined;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Read `output` through `view` (or one inferred from its shape when `view` is omitted and `infer` is
|
|
48
|
+
* on). `null` when there is nothing to draw: an `elsewhere` view, an empty reading set, a missing
|
|
49
|
+
* array. A table whose rows array is present but empty resolves with no rows and its `empty` line.
|
|
50
|
+
*/
|
|
51
|
+
export function resolveResultView(output, view, options = {}) {
|
|
52
|
+
const resolved = view ?? (options.infer === true ? inferResultView(output) : undefined);
|
|
53
|
+
if (resolved === undefined || resolved.kind === 'elsewhere')
|
|
54
|
+
return null;
|
|
55
|
+
switch (resolved.kind) {
|
|
56
|
+
case 'note': {
|
|
57
|
+
const text = fillTemplate(resolved.text, output);
|
|
58
|
+
return text === '' ? null : { kind: 'note', text };
|
|
59
|
+
}
|
|
60
|
+
case 'metrics': {
|
|
61
|
+
const readings = resolved.fields
|
|
62
|
+
.map((field) => ({ field, value: readPath(output, field.path) }))
|
|
63
|
+
.filter((entry) => entry.value !== undefined && entry.value !== null)
|
|
64
|
+
.map(({ field, value }) => ({
|
|
65
|
+
label: field.label,
|
|
66
|
+
value: toText(value),
|
|
67
|
+
unit: field.unit ?? null,
|
|
68
|
+
}));
|
|
69
|
+
return readings.length === 0 ? null : { kind: 'metrics', readings };
|
|
70
|
+
}
|
|
71
|
+
case 'log': {
|
|
72
|
+
const lines = readPath(output, resolved.lines);
|
|
73
|
+
if (!Array.isArray(lines) || lines.length === 0)
|
|
74
|
+
return null;
|
|
75
|
+
return { kind: 'log', lines: lines.map(toText) };
|
|
76
|
+
}
|
|
77
|
+
case 'table': {
|
|
78
|
+
const rows = readPath(output, resolved.rows);
|
|
79
|
+
if (!Array.isArray(rows))
|
|
80
|
+
return null;
|
|
81
|
+
return {
|
|
82
|
+
kind: 'table',
|
|
83
|
+
columns: resolved.columns,
|
|
84
|
+
rows: rows.map((row) => resolved.columns.map((column) => toText(readPath(row, column.path)))),
|
|
85
|
+
empty: rows.length === 0 ? (resolved.empty ?? null) : null,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=result-view.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"result-view.js","sourceRoot":"","sources":["../../../../../src/react/core/presentation/result-view.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAoBvD,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC;AAED,SAAS,MAAM,CAAC,KAAc;IAC5B,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,GAAG,CAAC;IACtD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,SAAS,EAAE,CAAC;QACzF,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;IACD,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC9D,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAAC,MAAe;IAC7C,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,SAAS,CAAC;IACxC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QAClD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,KAAK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CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC;QACtE,CAAC;QACD,KAAK,KAAK,EAAE,CAAC;YACX,MAAM,KAAK,GAAG,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC;YAC/C,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;gBAAE,OAAO,IAAI,CAAC;YAC7D,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC;QACnD,CAAC;QACD,KAAK,OAAO,EAAE,CAAC;YACb,MAAM,IAAI,GAAG,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;YAC7C,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;gBAAE,OAAO,IAAI,CAAC;YACtC,OAAO;gBACL,IAAI,EAAE,OAAO;gBACb,OAAO,EAAE,QAAQ,CAAC,OAAO;gBACzB,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CACrB,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CACrE;gBACD,KAAK,EAAE,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI;aAC3D,CAAC;QACJ,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import type { ToolConfirmation, ToolPresentation, ToolPresentationTone } from '../../../index.js';
|
|
2
|
+
import type { AnyToolUIPart, TranscriptToolCall } from '../transcript/model.js';
|
|
3
|
+
import { type ToolCatalog } from './phrasing.js';
|
|
4
|
+
import { type ResolvedResultView } from './result-view.js';
|
|
5
|
+
/**
|
|
6
|
+
* Where one call stands, as a person reads it:
|
|
7
|
+
* - `running` — input streaming or the tool executing;
|
|
8
|
+
* - `awaiting-approval` — an `action` call parked on a person;
|
|
9
|
+
* - `done` / `failed` / `denied` — settled. A tool that RETURNS `{ error }` has failed just as much
|
|
10
|
+
* as one that threw; the two arrive differently and read the same to a person.
|
|
11
|
+
*/
|
|
12
|
+
export type ToolCallStatus = 'running' | 'awaiting-approval' | 'done' | 'failed' | 'denied' | 'queued' | 'executing' | 'succeeded';
|
|
13
|
+
export interface ToolCallState {
|
|
14
|
+
status: ToolCallStatus;
|
|
15
|
+
isSettled: boolean;
|
|
16
|
+
isFailed: boolean;
|
|
17
|
+
isDenied: boolean;
|
|
18
|
+
output: unknown;
|
|
19
|
+
error: string | null;
|
|
20
|
+
}
|
|
21
|
+
/** Whether the stream classified this call as an `action` (it parks for approval before it runs). */
|
|
22
|
+
export declare function isActionCall(part: AnyToolUIPart): boolean;
|
|
23
|
+
export declare function toolCallState(part: AnyToolUIPart): ToolCallState;
|
|
24
|
+
/**
|
|
25
|
+
* Which failed calls the model went on to correct, by call id: a call that failed and was followed,
|
|
26
|
+
* in the same run, by a SUCCESS of the same tool. The operator wants to know a retry happened, not
|
|
27
|
+
* to read every attempt. A failed read is not corrected by a successful query.
|
|
28
|
+
*/
|
|
29
|
+
export declare function correctedCallIds(parts: readonly AnyToolUIPart[]): Set<string>;
|
|
30
|
+
/** Everything a surface needs to talk about one call without naming it. */
|
|
31
|
+
export interface ToolCallDescription {
|
|
32
|
+
status: ToolCallStatus;
|
|
33
|
+
/** "Querying orders" / "Queried orders" — or the generic fallback when the tool declared nothing. */
|
|
34
|
+
phrase: string;
|
|
35
|
+
/** The server's noun phrase for the tool; `null` when it declared no presentation. */
|
|
36
|
+
label: string | null;
|
|
37
|
+
icon: string | null;
|
|
38
|
+
tone: ToolPresentationTone;
|
|
39
|
+
detail: string | null;
|
|
40
|
+
/** The approval prompt, templated over the call's input; `null` when the tool declared none. */
|
|
41
|
+
confirm: {
|
|
42
|
+
title: string;
|
|
43
|
+
verb: string;
|
|
44
|
+
detail: string | null;
|
|
45
|
+
} | null;
|
|
46
|
+
/** The output read through its view, once the call is `done`; `null` otherwise or when nothing to draw. */
|
|
47
|
+
result: ResolvedResultView | null;
|
|
48
|
+
error: string | null;
|
|
49
|
+
presentation: ToolPresentation | null;
|
|
50
|
+
}
|
|
51
|
+
export interface DescribeToolCallOptions {
|
|
52
|
+
/** Resolved strings from the call preflight override the tool catalog templates. */
|
|
53
|
+
confirmation?: ToolConfirmation;
|
|
54
|
+
/** Words for a tool the catalog does not describe. Default `Working` / `Done`. */
|
|
55
|
+
fallback?: {
|
|
56
|
+
running: string;
|
|
57
|
+
done: string;
|
|
58
|
+
};
|
|
59
|
+
/** Infer a result view from the output's shape when the tool declared none. Default `false`. */
|
|
60
|
+
inferResult?: boolean;
|
|
61
|
+
}
|
|
62
|
+
export declare function describeToolCall(part: AnyToolUIPart, catalog: ToolCatalog | undefined, options?: DescribeToolCallOptions): ToolCallDescription;
|
|
63
|
+
/**
|
|
64
|
+
* Calls folded under one key — "Database query ×3" — with the state that matters most across them.
|
|
65
|
+
*/
|
|
66
|
+
export interface ToolActivityGroup {
|
|
67
|
+
key: string;
|
|
68
|
+
/** The server's label for the group's tool; `null` when it declared no presentation. */
|
|
69
|
+
label: string | null;
|
|
70
|
+
icon: string | null;
|
|
71
|
+
/** Worst-first across the calls: running › awaiting-approval › failed › denied › done. */
|
|
72
|
+
status: ToolCallStatus;
|
|
73
|
+
count: number;
|
|
74
|
+
/** The phrase of the group's LATEST call — what is happening now. */
|
|
75
|
+
phrase: string;
|
|
76
|
+
calls: TranscriptToolCall[];
|
|
77
|
+
/** Calls nested under the group's calls (all depths), when nesting was not expanded. */
|
|
78
|
+
innerCount: number;
|
|
79
|
+
}
|
|
80
|
+
export interface GroupToolActivityOptions {
|
|
81
|
+
catalog?: ToolCatalog;
|
|
82
|
+
/**
|
|
83
|
+
* What makes two calls "the same activity". Default: the tool's presentation `label`, else its
|
|
84
|
+
* name. Flippy-style source grouping passes its own (e.g. `github:search`).
|
|
85
|
+
*/
|
|
86
|
+
keyOf?: (call: TranscriptToolCall, presentation: ToolPresentation | undefined) => string;
|
|
87
|
+
/**
|
|
88
|
+
* Replace a call that has nested calls with those calls (recursively), so the activity reads as
|
|
89
|
+
* what the code-mode run DID rather than "ran code". Default `false`: groups are built over the
|
|
90
|
+
* top-level calls, and `innerCount` says how much ran beneath them.
|
|
91
|
+
*/
|
|
92
|
+
expandNested?: boolean;
|
|
93
|
+
/** Drop failed calls the model corrected with a later success of the same tool. Default `false`. */
|
|
94
|
+
hideCorrected?: boolean;
|
|
95
|
+
fallback?: {
|
|
96
|
+
running: string;
|
|
97
|
+
done: string;
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Fold a tool run into activity groups, in order of first appearance. Pass `block.roots` (the
|
|
102
|
+
* transcript's call tree) so nesting is honoured; a flat `block.calls` works too and simply has
|
|
103
|
+
* nothing nested.
|
|
104
|
+
*/
|
|
105
|
+
export declare function groupToolActivity(calls: readonly TranscriptToolCall[], options?: GroupToolActivityOptions): ToolActivityGroup[];
|
|
106
|
+
//# sourceMappingURL=tool-activity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-activity.d.ts","sourceRoot":"","sources":["../../../../../src/react/core/presentation/tool-activity.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAClG,OAAO,KAAK,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAChF,OAAO,EAA2B,KAAK,WAAW,EAAE,MAAM,eAAe,CAAC;AAC1E,OAAO,EAAE,KAAK,kBAA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