openbot 0.3.4 → 0.3.5

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/app/cli.js CHANGED
File without changes
@@ -0,0 +1,4 @@
1
+ <svg width="60.2" height="58.1" viewBox="262.8 360.5 84.2 82.1" fill="#9333EA" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M301.841 380.896C302.069 380.893 302.297 380.889 302.531 380.885C304.636 380.853 306.741 380.836 308.845 380.822C310.26 380.813 311.675 380.8 313.09 380.775C314.456 380.752 315.822 380.739 317.189 380.735C317.71 380.731 318.231 380.724 318.752 380.712C322.824 380.626 322.824 380.626 323.909 381.43C324.315 382.025 324.561 382.569 324.8 383.246C324.965 383.518 325.13 383.789 325.301 384.068C325.519 384.445 325.519 384.445 325.741 384.83C325.909 385.118 326.077 385.407 326.249 385.704C326.336 385.854 326.423 386.004 326.513 386.159C328.304 389.25 330.137 392.314 332.004 395.361C332.482 396.144 332.957 396.929 333.431 397.715C333.631 398.035 333.631 398.035 333.835 398.361C334.546 399.544 334.969 400.367 334.7 401.777C334.24 402.838 333.683 403.834 333.113 404.839C332.867 405.285 332.621 405.73 332.375 406.176C332.125 406.626 331.874 407.075 331.622 407.525C330.952 408.724 330.296 409.931 329.639 411.137C329.518 411.359 329.397 411.58 329.272 411.807C328.303 413.581 327.349 415.362 326.398 417.144C324.53 420.642 322.621 424.107 320.611 427.525C320.282 428.088 319.962 428.655 319.644 429.224C319.215 429.954 319.215 429.954 318.708 430.462C317.978 430.557 317.978 430.557 317.185 430.462C316.049 429.578 315.42 428.258 314.71 427.035C313.685 425.291 312.637 423.6 311.454 421.96C311.024 421.203 310.906 420.668 310.838 419.8C311.092 419.081 311.092 419.081 311.491 418.343C311.707 417.937 311.707 417.937 311.927 417.522C312.081 417.242 312.235 416.963 312.393 416.675C312.615 416.26 312.615 416.26 312.841 415.836C314.003 413.671 314.003 413.671 314.549 412.797C315.269 411.676 315.269 411.676 315.308 410.387C314.801 409.466 314.268 408.575 313.694 407.695C313.466 407.335 313.238 406.976 313.011 406.616C312.845 406.353 312.845 406.353 312.676 406.085C312.247 405.402 311.829 404.713 311.425 404.014C311.304 403.806 311.183 403.598 311.058 403.384C310.786 402.65 310.848 402.26 311.092 401.523C311.6 401.015 311.6 401.015 312.57 400.967C312.988 400.97 313.407 400.975 313.826 400.982C314.281 400.981 314.737 400.981 315.192 400.98C315.911 400.98 316.629 400.984 317.348 400.995C318.041 401.005 318.733 401.002 319.427 400.998C319.641 401.004 319.854 401.011 320.075 401.017C320.695 401.007 321.171 400.974 321.754 400.762C322.329 400.154 322.665 399.481 323.023 398.731C323.171 398.49 323.318 398.248 323.47 398C323.899 397.287 324.326 396.573 324.752 395.859C324.904 395.608 325.056 395.357 325.212 395.099C325.355 394.859 325.498 394.618 325.646 394.371C325.841 394.045 325.841 394.045 326.04 393.713C326.38 393.138 326.38 393.138 326.323 392.385C326.167 392.384 326.011 392.383 325.85 392.383C322.054 392.368 318.257 392.349 314.461 392.325C312.625 392.313 310.789 392.303 308.953 392.297C307.352 392.291 305.752 392.282 304.152 392.271C303.305 392.265 302.458 392.26 301.61 392.258C300.664 392.256 299.719 392.249 298.773 392.241C298.351 392.241 298.351 392.241 297.921 392.242C297.663 392.238 297.406 392.235 297.14 392.232C296.916 392.231 296.693 392.23 296.462 392.228C295.73 392.109 295.379 391.879 294.846 391.369C294.591 389.978 295.187 388.999 295.837 387.818C295.938 387.63 296.038 387.441 296.142 387.246C296.464 386.646 296.789 386.049 297.115 385.451C297.333 385.045 297.551 384.638 297.769 384.231C299.545 380.925 299.545 380.925 301.841 380.896Z" fill="#9333EA"/>
3
+ <path d="M291.476 372.547C292.795 373.009 293.243 374.055 293.942 375.218C294.23 375.684 294.519 376.15 294.807 376.615C294.945 376.84 295.082 377.065 295.223 377.297C295.544 377.813 295.875 378.314 296.225 378.811C296.388 379.044 296.551 379.277 296.718 379.518C296.856 379.711 296.994 379.903 297.137 380.102C297.492 380.97 297.407 381.615 297.131 382.485C296.704 383.459 296.209 384.39 295.703 385.325C295.497 385.714 295.497 385.714 295.287 386.111C294.44 387.702 293.559 389.255 292.565 390.759C292.217 391.585 292.351 392.026 292.562 392.892C292.955 393.665 292.955 393.665 293.466 394.431C293.555 394.572 293.644 394.713 293.736 394.858C294.019 395.304 294.305 395.748 294.592 396.192C294.971 396.778 295.346 397.365 295.719 397.953C295.886 398.212 296.053 398.471 296.225 398.738C296.646 399.535 296.848 400.115 296.877 401.015C296.559 401.435 296.559 401.435 296.115 401.777C295.364 401.849 294.663 401.877 293.911 401.871C293.467 401.876 293.023 401.88 292.579 401.885C291.879 401.887 291.18 401.888 290.48 401.888C289.804 401.888 289.129 401.895 288.453 401.903C288.244 401.901 288.036 401.899 287.82 401.897C286.637 401.91 286.637 401.91 285.616 402.466C284.844 403.543 284.229 404.69 283.598 405.854C283.455 406.11 283.312 406.365 283.165 406.628C283.031 406.873 282.897 407.118 282.76 407.371C282.637 407.594 282.515 407.818 282.389 408.048C282.071 408.656 282.071 408.656 282.408 409.392C282.559 409.393 282.71 409.394 282.865 409.395C286.539 409.416 290.213 409.439 293.886 409.465C295.663 409.478 297.439 409.49 299.216 409.499C300.929 409.509 302.642 409.521 304.356 409.534C305.011 409.539 305.665 409.543 306.32 409.546C307.235 409.55 308.15 409.557 309.064 409.565C309.473 409.566 309.473 409.566 309.89 409.567C310.139 409.57 310.388 409.573 310.644 409.576C310.861 409.577 311.077 409.578 311.3 409.58C311.854 409.646 311.854 409.646 312.615 410.154C312.797 411.581 312.41 412.577 311.745 413.808C311.656 413.979 311.567 414.15 311.475 414.326C311.288 414.685 311.099 415.042 310.908 415.399C310.616 415.946 310.329 416.495 310.042 417.045C309.859 417.394 309.676 417.743 309.492 418.092C309.363 418.337 309.363 418.337 309.231 418.588C308.881 419.242 308.574 419.78 308.046 420.308C307.364 420.361 306.707 420.382 306.024 420.382C305.815 420.383 305.606 420.385 305.391 420.387C304.698 420.392 304.005 420.392 303.312 420.393C302.832 420.395 302.351 420.396 301.871 420.398C300.862 420.401 299.854 420.402 298.845 420.402C297.552 420.402 296.259 420.409 294.966 420.417C293.973 420.423 292.98 420.424 291.987 420.424C291.51 420.424 291.034 420.427 290.557 420.431C289.89 420.436 289.224 420.434 288.557 420.431C288.36 420.434 288.163 420.437 287.959 420.44C287.061 420.429 286.569 420.386 285.852 419.824C285.47 419.314 285.137 418.817 284.831 418.259C284.718 418.056 284.605 417.852 284.488 417.643C284.367 417.423 284.246 417.203 284.121 416.976C282.907 414.808 281.638 412.679 280.329 410.566C280.156 410.286 279.982 410.006 279.803 409.717C279.469 409.176 279.134 408.636 278.799 408.096C277.871 406.592 276.959 405.077 276.062 403.554C275.968 403.409 275.874 403.264 275.777 403.114C275.143 402.097 274.834 401.442 275.046 400.254C275.425 399.337 275.889 398.475 276.363 397.604C276.568 397.22 276.568 397.22 276.777 396.828C278.005 394.541 279.284 392.283 280.569 390.029C282.224 387.119 283.868 384.197 285.327 381.184C289.509 372.654 289.509 372.654 291.476 372.547Z" fill="#9333EA"/>
4
+ </svg>
@@ -455,8 +455,8 @@ export const busServicesPlugin = (options) => (builder) => {
455
455
  });
