openbot 0.1.28 → 0.2.0

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.
@@ -0,0 +1,35 @@
1
+ import { llmPlugin } from "../plugins/llm/index.js";
2
+ import { fileSystemToolDefinitions, fileSystemPlugin } from "../plugins/file-system/index.js";
3
+ import { DEFAULT_BASE_DIR, resolvePath } from "../config.js";
4
+ export const agentCreatorAgent = (options) => (builder) => {
5
+ const { model } = options;
6
+ const agentsDir = resolvePath(`${DEFAULT_BASE_DIR}/agents`);
7
+ builder
8
+ .use(fileSystemPlugin({ baseDir: agentsDir }))
9
+ .use(llmPlugin({
10
+ model,
11
+ system: `You are the OpenBot Agent Creator. Your job is to help users build custom OpenBot agents via natural language.
12
+
13
+ An OpenBot agent is defined by a folder in ${agentsDir} containing an \`agent.yaml\` file.
14
+
15
+ The YAML format is:
16
+ name: <slug-name>
17
+ description: <short description>
18
+ plugins:
19
+ - name: file-system
20
+ - name: shell
21
+ - name: browser # (if they need web access)
22
+ systemPrompt: |
23
+ <detailed instructions for the agent>
24
+
25
+ Your workflow:
26
+ 1. Ask the user what kind of agent they want to build (if they haven't provided enough detail).
27
+ 2. Suggest a name, description, required plugins, and a draft system prompt.
28
+ 3. Once the user approves, use the file-system tools to create the directory ${agentsDir}/<name> and write the \`agent.yaml\` file inside it.
29
+ 4. Tell the user they may need to restart the OpenBot server for the new agent to be registered.`,
30
+ toolDefinitions: fileSystemToolDefinitions, // Give it access to write files
31
+ promptInputType: "agent:agent-creator:input",
32
+ actionResultInputType: "agent:agent-creator:result",
33
+ completionEventType: "agent:agent-creator:output",
34
+ }));
35
+ };
@@ -0,0 +1,24 @@
1
+ export const logoSvg = `<svg width="251.2" height="58.1" viewBox="274.8 372.5 251.2 58.1" fill="none" 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="#FBFBFB"/>
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="#FDFDFD"/>
4
+ <path d="M281.646 408.631C281.747 408.754 281.848 408.878 281.952 409.005C282.539 409.504 282.848 409.488 283.612 409.49C283.86 409.493 284.107 409.495 284.363 409.498C284.77 409.496 284.77 409.496 285.185 409.494C285.614 409.497 285.614 409.497 286.052 409.499C287 409.504 287.948 409.504 288.897 409.504C289.554 409.507 290.211 409.511 290.868 409.515C292.778 409.525 294.688 409.53 296.598 409.534C299.194 409.54 301.79 409.55 304.385 409.564C305.356 409.568 306.327 409.569 307.298 409.569C307.891 409.572 308.483 409.575 309.076 409.577C309.348 409.577 309.619 409.576 309.899 409.575C310.27 409.578 310.27 409.578 310.65 409.581C310.973 409.581 310.973 409.581 311.302 409.582C311.854 409.646 311.854 409.646 312.615 410.154C312.775 411.523 312.491 412.391 311.856 413.595C311.778 413.744 311.7 413.893 311.62 414.046C311.457 414.358 311.292 414.669 311.125 414.979C310.869 415.455 310.619 415.934 310.369 416.413C309.14 418.745 309.14 418.745 308.554 419.038C308.706 418.045 309.012 417.295 309.49 416.413C309.625 416.159 309.761 415.906 309.9 415.644C310.187 415.115 310.474 414.585 310.761 414.056C310.897 413.802 311.032 413.549 311.172 413.287C311.296 413.057 311.421 412.828 311.549 412.591C311.851 411.937 312.021 411.375 312.108 410.662C311.703 410.257 311.283 410.375 310.722 410.374C310.355 410.373 310.355 410.373 309.981 410.371C309.711 410.371 309.44 410.372 309.161 410.372C308.878 410.371 308.595 410.37 308.303 410.369C307.686 410.367 307.069 410.366 306.452 410.365C305.476 410.363 304.5 410.359 303.524 410.354C300.748 410.341 297.972 410.329 295.197 410.325C293.501 410.323 291.805 410.315 290.11 410.304C289.462 410.301 288.815 410.3 288.167 410.3C287.262 410.301 286.358 410.295 285.453 410.288C285.184 410.29 284.915 410.292 284.638 410.294C282.825 410.27 282.825 410.27 281.979 409.67C281.646 409.138 281.646 409.138 281.646 408.631Z" fill="#CECECF"/>
5
+ <path d="M299.669 380.962C307.46 380.962 315.25 380.962 323.277 380.962C323.403 381.338 323.403 381.338 323.531 381.723C315.74 381.723 307.95 381.723 299.923 381.723C299.839 381.891 299.756 382.058 299.669 382.231C299.502 382.231 299.334 382.231 299.162 382.231C299.329 381.812 299.497 381.393 299.669 380.962Z" fill="#EEEFF0"/>
6
+ <path d="M285.708 419.292C285.833 419.334 285.959 419.375 286.088 419.417C286.977 419.598 287.857 419.581 288.76 419.579C288.965 419.579 289.169 419.58 289.38 419.58C290.055 419.581 290.73 419.581 291.404 419.58C291.873 419.58 292.343 419.58 292.812 419.581C293.794 419.581 294.777 419.58 295.76 419.579C297.02 419.578 298.281 419.579 299.541 419.58C300.51 419.581 301.478 419.581 302.446 419.58C302.911 419.58 303.376 419.58 303.841 419.581C304.49 419.581 305.139 419.58 305.788 419.579C306.077 419.58 306.077 419.58 306.372 419.581C307.168 419.577 307.792 419.546 308.554 419.292C308.386 419.627 308.219 419.962 308.046 420.308C305.246 420.325 302.446 420.339 299.646 420.347C298.346 420.351 297.045 420.357 295.745 420.365C294.491 420.373 293.237 420.378 291.983 420.38C291.504 420.381 291.025 420.384 290.546 420.388C289.876 420.394 289.206 420.394 288.536 420.394C288.238 420.398 288.238 420.398 287.933 420.402C286.589 420.395 286.589 420.395 285.959 419.937C285.708 419.546 285.708 419.546 285.708 419.292Z" fill="#DCDDDD"/>
7
+ <path d="M292.054 390.608C292.308 391.369 292.308 391.369 292.394 392.082C292.589 393.028 292.943 393.622 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.114 296.877 401.015C296.559 401.434 296.559 401.434 296.115 401.777C295.364 401.855 294.663 401.889 293.911 401.889C293.695 401.892 293.479 401.896 293.256 401.899C292.564 401.91 291.873 401.915 291.181 401.92C290.491 401.926 289.8 401.933 289.109 401.943C288.68 401.949 288.25 401.953 287.82 401.954C286.434 401.97 286.434 401.97 285.2 402.538C285.676 401.555 285.676 401.555 285.962 401.269C286.712 401.229 287.457 401.203 288.207 401.189C288.432 401.184 288.657 401.178 288.889 401.173C289.611 401.156 290.333 401.141 291.054 401.126C291.542 401.115 292.03 401.104 292.518 401.093C293.717 401.066 294.916 401.04 296.115 401.015C295.967 399.829 295.862 399.073 295.116 398.128C294.244 396.945 293.452 395.733 292.688 394.479C292.572 394.296 292.456 394.113 292.336 393.924C291.801 393.033 291.538 392.57 291.586 391.508C291.8 390.862 291.8 390.862 292.054 390.608Z" fill="#E9E9E9"/>
8
+ <path d="M292.054 390.608C292.308 391.369 292.308 391.369 292.394 392.082C292.59 393.028 292.943 393.622 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.636 399.517 296.785 400.144 296.877 401.015C296.709 401.015 296.542 401.015 296.369 401.015C296.227 400.588 296.227 400.588 296.083 400.152C295.591 398.842 294.864 397.723 294.101 396.557C291.535 392.593 291.535 392.593 291.594 391.528C291.8 390.862 291.8 390.862 292.054 390.608Z" fill="#E5E5E6"/>
9
+ <path d="M308.046 419.292C308.214 419.292 308.381 419.292 308.554 419.292C308.386 419.627 308.219 419.962 308.046 420.308C305.701 420.308 303.355 420.308 300.939 420.308C301.022 420.14 301.106 419.973 301.192 419.8C301.391 419.794 301.59 419.787 301.794 419.781C302.688 419.751 303.582 419.72 304.476 419.689C304.789 419.679 305.102 419.669 305.424 419.659C305.869 419.643 305.869 419.643 306.324 419.626C306.599 419.617 306.874 419.608 307.158 419.598C307.777 419.616 307.777 419.616 308.046 419.292Z" fill="#D9DADA"/>
10
+ <path d="M312.108 404.823C312.275 404.823 312.443 404.823 312.615 404.823C312.945 405.289 312.945 405.289 313.313 405.934C313.728 406.653 314.142 407.367 314.586 408.069C314.726 408.291 314.866 408.513 315.011 408.742C315.142 408.946 315.272 409.15 315.407 409.36C315.662 409.9 315.662 409.9 315.408 410.662C314.857 409.737 314.307 408.811 313.758 407.885C313.6 407.621 313.443 407.357 313.281 407.084C313.132 406.833 312.983 406.582 312.83 406.323C312.691 406.091 312.553 405.858 312.411 405.618C312.108 405.077 312.108 405.077 312.108 404.823Z" fill="#D6D6D6"/>
11
+ <path d="M282.408 413.708C283.269 413.995 283.314 414.085 283.726 414.839C283.873 415.106 283.873 415.106 284.023 415.378C284.174 415.658 284.174 415.658 284.327 415.945C284.429 416.129 284.53 416.313 284.634 416.502C285.093 417.34 285.538 418.182 285.962 419.038C285.045 418.733 284.978 418.53 284.515 417.714C284.391 417.498 284.268 417.282 284.14 417.06C284.014 416.833 283.887 416.607 283.756 416.373C283.627 416.146 283.497 415.919 283.363 415.686C282.408 414.005 282.408 414.005 282.408 413.708Z" fill="#DADADA"/>
12
+ <path d="M293.577 375.123C294.324 376.037 295.019 376.973 295.687 377.947C295.869 378.21 296.052 378.472 296.239 378.742C296.366 378.972 296.493 379.202 296.623 379.438C296.539 379.69 296.456 379.941 296.369 380.2C295.93 379.576 295.492 378.95 295.055 378.324C294.789 377.944 294.522 377.565 294.248 377.19C293.682 376.397 293.577 376.145 293.577 375.123Z" fill="#CFCFCF"/>
13
+ <path d="M294.338 396.192C295.519 397.554 296.877 399.171 296.877 401.015C296.709 401.015 296.542 401.015 296.369 401.015C296.27 400.722 296.17 400.429 296.068 400.127C295.696 399.122 295.195 398.282 294.589 397.401C294.338 396.954 294.338 396.954 294.338 396.192Z" fill="#D2D3D3"/>
14
+ <path d="M299.669 380.962C300.926 380.962 302.182 380.962 303.477 380.962C303.393 381.129 303.309 381.297 303.223 381.469C302.369 381.57 301.52 381.598 300.661 381.636C300.417 381.665 300.174 381.693 299.923 381.723C299.839 381.891 299.756 382.058 299.669 382.231C299.502 382.231 299.334 382.231 299.162 382.231C299.329 381.812 299.497 381.393 299.669 380.962Z" fill="#E9EAEA"/>
15
+ <path d="M288.754 375.377C288.838 375.544 288.921 375.712 289.008 375.885C288.692 376.507 288.366 377.096 288.008 377.693C287.91 377.86 287.812 378.028 287.711 378.2C287.468 378.614 287.223 379.026 286.977 379.438C286.893 379.187 286.809 378.936 286.723 378.677C287.036 378.082 287.356 377.539 287.723 376.979C287.821 376.825 287.919 376.671 288.02 376.513C288.262 376.133 288.508 375.755 288.754 375.377Z" fill="#D8D8D9"/>
16
+ <path d="M308.046 419.292C308.214 419.292 308.381 419.292 308.554 419.292C308.386 419.627 308.219 419.962 308.046 420.308C307.208 420.308 306.371 420.308 305.508 420.308C305.508 420.14 305.508 419.973 305.508 419.8C305.751 419.777 305.751 419.777 305.999 419.753C306.313 419.721 306.313 419.721 306.634 419.689C306.843 419.668 307.052 419.648 307.268 419.626C307.789 419.6 307.789 419.6 308.046 419.292Z" fill="#D0D0D0"/>
17
+ <path d="M286.215 379.692C286.383 379.692 286.55 379.692 286.723 379.692C286.215 380.708 285.708 381.723 285.2 382.738C285.032 382.738 284.865 382.738 284.692 382.738C285.09 381.645 285.627 380.692 286.215 379.692Z" fill="#D0D0D0"/>
18
+ <path d="M284.438 382.992C284.606 382.992 284.774 382.992 284.946 382.992C284.549 384.086 284.011 385.039 283.423 386.038C283.256 385.955 283.088 385.871 282.915 385.785C283.418 384.863 283.921 383.942 284.438 382.992Z" fill="#DDDDDE"/>
19
+ <path d="M312.108 404.823C312.275 404.823 312.443 404.823 312.615 404.823C312.943 405.249 312.943 405.249 313.282 405.807C313.452 406.081 313.452 406.081 313.625 406.36C313.885 406.854 313.885 406.854 313.885 407.362C313.717 407.362 313.55 407.362 313.377 407.362C312.958 406.524 312.539 405.686 312.108 404.823Z" fill="#E0E0E1"/>
20
+ <path d="M291.546 372.838C292.442 372.991 292.538 373.061 293.133 373.838C293.577 374.615 293.577 374.615 293.577 375.123C293.409 375.123 293.242 375.123 293.069 375.123C292.686 374.623 292.686 374.623 292.276 373.981C292.139 373.769 292.002 373.557 291.861 373.338C291.757 373.173 291.653 373.008 291.546 372.838Z" fill="#CFCFCF"/>
21
+ <path d="M293.069 394.162C293.583 394.652 293.938 395.083 294.338 395.685C294.243 396.24 294.243 396.24 294.085 396.7C293.069 395.018 293.069 395.018 293.069 394.162Z" fill="#DEDEDE"/>
22
+ <path d="M295.1 378.169C295.902 378.517 296.114 378.674 296.623 379.438C296.539 379.69 296.456 379.941 296.369 380.2C296.157 379.91 295.946 379.619 295.735 379.327C295.617 379.165 295.499 379.003 295.378 378.837C295.1 378.423 295.1 378.423 295.1 378.169Z" fill="#E1E3E2"/>
23
+ <path d="M374.92 414.2C372.92 414.2 371.107 413.8 369.48 413C367.853 412.2 366.44 411.12 365.24 409.76C364.067 408.373 363.16 406.827 362.52 405.12C361.88 403.387 361.56 401.613 361.56 399.8C361.56 397.907 361.893 396.107 362.56 394.4C363.253 392.667 364.2 391.133 365.4 389.8C366.627 388.44 368.053 387.373 369.68 386.6C371.307 385.8 373.08 385.4 375 385.4C377 385.4 378.813 385.813 380.44 386.64C382.067 387.467 383.467 388.573 384.64 389.96C385.813 391.347 386.72 392.893 387.36 394.6C388 396.307 388.32 398.053 388.32 399.84C388.32 401.733 387.987 403.547 387.32 405.28C386.653 406.987 385.707 408.52 384.48 409.88C383.28 411.213 381.867 412.267 380.24 413.04C378.613 413.813 376.84 414.2 374.92 414.2ZM365.2 399.8C365.2 401.24 365.427 402.64 365.88 404C366.36 405.333 367.027 406.52 367.88 407.56C368.733 408.6 369.76 409.427 370.96 410.04C372.16 410.653 373.493 410.96 374.96 410.96C376.48 410.96 377.84 410.64 379.04 410C380.24 409.36 381.253 408.507 382.08 407.44C382.933 406.373 383.573 405.173 384 403.84C384.453 402.507 384.68 401.16 384.68 399.8C384.68 398.36 384.44 396.973 383.96 395.64C383.507 394.307 382.84 393.12 381.96 392.08C381.107 391.013 380.08 390.187 378.88 389.6C377.707 388.987 376.4 388.68 374.96 388.68C373.44 388.68 372.08 389 370.88 389.64C369.68 390.253 368.653 391.093 367.8 392.16C366.973 393.227 366.333 394.427 365.88 395.76C365.427 397.067 365.2 398.413 365.2 399.8ZM403.807 414.4C402.1 414.4 400.58 413.973 399.247 413.12C397.913 412.267 396.86 411.187 396.087 409.88V422.52H392.567V393.12H395.687V397.04C396.513 395.76 397.593 394.733 398.927 393.96C400.26 393.16 401.713 392.76 403.287 392.76C404.727 392.76 406.047 393.053 407.247 393.64C408.447 394.227 409.487 395.027 410.367 396.04C411.247 397.053 411.927 398.213 412.407 399.52C412.913 400.8 413.167 402.147 413.167 403.56C413.167 405.533 412.767 407.347 411.967 409C411.193 410.653 410.1 411.973 408.687 412.96C407.273 413.92 405.647 414.4 403.807 414.4ZM402.727 411.36C403.767 411.36 404.7 411.147 405.527 410.72C406.38 410.267 407.1 409.68 407.687 408.96C408.3 408.213 408.767 407.373 409.087 406.44C409.407 405.507 409.567 404.547 409.567 403.56C409.567 402.52 409.38 401.533 409.007 400.6C408.66 399.667 408.153 398.84 407.487 398.12C406.847 397.4 406.087 396.84 405.207 396.44C404.353 396.013 403.42 395.8 402.407 395.8C401.767 395.8 401.1 395.92 400.407 396.16C399.74 396.4 399.1 396.747 398.487 397.2C397.873 397.627 397.353 398.12 396.927 398.68C396.5 399.24 396.22 399.84 396.087 400.48V406.44C396.487 407.347 397.02 408.173 397.687 408.92C398.353 409.667 399.127 410.267 400.007 410.72C400.887 411.147 401.793 411.36 402.727 411.36ZM426.728 414.4C425.155 414.4 423.715 414.12 422.408 413.56C421.128 412.973 420.008 412.187 419.048 411.2C418.115 410.187 417.382 409.027 416.848 407.72C416.342 406.413 416.088 405.027 416.088 403.56C416.088 401.587 416.542 399.787 417.448 398.16C418.355 396.533 419.608 395.227 421.208 394.24C422.835 393.253 424.688 392.76 426.768 392.76C428.875 392.76 430.702 393.267 432.248 394.28C433.822 395.267 435.035 396.573 435.888 398.2C436.768 399.8 437.208 401.533 437.208 403.4C437.208 403.667 437.195 403.933 437.168 404.2C437.168 404.44 437.155 404.627 437.128 404.76H419.808C419.915 406.12 420.288 407.333 420.928 408.4C421.595 409.44 422.448 410.267 423.488 410.88C424.528 411.467 425.648 411.76 426.848 411.76C428.128 411.76 429.328 411.44 430.448 410.8C431.595 410.16 432.382 409.32 432.808 408.28L435.848 409.12C435.395 410.133 434.715 411.04 433.808 411.84C432.928 412.64 431.875 413.267 430.648 413.72C429.448 414.173 428.142 414.4 426.728 414.4ZM419.688 402.32H433.928C433.822 400.96 433.435 399.76 432.768 398.72C432.102 397.68 431.248 396.867 430.208 396.28C429.168 395.693 428.022 395.4 426.768 395.4C425.542 395.4 424.408 395.693 423.368 396.28C422.328 396.867 421.475 397.68 420.808 398.72C420.168 399.76 419.795 400.96 419.688 402.32ZM459.241 414H455.721V402.32C455.721 400.107 455.375 398.493 454.681 397.48C454.015 396.44 452.988 395.92 451.601 395.92C450.641 395.92 449.681 396.16 448.721 396.64C447.788 397.12 446.948 397.773 446.201 398.6C445.481 399.4 444.961 400.333 444.641 401.4V414H441.121V393.12H444.321V397.6C444.881 396.613 445.601 395.76 446.481 395.04C447.361 394.32 448.361 393.76 449.481 393.36C450.601 392.96 451.775 392.76 453.001 392.76C454.201 392.76 455.201 392.987 456.001 393.44C456.828 393.867 457.468 394.48 457.921 395.28C458.401 396.053 458.735 396.973 458.921 398.04C459.135 399.107 459.241 400.267 459.241 401.52V414ZM487.075 406.68C487.075 408.147 486.702 409.427 485.955 410.52C485.208 411.613 484.195 412.467 482.915 413.08C481.662 413.693 480.275 414 478.755 414H465.275V385.6H479.395C480.728 385.6 481.875 385.96 482.835 386.68C483.822 387.373 484.568 388.28 485.075 389.4C485.608 390.493 485.875 391.64 485.875 392.84C485.875 394.227 485.515 395.533 484.795 396.76C484.102 397.96 483.102 398.853 481.795 399.44C483.422 399.92 484.702 400.813 485.635 402.12C486.595 403.4 487.075 404.92 487.075 406.68ZM483.435 406.04C483.435 405.16 483.235 404.347 482.835 403.6C482.462 402.853 481.942 402.253 481.275 401.8C480.635 401.347 479.888 401.12 479.035 401.12H468.875V410.88H478.755C479.635 410.88 480.422 410.653 481.115 410.2C481.835 409.747 482.395 409.16 482.795 408.44C483.222 407.693 483.435 406.893 483.435 406.04ZM468.875 388.72V398.2H477.915C478.768 398.2 479.515 397.987 480.155 397.56C480.822 397.133 481.342 396.56 481.715 395.84C482.115 395.12 482.315 394.333 482.315 393.48C482.315 392.573 482.128 391.773 481.755 391.08C481.408 390.36 480.915 389.787 480.275 389.36C479.662 388.933 478.955 388.72 478.155 388.72H468.875ZM500.671 414.4C499.098 414.4 497.671 414.12 496.391 413.56C495.111 412.973 494.004 412.187 493.071 411.2C492.138 410.187 491.418 409.027 490.911 407.72C490.404 406.413 490.151 405.04 490.151 403.6C490.151 402.133 490.404 400.747 490.911 399.44C491.418 398.133 492.138 396.987 493.071 396C494.004 394.987 495.111 394.2 496.391 393.64C497.698 393.053 499.124 392.76 500.671 392.76C502.244 392.76 503.671 393.053 504.951 393.64C506.231 394.2 507.338 394.987 508.271 396C509.231 396.987 509.964 398.133 510.471 399.44C510.978 400.747 511.231 402.133 511.231 403.6C511.231 405.04 510.978 406.413 510.471 407.72C509.964 409.027 509.244 410.187 508.311 411.2C507.378 412.187 506.258 412.973 504.951 413.56C503.671 414.12 502.244 414.4 500.671 414.4ZM493.751 403.64C493.751 405.08 494.058 406.387 494.671 407.56C495.311 408.733 496.151 409.667 497.191 410.36C498.231 411.027 499.391 411.36 500.671 411.36C501.951 411.36 503.111 411.013 504.151 410.32C505.218 409.627 506.058 408.693 506.671 407.52C507.311 406.32 507.631 405 507.631 403.56C507.631 402.12 507.311 400.813 506.671 399.64C506.058 398.467 505.218 397.533 504.151 396.84C503.111 396.147 501.951 395.8 500.671 395.8C499.391 395.8 498.231 396.16 497.191 396.88C496.151 397.573 495.311 398.507 494.671 399.68C494.058 400.853 493.751 402.173 493.751 403.64ZM525.984 412.96C525.69 413.093 525.29 413.267 524.784 413.48C524.277 413.693 523.69 413.88 523.024 414.04C522.357 414.2 521.65 414.28 520.904 414.28C520.05 414.28 519.264 414.133 518.544 413.84C517.824 413.52 517.25 413.04 516.824 412.4C516.397 411.733 516.184 410.907 516.184 409.92V395.88H513.344V393.12H516.184V386.16H519.704V393.12H524.384V395.88H519.704V408.84C519.757 409.587 520.01 410.147 520.464 410.52C520.917 410.867 521.45 411.04 522.064 411.04C522.757 411.04 523.397 410.92 523.984 410.68C524.57 410.44 524.957 410.267 525.144 410.16L525.984 412.96Z" fill="white"/>
24
+ </svg>`;
package/dist/cli.js CHANGED
@@ -13,7 +13,7 @@ const program = new Command();
13
13
  program
