Skip to content
Open
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
4 changes: 2 additions & 2 deletions .secretlintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
"pattern": "/\\b(?<key>(?:password|pass|secret|token|apiKey)(?:[_-]\\w+)?)\\b\\s*[:=]\\s*(?<value>(?!['\"]?\\s*['\"]?$)(?!\\d+\\.\\d+(?:\\.\\d+)?(?:\\s|$))\\S.*)/i"
}
],
"allows": ["your_api_key", "YOUR_API_KEY"]
"allows": ["your_api_key", "YOUR_API_KEY","process.env.OPENAI_API_KEY"]
}
},
{ "id": "@secretlint/secretlint-rule-privatekey" }
]
}
}
2 changes: 1 addition & 1 deletion infra/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
},
"engines": {
"node": ">=22",
"pnpm": "9"
"pnpm": ">=9"
},
"devDependencies": {
"pnpm-dev-kit": "workspace:*",
Expand Down
1 change: 1 addition & 0 deletions multimodal/agent-tars/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"@agent-tars/interface": "workspace:*",
"@types/node": "^20.14.8",
"typescript": "^5.7.2",
"node-fetch": "^3.3.0",
"rimraf": "^6.0.1"
},
"pkg": {
Expand Down
1 change: 1 addition & 0 deletions multimodal/agent-tars/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"@tarko/shared-utils": "workspace:*",
"@tarko/shared-media-utils": "workspace:*",
"@tarko/mcp-agent": "workspace:*",
"@tarko/skill-agent": "workspace:*",
"@agent-tars/interface": "workspace:*"
},
"devDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions multimodal/agent-tars/core/rslib.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ export default defineConfig({
dts: true,
banner: { js: BANNER },
autoExternal: {
dependencies: false,
dependencies: true,
optionalDependencies: true,
peerDependencies: true,
},
output: {
externals: ['@tarko/shared-media-utils'],
externals: ['@tarko/shared-media-utils', 'node-fetch'],
},
},
],
Expand Down
42 changes: 26 additions & 16 deletions multimodal/agent-tars/core/src/agent-tars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import {
AgentEventStream,
MCPAgent,
LLMRequestHookPayload,
LLMResponseHookPayload,
ConsoleLogger,
Expand All @@ -23,13 +22,18 @@ import { AgentTARSBaseEnvironment } from './environments/base';
import { ToolLogger } from './utils';
import { AGENT_TARS_WEBUI_CONFIG } from './webui-config';

// Skill-related imports
import { SkillAgent, SkillAgentOptions } from '@tarko/skill-agent';

/**
* AgentTARS - A multimodal AI agent with browser, filesystem, and search capabilities
*
* This class provides a comprehensive AI agent built on the Tarko framework,
* This class provides a comprehensive AI agent built on Tarko framework,
* offering seamless integration with browsers, file systems, and search providers.
*
* Extends SkillAgent to provide skill management capabilities out of the box.
*/
export class AgentTARS<T extends AgentTARSOptions = AgentTARSOptions> extends MCPAgent<T> {
export class AgentTARS<T extends AgentTARSOptions = AgentTARSOptions> extends SkillAgent<T> {
static label = '@agent-tars/core';

/**
Expand Down Expand Up @@ -82,14 +86,19 @@ export class AgentTARS<T extends AgentTARSOptions = AgentTARSOptions> extends MC
new ConsoleLogger(options.id || 'AgentTARS'),
);

// Initialize parent class with environment-provided MCP configuration
super({
// Build options for parent SkillAgent
const skillAgentOptions: T = {
...processedOptions,
name: options.name ?? 'AgentTARS',
instructions,
mcpServers: environment.getMCPServerRegistry(),
maxTokens: processedOptions.maxTokens,
});
// Merge skills option if provided
// skills:false,
} as T;

// Call parent constructor (SkillAgent -> MCPAgent)
super(skillAgentOptions);

// Store configuration
this.tarsOptions = processedOptions;
Expand All @@ -102,9 +111,9 @@ export class AgentTARS<T extends AgentTARSOptions = AgentTARSOptions> extends MC
// Initialize core utilities
this.toolLogger = new ToolLogger(this.logger);

// Use the environment created earlier (with updated logger)
// Use the environment created earlier
this.environment = environment;
// Update environment logger to use the initialized logger
// Update environment logger to use initialized logger
if ('logger' in this.environment) {
(this.environment as any).logger = this.logger.spawn(
processedOptions.aioSandbox ? 'AIOEnvironment' : 'LocalEnvironment',
Expand All @@ -117,15 +126,18 @@ export class AgentTARS<T extends AgentTARSOptions = AgentTARSOptions> extends MC
}

/**
* Initialize the agent and all its components
* Initialize agent and all its components
*/
async initialize(): Promise<void> {
this.logger.info('🚀 Initializing AgentTARS...');

try {
// Initialize all components through the environment
// Initialize all components through environment
await this.environment.initialize((tool) => this.registerTool(tool), this.eventStream);

// Call parent initialize (SkillAgent) which will initialize skills
await super.initialize();

// Log registered tools
this.toolLogger.logRegisteredTools(this.getTools());

Expand All @@ -135,8 +147,6 @@ export class AgentTARS<T extends AgentTARSOptions = AgentTARSOptions> extends MC
await this.cleanup();
throw error;
}

await super.initialize();
}

/**
Expand Down Expand Up @@ -208,28 +218,28 @@ export class AgentTARS<T extends AgentTARSOptions = AgentTARSOptions> extends MC
}

/**
* Get the current working directory
* Get current working directory
*/
public getWorkingDirectory(): string {
return this.workspace;
}

/**
* Get the logger instance
* Get logger instance
*/
public getLogger(): ConsoleLogger {
return this.logger;
}

/**
* Get the current abort signal
* Get current abort signal
*/
public getAbortSignal(): AbortSignal | undefined {
return this.executionController.getAbortSignal();
}

/**
* Get the browser manager instance
* Get browser manager instance
*/
public getBrowserManager(): BrowserManager | undefined {
return this.environment.getBrowserManager();
Expand Down
78 changes: 78 additions & 0 deletions multimodal/agent-tars/core/src/debug.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/*
* Copyright (c) 2025 Bytedance, Inc. and its affiliates.
* SPDX-License-Identifier: Apache-2.0
*/
import { LogLevel } from '@tarko/interface';
import { AgentTARS } from './index';
import { AgentServer } from '@tarko/agent-server';
import { IAgent } from '@tarko/agent-interface';
import { homedir } from 'os';
import path from 'path';
import {
AgentTARSCLIArguments,
AgentTARSAppConfig,
BrowserControlMode,
AGENT_TARS_CONSTANTS,
} from '@agent-tars/interface';
// Simple test configuration
const testConfig: AgentTARSAppConfig = {
agent: {
type: 'module',
constructor: AgentTARS,
},
server: {
port: 3001,
storage: {
type: 'sqlite',
baseDir: path.join(homedir(), '.agent-tars', 'storage'),
dbName: 'agent-tars.db',
},
},
logLevel: LogLevel.DEBUG,
model: {
provider: 'openai',
id: 'qwen-max',
apiKey: process.env.OPENAI_API_KEY,
baseURL: process.env.OPENAI_BASE_URL,
},
workspace: path.join(homedir(), '.agent-tars', 'workspace'),
};

async function startServer() {
console.log('Starting Agent Server for debugging...');

const server = new AgentServer({
appConfig: testConfig,
versionInfo: {
version: '1.0.0',
buildTime: Date.now(),
gitHash: 'dev',
},
});

try {
// Create workspace directory if it doesn't exist
const { mkdirSync, existsSync } = await import('fs');
const workspaceDir = testConfig.workspace;

const httpServer = await server.start();
console.log(`\nAgent Server started successfully!`);
console.log(`Server URL: http://localhost:3001`);
console.log(`\nYou can now make requests to the API endpoints, e.g.:`);
console.log(`- POST http://localhost:3001/api/sessions (create session)`);
console.log(`- GET http://localhost:3001/api/system/info (system info)`);

// Keep server running
process.on('SIGINT', async () => {
console.log('\nStopping server...');
await server.stop();
console.log('Server stopped.');
process.exit(0);
});
} catch (error) {
console.error('Failed to start server:', error);
process.exit(1);
}
}

startServer();
3 changes: 2 additions & 1 deletion multimodal/agent-tars/interface/src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/

import type { MCPServerRegistry, MCPAgentOptions } from '@tarko/mcp-agent-interface';
import type { SkillAgentOptions } from '@tarko/skill-agent';

export type LocalBrowserSearchEngine = 'google' | 'bing' | 'baidu' | 'sogou';

Expand Down Expand Up @@ -131,7 +132,7 @@ export interface AgentTARSExperimentalOptions {
/**
* Common options interface for all Agent TARS implementations
*/
export interface AgentTARSOptions extends MCPAgentOptions {
export interface AgentTARSOptions extends SkillAgentOptions {
/**
* Search settings.
*/
Expand Down
8 changes: 7 additions & 1 deletion multimodal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,13 @@
},
"engines": {
"node": ">=22",
"pnpm": "9"
"pnpm": ">=9"
},
"pnpm": {
"overrides": {
"node-fetch": "^3.3.2",
"@types/node-fetch": "npm:@types/node-fetch@^3.0.0"
}
},
"devDependencies": {
"pnpm-dev-kit": "0.0.5-canary-7d05b7ce-20251213170600",
Expand Down
Loading