The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.
TypeScript 3d-modelingagent-frameworkagent-harnessai-agentscadclaude-codecodexcoding-agentsdeveloper-toolsesp32game-developmentmcp-servermulti-agentopen-hardwareopencodeopenharnesspcbroboticsterminaltmux
Store a skill mode per Swarm project (#1598)
0xken15259c2a2b96f0
diff --git a/backend/integration/superTabs.test.ts b/backend/integration/superTabs.test.tsindex 8b0f9f7e1..b036ca802 100644--- a/backend/integration/superTabs.test.ts+++ b/backend/integration/superTabs.test.ts@@ -1178,6 +1178,55 @@ describe('Super Tabs on a real Mongo replica set', () => {expect(rows).toEqual(['Rule added: Only this Mac.', 'Rule removed: Only this Mac.'])expect((await store.read(owner, tab)).state.projects!.map(p => p.id)).toEqual([projectId])})+ it('keeps a new Swarm\'s folder from tab.project on its first project, so the repository can be shared and the host uses it', async () => {+ // Review of #1598: a new Swarm stores its first project, which tab.project left without the folder.+ const tab = (await store.create(owner, randomUUID(), 'Folder')).id+ await run(tab, { type: 'tab.project', machineId: 'test-host', project: { cwd: '/work/app', repositoryUrl: null } })+ const url = 'https://github.com/example/app'+ await run(tab, { type: 'project.repository', projectId: 'lead', repositoryUrl: url })+ const repository = { machineId: 'test-host', cwd: '/work/app', repositoryUrl: url }+ expect((await store.read(owner, tab)).state.projects!.map(p => p.repository)).toEqual([repository])+ const invitation = await run(tab, { type: 'invite.create', email: host.email, role: 'collaborator', conversationId: 'lead' })+ await run(tab, { type: 'invite.accept', inviteId: invitation.result.inviteId as string }, host)+ await run(tab, { type: 'machine.contribute', machineId: 'test-host', name: 'Host', cwd: '/swarm-root', scope: 'swarm', engines: ['codex'], maxAgents: 2 }, host)+ const pool = (await store.hostPools(host, 'test-host')).find(p => p.tabId === tab)!+ await store.observeMachine(host, tab, 'test-host', { generation: pool.machine.generation,+ resources: { cpuPercent: 10, memoryTotalBytes: 32e9, memoryUsedBytes: 4e9, projectDiskFreeBytes: 100e9,+ diskFreeBytes: 100e9, diskTotalBytes: 500e9, deviceType: 'Laptop', chip: 'Fixture CPU', os: 'macOS', gpuPercent: null },+ quotas: [], tools: { git: true }, runningHarnessIds: [], stoppedHarnessIds: [] })+ const request = { conversationId: 'lead', machineId: 'test-host', engine: 'codex', name: 'Builder', cwd: '/work/app', worktree: true,+ requirements: { memoryBytes: 0, diskBytes: 0, maxCpuPercent: 100, tools: [], devices: [], quotaRequired: false } }+ await run(tab, { type: 'agent.start', request })+ expect((await store.hostPools(host, 'test-host')).find(p => p.tabId === tab)!.projects).toEqual([expect.objectContaining({ id: 'lead', repository })])+ })+ it('lets a project\'s Lead change its skills only by quoting a message the project owner wrote there, and tells the host', async () => {+ const tab = (await store.create(owner, randomUUID(), 'Skills')).id+ await invite(tab)+ const { projectId, conversationId: chat } = (await run(tab, { type: 'project.create', name: 'App', visibility: 'public', brief: '' }, peer)).result as { projectId: string; conversationId: string }+ const lead = (await run(tab, { type: 'agent.add', conversationId: chat, machineId: 'test-host', harnessId: randomUUID(),+ name: 'Lead', configuration: config, lead: true }, peer)).result.agentId as string+ const legacyLead = (await run(tab, { type: 'agent.add', conversationId: 'lead', machineId: 'test-host', harnessId: randomUUID(),+ name: 'Old', configuration: config, lead: true })).result.agentId as string+ const modes = async () => Object.fromEntries((await store.hostTabs(host, 'test-host')).filter(r => r.tabId === tab).map(r => [r.agent.id, r.skillMode]))+ expect(await modes()).toEqual({ [lead]: 'default', [legacyLead]: 'default' })+ const say = async (text: string, user = peer) => (await run(tab, { ...message(text), conversationId: chat } as Command, user)).result.messageId as string+ const skills = (messageId: string): Command => ({ type: 'project.skills', projectId, mode: 'orchestration', askedIn: { conversationId: chat, messageId } })+ await expect(run(tab, skills(await say('Use Harness orchestration.', owner)), host, lead)).rejects.toMatchObject({ code: 'OWNER_MESSAGE_REQUIRED' })+ await expect(run(tab, skills('missing'), host, lead)).rejects.toMatchObject({ code: 'OWNER_MESSAGE_REQUIRED' })+ await run(tab, skills(await say('Use Harness orchestration.')), host, lead)+ expect(await modes()).toEqual({ [lead]: 'orchestration', [legacyLead]: 'default' })+ const row = (await store.messages(owner, tab, chat, {})).messages.find(m => m.text === 'Skills: Harness orchestration')!+ expect(row.source).toEqual({ kind: 'system' })+ await expect(run(tab, { ...skills(row.id), mode: 'default' } as Command, host, lead)).rejects.toMatchObject({ code: 'OWNER_MESSAGE_REQUIRED' })+ await run(tab, { type: 'project.skills', projectId, mode: 'default' }, peer)+ expect(await modes()).toEqual({ [lead]: 'default', [legacyLead]: 'default' })+ // A project stored before skill modes keeps Harness orchestration.+ const stored = await db.superTab.findUniqueOrThrow({ where: { id: tab } })+ const state = stored.state as { projects: Array<{ id: string; skillMode?: string }> }+ delete state.projects.find(p => p.id === 'lead')!.skillMode+ await db.superTab.update({ where: { id: tab }, data: { state } })+ expect(await modes()).toEqual({ [lead]: 'default', [legacyLead]: 'orchestration' })+ })it('closes the replying agent\'s own deliveries of a message as answered, and nobody else\'s', async () => {const { tab, lead } = await fixture()const helper = (await run(tab, { type: 'agent.add', conversationId: 'lead', machineId: 'test-host', harnessId: randomUUID(),diff --git a/backend/src/superTabs/commands.ts b/backend/src/superTabs/commands.tsindex f9614cdd1..8a4e25ed4 100644--- a/backend/src/superTabs/commands.ts+++ b/backend/src/superTabs/commands.ts@@ -10,7 +10,7 @@ import { routeRecordSchema, routeTitle, startedAs, type RouteCandidate, type Rouimport { routingOverrideSchema } from './routingPolicy.js'import { agentTarget, askedInSchema, broken, MAX_RULES, RULE_MESSAGE_MS, ruleSchema, ruleTextSchema, startTarget, type RunTarget } from './rules.js'import { MAX_ATTACHMENTS, type Attachment } from './attachments.js'-import { agentProjectId, deleteProject, groupProject, inviteLanding, manageProject, mutableProjects, placeRules, projectMembers, projectOf, projectRules, readAgent, readConversation, readProject, sameProject, type SwarmProject } from './projects.js'+import { agentProjectId, deleteProject, groupProject, inviteLanding, manageProject, mutableProjects, placeRules, projectMembers, projectOf, projectRules, readAgent, readConversation, readProject, sameProject, SKILL_MODE_NAMES, skillModeOf, type SwarmProject } from './projects.js'const id = z.string().min(1).max(160).regex(/^[A-Za-z0-9_-]+$/)const title = z.string().trim().min(1).max(160)@@ -69,6 +69,7 @@ export const commandSchema = z.discriminatedUnion('type', [z.object({ type: z.literal('project.cadence'), projectId: id, minutes: z.union([z.literal(1), z.literal(5), z.literal(15), z.literal(30)]) }).strict(),z.object({ type: z.literal('project.report'), projectId: id, throughRevision: z.number().int().nonnegative().safe(), text: text.nullable() }).strict(),z.object({ type: z.literal('project.repository'), projectId: id, repositoryUrl }).strict(),+ z.object({ type: z.literal('project.skills'), projectId: id, mode: z.enum(['default', 'orchestration']), askedIn: askedInSchema.optional() }).strict(),z.object({ type: z.literal('conversation.create'), projectId: id.optional(), title, brief: z.string().trim().max(8000).optional(), task: task.optional(), reviewOf: id.optional(), checks: z.array(check).max(40) }).strict().refine(c => c.task !== undefined || c.brief !== undefined, 'Provide a task or brief.').refine(c => !c.task || renderWorkTask(c.task).length <= 8000, 'Keep the rendered task within 8,000 characters.'),@@ -119,7 +120,7 @@ export interface CommandContext {contribution?: { machineOwnerId: string; contributorId: string; hostGrant?: string | null }/** Loaded from this tab and conversation by the store. */reply?: { id: string; conversationId: string; author: Author }- /** The message a Lead quotes as the owner's request for a rule change, loaded from this tab by the store. */+ /** The message a Lead quotes as the owner's request for a rule or skill mode change, loaded from this tab by the store. */askedIn?: { author: Author; source: boolean; createdAt: number }/** The newest messages of this conversation before the one being sent, newest first, loaded by the store for `message.send`. */recent?: { author: Author; recipients: string[] }[]@@ -178,7 +179,9 @@ export function authorizeCommandAccess(state: SuperTabState, actor: Actor, commaif ('projectId' in command && command.projectId) readProject(state, actor, command.projectId)if ('agentId' in command) readAgent(state, actor, command.agentId)if (command.type === 'agent.start') readConversation(state, actor, command.request.conversationId)- if ((command.type === 'rule.set' || command.type === 'rule.remove') && command.askedIn) readConversation(state, actor, command.askedIn.conversationId)+ if ((command.type === 'rule.set' || command.type === 'rule.remove' || command.type === 'project.skills') && command.askedIn) {+ readConversation(state, actor, command.askedIn.conversationId)+ }if ('startId' in command && command.type !== 'route.modelResult') {const start = state.starts?.find(s => s.id === command.startId) ?? fail('NOT_FOUND', 'This agent start is unavailable.', 404)readConversation(state, actor, start.request.conversationId)@@ -351,13 +354,35 @@ export function applyCommand(original: SuperTabState, actor: Actor, input: Commaif (projects.length >= 100) fail('PROJECTS_FULL', 'A swarm can have up to 100 projects.')const leadConversationId = `project-${operationId}`projects.push({ id: operationId, name: command.name, ownerId: actor.userId, leadConversationId,- visibility: command.visibility, members: [], updateMinutes: 5 })+ visibility: command.visibility, members: [], updateMinutes: 5, skillMode: 'default' })state.conversations.push({ id: leadConversationId, projectId: operationId, title: 'Lead', leadId: null,agentIds: [], archived: false, brief: command.brief, checks: [], assignment: null, lastMessageSequence: 0 })result.projectId = operationIdresult.conversationId = leadConversationIdbreak}+ case 'project.skills': {+ // Only the project owner, or that project's Lead quoting a chat message the project owner wrote in the last day. The+ // same check as ruleChange, but against the project owner: the Swarm owner does not choose another person's skills.+ const project = readProject(state, actor, command.projectId)+ author(state, actor, true)+ if (!(actor.kind === 'person' && actor.userId === project.ownerId)) {+ if (actor.kind !== 'agent' || conversation(state, project.leadConversationId).leadId !== actor.agentId) {+ fail('PROJECT_OWNER_REQUIRED', 'Only the project owner, or its Lead passing on the owner\'s request, changes its skills.', 403)+ }+ const asked = command.askedIn && context.askedIn+ if (!asked || groupProject(state, conversation(state, command.askedIn!.conversationId)).id !== project.id+ || asked.author.kind !== 'person' || asked.author.id !== project.ownerId || asked.source+ || context.now - asked.createdAt > RULE_MESSAGE_MS) {+ fail('OWNER_MESSAGE_REQUIRED', 'Only the project owner changes its skills; quote a chat message the project owner wrote in the last day asking for this change.', 403)+ }+ }+ if (skillModeOf(project) === command.mode) break+ mutableProjects(state)+ projectOf(state, project.id).skillMode = command.mode+ message(project.leadConversationId, `Skills: ${SKILL_MODE_NAMES[command.mode]}`, [], null, SYSTEM_ROW)+ break+ }case 'project.rename': {const project = manageProject(state, actor, command.projectId)project.name = command.name@@ -389,6 +414,9 @@ export function applyCommand(original: SuperTabState, actor: Actor, input: Commaif (actor.kind === 'person') owner(state, actor)if (state.project) fail('PROJECT_SET', 'This Super Tab already has a project.')state.project = { machineId: command.machineId, ...command.project }+ // A new Swarm stores its first project, and stored projects are read instead of `state.project` (projectsOf).+ const first = state.projects?.find(p => p.id === 'lead')+ if (first) first.repository ??= { ...state.project }break}case 'machine.contribute': {diff --git a/backend/src/superTabs/machines.test.ts b/backend/src/superTabs/machines.test.tsindex 70e218f01..7b8d86914 100644--- a/backend/src/superTabs/machines.test.ts+++ b/backend/src/superTabs/machines.test.ts@@ -62,6 +62,7 @@ describe('a start on a contributed machine', () => {it('names the project\'s own checkout when the lead\'s machine is the one contributed', () => {const f = setup()+ delete f.state.projectsf.state.project = { machineId: 'host', cwd: '/Users/lead/work/repo', repositoryUrl: null }expect(refusal(f.state, f.request({ cwd: '/data/swarm-projects/tab/lead' }))!.message).toContain('this project uses /Users/lead/work/repo on it')expect(refusal(f.state, f.request({ cwd: '/Users/lead/work/repo' }))).toBeNull()diff --git a/backend/src/superTabs/model.ts b/backend/src/superTabs/model.tsindex 012d1cab6..f8dda2af4 100644--- a/backend/src/superTabs/model.ts+++ b/backend/src/superTabs/model.ts@@ -271,7 +271,8 @@ export function createSuperTab(id: string, name: string, owner: { id: string; emagents: [], invitations: [],conversations: [{ id: 'lead', title: 'Lead', leadId: null, agentIds: [], archived: false, brief: '', checks: [], assignment: null, lastMessageSequence: 0 }],}- if (visibility) state.projects = [{ ...projectsOf(state)[0]!, visibility }]+ // A new Swarm's first project starts in Default; only a project from before skill modes reads as Harness orchestration.+ state.projects = [{ ...projectsOf(state)[0]!, ...(visibility ? { visibility } : {}), skillMode: 'default' }]return state}diff --git a/backend/src/superTabs/projects.test.ts b/backend/src/superTabs/projects.test.tsindex 5f340e157..45b80338b 100644--- a/backend/src/superTabs/projects.test.ts+++ b/backend/src/superTabs/projects.test.ts@@ -1,7 +1,7 @@import { describe, expect, it } from 'vitest'-import { applyCommand, type Command } from './commands.js'-import { createSuperTab, visibleState, type Actor } from './model.js'-import { canReadAgent, projectsOf, readConversation } from './projects.js'+import { applyCommand, type Command, type CommandContext } from './commands.js'+import { createSuperTab, visibleState, type Actor, type MessageDraft } from './model.js'+import { canReadAgent, projectOf, projectsOf, readConversation, skillModeOf } from './projects.js'const owner: Actor = { kind: 'person', userId: 'owner', email: '[email protected]' }const peer: Actor = { kind: 'person', userId: 'peer', email: '[email protected]' }@@ -9,18 +9,19 @@ const configuration = { engine: 'codex', model: null, effort: null, contextWindofunction setup() {let state = createSuperTab('swarm', 'Team', { id: 'owner', email: '[email protected]' }, 'test')state.people.push({ id: 'peer', email: '[email protected]', role: 'collaborator', generation: 'first' })- let next = 0- const run = (command: Command, actor = owner) => {+ let next = 0, messages: MessageDraft[] = []+ const run = (command: Command, actor = owner, context: Partial<CommandContext> = {}) => {const effect = applyCommand(state, actor, command, { operationId: `op${next++}`, now: 1000,- contribution: { machineOwnerId: 'host', contributorId: actor.kind === 'person' ? actor.userId : 'owner' } })+ contribution: { machineOwnerId: 'host', contributorId: actor.kind === 'person' ? actor.userId : 'owner' }, ...context })state = effect.state+ messages = effect.messagesreturn effect.result}const project = (visibility: 'private' | 'public' = 'private', actor = owner) =>run({ type: 'project.create', name: 'Other project', visibility, brief: 'Its own outcome' }, actor) as { projectId: string; conversationId: string }const add = (conversationId: string, harnessId: string, lead = true) =>run({ type: 'agent.add', conversationId, harnessId, machineId: 'machine', name: harnessId, configuration, lead }).agentId as string- return { run, project, add, get state() { return state } }+ return { run, project, add, get state() { return state }, get messages() { return messages } }}describe('projects inside an invite-only swarm', () => {@@ -225,6 +226,7 @@ describe('projects inside an invite-only swarm', () => {it('shares a missing repository address on a tab from before projects', () => {const f = setup(), url = '[email protected]:example/project.git'+ delete f.state.projectsf.state.project = { machineId: 'machine', cwd: '/old', repositoryUrl: null }f.run({ type: 'project.repository', projectId: 'lead', repositoryUrl: url })expect(f.state.project).toEqual({ machineId: 'machine', cwd: '/old', repositoryUrl: url })@@ -241,3 +243,73 @@ describe('projects inside an invite-only swarm', () => {expect(readConversation(f.state, owner, p.conversationId).assignment?.status).toBe('reconciling')})})++describe('project skill modes', () => {+ const skills = (projectId: string, mode: 'default' | 'orchestration', askedIn?: { conversationId: string; messageId: string }): Command =>+ ({ type: 'project.skills', projectId, mode, ...(askedIn ? { askedIn } : {}) })+ const said = (id: string, patch: Record<string, unknown> = {}): Partial<CommandContext> => ({ askedIn: {+ author: { kind: 'person', id, name: id, membershipGeneration: 'first' }, source: false, createdAt: 1000, ...patch } })+ const agentActor = (agentId: string): Actor => ({ kind: 'agent', agentId, machineOwnerId: 'host' })+ const modeOf = (f: ReturnType<typeof setup>, projectId: string) => skillModeOf(projectOf(f.state, projectId))++ it('reads a project with no stored mode as Harness orchestration, and new projects and Swarms as Default', () => {+ const legacy = createSuperTab('old', 'Old', { id: 'owner', email: '[email protected]' }, 'test')+ delete legacy.projects+ expect(skillModeOf(projectsOf(legacy)[0]!)).toBe('orchestration')+ expect(skillModeOf({ ...projectsOf(legacy)[0]!, skillMode: undefined })).toBe('orchestration')+ for (const visibility of [undefined, 'private', 'public'] as const) {+ const swarm = createSuperTab('new', 'New', { id: 'owner', email: '[email protected]' }, 'test', visibility)+ expect(projectsOf(swarm).map(p => p.skillMode)).toEqual(['default'])+ }+ const f = setup(), p = f.project()+ expect(projectOf(f.state, p.projectId).skillMode).toBe('default')+ })++ it('lets the project owner change the mode and posts one Skills row in the project chat per real change', () => {+ const f = setup(), p = f.project('public', peer)+ f.run(skills(p.projectId, 'orchestration'), peer)+ expect(modeOf(f, p.projectId)).toBe('orchestration')+ expect(f.messages).toEqual([expect.objectContaining({ conversationId: p.conversationId, text: 'Skills: Harness orchestration', source: { kind: 'system' } })])+ f.run(skills(p.projectId, 'orchestration'), peer)+ expect(f.messages).toEqual([])+ const legacy = setup()+ delete legacy.state.projects+ legacy.run(skills('lead', 'orchestration'))+ expect([legacy.state.projects, legacy.messages]).toEqual([undefined, []])+ f.run(skills(p.projectId, 'default'), peer)+ expect(modeOf(f, p.projectId)).toBe('default')+ expect(f.messages).toEqual([expect.objectContaining({ conversationId: p.conversationId, text: 'Skills: Default', source: { kind: 'system' } })])+ })++ it('stores the mode on a Swarm whose original project was never materialized', () => {+ const f = setup()+ delete f.state.projects+ f.run(skills('lead', 'default'))+ expect(f.state.projects!.map(p => [p.id, p.skillMode])).toEqual([['lead', 'default']])+ expect(f.messages).toEqual([expect.objectContaining({ conversationId: 'lead', text: 'Skills: Default' })])+ })++ it('lets the project\'s Lead change it by quoting a chat message the project owner wrote in the last day', () => {+ const f = setup(), p = f.project('public', peer), lead = agentActor(f.add(p.conversationId, 'app-lead'))+ f.run(skills(p.projectId, 'orchestration', { conversationId: p.conversationId, messageId: 'm1' }), lead, said('peer'))+ expect(modeOf(f, p.projectId)).toBe('orchestration')+ expect(f.messages).toEqual([expect.objectContaining({ conversationId: p.conversationId, text: 'Skills: Harness orchestration' })])+ })++ it('refuses a collaborator, the Swarm owner, another project\'s Lead, a worker, a system row and an old message', () => {+ const f = setup(), p = f.project('public', peer), other = f.project('public')+ const lead = agentActor(f.add(p.conversationId, 'app-lead')), worker = agentActor(f.add(p.conversationId, 'app-worker', false))+ const otherLead = agentActor(f.add(other.conversationId, 'other-lead'))+ const quoted = { conversationId: p.conversationId, messageId: 'm1' }+ expect(() => f.run(skills(other.projectId, 'orchestration'), peer)).toThrow('Only the project owner')+ expect(() => f.run(skills(p.projectId, 'orchestration'), owner)).toThrow('Only the project owner')+ expect(() => f.run(skills(p.projectId, 'orchestration', quoted), otherLead, said('peer'))).toThrow('unavailable')+ expect(() => f.run(skills(p.projectId, 'orchestration', quoted), worker, said('peer'))).toThrow('Only the project owner')+ expect(() => f.run(skills(p.projectId, 'orchestration'), lead, said('peer'))).toThrow('quote a chat message the project owner wrote')+ expect(() => f.run(skills(p.projectId, 'orchestration', quoted), lead, said('owner'))).toThrow('quote a chat message the project owner wrote')+ expect(() => f.run(skills(p.projectId, 'orchestration', quoted), lead, said('peer', { source: true }))).toThrow('quote a chat message the project owner wrote')+ expect(() => f.run(skills(p.projectId, 'orchestration', quoted), lead, said('peer', { createdAt: 1000 - 24 * 3_600_000 - 1 }))).toThrow('quote a chat message the project owner wrote')+ expect(() => f.run(skills(p.projectId, 'orchestration', { conversationId: 'lead', messageId: 'm1' }), lead, said('peer'))).toThrow('unavailable')+ expect([modeOf(f, p.projectId), modeOf(f, other.projectId)]).toEqual(['default', 'default'])+ })+})diff --git a/backend/src/superTabs/projects.ts b/backend/src/superTabs/projects.tsindex 9613657e8..ed8bd485f 100644--- a/backend/src/superTabs/projects.ts+++ b/backend/src/superTabs/projects.ts@@ -2,6 +2,9 @@ import { activeWork, agent, author, conversation, fail, nextConversationNumber,import type { SwarmRule } from './rules.js'export type ProjectVisibility = 'public' | 'private'+/** Which built-in skill texts the project's agents get: Default (the team process only) or today's Harness orchestration. */+export type SkillMode = 'default' | 'orchestration'+export const SKILL_MODE_NAMES: Record<SkillMode, string> = { default: 'Default', orchestration: 'Harness orchestration' }export interface SwarmProject {id: stringname: string@@ -20,8 +23,12 @@ export interface SwarmProject {requestMessageId?: string}repository?: { machineId: string; cwd: string; repositoryUrl: string | null }+ /** Absent on projects from before skill modes, which keep the texts their agents already run. */+ skillMode?: SkillMode}+export const skillModeOf = (project: SwarmProject): SkillMode => project.skillMode ?? 'orchestration'+/** Existing tabs are one project; their conversation IDs and messages stay intact. */export function projectsOf(state: SuperTabState): SwarmProject[] {return state.projects ?? [{diff --git a/backend/src/superTabs/store.ts b/backend/src/superTabs/store.tsindex 7c72844b3..23bb53fc3 100644--- a/backend/src/superTabs/store.ts+++ b/backend/src/superTabs/store.ts@@ -10,7 +10,7 @@ import { attachmentMime, attachmentName, AttachmentTooLarge, checkedType, MAX_ATimport { randomBytes } from 'node:crypto'import type { Readable } from 'node:stream'import { logger } from '../utils/logger.js'-import { canReadAgent, canReadProject, groupProject, projectsOf, agentProjectId, readConversation, type ProjectVisibility } from './projects.js'+import { canReadAgent, canReadProject, groupProject, projectsOf, agentProjectId, readConversation, skillModeOf, type ProjectVisibility } from './projects.js'import { bindSession, makeProjectPrivate } from './sessionScope.js'import { noteProjectReports, projectUpdateRequest } from './projectUpdates.js'import { revokeNativeContexts, SuperTabNativeStore } from './native.js'@@ -399,7 +399,7 @@ export class SuperTabStore {const reply = await tx.superTabMessage.findFirst({ where: { id: command.replyTo, tabId, conversationId: command.conversationId } })if (reply) context.reply = { id: reply.id, conversationId: reply.conversationId, author: reply.author as unknown as Author }}- if ((command.type === 'rule.set' || command.type === 'rule.remove') && command.askedIn) {+ if ((command.type === 'rule.set' || command.type === 'rule.remove' || command.type === 'project.skills') && command.askedIn) {const asked = await tx.superTabMessage.findFirst({ where: { id: command.askedIn.messageId, tabId, conversationId: command.askedIn.conversationId } })if (asked) context.askedIn = { author: asked.author as unknown as Author, source: !!asked.source, createdAt: asked.createdAt.getTime() }}@@ -811,7 +811,11 @@ export class SuperTabStore {// (cli/src/superTabs/host.ts). A collaborator's Lead on a machine shared with them must not open it to every member.const joinSwarm = state.ownerId === user.sub && target.contributorId === user.sub && !state.machines?.some(m => m.machineId === machineId)&& state.conversations.some(c => !c.archived && c.leadId === target.id)- result.push({ tabId: row.id, tabName: state.name, revision: row.revision, paused: state.paused, active, attention, agent: target, joinSwarm,+ // Which skill texts this agent runs; the host reads it here rather than fetching each tab's state per poll. A row+ // whose project is gone reads like one from before skill modes instead of failing the host's whole poll.+ const home = projectsOf(state).find(p => p.id === agentProjectId(state, target))+ const skillMode = home ? skillModeOf(home) : 'orchestration'+ result.push({ tabId: row.id, tabName: state.name, revision: row.revision, paused: state.paused, active, attention, agent: target, joinSwarm, skillMode,stopRequested: target.workDecision === 'stop' && !state.conversations.some(c => activeWork(c) && c.assignment?.agentId === target.id),observers: people.filter(p => p.id !== user.sub &&canReadAgent(state, { kind: 'person', userId: p.id, email: p.email }, target))