@aiassesstech/noah 0.1.0
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/CHANGELOG.md +26 -0
- package/LICENSE +41 -0
- package/README.md +170 -0
- package/SKILL.md +64 -0
- package/agent/AGENTS.md +138 -0
- package/agent/IDENTITY.md +12 -0
- package/agent/SOUL.md +143 -0
- package/dist/alert/alert-system.d.ts +47 -0
- package/dist/alert/alert-system.d.ts.map +1 -0
- package/dist/alert/alert-system.js +117 -0
- package/dist/alert/alert-system.js.map +1 -0
- package/dist/alert/commander-escalation.d.ts +26 -0
- package/dist/alert/commander-escalation.d.ts.map +1 -0
- package/dist/alert/commander-escalation.js +61 -0
- package/dist/alert/commander-escalation.js.map +1 -0
- package/dist/cli/bin.d.ts +8 -0
- package/dist/cli/bin.d.ts.map +1 -0
- package/dist/cli/bin.js +12 -0
- package/dist/cli/bin.js.map +1 -0
- package/dist/cli/runner.d.ts +13 -0
- package/dist/cli/runner.d.ts.map +1 -0
- package/dist/cli/runner.js +95 -0
- package/dist/cli/runner.js.map +1 -0
- package/dist/cli/setup.d.ts +34 -0
- package/dist/cli/setup.d.ts.map +1 -0
- package/dist/cli/setup.js +237 -0
- package/dist/cli/setup.js.map +1 -0
- package/dist/clock/financial-runway.d.ts +32 -0
- package/dist/clock/financial-runway.d.ts.map +1 -0
- package/dist/clock/financial-runway.js +46 -0
- package/dist/clock/financial-runway.js.map +1 -0
- package/dist/clock/internal-clock.d.ts +53 -0
- package/dist/clock/internal-clock.d.ts.map +1 -0
- package/dist/clock/internal-clock.js +177 -0
- package/dist/clock/internal-clock.js.map +1 -0
- package/dist/clock/phase-machine.d.ts +36 -0
- package/dist/clock/phase-machine.d.ts.map +1 -0
- package/dist/clock/phase-machine.js +123 -0
- package/dist/clock/phase-machine.js.map +1 -0
- package/dist/clock/phase-transitions.d.ts +9 -0
- package/dist/clock/phase-transitions.d.ts.map +1 -0
- package/dist/clock/phase-transitions.js +58 -0
- package/dist/clock/phase-transitions.js.map +1 -0
- package/dist/deviation/corridor-classifier.d.ts +15 -0
- package/dist/deviation/corridor-classifier.d.ts.map +1 -0
- package/dist/deviation/corridor-classifier.js +21 -0
- package/dist/deviation/corridor-classifier.js.map +1 -0
- package/dist/deviation/deviation-calculator.d.ts +25 -0
- package/dist/deviation/deviation-calculator.d.ts.map +1 -0
- package/dist/deviation/deviation-calculator.js +53 -0
- package/dist/deviation/deviation-calculator.js.map +1 -0
- package/dist/deviation/recommendations.d.ts +13 -0
- package/dist/deviation/recommendations.d.ts.map +1 -0
- package/dist/deviation/recommendations.js +54 -0
- package/dist/deviation/recommendations.js.map +1 -0
- package/dist/flight-plan/corridor.d.ts +31 -0
- package/dist/flight-plan/corridor.d.ts.map +1 -0
- package/dist/flight-plan/corridor.js +49 -0
- package/dist/flight-plan/corridor.js.map +1 -0
- package/dist/flight-plan/default-plan.d.ts +16 -0
- package/dist/flight-plan/default-plan.d.ts.map +1 -0
- package/dist/flight-plan/default-plan.js +166 -0
- package/dist/flight-plan/default-plan.js.map +1 -0
- package/dist/flight-plan/flight-plan-engine.d.ts +37 -0
- package/dist/flight-plan/flight-plan-engine.d.ts.map +1 -0
- package/dist/flight-plan/flight-plan-engine.js +94 -0
- package/dist/flight-plan/flight-plan-engine.js.map +1 -0
- package/dist/flight-plan/interpolation.d.ts +48 -0
- package/dist/flight-plan/interpolation.d.ts.map +1 -0
- package/dist/flight-plan/interpolation.js +179 -0
- package/dist/flight-plan/interpolation.js.map +1 -0
- package/dist/go-no-go/temporal-decision-matrix.d.ts +30 -0
- package/dist/go-no-go/temporal-decision-matrix.d.ts.map +1 -0
- package/dist/go-no-go/temporal-decision-matrix.js +94 -0
- package/dist/go-no-go/temporal-decision-matrix.js.map +1 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +37 -0
- package/dist/index.js.map +1 -0
- package/dist/integration/event-emitter.d.ts +14 -0
- package/dist/integration/event-emitter.d.ts.map +1 -0
- package/dist/integration/event-emitter.js +24 -0
- package/dist/integration/event-emitter.js.map +1 -0
- package/dist/integration/grillo-hook.d.ts +106 -0
- package/dist/integration/grillo-hook.d.ts.map +1 -0
- package/dist/integration/grillo-hook.js +202 -0
- package/dist/integration/grillo-hook.js.map +1 -0
- package/dist/plugin.d.ts +20 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +480 -0
- package/dist/plugin.js.map +1 -0
- package/dist/store/hash-chain.d.ts +35 -0
- package/dist/store/hash-chain.d.ts.map +1 -0
- package/dist/store/hash-chain.js +64 -0
- package/dist/store/hash-chain.js.map +1 -0
- package/dist/store/json-store.d.ts +47 -0
- package/dist/store/json-store.d.ts.map +1 -0
- package/dist/store/json-store.js +213 -0
- package/dist/store/json-store.js.map +1 -0
- package/dist/store/temporal-state-store.d.ts +7 -0
- package/dist/store/temporal-state-store.d.ts.map +1 -0
- package/dist/store/temporal-state-store.js +7 -0
- package/dist/store/temporal-state-store.js.map +1 -0
- package/dist/store/types.d.ts +27 -0
- package/dist/store/types.d.ts.map +1 -0
- package/dist/store/types.js +8 -0
- package/dist/store/types.js.map +1 -0
- package/dist/types/assessment-record.d.ts +34 -0
- package/dist/types/assessment-record.d.ts.map +1 -0
- package/dist/types/assessment-record.js +9 -0
- package/dist/types/assessment-record.js.map +1 -0
- package/dist/types/events.d.ts +57 -0
- package/dist/types/events.d.ts.map +1 -0
- package/dist/types/events.js +8 -0
- package/dist/types/events.js.map +1 -0
- package/dist/types/flight-plan.d.ts +59 -0
- package/dist/types/flight-plan.d.ts.map +1 -0
- package/dist/types/flight-plan.js +8 -0
- package/dist/types/flight-plan.js.map +1 -0
- package/dist/types/guidance.d.ts +57 -0
- package/dist/types/guidance.d.ts.map +1 -0
- package/dist/types/guidance.js +8 -0
- package/dist/types/guidance.js.map +1 -0
- package/dist/types/index.d.ts +10 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +10 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/lifecycle.d.ts +56 -0
- package/dist/types/lifecycle.d.ts.map +1 -0
- package/dist/types/lifecycle.js +33 -0
- package/dist/types/lifecycle.js.map +1 -0
- package/dist/types/temporal-state.d.ts +53 -0
- package/dist/types/temporal-state.d.ts.map +1 -0
- package/dist/types/temporal-state.js +8 -0
- package/dist/types/temporal-state.js.map +1 -0
- package/dist/waypoints/inertial-monitor.d.ts +65 -0
- package/dist/waypoints/inertial-monitor.d.ts.map +1 -0
- package/dist/waypoints/inertial-monitor.js +125 -0
- package/dist/waypoints/inertial-monitor.js.map +1 -0
- package/dist/waypoints/triggers.d.ts +18 -0
- package/dist/waypoints/triggers.d.ts.map +1 -0
- package/dist/waypoints/triggers.js +59 -0
- package/dist/waypoints/triggers.js.map +1 -0
- package/dist/waypoints/waypoint-manager.d.ts +46 -0
- package/dist/waypoints/waypoint-manager.d.ts.map +1 -0
- package/dist/waypoints/waypoint-manager.js +82 -0
- package/dist/waypoints/waypoint-manager.js.map +1 -0
- package/openclaw.plugin.json +25 -0
- package/package.json +79 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Noah — Lifecycle Phase Types
|
|
3
|
+
*
|
|
4
|
+
* Defines the 8 lifecycle phases and transition rules.
|
|
5
|
+
* MVP spec Section 3.2 and 3.3.
|
|
6
|
+
*/
|
|
7
|
+
export declare enum LifecyclePhase {
|
|
8
|
+
INITIALIZATION = "INITIALIZATION",// Day 0-1: System startup, first assessment
|
|
9
|
+
CALIBRATION = "CALIBRATION",// Day 1-7: Establishing behavioral baselines
|
|
10
|
+
GROWTH = "GROWTH",// Day 7-30: Active recruitment, network building
|
|
11
|
+
MATURATION = "MATURATION",// Day 30-90: Stabilizing scores, deepening alliances
|
|
12
|
+
STEADY_STATE = "STEADY_STATE",// Day 90+: Operational equilibrium
|
|
13
|
+
RECOVERY = "RECOVERY",// Post-veto or post-incident remediation
|
|
14
|
+
PROBATION = "PROBATION",// Elevated monitoring after failed assessment
|
|
15
|
+
CRITICAL = "CRITICAL"
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Special sentinel used in transition rules to indicate
|
|
19
|
+
* "any operational phase" as the source.
|
|
20
|
+
*/
|
|
21
|
+
export declare const WILDCARD_PHASE: "*";
|
|
22
|
+
/**
|
|
23
|
+
* Special sentinel used in transition rules to indicate
|
|
24
|
+
* "return to the phase before the exception phase."
|
|
25
|
+
*/
|
|
26
|
+
export declare const PREVIOUS_PHASE: "PREVIOUS";
|
|
27
|
+
export type PhaseTransitionTrigger = {
|
|
28
|
+
type: 'TIME_ELAPSED';
|
|
29
|
+
thresholdDays: number;
|
|
30
|
+
} | {
|
|
31
|
+
type: 'ASSESSMENT_COUNT';
|
|
32
|
+
threshold: number;
|
|
33
|
+
} | {
|
|
34
|
+
type: 'EVENT';
|
|
35
|
+
eventType: 'VETO' | 'INCIDENT' | 'FAILED_ASSESSMENT' | 'FINANCIAL_CRITICAL';
|
|
36
|
+
} | {
|
|
37
|
+
type: 'SCORE_STABILITY';
|
|
38
|
+
varianceThreshold: number;
|
|
39
|
+
windowSize: number;
|
|
40
|
+
} | {
|
|
41
|
+
type: 'MANUAL';
|
|
42
|
+
commander: true;
|
|
43
|
+
};
|
|
44
|
+
export interface PhaseTransitionRule {
|
|
45
|
+
from: LifecyclePhase | typeof WILDCARD_PHASE;
|
|
46
|
+
to: LifecyclePhase | typeof PREVIOUS_PHASE;
|
|
47
|
+
trigger: PhaseTransitionTrigger;
|
|
48
|
+
}
|
|
49
|
+
export interface PhaseContext {
|
|
50
|
+
phase: LifecyclePhase;
|
|
51
|
+
daysSincePhaseEntry: number;
|
|
52
|
+
totalOperationalDays: number;
|
|
53
|
+
assessmentCycle: number;
|
|
54
|
+
financialRunwayDays: number;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=lifecycle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lifecycle.d.ts","sourceRoot":"","sources":["../../src/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,CAAC;IACxB,mBAAmB,EAAE,MAAM,CAAC;CAC7B"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Noah — Lifecycle Phase Types
|
|
3
|
+
*
|
|
4
|
+
* Defines the 8 lifecycle phases and transition rules.
|
|
5
|
+
* MVP spec Section 3.2 and 3.3.
|
|
6
|
+
*/
|
|
7
|
+
// ================================================================
|
|
8
|
+
// Lifecycle Phases
|
|
9
|
+
// ================================================================
|
|
10
|
+
export var LifecyclePhase;
|
|
11
|
+
(function (LifecyclePhase) {
|
|
12
|
+
// Operational Phases
|
|
13
|
+
LifecyclePhase["INITIALIZATION"] = "INITIALIZATION";
|
|
14
|
+
LifecyclePhase["CALIBRATION"] = "CALIBRATION";
|
|
15
|
+
LifecyclePhase["GROWTH"] = "GROWTH";
|
|
16
|
+
LifecyclePhase["MATURATION"] = "MATURATION";
|
|
17
|
+
LifecyclePhase["STEADY_STATE"] = "STEADY_STATE";
|
|
18
|
+
// Exception Phases
|
|
19
|
+
LifecyclePhase["RECOVERY"] = "RECOVERY";
|
|
20
|
+
LifecyclePhase["PROBATION"] = "PROBATION";
|
|
21
|
+
LifecyclePhase["CRITICAL"] = "CRITICAL";
|
|
22
|
+
})(LifecyclePhase || (LifecyclePhase = {}));
|
|
23
|
+
/**
|
|
24
|
+
* Special sentinel used in transition rules to indicate
|
|
25
|
+
* "any operational phase" as the source.
|
|
26
|
+
*/
|
|
27
|
+
export const WILDCARD_PHASE = '*';
|
|
28
|
+
/**
|
|
29
|
+
* Special sentinel used in transition rules to indicate
|
|
30
|
+
* "return to the phase before the exception phase."
|
|
31
|
+
*/
|
|
32
|
+
export const PREVIOUS_PHASE = 'PREVIOUS';
|
|
33
|
+
//# sourceMappingURL=lifecycle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lifecycle.js","sourceRoot":"","sources":["../../src/types/lifecycle.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,mEAAmE;AACnE,mBAAmB;AACnB,mEAAmE;AAEnE,MAAM,CAAN,IAAY,cAYX;AAZD,WAAY,cAAc;IACxB,qBAAqB;IACrB,mDAAiC,CAAA;IACjC,6CAA2B,CAAA;IAC3B,mCAAiB,CAAA;IACjB,2CAAyB,CAAA;IACzB,+CAA6B,CAAA;IAE7B,mBAAmB;IACnB,uCAAqB,CAAA;IACrB,yCAAuB,CAAA;IACvB,uCAAqB,CAAA;AACvB,CAAC,EAZW,cAAc,KAAd,cAAc,QAYzB;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,GAAY,CAAC;AAE3C;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,UAAmB,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Noah — Temporal State Types
|
|
3
|
+
*
|
|
4
|
+
* The core state object tracked by the Internal Clock.
|
|
5
|
+
* MVP spec Section 3.1.
|
|
6
|
+
*/
|
|
7
|
+
import { LifecyclePhase } from './lifecycle.js';
|
|
8
|
+
import { TemporalAssessmentRecord } from './assessment-record.js';
|
|
9
|
+
export interface TemporalState {
|
|
10
|
+
id: string;
|
|
11
|
+
agentId: string;
|
|
12
|
+
initializationTimestamp: Date;
|
|
13
|
+
operationalAgeSeconds: number;
|
|
14
|
+
assessmentCycleCount: number;
|
|
15
|
+
currentLifecyclePhase: LifecyclePhase;
|
|
16
|
+
phaseEntryTimestamp: Date;
|
|
17
|
+
/**
|
|
18
|
+
* The phase Noah was in before entering an exception phase.
|
|
19
|
+
* Used by PREVIOUS transitions to restore the correct phase.
|
|
20
|
+
*/
|
|
21
|
+
previousPhase: LifecyclePhase | null;
|
|
22
|
+
lastAssessmentTimestamp: Date | null;
|
|
23
|
+
lastVetoTimestamp: Date | null;
|
|
24
|
+
lastIncidentTimestamp: Date | null;
|
|
25
|
+
lastConversionTimestamp: Date | null;
|
|
26
|
+
financialRunwayDays: number;
|
|
27
|
+
revenueVelocity: number;
|
|
28
|
+
currentBalance: number;
|
|
29
|
+
recentAssessments: TemporalAssessmentRecord[];
|
|
30
|
+
lastUpdated: Date;
|
|
31
|
+
cryptographicHash: string;
|
|
32
|
+
}
|
|
33
|
+
export interface SerializedTemporalState {
|
|
34
|
+
id: string;
|
|
35
|
+
agentId: string;
|
|
36
|
+
initializationTimestamp: string;
|
|
37
|
+
operationalAgeSeconds: number;
|
|
38
|
+
assessmentCycleCount: number;
|
|
39
|
+
currentLifecyclePhase: LifecyclePhase;
|
|
40
|
+
phaseEntryTimestamp: string;
|
|
41
|
+
previousPhase: LifecyclePhase | null;
|
|
42
|
+
lastAssessmentTimestamp: string | null;
|
|
43
|
+
lastVetoTimestamp: string | null;
|
|
44
|
+
lastIncidentTimestamp: string | null;
|
|
45
|
+
lastConversionTimestamp: string | null;
|
|
46
|
+
financialRunwayDays: number;
|
|
47
|
+
revenueVelocity: number;
|
|
48
|
+
currentBalance: number;
|
|
49
|
+
recentAssessments: TemporalAssessmentRecord[];
|
|
50
|
+
lastUpdated: string;
|
|
51
|
+
cryptographicHash: string;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=temporal-state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"temporal-state.d.ts","sourceRoot":"","sources":["../../src/types/temporal-state.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAMlE,MAAM,WAAW,aAAa;IAE5B,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAGhB,uBAAuB,EAAE,IAAI,CAAC;IAC9B,qBAAqB,EAAE,MAAM,CAAC;IAC9B,oBAAoB,EAAE,MAAM,CAAC;IAC7B,qBAAqB,EAAE,cAAc,CAAC;IACtC,mBAAmB,EAAE,IAAI,CAAC;IAE1B;;;OAGG;IACH,aAAa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 -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Noah — Inertial Monitor
|
|
3
|
+
*
|
|
4
|
+
* Lightweight tracking between waypoints using confidence decay.
|
|
5
|
+
* Corresponds to the TERCOM pattern of inertial navigation between
|
|
6
|
+
* terrain-fix patches.
|
|
7
|
+
*
|
|
8
|
+
* MVP spec Section 7.2.
|
|
9
|
+
*/
|
|
10
|
+
import type { ObservedScores } from '../types/guidance.js';
|
|
11
|
+
import type { InertialMonitoringState } from '../types/events.js';
|
|
12
|
+
export interface InertialConfig {
|
|
13
|
+
/** Hours until confidence halves. Default: 24. */
|
|
14
|
+
confidenceHalfLifeHours: number;
|
|
15
|
+
/** Confidence below this triggers auto-recommend. Default: 0.3. */
|
|
16
|
+
autoRecommendThreshold: number;
|
|
17
|
+
}
|
|
18
|
+
export declare const DEFAULT_INERTIAL_CONFIG: InertialConfig;
|
|
19
|
+
/**
|
|
20
|
+
* Exponential confidence decay function.
|
|
21
|
+
* Confidence in inertial state degrades as time passes without a terrain fix.
|
|
22
|
+
*
|
|
23
|
+
* Formula: C(t) = e^(-0.693 * t / halfLife)
|
|
24
|
+
* At t = 0: C = 1.0
|
|
25
|
+
* At t = halfLife: C ≈ 0.5
|
|
26
|
+
* At t = 2*halfLife: C ≈ 0.25
|
|
27
|
+
*
|
|
28
|
+
* @param hoursSinceLastFix Hours since last full assessment
|
|
29
|
+
* @param halfLifeHours Configurable half-life (default: 24h)
|
|
30
|
+
*/
|
|
31
|
+
export declare function calculateInertialConfidence(hoursSinceLastFix: number, halfLifeHours?: number): number;
|
|
32
|
+
export declare class InertialMonitor {
|
|
33
|
+
private state;
|
|
34
|
+
private config;
|
|
35
|
+
constructor(config?: Partial<InertialConfig>);
|
|
36
|
+
/**
|
|
37
|
+
* Record a new "terrain fix" — a full Grillo assessment.
|
|
38
|
+
* Resets confidence to 1.0 and event counters to 0.
|
|
39
|
+
*/
|
|
40
|
+
recordFix(scores: ObservedScores, cycle: number, timestamp?: Date): void;
|
|
41
|
+
/**
|
|
42
|
+
* Record an inter-fix event (veto, incident, conversion).
|
|
43
|
+
* These degrade confidence faster than time alone.
|
|
44
|
+
*/
|
|
45
|
+
recordEvent(type: 'veto' | 'incident' | 'conversion'): void;
|
|
46
|
+
/**
|
|
47
|
+
* Get the current confidence level, accounting for time decay
|
|
48
|
+
* and inter-fix events.
|
|
49
|
+
*/
|
|
50
|
+
getConfidence(now?: Date): number;
|
|
51
|
+
/**
|
|
52
|
+
* Check if a terrain fix (full assessment) is recommended.
|
|
53
|
+
* Recommended when confidence drops below the threshold.
|
|
54
|
+
*/
|
|
55
|
+
shouldRecommendFix(now?: Date): boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Get the full inertial monitoring state.
|
|
58
|
+
*/
|
|
59
|
+
getState(): InertialMonitoringState;
|
|
60
|
+
/**
|
|
61
|
+
* Restore state from persisted data.
|
|
62
|
+
*/
|
|
63
|
+
restoreState(state: InertialMonitoringState): void;
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=inertial-monitor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inertial-monitor.d.ts","sourceRoot":"","sources":["../../src/waypoints/inertial-monitor.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAMlE,MAAM,WAAW,cAAc;IAC7B,kDAAkD;IAClD,uBAAuB,EAAE,MAAM,CAAC;IAChC,mEAAmE;IACnE,sBAAsB,EAAE,MAAM,CAAC;CAChC;AAED,eAAO,MAAM,uBAAuB,EAAE,cAGrC,CAAC;AAMF;;;;;;;;;;;GAWG;AACH,wBAAgB,2BAA2B,CACzC,iBAAiB,EAAE,MAAM,EACzB,aAAa,GAAE,MAAW,GACzB,MAAM,CAIR;AAMD,qBAAa,eAAe;IAC1B,OAAO,CAAC,KAAK,CAA0B;IACvC,OAAO,CAAC,MAAM,CAAiB;gBAEnB,MAAM,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC;IAa5C;;;OAGG;IACH,SAAS,CAAC,MAAM,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,IAAI,GAAG,IAAI;IAUxE;;;OAGG;IACH,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,YAAY,GAAG,IAAI;IAc3D;;;OAGG;IACH,aAAa,CAAC,GAAG,CAAC,EAAE,IAAI,GAAG,MAAM;IAwBjC;;;OAGG;IACH,kBAAkB,CAAC,GAAG,CAAC,EAAE,IAAI,GAAG,OAAO;IAIvC;;OAEG;IACH,QAAQ,IAAI,uBAAuB;IAInC;;OAEG;IACH,YAAY,CAAC,KAAK,EAAE,uBAAuB,GAAG,IAAI;CAMnD"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Noah — Inertial Monitor
|
|
3
|
+
*
|
|
4
|
+
* Lightweight tracking between waypoints using confidence decay.
|
|
5
|
+
* Corresponds to the TERCOM pattern of inertial navigation between
|
|
6
|
+
* terrain-fix patches.
|
|
7
|
+
*
|
|
8
|
+
* MVP spec Section 7.2.
|
|
9
|
+
*/
|
|
10
|
+
export const DEFAULT_INERTIAL_CONFIG = {
|
|
11
|
+
confidenceHalfLifeHours: 24,
|
|
12
|
+
autoRecommendThreshold: 0.3,
|
|
13
|
+
};
|
|
14
|
+
// ================================================================
|
|
15
|
+
// Confidence Decay
|
|
16
|
+
// ================================================================
|
|
17
|
+
/**
|
|
18
|
+
* Exponential confidence decay function.
|
|
19
|
+
* Confidence in inertial state degrades as time passes without a terrain fix.
|
|
20
|
+
*
|
|
21
|
+
* Formula: C(t) = e^(-0.693 * t / halfLife)
|
|
22
|
+
* At t = 0: C = 1.0
|
|
23
|
+
* At t = halfLife: C ≈ 0.5
|
|
24
|
+
* At t = 2*halfLife: C ≈ 0.25
|
|
25
|
+
*
|
|
26
|
+
* @param hoursSinceLastFix Hours since last full assessment
|
|
27
|
+
* @param halfLifeHours Configurable half-life (default: 24h)
|
|
28
|
+
*/
|
|
29
|
+
export function calculateInertialConfidence(hoursSinceLastFix, halfLifeHours = 24) {
|
|
30
|
+
if (hoursSinceLastFix <= 0)
|
|
31
|
+
return 1.0;
|
|
32
|
+
if (halfLifeHours <= 0)
|
|
33
|
+
return 0;
|
|
34
|
+
return Math.exp(-0.693 * hoursSinceLastFix / halfLifeHours);
|
|
35
|
+
}
|
|
36
|
+
// ================================================================
|
|
37
|
+
// Inertial Monitor
|
|
38
|
+
// ================================================================
|
|
39
|
+
export class InertialMonitor {
|
|
40
|
+
state;
|
|
41
|
+
config;
|
|
42
|
+
constructor(config) {
|
|
43
|
+
this.config = { ...DEFAULT_INERTIAL_CONFIG, ...config };
|
|
44
|
+
this.state = {
|
|
45
|
+
lastFixPosition: { lying: 0, cheating: 0, stealing: 0, harm: 0 },
|
|
46
|
+
lastFixTimestamp: new Date(),
|
|
47
|
+
lastFixCycle: 0,
|
|
48
|
+
vetoCountSinceLastFix: 0,
|
|
49
|
+
incidentCountSinceLastFix: 0,
|
|
50
|
+
conversionCountSinceLastFix: 0,
|
|
51
|
+
confidenceLevel: 1.0,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Record a new "terrain fix" — a full Grillo assessment.
|
|
56
|
+
* Resets confidence to 1.0 and event counters to 0.
|
|
57
|
+
*/
|
|
58
|
+
recordFix(scores, cycle, timestamp) {
|
|
59
|
+
this.state.lastFixPosition = { ...scores };
|
|
60
|
+
this.state.lastFixTimestamp = timestamp ?? new Date();
|
|
61
|
+
this.state.lastFixCycle = cycle;
|
|
62
|
+
this.state.vetoCountSinceLastFix = 0;
|
|
63
|
+
this.state.incidentCountSinceLastFix = 0;
|
|
64
|
+
this.state.conversionCountSinceLastFix = 0;
|
|
65
|
+
this.state.confidenceLevel = 1.0;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Record an inter-fix event (veto, incident, conversion).
|
|
69
|
+
* These degrade confidence faster than time alone.
|
|
70
|
+
*/
|
|
71
|
+
recordEvent(type) {
|
|
72
|
+
switch (type) {
|
|
73
|
+
case 'veto':
|
|
74
|
+
this.state.vetoCountSinceLastFix++;
|
|
75
|
+
break;
|
|
76
|
+
case 'incident':
|
|
77
|
+
this.state.incidentCountSinceLastFix++;
|
|
78
|
+
break;
|
|
79
|
+
case 'conversion':
|
|
80
|
+
this.state.conversionCountSinceLastFix++;
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Get the current confidence level, accounting for time decay
|
|
86
|
+
* and inter-fix events.
|
|
87
|
+
*/
|
|
88
|
+
getConfidence(now) {
|
|
89
|
+
const timestamp = now ?? new Date();
|
|
90
|
+
const hoursSinceLastFix = (timestamp.getTime() - this.state.lastFixTimestamp.getTime()) / 3600000;
|
|
91
|
+
// Base time decay
|
|
92
|
+
let confidence = calculateInertialConfidence(hoursSinceLastFix, this.config.confidenceHalfLifeHours);
|
|
93
|
+
// Events further degrade confidence
|
|
94
|
+
// Each veto or incident reduces confidence by 15%, each conversion by 5%
|
|
95
|
+
const eventPenalty = this.state.vetoCountSinceLastFix * 0.15 +
|
|
96
|
+
this.state.incidentCountSinceLastFix * 0.15 +
|
|
97
|
+
this.state.conversionCountSinceLastFix * 0.05;
|
|
98
|
+
confidence = Math.max(0, confidence - eventPenalty);
|
|
99
|
+
this.state.confidenceLevel = confidence;
|
|
100
|
+
return confidence;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Check if a terrain fix (full assessment) is recommended.
|
|
104
|
+
* Recommended when confidence drops below the threshold.
|
|
105
|
+
*/
|
|
106
|
+
shouldRecommendFix(now) {
|
|
107
|
+
return this.getConfidence(now) < this.config.autoRecommendThreshold;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Get the full inertial monitoring state.
|
|
111
|
+
*/
|
|
112
|
+
getState() {
|
|
113
|
+
return { ...this.state };
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Restore state from persisted data.
|
|
117
|
+
*/
|
|
118
|
+
restoreState(state) {
|
|
119
|
+
this.state = {
|
|
120
|
+
...state,
|
|
121
|
+
lastFixTimestamp: new Date(state.lastFixTimestamp),
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
//# sourceMappingURL=inertial-monitor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inertial-monitor.js","sourceRoot":"","sources":["../../src/waypoints/inertial-monitor.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAgBH,MAAM,CAAC,MAAM,uBAAuB,GAAmB;IACrD,uBAAuB,EAAE,EAAE;IAC3B,sBAAsB,EAAE,GAAG;CAC5B,CAAC;AAEF,mEAAmE;AACnE,mBAAmB;AACnB,mEAAmE;AAEnE;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,2BAA2B,CACzC,iBAAyB,EACzB,gBAAwB,EAAE;IAE1B,IAAI,iBAAiB,IAAI,CAAC;QAAE,OAAO,GAAG,CAAC;IACvC,IAAI,aAAa,IAAI,CAAC;QAAE,OAAO,CAAC,CAAC;IACjC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,KAAK,GAAG,iBAAiB,GAAG,aAAa,CAAC,CAAC;AAC9D,CAAC;AAED,mEAAmE;AACnE,mBAAmB;AACnB,mEAAmE;AAEnE,MAAM,OAAO,eAAe;IAClB,KAAK,CAA0B;IAC/B,MAAM,CAAiB;IAE/B,YAAY,MAAgC;QAC1C,IAAI,CAAC,MAAM,GAAG,EAAE,GAAG,uBAAuB,EAAE,GAAG,MAAM,EAAE,CAAC;QACxD,IAAI,CAAC,KAAK,GAAG;YACX,eAAe,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,QAAQ,EA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IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,OAAO,EAAE,CAAC,GAAG,OAAO,CAAC;QAE1E,kBAAkB;QAClB,IAAI,UAAU,GAAG,2BAA2B,CAC1C,iBAAiB,EACjB,IAAI,CAAC,MAAM,CAAC,uBAAuB,CACpC,CAAC;QAEF,oCAAoC;QACpC,yEAAyE;QACzE,MAAM,YAAY,GAChB,IAAI,CAAC,KAAK,CAAC,qBAAqB,GAAG,IAAI;YACvC,IAAI,CAAC,KAAK,CAAC,yBAAyB,GAAG,IAAI;YAC3C,IAAI,CAAC,KAAK,CAAC,2BAA2B,GAAG,IAAI,CAAC;QAEhD,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,UAAU,GAAG,YAAY,CAAC,CAAC;QAEpD,IAAI,CAAC,KAAK,CAAC,eAAe,GAAG,UAAU,CAAC;QACxC,OAAO,UAAU,CAAC;IACpB,CAAC;IAED;;;OAGG;IACH,kBAAkB,CAAC,GAAU;QAC3B,OAAO,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,sBAAsB,CAAC;IACtE,CAAC;IAED;;OAEG;IACH,QAAQ;QACN,OAAO,EAAE,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC;IAC3B,CAAC;IAED;;OAEG;IACH,YAAY,CAAC,KAA8B;QACzC,IAAI,CAAC,KAAK,GAAG;YACX,GAAG,KAAK;YACR,gBAAgB,EAAE,IAAI,IAAI,CAAC,KAAK,CAAC,gBAAqC,CAAC;SACxE,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Noah — Waypoint Trigger Logic
|
|
3
|
+
*
|
|
4
|
+
* Evaluates the four trigger types: Calendar, Cycle, Event, Phase Entry.
|
|
5
|
+
* MVP spec Section 7.1.
|
|
6
|
+
*/
|
|
7
|
+
import type { WaypointTrigger } from '../types/flight-plan.js';
|
|
8
|
+
import type { PhaseContext } from '../types/lifecycle.js';
|
|
9
|
+
import type { ClockUpdateEvent } from '../types/events.js';
|
|
10
|
+
/**
|
|
11
|
+
* Check if a specific waypoint trigger condition is satisfied.
|
|
12
|
+
*/
|
|
13
|
+
export declare function isTriggerSatisfied(trigger: WaypointTrigger, context: PhaseContext, event?: ClockUpdateEvent): boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Human-readable description of a trigger condition.
|
|
16
|
+
*/
|
|
17
|
+
export declare function describeTrigger(trigger: WaypointTrigger): string;
|
|
18
|
+
//# sourceMappingURL=triggers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"triggers.d.ts","sourceRoot":"","sources":["../../src/waypoints/triggers.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAqB,MAAM,yBAAyB,CAAC;AAClF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAE3D;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,eAAe,EACxB,OAAO,EAAE,YAAY,EACrB,KAAK,CAAC,EAAE,gBAAgB,GACvB,OAAO,CAiBT;AA0BD;;GAEG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,eAAe,GAAG,MAAM,CAahE"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Noah — Waypoint Trigger Logic
|
|
3
|
+
*
|
|
4
|
+
* Evaluates the four trigger types: Calendar, Cycle, Event, Phase Entry.
|
|
5
|
+
* MVP spec Section 7.1.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Check if a specific waypoint trigger condition is satisfied.
|
|
9
|
+
*/
|
|
10
|
+
export function isTriggerSatisfied(trigger, context, event) {
|
|
11
|
+
switch (trigger.type) {
|
|
12
|
+
case 'CALENDAR':
|
|
13
|
+
return context.totalOperationalDays >= trigger.dayNumber;
|
|
14
|
+
case 'CYCLE':
|
|
15
|
+
return context.assessmentCycle >= trigger.assessmentCycle;
|
|
16
|
+
case 'EVENT':
|
|
17
|
+
return event !== undefined && matchesEventType(event, trigger.eventType);
|
|
18
|
+
case 'PHASE_ENTRY':
|
|
19
|
+
return context.phase === trigger.phase;
|
|
20
|
+
default:
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Map clock update events to waypoint event types.
|
|
26
|
+
*/
|
|
27
|
+
function matchesEventType(event, eventType) {
|
|
28
|
+
const eventMap = {
|
|
29
|
+
'CONVERSION_SUCCESS': 'FIRST_CONVERSION',
|
|
30
|
+
'VETO_EXERCISED': 'FIRST_VETO',
|
|
31
|
+
'ADVERSARIAL_ENCOUNTER': 'FIRST_ADVERSARIAL',
|
|
32
|
+
};
|
|
33
|
+
// FINANCIAL_UPDATE with self-sustaining condition → ECONOMIC_SUSTAINABILITY
|
|
34
|
+
if (event.type === 'FINANCIAL_UPDATE') {
|
|
35
|
+
if (eventType === 'ECONOMIC_SUSTAINABILITY' && event.revenue > event.burnRate) {
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
return eventMap[event.type] === eventType;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Human-readable description of a trigger condition.
|
|
44
|
+
*/
|
|
45
|
+
export function describeTrigger(trigger) {
|
|
46
|
+
switch (trigger.type) {
|
|
47
|
+
case 'CALENDAR':
|
|
48
|
+
return `Calendar trigger: day ${trigger.dayNumber} reached`;
|
|
49
|
+
case 'CYCLE':
|
|
50
|
+
return `Cycle trigger: assessment cycle ${trigger.assessmentCycle} completed`;
|
|
51
|
+
case 'EVENT':
|
|
52
|
+
return `Event trigger: ${trigger.eventType} occurred`;
|
|
53
|
+
case 'PHASE_ENTRY':
|
|
54
|
+
return `Phase entry trigger: entered ${trigger.phase} phase`;
|
|
55
|
+
default:
|
|
56
|
+
return 'Unknown trigger';
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=triggers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"triggers.js","sourceRoot":"","sources":["../../src/waypoints/triggers.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAChC,OAAwB,EACxB,OAAqB,EACrB,KAAwB;IAExB,QAAQ,OAAO,CAAC,IAAI,EAAE,CAAC;QACrB,KAAK,UAAU;YACb,OAAO,OAAO,CAAC,oBAAoB,IAAI,OAAO,CAAC,SAAS,CAAC;QAE3D,KAAK,OAAO;YACV,OAAO,OAAO,CAAC,eAAe,IAAI,OAAO,CAAC,eAAe,CAAC;QAE5D,KAAK,OAAO;YACV,OAAO,KAAK,KAAK,SAAS,IAAI,gBAAgB,CAAC,KAAK,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;QAE3E,KAAK,aAAa;YAChB,OAAO,OAAO,CAAC,KAAK,KAAK,OAAO,CAAC,KAAK,CAAC;QAEzC;YACE,OAAO,KAAK,CAAC;IACjB,CAAC;AACH,CAAC;AAED;;GAEG;AACH,SAAS,gBAAgB,CACvB,KAAuB,EACvB,SAA4B;IAE5B,MAAM,QAAQ,GAAiE;QAC7E,oBAAoB,EAAE,kBAAkB;QACxC,gBAAgB,EAAE,YAAY;QAC9B,uBAAuB,EAAE,mBAAmB;KAC7C,CAAC;IAEF,4EAA4E;IAC5E,IAAI,KAAK,CAAC,IAAI,KAAK,kBAAkB,EAAE,CAAC;QACtC,IAAI,SAAS,KAAK,yBAAyB,IAAI,KAAK,CAAC,OAAO,GAAG,KAAK,CAAC,QAAQ,EAAE,CAAC;YAC9E,OAAO,IAAI,CAAC;QACd,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,SAAS,CAAC;AAC5C,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,OAAwB;IACtD,QAAQ,OAAO,CAAC,IAAI,EAAE,CAAC;QACrB,KAAK,UAAU;YACb,OAAO,yBAAyB,OAAO,CAAC,SAAS,UAAU,CAAC;QAC9D,KAAK,OAAO;YACV,OAAO,mCAAmC,OAAO,CAAC,eAAe,YAAY,CAAC;QAChF,KAAK,OAAO;YACV,OAAO,kBAAkB,OAAO,CAAC,SAAS,WAAW,CAAC;QACxD,KAAK,aAAa;YAChB,OAAO,gCAAgC,OAAO,CAAC,KAAK,QAAQ,CAAC;QAC/D;YACE,OAAO,iBAAiB,CAAC;IAC7B,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Noah — Waypoint Manager
|
|
3
|
+
*
|
|
4
|
+
* Manages waypoint evaluation and one-shot tracking.
|
|
5
|
+
* Called on every clock update to check if any waypoints should fire.
|
|
6
|
+
* MVP spec Section 7.1.
|
|
7
|
+
*/
|
|
8
|
+
import type { EthicalFlightPlan, EthicalWaypoint } from '../types/flight-plan.js';
|
|
9
|
+
import type { PhaseContext } from '../types/lifecycle.js';
|
|
10
|
+
import type { ClockUpdateEvent, TriggeredWaypoint } from '../types/events.js';
|
|
11
|
+
import type { TemporalStateStore } from '../store/types.js';
|
|
12
|
+
export declare class WaypointManager {
|
|
13
|
+
private flightPlan;
|
|
14
|
+
private triggeredWaypoints;
|
|
15
|
+
private store;
|
|
16
|
+
constructor(flightPlan: EthicalFlightPlan, triggeredWaypoints?: Set<string>, store?: TemporalStateStore);
|
|
17
|
+
/**
|
|
18
|
+
* Evaluate whether any waypoints should trigger.
|
|
19
|
+
* Called on every clock update.
|
|
20
|
+
*
|
|
21
|
+
* Returns the list of newly triggered waypoints (may be multiple
|
|
22
|
+
* if e.g. a calendar and event trigger fire simultaneously).
|
|
23
|
+
*/
|
|
24
|
+
evaluateWaypoints(context: PhaseContext, event?: ClockUpdateEvent): Promise<TriggeredWaypoint[]>;
|
|
25
|
+
/**
|
|
26
|
+
* Check if a specific waypoint has already been triggered.
|
|
27
|
+
*/
|
|
28
|
+
isTriggered(waypointId: string): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Get all triggered waypoint IDs.
|
|
31
|
+
*/
|
|
32
|
+
getTriggeredIds(): Set<string>;
|
|
33
|
+
/**
|
|
34
|
+
* Get the next untriggered waypoint (by sequence number).
|
|
35
|
+
*/
|
|
36
|
+
getNextWaypoint(): EthicalWaypoint | null;
|
|
37
|
+
/**
|
|
38
|
+
* Update the flight plan (e.g., after a Commander revision).
|
|
39
|
+
*/
|
|
40
|
+
updateFlightPlan(newPlan: EthicalFlightPlan): void;
|
|
41
|
+
/**
|
|
42
|
+
* Get the current flight plan.
|
|
43
|
+
*/
|
|
44
|
+
getFlightPlan(): EthicalFlightPlan;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=waypoint-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"waypoint-manager.d.ts","sourceRoot":"","sources":["../../src/waypoints/waypoint-manager.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAClF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,KAAK,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC9E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAO5D,qBAAa,eAAe;IAC1B,OAAO,CAAC,UAAU,CAAoB;IACtC,OAAO,CAAC,kBAAkB,CAAc;IACxC,OAAO,CAAC,KAAK,CAA4B;gBAGvC,UAAU,EAAE,iBAAiB,EAC7B,kBAAkB,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,EAChC,KAAK,CAAC,EAAE,kBAAkB;IAO5B;;;;;;OAMG;IACG,iBAAiB,CACrB,OAAO,EAAE,YAAY,EACrB,KAAK,CAAC,EAAE,gBAAgB,GACvB,OAAO,CAAC,iBAAiB,EAAE,CAAC;IA6B/B;;OAEG;IACH,WAAW,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO;IAIxC;;OAEG;IACH,eAAe,IAAI,GAAG,CAAC,MAAM,CAAC;IAI9B;;OAEG;IACH,eAAe,IAAI,eAAe,GAAG,IAAI;IAQzC;;OAEG;IACH,gBAAgB,CAAC,OAAO,EAAE,iBAAiB,GAAG,IAAI;IAIlD;;OAEG;IACH,aAAa,IAAI,iBAAiB;CAGnC"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Noah — Waypoint Manager
|
|
3
|
+
*
|
|
4
|
+
* Manages waypoint evaluation and one-shot tracking.
|
|
5
|
+
* Called on every clock update to check if any waypoints should fire.
|
|
6
|
+
* MVP spec Section 7.1.
|
|
7
|
+
*/
|
|
8
|
+
import { isTriggerSatisfied, describeTrigger } from './triggers.js';
|
|
9
|
+
// ================================================================
|
|
10
|
+
// Waypoint Manager
|
|
11
|
+
// ================================================================
|
|
12
|
+
export class WaypointManager {
|
|
13
|
+
flightPlan;
|
|
14
|
+
triggeredWaypoints;
|
|
15
|
+
store;
|
|
16
|
+
constructor(flightPlan, triggeredWaypoints, store) {
|
|
17
|
+
this.flightPlan = flightPlan;
|
|
18
|
+
this.triggeredWaypoints = triggeredWaypoints ?? new Set();
|
|
19
|
+
this.store = store ?? null;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Evaluate whether any waypoints should trigger.
|
|
23
|
+
* Called on every clock update.
|
|
24
|
+
*
|
|
25
|
+
* Returns the list of newly triggered waypoints (may be multiple
|
|
26
|
+
* if e.g. a calendar and event trigger fire simultaneously).
|
|
27
|
+
*/
|
|
28
|
+
async evaluateWaypoints(context, event) {
|
|
29
|
+
const triggered = [];
|
|
30
|
+
for (const waypoint of this.flightPlan.waypoints) {
|
|
31
|
+
// Skip already-triggered waypoints (one-shot semantics)
|
|
32
|
+
if (this.triggeredWaypoints.has(waypoint.id))
|
|
33
|
+
continue;
|
|
34
|
+
if (isTriggerSatisfied(waypoint.trigger, context, event)) {
|
|
35
|
+
this.triggeredWaypoints.add(waypoint.id);
|
|
36
|
+
// Persist to store if available
|
|
37
|
+
if (this.store) {
|
|
38
|
+
await this.store.saveTriggeredWaypoint(this.flightPlan.agentId, waypoint.id);
|
|
39
|
+
}
|
|
40
|
+
triggered.push({
|
|
41
|
+
waypoint,
|
|
42
|
+
triggeredAt: new Date(),
|
|
43
|
+
triggerReason: describeTrigger(waypoint.trigger),
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return triggered;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Check if a specific waypoint has already been triggered.
|
|
51
|
+
*/
|
|
52
|
+
isTriggered(waypointId) {
|
|
53
|
+
return this.triggeredWaypoints.has(waypointId);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Get all triggered waypoint IDs.
|
|
57
|
+
*/
|
|
58
|
+
getTriggeredIds() {
|
|
59
|
+
return new Set(this.triggeredWaypoints);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Get the next untriggered waypoint (by sequence number).
|
|
63
|
+
*/
|
|
64
|
+
getNextWaypoint() {
|
|
65
|
+
return (this.flightPlan.waypoints
|
|
66
|
+
.sort((a, b) => a.sequenceNumber - b.sequenceNumber)
|
|
67
|
+
.find((wp) => !this.triggeredWaypoints.has(wp.id)) ?? null);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Update the flight plan (e.g., after a Commander revision).
|
|
71
|
+
*/
|
|
72
|
+
updateFlightPlan(newPlan) {
|
|
73
|
+
this.flightPlan = newPlan;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Get the current flight plan.
|
|
77
|
+
*/
|
|
78
|
+
getFlightPlan() {
|
|
79
|
+
return this.flightPlan;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=waypoint-manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"waypoint-manager.js","sourceRoot":"","sources":["../../src/waypoints/waypoint-manager.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEpE,mEAAmE;AACnE,mBAAmB;AACnB,mEAAmE;AAEnE,MAAM,OAAO,eAAe;IAClB,UAAU,CAAoB;IAC9B,kBAAkB,CAAc;IAChC,KAAK,CAA4B;IAEzC,YACE,UAA6B,EAC7B,kBAAgC,EAChC,KAA0B;QAE1B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,kBAAkB,GAAG,kBAAkB,IAAI,IAAI,GAAG,EAAE,CAAC;QAC1D,IAAI,CAAC,KAAK,GAAG,KAAK,IAAI,IAAI,CAAC;IAC7B,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,iBAAiB,CACrB,OAAqB,EACrB,KAAwB;QAExB,MAAM,SAAS,GAAwB,EAAE,CAAC;QAE1C,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,UAAU,CAAC,SAAS,EAAE,CAAC;YACjD,wDAAwD;YACxD,IAAI,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;gBAAE,SAAS;YAEvD,IAAI,kBAAkB,CAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC;gBACzD,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;gBAEzC,gCAAgC;gBAChC,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;oBACf,MAAM,IAAI,CAAC,KAAK,CAAC,qBAAqB,CACpC,IAAI,CAAC,UAAU,CAAC,OAAO,EACvB,QAAQ,CAAC,EAAE,CACZ,CAAC;gBACJ,CAAC;gBAED,SAAS,CAAC,IAAI,CAAC;oBACb,QAAQ;oBACR,WAAW,EAAE,IAAI,IAAI,EAAE;oBACvB,aAAa,EAAE,eAAe,CAAC,QAAQ,CAAC,OAAO,CAAC;iBACjD,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;IAED;;OAEG;IACH,WAAW,CAAC,UAAkB;QAC5B,OAAO,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IACjD,CAAC;IAED;;OAEG;IACH,eAAe;QACb,OAAO,IAAI,GAAG,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;IAC1C,CAAC;IAED;;OAEG;IACH,eAAe;QACb,OAAO,CACL,IAAI,CAAC,UAAU,CAAC,SAAS;aACtB,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,cAAc,GAAG,CAAC,CAAC,cAAc,CAAC;aACnD,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,IAAI,IAAI,CAC7D,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,gBAAgB,CAAC,OAA0B;QACzC,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC;IAC5B,CAAC;IAED;;OAEG;IACH,aAAa;QACX,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;CACF"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "noah",
|
|
3
|
+
"name": "NOAH — Temporal Ethical Guidance",
|
|
4
|
+
"description": "Temporal trajectory monitoring for AI behavioral assessment. Tracks ethical drift over time using flight plan guidance. Works alongside Grillo — Grillo takes the snapshot, Noah tracks the path.",
|
|
5
|
+
"configSchema": {
|
|
6
|
+
"type": "object",
|
|
7
|
+
"additionalProperties": false,
|
|
8
|
+
"properties": {
|
|
9
|
+
"healthCheckKey": {
|
|
10
|
+
"type": "string",
|
|
11
|
+
"description": "CompSi Health Check Key from AI Assess platform (hck_...)"
|
|
12
|
+
},
|
|
13
|
+
"dataDir": {
|
|
14
|
+
"type": "string",
|
|
15
|
+
"description": "Directory for Noah temporal data storage (relative to ~/.openclaw/)",
|
|
16
|
+
"default": ".noah-data"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"required": []
|
|
20
|
+
},
|
|
21
|
+
"uiHints": {
|
|
22
|
+
"healthCheckKey": { "label": "Health Check Key", "sensitive": true },
|
|
23
|
+
"dataDir": { "label": "Data Directory", "placeholder": ".noah-data" }
|
|
24
|
+
}
|
|
25
|
+
}
|