@objectql/core 1.7.2 → 1.7.3
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 +8 -0
- package/LICENSE +118 -21
- package/dist/ai-agent.d.ts +175 -0
- package/dist/ai-agent.js +746 -0
- package/dist/ai-agent.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/repository.d.ts +7 -0
- package/dist/repository.js +64 -1
- package/dist/repository.js.map +1 -1
- package/dist/validator.d.ts +6 -2
- package/dist/validator.js +172 -13
- package/dist/validator.js.map +1 -1
- package/package.json +7 -3
- package/src/ai-agent.ts +888 -0
- package/src/index.ts +1 -2
- package/src/repository.ts +86 -3
- package/src/validator.ts +196 -13
- package/test/repository-validation.test.ts +343 -0
- package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
package/LICENSE
CHANGED
|
@@ -1,21 +1,118 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
to
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
# PolyForm Shield License 1.0.0
|
|
2
|
+
|
|
3
|
+
<https://polyformproject.org/licenses/shield/1.0.0>
|
|
4
|
+
|
|
5
|
+
## Acceptance
|
|
6
|
+
|
|
7
|
+
In order to get any license under these terms, you must agree
|
|
8
|
+
to them as both strict obligations and conditions to all
|
|
9
|
+
your licenses.
|
|
10
|
+
|
|
11
|
+
## Copyright License
|
|
12
|
+
|
|
13
|
+
The licensor grants you a copyright license for the
|
|
14
|
+
software to do everything you might do with the software
|
|
15
|
+
that would otherwise infringe the licensor's copyright
|
|
16
|
+
in it for any permitted purpose. However, you may
|
|
17
|
+
only distribute the software according to [Distribution
|
|
18
|
+
License](#distribution-license) and make changes or new works
|
|
19
|
+
based on the software according to [Changes and New Works
|
|
20
|
+
License](#changes-and-new-works-license).
|
|
21
|
+
|
|
22
|
+
## Distribution License
|
|
23
|
+
|
|
24
|
+
The licensor grants you an additional copyright license
|
|
25
|
+
to distribute copies of the software. Your license
|
|
26
|
+
to distribute covers distributing the software with
|
|
27
|
+
changes and new works permitted by [Changes and New Works
|
|
28
|
+
License](#changes-and-new-works-license).
|
|
29
|
+
|
|
30
|
+
## Notices
|
|
31
|
+
|
|
32
|
+
You must ensure that anyone who gets a copy of any part of
|
|
33
|
+
the software from you also gets a copy of these terms or the
|
|
34
|
+
URL for them above, as well as copies of any plain-text lines
|
|
35
|
+
beginning with `Required Notice:` that the licensor provided
|
|
36
|
+
with the software. For example:
|
|
37
|
+
|
|
38
|
+
> Required Notice: Copyright ObjectQL Contributors (https://github.com/objectql)
|
|
39
|
+
|
|
40
|
+
## Changes and New Works License
|
|
41
|
+
|
|
42
|
+
The licensor grants you an additional copyright license to
|
|
43
|
+
make changes and new works based on the software for any
|
|
44
|
+
permitted purpose.
|
|
45
|
+
|
|
46
|
+
## Patent License
|
|
47
|
+
|
|
48
|
+
The licensor grants you a patent license for the software that
|
|
49
|
+
covers patent claims the licensor can license, or becomes able
|
|
50
|
+
to license, that you would infringe by using the software.
|
|
51
|
+
|
|
52
|
+
## Fair Use
|
|
53
|
+
|
|
54
|
+
You may have "fair use" rights for the software under the
|
|
55
|
+
law. These terms do not limit them.
|
|
56
|
+
|
|
57
|
+
## No Other Rights
|
|
58
|
+
|
|
59
|
+
These terms do not allow you to sublicense or transfer any of
|
|
60
|
+
your licenses to anyone else, or prevent the licensor from
|
|
61
|
+
granting licenses to anyone else. These terms do not imply
|
|
62
|
+
any other licenses.
|
|
63
|
+
|
|
64
|
+
## Patent Defense
|
|
65
|
+
|
|
66
|
+
If you make any written claim that the software infringes or
|
|
67
|
+
contributes to infringement of any patent, your patent license
|
|
68
|
+
for the software granted under these terms ends immediately. If
|
|
69
|
+
your company makes such a claim, your patent license ends
|
|
70
|
+
immediately for work on behalf of your company.
|
|
71
|
+
|
|
72
|
+
## Violations
|
|
73
|
+
|
|
74
|
+
The first time you are notified in writing that you have
|
|
75
|
+
violated any of these terms, or done anything with the software
|
|
76
|
+
not covered by your licenses, your licenses can nonetheless
|
|
77
|
+
continue if you come into full compliance with these terms,
|
|
78
|
+
and take practical steps to correct past violations, within
|
|
79
|
+
32 days of receiving notice. Otherwise, all your licenses
|
|
80
|
+
end immediately.
|
|
81
|
+
|
|
82
|
+
## No Liability
|
|
83
|
+
|
|
84
|
+
***As far as the law allows, the software comes as is, without
|
|
85
|
+
any warranty or condition, and the licensor will not be liable
|
|
86
|
+
to you for any damages arising out of these terms or the use
|
|
87
|
+
or nature of the software, under any kind of legal claim.***
|
|
88
|
+
|
|
89
|
+
## Definitions
|
|
90
|
+
|
|
91
|
+
The **licensor** is the individual or entity offering these
|
|
92
|
+
terms, and the **software** is the software the licensor makes
|
|
93
|
+
available under these terms.
|
|
94
|
+
|
|
95
|
+
**You** refers to the individual or entity agreeing to these
|
|
96
|
+
terms.
|
|
97
|
+
|
|
98
|
+
**Your company** is any legal entity, sole proprietorship,
|
|
99
|
+
or other kind of organization that you work for, plus all
|
|
100
|
+
organizations that have control over, are under the control of,
|
|
101
|
+
or are under common control with that organization. **Control**
|
|
102
|
+
means ownership of substantially all the assets of an entity,
|
|
103
|
+
or the power to direct its management and policies by vote,
|
|
104
|
+
contract, or otherwise. Control can be direct or indirect.
|
|
105
|
+
|
|
106
|
+
**Your licenses** are all the licenses granted to you for the
|
|
107
|
+
software under these terms.
|
|
108
|
+
|
|
109
|
+
**Use** means anything you do with the software requiring one
|
|
110
|
+
of your licenses.
|
|
111
|
+
|
|
112
|
+
**Permitted purpose** means any purpose other than competing
|
|
113
|
+
with the licensor or any product the licensor or its affiliates
|
|
114
|
+
provides using the software.
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
Required Notice: Copyright (c) 2026 ObjectQL Contributors (https://github.com/objectql)
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ObjectQL AI Agent - Programmatic API for AI-powered application generation
|
|
3
|
+
*
|
|
4
|
+
* This module provides a high-level API for using AI to generate and validate
|
|
5
|
+
* ObjectQL metadata programmatically.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Configuration for the ObjectQL AI Agent
|
|
9
|
+
*/
|
|
10
|
+
export interface AgentConfig {
|
|
11
|
+
/** OpenAI API key */
|
|
12
|
+
apiKey: string;
|
|
13
|
+
/** OpenAI model to use (default: gpt-4) */
|
|
14
|
+
model?: string;
|
|
15
|
+
/** Temperature for generation (0-1, default: 0.7) */
|
|
16
|
+
temperature?: number;
|
|
17
|
+
/** Preferred language for messages (default: en) */
|
|
18
|
+
language?: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Options for generating application metadata
|
|
22
|
+
*/
|
|
23
|
+
export interface GenerateAppOptions {
|
|
24
|
+
/** Natural language description of the application */
|
|
25
|
+
description: string;
|
|
26
|
+
/** Type of generation: basic (minimal), complete (comprehensive), or custom */
|
|
27
|
+
type?: 'basic' | 'complete' | 'custom';
|
|
28
|
+
/** Maximum tokens for generation */
|
|
29
|
+
maxTokens?: number;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Result of application generation
|
|
33
|
+
*/
|
|
34
|
+
export interface GenerateAppResult {
|
|
35
|
+
/** Whether generation was successful */
|
|
36
|
+
success: boolean;
|
|
37
|
+
/** Generated metadata files */
|
|
38
|
+
files: Array<{
|
|
39
|
+
filename: string;
|
|
40
|
+
content: string;
|
|
41
|
+
type: 'object' | 'validation' | 'form' | 'view' | 'page' | 'menu' | 'action' | 'hook' | 'permission' | 'workflow' | 'report' | 'data' | 'application' | 'typescript' | 'test' | 'other';
|
|
42
|
+
}>;
|
|
43
|
+
/** Any errors encountered */
|
|
44
|
+
errors?: string[];
|
|
45
|
+
/** AI model response (raw) */
|
|
46
|
+
rawResponse?: string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Conversation message for step-by-step generation
|
|
50
|
+
*/
|
|
51
|
+
export interface ConversationMessage {
|
|
52
|
+
role: 'system' | 'user' | 'assistant';
|
|
53
|
+
content: string;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Options for conversational generation
|
|
57
|
+
*/
|
|
58
|
+
export interface ConversationalGenerateOptions {
|
|
59
|
+
/** Initial description or follow-up request */
|
|
60
|
+
message: string;
|
|
61
|
+
/** Previous conversation history */
|
|
62
|
+
conversationHistory?: ConversationMessage[];
|
|
63
|
+
/** Current application state (already generated files) */
|
|
64
|
+
currentApp?: GenerateAppResult;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Result of conversational generation
|
|
68
|
+
*/
|
|
69
|
+
export interface ConversationalGenerateResult extends GenerateAppResult {
|
|
70
|
+
/** Updated conversation history */
|
|
71
|
+
conversationHistory: ConversationMessage[];
|
|
72
|
+
/** Suggested next steps or questions */
|
|
73
|
+
suggestions?: string[];
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Options for validating metadata
|
|
77
|
+
*/
|
|
78
|
+
export interface ValidateMetadataOptions {
|
|
79
|
+
/** Metadata content (YAML string or parsed object) */
|
|
80
|
+
metadata: string | any;
|
|
81
|
+
/** Filename (for context) */
|
|
82
|
+
filename?: string;
|
|
83
|
+
/** Whether to check business logic consistency */
|
|
84
|
+
checkBusinessLogic?: boolean;
|
|
85
|
+
/** Whether to check performance considerations */
|
|
86
|
+
checkPerformance?: boolean;
|
|
87
|
+
/** Whether to check security issues */
|
|
88
|
+
checkSecurity?: boolean;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Result of metadata validation
|
|
92
|
+
*/
|
|
93
|
+
export interface ValidateMetadataResult {
|
|
94
|
+
/** Whether validation passed (no errors) */
|
|
95
|
+
valid: boolean;
|
|
96
|
+
/** Errors found */
|
|
97
|
+
errors: Array<{
|
|
98
|
+
message: string;
|
|
99
|
+
location?: string;
|
|
100
|
+
code?: string;
|
|
101
|
+
}>;
|
|
102
|
+
/** Warnings found */
|
|
103
|
+
warnings: Array<{
|
|
104
|
+
message: string;
|
|
105
|
+
location?: string;
|
|
106
|
+
suggestion?: string;
|
|
107
|
+
}>;
|
|
108
|
+
/** Informational messages */
|
|
109
|
+
info: Array<{
|
|
110
|
+
message: string;
|
|
111
|
+
location?: string;
|
|
112
|
+
}>;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* ObjectQL AI Agent for programmatic application generation and validation
|
|
116
|
+
*/
|
|
117
|
+
export declare class ObjectQLAgent {
|
|
118
|
+
private openai;
|
|
119
|
+
private validator;
|
|
120
|
+
private config;
|
|
121
|
+
constructor(config: AgentConfig);
|
|
122
|
+
/**
|
|
123
|
+
* Generate application metadata from natural language description
|
|
124
|
+
*/
|
|
125
|
+
generateApp(options: GenerateAppOptions): Promise<GenerateAppResult>;
|
|
126
|
+
/**
|
|
127
|
+
* Validate metadata using AI
|
|
128
|
+
*/
|
|
129
|
+
validateMetadata(options: ValidateMetadataOptions): Promise<ValidateMetadataResult>;
|
|
130
|
+
/**
|
|
131
|
+
* Refine existing metadata based on feedback
|
|
132
|
+
*/
|
|
133
|
+
refineMetadata(metadata: string, feedback: string, iterations?: number): Promise<GenerateAppResult>;
|
|
134
|
+
/**
|
|
135
|
+
* Conversational generation with step-by-step refinement
|
|
136
|
+
* This allows users to iteratively improve the application through dialogue
|
|
137
|
+
*/
|
|
138
|
+
generateConversational(options: ConversationalGenerateOptions): Promise<ConversationalGenerateResult>;
|
|
139
|
+
/**
|
|
140
|
+
* Generate suggestions for next steps based on current application state
|
|
141
|
+
*/
|
|
142
|
+
private generateSuggestions;
|
|
143
|
+
/**
|
|
144
|
+
* Get system prompt for metadata generation
|
|
145
|
+
*/
|
|
146
|
+
private getSystemPrompt;
|
|
147
|
+
/**
|
|
148
|
+
* Get system prompt for validation
|
|
149
|
+
*/
|
|
150
|
+
private getValidationSystemPrompt;
|
|
151
|
+
/**
|
|
152
|
+
* Build generation prompt based on options
|
|
153
|
+
*/
|
|
154
|
+
private buildGenerationPrompt;
|
|
155
|
+
/**
|
|
156
|
+
* Build validation prompt
|
|
157
|
+
*/
|
|
158
|
+
private buildValidationPrompt;
|
|
159
|
+
/**
|
|
160
|
+
* Parse generation response and extract files
|
|
161
|
+
*/
|
|
162
|
+
private parseGenerationResponse;
|
|
163
|
+
/**
|
|
164
|
+
* Parse validation feedback into structured result
|
|
165
|
+
*/
|
|
166
|
+
private parseFeedback;
|
|
167
|
+
/**
|
|
168
|
+
* Infer file type from filename
|
|
169
|
+
*/
|
|
170
|
+
private inferFileType;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Convenience function to create an agent instance
|
|
174
|
+
*/
|
|
175
|
+
export declare function createAgent(apiKey: string, options?: Partial<AgentConfig>): ObjectQLAgent;
|