BREAKING CHANGE(aidoc): migrate agent orchestration to new runAgent API and filesystem tools; refactor model handling and update README and tests

This commit is contained in:
2026-03-11 18:58:48 +00:00
parent 883985dbc0
commit 6b2957b272
11 changed files with 834 additions and 3270 deletions

View File

@@ -8,7 +8,7 @@ export class AiDoc {
public npmextraKV: plugins.npmextra.KeyValueStore;
public qenvInstance: plugins.qenv.Qenv;
public aidocInteract: plugins.smartinteract.SmartInteract;
public smartAiInstance: plugins.smartai.SmartAi;
public model: plugins.smartai.LanguageModelV3;
argvArg: any;
@@ -84,27 +84,16 @@ export class AiDoc {
this.openaiToken = await this.npmextraKV.readKey('OPENAI_TOKEN');
}
// lets assume we have an OPENAI_Token now
this.smartAiInstance = new plugins.smartai.SmartAi({
openaiToken: this.openaiToken,
// Create model using getModel()
this.model = plugins.smartai.getModel({
provider: 'openai',
model: 'gpt-5.4',
apiKey: this.openaiToken,
});
await this.smartAiInstance.start();
}
public async stop() {
if (this.smartAiInstance) {
await this.smartAiInstance.stop();
}
// No explicit cleanup needed for npmextraKV or aidocInteract
// They don't keep event loop alive
}
/**
* Get the OpenAI provider for direct chat calls
* This is a convenience getter to access the provider from SmartAi
*/
public get openaiProvider(): plugins.smartai.OpenAiProvider {
return this.smartAiInstance.openaiProvider;
// No lifecycle management needed with getModel() API
}
public getOpenaiToken(): string {
@@ -130,7 +119,7 @@ export class AiDoc {
const projectContextInstance = new aiDocsClasses.ProjectContext(projectDirArg);
return await projectContextInstance.gatherFiles();
}
/**
* Get the context with token count information
* @param projectDirArg The path to the project directory
@@ -141,7 +130,7 @@ export class AiDoc {
await projectContextInstance.update();
return projectContextInstance.getContextWithTokenCount();
}
/**
* Get just the token count for a project's context
* @param projectDirArg The path to the project directory
@@ -152,7 +141,7 @@ export class AiDoc {
await projectContextInstance.update();
return projectContextInstance.getTokenCount();
}
/**
* Estimate token count in a text string
* @param text The text to estimate tokens for