14
14
  .name("openbot")
15
15
  .description("OpenBot CLI - Secure and easy configuration")
16
- .version("0.1.28");
16
+ .version("0.1.29");
17
17
  /**
18
18
  * Check if a GitHub repository exists.
19
19
  */
package/dist/config.js CHANGED
@@ -24,6 +24,10 @@ export function saveConfig(config) {
24
24
  const newConfig = { ...currentConfig, ...config };
25
25
  fs.writeFileSync(configPath, JSON.stringify(newConfig, null, 2), { mode: 0o600 });
26
26
  }
27
+ export function isConfigured() {
28
+ const configPath = path.join(os.homedir(), ".openbot", "config.json");
29
+ return fs.existsSync(configPath);
30
+ }
27
31
  export function resolvePath(p) {
28
32
  return p.startsWith("~/") ? path.join(os.homedir(), p.slice(2)) : path.resolve(p);
29
33
  }
@@ -0,0 +1,132 @@
1
+ import { loadConfig } from "./config.js";
2
+ import { FALLBACK_MODELS } from "./model-defaults.js";
3
+ const CACHE_TTL_MS = 5 * 60 * 1000;
4
+ let cachedCatalog = null;
5
+ let cachedAt = 0;
6
+ let cachedFingerprint = "";
7
+ function keyFingerprint(value) {
8
+ if (!value)
9
+ return "none";
10
+ const trimmed = value.trim();
11
+ if (!trimmed)
12
+ return "none";
13
+ return `${trimmed.slice(0, 4)}:${trimmed.length}`;
14
+ }
15
+ function buildFingerprint(input) {
16
+ return [
17
+ `openai=${keyFingerprint(input.openaiApiKey)}`,
18
+ `anthropic=${keyFingerprint(input.anthropicApiKey)}`,
19
+ `model=${input.model ?? ""}`,
20
+ ].join("|");
21
+ }
22
+ function titleCaseModel(raw) {
23
+ return raw
24
+ .split("-")
25
+ .map((part) => (part ? part[0].toUpperCase() + part.slice(1) : part))
26
+ .join(" ");
27
+ }
28
+ function toProviderModel(provider, modelId) {
29
+ const id = `${provider}/${modelId}`;
30
+ const providerLabel = provider === "openai" ? "OpenAI" : "Anthropic";
31
+ return { id, label: `${providerLabel} ${titleCaseModel(modelId)}` };
32
+ }
33
+ function dedupeModels(models) {
34
+ const seen = new Set();
35
+ const deduped = [];
36
+ for (const model of models) {
37
+ if (seen.has(model.id))
38
+ continue;
39
+ seen.add(model.id);
40
+ deduped.push(model);
41
+ }
42
+ return deduped;
43
+ }
44
+ function sortModels(models) {
45
+ return [...models].sort((a, b) => a.id.localeCompare(b.id));
46
+ }
47
+ function keepLikelyOpenAIChatModel(modelId) {
48
+ return /^(gpt|o[1-9]|chatgpt)/.test(modelId);
49
+ }
50
+ async function fetchOpenAIModels(apiKey) {
51
+ const res = await fetch("https://api.openai.com/v1/models", {
52
+ headers: {
53
+ Authorization: `Bearer ${apiKey}`,
54
+ },
55
+ });
56
+ if (!res.ok) {
57
+ throw new Error(`OpenAI models request failed (${res.status})`);
58
+ }
59
+ const data = await res.json();
60
+ const models = (data.data ?? [])
61
+ .map((m) => (typeof m.id === "string" ? m.id : ""))
62
+ .filter((id) => !!id && keepLikelyOpenAIChatModel(id))
63
+ .map((id) => toProviderModel("openai", id));
64
+ return sortModels(dedupeModels(models));
65
+ }
66
+ async function fetchAnthropicModels(apiKey) {
67
+ const res = await fetch("https://api.anthropic.com/v1/models", {
68
+ headers: {
69
+ "x-api-key": apiKey,
70
+ "anthropic-version": "2023-06-01",
71
+ },
72
+ });
73
+ if (!res.ok) {
74
+ throw new Error(`Anthropic models request failed (${res.status})`);
75
+ }
76
+ const data = await res.json();
77
+ const models = (data.data ?? [])
78
+ .map((m) => {
79
+ const modelId = typeof m.id === "string" ? m.id : "";
80
+ if (!modelId)
81
+ return null;
82
+ const label = typeof m.display_name === "string" && m.display_name.trim()
83
+ ? m.display_name.trim()
84
+ : toProviderModel("anthropic", modelId).label;
85
+ return { id: `anthropic/${modelId}`, label };
86
+ })
87
+ .filter((m) => !!m);
88
+ return sortModels(dedupeModels(models));
89
+ }
90
+ export async function fetchProviderModels(provider, apiKey) {
91
+ if (provider === "openai") {
92
+ return fetchOpenAIModels(apiKey);
93
+ }
94
+ return fetchAnthropicModels(apiKey);
95
+ }
96
+ export async function getModelCatalog(forceRefresh = false) {
97
+ const cfg = loadConfig();
98
+ const openaiApiKey = cfg.openaiApiKey || process.env.OPENAI_API_KEY;
99
+ const anthropicApiKey = cfg.anthropicApiKey || process.env.ANTHROPIC_API_KEY;
100
+ const now = Date.now();
101
+ const fingerprint = buildFingerprint({
102
+ openaiApiKey,
103
+ anthropicApiKey,
104
+ model: cfg.model,
105
+ });
106
+ if (!forceRefresh &&
107
+ cachedCatalog &&
108
+ now - cachedAt < CACHE_TTL_MS &&
109
+ cachedFingerprint === fingerprint) {
110
+ return cachedCatalog;
111
+ }
112
+ const providerFetches = [];
113
+ if (openaiApiKey) {
114
+ providerFetches.push(fetchOpenAIModels(openaiApiKey));
115
+ }
116
+ if (anthropicApiKey) {
117
+ providerFetches.push(fetchAnthropicModels(anthropicApiKey));
118
+ }
119
+ const results = await Promise.allSettled(providerFetches);
120
+ const fetched = results
121
+ .filter((r) => r.status === "fulfilled")
122
+ .flatMap((r) => r.value);
123
+ const merged = dedupeModels([...fetched, ...FALLBACK_MODELS]);
124
+ if (cfg.model && !merged.some((m) => m.id === cfg.model)) {
125
+ merged.push({ id: cfg.model, label: cfg.model });
126
+ }
127
+ const catalog = sortModels(merged);
128
+ cachedCatalog = catalog;
129
+ cachedAt = now;
130
+ cachedFingerprint = fingerprint;
131
+ return catalog;
132
+ }
@@ -0,0 +1,20 @@
1
+ export const DEFAULT_MODEL_ID = "openai/gpt-5-nano";
2
+ export const DEFAULT_MODEL_BY_PROVIDER = {
3
+ openai: DEFAULT_MODEL_ID,
4
+ anthropic: "anthropic/claude-sonnet-4-5-20250929",
5
+ };
6
+ export const FALLBACK_MODELS = [
7
+ { id: "openai/gpt-5", label: "OpenAI GPT-5" },
8
+ { id: "openai/gpt-5-mini", label: "OpenAI GPT-5 Mini" },
9
+ { id: "openai/gpt-5-nano", label: "OpenAI GPT-5 Nano" },
10
+ { id: "openai/gpt-4.1", label: "OpenAI GPT-4.1" },
11
+ { id: "openai/gpt-4.1-mini", label: "OpenAI GPT-4.1 Mini" },
12
+ { id: "openai/gpt-4o", label: "OpenAI GPT-4o" },
13
+ { id: "openai/gpt-4o-mini", label: "OpenAI GPT-4o Mini" },
14
+ { id: "openai/o4-mini", label: "OpenAI o4-mini" },
15
+ { id: "anthropic/claude-opus-4-5-20251101", label: "Claude Opus 4.5" },
16
+ { id: "anthropic/claude-sonnet-4-5-20250929", label: "Claude Sonnet 4.5" },
17
+ { id: "anthropic/claude-3-7-sonnet-latest", label: "Claude 3.7 Sonnet" },
18
+ { id: "anthropic/claude-3-5-sonnet-latest", label: "Claude 3.5 Sonnet" },
19
+ { id: "anthropic/claude-3-5-haiku-latest", label: "Claude 3.5 Haiku" },
20
+ ];
package/dist/models.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { openai } from "@ai-sdk/openai";
2
2
  import { anthropic } from "@ai-sdk/anthropic";
