Commit Graph

156 Commits

Author SHA1 Message Date
chengyongru
a2acacd8f2 fix: add exception handling to prevent agent loop crash 2026-03-14 18:34:22 +08:00
Xubin Ren
411b059dd2 refactor: replace <SILENT_OK> with structured post-run evaluation
- Add nanobot/utils/evaluator.py: lightweight LLM tool-call to decide notify/silent after background task execution
- Remove magic token injection from heartbeat and cron prompts
- Clean session history (no more <SILENT_OK> pollution)
- Add tests for evaluator and updated heartbeat three-phase flow
2026-03-14 17:41:08 +08:00
SJK-py
4990c7478b suppress unnecessary cron notifications
Appends a strict instruction to background task prompts (cron and heartbeat) 
directing the agent to return a `<SILENT_OK>` token if there is nothing 
material to report. Adds conditional logic to intercept this token and 
suppress the outbound message to the user, preventing notification spam 
from autonomous background checks.
2026-03-14 17:41:08 +08:00
Peixian Gong
58fc34d3f4 refactor: use shutil.which() instead of shell=True for npm calls
Replace platform-specific shell=True logic with shutil.which('npm') to
resolve the full path to the npm executable. This is cleaner because:

- No shell=True needed (safer, no shell injection risk)
- No platform-specific branching (sys.platform checks removed)
- Works identically on Windows, macOS, and Linux
- shutil.which() resolves npm.cmd on Windows automatically

The npm path check that already existed in _get_bridge_dir() is now
reused as the resolved path for subprocess calls. The same pattern is
applied to channels_login().
2026-03-14 17:19:01 +08:00
Peixian Gong
805228e91e fix: add shell=True for npm subprocess calls on Windows
On Windows, npm is installed as npm.cmd (a batch script), not a direct
executable. When subprocess.run() is called with a list like
['npm', 'install'] without shell=True, Python's CreateProcess cannot
locate npm.cmd, resulting in:

  FileNotFoundError: [WinError 2] The system cannot find the file specified

This fix adds a sys.platform == 'win32' check before each npm subprocess
call. On Windows, it uses shell=True with a string command so the shell
can resolve npm.cmd. On other platforms, the original list-based call is
preserved unchanged.

Affected locations:
- _get_bridge_dir(): npm install, npm run build
- channels_login(): npm start

