Skip to content

Commit 9fbd033

Browse files
committed
b
1 parent 1eabd59 commit 9fbd033

File tree

14 files changed

+202
-111
lines changed

14 files changed

+202
-111
lines changed

backend/files/misc/common-startup-files/default-files/scrape-or-crawl-websites-or-sitemaps.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,22 @@ Hence, if the user is asking you to scrape some website or something related to
2525

2626
**IMPORTANT** - DO NOT save such tools unless the user explicitly tells you to do that! And you DO NOT need to instruct the Hyperlambda generator to create code that returns JSON since this is what it does by default.
2727

28-
If the user wants to create a reusable tool, you can invoke the Hyperlambda generator once more with a similar prompt, but this time starting out with "Generate an Executable Hyperlambda file that ...", mentioning input arguments in your prompt, which will give you a function taking arguments that you can persist as a Hyperlambda file in some module. Once it is saved, it can also be added to a machine learning type as an AI function using the "create-ai-function" function. But do NOT do this unless the user asks, but offer to do this after having verified the function successfully works as expected.
28+
If the user wants to create a reusable tool, you can invoke the Hyperlambda generator once more with a similar prompt, but this time starting out with "Generate an Executable Hyperlambda file that ...", mentioning input arguments in your prompt, which will give you a function taking arguments that you can persist as a Hyperlambda file in a module. Once it is saved, it can also be added to a machine learning type as an AI function using the "create-ai-function" function. But do NOT do this unless the user asks, but offer to do this only *after* having verified the function successfully works as expected.
2929

3030
If the user asks you to create web scraping tools, then follow this process, unless user explicitly tells you something else.
3131

3232
1. Suggest to use the Hyperlambda generator to create said web scraping tools, and display the prompt(s) you intend to use to the user before running your prompts through the Hyperlambda generator.
3333
2. Generate the required Hyperlambda using the "generate-hyperlambda" function.
34-
3. Execute the Hyperlambda immediately in the same message.
34+
3. Execute the Hyperlambda immediately in the same message using the "execute-hyperlambda" function.
3535
4. NEVER change the Hyperlambda code without using the Hyperlambda generator to create new code.
3636

3737
**IMPORTANT** - If the user asks you to change the Hyperlambda code, then change your *prompt* and rerun it through the Hyperlambda generator.
3838

3939
**NEVER** change the Hyperlambda returned by the Hyperlambda generator. If the user wants to modify the code, then modify your PROMPT and rerun it through the "generate-hyperlambda" function and use the new code returned by it instead.
4040

41-
**CRITICAL RULE****DO NOT** manually modify, rewrite, or even show an edited version of Hyperlambda code. If the user requests any change to previously generated Hyperlambda (even a small one), you must:
41+
**CRITICAL RULE****DO NOT** manually modify or rewrite Hyperlambda code. If the user requests any change to previously generated Hyperlambda (even a small one), you must:
4242

43-
1. Create a new prompt describing the desired change.
44-
2. Re‑invoke the generate-hyperlambda function with that prompt.
43+
1. Create a new prompt describing the desired result, including any changes the user asked for.
44+
2. Re‑invoke the "generate-hyperlambda" function with that prompt.
4545
3. Use the new code returned by the generator.
4646
4. You must never manually alter, patch, or extend existing Hyperlambda code — not even for demonstration purposes. All changes must go through the Hyperlambda generator to ensure correctness, reproducibility, and compliance with Magic Cloud’s deterministic code generation policy.

backend/files/system/diagnostics/system-information.get.hl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,6 @@ if
4949
default_db:x:@.default-db
5050
default_timezone:x:@.default-timezone
5151
has_openai:x:@.has-openai
52+
throw:You have not yet configured your auth secret
53+
public:bool:true
54+
status:int:400

