|
@@ -1,6 +1,5 @@
|
|
|
import path from 'node:path';
|
|
import path from 'node:path';
|
|
|
import type { PluginInput } from '@opencode-ai/plugin';
|
|
import type { PluginInput } from '@opencode-ai/plugin';
|
|
|
-import type { AgentName } from '../../config';
|
|
|
|
|
import {
|
|
import {
|
|
|
BackgroundJobBoard,
|
|
BackgroundJobBoard,
|
|
|
type BackgroundJobRecord,
|
|
type BackgroundJobRecord,
|
|
@@ -25,23 +24,11 @@ interface TaskArgs {
|
|
|
interface PendingTaskCall {
|
|
interface PendingTaskCall {
|
|
|
callId: string;
|
|
callId: string;
|
|
|
parentSessionId: string;
|
|
parentSessionId: string;
|
|
|
- agentType: AgentName;
|
|
|
|
|
|
|
+ agentType: string;
|
|
|
label: string;
|
|
label: string;
|
|
|
resumedTaskId?: string;
|
|
resumedTaskId?: string;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-const AGENT_NAME_SET = new Set<AgentName>([
|
|
|
|
|
- 'orchestrator',
|
|
|
|
|
- 'oracle',
|
|
|
|
|
- 'designer',
|
|
|
|
|
- 'explorer',
|
|
|
|
|
- 'librarian',
|
|
|
|
|
- 'fixer',
|
|
|
|
|
- 'observer',
|
|
|
|
|
- 'council',
|
|
|
|
|
- 'councillor',
|
|
|
|
|
-]);
|
|
|
|
|
-
|
|
|
|
|
const MAX_PENDING_TASK_CALLS = 100;
|
|
const MAX_PENDING_TASK_CALLS = 100;
|
|
|
|
|
|
|
|
interface PendingContextFile {
|
|
interface PendingContextFile {
|
|
@@ -108,10 +95,6 @@ function createOccurrenceId(
|
|
|
return `anon:${hash}`;
|
|
return `anon:${hash}`;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-function isAgentName(value: unknown): value is AgentName {
|
|
|
|
|
- return typeof value === 'string' && AGENT_NAME_SET.has(value as AgentName);
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
function extractPath(output: string): string | undefined {
|
|
function extractPath(output: string): string | undefined {
|
|
|
return /<path>([^<]+)<\/path>/.exec(output)?.[1];
|
|
return /<path>([^<]+)<\/path>/.exec(output)?.[1];
|
|
|
}
|
|
}
|
|
@@ -492,18 +475,23 @@ export function createTaskSessionManagerHook(
|
|
|
if (!isObjectRecord(output.args)) return;
|
|
if (!isObjectRecord(output.args)) return;
|
|
|
|
|
|
|
|
const args = output.args as TaskArgs;
|
|
const args = output.args as TaskArgs;
|
|
|
- if (!isAgentName(args.subagent_type)) {
|
|
|
|
|
|
|
+ if (
|
|
|
|
|
+ typeof args.subagent_type !== 'string' ||
|
|
|
|
|
+ args.subagent_type.trim() === ''
|
|
|
|
|
+ ) {
|
|
|
if (typeof args.task_id === 'string' && args.task_id.trim() !== '') {
|
|
if (typeof args.task_id === 'string' && args.task_id.trim() !== '') {
|
|
|
delete args.task_id;
|
|
delete args.task_id;
|
|
|
}
|
|
}
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ const agentType = args.subagent_type.trim();
|
|
|
|
|
+
|
|
|
const label = deriveTaskSessionLabel({
|
|
const label = deriveTaskSessionLabel({
|
|
|
description:
|
|
description:
|
|
|
typeof args.description === 'string' ? args.description : undefined,
|
|
typeof args.description === 'string' ? args.description : undefined,
|
|
|
prompt: typeof args.prompt === 'string' ? args.prompt : undefined,
|
|
prompt: typeof args.prompt === 'string' ? args.prompt : undefined,
|
|
|
- agentType: args.subagent_type,
|
|
|
|
|
|
|
+ agentType,
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
const pendingCall: PendingTaskCall = {
|
|
const pendingCall: PendingTaskCall = {
|
|
@@ -512,7 +500,7 @@ export function createTaskSessionManagerHook(
|
|
|
sessionID: input.sessionID,
|
|
sessionID: input.sessionID,
|
|
|
}),
|
|
}),
|
|
|
parentSessionId: input.sessionID,
|
|
parentSessionId: input.sessionID,
|
|
|
- agentType: args.subagent_type,
|
|
|
|
|
|
|
+ agentType,
|
|
|
label,
|
|
label,
|
|
|
};
|
|
};
|
|
|
rememberPendingCall(pendingCall);
|
|
rememberPendingCall(pendingCall);
|
|
@@ -525,7 +513,7 @@ export function createTaskSessionManagerHook(
|
|
|
const remembered = backgroundJobBoard.resolveReusable(
|
|
const remembered = backgroundJobBoard.resolveReusable(
|
|
|
input.sessionID,
|
|
input.sessionID,
|
|
|
requested,
|
|
requested,
|
|
|
- args.subagent_type,
|
|
|
|
|
|
|
+ agentType,
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
if (!remembered) {
|
|
if (!remembered) {
|