@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.
- package/LICENSE +4 -0
- package/README.md +19 -2
- package/dist/Action.d.ts +201 -0
- package/dist/Action.d.ts.map +1 -0
- package/dist/Action.js +172 -0
- package/dist/Action.js.map +1 -0
- package/dist/AgentChannel.d.ts +1717 -0
- package/dist/AgentChannel.d.ts.map +1 -0
- package/dist/AgentChannel.js +708 -0
- package/dist/AgentChannel.js.map +1 -0
- package/dist/AgentChannelConformance.d.ts +1543 -0
- package/dist/AgentChannelConformance.d.ts.map +1 -0
- package/dist/AgentChannelConformance.js +163 -0
- package/dist/AgentChannelConformance.js.map +1 -0
- package/dist/AgentChannelRuntime.d.ts +78 -0
- package/dist/AgentChannelRuntime.d.ts.map +1 -0
- package/dist/AgentChannelRuntime.js +270 -0
- package/dist/AgentChannelRuntime.js.map +1 -0
- package/dist/AiProvider.d.ts +132 -0
- package/dist/AiProvider.d.ts.map +1 -0
- package/dist/AiProvider.js +100 -0
- package/dist/AiProvider.js.map +1 -0
- package/dist/AuthMethod.d.ts +381 -0
- package/dist/AuthMethod.d.ts.map +1 -0
- package/dist/AuthMethod.js +225 -0
- package/dist/AuthMethod.js.map +1 -0
- package/dist/AuthMethodBinding.d.ts +77 -0
- package/dist/AuthMethodBinding.d.ts.map +1 -0
- package/dist/AuthMethodBinding.js +31 -0
- package/dist/AuthMethodBinding.js.map +1 -0
- package/dist/AuthMethodExecution.d.ts +223 -0
- package/dist/AuthMethodExecution.d.ts.map +1 -0
- package/dist/AuthMethodExecution.js +277 -0
- package/dist/AuthMethodExecution.js.map +1 -0
- package/dist/ConnectionResolver.d.ts +219 -0
- package/dist/ConnectionResolver.d.ts.map +1 -0
- package/dist/ConnectionResolver.js +153 -0
- package/dist/ConnectionResolver.js.map +1 -0
- package/dist/DefinitionError.d.ts +67 -0
- package/dist/DefinitionError.d.ts.map +1 -0
- package/dist/DefinitionError.js +82 -0
- package/dist/DefinitionError.js.map +1 -0
- package/dist/DualRegistry.d.ts +71 -0
- package/dist/DualRegistry.d.ts.map +1 -0
- package/dist/DualRegistry.js +96 -0
- package/dist/DualRegistry.js.map +1 -0
- package/dist/DualRuntime.d.ts +279 -0
- package/dist/DualRuntime.d.ts.map +1 -0
- package/dist/DualRuntime.js +311 -0
- package/dist/DualRuntime.js.map +1 -0
- package/dist/Files.d.ts +80 -0
- package/dist/Files.d.ts.map +1 -0
- package/dist/Files.js +66 -0
- package/dist/Files.js.map +1 -0
- package/dist/Group.d.ts +106 -0
- package/dist/Group.d.ts.map +1 -0
- package/dist/Group.js +86 -0
- package/dist/Group.js.map +1 -0
- package/dist/Http.d.ts +342 -0
- package/dist/Http.d.ts.map +1 -0
- package/dist/Http.js +677 -0
- package/dist/Http.js.map +1 -0
- package/dist/Mcp.d.ts +109 -0
- package/dist/Mcp.d.ts.map +1 -0
- package/dist/Mcp.js +176 -0
- package/dist/Mcp.js.map +1 -0
- package/dist/OAuth2TokenRefresher.d.ts +18 -0
- package/dist/OAuth2TokenRefresher.d.ts.map +1 -0
- package/dist/OAuth2TokenRefresher.js +19 -0
- package/dist/OAuth2TokenRefresher.js.map +1 -0
- package/dist/OAuthFlow.d.ts +71 -0
- package/dist/OAuthFlow.d.ts.map +1 -0
- package/dist/OAuthFlow.js +488 -0
- package/dist/OAuthFlow.js.map +1 -0
- package/dist/Plugin.d.ts +383 -0
- package/dist/Plugin.d.ts.map +1 -0
- package/dist/Plugin.js +249 -0
- package/dist/Plugin.js.map +1 -0
- package/dist/PluginRuntime.d.ts +3186 -0
- package/dist/PluginRuntime.d.ts.map +1 -0
- package/dist/PluginRuntime.js +331 -0
- package/dist/PluginRuntime.js.map +1 -0
- package/dist/Runner.d.ts +1 -0
- package/dist/Runner.js +124 -0
- package/dist/Runner.js.map +1 -0
- package/dist/ToolFile.d.ts +23 -0
- package/dist/ToolFile.d.ts.map +1 -0
- package/dist/ToolFile.js +33 -0
- package/dist/ToolFile.js.map +1 -0
- package/dist/Trigger.d.ts +358 -0
- package/dist/Trigger.d.ts.map +1 -0
- package/dist/Trigger.js +287 -0
- package/dist/Trigger.js.map +1 -0
- package/dist/_virtual/_rolldown/runtime.js +13 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.js +24 -0
- package/dist/internal/auth-context.d.ts +23 -0
- package/dist/internal/auth-context.d.ts.map +1 -0
- package/dist/internal/auth-context.js +1 -0
- package/dist/internal/auth-execution.d.ts +27 -0
- package/dist/internal/auth-execution.d.ts.map +1 -0
- package/dist/internal/auth-execution.js +66 -0
- package/dist/internal/auth-execution.js.map +1 -0
- package/dist/internal/auth-runtime.d.ts +5 -0
- package/dist/internal/auth-runtime.d.ts.map +1 -0
- package/dist/internal/auth-runtime.js +16 -0
- package/dist/internal/auth-runtime.js.map +1 -0
- package/dist/internal/capabilities.d.ts +24 -0
- package/dist/internal/capabilities.d.ts.map +1 -0
- package/dist/internal/capabilities.js +22 -0
- package/dist/internal/capabilities.js.map +1 -0
- package/dist/internal/children.d.ts +34 -0
- package/dist/internal/children.d.ts.map +1 -0
- package/dist/internal/children.js +53 -0
- package/dist/internal/children.js.map +1 -0
- package/dist/internal/collection-utils.d.ts +4 -0
- package/dist/internal/collection-utils.d.ts.map +1 -0
- package/dist/internal/collection-utils.js +6 -0
- package/dist/internal/collection-utils.js.map +1 -0
- package/dist/internal/dual/actions.d.ts +33 -0
- package/dist/internal/dual/actions.d.ts.map +1 -0
- package/dist/internal/dual/actions.js +26 -0
- package/dist/internal/dual/actions.js.map +1 -0
- package/dist/internal/dual/invoke.d.ts +63 -0
- package/dist/internal/dual/invoke.d.ts.map +1 -0
- package/dist/internal/dual/invoke.js +75 -0
- package/dist/internal/dual/invoke.js.map +1 -0
- package/dist/internal/dual/registry.d.ts +125 -0
- package/dist/internal/dual/registry.d.ts.map +1 -0
- package/dist/internal/dual/registry.js +172 -0
- package/dist/internal/dual/registry.js.map +1 -0
- package/dist/internal/dual/triggers.d.ts +29 -0
- package/dist/internal/dual/triggers.d.ts.map +1 -0
- package/dist/internal/dual/triggers.js +26 -0
- package/dist/internal/dual/triggers.js.map +1 -0
- package/dist/internal/handler-context.d.ts +9 -0
- package/dist/internal/handler-context.d.ts.map +1 -0
- package/dist/internal/handler-context.js +31 -0
- package/dist/internal/handler-context.js.map +1 -0
- package/dist/internal/identifier.d.ts +6 -0
- package/dist/internal/identifier.d.ts.map +1 -0
- package/dist/internal/identifier.js +28 -0
- package/dist/internal/identifier.js.map +1 -0
- package/dist/internal/plugin-handlers.d.ts +38 -0
- package/dist/internal/plugin-handlers.d.ts.map +1 -0
- package/dist/internal/plugin-handlers.js +52 -0
- package/dist/internal/plugin-handlers.js.map +1 -0
- package/dist/internal/proto.d.ts +7 -0
- package/dist/internal/proto.d.ts.map +1 -0
- package/dist/internal/proto.js +10 -0
- package/dist/internal/proto.js.map +1 -0
- package/dist/internal/schema-runtime.d.ts +6 -0
- package/dist/internal/schema-runtime.d.ts.map +1 -0
- package/dist/internal/schema-runtime.js +10 -0
- package/dist/internal/schema-runtime.js.map +1 -0
- package/dist/internal/trigger-runtime-shared.d.ts +41 -0
- package/dist/internal/trigger-runtime-shared.d.ts.map +1 -0
- package/dist/internal/trigger-runtime-shared.js +132 -0
- package/dist/internal/trigger-runtime-shared.js.map +1 -0
- package/dist/internal/trigger-runtime.d.ts +12 -0
- package/dist/internal/trigger-runtime.d.ts.map +1 -0
- package/dist/internal/trigger-runtime.js +95 -0
- package/dist/internal/trigger-runtime.js.map +1 -0
- package/dist/internal/types.d.ts +7 -0
- package/dist/internal/types.d.ts.map +1 -0
- package/dist/internal/types.js +1 -0
- package/dist/remote-runtime.d.ts +585 -0
- package/dist/remote-runtime.d.ts.map +1 -0
- package/dist/remote-runtime.js +367 -0
- package/dist/remote-runtime.js.map +1 -0
- package/package.json +55 -4
- package/src/Action.ts +370 -0
- package/src/AgentChannel.ts +860 -0
- package/src/AgentChannelConformance.ts +124 -0
- package/src/AgentChannelRuntime.ts +616 -0
- package/src/AiProvider.ts +255 -0
- package/src/AuthMethod.ts +954 -0
- package/src/AuthMethodBinding.ts +112 -0
- package/src/AuthMethodExecution.ts +542 -0
- package/src/ConnectionResolver.ts +265 -0
- package/src/DefinitionError.ts +115 -0
- package/src/DualRegistry.ts +152 -0
- package/src/DualRuntime.ts +1081 -0
- package/src/Files.ts +89 -0
- package/src/Group.ts +292 -0
- package/src/Http.ts +1205 -0
- package/src/Mcp.ts +299 -0
- package/src/OAuth2TokenRefresher.ts +22 -0
- package/src/OAuthFlow.ts +874 -0
- package/src/Plugin.ts +912 -0
- package/src/PluginRuntime.ts +414 -0
- package/src/Runner.ts +248 -0
- package/src/ToolFile.ts +28 -0
- package/src/Trigger.ts +722 -0
- package/src/index.ts +158 -0
- package/src/internal/auth-context.ts +27 -0
- package/src/internal/auth-execution.ts +241 -0
- package/src/internal/auth-runtime.ts +20 -0
- package/src/internal/capabilities.ts +55 -0
- package/src/internal/children.ts +126 -0
- package/src/internal/collection-utils.ts +8 -0
- package/src/internal/dual/actions.ts +116 -0
- package/src/internal/dual/invoke.ts +307 -0
- package/src/internal/dual/registry.ts +340 -0
- package/src/internal/dual/triggers.ts +128 -0
- package/src/internal/handler-context.ts +57 -0
- package/src/internal/identifier.ts +27 -0
- package/src/internal/plugin-handlers.ts +146 -0
- package/src/internal/proto.ts +8 -0
- package/src/internal/schema-runtime.ts +15 -0
- package/src/internal/trigger-runtime-shared.ts +449 -0
- package/src/internal/trigger-runtime.ts +223 -0
- package/src/internal/types.ts +12 -0
- package/src/remote-runtime.ts +469 -0
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Host-provided connection resolution contracts for SDK execution flows.
|
|
3
|
+
*
|
|
4
|
+
* @since 0.0.0
|
|
5
|
+
*/
|
|
6
|
+
import type { Effect } from "effect";
|
|
7
|
+
import { Context, Schema } from "effect";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Connection-aware runtime targets supported by the SDK.
|
|
11
|
+
*
|
|
12
|
+
* @since 0.0.0
|
|
13
|
+
* @category models
|
|
14
|
+
*/
|
|
15
|
+
export type ConnectionTargetKind = "action" | "trigger" | "ai_model" | "agent-channel";
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Tenant boundary for connection resolution and audit.
|
|
19
|
+
*
|
|
20
|
+
* @since 0.0.0
|
|
21
|
+
* @category models
|
|
22
|
+
*/
|
|
23
|
+
export interface ConnectionResolutionTenant {
|
|
24
|
+
readonly organizationId: string;
|
|
25
|
+
readonly teamId: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Product actor on whose behalf a connection is being selected.
|
|
30
|
+
*
|
|
31
|
+
* @since 0.0.0
|
|
32
|
+
* @category models
|
|
33
|
+
*/
|
|
34
|
+
export type ConnectionResolutionActor =
|
|
35
|
+
| { readonly kind: "user"; readonly userId: string }
|
|
36
|
+
| { readonly kind: "system"; readonly reason?: string | undefined };
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Product source that caused the invocation.
|
|
40
|
+
*
|
|
41
|
+
* @since 0.0.0
|
|
42
|
+
* @category models
|
|
43
|
+
*/
|
|
44
|
+
export interface ConnectionResolutionSource {
|
|
45
|
+
readonly kind: string;
|
|
46
|
+
readonly subjectId?: string;
|
|
47
|
+
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Host-owned context used to select, authorize, and audit a connection.
|
|
52
|
+
*
|
|
53
|
+
* @since 0.0.0
|
|
54
|
+
* @category models
|
|
55
|
+
*/
|
|
56
|
+
export interface ConnectionResolutionContext {
|
|
57
|
+
readonly tenant?: ConnectionResolutionTenant;
|
|
58
|
+
readonly actor?: ConnectionResolutionActor;
|
|
59
|
+
readonly source?: ConnectionResolutionSource;
|
|
60
|
+
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Request sent to the host connection resolver during action or trigger execution.
|
|
65
|
+
*
|
|
66
|
+
* @since 0.0.0
|
|
67
|
+
* @category models
|
|
68
|
+
*/
|
|
69
|
+
export interface ConnectionResolutionTarget {
|
|
70
|
+
readonly providerId: string;
|
|
71
|
+
readonly targetKind: ConnectionTargetKind;
|
|
72
|
+
readonly targetId: string;
|
|
73
|
+
readonly phase?: string;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export interface ResolveConnectionRequest {
|
|
77
|
+
readonly target: ConnectionResolutionTarget;
|
|
78
|
+
readonly connectionId?: string;
|
|
79
|
+
readonly context?: ConnectionResolutionContext;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export interface ResolvedConnectionMaterial {
|
|
83
|
+
readonly encoding?: "json";
|
|
84
|
+
readonly providerId: string;
|
|
85
|
+
readonly connectionId: string;
|
|
86
|
+
readonly methodId: string;
|
|
87
|
+
readonly material: unknown;
|
|
88
|
+
readonly setup: unknown;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Raised when a runtime target does not accept a connection but a connectionId was still provided.
|
|
93
|
+
*
|
|
94
|
+
* @since 0.0.0
|
|
95
|
+
* @category errors
|
|
96
|
+
*/
|
|
97
|
+
export class ConnectionIdNotAllowedError extends Schema.TaggedError<ConnectionIdNotAllowedError>()(
|
|
98
|
+
"ConnectionIdNotAllowedError",
|
|
99
|
+
{
|
|
100
|
+
connectionId: Schema.String,
|
|
101
|
+
phase: Schema.optional(Schema.String),
|
|
102
|
+
providerId: Schema.String,
|
|
103
|
+
targetId: Schema.String,
|
|
104
|
+
targetKind: Schema.Literals(["action", "trigger", "ai_model", "agent-channel"]),
|
|
105
|
+
},
|
|
106
|
+
) {}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Raised when execution requires a connection and no compatible binding is available.
|
|
110
|
+
*
|
|
111
|
+
* @since 0.0.0
|
|
112
|
+
* @category errors
|
|
113
|
+
*/
|
|
114
|
+
export class ConnectionRequiredError extends Schema.TaggedError<ConnectionRequiredError>()(
|
|
115
|
+
"ConnectionRequiredError",
|
|
116
|
+
{
|
|
117
|
+
phase: Schema.optional(Schema.String),
|
|
118
|
+
providerId: Schema.String,
|
|
119
|
+
targetId: Schema.String,
|
|
120
|
+
targetKind: Schema.Literals(["action", "trigger", "ai_model", "agent-channel"]),
|
|
121
|
+
},
|
|
122
|
+
) {}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Raised when several compatible connection bindings exist and the caller must choose one.
|
|
126
|
+
*
|
|
127
|
+
* @since 0.0.0
|
|
128
|
+
* @category errors
|
|
129
|
+
*/
|
|
130
|
+
export class ConnectionSelectionRequiredError extends Schema.TaggedError<ConnectionSelectionRequiredError>()(
|
|
131
|
+
"ConnectionSelectionRequiredError",
|
|
132
|
+
{
|
|
133
|
+
phase: Schema.optional(Schema.String),
|
|
134
|
+
providerId: Schema.String,
|
|
135
|
+
targetId: Schema.String,
|
|
136
|
+
targetKind: Schema.Literals(["action", "trigger", "ai_model", "agent-channel"]),
|
|
137
|
+
},
|
|
138
|
+
) {}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Raised when the requested connectionId does not resolve to a compatible binding.
|
|
142
|
+
*
|
|
143
|
+
* @since 0.0.0
|
|
144
|
+
* @category errors
|
|
145
|
+
*/
|
|
146
|
+
export class InvalidConnectionIdError extends Schema.TaggedError<InvalidConnectionIdError>()(
|
|
147
|
+
"InvalidConnectionIdError",
|
|
148
|
+
{
|
|
149
|
+
connectionId: Schema.String,
|
|
150
|
+
phase: Schema.optional(Schema.String),
|
|
151
|
+
providerId: Schema.String,
|
|
152
|
+
targetId: Schema.String,
|
|
153
|
+
targetKind: Schema.Literals(["action", "trigger", "ai_model", "agent-channel"]),
|
|
154
|
+
},
|
|
155
|
+
) {}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Raised when the resolved connection value does not satisfy the selected auth method schema.
|
|
159
|
+
*
|
|
160
|
+
* @since 0.0.0
|
|
161
|
+
* @category errors
|
|
162
|
+
*/
|
|
163
|
+
export class InvalidResolvedConnectionError extends Schema.TaggedError<InvalidResolvedConnectionError>()(
|
|
164
|
+
"InvalidResolvedConnectionError",
|
|
165
|
+
{
|
|
166
|
+
description: Schema.String,
|
|
167
|
+
methodId: Schema.String,
|
|
168
|
+
phase: Schema.optional(Schema.String),
|
|
169
|
+
providerId: Schema.String,
|
|
170
|
+
targetId: Schema.String,
|
|
171
|
+
targetKind: Schema.Literals(["action", "trigger", "ai_model", "agent-channel"]),
|
|
172
|
+
},
|
|
173
|
+
) {}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Raised when the provider refuses the connection's stored grant, so the user must sign in again.
|
|
177
|
+
*
|
|
178
|
+
* @since 0.0.0
|
|
179
|
+
* @category errors
|
|
180
|
+
*/
|
|
181
|
+
export class ConnectionReauthorizationRequiredError extends Schema.TaggedError<ConnectionReauthorizationRequiredError>()(
|
|
182
|
+
"ConnectionReauthorizationRequiredError",
|
|
183
|
+
{
|
|
184
|
+
connectionId: Schema.String,
|
|
185
|
+
message: Schema.String,
|
|
186
|
+
phase: Schema.optional(Schema.String),
|
|
187
|
+
providerId: Schema.String,
|
|
188
|
+
targetId: Schema.String,
|
|
189
|
+
targetKind: Schema.Literals(["action", "trigger", "ai_model", "agent-channel"]),
|
|
190
|
+
},
|
|
191
|
+
) {}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Raised when the host credential store cannot be read during connection resolution.
|
|
195
|
+
*
|
|
196
|
+
* @since 0.0.0
|
|
197
|
+
* @category errors
|
|
198
|
+
*/
|
|
199
|
+
export class ConnectionResolverStoreError extends Schema.TaggedError<ConnectionResolverStoreError>()(
|
|
200
|
+
"ConnectionResolverStoreError",
|
|
201
|
+
{
|
|
202
|
+
cause: Schema.Defect(),
|
|
203
|
+
operation: Schema.String,
|
|
204
|
+
phase: Schema.optional(Schema.String),
|
|
205
|
+
providerId: Schema.String,
|
|
206
|
+
targetId: Schema.String,
|
|
207
|
+
targetKind: Schema.Literals(["action", "trigger", "ai_model", "agent-channel"]),
|
|
208
|
+
},
|
|
209
|
+
) {}
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Structured connection failures surfaced by SDK runtime boundaries.
|
|
213
|
+
*
|
|
214
|
+
* @since 0.0.0
|
|
215
|
+
* @category errors
|
|
216
|
+
*/
|
|
217
|
+
export type ConnectionError =
|
|
218
|
+
| ConnectionIdNotAllowedError
|
|
219
|
+
| ConnectionRequiredError
|
|
220
|
+
| ConnectionSelectionRequiredError
|
|
221
|
+
| InvalidConnectionIdError
|
|
222
|
+
| InvalidResolvedConnectionError
|
|
223
|
+
| ConnectionReauthorizationRequiredError
|
|
224
|
+
| ConnectionResolverStoreError;
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Errors the host resolver itself is expected to surface.
|
|
228
|
+
*
|
|
229
|
+
* @since 0.0.0
|
|
230
|
+
* @category errors
|
|
231
|
+
*/
|
|
232
|
+
export type ResolveConnectionError =
|
|
233
|
+
| ConnectionRequiredError
|
|
234
|
+
| ConnectionSelectionRequiredError
|
|
235
|
+
| InvalidConnectionIdError
|
|
236
|
+
| InvalidResolvedConnectionError
|
|
237
|
+
| ConnectionReauthorizationRequiredError
|
|
238
|
+
| ConnectionResolverStoreError;
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Host-provided service used by SDK runtimes to select one concrete connection binding.
|
|
242
|
+
*
|
|
243
|
+
* The SDK narrows and validates this untyped host binding against the target's allowed methods
|
|
244
|
+
* before exposing it to handlers.
|
|
245
|
+
*
|
|
246
|
+
* @since 0.0.0
|
|
247
|
+
* @category services
|
|
248
|
+
*/
|
|
249
|
+
export interface ConnectionResolverInstance {
|
|
250
|
+
readonly resolve: (
|
|
251
|
+
input: ResolveConnectionRequest,
|
|
252
|
+
) => Effect.Effect<ResolvedConnectionMaterial, ResolveConnectionError>;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Host-provided connection resolver service.
|
|
257
|
+
*
|
|
258
|
+
* @since 0.0.0
|
|
259
|
+
* @category services
|
|
260
|
+
*/
|
|
261
|
+
export class Service extends Context.Service<Service, ConnectionResolverInstance>()(
|
|
262
|
+
"@dual-os/sdk/ConnectionResolver",
|
|
263
|
+
) {}
|
|
264
|
+
|
|
265
|
+
export * as ConnectionResolver from "./ConnectionResolver.ts";
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public SDK definition errors.
|
|
3
|
+
*
|
|
4
|
+
* @since 0.0.0
|
|
5
|
+
*/
|
|
6
|
+
import { Schema } from "effect";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @since 0.0.0
|
|
10
|
+
* @category models
|
|
11
|
+
*/
|
|
12
|
+
export type DefinitionIdentifierKind =
|
|
13
|
+
| "dual"
|
|
14
|
+
| "plugin"
|
|
15
|
+
| "provider"
|
|
16
|
+
| "group"
|
|
17
|
+
| "action"
|
|
18
|
+
| "trigger"
|
|
19
|
+
| "auth-method"
|
|
20
|
+
| "agent-channel";
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @since 0.0.0
|
|
24
|
+
* @category models
|
|
25
|
+
*/
|
|
26
|
+
export type DefinitionOwnerKind = "dual" | "plugin" | "group";
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @since 0.0.0
|
|
30
|
+
* @category models
|
|
31
|
+
*/
|
|
32
|
+
export type DefinitionChildKind =
|
|
33
|
+
| "plugin"
|
|
34
|
+
| "provider"
|
|
35
|
+
| "group"
|
|
36
|
+
| "action"
|
|
37
|
+
| "trigger"
|
|
38
|
+
| "agent-channel";
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* @since 0.0.0
|
|
42
|
+
* @category models
|
|
43
|
+
*/
|
|
44
|
+
export type InvalidIdentifierReason = "empty" | "contains-reserved-separator" | "invalid-format";
|
|
45
|
+
|
|
46
|
+
const DefinitionIdentifierKindSchema = Schema.Literals([
|
|
47
|
+
"dual",
|
|
48
|
+
"plugin",
|
|
49
|
+
"provider",
|
|
50
|
+
"group",
|
|
51
|
+
"action",
|
|
52
|
+
"trigger",
|
|
53
|
+
"auth-method",
|
|
54
|
+
"agent-channel",
|
|
55
|
+
]);
|
|
56
|
+
const DefinitionOwnerKindSchema = Schema.Literals(["dual", "plugin", "group"]);
|
|
57
|
+
const DefinitionChildKindSchema = Schema.Literals([
|
|
58
|
+
"agent-channel",
|
|
59
|
+
"plugin",
|
|
60
|
+
"provider",
|
|
61
|
+
"group",
|
|
62
|
+
"action",
|
|
63
|
+
"trigger",
|
|
64
|
+
]);
|
|
65
|
+
const InvalidIdentifierReasonSchema = Schema.Literals([
|
|
66
|
+
"empty",
|
|
67
|
+
"contains-reserved-separator",
|
|
68
|
+
"invalid-format",
|
|
69
|
+
]);
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Raised when a definition identifier does not satisfy SDK constraints.
|
|
73
|
+
*
|
|
74
|
+
* @since 0.0.0
|
|
75
|
+
* @category errors
|
|
76
|
+
*/
|
|
77
|
+
export class InvalidIdentifierError extends Schema.TaggedError<InvalidIdentifierError>()(
|
|
78
|
+
"InvalidIdentifierError",
|
|
79
|
+
{
|
|
80
|
+
identifier: Schema.String,
|
|
81
|
+
kind: DefinitionIdentifierKindSchema,
|
|
82
|
+
reason: InvalidIdentifierReasonSchema,
|
|
83
|
+
reservedCharacter: Schema.optional(Schema.Literals(["/"])),
|
|
84
|
+
},
|
|
85
|
+
) {}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Raised when two sibling definitions reuse the same identifier.
|
|
89
|
+
*
|
|
90
|
+
* @since 0.0.0
|
|
91
|
+
* @category errors
|
|
92
|
+
*/
|
|
93
|
+
export class BuilderCollisionError extends Schema.TaggedError<BuilderCollisionError>()(
|
|
94
|
+
"BuilderCollisionError",
|
|
95
|
+
{
|
|
96
|
+
childKind: DefinitionChildKindSchema,
|
|
97
|
+
childPluginIdentifier: Schema.optional(Schema.String),
|
|
98
|
+
existingChildKind: DefinitionChildKindSchema,
|
|
99
|
+
existingPluginIdentifier: Schema.optional(Schema.String),
|
|
100
|
+
identifier: Schema.String,
|
|
101
|
+
ownerIdentifier: Schema.String,
|
|
102
|
+
ownerKind: DefinitionOwnerKindSchema,
|
|
103
|
+
},
|
|
104
|
+
) {}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Raised when a provider reuses an auth method identifier.
|
|
108
|
+
*
|
|
109
|
+
* @since 0.0.0
|
|
110
|
+
* @category errors
|
|
111
|
+
*/
|
|
112
|
+
export class DuplicateAuthMethodIdentifierError extends Schema.TaggedError<DuplicateAuthMethodIdentifierError>()(
|
|
113
|
+
"DuplicateAuthMethodIdentifierError",
|
|
114
|
+
{ identifier: Schema.String, providerIdentifier: Schema.String },
|
|
115
|
+
) {}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dual registry resolution and materialization.
|
|
3
|
+
*
|
|
4
|
+
* @since 0.0.0
|
|
5
|
+
*/
|
|
6
|
+
import { Schema } from "effect";
|
|
7
|
+
|
|
8
|
+
import type * as AiProvider from "./AiProvider.ts";
|
|
9
|
+
import type { AnyApp, App } from "./DualRuntime.ts";
|
|
10
|
+
import { collectActionEntries, type AllActionEntries } from "./internal/dual/actions.ts";
|
|
11
|
+
import {
|
|
12
|
+
materializeResolvedRegistry,
|
|
13
|
+
type MaterializedRegistry,
|
|
14
|
+
type MaterializedRegistryOptions,
|
|
15
|
+
} from "./internal/dual/registry.ts";
|
|
16
|
+
import {
|
|
17
|
+
type AllTriggerEntries,
|
|
18
|
+
collectTriggerEntries,
|
|
19
|
+
type RuntimeTriggerEntry,
|
|
20
|
+
resolveRuntimeTrigger,
|
|
21
|
+
} from "./internal/dual/triggers.ts";
|
|
22
|
+
import type * as Plugin from "./Plugin.ts";
|
|
23
|
+
|
|
24
|
+
/** Raised when a trigger lifecycle request references an unknown trigger id. */
|
|
25
|
+
export class TriggerNotFoundError extends Schema.TaggedError<TriggerNotFoundError>()(
|
|
26
|
+
"TriggerNotFoundError",
|
|
27
|
+
{ triggerId: Schema.String },
|
|
28
|
+
) {}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Enumerate the canonical machine ids for every action in the app.
|
|
32
|
+
*
|
|
33
|
+
* @since 0.0.0
|
|
34
|
+
* @category getters
|
|
35
|
+
*/
|
|
36
|
+
export const actionIds = <
|
|
37
|
+
const P extends Plugin.Any,
|
|
38
|
+
LayerOutput,
|
|
39
|
+
LayerError,
|
|
40
|
+
LayerRequirements,
|
|
41
|
+
const AiProviders extends readonly AiProvider.Any[],
|
|
42
|
+
>(
|
|
43
|
+
app: App<P, LayerOutput, LayerError, LayerRequirements, AiProviders>,
|
|
44
|
+
): readonly AllActionEntries<readonly [P]>["actionId"][] =>
|
|
45
|
+
// The ids are walked from the erased plugin trees; the signature carries their literal types.
|
|
46
|
+
collectActionEntries(app.plugins).map(entry => entry.actionId) as never;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Enumerate the canonical machine ids for every trigger in the app.
|
|
50
|
+
*
|
|
51
|
+
* @since 0.0.0
|
|
52
|
+
* @category getters
|
|
53
|
+
*/
|
|
54
|
+
export const triggerIds = <
|
|
55
|
+
const P extends Plugin.Any,
|
|
56
|
+
LayerOutput,
|
|
57
|
+
LayerError,
|
|
58
|
+
LayerRequirements,
|
|
59
|
+
const AiProviders extends readonly AiProvider.Any[],
|
|
60
|
+
>(
|
|
61
|
+
app: App<P, LayerOutput, LayerError, LayerRequirements, AiProviders>,
|
|
62
|
+
): readonly AllTriggerEntries<readonly [P]>["triggerId"][] =>
|
|
63
|
+
// The ids are walked from the erased plugin trees; the signature carries their literal types.
|
|
64
|
+
collectTriggerEntries(app.plugins).map(entry => entry.triggerId) as never;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Resolve one trigger entry from the app, including its auth methods.
|
|
68
|
+
*
|
|
69
|
+
* @since 0.0.0
|
|
70
|
+
* @category getters
|
|
71
|
+
*/
|
|
72
|
+
export const resolveTrigger = (
|
|
73
|
+
app: AnyApp,
|
|
74
|
+
triggerId: string,
|
|
75
|
+
options: { readonly triggerVersion?: string } = {},
|
|
76
|
+
): RuntimeTriggerEntry | undefined =>
|
|
77
|
+
resolveRuntimeTrigger(app.plugins, triggerId, options.triggerVersion);
|
|
78
|
+
|
|
79
|
+
/** @since 0.0.0 @category registry */
|
|
80
|
+
export type {
|
|
81
|
+
MaterializedActionCapabilityVersion,
|
|
82
|
+
MaterializedChannelCapabilityVersion,
|
|
83
|
+
MaterializedAuthMethod,
|
|
84
|
+
MaterializedCapabilityVersion,
|
|
85
|
+
MaterializedProvider,
|
|
86
|
+
MaterializedRegistry,
|
|
87
|
+
MaterializedRegistryOptions,
|
|
88
|
+
MaterializedTriggerCapabilityVersion,
|
|
89
|
+
} from "./internal/dual/registry.ts";
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Materialize the capability catalog of an app's installed releases.
|
|
93
|
+
*
|
|
94
|
+
* @since 0.0.0
|
|
95
|
+
* @category registry
|
|
96
|
+
*/
|
|
97
|
+
export const materializeRegistry = (
|
|
98
|
+
app: AnyApp,
|
|
99
|
+
options: MaterializedRegistryOptions = {},
|
|
100
|
+
): MaterializedRegistry =>
|
|
101
|
+
materializeResolvedRegistry({
|
|
102
|
+
aiProviders: app.aiProviders,
|
|
103
|
+
dualIdentifier: app.identifier,
|
|
104
|
+
plugins: app.plugins,
|
|
105
|
+
projectSchemas: options.projectSchemas,
|
|
106
|
+
projections: options.projections,
|
|
107
|
+
schemaJson: options.schemaJson,
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
/** The contracts of one plugin release. @since 0.0.0 @category registry */
|
|
111
|
+
export interface MaterializedPlugin {
|
|
112
|
+
readonly pluginIdentifier: string;
|
|
113
|
+
readonly pluginVersion: string;
|
|
114
|
+
readonly providers: readonly MaterializedRegistry["providers"][number][];
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Extract a release's contracts without building Layers or running handlers.
|
|
119
|
+
*
|
|
120
|
+
* @since 0.0.0
|
|
121
|
+
* @category registry
|
|
122
|
+
*/
|
|
123
|
+
export const materializePlugin = (
|
|
124
|
+
plugin: Plugin.Any,
|
|
125
|
+
options: MaterializedRegistryOptions & { readonly version: string },
|
|
126
|
+
): MaterializedPlugin => ({
|
|
127
|
+
pluginIdentifier: plugin.identifier,
|
|
128
|
+
pluginVersion: options.version,
|
|
129
|
+
providers: materializeResolvedRegistry({
|
|
130
|
+
aiProviders: [],
|
|
131
|
+
dualIdentifier: plugin.identifier,
|
|
132
|
+
plugins: [{ plugin, version: options.version }],
|
|
133
|
+
projectSchemas: options.projectSchemas,
|
|
134
|
+
projections: options.projections,
|
|
135
|
+
schemaJson: options.schemaJson,
|
|
136
|
+
}).providers,
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
/** Every installed plugin release and its contracts. @since 0.0.0 @category registry */
|
|
140
|
+
export const materializePlugins = (app: AnyApp, options: MaterializedRegistryOptions = {}) => {
|
|
141
|
+
const projections = options.projections ?? new Map<Schema.Top, unknown>();
|
|
142
|
+
return app.plugins.map(installation => ({
|
|
143
|
+
...materializePlugin(installation.plugin, {
|
|
144
|
+
...options,
|
|
145
|
+
projections,
|
|
146
|
+
version: installation.version,
|
|
147
|
+
}),
|
|
148
|
+
ordinal: 0,
|
|
149
|
+
}));
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
export * as DualRegistry from "./DualRegistry.ts";
|