@zyro-sec/schema 0.0.0-stage → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (137) hide show
  1. package/AGENTS.md +95 -0
  2. package/package.json +31 -4
  3. package/script/build.ts +9 -0
  4. package/script/config-schema.ts +86 -0
  5. package/script/config-v1.json +1312 -0
  6. package/script/pack.ts +5 -0
  7. package/src/agent.ts +68 -0
  8. package/src/artifact.ts +81 -0
  9. package/src/automation.ts +224 -0
  10. package/src/blob-store.ts +25 -0
  11. package/src/command.ts +18 -0
  12. package/src/config/agent.ts +26 -0
  13. package/src/config/command.ts +14 -0
  14. package/src/config/compaction.ts +27 -0
  15. package/src/config/experimental.ts +72 -0
  16. package/src/config/flag.ts +39 -0
  17. package/src/config/formatter.ts +13 -0
  18. package/src/config/lsp.ts +19 -0
  19. package/src/config/mcp.ts +22 -0
  20. package/src/config/media.ts +15 -0
  21. package/src/config/model.ts +37 -0
  22. package/src/config/plugin.ts +14 -0
  23. package/src/config/policy.ts +57 -0
  24. package/src/config/provider.ts +122 -0
  25. package/src/config/reference.ts +23 -0
  26. package/src/config/shell.ts +10 -0
  27. package/src/config/tool-output.ts +9 -0
  28. package/src/config/warming.ts +21 -0
  29. package/src/config/watcher.ts +8 -0
  30. package/src/config/websearch.ts +17 -0
  31. package/src/config/worktree.ts +10 -0
  32. package/src/config.ts +149 -0
  33. package/src/connection.ts +38 -0
  34. package/src/credential-legacy.ts +29 -0
  35. package/src/credential.ts +78 -0
  36. package/src/durable-event-manifest.ts +7 -0
  37. package/src/event-log.ts +21 -0
  38. package/src/event-manifest.ts +108 -0
  39. package/src/event.ts +205 -0
  40. package/src/file-diff.ts +25 -0
  41. package/src/filesystem-v1.ts +1 -0
  42. package/src/filesystem.ts +48 -0
  43. package/src/form.ts +177 -0
  44. package/src/generate.ts +292 -0
  45. package/src/goal.ts +46 -0
  46. package/src/identifier.ts +32 -0
  47. package/src/index.ts +51 -0
  48. package/src/installation-event.ts +20 -0
  49. package/src/instruction-entry.ts +40 -0
  50. package/src/instruction.ts +25 -0
  51. package/src/integration-id.ts +13 -0
  52. package/src/integration.ts +129 -0
  53. package/src/job.ts +79 -0
  54. package/src/legacy-event.ts +1 -0
  55. package/src/llm.ts +6 -0
  56. package/src/location-event.ts +8 -0
  57. package/src/location.ts +36 -0
  58. package/src/lsp-event.ts +7 -0
  59. package/src/mcp-event.ts +63 -0
  60. package/src/mcp.ts +171 -0
  61. package/src/model-compatibility.ts +55 -0
  62. package/src/model.ts +176 -0
  63. package/src/models-dev.ts +9 -0
  64. package/src/money.ts +18 -0
  65. package/src/permission-saved.ts +25 -0
  66. package/src/permission-v1.ts +1 -0
  67. package/src/permission.ts +67 -0
  68. package/src/persistent-pty.ts +73 -0
  69. package/src/plugin.ts +62 -0
  70. package/src/project-id.ts +9 -0
  71. package/src/project.ts +62 -0
  72. package/src/prompt-input.ts +33 -0
  73. package/src/prompt.ts +117 -0
  74. package/src/provider.ts +136 -0
  75. package/src/pty-ticket.ts +10 -0
  76. package/src/pty.ts +61 -0
  77. package/src/push.ts +86 -0
  78. package/src/question.ts +22 -0
  79. package/src/reference.ts +40 -0
  80. package/src/rpc.ts +167 -0
  81. package/src/schema.ts +41 -0
  82. package/src/server-event.ts +8 -0
  83. package/src/session-error.ts +14 -0
  84. package/src/session-event.ts +739 -0
  85. package/src/session-fork.ts +10 -0
  86. package/src/session-id.ts +12 -0
  87. package/src/session-inbox.ts +102 -0
  88. package/src/session-legacy.ts +117 -0
  89. package/src/session-message.ts +352 -0
  90. package/src/session-metadata.ts +11 -0
  91. package/src/session-revert.ts +86 -0
  92. package/src/session-stats.ts +68 -0
  93. package/src/session-status-event.ts +53 -0
  94. package/src/session-transfer.ts +11 -0
  95. package/src/session-v1.ts +1 -0
  96. package/src/session.ts +147 -0
  97. package/src/shell.ts +90 -0
  98. package/src/skill.ts +68 -0
  99. package/src/snapshot.ts +6 -0
  100. package/src/token-usage.ts +18 -0
  101. package/src/tool.ts +143 -0
  102. package/src/tui-event.ts +59 -0
  103. package/src/usage-limits.ts +76 -0
  104. package/src/v1/filesystem.ts +11 -0
  105. package/src/v1/legacy-event.ts +18 -0
  106. package/src/v1/permission.ts +66 -0
  107. package/src/v1/session.ts +667 -0
  108. package/src/vcs-event.ts +14 -0
  109. package/src/vcs.ts +41 -0
  110. package/src/websearch.ts +44 -0
  111. package/src/workspace-event.ts +32 -0
  112. package/src/workspace-id.ts +19 -0
  113. package/src/workspace.ts +20 -0
  114. package/src/worktree-event.ts +22 -0
  115. package/src/worktree.ts +109 -0
  116. package/test/agent.test.ts +10 -0
  117. package/test/automation.test.ts +48 -0
  118. package/test/compatibility.test.ts +10 -0
  119. package/test/config.test.ts +194 -0
  120. package/test/contract-hygiene.test.ts +352 -0
  121. package/test/credential-legacy.test.ts +55 -0
  122. package/test/event-manifest.test.ts +228 -0
  123. package/test/event.test.ts +52 -0
  124. package/test/legacy-event.test.ts +46 -0
  125. package/test/mcp.test.ts +37 -0
  126. package/test/model.test.ts +104 -0
  127. package/test/session-cursor.test.ts +16 -0
  128. package/test/session-error.test.ts +51 -0
  129. package/test/session-legacy.test.ts +178 -0
  130. package/test/session-terminal.test.ts +50 -0
  131. package/test/token-usage.test.ts +18 -0
  132. package/test/v1-isolation.test.ts +26 -0
  133. package/test/vcs.test.ts +23 -0
  134. package/test/worktree.test.ts +45 -0
  135. package/tsconfig.build.json +11 -0
  136. package/tsconfig.json +14 -0
  137. package/README.md +0 -3
