fix: abort signal in polling loops, remove legacy k2p5, pass ctx.directory to skill tool
- Check context.abort in background-wait and background-output polling loops - Remove legacy kimi-for-coding/k2p5 from athena fallback chain - Pass ctx.directory from tool-registry to createSkillTool instead of process.cwd()
This commit is contained in:
@@ -102,6 +102,7 @@ export function createToolRegistry(args: {
|
||||
mcpManager: managers.skillMcpManager,
|
||||
getSessionID: getSessionIDForMcp,
|
||||
gitMasterConfig: pluginConfig.git_master,
|
||||
directory: ctx.directory,
|
||||
})
|
||||
|
||||
const taskSystemEnabled = pluginConfig.experimental?.task_system ?? false
|
||||
|
||||
@@ -92,7 +92,6 @@ export const AGENT_MODEL_REQUIREMENTS: Record<string, ModelRequirement> = {
|
||||
athena: {
|
||||
fallbackChain: [
|
||||
{ providers: ["anthropic", "github-copilot", "opencode"], model: "claude-opus-4-6", variant: "max" },
|
||||
{ providers: ["kimi-for-coding"], model: "k2p5" },
|
||||
{ providers: ["opencode"], model: "kimi-k2.5-free" },
|
||||
{ providers: ["zai-coding-plan"], model: "glm-4.7" },
|
||||
{ providers: ["opencode"], model: "glm-4.7-free" },
|
||||
|
||||
@@ -119,8 +119,13 @@ export function createBackgroundOutput(manager: BackgroundOutputManager, client:
|
||||
}
|
||||
|
||||
if (shouldBlock) {
|
||||
const abort = (toolContext as { abort?: AbortSignal } | undefined)?.abort
|
||||
const startTime = Date.now()
|
||||
while (Date.now() - startTime < timeoutMs) {
|
||||
if (abort?.aborted) {
|
||||
return formatTaskStatus(task)
|
||||
}
|
||||
|
||||
await delay(1000)
|
||||
|
||||
const currentTask = manager.getTask(args.task_id)
|
||||
|
||||
@@ -21,7 +21,9 @@ export function createBackgroundWait(manager: BackgroundOutputManager, client: B
|
||||
task_ids: tool.schema.array(tool.schema.string()).describe("Task IDs to monitor — returns when ANY one reaches a terminal state"),
|
||||
timeout: tool.schema.number().optional().describe("Max wait in ms. Default: 120000 (2 min). The tool returns immediately when any task finishes, so large values are fine."),
|
||||
},
|
||||
async execute(args: { task_ids: string[]; timeout?: number }) {
|
||||
async execute(args: { task_ids: string[]; timeout?: number }, toolContext?: unknown) {
|
||||
const abort = (toolContext as { abort?: AbortSignal } | undefined)?.abort
|
||||
|
||||
const taskIds = args.task_ids
|
||||
if (!taskIds || taskIds.length === 0) {
|
||||
return "Error: task_ids array is required and must not be empty."
|
||||
@@ -36,6 +38,10 @@ export function createBackgroundWait(manager: BackgroundOutputManager, client: B
|
||||
|
||||
const startTime = Date.now()
|
||||
while (Date.now() - startTime < timeoutMs) {
|
||||
if (abort?.aborted) {
|
||||
return buildProgressSummary(manager, taskIds, true)
|
||||
}
|
||||
|
||||
await delay(1000)
|
||||
|
||||
const found = findFirstTerminal(manager, taskIds)
|
||||
|
||||
@@ -250,7 +250,7 @@ export function createSkillTool(options: SkillLoadOptions = {}): ToolDefinition
|
||||
body = injectGitMasterConfig(body, options.gitMasterConfig)
|
||||
}
|
||||
|
||||
const dir = matchedSkill.path ? dirname(matchedSkill.path) : matchedSkill.resolvedPath || process.cwd()
|
||||
const dir = matchedSkill.path ? dirname(matchedSkill.path) : matchedSkill.resolvedPath || options.directory || process.cwd()
|
||||
|
||||
const output = [
|
||||
`## Skill: ${matchedSkill.name}`,
|
||||
|
||||
@@ -33,6 +33,6 @@ export interface SkillLoadOptions {
|
||||
/** Git master configuration for watermark/co-author settings */
|
||||
gitMasterConfig?: GitMasterConfig
|
||||
disabledSkills?: Set<string>
|
||||
/** Project directory for skill discovery. Falls back to process.cwd() if not provided. */
|
||||
/** Project directory for skill discovery and base directory resolution. Should be ctx.directory from PluginContext. */
|
||||
directory?: string
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user