agentlang 0.0.16 → 0.0.18
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/out/cli/docs.d.ts +2 -0
- package/out/cli/docs.d.ts.map +1 -0
- package/out/cli/docs.js +236 -0
- package/out/cli/docs.js.map +1 -0
- package/out/cli/openapi-docs.yml +695 -0
- package/out/extension/main.cjs +250 -250
- package/out/extension/main.cjs.map +2 -2
- package/out/index.d.ts +19 -0
- package/out/index.d.ts.map +1 -0
- package/out/index.js +25 -0
- package/out/index.js.map +1 -0
- package/out/language/generated/ast.d.ts +3 -3
- package/out/language/generated/ast.d.ts.map +1 -1
- package/out/language/generated/ast.js +0 -1
- package/out/language/generated/ast.js.map +1 -1
- package/out/language/generated/grammar.d.ts.map +1 -1
- package/out/language/generated/grammar.js +8 -0
- package/out/language/generated/grammar.js.map +1 -1
- package/out/language/main.cjs +510 -502
- package/out/language/main.cjs.map +3 -3
- package/out/runtime/agents/common.d.ts +1 -1
- package/out/runtime/agents/common.d.ts.map +1 -1
- package/out/runtime/agents/common.js +16 -2
- package/out/runtime/agents/common.js.map +1 -1
- package/out/runtime/auth/cognito.d.ts +4 -1
- package/out/runtime/auth/cognito.d.ts.map +1 -1
- package/out/runtime/auth/cognito.js +69 -1
- package/out/runtime/auth/cognito.js.map +1 -1
- package/out/runtime/auth/interface.d.ts +4 -1
- package/out/runtime/auth/interface.d.ts.map +1 -1
- package/out/runtime/interpreter.js +24 -5
- package/out/runtime/interpreter.js.map +1 -1
- package/out/runtime/jsmodules.js +1 -1
- package/out/runtime/jsmodules.js.map +1 -1
- package/out/runtime/module.d.ts +2 -0
- package/out/runtime/module.d.ts.map +1 -1
- package/out/runtime/module.js +14 -1
- package/out/runtime/module.js.map +1 -1
- package/out/runtime/modules/auth.d.ts +6 -3
- package/out/runtime/modules/auth.d.ts.map +1 -1
- package/out/runtime/modules/auth.js +67 -6
- package/out/runtime/modules/auth.js.map +1 -1
- package/out/syntaxes/agentlang.monarch.js +2 -2
- package/out/syntaxes/agentlang.monarch.js.map +1 -1
- package/package.json +6 -3
- package/src/language/agentlang.langium +2 -2
- package/src/language/generated/ast.ts +4 -3
- package/src/language/generated/grammar.ts +8 -0
- package/src/runtime/agents/common.ts +16 -2
- package/src/runtime/auth/cognito.ts +77 -0
- package/src/runtime/auth/interface.ts +10 -0
- package/src/runtime/interpreter.ts +22 -5
- package/src/runtime/jsmodules.ts +1 -1
- package/src/runtime/module.ts +15 -1
- package/src/runtime/modules/auth.ts +82 -7
- package/src/syntaxes/agentlang.monarch.ts +2 -2
|
@@ -4,9 +4,9 @@ export default {
|
|
|
4
4
|
'@actions', '@after', '@as', '@async', '@before', '@catch', '@distinct', '@enum', '@expr', '@from', '@into', '@meta', '@oneof', '@rbac', '@ref', '@then', '@upsert', '@with_unique', 'agent', 'allow', 'and', 'await', 'between', 'contains', 'create', 'delete', 'else', 'entity', 'error', 'event', 'extends', 'false', 'for', 'if', 'import', 'in', 'like', 'module', 'not', 'not_found', 'onSubscription', 'or', 'purge', 'query', 'read', 'record', 'relationship', 'resolver', 'return', 'roles', 'subscribe', 'true', 'update', 'upsert', 'where', 'workflow'
|
|
5
5
|
],
|
|
6
6
|
operators: [
|
|
7
|
-
'*', '+', ',', '-', '.', '/', ':', ';', '<', '<=', '<>', '=', '>', '>=', '?', '@'
|
|
7
|
+
'!=', '*', '+', ',', '-', '.', '/', ':', ';', '<', '<=', '<>', '=', '>', '>=', '?', '@'
|
|
8
8
|
],
|
|
9
|
-
symbols:
|
|
9
|
+
symbols: /!=|\(|\)|\*|\+|,|-|\.|\/|:|;|<|<=|<>|=|>|>=|\?|@|\[|\]|\{|\}/,
|
|
10
10
|
tokenizer: {
|
|
11
11
|
initial: [
|
|
12
12
|
{ regex: /(([_a-zA-Z][\w_]*)(\/([_a-zA-Z][\w_]*))?)/, action: { cases: { '@keywords': { "token": "keyword" }, '@default': { "token": "string" } } } },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agentlang.monarch.js","sourceRoot":"","sources":["../../src/syntaxes/agentlang.monarch.ts"],"names":[],"mappings":"AAAA,0DAA0D;AAC1D,eAAe;IACX,QAAQ,EAAE;QACN,UAAU,EAAC,QAAQ,EAAC,KAAK,EAAC,QAAQ,EAAC,SAAS,EAAC,QAAQ,EAAC,WAAW,EAAC,OAAO,EAAC,OAAO,EAAC,OAAO,EAAC,OAAO,EAAC,OAAO,EAAC,QAAQ,EAAC,OAAO,EAAC,MAAM,EAAC,OAAO,EAAC,SAAS,EAAC,cAAc,EAAC,OAAO,EAAC,OAAO,EAAC,KAAK,EAAC,OAAO,EAAC,SAAS,EAAC,UAAU,EAAC,QAAQ,EAAC,QAAQ,EAAC,MAAM,EAAC,QAAQ,EAAC,OAAO,EAAC,OAAO,EAAC,SAAS,EAAC,OAAO,EAAC,KAAK,EAAC,IAAI,EAAC,QAAQ,EAAC,IAAI,EAAC,MAAM,EAAC,QAAQ,EAAC,KAAK,EAAC,WAAW,EAAC,gBAAgB,EAAC,IAAI,EAAC,OAAO,EAAC,OAAO,EAAC,MAAM,EAAC,QAAQ,EAAC,cAAc,EAAC,UAAU,EAAC,QAAQ,EAAC,OAAO,EAAC,WAAW,EAAC,MAAM,EAAC,QAAQ,EAAC,QAAQ,EAAC,OAAO,EAAC,UAAU;KAChf;IACD,SAAS,EAAE;QACP,GAAG,EAAC,GAAG,EAAC,GAAG,EAAC,GAAG,EAAC,GAAG,EAAC,GAAG,EAAC,GAAG,EAAC,GAAG,EAAC,GAAG,EAAC,IAAI,EAAC,IAAI,EAAC,GAAG,EAAC,GAAG,EAAC,IAAI,EAAC,GAAG,EAAC,GAAG;
|
|
1
|
+
{"version":3,"file":"agentlang.monarch.js","sourceRoot":"","sources":["../../src/syntaxes/agentlang.monarch.ts"],"names":[],"mappings":"AAAA,0DAA0D;AAC1D,eAAe;IACX,QAAQ,EAAE;QACN,UAAU,EAAC,QAAQ,EAAC,KAAK,EAAC,QAAQ,EAAC,SAA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0.18",
|
|
5
5
|
"files": [
|
|
6
6
|
"bin",
|
|
7
7
|
"out",
|
|
@@ -11,12 +11,16 @@
|
|
|
11
11
|
"scripts": {
|
|
12
12
|
"install:pnpm": "pnpm install --prefer-offline",
|
|
13
13
|
"build": "tsc -b tsconfig.src.json && tsc -b tsconfig.declarations.json && node esbuild.mjs",
|
|
14
|
+
|
|
14
15
|
"build:ts": "tsc -b tsconfig.src.json",
|
|
15
16
|
"build:vite": "vite build --emptyOutDir",
|
|
16
17
|
"watch": "concurrently -n tsc,esbuild -c blue,yellow \"tsc -b tsconfig.src.json --watch\" \"node esbuild.mjs --watch\"",
|
|
18
|
+
|
|
17
19
|
"lint": "eslint . --ext .ts",
|
|
18
20
|
"lint:fix": "eslint . --ext .ts --fix",
|
|
21
|
+
|
|
19
22
|
"format": "prettier --write \"src/**/*.{js,ts,tsx,json,md}\"",
|
|
23
|
+
|
|
20
24
|
"format:check": "prettier --check \"src/**/*.{js,ts,tsx,json,md}\"",
|
|
21
25
|
"langium:generate": "langium generate",
|
|
22
26
|
"langium:generate:production": "langium generate --mode=production",
|
|
@@ -150,5 +154,4 @@
|
|
|
150
154
|
]
|
|
151
155
|
},
|
|
152
156
|
"packageManager": "pnpm@10.13.1+sha512.37ebf1a5c7a30d5fabe0c5df44ee8da4c965ca0c5af3dbab28c3a1681b70a256218d05c81c9c0dcf767ef6b8551eb5b960042b9ed4300c59242336377e01cfad"
|
|
153
|
-
}
|
|
154
|
-
|
|
157
|
+
}
|
|
@@ -154,7 +154,7 @@ Delete: 'delete' pattern=Pattern;
|
|
|
154
154
|
|
|
155
155
|
Purge: 'purge' pattern=Pattern;
|
|
156
156
|
|
|
157
|
-
SetAttribute: name=QueryId op=('='|'<>'|'<'|'<='|'>'|'>='|'in'|'like'|'between')? value=AttributeValueExpression;
|
|
157
|
+
SetAttribute: name=QueryId op=('='|'<>' | '!=' |'<'|'<='|'>'|'>='|'in'|'like'|'between')? value=AttributeValueExpression;
|
|
158
158
|
|
|
159
159
|
AttributeValueExpression: Expr;
|
|
160
160
|
|
|
@@ -170,7 +170,7 @@ Logical infers Expr:
|
|
|
170
170
|
Comparison ({infer BinExpr.e1=current} op=('or'|'and') e2=Comparison)*;
|
|
171
171
|
|
|
172
172
|
Comparison infers Expr:
|
|
173
|
-
PrimExpr ({infer BinExpr.e1=current} op=('='|'<>'|'<'|'<='|'>'|'>='|'in'|'like') e2=PrimExpr)*;
|
|
173
|
+
PrimExpr ({infer BinExpr.e1=current} op=('=' | '!=' | '<>'|'<'|'<='|'>'|'>='|'in'|'like') e2=PrimExpr)*;
|
|
174
174
|
|
|
175
175
|
PrimExpr: Literal | Group | NegExpr | NotExpr;
|
|
176
176
|
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* DO NOT EDIT MANUALLY!
|
|
4
4
|
******************************************************************************/
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
|
|
7
7
|
import * as langium from 'langium';
|
|
8
8
|
|
|
9
9
|
export const AgentlangTerminals = {
|
|
@@ -18,6 +18,7 @@ export const AgentlangTerminals = {
|
|
|
18
18
|
export type AgentlangTerminalNames = keyof typeof AgentlangTerminals;
|
|
19
19
|
|
|
20
20
|
export type AgentlangKeywordNames =
|
|
21
|
+
| "!="
|
|
21
22
|
| "("
|
|
22
23
|
| ")"
|
|
23
24
|
| "*"
|
|
@@ -311,7 +312,7 @@ export interface BinExpr extends langium.AstNode {
|
|
|
311
312
|
readonly $type: 'BinExpr';
|
|
312
313
|
e1: Expr | PrimExpr;
|
|
313
314
|
e2: Expr | PrimExpr;
|
|
314
|
-
op: '*' | '+' | '-' | '/' | '<' | '<=' | '<>' | '=' | '>' | '>=' | 'and' | 'in' | 'like' | 'or';
|
|
315
|
+
op: '!=' | '*' | '+' | '-' | '/' | '<' | '<=' | '<>' | '=' | '>' | '>=' | 'and' | 'in' | 'like' | 'or';
|
|
315
316
|
}
|
|
316
317
|
|
|
317
318
|
export const BinExpr = 'BinExpr';
|
|
@@ -1061,7 +1062,7 @@ export interface SetAttribute extends langium.AstNode {
|
|
|
1061
1062
|
readonly $container: CrudMapBody;
|
|
1062
1063
|
readonly $type: 'SetAttribute';
|
|
1063
1064
|
name: QueryId;
|
|
1064
|
-
op?: '<' | '<=' | '<>' | '=' | '>' | '>=' | 'between' | 'in' | 'like';
|
|
1065
|
+
op?: '!=' | '<' | '<=' | '<>' | '=' | '>' | '>=' | 'between' | 'in' | 'like';
|
|
1065
1066
|
value: AttributeValueExpression;
|
|
1066
1067
|
}
|
|
1067
1068
|
|
|
@@ -4423,6 +4423,10 @@ export const AgentlangGrammar = (): Grammar => loadedAgentlangGrammar ?? (loaded
|
|
|
4423
4423
|
"$type": "Keyword",
|
|
4424
4424
|
"value": "<>"
|
|
4425
4425
|
},
|
|
4426
|
+
{
|
|
4427
|
+
"$type": "Keyword",
|
|
4428
|
+
"value": "!="
|
|
4429
|
+
},
|
|
4426
4430
|
{
|
|
4427
4431
|
"$type": "Keyword",
|
|
4428
4432
|
"value": "<"
|
|
@@ -4763,6 +4767,10 @@ export const AgentlangGrammar = (): Grammar => loadedAgentlangGrammar ?? (loaded
|
|
|
4763
4767
|
"$type": "Keyword",
|
|
4764
4768
|
"value": "="
|
|
4765
4769
|
},
|
|
4770
|
+
{
|
|
4771
|
+
"$type": "Keyword",
|
|
4772
|
+
"value": "!="
|
|
4773
|
+
},
|
|
4766
4774
|
{
|
|
4767
4775
|
"$type": "Keyword",
|
|
4768
4776
|
"value": "<>"
|
|
@@ -67,7 +67,7 @@ The default query operator is '=' (equals). So an expression like 'employeeId? "
|
|
|
67
67
|
'{age?< 50}' - which means 'where age less-than 50'. The comparison operators supported by a query pattern are:
|
|
68
68
|
|
|
69
69
|
= - equals
|
|
70
|
-
|
|
70
|
+
!= - not-equals
|
|
71
71
|
< - less-than
|
|
72
72
|
<= - less-than or equals
|
|
73
73
|
> - greater-than
|
|
@@ -148,6 +148,20 @@ A fix for the reference-error is shown below:
|
|
|
148
148
|
{Employee {id? 101}} @as employee;
|
|
149
149
|
{SendEmail {to employee.email, body "hello"}}
|
|
150
150
|
|
|
151
|
+
Keep in mind that the only valid syntax for the 'if' condition is:
|
|
152
|
+
|
|
153
|
+
if (<expr>) {
|
|
154
|
+
<patterns>
|
|
155
|
+
} else if (<expr>) {
|
|
156
|
+
<patterns>
|
|
157
|
+
} else {
|
|
158
|
+
<patterns>
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
The following usage is NOT valid:
|
|
162
|
+
|
|
163
|
+
<pattern> if (<expr>)
|
|
164
|
+
|
|
151
165
|
A pattern may execute asynchronously and its eventual result can be handled by patterns provided in the '@then' clause. An example is shown below:
|
|
152
166
|
|
|
153
167
|
{sendChatMessage {to "amy", "text" "hello"}} @as response @then {
|
|
@@ -241,7 +255,7 @@ As an example, if the user request is "send an email to employee 101 with this m
|
|
|
241
255
|
[{employee {id? 101}} @as emp;
|
|
242
256
|
{email {to emp.email, body "please call me as soon as possible"}}]
|
|
243
257
|
|
|
244
|
-
|
|
258
|
+
You MUST separate each pattern in the array with a semi-colon (;) and never use a comma (,) for this purpose.
|
|
245
259
|
|
|
246
260
|
Now consider the following module definition and generate appropriate patterns in response to the user instructions. You must return only valid patterns or workflows,
|
|
247
261
|
no other descriptive text or comments are needed.
|
|
@@ -34,6 +34,9 @@ import {
|
|
|
34
34
|
let fromEnv: any = undefined;
|
|
35
35
|
let CognitoIdentityProviderClient: any = undefined;
|
|
36
36
|
let SignUpCommand: any = undefined;
|
|
37
|
+
let ConfirmSignUp: any = undefined;
|
|
38
|
+
let ForgotPasswordCommand: any = undefined;
|
|
39
|
+
let ConfirmForgotPasswordCommand: any = undefined;
|
|
37
40
|
let AdminGetUserCommand: any = undefined;
|
|
38
41
|
let InitiateAuthCommand: any = undefined;
|
|
39
42
|
let AuthenticationDetails: any = undefined;
|
|
@@ -51,6 +54,9 @@ if (isNodeEnv) {
|
|
|
51
54
|
const cip = await import('@aws-sdk/client-cognito-identity-provider');
|
|
52
55
|
CognitoIdentityProviderClient = cip.CognitoIdentityProviderClient;
|
|
53
56
|
SignUpCommand = cip.SignUpCommand;
|
|
57
|
+
ConfirmSignUp = cip.ConfirmSignUpCommand;
|
|
58
|
+
ForgotPasswordCommand = cip.ForgotPasswordCommand;
|
|
59
|
+
ConfirmForgotPasswordCommand = cip.ConfirmForgotPasswordCommand;
|
|
54
60
|
AdminGetUserCommand = cip.AdminGetUserCommand;
|
|
55
61
|
InitiateAuthCommand = cip.InitiateAuthCommand;
|
|
56
62
|
|
|
@@ -321,6 +327,8 @@ export class CognitoAuth implements AgentlangAuth {
|
|
|
321
327
|
}
|
|
322
328
|
|
|
323
329
|
async signUp(
|
|
330
|
+
firstName: string,
|
|
331
|
+
lastName: string,
|
|
324
332
|
username: string,
|
|
325
333
|
password: string,
|
|
326
334
|
userData: Map<string, string> | undefined,
|
|
@@ -340,6 +348,14 @@ export class CognitoAuth implements AgentlangAuth {
|
|
|
340
348
|
Name: 'name',
|
|
341
349
|
Value: username,
|
|
342
350
|
},
|
|
351
|
+
{
|
|
352
|
+
Name: 'given_name',
|
|
353
|
+
Value: firstName,
|
|
354
|
+
},
|
|
355
|
+
{
|
|
356
|
+
Name: 'family_name',
|
|
357
|
+
Value: lastName,
|
|
358
|
+
},
|
|
343
359
|
];
|
|
344
360
|
if (userData) {
|
|
345
361
|
userData.forEach((v: string, k: string) => {
|
|
@@ -384,6 +400,67 @@ export class CognitoAuth implements AgentlangAuth {
|
|
|
384
400
|
}
|
|
385
401
|
}
|
|
386
402
|
|
|
403
|
+
async confirmSignup(username: string, confirmationCode: string, env: Environment): Promise<void> {
|
|
404
|
+
try {
|
|
405
|
+
const client = new CognitoIdentityProviderClient({
|
|
406
|
+
region: process.env.AWS_REGION || 'us-west-2',
|
|
407
|
+
credentials: fromEnv(),
|
|
408
|
+
});
|
|
409
|
+
const command = new ConfirmSignUp({
|
|
410
|
+
ClientId: this.config.get('ClientId'),
|
|
411
|
+
Username: username,
|
|
412
|
+
ConfirmationCode: confirmationCode,
|
|
413
|
+
});
|
|
414
|
+
await client.send(command);
|
|
415
|
+
} catch (error: any) {
|
|
416
|
+
logger.error(`Failed to confirm signup: ${error.message}`);
|
|
417
|
+
handleCognitoError(error, 'confirmSignup');
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
async forgotPassword(username: string, _env: Environment): Promise<void> {
|
|
422
|
+
try {
|
|
423
|
+
const client = new CognitoIdentityProviderClient({
|
|
424
|
+
region: process.env.AWS_REGION || 'us-west-2',
|
|
425
|
+
credentials: fromEnv(),
|
|
426
|
+
});
|
|
427
|
+
const command = new ForgotPasswordCommand({
|
|
428
|
+
ClientId: this.fetchClientId(),
|
|
429
|
+
Username: username,
|
|
430
|
+
});
|
|
431
|
+
await client.send(command);
|
|
432
|
+
} catch (err: any) {
|
|
433
|
+
logger.error(`Forgot password failed for ${username}: ${sanitizeErrorMessage(err.message)}`);
|
|
434
|
+
handleCognitoError(err, 'forgotPassword');
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
async confirmForgotPassword(
|
|
439
|
+
username: string,
|
|
440
|
+
confirmationCode: string,
|
|
441
|
+
newPassword: string,
|
|
442
|
+
_env: Environment
|
|
443
|
+
): Promise<void> {
|
|
444
|
+
try {
|
|
445
|
+
const client = new CognitoIdentityProviderClient({
|
|
446
|
+
region: process.env.AWS_REGION || 'us-west-2',
|
|
447
|
+
credentials: fromEnv(),
|
|
448
|
+
});
|
|
449
|
+
const command = new ConfirmForgotPasswordCommand({
|
|
450
|
+
ClientId: this.fetchClientId(),
|
|
451
|
+
Username: username,
|
|
452
|
+
ConfirmationCode: confirmationCode,
|
|
453
|
+
Password: newPassword,
|
|
454
|
+
});
|
|
455
|
+
await client.send(command);
|
|
456
|
+
} catch (err: any) {
|
|
457
|
+
logger.error(
|
|
458
|
+
`Confirm forgot password failed for ${username}: ${sanitizeErrorMessage(err.message)}`
|
|
459
|
+
);
|
|
460
|
+
handleCognitoError(err, 'confirmForgotPassword');
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
|
|
387
464
|
async login(
|
|
388
465
|
username: string,
|
|
389
466
|
password: string,
|
|
@@ -22,12 +22,22 @@ export type LogoutCallback = (status: boolean) => void;
|
|
|
22
22
|
|
|
23
23
|
export interface AgentlangAuth {
|
|
24
24
|
signUp(
|
|
25
|
+
firstName: string,
|
|
26
|
+
lastName: string,
|
|
25
27
|
username: string,
|
|
26
28
|
password: string,
|
|
27
29
|
userData: Map<string, any> | undefined,
|
|
28
30
|
env: Environment,
|
|
29
31
|
cb: SignUpCallback
|
|
30
32
|
): any;
|
|
33
|
+
confirmSignup(username: string, confirmationCode: string, env: Environment): Promise<void>;
|
|
34
|
+
forgotPassword(username: string, env: Environment): Promise<void>;
|
|
35
|
+
confirmForgotPassword(
|
|
36
|
+
username: string,
|
|
37
|
+
confirmationCode: string,
|
|
38
|
+
newPassword: string,
|
|
39
|
+
env: Environment
|
|
40
|
+
): Promise<void>;
|
|
31
41
|
login(username: string, password: string, env: Environment, cb: LoginCallback): any;
|
|
32
42
|
logout(sessionInfo: SessionInfo, env: Environment, cb?: LogoutCallback): any;
|
|
33
43
|
verifyToken(token: string, env?: Environment): any;
|
|
@@ -1127,8 +1127,15 @@ async function evaluateCrudMap(crud: CrudMap, env: Environment): Promise<void> {
|
|
|
1127
1127
|
for (let j = 0; j < lastRes.length; ++j) {
|
|
1128
1128
|
const newEnv: Environment = Environment.from(env);
|
|
1129
1129
|
if (isContainsRelationship(rel.name, moduleName)) {
|
|
1130
|
-
const
|
|
1131
|
-
|
|
1130
|
+
const currInst: Instance = lastRes[j];
|
|
1131
|
+
let ppath = '';
|
|
1132
|
+
if (relEntry.isParent(currInst)) {
|
|
1133
|
+
ppath = currInst.lookup(PathAttributeName);
|
|
1134
|
+
newEnv.setParentPath(ppath + '/' + escapeFqName(relEntry.getFqName()));
|
|
1135
|
+
} else {
|
|
1136
|
+
ppath = currInst.lookup(ParentAttributeName);
|
|
1137
|
+
newEnv.setParentPath(ppath);
|
|
1138
|
+
}
|
|
1132
1139
|
newEnv.setNormalizedParentPath(ppath);
|
|
1133
1140
|
await evaluatePattern(rel.pattern, newEnv);
|
|
1134
1141
|
lastRes[j].attachRelatedInstances(rel.name, newEnv.getLastResult());
|
|
@@ -1303,11 +1310,17 @@ async function handleAgentInvocation(agentEventInst: Instance, env: Environment)
|
|
|
1303
1310
|
logger.debug(`Agent ${agent.name} generated pattern: ${result}`);
|
|
1304
1311
|
try {
|
|
1305
1312
|
let rs = result.trim();
|
|
1306
|
-
|
|
1313
|
+
let isWf = rs.startsWith('workflow');
|
|
1314
|
+
const isGrp = rs.startsWith('[');
|
|
1315
|
+
if (!isWf && !isGrp && rs.indexOf(';') > 0) {
|
|
1316
|
+
rs = `workflow T {${rs}}`;
|
|
1317
|
+
isWf = true;
|
|
1318
|
+
} else if (!isWf && isGrp) {
|
|
1307
1319
|
const stmts = rs.substring(1, rs.length - 1);
|
|
1308
1320
|
rs = `workflow T {${stmts}}`;
|
|
1321
|
+
isWf = true;
|
|
1309
1322
|
}
|
|
1310
|
-
if (
|
|
1323
|
+
if (isWf) {
|
|
1311
1324
|
const wf = await parseWorkflow(rs);
|
|
1312
1325
|
if (agent.runWorkflows) {
|
|
1313
1326
|
await evaluateStatements(wf.statements, env);
|
|
@@ -1334,7 +1347,10 @@ function cleanupAgentResponse(response: string | undefined): string | undefined
|
|
|
1334
1347
|
}
|
|
1335
1348
|
const parts = resp.split('\n');
|
|
1336
1349
|
const validated = parts.filter((s: string) => {
|
|
1337
|
-
|
|
1350
|
+
let stmt = s.trim();
|
|
1351
|
+
if (stmt.endsWith(',')) {
|
|
1352
|
+
stmt = `${stmt.substring(0, stmt.length - 1)};`;
|
|
1353
|
+
}
|
|
1338
1354
|
const r =
|
|
1339
1355
|
stmt.startsWith('{') ||
|
|
1340
1356
|
stmt.startsWith('}') ||
|
|
@@ -1479,6 +1495,7 @@ async function evaluateExpression(expr: Expr, env: Environment): Promise<void> {
|
|
|
1479
1495
|
result = v1 >= v2;
|
|
1480
1496
|
break;
|
|
1481
1497
|
case '<>':
|
|
1498
|
+
case '!=':
|
|
1482
1499
|
result = v1 != v2;
|
|
1483
1500
|
break;
|
|
1484
1501
|
case 'like':
|
package/src/runtime/jsmodules.ts
CHANGED
|
@@ -36,7 +36,7 @@ export async function importModule(path: string, name: string, moduleFileName?:
|
|
|
36
36
|
}
|
|
37
37
|
path = `${s}${sep}${path}`;
|
|
38
38
|
}
|
|
39
|
-
if (
|
|
39
|
+
if ((path.startsWith(sep) || path.startsWith('.')) && moduleFileName) {
|
|
40
40
|
path = process.cwd() + sep + path;
|
|
41
41
|
}
|
|
42
42
|
const m = await import(/* @vite-ignore */ path);
|
package/src/runtime/module.ts
CHANGED
|
@@ -139,6 +139,8 @@ function attributePropertyValueToString(
|
|
|
139
139
|
if (isTextualType(attrType) && propValue != 'now()' && propValue != 'uuid()') {
|
|
140
140
|
return `"${propValue}"`;
|
|
141
141
|
}
|
|
142
|
+
} else if (propName == 'comment') {
|
|
143
|
+
return `"${propValue}"`;
|
|
142
144
|
}
|
|
143
145
|
return `${propValue}`;
|
|
144
146
|
}
|
|
@@ -171,7 +173,7 @@ function normalizeMetaValue(metaValue: any): any {
|
|
|
171
173
|
return normalizeMetaValue(value.pattern.expr);
|
|
172
174
|
});
|
|
173
175
|
} else if (v.bool != undefined) {
|
|
174
|
-
return v.bool;
|
|
176
|
+
return v.bool == 'true' ? true : false;
|
|
175
177
|
} else if (v.id) {
|
|
176
178
|
return v.id;
|
|
177
179
|
} else if (v.map) {
|
|
@@ -884,6 +886,11 @@ export class Entity extends Record {
|
|
|
884
886
|
getRbacSpecifications(): RbacSpecification[] | undefined {
|
|
885
887
|
return this.rbac;
|
|
886
888
|
}
|
|
889
|
+
|
|
890
|
+
isConfigEntity(): boolean {
|
|
891
|
+
const v = this.getMeta('configEntity');
|
|
892
|
+
return v == true;
|
|
893
|
+
}
|
|
887
894
|
}
|
|
888
895
|
|
|
889
896
|
export class Event extends Record {
|
|
@@ -1286,6 +1293,12 @@ export class Module {
|
|
|
1286
1293
|
return entry;
|
|
1287
1294
|
}
|
|
1288
1295
|
|
|
1296
|
+
getConfigEntity(): Entity | undefined {
|
|
1297
|
+
return this.getEntityEntries().find((e: Entity) => {
|
|
1298
|
+
return e.isConfigEntity();
|
|
1299
|
+
});
|
|
1300
|
+
}
|
|
1301
|
+
|
|
1289
1302
|
addAgent(agentEntry: Agent): Agent {
|
|
1290
1303
|
return this.addEntry(agentEntry) as Agent;
|
|
1291
1304
|
}
|
|
@@ -1590,6 +1603,7 @@ export const propertyNames = new Set([
|
|
|
1590
1603
|
'@readonly',
|
|
1591
1604
|
'@enum',
|
|
1592
1605
|
'@oneof',
|
|
1606
|
+
'@comment',
|
|
1593
1607
|
]);
|
|
1594
1608
|
|
|
1595
1609
|
const TextualTypes = new Set(['String', 'Email', 'UUID', 'DateTime', 'Date', 'Time', 'Path']);
|
|
@@ -173,13 +173,29 @@ workflow RemoveUserSession {
|
|
|
173
173
|
}
|
|
174
174
|
|
|
175
175
|
workflow signup {
|
|
176
|
-
await Auth.signUpUser(signup.email, signup.password, signup.userData)
|
|
176
|
+
await Auth.signUpUser(signup.firstName, signup.lastName, signup.email, signup.password, signup.userData)
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
workflow confirmSignup {
|
|
180
|
+
await Auth.confirmSignupUser(confirmSignup.email, confirmSignup.confirmationCode)
|
|
177
181
|
}
|
|
178
182
|
|
|
179
183
|
workflow login {
|
|
180
184
|
await Auth.loginUser(login.email, login.password)
|
|
181
185
|
}
|
|
182
186
|
|
|
187
|
+
workflow forgotPassword {
|
|
188
|
+
await Auth.forgotPasswordUser(forgotPassword.email)
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
workflow confirmForgotPassword {
|
|
192
|
+
await Auth.confirmForgotPasswordUser(
|
|
193
|
+
confirmForgotPassword.email,
|
|
194
|
+
confirmForgotPassword.confirmationCode,
|
|
195
|
+
confirmForgotPassword.newPassword
|
|
196
|
+
)
|
|
197
|
+
}
|
|
198
|
+
|
|
183
199
|
workflow logout {
|
|
184
200
|
await Auth.logoutUser()
|
|
185
201
|
}
|
|
@@ -573,7 +589,10 @@ function fetchAuthImpl(): AgentlangAuth {
|
|
|
573
589
|
throw new Error('Auth not initialized');
|
|
574
590
|
}
|
|
575
591
|
}
|
|
592
|
+
|
|
576
593
|
export async function signUpUser(
|
|
594
|
+
firstName: string,
|
|
595
|
+
lastName: string,
|
|
577
596
|
username: string,
|
|
578
597
|
password: string,
|
|
579
598
|
userData: object,
|
|
@@ -582,6 +601,8 @@ export async function signUpUser(
|
|
|
582
601
|
let result: any;
|
|
583
602
|
try {
|
|
584
603
|
await fetchAuthImpl().signUp(
|
|
604
|
+
firstName,
|
|
605
|
+
lastName,
|
|
585
606
|
username,
|
|
586
607
|
password,
|
|
587
608
|
userData ? new Map(Object.entries(userData)) : undefined,
|
|
@@ -597,6 +618,49 @@ export async function signUpUser(
|
|
|
597
618
|
}
|
|
598
619
|
}
|
|
599
620
|
|
|
621
|
+
export async function confirmSignupUser(
|
|
622
|
+
username: string,
|
|
623
|
+
confirmationCode: string,
|
|
624
|
+
env: Environment
|
|
625
|
+
): Promise<Result> {
|
|
626
|
+
try {
|
|
627
|
+
console.log('confirmSignupUser', username, confirmationCode, env);
|
|
628
|
+
await fetchAuthImpl().confirmSignup(username, confirmationCode, env);
|
|
629
|
+
return {
|
|
630
|
+
status: 'ok',
|
|
631
|
+
message: 'User confirmed successfully',
|
|
632
|
+
};
|
|
633
|
+
} catch (err: any) {
|
|
634
|
+
logger.error(`Confirm signup failed for ${username}: ${err.message}`);
|
|
635
|
+
throw err; // Re-throw to preserve error type for HTTP status mapping
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
export async function forgotPasswordUser(username: string, env: Environment): Promise<Result> {
|
|
640
|
+
try {
|
|
641
|
+
await fetchAuthImpl().forgotPassword(username, env);
|
|
642
|
+
return { status: 'ok', message: 'Password reset code sent' };
|
|
643
|
+
} catch (err: any) {
|
|
644
|
+
logger.error(`Forgot password failed for ${username}: ${err.message}`);
|
|
645
|
+
throw err;
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
export async function confirmForgotPasswordUser(
|
|
650
|
+
username: string,
|
|
651
|
+
confirmationCode: string,
|
|
652
|
+
newPassword: string,
|
|
653
|
+
env: Environment
|
|
654
|
+
): Promise<Result> {
|
|
655
|
+
try {
|
|
656
|
+
await fetchAuthImpl().confirmForgotPassword(username, confirmationCode, newPassword, env);
|
|
657
|
+
return { status: 'ok', message: 'Password has been reset' };
|
|
658
|
+
} catch (err: any) {
|
|
659
|
+
logger.error(`Confirm forgot password failed for ${username}: ${err.message}`);
|
|
660
|
+
throw err;
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
|
|
600
664
|
export async function loginUser(
|
|
601
665
|
username: string,
|
|
602
666
|
password: string,
|
|
@@ -629,7 +693,7 @@ export async function loginUser(
|
|
|
629
693
|
}
|
|
630
694
|
}
|
|
631
695
|
|
|
632
|
-
async function logoutSession(userId: string, sess: Instance, env: Environment): Promise<
|
|
696
|
+
async function logoutSession(userId: string, sess: Instance, env: Environment): Promise<Result> {
|
|
633
697
|
const sessId = sess.lookup('id');
|
|
634
698
|
const tok = sess.lookup('authToken');
|
|
635
699
|
await fetchAuthImpl().logout(
|
|
@@ -644,23 +708,29 @@ async function logoutSession(userId: string, sess: Instance, env: Environment):
|
|
|
644
708
|
env
|
|
645
709
|
);
|
|
646
710
|
await removeSession(sessId, env);
|
|
647
|
-
return
|
|
711
|
+
return {
|
|
712
|
+
status: 'ok',
|
|
713
|
+
message: 'Logged out successfully',
|
|
714
|
+
};
|
|
648
715
|
}
|
|
649
716
|
|
|
650
|
-
export async function logoutUser(env: Environment): Promise<
|
|
717
|
+
export async function logoutUser(env: Environment): Promise<Result> {
|
|
651
718
|
const user = env.getActiveUser();
|
|
652
719
|
const sess = await findUserSession(user, env);
|
|
653
720
|
if (sess) {
|
|
654
721
|
return await logoutSession(user, sess, env);
|
|
655
722
|
}
|
|
656
|
-
return
|
|
723
|
+
return {
|
|
724
|
+
status: 'ok',
|
|
725
|
+
message: 'Logged out successfully',
|
|
726
|
+
};
|
|
657
727
|
}
|
|
658
728
|
|
|
659
729
|
export async function changePassword(
|
|
660
730
|
newPassword: string,
|
|
661
731
|
password: string,
|
|
662
732
|
env: Environment
|
|
663
|
-
): Promise<
|
|
733
|
+
): Promise<Result> {
|
|
664
734
|
const user = env.getActiveUser();
|
|
665
735
|
const sess = await findUserSession(user, env);
|
|
666
736
|
if (sess) {
|
|
@@ -870,7 +940,12 @@ export function requireAuth(moduleName: string, eventName: string): boolean {
|
|
|
870
940
|
if (isAuthEnabled()) {
|
|
871
941
|
const f =
|
|
872
942
|
moduleName == CoreAuthModuleName &&
|
|
873
|
-
(eventName == 'login' ||
|
|
943
|
+
(eventName == 'login' ||
|
|
944
|
+
eventName == 'signup' ||
|
|
945
|
+
eventName == 'confirmSignup' ||
|
|
946
|
+
eventName == 'forgotPassword' ||
|
|
947
|
+
eventName == 'confirmForgotPassword' ||
|
|
948
|
+
eventName == 'refreshToken');
|
|
874
949
|
return !f;
|
|
875
950
|
} else {
|
|
876
951
|
return false;
|
|
@@ -4,9 +4,9 @@ export default {
|
|
|
4
4
|
'@actions','@after','@as','@async','@before','@catch','@distinct','@enum','@expr','@from','@into','@meta','@oneof','@rbac','@ref','@then','@upsert','@with_unique','agent','allow','and','await','between','contains','create','delete','else','entity','error','event','extends','false','for','if','import','in','like','module','not','not_found','onSubscription','or','purge','query','read','record','relationship','resolver','return','roles','subscribe','true','update','upsert','where','workflow'
|
|
5
5
|
],
|
|
6
6
|
operators: [
|
|
7
|
-
'*','+',',','-','.','/',':',';','<','<=','<>','=','>','>=','?','@'
|
|
7
|
+
'!=','*','+',',','-','.','/',':',';','<','<=','<>','=','>','>=','?','@'
|
|
8
8
|
],
|
|
9
|
-
symbols:
|
|
9
|
+
symbols: /!=|\(|\)|\*|\+|,|-|\.|\/|:|;|<|<=|<>|=|>|>=|\?|@|\[|\]|\{|\}/,
|
|
10
10
|
|
|
11
11
|
tokenizer: {
|
|
12
12
|
initial: [
|