@zergai/ztc 0.19.0-beta.1 → 0.20.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.
Files changed (196) hide show
  1. package/README.md +222 -6
  2. package/bin/zmux-darwin-arm64 +0 -0
  3. package/bin/ztc-audio-darwin-arm64 +0 -0
  4. package/bin/ztc-capture-darwin-arm64 +0 -0
  5. package/bin/ztc-tui-darwin-arm64 +0 -0
  6. package/bin/zterm-darwin-arm64 +2 -2
  7. package/dist/agent/agent.d.ts +17 -0
  8. package/dist/agent/agent.js +77 -4
  9. package/dist/agent/backends/index.js +5 -3
  10. package/dist/agent/backends/zrouter_stream.js +8 -4
  11. package/dist/agent/commands/goal.d.ts +2 -0
  12. package/dist/agent/commands/goal.js +7 -2
  13. package/dist/agent/factory.d.ts +2 -0
  14. package/dist/agent/factory.js +1 -0
  15. package/dist/agent/request_encoder.d.ts +2 -1
  16. package/dist/agent/request_encoder.js +4 -3
  17. package/dist/agent/runtime/policy.d.ts +1 -0
  18. package/dist/agent/runtime/policy.js +23 -3
  19. package/dist/agent/runtime/tool_runtime.js +13 -12
  20. package/dist/agent/subagent.js +2 -1
  21. package/dist/agent/tools/ask_user.d.ts +1 -1
  22. package/dist/agent/tools/ask_user.js +15 -8
  23. package/dist/agent/tools/pane.d.ts +6 -0
  24. package/dist/agent/tools/pane.js +18 -4
  25. package/dist/agent/tools/search.js +1 -1
  26. package/dist/agent/tools/sim_domain_tools.d.ts +4 -0
  27. package/dist/agent/tools/sim_domain_tools.js +28 -2
  28. package/dist/agent/tools/types.d.ts +3 -0
  29. package/dist/app/correlated_turn.d.ts +14 -0
  30. package/dist/app/correlated_turn.js +78 -0
  31. package/dist/app/prompt_turn.d.ts +2 -1
  32. package/dist/app/prompt_turn.js +15 -2
  33. package/dist/app/session_manager.d.ts +17 -11
  34. package/dist/app/session_manager.js +74 -30
  35. package/dist/app/tool_callbacks.d.ts +1 -1
  36. package/dist/app/workspace_layout_controller.d.ts +21 -2
  37. package/dist/app/workspace_layout_controller.js +61 -10
  38. package/dist/app/workspace_monitor.js +67 -7
  39. package/dist/app/workspace_presets.d.ts +1 -0
  40. package/dist/app/workspace_presets.js +2 -2
  41. package/dist/cli.js +6 -2
  42. package/dist/cli_args.js +1 -0
  43. package/dist/cli_main.js +48 -2
  44. package/dist/cli_ratatui.d.ts +56 -8
  45. package/dist/cli_ratatui.js +689 -109
  46. package/dist/config/permissions.js +1 -1
  47. package/dist/config/router_required.d.ts +11 -0
  48. package/dist/config/router_required.js +23 -0
  49. package/dist/config/types.d.ts +5 -0
  50. package/dist/config.d.ts +3 -1
  51. package/dist/config.js +66 -49
  52. package/dist/desktop/daily/broker.d.ts +26 -0
  53. package/dist/desktop/daily/broker.js +140 -0
  54. package/dist/desktop/daily/codex_config.d.ts +2 -0
  55. package/dist/desktop/daily/codex_config.js +119 -0
  56. package/dist/desktop/daily/codex_exec_adapter.d.ts +42 -0
  57. package/dist/desktop/daily/codex_exec_adapter.js +251 -0
  58. package/dist/desktop/daily/control_client.d.ts +4 -0
  59. package/dist/desktop/daily/control_client.js +214 -0
  60. package/dist/desktop/daily/control_credentials.d.ts +15 -0
  61. package/dist/desktop/daily/control_credentials.js +85 -0
  62. package/dist/desktop/daily/control_hello.d.ts +10 -0
  63. package/dist/desktop/daily/control_hello.js +6 -0
  64. package/dist/desktop/daily/control_protocol.d.ts +39 -0
  65. package/dist/desktop/daily/control_protocol.js +4 -0
  66. package/dist/desktop/daily/control_schema.d.ts +9 -0
  67. package/dist/desktop/daily/control_schema.js +25 -0
  68. package/dist/desktop/daily/control_server.d.ts +44 -0
  69. package/dist/desktop/daily/control_server.js +286 -0
  70. package/dist/desktop/daily/daily_store.d.ts +71 -0
  71. package/dist/desktop/daily/daily_store.js +290 -0
  72. package/dist/desktop/daily/delegated_ztc_contract.d.ts +37 -0
  73. package/dist/desktop/daily/delegated_ztc_contract.js +90 -0
  74. package/dist/desktop/daily/desktop_wiring.d.ts +112 -0
  75. package/dist/desktop/daily/desktop_wiring.js +1048 -0
  76. package/dist/desktop/daily/enrollment.d.ts +74 -0
  77. package/dist/desktop/daily/enrollment.js +77 -0
  78. package/dist/desktop/daily/file_facts.d.ts +2 -0
  79. package/dist/desktop/daily/file_facts.js +41 -0
  80. package/dist/desktop/daily/lease.d.ts +57 -0
  81. package/dist/desktop/daily/lease.js +332 -0
  82. package/dist/desktop/daily/legacy_codex_homes.d.ts +1 -0
  83. package/dist/desktop/daily/legacy_codex_homes.js +26 -0
  84. package/dist/desktop/daily/native_pane_launcher.d.ts +31 -0
  85. package/dist/desktop/daily/native_pane_launcher.js +226 -0
  86. package/dist/desktop/daily/native_records.d.ts +13 -0
  87. package/dist/desktop/daily/native_records.js +81 -0
  88. package/dist/desktop/daily/native_status.d.ts +4 -0
  89. package/dist/desktop/daily/native_status.js +28 -0
  90. package/dist/desktop/daily/native_tool.d.ts +134 -0
  91. package/dist/desktop/daily/native_tool.js +91 -0
  92. package/dist/desktop/daily/owner_files.d.ts +3 -0
  93. package/dist/desktop/daily/owner_files.js +88 -0
  94. package/dist/desktop/daily/owner_seals.d.ts +9 -0
  95. package/dist/desktop/daily/owner_seals.js +56 -0
  96. package/dist/desktop/daily/process_identity.d.ts +13 -0
  97. package/dist/desktop/daily/process_identity.js +137 -0
  98. package/dist/desktop/daily/profile_bootstrap.d.ts +60 -0
  99. package/dist/desktop/daily/profile_bootstrap.js +194 -0
  100. package/dist/desktop/daily/raw_receipts.d.ts +1 -0
  101. package/dist/desktop/daily/raw_receipts.js +18 -0
  102. package/dist/desktop/daily/recipes.d.ts +36 -0
  103. package/dist/desktop/daily/recipes.js +177 -0
  104. package/dist/desktop/daily/router_state.d.ts +33 -0
  105. package/dist/desktop/daily/router_state.js +39 -0
  106. package/dist/desktop/daily/schema_registry.d.ts +19 -0
  107. package/dist/desktop/daily/schema_registry.js +71 -0
  108. package/dist/desktop/daily/source_baseline.d.ts +13 -0
  109. package/dist/desktop/daily/source_baseline.js +44 -0
  110. package/dist/desktop/daily/status_restore.d.ts +9 -0
  111. package/dist/desktop/daily/status_restore.js +114 -0
  112. package/dist/desktop/daily/summary.d.ts +59 -0
  113. package/dist/desktop/daily/summary.js +75 -0
  114. package/dist/desktop/daily/worker_provenance.d.ts +2 -0
  115. package/dist/desktop/daily/worker_provenance.js +18 -0
  116. package/dist/desktop/daily/worker_stop.d.ts +2 -0
  117. package/dist/desktop/daily/worker_stop.js +26 -0
  118. package/dist/desktop/daily/ztc_headless_adapter.d.ts +40 -0
  119. package/dist/desktop/daily/ztc_headless_adapter.js +194 -0
  120. package/dist/domain.d.ts +1 -1
  121. package/dist/domain.js +1 -1
  122. package/dist/events.d.ts +23 -1
  123. package/dist/headless.d.ts +9 -0
  124. package/dist/headless.js +161 -26
  125. package/dist/headless_approval.d.ts +29 -0
  126. package/dist/headless_approval.js +69 -0
  127. package/dist/headless_cli.js +2 -0
  128. package/dist/headless_cli_args.d.ts +4 -0
  129. package/dist/headless_cli_args.js +5 -0
  130. package/dist/library.d.ts +20 -0
  131. package/dist/library.js +66 -12
  132. package/dist/mcp/client.d.ts +16 -1
  133. package/dist/mcp/client.js +11 -5
  134. package/dist/mcp/registry.d.ts +3 -1
  135. package/dist/mcp/registry.js +10 -1
  136. package/dist/panes/pane_registry.js +14 -3
  137. package/dist/panes/types.d.ts +7 -1
  138. package/dist/panes/ztc_launch.d.ts +5 -0
  139. package/dist/panes/ztc_launch.js +30 -14
  140. package/dist/session.d.ts +6 -3
  141. package/dist/session.js +21 -2
  142. package/dist/simulation/domain_types.d.ts +2 -0
  143. package/dist/simulation/domains/loader.d.ts +7 -1
  144. package/dist/simulation/domains/loader.js +33 -1
  145. package/dist/simulation/living/context.d.ts +19 -19
  146. package/dist/simulation/living/definition.d.ts +2 -2
  147. package/dist/simulation/living/frame.d.ts +1 -1
  148. package/dist/simulation/living/open-world.d.ts +3 -3
  149. package/dist/simulation/living/types.d.ts +24 -24
  150. package/dist/simulation/toolkit/dynamic_state.d.ts +1 -1
  151. package/dist/skills/bundled/init-context/SKILL.md +16 -0
  152. package/dist/skills/registry.js +7 -3
  153. package/dist/tools.d.ts +6 -0
  154. package/dist/tools.js +14 -0
  155. package/dist/types.d.ts +30 -0
  156. package/dist/ui/ratatui/mux_persistence.d.ts +3 -1
  157. package/dist/ui/ratatui/mux_persistence.js +9 -2
  158. package/dist/ui/ratatui/pane_credential_broker.d.ts +8 -4
  159. package/dist/ui/ratatui/pane_credential_broker.js +26 -11
  160. package/dist/ui/ratatui/pane_relay.d.ts +2 -0
  161. package/dist/ui/ratatui/process.d.ts +6 -0
  162. package/dist/ui/ratatui/process.js +104 -6
  163. package/dist/ui/ratatui/protocol.d.ts +13 -0
  164. package/dist/ui/ratatui/protocol.js +1 -0
  165. package/dist/utils/compaction.js +6 -4
  166. package/dist/utils/subprocess_env.js +2 -0
  167. package/dist/web/browser_events.d.ts +10 -0
  168. package/dist/web/browser_events.js +9 -0
  169. package/dist/web/mirror_stream.d.ts +17 -5
  170. package/dist/web/mirror_stream.js +105 -13
  171. package/dist/web/pane_credentials.d.ts +6 -3
  172. package/dist/web/pane_credentials.js +20 -12
  173. package/dist/web/pane_registry.js +1 -0
  174. package/dist/workspace_agent.d.ts +2 -1
  175. package/dist/workspace_agent.js +7 -1
  176. package/dist/workspace_collision.d.ts +3 -0
  177. package/dist/workspace_collision.js +1 -1
  178. package/dist/workspace_layout.d.ts +3 -2
  179. package/dist/workspace_layout.js +8 -2
  180. package/dist/workspace_runtime.d.ts +7 -1
  181. package/dist/workspace_runtime.js +3 -3
  182. package/dist/zerg/manifest_builder_tools.js +35 -4
  183. package/dist/zerg/manifest_validator.js +55 -0
  184. package/dist/zlm-embed.mjs +261 -116
  185. package/node_modules/@zerg/model-contracts/README.md +19 -0
  186. package/node_modules/@zerg/model-contracts/index.js +19 -1
  187. package/node_modules/@ztc/sim-graph/dist/index.d.ts +1 -0
  188. package/node_modules/@ztc/sim-graph/dist/index.js +1 -0
  189. package/node_modules/@ztc/sim-graph/dist/sim_graph.d.ts +351 -0
  190. package/node_modules/@ztc/sim-graph/dist/sim_graph.js +795 -0
  191. package/node_modules/@ztc/sim-graph/package.json +37 -0
  192. package/node_modules/@ztc/sim-graph/src/index.ts +1 -0
  193. package/node_modules/@ztc/sim-graph/src/sim_graph.ts +1305 -0
  194. package/package.json +25 -24
  195. package/packages/model-contracts/README.md +19 -0
  196. package/packages/model-contracts/index.js +19 -1
