agentlang 0.9.0 → 0.9.1
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 +14 -5
- package/out/language/generated/ast.d.ts.map +1 -1
- package/out/language/generated/ast.js +17 -4
- 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 +248 -213
- package/out/language/generated/grammar.js.map +1 -1
- package/out/language/main.cjs +262 -217
- 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/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/package.json +3 -2
- package/src/language/agentlang.langium +5 -3
- package/src/language/generated/ast.ts +32 -9
- package/src/language/generated/grammar.ts +248 -213
- 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/core.ts +5 -1
- package/src/runtime/modules/mcp.ts +45 -0
- package/src/runtime/resolvers/sqldb/database.ts +3 -2
package/out/runtime/module.js
CHANGED
|
@@ -41,6 +41,7 @@ function normalizePropertyNames(props) {
|
|
|
41
41
|
}
|
|
42
42
|
const SystemAttributeProperty = 'system-attribute';
|
|
43
43
|
const SystemDefinedEvent = 'system-event';
|
|
44
|
+
const McpToolEvent = 'mcp-tool';
|
|
44
45
|
function asSystemAttribute(attrSpec) {
|
|
45
46
|
const props = attrSpec.properties ? attrSpec.properties : new Map();
|
|
46
47
|
props.set(SystemAttributeProperty, true);
|
|
@@ -1054,6 +1055,10 @@ export class Event extends Record {
|
|
|
1054
1055
|
var _a;
|
|
1055
1056
|
return ((_a = this.meta) === null || _a === void 0 ? void 0 : _a.get(SystemDefinedEvent)) === 'true';
|
|
1056
1057
|
}
|
|
1058
|
+
isMcpTool() {
|
|
1059
|
+
var _a;
|
|
1060
|
+
return ((_a = this.meta) === null || _a === void 0 ? void 0 : _a.get(McpToolEvent)) === 'true';
|
|
1061
|
+
}
|
|
1057
1062
|
}
|
|
1058
1063
|
var RelType;
|
|
1059
1064
|
(function (RelType) {
|
|
@@ -1412,6 +1417,21 @@ export class Workflow extends ModuleEntry {
|
|
|
1412
1417
|
return s.concat('\n}');
|
|
1413
1418
|
}
|
|
1414
1419
|
}
|
|
1420
|
+
function asFlowGraphEdge(stmt) {
|
|
1421
|
+
var _a;
|
|
1422
|
+
if (stmt === undefined) {
|
|
1423
|
+
return {
|
|
1424
|
+
rep: '',
|
|
1425
|
+
label: '',
|
|
1426
|
+
};
|
|
1427
|
+
}
|
|
1428
|
+
else {
|
|
1429
|
+
return {
|
|
1430
|
+
rep: ((_a = stmt.$cstNode) === null || _a === void 0 ? void 0 : _a.text) || '',
|
|
1431
|
+
label: statementLabel(stmt),
|
|
1432
|
+
};
|
|
1433
|
+
}
|
|
1434
|
+
}
|
|
1415
1435
|
function splitFlowSteps(flow) {
|
|
1416
1436
|
var _a;
|
|
1417
1437
|
const steps = new Array();
|
|
@@ -1458,7 +1478,7 @@ export class Flow extends ModuleEntry {
|
|
|
1458
1478
|
});
|
|
1459
1479
|
if (orig) {
|
|
1460
1480
|
const nxs = orig.next;
|
|
1461
|
-
nxs === null || nxs === void 0 ? void 0 : nxs.push(fp.next);
|
|
1481
|
+
nxs === null || nxs === void 0 ? void 0 : nxs.push(asFlowGraphEdge(fp.next));
|
|
1462
1482
|
const conds = orig.on;
|
|
1463
1483
|
conds === null || conds === void 0 ? void 0 : conds.push(fp.condition);
|
|
1464
1484
|
}
|
|
@@ -1467,7 +1487,7 @@ export class Flow extends ModuleEntry {
|
|
|
1467
1487
|
label: fp.first,
|
|
1468
1488
|
type: 'condition',
|
|
1469
1489
|
on: [fp.condition],
|
|
1470
|
-
next: [fp.next],
|
|
1490
|
+
next: [asFlowGraphEdge(fp.next)],
|
|
1471
1491
|
});
|
|
1472
1492
|
}
|
|
1473
1493
|
}
|
|
@@ -1475,7 +1495,7 @@ export class Flow extends ModuleEntry {
|
|
|
1475
1495
|
result.push({
|
|
1476
1496
|
label: fp.first,
|
|
1477
1497
|
type: 'action',
|
|
1478
|
-
next: [fp.next],
|
|
1498
|
+
next: [asFlowGraphEdge(fp.next)],
|
|
1479
1499
|
});
|
|
1480
1500
|
}
|
|
1481
1501
|
}
|
|
@@ -1549,6 +1569,32 @@ export class GlossaryEntry extends ModuleEntry {
|
|
|
1549
1569
|
return `glossaryEntry ${this.name} \n{\n${ss.join(',\n')}\n}`;
|
|
1550
1570
|
}
|
|
1551
1571
|
}
|
|
1572
|
+
function statementLabel(stmt) {
|
|
1573
|
+
var _a, _b;
|
|
1574
|
+
if (stmt === undefined)
|
|
1575
|
+
return '';
|
|
1576
|
+
let lbl = undefined;
|
|
1577
|
+
if (isLiteral(stmt.pattern.expr)) {
|
|
1578
|
+
lbl = stmt.pattern.expr.id || stmt.pattern.expr.ref || stmt.pattern.expr.str;
|
|
1579
|
+
}
|
|
1580
|
+
if (lbl !== undefined)
|
|
1581
|
+
return lbl;
|
|
1582
|
+
if (stmt.hints.length > 0) {
|
|
1583
|
+
for (let i = 0; i < stmt.hints.length; ++i) {
|
|
1584
|
+
const rh = stmt.hints[i];
|
|
1585
|
+
if ((_a = rh.aliasSpec) === null || _a === void 0 ? void 0 : _a.alias) {
|
|
1586
|
+
lbl = rh.aliasSpec.alias;
|
|
1587
|
+
break;
|
|
1588
|
+
}
|
|
1589
|
+
}
|
|
1590
|
+
}
|
|
1591
|
+
if (lbl !== undefined)
|
|
1592
|
+
return lbl;
|
|
1593
|
+
if (stmt.pattern.crudMap) {
|
|
1594
|
+
return stmt.pattern.crudMap.name;
|
|
1595
|
+
}
|
|
1596
|
+
throw new Error(`Failed to extract label from flow step - ${(_b = stmt.$cstNode) === null || _b === void 0 ? void 0 : _b.text}`);
|
|
1597
|
+
}
|
|
1552
1598
|
export function flowGraphNext(graph, currentNode, onCondition) {
|
|
1553
1599
|
var _a;
|
|
1554
1600
|
if (!currentNode) {
|
|
@@ -1565,9 +1611,9 @@ export function flowGraphNext(graph, currentNode, onCondition) {
|
|
|
1565
1611
|
if (c !== undefined) {
|
|
1566
1612
|
const next = node.next[c];
|
|
1567
1613
|
const r = graph.find((n) => {
|
|
1568
|
-
return n.label == next;
|
|
1614
|
+
return n.label == next.label;
|
|
1569
1615
|
});
|
|
1570
|
-
return r || { label: next, type: 'action', next: [] };
|
|
1616
|
+
return r || { label: next.label, type: 'action', next: [] };
|
|
1571
1617
|
}
|
|
1572
1618
|
else {
|
|
1573
1619
|
return undefined;
|
|
@@ -1575,7 +1621,7 @@ export function flowGraphNext(graph, currentNode, onCondition) {
|
|
|
1575
1621
|
}
|
|
1576
1622
|
else {
|
|
1577
1623
|
return graph.find((n) => {
|
|
1578
|
-
return n.label == node.next[0];
|
|
1624
|
+
return n.label == node.next[0].label;
|
|
1579
1625
|
});
|
|
1580
1626
|
}
|
|
1581
1627
|
}
|
|
@@ -2518,6 +2564,13 @@ export function addEvent(name, moduleName = activeModule, scm, ext) {
|
|
|
2518
2564
|
}
|
|
2519
2565
|
return event;
|
|
2520
2566
|
}
|
|
2567
|
+
export function addMcpEvent(name, moduleName) {
|
|
2568
|
+
const event = addEvent(name, moduleName);
|
|
2569
|
+
event.addMeta(SystemDefinedEvent, 'true');
|
|
2570
|
+
event.addMeta(McpToolEvent, 'true');
|
|
2571
|
+
event.setPublic(true);
|
|
2572
|
+
return event;
|
|
2573
|
+
}
|
|
2521
2574
|
export function addRecord(name, moduleName = activeModule, scm, ext) {
|
|
2522
2575
|
const module = fetchModule(moduleName);
|
|
2523
2576
|
return module.addEntry(new Record(name, moduleName, scm, ext));
|
|
@@ -3361,6 +3414,13 @@ export function isBetweenRelationship(relName, moduleName) {
|
|
|
3361
3414
|
const mod = fr.module;
|
|
3362
3415
|
return mod.isBetweenRelationship(fr.entryName);
|
|
3363
3416
|
}
|
|
3417
|
+
export function isOneToOneBetweenRelationship(relName, moduleName) {
|
|
3418
|
+
if (isBetweenRelationship(relName, moduleName)) {
|
|
3419
|
+
const rel = getRelationship(relName, moduleName);
|
|
3420
|
+
return rel.isOneToOne();
|
|
3421
|
+
}
|
|
3422
|
+
return false;
|
|
3423
|
+
}
|
|
3364
3424
|
export function isContainsRelationship(relName, moduleName) {
|
|
3365
3425
|
const fr = fetchModuleByEntryName(relName, moduleName);
|
|
3366
3426
|
const mod = fr.module;
|