@hybridaione/hybridclaw 0.2.3 → 0.2.6

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.
Files changed (277) hide show
  1. package/.github/workflows/ci.yml +70 -0
  2. package/.husky/pre-commit +1 -0
  3. package/CHANGELOG.md +70 -0
  4. package/CONTRIBUTING.md +33 -0
  5. package/README.md +39 -16
  6. package/SECURITY.md +17 -0
  7. package/biome.json +35 -0
  8. package/config.example.json +67 -7
  9. package/container/package-lock.json +2 -2
  10. package/container/package.json +1 -1
  11. package/container/src/approval-policy.ts +1303 -0
  12. package/container/src/browser-tools.ts +431 -136
  13. package/container/src/extensions.ts +36 -12
  14. package/container/src/hybridai-client.ts +34 -13
  15. package/container/src/index.ts +451 -109
  16. package/container/src/ipc.ts +5 -3
  17. package/container/src/token-usage.ts +20 -10
  18. package/container/src/tools.ts +599 -225
  19. package/container/src/types.ts +32 -2
  20. package/container/src/web-fetch.ts +89 -32
  21. package/dist/agent.d.ts.map +1 -1
  22. package/dist/agent.js +10 -2
  23. package/dist/agent.js.map +1 -1
  24. package/dist/audit-cli.d.ts.map +1 -1
  25. package/dist/audit-cli.js +4 -2
  26. package/dist/audit-cli.js.map +1 -1
  27. package/dist/audit-events.d.ts.map +1 -1
  28. package/dist/audit-events.js +53 -3
  29. package/dist/audit-events.js.map +1 -1
  30. package/dist/audit-trail.d.ts.map +1 -1
  31. package/dist/audit-trail.js +17 -8
  32. package/dist/audit-trail.js.map +1 -1
  33. package/dist/channels/discord/attachments.d.ts.map +1 -1
  34. package/dist/channels/discord/attachments.js +14 -7
  35. package/dist/channels/discord/attachments.js.map +1 -1
  36. package/dist/channels/discord/debounce.d.ts +9 -0
  37. package/dist/channels/discord/debounce.d.ts.map +1 -0
  38. package/dist/channels/discord/debounce.js +20 -0
  39. package/dist/channels/discord/debounce.js.map +1 -0
  40. package/dist/channels/discord/delivery.d.ts +4 -1
  41. package/dist/channels/discord/delivery.d.ts.map +1 -1
  42. package/dist/channels/discord/delivery.js +19 -3
  43. package/dist/channels/discord/delivery.js.map +1 -1
  44. package/dist/channels/discord/human-delay.d.ts +16 -0
  45. package/dist/channels/discord/human-delay.d.ts.map +1 -0
  46. package/dist/channels/discord/human-delay.js +29 -0
  47. package/dist/channels/discord/human-delay.js.map +1 -0
  48. package/dist/channels/discord/inbound.d.ts +4 -0
  49. package/dist/channels/discord/inbound.d.ts.map +1 -1
  50. package/dist/channels/discord/inbound.js +45 -4
  51. package/dist/channels/discord/inbound.js.map +1 -1
  52. package/dist/channels/discord/mentions.d.ts.map +1 -1
  53. package/dist/channels/discord/mentions.js +16 -4
  54. package/dist/channels/discord/mentions.js.map +1 -1
  55. package/dist/channels/discord/presence.d.ts +33 -0
  56. package/dist/channels/discord/presence.d.ts.map +1 -0
  57. package/dist/channels/discord/presence.js +111 -0
  58. package/dist/channels/discord/presence.js.map +1 -0
  59. package/dist/channels/discord/rate-limiter.d.ts +14 -0
  60. package/dist/channels/discord/rate-limiter.d.ts.map +1 -0
  61. package/dist/channels/discord/rate-limiter.js +49 -0
  62. package/dist/channels/discord/rate-limiter.js.map +1 -0
  63. package/dist/channels/discord/reactions.d.ts +38 -0
  64. package/dist/channels/discord/reactions.d.ts.map +1 -0
  65. package/dist/channels/discord/reactions.js +151 -0
  66. package/dist/channels/discord/reactions.js.map +1 -0
  67. package/dist/channels/discord/runtime.d.ts +6 -3
  68. package/dist/channels/discord/runtime.d.ts.map +1 -1
  69. package/dist/channels/discord/runtime.js +621 -125
  70. package/dist/channels/discord/runtime.js.map +1 -1
  71. package/dist/channels/discord/stream.d.ts +4 -1
  72. package/dist/channels/discord/stream.d.ts.map +1 -1
  73. package/dist/channels/discord/stream.js +16 -8
  74. package/dist/channels/discord/stream.js.map +1 -1
  75. package/dist/channels/discord/tool-actions.d.ts.map +1 -1
  76. package/dist/channels/discord/tool-actions.js +24 -12
  77. package/dist/channels/discord/tool-actions.js.map +1 -1
  78. package/dist/channels/discord/typing.d.ts +15 -0
  79. package/dist/channels/discord/typing.d.ts.map +1 -0
  80. package/dist/channels/discord/typing.js +106 -0
  81. package/dist/channels/discord/typing.js.map +1 -0
  82. package/dist/chunk.d.ts.map +1 -1
  83. package/dist/chunk.js +4 -2
  84. package/dist/chunk.js.map +1 -1
  85. package/dist/cli.js +47 -22
  86. package/dist/cli.js.map +1 -1
  87. package/dist/config.d.ts +19 -0
  88. package/dist/config.d.ts.map +1 -1
  89. package/dist/config.js +103 -18
  90. package/dist/config.js.map +1 -1
  91. package/dist/container-runner.d.ts.map +1 -1
  92. package/dist/container-runner.js +58 -26
  93. package/dist/container-runner.js.map +1 -1
  94. package/dist/container-setup.d.ts.map +1 -1
  95. package/dist/container-setup.js +10 -9
  96. package/dist/container-setup.js.map +1 -1
  97. package/dist/conversation.d.ts +2 -2
  98. package/dist/conversation.d.ts.map +1 -1
  99. package/dist/conversation.js +1 -1
  100. package/dist/conversation.js.map +1 -1
  101. package/dist/db.d.ts +118 -2
  102. package/dist/db.d.ts.map +1 -1
  103. package/dist/db.js +1568 -50
  104. package/dist/db.js.map +1 -1
  105. package/dist/delegation-manager.d.ts.map +1 -1
  106. package/dist/delegation-manager.js +3 -2
  107. package/dist/delegation-manager.js.map +1 -1
  108. package/dist/gateway-client.d.ts +2 -2
  109. package/dist/gateway-client.d.ts.map +1 -1
  110. package/dist/gateway-client.js +10 -4
  111. package/dist/gateway-client.js.map +1 -1
  112. package/dist/gateway-service.d.ts +3 -3
  113. package/dist/gateway-service.d.ts.map +1 -1
  114. package/dist/gateway-service.js +563 -73
  115. package/dist/gateway-service.js.map +1 -1
  116. package/dist/gateway-types.d.ts +24 -0
  117. package/dist/gateway-types.d.ts.map +1 -1
  118. package/dist/gateway-types.js.map +1 -1
  119. package/dist/gateway.js +179 -24
  120. package/dist/gateway.js.map +1 -1
  121. package/dist/health.d.ts.map +1 -1
  122. package/dist/health.js +20 -10
  123. package/dist/health.js.map +1 -1
  124. package/dist/heartbeat.d.ts +4 -0
  125. package/dist/heartbeat.d.ts.map +1 -1
  126. package/dist/heartbeat.js +48 -20
  127. package/dist/heartbeat.js.map +1 -1
  128. package/dist/hybridai-bots.d.ts.map +1 -1
  129. package/dist/hybridai-bots.js +4 -2
  130. package/dist/hybridai-bots.js.map +1 -1
  131. package/dist/instruction-approval-audit.d.ts.map +1 -1
  132. package/dist/instruction-approval-audit.js.map +1 -1
  133. package/dist/instruction-integrity.d.ts.map +1 -1
  134. package/dist/instruction-integrity.js +8 -2
  135. package/dist/instruction-integrity.js.map +1 -1
  136. package/dist/ipc.d.ts.map +1 -1
  137. package/dist/ipc.js +6 -1
  138. package/dist/ipc.js.map +1 -1
  139. package/dist/logger.js.map +1 -1
  140. package/dist/memory-consolidation.d.ts +17 -0
  141. package/dist/memory-consolidation.d.ts.map +1 -0
  142. package/dist/memory-consolidation.js +25 -0
  143. package/dist/memory-consolidation.js.map +1 -0
  144. package/dist/memory-service.d.ts +200 -0
  145. package/dist/memory-service.d.ts.map +1 -0
  146. package/dist/memory-service.js +294 -0
  147. package/dist/memory-service.js.map +1 -0
  148. package/dist/mount-security.d.ts.map +1 -1
  149. package/dist/mount-security.js +31 -7
  150. package/dist/mount-security.js.map +1 -1
  151. package/dist/observability-ingest.d.ts.map +1 -1
  152. package/dist/observability-ingest.js +32 -11
  153. package/dist/observability-ingest.js.map +1 -1
  154. package/dist/onboarding.d.ts.map +1 -1
  155. package/dist/onboarding.js +32 -9
  156. package/dist/onboarding.js.map +1 -1
  157. package/dist/proactive-policy.d.ts.map +1 -1
  158. package/dist/proactive-policy.js +2 -1
  159. package/dist/proactive-policy.js.map +1 -1
  160. package/dist/prompt-hooks.d.ts.map +1 -1
  161. package/dist/prompt-hooks.js +9 -7
  162. package/dist/prompt-hooks.js.map +1 -1
  163. package/dist/runtime-config.d.ts +98 -1
  164. package/dist/runtime-config.d.ts.map +1 -1
  165. package/dist/runtime-config.js +477 -23
  166. package/dist/runtime-config.js.map +1 -1
  167. package/dist/scheduled-task-runner.d.ts +1 -0
  168. package/dist/scheduled-task-runner.d.ts.map +1 -1
  169. package/dist/scheduled-task-runner.js +29 -10
  170. package/dist/scheduled-task-runner.js.map +1 -1
  171. package/dist/scheduler.d.ts +43 -4
  172. package/dist/scheduler.d.ts.map +1 -1
  173. package/dist/scheduler.js +530 -56
  174. package/dist/scheduler.js.map +1 -1
  175. package/dist/session-export.d.ts +26 -0
  176. package/dist/session-export.d.ts.map +1 -0
  177. package/dist/session-export.js +149 -0
  178. package/dist/session-export.js.map +1 -0
  179. package/dist/session-maintenance.d.ts.map +1 -1
  180. package/dist/session-maintenance.js +75 -13
  181. package/dist/session-maintenance.js.map +1 -1
  182. package/dist/session-transcripts.d.ts.map +1 -1
  183. package/dist/session-transcripts.js.map +1 -1
  184. package/dist/side-effects.d.ts.map +1 -1
  185. package/dist/side-effects.js +14 -2
  186. package/dist/side-effects.js.map +1 -1
  187. package/dist/skills-guard.d.ts.map +1 -1
  188. package/dist/skills-guard.js +893 -130
  189. package/dist/skills-guard.js.map +1 -1
  190. package/dist/skills.d.ts +5 -0
  191. package/dist/skills.d.ts.map +1 -1
  192. package/dist/skills.js +29 -15
  193. package/dist/skills.js.map +1 -1
  194. package/dist/token-efficiency.d.ts.map +1 -1
  195. package/dist/token-efficiency.js.map +1 -1
  196. package/dist/tui.js +92 -11
  197. package/dist/tui.js.map +1 -1
  198. package/dist/types.d.ts +146 -0
  199. package/dist/types.d.ts.map +1 -1
  200. package/dist/types.js +24 -1
  201. package/dist/types.js.map +1 -1
  202. package/dist/update.d.ts.map +1 -1
  203. package/dist/update.js +42 -14
  204. package/dist/update.js.map +1 -1
  205. package/dist/workspace.d.ts.map +1 -1
  206. package/dist/workspace.js +49 -9
  207. package/dist/workspace.js.map +1 -1
  208. package/docs/chat.html +9 -3
  209. package/docs/index.html +37 -13
  210. package/package.json +8 -2
  211. package/src/agent.ts +16 -3
  212. package/src/audit-cli.ts +44 -16
  213. package/src/audit-events.ts +69 -5
  214. package/src/audit-trail.ts +41 -15
  215. package/src/channels/discord/attachments.ts +81 -27
  216. package/src/channels/discord/debounce.ts +25 -0
  217. package/src/channels/discord/delivery.ts +57 -13
  218. package/src/channels/discord/human-delay.ts +48 -0
  219. package/src/channels/discord/inbound.ts +60 -7
  220. package/src/channels/discord/mentions.ts +42 -18
  221. package/src/channels/discord/presence.ts +148 -0
  222. package/src/channels/discord/rate-limiter.ts +58 -0
  223. package/src/channels/discord/reactions.ts +211 -0
  224. package/src/channels/discord/runtime.ts +979 -182
  225. package/src/channels/discord/stream.ts +73 -27
  226. package/src/channels/discord/tool-actions.ts +78 -37
  227. package/src/channels/discord/typing.ts +140 -0
  228. package/src/chunk.ts +12 -4
  229. package/src/cli.ts +141 -56
  230. package/src/config.ts +188 -36
  231. package/src/container-runner.ts +132 -42
  232. package/src/container-setup.ts +57 -22
  233. package/src/conversation.ts +9 -7
  234. package/src/db.ts +2217 -84
  235. package/src/delegation-manager.ts +6 -2
  236. package/src/gateway-client.ts +41 -17
  237. package/src/gateway-service.ts +931 -208
  238. package/src/gateway-types.ts +33 -0
  239. package/src/gateway.ts +321 -48
  240. package/src/health.ts +66 -26
  241. package/src/heartbeat.ts +84 -22
  242. package/src/hybridai-bots.ts +14 -5
  243. package/src/instruction-approval-audit.ts +4 -1
  244. package/src/instruction-integrity.ts +30 -9
  245. package/src/ipc.ts +23 -5
  246. package/src/logger.ts +4 -1
  247. package/src/memory-consolidation.ts +41 -0
  248. package/src/memory-service.ts +606 -0
  249. package/src/mount-security.ts +58 -13
  250. package/src/observability-ingest.ts +134 -35
  251. package/src/onboarding.ts +126 -35
  252. package/src/proactive-policy.ts +3 -1
  253. package/src/prompt-hooks.ts +40 -17
  254. package/src/runtime-config.ts +1055 -117
  255. package/src/scheduled-task-runner.ts +63 -11
  256. package/src/scheduler.ts +683 -60
  257. package/src/session-export.ts +196 -0
  258. package/src/session-maintenance.ts +125 -22
  259. package/src/session-transcripts.ts +12 -3
  260. package/src/side-effects.ts +28 -5
  261. package/src/skills-guard.ts +1067 -219
  262. package/src/skills.ts +163 -65
  263. package/src/token-efficiency.ts +31 -9
  264. package/src/tui.ts +166 -25
  265. package/src/types.ts +195 -2
  266. package/src/update.ts +79 -23
  267. package/src/workspace.ts +63 -11
  268. package/tests/approval-policy.test.ts +224 -0
  269. package/tests/discord.basic.test.ts +31 -3
  270. package/tests/discord.human-presence.test.ts +85 -0
  271. package/tests/gateway-service.media-routing.test.ts +8 -2
  272. package/tests/memory-service.test.ts +1114 -0
  273. package/tests/token-efficiency.basic.test.ts +8 -2
  274. package/vitest.e2e.config.ts +3 -1
  275. package/vitest.integration.config.ts +3 -1
  276. package/vitest.live.config.ts +3 -1
  277. package/vitest.unit.config.ts +9 -0
