@polderlabs/bizar 4.4.13 → 4.5.0
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.
- package/bizar-dash/CHANGELOG.md +37 -276
- package/bizar-dash/dist/assets/main-CDFKHzBg.css +1 -0
- package/bizar-dash/dist/assets/main-NYFpS2wY.js +312 -0
- package/bizar-dash/dist/assets/main-NYFpS2wY.js.map +1 -0
- package/bizar-dash/dist/assets/{mobile-DSb-t42Y.js → mobile--0FBIKX3.js} +2 -2
- package/bizar-dash/dist/assets/{mobile-DSb-t42Y.js.map → mobile--0FBIKX3.js.map} +1 -1
- package/bizar-dash/dist/assets/mobile-OgRp8VIb.js +352 -0
- package/bizar-dash/dist/assets/mobile-OgRp8VIb.js.map +1 -0
- package/bizar-dash/dist/index.html +3 -3
- package/bizar-dash/dist/mobile.html +2 -2
- package/bizar-dash/skills/agent-baseline/SKILL.md +80 -0
- package/bizar-dash/skills/bizar/SKILL.md +96 -0
- package/bizar-dash/skills/chat/SKILL.md +74 -0
- package/bizar-dash/skills/lightrag/SKILL.md +75 -0
- package/bizar-dash/skills/minimax/SKILL.md +80 -0
- package/bizar-dash/skills/obsidian/SKILL.md +55 -0
- package/bizar-dash/skills/providers/SKILL.md +75 -0
- package/bizar-dash/skills/sdk/SKILL.md +138 -0
- package/bizar-dash/skills/self-improvement/SKILL.md +53 -0
- package/bizar-dash/skills/skills-cli/SKILL.md +94 -0
- package/bizar-dash/skills/usage/SKILL.md +62 -0
- package/bizar-dash/src/server/api.mjs +12 -0
- package/bizar-dash/src/server/memory-lightrag.mjs +5 -2
- package/bizar-dash/src/server/memory-store.mjs +38 -0
- package/bizar-dash/src/server/minimax-usage-store.mjs +372 -0
- package/bizar-dash/src/server/minimax.mjs +196 -5
- package/bizar-dash/src/server/providers-store.mjs +956 -0
- package/bizar-dash/src/server/routes/config.mjs +52 -1
- package/bizar-dash/src/server/routes/env-vars.mjs +165 -0
- package/bizar-dash/src/server/routes/lightrag.mjs +154 -0
- package/bizar-dash/src/server/routes/memory.mjs +241 -1
- package/bizar-dash/src/server/routes/opencode-session-detail.mjs +14 -29
- package/bizar-dash/src/server/routes/opencode-sessions.mjs +205 -3
- package/bizar-dash/src/server/routes/providers.mjs +266 -5
- package/bizar-dash/src/server/routes/skills.mjs +32 -43
- package/bizar-dash/src/server/routes/update.mjs +340 -0
- package/bizar-dash/src/server/routes/usage.mjs +136 -0
- package/bizar-dash/src/server/serve-info.mjs +135 -4
- package/bizar-dash/src/server/server.mjs +4 -0
- package/bizar-dash/src/server/skills-store.mjs +152 -262
- package/bizar-dash/src/web/App.tsx +118 -29
- package/bizar-dash/src/web/components/EnvVarManager.tsx +247 -0
- package/bizar-dash/src/web/components/SettingsSearch.tsx +213 -0
- package/bizar-dash/src/web/components/Topbar.tsx +0 -1
- package/bizar-dash/src/web/components/UsageChart.tsx +250 -0
- package/bizar-dash/src/web/components/UsageTable.tsx +90 -0
- package/bizar-dash/src/web/components/chat/ChatComposer.tsx +21 -25
- package/bizar-dash/src/web/components/chat/ChatInfoPanel.tsx +199 -37
- package/bizar-dash/src/web/components/chat/ChatThread.tsx +29 -17
- package/bizar-dash/src/web/components/chat/FloatingComposer.tsx +7 -1
- package/bizar-dash/src/web/components/chat/InfoPanel.tsx +71 -6
- package/bizar-dash/src/web/components/chat/useChat.ts +751 -257
- package/bizar-dash/src/web/lib/api.ts +43 -0
- package/bizar-dash/src/web/main.tsx +1 -0
- package/bizar-dash/src/web/mobile/views/MobileChat.tsx +110 -35
- package/bizar-dash/src/web/styles/chat.css +135 -1
- package/bizar-dash/src/web/styles/main.css +46 -0
- package/bizar-dash/src/web/styles/minimax-usage.css +335 -0
- package/bizar-dash/src/web/styles/settings.css +418 -0
- package/bizar-dash/src/web/styles/skills.css +302 -0
- package/bizar-dash/src/web/styles/tasks.css +288 -0
- package/bizar-dash/src/web/views/Chat.tsx +276 -48
- package/bizar-dash/src/web/views/Config.tsx +3 -2065
- package/bizar-dash/src/web/views/MiniMaxUsage.tsx +476 -461
- package/bizar-dash/src/web/views/Settings.tsx +6 -0
- package/bizar-dash/src/web/views/Skills.tsx +208 -260
- package/bizar-dash/src/web/views/Tasks.tsx +348 -1119
- package/bizar-dash/tests/chat-session-create.test.mjs +391 -0
- package/bizar-dash/tests/chat-session-stream.test.mjs +308 -0
- package/bizar-dash/tests/env-vars-store.test.mjs +216 -0
- package/bizar-dash/tests/lightrag-defaults.node.test.mjs +118 -0
- package/bizar-dash/tests/minimax-chat-usage.test.mjs +178 -0
- package/bizar-dash/tests/minimax-usage-store.node.test.mjs +293 -0
- package/bizar-dash/tests/opencode-sessions-detail.test.mjs +12 -9
- package/bizar-dash/tests/providers-store-backup-keys.node.test.mjs +479 -3
- package/bizar-dash/tests/providers-store-search.node.test.mjs +166 -0
- package/bizar-dash/tests/skills-list.test.mjs +232 -0
- package/bizar-dash/tests/skills-search.test.mjs +222 -0
- package/bizar-dash/tests/tasks-create.test.mjs +187 -0
- package/bizar-dash/tests/update-check.test.mjs +127 -0
- package/bizar-dash/tests/update-run.test.mjs +266 -0
- package/cli/bin.mjs +82 -1
- package/cli/provision.mjs +118 -4
- package/config/agents/_shared/SKILLS.md +109 -0
- package/package.json +1 -1
- package/bizar-dash/dist/assets/main-BB5mJurD.js +0 -352
- package/bizar-dash/dist/assets/main-BB5mJurD.js.map +0 -1
- package/bizar-dash/dist/assets/main-BsnQLXdh.css +0 -1
- package/bizar-dash/dist/assets/mobile-Dl1q7Cyq.js +0 -354
- package/bizar-dash/dist/assets/mobile-Dl1q7Cyq.js.map +0 -1
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: sdk
|
|
3
|
+
description: @polderlabs/bizar-sdk usage - building AI agents on Cloudflare Workers using the Agents SDK. Covers Agent class, state management, callable RPC, Workflows, durable execution, queues, retries, observability, and React hooks.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# @polderlabs/bizar-sdk
|
|
7
|
+
|
|
8
|
+
The Bizar SDK lets you build AI-powered agents on Cloudflare Workers using the Agents SDK. It runs on Cloudflare's global network with automatic scaling and durable state.
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm install @polderlabs/bizar-sdk
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Core Concepts
|
|
17
|
+
|
|
18
|
+
### Agent Class
|
|
19
|
+
|
|
20
|
+
```typescript
|
|
21
|
+
import { Agent } from '@polderlabs/bizar-sdk';
|
|
22
|
+
|
|
23
|
+
const agent = new Agent({
|
|
24
|
+
name: 'my-agent',
|
|
25
|
+
model: 'minimax/MiniMax-M3',
|
|
26
|
+
systemPrompt: 'You are a helpful assistant.',
|
|
27
|
+
env: { MINIMAX_API_KEY },
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
export default agent;
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### State Management
|
|
34
|
+
|
|
35
|
+
Agents maintain durable state across requests using Cloudflare Durable Objects:
|
|
36
|
+
|
|
37
|
+
```typescript
|
|
38
|
+
const state = await agent.state.get();
|
|
39
|
+
// { count: 0, lastSeen: Date }
|
|
40
|
+
await agent.state.patch({ count: state.count + 1 });
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Callable RPC
|
|
44
|
+
|
|
45
|
+
Agents expose RPC methods callable via HTTP:
|
|
46
|
+
|
|
47
|
+
```typescript
|
|
48
|
+
agent.method('greet', async (name: string) => {
|
|
49
|
+
return `Hello, ${name}!`;
|
|
50
|
+
});
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Call from the dashboard or any HTTP client:
|
|
54
|
+
```bash
|
|
55
|
+
curl -X POST https://my-agent.workers.dev/rpc/greet \
|
|
56
|
+
-H "Content-Type: application/json" \
|
|
57
|
+
-d '{"name": "World"}'
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Workflows
|
|
61
|
+
|
|
62
|
+
For long-running tasks, use Workflows (durable execution):
|
|
63
|
+
|
|
64
|
+
```typescript
|
|
65
|
+
import { Workflow } from '@polderlabs/bizar-sdk';
|
|
66
|
+
|
|
67
|
+
const workflow = new Workflow({
|
|
68
|
+
name: 'data-processor',
|
|
69
|
+
retry: { maxAttempts: 3, backoff: 'exponential' },
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
workflow.step('fetch', async ({ input }) => {
|
|
73
|
+
return await fetch(input.url);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
workflow.step('process', async ({ input, state }) => {
|
|
77
|
+
const data = await input.json();
|
|
78
|
+
return { ...data, processed: true };
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
export default workflow;
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Queues
|
|
85
|
+
|
|
86
|
+
For async message processing:
|
|
87
|
+
|
|
88
|
+
```typescript
|
|
89
|
+
import { Queue } from '@polderlabs/bizar-sdk';
|
|
90
|
+
|
|
91
|
+
const queue = new Queue('my-queue', {
|
|
92
|
+
maxRetries: 3,
|
|
93
|
+
batchSize: 10,
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
queue.processor(async (messages) => {
|
|
97
|
+
for (const msg of messages) {
|
|
98
|
+
console.log('Received:', msg.body);
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## Observability
|
|
104
|
+
|
|
105
|
+
Built-in tracing to Cloudflare Analytics:
|
|
106
|
+
- Request logs
|
|
107
|
+
- Token usage
|
|
108
|
+
- Error rates
|
|
109
|
+
- Latency percentiles
|
|
110
|
+
|
|
111
|
+
## React Hooks
|
|
112
|
+
|
|
113
|
+
For building chat interfaces:
|
|
114
|
+
|
|
115
|
+
```typescript
|
|
116
|
+
import { useAgent, useSession } from '@polderlabs/bizar-sdk/react';
|
|
117
|
+
|
|
118
|
+
function ChatComponent({ agentName }: { agentName: string }) {
|
|
119
|
+
const { messages, send, isLoading } = useAgent(agentName);
|
|
120
|
+
|
|
121
|
+
return (
|
|
122
|
+
<div>
|
|
123
|
+
{messages.map((m) => (
|
|
124
|
+
<div key={m.id}>{m.role}: {m.content}</div>
|
|
125
|
+
))}
|
|
126
|
+
<input onSend={send} disabled={isLoading} />
|
|
127
|
+
</div>
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## Deployment
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
npx wrangler deploy
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
Workers are deployed to Cloudflare's global network. No cold starts, automatic HTTPS.
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: self-improvement
|
|
3
|
+
description: Use when setting up, configuring, or debugging the project-level self-improvement system. Every task records lessons learned to .bizar/AGENTS_SELF_IMPROVEMENT.md for agent behavior improvement across sessions.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Self-Improvement Protocol
|
|
7
|
+
|
|
8
|
+
Records lessons learned after every meaningful task to `.bizar/AGENTS_SELF_IMPROVEMENT.md`. This enables agents to avoid repeating mistakes and build on past successes.
|
|
9
|
+
|
|
10
|
+
## How It Works
|
|
11
|
+
|
|
12
|
+
After completing a non-trivial task, the agent appends a structured entry to `.bizar/AGENTS_SELF_IMPROVEMENT.md` in the project root. Entries are written in Markdown with frontmatter for easy querying.
|
|
13
|
+
|
|
14
|
+
## Entry Format
|
|
15
|
+
|
|
16
|
+
```markdown
|
|
17
|
+
## [YYYY-MM-DD] <one-line summary>
|
|
18
|
+
|
|
19
|
+
**Task:** <what was asked>
|
|
20
|
+
|
|
21
|
+
**Approach taken:** <key decisions and why>
|
|
22
|
+
|
|
23
|
+
**What worked:** <specific things that went well>
|
|
24
|
+
|
|
25
|
+
**What could be better:** <mistakes, friction points, missed opportunities>
|
|
26
|
+
|
|
27
|
+
**Will do differently:** <concrete rule or habit for next time>
|
|
28
|
+
|
|
29
|
+
**Tags:** #<tag1> #<tag2>
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## When to Write an Entry
|
|
33
|
+
|
|
34
|
+
Write an entry when:
|
|
35
|
+
- A bug took more than 30 minutes to find or fix
|
|
36
|
+
- A significant architectural decision was made
|
|
37
|
+
- A known pattern or idiom was rediscovered
|
|
38
|
+
- A previous mistake was identified and corrected
|
|
39
|
+
- A task involved non-obvious tool usage or workflow
|
|
40
|
+
|
|
41
|
+
## Reading Before New Tasks
|
|
42
|
+
|
|
43
|
+
Before starting a non-trivial task in an unfamiliar area, agents should search the self-improvement file:
|
|
44
|
+
```
|
|
45
|
+
grep -A5 "tag:debugging" .bizar/AGENTS_SELF_IMPROVEMENT.md
|
|
46
|
+
grep -A5 "tag:typescript" .bizar/AGENTS_SELF_IMPROVEMENT.md
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
This surfaces prior lessons that apply to the current work.
|
|
50
|
+
|
|
51
|
+
## Skill File Location
|
|
52
|
+
|
|
53
|
+
The skill instructions are at `~/.opencode/skills/self-improvement/SKILL.md`. Load with the `skill` tool when setting up or debugging the system.
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: skills-cli
|
|
3
|
+
description: How to discover and install skills using the skills CLI. Covers skills list, search, add, and the skills.sh ecosystem of skill repositories.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Skills CLI
|
|
7
|
+
|
|
8
|
+
The `skills` CLI (`npm install -g skills`) is the standard way to discover and install skills in BizarHarness. Skills are Markdown files with YAML frontmatter that encode specialized knowledge and workflows for agents.
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm install -g skills
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Verify: `skills --version`
|
|
17
|
+
|
|
18
|
+
## Core Commands
|
|
19
|
+
|
|
20
|
+
### skills list
|
|
21
|
+
List all installed skills:
|
|
22
|
+
```bash
|
|
23
|
+
skills list --json
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### skills search
|
|
27
|
+
Search for skills by keyword:
|
|
28
|
+
```bash
|
|
29
|
+
skills search "react performance"
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### skills add
|
|
33
|
+
Install a skill from a GitHub repository:
|
|
34
|
+
```bash
|
|
35
|
+
skills add owner/repo --all -y # install all skills from repo
|
|
36
|
+
skills add owner/repo -s "skill-name" -y # install specific skill
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### skills info
|
|
40
|
+
Get details about a skill:
|
|
41
|
+
```bash
|
|
42
|
+
skills info my-skill
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Known Skill Repositories
|
|
46
|
+
|
|
47
|
+
| Domain | Repository |
|
|
48
|
+
|---|---|
|
|
49
|
+
| General (find-skills, skill-creator) | `vercel-labs/skills` |
|
|
50
|
+
| Frontend (React, a11y, web-design) | `vercel-labs/agent-skills`, `shadcn/ui` |
|
|
51
|
+
| Backend (Supabase, Postgres, auth) | `supabase/agent-skills` |
|
|
52
|
+
| Testing (TDD, Playwright) | `mattpocock/skills`, `microsoft/playwright-cli` |
|
|
53
|
+
| Design (frontend-design, UI/UX) | `anthropics/skills`, `leonxlnx/taste-skill` |
|
|
54
|
+
|
|
55
|
+
## Skill File Format
|
|
56
|
+
|
|
57
|
+
Skills are `.md` files named `SKILL.md` inside a skill directory:
|
|
58
|
+
|
|
59
|
+
```
|
|
60
|
+
~/.opencode/skills/my-skill/
|
|
61
|
+
SKILL.md ← the skill content
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
The first line must be YAML frontmatter:
|
|
65
|
+
```yaml
|
|
66
|
+
---
|
|
67
|
+
name: my-skill
|
|
68
|
+
description: Use when you need to do X. Covers Y and Z.
|
|
69
|
+
---
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Skill Discovery Protocol
|
|
73
|
+
|
|
74
|
+
1. **Assess** - When given a task, consider whether a skill might exist for it
|
|
75
|
+
2. **Check installed** - Run `skills list --json` to see what is already available
|
|
76
|
+
3. **Try known repos** - Based on the task domain, attempt installation from known repos
|
|
77
|
+
4. **Use** - Load the skill with the `skill` tool before writing code
|
|
78
|
+
5. **Skip** - If no skill found, proceed without
|
|
79
|
+
|
|
80
|
+
## SKILL.md Structure
|
|
81
|
+
|
|
82
|
+
A good skill is 50–200 lines:
|
|
83
|
+
|
|
84
|
+
1. **Frontmatter** - `name`, `description`
|
|
85
|
+
2. **When to use** - trigger conditions and use cases
|
|
86
|
+
3. **Key concepts** - essential background
|
|
87
|
+
4. **Code examples** - realistic, copy-pasteable snippets
|
|
88
|
+
5. **Common gotchas** - pitfalls and how to avoid them
|
|
89
|
+
|
|
90
|
+
## Skill Loading in Bizar
|
|
91
|
+
|
|
92
|
+
When an agent task is dispatched, Bizar checks if a skill matches the task description. If matched, the skill's `SKILL.md` content is injected into the agent's context before the task prompt.
|
|
93
|
+
|
|
94
|
+
Use the `skill` tool explicitly when you want to load a skill's instructions into the current conversation.
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: usage
|
|
3
|
+
description: Usage monitoring and analytics in BizarHarness - token tracking, cost estimation, usage store, and the MiniMax usage dashboard.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Usage Monitoring
|
|
7
|
+
|
|
8
|
+
BizarHarness tracks LLM token usage across all sessions and agents. Data is stored in `bizar-dash/src/server/minimax-usage-store.mjs` and surfaced in the dashboard.
|
|
9
|
+
|
|
10
|
+
## What Is Tracked
|
|
11
|
+
|
|
12
|
+
Per request:
|
|
13
|
+
- **Input tokens** - prompt tokens sent to the model
|
|
14
|
+
- **Output tokens** - tokens received from the model
|
|
15
|
+
- **Model** - which model was used (MiniMax-M2.7, MiniMax-M3, etc.)
|
|
16
|
+
- **Provider** - which provider handled the request
|
|
17
|
+
- **Session ID** - which session this belongs to
|
|
18
|
+
- **Agent** - which agent made the request (Thor, Tyr, etc.)
|
|
19
|
+
- **Timestamp** - when the request completed
|
|
20
|
+
|
|
21
|
+
## Cost Estimation
|
|
22
|
+
|
|
23
|
+
Token counts are converted to cost using the model's published pricing:
|
|
24
|
+
- MiniMax-M2.7: $0.30/M input · $1.20/M output
|
|
25
|
+
- MiniMax-M3: $0.30/M input · $1.20/M output
|
|
26
|
+
|
|
27
|
+
The usage dashboard shows:
|
|
28
|
+
- Total cost (current billing period)
|
|
29
|
+
- Cost breakdown by agent
|
|
30
|
+
- Cost breakdown by day/week
|
|
31
|
+
- Token count vs cost trend
|
|
32
|
+
|
|
33
|
+
## Usage Store
|
|
34
|
+
|
|
35
|
+
`bizar-dash/src/server/minimax-usage-store.mjs` uses a simple JSON file at `~/.config/bizar/usage.jsonl` (one JSON object per line - append-only log).
|
|
36
|
+
|
|
37
|
+
The store aggregates on read:
|
|
38
|
+
- Daily totals
|
|
39
|
+
- Per-agent totals
|
|
40
|
+
- Per-session totals
|
|
41
|
+
|
|
42
|
+
## Usage API Endpoints
|
|
43
|
+
|
|
44
|
+
- `GET /api/minimax/usage` - aggregated usage stats
|
|
45
|
+
- `GET /api/minimax/usage/daily` - daily breakdown
|
|
46
|
+
- `GET /api/minimax/usage/sessions` - per-session usage
|
|
47
|
+
|
|
48
|
+
## Dashboard View
|
|
49
|
+
|
|
50
|
+
`bizar-dash/src/web/views/MiniMaxUsage.tsx` renders:
|
|
51
|
+
- Summary cards (total cost, total tokens, avg cost/session)
|
|
52
|
+
- Line chart of daily cost
|
|
53
|
+
- Bar chart of cost by agent
|
|
54
|
+
- Table of recent sessions with usage
|
|
55
|
+
|
|
56
|
+
## Retention
|
|
57
|
+
|
|
58
|
+
Usage data is retained for 90 days by default. Old entries are pruned on each write to keep the log manageable.
|
|
59
|
+
|
|
60
|
+
## Cost Alerts
|
|
61
|
+
|
|
62
|
+
When a session's cumulative cost exceeds a threshold, the system logs a warning. The threshold is configurable via `MINIMAX_COST_ALERT_THRESHOLD` env var (default: $5 per session).
|
|
@@ -50,6 +50,9 @@ import { createThemesRouter } from './routes/themes.mjs';
|
|
|
50
50
|
import { createNotificationsRouter } from './routes/notifications.mjs';
|
|
51
51
|
import { createMinimaxRouter } from './routes/minimax.mjs';
|
|
52
52
|
import { createMiscRouter } from './routes/misc.mjs';
|
|
53
|
+
import { createEnvVarsRouter } from './routes/env-vars.mjs';
|
|
54
|
+
import { createUpdateRouter } from './routes/update.mjs';
|
|
55
|
+
import { createUsageRouter } from './routes/usage.mjs';
|
|
53
56
|
|
|
54
57
|
/**
|
|
55
58
|
* @param {object} deps
|
|
@@ -103,6 +106,10 @@ export async function createApiRouter({
|
|
|
103
106
|
router.use(createHistoryRouter({ projectRoot }));
|
|
104
107
|
router.use(createConfigRouter({ state, watcher }));
|
|
105
108
|
router.use(createProvidersRouter());
|
|
109
|
+
router.use(createEnvVarsRouter());
|
|
110
|
+
// v4.6.0 — Update endpoints (status / check / apply). Wired with the
|
|
111
|
+
// shared broadcast so apply can stream progress via WS.
|
|
112
|
+
router.use(createUpdateRouter({ broadcast }));
|
|
106
113
|
router.use(createSettingsRouter({ state, broadcast }));
|
|
107
114
|
router.use(createChatRouter({ state, broadcast }));
|
|
108
115
|
router.use(createOpencodeSessionsRouter());
|
|
@@ -114,12 +121,17 @@ export async function createApiRouter({
|
|
|
114
121
|
// memory routes haven't landed yet, the dashboard still boots.
|
|
115
122
|
const { createMemoryRouter } = await import('./routes/memory.mjs');
|
|
116
123
|
router.use(createMemoryRouter({ projectRoot }));
|
|
124
|
+
// v4.6.0 — LightRAG settings endpoints (defaults + status). Lazy-imported
|
|
125
|
+
// so a sibling that owns this file can ship independently.
|
|
126
|
+
const { createLightragRouter } = await import('./routes/lightrag.mjs');
|
|
127
|
+
router.use(createLightragRouter({ projectRoot }));
|
|
117
128
|
router.use(createDiagnosticsRouter());
|
|
118
129
|
router.use(createPairRouter({ state, broadcast }));
|
|
119
130
|
router.use(createThemesRouter({ state }));
|
|
120
131
|
router.use(createNotificationsRouter({ broadcast }));
|
|
121
132
|
router.use(createArtifactsRouter({ state, broadcast, projectRoot }));
|
|
122
133
|
router.use(createMinimaxRouter({ state, broadcast }));
|
|
134
|
+
router.use(createUsageRouter());
|
|
123
135
|
router.use(createMiscRouter({ state, broadcast }));
|
|
124
136
|
|
|
125
137
|
// /api/auth/* must be reachable WITHOUT the bearer token so a fresh
|
|
@@ -99,8 +99,11 @@ export const LIGHTRAG_DEFAULTS = Object.freeze({
|
|
|
99
99
|
startupTimeoutMs: 30_000,
|
|
100
100
|
llmBinding: 'ollama', // ollama | openai | lollms | azure_openai | bedrock | gemini
|
|
101
101
|
embeddingBinding: 'ollama', // ollama | openai | azure_openai | bedrock | jina | gemini | voyageai
|
|
102
|
-
|
|
103
|
-
|
|
102
|
+
// v4.6.0 — Default to free opencode Zen models (no API key required).
|
|
103
|
+
// Per-project overrides via .bizar/memory.json#lightrag.{llmModel,embeddingModel}
|
|
104
|
+
// or env vars BIZAR_LIGHTRAG_LLM / BIZAR_LIGHTRAG_EMBEDDING.
|
|
105
|
+
llmModel: 'opencode/gpt-5-nano',
|
|
106
|
+
embeddingModel: 'opencode/text-embedding-3-small',
|
|
104
107
|
llmBindingHost: null, // for non-ollama bindings
|
|
105
108
|
embeddingBindingHost: null,
|
|
106
109
|
apiKey: 'env', // 'env' means read from env var; any other string is written to file
|
|
@@ -541,3 +541,41 @@ export {
|
|
|
541
541
|
reindexVault,
|
|
542
542
|
query as queryLightRAG,
|
|
543
543
|
} from './memory-lightrag.mjs';
|
|
544
|
+
|
|
545
|
+
// ── v4.6.0 LightRAG default model helpers ──────────────────────────────────
|
|
546
|
+
//
|
|
547
|
+
// Free opencode Zen defaults — no API key required for free-tier models.
|
|
548
|
+
// Operators can override per-project via:
|
|
549
|
+
// - env: BIZAR_LIGHTRAG_LLM, BIZAR_LIGHTRAG_EMBEDDING
|
|
550
|
+
// - config: .bizar/memory.json#lightrag.llmModel / .embeddingModel
|
|
551
|
+
//
|
|
552
|
+
// The dashboard surfaces these via /api/lightrag/defaults so the
|
|
553
|
+
// settings view can show "currently using: opencode/gpt-5-nano (free)".
|
|
554
|
+
|
|
555
|
+
export const LIGHTRAG_DEFAULT_LLM = 'opencode/gpt-5-nano';
|
|
556
|
+
export const LIGHTRAG_DEFAULT_EMBEDDING = 'opencode/text-embedding-3-small';
|
|
557
|
+
|
|
558
|
+
/**
|
|
559
|
+
* Return the effective LightRAG model defaults, applying env-var
|
|
560
|
+
* overrides on top of the built-in opencode-Zen-free defaults.
|
|
561
|
+
*
|
|
562
|
+
* @returns {{ llm: string, embedding: string, source: 'opencode-free' | 'env', llmSource: 'default' | 'env', embeddingSource: 'default' | 'env' }}
|
|
563
|
+
*/
|
|
564
|
+
export function getDefaultLightRAGConfig() {
|
|
565
|
+
const llmEnv = typeof process.env.BIZAR_LIGHTRAG_LLM === 'string' && process.env.BIZAR_LIGHTRAG_LLM.trim()
|
|
566
|
+
? process.env.BIZAR_LIGHTRAG_LLM.trim()
|
|
567
|
+
: null;
|
|
568
|
+
const embEnv = typeof process.env.BIZAR_LIGHTRAG_EMBEDDING === 'string' && process.env.BIZAR_LIGHTRAG_EMBEDDING.trim()
|
|
569
|
+
? process.env.BIZAR_LIGHTRAG_EMBEDDING.trim()
|
|
570
|
+
: null;
|
|
571
|
+
const llm = llmEnv || LIGHTRAG_DEFAULT_LLM;
|
|
572
|
+
const embedding = embEnv || LIGHTRAG_DEFAULT_EMBEDDING;
|
|
573
|
+
const source = (llmEnv || embEnv) ? 'env' : 'opencode-free';
|
|
574
|
+
return {
|
|
575
|
+
llm,
|
|
576
|
+
embedding,
|
|
577
|
+
source,
|
|
578
|
+
llmSource: llmEnv ? 'env' : 'default',
|
|
579
|
+
embeddingSource: embEnv ? 'env' : 'default',
|
|
580
|
+
};
|
|
581
|
+
}
|