@dual-os/sdk 0.0.0-stage → 0.8.0-next.0

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 (214) hide show
  1. package/LICENSE +4 -0
  2. package/README.md +19 -2
  3. package/dist/Action.d.ts +201 -0
  4. package/dist/Action.d.ts.map +1 -0
  5. package/dist/Action.js +172 -0
  6. package/dist/Action.js.map +1 -0
  7. package/dist/AgentChannel.d.ts +1717 -0
  8. package/dist/AgentChannel.d.ts.map +1 -0
  9. package/dist/AgentChannel.js +708 -0
  10. package/dist/AgentChannel.js.map +1 -0
  11. package/dist/AgentChannelConformance.d.ts +1543 -0
  12. package/dist/AgentChannelConformance.d.ts.map +1 -0
  13. package/dist/AgentChannelConformance.js +163 -0
  14. package/dist/AgentChannelConformance.js.map +1 -0
  15. package/dist/AgentChannelRuntime.d.ts +78 -0
  16. package/dist/AgentChannelRuntime.d.ts.map +1 -0
  17. package/dist/AgentChannelRuntime.js +270 -0
  18. package/dist/AgentChannelRuntime.js.map +1 -0
  19. package/dist/AiProvider.d.ts +132 -0
  20. package/dist/AiProvider.d.ts.map +1 -0
  21. package/dist/AiProvider.js +100 -0
  22. package/dist/AiProvider.js.map +1 -0
  23. package/dist/AuthMethod.d.ts +381 -0
  24. package/dist/AuthMethod.d.ts.map +1 -0
  25. package/dist/AuthMethod.js +225 -0
  26. package/dist/AuthMethod.js.map +1 -0
  27. package/dist/AuthMethodBinding.d.ts +77 -0
  28. package/dist/AuthMethodBinding.d.ts.map +1 -0
  29. package/dist/AuthMethodBinding.js +31 -0
  30. package/dist/AuthMethodBinding.js.map +1 -0
  31. package/dist/AuthMethodExecution.d.ts +223 -0
  32. package/dist/AuthMethodExecution.d.ts.map +1 -0
  33. package/dist/AuthMethodExecution.js +277 -0
  34. package/dist/AuthMethodExecution.js.map +1 -0
  35. package/dist/ConnectionResolver.d.ts +219 -0
  36. package/dist/ConnectionResolver.d.ts.map +1 -0
  37. package/dist/ConnectionResolver.js +153 -0
  38. package/dist/ConnectionResolver.js.map +1 -0
  39. package/dist/DefinitionError.d.ts +67 -0
  40. package/dist/DefinitionError.d.ts.map +1 -0
  41. package/dist/DefinitionError.js +82 -0
  42. package/dist/DefinitionError.js.map +1 -0
  43. package/dist/DualRegistry.d.ts +71 -0
  44. package/dist/DualRegistry.d.ts.map +1 -0
  45. package/dist/DualRegistry.js +96 -0
  46. package/dist/DualRegistry.js.map +1 -0
  47. package/dist/DualRuntime.d.ts +279 -0
  48. package/dist/DualRuntime.d.ts.map +1 -0
  49. package/dist/DualRuntime.js +311 -0
  50. package/dist/DualRuntime.js.map +1 -0
  51. package/dist/Files.d.ts +80 -0
  52. package/dist/Files.d.ts.map +1 -0
  53. package/dist/Files.js +66 -0
  54. package/dist/Files.js.map +1 -0
  55. package/dist/Group.d.ts +106 -0
  56. package/dist/Group.d.ts.map +1 -0
  57. package/dist/Group.js +86 -0
  58. package/dist/Group.js.map +1 -0
  59. package/dist/Http.d.ts +342 -0
  60. package/dist/Http.d.ts.map +1 -0
  61. package/dist/Http.js +677 -0
  62. package/dist/Http.js.map +1 -0
  63. package/dist/Mcp.d.ts +109 -0
  64. package/dist/Mcp.d.ts.map +1 -0
  65. package/dist/Mcp.js +176 -0
  66. package/dist/Mcp.js.map +1 -0
  67. package/dist/OAuth2TokenRefresher.d.ts +18 -0
  68. package/dist/OAuth2TokenRefresher.d.ts.map +1 -0
  69. package/dist/OAuth2TokenRefresher.js +19 -0
  70. package/dist/OAuth2TokenRefresher.js.map +1 -0
  71. package/dist/OAuthFlow.d.ts +71 -0
  72. package/dist/OAuthFlow.d.ts.map +1 -0
  73. package/dist/OAuthFlow.js +488 -0
  74. package/dist/OAuthFlow.js.map +1 -0
  75. package/dist/Plugin.d.ts +383 -0
  76. package/dist/Plugin.d.ts.map +1 -0
  77. package/dist/Plugin.js +249 -0
  78. package/dist/Plugin.js.map +1 -0
  79. package/dist/PluginRuntime.d.ts +3186 -0
  80. package/dist/PluginRuntime.d.ts.map +1 -0
  81. package/dist/PluginRuntime.js +331 -0
  82. package/dist/PluginRuntime.js.map +1 -0
  83. package/dist/Runner.d.ts +1 -0
  84. package/dist/Runner.js +124 -0
  85. package/dist/Runner.js.map +1 -0
  86. package/dist/ToolFile.d.ts +23 -0
  87. package/dist/ToolFile.d.ts.map +1 -0
  88. package/dist/ToolFile.js +33 -0
  89. package/dist/ToolFile.js.map +1 -0
  90. package/dist/Trigger.d.ts +358 -0
  91. package/dist/Trigger.d.ts.map +1 -0
  92. package/dist/Trigger.js +287 -0
  93. package/dist/Trigger.js.map +1 -0
  94. package/dist/_virtual/_rolldown/runtime.js +13 -0
  95. package/dist/index.d.ts +24 -0
  96. package/dist/index.js +24 -0
  97. package/dist/internal/auth-context.d.ts +23 -0
  98. package/dist/internal/auth-context.d.ts.map +1 -0
  99. package/dist/internal/auth-context.js +1 -0
  100. package/dist/internal/auth-execution.d.ts +27 -0
  101. package/dist/internal/auth-execution.d.ts.map +1 -0
  102. package/dist/internal/auth-execution.js +66 -0
  103. package/dist/internal/auth-execution.js.map +1 -0
  104. package/dist/internal/auth-runtime.d.ts +5 -0
  105. package/dist/internal/auth-runtime.d.ts.map +1 -0
  106. package/dist/internal/auth-runtime.js +16 -0
  107. package/dist/internal/auth-runtime.js.map +1 -0
  108. package/dist/internal/capabilities.d.ts +24 -0
  109. package/dist/internal/capabilities.d.ts.map +1 -0
  110. package/dist/internal/capabilities.js +22 -0
  111. package/dist/internal/capabilities.js.map +1 -0
  112. package/dist/internal/children.d.ts +34 -0
  113. package/dist/internal/children.d.ts.map +1 -0
  114. package/dist/internal/children.js +53 -0
  115. package/dist/internal/children.js.map +1 -0
  116. package/dist/internal/collection-utils.d.ts +4 -0
  117. package/dist/internal/collection-utils.d.ts.map +1 -0
  118. package/dist/internal/collection-utils.js +6 -0
  119. package/dist/internal/collection-utils.js.map +1 -0
  120. package/dist/internal/dual/actions.d.ts +33 -0
  121. package/dist/internal/dual/actions.d.ts.map +1 -0
  122. package/dist/internal/dual/actions.js +26 -0
  123. package/dist/internal/dual/actions.js.map +1 -0
  124. package/dist/internal/dual/invoke.d.ts +63 -0
  125. package/dist/internal/dual/invoke.d.ts.map +1 -0
  126. package/dist/internal/dual/invoke.js +75 -0
  127. package/dist/internal/dual/invoke.js.map +1 -0
  128. package/dist/internal/dual/registry.d.ts +125 -0
  129. package/dist/internal/dual/registry.d.ts.map +1 -0
  130. package/dist/internal/dual/registry.js +172 -0
  131. package/dist/internal/dual/registry.js.map +1 -0
  132. package/dist/internal/dual/triggers.d.ts +29 -0
  133. package/dist/internal/dual/triggers.d.ts.map +1 -0
  134. package/dist/internal/dual/triggers.js +26 -0
  135. package/dist/internal/dual/triggers.js.map +1 -0
  136. package/dist/internal/handler-context.d.ts +9 -0
  137. package/dist/internal/handler-context.d.ts.map +1 -0
  138. package/dist/internal/handler-context.js +31 -0
  139. package/dist/internal/handler-context.js.map +1 -0
  140. package/dist/internal/identifier.d.ts +6 -0
  141. package/dist/internal/identifier.d.ts.map +1 -0
  142. package/dist/internal/identifier.js +28 -0
  143. package/dist/internal/identifier.js.map +1 -0
  144. package/dist/internal/plugin-handlers.d.ts +38 -0
  145. package/dist/internal/plugin-handlers.d.ts.map +1 -0
  146. package/dist/internal/plugin-handlers.js +52 -0
  147. package/dist/internal/plugin-handlers.js.map +1 -0
  148. package/dist/internal/proto.d.ts +7 -0
  149. package/dist/internal/proto.d.ts.map +1 -0
  150. package/dist/internal/proto.js +10 -0
  151. package/dist/internal/proto.js.map +1 -0
  152. package/dist/internal/schema-runtime.d.ts +6 -0
  153. package/dist/internal/schema-runtime.d.ts.map +1 -0
  154. package/dist/internal/schema-runtime.js +10 -0
  155. package/dist/internal/schema-runtime.js.map +1 -0
  156. package/dist/internal/trigger-runtime-shared.d.ts +41 -0
  157. package/dist/internal/trigger-runtime-shared.d.ts.map +1 -0
  158. package/dist/internal/trigger-runtime-shared.js +132 -0
  159. package/dist/internal/trigger-runtime-shared.js.map +1 -0
  160. package/dist/internal/trigger-runtime.d.ts +12 -0
  161. package/dist/internal/trigger-runtime.d.ts.map +1 -0
  162. package/dist/internal/trigger-runtime.js +95 -0
  163. package/dist/internal/trigger-runtime.js.map +1 -0
  164. package/dist/internal/types.d.ts +7 -0
  165. package/dist/internal/types.d.ts.map +1 -0
  166. package/dist/internal/types.js +1 -0
  167. package/dist/remote-runtime.d.ts +585 -0
  168. package/dist/remote-runtime.d.ts.map +1 -0
  169. package/dist/remote-runtime.js +367 -0
  170. package/dist/remote-runtime.js.map +1 -0
  171. package/package.json +55 -4
  172. package/src/Action.ts +370 -0
  173. package/src/AgentChannel.ts +860 -0
  174. package/src/AgentChannelConformance.ts +124 -0
  175. package/src/AgentChannelRuntime.ts +616 -0
  176. package/src/AiProvider.ts +255 -0
  177. package/src/AuthMethod.ts +954 -0
  178. package/src/AuthMethodBinding.ts +112 -0
  179. package/src/AuthMethodExecution.ts +542 -0
  180. package/src/ConnectionResolver.ts +265 -0
  181. package/src/DefinitionError.ts +115 -0
  182. package/src/DualRegistry.ts +152 -0
  183. package/src/DualRuntime.ts +1081 -0
  184. package/src/Files.ts +89 -0
  185. package/src/Group.ts +292 -0
  186. package/src/Http.ts +1205 -0
  187. package/src/Mcp.ts +299 -0
  188. package/src/OAuth2TokenRefresher.ts +22 -0
  189. package/src/OAuthFlow.ts +874 -0
  190. package/src/Plugin.ts +912 -0
  191. package/src/PluginRuntime.ts +414 -0
  192. package/src/Runner.ts +248 -0
  193. package/src/ToolFile.ts +28 -0
  194. package/src/Trigger.ts +722 -0
  195. package/src/index.ts +158 -0
  196. package/src/internal/auth-context.ts +27 -0
  197. package/src/internal/auth-execution.ts +241 -0
  198. package/src/internal/auth-runtime.ts +20 -0
  199. package/src/internal/capabilities.ts +55 -0
  200. package/src/internal/children.ts +126 -0
  201. package/src/internal/collection-utils.ts +8 -0
  202. package/src/internal/dual/actions.ts +116 -0
  203. package/src/internal/dual/invoke.ts +307 -0
  204. package/src/internal/dual/registry.ts +340 -0
  205. package/src/internal/dual/triggers.ts +128 -0
  206. package/src/internal/handler-context.ts +57 -0
  207. package/src/internal/identifier.ts +27 -0
  208. package/src/internal/plugin-handlers.ts +146 -0
  209. package/src/internal/proto.ts +8 -0
  210. package/src/internal/schema-runtime.ts +15 -0
  211. package/src/internal/trigger-runtime-shared.ts +449 -0
  212. package/src/internal/trigger-runtime.ts +223 -0
  213. package/src/internal/types.ts +12 -0
  214. package/src/remote-runtime.ts +469 -0
