paracosm 0.7.407 → 0.7.409

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 (78) hide show
  1. package/README.md +77 -38
  2. package/dist/cli/pair-runner.d.ts +17 -0
  3. package/dist/cli/pair-runner.d.ts.map +1 -1
  4. package/dist/cli/pair-runner.js +81 -0
  5. package/dist/cli/pair-runner.js.map +1 -1
  6. package/dist/cli/server-app.d.ts.map +1 -1
  7. package/dist/cli/server-app.js +47 -6
  8. package/dist/cli/server-app.js.map +1 -1
  9. package/dist/cli/sim-config.d.ts +23 -0
  10. package/dist/cli/sim-config.d.ts.map +1 -1
  11. package/dist/cli/sim-config.js +10 -1
  12. package/dist/cli/sim-config.js.map +1 -1
  13. package/dist/engine/compiler/scenario-fixture.d.ts +6 -4
  14. package/dist/engine/compiler/scenario-fixture.d.ts.map +1 -1
  15. package/dist/engine/compiler/scenario-fixture.js +21 -0
  16. package/dist/engine/compiler/scenario-fixture.js.map +1 -1
  17. package/dist/engine/compiler/state-shape-block.d.ts +7 -11
  18. package/dist/engine/compiler/state-shape-block.d.ts.map +1 -1
  19. package/dist/engine/compiler/state-shape-block.js +14 -15
  20. package/dist/engine/compiler/state-shape-block.js.map +1 -1
  21. package/dist/engine/compiler/validate.d.ts.map +1 -1
  22. package/dist/engine/compiler/validate.js +2 -0
  23. package/dist/engine/compiler/validate.js.map +1 -1
  24. package/dist/engine/core/kernel.d.ts +38 -0
  25. package/dist/engine/core/kernel.d.ts.map +1 -1
  26. package/dist/engine/core/kernel.js +142 -11
  27. package/dist/engine/core/kernel.js.map +1 -1
  28. package/dist/engine/core/rng.d.ts +10 -2
  29. package/dist/engine/core/rng.d.ts.map +1 -1
  30. package/dist/engine/core/rng.js +20 -6
  31. package/dist/engine/core/rng.js.map +1 -1
  32. package/dist/engine/core/snapshot.d.ts +53 -0
  33. package/dist/engine/core/snapshot.d.ts.map +1 -0
  34. package/dist/engine/core/snapshot.js +6 -0
  35. package/dist/engine/core/snapshot.js.map +1 -0
  36. package/dist/engine/core/state.d.ts +14 -0
  37. package/dist/engine/core/state.d.ts.map +1 -1
  38. package/dist/engine/schema/artifact.d.ts +4 -0
  39. package/dist/engine/schema/artifact.d.ts.map +1 -1
  40. package/dist/engine/schema/primitives.d.ts +4 -0
  41. package/dist/engine/schema/primitives.d.ts.map +1 -1
  42. package/dist/engine/schema/primitives.js +13 -0
  43. package/dist/engine/schema/primitives.js.map +1 -1
  44. package/dist/engine/schema/stream.d.ts +2 -0
  45. package/dist/engine/schema/stream.d.ts.map +1 -1
  46. package/dist/engine/schema/stream.js +14 -0
  47. package/dist/engine/schema/stream.js.map +1 -1
  48. package/dist/runtime/agent-memory.d.ts +1 -1
  49. package/dist/runtime/agent-memory.d.ts.map +1 -1
  50. package/dist/runtime/agent-memory.js +4 -2
  51. package/dist/runtime/agent-memory.js.map +1 -1
  52. package/dist/runtime/agent-reactions.d.ts +6 -1
  53. package/dist/runtime/agent-reactions.d.ts.map +1 -1
  54. package/dist/runtime/agent-reactions.js +3 -1
  55. package/dist/runtime/agent-reactions.js.map +1 -1
  56. package/dist/runtime/build-artifact.d.ts +27 -2
  57. package/dist/runtime/build-artifact.d.ts.map +1 -1
  58. package/dist/runtime/build-artifact.js +26 -3
  59. package/dist/runtime/build-artifact.js.map +1 -1
  60. package/dist/runtime/chat-agents.d.ts +9 -1
  61. package/dist/runtime/chat-agents.d.ts.map +1 -1
  62. package/dist/runtime/chat-agents.js +13 -3
  63. package/dist/runtime/chat-agents.js.map +1 -1
  64. package/dist/runtime/contracts.d.ts +25 -7
  65. package/dist/runtime/contracts.d.ts.map +1 -1
  66. package/dist/runtime/orchestrator.d.ts +27 -0
  67. package/dist/runtime/orchestrator.d.ts.map +1 -1
  68. package/dist/runtime/orchestrator.js +90 -28
  69. package/dist/runtime/orchestrator.js.map +1 -1
  70. package/dist/runtime/reaction-step.d.ts +8 -0
  71. package/dist/runtime/reaction-step.d.ts.map +1 -1
  72. package/dist/runtime/reaction-step.js +1 -0
  73. package/dist/runtime/reaction-step.js.map +1 -1
  74. package/dist/runtime/world-model/index.d.ts +261 -0
  75. package/dist/runtime/world-model/index.d.ts.map +1 -0
  76. package/dist/runtime/world-model/index.js +285 -0
  77. package/dist/runtime/world-model/index.js.map +1 -0
  78. package/package.json +15 -2
