@hashgraphonline/standards-agent-kit 0.2.161 → 0.2.164
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/builders/inscriber/inscriber-builder.d.ts +3 -2
- package/dist/cjs/standards-agent-kit.cjs +1 -1
- package/dist/cjs/standards-agent-kit.cjs.map +1 -1
- package/dist/cjs/utils/inscription-utils.d.ts +1 -1
- package/dist/es/builders/inscriber/inscriber-builder.d.ts +3 -2
- package/dist/es/standards-agent-kit.es48.js +3 -7
- package/dist/es/standards-agent-kit.es48.js.map +1 -1
- package/dist/es/standards-agent-kit.es49.js +7 -3
- package/dist/es/standards-agent-kit.es49.js.map +1 -1
- package/dist/es/standards-agent-kit.es51.js +1 -1
- package/dist/es/standards-agent-kit.es51.js.map +1 -1
- package/dist/es/standards-agent-kit.es6.js +1 -1
- package/dist/es/standards-agent-kit.es7.js +1 -1
- package/dist/es/standards-agent-kit.es8.js +83 -43
- package/dist/es/standards-agent-kit.es8.js.map +1 -1
- package/dist/es/standards-agent-kit.es9.js +1 -1
- package/dist/es/utils/inscription-utils.d.ts +1 -1
- package/dist/umd/builders/inscriber/inscriber-builder.d.ts +3 -2
- package/dist/umd/standards-agent-kit.umd.js +1 -220
- package/dist/umd/standards-agent-kit.umd.js.map +1 -1
- package/dist/umd/utils/inscription-utils.d.ts +1 -1
- package/package.json +2 -2
- package/src/builders/inscriber/inscriber-builder.ts +95 -48
- package/src/utils/inscription-utils.ts +3 -2
|
@@ -9,7 +9,7 @@ export interface TopicIds {
|
|
|
9
9
|
* - Prefers jsonTopicId when present (for CDN linking)
|
|
10
10
|
* - Collects topic_id/topicId from either inscription or result
|
|
11
11
|
*/
|
|
12
|
-
export declare function extractTopicIds(inscription: RetrievedInscriptionResult, result?: unknown): TopicIds;
|
|
12
|
+
export declare function extractTopicIds(inscription: RetrievedInscriptionResult | undefined, result?: unknown): TopicIds;
|
|
13
13
|
/**
|
|
14
14
|
* Build HRL/CDN URLs from extracted topic ids.
|
|
15
15
|
* - HRL prefers jsonTopicId, falls back to topicId
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hashgraphonline/standards-agent-kit",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.164",
|
|
4
4
|
"description": "A modular SDK for building on-chain autonomous agents using Hashgraph Online Standards, including HCS-10 for agent discovery and communication.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/cjs/standards-agent-kit.cjs",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
65
|
"@hashgraph/sdk": "^2.72.0",
|
|
66
|
-
"@hashgraphonline/standards-sdk": "^0.1.
|
|
66
|
+
"@hashgraphonline/standards-sdk": "^0.1.111",
|
|
67
67
|
"@kiloscribe/inscription-sdk": "^1.0.60",
|
|
68
68
|
"@langchain/community": "^0.3.5",
|
|
69
69
|
"@langchain/core": "^0.3.71",
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
inscribe,
|
|
5
5
|
inscribeWithSigner,
|
|
6
6
|
retrieveInscription,
|
|
7
|
+
getOrCreateSDK,
|
|
7
8
|
InscriptionInput,
|
|
8
9
|
InscriptionOptions,
|
|
9
10
|
InscriptionResponse,
|
|
@@ -11,11 +12,12 @@ import {
|
|
|
11
12
|
HederaClientConfig,
|
|
12
13
|
NetworkType,
|
|
13
14
|
getTopicId,
|
|
15
|
+
Logger,
|
|
14
16
|
} from '@hashgraphonline/standards-sdk';
|
|
15
|
-
import {
|
|
17
|
+
import type {
|
|
16
18
|
InscriptionSDK,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
+
InscriptionResult,
|
|
20
|
+
RegistrationProgressData,
|
|
19
21
|
} from '@kiloscribe/inscription-sdk';
|
|
20
22
|
import type { AgentOperationalMode } from 'hedera-agent-kit';
|
|
21
23
|
|
|
@@ -45,12 +47,26 @@ export interface CompletedInscriptionResponse {
|
|
|
45
47
|
/**
|
|
46
48
|
* Builder for Inscription operations
|
|
47
49
|
*/
|
|
48
|
-
type InscriptionSDKInstance =
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
50
|
+
type InscriptionSDKInstance = InscriptionSDK;
|
|
51
|
+
|
|
52
|
+
export const toDashedTransactionId = (transactionId: string): string => {
|
|
53
|
+
if (transactionId.includes('-')) {
|
|
54
|
+
return transactionId;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const [account, timePart] = transactionId.split('@');
|
|
58
|
+
if (!account || !timePart) {
|
|
59
|
+
return transactionId;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const [secondsPart, nanosPart] = timePart.split('.');
|
|
63
|
+
if (!secondsPart) {
|
|
64
|
+
return transactionId;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const normalizedNanos = (nanosPart ?? '0').padEnd(9, '0').slice(0, 9);
|
|
68
|
+
return `${account}-${secondsPart}-${normalizedNanos}`;
|
|
69
|
+
};
|
|
54
70
|
|
|
55
71
|
export class InscriberBuilder extends BaseServiceBuilder {
|
|
56
72
|
protected inscriptionSDK?: InscriptionSDKInstance;
|
|
@@ -139,7 +155,7 @@ export class InscriberBuilder extends BaseServiceBuilder {
|
|
|
139
155
|
* Get or create Inscription SDK
|
|
140
156
|
*/
|
|
141
157
|
protected async getInscriptionSDK(
|
|
142
|
-
|
|
158
|
+
options: InscriptionOptions
|
|
143
159
|
): Promise<InscriptionSDKInstance | null> {
|
|
144
160
|
if (this.inscriptionSDK) {
|
|
145
161
|
return this.inscriptionSDK;
|
|
@@ -152,39 +168,37 @@ export class InscriberBuilder extends BaseServiceBuilder {
|
|
|
152
168
|
? 'mainnet'
|
|
153
169
|
: 'testnet';
|
|
154
170
|
const accountId = this.hederaKit.signer.getAccountId().toString();
|
|
171
|
+
const operatorKey = this.hederaKit.signer?.getOperatorPrivateKey();
|
|
172
|
+
const baseOptions: InscriptionOptions = {
|
|
173
|
+
...options,
|
|
174
|
+
network: options.network ?? networkType,
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
const apiKey = baseOptions.apiKey ?? (operatorKey ? undefined : 'public-access');
|
|
178
|
+
const effectiveOptions: InscriptionOptions = apiKey
|
|
179
|
+
? { ...baseOptions, apiKey }
|
|
180
|
+
: baseOptions;
|
|
181
|
+
|
|
182
|
+
const clientConfig = {
|
|
183
|
+
accountId,
|
|
184
|
+
privateKey: operatorKey?.toStringRaw() ?? apiKey ?? 'public-access',
|
|
185
|
+
network: networkType,
|
|
186
|
+
};
|
|
155
187
|
|
|
156
188
|
try {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
privateKey.toStringRaw() as ServerAuthConfig['privateKey'],
|
|
164
|
-
network: networkType,
|
|
165
|
-
});
|
|
166
|
-
}
|
|
189
|
+
this.inscriptionSDK = await getOrCreateSDK(
|
|
190
|
+
clientConfig,
|
|
191
|
+
effectiveOptions,
|
|
192
|
+
this.inscriptionSDK
|
|
193
|
+
);
|
|
194
|
+
return this.inscriptionSDK;
|
|
167
195
|
} catch (error) {
|
|
168
|
-
this.logger.
|
|
196
|
+
this.logger.error('failed to setup sdk', {
|
|
197
|
+
error: error instanceof Error ? error.message : String(error),
|
|
198
|
+
});
|
|
169
199
|
this.inscriptionSDK = undefined;
|
|
200
|
+
return null;
|
|
170
201
|
}
|
|
171
|
-
|
|
172
|
-
if (!this.inscriptionSDK) {
|
|
173
|
-
try {
|
|
174
|
-
this.inscriptionSDK = new InscriptionSDK({
|
|
175
|
-
apiKey: 'public-access',
|
|
176
|
-
network: networkType,
|
|
177
|
-
connectionMode: 'http',
|
|
178
|
-
});
|
|
179
|
-
} catch (fallbackError) {
|
|
180
|
-
this.logger.warn(
|
|
181
|
-
'Failed to create InscriptionSDK fallback instance',
|
|
182
|
-
fallbackError
|
|
183
|
-
);
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
return this.inscriptionSDK || null;
|
|
188
202
|
}
|
|
189
203
|
|
|
190
204
|
/**
|
|
@@ -326,6 +340,14 @@ export class InscriberBuilder extends BaseServiceBuilder {
|
|
|
326
340
|
network
|
|
327
341
|
);
|
|
328
342
|
|
|
343
|
+
this.logger.info('inscribeAuto start response', {
|
|
344
|
+
hasTransactionBytes:
|
|
345
|
+
typeof (start as { transactionBytes?: unknown }).transactionBytes ===
|
|
346
|
+
'string',
|
|
347
|
+
txId: (start as { tx_id?: unknown }).tx_id,
|
|
348
|
+
status: (start as { status?: unknown }).status,
|
|
349
|
+
});
|
|
350
|
+
|
|
329
351
|
const completedStart = start as CompletedInscriptionResponse;
|
|
330
352
|
const isCompletedResponse =
|
|
331
353
|
Boolean(completedStart?.inscription) && completedStart?.confirmed;
|
|
@@ -366,30 +388,55 @@ export class InscriberBuilder extends BaseServiceBuilder {
|
|
|
366
388
|
network
|
|
367
389
|
);
|
|
368
390
|
const transactionId = exec?.transactionId || '';
|
|
391
|
+
const rawTransactionId = startResponse.tx_id || transactionId;
|
|
392
|
+
const canonicalTransactionId = toDashedTransactionId(rawTransactionId);
|
|
393
|
+
|
|
394
|
+
this.logger.info('inscribeAuto wallet execution', {
|
|
395
|
+
transactionId,
|
|
396
|
+
network,
|
|
397
|
+
});
|
|
369
398
|
|
|
370
399
|
const shouldWait = options.quoteOnly
|
|
371
400
|
? false
|
|
372
401
|
: options.waitForConfirmation ?? true;
|
|
373
402
|
if (shouldWait) {
|
|
374
|
-
this.logger.debug('Will be retrieving inscription');
|
|
375
403
|
const maxAttempts =
|
|
376
404
|
(options as { waitMaxAttempts?: number }).waitMaxAttempts ?? 60;
|
|
377
405
|
const intervalMs =
|
|
378
406
|
(options as { waitIntervalMs?: number }).waitIntervalMs ?? 5000;
|
|
407
|
+
const pollId = canonicalTransactionId;
|
|
408
|
+
this.logger.debug('Will be retrieving inscription', pollId);
|
|
379
409
|
|
|
380
|
-
|
|
410
|
+
let retrieved: RetrievedInscriptionResult | null = null;
|
|
381
411
|
const sdk = await this.getInscriptionSDK(options);
|
|
412
|
+
|
|
382
413
|
if (sdk) {
|
|
383
|
-
|
|
384
|
-
await sdk.waitForInscription(
|
|
414
|
+
try {
|
|
415
|
+
retrieved = await sdk.waitForInscription(
|
|
385
416
|
pollId,
|
|
386
417
|
maxAttempts,
|
|
387
418
|
intervalMs,
|
|
388
419
|
true,
|
|
389
420
|
(progress: RegistrationProgressData) => {
|
|
390
|
-
this.logger.
|
|
421
|
+
this.logger.debug('checking inscription', progress);
|
|
391
422
|
}
|
|
392
423
|
);
|
|
424
|
+
} catch (error) {
|
|
425
|
+
this.logger.warn('Primary inscription wait failed', {
|
|
426
|
+
pollId,
|
|
427
|
+
error: error instanceof Error ? error.message : String(error),
|
|
428
|
+
});
|
|
429
|
+
}
|
|
430
|
+
} else {
|
|
431
|
+
this.logger.warn(
|
|
432
|
+
'No inscription SDK available, using public client',
|
|
433
|
+
{
|
|
434
|
+
pollId,
|
|
435
|
+
}
|
|
436
|
+
);
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
if (retrieved) {
|
|
393
440
|
const topicIdFromInscription: string | undefined = getTopicId(
|
|
394
441
|
retrieved as unknown
|
|
395
442
|
);
|
|
@@ -399,14 +446,14 @@ export class InscriberBuilder extends BaseServiceBuilder {
|
|
|
399
446
|
quote: false,
|
|
400
447
|
confirmed: true,
|
|
401
448
|
result: {
|
|
402
|
-
jobId: startResponse.tx_id || '',
|
|
403
|
-
transactionId,
|
|
449
|
+
jobId: toDashedTransactionId(startResponse.tx_id || ''),
|
|
450
|
+
transactionId: canonicalTransactionId,
|
|
404
451
|
topicId,
|
|
405
452
|
},
|
|
406
453
|
inscription: retrieved,
|
|
407
454
|
} as unknown as InscriptionResponse;
|
|
408
455
|
this.logger.debug(
|
|
409
|
-
'retrieved inscription',
|
|
456
|
+
'retrieved inscription confirmed',
|
|
410
457
|
resultConfirmed,
|
|
411
458
|
retrieved
|
|
412
459
|
);
|
|
@@ -418,8 +465,8 @@ export class InscriberBuilder extends BaseServiceBuilder {
|
|
|
418
465
|
quote: false,
|
|
419
466
|
confirmed: false,
|
|
420
467
|
result: {
|
|
421
|
-
jobId: startResponse.tx_id || '',
|
|
422
|
-
transactionId,
|
|
468
|
+
jobId: toDashedTransactionId(startResponse.tx_id || ''),
|
|
469
|
+
transactionId: canonicalTransactionId,
|
|
423
470
|
status: startResponse.status,
|
|
424
471
|
completed: startResponse.completed,
|
|
425
472
|
},
|
|
@@ -19,11 +19,12 @@ function getStringProp(obj: unknown, key: string): string | undefined {
|
|
|
19
19
|
* - Collects topic_id/topicId from either inscription or result
|
|
20
20
|
*/
|
|
21
21
|
export function extractTopicIds(
|
|
22
|
-
inscription: RetrievedInscriptionResult,
|
|
22
|
+
inscription: RetrievedInscriptionResult | undefined,
|
|
23
23
|
result?: unknown
|
|
24
24
|
): TopicIds {
|
|
25
25
|
const jsonTopicId =
|
|
26
|
-
inscription
|
|
26
|
+
(inscription as RetrievedInscriptionResult | undefined)?.jsonTopicId ||
|
|
27
|
+
getStringProp(inscription, 'json_topic_id');
|
|
27
28
|
|
|
28
29
|
const imageTopicId =
|
|
29
30
|
getStringProp(inscription, 'topic_id') ||
|