diff --git a/docs/ai.rst b/docs/ai.rst new file mode 100644 index 00000000..0aeac494 --- /dev/null +++ b/docs/ai.rst @@ -0,0 +1,158 @@ +splunklib.ai +------------ + +.. automodule:: splunklib.ai + +.. autoclass:: splunklib.ai.agent.Agent + :members: invoke, invoke_with_data + +.. autoexception:: splunklib.ai.agent.PrivilegedExecutionError + :members: + +.. rubric:: Models + +.. autoclass:: splunklib.ai.model.PredefinedModel + :members: + +.. autoclass:: splunklib.ai.model.AnthropicModel + :members: + +.. autoclass:: splunklib.ai.model.OpenAIModel + :members: + +.. autoclass:: splunklib.ai.model.GoogleModel + :members: + +.. rubric:: Messages + +.. autoclass:: splunklib.ai.messages.BaseMessage + :members: + +.. autoclass:: splunklib.ai.messages.HumanMessage + :members: + +.. autoclass:: splunklib.ai.messages.AIMessage + :members: + +.. autoclass:: splunklib.ai.messages.SystemMessage + :members: + +.. autoclass:: splunklib.ai.messages.ToolMessage + :members: + +.. autoclass:: splunklib.ai.messages.SubagentMessage + :members: + +.. autoclass:: splunklib.ai.messages.AgentResponse + :members: + +.. autoclass:: splunklib.ai.messages.TextBlock + :members: + +.. autoclass:: splunklib.ai.messages.ToolCall + :members: + +.. autoclass:: splunklib.ai.messages.SubagentCall + :members: + +.. autoclass:: splunklib.ai.messages.ToolResult + :members: + +.. autoclass:: splunklib.ai.messages.SubagentTextResult + :members: + +.. autoclass:: splunklib.ai.messages.SubagentStructuredResult + :members: + +.. autoclass:: splunklib.ai.messages.ToolFailureResult + :members: + +.. autoclass:: splunklib.ai.messages.SubagentFailureResult + :members: + +.. rubric:: Middleware + +.. autoclass:: splunklib.ai.middleware.AgentMiddleware + :members: + +.. autofunction:: splunklib.ai.middleware.agent_middleware + +.. autofunction:: splunklib.ai.middleware.model_middleware + +.. autofunction:: splunklib.ai.middleware.tool_middleware + +.. autofunction:: splunklib.ai.middleware.subagent_middleware + +.. autoclass:: splunklib.ai.middleware.AgentState + :members: + +.. autoclass:: splunklib.ai.middleware.AgentRequest + :members: + +.. autoclass:: splunklib.ai.middleware.ModelRequest + :members: + +.. autoclass:: splunklib.ai.middleware.ModelResponse + :members: + +.. autoclass:: splunklib.ai.middleware.ToolRequest + :members: + +.. autoclass:: splunklib.ai.middleware.ToolResponse + :members: + +.. autoclass:: splunklib.ai.middleware.SubagentRequest + :members: + +.. autoclass:: splunklib.ai.middleware.SubagentResponse + :members: + +.. rubric:: Limits + +.. autoclass:: splunklib.ai.limits.AgentLimits + :members: + +.. autoexception:: splunklib.ai.limits.AgentStopException + :members: + +.. autoexception:: splunklib.ai.limits.TokenLimitExceededException + :members: + +.. autoexception:: splunklib.ai.limits.StepsLimitExceededException + :members: + +.. autoexception:: splunklib.ai.limits.TimeoutExceededException + :members: + +.. autoexception:: splunklib.ai.limits.StructuredOutputRetryLimitExceededException + :members: + +.. rubric:: Tool settings + +.. autoclass:: splunklib.ai.tool_settings.ToolSettings + :members: + +.. autoclass:: splunklib.ai.tool_settings.LocalToolSettings + :members: + +.. autoclass:: splunklib.ai.tool_settings.RemoteToolSettings + :members: + +.. autoclass:: splunklib.ai.tool_settings.ToolAllowlist + :members: + +.. rubric:: Conversation store + +.. autoclass:: splunklib.ai.conversation_store.ConversationStore + :members: + +.. autoclass:: splunklib.ai.conversation_store.InMemoryStore + :members: + +.. rubric:: Security + +.. autofunction:: splunklib.ai.security.detect_injection + +.. autofunction:: splunklib.ai.security.truncate_input + +.. autofunction:: splunklib.ai.security.create_structured_prompt diff --git a/docs/index.rst b/docs/index.rst index 8f209468..1f2a0199 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -12,6 +12,7 @@ For more information, see the `Splunk Developer Portal /bin/tools.py`). - * Remote tools via `ToolSettings.remote` (requires Splunk MCP Server App present on SH). + loaded and exposed to the model. When provided, the agent loads + local tools via ``ToolSettings.local`` (registered in ``/bin/tools.py``) + and remote tools via ``ToolSettings.remote`` (requires Splunk MCP Server App present on SH). Each sub-setting accepts an optional allowlist to restrict which tools are exposed. No tools are loaded by default. diff --git a/splunklib/ai/security.py b/splunklib/ai/security.py index 80936fcc..8a933a6c 100644 --- a/splunklib/ai/security.py +++ b/splunklib/ai/security.py @@ -70,11 +70,14 @@ def create_structured_prompt(instructions: str, data: str | dict[str, Any]) -> s external data (alert payloads, log entries, API responses, etc.) to reduce the risk of indirect prompt injection. - Example: - HumanMessage(content=create_structured_prompt( - instructions="Summarize this security alert and assess its severity.", - data=alert_payload, - )) + Example:: + + HumanMessage( + content=create_structured_prompt( + instructions="Summarize this security alert and assess its severity.", + data=alert_payload, + ) + ) """ return ( f"INSTRUCTIONS:\n" diff --git a/splunklib/searchcommands/eventing_command.py b/splunklib/searchcommands/eventing_command.py index a02af0e0..b3b703d5 100644 --- a/splunklib/searchcommands/eventing_command.py +++ b/splunklib/searchcommands/eventing_command.py @@ -106,15 +106,15 @@ class ConfigurationSettings(SearchCommand.ConfigurationSettings): doc=""" Specifies the maximum number of events that can be passed to the command for each invocation. - This limit cannot exceed the value of `maxresultrows` as defined in limits.conf_. Under SCP 1 you must - specify this value in commands.conf_. + This limit cannot exceed the value of `maxresultrows` as defined in `limits.conf + `_. Under SCP 1 you must + specify this value in `commands.conf + `_. Default: The value of `maxresultrows`. Supported by: SCP 2 - .. _limits.conf: http://docs.splunk.com/Documentation/Splunk/latest/admin/Limitsconf - """ ) diff --git a/splunklib/searchcommands/reporting_command.py b/splunklib/searchcommands/reporting_command.py index 317cc3dd..11946695 100644 --- a/splunklib/searchcommands/reporting_command.py +++ b/splunklib/searchcommands/reporting_command.py @@ -216,15 +216,14 @@ class ConfigurationSettings(SearchCommand.ConfigurationSettings): doc=""" Specifies the maximum number of events that can be passed to the command for each invocation. - This limit cannot exceed the value of `maxresultrows` in limits.conf_. Under SCP 1 you must specify this - value in commands.conf_. + This limit cannot exceed the value of `maxresultrows` in `limits.conf + `_. Under SCP 1 you must specify this + value in `commands.conf `_. Default: The value of `maxresultrows`. Supported by: SCP 2 - .. _limits.conf: http://docs.splunk.com/Documentation/Splunk/latest/admin/Limitsconf - """ ) diff --git a/splunklib/searchcommands/search_command.py b/splunklib/searchcommands/search_command.py index 15add5f7..27b5bd0e 100644 --- a/splunklib/searchcommands/search_command.py +++ b/splunklib/searchcommands/search_command.py @@ -169,7 +169,7 @@ def gen_record(self, **record): record = Option( doc=""" - **Syntax: record= + **Syntax:** record= **Description:** When `true`, records the interaction between the command and splunkd. Defaults to `false`. @@ -1166,7 +1166,7 @@ def dispatch( execute :code:`command_class`, pass :const:`None` as the value of :code:`module_name`. :param command_class: Search command class to instantiate and execute. - :type command_class: type + :type command_class: :class:`type` :param argv: List of arguments to the command. :type argv: list or tuple :param input_file: File from which the command will read data. diff --git a/splunklib/searchcommands/streaming_command.py b/splunklib/searchcommands/streaming_command.py index 0af4d61f..fb401893 100644 --- a/splunklib/searchcommands/streaming_command.py +++ b/splunklib/searchcommands/streaming_command.py @@ -133,18 +133,18 @@ class ConfigurationSettings(SearchCommand.ConfigurationSettings): doc=""" :const:`True`, if this command should be distributed to indexers. - Under SCP 1 you must either specify `local = False` or include this line in commands.conf_, if this command + Under SCP 1 you must either specify `local = False` or include this line in `commands.conf + `_, if this command should be distributed to indexers. - ..code: + .. code-block:: text + local = true Default: :const:`True` Supported by: SCP 2 - .. commands.conf_: http://docs.splunk.com/Documentation/Splunk/latest/Admin/Commandsconf - """, ) @@ -153,7 +153,7 @@ class ConfigurationSettings(SearchCommand.ConfigurationSettings): Specifies the maximum number of events that can be passed to the command for each invocation. This limit cannot exceed the value of `maxresultrows` in limits.conf. Under SCP 1 you must specify this - value in commands.conf_. + value in `commands.conf `_. Default: The value of `maxresultrows`.