@@ -0,0 +1,70 @@
1
+ name: CI
2
+
3
+ on:
4
+ pull_request:
5
+ push:
6
+ branches:
7
+ - main
8
+
9
+ jobs:
10
+ unit-tests:
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - name: Checkout
14
+ uses: actions/checkout@v4
15
+
16
+ - name: Setup Node.js
17
+ uses: actions/setup-node@v4
18
+ with:
19
+ node-version: 22
20
+ cache: npm
21
+
22
+ - name: Install dependencies
23
+ run: npm install
24
+
25
+ - name: Install container dependencies
26
+ run: npm run setup
27
+
28
+ - name: Biome check (changed files)
29
+ shell: bash
30
+ run: |
31
+ set -euo pipefail
32
+
33
+ if [[ "${{ github.event_name }}" == "pull_request" ]]; then
34
+ BASE_SHA="${{ github.event.pull_request.base.sha }}"
35
+ else
36
+ BASE_SHA="${{ github.event.before }}"
37
+ fi
38
+ HEAD_SHA="${{ github.sha }}"
39
+
40
+ FILES=()
41
+ if [[ -z "${BASE_SHA}" || "${BASE_SHA}" == "0000000000000000000000000000000000000000" ]]; then
42
+ while IFS= read -r file; do
43
+ [[ -n "${file}" ]] && FILES+=("${file}")
44
+ done < <(git ls-files src | grep -E '^src/.*\.(ts|tsx|js|jsx)$' || true)
45
+ else
46
+ while IFS= read -r file; do
47
+ [[ -n "${file}" ]] && FILES+=("${file}")
48
+ done < <(
49
+ git diff --name-only --diff-filter=ACMRT "${BASE_SHA}" "${HEAD_SHA}" \
50
+ | grep -E '^src/.*\.(ts|tsx|js|jsx)$' || true
51
+ )
52
+ fi
53
+
54
+ if [[ "${#FILES[@]}" -eq 0 ]]; then
55
+ echo "No changed source files for Biome check."
56
+ exit 0
57
+ fi
58
+
59
+ echo "Running Biome on changed files:"
60
+ printf ' - %s\n' "${FILES[@]}"
61
+ npx biome check "${FILES[@]}"
62
+
63
+ - name: TypeScript lint (root)
64
+ run: npm run lint
65
+
66
+ - name: TypeScript lint (container)
67
+ run: npm --prefix container run lint
68
+
69
+ - name: Unit tests with coverage
70
+ run: npx vitest run --coverage --config vitest.unit.config.ts
@@ -0,0 +1 @@
1
+ npx biome check --write --staged
package/CHANGELOG.md CHANGED
@@ -2,12 +2,82 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ No unreleased changes.
6
+
7
+ ## [0.2.6](https://github.com/HybridAIOne/hybridclaw/tree/v0.2.6)
8
+
5
9
  ### Added
