@agentium/transport 2.3.2 → 2.4.0
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/dist/index.cjs +101 -6
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +101 -6
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1117,6 +1117,27 @@ var SCHEMAS = {
|
|
|
1117
1117
|
sessionId: { type: "string" },
|
|
1118
1118
|
userId: { type: "string" }
|
|
1119
1119
|
}
|
|
1120
|
+
},
|
|
1121
|
+
CorrectionRequest: {
|
|
1122
|
+
type: "object",
|
|
1123
|
+
required: ["originalValue", "correctedValue"],
|
|
1124
|
+
properties: {
|
|
1125
|
+
originalValue: { type: "string", description: "What the agent produced (the wrong value)" },
|
|
1126
|
+
correctedValue: { type: "string", description: "What it should have been" },
|
|
1127
|
+
field: { type: "string", description: "The specific field/aspect corrected" },
|
|
1128
|
+
reason: { type: "string", description: "Why the correction applies" },
|
|
1129
|
+
entityKey: { type: "string", description: "Real-world entity this applies to, e.g. a vendor ID" },
|
|
1130
|
+
runId: { type: "string", description: "Run that produced the corrected output" },
|
|
1131
|
+
sessionId: { type: "string" },
|
|
1132
|
+
userId: { type: "string" },
|
|
1133
|
+
tenantId: { type: "string" },
|
|
1134
|
+
scope: {
|
|
1135
|
+
type: "string",
|
|
1136
|
+
enum: ["user", "agent", "tenant", "global"],
|
|
1137
|
+
description: "Visibility scope (default: agent)"
|
|
1138
|
+
},
|
|
1139
|
+
tags: { type: "array", items: { type: "string" } }
|
|
1140
|
+
}
|
|
1120
1141
|
}
|
|
1121
1142
|
};
|
|
1122
1143
|
function buildAgentDescription(agent) {
|
|
@@ -1328,6 +1349,43 @@ ${agentDesc}`,
|
|
|
1328
1349
|
}
|
|
1329
1350
|
}
|
|
1330
1351
|
};
|
|
1352
|
+
spec.paths[`${prefix}/agents/${name}/corrections`] = {
|
|
1353
|
+
post: {
|
|
1354
|
+
tags: ["Agents"],
|
|
1355
|
+
summary: `Record a correction for agent: ${name}`,
|
|
1356
|
+
description: `Record a human correction of agent **${name}**'s output. The correction is stored as vectorized knowledge and retrieved on future relevant runs so the mistake is not repeated. Requires the agent to have \`memory.corrections\` configured.`,
|
|
1357
|
+
operationId: `recordCorrection_${name}`,
|
|
1358
|
+
requestBody: {
|
|
1359
|
+
required: true,
|
|
1360
|
+
content: {
|
|
1361
|
+
"application/json": {
|
|
1362
|
+
schema: { $ref: "#/components/schemas/CorrectionRequest" }
|
|
1363
|
+
}
|
|
1364
|
+
}
|
|
1365
|
+
},
|
|
1366
|
+
responses: {
|
|
1367
|
+
"201": {
|
|
1368
|
+
description: "Correction recorded"
|
|
1369
|
+
},
|
|
1370
|
+
"400": {
|
|
1371
|
+
description: "Bad request",
|
|
1372
|
+
content: {
|
|
1373
|
+
"application/json": {
|
|
1374
|
+
schema: { $ref: "#/components/schemas/Error" }
|
|
1375
|
+
}
|
|
1376
|
+
}
|
|
1377
|
+
},
|
|
1378
|
+
"404": {
|
|
1379
|
+
description: "Corrections not enabled for this agent",
|
|
1380
|
+
content: {
|
|
1381
|
+
"application/json": {
|
|
1382
|
+
schema: { $ref: "#/components/schemas/Error" }
|
|
1383
|
+
}
|
|
1384
|
+
}
|
|
1385
|
+
}
|
|
1386
|
+
}
|
|
1387
|
+
}
|
|
1388
|
+
};
|
|
1331
1389
|
}
|
|
1332
1390
|
}
|
|
1333
1391
|
if (routerOpts.teams && Object.keys(routerOpts.teams).length > 0) {
|
|
@@ -1651,6 +1709,45 @@ function createAgentRouter(opts) {
|
|
|
1651
1709
|
}
|
|
1652
1710
|
}
|
|
1653
1711
|
});
|
|
1712
|
+
router.post(`/agents/${name}/corrections`, async (req, res) => {
|
|
1713
|
+
try {
|
|
1714
|
+
const memory = agent.memory;
|
|
1715
|
+
if (!memory || !memory.getCorrectionStore?.()) {
|
|
1716
|
+
return res.status(404).json({
|
|
1717
|
+
error: `Corrections are not enabled for agent "${name}". Configure memory.corrections with a vectorStore.`
|
|
1718
|
+
});
|
|
1719
|
+
}
|
|
1720
|
+
const validated = validateBody(req.body, {
|
|
1721
|
+
originalValue: "string",
|
|
1722
|
+
correctedValue: "string",
|
|
1723
|
+
field: "string?",
|
|
1724
|
+
reason: "string?",
|
|
1725
|
+
entityKey: "string?",
|
|
1726
|
+
runId: "string?",
|
|
1727
|
+
sessionId: "string?",
|
|
1728
|
+
userId: "string?",
|
|
1729
|
+
tenantId: "string?",
|
|
1730
|
+
scope: "string?"
|
|
1731
|
+
});
|
|
1732
|
+
const correction = await memory.recordCorrection({
|
|
1733
|
+
agentName: name,
|
|
1734
|
+
runId: validated.runId,
|
|
1735
|
+
sessionId: validated.sessionId,
|
|
1736
|
+
field: validated.field,
|
|
1737
|
+
originalValue: validated.originalValue,
|
|
1738
|
+
correctedValue: validated.correctedValue,
|
|
1739
|
+
reason: validated.reason,
|
|
1740
|
+
entityKey: validated.entityKey,
|
|
1741
|
+
tags: Array.isArray(req.body?.tags) ? req.body.tags : void 0,
|
|
1742
|
+
scope: validated.scope,
|
|
1743
|
+
userId: validated.userId,
|
|
1744
|
+
tenantId: validated.tenantId
|
|
1745
|
+
});
|
|
1746
|
+
res.status(201).json(correction);
|
|
1747
|
+
} catch (error) {
|
|
1748
|
+
res.status(400).json({ error: error.message });
|
|
1749
|
+
}
|
|
1750
|
+
});
|
|
1654
1751
|
}
|
|
1655
1752
|
}
|
|
1656
1753
|
if (opts.teams) {
|
|
@@ -1906,8 +2003,7 @@ function createAgentRouter(opts) {
|
|
|
1906
2003
|
router.get("/agents/:name/checkpoints", async (req, res) => {
|
|
1907
2004
|
const agent = reg.getAgent(req.params.name);
|
|
1908
2005
|
if (!agent) return res.status(404).json({ error: `Agent "${req.params.name}" not found` });
|
|
1909
|
-
const
|
|
1910
|
-
const checkpointMgr = config?._checkpointManager;
|
|
2006
|
+
const checkpointMgr = agent.checkpointManager ?? agent.config?._checkpointManager;
|
|
1911
2007
|
if (!checkpointMgr) return res.json([]);
|
|
1912
2008
|
const runId = req.query.runId;
|
|
1913
2009
|
if (!runId) return res.status(400).json({ error: "runId query param required" });
|
|
@@ -1921,8 +2017,7 @@ function createAgentRouter(opts) {
|
|
|
1921
2017
|
router.post("/agents/:name/rollback/:checkpointId", async (req, res) => {
|
|
1922
2018
|
const agent = reg.getAgent(req.params.name);
|
|
1923
2019
|
if (!agent) return res.status(404).json({ error: `Agent "${req.params.name}" not found` });
|
|
1924
|
-
const
|
|
1925
|
-
const checkpointMgr = config?._checkpointManager;
|
|
2020
|
+
const checkpointMgr = agent.checkpointManager ?? agent.config?._checkpointManager;
|
|
1926
2021
|
if (!checkpointMgr) return res.status(400).json({ error: "Checkpointing not enabled for this agent" });
|
|
1927
2022
|
try {
|
|
1928
2023
|
const checkpoint = await checkpointMgr.rollback(req.params.checkpointId);
|
|
@@ -1944,11 +2039,11 @@ function createAgentRouter(opts) {
|
|
|
1944
2039
|
`);
|
|
1945
2040
|
};
|
|
1946
2041
|
for (const agent of reg.agents.values()) {
|
|
1947
|
-
agent.eventBus
|
|
2042
|
+
agent.eventBus?.on("tool.approval.request", listener);
|
|
1948
2043
|
}
|
|
1949
2044
|
req.on("close", () => {
|
|
1950
2045
|
for (const agent of reg.agents.values()) {
|
|
1951
|
-
agent.eventBus
|
|
2046
|
+
agent.eventBus?.off("tool.approval.request", listener);
|
|
1952
2047
|
}
|
|
1953
2048
|
});
|
|
1954
2049
|
});
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Agent, A2AAgentCard, MCPToolProviderConfig, ToolDef, MCPToolProvider, Registry, Servable, Team, Workflow, Toolkit, EventBus, VisionAgent, VoiceAgent } from '@agentium/core';
|
|
1
|
+
import { Agent, A2AAgentCard, MCPToolProviderConfig, ToolDef, MCPToolProvider, Registry, Servable, ServableAgent, Team, Workflow, Toolkit, EventBus, VisionAgent, VoiceAgent } from '@agentium/core';
|
|
2
2
|
|
|
3
3
|
interface A2AServerOptions {
|
|
4
4
|
agents: Record<string, Agent>;
|
|
@@ -184,7 +184,7 @@ interface RouterOptions {
|
|
|
184
184
|
* Each item is classified by its `.kind` and keyed by `.name`.
|
|
185
185
|
*/
|
|
186
186
|
serve?: Servable[];
|
|
187
|
-
agents?: Record<string, Agent>;
|
|
187
|
+
agents?: Record<string, Agent | ServableAgent>;
|
|
188
188
|
teams?: Record<string, Team>;
|
|
189
189
|
workflows?: Record<string, Workflow<any>>;
|
|
190
190
|
middleware?: any[];
|
|
@@ -435,7 +435,7 @@ interface GatewayOptions {
|
|
|
435
435
|
* Each item is classified by its `.kind` and keyed by `.name`.
|
|
436
436
|
*/
|
|
437
437
|
serve?: Servable[];
|
|
438
|
-
agents?: Record<string, Agent>;
|
|
438
|
+
agents?: Record<string, Agent | ServableAgent>;
|
|
439
439
|
teams?: Record<string, Team>;
|
|
440
440
|
io: any;
|
|
441
441
|
namespace?: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Agent, A2AAgentCard, MCPToolProviderConfig, ToolDef, MCPToolProvider, Registry, Servable, Team, Workflow, Toolkit, EventBus, VisionAgent, VoiceAgent } from '@agentium/core';
|
|
1
|
+
import { Agent, A2AAgentCard, MCPToolProviderConfig, ToolDef, MCPToolProvider, Registry, Servable, ServableAgent, Team, Workflow, Toolkit, EventBus, VisionAgent, VoiceAgent } from '@agentium/core';
|
|
2
2
|
|
|
3
3
|
interface A2AServerOptions {
|
|
4
4
|
agents: Record<string, Agent>;
|
|
@@ -184,7 +184,7 @@ interface RouterOptions {
|
|
|
184
184
|
* Each item is classified by its `.kind` and keyed by `.name`.
|
|
185
185
|
*/
|
|
186
186
|
serve?: Servable[];
|
|
187
|
-
agents?: Record<string, Agent>;
|
|
187
|
+
agents?: Record<string, Agent | ServableAgent>;
|
|
188
188
|
teams?: Record<string, Team>;
|
|
189
189
|
workflows?: Record<string, Workflow<any>>;
|
|
190
190
|
middleware?: any[];
|
|
@@ -435,7 +435,7 @@ interface GatewayOptions {
|
|
|
435
435
|
* Each item is classified by its `.kind` and keyed by `.name`.
|
|
436
436
|
*/
|
|
437
437
|
serve?: Servable[];
|
|
438
|
-
agents?: Record<string, Agent>;
|
|
438
|
+
agents?: Record<string, Agent | ServableAgent>;
|
|
439
439
|
teams?: Record<string, Team>;
|
|
440
440
|
io: any;
|
|
441
441
|
namespace?: string;
|
package/dist/index.js
CHANGED
|
@@ -1069,6 +1069,27 @@ var SCHEMAS = {
|
|
|
1069
1069
|
sessionId: { type: "string" },
|
|
1070
1070
|
userId: { type: "string" }
|
|
1071
1071
|
}
|
|
1072
|
+
},
|
|
1073
|
+
CorrectionRequest: {
|
|
1074
|
+
type: "object",
|
|
1075
|
+
required: ["originalValue", "correctedValue"],
|
|
1076
|
+
properties: {
|
|
1077
|
+
originalValue: { type: "string", description: "What the agent produced (the wrong value)" },
|
|
1078
|
+
correctedValue: { type: "string", description: "What it should have been" },
|
|
1079
|
+
field: { type: "string", description: "The specific field/aspect corrected" },
|
|
1080
|
+
reason: { type: "string", description: "Why the correction applies" },
|
|
1081
|
+
entityKey: { type: "string", description: "Real-world entity this applies to, e.g. a vendor ID" },
|
|
1082
|
+
runId: { type: "string", description: "Run that produced the corrected output" },
|
|
1083
|
+
sessionId: { type: "string" },
|
|
1084
|
+
userId: { type: "string" },
|
|
1085
|
+
tenantId: { type: "string" },
|
|
1086
|
+
scope: {
|
|
1087
|
+
type: "string",
|
|
1088
|
+
enum: ["user", "agent", "tenant", "global"],
|
|
1089
|
+
description: "Visibility scope (default: agent)"
|
|
1090
|
+
},
|
|
1091
|
+
tags: { type: "array", items: { type: "string" } }
|
|
1092
|
+
}
|
|
1072
1093
|
}
|
|
1073
1094
|
};
|
|
1074
1095
|
function buildAgentDescription(agent) {
|
|
@@ -1280,6 +1301,43 @@ ${agentDesc}`,
|
|
|
1280
1301
|
}
|
|
1281
1302
|
}
|
|
1282
1303
|
};
|
|
1304
|
+
spec.paths[`${prefix}/agents/${name}/corrections`] = {
|
|
1305
|
+
post: {
|
|
1306
|
+
tags: ["Agents"],
|
|
1307
|
+
summary: `Record a correction for agent: ${name}`,
|
|
1308
|
+
description: `Record a human correction of agent **${name}**'s output. The correction is stored as vectorized knowledge and retrieved on future relevant runs so the mistake is not repeated. Requires the agent to have \`memory.corrections\` configured.`,
|
|
1309
|
+
operationId: `recordCorrection_${name}`,
|
|
1310
|
+
requestBody: {
|
|
1311
|
+
required: true,
|
|
1312
|
+
content: {
|
|
1313
|
+
"application/json": {
|
|
1314
|
+
schema: { $ref: "#/components/schemas/CorrectionRequest" }
|
|
1315
|
+
}
|
|
1316
|
+
}
|
|
1317
|
+
},
|
|
1318
|
+
responses: {
|
|
1319
|
+
"201": {
|
|
1320
|
+
description: "Correction recorded"
|
|
1321
|
+
},
|
|
1322
|
+
"400": {
|
|
1323
|
+
description: "Bad request",
|
|
1324
|
+
content: {
|
|
1325
|
+
"application/json": {
|
|
1326
|
+
schema: { $ref: "#/components/schemas/Error" }
|
|
1327
|
+
}
|
|
1328
|
+
}
|
|
1329
|
+
},
|
|
1330
|
+
"404": {
|
|
1331
|
+
description: "Corrections not enabled for this agent",
|
|
1332
|
+
content: {
|
|
1333
|
+
"application/json": {
|
|
1334
|
+
schema: { $ref: "#/components/schemas/Error" }
|
|
1335
|
+
}
|
|
1336
|
+
}
|
|
1337
|
+
}
|
|
1338
|
+
}
|
|
1339
|
+
}
|
|
1340
|
+
};
|
|
1283
1341
|
}
|
|
1284
1342
|
}
|
|
1285
1343
|
if (routerOpts.teams && Object.keys(routerOpts.teams).length > 0) {
|
|
@@ -1603,6 +1661,45 @@ function createAgentRouter(opts) {
|
|
|
1603
1661
|
}
|
|
1604
1662
|
}
|
|
1605
1663
|
});
|
|
1664
|
+
router.post(`/agents/${name}/corrections`, async (req, res) => {
|
|
1665
|
+
try {
|
|
1666
|
+
const memory = agent.memory;
|
|
1667
|
+
if (!memory || !memory.getCorrectionStore?.()) {
|
|
1668
|
+
return res.status(404).json({
|
|
1669
|
+
error: `Corrections are not enabled for agent "${name}". Configure memory.corrections with a vectorStore.`
|
|
1670
|
+
});
|
|
1671
|
+
}
|
|
1672
|
+
const validated = validateBody(req.body, {
|
|
1673
|
+
originalValue: "string",
|
|
1674
|
+
correctedValue: "string",
|
|
1675
|
+
field: "string?",
|
|
1676
|
+
reason: "string?",
|
|
1677
|
+
entityKey: "string?",
|
|
1678
|
+
runId: "string?",
|
|
1679
|
+
sessionId: "string?",
|
|
1680
|
+
userId: "string?",
|
|
1681
|
+
tenantId: "string?",
|
|
1682
|
+
scope: "string?"
|
|
1683
|
+
});
|
|
1684
|
+
const correction = await memory.recordCorrection({
|
|
1685
|
+
agentName: name,
|
|
1686
|
+
runId: validated.runId,
|
|
1687
|
+
sessionId: validated.sessionId,
|
|
1688
|
+
field: validated.field,
|
|
1689
|
+
originalValue: validated.originalValue,
|
|
1690
|
+
correctedValue: validated.correctedValue,
|
|
1691
|
+
reason: validated.reason,
|
|
1692
|
+
entityKey: validated.entityKey,
|
|
1693
|
+
tags: Array.isArray(req.body?.tags) ? req.body.tags : void 0,
|
|
1694
|
+
scope: validated.scope,
|
|
1695
|
+
userId: validated.userId,
|
|
1696
|
+
tenantId: validated.tenantId
|
|
1697
|
+
});
|
|
1698
|
+
res.status(201).json(correction);
|
|
1699
|
+
} catch (error) {
|
|
1700
|
+
res.status(400).json({ error: error.message });
|
|
1701
|
+
}
|
|
1702
|
+
});
|
|
1606
1703
|
}
|
|
1607
1704
|
}
|
|
1608
1705
|
if (opts.teams) {
|
|
@@ -1858,8 +1955,7 @@ function createAgentRouter(opts) {
|
|
|
1858
1955
|
router.get("/agents/:name/checkpoints", async (req, res) => {
|
|
1859
1956
|
const agent = reg.getAgent(req.params.name);
|
|
1860
1957
|
if (!agent) return res.status(404).json({ error: `Agent "${req.params.name}" not found` });
|
|
1861
|
-
const
|
|
1862
|
-
const checkpointMgr = config?._checkpointManager;
|
|
1958
|
+
const checkpointMgr = agent.checkpointManager ?? agent.config?._checkpointManager;
|
|
1863
1959
|
if (!checkpointMgr) return res.json([]);
|
|
1864
1960
|
const runId = req.query.runId;
|
|
1865
1961
|
if (!runId) return res.status(400).json({ error: "runId query param required" });
|
|
@@ -1873,8 +1969,7 @@ function createAgentRouter(opts) {
|
|
|
1873
1969
|
router.post("/agents/:name/rollback/:checkpointId", async (req, res) => {
|
|
1874
1970
|
const agent = reg.getAgent(req.params.name);
|
|
1875
1971
|
if (!agent) return res.status(404).json({ error: `Agent "${req.params.name}" not found` });
|
|
1876
|
-
const
|
|
1877
|
-
const checkpointMgr = config?._checkpointManager;
|
|
1972
|
+
const checkpointMgr = agent.checkpointManager ?? agent.config?._checkpointManager;
|
|
1878
1973
|
if (!checkpointMgr) return res.status(400).json({ error: "Checkpointing not enabled for this agent" });
|
|
1879
1974
|
try {
|
|
1880
1975
|
const checkpoint = await checkpointMgr.rollback(req.params.checkpointId);
|
|
@@ -1896,11 +1991,11 @@ function createAgentRouter(opts) {
|
|
|
1896
1991
|
`);
|
|
1897
1992
|
};
|
|
1898
1993
|
for (const agent of reg.agents.values()) {
|
|
1899
|
-
agent.eventBus
|
|
1994
|
+
agent.eventBus?.on("tool.approval.request", listener);
|
|
1900
1995
|
}
|
|
1901
1996
|
req.on("close", () => {
|
|
1902
1997
|
for (const agent of reg.agents.values()) {
|
|
1903
|
-
agent.eventBus
|
|
1998
|
+
agent.eventBus?.off("tool.approval.request", listener);
|
|
1904
1999
|
}
|
|
1905
2000
|
});
|
|
1906
2001
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentium/transport",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0",
|
|
4
4
|
"description": "HTTP and WebSocket transport layer for Agentium agents",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"typescript": "^5.6.0"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
|
-
"@agentium/core": "^2.
|
|
45
|
+
"@agentium/core": "^2.4.0",
|
|
46
46
|
"@types/express": "^4.0.0 || ^5.0.0",
|
|
47
47
|
"express": "^4.0.0 || ^5.0.0",
|
|
48
48
|
"multer": ">=2.0.0",
|