@zergai/ztc 0.26.6-dev.202611240947 → 0.27.0-beta.1
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 +629 -167
- package/RUST_THIRD_PARTY_LICENSES.txt +5 -5
- package/bin/zmux-darwin-arm64 +0 -0
- package/bin/zmux-linux-x64 +0 -0
- package/bin/ztc-audio-darwin-arm64 +0 -0
- package/bin/ztc-capture-darwin-arm64 +0 -0
- package/bin/ztc-computer-darwin-arm64 +0 -0
- package/bin/ztc-llm-darwin-arm64 +0 -0
- package/bin/ztc-tts-darwin-arm64 +0 -0
- package/bin/ztc-tui-darwin-arm64 +0 -0
- package/bin/ztc-tui-linux-x64 +0 -0
- package/bin/zterm-darwin-arm64 +2 -2
- package/dist/App.js +6 -1
- package/dist/agent/agent.d.ts +21 -15
- package/dist/agent/agent.js +389 -163
- package/dist/agent/backends/codex_app_server.d.ts +7 -1
- package/dist/agent/backends/codex_app_server.js +11 -1
- package/dist/agent/backends/gemini.js +22 -8
- package/dist/agent/commands/batch.js +8 -0
- package/dist/agent/commands/config.js +10 -0
- package/dist/agent/commands/environment.js +5 -5
- package/dist/agent/commands/goal.d.ts +1 -0
- package/dist/agent/commands/goal.js +2 -1
- package/dist/agent/commands/index.js +2 -1
- package/dist/agent/commands/manifest.js +4 -0
- package/dist/agent/commands/optimize.js +5 -2
- package/dist/agent/commands/pane_cli.d.ts +29 -0
- package/dist/agent/commands/pane_cli.js +303 -0
- package/dist/agent/commands/settings.js +13 -3
- package/dist/agent/commands/shannon.js +8 -0
- package/dist/agent/commands/update.js +15 -3
- package/dist/agent/commands/zerg.js +31 -1
- package/dist/agent/commands/ztc_pane.js +3 -1
- package/dist/agent/factory.d.ts +4 -0
- package/dist/agent/factory.js +11 -1
- package/dist/agent/loop_policy.d.ts +42 -5
- package/dist/agent/loop_policy.js +206 -3
- package/dist/agent/runtime/command_jobs.d.ts +5 -0
- package/dist/agent/runtime/command_jobs.js +241 -31
- package/dist/agent/runtime/command_wait.d.ts +2 -0
- package/dist/agent/runtime/command_wait.js +1 -0
- package/dist/agent/runtime/done_report.d.ts +18 -0
- package/dist/agent/runtime/done_report.js +130 -0
- package/dist/agent/runtime/execution_context.js +4 -1
- package/dist/agent/runtime/failure_cause.d.ts +2 -0
- package/dist/agent/runtime/failure_cause.js +35 -0
- package/dist/agent/runtime/policy.d.ts +14 -2
- package/dist/agent/runtime/policy.js +104 -12
- package/dist/agent/runtime/quiet_job.d.ts +18 -0
- package/dist/agent/runtime/quiet_job.js +48 -0
- package/dist/agent/runtime/recovery.d.ts +1 -5
- package/dist/agent/runtime/recovery.js +2 -44
- package/dist/agent/runtime/tool_runtime.d.ts +1 -0
- package/dist/agent/runtime/tool_runtime.js +2 -0
- package/dist/agent/subagent.js +6 -1
- package/dist/agent/tools/deferred.js +1 -0
- package/dist/agent/tools/index.d.ts +2 -0
- package/dist/agent/tools/index.js +1 -0
- package/dist/agent/tools/outcome.d.ts +15 -0
- package/dist/agent/tools/outcome.js +107 -0
- package/dist/agent/tools/pane.d.ts +2 -1
- package/dist/agent/tools/pane.js +21 -3
- package/dist/agent/tools/registry.js +2 -0
- package/dist/agent/tools/shell.d.ts +1 -0
- package/dist/agent/tools/shell.js +128 -17
- package/dist/agent/tools/sim_domain_tools.js +4 -2
- package/dist/agent/tools/supervision.js +4 -2
- package/dist/agent/tools/types.d.ts +3 -0
- package/dist/app/command_context.js +5 -9
- package/dist/app/conversation_compaction.d.ts +4 -2
- package/dist/app/conversation_compaction.js +16 -5
- package/dist/app/headless_shell_mode.d.ts +14 -0
- package/dist/app/headless_shell_mode.js +7 -0
- package/dist/app/hosted_resident.d.ts +356 -0
- package/dist/app/hosted_resident.js +677 -0
- package/dist/app/restart.js +11 -2
- package/dist/app/session_manager.d.ts +5 -0
- package/dist/app/session_manager.js +21 -6
- package/dist/app/session_messages.js +6 -6
- package/dist/app/workspace_layout_controller.js +7 -0
- package/dist/batch/worktree.d.ts +10 -0
- package/dist/batch/worktree.js +15 -0
- package/dist/bench/registry.js +4 -2
- package/dist/cli_args.js +1 -1
- package/dist/cli_main.js +80 -10
- package/dist/cli_ratatui.d.ts +75 -0
- package/dist/cli_ratatui.js +485 -84
- package/dist/components/InputArea.js +4 -4
- package/dist/config/execution.d.ts +10 -0
- package/dist/config/execution.js +10 -0
- package/dist/config/hosted_runtime.d.ts +4 -1
- package/dist/config/hosted_runtime.js +4 -1
- package/dist/config/permission_pin.d.ts +34 -2
- package/dist/config/permission_pin.js +52 -2
- package/dist/config/person_command_policy.d.ts +38 -0
- package/dist/config/person_command_policy.js +11 -0
- package/dist/config/profiles.d.ts +21 -0
- package/dist/config/profiles.js +56 -2
- package/dist/config/types.d.ts +4 -1
- package/dist/config.js +34 -19
- package/dist/desktop/daily/codex_exec_adapter.js +7 -2
- package/dist/desktop/daily/desktop_wiring.d.ts +7 -1
- package/dist/desktop/daily/desktop_wiring.js +11 -3
- package/dist/desktop/daily/recipes.js +20 -4
- package/dist/desktop/health.d.ts +24 -0
- package/dist/desktop/health.js +151 -0
- package/dist/desktop/native_dialogs.d.ts +37 -0
- package/dist/desktop/native_dialogs.js +105 -0
- package/dist/diagnostics/session_export.d.ts +1 -0
- package/dist/diagnostics/session_export.js +28 -0
- package/dist/embedded/registry.js +4 -2
- package/dist/emulation/tool_adapters.js +9 -4
- package/dist/emulation/ztc_addendum.js +3 -0
- package/dist/headless.d.ts +11 -4
- package/dist/headless.js +99 -34
- package/dist/headless_approval.d.ts +6 -0
- package/dist/headless_cli.js +1 -1
- package/dist/hooks/runner.js +7 -6
- package/dist/library.d.ts +4 -0
- package/dist/library.js +3 -0
- package/dist/mcp/client.js +3 -3
- package/dist/modes/registry.js +13 -4
- package/dist/onboarding/setup_environment.js +13 -1
- package/dist/optimize/adapters/kernelbench.js +88 -10
- package/dist/optimize/adapters/types.d.ts +5 -0
- package/dist/optimize/executor.js +21 -0
- package/dist/panes/cli_install.d.ts +54 -0
- package/dist/panes/cli_install.js +157 -0
- package/dist/panes/model_catalog.js +3 -0
- package/dist/panes/new_pane_choices.d.ts +6 -2
- package/dist/panes/new_pane_choices.js +24 -12
- package/dist/panes/pane_cli_launch.d.ts +50 -0
- package/dist/panes/pane_cli_launch.js +124 -0
- package/dist/panes/pane_clis.d.ts +171 -0
- package/dist/panes/pane_clis.js +325 -0
- package/dist/panes/person_only_panes.d.ts +45 -0
- package/dist/panes/person_only_panes.js +117 -0
- package/dist/plugin/simulation_living.js +0 -2
- package/dist/plugin/simulation_living_engine.d.ts +1 -0
- package/dist/plugin/simulation_living_engine.js +1 -0
- package/dist/plugin/simulation_living_labels.d.ts +3 -0
- package/dist/plugin/simulation_living_labels.js +2 -0
- package/dist/router_auth.js +12 -1
- package/dist/session.js +26 -1
- package/dist/simulation/art/gemini_image.js +11 -5
- package/dist/simulation/domains/loader.js +25 -3
- package/dist/simulation/living/cold.d.ts +23 -0
- package/dist/simulation/living/cold.js +41 -0
- package/dist/simulation/living/context.d.ts +591 -1283
- package/dist/simulation/living/context.js +378 -244
- package/dist/simulation/living/contradictions.d.ts +14 -0
- package/dist/simulation/living/contradictions.js +282 -0
- package/dist/simulation/living/core/ids.d.ts +53 -0
- package/dist/simulation/living/core/ids.js +39 -0
- package/dist/simulation/living/core/kind.d.ts +20 -0
- package/dist/simulation/living/core/kind.js +15 -0
- package/dist/simulation/living/core/laws.d.ts +179 -0
- package/dist/simulation/living/core/laws.js +184 -0
- package/dist/simulation/living/core/ops.d.ts +257 -0
- package/dist/simulation/living/core/ops.js +34 -0
- package/dist/simulation/living/definer.d.ts +17 -1
- package/dist/simulation/living/definer.js +130 -51
- package/dist/simulation/living/definition.d.ts +174 -65
- package/dist/simulation/living/definition.js +287 -180
- package/dist/simulation/living/director.d.ts +80 -0
- package/dist/simulation/living/director.js +363 -0
- package/dist/simulation/living/frame.d.ts +108 -21
- package/dist/simulation/living/frame.js +111 -66
- package/dist/simulation/living/identifiers.d.ts +0 -1
- package/dist/simulation/living/identifiers.js +0 -3
- package/dist/simulation/living/index.d.ts +18 -9
- package/dist/simulation/living/index.js +18 -9
- package/dist/simulation/living/inference.d.ts +92 -50
- package/dist/simulation/living/inference.js +319 -175
- package/dist/simulation/living/knowledge.d.ts +28 -0
- package/dist/simulation/living/knowledge.js +73 -0
- package/dist/simulation/living/library.json +1177 -0
- package/dist/simulation/living/mechanics.d.ts +31 -34
- package/dist/simulation/living/mechanics.js +222 -138
- package/dist/simulation/living/model-input.d.ts +6 -3
- package/dist/simulation/living/model-input.js +18 -26
- package/dist/simulation/living/open-world.d.ts +74 -94
- package/dist/simulation/living/open-world.js +151 -30
- package/dist/simulation/living/phrases.d.ts +3 -0
- package/dist/simulation/living/phrases.js +37 -0
- package/dist/simulation/living/phrases.json +560 -0
- package/dist/simulation/living/projection.d.ts +316 -2
- package/dist/simulation/living/projection.js +50 -2
- package/dist/simulation/living/prompts/example-spec.json +11 -0
- package/dist/simulation/living/prompts/role-text.json +14 -0
- package/dist/simulation/living/prompts.d.ts +5 -0
- package/dist/simulation/living/prompts.js +275 -0
- package/dist/simulation/living/recall.d.ts +2 -2
- package/dist/simulation/living/reduce.d.ts +51 -14
- package/dist/simulation/living/reduce.js +941 -579
- package/dist/simulation/living/replay.d.ts +5 -4
- package/dist/simulation/living/replay.js +10 -9
- package/dist/simulation/living/runtime.d.ts +135 -25
- package/dist/simulation/living/runtime.js +1641 -583
- package/dist/simulation/living/scale.d.ts +96 -0
- package/dist/simulation/living/scale.js +124 -0
- package/dist/simulation/living/script.d.ts +5 -0
- package/dist/simulation/living/script.js +115 -0
- package/dist/simulation/living/shared-kinds.d.ts +4 -11
- package/dist/simulation/living/shared-kinds.js +11 -81
- package/dist/simulation/living/space.d.ts +14 -0
- package/dist/simulation/living/space.js +132 -0
- package/dist/simulation/living/state.d.ts +100 -0
- package/dist/simulation/living/state.js +393 -0
- package/dist/simulation/living/types.d.ts +829 -512
- package/dist/simulation/living/types.js +162 -187
- package/dist/simulation/living/world-rules.d.ts +100 -0
- package/dist/simulation/living/world-rules.js +267 -0
- package/dist/simulation/plugins/loader.js +11 -0
- package/dist/skills/loader.js +4 -0
- package/dist/tools.d.ts +1 -0
- package/dist/tools.js +1 -0
- package/dist/ui/ratatui/headless_pane_manager.d.ts +4 -1
- package/dist/ui/ratatui/headless_pane_manager.js +13 -9
- package/dist/ui/ratatui/pane_relay.js +29 -0
- package/dist/ui/ratatui/pane_type.d.ts +10 -0
- package/dist/ui/ratatui/pane_type.js +11 -0
- package/dist/ui/ratatui/process.d.ts +30 -0
- package/dist/ui/ratatui/process.js +133 -19
- package/dist/ui/ratatui/protocol.d.ts +124 -2
- package/dist/ui/ratatui/protocol.js +35 -0
- package/dist/ui/ratatui/relay_policy.js +3 -0
- package/dist/ui/ratatui/ztc_launch_trust.d.ts +2 -1
- package/dist/ui/ratatui/ztc_launch_trust.js +8 -1
- package/dist/ui/terminal_image.d.ts +12 -0
- package/dist/ui/terminal_image.js +21 -1
- package/dist/utils/codex_project_trust.d.ts +19 -0
- package/dist/utils/codex_project_trust.js +37 -0
- package/dist/utils/compaction.js +103 -20
- package/dist/utils/git_program_files.d.ts +19 -12
- package/dist/utils/git_program_files.js +411 -83
- package/dist/utils/host_shell.d.ts +10 -1
- package/dist/utils/host_shell.js +14 -1
- package/dist/utils/mid_turn_compaction.d.ts +2 -0
- package/dist/utils/mid_turn_compaction.js +2 -0
- package/dist/utils/models.js +6 -1
- package/dist/utils/sandbox.d.ts +109 -8
- package/dist/utils/sandbox.js +981 -187
- package/dist/utils/shell.d.ts +2 -0
- package/dist/utils/shell.js +10 -4
- package/dist/utils/subprocess_env.d.ts +47 -11
- package/dist/utils/subprocess_env.js +107 -15
- package/dist/utils/system_ps.d.ts +8 -0
- package/dist/utils/system_ps.js +39 -7
- package/dist/utils/unattended_compaction.d.ts +9 -0
- package/dist/utils/unattended_compaction.js +13 -0
- package/dist/utils/ztc_own_state.d.ts +8 -5
- package/dist/utils/ztc_own_state.js +17 -11
- package/dist/web/mirror_client.js +1 -0
- package/dist/web/mirror_stream.d.ts +50 -6
- package/dist/web/mirror_stream.js +160 -15
- package/dist/workflows/registry.js +3 -1
- package/dist/workspace/controller.js +12 -0
- package/dist/workspace_collision.d.ts +3 -0
- package/dist/workspace_collision.js +14 -1
- package/dist/workspace_session_context.js +2 -1
- package/dist/zlm-embed.mjs +3823 -1970
- package/node_modules/@zerg/model-contracts/README.md +16 -4
- package/node_modules/@zerg/model-contracts/index.js +6 -1
- package/npm-shrinkwrap.json +1 -1
- package/package.json +42 -24
- package/packages/model-contracts/README.md +16 -4
- package/packages/model-contracts/index.js +6 -1
|
@@ -1,50 +1,94 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { kindDefinitionSchema, valueMatchesType } from './open-world.js';
|
|
2
|
+
import { kindFirst, livingAnswerTokens, LIVING_INFERENCE_LIMITS } from './inference.js';
|
|
3
|
+
import { kindDefinitionSchema, lawProblems, valueMatchesType } from './open-world.js';
|
|
5
4
|
import { assertLivingModelCall, LIVING_INPUT_BUDGETS } from './model-input.js';
|
|
5
|
+
import { systemFor } from './prompts.js';
|
|
6
6
|
import { LivingWorldError } from './types.js';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
7
|
+
import { lawSchema } from './core/laws.js';
|
|
8
|
+
import { parseKindRevision } from './definition.js';
|
|
9
|
+
function withSettings(arm, key) {
|
|
10
|
+
const properties = arm.properties ?? {};
|
|
11
|
+
const { [key]: discriminator, ...fields } = properties;
|
|
12
|
+
return { type: 'object', additionalProperties: false, required: [key, 'settings'], properties: { [key]: discriminator,
|
|
13
|
+
settings: { type: 'object', additionalProperties: false, required: (arm.required ?? []).filter(name => name !== key),
|
|
14
|
+
properties: Object.fromEntries(Object.entries(fields).map(([name, child]) => [name, shapeFirst(child)])) } } };
|
|
15
|
+
}
|
|
16
|
+
function shapeFirst(node) {
|
|
17
|
+
const arms = node.anyOf ?? node.oneOf;
|
|
18
|
+
if (arms !== undefined) {
|
|
19
|
+
const key = arms.every(arm => arm.properties?.kind?.const !== undefined) ? 'kind'
|
|
20
|
+
: arms.every(arm => arm.properties?.op?.const !== undefined) ? 'op' : null;
|
|
21
|
+
if (key !== null)
|
|
22
|
+
return { anyOf: arms.map(arm => withSettings(arm, key)) };
|
|
23
|
+
const firsts = arms.map(arm => Object.keys(arm.properties ?? {})[0]);
|
|
24
|
+
if (firsts.every(name => name !== undefined) && new Set(firsts).size === arms.length) {
|
|
25
|
+
return { anyOf: arms.map((arm, index) => {
|
|
26
|
+
const name = firsts[index];
|
|
27
|
+
const { [name]: value, ...others } = arm.properties;
|
|
28
|
+
return { type: 'object', additionalProperties: false, required: ['kind', 'settings'], properties: { kind: { const: name },
|
|
29
|
+
settings: { type: 'object', additionalProperties: false, required: [name, ...(arm.required ?? []).filter(field => field !== name)],
|
|
30
|
+
properties: { [name]: shapeFirst(value), ...others } } } };
|
|
31
|
+
}) };
|
|
32
|
+
}
|
|
33
|
+
return { ...node, anyOf: arms.map(shapeFirst) };
|
|
34
|
+
}
|
|
35
|
+
if (node.properties !== undefined)
|
|
36
|
+
return { ...node, properties: Object.fromEntries(Object.entries(node.properties).map(([name, child]) => [name, shapeFirst(child)])) };
|
|
37
|
+
if (node.items !== undefined)
|
|
38
|
+
return { ...node, items: shapeFirst(node.items) };
|
|
39
|
+
return node;
|
|
40
|
+
}
|
|
41
|
+
function capIntent(node) {
|
|
42
|
+
if (node.properties?.intent?.type === 'string')
|
|
43
|
+
node.properties.intent.maxLength = 600;
|
|
44
|
+
for (const child of Object.values(node.properties ?? {}))
|
|
45
|
+
capIntent(child);
|
|
46
|
+
for (const arm of node.anyOf ?? [])
|
|
47
|
+
capIntent(arm);
|
|
48
|
+
if (node.items !== undefined)
|
|
49
|
+
capIntent(node.items);
|
|
50
|
+
}
|
|
17
51
|
function modelKindSchema() {
|
|
18
52
|
const schema = structuredClone(z.toJSONSchema(kindDefinitionSchema));
|
|
19
|
-
const { mechanics, ...slots } = schema.properties;
|
|
53
|
+
const { mechanics, laws, library, neverHeld, ...slots } = schema.properties;
|
|
20
54
|
const items = mechanics.items;
|
|
21
|
-
const shapes = (items.anyOf ?? items.oneOf ?? []).map(shape => kindFirst('settings')({ required: shape.required,
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
55
|
+
const shapes = (items.anyOf ?? items.oneOf ?? []).map(shape => kindFirst('settings')({ required: shape.required, properties: shape.properties }));
|
|
56
|
+
const lawsSchema = shapeFirst(z.toJSONSchema(lawSchema));
|
|
57
|
+
capIntent(lawsSchema);
|
|
58
|
+
const lawShapes = lawsSchema.anyOf ?? [];
|
|
59
|
+
return { ...schema, properties: { ...slots, z: { type: 'array', description: mechanics.description, items: { anyOf: [...shapes, ...lawShapes] } } },
|
|
60
|
+
required: [...schema.required.filter(name => name !== 'mechanics'), 'z'] };
|
|
25
61
|
}
|
|
26
62
|
function fromModelKind(answer) {
|
|
27
63
|
if (answer === null || typeof answer !== 'object' || Array.isArray(answer))
|
|
28
64
|
return answer;
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
65
|
+
const unwrapped = unwrapModel(answer);
|
|
66
|
+
const { rules, z, l, ...rest } = unwrapped;
|
|
67
|
+
const items = Array.isArray(z) ? z : Array.isArray(rules) ? rules : [];
|
|
68
|
+
const isLaw = (item) => item !== null && typeof item === 'object' && ['react', 'forbid'].includes(String(item.kind));
|
|
69
|
+
const mechanics = items.filter(item => !isLaw(item));
|
|
70
|
+
const laws = [...items.filter(isLaw), ...(Array.isArray(l) ? l : [])];
|
|
71
|
+
return { ...rest, mechanics, ...(laws.length === 0 ? {} : { laws }) };
|
|
72
|
+
}
|
|
73
|
+
function unwrapModel(value) {
|
|
74
|
+
if (Array.isArray(value))
|
|
75
|
+
return value.map(unwrapModel);
|
|
76
|
+
if (value === null || typeof value !== 'object')
|
|
77
|
+
return value;
|
|
78
|
+
const record = value;
|
|
79
|
+
const settings = record.settings;
|
|
80
|
+
if (settings !== null && typeof settings === 'object' && !Array.isArray(settings)) {
|
|
81
|
+
const fields = settings;
|
|
82
|
+
if (typeof record.kind === 'string' && ['changed', 'added', 'created', 'every', 'attempted'].includes(record.kind) && 'slot' in fields) {
|
|
83
|
+
const { slot, ...others } = fields;
|
|
84
|
+
return { [record.kind]: slot, ...others };
|
|
85
|
+
}
|
|
86
|
+
const { settings: _settings, ...rest } = record;
|
|
87
|
+
return unwrapModel({ ...fields, ...rest });
|
|
88
|
+
}
|
|
89
|
+
return Object.fromEntries(Object.entries(record).map(([name, child]) => [name, unwrapModel(child)]));
|
|
38
90
|
}
|
|
39
91
|
export const kindDefinitionResponseSchema = modelKindSchema();
|
|
40
|
-
export const DEFINER_SYSTEM = `Role:
|
|
41
|
-
You define one reusable kind for a living world. Include only properties, relations, and automatic mechanics needed for its general meaning.
|
|
42
|
-
Principles:
|
|
43
|
-
${WORLD_PRINCIPLES}
|
|
44
|
-
Fields:
|
|
45
|
-
${responseFieldLines(kindDefinitionResponseSchema)}
|
|
46
|
-
Example:
|
|
47
|
-
{"id":"new-kind","meaning":"A general thing.","name":"New kind","properties":[],"relations":[],"rules":[]}`;
|
|
48
92
|
function responseSchemaFor(request, existing) {
|
|
49
93
|
const schema = structuredClone(kindDefinitionResponseSchema);
|
|
50
94
|
const properties = schema.properties;
|
|
@@ -102,11 +146,13 @@ export async function defineLivingKind(options) {
|
|
|
102
146
|
errors.push(last.slice(0, end));
|
|
103
147
|
}
|
|
104
148
|
}
|
|
149
|
+
const responseSchema = responseSchemaFor(options.request, selected);
|
|
150
|
+
const built = input();
|
|
105
151
|
const call = { reserveRetry,
|
|
106
|
-
role: 'definer', phase: 'define', system:
|
|
107
|
-
input:
|
|
108
|
-
responseSchema
|
|
109
|
-
maxTokens: 700, timeoutMs: 45_000, ...(options.stillWanted ? { stillWanted: options.stillWanted } : {}),
|
|
152
|
+
role: 'definer', phase: 'define', system: systemFor('definer', responseSchema, built, kindDefinitionResponseSchema),
|
|
153
|
+
input: built,
|
|
154
|
+
responseSchema,
|
|
155
|
+
maxTokens: Math.max(700, livingAnswerTokens(responseSchema)), timeoutMs: 45_000, ...(options.stillWanted ? { stillWanted: options.stillWanted } : {}),
|
|
110
156
|
};
|
|
111
157
|
assertLivingModelCall(call);
|
|
112
158
|
const answer = await options.inference.complete(call);
|
|
@@ -143,12 +189,8 @@ function ruleProblems(mechanic, definition) {
|
|
|
143
189
|
problems.push(`${mechanic.kind} rule names unknown property ${on}`);
|
|
144
190
|
if ('relationId' in mechanic && mechanic.relationId !== null && !relations.has(mechanic.relationId))
|
|
145
191
|
problems.push(`${mechanic.kind} rule names unknown relation ${mechanic.relationId}`);
|
|
146
|
-
if (mechanic.kind === 'authority' && (mechanic.propertyId === null) === (mechanic.relationId === null))
|
|
147
|
-
problems.push(`authority rule for ${mechanic.roleId} needs exactly one of propertyId or relationId`);
|
|
148
192
|
if (mechanic.kind === 'spread' && onType !== undefined && onType !== 'level')
|
|
149
193
|
problems.push(`spread rule on ${on}: it must be a level property, not ${onType}`);
|
|
150
|
-
if (mechanic.kind === 'trigger' && onType !== undefined && onType !== 'number')
|
|
151
|
-
problems.push(`trigger rule on ${on}: it must be a number property, not ${onType}`);
|
|
152
194
|
if (mechanic.kind === 'change' && !mechanic.onEvent && onType !== undefined && onType !== 'number')
|
|
153
195
|
problems.push(`change rule on ${on}: it must be a number property, not ${onType}`);
|
|
154
196
|
if (mechanic.kind === 'change' && mechanic.onEvent) {
|
|
@@ -160,13 +202,6 @@ function ruleProblems(mechanic, definition) {
|
|
|
160
202
|
if (typeOf(subject) !== 'id')
|
|
161
203
|
problems.push(`change rule on ${on}: onEvent.subjectPropertyId ${subject} is ${typeOf(subject) === undefined ? 'not a property' : `a ${typeOf(subject)} property`}; it must name an id property`);
|
|
162
204
|
}
|
|
163
|
-
if (mechanic.kind === 'gate') {
|
|
164
|
-
const subject = mechanic.subjectPropertyId;
|
|
165
|
-
if (typeOf(subject) !== 'id')
|
|
166
|
-
problems.push(`gate rule on ${on}: subjectPropertyId ${subject} is ${typeOf(subject) === undefined ? 'not a property' : `a ${typeOf(subject)} property`}; it must name an id property`);
|
|
167
|
-
if (mechanic.atLeast !== undefined && onType !== undefined && onType !== 'level')
|
|
168
|
-
problems.push(`gate rule on ${on}: atLeast needs a level property, not ${onType}`);
|
|
169
|
-
}
|
|
170
205
|
return problems;
|
|
171
206
|
}
|
|
172
207
|
// What is wrong with a proposed kind, each problem naming the slot or rule at fault.
|
|
@@ -192,6 +227,8 @@ function definitionProblems(answer, request, existing) {
|
|
|
192
227
|
problem(`Relation ${id} appears twice`);
|
|
193
228
|
if (new Set(definition.mechanics.map(mechanic => JSON.stringify(mechanic))).size !== definition.mechanics.length)
|
|
194
229
|
problem('A kind repeats a mechanic');
|
|
230
|
+
if (new Set((definition.laws ?? []).map(law => JSON.stringify(law))).size !== (definition.laws ?? []).length)
|
|
231
|
+
problem('A kind repeats a law');
|
|
195
232
|
for (const relation of definition.relations) {
|
|
196
233
|
if (propertyIds.includes(relation.id))
|
|
197
234
|
problem(`Slot ${relation.id} is both a property and a relation; give the relation another id or drop it`);
|
|
@@ -202,6 +239,9 @@ function definitionProblems(answer, request, existing) {
|
|
|
202
239
|
for (const mechanic of definition.mechanics)
|
|
203
240
|
for (const message of ruleProblems(mechanic, definition))
|
|
204
241
|
problem(message);
|
|
242
|
+
for (const law of definition.laws ?? [])
|
|
243
|
+
for (const message of lawProblems(law, definition))
|
|
244
|
+
problem(message);
|
|
205
245
|
return problems;
|
|
206
246
|
}
|
|
207
247
|
// The part of a proposed kind that holds: every slot that is sound and every rule that fits its
|
|
@@ -218,6 +258,45 @@ function soundPart(answer, request, existing) {
|
|
|
218
258
|
const slots = { ...definition, properties, relations };
|
|
219
259
|
const mechanics = definition.mechanics.filter((mechanic, index, all) => all.findIndex(other => JSON.stringify(other) === JSON.stringify(mechanic)) === index
|
|
220
260
|
&& ruleProblems(mechanic, slots).length === 0);
|
|
221
|
-
const
|
|
261
|
+
const laws = (definition.laws ?? []).filter((law, index, all) => all.findIndex(other => JSON.stringify(other) === JSON.stringify(law)) === index
|
|
262
|
+
&& lawProblems(law, slots).length === 0);
|
|
263
|
+
const kept = { ...slots, mechanics, ...(definition.laws === undefined ? {} : { laws }) };
|
|
222
264
|
return definitionProblems(kept, request, existing).length === 0 ? kept : null;
|
|
223
265
|
}
|
|
266
|
+
export const REVISION_CALLS = 2;
|
|
267
|
+
export async function reviseLivingKind(options) {
|
|
268
|
+
const existing = definitionContext(options.library.filter(kind => kind.id !== options.kind.id));
|
|
269
|
+
let previousErrors = [];
|
|
270
|
+
let spent = 0;
|
|
271
|
+
const reserveRetry = () => {
|
|
272
|
+
if (spent >= REVISION_CALLS)
|
|
273
|
+
return false;
|
|
274
|
+
spent += 1;
|
|
275
|
+
return true;
|
|
276
|
+
};
|
|
277
|
+
for (let attempt = 0; attempt < REVISION_CALLS && reserveRetry(); attempt += 1) {
|
|
278
|
+
const input = () => ({ kind: options.kind, facets: options.facets.slice(0, 8), requests: (options.requests ?? []).slice(0, 4),
|
|
279
|
+
existing: existing.map(kind => ({ id: kind.id, meaning: kind.meaning })),
|
|
280
|
+
...(previousErrors.length ? { previousErrors } : {}) });
|
|
281
|
+
const responseSchema = kindDefinitionResponseSchema;
|
|
282
|
+
const built = input();
|
|
283
|
+
const call = { reserveRetry, role: 'definer', phase: 'revise',
|
|
284
|
+
system: systemFor('definer', responseSchema, built, kindDefinitionResponseSchema),
|
|
285
|
+
input: built, responseSchema, ...LIVING_INFERENCE_LIMITS.revise,
|
|
286
|
+
maxTokens: Math.max(LIVING_INFERENCE_LIMITS.revise.maxTokens, livingAnswerTokens(responseSchema)),
|
|
287
|
+
...(options.stillWanted ? { stillWanted: options.stillWanted } : {}) };
|
|
288
|
+
assertLivingModelCall(call);
|
|
289
|
+
const answer = await options.inference.complete(call);
|
|
290
|
+
try {
|
|
291
|
+
return parseKindRevision(options.kind, fromModelKind(answer));
|
|
292
|
+
}
|
|
293
|
+
catch (error) {
|
|
294
|
+
if (!(error instanceof LivingWorldError))
|
|
295
|
+
throw error;
|
|
296
|
+
if (spent >= REVISION_CALLS)
|
|
297
|
+
throw error;
|
|
298
|
+
previousErrors = [error.message.slice(0, DEFINER_ERROR_BUDGET)];
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
throw new LivingWorldError('inference-invalid', 'The steward could not revise the kind');
|
|
302
|
+
}
|
|
@@ -1,11 +1,76 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { type
|
|
2
|
+
import { type LivingStateRaw } from './types.js';
|
|
3
|
+
import { type LivingKindDefinition } from './open-world.js';
|
|
4
|
+
import { type LivingCalendar } from './scale.js';
|
|
5
|
+
import type { CellTable, EntityId, KindId, Minutes, PersonId, PlaceId, PropertyId, RelationId } from './core/ids.js';
|
|
3
6
|
export declare const definitionSchema: z.ZodObject<{
|
|
4
7
|
kind: z.ZodString;
|
|
8
|
+
look: z.ZodOptional<z.ZodObject<{
|
|
9
|
+
map: z.ZodOptional<z.ZodObject<{
|
|
10
|
+
name: z.ZodString;
|
|
11
|
+
terrain: z.ZodString;
|
|
12
|
+
palette: z.ZodObject<{
|
|
13
|
+
ground: z.ZodString;
|
|
14
|
+
path: z.ZodString;
|
|
15
|
+
wall: z.ZodString;
|
|
16
|
+
floor: z.ZodString;
|
|
17
|
+
ink: z.ZodString;
|
|
18
|
+
accent: z.ZodString;
|
|
19
|
+
}, z.core.$strip>;
|
|
20
|
+
paths: z.ZodArray<z.ZodString>;
|
|
21
|
+
locations: z.ZodArray<z.ZodObject<{
|
|
22
|
+
id: z.ZodString;
|
|
23
|
+
name: z.ZodString;
|
|
24
|
+
x: z.ZodNumber;
|
|
25
|
+
y: z.ZodNumber;
|
|
26
|
+
w: z.ZodNumber;
|
|
27
|
+
h: z.ZodNumber;
|
|
28
|
+
station: z.ZodObject<{
|
|
29
|
+
x: z.ZodNumber;
|
|
30
|
+
y: z.ZodNumber;
|
|
31
|
+
}, z.core.$strip>;
|
|
32
|
+
props: z.ZodArray<z.ZodObject<{
|
|
33
|
+
kind: z.ZodString;
|
|
34
|
+
x: z.ZodNumber;
|
|
35
|
+
y: z.ZodNumber;
|
|
36
|
+
rotate: z.ZodOptional<z.ZodNumber>;
|
|
37
|
+
scale: z.ZodOptional<z.ZodNumber>;
|
|
38
|
+
}, z.core.$strip>>;
|
|
39
|
+
}, z.core.$strip>>;
|
|
40
|
+
trees: z.ZodArray<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
|
|
41
|
+
}, z.core.$strip>>;
|
|
42
|
+
art: z.ZodOptional<z.ZodString>;
|
|
43
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
44
|
+
catalog: z.ZodOptional<z.ZodObject<{
|
|
45
|
+
shortTitle: z.ZodString;
|
|
46
|
+
eyebrow: z.ZodString;
|
|
47
|
+
fantasy: z.ZodString;
|
|
48
|
+
primaryVerb: z.ZodString;
|
|
49
|
+
verbs: z.ZodTuple<[z.ZodString, z.ZodString, z.ZodString], null>;
|
|
50
|
+
palette: z.ZodTuple<[z.ZodString, z.ZodString, z.ZodString], null>;
|
|
51
|
+
texture: z.ZodString;
|
|
52
|
+
}, z.core.$strip>>;
|
|
53
|
+
}, z.core.$strip>>;
|
|
5
54
|
title: z.ZodString;
|
|
6
55
|
tagline: z.ZodString;
|
|
7
56
|
setting: z.ZodString;
|
|
8
57
|
startClock: z.ZodNumber;
|
|
58
|
+
calendar: z.ZodDefault<z.ZodObject<{
|
|
59
|
+
beat: z.ZodNumber;
|
|
60
|
+
day: z.ZodNumber;
|
|
61
|
+
hours: z.ZodDefault<z.ZodNumber>;
|
|
62
|
+
minutes: z.ZodDefault<z.ZodNumber>;
|
|
63
|
+
rest: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
64
|
+
from: z.ZodNumber;
|
|
65
|
+
until: z.ZodNumber;
|
|
66
|
+
span: z.ZodOptional<z.ZodNumber>;
|
|
67
|
+
action: z.ZodString;
|
|
68
|
+
why: z.ZodString;
|
|
69
|
+
}, z.core.$strip>>>;
|
|
70
|
+
}, z.core.$strip>>;
|
|
71
|
+
travel: z.ZodDefault<z.ZodObject<{
|
|
72
|
+
steps: z.ZodNumber;
|
|
73
|
+
}, z.core.$strip>>;
|
|
9
74
|
clock: z.ZodOptional<z.ZodObject<{
|
|
10
75
|
rate: z.ZodNumber;
|
|
11
76
|
}, z.core.$strip>>;
|
|
@@ -13,29 +78,33 @@ export declare const definitionSchema: z.ZodObject<{
|
|
|
13
78
|
minutes: z.ZodNumber;
|
|
14
79
|
how: z.ZodString;
|
|
15
80
|
}, z.core.$strip>>;
|
|
16
|
-
|
|
17
|
-
symbol: z.ZodString;
|
|
18
|
-
name: z.ZodString;
|
|
19
|
-
}, z.core.$strip>>;
|
|
20
|
-
accounts: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
81
|
+
units: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
21
82
|
id: z.ZodString;
|
|
22
83
|
name: z.ZodString;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
84
|
+
symbol: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
85
|
+
}, z.core.$strip>>>;
|
|
86
|
+
numbers: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
87
|
+
id: z.ZodString;
|
|
88
|
+
unit: z.ZodString;
|
|
89
|
+
min: z.ZodDefault<z.ZodNullable<z.ZodNumber>>;
|
|
90
|
+
max: z.ZodDefault<z.ZodNullable<z.ZodNumber>>;
|
|
91
|
+
}, z.core.$strip>>>;
|
|
92
|
+
channels: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
93
|
+
id: z.ZodString;
|
|
94
|
+
notice: z.ZodString;
|
|
95
|
+
reach: z.ZodNumber;
|
|
96
|
+
namesKind: z.ZodOptional<z.ZodBoolean>;
|
|
97
|
+
heard: z.ZodOptional<z.ZodBoolean>;
|
|
26
98
|
}, z.core.$strip>>>;
|
|
27
99
|
places: z.ZodArray<z.ZodObject<{
|
|
28
100
|
id: z.ZodString;
|
|
29
101
|
name: z.ZodString;
|
|
30
|
-
kind: z.ZodEnum<{
|
|
31
|
-
private: "private";
|
|
32
|
-
transit: "transit";
|
|
33
|
-
room: "room";
|
|
34
|
-
outdoors: "outdoors";
|
|
35
|
-
}>;
|
|
36
102
|
summary: z.ZodString;
|
|
103
|
+
containerId: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
37
104
|
connections: z.ZodArray<z.ZodString>;
|
|
105
|
+
edgeCosts: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
|
|
38
106
|
conditions: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
107
|
+
numbers: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodNumber>>;
|
|
39
108
|
}, z.core.$strip>>;
|
|
40
109
|
player: z.ZodObject<{
|
|
41
110
|
id: z.ZodString;
|
|
@@ -45,7 +114,7 @@ export declare const definitionSchema: z.ZodObject<{
|
|
|
45
114
|
summary: z.ZodString;
|
|
46
115
|
pronouns: z.ZodOptional<z.ZodString>;
|
|
47
116
|
placeId: z.ZodString;
|
|
48
|
-
|
|
117
|
+
numbers: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodNumber>>;
|
|
49
118
|
}, z.core.$strip>;
|
|
50
119
|
cast: z.ZodArray<z.ZodObject<{
|
|
51
120
|
id: z.ZodString;
|
|
@@ -59,10 +128,13 @@ export declare const definitionSchema: z.ZodObject<{
|
|
|
59
128
|
values: z.ZodArray<z.ZodString>;
|
|
60
129
|
redLines: z.ZodArray<z.ZodString>;
|
|
61
130
|
privateConcerns: z.ZodArray<z.ZodString>;
|
|
131
|
+
wants: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
132
|
+
fears: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
62
133
|
}, z.core.$strip>>;
|
|
63
134
|
pronouns: z.ZodOptional<z.ZodString>;
|
|
64
135
|
placeId: z.ZodString;
|
|
65
|
-
|
|
136
|
+
knownPlaceIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
137
|
+
numbers: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodNumber>>;
|
|
66
138
|
mood: z.ZodString;
|
|
67
139
|
goals: z.ZodArray<z.ZodString>;
|
|
68
140
|
beliefs: z.ZodArray<z.ZodObject<{
|
|
@@ -87,8 +159,7 @@ export declare const definitionSchema: z.ZodObject<{
|
|
|
87
159
|
id: z.ZodString;
|
|
88
160
|
name: z.ZodString;
|
|
89
161
|
summary: z.ZodString;
|
|
90
|
-
|
|
91
|
-
holderId: z.ZodNullable<z.ZodString>;
|
|
162
|
+
containerId: z.ZodNullable<z.ZodString>;
|
|
92
163
|
ownerId: z.ZodNullable<z.ZodString>;
|
|
93
164
|
condition: z.ZodString;
|
|
94
165
|
singlePersonMovable: z.ZodDefault<z.ZodBoolean>;
|
|
@@ -108,8 +179,13 @@ export declare const definitionSchema: z.ZodObject<{
|
|
|
108
179
|
flag: "flag";
|
|
109
180
|
level: "level";
|
|
110
181
|
time: "time";
|
|
182
|
+
series: "series";
|
|
111
183
|
}>;
|
|
184
|
+
options: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
185
|
+
perActor: z.ZodOptional<z.ZodBoolean>;
|
|
186
|
+
sealedBy: z.ZodOptional<z.ZodString>;
|
|
112
187
|
requiredOnCreate: z.ZodOptional<z.ZodBoolean>;
|
|
188
|
+
target: z.ZodOptional<z.ZodLiteral<"tension">>;
|
|
113
189
|
}, z.core.$strip>>;
|
|
114
190
|
relations: z.ZodArray<z.ZodObject<{
|
|
115
191
|
id: z.ZodString;
|
|
@@ -136,63 +212,38 @@ export declare const definitionSchema: z.ZodObject<{
|
|
|
136
212
|
low: "low";
|
|
137
213
|
medium: "medium";
|
|
138
214
|
high: "high";
|
|
139
|
-
}>, z.ZodString
|
|
215
|
+
}>, z.ZodString, z.ZodArray<z.ZodObject<{
|
|
216
|
+
option: z.ZodString;
|
|
217
|
+
personId: z.ZodString;
|
|
218
|
+
at: z.ZodNumber;
|
|
219
|
+
seq: z.ZodNumber;
|
|
220
|
+
}, z.core.$strip>>]>;
|
|
140
221
|
}, z.core.$strip>>;
|
|
141
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
142
|
-
kind: z.ZodLiteral<"trigger">;
|
|
143
|
-
propertyId: z.ZodString;
|
|
144
|
-
threshold: z.ZodNumber;
|
|
145
|
-
direction: z.ZodEnum<{
|
|
146
|
-
"at-least": "at-least";
|
|
147
|
-
"at-most": "at-most";
|
|
148
|
-
}>;
|
|
149
|
-
intent: z.ZodString;
|
|
150
|
-
delayMinutes: z.ZodNumber;
|
|
151
|
-
minImportance: z.ZodOptional<z.ZodNumber>;
|
|
152
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
153
|
-
kind: z.ZodLiteral<"gate">;
|
|
154
|
-
propertyId: z.ZodString;
|
|
155
|
-
subjectPropertyId: z.ZodString;
|
|
156
|
-
atLeast: z.ZodOptional<z.ZodEnum<{
|
|
157
|
-
none: "none";
|
|
158
|
-
low: "low";
|
|
159
|
-
medium: "medium";
|
|
160
|
-
high: "high";
|
|
161
|
-
}>>;
|
|
162
|
-
blockedActionKinds: z.ZodArray<z.ZodString>;
|
|
163
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
164
|
-
kind: z.ZodLiteral<"norm">;
|
|
165
|
-
actionKind: z.ZodString;
|
|
166
|
-
roleId: z.ZodNullable<z.ZodString>;
|
|
167
|
-
forbidden: z.ZodBoolean;
|
|
168
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
169
|
-
kind: z.ZodLiteral<"authority">;
|
|
170
|
-
roleId: z.ZodString;
|
|
171
|
-
relationId: z.ZodNullable<z.ZodString>;
|
|
172
|
-
propertyId: z.ZodNullable<z.ZodString>;
|
|
173
222
|
}, z.core.$strip>], "kind">>;
|
|
223
|
+
laws: z.ZodOptional<z.ZodArray<z.ZodType<import("./core/laws.js").Law, unknown, z.core.$ZodTypeInternals<import("./core/laws.js").Law, unknown>>>>;
|
|
224
|
+
library: z.ZodOptional<z.ZodBoolean>;
|
|
225
|
+
neverHeld: z.ZodOptional<z.ZodBoolean>;
|
|
174
226
|
}, z.core.$strip>>>;
|
|
175
227
|
entities: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
176
228
|
id: z.ZodString;
|
|
177
229
|
kindId: z.ZodString;
|
|
178
230
|
name: z.ZodString;
|
|
179
|
-
|
|
231
|
+
containerId: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
180
232
|
properties: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodBoolean, z.ZodNumber, z.ZodEnum<{
|
|
181
233
|
none: "none";
|
|
182
234
|
low: "low";
|
|
183
235
|
medium: "medium";
|
|
184
236
|
high: "high";
|
|
185
|
-
}>, z.ZodString
|
|
237
|
+
}>, z.ZodString, z.ZodArray<z.ZodObject<{
|
|
238
|
+
option: z.ZodString;
|
|
239
|
+
personId: z.ZodString;
|
|
240
|
+
at: z.ZodNumber;
|
|
241
|
+
seq: z.ZodNumber;
|
|
242
|
+
}, z.core.$strip>>]>>>;
|
|
186
243
|
relations: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
187
|
-
|
|
188
|
-
settles: z.ZodOptional<z.ZodString>;
|
|
244
|
+
numbers: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodNumber>>;
|
|
189
245
|
knownTo: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
190
246
|
hidden: z.ZodOptional<z.ZodBoolean>;
|
|
191
|
-
transfers: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
192
|
-
fromId: z.ZodNullable<z.ZodString>;
|
|
193
|
-
toId: z.ZodNullable<z.ZodString>;
|
|
194
|
-
amount: z.ZodNumber;
|
|
195
|
-
}, z.core.$strip>>>;
|
|
196
247
|
}, z.core.$strip>>>;
|
|
197
248
|
facts: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
198
249
|
aspect: z.ZodString;
|
|
@@ -231,7 +282,8 @@ export declare const definitionSchema: z.ZodObject<{
|
|
|
231
282
|
settled: "settled";
|
|
232
283
|
}>>;
|
|
233
284
|
}, z.core.$strip>>;
|
|
234
|
-
|
|
285
|
+
shifts: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
286
|
+
slot: z.ZodString;
|
|
235
287
|
fromId: z.ZodNullable<z.ZodString>;
|
|
236
288
|
toId: z.ZodNullable<z.ZodString>;
|
|
237
289
|
amount: z.ZodNumber;
|
|
@@ -251,7 +303,64 @@ export declare const definitionSchema: z.ZodObject<{
|
|
|
251
303
|
concerns: z.ZodOptional<z.ZodString>;
|
|
252
304
|
}, z.core.$strip>>>;
|
|
253
305
|
}, z.core.$strip>;
|
|
254
|
-
export
|
|
306
|
+
export declare function definitionJsonSchema(): Record<string, unknown>;
|
|
307
|
+
export type LivingWorldDefinitionRaw = z.infer<typeof definitionSchema>;
|
|
255
308
|
export type LivingWorldDefinitionInput = z.input<typeof definitionSchema>;
|
|
256
|
-
|
|
257
|
-
|
|
309
|
+
type RawDefinition = LivingWorldDefinitionRaw;
|
|
310
|
+
type RawDefinitionKind = RawDefinition['kinds'][number];
|
|
311
|
+
type RawDefinitionEntity = RawDefinition['entities'][number];
|
|
312
|
+
type RawDefinitionPlace = RawDefinition['places'][number];
|
|
313
|
+
type RawDefinitionPerson = RawDefinition['cast'][number];
|
|
314
|
+
type RawDefinitionObject = RawDefinition['objects'][number];
|
|
315
|
+
export type LivingWorldDefinition = Omit<RawDefinition, 'startClock' | 'places' | 'player' | 'cast' | 'objects' | 'kinds' | 'entities' | 'tension' | 'beats'> & {
|
|
316
|
+
startClock: Minutes;
|
|
317
|
+
calendar: LivingCalendar;
|
|
318
|
+
places: (Omit<RawDefinitionPlace, 'id' | 'connections' | 'containerId'> & {
|
|
319
|
+
id: PlaceId;
|
|
320
|
+
containerId: PlaceId | null;
|
|
321
|
+
connections: PlaceId[];
|
|
322
|
+
})[];
|
|
323
|
+
player: Omit<RawDefinition['player'], 'id' | 'placeId'> & {
|
|
324
|
+
id: PersonId;
|
|
325
|
+
placeId: PlaceId;
|
|
326
|
+
};
|
|
327
|
+
cast: (Omit<RawDefinitionPerson, 'id' | 'placeId'> & {
|
|
328
|
+
id: PersonId;
|
|
329
|
+
placeId: PlaceId;
|
|
330
|
+
})[];
|
|
331
|
+
objects: (Omit<RawDefinitionObject, 'id' | 'containerId' | 'ownerId'> & {
|
|
332
|
+
id: EntityId;
|
|
333
|
+
containerId: PlaceId | PersonId | null;
|
|
334
|
+
ownerId: PersonId | null;
|
|
335
|
+
})[];
|
|
336
|
+
kinds: (Omit<RawDefinitionKind, 'id' | 'properties' | 'relations'> & {
|
|
337
|
+
id: KindId;
|
|
338
|
+
properties: (Omit<RawDefinitionKind['properties'][number], 'id'> & {
|
|
339
|
+
id: PropertyId;
|
|
340
|
+
})[];
|
|
341
|
+
relations: (Omit<RawDefinitionKind['relations'][number], 'id' | 'targetKindId'> & {
|
|
342
|
+
id: RelationId;
|
|
343
|
+
targetKindId: KindId;
|
|
344
|
+
})[];
|
|
345
|
+
})[];
|
|
346
|
+
entities: (Omit<RawDefinitionEntity, 'id' | 'kindId' | 'containerId' | 'properties' | 'relations'> & {
|
|
347
|
+
id: EntityId;
|
|
348
|
+
kindId: KindId;
|
|
349
|
+
containerId: PlaceId | PersonId | null;
|
|
350
|
+
properties: CellTable<PropertyId, unknown>;
|
|
351
|
+
relations: CellTable<RelationId, EntityId>;
|
|
352
|
+
})[];
|
|
353
|
+
tension: Omit<RawDefinition['tension'], 'id' | 'participantIds'> & {
|
|
354
|
+
id: EntityId;
|
|
355
|
+
participantIds: PersonId[];
|
|
356
|
+
};
|
|
357
|
+
beats: (Omit<RawDefinition['beats'][number], 'id' | 'placeId' | 'concerns'> & {
|
|
358
|
+
id: EntityId;
|
|
359
|
+
placeId: PlaceId;
|
|
360
|
+
concerns?: EntityId;
|
|
361
|
+
})[];
|
|
362
|
+
};
|
|
363
|
+
export declare function parseLivingWorldDefinition(value: unknown): LivingWorldDefinitionRaw;
|
|
364
|
+
export declare function parseKindRevision(previous: LivingKindDefinition, proposed: unknown): LivingKindDefinition;
|
|
365
|
+
export declare function createLivingState(definition: LivingWorldDefinitionRaw, seed: string): LivingStateRaw;
|
|
366
|
+
export {};
|