@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
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { phrase } from '../phrases.js';
|
|
3
|
+
const id = z.string().min(1).max(64);
|
|
4
|
+
const subject = z.union([z.literal('self'), z.literal('actor'), z.literal('target')])
|
|
5
|
+
.describe(phrase('schema.description.1'));
|
|
6
|
+
const slot = id.describe(phrase('schema.description.2'));
|
|
7
|
+
const of = subject.optional();
|
|
8
|
+
const termValue = z.union([z.boolean(), z.number(), z.string(), z.null()])
|
|
9
|
+
.describe(phrase('schema.description.3'));
|
|
10
|
+
const count = z.object({
|
|
11
|
+
slot: slot.describe(phrase('schema.description.4')),
|
|
12
|
+
equals: id.describe(phrase('schema.description.5')).optional(),
|
|
13
|
+
of: of.describe(phrase('schema.description.6')),
|
|
14
|
+
}).describe(phrase('schema.description.7'));
|
|
15
|
+
const size = z.object({
|
|
16
|
+
slot: slot.describe(phrase('schema.description.4')),
|
|
17
|
+
of: of.describe(phrase('schema.description.6')),
|
|
18
|
+
}).describe(phrase('schema.description.8'));
|
|
19
|
+
const termSchema = z.lazy(() => z.union([
|
|
20
|
+
z.object({ value: termValue }),
|
|
21
|
+
z.object({ slot: slot.describe(phrase('schema.description.9')), of: of.describe(phrase('schema.description.1')) }),
|
|
22
|
+
z.object({ count }),
|
|
23
|
+
z.object({ size }),
|
|
24
|
+
z.object({ actor: z.literal(true).describe(phrase('schema.description.10')) }),
|
|
25
|
+
z.object({ now: z.literal(true).describe(phrase('schema.description.11')) }),
|
|
26
|
+
]).describe(phrase('schema.description.12')));
|
|
27
|
+
const conditionSchema = z.lazy(() => z.union([
|
|
28
|
+
z.object({ op: z.enum(['eq', 'ne', 'gte', 'lte', 'gt', 'lt']).describe(phrase('schema.description.13')), left: termSchema, right: termSchema }),
|
|
29
|
+
z.object({ op: z.literal('holds').describe(phrase('schema.description.14')), subject: subject.describe(phrase('schema.description.1')), slot: slot.describe(phrase('schema.description.15')), value: termSchema }),
|
|
30
|
+
z.object({ op: z.literal('present').describe(phrase('schema.description.16')), subject: subject.describe(phrase('schema.description.1')), slot: slot.describe(phrase('schema.description.15')) }),
|
|
31
|
+
z.object({ op: z.literal('on').describe(phrase('schema.description.17')), subject: subject.describe(phrase('schema.description.1')), slot: slot.describe(phrase('schema.description.15')) }),
|
|
32
|
+
z.object({ op: z.literal('wrote').describe(phrase('schema.description.18')), subject: subject.describe(phrase('schema.description.19')), slot: slot.describe(phrase('schema.description.20')), person: subject.describe(phrase('schema.description.21')) }),
|
|
33
|
+
z.object({ op: z.literal('names').describe(phrase('schema.description.22')), subject: subject.describe(phrase('schema.description.1')), slot: slot.describe(phrase('schema.description.23')), target: subject.describe(phrase('schema.description.24')) }),
|
|
34
|
+
z.object({ op: z.literal('linked').describe(phrase('schema.description.25')), subject: subject.describe(phrase('schema.description.26')), relation: id.describe(phrase('schema.description.27')), target: subject.describe(phrase('schema.description.28')) }),
|
|
35
|
+
z.object({ op: z.literal('crossed').describe(phrase('schema.description.29')), slot: slot.describe(phrase('schema.description.30')), threshold: z.number().finite().describe(phrase('schema.description.31')), direction: z.enum(['at-least', 'at-most']).describe(phrase('schema.description.32')), of: of.describe(phrase('schema.description.1')) }),
|
|
36
|
+
z.object({ op: z.literal('role').describe(phrase('schema.description.33')), subject: subject.describe(phrase('schema.description.34')), is: id.describe(phrase('schema.description.35')) }),
|
|
37
|
+
z.object({ op: z.literal('beside').describe(phrase('schema.description.36')), subject: subject.describe(phrase('schema.description.37')), other: termSchema }),
|
|
38
|
+
z.object({ op: z.literal('actor').describe(phrase('schema.description.38')), }),
|
|
39
|
+
z.object({ op: z.literal('allOf').describe(phrase('schema.description.39')), of: z.array(conditionSchema).min(1).describe(phrase('schema.description.40')) }),
|
|
40
|
+
z.object({ op: z.literal('anyOf').describe(phrase('schema.description.41')), of: z.array(conditionSchema).min(1).describe(phrase('schema.description.42')) }),
|
|
41
|
+
z.object({ op: z.literal('not').describe(phrase('schema.description.43')), of: conditionSchema }),
|
|
42
|
+
]).describe(phrase('schema.description.44')));
|
|
43
|
+
const cueSchema = z.union([
|
|
44
|
+
z.object({ changed: id.describe(phrase('schema.description.45')) }),
|
|
45
|
+
z.object({ added: id.describe(phrase('schema.description.46')) }),
|
|
46
|
+
z.object({ created: z.literal(true).describe(phrase('schema.description.47')) }),
|
|
47
|
+
z.object({ every: z.number().int().min(1).describe(phrase('schema.description.48')) }),
|
|
48
|
+
z.object({ attempted: z.union([id, z.array(id).min(1)]).describe(phrase('schema.description.49')) }),
|
|
49
|
+
]);
|
|
50
|
+
const actionSchema = z.union([
|
|
51
|
+
z.object({ op: z.literal('set').describe(phrase('schema.description.50')), slot: slot.describe(phrase('schema.description.51')), value: termSchema }),
|
|
52
|
+
z.object({ op: z.literal('add').describe(phrase('schema.description.52')), slot: slot.describe(phrase('schema.description.53')), option: termSchema, person: subject.describe(phrase('schema.description.54')).optional() }),
|
|
53
|
+
z.object({ op: z.literal('shift').describe(phrase('schema.description.55')), slot: termSchema, from: termSchema, to: termSchema, amount: termSchema }),
|
|
54
|
+
z.object({ op: z.literal('link').describe(phrase('schema.description.56')), relation: id.describe(phrase('schema.description.57')), target: termSchema }),
|
|
55
|
+
z.object({ op: z.literal('settle').describe(phrase('schema.description.58')), tension: termSchema }),
|
|
56
|
+
z.object({ op: z.literal('happen').describe(phrase('schema.description.59')), intent: z.string().min(1).max(2000).describe(phrase('schema.description.60')), ['delayMinutes']: z.number().int().min(1).describe(phrase('schema.description.61')), minImportance: z.number().int().min(1).max(10).describe(phrase('schema.description.62')).optional() }),
|
|
57
|
+
z.object({ op: z.literal('violation').describe(phrase('schema.description.63')), }),
|
|
58
|
+
]);
|
|
59
|
+
export const lawSchema = z.union([
|
|
60
|
+
z.object({ kind: z.literal('react').describe(phrase('schema.description.64')), on: cueSchema.describe(phrase('schema.description.65')), when: conditionSchema.optional(), do: z.array(actionSchema).min(1).describe(phrase('schema.description.66')) }),
|
|
61
|
+
z.object({ kind: z.literal('forbid').describe(phrase('schema.description.67')), on: cueSchema.describe(phrase('schema.description.65')), when: conditionSchema.optional(), then: z.string().min(1).max(80).describe(phrase('schema.description.68')) }),
|
|
62
|
+
]);
|
|
63
|
+
function entityOf(state, id) {
|
|
64
|
+
return state.entities[id];
|
|
65
|
+
}
|
|
66
|
+
function seriesOf(state, env, slot, of) {
|
|
67
|
+
const entity = of === 'self' ? entityOf(state, env.self) : of === 'actor' && env.actor !== null ? entityOf(state, env.actor) : of === 'target' && env.target !== null ? entityOf(state, env.target) : undefined;
|
|
68
|
+
const value = entity?.properties[slot]?.value;
|
|
69
|
+
return Array.isArray(value) ? value : [];
|
|
70
|
+
}
|
|
71
|
+
export function subjectId(env, of) {
|
|
72
|
+
return of === 'self' ? env.self : of === 'actor' ? env.actor : env.target;
|
|
73
|
+
}
|
|
74
|
+
export function readSlot(state, env, slot, of) {
|
|
75
|
+
if (of === 'target' && slot === 'value')
|
|
76
|
+
return env.value;
|
|
77
|
+
if (of === 'actor')
|
|
78
|
+
return env.actor;
|
|
79
|
+
if (of === 'target')
|
|
80
|
+
return env.target;
|
|
81
|
+
return entityOf(state, env.self)?.properties[slot]?.value;
|
|
82
|
+
}
|
|
83
|
+
export function evaluateTerm(state, env, term) {
|
|
84
|
+
const value = term;
|
|
85
|
+
if (value.value !== undefined)
|
|
86
|
+
return value.value;
|
|
87
|
+
if (value.actor === true)
|
|
88
|
+
return env.actor;
|
|
89
|
+
if (value.now === true)
|
|
90
|
+
return env.at;
|
|
91
|
+
if (value.slot !== undefined)
|
|
92
|
+
return readSlot(state, env, value.slot, value.of ?? 'self');
|
|
93
|
+
if (value.count !== undefined) {
|
|
94
|
+
const entries = seriesOf(state, env, value.count.slot, value.count.of ?? 'self');
|
|
95
|
+
return entries.filter(entry => value.count.equals === undefined || entry.option === value.count.equals).length;
|
|
96
|
+
}
|
|
97
|
+
if (value.size !== undefined)
|
|
98
|
+
return seriesOf(state, env, value.size.slot, value.size.of ?? 'self').length;
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
function compare(left, right) {
|
|
102
|
+
if (typeof left === 'number' && typeof right === 'number')
|
|
103
|
+
return left - right;
|
|
104
|
+
if (typeof left === 'string' && typeof right === 'string') {
|
|
105
|
+
return left < right ? -1 : left > right ? 1 : 0;
|
|
106
|
+
}
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
function isOn(value) {
|
|
110
|
+
return value !== undefined && value !== null && value !== false && value !== 0 && value !== 'none';
|
|
111
|
+
}
|
|
112
|
+
export function evaluateCondition(state, env, condition) {
|
|
113
|
+
switch (condition.op) {
|
|
114
|
+
case 'eq': return evaluateTerm(state, env, condition.left) === evaluateTerm(state, env, condition.right);
|
|
115
|
+
case 'ne': return evaluateTerm(state, env, condition.left) !== evaluateTerm(state, env, condition.right);
|
|
116
|
+
case 'gte': {
|
|
117
|
+
const order = compare(evaluateTerm(state, env, condition.left), evaluateTerm(state, env, condition.right));
|
|
118
|
+
return order !== null && order >= 0;
|
|
119
|
+
}
|
|
120
|
+
case 'lte': {
|
|
121
|
+
const order = compare(evaluateTerm(state, env, condition.left), evaluateTerm(state, env, condition.right));
|
|
122
|
+
return order !== null && order <= 0;
|
|
123
|
+
}
|
|
124
|
+
case 'gt': {
|
|
125
|
+
const order = compare(evaluateTerm(state, env, condition.left), evaluateTerm(state, env, condition.right));
|
|
126
|
+
return order !== null && order > 0;
|
|
127
|
+
}
|
|
128
|
+
case 'lt': {
|
|
129
|
+
const order = compare(evaluateTerm(state, env, condition.left), evaluateTerm(state, env, condition.right));
|
|
130
|
+
return order !== null && order < 0;
|
|
131
|
+
}
|
|
132
|
+
case 'holds': return evaluateTerm(state, env, condition.value) === readSlot(state, env, condition.slot, condition.subject);
|
|
133
|
+
case 'present': {
|
|
134
|
+
const value = readSlot(state, env, condition.slot, condition.subject);
|
|
135
|
+
return value !== undefined && value !== null && value !== false;
|
|
136
|
+
}
|
|
137
|
+
case 'on': return isOn(readSlot(state, env, condition.slot, condition.subject));
|
|
138
|
+
case 'wrote': return seriesOf(state, env, condition.slot, condition.subject).some(entry => entry.personId === subjectId(env, condition.person));
|
|
139
|
+
case 'names': return readSlot(state, env, condition.slot, condition.subject) === subjectId(env, condition.target);
|
|
140
|
+
case 'linked': return entityOf(state, env.self)?.relations[condition.relation]?.targetId === subjectId(env, condition.target);
|
|
141
|
+
case 'crossed': {
|
|
142
|
+
const of = condition.of ?? 'self';
|
|
143
|
+
const value = of === 'self' && typeof env.value === 'number' ? env.value : readSlot(state, env, condition.slot, of);
|
|
144
|
+
if (typeof value !== 'number')
|
|
145
|
+
return false;
|
|
146
|
+
const previous = typeof env.previous === 'number' ? env.previous : null;
|
|
147
|
+
return condition.direction === 'at-least'
|
|
148
|
+
? (previous === null || previous < condition.threshold) && value >= condition.threshold
|
|
149
|
+
: (previous === null || previous > condition.threshold) && value <= condition.threshold;
|
|
150
|
+
}
|
|
151
|
+
case 'role': {
|
|
152
|
+
const personId = subjectId(env, condition.subject);
|
|
153
|
+
return personId !== null && state.people[personId]?.roleId === condition.is;
|
|
154
|
+
}
|
|
155
|
+
case 'beside': {
|
|
156
|
+
const personId = subjectId(env, condition.subject);
|
|
157
|
+
const other = evaluateTerm(state, env, condition.other);
|
|
158
|
+
if (personId === null || typeof other !== 'string' || other === personId)
|
|
159
|
+
return false;
|
|
160
|
+
const person = state.people[personId];
|
|
161
|
+
const keeper = state.people[other];
|
|
162
|
+
return person !== undefined && keeper !== undefined && keeper.placeId === person.placeId
|
|
163
|
+
&& keeper.away === undefined && keeper.departed === undefined;
|
|
164
|
+
}
|
|
165
|
+
case 'actor': return env.actor !== null;
|
|
166
|
+
case 'allOf': return condition.of.every(part => evaluateCondition(state, env, part));
|
|
167
|
+
case 'anyOf': return condition.of.some(part => evaluateCondition(state, env, part));
|
|
168
|
+
case 'not': return !evaluateCondition(state, env, condition.of);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
export function cueMatches(cue, slot) {
|
|
172
|
+
const value = cue;
|
|
173
|
+
return value.changed === slot || value.added === slot;
|
|
174
|
+
}
|
|
175
|
+
export function lawCueSlot(cue) {
|
|
176
|
+
const value = cue;
|
|
177
|
+
return value.changed ?? value.added ?? null;
|
|
178
|
+
}
|
|
179
|
+
export function attemptedKinds(cue) {
|
|
180
|
+
const value = cue.attempted;
|
|
181
|
+
if (value === undefined)
|
|
182
|
+
return [];
|
|
183
|
+
return typeof value === 'string' ? [value] : [...value];
|
|
184
|
+
}
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
import type { ChannelId, EntityId, FacetId, KindId, Minutes, OptionId, Prose, RelationId, SlotId } from './ids.js';
|
|
2
|
+
export type Source = 'referee' | 'mind' | 'law' | 'director' | 'host' | 'world-data';
|
|
3
|
+
export declare const OPS: {
|
|
4
|
+
readonly create: {
|
|
5
|
+
readonly lasting: true;
|
|
6
|
+
readonly sources: readonly ["referee", "law", "world-data"];
|
|
7
|
+
};
|
|
8
|
+
readonly set: {
|
|
9
|
+
readonly lasting: true;
|
|
10
|
+
readonly sources: readonly ["referee", "mind", "law", "world-data"];
|
|
11
|
+
};
|
|
12
|
+
readonly add: {
|
|
13
|
+
readonly lasting: true;
|
|
14
|
+
readonly sources: readonly ["referee", "mind", "law"];
|
|
15
|
+
};
|
|
16
|
+
readonly shift: {
|
|
17
|
+
readonly lasting: true;
|
|
18
|
+
readonly sources: readonly ["referee", "mind", "law"];
|
|
19
|
+
};
|
|
20
|
+
readonly link: {
|
|
21
|
+
readonly lasting: true;
|
|
22
|
+
readonly sources: readonly ["referee", "law"];
|
|
23
|
+
};
|
|
24
|
+
readonly place: {
|
|
25
|
+
readonly lasting: true;
|
|
26
|
+
readonly sources: readonly ["referee", "mind", "law"];
|
|
27
|
+
};
|
|
28
|
+
readonly retire: {
|
|
29
|
+
readonly lasting: true;
|
|
30
|
+
readonly sources: readonly ["referee", "law"];
|
|
31
|
+
};
|
|
32
|
+
readonly note: {
|
|
33
|
+
readonly lasting: true;
|
|
34
|
+
readonly sources: readonly ["referee"];
|
|
35
|
+
};
|
|
36
|
+
readonly thread: {
|
|
37
|
+
readonly lasting: true;
|
|
38
|
+
readonly sources: readonly ["referee", "law", "director"];
|
|
39
|
+
};
|
|
40
|
+
readonly happen: {
|
|
41
|
+
readonly lasting: false;
|
|
42
|
+
readonly sources: readonly ["referee", "law", "director", "world-data"];
|
|
43
|
+
};
|
|
44
|
+
readonly cancel: {
|
|
45
|
+
readonly lasting: false;
|
|
46
|
+
readonly sources: readonly ["referee", "law"];
|
|
47
|
+
};
|
|
48
|
+
readonly say: {
|
|
49
|
+
readonly lasting: false;
|
|
50
|
+
readonly sources: readonly ["mind"];
|
|
51
|
+
};
|
|
52
|
+
readonly send: {
|
|
53
|
+
readonly lasting: false;
|
|
54
|
+
readonly sources: readonly ["mind", "referee"];
|
|
55
|
+
};
|
|
56
|
+
readonly ask: {
|
|
57
|
+
readonly lasting: false;
|
|
58
|
+
readonly sources: readonly ["mind", "referee"];
|
|
59
|
+
};
|
|
60
|
+
readonly answer: {
|
|
61
|
+
readonly lasting: false;
|
|
62
|
+
readonly sources: readonly ["mind"];
|
|
63
|
+
};
|
|
64
|
+
readonly promise: {
|
|
65
|
+
readonly lasting: false;
|
|
66
|
+
readonly sources: readonly ["mind", "referee"];
|
|
67
|
+
};
|
|
68
|
+
readonly settle: {
|
|
69
|
+
readonly lasting: false;
|
|
70
|
+
readonly sources: readonly ["mind", "law"];
|
|
71
|
+
};
|
|
72
|
+
readonly aim: {
|
|
73
|
+
readonly lasting: false;
|
|
74
|
+
readonly sources: readonly ["mind", "referee"];
|
|
75
|
+
};
|
|
76
|
+
readonly regard: {
|
|
77
|
+
readonly lasting: false;
|
|
78
|
+
readonly sources: readonly ["mind", "referee"];
|
|
79
|
+
};
|
|
80
|
+
readonly believe: {
|
|
81
|
+
readonly lasting: false;
|
|
82
|
+
readonly sources: readonly ["mind", "referee"];
|
|
83
|
+
};
|
|
84
|
+
readonly plan: {
|
|
85
|
+
readonly lasting: false;
|
|
86
|
+
readonly sources: readonly ["mind"];
|
|
87
|
+
};
|
|
88
|
+
readonly offstage: {
|
|
89
|
+
readonly lasting: false;
|
|
90
|
+
readonly sources: readonly ["mind", "referee"];
|
|
91
|
+
};
|
|
92
|
+
readonly clock: {
|
|
93
|
+
readonly lasting: false;
|
|
94
|
+
readonly sources: readonly ["host"];
|
|
95
|
+
};
|
|
96
|
+
readonly revise: {
|
|
97
|
+
readonly lasting: false;
|
|
98
|
+
readonly sources: readonly ["host"];
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
export type OpName = keyof typeof OPS;
|
|
102
|
+
export type Cell = {
|
|
103
|
+
entity: EntityId;
|
|
104
|
+
slot: SlotId;
|
|
105
|
+
};
|
|
106
|
+
export type Whereabouts = {
|
|
107
|
+
in: EntityId;
|
|
108
|
+
} | {
|
|
109
|
+
nowhere: true;
|
|
110
|
+
};
|
|
111
|
+
type Fields = {
|
|
112
|
+
create: {
|
|
113
|
+
id: EntityId;
|
|
114
|
+
kind: KindId;
|
|
115
|
+
name: Prose;
|
|
116
|
+
where: Whereabouts;
|
|
117
|
+
cells: readonly {
|
|
118
|
+
slot: SlotId;
|
|
119
|
+
value: unknown;
|
|
120
|
+
}[];
|
|
121
|
+
};
|
|
122
|
+
set: Cell & {
|
|
123
|
+
value: unknown;
|
|
124
|
+
};
|
|
125
|
+
add: Cell & {
|
|
126
|
+
option: OptionId;
|
|
127
|
+
};
|
|
128
|
+
shift: {
|
|
129
|
+
from: Cell | null;
|
|
130
|
+
to: Cell | null;
|
|
131
|
+
amount: number;
|
|
132
|
+
};
|
|
133
|
+
link: {
|
|
134
|
+
entity: EntityId;
|
|
135
|
+
relation: RelationId;
|
|
136
|
+
target: EntityId;
|
|
137
|
+
on: boolean;
|
|
138
|
+
};
|
|
139
|
+
place: {
|
|
140
|
+
entity: EntityId;
|
|
141
|
+
where: Whereabouts;
|
|
142
|
+
};
|
|
143
|
+
retire: {
|
|
144
|
+
entity: EntityId;
|
|
145
|
+
why: Prose;
|
|
146
|
+
};
|
|
147
|
+
note: {
|
|
148
|
+
about: EntityId | null;
|
|
149
|
+
facet: FacetId;
|
|
150
|
+
text: Prose | null;
|
|
151
|
+
};
|
|
152
|
+
thread: {
|
|
153
|
+
id: EntityId;
|
|
154
|
+
title: Prose;
|
|
155
|
+
summary: Prose;
|
|
156
|
+
parties: readonly EntityId[];
|
|
157
|
+
open: boolean;
|
|
158
|
+
resolution: Prose | null;
|
|
159
|
+
};
|
|
160
|
+
happen: {
|
|
161
|
+
id: EntityId;
|
|
162
|
+
after: Minutes;
|
|
163
|
+
what: Prose;
|
|
164
|
+
at: EntityId | null;
|
|
165
|
+
who: EntityId | null;
|
|
166
|
+
weight: number;
|
|
167
|
+
every: Minutes | null;
|
|
168
|
+
};
|
|
169
|
+
cancel: {
|
|
170
|
+
id: EntityId;
|
|
171
|
+
};
|
|
172
|
+
say: {
|
|
173
|
+
words: Prose;
|
|
174
|
+
to: readonly EntityId[];
|
|
175
|
+
};
|
|
176
|
+
send: {
|
|
177
|
+
to: readonly EntityId[];
|
|
178
|
+
words: Prose;
|
|
179
|
+
via: ChannelId | null;
|
|
180
|
+
};
|
|
181
|
+
ask: {
|
|
182
|
+
id: EntityId;
|
|
183
|
+
of: EntityId;
|
|
184
|
+
topic: Prose;
|
|
185
|
+
};
|
|
186
|
+
answer: {
|
|
187
|
+
ask: EntityId;
|
|
188
|
+
verdict: 'accepted' | 'refused' | 'done';
|
|
189
|
+
words: Prose | null;
|
|
190
|
+
};
|
|
191
|
+
promise: {
|
|
192
|
+
id: EntityId;
|
|
193
|
+
to: EntityId;
|
|
194
|
+
text: Prose;
|
|
195
|
+
due: Minutes | null;
|
|
196
|
+
at: EntityId | null;
|
|
197
|
+
};
|
|
198
|
+
settle: {
|
|
199
|
+
promise: EntityId;
|
|
200
|
+
verdict: 'kept' | 'broken';
|
|
201
|
+
};
|
|
202
|
+
aim: {
|
|
203
|
+
id: EntityId;
|
|
204
|
+
text: Prose;
|
|
205
|
+
status: 'active' | 'done' | 'dropped';
|
|
206
|
+
};
|
|
207
|
+
regard: {
|
|
208
|
+
toward: EntityId;
|
|
209
|
+
trust: number;
|
|
210
|
+
warmth: number;
|
|
211
|
+
stance: Prose | null;
|
|
212
|
+
decided: boolean;
|
|
213
|
+
};
|
|
214
|
+
believe: {
|
|
215
|
+
subject: Prose;
|
|
216
|
+
claim: Prose;
|
|
217
|
+
from: EntityId | null;
|
|
218
|
+
};
|
|
219
|
+
plan: {
|
|
220
|
+
intent: Prose;
|
|
221
|
+
seen: Prose | null;
|
|
222
|
+
at: EntityId | null;
|
|
223
|
+
with: EntityId | null;
|
|
224
|
+
due: Minutes;
|
|
225
|
+
};
|
|
226
|
+
offstage: {
|
|
227
|
+
until: Minutes | null;
|
|
228
|
+
why: Prose;
|
|
229
|
+
};
|
|
230
|
+
clock: {
|
|
231
|
+
paused: boolean;
|
|
232
|
+
rate: number;
|
|
233
|
+
};
|
|
234
|
+
revise: {
|
|
235
|
+
kind: KindId;
|
|
236
|
+
revision: number;
|
|
237
|
+
};
|
|
238
|
+
};
|
|
239
|
+
export type Op = {
|
|
240
|
+
[N in OpName]: {
|
|
241
|
+
op: N;
|
|
242
|
+
} & Fields[N];
|
|
243
|
+
}[OpName];
|
|
244
|
+
export type OpOf<N extends OpName> = Extract<Op, {
|
|
245
|
+
op: N;
|
|
246
|
+
}>;
|
|
247
|
+
export declare const ACT_MODES: readonly ["say", "do", "go", "send", "choose", "wait"];
|
|
248
|
+
export type ActMode = typeof ACT_MODES[number];
|
|
249
|
+
export declare const REFUSALS: readonly ["unknown-id", "wrong-type", "write-denied", "forbidden", "short", "out-of-reach", "not-loaded", "full", "stale", "source-denied"];
|
|
250
|
+
export type Refusal = {
|
|
251
|
+
index: number;
|
|
252
|
+
op: OpName;
|
|
253
|
+
code: typeof REFUSALS[number];
|
|
254
|
+
};
|
|
255
|
+
export declare function lastingOps(): readonly OpName[];
|
|
256
|
+
export declare function opsFrom(source: Source): readonly OpName[];
|
|
257
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export const OPS = {
|
|
2
|
+
create: { lasting: true, sources: ['referee', 'law', 'world-data'] },
|
|
3
|
+
set: { lasting: true, sources: ['referee', 'mind', 'law', 'world-data'] },
|
|
4
|
+
add: { lasting: true, sources: ['referee', 'mind', 'law'] },
|
|
5
|
+
shift: { lasting: true, sources: ['referee', 'mind', 'law'] },
|
|
6
|
+
link: { lasting: true, sources: ['referee', 'law'] },
|
|
7
|
+
place: { lasting: true, sources: ['referee', 'mind', 'law'] },
|
|
8
|
+
retire: { lasting: true, sources: ['referee', 'law'] },
|
|
9
|
+
note: { lasting: true, sources: ['referee'] },
|
|
10
|
+
thread: { lasting: true, sources: ['referee', 'law', 'director'] },
|
|
11
|
+
happen: { lasting: false, sources: ['referee', 'law', 'director', 'world-data'] },
|
|
12
|
+
cancel: { lasting: false, sources: ['referee', 'law'] },
|
|
13
|
+
say: { lasting: false, sources: ['mind'] },
|
|
14
|
+
send: { lasting: false, sources: ['mind', 'referee'] },
|
|
15
|
+
ask: { lasting: false, sources: ['mind', 'referee'] },
|
|
16
|
+
answer: { lasting: false, sources: ['mind'] },
|
|
17
|
+
promise: { lasting: false, sources: ['mind', 'referee'] },
|
|
18
|
+
settle: { lasting: false, sources: ['mind', 'law'] },
|
|
19
|
+
aim: { lasting: false, sources: ['mind', 'referee'] },
|
|
20
|
+
regard: { lasting: false, sources: ['mind', 'referee'] },
|
|
21
|
+
believe: { lasting: false, sources: ['mind', 'referee'] },
|
|
22
|
+
plan: { lasting: false, sources: ['mind'] },
|
|
23
|
+
offstage: { lasting: false, sources: ['mind', 'referee'] },
|
|
24
|
+
clock: { lasting: false, sources: ['host'] },
|
|
25
|
+
revise: { lasting: false, sources: ['host'] },
|
|
26
|
+
};
|
|
27
|
+
export const ACT_MODES = ['say', 'do', 'go', 'send', 'choose', 'wait'];
|
|
28
|
+
export const REFUSALS = ['unknown-id', 'wrong-type', 'write-denied', 'forbidden', 'short', 'out-of-reach', 'not-loaded', 'full', 'stale', 'source-denied'];
|
|
29
|
+
export function lastingOps() {
|
|
30
|
+
return Object.entries(OPS).filter(([, spec]) => spec.lasting).map(([name]) => name);
|
|
31
|
+
}
|
|
32
|
+
export function opsFrom(source) {
|
|
33
|
+
return Object.entries(OPS).filter(([, spec]) => spec.sources.includes(source)).map(([name]) => name);
|
|
34
|
+
}
|
|
@@ -2,7 +2,6 @@ import { z } from 'zod';
|
|
|
2
2
|
import { type LivingInference } from './inference.js';
|
|
3
3
|
import { kindRequestSchema, type LivingKindDefinition } from './open-world.js';
|
|
4
4
|
export declare const kindDefinitionResponseSchema: Readonly<Record<string, unknown>>;
|
|
5
|
-
export declare const DEFINER_SYSTEM: string;
|
|
6
5
|
export declare const DEFINER_CALLS = 3;
|
|
7
6
|
export declare function defineLivingKind(options: {
|
|
8
7
|
request: z.infer<typeof kindRequestSchema>;
|
|
@@ -10,3 +9,20 @@ export declare function defineLivingKind(options: {
|
|
|
10
9
|
inference: LivingInference;
|
|
11
10
|
stillWanted?: () => boolean;
|
|
12
11
|
}): Promise<LivingKindDefinition>;
|
|
12
|
+
export declare const REVISION_CALLS = 2;
|
|
13
|
+
export declare function reviseLivingKind(options: {
|
|
14
|
+
kind: LivingKindDefinition;
|
|
15
|
+
facets: readonly {
|
|
16
|
+
facet: string;
|
|
17
|
+
count: number;
|
|
18
|
+
text: string;
|
|
19
|
+
}[];
|
|
20
|
+
requests?: readonly {
|
|
21
|
+
id: string;
|
|
22
|
+
name: string;
|
|
23
|
+
meaning: string;
|
|
24
|
+
}[];
|
|
25
|
+
library: readonly LivingKindDefinition[];
|
|
26
|
+
inference: LivingInference;
|
|
27
|
+
stillWanted?: () => boolean;
|
|
28
|
+
}): Promise<LivingKindDefinition>;
|