agentlang 0.9.0 → 0.9.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/language/generated/ast.d.ts +26 -14
- package/out/language/generated/ast.d.ts.map +1 -1
- package/out/language/generated/ast.js +23 -6
- 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 +400 -214
- package/out/language/generated/grammar.js.map +1 -1
- package/out/language/main.cjs +414 -218
- package/out/language/main.cjs.map +2 -2
- package/out/language/syntax.d.ts +6 -2
- package/out/language/syntax.d.ts.map +1 -1
- package/out/language/syntax.js +19 -6
- package/out/language/syntax.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 +6 -2
- package/out/runtime/agents/common.js.map +1 -1
- package/out/runtime/defs.d.ts +9 -7
- package/out/runtime/defs.d.ts.map +1 -1
- package/out/runtime/defs.js +11 -7
- package/out/runtime/defs.js.map +1 -1
- package/out/runtime/exec-graph.d.ts.map +1 -1
- package/out/runtime/exec-graph.js +32 -2
- package/out/runtime/exec-graph.js.map +1 -1
- package/out/runtime/interpreter.d.ts +4 -1
- package/out/runtime/interpreter.d.ts.map +1 -1
- package/out/runtime/interpreter.js +54 -8
- package/out/runtime/interpreter.js.map +1 -1
- package/out/runtime/mcpclient.d.ts +46 -0
- package/out/runtime/mcpclient.d.ts.map +1 -0
- package/out/runtime/mcpclient.js +457 -0
- package/out/runtime/mcpclient.js.map +1 -0
- package/out/runtime/module.d.ts +8 -1
- package/out/runtime/module.d.ts.map +1 -1
- package/out/runtime/module.js +66 -6
- package/out/runtime/module.js.map +1 -1
- package/out/runtime/modules/ai.d.ts.map +1 -1
- package/out/runtime/modules/ai.js +6 -20
- package/out/runtime/modules/ai.js.map +1 -1
- package/out/runtime/modules/auth.js +2 -2
- package/out/runtime/modules/core.d.ts.map +1 -1
- package/out/runtime/modules/core.js +6 -1
- package/out/runtime/modules/core.js.map +1 -1
- package/out/runtime/modules/mcp.d.ts +6 -0
- package/out/runtime/modules/mcp.d.ts.map +1 -0
- package/out/runtime/modules/mcp.js +43 -0
- package/out/runtime/modules/mcp.js.map +1 -0
- package/out/runtime/resolvers/sqldb/database.d.ts.map +1 -1
- package/out/runtime/resolvers/sqldb/database.js +3 -2
- package/out/runtime/resolvers/sqldb/database.js.map +1 -1
- package/out/syntaxes/agentlang.monarch.d.ts.map +1 -1
- package/out/syntaxes/agentlang.monarch.js +1 -0
- package/out/syntaxes/agentlang.monarch.js.map +1 -1
- package/package.json +3 -2
- package/src/language/agentlang.langium +10 -4
- package/src/language/generated/ast.ts +49 -19
- package/src/language/generated/grammar.ts +400 -214
- package/src/language/syntax.ts +24 -7
- package/src/runtime/agents/common.ts +6 -2
- package/src/runtime/defs.ts +5 -0
- package/src/runtime/exec-graph.ts +36 -1
- package/src/runtime/interpreter.ts +68 -7
- package/src/runtime/mcpclient.ts +542 -0
- package/src/runtime/module.ts +70 -7
- package/src/runtime/modules/ai.ts +6 -22
- package/src/runtime/modules/auth.ts +2 -2
- package/src/runtime/modules/core.ts +5 -1
- package/src/runtime/modules/mcp.ts +45 -0
- package/src/runtime/resolvers/sqldb/database.ts +3 -2
- package/src/syntaxes/agentlang.monarch.ts +1 -0
|
@@ -15,7 +15,6 @@ import {
|
|
|
15
15
|
parseAndEvaluateStatement,
|
|
16
16
|
} from '../interpreter.js';
|
|
17
17
|
import {
|
|
18
|
-
Agent,
|
|
19
18
|
asJSONSchema,
|
|
20
19
|
Decision,
|
|
21
20
|
fetchModule,
|
|
@@ -757,27 +756,12 @@ Only return a pure JSON object with no extra text, annotations etc.`;
|
|
|
757
756
|
if (entryName) {
|
|
758
757
|
const hasmod = slimModules.has(moduleName);
|
|
759
758
|
const defs = hasmod ? slimModules.get(moduleName) : new Array<string>();
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
if (entry) {
|
|
767
|
-
const s =
|
|
768
|
-
entry instanceof Record
|
|
769
|
-
? (entry as Record).toString_(true, true)
|
|
770
|
-
: entry.toString();
|
|
771
|
-
// Add full qualified name comment so LLM knows how to reference it
|
|
772
|
-
const fqName = `${moduleName}/${entryName}`;
|
|
773
|
-
defs?.push(
|
|
774
|
-
`# Tool: ${fqName}\n# Use as: {${fqName} {...}} or {${fqName}? {...}}\n${s}`
|
|
775
|
-
);
|
|
776
|
-
if (!hasmod && defs) {
|
|
777
|
-
slimModules.set(moduleName, defs);
|
|
778
|
-
}
|
|
779
|
-
} else {
|
|
780
|
-
logger.warn(`Tool entry '${entryName}' not found in module '${moduleName}'`);
|
|
759
|
+
const entry = m.getEntry(entryName);
|
|
760
|
+
const s =
|
|
761
|
+
entry instanceof Record ? (entry as Record).toString_(true, true) : entry.toString();
|
|
762
|
+
defs?.push(s);
|
|
763
|
+
if (!hasmod && defs) {
|
|
764
|
+
slimModules.set(moduleName, defs);
|
|
781
765
|
}
|
|
782
766
|
} else {
|
|
783
767
|
tooldefs.push(fetchModule(moduleName).toString());
|
|
@@ -337,13 +337,13 @@ entity Session {
|
|
|
337
337
|
{Role {name? UpdatePermissionAssignment.roleName}} @as [role]
|
|
338
338
|
{Permission {id? UpdatePermissionAssignment.permissionId}} @as [permission]
|
|
339
339
|
if (role and permission) {
|
|
340
|
-
{RolePermission {__path__? UpdatePermissionAssignment.rolePermission, Permission
|
|
340
|
+
{RolePermission {__path__? UpdatePermissionAssignment.rolePermission, Permission permission.__path__, Role role.__path__}}
|
|
341
341
|
}
|
|
342
342
|
else if (role) {
|
|
343
343
|
{RolePermission {__path__? UpdatePermissionAssignment.rolePermission, Role role.__path__}}
|
|
344
344
|
}
|
|
345
345
|
else if (permission) {
|
|
346
|
-
{RolePermission {__path__? UpdatePermissionAssignment.rolePermission, Permission
|
|
346
|
+
{RolePermission {__path__? UpdatePermissionAssignment.rolePermission, Permission permission.__path__}}
|
|
347
347
|
}
|
|
348
348
|
}
|
|
349
349
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { default as ai } from './ai.js';
|
|
2
2
|
import { default as auth } from './auth.js';
|
|
3
3
|
import { default as files } from './files.js';
|
|
4
|
+
import { default as mcp } from './mcp.js';
|
|
4
5
|
import {
|
|
5
6
|
DefaultModuleName,
|
|
6
7
|
DefaultModules,
|
|
@@ -39,7 +40,7 @@ import {
|
|
|
39
40
|
} from '../defs.js';
|
|
40
41
|
import { getMonitor, getMonitorsForEvent, Monitor } from '../monitor.js';
|
|
41
42
|
import { registerResolver, setResolver } from '../resolvers/registry.js';
|
|
42
|
-
import { base64Encode } from '../../utils/runtime.js';
|
|
43
|
+
import { base64Encode, isNodeEnv } from '../../utils/runtime.js';
|
|
43
44
|
|
|
44
45
|
const CoreModuleDefinition = `module ${DefaultModuleName}
|
|
45
46
|
|
|
@@ -180,14 +181,17 @@ export function registerCoreModules() {
|
|
|
180
181
|
DefaultModules.add(DefaultModuleName);
|
|
181
182
|
CoreModules.push(CoreModuleDefinition);
|
|
182
183
|
|
|
184
|
+
const mcpn = makeCoreModuleName('mcp');
|
|
183
185
|
// Map of module definitions to their names for proper DefaultModules registration
|
|
184
186
|
const coreModuleInfo: Array<{ def: string; name: string }> = [
|
|
185
187
|
{ def: auth, name: makeCoreModuleName('auth') },
|
|
186
188
|
{ def: ai, name: makeCoreModuleName('ai') },
|
|
187
189
|
{ def: files, name: makeCoreModuleName('files') },
|
|
190
|
+
{ def: mcp, name: mcpn },
|
|
188
191
|
];
|
|
189
192
|
|
|
190
193
|
coreModuleInfo.forEach(({ def, name }) => {
|
|
194
|
+
if (!isNodeEnv && name == mcpn) return;
|
|
191
195
|
CoreModules.push(def);
|
|
192
196
|
// Add module NAME (not definition) to DefaultModules so flushAllModules() doesn't remove core modules
|
|
193
197
|
DefaultModules.add(name);
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { listClientTools } from '../mcpclient.js';
|
|
2
|
+
import { makeCoreModuleName } from '../util.js';
|
|
3
|
+
|
|
4
|
+
export const CoreMcpModuleName = makeCoreModuleName('mcp');
|
|
5
|
+
|
|
6
|
+
export default `module ${CoreMcpModuleName}
|
|
7
|
+
|
|
8
|
+
import "./modules/mcp.js" @as mcp
|
|
9
|
+
|
|
10
|
+
entity Client {
|
|
11
|
+
name String @id,
|
|
12
|
+
version String @default("1.0.0"),
|
|
13
|
+
serverUrl String,
|
|
14
|
+
clientId String @optional,
|
|
15
|
+
clientSecret String @optional,
|
|
16
|
+
bearerToken String @optional
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
@public event listTools {
|
|
20
|
+
clientName String
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
workflow listTools {
|
|
24
|
+
{Client {name? listTools.clientName}} @as [client];
|
|
25
|
+
await mcp.listClientTools_(client)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
@public event createClient {
|
|
29
|
+
name String @id,
|
|
30
|
+
version String @default("1.0.0"),
|
|
31
|
+
serverUrl String,
|
|
32
|
+
clientId String @optional,
|
|
33
|
+
clientSecret String @optional,
|
|
34
|
+
bearerToken String @optional
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
workflow createClient {
|
|
38
|
+
purge {Client {name? createClient.name}}
|
|
39
|
+
{Client {}, @from createClient} @as client
|
|
40
|
+
{listTools {clientName client.name}}
|
|
41
|
+
client
|
|
42
|
+
}
|
|
43
|
+
`;
|
|
44
|
+
|
|
45
|
+
export const listClientTools_ = listClientTools;
|
|
@@ -1081,10 +1081,11 @@ export async function getManyByJoin(
|
|
|
1081
1081
|
if (querySpec.intoSpec === undefined) {
|
|
1082
1082
|
throw new Error('SELECT-INTO pattern is missing');
|
|
1083
1083
|
}
|
|
1084
|
-
const intos = intoSpecToSql(querySpec.intoSpec);
|
|
1084
|
+
const intos = querySpec.intoSpec.size > 0 ? intoSpecToSql(querySpec.intoSpec) : '';
|
|
1085
|
+
const intos_sep = intos.length === 0 ? '' : ',';
|
|
1085
1086
|
const aggrs =
|
|
1086
1087
|
querySpec.aggregates !== undefined ? intoSpecToSql(querySpec.aggregates) : undefined;
|
|
1087
|
-
const cols = aggrs ? `${intos}
|
|
1088
|
+
const cols = aggrs ? `${intos} ${intos_sep} ${aggrs}` : intos;
|
|
1088
1089
|
let sql = `SELECT ${querySpec.distinct ? 'DISTINCT' : ''} ${cols} FROM ${tableName} ${joinSql.join('\n')} WHERE ${queryStr}`;
|
|
1089
1090
|
if (querySpec.groupBy !== undefined) {
|
|
1090
1091
|
sql = `${sql} GROUP BY ${querySpec.groupBy.join(', ')}`;
|
|
@@ -13,6 +13,7 @@ export default {
|
|
|
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
15
|
{ regex: /("(((\\([\s\S]))|((?!(((\\|")|\r)|\n))[\s\S]*?))|(\r?\n))*")/, action: {"token":"string"} },
|
|
16
|
+
{ regex: /(`(((\\([\s\S]))|((?!(((\\|`)|\r)|\n))[\s\S]*?))|(\r?\n))*`)/, action: {"token":"string"} },
|
|
16
17
|
{ regex: /-?[0-9]+/, action: {"token":"number"} },
|
|
17
18
|
{ include: '@whitespace' },
|
|
18
19
|
{ regex: /@symbols/, action: { cases: { '@operators': {"token":"operator"}, '@default': {"token":""} }} },
|