From f74d47a0dafea4e81a6159647979c99b127325d8 Mon Sep 17 00:00:00 2001 From: TheAnimatrix Date: Mon, 30 Nov 2026 08:22:13 +0530 Subject: [PATCH] test(automations): an ordinary chat's agent lists the automation tools, as #2385 made it --- tests/automationDrafts.test.ts | 7 +++++-- tests/automationInbox.test.ts | 10 ++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/tests/automationDrafts.test.ts b/tests/automationDrafts.test.ts index 43922ee79..52e0b92ca 100644 --- a/tests/automationDrafts.test.ts +++ b/tests/automationDrafts.test.ts @@ -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) @@ -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') }) }) diff --git a/tests/automationInbox.test.ts b/tests/automationInbox.test.ts index 645b2beb9..540eb27ac 100644 --- a/tests/automationInbox.test.ts +++ b/tests/automationInbox.test.ts @@ -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, @@ -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)