chore: generate
This commit is contained in:
@@ -270,10 +270,9 @@ export const sessionHandlers = HttpApiBuilder.group(InstanceHttpApi, "session",
|
|||||||
Effect.provideService(WorkspaceRef, workspace),
|
Effect.provideService(WorkspaceRef, workspace),
|
||||||
Effect.mapError(() => new HttpApiError.BadRequest({})),
|
Effect.mapError(() => new HttpApiError.BadRequest({})),
|
||||||
)
|
)
|
||||||
return HttpServerResponse.stream(
|
return HttpServerResponse.stream(Stream.make(JSON.stringify(message)).pipe(Stream.encodeText), {
|
||||||
Stream.make(JSON.stringify(message)).pipe(Stream.encodeText),
|
contentType: "application/json",
|
||||||
{ contentType: "application/json" },
|
})
|
||||||
)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
const promptAsync = Effect.fn("SessionHttpApi.promptAsync")(function* (ctx: {
|
const promptAsync = Effect.fn("SessionHttpApi.promptAsync")(function* (ctx: {
|
||||||
|
|||||||
@@ -389,12 +389,10 @@ export const layer: Layer.Layer<
|
|||||||
typeof attachment.mime === "string" &&
|
typeof attachment.mime === "string" &&
|
||||||
typeof attachment.url === "string",
|
typeof attachment.url === "string",
|
||||||
)
|
)
|
||||||
const normalized = yield* Effect.forEach(
|
const normalized = yield* Effect.forEach(toolAttachments, (attachment) =>
|
||||||
toolAttachments,
|
attachment.mime.startsWith("image/")
|
||||||
(attachment) =>
|
? image.normalize(attachment).pipe(Effect.exit)
|
||||||
attachment.mime.startsWith("image/")
|
: Effect.succeed(Exit.succeed<MessageV2.FilePart>(attachment)),
|
||||||
? image.normalize(attachment).pipe(Effect.exit)
|
|
||||||
: Effect.succeed(Exit.succeed<MessageV2.FilePart>(attachment)),
|
|
||||||
)
|
)
|
||||||
const omitted = normalized.filter(Exit.isFailure).length
|
const omitted = normalized.filter(Exit.isFailure).length
|
||||||
const attachments = normalized.filter(Exit.isSuccess).map((item) => item.value)
|
const attachments = normalized.filter(Exit.isSuccess).map((item) => item.value)
|
||||||
|
|||||||
@@ -1278,9 +1278,7 @@ NOTE: At any point in time through this workflow you should feel free to ask the
|
|||||||
)
|
)
|
||||||
|
|
||||||
const parts = yield* Effect.forEach(resolvedParts, (part) =>
|
const parts = yield* Effect.forEach(resolvedParts, (part) =>
|
||||||
part.type === "file" && part.mime.startsWith("image/")
|
part.type === "file" && part.mime.startsWith("image/") ? image.normalize(part) : Effect.succeed(part),
|
||||||
? image.normalize(part)
|
|
||||||
: Effect.succeed(part),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const parsed = MessageV2.Info.zod.safeParse(info)
|
const parsed = MessageV2.Info.zod.safeParse(info)
|
||||||
@@ -1376,26 +1374,26 @@ NOTE: At any point in time through this workflow you should feel free to ask the
|
|||||||
return { info, parts }
|
return { info, parts }
|
||||||
}, Effect.scoped)
|
}, Effect.scoped)
|
||||||
|
|
||||||
const prompt: (input: PromptInput) => Effect.Effect<MessageV2.WithParts, Image.Error> = Effect.fn("SessionPrompt.prompt")(
|
const prompt: (input: PromptInput) => Effect.Effect<MessageV2.WithParts, Image.Error> = Effect.fn(
|
||||||
function* (input: PromptInput) {
|
"SessionPrompt.prompt",
|
||||||
const session = yield* sessions.get(input.sessionID).pipe(Effect.orDie)
|
)(function* (input: PromptInput) {
|
||||||
yield* revert.cleanup(session)
|
const session = yield* sessions.get(input.sessionID).pipe(Effect.orDie)
|
||||||
const message = yield* createUserMessage(input)
|
yield* revert.cleanup(session)
|
||||||
yield* sessions.touch(input.sessionID)
|
const message = yield* createUserMessage(input)
|
||||||
|
yield* sessions.touch(input.sessionID)
|
||||||
|
|
||||||
const permissions: Permission.Ruleset = []
|
const permissions: Permission.Ruleset = []
|
||||||
for (const [t, enabled] of Object.entries(input.tools ?? {})) {
|
for (const [t, enabled] of Object.entries(input.tools ?? {})) {
|
||||||
permissions.push({ permission: t, action: enabled ? "allow" : "deny", pattern: "*" })
|
permissions.push({ permission: t, action: enabled ? "allow" : "deny", pattern: "*" })
|
||||||
}
|
}
|
||||||
if (permissions.length > 0) {
|
if (permissions.length > 0) {
|
||||||
session.permission = permissions
|
session.permission = permissions
|
||||||
yield* sessions.setPermission({ sessionID: session.id, permission: permissions })
|
yield* sessions.setPermission({ sessionID: session.id, permission: permissions })
|
||||||
}
|
}
|
||||||
|
|
||||||
if (input.noReply === true) return message
|
if (input.noReply === true) return message
|
||||||
return yield* loop({ sessionID: input.sessionID })
|
return yield* loop({ sessionID: input.sessionID })
|
||||||
},
|
})
|
||||||
)
|
|
||||||
|
|
||||||
const lastAssistant = Effect.fnUntraced(function* (sessionID: SessionID) {
|
const lastAssistant = Effect.fnUntraced(function* (sessionID: SessionID) {
|
||||||
const match = yield* sessions.findMessage(sessionID, (m) => m.info.role !== "user")
|
const match = yield* sessions.findMessage(sessionID, (m) => m.info.role !== "user")
|
||||||
|
|||||||
@@ -9,7 +9,9 @@ const it = testEffect(Layer.mergeAll(Image.layer.pipe(Layer.provide(TestConfig.l
|
|||||||
const tiny = testEffect(
|
const tiny = testEffect(
|
||||||
Layer.mergeAll(
|
Layer.mergeAll(
|
||||||
Image.layer.pipe(
|
Image.layer.pipe(
|
||||||
Layer.provide(TestConfig.layer({ get: () => Effect.succeed({ attachment: { image: { max_base64_bytes: 1 } } }) })),
|
Layer.provide(
|
||||||
|
TestConfig.layer({ get: () => Effect.succeed({ attachment: { image: { max_base64_bytes: 1 } } }) }),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
@@ -60,7 +62,9 @@ describe("Image", () => {
|
|||||||
const photon = yield* Effect.promise(() => import("@silvia-odwyer/photon-node"))
|
const photon = yield* Effect.promise(() => import("@silvia-odwyer/photon-node"))
|
||||||
const source = new photon.PhotonImage(new Uint8Array(Array.from({ length: 4 }, () => 255)), 1, 1)
|
const source = new photon.PhotonImage(new Uint8Array(Array.from({ length: 4 }, () => 255)), 1, 1)
|
||||||
const image = yield* Image.Service
|
const image = yield* Image.Service
|
||||||
const exit = yield* image.normalize(part("image/png", Buffer.from(source.get_bytes()).toString("base64"))).pipe(Effect.exit)
|
const exit = yield* image
|
||||||
|
.normalize(part("image/png", Buffer.from(source.get_bytes()).toString("base64")))
|
||||||
|
.pipe(Effect.exit)
|
||||||
|
|
||||||
source.free()
|
source.free()
|
||||||
expect(Exit.isFailure(exit)).toBe(true)
|
expect(Exit.isFailure(exit)).toBe(true)
|
||||||
|
|||||||
@@ -279,7 +279,10 @@ function llm() {
|
|||||||
function liveRuntime(layer: Layer.Layer<LLM.Service>, provider = ProviderTest.fake(), config = Config.defaultLayer) {
|
function liveRuntime(layer: Layer.Layer<LLM.Service>, provider = ProviderTest.fake(), config = Config.defaultLayer) {
|
||||||
const bus = Bus.layer
|
const bus = Bus.layer
|
||||||
const status = SessionStatus.layer.pipe(Layer.provide(bus))
|
const status = SessionStatus.layer.pipe(Layer.provide(bus))
|
||||||
const processor = SessionProcessorModule.SessionProcessor.layer.pipe(Layer.provide(summary), Layer.provide(Image.defaultLayer))
|
const processor = SessionProcessorModule.SessionProcessor.layer.pipe(
|
||||||
|
Layer.provide(summary),
|
||||||
|
Layer.provide(Image.defaultLayer),
|
||||||
|
)
|
||||||
return ManagedRuntime.make(
|
return ManagedRuntime.make(
|
||||||
Layer.mergeAll(SessionCompaction.layer.pipe(Layer.provide(processor)), processor, bus, status).pipe(
|
Layer.mergeAll(SessionCompaction.layer.pipe(Layer.provide(processor)), processor, bus, status).pipe(
|
||||||
Layer.provide(provider.layer),
|
Layer.provide(provider.layer),
|
||||||
|
|||||||
@@ -188,7 +188,11 @@ function makeHttp() {
|
|||||||
Layer.provideMerge(deps),
|
Layer.provideMerge(deps),
|
||||||
)
|
)
|
||||||
const trunc = Truncate.layer.pipe(Layer.provideMerge(deps))
|
const trunc = Truncate.layer.pipe(Layer.provideMerge(deps))
|
||||||
const proc = SessionProcessor.layer.pipe(Layer.provide(summary), Layer.provide(Image.defaultLayer), Layer.provideMerge(deps))
|
const proc = SessionProcessor.layer.pipe(
|
||||||
|
Layer.provide(summary),
|
||||||
|
Layer.provide(Image.defaultLayer),
|
||||||
|
Layer.provideMerge(deps),
|
||||||
|
)
|
||||||
const compact = SessionCompaction.layer.pipe(Layer.provideMerge(proc), Layer.provideMerge(deps))
|
const compact = SessionCompaction.layer.pipe(Layer.provideMerge(proc), Layer.provideMerge(deps))
|
||||||
return Layer.mergeAll(
|
return Layer.mergeAll(
|
||||||
TestLLMServer.layer,
|
TestLLMServer.layer,
|
||||||
|
|||||||
@@ -12010,6 +12010,36 @@
|
|||||||
"enum": ["auto", "stretch"],
|
"enum": ["auto", "stretch"],
|
||||||
"description": "@deprecated Always uses stretch layout."
|
"description": "@deprecated Always uses stretch layout."
|
||||||
},
|
},
|
||||||
|
"ImageAttachmentConfig": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"auto_resize": {
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
"max_width": {
|
||||||
|
"type": "integer",
|
||||||
|
"exclusiveMinimum": 0
|
||||||
|
},
|
||||||
|
"max_height": {
|
||||||
|
"type": "integer",
|
||||||
|
"exclusiveMinimum": 0
|
||||||
|
},
|
||||||
|
"max_base64_bytes": {
|
||||||
|
"type": "integer",
|
||||||
|
"exclusiveMinimum": 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"additionalProperties": false
|
||||||
|
},
|
||||||
|
"AttachmentConfig": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"image": {
|
||||||
|
"$ref": "#/components/schemas/ImageAttachmentConfig"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"additionalProperties": false
|
||||||
|
},
|
||||||
"Config": {
|
"Config": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
@@ -12340,6 +12370,9 @@
|
|||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"attachment": {
|
||||||
|
"$ref": "#/components/schemas/AttachmentConfig"
|
||||||
|
},
|
||||||
"enterprise": {
|
"enterprise": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
|||||||
Reference in New Issue
Block a user