@@ -68,6 +68,25 @@ documents the effective V4.1 levels: `none`, `low`, `high`, and `max`.
68
68
  The contract retains the existing 256–384,000-token output range and allows
69
69
  hosted fallback as Router policy; these are not published provider limits.
70
70
 
71
+ `deepinfra/deepseek-ai/DeepSeek-V4.1-Flash` and its `-1017` update use the
72
+ same contract. DeepInfra's `/v1/openai/models` listed a 1,048,576-token context
73
+ for both on November 7, 2026. Bounded live requests that day showed that its
74
+ chat API accepts `none`, `low`, `high` and `max` and rejects unknown levels with
75
+ HTTP 422. The contract keeps DeepSeek's own four levels, although DeepInfra
76
+ also accepts `minimal`, `medium` and `xhigh`. IDs are matched case-insensitively.
77
+
78
+ `morph/morph-dsv41flash-1017`, `morph/morph-dsv41flash` and
79
+ `morph/morph-kimik31` are Morph's personal-subscription models. Bounded live
80
+ requests on November 10, 2026 showed Morph's chat API accepts `none`, `minimal`,
81
+ `low`, `medium`, `high`, `xhigh` and `max` for each and rejects other values with
82
+ HTTP 400; `none` turns thinking off. The DeepSeek pair keeps DeepSeek's four
83
+ levels and the 384,000-token output range above, with a 1,048,576-token window
84
+ (a 945,000-token prompt was accepted). Kimi K3.1 lists the five levels whose
85
+ reasoning depth differed, Kimi K3's 64,000-token output cap, and a conservative
86
+ 262,144-token window (a 300,000-token prompt was accepted). Morph validates
87
+ `max_tokens` at 1,048,576 or less. Router serves these only on their owner's own
88
+ key.
89
+
71
90
  ## Evidence and extension
