@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,6 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { BaseHCS2QueryTool } from './base-hcs2-tools';
|
|
3
3
|
import { CallbackManagerForToolRun } from '@langchain/core/callbacks/manager';
|
|
4
|
+
import { isWalletBytesResponse, type RegistryOperationResult } from '../../types/tx-results';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Schema for deleting an entry from HCS-2
|
|
@@ -37,7 +38,7 @@ export class DeleteEntryTool extends BaseHCS2QueryTool<typeof deleteEntrySchema>
|
|
|
37
38
|
_runManager?: CallbackManagerForToolRun
|
|
38
39
|
): Promise<unknown> {
|
|
39
40
|
try {
|
|
40
|
-
const result = await this.hcs2Builder.deleteEntry(
|
|
41
|
+
const result: RegistryOperationResult = await this.hcs2Builder.deleteEntry(
|
|
41
42
|
params.registryTopicId,
|
|
42
43
|
{
|
|
43
44
|
uid: params.uid,
|
|
@@ -45,10 +46,23 @@ export class DeleteEntryTool extends BaseHCS2QueryTool<typeof deleteEntrySchema>
|
|
|
45
46
|
}
|
|
46
47
|
);
|
|
47
48
|
|
|
48
|
-
if (!result.success) {
|
|
49
|
+
if (!('success' in result) || !result.success) {
|
|
49
50
|
throw new Error(result.error || 'Failed to delete entry');
|
|
50
51
|
}
|
|
51
52
|
|
|
53
|
+
if (isWalletBytesResponse(result)) {
|
|
54
|
+
const txBytes = result.transactionBytes;
|
|
55
|
+
return {
|
|
56
|
+
message: 'I prepared an unsigned transaction to delete the HCS-2 registry entry. Please review and approve to submit.',
|
|
57
|
+
transactionBytes: txBytes,
|
|
58
|
+
metadata: {
|
|
59
|
+
transactionBytes: txBytes,
|
|
60
|
+
pendingApproval: true,
|
|
61
|
+
description: `Delete HCS-2 entry (registry ${params.registryTopicId}, uid ${params.uid})`,
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
52
66
|
return `Successfully deleted entry from HCS-2 registry!\n\nRegistry Topic: ${params.registryTopicId}\nUID: ${params.uid}${params.memo ? `\nMemo: ${params.memo}` : ''}\n\nThe entry has been removed from the registry.`;
|
|
53
67
|
} catch (error) {
|
|
54
68
|
const errorMessage = error instanceof Error ? error.message : 'Failed to delete entry';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { BaseHCS2QueryTool } from './base-hcs2-tools';
|
|
3
3
|
import { CallbackManagerForToolRun } from '@langchain/core/callbacks/manager';
|
|
4
|
+
import { isWalletBytesResponse, type RegistryOperationResult } from '../../types/tx-results';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Schema for migrating an HCS-2 registry
|
|
@@ -42,7 +43,7 @@ export class MigrateRegistryTool extends BaseHCS2QueryTool<typeof migrateRegistr
|
|
|
42
43
|
_runManager?: CallbackManagerForToolRun
|
|
43
44
|
): Promise<unknown> {
|
|
44
45
|
try {
|
|
45
|
-
const result = await this.hcs2Builder.migrateRegistry(
|
|
46
|
+
const result: RegistryOperationResult = await this.hcs2Builder.migrateRegistry(
|
|
46
47
|
params.registryTopicId,
|
|
47
48
|
{
|
|
48
49
|
targetTopicId: params.targetTopicId,
|
|
@@ -51,10 +52,23 @@ export class MigrateRegistryTool extends BaseHCS2QueryTool<typeof migrateRegistr
|
|
|
51
52
|
}
|
|
52
53
|
);
|
|
53
54
|
|
|
54
|
-
if (!result.success) {
|
|
55
|
+
if (!('success' in result) || !result.success) {
|
|
55
56
|
throw new Error(result.error || 'Failed to migrate registry');
|
|
56
57
|
}
|
|
57
58
|
|
|
59
|
+
if (isWalletBytesResponse(result)) {
|
|
60
|
+
const txBytes = result.transactionBytes;
|
|
61
|
+
return {
|
|
62
|
+
message: 'I prepared an unsigned transaction to migrate the HCS-2 registry. Please review and approve to submit.',
|
|
63
|
+
transactionBytes: txBytes,
|
|
64
|
+
metadata: {
|
|
65
|
+
transactionBytes: txBytes,
|
|
66
|
+
pendingApproval: true,
|
|
67
|
+
description: `Migrate HCS-2 registry (from ${params.registryTopicId} to ${params.targetTopicId})`,
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
|
|
58
72
|
return `Successfully migrated HCS-2 registry!\n\nFrom Registry Topic: ${params.registryTopicId}\nTo Target Topic: ${params.targetTopicId}${params.metadata ? `\nMetadata: ${params.metadata}` : ''}${params.memo ? `\nMemo: ${params.memo}` : ''}\n\nThe registry has been migrated to the new topic.`;
|
|
59
73
|
} catch (error) {
|
|
60
74
|
const errorMessage = error instanceof Error ? error.message : 'Failed to migrate registry';
|
|
@@ -34,7 +34,7 @@ const queryRegistrySchema = z.object({
|
|
|
34
34
|
*/
|
|
35
35
|
export class QueryRegistryTool extends BaseHCS2QueryTool<typeof queryRegistrySchema> {
|
|
36
36
|
name = 'queryHCS2Registry';
|
|
37
|
-
description = 'Query entries from an HCS-2 registry'
|
|
37
|
+
description = 'Query entries from an HCS-2 registry (standard HCS-2). Retrieves indexed or latest entries and returns a structured summary.'
|
|
38
38
|
|
|
39
39
|
get specificInputSchema() {
|
|
40
40
|
return queryRegistrySchema;
|
|
@@ -50,9 +50,18 @@ export class QueryRegistryTool extends BaseHCS2QueryTool<typeof queryRegistrySch
|
|
|
50
50
|
skip: params.skip,
|
|
51
51
|
});
|
|
52
52
|
|
|
53
|
+
const typeVal = (registry as unknown as { registryType: unknown }).registryType;
|
|
54
|
+
const isIndexed =
|
|
55
|
+
typeVal === 0 ||
|
|
56
|
+
typeVal === '0' ||
|
|
57
|
+
String(typeVal).toLowerCase() === 'indexed' ||
|
|
58
|
+
String(typeVal).toLowerCase() === 'index' ||
|
|
59
|
+
String(typeVal).toLowerCase() === 'index_topic' ||
|
|
60
|
+
String(typeVal).toLowerCase() === 'indexed_registry';
|
|
61
|
+
|
|
53
62
|
return {
|
|
54
63
|
topicId: registry.topicId,
|
|
55
|
-
registryType:
|
|
64
|
+
registryType: isIndexed ? 'indexed' : 'non-indexed',
|
|
56
65
|
ttl: registry.ttl,
|
|
57
66
|
totalEntries: registry.entries.length,
|
|
58
67
|
entries: registry.entries.map(entry => ({
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { BaseHCS2QueryTool } from './base-hcs2-tools';
|
|
3
3
|
import { CallbackManagerForToolRun } from '@langchain/core/callbacks/manager';
|
|
4
|
+
import { isWalletBytesResponse, type RegistryOperationResult } from '../../types/tx-results';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Schema for registering an entry in HCS-2
|
|
@@ -30,7 +31,7 @@ const registerEntrySchema = z.object({
|
|
|
30
31
|
*/
|
|
31
32
|
export class RegisterEntryTool extends BaseHCS2QueryTool<typeof registerEntrySchema> {
|
|
32
33
|
name = 'registerHCS2Entry';
|
|
33
|
-
description = 'Register
|
|
34
|
+
description = 'Register an entry in an HCS-2 registry (standard HCS-2). Use this to add a target topic to an existing HCS-2 registry.'
|
|
34
35
|
|
|
35
36
|
get specificInputSchema(): typeof registerEntrySchema {
|
|
36
37
|
return registerEntrySchema;
|
|
@@ -41,7 +42,7 @@ export class RegisterEntryTool extends BaseHCS2QueryTool<typeof registerEntrySch
|
|
|
41
42
|
_runManager?: CallbackManagerForToolRun
|
|
42
43
|
): Promise<unknown> {
|
|
43
44
|
try {
|
|
44
|
-
const result = await this.hcs2Builder.registerEntry(
|
|
45
|
+
const result: RegistryOperationResult = await this.hcs2Builder.registerEntry(
|
|
45
46
|
params.registryTopicId,
|
|
46
47
|
{
|
|
47
48
|
targetTopicId: params.targetTopicId,
|
|
@@ -50,10 +51,23 @@ export class RegisterEntryTool extends BaseHCS2QueryTool<typeof registerEntrySch
|
|
|
50
51
|
}
|
|
51
52
|
);
|
|
52
53
|
|
|
53
|
-
if (!result.success) {
|
|
54
|
+
if (!('success' in result) || !result.success) {
|
|
54
55
|
throw new Error(result.error || 'Failed to register entry');
|
|
55
56
|
}
|
|
56
57
|
|
|
58
|
+
if (isWalletBytesResponse(result)) {
|
|
59
|
+
const txBytes = result.transactionBytes;
|
|
60
|
+
return {
|
|
61
|
+
message: 'I prepared an unsigned transaction to register the entry in the HCS-2 registry. Please review and approve to submit.',
|
|
62
|
+
transactionBytes: txBytes,
|
|
63
|
+
metadata: {
|
|
64
|
+
transactionBytes: txBytes,
|
|
65
|
+
pendingApproval: true,
|
|
66
|
+
description: `Register HCS-2 entry (registry ${params.registryTopicId} -> target ${params.targetTopicId})`,
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
57
71
|
return `Successfully registered entry in HCS-2 registry!\n\nRegistry Topic: ${params.registryTopicId}\nTarget Topic ID: ${params.targetTopicId}${params.metadata ? `\nMetadata: ${params.metadata}` : ''}${params.memo ? `\nMemo: ${params.memo}` : ''}\n\nThe entry has been added to the registry.`;
|
|
58
72
|
} catch (error) {
|
|
59
73
|
const errorMessage = error instanceof Error ? error.message : 'Failed to register entry';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { BaseHCS2QueryTool } from './base-hcs2-tools';
|
|
3
3
|
import { CallbackManagerForToolRun } from '@langchain/core/callbacks/manager';
|
|
4
|
+
import { isWalletBytesResponse, type RegistryOperationResult } from '../../types/tx-results';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Schema for updating an entry in HCS-2
|
|
@@ -45,7 +46,7 @@ export class UpdateEntryTool extends BaseHCS2QueryTool<typeof updateEntrySchema>
|
|
|
45
46
|
_runManager?: CallbackManagerForToolRun
|
|
46
47
|
): Promise<unknown> {
|
|
47
48
|
try {
|
|
48
|
-
const result = await this.hcs2Builder.updateEntry(
|
|
49
|
+
const result: RegistryOperationResult = await this.hcs2Builder.updateEntry(
|
|
49
50
|
params.registryTopicId,
|
|
50
51
|
{
|
|
51
52
|
targetTopicId: params.targetTopicId,
|
|
@@ -55,10 +56,23 @@ export class UpdateEntryTool extends BaseHCS2QueryTool<typeof updateEntrySchema>
|
|
|
55
56
|
}
|
|
56
57
|
);
|
|
57
58
|
|
|
58
|
-
if (!result.success) {
|
|
59
|
+
if (!('success' in result) || !result.success) {
|
|
59
60
|
throw new Error(result.error || 'Failed to update entry');
|
|
60
61
|
}
|
|
61
62
|
|
|
63
|
+
if (isWalletBytesResponse(result)) {
|
|
64
|
+
const txBytes = result.transactionBytes;
|
|
65
|
+
return {
|
|
66
|
+
message: 'I prepared an unsigned transaction to update the HCS-2 registry entry. Please review and approve to submit.',
|
|
67
|
+
transactionBytes: txBytes,
|
|
68
|
+
metadata: {
|
|
69
|
+
transactionBytes: txBytes,
|
|
70
|
+
pendingApproval: true,
|
|
71
|
+
description: `Update HCS-2 entry (registry ${params.registryTopicId}, uid ${params.uid} -> ${params.targetTopicId})`,
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
62
76
|
return `Successfully updated entry in HCS-2 registry!\n\nRegistry Topic: ${params.registryTopicId}\nUID: ${params.uid}\nNew Target Topic ID: ${params.targetTopicId}${params.metadata ? `\nMetadata: ${params.metadata}` : ''}${params.memo ? `\nMemo: ${params.memo}` : ''}\n\nThe entry has been updated in the registry.`;
|
|
63
77
|
} catch (error) {
|
|
64
78
|
const errorMessage = error instanceof Error ? error.message : 'Failed to update entry';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { BaseHCS6QueryTool } from './base-hcs6-tools';
|
|
3
|
+
import { isWalletBytesResponse } from '../../types/tx-results';
|
|
3
4
|
import { HCS6QueryToolParams } from './hcs6-tool-params';
|
|
4
5
|
import { CallbackManagerForToolRun } from '@langchain/core/callbacks/manager';
|
|
5
6
|
|
|
@@ -44,10 +45,23 @@ export class CreateDynamicRegistryTool extends BaseHCS6QueryTool<typeof CreateDy
|
|
|
44
45
|
submitKey: params.submitKey,
|
|
45
46
|
});
|
|
46
47
|
|
|
47
|
-
if (!result.success) {
|
|
48
|
-
throw new Error(result.error || 'Failed to create dynamic registry');
|
|
48
|
+
if (!('success' in result) || !result.success) {
|
|
49
|
+
throw new Error((result as any).error || 'Failed to create dynamic registry');
|
|
49
50
|
}
|
|
50
51
|
|
|
51
|
-
|
|
52
|
+
if (isWalletBytesResponse(result)) {
|
|
53
|
+
const txBytes = result.transactionBytes;
|
|
54
|
+
return {
|
|
55
|
+
message: 'I prepared an unsigned transaction to create your HCS-6 dynamic registry. Please review and approve to submit.',
|
|
56
|
+
transactionBytes: txBytes,
|
|
57
|
+
metadata: {
|
|
58
|
+
transactionBytes: txBytes,
|
|
59
|
+
pendingApproval: true,
|
|
60
|
+
description: `Create HCS-6 dynamic registry (TTL: ${params.ttl}s)`,
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return `Successfully created HCS-6 dynamic registry!\n\nTopic ID: ${(result as any).topicId}\nTTL: ${params.ttl} seconds\n\nYou can now register dynamic hashinals to this registry using the topic ID.`;
|
|
52
66
|
}
|
|
53
67
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { BaseHCS6QueryTool } from './base-hcs6-tools';
|
|
3
|
+
import { isWalletBytesResponse } from '../../types/tx-results';
|
|
3
4
|
import { HCS6QueryToolParams } from './hcs6-tool-params';
|
|
4
5
|
import { CallbackManagerForToolRun } from '@langchain/core/callbacks/manager';
|
|
5
6
|
|
|
@@ -60,10 +61,23 @@ export class RegisterDynamicHashinalTool extends BaseHCS6QueryTool<typeof Regist
|
|
|
60
61
|
submitKey: params.submitKey,
|
|
61
62
|
});
|
|
62
63
|
|
|
63
|
-
if (!result.success) {
|
|
64
|
-
throw new Error(result.error || 'Failed to register dynamic hashinal');
|
|
64
|
+
if (!('success' in result) || !result.success) {
|
|
65
|
+
throw new Error((result as any).error || 'Failed to register dynamic hashinal');
|
|
65
66
|
}
|
|
66
67
|
|
|
67
|
-
|
|
68
|
+
if (isWalletBytesResponse(result as any)) {
|
|
69
|
+
const txBytes = (result as any).transactionBytes as string;
|
|
70
|
+
return {
|
|
71
|
+
message: 'I prepared an unsigned transaction to register a dynamic hashinal. Please review and approve to submit.',
|
|
72
|
+
transactionBytes: txBytes,
|
|
73
|
+
metadata: {
|
|
74
|
+
transactionBytes: txBytes,
|
|
75
|
+
pendingApproval: true,
|
|
76
|
+
description: `Register dynamic hashinal${params.memo ? ` (Memo: ${params.memo})` : ''}`,
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return `Successfully registered dynamic hashinal!\n\nRegistry Topic ID: ${(result as any).registryTopicId}\nInscription Topic ID: ${(result as any).inscriptionTopicId}${params.memo ? `\nMemo: ${params.memo}` : ''}\n\nThe dynamic hashinal has been created and can be updated using the registry topic ID.`;
|
|
68
82
|
}
|
|
69
83
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { BaseHCS6QueryTool } from './base-hcs6-tools';
|
|
3
|
+
import { isWalletBytesResponse } from '../../types/tx-results';
|
|
3
4
|
import { HCS6QueryToolParams } from './hcs6-tool-params';
|
|
4
5
|
import { CallbackManagerForToolRun } from '@langchain/core/callbacks/manager';
|
|
5
6
|
|
|
@@ -54,10 +55,23 @@ export class UpdateDynamicHashinalTool extends BaseHCS6QueryTool<typeof UpdateDy
|
|
|
54
55
|
submitKey: params.submitKey,
|
|
55
56
|
});
|
|
56
57
|
|
|
57
|
-
if (!result.success) {
|
|
58
|
-
throw new Error(result.error || 'Failed to update dynamic hashinal');
|
|
58
|
+
if (!('success' in result) || !result.success) {
|
|
59
|
+
throw new Error((result as any).error || 'Failed to update dynamic hashinal');
|
|
59
60
|
}
|
|
60
61
|
|
|
61
|
-
|
|
62
|
+
if (isWalletBytesResponse(result as any)) {
|
|
63
|
+
const txBytes = (result as any).transactionBytes as string;
|
|
64
|
+
return {
|
|
65
|
+
message: 'I prepared an unsigned transaction to update a dynamic hashinal. Please review and approve to submit.',
|
|
66
|
+
transactionBytes: txBytes,
|
|
67
|
+
metadata: {
|
|
68
|
+
transactionBytes: txBytes,
|
|
69
|
+
pendingApproval: true,
|
|
70
|
+
description: `Update dynamic hashinal (registry ${params.registryTopicId})${params.memo ? ` (Memo: ${params.memo})` : ''}`,
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return `Successfully updated dynamic hashinal!\n\nRegistry Topic ID: ${params.registryTopicId}\nInscription Topic ID: ${(result as any).inscriptionTopicId}${params.memo ? `\nUpdate Memo: ${params.memo}` : ''}\n\nThe dynamic hashinal has been updated with new content.`;
|
|
62
76
|
}
|
|
63
77
|
}
|
|
@@ -1,23 +1,54 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { BaseInscriberQueryTool } from './base-inscriber-tools';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
InscriptionOptions,
|
|
5
|
+
InscriptionResponse,
|
|
6
|
+
InscriptionResult,
|
|
7
|
+
} from '@hashgraphonline/standards-sdk';
|
|
4
8
|
import { CallbackManagerForToolRun } from '@langchain/core/callbacks/manager';
|
|
5
9
|
import { resolveContent } from '../../utils/content-resolver';
|
|
6
10
|
import { contentRefSchema } from '../../validation/content-ref-schemas';
|
|
7
11
|
import { loadConfig } from '../../config/ContentReferenceConfig';
|
|
12
|
+
import {
|
|
13
|
+
extractTopicIds,
|
|
14
|
+
buildInscriptionLinks,
|
|
15
|
+
} from '../../utils/inscription-utils';
|
|
8
16
|
|
|
9
17
|
const inscribeFromBufferSchema = z.object({
|
|
10
|
-
base64Data: z
|
|
11
|
-
.
|
|
18
|
+
base64Data: z
|
|
19
|
+
.union([z.string(), contentRefSchema])
|
|
20
|
+
.describe(
|
|
21
|
+
'Content to inscribe as base64 data, plain text, or content reference'
|
|
22
|
+
),
|
|
12
23
|
fileName: z.string().min(1).describe('Name for the inscribed content'),
|
|
13
24
|
mimeType: z.string().optional().describe('MIME type of the content'),
|
|
14
25
|
metadata: z.record(z.unknown()).optional().describe('Metadata to attach'),
|
|
15
|
-
tags: z
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
26
|
+
tags: z
|
|
27
|
+
.array(z.string())
|
|
28
|
+
.optional()
|
|
29
|
+
.describe('Tags to categorize the inscription'),
|
|
30
|
+
chunkSize: z
|
|
31
|
+
.number()
|
|
32
|
+
.int()
|
|
33
|
+
.positive()
|
|
34
|
+
.optional()
|
|
35
|
+
.describe('Chunk size for large files'),
|
|
36
|
+
waitForConfirmation: z
|
|
37
|
+
.boolean()
|
|
38
|
+
.optional()
|
|
39
|
+
.describe('Wait for inscription confirmation'),
|
|
40
|
+
timeoutMs: z
|
|
41
|
+
.number()
|
|
42
|
+
.int()
|
|
43
|
+
.positive()
|
|
44
|
+
.optional()
|
|
45
|
+
.describe('Timeout in milliseconds'),
|
|
19
46
|
apiKey: z.string().optional().describe('API key for inscription service'),
|
|
20
|
-
quoteOnly: z
|
|
47
|
+
quoteOnly: z
|
|
48
|
+
.boolean()
|
|
49
|
+
.optional()
|
|
50
|
+
.default(false)
|
|
51
|
+
.describe('Return cost quote only'),
|
|
21
52
|
});
|
|
22
53
|
|
|
23
54
|
export class InscribeFromBufferTool extends BaseInscriberQueryTool<
|
|
@@ -33,19 +64,92 @@ export class InscribeFromBufferTool extends BaseInscriberQueryTool<
|
|
|
33
64
|
return inscribeFromBufferSchema;
|
|
34
65
|
}
|
|
35
66
|
|
|
67
|
+
protected override async _call(
|
|
68
|
+
args: z.infer<typeof inscribeFromBufferSchema>,
|
|
69
|
+
_runManager?: CallbackManagerForToolRun
|
|
70
|
+
): Promise<string> {
|
|
71
|
+
try {
|
|
72
|
+
const input = typeof args.base64Data === 'string' ? args.base64Data : '';
|
|
73
|
+
const buffer = /^[A-Za-z0-9+/]*={0,2}$/.test(input)
|
|
74
|
+
? Buffer.from(input, 'base64')
|
|
75
|
+
: Buffer.from(input, 'utf8');
|
|
76
|
+
|
|
77
|
+
const fileName = args.fileName;
|
|
78
|
+
const mimeType = args.mimeType;
|
|
79
|
+
|
|
80
|
+
const network = this.inscriberBuilder['hederaKit'].client.network
|
|
81
|
+
.toString()
|
|
82
|
+
.includes('mainnet')
|
|
83
|
+
? 'mainnet'
|
|
84
|
+
: 'testnet';
|
|
85
|
+
|
|
86
|
+
const options: InscriptionOptions = {
|
|
87
|
+
mode: 'file',
|
|
88
|
+
metadata: args.metadata,
|
|
89
|
+
tags: args.tags,
|
|
90
|
+
chunkSize: args.chunkSize,
|
|
91
|
+
waitForConfirmation: args.quoteOnly ? false : args.waitForConfirmation ?? true,
|
|
92
|
+
waitMaxAttempts: 60,
|
|
93
|
+
waitIntervalMs: 5000,
|
|
94
|
+
apiKey: args.apiKey,
|
|
95
|
+
network,
|
|
96
|
+
quoteOnly: args.quoteOnly,
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
const result = await this.inscriberBuilder.inscribe(
|
|
100
|
+
{ type: 'buffer', buffer, fileName, mimeType },
|
|
101
|
+
options
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
const typed = result as InscriptionResponse;
|
|
105
|
+
if (typed.confirmed && !typed.quote) {
|
|
106
|
+
const ids = extractTopicIds(typed.inscription, typed.result);
|
|
107
|
+
const { topicId, cdnUrl } = buildInscriptionLinks(ids, network, '1');
|
|
108
|
+
return JSON.stringify({
|
|
109
|
+
success: true,
|
|
110
|
+
data: `Successfully inscribed and confirmed content on the Hedera network!\n\nTransaction ID: ${
|
|
111
|
+
(typed.result as InscriptionResult)?.transactionId ?? 'unknown'
|
|
112
|
+
}\nTopic ID: ${topicId || 'N/A'}${
|
|
113
|
+
cdnUrl ? `\nView inscription: ${cdnUrl}` : ''
|
|
114
|
+
}\n\nThe inscription is now available.`,
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return JSON.stringify({
|
|
119
|
+
success: true,
|
|
120
|
+
data: `Successfully submitted inscription to the Hedera network!\n\nTransaction ID: ${
|
|
121
|
+
(typed.result as InscriptionResult)?.transactionId ?? 'unknown'
|
|
122
|
+
}\n\nThe inscription is processing and will be confirmed shortly.`,
|
|
123
|
+
});
|
|
124
|
+
} catch (error) {
|
|
125
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
126
|
+
return JSON.stringify({ success: false, error: `Inscription failed: ${errorMessage}` });
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
36
130
|
protected async executeQuery(
|
|
37
131
|
params: z.infer<typeof inscribeFromBufferSchema>,
|
|
38
132
|
_runManager?: CallbackManagerForToolRun
|
|
39
133
|
): Promise<unknown> {
|
|
40
|
-
this.validateInput(params);
|
|
41
134
|
|
|
42
135
|
const resolvedContent = await resolveContent(
|
|
43
136
|
params.base64Data,
|
|
44
137
|
params.mimeType,
|
|
45
138
|
params.fileName
|
|
46
139
|
);
|
|
140
|
+
console.log('[InscribeFromBufferTool] Resolved content bytes:', resolvedContent.buffer?.length ?? -1);
|
|
47
141
|
|
|
48
|
-
|
|
142
|
+
try {
|
|
143
|
+
this.validateContent(resolvedContent.buffer);
|
|
144
|
+
} catch (validationError) {
|
|
145
|
+
this.logger?.warn(
|
|
146
|
+
`Content validation warning: ${
|
|
147
|
+
validationError instanceof Error
|
|
148
|
+
? validationError.message
|
|
149
|
+
: String(validationError)
|
|
150
|
+
}`
|
|
151
|
+
);
|
|
152
|
+
}
|
|
49
153
|
|
|
50
154
|
const buffer = resolvedContent.buffer;
|
|
51
155
|
const resolvedMimeType = resolvedContent.mimeType || params.mimeType;
|
|
@@ -108,6 +212,7 @@ export class InscribeFromBufferTool extends BaseInscriberQueryTool<
|
|
|
108
212
|
}
|
|
109
213
|
|
|
110
214
|
try {
|
|
215
|
+
console.log('[InscribeFromBufferTool] Calling inscribe with fileName:', resolvedFileName, 'mime:', resolvedMimeType);
|
|
111
216
|
const result = await this.executeInscription(
|
|
112
217
|
buffer,
|
|
113
218
|
resolvedFileName,
|
|
@@ -115,8 +220,10 @@ export class InscribeFromBufferTool extends BaseInscriberQueryTool<
|
|
|
115
220
|
options,
|
|
116
221
|
params.timeoutMs
|
|
117
222
|
);
|
|
223
|
+
console.log('[InscribeFromBufferTool] Inscribe result (confirmed):', Boolean((result as any)?.confirmed));
|
|
118
224
|
return this.formatInscriptionResult(result, options);
|
|
119
225
|
} catch (error) {
|
|
226
|
+
console.warn('[InscribeFromBufferTool] Error during inscription:', error);
|
|
120
227
|
const errorMessage =
|
|
121
228
|
error instanceof Error
|
|
122
229
|
? error.message
|
|
@@ -218,27 +325,25 @@ export class InscribeFromBufferTool extends BaseInscriberQueryTool<
|
|
|
218
325
|
result: Awaited<ReturnType<typeof this.inscriberBuilder.inscribe>>,
|
|
219
326
|
options: InscriptionOptions
|
|
220
327
|
): string {
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
const
|
|
225
|
-
const
|
|
226
|
-
|
|
227
|
-
: null;
|
|
328
|
+
const typed = result as InscriptionResponse;
|
|
329
|
+
|
|
330
|
+
if (typed.confirmed && !typed.quote) {
|
|
331
|
+
const ids = extractTopicIds(typed.inscription, typed.result);
|
|
332
|
+
const network = (options.network || 'testnet') as 'mainnet' | 'testnet';
|
|
333
|
+
const { topicId, cdnUrl } = buildInscriptionLinks(ids, network, '1');
|
|
228
334
|
return `Successfully inscribed and confirmed content on the Hedera network!\n\nTransaction ID: ${
|
|
229
|
-
(
|
|
335
|
+
(typed.result as InscriptionResult)?.transactionId ?? 'unknown'
|
|
230
336
|
}\nTopic ID: ${topicId || 'N/A'}${
|
|
231
337
|
cdnUrl ? `\nView inscription: ${cdnUrl}` : ''
|
|
232
338
|
}\n\nThe inscription is now available.`;
|
|
233
339
|
}
|
|
234
340
|
|
|
235
|
-
if (!
|
|
341
|
+
if (!typed.quote && !typed.confirmed) {
|
|
236
342
|
return `Successfully submitted inscription to the Hedera network!\n\nTransaction ID: ${
|
|
237
|
-
(
|
|
343
|
+
(typed.result as InscriptionResult)?.transactionId ?? 'unknown'
|
|
238
344
|
}\n\nThe inscription is processing and will be confirmed shortly.`;
|
|
239
345
|
}
|
|
240
346
|
|
|
241
347
|
return 'Inscription operation completed.';
|
|
242
348
|
}
|
|
243
|
-
|
|
244
349
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { BaseInscriberQueryTool } from './base-inscriber-tools';
|
|
3
|
-
import { InscriptionOptions } from '@hashgraphonline/standards-sdk';
|
|
3
|
+
import { InscriptionOptions, InscriptionResponse } from '@hashgraphonline/standards-sdk';
|
|
4
4
|
import { CallbackManagerForToolRun } from '@langchain/core/callbacks/manager';
|
|
5
5
|
import * as fs from 'fs/promises';
|
|
6
6
|
import * as path from 'path';
|
|
7
|
+
import { extractTopicIds, buildInscriptionLinks } from '../../utils/inscription-utils';
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Schema for inscribing from file
|
|
@@ -206,10 +207,10 @@ export class InscribeFromFileTool extends BaseInscriberQueryTool<
|
|
|
206
207
|
}
|
|
207
208
|
|
|
208
209
|
try {
|
|
209
|
-
let result:
|
|
210
|
+
let result: Awaited<ReturnType<typeof this.inscriberBuilder.inscribe>>;
|
|
210
211
|
|
|
211
212
|
if (params.timeoutMs) {
|
|
212
|
-
const timeoutPromise = new Promise((_, reject) => {
|
|
213
|
+
const timeoutPromise = new Promise<never>((_, reject) => {
|
|
213
214
|
setTimeout(
|
|
214
215
|
() =>
|
|
215
216
|
reject(
|
|
@@ -243,22 +244,18 @@ export class InscribeFromFileTool extends BaseInscriberQueryTool<
|
|
|
243
244
|
);
|
|
244
245
|
}
|
|
245
246
|
|
|
246
|
-
const inscriptionResult = result as
|
|
247
|
+
const inscriptionResult = result as InscriptionResponse;
|
|
247
248
|
if (inscriptionResult.confirmed && !inscriptionResult.quote) {
|
|
248
|
-
const
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
const network = options.network || 'testnet';
|
|
252
|
-
const cdnUrl = topicId
|
|
253
|
-
? `https://kiloscribe.com/api/inscription-cdn/${topicId}?network=${network}`
|
|
254
|
-
: null;
|
|
249
|
+
const ids = extractTopicIds(inscriptionResult.inscription, inscriptionResult.result);
|
|
250
|
+
const network = (options.network || 'testnet') as 'mainnet' | 'testnet';
|
|
251
|
+
const { topicId, cdnUrl } = buildInscriptionLinks(ids, network, '1');
|
|
255
252
|
return `Successfully inscribed and confirmed content on the Hedera network!\n\nTransaction ID: ${
|
|
256
|
-
inscriptionResult.result
|
|
253
|
+
(inscriptionResult.result as { transactionId?: string })?.transactionId ?? 'unknown'
|
|
257
254
|
}\nTopic ID: ${topicId || 'N/A'}${
|
|
258
255
|
cdnUrl ? `\nView inscription: ${cdnUrl}` : ''
|
|
259
256
|
}\n\nThe inscription is now available.`;
|
|
260
257
|
} else if (!inscriptionResult.quote && !inscriptionResult.confirmed) {
|
|
261
|
-
return `Successfully submitted inscription to the Hedera network!\n\nTransaction ID: ${inscriptionResult.result
|
|
258
|
+
return `Successfully submitted inscription to the Hedera network!\n\nTransaction ID: ${(inscriptionResult.result as { transactionId?: string })?.transactionId ?? 'unknown'}\n\nThe inscription is processing and will be confirmed shortly.`;
|
|
262
259
|
} else {
|
|
263
260
|
return 'Inscription operation completed.';
|
|
264
261
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { BaseInscriberQueryTool } from './base-inscriber-tools';
|
|
3
|
-
import { InscriptionOptions, Logger } from '@hashgraphonline/standards-sdk';
|
|
3
|
+
import { InscriptionOptions, Logger, InscriptionResponse } from '@hashgraphonline/standards-sdk';
|
|
4
4
|
import { CallbackManagerForToolRun } from '@langchain/core/callbacks/manager';
|
|
5
|
+
import { extractTopicIds, buildInscriptionLinks } from '../../utils/inscription-utils';
|
|
5
6
|
|
|
6
7
|
const logger = new Logger({ module: 'InscribeFromUrlTool' });
|
|
7
8
|
|
|
@@ -309,21 +310,24 @@ export class InscribeFromUrlTool extends BaseInscriberQueryTool<
|
|
|
309
310
|
);
|
|
310
311
|
}
|
|
311
312
|
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
const
|
|
316
|
-
const
|
|
317
|
-
|
|
318
|
-
|
|
313
|
+
const typed = result as InscriptionResponse;
|
|
314
|
+
|
|
315
|
+
if (typed.confirmed && !typed.quote) {
|
|
316
|
+
const ids = extractTopicIds(typed.inscription, typed.result);
|
|
317
|
+
const network = (options.network || 'testnet') as 'mainnet' | 'testnet';
|
|
318
|
+
const { topicId, cdnUrl } = buildInscriptionLinks(
|
|
319
|
+
ids,
|
|
320
|
+
network,
|
|
321
|
+
'1'
|
|
322
|
+
);
|
|
319
323
|
return `Successfully inscribed and confirmed content on the Hedera network!\n\nTransaction ID: ${
|
|
320
|
-
(
|
|
324
|
+
(typed.result as { transactionId?: string })?.transactionId ?? 'unknown'
|
|
321
325
|
}\nTopic ID: ${topicId || 'N/A'}${
|
|
322
326
|
cdnUrl ? `\nView inscription: ${cdnUrl}` : ''
|
|
323
327
|
}\n\nThe inscription is now available.`;
|
|
324
|
-
} else if (!
|
|
328
|
+
} else if (!typed.quote && !typed.confirmed) {
|
|
325
329
|
return `Successfully submitted inscription to the Hedera network!\n\nTransaction ID: ${
|
|
326
|
-
(
|
|
330
|
+
(typed.result as { transactionId?: string })?.transactionId ?? 'unknown'
|
|
327
331
|
}\n\nThe inscription is processing and will be confirmed shortly.`;
|
|
328
332
|
} else {
|
|
329
333
|
return 'Inscription operation completed.';
|