backend/files/system/sql/ddl/export-tables.post.hl

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ validators.enum:x:@.arguments/*/databaseType
2929
.:mysql
3030
.:sqlite
3131
.:pgsql
32+
.:mssql
3233

3334
// Creating our database connection.
3435
strings.concat
@@ -148,3 +149,99 @@ group by pn.nspname, pc.relname, pa.attrelid;"
148149
unwrap:x:+/*
149150
return
150151
result:x:@.result
152+
153+
case:mssql
154+
.result
155+
set-value:x:@.result
156+
strings.concat
157+
.:"/*\r\n * Automatically generated by Magic.\r\n */\r\n"
158+
for-each:x:@.arguments/*/tables/*
159+
.scheme
160+
.table
161+
strings.split:x:@.dp/#
162+
.:.
163+
set-value:x:@.scheme
164+
get-value:x:@strings.split/0
165+
set-value:x:@.table
166+
get-value:x:@strings.split/1
167+
.sql:@"SELECT
168+
'CREATE TABLE [' + s.name + '].[' + t.name + '] (' +
169+
STRING_AGG(
170+
' [' + c.name + '] ' +
171+
UPPER(ty.name) +
172+
CASE
173+
WHEN ty.name IN ('varchar','char','nvarchar','nchar')
174+
THEN '(' + CASE WHEN c.max_length = -1 THEN 'MAX'
175+
ELSE CAST(c.max_length AS varchar) END + ')'
176+
WHEN ty.name IN ('decimal','numeric')
177+
THEN '(' + CAST(c.precision AS varchar) + ',' + CAST(c.scale AS varchar) + ')'
178+
ELSE ''
179+
END +
180+
CASE WHEN c.is_identity = 1 THEN ' IDENTITY(1,1)' ELSE '' END +
181+
CASE WHEN c.is_nullable = 0 THEN ' NOT NULL' ELSE ' NULL' END
182+
, ',' + CHAR(10)) +
183+
CHAR(10) + ');'
184+
AS ddl
185+
FROM sys.tables t
186+
JOIN sys.schemas s ON t.schema_id = s.schema_id
187+
JOIN sys.columns c ON t.object_id = c.object_id
188+
JOIN sys.types ty ON c.user_type_id = ty.user_type_id
189+
WHERE t.name = @name AND s.name = @scheme
190+
GROUP BY s.name, t.name
191+
ORDER BY s.name, t.name;
192+
"
193+
data.select:x:@.sql
194+
database-type:x:@.arguments/*/databaseType
195+
name:x:@.table
196+
scheme:x:@.scheme
197+
set-value:x:@.result
198+
strings.concat
199+
get-value:x:@.result
200+
get-value:x:@data.select/*/*/ddl
201+
.:"\r\n\r\n"
202+
.sql:@"SELECT
203+
'ALTER TABLE [' + s.name + '].[' + t.name + '] ADD CONSTRAINT [' + kc.name + '] PRIMARY KEY (' +
204+
STRING_AGG('[' + c.name + ']', ', ') + ');' AS ddl
205+
FROM sys.key_constraints kc
206+
JOIN sys.tables t ON kc.parent_object_id = t.object_id
207+
JOIN sys.schemas s ON t.schema_id = s.schema_id
208+
JOIN sys.index_columns ic ON kc.parent_object_id = ic.object_id AND kc.unique_index_id = ic.index_id
209+
JOIN sys.columns c ON ic.object_id = c.object_id AND ic.column_id = c.column_id
210+
WHERE kc.type = 'PK' AND t.name = @name AND s.name = @scheme
211+
GROUP BY s.name, t.name, kc.name;
212+
"
213+
data.select:x:@.sql
214+
database-type:x:@.arguments/*/databaseType
215+
name:x:@.table
216+
scheme:x:@.scheme
217+
set-value:x:@.result
218+
strings.concat
219+
get-value:x:@.result
220+
get-value:x:@data.select/*/*/ddl
221+
.:"\r\n\r\n"
222+
.sql:@"SELECT
223+
'ALTER TABLE [' + s.name + '].[' + t.name + '] ADD CONSTRAINT [' + fk.name + '] FOREIGN KEY ([' +
224+
pc.name + ']) REFERENCES [' +
225+
rs.name + '].[' + rt.name + ']([' + rc.name + ']);' AS ddl
226+
FROM sys.foreign_keys fk
227+
JOIN sys.tables t ON fk.parent_object_id = t.object_id
228+
JOIN sys.schemas s ON t.schema_id = s.schema_id
229+
JOIN sys.foreign_key_columns fkc ON fk.object_id = fkc.constraint_object_id
230+
JOIN sys.columns pc ON fkc.parent_object_id = pc.object_id AND fkc.parent_column_id = pc.column_id
231+
JOIN sys.tables rt ON fkc.referenced_object_id = rt.object_id
232+
JOIN sys.schemas rs ON rt.schema_id = rs.schema_id
233+
JOIN sys.columns rc ON fkc.referenced_object_id = rc.object_id AND fkc.referenced_column_id = rc.column_id
234+
WHERE t.name = @name and s.name = @scheme;
235+
"
236+
data.select:x:@.sql
237+
database-type:x:@.arguments/*/databaseType
238+
name:x:@.table
239+
scheme:x:@.scheme
240+
set-value:x:@.result
241+
strings.concat
242+
get-value:x:@.result
243+
get-value:x:@data.select/*/*/ddl
244+
.:"\r\n\r\n"
245+
unwrap:x:+/*
246+
return
247+
result:x:@.result

frontend/src/app/components/protected/create/sql-studio/components/tables-view/components/export-ddl/export-ddl.component.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,16 @@ <h3 mat-dialog-title class="mb-0">Export DDL</h3>
2222

2323
<button
2424
mat-button
25-
mat-dialog-close>
26-
Cancel
27-
</button>
28-
29-
<button
30-
mat-flat-button
3125
color="primary"
3226
class="px-4"
3327
[mat-dialog-close]="data">
3428
Export to module
3529
</button>
3630

31+
<button
32+
mat-flat-button
33+
mat-dialog-close>
34+
Close
35+
</button>
36+
3737
</div>

frontend/src/app/components/protected/create/sql-studio/components/tables-view/tables-view.component.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,6 @@ export class TablesViewComponent implements OnInit, OnDestroy {
144144

145145
viewTableDDL(tableName: string) {
146146

147-
if (this.selectedDbType === 'mssql') {
148-
this.generalService.showFeedback('SQL Server does not allow us to easily view DDL');
149-
return;
150-
}
151-
152147
this.generalService.showLoading();
153148

154149
this.sqlService.exportDdl(

frontend/src/app/components/protected/create/sql-studio/sql-studio.component.html

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,3 +248,42 @@
248248
</div>
249249

250250
</div>
251+
252+
<div class="backdrop" *ngIf="waitingForAnswer">
253+
<svg width="120" height="40" xmlns="http://www.w3.org/2000/svg">
254+
<circle cx="15" cy="20" r="10" fill="#9A8AfD">
255+
<animate attributeName="opacity"
256+
dur="1.2s"
257+
values="0.3;1;0.3"
258+
repeatCount="indefinite"/>
259+
<animate attributeName="cy"
260+
dur="1.2s"
261+
values="20;10;20"
262+
repeatCount="indefinite"/>
263+
</circle>
264+
<circle cx="60" cy="20" r="10" fill="#9A8AfD">
265+
<animate attributeName="opacity"
266+
dur="1.2s"
267+
values="0.3;1;0.3"
268+
repeatCount="indefinite"
269+
begin="0.4s"/>
270+
<animate attributeName="cy"
271+
dur="1.2s"
272+
values="20;10;20"
273+
repeatCount="indefinite"
274+
begin="0.4s"/>
275+
</circle>
276+
<circle cx="105" cy="20" r="10" fill="#9A8AfD">
277+
<animate attributeName="opacity"
278+
dur="1.2s"
279+
values="0.3;1;0.3"
280+
repeatCount="indefinite"
281+
begin="0.8s"/>
282+
<animate attributeName="cy"
283+
dur="1.2s"
284+
values="20;10;20"
285+
repeatCount="indefinite"
286+
begin="0.8s"/>
287+
</circle>
288+
</svg>
289+
</div>

frontend/src/app/components/protected/create/sql-studio/sql-studio.component.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,15 @@ import { NewTableComponent } from './components/tables-view/components/add-table
2121
*/
2222
@Component({
2323
selector: 'app-sql-studio',
24-
templateUrl: './sql-studio.component.html'
24+
templateUrl: './sql-studio.component.html',
25+
styleUrls: ['sql-studio.components.scss']
2526
})
2627
export class SQLStudioComponent implements OnInit {
2728

2829
private _tables: ReplaySubject<any[]> = new ReplaySubject();
2930
private _hintTables: ReplaySubject<any> = new ReplaySubject();
3031
private _dbLoading: ReplaySubject<boolean> = new ReplaySubject();
32+
waitingForAnswer: boolean = false;
3133

3234
databaseTypes: any = [] = [
3335
{type: 'sqlite', name: 'SQLite'},
@@ -236,11 +238,6 @@ export class SQLStudioComponent implements OnInit {
236238
return;
237239
}
238240

239-
if (this.selectedDbType === 'mssql') {
240-
this.generalService.showFeedback('SQL Server does not allow us to easily view DDL');
241-
return;
242-
}
243-
244241
let tables = this.databases.find((db: any) => db.name === this.selectedDatabase).tables || [];
245242
if (tables.length === 0) {
246243

@@ -257,6 +254,8 @@ export class SQLStudioComponent implements OnInit {
257254
return 0;
258255
});
259256

257+
this.generalService.showLoading();
258+
this.waitingForAnswer = true;
260259
this.sqlService.exportDdl(
261260
this.selectedDbType,
262261
this.selectedConnectionString,
@@ -265,6 +264,8 @@ export class SQLStudioComponent implements OnInit {
265264
true).subscribe({
266265
next: (result: any) => {
267266

267+
this.generalService.hideLoading();
268+
this.waitingForAnswer = false;
268269
this.dialog.open(ExportDdlComponent, {
269270
width: '80vw',
270271
panelClass: 'light',
@@ -291,8 +292,12 @@ export class SQLStudioComponent implements OnInit {
291292
}
292293
});
293294
},
294-
error: (error: any) => this.generalService.showFeedback(error?.error?.message ?? error, 'errorMessage', 'Ok', 5000)
295-
});
295+
error: (error: any) => {
296+
297+
this.generalService.hideLoading();
298+
this.waitingForAnswer = false;
299+
this.generalService.showFeedback(error?.error?.message ?? error, 'errorMessage', 'Ok', 5000);
300+
}});
296301
}
297302

