ont-run 0.0.1
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 +228 -0
- package/bin/ont.ts +5 -0
- package/dist/bin/ont.d.ts +2 -0
- package/dist/bin/ont.js +13667 -0
- package/dist/index.js +23152 -0
- package/dist/src/browser/server.d.ts +16 -0
- package/dist/src/browser/transform.d.ts +87 -0
- package/dist/src/cli/commands/init.d.ts +12 -0
- package/dist/src/cli/commands/review.d.ts +17 -0
- package/dist/src/cli/index.d.ts +1 -0
- package/dist/src/cli/utils/config-loader.d.ts +13 -0
- package/dist/src/config/categorical.d.ts +76 -0
- package/dist/src/config/define.d.ts +46 -0
- package/dist/src/config/index.d.ts +4 -0
- package/dist/src/config/schema.d.ts +162 -0
- package/dist/src/config/types.d.ts +94 -0
- package/dist/src/index.d.ts +37 -0
- package/dist/src/lockfile/differ.d.ts +11 -0
- package/dist/src/lockfile/hasher.d.ts +31 -0
- package/dist/src/lockfile/index.d.ts +53 -0
- package/dist/src/lockfile/types.d.ts +90 -0
- package/dist/src/runtime/index.d.ts +28 -0
- package/dist/src/server/api/index.d.ts +20 -0
- package/dist/src/server/api/middleware.d.ts +34 -0
- package/dist/src/server/api/router.d.ts +18 -0
- package/dist/src/server/mcp/index.d.ts +23 -0
- package/dist/src/server/mcp/tools.d.ts +35 -0
- package/dist/src/server/resolver.d.ts +30 -0
- package/dist/src/server/start.d.ts +37 -0
- package/package.json +63 -0
- package/src/browser/server.ts +2567 -0
- package/src/browser/transform.ts +473 -0
- package/src/cli/commands/init.ts +226 -0
- package/src/cli/commands/review.ts +126 -0
- package/src/cli/index.ts +19 -0
- package/src/cli/utils/config-loader.ts +78 -0
- package/src/config/categorical.ts +101 -0
- package/src/config/define.ts +78 -0
- package/src/config/index.ts +23 -0
- package/src/config/schema.ts +196 -0
- package/src/config/types.ts +121 -0
- package/src/index.ts +53 -0
- package/src/lockfile/differ.ts +242 -0
- package/src/lockfile/hasher.ts +175 -0
- package/src/lockfile/index.ts +159 -0
- package/src/lockfile/types.ts +95 -0
- package/src/runtime/index.ts +114 -0
- package/src/server/api/index.ts +92 -0
- package/src/server/api/middleware.ts +118 -0
- package/src/server/api/router.ts +102 -0
- package/src/server/mcp/index.ts +182 -0
- package/src/server/mcp/tools.ts +199 -0
- package/src/server/resolver.ts +109 -0
- package/src/server/start.ts +151 -0
package/README.md
ADDED
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
# ont-run
|
|
2
|
+
|
|
3
|
+
**Vibe code with confidence.**
|
|
4
|
+
|
|
5
|
+
A web framework designed for the era of coding agents. You define the ontology—what operations exist and who can perform them. AI writes the implementation.
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
// ontology.config.ts
|
|
9
|
+
import { defineOntology, z } from 'ont-run';
|
|
10
|
+
|
|
11
|
+
export default defineOntology({
|
|
12
|
+
name: 'support-desk',
|
|
13
|
+
|
|
14
|
+
accessGroups: {
|
|
15
|
+
public: { description: 'Unauthenticated users' },
|
|
16
|
+
support: { description: 'Support agents' },
|
|
17
|
+
admin: { description: 'Administrators' },
|
|
18
|
+
},
|
|
19
|
+
|
|
20
|
+
functions: {
|
|
21
|
+
getTicket: {
|
|
22
|
+
description: 'Get ticket details',
|
|
23
|
+
access: ['support', 'admin'],
|
|
24
|
+
inputs: z.object({ ticketId: z.string().uuid() }),
|
|
25
|
+
resolver: './resolvers/getTicket.ts',
|
|
26
|
+
},
|
|
27
|
+
assignTicket: {
|
|
28
|
+
description: 'Assign ticket to an agent',
|
|
29
|
+
access: ['admin'], // If AI tries to add 'public' here, review is triggered
|
|
30
|
+
inputs: z.object({ ticketId: z.string().uuid(), assignee: z.string() }),
|
|
31
|
+
resolver: './resolvers/assignTicket.ts',
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
// ...
|
|
35
|
+
});
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## How It Works
|
|
39
|
+
|
|
40
|
+
Coding agents (Claude Code, Cursor, etc.) can edit resolver implementations freely. But changes to the ontology—functions, access groups, inputs—trigger a review that agents can't bypass. It's built into the framework.
|
|
41
|
+
|
|
42
|
+
| Layer | Contains | Who modifies |
|
|
43
|
+
|-------|----------|--------------|
|
|
44
|
+
| **Ontology** | Functions, access groups, inputs, entities | Humans only (via `ont-run review`) |
|
|
45
|
+
| **Implementation** | Resolver code | AI agents freely |
|
|
46
|
+
|
|
47
|
+
Your job shifts: instead of writing every line, you encode what the system can do and who can do it. You review a visual map of capabilities—not 7,000 lines of code.
|
|
48
|
+
|
|
49
|
+
## The Enforcement
|
|
50
|
+
|
|
51
|
+
If Claude tries to let `public` call `assignTicket` (currently `admin`-only):
|
|
52
|
+
|
|
53
|
+
1. The ontology config changes
|
|
54
|
+
2. `ont.lock` detects the mismatch
|
|
55
|
+
3. Server refuses to start
|
|
56
|
+
4. You review the visual diff and approve or reject
|
|
57
|
+
|
|
58
|
+
```
|
|
59
|
+
WARN Ontology has changed:
|
|
60
|
+
~ assignTicket
|
|
61
|
+
Access: [admin] -> [admin, public]
|
|
62
|
+
|
|
63
|
+
WARN Run `npx ont-run review` to approve these changes.
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
**Why not just prompts?** The ontology is the source of truth. The framework won't run if it changes without human review.
|
|
67
|
+
|
|
68
|
+
## Installation
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
npm install ont-run
|
|
72
|
+
# or
|
|
73
|
+
bun add ont-run
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Works with both Node.js and Bun.
|
|
77
|
+
|
|
78
|
+
## Quick Start
|
|
79
|
+
|
|
80
|
+
### 1. Initialize
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
npx ont-run init my-api
|
|
84
|
+
cd my-api
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### 2. Review the initial ontology
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
npx ont-run review
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Opens a browser showing all functions and access groups. Click **Approve** to generate `ont.lock`.
|
|
94
|
+
|
|
95
|
+
### 3. Start the server
|
|
96
|
+
|
|
97
|
+
```typescript
|
|
98
|
+
// index.ts
|
|
99
|
+
import { startOnt } from 'ont-run';
|
|
100
|
+
|
|
101
|
+
await startOnt({ port: 3000 });
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
bun index.ts
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Your API is running at `http://localhost:3000`.
|
|
109
|
+
|
|
110
|
+
## Writing Resolvers
|
|
111
|
+
|
|
112
|
+
Resolvers are where AI writes the implementation:
|
|
113
|
+
|
|
114
|
+
```typescript
|
|
115
|
+
// resolvers/assignTicket.ts
|
|
116
|
+
import type { ResolverContext } from 'ont-run';
|
|
117
|
+
|
|
118
|
+
export default async function assignTicket(
|
|
119
|
+
ctx: ResolverContext,
|
|
120
|
+
args: { ticketId: string; assignee: string }
|
|
121
|
+
) {
|
|
122
|
+
// AI can modify this freely—no review required
|
|
123
|
+
const ticket = await db.tickets.update({
|
|
124
|
+
where: { id: args.ticketId },
|
|
125
|
+
data: { assigneeId: args.assignee },
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
return { id: ticket.id, assignedTo: args.assignee };
|
|
129
|
+
}
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
The resolver context provides:
|
|
133
|
+
- `ctx.env` — Current environment name
|
|
134
|
+
- `ctx.envConfig` — Environment configuration
|
|
135
|
+
- `ctx.logger` — Logger instance
|
|
136
|
+
- `ctx.accessGroups` — Access groups for the request
|
|
137
|
+
|
|
138
|
+
## Configuration Reference
|
|
139
|
+
|
|
140
|
+
```typescript
|
|
141
|
+
import { defineOntology, z } from 'ont-run';
|
|
142
|
+
|
|
143
|
+
export default defineOntology({
|
|
144
|
+
name: 'my-api',
|
|
145
|
+
|
|
146
|
+
environments: {
|
|
147
|
+
dev: { debug: true },
|
|
148
|
+
prod: { debug: false },
|
|
149
|
+
},
|
|
150
|
+
|
|
151
|
+
auth: async (req: Request) => {
|
|
152
|
+
const token = req.headers.get('Authorization');
|
|
153
|
+
if (!token) return ['public'];
|
|
154
|
+
if (token === 'admin-secret') return ['admin', 'user', 'public'];
|
|
155
|
+
return ['user', 'public'];
|
|
156
|
+
},
|
|
157
|
+
|
|
158
|
+
accessGroups: {
|
|
159
|
+
public: { description: 'Unauthenticated users' },
|
|
160
|
+
user: { description: 'Authenticated users' },
|
|
161
|
+
admin: { description: 'Administrators' },
|
|
162
|
+
},
|
|
163
|
+
|
|
164
|
+
entities: {
|
|
165
|
+
User: { description: 'A user account' },
|
|
166
|
+
Ticket: { description: 'A support ticket' },
|
|
167
|
+
},
|
|
168
|
+
|
|
169
|
+
functions: {
|
|
170
|
+
getUser: {
|
|
171
|
+
description: 'Get user by ID',
|
|
172
|
+
access: ['user', 'admin'],
|
|
173
|
+
entities: ['User'],
|
|
174
|
+
inputs: z.object({ userId: z.string().uuid() }),
|
|
175
|
+
resolver: './resolvers/getUser.ts',
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
});
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
## The Lockfile
|
|
182
|
+
|
|
183
|
+
`ont.lock` is the enforcement mechanism. It contains a hash of your ontology:
|
|
184
|
+
|
|
185
|
+
**What gets hashed (requires review):**
|
|
186
|
+
- Function names and descriptions
|
|
187
|
+
- Access group assignments
|
|
188
|
+
- Input schemas
|
|
189
|
+
|
|
190
|
+
**What doesn't get hashed (AI can change freely):**
|
|
191
|
+
- Resolver implementations
|
|
192
|
+
- Environment configurations
|
|
193
|
+
- Auth function implementation
|
|
194
|
+
|
|
195
|
+
## CLI Commands
|
|
196
|
+
|
|
197
|
+
```bash
|
|
198
|
+
npx ont-run init [dir] # Initialize a new project
|
|
199
|
+
npx ont-run review # Review and approve ontology changes
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
## API Endpoints
|
|
203
|
+
|
|
204
|
+
All functions are exposed as POST endpoints:
|
|
205
|
+
|
|
206
|
+
```bash
|
|
207
|
+
# Call a function
|
|
208
|
+
curl -X POST http://localhost:3000/api/getUser \
|
|
209
|
+
-H "Authorization: your-token" \
|
|
210
|
+
-H "Content-Type: application/json" \
|
|
211
|
+
-d '{"userId": "123e4567-e89b-12d3-a456-426614174000"}'
|
|
212
|
+
|
|
213
|
+
# List available functions
|
|
214
|
+
curl http://localhost:3000/api
|
|
215
|
+
|
|
216
|
+
# Health check
|
|
217
|
+
curl http://localhost:3000/health
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
## The Bigger Picture
|
|
221
|
+
|
|
222
|
+
As the cost of software production trends toward the cost of compute, every business will encode itself as a software system—through autonomous agents and process orchestration.
|
|
223
|
+
|
|
224
|
+
ont-run is the enforcement layer that keeps AI agents aligned with your business rules as they automate your operations.
|
|
225
|
+
|
|
226
|
+
## License
|
|
227
|
+
|
|
228
|
+
MIT
|
package/bin/ont.ts
ADDED