Commit Graph

4632 Commits

Author SHA1 Message Date
Tyler Yust
bcbb447357 feat: extend CreateAgentSessionOptions with new properties
- Added systemPrompt for overriding the default system prompt.
- Introduced skills for pre-loaded skills management.
- Added contextFiles for handling pre-loaded context files with path and content attributes.
2026-02-01 14:53:33 -08:00
Peter Steinberger
8eb11bd304 fix: wire before_tool_call hook into tool execution (#6570) (thanks @ryancnelson) (#6660) 2026-02-01 14:52:11 -08:00
Ryan Nelson
6c6f1e9660 Fix missing before_tool_call hook integration (#6570)
* Fix missing before_tool_call hook integration

- Add hook call in handleToolExecutionStart before tool execution begins
- Support parameter modification via hookResult.params
- Support tool call blocking via hookResult.block with custom blockReason
- Fix try/catch logic to properly re-throw blocking errors using __isHookBlocking flag
- Maintain tool event consistency by emitting start/end events when blocked
- Addresses GitHub issue #6535 (1 of 8 unimplemented hooks now working)

Co-Authored-By: Claude Sonnet 4 <noreply@anthropic.com>

* Add comprehensive test suite for before_tool_call hook

- 9 tests covering all hook scenarios: no hooks, parameter passing, modification, blocking, error handling
- Tests tool name normalization and different argument types
- Verifies proper error re-throwing and logging behavior
- Maintained in fork for regression testing

* Fix all issues identified by Greptile code review

Address P0/P1/P3 bugs:

P0 - Fix parameter mutation crash for non-object args:
- Normalize args to objects before passing to hooks (maintains hook contract)
- Handle parameter merging safely for both object and non-object args

P1 - Add missing internal state updates when blocking tools:
- Set toolMetaById metadata like normal flow
- Call onAgentEvent callback to maintain consistency
- Emit events in same order as normal tool execution

P1 - Fix test expectations to match implementation reality:
- Non-object args normalized to {} for hook params (not passed as-is)
- Add test for safe parameter modification with various arg types
- Update mocks to verify state updates when blocking

P3 - Replace magic __isHookBlocking property with dedicated ToolBlockedError class:
- More robust error handling without property collision risk
- Cleaner control flow that's serialization-safe

Co-Authored-By: Claude Sonnet 4 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4 <noreply@anthropic.com>
2026-02-01 14:49:14 -08:00
Leszek Szpunar
1bdd9e313f security(web): sanitize WhatsApp accountId to prevent path traversal (#4610)
* security(web): sanitize WhatsApp accountId to prevent path traversal

Apply normalizeAccountId() from routing/session-key to
resolveDefaultAuthDir() so that malicious config values like
"../../../etc" cannot escape the intended auth directory.

Fixes #2692

* fix(web): check sanitized segment instead of full path in Windows test

* style(web): fix oxfmt formatting in accounts test
2026-02-01 14:29:53 -08:00
Peter Steinberger
9d2784cdb9 test: speed up telegram suites 2026-02-01 22:23:16 +00:00
Peter Steinberger
bcde2fca5a fix: align embedded agent session setup 2026-02-01 22:23:16 +00:00
Leszek Szpunar
9b6fffd00a security(message-tool): validate filePath/path against sandbox root (#6398)
* security(message-tool): validate filePath/path against sandbox root

* style: translate Polish comments to English for consistency
2026-02-01 14:19:09 -08:00
Peter Steinberger
083ec9325e fix: cover OpenRouter attribution headers 2026-02-01 19:30:33 +00:00
Alex Atallah
74039fc0f1 Add openrouter attribution headers 2026-02-01 19:24:55 +00:00
Ayaan Zaidi
e9f70e8585 fix: satisfy lint curly rule (#6310)
* fix: satisfy lint curly rule

* docs: apply oxfmt formatting
2026-02-01 20:04:53 +05:30
Ayaan Zaidi
0992c5a809 fix: cap context window resolution (#6187) (thanks @iamEvanYT) 2026-02-01 19:52:56 +05:30
Evan
5d3c898a94 fix: update compaction safeguard to respect context window tokens 2026-02-01 19:52:56 +05:30
clawdinator[bot]
b897389b87 fix: friendlier Windows onboarding message (#6242)
Co-authored-by: CLAWDINATOR <clawdinator@openclaw.ai>
Co-authored-by: Scott Hanselman <scott@hanselman.com>
2026-02-01 12:55:22 +00:00
Peter Steinberger
a1e89afcc1 fix: secure chrome extension relay cdp 2026-02-01 02:25:14 -08:00
Peter Steinberger
e4f7155369 fix(ci): repair lint/build checks 2026-02-01 10:20:27 +00:00
Vignesh
35dc417b18 agents: add tool policy conformance snapshot (no runtime behavior change) (#6011) 2026-02-01 01:57:49 -08:00
Ayaan Zaidi
633f848481 fix: use telegram user id for pairing request 2026-02-01 15:22:37 +05:30
Ayaan Zaidi
24fbafa9a7 refactor: use shared pairing store for telegram 2026-02-01 15:22:37 +05:30
Armin Ronacher
ca92597e1f Merge commit from fork 2026-02-01 10:43:54 +01:00
Mario Zechner
c621c80afc fix(tui): prevent crash when searching with digits in model selector
highlightMatch() was replacing tokens inside ANSI escape codes,
corrupting sequences like [38;2;123;127;135m when searching for '2'.
Fix: apply highlighting to plain text before theme styling.
2026-02-01 09:50:57 +01:00
Mario Zechner
ba4a55f6d9 fix(agents): update cacheControlTtl to cacheRetention for pi-ai 0.50.9
- Update @mariozechner/pi-ai and pi-agent-core to 0.50.9
- Rename cacheControlTtl to cacheRetention with values none/short/long
- Add backwards compatibility mapping: 5m->short, 1h->long
- Remove dead OpenRouter check (uses openai-completions API)
- Default new configs to cacheRetention: short
2026-02-01 09:50:52 +01:00
xiaose
511b2c91e3 feat: mr 2026-02-01 01:11:22 -05:00
cpojer
b48d72a2b8 chore: fix lint, and format after lint to catch reformats triggered by autofixes. 2026-02-01 13:19:06 +09:00
bravostation
b4e2e746b3 /new: use agent personality in session greeting (#5706)
* Slash new: use agent personality in session greeting

Previously /new and /reset used a generic greeting prompt. Agents with
personality files (IDENTITY.md, SOUL.md, etc) would respond out of
character until the conversation got going.

Now the prompt instructs the agent to greet users as their character,
using their defined voice, mannerisms, and mood from the start.

* Auto-reply: avoid workspace references in reset prompt

* fix: avoid workspace references in reset greeting (#5706) (thanks @bravostation)

---------

Co-authored-by: MoltBot <bot@moltbot.com>
Co-authored-by: Shadow <shadow@clawd.bot>
2026-01-31 20:43:19 -06:00
Jhin
dc8a63cb8b fix: skip extension append if command already has one
Addresses review feedback - now checks path.extname() before
appending .cmd to avoid producing invalid paths like npm.cmd.cmd
2026-01-31 20:39:33 -06:00
Jhin
5c8880ed3f fix(process): resolve npm/pnpm spawn ENOENT on Windows
On Windows, non-.exe commands like npm, pnpm, yarn, npx require
their .cmd extension when using spawn(). This adds a resolveCommand()
helper that automatically appends .cmd on Windows for these commands.

Fixes #5773
2026-01-31 20:39:33 -06:00
Lalit Singh
01d76e4799 feat(routing): add thread parent binding inheritance for Discord (#3892)
* feat(routing): add thread parent binding inheritance for Discord

When a Discord thread message doesn't match a direct peer binding,
now checks if the parent channel has a binding and uses that agent.

This enables multi-agent setups where threads inherit their parent
channel's agent binding automatically.

Changes:
- Add parentPeer parameter to ResolveAgentRouteInput
- Add binding.peer.parent match type
- Resolve thread parent early in Discord preflight
- Pass parentPeer to resolveAgentRoute for threads

Fixes thread routing in Discord multi-agent configurations where
threads were incorrectly routed to the default agent instead of
inheriting from their parent channel's binding.

* ci: trigger fresh macOS runners

* Discord: inherit thread bindings in reactions

* fix: add changelog for thread parent binding (#3892) (thanks @aerolalit)

---------

Co-authored-by: Lalit Singh <lalit@clawd.bot>
Co-authored-by: OSS Agent <oss-agent@clawdbot.ai>
Co-authored-by: Shadow <shadow@clawd.bot>
2026-01-31 20:30:45 -06:00
Tak Hoffman
a393ae79d2 Merge pull request #3677 from conroywhitney/fix/1897-session-status-time-hint
fix(system-prompt): hint session_status for date/time instead of embedding it
2026-01-31 20:22:41 -06:00
Shadow
abcca0f9bd Discord: fix PK sender identity context 2026-01-31 20:20:17 -06:00
cpojer
58f4185925 fix: Failing tests due to import sorting. 2026-02-01 11:05:46 +09:00
Tak Hoffman
1aeaf811b0 Merge branch 'main' into fix/1897-session-status-time-hint 2026-01-31 19:58:05 -06:00
Shadow
8e2b17e0c5 Discord: add PluralKit sender identity resolver (#5838)
* Discord: add PluralKit sender identity resolver

* fix: resolve PluralKit sender identities (#5838) (thanks @thewilloftheshadow)
2026-01-31 19:50:06 -06:00
cpojer
147eba11fd chore: Manually fix TypeScript errors uncovered by sorting imports.
Some TypeScript checks are order dependent, and the fixed types were `any`/`unknown`, TypeScript just didn't report it before for some reason.
2026-02-01 10:24:09 +09:00
cpojer
f06dd8df06 chore: Enable "experimentalSortImports" in Oxfmt and reformat all imorts. 2026-02-01 10:03:47 +09:00
Glucksberg
34e2425b4d fix(security): restrict MEDIA path extraction to prevent LFI (#4930)
* fix(security): restrict inbound media staging to media directory

* docs: update MEDIA path guidance for security restrictions

- Update agent hint to warn against absolute/~ paths
- Update docs example to use https:// instead of /tmp/

---------

Co-authored-by: Evan Otero <evanotero@google.com>
2026-01-31 10:55:37 -08:00
Ayaan Zaidi
b5c2b1880d fix: stabilize partial streaming filters 2026-01-31 22:46:19 +05:30
Ayaan Zaidi
a64d8d2d66 fix: harden telegram streaming state 2026-01-31 22:46:19 +05:30
Ayaan Zaidi
37721ebd7c fix: restore telegram draft streaming partials 2026-01-31 22:46:19 +05:30
Tak Hoffman
9c29853014 Gateway: inject timestamps into agent/chat.send (#3705) (thanks @conroywhitney, @CashWilliams) 2026-01-31 09:47:27 -06:00
Conroy Whitney
8a5b139a9f revert: drop "Current Date:" label, keep [Wed YYYY-MM-DD HH:MM TZ]
Small model testing showed the label did not meaningfully help:
- Sub-3B models fail regardless of format
- 8B models untested with label specifically
- Frontier models never needed it

The bracket convention [Wed 2026-01-28 22:30 EST] matches existing
channel envelope format and is widely present in training data.
Saves ~2-3 tokens per message vs the labeled version.
2026-01-31 09:47:27 -06:00
Conroy Whitney
b6c8c1e89d feat: add "Current Date:" label to timestamp prefix
Changes [Wed 2026-01-28 20:30 EST] to [Current Date: Wed 2026-01-28 20:30 EST].

Tested with qwen3-1.7B: even with DOW in the timestamp, the model
ignored it and tried to compute the day using Zeller's Congruence.
The "Current Date:" semantic label is widely present in training data
and gives small models the best chance of recognizing the timestamp
as authoritative context rather than metadata to parse.

Cost: ~18 tokens per message. Prevents hallucination spirals that
burn hundreds or thousands of tokens on date derivation.
2026-01-31 09:47:27 -06:00
Conroy Whitney
a6c68e8690 feat: add 3-letter DOW prefix to injected timestamps
Changes [2026-01-28 20:30 EST] to [Wed 2026-01-28 20:30 EST].
Costs ~1 extra token but provides day-of-week for smaller models
that can't derive DOW from a date. Frontier models already handle
it, but this is cheap insurance for 7B-class models.
2026-01-31 09:47:27 -06:00
Conroy Whitney
76391bba3f refactor: use compact formatZonedTimestamp for injection
Replace verbose formatUserTime (Wednesday, January 28th, 2026 — 8:30 PM)
with the same formatZonedTimestamp used by channel envelopes (2026-01-28
20:30 EST). This:

- Saves ~4 tokens per message (~7 vs ~11)
- Uses globally unambiguous YYYY-MM-DD 24h format
- Removes 12/24h config option (always 24h, agent-facing)
- Anchors envelope detection to the actual format function — if channels
  change their timestamp format, our injection + detection change too
- Adds test that compares injection output to formatZonedTimestamp directly

Exported formatZonedTimestamp from auto-reply/envelope.ts for reuse.
2026-01-31 09:47:27 -06:00
Conroy Whitney
08886eaaa3 test: add DST boundary test for timestamp injection
Verifies that America/New_York correctly resolves to midnight for
both EST (winter, UTC-5) and EDT (summer, UTC-4) using the same
IANA timezone. Intl.DateTimeFormat handles the DST transition.
2026-01-31 09:47:27 -06:00
Conroy Whitney
bbf2205640 feat(gateway): inject timestamps into chat.send (webchat/TUI)
The chat.send handler (used by webchat and TUI) is a separate path
from the agent handler. Inject timestamp into BodyForAgent (what the
model sees) while keeping Body raw for UI display.

This completes timestamp coverage for all non-channel paths:
- agent handler: spawned subagents, sessions_send, heartbeats
- chat.send: webchat, TUI
2026-01-31 09:47:27 -06:00
Conroy Whitney
582a4e261a feat(gateway): inject timestamps into agent handler messages
Messages arriving through the gateway agent method (TUI, web, spawned
subagents, sessions_send, heartbeats) now get a timestamp prefix
automatically. This gives all agent contexts date/time awareness
without modifying the system prompt (which is cached for stability).

Channel messages (Discord, Telegram, etc.) already have timestamps
via envelope formatting in a separate code path and never reach
the agent handler, so there is no double-stamping risk.

Cron jobs also inject their own 'Current time:' prefix and are
detected and skipped.

Extracted as a pure function (injectTimestamp) with 12 unit tests
covering: timezone handling, 12/24h format, midnight boundaries,
envelope detection, cron detection, and empty messages.

Integration test verifies the agent handler wires it in correctly.

Closes #3658
Refs: #1897, #1928, #2108
2026-01-31 09:47:27 -06:00
Josh Palmer
7a6c40872d Agents: add system prompt safety guardrails (#5445)
* 🤖 agents: add system prompt safety guardrails

What:
- add safety guardrails to system prompt
- update system prompt docs
- update prompt tests

Why:
- discourage power-seeking or self-modification behavior
- clarify safety/oversight priority when conflicts arise

Tests:
- pnpm lint (pass)
- pnpm build (fails: DefaultResourceLoader missing in pi-coding-agent)
- pnpm test (not run; build failed)

* 🤖 agents: tighten safety wording for prompt guardrails

What:
- scope safety wording to system prompts/safety/tool policy changes
- document Safety inclusion in minimal prompt mode
- update safety prompt tests

Why:
- avoid blocking normal code changes or PR workflows
- keep prompt mode docs consistent with implementation

Tests:
- pnpm lint (pass)
- pnpm build (fails: DefaultResourceLoader missing in pi-coding-agent)
- pnpm test (not run; build failed)

* 🤖 docs: note safety guardrails are soft

What:
- document system prompt safety guardrails as advisory
- add security note on prompt guardrails vs hard controls

Why:
- clarify threat model and operator expectations
- avoid implying prompt text is an enforcement layer

Tests:
- pnpm lint (pass)
- pnpm build (fails: DefaultResourceLoader missing in pi-coding-agent)
- pnpm test (not run; build failed)
2026-01-31 15:50:15 +01:00
cpojer
59cfff02f6 chore: Emit TypeScript declaration files so that we can type-check the extensions folder soon. 2026-01-31 21:57:21 +09:00
Peter Steinberger
1287328b6f feat: add MiniMax OAuth plugin (#4521) (thanks @Maosghoul) 2026-01-31 12:42:45 +01:00
cpojer
76361ae3ab revert: Switch back to tsc for compiling. 2026-01-31 18:31:49 +09:00