@agentium/transport 2.3.2 → 2.5.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 +107 -6
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +107 -6
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1117,6 +1117,31 @@ 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
|
+
originalInput: {
|
|
1132
|
+
type: "string",
|
|
1133
|
+
description: "The input that produced the corrected output \u2014 enables regression eval replay"
|
|
1134
|
+
},
|
|
1135
|
+
sessionId: { type: "string" },
|
|
1136
|
+
userId: { type: "string" },
|
|
1137
|
+
tenantId: { type: "string" },
|
|
1138
|
+
scope: {
|
|
1139
|
+
type: "string",
|
|
1140
|
+
enum: ["user", "agent", "tenant", "global"],
|
|
1141
|
+
description: "Visibility scope (default: agent)"
|
|
1142
|
+
},
|
|
1143
|
+
tags: { type: "array", items: { type: "string" } }
|
|
1144
|
+
}
|
|
1120
1145
|
}
|
|
1121
1146
|
};
|
|
1122
1147
|
function buildAgentDescription(agent) {
|
|
@@ -1328,6 +1353,43 @@ ${agentDesc}`,
|
|
|
1328
1353
|
}
|
|
1329
1354
|
}
|
|
1330
1355
|
};
|
|
1356
|
+
spec.paths[`${prefix}/agents/${name}/corrections`] = {
|
|
1357
|
+
post: {
|
|
1358
|
+
tags: ["Agents"],
|
|
1359
|
+
summary: `Record a correction for agent: ${name}`,
|
|
1360
|
+
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.`,
|
|
1361
|
+
operationId: `recordCorrection_${name}`,
|
|
1362
|
+
requestBody: {
|
|
1363
|
+
required: true,
|
|
1364
|
+
content: {
|
|
1365
|
+
"application/json": {
|
|
1366
|
+
schema: { $ref: "#/components/schemas/CorrectionRequest" }
|
|
1367
|
+
}
|
|
1368
|
+
}
|
|
1369
|
+
},
|
|
1370
|
+
responses: {
|
|
1371
|
+
"201": {
|
|
1372
|
+
description: "Correction recorded"
|
|
1373
|
+
},
|
|
1374
|
+
"400": {
|
|
1375
|
+
description: "Bad request",
|
|
1376
|
+
content: {
|
|
1377
|
+
"application/json": {
|
|
1378
|
+
schema: { $ref: "#/components/schemas/Error" }
|
|
1379
|
+
}
|
|
1380
|
+
}
|
|
1381
|
+
},
|
|
1382
|
+
"404": {
|
|
1383
|
+
description: "Corrections not enabled for this agent",
|
|
1384
|
+
content: {
|
|
1385
|
+
"application/json": {
|
|
1386
|
+
schema: { $ref: "#/components/schemas/Error" }
|
|
1387
|
+
}
|
|
1388
|
+
}
|
|
1389
|
+
}
|
|
1390
|
+
}
|
|
1391
|
+
}
|
|
1392
|
+
};
|
|
1331
1393
|
}
|
|
1332
1394
|
}
|
|
1333
1395
|
if (routerOpts.teams && Object.keys(routerOpts.teams).length > 0) {
|
|
@@ -1651,6 +1713,47 @@ function createAgentRouter(opts) {
|
|
|
1651
1713
|
}
|
|
1652
1714
|
}
|
|
1653
1715
|
});
|
|
1716
|
+
router.post(`/agents/${name}/corrections`, async (req, res) => {
|
|
1717
|
+
try {
|
|
1718
|
+
const memory = agent.memory;
|
|
1719
|
+
if (!memory || !memory.getCorrectionStore?.()) {
|
|
1720
|
+
return res.status(404).json({
|
|
1721
|
+
error: `Corrections are not enabled for agent "${name}". Configure memory.corrections with a vectorStore.`
|
|
1722
|
+
});
|
|
1723
|
+
}
|
|
1724
|
+
const validated = validateBody(req.body, {
|
|
1725
|
+
originalValue: "string",
|
|
1726
|
+
correctedValue: "string",
|
|
1727
|
+
field: "string?",
|
|
1728
|
+
reason: "string?",
|
|
1729
|
+
entityKey: "string?",
|
|
1730
|
+
runId: "string?",
|
|
1731
|
+
sessionId: "string?",
|
|
1732
|
+
userId: "string?",
|
|
1733
|
+
tenantId: "string?",
|
|
1734
|
+
scope: "string?",
|
|
1735
|
+
originalInput: "string?"
|
|
1736
|
+
});
|
|
1737
|
+
const correction = await memory.recordCorrection({
|
|
1738
|
+
agentName: name,
|
|
1739
|
+
runId: validated.runId,
|
|
1740
|
+
sessionId: validated.sessionId,
|
|
1741
|
+
originalInput: validated.originalInput,
|
|
1742
|
+
field: validated.field,
|
|
1743
|
+
originalValue: validated.originalValue,
|
|
1744
|
+
correctedValue: validated.correctedValue,
|
|
1745
|
+
reason: validated.reason,
|
|
1746
|
+
entityKey: validated.entityKey,
|
|
1747
|
+
tags: Array.isArray(req.body?.tags) ? req.body.tags : void 0,
|
|
1748
|
+
scope: validated.scope,
|
|
1749
|
+
userId: validated.userId,
|
|
1750
|
+
tenantId: validated.tenantId
|
|
1751
|
+
});
|
|
1752
|
+
res.status(201).json(correction);
|
|
1753
|
+
} catch (error) {
|
|
1754
|
+
res.status(400).json({ error: error.message });
|
|
1755
|
+
}
|
|
1756
|
+
});
|
|
1654
1757
|
}
|
|
1655
1758
|
}
|
|
1656
1759
|
if (opts.teams) {
|
|
@@ -1906,8 +2009,7 @@ function createAgentRouter(opts) {
|
|
|
1906
2009
|
router.get("/agents/:name/checkpoints", async (req, res) => {
|
|
1907
2010
|
const agent = reg.getAgent(req.params.name);
|
|
1908
2011
|
if (!agent) return res.status(404).json({ error: `Agent "${req.params.name}" not found` });
|
|
1909
|
-
const
|
|
1910
|
-
const checkpointMgr = config?._checkpointManager;
|
|
2012
|
+
const checkpointMgr = agent.checkpointManager ?? agent.config?._checkpointManager;
|
|
1911
2013
|
if (!checkpointMgr) return res.json([]);
|
|
1912
2014
|
const runId = req.query.runId;
|
|
1913
2015
|
if (!runId) return res.status(400).json({ error: "runId query param required" });
|
|
@@ -1921,8 +2023,7 @@ function createAgentRouter(opts) {
|
|
|
1921
2023
|
router.post("/agents/:name/rollback/:checkpointId", async (req, res) => {
|
|
1922
2024
|
const agent = reg.getAgent(req.params.name);
|
|
1923
2025
|
if (!agent) return res.status(404).json({ error: `Agent "${req.params.name}" not found` });
|
|
1924
|
-
const
|
|
1925
|
-
const checkpointMgr = config?._checkpointManager;
|
|
2026
|
+
const checkpointMgr = agent.checkpointManager ?? agent.config?._checkpointManager;
|
|
1926
2027
|
if (!checkpointMgr) return res.status(400).json({ error: "Checkpointing not enabled for this agent" });
|
|
1927
2028
|
try {
|
|
1928
2029
|
const checkpoint = await checkpointMgr.rollback(req.params.checkpointId);
|
|
@@ -1944,11 +2045,11 @@ function createAgentRouter(opts) {
|
|
|
1944
2045
|
`);
|
|
1945
2046
|
};
|
|
1946
2047
|
for (const agent of reg.agents.values()) {
|
|
1947
|
-
agent.eventBus
|
|
2048
|
+
agent.eventBus?.on("tool.approval.request", listener);
|
|
1948
2049
|
}
|
|
1949
2050
|
req.on("close", () => {
|
|
1950
2051
|
for (const agent of reg.agents.values()) {
|
|
1951
|
-
agent.eventBus
|
|
2052
|
+
agent.eventBus?.off("tool.approval.request", listener);
|
|
1952
2053
|
}
|
|
1953
2054
|
});
|
|
1954
2055
|
});
|
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,31 @@ 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
|
+
originalInput: {
|
|
1084
|
+
type: "string",
|
|
1085
|
+
description: "The input that produced the corrected output \u2014 enables regression eval replay"
|
|
1086
|
+
},
|
|
1087
|
+
sessionId: { type: "string" },
|
|
1088
|
+
userId: { type: "string" },
|
|
1089
|
+
tenantId: { type: "string" },
|
|
1090
|
+
scope: {
|
|
1091
|
+
type: "string",
|
|
1092
|
+
enum: ["user", "agent", "tenant", "global"],
|
|
1093
|
+
description: "Visibility scope (default: agent)"
|
|
1094
|
+
},
|
|
1095
|
+
tags: { type: "array", items: { type: "string" } }
|
|
1096
|
+
}
|
|
1072
1097
|
}
|
|
1073
1098
|
};
|
|
1074
1099
|
function buildAgentDescription(agent) {
|
|
@@ -1280,6 +1305,43 @@ ${agentDesc}`,
|
|
|
1280
1305
|
}
|
|
1281
1306
|
}
|
|
1282
1307
|
};
|
|
1308
|
+
spec.paths[`${prefix}/agents/${name}/corrections`] = {
|
|
1309
|
+
post: {
|
|
1310
|
+
tags: ["Agents"],
|
|
1311
|
+
summary: `Record a correction for agent: ${name}`,
|
|
1312
|
+
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.`,
|
|
1313
|
+
operationId: `recordCorrection_${name}`,
|
|
1314
|
+
requestBody: {
|
|
1315
|
+
required: true,
|
|
1316
|
+
content: {
|
|
1317
|
+
"application/json": {
|
|
1318
|
+
schema: { $ref: "#/components/schemas/CorrectionRequest" }
|
|
1319
|
+
}
|
|
1320
|
+
}
|
|
1321
|
+
},
|
|
1322
|
+
responses: {
|
|
1323
|
+
"201": {
|
|
1324
|
+
description: "Correction recorded"
|
|
1325
|
+
},
|
|
1326
|
+
"400": {
|
|
1327
|
+
description: "Bad request",
|
|
1328
|
+
content: {
|
|
1329
|
+
"application/json": {
|
|
1330
|
+
schema: { $ref: "#/components/schemas/Error" }
|
|
1331
|
+
}
|
|
1332
|
+
}
|
|
1333
|
+
},
|
|
1334
|
+
"404": {
|
|
1335
|
+
description: "Corrections not enabled for this agent",
|
|
1336
|
+
content: {
|
|
1337
|
+
"application/json": {
|
|
1338
|
+
schema: { $ref: "#/components/schemas/Error" }
|
|
1339
|
+
}
|
|
1340
|
+
}
|
|
1341
|
+
}
|
|
1342
|
+
}
|
|
1343
|
+
}
|
|
1344
|
+
};
|
|
1283
1345
|
}
|
|
1284
1346
|
}
|
|
1285
1347
|
if (routerOpts.teams && Object.keys(routerOpts.teams).length > 0) {
|
|
@@ -1603,6 +1665,47 @@ function createAgentRouter(opts) {
|
|
|
1603
1665
|
}
|
|
1604
1666
|
}
|
|
1605
1667
|
});
|
|
1668
|
+
router.post(`/agents/${name}/corrections`, async (req, res) => {
|
|
1669
|
+
try {
|
|
1670
|
+
const memory = agent.memory;
|
|
1671
|
+
if (!memory || !memory.getCorrectionStore?.()) {
|
|
1672
|
+
return res.status(404).json({
|
|
1673
|
+
error: `Corrections are not enabled for agent "${name}". Configure memory.corrections with a vectorStore.`
|
|
1674
|
+
});
|
|
1675
|
+
}
|
|
1676
|
+
const validated = validateBody(req.body, {
|
|
1677
|
+
originalValue: "string",
|
|
1678
|
+
correctedValue: "string",
|
|
1679
|
+
field: "string?",
|
|
1680
|
+
reason: "string?",
|
|
1681
|
+
entityKey: "string?",
|
|
1682
|
+
runId: "string?",
|
|
1683
|
+
sessionId: "string?",
|
|
1684
|
+
userId: "string?",
|
|
1685
|
+
tenantId: "string?",
|
|
1686
|
+
scope: "string?",
|
|
1687
|
+
originalInput: "string?"
|
|
1688
|
+
});
|
|
1689
|
+
const correction = await memory.recordCorrection({
|
|
1690
|
+
agentName: name,
|
|
1691
|
+
runId: validated.runId,
|
|
1692
|
+
sessionId: validated.sessionId,
|
|
1693
|
+
originalInput: validated.originalInput,
|
|
1694
|
+
field: validated.field,
|
|
1695
|
+
originalValue: validated.originalValue,
|
|
1696
|
+
correctedValue: validated.correctedValue,
|
|
1697
|
+
reason: validated.reason,
|
|
1698
|
+
entityKey: validated.entityKey,
|
|
1699
|
+
tags: Array.isArray(req.body?.tags) ? req.body.tags : void 0,
|
|
1700
|
+
scope: validated.scope,
|
|
1701
|
+
userId: validated.userId,
|
|
1702
|
+
tenantId: validated.tenantId
|
|
1703
|
+
});
|
|
1704
|
+
res.status(201).json(correction);
|
|
1705
|
+
} catch (error) {
|
|
1706
|
+
res.status(400).json({ error: error.message });
|
|
1707
|
+
}
|
|
1708
|
+
});
|
|
1606
1709
|
}
|
|
1607
1710
|
}
|
|
1608
1711
|
if (opts.teams) {
|
|
@@ -1858,8 +1961,7 @@ function createAgentRouter(opts) {
|
|
|
1858
1961
|
router.get("/agents/:name/checkpoints", async (req, res) => {
|
|
1859
1962
|
const agent = reg.getAgent(req.params.name);
|
|
1860
1963
|
if (!agent) return res.status(404).json({ error: `Agent "${req.params.name}" not found` });
|
|
1861
|
-
const
|
|
1862
|
-
const checkpointMgr = config?._checkpointManager;
|
|
1964
|
+
const checkpointMgr = agent.checkpointManager ?? agent.config?._checkpointManager;
|
|
1863
1965
|
if (!checkpointMgr) return res.json([]);
|
|
1864
1966
|
const runId = req.query.runId;
|
|
1865
1967
|
if (!runId) return res.status(400).json({ error: "runId query param required" });
|
|
@@ -1873,8 +1975,7 @@ function createAgentRouter(opts) {
|
|
|
1873
1975
|
router.post("/agents/:name/rollback/:checkpointId", async (req, res) => {
|
|
1874
1976
|
const agent = reg.getAgent(req.params.name);
|
|
1875
1977
|
if (!agent) return res.status(404).json({ error: `Agent "${req.params.name}" not found` });
|
|
1876
|
-
const
|
|
1877
|
-
const checkpointMgr = config?._checkpointManager;
|
|
1978
|
+
const checkpointMgr = agent.checkpointManager ?? agent.config?._checkpointManager;
|
|
1878
1979
|
if (!checkpointMgr) return res.status(400).json({ error: "Checkpointing not enabled for this agent" });
|
|
1879
1980
|
try {
|
|
1880
1981
|
const checkpoint = await checkpointMgr.rollback(req.params.checkpointId);
|
|
@@ -1896,11 +1997,11 @@ function createAgentRouter(opts) {
|
|
|
1896
1997
|
`);
|
|
1897
1998
|
};
|
|
1898
1999
|
for (const agent of reg.agents.values()) {
|
|
1899
|
-
agent.eventBus
|
|
2000
|
+
agent.eventBus?.on("tool.approval.request", listener);
|
|
1900
2001
|
}
|
|
1901
2002
|
req.on("close", () => {
|
|
1902
2003
|
for (const agent of reg.agents.values()) {
|
|
1903
|
-
agent.eventBus
|
|
2004
|
+
agent.eventBus?.off("tool.approval.request", listener);
|
|
1904
2005
|
}
|
|
1905
2006
|
});
|
|
1906
2007
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentium/transport",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.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.5.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",
|