Skip to content

Commit 883cd09

Browse files
committed
docs(paracosm): cover 0.6.0 universal schema + list as ecosystem app
PARACOSM.md - Rewrite quick-start result reads to use finalState?.metrics and forgedTools?.length (old finalState.systems + totalToolsForged removed). - Add universal result contract section covering RunArtifact, three modes, 11 primitives, scenarioExtensions escape hatch, JSON Schema export. - Add subjects and interventions section documenting SubjectConfig and InterventionConfig input primitives. - Rewrite API surface imports to include paracosm/schema and paracosm/compiler. - Fix broken TypeDoc links (/paracosm/interfaces -> /paracosm/engine/interfaces, /paracosm/classes -> /paracosm/engine/classes). - Add the 17-variant StreamEvent list under HTTP+SSE section. ECOSYSTEM.md - Add Paracosm as the lead applications entry with npm badge, feature bullets, and live demo link.
1 parent 8a3fe46 commit 883cd09

2 files changed

Lines changed: 112 additions & 11 deletions

File tree

docs/PARACOSM.md

Lines changed: 91 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,70 @@ const result = await runSimulation(aria, [], {
3535
onEvent: e => console.log(e.type, e.data?.title),
3636
});
3737

38-
console.log(result.finalState.systems.population);
39-
console.log(result.totalToolsForged);
38+
console.log(result.finalState?.metrics.population);
39+
console.log(result.forgedTools?.length ?? 0);
4040
```
4141

4242
Or run the hosted demo at [paracosm.agentos.sh/sim](https://paracosm.agentos.sh/sim) with zero setup. The demo caps turns, population, and model tier so public access stays affordable; paste your own OpenAI or Anthropic key into Settings to unlock full scope.
4343

44+
## The universal result contract
45+
46+
Every `runSimulation()` call returns a Zod-validated `RunArtifact` exported from the `paracosm/schema` subpath. One shape covers three simulation modes, discriminated on `metadata.mode`:
47+
48+
- `turn-loop`: civilization sims (paracosm's built-in mode). Populates `trajectory.timepoints[]` and `decisions[]` with per-turn specialist notes.
49+
- `batch-trajectory`: digital-twin simulations (digital-twin). Labeled timepoints over a horizon, populated by external LangGraph-style executors.
50+
- `batch-point`: one-shot forecasts. Overview and risk flags only, no trajectory.
51+
52+
```typescript
53+
import { RunArtifactSchema, type RunArtifact } from 'paracosm/schema';
54+
import { runSimulation } from 'paracosm/runtime';
55+
56+
const artifact: RunArtifact = await runSimulation(leader, [], opts);
57+
const parsed = RunArtifactSchema.parse(artifact); // optional runtime validation
58+
59+
switch (artifact.metadata.mode) {
60+
case 'turn-loop':
61+
case 'batch-trajectory':
62+
case 'batch-point':
63+
}
64+
65+
artifact.trajectory?.timepoints?.forEach((tp) => {
66+
console.log(tp.label, tp.score?.value, tp.narrative);
67+
});
68+
```
69+
70+
The schema exposes 11 content primitives (`RunMetadata`, `WorldSnapshot`, `Score`, `HighlightMetric`, `Timepoint`, `TrajectoryPoint`, `Trajectory`, `Citation`, `SpecialistDetail`, `SpecialistNote`, `RiskFlag`, `Decision`) plus operational types (`Cost`, `ProviderError`). Every primitive carries an optional `scenarioExtensions?: Record<string, unknown>` escape hatch for domain-specific fields that must not pollute the universal shape.
71+
72+
Non-TypeScript consumers generate equivalent types from JSON Schema: `npm run export:json-schema` emits `schema/run-artifact.schema.json` and `schema/stream-event.schema.json`. Python projects use `datamodel-codegen`; any ecosystem with a JSON-Schema code generator adopts cleanly. Full adoption walkthrough at [paracosm/docs/adoption/digital-twin.md](https://github.com/framersai/paracosm/blob/master/docs/adoption/digital-twin.md).
73+
74+
### Subjects and interventions
75+
76+
For simulations built around a single subject (a person, character, organism, vessel) under a counterfactual intervention, `paracosm/schema` exposes `SubjectConfig` and `InterventionConfig` as first-class input primitives. Pass them through `RunOptions` and they carry through to `RunArtifact.subject` and `RunArtifact.intervention` for downstream consumers:
77+
78+
```typescript
79+
import { SubjectConfigSchema, InterventionConfigSchema } from 'paracosm/schema';
80+
81+
const subject = SubjectConfigSchema.parse({
82+
id: 'user-42',
83+
name: 'Alice',
84+
profile: { age: 34, diet: 'mediterranean' },
85+
signals: [{ label: 'HRV', value: 48.2, unit: 'ms', recordedAt: '2026-04-21T08:00:00Z' }],
86+
markers: [{ id: 'rs4680', category: 'genome', value: 'AA' }],
87+
});
88+
89+
const intervention = InterventionConfigSchema.parse({
90+
id: 'intv-1',
91+
name: 'Creatine + Sleep Hygiene',
92+
description: '5g daily + 11pm bedtime.',
93+
duration: { value: 12, unit: 'weeks' },
94+
adherenceProfile: { expected: 0.7 },
95+
});
96+
97+
const artifact = await runSimulation(leader, [], { scenario, subject, intervention });
98+
```
99+
100+
Turn-loop mode stashes both verbatim without semantic consumption; external batch-trajectory executors populate them from their own flow.
101+
44102
## What it does
45103

46104
Paracosm runs two leaders through the same scenario in parallel and makes their divergence measurable. Each turn has nine stages:
@@ -115,21 +173,33 @@ Users who want more runs paste their own OpenAI or Anthropic key. The dashboard'
115173
## API surface
116174

117175
```typescript
118-
import type { ScenarioPackage, Agent } from 'paracosm';
176+
import type { ScenarioPackage, Agent, LeaderConfig, HexacoProfile } from 'paracosm';
177+
import { SimulationKernel, SeededRng } from 'paracosm';
119178
import { marsScenario } from 'paracosm/mars';
120179
import { lunarScenario } from 'paracosm/lunar';
121180
import { runSimulation, runBatch } from 'paracosm/runtime';
122-
import { SimulationKernel, SeededRng } from 'paracosm';
181+
import { compileScenario } from 'paracosm/compiler';
182+
import {
183+
RunArtifactSchema,
184+
StreamEventSchema,
185+
SubjectConfigSchema,
186+
InterventionConfigSchema,
187+
type RunArtifact,
188+
type StreamEvent,
189+
type SubjectConfig,
190+
type InterventionConfig,
191+
} from 'paracosm/schema';
123192
```
124193

125194
Full type reference is auto-generated from source at [/paracosm](/paracosm). The core types:
126195

127-
- [`ScenarioPackage`](/paracosm/interfaces/ScenarioPackage) — domain-agnostic scenario bundle
128-
- [`LeaderConfig`](/paracosm/interfaces/LeaderConfig) — commander identity + HEXACO profile
129-
- [`HexacoProfile`](/paracosm/interfaces/HexacoProfile) — six-axis personality vector
130-
- [`SimulationKernel`](/paracosm/classes/SimulationKernel) — deterministic state machine
131-
- [`runSimulation`](/paracosm/runtime/functions/runSimulation) — single-leader turn loop
132-
- [`runBatch`](/paracosm/runtime/functions/runBatch) — parallel multi-scenario runner
196+
- [`ScenarioPackage`](/paracosm/engine/interfaces/ScenarioPackage): domain-agnostic scenario bundle
197+
- [`LeaderConfig`](/paracosm/engine/interfaces/LeaderConfig): commander identity plus HEXACO profile
198+
- [`HexacoProfile`](/paracosm/engine/interfaces/HexacoProfile): six-axis personality vector
199+
- [`SimulationKernel`](/paracosm/engine/classes/SimulationKernel): deterministic state machine
200+
- [`runSimulation`](/paracosm/runtime/functions/runSimulation): single-leader turn loop, returns `Promise<RunArtifact>`
201+
- [`runBatch`](/paracosm/runtime/functions/runBatch): parallel multi-scenario runner
202+
- [`compileScenario`](/paracosm/engine/compiler/functions/compileScenario): turns scenario JSON into a runnable `ScenarioPackage`
133203

134204
## HTTP + SSE server
135205

@@ -148,6 +218,17 @@ The dashboard server exposes a small HTTP API for driving sims from any client:
148218

149219
`/events` replays a buffered event history on reconnect (persisted to disk so restarts do not evaporate completed runs), closes with a `replay_done` marker so clients can distinguish historical from live events.
150220

221+
The SSE stream emits a 17-variant `StreamEvent` discriminated union (defined in `paracosm/schema`), every event carrying a universal `e.data.summary` one-liner so consumers can render cleanly without narrowing on per-event fields:
222+
223+
```
224+
turn_start, event_start, specialist_start, specialist_done, forge_attempt,
225+
decision_pending, decision_made, outcome, personality_drift, agent_reactions,
226+
bulletin, turn_done, promotion, systems_snapshot, provider_error,
227+
validation_fallback, sim_aborted
228+
```
229+
230+
Narrow via `e.type` for per-event intellisense on `e.data`. Validate the envelope at runtime with `StreamEventSchema.parse(evt)` when ingesting untrusted streams.
231+
151232
## Related
152233

153234
- [Emergent Capabilities](/features/emergent-capabilities) — the forge + judge machinery underlying `forge_tool`

docs/architecture/ECOSYSTEM.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,26 @@ This is the content package for skills. The runtime engine (SkillLoader, SkillRe
122122

123123
## Applications
124124

125+
### [Paracosm](https://github.com/framersai/paracosm)
126+
**AI Agent Swarm Simulation Engine** — Define worlds as JSON, assign AI leaders with HEXACO personality profiles, and watch their decisions compound into measurably different outcomes from identical starting conditions. Built on `@framers/agentos`.
127+
128+
```bash
129+
npm install paracosm
130+
```
131+
132+
[![npm](https://img.shields.io/npm/v/paracosm?logo=npm&color=cb3837)](https://www.npmjs.com/package/paracosm)
133+
[![GitHub](https://img.shields.io/github/stars/framersai/paracosm?style=social)](https://github.com/framersai/paracosm)
134+
135+
**Features:**
136+
- Universal `RunArtifact` schema at `paracosm/schema` covering turn-loop civilization sims, batch-trajectory digital twins, and batch-point forecasts
137+
- HEXACO personality-driven commander decisions with runtime tool forging through AgentOS's `EmergentCapabilityEngine`
138+
- Deterministic kernel: same seed plus same crises equals replayable, diff-able runs
139+
- `SubjectConfig` and `InterventionConfig` input primitives for digital-twin adoption
140+
141+
🌐 **Live demo:** [paracosm.agentos.sh](https://paracosm.agentos.sh) · **Docs:** [paracosm.agentos.sh/docs](https://paracosm.agentos.sh/docs)
142+
143+
---
144+
125145
### [agentos.sh](https://github.com/framersai/agentos.sh)
126146
**Documentation Website** — Official documentation and marketing site.
127147

@@ -157,7 +177,7 @@ npm install wunderland
157177
| Resource | Link |
158178
|----------|------|
159179
| Documentation | [agentos.sh/docs](https://agentos.sh/docs) |
160-
| API Reference | [agentos-live-docs branch](https://github.com/framersai/agentos/tree/agentos-live-docs) |
180+
| API Reference | [docs.agentos.sh/api](https://docs.agentos.sh/api/) |
161181
| npm | [@framers/agentos](https://www.npmjs.com/package/@framers/agentos) |
162182
| Discord | [Join Community](https://discord.gg/usEkfCeQxs) |
163183
| Twitter | [@framersai](https://twitter.com/framersai) |

0 commit comments

Comments
 (0)