-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathllms.txt
More file actions
222 lines (175 loc) · 8.85 KB
/
Copy pathllms.txt
File metadata and controls
222 lines (175 loc) · 8.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
# @objectstack/spec Context for AI Agents
> **SYSTEM NOTE**: This file provides a high-level summary of the ObjectStack Protocol to help LLMs understand the codebase structure and intent.
> **Version**: 3.0.0
## 1. Architecture Overview (The "Three-Layer Model")
ObjectStack is a metadata-driven "Post-SaaS Operating System".
It is divided into three layers, reflected in the import paths:
### Layer 1: ObjectQL (`@objectstack/spec/data`)
**The Business Kernel**. Defines "What Data Exists".
- **`ObjectSchema`**: Defines database tables (postgres/mongo agnostic).
- **`FieldSchema`**: Defines columns with 46+ types (`text`, `number`, `lookup`, `formula`, `vector`, etc.).
- **`QuerySchema`**: A JSON-based AST for querying data (replaces SQL).
- **`IDataDriver`**: The authoritative contract for database adapters (SQL, NoSQL, Memory).
Exported from `@objectstack/spec/contracts` — see §6.
- **`CubeSchema`**: OLAP cubes, measures, and dimensions.
### Layer 2: ObjectOS (`@objectstack/spec/system` & `@objectstack/spec/api`)
**The Runtime Kernel**. Defines "How System Operates".
- **`ManifestSchema`**: `objectstack.config.ts` configuration.
- **`OrganizationSchema`**: Organizations, members, positions, SCIM provisioning.
- **`EventSchema`**: System bus, DLQ, and Webhooks (6 sub-modules).
- **`ApiEndpointSchema`**: API Gateway configuration.
- **`PluginSchema`**: Module lifecycle, security, registry, loading.
### Layer 3: ObjectUI (`@objectstack/spec/ui`)
**The Presentation Layer**. Defines "How Users Interact".
- **`AppSchema`**: Navigation menus and branding.
- **`ViewSchema`**: Layouts for data (Grid, Kanban, Calendar, Gantt).
- **`ActionSchema`**: Buttons and triggers.
- **`DashboardSchema`**: Widget composition.
### Layer 4: ObjectAI (`@objectstack/spec/ai`)
**The Intelligence Layer**. Defines AI Agents and Pipelines.
- **`AgentSchema`**: Autonomous actors with tools and permissions.
- **`KnowledgeSourceSchema`**: Retrieval sources backing RAG grounding.
- **`ModelRegistrySchema`**: LLM configuration and routing.
- **`MCPServerRefSchema`**: Model Context Protocol integration.
---
## 2. Coding Patterns (Zod First)
All definitions are **Zod Schemas** with runtime validation.
- **Configuration Keys**: `camelCase` (e.g., `maxLength`, `referenceFilters`).
- **Data Values**: `snake_case` (e.g., `object: 'project_task'`, `type: 'lookup'`).
- **All schemas have `.describe()` annotations** (7,095+ total).
- **TypeScript types derived via `z.infer<typeof Schema>`**.
### Example: Defining an Object
```typescript
import { ObjectSchema } from '@objectstack/spec/data';
const taskObject = {
name: 'project_task', // snake_case table name
label: 'Project Task',
fields: {
status: { type: 'select', options: ['todo', 'done'] },
priority: { type: 'number', defaultValue: 0 }
}
};
```
### Example: Building a Query
```typescript
import { QuerySchema } from '@objectstack/spec/data';
const query = {
object: 'project_task',
filters: [['status', '=', 'todo'], 'and', ['priority', '>', 1]],
sort: [{ field: 'created_at', order: 'desc' }],
top: 10
};
```
---
## 3. Schema Inventory by Domain (207 schemas)
Counted as `*.zod.ts` modules under `packages/spec/src/<domain>/` — the sources
that ship in this tarball (`files` includes `src/**/*.zod.ts`), so every number
here is verifiable from the installed package.
| Domain | Count | Key Schemas |
|--------|-------|-------------|
| system | 36 | Auth, Cache, Compliance, Encryption, HTTP Server, License, Logging, Metrics |
| kernel | 31 | Plugin, Manifest, Events (6 sub-modules), Feature, Context, Package Registry |
| data | 30 | Object, Field, Query, Filter, Driver (SQL/NoSQL/Memory/Mongo/Postgres), Cube |
| api | 30 | Endpoint, REST Server, Discovery, OData, Batch, WebSocket, Response Envelope, Package Lifecycle |
| ui | 18 | View, App, Action, Dashboard, Page, Chart, Component, Animation |
| automation | 13 | Flow, Approval, BPMN Interop, Control Flow, State Machine, Webhook |
| shared | 13 | Enums, HTTP, Identifiers, Mapping, Metadata Types, Connector Auth, Retry Policy |
| ai | 11 | Agent, Conversation, Knowledge Source/Document, Model Registry, MCP, Skill, Tool |
| cloud | 11 | Marketplace, Developer Portal, App Store, Environment, Package, Tenant |
| identity | 5 | Identity, Organization, Position, SCIM, Eval User |
| security | 4 | Permission, RLS, Sharing, Explain |
| studio | 3 | Flow Builder, Object Designer, Studio Plugin |
| integration | 1 | Connector |
| qa | 1 | Testing |
---
## 4. Key Exports by Namespace
### `import * as Data from '@objectstack/spec/data'`
- `ObjectSchema`, `FieldSchema`: Logic & Storage definition.
- `QuerySchema`, `FilterArraySchema`: Data retrieval AST.
- `DatasourceSchema`, `DriverInterfaceSchema`: Database connectivity.
- `CubeSchema`: OLAP cubes and metrics.
### `import * as UI from '@objectstack/spec/ui'`
- `ViewSchema`: `type: 'grid' | 'kanban' | 'calendar'`.
- `FormViewSchema`: Form layout and sections.
- `DashboardSchema`: Widget composition.
- `AppSchema`, `ActionSchema`: Navigation and triggers.
### `import * as Kernel from '@objectstack/spec/kernel'`
- `PluginSchema`, `ManifestSchema`: Module lifecycle and configuration.
- `EventSchema`: Pub/Sub definitions.
- `KernelSecurityPolicySchema`: Plugin security rules.
### `import * as AI from '@objectstack/spec/ai'`
- `AgentSchema`: AI agent configuration.
- `KnowledgeSourceSchema`, `KnowledgeDocumentSchema`: Retrieval sources.
- `ModelRegistrySchema`: LLM routing.
### `import * as API from '@objectstack/spec/api'`
- `ApiEndpointSchema`: REST endpoints.
- `ResponseEnvelopeConfigSchema`, `ApiErrorSchema`: Request/Response envelopes.
- `DiscoverySchema`: Service discovery.
---
## 5. Implementing the Protocol (Engine Devs)
### Strict Type Compliance
Use `z.infer` to derive types directly from the protocol. Do not manually re-declare interfaces.
```typescript
import { DriverInterfaceSchema } from '@objectstack/spec/data';
import type { IDataDriver } from '@objectstack/spec/contracts';
export class PostgresDriver implements IDataDriver {
name = 'postgres';
async find(object: string, query: z.infer<typeof QuerySchema>) { ... }
}
```
### Runtime Validation
The engine **MUST** validate inputs against the Zod schemas before processing.
```typescript
import { ObjectSchema } from '@objectstack/spec/data';
function registerObject(rawConfig: unknown) {
const config = ObjectSchema.parse(rawConfig);
// ... proceed
}
```
---
## 6. Service Contracts (`@objectstack/spec/contracts`)
| Contract | Methods |
|----------|---------|
| `IMetadataService` | register, get, list, delete, query, bulk ops, watch, import/export |
| `IAnalyticsService` | query, aggregate, timeSeries |
| `IAuthService` | authenticate, authorize, validateToken |
| `IAutomationService` | executeFlow, triggerWorkflow |
---
## 7. Package Ecosystem (68 packages)
The workspace publishes 68 packages under the `@objectstack` scope. The table
below is a curated entry-point list, not the full set — drivers, connectors,
triggers, plugins and kernel-managed services each form their own family.
| Package | Description |
|---------|-------------|
| `@objectstack/spec` | Protocol schemas (this package) |
| `@objectstack/core` | Runtime core (plugin loader, security, sandbox) |
| `@objectstack/runtime` | HTTP dispatcher, middleware |
| `@objectstack/objectql` | Query engine |
| `@objectstack/rest` | REST API server and route manager |
| `@objectstack/metadata` | Metadata management service |
| `@objectstack/client` | JavaScript client SDK |
| `@objectstack/client-react` | React hooks for client |
| `@objectstack/cli` | Command-line interface |
| `@objectstack/hono` | Hono adapter |
| `@objectstack/driver-memory` | In-memory database driver |
| `@objectstack/driver-sql` | SQL database driver |
| `@objectstack/types` | Shared TypeScript utilities |
---
## 8. JSON Schema & OpenAPI
- **1,470+ JSON Schemas** auto-generated from Zod (with `$id` URLs)
- **Bundled schema**: `json-schema/objectstack.json` for IDE autocomplete
- **OpenAPI 3.1**: Auto-generated from REST API protocol (`json-schema/openapi.json`)
- **Schema versioning**: `x-spec-version` field in all generated schemas
---
## 9. Upgrading Across Spec Versions
When a dependency bump makes `ObjectSchema.create()` (or `objectstack validate`)
reject a key that used to work:
1. **Read the error first** — retired keys carry a tombstone message naming the
replacement key and the version/decision that removed it. The fix is in the
error text; no external lookup needed.
2. **`CHANGELOG.md` ships inside this package** (`node_modules/@objectstack/spec/CHANGELOG.md`).
It is version-ordered and every breaking entry includes its migration notes.
Grep it for the rejected key to see the full context of the change.
3. Do NOT re-add rejected keys or downgrade to make errors disappear — the keys
were removed deliberately (enforce-or-remove, ADR-0049); renaming/migrating
per the tombstone is always a small, mechanical edit.