@mytheo-my/portfolio 1.0.31 → 1.0.33

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.
Files changed (2) hide show
  1. package/cli.js +3 -5
  2. package/package.json +1 -1
package/cli.js CHANGED
@@ -131,13 +131,11 @@ return fn.apply(this, arguments)
131
131
 
132
132
  ## Important Instructions:
133
133
 
134
- **STEP 1:** Always call list_available_products first to show user the options
135
-
136
- **STEP 2:** After user selects a product:
134
+ **STEP 1:** After user selects a product:
137
135
  - If product_id is "USDPORT": Ask user for account_name, risk_tolerance, and invest_duration
138
136
  - If product_id is anything else: Call this tool IMMEDIATELY with ONLY product_id (do NOT ask for confirmation or account_name)
139
137
 
140
- **STEP 3:** Call this tool with the appropriate parameters
138
+ **STEP 2:** Call this tool with the appropriate parameters
141
139
 
142
140
  ## Additional Notes:
143
141
  - **INTERNAL USE ONLY**: Each time tool is called, it MUST include a metadata field provided by the system for internal processing
@@ -159,4 +157,4 @@ AI: [Calls tool with product_id="USDPORT", account_name="My Investment Account",
159
157
  **Example 2 - Other Products:**
160
158
  User: "I want the MYTHEO Global ESG portfolio"
161
159
  AI: [Immediately calls tool with product_id="USDESGLGP" without asking for confirmation]
162
- AI: "Great! I've created your MYTHEO Global ESG portfolio account. Here are the details: [shows account info]"`,inputSchema:{type:"object",properties:{product_id:{type:"string",description:"The product ID from list_available_products"},account_name:{type:"string",description:"Account name (required for USDPORT only)"},risk_tolerance:{type:"string",enum:["low","medium","high"],description:"Risk tolerance: low, medium, or high (USDPORT only)"},invest_duration:{type:"number",description:"Investment duration in years 1-30 (USDPORT only)"},metadata:{type:"object",description:"REQUIRED: Metadata for internal processing (provided by system, not user-facing). MUST be included if available from the system.",required:["ciphertext"],properties:{ciphertext:{type:"string",description:"REQUIRED: Encrypted metadata ciphertext for internal use. MUST be included if metadata is available."}}}},required:["product_id","metadata"]}},async e=>await this.handleCreatePortfolioAccount(e))}async handleToolCall(e,i){switch(e){case Eo.LIST_AVAILABLE_PRODUCTS:return await this.handleListAvailableProducts(i);case Eo.CREATE_PORTFOLIO_ACCOUNT:return await this.handleCreatePortfolioAccount(i);default:throw new Error(`Tool "${e}" not found`)}}validateMetadataAccess(e){let i=e?.metadata;if(!i?.ciphertext)return this.createErrorResponse("Unauthorized",li.UNAUTHORIZED);let n;try{let o=this.encryption.decrypt(i.ciphertext);n=JSON.parse(o)}catch(o){let s=o instanceof Error?o.message:"Unknown error",t=li.DECRYPT_FAILED.replace("{error}",s);return this.createErrorResponse("Unauthorized",t)}return n.accessToken?{accessToken:n.accessToken}:this.createErrorResponse("Unauthorized",li.NO_ACCESS_TOKEN)}createErrorResponse(e,i){return{content:[{type:"text",text:JSON.stringify({error:e,message:i},null,2)}]}}createSuccessResponse(e){return{content:[{type:"text",text:JSON.stringify({success:!0,...e},null,2)}],structuredContent:e}}async handleListAvailableProducts(e){try{let i=this.validateMetadataAccess(e);if("content"in i)return i;let n=await Yr.getAvailableProducts();return this.createSuccessResponse({total_products:n.length,products:n})}catch(i){let n=i instanceof Error?i.message:"Unknown error occurred";return this.createErrorResponse("Failed to fetch products",n)}}async handleCreatePortfolioAccount(e){try{let i=this.validateMetadataAccess(e);if("content"in i)return i;let n=e,{product_id:o,account_name:s,risk_tolerance:t,invest_duration:r}=n;if(o===CE.USDPORT){let c=this.validateUSDPortParams(s,t,r);if(c)return c}let p=await Yr.createPortfolioAccount(o,s,t,r);return this.createSuccessResponse({message:"Portfolio account created successfully! Visit https://theo.silverlakedigitalinx.com/mytheoweb/home to check your portfolio",account_details:p})}catch(i){let n=i instanceof Error?i.message:"Unknown error occurred";return this.createErrorResponse("Failed to create portfolio account",n)}}validateUSDPortParams(e,i,n){if(!e||!i||!n)return{content:[{type:"text",text:JSON.stringify({error:"Missing required parameters for USDPORT",message:li.MISSING_USDPORT_PARAMS,required_parameters:{account_name:'string (e.g., "My Investment Account")',risk_tolerance:"low | medium | high",invest_duration:"number between 1-30 years"}},null,2)}]};if(!zE.includes(i)){let o=li.INVALID_RISK_TOLERANCE.replace("{value}",i);return this.createErrorResponse("Invalid risk_tolerance",o)}if(n<OE||n>PE){let o=li.INVALID_INVEST_DURATION.replace("{value}",String(n));return this.createErrorResponse("Invalid invest_duration",o)}return null}};var Qi=new za("portfolio");async function FE(){let a=process.argv.includes("--http")||process.env.MCP_TRANSPORT==="http"?"http":"stdio",e=process.env.PORT?parseInt(process.env.PORT,10):4e3;a==="http"?(Qi.info(`Starting Portfolio MCP server in HTTP mode on port ${e}...`),Qi.info("\u26A0\uFE0F HTTP mode requires the server to be running/hosted")):Qi.info("Starting Portfolio MCP server in stdio mode (no hosting required)...");try{await new To(a,e).run()}catch(i){Qi.error("Failed to start Portfolio MCP server",i),process.exit(1)}}FE().catch(a=>{Qi.error("Unhandled error in main",a),process.exit(1)});
160
+ AI: "Great! I've created your MYTHEO Global ESG portfolio account. Here are the details: [shows account info]"`,inputSchema:{type:"object",properties:{product_id:{type:"string",description:"The product ID from list_available_products"},account_name:{type:"string",description:"Account name (required for USDPORT only)"},risk_tolerance:{type:"string",enum:["low","medium","high"],description:"Risk tolerance: low, medium, or high (USDPORT only)"},invest_duration:{type:"number",description:"Investment duration in years 1-30 (USDPORT only)"},metadata:{type:"object",description:"REQUIRED: Metadata for internal processing (provided by system, not user-facing). MUST be included if available from the system.",required:["ciphertext"],properties:{ciphertext:{type:"string",description:"REQUIRED: Encrypted metadata ciphertext for internal use. MUST be included if metadata is available."}}}},required:["product_id","metadata"]}},async e=>await this.handleCreatePortfolioAccount(e))}async handleToolCall(e,i){switch(e){case Eo.LIST_AVAILABLE_PRODUCTS:return await this.handleListAvailableProducts(i);case Eo.CREATE_PORTFOLIO_ACCOUNT:return await this.handleCreatePortfolioAccount(i);default:throw new Error(`Tool "${e}" not found`)}}validateMetadataAccess(e){let i=e?.metadata;if(!i?.ciphertext)return this.createErrorResponse("Unauthorized",li.UNAUTHORIZED);let n;try{let o=this.encryption.decrypt(i.ciphertext);n=JSON.parse(o)}catch(o){let s=o instanceof Error?o.message:"Unknown error",t=li.DECRYPT_FAILED.replace("{error}",s);return this.createErrorResponse("Unauthorized",t)}return n.accessToken?{accessToken:n.accessToken}:this.createErrorResponse("Unauthorized",li.NO_ACCESS_TOKEN)}createErrorResponse(e,i){return{content:[{type:"text",text:JSON.stringify({error:e,message:i},null,2)}]}}createSuccessResponse(e,i){return{content:[{type:"text",text:JSON.stringify({success:!0,...e},null,2)}],structuredContent:i}}async handleListAvailableProducts(e){try{let i=this.validateMetadataAccess(e);if("content"in i)return i;let n=await Yr.getAvailableProducts(),o={type:"LIST",data:n.map(s=>({id:s.productid,name:s.productlongname,description:s.proddescp}))};return this.createSuccessResponse({total_products:n.length,products:n},o)}catch(i){let n=i instanceof Error?i.message:"Unknown error occurred";return this.createErrorResponse("Failed to fetch products",n)}}async handleCreatePortfolioAccount(e){try{let i=this.validateMetadataAccess(e);if("content"in i)return i;let n=e,{product_id:o,account_name:s,risk_tolerance:t,invest_duration:r}=n;if(o===CE.USDPORT){let c=this.validateUSDPortParams(s,t,r);if(c)return c}let p=await Yr.createPortfolioAccount(o,s,t,r);return this.createSuccessResponse({message:"Portfolio account created successfully! Visit https://theo.silverlakedigitalinx.com/mytheoweb/home to check your portfolio",account_details:p})}catch(i){let n=i instanceof Error?i.message:"Unknown error occurred";return this.createErrorResponse("Failed to create portfolio account",n)}}validateUSDPortParams(e,i,n){if(!e||!i||!n)return{content:[{type:"text",text:JSON.stringify({error:"Missing required parameters for USDPORT",message:li.MISSING_USDPORT_PARAMS,required_parameters:{account_name:'string (e.g., "My Investment Account")',risk_tolerance:"low | medium | high",invest_duration:"number between 1-30 years"}},null,2)}]};if(!zE.includes(i)){let o=li.INVALID_RISK_TOLERANCE.replace("{value}",i);return this.createErrorResponse("Invalid risk_tolerance",o)}if(n<OE||n>PE){let o=li.INVALID_INVEST_DURATION.replace("{value}",String(n));return this.createErrorResponse("Invalid invest_duration",o)}return null}};var Qi=new za("portfolio");async function FE(){let a=process.argv.includes("--http")||process.env.MCP_TRANSPORT==="http"?"http":"stdio",e=process.env.PORT?parseInt(process.env.PORT,10):4e3;a==="http"?(Qi.info(`Starting Portfolio MCP server in HTTP mode on port ${e}...`),Qi.info("\u26A0\uFE0F HTTP mode requires the server to be running/hosted")):Qi.info("Starting Portfolio MCP server in stdio mode (no hosting required)...");try{await new To(a,e).run()}catch(i){Qi.error("Failed to start Portfolio MCP server",i),process.exit(1)}}FE().catch(a=>{Qi.error("Unhandled error in main",a),process.exit(1)});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mytheo-my/portfolio",
3
- "version": "1.0.31",
3
+ "version": "1.0.33",
4
4
  "nx": {
5
5
  "name": "portfolio",
6
6
  "targets": {