feat(plugin): expose app metadata (#38179)
This commit is contained in:
parent
2ed8fe5960
commit
8de40be6ea
71 changed files with 477 additions and 286 deletions
|
|
@ -11,7 +11,7 @@ export const create = Effect.fn("OpenCode.create")(function* (options: ServerOpt
|
|||
ManagedRuntime.make(
|
||||
createEmbeddedRoutes({
|
||||
...options,
|
||||
client: options.client ?? "sdk",
|
||||
app: { ...options.app, name: options.app?.name ?? "sdk" },
|
||||
database: { path: ":memory:", ...options.database },
|
||||
}).pipe(Layer.provide(HttpServer.layerServices)),
|
||||
),
|
||||
|
|
|
|||
|
|
@ -25,6 +25,27 @@ const sessionID = (fixture: Fixture) => fixture.sdk.Session.ID.create()
|
|||
const location = (fixture: Fixture) =>
|
||||
fixture.sdk.Location.Ref.make({ directory: fixture.sdk.AbsolutePath.make(fixture.directory) })
|
||||
|
||||
it.live("exposes app metadata to plugins", () =>
|
||||
withEmbedded("opencode-embedded-app-", (fixture) =>
|
||||
Effect.gen(function* () {
|
||||
const opencode = yield* fixture.sdk.OpenCode.create({
|
||||
app: { name: "test", version: "1.2.3", channel: "beta" },
|
||||
})
|
||||
const app = yield* Deferred.make<{ readonly name: string; readonly version: string; readonly channel: string }>()
|
||||
yield* opencode.plugin({
|
||||
id: `app-${crypto.randomUUID()}`,
|
||||
effect: (ctx) => Deferred.succeed(app, ctx.app).pipe(Effect.asVoid),
|
||||
})
|
||||
yield* opencode.plugin.list({ location: location(fixture) })
|
||||
expect(yield* Deferred.await(app).pipe(Effect.timeout("4 seconds"))).toEqual({
|
||||
name: "test",
|
||||
version: "1.2.3",
|
||||
channel: "beta",
|
||||
})
|
||||
}),
|
||||
),
|
||||
)
|
||||
|
||||
it.live(
|
||||
"reloads every booted Location after SDK plugin registration",
|
||||
() =>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue