@hashgraphonline/conversational-agent 0.2.213 → 0.2.214
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/esm/index10.js +2 -2
- package/dist/esm/index21.js +1 -1
- package/dist/esm/index23.js +1 -1
- package/dist/esm/index33.js +4 -4
- package/dist/esm/index42.js +4 -26
- package/dist/esm/index42.js.map +1 -1
- package/dist/esm/index43.js +11 -4
- package/dist/esm/index43.js.map +1 -1
- package/dist/esm/index44.js +322 -12
- package/dist/esm/index44.js.map +1 -1
- package/dist/esm/index45.js +142 -280
- package/dist/esm/index45.js.map +1 -1
- package/dist/esm/index46.js +7 -184
- package/dist/esm/index46.js.map +1 -1
- package/dist/esm/index47.js +26 -6
- package/dist/esm/index47.js.map +1 -1
- package/package.json +2 -2
package/dist/esm/index46.js
CHANGED
|
@@ -1,187 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
this.memory = memory;
|
|
8
|
-
this.logger = logger || new Logger({ module: "ExecutionPipeline" });
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Execute a tool through the pipeline
|
|
12
|
-
*/
|
|
13
|
-
async execute(toolName, input, sessionContext) {
|
|
14
|
-
const traceId = `trace-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
15
|
-
const startTime = Date.now();
|
|
16
|
-
const toolEntry = this.toolRegistry.getTool(toolName);
|
|
17
|
-
if (!toolEntry) {
|
|
18
|
-
throw new Error(`Tool not found in registry: ${toolName}`);
|
|
19
|
-
}
|
|
20
|
-
const context = {
|
|
21
|
-
toolName,
|
|
22
|
-
input,
|
|
23
|
-
session: sessionContext || this.buildDefaultSession(),
|
|
24
|
-
memory: this.memory,
|
|
25
|
-
traceId,
|
|
26
|
-
toolEntry
|
|
27
|
-
};
|
|
28
|
-
try {
|
|
29
|
-
const shouldGenerateForm = await this.checkFormGeneration(context);
|
|
30
|
-
if (shouldGenerateForm.requiresForm && shouldGenerateForm.formMessage) {
|
|
31
|
-
return {
|
|
32
|
-
success: false,
|
|
33
|
-
output: "Form generation required",
|
|
34
|
-
requiresForm: true,
|
|
35
|
-
formMessage: shouldGenerateForm.formMessage,
|
|
36
|
-
traceId,
|
|
37
|
-
executionTime: Date.now() - startTime
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
const result = await this.executeToolDirect(context);
|
|
41
|
-
return {
|
|
42
|
-
success: true,
|
|
43
|
-
output: result,
|
|
44
|
-
traceId,
|
|
45
|
-
executionTime: Date.now() - startTime
|
|
46
|
-
};
|
|
47
|
-
} catch (error) {
|
|
48
|
-
return this.handleExecutionError(
|
|
49
|
-
error,
|
|
50
|
-
context,
|
|
51
|
-
traceId,
|
|
52
|
-
Date.now() - startTime
|
|
53
|
-
);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Execute tool with validation
|
|
58
|
-
*/
|
|
59
|
-
async executeWithValidation(toolName, input, sessionContext) {
|
|
60
|
-
return this.execute(toolName, input, sessionContext);
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Process form submission
|
|
64
|
-
*/
|
|
65
|
-
async processFormSubmission(toolName, formId, parameters, sessionContext) {
|
|
66
|
-
const traceId = `form-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
67
|
-
const startTime = Date.now();
|
|
68
|
-
try {
|
|
69
|
-
const formSubmission = {
|
|
70
|
-
formId,
|
|
71
|
-
toolName,
|
|
72
|
-
parameters,
|
|
73
|
-
timestamp: Date.now()
|
|
74
|
-
};
|
|
75
|
-
const processedInput = await this.formEngine.processSubmission(
|
|
76
|
-
formSubmission
|
|
77
|
-
);
|
|
78
|
-
return this.execute(toolName, processedInput, sessionContext);
|
|
79
|
-
} catch (error) {
|
|
80
|
-
return {
|
|
81
|
-
success: false,
|
|
82
|
-
output: "Form submission processing failed",
|
|
83
|
-
error: error instanceof Error ? error.message : String(error),
|
|
84
|
-
traceId,
|
|
85
|
-
executionTime: Date.now() - startTime
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Check if form generation is required
|
|
91
|
-
*/
|
|
92
|
-
async checkFormGeneration(context) {
|
|
93
|
-
const inputRecord = context.input;
|
|
94
|
-
if (inputRecord?.__fromForm === true || inputRecord?.renderForm === false) {
|
|
95
|
-
return { requiresForm: false };
|
|
96
|
-
}
|
|
97
|
-
if (!this.formEngine.shouldGenerateForm(context.toolEntry.tool, context.input)) {
|
|
98
|
-
return { requiresForm: false };
|
|
99
|
-
}
|
|
100
|
-
const formMessage = await this.formEngine.generateForm(
|
|
101
|
-
context.toolName,
|
|
102
|
-
context.toolEntry.tool,
|
|
103
|
-
context.input
|
|
104
|
-
);
|
|
105
|
-
if (formMessage) {
|
|
106
|
-
return { requiresForm: true, formMessage };
|
|
107
|
-
}
|
|
108
|
-
return { requiresForm: false };
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* Execute tool directly
|
|
112
|
-
*/
|
|
113
|
-
async executeToolDirect(context) {
|
|
114
|
-
const { toolEntry, input } = context;
|
|
115
|
-
const parameters = input || {};
|
|
116
|
-
const mergedArgs = { ...parameters, renderForm: false };
|
|
117
|
-
if (toolEntry.wrapper) {
|
|
118
|
-
return this.executeWrappedTool(toolEntry, mergedArgs);
|
|
119
|
-
}
|
|
120
|
-
return await toolEntry.tool.call(mergedArgs);
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* Execute wrapped tool
|
|
124
|
-
*/
|
|
125
|
-
async executeWrappedTool(toolEntry, mergedArgs) {
|
|
126
|
-
const wrapper = toolEntry.wrapper;
|
|
127
|
-
if (!wrapper) {
|
|
128
|
-
throw new Error("Tool wrapper not found");
|
|
129
|
-
}
|
|
130
|
-
const wrapperAsAny = wrapper;
|
|
131
|
-
if (wrapperAsAny.executeOriginal) {
|
|
132
|
-
return await wrapperAsAny.executeOriginal(mergedArgs);
|
|
133
|
-
}
|
|
134
|
-
if (wrapperAsAny.originalTool?.call) {
|
|
135
|
-
return await wrapperAsAny.originalTool.call(mergedArgs);
|
|
136
|
-
}
|
|
137
|
-
return await toolEntry.originalTool.call(mergedArgs);
|
|
138
|
-
}
|
|
139
|
-
/**
|
|
140
|
-
* Handle execution error
|
|
141
|
-
*/
|
|
142
|
-
handleExecutionError(error, context, traceId, executionTime) {
|
|
143
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
144
|
-
if (error instanceof ZodError) {
|
|
145
|
-
return {
|
|
146
|
-
success: false,
|
|
147
|
-
output: "Validation error occurred",
|
|
148
|
-
error: errorMessage,
|
|
149
|
-
traceId,
|
|
150
|
-
executionTime
|
|
151
|
-
};
|
|
152
|
-
}
|
|
153
|
-
this.logger.error(`Tool execution failed: ${context.toolName}`, {
|
|
154
|
-
traceId,
|
|
155
|
-
error: errorMessage
|
|
156
|
-
});
|
|
157
|
-
return {
|
|
158
|
-
success: false,
|
|
159
|
-
output: "Tool execution failed",
|
|
160
|
-
error: errorMessage,
|
|
161
|
-
traceId,
|
|
162
|
-
executionTime
|
|
163
|
-
};
|
|
164
|
-
}
|
|
165
|
-
/**
|
|
166
|
-
* Build default session context
|
|
167
|
-
*/
|
|
168
|
-
buildDefaultSession() {
|
|
169
|
-
return {
|
|
170
|
-
sessionId: `session-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`,
|
|
171
|
-
timestamp: Date.now()
|
|
172
|
-
};
|
|
173
|
-
}
|
|
174
|
-
/**
|
|
175
|
-
* Get statistics about the pipeline
|
|
176
|
-
*/
|
|
177
|
-
getStatistics() {
|
|
178
|
-
return {
|
|
179
|
-
totalMiddleware: 0,
|
|
180
|
-
registeredMiddleware: []
|
|
181
|
-
};
|
|
182
|
-
}
|
|
183
|
-
}
|
|
1
|
+
const FIELD_PRIORITIES = {
|
|
2
|
+
ESSENTIAL: "essential",
|
|
3
|
+
COMMON: "common",
|
|
4
|
+
ADVANCED: "advanced",
|
|
5
|
+
EXPERT: "expert"
|
|
6
|
+
};
|
|
184
7
|
export {
|
|
185
|
-
|
|
8
|
+
FIELD_PRIORITIES
|
|
186
9
|
};
|
|
187
10
|
//# sourceMappingURL=index46.js.map
|
package/dist/esm/index46.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index46.js","sources":["../../src/execution/execution-pipeline.ts"],"sourcesContent":["import { ZodError } from 'zod';\nimport { Logger } from '@hashgraphonline/standards-sdk';\nimport { SmartMemoryManager } from '../memory/smart-memory-manager';\nimport { FormEngine, ToolExecutionResult } from '../forms/form-engine';\nimport type { FormMessage, FormSubmission } from '../forms/types';\nimport type { ToolRegistry, ToolRegistryEntry } from '../core/tool-registry';\n\n/**\n * Session context for tool execution\n */\nexport interface SessionContext {\n sessionId: string;\n userId?: string;\n timestamp: number;\n conversationId?: string;\n}\n\n/**\n * Context passed through execution pipeline\n */\nexport interface ExecutionContext {\n toolName: string;\n input: unknown;\n session: SessionContext;\n memory: SmartMemoryManager;\n traceId: string;\n toolEntry: ToolRegistryEntry;\n}\n\n/**\n * Result of tool execution with metadata\n */\nexport interface ExecutionResult extends ToolExecutionResult {\n traceId: string;\n executionTime: number;\n}\n\n/**\n * ExecutionPipeline handles tool execution coordination\n */\nexport class ExecutionPipeline {\n private logger: Logger;\n private toolRegistry: ToolRegistry;\n private formEngine: FormEngine;\n private memory: SmartMemoryManager;\n\n constructor(\n toolRegistry: ToolRegistry,\n formEngine: FormEngine,\n memory: SmartMemoryManager,\n logger?: Logger\n ) {\n this.toolRegistry = toolRegistry;\n this.formEngine = formEngine;\n this.memory = memory;\n this.logger = logger || new Logger({ module: 'ExecutionPipeline' });\n }\n\n /**\n * Execute a tool through the pipeline\n */\n async execute(\n toolName: string,\n input: unknown,\n sessionContext?: SessionContext\n ): Promise<ExecutionResult> {\n const traceId = `trace-${Date.now()}-${Math.random()\n .toString(36)\n .substr(2, 9)}`;\n const startTime = Date.now();\n\n const toolEntry = this.toolRegistry.getTool(toolName);\n if (!toolEntry) {\n throw new Error(`Tool not found in registry: ${toolName}`);\n }\n\n const context: ExecutionContext = {\n toolName,\n input,\n session: sessionContext || this.buildDefaultSession(),\n memory: this.memory,\n traceId,\n toolEntry,\n };\n\n try {\n const shouldGenerateForm = await this.checkFormGeneration(context);\n if (shouldGenerateForm.requiresForm && shouldGenerateForm.formMessage) {\n return {\n success: false,\n output: 'Form generation required',\n requiresForm: true,\n formMessage: shouldGenerateForm.formMessage,\n traceId,\n executionTime: Date.now() - startTime,\n };\n }\n\n const result = await this.executeToolDirect(context);\n\n return {\n success: true,\n output: result,\n traceId,\n executionTime: Date.now() - startTime,\n };\n } catch (error) {\n return this.handleExecutionError(\n error,\n context,\n traceId,\n Date.now() - startTime\n );\n }\n }\n\n /**\n * Execute tool with validation\n */\n async executeWithValidation(\n toolName: string,\n input: unknown,\n sessionContext?: SessionContext\n ): Promise<ExecutionResult> {\n return this.execute(toolName, input, sessionContext);\n }\n\n /**\n * Process form submission\n */\n async processFormSubmission(\n toolName: string,\n formId: string,\n parameters: Record<string, unknown>,\n sessionContext?: SessionContext\n ): Promise<ExecutionResult> {\n const traceId = `form-${Date.now()}-${Math.random()\n .toString(36)\n .substr(2, 9)}`;\n const startTime = Date.now();\n\n try {\n const formSubmission: FormSubmission = {\n formId,\n toolName,\n parameters,\n timestamp: Date.now(),\n };\n\n const processedInput = await this.formEngine.processSubmission(\n formSubmission\n );\n\n return this.execute(toolName, processedInput, sessionContext);\n } catch (error) {\n return {\n success: false,\n output: 'Form submission processing failed',\n error: error instanceof Error ? error.message : String(error),\n traceId,\n executionTime: Date.now() - startTime,\n };\n }\n }\n\n /**\n * Check if form generation is required\n */\n private async checkFormGeneration(context: ExecutionContext): Promise<{\n requiresForm: boolean;\n formMessage?: FormMessage;\n }> {\n const inputRecord = context.input as Record<string, unknown>;\n if (inputRecord?.__fromForm === true || inputRecord?.renderForm === false) {\n return { requiresForm: false };\n }\n\n if (\n !this.formEngine.shouldGenerateForm(context.toolEntry.tool, context.input)\n ) {\n return { requiresForm: false };\n }\n\n const formMessage = await this.formEngine.generateForm(\n context.toolName,\n context.toolEntry.tool,\n context.input\n );\n\n if (formMessage) {\n return { requiresForm: true, formMessage };\n }\n\n return { requiresForm: false };\n }\n\n /**\n * Execute tool directly\n */\n private async executeToolDirect(context: ExecutionContext): Promise<string> {\n const { toolEntry, input } = context;\n const parameters = (input as Record<string, unknown>) || {};\n const mergedArgs = { ...parameters, renderForm: false };\n\n if (toolEntry.wrapper) {\n return this.executeWrappedTool(toolEntry, mergedArgs);\n }\n\n return await toolEntry.tool.call(mergedArgs);\n }\n\n /**\n * Execute wrapped tool\n */\n private async executeWrappedTool(\n toolEntry: ToolRegistryEntry,\n mergedArgs: Record<string, unknown>\n ): Promise<string> {\n const wrapper = toolEntry.wrapper;\n if (!wrapper) {\n throw new Error('Tool wrapper not found');\n }\n\n const wrapperAsAny = wrapper as unknown as {\n executeOriginal?: (args: Record<string, unknown>) => Promise<string>;\n originalTool?: {\n call?: (args: Record<string, unknown>) => Promise<string>;\n };\n };\n\n if (wrapperAsAny.executeOriginal) {\n return await wrapperAsAny.executeOriginal(mergedArgs);\n }\n\n if (wrapperAsAny.originalTool?.call) {\n return await wrapperAsAny.originalTool.call(mergedArgs);\n }\n\n return await toolEntry.originalTool.call(mergedArgs);\n }\n\n /**\n * Handle execution error\n */\n private handleExecutionError(\n error: unknown,\n context: ExecutionContext,\n traceId: string,\n executionTime: number\n ): ExecutionResult {\n const errorMessage = error instanceof Error ? error.message : String(error);\n\n if (error instanceof ZodError) {\n return {\n success: false,\n output: 'Validation error occurred',\n error: errorMessage,\n traceId,\n executionTime,\n };\n }\n\n this.logger.error(`Tool execution failed: ${context.toolName}`, {\n traceId,\n error: errorMessage,\n });\n\n return {\n success: false,\n output: 'Tool execution failed',\n error: errorMessage,\n traceId,\n executionTime,\n };\n }\n\n /**\n * Build default session context\n */\n private buildDefaultSession(): SessionContext {\n return {\n sessionId: `session-${Date.now()}-${Math.random()\n .toString(36)\n .substr(2, 9)}`,\n timestamp: Date.now(),\n };\n }\n\n /**\n * Get statistics about the pipeline\n */\n getStatistics(): {\n totalMiddleware: number;\n registeredMiddleware: string[];\n } {\n return {\n totalMiddleware: 0,\n registeredMiddleware: [],\n };\n }\n}\n"],"names":[],"mappings":";;AAwCO,MAAM,kBAAkB;AAAA,EAM7B,YACE,cACA,YACA,QACA,QACA;AACA,SAAK,eAAe;AACpB,SAAK,aAAa;AAClB,SAAK,SAAS;AACd,SAAK,SAAS,UAAU,IAAI,OAAO,EAAE,QAAQ,qBAAqB;AAAA,EACpE;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,QACJ,UACA,OACA,gBAC0B;AAC1B,UAAM,UAAU,SAAS,KAAK,IAAA,CAAK,IAAI,KAAK,OAAA,EACzC,SAAS,EAAE,EACX,OAAO,GAAG,CAAC,CAAC;AACf,UAAM,YAAY,KAAK,IAAA;AAEvB,UAAM,YAAY,KAAK,aAAa,QAAQ,QAAQ;AACpD,QAAI,CAAC,WAAW;AACd,YAAM,IAAI,MAAM,+BAA+B,QAAQ,EAAE;AAAA,IAC3D;AAEA,UAAM,UAA4B;AAAA,MAChC;AAAA,MACA;AAAA,MACA,SAAS,kBAAkB,KAAK,oBAAA;AAAA,MAChC,QAAQ,KAAK;AAAA,MACb;AAAA,MACA;AAAA,IAAA;AAGF,QAAI;AACF,YAAM,qBAAqB,MAAM,KAAK,oBAAoB,OAAO;AACjE,UAAI,mBAAmB,gBAAgB,mBAAmB,aAAa;AACrE,eAAO;AAAA,UACL,SAAS;AAAA,UACT,QAAQ;AAAA,UACR,cAAc;AAAA,UACd,aAAa,mBAAmB;AAAA,UAChC;AAAA,UACA,eAAe,KAAK,QAAQ;AAAA,QAAA;AAAA,MAEhC;AAEA,YAAM,SAAS,MAAM,KAAK,kBAAkB,OAAO;AAEnD,aAAO;AAAA,QACL,SAAS;AAAA,QACT,QAAQ;A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A,IAAA,CACR;AAED,WAAO;AAAA,MACL,SAAS;AAAA,MACT,QAAQ;AAAA,MACR,OAAO;AAAA,MACP;AAAA,MACA;AAAA,IAAA;AAAA,EAEJ;AAAA;AAAA;AAAA;AAAA,EAKQ,sBAAsC;AAC5C,WAAO;AAAA,MACL,WAAW,WAAW,KAAK,IAAA,CAAK,IAAI,KAAK,OAAA,EACtC,SAAS,EAAE,EACX,OAAO,GAAG,CAAC,CAAC;AAAA,MACf,WAAW,KAAK,IAAA;AAAA,IAAI;AAAA,EAExB;AAAA;AAAA;AAAA;AAAA,EAKA,gBAGE;AACA,WAAO;AAAA,MACL,iBAAiB;AAAA,MACjB,sBAAsB,CAAA;AAAA,IAAC;AAAA,EAE3B;AACF;"}
|
|
1
|
+
{"version":3,"file":"index46.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;"}
|
package/dist/esm/index47.js
CHANGED
|
@@ -1,10 +1,30 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
+
}
|
|
6
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";
|
|
24
|
+
}
|
|
25
|
+
}
|
|
7
26
|
export {
|
|
8
|
-
|
|
27
|
+
ContentReferenceError,
|
|
28
|
+
DEFAULT_CONTENT_REFERENCE_CONFIG
|
|
9
29
|
};
|
|
10
30
|
//# sourceMappingURL=index47.js.map
|
package/dist/esm/index47.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index47.js","sources":["../../src/
|
|
1
|
+
{"version":3,"file":"index47.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;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hashgraphonline/conversational-agent",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.214",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/cjs/index.cjs",
|
|
6
6
|
"module": "./dist/esm/index.js",
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"dependencies": {
|
|
77
77
|
"@hashgraph/sdk": "^2.72.0",
|
|
78
78
|
"@hashgraphonline/hashinal-wc": "^1.0.107",
|
|
79
|
-
"@hashgraphonline/standards-agent-kit": "^0.2.
|
|
79
|
+
"@hashgraphonline/standards-agent-kit": "^0.2.160",
|
|
80
80
|
"@hashgraphonline/standards-sdk": "0.1.110",
|
|
81
81
|
"@langchain/anthropic": "^0.3.28",
|
|
82
82
|
"@langchain/core": "^0.3.77",
|