# diasissatayev/bitrix-agent-test architecture

> Architecture diagram of the GitHub repository diasissatayev/bitrix-agent-test, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/diasissatayev/bitrix-agent-test
- Repository: https://github.com/diasissatayev/bitrix-agent-test

## Overview

Bitrix-агент uses a low-cost scheduled monitor to detect task activity and wake Claude only when configured rules match. Claude then follows the agent routine: inspect tasks and comments, verify trust, download attachments such as résumés, and respond or send owner-only summaries. The sampled code shows the monitor, REST client, text helpers, and agent tools; the README documents the routine’s broader behavior. Browser-based posting is a documented fallback, not the main path.

Main entry points: [`monitor/check.mjs`](https://github.com/diasissatayev/bitrix-agent-test/blob/claude/zen-archimedes-tbzhv0/monitor/check.mjs) (Activity monitor), [`agent/bx.mjs`](https://github.com/diasissatayev/bitrix-agent-test/blob/claude/zen-archimedes-tbzhv0/agent/bx.mjs) (Agent tools), [`lib/bitrix.mjs`](https://github.com/diasissatayev/bitrix-agent-test/blob/claude/zen-archimedes-tbzhv0/lib/bitrix.mjs) (REST client), [`scripts/post-comment.js`](https://github.com/diasissatayev/bitrix-agent-test/blob/claude/zen-archimedes-tbzhv0/scripts/post-comment.js) (Browser comment posting)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_monitoring["Activity monitoring"]
  node_monitor["Activity monitor<br/>[check.mjs]"]
  node_config["Rules and settings<br/>[config.json]"]
  node_monitor_state[("Monitor state")]
  node_events["Queued events"]
end

subgraph group_agent["Claude task agent"]
  node_routine["Agent instructions<br/>[ROUTINE.md]"]
  node_tools["Agent tools<br/>[bx.mjs]"]
  node_signature["Required signature<br/>[signature.json]"]
end

subgraph group_shared["Bitrix integration"]
  node_client["REST client<br/>[bitrix.mjs]"]
  node_text["Text and time helpers<br/>[text.mjs]"]
end

subgraph group_browser["Browser fallback"]
  node_browser_session["Browser session<br/>[bitrix-session.js]"]
  node_browser_post["Browser comment posting<br/>[post-comment.js]"]
end

node_team(("Team members"))
node_portal{{"Bitrix24"}}
node_claude{{"Claude routine"}}

node_team -->|"posts activity"| node_portal
node_monitor -->|"reads rules"| node_config
node_monitor -->|"loads and saves"| node_monitor_state
node_monitor -->|"connects through"| node_client
node_monitor -->|"uses helpers"| node_text
node_client -->|"requests task data"| node_portal
node_monitor -->|"sends wake events"| node_claude
node_monitor -.->|"writes if unconfigured"| node_events
node_claude -->|"follows instructions"| node_routine
node_routine -->|"invokes actions"| node_tools
node_tools -->|"reads trust settings"| node_config
node_tools -->|"reads prefix"| node_signature
node_tools -->|"connects through"| node_client
node_tools -->|"uses helpers"| node_text
node_client -->|"reads and writes"| node_portal
node_portal -->|"shows replies"| node_team
node_browser_post -.->|"opens session"| node_browser_session
node_browser_session -.->|"authenticates"| node_portal
node_browser_post -.->|"reads prefix"| node_signature

click node_monitor "https://github.com/diasissatayev/bitrix-agent-test/blob/claude/zen-archimedes-tbzhv0/monitor/check.mjs"
click node_config "https://github.com/diasissatayev/bitrix-agent-test/blob/claude/zen-archimedes-tbzhv0/monitor/config.json"
click node_routine "https://github.com/diasissatayev/bitrix-agent-test/blob/claude/zen-archimedes-tbzhv0/agent/ROUTINE.md"
click node_tools "https://github.com/diasissatayev/bitrix-agent-test/blob/claude/zen-archimedes-tbzhv0/agent/bx.mjs"
click node_signature "https://github.com/diasissatayev/bitrix-agent-test/blob/claude/zen-archimedes-tbzhv0/lib/signature.json"
click node_client "https://github.com/diasissatayev/bitrix-agent-test/blob/claude/zen-archimedes-tbzhv0/lib/bitrix.mjs"
click node_text "https://github.com/diasissatayev/bitrix-agent-test/blob/claude/zen-archimedes-tbzhv0/lib/text.mjs"
click node_browser_session "https://github.com/diasissatayev/bitrix-agent-test/blob/claude/zen-archimedes-tbzhv0/scripts/bitrix-session.js"
click node_browser_post "https://github.com/diasissatayev/bitrix-agent-test/blob/claude/zen-archimedes-tbzhv0/scripts/post-comment.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_monitor,node_config,node_monitor_state,node_events toneBlue
class node_routine,node_tools,node_signature toneAmber
class node_client,node_text toneMint
class node_browser_session,node_browser_post toneRose
class node_team,node_portal,node_claude toneIndigo
```

## Components

### Activity monitoring

- [Activity monitor](https://github.com/diasissatayev/bitrix-agent-test/blob/claude/zen-archimedes-tbzhv0/monitor/check.mjs): `monitor/check.mjs`
- [Rules and settings](https://github.com/diasissatayev/bitrix-agent-test/blob/claude/zen-archimedes-tbzhv0/monitor/config.json): `monitor/config.json`
- **Monitor state**
- **Queued events**

### Claude task agent

- [Agent instructions](https://github.com/diasissatayev/bitrix-agent-test/blob/claude/zen-archimedes-tbzhv0/agent/ROUTINE.md): `agent/ROUTINE.md`
- [Agent tools](https://github.com/diasissatayev/bitrix-agent-test/blob/claude/zen-archimedes-tbzhv0/agent/bx.mjs): `agent/bx.mjs`
- [Required signature](https://github.com/diasissatayev/bitrix-agent-test/blob/claude/zen-archimedes-tbzhv0/lib/signature.json): `lib/signature.json`

### Bitrix integration

- [REST client](https://github.com/diasissatayev/bitrix-agent-test/blob/claude/zen-archimedes-tbzhv0/lib/bitrix.mjs): `lib/bitrix.mjs`
- [Text and time helpers](https://github.com/diasissatayev/bitrix-agent-test/blob/claude/zen-archimedes-tbzhv0/lib/text.mjs): `lib/text.mjs`

### Browser fallback

- [Browser session](https://github.com/diasissatayev/bitrix-agent-test/blob/claude/zen-archimedes-tbzhv0/scripts/bitrix-session.js): `scripts/bitrix-session.js`
- [Browser comment posting](https://github.com/diasissatayev/bitrix-agent-test/blob/claude/zen-archimedes-tbzhv0/scripts/post-comment.js): `scripts/post-comment.js`

### Other components

- **Team members**
- **Bitrix24**
- **Claude routine**

## Connections

- Team members → Bitrix24: posts activity
- Activity monitor → Rules and settings: reads rules
- Activity monitor → Monitor state: loads and saves
- Activity monitor → REST client: connects through
- Activity monitor → Text and time helpers: uses helpers
- REST client → Bitrix24: requests task data
- Activity monitor → Claude routine: sends wake events
- Activity monitor → Queued events: writes if unconfigured
- Claude routine → Agent instructions: follows instructions
- Agent instructions → Agent tools: invokes actions
- Agent tools → Rules and settings: reads trust settings
- Agent tools → Required signature: reads prefix
- Agent tools → REST client: connects through
- Agent tools → Text and time helpers: uses helpers
- REST client → Bitrix24: reads and writes
- Bitrix24 → Team members: shows replies
- Browser comment posting → Browser session: opens session
- Browser session → Bitrix24: authenticates
- Browser comment posting → Required signature: reads prefix
