@zyro-sec/schema 1.0.1 → 1.0.3

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 (136) hide show
  1. package/AGENTS.md +95 -95
  2. package/package.json +5 -1
  3. package/script/build.ts +9 -9
  4. package/script/config-schema.ts +86 -86
  5. package/script/config-v1.json +1311 -1311
  6. package/script/pack.ts +5 -5
  7. package/src/agent.ts +68 -68
  8. package/src/artifact.ts +81 -81
  9. package/src/automation.ts +224 -224
  10. package/src/blob-store.ts +25 -25
  11. package/src/command.ts +18 -18
  12. package/src/config/agent.ts +26 -26
  13. package/src/config/command.ts +14 -14
  14. package/src/config/compaction.ts +27 -27
  15. package/src/config/experimental.ts +72 -72
  16. package/src/config/flag.ts +39 -39
  17. package/src/config/formatter.ts +13 -13
  18. package/src/config/lsp.ts +19 -19
  19. package/src/config/mcp.ts +22 -22
  20. package/src/config/media.ts +15 -15
  21. package/src/config/model.ts +37 -37
  22. package/src/config/plugin.ts +14 -14
  23. package/src/config/policy.ts +57 -57
  24. package/src/config/provider.ts +122 -122
  25. package/src/config/reference.ts +23 -23
  26. package/src/config/shell.ts +10 -10
  27. package/src/config/tool-output.ts +9 -9
  28. package/src/config/warming.ts +21 -21
  29. package/src/config/watcher.ts +8 -8
  30. package/src/config/websearch.ts +17 -17
  31. package/src/config/worktree.ts +10 -10
  32. package/src/config.ts +149 -149
  33. package/src/connection.ts +38 -38
  34. package/src/credential-legacy.ts +29 -29
  35. package/src/credential.ts +78 -78
  36. package/src/durable-event-manifest.ts +7 -7
  37. package/src/event-log.ts +21 -21
  38. package/src/event-manifest.ts +108 -108
  39. package/src/event.ts +205 -205
  40. package/src/file-diff.ts +25 -25
  41. package/src/filesystem-v1.ts +1 -1
  42. package/src/filesystem.ts +48 -48
  43. package/src/form.ts +177 -177
  44. package/src/generate.ts +292 -292
  45. package/src/goal.ts +46 -46
  46. package/src/identifier.ts +32 -32
  47. package/src/index.ts +51 -51
  48. package/src/installation-event.ts +20 -20
  49. package/src/instruction-entry.ts +40 -40
  50. package/src/instruction.ts +25 -25
  51. package/src/integration-id.ts +13 -13
  52. package/src/integration.ts +129 -129
  53. package/src/job.ts +79 -79
  54. package/src/legacy-event.ts +1 -1
  55. package/src/llm.ts +6 -6
  56. package/src/location-event.ts +8 -8
  57. package/src/location.ts +36 -36
  58. package/src/lsp-event.ts +7 -7
  59. package/src/mcp-event.ts +63 -63
  60. package/src/mcp.ts +171 -171
  61. package/src/model-compatibility.ts +55 -55
  62. package/src/model.ts +176 -176
  63. package/src/models-dev.ts +9 -9
  64. package/src/money.ts +18 -18
  65. package/src/permission-saved.ts +25 -25
  66. package/src/permission-v1.ts +1 -1
  67. package/src/permission.ts +67 -67
  68. package/src/persistent-pty.ts +73 -73
  69. package/src/plugin.ts +62 -62
  70. package/src/project-id.ts +9 -9
  71. package/src/project.ts +62 -62
  72. package/src/prompt-input.ts +33 -33
  73. package/src/prompt.ts +117 -117
  74. package/src/provider.ts +136 -136
  75. package/src/pty-ticket.ts +10 -10
  76. package/src/pty.ts +61 -61
  77. package/src/push.ts +86 -86
  78. package/src/question.ts +22 -22
  79. package/src/reference.ts +40 -40
  80. package/src/rpc.ts +167 -167
  81. package/src/schema.ts +41 -41
  82. package/src/server-event.ts +8 -8
  83. package/src/session-error.ts +14 -14
  84. package/src/session-event.ts +739 -739
  85. package/src/session-fork.ts +10 -10
  86. package/src/session-id.ts +12 -12
  87. package/src/session-inbox.ts +102 -102
  88. package/src/session-legacy.ts +117 -117
  89. package/src/session-message.ts +352 -352
  90. package/src/session-metadata.ts +11 -11
  91. package/src/session-revert.ts +86 -86
  92. package/src/session-stats.ts +68 -68
  93. package/src/session-status-event.ts +53 -53
  94. package/src/session-transfer.ts +11 -11
  95. package/src/session-v1.ts +1 -1
  96. package/src/session.ts +147 -147
  97. package/src/shell.ts +90 -90
  98. package/src/skill.ts +68 -68
  99. package/src/snapshot.ts +6 -6
  100. package/src/token-usage.ts +18 -18
  101. package/src/tool.ts +143 -143
  102. package/src/tui-event.ts +59 -59
  103. package/src/usage-limits.ts +76 -76
  104. package/src/v1/filesystem.ts +11 -11
  105. package/src/v1/legacy-event.ts +18 -18
  106. package/src/v1/permission.ts +66 -66
  107. package/src/v1/session.ts +667 -667
  108. package/src/vcs-event.ts +14 -14
  109. package/src/vcs.ts +41 -41
  110. package/src/websearch.ts +44 -44
  111. package/src/workspace-event.ts +32 -32
  112. package/src/workspace-id.ts +19 -19
  113. package/src/workspace.ts +20 -20
  114. package/src/worktree-event.ts +22 -22
  115. package/src/worktree.ts +109 -109
  116. package/tsconfig.build.json +11 -11
  117. package/tsconfig.json +14 -14
  118. package/test/agent.test.ts +0 -10
  119. package/test/automation.test.ts +0 -48
  120. package/test/compatibility.test.ts +0 -10
  121. package/test/config.test.ts +0 -194
  122. package/test/contract-hygiene.test.ts +0 -352
  123. package/test/credential-legacy.test.ts +0 -55
  124. package/test/event-manifest.test.ts +0 -228
  125. package/test/event.test.ts +0 -52
  126. package/test/legacy-event.test.ts +0 -46
  127. package/test/mcp.test.ts +0 -37
  128. package/test/model.test.ts +0 -104
  129. package/test/session-cursor.test.ts +0 -16
  130. package/test/session-error.test.ts +0 -51
  131. package/test/session-legacy.test.ts +0 -178
  132. package/test/session-terminal.test.ts +0 -50
  133. package/test/token-usage.test.ts +0 -18
  134. package/test/v1-isolation.test.ts +0 -26
  135. package/test/vcs.test.ts +0 -23
  136. package/test/worktree.test.ts +0 -45
