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