Showing the changes to apps/server/src/textGeneration/OpenCodeTextGeneration.ts (1 of 4 files). Show all
Unified · Split
| @@ -389,19 +389,21 @@ export const makeOpenCodeTextGeneration = Effect.fn("makeOpenCodeTextGeneration" · 388 unmodified lines | ||
| 389 | 389 | ? { serverPassword: openCodeSettings.serverPassword } |
| 390 | 390 | : {}), |
| 391 | 391 | }); |
| 392 | − const session = yield* Effect.tryPromise({ | |
| 393 | − try: () => | |
| 394 | − client.session.create({ | |
| 395 | − title: `T3 Code ${input.operation}`, | |
| 396 | − permission: [{ permission: "*", pattern: "*", action: "deny" }], | |
| 397 | − }), | |
| 398 | − catch: (cause) => | |
| 399 | − new OpenCodeTextGenerationSessionRequestError({ | |
| 400 | − operation: input.operation, | |
| 401 | − cwd: input.cwd, | |
| 402 | − cause, | |
| 403 | − }), | |
| 404 | − }); | |
| 392 | + const session = yield* OpenCodeRuntime.runOpenCodeSdk("session.create", () => | |
| 393 | + client.session.create({ | |
| 394 | + title: `T3 Code ${input.operation}`, | |
| 395 | + permission: [{ permission: "*", pattern: "*", action: "deny" }], | |
| 396 | + }), | |
| 397 | + ).pipe( | |
| 398 | + Effect.mapError( | |
| 399 | + (cause) => | |
| 400 | + new OpenCodeTextGenerationSessionRequestError({ | |
| 401 | + operation: input.operation, | |
| 402 | + cwd: input.cwd, | |
| 403 | + cause: cause.cause, | |
| 404 | + }), | |
| 405 | + ), | |
| 406 | + ); | |
| 405 | 407 | if (!session.data) { |
| 406 | 408 | return yield* new OpenCodeTextGenerationSessionPayloadError({ |
| 407 | 409 | operation: input.operation, |
| @@ -418,21 +420,23 @@ export const makeOpenCodeTextGeneration = Effect.fn("makeOpenCodeTextGeneration" · 10 unmodified lines | ||
| 418 | 420 | modelId: parsedModel.modelID, |
| 419 | 421 | }; |
| 420 | 422 | |
| 421 | − const result = yield* Effect.tryPromise({ | |
| 422 | − try: () => | |
| 423 | − client.session.prompt({ | |
| 424 | − sessionID: session.data.id, | |
| 425 | − model: parsedModel, | |
| 426 | − ...(selectedAgent ? { agent: selectedAgent } : {}), | |
| 427 | − ...(selectedVariant ? { variant: selectedVariant } : {}), | |
| 428 | − parts: [{ type: "text", text: input.prompt }, ...fileParts], | |
| 429 | − }), | |
| 430 | − catch: (cause) => | |
| 431 | − new OpenCodeTextGenerationPromptRequestError({ | |
| 432 | − ...promptContext, | |
| 433 | − cause, | |
| 434 | − }), | |
| 435 | − }); | |
| 423 | + const result = yield* OpenCodeRuntime.runOpenCodeSdk("session.prompt", () => | |
| 424 | + client.session.prompt({ | |
| 425 | + sessionID: session.data.id, | |
| 426 | + model: parsedModel, | |
| 427 | + ...(selectedAgent ? { agent: selectedAgent } : {}), | |
| 428 | + ...(selectedVariant ? { variant: selectedVariant } : {}), | |
| 429 | + parts: [{ type: "text", text: input.prompt }, ...fileParts], | |
| 430 | + }), | |
| 431 | + ).pipe( | |
| 432 | + Effect.mapError( | |
| 433 | + (cause) => | |
| 434 | + new OpenCodeTextGenerationPromptRequestError({ | |
| 435 | + ...promptContext, | |
| 436 | + cause: cause.cause, | |
| 437 | + }), | |
| 438 | + ), | |
| 439 | + ); | |
| 436 | 440 | const promptFailure = getOpenCodePromptFailure(result.data?.info?.error); |
| 437 | 441 | if (promptFailure) { |
| 438 | 442 | return yield* new OpenCodeTextGenerationPromptResponseError({ |