@almadar/agent 3.5.7 → 3.5.12

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.
@@ -110,5 +110,19 @@ export interface ReviewOptions {
110
110
  minScore?: number;
111
111
  format?: 'json' | 'table';
112
112
  }
113
+ /**
114
+ * Review collected online evaluation samples.
115
+ *
116
+ * Displays a table or JSON summary of sampled evaluations for a given date,
117
+ * including scores, latency, provider, and success status.
118
+ *
119
+ * @param {OnlineEvalSampler} sampler - The sampler instance to pull samples from
120
+ * @param {ReviewOptions} [options] - Options for filtering and formatting output
121
+ * @param {string} [options.date] - Date to review (YYYY-MM-DD format, defaults to today)
122
+ * @param {number} [options.limit] - Maximum number of samples to show (default: 20)
123
+ * @param {number} [options.minScore] - Minimum score filter
124
+ * @param {string} [options.format] - Output format: 'json' or 'table' (default: table)
125
+ * @returns {Promise<void>}
126
+ */
113
127
  export declare function reviewSamples(sampler: OnlineEvalSampler, options?: ReviewOptions): Promise<void>;
114
128
  export declare function createOnlineEvalSampler(config?: Partial<SamplingConfig>): OnlineEvalSampler;
@@ -262,23 +262,33 @@ export declare function createConnectTool(workDir: string): import("@langchain/c
262
262
  export declare function createComposeTool(workDir: string): import("@langchain/core/tools").DynamicStructuredTool<z.ZodObject<{
263
263
  appName: z.ZodOptional<z.ZodString>;
264
264
  orbitalFiles: z.ZodOptional<z.ZodString>;
265
- pagesJson: z.ZodOptional<z.ZodString>;
265
+ layoutStrategy: z.ZodOptional<z.ZodEnum<["sidebar", "tabs", "dashboard", "wizard-flow", "auto"]>>;
266
+ eventWiringJson: z.ZodOptional<z.ZodString>;
267
+ entityMappingsJson: z.ZodOptional<z.ZodString>;
266
268
  }, "strip", z.ZodTypeAny, {
267
269
  appName?: string | undefined;
268
270
  orbitalFiles?: string | undefined;
269
- pagesJson?: string | undefined;
271
+ layoutStrategy?: "dashboard" | "sidebar" | "tabs" | "wizard-flow" | "auto" | undefined;
272
+ eventWiringJson?: string | undefined;
273
+ entityMappingsJson?: string | undefined;
270
274
  }, {
271
275
  appName?: string | undefined;
272
276
  orbitalFiles?: string | undefined;
273
- pagesJson?: string | undefined;
277
+ layoutStrategy?: "dashboard" | "sidebar" | "tabs" | "wizard-flow" | "auto" | undefined;
278
+ eventWiringJson?: string | undefined;
279
+ entityMappingsJson?: string | undefined;
274
280
  }>, {
275
281
  appName?: string | undefined;
276
282
  orbitalFiles?: string | undefined;
277
- pagesJson?: string | undefined;
283
+ layoutStrategy?: "dashboard" | "sidebar" | "tabs" | "wizard-flow" | "auto" | undefined;
284
+ eventWiringJson?: string | undefined;
285
+ entityMappingsJson?: string | undefined;
278
286
  }, {
279
287
  appName?: string | undefined;
280
288
  orbitalFiles?: string | undefined;
281
- pagesJson?: string | undefined;
289
+ layoutStrategy?: "dashboard" | "sidebar" | "tabs" | "wizard-flow" | "auto" | undefined;
290
+ eventWiringJson?: string | undefined;
291
+ entityMappingsJson?: string | undefined;
282
292
  }, {
283
293
  success: boolean;
284
294
  error: string;
@@ -299,4 +309,4 @@ export declare function createComposeTool(workDir: string): import("@langchain/c
299
309
  errors: string[];
300
310
  };
301
311
  error?: undefined;
302
- }, unknown, "compose_app">;
312
+ }, unknown, "compose_behaviors">;
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Behavior Pipeline Orchestrator
3
+ *
4
+ * Chains BG0-A (decompose, 1 LLM call) -> BG0-B (match, 1 LLM call)
5
+ * -> BG1 -> BG2 -> BG3 (all deterministic).
6
+ *
7
+ * Total: 2 LLM calls for any app size.
8
+ *
9
+ * @packageDocumentation
10
+ */
11
+ import type { LLMClient } from '@almadar/llm';
12
+ import type { BehaviorPipelineConfig, BehaviorPipelineResult } from './types.js';
13
+ /**
14
+ * Execute the complete Behavior Pipeline.
15
+ *
16
+ * Chains all behavior gates: BG0-A (decompose, 1 LLM call) -> BG0-B (match, 1 LLM call)
17
+ * -> BG1 -> BG2 -> BG3 (all deterministic). Total: 2 LLM calls for any app size.
18
+ *
19
+ * @param {LLMClient} client - The LLM client to use for generation
20
+ * @param {string} prompt - The user's natural language request
21
+ * @param {BehaviorPipelineConfig} [config] - Optional pipeline configuration
22
+ * @returns {Promise<BehaviorPipelineResult>} The complete pipeline result with schema
23
+ */
24
+ export declare function runBehaviorPipeline(client: LLMClient, prompt: string, config?: BehaviorPipelineConfig): Promise<BehaviorPipelineResult>;
25
+ /** Create the default Mistral Small client for behavior pipeline */
26
+ export declare function createBehaviorClient(): LLMClient;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Behavior Prompts (BG0)
3
+ *
4
+ * Builds system and user prompts for the behavior selection gate.
5
+ * Uses behavior catalog sections from @almadar/skills.
6
+ *
7
+ * @packageDocumentation
8
+ */
9
+ export declare function buildBG0SystemPrompt(): string;
10
+ export declare function buildBG0UserPrompt(prompt: string): string;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * BG0: Behavior Selection
3
+ *
4
+ * One LLM call. Selects behaviors from the standard library based on
5
+ * a natural language prompt and produces a BehaviorPlan.
6
+ *
7
+ * @packageDocumentation
8
+ */
9
+ import type { LLMClient } from '@almadar/llm';
10
+ import type { BehaviorPlan, BehaviorPipelineConfig } from './types.js';
11
+ /**
12
+ * Execute BG0: Behavior Selection.
13
+ *
14
+ * Selects behaviors from the standard library based on a natural language
15
+ * prompt and produces a BehaviorPlan. This is the first step in the
16
+ * behavior-based generation pipeline.
17
+ *
18
+ * @param {LLMClient} client - The LLM client to use for selection
19
+ * @param {string} prompt - The user's natural language request
20
+ * @param {BehaviorPipelineConfig} [_config] - Optional pipeline configuration
21
+ * @returns {Promise<BehaviorPlan>} The selected behavior plan
22
+ */
23
+ export declare function runBG0(client: LLMClient, prompt: string, _config?: BehaviorPipelineConfig): Promise<BehaviorPlan>;
@@ -0,0 +1,29 @@
1
+ /**
2
+ * BG0-A: Decompose
3
+ *
4
+ * First LLM call. Breaks a natural language prompt into a shell OrbitalSchema
5
+ * (orbital names, entity names with fields, pages). Then converts each orbital
6
+ * to a domain language paragraph for BG0-B to match against behaviors.
7
+ *
8
+ * Reuses the existing Gate 0 (decompose_app) logic.
9
+ *
10
+ * @packageDocumentation
11
+ */
12
+ import type { LLMClient } from '@almadar/llm';
13
+ import type { OrbitalSchema } from '@almadar/core/types';
14
+ import type { BehaviorPipelineConfig } from './types.js';
15
+ export interface DecomposeResult {
16
+ /** Shell schema from Gate 0 */
17
+ shellOrb: OrbitalSchema;
18
+ /** One domain language paragraph per orbital */
19
+ orbitalDescriptions: Array<{
20
+ orbitalName: string;
21
+ entityName: string;
22
+ domainText: string;
23
+ fields: Array<{
24
+ name: string;
25
+ type: string;
26
+ }>;
27
+ }>;
28
+ }
29
+ export declare function runBG0A(client: LLMClient, prompt: string, _config?: BehaviorPipelineConfig): Promise<DecomposeResult>;
@@ -0,0 +1,29 @@
1
+ /**
2
+ * BG0-B: Per-Orbital Behavior Matching
3
+ *
4
+ * Second LLM call. For each orbital description from BG0-A, selects the
5
+ * best behavior from the catalog. One focused decision per orbital.
6
+ *
7
+ * Uses a single batched LLM call for all orbitals (not one call per orbital)
8
+ * to keep total LLM calls at 2.
9
+ *
10
+ * @packageDocumentation
11
+ */
12
+ import type { LLMClient } from '@almadar/llm';
13
+ import type { BehaviorPlan, BehaviorPipelineConfig } from './types.js';
14
+ import type { DecomposeResult } from './bg0a-decompose.js';
15
+ /**
16
+ * Execute BG0-B: Per-Orbital Behavior Matching.
17
+ *
18
+ * Second LLM call in the behavior pipeline. For each orbital description
19
+ * from BG0-A, selects the best behavior from the catalog.
20
+ *
21
+ * Uses a single batched LLM call for all orbitals to keep total LLM calls at 2.
22
+ *
23
+ * @param {LLMClient} client - The LLM client to use for matching
24
+ * @param {DecomposeResult} decomposed - The decomposed result from BG0-A
25
+ * @param {string} originalPrompt - The original user request for context
26
+ * @param {BehaviorPipelineConfig} [_config] - Optional pipeline configuration
27
+ * @returns {Promise<BehaviorPlan>} The matched behavior plan
28
+ */
29
+ export declare function runBG0B(client: LLMClient, decomposed: DecomposeResult, originalPrompt: string, _config?: BehaviorPipelineConfig): Promise<BehaviorPlan>;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * BG1: Behavior Instantiation
3
+ *
4
+ * Zero LLM calls. Calls behavior pure functions from @almadar/std
5
+ * to produce OrbitalDefinitions. Falls back to golden .orb files.
6
+ *
7
+ * @packageDocumentation
8
+ */
9
+ import type { OrbitalDefinition } from '@almadar/core/types';
10
+ import type { BehaviorPlan } from './types.js';
11
+ export declare function runBG1(plan: BehaviorPlan): Promise<OrbitalDefinition[]>;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * BG2: Event Wiring
3
+ *
4
+ * Zero LLM calls. Applies cross-orbital event wiring from
5
+ * the BehaviorPlan's suggestedWiring entries.
6
+ *
7
+ * @packageDocumentation
8
+ */
9
+ import type { OrbitalDefinition } from '@almadar/core/types';
10
+ import type { BehaviorPlan } from './types.js';
11
+ /**
12
+ * Execute BG2: Event Wiring.
13
+ *
14
+ * Zero LLM calls. Applies cross-orbital event wiring from the BehaviorPlan's
15
+ * suggestedWiring entries to connect orbitals via events.
16
+ *
17
+ * @param {OrbitalDefinition[]} orbitals - The orbitals to wire together
18
+ * @param {BehaviorPlan} plan - The behavior plan containing wiring suggestions
19
+ * @returns {Promise<OrbitalDefinition[]>} The wired orbitals
20
+ */
21
+ export declare function runBG2(orbitals: OrbitalDefinition[], plan: BehaviorPlan): Promise<OrbitalDefinition[]>;
@@ -0,0 +1,22 @@
1
+ /**
2
+ * BG3: Application Composition
3
+ *
4
+ * Zero LLM calls. Uses composeBehaviors from @almadar/core to
5
+ * produce a complete OrbitalSchema with pages and layout.
6
+ *
7
+ * @packageDocumentation
8
+ */
9
+ import type { ComposeBehaviorsResult } from '@almadar/core/builders';
10
+ import type { OrbitalDefinition } from '@almadar/core/types';
11
+ import type { BehaviorPlan } from './types.js';
12
+ /**
13
+ * Execute BG3: Application Composition.
14
+ *
15
+ * Zero LLM calls. Uses composeBehaviors from @almadar/core to produce
16
+ * a complete OrbitalSchema with pages and layout.
17
+ *
18
+ * @param {OrbitalDefinition[]} orbitals - The wired orbitals to compose
19
+ * @param {BehaviorPlan} plan - The behavior plan containing composition settings
20
+ * @returns {Promise<ComposeBehaviorsResult>} The composed application schema
21
+ */
22
+ export declare function runBG3(orbitals: OrbitalDefinition[], plan: BehaviorPlan): Promise<ComposeBehaviorsResult>;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Behavior Gate Pipeline
3
+ *
4
+ * Sequential pipeline for behavior-based application composition.
5
+ * BG0-A (decompose, 1 LLM) -> BG0-B (match, 1 LLM) -> BG1 -> BG2 -> BG3 (deterministic).
6
+ *
7
+ * @packageDocumentation
8
+ */
9
+ export { runBehaviorPipeline, createBehaviorClient } from './behavior-orchestrator.js';
10
+ export { runBG0A, type DecomposeResult } from './bg0a-decompose.js';
11
+ export { runBG0B } from './bg0b-match.js';
12
+ export { runBG0 } from './bg0-behavior-selection.js';
13
+ export { runBG1 } from './bg1-instantiation.js';
14
+ export { runBG2 } from './bg2-wiring.js';
15
+ export { runBG3 } from './bg3-composition.js';
16
+ export type { BehaviorPlan, BehaviorSelection, BehaviorPipelineConfig, BehaviorPipelineResult } from './types.js';
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Behavior Gate Pipeline Types
3
+ *
4
+ * Type definitions for the sequential BG0-BG3 behavior composition pipeline.
5
+ *
6
+ * @packageDocumentation
7
+ */
8
+ import type { OrbitalDefinition, OrbitalSchema } from '@almadar/core/types';
9
+ import type { EventWiringEntry } from '@almadar/core/builders';
10
+ export interface BehaviorSelection {
11
+ behaviorName: string;
12
+ entityName: string;
13
+ fields: Array<{
14
+ name: string;
15
+ type: string;
16
+ required?: boolean;
17
+ default?: unknown;
18
+ }>;
19
+ persistence: 'persistent' | 'runtime' | 'singleton';
20
+ pageTitle?: string;
21
+ pagePath?: string;
22
+ }
23
+ export interface BehaviorPlan {
24
+ appName: string;
25
+ selections: BehaviorSelection[];
26
+ suggestedWiring: EventWiringEntry[];
27
+ layoutStrategy?: 'sidebar' | 'tabs' | 'dashboard' | 'wizard-flow' | 'auto';
28
+ }
29
+ export interface BehaviorPipelineConfig {
30
+ workDir?: string;
31
+ validateAfterCompose?: boolean;
32
+ }
33
+ export interface BehaviorPipelineResult {
34
+ plan: BehaviorPlan;
35
+ orbitals: OrbitalDefinition[];
36
+ schema: OrbitalSchema;
37
+ layout: {
38
+ strategy: string;
39
+ pageCount: number;
40
+ };
41
+ validation: {
42
+ valid: boolean;
43
+ errors: string[];
44
+ };
45
+ timings: {
46
+ total: number;
47
+ bg0: number;
48
+ bg1: number;
49
+ bg2: number;
50
+ bg3: number;
51
+ };
52
+ llmCalls: number;
53
+ }
@@ -10,4 +10,17 @@
10
10
  import type { LLMClient } from '@almadar/llm';
