0.11.0 退役老预设线:workbench/host/service.mjs
This commit is contained in:
parent
e42896c9c5
commit
6212092172
|
|
@ -663,13 +663,13 @@ export function createWorkbenchService(options = {}) {
|
|||
if (typeof packet !== 'object' || Array.isArray(packet)) {
|
||||
throw new ServiceError(SERVICE_CODES.INVALID_INPUT, 'packet 必须是对象', { field: 'packet' })
|
||||
}
|
||||
// 记忆注入:派发时把项目记忆与长期记忆的摘录并进交接材料,
|
||||
// 部门开工前就能看到「这个项目之前发生过什么」与「用户长期偏好」。
|
||||
// 记忆是参考资料:读失败不拦派发,按没有记忆处理。
|
||||
// 记忆注入:派发时把部门记忆、项目记忆与长期记忆的摘录并进交接材料,
|
||||
// 部门开工前就能看到「自己以前摸出的经验」「这个项目之前发生过什么」
|
||||
// 与「用户长期偏好」。记忆是参考资料:读失败不拦派发,按没有记忆处理。
|
||||
let memoryExcerpts = []
|
||||
if (memory !== null) {
|
||||
try {
|
||||
memoryExcerpts = memory.excerptsFor(project.id)
|
||||
memoryExcerpts = memory.excerptsFor(project.id, task.ownerRoleId)
|
||||
} catch {
|
||||
memoryExcerpts = []
|
||||
}
|
||||
|
|
@ -892,14 +892,23 @@ export function createWorkbenchService(options = {}) {
|
|||
}
|
||||
}
|
||||
|
||||
// 自动记账:新成果落账后往项目记忆里记一行(哪个部门、做了什么),
|
||||
// 项目记忆由此随干活自然生长。尽力而为:写失败不影响成果本身。
|
||||
// 自动记账:新成果落账后记两行——项目记忆里一行(哪个部门、做了什么),
|
||||
// 主责部门自己的部门记忆里也一行(在哪个项目、做了什么),两本记忆
|
||||
// 都随干活自然生长。尽力而为:写失败不影响成果本身。
|
||||
if (memory !== null) {
|
||||
try {
|
||||
memory.appendProject(project.id, `${task.ownerRoleId} 汇报成果(任务「${task.title}」):${summary.slice(0, 500)}`)
|
||||
} catch {
|
||||
// 记忆是参考资料,不拖垮业务。
|
||||
}
|
||||
try {
|
||||
const projectLabel = typeof project.displayNameCache === 'string' && project.displayNameCache !== ''
|
||||
? project.displayNameCache
|
||||
: project.id
|
||||
memory.appendDepartment(task.ownerRoleId, `在项目「${projectLabel}」汇报成果(任务「${task.title}」):${summary.slice(0, 500)}`)
|
||||
} catch {
|
||||
// 同上。
|
||||
}
|
||||
}
|
||||
|
||||
if (isTerminal('task', task.status)) {
|
||||
|
|
@ -1446,8 +1455,8 @@ export function createWorkbenchService(options = {}) {
|
|||
// ---------- 记忆 ----------
|
||||
|
||||
function requireMemoryScope(value) {
|
||||
if (value !== 'long-term' && value !== 'project') {
|
||||
throw new ServiceError(SERVICE_CODES.INVALID_INPUT, 'scope 必须是 long-term 或 project', { field: 'scope' })
|
||||
if (value !== 'long-term' && value !== 'project' && value !== 'department') {
|
||||
throw new ServiceError(SERVICE_CODES.INVALID_INPUT, 'scope 必须是 long-term、project 或 department', { field: 'scope' })
|
||||
}
|
||||
return value
|
||||
}
|
||||
|
|
@ -1466,6 +1475,11 @@ export function createWorkbenchService(options = {}) {
|
|||
const found = mem.readLongTerm()
|
||||
return { scope, text: found.text, exists: found.exists }
|
||||
}
|
||||
if (scope === 'department') {
|
||||
const roleId = requireRole(input.roleId, 'roleId')
|
||||
const found = mem.readDepartment(roleId)
|
||||
return { scope, roleId, text: found.text, exists: found.exists }
|
||||
}
|
||||
const project = projectIdOf(input)
|
||||
const found = mem.readProject(project.id)
|
||||
return { scope, projectId: project.id, text: found.text, exists: found.exists }
|
||||
|
|
@ -1481,6 +1495,11 @@ export function createWorkbenchService(options = {}) {
|
|||
mem.writeLongTerm(input.text)
|
||||
return { scope, text: input.text }
|
||||
}
|
||||
if (scope === 'department') {
|
||||
const roleId = requireRole(input.roleId, 'roleId')
|
||||
mem.writeDepartment(roleId, input.text)
|
||||
return { scope, roleId, text: input.text }
|
||||
}
|
||||
const project = projectIdOf(input)
|
||||
mem.writeProject(project.id, input.text)
|
||||
return { scope, projectId: project.id, text: input.text }
|
||||
|
|
@ -1493,6 +1512,10 @@ export function createWorkbenchService(options = {}) {
|
|||
if (scope === 'long-term') {
|
||||
return { scope, text: mem.appendLongTerm(text).text }
|
||||
}
|
||||
if (scope === 'department') {
|
||||
const roleId = requireRole(input.roleId, 'roleId')
|
||||
return { scope, roleId, text: mem.appendDepartment(roleId, text).text }
|
||||
}
|
||||
const project = projectIdOf(input)
|
||||
return { scope, projectId: project.id, text: mem.appendProject(project.id, text).text }
|
||||
})
|
||||
|
|
|
|||
Loading…
Reference in New Issue