@almadar/agent 1.6.4 → 2.0.1
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/LICENSE +21 -72
- package/README.md +25 -0
- package/dist/agent/event-budget.d.ts +28 -0
- package/dist/agent/experimental/hitl-v2.d.ts +161 -0
- package/dist/agent/experimental/hitl-workflow-integration.d.ts +182 -0
- package/dist/agent/index.d.ts +14 -13
- package/dist/agent/index.js.map +1 -1
- package/dist/agent/interrupt-config.d.ts +51 -0
- package/dist/agent/session-manager.d.ts +204 -0
- package/dist/agent/skill-agent.d.ts +182 -0
- package/dist/agent/workflow-middleware.d.ts +63 -0
- package/dist/agent/workflow-tool-wrapper.d.ts +87 -0
- package/dist/{api-types-CXrq-fts.d.ts → api-types.d.ts} +85 -51
- package/dist/context/compaction.d.ts +191 -0
- package/dist/context-compaction.d.ts +55 -0
- package/dist/evals/online-sampling.d.ts +114 -0
- package/dist/evals/utils/compact-orbital.d.ts +100 -0
- package/dist/event-transformer/event-transformer.d.ts +120 -0
- package/dist/event-transformer/index.d.ts +4 -122
- package/dist/events.d.ts +85 -0
- package/dist/index.d.ts +58 -1678
- package/dist/index.js +39 -0
- package/dist/index.js.map +1 -1
- package/dist/memory/MemoryManager.d.ts +243 -0
- package/dist/memory/PreferenceLearner.d.ts +59 -0
- package/dist/memory/agentic-search.d.ts +116 -0
- package/dist/memory/index.d.ts +14 -0
- package/dist/memory/memory-orbital.d.ts +66 -0
- package/dist/memory/types.d.ts +143 -0
- package/dist/metrics.d.ts +77 -0
- package/dist/multi-user.d.ts +155 -0
- package/dist/observability/index.d.ts +14 -0
- package/dist/observability/langsmith-integration.d.ts +203 -0
- package/dist/observability.d.ts +196 -0
- package/dist/orbitals/archive/sanitize.d.ts +24 -0
- package/dist/orbitals/batch/batch-generator.d.ts +41 -0
- package/dist/orbitals/batch/concurrency.d.ts +54 -0
- package/dist/orbitals/batch/index.d.ts +14 -0
- package/dist/orbitals/batch/prompt-assembler.d.ts +92 -0
- package/dist/orbitals/batch/types.d.ts +103 -0
- package/dist/orbitals/cache/index.d.ts +11 -0
- package/dist/orbitals/cache/orbital-fingerprint.d.ts +37 -0
- package/dist/orbitals/cache/prompt-assembler.d.ts +65 -0
- package/dist/orbitals/cache/structural-templates.d.ts +33 -0
- package/dist/orbitals/combiner/index.d.ts +102 -0
- package/dist/orbitals/domain-language/index.d.ts +9 -0
- package/dist/orbitals/domain-language/prompts/index.d.ts +11 -0
- package/dist/orbitals/domain-language/prompts/odl-examples.d.ts +8 -0
- package/dist/orbitals/domain-language/prompts/odl-patterns.d.ts +8 -0
- package/dist/orbitals/domain-language/prompts/odl-syntax.d.ts +8 -0
- package/dist/orbitals/domain-language/prompts/odl-to-schema.d.ts +8 -0
- package/dist/orbitals/generation/index.d.ts +10 -0
- package/dist/orbitals/generation/orbital-generator.d.ts +120 -0
- package/dist/orbitals/shared/constants.d.ts +65 -0
- package/dist/orbitals/shared/index.d.ts +11 -0
- package/dist/orbitals/shared/types.d.ts +187 -0
- package/dist/orbitals/shared/utils.d.ts +97 -0
- package/dist/orchestration/complexity-classifier.d.ts +38 -0
- package/dist/orchestration/fixing-orchestrator.d.ts +53 -0
- package/dist/orchestration/index.d.ts +31 -0
- package/dist/orchestration/provider-router.d.ts +45 -0
- package/dist/{firestore-checkpointer-CkNKXoun.d.ts → persistence/firestore-checkpointer.d.ts} +13 -58
- package/dist/persistence/firestore-session-store.d.ts +75 -0
- package/dist/persistence/firestore-store.d.ts +86 -0
- package/dist/persistence/index.d.ts +7 -198
- package/dist/persistence/memory-backend.d.ts +33 -0
- package/dist/persistence/types.d.ts +40 -0
- package/dist/security/audit-log.d.ts +44 -0
- package/dist/state-sync.d.ts +171 -0
- package/dist/subagents.d.ts +38 -0
- package/dist/tools/combine-schemas.d.ts +154 -0
- package/dist/tools/composition.d.ts +119 -0
- package/dist/{orbital-subagent-BdFuf77p.d.ts → tools/domain-orbital.d.ts} +22 -461
- package/dist/tools/execute.d.ts +38 -0
- package/dist/tools/finish-task.d.ts +56 -0
- package/dist/tools/generate-schema.d.ts +53 -0
- package/dist/tools/github.d.ts +297 -0
- package/dist/tools/index.d.ts +1318 -8
- package/dist/tools/orbital-batch-subagent.d.ts +85 -0
- package/dist/tools/orbital-subagent.d.ts +454 -0
- package/dist/tools/orchestrated-fixing.d.ts +74 -0
- package/dist/tools/orchestrated-generation.d.ts +75 -0
- package/dist/tools/sandbox-executor.d.ts +31 -0
- package/dist/tools/schema-chunking.d.ts +117 -0
- package/dist/tools/trait-subagent.d.ts +179 -0
- package/dist/tools/validate-schema.d.ts +17 -0
- package/dist/types.d.ts +14 -17
- package/dist/utils/safety/capability-token.d.ts +50 -0
- package/dist/utils/safety/circuit-breaker.d.ts +71 -0
- package/dist/utils/safety/index.d.ts +19 -0
- package/dist/utils/safety/rate-limiter.d.ts +39 -0
- package/dist/utils/safety/threshold-auth.d.ts +70 -0
- package/dist/workspace/git-client.d.ts +51 -0
- package/dist/workspace/index.d.ts +29 -346
- package/dist/workspace/index.js +39 -0
- package/dist/workspace/index.js.map +1 -1
- package/dist/workspace/memory-files.d.ts +31 -0
- package/dist/workspace/sink-manager.d.ts +26 -0
- package/dist/workspace/sinks/firestore-sink.d.ts +41 -0
- package/dist/workspace/sinks/git-sink.d.ts +47 -0
- package/dist/workspace/sinks/index.d.ts +9 -0
- package/dist/workspace/templates.d.ts +32 -0
- package/dist/workspace/types.d.ts +86 -0
- package/dist/workspace/workspace-manager.d.ts +57 -0
- package/package.json +12 -10
- package/dist/index-DW3F-Ihx.d.ts +0 -2501
- package/dist/index-DZn69no8.d.ts +0 -1014
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Batch Generator
|
|
3
|
+
*
|
|
4
|
+
* Core batch generation logic for generating multiple orbitals efficiently.
|
|
5
|
+
* Supports multiple modes: single-call, parallel-individual, adaptive.
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
import type { LLMClient } from '@almadar/llm';
|
|
10
|
+
import type { OrbitalDefinition } from '@almadar/core/types';
|
|
11
|
+
import type { BatchGenerationOptions, BatchGenerationResult } from './types.js';
|
|
12
|
+
/**
|
|
13
|
+
* Generate multiple orbitals in optimized batches.
|
|
14
|
+
*
|
|
15
|
+
* This is the main entry point for batch generation. It:
|
|
16
|
+
* 1. Splits orbitals into optimal batches
|
|
17
|
+
* 2. Generates each batch (parallel or sequential)
|
|
18
|
+
* 3. Combines results into final schema
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* const result = await generateOrbitalsBatch(client, [
|
|
23
|
+
* { name: "Products", ... },
|
|
24
|
+
* { name: "Orders", ... },
|
|
25
|
+
* { name: "Customers", ... },
|
|
26
|
+
* ], { mode: 'single-call', batchSize: 3 });
|
|
27
|
+
*
|
|
28
|
+
* console.log(`Generated ${result.summary.successful}/${result.summary.total} orbitals`);
|
|
29
|
+
* console.log(`Total time: ${result.totalDurationMs}ms`);
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export declare function generateOrbitalsBatch(client: LLMClient, orbitals: OrbitalDefinition[], options?: BatchGenerationOptions): Promise<BatchGenerationResult>;
|
|
33
|
+
/**
|
|
34
|
+
* Estimate optimal batch configuration for a set of orbitals.
|
|
35
|
+
*/
|
|
36
|
+
export declare function estimateOptimalBatchConfig(orbitals: OrbitalDefinition[], provider: 'anthropic' | 'openai' | 'deepseek' | 'kimi' | 'openrouter'): {
|
|
37
|
+
recommendedMode: 'single-call' | 'parallel-individual';
|
|
38
|
+
optimalBatchSize: number;
|
|
39
|
+
estimatedBatches: number;
|
|
40
|
+
estimatedTimeSeconds: number;
|
|
41
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Concurrency Controller
|
|
3
|
+
*
|
|
4
|
+
* Semaphore-based concurrency control for parallel operations.
|
|
5
|
+
*
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
*/
|
|
8
|
+
import type { ConcurrencyController } from './types.js';
|
|
9
|
+
/**
|
|
10
|
+
* Create a semaphore-based concurrency controller.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* const controller = createConcurrencyController(3); // Max 3 concurrent
|
|
15
|
+
*
|
|
16
|
+
* await controller.acquire(); // Acquire slot
|
|
17
|
+
* try {
|
|
18
|
+
* await doWork();
|
|
19
|
+
* } finally {
|
|
20
|
+
* controller.release(); // Release slot
|
|
21
|
+
* }
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare function createConcurrencyController(maxConcurrency: number): ConcurrencyController;
|
|
25
|
+
/**
|
|
26
|
+
* Execute an array of async functions with concurrency control.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```typescript
|
|
30
|
+
* const results = await runWithConcurrency(
|
|
31
|
+
* items.map(item => () => processItem(item)),
|
|
32
|
+
* { concurrency: 3 }
|
|
33
|
+
* );
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export declare function runWithConcurrency<T>(tasks: Array<() => Promise<T>>, options: {
|
|
37
|
+
concurrency: number;
|
|
38
|
+
onProgress?: (completed: number, total: number) => void;
|
|
39
|
+
}): Promise<T[]>;
|
|
40
|
+
/**
|
|
41
|
+
* Async map with concurrency limit.
|
|
42
|
+
*
|
|
43
|
+
* Similar to Promise.all() but with max concurrency.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```typescript
|
|
47
|
+
* const results = await asyncMapWithConcurrency(
|
|
48
|
+
* items,
|
|
49
|
+
* async (item, index) => process(item),
|
|
50
|
+
* 3 // max 3 concurrent
|
|
51
|
+
* );
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
export declare function asyncMapWithConcurrency<T, R>(items: T[], mapper: (item: T, index: number) => Promise<R>, concurrency: number): Promise<R[]>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Batch Orbital Generation
|
|
3
|
+
*
|
|
4
|
+
* Efficient batch generation of multiple orbitals using:
|
|
5
|
+
* - Single-call batch mode (multiple orbitals per LLM call)
|
|
6
|
+
* - Parallel individual mode (concurrent single-orbital calls)
|
|
7
|
+
* - Adaptive mode (automatically chooses best strategy)
|
|
8
|
+
*
|
|
9
|
+
* @packageDocumentation
|
|
10
|
+
*/
|
|
11
|
+
export { generateOrbitalsBatch, estimateOptimalBatchConfig, } from './batch-generator.js';
|
|
12
|
+
export { assembleBatchPrompt, splitIntoBatches, extractSharedContext, estimateBatchTokens, willBatchFit, type BatchAssembledPrompt, type SharedBatchContext, } from './prompt-assembler.js';
|
|
13
|
+
export { createConcurrencyController, runWithConcurrency, asyncMapWithConcurrency, } from './concurrency.js';
|
|
14
|
+
export { type BatchGenerationOptions, type BatchGenerationResult, type BatchProgressEvent, type SingleBatchResult, type ConcurrencyController, type BatchMode, type SingleCallBatchOptions, type ParallelIndividualOptions, type AdaptiveBatchOptions, } from './types.js';
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Batch Prompt Assembler
|
|
3
|
+
*
|
|
4
|
+
* Assembles prompts for generating multiple orbitals in a single LLM call.
|
|
5
|
+
* Optimized for:
|
|
6
|
+
* - Context sharing (domain vocabulary, design style)
|
|
7
|
+
* - Cross-orbital references (emits/listens wiring)
|
|
8
|
+
* - Token efficiency (shared system context)
|
|
9
|
+
*
|
|
10
|
+
* @packageDocumentation
|
|
11
|
+
*/
|
|
12
|
+
import type { OrbitalDefinition } from '@almadar/core/types';
|
|
13
|
+
import type { AssembledPrompt } from '../cache/index.js';
|
|
14
|
+
/**
|
|
15
|
+
* Assembled prompt for batch generation.
|
|
16
|
+
*/
|
|
17
|
+
export interface BatchAssembledPrompt extends AssembledPrompt {
|
|
18
|
+
/** Number of orbitals in this batch */
|
|
19
|
+
orbitalCount: number;
|
|
20
|
+
/** Names of orbitals in this batch */
|
|
21
|
+
orbitalNames: string[];
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Shared context extracted from a batch of orbitals.
|
|
25
|
+
*/
|
|
26
|
+
export interface SharedBatchContext {
|
|
27
|
+
/** Domain vocabulary shared across orbitals */
|
|
28
|
+
domainVocabulary?: Record<string, string>;
|
|
29
|
+
/** Design style (minimal, modern, etc.) */
|
|
30
|
+
designStyle?: string;
|
|
31
|
+
/** Common patterns used */
|
|
32
|
+
commonPatterns?: string[];
|
|
33
|
+
/** Cross-orbital event relationships */
|
|
34
|
+
eventRelationships?: Array<{
|
|
35
|
+
emitter: string;
|
|
36
|
+
event: string;
|
|
37
|
+
listener: string;
|
|
38
|
+
handler: string;
|
|
39
|
+
}>;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Extract shared context from a batch of orbitals.
|
|
43
|
+
*/
|
|
44
|
+
export declare function extractSharedContext(orbitals: OrbitalDefinition[]): SharedBatchContext;
|
|
45
|
+
/**
|
|
46
|
+
* Assemble a batch prompt for generating multiple orbitals in one call.
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```typescript
|
|
50
|
+
* const batchPrompt = assembleBatchPrompt([
|
|
51
|
+
* { name: "Products", entity: {...}, traits: [...] },
|
|
52
|
+
* { name: "Orders", entity: {...}, traits: [...] },
|
|
53
|
+
* { name: "Customers", entity: {...}, traits: [...] },
|
|
54
|
+
* ]);
|
|
55
|
+
* // Returns a single prompt that generates all 3 orbitals
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
export declare function assembleBatchPrompt(orbitals: OrbitalDefinition[], options?: {
|
|
59
|
+
baseSystemPrompt?: string;
|
|
60
|
+
includeConnectivity?: boolean;
|
|
61
|
+
}): BatchAssembledPrompt;
|
|
62
|
+
/**
|
|
63
|
+
* Split orbitals into optimally-sized batches.
|
|
64
|
+
*
|
|
65
|
+
* Considers:
|
|
66
|
+
* - Provider token limits
|
|
67
|
+
* - Cross-orbital relationships (keeps related orbitals together)
|
|
68
|
+
* - Batch size limits
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```typescript
|
|
72
|
+
* const batches = splitIntoBatches(orbitals, {
|
|
73
|
+
* maxBatchSize: 3,
|
|
74
|
+
* provider: 'anthropic'
|
|
75
|
+
* });
|
|
76
|
+
* // Returns: [[orb1, orb2, orb3], [orb4, orb5], [orb6]]
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
export declare function splitIntoBatches(orbitals: OrbitalDefinition[], options?: {
|
|
80
|
+
maxBatchSize?: number;
|
|
81
|
+
provider?: 'anthropic' | 'openai' | 'deepseek' | 'kimi' | 'openrouter';
|
|
82
|
+
preserveRelationships?: boolean;
|
|
83
|
+
}): OrbitalDefinition[][];
|
|
84
|
+
/**
|
|
85
|
+
* Estimate token count for a batch prompt.
|
|
86
|
+
* Rough estimate: ~4 characters per token.
|
|
87
|
+
*/
|
|
88
|
+
export declare function estimateBatchTokens(orbitals: OrbitalDefinition[]): number;
|
|
89
|
+
/**
|
|
90
|
+
* Check if a batch will fit within token limits.
|
|
91
|
+
*/
|
|
92
|
+
export declare function willBatchFit(orbitals: OrbitalDefinition[], maxTokens?: number): boolean;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Batch Generation Types
|
|
3
|
+
*
|
|
4
|
+
* Type definitions specific to batch orbital generation.
|
|
5
|
+
*
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
*/
|
|
8
|
+
import type { OrbitalDefinition } from '@almadar/core/types';
|
|
9
|
+
import type { GenerationLog, TokenUsage, BatchGenerationOptions as SharedBatchOptions, BatchGenerationResult as SharedBatchResult } from '../shared/index.js';
|
|
10
|
+
export { type GenerationLog, type TokenUsage, type ValidationResult, } from '../shared/index.js';
|
|
11
|
+
/**
|
|
12
|
+
* Options for batch generation.
|
|
13
|
+
*/
|
|
14
|
+
export interface BatchGenerationOptions extends SharedBatchOptions {
|
|
15
|
+
/** Callback for batch progress events */
|
|
16
|
+
onBatchProgress?: (event: BatchProgressEvent) => void;
|
|
17
|
+
/** Whether to group orbitals by relationships */
|
|
18
|
+
preserveRelationships?: boolean;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Batch progress event.
|
|
22
|
+
*/
|
|
23
|
+
export interface BatchProgressEvent {
|
|
24
|
+
type: 'batch_start' | 'batch_complete' | 'orbital_start' | 'orbital_complete' | 'error';
|
|
25
|
+
batchIndex: number;
|
|
26
|
+
totalBatches: number;
|
|
27
|
+
orbitalIndex?: number;
|
|
28
|
+
orbitalName?: string;
|
|
29
|
+
completedOrbitals: number;
|
|
30
|
+
totalOrbitals: number;
|
|
31
|
+
error?: string;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Result for a single batch within multi-batch generation.
|
|
35
|
+
*/
|
|
36
|
+
export interface SingleBatchResult {
|
|
37
|
+
/** Orbitals in this batch */
|
|
38
|
+
orbitals: OrbitalDefinition[];
|
|
39
|
+
/** Generated results */
|
|
40
|
+
results: Array<{
|
|
41
|
+
orbital: OrbitalDefinition;
|
|
42
|
+
success: boolean;
|
|
43
|
+
error?: string;
|
|
44
|
+
}>;
|
|
45
|
+
/** Token usage for this batch */
|
|
46
|
+
usage?: TokenUsage;
|
|
47
|
+
/** Batch duration in ms */
|
|
48
|
+
durationMs: number;
|
|
49
|
+
/** Logs from this batch */
|
|
50
|
+
logs: GenerationLog[];
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Complete batch generation result.
|
|
54
|
+
*/
|
|
55
|
+
export interface BatchGenerationResult extends SharedBatchResult {
|
|
56
|
+
/** Results grouped by batch */
|
|
57
|
+
batchResults: SingleBatchResult[];
|
|
58
|
+
/** Total number of batches */
|
|
59
|
+
totalBatches: number;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Concurrency controller interface.
|
|
63
|
+
*/
|
|
64
|
+
export interface ConcurrencyController {
|
|
65
|
+
/** Acquire a slot (returns promise that resolves when slot available) */
|
|
66
|
+
acquire(): Promise<void>;
|
|
67
|
+
/** Release a slot */
|
|
68
|
+
release(): void;
|
|
69
|
+
/** Current active count */
|
|
70
|
+
readonly activeCount: number;
|
|
71
|
+
/** Current waiting count */
|
|
72
|
+
readonly waitingCount: number;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Mode for batch generation.
|
|
76
|
+
*/
|
|
77
|
+
export type BatchMode = 'single-call' | 'parallel-individual' | 'adaptive';
|
|
78
|
+
/**
|
|
79
|
+
* Options for single-call batch generation.
|
|
80
|
+
*/
|
|
81
|
+
export interface SingleCallBatchOptions {
|
|
82
|
+
mode: 'single-call';
|
|
83
|
+
/** Max orbitals per LLM call */
|
|
84
|
+
maxBatchSize: number;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Options for parallel individual generation.
|
|
88
|
+
*/
|
|
89
|
+
export interface ParallelIndividualOptions {
|
|
90
|
+
mode: 'parallel-individual';
|
|
91
|
+
/** Max concurrent generations */
|
|
92
|
+
concurrency: number;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Options for adaptive mode (chooses best strategy).
|
|
96
|
+
*/
|
|
97
|
+
export interface AdaptiveBatchOptions {
|
|
98
|
+
mode: 'adaptive';
|
|
99
|
+
/** Prefer speed vs quality */
|
|
100
|
+
priority?: 'speed' | 'quality';
|
|
101
|
+
/** Max time budget in seconds */
|
|
102
|
+
timeBudget?: number;
|
|
103
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Orbital Cache Module
|
|
3
|
+
*
|
|
4
|
+
* Exports fingerprinting, templates, and prompt assembly utilities
|
|
5
|
+
* for efficient LLM prompt caching.
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
export { computeOrbitalFingerprint, computeEntitySignature, fingerprintsMatch, parseFingerprint, fingerprintSimilarity, } from './orbital-fingerprint.js';
|
|
10
|
+
export { type StructuralTemplate, STRUCTURAL_TEMPLATES, findMatchingTemplates, getBestTemplate, getTemplateGuidance, } from './structural-templates.js';
|
|
11
|
+
export { type AssembledPrompt, type CacheableAssembledPrompt, assembleOrbitalPrompt, assembleCacheableOrbitalPrompt, assembleMultiOrbitalPrompts, getCacheStats, } from './prompt-assembler.js';
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Orbital Fingerprinting for Caching
|
|
3
|
+
*
|
|
4
|
+
* Computes structural fingerprints for Orbital Units to enable
|
|
5
|
+
* prompt caching based on similar structures.
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
import type { OrbitalUnit, OrbitalEntity } from '@almadar/core/types';
|
|
10
|
+
/**
|
|
11
|
+
* Compute a structural fingerprint for an Orbital Unit.
|
|
12
|
+
* Units with the same fingerprint can share cached prompts.
|
|
13
|
+
* Only works with full orbital definitions (not references).
|
|
14
|
+
*/
|
|
15
|
+
export declare function computeOrbitalFingerprint(orbital: OrbitalUnit): string;
|
|
16
|
+
/**
|
|
17
|
+
* Compute entity structure signature based on field types.
|
|
18
|
+
*/
|
|
19
|
+
export declare function computeEntitySignature(entity: OrbitalEntity): string;
|
|
20
|
+
/**
|
|
21
|
+
* Check if two fingerprints are structurally similar.
|
|
22
|
+
* Similar fingerprints can share template guidance.
|
|
23
|
+
*/
|
|
24
|
+
export declare function fingerprintsMatch(fp1: string, fp2: string): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Extract fingerprint components.
|
|
27
|
+
*/
|
|
28
|
+
export declare function parseFingerprint(fingerprint: string): {
|
|
29
|
+
persistence: string;
|
|
30
|
+
entity: string;
|
|
31
|
+
traits: string[];
|
|
32
|
+
patterns: string[];
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Compute similarity score between two fingerprints (0-1).
|
|
36
|
+
*/
|
|
37
|
+
export declare function fingerprintSimilarity(fp1: string, fp2: string): number;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prompt Assembler for Cache-Aware Prompt Construction
|
|
3
|
+
*
|
|
4
|
+
* Assembles prompts with cache markers for efficient LLM caching.
|
|
5
|
+
*
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
*/
|
|
8
|
+
import type { OrbitalUnit } from '@almadar/core/types';
|
|
9
|
+
import type { CacheableBlock } from '@almadar/llm';
|
|
10
|
+
export interface AssembledPrompt {
|
|
11
|
+
/** The full prompt text */
|
|
12
|
+
prompt: string;
|
|
13
|
+
/** Fingerprint for this orbital */
|
|
14
|
+
fingerprint: string;
|
|
15
|
+
/** Whether a cached template was used */
|
|
16
|
+
usedCachedTemplate: boolean;
|
|
17
|
+
/** Template name if used */
|
|
18
|
+
templateName?: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Cache-aware assembled prompt with separate blocks.
|
|
22
|
+
*/
|
|
23
|
+
export interface CacheableAssembledPrompt {
|
|
24
|
+
/** System blocks (cacheable) */
|
|
25
|
+
systemBlocks: CacheableBlock[];
|
|
26
|
+
/** User blocks (usually not cacheable) */
|
|
27
|
+
userBlocks: CacheableBlock[];
|
|
28
|
+
/** Fingerprint for this orbital */
|
|
29
|
+
fingerprint: string;
|
|
30
|
+
/** Whether a cached template was used */
|
|
31
|
+
usedCachedTemplate: boolean;
|
|
32
|
+
/** Template name if used */
|
|
33
|
+
templateName?: string;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Assemble a prompt for orbital unit generation.
|
|
37
|
+
* Organizes content to maximize cache hits.
|
|
38
|
+
* Only works with full orbital definitions (not references).
|
|
39
|
+
*/
|
|
40
|
+
export declare function assembleOrbitalPrompt(orbital: OrbitalUnit, baseSystemPrompt: string): AssembledPrompt;
|
|
41
|
+
/**
|
|
42
|
+
* Assemble cacheable blocks for Anthropic prompt caching.
|
|
43
|
+
*
|
|
44
|
+
* Structure:
|
|
45
|
+
* - System block 1: Base system prompt (highly cacheable, rarely changes)
|
|
46
|
+
* - System block 2: Template guidance (cacheable per fingerprint)
|
|
47
|
+
* - User block: Specific orbital details (not cached)
|
|
48
|
+
*
|
|
49
|
+
* Only works with full orbital definitions (not references).
|
|
50
|
+
*/
|
|
51
|
+
export declare function assembleCacheableOrbitalPrompt(orbital: OrbitalUnit, baseSystemPrompt: string): CacheableAssembledPrompt;
|
|
52
|
+
/**
|
|
53
|
+
* Assemble prompts for multiple orbitals.
|
|
54
|
+
* Groups by fingerprint for batch efficiency.
|
|
55
|
+
*/
|
|
56
|
+
export declare function assembleMultiOrbitalPrompts(orbitals: OrbitalUnit[], baseSystemPrompt: string): Map<string, AssembledPrompt[]>;
|
|
57
|
+
/**
|
|
58
|
+
* Get cache statistics for a set of orbitals.
|
|
59
|
+
*/
|
|
60
|
+
export declare function getCacheStats(orbitals: OrbitalUnit[]): {
|
|
61
|
+
totalOrbitals: number;
|
|
62
|
+
uniqueFingerprints: number;
|
|
63
|
+
potentialCacheHits: number;
|
|
64
|
+
templateMatches: number;
|
|
65
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Structural Templates for Cached Generation
|
|
3
|
+
*
|
|
4
|
+
* Pre-defined templates for common structural patterns.
|
|
5
|
+
*
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
*/
|
|
8
|
+
export interface StructuralTemplate {
|
|
9
|
+
/** Fingerprint pattern this template matches */
|
|
10
|
+
fingerprintPattern: string;
|
|
11
|
+
/** Human-readable name */
|
|
12
|
+
name: string;
|
|
13
|
+
/** Template guidance for generation */
|
|
14
|
+
guidance: string;
|
|
15
|
+
/** Example sections */
|
|
16
|
+
exampleSections: string[];
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Templates for common structural patterns.
|
|
20
|
+
*/
|
|
21
|
+
export declare const STRUCTURAL_TEMPLATES: StructuralTemplate[];
|
|
22
|
+
/**
|
|
23
|
+
* Find matching templates for a fingerprint.
|
|
24
|
+
*/
|
|
25
|
+
export declare function findMatchingTemplates(fingerprint: string): StructuralTemplate[];
|
|
26
|
+
/**
|
|
27
|
+
* Get the best matching template for a fingerprint.
|
|
28
|
+
*/
|
|
29
|
+
export declare function getBestTemplate(fingerprint: string): StructuralTemplate | null;
|
|
30
|
+
/**
|
|
31
|
+
* Get guidance for a fingerprint.
|
|
32
|
+
*/
|
|
33
|
+
export declare function getTemplateGuidance(fingerprint: string): string;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Orbital Combiner
|
|
3
|
+
*
|
|
4
|
+
* Deterministically combines multiple Orbitals into a single OrbitalSchema.
|
|
5
|
+
* This removes the need for LLM involvement in the combining step.
|
|
6
|
+
*
|
|
7
|
+
* All UI is rendered via render_ui effects from traits (no static sections).
|
|
8
|
+
*
|
|
9
|
+
* NOTE: Validation is handled externally via `orbital validate` CLI.
|
|
10
|
+
* The combiner only assembles schemas - it does not validate them.
|
|
11
|
+
*
|
|
12
|
+
* @packageDocumentation
|
|
13
|
+
*/
|
|
14
|
+
import type { Orbital, OrbitalSchema, DomainContext } from "@almadar/core/types";
|
|
15
|
+
export interface OrbitalSchemaValidationResult {
|
|
16
|
+
valid: boolean;
|
|
17
|
+
errors: Array<{
|
|
18
|
+
code: string;
|
|
19
|
+
message: string;
|
|
20
|
+
path?: string;
|
|
21
|
+
}>;
|
|
22
|
+
warnings: Array<{
|
|
23
|
+
code: string;
|
|
24
|
+
message: string;
|
|
25
|
+
path?: string;
|
|
26
|
+
}>;
|
|
27
|
+
}
|
|
28
|
+
type FullOrbitalUnit = Orbital;
|
|
29
|
+
export interface CombinerOptions {
|
|
30
|
+
/** Application name */
|
|
31
|
+
name: string;
|
|
32
|
+
/** Optional description */
|
|
33
|
+
description?: string;
|
|
34
|
+
/** Schema version */
|
|
35
|
+
version?: string;
|
|
36
|
+
/** Domain context */
|
|
37
|
+
domain?: DomainContext;
|
|
38
|
+
/** Whether to run validation (default: true) */
|
|
39
|
+
validate?: boolean;
|
|
40
|
+
/** Global theme */
|
|
41
|
+
theme?: string;
|
|
42
|
+
/** Default route (first page if not specified) */
|
|
43
|
+
defaultRoute?: string;
|
|
44
|
+
}
|
|
45
|
+
export interface CombinerResult {
|
|
46
|
+
/** Whether combining succeeded */
|
|
47
|
+
success: boolean;
|
|
48
|
+
/** The combined OrbitalSchema (if successful) */
|
|
49
|
+
schema?: OrbitalSchema;
|
|
50
|
+
/** Validation result (if validation was run) */
|
|
51
|
+
validation?: OrbitalSchemaValidationResult;
|
|
52
|
+
/** Error message (if failed) */
|
|
53
|
+
error?: string;
|
|
54
|
+
/** Statistics about the combining */
|
|
55
|
+
stats: {
|
|
56
|
+
totalOrbitals: number;
|
|
57
|
+
totalEntities: number;
|
|
58
|
+
totalPages: number;
|
|
59
|
+
totalTraits: number;
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Combine multiple Orbitals into a single OrbitalSchema.
|
|
64
|
+
*
|
|
65
|
+
* This function performs deterministic merging:
|
|
66
|
+
* 1. Builds an OrbitalSchema from the Orbitals
|
|
67
|
+
* 2. Optionally runs validation
|
|
68
|
+
*
|
|
69
|
+
* Note: All UI is rendered via render_ui effects from traits.
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```typescript
|
|
73
|
+
* const result = combineOrbitals([taskOrbital, userOrbital], {
|
|
74
|
+
* name: 'My App',
|
|
75
|
+
* validate: true,
|
|
76
|
+
* });
|
|
77
|
+
*
|
|
78
|
+
* if (result.success) {
|
|
79
|
+
* // Write schema to file
|
|
80
|
+
* await fs.writeFile('schema.json', JSON.stringify(result.schema, null, 2));
|
|
81
|
+
* } else {
|
|
82
|
+
* console.error(result.error);
|
|
83
|
+
* console.error(result.validation?.errors);
|
|
84
|
+
* }
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
export declare function combineOrbitals(orbitals: FullOrbitalUnit[], options: CombinerOptions): CombinerResult;
|
|
88
|
+
/**
|
|
89
|
+
* Combine orbitals and return only the schema (throws on error).
|
|
90
|
+
* Use this when you want a simple API and will handle errors upstream.
|
|
91
|
+
*/
|
|
92
|
+
export declare function combineOrbitalsToSchema(orbitals: FullOrbitalUnit[], options: CombinerOptions): OrbitalSchema;
|
|
93
|
+
/**
|
|
94
|
+
* Estimate the combination complexity (for progress indication).
|
|
95
|
+
*/
|
|
96
|
+
export declare function estimateCombineComplexity(orbitals: FullOrbitalUnit[]): {
|
|
97
|
+
entities: number;
|
|
98
|
+
pages: number;
|
|
99
|
+
traits: number;
|
|
100
|
+
totalSections: number;
|
|
101
|
+
};
|
|
102
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Domain Language Module
|
|
3
|
+
*
|
|
4
|
+
* MIGRATED: The core domain language engine has been moved to @almadar/core.
|
|
5
|
+
* This file re-exports everything from the core package for backward compatibility.
|
|
6
|
+
* Only agent-specific modules (prompts) remain here.
|
|
7
|
+
*/
|
|
8
|
+
export * from '@almadar/core/domain-language';
|
|
9
|
+
export * from './prompts/index.js';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Domain Language Prompts
|
|
3
|
+
*
|
|
4
|
+
* Reusable prompt sections for Domain Language generation and fixing.
|
|
5
|
+
*
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
*/
|
|
8
|
+
export { ODL_SYNTAX_REFERENCE } from './odl-syntax.js';
|
|
9
|
+
export { ODL_EXAMPLES } from './odl-examples.js';
|
|
10
|
+
export { ODL_PATTERNS } from './odl-patterns.js';
|
|
11
|
+
export { ODL_TO_SCHEMA_MAPPING } from './odl-to-schema.js';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Domain Language Examples
|
|
3
|
+
*
|
|
4
|
+
* Complete examples of Domain Language for common patterns.
|
|
5
|
+
*
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
*/
|
|
8
|
+
export declare const ODL_EXAMPLES = "\n## Complete Example\n\n### Entity\n\n```\nA Task is a persistent entity that:\n - has title as text (required)\n - has description as long text\n - has status as enum [todo, in_progress, done] with default \"todo\"\n - has dueDate as date\n - belongs to User as assignee\n - belongs to Project\n```\n\n### Page\n\n```\nTasksPage at /tasks:\n - shows Task using TaskManagement\n - view type: list\n - is initial page\n```\n\n### Behavior\n\n```\nTaskManagement behavior:\n States: Viewing, Editing, Creating\n Initial: Viewing\n\n Transitions:\n - From Viewing to Viewing on INIT\n then render page-header to main with title 'Tasks'\n then render entity-table to center for Task\n\n - From Viewing to Editing on EDIT_TASK\n then render form-section to modal for Task\n\n - From Editing to Viewing on SAVE_TASK\n then persist update Task\n then render null to modal\n then emit TASK_UPDATED\n```\n\n## Multi-Entity Example\n\n```\n# Entities\n\nA User is a persistent entity that:\n - has name as text (required)\n - has email as text (required)\n - has role as enum [admin, user, guest] with default \"user\"\n\nA Project is a persistent entity that:\n - has name as text (required)\n - has description as long text\n - has status as enum [active, archived] with default \"active\"\n - belongs to User as owner\n\nA Task is a persistent entity that:\n - has title as text (required)\n - has status as enum [todo, in_progress, done] with default \"todo\"\n - has priority as number with default 0\n - belongs to Project\n - belongs to User as assignee\n\n# Pages\n\nProjectsPage at /projects:\n - shows Project using ProjectManagement\n - view type: list\n - is initial page\n\nTasksPage at /projects/:projectId/tasks:\n - shows Task using TaskManagement\n - view type: list\n\n# Behaviors\n\nProjectManagement behavior:\n States: List, Detail\n Initial: List\n\n Transitions:\n - From List to List on INIT\n then render entity-table to main for Project\n\n - From List to Detail on VIEW_PROJECT\n then render entity-detail to drawer for Project\n\nTaskManagement behavior:\n States: Viewing, Editing\n Initial: Viewing\n\n Transitions:\n - From Viewing to Viewing on INIT\n then [\"render-ui\", \"main\", {\"type\": \"entity-table\", \"entity\": \"Task\", \"itemActions\": [{\"label\": \"Edit\", \"event\": \"EDIT_TASK\"}, {\"label\": \"Delete\", \"event\": \"DELETE_TASK\", \"variant\": \"danger\"}]}]\n\n - From Viewing to Editing on EDIT_TASK\n then render form-section to modal for Task\n\n - From Editing to Viewing on SAVE_TASK\n then persist update Task\n then render null to modal\n```\n\n## Dashboard Example (Complex Patterns)\n\n```\nDashboard behavior:\n States: Viewing\n Initial: Viewing\n\n Transitions:\n - From Viewing to Viewing on INIT\n then render page-header to main with title 'Dashboard'\n then [\"render-ui\", \"center\", {\"type\": \"stats\", \"metrics\": [{\"field\": \"totalTasks\", \"label\": \"Total Tasks\"}, {\"field\": \"completedTasks\", \"label\": \"Completed\"}, {\"field\": \"overdueTasks\", \"label\": \"Overdue\"}]}]\n then [\"render-ui\", \"bottom\", {\"type\": \"tabs\", \"tabs\": [{\"id\": \"overview\", \"label\": \"Overview\", \"event\": \"VIEW_OVERVIEW\"}, {\"id\": \"recent\", \"label\": \"Recent Activity\", \"event\": \"VIEW_RECENT\"}]}]\n```\n\n**Note**: Use inline JSON for `render-ui` effects with complex props (metrics, tabs, itemActions, cells).\n";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Domain Language Common Patterns
|
|
3
|
+
*
|
|
4
|
+
* Reusable patterns for common application types.
|
|
5
|
+
*
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
*/
|
|
8
|
+
export declare const ODL_PATTERNS = "\n## Common Patterns\n\n### CRUD Pattern\n\n```\n[Entity]Management behavior:\n States: List, Detail, Create, Edit\n Initial: List\n\n Transitions:\n - From List to List on INIT\n then render entity-table to main for [Entity]\n\n - From List to Create on CREATE_[ENTITY]\n then render form-section to modal for [Entity]\n\n - From Create to List on SUBMIT_CREATE\n then persist create [Entity]\n then render null to modal\n\n - From List to Detail on VIEW_[ENTITY]\n then render entity-detail to drawer for [Entity]\n\n - From Detail to Edit on EDIT_[ENTITY]\n then render form-section to modal for [Entity]\n\n - From Edit to Detail on SUBMIT_EDIT\n then persist update [Entity]\n then render null to modal\n\n - From Detail to List on DELETE_[ENTITY]\n then persist delete [Entity]\n then render null to drawer\n```\n\n### Game Health Pattern\n\n```\nHealth behavior:\n States: Healthy, Wounded, Critical, Dead\n Initial: Healthy\n\n Transitions:\n - From Healthy to Wounded on TAKE_DAMAGE\n if health >= 30 and health < 70\n then update status to 'wounded'\n\n - From Wounded to Critical on TAKE_DAMAGE\n if health < 30\n then update status to 'critical'\n\n - From Critical to Dead on TAKE_DAMAGE\n if health <= 0\n then update isAlive to false\n then emit ENTITY_DIED\n```\n\n### Approval Workflow Pattern\n\n```\nApprovalWorkflow behavior:\n States: Draft, Pending, Approved, Rejected\n Initial: Draft\n\n Transitions:\n - From Draft to Pending on SUBMIT\n then update status to 'pending'\n then emit APPROVAL_REQUESTED\n\n - From Pending to Approved on APPROVE\n then update status to 'approved'\n then update approvedAt to now\n then emit APPROVAL_GRANTED\n\n - From Pending to Rejected on REJECT\n then update status to 'rejected'\n then emit APPROVAL_DENIED\n\n - From Rejected to Draft on REVISE\n then update status to 'draft'\n```\n\n### Form Validation Pattern\n\n```\nFormValidation behavior:\n States: Idle, Validating, Valid, Invalid\n Initial: Idle\n\n Transitions:\n - From Idle to Validating on VALIDATE\n then update isValidating to true\n\n - From Validating to Valid on VALIDATION_SUCCESS\n then update isValidating to false\n then update errors to null\n\n - From Validating to Invalid on VALIDATION_FAILED\n then update isValidating to false\n\n - From Invalid to Validating on VALIDATE\n then update isValidating to true\n\n - From Valid to Idle on RESET\n then update errors to null\n```\n\n### Dashboard Pattern\n\n```\nDashboardView behavior:\n States: Loading, Ready\n Initial: Loading\n\n Transitions:\n - From Loading to Ready on DATA_LOADED\n then render stats to main\n then render entity-cards to center\n\n - From Ready to Loading on REFRESH\n then emit FETCH_DASHBOARD_DATA\n```\n";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Domain Language Syntax Reference
|
|
3
|
+
*
|
|
4
|
+
* Complete syntax reference for the Orbital Domain Language.
|
|
5
|
+
*
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
*/
|
|
8
|
+
export declare const ODL_SYNTAX_REFERENCE = "\n## Domain Language Syntax\n\n### Entity Definition\n\n```\nA [EntityName] is a [persistence] entity that:\n - has [fieldName] as [type] (required|optional)\n - has [fieldName] as [type] with default [value]\n - belongs to [RelatedEntity]\n - belongs to [RelatedEntity] as [alias]\n - has many [RelatedEntity]s\n```\n\n**Persistence types:**\n- `persistent` - Stored in database (default)\n- `runtime` - Memory only, for games/UI state\n- `singleton` - Single instance, for config\n\n**Field types:**\n- `text` / `long text` - String fields\n- `number` / `currency` - Numeric fields\n- `yes/no` - Boolean fields\n- `date` / `timestamp` / `datetime` - Date fields\n- `enum [val1, val2]` - Enumeration\n- `list` / `object` - Complex types\n\n### Page Definition\n\n```\n[PageName] at /[path]:\n - shows [Entity] using [TraitName]\n - view type: [list|detail|create|edit|dashboard]\n - is initial page\n```\n\n### Behavior Definition\n\n```\n[BehaviorName] behavior:\n States: [State1], [State2], [State3]\n Initial: [State1]\n\n Transitions:\n - From [State1] to [State2] on [EVENT_NAME]\n if [guard condition]\n then [effect1]\n then [effect2]\n```\n\n### Section Headers\n\nDomain Language text is organized into sections:\n\n```\n# Entities\n[entity definitions]\n\n# Pages\n[page definitions]\n\n# Behaviors\n[behavior/trait definitions]\n```\n";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Domain Language to OrbitalSchema Mapping
|
|
3
|
+
*
|
|
4
|
+
* Reference for how Domain Language maps to OrbitalSchema JSON.
|
|
5
|
+
*
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
*/
|
|
8
|
+
export declare const ODL_TO_SCHEMA_MAPPING = "\n## Domain Language -> OrbitalSchema Mapping\n\n| Domain Language | OrbitalSchema |\n|-----------------|---------------|\n| \"A Task is...\" | `{ \"entity\": { \"name\": \"Task\", ... } }` |\n| \"persistent entity\" | `\"persistence\": \"persistent\"` |\n| \"runtime entity\" | `\"persistence\": \"runtime\"` |\n| \"singleton entity\" | `\"persistence\": \"singleton\"` |\n| \"has X as text\" | `{ \"name\": \"X\", \"type\": \"string\" }` |\n| \"has X as number\" | `{ \"name\": \"X\", \"type\": \"number\" }` |\n| \"has X as yes/no\" | `{ \"name\": \"X\", \"type\": \"boolean\" }` |\n| \"has X as enum [a, b]\" | `{ \"name\": \"X\", \"type\": \"enum\", \"values\": [\"a\", \"b\"] }` |\n| \"belongs to Y\" | `{ \"type\": \"relation\", \"relation\": { \"entity\": \"Y\" } }` |\n| \"belongs to Y as alias\" | `{ \"name\": \"alias\", \"type\": \"relation\", \"relation\": { \"entity\": \"Y\" } }` |\n| \"States: A, B\" | `\"states\": [{ \"name\": \"A\" }, { \"name\": \"B\" }]` |\n| \"Initial: A\" | `{ \"name\": \"A\", \"isInitial\": true }` |\n| \"From X to Y on Z\" | `{ \"from\": \"X\", \"to\": \"Y\", \"event\": \"Z\" }` |\n| \"if health >= 0\" | `\"guard\": [\">=\", \"@entity.health\", 0]` |\n| \"then update status to 'done'\" | `\"effects\": [[\"set\", \"@entity.status\", \"done\"]]` |\n| \"then emit EVENT\" | `\"effects\": [[\"emit\", \"EVENT\"]]` |\n| \"then render X to slot\" | `\"effects\": [[\"render-ui\", \"slot\", { \"type\": \"X\" }]]` |\n| \"then persist create Task\" | `\"effects\": [[\"persist\", \"create\", \"Task\"]]` |\n| \"then navigate to /path\" | `\"effects\": [[\"navigate\", \"/path\"]]` |\n\n## Conversion Process\n\n1. **Parse Domain Language** - Split into sections (Entities, Pages, Behaviors)\n2. **Extract entities** - Parse \"A X is...\" definitions\n3. **Extract pages** - Parse \"[Name] at /path\" definitions\n4. **Extract behaviors** - Parse \"[Name] behavior:\" definitions\n5. **Parse guards** - Convert human-readable conditions to S-expressions\n6. **Parse effects** - Convert human-readable effects to S-expressions\n7. **Assemble schema** - Build OrbitalSchema JSON structure\n\n## CLI Commands\n\n```bash\n# Convert Domain Language to OrbitalSchema\nnpx kflow domain:to-schema input.txt -o output.orb\n\n# Convert OrbitalSchema to Domain Language\nnpx kflow domain:to-text input.orb -o output.txt\n\n# Validate round-trip conversion\nnpx kflow domain:validate input.orb --verbose\n```\n";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Orbital Generation Module
|
|
3
|
+
*
|
|
4
|
+
* Exports generation utilities for eval/testing purposes.
|
|
5
|
+
* NOTE: The actual skill uses the DeepAgent/subagent pattern where
|
|
6
|
+
* agents use parent tools to write schema - not programmatic generation.
|
|
7
|
+
*
|
|
8
|
+
* @packageDocumentation
|
|
9
|
+
*/
|
|
10
|
+
export { generateFullOrbital, generateFullOrbitalsParallel, decomposeToOrbitals, estimateCacheSavings, PROVIDER_CONCURRENCY_LIMITS, type GenerationLog, type OrbitalGenerationOptions, type OrbitalGenerationResult, type ParallelGenerationOptions, type ParallelGenerationResult, type ExtractedRequirements, type DecomposeOptions, } from './orbital-generator.js';
|