11
11
  import type { OrbitalSchema } from '@almadar/core/types';
12
12
  import type { GateOpts, BehaviorGateData } from './types.js';
13
+ /**
14
+ * Execute Gate 0: Application Decomposition.
15
+ *
16
+ * Decomposes a natural language prompt into an initial orbital schema
17
+ * with entities, traits, and pages. This is the first gate in the
18
+ * multi-gate generation pipeline.
19
+ *
20
+ * @param {LLMClient} client - The LLM client to use for generation
21
+ * @param {string} prompt - The user's natural language request
22
+ * @param {GateOpts} [opts] - Optional configuration for the gate
23
+ * @param {BehaviorGateData} [behaviorData] - Optional guidance from behavior analysis
24
+ * @returns {Promise<OrbitalSchema>} The decomposed orbital schema
25
+ */
13
26
  export declare function runGate0(client: LLMClient, prompt: string, opts?: GateOpts, behaviorData?: BehaviorGateData): Promise<OrbitalSchema>;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Gate 3.5: Pattern Matching
3
+ *
4
+ * Selects the 10-20 most relevant UI patterns for this application.
5
+ * Two-phase approach:
6
+ * 1. Deterministic pre-filter: analyze state machine to exclude irrelevant
7
+ * categories (game patterns for CRUD apps, form patterns for read-only, etc.)
8
+ * 2. LLM selection: pick from the pre-filtered set
9
+ *
10
+ * Gate 4 then receives only these patterns with full prop details.
11
+ *
12
+ * @packageDocumentation
13
+ */
14
+ import type { LLMClient } from '@almadar/llm';
15
+ import type { OrbitalSchema } from '@almadar/core/types';
16
+ import type { GateOpts } from './types.js';
17
+ /**
18
+ * Run Gate 3.5: select relevant patterns for this application.
19
+ * Phase 1: deterministic pre-filter based on state machine analysis.
20
+ * Phase 2: LLM selects from the pre-filtered set.
21
+ * Returns an array of pattern names (always includes core patterns).
22
+ */
23
+ export declare function runGate35(client: LLMClient, orb: OrbitalSchema, _opts?: GateOpts): Promise<string[]>;
@@ -14,4 +14,4 @@ import type { GateOpts, BehaviorGateData } from './types.js';
14
14
  * Append render-ui effects to all transitions.
15
15
  * Builds slot context from state machine and passes it to every LLM call.
16
16
  */
17
- export declare function runGate4(client: LLMClient, orb: OrbitalSchema, opts?: GateOpts, _behaviorData?: BehaviorGateData): Promise<OrbitalSchema>;
17
+ export declare function runGate4(client: LLMClient, orb: OrbitalSchema, opts?: GateOpts, _behaviorData?: BehaviorGateData, matchedPatterns?: string[]): Promise<OrbitalSchema>;