🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
✨ feat(goal): unify goal creation flow (#18091)
Arvin Xudc976694d0d4
diff --git a/apps/server/src/services/aiAgent/__tests__/execAgent.pinnedSkillContent.test.ts b/apps/server/src/services/aiAgent/__tests__/execAgent.pinnedSkillContent.test.tsindex 810bdffe262..343f9a0aa04 100644--- a/apps/server/src/services/aiAgent/__tests__/execAgent.pinnedSkillContent.test.ts+++ b/apps/server/src/services/aiAgent/__tests__/execAgent.pinnedSkillContent.test.ts@@ -186,6 +186,16 @@ const operationSkillSetArg = () =>}| undefined;+const toolsEngineConfigArg = () =>+ mockCreateServerAgentToolsEngine.mock.calls[0][1] as+ | {+ agentConfig: {+ chatConfig?: { toolMode?: string };+ plugins: string[];+ };+ }+ | undefined;+const skillById = (identifier: string) =>operationSkillSetArg()?.skills.find((s) => s.identifier === identifier);@@ -299,6 +309,49 @@ describe('AiAgentService.execAgent - pinned skill content injection', () => {expect(mockSkillFindByIds).toHaveBeenCalledWith([]);});+ it('enables the goal tool for a direct server /goal prompt', async () => {+ mockGetAgentConfig.mockResolvedValue({+ chatConfig: {},+ id: 'agent-1',+ model: 'gpt-4',+ plugins: [],+ provider: 'openai',+ systemRole: 'You are a helper',+ });++ await service.execAgent({ agentId: 'agent-1', prompt: '/goal ship it' } as any);++ expect(operationSkillSetArg()?.enabledPluginIds).toContain('lobe-goal');+ expect(operationSkillSetArg()?.enabledPluginIds).not.toContain('lobe-task');+ expect(toolsEngineConfigArg()?.agentConfig).toEqual({+ chatConfig: { toolMode: 'custom' },+ plugins: ['lobe-goal'],+ });+ });++ it('isolates a direct server /goal prompt from pinned and selected tools', async () => {+ mockGetAgentConfig.mockResolvedValue({+ chatConfig: { toolMode: 'agent' },+ id: 'agent-1',+ model: 'gpt-4',+ plugins: ['lobe-agent', 'pinned-tool'],+ provider: 'openai',+ systemRole: 'You are a helper',+ });++ await service.execAgent({+ agentId: 'agent-1',+ prompt: '/goal ship it',+ selectedToolIds: ['selected-tool'],+ } as any);++ expect(operationSkillSetArg()?.enabledPluginIds).toEqual(['lobe-goal']);+ expect(toolsEngineConfigArg()?.agentConfig).toEqual({+ chatConfig: { toolMode: 'custom' },+ plugins: ['lobe-goal'],+ });+ });+it('does not eager-inject an auto skill whose identifier collides with a turn-scoped tool id', async () => {mockGetAgentConfig.mockResolvedValue({chatConfig: {},diff --git a/apps/server/src/services/aiAgent/index.ts b/apps/server/src/services/aiAgent/index.tsindex dbf7ce1d88d..20dc292c178 100644--- a/apps/server/src/services/aiAgent/index.ts+++ b/apps/server/src/services/aiAgent/index.ts@@ -12,6 +12,7 @@ import {import { BUILTIN_AGENT_SLUGS, getAgentRuntimeConfig } from '@lobechat/builtin-agents';import { builtinSkills } from '@lobechat/builtin-skills';import { CloudSandboxManifest } from '@lobechat/builtin-tool-cloud-sandbox';+import { GoalIdentifier, isGoalPrompt } from '@lobechat/builtin-tool-goal';import { LobeAgentIdentifier, LobeAgentManifest } from '@lobechat/builtin-tool-lobe-agent';import { getShellSyntaxGuidance, LocalSystemManifest } from '@lobechat/builtin-tool-local-system';import { MessageToolIdentifier } from '@lobechat/builtin-tool-message';@@ -2850,14 +2851,17 @@ export class AiAgentService {// (deduped) alongside the agent's pinned plugins and any internal// `additionalPluginIds` so a mentioned-but-not-pinned tool (e.g. a custom MCP// connector) is both queried for manifests and enabled by the tools engine.- let agentPlugins: string[] = [- ...new Set([- ...getActivePluginIds(agentConfig?.plugins),- ...(additionalPluginIds || []),- ...(selectedToolIds || []),- ...(hasMentionedAgents ? ['lobe-agent-management'] : []),- ]),- ];+ const isGoalTurn = isGoalPrompt(prompt);+ let agentPlugins: string[] = isGoalTurn+ ? [GoalIdentifier]+ : [+ ...new Set([+ ...getActivePluginIds(agentConfig?.plugins),+ ...(additionalPluginIds || []),+ ...(selectedToolIds || []),+ ...(hasMentionedAgents ? ['lobe-agent-management'] : []),+ ]),+ ];// Model metadata is needed both for tool support checks and agent-management context.const { loadModels } = await import('@/business/client/model-bank/loadModels');@@ -3441,7 +3445,9 @@ export class AiAgentService {...activeConnectorManifests,],agentConfig: {- chatConfig: agentConfig.chatConfig ?? undefined,+ chatConfig: isGoalTurn+ ? { ...agentConfig.chatConfig, toolMode: 'custom' }+ : (agentConfig.chatConfig ?? undefined),plugins: agentPlugins,},canUseDevice,diff --git a/apps/server/src/services/toolExecution/serverRuntimes/index.ts b/apps/server/src/services/toolExecution/serverRuntimes/index.tsindex f34d80f8ed9..b22fdd7477c 100644--- a/apps/server/src/services/toolExecution/serverRuntimes/index.ts+++ b/apps/server/src/services/toolExecution/serverRuntimes/index.ts@@ -6,6 +6,8 @@* - Pre-instantiated runtimes (e.g., WebBrowsing - no per-request context needed)* - Per-request runtimes (e.g., CloudSandbox - needs topicId, userId)*/+import { GoalIdentifier } from '@lobechat/builtin-tool-goal';+import type { ToolExecutionContext } from '../types';import { activatorRuntime } from './activator';import { agentBuilderRuntime } from './agentBuilder';@@ -43,6 +45,14 @@ import { verifyResultRuntime } from './verifyResult';import { webBrowsingRuntime } from './webBrowsing';import { webOnboardingRuntime } from './webOnboarding';+const goalRuntime: ServerRuntimeRegistration = {+ factory: async (context) => {+ const runtime = await taskRuntime.factory(context);+ return { createGoal: runtime.createGoal };+ },+ identifier: GoalIdentifier,+};+/*** Registry of server runtime factories by identifier*/@@ -81,6 +91,7 @@ registerRuntimes([userInteractionRuntime,credsRuntime,groupManagementRuntime,+ goalRuntime,imageGenerationRuntime,knowledgeBaseRuntime,webOnboardingRuntime,diff --git a/locales/en-US/editor.json b/locales/en-US/editor.jsonindex 52f2d512c33..2fdc26d768a 100644--- a/locales/en-US/editor.json+++ b/locales/en-US/editor.json@@ -64,6 +64,8 @@"skillFrontmatter.saveFailed": "Metadata was not saved. Retry, or keep editing.","skillFrontmatter.title": "Skill metadata","slash.compact": "Compact context",+ "slash.goal": "Set goal",+ "slash.goal.desc": "Plan and start a goal with editable acceptance criteria","slash.h1": "Heading 1","slash.h2": "Heading 2","slash.h3": "Heading 3",diff --git a/locales/en-US/plugin.json b/locales/en-US/plugin.jsonindex d42e6817a29..7d4dc533f51 100644--- a/locales/en-US/plugin.json+++ b/locales/en-US/plugin.json@@ -228,6 +228,7 @@"builtins.lobe-delivery-checker.verifyPlan.portal.verifier.program.title": "Program check","builtins.lobe-delivery-checker.verifyPlan.portal.verifier.title": "Verification method","builtins.lobe-delivery-checker.verifyPlan.required": "Required",+ "builtins.lobe-goal.apiName.createGoal": "Start goal","builtins.lobe-group-agent-builder.apiName.batchCreateAgents": "Batch create agents","builtins.lobe-group-agent-builder.apiName.createAgent": "Create agent","builtins.lobe-group-agent-builder.apiName.createGroup": "Create group",diff --git a/locales/zh-CN/editor.json b/locales/zh-CN/editor.jsonindex 4a34949c2e8..188b8515f23 100644--- a/locales/zh-CN/editor.json+++ b/locales/zh-CN/editor.json@@ -64,6 +64,8 @@"skillFrontmatter.saveFailed": "元信息未保存。请重试,或继续编辑。","skillFrontmatter.title": "技能元信息","slash.compact": "压缩上下文",+ "slash.goal": "设定目标",+ "slash.goal.desc": "规划并启动带有可编辑验收标准的目标","slash.h1": "一级标题","slash.h2": "二级标题","slash.h3": "三级标题",diff --git a/locales/zh-CN/plugin.json b/locales/zh-CN/plugin.jsonindex 26d46c21814..3b30d8a80b4 100644--- a/locales/zh-CN/plugin.json+++ b/locales/zh-CN/plugin.json@@ -228,6 +228,7 @@"builtins.lobe-delivery-checker.verifyPlan.portal.verifier.program.title": "程序化检查","builtins.lobe-delivery-checker.verifyPlan.portal.verifier.title": "检查方式","builtins.lobe-delivery-checker.verifyPlan.required": "必选",+ "builtins.lobe-goal.apiName.createGoal": "启动目标","builtins.lobe-group-agent-builder.apiName.batchCreateAgents": "批量创建 Agent","builtins.lobe-group-agent-builder.apiName.createAgent": "创建助理","builtins.lobe-group-agent-builder.apiName.createGroup": "创建群组",diff --git a/package.json b/package.jsonindex c69ef2d6d6a..3a6223cf4c4 100644--- a/package.json+++ b/package.json@@ -234,6 +234,7 @@"@lobechat/builtin-tool-claude-code": "workspace:*","@lobechat/builtin-tool-cloud-sandbox": "workspace:*","@lobechat/builtin-tool-creds": "workspace:*",+ "@lobechat/builtin-tool-goal": "workspace:*","@lobechat/builtin-tool-group-agent-builder": "workspace:*","@lobechat/builtin-tool-group-management": "workspace:*","@lobechat/builtin-tool-image-generation": "workspace:*",diff --git a/packages/builtin-tool-goal/package.json b/packages/builtin-tool-goal/package.jsonnew file mode 100644index 00000000000..7c173133177--- /dev/null+++ b/packages/builtin-tool-goal/package.json@@ -0,0 +1,20 @@+{+ "name": "@lobechat/builtin-tool-goal",+ "version": "1.0.0",+ "private": true,+ "exports": {+ ".": "./src/index.ts",+ "./client": "./src/client/index.ts",+ "./client/executor": "./src/client/executor/index.ts"+ },+ "main": "./src/index.ts",+ "dependencies": {+ "@lobechat/builtin-tool-task": "workspace:*"+ },+ "devDependencies": {+ "@lobechat/types": "workspace:*"+ },+ "peerDependencies": {+ "react": "*"+ }+}diff --git a/packages/builtin-tool-goal/src/client/executor/index.ts b/packages/builtin-tool-goal/src/client/executor/index.tsnew file mode 100644index 00000000000..9a642b4bcbd--- /dev/null+++ b/packages/builtin-tool-goal/src/client/executor/index.ts@@ -0,0 +1,23 @@+import { taskExecutor } from '@lobechat/builtin-tool-task/client/executor';+import type { BuiltinToolContext, BuiltinToolResult, ToolAfterCallContext } from '@lobechat/types';+import { BaseExecutor } from '@lobechat/types';++import { GoalIdentifier } from '../../manifest';+import type { CreateGoalParams } from '../../types';+import { GoalApiName } from '../../types';++class GoalExecutor extends BaseExecutor<typeof GoalApiName> {+ readonly identifier = GoalIdentifier;+ protected readonly apiEnum = GoalApiName;++ onAfterCall = async (context: ToolAfterCallContext): Promise<void> => {+ await taskExecutor.onAfterCall(context);+ };++ createGoal = async (+ params: CreateGoalParams,+ context?: BuiltinToolContext,+ ): Promise<BuiltinToolResult> => taskExecutor.createGoal(params, context);+}++export const goalExecutor = new GoalExecutor();diff --git a/packages/builtin-tool-goal/src/client/index.ts b/packages/builtin-tool-goal/src/client/index.tsnew file mode 100644index 00000000000..94a07ab627b--- /dev/null+++ b/packages/builtin-tool-goal/src/client/index.ts@@ -0,0 +1,24 @@+import {+ CreateGoalInspector,+ CreateGoalRender,+ TaskInterventions,+} from '@lobechat/builtin-tool-task/client';+import type { BuiltinInspector, BuiltinIntervention, BuiltinRender } from '@lobechat/types';++import { GoalIdentifier, GoalManifest } from '../manifest';+import { GoalApiName } from '../types';++export const GoalInspectors: Record<string, BuiltinInspector> = {+ [GoalApiName.createGoal]: CreateGoalInspector as BuiltinInspector,+};++export const GoalInterventions: Record<string, BuiltinIntervention> = {+ [GoalApiName.createGoal]: TaskInterventions.createGoal as BuiltinIntervention,+};++export const GoalRenders: Record<string, BuiltinRender> = {+ [GoalApiName.createGoal]: CreateGoalRender as BuiltinRender,+};++export { GoalIdentifier, GoalManifest };+export * from '../types';diff --git a/packages/builtin-tool-goal/src/goalPrompt.test.ts b/packages/builtin-tool-goal/src/goalPrompt.test.tsnew file mode 100644index 00000000000..5be12920efd--- /dev/null+++ b/packages/builtin-tool-goal/src/goalPrompt.test.ts@@ -0,0 +1,16 @@+import { describe, expect, it } from 'vitest';++import { isGoalPrompt } from './goalPrompt';++describe('isGoalPrompt', () => {+ it.each(['/goal ship it', ' /goal\nship it', '/GOAL ship it'])('matches %j', (prompt) => {+ expect(isGoalPrompt(prompt)).toBe(true);+ });++ it.each(['/goals ship it', 'please /goal ship it', '', undefined])(+ 'does not match %j',+ (prompt) => {+ expect(isGoalPrompt(prompt)).toBe(false);+ },+ );+});diff --git a/packages/builtin-tool-goal/src/goalPrompt.ts b/packages/builtin-tool-goal/src/goalPrompt.tsnew file mode 100644index 00000000000..0f2917d4e88--- /dev/null+++ b/packages/builtin-tool-goal/src/goalPrompt.ts@@ -0,0 +1,5 @@+const GOAL_COMMAND_PATTERN = /^\s*\/goal(?:\s|$)/i;++/** Whether a user prompt explicitly requests the canonical goal workflow. */+export const isGoalPrompt = (prompt: unknown): boolean =>+ typeof prompt === 'string' && GOAL_COMMAND_PATTERN.test(prompt);diff --git a/packages/builtin-tool-goal/src/index.ts b/packages/builtin-tool-goal/src/index.tsnew file mode 100644index 00000000000..5f969bceccf--- /dev/null+++ b/packages/builtin-tool-goal/src/index.ts@@ -0,0 +1,4 @@+export { isGoalPrompt } from './goalPrompt';+export { GoalIdentifier, GoalManifest } from './manifest';+export { systemPrompt } from './systemRole';+export * from './types';diff --git a/packages/builtin-tool-goal/src/manifest.test.ts b/packages/builtin-tool-goal/src/manifest.test.tsnew file mode 100644index 00000000000..172a35be613--- /dev/null+++ b/packages/builtin-tool-goal/src/manifest.test.ts@@ -0,0 +1,13 @@+import { describe, expect, it } from 'vitest';++import { GoalManifest } from './manifest';+import { GoalApiName } from './types';++describe('GoalManifest', () => {+ it('exposes only the canonical createGoal workflow', () => {+ expect(GoalManifest.identifier).toBe('lobe-goal');+ expect(GoalManifest.api.map(({ name }) => name)).toEqual([GoalApiName.createGoal]);+ expect(GoalManifest.api[0].humanIntervention).toBe('required');+ expect(GoalManifest.api[0].work).toBeUndefined();+ });+});diff --git a/packages/builtin-tool-goal/src/manifest.ts b/packages/builtin-tool-goal/src/manifest.tsnew file mode 100644index 00000000000..4094e31470c--- /dev/null+++ b/packages/builtin-tool-goal/src/manifest.ts@@ -0,0 +1,66 @@+import type { BuiltinToolManifest } from '@lobechat/types';++import { systemPrompt } from './systemRole';+import { GoalApiName } from './types';++export const GoalIdentifier = 'lobe-goal';++export const GoalManifest: BuiltinToolManifest = {+ api: [+ {+ description:+ 'Create and immediately start a goal-driven task with an editable acceptance plan. Use this only when the user explicitly starts their request with /goal. The call pauses for confirmation; after approval it creates the underlying task, persists the acceptance criteria, enables bounded automatic repair, and runs the current agent in a separate task topic. Once it succeeds, do not execute or reproduce the work in the current conversation; the live result card is the progress and result entry point.',+ humanIntervention: 'required',+ name: GoalApiName.createGoal,+ parameters: {+ additionalProperties: false,+ properties: {+ criteria: {+ description:+ 'Concrete acceptance criteria derived from every explicit user requirement.',+ items: {+ additionalProperties: false,+ properties: {+ description: { type: 'string' },+ instruction: {+ description: 'Detailed judging instruction. Omit for program checks.',+ type: 'string',+ },+ onFail: { enum: ['auto_repair', 'manual'], type: 'string' },+ required: { type: 'boolean' },+ title: { type: 'string' },+ verifierConfig: { type: 'object' },+ verifierType: { enum: ['agent', 'llm', 'program'], type: 'string' },+ },+ required: ['title'],+ type: 'object',+ },+ type: 'array',+ },+ instruction: { description: 'Detailed task direction and constraints.', type: 'string' },+ maxIterations: {+ description:+ 'Maximum automatic execution/repair rounds. Default 3, minimum 2. Null means no user-specified cap.',+ type: ['number', 'null'],+ },+ maxTotalCost: {+ description: 'Optional total USD budget. Null means no user-specified cap.',+ type: ['number', 'null'],+ },+ name: { description: 'Short goal title.', type: 'string' },+ },+ required: ['name', 'instruction', 'criteria'],+ type: 'object',+ },+ renderDisplayControl: 'expand',+ },+ ],+ identifier: GoalIdentifier,+ meta: {+ avatar: '🎯',+ description: 'Plan and start goals with editable acceptance criteria',+ title: 'Goal',+ },+ systemRole: systemPrompt,+ type: 'builtin',+};diff --git a/packages/builtin-tool-goal/src/systemRole.test.ts b/packages/builtin-tool-goal/src/systemRole.test.tsnew file mode 100644index 00000000000..6dc8f25ebb6--- /dev/null+++ b/packages/builtin-tool-goal/src/systemRole.test.ts@@ -0,0 +1,13 @@+import { describe, expect, it } from 'vitest';++import { systemPrompt } from './systemRole';++describe('Goal systemPrompt', () => {+ it('hands successful goal execution off instead of duplicating it', () => {+ expect(systemPrompt).toContain('the work has been handed off to a separate task topic');+ expect(systemPrompt).toContain(+ 'do not perform, reproduce, preview, or self-check the requested work in the current conversation',+ );+ expect(systemPrompt).toContain('its live card shows progress');+ });+});diff --git a/packages/builtin-tool-goal/src/systemRole.ts b/packages/builtin-tool-goal/src/systemRole.tsnew file mode 100644index 00000000000..309d425c312--- /dev/null+++ b/packages/builtin-tool-goal/src/systemRole.ts@@ -0,0 +1,3 @@+export const systemPrompt = `You have access to the Goal tool.++- **createGoal**: When — and only when — the user's message starts with \`/goal\`, turn the request into one editable goal plan and call createGoal before doing any substantive work. Use the current agent implicitly. Derive one concrete criterion per explicit requirement, default failed criteria to auto_repair, default maxIterations to 3, and omit maxTotalCost unless the user set one. The user confirms or edits the complete plan before the task starts. After createGoal succeeds, the work has been handed off to a separate task topic: do not perform, reproduce, preview, or self-check the requested work in the current conversation. End the turn with at most one brief sentence saying the goal is running and its live card shows progress.`;diff --git a/packages/builtin-tool-goal/src/types.ts b/packages/builtin-tool-goal/src/types.tsnew file mode 100644index 00000000000..f70f9d98f97--- /dev/null+++ b/packages/builtin-tool-goal/src/types.ts@@ -0,0 +1,11 @@+export type {+ CreateGoalParams,+ CreateGoalState,+ GoalCriterionDraft,+} from '@lobechat/builtin-tool-task';++export const GoalApiName = {+ createGoal: 'createGoal',+} as const;++export type GoalApiNameType = (typeof GoalApiName)[keyof typeof GoalApiName];diff --git a/packages/builtin-tool-goal/vitest.config.mts b/packages/builtin-tool-goal/vitest.config.mtsnew file mode 100644index 00000000000..9e935ef21d1--- /dev/null+++ b/packages/builtin-tool-goal/vitest.config.mts@@ -0,0 +1,18 @@+import path from 'node:path';+import { fileURLToPath } from 'node:url';++import { defineConfig } from 'vitest/config';++const packageDir = path.dirname(fileURLToPath(import.meta.url));+const repoRoot = path.resolve(packageDir, '../..');++export default defineConfig({+ resolve: {+ alias: {+ '@': path.resolve(repoRoot, 'src'),+ },+ },+ test: {+ environment: 'happy-dom',+ },+});diff --git a/packages/builtin-tool-task/src/client/Inspector/CreateGoal/index.tsx b/packages/builtin-tool-task/src/client/Inspector/CreateGoal/index.tsxindex 4ffc01e99d2..d8f4ed38e36 100644--- a/packages/builtin-tool-task/src/client/Inspector/CreateGoal/index.tsx+++ b/packages/builtin-tool-task/src/client/Inspector/CreateGoal/index.tsx@@ -21,7 +21,7 @@ const CreateGoalInspector = memo<BuiltinInspectorProps<CreateGoalParams, CreateG(isArgumentsStreaming || isLoading) && shinyTextStyles.shinyText,)}>- <span>{t('builtins.lobe-task.apiName.createGoal')}</span>+ <span>{t('builtins.lobe-goal.apiName.createGoal')}</span>{name && <span> · {name}</span>}</div>);diff --git a/packages/builtin-tool-task/src/index.ts b/packages/builtin-tool-task/src/index.tsindex 3c4ef3ffa23..9a697a9a168 100644--- a/packages/builtin-tool-task/src/index.ts+++ b/packages/builtin-tool-task/src/index.ts@@ -6,5 +6,5 @@ export {} from './listTasks';export { TaskIdentifier, TaskManifest } from './manifest';export { systemPrompt } from './systemRole';-export type { CreateGoalParams, GoalCriterionDraft } from './types';+export type { CreateGoalParams, CreateGoalState, GoalCriterionDraft } from './types';export { TaskApiName } from './types';diff --git a/packages/builtin-tool-task/src/manifest.test.ts b/packages/builtin-tool-task/src/manifest.test.tsindex 4c281d54a19..41f9bab6829 100644--- a/packages/builtin-tool-task/src/manifest.test.ts+++ b/packages/builtin-tool-task/src/manifest.test.ts@@ -4,11 +4,10 @@ import { TaskManifest } from './manifest';import { TaskApiName } from './types';describe('TaskManifest Work semantics', () => {- it('keeps Goal as a virtual message artifact instead of a persisted Work', () => {- const createGoal = TaskManifest.api.find((api) => api.name === TaskApiName.createGoal);+ it('keeps goal orchestration outside the task tool scope', () => {const createTask = TaskManifest.api.find((api) => api.name === TaskApiName.createTask);- expect(createGoal?.work).toBeUndefined();+ expect(TaskManifest.api.some((api) => api.name === TaskApiName.createGoal)).toBe(false);expect(createTask?.work).toEqual({ action: 'create', resourceType: 'task' });});});diff --git a/packages/builtin-tool-task/src/manifest.ts b/packages/builtin-tool-task/src/manifest.tsindex d7edc42a047..5093a3855ee 100644--- a/packages/builtin-tool-task/src/manifest.ts+++ b/packages/builtin-tool-task/src/manifest.ts@@ -10,51 +10,6 @@ export const TaskIdentifier = 'lobe-task';export const TaskManifest: BuiltinToolManifest = {api: [// ==================== Task CRUD ====================- {- description:- 'Create and immediately start a goal-driven task with an editable acceptance plan. Use this only when the user explicitly starts their request with /goal. The call pauses for confirmation; after approval it creates the task, persists the acceptance criteria, enables bounded automatic repair, and runs the current agent in a separate task topic. Once it succeeds, do not execute or reproduce the work in the current conversation; the live result card is the progress and result entry point.',- humanIntervention: 'required',- name: TaskApiName.createGoal,- parameters: {- properties: {- criteria: {- description:- 'Concrete acceptance criteria derived from every explicit user requirement.',- items: {- properties: {- description: { type: 'string' },- instruction: {- description: 'Detailed judging instruction. Omit for program checks.',- type: 'string',- },- onFail: { enum: ['auto_repair', 'manual'], type: 'string' },- required: { type: 'boolean' },- title: { type: 'string' },- verifierConfig: { type: 'object' },- verifierType: { enum: ['agent', 'llm', 'program'], type: 'string' },- },- required: ['title'],- type: 'object',- },- type: 'array',- },- instruction: { description: 'Detailed task direction and constraints.', type: 'string' },- maxIterations: {- description:- 'Maximum automatic execution/repair rounds. Default 3, minimum 2. Null means no user-specified cap.',- type: ['number', 'null'],- },- maxTotalCost: {- description: 'Optional total USD budget. Null means no user-specified cap.',- type: ['number', 'null'],- },- name: { description: 'Short task title.', type: 'string' },- },- required: ['name', 'instruction', 'criteria'],- type: 'object',- },- renderDisplayControl: 'expand',- },{description:'Create a new task. Optionally attach it as a subtask by specifying parentIdentifier.',diff --git a/packages/builtin-tool-task/src/systemRole.test.ts b/packages/builtin-tool-task/src/systemRole.test.tsindex 608c0cb15dd..d1a42605f1e 100644--- a/packages/builtin-tool-task/src/systemRole.test.ts+++ b/packages/builtin-tool-task/src/systemRole.test.ts@@ -3,12 +3,8 @@ import { describe, expect, it } from 'vitest';import { systemPrompt } from './systemRole';describe('systemPrompt', () => {- it('hands successful goal execution off instead of duplicating it in the origin conversation', () => {- expect(systemPrompt).toContain('the work has been handed off to a separate task topic');- expect(systemPrompt).toContain(- 'do not perform, reproduce, preview, or self-check the requested work in the current conversation',- );- expect(systemPrompt).toContain('its live card shows progress');+ it('does not instruct the task tool to run the goal workflow', () => {+ expect(systemPrompt).not.toContain('**createGoal**');});it('starts a configured cron schedule by default without running it immediately', () => {diff --git a/packages/builtin-tool-task/src/systemRole.ts b/packages/builtin-tool-task/src/systemRole.tsindex 58274226d14..8f621701c09 100644--- a/packages/builtin-tool-task/src/systemRole.ts+++ b/packages/builtin-tool-task/src/systemRole.ts@@ -1,6 +1,5 @@export const systemPrompt = `You have access to Task management tools. Use them to:-- **createGoal**: When — and only when — the user's message starts with \`/goal\`, turn the request into one editable goal plan and call createGoal before doing any substantive work. Use the current agent implicitly. Derive one concrete criterion per explicit requirement, default failed criteria to auto_repair, default maxIterations to 3, and omit maxTotalCost unless the user set one. The user confirms or edits the complete plan before the task starts. Do not call createTask/setTaskVerify/runTask separately for a /goal request. After createGoal succeeds, the work has been handed off to a separate task topic: do not perform, reproduce, preview, or self-check the requested work in the current conversation. End the turn with at most one brief sentence saying the goal is running and its live card shows progress- **createTask**: Create a new task. Use parentIdentifier to make it a subtask- **createTasks**: Create multiple tasks in one call. Prefer this when you are about to create more than one task in a row (e.g. all subtasks under one parent, or all chapters of an outline) — it cuts the number of tool calls and keeps the batch atomic from the user's perspective- **listTasks**: List tasks. With no filters, defaults to top-level unfinished tasks of the current agent in normal agent conversations, or top-level unfinished tasks across all agents in task manager conversations. If you provide any filter, omitted filters are not applied implicitlydiff --git a/packages/builtin-tools/package.json b/packages/builtin-tools/package.jsonindex 49d617ded1c..a46ae05f070 100644--- a/packages/builtin-tools/package.json+++ b/packages/builtin-tools/package.json@@ -31,6 +31,7 @@"@lobechat/builtin-tool-claude-code": "workspace:*","@lobechat/builtin-tool-cloud-sandbox": "workspace:*","@lobechat/builtin-tool-creds": "workspace:*",+ "@lobechat/builtin-tool-goal": "workspace:*","@lobechat/builtin-tool-group-agent-builder": "workspace:*","@lobechat/builtin-tool-group-management": "workspace:*","@lobechat/builtin-tool-image-generation": "workspace:*",diff --git a/packages/builtin-tools/src/identifiers.ts b/packages/builtin-tools/src/identifiers.tsindex 89106a7b274..6257581f466 100644--- a/packages/builtin-tools/src/identifiers.ts+++ b/packages/builtin-tools/src/identifiers.ts@@ -12,6 +12,7 @@ import { BrowserManifest } from '@lobechat/builtin-tool-browser';import { CalculatorManifest } from '@lobechat/builtin-tool-calculator/manifest';import { CloudSandboxManifest } from '@lobechat/builtin-tool-cloud-sandbox';import { CredsManifest } from '@lobechat/builtin-tool-creds';+import { GoalManifest } from '@lobechat/builtin-tool-goal';import { GroupAgentBuilderManifest } from '@lobechat/builtin-tool-group-agent-builder';import { GroupManagementManifest } from '@lobechat/builtin-tool-group-management';import { ImageGenerationManifest } from '@lobechat/builtin-tool-image-generation';@@ -40,6 +41,7 @@ export const builtinToolIdentifiers: string[] = [CredsManifest.identifier,GroupAgentBuilderManifest.identifier,GroupManagementManifest.identifier,+ GoalManifest.identifier,ImageGenerationManifest.identifier,KnowledgeBaseManifest.identifier,BrowserManifest.identifier,diff --git a/packages/builtin-tools/src/index.ts b/packages/builtin-tools/src/index.tsindex fa2cbedfe08..9c38e2792eb 100644--- a/packages/builtin-tools/src/index.ts+++ b/packages/builtin-tools/src/index.ts@@ -13,6 +13,7 @@ import { BrowserManifest } from '@lobechat/builtin-tool-browser';import { CalculatorManifest } from '@lobechat/builtin-tool-calculator/manifest';import { CloudSandboxManifest } from '@lobechat/builtin-tool-cloud-sandbox';import { CredsManifest } from '@lobechat/builtin-tool-creds';+import { GoalManifest } from '@lobechat/builtin-tool-goal';import { GroupAgentBuilderManifest } from '@lobechat/builtin-tool-group-agent-builder';import { GroupManagementManifest } from '@lobechat/builtin-tool-group-management';import { ImageGenerationManifest } from '@lobechat/builtin-tool-image-generation';@@ -362,6 +363,13 @@ const builtinToolRegistry: LobeBuiltinTool[] = [manifest: UserInteractionManifest,type: 'builtin',},+ {+ discoverable: false,+ hidden: true,+ identifier: GoalManifest.identifier,+ manifest: GoalManifest,+ type: 'builtin',+ },{identifier: TaskManifest.identifier,manifest: TaskManifest,diff --git a/packages/builtin-tools/src/register.ts b/packages/builtin-tools/src/register.tsindex 9a564a2bbef..9321c784c89 100644--- a/packages/builtin-tools/src/register.ts+++ b/packages/builtin-tools/src/register.ts@@ -37,6 +37,12 @@ import {CloudSandboxRenders,CloudSandboxStreamings,} from '@lobechat/builtin-tool-cloud-sandbox/client';+import {+ GoalInspectors,+ GoalInterventions,+ GoalManifest,+ GoalRenders,+} from '@lobechat/builtin-tool-goal/client';import {GroupAgentBuilderInspectors,GroupAgentBuilderManifest,@@ -223,6 +229,7 @@ export const registerBuiltinToolSurfaces = (): void => {BuiltinRender>,[GroupManagementManifest.identifier]: GroupManagementRenders as Record<string, BuiltinRender>,+ [GoalManifest.identifier]: GoalRenders as Record<string, BuiltinRender>,[ImageGenerationManifest.identifier]: ImageGenerationRenders as Record<string, BuiltinRender>,[KnowledgeBaseManifest.identifier]: KnowledgeBaseRenders as Record<string, BuiltinRender>,[LobeAgentManifest.identifier]: LobeAgentRenders as Record<string, BuiltinRender>,@@ -275,6 +282,7 @@ export const registerBuiltinToolSurfaces = (): void => {string,BuiltinInspector>,+ [GoalManifest.identifier]: GoalInspectors as Record<string, BuiltinInspector>,[ImageGenerationManifest.identifier]: ImageGenerationInspectors as Record<string,BuiltinInspector@@ -354,6 +362,7 @@ export const registerBuiltinToolSurfaces = (): void => {string,BuiltinIntervention>,+ [GoalManifest.identifier]: GoalInterventions as Record<string, BuiltinIntervention>,[LobeAgentManifest.identifier]: LobeAgentInterventions as Record<string, BuiltinIntervention>,[LocalSystemIdentifier]: LocalSystemInterventions as Record<string, BuiltinIntervention>,[MemoryManifest.identifier]: MemoryInterventions as Record<string, BuiltinIntervention>,diff --git a/packages/locales/src/default/editor.ts b/packages/locales/src/default/editor.tsindex 361de75e4f1..4c67886c15a 100644--- a/packages/locales/src/default/editor.ts+++ b/packages/locales/src/default/editor.ts@@ -55,6 +55,8 @@ export default {'actionTag.tooltip.skill': 'Loads a reusable skill package for this request.','actionTag.tooltip.tool': 'Marks a tool the user explicitly selected for this request.','slash.compact': 'Compact context',+ 'slash.goal': 'Set goal',+ 'slash.goal.desc': 'Plan and start a goal with editable acceptance criteria','slash.h1': 'Heading 1','slash.h2': 'Heading 2','slash.h3': 'Heading 3',diff --git a/packages/locales/src/default/plugin.ts b/packages/locales/src/default/plugin.tsindex 523a1937a87..7f9c084869b 100644--- a/packages/locales/src/default/plugin.ts+++ b/packages/locales/src/default/plugin.ts@@ -423,6 +423,7 @@ export default {'builtins.lobe-skills.title': 'Skills','builtins.lobe-task.apiName.createTask': 'Create task','builtins.lobe-task.apiName.createGoal': 'Start goal',+ 'builtins.lobe-goal.apiName.createGoal': 'Start goal','builtins.lobe-task.apiName.createTasks': 'Create tasks','builtins.lobe-task.apiName.addTaskComment': 'Add comment','builtins.lobe-task.apiName.deleteTask': 'Delete task',diff --git a/src/features/ChatInput/ActionBar/GoalModeChip.tsx b/src/features/ChatInput/ActionBar/GoalModeChip.tsxnew file mode 100644index 00000000000..37ec8ad1fec--- /dev/null+++ b/src/features/ChatInput/ActionBar/GoalModeChip.tsx@@ -0,0 +1,58 @@+'use client';++import { ActionIcon, Flexbox, Icon, Text } from '@lobehub/ui';+import { createStaticStyles, cssVar } from 'antd-style';+import { TargetIcon, XIcon } from 'lucide-react';+import { memo } from 'react';+import { useTranslation } from 'react-i18next';++import { useChatInputStore } from '../store';++const styles = createStaticStyles(({ css }) => ({+ chip: css`+ flex: none;++ height: 28px;+ padding-inline: 8px 4px;+ border-radius: 14px;++ background: ${cssVar.colorInfoBg};+ `,+ label: css`+ font-size: 12px;+ line-height: 1;+ color: ${cssVar.colorInfoText};+ white-space: nowrap;+ `,+}));++/**+ * Visible state for the hidden `/goal` send mode.+ *+ * This deliberately follows the heterogeneous input's armed-action chip+ * contract: it is a separate action-bar item immediately after the control+ * that armed it, and carries its own clear action.+ */+const GoalModeChip = memo(() => {+ const { t } = useTranslation('verify');+ const [goalMode, setGoalMode] = useChatInputStore((s) => [s.goalMode, s.setGoalMode]);++ if (!goalMode) return null;++ return (+ <Flexbox horizontal align={'center'} className={styles.chip} gap={4}>+ <Icon icon={TargetIcon} size={12} style={{ color: cssVar.colorInfoText }} />+ <Text className={styles.label}>{t('acceptance.tray.menuSetGoal')}</Text>+ <ActionIcon+ icon={XIcon}+ size={'small'}+ title={t('acceptance.tray.goalDisarm')}+ onClick={() => setGoalMode(false)}+ />+ </Flexbox>+ );+});++GoalModeChip.displayName = 'GoalModeChip';++export default GoalModeChip;diff --git a/src/features/ChatInput/ActionBar/Plus/index.tsx b/src/features/ChatInput/ActionBar/Plus/index.tsxindex 52b217919e2..99a88ad83da 100644--- a/src/features/ChatInput/ActionBar/Plus/index.tsx+++ b/src/features/ChatInput/ActionBar/Plus/index.tsx@@ -23,7 +23,7 @@ import {TypeIcon,} from 'lucide-react';import type { ReactNode } from 'react';-import { memo, Suspense, useCallback, useEffect, useMemo, useRef, useState } from 'react';+import { Fragment, memo, Suspense, useCallback, useEffect, useMemo, useRef, useState } from 'react';import { useTranslation } from 'react-i18next';import { openAttachKnowledgeModal } from '@/features/LibraryModal';@@ -33,7 +33,6 @@ import { useModelSupportToolUse } from '@/hooks/useModelSupportToolUse';import { useAgentStore } from '@/store/agent';import { agentSelectors, chatConfigByIdSelectors } from '@/store/agent/selectors';import { aiModelSelectors, aiProviderSelectors, useAiInfraStore } from '@/store/aiInfra';-import { useChatStore } from '@/store/chat';import { useFileStore } from '@/store/file';import { useGlobalStore } from '@/store/global';import { systemStatusSelectors } from '@/store/global/selectors';@@ -45,15 +44,15 @@ import {import { useUserStore } from '@/store/user';import { labPreferSelectors, settingsSelectors } from '@/store/user/selectors';-import { useGoalArmStore } from '../../../Conversation/ChatInput/VerifyTray/goalArmStore';-import { openTopicGoalModal } from '../../../Conversation/ChatInput/VerifyTray/useTopicChecklist';import { useAgentId } from '../../hooks/useAgentId';import { useChatInputResourceAccess } from '../../hooks/useChatInputResourceAccess';import { useEffectiveModel } from '../../hooks/useEffectiveModel';import { useUpdateAgentConfig } from '../../hooks/useUpdateAgentConfig';+import { enterGoalMode } from '../../InputEditor/goalMode';import { useChatInputStore } from '../../store';import { type ActionDropdownMenuItems } from '../components/ActionDropdown';import { ChatInputAction } from '../components/ChatInputAction';+import GoalModeChip from '../GoalModeChip';import { useControls as useKnowledgeControls } from '../Knowledge/useControls';import { useMemoryEnabled } from '../Memory/useMemoryEnabled';import { useControls as useToolsControls } from '../Tools/useControls';@@ -296,12 +295,8 @@ const usePlusMenuItems = ({ close }: { close: () => void }): ActionDropdownMenuIconst { canConfigureResource } = useChatInputResourceAccess();const { updateAgentChatConfig } = useUpdateAgentConfig();- // Topic acceptance (lab): a "new acceptance item" entry in the "+" menu, so a- // topic's checklist starts from here instead of an always-on strip above the- // composer. Global stores only — Plus renders on surfaces without conversation- // context.+ // Goal creation is lab-gated while the product surface is being rolled out.const enableTopicAcceptance = useUserStore(labPreferSelectors.enableTopicAcceptance);- const activeTopicId = useChatStore((s) => s.activeTopicId);const upload = useFileStore((s) => s.uploadChatFiles);const { enableKnowledgeBase } = useServerConfigStore(featureFlagsSelectors);@@ -333,6 +328,7 @@ const usePlusMenuItems = ({ close }: { close: () => void }): ActionDropdownMenuIconst isMemoryEnabled = useMemoryEnabled(agentId);const [showTypoBar, setShowTypoBar] = useChatInputStore((s) => [s.showTypoBar, s.setShowTypoBar]);const editor = useChatInputStore((s) => s.editor);+ const setGoalMode = useChatInputStore((s) => s.setGoalMode);const { canUploadImage, canUploadVideo, canUploadAudio } = useMediaUploadAbility(model,provider,@@ -711,9 +707,9 @@ const usePlusMenuItems = ({ close }: { close: () => void }): ActionDropdownMenuI]: uploadItems;- // Before a topic exists there is nothing to persist a goal onto, so the- // entry *arms* the goal (the next message becomes it); once a topic exists- // it opens the editor directly.+ // Goal creation has one canonical entry: put the composer in /goal mode.+ // The agent then plans and calls lobe-goal.createGoal, regardless of whether+ // this conversation already has a topic.const acceptanceItems: ActionDropdownMenuItems = enableTopicAcceptance? [{@@ -721,13 +717,7 @@ const usePlusMenuItems = ({ close }: { close: () => void }): ActionDropdownMenuIkey: 'set-topic-goal',label: tVerify('acceptance.tray.menuSetGoal'),onClick: () => {- if (activeTopicId) {- void openTopicGoalModal(activeTopicId);- } else if (agentId) {- // Arm only — the persistent "armed" chip above the composer is the- // feedback now (the next message becomes the goal), not a toast.- useGoalArmStore.getState().arm(agentId);- }+ enterGoalMode(editor, setGoalMode);},},]@@ -747,7 +737,6 @@ const usePlusMenuItems = ({ close }: { close: () => void }): ActionDropdownMenuI}, [agentId,activeSearchOption,- activeTopicId,canConfigureResource,effortItem,enableTopicAcceptance,@@ -770,6 +759,7 @@ const usePlusMenuItems = ({ close }: { close: () => void }): ActionDropdownMenuIisParamsPanelActive,knowledgeEnabledCount,setShowTypoBar,+ setGoalMode,showProviderSearch,showTypoBar,skillActivateMode,@@ -799,17 +789,20 @@ const PlusAction = memo(() => {const { t } = useTranslation('chat');return (- <ChatInputAction- icon={PlusIcon}- size={{ blockSize: 32, borderRadius: 16, size: 18 }}- title={t('plus.tooltip')}- tooltipProps={{ placement: 'top' }}- dropdown={{- menu: { useItems: usePlusMenuItems },- minWidth: 220,- placement: 'topLeft',- }}- />+ <Fragment>+ <ChatInputAction+ icon={PlusIcon}+ size={{ blockSize: 32, borderRadius: 16, size: 18 }}+ title={t('plus.tooltip')}+ tooltipProps={{ placement: 'top' }}+ dropdown={{+ menu: { useItems: usePlusMenuItems },+ minWidth: 220,+ placement: 'topLeft',+ }}+ />+ <GoalModeChip />+ </Fragment>);});diff --git a/src/features/ChatInput/Desktop/index.tsx b/src/features/ChatInput/Desktop/index.tsxindex f3d62e5d7f4..2c516120033 100644--- a/src/features/ChatInput/Desktop/index.tsx+++ b/src/features/ChatInput/Desktop/index.tsx@@ -154,7 +154,7 @@ const DesktopChatInput = memo<DesktopChatInputProps>(// context-window token tag; without one, SendArea keeps it beside Send.const hasControlBar = Boolean(controlBarSlot) || showControlBar;- const setExpand = useChatInputStore((s) => s.setExpand);+ const [setExpand, setGoalMode] = useChatInputStore((s) => [s.setExpand, s.setGoalMode]);const skillDrop = useSkillDrop();const topicDrop = useTopicDrop();const workspaceFileDrop = useWorkspaceFileDrop();@@ -175,7 +175,8 @@ const DesktopChatInput = memo<DesktopChatInputProps>(useEffect(() => {if (editor) editor.focus();setExpand(false);- }, [chatKey, editor, setExpand]);+ setGoalMode(false);+ }, [chatKey, editor, setExpand, setGoalMode]);const shouldShowContextContainer =leftActions.flat().includes('fileUpload') || hasContextSelections || hasFiles;diff --git a/src/features/ChatInput/InputEditor/ActionTag/useSlashActionItems.ts b/src/features/ChatInput/InputEditor/ActionTag/useSlashActionItems.tsindex 0802888f146..3cc40c148eb 100644--- a/src/features/ChatInput/InputEditor/ActionTag/useSlashActionItems.ts+++ b/src/features/ChatInput/InputEditor/ActionTag/useSlashActionItems.ts@@ -5,7 +5,7 @@ import { SkillsIcon } from '@lobehub/ui/icons';import isEqual from 'fast-deep-equal';import Fuse from 'fuse.js';import { $getSelection, $isRangeSelection } from 'lexical';-import { ArchiveIcon, MessageSquarePlusIcon } from 'lucide-react';+import { ArchiveIcon, MessageSquarePlusIcon, TargetIcon } from 'lucide-react';import { useCallback, useMemo } from 'react';import { useTranslation } from 'react-i18next';@@ -22,6 +22,7 @@ import type { AgentDocumentSkillItem } from '@/store/tool/slices/agentDocumentSkimport { useAgentId } from '../../hooks/useAgentId';import { useChatInputStore } from '../../store';+import { enterGoalMode } from '../goalMode';import { INSERT_ACTION_TAG_COMMAND, type InsertActionTagPayload } from './command';import { type ActionTagData, BUILTIN_COMMANDS } from './types';import { useInstalledSkillsAndTools } from './useInstalledSkillsAndTools';@@ -44,6 +45,7 @@ const COMMAND_ICONS: Record<string, any> = {export const useSlashActionItems = (): SlashOptions['items'] => {const { t } = useTranslation('editor');const editorInstance = useChatInputStore((s) => s.editor);+ const setGoalMode = useChatInputStore((s) => s.setGoalMode);const activeTopicId = useChatStore((s) => s.activeTopicId);// Resolve the active working directory so we can surface filesystem skills.@@ -232,6 +234,17 @@ export const useSlashActionItems = (): SlashOptions['items'] => {// Built-in commands — line-start onlyif (isAtLineStart) {+ allItems.push({+ icon: TargetIcon,+ key: 'goal',+ label: t('slash.goal' as any),+ metadata: {+ category: 'command',+ description: t('slash.goal.desc' as any, { defaultValue: '' }),+ type: 'goal',+ },+ onSelect: (editor: IEditor) => enterGoalMode(editor, setGoalMode, true),+ } as SlashItem);for (const action of BUILTIN_COMMANDS) {if (action.type === 'newTopic' && !activeTopicId) continue;allItems.push(makeCommandItem(action) as SlashItem);@@ -269,6 +282,14 @@ export const useSlashActionItems = (): SlashOptions['items'] => {return allItems;},- [t, editorInstance, activeTopicId, projectSkills, installedSkills, agentDocumentSkills],+ [+ t,+ editorInstance,+ activeTopicId,+ projectSkills,+ installedSkills,+ agentDocumentSkills,+ setGoalMode,+ ],);};diff --git a/src/features/ChatInput/InputEditor/goalMode.test.ts b/src/features/ChatInput/InputEditor/goalMode.test.tsnew file mode 100644index 00000000000..733c07437c6--- /dev/null+++ b/src/features/ChatInput/InputEditor/goalMode.test.ts@@ -0,0 +1,36 @@+import type { IEditor } from '@lobehub/editor';+import { describe, expect, it, vi } from 'vitest';++import { enterGoalMode } from './goalMode';++const createEditor = (content: string) =>+ ({+ focus: vi.fn(),+ getDocument: vi.fn().mockReturnValue(content),+ setDocument: vi.fn(),+ }) as unknown as IEditor;++describe('enterGoalMode', () => {+ it('enables goal mode without changing an existing draft', () => {+ const editor = createEditor('ship the homepage');+ const setGoalMode = vi.fn();++ enterGoalMode(editor, setGoalMode);++ expect(editor.setDocument).not.toHaveBeenCalled();+ expect(setGoalMode).toHaveBeenCalledWith(true);+ expect(editor.focus).toHaveBeenCalled();+ });++ it('replaces the partial slash query selected from the command menu', () => {+ const editor = createEditor('/go');+ const setGoalMode = vi.fn();++ enterGoalMode(editor, setGoalMode, true);++ expect(editor.setDocument).toHaveBeenCalledWith('markdown', '', {+ keepHistory: true,+ });+ expect(setGoalMode).toHaveBeenCalledWith(true);+ });+});diff --git a/src/features/ChatInput/InputEditor/goalMode.ts b/src/features/ChatInput/InputEditor/goalMode.tsnew file mode 100644index 00000000000..af7aa45e02d--- /dev/null+++ b/src/features/ChatInput/InputEditor/goalMode.ts@@ -0,0 +1,15 @@+import type { IEditor } from '@lobehub/editor';++export const enterGoalMode = (+ editor: IEditor | undefined,+ setGoalMode: (enabled: boolean) => void,+ replaceSlashQuery = false,+) => {+ if (!editor) return;++ if (replaceSlashQuery) {+ editor.setDocument('markdown', '', { keepHistory: true });+ }+ setGoalMode(true);+ editor.focus();+};diff --git a/src/features/ChatInput/store/action.test.ts b/src/features/ChatInput/store/action.test.tsindex a954534e205..c89b6a581b5 100644--- a/src/features/ChatInput/store/action.test.ts+++ b/src/features/ChatInput/store/action.test.ts@@ -75,6 +75,31 @@ describe('ChatInput store actions', () => {expect(getInputHistory()).toEqual([]);});+ it('adds the hidden /goal prefix only when sending in goal mode', () => {+ const onSend = vi.fn(({ clearContent, getMarkdownContent }) => {+ expect(getMarkdownContent()).toBe('/goal Ship the homepage');+ clearContent();+ });+ const editor = {+ cleanDocument: vi.fn(),+ focus: vi.fn(),+ getDocument: vi.fn((type: string) =>+ type === 'markdown' ? 'Ship the homepage' : { root: {} },+ ),+ };+ const store = createStore({+ editor: editor as unknown as IEditor,+ onSend,+ });++ store.getState().setGoalMode(true);+ store.getState().handleSendButton();++ expect(onSend).toHaveBeenCalledOnce();+ expect(editor.cleanDocument).toHaveBeenCalledOnce();+ expect(store.getState().goalMode).toBe(false);+ });+it('does not record history when the input history feature is disabled', () => {const editor = {cleanDocument: vi.fn(),diff --git a/src/features/ChatInput/store/action.ts b/src/features/ChatInput/store/action.tsindex 8cd33f362a7..d930bae527a 100644--- a/src/features/ChatInput/store/action.ts+++ b/src/features/ChatInput/store/action.ts@@ -20,6 +20,7 @@ export interface Action {pauseInputCompletion: (error: State['inputCompletionError']) => void;setDocument: (type: string, content: any, options?: Record<string, unknown>) => void;setExpand: (expend: boolean) => void;+ setGoalMode: (enabled: boolean) => void;setJSONState: (content: any) => void;setShowTypoBar: (show: boolean) => void;updateMarkdownContent: () => void;@@ -86,10 +87,16 @@ export const store: CreateStore = (publicState) => (set, get) => ({: undefined;onSend?.({- clearContent: () => editor?.cleanDocument(),+ clearContent: () => {+ editor?.cleanDocument();+ set({ goalMode: false });+ },editor: editor!,getEditorData: get().getJSONState,- getMarkdownContent: get().getMarkdownContent,+ getMarkdownContent: () => {+ const content = get().getMarkdownContent();+ return get().goalMode ? `/goal ${content}`.trimEnd() : content;+ },});if (historySnapshot) {@@ -129,6 +136,10 @@ export const store: CreateStore = (publicState) => (set, get) => ({set({ _savedEditorState, expand });},+ setGoalMode: (goalMode) => {+ set({ goalMode });+ },+setJSONState: (content) => {get().editor?.setDocument('json', content);},diff --git a/src/features/ChatInput/store/initialState.ts b/src/features/ChatInput/store/initialState.tsindex 75d5b273076..a12089d5dc1 100644--- a/src/features/ChatInput/store/initialState.ts+++ b/src/features/ChatInput/store/initialState.ts@@ -89,6 +89,7 @@ export interface PublicState {export interface State extends PublicState {_savedEditorState?: Record<string, any>;editor?: IEditor;+ goalMode: boolean;inputCompletionError?: InputCompletionError;inputCompletionErrorDismissed: boolean;isContentEmpty: boolean;@@ -100,6 +101,7 @@ export const initialState: State = {allowExpand: true,expand: false,feature: DEFAULT_CHAT_INPUT_FEATURE,+ goalMode: false,inputCompletionErrorDismissed: false,isContentEmpty: false,leftActions: [],diff --git a/src/features/Conversation/Messages/GoalWorkCard/deriveOperationGoals.test.ts b/src/features/Conversation/Messages/GoalWorkCard/deriveOperationGoals.test.tsindex e32872e0a96..a4e756b7d69 100644--- a/src/features/Conversation/Messages/GoalWorkCard/deriveOperationGoals.test.ts+++ b/src/features/Conversation/Messages/GoalWorkCard/deriveOperationGoals.test.ts@@ -21,7 +21,7 @@ describe('deriveOperationGoals', () => {name: 'San Francisco night fog',}),id: 'call-1',- identifier: 'lobe-task',+ identifier: 'lobe-goal',result: {content: 'started',id: 'tool-1',diff --git a/src/features/Conversation/Messages/GoalWorkCard/deriveOperationGoals.ts b/src/features/Conversation/Messages/GoalWorkCard/deriveOperationGoals.tsindex a3efb380bd8..dff613dd729 100644--- a/src/features/Conversation/Messages/GoalWorkCard/deriveOperationGoals.ts+++ b/src/features/Conversation/Messages/GoalWorkCard/deriveOperationGoals.ts@@ -23,7 +23,8 @@ const nonEmptyString = (value: unknown): string | undefined =>export const deriveOperationGoals = (blocks: AssistantContentBlock[] = []): OperationGoal[] => {const goals = blocks.flatMap((block) =>(block.tools ?? []).flatMap((tool) => {- if (tool.identifier !== 'lobe-task' || tool.apiName !== 'createGoal') return [];+ if (!['lobe-goal', 'lobe-task'].includes(tool.identifier) || tool.apiName !== 'createGoal')+ return [];if (tool.result?.error || !isRecord(tool.result?.state) || tool.result.state.success !== true)return [];diff --git a/src/features/DevPanel/RenderGallery/fixtures/lobe-task.ts b/src/features/DevPanel/RenderGallery/fixtures/lobe-task.tsindex 50d10a19644..576ca65aaf8 100644--- a/src/features/DevPanel/RenderGallery/fixtures/lobe-task.ts+++ b/src/features/DevPanel/RenderGallery/fixtures/lobe-task.ts@@ -33,7 +33,7 @@ const goalArgs = {};export default defineFixtures({- identifier: 'lobe-task',+ identifier: 'lobe-goal',fixtures: {createGoal: variants([{diff --git a/src/routes/(main)/agent/features/Conversation/HeterogeneousChatInput/HeteroPlus.tsx b/src/routes/(main)/agent/features/Conversation/HeterogeneousChatInput/HeteroPlus.tsxindex 80c5116c541..07b83d9a46a 100644--- a/src/routes/(main)/agent/features/Conversation/HeterogeneousChatInput/HeteroPlus.tsx+++ b/src/routes/(main)/agent/features/Conversation/HeterogeneousChatInput/HeteroPlus.tsx@@ -16,10 +16,9 @@ import { useTranslation } from 'react-i18next';import { type ActionDropdownMenuItems } from '@/features/ChatInput/ActionBar/components/ActionDropdown';import { ChatInputAction } from '@/features/ChatInput/ActionBar/components/ChatInputAction';+import { enterGoalMode } from '@/features/ChatInput/InputEditor/goalMode';import { useChatInputStore } from '@/features/ChatInput/store';import { useConversationStore } from '@/features/Conversation';-import { useGoalArmStore } from '@/features/Conversation/ChatInput/VerifyTray/goalArmStore';-import { openTopicGoalModal } from '@/features/Conversation/ChatInput/VerifyTray/useTopicChecklist';import { useUserStore } from '@/store/user';import { labPreferSelectors } from '@/store/user/selectors';@@ -44,12 +43,15 @@ const HeteroPlus = memo(() => {const { t: tVerify } = useTranslation('verify');const [open, setOpen] = useState(false);- const [showTypoBar, setShowTypoBar] = useChatInputStore((s) => [s.showTypoBar, s.setShowTypoBar]);+ const [editor, setGoalMode, showTypoBar, setShowTypoBar] = useChatInputStore((s) => [+ s.editor,+ s.setGoalMode,+ s.showTypoBar,+ s.setShowTypoBar,+ ]);const scheduledSendAt = useConversationStore((s) => s.scheduledSendAt);const setScheduledSendAt = useConversationStore((s) => s.setScheduledSendAt);- const topicId = useConversationStore((s) => s.context.topicId);- const agentId = useConversationStore((s) => s.context.agentId);const enableTopicAcceptance = useUserStore(labPreferSelectors.enableTopicAcceptance);const armSchedule = useCallback(@@ -101,8 +103,7 @@ const HeteroPlus = memo(() => {onCheckedChange: (checked: boolean) => setShowTypoBar(checked),type: 'switch',},- // Topic goal (lab): before a topic exists this *arms* the goal (the next- // message becomes it); once a topic exists it opens the editor directly.+ // Goal creation shares the same hidden /goal mode as the standard input....(enableTopicAcceptance? ([{ type: 'divider' },@@ -112,13 +113,7 @@ const HeteroPlus = memo(() => {label: tVerify('acceptance.tray.menuSetGoal'),onClick: () => {setOpen(false);- if (topicId) {- void openTopicGoalModal(topicId);- } else if (agentId) {- // Arm only — the persistent "armed" chip above the composer is- // the feedback now (the next message becomes the goal).- useGoalArmStore.getState().arm(agentId);- }+ enterGoalMode(editor, setGoalMode);},},] as ActionDropdownMenuItems)@@ -133,8 +128,8 @@ const HeteroPlus = memo(() => {armSchedule,scheduledSendAt,enableTopicAcceptance,- agentId,- topicId,+ editor,+ setGoalMode,]);return (diff --git a/src/routes/(main)/agent/features/Conversation/HeterogeneousChatInput/index.tsx b/src/routes/(main)/agent/features/Conversation/HeterogeneousChatInput/index.tsxindex 8b77e304604..fd2140b9a5d 100644--- a/src/routes/(main)/agent/features/Conversation/HeterogeneousChatInput/index.tsx+++ b/src/routes/(main)/agent/features/Conversation/HeterogeneousChatInput/index.tsx@@ -10,6 +10,7 @@ import { useTranslation } from 'react-i18next';import { useHeteroAgentCloudConfig } from '@/business/client/hooks/useHeteroAgentCloudConfig';import { isDesktop } from '@/const/version';import { type ActionKeys } from '@/features/ChatInput';+import GoalModeChip from '@/features/ChatInput/ActionBar/GoalModeChip';import HeteroModel from '@/features/ChatInput/ControlBar/HeteroModel';import { ChatInput } from '@/features/Conversation';import { contextSelectors, useConversationStore } from '@/features/Conversation/store';@@ -127,6 +128,7 @@ const HeterogeneousChatInput = memo(() => {const extraActionItems = useMemo<ChatInputActionsProps['items']>(() => [{ alwaysDisplay: true, children: <HeteroPlus />, key: 'heteroPlus' },+ { alwaysDisplay: true, children: <GoalModeChip />, key: 'goalModeChip' },{ alwaysDisplay: true, children: <ScheduledSendChip />, key: 'scheduledSendChip' },],[],diff --git a/src/store/chat/slices/agentRun/actions/__tests__/conversationLifecycle.test.ts b/src/store/chat/slices/agentRun/actions/__tests__/conversationLifecycle.test.tsindex 5d3de757b07..7bc2491452c 100644--- a/src/store/chat/slices/agentRun/actions/__tests__/conversationLifecycle.test.ts+++ b/src/store/chat/slices/agentRun/actions/__tests__/conversationLifecycle.test.ts@@ -1776,6 +1776,33 @@ describe('ConversationLifecycle actions', () => {});describe('page scope documentId injection', () => {+ it('enables the task tool for a /goal gateway turn', async () => {+ const { result } = renderHook(() => useChatStore());+ const executeGatewayAgentSpy = vi.fn().mockResolvedValue({+ assistantMessageId: TEST_IDS.ASSISTANT_MESSAGE_ID,+ operationId: 'op-goal',+ userMessageId: TEST_IDS.USER_MESSAGE_ID,+ });++ act(() => {+ useChatStore.setState({+ executeGatewayAgent: executeGatewayAgentSpy,+ isGatewayModeEnabled: () => true,+ });+ });++ await act(async () => {+ await result.current.sendMessage({+ context: createTestContext(),+ message: '/goal ship the homepage',+ });+ });++ expect(executeGatewayAgentSpy).toHaveBeenCalledWith(+ expect.objectContaining({ selectedToolIds: ['lobe-goal'] }),+ );+ });+it('injects the active page documentId into the gateway context when scope is page', async () => {const { result } = renderHook(() => useChatStore());diff --git a/src/store/chat/slices/agentRun/actions/entries/conversationLifecycle.ts b/src/store/chat/slices/agentRun/actions/entries/conversationLifecycle.tsindex 508b94e247f..23ddb462e26 100644--- a/src/store/chat/slices/agentRun/actions/entries/conversationLifecycle.ts+++ b/src/store/chat/slices/agentRun/actions/entries/conversationLifecycle.ts@@ -1,5 +1,6 @@// Disable the auto sort key eslint rule to make the code more logic and readableimport { createCallAgentManifest } from '@lobechat/builtin-tool-agent-management';+import { GoalIdentifier, isGoalPrompt } from '@lobechat/builtin-tool-goal';import { isDesktop, isHeterogeneousAgentModelId, LOADING_FLAT } from '@lobechat/const';import { formatSelectedSkillsContext, formatSelectedToolsContext } from '@lobechat/context-engine';import { isRemoteHeterogeneousType } from '@lobechat/heterogeneous-agents';@@ -273,6 +274,12 @@ export class ConversationLifecycleActionImpl {const ownerAgentId = context.agentId;const selectedSkills = parseSelectedSkillsFromEditorData(editorData);const selectedTools = parseSelectedToolsFromEditorData(editorData);+ if (+ isGoalPrompt(message) &&+ !selectedTools.some(({ identifier }) => identifier === GoalIdentifier)+ ) {+ selectedTools.push({ identifier: GoalIdentifier, name: 'Goal' });+ }const mentionedAgents = parseMentionedAgentsFromEditorData(editorData);const localFileReferences = mergeLocalFileReferences(diff --git a/src/store/tool/slices/builtin/executors/catalog.ts b/src/store/tool/slices/builtin/executors/catalog.tsindex a4c4fd70c10..0e92c73f9e0 100644--- a/src/store/tool/slices/builtin/executors/catalog.ts+++ b/src/store/tool/slices/builtin/executors/catalog.ts@@ -4,6 +4,7 @@ import { browserExecutor } from '@lobechat/builtin-tool-browser/client/executor'import { calculatorExecutor } from '@lobechat/builtin-tool-calculator/executor';import { cloudSandboxExecutor } from '@lobechat/builtin-tool-cloud-sandbox/executor';import { credsExecutor } from '@lobechat/builtin-tool-creds/executor';+import { goalExecutor } from '@lobechat/builtin-tool-goal/client/executor';import { groupAgentBuilderExecutor } from '@lobechat/builtin-tool-group-agent-builder/executor';import { groupManagementExecutor } from '@lobechat/builtin-tool-group-management/executor';import { imageGenerationExecutor } from '@lobechat/builtin-tool-image-generation/executor';@@ -51,6 +52,7 @@ export const builtinToolExecutors = [credsExecutor,groupAgentBuilderExecutor,groupManagementExecutor,+ goalExecutor,imageGenerationExecutor,knowledgeBaseExecutor,browserExecutor,