paracosm 0.9.764 → 0.9.768

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 +6 -74
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -43,7 +43,7 @@
43
43
 
44
44
  Paracosm is an agent swarm simulation framework for structured world modeling with LLMs. It compiles a JSON scenario draft (or a prompt, or an extracted document) into a runnable multi-agent world, plays it through a deterministic kernel, and lets agents with HEXACO personality profiles decide turn by turn how the world unfolds. Snapshots persist on disk. Runs replay byte-for-byte. Any past turn can be forked with a different actor, a different seed, or a custom event, and the divergent branch streams alongside the trunk so the contrast is visible in the artifact, not promised in copy.
45
45
 
46
- The product is the contrast. Same compiled world, same crises, same kernel: swap one variable and the trajectory measurably moves.
46
+ The product is the contrast. Same compiled world, same kernel, same seed but the LLM Event Director reads each leader's HEXACO profile and accumulated state, so the events themselves diverge from turn 1. Swap one variable and the trajectory measurably moves; replay the same leader on the same seed and the run reproduces.
47
47
 
48
48
  ---
49
49
 
@@ -413,83 +413,15 @@ Every structured LLM call (director, departments, commander, reactions, verdict)
413
413
 
414
414
  ---
415
415
 
416
- ## Built-in scenarios
416
+ ## Built-in scenarios + APIs
417
417
 
418
- | Scenario | Description |
419
- |---------------|-------------------------------------------------------------------------------------------------------------------|
420
- | Mars Genesis | 100 colonists, 6 turns over 48 years. 5 departments, emergent dust storms, water crises, first Marsborn generation. |
421
- | Lunar Outpost | 50-person crew at the south pole. Mining, life support, comms. Regolith toxicity, 1/6g atrophy. |
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.
422
419
 
423
- Both ship as `marsScenario` and `lunarScenario` named exports from the `paracosm` root and serve as references for building custom scenarios.
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).
424
421
 
425
- ---
426
-
427
- ## Programmatic API
428
-
429
- | Import | Surface |
430
- |-------------------------------------|-----------------------------------------------------------------------------------------------------------|
431
- | `paracosm` (root) | `run`, `runMany`, `WorldModel`, `compileScenario`, `marsScenario`, `lunarScenario`, `ACTOR_PRESETS`, `createParacosmClient`, all public types |
432
- | `paracosm/compiler` | `compileScenario`, `ingestSeed`, `ingestFromUrl`, `CompileOptions` (deep authoring path) |
433
- | `paracosm/schema` | Zod runtime validators: `RunArtifactSchema`, `StreamEventSchema`, etc. |
434
- | `paracosm/swarm` | Post-run swarm inspection helpers |
435
- | `paracosm/digital-twin` | `DigitalTwin` (alias of `WorldModel`) and digital-twin schemas |
436
- | `paracosm/core` | Kernel internals: `SimulationKernel`, `SeededRng`, `generateInitialPopulation`, kernel state types |
437
-
438
- `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.
439
-
440
- ```bash
441
- PARACOSM_PROVIDER=anthropic \
442
- PARACOSM_COST_PRESET=economy \
443
- PARACOSM_MODEL_DEPARTMENTS=claude-sonnet-4-6 \
444
- node my-runner.js
445
- ```
446
-
447
- `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.
448
-
449
- ---
450
-
451
- ## HTTP API: `POST /simulate`
452
-
453
- 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.
454
-
455
- ```bash
456
- export PARACOSM_ENABLE_SIMULATE_ENDPOINT=true
457
- paracosm dashboard
458
-
459
- curl -s -X POST http://localhost:3456/simulate \
460
- -H 'Content-Type: application/json' \
461
- -H 'X-Anthropic-Key: sk-ant-...' \
462
- -d @run.json | jq '.artifact.fingerprint'
463
- ```
464
-
465
- 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`.
466
-
467
- 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).
468
-
469
- ---
470
-
471
- ## Storage
472
-
473
- 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.
474
-
475
- ```bash
476
- paracosm dashboard # SQLite, ./data/runs.db
477
- STORAGE_ADAPTER=postgres DATABASE_URL=... paracosm dashboard # Postgres in production
478
- STORAGE_ADAPTER=sqljs paracosm dashboard # pure-WASM fallback
479
- ```
480
-
481
- `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`.
482
-
483
- ### Admin endpoints
484
-
485
- Two destructive admin routes ship with the dashboard, gated by **two** env vars on the server:
486
-
487
- | Env var | Purpose |
488
- |-----------------------|------------------------------------------------------------------------------------------------------|
489
- | `ADMIN_WRITE=true` | Master switch. Off, every `/admin/*` route returns `403`. |
490
- | `ADMIN_TOKEN=<secret>`| Per-request bearer token in `X-Admin-Token`. With `ADMIN_WRITE=true` and no token, the server returns `503` (fail-closed).|
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).
491
423
 
492
- `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.
493
425
 
494
426
  ---
495
427
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "paracosm",
3
- "version": "0.9.764",
3
+ "version": "0.9.768",
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",