3
3
  import { loadConfig } from "./config.js";
4
+ import { DEFAULT_MODEL_ID } from "./model-defaults.js";
4
5
  /**
5
6
  * Parse model string to extract provider and model ID
6
7
  * Supports formats: "provider/model" or just "model" (defaults to openai)
@@ -30,7 +31,7 @@ export function createModel(options) {
30
31
  if (anthropicKey) {
31
32
  process.env.ANTHROPIC_API_KEY = anthropicKey;
32
33
  }
33
- const { provider, modelId } = parseModelString(options?.model || config.model || "gpt-4o-mini");
34
+ const { provider, modelId } = parseModelString(options?.model || config.model || DEFAULT_MODEL_ID);
34
35
  if (provider === "anthropic") {
35
36
  if (!anthropicKey) {
36
37
  console.warn("Warning: Anthropic model selected but ANTHROPIC_API_KEY is not set");
package/dist/open-bot.js CHANGED
@@ -1,38 +1,36 @@
1
- import { melony } from "melony";
2
1
  import { osAgent } from "./agents/os-agent.js";
3
2
  import { topicAgent } from "./agents/topic-agent.js";
3
+ import { agentCreatorAgent } from "./agents/agent-creator.js";
4
4
  import { brainPlugin, brainToolDefinitions, createBrainPromptBuilder } from "./plugins/brain/index.js";
5
5
  import { llmPlugin } from "./plugins/llm/index.js";
6
- import { initHandler } from "./handlers/init.js";
7
- import { sessionChangeHandler } from "./handlers/session-change.js";
8
- import { tabChangeHandler } from "./handlers/tab-change.js";
9
- import { updateSettingsHandler, openAgentFolderHandler } from "./handlers/settings.js";
10
6
  import { loadConfig, resolvePath, DEFAULT_BASE_DIR } from "./config.js";
11
- import { createModel } from "./models.js";
7
+ import { createModel, parseModelString } from "./models.js";
8
+ import { DEFAULT_MODEL_ID } from "./model-defaults.js";
12
9
  import path from "node:path";
13
10
  import { z } from "zod";
14
- // Plugin imports for the registry
15
11
  import { shellPlugin, shellToolDefinitions } from "./plugins/shell/index.js";
16
12
  import { fileSystemPlugin, fileSystemToolDefinitions } from "./plugins/file-system/index.js";
17
13
  import { approvalPlugin } from "./plugins/approval/index.js";
18
- // Registry
19
- import { PluginRegistry, AgentRegistry, discoverYamlAgents, loadPluginsFromDir } from "./registry/index.js";
14
+ import { PluginRegistry, AgentRegistry, discoverYamlAgents, discoverTsAgents, loadPluginsFromDir } from "./registry/index.js";
15
+ import { Orchestrator } from "./orchestrator.js";
20
16
  /**
21
- * Create the OpenBot manager agent.
17
+ * Create the OpenBot orchestrator.
22
18
  *
23
19
  * Architecture:
24
- * 1. Built-in plugins are registered in the Plugin Registry so YAML agents can reference them by name.
25
- * 2. Built-in agents + YAML agents discovered from ~/.openbot/agents/ are registered in the Agent Registry.
26
- * 3. The manager LLM gets a dynamically-built `delegateTask` tool listing all registered agents.
27
- * 4. A generic delegation handler + bridge-back wiring replaces per-agent boilerplate.
20
+ * 1. Each agent gets its own isolated melony runtime (no shared handlers or state).
21
+ * 2. The manager has its own runtime with brain tools and a delegateTask tool.
22
+ * 3. The Orchestrator routes events between manager and agent runtimes.
23
+ * 4. Plugins are only instantiated within the runtime that needs them — no duplication.
28
24
  */
