Skip to content

Commit ec1490a

Browse files
committed
Add documentation and configuration files for Chronos framework
- Introduced GitHub Actions workflow for deploying documentation on push to the main branch. - Added Jekyll configuration in `_config.yml` for site metadata and theme settings. - Created initial documentation structure with `index.md`, navigation, and API references. - Implemented custom CSS for styling the documentation site. - Added Docker and Kubernetes deployment guides to facilitate containerized and cloud-based setups. - Included configuration management documentation for agent setup and YAML structure. - Established CLI reference and core interfaces documentation to enhance developer usability.
1 parent b8b2ed7 commit ec1490a

29 files changed

Lines changed: 4980 additions & 0 deletions

.github/workflows/docs.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Deploy Documentation
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths:
7+
- "docs/**"
8+
- ".github/workflows/docs.yml"
9+
workflow_dispatch:
10+
11+
permissions:
12+
contents: read
13+
pages: write
14+
id-token: write
15+
16+
concurrency:
17+
group: "pages"
18+
cancel-in-progress: false
19+
20+
jobs:
21+
build:
22+
runs-on: ubuntu-latest
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@v4
26+
27+
- name: Setup Pages
28+
uses: actions/configure-pages@v5
29+
30+
- name: Setup Ruby
31+
uses: ruby/setup-ruby@v1
32+
with:
33+
ruby-version: "3.3"
34+
bundler-cache: true
35+
working-directory: docs
36+
37+
- name: Build with Jekyll
38+
run: bundle exec jekyll build --baseurl "${{ steps.pages.outputs.base_path }}"
39+
working-directory: docs
40+
env:
41+
JEKYLL_ENV: production
42+
43+
- name: Upload artifact
44+
uses: actions/upload-pages-artifact@v3
45+
with:
46+
path: docs/_site
47+
48+
deploy:
49+
environment:
50+
name: github-pages
51+
url: ${{ steps.deployment.outputs.page_url }}
52+
runs-on: ubuntu-latest
53+
needs: build
54+
steps:
55+
- name: Deploy to GitHub Pages
56+
id: deployment
57+
uses: actions/deploy-pages@v4

docs/Gemfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
source "https://rubygems.org"
2+
3+
gem "github-pages", group: :jekyll_plugins
4+
gem "jekyll-include-cache", group: :jekyll_plugins

docs/_config.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
title: Chronos
2+
description: "A Go framework for building durable, scalable AI agents"
3+
url: "https://chronos-ai.github.io"
4+
baseurl: "/chronos"
5+
6+
remote_theme: "mmistakes/minimal-mistakes@4.26.2"
7+
8+
minimal_mistakes_skin: "dark"
9+
10+
locale: "en-US"
11+
title_separator: "|"
12+
subtitle: "AI Agent Framework"
13+
name: "Chronos"
14+
repository: "chronos-ai/chronos"
15+
16+
teaser: /assets/images/chronos-og.png
17+
og_image: /assets/images/chronos-og.png
18+
logo: /assets/images/logo.svg
19+
20+
search: true
21+
search_full_content: true
22+
23+
analytics:
24+
provider: false
25+
26+
footer:
27+
links:
28+
- label: "GitHub"
29+
icon: "fab fa-fw fa-github"
30+
url: "https://github.com/chronos-ai/chronos"
31+
32+
defaults:
33+
- scope:
34+
path: ""
35+
type: pages
36+
values:
37+
layout: single
38+
sidebar:
39+
nav: "docs"
40+
toc: true
41+
toc_sticky: true
42+
toc_label: "On this page"
43+
44+
plugins:
45+
- jekyll-remote-theme
46+
- jekyll-seo-tag
47+
- jekyll-include-cache
48+
49+
include:
50+
- _pages
51+
52+
exclude:
53+
- Gemfile
54+
- Gemfile.lock
55+
- vendor

