@minded-ai/mindedjs 2.0.4 → 2.0.6-beta-1
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/agent.d.ts.map +1 -1
- package/dist/agent.js +2 -0
- package/dist/agent.js.map +1 -1
- package/dist/browserTask/executeBrowserTask.d.ts +2 -1
- package/dist/browserTask/executeBrowserTask.d.ts.map +1 -1
- package/dist/browserTask/executeBrowserTask.js +16 -1
- package/dist/browserTask/executeBrowserTask.js.map +1 -1
- package/dist/cli/index.js +0 -0
- package/dist/edges/createPromptRouter.d.ts.map +1 -1
- package/dist/edges/createPromptRouter.js +3 -10
- package/dist/edges/createPromptRouter.js.map +1 -1
- package/dist/guidelines/guidelinesManager.d.ts +37 -0
- package/dist/guidelines/guidelinesManager.d.ts.map +1 -0
- package/dist/guidelines/guidelinesManager.js +172 -0
- package/dist/guidelines/guidelinesManager.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/internalTools/documentExtraction.d.ts +69 -0
- package/dist/internalTools/documentExtraction.d.ts.map +1 -0
- package/dist/internalTools/documentExtraction.js +65 -0
- package/dist/internalTools/documentExtraction.js.map +1 -0
- package/dist/internalTools/managedDocumentParser/managedDocumentParser.d.ts +10 -0
- package/dist/internalTools/managedDocumentParser/managedDocumentParser.d.ts.map +1 -0
- package/dist/internalTools/managedDocumentParser/managedDocumentParser.js +80 -0
- package/dist/internalTools/managedDocumentParser/managedDocumentParser.js.map +1 -0
- package/dist/internalTools/retell.d.ts +12 -0
- package/dist/internalTools/retell.d.ts.map +1 -0
- package/dist/internalTools/retell.js +44 -0
- package/dist/internalTools/retell.js.map +1 -0
- package/dist/internalTools/sendPlaceholderMessage.d.ts +14 -0
- package/dist/internalTools/sendPlaceholderMessage.d.ts.map +1 -0
- package/dist/internalTools/sendPlaceholderMessage.js +51 -0
- package/dist/internalTools/sendPlaceholderMessage.js.map +1 -0
- package/dist/pii-gateway/gateway.d.ts +17 -0
- package/dist/pii-gateway/gateway.d.ts.map +1 -0
- package/dist/pii-gateway/gateway.js +77 -0
- package/dist/pii-gateway/gateway.js.map +1 -0
- package/dist/pii-gateway/index.d.ts +4 -0
- package/dist/pii-gateway/index.d.ts.map +1 -0
- package/dist/pii-gateway/index.js +14 -0
- package/dist/pii-gateway/index.js.map +1 -0
- package/dist/pii-gateway/proxy.d.ts +80 -0
- package/dist/pii-gateway/proxy.d.ts.map +1 -0
- package/dist/pii-gateway/proxy.js +106 -0
- package/dist/pii-gateway/proxy.js.map +1 -0
- package/dist/pii-gateway/types.d.ts +27 -0
- package/dist/pii-gateway/types.d.ts.map +1 -0
- package/dist/pii-gateway/types.js +3 -0
- package/dist/pii-gateway/types.js.map +1 -0
- package/dist/platform/mindedChatOpenAI.d.ts +5 -0
- package/dist/platform/mindedChatOpenAI.d.ts.map +1 -0
- package/dist/platform/mindedChatOpenAI.js +23 -0
- package/dist/platform/mindedChatOpenAI.js.map +1 -0
- package/dist/platform/mindedConnectionTypes.d.ts +10 -0
- package/dist/platform/mindedConnectionTypes.d.ts.map +1 -1
- package/dist/platform/mindedConnectionTypes.js +1 -0
- package/dist/platform/mindedConnectionTypes.js.map +1 -1
- package/dist/platform/mindedUtils.d.ts +1 -0
- package/dist/platform/mindedUtils.d.ts.map +1 -0
- package/dist/platform/mindedUtils.js +2 -0
- package/dist/platform/mindedUtils.js.map +1 -0
- package/dist/platform/parallelAzureChatOpenAI.d.ts +39 -0
- package/dist/platform/parallelAzureChatOpenAI.d.ts.map +1 -0
- package/dist/platform/parallelAzureChatOpenAI.js +114 -0
- package/dist/platform/parallelAzureChatOpenAI.js.map +1 -0
- package/dist/platform/parallelChatOpenAI.d.ts +38 -0
- package/dist/platform/parallelChatOpenAI.d.ts.map +1 -0
- package/dist/platform/parallelChatOpenAI.js +111 -0
- package/dist/platform/parallelChatOpenAI.js.map +1 -0
- package/dist/platform/parallelMindedChatOpenAI.d.ts +39 -0
- package/dist/platform/parallelMindedChatOpenAI.d.ts.map +1 -0
- package/dist/platform/parallelMindedChatOpenAI.js +111 -0
- package/dist/platform/parallelMindedChatOpenAI.js.map +1 -0
- package/dist/platform/piiGateway/proxy.d.ts +20 -0
- package/dist/platform/piiGateway/proxy.d.ts.map +1 -0
- package/dist/platform/piiGateway/proxy.js +24 -0
- package/dist/platform/piiGateway/proxy.js.map +1 -0
- package/dist/types/Agent.d.ts +2 -0
- package/dist/types/Agent.d.ts.map +1 -0
- package/dist/types/Agent.js +18 -0
- package/dist/types/Agent.js.map +1 -0
- package/dist/types/Flows.d.ts +2 -0
- package/dist/types/Flows.d.ts.map +1 -0
- package/dist/types/Flows.js +18 -0
- package/dist/types/Flows.js.map +1 -0
- package/dist/types/LLM.d.ts +2 -0
- package/dist/types/LLM.d.ts.map +1 -0
- package/dist/types/LLM.js +18 -0
- package/dist/types/LLM.js.map +1 -0
- package/dist/types/LangGraph.d.ts +2 -0
- package/dist/types/LangGraph.d.ts.map +1 -0
- package/dist/types/LangGraph.js +18 -0
- package/dist/types/LangGraph.js.map +1 -0
- package/dist/types/Platform.d.ts +2 -0
- package/dist/types/Platform.d.ts.map +1 -0
- package/dist/types/Platform.js +18 -0
- package/dist/types/Platform.js.map +1 -0
- package/dist/types/Tools.d.ts +2 -0
- package/dist/types/Tools.d.ts.map +1 -0
- package/dist/types/Tools.js +18 -0
- package/dist/types/Tools.js.map +1 -0
- package/dist/types/Triggers.d.ts +2 -0
- package/dist/types/Triggers.d.ts.map +1 -0
- package/dist/types/Triggers.js +18 -0
- package/dist/types/Triggers.js.map +1 -0
- package/dist/types/Triggers.types.d.ts +25 -0
- package/dist/types/Triggers.types.d.ts.map +1 -0
- package/dist/types/Triggers.types.js +3 -0
- package/dist/types/Triggers.types.js.map +1 -0
- package/dist/types/Voice.d.ts +2 -0
- package/dist/types/Voice.d.ts.map +1 -0
- package/dist/types/Voice.js +18 -0
- package/dist/types/Voice.js.map +1 -0
- package/dist/types/index.d.ts +9 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +25 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/LogicalConditionDebugger.d.ts +57 -0
- package/dist/utils/LogicalConditionDebugger.d.ts.map +1 -0
- package/dist/utils/LogicalConditionDebugger.js +143 -0
- package/dist/utils/LogicalConditionDebugger.js.map +1 -0
- package/dist/utils/documentProcessor.d.ts +87 -0
- package/dist/utils/documentProcessor.d.ts.map +1 -0
- package/dist/utils/documentProcessor.js +726 -0
- package/dist/utils/documentProcessor.js.map +1 -0
- package/dist/utils/extractStateMemoryResponse.d.ts +1 -0
- package/dist/utils/extractStateMemoryResponse.d.ts.map +1 -0
- package/dist/utils/extractStateMemoryResponse.js +89 -0
- package/dist/utils/extractStateMemoryResponse.js.map +1 -0
- package/dist/utils/extractToolGuidelineParams.d.ts +4 -0
- package/dist/utils/extractToolGuidelineParams.d.ts.map +1 -0
- package/dist/utils/extractToolGuidelineParams.js +20 -0
- package/dist/utils/extractToolGuidelineParams.js.map +1 -0
- package/dist/utils/extractToolMemoryResponse.d.ts +4 -0
- package/dist/utils/extractToolMemoryResponse.d.ts.map +1 -0
- package/dist/utils/extractToolMemoryResponse.js +16 -0
- package/dist/utils/extractToolMemoryResponse.js.map +1 -0
- package/dist/utils/parseAttachments.d.ts +14 -0
- package/dist/utils/parseAttachments.d.ts.map +1 -0
- package/dist/utils/parseAttachments.js +54 -0
- package/dist/utils/parseAttachments.js.map +1 -0
- package/package.json +1 -1
- package/src/agent.ts +7 -0
- package/src/browserTask/executeBrowserTask.ts +24 -0
- package/src/cli/lambdaHandlerTemplate.ts +53 -38
- package/src/debugging/llmCallbackHandler.ts +6 -7
- package/src/edges/createPromptRouter.ts +7 -15
- package/src/index.ts +2 -0
- package/src/internalTools/timer.ts +1 -1
- package/src/platform/mindedConnection.ts +38 -20
- package/src/platform/mindedConnectionTypes.ts +12 -0
- package/src/utils/logger.ts +1 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { ZodSchema } from 'zod';
|
|
2
|
+
import { DocumentProcessorConfig } from './documentProcessor';
|
|
3
|
+
import { BaseLanguageModel } from '@langchain/core/language_models/base';
|
|
4
|
+
/**
|
|
5
|
+
* Extract data from documents using AI or return raw text.
|
|
6
|
+
*
|
|
7
|
+
* This function allows you to process various document types (PDFs, images, Word docs, etc.)
|
|
8
|
+
* in multiple ways:
|
|
9
|
+
* - With LLM + Schema: Extract structured data according to a Zod schema
|
|
10
|
+
* - With LLM + System Prompt: Extract unstructured data based on prompt instructions
|
|
11
|
+
* - Without LLM: Extract raw text content using LlamaParse
|
|
12
|
+
*
|
|
13
|
+
* @param options - Document extraction options
|
|
14
|
+
* @param options.llm - Optional language model for AI-powered extraction
|
|
15
|
+
* @param options.documentPath - Path to the document file
|
|
16
|
+
* @param options.documentContent - Document content as Buffer or string
|
|
17
|
+
* @param options.documentUrl - URL to fetch the document from
|
|
18
|
+
* @param options.schema - Optional Zod schema for structured data extraction
|
|
19
|
+
* @param options.systemPrompt - Optional prompt for guiding extraction
|
|
20
|
+
* @param options.config - Optional document processor configuration
|
|
21
|
+
*
|
|
22
|
+
* @returns Promise resolving to extracted data/text and metadata
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* import { extractFromDocument } from '@minded-ai/mindedjs';
|
|
27
|
+
* import { z } from 'zod';
|
|
28
|
+
*
|
|
29
|
+
* // Extract structured data with schema
|
|
30
|
+
* const result1 = await extractFromDocument({
|
|
31
|
+
* llm: agent.llm,
|
|
32
|
+
* documentPath: './invoice.pdf',
|
|
33
|
+
* schema: z.object({
|
|
34
|
+
* invoiceNumber: z.string(),
|
|
35
|
+
* amount: z.number(),
|
|
36
|
+
* })
|
|
37
|
+
* });
|
|
38
|
+
*
|
|
39
|
+
* // Extract unstructured data with prompt
|
|
40
|
+
* const result2 = await extractFromDocument({
|
|
41
|
+
* llm: agent.llm,
|
|
42
|
+
* documentPath: './contract.pdf',
|
|
43
|
+
* systemPrompt: 'Extract all payment terms and conditions'
|
|
44
|
+
* });
|
|
45
|
+
*
|
|
46
|
+
* // Extract raw text without LLM
|
|
47
|
+
* const result3 = await extractFromDocument({
|
|
48
|
+
* documentPath: './document.pdf'
|
|
49
|
+
* });
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
export declare function extractFromDocument<T = string>(options: {
|
|
53
|
+
llm?: BaseLanguageModel;
|
|
54
|
+
documentPath?: string;
|
|
55
|
+
documentContent?: Buffer | string;
|
|
56
|
+
documentUrl?: string;
|
|
57
|
+
schema?: ZodSchema<T>;
|
|
58
|
+
systemPrompt?: string;
|
|
59
|
+
config?: DocumentProcessorConfig;
|
|
60
|
+
}): Promise<{
|
|
61
|
+
data: T;
|
|
62
|
+
metadata: {
|
|
63
|
+
fileSize?: number;
|
|
64
|
+
fileType: string;
|
|
65
|
+
processingTime: number;
|
|
66
|
+
contentLength: number;
|
|
67
|
+
};
|
|
68
|
+
}>;
|
|
69
|
+
//# sourceMappingURL=documentExtraction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"documentExtraction.d.ts","sourceRoot":"","sources":["../../src/internalTools/documentExtraction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,KAAK,CAAC;AAChC,OAAO,EAAqB,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AACxF,OAAO,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AAEzE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACH,wBAAsB,mBAAmB,CAAC,CAAC,GAAG,MAAM,EAAE,OAAO,EAAE;IAC7D,GAAG,CAAC,EAAE,iBAAiB,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,eAAe,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAClC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,uBAAuB,CAAC;CAClC,GAAG,OAAO,CAAC;IACV,IAAI,EAAE,CAAC,CAAC;IACR,QAAQ,EAAE;QACR,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,QAAQ,EAAE,MAAM,CAAC;QACjB,cAAc,EAAE,MAAM,CAAC;QACvB,aAAa,EAAE,MAAM,CAAC;KACvB,CAAC;CACH,CAAC,CAYD"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.extractFromDocument = extractFromDocument;
|
|
4
|
+
const documentProcessor_1 = require("../utils/documentProcessor");
|
|
5
|
+
/**
|
|
6
|
+
* Extract data from documents using AI or return raw text.
|
|
7
|
+
*
|
|
8
|
+
* This function allows you to process various document types (PDFs, images, Word docs, etc.)
|
|
9
|
+
* in multiple ways:
|
|
10
|
+
* - With LLM + Schema: Extract structured data according to a Zod schema
|
|
11
|
+
* - With LLM + System Prompt: Extract unstructured data based on prompt instructions
|
|
12
|
+
* - Without LLM: Extract raw text content using LlamaParse
|
|
13
|
+
*
|
|
14
|
+
* @param options - Document extraction options
|
|
15
|
+
* @param options.llm - Optional language model for AI-powered extraction
|
|
16
|
+
* @param options.documentPath - Path to the document file
|
|
17
|
+
* @param options.documentContent - Document content as Buffer or string
|
|
18
|
+
* @param options.documentUrl - URL to fetch the document from
|
|
19
|
+
* @param options.schema - Optional Zod schema for structured data extraction
|
|
20
|
+
* @param options.systemPrompt - Optional prompt for guiding extraction
|
|
21
|
+
* @param options.config - Optional document processor configuration
|
|
22
|
+
*
|
|
23
|
+
* @returns Promise resolving to extracted data/text and metadata
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```typescript
|
|
27
|
+
* import { extractFromDocument } from '@minded-ai/mindedjs';
|
|
28
|
+
* import { z } from 'zod';
|
|
29
|
+
*
|
|
30
|
+
* // Extract structured data with schema
|
|
31
|
+
* const result1 = await extractFromDocument({
|
|
32
|
+
* llm: agent.llm,
|
|
33
|
+
* documentPath: './invoice.pdf',
|
|
34
|
+
* schema: z.object({
|
|
35
|
+
* invoiceNumber: z.string(),
|
|
36
|
+
* amount: z.number(),
|
|
37
|
+
* })
|
|
38
|
+
* });
|
|
39
|
+
*
|
|
40
|
+
* // Extract unstructured data with prompt
|
|
41
|
+
* const result2 = await extractFromDocument({
|
|
42
|
+
* llm: agent.llm,
|
|
43
|
+
* documentPath: './contract.pdf',
|
|
44
|
+
* systemPrompt: 'Extract all payment terms and conditions'
|
|
45
|
+
* });
|
|
46
|
+
*
|
|
47
|
+
* // Extract raw text without LLM
|
|
48
|
+
* const result3 = await extractFromDocument({
|
|
49
|
+
* documentPath: './document.pdf'
|
|
50
|
+
* });
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
async function extractFromDocument(options) {
|
|
54
|
+
// Create a document processor
|
|
55
|
+
const processor = new documentProcessor_1.DocumentProcessor(options.config, options.llm);
|
|
56
|
+
// Extract from document using the processor
|
|
57
|
+
return processor.extractFromDocument({
|
|
58
|
+
documentPath: options.documentPath,
|
|
59
|
+
documentContent: options.documentContent,
|
|
60
|
+
documentUrl: options.documentUrl,
|
|
61
|
+
schema: options.schema,
|
|
62
|
+
systemPrompt: options.systemPrompt,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=documentExtraction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"documentExtraction.js","sourceRoot":"","sources":["../../src/internalTools/documentExtraction.ts"],"names":[],"mappings":";;AAoDA,kDA4BC;AA/ED,kEAAwF;AAGxF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACI,KAAK,UAAU,mBAAmB,CAAa,OAQrD;IASC,8BAA8B;IAC9B,MAAM,SAAS,GAAG,IAAI,qCAAiB,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;IAErE,4CAA4C;IAC5C,OAAO,SAAS,CAAC,mBAAmB,CAAC;QACnC,YAAY,EAAE,OAAO,CAAC,YAAY;QAClC,eAAe,EAAE,OAAO,CAAC,eAAe;QACxC,WAAW,EAAE,OAAO,CAAC,WAAW;QAChC,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,YAAY,EAAE,OAAO,CAAC,YAAY;KACnC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { DocumentExtractionOptions, DocumentProcessingResult } from '../documentExtraction/types';
|
|
2
|
+
/**
|
|
3
|
+
* Managed document parser that sends requests to the backend for processing
|
|
4
|
+
* This replaces the local document extraction implementation
|
|
5
|
+
*/
|
|
6
|
+
export declare function parseDocumentManaged<T = string>(options: DocumentExtractionOptions & {
|
|
7
|
+
sessionId: string;
|
|
8
|
+
extractRaw?: boolean;
|
|
9
|
+
}): Promise<DocumentProcessingResult<T>>;
|
|
10
|
+
//# sourceMappingURL=managedDocumentParser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"managedDocumentParser.d.ts","sourceRoot":"","sources":["../../../src/internalTools/managedDocumentParser/managedDocumentParser.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,yBAAyB,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AAGlG;;;GAGG;AACH,wBAAsB,oBAAoB,CAAC,CAAC,GAAG,MAAM,EACnD,OAAO,EAAE,yBAAyB,GAAG;IACnC,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,GACA,OAAO,CAAC,wBAAwB,CAAC,CAAC,CAAC,CAAC,CA8EtC"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseDocumentManaged = parseDocumentManaged;
|
|
4
|
+
const mindedConnection_1 = require("../../platform/mindedConnection");
|
|
5
|
+
const mindedConnectionTypes_1 = require("../../platform/mindedConnectionTypes");
|
|
6
|
+
const logger_1 = require("../../utils/logger");
|
|
7
|
+
/**
|
|
8
|
+
* Managed document parser that sends requests to the backend for processing
|
|
9
|
+
* This replaces the local document extraction implementation
|
|
10
|
+
*/
|
|
11
|
+
async function parseDocumentManaged(options) {
|
|
12
|
+
try {
|
|
13
|
+
// Prepare the request
|
|
14
|
+
const request = {
|
|
15
|
+
type: mindedConnectionTypes_1.mindedConnectionSocketMessageType.PARSE_DOCUMENT,
|
|
16
|
+
sessionId: options.sessionId,
|
|
17
|
+
documentPath: options.documentPath,
|
|
18
|
+
documentUrl: options.documentUrl,
|
|
19
|
+
extractRaw: options.extractRaw,
|
|
20
|
+
systemPrompt: options.systemPrompt,
|
|
21
|
+
};
|
|
22
|
+
// Handle document content - convert to base64 if needed
|
|
23
|
+
if (options.documentContent) {
|
|
24
|
+
if (Buffer.isBuffer(options.documentContent)) {
|
|
25
|
+
request.documentContent = options.documentContent.toString('base64');
|
|
26
|
+
request.config = {
|
|
27
|
+
...request.config,
|
|
28
|
+
useBase64: true,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
request.documentContent = options.documentContent;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
// Handle schema - needs to be serialized
|
|
36
|
+
if (options.schema) {
|
|
37
|
+
// Zod schemas can't be directly serialized, so we'll pass the schema shape
|
|
38
|
+
// The backend will need to reconstruct it
|
|
39
|
+
request.schema = options.schema;
|
|
40
|
+
}
|
|
41
|
+
// Add any additional config
|
|
42
|
+
if (options.llmConfig) {
|
|
43
|
+
request.config = {
|
|
44
|
+
...request.config,
|
|
45
|
+
...options.llmConfig,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
logger_1.logger.info({
|
|
49
|
+
msg: 'Sending document parse request to backend',
|
|
50
|
+
sessionId: options.sessionId,
|
|
51
|
+
hasPath: !!request.documentPath,
|
|
52
|
+
hasContent: !!request.documentContent,
|
|
53
|
+
hasUrl: !!request.documentUrl,
|
|
54
|
+
extractRaw: request.extractRaw,
|
|
55
|
+
hasSchema: !!request.schema,
|
|
56
|
+
hasPrompt: !!request.systemPrompt,
|
|
57
|
+
});
|
|
58
|
+
// Send request to backend and wait for response
|
|
59
|
+
const response = await mindedConnection_1.mindedConnection.awaitEmit(mindedConnectionTypes_1.mindedConnectionSocketMessageType.PARSE_DOCUMENT, request, 30000);
|
|
60
|
+
if (response.error) {
|
|
61
|
+
throw new Error(response.error);
|
|
62
|
+
}
|
|
63
|
+
if (!response.data || !response.metadata) {
|
|
64
|
+
throw new Error('Invalid response from document parser');
|
|
65
|
+
}
|
|
66
|
+
return {
|
|
67
|
+
data: response.data,
|
|
68
|
+
metadata: response.metadata,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
logger_1.logger.error({
|
|
73
|
+
msg: 'Failed to parse document via managed service',
|
|
74
|
+
error: error instanceof Error ? error.message : String(error),
|
|
75
|
+
sessionId: options.sessionId,
|
|
76
|
+
});
|
|
77
|
+
throw error;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=managedDocumentParser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"managedDocumentParser.js","sourceRoot":"","sources":["../../../src/internalTools/managedDocumentParser/managedDocumentParser.ts"],"names":[],"mappings":";;AASA,oDAmFC;AA5FD,sEAAmE;AACnE,gFAAsI;AAEtI,+CAA4C;AAE5C;;;GAGG;AACI,KAAK,UAAU,oBAAoB,CACxC,OAGC;IAED,IAAI,CAAC;QACH,sBAAsB;QACtB,MAAM,OAAO,GAAyB;YACpC,IAAI,EAAE,yDAAiC,CAAC,cAAc;YACtD,SAAS,EAAE,OAAO,C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C,MAAM;YAC3B,SAAS,EAAE,CAAC,CAAC,OAAO,CAAC,YAAY;SAClC,CAAC,CAAC;QAEH,gDAAgD;QAChD,MAAM,QAAQ,GAAG,MAAM,mCAAgB,CAAC,SAAS,CAC/C,yDAAiC,CAAC,cAAc,EAChD,OAAO,EACP,KAAK,CACN,CAAC;QAEF,IAAI,QAAQ,CAAC,KAAK,EAAE,CAAC;YACnB,MAAM,IAAI,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QAClC,CAAC;QAED,IAAI,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC;YACzC,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;QAC3D,CAAC;QAED,OAAO;YACL,IAAI,EAAE,QAAQ,CAAC,IAAS;YACxB,QAAQ,EAAE,QAAQ,CAAC,QAAQ;SAC5B,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,eAAM,CAAC,KAAK,CAAC;YACX,GAAG,EAAE,8CAA8C;YACnD,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;YAC7D,SAAS,EAAE,OAAO,CAAC,SAAS;SAC7B,CAAC,CAAC;QACH,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { TimerResetResponse, RetellGetCallResponse } from '../platform/mindedConnectionTypes';
|
|
2
|
+
export declare function retellCall({ sessionId, callName, callAgentId, vars, }: {
|
|
3
|
+
sessionId: string;
|
|
4
|
+
callName: string;
|
|
5
|
+
callAgentId: string;
|
|
6
|
+
vars?: Record<string, any>;
|
|
7
|
+
}): Promise<TimerResetResponse>;
|
|
8
|
+
export declare function retellGetCall({ sessionId, callId }: {
|
|
9
|
+
sessionId: string;
|
|
10
|
+
callId: string;
|
|
11
|
+
}): Promise<RetellGetCallResponse>;
|
|
12
|
+
//# sourceMappingURL=retell.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retell.d.ts","sourceRoot":"","sources":["../../src/internalTools/retell.ts"],"names":[],"mappings":"AACA,OAAO,EAAqC,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAEjI,wBAAsB,UAAU,CAAC,EAC/B,SAAS,EACT,QAAQ,EACR,WAAW,EACX,IAAS,GACV,EAAE;IACD,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC5B,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAO9B;AAED,wBAAsB,aAAa,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAKhI"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.retellCall = retellCall;
|
|
27
|
+
exports.retellGetCall = retellGetCall;
|
|
28
|
+
const mindedConnection = __importStar(require("../platform/mindedConnection"));
|
|
29
|
+
const mindedConnectionTypes_1 = require("../platform/mindedConnectionTypes");
|
|
30
|
+
async function retellCall({ sessionId, callName, callAgentId, vars = {}, }) {
|
|
31
|
+
return await mindedConnection.awaitEmit(mindedConnectionTypes_1.mindedConnectionSocketMessageType.RETELL_CALL, {
|
|
32
|
+
sessionId,
|
|
33
|
+
callName,
|
|
34
|
+
callAgentId,
|
|
35
|
+
vars,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
async function retellGetCall({ sessionId, callId }) {
|
|
39
|
+
return await mindedConnection.awaitEmit(mindedConnectionTypes_1.mindedConnectionSocketMessageType.RETELL_GET_CALL, {
|
|
40
|
+
sessionId,
|
|
41
|
+
callId,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=retell.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retell.js","sourceRoot":"","sources":["../../src/internalTools/retell.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAGA,gCAiBC;AAED,sCAKC;AA3BD,+EAAiE;AACjE,6EAAiI;AAE1H,KAAK,UAAU,UAAU,CAAC,EAC/B,SAAS,EACT,QAAQ,EACR,WAAW,EACX,IAAI,GAAG,EAAE,GAMV;IACC,OAAO,MAAM,gBAAgB,CAAC,SAAS,CAAC,yDAAiC,CAAC,WAAW,EAAE;QACrF,SAAS;QACT,QAAQ;QACR,WAAW;QACX,IAAI;KACL,CAAC,CAAC;AACL,CAAC;AAEM,KAAK,UAAU,aAAa,CAAC,EAAE,SAAS,EAAE,MAAM,EAAyC;IAC9F,OAAO,MAAM,gBAAgB,CAAC,SAAS,CAAC,yDAAiC,CAAC,eAAe,EAAE;QACzF,SAAS;QACT,MAAM;KACP,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Send a placeholder message to the dashboard voice session.
|
|
3
|
+
* This is typically used for voice sessions to provide immediate feedback to users.
|
|
4
|
+
*
|
|
5
|
+
* @param params - The parameters for sending the placeholder message
|
|
6
|
+
* @param params.sessionId - The session ID of the voice session
|
|
7
|
+
* @param params.message - The placeholder message to send
|
|
8
|
+
* @throws {Error} When the Minded connection is not established
|
|
9
|
+
*/
|
|
10
|
+
export declare function sendPlaceholderMessage(params: {
|
|
11
|
+
sessionId: string;
|
|
12
|
+
message: string;
|
|
13
|
+
}): Promise<void>;
|
|
14
|
+
//# sourceMappingURL=sendPlaceholderMessage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sendPlaceholderMessage.d.ts","sourceRoot":"","sources":["../../src/internalTools/sendPlaceholderMessage.ts"],"names":[],"mappings":"AAGA;;;;;;;;GAQG;AACH,wBAAsB,sBAAsB,CAAC,MAAM,EAAE;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAc1G"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.sendPlaceholderMessage = sendPlaceholderMessage;
|
|
27
|
+
const mindedConnection = __importStar(require("../platform/mindedConnection"));
|
|
28
|
+
const mindedConnectionTypes_1 = require("../platform/mindedConnectionTypes");
|
|
29
|
+
/**
|
|
30
|
+
* Send a placeholder message to the dashboard voice session.
|
|
31
|
+
* This is typically used for voice sessions to provide immediate feedback to users.
|
|
32
|
+
*
|
|
33
|
+
* @param params - The parameters for sending the placeholder message
|
|
34
|
+
* @param params.sessionId - The session ID of the voice session
|
|
35
|
+
* @param params.message - The placeholder message to send
|
|
36
|
+
* @throws {Error} When the Minded connection is not established
|
|
37
|
+
*/
|
|
38
|
+
async function sendPlaceholderMessage(params) {
|
|
39
|
+
const { sessionId, message } = params;
|
|
40
|
+
if (!mindedConnection.isConnected()) {
|
|
41
|
+
throw new Error('Minded connection is not established when trying to send placeholder message');
|
|
42
|
+
}
|
|
43
|
+
const connection = mindedConnection;
|
|
44
|
+
connection.emit(mindedConnectionTypes_1.mindedConnectionSocketMessageType.VOICE_PLACEHOLDER_MESSAGES, {
|
|
45
|
+
sessionId,
|
|
46
|
+
message,
|
|
47
|
+
timestamp: Date.now(),
|
|
48
|
+
type: mindedConnectionTypes_1.mindedConnectionSocketMessageType.VOICE_PLACEHOLDER_MESSAGES,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=sendPlaceholderMessage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sendPlaceholderMessage.js","sourceRoot":"","sources":["../../src/internalTools/sendPlaceholderMessage.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAYA,wDAcC;AA1BD,+EAAiE;AACjE,6EAAsF;AAEtF;;;;;;;;GAQG;AACI,KAAK,UAAU,sBAAsB,CAAC,MAA8C;IACzF,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC;IAEtC,IAAI,CAAC,gBAAgB,CAAC,WAAW,EAAE,EAAE,CAAC;QACpC,MAAM,IAAI,KAAK,CAAC,8EAA8E,CAAC,CAAC;IAClG,CAAC;IAED,MAAM,UAAU,GAAG,gBAAgB,CAAC;IACpC,UAAU,CAAC,IAAI,CAAC,yDAAiC,CAAC,0BAA0B,EAAE;QAC5E,SAAS;QACT,OAAO;QACP,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;QACrB,IAAI,EAAE,yDAAiC,CAAC,0BAA0B;KACnE,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { MindedConnection } from '../platform/mindedConnection';
|
|
2
|
+
import { HttpRequestConfig, HttpResponse, PIIGatewayInstance } from './types';
|
|
3
|
+
export declare class PIIGateway implements PIIGatewayInstance {
|
|
4
|
+
private mindedConnection;
|
|
5
|
+
private sessionId;
|
|
6
|
+
constructor(mindedConnection: MindedConnection, sessionId: string);
|
|
7
|
+
private makeRequest;
|
|
8
|
+
get<T = any>(url: string, config?: HttpRequestConfig): Promise<HttpResponse<T>>;
|
|
9
|
+
post<T = any>(url: string, data?: any, config?: HttpRequestConfig): Promise<HttpResponse<T>>;
|
|
10
|
+
put<T = any>(url: string, data?: any, config?: HttpRequestConfig): Promise<HttpResponse<T>>;
|
|
11
|
+
delete<T = any>(url: string, config?: HttpRequestConfig): Promise<HttpResponse<T>>;
|
|
12
|
+
patch<T = any>(url: string, data?: any, config?: HttpRequestConfig): Promise<HttpResponse<T>>;
|
|
13
|
+
head<T = any>(url: string, config?: HttpRequestConfig): Promise<HttpResponse<T>>;
|
|
14
|
+
options<T = any>(url: string, config?: HttpRequestConfig): Promise<HttpResponse<T>>;
|
|
15
|
+
request<T = any>(config: HttpRequestConfig): Promise<HttpResponse<T>>;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=gateway.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gateway.d.ts","sourceRoot":"","sources":["../../src/pii-gateway/gateway.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAEhE,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAE9E,qBAAa,UAAW,YAAW,kBAAkB;IACnD,OAAO,CAAC,gBAAgB,CAAmB;IAC3C,OAAO,CAAC,SAAS,CAAS;gBAEd,gBAAgB,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM;YAKnD,WAAW;IAmDnB,GAAG,CAAC,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IAI/E,IAAI,CAAC,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IAI5F,GAAG,CAAC,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IAI3F,MAAM,CAAC,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IAIlF,KAAK,CAAC,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IAI7F,IAAI,CAAC,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IAIhF,OAAO,CAAC,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IAInF,OAAO,CAAC,CAAC,GAAG,GAAG,EAAE,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;CAI5E"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PIIGateway = void 0;
|
|
4
|
+
const uuid_1 = require("uuid");
|
|
5
|
+
const mindedConnectionTypes_1 = require("../platform/mindedConnectionTypes");
|
|
6
|
+
class PIIGateway {
|
|
7
|
+
constructor(mindedConnection, sessionId) {
|
|
8
|
+
this.mindedConnection = mindedConnection;
|
|
9
|
+
this.sessionId = sessionId;
|
|
10
|
+
}
|
|
11
|
+
async makeRequest(method, url, data, config) {
|
|
12
|
+
var _a;
|
|
13
|
+
if (!((_a = this.mindedConnection) === null || _a === void 0 ? void 0 : _a.isConnected)) {
|
|
14
|
+
throw new Error('Minded connection is not established. PII-secured HTTP requests require a connection to the Minded platform.');
|
|
15
|
+
}
|
|
16
|
+
try {
|
|
17
|
+
const requestId = (0, uuid_1.v4)();
|
|
18
|
+
const requestPayload = {
|
|
19
|
+
type: mindedConnectionTypes_1.MindedConnectionSocketMessageType.PII_HTTP_REQUEST,
|
|
20
|
+
requestId,
|
|
21
|
+
method,
|
|
22
|
+
url,
|
|
23
|
+
headers: config === null || config === void 0 ? void 0 : config.headers,
|
|
24
|
+
params: config === null || config === void 0 ? void 0 : config.params,
|
|
25
|
+
data,
|
|
26
|
+
sessionId: this.sessionId,
|
|
27
|
+
};
|
|
28
|
+
const response = await this.mindedConnection.awaitEmit(mindedConnectionTypes_1.MindedConnectionSocketMessageType.PII_HTTP_REQUEST, requestPayload, 30000);
|
|
29
|
+
if (response.error) {
|
|
30
|
+
throw new Error(`HTTP request failed: ${response.error}`);
|
|
31
|
+
}
|
|
32
|
+
// Verify that the response requestId matches our request
|
|
33
|
+
if (response.requestId && response.requestId !== requestId) {
|
|
34
|
+
console.warn(`Response requestId (${response.requestId}) does not match request requestId (${requestId})`);
|
|
35
|
+
}
|
|
36
|
+
// Return generic HttpResponse format
|
|
37
|
+
return {
|
|
38
|
+
data: response.data,
|
|
39
|
+
status: response.status || 200,
|
|
40
|
+
statusText: response.statusText || 'OK',
|
|
41
|
+
headers: response.headers || {},
|
|
42
|
+
config: config || {},
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
throw new Error(`Secure HTTP request failed: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
async get(url, config) {
|
|
50
|
+
return this.makeRequest('GET', url, undefined, config);
|
|
51
|
+
}
|
|
52
|
+
async post(url, data, config) {
|
|
53
|
+
return this.makeRequest('POST', url, data, config);
|
|
54
|
+
}
|
|
55
|
+
async put(url, data, config) {
|
|
56
|
+
return this.makeRequest('PUT', url, data, config);
|
|
57
|
+
}
|
|
58
|
+
async delete(url, config) {
|
|
59
|
+
return this.makeRequest('DELETE', url, undefined, config);
|
|
60
|
+
}
|
|
61
|
+
async patch(url, data, config) {
|
|
62
|
+
return this.makeRequest('PATCH', url, data, config);
|
|
63
|
+
}
|
|
64
|
+
async head(url, config) {
|
|
65
|
+
return this.makeRequest('HEAD', url, undefined, config);
|
|
66
|
+
}
|
|
67
|
+
async options(url, config) {
|
|
68
|
+
return this.makeRequest('OPTIONS', url, undefined, config);
|
|
69
|
+
}
|
|
70
|
+
async request(config) {
|
|
71
|
+
var _a;
|
|
72
|
+
const method = (((_a = config.method) === null || _a === void 0 ? void 0 : _a.toUpperCase()) || 'GET');
|
|
73
|
+
return this.makeRequest(method, config.url || '', config.data, config);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
exports.PIIGateway = PIIGateway;
|
|
77
|
+
//# sourceMappingURL=gateway.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gateway.js","sourceRoot":"","sources":["../../src/pii-gateway/gateway.ts"],"names":[],"mappings":";;;AAAA,+BAAoC;AAEpC,6EAA2H;AAG3H,MAAa,UAAU;IAIrB,YAAY,gBAAkC,EAAE,SAAiB;QAC/D,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;QACzC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;IAEO,KAAK,CAAC,WAAW,CACvB,MAAwE,EACxE,GAAW,EACX,IAAU,EACV,MAA0B;;QAE1B,IAAI,CAAC,CAAA,MAAA,IAAI,CAAC,gBAAgB,0CAAE,WAAW,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,KAAK,CAAC,OAAO,CAAU,MAAyB;;QAC9C,MAAM,MAAM,GAAG,CAAC,CAAA,MAAA,MAAM,CAAC,MAAM,0CAAE,WAAW,EAAE,KAAI,KAAK,CAAQ,CAAC;QAC9D,OAAO,IAAI,CAAC,WAAW,CAAI,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,EAAE,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAC5E,CAAC;CACF;AA5FD,gCA4FC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export type { HttpRequestConfig, HttpResponse, PIIGatewayInstance } from './types';
|
|
2
|
+
export { PIIGateway } from './gateway';
|
|
3
|
+
export { piiGateway, getPIIGateway, createPIIGateway, _setGlobalPIIGateway, _clearGlobalPIIGateway } from './proxy';
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/pii-gateway/index.ts"],"names":[],"mappings":"AACA,YAAY,EAAE,iBAAiB,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAGnF,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAGvC,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports._clearGlobalPIIGateway = exports._setGlobalPIIGateway = exports.createPIIGateway = exports.getPIIGateway = exports.piiGateway = exports.PIIGateway = void 0;
|
|
4
|
+
// Export core gateway class
|
|
5
|
+
var gateway_1 = require("./gateway");
|
|
6
|
+
Object.defineProperty(exports, "PIIGateway", { enumerable: true, get: function () { return gateway_1.PIIGateway; } });
|
|
7
|
+
// Export proxy and management functions
|
|
8
|
+
var proxy_1 = require("./proxy");
|
|
9
|
+
Object.defineProperty(exports, "piiGateway", { enumerable: true, get: function () { return proxy_1.piiGateway; } });
|
|
10
|
+
Object.defineProperty(exports, "getPIIGateway", { enumerable: true, get: function () { return proxy_1.getPIIGateway; } });
|
|
11
|
+
Object.defineProperty(exports, "createPIIGateway", { enumerable: true, get: function () { return proxy_1.createPIIGateway; } });
|
|
12
|
+
Object.defineProperty(exports, "_setGlobalPIIGateway", { enumerable: true, get: function () { return proxy_1._setGlobalPIIGateway; } });
|
|
13
|
+
Object.defineProperty(exports, "_clearGlobalPIIGateway", { enumerable: true, get: function () { return proxy_1._clearGlobalPIIGateway; } });
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/pii-gateway/index.ts"],"names":[],"mappings":";;;AAGA,4BAA4B;AAC5B,qCAAuC;AAA9B,qGAAA,UAAU,OAAA;AAEnB,wCAAwC;AACxC,iCAAoH;AAA3G,mGAAA,UAAU,OAAA;AAAE,sGAAA,aAAa,OAAA;AAAE,yGAAA,gBAAgB,OAAA;AAAE,6GAAA,oBAAoB,OAAA;AAAE,+GAAA,sBAAsB,OAAA"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { MindedConnection } from '../platform/mindedConnection';
|
|
2
|
+
import { PIIGatewayInstance } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Global PII Gateway that is automatically initialized when a trigger with sessionId is received.
|
|
5
|
+
* This provides seamless access to PII masking capabilities within workflows and custom tools.
|
|
6
|
+
*
|
|
7
|
+
* The gateway acts as a proxy that automatically uses the current session's PII context.
|
|
8
|
+
* All standard HTTP methods (get, post, put, delete, patch, head, options, request) are available.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* import { piiGateway } from '@minded-ai/mindedjs';
|
|
13
|
+
*
|
|
14
|
+
* // Within a custom tool or workflow (after trigger is received)
|
|
15
|
+
* async function fetchUserData() {
|
|
16
|
+
* const response = await piiGateway.get('/api/user/profile');
|
|
17
|
+
* return response.data;
|
|
18
|
+
* }
|
|
19
|
+
*
|
|
20
|
+
* // POST request
|
|
21
|
+
* const createResponse = await piiGateway.post('/api/users', {
|
|
22
|
+
* name: 'John Doe',
|
|
23
|
+
* email: 'john@example.com'
|
|
24
|
+
* });
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare const piiGateway: PIIGatewayInstance;
|
|
28
|
+
/**
|
|
29
|
+
* Get the global PII Gateway instance that is automatically initialized when a trigger with sessionId is received.
|
|
30
|
+
* This provides seamless access to PII masking capabilities within workflows and custom tools.
|
|
31
|
+
*
|
|
32
|
+
* @returns The PII Gateway instance for the current session
|
|
33
|
+
* @throws {Error} When no active session or PII gateway is not initialized
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```typescript
|
|
37
|
+
* import { getPIIGateway } from '@minded-ai/mindedjs';
|
|
38
|
+
*
|
|
39
|
+
* // Within a custom tool or workflow (after trigger is received)
|
|
40
|
+
* async function fetchUserData() {
|
|
41
|
+
* const piiGateway = getPIIGateway();
|
|
42
|
+
* const response = await piiGateway.get('/api/user/profile');
|
|
43
|
+
* return response.data;
|
|
44
|
+
* }
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export declare function getPIIGateway(): PIIGatewayInstance;
|
|
48
|
+
/**
|
|
49
|
+
* Create a PII Gateway instance with a specific Minded connection and session ID.
|
|
50
|
+
* This is used internally by the Agent and for advanced use cases.
|
|
51
|
+
*
|
|
52
|
+
* @param mindedConnection - The Minded connection to use for the requests
|
|
53
|
+
* @param sessionId - Session ID for PII context (required for proper masking)
|
|
54
|
+
* @returns A PII Gateway instance
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```typescript
|
|
58
|
+
* import { createPIIGateway } from '@minded-ai/mindedjs';
|
|
59
|
+
*
|
|
60
|
+
* const piiGateway = createPIIGateway(mindedConnection, 'session-123');
|
|
61
|
+
* const response = await piiGateway.get('/api/data');
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
export declare function createPIIGateway(mindedConnection: MindedConnection, sessionId: string): PIIGatewayInstance;
|
|
65
|
+
/**
|
|
66
|
+
* Internal function used by the Agent to set the global PII gateway when a trigger is received.
|
|
67
|
+
* This ensures the PII masking is automatically available to SDK users.
|
|
68
|
+
*
|
|
69
|
+
* @internal
|
|
70
|
+
* @param mindedConnection - The Minded connection to use
|
|
71
|
+
* @param sessionId - The session ID from the trigger
|
|
72
|
+
*/
|
|
73
|
+
export declare function _setGlobalPIIGateway(mindedConnection: MindedConnection, sessionId: string): void;
|
|
74
|
+
/**
|
|
75
|
+
* Internal function to clear the global PII gateway.
|
|
76
|
+
*
|
|
77
|
+
* @internal
|
|
78
|
+
*/
|
|
79
|
+
export declare function _clearGlobalPIIGateway(): void;
|
|
80
|
+
//# sourceMappingURL=proxy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proxy.d.ts","sourceRoot":"","sources":["../../src/pii-gateway/proxy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAM7C;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,UAAU,EAAE,kBAOvB,CAAC;AAEH;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,aAAa,IAAI,kBAAkB,CAKlD;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,gBAAgB,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,GAAG,kBAAkB,CAE1G;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CAEhG;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,IAAI,IAAI,CAE7C"}
|