paracosm 0.9.763 → 0.9.767

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.
Files changed (2) hide show
  1. package/README.md +21 -125
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -24,9 +24,19 @@
24
24
  </p>
25
25
 
26
26
  <p align="center">
27
- <a href="https://paracosm.agentos.sh/demo/e2e-atlas-8-hero.mp4">▶ Watch the 90-second end-to-end demo</a>
27
+ <img src="assets/blog/readme/paracosm-hero.gif" alt="Paracosm end-to-end: paragraph in, two leaders running, fork-and-replay out" width="720" />
28
+ </p>
29
+
30
+ <p align="center">
31
+ <em>Type a what-if. Compile a typed world. Run two LLM commanders against it. Fork any past turn. Watch the trajectories diverge.</em>
32
+ </p>
33
+
34
+ <p align="center">
35
+ <a href="https://paracosm.agentos.sh/demo/e2e-atlas-8-hero.mp4">▶ Full 90-second demo</a>
36
+ &nbsp;·&nbsp;
37
+ <a href="https://paracosm.agentos.sh/demo/digital-twin-maria-2-hero.mp4">▶ Digital twin</a>
28
38
  &nbsp;·&nbsp;
29
- <a href="https://paracosm.agentos.sh/demo/digital-twin-maria-2-hero.mp4">▶ Digital twin walkthrough</a>
39
+ <a href="https://paracosm.agentos.sh/demo/branches.mp4">▶ Branches & forks</a>
30
40
  </p>
31
41
 
32
42
  ---
@@ -391,135 +401,27 @@ Numbers assume 6 turns, 5 departments, 100 agents, up to 3 events per turn. Forg
391
401
 
392
402
  ## How a turn runs
393
403
 
394
- ```
395
- 1. EVENT DIRECTOR Reads world state, prior decisions, tool intelligence.
396
- Generates an event that targets actual weaknesses.
397
-
398
- 2. KERNEL ADVANCE Deterministic time progression: births, deaths, aging,
399
- health decay, resource consumption. Seeded PRNG.
400
-
401
- 3. DEPARTMENT ANALYSIS All active departments analyze the event in parallel.
402
- Each head uses personality plus tools. Specialists can
403
- forge new computational tools at runtime in a hardened
404
- node:vm sandbox. An LLM judge approves each forge.
405
-
406
- 4. COMMANDER DECISION Reads all department reports. Selects an option.
407
- Personality shapes risk tolerance and priority weighting.
408
-
409
- 5. OUTCOME Kernel classifies the outcome (risky success, risky
410
- failure, safe success, safe failure) from option,
411
- probability, and colony state.
412
-
413
- 6. EFFECTS Kernel applies deltas (population, morale, food,
414
- power, etc.) per outcome and event category.
415
-
416
- 7. AGENT REACTIONS ~100 agents react in parallel using a cheap model.
417
- Each reaction is shaped by the agent's personality,
418
- health, relationships, and accumulated memories.
419
-
420
- 8. MEMORY Reactions become persistent memories. Short-term
421
- consolidates into long-term. Stances drift.
422
- Relationships shift on shared experience.
423
-
424
- 9. PERSONALITY DRIFT HEXACO traits shift through actor pull, role activation,
425
- and outcome reinforcement. The commander drifts alongside
426
- their agents using peer-reviewed outcome-pull tables.
427
- ```
428
-
429
- Every structured LLM call (director events, department reports, commander decisions, reactions, verdict, promotions) runs through Zod schema validation with automatic retry-with-feedback on failure. Schemas live under [`src/runtime/schemas/`](src/runtime/schemas/). Two wrappers (`generateValidatedObject` for one-shot, `sendAndValidate` for session-aware) preserve conversation memory while enforcing validation discipline.
430
-
431
- ---
432
-
433
- ## Seed enrichment and citations
434
-
435
- Real source material grounds the scenario all the way through to department reports.
436
-
437
- ```bash
438
- paracosm compile scenarios/lunar.json --seed-text "$(cat ./papers/iss-radiation.md)"
439
- paracosm compile scenarios/lunar.json --seed-url https://ntrs.nasa.gov/citations/20210018970
440
- ```
441
-
442
- The pipeline runs eight steps: extract topics and search queries from the seed, fan out to Firecrawl / Tavily / Serper / Brave in parallel, dedup and rerank with Cohere `rerank-v3.5`, assemble a `KnowledgeBundle`, ingest into an AgentOS `AgentMemory.sqlite()` store, recall per event during runtime, inject `[claim](url)` markdown into department prompts, and surface citations in the dashboard's Reports tab. The seed bundle is cached separately from the hook cache, keyed on the seed signature, so the same URL never re-extracts.
443
-
444
- ---
445
-
446
- ## Built-in scenarios
404
+ Director event → Kernel advance (deterministic, seeded) → Department analysis in parallel (with optional runtime tool forging in a hardened `node:vm` sandbox; an LLM judge approves each forge) → Commander decision (HEXACO-weighted) → Outcome classification → Kernel effects → Agent reactions → Memory consolidation → Personality drift.
447
405
 