docs/_data/navigation.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
docs:
2+
- title: "Getting Started"
3+
children:
4+
- title: "Introduction"
5+
url: /
6+
- title: "Installation"
7+
url: /getting-started/installation/
8+
- title: "Quickstart"
9+
url: /getting-started/quickstart/
10+
- title: "Configuration"
11+
url: /getting-started/configuration/
12+
13+
- title: "Core Concepts"
14+
children:
15+
- title: "Agents"
16+
url: /guides/agents/
17+
- title: "Model Providers"
18+
url: /guides/models/
19+
- title: "Tools & Function Calling"
20+
url: /guides/tools/
21+
- title: "Memory & Knowledge"
22+
url: /guides/memory/
23+
- title: "Context Management"
24+
url: /guides/context-management/
25+
- title: "Multi-Agent Teams"
26+
url: /guides/teams/
27+
- title: "StateGraph Runtime"
28+
url: /guides/stategraph/
29+
30+
- title: "Middleware"
31+
children:
32+
- title: "Overview"
33+
url: /guides/middleware/
34+
- title: "Guardrails"
35+
url: /guides/guardrails/
36+
- title: "Cost Tracking"
37+
url: /guides/cost-tracking/
38+
39+
- title: "Infrastructure"
40+
children:
41+
- title: "Storage Adapters"
42+
url: /guides/storage/
43+
- title: "Streaming & SSE"
44+
url: /guides/streaming/
45+
46+
- title: "Deployment"
47+
children:
48+
- title: "Docker"
49+
url: /deployment/docker/
50+
- title: "Kubernetes & Helm"
51+
url: /deployment/kubernetes/
52+
- title: "CI/CD"
53+
url: /deployment/cicd/
54+
55+
- title: "API Reference"
56+
children:
57+
- title: "Interfaces"
58+
url: /api/interfaces/
59+
- title: "Agent Builder"
60+
url: /api/agent-builder/
61+
- title: "CLI Reference"
62+
url: /api/cli/

docs/_includes/head/custom.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<link rel="stylesheet" href="{{ '/assets/css/custom.css' | relative_url }}">
2+
<link rel="icon" type="image/svg+xml" href="{{ '/assets/images/logo.svg' | relative_url }}">

docs/api/agent-builder.md