@@ -0,0 +1,285 @@
1
+ /**
2
+ * Paracosm WorldModel façade: a one-object surface over the
3
+ * `compileScenario + runSimulation + runBatch` trio, plus the
4
+ * snapshot + fork API that operationalizes paracosm's CWSM
5
+ * (counterfactual world simulation model) positioning.
6
+ *
7
+ * Why it exists: paracosm positions itself as a structured world model
8
+ * for AI agents (see `docs/positioning/world-model-mapping.md`). The
9
+ * existing APIs (`compileScenario`, `runSimulation`, `runBatch`) are all
10
+ * first-class and unchanged. `WorldModel` is an additive thin wrapper
11
+ * that lets consumers write code in the same vocabulary the docs use:
12
+ *
13
+ * ```ts
14
+ * import { WorldModel } from 'paracosm/world-model';
15
+ *
16
+ * const wm = await WorldModel.fromJson(worldJson, { provider: 'anthropic' });
17
+ * const result = await wm.simulate(leader, { maxTurns: 6, seed: 42 });
18
+ * ```
19
+ *
20
+ * Every method dispatches to the underlying API with the `scenario`
21
+ * slot pinned to this world. Per-call options are passed through
22
+ * verbatim. Nothing here changes orchestrator semantics, kernel
23
+ * behavior, or the returned `RunArtifact` shape.
24
+ *
25
+ * The façade lives in `runtime/` rather than `engine/` because it
26
+ * depends on `runSimulation` + `runBatch`; the engine layer does not
27
+ * import from runtime (one-way dependency).
28
+ *
29
+ * @module paracosm/world-model
30
+ */
31
+ import { runSimulation } from '../orchestrator.js';
32
+ import { runBatch } from '../batch.js';
33
+ import { compileScenario } from '../../engine/compiler/index.js';
34
+ /**
35
+ * A compiled, runnable world. Wraps a {@link ScenarioPackage} with
36
+ * convenience methods for simulating single leaders or running a batch.
37
+ *
38
+ * Construct via {@link WorldModel.fromJson} (compile from raw JSON) or
39
+ * {@link WorldModel.fromScenario} (wrap an already-compiled scenario,
40
+ * e.g. `marsScenario`).
41
+ *
42
+ * The underlying scenario is exposed via {@link WorldModel.scenario} as
43
+ * an escape hatch for callers that want the raw
44
+ * {@link ScenarioPackage}: direct `runSimulation(leader, [], { scenario: wm.scenario, ... })`
45
+ * still works and is unchanged.
46
+ *
47
+ * @example Single-leader simulation
48
+ * ```ts
49
+ * import { WorldModel } from 'paracosm/world-model';
50
+ * import worldJson from './my-world.json' with { type: 'json' };
51
+ *
52
+ * const wm = await WorldModel.fromJson(worldJson, { provider: 'anthropic' });
53
+ * const artifact = await wm.simulate(leader, { maxTurns: 6, seed: 42 });
54
+ * ```
55
+ *
56
+ * @example Counterfactual branch via fork
57
+ * ```ts
58
+ * const wm = await WorldModel.fromJson(worldJson);
59
+ * const trunk = await wm.simulate(visionary, {
60
+ * maxTurns: 6, seed: 42, captureSnapshots: true,
61
+ * });
62
+ * const branch = await (await wm.forkFromArtifact(trunk, 3)).simulate(
63
+ * pragmatist, { maxTurns: 3, seed: 42 },
64
+ * );
65
+ * // branch.metadata.forkedFrom === { parentRunId: trunk.metadata.runId, atTurn: 3 }
66
+ * ```
67
+ *
68
+ * @example Pre-compiled scenario
69
+ * ```ts
70
+ * import { marsScenario } from 'paracosm/mars';
71
+ * import { WorldModel } from 'paracosm/world-model';
72
+ *
73
+ * const wm = WorldModel.fromScenario(marsScenario);
74
+ * const artifact = await wm.simulate(leader, { maxTurns: 8 });
75
+ * ```
76
+ */
77
+ export class WorldModel {
78
+ /**
79
+ * The underlying compiled scenario. Exposed so callers can drop down
80
+ * to direct `runSimulation` / `runBatch` calls when they need options
81
+ * the façade does not surface.
82
+ */
83
+ scenario;
84
+ /**
85
+ * Snapshot of the kernel at the end of the most recent successful
86
+ * `simulate()` call. Populated when that simulate() was invoked with
87
+ * `captureSnapshots: true`. Used by {@link WorldModel.snapshot} to
88
+ * emit a {@link WorldModelSnapshot} without requiring callers to
89
+ * plumb the kernel themselves. Undefined otherwise.
90
+ */
91
+ _lastKernelSnapshot;
92
+ /**
93
+ * Run id of the most recent successful `simulate()` call. Used by
94
+ * {@link WorldModel.snapshot} to populate
95
+ * {@link WorldModelSnapshot.parentRunId} so child runs record
96
+ * `forkedFrom.parentRunId`.
97
+ */
98
+ _lastRunId;
99
+ /**
100
+ * When this WorldModel was produced by {@link WorldModel.fork} or
101
+ * {@link WorldModel.forkFromArtifact}, this holds the `forkedFrom`
102
+ * link that the next {@link WorldModel.simulate} call threads into
103
+ * the child RunArtifact's `metadata.forkedFrom`. Cleared after
104
+ * simulate() consumes it.
105
+ */
106
+ _pendingForkedFrom;
107
+ /**
108
+ * When this WorldModel was produced by {@link WorldModel.fork}, this
109
+ * holds the kernel snapshot that {@link WorldModel.simulate} must
110
+ * restore before running. Cleared after simulate() consumes it.
111
+ */
112
+ _pendingResumeFrom;
113
+ constructor(scenario) {
114
+ this.scenario = scenario;
115
+ }
116
+ /**
117
+ * Compile a raw scenario JSON into a runnable {@link WorldModel}.
118
+ *
119
+ * Delegates to {@link compileScenario} under the hood; all
120
+ * {@link CompileOptions} (cache, provider, model, seed ingestion) are
121
+ * supported.
122
+ */
123
+ static async fromJson(worldJson, options = {}) {
124
+ const scenario = await compileScenario(worldJson, options);
125
+ return new WorldModel(scenario);
126
+ }
127
+ /**
128
+ * Wrap an already-compiled {@link ScenarioPackage} (e.g. `marsScenario`,
129
+ * `lunarScenario`, or any cached result of a prior `compileScenario`
130
+ * call).
131
+ *
132
+ * Pure construction, no I/O.
133
+ */
134
+ static fromScenario(scenario) {
135
+ return new WorldModel(scenario);
136
+ }
137
+ /**
138
+ * Run a single simulation through this world with the given leader.
139
+ * Delegates to {@link runSimulation} with `scenario` pinned to this
140
+ * instance.
141
+ *
142
+ * `keyPersonnel` is optional for parity with the underlying API; most
143
+ * callers pass `[]` or omit it. The returned {@link RunArtifact} is
144
+ * the universal Zod-validated contract exported from `paracosm/schema`.
145
+ *
146
+ * When this WorldModel was produced by {@link WorldModel.fork} or
147
+ * {@link WorldModel.forkFromArtifact}, the pending
148
+ * `_resumeFrom` + `_forkedFrom` context is threaded into the
149
+ * underlying runSimulation via the internal `_resumeFrom` /
150
+ * `_forkedFrom` fields on {@link RunOptions}. Both are cleared after
151
+ * simulate() consumes them so a second simulate() on the same
152
+ * WorldModel does not double-apply.
153
+ */
154
+ async simulate(leader, options = {}, keyPersonnel = []) {
155
+ const mergedOpts = {
156
+ ...options,
157
+ scenario: this.scenario,
158
+ _forkedFrom: this._pendingForkedFrom,
159
+ _resumeFrom: this._pendingResumeFrom,
160
+ };
161
+ // Drop the pending context so subsequent simulate calls on the
162
+ // same WorldModel don't double-apply.
163
+ this._pendingForkedFrom = undefined;
164
+ this._pendingResumeFrom = undefined;
165
+ const artifact = await runSimulation(leader, keyPersonnel, mergedOpts);
166
+ this._lastRunId = artifact.metadata.runId;
167
+ // Pull the terminal kernel snapshot from the artifact's embedded
168
+ // per-turn snapshots (populated when captureSnapshots: true was
169
+ // on). When captureSnapshots was off, snapshot() is degraded /
170
+ // unavailable; snapshot() throws with a pointer to the flag.
171
+ const perTurn = artifact.scenarioExtensions?.kernelSnapshotsPerTurn;
172
+ if (perTurn && perTurn.length > 0) {
173
+ this._lastKernelSnapshot = perTurn[perTurn.length - 1];
174
+ }
175
+ else {
176
+ this._lastKernelSnapshot = undefined;
177
+ }
178
+ return artifact;
179
+ }
180
+ /**
181
+ * Run N leaders through this world in parallel via {@link runBatch}.
182
+ * `scenarios` is fixed to `[this.scenario]`; supply `leaders`, `turns`,
183
+ * `seed`, and any other {@link BatchConfig} fields.
184
+ *
185
+ * For N-scenarios-×-M-leaders sweeps that span multiple worlds, call
186
+ * {@link runBatch} directly with an explicit `scenarios` array.
187
+ */
188
+ async batch(options) {
189
+ return runBatch({
190
+ ...options,
191
+ scenarios: [this.scenario],
192
+ });
193
+ }
194
+ /**
195
+ * Capture a {@link WorldModelSnapshot} of the state at the end of
196
+ * this WorldModel's most recent `simulate()` call. Requires
197
+ * `simulate(..., { captureSnapshots: true })` on that prior call;
198
+ * throws with a clear pointer otherwise.
199
+ *
200
+ * The returned snapshot is plain JSON-safe; serialize to disk with
201
+ * `JSON.stringify` and reload with `JSON.parse` + `fork()`.
202
+ *
203
+ * @throws Error when this WorldModel has never run simulate(), or
204
+ * when the last simulate() did not set `captureSnapshots: true`.
205
+ */
206
+ snapshot() {
207
+ if (!this._lastKernelSnapshot) {
208
+ throw new Error('WorldModel.snapshot() requires a prior `simulate(..., { captureSnapshots: true })` ' +
209
+ 'call on this WorldModel. Either enable snapshot capture on your simulation run or ' +
210
+ 'use `forkFromArtifact(artifact, atTurn)` to fork from a stored RunArtifact.');
211
+ }
212
+ return {
213
+ snapshotVersion: 1,
214
+ kernel: this._lastKernelSnapshot,
215
+ parentRunId: this._lastRunId,
216
+ };
217
+ }
218
+ /**
219
+ * Construct a new WorldModel positioned at the snapshot's turn. The
220
+ * new WorldModel has no prior run of its own; calling `.simulate()`
221
+ * on it resumes from the snapshot's kernel state, optionally with a
222
+ * different leader, seed, or custom events.
223
+ *
224
+ * `metadata.forkedFrom` on the subsequent `.simulate()` call's
225
+ * returned RunArtifact is set to
226
+ * `{ parentRunId: snapshot.parentRunId, atTurn: snapshot.kernel.turn }`.
227
+ *
228
+ * The `opts` argument is accepted for API symmetry but not consumed
229
+ * at fork time; the caller passes `opts.leader` / `opts.seed` /
230
+ * `opts.customEvents` through to the subsequent `.simulate()` call
231
+ * directly. A future spec may fold this into a single-call API.
232
+ *
233
+ * @throws Error when `snapshot.kernel.scenarioId !== this.scenario.id`.
234
+ */
235
+ async fork(snapshot, opts = {}) {
236
+ if (snapshot.kernel.scenarioId !== this.scenario.id) {
237
+ throw new Error(`WorldModel.fork: scenario id mismatch. Snapshot was taken against ` +
238
+ `'${snapshot.kernel.scenarioId}' but this WorldModel wraps ` +
239
+ `'${this.scenario.id}'. Cross-scenario forks are not supported.`);
240
+ }
241
+ const child = new WorldModel(this.scenario);
242
+ child._pendingResumeFrom = snapshot.kernel;
243
+ if (snapshot.parentRunId) {
244
+ child._pendingForkedFrom = {
245
+ parentRunId: snapshot.parentRunId,
246
+ atTurn: snapshot.kernel.turn,
247
+ };
248
+ }
249
+ // `opts` (leader / seed / customEvents) are documented at the
250
+ // interface boundary and intended for the subsequent simulate()
251
+ // call; fork() itself only needs the snapshot. Silence
252
+ // unused-parameter warnings explicitly.
253
+ void opts;
254
+ return child;
255
+ }
256
+ /**
257
+ * Convenience: pulls the kernel snapshot at `atTurn` from
258
+ * `artifact.scenarioExtensions.kernelSnapshotsPerTurn` (populated
259
+ * when the parent run was created with `captureSnapshots: true`)
260
+ * and calls {@link WorldModel.fork} with it.
261
+ *
262
+ * @throws Error when the artifact has no embedded per-turn
263
+ * snapshots (parent wasn't run with `captureSnapshots: true`) or
264
+ * when `atTurn` is out of range of the available snapshots.
265
+ */
266
+ async forkFromArtifact(artifact, atTurn, opts = {}) {
267
+ const perTurn = artifact.scenarioExtensions?.kernelSnapshotsPerTurn;
268
+ if (!perTurn || perTurn.length === 0) {
269
+ throw new Error(`WorldModel.forkFromArtifact: artifact has no embedded kernel snapshots. ` +
270
+ `Re-run the parent simulation with \`captureSnapshots: true\` on its RunOptions ` +
271
+ `to enable forking from the stored artifact.`);
272
+ }
273
+ const snap = perTurn.find(s => s.turn === atTurn);
274
+ if (!snap) {
275
+ throw new Error(`WorldModel.forkFromArtifact: no snapshot at turn ${atTurn}. ` +
276
+ `Available turns: [${perTurn.map(s => s.turn).join(', ')}].`);
277
+ }
278
+ return this.fork({
279
+ snapshotVersion: 1,
280
+ kernel: snap,
281
+ parentRunId: artifact.metadata.runId,
282
+ }, opts);
283
+ }
284
+ }
285
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/runtime/world-model/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,EAAE,aAAa,EAAsC,MAAM,oBAAoB,CAAC;AACvF,OAAO,EAAE,QAAQ,EA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Ae,EAAE,CAAC;YAClB,MAAM,EAAE,IAAI;YACZ,WAAW,EAAE,QAAQ,CAAC,QAAQ,CAAC,KAAK;SACrC,EACD,IAAI,CACL,CAAC;IACJ,CAAC;CACF"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "paracosm",
3
- "version": "0.7.407",
4
- "description": "AI agent swarm simulation engine with emergent crises, runtime tool forging, HEXACO personality drift, and deterministic kernels. Built on AgentOS.",
3
+ "version": "0.7.409",
4
+ "description": "Structured world model for AI agents: reproducible counterfactual simulations with deterministic kernels, HEXACO-personality leaders, LLM-driven events, and runtime tool forging. Covers turn-loop civ sims, batch-trajectory digital twins, and batch-point forecasts via one universal Zod-validated RunArtifact. Built on AgentOS.",
5
5
  "type": "module",
6
6
  "main": "dist/engine/index.js",
7
7
  "types": "dist/engine/index.d.ts",
@@ -37,6 +37,10 @@
37
37
  "./schema": {
38
38
  "import": "./dist/engine/schema/index.js",
39
39
  "types": "./dist/engine/schema/index.d.ts"
40
+ },
41
+ "./world-model": {
42
+ "import": "./dist/runtime/world-model/index.js",
43
+ "types": "./dist/runtime/world-model/index.d.ts"
40
44
  }
41
45
  },
42
46
  "files": [
@@ -81,9 +85,18 @@
81
85
  },
82
86
  "keywords": [
83
87
  "paracosm",
88
+ "world-model",
89
+ "structured-world-model",
90
+ "llm-world-model",
91
+ "counterfactual-simulation",
92
+ "cwsm",
93
+ "digital-twin",
94
+ "decision-simulation",
84
95
  "simulation",
85
96
  "multi-agent",
86
97
  "ai-agents",
98
+ "llm-agents",
99
+ "agent-based-modeling",
87
100
  "emergent-behavior",
88
101
  "tool-forging",
89
102
  "hexaco",