1/**
2 * ACP Registry instance settings. Shared by the server driver and the client
3 * settings form, so it holds only browser-safe schema code.
4 *
5 * @module provider-acp-registry/settings
6 */
7import { TrimmedString, makeProviderSettingsSchema } from "@t3tools/contracts";
8import * as Effect from "effect/Effect";
9import * as Schema from "effect/Schema";
10
11export const AcpRegistryDistributionPreference = Schema.Literals(["auto", "binary", "npx", "uvx"]);
12export type AcpRegistryDistributionPreference = typeof AcpRegistryDistributionPreference.Type;
13
14export const AcpRegistrySettings = makeProviderSettingsSchema(
15 {
16 source: Schema.Literals(["registry", "local"]).pipe(
17 Schema.withDecodingDefault(Effect.succeed("registry")),
18 Schema.annotateKey({
19 title: "ACP source",
20 providerSettingsForm: {
21 control: "select",
22 options: [
23 { value: "registry", label: "ACP Registry" },
24 { value: "local", label: "Local command" },
25 ],
26 },
27 }),
28 ),
29 enabled: Schema.Boolean.pipe(
30 Schema.withDecodingDefault(Effect.succeed(true)),
31 Schema.annotateKey({ providerSettingsForm: { hidden: true } }),
32 ),
33 agentId: TrimmedString.pipe(
34 Schema.withDecodingDefault(Effect.succeed("")),
35 Schema.annotateKey({
36 title: "Registry agent ID",
37 description: "Agent identifier from the official ACP Registry, for example 'devin'.",
38 providerSettingsForm: { placeholder: "devin", clearWhenEmpty: "persist" },
39 }),
40 ),
41 commandPath: TrimmedString.pipe(
42 Schema.withDecodingDefault(Effect.succeed("")),
43 Schema.annotateKey({
44 title: "Executable override",
45 description:
46 "Executable on this environment. For registry agents, this overrides the distribution executable while keeping its arguments and environment.",
47 providerSettingsForm: { placeholder: "Registry default", clearWhenEmpty: "omit" },
48 }),
49 ),
50 commandArgs: Schema.Array(Schema.String).pipe(
51 Schema.withDecodingDefault(Effect.succeed([])),
52 Schema.annotateKey({ providerSettingsForm: { hidden: true } }),
53 ),
54 authMethodId: TrimmedString.pipe(
55 Schema.withDecodingDefault(Effect.succeed("")),
56 Schema.annotateKey({
57 title: "Authentication method",
58 description:
59 "Optional ACP authentication method ID. By default, the first agent-managed method is selected.",
60 providerSettingsForm: { placeholder: "auto", clearWhenEmpty: "omit" },
61 }),
62 ),
63 distribution: AcpRegistryDistributionPreference.pipe(
64 Schema.withDecodingDefault(Effect.succeed("auto")),
65 Schema.annotateKey({ providerSettingsForm: { hidden: true } }),
66 ),
67 customModels: Schema.Array(Schema.String).pipe(
68 Schema.withDecodingDefault(Effect.succeed([])),
69 Schema.annotateKey({ providerSettingsForm: { hidden: true } }),
70 ),
71 },
72 {
73 order: ["source", "agentId", "commandPath", "authMethodId"],
74 },
75);
76export type AcpRegistrySettings = typeof AcpRegistrySettings.Type;