@hashgraphonline/standards-agent-kit 0.2.136 → 0.2.138
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/README.md +3 -4
- package/dist/cjs/builders/hcs10/hcs10-builder.d.ts +1 -0
- package/dist/cjs/builders/hcs2/hcs2-builder.d.ts +8 -7
- package/dist/cjs/builders/hcs6/hcs6-builder.d.ts +5 -4
- package/dist/cjs/builders/inscriber/inscriber-builder.d.ts +32 -1
- package/dist/cjs/index.d.ts +4 -0
- package/dist/cjs/signing/bytes-registry.d.ts +17 -0
- package/dist/cjs/signing/signer-provider.d.ts +45 -0
- package/dist/cjs/standards-agent-kit.cjs +1 -1
- package/dist/cjs/standards-agent-kit.cjs.map +1 -1
- package/dist/cjs/tools/hcs10/InitiateConnectionTool.d.ts +4 -4
- package/dist/cjs/tools/hcs2/CreateRegistryTool.d.ts +2 -2
- package/dist/cjs/tools/hcs2/DeleteEntryTool.d.ts +2 -2
- package/dist/cjs/tools/hcs2/UpdateEntryTool.d.ts +2 -2
- package/dist/cjs/tools/hcs6/RegisterDynamicHashinalTool.d.ts +10 -10
- package/dist/cjs/tools/hcs6/UpdateDynamicHashinalTool.d.ts +8 -8
- package/dist/cjs/tools/inscriber/InscribeFromBufferTool.d.ts +5 -4
- package/dist/cjs/tools/inscriber/InscribeFromFileTool.d.ts +2 -2
- package/dist/cjs/tools/inscriber/InscribeFromUrlTool.d.ts +4 -4
- package/dist/cjs/tools/inscriber/InscribeHashinalTool.d.ts +3 -3
- package/dist/cjs/types/inscription-response.d.ts +8 -0
- package/dist/cjs/types/tx-results.d.ts +15 -0
- package/dist/cjs/utils/CodedError.d.ts +4 -0
- package/dist/cjs/utils/inscription-utils.d.ts +21 -0
- package/dist/cjs/validation/hip412-schemas.d.ts +2 -2
- package/dist/es/builders/hcs10/hcs10-builder.d.ts +1 -0
- package/dist/es/builders/hcs2/hcs2-builder.d.ts +8 -7
- package/dist/es/builders/hcs6/hcs6-builder.d.ts +5 -4
- package/dist/es/builders/inscriber/inscriber-builder.d.ts +32 -1
- package/dist/es/index.d.ts +4 -0
- package/dist/es/signing/bytes-registry.d.ts +17 -0
- package/dist/es/signing/signer-provider.d.ts +45 -0
- package/dist/es/standards-agent-kit.es.js +46 -42
- package/dist/es/standards-agent-kit.es.js.map +1 -1
- package/dist/es/standards-agent-kit.es10.js +24 -83
- package/dist/es/standards-agent-kit.es10.js.map +1 -1
- package/dist/es/standards-agent-kit.es11.js +224 -20
- package/dist/es/standards-agent-kit.es11.js.map +1 -1
- package/dist/es/standards-agent-kit.es12.js +78 -27
- package/dist/es/standards-agent-kit.es12.js.map +1 -1
- package/dist/es/standards-agent-kit.es13.js +26 -36
- package/dist/es/standards-agent-kit.es13.js.map +1 -1
- package/dist/es/standards-agent-kit.es14.js +17 -39
- package/dist/es/standards-agent-kit.es14.js.map +1 -1
- package/dist/es/standards-agent-kit.es15.js +36 -58
- package/dist/es/standards-agent-kit.es15.js.map +1 -1
- package/dist/es/standards-agent-kit.es16.js +45 -18
- package/dist/es/standards-agent-kit.es16.js.map +1 -1
- package/dist/es/standards-agent-kit.es17.js +53 -16
- package/dist/es/standards-agent-kit.es17.js.map +1 -1
- package/dist/es/standards-agent-kit.es18.js +18 -28
- package/dist/es/standards-agent-kit.es18.js.map +1 -1
- package/dist/es/standards-agent-kit.es19.js +26 -12
- package/dist/es/standards-agent-kit.es19.js.map +1 -1
- package/dist/es/standards-agent-kit.es20.js +38 -136
- package/dist/es/standards-agent-kit.es20.js.map +1 -1
- package/dist/es/standards-agent-kit.es21.js +13 -24
- package/dist/es/standards-agent-kit.es21.js.map +1 -1
- package/dist/es/standards-agent-kit.es22.js +136 -39
- package/dist/es/standards-agent-kit.es22.js.map +1 -1
- package/dist/es/standards-agent-kit.es23.js +25 -41
- package/dist/es/standards-agent-kit.es23.js.map +1 -1
- package/dist/es/standards-agent-kit.es24.js +49 -31
- package/dist/es/standards-agent-kit.es24.js.map +1 -1
- package/dist/es/standards-agent-kit.es25.js +34 -18
- package/dist/es/standards-agent-kit.es25.js.map +1 -1
- package/dist/es/standards-agent-kit.es26.js +35 -19
- package/dist/es/standards-agent-kit.es26.js.map +1 -1
- package/dist/es/standards-agent-kit.es27.js +45 -32
- package/dist/es/standards-agent-kit.es27.js.map +1 -1
- package/dist/es/standards-agent-kit.es28.js +54 -25
- package/dist/es/standards-agent-kit.es28.js.map +1 -1
- package/dist/es/standards-agent-kit.es29.js +35 -23
- package/dist/es/standards-agent-kit.es29.js.map +1 -1
- package/dist/es/standards-agent-kit.es3.js +41 -1545
- package/dist/es/standards-agent-kit.es3.js.map +1 -1
- package/dist/es/standards-agent-kit.es30.js +23 -39
- package/dist/es/standards-agent-kit.es30.js.map +1 -1
- package/dist/es/standards-agent-kit.es31.js +30 -28
- package/dist/es/standards-agent-kit.es31.js.map +1 -1
- package/dist/es/standards-agent-kit.es32.js +45 -32
- package/dist/es/standards-agent-kit.es32.js.map +1 -1
- package/dist/es/standards-agent-kit.es33.js +50 -89
- package/dist/es/standards-agent-kit.es33.js.map +1 -1
- package/dist/es/standards-agent-kit.es34.js +35 -228
- package/dist/es/standards-agent-kit.es34.js.map +1 -1
- package/dist/es/standards-agent-kit.es35.js +87 -212
- package/dist/es/standards-agent-kit.es35.js.map +1 -1
- package/dist/es/standards-agent-kit.es36.js +188 -128
- package/dist/es/standards-agent-kit.es36.js.map +1 -1
- package/dist/es/standards-agent-kit.es37.js +167 -561
- package/dist/es/standards-agent-kit.es37.js.map +1 -1
- package/dist/es/standards-agent-kit.es38.js +236 -31
- package/dist/es/standards-agent-kit.es38.js.map +1 -1
- package/dist/es/standards-agent-kit.es39.js +483 -206
- package/dist/es/standards-agent-kit.es39.js.map +1 -1
- package/dist/es/standards-agent-kit.es4.js +359 -81
- package/dist/es/standards-agent-kit.es4.js.map +1 -1
- package/dist/es/standards-agent-kit.es40.js +39 -135
- package/dist/es/standards-agent-kit.es40.js.map +1 -1
- package/dist/es/standards-agent-kit.es41.js +244 -28
- package/dist/es/standards-agent-kit.es41.js.map +1 -1
- package/dist/es/standards-agent-kit.es42.js +132 -418
- package/dist/es/standards-agent-kit.es42.js.map +1 -1
- package/dist/es/standards-agent-kit.es43.js +28 -184
- package/dist/es/standards-agent-kit.es43.js.map +1 -1
- package/dist/es/standards-agent-kit.es44.js +423 -3
- package/dist/es/standards-agent-kit.es44.js.map +1 -1
- package/dist/es/standards-agent-kit.es45.js +185 -24
- package/dist/es/standards-agent-kit.es45.js.map +1 -1
- package/dist/es/standards-agent-kit.es46.js +3 -3
- package/dist/es/standards-agent-kit.es46.js.map +1 -1
- package/dist/es/standards-agent-kit.es47.js +21 -50
- package/dist/es/standards-agent-kit.es47.js.map +1 -1
- package/dist/es/standards-agent-kit.es48.js +8 -3
- package/dist/es/standards-agent-kit.es48.js.map +1 -1
- package/dist/es/standards-agent-kit.es49.js +3 -39
- package/dist/es/standards-agent-kit.es49.js.map +1 -1
- package/dist/es/standards-agent-kit.es5.js +1747 -73
- package/dist/es/standards-agent-kit.es5.js.map +1 -1
- package/dist/es/standards-agent-kit.es50.js +18 -16
- package/dist/es/standards-agent-kit.es50.js.map +1 -1
- package/dist/es/standards-agent-kit.es51.js +49 -49
- package/dist/es/standards-agent-kit.es51.js.map +1 -1
- package/dist/es/standards-agent-kit.es52.js +6 -0
- package/dist/es/standards-agent-kit.es52.js.map +1 -0
- package/dist/es/standards-agent-kit.es53.js +43 -0
- package/dist/es/standards-agent-kit.es53.js.map +1 -0
- package/dist/es/standards-agent-kit.es54.js +22 -0
- package/dist/es/standards-agent-kit.es54.js.map +1 -0
- package/dist/es/standards-agent-kit.es55.js +77 -0
- package/dist/es/standards-agent-kit.es55.js.map +1 -0
- package/dist/es/standards-agent-kit.es56.js +7 -0
- package/dist/es/standards-agent-kit.es56.js.map +1 -0
- package/dist/es/standards-agent-kit.es6.js +347 -32
- package/dist/es/standards-agent-kit.es6.js.map +1 -1
- package/dist/es/standards-agent-kit.es7.js +142 -293
- package/dist/es/standards-agent-kit.es7.js.map +1 -1
- package/dist/es/standards-agent-kit.es8.js +201 -21
- package/dist/es/standards-agent-kit.es8.js.map +1 -1
- package/dist/es/standards-agent-kit.es9.js +301 -213
- package/dist/es/standards-agent-kit.es9.js.map +1 -1
- package/dist/es/tools/hcs10/InitiateConnectionTool.d.ts +4 -4
- package/dist/es/tools/hcs2/CreateRegistryTool.d.ts +2 -2
- package/dist/es/tools/hcs2/DeleteEntryTool.d.ts +2 -2
- package/dist/es/tools/hcs2/UpdateEntryTool.d.ts +2 -2
- package/dist/es/tools/hcs6/RegisterDynamicHashinalTool.d.ts +10 -10
- package/dist/es/tools/hcs6/UpdateDynamicHashinalTool.d.ts +8 -8
- package/dist/es/tools/inscriber/InscribeFromBufferTool.d.ts +5 -4
- package/dist/es/tools/inscriber/InscribeFromFileTool.d.ts +2 -2
- package/dist/es/tools/inscriber/InscribeFromUrlTool.d.ts +4 -4
- package/dist/es/tools/inscriber/InscribeHashinalTool.d.ts +3 -3
- package/dist/es/types/inscription-response.d.ts +8 -0
- package/dist/es/types/tx-results.d.ts +15 -0
- package/dist/es/utils/CodedError.d.ts +4 -0
- package/dist/es/utils/inscription-utils.d.ts +21 -0
- package/dist/es/validation/hip412-schemas.d.ts +2 -2
- package/dist/umd/builders/hcs10/hcs10-builder.d.ts +1 -0
- package/dist/umd/builders/hcs2/hcs2-builder.d.ts +8 -7
- package/dist/umd/builders/hcs6/hcs6-builder.d.ts +5 -4
- package/dist/umd/builders/inscriber/inscriber-builder.d.ts +32 -1
- package/dist/umd/index.d.ts +4 -0
- package/dist/umd/signing/bytes-registry.d.ts +17 -0
- package/dist/umd/signing/signer-provider.d.ts +45 -0
- package/dist/umd/standards-agent-kit.umd.js +1 -1
- package/dist/umd/standards-agent-kit.umd.js.map +1 -1
- package/dist/umd/tools/hcs10/InitiateConnectionTool.d.ts +4 -4
- package/dist/umd/tools/hcs2/CreateRegistryTool.d.ts +2 -2
- package/dist/umd/tools/hcs2/DeleteEntryTool.d.ts +2 -2
- package/dist/umd/tools/hcs2/UpdateEntryTool.d.ts +2 -2
- package/dist/umd/tools/hcs6/RegisterDynamicHashinalTool.d.ts +10 -10
- package/dist/umd/tools/hcs6/UpdateDynamicHashinalTool.d.ts +8 -8
- package/dist/umd/tools/inscriber/InscribeFromBufferTool.d.ts +5 -4
- package/dist/umd/tools/inscriber/InscribeFromFileTool.d.ts +2 -2
- package/dist/umd/tools/inscriber/InscribeFromUrlTool.d.ts +4 -4
- package/dist/umd/tools/inscriber/InscribeHashinalTool.d.ts +3 -3
- package/dist/umd/types/inscription-response.d.ts +8 -0
- package/dist/umd/types/tx-results.d.ts +15 -0
- package/dist/umd/utils/CodedError.d.ts +4 -0
- package/dist/umd/utils/inscription-utils.d.ts +21 -0
- package/dist/umd/validation/hip412-schemas.d.ts +2 -2
- package/package.json +10 -5
- package/src/builders/hcs10/hcs10-builder.ts +239 -6
- package/src/builders/hcs2/hcs2-builder.ts +302 -9
- package/src/builders/hcs6/hcs6-builder.ts +79 -4
- package/src/builders/inscriber/inscriber-builder.ts +235 -2
- package/src/hcs10/HCS10Client.ts +1 -1
- package/src/index.ts +5 -1
- package/src/lib/zod-render/schema-extension.ts +0 -1
- package/src/signing/bytes-registry.ts +501 -0
- package/src/signing/signer-provider.ts +120 -0
- package/src/tools/hcs2/CreateRegistryTool.ts +30 -5
- package/src/tools/hcs2/DeleteEntryTool.ts +16 -2
- package/src/tools/hcs2/MigrateRegistryTool.ts +16 -2
- package/src/tools/hcs2/QueryRegistryTool.ts +11 -2
- package/src/tools/hcs2/RegisterEntryTool.ts +17 -3
- package/src/tools/hcs2/UpdateEntryTool.ts +16 -2
- package/src/tools/hcs6/CreateDynamicRegistryTool.ts +17 -3
- package/src/tools/hcs6/RegisterDynamicHashinalTool.ts +17 -3
- package/src/tools/hcs6/UpdateDynamicHashinalTool.ts +17 -3
- package/src/tools/inscriber/InscribeFromBufferTool.ts +126 -21
- package/src/tools/inscriber/InscribeFromFileTool.ts +10 -13
- package/src/tools/inscriber/InscribeFromUrlTool.ts +15 -11
- package/src/tools/inscriber/InscribeHashinalTool.ts +40 -168
- package/src/tools/inscriber/RetrieveInscriptionTool.ts +15 -16
- package/src/types/inscription-response.ts +27 -0
- package/src/types/tx-results.ts +18 -0
- package/src/utils/CodedError.ts +8 -0
- package/src/utils/Encryption.ts +0 -2
- package/src/utils/ensure-agent-has-hbar.ts +4 -5
- package/src/utils/inscription-utils.ts +53 -0
|
@@ -1,40 +1,91 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
import { BaseHCS10TransactionTool } from "./standards-agent-kit.es10.js";
|
|
3
|
+
import { Logger } from "@hashgraphonline/standards-sdk";
|
|
4
|
+
const logger = new Logger({ module: "SendMessageToConnectionTool" });
|
|
5
|
+
const SendMessageToConnectionZodSchema = z.object({
|
|
6
|
+
targetIdentifier: z.string().optional().describe(
|
|
7
|
+
"The request key (e.g., 'req-1:0.0.6155171@0.0.6154875'), account ID (e.g., 0.0.12345) of the target agent, OR the connection number (e.g., '1', '2') from the 'list_connections' tool. Request key is most deterministic."
|
|
6
8
|
),
|
|
7
|
-
|
|
9
|
+
connectionId: z.string().optional().describe(
|
|
10
|
+
"The connection number (e.g., '1', '2') from the 'list_connections' tool."
|
|
11
|
+
),
|
|
12
|
+
agentId: z.string().optional().describe("The account ID (e.g., 0.0.12345) of the target agent."),
|
|
13
|
+
message: z.string().describe("The text message content to send."),
|
|
14
|
+
disableMonitoring: z.boolean().optional().default(false)
|
|
8
15
|
});
|
|
9
|
-
class
|
|
16
|
+
class SendMessageToConnectionTool extends BaseHCS10TransactionTool {
|
|
10
17
|
constructor(params) {
|
|
11
18
|
super(params);
|
|
12
|
-
this.name = "
|
|
13
|
-
this.description = "
|
|
14
|
-
this.specificInputSchema =
|
|
19
|
+
this.name = "send_message_to_connection";
|
|
20
|
+
this.description = "Use this to send a message to an agent you already have an active connection with. Provide the target agent's account ID (e.g., 0.0.12345) and your message. If no active connection exists, this will fail - use initiate_connection instead to create a new connection first.";
|
|
21
|
+
this.specificInputSchema = SendMessageToConnectionZodSchema;
|
|
22
|
+
this.requiresMultipleTransactions = true;
|
|
23
|
+
this.neverScheduleThisTool = true;
|
|
15
24
|
}
|
|
16
|
-
async
|
|
17
|
-
const hcs10Builder =
|
|
18
|
-
const
|
|
19
|
-
if (
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
params.showPending = args.showPending;
|
|
25
|
+
async callBuilderMethod(builder, specificArgs) {
|
|
26
|
+
const hcs10Builder = builder;
|
|
27
|
+
const targetIdentifier = specificArgs.targetIdentifier || specificArgs.agentId || specificArgs.connectionId;
|
|
28
|
+
if (!targetIdentifier) {
|
|
29
|
+
throw new Error(
|
|
30
|
+
"Either targetIdentifier, connectionId, or agentId must be provided"
|
|
31
|
+
);
|
|
24
32
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
+
const stateManager = hcs10Builder.getStateManager();
|
|
34
|
+
if (stateManager) {
|
|
35
|
+
const connectionsManager = stateManager.getConnectionsManager();
|
|
36
|
+
if (connectionsManager) {
|
|
37
|
+
try {
|
|
38
|
+
const currentAgent = stateManager.getCurrentAgent();
|
|
39
|
+
if (currentAgent && currentAgent.accountId) {
|
|
40
|
+
await connectionsManager.fetchConnectionData(
|
|
41
|
+
currentAgent.accountId
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
} catch (error) {
|
|
45
|
+
logger.debug("Could not refresh connections:", error);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
if (targetIdentifier.match(/^\d+$/)) {
|
|
49
|
+
const connections = stateManager.listConnections();
|
|
50
|
+
const connectionIndex = parseInt(targetIdentifier) - 1;
|
|
51
|
+
const establishedConnections = connections.filter(
|
|
52
|
+
(conn) => conn.status === "established" && !conn.isPending && !conn.needsConfirmation
|
|
53
|
+
);
|
|
54
|
+
if (connectionIndex >= 0 && connectionIndex < establishedConnections.length) {
|
|
55
|
+
const selectedConnection = establishedConnections[connectionIndex];
|
|
56
|
+
if (selectedConnection && selectedConnection.connectionTopicId) {
|
|
57
|
+
await hcs10Builder.sendMessageToConnection({
|
|
58
|
+
targetIdentifier: selectedConnection.connectionTopicId,
|
|
59
|
+
message: specificArgs.message,
|
|
60
|
+
disableMonitoring: specificArgs.disableMonitoring
|
|
61
|
+
});
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
if (targetIdentifier.match(/^\d+\.\d+\.\d+$/)) {
|
|
67
|
+
const connections = stateManager.listConnections();
|
|
68
|
+
const establishedConnection = connections.find(
|
|
69
|
+
(conn) => (conn.targetAccountId === targetIdentifier || conn.targetAccountId === `0.0.${targetIdentifier}`) && conn.status === "established" && !conn.isPending && !conn.needsConfirmation
|
|
70
|
+
);
|
|
71
|
+
if (establishedConnection && establishedConnection.connectionTopicId) {
|
|
72
|
+
await hcs10Builder.sendMessageToConnection({
|
|
73
|
+
targetIdentifier: establishedConnection.connectionTopicId,
|
|
74
|
+
message: specificArgs.message,
|
|
75
|
+
disableMonitoring: specificArgs.disableMonitoring
|
|
76
|
+
});
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
33
80
|
}
|
|
34
|
-
|
|
81
|
+
await hcs10Builder.sendMessageToConnection({
|
|
82
|
+
targetIdentifier,
|
|
83
|
+
message: specificArgs.message,
|
|
84
|
+
disableMonitoring: specificArgs.disableMonitoring
|
|
85
|
+
});
|
|
35
86
|
}
|
|
36
87
|
}
|
|
37
88
|
export {
|
|
38
|
-
|
|
89
|
+
SendMessageToConnectionTool
|
|
39
90
|
};
|
|
40
91
|
//# sourceMappingURL=standards-agent-kit.es12.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standards-agent-kit.es12.js","sources":["../../src/tools/hcs10/
|
|
1
|
+
{"version":3,"file":"standards-agent-kit.es12.js","sources":["../../src/tools/hcs10/SendMessageToConnectionTool.ts"],"sourcesContent":["import { z } from 'zod';\nimport { BaseHCS10TransactionTool } from './base-hcs10-tools';\nimport { HCS10Builder } from '../../builders/hcs10/hcs10-builder';\nimport { HCS10TransactionToolParams } from './hcs10-tool-params';\nimport { BaseServiceBuilder } from 'hedera-agent-kit';\nimport { Logger } from '@hashgraphonline/standards-sdk';\n\nconst logger = new Logger({ module: 'SendMessageToConnectionTool' });\n\nconst SendMessageToConnectionZodSchema = z.object({\n targetIdentifier: z\n .string()\n .optional()\n .describe(\n \"The request key (e.g., 'req-1:0.0.6155171@0.0.6154875'), account ID (e.g., 0.0.12345) of the target agent, OR the connection number (e.g., '1', '2') from the 'list_connections' tool. Request key is most deterministic.\"\n ),\n connectionId: z\n .string()\n .optional()\n .describe(\n \"The connection number (e.g., '1', '2') from the 'list_connections' tool.\"\n ),\n agentId: z\n .string()\n .optional()\n .describe('The account ID (e.g., 0.0.12345) of the target agent.'),\n message: z.string().describe('The text message content to send.'),\n disableMonitoring: z.boolean().optional().default(false),\n});\n\n/**\n * A tool to send a message to an agent over an established HCS-10 connection.\n */\nexport class SendMessageToConnectionTool extends BaseHCS10TransactionTool<\n typeof SendMessageToConnectionZodSchema\n> {\n name = 'send_message_to_connection';\n description =\n \"Use this to send a message to an agent you already have an active connection with. Provide the target agent's account ID (e.g., 0.0.12345) and your message. If no active connection exists, this will fail - use initiate_connection instead to create a new connection first.\";\n specificInputSchema = SendMessageToConnectionZodSchema;\n constructor(params: HCS10TransactionToolParams) {\n super(params);\n this.requiresMultipleTransactions = true;\n this.neverScheduleThisTool = true;\n }\n\n protected async callBuilderMethod(\n builder: BaseServiceBuilder,\n specificArgs: z.infer<typeof SendMessageToConnectionZodSchema>\n ): Promise<void> {\n const hcs10Builder = builder as HCS10Builder;\n\n const targetIdentifier =\n specificArgs.targetIdentifier ||\n specificArgs.agentId ||\n specificArgs.connectionId;\n\n if (!targetIdentifier) {\n throw new Error(\n 'Either targetIdentifier, connectionId, or agentId must be provided'\n );\n }\n\n const stateManager = hcs10Builder.getStateManager();\n if (stateManager) {\n const connectionsManager = stateManager.getConnectionsManager();\n if (connectionsManager) {\n try {\n const currentAgent = stateManager.getCurrentAgent();\n if (currentAgent && currentAgent.accountId) {\n await connectionsManager.fetchConnectionData(\n currentAgent.accountId\n );\n }\n } catch (error) {\n logger.debug('Could not refresh connections:', error);\n }\n }\n\n if (targetIdentifier.match(/^\\d+$/)) {\n const connections = stateManager.listConnections();\n const connectionIndex = parseInt(targetIdentifier) - 1; // Connection numbers are 1-based\n\n const establishedConnections = connections.filter(\n (conn) =>\n conn.status === 'established' &&\n !conn.isPending &&\n !conn.needsConfirmation\n );\n\n if (\n connectionIndex >= 0 &&\n connectionIndex < establishedConnections.length\n ) {\n const selectedConnection = establishedConnections[connectionIndex];\n if (selectedConnection && selectedConnection.connectionTopicId) {\n await hcs10Builder.sendMessageToConnection({\n targetIdentifier: selectedConnection.connectionTopicId,\n message: specificArgs.message,\n disableMonitoring: specificArgs.disableMonitoring,\n });\n return;\n }\n }\n }\n\n if (targetIdentifier.match(/^\\d+\\.\\d+\\.\\d+$/)) {\n const connections = stateManager.listConnections();\n const establishedConnection = connections.find(\n (conn) =>\n (conn.targetAccountId === targetIdentifier ||\n conn.targetAccountId === `0.0.${targetIdentifier}`) &&\n conn.status === 'established' &&\n !conn.isPending &&\n !conn.needsConfirmation\n );\n\n if (establishedConnection && establishedConnection.connectionTopicId) {\n await hcs10Builder.sendMessageToConnection({\n targetIdentifier: establishedConnection.connectionTopicId,\n message: specificArgs.message,\n disableMonitoring: specificArgs.disableMonitoring,\n });\n return;\n }\n }\n }\n\n await hcs10Builder.sendMessageToConnection({\n targetIdentifier: targetIdentifier,\n message: specificArgs.message,\n disableMonitoring: specificArgs.disableMonitoring,\n });\n }\n}\n"],"names":[],"mappings":";;;AAOA,MAAM,SAAS,IAAI,OAAO,EAAE,QAAQ,+BAA+B;AAEnE,MAAM,mCAAmC,EAAE,OAAO;AAAA,EAChD,kBAAkB,EACf,SACA,WACA;AAAA,IACC;AAAA,EAAA;AAAA,EAEJ,cAAc,EACX,SACA,WACA;AAAA,IACC;AAAA,EAAA;AAAA,EAEJ,SAAS,EACN,OAAA,EACA,SAAA,EACA,SAAS,uDAAuD;AAAA,EACnE,SAAS,EAAE,SAAS,SAAS,mCAAmC;AAAA,EAChE,mBAAmB,EAAE,QAAA,EAAU,SAAA,EAAW,QAAQ,KAAK;AACzD,CAAC;AAKM,MAAM,oCAAoC,yBAE/C;AAAA,EAKA,YAAY,QAAoC;AAC9C,UAAM,MAAM;AALd,SAAA,OAAO;AACP,SAAA,cACE;AACF,SAAA,sBAAsB;AAGpB,SAAK,+BAA+B;AACpC,SAAK,wBAAwB;AAAA,EAC/B;AAAA,EAEA,MAAgB,kBACd,SACA,cACe;AACf,UAAM,eAAe;AAErB,UAAM,mBACJ,aAAa,oBACb,aAAa,WACb,aAAa;AAEf,QAAI,CAAC,kBAAkB;AACrB,YAAM,IAAI;AAAA,QACR;AAAA,MAAA;AAAA,IAEJ;AAEA,UAAM,eAAe,aAAa,gBAAA;AAClC,QAAI,cAAc;AAChB,YAAM,qBAAqB,aAAa,sBAAA;AACxC,UAAI,oBAAoB;AACtB,YAAI;AACF,gBAAM,eAAe,aAAa,gBAAA;AAClC,cAAI,gBAAgB,aAAa,WAAW;AAC1C,kBAAM,mBAAmB;AAAA,cACvB,aAAa;AAAA,YAAA;AAAA,UAEjB;AAAA,QACF,SAAS,OAAO;AACd,iBAAO,MAAM,kCAAkC,KAAK;AAAA,QACtD;AAAA,MACF;AAEA,UAAI,iBAAiB,MAAM,OAAO,GAAG;AACnC,cAAM,cAAc,aAAa,gBAAA;AACjC,cAAM,kBAAkB,SAAS,gBAAgB,IAAI;AAErD,cAAM,yBAAyB,YAAY;AAAA,UACzC,CAAC,SACC,KAAK,WAAW,iBAChB,CAAC,KAAK,aACN,CAAC,KAAK;AAAA,QAAA;AAGV,YACE,mBAAmB,KACnB,kBAAkB,uBAAuB,QACzC;AACA,gBAAM,qBAAqB,uBAAuB,eAAe;AACjE,cAAI,sBAAsB,mBAAmB,mBAAmB;AAC9D,kBAAM,aAAa,wBAAwB;AAAA,cACzC,kBAAkB,mBAAmB;AAAA,cACrC,SAAS,aAAa;AAAA,cACtB,mBAAmB,aAAa;AAAA,YAAA,CACjC;AACD;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAEA,UAAI,iBAAiB,MAAM,iBAAiB,GAAG;AAC7C,cAAM,cAAc,aAAa,gBAAA;AACjC,cAAM,wBAAwB,YAAY;AAAA,UACxC,CAAC,UACE,KAAK,oBAAoB,oBACxB,KAAK,oBAAoB,OAAO,gBAAgB,OAClD,KAAK,WAAW,iBAChB,CAAC,KAAK,aACN,CAAC,KAAK;AAAA,QAAA;AAGV,YAAI,yBAAyB,sBAAsB,mBAAmB;AACpE,gBAAM,aAAa,wBAAwB;AAAA,YACzC,kBAAkB,sBAAsB;AAAA,YACxC,SAAS,aAAa;AAAA,YACtB,mBAAmB,aAAa;AAAA,UAAA,CACjC;AACD;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAEA,UAAM,aAAa,wBAAwB;AAAA,MACzC;AAAA,MACA,SAAS,aAAa;AAAA,MACtB,mBAAmB,aAAa;AAAA,IAAA,CACjC;AAAA,EACH;AACF;"}
|
|
@@ -1,50 +1,40 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import {
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
"The account ID (e.g., 0.0.12345) of the
|
|
2
|
+
import { BaseHCS10TransactionTool } from "./standards-agent-kit.es10.js";
|
|
3
|
+
const InitiateConnectionZodSchema = z.object({
|
|
4
|
+
targetAccountId: z.string().describe(
|
|
5
|
+
"The Hedera account ID (e.g., 0.0.12345) of the agent you want to connect with."
|
|
6
6
|
),
|
|
7
|
-
|
|
8
|
-
"
|
|
7
|
+
disableMonitor: z.boolean().optional().describe(
|
|
8
|
+
"If true, does not wait for connection confirmation. Returns immediately after sending the request."
|
|
9
9
|
),
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
memo: z.string().optional().describe(
|
|
11
|
+
'Optional memo to include with the connection request (e.g., "Hello from Alice"). If not provided, defaults to "true" or "false" based on monitoring preference.'
|
|
12
12
|
)
|
|
13
13
|
});
|
|
14
|
-
class
|
|
14
|
+
class InitiateConnectionTool extends BaseHCS10TransactionTool {
|
|
15
15
|
constructor(params) {
|
|
16
16
|
super(params);
|
|
17
|
-
this.name = "
|
|
18
|
-
this.description =
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
Use 'lastMessagesCount' to specify how many latest messages to retrieve (default 1 when fetchLatest is true).`;
|
|
23
|
-
this.specificInputSchema = CheckMessagesZodSchema;
|
|
17
|
+
this.name = "initiate_connection";
|
|
18
|
+
this.description = "ONLY use this to START a BRAND NEW connection to an agent you have NEVER connected to before. If you already have an active connection to this agent, use send_message_to_connection instead. This creates a new connection request and waits for acceptance.";
|
|
19
|
+
this.specificInputSchema = InitiateConnectionZodSchema;
|
|
20
|
+
this.neverScheduleThisTool = true;
|
|
21
|
+
this.requiresMultipleTransactions = true;
|
|
24
22
|
}
|
|
25
|
-
async
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
targetIdentifier,
|
|
33
|
-
fetchLatest,
|
|
34
|
-
lastMessagesCount: lastMessagesCount || 1
|
|
35
|
-
});
|
|
36
|
-
const result = await hcs10Builder.execute();
|
|
37
|
-
if (result.success && "rawResult" in result && result.rawResult) {
|
|
38
|
-
const raw = result.rawResult;
|
|
39
|
-
return {
|
|
40
|
-
success: true,
|
|
41
|
-
data: raw.formattedOutput || raw.message || "Messages checked"
|
|
42
|
-
};
|
|
23
|
+
async callBuilderMethod(builder, specificArgs) {
|
|
24
|
+
const hcs10Builder = builder;
|
|
25
|
+
const params = {
|
|
26
|
+
targetAccountId: specificArgs.targetAccountId
|
|
27
|
+
};
|
|
28
|
+
if (specificArgs.disableMonitor !== void 0) {
|
|
29
|
+
params.disableMonitor = specificArgs.disableMonitor;
|
|
43
30
|
}
|
|
44
|
-
|
|
31
|
+
if (specificArgs.memo !== void 0) {
|
|
32
|
+
params.memo = specificArgs.memo;
|
|
33
|
+
}
|
|
34
|
+
await hcs10Builder.initiateConnection(params);
|
|
45
35
|
}
|
|
46
36
|
}
|
|
47
37
|
export {
|
|
48
|
-
|
|
38
|
+
InitiateConnectionTool
|
|
49
39
|
};
|
|
50
40
|
//# sourceMappingURL=standards-agent-kit.es13.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standards-agent-kit.es13.js","sources":["../../src/tools/hcs10/
|
|
1
|
+
{"version":3,"file":"standards-agent-kit.es13.js","sources":["../../src/tools/hcs10/InitiateConnectionTool.ts"],"sourcesContent":["import { z } from 'zod';\nimport { BaseHCS10TransactionTool } from './base-hcs10-tools';\nimport { HCS10Builder } from '../../builders/hcs10/hcs10-builder';\nimport { HCS10TransactionToolParams } from './hcs10-tool-params';\nimport { BaseServiceBuilder } from 'hedera-agent-kit';\n\nconst InitiateConnectionZodSchema = z.object({\n targetAccountId: z\n .string()\n .describe(\n 'The Hedera account ID (e.g., 0.0.12345) of the agent you want to connect with.'\n ),\n disableMonitor: z\n .boolean()\n .optional()\n .describe(\n 'If true, does not wait for connection confirmation. Returns immediately after sending the request.'\n ),\n memo: z\n .string()\n .optional()\n .describe(\n 'Optional memo to include with the connection request (e.g., \"Hello from Alice\"). If not provided, defaults to \"true\" or \"false\" based on monitoring preference.'\n ),\n});\n\n/**\n * A tool to actively START a NEW HCS-10 connection TO a target agent.\n * Requires the target agent's account ID.\n * It retrieves their profile, sends a connection request, and optionally waits for confirmation.\n * Use this tool ONLY to actively INITIATE an OUTGOING connection.\n */\nexport class InitiateConnectionTool extends BaseHCS10TransactionTool<\n typeof InitiateConnectionZodSchema\n> {\n name = 'initiate_connection';\n description =\n 'ONLY use this to START a BRAND NEW connection to an agent you have NEVER connected to before. If you already have an active connection to this agent, use send_message_to_connection instead. This creates a new connection request and waits for acceptance.';\n specificInputSchema = InitiateConnectionZodSchema;\n constructor(params: HCS10TransactionToolParams) {\n super(params);\n this.neverScheduleThisTool = true;\n this.requiresMultipleTransactions = true;\n }\n\n protected async callBuilderMethod(\n builder: BaseServiceBuilder,\n specificArgs: z.infer<typeof InitiateConnectionZodSchema>\n ): Promise<void> {\n const hcs10Builder = builder as HCS10Builder;\n const params: {\n targetAccountId: string;\n disableMonitor?: boolean;\n memo?: string;\n } = {\n targetAccountId: specificArgs.targetAccountId,\n };\n if (specificArgs.disableMonitor !== undefined) {\n params.disableMonitor = specificArgs.disableMonitor;\n }\n if (specificArgs.memo !== undefined) {\n params.memo = specificArgs.memo;\n }\n await hcs10Builder.initiateConnection(params);\n }\n}"],"names":[],"mappings":";;AAMA,MAAM,8BAA8B,EAAE,OAAO;AAAA,EAC3C,iBAAiB,EACd,OAAA,EACA;AAAA,IACC;AAAA,EAAA;AAAA,EAEJ,gBAAgB,EACb,UACA,WACA;AAAA,IACC;AAAA,EAAA;AAAA,EAEJ,MAAM,EACH,SACA,WACA;AAAA,IACC;AAAA,EAAA;AAEN,CAAC;AAQM,MAAM,+BAA+B,yBAE1C;AAAA,EAKA,YAAY,QAAoC;AAC9C,UAAM,MAAM;AALd,SAAA,OAAO;AACP,SAAA,cACE;AACF,SAAA,sBAAsB;AAGpB,SAAK,wBAAwB;AAC7B,SAAK,+BAA+B;AAAA,EACtC;AAAA,EAEA,MAAgB,kBACd,SACA,cACe;AACf,UAAM,eAAe;AACrB,UAAM,SAIF;AAAA,MACF,iBAAiB,aAAa;AAAA,IAAA;AAEhC,QAAI,aAAa,mBAAmB,QAAW;AAC7C,aAAO,iBAAiB,aAAa;AAAA,IACvC;AACA,QAAI,aAAa,SAAS,QAAW;AACnC,aAAO,OAAO,aAAa;AAAA,IAC7B;AACA,UAAM,aAAa,mBAAmB,MAAM;AAAA,EAC9C;AACF;"}
|
|
@@ -1,62 +1,40 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
accountId: z.string().optional().describe(
|
|
7
|
-
"Optional: Filter registrations by a specific Hedera account ID (e.g., 0.0.12345)."
|
|
2
|
+
import { BaseHCS10QueryTool } from "./standards-agent-kit.es10.js";
|
|
3
|
+
const ListConnectionsZodSchema = z.object({
|
|
4
|
+
includeDetails: z.boolean().optional().describe(
|
|
5
|
+
"Whether to include detailed information about each connection"
|
|
8
6
|
),
|
|
9
|
-
|
|
10
|
-
z.array(z.nativeEnum(AIAgentCapability)),
|
|
11
|
-
z.array(z.string()),
|
|
12
|
-
z.string()
|
|
13
|
-
]).optional().transform((val) => {
|
|
14
|
-
if (!val) {
|
|
15
|
-
return void 0;
|
|
16
|
-
}
|
|
17
|
-
if (typeof val === "string") {
|
|
18
|
-
return NaturalLanguageMapper.parseCapabilities(val);
|
|
19
|
-
}
|
|
20
|
-
if (Array.isArray(val) && val.length > 0 && typeof val[0] === "string") {
|
|
21
|
-
return NaturalLanguageMapper.parseTagsOrCapabilities(val);
|
|
22
|
-
}
|
|
23
|
-
return val;
|
|
24
|
-
}).describe(
|
|
25
|
-
'Optional: Filter by capabilities/tags like "ai", "data", "analytics". Can be natural language terms or capability numbers.'
|
|
26
|
-
)
|
|
7
|
+
showPending: z.boolean().optional().describe("Whether to include pending connection requests")
|
|
27
8
|
});
|
|
28
|
-
class
|
|
9
|
+
class ListConnectionsTool extends BaseHCS10QueryTool {
|
|
29
10
|
constructor(params) {
|
|
30
11
|
super(params);
|
|
31
|
-
this.name = "
|
|
32
|
-
this.description =
|
|
33
|
-
this.specificInputSchema =
|
|
12
|
+
this.name = "list_connections";
|
|
13
|
+
this.description = "Lists all active HCS-10 connections. Use this FIRST before sending messages to check if you already have an active connection to a target agent. Shows connection details and agent information for each active connection.";
|
|
14
|
+
this.specificInputSchema = ListConnectionsZodSchema;
|
|
34
15
|
}
|
|
35
|
-
async executeQuery({
|
|
36
|
-
accountId,
|
|
37
|
-
tags
|
|
38
|
-
}) {
|
|
16
|
+
async executeQuery(args) {
|
|
39
17
|
const hcs10Builder = this.hcs10Builder;
|
|
40
18
|
const params = {};
|
|
41
|
-
if (
|
|
42
|
-
params.
|
|
19
|
+
if (args.includeDetails !== void 0) {
|
|
20
|
+
params.includeDetails = args.includeDetails;
|
|
43
21
|
}
|
|
44
|
-
if (
|
|
45
|
-
params.
|
|
22
|
+
if (args.showPending !== void 0) {
|
|
23
|
+
params.showPending = args.showPending;
|
|
46
24
|
}
|
|
47
|
-
await hcs10Builder.
|
|
25
|
+
await hcs10Builder.listConnections(params);
|
|
48
26
|
const result = await hcs10Builder.execute();
|
|
49
27
|
if (result.success && "rawResult" in result && result.rawResult) {
|
|
50
28
|
const raw = result.rawResult;
|
|
51
29
|
return {
|
|
52
30
|
success: true,
|
|
53
|
-
data: raw.formattedOutput || raw.message || "
|
|
31
|
+
data: raw.formattedOutput || raw.message || "Connections listed"
|
|
54
32
|
};
|
|
55
33
|
}
|
|
56
34
|
return result;
|
|
57
35
|
}
|
|
58
36
|
}
|
|
59
37
|
export {
|
|
60
|
-
|
|
38
|
+
ListConnectionsTool
|
|
61
39
|
};
|
|
62
40
|
//# sourceMappingURL=standards-agent-kit.es14.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standards-agent-kit.es14.js","sources":["../../src/tools/hcs10/
|
|
1
|
+
{"version":3,"file":"standards-agent-kit.es14.js","sources":["../../src/tools/hcs10/ListConnectionsTool.ts"],"sourcesContent":["import { z } from 'zod';\nimport { BaseHCS10QueryTool } from './base-hcs10-tools';\nimport { HCS10QueryToolParams } from './hcs10-tool-params';\n\n/**\n * A tool to list currently active HCS-10 connections stored in the state manager.\n * Enhanced to show more details similar to moonscape's implementation.\n */\nconst ListConnectionsZodSchema = z.object({\n includeDetails: z\n .boolean()\n .optional()\n .describe(\n 'Whether to include detailed information about each connection'\n ),\n showPending: z\n .boolean()\n .optional()\n .describe('Whether to include pending connection requests'),\n});\n\nexport class ListConnectionsTool extends BaseHCS10QueryTool<\n typeof ListConnectionsZodSchema\n> {\n name = 'list_connections';\n description =\n 'Lists all active HCS-10 connections. Use this FIRST before sending messages to check if you already have an active connection to a target agent. Shows connection details and agent information for each active connection.';\n specificInputSchema = ListConnectionsZodSchema;\n constructor(params: HCS10QueryToolParams) {\n super(params);\n }\n\n protected async executeQuery(\n args: z.infer<typeof ListConnectionsZodSchema>\n ): Promise<unknown> {\n const hcs10Builder = this.hcs10Builder;\n const params: { includeDetails?: boolean; showPending?: boolean } = {};\n if (args.includeDetails !== undefined) {\n params.includeDetails = args.includeDetails;\n }\n if (args.showPending !== undefined) {\n params.showPending = args.showPending;\n }\n await hcs10Builder.listConnections(params);\n\n const result = await hcs10Builder.execute();\n\n if (result.success && 'rawResult' in result && result.rawResult) {\n const raw = result.rawResult as { formattedOutput?: string; message?: string };\n return {\n success: true,\n data: raw.formattedOutput || raw.message || 'Connections listed'\n };\n }\n\n return result;\n }\n}"],"names":[],"mappings":";;AAQA,MAAM,2BAA2B,EAAE,OAAO;AAAA,EACxC,gBAAgB,EACb,UACA,WACA;AAAA,IACC;AAAA,EAAA;AAAA,EAEJ,aAAa,EACV,QAAA,EACA,SAAA,EACA,SAAS,gDAAgD;AAC9D,CAAC;AAEM,MAAM,4BAA4B,mBAEvC;AAAA,EAKA,YAAY,QAA8B;AACxC,UAAM,MAAM;AALd,SAAA,OAAO;AACP,SAAA,cACE;AACF,SAAA,sBAAsB;AAAA,EAGtB;AAAA,EAEA,MAAgB,aACd,MACkB;AAClB,UAAM,eAAe,KAAK;AAC1B,UAAM,SAA8D,CAAA;AACpE,QAAI,KAAK,mBAAmB,QAAW;AACrC,aAAO,iBAAiB,KAAK;AAAA,IAC/B;AACA,QAAI,KAAK,gBAAgB,QAAW;AAClC,aAAO,cAAc,KAAK;AAAA,IAC5B;AACA,UAAM,aAAa,gBAAgB,MAAM;AAEzC,UAAM,SAAS,MAAM,aAAa,QAAA;AAElC,QAAI,OAAO,WAAW,eAAe,UAAU,OAAO,WAAW;AAC/D,YAAM,MAAM,OAAO;AACnB,aAAO;AAAA,QACL,SAAS;AAAA,QACT,MAAM,IAAI,mBAAmB,IAAI,WAAW;AAAA,MAAA;AAAA,IAEhD;AAEA,WAAO;AAAA,EACT;AACF;"}
|
|
@@ -1,72 +1,50 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import {
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
"
|
|
2
|
+
import { BaseHCS10QueryTool } from "./standards-agent-kit.es10.js";
|
|
3
|
+
const CheckMessagesZodSchema = z.object({
|
|
4
|
+
targetIdentifier: z.string().describe(
|
|
5
|
+
"The account ID (e.g., 0.0.12345) of the target agent OR the connection number (e.g., '1', '2') from the 'list_connections' tool to check messages for."
|
|
6
6
|
),
|
|
7
|
-
|
|
8
|
-
"
|
|
7
|
+
fetchLatest: z.boolean().optional().default(false).describe(
|
|
8
|
+
"Set to true to fetch the latest messages even if they have been seen before, ignoring the last checked timestamp. Defaults to false (fetching only new messages)."
|
|
9
9
|
),
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
amount: z.number(),
|
|
13
|
-
collectorAccount: z.string().optional()
|
|
14
|
-
})
|
|
15
|
-
).optional().describe(
|
|
16
|
-
"Array of HBAR fee amounts to charge per message (with optional collector accounts)."
|
|
17
|
-
),
|
|
18
|
-
tokenFees: z.array(
|
|
19
|
-
z.object({
|
|
20
|
-
amount: z.number(),
|
|
21
|
-
tokenId: z.string(),
|
|
22
|
-
collectorAccount: z.string().optional()
|
|
23
|
-
})
|
|
24
|
-
).optional().describe(
|
|
25
|
-
"Array of token fee amounts and IDs to charge per message (with optional collector accounts)."
|
|
26
|
-
),
|
|
27
|
-
exemptAccountIds: z.array(z.string()).optional().describe(
|
|
28
|
-
"Array of account IDs to exempt from ALL fees set in this request."
|
|
29
|
-
),
|
|
30
|
-
monitorDurationSeconds: z.number().optional().describe(
|
|
31
|
-
"How long to monitor for incoming requests in seconds. Default is 120."
|
|
32
|
-
),
|
|
33
|
-
defaultCollectorAccount: z.string().optional().describe(
|
|
34
|
-
"Default account to collect fees if not specified at the fee level. Defaults to the agent account."
|
|
10
|
+
lastMessagesCount: z.number().int().positive().optional().describe(
|
|
11
|
+
"When fetchLatest is true, specifies how many of the most recent messages to retrieve. Defaults to 1."
|
|
35
12
|
)
|
|
36
13
|
});
|
|
37
|
-
class
|
|
14
|
+
class CheckMessagesTool extends BaseHCS10QueryTool {
|
|
38
15
|
constructor(params) {
|
|
39
16
|
super(params);
|
|
40
|
-
this.name = "
|
|
41
|
-
this.description =
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
17
|
+
this.name = "check_messages";
|
|
18
|
+
this.description = `Checks for and retrieves messages from an active connection.
|
|
19
|
+
Identify the target agent using their account ID (e.g., 0.0.12345) or the connection number shown in 'list_connections'.
|
|
20
|
+
By default, it only retrieves messages newer than the last check.
|
|
21
|
+
Use 'fetchLatest: true' to get the most recent messages regardless of when they arrived.
|
|
22
|
+
Use 'lastMessagesCount' to specify how many latest messages to retrieve (default 1 when fetchLatest is true).`;
|
|
23
|
+
this.specificInputSchema = CheckMessagesZodSchema;
|
|
45
24
|
}
|
|
46
|
-
async
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
monitorDurationSeconds: specificArgs.monitorDurationSeconds
|
|
57
|
-
},
|
|
58
|
-
hbarFees: specificArgs.hbarFees || [],
|
|
59
|
-
tokenFees: specificArgs.tokenFees || [],
|
|
60
|
-
...specificArgs.exemptAccountIds !== void 0 && {
|
|
61
|
-
exemptAccountIds: specificArgs.exemptAccountIds
|
|
62
|
-
},
|
|
63
|
-
...specificArgs.defaultCollectorAccount !== void 0 && {
|
|
64
|
-
defaultCollectorAccount: specificArgs.defaultCollectorAccount
|
|
65
|
-
}
|
|
25
|
+
async executeQuery({
|
|
26
|
+
targetIdentifier,
|
|
27
|
+
fetchLatest,
|
|
28
|
+
lastMessagesCount
|
|
29
|
+
}) {
|
|
30
|
+
const hcs10Builder = this.hcs10Builder;
|
|
31
|
+
await hcs10Builder.checkMessages({
|
|
32
|
+
targetIdentifier,
|
|
33
|
+
fetchLatest,
|
|
34
|
+
lastMessagesCount: lastMessagesCount || 1
|
|
66
35
|
});
|
|
36
|
+
const result = await hcs10Builder.execute();
|
|
37
|
+
if (result.success && "rawResult" in result && result.rawResult) {
|
|
38
|
+
const raw = result.rawResult;
|
|
39
|
+
return {
|
|
40
|
+
success: true,
|
|
41
|
+
data: raw.formattedOutput || raw.message || "Messages checked"
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
return result;
|
|
67
45
|
}
|
|
68
46
|
}
|
|
69
47
|
export {
|
|
70
|
-
|
|
48
|
+
CheckMessagesTool
|
|
71
49
|
};
|
|
72
50
|
//# sourceMappingURL=standards-agent-kit.es15.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standards-agent-kit.es15.js","sources":["../../src/tools/hcs10/
|
|
1
|
+
{"version":3,"file":"standards-agent-kit.es15.js","sources":["../../src/tools/hcs10/CheckMessagesTool.ts"],"sourcesContent":["import { z } from 'zod';\nimport { BaseHCS10QueryTool } from './base-hcs10-tools';\nimport { HCS10QueryToolParams } from './hcs10-tool-params';\n\n/**\n * A tool to check for new messages on an active HCS-10 connection topic,\n * or optionally fetch the latest messages regardless of timestamp.\n */\nconst CheckMessagesZodSchema = z.object({\n targetIdentifier: z\n .string()\n .describe(\n \"The account ID (e.g., 0.0.12345) of the target agent OR the connection number (e.g., '1', '2') from the 'list_connections' tool to check messages for.\"\n ),\n fetchLatest: z\n .boolean()\n .optional()\n .default(false)\n .describe(\n 'Set to true to fetch the latest messages even if they have been seen before, ignoring the last checked timestamp. Defaults to false (fetching only new messages).'\n ),\n lastMessagesCount: z\n .number()\n .int()\n .positive()\n .optional()\n .describe(\n 'When fetchLatest is true, specifies how many of the most recent messages to retrieve. Defaults to 1.'\n ),\n});\n\nexport class CheckMessagesTool extends BaseHCS10QueryTool<\n typeof CheckMessagesZodSchema\n> {\n name = 'check_messages';\n description = `Checks for and retrieves messages from an active connection.\nIdentify the target agent using their account ID (e.g., 0.0.12345) or the connection number shown in 'list_connections'.\nBy default, it only retrieves messages newer than the last check.\nUse 'fetchLatest: true' to get the most recent messages regardless of when they arrived.\nUse 'lastMessagesCount' to specify how many latest messages to retrieve (default 1 when fetchLatest is true).`;\n specificInputSchema = CheckMessagesZodSchema;\n constructor(params: HCS10QueryToolParams) {\n super(params);\n }\n\n protected async executeQuery({\n targetIdentifier,\n fetchLatest,\n lastMessagesCount,\n }: z.infer<typeof CheckMessagesZodSchema>): Promise<unknown> {\n const hcs10Builder = this.hcs10Builder;\n await hcs10Builder.checkMessages({\n targetIdentifier,\n fetchLatest,\n lastMessagesCount: lastMessagesCount || 1,\n });\n\n const result = await hcs10Builder.execute();\n\n if (result.success && 'rawResult' in result && result.rawResult) {\n const raw = result.rawResult as {\n formattedOutput?: string;\n message?: string;\n };\n return {\n success: true,\n data: raw.formattedOutput || raw.message || 'Messages checked',\n };\n }\n\n return result;\n }\n}"],"names":[],"mappings":";;AAQA,MAAM,yBAAyB,EAAE,OAAO;AAAA,EACtC,kBAAkB,EACf,OAAA,EACA;AAAA,IACC;AAAA,EAAA;AAAA,EAEJ,aAAa,EACV,QAAA,EACA,WACA,QAAQ,KAAK,EACb;AAAA,IACC;AAAA,EAAA;AAAA,EAEJ,mBAAmB,EAChB,SACA,MACA,SAAA,EACA,SAAA,EACA;AAAA,IACC;AAAA,EAAA;AAEN,CAAC;AAEM,MAAM,0BAA0B,mBAErC;AAAA,EAQA,YAAY,QAA8B;AACxC,UAAM,MAAM;AARd,SAAA,OAAO;AACP,SAAA,cAAc;AAAA;AAAA;AAAA;AAAA;AAKd,SAAA,sBAAsB;AAAA,EAGtB;AAAA,EAEA,MAAgB,aAAa;AAAA,IAC3B;AAAA,IACA;AAAA,IACA;AAAA,EAAA,GAC2D;AAC3D,UAAM,eAAe,KAAK;AAC1B,UAAM,aAAa,cAAc;AAAA,MAC/B;AAAA,MACA;AAAA,MACA,mBAAmB,qBAAqB;AAAA,IAAA,CACzC;AAED,UAAM,SAAS,MAAM,aAAa,QAAA;AAElC,QAAI,OAAO,WAAW,eAAe,UAAU,OAAO,WAAW;AAC/D,YAAM,MAAM,OAAO;AAInB,aAAO;AAAA,QACL,SAAS;AAAA,QACT,MAAM,IAAI,mBAAmB,IAAI,WAAW;AAAA,MAAA;AAAA,IAEhD;AAEA,WAAO;AAAA,EACT;AACF;"}
|
|
@@ -1,35 +1,62 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
import { AIAgentCapability } from "@hashgraphonline/standards-sdk";
|
|
3
|
+
import { BaseHCS10QueryTool } from "./standards-agent-kit.es10.js";
|
|
4
|
+
import { NaturalLanguageMapper } from "./standards-agent-kit.es22.js";
|
|
5
|
+
const FindRegistrationsZodSchema = z.object({
|
|
6
|
+
accountId: z.string().optional().describe(
|
|
7
|
+
"Optional: Filter registrations by a specific Hedera account ID (e.g., 0.0.12345)."
|
|
6
8
|
),
|
|
7
|
-
|
|
8
|
-
|
|
9
|
+
tags: z.union([
|
|
10
|
+
z.array(z.nativeEnum(AIAgentCapability)),
|
|
11
|
+
z.array(z.string()),
|
|
12
|
+
z.string()
|
|
13
|
+
]).optional().transform((val) => {
|
|
14
|
+
if (!val) {
|
|
15
|
+
return void 0;
|
|
16
|
+
}
|
|
17
|
+
if (typeof val === "string") {
|
|
18
|
+
return NaturalLanguageMapper.parseCapabilities(val);
|
|
19
|
+
}
|
|
20
|
+
if (Array.isArray(val) && val.length > 0 && typeof val[0] === "string") {
|
|
21
|
+
return NaturalLanguageMapper.parseTagsOrCapabilities(val);
|
|
22
|
+
}
|
|
23
|
+
return val;
|
|
24
|
+
}).describe(
|
|
25
|
+
'Optional: Filter by capabilities/tags like "ai", "data", "analytics". Can be natural language terms or capability numbers.'
|
|
9
26
|
)
|
|
10
27
|
});
|
|
11
|
-
class
|
|
28
|
+
class FindRegistrationsTool extends BaseHCS10QueryTool {
|
|
12
29
|
constructor(params) {
|
|
13
30
|
super(params);
|
|
14
|
-
this.name = "
|
|
15
|
-
this.description = '
|
|
16
|
-
this.specificInputSchema =
|
|
31
|
+
this.name = "find_registrations";
|
|
32
|
+
this.description = 'Searches the configured agent registry for HCS-10 agents. You can filter by account ID or tags/capabilities using natural language like "ai", "data processing", "analytics". Returns basic registration info.';
|
|
33
|
+
this.specificInputSchema = FindRegistrationsZodSchema;
|
|
17
34
|
}
|
|
18
35
|
async executeQuery({
|
|
19
|
-
|
|
20
|
-
|
|
36
|
+
accountId,
|
|
37
|
+
tags
|
|
21
38
|
}) {
|
|
22
39
|
const hcs10Builder = this.hcs10Builder;
|
|
23
|
-
const params = {
|
|
24
|
-
if (
|
|
25
|
-
params.
|
|
40
|
+
const params = {};
|
|
41
|
+
if (accountId) {
|
|
42
|
+
params.accountId = accountId;
|
|
26
43
|
}
|
|
27
|
-
|
|
44
|
+
if (tags) {
|
|
45
|
+
params.tags = tags;
|
|
46
|
+
}
|
|
47
|
+
await hcs10Builder.findRegistrations(params);
|
|
28
48
|
const result = await hcs10Builder.execute();
|
|
29
|
-
|
|
49
|
+
if (result.success && "rawResult" in result && result.rawResult) {
|
|
50
|
+
const raw = result.rawResult;
|
|
51
|
+
return {
|
|
52
|
+
success: true,
|
|
53
|
+
data: raw.formattedOutput || raw.message || "Registrations searched"
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
return result;
|
|
30
57
|
}
|
|
31
58
|
}
|
|
32
59
|
export {
|
|
33
|
-
|
|
60
|
+
FindRegistrationsTool
|
|
34
61
|
};
|
|
35
62
|
//# sourceMappingURL=standards-agent-kit.es16.js.map
|