Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

Merge upstream/main into fix/issue-5570

Krishna Dobhal1c05ad78ddb0
diff --cc server/host/skills-library.ts
index 2723608258,10994a1a73..73895926f7
--- a/server/host/skills-library.ts
+++ b/server/host/skills-library.ts
@@@ -29,9 -29,9 +29,9 @@@ import
} from "../skill-share.ts";
import { enabledSkillFiles, listSkills, readSkillFile, resolveBotSkills, skillsSystemPrompt, type SkillListing } from "../skills.ts";
import type { BotRecord, Message, Store } from "../store.ts";
-import { claudeUserSkillsEnabled } from "../turn-settings.ts";
+import { claudeUserSkillsEnabled, settingsTurnFields } from "../turn-settings.ts";
import { typedWords } from "../typed-sends.ts";
- import { TASK_WORKSPACES_DIR } from "../workspace.ts";
+ import { supportsWorkspaceFiles, TASK_WORKSPACES_DIR } from "../workspace.ts";
type ReceiptArgs = {
botId: string;
@@@ -275,18 -301,10 +308,19 @@@ export function createSkillsLibraryHost
return listedImports(bot, importsFor(bot, conversationSkills(bot, threadId), instance));
},
+ turnSkillFiles,
+
+ turnSettings(bot: BotRecord, threadId: string, instance: TurnInstance, restrictsMcp: boolean) {
+ return {
+ ...settingsTurnFields(cfg, DATA_DIR, restrictsMcp),
+ ...(instance.driverKind === "antigravityAgent" ? { skillFiles: turnSkillFiles(bot, threadId, instance) } : {}),
+ };
+ },
+
- /** Each `/name` called for one of the bot's own, library or imported skills, or one its engine loads by itself. `lines`
- * are the turn's own lines when it is a person's turn: only words they typed can call a skill past the start of the text. */
- expandSkillCommand(bot: BotRecord, threadId: string, text: string, instance?: TurnInstance, lines: ReadonlyArray<{ sendId?: string; text?: string }> = [], ownStart = false): string {
+ /** Each `/name` called for one of the bot's own, library or imported skills, one its engine loads by itself, or one its
+ * project ships. `lines` are the turn's own lines when it is a person's turn: only words they typed can call a skill
+ * past the start of the text. `privateOnly`: the conversation keeps a private folder, as `store.pinTaskCwd` is told. */
+ expandSkillCommand(bot: BotRecord, threadId: string, text: string, instance?: TurnInstance, lines: ReadonlyArray<{ sendId?: string; text?: string }> = [], ownStart = false, privateOnly = false): string {
const typed = typedWords(threadId, lines);
const mentioned = skillCalls(text, typed, ownStart);
if (!mentioned.length) return text;
diff --cc server/skill-command.test.ts
index c49b2a83bd,9d09cb95ad..ffb5983237
--- a/server/skill-command.test.ts
+++ b/server/skill-command.test.ts
@@@ -62,39 -60,6 +62,39 @@@ describe("parseSkillCommand", () =>
});
describe("words a person typed", () => {
+ it("stages an explicitly called team skill shared after the conversation started", () => {
+ const name = "late-" + randomUUID().slice(0, 8);
+ const author = { id: "author-" + randomUUID().slice(0, 8), name: "Author", section: "Team" };
+ const mate = { id: "mate-" + randomUUID().slice(0, 8), name: "Mate", section: "Team", assignedSkills: [] as string[] } as BotRecord;
+ const staged = stageSkillWrite(author.id, { action: "create", files: [{ path: "SKILL.md", content: SKILL(name) }], source: "learn:conversation" });
+ if ("error" in staged) throw new Error(staged.error);
+ expect(applyStagedSkillWrite(author.id, staged.id, { expectedSha256: staged.sha256 })).not.toHaveProperty("error");
+ expect(shareLearnedSkill({ author, bots: [author, mate], name, now: 1000,
+ patchAssigned: (id, assigned) => { if (id === mate.id) mate.assignedSkills = assigned; },
+ })).not.toHaveProperty("error");
+ const libraryHost = createSkillsLibraryHost({
- store: { bot: () => mate, messagesFor: () => [{ at: 500 }] } as unknown as Store,
++ store: { bot: () => mate, messagesFor: () => [{ at: 500 }], taskByThread: () => undefined } as unknown as Store,
+ cfg: { features: { skillsLibrary: true } } as AppConfig,
+ appendSkillRequestCard: () => ({ requestId: "", summary: "" }),
+ });
+ const engine = { instanceId: "antigravity", driverKind: "antigravityAgent" };
+ expect(libraryHost.skillsIndex(mate, "thread", engine)).not.toContain(name);
+ expect(libraryHost.expandSkillCommand(mate, "thread", "/" + name, engine, [], true)).toContain(JSON.stringify(librarySkillFilePath(name)));
+ expect(libraryHost.turnSkillFiles(mate, "thread", engine)).toContain(librarySkillFilePath(name));
+ });
+
+ it("offers only enabled skill files for driver staging", () => {
+ const bot = botWith("standup");
+ const record = { id: bot } as BotRecord;
+ expect(host.turnSkillFiles(record, "thread")).toEqual([enabledSkillFile(bot, "standup")]);
+ expect(host.turnSettings(record, "thread", { instanceId: "antigravity", driverKind: "antigravityAgent" }, true))
+ .toMatchObject({ skillFiles: [enabledSkillFile(bot, "standup")], mcpFromUserConfig: false });
+ expect(host.turnSettings(record, "thread", { instanceId: "claude", driverKind: "claudeAgent" }, false))
+ .not.toHaveProperty("skillFiles");
+ expect("error" in setSkillEnabled(bot, "standup", false)).toBe(false);
+ expect(host.turnSkillFiles(record, "thread")).toEqual([]);
+ });
+
it("points the engine at the enabled skill's reviewed SKILL.md", () => {
const bot = botWith("standup");
const file = join(workspaceDir(bot), "skills", "standup", "SKILL.md");