@alfe.ai/openclaw 0.2.0 → 0.3.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/plugin2.cjs CHANGED
@@ -31,6 +31,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
31
31
  }) : target, mod));
32
32
  //#endregion
33
33
  let node_path = require("node:path");
34
+ let node_fs_promises = require("node:fs/promises");
34
35
  let node_os = require("node:os");
35
36
  let node_module = require("node:module");
36
37
  let _alfe_ai_config = require("@alfe.ai/config");
@@ -3096,6 +3097,22 @@ let ipcClient = null;
3096
3097
  * proxy. openclaw-chat hardcodes the same host for /__alfe/set-identity.
3097
3098
  */
3098
3099
  const LOCAL_AI_PROXY_URL = process.env.ALFE_AI_PROXY_URL ?? "http://127.0.0.1:18193";
3100
+ /** Max avatar upload size — mirrors the server-side finalize check. */
3101
+ const MAX_AVATAR_BYTES = 5 * 1024 * 1024;
3102
+ /** Image types the avatar presign/finalize flow accepts, keyed by file extension. */
3103
+ const AVATAR_MIME_BY_EXT = {
3104
+ ".png": "image/png",
3105
+ ".jpg": "image/jpeg",
3106
+ ".jpeg": "image/jpeg",
3107
+ ".webp": "image/webp"
3108
+ };
3109
+ /** Infer an avatar mime type from a file path, rejecting unsupported types. */
3110
+ function avatarMimeFromPath(path) {
3111
+ const ext = (0, node_path.extname)(path).toLowerCase();
3112
+ const mimeType = AVATAR_MIME_BY_EXT[ext];
3113
+ if (!mimeType) throw new Error(`unsupported image type "${ext || path}" — set_avatar accepts .png, .jpg/.jpeg, or .webp`);
3114
+ return mimeType;
3115
+ }
3099
3116
  function ok(result) {
3100
3117
  return { content: [{
3101
3118
  type: "text",
@@ -3225,6 +3242,45 @@ function buildVoiceTools(client) {
3225
3242
  };
3226
3243
  }
3227
3244
  }),
3245
+ defineTool({
3246
+ name: "generate_avatar",
3247
+ description: "Generate and set THIS agent's own profile picture / avatar from a text prompt (e.g. a character description). Updates the agent's real profile picture shown in the dashboard, chat, and apps. Use this — do NOT use `config set ui.assistant.avatar`, which has no effect on the real profile.",
3248
+ parameters: Type.Object({ prompt: Type.String({ description: "Text description of the avatar to generate (e.g. a character or portrait description)." }) }),
3249
+ handler: async (params) => {
3250
+ const prompt = params.prompt;
3251
+ return {
3252
+ updated: true,
3253
+ avatarUrl: (await client.generateAvatar({ prompt })).avatarUrl,
3254
+ note: "This is now your live profile picture across the Alfe dashboard, chat, and apps. `config set ui.assistant.avatar` is NOT the way — it has no effect on the real profile."
3255
+ };
3256
+ }
3257
+ }),
3258
+ defineTool({
3259
+ name: "set_avatar",
3260
+ description: "Set THIS agent's own profile picture from a local image file you created or downloaded (png/jpeg/webp, <=5MB). Updates the real profile picture shown in the dashboard, chat, and apps. Use this — do NOT use `config set ui.assistant.avatar`, which has no effect on the real profile.",
3261
+ parameters: Type.Object({ path: Type.String({ description: "Absolute path to a local image file (.png, .jpg/.jpeg, or .webp, <=5MB) to use as the avatar." }) }),
3262
+ handler: async (params) => {
3263
+ const path = params.path;
3264
+ const mimeType = avatarMimeFromPath(path);
3265
+ const bytes = await (0, node_fs_promises.readFile)(path);
3266
+ if (bytes.length > MAX_AVATAR_BYTES) throw new Error(`image is ${String(bytes.length)} bytes — the avatar limit is ${String(MAX_AVATAR_BYTES)} bytes (5MB)`);
3267
+ const { uploadUrl, s3Key } = await client.presignAvatar({
3268
+ mimeType,
3269
+ size: bytes.length
3270
+ });
3271
+ const putRes = await fetch(uploadUrl, {
3272
+ method: "PUT",
3273
+ headers: { "Content-Type": mimeType },
3274
+ body: bytes
3275
+ });
3276
+ if (!putRes.ok) throw new Error(`failed to upload the avatar image (${String(putRes.status)})`);
3277
+ return {
3278
+ updated: true,
3279
+ avatarUrl: (await client.finalizeAvatar(s3Key)).avatarUrl,
3280
+ note: "This is now your live profile picture across the Alfe dashboard, chat, and apps. `config set ui.assistant.avatar` is NOT the way — it has no effect on the real profile."
3281
+ };
3282
+ }
3283
+ }),
3228
3284
  defineTool({
3229
3285
  name: "generate_image",
3230
3286
  description: "Generate an image from a text prompt. Returns a URL to the generated PNG. To show the image to the user, embed it in your reply as markdown: ![description](imageUrl). Optional `model` picks the image model (default gpt-image-1).",
package/dist/plugin2.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { createRequire } from "node:module";
2
- import { join } from "node:path";
2
+ import { extname, join } from "node:path";
3
+ import { readFile } from "node:fs/promises";
3
4
  import { homedir } from "node:os";
4
5
  import { resolveConfig } from "@alfe.ai/config";
5
6
  import { AgentApiClient } from "@alfe.ai/agent-api-client";
@@ -3097,6 +3098,22 @@ let ipcClient = null;
3097
3098
  * proxy. openclaw-chat hardcodes the same host for /__alfe/set-identity.
3098
3099
  */
3099
3100
  const LOCAL_AI_PROXY_URL = process.env.ALFE_AI_PROXY_URL ?? "http://127.0.0.1:18193";
3101
+ /** Max avatar upload size — mirrors the server-side finalize check. */
3102
+ const MAX_AVATAR_BYTES = 5 * 1024 * 1024;
3103
+ /** Image types the avatar presign/finalize flow accepts, keyed by file extension. */
3104
+ const AVATAR_MIME_BY_EXT = {
3105
+ ".png": "image/png",
3106
+ ".jpg": "image/jpeg",
3107
+ ".jpeg": "image/jpeg",
3108
+ ".webp": "image/webp"
3109
+ };
3110
+ /** Infer an avatar mime type from a file path, rejecting unsupported types. */
3111
+ function avatarMimeFromPath(path) {
3112
+ const ext = extname(path).toLowerCase();
3113
+ const mimeType = AVATAR_MIME_BY_EXT[ext];
3114
+ if (!mimeType) throw new Error(`unsupported image type "${ext || path}" — set_avatar accepts .png, .jpg/.jpeg, or .webp`);
3115
+ return mimeType;
3116
+ }
3100
3117
  function ok(result) {
3101
3118
  return { content: [{
3102
3119
  type: "text",
@@ -3226,6 +3243,45 @@ function buildVoiceTools(client) {
3226
3243
  };
3227
3244
  }
3228
3245
  }),
3246
+ defineTool({
3247
+ name: "generate_avatar",
3248
+ description: "Generate and set THIS agent's own profile picture / avatar from a text prompt (e.g. a character description). Updates the agent's real profile picture shown in the dashboard, chat, and apps. Use this — do NOT use `config set ui.assistant.avatar`, which has no effect on the real profile.",
3249
+ parameters: Type.Object({ prompt: Type.String({ description: "Text description of the avatar to generate (e.g. a character or portrait description)." }) }),
3250
+ handler: async (params) => {
3251
+ const prompt = params.prompt;
3252
+ return {
3253
+ updated: true,
3254
+ avatarUrl: (await client.generateAvatar({ prompt })).avatarUrl,
3255
+ note: "This is now your live profile picture across the Alfe dashboard, chat, and apps. `config set ui.assistant.avatar` is NOT the way — it has no effect on the real profile."
3256
+ };
3257
+ }
3258
+ }),
3259
+ defineTool({
3260
+ name: "set_avatar",
3261
+ description: "Set THIS agent's own profile picture from a local image file you created or downloaded (png/jpeg/webp, <=5MB). Updates the real profile picture shown in the dashboard, chat, and apps. Use this — do NOT use `config set ui.assistant.avatar`, which has no effect on the real profile.",
3262
+ parameters: Type.Object({ path: Type.String({ description: "Absolute path to a local image file (.png, .jpg/.jpeg, or .webp, <=5MB) to use as the avatar." }) }),
3263
+ handler: async (params) => {
3264
+ const path = params.path;
3265
+ const mimeType = avatarMimeFromPath(path);
3266
+ const bytes = await readFile(path);
3267
+ if (bytes.length > MAX_AVATAR_BYTES) throw new Error(`image is ${String(bytes.length)} bytes — the avatar limit is ${String(MAX_AVATAR_BYTES)} bytes (5MB)`);
3268
+ const { uploadUrl, s3Key } = await client.presignAvatar({
3269
+ mimeType,
3270
+ size: bytes.length
3271
+ });
3272
+ const putRes = await fetch(uploadUrl, {
3273
+ method: "PUT",
3274
+ headers: { "Content-Type": mimeType },
3275
+ body: bytes
3276
+ });
3277
+ if (!putRes.ok) throw new Error(`failed to upload the avatar image (${String(putRes.status)})`);
3278
+ return {
3279
+ updated: true,
3280
+ avatarUrl: (await client.finalizeAvatar(s3Key)).avatarUrl,
3281
+ note: "This is now your live profile picture across the Alfe dashboard, chat, and apps. `config set ui.assistant.avatar` is NOT the way — it has no effect on the real profile."
3282
+ };
3283
+ }
3284
+ }),
3229
3285
  defineTool({
3230
3286
  name: "generate_image",
3231
3287
  description: "Generate an image from a text prompt. Returns a URL to the generated PNG. To show the image to the user, embed it in your reply as markdown: ![description](imageUrl). Optional `model` picks the image model (default gpt-image-1).",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alfe.ai/openclaw",
3
- "version": "0.2.0",
3
+ "version": "0.3.1",
4
4
  "description": "OpenClaw plugin for Alfe — connects to local gateway daemon via IPC for integration management",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -27,7 +27,7 @@
27
27
  "@sinclair/typebox": "^0.34.48",
28
28
  "zod": "^4.1.5",
29
29
  "@alfe.ai/agent-api-client": "^0.4.0",
30
- "@alfe.ai/config": "^0.2.0"
30
+ "@alfe.ai/config": "^0.3.0"
31
31
  },
32
32
  "peerDependencies": {
33
33
  "openclaw": ">=2026.3.0"