448
- | Scenario | Description |
449
- |---------------|-------------------------------------------------------------------------------------------------------------------|
450
- | Mars Genesis | 100 colonists, 6 turns over 48 years. 5 departments, emergent dust storms, water crises, first Marsborn generation. |
451
- | Lunar Outpost | 50-person crew at the south pole. Mining, life support, comms. Regolith toxicity, 1/6g atrophy. |
452
-
453
- Both ship as `marsScenario` and `lunarScenario` named exports from the `paracosm` root and serve as references for building custom scenarios.
406
+ Every structured LLM call (director, departments, commander, reactions, verdict) is Zod-validated with retry-with-feedback. Schemas under [`src/runtime/schemas/`](src/runtime/schemas/). Full per-stage breakdown in [docs/architecture.md](docs/architecture.md).
454
407
 
455
408
  ---
456
409
 
457
- ## Programmatic API
458
-
459
- | Import | Surface |
460
- |-------------------------------------|-----------------------------------------------------------------------------------------------------------|
461
- | `paracosm` (root) | `run`, `runMany`, `WorldModel`, `compileScenario`, `marsScenario`, `lunarScenario`, `ACTOR_PRESETS`, `createParacosmClient`, all public types |
462
- | `paracosm/compiler` | `compileScenario`, `ingestSeed`, `ingestFromUrl`, `CompileOptions` (deep authoring path) |
463
- | `paracosm/schema` | Zod runtime validators: `RunArtifactSchema`, `StreamEventSchema`, etc. |
464
- | `paracosm/swarm` | Post-run swarm inspection helpers |
465
- | `paracosm/digital-twin` | `DigitalTwin` (alias of `WorldModel`) and digital-twin schemas |
466
- | `paracosm/core` | Kernel internals: `SimulationKernel`, `SeededRng`, `generateInitialPopulation`, kernel state types |
467
-
468
- `createParacosmClient` pins `provider`, `costPreset`, per-role `models`, and compile-time options once, then hands back methods that inherit those defaults. Per-call overrides still win, merged at the per-role level. Env vars feed the same defaults; explicit args win over env, env wins over library defaults.
469
-
470
- ```bash
471
- PARACOSM_PROVIDER=anthropic \
472
- PARACOSM_COST_PRESET=economy \
473
- PARACOSM_MODEL_DEPARTMENTS=claude-sonnet-4-6 \
474
- node my-runner.js
475
- ```
410
+ ## Seed enrichment
476
411
 
477
- `runSimulation` accepts an `AbortSignal` and short-circuits at the next turn boundary on cancel, returning the partial result with `output.aborted === true`. Custom events at fixed turns ride the same options bag (`customEvents: [{ turn: 3, title, description }]`). Provider-key failures throw `ProviderKeyMissingError` once at the top of the run instead of retrying silently per call.
412
+ `paracosm compile <scenario.json> --seed-text "..."` or `--seed-url <url>` extracts topics, searches across Firecrawl + Tavily + Serper + Brave in parallel, reranks with Cohere `rerank-v3.5`, ingests the result into an AgentOS `AgentMemory.sqlite()` store, and threads citations into department prompts. Bundle cached per-seed. Surface citations land in the dashboard's Reports tab.
478
413
 
479
414
  ---
480
415
 
481
- ## HTTP API: `POST /simulate`
482
-
483
- For non-SSE consumers (curl, Python integrations, third-party dashboards) a plain request-response endpoint runs a simulation in one call. Gated behind `PARACOSM_ENABLE_SIMULATE_ENDPOINT=true` so the hosted demo's SSE-first path stays the default.
416
+ ## Built-in scenarios + APIs
484
417
 
485
- ```bash
486
- export PARACOSM_ENABLE_SIMULATE_ENDPOINT=true
487
- paracosm dashboard
418
+ `marsScenario` (100 colonists, 6 turns over 48 years; 5 departments) and `lunarScenario` (50-person south-pole crew; regolith + 1/6g) ship from the `paracosm` root as references for custom scenarios.
488
419
 
489
- curl -s -X POST http://localhost:3456/simulate \
490
- -H 'Content-Type: application/json' \
491
- -H 'X-Anthropic-Key: sk-ant-...' \
492
- -d @run.json | jq '.artifact.fingerprint'
493
- ```
420
+ Programmatic surfaces: `paracosm` root (`run`, `runMany`, `WorldModel`, `compileScenario`, `createParacosmClient`), plus `paracosm/{compiler,schema,swarm,digital-twin,core}` for deeper paths. Provider / preset / model defaults can be pinned per client or via `PARACOSM_*` env vars. Full reference + every method signature: [`docs/COOKBOOK.md`](docs/COOKBOOK.md).
494
421
 
