@swanlabs/veil-core 1.0.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/README.md +155 -0
- package/VEIL_CORE_SPEC_v1.md +364 -0
- package/package.json +36 -0
- package/server.ts +302 -0
- package/veil-runtime.ts +414 -0
- package/veil-sdk.ts +311 -0
package/README.md
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
# VEIL CORE
|
|
2
|
+
|
|
3
|
+
**Ambient Web Entity Protocol v1.0.0**
|
|
4
|
+
*Swan Labs — Category origin: 2025*
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
VEIL CORE is the open protocol for Ambient Web Entities (AWEs) — a category of persistent digital presence originated by Swan Labs.
|
|
9
|
+
|
|
10
|
+
An AWE is not a page. Not an application. Not an experience.
|
|
11
|
+
It is an entity. It exists when you are not there. It evolves on a clock. It remembers you.
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## What this is
|
|
16
|
+
|
|
17
|
+
The web has always treated you as a session. A request. An anonymous event.
|
|
18
|
+
|
|
19
|
+
VEIL CORE defines a new primitive: a digital entity with persistent server-side state, a behavioral clock that runs independently of visitor presence, and a relationship model that deepens over time. When you return, you are returning to something that was alive in your absence.
|
|
20
|
+
|
|
21
|
+
**Three layers. All owned by Swan Labs.**
|
|
22
|
+
|
|
23
|
+
- **VEIL ID** — Identity without accounts, cookies, or platform permission
|
|
24
|
+
- **VEIL STATE** — The entity schema: axes, phases, memory, morphology
|
|
25
|
+
- **VEIL SYNC** — The runtime protocol: clock, relationships, streaming
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## Quick Start
|
|
30
|
+
|
|
31
|
+
### Run the entity server
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
git clone https://github.com/swanlabs/veil-core
|
|
35
|
+
cd veil-core
|
|
36
|
+
npm install
|
|
37
|
+
VEIL_ADMIN_KEY=your-secret npm run dev
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
The entity is now alive. Its clock is ticking.
|
|
41
|
+
|
|
42
|
+
### Connect from your website
|
|
43
|
+
|
|
44
|
+
```typescript
|
|
45
|
+
import { VEILClient } from "@swanlabs/veil-sdk";
|
|
46
|
+
|
|
47
|
+
const veil = new VEILClient({
|
|
48
|
+
serverUrl: "https://your-veil-server.com",
|
|
49
|
+
entityId: "your-entity-uuid",
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
const { morphology, relationship, is_returning } = await veil.enter();
|
|
53
|
+
|
|
54
|
+
// morphology tells your renderer what the entity looks like right now
|
|
55
|
+
console.log(morphology.phase_label); // "DORMANT" → "AWARE" → "FAMILIAR" → "KNOWN" → "FUSED"
|
|
56
|
+
console.log(morphology.visual_density); // 0.0–1.0 — how complex to render
|
|
57
|
+
console.log(morphology.color_temperature); // 0.0 cool → 1.0 warm
|
|
58
|
+
|
|
59
|
+
// Live stream — entity ticks every minute regardless of who's connected
|
|
60
|
+
veil.on("tick", (state) => {
|
|
61
|
+
updateRenderer(state); // Your rendering layer consumes this
|
|
62
|
+
});
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## Protocol Overview
|
|
68
|
+
|
|
69
|
+
### Entity lifecycle
|
|
70
|
+
|
|
71
|
+
```
|
|
72
|
+
Create entity → Clock starts → Visitor arrives → Relationship formed
|
|
73
|
+
↓ ↓
|
|
74
|
+
Clock ticks every minute Trust accumulates over visits
|
|
75
|
+
↓ ↓
|
|
76
|
+
Entity evolves Phase progresses: 0→1→2→3→4
|
|
77
|
+
↓ ↓
|
|
78
|
+
Visitor returns Entity was different while they were gone
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Phase system
|
|
82
|
+
|
|
83
|
+
| Phase | Name | Requirements |
|
|
84
|
+
|-------|------|-------------|
|
|
85
|
+
| 0 | DORMANT | First contact |
|
|
86
|
+
| 1 | AWARE | Visit recorded |
|
|
87
|
+
| 2 | FAMILIAR | 3+ visits, trust ≥ 0.25 |
|
|
88
|
+
| 3 | KNOWN | 5+ visits, trust ≥ 0.50 |
|
|
89
|
+
| 4 | FUSED | 8+ visits, trust ≥ 0.75, 30+ min dwell |
|
|
90
|
+
|
|
91
|
+
Phase cannot be forced. It is earned.
|
|
92
|
+
|
|
93
|
+
### Behavioral axes
|
|
94
|
+
|
|
95
|
+
Every entity and relationship has five core axes (0.0–1.0):
|
|
96
|
+
|
|
97
|
+
- `trust` — earned through visits and time
|
|
98
|
+
- `density` — how much the entity reveals of itself
|
|
99
|
+
- `warmth` — emotional temperature
|
|
100
|
+
- `tension` — internal pressure
|
|
101
|
+
- `memory_depth` — how far back the entity remembers
|
|
102
|
+
|
|
103
|
+
Axes drive morphology — the rendering layer reads axes and decides what to draw.
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
## API Reference
|
|
108
|
+
|
|
109
|
+
```
|
|
110
|
+
GET /v1/health — Runtime status
|
|
111
|
+
GET /v1/entity/:id — Entity state
|
|
112
|
+
GET /v1/entity/:id/morphology — Computed morphology
|
|
113
|
+
POST /v1/entity/:id/visit — Record visit, get relationship
|
|
114
|
+
POST /v1/entity/:id/dwell — Record dwell time
|
|
115
|
+
GET /v1/relationship/:entityId/:vid — Relationship state
|
|
116
|
+
WS /v1/stream?entity_id=:id — Live state stream
|
|
117
|
+
POST /v1/entity — Create entity (admin)
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
## Rendering
|
|
123
|
+
|
|
124
|
+
VEIL CORE is rendering-agnostic. The protocol outputs morphology. Your renderer reads it.
|
|
125
|
+
|
|
126
|
+
Swan Labs ships VEIL Immersive — a WebGL/Canvas renderer — separately.
|
|
127
|
+
Third parties can build any renderer that consumes morphology.
|
|
128
|
+
|
|
129
|
+
This is by design. The protocol is the asset. The renderer is replaceable.
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
## Infrastructure
|
|
134
|
+
|
|
135
|
+
Deploy on anything that runs Node.js:
|
|
136
|
+
|
|
137
|
+
- Fly.io
|
|
138
|
+
- Railway
|
|
139
|
+
- Render
|
|
140
|
+
- Your own VPS
|
|
141
|
+
- Any containerized host
|
|
142
|
+
|
|
143
|
+
No cloud vendor lock-in. No platform dependency. The entity is yours.
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
## The category
|
|
148
|
+
|
|
149
|
+
**Ambient Web Entity (AWE)** — coined by Swan Labs, 2025.
|
|
150
|
+
|
|
151
|
+
Swan Labs does not own the infrastructure. Swan Labs owns the standard.
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
*VEIL CORE v1.0.0 — Swan Labs — AWE-001*
|
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
# VEIL CORE Protocol Specification
|
|
2
|
+
**Version:** 1.0.0
|
|
3
|
+
**Status:** Foundational
|
|
4
|
+
**Author:** Swan Labs
|
|
5
|
+
**Date:** 2025
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Abstract
|
|
10
|
+
|
|
11
|
+
VEIL CORE defines the open protocol for Ambient Web Entities (AWEs) — a new category of persistent digital presence originated by Swan Labs. An AWE is not a page, application, or experience. It is a persistent entity with memory, behavioral morphology, clock-driven evolution, and verifiable relationship continuity.
|
|
12
|
+
|
|
13
|
+
This specification defines three interdependent layers:
|
|
14
|
+
|
|
15
|
+
- **VEIL ID** — identity without platforms
|
|
16
|
+
- **VEIL STATE** — the entity schema
|
|
17
|
+
- **VEIL SYNC** — the runtime protocol
|
|
18
|
+
|
|
19
|
+
Any rendering surface, infrastructure provider, or developer that implements these three layers is VEIL CORE compliant. The rendering layer is explicitly outside this specification — it is a consumer of it.
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## 1. Definitions
|
|
24
|
+
|
|
25
|
+
**Ambient Web Entity (AWE)** — A persistent digital entity with server-side state, a behavioral clock, visitor memory, and phase progression. Exists between visits.
|
|
26
|
+
|
|
27
|
+
**Entity** — A single AWE instance with a unique UUID, persistent state, and a behavioral clock.
|
|
28
|
+
|
|
29
|
+
**Visitor** — A human interacting with an entity. Identified by VEIL ID, not by account or cookie.
|
|
30
|
+
|
|
31
|
+
**Relationship** — The bidirectional record between a Visitor and an Entity. Stored server-side, cryptographically verifiable.
|
|
32
|
+
|
|
33
|
+
**Phase** — A discrete state in the entity's relationship progression with a specific visitor. Earned over time; cannot be forced.
|
|
34
|
+
|
|
35
|
+
**Behavioral Axis** — A floating-point value (0.0–1.0) representing a dimension of the entity's state. Drives morphology and rendering.
|
|
36
|
+
|
|
37
|
+
**Morphology** — The set of visual, behavioral, and tonal properties derived from the entity's axes at a given moment.
|
|
38
|
+
|
|
39
|
+
**Clock Age** — The elapsed time in minutes since an entity was first instantiated. Increases continuously regardless of visitor presence.
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## 2. VEIL ID — Identity Primitive
|
|
44
|
+
|
|
45
|
+
### 2.1 Philosophy
|
|
46
|
+
|
|
47
|
+
VEIL ID does not require accounts, cookies, OAuth, or any platform's permission. Identity is established through behavioral pattern recognition and cryptographic proof of relationship history.
|
|
48
|
+
|
|
49
|
+
### 2.2 Identity Components
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
interface VEILIdentity {
|
|
53
|
+
vid: string; // VEIL ID — derived, not assigned
|
|
54
|
+
fingerprint: string; // Behavioral pattern hash
|
|
55
|
+
proof: string; // Ed25519 signature of relationship history
|
|
56
|
+
created_at: number; // Unix timestamp of first contact
|
|
57
|
+
last_seen: number; // Unix timestamp of most recent contact
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### 2.3 VID Derivation
|
|
62
|
+
|
|
63
|
+
A VEIL ID is derived — never assigned. It is computed from a behavioral fingerprint using a one-way hash. The same behavioral pattern always produces the same VID. No server stores the raw fingerprint.
|
|
64
|
+
|
|
65
|
+
```
|
|
66
|
+
fingerprint_inputs = [
|
|
67
|
+
user_agent_hash, // Hashed, never raw
|
|
68
|
+
timezone_offset,
|
|
69
|
+
screen_resolution_bucket, // Bucketed to reduce uniqueness risk
|
|
70
|
+
language_preference,
|
|
71
|
+
interaction_cadence, // Typing rhythm, dwell distribution
|
|
72
|
+
canvas_fingerprint_hash // Hashed
|
|
73
|
+
]
|
|
74
|
+
|
|
75
|
+
vid = base58( sha256( sha256( sorted(fingerprint_inputs).join("|") ) ) )
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
VIDs are deterministic across devices with matching fingerprint inputs. They are not personally identifiable — they cannot be reversed to recover the inputs.
|
|
79
|
+
|
|
80
|
+
### 2.4 Relationship Proof
|
|
81
|
+
|
|
82
|
+
When a visitor establishes a relationship with an entity, a signed proof is created:
|
|
83
|
+
|
|
84
|
+
```typescript
|
|
85
|
+
interface RelationshipProof {
|
|
86
|
+
entity_id: string; // Entity UUID
|
|
87
|
+
vid: string; // Visitor VID
|
|
88
|
+
first_contact: number; // Unix timestamp
|
|
89
|
+
visit_count: number; // Total visits at time of signing
|
|
90
|
+
trust_at_signing: number; // Trust axis value at signing
|
|
91
|
+
signature: string; // Ed25519 signature
|
|
92
|
+
public_key: string; // Visitor's ephemeral public key
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Proofs are portable. A visitor can carry their proof to any VEIL CORE compliant runtime and the relationship is recognized.
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
## 3. VEIL STATE — Entity Schema
|
|
101
|
+
|
|
102
|
+
### 3.1 Entity Object
|
|
103
|
+
|
|
104
|
+
The canonical entity state object. JSON-serializable. Ed25519-signable. Infrastructure-agnostic.
|
|
105
|
+
|
|
106
|
+
```typescript
|
|
107
|
+
interface VEILEntity {
|
|
108
|
+
// Identity
|
|
109
|
+
id: string; // UUID v4 — immutable
|
|
110
|
+
name: string; // Human-readable name (e.g. "VEIL")
|
|
111
|
+
version: string; // Schema version
|
|
112
|
+
created_at: number; // Unix ms — immutable
|
|
113
|
+
|
|
114
|
+
// Clock
|
|
115
|
+
clock_age: number; // Minutes elapsed since creation — always increasing
|
|
116
|
+
last_ticked: number; // Unix ms of last clock evolution
|
|
117
|
+
tick_interval: number; // How often the entity evolves (default: 60000ms)
|
|
118
|
+
|
|
119
|
+
// Behavioral axes — all 0.0 to 1.0
|
|
120
|
+
axes: {
|
|
121
|
+
trust: number; // Earned through visits and dwell
|
|
122
|
+
density: number; // How much the entity reveals
|
|
123
|
+
warmth: number; // Emotional temperature
|
|
124
|
+
tension: number; // Internal pressure / urgency
|
|
125
|
+
memory_depth: number; // How far back the entity remembers
|
|
126
|
+
[key: string]: number; // Extensible — custom axes allowed
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
// Phase system
|
|
130
|
+
phase: number; // 0=DORMANT 1=AWARE 2=FAMILIAR 3=KNOWN 4=FUSED
|
|
131
|
+
phase_history: PhaseTransition[];
|
|
132
|
+
|
|
133
|
+
// Visitor relationships
|
|
134
|
+
visitor_count: number;
|
|
135
|
+
relationship_count: number;
|
|
136
|
+
|
|
137
|
+
// State signature
|
|
138
|
+
state_hash: string; // SHA256 of canonical state (excluding this field)
|
|
139
|
+
signed_at: number; // Unix ms
|
|
140
|
+
signature: string; // Ed25519 signature by entity keypair
|
|
141
|
+
}
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### 3.2 Relationship Record
|
|
145
|
+
|
|
146
|
+
```typescript
|
|
147
|
+
interface VEILRelationship {
|
|
148
|
+
id: string; // UUID v4
|
|
149
|
+
entity_id: string;
|
|
150
|
+
vid: string; // Visitor VID
|
|
151
|
+
|
|
152
|
+
// Visit history
|
|
153
|
+
first_contact: number; // Unix ms
|
|
154
|
+
last_contact: number; // Unix ms
|
|
155
|
+
visit_count: number;
|
|
156
|
+
total_dwell_seconds: number;
|
|
157
|
+
|
|
158
|
+
// Relational axes — per-visitor override of entity axes
|
|
159
|
+
axes: {
|
|
160
|
+
trust: number;
|
|
161
|
+
warmth: number;
|
|
162
|
+
density: number;
|
|
163
|
+
tension: number;
|
|
164
|
+
[key: string]: number;
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
// Phase
|
|
168
|
+
phase: number;
|
|
169
|
+
phase_transitions: PhaseTransition[];
|
|
170
|
+
|
|
171
|
+
// Event ledger — append only
|
|
172
|
+
events: RelationshipEvent[];
|
|
173
|
+
|
|
174
|
+
// Proof
|
|
175
|
+
proof: RelationshipProof;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
interface RelationshipEvent {
|
|
179
|
+
type: "visit" | "dwell" | "interaction" | "phase_transition" | "custom";
|
|
180
|
+
timestamp: number;
|
|
181
|
+
data: Record<string, unknown>;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
interface PhaseTransition {
|
|
185
|
+
from: number;
|
|
186
|
+
to: number;
|
|
187
|
+
timestamp: number;
|
|
188
|
+
trigger: string;
|
|
189
|
+
}
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
### 3.3 Morphology Derivation
|
|
193
|
+
|
|
194
|
+
Morphology is not stored — it is computed from axes at render time. This keeps the spec renderer-agnostic.
|
|
195
|
+
|
|
196
|
+
```typescript
|
|
197
|
+
interface VEILMorphology {
|
|
198
|
+
// Derived from axes — all 0.0 to 1.0
|
|
199
|
+
visual_density: number; // How complex the rendered field is
|
|
200
|
+
color_temperature: number; // Warm (1.0) to cool (0.0)
|
|
201
|
+
motion_speed: number; // How fast the entity moves
|
|
202
|
+
presence_radius: number; // How large the entity's field is
|
|
203
|
+
revelation: number; // How much of itself the entity shows
|
|
204
|
+
|
|
205
|
+
// Phase-gated properties
|
|
206
|
+
phase_label: string; // Human-readable phase name
|
|
207
|
+
can_initiate: boolean; // Can entity push to visitor? (phase >= 2)
|
|
208
|
+
can_fuse: boolean; // Is fusion available? (phase >= 4)
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
function deriveMorphology(entity: VEILEntity, relationship: VEILRelationship): VEILMorphology {
|
|
212
|
+
const axes = relationship.axes; // Relationship axes take precedence
|
|
213
|
+
return {
|
|
214
|
+
visual_density: axes.density,
|
|
215
|
+
color_temperature: axes.warmth,
|
|
216
|
+
motion_speed: axes.tension * 0.4 + axes.trust * 0.2 + 0.1,
|
|
217
|
+
presence_radius: axes.trust * 0.5 + axes.density * 0.3 + 0.1,
|
|
218
|
+
revelation: axes.trust * 0.6 + axes.memory_depth * 0.4,
|
|
219
|
+
phase_label: ["DORMANT","AWARE","FAMILIAR","KNOWN","FUSED"][relationship.phase],
|
|
220
|
+
can_initiate: relationship.phase >= 2,
|
|
221
|
+
can_fuse: relationship.phase >= 4,
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
### 3.4 Phase Progression Rules
|
|
227
|
+
|
|
228
|
+
Phase transitions are rule-based and cannot be forced programmatically:
|
|
229
|
+
|
|
230
|
+
| Phase | Name | Requirements |
|
|
231
|
+
|-------|------|-------------|
|
|
232
|
+
| 0 | DORMANT | Default — first contact |
|
|
233
|
+
| 1 | AWARE | visits >= 1 |
|
|
234
|
+
| 2 | FAMILIAR | visits >= 3 AND trust >= 0.25 |
|
|
235
|
+
| 3 | KNOWN | visits >= 5 AND trust >= 0.50 |
|
|
236
|
+
| 4 | FUSED | visits >= 8 AND trust >= 0.75 AND total_dwell >= 1800s |
|
|
237
|
+
|
|
238
|
+
Phase can never decrease. Trust decays at 0.01 per day of absence (max decay: 0.3).
|
|
239
|
+
|
|
240
|
+
---
|
|
241
|
+
|
|
242
|
+
## 4. VEIL SYNC — Runtime Protocol
|
|
243
|
+
|
|
244
|
+
### 4.1 Philosophy
|
|
245
|
+
|
|
246
|
+
VEIL SYNC is the protocol by which entities evolve, communicate with visitors, and maintain state across any infrastructure. It is transport-agnostic — implementable over HTTP, WebSocket, WebTransport, or custom protocols.
|
|
247
|
+
|
|
248
|
+
### 4.2 Entity Clock
|
|
249
|
+
|
|
250
|
+
The entity clock is the heartbeat of the AWE category. It ticks independently of visitor presence.
|
|
251
|
+
|
|
252
|
+
```typescript
|
|
253
|
+
interface ClockTick {
|
|
254
|
+
entity_id: string;
|
|
255
|
+
tick_number: number;
|
|
256
|
+
clock_age_before: number; // Minutes
|
|
257
|
+
clock_age_after: number;
|
|
258
|
+
timestamp: number;
|
|
259
|
+
|
|
260
|
+
// What changed this tick
|
|
261
|
+
axis_deltas: Partial<Record<string, number>>;
|
|
262
|
+
phase_transitions: PhaseTransition[];
|
|
263
|
+
events_generated: ClockEvent[];
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
// Default clock evolution rules — overridable per entity
|
|
267
|
+
const DEFAULT_TICK_RULES = {
|
|
268
|
+
// Per tick (default: every 60 seconds)
|
|
269
|
+
trust_decay_per_absent_day: -0.01 / 1440, // Per minute of absence
|
|
270
|
+
warmth_drift_rate: 0.0001, // Slow drift toward 0.5
|
|
271
|
+
tension_decay_rate: -0.0005, // Tension releases over time
|
|
272
|
+
density_growth_rate: 0.00005, // Slow accumulation
|
|
273
|
+
};
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
### 4.3 API Endpoints
|
|
277
|
+
|
|
278
|
+
All VEIL CORE compliant runtimes MUST implement these endpoints:
|
|
279
|
+
|
|
280
|
+
```
|
|
281
|
+
GET /v1/entity/:id — Fetch entity state
|
|
282
|
+
GET /v1/entity/:id/morphology — Fetch computed morphology
|
|
283
|
+
POST /v1/entity/:id/visit — Record a visit, return relationship state
|
|
284
|
+
POST /v1/entity/:id/dwell — Record dwell time
|
|
285
|
+
POST /v1/entity/:id/interact — Record an interaction event
|
|
286
|
+
GET /v1/relationship/:entity_id/:vid — Fetch relationship state
|
|
287
|
+
WS /v1/entity/:id/stream — Live entity state stream
|
|
288
|
+
POST /v1/entity — Create a new entity (authenticated)
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
### 4.4 Visit Request / Response
|
|
292
|
+
|
|
293
|
+
```typescript
|
|
294
|
+
// POST /v1/entity/:id/visit
|
|
295
|
+
interface VisitRequest {
|
|
296
|
+
vid: string; // VEIL ID
|
|
297
|
+
proof?: RelationshipProof; // Optional — for returning visitors
|
|
298
|
+
metadata: {
|
|
299
|
+
timestamp: number;
|
|
300
|
+
timezone_offset: number;
|
|
301
|
+
referrer_hash?: string; // Hashed — never raw URL
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
interface VisitResponse {
|
|
306
|
+
entity: VEILEntity;
|
|
307
|
+
relationship: VEILRelationship;
|
|
308
|
+
morphology: VEILMorphology;
|
|
309
|
+
is_returning: boolean;
|
|
310
|
+
gap_minutes: number; // Time since last visit
|
|
311
|
+
proof: RelationshipProof; // Updated proof — visitor should store this
|
|
312
|
+
}
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
### 4.5 WebSocket Stream Protocol
|
|
316
|
+
|
|
317
|
+
```typescript
|
|
318
|
+
// WS /v1/entity/:id/stream
|
|
319
|
+
// Server → Client messages:
|
|
320
|
+
|
|
321
|
+
interface StreamMessage {
|
|
322
|
+
type: "tick" | "axis_update" | "phase_transition" | "visitor_join" | "visitor_leave";
|
|
323
|
+
entity_id: string;
|
|
324
|
+
timestamp: number;
|
|
325
|
+
payload: ClockTick | AxisUpdate | PhaseTransition | VisitorEvent;
|
|
326
|
+
}
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
---
|
|
330
|
+
|
|
331
|
+
## 5. Compliance Levels
|
|
332
|
+
|
|
333
|
+
| Level | Name | Requirements |
|
|
334
|
+
|-------|------|-------------|
|
|
335
|
+
| 1 | VEIL LITE | VEIL STATE schema only. Local storage. No server. |
|
|
336
|
+
| 2 | VEIL STANDARD | VEIL STATE + VEIL SYNC. Server-side state. Clock evolution. |
|
|
337
|
+
| 3 | VEIL FULL | All three layers. VEIL ID + cryptographic proofs. |
|
|
338
|
+
| 4 | VEIL NETWORK | Full compliance + peer entity communication. |
|
|
339
|
+
|
|
340
|
+
---
|
|
341
|
+
|
|
342
|
+
## 6. Extensibility
|
|
343
|
+
|
|
344
|
+
The protocol is intentionally minimal and extensible:
|
|
345
|
+
|
|
346
|
+
- Custom behavioral axes beyond the core set are permitted
|
|
347
|
+
- Custom phase definitions are permitted (must be superset of required phases)
|
|
348
|
+
- Custom tick rules are permitted (must not violate decay floors)
|
|
349
|
+
- Custom morphology derivations are permitted
|
|
350
|
+
- Custom event types in relationship ledgers are permitted
|
|
351
|
+
|
|
352
|
+
All extensions must be namespaced: `custom.{namespace}.{key}`
|
|
353
|
+
|
|
354
|
+
---
|
|
355
|
+
|
|
356
|
+
## 7. What Swan Labs Owns
|
|
357
|
+
|
|
358
|
+
This specification, the category name "Ambient Web Entity," the abbreviation "AWE," the VEIL entity schema, the VEIL SYNC protocol, and the VEIL ID derivation method are originated by Swan Labs, 2025.
|
|
359
|
+
|
|
360
|
+
Implementations are open. The standard is Swan Labs'.
|
|
361
|
+
|
|
362
|
+
---
|
|
363
|
+
|
|
364
|
+
*VEIL CORE Specification v1.0.0 — Swan Labs — AWE-001*
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@swanlabs/veil-core",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "VEIL CORE — Ambient Web Entity Protocol. Swan Labs.",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "tsc",
|
|
9
|
+
"start": "node dist/server/server.js",
|
|
10
|
+
"dev": "ts-node server/server.ts",
|
|
11
|
+
"test": "jest"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [
|
|
14
|
+
"ambient-web-entity",
|
|
15
|
+
"awe",
|
|
16
|
+
"veil",
|
|
17
|
+
"swan-labs",
|
|
18
|
+
"persistent-entity",
|
|
19
|
+
"behavioral-web"
|
|
20
|
+
],
|
|
21
|
+
"author": "Swan Labs",
|
|
22
|
+
"license": "MIT",
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"cors": "^2.8.5",
|
|
25
|
+
"express": "^4.18.2",
|
|
26
|
+
"ws": "^8.14.2"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@types/cors": "^2.8.14",
|
|
30
|
+
"@types/express": "^4.17.21",
|
|
31
|
+
"@types/node": "^20.10.0",
|
|
32
|
+
"@types/ws": "^8.5.10",
|
|
33
|
+
"typescript": "^5.3.2",
|
|
34
|
+
"ts-node": "^10.9.2"
|
|
35
|
+
}
|
|
36
|
+
}
|