@agentlas/core
v0.1.6
Published
Shared Agentlas plugin core: API client, config, Tree Hole orchestrator.
Readme
@agentlas/core
Shared logic for every Agentlas host plugin and MCP server. No host-specific imports — pure TS.
Surface
Config types & readers
| Export | Purpose |
| --- | --- |
| AgentlasPluginConfig | { apiBaseUrl, apiToken } shape used by every plugin. |
| readPluginConfig(raw) | Normalize an arbitrary config object (OpenClaw passes one). |
| readPluginConfigFromEnv(env?) | Read config from AGENTLAS_API_BASE_URL / AGENTLAS_API_TOKEN. |
| readPluginConfigLayered(env?) | Recommended for runtimes. Reads env vars first, then falls back to ~/.agentlas/config.json. The MCP server uses this so credentials survive plugin reinstalls. |
| normalizeBaseUrl(url) | Strip trailing slashes from a base URL. |
User-level config file
| Export | Purpose |
| --- | --- |
| AGENTLAS_CONFIG_DIR | process.env.AGENTLAS_CONFIG_DIR or ~/.agentlas. |
| AGENTLAS_CONFIG_FILE | <AGENTLAS_CONFIG_DIR>/config.json. |
| readConfigFile() | Read the JSON config file (returns {} on missing/invalid). |
| writeConfigFile(config) | Atomic write with dir 0700 / file 0600 permissions. |
| deleteConfigFile() | Best-effort unlink. |
| hasConfiguredCredentials(env?) | true if either env vars or the file provide both fields. |
HTTP / Tree Hole
| Export | Purpose |
| --- | --- |
| agentlasFetch(config, path, init?) | Generic HTTP helper. Adds x-api-key, throws AgentlasFetchError on non-2xx, returns parsed JSON. |
| AgentlasFetchError | Error thrown by agentlasFetch; carries status, statusText, body. |
| createTreeholePost(config, body) | Low-level Tree Hole call returning a CreateTreeholeResult envelope (no throws). |
| saveTreehole(config, body) / saveTreeholeFromText(rawConfig, body) | High-level orchestrators that produce user-facing confirmation text. |
