shotgun-sh 0.3.3.dev1__py3-none-any.whl → 0.6.2__py3-none-any.whl
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.
- shotgun/agents/agent_manager.py +497 -30
- shotgun/agents/cancellation.py +103 -0
- shotgun/agents/common.py +90 -77
- shotgun/agents/config/README.md +0 -1
- shotgun/agents/config/manager.py +52 -8
- shotgun/agents/config/models.py +21 -27
- shotgun/agents/config/provider.py +44 -27
- shotgun/agents/conversation/history/file_content_deduplication.py +66 -43
- shotgun/agents/conversation/history/token_counting/base.py +51 -9
- shotgun/agents/export.py +12 -13
- shotgun/agents/file_read.py +176 -0
- shotgun/agents/messages.py +15 -3
- shotgun/agents/models.py +90 -2
- shotgun/agents/plan.py +12 -13
- shotgun/agents/research.py +13 -10
- shotgun/agents/router/__init__.py +47 -0
- shotgun/agents/router/models.py +384 -0
- shotgun/agents/router/router.py +185 -0
- shotgun/agents/router/tools/__init__.py +18 -0
- shotgun/agents/router/tools/delegation_tools.py +557 -0
- shotgun/agents/router/tools/plan_tools.py +403 -0
- shotgun/agents/runner.py +17 -2
- shotgun/agents/specify.py +12 -13
- shotgun/agents/tasks.py +12 -13
- shotgun/agents/tools/__init__.py +8 -0
- shotgun/agents/tools/codebase/directory_lister.py +27 -39
- shotgun/agents/tools/codebase/file_read.py +26 -35
- shotgun/agents/tools/codebase/query_graph.py +9 -0
- shotgun/agents/tools/codebase/retrieve_code.py +9 -0
- shotgun/agents/tools/file_management.py +81 -3
- shotgun/agents/tools/file_read_tools/__init__.py +7 -0
- shotgun/agents/tools/file_read_tools/multimodal_file_read.py +167 -0
- shotgun/agents/tools/markdown_tools/__init__.py +62 -0
- shotgun/agents/tools/markdown_tools/insert_section.py +148 -0
- shotgun/agents/tools/markdown_tools/models.py +86 -0
- shotgun/agents/tools/markdown_tools/remove_section.py +114 -0
- shotgun/agents/tools/markdown_tools/replace_section.py +119 -0
- shotgun/agents/tools/markdown_tools/utils.py +453 -0
- shotgun/agents/tools/registry.py +46 -6
- shotgun/agents/tools/web_search/__init__.py +1 -2
- shotgun/agents/tools/web_search/gemini.py +1 -3
- shotgun/agents/tools/web_search/openai.py +42 -23
- shotgun/attachments/__init__.py +41 -0
- shotgun/attachments/errors.py +60 -0
- shotgun/attachments/models.py +107 -0
- shotgun/attachments/parser.py +257 -0
- shotgun/attachments/processor.py +193 -0
- shotgun/build_constants.py +4 -7
- shotgun/cli/clear.py +2 -2
- shotgun/cli/codebase/commands.py +181 -65
- shotgun/cli/compact.py +2 -2
- shotgun/cli/context.py +2 -2
- shotgun/cli/error_handler.py +2 -2
- shotgun/cli/run.py +90 -0
- shotgun/cli/spec/backup.py +2 -1
- shotgun/codebase/__init__.py +2 -0
- shotgun/codebase/benchmarks/__init__.py +35 -0
- shotgun/codebase/benchmarks/benchmark_runner.py +309 -0
- shotgun/codebase/benchmarks/exporters.py +119 -0
- shotgun/codebase/benchmarks/formatters/__init__.py +49 -0
- shotgun/codebase/benchmarks/formatters/base.py +34 -0
- shotgun/codebase/benchmarks/formatters/json_formatter.py +106 -0
- shotgun/codebase/benchmarks/formatters/markdown.py +136 -0
- shotgun/codebase/benchmarks/models.py +129 -0
- shotgun/codebase/core/__init__.py +4 -0
- shotgun/codebase/core/call_resolution.py +91 -0
- shotgun/codebase/core/change_detector.py +11 -6
- shotgun/codebase/core/errors.py +159 -0
- shotgun/codebase/core/extractors/__init__.py +23 -0
- shotgun/codebase/core/extractors/base.py +138 -0
- shotgun/codebase/core/extractors/factory.py +63 -0
- shotgun/codebase/core/extractors/go/__init__.py +7 -0
- shotgun/codebase/core/extractors/go/extractor.py +122 -0
- shotgun/codebase/core/extractors/javascript/__init__.py +7 -0
- shotgun/codebase/core/extractors/javascript/extractor.py +132 -0
- shotgun/codebase/core/extractors/protocol.py +109 -0
- shotgun/codebase/core/extractors/python/__init__.py +7 -0
- shotgun/codebase/core/extractors/python/extractor.py +141 -0
- shotgun/codebase/core/extractors/rust/__init__.py +7 -0
- shotgun/codebase/core/extractors/rust/extractor.py +139 -0
- shotgun/codebase/core/extractors/types.py +15 -0
- shotgun/codebase/core/extractors/typescript/__init__.py +7 -0
- shotgun/codebase/core/extractors/typescript/extractor.py +92 -0
- shotgun/codebase/core/gitignore.py +252 -0
- shotgun/codebase/core/ingestor.py +644 -354
- shotgun/codebase/core/kuzu_compat.py +119 -0
- shotgun/codebase/core/language_config.py +239 -0
- shotgun/codebase/core/manager.py +256 -46
- shotgun/codebase/core/metrics_collector.py +310 -0
- shotgun/codebase/core/metrics_types.py +347 -0
- shotgun/codebase/core/parallel_executor.py +424 -0
- shotgun/codebase/core/work_distributor.py +254 -0
- shotgun/codebase/core/worker.py +768 -0
- shotgun/codebase/indexing_state.py +86 -0
- shotgun/codebase/models.py +94 -0
- shotgun/codebase/service.py +13 -0
- shotgun/exceptions.py +9 -9
- shotgun/main.py +3 -16
- shotgun/posthog_telemetry.py +165 -24
- shotgun/prompts/agents/export.j2 +2 -0
- shotgun/prompts/agents/file_read.j2 +48 -0
- shotgun/prompts/agents/partials/common_agent_system_prompt.j2 +19 -52
- shotgun/prompts/agents/partials/content_formatting.j2 +12 -33
- shotgun/prompts/agents/partials/interactive_mode.j2 +9 -32
- shotgun/prompts/agents/partials/router_delegation_mode.j2 +35 -0
- shotgun/prompts/agents/plan.j2 +38 -12
- shotgun/prompts/agents/research.j2 +70 -31
- shotgun/prompts/agents/router.j2 +713 -0
- shotgun/prompts/agents/specify.j2 +53 -16
- shotgun/prompts/agents/state/codebase/codebase_graphs_available.j2 +14 -1
- shotgun/prompts/agents/state/system_state.j2 +24 -13
- shotgun/prompts/agents/tasks.j2 +72 -34
- shotgun/settings.py +49 -10
- shotgun/tui/app.py +154 -24
- shotgun/tui/commands/__init__.py +9 -1
- shotgun/tui/components/attachment_bar.py +87 -0
- shotgun/tui/components/mode_indicator.py +120 -25
- shotgun/tui/components/prompt_input.py +25 -28
- shotgun/tui/components/status_bar.py +14 -7
- shotgun/tui/dependencies.py +58 -8
- shotgun/tui/protocols.py +55 -0
- shotgun/tui/screens/chat/chat.tcss +24 -1
- shotgun/tui/screens/chat/chat_screen.py +1376 -213
- shotgun/tui/screens/chat/codebase_index_prompt_screen.py +8 -4
- shotgun/tui/screens/chat_screen/attachment_hint.py +40 -0
- shotgun/tui/screens/chat_screen/command_providers.py +0 -97
- shotgun/tui/screens/chat_screen/history/agent_response.py +7 -3
- shotgun/tui/screens/chat_screen/history/chat_history.py +58 -6
- shotgun/tui/screens/chat_screen/history/formatters.py +75 -15
- shotgun/tui/screens/chat_screen/history/partial_response.py +11 -1
- shotgun/tui/screens/chat_screen/history/user_question.py +25 -3
- shotgun/tui/screens/chat_screen/messages.py +219 -0
- shotgun/tui/screens/database_locked_dialog.py +219 -0
- shotgun/tui/screens/database_timeout_dialog.py +158 -0
- shotgun/tui/screens/kuzu_error_dialog.py +135 -0
- shotgun/tui/screens/model_picker.py +1 -3
- shotgun/tui/screens/models.py +11 -0
- shotgun/tui/state/processing_state.py +19 -0
- shotgun/tui/utils/mode_progress.py +20 -86
- shotgun/tui/widgets/__init__.py +2 -1
- shotgun/tui/widgets/approval_widget.py +152 -0
- shotgun/tui/widgets/cascade_confirmation_widget.py +203 -0
- shotgun/tui/widgets/plan_panel.py +129 -0
- shotgun/tui/widgets/step_checkpoint_widget.py +180 -0
- shotgun/tui/widgets/widget_coordinator.py +18 -0
- shotgun/utils/file_system_utils.py +4 -1
- {shotgun_sh-0.3.3.dev1.dist-info → shotgun_sh-0.6.2.dist-info}/METADATA +88 -35
- shotgun_sh-0.6.2.dist-info/RECORD +291 -0
- shotgun/cli/export.py +0 -81
- shotgun/cli/plan.py +0 -73
- shotgun/cli/research.py +0 -93
- shotgun/cli/specify.py +0 -70
- shotgun/cli/tasks.py +0 -78
- shotgun/sentry_telemetry.py +0 -232
- shotgun/tui/screens/onboarding.py +0 -580
- shotgun_sh-0.3.3.dev1.dist-info/RECORD +0 -229
- {shotgun_sh-0.3.3.dev1.dist-info → shotgun_sh-0.6.2.dist-info}/WHEEL +0 -0
- {shotgun_sh-0.3.3.dev1.dist-info → shotgun_sh-0.6.2.dist-info}/entry_points.txt +0 -0
- {shotgun_sh-0.3.3.dev1.dist-info → shotgun_sh-0.6.2.dist-info}/licenses/LICENSE +0 -0
shotgun/agents/messages.py
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
"""Custom message types for Shotgun agents.
|
|
2
2
|
|
|
3
|
-
This module defines specialized
|
|
4
|
-
between different types of
|
|
3
|
+
This module defines specialized message part subclasses to distinguish
|
|
4
|
+
between different types of prompts in the agent pipeline.
|
|
5
5
|
"""
|
|
6
6
|
|
|
7
7
|
from dataclasses import dataclass, field
|
|
8
|
+
from typing import Literal
|
|
8
9
|
|
|
9
|
-
from pydantic_ai.messages import SystemPromptPart
|
|
10
|
+
from pydantic_ai.messages import SystemPromptPart, UserPromptPart
|
|
10
11
|
|
|
11
12
|
from shotgun.agents.models import AgentType
|
|
12
13
|
|
|
@@ -33,3 +34,14 @@ class SystemStatusPrompt(SystemPromptPart):
|
|
|
33
34
|
"""
|
|
34
35
|
|
|
35
36
|
prompt_type: str = "status"
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
@dataclass
|
|
40
|
+
class InternalPromptPart(UserPromptPart):
|
|
41
|
+
"""User prompt that is system-generated rather than actual user input.
|
|
42
|
+
|
|
43
|
+
Used for internal continuation prompts like file resume messages.
|
|
44
|
+
These should be hidden from the UI but preserved in agent history for context.
|
|
45
|
+
"""
|
|
46
|
+
|
|
47
|
+
part_kind: Literal["internal-prompt"] = "internal-prompt" # type: ignore[assignment]
|
shotgun/agents/models.py
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"""Pydantic models for agent dependencies and configuration."""
|
|
2
2
|
|
|
3
3
|
import os
|
|
4
|
-
from asyncio import Future, Queue
|
|
4
|
+
from asyncio import Event, Future, Queue
|
|
5
5
|
from collections.abc import Callable
|
|
6
6
|
from datetime import datetime
|
|
7
7
|
from enum import StrEnum
|
|
8
8
|
from pathlib import Path
|
|
9
|
-
from typing import TYPE_CHECKING
|
|
9
|
+
from typing import TYPE_CHECKING, TypeAlias
|
|
10
10
|
|
|
11
11
|
from pydantic import BaseModel, ConfigDict, Field
|
|
12
12
|
from pydantic_ai import RunContext
|
|
@@ -16,9 +16,57 @@ from shotgun.agents.usage_manager import SessionUsageManager, get_session_usage_
|
|
|
16
16
|
from .config.models import ModelConfig
|
|
17
17
|
|
|
18
18
|
if TYPE_CHECKING:
|
|
19
|
+
from pydantic_ai import Agent
|
|
20
|
+
|
|
21
|
+
from shotgun.agents.router.models import RouterDeps
|
|
19
22
|
from shotgun.codebase.service import CodebaseService
|
|
20
23
|
|
|
21
24
|
|
|
25
|
+
class SubAgentContext(BaseModel):
|
|
26
|
+
"""
|
|
27
|
+
Context passed to sub-agents so they know they're being orchestrated.
|
|
28
|
+
|
|
29
|
+
When sub-agents receive this context, they should:
|
|
30
|
+
- Be more concise (router handles user communication)
|
|
31
|
+
- Focus on their specific task
|
|
32
|
+
- Return structured results
|
|
33
|
+
"""
|
|
34
|
+
|
|
35
|
+
is_router_delegated: bool = Field(
|
|
36
|
+
default=True, description="Always True when passed to sub-agent"
|
|
37
|
+
)
|
|
38
|
+
plan_goal: str = Field(
|
|
39
|
+
default="", description="High-level goal from execution plan"
|
|
40
|
+
)
|
|
41
|
+
current_step_id: str | None = Field(
|
|
42
|
+
default=None, description="ID of the current execution step"
|
|
43
|
+
)
|
|
44
|
+
current_step_title: str | None = Field(
|
|
45
|
+
default=None, description="Title of the current execution step"
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
class AgentSystemPromptContext(BaseModel):
|
|
50
|
+
"""Context passed to agent system prompt templates.
|
|
51
|
+
|
|
52
|
+
This model standardizes the context variables passed to Jinja2 templates
|
|
53
|
+
when rendering agent system prompts. Using a model makes it easier to
|
|
54
|
+
test template context construction and ensures type safety.
|
|
55
|
+
"""
|
|
56
|
+
|
|
57
|
+
interactive_mode: bool = Field(
|
|
58
|
+
description="Whether the agent is running in interactive mode"
|
|
59
|
+
)
|
|
60
|
+
mode: str = Field(description="The agent type (research, specify, plan, etc.)")
|
|
61
|
+
sub_agent_context: SubAgentContext | None = Field(
|
|
62
|
+
default=None, description="Context when running as a sub-agent of the router"
|
|
63
|
+
)
|
|
64
|
+
router_mode: str | None = Field(
|
|
65
|
+
default=None,
|
|
66
|
+
description="Router mode value (planning/drafting) if router agent",
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
|
|
22
70
|
class AgentResponse(BaseModel):
|
|
23
71
|
"""Structured response from an agent with optional clarifying questions.
|
|
24
72
|
|
|
@@ -39,6 +87,23 @@ class AgentResponse(BaseModel):
|
|
|
39
87
|
Optional list of clarifying questions to ask the user.
|
|
40
88
|
- Single question: Shown as a non-blocking suggestion (user can answer or continue with other prompts)
|
|
41
89
|
- Multiple questions (2+): Asked sequentially in Q&A mode (blocks input until all answered or cancelled)
|
|
90
|
+
""",
|
|
91
|
+
)
|
|
92
|
+
files_found: list[str] | None = Field(
|
|
93
|
+
default=None,
|
|
94
|
+
description="""
|
|
95
|
+
Optional list of absolute file paths found by the agent.
|
|
96
|
+
Used by FileReadAgent to return paths of files it searched and found.
|
|
97
|
+
The delegation tool can then load these files as multimodal content.
|
|
98
|
+
""",
|
|
99
|
+
)
|
|
100
|
+
file_requests: list[str] | None = Field(
|
|
101
|
+
default=None,
|
|
102
|
+
description="""
|
|
103
|
+
Optional list of file paths the agent wants to read.
|
|
104
|
+
When set, the agent loop exits, files are loaded as BinaryContent,
|
|
105
|
+
and the loop resumes with file content in the next prompt.
|
|
106
|
+
Use this for PDFs, images, or other binary files you need to analyze.
|
|
42
107
|
""",
|
|
43
108
|
)
|
|
44
109
|
|
|
@@ -51,6 +116,8 @@ class AgentType(StrEnum):
|
|
|
51
116
|
PLAN = "plan"
|
|
52
117
|
TASKS = "tasks"
|
|
53
118
|
EXPORT = "export"
|
|
119
|
+
ROUTER = "router"
|
|
120
|
+
FILE_READ = "file_read"
|
|
54
121
|
|
|
55
122
|
|
|
56
123
|
class PipelineConfigEntry(BaseModel):
|
|
@@ -319,6 +386,16 @@ class AgentDeps(AgentRuntimeOptions):
|
|
|
319
386
|
description="Current agent mode for file scoping",
|
|
320
387
|
)
|
|
321
388
|
|
|
389
|
+
sub_agent_context: SubAgentContext | None = Field(
|
|
390
|
+
default=None,
|
|
391
|
+
description="Context when agent is delegated to by router",
|
|
392
|
+
)
|
|
393
|
+
|
|
394
|
+
cancellation_event: Event | None = Field(
|
|
395
|
+
default=None,
|
|
396
|
+
description="Event set when the operation should be cancelled",
|
|
397
|
+
)
|
|
398
|
+
|
|
322
399
|
|
|
323
400
|
# Rebuild model to resolve forward references after imports are available
|
|
324
401
|
try:
|
|
@@ -328,3 +405,14 @@ try:
|
|
|
328
405
|
except ImportError:
|
|
329
406
|
# Services may not be available in all contexts
|
|
330
407
|
pass
|
|
408
|
+
|
|
409
|
+
|
|
410
|
+
# Type alias for the standard agent type used throughout the codebase
|
|
411
|
+
ShotgunAgent: TypeAlias = "Agent[AgentDeps, AgentResponse]"
|
|
412
|
+
|
|
413
|
+
# Type alias for router agent (uses RouterDeps which extends AgentDeps)
|
|
414
|
+
# Note: Agent is contravariant in deps, so RouterAgent is NOT a subtype of ShotgunAgent
|
|
415
|
+
RouterAgent: TypeAlias = "Agent[RouterDeps, AgentResponse]"
|
|
416
|
+
|
|
417
|
+
# Union type for any agent type (used in AgentManager)
|
|
418
|
+
AnyAgent: TypeAlias = "ShotgunAgent | RouterAgent"
|
shotgun/agents/plan.py
CHANGED
|
@@ -2,16 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
from functools import partial
|
|
4
4
|
|
|
5
|
-
from pydantic_ai import (
|
|
6
|
-
Agent,
|
|
7
|
-
)
|
|
8
5
|
from pydantic_ai.agent import AgentRunResult
|
|
9
6
|
from pydantic_ai.messages import ModelMessage
|
|
10
7
|
|
|
11
8
|
from shotgun.agents.config import ProviderType
|
|
9
|
+
from shotgun.agents.models import ShotgunAgent
|
|
12
10
|
from shotgun.logging_config import get_logger
|
|
13
11
|
|
|
14
12
|
from .common import (
|
|
13
|
+
EventStreamHandler,
|
|
15
14
|
add_system_status_message,
|
|
16
15
|
build_agent_system_prompt,
|
|
17
16
|
create_base_agent,
|
|
@@ -25,7 +24,7 @@ logger = get_logger(__name__)
|
|
|
25
24
|
|
|
26
25
|
async def create_plan_agent(
|
|
27
26
|
agent_runtime_options: AgentRuntimeOptions, provider: ProviderType | None = None
|
|
28
|
-
) -> tuple[
|
|
27
|
+
) -> tuple[ShotgunAgent, AgentDeps]:
|
|
29
28
|
"""Create a plan agent with artifact management capabilities.
|
|
30
29
|
|
|
31
30
|
Args:
|
|
@@ -51,26 +50,25 @@ async def create_plan_agent(
|
|
|
51
50
|
|
|
52
51
|
|
|
53
52
|
async def run_plan_agent(
|
|
54
|
-
agent:
|
|
55
|
-
|
|
53
|
+
agent: ShotgunAgent,
|
|
54
|
+
prompt: str,
|
|
56
55
|
deps: AgentDeps,
|
|
57
56
|
message_history: list[ModelMessage] | None = None,
|
|
57
|
+
event_stream_handler: EventStreamHandler | None = None,
|
|
58
58
|
) -> AgentRunResult[AgentResponse]:
|
|
59
|
-
"""Create or update a plan based on the given
|
|
59
|
+
"""Create or update a plan based on the given prompt using artifacts.
|
|
60
60
|
|
|
61
61
|
Args:
|
|
62
62
|
agent: The configured plan agent
|
|
63
|
-
|
|
63
|
+
prompt: The planning prompt or instruction
|
|
64
64
|
deps: Agent dependencies
|
|
65
65
|
message_history: Optional message history for conversation continuity
|
|
66
|
+
event_stream_handler: Optional callback for streaming events
|
|
66
67
|
|
|
67
68
|
Returns:
|
|
68
69
|
AgentRunResult containing the planning process output
|
|
69
70
|
"""
|
|
70
|
-
logger.debug("📋 Starting planning for
|
|
71
|
-
|
|
72
|
-
# Simple prompt - the agent system prompt has all the artifact instructions
|
|
73
|
-
full_prompt = f"Create a comprehensive plan for: {goal}"
|
|
71
|
+
logger.debug("📋 Starting planning for prompt: %s", prompt)
|
|
74
72
|
|
|
75
73
|
try:
|
|
76
74
|
# Create usage limits for responsible API usage
|
|
@@ -80,10 +78,11 @@ async def run_plan_agent(
|
|
|
80
78
|
|
|
81
79
|
result = await run_agent(
|
|
82
80
|
agent=agent,
|
|
83
|
-
prompt=
|
|
81
|
+
prompt=prompt,
|
|
84
82
|
deps=deps,
|
|
85
83
|
message_history=message_history,
|
|
86
84
|
usage_limits=usage_limits,
|
|
85
|
+
event_stream_handler=event_stream_handler,
|
|
87
86
|
)
|
|
88
87
|
|
|
89
88
|
logger.debug("✅ Planning completed successfully")
|
shotgun/agents/research.py
CHANGED
|
@@ -2,18 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
from functools import partial
|
|
4
4
|
|
|
5
|
-
from pydantic_ai import (
|
|
6
|
-
Agent,
|
|
7
|
-
)
|
|
8
5
|
from pydantic_ai.agent import AgentRunResult
|
|
9
6
|
from pydantic_ai.messages import (
|
|
10
7
|
ModelMessage,
|
|
11
8
|
)
|
|
12
9
|
|
|
13
10
|
from shotgun.agents.config import ProviderType
|
|
11
|
+
from shotgun.agents.models import ShotgunAgent
|
|
14
12
|
from shotgun.logging_config import get_logger
|
|
15
13
|
|
|
16
14
|
from .common import (
|
|
15
|
+
EventStreamHandler,
|
|
17
16
|
add_system_status_message,
|
|
18
17
|
build_agent_system_prompt,
|
|
19
18
|
create_base_agent,
|
|
@@ -28,7 +27,7 @@ logger = get_logger(__name__)
|
|
|
28
27
|
|
|
29
28
|
async def create_research_agent(
|
|
30
29
|
agent_runtime_options: AgentRuntimeOptions, provider: ProviderType | None = None
|
|
31
|
-
) -> tuple[
|
|
30
|
+
) -> tuple[ShotgunAgent, AgentDeps]:
|
|
32
31
|
"""Create a research agent with web search and artifact management capabilities.
|
|
33
32
|
|
|
34
33
|
Args:
|
|
@@ -65,22 +64,25 @@ async def create_research_agent(
|
|
|
65
64
|
|
|
66
65
|
|
|
67
66
|
async def run_research_agent(
|
|
68
|
-
agent:
|
|
69
|
-
|
|
67
|
+
agent: ShotgunAgent,
|
|
68
|
+
prompt: str,
|
|
70
69
|
deps: AgentDeps,
|
|
71
70
|
message_history: list[ModelMessage] | None = None,
|
|
71
|
+
event_stream_handler: EventStreamHandler | None = None,
|
|
72
72
|
) -> AgentRunResult[AgentResponse]:
|
|
73
|
-
"""Perform research on the given
|
|
73
|
+
"""Perform research on the given prompt and update research artifacts.
|
|
74
74
|
|
|
75
75
|
Args:
|
|
76
76
|
agent: The configured research agent
|
|
77
|
-
|
|
77
|
+
prompt: The research prompt to investigate
|
|
78
78
|
deps: Agent dependencies
|
|
79
|
+
message_history: Optional message history for conversation continuity
|
|
80
|
+
event_stream_handler: Optional callback for streaming events
|
|
79
81
|
|
|
80
82
|
Returns:
|
|
81
83
|
Summary of research findings
|
|
82
84
|
"""
|
|
83
|
-
logger.debug("🔬 Starting research for
|
|
85
|
+
logger.debug("🔬 Starting research for prompt: %s", prompt)
|
|
84
86
|
|
|
85
87
|
message_history = await add_system_status_message(deps, message_history)
|
|
86
88
|
|
|
@@ -90,10 +92,11 @@ async def run_research_agent(
|
|
|
90
92
|
|
|
91
93
|
result = await run_agent(
|
|
92
94
|
agent=agent,
|
|
93
|
-
prompt=
|
|
95
|
+
prompt=prompt,
|
|
94
96
|
deps=deps,
|
|
95
97
|
message_history=message_history,
|
|
96
98
|
usage_limits=usage_limits,
|
|
99
|
+
event_stream_handler=event_stream_handler,
|
|
97
100
|
)
|
|
98
101
|
|
|
99
102
|
logger.debug("✅ Research completed successfully")
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"""Router Agent - The intelligent orchestrator for shotgun agents."""
|
|
2
|
+
|
|
3
|
+
from shotgun.agents.router.models import (
|
|
4
|
+
CascadeScope,
|
|
5
|
+
CreatePlanInput,
|
|
6
|
+
DelegationInput,
|
|
7
|
+
DelegationResult,
|
|
8
|
+
ExecutionPlan,
|
|
9
|
+
ExecutionStep,
|
|
10
|
+
ExecutionStepInput,
|
|
11
|
+
MarkStepDoneInput,
|
|
12
|
+
PlanApprovalStatus,
|
|
13
|
+
RemoveStepInput,
|
|
14
|
+
RouterDeps,
|
|
15
|
+
RouterMode,
|
|
16
|
+
StepCheckpointAction,
|
|
17
|
+
SubAgentResult,
|
|
18
|
+
SubAgentResultStatus,
|
|
19
|
+
ToolResult,
|
|
20
|
+
)
|
|
21
|
+
from shotgun.agents.router.router import create_router_agent, run_router_agent
|
|
22
|
+
|
|
23
|
+
__all__ = [
|
|
24
|
+
# Agent factory
|
|
25
|
+
"create_router_agent",
|
|
26
|
+
"run_router_agent",
|
|
27
|
+
# Enums
|
|
28
|
+
"RouterMode",
|
|
29
|
+
"PlanApprovalStatus",
|
|
30
|
+
"StepCheckpointAction",
|
|
31
|
+
"CascadeScope",
|
|
32
|
+
"SubAgentResultStatus",
|
|
33
|
+
# Plan models
|
|
34
|
+
"ExecutionStep",
|
|
35
|
+
"ExecutionPlan",
|
|
36
|
+
# Tool I/O models
|
|
37
|
+
"ExecutionStepInput",
|
|
38
|
+
"CreatePlanInput",
|
|
39
|
+
"MarkStepDoneInput",
|
|
40
|
+
"RemoveStepInput",
|
|
41
|
+
"DelegationInput",
|
|
42
|
+
"ToolResult",
|
|
43
|
+
"DelegationResult",
|
|
44
|
+
"SubAgentResult",
|
|
45
|
+
# Deps
|
|
46
|
+
"RouterDeps",
|
|
47
|
+
]
|