72
91
 
73
92
  Reviewed on September 30, 2026:
@@ -147,9 +147,27 @@ const MODEL_CONTRACTS = new Map([
147
147
  ["inkling", { reasoningEfforts: [], maxOutputTokens: null, fallbackRouting: false }],
148
148
  ["kimi-k2p6", { reasoningEfforts: [], maxOutputTokens: null, fallbackRouting: false }],
149
149
  ])],
150
+ ["deepinfra", new Map([
151
+ // DeepInfra's shared DeepSeek V4.1 Flash (fp8), verified 2026-11-07 against
152
+ // https://api.deepinfra.com/v1/openai/models and chat/completions. DeepInfra
153
+ // also accepts minimal, medium and xhigh; these are DeepSeek's own levels.
154
+ ["deepseek-ai/deepseek-v4.1-flash", { reasoningEfforts: ["none","low","high","max"], contextWindow: 1048576, maxOutputTokens: {"min":256,"max":384000}, fallbackRouting: true }],
155
+ ["deepseek-ai/deepseek-v4.1-flash-1017", { reasoningEfforts: ["none","low","high","max"], contextWindow: 1048576, maxOutputTokens: {"min":256,"max":384000}, fallbackRouting: true }],
156
+ ])],
157
+ ["morph", new Map([
158
+ // Morph's personal-subscription models, measured 2026-11-10 against
159
+ // https://api.morphllm.com/v1/chat/completions. Morph accepts none,
160
+ // minimal, low, medium, high, xhigh and max for every model; "none" turns
161
+ // thinking off. DeepSeek keeps its own levels (as on DeepInfra); Kimi K3.1
162
+ // thinks measurably deeper at each listed step. DeepSeek took a 945K-token
163
+ // prompt; Kimi K3.1 took 300K, declared conservatively at 256K.
164
+ ["morph-dsv41flash-1017", { reasoningEfforts: ["none","low","high","max"], contextWindow: 1048576, maxOutputTokens: {"min":256,"max":384000}, fallbackRouting: true }],
165
+ ["morph-dsv41flash", { reasoningEfforts: ["none","low","high","max"], contextWindow: 1048576, maxOutputTokens: {"min":256,"max":384000}, fallbackRouting: true }],
166
+ ["morph-kimik31", { reasoningEfforts: ["none","low","medium","high","max"], contextWindow: 262144, maxOutputTokens: {"min":256,"max":64000}, fallbackRouting: true }],
167
+ ])],
150
168
  ]);