Lines changed: 199 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,199 @@
1+
---
2+
title: "Agent Builder API"
3+
permalink: /api/agent-builder/
4+
sidebar:
5+
nav: "docs"
6+
toc: true
7+
toc_sticky: true
8+
---
9+
10+
The agent builder provides a fluent API for constructing fully-wired agents.
11+
12+
## Constructor
13+
14+
```go
15+
agent.New(id string, name string) *Builder
16+
```
17+
18+
Creates a new builder with defaults: empty tool registry, empty skill registry, guardrails engine, and `MaxConcurrentSubAgents` set to 5.
19+
20+
## Builder Methods
21+
22+
All builder methods return `*Builder` for chaining.
23+
24+
### Identity
25+
26+
| Method | Description |
27+
|--------|-------------|
28+
| `Description(d string)` | Set agent description |
29+
| `WithUserID(id string)` | Set the user ID for memory scoping |
30+
31+
### Core Components
32+
33+
| Method | Description |
34+
|--------|-------------|
35+
| `WithModel(p model.Provider)` | Set the LLM provider |
36+
| `WithStorage(s storage.Storage)` | Set the persistence backend |
37+
| `WithMemory(m *memory.Store)` | Set the memory store |
38+
| `WithKnowledge(k knowledge.Knowledge)` | Set the RAG knowledge base |
39+
| `WithMemoryManager(m *memory.Manager)` | Set the LLM-powered memory manager |
40+
| `WithGraph(g *graph.StateGraph)` | Set the execution graph |
41+
42+
### Configuration
43+
44+
| Method | Description |
45+
|--------|-------------|
46+
| `WithSystemPrompt(prompt string)` | Set the system prompt |
47+
| `AddInstruction(instruction string)` | Append an instruction to system context |
48+
| `WithOutputSchema(s map[string]any)` | Set JSON Schema for structured output |
49+
| `WithHistoryRuns(n int)` | Number of past runs to inject into context |
50+
| `WithContextConfig(cfg ContextConfig)` | Configure context window management |
51+
52+
### ContextConfig
53+
54+
```go
55+
type ContextConfig struct {
56+
MaxContextTokens int // override model default; 0 = use model default
57+
SummarizeThreshold float64 // fraction of context to trigger summarization (default 0.8)
58+
PreserveRecentTurns int // recent user/assistant pairs to keep (default 5)
59+
}
60+
```
61+
62+
### Tools and Skills
63+
64+
| Method | Description |
65+
|--------|-------------|
66+
| `AddTool(def *tool.Definition)` | Register a tool the model can call |
67+
| `AddSkill(s *skill.Skill)` | Register a skill |
68+
| `AddCapability(capability string)` | Advertise a capability for the protocol bus |
69+
70+
### Middleware
71+
72+
| Method | Description |
73+
|--------|-------------|
74+
| `AddHook(h hooks.Hook)` | Append a middleware hook |
75+
| `AddInputGuardrail(name string, g guardrails.Guardrail)` | Add input validation |
76+
| `AddOutputGuardrail(name string, g guardrails.Guardrail)` | Add output validation |
77+
78+
### Multi-Agent
79+
80+
| Method | Description |
81+
|--------|-------------|
82+
| `AddSubAgent(sub *Agent)` | Register a sub-agent |
83+
84+
### Build
85+
86+
```go
87+
func (b *Builder) Build() (*Agent, error)
88+
```
89+
90+
Compiles the graph (if set) and returns the configured agent. Returns an error if graph compilation fails.
91+
92+
## Agent Methods
93+
94+
### Chat (Single-Turn)
95+
96+
```go
97+
func (a *Agent) Chat(ctx context.Context, userMessage string) (*model.ChatResponse, error)
98+
```
99+
100+
Sends a single user message to the model. Stateless -- no conversation history is maintained between calls.
101+
102+
**Flow:**
103+
1. Build messages: system prompt, instructions, memories, knowledge, user message
104+
2. Check input guardrails
105+
3. Fire `model_call.before` hooks
106+
4. Call `model.Provider.Chat`
107+
5. Fire `model_call.after` hooks
108+
6. Handle tool calls (if any)
109+
7. Check output guardrails
110+
8. Extract memories
111+
112+
### ChatWithSession (Multi-Turn)
113+
114+
```go
115+
func (a *Agent) ChatWithSession(ctx context.Context, sessionID, userMessage string) (*model.ChatResponse, error)
116+
```
117+
118+
Sends a message within a persistent, multi-turn session. Messages are stored in the event ledger. When the conversation approaches the model's context window limit, older messages are automatically summarized.
119+
120+
**Requires:** `Storage` must be set on the agent.
121+
122+
**Flow:**
123+
1. Load or create session
124+
2. Reconstruct conversation from events
125+
3. Append user message
126+
4. Check if summarization is needed
127+
5. Summarize older messages (if threshold exceeded)
128+
6. Build messages with system context + summary + recent history
129+
7. Call model, handle tool calls, check guardrails
130+
8. Persist assistant response
131+
132+
### Run (Graph Execution)
133+
134+
```go
135+
func (a *Agent) Run(ctx context.Context, input map[string]any) (*graph.RunState, error)
136+
```
137+
138+
Starts a new execution session using the agent's StateGraph. State is checkpointed after every node.
139+
140+
**Requires:** `Graph` and `Storage` must be set.
141+
142+
### Resume
143+
144+
```go
145+
func (a *Agent) Resume(ctx context.Context, sessionID string) (*graph.RunState, error)
146+
```
147+
148+
Continues a paused session from the latest checkpoint.
149+
150+
## YAML Configuration
151+
152+
Agents can also be built from YAML config:
153+
154+
```go
155+
fc, _ := agent.LoadFile("")
156+
cfg, _ := fc.FindAgent("dev")
157+
a, _ := agent.BuildAgent(ctx, cfg)
158+
```
159+
160+
See the [Configuration guide]({{ '/getting-started/configuration/' | relative_url }}) for full YAML reference.
161+
162+
## Complete Example
163+
164+
```go
165+
store, _ := sqlite.New("app.db")
166+
store.Migrate(ctx)
167+
168+
tracker := hooks.NewCostTracker(nil)
169+
170+
a, _ := agent.New("assistant", "AI Assistant").
171+
WithModel(model.NewOpenAI(os.Getenv("OPENAI_API_KEY"))).
172+
WithStorage(store).
173+
WithSystemPrompt("You are a helpful coding assistant.").
174+
AddInstruction("Always include code examples.").
175+
WithContextConfig(agent.ContextConfig{
176+
SummarizeThreshold: 0.8,
177+
PreserveRecentTurns: 5,
178+
}).
179+
AddTool(&tool.Definition{
180+
Name: "search_docs",
181+
Description: "Search project documentation",
182+
Parameters: map[string]any{"type": "object", "properties": map[string]any{
183+
"query": map[string]string{"type": "string"},
184+
}},
185+
Permission: tool.PermAllow,
186+
Handler: searchHandler,
187+
}).
188+
AddHook(hooks.NewRetryHook(3)).
189+
AddHook(tracker).
190+
AddInputGuardrail("blocklist", &guardrails.BlocklistGuardrail{
191+
Blocklist: []string{"password", "secret"},
192+
}).
193+
Build()
194+
195+
// Multi-turn session with automatic summarization
196+
resp, _ := a.ChatWithSession(ctx, "session-001", "How do I implement auth?")
197+
fmt.Println(resp.Content)
198+
fmt.Printf("Cost: $%.6f\n", tracker.GetGlobalCost().TotalCost)
199+
```

0 commit comments

Comments
 (0)