6
10
 
11
+ - **Memory consolidation runtime controls**: Added `memory.decayRate` and `memory.consolidationIntervalHours` config support, plus gateway-managed periodic consolidation scheduling.
12
+ - **Scheduler job runtime metadata**: Added optional `scheduler.jobs[].name` / `description`, persisted `nextRunAt`, and scheduler status surfaces for runtime visibility.
13
+ - **Scheduler status API typing**: Added gateway status typing for scheduler jobs (`id`, `name`, `description`, `enabled`, `lastRun`, `lastStatus`, `nextRunAt`, `disabled`, `consecutiveErrors`).
14
+ - **CLI version flag**: Added top-level `hybridclaw --version` / `-v`.
15
+ - **Memory substrate architecture**: Added full SQLite-backed memory layers for structured KV (`kv_store`), semantic memory (`semantic_memories` with optional embeddings), knowledge graph (`entities` + `relations`), canonical cross-channel sessions, and usage events.
16
+ - **Knowledge graph model + APIs**: Added typed entity/relation enums (with custom value support), relation traversal query APIs, and normalized serialization/parsing for graph properties.
17
+ - **Canonical cross-channel sessions**: Added `canonical_sessions` persistence keyed by `(agent_id, user_id)` with rolling window retention, compaction summaries, and current-session exclusion support at recall time.
18
+ - **Usage aggregation layer**: Added `usage_events` persistence plus aggregation queries (daily/monthly totals, by-agent, by-model, and daily breakdown) and gateway `usage` command surface.
19
+ - **JSONL session export tools**: Added manual `export session [sessionId]` command and automatic compaction exports to `.session-exports/` for debugging and human review.
20
+ - **Memory service abstraction**: Added `MemoryService` + pluggable backend interface for session/memory access, semantic recall, knowledge graph APIs, canonical recall, and compaction helpers.
21
+ - **Memory consolidation engine**: Added consolidation engine + report model for periodic semantic decay operations.
22
+ - **Discord command namespace expansion**: Added `usage` and `export` command parsing support.
23
+ - **Coverage expansion**: Added comprehensive memory/DB unit tests (`tests/memory-service.test.ts`) and Discord parsing coverage for `usage`.
24
+
7
25
  ### Changed
