agentlang 0.3.0 → 0.3.2
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/README.md +295 -31
- package/out/api/http.d.ts.map +1 -1
- package/out/api/http.js +5 -3
- package/out/api/http.js.map +1 -1
- package/out/language/agentlang-validator.d.ts.map +1 -1
- package/out/language/agentlang-validator.js +24 -4
- package/out/language/agentlang-validator.js.map +1 -1
- package/out/language/generated/ast.d.ts +58 -7
- package/out/language/generated/ast.d.ts.map +1 -1
- package/out/language/generated/ast.js +82 -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 +537 -216
- package/out/language/generated/grammar.js.map +1 -1
- package/out/language/main.cjs +614 -221
- package/out/language/main.cjs.map +2 -2
- package/out/runtime/agents/common.d.ts +15 -1
- package/out/runtime/agents/common.d.ts.map +1 -1
- package/out/runtime/agents/common.js +71 -2
- package/out/runtime/agents/common.js.map +1 -1
- package/out/runtime/exec-graph.d.ts.map +1 -1
- package/out/runtime/exec-graph.js +1 -7
- package/out/runtime/exec-graph.js.map +1 -1
- package/out/runtime/interpreter.d.ts.map +1 -1
- package/out/runtime/interpreter.js +45 -17
- package/out/runtime/interpreter.js.map +1 -1
- package/out/runtime/loader.d.ts +3 -4
- package/out/runtime/loader.d.ts.map +1 -1
- package/out/runtime/loader.js +97 -12
- package/out/runtime/loader.js.map +1 -1
- package/out/runtime/module.d.ts +41 -4
- package/out/runtime/module.d.ts.map +1 -1
- package/out/runtime/module.js +237 -18
- package/out/runtime/module.js.map +1 -1
- package/out/runtime/modules/ai.d.ts.map +1 -1
- package/out/runtime/modules/ai.js +16 -7
- package/out/runtime/modules/ai.js.map +1 -1
- package/out/runtime/modules/auth.d.ts.map +1 -1
- package/out/runtime/modules/auth.js +42 -43
- package/out/runtime/modules/auth.js.map +1 -1
- package/out/runtime/modules/core.js +1 -1
- package/out/runtime/util.d.ts +3 -1
- package/out/runtime/util.d.ts.map +1 -1
- package/out/runtime/util.js +16 -0
- package/out/runtime/util.js.map +1 -1
- package/out/syntaxes/agentlang.monarch.js +1 -1
- package/out/syntaxes/agentlang.monarch.js.map +1 -1
- package/package.json +1 -1
- package/src/api/http.ts +5 -3
- package/src/language/agentlang-validator.ts +29 -4
- package/src/language/agentlang.langium +15 -3
- package/src/language/generated/ast.ts +149 -7
- package/src/language/generated/grammar.ts +537 -216
- package/src/runtime/agents/common.ts +96 -3
- package/src/runtime/exec-graph.ts +1 -8
- package/src/runtime/interpreter.ts +47 -16
- package/src/runtime/loader.ts +110 -9
- package/src/runtime/module.ts +268 -24
- package/src/runtime/modules/ai.ts +13 -6
- package/src/runtime/modules/auth.ts +42 -43
- package/src/runtime/modules/core.ts +1 -1
- package/src/runtime/util.ts +19 -0
- package/src/syntaxes/agentlang.monarch.ts +1 -1
|
@@ -44,25 +44,25 @@ workflow AfterDeleteUser {
|
|
|
44
44
|
{RemoveUserSession {id AfterDeleteUser.User.id}}
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
workflow CreateUser {
|
|
47
|
+
@public workflow CreateUser {
|
|
48
48
|
{User {id CreateUser.id,
|
|
49
49
|
email CreateUser.email,
|
|
50
50
|
firstName CreateUser.firstName,
|
|
51
51
|
lastName CreateUser.lastName}}
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
workflow UpdateUser {
|
|
54
|
+
@public workflow UpdateUser {
|
|
55
55
|
{User {id UpdateUser.id,
|
|
56
56
|
firstName UpdateUser.firstName,
|
|
57
57
|
lastName UpdateUser.lastName}, @upsert}
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
workflow FindUser {
|
|
60
|
+
@public workflow FindUser {
|
|
61
61
|
{User {id? FindUser.id}} @as [user];
|
|
62
62
|
user
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
workflow FindUserByEmail {
|
|
65
|
+
@public workflow FindUserByEmail {
|
|
66
66
|
{User {email? FindUserByEmail.email}} @as [user];
|
|
67
67
|
user
|
|
68
68
|
}
|
|
@@ -84,20 +84,20 @@ entity Permission {
|
|
|
84
84
|
|
|
85
85
|
relationship RolePermission between(Role, Permission)
|
|
86
86
|
|
|
87
|
-
workflow CreateRole {
|
|
87
|
+
@public workflow CreateRole {
|
|
88
88
|
{Role {name CreateRole.name}, @upsert}
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
workflow FindRole {
|
|
91
|
+
@public workflow FindRole {
|
|
92
92
|
{Role {name? FindRole.name}} @as [role];
|
|
93
93
|
role
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
-
workflow ListRoles {
|
|
96
|
+
@public workflow ListRoles {
|
|
97
97
|
{Role? {}}
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
workflow ListUserRoles {
|
|
100
|
+
@public workflow ListUserRoles {
|
|
101
101
|
if (ListUserRoles.Role and ListUserRoles.User) {
|
|
102
102
|
{UserRole {User? ListUserRoles.User, Role? ListUserRoles.Role}}
|
|
103
103
|
}
|
|
@@ -112,11 +112,11 @@ workflow ListUserRoles {
|
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
-
workflow ListPermissions {
|
|
115
|
+
@public workflow ListPermissions {
|
|
116
116
|
{Permission? {}}
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
-
workflow ListRolePermissions {
|
|
119
|
+
@public workflow ListRolePermissions {
|
|
120
120
|
if (ListRolePermissions.Role and ListRolePermissions.Permission) {
|
|
121
121
|
{RolePermission {Role? ListRolePermissions.Role, Permission? ListRolePermissions.Permission}}
|
|
122
122
|
}
|
|
@@ -131,24 +131,24 @@ workflow ListRolePermissions {
|
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
133
|
|
|
134
|
-
workflow AssignUserToRole {
|
|
134
|
+
@public workflow AssignUserToRole {
|
|
135
135
|
{User {id? AssignUserToRole.userId}} @as [user];
|
|
136
136
|
{Role {name? AssignUserToRole.roleName}} @as [role];
|
|
137
137
|
{UserRole {User user, Role role}, @upsert}
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
-
workflow AssignUserToRoleByEmail {
|
|
140
|
+
@public workflow AssignUserToRoleByEmail {
|
|
141
141
|
{User {email? AssignUserToRoleByEmail.email}} @as [user];
|
|
142
142
|
{Role {name? AssignUserToRoleByEmail.roleName}} @as [role];
|
|
143
143
|
{UserRole {User user, Role role}, @upsert}
|
|
144
144
|
}
|
|
145
145
|
|
|
146
|
-
workflow FindUserRoles {
|
|
146
|
+
@public workflow FindUserRoles {
|
|
147
147
|
{User {id? FindUserRoles.userId},
|
|
148
148
|
UserRole {Role? {}}}
|
|
149
149
|
}
|
|
150
150
|
|
|
151
|
-
workflow CreatePermission {
|
|
151
|
+
@public workflow CreatePermission {
|
|
152
152
|
{Permission {id CreatePermission.id,
|
|
153
153
|
resourceFqName CreatePermission.resourceFqName,
|
|
154
154
|
c CreatePermission.c,
|
|
@@ -159,13 +159,13 @@ workflow CreatePermission {
|
|
|
159
159
|
@upsert}
|
|
160
160
|
}
|
|
161
161
|
|
|
162
|
-
workflow AddPermissionToRole {
|
|
162
|
+
@public workflow AddPermissionToRole {
|
|
163
163
|
{Role {name? AddPermissionToRole.roleName}} @as [role];
|
|
164
164
|
{Permission {id? AddPermissionToRole.permissionId}} @as [perm];
|
|
165
165
|
{RolePermission {Role role, Permission perm}, @upsert}
|
|
166
166
|
}
|
|
167
167
|
|
|
168
|
-
workflow FindRolePermissions {
|
|
168
|
+
@public workflow FindRolePermissions {
|
|
169
169
|
{Role {name? FindRolePermissions.role},
|
|
170
170
|
RolePermission {Permission? {}}}
|
|
171
171
|
}
|
|
@@ -180,8 +180,7 @@ entity Session {
|
|
|
180
180
|
@rbac [(allow: [read, delete, update, create], where: auth.user = this.userId)]
|
|
181
181
|
}
|
|
182
182
|
|
|
183
|
-
|
|
184
|
-
workflow CreateSession {
|
|
183
|
+
@public workflow CreateSession {
|
|
185
184
|
{Session {id CreateSession.id, userId CreateSession.userId,
|
|
186
185
|
authToken CreateSession.authToken,
|
|
187
186
|
accessToken CreateSession.accessToken,
|
|
@@ -189,7 +188,7 @@ workflow CreateSession {
|
|
|
189
188
|
isActive true}}
|
|
190
189
|
}
|
|
191
190
|
|
|
192
|
-
workflow UpdateSession {
|
|
191
|
+
@public workflow UpdateSession {
|
|
193
192
|
{Session {id? UpdateSession.id,
|
|
194
193
|
authToken UpdateSession.authToken,
|
|
195
194
|
accessToken UpdateSession.accessToken,
|
|
@@ -197,44 +196,44 @@ workflow UpdateSession {
|
|
|
197
196
|
isActive true}, @upsert}
|
|
198
197
|
}
|
|
199
198
|
|
|
200
|
-
workflow FindSession {
|
|
199
|
+
@public workflow FindSession {
|
|
201
200
|
{Session {id? FindSession.id}} @as [session];
|
|
202
201
|
session
|
|
203
202
|
}
|
|
204
203
|
|
|
205
|
-
workflow FindUserSession {
|
|
204
|
+
@public workflow FindUserSession {
|
|
206
205
|
{Session {userId? FindUserSession.userId}} @as [session];
|
|
207
206
|
session
|
|
208
207
|
}
|
|
209
208
|
|
|
210
|
-
workflow RemoveSession {
|
|
209
|
+
@public workflow RemoveSession {
|
|
211
210
|
purge {Session {id? RemoveSession.id}}
|
|
212
211
|
}
|
|
213
212
|
|
|
214
|
-
workflow RemoveUserSession {
|
|
213
|
+
@public workflow RemoveUserSession {
|
|
215
214
|
{Session {userId? RemoveUserSession.id}} @as [session];
|
|
216
215
|
purge {Session {id? session.id}}
|
|
217
216
|
}
|
|
218
217
|
|
|
219
|
-
workflow DeleteRole {
|
|
218
|
+
@public workflow DeleteRole {
|
|
220
219
|
purge {UserRole {Role? DeleteRole.name}}
|
|
221
220
|
purge {Role {name? DeleteRole.name}}
|
|
222
221
|
}
|
|
223
222
|
|
|
224
|
-
workflow DeleteUserRole {
|
|
223
|
+
@public workflow DeleteUserRole {
|
|
225
224
|
purge {UserRole {User? DeleteUserRole.User, Role? DeleteUserRole.Role}}
|
|
226
225
|
}
|
|
227
226
|
|
|
228
|
-
workflow DeletePermission {
|
|
227
|
+
@public workflow DeletePermission {
|
|
229
228
|
purge {RolePermission {Permission? DeletePermission.id}}
|
|
230
229
|
purge {Permission {id? DeletePermission.id}}
|
|
231
230
|
}
|
|
232
231
|
|
|
233
|
-
workflow DeleteRolePermission {
|
|
232
|
+
@public workflow DeleteRolePermission {
|
|
234
233
|
purge {RolePermission {Role? DeleteRolePermission.Role, Permission? DeleteRolePermission.Permission}}
|
|
235
234
|
}
|
|
236
235
|
|
|
237
|
-
workflow UpdateRoleAssignment {
|
|
236
|
+
@public workflow UpdateRoleAssignment {
|
|
238
237
|
{User {id? UpdateRoleAssignment.userId}} @as [user]
|
|
239
238
|
{Role {name? UpdateRoleAssignment.roleName}} @as [role]
|
|
240
239
|
if (user and role) {
|
|
@@ -248,7 +247,7 @@ workflow UpdateRoleAssignment {
|
|
|
248
247
|
}
|
|
249
248
|
}
|
|
250
249
|
|
|
251
|
-
workflow UpdatePermissionAssignment {
|
|
250
|
+
@public workflow UpdatePermissionAssignment {
|
|
252
251
|
{Role {name? UpdatePermissionAssignment.roleName}} @as [role]
|
|
253
252
|
{Permission {id? UpdatePermissionAssignment.permissionId}} @as [permission]
|
|
254
253
|
if (role and permission) {
|
|
@@ -262,7 +261,7 @@ workflow UpdatePermissionAssignment {
|
|
|
262
261
|
}
|
|
263
262
|
}
|
|
264
263
|
|
|
265
|
-
workflow UpdatePermission {
|
|
264
|
+
@public workflow UpdatePermission {
|
|
266
265
|
if (UpdatePermission.resourceFqName and UpdatePermission.c != undefined and UpdatePermission.r != undefined and UpdatePermission.u != undefined and UpdatePermission.d != undefined) {
|
|
267
266
|
{Permission {id? UpdatePermission.id,
|
|
268
267
|
resourceFqName UpdatePermission.resourceFqName,
|
|
@@ -285,27 +284,27 @@ workflow UpdatePermission {
|
|
|
285
284
|
}
|
|
286
285
|
}
|
|
287
286
|
|
|
288
|
-
workflow signup {
|
|
287
|
+
@public workflow signup {
|
|
289
288
|
await Auth.signUpUser(signup.firstName, signup.lastName, signup.email, signup.password, signup.userData)
|
|
290
289
|
}
|
|
291
290
|
|
|
292
|
-
workflow confirmSignup {
|
|
291
|
+
@public workflow confirmSignup {
|
|
293
292
|
await Auth.confirmSignupUser(confirmSignup.email, confirmSignup.confirmationCode)
|
|
294
293
|
}
|
|
295
294
|
|
|
296
|
-
workflow resendConfirmationCode {
|
|
295
|
+
@public workflow resendConfirmationCode {
|
|
297
296
|
await Auth.resendConfirmationCodeUser(resendConfirmationCode.email)
|
|
298
297
|
}
|
|
299
298
|
|
|
300
|
-
workflow login {
|
|
299
|
+
@public workflow login {
|
|
301
300
|
await Auth.loginUser(login.email, login.password)
|
|
302
301
|
}
|
|
303
302
|
|
|
304
|
-
workflow forgotPassword {
|
|
303
|
+
@public workflow forgotPassword {
|
|
305
304
|
await Auth.forgotPasswordUser(forgotPassword.email)
|
|
306
305
|
}
|
|
307
306
|
|
|
308
|
-
workflow confirmForgotPassword {
|
|
307
|
+
@public workflow confirmForgotPassword {
|
|
309
308
|
await Auth.confirmForgotPasswordUser(
|
|
310
309
|
confirmForgotPassword.email,
|
|
311
310
|
confirmForgotPassword.confirmationCode,
|
|
@@ -313,32 +312,32 @@ workflow confirmForgotPassword {
|
|
|
313
312
|
)
|
|
314
313
|
}
|
|
315
314
|
|
|
316
|
-
workflow logout {
|
|
315
|
+
@public workflow logout {
|
|
317
316
|
await Auth.logoutUser()
|
|
318
317
|
}
|
|
319
318
|
|
|
320
|
-
workflow changePassword {
|
|
319
|
+
@public workflow changePassword {
|
|
321
320
|
await Auth.changePassword(changePassword.newPassword, changePassword.password)
|
|
322
321
|
}
|
|
323
322
|
|
|
324
|
-
workflow refreshToken {
|
|
323
|
+
@public workflow refreshToken {
|
|
325
324
|
await Auth.refreshUserToken(refreshToken.refreshToken)
|
|
326
325
|
}
|
|
327
326
|
|
|
328
|
-
workflow getUser {
|
|
327
|
+
@public workflow getUser {
|
|
329
328
|
await Auth.getUserInfo(getUser.userId)
|
|
330
329
|
}
|
|
331
330
|
|
|
332
|
-
workflow getUserByEmail {
|
|
331
|
+
@public workflow getUserByEmail {
|
|
333
332
|
await Auth.getUserInfoByEmail(getUserByEmail.email)
|
|
334
333
|
}
|
|
335
334
|
|
|
336
|
-
workflow inviteUser {
|
|
335
|
+
@public workflow inviteUser {
|
|
337
336
|
await Auth.inviteUser(inviteUser.email, inviteUser.firstName, inviteUser.lastName, inviteUser.userData)
|
|
338
337
|
}
|
|
339
338
|
|
|
340
339
|
|
|
341
|
-
workflow acceptInvitation {
|
|
340
|
+
@public workflow acceptInvitation {
|
|
342
341
|
await Auth.acceptInvitationUser(acceptInvitation.email, acceptInvitation.tempPassword, acceptInvitation.newPassword)
|
|
343
342
|
}
|
|
344
343
|
`;
|
package/src/runtime/util.ts
CHANGED
|
@@ -3,6 +3,9 @@ import {
|
|
|
3
3
|
AliasSpec,
|
|
4
4
|
CatchSpec,
|
|
5
5
|
ExtendsClause,
|
|
6
|
+
isLiteral,
|
|
7
|
+
MapEntry,
|
|
8
|
+
MapLiteral,
|
|
6
9
|
MetaDefinition,
|
|
7
10
|
PrePostTriggerDefinition,
|
|
8
11
|
RbacSpecDefinition,
|
|
@@ -161,6 +164,10 @@ export function splitRefs(s: string): string[] {
|
|
|
161
164
|
}
|
|
162
165
|
}
|
|
163
166
|
|
|
167
|
+
export function rootRef(s: string): string {
|
|
168
|
+
return splitRefs(s)[0];
|
|
169
|
+
}
|
|
170
|
+
|
|
164
171
|
export function runShellCommand(cmd: string, options?: any, continuation?: Function) {
|
|
165
172
|
if (!isNodeEnv) {
|
|
166
173
|
console.warn('Shell commands cannot be executed in non-Node.js environments');
|
|
@@ -535,3 +542,15 @@ export function trimQuotes(s: string): string {
|
|
|
535
542
|
}
|
|
536
543
|
return ss;
|
|
537
544
|
}
|
|
545
|
+
|
|
546
|
+
export function asStringLiteralsMap(mapLit: MapLiteral): Map<string, string> {
|
|
547
|
+
const result = new Map<string, string>();
|
|
548
|
+
mapLit.entries.forEach((me: MapEntry) => {
|
|
549
|
+
const k = me.key.str;
|
|
550
|
+
if (k && isLiteral(me.value)) {
|
|
551
|
+
const v = me.value.str || me.value.id || me.value.ref;
|
|
552
|
+
if (v) result.set(k, v);
|
|
553
|
+
}
|
|
554
|
+
});
|
|
555
|
+
return result;
|
|
556
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Monarch syntax highlighting for the agentlang language.
|
|
2
2
|
export default {
|
|
3
3
|
keywords: [
|
|
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','case','commitTransaction','contains','create','decision','delete','else','entity','error','event','extends','false','flow','for','if','import','in','like','module','not','not_found','onSubscription','or','purge','query','read','record','relationship','resolver','return','roles','rollbackTransaction','startTransaction','subscribe','true','update','upsert','where','workflow'
|
|
4
|
+
'@actions','@after','@as','@async','@before','@catch','@distinct','@enum','@expr','@from','@into','@meta','@oneof','@public','@rbac','@ref','@then','@upsert','@with_unique','agent','allow','and','await','between','case','commitTransaction','contains','create','decision','delete','directive','else','entity','error','event','extends','false','flow','for','glossaryEntry','if','import','in','like','module','not','not_found','onSubscription','or','purge','query','read','record','relationship','resolver','return','roles','rollbackTransaction','scenario','startTransaction','subscribe','true','update','upsert','where','workflow'
|
|
5
5
|
],
|
|
6
6
|
operators: [
|
|
7
7
|
'!=','*','+',',','-','-->','.','/',':',';','<','<=','<>','=','==','>','>=','?','@'
|