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
12 changes: 11 additions & 1 deletion packages/ai-engine/src/agent-runner.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import os from 'node:os';
import path from 'node:path';

import type { UseCaseNode } from '@tally/core';
import { FileSystemProjectStore, type ProjectStore } from '@tally/storage';
import { FileSystemOAuthStore, FileSystemProjectStore, type ProjectStore } from '@tally/storage';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';

import { runAgent, type SdkLike } from './agent-runner';
Expand Down Expand Up @@ -75,6 +75,7 @@ describe('runAgent', () => {
for await (const e of runAgent({
sdk: mockSdk as never,
store,
oauthStore: new FileSystemOAuthStore(root),
projectDir: root,
req: {
type: 'start',
Expand Down Expand Up @@ -116,6 +117,7 @@ describe('runAgent', () => {
for await (const e of runAgent({
sdk: mockSdk as never,
store,
oauthStore: new FileSystemOAuthStore(root),
projectDir: root,
req: {
type: 'start',
Expand Down Expand Up @@ -148,6 +150,7 @@ describe('runAgent', () => {
for await (const e of runAgent({
sdk: mockSdk as never,
store,
oauthStore: new FileSystemOAuthStore(root),
projectDir: root,
req: {
type: 'start',
Expand All @@ -173,6 +176,7 @@ describe('runAgent', () => {
for await (const e of runAgent({
sdk: mockSdk as never,
store,
oauthStore: new FileSystemOAuthStore(root),
projectDir: root,
req: {
type: 'start',
Expand Down Expand Up @@ -202,6 +206,7 @@ describe('runAgent', () => {
for await (const e of runAgent({
sdk: mockSdk as never,
store,
oauthStore: new FileSystemOAuthStore(root),
projectDir: root,
req: {
type: 'start',
Expand Down Expand Up @@ -257,6 +262,7 @@ describe('runAgent', () => {
for await (const e of runAgent({
sdk: mockSdk as never,
store,
oauthStore: new FileSystemOAuthStore(root),
projectDir: root,
req: {
type: 'start',
Expand Down Expand Up @@ -317,6 +323,7 @@ describe('runAgent', () => {
for await (const e of runAgent({
sdk: mockSdk as never,
store,
oauthStore: new FileSystemOAuthStore(root),
projectDir: root,
req: {
type: 'start',
Expand Down Expand Up @@ -411,6 +418,7 @@ describe('runAgent', () => {
for await (const e of runAgent({
sdk,
store,
oauthStore: new FileSystemOAuthStore(projectDir),
projectDir,
req: {
type: 'start',
Expand Down Expand Up @@ -474,6 +482,7 @@ describe('runAgent', () => {
for await (const e of runAgent({
sdk,
store,
oauthStore: new FileSystemOAuthStore('/ws'),
projectDir: '/ws',
req: {
type: 'start',
Expand Down Expand Up @@ -546,6 +555,7 @@ describe('runAgent', () => {
for await (const _ of runAgent({
sdk,
store,
oauthStore: new FileSystemOAuthStore('/ws'),
projectDir: '/ws',
req: {
type: 'start',
Expand Down
10 changes: 7 additions & 3 deletions packages/ai-engine/src/agent-runner.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { AgentName } from '@tally/core';
import type { ProjectStore } from '@tally/storage';
import type { OAuthStore, ProjectStore } from '@tally/storage';

import { AGENT_REGISTRY } from './agents/registry';
import { buildMcpServers } from './mcp/build-mcp-servers';
Expand Down Expand Up @@ -67,6 +67,9 @@ export interface SdkLike {
export interface RunAgentDeps {
sdk: SdkLike;
store: ProjectStore;
// ADR-0011 PR-E4: 外部 MCP の Authorization header 注入用に、buildMcpServers が
// FileSystemOAuthStore.read を叩く。agent-runner は per-request に store を渡される。
oauthStore: OAuthStore;
projectDir: string;
req: StartRequest;
}
Expand All @@ -77,7 +80,7 @@ export interface RunAgentDeps {
// SDK 呼び出し中に MCP ツールハンドラが emit した side events (node_created など) は
// 次の SDK メッセージを受け取るタイミングで合流して flush する。
export async function* runAgent(deps: RunAgentDeps): AsyncGenerator<AgentEvent> {
const { sdk, store, projectDir, req } = deps;
const { sdk, store, oauthStore, projectDir, req } = deps;
yield { type: 'start', agent: req.agent, input: req.input };

const def = AGENT_REGISTRY[req.agent];
Expand Down Expand Up @@ -128,9 +131,10 @@ export async function* runAgent(deps: RunAgentDeps): AsyncGenerator<AgentEvent>
// env 未設定時は throw → catch で error event に流す。
const projectMeta = await store.getProjectMeta();
const externalConfigs = projectMeta?.mcpServers ?? [];
const { mcpServers, allowedTools: externalAllowed } = buildMcpServers({
const { mcpServers, allowedTools: externalAllowed } = await buildMcpServers({
tallyMcp: mcp,
configs: externalConfigs,
oauthStore,
});

// built-in ツールは mcp__ プレフィックスを持たないもの (Read / Glob / Grep など)。
Expand Down
87 changes: 0 additions & 87 deletions packages/ai-engine/src/auth-detector.test.ts

This file was deleted.

37 changes: 0 additions & 37 deletions packages/ai-engine/src/auth-detector.ts

This file was deleted.

Loading