8
26
 
27
+ - **Session compaction controls**: Added token-budget compaction knobs (`sessionCompaction.tokenBudget`, `sessionCompaction.budgetRatio`) and exposed them in config normalization + example config.
28
+ - **Gateway runtime scheduling**: Gateway now starts/restarts memory consolidation when runtime config changes and stops it cleanly on shutdown.
29
+ - **Heartbeat memory path**: Heartbeat turns now use `MemoryService` for session retrieval, prompt-memory context, and turn persistence.
30
+ - **Scheduler observability depth**: Scheduler now tracks and persists `nextRunAt`, includes job labels in logs, and keeps runtime state synchronized for status consumers.
31
+ - **Approval UX wording**: Red-tier approval prompt now instructs users to deny with `no` (alias `4`) instead of `skip`.
32
+ - **Prompt wording clarity**: Session summary hook text now explicitly frames memory as compressed/recalled durable context.
33
+ - **Runtime hygiene sweep**: Applied project-wide lint/import-order/format cleanup across gateway/runtime modules (audit, Discord channels, container runtime, onboarding, observability, skills/security, and Vitest configs) without behavior changes.
34
+ - **Schema migrations**: Replaced ad-hoc bootstrapping with versioned `user_version` migrations (including forward-version guard) and migration records.
35
+ - **Memory context injection**: Gateway prompt assembly now includes canonical cross-channel recall (summary + recent messages) while excluding the current session to avoid duplicate context.
36
+ - **SQLite migration baseline**: Introduced schema version `4` with explicit `user_version` migrations for canonical and usage tables.
37
+ - **SQLite concurrency defaults**: Database initialization now enforces `PRAGMA journal_mode=WAL` and `PRAGMA busy_timeout=5000` for better concurrent read behavior.
38
+ - **Gateway memory integration**: Gateway flows now route session/history/memory operations through `MemoryService`, append canonical turns after successful responses, and record usage events from model telemetry.
39
+ - **Compaction instrumentation**: Session maintenance now exports compacted snapshots to JSONL and records richer compaction diagnostics.
40
+ - **Scheduled usage accounting**: Isolated scheduled task runs now record usage events for aggregation parity with interactive turns.
41
+
42
+ ## [0.2.5](https://github.com/HybridAIOne/hybridclaw/tree/v0.2.5)
43
+
44
+ ### Added
45
+
46
+ - **Trusted-coworker approval flow**: Added green/yellow/red approval runtime with contextual red prompts and support for `yes`, `yes for session`, `yes for agent`, and `skip` (including `1/2/3/4` shorthand replies).
47
+ - **TUI approval selector**: Added an interactive TUI approval menu for pending red actions to reduce reply friction while preserving explicit consent.
48
+ - **Agent-scoped approval trust persistence**: Added durable per-agent trust state in `.hybridclaw/approval-trust.json` for `yes for agent` decisions.
49
+
50
+ ### Changed
51
+
52
+ - **Approval policy location**: Moved policy configuration from `.claude/policy.yaml` to `.hybridclaw/policy.yaml` and updated workspace bootstrap seeding/docs accordingly.
53
+ - **Yellow-tier timing**: Increased yellow implicit approval countdown from 2s to 5s and simplified yellow narration text.
54
+ - **CI quality gates**: Updated CI to install container dependencies and enforce changed-file Biome checks plus root/container TypeScript lint before running unit tests.
55
+
9
56
  ### Fixed