@@ -0,0 +1,22 @@
1
+ export * as ConfigMCP from "./mcp.js"
2
+
3
+ import { Schema } from "effect"
4
+ import { Mcp } from "../mcp.js"
5
+ import { optional } from "../schema.js"
6
+
7
+ export const Timeout = Mcp.TimeoutConfig
8
+ export type Timeout = Mcp.TimeoutConfig
9
+ export const Local = Mcp.LocalConfig
10
+ export type Local = Mcp.LocalConfig
11
+ export const OAuth = Mcp.OAuthConfig
12
+ export type OAuth = Mcp.OAuthConfig
13
+ export const Remote = Mcp.RemoteConfig
14
+ export type Remote = Mcp.RemoteConfig
15
+ export const Server = Mcp.ServerConfig
16
+ export const Protocol = Mcp.Protocol
17
+ export type Protocol = Mcp.Protocol
18
+
19
+ export class Info extends Schema.Class<Info>("Config.MCP")({
20
+ timeout: Timeout.pipe(optional),
21
+ servers: Schema.Record(Schema.String, Server).pipe(optional),
22
+ }) {}
@@ -0,0 +1,15 @@
1
+ export * as ConfigMedia from "./media.js"
2
+
3
+ import { Schema } from "effect"
4
+ import { optional, PositiveInt } from "../schema.js"
5
+
6
+ export class Image extends Schema.Class<Image>("Config.Media.Image")({
7
+ auto_resize: Schema.Boolean.pipe(optional),
8
+ max_width: PositiveInt.pipe(optional),
9
+ max_height: PositiveInt.pipe(optional),
10
+ max_base64_bytes: PositiveInt.pipe(optional),
11
+ }) {}
12
+
13
+ export class Info extends Schema.Class<Info>("Config.Media")({
14
+ image: Image.pipe(optional),
15
+ }) {}
@@ -0,0 +1,37 @@
1
+ export * as ConfigModel from "./model.js"
2
+
3
+ import { Schema, SchemaGetter } from "effect"
4
+ import { Model } from "../model.js"
5
+ import { Provider } from "../provider.js"
6
+ import { optional } from "../schema.js"
7
+
8
+ const ProviderID = Provider.ID.check(Schema.isPattern(/^[^/#]+$/u))
9
+ const ModelID = Model.ID.check(Schema.isPattern(/^[^#]+$/u))
10
+ const VariantID = Model.VariantID.check(Schema.isPattern(/^[^#]+$/u))
11
+
12
+ const Explicit = Schema.Struct({
13
+ providerID: ProviderID,
14
+ model: ModelID,
15
+ variant: VariantID.pipe(optional),
16
+ })
17
+
18
+ const Short = Schema.String.check(Schema.isPattern(/^[^/#]+\/[^#]+(?:#[^#]+)?$/u))
19
+
20
+ export interface Selection extends Schema.Schema.Type<typeof Explicit> {}
21
+ export const Selection = Schema.Union([Short, Explicit])
22
+ .pipe(
23
+ Schema.decodeTo(Explicit, {
24
+ decode: SchemaGetter.transform((input) => (typeof input === "string" ? parse(input) : input)),
25
+ encode: SchemaGetter.passthrough({ strict: false }),
26
+ }),
27
+ )
28
+ .annotate({ identifier: "Config.ModelSelection" })
29
+
30
+ function parse(input: string): Selection {
31
+ const ref = Model.Ref.parse(input)
32
+ return {
33
+ providerID: ref.providerID,
34
+ model: ref.id,
35
+ ...(ref.variant ? { variant: ref.variant } : {}),
36
+ }
37
+ }
@@ -0,0 +1,14 @@
1
+ export * as ConfigPlugin from "./plugin.js"
2
+
3
+ import { Schema } from "effect"
4
+ import { optional } from "../schema.js"
5
+
6
+ export class Entry extends Schema.Class<Entry>("Config.Plugin.Entry")({
7
+ package: Schema.String,
8
+ options: Schema.Record(Schema.String, Schema.Unknown).pipe(optional),
9
+ }) {}
10
+
11
+ export const Plugin = Schema.Union([Schema.String, Entry])
12
+ export type Plugin = typeof Plugin.Type
13
+
14
+ export const Plugins = Plugin.pipe(Schema.Array)
@@ -0,0 +1,57 @@
1
+ export * as ConfigPolicy from "./policy.js"
2
+
3
+ import { Schema, SchemaGetter } from "effect"
4
+
5
+ export const Effect = Schema.Literals(["allow", "deny"])
6
+ export type Effect = typeof Effect.Type
7
+
8
+ /**
9
+ * - `provider.use`: resource is a provider ID.
10
+ * - `tool.use`: resource is `<tool>:<input>`, such as `shell:git *`.
11
+ * - `integration.connect`: resource is an integration ID; controls which integrations can be listed and connected.
12
+ * - `integration.use`: resource is `<integration>#<account>`, or the bare integration ID when the providers, models,
13
+ * web search, MCP servers, or config an integration supplies come from no account (env keys, local config, the
14
+ * signed-out free tier).
15
+ * - `mcp.use`, `skill.use`, `plugin.use`: resource is an MCP server name, skill ID, or plugin target.
16
+ * - `websearch.use`: resource is a web search provider ID, such as `opencode` or `exa`.
17
+ */
18
+ export const Action = Schema.Literals([
19
+ "provider.use",
20
+ "tool.use",
21
+ "integration.connect",
22
+ "integration.use",
23
+ "mcp.use",
24
+ "skill.use",
25
+ "plugin.use",
26
+ "websearch.use",
27
+ ])
28
+ export type Action = typeof Action.Type
29
+
30
+ const Statement = Schema.Struct({
31
+ action: Action,
32
+ resource: Schema.String,
33
+ effect: Effect,
34
+ })
35
+
36
+ // Before `mcp.use`, `skill.use` and `plugin.use` existed, `integration.use` covered them with a resource prefix.
37
+ // Every policy source decodes through this schema, so this is the only place that knows the legacy form. Only prefixed
38
+ // resources convert: a bare `integration.use` `*` keeps its action and now covers providers and accounts.
39
+ const legacy = new Map<string, Action>([
40
+ ["mcp", "mcp.use"],
41
+ ["skill", "skill.use"],
42
+ ["plugin", "plugin.use"],
43
+ ])
44
+
45
+ export const Info = Statement.pipe(
46
+ Schema.decodeTo(Schema.toType(Statement), {
47
+ decode: SchemaGetter.transform((policy) => {
48
+ if (policy.action !== "integration.use") return policy
49
+ const separator = policy.resource.indexOf(":")
50
+ const action = separator === -1 ? undefined : legacy.get(policy.resource.slice(0, separator))
51
+ if (!action) return policy
52
+ return { ...policy, action, resource: policy.resource.slice(separator + 1) }
53
+ }),
54
+ encode: SchemaGetter.passthrough(),
55
+ }),
56
+ )
57
+ export type Info = typeof Info.Type
@@ -0,0 +1,122 @@
1
+ export * as ConfigProvider from "./provider.js"
2
+
3
+ import { Schema, Struct } from "effect"
4
+ import { Money } from "../money.js"
5
+ import { Capabilities, Compatibility, Family, ID, Model, Type, VariantID } from "../model.js"
6
+ import { ProviderCompatibility } from "../model-compatibility.js"
7
+ import { Provider } from "../provider.js"
8
+ import { optional } from "../schema.js"
9
+
10
+ export const Settings = Schema.StructWithRest(Schema.Struct(Provider.Settings.schema.fields), [
11
+ Schema.Record(Schema.String, Schema.UndefinedOr(Schema.Json)),
12
+ ]).annotate({ identifier: "Config.Provider.Settings" })
13
+ export type Settings = typeof Settings.Type
14
+
15
+ export const ModelSettings = Schema.StructWithRest(Schema.Struct(Model.Settings.schema.fields), [
16
+ Schema.Record(Schema.String, Schema.UndefinedOr(Schema.Json)),
17
+ ]).annotate({ identifier: "Config.Model.Settings" })
18
+ export type ModelSettings = typeof ModelSettings.Type
19
+
20
+ const JsonRecord = Schema.Record(Schema.String, Schema.Json)
21
+
22
+ export const Overlays = {
23
+ settings: Settings.pipe(optional),
24
+ headers: Schema.Record(Schema.String, Schema.String).pipe(optional),
25
+ body: JsonRecord.pipe(optional),
26
+ }
27
+
28
+ const ModelOverlays = {
29
+ settings: ModelSettings.pipe(optional),
30
+ headers: Schema.Record(Schema.String, Schema.String).pipe(optional),
31
+ body: JsonRecord.pipe(optional),
32
+ }
33
+
34
+ export class Request extends Schema.Class<Request>("Config.Provider.Request")({
35
+ headers: Overlays.headers,
36
+ body: Overlays.body,
37
+ }) {}
38
+
39
+ class Cache extends Schema.Class<Cache>("Config.Model.Cost.Cache")({
40
+ read: Money.USDPerMillionTokens.pipe(optional),
41
+ write: Money.USDPerMillionTokens.pipe(optional),
42
+ }) {}
43
+
44
+ class Cost extends Schema.Class<Cost>("Config.Model.Cost")({
45
+ tier: Schema.Struct({
46
+ type: Schema.Literal("context"),
47
+ size: Schema.Int,
48
+ }).pipe(optional),
49
+ input: Money.USDPerMillionTokens,
50
+ output: Money.USDPerMillionTokens,
51
+ cache: Cache.pipe(optional),
52
+ }) {}
53
+
54
+ class Limit extends Schema.Class<Limit>("Config.Model.Limit")({
55
+ context: Schema.Int.pipe(optional),
56
+ input: Schema.Int.pipe(optional),
57
+ output: Schema.Int.pipe(optional),
58
+ }) {}
59
+
60
+ // models.dev v2's `capabilities.reasoning`. OpenCode builds the model's variants from it; no control means none.
61
+ export const Reasoning = Schema.Union([
62
+ Schema.Struct({ supported: Schema.Literal(false) }),
63
+ Schema.Struct({
64
+ supported: Schema.Literal(true),
65
+ toggle: Schema.Boolean.pipe(optional),
66
+ effort: Schema.String.pipe(Schema.Array, optional),
67
+ budget: Schema.Struct({
68
+ min: Schema.Int.pipe(optional),
69
+ max: Schema.Int.pipe(optional),
70
+ }).pipe(optional),
71
+ }),
72
+ ]).annotate({ identifier: "Config.Model.Reasoning" })
73
+ export type Reasoning = typeof Reasoning.Type
74
+
75
+ class ModelConfig extends Schema.Class<ModelConfig>("Config.Model")({
76
+ modelID: ID.pipe(optional),
77
+ type: Type.pipe(optional),
78
+ family: Family.pipe(optional),
79
+ name: Schema.String.pipe(optional),
80
+ releaseDate: Schema.String.check(Schema.isPattern(/^\d{4}-\d{2}(-\d{2})?$/u))
81
+ .annotate({ description: "Release date as YYYY-MM-DD or YYYY-MM" })
82
+ .pipe(optional),
83
+ compatibility: Compatibility.pipe(optional),
84
+ package: Schema.String.pipe(optional),
85
+ ...ModelOverlays,
86
+ // Partial: unset fields fall back to the base model's capabilities, then the defaults.
87
+ capabilities: Capabilities.mapFields((fields) => ({
88
+ tools: optional(fields.tools),
89
+ freeform: fields.freeform,
90
+ input: optional(fields.input),
91
+ output: optional(fields.output),
92
+ temperature: fields.temperature,
93
+ reasoning: Reasoning.pipe(optional),
94
+ }))
95
+ .annotate({ identifier: "Config.Model.Capabilities" })
96
+ .pipe(optional),
97
+ variants: Schema.Struct({
98
+ id: VariantID,
99
+ ...ModelOverlays,
100
+ // The prompt cache belongs to the model, so a variant can't change it.
101
+ settings: Schema.StructWithRest(
102
+ Schema.Struct(Struct.omit(ModelSettings.schema.fields, ["cache"])),
103
+ ModelSettings.records,
104
+ )
105
+ .annotate({ identifier: "Config.Model.VariantSettings" })
106
+ .pipe(optional),
107
+ }).pipe(Schema.Array, optional),
108
+ cost: Schema.Union([Cost, Cost.pipe(Schema.Array)]).pipe(optional),
109
+ disabled: Schema.Boolean.pipe(optional),
110
+ limit: Limit.pipe(optional),
111
+ }) {}
112
+
113
+ export class Info extends Schema.Class<Info>("Config.Provider")({
114
+ canonical: Provider.ID.pipe(optional),
115
+ name: Schema.String.pipe(optional),
116
+ env: Schema.String.pipe(Schema.Array, optional),
117
+ package: Schema.String.pipe(optional),
118
+ // Defaults for every model of this provider; model compatibility overrides individual fields.
119
+ compatibility: ProviderCompatibility.pipe(optional),
120
+ ...Overlays,
121
+ models: Schema.Record(Schema.String, ModelConfig).pipe(optional),
122
+ }) {}
@@ -0,0 +1,23 @@
1
+ export * as ConfigReference from "./reference.js"
2
+
3
+ import { Schema } from "effect"
4
+ import { optional } from "../schema.js"
5
+
6
+ export class Git extends Schema.Class<Git>("Config.Reference.Git")({
7
+ repository: Schema.String,
8
+ branch: Schema.String.pipe(optional),
9
+ description: Schema.String.pipe(optional),
10
+ hidden: Schema.Boolean.pipe(optional),
11
+ }) {}
12
+
13
+ export class Local extends Schema.Class<Local>("Config.Reference.Local")({
14
+ path: Schema.String,
15
+ description: Schema.String.pipe(optional),
16
+ hidden: Schema.Boolean.pipe(optional),
17
+ }) {}
18
+
19
+ export const Entry = Schema.Union([Schema.String, Git, Local])
20
+ export type Entry = typeof Entry.Type
21
+
22
+ export const Info = Schema.Record(Schema.String, Entry)
23
+ export type Info = typeof Info.Type
@@ -0,0 +1,10 @@
1
+ export * as ConfigShell from "./shell.js"
2
+
3
+ import { Schema } from "effect"
4
+
5
+ export const Option = Schema.Struct({
6
+ path: Schema.String,
7
+ name: Schema.String,
8
+ acceptable: Schema.Boolean,
9
+ }).annotate({ identifier: "ConfigShell.Option" })
10
+ export interface Option extends Schema.Schema.Type<typeof Option> {}
@@ -0,0 +1,9 @@
1
+ export * as ConfigToolOutput from "./tool-output.js"
2
+
3
+ import { Schema } from "effect"
4
+ import { optional, PositiveInt } from "../schema.js"
5
+
6
+ export class Info extends Schema.Class<Info>("Config.ToolOutput")({
7
+ max_lines: PositiveInt.pipe(optional),
8
+ max_bytes: PositiveInt.pipe(optional),
9
+ }) {}
@@ -0,0 +1,21 @@
1
+ export * as ConfigWarming from "./warming.js"
2
+
3
+ import { Schema } from "effect"
4
+ import { optional } from "../schema.js"
5
+
6
+ export class Info extends Schema.Class<Info>("Config.Warming")({
7
+ prompt: Schema.String.pipe(optional).annotate({
8
+ description: "Prompt sent for keep-alive requests",
9
+ }),
10
+ interval: Schema.Union([Schema.Literal("auto"), Schema.DurationFromString])
11
+ .pipe(optional)
12
+ .annotate({
13
+ description:
14
+ 'Idle time between keep-alive requests (default: "auto"). "auto" uses 90% of the model\'s cache.ttl, or 4 minutes when it has none.',
15
+ }),
16
+ duration: Schema.DurationFromString.pipe(optional).annotate({
17
+ description: 'Time after the last active request to keep a session warm (default: "30 minutes")',
18
+ }),
19
+ }) {}
20
+
21
+ export const Warming = Schema.Union([Schema.Boolean, Info])
@@ -0,0 +1,8 @@
1
+ export * as ConfigWatcher from "./watcher.js"
2
+
3
+ import { Schema } from "effect"
4
+ import { optional } from "../schema.js"
5
+
6
+ export class Info extends Schema.Class<Info>("Config.Watcher")({
7
+ ignore: Schema.String.pipe(Schema.Array, optional),
8
+ }) {}
@@ -0,0 +1,17 @@
1
+ export * as ConfigWebSearch from "./websearch.js"
2
+
3
+ import { Schema } from "effect"
4
+ import { WebSearch } from "../websearch.js"
5
+
6
+ export class Info extends Schema.Class<Info>("ConfigWebSearch.Info")({
7
+ provider: Schema.Union([
8
+ Schema.Literal("random").annotate({
9
+ description:
10
+ "Reuse a randomly selected provider until it is rate limited, then switch to another available provider.",
11
+ }),
12
+ WebSearch.ID,
13
+ ]),
14
+ }) {}
15
+
16
+ export const Selection = Schema.Union([Schema.Literal(false), Info])
17
+ export type Selection = typeof Selection.Type
@@ -0,0 +1,10 @@
1
+ export * as ConfigWorktree from "./worktree.js"
2
+
3
+ import { Schema } from "effect"
4
+
5
+ export const Info = Schema.Struct({
6
+ directory: Schema.Trim.pipe(Schema.check(Schema.isNonEmpty())).annotate({
7
+ description: "Parent directory for new worktrees, relative to the project's primary checkout when not absolute",
8
+ }),
9
+ }).annotate({ identifier: "Config.Worktree" })
10
+ export interface Info extends Schema.Schema.Type<typeof Info> {}
package/src/config.ts ADDED
@@ -0,0 +1,149 @@
1
+ export * as Config from "./config.js"
2
+
3
+ import { Schema } from "effect"
4
+ import { ephemeral, inventory } from "./event.js"
5
+ import { Permission } from "./permission.js"
6
+ import { AbsolutePath, optional } from "./schema.js"
7
+ import { ConfigAgent } from "./config/agent.js"
8
+ import { ConfigMedia } from "./config/media.js"
9
+ import { ConfigCompaction } from "./config/compaction.js"
10
+ import { ConfigCommand } from "./config/command.js"
11
+ import { ConfigExperimental } from "./config/experimental.js"
12
+ import { ConfigFormatter } from "./config/formatter.js"
13
+ import { ConfigLSP } from "./config/lsp.js"
14
+ import { ConfigMCP } from "./config/mcp.js"
15
+ import { ConfigModel } from "./config/model.js"
16
+ import { ConfigPlugin } from "./config/plugin.js"
17
+ import { ConfigPolicy } from "./config/policy.js"
18
+ import { ConfigProvider } from "./config/provider.js"
19
+ import { ConfigReference } from "./config/reference.js"
20
+ import { ConfigWebSearch } from "./config/websearch.js"
21
+ import { ConfigToolOutput } from "./config/tool-output.js"
22
+ import { ConfigWatcher } from "./config/watcher.js"
23
+ import { ConfigWarming } from "./config/warming.js"
24
+ import { ConfigWorktree } from "./config/worktree.js"
25
+
26
+ export class Info extends Schema.Class<Info>("Config.Info")({
27
+ $schema: optional(Schema.String).annotate({
28
+ description: "JSON schema reference for configuration validation",
29
+ }),
30
+ shell: Schema.String.pipe(optional).annotate({
31
+ description: "Default shell to use for terminal and shell tool execution",
32
+ }),
33
+ model: ConfigModel.Selection.pipe(optional).annotate({
34
+ description: "Default model to use when no session or agent model is selected",
35
+ }),
36
+ default_agent: Schema.String.pipe(optional).annotate({
37
+ description: "Default primary agent to use when no session agent is selected",
38
+ }),
39
+ update: Schema.Literals(["disable", "notify", "auto"]).pipe(optional).annotate({
40
+ description: "Disable updates, notify when one is available, or install updates automatically",
41
+ }),
42
+ share: Schema.Literals(["manual", "auto", "disabled"]).pipe(optional).annotate({
43
+ description: "Control whether sessions may be shared manually, automatically, or not at all",
44
+ }),
45
+ enterprise: Schema.Struct({
46
+ url: Schema.String.pipe(optional),
47
+ })
48
+ .pipe(optional)
49
+ .annotate({
50
+ description: "Enterprise sharing service configuration",
51
+ }),
52
+ username: Schema.String.pipe(optional).annotate({
53
+ description: "Username displayed in conversations and used for telemetry identity",
54
+ }),
55
+ timezone: Schema.String.pipe(optional).annotate({
56
+ description: "IANA time zone for schedules, e.g. America/Los_Angeles. Defaults to the server's local zone",
57
+ }),
58
+ automations: Schema.Boolean.pipe(optional).annotate({
59
+ description:
60
+ "Run prompts, shell commands or Code Mode actions on a timer, on a cron schedule, or on push events from connected MCP servers. Defaults to true; set false to disable.",
61
+ }),
62
+ permissions: Permission.Ruleset.pipe(optional).annotate({
63
+ description: "Ordered tool permission rules applied to agent tool use",
64
+ }),
65
+ policies: ConfigPolicy.Info.pipe(Schema.Array, optional).annotate({
66
+ description: "Ordered policies controlling access to providers, tools, and integrations",
67
+ }),
68
+ agents: Schema.Record(Schema.String, ConfigAgent.Info).pipe(optional).annotate({
69
+ description: "Named built-in agent overrides and custom agent definitions",
70
+ }),
71
+ snapshots: Schema.Boolean.pipe(optional).annotate({
72
+ description: "Enable snapshots used for undo and revert behavior",
73
+ }),
74
+ watcher: ConfigWatcher.Info.pipe(optional).annotate({
75
+ description: "Filesystem watcher configuration",
76
+ }),
77
+ formatter: ConfigFormatter.Info.pipe(optional).annotate({
78
+ description: "Enable built-in formatters or configure formatter overrides",
79
+ }),
80
+ lsp: ConfigLSP.Info.pipe(optional).annotate({
81
+ description: "Enable built-in language servers or configure server overrides",
82
+ }),
83
+ media: ConfigMedia.Info.pipe(optional).annotate({
84
+ description: "Media processing configuration",
85
+ }),
86
+ tool_output: ConfigToolOutput.Info.pipe(optional).annotate({
87
+ description: "Tool output truncation thresholds",
88
+ }),
89
+ mcp: ConfigMCP.Info.pipe(optional).annotate({
90
+ description: "MCP server configuration",
91
+ }),
92
+ compaction: ConfigCompaction.Info.pipe(optional).annotate({
93
+ description: "Conversation compaction behavior",
94
+ }),
95
+ skills: Schema.String.pipe(Schema.Array, optional).annotate({
96
+ description: "Additional paths or URLs to discover skills from",
97
+ }),
98
+ commands: Schema.Record(Schema.String, ConfigCommand.Info).pipe(optional).annotate({
99
+ description: "Named slash command definitions",
100
+ }),
101
+ instructions: Schema.String.pipe(Schema.Array, optional).annotate({
102
+ description: "Additional paths or URLs supplying ambient instructions",
103
+ }),
104
+ references: ConfigReference.Info.pipe(optional).annotate({
105
+ description: "Named local directories or Git repositories available as external context",
106
+ }),
107
+ websearch: ConfigWebSearch.Selection.pipe(optional).annotate({
108
+ description: "Web search provider selection",
109
+ }),
110
+ plugins: ConfigPlugin.Plugins.pipe(optional).annotate({
111
+ description: "Ordered plugin enablement directives and external package declarations",
112
+ }),
113
+ worktree: ConfigWorktree.Info.pipe(optional).annotate({
114
+ description: "Directory defaults for local worktree creation",
115
+ }),
116
+ warming: ConfigWarming.Warming.pipe(optional).annotate({
117
+ description: "Keep recently active sessions warm with transient model requests (default: false)",
118
+ }),
119
+ providers: Schema.Record(Schema.String, ConfigProvider.Info).pipe(optional),
120
+ experimental: ConfigExperimental.Info.pipe(optional),
121
+ }) {}
122
+
123
+ export const Patch = Schema.Struct({
124
+ shell: Schema.NullOr(Schema.String),
125
+ }).annotate({ identifier: "Config.Patch" })
126
+ export interface Patch extends Schema.Schema.Type<typeof Patch> {}
127
+
128
+ export class Document extends Schema.Class<Document>("Config.Document")({
129
+ type: Schema.Literal("document"),
130
+ path: AbsolutePath.pipe(optional),
131
+ info: Info,
132
+ }) {}
133
+
134
+ export class Directory extends Schema.Class<Directory>("Config.Directory")({
135
+ type: Schema.Literal("directory"),
136
+ path: AbsolutePath,
137
+ }) {}
138
+
139
+ export const Entry = Schema.Union([Document, Directory]).annotate({
140
+ identifier: "Config.Entry",
141
+ })
142
+ export type Entry = typeof Entry.Type
143
+
144
+ const Updated = ephemeral({
145
+ type: "config.updated",
146
+ schema: {},
147
+ })
148
+
149
+ export const Event = { Updated, Definitions: inventory(Updated) }
@@ -0,0 +1,38 @@
1
+ export * as Connection from "./connection.js"
2
+
3
+ import { Schema } from "effect"
4
+ import { Credential } from "./credential.js"
5
+ import { optional } from "./schema.js"
6
+
7
+ /**
8
+ * Runtime problem an integration reported for a connection. `needs_auth` asks the user to sign in again:
9
+ * at `url` when set (the credential itself stays valid), otherwise by reconnecting the integration.
10
+ */
11
+ export interface Status extends Schema.Schema.Type<typeof Status> {}
12
+ export const Status = Schema.Struct({
13
+ status: Schema.Literals(["needs_auth"]),
14
+ message: Schema.String,
15
+ url: optional(Schema.String),
16
+ }).annotate({ identifier: "Connection.Status" })
17
+
18
+ export interface CredentialInfo extends Schema.Schema.Type<typeof CredentialInfo> {}
19
+ export const CredentialInfo = Schema.Struct({
20
+ type: Schema.Literal("credential"),
21
+ id: Credential.ID,
22
+ label: Schema.String,
23
+ /** Whether the connection stores a key, an OAuth grant, or an external credential-source reference. */
24
+ method: Schema.Literals(["key", "oauth", "external"]),
25
+ status: optional(Status),
26
+ }).annotate({ identifier: "Connection.CredentialInfo" })
27
+
28
+ export interface EnvInfo extends Schema.Schema.Type<typeof EnvInfo> {}
29
+ export const EnvInfo = Schema.Struct({
30
+ type: Schema.Literal("env"),
31
+ name: Schema.String,
32
+ status: optional(Status),
33
+ }).annotate({ identifier: "Connection.EnvInfo" })
34
+
35
+ export const Info = Schema.Union([CredentialInfo, EnvInfo])
36
+ .pipe(Schema.toTaggedUnion("type"))
37
+ .annotate({ identifier: "Connection.Info" })
38
+ export type Info = typeof Info.Type
@@ -0,0 +1,29 @@
1
+ export * as CredentialLegacy from "./credential-legacy.js"
2
+
3
+ import { Schema, SchemaTransformation } from "effect"
4
+ import { Credential } from "./credential.js"
5
+ import { Form } from "./form.js"
6
+ import { optional } from "./schema.js"
7
+
8
+ /**
9
+ * Storage and import compatibility for credentials written before v2.1 (not V1 contracts). Key credentials then kept
10
+ * their setup-form answers in `configuration`; they now live in `metadata`. Only decoders for stored rows and
11
+ * `auth export` files use these schemas, so the public credential contract never sees the old field.
12
+ */
13
+ const Key = Schema.Struct({ ...Credential.Key.fields, configuration: optional(Form.Answer) }).pipe(
14
+ Schema.decodeTo(
15
+ Credential.Key,
16
+ SchemaTransformation.transform({
17
+ // Form answers overrode metadata when both reached provider settings, so they keep precedence.
18
+ decode: ({ configuration, ...key }) =>
19
+ configuration === undefined ? key : { ...key, metadata: { ...key.metadata, ...configuration } },
20
+ encode: (key) => key,
21
+ }),
22
+ ),
23
+ )
24
+
25
+ /** Decodes a stored or exported credential value of either shape into the current `Credential.Value`. */
26
+ export const Value = Schema.Union([Credential.OAuth, Key, Credential.External])
27
+
28
+ /** Decodes an `auth export` entry of either shape into the current `Credential.Entry`. */
29
+ export const Entry = Schema.Struct({ ...Credential.Entry.fields, value: Value })