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 ProviderApprovalDecision = Schema.Literals([
48 "accept",
49 "acceptForSession",
50 "acceptAlways",
51 "decline",
52 "cancel",
53]);
54export type ProviderApprovalDecision = typeof ProviderApprovalDecision.Type;
55
56// Why an approval reached the user although the thread runs with full access:
57// the user's own ask rule, or a check the provider enforces even when bypassed.
58export const ProviderApprovalFullAccessOverride = Schema.Literals(["ask_rule", "provider_check"]);
59export type ProviderApprovalFullAccessOverride = typeof ProviderApprovalFullAccessOverride.Type;
60
61export const ProviderApprovalOption = Schema.Struct({
62 decision: ProviderApprovalDecision,
63 label: TrimmedNonEmptyString,
64 warning: Schema.optional(TrimmedNonEmptyString),
65});
66export type ProviderApprovalOption = typeof ProviderApprovalOption.Type;
67
68export const ProviderUserInputAnswers = Schema.Record(Schema.String, Schema.Unknown);
69export type ProviderUserInputAnswers = typeof ProviderUserInputAnswers.Type;
70
71export const UserInputAttachments = Schema.Record(
72 Schema.String,
73 Schema.Array(Schema.Union([ChatImageAttachment, ChatFileAttachment])).pipe(
74 Schema.check(Schema.isMaxLength(PROVIDER_SEND_TURN_MAX_ATTACHMENTS)),
75 ),
76);
77export type UserInputAttachments = typeof UserInputAttachments.Type;
78
79export const UserInputAttachmentAnswerPayload = Schema.Struct({
80 requestId: TrimmedNonEmptyString,
81 questionTextById: Schema.optional(Schema.Record(Schema.String, Schema.String)),
82 answers: ProviderUserInputAnswers,
83 attachmentsByQuestionId: UserInputAttachments,
84});
85export type UserInputAttachmentAnswerPayload = typeof UserInputAttachmentAnswerPayload.Type;