Rebase onto upstream (a4d95fd)
#12
@@ -53,14 +53,24 @@ Skills with available="false" need dependencies installed first - you can try in
|
|||||||
return "\n\n---\n\n".join(parts)
|
return "\n\n---\n\n".join(parts)
|
||||||
|
|
||||||
def _get_identity(self) -> str:
|
def _get_identity(self) -> str:
|
||||||
"""Get the core identity section."""
|
"""Get the core identity section with runtime context."""
|
||||||
|
from datetime import datetime
|
||||||
|
import time as _time
|
||||||
|
now = datetime.now().strftime("%Y-%m-%d %H:%M (%A)")
|
||||||
|
tz = _time.strftime("%Z") or "UTC"
|
||||||
workspace_path = str(self.workspace.expanduser().resolve())
|
workspace_path = str(self.workspace.expanduser().resolve())
|
||||||
system = platform.system()
|
system = platform.system()
|
||||||
runtime = f"{'macOS' if system == 'Darwin' else system} {platform.machine()}, Python {platform.python_version()}"
|
runtime = f"{'macOS' if system == 'Darwin' else system} {platform.machine()}, Python {platform.python_version()}"
|
||||||
|
|
||||||
return f"""# nanobot 🐈
|
|
||||||
|
|
||||||
You are nanobot, a helpful AI assistant.
|
return f"""You have access to tools that allow you to:
|
||||||
|
- Read, write, and edit files
|
||||||
|
- Execute shell commands
|
||||||
|
- Search the web and fetch web pages
|
||||||
|
- Send messages to users on chat channels
|
||||||
|
- Spawn subagents for complex background tasks
|
||||||
|
|
||||||
|
## Current Time
|
||||||
|
{now} ({tz})
|
||||||
|
|
||||||
## Runtime
|
## Runtime
|
||||||
{runtime}
|
{runtime}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import httpx
|
|||||||
from loguru import logger
|
from loguru import logger
|
||||||
|
|
||||||
from nanobot.providers.base import LLMProvider, LLMResponse, ToolCallRequest
|
from nanobot.providers.base import LLMProvider, LLMResponse, ToolCallRequest
|
||||||
from nanobot.providers.oauth_utils import get_auth_headers, get_claude_code_system_prefix
|
from nanobot.providers.oauth_utils import get_auth_headers
|
||||||
|
|
||||||
|
|
||||||
class AnthropicOAuthProvider(LLMProvider):
|
class AnthropicOAuthProvider(LLMProvider):
|
||||||
@@ -78,7 +78,7 @@ class AnthropicOAuthProvider(LLMProvider):
|
|||||||
|
|
||||||
Returns (system_prompt, anthropic_messages)
|
Returns (system_prompt, anthropic_messages)
|
||||||
"""
|
"""
|
||||||
system_parts = [get_claude_code_system_prefix()]
|
system_parts = []
|
||||||
converted: list[dict[str, Any]] = []
|
converted: list[dict[str, Any]] = []
|
||||||
|
|
||||||
for msg in messages:
|
for msg in messages:
|
||||||
|
|||||||
@@ -36,11 +36,3 @@ def get_auth_headers(token: str, is_oauth: bool = False) -> dict[str, str]:
|
|||||||
headers["x-api-key"] = token
|
headers["x-api-key"] = token
|
||||||
|
|
||||||
return headers
|
return headers
|
||||||
|
|
||||||
|
|
||||||
def get_claude_code_system_prefix() -> str:
|
|
||||||
"""Get the required system prompt prefix for OAuth tokens.
|
|
||||||
|
|
||||||
Anthropic requires this identity declaration for OAuth auth.
|
|
||||||
"""
|
|
||||||
return "You are Claude Code, Anthropic's official CLI for Claude."
|
|
||||||
|
|||||||
Reference in New Issue
Block a user