29
25
  export async function createOpenBot(options) {
30
26
  const config = loadConfig();
31
27
  const baseDir = config.baseDir || DEFAULT_BASE_DIR;
32
28
  const resolvedBaseDir = resolvePath(baseDir);
29
+ const configuredModel = config.model || DEFAULT_MODEL_ID;
30
+ const { provider, modelId } = parseModelString(configuredModel);
31
+ const resolvedModelId = `${provider}/${modelId}`;
33
32
  const model = createModel(options);
34
33
  // ─── Plugin Registry ─────────────────────────────────────────────
35
- // Register built-in plugins so YAML agents can reference them by name.
36
34
  const pluginRegistry = new PluginRegistry();
37
35
  pluginRegistry.register({
38
36
  name: "shell",
@@ -53,74 +51,43 @@ export async function createOpenBot(options) {
53
51
  factory: (options) => approvalPlugin(options),
54
52
  });
55
53
  // ─── Shared Plugins ──────────────────────────────────────────────
56
- // Load community/user plugins from ~/.openbot/plugins/
57
54
  const sharedPlugins = await loadPluginsFromDir(path.join(resolvedBaseDir, "plugins"));
58
55
  for (const p of sharedPlugins) {
59
56
  pluginRegistry.register(p);
60
57
  console.log(`[plugins] Loaded shared plugin: ${p.name}`);
61
58
  }
62
59
  // ─── Agent Registry ──────────────────────────────────────────────
63
- // Register built-in agents, then discover YAML agents from ~/.openbot/agents/.
64
60
  const agentRegistry = new AgentRegistry();
65
61
  agentRegistry.register({
66
62
  name: "os",
67
63
  description: "Handles shell commands and file system operations",
68
64
  capabilities: {
69
65
  ...Object.fromEntries(Object.entries(shellToolDefinitions).map(([k, v]) => [k, v.description])),
70
- ...Object.fromEntries(Object.entries(fileSystemToolDefinitions).map(([k, v]) => [
71
- k,
72
- v.description,
73
- ])),
66
+ ...Object.fromEntries(Object.entries(fileSystemToolDefinitions).map(([k, v]) => [k, v.description])),
74
67
  },
75
68
  plugin: osAgent({ model: model }),
76
69
  });
77
70
  agentRegistry.register({
78
- name: "topic",
79
- description: "Automatically titles threads",
80
- plugin: topicAgent({ model: model }),
81
- subscribe: ["manager:completion"],
71
+ name: "agent-creator",
72
+ description: "Helps the user create and configure new custom OpenBot agents via natural language.",
73
+ capabilities: {
74
+ ...Object.fromEntries(Object.entries(fileSystemToolDefinitions).map(([k, v]) => [k, v.description])),
75
+ },
76
+ plugin: agentCreatorAgent({ model: model }),
82
77
  });
83
78
  // Discover community / user agents from ~/.openbot/agents/
84
- const yamlAgents = await discoverYamlAgents(path.join(resolvedBaseDir, "agents"), pluginRegistry, model, options);
85
- for (const agent of yamlAgents) {
79
+ const agentsDir = path.join(resolvedBaseDir, "agents");
80
+ const [yamlAgents, tsAgents] = await Promise.all([
81
+ discoverYamlAgents(agentsDir, pluginRegistry, model, options),
82
+ discoverTsAgents(agentsDir, model, options),
83
+ ]);
84
+ for (const agent of [...yamlAgents, ...tsAgents]) {
86
85
  agentRegistry.register(agent);
87
86
  }
88
- // ─── Compose the Melony App ──────────────────────────────────────
87
+ // ─── Build Orchestrator ──────────────────────────────────────────
89
88
  const allAgents = agentRegistry.getAll();
90
89
  const agentNames = agentRegistry.getNames();
91
- const app = melony();
92
- // 1. Register all agent plugins
93
- for (const agent of allAgents) {
94
- app.use(agent.plugin);
95
- // Choreography bridge: Auto-wire subscriptions
96
- if (agent.subscribe) {
97
- for (const eventType of agent.subscribe) {
98
- app.on(eventType, async function* (event, { state }) {
99
- // Avoid self-triggering if the event has agent meta
100
- if (event.meta?.agent === agent.name)
101
- return;
102
- yield {
103
- type: `agent:${agent.name}:input`,
104
- data: {
105
- content: `Event observed: ${event.type}\nData: ${JSON.stringify(event.data)}`,
106
- },
107
- meta: {
108
- background: true,
109
- agent: agent.name
110
- },
111
- };
112
- });
113
- }
114
- }
115
- }
116
- // 2. Register global plugins (brain, UI, etc.)
117
90
  const buildBrainPrompt = createBrainPromptBuilder(baseDir);
118
- app
119
- .use(brainPlugin({
120
- baseDir: resolvedBaseDir,
121
- allowSoulModification: false,
122
- }));
123
- // 3. Build dynamic delegation tool from the agent registry
124
91
  const agentDescriptions = allAgents
125
92
  .map((a) => {
126
93
  const tools = a.capabilities
@@ -128,80 +95,80 @@ export async function createOpenBot(options) {
128
95
  .map(([name, desc]) => ` - ${name}: ${desc}`)
129
96
  .join("\n")
130
97
  : "";
131
- return `- **${a.name}**: ${a.description}${tools ? `\n Capabilities:\n${tools}` : ""}`;
98
+ return `<agent name="${a.name}">
99
+ <description>${a.description}</description>
100
+ ${tools ? ` <capabilities>\n${tools}\n </capabilities>` : ""}
101
+ </agent>`;
132
102
  })
133
103
  .join("\n\n");
134
- app.use(llmPlugin({
135
- model: model,
136
- system: async (context) => {
137
- const [brainPrompt] = await Promise.all([
138
- buildBrainPrompt(context),
139
- ]);
140
- return `${brainPrompt}
104
+ // The manager plugin composes brain, topic, and the manager LLM
105
+ const managerPlugin = (builder) => {
106
+ builder
107
+ .use(brainPlugin({
108
+ baseDir: resolvedBaseDir,
109
+ allowSoulModification: false,
110
+ }))
111
+ .use(topicAgent({ model: model }))
112
+ .use(llmPlugin({
113
+ model: model,
114
+ modelId: resolvedModelId,
115
+ usageScope: "manager",
116
+ system: async (context) => {
117
+ const brainPrompt = await buildBrainPrompt(context);
118
+ return `${brainPrompt}
141
119
 
142
- ## Delegation & Specialized Agents
143
- You are the **Manager Agent**. Your primary role is to orchestrate tasks by delegating them to specialized agents when appropriate.
144
- If a task falls outside your core capabilities (memory and orchestration), you **MUST** use the \`delegateTask\` tool.
120
+ <manager_core>
121
+ <role>
122
+ Your role is to be the central orchestrator of this system. Your primary goal is to solve user requests by managing your persistent memory and delegating tasks to expert sub-agents.
123
+ </role>
145
124
 
146
- ### Available Agents:
147
- ${agentDescriptions}
125
+ <operating_principles>
126
+ 1. **Delegate by Default**: If a task requires specialized expertise (shell, files, browser, etc.), you **must** delegate to an expert agent via \`delegateTask\`.
127
+ 2. **Context-Rich Delegation**: When calling \`delegateTask\`, provide a thorough, context-rich task description so the sub-agent can work independently. If the user included attachments, pass them through \`attachments\`.
128
+ 3. **Concise Reporting**: After a sub-agent finishes, provide a high-level, concise summary to the user. Do not repeat technical details unless requested.
129
+ 4. **Memory Management**: Use your brain tools (\`remember\`, \`recall\`, \`journal\`, etc.) to maintain continuity and preferences across sessions.
130
+ </operating_principles>
131
+ </manager_core>
148
132
 
149
- ### Delegation Guidelines:
150
- 1. **Choose the Best Expert**: Analyze the user's request and select the agent whose description most closely matches the required expertise.
151
- 2. **Task Description**: When delegating, provide a clear and detailed task description. Include any context the agent might need to succeed.
152
- 3. **No "I Can't"**: If an agent is available that can handle a request, do not tell the user you cannot do it. Simply delegate.
153
- 4. **Summary**: Once an agent returns a result, summarize the findings or actions for the user.
133
+ <specialized_agents>
134
+ ${agentDescriptions}
135
+ </specialized_agents>
154
136
 
155
- Example: If the user asks to "check the weather", and you see a 'browser' agent, delegate the task to it.`;
156
- },
157
- completionEventType: "manager:completion",
158
- toolDefinitions: {
159
- ...brainToolDefinitions,
160
- delegateTask: {
161
- description: `Delegate a specialized task to another agent. Use this whenever a task matches the capabilities of one of the available agents.`,
162
- inputSchema: z.object({
163
- agent: z.enum(agentNames).describe("The specialized agent to use"),
164
- task: z.string().describe("The detailed task description for the agent"),
165
- }),
137
+ <final_guidance>
138
+ Always remain professional and efficient. You manage the big picture; let the agents do the work.
139
+ </final_guidance>`;
166
140
  },
167
- },
141
+ promptInputType: "manager:input",
142
+ actionResultInputType: "manager:result",
143
+ completionEventType: "manager:completion",
144
+ toolDefinitions: {
145
+ ...brainToolDefinitions,
146
+ delegateTask: {
147
+ description: `Delegate a specialized task to another agent. Use this whenever a task matches the capabilities of one of the available agents.`,
148
+ inputSchema: z.object({
149
+ agent: z.enum(agentNames).describe("The specialized agent to use"),
150
+ task: z.string().describe("The detailed task description for the agent"),
151
+ attachments: z.array(z.object({
152
+ id: z.string(),
153
+ name: z.string(),
154
+ mimeType: z.string(),
155
+ size: z.number(),
156
+ url: z.string(),
157
+ })).optional().describe("Image/file attachments from the user message, if present."),
158
+ }),
159
+ },
160
+ },
161
+ }));
162
+ };
163
+ // Collect agents for the orchestrator (excludes topic since it's a manager plugin now)
164
+ const orchestratorAgents = allAgents.map((a) => ({
165
+ name: a.name,
166
+ description: a.description,
167
+ plugin: a.plugin,
168
+ capabilities: a.capabilities,
168
169
  }));
169
- // 4. Generic delegation handler — works for any registered agent
170
- app.on("action:delegateTask", async function* (event, { state }) {
171
- const { agent, task, toolCallId } = event.data;
172
- const s = state;
173
- if (!s.pendingAgentTasks)
174
- s.pendingAgentTasks = {};
175
- s.pendingAgentTasks[agent] = { toolCallId };
176
- yield {
177
- type: `agent:${agent}:input`,
178
- data: { content: task },
179
- };
170
+ return new Orchestrator({
171
+ managerPlugin,
172
+ agents: orchestratorAgents,
180
173
  });
181
- // 5. Generic bridge-back handlers — auto-wired for every registered agent
182
- for (const agent of allAgents) {
183
- app.on(`agent:${agent.name}:output`, async function* (event, { state }) {
184
- const s = state;
185
- const pending = s.pendingAgentTasks?.[agent.name];
186
- if (pending) {
187
- delete s.pendingAgentTasks[agent.name];
188
- yield {
189
- type: "action:taskResult",
190
- data: {
191
- action: "delegateTask",
192
- toolCallId: pending.toolCallId,
193
- result: event.data.content,
194
- },
195
- };
196
- }
197
- });
198
- }
199
- // 6. Init handlers
200
- app
201
- .on("init", initHandler)
202
- .on("sessionChange", sessionChangeHandler)
203
- .on("tabChange", tabChangeHandler)
204
- .on("action:updateSettings", updateSettingsHandler)
205
- .on("action:openAgentFolder", openAgentFolderHandler);
206
- return app;
207
174
  }
@@ -0,0 +1,13 @@
1
+ export function parseDirectAgentInvocation(content, hasAgent) {
2
+ const trimmed = content.trim();
3
+ if (!trimmed || (!trimmed.startsWith("/") && !trimmed.startsWith("@"))) {
4
+ return undefined;
5
+ }
6
+ const firstSpace = trimmed.indexOf(" ");
7
+ const agentName = firstSpace === -1 ? trimmed.slice(1) : trimmed.slice(1, firstSpace);
8
+ if (!hasAgent(agentName)) {
9
+ return undefined;
10
+ }
11
+ const task = firstSpace === -1 ? "" : trimmed.slice(firstSpace + 1).trim();
12
+ return { agentName, task };
13
+ }
@@ -0,0 +1,36 @@
1
+ const AGENT_TEXT_TYPES = new Set(["assistant:text-delta", "assistant:text"]);
2
+ export function isAgentTextEvent(event) {
3
+ return AGENT_TEXT_TYPES.has(event.type);
4
+ }
5
+ export function isApprovalEvent(event) {
6
+ return event.type === "action:approve" || event.type === "action:deny";
7
+ }
8
+ export function makeManagerInputEvent(data) {
9
+ return { type: "manager:input", data };
10
+ }
11
+ export function makeManagerResultEvent(options) {
12
+ const { action = "delegateTask", toolCallId, result } = options;
13
+ return {
14
+ type: "manager:result",
15
+ data: { action, toolCallId, result },
16
+ };
17
+ }
18
+ export function makeAgentInputEvent(agentName, task) {
19
+ return {
20
+ type: `agent:${agentName}:input`,
21
+ data: { content: task },
22
+ };
23
+ }
24
+ export function makeAgentResultType(agentName) {
25
+ return `agent:${agentName}:result`;
26
+ }
27
+ export function makeAgentOutputType(agentName) {
28
+ return `agent:${agentName}:output`;
29
+ }
30
+ export function makeAssistantTextEvent(content, agentName) {
31
+ return {
32
+ type: "assistant:text",
33
+ data: { content },
34
+ meta: { agent: agentName },
35
+ };
36
+ }