Merge v3 messages compatibility fix into v3-t51
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
/** Fork a tree root, record its starter, and admit the first message exactly once. */
|
||||
import { bool, int, obj, opt, str } from '@earendil-works/pi-schema'
|
||||
import { configure, defineTool, ROOT_CONVERSATION_ID } from '@earendil-works/pi-durable'
|
||||
import { discover } from '../subagents/definitions.ts'
|
||||
import { childConfiguration } from '../subagents/children.ts'
|
||||
import { defineTool, ROOT_CONVERSATION_ID } from '@earendil-works/pi-durable'
|
||||
import { ModelsApi } from '../models/api.ts'
|
||||
import { configureChild } from '../subagents/children.ts'
|
||||
import { LineageApi, Roots } from '../lineage/api.ts'
|
||||
import { imagesParameter } from './images.ts'
|
||||
import { send } from './send.ts'
|
||||
@@ -17,14 +17,13 @@ export const branchTool = (host: any) => defineTool({
|
||||
const roots = (await api.snapshot(Roots, ROOT_CONVERSATION_ID, ctx))?.roots ?? []
|
||||
const root = input.root ?? await lineage.rootOf(api.conversationId, ctx) ?? (roots.length === 1 ? roots[0] : undefined)
|
||||
if (root === undefined || !roots.includes(root)) throw new Error('Choose a listed root')
|
||||
const {definitions} = await discover(host, input.repo)
|
||||
const {definitions} = await host.need(ModelsApi).discover(input.repo)
|
||||
const coordinator = definitions.find((definition: any) => definition.name === 'coordinator')
|
||||
if (!coordinator) throw new Error('Missing coordinator definition')
|
||||
const rootAgent = await (await host.harness().conversation(root, ctx))!.agent(ctx)
|
||||
const config = childConfiguration({definition: coordinator, parentAgent: rootAgent, cwd: input.repo})
|
||||
const branch = await lineage.branch({from: root, repo: input.repo, prompt: input.prompt, title: input.title, isolated: input.isolated ?? false, deliver: false, by: api.conversationId, receipt: {taskId: api.taskId, callId: api.callId}, model: config.model, thinkingLevel: config.thinkingLevel}, ctx)
|
||||
const branch = await lineage.branch({from: root, repo: input.repo, prompt: input.prompt, title: input.title, isolated: input.isolated ?? false, deliver: false, by: api.conversationId, receipt: {taskId: api.taskId, callId: api.callId}}, ctx)
|
||||
await host.harness().commit(async (tx: any) => {
|
||||
await configure(tx, branch.id, config)
|
||||
await configureChild(host, tx, branch.id, {definition: coordinator, parentAgent: rootAgent, cwd: input.repo})
|
||||
;(await tx.doc(host.metadata, branch.id)).label = 'coordinator'
|
||||
}, ctx)
|
||||
id = await api.memo('branch-id', branch.id, ctx)
|
||||
|
||||
Reference in New Issue
Block a user