10
57
 
58
+ - **Pinned red trust behavior**: Pinned-red actions now correctly reject session/agent trust promotion and fall back to one-time approval only.
59
+ - **Approval audit classification**: Approval audit events now mark `approved_agent` decisions as approved and include richer approval reason metadata.
60
+
61
+ ## [0.2.4](https://github.com/HybridAIOne/hybridclaw/tree/v0.2.4)
62
+
63
+ ### Added
64
+
65
+ - **Dynamic Discord self-presence states**: Added health-aware presence management that maps runtime state to Discord status (`online`, `idle`, `dnd`) and applies maintenance `invisible` presence during shutdown.
66
+ - **Config-backed proactive scheduler jobs**: Added `scheduler.jobs[]` runtime jobs with `cron`/`every`/`at` schedules, `agent_turn`/`system_event` actions, and `channel`/`last-channel`/`webhook` delivery targets.
67
+ - **Scheduler metadata persistence for config jobs**: Added atomic persisted state at `data/scheduler-jobs-state.json` for per-job `lastRun`, `lastStatus`, `consecutiveErrors`, `disabled`, and one-shot completion tracking.
68
+ - **Discord humanization behaviors**: Added time-of-day/weekend pacing, conversation cooldown scaling after long back-and-forth, selective silence in active group channels, short-ack read-without-reply reactions, and reconnect startup staggering.
69
+
70
+ ### Changed
71
+
72
+ - **Scheduler execution model**: Scheduler now co-schedules legacy DB tasks and config jobs in one timer loop with consistent due-time arming and persisted per-job error recovery behavior.
73
+ - **Discord inbound debounce behavior**: Debounce batching now skips immediate flush delays for commands/media and keeps per-channel debounce tuning for normal chat messages.
74
+ - **Documentation sync for Discord humanization/scheduler controls**: Updated README and site docs to cover health-driven presence, proactive job config, and human-like reply pacing behavior.
75
+
76
+ ### Fixed
77
+
78
+ - **Uncanny Discord response timing**: Reduced robotic burst behavior by adding natural delay variation over long exchanges and reconnect bursts.
79
+ - **Over-eager group replies**: Free-mode channels now avoid unnecessary follow-up replies when another participant likely already answered.
80
+
11
81
  ## [0.2.3](https://github.com/HybridAIOne/hybridclaw/tree/v0.2.3)
12
82
 
13
83
  ### Added
@@ -0,0 +1,33 @@
1
+ # Contributing
2
+
3
+ ## Development setup
4
+
5
+ ```bash
6
+ npm install
7
+ ```
8
+
9
+ `npm install` runs the `prepare` script and installs Husky git hooks.
10
+
11
+ ## Code quality checks
12
+
13
+ ```bash
14
+ # TypeScript checks
15
+ npm run typecheck
16
+ npm run lint
17
+
18
+ # Biome (lint + formatting + import sorting)
19
+ npm run check
20
+
21
+ # Apply Biome fixes to src
22
+ npm run format
23
+ ```
24
+
25
+ ## Git hooks
26
+
27
+ This repo uses Husky with a pre-commit hook:
28
+
29
+ ```bash
30
+ npx biome check --write --staged
31
+ ```
32
+
33
+ Before committing, stage your files (`git add ...`). The hook validates and auto-formats staged changes.
package/README.md CHANGED
@@ -11,15 +11,7 @@ npm install -g @hybridaione/hybridclaw
11
11
  hybridclaw onboarding
