Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
74693cccd3 | ||
|
|
115113247f |
@@ -218,7 +218,7 @@ Read-only browser of every volume (`src/utils/storage-volumes.ts`: bots, workspa
|
||||
- **Per-bot models:** workspace row > bot row > default; the coordinator always uses the defaults. Every entry point takes `bot_id` and passes it on. **Embeddings are install-wide** (`install_wide` in `Harnesses`, `isInstallWideHarness`): `grabHarnessSetting` ignores bot/workspace rows for them, the per-bot/workspace forms don't list them and saving one is refused, so every stored vector comes from one model. Shared form `settings/models/(partials)/harness-settings-form.tsx`.
|
||||
- **Tools:** `HarnessTool` built per run; own tools validate with zod. `run-tool-call.ts` reports errors back to the model and caps each call (`AppData.HarnessToolTimeoutMs`); a `computer_*`/`browser_*` call from a run without them (a reply) is told to use `start_task` (`unknownToolMessage`). Bot tools in `src/harness/tools/bot/` (memory, instructions, tasks, schedules, `start_task`, coordinator's crew management, `delegate_task` and `hand_over_schedule`, with results relayed back by `relayJobToRequester`).
|
||||
- **Extensions:** MCP servers (`mcp_servers`, remote or stdio), custom tools (`custom_tools`: http, script, prompt) and skills (`skills`, runbooks loaded with `load_skill`). Given per bot / per workspace (`botExtensionsSql`); `all_bots` only decides what new bots get. Templates `{{args.x}}`/`{{env.KEY}}` via `fillTemplate`; secrets redacted from results. stdio servers run in a per-process pool. Skill body limits are app settings (`grabSkillBodyMaxChars`, `grabSkillBodyShownChars`). A skill proposal says what it changes (`skillProposalChanges`) to the bot and in the confirm outcome, takes no unknown keys (a misnamed `body` would re-propose the saved runbook) and is refused when it changes nothing.
|
||||
- **Bots never add or repoint extensions or set envs.** The coordinator may only change what can't alter where data is sent (name, description, on/off, access). New skills, servers, tools, or changes to a URL, headers, kind, config or a skill's runbook go through `propose_*` -> `extension_proposals` -> `[proposal:ID]` card, which the app describes from the config itself (never from what the bot says) and the super admin confirms (`checkProposalData` re-checks). Stdio servers are never proposed by bots (they run in the app container, which holds the docker socket).
|
||||
- **Bots never add or repoint extensions or set envs.** The coordinator may only change what can't alter where data is sent (name, description, on/off, access); its extension tools (`grabCoordinatorExtensionTools`) come wherever it works, a workspace as much as its own chat. New skills, servers, tools, or changes to a URL, headers, kind, config or a skill's runbook go through `propose_*` -> `extension_proposals` -> `[proposal:ID]` card, which the app describes from the config itself (never from what the bot says) and the super admin confirms (`checkProposalData` re-checks). Stdio servers are never proposed by bots (they run in the app container, which holds the docker socket).
|
||||
- **Check before and after acting** (`ActionCheckNote`): look for an existing record before creating one, verify every action took effect. Tools enforce it (read-back on memory saves, duplicate checks on bots, schedules, tasks, workspaces).
|
||||
|
||||
### Token usage
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "cobble",
|
||||
"version": "0.18.2",
|
||||
"version": "0.18.3",
|
||||
"module": "index.ts",
|
||||
"type": "module",
|
||||
"private": true,
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
import { afterAll, describe, expect, mock, test } from "bun:test";
|
||||
import type { HarnessTool } from "../../types";
|
||||
import type { BUN_SQLITE_COBBLE_BOTS } from "@/db/types/db";
|
||||
|
||||
/**
|
||||
* The coordinator keeps the install's skills, MCP servers and tools
|
||||
* wherever it works. Its workspace conversation is where a runbook for
|
||||
* that workspace's crew gets written, so the branch that returns early for
|
||||
* a workspace must still carry `grabCoordinatorExtensionTools`: a
|
||||
* coordinator asked to make a skill there once had no tool to make one
|
||||
* with, and wrote a file into its folder instead.
|
||||
*
|
||||
* Everything the tool list would read from the database is mocked, so this
|
||||
* suite checks the list's structure alone: which branch pushed what.
|
||||
*/
|
||||
const marker = ({ name }: { name: string }): HarnessTool => ({
|
||||
name,
|
||||
description: `${name} marker`,
|
||||
run: async () => "ok",
|
||||
});
|
||||
|
||||
/**
|
||||
* What `grabCrewWorkers` answers, per test: a workspace with no worker is
|
||||
* the branch that returned before the extension tools were pushed.
|
||||
*/
|
||||
let workers: BUN_SQLITE_COBBLE_BOTS[] = [{ id: 5, name: "A worker", kind: "worker" }];
|
||||
|
||||
mock.module("./extensions/grab-coordinator-extension-tools", () => ({
|
||||
default: async () => [marker({ name: "list_extensions" }), marker({ name: "propose_skill" })],
|
||||
}));
|
||||
mock.module("./grab-bot-tools", () => ({
|
||||
default: async () => [marker({ name: "update_memory" })],
|
||||
}));
|
||||
mock.module("@/src/functions/backend/db/workspaces/grab-user-workspaces", () => ({
|
||||
default: async () => [{ id: 11, name: "A workspace", archived: 0 }],
|
||||
}));
|
||||
mock.module("@/src/functions/backend/db/bots/grab-crew-workers", () => ({
|
||||
default: async () => workers,
|
||||
}));
|
||||
|
||||
const grabBotChatTools = (await import("./grab-bot-chat-tools")).default;
|
||||
|
||||
afterAll(() => {
|
||||
mock.restore();
|
||||
});
|
||||
|
||||
async function names({ workspace_id }: { workspace_id: number | null }) {
|
||||
const coordinator = {
|
||||
bot_types: [],
|
||||
is_coordinator: true,
|
||||
admin_workspace_ids: [],
|
||||
is_workspace_admin: false,
|
||||
can: () => true,
|
||||
};
|
||||
|
||||
const tools = await grabBotChatTools({
|
||||
bot: { id: 1, kind: "coordinator", name: "Coordinator" },
|
||||
powers: coordinator,
|
||||
user_id: 1,
|
||||
computers: [],
|
||||
session_id: 9,
|
||||
workspace_id,
|
||||
onPropose: () => {},
|
||||
});
|
||||
|
||||
return tools.map((tool) => tool.name);
|
||||
}
|
||||
|
||||
describe("grabBotChatTools", () => {
|
||||
test("the coordinator in a workspace reaches the install's skills, servers and tools", async () => {
|
||||
workers = [{ id: 5, name: "A worker", kind: "worker" }];
|
||||
|
||||
const list = await names({ workspace_id: 11 });
|
||||
|
||||
expect(list).toContain("list_extensions");
|
||||
expect(list).toContain("propose_skill");
|
||||
});
|
||||
|
||||
test("a workspace with no worker still gets them, before the empty-crew return", async () => {
|
||||
workers = [];
|
||||
|
||||
const list = await names({ workspace_id: 11 });
|
||||
|
||||
expect(list).toContain("list_extensions");
|
||||
expect(list).toContain("propose_skill");
|
||||
});
|
||||
|
||||
test("its own chat carries them too", async () => {
|
||||
workers = [{ id: 5, name: "A worker", kind: "worker" }];
|
||||
|
||||
const list = await names({ workspace_id: null });
|
||||
|
||||
expect(list).toContain("list_extensions");
|
||||
expect(list).toContain("propose_skill");
|
||||
});
|
||||
});
|
||||
@@ -105,10 +105,12 @@ type Params = {
|
||||
* update_bot, delete_bot and delete_workspace (which workspace, which
|
||||
* computers, and which name, role and core instructions each crew member
|
||||
* gets, and what goes) and the install's skills, MCP servers and custom
|
||||
* tools (`grabCoordinatorExtensionTools`) or, in a workspace,
|
||||
* set_bot_workspace_instructions and update_bot for the workspace's crew
|
||||
* (a bot's core prompt is asked for from wherever the user is), plus
|
||||
* set_bot_type to make a worker a workspace's admin. A workspace admin, in the workspace it leads, gets
|
||||
* tools (`grabCoordinatorExtensionTools`, in a workspace as much as in its
|
||||
* own chat: a runbook for the crew there is written from either) or, in a
|
||||
* workspace, set_bot_workspace_instructions and update_bot for the
|
||||
* workspace's crew (a bot's core prompt is asked for from wherever the
|
||||
* user is), plus set_bot_type to make a worker a workspace's admin. A
|
||||
* workspace admin, in the workspace it leads, gets
|
||||
* `grabWorkspaceAdminTools`. Every gate reads the bot's types (`powers`),
|
||||
* never `bots.kind`. Anything else on a computer goes through a task,
|
||||
* never mid-reply.
|
||||
@@ -177,6 +179,14 @@ export default async function grabBotChatTools({
|
||||
return tools;
|
||||
}
|
||||
|
||||
/**
|
||||
* The install's skills, MCP servers and tools are the coordinator's
|
||||
* wherever it works, a workspace as much as its own chat: a skill the
|
||||
* crew there needs is written from either, and every tool checks the
|
||||
* super admin again when it runs.
|
||||
*/
|
||||
tools.push(...(await grabCoordinatorExtensionTools({ user_id, bot_id, session_id, workspace_id, onPropose })));
|
||||
|
||||
const workspaces = (await grabUserWorkspaces({ user_id })).filter((w) => !w.archived);
|
||||
|
||||
/**
|
||||
@@ -227,12 +237,7 @@ export default async function grabBotChatTools({
|
||||
return tools;
|
||||
}
|
||||
|
||||
tools.push(
|
||||
findBotTool(),
|
||||
findWorkspaceTool({ user_id }),
|
||||
listWorkspaceBotsTool({ user_id }),
|
||||
...(await grabCoordinatorExtensionTools({ user_id, bot_id, session_id, workspace_id, onPropose })),
|
||||
);
|
||||
tools.push(findBotTool(), findWorkspaceTool({ user_id }), listWorkspaceBotsTool({ user_id }));
|
||||
|
||||
tools.push(deleteWorkspaceTool({ user_id, workspaces }));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user