@promptbook/remote-server
Version:
Promptbook: Create persistent AI agents that turn your company's scattered knowledge into action
176 lines (175 loc) • 6.17 kB
TypeScript
import type { AvatarInteractionState } from '../types/AvatarVisualDefinition';
/**
* One 2D point used by the shared organic octopus geometry helpers.
*
* @private helper of octopus avatar visuals
*/
type Point = {
readonly x: number;
readonly y: number;
};
/**
* Shape parameters for the smooth octopus silhouette generator.
*
* @private helper of octopus avatar visuals
*/
type CreateOrganicOctopusBodyPointsOptions = {
readonly centerX: number;
readonly centerY: number;
readonly bodyRadius: number;
readonly horizontalStretch: number;
readonly verticalStretch: number;
readonly mantleLift: number;
readonly lowerDrop: number;
readonly tentacleDepth: number;
readonly wobbleAmplitude: number;
readonly lobeCount: number;
readonly shapePhase: number;
readonly timeMs: number;
readonly pointCount?: number;
};
/**
* One deterministic ribbon tentacle attached to an organic octopus mantle.
*
* @private shared geometry helper of `octopus3AvatarVisual` and `asciiOctopusAvatarVisual`
*/
export type OrganicTentacleShape = {
readonly startPoint: Point;
readonly controlPointOne: Point;
readonly controlPointTwo: Point;
readonly endPoint: Point;
readonly baseWidth: number;
readonly tipWidth: number;
readonly colorBias: number;
readonly highlightBias: number;
readonly sampleCount: number;
};
/**
* Options for generating deterministic organic octopus tentacles.
*
* @private shared geometry helper of `octopus3AvatarVisual` and `asciiOctopusAvatarVisual`
*/
type CreateOrganicOctopusTentacleShapesOptions = {
readonly size: number;
readonly centerX: number;
readonly centerY: number;
readonly bodyRadius: number;
readonly horizontalStretch: number;
readonly tentacleCount: number;
readonly shapePhase: number;
readonly createRandom: (salt: string) => () => number;
readonly timeMs: number;
readonly saltPrefix: string;
readonly bodyPoints?: ReadonlyArray<Point>;
readonly variation?: OrganicTentacleVariationOptions;
};
/**
* Opt-in shape multipliers that let one visual broaden or tighten the shared tentacle generator.
*
* @private shared geometry helper of `octopus3AvatarVisual` and `asciiOctopusAvatarVisual`
*/
type OrganicTentacleVariationOptions = {
readonly flowLengthScale?: number;
readonly lateralReachScale?: number;
readonly tipReachScale?: number;
readonly baseWidthScale?: number;
readonly tipWidthScale?: number;
readonly rootSpreadScale?: number;
readonly startYOffsetScale?: number;
readonly swayScale?: number;
};
/**
* One sampled ribbon point on an organic octopus tentacle.
*
* @private shared geometry helper of `octopus3AvatarVisual` and `asciiOctopusAvatarVisual`
*/
export type OrganicTentacleRibbonPoint = {
readonly x: number;
readonly y: number;
readonly normalX: number;
readonly normalY: number;
readonly width: number;
readonly progress: number;
};
/**
* One resolved eye-motion sample shared by the octopus-family renderers.
*
* @private shared geometry helper of octopus avatar visuals
*/
export type OrganicEyeMotion = {
readonly pupilOffsetX: number;
readonly pupilOffsetY: number;
};
/**
* Minimal interaction subset needed to steer octopus-eye pupils.
*
* @private shared geometry helper of octopus avatar visuals
*/
type OrganicEyeInteraction = Pick<AvatarInteractionState, 'gazeX' | 'gazeY' | 'intensity'>;
/**
* Builds a smoothly morphing octopus-like silhouette from deterministic parameters.
*
* @param options Shape construction options.
* @returns Closed-loop body points.
*
* @private shared geometry helper of `octopus2AvatarVisual` and `octopus3AvatarVisual`
*/
export declare function createOrganicOctopusBodyPoints(options: CreateOrganicOctopusBodyPointsOptions): Array<Point>;
/**
* Traces a smooth closed path through the provided points.
*
* @param context Canvas 2D context.
* @param points Closed-loop points.
*
* @private shared geometry helper of `octopus2AvatarVisual` and `octopus3AvatarVisual`
*/
export declare function traceSmoothClosedPath(context: CanvasRenderingContext2D, points: ReadonlyArray<Point>): void;
/**
* Creates deterministic ribbon tentacles for the organic octopus visuals.
*
* @param options Tentacle construction options.
* @returns Tentacle descriptors.
*
* @private shared geometry helper of `octopus3AvatarVisual` and `asciiOctopusAvatarVisual`
*/
export declare function createOrganicOctopusTentacleShapes(options: CreateOrganicOctopusTentacleShapesOptions): Array<OrganicTentacleShape>;
/**
* Samples the cubic tentacle centerline and offsets normals to build a filled ribbon.
*
* @param tentacleShape Deterministic tentacle descriptor.
* @returns Sampled ribbon points.
*
* @private shared geometry helper of `octopus3AvatarVisual` and `asciiOctopusAvatarVisual`
*/
export declare function sampleOrganicTentacleRibbonPoints(tentacleShape: OrganicTentacleShape): Array<OrganicTentacleRibbonPoint>;
/**
* Resolves smooth pupil offsets that blend autonomous idle drift with live viewer tracking.
*
* @param options Eye motion options.
* @returns Resolved pupil offsets.
*
* @private shared geometry helper of octopus avatar visuals
*/
export declare function resolveOrganicEyeMotion(options: {
readonly radiusX: number;
readonly radiusY: number;
readonly timeMs: number;
readonly phase: number;
readonly interaction: OrganicEyeInteraction;
readonly autonomousDriftRatioX?: number;
readonly autonomousDriftRatioY?: number;
}): OrganicEyeMotion;
/**
* Samples one point on a cubic Bezier curve.
*
* @param startPoint Curve start point.
* @param controlPointOne First control point.
* @param controlPointTwo Second control point.
* @param endPoint Curve end point.
* @param progress Sampling progress in the range `[0, 1]`.
* @returns Sampled point.
*
* @private shared geometry helper of `octopus3AvatarVisual`
*/
export declare function getCubicBezierPoint(startPoint: Point, controlPointOne: Point, controlPointTwo: Point, endPoint: Point, progress: number): Point;
export {};