@ixo/common 1.1.36 → 1.1.37
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/.turbo/turbo-build.log +1 -1
- package/dist/ai/tools/parser-action-tool.d.ts.map +1 -1
- package/dist/ai/tools/parser-action-tool.js +9 -3
- package/dist/ai/tools/parser-action-tool.js.map +1 -1
- package/package.json +3 -3
- package/src/ai/tools/parser-action-tool.ts +20 -3
- package/tsconfig.tsbuildinfo +1 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parser-action-tool.d.ts","sourceRoot":"","sources":["../../../src/ai/tools/parser-action-tool.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"parser-action-tool.d.ts","sourceRoot":"","sources":["../../../src/ai/tools/parser-action-tool.ts"],"names":[],"mappings":"AAMA,UAAU,oBAAoB;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC;AAGD,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,oBAAoB,oHAgE5D"}
|
|
@@ -1,20 +1,26 @@
|
|
|
1
1
|
import { tool } from '@langchain/core/tools';
|
|
2
|
+
import { randomUUID } from 'node:crypto';
|
|
2
3
|
import { callAgAction } from './action-caller.js';
|
|
3
4
|
import { logActionToMatrix } from './log-action-to-matrix.js';
|
|
4
5
|
export function parserActionTool(action) {
|
|
5
6
|
const { name, description, schema } = action;
|
|
6
7
|
return tool(async (input, runnableConfig) => {
|
|
7
8
|
const { configurable } = runnableConfig;
|
|
8
|
-
const
|
|
9
|
+
const sessionIdField = configurable.sessionId;
|
|
10
|
+
const sessionId = typeof sessionIdField === 'string' && sessionIdField.length > 0
|
|
11
|
+
? sessionIdField
|
|
12
|
+
: configurable.thread_id;
|
|
13
|
+
const { requestId, configs } = configurable;
|
|
9
14
|
if (!sessionId) {
|
|
10
15
|
throw new Error('sessionId is required for AG-UI actions');
|
|
11
16
|
}
|
|
17
|
+
const toolCallId = `ag_${requestId ?? 'noreq'}_${randomUUID().slice(0, 8)}`;
|
|
12
18
|
const result = await callAgAction({
|
|
13
19
|
sessionId,
|
|
14
|
-
toolCallId
|
|
20
|
+
toolCallId,
|
|
15
21
|
toolName: name,
|
|
16
22
|
args: input,
|
|
17
|
-
timeout:
|
|
23
|
+
timeout: 15000,
|
|
18
24
|
});
|
|
19
25
|
if (configs?.matrix.roomId) {
|
|
20
26
|
void logActionToMatrix({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parser-action-tool.js","sourceRoot":"","sources":["../../../src/ai/tools/parser-action-tool.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAS9D,MAAM,UAAU,gBAAgB,CAAC,MAA4B;IAC3D,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC;IAC7C,OAAO,IAAI,CACT,KAAK,EAAE,KAAK,EAAE,cAAc,EAAE,EAAE;QAC9B,MAAM,EAAE,YAAY,EAAE,GACpB,cAAmD,CAAC;
|
|
1
|
+
{"version":3,"file":"parser-action-tool.js","sourceRoot":"","sources":["../../../src/ai/tools/parser-action-tool.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAS9D,MAAM,UAAU,gBAAgB,CAAC,MAA4B;IAC3D,MAAM,EAAE,IAA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CACF,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ixo/common",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.37",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -33,9 +33,9 @@
|
|
|
33
33
|
"testcontainers": "^10.16.0",
|
|
34
34
|
"typescript": "^5.3.3",
|
|
35
35
|
"@ixo/eslint-config": "2.0.0",
|
|
36
|
+
"@ixo/oracles-events": "^1.0.4",
|
|
36
37
|
"@ixo/typescript-config": "1.0.0",
|
|
37
|
-
"@ixo/vitest-config": "1.0.0"
|
|
38
|
-
"@ixo/oracles-events": "^1.0.4"
|
|
38
|
+
"@ixo/vitest-config": "1.0.0"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@cosmjs/proto-signing": "^0.33.0",
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type IRunnableConfigWithRequiredFields } from '@ixo/matrix';
|
|
2
2
|
import { tool } from '@langchain/core/tools';
|
|
3
|
+
import { randomUUID } from 'node:crypto';
|
|
3
4
|
import { callAgAction } from './action-caller.js';
|
|
4
5
|
import { logActionToMatrix } from './log-action-to-matrix.js';
|
|
5
6
|
|
|
@@ -16,19 +17,35 @@ export function parserActionTool(action: IParseAgActionParams) {
|
|
|
16
17
|
async (input, runnableConfig) => {
|
|
17
18
|
const { configurable } =
|
|
18
19
|
runnableConfig as IRunnableConfigWithRequiredFields;
|
|
19
|
-
|
|
20
|
+
// Prefer explicit `sessionId` — sub-agent wrappers set this to the real
|
|
21
|
+
// user WS session so routing works from nested contexts. Fall back to
|
|
22
|
+
// `thread_id` for direct invocations from the main agent (where
|
|
23
|
+
// thread_id IS the user's session).
|
|
24
|
+
const sessionIdField = (
|
|
25
|
+
configurable as { sessionId?: unknown }
|
|
26
|
+
).sessionId;
|
|
27
|
+
const sessionId =
|
|
28
|
+
typeof sessionIdField === 'string' && sessionIdField.length > 0
|
|
29
|
+
? sessionIdField
|
|
30
|
+
: configurable.thread_id;
|
|
31
|
+
const { requestId, configs } = configurable;
|
|
20
32
|
|
|
21
33
|
if (!sessionId) {
|
|
22
34
|
throw new Error('sessionId is required for AG-UI actions');
|
|
23
35
|
}
|
|
24
36
|
|
|
37
|
+
// Unique toolCallId per invocation. Protects against:
|
|
38
|
+
// - Multiple tool calls sharing one requestId (React key collisions)
|
|
39
|
+
// - Any future code path that forgets to propagate requestId
|
|
40
|
+
const toolCallId = `ag_${requestId ?? 'noreq'}_${randomUUID().slice(0, 8)}`;
|
|
41
|
+
|
|
25
42
|
// Call the action and WAIT for result from frontend
|
|
26
43
|
const result = await callAgAction({
|
|
27
44
|
sessionId,
|
|
28
|
-
toolCallId
|
|
45
|
+
toolCallId,
|
|
29
46
|
toolName: name,
|
|
30
47
|
args: input as Record<string, unknown>,
|
|
31
|
-
timeout:
|
|
48
|
+
timeout: 15000, // 15 seconds
|
|
32
49
|
});
|
|
33
50
|
|
|
34
51
|
if (configs?.matrix.roomId) {
|