151
169
 
152
- export const CONTRACT_PROVIDERS = Object.freeze(["anthropic","openai","gemini","deepseek","fireworks","openrouter","kimi","voyage","cohere","elevenlabs","replicate","fal","zai","modal","codex","self_hosted","openai_compatible","typesafe"]);
170
+ export const CONTRACT_PROVIDERS = Object.freeze(["anthropic","openai","gemini","deepseek","fireworks","openrouter","deepinfra","morph","kimi","voyage","cohere","elevenlabs","replicate","fal","zai","modal","codex","self_hosted","openai_compatible","typesafe"]);
153
171
 
154
172
  export function normalizeContractProvider(provider) {
155
173
  const normalized = provider.trim().toLowerCase();
@@ -0,0 +1 @@
1
+ export * from './sim_graph.js';
@@ -0,0 +1 @@
1
+ export * from './sim_graph.js';
@@ -0,0 +1,351 @@
1
+ /**
2
+ * SimGraph — FalkorDB Graph Backbone for Simulation
3
+ *
4
+ * Property graph storing entities, temporal facts, relationships,
5
+ * feed posts, and events. Replaces flat in-memory stores with
6
+ * structured, queryable graph data.
7
+ *
8
+ * Inspired by MiroFish/Graphiti's temporal knowledge graph but
9
+ * implemented natively in TypeScript with FalkorDBLite (embedded,
10
+ * no Docker, no Python).
11
+ */
12
+ /**
13
+ * Scalar + nested shape accepted by FalkorDB parameter binding. Mirrors
14
+ * the internal `QueryParam` type from the `falkordb` package (which is
15
+ * not exported) so consumers of `rawQuery` get the same strictness.
16
+ */
17
+ export type QueryParamValue = null | string | number | boolean | QueryParams | QueryParamValue[];
18
+ export interface QueryParams {
19
+ [key: string]: QueryParamValue;
20
+ }
21
+ export interface GraphFact {
22
+ id: string;
23
+ content: string;
24
+ category: string;
25
+ sourceTick: number;
26
+ validFrom: number;
27
+ invalidAt: number | null;
28
+ }
29
+ export interface GraphRelationship {
30
+ agentIdA: string;
31
+ agentIdB: string;
32
+ nameA: string;
33
+ nameB: string;
34
+ sentiment: number;
35
+ trust: number;
36
+ interactionCount: number;
37
+ lastNote: string | null;
38
+ }
39
+ export interface GraphFeedPost {
40
+ id: string;
41
+ content: string;
42
+ authorId: string;
43
+ authorName: string;
44
+ authorRole: string;
45
+ source: string;
46
+ createdAt: number;
47
+ replyTo: string | null;
48
+ reactionCount: number;
49
+ topicTags: string[];
50
+ }
51
+ export interface GraphContext {
52
+ facts: GraphFact[];
53
+ agents: Array<{
54
+ id: string;
55
+ name: string;
56
+ role: string;
57
+ }>;
58
+ relationships: GraphRelationship[];
59
+ }
60
+ export interface WorldView {
61
+ ownFacts: GraphFact[];
62
+ peerFacts: Array<{
63
+ peerName: string;
64
+ peerRole: string;
65
+ facts: GraphFact[];
66
+ }>;
67
+ topicFacts: GraphFact[];
68
+ }
69
+ export interface SimulationGraphFact {
70
+ id: string;
71
+ subjectId: string;
72
+ predicate: string;
73
+ objectId: string;
74
+ content: string;
75
+ validFrom: number;
76
+ invalidAt: number | null;
77
+ sourceEventId: string;
78
+ data: Record<string, unknown>;
79
+ }
80
+ export interface SimulationGraphFactInput {
81
+ id: string;
82
+ subjectId: string;
83
+ predicate: string;
84
+ objectId?: string;
85
+ content: string;
86
+ validFrom: number;
87
+ invalidAt?: number | null;
88
+ sourceEventId?: string;
89
+ supersedesIds?: string[];
90
+ data?: Record<string, unknown>;
91
+ }
92
+ export interface SimulationGraphEdge {
93
+ sourceId: string;
94
+ targetId: string;
95
+ type: string;
96
+ tick: number;
97
+ data: Record<string, unknown>;
98
+ }
99
+ export interface SimulationFactGraph {
100
+ schemaVersion: 1;
101
+ facts: SimulationGraphFact[];
102
+ edges: SimulationGraphEdge[];
103
+ }
104
+ export interface RecordSimulationFactInput {
105
+ graph?: SimulationFactGraph;
106
+ fact: SimulationGraphFactInput;
107
+ }
108
+ export interface ProjectActiveFactsInput {
109
+ graph: SimulationFactGraph;
110
+ atTick: number;
111
+ subjectIds?: string[];
112
+ predicates?: string[];
113
+ }
114
+ export interface SimulationNeighborhoodInput {
115
+ graph: SimulationFactGraph;
116
+ startIds: string[];
117
+ maxDepth?: number;
118
+ edgeTypes?: string[];
119
+ }
120
+ export interface SimulationNeighborhood {
121
+ schemaVersion: 1;
122
+ factIds: string[];
123
+ facts: SimulationGraphFact[];
124
+ edges: SimulationGraphEdge[];
125
+ depthByFactId: Record<string, number>;
126
+ }
127
+ export type SimulationFocusGraphDirection = 'in' | 'out' | 'both';
128
+ export interface SimulationFocusGraphNode {
129
+ id: string;
130
+ kind?: string;
131
+ label?: string;
132
+ data?: Record<string, unknown>;
133
+ }
134
+ export interface SimulationFocusGraphEdge {
135
+ sourceId: string;
136
+ targetId: string;
137
+ type: string;
138
+ createdAt?: string;
139
+ data: Record<string, unknown>;
140
+ }
141
+ export interface SimulationFocusRelationSpec {
142
+ name: string;
143
+ edgeTypes: string[];
144
+ direction?: SimulationFocusGraphDirection;
145
+ limit?: number;
146
+ }
147
+ export interface SimulationFocusLineageSpec {
148
+ edgeTypes: string[];
149
+ direction?: Exclude<SimulationFocusGraphDirection, 'both'>;
150
+ includeFocus?: boolean;
151
+ maxDepth?: number;
152
+ }
153
+ export interface BuildSimulationFocusGraphContextInput {
154
+ nodes?: SimulationFocusGraphNode[];
155
+ edges?: SimulationFocusGraphEdge[];
156
+ focusIds?: string[];
157
+ relations?: SimulationFocusRelationSpec[];
158
+ lineage?: SimulationFocusLineageSpec;
159
+ maxFocusIds?: number;
160
+ }
161
+ export interface SimulationFocusLineage {
162
+ focusId: string;
163
+ nodeIds: string[];
164
+ edgeTypes: string[];
165
+ edges: SimulationFocusGraphEdge[];
166
+ }
167
+ export interface SimulationFocusRelationGroup {
168
+ name: string;
169
+ focusId: string;
170
+ nodeIds: string[];
171
+ edges: SimulationFocusGraphEdge[];
172
+ }
173
+ export interface SimulationFocusGraphContext {
174
+ version: 1;
175
+ focusIds: string[];
176
+ lineages: SimulationFocusLineage[];
177
+ relationGroups: SimulationFocusRelationGroup[];
178
+ }
179
+ export interface SimulationSteeringEvent {
180
+ id: string;
181
+ eventType?: string;
182
+ acceptedSignalKinds?: string[];
183
+ subjectId?: string;
184
+ verdict?: string;
185
+ selectionStatus?: string;
186
+ createdAt?: string;
187
+ data?: Record<string, unknown>;
188
+ }
189
+ export interface SimulationSteeringSignal {
190
+ kind?: string;
191
+ subjectId?: string;
192
+ verdict?: string;
193
+ selectionStatus?: string;
194
+ priority?: number;
195
+ data?: Record<string, unknown>;
196
+ }
197
+ export interface SimulationSteeringTask {
198
+ id: string;
199
+ taskType?: string;
200
+ source?: string;
201
+ createdAt?: string;
202
+ signals?: SimulationSteeringSignal[];
203
+ }
204
+ export interface SimulationSteeringOutput {
205
+ id: string;
206
+ taskId: string;
207
+ outputType?: string;
208
+ createdAt?: string;
209
+ data?: Record<string, unknown>;
210
+ }
211
+ export interface SimulationSteeringInfluenceEdge {
212
+ sourceId: string;
213
+ targetId: string;
214
+ type: 'steering_influenced_task' | 'steering_influenced_output';
215
+ createdAt: string;
216
+ data: Record<string, unknown>;
217
+ }
218
+ export interface BuildSimulationSteeringInfluenceGraphInput {
219
+ steeringEvents?: SimulationSteeringEvent[];
220
+ tasks?: SimulationSteeringTask[];
221
+ outputs?: SimulationSteeringOutput[];
222
+ ignoreVerdictKinds?: string[];
223
+ }
224
+ export interface SimulationSteeringInfluenceGraph {
225
+ version: 1;
226
+ taskEdges: SimulationSteeringInfluenceEdge[];
227
+ outputEdges: SimulationSteeringInfluenceEdge[];
228
+ }
229
+ export interface SimulationRestartMemoryGraphStats {
230
+ nodes: number;
231
+ edges: number;
232
+ activeFactCount: number;
233
+ }
234
+ export interface SimulationRestartMemoryPacket<TFact = Record<string, unknown>> {
235
+ version: 1;
236
+ runId: string;
237
+ focusIds: string[];
238
+ activeFacts: TFact[];
239
+ graphStats: SimulationRestartMemoryGraphStats;
240
+ }
241
+ export interface BuildSimulationRestartMemoryInput<TFact = Record<string, unknown>> {
242
+ runId?: string;
243
+ focusIds?: string[];
244
+ activeFacts?: TFact[];
245
+ graphStats?: Partial<SimulationRestartMemoryGraphStats>;
246
+ maxFocusIds?: number;
247
+ }
248
+ export declare function recordSimulationFact(input: RecordSimulationFactInput): SimulationFactGraph;
249
+ export declare function projectActiveFacts(input: ProjectActiveFactsInput): SimulationGraphFact[];
250
+ export declare function traverseSimulationNeighborhood(input: SimulationNeighborhoodInput): SimulationNeighborhood;
251
+ export declare function buildSimulationFocusGraphContext(input: BuildSimulationFocusGraphContextInput): SimulationFocusGraphContext;
252
+ export declare function buildSimulationSteeringInfluenceGraph(input: BuildSimulationSteeringInfluenceGraphInput): SimulationSteeringInfluenceGraph;
253
+ export declare function buildSimulationRestartMemory<TFact = Record<string, unknown>>(input: BuildSimulationRestartMemoryInput<TFact>): SimulationRestartMemoryPacket<TFact>;
254
+ export declare class SimGraph {
255
+ private db;
256
+ private graph;
257
+ /** Per-instance counter (review #8: avoid module-level mutable state) */
258
+ private factCounter;
259
+ private constructor();
260
+ /**
261
+ * Open an embedded FalkorDB instance and select the simulation graph.
262
+ * If dataPath is provided, data persists to disk.
263
+ */
264
+ static open(dataPath?: string): Promise<SimGraph>;
265
+ /** Close the graph database and stop the embedded server. */
266
+ close(): Promise<void>;
267
+ /**
268
+ * Escape hatch for domain-specific adapters that want to use labels/
269
+ * relationships outside the built-in schema (e.g. cybersim's `:CS*`
270
+ * nodes). Returned shape matches FalkorDB's `graph.query` result.
271
+ */
272
+ rawQuery<T = Record<string, unknown>>(cypher: string, params?: QueryParams): Promise<{
273
+ data?: T[];
274
+ }>;
275
+ /**
276
+ * Register a range index on a node label/property pair. Safe to call
277
+ * for already-indexed pairs — creation errors are swallowed.
278
+ */
279
+ ensureNodeIndex(label: string, property: string): Promise<void>;
280
+ /** Create indices for common query patterns. */
281
+ private initSchema;
282
+ addAgent(agent: {
283
+ id: string;
284
+ name: string;
285
+ role: string;
286
+ organization: string;
287
+ type: 'internal' | 'external';
288
+ }): Promise<void>;
289
+ addCompany(company: {
290
+ id: string;
291
+ name: string;
292
+ industry: string;
293
+ stage: string;
294
+ }): Promise<void>;
295
+ addCompetitor(companyIdA: string, companyIdB: string): Promise<void>;
296
+ addWorksAt(agentId: string, companyId: string): Promise<void>;
297
+ /** Add a fact stated by an agent. Returns the fact ID. */
298
+ addFact(agentId: string, content: string, category: string, tick: number, aboutEntityId?: string): Promise<string>;
299
+ /** Invalidate a fact at the given tick. */
300
+ invalidateFact(factId: string, tick: number): Promise<void>;
301
+ /**
302
+ * Add a fact, checking for contradictions. If the same agent has
303
+ * a current fact in the same category about the same entity,
304
+ * invalidate the old fact and create a SUPERSEDES edge.
305
+ */
306
+ addFactWithSupersede(agentId: string, content: string, category: string, tick: number, aboutEntityId?: string): Promise<string>;
307
+ /** Get all facts stated by an agent. */
308
+ getAgentFacts(agentId: string, currentOnly?: boolean): Promise<GraphFact[]>;
309
+ /** Get all facts about an entity. */
310
+ getFactsAbout(entityId: string, currentOnly?: boolean): Promise<GraphFact[]>;
311
+ /** Get facts matching a keyword in content. */
312
+ getFactsByKeyword(keyword: string, currentOnly?: boolean): Promise<GraphFact[]>;
313
+ setRelationship(agentIdA: string, agentIdB: string, sentiment: number, trust: number, interactionCount: number, note?: string): Promise<void>;
314
+ /** Review #12: Query both directions for KNOWS relationship. */
315
+ getRelationship(agentIdA: string, agentIdB: string): Promise<GraphRelationship | null>;
316
+ getRelationshipsFor(agentId: string): Promise<GraphRelationship[]>;
317
+ addPost(post: {
318
+ id: string;
319
+ content: string;
320
+ authorId: string;
321
+ authorName: string;
322
+ authorRole: string;
323
+ source: string;
324
+ tick: number;
325
+ replyTo?: string;
326
+ topicTags?: string[];
327
+ }): Promise<void>;
328
+ addReaction(agentId: string, postId: string): Promise<void>;
329
+ getRecentPosts(limit?: number, sinceTick?: number): Promise<GraphFeedPost[]>;
330
+ addEvent(event: {
331
+ id: string;
332
+ type: string;
333
+ description: string;
334
+ tick: number;
335
+ participantIds: string[];
336
+ }): Promise<void>;
337
+ /**
338
+ * Get an agent's full world view at a given tick:
339
+ * - Facts they've stated (current)
340
+ * - Facts their peers have stated (current)
341
+ * - Facts about topics they've discussed
342
+ */
343
+ getAgentWorldView(agentId: string, tick: number): Promise<WorldView>;
344
+ /**
345
+ * Get context around any entity — all facts, agents, and relationships.
346
+ * Review #9: removed unused depth param (queries are always 1-hop).
347
+ */
348
+ getEntityContext(entityId: string): Promise<GraphContext>;
349
+ private parseFactRows;
350
+ private parsePostRows;
351
+ }