Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions tests/automationDrafts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -466,13 +466,13 @@ describe('the automation tools', () => {
})

describe('the tool list', () => {
it('offers the schedule tools once the profile hands its jobs over after the list was built, and the automation tools to the manager only', async () => {
it('offers the schedule tools once the profile hands its jobs over after the list was built, and the automation tools to the manager and a person\'s chat', async () => {
const { createAppToolRegistry } = await import('../src/mms/run/mcp/appTools')
const { fakeAppToolHost } = await import('./run/appToolsFixture')
const { drafts } = setup()
const host = fakeAppToolHost().host
host.agentAccess = () => ({ level: 'manage', projectIds: [] })
const tools: AutomationToolHost = { drafts, isManagerThread: (id) => id === 'manager', botOf: () => undefined }
const tools: AutomationToolHost = { drafts, isManagerThread: (id) => id === 'manager', botOf: () => undefined, ordinaryThread: (id) => id === 'chat' }
host.automations = () => tools
const { registry } = createAppToolRegistry({ host, engine: { delegations: { getLineage: () => undefined } } as never })
const names = (threadId: string) => registry.listForThread(threadId, 'manage').map((tool) => tool.name)
Expand All @@ -481,6 +481,9 @@ describe('the tool list', () => {
expect(names('t1')).toEqual(expect.arrayContaining(['schedule_list', 'schedule_create', 'schedule_update', 'schedule_pause', 'schedule_run']))
expect(names('t1')).not.toContain('automation_draft_save')
expect(names('manager')).toEqual(expect.arrayContaining(['automation_draft_save', 'automation_ask', 'automation_list', 'automation_update', 'automation_pause']))
// A person's chat gets them too (#2385); automation_ask stays the manager's and bots'.
expect(names('chat')).toEqual(expect.arrayContaining(['automation_draft_save', 'automation_list', 'automation_update', 'automation_pause']))
expect(names('chat')).not.toContain('automation_ask')
})
})

Expand Down
10 changes: 6 additions & 4 deletions tests/automationInbox.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ describe('the draft tool in an ordinary chat', () => {
context: 'Rerun checkout.spec 20× on main; report only failures, with the failing seed and log.'
}

it('is offered to a person\'s chat, keeps what "this" meant and where it was made, and only that chat changes its draft', async () => {
it('is offered to a person\'s chat, keeps what "this" meant and where it was made, and no other chat saves over its draft', async () => {
const service = drafts()
const host: AutomationToolHost = {
drafts: service,
Expand All @@ -355,15 +355,17 @@ describe('the draft tool in an ordinary chat', () => {
const save = list.find((tool) => tool.name === 'automation_draft_save')!
expect(save.listed!({ threadId: 'chat', readOnly: false } as never)).toBe(true)
expect(save.listed!({ threadId: 'run-thread', readOnly: false } as never)).toBe(false)
// The manager's other tools stay the manager's.
expect(list.find((tool) => tool.name === 'automation_list')!.listed!({ threadId: 'chat', readOnly: false } as never)).toBe(false)
// Since #2385 the chat's agent lists automations too; an automation's run thread still does not.
const automationList = list.find((tool) => tool.name === 'automation_list')!
expect(automationList.listed!({ threadId: 'chat', readOnly: false } as never)).toBe(true)
expect(automationList.listed!({ threadId: 'run-thread', readOnly: false } as never)).toBe(false)

const result = JSON.parse((await save.handler(CHECK, ctx('chat'))).text) as { draftId: string; problems: string[] }
expect(result.problems).toEqual([])
const contract = service.list().find((entry) => entry.id === result.draftId)!
expect(contract).toMatchObject({ draft: true, context: CHECK.context, createdFrom: { threadId: 'chat' } })
expect(runs.meta(result.draftId)).toEqual({ originThreadId: 'chat', context: CHECK.context })
// Another chat cannot change it.
// Another chat cannot save over it.
expect((await save.handler({ ...CHECK, draftId: result.draftId }, ctx('other-chat'))).isError).toBe(true)
// Turn on keeps where it came from; its runs never post into that chat (a new thread each run).
const job = service.turnOn(result.draftId)
Expand Down
Loading