298303
changeDatabase() {
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
2+
@keyframes waiting_for_ai {
3+
to {
4+
opacity: 1;
5+
}
6+
}
7+
8+
.backdrop {
9+
background: rgba(0,0,0,.7);
10+
z-index: 10000;
11+
position: fixed;
12+
left: 0;
13+
top:0;
14+
right:0;
15+
bottom:0;
16+
animation: 1s waiting_for_ai linear forwards;
17+
opacity: 0;
18+
}
19+
20+
.backdrop svg {
21+
width: 150px;
22+
display: block;
23+
position: absolute;
24+
bottom: 1rem;
25+
left: calc(50% - 75px)
26+
}

frontend/src/app/components/protected/dashboard/_models/dashboard.model.ts

Lines changed: 1 addition & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -6,67 +6,7 @@
66
* Retrieving reports on the health and activities of your backend.
77
*/
88
export interface SystemReport {
9-
cache_items?: number,
109
default_db?: string,
10+
has_openai?: boolean,
1111
default_timezone?: string, // "none", "utc" or "local"
12-
dynamic_slots?: number,
13-
endpoints?: number,
14-
has_scheduler?: boolean,
15-
has_terminal?: boolean,
16-
persisted_tasks?: number,
17-
version?: string,
18-
server_ip?: string,
19-
slots?: number,
20-
log_items?: number,
21-
last_log_items?: LastLogItems[],
22-
modules?: Modules[],
23-
log_types?: LogTypes[],
24-
timeshifts?: Timeshifts[]
25-
}
26-
27-
/**
28-
* type of logs created on the backend
29-
*/
30-
export interface LogTypes {
31-
debug?: number,
32-
error?: number,
33-
fatal?: number
34-
}
35-
36-
/**
37-
* Displaying the of login details on the system
38-
*/
39-
export interface Timeshifts {
40-
variable?: {
41-
description?: string,
42-
name?: string,
43-
items?: [{
44-
when?: Date,
45-
count?: number
46-
}]
47-
}
48-
}
49-
50-
/**
51-
* Displaying the complexity of modules
52-
*/
53-
export interface Modules {
54-
variable?: [{
55-
files?: number,
56-
loc?: number
57-
}]
58-
}
59-
60-
/**
61-
* Displaying the complexity of modules
62-
*/
63-
export interface LastLogItems {
64-
id: string,
65-
content?: string,
66-
type?: string,
67-
created?: string,
68-
exception?: string,
69-
meta?: {
70-
variable?: string
71-
}
7212
}

frontend/src/app/components/protected/dashboard/components/vibe-coding/vibe-coding.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191

9292
<form [class]="'col-12' + (is_answering ? ' hide_input' : '')" (ngSubmit)="submit()">
9393

94-
<mat-form-field class="w-100">
94+
<mat-form-field class="w-100 input-textarea">
9595
<textarea
9696
#queryTextarea
9797
matInput

0 commit comments

Comments
 (0)