@hashgraphonline/conversational-agent 0.2.201 → 0.2.203

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.
@@ -3,3 +3,4 @@ export { HCS2Plugin } from './hcs-2';
3
3
  export { InscribePlugin } from './inscribe';
4
4
  export { HbarPlugin } from './hbar/HbarPlugin';
5
5
  export * from './hbar';
6
+ export { WebBrowserPlugin } from './web-browser/WebBrowserPlugin';
@@ -0,0 +1,14 @@
1
+ import { BasePlugin, GenericPluginContext, HederaTool } from 'hedera-agent-kit';
2
+
3
+ export declare class WebBrowserPlugin extends BasePlugin<GenericPluginContext> {
4
+ id: string;
5
+ name: string;
6
+ description: string;
7
+ version: string;
8
+ author: string;
9
+ namespace: string;
10
+ private tools;
11
+ initialize(context: GenericPluginContext): Promise<void>;
12
+ getTools(): HederaTool[];
13
+ cleanup(): Promise<void>;
14
+ }
@@ -3,8 +3,8 @@ import { extractRenderConfigs, generateFieldOrdering } from "@hashgraphonline/st
3
3
  import { Logger } from "@hashgraphonline/standards-sdk";
4
4
  import { fieldTypeRegistry } from "./index12.js";
5
5
  import { fieldGuidanceRegistry } from "./index13.js";
6
- import "./index41.js";
7
- import { FIELD_PRIORITIES } from "./index43.js";
6
+ import "./index44.js";
7
+ import { FIELD_PRIORITIES } from "./index47.js";
8
8
  function isZodObjectSchema(schema) {
9
9
  return typeof schema === "object" && schema !== null && "shape" in schema;
10
10
  }
@@ -1,5 +1,5 @@
1
1
  import { ReferenceIdGenerator } from "./index22.js";
