agentlang 0.0.3 → 0.0.4
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 +16 -47
- package/out/api/http.d.ts.map +1 -1
- package/out/api/http.js +12 -0
- package/out/api/http.js.map +1 -1
- package/out/cli/main.d.ts +1 -3
- package/out/cli/main.d.ts.map +1 -1
- package/out/cli/main.js +6 -12
- package/out/cli/main.js.map +1 -1
- package/out/language/generated/ast.d.ts +80 -18
- package/out/language/generated/ast.d.ts.map +1 -1
- package/out/language/generated/ast.js +119 -26
- package/out/language/generated/ast.js.map +1 -1
- package/out/language/generated/grammar.d.ts +1 -1
- package/out/language/generated/grammar.d.ts.map +1 -1
- package/out/language/generated/grammar.js +831 -238
- package/out/language/generated/grammar.js.map +1 -1
- package/out/language/generated/module.d.ts +1 -1
- package/out/language/generated/module.js +1 -1
- package/out/language/main.cjs +995 -331
- package/out/language/main.cjs.map +2 -2
- package/out/language/parser.js +13 -6
- package/out/language/parser.js.map +1 -1
- 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 +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 +540 -73
- package/out/runtime/auth/cognito.js.map +1 -1
- package/out/runtime/auth/defs.d.ts +3 -0
- package/out/runtime/auth/defs.d.ts.map +1 -1
- package/out/runtime/auth/defs.js +17 -1
- package/out/runtime/auth/defs.js.map +1 -1
- package/out/runtime/auth/interface.d.ts +6 -1
- package/out/runtime/auth/interface.d.ts.map +1 -1
- package/out/runtime/defs.d.ts +21 -0
- package/out/runtime/defs.d.ts.map +1 -1
- package/out/runtime/defs.js +35 -0
- package/out/runtime/defs.js.map +1 -1
- package/out/runtime/interpreter.d.ts.map +1 -1
- package/out/runtime/interpreter.js +45 -36
- package/out/runtime/interpreter.js.map +1 -1
- package/out/runtime/loader.d.ts +4 -2
- package/out/runtime/loader.d.ts.map +1 -1
- package/out/runtime/loader.js +148 -29
- package/out/runtime/loader.js.map +1 -1
- package/out/runtime/module.d.ts +48 -5
- package/out/runtime/module.d.ts.map +1 -1
- package/out/runtime/module.js +200 -9
- package/out/runtime/module.js.map +1 -1
- package/out/runtime/modules/ai.d.ts +7 -5
- package/out/runtime/modules/ai.d.ts.map +1 -1
- package/out/runtime/modules/ai.js +50 -24
- package/out/runtime/modules/ai.js.map +1 -1
- package/out/runtime/modules/auth.d.ts +17 -1
- package/out/runtime/modules/auth.d.ts.map +1 -1
- package/out/runtime/modules/auth.js +282 -30
- package/out/runtime/modules/auth.js.map +1 -1
- package/out/runtime/modules/core.d.ts.map +1 -1
- package/out/runtime/modules/core.js +3 -1
- package/out/runtime/modules/core.js.map +1 -1
- package/out/runtime/relgraph.d.ts.map +1 -1
- package/out/runtime/relgraph.js +2 -2
- package/out/runtime/relgraph.js.map +1 -1
- package/out/runtime/resolvers/interface.d.ts +37 -2
- package/out/runtime/resolvers/interface.d.ts.map +1 -1
- package/out/runtime/resolvers/interface.js +103 -5
- package/out/runtime/resolvers/interface.js.map +1 -1
- package/out/runtime/resolvers/registry.d.ts +3 -2
- package/out/runtime/resolvers/registry.d.ts.map +1 -1
- package/out/runtime/resolvers/registry.js +3 -0
- package/out/runtime/resolvers/registry.js.map +1 -1
- package/out/runtime/state.d.ts +31 -3
- package/out/runtime/state.d.ts.map +1 -1
- package/out/runtime/state.js +11 -1
- package/out/runtime/state.js.map +1 -1
- package/out/runtime/util.d.ts +4 -0
- 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 +2 -2
- package/out/syntaxes/agentlang.monarch.js.map +1 -1
- package/out/utils/http.d.ts +2 -0
- package/out/utils/http.d.ts.map +1 -0
- package/out/utils/http.js +5 -0
- package/out/utils/http.js.map +1 -0
- package/package.json +8 -6
- package/src/api/http.ts +15 -0
- package/src/cli/main.ts +6 -12
- package/src/language/agentlang.langium +31 -10
- package/src/language/generated/ast.ts +212 -44
- package/src/language/generated/grammar.ts +831 -238
- package/src/language/generated/module.ts +1 -1
- package/src/language/parser.ts +12 -8
- package/src/runtime/agents/common.ts +1 -1
- package/src/runtime/auth/cognito.ts +605 -74
- package/src/runtime/auth/defs.ts +17 -1
- package/src/runtime/auth/interface.ts +6 -1
- package/src/runtime/defs.ts +45 -0
- package/src/runtime/interpreter.ts +43 -34
- package/src/runtime/loader.ts +159 -30
- package/src/runtime/module.ts +243 -10
- package/src/runtime/modules/ai.ts +52 -28
- package/src/runtime/modules/auth.ts +330 -38
- package/src/runtime/modules/core.ts +3 -1
- package/src/runtime/relgraph.ts +2 -8
- package/src/runtime/resolvers/interface.ts +141 -6
- package/src/runtime/resolvers/registry.ts +5 -2
- package/src/runtime/state.ts +11 -1
- package/src/runtime/util.ts +17 -0
- package/src/syntaxes/agentlang.monarch.ts +2 -2
- package/src/utils/http.ts +5 -0
- package/src/index.ts +0 -29
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { Resolver } from './interface.js';
|
|
1
|
+
import { Resolver, setSubscriptionEvent } from './interface.js';
|
|
2
2
|
|
|
3
3
|
type MakeResolver = () => Resolver;
|
|
4
4
|
const resolverDb: Map<string, MakeResolver> = new Map<string, MakeResolver>();
|
|
5
5
|
const resolverPathMappings: Map<string, string> = new Map<string, string>();
|
|
6
6
|
|
|
7
|
-
export function registerResolver(name: string, r: MakeResolver) {
|
|
7
|
+
export function registerResolver(name: string, r: MakeResolver): string {
|
|
8
8
|
resolverDb.set(name, r);
|
|
9
|
+
return name;
|
|
9
10
|
}
|
|
10
11
|
|
|
11
12
|
export function setResolver(fqEntryName: string, resolverName: string) {
|
|
@@ -16,6 +17,8 @@ export function setResolver(fqEntryName: string, resolverName: string) {
|
|
|
16
17
|
}
|
|
17
18
|
}
|
|
18
19
|
|
|
20
|
+
export const setSubscription = setSubscriptionEvent;
|
|
21
|
+
|
|
19
22
|
export function getResolverNameForPath(fqEntryName: string): string | undefined {
|
|
20
23
|
return resolverPathMappings.get(fqEntryName);
|
|
21
24
|
}
|
package/src/runtime/state.ts
CHANGED
|
@@ -38,7 +38,17 @@ export const ConfigSchema = z.object({
|
|
|
38
38
|
enabled: z.boolean().default(false),
|
|
39
39
|
})
|
|
40
40
|
.optional(),
|
|
41
|
-
|
|
41
|
+
rbac: z
|
|
42
|
+
.object({
|
|
43
|
+
enabled: z.boolean().default(false),
|
|
44
|
+
roles: z.array(z.string()).optional(),
|
|
45
|
+
})
|
|
46
|
+
.optional(),
|
|
47
|
+
auth: z
|
|
48
|
+
.object({
|
|
49
|
+
enabled: z.boolean().default(false),
|
|
50
|
+
})
|
|
51
|
+
.optional(),
|
|
42
52
|
auditTrail: z
|
|
43
53
|
.object({
|
|
44
54
|
enabled: z.boolean().default(false),
|
package/src/runtime/util.ts
CHANGED
|
@@ -88,6 +88,14 @@ export async function invokeModuleFn(
|
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
+
export function getModuleFn(fqFnName: string): Function | undefined {
|
|
92
|
+
const refs: string[] = splitRefs(fqFnName);
|
|
93
|
+
const m = importedModules.get(refs[0]);
|
|
94
|
+
if (m != undefined) {
|
|
95
|
+
return m[refs[1]];
|
|
96
|
+
} else return undefined;
|
|
97
|
+
}
|
|
98
|
+
|
|
91
99
|
export function isNumber(x: any): boolean {
|
|
92
100
|
return typeof x === 'number';
|
|
93
101
|
}
|
|
@@ -111,6 +119,14 @@ function asString(s: MaybeString): string {
|
|
|
111
119
|
else return s;
|
|
112
120
|
}
|
|
113
121
|
|
|
122
|
+
export function restoreSpecialChars(s: string) {
|
|
123
|
+
return s.replaceAll('"e;', '"');
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export function escapeSpecialChars(s: string) {
|
|
127
|
+
return s.replaceAll('"', '"e;');
|
|
128
|
+
}
|
|
129
|
+
|
|
114
130
|
export class Path {
|
|
115
131
|
private moduleName: MaybeString;
|
|
116
132
|
private entryName: MaybeString;
|
|
@@ -256,6 +272,7 @@ export function arrayEquals(a: Array<any>, b: Array<any>) {
|
|
|
256
272
|
}
|
|
257
273
|
|
|
258
274
|
export const DefaultModuleName = 'agentlang';
|
|
275
|
+
export const DefaultModules = new Set();
|
|
259
276
|
|
|
260
277
|
export function makeCoreModuleName(n: string): string {
|
|
261
278
|
return DefaultModuleName + '_' + n;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Monarch syntax highlighting for the agentlang language.
|
|
2
2
|
export default {
|
|
3
3
|
keywords: [
|
|
4
|
-
'@after','@async','@before','@enum','@expr','@meta','@oneof','@rbac','@ref','@with_unique','allow','and','as','await','between','catch','contains','create','delete','else','entity','error','event','extends','false','for','if','import','in','into','like','module','not','not_found','or','purge','read','record','relationship','roles','true','update','upsert','where','workflow'
|
|
4
|
+
'@actions','@after','@async','@before','@enum','@expr','@meta','@oneof','@rbac','@ref','@upsert','@with_unique','agent','allow','and','as','await','between','catch','contains','create','delete','else','entity','error','event','extends','false','for','if','import','in','into','like','module','not','not_found','onSubscription','or','purge','query','read','record','relationship','resolver','roles','subscribe','true','update','upsert','where','workflow'
|
|
5
5
|
],
|
|
6
6
|
operators: [
|
|
7
7
|
'*','+',',','-','.','/',':',';','<','<=','<>','=','>','>=','?','@'
|
|
@@ -12,7 +12,7 @@ export default {
|
|
|
12
12
|
initial: [
|
|
13
13
|
{ regex: /(([_a-zA-Z][\w_]*)(\/([_a-zA-Z][\w_]*))?)/, action: { cases: { '@keywords': {"token":"keyword"}, '@default': {"token":"string"} }} },
|
|
14
14
|
{ regex: /[_a-zA-Z][\w_]*/, action: { cases: { '@keywords': {"token":"keyword"}, '@default': {"token":"string"} }} },
|
|
15
|
-
{ regex: /([
|
|
15
|
+
{ regex: /("(((\\([\s\S]))|((?!(((\\|")|\r)|\n))[\s\S]*?))|(\r?\n))*")/, action: {"token":"string"} },
|
|
16
16
|
{ regex: /-?[0-9]+/, action: {"token":"number"} },
|
|
17
17
|
{ include: '@whitespace' },
|
|
18
18
|
{ regex: /@symbols/, action: { cases: { '@operators': {"token":"operator"}, '@default': {"token":""} }} },
|
package/src/index.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
// Main exports for the agentlang runtime
|
|
2
|
-
export * from './runtime/defs.js';
|
|
3
|
-
export * from './runtime/module.js';
|
|
4
|
-
export * from './runtime/interpreter.js';
|
|
5
|
-
export * from './runtime/loader.js';
|
|
6
|
-
export * from './runtime/state.js';
|
|
7
|
-
export * from './runtime/util.js';
|
|
8
|
-
export * from './runtime/logger.js';
|
|
9
|
-
|
|
10
|
-
// Export auth interfaces
|
|
11
|
-
export * from './runtime/auth/defs.js';
|
|
12
|
-
export * from './runtime/auth/interface.js';
|
|
13
|
-
|
|
14
|
-
// Export agent interfaces
|
|
15
|
-
export * from './runtime/agents/common.js';
|
|
16
|
-
export * from './runtime/agents/provider.js';
|
|
17
|
-
export * from './runtime/agents/registry.js';
|
|
18
|
-
|
|
19
|
-
// Export resolver interfaces
|
|
20
|
-
export * from './runtime/resolvers/interface.js';
|
|
21
|
-
export * from './runtime/resolvers/registry.js';
|
|
22
|
-
|
|
23
|
-
// Export modules
|
|
24
|
-
export * from './runtime/modules/core.js';
|
|
25
|
-
export * from './runtime/modules/auth.js';
|
|
26
|
-
export * from './runtime/modules/ai.js';
|
|
27
|
-
|
|
28
|
-
// Export CLI utilities
|
|
29
|
-
export * from './cli/cli-util.js';
|