Pass cached conversation ancestry to bash execution

This commit is contained in:
2026-11-07 12:28:46 +00:00
parent ad6aa97ee1
commit e003fd6b40
8 changed files with 22810 additions and 8 deletions
+29 -2
View File
@@ -53126,6 +53126,31 @@ async function openStorage(path3) {
}
// environment.ts
var Started = defineDoc({
kind: "board.started",
version: 1,
checkpointWhen: () => false,
scope: "conversation",
history: "latest",
fork: "initial",
initial: () => ({})
});
function conversationChains(harness2, context) {
const cache = /* @__PURE__ */ new Map();
const chain2 = (id) => {
let result = cache.get(id);
if (!result) {
result = (async () => {
const record = await harness2.commit((tx) => tx.conversation(id), context);
const up = record?.owner?.conversationId ?? record?.parent?.conversationId ?? (await harness2.snapshot(Started, id, context))?.by;
return [String(id), ...up === void 0 ? [] : await chain2(up)];
})();
cache.set(id, result);
}
return result;
};
return chain2;
}
var ops = Deno.core.ops;
var ok = (value2) => ({ ok: true, value: value2 });
var path2 = (cwd, input) => {
@@ -53137,6 +53162,7 @@ var path2 = (cwd, input) => {
return "/" + parts.join("/");
};
function environment(cwd = "/", conversation) {
const conversations = Array.isArray(conversation) ? conversation : conversation === void 0 ? [] : [String(conversation)];
const call = (kind, p, bytes2 = []) => ops.op_file(kind, path2(cwd, p), bytes2);
const env = {
id: "world",
@@ -53215,7 +53241,7 @@ function environment(cwd = "/", conversation) {
}
};
try {
const rid = ops.op_exec(command, options?.cwd ?? cwd, options?.timeout, conversation === void 0 ? void 0 : String(conversation));
const rid = ops.op_exec(command, options?.cwd ?? cwd, options?.timeout, void 0, void 0, conversations);
const decoders = { stdout: new TextDecoder(), stderr: new TextDecoder() };
let result;
while (true) {
@@ -54219,8 +54245,9 @@ var harness = await Harness.open(storage, {
settings: { followUpMode: "all", get extensions() {
return registry.snapshot().installed();
} },
env: (target) => environment(target.cwd ?? "/", target.conversationId)
env: async (target) => environment(target.cwd ?? "/", await chain(target.conversationId))
}, BACKGROUND_CONTEXT);
var chain = conversationChains(harness, BACKGROUND_CONTEXT);
var root = await harness.root(BACKGROUND_CONTEXT, { agent: { model: { provider: "openai", modelId: model2.id }, thinkingLevel: "low", cwd: "/" } });
var storedAgent = await harness.snapshot(AgentDoc, root.id, BACKGROUND_CONTEXT);
if (Array.isArray(storedAgent?.extensions) && storedAgent.extensions.length === 2 && [CodingTools, CredentialRequests].every((extension) => storedAgent.extensions.includes(extension.name))) {