@medicine-wheel/fire-keeper 0.2.2
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 +71 -0
- package/dist/ceremony-state.d.ts +63 -0
- package/dist/ceremony-state.d.ts.map +1 -0
- package/dist/ceremony-state.js +161 -0
- package/dist/ceremony-state.js.map +1 -0
- package/dist/check-back.d.ts +43 -0
- package/dist/check-back.d.ts.map +1 -0
- package/dist/check-back.js +138 -0
- package/dist/check-back.js.map +1 -0
- package/dist/decisions.d.ts +61 -0
- package/dist/decisions.d.ts.map +1 -0
- package/dist/decisions.js +111 -0
- package/dist/decisions.js.map +1 -0
- package/dist/gating.d.ts +55 -0
- package/dist/gating.d.ts.map +1 -0
- package/dist/gating.js +88 -0
- package/dist/gating.js.map +1 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +44 -0
- package/dist/index.js.map +1 -0
- package/dist/keeper.d.ts +85 -0
- package/dist/keeper.d.ts.map +1 -0
- package/dist/keeper.js +245 -0
- package/dist/keeper.js.map +1 -0
- package/dist/messages.d.ts +166 -0
- package/dist/messages.d.ts.map +1 -0
- package/dist/messages.js +10 -0
- package/dist/messages.js.map +1 -0
- package/dist/trajectory.d.ts +45 -0
- package/dist/trajectory.d.ts.map +1 -0
- package/dist/trajectory.js +85 -0
- package/dist/trajectory.js.map +1 -0
- package/dist/types.d.ts +161 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +10 -0
- package/dist/types.js.map +1 -0
- package/package.json +42 -0
package/dist/keeper.js
ADDED
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @medicine-wheel/fire-keeper — Fire Keeper Class
|
|
4
|
+
*
|
|
5
|
+
* The core coordination engine. The Fire Keeper tends the ceremony fire,
|
|
6
|
+
* receives and evaluates ImportanceUnits, gates work through relational
|
|
7
|
+
* conditions, and issues stop-work orders when accountability is violated.
|
|
8
|
+
*
|
|
9
|
+
* The Fire Keeper does not write code or produce artifacts directly.
|
|
10
|
+
* It receives, evaluates, routes, and gates the work of sub-agents.
|
|
11
|
+
*/
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.FireKeeper = void 0;
|
|
14
|
+
const gating_js_1 = require("./gating.js");
|
|
15
|
+
const decisions_js_1 = require("./decisions.js");
|
|
16
|
+
const check_back_js_1 = require("./check-back.js");
|
|
17
|
+
const trajectory_js_1 = require("./trajectory.js");
|
|
18
|
+
const ceremony_state_js_1 = require("./ceremony-state.js");
|
|
19
|
+
// ── Fire Keeper Class ───────────────────────────────────────────────────────
|
|
20
|
+
/**
|
|
21
|
+
* The Fire Keeper — ceremony coordination agent.
|
|
22
|
+
* Tends the fire so the ceremony can proceed with relational integrity.
|
|
23
|
+
*/
|
|
24
|
+
class FireKeeper {
|
|
25
|
+
config;
|
|
26
|
+
state;
|
|
27
|
+
managers = new Map();
|
|
28
|
+
constructor(config) {
|
|
29
|
+
this.config = config;
|
|
30
|
+
this.state = {
|
|
31
|
+
active: false,
|
|
32
|
+
ceremonies: {},
|
|
33
|
+
currentTier: 'observe',
|
|
34
|
+
activeStopWorkOrders: [],
|
|
35
|
+
lastUpdated: new Date().toISOString(),
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
/** Get the current Fire Keeper state */
|
|
39
|
+
getState() {
|
|
40
|
+
return { ...this.state };
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Begin tending a ceremony for a given inquiry.
|
|
44
|
+
* @param inquiryRef - Reference to the inquiry
|
|
45
|
+
* @param startDirection - Initial direction (default: east)
|
|
46
|
+
*/
|
|
47
|
+
beginCeremony(inquiryRef, startDirection = 'east') {
|
|
48
|
+
const ceremonyState = (0, ceremony_state_js_1.createCeremonyState)(inquiryRef, startDirection);
|
|
49
|
+
this.state.ceremonies[inquiryRef] = ceremonyState;
|
|
50
|
+
this.state.active = true;
|
|
51
|
+
this.state.lastUpdated = new Date().toISOString();
|
|
52
|
+
const manager = new ceremony_state_js_1.CeremonyStateManager(ceremonyState);
|
|
53
|
+
this.managers.set(inquiryRef, manager);
|
|
54
|
+
return ceremonyState;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Evaluate an incoming ImportanceUnit against gating conditions,
|
|
58
|
+
* ceremony state, and relational check-back protocol.
|
|
59
|
+
* @param unit - The ImportanceUnit payload
|
|
60
|
+
* @param inquiryRef - Reference to the active inquiry
|
|
61
|
+
*/
|
|
62
|
+
evaluateImportance(unit, inquiryRef) {
|
|
63
|
+
const ceremonyState = this.state.ceremonies[inquiryRef];
|
|
64
|
+
if (!ceremonyState) {
|
|
65
|
+
return {
|
|
66
|
+
type: 'importance.held',
|
|
67
|
+
payload: {
|
|
68
|
+
unitId: unit['id'] || 'unknown',
|
|
69
|
+
reason: `No active ceremony for inquiry: ${inquiryRef}`,
|
|
70
|
+
unsatisfiedConditions: [],
|
|
71
|
+
suggestedAction: 'Begin a ceremony before submitting importance units',
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
const context = this.buildContext(inquiryRef, unit);
|
|
76
|
+
// Evaluate gating conditions
|
|
77
|
+
const gateResult = (0, gating_js_1.evaluateGates)(this.config.gatingConditions, context);
|
|
78
|
+
if (!gateResult.allSatisfied) {
|
|
79
|
+
return {
|
|
80
|
+
type: 'importance.held',
|
|
81
|
+
payload: {
|
|
82
|
+
unitId: unit['id'] || 'unknown',
|
|
83
|
+
reason: 'Gating conditions not satisfied',
|
|
84
|
+
unsatisfiedConditions: gateResult.unsatisfied.map((s) => ({
|
|
85
|
+
condition: s.condition,
|
|
86
|
+
satisfied: s.satisfied,
|
|
87
|
+
})),
|
|
88
|
+
suggestedAction: 'Satisfy all required gating conditions before proceeding',
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
// Relational check-back
|
|
93
|
+
const checkBack = (0, check_back_js_1.relationalCheckBack)(`Evaluate importance unit: ${unit['title'] || 'untitled'}`, context);
|
|
94
|
+
if (!checkBack.approved) {
|
|
95
|
+
const failedStep = checkBack.steps.find((s) => !s.passed);
|
|
96
|
+
return {
|
|
97
|
+
type: 'importance.held',
|
|
98
|
+
payload: {
|
|
99
|
+
unitId: unit['id'] || 'unknown',
|
|
100
|
+
reason: checkBack.summary,
|
|
101
|
+
unsatisfiedConditions: checkBack.steps
|
|
102
|
+
.filter((s) => !s.passed)
|
|
103
|
+
.map((s) => ({ condition: s.question, satisfied: false })),
|
|
104
|
+
suggestedAction: failedStep?.reason || 'Address relational check-back concerns',
|
|
105
|
+
},
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
// Check if human decision is needed
|
|
109
|
+
const decision = (0, decisions_js_1.humanNeeded)(context, this.config.humanDecisionPoints, this.config.trajectoryThreshold);
|
|
110
|
+
if (decision.needed) {
|
|
111
|
+
return {
|
|
112
|
+
type: 'human.needed',
|
|
113
|
+
payload: {
|
|
114
|
+
requestId: `eval-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`,
|
|
115
|
+
reason: decision.reason || 'Human decision required',
|
|
116
|
+
decisionType: decision.decisionType || 'value-conflict',
|
|
117
|
+
context: {
|
|
118
|
+
unitId: unit['id'] || undefined,
|
|
119
|
+
summary: `ImportanceUnit evaluation requires human input: ${decision.reason}`,
|
|
120
|
+
options: ['approve', 'deepen', 'hold', 'reject'],
|
|
121
|
+
},
|
|
122
|
+
suggestedModality: 'protocol',
|
|
123
|
+
},
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
// Unit accepted
|
|
127
|
+
const direction = unit['direction'] || ceremonyState.activeDirection;
|
|
128
|
+
return {
|
|
129
|
+
type: 'importance.accepted',
|
|
130
|
+
payload: {
|
|
131
|
+
unitId: unit['id'] || 'unknown',
|
|
132
|
+
assignedDirection: direction,
|
|
133
|
+
gatingStatus: 'all-satisfied',
|
|
134
|
+
},
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Check the current ceremony state for a given inquiry.
|
|
139
|
+
* @param inquiryRef - Reference to the inquiry
|
|
140
|
+
*/
|
|
141
|
+
checkCeremonyState(inquiryRef) {
|
|
142
|
+
return this.state.ceremonies[inquiryRef] || null;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Request that a participant deepen their work in a specific direction.
|
|
146
|
+
* @param unitId - The ImportanceUnit to deepen
|
|
147
|
+
* @param direction - Direction to return to
|
|
148
|
+
* @param guidance - Guidance for the deepening
|
|
149
|
+
*/
|
|
150
|
+
requestDeepening(unitId, direction, guidance) {
|
|
151
|
+
return {
|
|
152
|
+
type: 'deepen.requested',
|
|
153
|
+
payload: {
|
|
154
|
+
unitId,
|
|
155
|
+
currentCircleDepth: 0,
|
|
156
|
+
missingQuadrants: this.getMissingQuadrants(direction),
|
|
157
|
+
guidance,
|
|
158
|
+
},
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Issue a stop-work order when relational accountability is violated.
|
|
163
|
+
* This is an emergency halt — the Fire Keeper's most serious action.
|
|
164
|
+
* @param targetAgentId - Agent to halt
|
|
165
|
+
* @param reason - Reason for the stop work order
|
|
166
|
+
* @param unitId - Related ImportanceUnit, if any
|
|
167
|
+
*/
|
|
168
|
+
issueStopWork(targetAgentId, reason, unitId = null) {
|
|
169
|
+
const order = {
|
|
170
|
+
targetAgentId,
|
|
171
|
+
reason,
|
|
172
|
+
unitId,
|
|
173
|
+
resumeCondition: 'Human review required via human.needed',
|
|
174
|
+
};
|
|
175
|
+
this.state.activeStopWorkOrders.push(order);
|
|
176
|
+
this.state.lastUpdated = new Date().toISOString();
|
|
177
|
+
return {
|
|
178
|
+
type: 'stopwork.order',
|
|
179
|
+
payload: {
|
|
180
|
+
targetAgentId: order.targetAgentId,
|
|
181
|
+
reason: order.reason,
|
|
182
|
+
unitId: order.unitId,
|
|
183
|
+
resumeCondition: order.resumeCondition,
|
|
184
|
+
},
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Verify Wilson alignment across the current ceremony.
|
|
189
|
+
* Checks trajectory confidence, gating conditions, and relational milestones.
|
|
190
|
+
* @param inquiryRef - Reference to the inquiry
|
|
191
|
+
*/
|
|
192
|
+
checkRelationalAlignment(inquiryRef) {
|
|
193
|
+
const ceremonyState = this.state.ceremonies[inquiryRef];
|
|
194
|
+
if (!ceremonyState) {
|
|
195
|
+
return {
|
|
196
|
+
aligned: false,
|
|
197
|
+
confidence: 0,
|
|
198
|
+
issues: [`No active ceremony for inquiry: ${inquiryRef}`],
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
const confidence = (0, trajectory_js_1.trajectoryConfidence)(ceremonyState.trajectoryHistory);
|
|
202
|
+
const unsatisfiedGates = ceremonyState.gatingConditions.filter((g) => !g.satisfied);
|
|
203
|
+
const incompleteMilestones = ceremonyState.relationalMilestones.filter((m) => !m.complete);
|
|
204
|
+
const issues = [];
|
|
205
|
+
if (confidence < this.config.trajectoryThreshold) {
|
|
206
|
+
issues.push(`Trajectory confidence (${confidence.toFixed(2)}) below threshold (${this.config.trajectoryThreshold})`);
|
|
207
|
+
}
|
|
208
|
+
if (unsatisfiedGates.length > 0) {
|
|
209
|
+
issues.push(`${unsatisfiedGates.length} unsatisfied gating condition(s)`);
|
|
210
|
+
}
|
|
211
|
+
if (this.state.activeStopWorkOrders.length > 0) {
|
|
212
|
+
issues.push(`${this.state.activeStopWorkOrders.length} active stop-work order(s)`);
|
|
213
|
+
}
|
|
214
|
+
return {
|
|
215
|
+
aligned: issues.length === 0,
|
|
216
|
+
confidence,
|
|
217
|
+
issues,
|
|
218
|
+
unsatisfiedGates: unsatisfiedGates.map((g) => g.condition),
|
|
219
|
+
incompleteMilestones: incompleteMilestones.map((m) => m.milestone),
|
|
220
|
+
activeStopWorkOrders: this.state.activeStopWorkOrders.length,
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
// ── Private Helpers ─────────────────────────────────────────────────────
|
|
224
|
+
buildContext(inquiryRef, unit) {
|
|
225
|
+
return {
|
|
226
|
+
ceremonyState: this.state.ceremonies[inquiryRef],
|
|
227
|
+
unitId: unit ? unit['id'] : undefined,
|
|
228
|
+
wilsonAlignment: this.estimateWilsonAlignment(inquiryRef),
|
|
229
|
+
ocapCompliant: true,
|
|
230
|
+
metadata: unit,
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
estimateWilsonAlignment(inquiryRef) {
|
|
234
|
+
const ceremony = this.state.ceremonies[inquiryRef];
|
|
235
|
+
if (!ceremony)
|
|
236
|
+
return 0;
|
|
237
|
+
return (0, trajectory_js_1.trajectoryConfidence)(ceremony.trajectoryHistory);
|
|
238
|
+
}
|
|
239
|
+
getMissingQuadrants(currentDirection) {
|
|
240
|
+
const all = ['east', 'south', 'west', 'north'];
|
|
241
|
+
return all.filter((d) => d !== currentDirection);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
exports.FireKeeper = FireKeeper;
|
|
245
|
+
//# sourceMappingURL=keeper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keeper.js","sourceRoot":"","sources":["../src/keeper.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;AAkBH,2CAA4C;AAC5C,iDAA6C;AAC7C,mDAAsD;AACtD,mDAAuD;AACvD,2DAAgF;AAWhF,+EAA+E;AAE/E;;;GAGG;AACH,MAAa,UAAU;IACb,MAAM,CAAmB;IACzB,KAAK,CAAkB;IACvB,QAAQ,GAAsC,IAAI,GAAG,EAAE,CAAC;IAEhE,YAAY,MAAwB;QAClC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,KAAK,GAAG;YACX,MAAM,EAAE,KAAK;YACb,UAAU,EAAE,EAAE;YACd,WAAW,EAAE,SAAS;YACtB,oBAAoB,EAAE,EAAE;YACxB,WAAW,EAAE,IAAI,IAAI,EAAE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AE9B,OAAO;YACL,aAAa,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,UAAU,CAAC;YAChD,MAAM,EAAE,IAAI,CAAC,CAAC,CAAE,IAAI,CAAC,IAAI,CAAY,CAAC,CAAC,CAAC,SAAS;YACjD,eAAe,EAAE,IAAI,CAAC,uBAAuB,CAAC,UAAU,CAAC;YACzD,aAAa,EAAE,IAAI;YACnB,QAAQ,EAAE,IAAI;SACf,CAAC;IACJ,CAAC;IAEO,uBAAuB,CAAC,UAAkB;QAChD,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;QACnD,IAAI,CAAC,QAAQ;YAAE,OAAO,CAAC,CAAC;QACxB,OAAO,IAAA,oCAAoB,EAAC,QAAQ,CAAC,iBAAiB,CAAC,CAAC;IAC1D,CAAC;IAEO,mBAAmB,CACzB,gBAA+B;QAE/B,MAAM,GAAG,GAAoB,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;QAChE,OAAO,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,gBAAgB,CAAC,CAAC;IACnD,CAAC;CACF;AAzRD,gCAyRC"}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @medicine-wheel/fire-keeper — Message Types
|
|
3
|
+
*
|
|
4
|
+
* A2A message type definitions for Fire Keeper communication.
|
|
5
|
+
* All messages flow through the message broker; the Fire Keeper
|
|
6
|
+
* is the primary consumer and producer of these message types.
|
|
7
|
+
*/
|
|
8
|
+
import type { DirectionName } from '@medicine-wheel/ontology-core';
|
|
9
|
+
import type { DecisionPointType } from './types.js';
|
|
10
|
+
/** A sub-agent submits a new ImportanceUnit for evaluation */
|
|
11
|
+
export interface ImportanceSubmittedMessage {
|
|
12
|
+
type: 'importance.submitted';
|
|
13
|
+
payload: {
|
|
14
|
+
/** The ImportanceUnit payload (schema-conformant) */
|
|
15
|
+
unit: Record<string, unknown>;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
/** A sub-agent signals it has circled back with new depth */
|
|
19
|
+
export interface CircleReturnMessage {
|
|
20
|
+
type: 'circle.return';
|
|
21
|
+
payload: {
|
|
22
|
+
/** The ImportanceUnit being circled */
|
|
23
|
+
unitId: string;
|
|
24
|
+
/** New circle depth after this return */
|
|
25
|
+
newCircleDepth: number;
|
|
26
|
+
/** What changed or deepened in this pass */
|
|
27
|
+
shift: string;
|
|
28
|
+
/** Direction of the circle return */
|
|
29
|
+
direction: DirectionName;
|
|
30
|
+
/** Source modality */
|
|
31
|
+
source: string;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
/** Periodic status from a working sub-agent */
|
|
35
|
+
export interface AgentReportMessage {
|
|
36
|
+
type: 'agent.report';
|
|
37
|
+
payload: {
|
|
38
|
+
/** Reporting agent identifier */
|
|
39
|
+
agentId: string;
|
|
40
|
+
/** Current direction the agent is working in */
|
|
41
|
+
currentDirection: DirectionName;
|
|
42
|
+
/** Active ImportanceUnit IDs */
|
|
43
|
+
activeUnits: string[];
|
|
44
|
+
/** Agent's self-assessed trajectory confidence (0–1) */
|
|
45
|
+
trajectoryConfidence: number;
|
|
46
|
+
/** Flags indicating potential value divergence */
|
|
47
|
+
valueDivergenceFlags: string[];
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
/** The human responds to a human.needed request */
|
|
51
|
+
export interface HumanResponseMessage {
|
|
52
|
+
type: 'human.response';
|
|
53
|
+
payload: {
|
|
54
|
+
/** Matches the original human.needed requestId */
|
|
55
|
+
requestId: string;
|
|
56
|
+
/** The human's decision */
|
|
57
|
+
decision: string;
|
|
58
|
+
/** Modality chosen by the human */
|
|
59
|
+
modality: string;
|
|
60
|
+
/** Optional additional context */
|
|
61
|
+
additionalContext: string | null;
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
/** The submitted ImportanceUnit passes gating conditions */
|
|
65
|
+
export interface ImportanceAcceptedMessage {
|
|
66
|
+
type: 'importance.accepted';
|
|
67
|
+
payload: {
|
|
68
|
+
/** The accepted unit's ID */
|
|
69
|
+
unitId: string;
|
|
70
|
+
/** Direction assigned for this unit's work */
|
|
71
|
+
assignedDirection: DirectionName;
|
|
72
|
+
/** Summary of gating evaluation */
|
|
73
|
+
gatingStatus: string;
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
/** The unit cannot proceed — a gating condition is unsatisfied */
|
|
77
|
+
export interface ImportanceHeldMessage {
|
|
78
|
+
type: 'importance.held';
|
|
79
|
+
payload: {
|
|
80
|
+
/** The held unit's ID */
|
|
81
|
+
unitId: string;
|
|
82
|
+
/** Reason for the hold */
|
|
83
|
+
reason: string;
|
|
84
|
+
/** Which conditions were not satisfied */
|
|
85
|
+
unsatisfiedConditions: Array<{
|
|
86
|
+
condition: string;
|
|
87
|
+
satisfied: boolean;
|
|
88
|
+
}>;
|
|
89
|
+
/** Suggested action to resolve the hold */
|
|
90
|
+
suggestedAction: string;
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
/** Fire Keeper asks a sub-agent to circle back for more depth */
|
|
94
|
+
export interface DeepenRequestedMessage {
|
|
95
|
+
type: 'deepen.requested';
|
|
96
|
+
payload: {
|
|
97
|
+
/** The unit needing deeper work */
|
|
98
|
+
unitId: string;
|
|
99
|
+
/** Current circle depth */
|
|
100
|
+
currentCircleDepth: number;
|
|
101
|
+
/** Quadrants not yet visited */
|
|
102
|
+
missingQuadrants: DirectionName[];
|
|
103
|
+
/** Guidance for the sub-agent */
|
|
104
|
+
guidance: string;
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
/** A decision point requires the human in the loop */
|
|
108
|
+
export interface HumanNeededMessage {
|
|
109
|
+
type: 'human.needed';
|
|
110
|
+
payload: {
|
|
111
|
+
/** Unique request identifier */
|
|
112
|
+
requestId: string;
|
|
113
|
+
/** Why human involvement is needed */
|
|
114
|
+
reason: string;
|
|
115
|
+
/** Type of decision required */
|
|
116
|
+
decisionType: DecisionPointType;
|
|
117
|
+
/** Context for the decision */
|
|
118
|
+
context: {
|
|
119
|
+
unitId?: string;
|
|
120
|
+
summary: string;
|
|
121
|
+
options: string[];
|
|
122
|
+
};
|
|
123
|
+
/** Suggested modality for the work */
|
|
124
|
+
suggestedModality: string;
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
/** Broadcast ceremony state change to all sub-agents */
|
|
128
|
+
export interface CeremonyStateUpdateMessage {
|
|
129
|
+
type: 'ceremony.state.update';
|
|
130
|
+
payload: {
|
|
131
|
+
/** Inquiry reference */
|
|
132
|
+
inquiryRef: string;
|
|
133
|
+
/** Currently active quadrant */
|
|
134
|
+
activeQuadrant: DirectionName;
|
|
135
|
+
/** Quadrants that have been completed */
|
|
136
|
+
quadrantsCompleted: DirectionName[];
|
|
137
|
+
/** Total ImportanceUnits in play */
|
|
138
|
+
totalUnits: number;
|
|
139
|
+
/** Number of completed relational circles */
|
|
140
|
+
completedCircles: number;
|
|
141
|
+
/** Overall trajectory confidence (0–1) */
|
|
142
|
+
overallTrajectoryConfidence: number;
|
|
143
|
+
/** Current gating condition statuses */
|
|
144
|
+
activeGatingConditions: Array<{
|
|
145
|
+
condition: string;
|
|
146
|
+
satisfied: boolean;
|
|
147
|
+
}>;
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
/** Emergency halt — a sub-agent's trajectory has diverged from core values */
|
|
151
|
+
export interface StopWorkOrderMessage {
|
|
152
|
+
type: 'stopwork.order';
|
|
153
|
+
payload: {
|
|
154
|
+
/** Target agent to halt */
|
|
155
|
+
targetAgentId: string;
|
|
156
|
+
/** Reason for the stop work order */
|
|
157
|
+
reason: string;
|
|
158
|
+
/** ImportanceUnit involved, if any */
|
|
159
|
+
unitId: string | null;
|
|
160
|
+
/** Condition for resuming work */
|
|
161
|
+
resumeCondition: string;
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
/** Union of all Fire Keeper message types */
|
|
165
|
+
export type FireKeeperMessage = ImportanceSubmittedMessage | CircleReturnMessage | AgentReportMessage | HumanResponseMessage | ImportanceAcceptedMessage | ImportanceHeldMessage | DeepenRequestedMessage | HumanNeededMessage | CeremonyStateUpdateMessage | StopWorkOrderMessage;
|
|
166
|
+
//# sourceMappingURL=messages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../src/messages.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,KAAK,EAAE,iBAAiB,EAAyB,MAAM,YAAY,CAAC;AAI3E,8DAA8D;AAC9D,MAAM,WAAW,0BAA0B;IACzC,IAAI,EAAE,sBAAsB,CAAC;IAC7B,OAAO,EAAE;QACP,qDAAqD;QACrD,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KAC/B,CAAC;CACH;AAED,6DAA6D;AAC7D,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,eAAe,CAAC;IACtB,OAAO,EAAE;QACP,uCAAuC;QACvC,MAAM,EAAE,MAAM,CAAC;QACf,yCAAyC;QACzC,cAAc,EAAE,MAAM,CAAC;QACvB,4CAA4C;QAC5C,KAAK,EAAE,MAAM,CAAC;QACd,qCAAqC;QACrC,SAAS,EAAE,aAAa,CAAC;QACzB,sBAAsB;QACtB,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;CACH;AAED,+CAA+C;AAC/C,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,cAAc,CAAC;IACrB,OAAO,EAAE;QACP,iCAAiC;QACjC,OAAO,EAAE,MAAM,CAAC;QAChB,gDAAgD;QAChD,gBAAgB,EAAE,aAAa,CAAC;QAChC,gCAAgC;QAChC,WAAW,EAAE,MAAM,EAAE,CAAC;QACtB,wDAAwD;QACxD,oBAAoB,EAAE,MAAM,CAAC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AC;QACtB,kCAAkC;QAClC,eAAe,EAAE,MAAM,CAAC;KACzB,CAAC;CACH;AAID,6CAA6C;AAC7C,MAAM,MAAM,iBAAiB,GACzB,0BAA0B,GAC1B,mBAAmB,GACnB,kBAAkB,GAClB,oBAAoB,GACpB,yBAAyB,GACzB,qBAAqB,GACrB,sBAAsB,GACtB,kBAAkB,GAClB,0BAA0B,GAC1B,oBAAoB,CAAC"}
|
package/dist/messages.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @medicine-wheel/fire-keeper — Message Types
|
|
4
|
+
*
|
|
5
|
+
* A2A message type definitions for Fire Keeper communication.
|
|
6
|
+
* All messages flow through the message broker; the Fire Keeper
|
|
7
|
+
* is the primary consumer and producer of these message types.
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
//# sourceMappingURL=messages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.js","sourceRoot":"","sources":["../src/messages.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @medicine-wheel/fire-keeper — Trajectory Analysis
|
|
3
|
+
*
|
|
4
|
+
* Assesses whether the ceremony is on track by analyzing trajectory
|
|
5
|
+
* history and detecting value divergence. The Fire Keeper uses these
|
|
6
|
+
* signals to decide when human intervention is needed.
|
|
7
|
+
*/
|
|
8
|
+
import type { TrajectoryCheckpoint } from './types.js';
|
|
9
|
+
/**
|
|
10
|
+
* Compute overall trajectory confidence from a history of checkpoints.
|
|
11
|
+
* Returns a score between 0 and 1 indicating how confident we are
|
|
12
|
+
* that the ceremony is aligned with its intended values.
|
|
13
|
+
*
|
|
14
|
+
* Algorithm:
|
|
15
|
+
* - Weighted average favoring recent checkpoints
|
|
16
|
+
* - Penalizes declining trends
|
|
17
|
+
* - Empty history returns 0.5 (neutral)
|
|
18
|
+
*
|
|
19
|
+
* @param history - Array of trajectory checkpoints
|
|
20
|
+
* @returns Confidence score between 0 and 1
|
|
21
|
+
*/
|
|
22
|
+
export declare function trajectoryConfidence(history: TrajectoryCheckpoint[]): number;
|
|
23
|
+
/** Result of value divergence analysis */
|
|
24
|
+
export interface DivergenceResult {
|
|
25
|
+
/** Whether divergence was detected */
|
|
26
|
+
diverged: boolean;
|
|
27
|
+
/** Magnitude of the divergence (0–1, where 1 is maximum divergence) */
|
|
28
|
+
magnitude: number;
|
|
29
|
+
/** Human-readable description of the divergence */
|
|
30
|
+
description: string;
|
|
31
|
+
/** Suggested corrective action */
|
|
32
|
+
suggestedAction: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Detect when the ceremony's trajectory diverges from its intended values.
|
|
36
|
+
* Compares current trajectory confidence against the intended confidence
|
|
37
|
+
* established at ceremony inception.
|
|
38
|
+
*
|
|
39
|
+
* @param current - Current trajectory confidence (0–1)
|
|
40
|
+
* @param intended - Intended/baseline trajectory confidence (0–1)
|
|
41
|
+
* @param threshold - Divergence threshold before flagging (default: 0.15)
|
|
42
|
+
* @returns Divergence analysis result
|
|
43
|
+
*/
|
|
44
|
+
export declare function valueDivergenceDetect(current: number, intended: number, threshold?: number): DivergenceResult;
|
|
45
|
+
//# sourceMappingURL=trajectory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trajectory.d.ts","sourceRoot":"","sources":["../src/trajectory.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAIvD;;;;;;;;;;;;GAYG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,oBAAoB,EAAE,GAAG,MAAM,CA4B5E;AAID,0CAA0C;AAC1C,MAAM,WAAW,gBAAgB;IAC/B,sCAAsC;IACtC,QAAQ,EAAE,OAAO,CAAC;IAClB,uEAAuE;IACvE,SAAS,EAAE,MAAM,CAAC;IAClB,mDAAmD;IACnD,WAAW,EAAE,MAAM,CAAC;IACpB,kCAAkC;IAClC,eAAe,EAAE,MAAM,CAAC;CACzB;AAED;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,SAAS,GAAE,MAAa,GACvB,gBAAgB,CAyBlB"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @medicine-wheel/fire-keeper — Trajectory Analysis
|
|
4
|
+
*
|
|
5
|
+
* Assesses whether the ceremony is on track by analyzing trajectory
|
|
6
|
+
* history and detecting value divergence. The Fire Keeper uses these
|
|
7
|
+
* signals to decide when human intervention is needed.
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.trajectoryConfidence = trajectoryConfidence;
|
|
11
|
+
exports.valueDivergenceDetect = valueDivergenceDetect;
|
|
12
|
+
// ── Trajectory Confidence ───────────────────────────────────────────────────
|
|
13
|
+
/**
|
|
14
|
+
* Compute overall trajectory confidence from a history of checkpoints.
|
|
15
|
+
* Returns a score between 0 and 1 indicating how confident we are
|
|
16
|
+
* that the ceremony is aligned with its intended values.
|
|
17
|
+
*
|
|
18
|
+
* Algorithm:
|
|
19
|
+
* - Weighted average favoring recent checkpoints
|
|
20
|
+
* - Penalizes declining trends
|
|
21
|
+
* - Empty history returns 0.5 (neutral)
|
|
22
|
+
*
|
|
23
|
+
* @param history - Array of trajectory checkpoints
|
|
24
|
+
* @returns Confidence score between 0 and 1
|
|
25
|
+
*/
|
|
26
|
+
function trajectoryConfidence(history) {
|
|
27
|
+
if (history.length === 0)
|
|
28
|
+
return 0.5;
|
|
29
|
+
if (history.length === 1)
|
|
30
|
+
return history[0].confidence;
|
|
31
|
+
// Weighted average: more recent checkpoints count more
|
|
32
|
+
let weightedSum = 0;
|
|
33
|
+
let weightTotal = 0;
|
|
34
|
+
for (let i = 0; i < history.length; i++) {
|
|
35
|
+
const weight = i + 1; // Linear increasing weight
|
|
36
|
+
weightedSum += history[i].confidence * weight;
|
|
37
|
+
weightTotal += weight;
|
|
38
|
+
}
|
|
39
|
+
const weightedAvg = weightedSum / weightTotal;
|
|
40
|
+
// Trend penalty: if confidence is declining, reduce the score
|
|
41
|
+
const recent = history.slice(-3);
|
|
42
|
+
if (recent.length >= 2) {
|
|
43
|
+
const trend = recent[recent.length - 1].confidence - recent[0].confidence;
|
|
44
|
+
if (trend < 0) {
|
|
45
|
+
// Apply a penalty proportional to the decline
|
|
46
|
+
const penalty = Math.abs(trend) * 0.2;
|
|
47
|
+
return Math.max(0, Math.min(1, weightedAvg - penalty));
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return Math.max(0, Math.min(1, weightedAvg));
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Detect when the ceremony's trajectory diverges from its intended values.
|
|
54
|
+
* Compares current trajectory confidence against the intended confidence
|
|
55
|
+
* established at ceremony inception.
|
|
56
|
+
*
|
|
57
|
+
* @param current - Current trajectory confidence (0–1)
|
|
58
|
+
* @param intended - Intended/baseline trajectory confidence (0–1)
|
|
59
|
+
* @param threshold - Divergence threshold before flagging (default: 0.15)
|
|
60
|
+
* @returns Divergence analysis result
|
|
61
|
+
*/
|
|
62
|
+
function valueDivergenceDetect(current, intended, threshold = 0.15) {
|
|
63
|
+
const magnitude = Math.abs(current - intended);
|
|
64
|
+
const diverged = magnitude > threshold;
|
|
65
|
+
if (!diverged) {
|
|
66
|
+
return {
|
|
67
|
+
diverged: false,
|
|
68
|
+
magnitude,
|
|
69
|
+
description: `Trajectory within acceptable range (divergence: ${magnitude.toFixed(3)})`,
|
|
70
|
+
suggestedAction: 'Continue current trajectory',
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
const declining = current < intended;
|
|
74
|
+
return {
|
|
75
|
+
diverged: true,
|
|
76
|
+
magnitude,
|
|
77
|
+
description: declining
|
|
78
|
+
? `Trajectory declining — current confidence (${current.toFixed(2)}) is ${magnitude.toFixed(2)} below intended (${intended.toFixed(2)})`
|
|
79
|
+
: `Trajectory shifted — current confidence (${current.toFixed(2)}) differs from intended (${intended.toFixed(2)}) by ${magnitude.toFixed(2)}`,
|
|
80
|
+
suggestedAction: declining
|
|
81
|
+
? 'Consider pausing for relational check-back or requesting human guidance'
|
|
82
|
+
: 'Review whether trajectory shift reflects genuine deepening or drift',
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=trajectory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trajectory.js","sourceRoot":"","sources":["../src/trajectory.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AAmBH,oDA4BC;AA0BD,sDA6BC;AAlGD,+EAA+E;AAE/E;;;;;;;;;;;;GAYG;AACH,SAAgB,oBAAoB,CAAC,OAA+B;IAClE,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,GAAG,CAAC;IACrC,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,OAAO,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC;IAEvD,uDAAuD;IACvD,IAAI,WAAW,GAAG,CAAC,CAAC;IACpB,IAAI,WAAW,GAAG,CAAC,CAAC;IAEpB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACxC,MAAM,MAAM,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,2BAA2B;QACjD,WAAW,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC,UAAU,GAAG,MAAM,CAAC;QAC9C,WAAW,IAAI,MAAM,CAAC;IACxB,CAAC;IAED,MAAM,WAAW,GAAG,WAAW,GAAG,WAAW,CAAC;IAE9C,8DAA8D;IAC9D,MAAM,MAAM,GAAG,OAAO,CAAC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