| 1 | import { |
| 2 | ChatImageAttachment, |
| 3 | ChatFileAttachment, |
| 4 | PROVIDER_SEND_TURN_MAX_ATTACHMENTS, |
| 5 | } from "./chatAttachment.ts"; |
| 6 | import * as Schema from "effect/Schema"; |
| 7 | |
| 8 | import { TrimmedNonEmptyString } from "./baseSchemas.ts"; |
| 9 | |
| 10 | export const ProviderApprovalPolicy = Schema.Literals([ |
| 11 | "untrusted", |
| 12 | "on-failure", |
| 13 | "on-request", |
| 14 | "never", |
| 15 | ]); |
| 16 | export type ProviderApprovalPolicy = typeof ProviderApprovalPolicy.Type; |
| 17 | |
| 18 | export const ProviderSandboxMode = Schema.Literals([ |
| 19 | "read-only", |
| 20 | "workspace-write", |
| 21 | "danger-full-access", |
| 22 | ]); |
| 23 | export type ProviderSandboxMode = typeof ProviderSandboxMode.Type; |
| 24 | |
| 25 | export const RuntimeMode = Schema.Literals([ |
| 26 | "approval-required", |
| 27 | "auto-accept-edits", |
| 28 | "auto", |
| 29 | "full-access", |
| 30 | ]); |
| 31 | export type RuntimeMode = typeof RuntimeMode.Type; |
| 32 | export const DEFAULT_RUNTIME_MODE: RuntimeMode = "full-access"; |
| 33 | |
| 34 | export const ProviderInteractionMode = Schema.Literals(["default", "plan"]); |
| 35 | export type ProviderInteractionMode = typeof ProviderInteractionMode.Type; |
| 36 | export const DEFAULT_PROVIDER_INTERACTION_MODE: ProviderInteractionMode = "default"; |
| 37 | |
| 38 | export const ProviderRequestKind = Schema.Literals([ |
| 39 | "command", |
| 40 | "file-read", |
| 41 | "file-change", |
| 42 | "mcp-elicitation", |
| 43 | "permission", |
| 44 | ]); |
| 45 | export type ProviderRequestKind = typeof ProviderRequestKind.Type; |
| 46 | |
| 47 | export const AssistantDeliveryMode = Schema.Literals(["buffered", "streaming"]); |
| 48 | export type AssistantDeliveryMode = typeof AssistantDeliveryMode.Type; |
| 49 | |
| 50 | export const ProviderApprovalDecision = Schema.Literals([ |
| 51 | "accept", |
| 52 | "acceptForSession", |
| 53 | "acceptAlways", |
| 54 | "decline", |
| 55 | "cancel", |
| 56 | ]); |
| 57 | export type ProviderApprovalDecision = typeof ProviderApprovalDecision.Type; |
| 58 | |
| 59 | export const ProviderApprovalOption = Schema.Struct({ |
| 60 | decision: ProviderApprovalDecision, |
| 61 | label: TrimmedNonEmptyString, |
| 62 | /** Provider-supplied caution shown next to the option, such as a prompt injection warning. */ |
| 63 | warning: Schema.optional(TrimmedNonEmptyString), |
| 64 | }); |
| 65 | export type ProviderApprovalOption = typeof ProviderApprovalOption.Type; |
| 66 | |
| 67 | export const ProviderUserInputAnswers = Schema.Record(Schema.String, Schema.Unknown); |
| 68 | export type ProviderUserInputAnswers = typeof ProviderUserInputAnswers.Type; |
| 69 | |
| 70 | export const UserInputAttachments = Schema.Record( |
| 71 | Schema.String, |
| 72 | Schema.Array(Schema.Union([ChatImageAttachment, ChatFileAttachment])).pipe( |
| 73 | Schema.check(Schema.isMaxLength(PROVIDER_SEND_TURN_MAX_ATTACHMENTS)), |
| 74 | ), |
| 75 | ); |
| 76 | export type UserInputAttachments = typeof UserInputAttachments.Type; |
| 77 | |
| 78 | export const UserInputAttachmentAnswerPayload = Schema.Struct({ |
| 79 | requestId: TrimmedNonEmptyString, |
| 80 | questionTextById: Schema.optional(Schema.Record(Schema.String, Schema.String)), |
| 81 | answers: ProviderUserInputAnswers, |
| 82 | attachmentsByQuestionId: UserInputAttachments, |
| 83 | }); |
| 84 | export type UserInputAttachmentAnswerPayload = typeof UserInputAttachmentAnswerPayload.Type; |