fix(run): restore subprocess output contracts
This commit is contained in:
parent
b99759c7de
commit
ba07481b59
3 changed files with 42 additions and 57 deletions
|
|
@ -294,8 +294,6 @@ export function createRoutes(
|
||||||
HttpServer.layerServices,
|
HttpServer.layerServices,
|
||||||
]),
|
]),
|
||||||
Layer.provide(Layer.succeed(CorsConfig)(corsOptions)),
|
Layer.provide(Layer.succeed(CorsConfig)(corsOptions)),
|
||||||
Layer.provideMerge(Observability.layer),
|
|
||||||
|
|
||||||
Layer.provide(formLocationLayer),
|
Layer.provide(formLocationLayer),
|
||||||
Layer.provide(sessionLocationLayer),
|
Layer.provide(sessionLocationLayer),
|
||||||
Layer.provide(locationLayer),
|
Layer.provide(locationLayer),
|
||||||
|
|
@ -312,6 +310,7 @@ export function createRoutes(
|
||||||
Layer.provide(locationServiceMapV2),
|
Layer.provide(locationServiceMapV2),
|
||||||
|
|
||||||
Layer.provide(AppNodeBuilderV1.build(app)),
|
Layer.provide(AppNodeBuilderV1.build(app)),
|
||||||
|
Layer.provideMerge(Observability.layer),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -110,6 +110,39 @@ function tool(input: { id: string; messageID: string; tool: string; state: Recor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function shellInfo(id: string, status: "running" | "exited", completed?: number) {
|
||||||
|
return {
|
||||||
|
id,
|
||||||
|
status,
|
||||||
|
command: "pwd",
|
||||||
|
cwd: "/tmp/demo",
|
||||||
|
shell: "/bin/sh",
|
||||||
|
file: `/tmp/${id}.log`,
|
||||||
|
...(status === "exited" ? { exit: 0 } : {}),
|
||||||
|
metadata: {},
|
||||||
|
time: { started: 1, ...(completed === undefined ? {} : { completed }) },
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function shellStarted(id = "call-1") {
|
||||||
|
return {
|
||||||
|
type: "session.shell.started",
|
||||||
|
properties: { sessionID: "session-1", shell: shellInfo(id, "running") },
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function shellEnded(id = "call-1") {
|
||||||
|
const output = "/tmp/demo\n"
|
||||||
|
return {
|
||||||
|
type: "session.shell.ended",
|
||||||
|
properties: {
|
||||||
|
sessionID: "session-1",
|
||||||
|
shell: shellInfo(id, "exited", 2),
|
||||||
|
output: { output, cursor: Buffer.byteLength(output), size: Buffer.byteLength(output), truncated: false },
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
describe("run session data", () => {
|
describe("run session data", () => {
|
||||||
test("buffers delayed assistant text until the role is known", () => {
|
test("buffers delayed assistant text until the role is known", () => {
|
||||||
let data = createSessionData()
|
let data = createSessionData()
|
||||||
|
|
@ -328,15 +361,7 @@ describe("run session data", () => {
|
||||||
|
|
||||||
test("renders direct shell mode from first-class shell events", () => {
|
test("renders direct shell mode from first-class shell events", () => {
|
||||||
let data = createSessionData()
|
let data = createSessionData()
|
||||||
const started = reduce(data, {
|
const started = reduce(data, shellStarted())
|
||||||
type: "session.shell.started",
|
|
||||||
properties: {
|
|
||||||
sessionID: "session-1",
|
|
||||||
timestamp: 1,
|
|
||||||
callID: "call-1",
|
|
||||||
command: "pwd",
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
expect(started.commits).toEqual([
|
expect(started.commits).toEqual([
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
|
|
@ -352,15 +377,7 @@ describe("run session data", () => {
|
||||||
])
|
])
|
||||||
|
|
||||||
data = started.data
|
data = started.data
|
||||||
const ended = reduce(data, {
|
const ended = reduce(data, shellEnded())
|
||||||
type: "session.shell.ended",
|
|
||||||
properties: {
|
|
||||||
sessionID: "session-1",
|
|
||||||
timestamp: 2,
|
|
||||||
callID: "call-1",
|
|
||||||
output: "/tmp/demo\n",
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
expect(ended.commits).toEqual([
|
expect(ended.commits).toEqual([
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
|
|
@ -379,15 +396,7 @@ describe("run session data", () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
test("suppresses legacy bash part updates once shell events claim the call", () => {
|
test("suppresses legacy bash part updates once shell events claim the call", () => {
|
||||||
let data = reduce(createSessionData(), {
|
let data = reduce(createSessionData(), shellStarted()).data
|
||||||
type: "session.shell.started",
|
|
||||||
properties: {
|
|
||||||
sessionID: "session-1",
|
|
||||||
timestamp: 1,
|
|
||||||
callID: "call-1",
|
|
||||||
command: "pwd",
|
|
||||||
},
|
|
||||||
}).data
|
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
reduce(
|
reduce(
|
||||||
|
|
@ -408,15 +417,7 @@ describe("run session data", () => {
|
||||||
).commits,
|
).commits,
|
||||||
).toEqual([])
|
).toEqual([])
|
||||||
|
|
||||||
data = reduce(data, {
|
data = reduce(data, shellEnded()).data
|
||||||
type: "session.shell.ended",
|
|
||||||
properties: {
|
|
||||||
sessionID: "session-1",
|
|
||||||
timestamp: 2,
|
|
||||||
callID: "call-1",
|
|
||||||
output: "/tmp/demo\n",
|
|
||||||
},
|
|
||||||
}).data
|
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
reduce(
|
reduce(
|
||||||
|
|
@ -462,15 +463,7 @@ describe("run session data", () => {
|
||||||
).data
|
).data
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
reduce(data, {
|
reduce(data, shellStarted()).commits,
|
||||||
type: "session.shell.started",
|
|
||||||
properties: {
|
|
||||||
sessionID: "session-1",
|
|
||||||
timestamp: 1,
|
|
||||||
callID: "call-1",
|
|
||||||
command: "pwd",
|
|
||||||
},
|
|
||||||
}).commits,
|
|
||||||
).toEqual([])
|
).toEqual([])
|
||||||
|
|
||||||
data = reduce(
|
data = reduce(
|
||||||
|
|
@ -496,15 +489,7 @@ describe("run session data", () => {
|
||||||
).data
|
).data
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
reduce(data, {
|
reduce(data, shellEnded()).commits,
|
||||||
type: "session.shell.ended",
|
|
||||||
properties: {
|
|
||||||
sessionID: "session-1",
|
|
||||||
timestamp: 2,
|
|
||||||
callID: "call-1",
|
|
||||||
output: "/tmp/demo\n",
|
|
||||||
},
|
|
||||||
}).commits,
|
|
||||||
).toEqual([])
|
).toEqual([])
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -606,7 +606,8 @@ function hit(url: string, body: unknown) {
|
||||||
|
|
||||||
function isTitleRequest(body: unknown): boolean {
|
function isTitleRequest(body: unknown): boolean {
|
||||||
if (!body || typeof body !== "object") return false
|
if (!body || typeof body !== "object") return false
|
||||||
return JSON.stringify(body).includes("Generate a title for this conversation")
|
const value = JSON.stringify(body)
|
||||||
|
return value.includes("Generate a title for this conversation") || value.includes("You are a title generator")
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace TestLLMServer {
|
namespace TestLLMServer {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue