@kelceyp/caw-server 1.0.246 → 1.0.249
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/README.md +9 -185
- package/dist/cli.js +4 -10
- package/dist/main.js +434 -434
- package/dist/public_html/main.js +449 -449
- package/dist/public_html/styles.css +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,198 +1,22 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @kelceyp/caw-server
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
You probably want **[`@kelceyp/caw`](https://www.npmjs.com/package/@kelceyp/caw)**, which installs, launches and manages this server for you.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
`@kelceyp/caw-server` is the backing server component of [CAW](https://www.npmjs.com/package/@kelceyp/caw): a REST API, an MCP server, the web UI static assets, and a SQLite-backed content store, packaged as one Node.js application.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
## Standalone install
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
- **MCP Server** - HTTP MCP server for Claude Code integration
|
|
11
|
-
- **WebSocket Bridge** - Real-time communication with browser extension tabs
|
|
12
|
-
- **Core** - Business logic layer (services, stores, entities)
|
|
13
|
-
- **Static File Hosting** - Serves the web client
|
|
14
|
-
|
|
15
|
-
## Architecture
|
|
16
|
-
|
|
17
|
-
```
|
|
18
|
-
┌─────────────────────────────────────────┐
|
|
19
|
-
│ API Layer (REST/MCP) │ HTTP routes, MCP tools
|
|
20
|
-
│ (api/, mcp/) │ Auth via Bearer tokens
|
|
21
|
-
└─────────────────────────────────────────┘
|
|
22
|
-
↓
|
|
23
|
-
┌─────────────────────────────────────────┐
|
|
24
|
-
│ Server.js │ Express app setup
|
|
25
|
-
│ (main.js) │ Port management
|
|
26
|
-
└─────────────────────────────────────────┘
|
|
27
|
-
↓
|
|
28
|
-
┌─────────────────────────────────────────┐
|
|
29
|
-
│ Core Facade │ Token resolution
|
|
30
|
-
│ (core/Core.js) │ Service caching
|
|
31
|
-
│ │ Flat API
|
|
32
|
-
└─────────────────────────────────────────┘
|
|
33
|
-
↓
|
|
34
|
-
┌─────────────────────────────────────────┐
|
|
35
|
-
│ Services Layer │ Orchestration
|
|
36
|
-
│ (core/services/) │ Business workflows
|
|
37
|
-
│ │ Multi-store coordination
|
|
38
|
-
└─────────────────────────────────────────┘
|
|
39
|
-
↓
|
|
40
|
-
┌─────────────────────────────────────────┐
|
|
41
|
-
│ Stores Layer │ Data access
|
|
42
|
-
│ (core/stores/) │ Identity Map caching
|
|
43
|
-
│ │ CRUD operations
|
|
44
|
-
└─────────────────────────────────────────┘
|
|
45
|
-
↓
|
|
46
|
-
┌─────────────────────────────────────────┐
|
|
47
|
-
│ Database Layer │ SQLite
|
|
48
|
-
│ (db/) │ Kysely query builder
|
|
49
|
-
└─────────────────────────────────────────┘
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
## Directory Structure
|
|
53
|
-
|
|
54
|
-
```
|
|
55
|
-
server/
|
|
56
|
-
├── src/
|
|
57
|
-
│ ├── main.js # Entry point, server initialization
|
|
58
|
-
│ ├── Server.js # Express app factory
|
|
59
|
-
│ ├── api/ # REST API routes
|
|
60
|
-
│ │ ├── ProjectRoutes.js
|
|
61
|
-
│ │ ├── FolderRoutes.js
|
|
62
|
-
│ │ ├── DocumentRoutes.js
|
|
63
|
-
│ │ ├── TemplateRoutes.js
|
|
64
|
-
│ │ ├── FieldRoutes.js
|
|
65
|
-
│ │ ├── BundleRoutes.js
|
|
66
|
-
│ │ └── EventRoutes.js
|
|
67
|
-
│ ├── core/ # Business logic layer
|
|
68
|
-
│ │ ├── Core.js # Facade - token resolution, service caching
|
|
69
|
-
│ │ ├── entities/ # Domain objects (read-only)
|
|
70
|
-
│ │ ├── services/ # Orchestration layer
|
|
71
|
-
│ │ └── stores/ # Data access + caching
|
|
72
|
-
│ ├── db/ # Database layer
|
|
73
|
-
│ │ ├── Connection.js # Database connection factory
|
|
74
|
-
│ │ ├── schema.js # Table definitions
|
|
75
|
-
│ │ └── seed.js # Initial data seeding
|
|
76
|
-
│ ├── mcp/ # MCP server implementation
|
|
77
|
-
│ ├── wss/ # WebSocket server
|
|
78
|
-
│ ├── static/ # Static files for web client
|
|
79
|
-
│ └── common/ # Shared utilities
|
|
80
|
-
└── test/ # Test suites
|
|
81
|
-
├── unit/ # In-memory unit tests
|
|
82
|
-
├── integration/ # Real database integration tests
|
|
83
|
-
└── component/ # Black-box HTTP tests via subprocess
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
## Port Configuration
|
|
87
|
-
|
|
88
|
-
The server uses the `CAW_PORT` environment variable:
|
|
89
|
-
|
|
90
|
-
```bash
|
|
91
|
-
CAW_PORT=2229 caw-server # Default: 2229
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
## Building
|
|
95
|
-
|
|
96
|
-
```bash
|
|
97
|
-
# Build server only
|
|
98
|
-
bun run build
|
|
99
|
-
|
|
100
|
-
# Build client + server
|
|
101
|
-
bun run build:all
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
Output: `dist/main.js` (ES6 module for Node.js)
|
|
105
|
-
|
|
106
|
-
## Running
|
|
107
|
-
|
|
108
|
-
```bash
|
|
109
|
-
# Development (uses source files)
|
|
110
|
-
bun run dev
|
|
111
|
-
|
|
112
|
-
# Production (uses built files)
|
|
113
|
-
node dist/main.js
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
## Testing
|
|
117
|
-
|
|
118
|
-
```bash
|
|
119
|
-
# Run all tests
|
|
120
|
-
bun test
|
|
121
|
-
|
|
122
|
-
# Run specific test suite
|
|
123
|
-
bun test test/unit/
|
|
124
|
-
bun test test/integration/
|
|
125
|
-
bun test test/component/
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
Test types:
|
|
129
|
-
- **Unit** - In-memory tests (entities, utilities)
|
|
130
|
-
- **Integration** - Real database tests (stores, services)
|
|
131
|
-
- **Component** - Black-box HTTP tests (API routes, MCP tools)
|
|
132
|
-
|
|
133
|
-
## Tech Stack
|
|
134
|
-
|
|
135
|
-
- **Pure JavaScript** - ES6 modules, factory functions only
|
|
136
|
-
- **Express** - HTTP server framework
|
|
137
|
-
- **Kysely** - SQL query builder (type-safe)
|
|
138
|
-
- **better-sqlite3** - SQLite driver
|
|
139
|
-
- **ws** - WebSocket server
|
|
140
|
-
- **MCP SDK** - Model Context Protocol implementation
|
|
141
|
-
- **Bun** - Build tool (development and bundling)
|
|
142
|
-
|
|
143
|
-
## Distribution
|
|
144
|
-
|
|
145
|
-
Published to npm as `@kelceyp/caw-server`:
|
|
9
|
+
Most users should install the launcher instead — it handles lifecycle (start / stop / status / logs / upgrade), config, and integrations. If you have a specific reason to run the server directly:
|
|
146
10
|
|
|
147
11
|
```bash
|
|
148
|
-
# Global install
|
|
149
12
|
npm install -g @kelceyp/caw-server
|
|
150
|
-
|
|
151
|
-
# Run
|
|
152
13
|
caw-server
|
|
153
14
|
```
|
|
154
15
|
|
|
155
|
-
##
|
|
156
|
-
|
|
157
|
-
### Token-Based Authentication
|
|
158
|
-
|
|
159
|
-
All API and MCP requests use Bearer tokens:
|
|
160
|
-
|
|
161
|
-
```bash
|
|
162
|
-
Authorization: Bearer <project-token>
|
|
163
|
-
```
|
|
164
|
-
|
|
165
|
-
Core facade resolves tokens to project context and caches services per project.
|
|
166
|
-
|
|
167
|
-
### Multi-Store System
|
|
168
|
-
|
|
169
|
-
Projects use a hierarchical store structure:
|
|
170
|
-
- **DemuxStore** - Routes operations to child stores
|
|
171
|
-
- **LocalStore A** - Project-specific content
|
|
172
|
-
- **LocalStore B** - Shared content across projects
|
|
173
|
-
|
|
174
|
-
### Identity Map Caching
|
|
175
|
-
|
|
176
|
-
Stores cache entities to ensure single object instance per ID:
|
|
177
|
-
- Cache checked before database queries
|
|
178
|
-
- Mutations update cache after DB commit (via onSuccess callbacks)
|
|
179
|
-
- Referential equality guaranteed
|
|
180
|
-
|
|
181
|
-
### Field System
|
|
16
|
+
## Links
|
|
182
17
|
|
|
183
|
-
|
|
184
|
-
- In-memory only (not persisted)
|
|
185
|
-
- Store-level defaults
|
|
186
|
-
- Single-valued and multi-valued fields
|
|
187
|
-
- Accessed via FieldService
|
|
18
|
+
- [Report an Issue or request a Feature](https://github.com/kelceyp/caw-feedback/issues)
|
|
188
19
|
|
|
189
|
-
##
|
|
20
|
+
## License
|
|
190
21
|
|
|
191
|
-
|
|
192
|
-
- `/core/README.md` - Core architecture
|
|
193
|
-
- `/core/entities/README.md` - Domain entities
|
|
194
|
-
- `/core/services/README.md` - Service layer
|
|
195
|
-
- `/core/stores/README.md` - Data access layer
|
|
196
|
-
- `/api/README.md` - REST API routes
|
|
197
|
-
- `/db/README.md` - Database layer
|
|
198
|
-
- `/test/README.md` - Testing guide
|
|
22
|
+
Proprietary. All rights reserved.
|
package/dist/cli.js
CHANGED
|
@@ -10163,15 +10163,14 @@ var list_default5 = Object.freeze({ create: create74 });
|
|
|
10163
10163
|
// src/commands/bundle/preview.js
|
|
10164
10164
|
var splitIds = (value) => value.split(",").map((s) => s.trim()).filter((s) => s.length > 0);
|
|
10165
10165
|
var create75 = ({ httpClient }) => {
|
|
10166
|
-
return createCommand("preview").summary("Preview a bundle export (dependency walk)").param((p) => p.name("sid").type("string").flag("sid", "s").required()).param((p) => p.name("store").type("string").flag("store")).param((p) => p.name("pickedDocIds").type("string").flag("pickedDocIds")).param((p) => p.name("pickedTemplateIds").type("string").flag("pickedTemplateIds")).param((p) => p.name("pickedTrackIds").type("string").flag("pickedTrackIds")).param((p) => p.name("pickedFolderIds").type("string").flag("pickedFolderIds")).
|
|
10166
|
+
return createCommand("preview").summary("Preview a bundle export (dependency walk)").param((p) => p.name("sid").type("string").flag("sid", "s").required()).param((p) => p.name("store").type("string").flag("store")).param((p) => p.name("pickedDocIds").type("string").flag("pickedDocIds")).param((p) => p.name("pickedTemplateIds").type("string").flag("pickedTemplateIds")).param((p) => p.name("pickedTrackIds").type("string").flag("pickedTrackIds")).param((p) => p.name("pickedFolderIds").type("string").flag("pickedFolderIds")).run(async (ctx) => {
|
|
10167
10167
|
const {
|
|
10168
10168
|
sid,
|
|
10169
10169
|
store,
|
|
10170
10170
|
pickedDocIds,
|
|
10171
10171
|
pickedTemplateIds,
|
|
10172
10172
|
pickedTrackIds,
|
|
10173
|
-
pickedFolderIds
|
|
10174
|
-
excludeIds
|
|
10173
|
+
pickedFolderIds
|
|
10175
10174
|
} = ctx.params;
|
|
10176
10175
|
const args = { commit: false };
|
|
10177
10176
|
if (pickedDocIds !== undefined)
|
|
@@ -10182,8 +10181,6 @@ var create75 = ({ httpClient }) => {
|
|
|
10182
10181
|
args.pickedTrackIds = splitIds(pickedTrackIds);
|
|
10183
10182
|
if (pickedFolderIds !== undefined)
|
|
10184
10183
|
args.pickedFolderIds = splitIds(pickedFolderIds);
|
|
10185
|
-
if (excludeIds !== undefined)
|
|
10186
|
-
args.excludeIds = splitIds(excludeIds);
|
|
10187
10184
|
if (store !== undefined)
|
|
10188
10185
|
args.store = store;
|
|
10189
10186
|
const result = await httpClient.post(`/cli/mcp-client/${sid}/dispatch`, {
|
|
@@ -10200,7 +10197,7 @@ var preview_default = Object.freeze({ create: create75 });
|
|
|
10200
10197
|
// src/commands/bundle/export.js
|
|
10201
10198
|
var splitIds2 = (value) => value.split(",").map((s) => s.trim()).filter((s) => s.length > 0);
|
|
10202
10199
|
var create76 = ({ httpClient }) => {
|
|
10203
|
-
return createCommand("export").summary("Export a bundle (commit)").param((p) => p.name("sid").type("string").flag("sid", "s").required()).param((p) => p.name("name").type("string").flag("name").required()).param((p) => p.name("store").type("string").flag("store")).param((p) => p.name("pickedDocIds").type("string").flag("pickedDocIds")).param((p) => p.name("pickedTemplateIds").type("string").flag("pickedTemplateIds")).param((p) => p.name("pickedTrackIds").type("string").flag("pickedTrackIds")).param((p) => p.name("pickedFolderIds").type("string").flag("pickedFolderIds")).
|
|
10200
|
+
return createCommand("export").summary("Export a bundle (commit)").param((p) => p.name("sid").type("string").flag("sid", "s").required()).param((p) => p.name("name").type("string").flag("name").required()).param((p) => p.name("store").type("string").flag("store")).param((p) => p.name("pickedDocIds").type("string").flag("pickedDocIds")).param((p) => p.name("pickedTemplateIds").type("string").flag("pickedTemplateIds")).param((p) => p.name("pickedTrackIds").type("string").flag("pickedTrackIds")).param((p) => p.name("pickedFolderIds").type("string").flag("pickedFolderIds")).run(async (ctx) => {
|
|
10204
10201
|
const {
|
|
10205
10202
|
sid,
|
|
10206
10203
|
name,
|
|
@@ -10208,8 +10205,7 @@ var create76 = ({ httpClient }) => {
|
|
|
10208
10205
|
pickedDocIds,
|
|
10209
10206
|
pickedTemplateIds,
|
|
10210
10207
|
pickedTrackIds,
|
|
10211
|
-
pickedFolderIds
|
|
10212
|
-
excludeIds
|
|
10208
|
+
pickedFolderIds
|
|
10213
10209
|
} = ctx.params;
|
|
10214
10210
|
const args = { commit: true, name };
|
|
10215
10211
|
if (pickedDocIds !== undefined)
|
|
@@ -10220,8 +10216,6 @@ var create76 = ({ httpClient }) => {
|
|
|
10220
10216
|
args.pickedTrackIds = splitIds2(pickedTrackIds);
|
|
10221
10217
|
if (pickedFolderIds !== undefined)
|
|
10222
10218
|
args.pickedFolderIds = splitIds2(pickedFolderIds);
|
|
10223
|
-
if (excludeIds !== undefined)
|
|
10224
|
-
args.excludeIds = splitIds2(excludeIds);
|
|
10225
10219
|
if (store !== undefined)
|
|
10226
10220
|
args.store = store;
|
|
10227
10221
|
const result = await httpClient.post(`/cli/mcp-client/${sid}/dispatch`, {
|