495
- The body accepts either a pre-compiled `ScenarioPackage` or a raw scenario draft (auto-compiled server-side with optional `options.seedText` / `options.seedUrl` grounding). The response is `{ artifact, scenario, durationMs }`. Rate limiting and the 5 MiB body cap match `/setup`.
422
+ For non-SSE consumers there's `POST /simulate` (gated on `PARACOSM_ENABLE_SIMULATE_ENDPOINT=true`) and nine read-and-replay routes under `/api/v1/*`. Wire-level details: [`docs/HTTP_API.md`](docs/HTTP_API.md).
496
423
 
497
- The dashboard server also exposes nine read-and-replay routes under `/api/v1/*` (list runs, fetch artifacts, re-execute, import). Wire-level reference: [`docs/HTTP_API.md`](docs/HTTP_API.md).
498
-
499
- ---
500
-
501
- ## Storage
502
-
503
- Run history (Library tab) and replayable session blobs (Load menu) persist through [`@framers/sql-storage-adapter`](https://github.com/framersai/sql-storage-adapter). The same code paths run unchanged against SQLite, Postgres, sql.js, and IndexedDB; switching backends is one env var.
504
-
505
- ```bash
506
- paracosm dashboard # SQLite, ./data/runs.db
507
- STORAGE_ADAPTER=postgres DATABASE_URL=... paracosm dashboard # Postgres in production
508
- STORAGE_ADAPTER=sqljs paracosm dashboard # pure-WASM fallback
509
- ```
510
-
511
- `runs` and `sessions` schemas bootstrap idempotently on first boot. Legacy v0.7 databases auto-migrate `leader_*` columns to `actor_*` in place via `ALTER TABLE RENAME COLUMN`.
512
-
513
- ### Admin endpoints
514
-
515
- Two destructive admin routes ship with the dashboard, gated by **two** env vars on the server:
516
-
517
- | Env var | Purpose |
518
- |-----------------------|------------------------------------------------------------------------------------------------------|
519
- | `ADMIN_WRITE=true` | Master switch. Off, every `/admin/*` route returns `403`. |
520
- | `ADMIN_TOKEN=<secret>`| Per-request bearer token in `X-Admin-Token`. With `ADMIN_WRITE=true` and no token, the server returns `503` (fail-closed).|
521
-
522
- `POST /admin/sessions/save` snapshots the current event buffer as a replayable session. `POST /admin/data/wipe` clears `runs.db`, `sessions.db`, on-disk artifact JSONs, and the SSE event buffer. The dashboard's Wipe All control prompts for the token on first use and stores it in `localStorage`.
424
+ Storage: SQLite by default, Postgres / sql.js / IndexedDB via `STORAGE_ADAPTER=` env. Run history (Library) and session blobs (Load menu) share the same schema. Admin write routes (`/admin/sessions/save`, `/admin/data/wipe`) require both `ADMIN_WRITE=true` and an `ADMIN_TOKEN` bearer; off by default.
523
425
 
524
426
  ---
525
427
 
@@ -553,12 +455,6 @@ The engine owns the chassis. The scenario owns the domain. The kernel handles st
553
455
 
554
456
  ---
555
457
 
556
- ## Background
557
-
558
- Paracosm sits in the structured world model lineage ([Xing 2025](https://arxiv.org/abs/2507.05169), [ACM CSUR 2025](https://dl.acm.org/doi/full/10.1145/3746449)). The LLM-world-model implementation closest to it is [Yang et al, 2026](https://openreview.net/forum?id=XmYCERErcD), which evaluates LLM-based world models through policy verification, action proposal, and policy planning. Full taxonomy mapping in [`docs/positioning/world-model-mapping.md`](docs/positioning/world-model-mapping.md).
559
-
560
- ---
561
-
562
458
  ## Built on AgentOS
563
459
 
564
460
  > "You are not the kind of dead that can be brought back."
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "paracosm",
3
- "version": "0.9.763",
3
+ "version": "0.9.767",
4
4
  "description": "Agent swarm simulation for structured world modeling with LLMs. Multi-agent worlds with HEXACO personalities, deterministic kernels, runtime tool forging, and reproducible forkable RunArtifacts. Built on AgentOS.",
5
5
  "type": "module",
6
6
  "main": "dist/engine/index.js",