paracosm 0.4.384 → 0.4.386
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 +62 -2
- package/dist/cli/run.js +40 -9
- package/dist/cli/run.js.map +1 -1
- package/dist/cli/serve.js +13 -5
- package/dist/cli/serve.js.map +1 -1
- package/dist/engine/index.d.ts +3 -0
- package/dist/engine/index.d.ts.map +1 -1
- package/dist/engine/index.js +5 -0
- package/dist/engine/index.js.map +1 -1
- package/dist/runtime/client.d.ts +128 -0
- package/dist/runtime/client.d.ts.map +1 -0
- package/dist/runtime/client.js +155 -0
- package/dist/runtime/client.js.map +1 -0
- package/dist/runtime/index.d.ts +2 -0
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +1 -0
- package/dist/runtime/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -305,11 +305,71 @@ Everything the dashboard does is also available as library calls. The exports fa
|
|
|
305
305
|
| Import | Surface |
|
|
306
306
|
|--------|---------|
|
|
307
307
|
| `paracosm/compiler` | `compileScenario`, `ingestSeed`, `ingestFromUrl`, type `CompileOptions` |
|
|
308
|
-
| `paracosm/runtime` | `runSimulation`, `runBatch`, `EventDirector`, `generateAgentReactions`, `buildEventSummary`, memory helpers, type `CostPreset` |
|
|
309
|
-
| `paracosm` | `ProviderKeyMissingError`, `SeededRng`, `SimulationKernel`, all `Scenario*` types |
|
|
308
|
+
| `paracosm/runtime` | `runSimulation`, `runBatch`, `EventDirector`, `generateAgentReactions`, `buildEventSummary`, `createParacosmClient`, memory helpers, type `CostPreset` |
|
|
309
|
+
| `paracosm` | `createParacosmClient`, `ProviderKeyMissingError`, `SeededRng`, `SimulationKernel`, all `Scenario*` types |
|
|
310
310
|
| `paracosm/core` | Kernel state types (`Agent`, `WorldState`, `HexacoProfile`, …) |
|
|
311
311
|
| `paracosm/mars`, `paracosm/lunar` | Pre-built `ScenarioPackage` constants to use or fork |
|
|
312
312
|
|
|
313
|
+
### Client — global defaults + env-var config
|
|
314
|
+
|
|
315
|
+
`createParacosmClient` pins `provider`, `costPreset`, per-role `models`, and compile-time options once, then hands back `runSimulation` / `runBatch` / `compileScenario` methods that inherit those defaults. Per-call overrides still win, merged at the per-role level so `models: { departments: 'gpt-5.4' }` at the client and `models: { judge: 'gpt-5.4' }` at the call combine to pin both roles instead of one replacing the other.
|
|
316
|
+
|
|
317
|
+
```typescript
|
|
318
|
+
import { createParacosmClient } from 'paracosm';
|
|
319
|
+
|
|
320
|
+
const client = createParacosmClient({
|
|
321
|
+
provider: 'openai',
|
|
322
|
+
costPreset: 'economy', // cheap default for iteration
|
|
323
|
+
models: { departments: 'gpt-5.4' }, // but pin departments to flagship
|
|
324
|
+
compilerProvider: 'anthropic', // compile on a different provider if you want
|
|
325
|
+
compilerModel: 'claude-sonnet-4-6',
|
|
326
|
+
});
|
|
327
|
+
|
|
328
|
+
const scenario = await client.compileScenario(worldJson);
|
|
329
|
+
const out = await client.runSimulation(leader, [], { maxTurns: 6, seed: 42 });
|
|
330
|
+
|
|
331
|
+
// Promote one specific run to quality without touching the client:
|
|
332
|
+
const gold = await client.runSimulation(leader, [], {
|
|
333
|
+
maxTurns: 8, seed: 42, costPreset: 'quality',
|
|
334
|
+
});
|
|
335
|
+
|
|
336
|
+
// Batch 20 ablations with shared config:
|
|
337
|
+
const manifest = await client.runBatch({
|
|
338
|
+
scenarios: [scenarioA, scenarioB], leaders, turns: 6, seed: 42, maxConcurrency: 4,
|
|
339
|
+
});
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
Env vars feed the same defaults and are read once at `createParacosmClient` construction. Explicit args win over env; env wins over the built-in library defaults.
|
|
343
|
+
|
|
344
|
+
| Env var | Maps to | Valid values |
|
|
345
|
+
|---------|---------|--------------|
|
|
346
|
+
| `PARACOSM_PROVIDER` | `provider` | `openai` / `anthropic` |
|
|
347
|
+
| `PARACOSM_COST_PRESET` | `costPreset` | `quality` / `economy` |
|
|
348
|
+
| `PARACOSM_MODEL_COMMANDER` | `models.commander` | any provider-valid model id |
|
|
349
|
+
| `PARACOSM_MODEL_DEPARTMENTS` | `models.departments` | any provider-valid model id |
|
|
350
|
+
| `PARACOSM_MODEL_JUDGE` | `models.judge` | any provider-valid model id |
|
|
351
|
+
| `PARACOSM_MODEL_DIRECTOR` | `models.director` | any provider-valid model id |
|
|
352
|
+
| `PARACOSM_MODEL_AGENT_REACTIONS` | `models.agentReactions` | any provider-valid model id |
|
|
353
|
+
| `PARACOSM_COMPILER_PROVIDER` | `compilerProvider` | `openai` / `anthropic` |
|
|
354
|
+
| `PARACOSM_COMPILER_MODEL` | `compilerModel` | any provider-valid model id |
|
|
355
|
+
|
|
356
|
+
Invalid values (typos, unknown providers) are silently ignored so bad env state can't crash boot — the client falls back to the next layer. Empty or whitespace-only env values are treated as unset.
|
|
357
|
+
|
|
358
|
+
```bash
|
|
359
|
+
# Zero-code config for hosting / CI:
|
|
360
|
+
PARACOSM_PROVIDER=anthropic \
|
|
361
|
+
PARACOSM_COST_PRESET=economy \
|
|
362
|
+
PARACOSM_MODEL_DEPARTMENTS=claude-sonnet-4-6 \
|
|
363
|
+
node my-runner.js
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
```typescript
|
|
367
|
+
// my-runner.js reads them all implicitly:
|
|
368
|
+
const client = createParacosmClient(); // no args, pulls from env
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
Direct `runSimulation(...)` / `runBatch(...)` / `compileScenario(...)` calls without a client are still fully supported — the client is purely additive for multi-run workflows.
|
|
372
|
+
|
|
313
373
|
### Batch runner — N scenarios × M leaders
|
|
314
374
|
|
|
315
375
|
```typescript
|
package/dist/cli/run.js
CHANGED
|
@@ -15,23 +15,54 @@
|
|
|
15
15
|
* npx tsx src/run.ts --leaders ./my-leaders.json # Custom config file
|
|
16
16
|
*/
|
|
17
17
|
import { readFileSync, existsSync } from 'node:fs';
|
|
18
|
-
import { resolve
|
|
19
|
-
import { fileURLToPath } from 'node:url';
|
|
18
|
+
import { resolve } from 'node:path';
|
|
20
19
|
import { runSimulation } from '../runtime/orchestrator.js';
|
|
21
20
|
import { parseCliRunOptions } from './cli-run-options.js';
|
|
22
21
|
import { DEFAULT_KEY_PERSONNEL } from './sim-config.js';
|
|
23
22
|
import { marsScenario } from '../engine/mars/index.js';
|
|
24
23
|
import { resolveLeaders, parseLeadersFlag } from './leaders-resolver.js';
|
|
25
|
-
|
|
24
|
+
/**
|
|
25
|
+
* Load `.env` from the current working directory if one exists.
|
|
26
|
+
*
|
|
27
|
+
* The previous implementation resolved the path relative to this
|
|
28
|
+
* module's own location (`__dirname/../..`), which meant:
|
|
29
|
+
*
|
|
30
|
+
* - Paracosm devs cloning the repo: loaded `<repo>/.env` — desired.
|
|
31
|
+
* - npm consumers: searched `node_modules/paracosm/.env`, which is
|
|
32
|
+
* not shipped in the tarball and so never matched — fine in the
|
|
33
|
+
* normal case, but surprising if a rogue file (manual copy, dirty
|
|
34
|
+
* postinstall, tampered registry mirror) ever landed there.
|
|
35
|
+
*
|
|
36
|
+
* CWD-scoped is the more honest default:
|
|
37
|
+
*
|
|
38
|
+
* - `paracosm-dashboard` from a project root: loads `<project>/.env`.
|
|
39
|
+
* - `paracosm-dashboard` from the paracosm repo root (dev mode):
|
|
40
|
+
* loads `<repo>/.env` because CWD matches. Same outcome as before.
|
|
41
|
+
* - `paracosm-dashboard` from anywhere else (e.g. `~/`): loads
|
|
42
|
+
* whatever `.env` sits there, which matches every other Node CLI
|
|
43
|
+
* tool's behavior and stops being silently-wrong-but-dev-friendly.
|
|
44
|
+
*
|
|
45
|
+
* Existing `process.env` values always win over `.env` entries so a
|
|
46
|
+
* shell-exported key doesn't get clobbered by a stale file.
|
|
47
|
+
*
|
|
48
|
+
* Logs the source path when a file was loaded so users can audit where
|
|
49
|
+
* their keys came from — addresses the "I deleted my .env but the sim
|
|
50
|
+
* still runs, where is the key coming from?" surprise.
|
|
51
|
+
*/
|
|
26
52
|
function loadEnv() {
|
|
27
|
-
const envPath = resolve(
|
|
28
|
-
if (existsSync(envPath))
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
53
|
+
const envPath = resolve(process.cwd(), '.env');
|
|
54
|
+
if (!existsSync(envPath))
|
|
55
|
+
return;
|
|
56
|
+
let loaded = 0;
|
|
57
|
+
for (const line of readFileSync(envPath, 'utf-8').split('\n')) {
|
|
58
|
+
const match = line.match(/^\s*([^#=]+?)\s*=\s*(.+?)\s*$/);
|
|
59
|
+
if (match && !process.env[match[1]]) {
|
|
60
|
+
process.env[match[1]] = match[2];
|
|
61
|
+
loaded += 1;
|
|
33
62
|
}
|
|
34
63
|
}
|
|
64
|
+
if (loaded > 0)
|
|
65
|
+
console.log(` [env] loaded ${loaded} var${loaded === 1 ? '' : 's'} from ${envPath}`);
|
|
35
66
|
}
|
|
36
67
|
function loadLeaders(argv) {
|
|
37
68
|
const explicitPath = parseLeadersFlag(argv);
|
package/dist/cli/run.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.js","sourceRoot":"","sources":["../../src/cli/run.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"run.js","sourceRoot":"","sources":["../../src/cli/run.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,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AS,OAAO,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;AACnF,OAAO,CAAC,GAAG,CAAC,eAAe,MAAM,CAAC,MAAM,CAAC,QAAQ,MAAM,MAAM,CAAC,MAAM,CAAC,iBAAiB,MAAM,MAAM,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC,CAAC;AAE1H,aAAa,CAAC,MAAM,EAAE,qBAAqB,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,UAAU,EAAE,QAAQ,EAAE,YAAY,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IAC/G,OAAO,CAAC,KAAK,CAAC,oBAAoB,EAAE,GAAG,CAAC,CAAC;IACzC,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AACvB,CAAC,CAAC,CAAC"}
|
package/dist/cli/serve.js
CHANGED
|
@@ -7,21 +7,29 @@
|
|
|
7
7
|
* Open http://localhost:3456/sim?tab=settings or /setup
|
|
8
8
|
*/
|
|
9
9
|
import { readFileSync, existsSync } from 'node:fs';
|
|
10
|
-
import { resolve
|
|
11
|
-
import { fileURLToPath } from 'node:url';
|
|
10
|
+
import { resolve } from 'node:path';
|
|
12
11
|
import { createMarsServer } from './server-app.js';
|
|
13
12
|
import { normalizeSimulationConfig } from './sim-config.js';
|
|
14
13
|
import { parseCliRunOptions } from './cli-run-options.js';
|
|
15
14
|
import { resolveLeaders, parseLeadersFlag } from './leaders-resolver.js';
|
|
16
|
-
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
17
15
|
const PORT = parseInt(process.env.PORT || '3456', 10);
|
|
18
|
-
|
|
16
|
+
// Load `.env` from the current working directory (not the paracosm
|
|
17
|
+
// package root). See `src/cli/run.ts::loadEnv` for the full rationale
|
|
18
|
+
// — CWD-scoped is auditable, matches normal CLI-tool convention, and
|
|
19
|
+
// stops a stray `.env` landing inside `node_modules/paracosm/` from
|
|
20
|
+
// quietly overriding the user's environment.
|
|
21
|
+
const envPath = resolve(process.cwd(), '.env');
|
|
19
22
|
if (existsSync(envPath)) {
|
|
23
|
+
let loaded = 0;
|
|
20
24
|
for (const line of readFileSync(envPath, 'utf-8').split('\n')) {
|
|
21
25
|
const match = line.match(/^\s*([^#=]+?)\s*=\s*(.+?)\s*$/);
|
|
22
|
-
if (match && !process.env[match[1]])
|
|
26
|
+
if (match && !process.env[match[1]]) {
|
|
23
27
|
process.env[match[1]] = match[2];
|
|
28
|
+
loaded += 1;
|
|
29
|
+
}
|
|
24
30
|
}
|
|
31
|
+
if (loaded > 0)
|
|
32
|
+
console.log(` [env] loaded ${loaded} var${loaded === 1 ? '' : 's'} from ${envPath}`);
|
|
25
33
|
}
|
|
26
34
|
const server = createMarsServer({ env: process.env });
|
|
27
35
|
const cliOptions = parseCliRunOptions(process.argv.slice(2));
|
package/dist/cli/serve.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serve.js","sourceRoot":"","sources":["../../src/cli/serve.ts"],"names":[],"mappings":";AACA;;;;;;GAMG;AAEH,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"serve.js","sourceRoot":"","sources":["../../src/cli/serve.ts"],"names":[],"mappings":";AACA;;;;;;GAMG;AAEH,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAGzE,MAAM,IAAI,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,MA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QAAQ;QAC1B,IAAI,EAAE,UAAU,CAAC,IAAI;QACrB,SAAS,EAAE,UAAU,CAAC,SAAS;QAC/B,UAAU,EAAE,UAAU,CAAC,UAAU;QACjC,QAAQ,EAAE,UAAU,CAAC,QAAQ;QAC7B,MAAM,EAAE,UAAU,CAAC,MAAM;KAC1B,CAAC,CAAC;IAEH,MAAM,MAAM,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC;IACxC,OAAO,CAAC,GAAG,CAAC,0DAA0D,GAAG,IAAI,CAAC,CAAC;IAC/E,OAAO,CAAC,GAAG,CAAC,kCAAkC,GAAG,IAAI,GAAG,qBAAqB,CAAC,CAAC;AACjF,CAAC,CAAC,CAAC"}
|
package/dist/engine/index.d.ts
CHANGED
|
@@ -24,4 +24,7 @@ export { marsScenario } from './mars/index.js';
|
|
|
24
24
|
export { lunarScenario } from './lunar/index.js';
|
|
25
25
|
export { ProviderKeyMissingError, resolveProviderWithFallback } from './provider-resolver.js';
|
|
26
26
|
export type { ResolvedProviderChoice, ResolveProviderOptions } from './provider-resolver.js';
|
|
27
|
+
export { createParacosmClient } from '../runtime/client.js';
|
|
28
|
+
export type { ParacosmClient, ParacosmClientOptions } from '../runtime/client.js';
|
|
29
|
+
export type { CostPreset } from '../cli/sim-config.js';
|
|
27
30
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/engine/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,YAAY,EACV,eAAe,EACf,cAAc,EACd,aAAa,EACb,mBAAmB,EACnB,mBAAmB,EACnB,iBAAiB,EACjB,UAAU,EACV,eAAe,EACf,oBAAoB,EACpB,oBAAoB,EACpB,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,oBAAoB,EACpB,iBAAiB,EACjB,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,sBAAsB,EACtB,iBAAiB,EACjB,aA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zB,YAAY,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAC3F,YAAY,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,qBAAqB,EAAE,QAAQ,EAAE,cAAc,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAGjJ,YAAY,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,YAAY,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACzD,YAAY,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAG7D,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAMjD,OAAO,EAAE,uBAAuB,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAC9F,YAAY,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAM7F,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,YAAY,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAClF,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC"}
|
package/dist/engine/index.js
CHANGED
|
@@ -21,4 +21,9 @@ export { lunarScenario } from './lunar/index.js';
|
|
|
21
21
|
// lets tools/tests drive the resolver without importing from internal
|
|
22
22
|
// paths.
|
|
23
23
|
export { ProviderKeyMissingError, resolveProviderWithFallback } from './provider-resolver.js';
|
|
24
|
+
// Top-level client re-export so `import { createParacosmClient } from
|
|
25
|
+
// 'paracosm'` works. Keeps the discoverability bar low for new users:
|
|
26
|
+
// one import for the most common entry point, deeper imports available
|
|
27
|
+
// via `paracosm/runtime` and `paracosm/compiler` when needed.
|
|
28
|
+
export { createParacosmClient } from '../runtime/client.js';
|
|
24
29
|
//# sourceMappingURL=index.js.map
|
package/dist/engine/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/engine/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AA4BH,aAAa;AACb,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,cAAc;AACd,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAoB1H,oBAAoB;AACpB,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,8DAA8D;AAC9D,oEAAoE;AACpE,sEAAsE;AACtE,SAAS;AACT,OAAO,EAAE,uBAAuB,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/engine/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AA4BH,aAAa;AACb,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,cAAc;AACd,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAoB1H,oBAAoB;AACpB,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,8DAA8D;AAC9D,oEAAoE;AACpE,sEAAsE;AACtE,SAAS;AACT,OAAO,EAAE,uBAAuB,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAG9F,sEAAsE;AACtE,sEAAsE;AACtE,uEAAuE;AACvE,8DAA8D;AAC9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Paracosm client — one-call factory that pins `provider`, `costPreset`,
|
|
3
|
+
* per-role `models`, and compile-time options once, then hands back
|
|
4
|
+
* methods that inherit those defaults on every call.
|
|
5
|
+
*
|
|
6
|
+
* Problem it solves: a typical programmatic workflow runs 10-50
|
|
7
|
+
* simulations (batch sweeps, CI regression checks, per-scenario
|
|
8
|
+
* ablations). Passing the same `{ provider, costPreset, models }` on
|
|
9
|
+
* every `runSimulation(leader, [], { ... })` call is noisy and
|
|
10
|
+
* error-prone; a typo in one config entry silently breaks that run's
|
|
11
|
+
* model routing without breaking the others. The client centralizes
|
|
12
|
+
* the defaults so per-call overrides become the exception, not the
|
|
13
|
+
* baseline.
|
|
14
|
+
*
|
|
15
|
+
* Layering (lowest precedence to highest):
|
|
16
|
+
* 1. Built-in defaults from `DEFAULT_MODELS` / `DEMO_MODELS`
|
|
17
|
+
* 2. `PARACOSM_*` env vars (read once at client construction)
|
|
18
|
+
* 3. Explicit `createParacosmClient({ ... })` args
|
|
19
|
+
* 4. Per-call overrides on `client.runSimulation(leader, [], { ... })`
|
|
20
|
+
*
|
|
21
|
+
* Each higher layer merges over the lower one; `models` merges at the
|
|
22
|
+
* per-role level so you can pin `departments: 'gpt-5.4'` at the client
|
|
23
|
+
* and still override `judge` per call.
|
|
24
|
+
*
|
|
25
|
+
* @module paracosm/runtime/client
|
|
26
|
+
*/
|
|
27
|
+
import { runSimulation, type RunOptions, type LeaderConfig } from './orchestrator.js';
|
|
28
|
+
import { type BatchConfig, type BatchManifest } from './batch.js';
|
|
29
|
+
import type { CompileOptions } from '../engine/compiler/types.js';
|
|
30
|
+
import type { KeyPersonnel } from '../engine/core/agent-generator.js';
|
|
31
|
+
import type { LlmProvider, ScenarioPackage, SimulationModelConfig } from '../engine/types.js';
|
|
32
|
+
import type { CostPreset } from '../cli/sim-config.js';
|
|
33
|
+
/** Options passed to `createParacosmClient`. Every field is optional and composes with env-var reads. */
|
|
34
|
+
export interface ParacosmClientOptions {
|
|
35
|
+
/**
|
|
36
|
+
* Default provider for `runSimulation` / `runBatch`. Env fallback:
|
|
37
|
+
* `PARACOSM_PROVIDER=openai` or `=anthropic`. Per-call `opts.provider`
|
|
38
|
+
* still wins.
|
|
39
|
+
*/
|
|
40
|
+
provider?: LlmProvider;
|
|
41
|
+
/**
|
|
42
|
+
* Default cost preset. Env fallback: `PARACOSM_COST_PRESET=quality`
|
|
43
|
+
* or `=economy`.
|
|
44
|
+
*/
|
|
45
|
+
costPreset?: CostPreset;
|
|
46
|
+
/**
|
|
47
|
+
* Per-role model pins. Env fallbacks:
|
|
48
|
+
* PARACOSM_MODEL_COMMANDER, PARACOSM_MODEL_DEPARTMENTS,
|
|
49
|
+
* PARACOSM_MODEL_JUDGE, PARACOSM_MODEL_DIRECTOR,
|
|
50
|
+
* PARACOSM_MODEL_AGENT_REACTIONS
|
|
51
|
+
* Merged at the per-role level, not whole-object: setting
|
|
52
|
+
* `models: { departments: 'gpt-5.4' }` pins departments but leaves
|
|
53
|
+
* commander / director / judge / agentReactions flowing from the
|
|
54
|
+
* preset as before.
|
|
55
|
+
*/
|
|
56
|
+
models?: Partial<SimulationModelConfig>;
|
|
57
|
+
/**
|
|
58
|
+
* Provider to use for compile-time LLM calls in `client.compileScenario`.
|
|
59
|
+
* Defaults to `provider` when unset so most users only configure one
|
|
60
|
+
* provider. Env fallback: `PARACOSM_COMPILER_PROVIDER`.
|
|
61
|
+
*/
|
|
62
|
+
compilerProvider?: LlmProvider;
|
|
63
|
+
/**
|
|
64
|
+
* Model to use for compile-time LLM calls. Env fallback:
|
|
65
|
+
* `PARACOSM_COMPILER_MODEL`. If omitted the compiler picks a
|
|
66
|
+
* provider-default (gpt-5.4-mini on OpenAI, claude-sonnet-4-6 on
|
|
67
|
+
* Anthropic).
|
|
68
|
+
*/
|
|
69
|
+
compilerModel?: string;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Handle returned by `createParacosmClient`. The three methods mirror
|
|
73
|
+
* the corresponding standalone exports — same arg shapes, same return
|
|
74
|
+
* types — but with the client's defaults layered in.
|
|
75
|
+
*/
|
|
76
|
+
export interface ParacosmClient {
|
|
77
|
+
/**
|
|
78
|
+
* Run one simulation. Leader + key personnel passed per-call; all
|
|
79
|
+
* other options inherit from the client with per-call overrides.
|
|
80
|
+
*/
|
|
81
|
+
runSimulation: (leader: LeaderConfig, keyPersonnel: KeyPersonnel[], opts?: RunOptions) => ReturnType<typeof runSimulation>;
|
|
82
|
+
/**
|
|
83
|
+
* Run a batch sweep. Scenarios / leaders / turns / seed are the
|
|
84
|
+
* caller's responsibility; provider + costPreset + models inherit.
|
|
85
|
+
*/
|
|
86
|
+
runBatch: (config: BatchConfig) => Promise<BatchManifest>;
|
|
87
|
+
/**
|
|
88
|
+
* Compile a scenario with the client's compiler defaults.
|
|
89
|
+
*/
|
|
90
|
+
compileScenario: (scenarioJson: Record<string, unknown>, opts?: CompileOptions) => Promise<ScenarioPackage>;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Create a Paracosm client with pinned defaults. Env vars are read once
|
|
94
|
+
* at construction; subsequent `process.env` mutations won't retrigger.
|
|
95
|
+
*
|
|
96
|
+
* @example
|
|
97
|
+
* ```typescript
|
|
98
|
+
* import { createParacosmClient } from 'paracosm/runtime';
|
|
99
|
+
*
|
|
100
|
+
* const client = createParacosmClient({
|
|
101
|
+
* provider: 'openai',
|
|
102
|
+
* costPreset: 'economy',
|
|
103
|
+
* models: { departments: 'gpt-5.4' }, // pin only departments to flagship
|
|
104
|
+
* });
|
|
105
|
+
*
|
|
106
|
+
* const scenario = await client.compileScenario(worldJson);
|
|
107
|
+
* const out = await client.runSimulation(leader, [], { maxTurns: 6, seed: 42 });
|
|
108
|
+
*
|
|
109
|
+
* // Per-call override wins over client defaults:
|
|
110
|
+
* const quality = await client.runSimulation(leader, [], {
|
|
111
|
+
* maxTurns: 8, seed: 42,
|
|
112
|
+
* costPreset: 'quality', // promote this one run to flagship
|
|
113
|
+
* });
|
|
114
|
+
* ```
|
|
115
|
+
*
|
|
116
|
+
* @example Env-driven (zero-code config for hosting / CI):
|
|
117
|
+
* ```bash
|
|
118
|
+
* PARACOSM_PROVIDER=anthropic \
|
|
119
|
+
* PARACOSM_COST_PRESET=economy \
|
|
120
|
+
* PARACOSM_MODEL_DEPARTMENTS=claude-sonnet-4-6 \
|
|
121
|
+
* node my-runner.js
|
|
122
|
+
* ```
|
|
123
|
+
* ```typescript
|
|
124
|
+
* const client = createParacosmClient(); // no args — reads from env
|
|
125
|
+
* ```
|
|
126
|
+
*/
|
|
127
|
+
export declare function createParacosmClient(options?: ParacosmClientOptions): ParacosmClient;
|
|
128
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/runtime/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EAAE,aAAa,EAAE,KAAK,UAAU,EAAE,KAAK,YAAY,EAAE,MAAM,mBAAmB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"}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Paracosm client — one-call factory that pins `provider`, `costPreset`,
|
|
3
|
+
* per-role `models`, and compile-time options once, then hands back
|
|
4
|
+
* methods that inherit those defaults on every call.
|
|
5
|
+
*
|
|
6
|
+
* Problem it solves: a typical programmatic workflow runs 10-50
|
|
7
|
+
* simulations (batch sweeps, CI regression checks, per-scenario
|
|
8
|
+
* ablations). Passing the same `{ provider, costPreset, models }` on
|
|
9
|
+
* every `runSimulation(leader, [], { ... })` call is noisy and
|
|
10
|
+
* error-prone; a typo in one config entry silently breaks that run's
|
|
11
|
+
* model routing without breaking the others. The client centralizes
|
|
12
|
+
* the defaults so per-call overrides become the exception, not the
|
|
13
|
+
* baseline.
|
|
14
|
+
*
|
|
15
|
+
* Layering (lowest precedence to highest):
|
|
16
|
+
* 1. Built-in defaults from `DEFAULT_MODELS` / `DEMO_MODELS`
|
|
17
|
+
* 2. `PARACOSM_*` env vars (read once at client construction)
|
|
18
|
+
* 3. Explicit `createParacosmClient({ ... })` args
|
|
19
|
+
* 4. Per-call overrides on `client.runSimulation(leader, [], { ... })`
|
|
20
|
+
*
|
|
21
|
+
* Each higher layer merges over the lower one; `models` merges at the
|
|
22
|
+
* per-role level so you can pin `departments: 'gpt-5.4'` at the client
|
|
23
|
+
* and still override `judge` per call.
|
|
24
|
+
*
|
|
25
|
+
* @module paracosm/runtime/client
|
|
26
|
+
*/
|
|
27
|
+
import { runSimulation } from './orchestrator.js';
|
|
28
|
+
import { runBatch } from './batch.js';
|
|
29
|
+
import { compileScenario } from '../engine/compiler/index.js';
|
|
30
|
+
const VALID_PROVIDERS = ['openai', 'anthropic'];
|
|
31
|
+
const VALID_PRESETS = ['quality', 'economy'];
|
|
32
|
+
function envString(key) {
|
|
33
|
+
const env = typeof process !== 'undefined' && process.env ? process.env : undefined;
|
|
34
|
+
if (!env)
|
|
35
|
+
return undefined;
|
|
36
|
+
const v = env[key];
|
|
37
|
+
if (typeof v !== 'string')
|
|
38
|
+
return undefined;
|
|
39
|
+
const trimmed = v.trim();
|
|
40
|
+
return trimmed.length > 0 ? trimmed : undefined;
|
|
41
|
+
}
|
|
42
|
+
function readEnvClientOptions() {
|
|
43
|
+
const rawProvider = envString('PARACOSM_PROVIDER');
|
|
44
|
+
const rawCompilerProvider = envString('PARACOSM_COMPILER_PROVIDER');
|
|
45
|
+
const rawPreset = envString('PARACOSM_COST_PRESET');
|
|
46
|
+
const provider = rawProvider && VALID_PROVIDERS.includes(rawProvider)
|
|
47
|
+
? rawProvider
|
|
48
|
+
: undefined;
|
|
49
|
+
const compilerProvider = rawCompilerProvider && VALID_PROVIDERS.includes(rawCompilerProvider)
|
|
50
|
+
? rawCompilerProvider
|
|
51
|
+
: undefined;
|
|
52
|
+
const costPreset = rawPreset && VALID_PRESETS.includes(rawPreset)
|
|
53
|
+
? rawPreset
|
|
54
|
+
: undefined;
|
|
55
|
+
const models = {};
|
|
56
|
+
const commander = envString('PARACOSM_MODEL_COMMANDER');
|
|
57
|
+
const departments = envString('PARACOSM_MODEL_DEPARTMENTS');
|
|
58
|
+
const judge = envString('PARACOSM_MODEL_JUDGE');
|
|
59
|
+
const director = envString('PARACOSM_MODEL_DIRECTOR');
|
|
60
|
+
const agentReactions = envString('PARACOSM_MODEL_AGENT_REACTIONS');
|
|
61
|
+
if (commander)
|
|
62
|
+
models.commander = commander;
|
|
63
|
+
if (departments)
|
|
64
|
+
models.departments = departments;
|
|
65
|
+
if (judge)
|
|
66
|
+
models.judge = judge;
|
|
67
|
+
if (director)
|
|
68
|
+
models.director = director;
|
|
69
|
+
if (agentReactions)
|
|
70
|
+
models.agentReactions = agentReactions;
|
|
71
|
+
return {
|
|
72
|
+
provider,
|
|
73
|
+
compilerProvider,
|
|
74
|
+
costPreset,
|
|
75
|
+
models: Object.keys(models).length > 0 ? models : undefined,
|
|
76
|
+
compilerModel: envString('PARACOSM_COMPILER_MODEL'),
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Create a Paracosm client with pinned defaults. Env vars are read once
|
|
81
|
+
* at construction; subsequent `process.env` mutations won't retrigger.
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```typescript
|
|
85
|
+
* import { createParacosmClient } from 'paracosm/runtime';
|
|
86
|
+
*
|
|
87
|
+
* const client = createParacosmClient({
|
|
88
|
+
* provider: 'openai',
|
|
89
|
+
* costPreset: 'economy',
|
|
90
|
+
* models: { departments: 'gpt-5.4' }, // pin only departments to flagship
|
|
91
|
+
* });
|
|
92
|
+
*
|
|
93
|
+
* const scenario = await client.compileScenario(worldJson);
|
|
94
|
+
* const out = await client.runSimulation(leader, [], { maxTurns: 6, seed: 42 });
|
|
95
|
+
*
|
|
96
|
+
* // Per-call override wins over client defaults:
|
|
97
|
+
* const quality = await client.runSimulation(leader, [], {
|
|
98
|
+
* maxTurns: 8, seed: 42,
|
|
99
|
+
* costPreset: 'quality', // promote this one run to flagship
|
|
100
|
+
* });
|
|
101
|
+
* ```
|
|
102
|
+
*
|
|
103
|
+
* @example Env-driven (zero-code config for hosting / CI):
|
|
104
|
+
* ```bash
|
|
105
|
+
* PARACOSM_PROVIDER=anthropic \
|
|
106
|
+
* PARACOSM_COST_PRESET=economy \
|
|
107
|
+
* PARACOSM_MODEL_DEPARTMENTS=claude-sonnet-4-6 \
|
|
108
|
+
* node my-runner.js
|
|
109
|
+
* ```
|
|
110
|
+
* ```typescript
|
|
111
|
+
* const client = createParacosmClient(); // no args — reads from env
|
|
112
|
+
* ```
|
|
113
|
+
*/
|
|
114
|
+
export function createParacosmClient(options = {}) {
|
|
115
|
+
const fromEnv = readEnvClientOptions();
|
|
116
|
+
// Explicit args win over env; env wins over the built-in library
|
|
117
|
+
// defaults further down the call chain (DEFAULT_MODELS / DEMO_MODELS).
|
|
118
|
+
const provider = options.provider ?? fromEnv.provider;
|
|
119
|
+
const costPreset = options.costPreset ?? fromEnv.costPreset;
|
|
120
|
+
const mergedModels = {
|
|
121
|
+
...fromEnv.models,
|
|
122
|
+
...options.models,
|
|
123
|
+
};
|
|
124
|
+
const compilerProvider = options.compilerProvider
|
|
125
|
+
?? fromEnv.compilerProvider
|
|
126
|
+
?? provider;
|
|
127
|
+
const compilerModel = options.compilerModel ?? fromEnv.compilerModel;
|
|
128
|
+
const hasClientModels = Object.keys(mergedModels).length > 0;
|
|
129
|
+
return {
|
|
130
|
+
runSimulation: (leader, keyPersonnel, opts = {}) => runSimulation(leader, keyPersonnel, {
|
|
131
|
+
...opts,
|
|
132
|
+
provider: opts.provider ?? provider,
|
|
133
|
+
costPreset: opts.costPreset ?? costPreset,
|
|
134
|
+
// Per-role merge so caller's override only stomps the role(s)
|
|
135
|
+
// they specified, not the whole client pin.
|
|
136
|
+
models: hasClientModels || opts.models
|
|
137
|
+
? { ...mergedModels, ...opts.models }
|
|
138
|
+
: undefined,
|
|
139
|
+
}),
|
|
140
|
+
runBatch: (config) => runBatch({
|
|
141
|
+
...config,
|
|
142
|
+
provider: config.provider ?? provider,
|
|
143
|
+
costPreset: config.costPreset ?? costPreset,
|
|
144
|
+
models: hasClientModels || config.models
|
|
145
|
+
? { ...mergedModels, ...config.models }
|
|
146
|
+
: undefined,
|
|
147
|
+
}),
|
|
148
|
+
compileScenario: (scenarioJson, opts = {}) => compileScenario(scenarioJson, {
|
|
149
|
+
...opts,
|
|
150
|
+
provider: opts.provider ?? compilerProvider,
|
|
151
|
+
model: opts.model ?? compilerModel,
|
|
152
|
+
}),
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/runtime/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EAAE,aAAa,EAAsC,MAAM,mBAAmB,CAAC;AACtF,OAAO,EAAE,QAAQ,EAAwC,MAAM,YAAY,CA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,GAAG,IAAI;YACP,QAAQ,EAAE,IAAI,CAAC,QAAQ,IAAI,gBAAgB;YAC3C,KAAK,EAAE,IAAI,CAAC,KAAK,IAAI,aAAa;SACnC,CAAC;KACH,CAAC;AACJ,CAAC"}
|
package/dist/runtime/index.d.ts
CHANGED
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
export { runSimulation, buildEventSummary } from './orchestrator.js';
|
|
7
7
|
export type { RunOptions, SimEvent, SimEventType, SimEventPayloadMap, SimEventCostPayload, LeaderConfig, } from './orchestrator.js';
|
|
8
8
|
export type { CostPreset } from '../cli/sim-config.js';
|
|
9
|
+
export { createParacosmClient } from './client.js';
|
|
10
|
+
export type { ParacosmClient, ParacosmClientOptions } from './client.js';
|
|
9
11
|
export { EventDirector } from './director.js';
|
|
10
12
|
export type { DirectorEvent, DirectorCrisis, DirectorContext, EventCategory, CrisisCategory } from './director.js';
|
|
11
13
|
export type { DepartmentReport, CommanderDecision, TurnArtifact, CrisisResearchPacket } from './contracts.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACrE,YAAY,EACV,UAAU,EACV,QAAQ,EACR,YAAY,EACZ,kBAAkB,EAClB,mBAAmB,EACnB,YAAY,GACb,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,eAAe,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACnH,YAAY,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAC9G,OAAO,EAAE,sBAAs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AsB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC1E,OAAO,EACL,sBAAsB,EACtB,uBAAuB,GACxB,MAAM,wBAAwB,CAAC;AAChC,YAAY,EACV,iBAAiB,EACjB,wBAAwB,EACxB,4BAA4B,GAC7B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,gCAAgC,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC"}
|
package/dist/runtime/index.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* Run simulations with AI agents, crisis directors, and department analysis.
|
|
5
5
|
*/
|
|
6
6
|
export { runSimulation, buildEventSummary } from './orchestrator.js';
|
|
7
|
+
export { createParacosmClient } from './client.js';
|
|
7
8
|
export { EventDirector } from './director.js';
|
|
8
9
|
export { buildDepartmentContext, getDepartmentsForTurn } from './departments.js';
|
|
9
10
|
export { generateAgentReactions } from './agent-reactions.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAUrE,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAG9C,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AACjF,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,OAAO,EACL,sBAAsB,EACtB,uBAAuB,GACxB,MAAM,wBAAwB,CAAC;AAMhC,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,gCAAgC,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAUrE,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAEnD,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAG9C,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AACjF,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,OAAO,EACL,sBAAsB,EACtB,uBAAuB,GACxB,MAAM,wBAAwB,CAAC;AAMhC,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,gCAAgC,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "paracosm",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.386",
|
|
4
4
|
"description": "AI agent swarm simulation engine with emergent crises, runtime tool forging, HEXACO personality drift, and deterministic kernels. Built on AgentOS.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/engine/index.js",
|