@hazeljs/organism 2.0.6
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 +205 -0
- package/dist/__tests__/organism.embedding.test.d.ts +2 -0
- package/dist/__tests__/organism.embedding.test.d.ts.map +1 -0
- package/dist/__tests__/organism.embedding.test.js +166 -0
- package/dist/__tests__/organism.embedding.test.js.map +1 -0
- package/dist/__tests__/organism.phase1.test.d.ts +2 -0
- package/dist/__tests__/organism.phase1.test.d.ts.map +1 -0
- package/dist/__tests__/organism.phase1.test.js +375 -0
- package/dist/__tests__/organism.phase1.test.js.map +1 -0
- package/dist/__tests__/organism.phase2-3.test.d.ts +2 -0
- package/dist/__tests__/organism.phase2-3.test.d.ts.map +1 -0
- package/dist/__tests__/organism.phase2-3.test.js +320 -0
- package/dist/__tests__/organism.phase2-3.test.js.map +1 -0
- package/dist/__tests__/organism.phase4.test.d.ts +2 -0
- package/dist/__tests__/organism.phase4.test.d.ts.map +1 -0
- package/dist/__tests__/organism.phase4.test.js +217 -0
- package/dist/__tests__/organism.phase4.test.js.map +1 -0
- package/dist/bridge/signal-bridge.d.ts +46 -0
- package/dist/bridge/signal-bridge.d.ts.map +1 -0
- package/dist/bridge/signal-bridge.js +75 -0
- package/dist/bridge/signal-bridge.js.map +1 -0
- package/dist/core/capability-registry.d.ts +16 -0
- package/dist/core/capability-registry.d.ts.map +1 -0
- package/dist/core/capability-registry.js +71 -0
- package/dist/core/capability-registry.js.map +1 -0
- package/dist/core/clock.d.ts +17 -0
- package/dist/core/clock.d.ts.map +1 -0
- package/dist/core/clock.js +63 -0
- package/dist/core/clock.js.map +1 -0
- package/dist/core/mission.d.ts +4 -0
- package/dist/core/mission.d.ts.map +1 -0
- package/dist/core/mission.js +74 -0
- package/dist/core/mission.js.map +1 -0
- package/dist/core/organism-context.d.ts +139 -0
- package/dist/core/organism-context.d.ts.map +1 -0
- package/dist/core/organism-context.js +62 -0
- package/dist/core/organism-context.js.map +1 -0
- package/dist/core/organism-runtime.d.ts +199 -0
- package/dist/core/organism-runtime.d.ts.map +1 -0
- package/dist/core/organism-runtime.js +1016 -0
- package/dist/core/organism-runtime.js.map +1 -0
- package/dist/decorators/index.d.ts +39 -0
- package/dist/decorators/index.d.ts.map +1 -0
- package/dist/decorators/index.js +165 -0
- package/dist/decorators/index.js.map +1 -0
- package/dist/economy/market-engine.d.ts +57 -0
- package/dist/economy/market-engine.d.ts.map +1 -0
- package/dist/economy/market-engine.js +258 -0
- package/dist/economy/market-engine.js.map +1 -0
- package/dist/economy/resource-allocator.d.ts +39 -0
- package/dist/economy/resource-allocator.d.ts.map +1 -0
- package/dist/economy/resource-allocator.js +153 -0
- package/dist/economy/resource-allocator.js.map +1 -0
- package/dist/economy/utility-engine.d.ts +16 -0
- package/dist/economy/utility-engine.d.ts.map +1 -0
- package/dist/economy/utility-engine.js +80 -0
- package/dist/economy/utility-engine.js.map +1 -0
- package/dist/economy/utility-forecaster.d.ts +24 -0
- package/dist/economy/utility-forecaster.d.ts.map +1 -0
- package/dist/economy/utility-forecaster.js +60 -0
- package/dist/economy/utility-forecaster.js.map +1 -0
- package/dist/errors/organism.errors.d.ts +23 -0
- package/dist/errors/organism.errors.d.ts.map +1 -0
- package/dist/errors/organism.errors.js +50 -0
- package/dist/errors/organism.errors.js.map +1 -0
- package/dist/events/organism-events.d.ts +61 -0
- package/dist/events/organism-events.d.ts.map +1 -0
- package/dist/events/organism-events.js +95 -0
- package/dist/events/organism-events.js.map +1 -0
- package/dist/evolution/evolution-engine.d.ts +41 -0
- package/dist/evolution/evolution-engine.d.ts.map +1 -0
- package/dist/evolution/evolution-engine.js +135 -0
- package/dist/evolution/evolution-engine.js.map +1 -0
- package/dist/evolution/mutation-engine.d.ts +21 -0
- package/dist/evolution/mutation-engine.d.ts.map +1 -0
- package/dist/evolution/mutation-engine.js +84 -0
- package/dist/evolution/mutation-engine.js.map +1 -0
- package/dist/genealogy/genealogy-manager.d.ts +18 -0
- package/dist/genealogy/genealogy-manager.d.ts.map +1 -0
- package/dist/genealogy/genealogy-manager.js +64 -0
- package/dist/genealogy/genealogy-manager.js.map +1 -0
- package/dist/governance/constitution.d.ts +20 -0
- package/dist/governance/constitution.d.ts.map +1 -0
- package/dist/governance/constitution.js +109 -0
- package/dist/governance/constitution.js.map +1 -0
- package/dist/host/organism-host-registry.d.ts +24 -0
- package/dist/host/organism-host-registry.d.ts.map +1 -0
- package/dist/host/organism-host-registry.js +65 -0
- package/dist/host/organism-host-registry.js.map +1 -0
- package/dist/host/organism-host.d.ts +32 -0
- package/dist/host/organism-host.d.ts.map +1 -0
- package/dist/host/organism-host.js +64 -0
- package/dist/host/organism-host.js.map +1 -0
- package/dist/index.d.ts +43 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +117 -0
- package/dist/index.js.map +1 -0
- package/dist/integration/create-ops-organism.d.ts +34 -0
- package/dist/integration/create-ops-organism.d.ts.map +1 -0
- package/dist/integration/create-ops-organism.js +43 -0
- package/dist/integration/create-ops-organism.js.map +1 -0
- package/dist/lifecycle/birth-engine.d.ts +41 -0
- package/dist/lifecycle/birth-engine.d.ts.map +1 -0
- package/dist/lifecycle/birth-engine.js +182 -0
- package/dist/lifecycle/birth-engine.js.map +1 -0
- package/dist/lifecycle/decision-engine.d.ts +19 -0
- package/dist/lifecycle/decision-engine.d.ts.map +1 -0
- package/dist/lifecycle/decision-engine.js +137 -0
- package/dist/lifecycle/decision-engine.js.map +1 -0
- package/dist/lifecycle/reproduction-engine.d.ts +58 -0
- package/dist/lifecycle/reproduction-engine.d.ts.map +1 -0
- package/dist/lifecycle/reproduction-engine.js +207 -0
- package/dist/lifecycle/reproduction-engine.js.map +1 -0
- package/dist/lifecycle/survival-engine.d.ts +17 -0
- package/dist/lifecycle/survival-engine.d.ts.map +1 -0
- package/dist/lifecycle/survival-engine.js +83 -0
- package/dist/lifecycle/survival-engine.js.map +1 -0
- package/dist/observability/metrics.d.ts +37 -0
- package/dist/observability/metrics.d.ts.map +1 -0
- package/dist/observability/metrics.js +80 -0
- package/dist/observability/metrics.js.map +1 -0
- package/dist/perception/perception-engine.d.ts +40 -0
- package/dist/perception/perception-engine.d.ts.map +1 -0
- package/dist/perception/perception-engine.js +126 -0
- package/dist/perception/perception-engine.js.map +1 -0
- package/dist/persistence/in-memory-organism-repository.d.ts +2 -0
- package/dist/persistence/in-memory-organism-repository.d.ts.map +1 -0
- package/dist/persistence/in-memory-organism-repository.js +18 -0
- package/dist/persistence/in-memory-organism-repository.js.map +1 -0
- package/dist/persistence/organism-repository.d.ts +42 -0
- package/dist/persistence/organism-repository.d.ts.map +1 -0
- package/dist/persistence/organism-repository.js +105 -0
- package/dist/persistence/organism-repository.js.map +1 -0
- package/dist/types/organism.types.d.ts +482 -0
- package/dist/types/organism.types.d.ts.map +1 -0
- package/dist/types/organism.types.js +45 -0
- package/dist/types/organism.types.js.map +1 -0
- package/examples/ecommerce-organism/run.ts +245 -0
- package/package.json +73 -0
- package/src/bridge/signal-bridge.ts +116 -0
- package/src/core/capability-registry.ts +72 -0
- package/src/core/clock.ts +58 -0
- package/src/core/mission.ts +83 -0
- package/src/core/organism-context.ts +176 -0
- package/src/core/organism-runtime.ts +1369 -0
- package/src/decorators/index.ts +180 -0
- package/src/economy/market-engine.ts +324 -0
- package/src/economy/resource-allocator.ts +188 -0
- package/src/economy/utility-engine.ts +103 -0
- package/src/economy/utility-forecaster.ts +88 -0
- package/src/errors/organism.errors.ts +47 -0
- package/src/events/organism-events.ts +122 -0
- package/src/evolution/evolution-engine.ts +167 -0
- package/src/evolution/mutation-engine.ts +110 -0
- package/src/genealogy/genealogy-manager.ts +70 -0
- package/src/governance/constitution.ts +120 -0
- package/src/host/organism-host-registry.ts +72 -0
- package/src/host/organism-host.ts +103 -0
- package/src/index.ts +78 -0
- package/src/integration/create-ops-organism.ts +80 -0
- package/src/lifecycle/birth-engine.ts +225 -0
- package/src/lifecycle/decision-engine.ts +158 -0
- package/src/lifecycle/reproduction-engine.ts +289 -0
- package/src/lifecycle/survival-engine.ts +95 -0
- package/src/observability/metrics.ts +120 -0
- package/src/perception/perception-engine.ts +140 -0
- package/src/persistence/in-memory-organism-repository.ts +1 -0
- package/src/persistence/organism-repository.ts +134 -0
- package/src/types/organism.types.ts +591 -0
- package/tsconfig.jest.json +8 -0
|
@@ -0,0 +1,591 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @hazeljs/organism — core type definitions
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export type OrganismStatus =
|
|
6
|
+
| 'created'
|
|
7
|
+
| 'initializing'
|
|
8
|
+
| 'observing'
|
|
9
|
+
| 'planning'
|
|
10
|
+
| 'operating'
|
|
11
|
+
| 'degraded'
|
|
12
|
+
| 'paused'
|
|
13
|
+
| 'completed'
|
|
14
|
+
| 'failed'
|
|
15
|
+
| 'terminated';
|
|
16
|
+
|
|
17
|
+
export type RuntimeAgentStatus =
|
|
18
|
+
| 'conceived'
|
|
19
|
+
| 'initializing'
|
|
20
|
+
| 'active'
|
|
21
|
+
| 'idle'
|
|
22
|
+
| 'specializing'
|
|
23
|
+
| 'reproducing'
|
|
24
|
+
| 'suspended'
|
|
25
|
+
| 'termination-pending'
|
|
26
|
+
| 'terminated'
|
|
27
|
+
| 'failed';
|
|
28
|
+
|
|
29
|
+
export type MissionMetricOperator = 'gt' | 'gte' | 'lt' | 'lte' | 'eq' | 'maximize' | 'minimize';
|
|
30
|
+
|
|
31
|
+
export interface MissionMetric {
|
|
32
|
+
name: string;
|
|
33
|
+
operator: MissionMetricOperator;
|
|
34
|
+
target?: number;
|
|
35
|
+
weight?: number;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface MissionPriority {
|
|
39
|
+
name: string;
|
|
40
|
+
weight: number;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface MissionDefinition {
|
|
44
|
+
id: string;
|
|
45
|
+
objective: string;
|
|
46
|
+
description?: string;
|
|
47
|
+
horizon?: string | number;
|
|
48
|
+
successCriteria?: MissionMetric[];
|
|
49
|
+
constraints?: string[];
|
|
50
|
+
priorities?: MissionPriority[];
|
|
51
|
+
metadata?: Record<string, unknown>;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface ResourceLimits {
|
|
55
|
+
tokens?: number;
|
|
56
|
+
money?: { amount: number; currency: string };
|
|
57
|
+
computeUnits?: number;
|
|
58
|
+
toolCalls?: number;
|
|
59
|
+
maxConcurrentAgents?: number;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface AgentGeneDefinition {
|
|
63
|
+
id: string;
|
|
64
|
+
description?: string;
|
|
65
|
+
capabilities: string[];
|
|
66
|
+
tools?: unknown[];
|
|
67
|
+
initialPrompt?: string;
|
|
68
|
+
policies?: string[];
|
|
69
|
+
resourceLimits?: ResourceLimits;
|
|
70
|
+
reproduction?: {
|
|
71
|
+
enabled: boolean;
|
|
72
|
+
maxChildren?: number;
|
|
73
|
+
};
|
|
74
|
+
mutation?: {
|
|
75
|
+
enabled: boolean;
|
|
76
|
+
allowedProperties?: string[];
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export type ConstitutionSeverity = 'critical' | 'high' | 'medium' | 'low';
|
|
81
|
+
|
|
82
|
+
export interface ConstitutionRule {
|
|
83
|
+
id: string;
|
|
84
|
+
rule: string;
|
|
85
|
+
severity: ConstitutionSeverity;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export interface ConstitutionDefinition {
|
|
89
|
+
id: string;
|
|
90
|
+
rules: ConstitutionRule[];
|
|
91
|
+
description?: string;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export interface EnvironmentSignal {
|
|
95
|
+
id: string;
|
|
96
|
+
type: string;
|
|
97
|
+
source: string;
|
|
98
|
+
timestamp: Date;
|
|
99
|
+
data: unknown;
|
|
100
|
+
severity?: number;
|
|
101
|
+
relevance?: number;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export interface EnvironmentSourceDefinition {
|
|
105
|
+
id: string;
|
|
106
|
+
publish?: (signal: EnvironmentSignal) => void | Promise<void>;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export interface EnvironmentDefinition {
|
|
110
|
+
id: string;
|
|
111
|
+
sources?: EnvironmentSourceDefinition[];
|
|
112
|
+
description?: string;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export interface ResourceDefinition {
|
|
116
|
+
id?: string;
|
|
117
|
+
monthlyBudget?: { amount: number; currency: string };
|
|
118
|
+
tokenBudget?: number;
|
|
119
|
+
maxConcurrentAgents?: number;
|
|
120
|
+
computeUnits?: number;
|
|
121
|
+
toolCalls?: number;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export interface OrganismLimits {
|
|
125
|
+
maxAgents: number;
|
|
126
|
+
maxGenerationDepth: number;
|
|
127
|
+
maxChildrenPerAgent: number;
|
|
128
|
+
maxSpawnRatePerMinute: number;
|
|
129
|
+
maxTotalCostPerHour: number;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export interface OrganismCycleConfig {
|
|
133
|
+
perception?: string | number;
|
|
134
|
+
evaluation?: string | number;
|
|
135
|
+
survival?: string | number;
|
|
136
|
+
missionEvaluation?: string | number;
|
|
137
|
+
resourceAllocation?: string | number;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export interface AgentResourceWallet {
|
|
141
|
+
tokensRemaining?: number;
|
|
142
|
+
moneyRemaining?: { amount: number; currency: string };
|
|
143
|
+
computeUnitsRemaining?: number;
|
|
144
|
+
toolCallsRemaining?: number;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export interface AgentReputation {
|
|
148
|
+
agentId: string;
|
|
149
|
+
score: number;
|
|
150
|
+
dimensions: {
|
|
151
|
+
usefulness: number;
|
|
152
|
+
reliability: number;
|
|
153
|
+
efficiency: number;
|
|
154
|
+
policyCompliance: number;
|
|
155
|
+
collaboration: number;
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export interface UtilityScore {
|
|
160
|
+
score: number;
|
|
161
|
+
valueGenerated: number;
|
|
162
|
+
cost: number;
|
|
163
|
+
riskPenalty: number;
|
|
164
|
+
confidence: number;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export interface UtilityWeights {
|
|
168
|
+
missionContribution: number;
|
|
169
|
+
reliability: number;
|
|
170
|
+
efficiency: number;
|
|
171
|
+
policyCompliance: number;
|
|
172
|
+
collaboration: number;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
export const DEFAULT_UTILITY_WEIGHTS: UtilityWeights = {
|
|
176
|
+
missionContribution: 0.35,
|
|
177
|
+
reliability: 0.2,
|
|
178
|
+
efficiency: 0.2,
|
|
179
|
+
policyCompliance: 0.15,
|
|
180
|
+
collaboration: 0.1,
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
export const DEFAULT_ORGANISM_LIMITS: OrganismLimits = {
|
|
184
|
+
maxAgents: 25,
|
|
185
|
+
maxGenerationDepth: 5,
|
|
186
|
+
maxChildrenPerAgent: 3,
|
|
187
|
+
maxSpawnRatePerMinute: 5,
|
|
188
|
+
maxTotalCostPerHour: 10,
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
export interface AgentGenealogy {
|
|
192
|
+
agentId: string;
|
|
193
|
+
parentAgentId?: string;
|
|
194
|
+
rootGeneId: string;
|
|
195
|
+
generation: number;
|
|
196
|
+
children: string[];
|
|
197
|
+
createdAt: Date;
|
|
198
|
+
terminatedAt?: Date;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
export interface AgentMutation {
|
|
202
|
+
promptChanges?: string[];
|
|
203
|
+
addedCapabilities?: string[];
|
|
204
|
+
removedCapabilities?: string[];
|
|
205
|
+
modelConfig?: Record<string, unknown>;
|
|
206
|
+
strategyConfig?: Record<string, unknown>;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
export interface AgentBirthProposal {
|
|
210
|
+
reason: string;
|
|
211
|
+
needId: string;
|
|
212
|
+
requiredCapabilities: string[];
|
|
213
|
+
expectedOutcome: string;
|
|
214
|
+
estimatedCost?: number;
|
|
215
|
+
expectedUtility?: number;
|
|
216
|
+
terminationCriteria?: string[];
|
|
217
|
+
confidence: number;
|
|
218
|
+
geneId?: string;
|
|
219
|
+
specialize?: string[];
|
|
220
|
+
parentAgentId?: string;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
export interface DetectedNeed {
|
|
224
|
+
need: string;
|
|
225
|
+
reason: string;
|
|
226
|
+
requiredCapabilities: string[];
|
|
227
|
+
urgency: number;
|
|
228
|
+
confidence: number;
|
|
229
|
+
signalId?: string;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
export type OrganismDecisionAction =
|
|
233
|
+
| 'delegate'
|
|
234
|
+
| 'spawn'
|
|
235
|
+
| 'specialize'
|
|
236
|
+
| 'reproduce'
|
|
237
|
+
| 'terminate'
|
|
238
|
+
| 'reallocate'
|
|
239
|
+
| 'observe';
|
|
240
|
+
|
|
241
|
+
export interface ResourceRequest {
|
|
242
|
+
tokens?: number;
|
|
243
|
+
money?: number;
|
|
244
|
+
computeUnits?: number;
|
|
245
|
+
toolCalls?: number;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
export interface OrganismDecision {
|
|
249
|
+
action: OrganismDecisionAction;
|
|
250
|
+
reasoningSummary: string;
|
|
251
|
+
confidence: number;
|
|
252
|
+
targetAgentId?: string;
|
|
253
|
+
requiredCapabilities?: string[];
|
|
254
|
+
resourceRequest?: ResourceRequest;
|
|
255
|
+
birthProposal?: AgentBirthProposal;
|
|
256
|
+
needId?: string;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
export interface AgentOutcomeReport {
|
|
260
|
+
taskId?: string;
|
|
261
|
+
result: string;
|
|
262
|
+
metrics?: {
|
|
263
|
+
valueGenerated?: number;
|
|
264
|
+
confidence?: number;
|
|
265
|
+
cost?: number;
|
|
266
|
+
riskPenalty?: number;
|
|
267
|
+
[key: string]: number | undefined;
|
|
268
|
+
};
|
|
269
|
+
evidence?: string[];
|
|
270
|
+
missionMetricUpdates?: Record<string, number>;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
export interface RuntimeAgentRecord {
|
|
274
|
+
id: string;
|
|
275
|
+
name: string;
|
|
276
|
+
objective: string;
|
|
277
|
+
capabilities: string[];
|
|
278
|
+
geneId: string;
|
|
279
|
+
parentAgentId?: string;
|
|
280
|
+
generation: number;
|
|
281
|
+
status: RuntimeAgentStatus;
|
|
282
|
+
reputation: AgentReputation;
|
|
283
|
+
utility: UtilityScore;
|
|
284
|
+
wallet: AgentResourceWallet;
|
|
285
|
+
birthProposal: AgentBirthProposal;
|
|
286
|
+
terminationCriteria: string[];
|
|
287
|
+
createdAt: Date;
|
|
288
|
+
terminatedAt?: Date;
|
|
289
|
+
evaluationCount: number;
|
|
290
|
+
lastEvaluatedAt?: Date;
|
|
291
|
+
criticalResponsibility: boolean;
|
|
292
|
+
costConsumed: number;
|
|
293
|
+
tokensConsumed: number;
|
|
294
|
+
valueGenerated: number;
|
|
295
|
+
specialize?: string[];
|
|
296
|
+
dnaAgentName: string;
|
|
297
|
+
/** Inherited / mutable system prompt fragment. */
|
|
298
|
+
systemPrompt?: string;
|
|
299
|
+
/** Capability grants / permission tags — child must be subset of parent. */
|
|
300
|
+
permissions: string[];
|
|
301
|
+
/** Safe strategy configuration (mutable under mutation policy). */
|
|
302
|
+
strategyConfig: Record<string, unknown>;
|
|
303
|
+
/** Safe model preference config (mutable under mutation policy). */
|
|
304
|
+
modelConfig: Record<string, unknown>;
|
|
305
|
+
/** Auditable mutation history. */
|
|
306
|
+
mutations: AgentMutationRecord[];
|
|
307
|
+
/** Strategy cohort id for evolutionary evaluation. */
|
|
308
|
+
strategyId?: string;
|
|
309
|
+
lastReproductionAt?: Date;
|
|
310
|
+
lastMutationAt?: Date;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
export type InheritanceMemoryStrategy = 'none' | 'relevant-only' | 'all';
|
|
314
|
+
|
|
315
|
+
export interface InheritancePolicy {
|
|
316
|
+
mission?: boolean;
|
|
317
|
+
constitution?: boolean;
|
|
318
|
+
permissions?: 'subset' | 'none' | 'copy';
|
|
319
|
+
memory?: {
|
|
320
|
+
strategy: InheritanceMemoryStrategy;
|
|
321
|
+
maxItems?: number;
|
|
322
|
+
};
|
|
323
|
+
tools?: boolean;
|
|
324
|
+
skills?: boolean;
|
|
325
|
+
context?: boolean;
|
|
326
|
+
strategies?: boolean;
|
|
327
|
+
modelSettings?: boolean;
|
|
328
|
+
resources?: {
|
|
329
|
+
/** Fraction of parent wallet tokens/money transferred (0-1). Default 0.25. */
|
|
330
|
+
transferFraction?: number;
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
export const DEFAULT_INHERITANCE_POLICY: InheritancePolicy = {
|
|
335
|
+
mission: true,
|
|
336
|
+
constitution: true,
|
|
337
|
+
permissions: 'subset',
|
|
338
|
+
memory: { strategy: 'relevant-only', maxItems: 100 },
|
|
339
|
+
tools: true,
|
|
340
|
+
skills: true,
|
|
341
|
+
context: false,
|
|
342
|
+
strategies: true,
|
|
343
|
+
modelSettings: true,
|
|
344
|
+
resources: { transferFraction: 0.25 },
|
|
345
|
+
};
|
|
346
|
+
|
|
347
|
+
export interface ReproduceRequest {
|
|
348
|
+
reason: string;
|
|
349
|
+
specialization?: string[];
|
|
350
|
+
objective?: string;
|
|
351
|
+
needId?: string;
|
|
352
|
+
inheritance?: InheritancePolicy;
|
|
353
|
+
tokens?: number;
|
|
354
|
+
confidence?: number;
|
|
355
|
+
terminationCriteria?: string[];
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
export interface AgentMutationRecord {
|
|
359
|
+
id: string;
|
|
360
|
+
at: Date;
|
|
361
|
+
mutation: AgentMutation;
|
|
362
|
+
reason: string;
|
|
363
|
+
parentStrategyId?: string;
|
|
364
|
+
resultingStrategyId?: string;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
export interface GenerationMemberScore {
|
|
368
|
+
agentId: string;
|
|
369
|
+
score: number;
|
|
370
|
+
utility: number;
|
|
371
|
+
reputation: number;
|
|
372
|
+
cost: number;
|
|
373
|
+
policyCompliance: number;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
export interface GenerationEvaluationResult {
|
|
377
|
+
populationId: string;
|
|
378
|
+
winner: string;
|
|
379
|
+
scores: Record<string, number>;
|
|
380
|
+
members: GenerationMemberScore[];
|
|
381
|
+
promotedStrategyId?: string;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
export interface EvolutionaryHistoryEntry {
|
|
385
|
+
at: Date;
|
|
386
|
+
populationId: string;
|
|
387
|
+
winnerAgentId: string;
|
|
388
|
+
scores: Record<string, number>;
|
|
389
|
+
promotedStrategyId?: string;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
export interface MissionProgress {
|
|
393
|
+
missionId: string;
|
|
394
|
+
objective: string;
|
|
395
|
+
metrics: Record<string, number>;
|
|
396
|
+
criteriaMet: Record<string, boolean>;
|
|
397
|
+
completed: boolean;
|
|
398
|
+
updatedAt: Date;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
export interface OrganismRecord {
|
|
402
|
+
id: string;
|
|
403
|
+
status: OrganismStatus;
|
|
404
|
+
mission: MissionDefinition;
|
|
405
|
+
constitution?: ConstitutionDefinition;
|
|
406
|
+
environment?: EnvironmentDefinition;
|
|
407
|
+
genes: AgentGeneDefinition[];
|
|
408
|
+
resources: ResourceDefinition;
|
|
409
|
+
limits: OrganismLimits;
|
|
410
|
+
cycles: OrganismCycleConfig;
|
|
411
|
+
missionProgress: MissionProgress;
|
|
412
|
+
pool: {
|
|
413
|
+
tokensRemaining: number;
|
|
414
|
+
moneyRemaining: { amount: number; currency: string };
|
|
415
|
+
costSpentThisHour: number;
|
|
416
|
+
};
|
|
417
|
+
debug: boolean;
|
|
418
|
+
simulation: boolean;
|
|
419
|
+
createdAt: Date;
|
|
420
|
+
updatedAt: Date;
|
|
421
|
+
emergencyStopped: boolean;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
export interface OrganismGraphNode {
|
|
425
|
+
id: string;
|
|
426
|
+
label: string;
|
|
427
|
+
status: RuntimeAgentStatus;
|
|
428
|
+
generation: number;
|
|
429
|
+
utility: number;
|
|
430
|
+
reputation: number;
|
|
431
|
+
cost: number;
|
|
432
|
+
tokens: number;
|
|
433
|
+
objective: string;
|
|
434
|
+
geneId: string;
|
|
435
|
+
parentId?: string;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
export interface OrganismGraphEdge {
|
|
439
|
+
from: string;
|
|
440
|
+
to: string;
|
|
441
|
+
kind: 'parent' | 'gene';
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
export interface OrganismGraph {
|
|
445
|
+
nodes: OrganismGraphNode[];
|
|
446
|
+
edges: OrganismGraphEdge[];
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
export interface OrganismInspectState {
|
|
450
|
+
mission: MissionDefinition;
|
|
451
|
+
missionProgress: MissionProgress;
|
|
452
|
+
status: OrganismStatus;
|
|
453
|
+
agents: Array<{
|
|
454
|
+
id: string;
|
|
455
|
+
objective: string;
|
|
456
|
+
capabilities: string[];
|
|
457
|
+
parentId?: string;
|
|
458
|
+
generation: number;
|
|
459
|
+
status: RuntimeAgentStatus;
|
|
460
|
+
reputation: AgentReputation;
|
|
461
|
+
utility: UtilityScore;
|
|
462
|
+
resourceConsumption: { tokens: number; cost: number };
|
|
463
|
+
}>;
|
|
464
|
+
resources: {
|
|
465
|
+
pool: OrganismRecord['pool'];
|
|
466
|
+
limits: OrganismLimits;
|
|
467
|
+
};
|
|
468
|
+
recentSignals: EnvironmentSignal[];
|
|
469
|
+
recentDecisions: OrganismDecision[];
|
|
470
|
+
genealogy: AgentGenealogy[];
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
export interface SignalNeedMapping {
|
|
474
|
+
signalType: string;
|
|
475
|
+
need: string;
|
|
476
|
+
requiredCapabilities: string[];
|
|
477
|
+
urgency?: number;
|
|
478
|
+
confidence?: number;
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
export interface SurvivalConfig {
|
|
482
|
+
minimumUtility: number;
|
|
483
|
+
minimumEvaluationAgeMs: number;
|
|
484
|
+
minimumSampleSize: number;
|
|
485
|
+
cooldownMs: number;
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
export const DEFAULT_SURVIVAL_CONFIG: SurvivalConfig = {
|
|
489
|
+
minimumUtility: 0.2,
|
|
490
|
+
minimumEvaluationAgeMs: 60_000,
|
|
491
|
+
minimumSampleSize: 3,
|
|
492
|
+
cooldownMs: 30_000,
|
|
493
|
+
};
|
|
494
|
+
|
|
495
|
+
export type SurvivalState =
|
|
496
|
+
| 'healthy'
|
|
497
|
+
| 'watch'
|
|
498
|
+
| 'resource-reduced'
|
|
499
|
+
| 'candidate-for-termination'
|
|
500
|
+
| 'terminated';
|
|
501
|
+
|
|
502
|
+
/** Phase 4 — agent economy */
|
|
503
|
+
|
|
504
|
+
export type ResourceBidStatus = 'open' | 'won' | 'lost' | 'cancelled' | 'expired';
|
|
505
|
+
|
|
506
|
+
export interface ResourceBid {
|
|
507
|
+
id: string;
|
|
508
|
+
agentId: string;
|
|
509
|
+
reason: string;
|
|
510
|
+
requested: ResourceRequest;
|
|
511
|
+
/** Estimated mission value if granted (absolute units). */
|
|
512
|
+
expectedValue: number;
|
|
513
|
+
confidence: number;
|
|
514
|
+
urgency: number;
|
|
515
|
+
/** Optional willingness-to-pay in pool money units. */
|
|
516
|
+
bidPrice?: number;
|
|
517
|
+
createdAt: Date;
|
|
518
|
+
expiresAt?: Date;
|
|
519
|
+
status: ResourceBidStatus;
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
export interface UtilityForecast {
|
|
523
|
+
agentId: string;
|
|
524
|
+
expectedUtility: number;
|
|
525
|
+
expectedValue: number;
|
|
526
|
+
estimatedCost: number;
|
|
527
|
+
opportunityCost: number;
|
|
528
|
+
netExpectedValue: number;
|
|
529
|
+
confidence: number;
|
|
530
|
+
reasoningSummary: string;
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
export interface OpportunityCostEstimate {
|
|
534
|
+
tokens: number;
|
|
535
|
+
money: number;
|
|
536
|
+
/** Marginal value of scarce resources given current pool pressure. */
|
|
537
|
+
scarcityMultiplier: number;
|
|
538
|
+
total: number;
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
export interface MarketClearingResult {
|
|
542
|
+
roundId: string;
|
|
543
|
+
awarded: Array<{
|
|
544
|
+
bidId: string;
|
|
545
|
+
agentId: string;
|
|
546
|
+
wallet: AgentResourceWallet;
|
|
547
|
+
forecast: UtilityForecast;
|
|
548
|
+
}>;
|
|
549
|
+
denied: Array<{
|
|
550
|
+
bidId: string;
|
|
551
|
+
agentId: string;
|
|
552
|
+
reason: string;
|
|
553
|
+
forecast?: UtilityForecast;
|
|
554
|
+
}>;
|
|
555
|
+
opportunityCostTotal: number;
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
export interface NegotiationOffer {
|
|
559
|
+
fromAgentId: string;
|
|
560
|
+
toAgentId: string;
|
|
561
|
+
reason: string;
|
|
562
|
+
transfer: ResourceRequest;
|
|
563
|
+
expectedValue?: number;
|
|
564
|
+
confidence?: number;
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
export interface NegotiationResult {
|
|
568
|
+
approved: boolean;
|
|
569
|
+
reason: string;
|
|
570
|
+
transfer?: ResourceRequest;
|
|
571
|
+
fromWallet?: AgentResourceWallet;
|
|
572
|
+
toWallet?: AgentResourceWallet;
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
export interface MarketConfig {
|
|
576
|
+
/** Minimum net expected value (after opportunity cost) to win a bid. */
|
|
577
|
+
minNetExpectedValue: number;
|
|
578
|
+
/** Weight of bidPrice in clearing score (0-1). */
|
|
579
|
+
priceWeight: number;
|
|
580
|
+
/** Default bid TTL in ms. */
|
|
581
|
+
defaultBidTtlMs: number;
|
|
582
|
+
/** Scarcity kicks in when pool utilization exceeds this (0-1). */
|
|
583
|
+
scarcityThreshold: number;
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
export const DEFAULT_MARKET_CONFIG: MarketConfig = {
|
|
587
|
+
minNetExpectedValue: 0,
|
|
588
|
+
priceWeight: 0.15,
|
|
589
|
+
defaultBidTtlMs: 60_000,
|
|
590
|
+
scarcityThreshold: 0.7,
|
|
591
|
+
};
|