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.
Files changed (113) hide show
  1. package/README.md +16 -47
  2. package/out/api/http.d.ts.map +1 -1
  3. package/out/api/http.js +12 -0
  4. package/out/api/http.js.map +1 -1
  5. package/out/cli/main.d.ts +1 -3
  6. package/out/cli/main.d.ts.map +1 -1
  7. package/out/cli/main.js +6 -12
  8. package/out/cli/main.js.map +1 -1
  9. package/out/language/generated/ast.d.ts +80 -18
  10. package/out/language/generated/ast.d.ts.map +1 -1
  11. package/out/language/generated/ast.js +119 -26
  12. package/out/language/generated/ast.js.map +1 -1
  13. package/out/language/generated/grammar.d.ts +1 -1
  14. package/out/language/generated/grammar.d.ts.map +1 -1
  15. package/out/language/generated/grammar.js +831 -238
  16. package/out/language/generated/grammar.js.map +1 -1
  17. package/out/language/generated/module.d.ts +1 -1
  18. package/out/language/generated/module.js +1 -1
  19. package/out/language/main.cjs +995 -331
  20. package/out/language/main.cjs.map +2 -2
  21. package/out/language/parser.js +13 -6
  22. package/out/language/parser.js.map +1 -1
  23. package/out/runtime/agents/common.d.ts +1 -1
  24. package/out/runtime/agents/common.d.ts.map +1 -1
  25. package/out/runtime/agents/common.js +1 -1
  26. package/out/runtime/auth/cognito.d.ts +4 -1
  27. package/out/runtime/auth/cognito.d.ts.map +1 -1
  28. package/out/runtime/auth/cognito.js +540 -73
  29. package/out/runtime/auth/cognito.js.map +1 -1
  30. package/out/runtime/auth/defs.d.ts +3 -0
  31. package/out/runtime/auth/defs.d.ts.map +1 -1
  32. package/out/runtime/auth/defs.js +17 -1
  33. package/out/runtime/auth/defs.js.map +1 -1
  34. package/out/runtime/auth/interface.d.ts +6 -1
  35. package/out/runtime/auth/interface.d.ts.map +1 -1
  36. package/out/runtime/defs.d.ts +21 -0
  37. package/out/runtime/defs.d.ts.map +1 -1
  38. package/out/runtime/defs.js +35 -0
  39. package/out/runtime/defs.js.map +1 -1
  40. package/out/runtime/interpreter.d.ts.map +1 -1
  41. package/out/runtime/interpreter.js +45 -36
  42. package/out/runtime/interpreter.js.map +1 -1
  43. package/out/runtime/loader.d.ts +4 -2
  44. package/out/runtime/loader.d.ts.map +1 -1
  45. package/out/runtime/loader.js +148 -29
  46. package/out/runtime/loader.js.map +1 -1
  47. package/out/runtime/module.d.ts +48 -5
  48. package/out/runtime/module.d.ts.map +1 -1
  49. package/out/runtime/module.js +200 -9
  50. package/out/runtime/module.js.map +1 -1
  51. package/out/runtime/modules/ai.d.ts +7 -5
  52. package/out/runtime/modules/ai.d.ts.map +1 -1
  53. package/out/runtime/modules/ai.js +50 -24
  54. package/out/runtime/modules/ai.js.map +1 -1
  55. package/out/runtime/modules/auth.d.ts +17 -1
  56. package/out/runtime/modules/auth.d.ts.map +1 -1
  57. package/out/runtime/modules/auth.js +282 -30
  58. package/out/runtime/modules/auth.js.map +1 -1
  59. package/out/runtime/modules/core.d.ts.map +1 -1
  60. package/out/runtime/modules/core.js +3 -1
  61. package/out/runtime/modules/core.js.map +1 -1
  62. package/out/runtime/relgraph.d.ts.map +1 -1
  63. package/out/runtime/relgraph.js +2 -2
  64. package/out/runtime/relgraph.js.map +1 -1
  65. package/out/runtime/resolvers/interface.d.ts +37 -2
  66. package/out/runtime/resolvers/interface.d.ts.map +1 -1
  67. package/out/runtime/resolvers/interface.js +103 -5
  68. package/out/runtime/resolvers/interface.js.map +1 -1
  69. package/out/runtime/resolvers/registry.d.ts +3 -2
  70. package/out/runtime/resolvers/registry.d.ts.map +1 -1
  71. package/out/runtime/resolvers/registry.js +3 -0
  72. package/out/runtime/resolvers/registry.js.map +1 -1
  73. package/out/runtime/state.d.ts +31 -3
  74. package/out/runtime/state.d.ts.map +1 -1
  75. package/out/runtime/state.js +11 -1
  76. package/out/runtime/state.js.map +1 -1
  77. package/out/runtime/util.d.ts +4 -0
  78. package/out/runtime/util.d.ts.map +1 -1
  79. package/out/runtime/util.js +16 -0
  80. package/out/runtime/util.js.map +1 -1
  81. package/out/syntaxes/agentlang.monarch.js +2 -2
  82. package/out/syntaxes/agentlang.monarch.js.map +1 -1
  83. package/out/utils/http.d.ts +2 -0
  84. package/out/utils/http.d.ts.map +1 -0
  85. package/out/utils/http.js +5 -0
  86. package/out/utils/http.js.map +1 -0
  87. package/package.json +8 -6
  88. package/src/api/http.ts +15 -0
  89. package/src/cli/main.ts +6 -12
  90. package/src/language/agentlang.langium +31 -10
  91. package/src/language/generated/ast.ts +212 -44
  92. package/src/language/generated/grammar.ts +831 -238
  93. package/src/language/generated/module.ts +1 -1
  94. package/src/language/parser.ts +12 -8
  95. package/src/runtime/agents/common.ts +1 -1
  96. package/src/runtime/auth/cognito.ts +605 -74
  97. package/src/runtime/auth/defs.ts +17 -1
  98. package/src/runtime/auth/interface.ts +6 -1
  99. package/src/runtime/defs.ts +45 -0
  100. package/src/runtime/interpreter.ts +43 -34
  101. package/src/runtime/loader.ts +159 -30
  102. package/src/runtime/module.ts +243 -10
  103. package/src/runtime/modules/ai.ts +52 -28
  104. package/src/runtime/modules/auth.ts +330 -38
  105. package/src/runtime/modules/core.ts +3 -1
  106. package/src/runtime/relgraph.ts +2 -8
  107. package/src/runtime/resolvers/interface.ts +141 -6
  108. package/src/runtime/resolvers/registry.ts +5 -2
  109. package/src/runtime/state.ts +11 -1
  110. package/src/runtime/util.ts +17 -0
  111. package/src/syntaxes/agentlang.monarch.ts +2 -2
  112. package/src/utils/http.ts +5 -0
  113. 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
  }
@@ -38,7 +38,17 @@ export const ConfigSchema = z.object({
38
38
  enabled: z.boolean().default(false),
39
39
  })
40
40
  .optional(),
41
- rbacEnabled: z.boolean().optional(),
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),
@@ -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('&quote;', '"');
124
+ }
125
+
126
+ export function escapeSpecialChars(s: string) {
127
+ return s.replaceAll('"', '&quote;');
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: /(["'])((\\{2})*|(.*?[^\\](\\{2})*))\1/, action: {"token":"string"} },
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":""} }} },
@@ -0,0 +1,5 @@
1
+ import { Buffer } from 'buffer';
2
+
3
+ export function encodeForBasicAuth(username: string, password: string): string {
4
+ return Buffer.from(`${username}:${password}`).toString('base64');
5
+ }
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';