feat(core): port v2 runtime fixes onto dev

Cherry-picks the packages/core changes from the v2 branch onto dev:
- combined ordered stdout/stderr in AppProcess + bash structured output
- edit/apply-patch return FileDiff info with status and line stats
- ignore no-op model switches; record reasoning timestamps
- return unexpected local tool defects to the model and continue
- keep OAuth account metadata out of request bodies
- nest OpenAI reasoning effort/summary options
- load OpenCode provider config asynchronously; batch plugin boot
- export latest public event manifest

Includes the supporting schema reasoning time field and regenerated
client/SDK types.
This commit is contained in:
Dax Raad 2026-06-27 00:05:29 -04:00
commit 93159bccbf
28 changed files with 385 additions and 130 deletions

View file

@ -25,6 +25,20 @@ function required<T>(value: T | undefined): T {
return value
}
function eventually<A>(
effect: Effect.Effect<A>,
predicate: (value: A) => boolean,
remaining = 1000,
): Effect.Effect<A, Error> {
return Effect.gen(function* () {
const value = yield* effect
if (predicate(value)) return value
if (remaining === 0) return yield* Effect.fail(new Error("Timed out waiting for value"))
yield* Effect.promise(() => Bun.sleep(1))
return yield* eventually(effect, predicate, remaining - 1)
})
}
function withEnv<A, E, R>(vars: Record<string, string | undefined>, effect: () => Effect.Effect<A, E, R>) {
return Effect.acquireUseRelease(
Effect.sync(() => {
@ -67,11 +81,14 @@ describe("OpencodePlugin", () => {
Effect.acquireUseRelease(
Effect.sync(() => {
const authorization: Array<string | null> = []
const gate = Promise.withResolvers<void>()
return {
authorization,
release: gate.resolve,
server: Bun.serve({
port: 0,
fetch: (request) => {
fetch: async (request) => {
await gate.promise
authorization.push(request.headers.get("authorization"))
const origin = new URL(request.url).origin
return Response.json({
@ -110,7 +127,7 @@ describe("OpencodePlugin", () => {
}),
}
}),
({ authorization, server }) =>
({ authorization, release, server }) =>
Effect.gen(function* () {
const credentials = yield* Credential.Service
const catalog = yield* Catalog.Service
@ -128,8 +145,15 @@ describe("OpencodePlugin", () => {
})
yield* addPlugin()
expect(authorization).toEqual([])
release()
const provider = required(yield* catalog.provider.get(ProviderV2.ID.make("remote")))
const provider = required(
yield* eventually(
catalog.provider.get(ProviderV2.ID.make("remote")),
(item) => item?.integrationID === Integration.ID.make("opencode"),
),
)
expect(provider).toMatchObject({
name: "Remote",
integrationID: "opencode",