12
12
  ```
13
13
 
14
- Latest release: [v0.2.3](https://github.com/HybridAIOne/hybridclaw/releases/tag/v0.2.3)
15
-
16
- ## What's new in v0.2.3
17
-
18
- - Added Discord guild channel policy controls with typed config: `discord.groupPolicy`, `discord.freeResponseChannels`, and `discord.guilds.<guildId>.channels.<channelId>.mode`
19
- - Added `/channel-mode` slash command to switch a channel between `off`, `mention`, and `free`
20
- - Added `!claw channel mode` and `!claw channel policy` command flows for in-chat policy changes
21
- - Enforced channel mode/policy in Discord trigger logic while keeping prefixed commands available
22
- - Updated status/activation labeling to reflect allowlist/disabled/mixed channel policy modes
14
+ Latest release: [v0.2.6](https://github.com/HybridAIOne/hybridclaw/releases/tag/v0.2.6)
23
15
 
24
16
  ## HybridAI Advantage
25
17
 
@@ -32,7 +24,7 @@ Latest release: [v0.2.3](https://github.com/HybridAIOne/hybridclaw/releases/tag/
32
24
 
33
25
  ## Architecture
34
26
 
35
- - **Gateway service** (Node.js) — shared message/command handlers, SQLite persistence, scheduler, heartbeat, web/API, and optional Discord integration
27
+ - **Gateway service** (Node.js) — shared message/command handlers, SQLite persistence (KV + semantic + knowledge graph + canonical sessions + usage events), scheduler, heartbeat, web/API, and optional Discord integration
36
28
  - **TUI client** — thin client over HTTP (`/api/chat`, `/api/command`)
37
29
  - **Container** (Docker, ephemeral) — HybridAI API client, sandboxed tool executor, and preinstalled browser automation runtime
38
30
  - Communication via file-based IPC (input.json / output.json)
@@ -84,14 +76,18 @@ HybridClaw best-in-class capabilities:
84
76
 
85
77
  - explicit trust-model acceptance during onboarding (recorded in `config.json`)
86
78
  - typed `config.json` runtime settings with defaults, validation, and hot reload
87
- - formal prompt hook orchestration (`bootstrap`, `memory`, `safety`)
88
- - Discord conversational UX: edit-in-place streaming responses, fence-safe chunking beyond Discord's 2000-char limit, typing keepalive, debounce batching, reply-chain-aware context, and concise attachment-first screenshot replies
79
+ - formal prompt hook orchestration (`bootstrap`, `memory`, `safety`, `proactivity`)
80
+ - layered memory substrate: structured KV, semantic memory, typed knowledge graph entities/relations, canonical cross-channel sessions, and usage event persistence
81
+ - lightweight DB evolution and concurrency hardening via `PRAGMA user_version` migrations, `journal_mode=WAL`, and `busy_timeout=5000`
82
+ - Discord conversational UX: edit-in-place streaming responses, fence-safe chunking beyond Discord's 2000-char limit, phase-aware typing/reactions, adaptive debounce batching, per-user rate limits, health-driven self-presence, reply-chain-aware context, concise attachment-first screenshot replies, and humanized pacing (time-of-day slowdown, cooldown scaling, selective silence, read-without-reply, startup staggering)
89
83
  - token-efficient context assembly: per-message history truncation, hard history budgets with head/tail preservation, and head/tail truncation for oversized bootstrap files
90
84
  - runtime self-awareness in prompts: exact HybridClaw version/date, model, and runtime host metadata injected each turn for reliable "what version/model are you?" answers
91
85
  - proactive runtime layer with active-hours gating, push delegation (`single`/`parallel`/`chain`), depth-aware tool policy, and retry controls
86
+ - trusted-coworker approval model for tool execution: Green (`just run`), Yellow (`narrate + 5s interrupt window`), Red (`explicit approval`) with `yes` (once), `yes for session`, `yes for agent`, and explicit deny (`no`, also `4`) plus pinned-red protections
92
87
  - structured audit trail: append-only hash-chained wire logs (`data/audit/<session>/wire.jsonl`) with tamper-evident immutability, normalized SQLite audit tables, and verification/search CLI commands
93
88
  - observability export: incremental `events:batch` forwarding with durable cursor tracking and bot-scoped ingest token lifecycle via `ingest-token:ensure`
94
89
  - model token telemetry in audit/observability events (`model.usage`) with API usage + deterministic fallback estimates
90
+ - built-in usage aggregation (`usage summary|daily|monthly|model`) plus JSONL session exports (`export session [sessionId]`) for cost/debug visibility
95
91
  - gateway lifecycle controls: managed + unmanaged restart/stop flows with graceful shutdown fallback paths
96
92
  - instruction-integrity approval flow: core instruction docs (`AGENTS.md`, `SECURITY.md`, `TRUST_MODEL.md`) are hash-verified against a local approved baseline before TUI start
97
93
 
@@ -103,13 +99,32 @@ HybridClaw uses typed runtime config in `config.json` (auto-created on first run
103
99
  - Runtime watches `config.json` and hot-reloads most settings (model defaults, heartbeat, prompt hooks, limits, etc.)
104
100
  - `discord.guildMembersIntent` enables richer guild member context and better `@name` mention resolution in replies (requires enabling **Server Members Intent** in Discord Developer Portal)
105
101
  - `discord.presenceIntent` enables Discord presence events (requires enabling **Presence Intent** in Discord Developer Portal)
106
- - `discord.respondToAllMessages` changes guild trigger behavior: `false` (default) replies only on mention/`!claw`; `true` replies to every user message in the channel
102
+ - `discord.respondToAllMessages` is a global fallback for open-policy guild channels without explicit mode config (`false` mention-gated, `true` free-response)
107
103
  - `discord.commandUserId` restricts `!claw <command>` admin commands to a single Discord user ID (all other messages still use normal chat handling)
108
104
  - `discord.commandsOnly` optional hard mode: if `true`, the bot ignores non-`!claw` messages and only accepts prefixed commands (optionally limited by `discord.commandUserId`)
109
105
  - `discord.groupPolicy` controls guild channel scope: `open` (default), `allowlist`, or `disabled`
110
106
  - `discord.freeResponseChannels` is a Hermes-style channel ID list that gets free-response behavior while other channels remain mention-gated
111
- - `discord.guilds.<guildId>.channels.<channelId>.mode` sets per-channel behavior to `off`, `mention`, or `free` (works with `allowlist` policy)
112
- - Discord slash commands: `/status` and `/channel-mode <off|mention|free>` (ephemeral replies)
107
+ - `discord.humanDelay` controls natural delays between multi-part messages (`off|natural|custom`)
108
+ - `discord.typingMode` controls typing indicator lifecycle (`instant|thinking|streaming|never`)
109
+ - `discord.presence.*` enables dynamic self-presence health states (healthy/degraded/exhausted mapped to `online|idle|dnd`, plus maintenance `invisible` during shutdown)
110
+ - `discord.lifecycleReactions.*` enables phase emoji transitions (`queued|thinking|toolUse|streaming|done|error`)
111
+ - approval policy layer is configured via `.hybridclaw/policy.yaml` (`approval.pinned_red`, `workspace_fence`, pending/timeout controls, audit toggles)
112
+ - `discord.ackReaction`, `discord.ackReactionScope`, and `discord.removeAckAfterReply` control acknowledgment reaction behavior
113
+ - `discord.debounceMs` controls default inbound debounce; channel overrides can tune noisy channels
114
+ - `discord.rateLimitPerUser` and `discord.rateLimitExemptRoles` enforce per-user sliding-window limits
115
+ - `discord.suppressPatterns` blocks auto-reply triggers for suppression terms (case-insensitive)
116
+ - `discord.maxConcurrentPerChannel` limits concurrent in-flight runs per channel
117
+ - `discord.guilds.<guildId>.defaultMode` sets that guild's fallback mode in `open` policy (`mention` recommended)
118
+ - `discord.guilds.<guildId>.channels.<channelId>.*` supports per-channel mode and behavior overrides (`mode`, `typingMode`, `debounceMs`, `ackReaction*`, `humanDelay`, `rateLimitPerUser`, `suppressPatterns`, `maxConcurrentPerChannel`)
119
+ - `scheduler.jobs[]` defines config-backed proactive jobs with `schedule.kind` (`cron|every|at`), `action.kind` (`agent_turn|system_event`), and delivery targets (`channel|last-channel|webhook`)
120
+ - `scheduler.jobs[].name` / `scheduler.jobs[].description` add optional human-readable labels for status/log output; runtime status persists `nextRunAt`
121
+ - Config scheduler job metadata (last status, consecutive errors, one-shot completion) persists atomically in `data/scheduler-jobs-state.json`
122
+ - Config scheduler jobs auto-disable after repeated failures (5 consecutive errors) and one-shot jobs retry on a bounded interval until successful
123
+ - `memory.decayRate` and `memory.consolidationIntervalHours` control semantic-memory consolidation intensity/cadence
124
+ - `sessionCompaction.tokenBudget` and `sessionCompaction.budgetRatio` tune compaction token budgeting behavior
125
+ - Built-in Discord humanization behaviors include night/weekend pacing, post-exchange cooldown scaling (after 5+ exchanges, reset after 20 minutes idle), selective silence in active free-mode channels, short-ack read reactions, and reconnect staggered dequeue
126
+ - Per-guild/per-channel mode takes precedence over `discord.respondToAllMessages`
127
+ - Discord slash commands: `/status`, `/channel-mode <off|mention|free>`, and `/channel-policy <open|allowlist|disabled>` (ephemeral replies)
113
128
  - `skills.extraDirs` adds additional enterprise/shared skill roots (lowest precedence tier)
114
129
  - `proactive.*` controls autonomous behavior (`activeHours`, `delegation`, `autoRetry`, `ralph`)
115
130
  - `proactive.ralph.maxIterations` enables Ralph loop (`0` off, `-1` unlimited, `>0` extra autonomous iterations before forcing completion)
@@ -343,6 +358,9 @@ HybridClaw also supports automatic session compaction with pre-compaction memory
343
358
 
344
359
  - when a session gets long, old turns are summarized into `session_summary`
345
360
  - before compaction, the agent gets a `memory`-only flush turn to persist durable notes
361
+ - each `(agent_id, user_id)` pair also maintains a canonical cross-channel session for continuity across channels
362
+ - canonical context injection includes compacted summary + recent cross-channel messages (excluding the current live session)
363
+ - compaction writes JSONL exports to `<workspace>/.session-exports/` for human-readable debugging
346
364
 
347
365
  System prompt assembly is handled by a formal hook pipeline:
348
366
 
@@ -385,6 +403,7 @@ Test layout and scopes:
385
403
 
386
404
  CLI runtime commands:
387
405
 
406
+ - `hybridclaw --version` / `-v` — Print installed HybridClaw version
388
407
  - `hybridclaw gateway start [--foreground]` — Start gateway (backend by default; foreground with flag)
389
408
  - `hybridclaw gateway restart [--foreground]` — Restart managed gateway backend process
390
409
  - `hybridclaw gateway stop` — Stop managed gateway backend process
@@ -406,7 +425,11 @@ In Discord, use `!claw help` to see all commands. Key ones:
406
425
  - `!claw audit verify [sessionId]` — Verify audit hash chain integrity
407
426
  - `!claw audit search <query>` — Search structured audit history
408
427
  - `!claw audit approvals [n] [--denied]` — Show policy approval decisions
409
- - `!claw schedule add "<cron>" <prompt>`Add scheduled task
428
+ - `!claw usage [summary|daily|monthly|model [daily|monthly] [agentId]]`Show token/cost aggregates
429
+ - `!claw export session [sessionId]` — Export session snapshot as JSONL
430
+ - `!claw schedule add "<cron>" <prompt>` — Add cron scheduled task
431
+ - `!claw schedule add at "<ISO time>" <prompt>` — Add one-shot task
432
+ - `!claw schedule add every <ms> <prompt>` — Add interval task
410
433
 
411
434
  ## Project structure
412
435
 
package/SECURITY.md CHANGED
@@ -40,6 +40,23 @@ Before tool execution, HybridClaw applies policy hooks that block known dangerou
40
40
 
41
41
  Implementation: [container/src/extensions.ts](./container/src/extensions.ts)
42
42
 
43
+ ### 2.1) Trusted-Coworker Approvals
44
+
45
+ Tool actions are risk-tiered at runtime:
46
+
47
+ - Green: execute silently (read/search/status checks)
48
+ - Yellow: execute with narrated intent and a short interrupt window
49
+ - Red: explicit user approval required (`yes` / `yes for session` / `yes for agent` / `skip`, or `1/2/3/4`)
50
+
51
+ The policy layer is repo-controlled through `.hybridclaw/policy.yaml`:
52
+
53
+ - `approval.pinned_red` (never auto-promoted high-risk actions)
54
+ - `approval.workspace_fence` (no writes outside workspace fence)
55
+ - `approval.max_pending_approvals` and `approval.approval_timeout_secs`
56
+ - `audit.log_all_red` and `audit.log_denials`
57
+
58
+ Implementation: [container/src/approval-policy.ts](./container/src/approval-policy.ts)
59
+
43
60
  ### 3) Container Isolation
44
61
 
45
62
  Tool execution runs inside Docker with sandbox constraints:
package/biome.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "$schema": "https://biomejs.dev/schemas/2.4.5/schema.json",
3
+ "vcs": {
4
+ "enabled": true,
5
+ "clientKind": "git",
6
+ "useIgnoreFile": true
7
+ },
8
+ "files": {
9
+ "includes": ["**", "!!**/dist"]
10
+ },
11
+ "formatter": {
12
+ "enabled": true,
13
+ "indentStyle": "space",
14
+ "indentWidth": 2
15
+ },
16
+ "linter": {
17
+ "enabled": true,
18
+ "rules": {
19
+ "recommended": true
20
+ }
21
+ },
22
+ "javascript": {
23
+ "formatter": {
24
+ "quoteStyle": "single"
25
+ }
26
+ },
27
+ "assist": {
28
+ "enabled": true,
29
+ "actions": {
30
+ "source": {
31
+ "organizeImports": "on"
32
+ }
33
+ }
34
+ }
35
+ }
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": 3,
2
+ "version": 5,
3
3
  "security": {
4
4
  "trustModelAccepted": false,
5
5
  "trustModelAcceptedAt": "",
@@ -18,6 +18,40 @@
18
18
  "commandUserId": "",
19
19
  "groupPolicy": "open",
20
20
  "freeResponseChannels": [],
21
+ "humanDelay": {
22
+ "mode": "natural",
23
+ "minMs": 800,
24
+ "maxMs": 2500
25
+ },
26
+ "typingMode": "thinking",
27
+ "presence": {
28
+ "enabled": true,
29
+ "intervalMs": 30000,
30
+ "healthyText": "Watching the channels",
31
+ "degradedText": "Thinking slowly...",
32
+ "exhaustedText": "Taking a break",
33
+ "activityType": "watching"
34
+ },
35
+ "lifecycleReactions": {
36
+ "enabled": true,
37
+ "removeOnComplete": true,
38
+ "phases": {
39
+ "queued": "⏳",
40
+ "thinking": "🤔",
41
+ "toolUse": "⚙️",
42
+ "streaming": "✍️",
43
+ "done": "✅",
44
+ "error": "❌"
45
+ }
46
+ },
47
+ "ackReaction": "👀",
48
+ "ackReactionScope": "group-mentions",
49
+ "removeAckAfterReply": true,
50
+ "debounceMs": 2500,
51
+ "rateLimitPerUser": 0,
52
+ "rateLimitExemptRoles": [],
53
+ "suppressPatterns": ["/stop", "/pause", "brb", "afk"],
54
+ "maxConcurrentPerChannel": 2,
21
55
  "guilds": {}
22
56
  },
23
57
  "hybridai": {
@@ -25,11 +59,7 @@
25
59
  "defaultModel": "gpt-5-nano",
26
60
  "defaultChatbotId": "",
27
61
  "enableRag": true,
28
- "models": [
29
- "gpt-5-nano",
30
- "gpt-5-mini",
31
- "gpt-5"
32
- ]
62
+ "models": ["gpt-5-nano", "gpt-5-mini", "gpt-5"]
33
63
  },
34
64
  "container": {
35
65
  "image": "hybridclaw-agent",
@@ -45,6 +75,10 @@
45
75
  "intervalMs": 1800000,
46
76
  "channel": ""
47
77
  },
78
+ "memory": {
79
+ "decayRate": 0.1,
80
+ "consolidationIntervalHours": 24
81
+ },
48
82
  "ops": {
49
83
  "healthHost": "127.0.0.1",
50
84
  "healthPort": 9090,
@@ -68,7 +102,9 @@
68
102
  },
69
103
  "sessionCompaction": {
70
104
  "enabled": true,
71
- "threshold": 120,
105
+ "tokenBudget": 100000,
106
+ "budgetRatio": 0.7,
107
+ "threshold": 200,
72
108
  "keepRecent": 40,
73
109
  "summaryMaxChars": 8000,
74
110
  "preCompactionMemoryFlush": {
@@ -106,5 +142,29 @@
106
142
  "ralph": {
107
143
  "maxIterations": 0
108
144
  }
145
+ },
146
+ "scheduler": {
147
+ "jobs": [
148
+ {
149
+ "id": "morning-standup",
150
+ "name": "Daily Standup Report",
151
+ "description": "Runs standup summary every weekday at 9am.",
152
+ "schedule": {
153
+ "kind": "cron",
154
+ "expr": "0 9 * * 1-5",
155
+ "tz": "America/New_York"
156
+ },
157
+ "action": {
158
+ "kind": "agent_turn",
159
+ "message": "Post a brief morning standup update for the team."
160
+ },
161
+ "delivery": {
162
+ "kind": "channel",
163
+ "channel": "discord",
164
+ "to": "123456789012345678"
165
+ },
166
+ "enabled": false
167
+ }
168
+ ]
109
169
  }
110
170
  }
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "hybridclaw-agent",
3
- "version": "0.2.3",
3
+ "version": "0.2.6",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "hybridclaw-agent",
9
- "version": "0.2.3",
9
+ "version": "0.2.6",
10
10
  "dependencies": {
11
11
  "@mozilla/readability": "^0.6.0",
12
12
  "agent-browser": "^0.15.1",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hybridclaw-agent",
3
- "version": "0.2.3",
3
+ "version": "0.2.6",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "build": "tsc",