@minded-ai/mindedjs 1.0.62-patch5 → 1.0.62
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/cli/index.js +1 -87
- package/dist/cli/index.js.map +1 -1
- package/package.json +2 -4
- package/src/cli/index.ts +1 -96
- package/dist/cli/lambdaHandlerTemplate.d.ts +0 -3
- package/dist/cli/lambdaHandlerTemplate.d.ts.map +0 -1
- package/dist/cli/lambdaHandlerTemplate.js +0 -44
- package/dist/cli/lambdaHandlerTemplate.js.map +0 -1
- package/dist/cli/lambdaHandlerTemplate.ts +0 -46
- package/src/cli/lambdaHandlerTemplate.ts +0 -46
package/dist/cli/index.js
CHANGED
|
@@ -37,7 +37,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
37
37
|
const fs = __importStar(require("fs"));
|
|
38
38
|
const path = __importStar(require("path"));
|
|
39
39
|
const logger_1 = require("../utils/logger");
|
|
40
|
-
const child_process_1 = require("child_process");
|
|
41
40
|
const ENV_FILE = '.env';
|
|
42
41
|
function getEnvFilePath() {
|
|
43
42
|
return path.join(process.cwd(), ENV_FILE);
|
|
@@ -69,88 +68,6 @@ function setToken(token) {
|
|
|
69
68
|
}
|
|
70
69
|
}
|
|
71
70
|
}
|
|
72
|
-
function generateLambdaHandler() {
|
|
73
|
-
const mindedConfigPath = path.join(process.cwd(), 'minded.json');
|
|
74
|
-
// Check if minded.json exists
|
|
75
|
-
if (!fs.existsSync(mindedConfigPath)) {
|
|
76
|
-
logger_1.logger.error('minded.json not found in the current directory');
|
|
77
|
-
process.exit(1);
|
|
78
|
-
}
|
|
79
|
-
// Read and parse minded.json
|
|
80
|
-
let mindedConfig;
|
|
81
|
-
try {
|
|
82
|
-
const configContent = fs.readFileSync(mindedConfigPath, 'utf8');
|
|
83
|
-
mindedConfig = JSON.parse(configContent);
|
|
84
|
-
}
|
|
85
|
-
catch (error) {
|
|
86
|
-
logger_1.logger.error('Failed to read or parse minded.json:', error);
|
|
87
|
-
process.exit(1);
|
|
88
|
-
}
|
|
89
|
-
// Get the agent path
|
|
90
|
-
const agentPath = mindedConfig.agent;
|
|
91
|
-
if (!agentPath) {
|
|
92
|
-
logger_1.logger.error('No agent path found in minded.json');
|
|
93
|
-
process.exit(1);
|
|
94
|
-
}
|
|
95
|
-
// Remove .ts or .js extension if present and convert to relative path
|
|
96
|
-
const modulePath = agentPath.replace(/\.(ts|js)$/, '');
|
|
97
|
-
// Get the path to the template file
|
|
98
|
-
// Try multiple locations to support both development and npm package scenarios
|
|
99
|
-
const templatePaths = [
|
|
100
|
-
path.join(__dirname, 'lambdaHandlerTemplate.ts'), // For npm package
|
|
101
|
-
path.join(__dirname, '..', '..', 'src', 'cli', 'lambdaHandlerTemplate.ts'), // For development
|
|
102
|
-
];
|
|
103
|
-
let templateContent = null;
|
|
104
|
-
// Try each path until we find the template
|
|
105
|
-
for (const templatePath of templatePaths) {
|
|
106
|
-
try {
|
|
107
|
-
if (fs.existsSync(templatePath)) {
|
|
108
|
-
templateContent = fs.readFileSync(templatePath, 'utf8');
|
|
109
|
-
logger_1.logger.debug(`Found template at ${templatePath}`);
|
|
110
|
-
break;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
catch (error) {
|
|
114
|
-
// Continue to next path
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
if (!templateContent) {
|
|
118
|
-
logger_1.logger.error('Could not find Lambda handler template file');
|
|
119
|
-
process.exit(1);
|
|
120
|
-
}
|
|
121
|
-
try {
|
|
122
|
-
// Replace the placeholder with the actual module path
|
|
123
|
-
// Using a string literal here to make sure we match exactly what's in the template
|
|
124
|
-
templateContent = templateContent.replace(/const modulePath = '{MODULE_PATH}';/, `const modulePath = '${modulePath}';`);
|
|
125
|
-
// Write the Lambda handler to index.ts at the root
|
|
126
|
-
const outputPath = path.join(process.cwd(), 'index.ts');
|
|
127
|
-
fs.writeFileSync(outputPath, templateContent);
|
|
128
|
-
logger_1.logger.info(`Generated Lambda handler at ${outputPath}`);
|
|
129
|
-
// Also compile the TS file to JS and place it in dist/ directory
|
|
130
|
-
const distDir = path.join(process.cwd(), 'dist');
|
|
131
|
-
// Ensure dist directory exists
|
|
132
|
-
if (!fs.existsSync(distDir)) {
|
|
133
|
-
fs.mkdirSync(distDir, { recursive: true });
|
|
134
|
-
}
|
|
135
|
-
try {
|
|
136
|
-
// Compile just the index.ts file using tsc
|
|
137
|
-
logger_1.logger.info('Compiling index.ts to JavaScript...');
|
|
138
|
-
(0, child_process_1.execSync)(`npx tsc ${outputPath} --outDir ${distDir} --esModuleInterop --skipLibCheck`, {
|
|
139
|
-
cwd: process.cwd(),
|
|
140
|
-
stdio: 'pipe',
|
|
141
|
-
});
|
|
142
|
-
logger_1.logger.info(`Successfully compiled index.js to ${path.join(distDir, 'index.js')}`);
|
|
143
|
-
}
|
|
144
|
-
catch (compileError) {
|
|
145
|
-
logger_1.logger.error('Failed to compile index.ts:', compileError);
|
|
146
|
-
logger_1.logger.info('You will need to include index.ts in your TypeScript compilation');
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
catch (error) {
|
|
150
|
-
logger_1.logger.error('Failed to generate Lambda handler:', error);
|
|
151
|
-
process.exit(1);
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
71
|
function main() {
|
|
155
72
|
const args = process.argv.slice(2);
|
|
156
73
|
const command = args[0];
|
|
@@ -162,11 +79,8 @@ function main() {
|
|
|
162
79
|
}
|
|
163
80
|
setToken(token);
|
|
164
81
|
}
|
|
165
|
-
else if (command === 'generate-lambda-ts-handler') {
|
|
166
|
-
generateLambdaHandler();
|
|
167
|
-
}
|
|
168
82
|
else {
|
|
169
|
-
logger_1.logger.error('Unknown command. Available commands: token
|
|
83
|
+
logger_1.logger.error('Unknown command. Available commands: token');
|
|
170
84
|
process.exit(1);
|
|
171
85
|
}
|
|
172
86
|
}
|
package/dist/cli/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,uCAAyB;AACzB,2CAA6B;AAC7B,4CAAyC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,uCAAyB;AACzB,2CAA6B;AAC7B,4CAAyC;AAEzC,MAAM,QAAQ,GAAG,MAAM,CAAC;AAExB,SAAS,cAAc;IACrB,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,QAAQ,CAAC,CAAC;AAC5C,CAAC;AAED,SAAS,QAAQ,CAAC,KAAa;IAC7B,MAAM,OAAO,GAAG,cAAc,EAAE,CAAC;IACjC,MAAM,SAAS,GAAG,2BAA2B,KAAK,EAAE,CAAC;IAErD,4BAA4B;IAC5B,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;QAC5B,kCAAkC;QAClC,EAAE,CAAC,aAAa,CAAC,OAAO,EAAE,SAAS,GAAG,IAAI,CAAC,CAAC;QAC5C,eAAM,CAAC,IAAI,CAAC,WAAW,OAAO,kBAAkB,CAAC,CAAC;IACpD,CAAC;SAAM,CAAC;QACN,0BAA0B;QAC1B,MAAM,UAAU,GAAG,EAAE,CAAC,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAEpD,kDAAkD;QAClD,IAAI,UAAU,CAAC,QAAQ,CAAC,0BAA0B,CAAC,EAAE,CAAC;YACpD,yBAAyB;YACzB,MAAM,cAAc,GAAG,UAAU,CAAC,OAAO,CAAC,4BAA4B,EAAE,SAAS,CAAC,CAAC;YACnF,EAAE,CAAC,aAAa,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;YAC1C,eAAM,CAAC,IAAI,CAAC,sCAAsC,OAAO,EAAE,CAAC,CAAC;QAC/D,CAAC;aAAM,CAAC;YACN,gCAAgC;YAChC,MAAM,UAAU,GAAG,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,UAAU,GAAG,SAAS,GAAG,IAAI,CAAC,CAAC,CAAC,UAAU,GAAG,IAAI,GAAG,SAAS,GAAG,IAAI,CAAC;YACpH,EAAE,CAAC,aAAa,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;YACtC,eAAM,CAAC,IAAI,CAAC,oCAAoC,OAAO,EAAE,CAAC,CAAC;QAC7D,CAAC;IACH,CAAC;AACH,CAAC;AAED,SAAS,IAAI;IACX,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACnC,MAAM,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;IAExB,IAAI,OAAO,KAAK,OAAO,EAAE,CAAC;QACxB,MAAM,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QACtB,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,eAAM,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAC;YACvC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QACD,QAAQ,CAAC,KAAK,CAAC,CAAC;IAClB,CAAC;SAAM,CAAC;QACN,eAAM,CAAC,KAAK,CAAC,4CAA4C,CAAC,CAAC;QAC3D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC;AAED,IAAI,EAAE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@minded-ai/mindedjs",
|
|
3
|
-
"version": "1.0.62
|
|
3
|
+
"version": "1.0.62",
|
|
4
4
|
"description": "MindedJS is a TypeScript library for building agents.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -12,8 +12,7 @@
|
|
|
12
12
|
"src"
|
|
13
13
|
],
|
|
14
14
|
"scripts": {
|
|
15
|
-
"build": "tsc
|
|
16
|
-
"copy-templates": "cp -r src/cli/lambdaHandlerTemplate.ts dist/cli/",
|
|
15
|
+
"build": "tsc",
|
|
17
16
|
"watch": "tsc -w",
|
|
18
17
|
"test": "NODE_ENV=test mocha --parallel --jobs auto --retries 1 -r ts-node/register -r ./test/setup.ts \"test/**/*.test.ts\"",
|
|
19
18
|
"testFile": "NODE_ENV=test mocha -r ts-node/register -r ./test/setup.ts",
|
|
@@ -27,7 +26,6 @@
|
|
|
27
26
|
"license": "ISC",
|
|
28
27
|
"devDependencies": {
|
|
29
28
|
"@eslint/js": "^9.27.0",
|
|
30
|
-
"@types/aws-lambda": "^8.10.150",
|
|
31
29
|
"@types/chai": "^4.3.11",
|
|
32
30
|
"@types/mocha": "^10.0.6",
|
|
33
31
|
"@types/node": "^20.11.19",
|
package/src/cli/index.ts
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
import * as fs from 'fs';
|
|
4
4
|
import * as path from 'path';
|
|
5
5
|
import { logger } from '../utils/logger';
|
|
6
|
-
import { execSync } from 'child_process';
|
|
7
6
|
|
|
8
7
|
const ENV_FILE = '.env';
|
|
9
8
|
|
|
@@ -39,98 +38,6 @@ function setToken(token: string): void {
|
|
|
39
38
|
}
|
|
40
39
|
}
|
|
41
40
|
|
|
42
|
-
function generateLambdaHandler(): void {
|
|
43
|
-
const mindedConfigPath = path.join(process.cwd(), 'minded.json');
|
|
44
|
-
|
|
45
|
-
// Check if minded.json exists
|
|
46
|
-
if (!fs.existsSync(mindedConfigPath)) {
|
|
47
|
-
logger.error('minded.json not found in the current directory');
|
|
48
|
-
process.exit(1);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
// Read and parse minded.json
|
|
52
|
-
let mindedConfig;
|
|
53
|
-
try {
|
|
54
|
-
const configContent = fs.readFileSync(mindedConfigPath, 'utf8');
|
|
55
|
-
mindedConfig = JSON.parse(configContent);
|
|
56
|
-
} catch (error) {
|
|
57
|
-
logger.error('Failed to read or parse minded.json:', error);
|
|
58
|
-
process.exit(1);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// Get the agent path
|
|
62
|
-
const agentPath = mindedConfig.agent;
|
|
63
|
-
if (!agentPath) {
|
|
64
|
-
logger.error('No agent path found in minded.json');
|
|
65
|
-
process.exit(1);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// Remove .ts or .js extension if present and convert to relative path
|
|
69
|
-
const modulePath = agentPath.replace(/\.(ts|js)$/, '');
|
|
70
|
-
|
|
71
|
-
// Get the path to the template file
|
|
72
|
-
// Try multiple locations to support both development and npm package scenarios
|
|
73
|
-
const templatePaths = [
|
|
74
|
-
path.join(__dirname, 'lambdaHandlerTemplate.ts'), // For npm package
|
|
75
|
-
path.join(__dirname, '..', '..', 'src', 'cli', 'lambdaHandlerTemplate.ts'), // For development
|
|
76
|
-
];
|
|
77
|
-
|
|
78
|
-
let templateContent: string | null = null;
|
|
79
|
-
|
|
80
|
-
// Try each path until we find the template
|
|
81
|
-
for (const templatePath of templatePaths) {
|
|
82
|
-
try {
|
|
83
|
-
if (fs.existsSync(templatePath)) {
|
|
84
|
-
templateContent = fs.readFileSync(templatePath, 'utf8');
|
|
85
|
-
logger.debug(`Found template at ${templatePath}`);
|
|
86
|
-
break;
|
|
87
|
-
}
|
|
88
|
-
} catch (error) {
|
|
89
|
-
// Continue to next path
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
if (!templateContent) {
|
|
94
|
-
logger.error('Could not find Lambda handler template file');
|
|
95
|
-
process.exit(1);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
try {
|
|
99
|
-
// Replace the placeholder with the actual module path
|
|
100
|
-
// Using a string literal here to make sure we match exactly what's in the template
|
|
101
|
-
templateContent = templateContent.replace(/const modulePath = '{MODULE_PATH}';/, `const modulePath = '${modulePath}';`);
|
|
102
|
-
|
|
103
|
-
// Write the Lambda handler to index.ts at the root
|
|
104
|
-
const outputPath = path.join(process.cwd(), 'index.ts');
|
|
105
|
-
fs.writeFileSync(outputPath, templateContent);
|
|
106
|
-
logger.info(`Generated Lambda handler at ${outputPath}`);
|
|
107
|
-
|
|
108
|
-
// Also compile the TS file to JS and place it in dist/ directory
|
|
109
|
-
const distDir = path.join(process.cwd(), 'dist');
|
|
110
|
-
|
|
111
|
-
// Ensure dist directory exists
|
|
112
|
-
if (!fs.existsSync(distDir)) {
|
|
113
|
-
fs.mkdirSync(distDir, { recursive: true });
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
try {
|
|
117
|
-
// Compile just the index.ts file using tsc
|
|
118
|
-
logger.info('Compiling index.ts to JavaScript...');
|
|
119
|
-
execSync(`npx tsc ${outputPath} --outDir ${distDir} --esModuleInterop --skipLibCheck`, {
|
|
120
|
-
cwd: process.cwd(),
|
|
121
|
-
stdio: 'pipe',
|
|
122
|
-
});
|
|
123
|
-
logger.info(`Successfully compiled index.js to ${path.join(distDir, 'index.js')}`);
|
|
124
|
-
} catch (compileError) {
|
|
125
|
-
logger.error('Failed to compile index.ts:', compileError);
|
|
126
|
-
logger.info('You will need to include index.ts in your TypeScript compilation');
|
|
127
|
-
}
|
|
128
|
-
} catch (error) {
|
|
129
|
-
logger.error('Failed to generate Lambda handler:', error);
|
|
130
|
-
process.exit(1);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
41
|
function main() {
|
|
135
42
|
const args = process.argv.slice(2);
|
|
136
43
|
const command = args[0];
|
|
@@ -142,10 +49,8 @@ function main() {
|
|
|
142
49
|
process.exit(1);
|
|
143
50
|
}
|
|
144
51
|
setToken(token);
|
|
145
|
-
} else if (command === 'generate-lambda-ts-handler') {
|
|
146
|
-
generateLambdaHandler();
|
|
147
52
|
} else {
|
|
148
|
-
logger.error('Unknown command. Available commands: token
|
|
53
|
+
logger.error('Unknown command. Available commands: token');
|
|
149
54
|
process.exit(1);
|
|
150
55
|
}
|
|
151
56
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"lambdaHandlerTemplate.d.ts","sourceRoot":"","sources":["../../src/cli/lambdaHandlerTemplate.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAElF,eAAO,MAAM,OAAO,GAAU,OAAO,oBAAoB,EAAE,SAAS,OAAO,KAAG,OAAO,CAAC,qBAAqB,CAwC1G,CAAC"}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// This is the template for the Lambda handler
|
|
3
|
-
// The {MODULE_PATH} placeholder will be replaced with the actual path
|
|
4
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.handler = void 0;
|
|
6
|
-
const handler = async (event, context) => {
|
|
7
|
-
const modulePath = '{MODULE_PATH}'; // Agent path from minded.json
|
|
8
|
-
const resolvedPath = require.resolve(modulePath);
|
|
9
|
-
delete require.cache[resolvedPath];
|
|
10
|
-
const agent = require(modulePath).default;
|
|
11
|
-
const { agentFunctionName, agentFunctionBody } = event.body ? JSON.parse(event.body) : event;
|
|
12
|
-
if (!agent[agentFunctionName]) {
|
|
13
|
-
throw new Error('Unknown agentFunctionName: ' + agentFunctionName);
|
|
14
|
-
}
|
|
15
|
-
const response = await agent[agentFunctionName](agentFunctionBody);
|
|
16
|
-
// Safely stringify the response. If it fails (e.g., due to circular refs
|
|
17
|
-
// or non-serialisable class instances), fall back to null.
|
|
18
|
-
let responseBody = null;
|
|
19
|
-
try {
|
|
20
|
-
JSON.stringify(response);
|
|
21
|
-
responseBody = response;
|
|
22
|
-
}
|
|
23
|
-
catch (_) {
|
|
24
|
-
// ignored - responseBody stays null
|
|
25
|
-
}
|
|
26
|
-
if (agentFunctionName === 'startVoiceSession') {
|
|
27
|
-
const wait = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
28
|
-
while (context.getRemainingTimeInMillis() > 1000) {
|
|
29
|
-
console.log('Lambda remaining time in seconds: ', context.getRemainingTimeInMillis() / 1000);
|
|
30
|
-
await wait(1000); // sleep 1 s
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
return {
|
|
34
|
-
statusCode: 200,
|
|
35
|
-
headers: {
|
|
36
|
-
'Content-Type': 'application/json',
|
|
37
|
-
'Access-Control-Allow-Origin': '*',
|
|
38
|
-
'Access-Control-Allow-Credentials': true,
|
|
39
|
-
},
|
|
40
|
-
body: JSON.stringify(responseBody),
|
|
41
|
-
};
|
|
42
|
-
};
|
|
43
|
-
exports.handler = handler;
|
|
44
|
-
//# sourceMappingURL=lambdaHandlerTemplate.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"lambdaHandlerTemplate.js","sourceRoot":"","sources":["../../src/cli/lambdaHandlerTemplate.ts"],"names":[],"mappings":";AAAA,8CAA8C;AAC9C,sEAAsE;;;AAI/D,MAAM,OAAO,GAAG,KAAK,EAAE,KAA2B,EAAE,OAAgB,EAAkC,EAAE;IAC7G,MAAM,UAAU,GAAG,eAAe,CAAC,CAAC,8BAA8B;IAClE,MAAM,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IACjD,OAAO,OAAO,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;IACnC,MAAM,KAAK,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC;IAC1C,MAAM,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IAE7F,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,EAAE,CAAC;QAC9B,MAAM,IAAI,KAAK,CAAC,6BAA6B,GAAG,iBAAiB,CAAC,CAAC;IACrE,CAAC;IAED,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,iBAAiB,CAAC,CAAC,iBAAiB,CAAC,CAAC;IAEnE,yEAAyE;IACzE,2DAA2D;IAC3D,IAAI,YAAY,GAAG,IAAI,CAAC;IACxB,IAAI,CAAC;QACH,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;QACzB,YAAY,GAAG,QAAQ,CAAC;IAC1B,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,oCAAoC;IACtC,CAAC;IAED,IAAI,iBAAiB,KAAK,mBAAmB,EAAE,CAAC;QAC9C,MAAM,IAAI,GAAG,CAAC,EAAU,EAAE,EAAE,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;QACnE,OAAO,OAAO,CAAC,wBAAwB,EAAE,GAAG,IAAI,EAAE,CAAC;YACjD,OAAO,CAAC,GAAG,CAAC,oCAAoC,EAAE,OAAO,CAAC,wBAAwB,EAAE,GAAG,IAAI,CAAC,CAAC;YAC7F,MAAM,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,YAAY;QAChC,CAAC;IACH,CAAC;IAED,OAAO;QACL,UAAU,EAAE,GAAG;QACf,OAAO,EAAE;YACP,cAAc,EAAE,kBAAkB;YAClC,6BAA6B,EAAE,GAAG;YAClC,kCAAkC,EAAE,IAAI;SACzC;QACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC;KACnC,CAAC;AACJ,CAAC,CAAC;AAxCW,QAAA,OAAO,WAwClB"}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
// This is the template for the Lambda handler
|
|
2
|
-
// The {MODULE_PATH} placeholder will be replaced with the actual path
|
|
3
|
-
|
|
4
|
-
import { APIGatewayProxyEvent, APIGatewayProxyResult, Context } from 'aws-lambda';
|
|
5
|
-
|
|
6
|
-
export const handler = async (event: APIGatewayProxyEvent, context: Context): Promise<APIGatewayProxyResult> => {
|
|
7
|
-
const modulePath = '{MODULE_PATH}'; // Agent path from minded.json
|
|
8
|
-
const resolvedPath = require.resolve(modulePath);
|
|
9
|
-
delete require.cache[resolvedPath];
|
|
10
|
-
const agent = require(modulePath).default;
|
|
11
|
-
const { agentFunctionName, agentFunctionBody } = event.body ? JSON.parse(event.body) : event;
|
|
12
|
-
|
|
13
|
-
if (!agent[agentFunctionName]) {
|
|
14
|
-
throw new Error('Unknown agentFunctionName: ' + agentFunctionName);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const response = await agent[agentFunctionName](agentFunctionBody);
|
|
18
|
-
|
|
19
|
-
// Safely stringify the response. If it fails (e.g., due to circular refs
|
|
20
|
-
// or non-serialisable class instances), fall back to null.
|
|
21
|
-
let responseBody = null;
|
|
22
|
-
try {
|
|
23
|
-
JSON.stringify(response);
|
|
24
|
-
responseBody = response;
|
|
25
|
-
} catch (_) {
|
|
26
|
-
// ignored - responseBody stays null
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (agentFunctionName === 'startVoiceSession') {
|
|
30
|
-
const wait = (ms: number) => new Promise((r) => setTimeout(r, ms));
|
|
31
|
-
while (context.getRemainingTimeInMillis() > 1000) {
|
|
32
|
-
console.log('Lambda remaining time in seconds: ', context.getRemainingTimeInMillis() / 1000);
|
|
33
|
-
await wait(1000); // sleep 1 s
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
return {
|
|
38
|
-
statusCode: 200,
|
|
39
|
-
headers: {
|
|
40
|
-
'Content-Type': 'application/json',
|
|
41
|
-
'Access-Control-Allow-Origin': '*',
|
|
42
|
-
'Access-Control-Allow-Credentials': true,
|
|
43
|
-
},
|
|
44
|
-
body: JSON.stringify(responseBody),
|
|
45
|
-
};
|
|
46
|
-
};
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
// This is the template for the Lambda handler
|
|
2
|
-
// The {MODULE_PATH} placeholder will be replaced with the actual path
|
|
3
|
-
|
|
4
|
-
import { APIGatewayProxyEvent, APIGatewayProxyResult, Context } from 'aws-lambda';
|
|
5
|
-
|
|
6
|
-
export const handler = async (event: APIGatewayProxyEvent, context: Context): Promise<APIGatewayProxyResult> => {
|
|
7
|
-
const modulePath = '{MODULE_PATH}'; // Agent path from minded.json
|
|
8
|
-
const resolvedPath = require.resolve(modulePath);
|
|
9
|
-
delete require.cache[resolvedPath];
|
|
10
|
-
const agent = require(modulePath).default;
|
|
11
|
-
const { agentFunctionName, agentFunctionBody } = event.body ? JSON.parse(event.body) : event;
|
|
12
|
-
|
|
13
|
-
if (!agent[agentFunctionName]) {
|
|
14
|
-
throw new Error('Unknown agentFunctionName: ' + agentFunctionName);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const response = await agent[agentFunctionName](agentFunctionBody);
|
|
18
|
-
|
|
19
|
-
// Safely stringify the response. If it fails (e.g., due to circular refs
|
|
20
|
-
// or non-serialisable class instances), fall back to null.
|
|
21
|
-
let responseBody = null;
|
|
22
|
-
try {
|
|
23
|
-
JSON.stringify(response);
|
|
24
|
-
responseBody = response;
|
|
25
|
-
} catch (_) {
|
|
26
|
-
// ignored - responseBody stays null
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (agentFunctionName === 'startVoiceSession') {
|
|
30
|
-
const wait = (ms: number) => new Promise((r) => setTimeout(r, ms));
|
|
31
|
-
while (context.getRemainingTimeInMillis() > 1000) {
|
|
32
|
-
console.log('Lambda remaining time in seconds: ', context.getRemainingTimeInMillis() / 1000);
|
|
33
|
-
await wait(1000); // sleep 1 s
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
return {
|
|
38
|
-
statusCode: 200,
|
|
39
|
-
headers: {
|
|
40
|
-
'Content-Type': 'application/json',
|
|
41
|
-
'Access-Control-Allow-Origin': '*',
|
|
42
|
-
'Access-Control-Allow-Credentials': true,
|
|
43
|
-
},
|
|
44
|
-
body: JSON.stringify(responseBody),
|
|
45
|
-
};
|
|
46
|
-
};
|