No behavioral change on Linux/macOS.
2026-03-14 17:19:01 +08:00
Xubin Ren
af65145bc8 fix(qq): add configurable message format and onboard backfill 2026-03-14 08:25:44 +00:00
Xubin Ren
dbdb43faff feat: channel plugin architecture with decoupled configs
- Add plugin discovery via Python entry_points (group: nanobot.channels)
- Move 11 channel Config classes from schema.py into their own channel modules
- ChannelsConfig now only keeps send_progress + send_tool_hints (extra=allow)
- Each built-in channel parses dict->Pydantic in __init__, zero internal changes
- All channels implement default_config() for onboard auto-population
- nanobot onboard injects defaults for all discovered channels (built-in + plugins)
- Add nanobot plugins list CLI command
- Add Channel Plugin Guide (docs/CHANNEL_PLUGIN_GUIDE.md)
- Fully backward compatible: existing config.json and sessions work as-is
- 340 tests pass, zero regressions
2026-03-14 16:13:38 +08:00
Xubin Ren
ca5047b602 feat(web): multi-provider web search + Jina Reader fetch 2026-03-13 05:44:16 +00:00
Re-bin
3fa62e7fda fix: remove duplicate dim/arrow prefix in interactive progress line 2026-03-12 15:38:39 +00:00
Re-bin
48c74a11d4 Merge remote-tracking branch 'origin/main' into pr-1930 2026-03-12 15:28:57 +00:00
chengdu121
d51ec7f0e8 fix: preserve interactive CLI formatting for async subagent output 2026-03-12 19:15:04 +08:00
Re-bin
254cfd48ba refactor: auto-discover channels via pkgutil, eliminate hardcoded registry 2026-03-11 14:23:19 +00:00
Re-bin
c72c2ce7e2 refactor: move generation settings to provider level, eliminate parameter passthrough 2026-03-11 09:47:04 +00:00
Jerome Sonnet (letzdoo)
dee4f27dce feat: add Ollama as a local LLM provider
Add native Ollama support so local models (e.g. nemotron-3-nano) can be
used without an API key. Adds ProviderSpec with ollama_chat LiteLLM
prefix, ProvidersConfig field, and skips API key validation for local
providers.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-11 08:13:14 +04:00
Re-bin
62ccda43b9 refactor(memory): switch consolidation to token-based context windows
Move consolidation policy into MemoryConsolidator, keep backward compatibility for legacy config, and compress history by token budget instead of message count.
2026-03-10 19:55:06 +00:00
Re-bin
4784eb4128 merge origin/main into pr-1704 2026-03-10 18:09:15 +00:00
Protocol Zero
1284c7217e fix(cli): let gateway use config port by default
Respect config.gateway.port when --port is omitted, while keeping CLI flags as the highest-precedence override.
2026-03-09 20:12:11 +00:00
VITOHJL
2706d3c317 fix(commands): use max_tokens_output instead of max_tokens from AgentDefaults 2026-03-08 15:20:34 +08:00
VITOHJL
2dcb4de422 fix(commands): update AgentLoop calls to use token-based compression parameters 2026-03-08 15:04:38 +08:00
Re-bin
bf0ab93b06 Merge branch 'main' into pr-1635 2026-03-08 03:24:15 +00:00
Re-bin
fb4f696085 Merge branch 'main' into pr-1635 2026-03-08 03:14:20 +00:00
Re-bin
20dfaa5d34 refactor: unify instance path resolution and preserve workspace override 2026-03-08 02:58:25 +00:00
Re-bin
bdac08161b Merge branch 'main' into pr-1581 2026-03-08 02:05:23 +00:00
Maciej Wojcik
79f3ca4f12 feat(cli): add workspace and config flags to agent 2026-03-06 20:32:10 +00:00
Kunal Karmakar
33c52cfb74 Merge branch 'main' of https://github.com/kunalk16/nanobot into feat-support-azure-openai 2026-03-06 10:39:29 +00:00
Kunal Karmakar
813d37ad35 Support Azure OpenAI 2026-03-06 08:43:58 +00:00
Re-bin
cbce674669 Merge remote-tracking branch 'origin/main' into pr-1546 2026-03-06 07:18:06 +00:00
nanobot-contributor
9ab4155991 fix(cli): add Windows compatibility for signal handlers (PR #1400)
SIGHUP and SIGPIPE are not available on Windows. Add hasattr() checks
before registering these signal handlers to prevent AttributeError on
Windows systems.

Fixes compatibility issue introduced in PR #1400.
2026-03-06 09:57:03 +08:00
samsonchoi
4e4d40ef33 feat: multi-instance support with --config parameter
Add support for running multiple nanobot instances with complete isolation:

- Add --config parameter to gateway command for custom config file path
- Implement set_config_path() in config/loader.py for dynamic config path
- Derive data directory from config file location (e.g., ~/.nanobot-xxx/)
- Update get_data_path() to use unified data directory from config loader
- Ensure cron jobs use instance-specific data directory

This enables running multiple isolated nanobot instances by specifying
different config files, with each instance maintaining separate:
- Configuration files
- Workspace (memory, sessions, skills)
- Cron jobs
- Logs and media

Example usage:
  nanobot gateway --config ~/.nanobot-instance2/config.json --port 18791
2026-03-05 23:48:45 +08:00
Re-bin
4ba8d137bc Merge remote-tracking branch 'origin/main' into pr-1400 2026-03-05 14:56:18 +00:00
Re-bin
0343d66224 fix(gateway): remove duplicate load_config() that overwrote custom workspace/config 2026-03-05 14:54:53 +00:00
Re-bin
6d342fe79d Merge remote-tracking branch 'origin/main' into pr-1435 2026-03-05 14:51:13 +00:00
hcanyz
a08aae93e6 fix: not imported when LiteLLMProvider is not used
LiteLLM:WARNING: get_model_cost_map.py:213 - LiteLLM: Failed to fetch remote model cost map from https://raw.githubusercontent.com/BerriAI/litellm/main/model_prices_and_context_window.json: The read operation timed out. Falling back to local backup.
2026-03-05 11:33:24 +08:00
Re-bin
c05cb2ef64 refactor(cron): remove CLI cron commands and unify scheduling via cron tool 2026-03-03 05:51:24 +00:00
Re-bin
30803afec0 fix(cron): isolate cron-execution guard with contextvars 2026-03-03 05:36:48 +00:00
Nikolas de Hor
da8a4fc68c fix: prevent cron job execution from scheduling new jobs
When a cron job fires, the agent processes the scheduled message and
has access to the cron tool. If the original message resembles a
scheduling instruction (e.g. "remind me in 10 seconds"), the agent
would call cron.add again, creating an infinite feedback loop.

Add a cron-context flag to CronTool that blocks add operations during
cron job execution. The flag is set before process_direct() and cleared
in a finally block to ensure cleanup even on errors.

Fixes #1441
2026-03-03 01:02:33 -03:00
chengyongru
8f4baaa5ce feat(gateway): support multiple instances with --workspace and --config options
- Add --workspace/-w flag to specify workspace directory
- Add --config/-c flag to specify config file path
- Move cron store to workspace directory for per-instance isolation
- Enable running multiple nanobot instances simultaneously
2026-03-02 23:18:54 +08:00
chengyongru
aed1ef5529 fix: add SIGTERM, SIGHUP handling and ignore SIGPIPE
- Add handler for SIGTERM to prevent "Terminated" message on Linux
- Add handler for SIGHUP for terminal closure handling
- Ignore SIGPIPE to prevent silent process termination
- Change os._exit(0) to sys.exit(0) for proper cleanup

Fixes issue #1365

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 11:04:53 +08:00
Re-bin
f5c0c75648 Merge branch 'main' into pr-1370 2026-03-01 12:48:01 +00:00
Re-bin
a7d24192d9 fix(cron): route scheduled jobs through process_direct with english reminder prefix 2026-03-01 12:45:53 +00:00
VITOHJL
468dfc406b feat(cron): improve cron job context handling
Improve cron job execution context to ensure proper message delivery and
session history recording.

Changes:
- Add [绯荤粺瀹氭椂浠诲姟] prefix to cron reminder messages to clearly mark
  them as system-driven, not user queries
- Use user role for cron reminder messages (required by some LLM APIs)
- Properly handle MessageTool to avoid duplicate message delivery
- Correctly save turn history with proper skip count
- Ensure Runtime Context is included in the message list

This ensures that:
1. Cron jobs execute with proper context
2. Messages are correctly delivered to users
3. Session history accurately records cron job interactions
4. The LLM understands these are system-driven reminders, not user queries
2026-03-01 17:05:04 +08:00
chengyongru
82be2ae1a5 feat(tool): add web search proxy 2026-03-01 16:51:54 +08:00
Jack Lu
3ee061b879 Merge branch 'main' into main 2026-03-01 13:35:24 +08:00
Re-bin
f9d72e2e74 feat: add reasoning_effort config to enable LLM thinking mode 2026-02-28 17:18:05 +00:00
JK_Lu
977ca725f2 style: unify code formatting and import order
- Remove trailing whitespace and normalize blank lines
- Unify string quotes and line breaks for long lines
- Sort imports alphabetically across modules
2026-02-28 20:55:43 +08:00
Re-bin
d5808bf586 refactor: streamline workspace template sync 2026-02-27 09:46:57 +00:00
Hon Jia Xuan
cb999ae826 feat: implement automatic workspace template synchronization 2026-02-27 10:39:05 +08:00
Re-bin
f828a1d5d1 fix(gateway): show actual heartbeat interval in startup log 2026-02-24 12:09:19 +00:00
Re-bin
ec55f77912 fix(heartbeat): replace HEARTBEAT_OK token with virtual tool-call decision 2026-02-24 11:04:56 +00:00
Re-bin
7671239902 fix(heartbeat): suppress progress messages and deliver agent response to user 2026-02-23 13:45:09 +00:00