456
456
  builder.on('action:storage:create-agent', async function* (event) {
457
457
  try {
458
- const { agentId, name, description, instructions, plugins } = event.data;
459
- await storage.createAgent({ agentId, name, description, instructions, plugins });
458
+ const { agentId, name, description, image, instructions, plugins } = event.data;
459
+ await storage.createAgent({ agentId, name, description, image, instructions, plugins });
460
460
  yield { type: 'action:storage:create-agent-result', data: { success: true } };
461
461
  }
462
462
  catch (error) {
@@ -471,8 +471,8 @@ export const busServicesPlugin = (options) => (builder) => {
471
471
  });
472
472
  builder.on('action:storage:update-agent', async function* (event) {
473
473
  try {
474
- const { agentId, name, description, instructions, plugins } = event.data;
475
- await storage.updateAgent({ agentId, name, description, instructions, plugins });
474
+ const { agentId, name, description, image, instructions, plugins } = event.data;
475
+ await storage.updateAgent({ agentId, name, description, image, instructions, plugins });
476
476
  yield { type: 'action:storage:update-agent-result', data: { success: true } };
477
477
  }
478
478
  catch (error) {
@@ -758,7 +758,7 @@ export const busServicesPlugin = (options) => (builder) => {
758
758
  });
759
759
  builder.on('action:agent:install', async function* (event) {
760
760
  try {
761
- const { agentId, name, description, instructions, plugins } = event.data;
761
+ const { agentId, name, description, image, instructions, plugins } = event.data;
762
762
  // Ensure each plugin is available locally. Built-in ids resolve
763
763
  // immediately; npm-name ids are fetched on demand.
764
764
  for (const ref of plugins) {
@@ -780,6 +780,7 @@ export const busServicesPlugin = (options) => (builder) => {
780
780
  agentId,
781
781
  name,
782
782
  description,
783
+ image,
783
784
  instructions,
784
785
  plugins,
785
786
  });
@@ -1,6 +1,8 @@
1
1
  import { DEFAULT_PLUGINS_DIR, DEFAULT_AGENTS_DIR, DEFAULT_BASE_DIR, DEFAULT_CHANNELS_DIR, loadConfig, resolvePath, VARIABLES_FILE, } from '../app/config.js';
2
2
  import fs from 'node:fs/promises';
3
+ import { readFileSync } from 'node:fs';
3
4
  import path from 'node:path';
5
+ import { fileURLToPath, pathToFileURL } from 'node:url';
4
6
  import crypto from 'node:crypto';
5
7
  import matter from 'gray-matter';
6
8
  import { aiSdkPlugin } from '../plugins/ai-sdk/index.js';
@@ -8,13 +10,31 @@ import { AI_SDK_SYSTEM_PROMPT } from '../plugins/ai-sdk/system-prompt.js';
8
10
  import { listBuiltInPlugins, parsePluginModule } from '../registry/plugins.js';
9
11
  import { processService } from '../harness/process.js';
10
12
  import { memoryService } from './memory.js';
11
- import { pathToFileURL } from 'node:url';
12
13
  const resolveBaseDir = () => {
13
14
  const config = loadConfig();
14
15
  return resolvePath(config.baseDir || DEFAULT_BASE_DIR);
15
16
  };
16
17
  const ENTITY_SVG_CANDIDATE_NAMES = ['avatar.svg', 'icon.svg', 'image.svg', 'logo.svg'];
17
18
  const toSvgDataUrl = (svg) => `data:image/svg+xml;base64,${Buffer.from(svg, 'utf-8').toString('base64')}`;
19
+ let bundledSystemAgentImage;
20
+ let bundledSystemAgentImageLoaded = false;
21
+ /** OpenBot mark from `src/assets/icon.svg` (also copied to `dist/assets` at build). */
22
+ function getBundledSystemAgentImage() {
23
+ if (bundledSystemAgentImageLoaded)
24
+ return bundledSystemAgentImage;
25
+ bundledSystemAgentImageLoaded = true;
26
+ try {
27
+ const iconPath = path.join(path.dirname(fileURLToPath(import.meta.url)), '../assets/icon.svg');
28
+ const trimmed = readFileSync(iconPath, 'utf-8').trim();
29
+ if (!trimmed.startsWith('<svg'))
30
+ return undefined;
31
+ bundledSystemAgentImage = toSvgDataUrl(trimmed);
32
+ }
33
+ catch {
34
+ bundledSystemAgentImage = undefined;
35
+ }
36
+ return bundledSystemAgentImage;
37
+ }
18
38
  const tryReadSvgDataUrl = async (filePath) => {
19
39
  try {
20
40
  const svg = await fs.readFile(filePath, 'utf-8');
@@ -72,7 +92,7 @@ function getSystemAgentDetails(overrides) {
72
92
  const defaults = {
73
93
  id: SYSTEM_AGENT_ID,
74
94
  name: 'OpenBot',
75
- image: undefined,
95
+ image: getBundledSystemAgentImage(),
76
96
  description: 'First-party orchestration agent for OpenBot. Coordinates other agents via handoff.',
77
97
  instructions: AI_SDK_SYSTEM_PROMPT,
78
98
  plugins: SYSTEM_DEFAULT_PLUGINS.map((ref) => ref.id),
@@ -599,6 +619,9 @@ export const storageService = {
599
619
  const discoveredImage = await resolveEntityImageDataUrl(agentDir);
600
620
  const stats = await fs.stat(agentMdPath);
601
621
  const pluginRefs = parsePluginRefs(data.plugins);
622
+ const frontmatterImage = typeof data.image === 'string' && data.image.trim() !== ''
623
+ ? data.image.trim()
624
+ : undefined;
602
625
  diskDetails = {
603
626
  id: agentId,
604
627
  name: typeof data.name === 'string' ? data.name : agentId,
@@ -606,7 +629,7 @@ export const storageService = {
606
629
  plugins: pluginRefs.map((ref) => ref.id),
607
630
  pluginRefs,
608
631
  description: typeof data.description === 'string' ? data.description : '',
609
- image: discoveredImage || undefined,
632
+ image: frontmatterImage || discoveredImage || undefined,
610
633
  createdAt: stats.birthtime,
611
634
  updatedAt: stats.mtime,
612
635
  };
@@ -630,7 +653,7 @@ export const storageService = {
630
653
  }
631
654
  return diskDetails;
632
655
  },
633
- createAgent: async ({ agentId, name, description = '', instructions, plugins, }) => {
656
+ createAgent: async ({ agentId, name, description = '', image, instructions, plugins, }) => {
634
657
  assertValidDiskAgentId(agentId);
635
658
  const agentDir = resolvePath(path.join(getAgentsRootDir(), agentId));
636
659
  const agentMdPath = path.join(agentDir, 'AGENT.md');
@@ -656,10 +679,13 @@ export const storageService = {
656
679
  description,
657
680
  plugins: serializePluginRefs(plugins),
658
681
  };
682
+ if (typeof image === 'string' && image.trim() !== '') {
683
+ data.image = image.trim();
684
+ }
659
685
  const body = matter.stringify(`${instructions.trim()}\n`, data);
660
686
  await fs.writeFile(agentMdPath, body, 'utf-8');
661
687
  },
662
- updateAgent: async ({ agentId, name, description, instructions, plugins, }) => {
688
+ updateAgent: async ({ agentId, name, description, image, instructions, plugins, }) => {
663
689
  assertValidDiskAgentId(agentId);
664
690
  const agentDir = resolvePath(path.join(getAgentsRootDir(), agentId));
665
691
  const agentMdPath = path.join(agentDir, 'AGENT.md');
@@ -683,6 +709,14 @@ export const storageService = {
683
709
  nextData.description = description;
684
710
  if (plugins !== undefined)
685
711
  nextData.plugins = serializePluginRefs(plugins);
712
+ if (image !== undefined) {
713
+ if (typeof image === 'string' && image.trim() !== '') {
714
+ nextData.image = image.trim();
715
+ }
716
+ else {
717
+ delete nextData.image;
718
+ }
719
+ }
686
720
  const nextContent = instructions !== undefined ? instructions : parsed.content;
687
721
  const body = matter.stringify(`${String(nextContent).trim()}\n`, nextData);
688
722
  await fs.writeFile(agentMdPath, body, 'utf-8');
package/package.json CHANGED
@@ -1,16 +1,11 @@
1
1
  {
2
2
  "name": "openbot",
3
- "version": "0.3.4",
3
+ "version": "0.3.5",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "engines": {
7
7
  "node": ">=20.12.0"
8
8
  },
9
- "scripts": {
10
- "dev": "tsx watch src/app/cli.ts start",
11
- "build": "tsc",
12
- "start": "node dist/app/cli.js start"
13
- },
14
9
  "bin": {
15
10
  "openbot": "./dist/app/cli.js"
16
11
  },
@@ -36,5 +31,10 @@
36
31
  "@types/node": "^20.10.1",
37
32
  "tsx": "^4.21.0",
38
33
  "typescript": "^5.9.3"
34
+ },
35
+ "scripts": {
36
+ "dev": "tsx watch src/app/cli.ts start",
37
+ "build": "tsc && mkdir -p dist/assets && cp src/assets/icon.svg dist/assets/icon.svg",
38
+ "start": "node dist/app/cli.js start"
39
39
  }
40
- }
40
+ }
package/src/app/types.ts CHANGED
@@ -143,6 +143,7 @@ export type CreateAgentEvent = BaseEvent & {
143
143
  agentId: string;
144
144
  name: string;
145
145
  description?: string;
146
+ image?: string;
146
147
  instructions: string;
147
148
  plugins: PluginRef[];
148
149
  };
@@ -162,6 +163,7 @@ export type UpdateAgentEvent = BaseEvent & {
162
163
  agentId: string;
163
164
  name?: string;
164
165
  description?: string;
166
+ image?: string;
165
167
  instructions?: string;
166
168
  plugins?: PluginRef[];
167
169
  };
@@ -745,6 +747,7 @@ export type InstallAgentEvent = BaseEvent & {
745
747
  agentId: string;
746
748
  name: string;
747
749
  description?: string;
750
+ image?: string;
748
751
  instructions: string;
749
752
  plugins: PluginRef[];
750
753
  };
@@ -550,8 +550,8 @@ export const busServicesPlugin =
550
550
 
551
551
  builder.on('action:storage:create-agent', async function* (event) {
552
552
  try {
553
- const { agentId, name, description, instructions, plugins } = event.data;
554
- await storage.createAgent({ agentId, name, description, instructions, plugins });
553
+ const { agentId, name, description, image, instructions, plugins } = event.data;
554
+ await storage.createAgent({ agentId, name, description, image, instructions, plugins });
555
555
  yield { type: 'action:storage:create-agent-result', data: { success: true } };
556
556
  } catch (error) {
557
557
  yield {
@@ -566,8 +566,8 @@ export const busServicesPlugin =
566
566
 
567
567
  builder.on('action:storage:update-agent', async function* (event) {
568
568
  try {
569
- const { agentId, name, description, instructions, plugins } = event.data;
570
- await storage.updateAgent({ agentId, name, description, instructions, plugins });
569
+ const { agentId, name, description, image, instructions, plugins } = event.data;
570
+ await storage.updateAgent({ agentId, name, description, image, instructions, plugins });
571
571
  yield { type: 'action:storage:update-agent-result', data: { success: true } };
572
572
  } catch (error) {
573
573
  yield {
@@ -858,7 +858,7 @@ export const busServicesPlugin =
858
858
 
859
859
  builder.on('action:agent:install', async function* (event) {
860
860
  try {
861
- const { agentId, name, description, instructions, plugins } = event.data;
861
+ const { agentId, name, description, image, instructions, plugins } = event.data;
862
862
 
863
863
  // Ensure each plugin is available locally. Built-in ids resolve
864
864
  // immediately; npm-name ids are fetched on demand.
@@ -881,6 +881,7 @@ export const busServicesPlugin =
881
881
  agentId,
882
882
  name,
883
883
  description,
884
+ image,
884
885
  instructions,
885
886
  plugins,
886
887
  });
package/src/bus/types.ts CHANGED
@@ -113,6 +113,8 @@ export interface Storage {
113
113
  agentId: string;
114
114
  name: string;
115
115
  description?: string;
116
+ /** Avatar/logo URL or data URI; persisted in AGENT.md frontmatter. */
117
+ image?: string;
116
118
  instructions: string;
117
119
  plugins: PluginRef[];
118
120
  }) => Promise<void>;
@@ -120,6 +122,8 @@ export interface Storage {
120
122
  agentId: string;
121
123
  name?: string;
122
124
  description?: string;
125
+ /** Omit to leave unchanged; empty string removes stored image. */
126
+ image?: string;
123
127
  instructions?: string;
124
128
  plugins?: PluginRef[];
125
129
  }) => Promise<void>;
@@ -9,7 +9,9 @@ import {
9
9
  VARIABLES_FILE,
10
10
  } from '../app/config.js';
11
11
  import fs from 'node:fs/promises';
12
+ import { readFileSync } from 'node:fs';
12
13
  import path from 'node:path';
14
+ import { fileURLToPath, pathToFileURL } from 'node:url';
13
15
  import crypto from 'node:crypto';
14
16
  import matter from 'gray-matter';
15
17
  import {
@@ -28,7 +30,6 @@ import { listBuiltInPlugins, parsePluginModule } from '../registry/plugins.js';
28
30
  import { OpenBotEvent, OpenBotState } from '../app/types.js';
29
31
  import { processService } from '../harness/process.js';
30
32
  import { memoryService } from './memory.js';
31
- import { pathToFileURL } from 'node:url';
32
33
 
33
34
  const resolveBaseDir = () => {
34
35
  const config = loadConfig();
@@ -40,6 +41,24 @@ const ENTITY_SVG_CANDIDATE_NAMES = ['avatar.svg', 'icon.svg', 'image.svg', 'logo
40
41
  const toSvgDataUrl = (svg: string) =>
41
42
  `data:image/svg+xml;base64,${Buffer.from(svg, 'utf-8').toString('base64')}`;
42
43
 
44
+ let bundledSystemAgentImage: string | undefined;
45
+ let bundledSystemAgentImageLoaded = false;
46
+
47
+ /** OpenBot mark from `src/assets/icon.svg` (also copied to `dist/assets` at build). */
48
+ function getBundledSystemAgentImage(): string | undefined {
49
+ if (bundledSystemAgentImageLoaded) return bundledSystemAgentImage;
50
+ bundledSystemAgentImageLoaded = true;
51
+ try {
52
+ const iconPath = path.join(path.dirname(fileURLToPath(import.meta.url)), '../assets/icon.svg');
53
+ const trimmed = readFileSync(iconPath, 'utf-8').trim();
54
+ if (!trimmed.startsWith('<svg')) return undefined;
55
+ bundledSystemAgentImage = toSvgDataUrl(trimmed);
56
+ } catch {
57
+ bundledSystemAgentImage = undefined;
58
+ }
59
+ return bundledSystemAgentImage;
60
+ }
61
+
43
62
  const tryReadSvgDataUrl = async (filePath: string): Promise<string | null> => {
44
63
  try {
45
64
  const svg = await fs.readFile(filePath, 'utf-8');
@@ -101,7 +120,7 @@ function getSystemAgentDetails(overrides?: Partial<AgentDetails>): AgentDetails
101
120
  const defaults: AgentDetails = {
102
121
  id: SYSTEM_AGENT_ID,
103
122
  name: 'OpenBot',
104
- image: undefined,
123
+ image: getBundledSystemAgentImage(),
105
124
  description:
106
125
  'First-party orchestration agent for OpenBot. Coordinates other agents via handoff.',
107
126
  instructions: AI_SDK_SYSTEM_PROMPT,
@@ -764,6 +783,10 @@ export const storageService = {
764
783
  const stats = await fs.stat(agentMdPath);
765
784
 
766
785
  const pluginRefs = parsePluginRefs(data.plugins);
786
+ const frontmatterImage =
787
+ typeof data.image === 'string' && data.image.trim() !== ''
788
+ ? data.image.trim()
789
+ : undefined;
767
790
 
768
791
  diskDetails = {
769
792
  id: agentId,
@@ -772,7 +795,7 @@ export const storageService = {
772
795
  plugins: pluginRefs.map((ref) => ref.id),
773
796
  pluginRefs,
774
797
  description: typeof data.description === 'string' ? data.description : '',
775
- image: discoveredImage || undefined,
798
+ image: frontmatterImage || discoveredImage || undefined,
776
799
  createdAt: stats.birthtime,
777
800
  updatedAt: stats.mtime,
778
801
  };
@@ -802,12 +825,14 @@ export const storageService = {
802
825
  agentId,
803
826
  name,
804
827
  description = '',
828
+ image,
805
829
  instructions,
806
830
  plugins,
807
831
  }: {
808
832
  agentId: string;
809
833
  name: string;
810
834
  description?: string;
835
+ image?: string;
811
836
  instructions: string;
812
837
  plugins: PluginRef[];
813
838
  }): Promise<void> => {
@@ -836,6 +861,9 @@ export const storageService = {
836
861
  description,
837
862
  plugins: serializePluginRefs(plugins),
838
863
  };
864
+ if (typeof image === 'string' && image.trim() !== '') {
865
+ data.image = image.trim();
866
+ }
839
867
 
840
868
  const body = matter.stringify(`${instructions.trim()}\n`, data);
841
869
  await fs.writeFile(agentMdPath, body, 'utf-8');
@@ -844,12 +872,14 @@ export const storageService = {
844
872
  agentId,
845
873
  name,
846
874
  description,
875
+ image,
847
876
  instructions,
848
877
  plugins,
849
878
  }: {
850
879
  agentId: string;
851
880
  name?: string;
852
881
  description?: string;
882
+ image?: string;
853
883
  instructions?: string;
854
884
  plugins?: PluginRef[];
855
885
  }): Promise<void> => {
@@ -874,6 +904,13 @@ export const storageService = {
874
904
  if (name !== undefined) nextData.name = name;
875
905
  if (description !== undefined) nextData.description = description;
876
906
  if (plugins !== undefined) nextData.plugins = serializePluginRefs(plugins);
907
+ if (image !== undefined) {
908
+ if (typeof image === 'string' && image.trim() !== '') {
909
+ nextData.image = image.trim();
910
+ } else {
911
+ delete nextData.image;
912
+ }
913
+ }
877
914
 
878
915
  const nextContent = instructions !== undefined ? instructions : parsed.content;
879
916
  const body = matter.stringify(`${String(nextContent).trim()}\n`, nextData);