AD4M Languages are JavaScript modules that get installed into the user's AD4M instance. They are used to resolve Expression URIs in order to get the actual data, and to create new Expressions. tutorial
Here we retrieve and display the list of installed languages and show the metadata (author, description, etc.) for one of them.
languages.ts
import { getAd4mClient } from "@perspect3vism/ad4m-connect"; import type { Ad4mClient, LanguageHandle } from "@perspect3vism/ad4m"; /* * Function to show installed languages */ export default async function languages() { const ad4m: Ad4mClient = await getAd4mClient(); // We retrieve all installed languages const installedLanguages: LanguageHandle[] = await ad4m.languages.all(); console.log(installedLanguages); // And ask for the meta info of one of them const metaInfo = await ad4m.languages.meta(installedLanguages[1].address); console.log(metaInfo); }
AD4M will automatically try to download and install a new Language when an app tries to use it. Since this entails running foreign code, AD4M checks the signature of the Language code and if its auther is trusted, and potentially explicitly asks the user if they want to add the Language's author to their list of trusted agents.
~
Console output:
[ { name: 'languages', address: 'QmZUAan3A2BvSEoj54xBsShQM2icsxeAYcZuunrnNuAV1z', settings: '{}', icon: null, constructorIcon: null, settingsIcon: null }, { name: 'agent-expression-store', address: 'QmVYQxroapbRebjjbZnjKSTQBsqvk5sEBCcyiEKyBRXKLo', settings: '{}', icon: null, constructorIcon: null, settingsIcon: null }, { name: 'neighbourhood-store', address: 'QmNLtgDrjri7DzqDohmQUKJzr5fXVAN95K4VhMr9GhM9ia', settings: '{}', icon: null, constructorIcon: null, settingsIcon: null }, { name: 'perspective-language', address: 'QmYRCZkyZJ7axzPcNCizgEqkjXwvC2nu2UR1M31geggx4W', settings: '{}', icon: null, constructorIcon: null, settingsIcon: null }, { name: 'direct-message-language', address: 'Qma7Ftk86T4mKJvMoVroFKxN7tRmrPS1B3hrUvEqv69HeZ', settings: '{}', icon: null, constructorIcon: null, settingsIcon: null } ] { name: 'agent-language', address: 'QmVYQxroapbRebjjbZnjKSTQBsqvk5sEBCcyiEKyBRXKLo', description: 'Holochain based language for storing agent profile expressions', author: 'did:key:zQ3sheV6m6sT83woZtVL2PHiz6J1qWRh4FWW2aiJvxy6d2o7S', templated: false, templateSourceLanguageAddress: null, templateAppliedParams: null, possibleTemplateParams: [ '' ], sourceCodeLink: 'https://github.com/perspect3vism/agent-language' }
agent-language sourceCodeLink – A ad4m language to store Agent data associated with DID's