agentlang 0.7.0 → 0.7.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/out/api/http.d.ts.map +1 -1
- package/out/api/http.js +46 -26
- package/out/api/http.js.map +1 -1
- package/out/cli/main.d.ts +1 -0
- package/out/cli/main.d.ts.map +1 -1
- package/out/cli/main.js +15 -2
- package/out/cli/main.js.map +1 -1
- package/out/language/generated/ast.d.ts +15 -6
- package/out/language/generated/ast.d.ts.map +1 -1
- package/out/language/generated/ast.js +16 -2
- 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 +215 -164
- package/out/language/generated/grammar.js.map +1 -1
- package/out/language/main.cjs +227 -166
- package/out/language/main.cjs.map +2 -2
- package/out/runtime/defs.d.ts +16 -1
- package/out/runtime/defs.d.ts.map +1 -1
- package/out/runtime/defs.js +29 -1
- package/out/runtime/defs.js.map +1 -1
- package/out/runtime/exec-graph.d.ts.map +1 -1
- package/out/runtime/exec-graph.js +8 -0
- package/out/runtime/exec-graph.js.map +1 -1
- package/out/runtime/interpreter.d.ts +2 -1
- package/out/runtime/interpreter.d.ts.map +1 -1
- package/out/runtime/interpreter.js +10 -0
- package/out/runtime/interpreter.js.map +1 -1
- package/out/runtime/jsmodules.d.ts +8 -0
- package/out/runtime/jsmodules.d.ts.map +1 -1
- package/out/runtime/jsmodules.js +139 -22
- package/out/runtime/jsmodules.js.map +1 -1
- package/out/runtime/loader.d.ts +1 -0
- package/out/runtime/loader.d.ts.map +1 -1
- package/out/runtime/loader.js +9 -2
- package/out/runtime/loader.js.map +1 -1
- package/out/runtime/module-transform.d.ts +77 -0
- package/out/runtime/module-transform.d.ts.map +1 -0
- package/out/runtime/module-transform.js +201 -0
- package/out/runtime/module-transform.js.map +1 -0
- package/out/runtime/modules/ai.d.ts.map +1 -1
- package/out/runtime/modules/ai.js +18 -6
- package/out/runtime/modules/ai.js.map +1 -1
- package/out/runtime/modules/core.d.ts +5 -0
- package/out/runtime/modules/core.d.ts.map +1 -1
- package/out/runtime/modules/core.js +58 -6
- package/out/runtime/modules/core.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 +51 -25
- package/src/cli/main.ts +20 -0
- package/src/language/agentlang.langium +3 -1
- package/src/language/generated/ast.ts +32 -8
- package/src/language/generated/grammar.ts +215 -164
- package/src/runtime/defs.ts +47 -0
- package/src/runtime/exec-graph.ts +13 -0
- package/src/runtime/interpreter.ts +12 -0
- package/src/runtime/jsmodules.ts +189 -22
- package/src/runtime/loader.ts +10 -2
- package/src/runtime/module-transform.ts +277 -0
- package/src/runtime/modules/ai.ts +20 -6
- package/src/runtime/modules/core.ts +80 -5
- package/src/syntaxes/agentlang.monarch.ts +1 -1
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
parseAndEvaluateStatement,
|
|
16
16
|
} from '../interpreter.js';
|
|
17
17
|
import {
|
|
18
|
+
Agent,
|
|
18
19
|
asJSONSchema,
|
|
19
20
|
Decision,
|
|
20
21
|
fetchModule,
|
|
@@ -663,12 +664,25 @@ Only return a pure JSON object with no extra text, annotations etc.`;
|
|
|
663
664
|
if (entryName) {
|
|
664
665
|
const hasmod = slimModules.has(moduleName);
|
|
665
666
|
const defs = hasmod ? slimModules.get(moduleName) : new Array<string>();
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
667
|
+
// Try to get entry directly first, then try as an agent (agents have _agent suffix)
|
|
668
|
+
let entry = m.getEntrySafe(entryName);
|
|
669
|
+
if (!entry) {
|
|
670
|
+
// Try with agent suffix - agents are stored with escaped names
|
|
671
|
+
entry = m.getEntrySafe(Agent.EscapeName(entryName));
|
|
672
|
+
}
|
|
673
|
+
if (entry) {
|
|
674
|
+
const s =
|
|
675
|
+
entry instanceof Record ? (entry as Record).toString_(true) : entry.toString();
|
|
676
|
+
// Add full qualified name comment so LLM knows how to reference it
|
|
677
|
+
const fqName = `${moduleName}/${entryName}`;
|
|
678
|
+
defs?.push(
|
|
679
|
+
`# Tool: ${fqName}\n# Use as: {${fqName} {...}} or {${fqName}? {...}}\n${s}`
|
|
680
|
+
);
|
|
681
|
+
if (!hasmod && defs) {
|
|
682
|
+
slimModules.set(moduleName, defs);
|
|
683
|
+
}
|
|
684
|
+
} else {
|
|
685
|
+
logger.warn(`Tool entry '${entryName}' not found in module '${moduleName}'`);
|
|
672
686
|
}
|
|
673
687
|
} else {
|
|
674
688
|
tooldefs.push(fetchModule(moduleName).toString());
|
|
@@ -7,8 +7,17 @@ import {
|
|
|
7
7
|
escapeSpecialChars,
|
|
8
8
|
isString,
|
|
9
9
|
restoreSpecialChars,
|
|
10
|
+
makeCoreModuleName,
|
|
10
11
|
} from '../util.js';
|
|
11
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
fetchModule,
|
|
14
|
+
Instance,
|
|
15
|
+
isInstanceOfType,
|
|
16
|
+
isModule,
|
|
17
|
+
makeInstance,
|
|
18
|
+
newInstanceAttributes,
|
|
19
|
+
removeModule,
|
|
20
|
+
} from '../module.js';
|
|
12
21
|
import {
|
|
13
22
|
Environment,
|
|
14
23
|
evaluate,
|
|
@@ -20,7 +29,12 @@ import { logger } from '../logger.js';
|
|
|
20
29
|
import { Statement } from '../../language/generated/ast.js';
|
|
21
30
|
import { parseModule, parseStatements } from '../../language/parser.js';
|
|
22
31
|
import { Resolver } from '../resolvers/interface.js';
|
|
23
|
-
import {
|
|
32
|
+
import {
|
|
33
|
+
FlowSuspensionTag,
|
|
34
|
+
ForceReadPermFlag,
|
|
35
|
+
InternDynamicModule,
|
|
36
|
+
PathAttributeName,
|
|
37
|
+
} from '../defs.js';
|
|
24
38
|
import { getMonitor, getMonitorsForEvent, Monitor } from '../monitor.js';
|
|
25
39
|
|
|
26
40
|
const CoreModuleDefinition = `module ${DefaultModuleName}
|
|
@@ -127,6 +141,18 @@ workflow validateModule {
|
|
|
127
141
|
await Core.validateModule(validateModule.data)
|
|
128
142
|
}
|
|
129
143
|
|
|
144
|
+
entity Module {
|
|
145
|
+
name String @id,
|
|
146
|
+
definition String
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
resolver moduleResolver [agentlang/Module] {
|
|
150
|
+
create Core.createModule,
|
|
151
|
+
update Core.updateModule,
|
|
152
|
+
delete Core.deleteModule,
|
|
153
|
+
query Core.getModule
|
|
154
|
+
}
|
|
155
|
+
|
|
130
156
|
entity Migration {
|
|
131
157
|
appVersion String @id,
|
|
132
158
|
ups String @optional,
|
|
@@ -139,9 +165,18 @@ export const CoreModules: string[] = [];
|
|
|
139
165
|
export function registerCoreModules() {
|
|
140
166
|
DefaultModules.add(DefaultModuleName);
|
|
141
167
|
CoreModules.push(CoreModuleDefinition);
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
168
|
+
|
|
169
|
+
// Map of module definitions to their names for proper DefaultModules registration
|
|
170
|
+
const coreModuleInfo: Array<{ def: string; name: string }> = [
|
|
171
|
+
{ def: auth, name: makeCoreModuleName('auth') },
|
|
172
|
+
{ def: ai, name: makeCoreModuleName('ai') },
|
|
173
|
+
{ def: files, name: makeCoreModuleName('files') },
|
|
174
|
+
];
|
|
175
|
+
|
|
176
|
+
coreModuleInfo.forEach(({ def, name }) => {
|
|
177
|
+
CoreModules.push(def);
|
|
178
|
+
// Add module NAME (not definition) to DefaultModules so flushAllModules() doesn't remove core modules
|
|
179
|
+
DefaultModules.add(name);
|
|
145
180
|
});
|
|
146
181
|
}
|
|
147
182
|
|
|
@@ -417,6 +452,46 @@ export async function validateModule(moduleDef: any): Promise<Instance> {
|
|
|
417
452
|
}
|
|
418
453
|
}
|
|
419
454
|
|
|
455
|
+
export async function internModuleHelper(
|
|
456
|
+
name: string,
|
|
457
|
+
definition: string
|
|
458
|
+
): Promise<string | undefined> {
|
|
459
|
+
if (InternDynamicModule !== undefined) {
|
|
460
|
+
return await InternDynamicModule(name, definition);
|
|
461
|
+
} else {
|
|
462
|
+
return undefined;
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
export async function createModule(_: Resolver, inst: Instance) {
|
|
467
|
+
await internModuleHelper(inst.lookup('name'), inst.lookup('definition'));
|
|
468
|
+
return inst;
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
export async function updateModule(r: Resolver, inst: Instance) {
|
|
472
|
+
return await createModule(r, inst);
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
export async function deleteModule(_: Resolver, inst: Instance) {
|
|
476
|
+
removeModule(inst.lookup('name'));
|
|
477
|
+
return inst;
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
export async function getModule(_: Resolver, inst: Instance) {
|
|
481
|
+
const p = inst.lookupQueryVal(PathAttributeName);
|
|
482
|
+
if (p !== undefined) {
|
|
483
|
+
const idx = p.lastIndexOf('/');
|
|
484
|
+
const n = p.substring(idx + 1);
|
|
485
|
+
if (isModule(n)) {
|
|
486
|
+
const m = fetchModule(n);
|
|
487
|
+
const defn = inst.lookup('definition') || m.toString();
|
|
488
|
+
const attrs = newInstanceAttributes().set('name', n).set('definition', defn);
|
|
489
|
+
return [makeInstance('agentlang', 'Module', attrs)];
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
return null;
|
|
493
|
+
}
|
|
494
|
+
|
|
420
495
|
const SqlSep = ';\n\n';
|
|
421
496
|
|
|
422
497
|
export async function saveMigration(
|
|
@@ -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','@full_join','@inner_join','@into','@join','@left_join','@meta','@oneof','@public','@rbac','@ref','@right_join','@then','@upsert','@with_unique','agent','agentlang/retry','allow','and','attempts','await','backoff','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'
|
|
4
|
+
'@actions','@after','@as','@async','@before','@catch','@distinct','@enum','@expr','@from','@full_join','@inner_join','@into','@join','@left_join','@meta','@oneof','@public','@rbac','@ref','@right_join','@then','@upsert','@with_unique','agent','agentlang/retry','allow','and','attempts','await','backoff','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','throw','true','update','upsert','where','workflow'
|
|
5
5
|
],
|
|
6
6
|
operators: [
|
|
7
7
|
'!=','*','+',',','-','-->','.','/',':',';','<','<=','<>','=','==','>','>=','?','@'
|