package/src/Files.ts ADDED
@@ -0,0 +1,89 @@
1
+ /**
2
+ * Files that actions take and return: a small reference in action data, with the bytes kept by the
3
+ * host and read or written through the host's file service.
4
+ *
5
+ * @since 0.1.0
6
+ */
7
+ import { Context, Effect, Schema, pipe } from "effect";
8
+
9
+ /**
10
+ * A file stored by the host. Action inputs and outputs carry this reference, never the bytes.
11
+ *
12
+ * @since 0.1.0
13
+ * @category schemas
14
+ */
15
+ export type File = typeof File.Type;
16
+ export const File = Schema.TaggedStruct("File", {
17
+ contentType: Schema.String,
18
+ id: Schema.NonEmptyString,
19
+ name: Schema.String,
20
+ sizeBytes: Schema.Natural,
21
+ }).annotate({
22
+ description: "A file: pass the reference a file input or an earlier step returned.",
23
+ });
24
+
25
+ /**
26
+ * A file the host could not read or keep. The message is safe for callers; an optional cause
27
+ * retains the host failure in memory for trusted diagnostics. Wrap causes with Redacted.make
28
+ * without a provider-derived label. JSON schema encoding of a cause is intentionally refused.
29
+ *
30
+ * @since 0.1.0
31
+ * @category errors
32
+ */
33
+ export class FileError extends Schema.TaggedError<FileError>()("FileError", {
34
+ cause: Schema.optionalKey(Schema.Redacted(Schema.Unknown, { disallowJsonEncode: true })),
35
+ message: Schema.String,
36
+ }) {}
37
+
38
+ /**
39
+ * Reads and stores files for the caller of an action: a workflow run, or the person in a chat.
40
+ *
41
+ * @since 0.1.0
42
+ * @category services
43
+ */
44
+ export class Service extends Context.Service<
45
+ Service,
46
+ {
47
+ readonly read: (file: File) => Effect.Effect<Uint8Array, FileError>;
48
+ readonly write: (file: {
49
+ bytes: Uint8Array;
50
+ name: string;
51
+ // oxlint-disable-next-line typescript/no-restricted-types -- Hosts and existing callers may explicitly supply an absent content type.
52
+ contentType?: string | null | undefined;
53
+ }) => Effect.Effect<File, FileError>;
54
+ }
55
+ >()("@dual-os/sdk/Files/Service") {}
56
+
57
+ // Dual provides the service to each action call, so an action declares no requirement for it.
58
+ const service = pipe(
59
+ Effect.serviceOption(Service),
60
+ Effect.flatMap(
61
+ Effect.fromOption(() =>
62
+ FileError.make({ message: "Files are only available when Dual calls the action" }),
63
+ ),
64
+ ),
65
+ );
66
+
67
+ /**
68
+ * Reads a file's bytes through the caller's file service.
69
+ *
70
+ * @since 0.1.0
71
+ * @category files
72
+ */
73
+ export const read = Effect.fnUntraced(function* (file: File) {
74
+ return yield* (yield* service).read(file);
75
+ });
76
+
77
+ /**
78
+ * Stores bytes as a new file of the caller and returns its reference.
79
+ *
80
+ * @since 0.1.0
81
+ * @category files
82
+ */
83
+ export const write = Effect.fnUntraced(function* (
84
+ file: Parameters<Service["Service"]["write"]>[0],
85
+ ) {
86
+ return yield* (yield* service).write(file);
87
+ });
88
+
89
+ export * as Files from "./Files.ts";
package/src/Group.ts ADDED
@@ -0,0 +1,292 @@
1
+ /**
2
+ * Canonical group definition builders and types for the Dual SDK.
3
+ *
4
+ * Groups are structural namespaces nested beneath providers or other groups.
5
+ *
6
+ * @since 0.0.0
7
+ */
8
+ import type { Pipeable } from "effect";
9
+ import { Function as Func, Predicate } from "effect";
10
+
11
+ import type * as Action from "./Action.ts";
12
+ import {
13
+ assertUniqueMixedChildIdentifiers,
14
+ assertUniqueStructuralChildIdentifiers,
15
+ type FilterChildren,
16
+ partitionChildren,
17
+ type StructuralChildKind,
18
+ } from "./internal/children.ts";
19
+ import { appendElements } from "./internal/collection-utils.ts";
20
+ import { validateIdentifier } from "./internal/identifier.ts";
21
+ import { PipeableProto } from "./internal/proto.ts";
22
+ import type * as Trigger from "./Trigger.ts";
23
+
24
+ /** @since 0.0.0 @category type ids */
25
+ export const TypeId = "@dual-os/sdk/Group" as const;
26
+ /** @since 0.0.0 @category type ids */
27
+ export type TypeId = typeof TypeId;
28
+
29
+ /** @since 0.0.0 @category type-level */
30
+ export interface Any extends Pipeable.Pipeable {
31
+ readonly [TypeId]: TypeId;
32
+ readonly identifier: string;
33
+ readonly name: string | undefined;
34
+ readonly description: string | undefined;
35
+ readonly groups: readonly Any[];
36
+ readonly actions: readonly Action.Any[];
37
+ readonly triggers: readonly Trigger.Any[];
38
+ }
39
+
40
+ /** @since 0.0.0 @category models */
41
+ export interface GroupOptions<Identifier extends string = string> {
42
+ readonly identifier: Identifier;
43
+ readonly name?: string;
44
+ readonly description?: string;
45
+ }
46
+
47
+ /** @since 0.0.0 @category models */
48
+ export interface Group<
49
+ out Identifier extends string = string,
50
+ out Groups extends readonly Any[] = readonly [],
51
+ out Actions extends readonly Action.Any[] = readonly [],
52
+ out Triggers extends readonly Trigger.Any[] = readonly [],
53
+ >
54
+ extends Pipeable.Pipeable {
55
+ readonly [TypeId]: TypeId;
56
+ readonly identifier: Identifier;
57
+ readonly name: string | undefined;
58
+ readonly description: string | undefined;
59
+ readonly groups: Groups;
60
+ readonly actions: Actions;
61
+ readonly triggers: Triggers;
62
+ }
63
+
64
+ export type StructuralChild = Any | Action.Any | Trigger.Any;
65
+
66
+ export type GroupsFromChildren<Children extends readonly StructuralChild[]> = FilterChildren<
67
+ Children,
68
+ Any
69
+ >;
70
+
71
+ export type ActionsFromChildren<Children extends readonly StructuralChild[]> = FilterChildren<
72
+ Children,
73
+ Action.Any
74
+ >;
75
+
76
+ export type TriggersFromChildren<Children extends readonly StructuralChild[]> = FilterChildren<
77
+ Children,
78
+ Trigger.Any
79
+ >;
80
+
81
+ /**
82
+ * Result of appending children to a group; shared by every child combinator so
83
+ * their overloads stay declarative.
84
+ *
85
+ * @since 0.0.0
86
+ * @category type-level
87
+ */
88
+ export type AddChildren<
89
+ Self extends Any,
90
+ AddedGroups extends readonly Any[] = readonly [],
91
+ AddedActions extends readonly Action.Any[] = readonly [],
92
+ AddedTriggers extends readonly Trigger.Any[] = readonly [],
93
+ > =
94
+ Self extends Group<infer Identifier, infer Groups, infer Actions, infer Triggers>
95
+ ? Group<
96
+ Identifier,
97
+ readonly [...Groups, ...AddedGroups],
98
+ readonly [...Actions, ...AddedActions],
99
+ readonly [...Triggers, ...AddedTriggers]
100
+ >
101
+ : never;
102
+
103
+ const optionsFromGroup = (group: Any): GroupOptions => ({
104
+ identifier: group.identifier,
105
+ ...(group.name === undefined ? {} : { name: group.name }),
106
+ ...(group.description === undefined ? {} : { description: group.description }),
107
+ });
108
+
109
+ const Proto = { ...PipeableProto, [TypeId]: TypeId };
110
+
111
+ const makeGroup = <
112
+ Identifier extends string,
113
+ Groups extends readonly Any[],
114
+ Actions extends readonly Action.Any[],
115
+ Triggers extends readonly Trigger.Any[],
116
+ >(
117
+ options: GroupOptions<Identifier>,
118
+ groups: Groups,
119
+ actions: Actions,
120
+ triggers: Triggers,
121
+ ): Group<Identifier, Groups, Actions, Triggers> => {
122
+ validateIdentifier("group", options.identifier);
123
+
124
+ return Object.assign(Object.create(Proto), {
125
+ actions,
126
+ description: options.description,
127
+ groups,
128
+ identifier: options.identifier,
129
+ name: options.name,
130
+ triggers,
131
+ }) as Group<Identifier, Groups, Actions, Triggers>;
132
+ };
133
+
134
+ const appendChildren = (
135
+ group: Any,
136
+ children: readonly StructuralChild[],
137
+ childKind?: StructuralChildKind,
138
+ ): Any => {
139
+ if (childKind === undefined) {
140
+ assertUniqueMixedChildIdentifiers("group", group.identifier, group, children);
141
+ } else {
142
+ assertUniqueStructuralChildIdentifiers("group", group.identifier, group, children, childKind);
143
+ }
144
+
145
+ const partitioned = partitionChildren(children);
146
+ return makeGroup(
147
+ optionsFromGroup(group),
148
+ appendElements(group.groups, partitioned.groups),
149
+ appendElements(group.actions, partitioned.actions),
150
+ appendElements(group.triggers, partitioned.triggers),
151
+ );
152
+ };
153
+
154
+ /** @since 0.0.0 @category constructors */
155
+ export const make = <const Identifier extends string>(identifier: Identifier): Group<Identifier> =>
156
+ makeGroup({ identifier }, [] as const, [] as const, [] as const);
157
+
158
+ /** @since 0.0.0 @category guards */
159
+ export const isGroup = (u: unknown): u is Any => Predicate.hasProperty(u, TypeId);
160
+
161
+ /** @since 0.0.0 @category combinators */
162
+ export const withName: {
163
+ (name: string): <G extends Group<any, any, any, any>>(group: G) => G;
164
+ <G extends Group<any, any, any, any>>(group: G, name: string): G;
165
+ } = Func.dual(
166
+ 2,
167
+ <G extends Group<any, any, any, any>>(group: G, name: string): G =>
168
+ makeGroup(
169
+ { ...optionsFromGroup(group), name },
170
+ group.groups,
171
+ group.actions,
172
+ group.triggers,
173
+ ) as G,
174
+ );
175
+
176
+ /** @since 0.0.0 @category combinators */
177
+ export const withDescription: {
178
+ (description: string): <G extends Group<any, any, any, any>>(group: G) => G;
179
+ <G extends Group<any, any, any, any>>(group: G, description: string): G;
180
+ } = Func.dual(
181
+ 2,
182
+ <G extends Group<any, any, any, any>>(group: G, description: string): G =>
183
+ makeGroup(
184
+ { ...optionsFromGroup(group), description },
185
+ group.groups,
186
+ group.actions,
187
+ group.triggers,
188
+ ) as G,
189
+ );
190
+
191
+ /** @since 0.0.0 @category combinators */
192
+ export const withGroups: {
193
+ <const AddedGroups extends readonly Any[]>(
194
+ groups: AddedGroups,
195
+ ): <Self extends Any>(group: Self) => AddChildren<Self, AddedGroups>;
196
+ <Self extends Any, const AddedGroups extends readonly Any[]>(
197
+ group: Self,
198
+ groups: AddedGroups,
199
+ ): AddChildren<Self, AddedGroups>;
200
+ } = Func.dual(2, (group: Any, groups: readonly Any[]) => appendChildren(group, groups, "group"));
201
+
202
+ /** @since 0.0.0 @category combinators */
203
+ export const withActions: {
204
+ <const AddedActions extends readonly Action.Any[]>(
205
+ actions: AddedActions,
206
+ ): <Self extends Any>(group: Self) => AddChildren<Self, readonly [], AddedActions>;
207
+ <Self extends Any, const AddedActions extends readonly Action.Any[]>(
208
+ group: Self,
209
+ actions: AddedActions,
210
+ ): AddChildren<Self, readonly [], AddedActions>;
211
+ } = Func.dual(2, (group: Any, actions: readonly Action.Any[]) =>
212
+ appendChildren(group, actions, "action"),
213
+ );
214
+
215
+ /** @since 0.0.0 @category combinators */
216
+ export const withTriggers: {
217
+ <const AddedTriggers extends readonly Trigger.Any[]>(
218
+ triggers: AddedTriggers,
219
+ ): <Self extends Any>(group: Self) => AddChildren<Self, readonly [], readonly [], AddedTriggers>;
220
+ <Self extends Any, const AddedTriggers extends readonly Trigger.Any[]>(
221
+ group: Self,
222
+ triggers: AddedTriggers,
223
+ ): AddChildren<Self, readonly [], readonly [], AddedTriggers>;
224
+ } = Func.dual(2, (group: Any, triggers: readonly Trigger.Any[]) =>
225
+ appendChildren(group, triggers, "trigger"),
226
+ );
227
+
228
+ /** @since 0.0.0 @category combinators */
229
+ export const withGroup: {
230
+ <const AddedGroup extends Any>(
231
+ group: AddedGroup,
232
+ ): <Self extends Any>(value: Self) => AddChildren<Self, readonly [AddedGroup]>;
233
+ <Self extends Any, const AddedGroup extends Any>(
234
+ value: Self,
235
+ group: AddedGroup,
236
+ ): AddChildren<Self, readonly [AddedGroup]>;
237
+ } = Func.dual(2, (value: Any, group: Any) => appendChildren(value, [group], "group"));
238
+
239
+ /** @since 0.0.0 @category combinators */
240
+ export const withAction: {
241
+ <const AddedAction extends Action.Any>(
242
+ action: AddedAction,
243
+ ): <Self extends Any>(value: Self) => AddChildren<Self, readonly [], readonly [AddedAction]>;
244
+ <Self extends Any, const AddedAction extends Action.Any>(
245
+ value: Self,
246
+ action: AddedAction,
247
+ ): AddChildren<Self, readonly [], readonly [AddedAction]>;
248
+ } = Func.dual(2, (value: Any, action: Action.Any) => appendChildren(value, [action], "action"));
249
+
250
+ /** @since 0.0.0 @category combinators */
251
+ export const withTrigger: {
252
+ <const AddedTrigger extends Trigger.Any>(
253
+ trigger: AddedTrigger,
254
+ ): <Self extends Any>(
255
+ value: Self,
256
+ ) => AddChildren<Self, readonly [], readonly [], readonly [AddedTrigger]>;
257
+ <Self extends Any, const AddedTrigger extends Trigger.Any>(
258
+ value: Self,
259
+ trigger: AddedTrigger,
260
+ ): AddChildren<Self, readonly [], readonly [], readonly [AddedTrigger]>;
261
+ } = Func.dual(2, (value: Any, trigger: Trigger.Any) => appendChildren(value, [trigger], "trigger"));
262
+
263
+ /**
264
+ * Add mixed structural children to a group.
265
+ *
266
+ * @since 0.0.0
267
+ * @category combinators
268
+ */
269
+ export const add: {
270
+ <const Children extends readonly StructuralChild[]>(
271
+ ...children: Children
272
+ ): <Self extends Any>(
273
+ group: Self,
274
+ ) => AddChildren<
275
+ Self,
276
+ GroupsFromChildren<Children>,
277
+ ActionsFromChildren<Children>,
278
+ TriggersFromChildren<Children>
279
+ >;
280
+ <Self extends Any, const Children extends readonly StructuralChild[]>(
281
+ group: Self,
282
+ ...children: Children
283
+ ): AddChildren<
284
+ Self,
285
+ GroupsFromChildren<Children>,
286
+ ActionsFromChildren<Children>,
287
+ TriggersFromChildren<Children>
288
+ >;
289
+ } = Func.dual(
290
+ args => isGroup(args[0]),
291
+ (group: Any, ...children: readonly StructuralChild[]) => appendChildren(group, children),
292
+ );