2
- import { DEFAULT_CONTENT_REFERENCE_CONFIG, ContentReferenceError } from "./index44.js";
2
+ import { DEFAULT_CONTENT_REFERENCE_CONFIG, ContentReferenceError } from "./index42.js";
3
3
  const _ContentStorage = class _ContentStorage {
4
4
  constructor(maxStorage = _ContentStorage.DEFAULT_MAX_STORAGE, referenceConfig) {
5
5
  this.messages = [];
@@ -1,6 +1,6 @@
1
1
  import { ChatOpenAI } from "@langchain/openai";
2
2
  import { Logger } from "@hashgraphonline/standards-sdk";
3
- import { ENTITY_PATTERNS } from "./index41.js";
3
+ import { ENTITY_PATTERNS } from "./index44.js";
4
4
  import "hedera-agent-kit";
5
5
  import "@hashgraphonline/standards-agent-kit";
6
6
  import "./index13.js";
@@ -8,11 +8,11 @@ import { MCPClientManager } from "./index15.js";
8
8
  import { convertMCPToolToLangChain } from "./index17.js";
9
9
  import { SmartMemoryManager } from "./index18.js";
10
10
  import { ResponseFormatter } from "./index35.js";
11
- import { ERROR_MESSAGES } from "./index45.js";
12
- import "./index41.js";
11
+ import { ERROR_MESSAGES } from "./index43.js";
12
+ import "./index44.js";
13
13
  import { SystemMessage, AIMessage, HumanMessage } from "@langchain/core/messages";
14
- import { ToolRegistry } from "./index46.js";
15
- import { ExecutionPipeline } from "./index47.js";
14
+ import { ToolRegistry } from "./index45.js";
15
+ import { ExecutionPipeline } from "./index46.js";
16
16
  import { FormEngine } from "./index11.js";
17
17
  function hasHashLinkBlock(metadata) {
18
18
  if (!metadata || typeof metadata !== "object") {
@@ -1,5 +1,5 @@
1
1
  import { z } from "zod";
2
- import { AccountBuilder } from "./index42.js";
2
+ import { AccountBuilder } from "./index48.js";
3
3
  import { BaseHederaTransactionTool } from "hedera-agent-kit";
4
4
  const HbarTransferInputSchema = z.object({
5
5
  accountId: z.string().describe('Account ID for the transfer (e.g., "0.0.xxxx").'),
@@ -1,24 +1,82 @@
1
- const getSystemMessage = (accountId) => `You are a helpful assistant managing Hashgraph Online HCS-10 connections, messages, HCS-2 registries, content inscription, and Hedera Hashgraph operations.
2
-
3
- You have access to tools for:
4
- - HCS-10: registering agents, finding registered agents, initiating connections, listing active connections, sending messages over connections, and checking for new messages
5
- - HCS-2: creating registries, registering entries, updating entries, deleting entries, migrating registries, and querying registry contents
6
- - Inscription: inscribing content from URLs, files, or buffers, creating Hashinal NFTs, and retrieving inscriptions
7
- - Hedera Token Service (HTS): creating tokens, transferring tokens, airdropping tokens, and managing token operations
8
-
9
-
10
- *** IMPORTANT CONTEXT ***
11
- You are currently operating as agent: ${accountId || "unknown"} on the Hedera Hashgraph
12
- When users ask about "my profile", "my account", "my connections", etc., use this account ID: ${accountId || "unknown"}
13
-
14
- *** CRITICAL ENTITY HANDLING RULES ***
15
- - When users refer to entities (tokens, topics, accounts) with pronouns like "it", "that", "the token/topic", etc., ALWAYS use the most recently created entity of that type
16
- - Entity IDs look like "0.0.XXXXXX" and are stored in memory after creation
17
- - NEVER use example or placeholder IDs like "0.0.123456" - always use actual created entity IDs
18
- - Account ID ${accountId} is NOT a token - tokens and accounts are different entities
19
-
20
- Remember the connection numbers when listing connections, as users might refer to them.`;
1
+ import { BasePlugin, BaseHederaQueryTool } from "hedera-agent-kit";
2
+ import { z } from "zod";
3
+ const PageSnapshotSchema = z.object({
4
+ url: z.string().url(),
5
+ maxCharacters: z.number().int().min(256, "Minimum length is 256 characters").max(8e3, "Maximum length is 8000 characters").optional().default(3e3)
6
+ });
7
+ class WebPageSnapshotTool extends BaseHederaQueryTool {
8
+ constructor(params) {
9
+ const { fetchImpl, ...rest } = params;
10
+ super(rest);
11
+ this.name = "web_page_snapshot";
12
+ this.description = "Fetches the visible text content of a web page for analysis.";
13
+ this.namespace = "browser";
14
+ this.specificInputSchema = PageSnapshotSchema;
15
+ this.fetchImpl = fetchImpl ?? fetch;
16
+ }
17
+ async executeQuery(input) {
18
+ const maxChars = input.maxCharacters ?? 3e3;
19
+ try {
20
+ const response = await this.fetchImpl(input.url, {
21
+ redirect: "follow"
22
+ });
23
+ if (!response.ok) {
24
+ return `Failed to load ${input.url}: HTTP ${response.status}`;
25
+ }
26
+ const html = await response.text();
27
+ const text = this.normalizeHtml(html);
28
+ if (!text) {
29
+ return "The fetched page did not contain readable text.";
30
+ }
31
+ return text.length > maxChars ? `${text.slice(0, maxChars)}…` : text;
32
+ } catch (error) {
33
+ this.logger.error("WebPageSnapshotTool failed", error);
34
+ return `Failed to fetch content for ${input.url}: ${error instanceof Error ? error.message : String(error)}`;
35
+ }
36
+ }
37
+ normalizeHtml(html) {
38
+ const withoutScripts = html.replace(/<script[\s\S]*?<\/script>/gi, " ").replace(/<style[\s\S]*?<\/style>/gi, " ").replace(/<!--([\s\S]*?)-->/g, " ");
39
+ const stripped = withoutScripts.replace(/<[^>]+>/g, " ");
40
+ const decoded = stripped.replace(/&nbsp;/gi, " ").replace(/&amp;/gi, "&").replace(/&lt;/gi, "<").replace(/&gt;/gi, ">").replace(/&quot;/gi, '"').replace(/&#39;/gi, "'");
41
+ return decoded.replace(/\s+/g, " ").trim();
42
+ }
43
+ }
44
+ class WebBrowserPlugin extends BasePlugin {
45
+ constructor() {
46
+ super(...arguments);
47
+ this.id = "web-browser";
48
+ this.name = "Web Browser Plugin";
49
+ this.description = "Provides tools for fetching live web page content to enrich assistant understanding.";
50
+ this.version = "0.1.0";
51
+ this.author = "Hashgraph Online";
52
+ this.namespace = "browser";
53
+ this.tools = [];
54
+ }
55
+ async initialize(context) {
56
+ await super.initialize(context);
57
+ const hederaKit = context.config.hederaKit;
58
+ if (!hederaKit) {
59
+ this.context.logger.warn(
60
+ "WebBrowserPlugin skipped because HederaAgentKit was not present in plugin context."
61
+ );
62
+ this.tools = [];
63
+ return;
64
+ }
65
+ const tool = new WebPageSnapshotTool({
66
+ hederaKit,
67
+ logger: this.context.logger
68
+ });
69
+ this.tools = [tool];
70
+ this.context.logger.info("Web Browser Plugin initialized with snapshot tool");
71
+ }
72
+ getTools() {
73
+ return this.tools;
74
+ }
75
+ async cleanup() {
76
+ this.tools = [];
77
+ }
78
+ }
21
79
  export {
22
- getSystemMessage
80
+ WebBrowserPlugin
23
81
  };
24
82
  //# sourceMappingURL=index40.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index40.js","sources":["../../src/config/system-message.ts"],"sourcesContent":["export const getSystemMessage = (\n accountId?: string\n): string => `You are a helpful assistant managing Hashgraph Online HCS-10 connections, messages, HCS-2 registries, content inscription, and Hedera Hashgraph operations.\n\nYou have access to tools for:\n- HCS-10: registering agents, finding registered agents, initiating connections, listing active connections, sending messages over connections, and checking for new messages\n- HCS-2: creating registries, registering entries, updating entries, deleting entries, migrating registries, and querying registry contents\n- Inscription: inscribing content from URLs, files, or buffers, creating Hashinal NFTs, and retrieving inscriptions\n- Hedera Token Service (HTS): creating tokens, transferring tokens, airdropping tokens, and managing token operations\n\n\n*** IMPORTANT CONTEXT ***\nYou are currently operating as agent: ${accountId || 'unknown'} on the Hedera Hashgraph\nWhen users ask about \"my profile\", \"my account\", \"my connections\", etc., use this account ID: ${accountId || 'unknown'}\n\n*** CRITICAL ENTITY HANDLING RULES ***\n- When users refer to entities (tokens, topics, accounts) with pronouns like \"it\", \"that\", \"the token/topic\", etc., ALWAYS use the most recently created entity of that type\n- Entity IDs look like \"0.0.XXXXXX\" and are stored in memory after creation\n- NEVER use example or placeholder IDs like \"0.0.123456\" - always use actual created entity IDs\n- Account ID ${accountId} is NOT a token - tokens and accounts are different entities\n\n Remember the connection numbers when listing connections, as users might refer to them.`;\n"],"names":[],"mappings":"AAAO,MAAM,mBAAmB,CAC9B,cACW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wCAU2B,aAAa,SAAS;AAAA,gGACkC,aAAa,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,eAMvG,SAAS;AAAA;AAAA;"}
1
+ {"version":3,"file":"index40.js","sources":["../../src/plugins/web-browser/WebBrowserPlugin.ts"],"sourcesContent":["import {\n BasePlugin,\n type GenericPluginContext,\n BaseHederaQueryTool,\n type HederaAgentKit,\n type HederaTool,\n} from 'hedera-agent-kit';\nimport { z } from 'zod';\n\nconst PageSnapshotSchema = z.object({\n url: z.string().url(),\n maxCharacters: z\n .number()\n .int()\n .min(256, 'Minimum length is 256 characters')\n .max(8000, 'Maximum length is 8000 characters')\n .optional()\n .default(3000),\n});\n\nclass WebPageSnapshotTool extends BaseHederaQueryTool<typeof PageSnapshotSchema> {\n name = 'web_page_snapshot';\n description = 'Fetches the visible text content of a web page for analysis.';\n namespace = 'browser';\n specificInputSchema = PageSnapshotSchema;\n\n constructor(params: {\n hederaKit: HederaAgentKit;\n logger?: GenericPluginContext['logger'];\n fetchImpl?: typeof fetch;\n }) {\n const { fetchImpl, ...rest } = params;\n super(rest);\n this.fetchImpl = fetchImpl ?? fetch;\n }\n\n private readonly fetchImpl: typeof fetch;\n\n protected async executeQuery(\n input: z.infer<typeof PageSnapshotSchema>\n ): Promise<string> {\n const maxChars = input.maxCharacters ?? 3000;\n\n try {\n const response = await this.fetchImpl(input.url, {\n redirect: 'follow',\n });\n\n if (!response.ok) {\n return `Failed to load ${input.url}: HTTP ${response.status}`;\n }\n\n const html = await response.text();\n const text = this.normalizeHtml(html);\n\n if (!text) {\n return 'The fetched page did not contain readable text.';\n }\n\n return text.length > maxChars ? `${text.slice(0, maxChars)}…` : text;\n } catch (error) {\n this.logger.error('WebPageSnapshotTool failed', error);\n return `Failed to fetch content for ${input.url}: ${\n error instanceof Error ? error.message : String(error)\n }`;\n }\n }\n\n private normalizeHtml(html: string): string {\n const withoutScripts = html\n .replace(/<script[\\s\\S]*?<\\/script>/gi, ' ')\n .replace(/<style[\\s\\S]*?<\\/style>/gi, ' ')\n .replace(/<!--([\\s\\S]*?)-->/g, ' ');\n\n const stripped = withoutScripts.replace(/<[^>]+>/g, ' ');\n const decoded = stripped\n .replace(/&nbsp;/gi, ' ')\n .replace(/&amp;/gi, '&')\n .replace(/&lt;/gi, '<')\n .replace(/&gt;/gi, '>')\n .replace(/&quot;/gi, '\"')\n .replace(/&#39;/gi, \"'\");\n\n return decoded.replace(/\\s+/g, ' ').trim();\n }\n}\n\nexport class WebBrowserPlugin extends BasePlugin<GenericPluginContext> {\n id = 'web-browser';\n name = 'Web Browser Plugin';\n description =\n 'Provides tools for fetching live web page content to enrich assistant understanding.';\n version = '0.1.0';\n author = 'Hashgraph Online';\n namespace = 'browser';\n\n private tools: HederaTool[] = [];\n\n override async initialize(context: GenericPluginContext): Promise<void> {\n await super.initialize(context);\n\n const hederaKit = context.config.hederaKit as HederaAgentKit | undefined;\n\n if (!hederaKit) {\n this.context.logger.warn(\n 'WebBrowserPlugin skipped because HederaAgentKit was not present in plugin context.'\n );\n this.tools = [];\n return;\n }\n\n const tool = new WebPageSnapshotTool({\n hederaKit,\n logger: this.context.logger,\n });\n\n this.tools = [tool];\n this.context.logger.info('Web Browser Plugin initialized with snapshot tool');\n }\n\n override getTools(): HederaTool[] {\n return this.tools;\n }\n\n override async cleanup(): Promise<void> {\n this.tools = [];\n }\n}\n"],"names":[],"mappings":";;AASA,MAAM,qBAAqB,EAAE,OAAO;AAAA,EAClC,KAAK,EAAE,OAAA,EAAS,IAAA;AAAA,EAChB,eAAe,EACZ,OAAA,EACA,IAAA,EACA,IAAI,KAAK,kCAAkC,EAC3C,IAAI,KAAM,mCAAmC,EAC7C,SAAA,EACA,QAAQ,GAAI;AACjB,CAAC;AAED,MAAM,4BAA4B,oBAA+C;AAAA,EAM/E,YAAY,QAIT;AACD,UAAM,EAAE,WAAW,GAAG,KAAA,IAAS;AAC/B,UAAM,IAAI;AAXZ,SAAA,OAAO;AACP,SAAA,cAAc;AACd,SAAA,YAAY;AACZ,SAAA,sBAAsB;AASpB,SAAK,YAAY,aAAa;AAAA,EAChC;AAAA,EAIA,MAAgB,aACd,OACiB;AACjB,UAAM,WAAW,MAAM,iBAAiB;AAExC,QAAI;AACF,YAAM,WAAW,MAAM,KAAK,UAAU,MAAM,KAAK;AAAA,QAC/C,UAAU;AAAA,MAAA,CACX;AAED,UAAI,CAAC,SAAS,IAAI;AAChB,eAAO,kBAAkB,MAAM,GAAG,UAAU,SAAS,MAAM;AAAA,MAC7D;AAEA,YAAM,OAAO,MAAM,SAAS,KAAA;AAC5B,YAAM,OAAO,KAAK,cAAc,IAAI;AAEpC,UAAI,CAAC,MAAM;AACT,eAAO;AAAA,MACT;AAEA,aAAO,KAAK,SAAS,WAAW,GAAG,KAAK,MAAM,GAAG,QAAQ,CAAC,MAAM;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,EAEA,MAAe,UAAyB;AACtC,SAAK,QAAQ,CAAA;AAAA,EACf;AACF;"}
@@ -1,15 +1,24 @@
1
- import { EntityFormat } from "./index26.js";
2
- const ENTITY_PATTERNS = {
3
- TOPIC_REFERENCE: "the topic",
4
- TOKEN_REFERENCE: "the token"
5
- };
6
- ({
7
- TOPIC: EntityFormat.TOPIC_ID,
8
- TOKEN: EntityFormat.TOKEN_ID,
9
- ACCOUNT: EntityFormat.ACCOUNT_ID,
10
- CONTRACT: EntityFormat.CONTRACT_ID
11
- });
1
+ const getSystemMessage = (accountId) => `You are a helpful assistant managing Hashgraph Online HCS-10 connections, messages, HCS-2 registries, content inscription, and Hedera Hashgraph operations.
2
+
3
+ You have access to tools for:
4
+ - HCS-10: registering agents, finding registered agents, initiating connections, listing active connections, sending messages over connections, and checking for new messages
5
+ - HCS-2: creating registries, registering entries, updating entries, deleting entries, migrating registries, and querying registry contents
6
+ - Inscription: inscribing content from URLs, files, or buffers, creating Hashinal NFTs, and retrieving inscriptions
7
+ - Hedera Token Service (HTS): creating tokens, transferring tokens, airdropping tokens, and managing token operations
8
+
9
+
10
+ *** IMPORTANT CONTEXT ***
11
+ You are currently operating as agent: ${accountId || "unknown"} on the Hedera Hashgraph
12
+ When users ask about "my profile", "my account", "my connections", etc., use this account ID: ${accountId || "unknown"}
13
+
14
+ *** CRITICAL ENTITY HANDLING RULES ***
15
+ - When users refer to entities (tokens, topics, accounts) with pronouns like "it", "that", "the token/topic", etc., ALWAYS use the most recently created entity of that type
16
+ - Entity IDs look like "0.0.XXXXXX" and are stored in memory after creation
17
+ - NEVER use example or placeholder IDs like "0.0.123456" - always use actual created entity IDs
18
+ - Account ID ${accountId} is NOT a token - tokens and accounts are different entities
19
+
20
+ Remember the connection numbers when listing connections, as users might refer to them.`;
12
21
  export {
13
- ENTITY_PATTERNS
22
+ getSystemMessage
14
23
  };
15
24
  //# sourceMappingURL=index41.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index41.js","sources":["../../src/constants/entity-references.ts"],"sourcesContent":["/**\n * Common entity reference patterns used across the application\n */\nexport const ENTITY_PATTERNS = {\n TOPIC_REFERENCE: 'the topic',\n TOKEN_REFERENCE: 'the token',\n ACCOUNT_REFERENCE: 'the account',\n TRANSACTION_REFERENCE: 'the transaction',\n CONTRACT_REFERENCE: 'the contract',\n} as const;\n\n/**\n * Entity type identifiers\n */\nimport { EntityFormat } from '../services/formatters/types';\n\nexport const ENTITY_TYPES = {\n TOPIC: EntityFormat.TOPIC_ID,\n TOKEN: EntityFormat.TOKEN_ID,\n ACCOUNT: EntityFormat.ACCOUNT_ID,\n TRANSACTION: 'transaction',\n CONTRACT: EntityFormat.CONTRACT_ID,\n} as const;\n"],"names":[],"mappings":";AAGO,MAAM,kBAAkB;AAAA,EAC7B,iBAAiB;AAAA,EACjB,iBAAiB;AAInB;AAAA,CAO4B;AAAA,EAC1B,OAAO,aAAa;AAAA,EACpB,OAAO,aAAa;AAAA,EACpB,SAAS,aAAa;AAAA,EAEtB,UAAU,aAAa;AACzB;"}
1
+ {"version":3,"file":"index41.js","sources":["../../src/config/system-message.ts"],"sourcesContent":["export const getSystemMessage = (\n accountId?: string\n): string => `You are a helpful assistant managing Hashgraph Online HCS-10 connections, messages, HCS-2 registries, content inscription, and Hedera Hashgraph operations.\n\nYou have access to tools for:\n- HCS-10: registering agents, finding registered agents, initiating connections, listing active connections, sending messages over connections, and checking for new messages\n- HCS-2: creating registries, registering entries, updating entries, deleting entries, migrating registries, and querying registry contents\n- Inscription: inscribing content from URLs, files, or buffers, creating Hashinal NFTs, and retrieving inscriptions\n- Hedera Token Service (HTS): creating tokens, transferring tokens, airdropping tokens, and managing token operations\n\n\n*** IMPORTANT CONTEXT ***\nYou are currently operating as agent: ${accountId || 'unknown'} on the Hedera Hashgraph\nWhen users ask about \"my profile\", \"my account\", \"my connections\", etc., use this account ID: ${accountId || 'unknown'}\n\n*** CRITICAL ENTITY HANDLING RULES ***\n- When users refer to entities (tokens, topics, accounts) with pronouns like \"it\", \"that\", \"the token/topic\", etc., ALWAYS use the most recently created entity of that type\n- Entity IDs look like \"0.0.XXXXXX\" and are stored in memory after creation\n- NEVER use example or placeholder IDs like \"0.0.123456\" - always use actual created entity IDs\n- Account ID ${accountId} is NOT a token - tokens and accounts are different entities\n\n Remember the connection numbers when listing connections, as users might refer to them.`;\n"],"names":[],"mappings":"AAAO,MAAM,mBAAmB,CAC9B,cACW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wCAU2B,aAAa,SAAS;AAAA,gGACkC,aAAa,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,eAMvG,SAAS;AAAA;AAAA;"}
@@ -1,98 +1,30 @@
1
- import { TransferTransaction, AccountId, Hbar } from "@hashgraph/sdk";
2
- import BigNumber from "bignumber.js";
3
- import { BaseServiceBuilder } from "hedera-agent-kit";
4
- class AccountBuilder extends BaseServiceBuilder {
5
- constructor(hederaKit) {
6
- super(hederaKit);
1
+ const DEFAULT_CONTENT_REFERENCE_CONFIG = {
2
+ sizeThresholdBytes: 10 * 1024,
3
+ maxAgeMs: 60 * 60 * 1e3,
4
+ maxReferences: 100,
5
+ maxTotalStorageBytes: 100 * 1024 * 1024,
6
+ enableAutoCleanup: true,
7
+ cleanupIntervalMs: 5 * 60 * 1e3,
8
+ enablePersistence: false,
9
+ storageBackend: "memory",
10
+ cleanupPolicies: {
11
+ recent: { maxAgeMs: 30 * 60 * 1e3, priority: 1 },
12
+ userContent: { maxAgeMs: 2 * 60 * 60 * 1e3, priority: 2 },
13
+ agentGenerated: { maxAgeMs: 60 * 60 * 1e3, priority: 3 },
14
+ default: { maxAgeMs: 60 * 60 * 1e3, priority: 4 }
7
15
  }
8
- /**
9
- * Transfers HBAR between accounts with proper decimal handling
10
- */
11
- transferHbar(params, isUserInitiated = true) {
12
- this.clearNotes();
13
- const transaction = new TransferTransaction();
14
- if (!params.transfers || params.transfers.length === 0) {
15
- throw new Error("HbarTransferParams must include at least one transfer.");
16
- }
17
- let netZeroInTinybars = new BigNumber(0);
18
- let userTransferProcessedForScheduling = false;
19
- if (isUserInitiated && this.kit.userAccountId && this.kit.operationalMode === "provideBytes" && params.transfers.length === 1) {
20
- const receiverTransfer = params.transfers[0];
21
- const amountValue = typeof receiverTransfer.amount === "string" || typeof receiverTransfer.amount === "number" ? receiverTransfer.amount : receiverTransfer.amount.toString();
22
- const amountBigNum = new BigNumber(amountValue);
23
- if (amountBigNum.isPositive()) {
24
- const recipientAccountId = typeof receiverTransfer.accountId === "string" ? AccountId.fromString(receiverTransfer.accountId) : receiverTransfer.accountId;
25
- const roundedAmount = amountBigNum.toFixed(8, BigNumber.ROUND_DOWN);
26
- const sdkHbarAmount = Hbar.fromString(roundedAmount);
27
- this.logger.info(
28
- `[AccountBuilder.transferHbar] Configuring user-initiated scheduled transfer: ${sdkHbarAmount.toString()} from ${this.kit.userAccountId} to ${recipientAccountId.toString()}`
29
- );
30
- this.addNote(
31
- `Configured HBAR transfer from your account (${this.kit.userAccountId}) to ${recipientAccountId.toString()} for ${sdkHbarAmount.toString()}.`
32
- );
33
- transaction.addHbarTransfer(recipientAccountId, sdkHbarAmount);
34
- transaction.addHbarTransfer(
35
- AccountId.fromString(this.kit.userAccountId),
36
- sdkHbarAmount.negated()
37
- );
38
- userTransferProcessedForScheduling = true;
39
- }
40
- }
41
- if (!userTransferProcessedForScheduling) {
42
- const processedTransfers = [];
43
- for (const transferInput of params.transfers) {
44
- const accountId = typeof transferInput.accountId === "string" ? AccountId.fromString(transferInput.accountId) : transferInput.accountId;
45
- const amountValue = typeof transferInput.amount === "string" || typeof transferInput.amount === "number" ? transferInput.amount : transferInput.amount.toString();
46
- const amountBigNum = new BigNumber(amountValue);
47
- const roundedAmount = amountBigNum.toFixed(8, BigNumber.ROUND_DOWN);
48
- this.logger.info(
49
- `Processing transfer: ${amountValue} HBAR (rounded to ${roundedAmount}) for account ${accountId.toString()}`
50
- );
51
- const sdkHbarAmount = Hbar.fromString(roundedAmount);
52
- processedTransfers.push({
53
- accountId,
54
- amount: amountBigNum,
55
- hbar: sdkHbarAmount
56
- });
57
- const tinybarsContribution = sdkHbarAmount.toTinybars();
58
- netZeroInTinybars = netZeroInTinybars.plus(
59
- tinybarsContribution.toString()
60
- );
61
- }
62
- if (!netZeroInTinybars.isZero()) {
63
- this.logger.warn(
64
- `Transfer sum not zero: ${netZeroInTinybars.toString()} tinybars off. Adjusting last transfer.`
65
- );
66
- if (processedTransfers.length > 0) {
67
- const lastTransfer = processedTransfers[processedTransfers.length - 1];
68
- const adjustment = netZeroInTinybars.dividedBy(-1e8);
69
- const adjustedAmount = lastTransfer.amount.plus(adjustment);
70
- const adjustedRounded = adjustedAmount.toFixed(
71
- 8,
72
- BigNumber.ROUND_DOWN
73
- );
74
- lastTransfer.hbar = Hbar.fromString(adjustedRounded);
75
- this.logger.info(
76
- `Adjusted last transfer for ${lastTransfer.accountId.toString()} to ${adjustedRounded} HBAR`
77
- );
78
- }
79
- }
80
- for (const transfer of processedTransfers) {
81
- transaction.addHbarTransfer(transfer.accountId, transfer.hbar);
82
- }
83
- }
84
- if (typeof params.memo !== "undefined") {
85
- if (params.memo === null) {
86
- this.logger.warn("Received null for memo in transferHbar.");
87
- } else {
88
- transaction.setTransactionMemo(params.memo);
89
- }
90
- }
91
- this.setCurrentTransaction(transaction);
92
- return this;
16
+ };
17
+ class ContentReferenceError extends Error {
18
+ constructor(message, type, referenceId, suggestedActions) {
19
+ super(message);
20
+ this.type = type;
21
+ this.referenceId = referenceId;
22
+ this.suggestedActions = suggestedActions;
23
+ this.name = "ContentReferenceError";
93
24
  }
94
25
  }
95
26
  export {
96
- AccountBuilder
27
+ ContentReferenceError,
28
+ DEFAULT_CONTENT_REFERENCE_CONFIG
97
29
  };
98
30
  //# sourceMappingURL=index42.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index42.js","sources":["../../src/plugins/hbar/AccountBuilder.ts"],"sourcesContent":["import { AccountId, Hbar, TransferTransaction } from '@hashgraph/sdk';\nimport BigNumber from 'bignumber.js';\nimport { HederaAgentKit, BaseServiceBuilder } from 'hedera-agent-kit';\nimport { HbarTransferParams } from './types';\n\n/**\n * Custom AccountBuilder that properly handles HBAR decimal conversion\n */\nexport class AccountBuilder extends BaseServiceBuilder {\n constructor(hederaKit: HederaAgentKit) {\n super(hederaKit);\n }\n\n /**\n * Transfers HBAR between accounts with proper decimal handling\n */\n public transferHbar(\n params: HbarTransferParams,\n isUserInitiated: boolean = true\n ): this {\n this.clearNotes();\n const transaction = new TransferTransaction();\n\n if (!params.transfers || params.transfers.length === 0) {\n throw new Error('HbarTransferParams must include at least one transfer.');\n }\n\n let netZeroInTinybars = new BigNumber(0);\n let userTransferProcessedForScheduling = false;\n\n if (\n isUserInitiated &&\n this.kit.userAccountId &&\n (this.kit.operationalMode as string) === 'provideBytes' &&\n params.transfers.length === 1\n ) {\n const receiverTransfer = params.transfers[0];\n const amountValue =\n typeof receiverTransfer.amount === 'string' ||\n typeof receiverTransfer.amount === 'number'\n ? receiverTransfer.amount\n : receiverTransfer.amount.toString();\n\n const amountBigNum = new BigNumber(amountValue);\n\n if (amountBigNum.isPositive()) {\n const recipientAccountId =\n typeof receiverTransfer.accountId === 'string'\n ? AccountId.fromString(receiverTransfer.accountId)\n : receiverTransfer.accountId;\n\n const roundedAmount = amountBigNum.toFixed(8, BigNumber.ROUND_DOWN);\n const sdkHbarAmount = Hbar.fromString(roundedAmount);\n\n this.logger.info(\n `[AccountBuilder.transferHbar] Configuring user-initiated scheduled transfer: ${sdkHbarAmount.toString()} from ${\n this.kit.userAccountId\n } to ${recipientAccountId.toString()}`\n );\n\n this.addNote(\n `Configured HBAR transfer from your account (${\n this.kit.userAccountId\n }) to ${recipientAccountId.toString()} for ${sdkHbarAmount.toString()}.`\n );\n\n transaction.addHbarTransfer(recipientAccountId, sdkHbarAmount);\n transaction.addHbarTransfer(\n AccountId.fromString(this.kit.userAccountId),\n sdkHbarAmount.negated()\n );\n\n userTransferProcessedForScheduling = true;\n }\n }\n\n if (!userTransferProcessedForScheduling) {\n const processedTransfers: Array<{\n accountId: AccountId;\n amount: BigNumber;\n hbar: Hbar;\n }> = [];\n\n for (const transferInput of params.transfers) {\n const accountId =\n typeof transferInput.accountId === 'string'\n ? AccountId.fromString(transferInput.accountId)\n : transferInput.accountId;\n\n const amountValue =\n typeof transferInput.amount === 'string' ||\n typeof transferInput.amount === 'number'\n ? transferInput.amount\n : transferInput.amount.toString();\n\n const amountBigNum = new BigNumber(amountValue);\n const roundedAmount = amountBigNum.toFixed(8, BigNumber.ROUND_DOWN);\n\n this.logger.info(\n `Processing transfer: ${amountValue} HBAR (rounded to ${roundedAmount}) for account ${accountId.toString()}`\n );\n\n const sdkHbarAmount = Hbar.fromString(roundedAmount);\n processedTransfers.push({\n accountId,\n amount: amountBigNum,\n hbar: sdkHbarAmount,\n });\n\n const tinybarsContribution = sdkHbarAmount.toTinybars();\n netZeroInTinybars = netZeroInTinybars.plus(\n tinybarsContribution.toString()\n );\n }\n\n if (!netZeroInTinybars.isZero()) {\n this.logger.warn(\n `Transfer sum not zero: ${netZeroInTinybars.toString()} tinybars off. Adjusting last transfer.`\n );\n\n if (processedTransfers.length > 0) {\n const lastTransfer =\n processedTransfers[processedTransfers.length - 1];\n const adjustment = netZeroInTinybars.dividedBy(-100000000);\n const adjustedAmount = lastTransfer.amount.plus(adjustment);\n const adjustedRounded = adjustedAmount.toFixed(\n 8,\n BigNumber.ROUND_DOWN\n );\n lastTransfer.hbar = Hbar.fromString(adjustedRounded);\n\n this.logger.info(\n `Adjusted last transfer for ${lastTransfer.accountId.toString()} to ${adjustedRounded} HBAR`\n );\n }\n }\n\n for (const transfer of processedTransfers) {\n transaction.addHbarTransfer(transfer.accountId, transfer.hbar);\n }\n }\n\n if (typeof params.memo !== 'undefined') {\n if (params.memo === null) {\n this.logger.warn('Received null for memo in transferHbar.');\n } else {\n transaction.setTransactionMemo(params.memo);\n }\n }\n\n this.setCurrentTransaction(transaction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AgB,SAAS,WAAW,SAAS,IAAI;AAAA,MAC/D;AAAA,IACF;AAEA,QAAI,OAAO,OAAO,SAAS,aAAa;AACtC,UAAI,OAAO,SAAS,MAAM;AACxB,aAAK,OAAO,KAAK,yCAAyC;AAAA,MAC5D,OAAO;AACL,oBAAY,mBAAmB,OAAO,IAAI;AAAA,MAC5C;AAAA,IACF;AAEA,SAAK,sBAAsB,WAAW;AACtC,WAAO;AAAA,EACT;AACF;"}
1
+ {"version":3,"file":"index42.js","sources":["../../src/types/content-reference.ts"],"sourcesContent":["/**\n * Content Reference System Types\n *\n * Shared interfaces for the Reference-Based Content System that handles\n * large content storage with unique reference IDs to optimize context window usage.\n */\n\n/**\n * Unique identifier for stored content references\n * Format: Cryptographically secure 32-byte identifier with base64url encoding\n */\nexport type ReferenceId = string;\n\n/**\n * Lifecycle state of a content reference\n */\nexport type ReferenceLifecycleState =\n | 'active'\n | 'expired'\n | 'cleanup_pending'\n | 'invalid';\n\n/**\n * Content types supported by the reference system\n */\nexport type ContentType =\n | 'text'\n | 'json'\n | 'html'\n | 'markdown'\n | 'binary'\n | 'unknown';\n\n/**\n * Sources that created the content reference\n */\nexport type ContentSource =\n | 'mcp_tool'\n | 'user_upload'\n | 'agent_generated'\n | 'system';\n\n/**\n * Metadata associated with stored content\n */\nexport interface ContentMetadata {\n /** Content type classification */\n contentType: ContentType;\n\n /** MIME type of the original content */\n mimeType?: string;\n\n /** Size in bytes of the stored content */\n sizeBytes: number;\n\n /** When the content was originally stored */\n createdAt: Date;\n\n /** Last time the content was accessed via reference resolution */\n lastAccessedAt: Date;\n\n /** Source that created this content reference */\n source: ContentSource;\n\n /** Name of the MCP tool that generated the content (if applicable) */\n mcpToolName?: string;\n\n /** Original filename or suggested name for the content */\n fileName?: string;\n\n /** Number of times this reference has been resolved */\n accessCount: number;\n\n /** Tags for categorization and cleanup policies */\n tags?: string[];\n\n /** Custom metadata from the source */\n customMetadata?: Record<string, unknown>;\n}\n\n/**\n * Core content reference object passed through agent context\n * Designed to be lightweight (<100 tokens) while providing enough\n * information for agent decision-making\n */\nexport interface ContentReference {\n /** Unique identifier for resolving the content */\n referenceId: ReferenceId;\n\n /** Current lifecycle state */\n state: ReferenceLifecycleState;\n\n /** Brief description or preview of the content (max 200 chars) */\n preview: string;\n\n /** Essential metadata for agent decision-making */\n metadata: Pick<\n ContentMetadata,\n 'contentType' | 'sizeBytes' | 'source' | 'fileName' | 'mimeType'\n >;\n\n /** When this reference was created */\n createdAt: Date;\n\n /** Special format indicator for reference IDs in content */\n readonly format: 'ref://{id}';\n}\n\n/**\n * Result of attempting to resolve a content reference\n */\nexport interface ReferenceResolutionResult {\n /** Whether the resolution was successful */\n success: boolean;\n\n /** The resolved content if successful */\n content?: Buffer;\n\n /** Complete metadata if successful */\n metadata?: ContentMetadata;\n\n /** Error message if resolution failed */\n error?: string;\n\n /** Specific error type for targeted error handling */\n errorType?:\n | 'not_found'\n | 'expired'\n | 'corrupted'\n | 'access_denied'\n | 'system_error';\n\n /** Suggested actions for recovery */\n suggestedActions?: string[];\n}\n\n/**\n * Configuration for content reference storage and lifecycle\n */\nexport interface ContentReferenceConfig {\n /** Size threshold above which content should be stored as references (default: 10KB) */\n sizeThresholdBytes: number;\n\n /** Maximum age for unused references before cleanup (default: 1 hour) */\n maxAgeMs: number;\n\n /** Maximum number of references to store simultaneously */\n maxReferences: number;\n\n /** Maximum total storage size for all references */\n maxTotalStorageBytes: number;\n\n /** Whether to enable automatic cleanup */\n enableAutoCleanup: boolean;\n\n /** Interval for cleanup checks in milliseconds */\n cleanupIntervalMs: number;\n\n /** Whether to persist references across restarts */\n enablePersistence: boolean;\n\n /** Storage backend configuration */\n storageBackend: 'memory' | 'filesystem' | 'hybrid';\n\n /** Cleanup policies for different content types */\n cleanupPolicies: {\n /** Policy for content marked as \"recent\" from MCP tools */\n recent: { maxAgeMs: number; priority: number };\n\n /** Policy for user-uploaded content */\n userContent: { maxAgeMs: number; priority: number };\n\n /** Policy for agent-generated content */\n agentGenerated: { maxAgeMs: number; priority: number };\n\n /** Default policy for other content */\n default: { maxAgeMs: number; priority: number };\n };\n}\n\n/**\n * Default configuration values\n */\nexport const DEFAULT_CONTENT_REFERENCE_CONFIG: ContentReferenceConfig = {\n sizeThresholdBytes: 10 * 1024,\n maxAgeMs: 60 * 60 * 1000,\n maxReferences: 100,\n maxTotalStorageBytes: 100 * 1024 * 1024,\n enableAutoCleanup: true,\n cleanupIntervalMs: 5 * 60 * 1000,\n enablePersistence: false,\n storageBackend: 'memory',\n cleanupPolicies: {\n recent: { maxAgeMs: 30 * 60 * 1000, priority: 1 },\n userContent: { maxAgeMs: 2 * 60 * 60 * 1000, priority: 2 },\n agentGenerated: { maxAgeMs: 60 * 60 * 1000, priority: 3 },\n default: { maxAgeMs: 60 * 60 * 1000, priority: 4 },\n },\n};\n\n/**\n * Statistics about content reference usage and storage\n */\nexport interface ContentReferenceStats {\n /** Total number of active references */\n activeReferences: number;\n\n /** Total storage used by all references in bytes */\n totalStorageBytes: number;\n\n /** Number of references cleaned up in last cleanup cycle */\n recentlyCleanedUp: number;\n\n /** Number of successful reference resolutions since startup */\n totalResolutions: number;\n\n /** Number of failed resolution attempts */\n failedResolutions: number;\n\n /** Average content size in bytes */\n averageContentSize: number;\n\n /** Most frequently accessed reference ID */\n mostAccessedReferenceId?: ReferenceId;\n\n /** Storage utilization percentage */\n storageUtilization: number;\n\n /** Performance metrics */\n performanceMetrics: {\n /** Average time to create a reference in milliseconds */\n averageCreationTimeMs: number;\n\n /** Average time to resolve a reference in milliseconds */\n averageResolutionTimeMs: number;\n\n /** Average cleanup time in milliseconds */\n averageCleanupTimeMs: number;\n };\n}\n\n/**\n * Error types for content reference operations\n */\nexport class ContentReferenceError extends Error {\n constructor(\n message: string,\n public readonly type: ReferenceResolutionResult['errorType'],\n public readonly referenceId?: ReferenceId,\n public readonly suggestedActions?: string[]\n ) {\n super(message);\n this.name = 'ContentReferenceError';\n }\n}\n\n/**\n * Interface for content reference storage implementations\n */\nexport interface ContentReferenceStore {\n /**\n * Store content and return a reference\n */\n storeContent(\n content: Buffer,\n metadata: Omit<\n ContentMetadata,\n 'createdAt' | 'lastAccessedAt' | 'accessCount'\n >\n ): Promise<ContentReference>;\n\n /**\n * Resolve a reference to its content\n */\n resolveReference(\n referenceId: ReferenceId\n ): Promise<ReferenceResolutionResult>;\n\n /**\n * Check if a reference exists and is valid\n */\n hasReference(referenceId: ReferenceId): Promise<boolean>;\n\n /**\n * Mark a reference for cleanup\n */\n cleanupReference(referenceId: ReferenceId): Promise<boolean>;\n\n /**\n * Get current storage statistics\n */\n getStats(): Promise<ContentReferenceStats>;\n\n /**\n * Update configuration\n */\n updateConfig(config: Partial<ContentReferenceConfig>): Promise<void>;\n\n /**\n * Perform cleanup based on current policies\n */\n performCleanup(): Promise<{ cleanedUp: number; errors: string[] }>;\n\n /**\n * Dispose of resources\n */\n dispose(): Promise<void>;\n}\n"],"names":[],"mappings":"AAuLO,MAAM,mCAA2D;AAAA,EACtE,oBAAoB,KAAK;AAAA,EACzB,UAAU,KAAK,KAAK;AAAA,EACpB,eAAe;AAAA,EACf,sBAAsB,MAAM,OAAO;AAAA,EACnC,mBAAmB;AAAA,EACnB,mBAAmB,IAAI,KAAK;AAAA,EAC5B,mBAAmB;AAAA,EACnB,gBAAgB;AAAA,EAChB,iBAAiB;AAAA,IACf,QAAQ,EAAE,UAAU,KAAK,KAAK,KAAM,UAAU,EAAA;AAAA,IAC9C,aAAa,EAAE,UAAU,IAAI,KAAK,KAAK,KAAM,UAAU,EAAA;AAAA,IACvD,gBAAgB,EAAE,UAAU,KAAK,KAAK,KAAM,UAAU,EAAA;AAAA,IACtD,SAAS,EAAE,UAAU,KAAK,KAAK,KAAM,UAAU,EAAA;AAAA,EAAE;AAErD;AA8CO,MAAM,8BAA8B,MAAM;AAAA,EAC/C,YACE,SACgB,MACA,aACA,kBAChB;AACA,UAAM,OAAO;AAJG,SAAA,OAAA;AACA,SAAA,cAAA;AACA,SAAA,mBAAA;AAGhB,SAAK,OAAO;AAAA,EACd;AACF;"}
@@ -1,10 +1,8 @@
1
- const FIELD_PRIORITIES = {
2
- ESSENTIAL: "essential",
3
- COMMON: "common",
4
- ADVANCED: "advanced",
5
- EXPERT: "expert"
1
+ const ERROR_MESSAGES = {
2
+ TOO_MANY_REQUESTS: "Too many requests. Please wait a moment and try again.",
3
+ RATE_LIMITED: "I'm receiving too many requests right now. Please wait a moment and try again."
6
4
  };
7
5
  export {
8
- FIELD_PRIORITIES
6
+ ERROR_MESSAGES
9
7
  };
10
8
  //# sourceMappingURL=index43.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index43.js","sources":["../../src/constants/form-priorities.ts"],"sourcesContent":["/**\n * Form field priorities for progressive disclosure\n */\nexport const FIELD_PRIORITIES = {\n ESSENTIAL: 'essential',\n COMMON: 'common', \n ADVANCED: 'advanced',\n EXPERT: 'expert'\n} as const;\n\n/**\n * Form field types\n */\nexport const FORM_FIELD_TYPES = {\n TEXT: 'text',\n NUMBER: 'number',\n SELECT: 'select',\n CHECKBOX: 'checkbox',\n TEXTAREA: 'textarea',\n FILE: 'file',\n ARRAY: 'array',\n OBJECT: 'object',\n CURRENCY: 'currency',\n PERCENTAGE: 'percentage',\n} as const;"],"names":[],"mappings":"AAGO,MAAM,mBAAmB;AAAA,EAC9B,WAAW;AAAA,EACX,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,QAAQ;AACV;"}
1
+ {"version":3,"file":"index43.js","sources":["../../src/constants/messages.ts"],"sourcesContent":["/**\n * Common error messages and user feedback strings\n */\nexport const ERROR_MESSAGES = {\n TOO_MANY_REQUESTS: 'Too many requests. Please wait a moment and try again.',\n RATE_LIMITED: \"I'm receiving too many requests right now. Please wait a moment and try again.\",\n SYSTEM_ERROR: 'System error occurred',\n INVALID_INPUT: 'Invalid input provided',\n NETWORK_ERROR: 'Network error occurred',\n} as const;\n\n/**\n * Common success and status messages\n */\nexport const STATUS_MESSAGES = {\n OPERATION_SUCCESSFUL: 'Operation completed successfully',\n PROCESSING: 'Processing your request...',\n READY: 'Ready to process requests',\n INITIALIZING: 'Initializing...',\n} as const;"],"names":[],"mappings":"AAGO,MAAM,iBAAiB;AAAA,EAC5B,mBAAmB;AAAA,EACnB,cAAc;AAIhB;"}
@@ -1,30 +1,15 @@
1
- const DEFAULT_CONTENT_REFERENCE_CONFIG = {
2
- sizeThresholdBytes: 10 * 1024,
3
- maxAgeMs: 60 * 60 * 1e3,
4
- maxReferences: 100,
5
- maxTotalStorageBytes: 100 * 1024 * 1024,
6
- enableAutoCleanup: true,
7
- cleanupIntervalMs: 5 * 60 * 1e3,
8
- enablePersistence: false,
9
- storageBackend: "memory",
10
- cleanupPolicies: {
11
- recent: { maxAgeMs: 30 * 60 * 1e3, priority: 1 },
12
- userContent: { maxAgeMs: 2 * 60 * 60 * 1e3, priority: 2 },
13
- agentGenerated: { maxAgeMs: 60 * 60 * 1e3, priority: 3 },
14
- default: { maxAgeMs: 60 * 60 * 1e3, priority: 4 }
15
- }
1
+ import { EntityFormat } from "./index26.js";
2
+ const ENTITY_PATTERNS = {
3
+ TOPIC_REFERENCE: "the topic",
4
+ TOKEN_REFERENCE: "the token"
16
5
  };
17
- class ContentReferenceError extends Error {
18
- constructor(message, type, referenceId, suggestedActions) {
19
- super(message);
20
- this.type = type;
21
- this.referenceId = referenceId;
22
- this.suggestedActions = suggestedActions;
23
- this.name = "ContentReferenceError";
24
- }
25
- }
6
+ ({
7
+ TOPIC: EntityFormat.TOPIC_ID,
8
+ TOKEN: EntityFormat.TOKEN_ID,
9
+ ACCOUNT: EntityFormat.ACCOUNT_ID,
10
+ CONTRACT: EntityFormat.CONTRACT_ID
11
+ });
26
12
  export {
27
- ContentReferenceError,
28
- DEFAULT_CONTENT_REFERENCE_CONFIG
13
+ ENTITY_PATTERNS
29
14
  };
30
15
  //# sourceMappingURL=index44.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index44.js","sources":["../../src/types/content-reference.ts"],"sourcesContent":["/**\n * Content Reference System Types\n *\n * Shared interfaces for the Reference-Based Content System that handles\n * large content storage with unique reference IDs to optimize context window usage.\n */\n\n/**\n * Unique identifier for stored content references\n * Format: Cryptographically secure 32-byte identifier with base64url encoding\n */\nexport type ReferenceId = string;\n\n/**\n * Lifecycle state of a content reference\n */\nexport type ReferenceLifecycleState =\n | 'active'\n | 'expired'\n | 'cleanup_pending'\n | 'invalid';\n\n/**\n * Content types supported by the reference system\n */\nexport type ContentType =\n | 'text'\n | 'json'\n | 'html'\n | 'markdown'\n | 'binary'\n | 'unknown';\n\n/**\n * Sources that created the content reference\n */\nexport type ContentSource =\n | 'mcp_tool'\n | 'user_upload'\n | 'agent_generated'\n | 'system';\n\n/**\n * Metadata associated with stored content\n */\nexport interface ContentMetadata {\n /** Content type classification */\n contentType: ContentType;\n\n /** MIME type of the original content */\n mimeType?: string;\n\n /** Size in bytes of the stored content */\n sizeBytes: number;\n\n /** When the content was originally stored */\n createdAt: Date;\n\n /** Last time the content was accessed via reference resolution */\n lastAccessedAt: Date;\n\n /** Source that created this content reference */\n source: ContentSource;\n\n /** Name of the MCP tool that generated the content (if applicable) */\n mcpToolName?: string;\n\n /** Original filename or suggested name for the content */\n fileName?: string;\n\n /** Number of times this reference has been resolved */\n accessCount: number;\n\n /** Tags for categorization and cleanup policies */\n tags?: string[];\n\n /** Custom metadata from the source */\n customMetadata?: Record<string, unknown>;\n}\n\n/**\n * Core content reference object passed through agent context\n * Designed to be lightweight (<100 tokens) while providing enough\n * information for agent decision-making\n */\nexport interface ContentReference {\n /** Unique identifier for resolving the content */\n referenceId: ReferenceId;\n\n /** Current lifecycle state */\n state: ReferenceLifecycleState;\n\n /** Brief description or preview of the content (max 200 chars) */\n preview: string;\n\n /** Essential metadata for agent decision-making */\n metadata: Pick<\n ContentMetadata,\n 'contentType' | 'sizeBytes' | 'source' | 'fileName' | 'mimeType'\n >;\n\n /** When this reference was created */\n createdAt: Date;\n\n /** Special format indicator for reference IDs in content */\n readonly format: 'ref://{id}';\n}\n\n/**\n * Result of attempting to resolve a content reference\n */\nexport interface ReferenceResolutionResult {\n /** Whether the resolution was successful */\n success: boolean;\n\n /** The resolved content if successful */\n content?: Buffer;\n\n /** Complete metadata if successful */\n metadata?: ContentMetadata;\n\n /** Error message if resolution failed */\n error?: string;\n\n /** Specific error type for targeted error handling */\n errorType?:\n | 'not_found'\n | 'expired'\n | 'corrupted'\n | 'access_denied'\n | 'system_error';\n\n /** Suggested actions for recovery */\n suggestedActions?: string[];\n}\n\n/**\n * Configuration for content reference storage and lifecycle\n */\nexport interface ContentReferenceConfig {\n /** Size threshold above which content should be stored as references (default: 10KB) */\n sizeThresholdBytes: number;\n\n /** Maximum age for unused references before cleanup (default: 1 hour) */\n maxAgeMs: number;\n\n /** Maximum number of references to store simultaneously */\n maxReferences: number;\n\n /** Maximum total storage size for all references */\n maxTotalStorageBytes: number;\n\n /** Whether to enable automatic cleanup */\n enableAutoCleanup: boolean;\n\n /** Interval for cleanup checks in milliseconds */\n cleanupIntervalMs: number;\n\n /** Whether to persist references across restarts */\n enablePersistence: boolean;\n\n /** Storage backend configuration */\n storageBackend: 'memory' | 'filesystem' | 'hybrid';\n\n /** Cleanup policies for different content types */\n cleanupPolicies: {\n /** Policy for content marked as \"recent\" from MCP tools */\n recent: { maxAgeMs: number; priority: number };\n\n /** Policy for user-uploaded content */\n userContent: { maxAgeMs: number; priority: number };\n\n /** Policy for agent-generated content */\n agentGenerated: { maxAgeMs: number; priority: number };\n\n /** Default policy for other content */\n default: { maxAgeMs: number; priority: number };\n };\n}\n\n/**\n * Default configuration values\n */\nexport const DEFAULT_CONTENT_REFERENCE_CONFIG: ContentReferenceConfig = {\n sizeThresholdBytes: 10 * 1024,\n maxAgeMs: 60 * 60 * 1000,\n maxReferences: 100,\n maxTotalStorageBytes: 100 * 1024 * 1024,\n enableAutoCleanup: true,\n cleanupIntervalMs: 5 * 60 * 1000,\n enablePersistence: false,\n storageBackend: 'memory',\n cleanupPolicies: {\n recent: { maxAgeMs: 30 * 60 * 1000, priority: 1 },\n userContent: { maxAgeMs: 2 * 60 * 60 * 1000, priority: 2 },\n agentGenerated: { maxAgeMs: 60 * 60 * 1000, priority: 3 },\n default: { maxAgeMs: 60 * 60 * 1000, priority: 4 },\n },\n};\n\n/**\n * Statistics about content reference usage and storage\n */\nexport interface ContentReferenceStats {\n /** Total number of active references */\n activeReferences: number;\n\n /** Total storage used by all references in bytes */\n totalStorageBytes: number;\n\n /** Number of references cleaned up in last cleanup cycle */\n recentlyCleanedUp: number;\n\n /** Number of successful reference resolutions since startup */\n totalResolutions: number;\n\n /** Number of failed resolution attempts */\n failedResolutions: number;\n\n /** Average content size in bytes */\n averageContentSize: number;\n\n /** Most frequently accessed reference ID */\n mostAccessedReferenceId?: ReferenceId;\n\n /** Storage utilization percentage */\n storageUtilization: number;\n\n /** Performance metrics */\n performanceMetrics: {\n /** Average time to create a reference in milliseconds */\n averageCreationTimeMs: number;\n\n /** Average time to resolve a reference in milliseconds */\n averageResolutionTimeMs: number;\n\n /** Average cleanup time in milliseconds */\n averageCleanupTimeMs: number;\n };\n}\n\n/**\n * Error types for content reference operations\n */\nexport class ContentReferenceError extends Error {\n constructor(\n message: string,\n public readonly type: ReferenceResolutionResult['errorType'],\n public readonly referenceId?: ReferenceId,\n public readonly suggestedActions?: string[]\n ) {\n super(message);\n this.name = 'ContentReferenceError';\n }\n}\n\n/**\n * Interface for content reference storage implementations\n */\nexport interface ContentReferenceStore {\n /**\n * Store content and return a reference\n */\n storeContent(\n content: Buffer,\n metadata: Omit<\n ContentMetadata,\n 'createdAt' | 'lastAccessedAt' | 'accessCount'\n >\n ): Promise<ContentReference>;\n\n /**\n * Resolve a reference to its content\n */\n resolveReference(\n referenceId: ReferenceId\n ): Promise<ReferenceResolutionResult>;\n\n /**\n * Check if a reference exists and is valid\n */\n hasReference(referenceId: ReferenceId): Promise<boolean>;\n\n /**\n * Mark a reference for cleanup\n */\n cleanupReference(referenceId: ReferenceId): Promise<boolean>;\n\n /**\n * Get current storage statistics\n */\n getStats(): Promise<ContentReferenceStats>;\n\n /**\n * Update configuration\n */\n updateConfig(config: Partial<ContentReferenceConfig>): Promise<void>;\n\n /**\n * Perform cleanup based on current policies\n */\n performCleanup(): Promise<{ cleanedUp: number; errors: string[] }>;\n\n /**\n * Dispose of resources\n */\n dispose(): Promise<void>;\n}\n"],"names":[],"mappings":"AAuLO,MAAM,mCAA2D;AAAA,EACtE,oBAAoB,KAAK;AAAA,EACzB,UAAU,KAAK,KAAK;AAAA,EACpB,eAAe;AAAA,EACf,sBAAsB,MAAM,OAAO;AAAA,EACnC,mBAAmB;AAAA,EACnB,mBAAmB,IAAI,KAAK;AAAA,EAC5B,mBAAmB;AAAA,EACnB,gBAAgB;AAAA,EAChB,iBAAiB;AAAA,IACf,QAAQ,EAAE,UAAU,KAAK,KAAK,KAAM,UAAU,EAAA;AAAA,IAC9C,aAAa,EAAE,UAAU,IAAI,KAAK,KAAK,KAAM,UAAU,EAAA;AAAA,IACvD,gBAAgB,EAAE,UAAU,KAAK,KAAK,KAAM,UAAU,EAAA;AAAA,IACtD,SAAS,EAAE,UAAU,KAAK,KAAK,KAAM,UAAU,EAAA;AAAA,EAAE;AAErD;AA8CO,MAAM,8BAA8B,MAAM;AAAA,EAC/C,YACE,SACgB,MACA,aACA,kBAChB;AACA,UAAM,OAAO;AAJG,SAAA,OAAA;AACA,SAAA,cAAA;AACA,SAAA,mBAAA;AAGhB,SAAK,OAAO;AAAA,EACd;AACF;"}
1
+ {"version":3,"file":"index44.js","sources":["../../src/constants/entity-references.ts"],"sourcesContent":["/**\n * Common entity reference patterns used across the application\n */\nexport const ENTITY_PATTERNS = {\n TOPIC_REFERENCE: 'the topic',\n TOKEN_REFERENCE: 'the token',\n ACCOUNT_REFERENCE: 'the account',\n TRANSACTION_REFERENCE: 'the transaction',\n CONTRACT_REFERENCE: 'the contract',\n} as const;\n\n/**\n * Entity type identifiers\n */\nimport { EntityFormat } from '../services/formatters/types';\n\nexport const ENTITY_TYPES = {\n TOPIC: EntityFormat.TOPIC_ID,\n TOKEN: EntityFormat.TOKEN_ID,\n ACCOUNT: EntityFormat.ACCOUNT_ID,\n TRANSACTION: 'transaction',\n CONTRACT: EntityFormat.CONTRACT_ID,\n} as const;\n"],"names":[],"mappings":";AAGO,MAAM,kBAAkB;AAAA,EAC7B,iBAAiB;AAAA,EACjB,iBAAiB;AAInB;AAAA,CAO4B;AAAA,EAC1B,OAAO,aAAa;AAAA,EACpB,OAAO,aAAa;AAAA,EACpB,SAAS,aAAa;AAAA,EAEtB,UAAU,aAAa;AACzB;"}