package/src/config.ts CHANGED
@@ -1,149 +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) }
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) }
package/src/connection.ts CHANGED
@@ -1,38 +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
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
@@ -1,29 +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 })
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 })
package/src/credential.ts CHANGED
@@ -1,78 +1,78 @@
1
- export * as Credential from "./credential.js"
2
-
3
- import { Schema } from "effect"
4
- import { optional } from "./schema.js"
5
- import { ephemeral, inventory } from "./event.js"
6
- import { IntegrationID, IntegrationMethodID } from "./integration-id.js"
7
- import { ascending } from "./identifier.js"
8
- import { NonNegativeInt, statics } from "./schema.js"
9
-
10
- export const ID = Schema.String.pipe(
11
- Schema.brand("Credential.ID"),
12
- Schema.annotate({ identifier: "Credential.ID" }),
13
- statics((schema) => ({ create: () => schema.make("cred_" + ascending()) })),
14
- )
15
- export type ID = typeof ID.Type
16
-
17
- // A login was added, renamed or removed. Every change is to exactly one credential.
18
- const Updated = ephemeral({
19
- type: "credential.updated",
20
- schema: { integrationID: IntegrationID, credentialID: ID },
21
- })
22
- const Switched = ephemeral({
23
- type: "credential.switched",
24
- schema: { integrationID: IntegrationID, credentialID: Schema.NullOr(ID) },
25
- })
26
- export const Event = {
27
- Updated,
28
- Switched,
29
- Definitions: inventory(Updated, Switched),
30
- }
31
-
32
- export interface OAuth extends Schema.Schema.Type<typeof OAuth> {}
33
- export const OAuth = Schema.Struct({
34
- type: Schema.Literal("oauth"),
35
- methodID: IntegrationMethodID,
36
- refresh: Schema.String,
37
- access: Schema.String,
38
- expires: NonNegativeInt,
39
- metadata: optional(Schema.Record(Schema.String, Schema.Unknown)),
40
- }).annotate({ identifier: "Credential.OAuth" })
41
-
42
- export interface Key extends Schema.Schema.Type<typeof Key> {}
43
- export const Key = Schema.Struct({
44
- type: Schema.Literal("key"),
45
- key: Schema.String,
46
- metadata: optional(Schema.Record(Schema.String, Schema.Unknown)),
47
- }).annotate({ identifier: "Credential.Key" })
48
-
49
- /** References a credential source whose secrets and renewal are managed outside the credential store. */
50
- export interface External extends Schema.Schema.Type<typeof External> {}
51
- export const External = Schema.Struct({
52
- type: Schema.Literal("external"),
53
- methodID: IntegrationMethodID,
54
- metadata: optional(Schema.Record(Schema.String, Schema.Unknown)),
55
- }).annotate({ identifier: "Credential.External" })
56
-
57
- export const Value = Schema.Union([OAuth, Key, External])
58
- .pipe(Schema.toTaggedUnion("type"))
59
- .annotate({ identifier: "Credential.Value" })
60
- export type Value = Schema.Schema.Type<typeof Value>
61
-
62
- export interface Entry extends Schema.Schema.Type<typeof Entry> {}
63
- export const Entry = Schema.Struct({
64
- id: ID,
65
- integrationID: IntegrationID,
66
- label: Schema.String,
67
- active: Schema.Boolean,
68
- value: Value,
69
- }).annotate({ identifier: "Credential.Entry" })
70
-
71
- export interface CreateInput extends Schema.Schema.Type<typeof CreateInput> {}
72
- export const CreateInput = Schema.Struct({
73
- id: optional(ID),
74
- integrationID: IntegrationID,
75
- label: optional(Schema.String),
76
- value: Value,
77
- activate: optional(Schema.Boolean),
78
- }).annotate({ identifier: "Credential.CreateInput" })
1
+ export * as Credential from "./credential.js"
2
+
3
+ import { Schema } from "effect"
4
+ import { optional } from "./schema.js"
5
+ import { ephemeral, inventory } from "./event.js"
6
+ import { IntegrationID, IntegrationMethodID } from "./integration-id.js"
7
+ import { ascending } from "./identifier.js"
8
+ import { NonNegativeInt, statics } from "./schema.js"
9
+
10
+ export const ID = Schema.String.pipe(
11
+ Schema.brand("Credential.ID"),
12
+ Schema.annotate({ identifier: "Credential.ID" }),
13
+ statics((schema) => ({ create: () => schema.make("cred_" + ascending()) })),
14
+ )
15
+ export type ID = typeof ID.Type
16
+
17
+ // A login was added, renamed or removed. Every change is to exactly one credential.
18
+ const Updated = ephemeral({
19
+ type: "credential.updated",
20
+ schema: { integrationID: IntegrationID, credentialID: ID },
21
+ })
22
+ const Switched = ephemeral({
23
+ type: "credential.switched",
24
+ schema: { integrationID: IntegrationID, credentialID: Schema.NullOr(ID) },
25
+ })
26
+ export const Event = {
27
+ Updated,
28
+ Switched,
29
+ Definitions: inventory(Updated, Switched),
30
+ }
31
+
32
+ export interface OAuth extends Schema.Schema.Type<typeof OAuth> {}
33
+ export const OAuth = Schema.Struct({
34
+ type: Schema.Literal("oauth"),
35
+ methodID: IntegrationMethodID,
36
+ refresh: Schema.String,
37
+ access: Schema.String,
38
+ expires: NonNegativeInt,
39
+ metadata: optional(Schema.Record(Schema.String, Schema.Unknown)),
40
+ }).annotate({ identifier: "Credential.OAuth" })
41
+
42
+ export interface Key extends Schema.Schema.Type<typeof Key> {}
43
+ export const Key = Schema.Struct({
44
+ type: Schema.Literal("key"),
45
+ key: Schema.String,
46
+ metadata: optional(Schema.Record(Schema.String, Schema.Unknown)),
47
+ }).annotate({ identifier: "Credential.Key" })
48
+
49
+ /** References a credential source whose secrets and renewal are managed outside the credential store. */
50
+ export interface External extends Schema.Schema.Type<typeof External> {}
51
+ export const External = Schema.Struct({
52
+ type: Schema.Literal("external"),
53
+ methodID: IntegrationMethodID,
54
+ metadata: optional(Schema.Record(Schema.String, Schema.Unknown)),
55
+ }).annotate({ identifier: "Credential.External" })
56
+
57
+ export const Value = Schema.Union([OAuth, Key, External])
58
+ .pipe(Schema.toTaggedUnion("type"))
59
+ .annotate({ identifier: "Credential.Value" })
60
+ export type Value = Schema.Schema.Type<typeof Value>
61
+
62
+ export interface Entry extends Schema.Schema.Type<typeof Entry> {}
63
+ export const Entry = Schema.Struct({
64
+ id: ID,
65
+ integrationID: IntegrationID,
66
+ label: Schema.String,
67
+ active: Schema.Boolean,
68
+ value: Value,
69
+ }).annotate({ identifier: "Credential.Entry" })
70
+
71
+ export interface CreateInput extends Schema.Schema.Type<typeof CreateInput> {}
72
+ export const CreateInput = Schema.Struct({
73
+ id: optional(ID),
74
+ integrationID: IntegrationID,
75
+ label: optional(Schema.String),
76
+ value: Value,
77
+ activate: optional(Schema.Boolean),
78
+ }).annotate({ identifier: "Credential.CreateInput" })
@@ -1,7 +1,7 @@
1
- export * as DurableEventManifest from "./durable-event-manifest.js"
2
-
3
- import { Event } from "./event.js"
4
- import { Worktree } from "./worktree.js"
5
- import { SessionEvent } from "./session-event.js"
6
-
7
- export const Durable = Event.durableMap([...SessionEvent.DurableDefinitions, Worktree.Event.Resolved])
1
+ export * as DurableEventManifest from "./durable-event-manifest.js"
2
+
3
+ import { Event } from "./event.js"
4
+ import { Worktree } from "./worktree.js"
5
+ import { SessionEvent } from "./session-event.js"
6
+
7
+ export const Durable = Event.durableMap([...SessionEvent.DurableDefinitions, Worktree.Event.Resolved])
package/src/event-log.ts CHANGED
@@ -1,21 +1,21 @@
1
- export * as EventLog from "./event-log.js"
2
-
3
- import { Schema } from "effect"
4
- import { Event } from "./event.js"
5
- import { optional } from "./schema.js"
6
-
7
- /**
8
- * Replay-to-live boundary marker for a durable log read. The reader now holds
9
- * every event committed at or below this watermark; `seq` is absent when the
10
- * captured watermark is empty. Emitted once for the captured watermark.
11
- */
12
- export const Synced = Schema.Struct({
13
- type: Schema.Literal("log.synced"),
14
- aggregateID: Schema.String,
15
- seq: optional(Event.Seq),
16
- }).annotate({
17
- identifier: "EventLog.Synced",
18
- description:
19
- "Marker emitted once when a log read reaches its captured watermark. The reader holds every event committed at or below seq.",
20
- })
21
- export interface Synced extends Schema.Schema.Type<typeof Synced> {}
1
+ export * as EventLog from "./event-log.js"
2
+
3
+ import { Schema } from "effect"
4
+ import { Event } from "./event.js"
5
+ import { optional } from "./schema.js"
6
+
7
+ /**
8
+ * Replay-to-live boundary marker for a durable log read. The reader now holds
9
+ * every event committed at or below this watermark; `seq` is absent when the
10
+ * captured watermark is empty. Emitted once for the captured watermark.
11
+ */
12
+ export const Synced = Schema.Struct({
13
+ type: Schema.Literal("log.synced"),
14
+ aggregateID: Schema.String,
15
+ seq: optional(Event.Seq),
16
+ }).annotate({
17
+ identifier: "EventLog.Synced",
18
+ description:
19
+ "Marker emitted once when a log read reaches its captured watermark. The reader holds every event committed at or below seq.",
20
+ })
21
+ export interface Synced extends Schema.Schema.Type<typeof Synced> {}