mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-12-06 16:24:17 +00:00
refactor(agent): drop field/option ids from list_autofill_fields results
This commit is contained in:
@@ -1726,15 +1726,14 @@ describe('Agent Database Activities Integration', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
expect(res.fields).toHaveLength(2)
|
expect(res.fields).toHaveLength(2)
|
||||||
const source = res.fields.find((f: { id: string }) => f.id === 'source')
|
const source = res.fields.find((f: { name: string }) => f.name === 'Source')
|
||||||
expect(source?.name).toBe('Source')
|
expect(source?.name).toBe('Source')
|
||||||
expect(source?.type).toBe('select')
|
expect(source?.type).toBe('select')
|
||||||
expect(source?.description).toBe('Generation source')
|
expect(source?.description).toBe('Generation source')
|
||||||
expect(source?.options).toEqual([
|
expect(source?.options).toEqual([{ displayName: 'Gemini' }, { displayName: 'Seedance' }])
|
||||||
{ id: 'gemini', displayName: 'Gemini', color: '#ffffff' },
|
expect(
|
||||||
{ id: 'seedance', displayName: 'Seedance', color: '#ffffff' },
|
res.fields.find((f: { name: string }) => f.name === 'Manual Notes'),
|
||||||
])
|
).toBeUndefined()
|
||||||
expect(res.fields.find((f: { id: string }) => f.id === 'manual_notes')).toBeUndefined()
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should resolve the project through the ancestor chain', async () => {
|
it('should resolve the project through the ancestor chain', async () => {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import {
|
import {
|
||||||
type AgentMessage,
|
type AgentMessage,
|
||||||
type AgentTool,
|
type AgentTool,
|
||||||
type SessionTreeEntry,
|
type SessionTreeEntry,
|
||||||
} from '@earendil-works/pi-agent-core'
|
} from '@earendil-works/pi-agent-core'
|
||||||
import { type ImageContent } from '@earendil-works/pi-ai'
|
import { type ImageContent } from '@earendil-works/pi-ai'
|
||||||
import { assetService } from '@shumai/core/src/asset/asset'
|
import { assetService } from '@shumai/core/src/asset/asset'
|
||||||
@@ -19,10 +19,10 @@ import { generateKeyBetween } from 'jittered-fractional-indexing'
|
|||||||
import { ulid } from 'ulid'
|
import { ulid } from 'ulid'
|
||||||
import { DatabaseSessionStorage } from '../database-session-storage'
|
import { DatabaseSessionStorage } from '../database-session-storage'
|
||||||
import {
|
import {
|
||||||
createAgentSession,
|
createAgentSession,
|
||||||
fieldsToTypeBoxSchema,
|
fieldsToTypeBoxSchema,
|
||||||
type AutofillField,
|
type AutofillField,
|
||||||
type DbProviderInfo,
|
type DbProviderInfo,
|
||||||
} from '../index'
|
} from '../index'
|
||||||
|
|
||||||
import { aiUsageService } from '@shumai/core/src/ai-usage/ai-usage'
|
import { aiUsageService } from '@shumai/core/src/ai-usage/ai-usage'
|
||||||
@@ -96,7 +96,7 @@ shumai has its own cloud file system. If a user asks you to perform file system
|
|||||||
|
|
||||||
If you need to create files in the local filesystem (for example, a temporary file for uploading), only the '.pi' folder in the current directory has write permissions. Do NOT attempt to create files in any other directories.
|
If you need to create files in the local filesystem (for example, a temporary file for uploading), only the '.pi' folder in the current directory has write permissions. Do NOT attempt to create files in any other directories.
|
||||||
|
|
||||||
Before creating a file or version, use 'list_autofill_fields' to check the project's AI-autofillable metadata fields. If relevant, pass a short, simple context (max 50 words) about the file's source or how it was generated via the 'context' parameter of 'create_file' or 'create_version'.`
|
When creating a file or version, first use 'list_autofill_fields' to inspect the project's AI-autofillable metadata fields. If relevant metadata depends on information unavailable from the file content (for example, the AI model or tool used to generate it), include a brief context hint (maximum 50 words) in the 'context' parameter.`
|
||||||
|
|
||||||
if (agent.soul) {
|
if (agent.soul) {
|
||||||
systemPrompt = `${systemPrompt}\n\nAgent Personality and Core Instructions:\n${agent.soul}`
|
systemPrompt = `${systemPrompt}\n\nAgent Personality and Core Instructions:\n${agent.soul}`
|
||||||
@@ -1457,11 +1457,14 @@ export async function executeAgentToolActivity(params: ExecuteAgentToolParams):
|
|||||||
const autofillFields = fields
|
const autofillFields = fields
|
||||||
.filter((f) => f.field.aiAutofill)
|
.filter((f) => f.field.aiAutofill)
|
||||||
.map((f) => ({
|
.map((f) => ({
|
||||||
id: f.field.key,
|
|
||||||
name: f.field.config?.name,
|
name: f.field.config?.name,
|
||||||
type: f.field.config?.type,
|
type: f.field.config?.type,
|
||||||
description: f.field.description,
|
description: f.field.description,
|
||||||
options: f.field.config?.select?.options ?? f.field.config?.selectMulti?.options ?? [],
|
options: (
|
||||||
|
f.field.config?.select?.options ??
|
||||||
|
f.field.config?.selectMulti?.options ??
|
||||||
|
[]
|
||||||
|
).map((o) => ({ displayName: o.displayName })),
|
||||||
}))
|
}))
|
||||||
|
|
||||||
return { fields: autofillFields }
|
return { fields: autofillFields }
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { executeAgentToolWorkflow } from './utils'
|
|||||||
|
|
||||||
vi.mock('./utils', () => ({
|
vi.mock('./utils', () => ({
|
||||||
executeAgentToolWorkflow: vi.fn().mockResolvedValue({
|
executeAgentToolWorkflow: vi.fn().mockResolvedValue({
|
||||||
fields: [{ id: 'source', name: 'Source', type: 'select', options: [] }],
|
fields: [{ name: 'Source', type: 'select', options: [{ displayName: 'Gemini' }] }],
|
||||||
}),
|
}),
|
||||||
}))
|
}))
|
||||||
|
|
||||||
@@ -25,7 +25,7 @@ describe('createListAutofillFieldsTool', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
expect(result.details).toEqual({
|
expect(result.details).toEqual({
|
||||||
fields: [{ id: 'source', name: 'Source', type: 'select', options: [] }],
|
fields: [{ name: 'Source', type: 'select', options: [{ displayName: 'Gemini' }] }],
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user